{"version":3,"file":"Switch_1_1.DfcK3NJ_.mjs","names":["React.useState","__esmMin","window","init_npm_react_18_3_1","ce","init_ssg_sandbox_shims","_e","init_jsx_runtime","addPropertyControls","init_framer_DymZktPS","ControlType","Frame","getStoredTheme","useGlobalTapAndCopyDisable","style","ThemeSwitch","isOn","setIsOn","isThemeSet","setIsThemeSet","systemTheme","setSystemTheme","toggle","newToggleState","updateTheme","styleTag","theme","handleSystemThemeChange","storedTheme","circleSize","switchSize","iconSize","backgroundColor","circleColor","iconColor","init_Switch_1_1"],"sources":["https:/framerusercontent.com/modules/1an48kD3lCmOyvwXlp9Z/yfVbGFcCLAsSyG4bFC14/Switch_1_1.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,addPropertyControls,ControlType}from\"framer\";function getStoredTheme(){return localStorage.getItem(\"currentToggleState\");}// ✅ Disable tap highlight, long-press, and text selection globally\nfunction useGlobalTapAndCopyDisable(){React.useEffect(()=>{const style=document.createElement(\"style\");style.innerHTML=`\n            * {\n                -webkit-tap-highlight-color: transparent !important;\n                -webkit-touch-callout: none !important;\n                user-select: none !important;\n            }\n        `;document.head.appendChild(style);return()=>{document.head.removeChild(style);};},[]);}function SystemThemeDetector({onThemeDetected}){const[systemTheme,setSystemTheme]=React.useState(null);const[errorMessage,setErrorMessage]=React.useState(null);React.useEffect(()=>{const darkModeMediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");const handleThemeChange=e=>{const theme=e.matches?\"dark\":\"light\";setSystemTheme(theme);setErrorMessage(null);onThemeDetected(theme);};try{if(darkModeMediaQuery.media===\"not all\"){setErrorMessage(\"System theme detection not supported\");onThemeDetected(null);}else{handleThemeChange(darkModeMediaQuery);darkModeMediaQuery.addListener(handleThemeChange);}}catch(error){setErrorMessage(\"Error detecting system theme\");onThemeDetected(null);}return()=>{darkModeMediaQuery.removeListener(handleThemeChange);};},[onThemeDetected]);return null;}export function ThemeSwitch({backgroundColor,iconColor,switchSize,circleColor}){useGlobalTapAndCopyDisable()// ✅ Disable universal tap highlighting\n;const[isOn,setIsOn]=React.useState(false);const[isThemeSet,setIsThemeSet]=React.useState(false);const[systemTheme,setSystemTheme]=React.useState(null);const toggle=()=>{const newToggleState=isOn?\"dark\":\"light\";setIsOn(!isOn);localStorage.setItem(\"currentToggleState\",newToggleState);updateTheme(newToggleState);};const updateTheme=theme=>{if(typeof document!==\"undefined\"){const styleTag=document.getElementsByTagName(\"style\")[0];const newCSS=styleTag.innerHTML.replace(/prefers-color-scheme: \\w+/,`prefers-color-scheme: ${theme}`);styleTag.innerHTML=newCSS;}window.dispatchEvent(new CustomEvent(\"themeChange\"));};const handleSystemThemeChange=theme=>{setSystemTheme(theme);if(!isThemeSet){setIsOn(theme===\"light\");updateTheme(theme);setIsThemeSet(true);}};React.useEffect(()=>{const storedTheme=getStoredTheme();if(storedTheme){setIsOn(storedTheme===\"light\");updateTheme(storedTheme);setIsThemeSet(true);}else{handleSystemThemeChange(null);}},[]);const circleSize=switchSize/2-switchSize/8;const iconSize=circleSize;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})})})});}ThemeSwitch.defaultProps={backgroundColor:\"#e0e0e0\",iconColor:\"#000000\",switchSize:60,circleColor:\"#ffffff\"};addPropertyControls(ThemeSwitch,{backgroundColor:{title:\"Background Color\",type:ControlType.Color,defaultValue:\"#e0e0e0\"},switchSize:{title:\"Switch Size\",type:ControlType.Number,defaultValue:60,min:20,max:200,step:1},circleColor:{title:\"Circle Color\",type:ControlType.Color,defaultValue:\"#ffffff\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"ThemeSwitch\":{\"type\":\"reactComponent\",\"name\":\"ThemeSwitch\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Switch_1_1.map"],"mappings":"A,iMAAiI,SAASY,GAAgB,CAAC,OAAO,aAAa,QAAQ,oBAAoB,CAAE,CAC7M,SAASC,GAA4B,CAACT,MAAoB,CAAC,IAAMU,EAAM,SAAS,cAAc,OAAO,EAM1D,MAN4D,GAAM,UAAU;;;;;;UAM7G,SAAS,KAAK,YAAYA,CAAK,MAAY,CAAC,SAAS,KAAK,YAAYA,CAAK,CAAE,CAAE,EAAE,CAAC,CAAC,CAAE,CAA0xB,SAAgBC,EAAY,CAAC,kBAAgB,YAAU,aAAW,eAAa,CAACF,EAA2B,EACn+B,GAAK,CAACG,EAAKC,GAASjB,EAAe,EAAK,EAAO,CAACkB,EAAWC,GAAenB,EAAe,EAAK,EAAO,CAACoB,EAAYC,GAAgBrB,EAAe,IAAI,EAAQsB,MAAW,CAAC,IAAMC,EAAeP,EAAK,OAAO,QAAQC,EAAQ,CAACD,CAAI,EAAE,aAAa,QAAQ,qBAAqBO,CAAc,EAAEC,EAAYD,CAAc,CAAE,EAAQC,EAAY,GAAO,CAAC,GAAG,OAAO,SAAW,IAAY,CAAC,IAAMC,EAAS,SAAS,qBAAqB,OAAO,CAAC,CAAC,GAAyG,EAAS,UAAlGA,EAAS,UAAU,QAAQ,4B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