import{o as e,r as t,t as n}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{o as r}from"./app-CXDQ5oEH-1776590214964.js";import{t as i}from"./useTranslation-D1etqd9u-1776590214964.js";var a=n();function o(){let{appSettings:e}=r().props,t=e?.appearance;return t?(0,a.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`
        :root {
            --primary: ${t.light.primary};
            --primary-foreground: ${t.light.primary_fg};
            --radius: ${t.radius};
        }
        .dark {
            --primary: ${t.dark.primary};
            --primary-foreground: ${t.dark.primary_fg};
        }
    `}}):null}var s=e(t(),1),c=(0,s.createContext)();function l({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`}){let[r,i]=(0,s.useState)(()=>localStorage.getItem(n)||t);(0,s.useEffect)(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),r===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t);return}e.classList.add(r)},[r]);let l={theme:r,setTheme:e=>{localStorage.setItem(n,e),i(e)}};return(0,a.jsxs)(c.Provider,{value:l,children:[(0,a.jsx)(o,{}),e]})}var u=()=>{let e=(0,s.useContext)(c),{t}=i();if(e===void 0)throw Error(t(`useTheme must be used within a ThemeProvider`));return e};export{u as n,l as t};