{"version":3,"file":"ThemeSwitcher.BjTLSCnY.mjs","names":["React.useState","React.useRef"],"sources":["https:/framerusercontent.com/modules/n0YqkCoUWrrPIyrd2sLI/Aaxiyyx4MG4eYrBf3Zzz/ThemeSwitcher.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 60\n * @framerIntrinsicHeight 30\n */export default function ThemeSwitch({backgroundColor,iconColor,switchSize,iconPadding,circleColor}){const[isOn,setIsOn]=React.useState(false);const[isThemeSet,setIsThemeSet]=React.useState(false);const tokenMapRef=React.useRef(null);const toggle=()=>{const newTheme=isOn?\"light\":\"dark\";console.log(\"Toggle clicked. New theme:\",newTheme);setIsOn(!isOn);localStorage.setItem(\"currentToggleState\",newTheme);updateTheme(newTheme);};const extractTokenValues=()=>{console.log(\"Extracting token values from stylesheets...\");const tokens={light:{},dark:{}};// Find the body style rules\nfor(const sheet of document.styleSheets){try{for(const rule of sheet.cssRules||[]){if(rule.selectorText===\"body\"&&rule.style){// Get light mode tokens\nfor(let i=0;i<rule.style.length;i++){const prop=rule.style[i];if(prop.startsWith(\"--token-\")){tokens.light[prop]=rule.style.getPropertyValue(prop).trim();}}}// Get dark mode tokens from media query\nif(rule.media&&rule.media.mediaText.includes(\"prefers-color-scheme: dark\")){for(const innerRule of rule.cssRules||[]){if(innerRule.selectorText===\"body\"&&innerRule.style){for(let i=0;i<innerRule.style.length;i++){const prop=innerRule.style[i];if(prop.startsWith(\"--token-\")){tokens.dark[prop]=innerRule.style.getPropertyValue(prop).trim();}}}}}}}catch(e){// CORS issues with external stylesheets - skip\n}}console.log(\"Extracted tokens:\",tokens);return tokens;};const updateTheme=theme=>{console.log(\"Updating theme to:\",theme);if(!tokenMapRef.current){tokenMapRef.current=extractTokenValues();}const tokens=tokenMapRef.current;const sourceTokens=theme===\"dark\"?tokens.dark:tokens.light;console.log(`Applying ${theme} theme with ${Object.keys(sourceTokens).length} tokens`);// Apply tokens directly to body\nfor(const[key,value]of Object.entries(sourceTokens)){document.body.style.setProperty(key,value);}console.log(\"Theme applied\");};React.useEffect(()=>{const storedTheme=localStorage.getItem(\"currentToggleState\");console.log(\"Stored theme:\",storedTheme);if(storedTheme){setIsOn(storedTheme===\"dark\");updateTheme(storedTheme);}else{const darkModeMediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");const systemTheme=darkModeMediaQuery.matches?\"dark\":\"light\";console.log(\"System theme:\",systemTheme);setIsOn(systemTheme===\"dark\");}setIsThemeSet(true);},[]);const circleSize=switchSize/2-switchSize/8;const iconSize=circleSize-iconPadding*2;return /*#__PURE__*/_jsx(Frame,{width:switchSize,height:switchSize/2,background:backgroundColor,style:{borderRadius:switchSize/4,cursor:\"pointer\",position:\"relative\",display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",padding:`0 ${switchSize/8}px`},onClick:toggle,children:isThemeSet&&/*#__PURE__*/_jsx(Frame,{width:circleSize,height:circleSize,background:circleColor,style:{borderRadius:\"50%\",position:\"absolute\",left:isOn?`calc(100% - ${circleSize+switchSize/16}px)`:`${switchSize/16}px`,transition:\"left 0.2s\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},initial:false,animate:{left:isOn?`calc(100% - ${circleSize+switchSize/16}px)`:`${switchSize/16}px`},children:/*#__PURE__*/_jsx(Frame,{width:iconSize,height:iconSize,background:\"transparent\",style:{overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",viewBox:\"0 0 24 24\",fill:iconColor,width:iconSize,height:iconSize,children:/*#__PURE__*/_jsx(\"path\",{d:\"M12 21.9967C6.47715 21.9967 2 17.5196 2 11.9967C2 6.47386 6.47715 1.9967 12 1.9967C17.5228 1.9967 22 6.47386 22 11.9967C22 17.5196 17.5228 21.9967 12 21.9967ZM12 19.9967C16.4183 19.9967 20 16.415 20 11.9967C20 7.57843 16.4183 3.9967 12 3.9967C7.58172 3.9967 4 7.57843 4 11.9967C4 16.415 7.58172 19.9967 12 19.9967ZM12 17.9967V5.9967C15.3137 5.9967 18 8.683 18 11.9967C18 15.3104 15.3137 17.9967 12 17.9967Z\"})})})})});}ThemeSwitch.defaultProps={backgroundColor:\"#e0e0e0\",iconColor:\"#000000\",switchSize:60,iconPadding:4,circleColor:\"#ffffff\"};addPropertyControls(ThemeSwitch,{backgroundColor:{title:\"Background Color\",type:ControlType.Color,defaultValue:\"#e0e0e0\"},iconColor:{title:\"Icon Color\",type:ControlType.Color,defaultValue:\"#000000\"},switchSize:{title:\"Switch Size\",type:ControlType.Number,defaultValue:60,min:20,max:200,step:1},iconPadding:{title:\"Icon Padding\",type:ControlType.Number,defaultValue:4,min:0,max:20,step:1},circleColor:{title:\"Circle Color\",type:ControlType.Color,defaultValue:\"#ffffff\",description:\"This component will only work when you publish your site, not inside Framer preview \\n2.0 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ThemeSwitch\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"60\",\"framerSupportedLayoutWidth\":\"any\",\"framerIntrinsicHeight\":\"30\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ThemeSwitcher.map"],"mappings":"6MAOG,SAAwB,EAAY,CAAC,kBAAgB,YAAU,aAAW,cAAY,eAAa,CAAC,GAAK,CAAC,EAAK,GAASA,EAAe,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAe,GAAM,CAAO,EAAYC,EAAa,KAAK,CAAO,MAAW,CAAC,IAAM,EAAS,EAAK,QAAQ,OAAO,QAAQ,IAAI,6BAA6B,EAAS,CAAC,EAAQ,CAAC,EAAK,CAA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