import{C as B,a as _,m as L,n as Q}from"/build/_shared/chunk-XIQ3C74K.js";import{b as u,e as R}from"/build/_shared/chunk-G5WX4PPA.js";var A=u(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.useBroadcastChannel=void 0;var C=_();function F(e,n,i){let r=(0,C.useRef)(typeof window<"u"&&"BroadcastChannel"in window?new BroadcastChannel(e+"-channel"):null);return O(r,"message",n),O(r,"messageerror",i),(0,C.useCallback)(o=>{var a;(a=r?.current)===null||a===void 0||a.postMessage(o)},[r])}f.useBroadcastChannel=F;function O(e,n,i=()=>{}){(0,C.useEffect)(()=>{let r=e.current;if(r)return r.addEventListener(n,i),()=>r.removeEventListener(n,i)},[e,n,i])}});var S=u(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.useCorrectCssTransition=void 0;var W=_();function H(e){let n=document.createElement("style");n.appendChild(document.createTextNode(`* {
       -webkit-transition: none !important;
       -moz-transition: none !important;
       -o-transition: none !important;
       -ms-transition: none !important;
       transition: none !important;
    }`)),document.head.appendChild(n),e(),setTimeout(()=>{let i=window.getComputedStyle(n).transition;document.head.removeChild(n)},0)}function I({disableTransitions:e=!1}={}){return(0,W.useCallback)(n=>{e?H(()=>{n()}):n()},[e])}T.useCorrectCssTransition=I});var v=u(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isTheme=t.useTheme=t.PreventFlashOnWrongTheme=t.ThemeProvider=t.mediaQuery=t.themes=t.Theme=void 0;var h=B(),c=_(),N=A(),D=S(),m;(function(e){e.DARK="dark",e.LIGHT="light"})(m=t.Theme||(t.Theme={}));t.themes=Object.values(m);var P=(0,c.createContext)(void 0);P.displayName="ThemeContext";var b="(prefers-color-scheme: light)",G=()=>window.matchMedia(b).matches?m.LIGHT:m.DARK;t.mediaQuery=typeof window<"u"?window.matchMedia(b):null;function K({children:e,specifiedTheme:n,themeAction:i,disableTransitionOnThemeChange:r=!1}){let o=(0,D.useCorrectCssTransition)({disableTransitions:r}),[a,y]=(0,c.useState)(()=>n?t.themes.includes(n)?n:null:typeof window!="object"?null:G()),w=(0,c.useRef)(!1),j=(0,N.useBroadcastChannel)("remix-themes",l=>{o(()=>{y(l.data)})});return(0,c.useEffect)(()=>{if(!w.current){w.current=!0;return}a&&(fetch(`${i}`,{method:"POST",body:JSON.stringify({theme:a})}),o(()=>{j(a)}))},[j,a,i,o]),(0,c.useEffect)(()=>{let l=M=>{o(()=>{y(M.matches?m.LIGHT:m.DARK)})};return t.mediaQuery===null||t.mediaQuery===void 0||t.mediaQuery.addEventListener("change",l),()=>t.mediaQuery===null||t.mediaQuery===void 0?void 0:t.mediaQuery.removeEventListener("change",l)},[o]),(0,h.jsx)(P.Provider,{value:[a,y],children:e})}t.ThemeProvider=K;var $=`
(() => {
  const theme = window.matchMedia(${JSON.stringify(b)}).matches
    ? 'light'
    : 'dark';
  
  const cl = document.documentElement.classList;
  const dataAttr = document.documentElement.dataset.theme;

  if (dataAttr != null) {
    const themeAlreadyApplied = dataAttr === 'light' || dataAttr === 'dark';
    if (!themeAlreadyApplied) {
      document.documentElement.dataset.theme = theme;
    }
  } else {
    const themeAlreadyApplied = cl.contains('light') || cl.contains('dark');
    if (!themeAlreadyApplied) {
      cl.add(theme);
    }
  }
  
  const meta = document.querySelector('meta[name=color-scheme]');
  if (meta) {
    if (theme === 'dark') {
      meta.content = 'dark light';
    } else if (theme === 'light') {
      meta.content = 'light dark';
    }
  }
})();
`;function J({ssrTheme:e,nonce:n}){let[i]=E();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("meta",{name:"color-scheme",content:i==="light"?"light dark":"dark light"}),e?null:(0,h.jsx)("script",{dangerouslySetInnerHTML:{__html:$},nonce:n})]})}t.PreventFlashOnWrongTheme=J;function E(){let e=(0,c.useContext)(P);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e}t.useTheme=E;function z(e){return typeof e=="string"&&t.themes.includes(e)}t.isTheme=z});var k=u(g=>{"use strict";Object.defineProperty(g,"__esModule",{value:!0});g.createThemeSessionResolver=void 0;var V=v(),U=e=>async i=>{let r=await e.getSession(i.headers.get("Cookie"));return{getTheme:()=>{let o=r.get("theme");return(0,V.isTheme)(o)?o:null},setTheme:o=>r.set("theme",o),commit:()=>e.commitSession(r)}};g.createThemeSessionResolver=U});var x=u(p=>{"use strict";Object.defineProperty(p,"__esModule",{value:!0});p.createThemeAction=void 0;var q=(Q(),R(L)),X=v(),Y=e=>async({request:i})=>{let r=await e(i),{theme:o}=await i.json();if(!(0,X.isTheme)(o)){let a=o?`theme value of ${o} is not a valid theme.`:"empty theme provided";return(0,q.json)({success:!1,message:a})}return r.setTheme(o),(0,q.json)({success:!0},{headers:{"Set-Cookie":await r.commit()}})};p.createThemeAction=Y});var te=u(s=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.createThemeAction=s.PreventFlashOnWrongTheme=s.isTheme=s.Theme=s.themes=s.useTheme=s.ThemeProvider=s.createThemeSessionResolver=void 0;var Z=k();Object.defineProperty(s,"createThemeSessionResolver",{enumerable:!0,get:function(){return Z.createThemeSessionResolver}});var d=v();Object.defineProperty(s,"ThemeProvider",{enumerable:!0,get:function(){return d.ThemeProvider}});Object.defineProperty(s,"useTheme",{enumerable:!0,get:function(){return d.useTheme}});Object.defineProperty(s,"themes",{enumerable:!0,get:function(){return d.themes}});Object.defineProperty(s,"Theme",{enumerable:!0,get:function(){return d.Theme}});Object.defineProperty(s,"isTheme",{enumerable:!0,get:function(){return d.isTheme}});Object.defineProperty(s,"PreventFlashOnWrongTheme",{enumerable:!0,get:function(){return d.PreventFlashOnWrongTheme}});var ee=x();Object.defineProperty(s,"createThemeAction",{enumerable:!0,get:function(){return ee.createThemeAction}})});export{te as a};
