{"version":3,"file":"ThemeSwitcher.CP6BAxUr.mjs","names":[],"sources":["https:/framerusercontent.com/modules/wi2HIkvFUB82jpdwKHB3/jNJaKs1xdx4aYcrrgls6/ThemeSwitcher.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect}from\"react\";const changeTheme=theme=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const htmlElement=document.getElementsByTagName(\"html\")[0];const bodyElement=document.getElementsByTagName(\"body\")[0];htmlElement.setAttribute(\"toggle-theme\",theme);bodyElement.setAttribute(\"toggle-theme\",theme);localStorage.setItem(\"theme\",theme);const event=new Event(\"themeChange\");window.dispatchEvent(event);};function extractAndApplyThemeTokens(){if(typeof document===\"undefined\")return;let lightThemeTokens=[];let darkThemeTokens=\"\";for(let i=0;i<document.styleSheets.length;i++){const sheet=document.styleSheets[i];try{// @ts-ignore\nconst rules=sheet.cssRules||[];for(let k=0;k<rules.length;k++){const rule=rules[k];if(\"selectorText\"in rule&&rule.selectorText===\"body\"){const style=rule.style;for(let j=0;j<style.length;j++){const propertyName=style[j];if(propertyName.includes(\"--token\")){const value=style.getPropertyValue(propertyName);const combinedCssRule=`${propertyName}: ${value};`;lightThemeTokens.push(combinedCssRule);}}}else if(\"conditionText\"in rule&&rule.conditionText===\"(prefers-color-scheme: dark)\"){// @ts-ignore\nconst cssRules=rule.cssRules||[];if(cssRules.length>0){// @ts-ignore\nlet mediaRulesString=cssRules[0].cssText;mediaRulesString=mediaRulesString.replace(\"body\",\"\").replace(/\\s*{\\s*/,\"\").replace(/\\s*}\\s*$/,\"\");darkThemeTokens=mediaRulesString;}}}}catch(e){// Cannot access stylesheet (cross-origin)\n}}// Remove existing style element if it exists\nconst existingStyleElement=document.getElementById(\"toggle-theme\");if(existingStyleElement){document.head.removeChild(existingStyleElement);}// Create new style element with theme tokens\nconst styleElement=document.createElement(\"style\");styleElement.id=\"toggle-theme\";const customCssRule=`body[toggle-theme=\"light\"] {${lightThemeTokens.join(\" \")}} body[toggle-theme=\"dark\"]{${darkThemeTokens}} html[toggle-theme=\"light\"] { color-scheme: light; } html[toggle-theme=\"dark\"] { color-scheme: dark; }`;styleElement.textContent=customCssRule;document.head.appendChild(styleElement);}/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 1\n * @framerIntrinsicHeight 1\n * @framerDisableUnlink\n */export default function ThemeSwitcher(props){const{theme=\"light\"}=props;// Initialize theme tokens extraction on mount (only once)\nuseEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;// Extract CSS tokens and create style element\nextractAndApplyThemeTokens();// Cleanup function\nreturn()=>{const existingStyleElement=document.getElementById(\"toggle-theme\");if(existingStyleElement){document.head.removeChild(existingStyleElement);}const htmlElement=document.getElementsByTagName(\"html\")[0];const bodyElement=document.getElementsByTagName(\"body\")[0];htmlElement.setAttribute(\"toggle-theme\",\"system\");bodyElement.setAttribute(\"toggle-theme\",\"system\");};},[]);// Apply theme when prop changes\nuseEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;changeTheme(theme);},[theme]);// Return invisible component\nreturn /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"absolute\",width:1,height:1,opacity:0,pointerEvents:\"none\"}});}ThemeSwitcher.defaultProps={theme:\"light\"};addPropertyControls(ThemeSwitcher,{theme:{type:ControlType.Enum,title:\"Theme\",options:[\"light\",\"dark\"],optionTitles:[\"Light\",\"Dark\"],defaultValue:\"light\",displaySegmentedControl:true}});ThemeSwitcher.displayName=\"Dark/Light Mode Toggle\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ThemeSwitcher\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\",\"framerIntrinsicWid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