import{Bt as e,J as t,Xn as n}from"./dist-CoD0k1Bd.js";function r(e){if(!(typeof window>`u`)){if(e===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;document.documentElement.classList.toggle(`dark`,e===`dark`)}else document.documentElement.classList.toggle(`dark`,e===`dark`)}}var i=(e,t,n=365)=>{if(typeof document>`u`)return;let r=n*24*60*60;document.cookie=`${e}=${t};path=/;max-age=${r};SameSite=Lax`},a=()=>typeof window>`u`?null:window.matchMedia(`(prefers-color-scheme: dark)`),o=()=>typeof window>`u`?null:localStorage.getItem(`appearance`),s=()=>typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches,c=()=>{r(o()||`system`)};function l(){typeof window>`u`||(r(o()||`system`),a()?.addEventListener(`change`,c))}var u=n(`system`);function d(){e(()=>{let e=localStorage.getItem(`appearance`);e&&(u.value=e)});let n=t(()=>u.value===`system`?s()?`dark`:`light`:u.value);function a(e){u.value=e,localStorage.setItem(`appearance`,e),i(`appearance`,e),r(e)}return{appearance:u,resolvedAppearance:n,updateAppearance:a}}export{d as n,l as t};