import Foundation

enum AppIdentifiers {
    // Read from Info.plist (values come from xcconfig)
    static let publicAppName: String = {
        Bundle.main.object(forInfoDictionaryKey: "PublicAppName") as? String
            ?? "SelfieCam"
    }()

    static let appGroupIdentifier: String = {
        Bundle.main.object(forInfoDictionaryKey: "AppGroupIdentifier") as? String
            ?? "group.com.mbrucedogs.SelfieCam"
    }()
    
    static let cloudKitContainerIdentifier: String = {
        Bundle.main.object(forInfoDictionaryKey: "CloudKitContainerIdentifier") as? String
            ?? "iCloud.com.mbrucedogs.SelfieCam"
    }()
    
    static let appClipDomain: String = {
        Bundle.main.object(forInfoDictionaryKey: "AppClipDomain") as? String
            ?? "yourapp.example.com"
    }()
    
    // Derived from bundle identifier
    static var bundleIdentifier: String {
        Bundle.main.bundleIdentifier ?? "com.mbrucedogs.SelfieCam"
    }
    
    static var watchBundleIdentifier: String {
        "\(bundleIdentifier).watchkitapp"
    }
    
    static var appClipBundleIdentifier: String {
        "\(bundleIdentifier).Clip"
    }
    
    static var widgetBundleIdentifier: String {
        "\(bundleIdentifier).Widget"
    }
    
    static func appClipURL(recordName: String) -> URL? {
        URL(string: "https://\(appClipDomain)/appclip?id=\(recordName)")
    }
}
