{"version":3,"file":"ThemeToggle.DuErRIPG.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/9LRjLU8WhBqgqcaDzwG2/bgmF4Cwvx5Fs7HBohfwW/ThemeToggle.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";function getOSTheme(){if(typeof window!==\"undefined\"&&typeof document!==\"undefined\"){return window.matchMedia&&window.matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";}return\"light\";}function setInitialState(){const osTheme=getOSTheme();const currentToggleState=localStorage.getItem(\"currentToggleState\")||(osTheme===\"dark\"?\"dark\":\"light\");localStorage.setItem(\"currentToggleState\",currentToggleState);if(typeof document!==\"undefined\"){const styleTag=document.getElementsByTagName(\"style\")[0];const newCSS=styleTag.innerHTML.replace(/prefers-color-scheme: \\w+/,`prefers-color-scheme: ${currentToggleState===\"dark\"&&osTheme===\"dark\"||currentToggleState===\"light\"&&osTheme===\"light\"?\"dark\":\"light\"}`);styleTag.innerHTML=newCSS;}return currentToggleState===\"dark\";}export function themeSwictherBasedOnSystem(Component){return props=>{const[isOn,setIsOn]=useState(setInitialState());const toggle=()=>{const newToggleState=!isOn?\"dark\":\"light\";setIsOn(!isOn);localStorage.setItem(\"currentToggleState\",newToggleState);if(typeof window!==\"undefined\"){window.dispatchEvent(new CustomEvent(\"themeChange\"));}};useEffect(()=>{if(typeof window!==\"undefined\"){const mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");mediaQuery.addListener(e=>{const newTheme=e.matches?\"dark\":\"light\";localStorage.setItem(\"currentOsTheme\",newTheme);localStorage.setItem(\"currentToggleState\",newTheme);setIsOn(newTheme===\"dark\");if(typeof document!==\"undefined\"){const styleTag=document.getElementsByTagName(\"style\")[0];const newCSS=styleTag.innerHTML.replace(/prefers-color-scheme: \\w+/,`prefers-color-scheme: ${newTheme===\"dark\"&&newTheme===\"dark\"||newTheme===\"light\"&&newTheme===\"light\"?\"dark\":\"light\"}`);styleTag.innerHTML=newCSS;}window.dispatchEvent(new CustomEvent(\"themeChange\"));});}},[]);useEffect(()=>{if(typeof window!==\"undefined\"&&typeof document!==\"undefined\"){const currentToggleState=isOn?\"dark\":\"light\";const currentOsTheme=localStorage.getItem(\"currentOsTheme\")||getOSTheme();const styleTag=document.getElementsByTagName(\"style\")[0];const newCSS=styleTag.innerHTML.replace(/prefers-color-scheme: \\w+/,`prefers-color-scheme: ${currentToggleState===\"dark\"&&currentOsTheme===\"dark\"||currentToggleState===\"light\"&&currentOsTheme===\"light\"?\"dark\":\"light\"}`);styleTag.innerHTML=newCSS;localStorage.setItem(\"currentToggleState\",currentToggleState);}},[isOn]);const[isClient,setIsClient]=useState(false);useEffect(()=>{setIsClient(true);},[]);return /*#__PURE__*/_jsx(Component,{...props,onClick:toggle});};}\nexport const __FramerMetadata__ = {\"exports\":{\"themeSwictherBasedOnSystem\":{\"type\":\"reactHoc\",\"name\":\"themeSwictherBasedOnSystem\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ThemeToggle.map"],"mappings":"2MAAiF,SAAS,GAAY,CAAoK,OAAzJ,IAAS,QAAa,OAAO,SAAW,KAAoB,EAAO,YAAY,EAAO,WAAW,+BAA+B,CAAC,QAAQ,OAAO,QAAwB,SAAS,GAAiB,CAAC,IAAM,EAAQ,GAAY,CAAO,EAAmB,aAAa,QAAQ,qBAAqB,GAAG,IAAU,OAAO,OAAO,SAAuE,GAA9D,aAAa,QAAQ,qBAAqB,EAAmB,CAAI,OAAO,SAAW,IAAY,CAAC,IAAM,EAAS,SAAS,qBAAqB,QAAQ,CAAC,GAAiN,EAAS,UAA1M,EAAS,UAAU,QAAQ,4BAA4B,yBAAyB,IAAqB,QAAQ,IAAU,QAAQ,IAAqB,SAAS,IAAU,QAAQ,OAAO,UAAU,CAA4B,OAAO,IAAqB,OAAQ,SAAgB,EAA2B,EAAU,CAAC,MAAO,IAAO,CAAC,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