using System;

namespace Davanci.Nexus
{
    // Splash / boot gate: tracks the one-time permissions flow (CMP → ATT → notifications)
    // and signals when Nexus startup is safe to leave the splash scene.
    public static class NexusStartup
    {
        public const string PermissionsCompleteKey = "nexus_permissions_complete";

        public static bool HasCompletedPermissionsFlow =>
            UnityEngine.PlayerPrefs.GetInt(PermissionsCompleteKey, 0) == 1;

        public static bool IsStartupComplete { get; private set; }

        public static event Action StartupComplete;

        internal static void MarkStartupComplete()
        {
            if (IsStartupComplete) return;

            IsStartupComplete = true;
            UnityEngine.PlayerPrefs.SetInt(PermissionsCompleteKey, 1);
            UnityEngine.PlayerPrefs.Save();
            StartupComplete?.Invoke();
            UnityEngine.Debug.Log("[Nexus] Startup complete — splash may proceed.");
        }
    }
}
