{"version":3,"file":"ThemeSwitcher.B96BMPeg.mjs","names":["useState","useCallback","__legacyOverrideHOC_DataObserverContext","_jsx","useLayoutEffect","useEffect"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/gMofebSEyMcVTlUZTex0/qIB6wGaxWbnPYnMvM9jT/ThemeSwitcher.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{startTransition,useCallback,useLayoutEffect,useEffect}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const isBrowser=typeof window!==\"undefined\"&&typeof document!==\"undefined\";const STORAGE_KEY=\"theme\";const STYLE_ID=\"toggle-theme\";const THEME_EVENT=\"toggle-theme-change\";let hasInitializedTheme=false;let pendingBodyTheme=null;let hasBodyReadyListener=false;const getInitialTheme=()=>{return\"dark\";};const useStore=createStore({theme:getInitialTheme()});let cachedLightTokens=\"\";let cachedDarkTokens=\"\";let hasExtractedTokens=false;const resolveSystemTheme=()=>{return\"dark\";};const resolveThemeFromPreference=preference=>{return\"dark\";};const readActiveTheme=()=>{return\"dark\";};const ensureBodyThemeAttribute=theme=>{if(!isBrowser)return;const body=document.body;if(body){body.setAttribute(\"toggle-theme\",theme);pendingBodyTheme=null;return;}pendingBodyTheme=theme;if(hasBodyReadyListener)return;hasBodyReadyListener=true;const applyPendingTheme=()=>{const nextBody=document.body;if(nextBody&&pendingBodyTheme){nextBody.setAttribute(\"toggle-theme\",pendingBodyTheme);pendingBodyTheme=null;}hasBodyReadyListener=false;};if(document.readyState===\"loading\"){document.addEventListener(\"DOMContentLoaded\",applyPendingTheme,{once:true});}else{queueMicrotask(applyPendingTheme);}};const applyTheme=(theme,preference)=>{if(!isBrowser)return;const html=document.documentElement;html.setAttribute(\"toggle-theme\",theme);ensureBodyThemeAttribute(theme);localStorage.setItem(STORAGE_KEY,preference);window.dispatchEvent(new CustomEvent(THEME_EVENT,{detail:{theme,preference}}));};const initializeThemeSync=()=>{if(!isBrowser||hasInitializedTheme)return;hasInitializedTheme=true;applyTheme(\"dark\",\"dark\");};const extractTokensOnce=()=>{if(!isBrowser||hasExtractedTokens)return;const lightTokens=[];let darkTokens=[];for(const sheet of document.styleSheets){try{for(const rule of sheet.cssRules){if(rule instanceof CSSStyleRule&&rule.selectorText===\"body\"){for(let i=0;i<rule.style.length;i++){const name=rule.style[i];if(name.includes(\"--token\")){const value=rule.style.getPropertyValue(name);lightTokens.push(`${name}: ${value};`);}}}if(rule instanceof CSSMediaRule&&rule.conditionText.includes(\"prefers-color-scheme: dark\")){const css=rule.cssRules?.[0]?.cssText??\"\";darkTokens=css.replace(\"body\",\"\").replace(/{|}/g,\"\").split(\";\").map(s=>s.trim()+\";\").filter(Boolean);}}}catch{// skip CORS-protected stylesheets\n}}cachedLightTokens=lightTokens.join(\" \");cachedDarkTokens=darkTokens.join(\" \");hasExtractedTokens=true;};const injectThemeStyle=()=>{if(!isBrowser)return;document.getElementById(STYLE_ID)?.remove();const style=document.createElement(\"style\");style.id=STYLE_ID;style.textContent=`\n        body[toggle-theme=\"light\"] { ${cachedLightTokens} }\n        body[toggle-theme=\"dark\"]  { ${cachedDarkTokens} }\n        html[toggle-theme=\"light\"] { color-scheme: light; }\n        html[toggle-theme=\"dark\"]  { color-scheme: dark; }\n    `;document.head.appendChild(style);};const syncThemeFromStorage=()=>{if(!isBrowser)return;applyTheme(\"dark\",\"dark\");};const useIsomorphicLayoutEffect=isBrowser?useLayoutEffect:useEffect;initializeThemeSync();export function useSingleToggle(){const[,setStore]=useStore();const resolvedTheme=\"dark\";useIsomorphicLayoutEffect(()=>{extractTokensOnce();injectThemeStyle();applyTheme(\"dark\",\"dark\");startTransition(()=>setStore({theme:\"dark\"}));},[setStore]);const handleClick=useCallback(()=>{startTransition(()=>setStore({theme:\"dark\"}));applyTheme(\"dark\",\"dark\");},[setStore]);return{onClick:handleClick,variant:\"Dark\",role:\"button\",\"aria-pressed\":true};}export function withGlobalThemeManager(){useIsomorphicLayoutEffect(()=>{extractTokensOnce();injectThemeStyle();syncThemeFromStorage();},[]);return{};}export function withGlobalThemeVariantSync(){return{variant:\"dark\"};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withuseSingleToggle(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...useSingleToggle(props)});};}withuseSingleToggle.displayName=\"useSingleToggle\";export function withwithGlobalThemeManager(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...withGlobalThemeManager(props)});};}withwithGlobalThemeManager.displayName=\"withGlobalThemeManager\";export function withwithGlobalThemeVariantSync(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...withGlobalThemeVariantSync(props)});};}withwithGlobalThemeVariantSync.displayName=\"withGlobalThemeVariantSync\";\nexport const __FramerMetadata__ = {\"exports\":{\"withuseSingleToggle\":{\"type\":\"reactHoc\",\"name\":\"withuseSingleToggle\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withwithGlobalThemeManager\":{\"type\":\"reactHoc\",\"name\":\"withwithGlobalThemeManager\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withwithGlobalThemeVariantSync\":{\"type\":\"reactHoc\",\"name\":\"withwithGlobalThemeVariantSync\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGlobalThemeManager\":{\"type\":\"override\",\"name\":\"withGlobalThemeManager\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withGlobalThemeVariantSync\":{\"type\":\"override\",\"name\":\"withGlobalThemeVariantSync\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSingleToggle\":{\"type\":\"override\",\"name\":\"useSingleToggle\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ThemeSwitcher.map"],"mappings":"mOAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,CA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