//
//  SettingsState.swift
//  BusinessCard
//
//  Observable state for app settings.
//

import Foundation
import Observation

@Observable
@MainActor
final class SettingsState {
    
    // MARK: - App Info
    
    /// The app's display name.
    var appName: String {
        Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String
            ?? Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String
            ?? "BusinessCard"
    }
    
    /// The app's version string (e.g., "1.0.0").
    var appVersion: String {
        Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.0"
    }
    
    /// The app's build number.
    var buildNumber: String {
        Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "1"
    }
    
    /// Combined version and build string for display.
    var versionString: String {
        "Version \(appVersion) (\(buildNumber))"
    }
    
    // MARK: - Debug Settings
    
    #if DEBUG
    /// Debug-only: Simulates premium being unlocked for testing.
    var isDebugPremiumEnabled: Bool {
        get { UserDefaults.standard.bool(forKey: "debugPremiumEnabled") }
        set { UserDefaults.standard.set(newValue, forKey: "debugPremiumEnabled") }
    }
    #endif
    
    // MARK: - Initialization
    
    init() {}
}
