#if UNITY_EDITOR
using System;
using System.IO;
using UnityEditor;
using UnityEngine;

namespace lilToon
{
    public class lilConstants
    {
        public static string currentVersionName = Version.version;
        public const int currentVersionValue = 45;
        internal static lilToonInspector.lilToonVersion version = null;
        internal static lilToonInspector.lilToonVersion Version => GetFromPackage();
        private static lilToonInspector.lilToonVersion GetFromPackage()
        {
            if (version == null)
            {
                var v = new lilToonInspector.lilToonVersion();
                try
                {
                    EditorJsonUtility.FromJsonOverwrite(File.ReadAllText(lilDirectoryManager.GetPackageJsonPath()), v);
                    v.semver = new SemVerParser(v.version);
                    version = v;
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                    Debug.Log("[lilToon] GetFromPackage() failed");

                    v.version = "0.0.0";
                    v.semver = new SemVerParser(v.version);
                    return v;
                }
            }
            return version;
        }

        internal const string boothURL = "https://lilxyzw.booth.pm/";
        internal const string githubURL = "https://github.com/lilxyzw/lilToon";
        internal const string versionInfoURL = "https://raw.githubusercontent.com/lilxyzw/lilToon/refs/heads/master/Assets/lilToon/package.json";

        internal static readonly string[] mainTexCheckWords = new[] {"mask", "shadow", "shade", "outline", "normal", "bumpmap", "matcap", "rimlight", "emittion", "reflection", "specular", "roughness", "smoothness", "metallic", "metalness", "opacity", "parallax", "displacement", "height", "ambient", "occlusion"};

        public static readonly Vector2 defaultTextureOffset = new Vector2(0.0f,0.0f);
        public static readonly Vector2 defaultTextureScale = new Vector2(1.0f,1.0f);
        public static readonly Vector4 defaultScrollRotate = new Vector4(0.0f,0.0f,0.0f,0.0f);
        public static readonly Vector4 defaultHSVG = new Vector4(0.0f,1.0f,1.0f,1.0f);
        public static readonly Vector4 defaultKeys = new Vector4(0.0f,0.0f,0.0f,0.0f);
        public static readonly Vector4 defaultDecalAnim = new Vector4(1.0f,1.0f,1.0f,30.0f);
        public static readonly Vector4 defaultDissolveParams = new Vector4(0.0f,0.0f,0.5f,0.1f);
        public static readonly Vector4 defaultDistanceFadeParams = new Vector4(0.1f,0.01f,0.0f,0.0f);
        public static readonly Color lineColor = EditorGUIUtility.isProSkin ? new Color(0.35f,0.35f,0.35f,1.0f) : new Color(0.4f,0.4f,0.4f,1.0f);
    }
}
#endif