import AppIntents
import Foundation
import SwiftUI

public struct CreateIntentsPackage: AppIntentsPackage {}

public struct CreateClipWithTextIntent: AppIntent, Sendable {
    public static let title: LocalizedStringResource = LocalizedStringResource("create_clip_with_text_intent_title", table: "CreateAppShortcutsAndIntents")

    public static let description = IntentDescription(
        LocalizedStringResource("create_clip_with_text_intent_description", table: "CreateAppShortcutsAndIntents"),
        categoryName: LocalizedStringResource("create_clip_intent_category", table: "CreateAppShortcutsAndIntents")
    )

    public static let openAppWhenRun: Bool = true

    public init() {}

    @MainActor
    public func perform() async throws -> some IntentResult {
        let urlString = "suno://create-text"
        let url = URL(string: urlString)
        if let url = url {
            await UIApplication.shared.open(url)
        }
        return .result()
    }
}

public struct CreateClipWithAudioIntent: AppIntent, Sendable {
    public static let title: LocalizedStringResource = LocalizedStringResource("create_clip_with_audio_intent_title", table: "CreateAppShortcutsAndIntents")

    public static let description = IntentDescription(
        LocalizedStringResource("create_clip_with_audio_intent_description", table: "CreateAppShortcutsAndIntents"),
        categoryName: LocalizedStringResource("create_clip_intent_category", table: "CreateAppShortcutsAndIntents")
    )

    public static let openAppWhenRun: Bool = true

    public init() {}

    @MainActor
    public func perform() async throws -> some IntentResult {
        let urlString = "suno://create-audio"
        let url = URL(string: urlString)
        if let url = url {
            await UIApplication.shared.open(url)
        }
        return .result()
    }
}

public struct CreateClipWithCameraIntent: AppIntent, Sendable {
    public static let title: LocalizedStringResource = LocalizedStringResource("create_clip_with_camera_intent_title", table: "CreateAppShortcutsAndIntents")

    public static let description = IntentDescription(
        LocalizedStringResource("create_clip_with_camera_intent_description", table: "CreateAppShortcutsAndIntents"),
        categoryName: LocalizedStringResource("create_clip_intent_category", table: "CreateAppShortcutsAndIntents")
    )

    public static let openAppWhenRun: Bool = true

    public init() {}

    @MainActor
    public func perform() async throws -> some IntentResult {
        let urlString = "suno://create-camera"
        let url = URL(string: urlString)
        if let url = url {
            await UIApplication.shared.open(url)
        }
        return .result()
    }
}
