{"version":3,"file":"Light_Dark_Button.DOKGuSW8.mjs","names":["useState","useRef","e"],"sources":["https:/framerusercontent.com/modules/BMvMsvOJYM8jpDNH7rBF/DqdvkRjmQPSURhhMc2e8/Light_Dark_Button.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useState,useRef}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */// Phosphor Sun Icon (Light Mode) - Regular weight\nconst SunIcon=({color,size=20,...props})=>/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:size,height:size,fill:color,viewBox:\"0 0 256 256\",...props,children:/*#__PURE__*/_jsx(\"path\",{d:\"M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z\"})});// Phosphor Moon Icon (Dark Mode) - Regular weight\nconst MoonIcon=({color,size=20,...props})=>/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:size,height:size,fill:color,viewBox:\"0 0 256 256\",...props,children:/*#__PURE__*/_jsx(\"path\",{d:\"M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56A104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z\"})});// Browser compatibility helpers\nfunction hasLocalStorageSupport(){try{if(typeof Storage===\"undefined\"||typeof window.localStorage===\"undefined\"){return false;}const test=\"__localStorage_test__\";localStorage.setItem(test,\"test\");localStorage.removeItem(test);return true;}catch(e){return false;}}function hasMatchMediaSupport(){return typeof window!==\"undefined\"&&typeof window.matchMedia===\"function\";}function getSystemTheme(){if(!hasMatchMediaSupport()){return\"light\";}try{return window.matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";}catch(e){return\"light\";}}// Cross-browser event handling\nfunction addMediaQueryListener(mediaQuery,handler){if(!mediaQuery)return()=>{};if(typeof mediaQuery.addListener===\"function\"){mediaQuery.addListener(handler);return()=>{if(typeof mediaQuery.removeListener===\"function\"){mediaQuery.removeListener(handler);}};}else if(typeof mediaQuery.addEventListener===\"function\"){mediaQuery.addEventListener(\"change\",handler);return()=>mediaQuery.removeEventListener(\"change\",handler);}return()=>{};}// Cross-browser custom event dispatch\nfunction dispatchCustomEvent(eventName,detail){if(typeof window===\"undefined\")return;let event;try{// Modern browsers\nevent=new CustomEvent(eventName,{detail});}catch(e){// IE/older browsers\ntry{event=document.createEvent(\"CustomEvent\");event.initCustomEvent(eventName,false,false,detail);}catch(e2){// Fallback for very old browsers\nevent=document.createEvent(\"Event\");event.initEvent(eventName,false,false);event.detail=detail;}}if(event&&window.dispatchEvent){window.dispatchEvent(event);}}function disableTransitions(){if(typeof document===\"undefined\")return null;try{const css=document.createElement(\"style\");css.type=\"text/css\";const cssText=`\n            * {\n                -webkit-transition: none !important;\n                -moz-transition: none !important;\n                -o-transition: none !important;\n                -ms-transition: none !important;\n                transition: none !important;\n            }\n        `;// Cross-browser text content setting\nif(css.styleSheet){// IE\ncss.styleSheet.cssText=cssText;}else{// Modern browsers\ncss.appendChild(document.createTextNode(cssText));}if(document.head){document.head.appendChild(css);}else if(document.getElementsByTagName(\"head\")[0]){document.getElementsByTagName(\"head\")[0].appendChild(css);}return css;}catch(e){return null;}}function enableTransitions(css){if(!css||typeof document===\"undefined\")return;try{// Force browser repaint\nif(window.getComputedStyle&&css.style){window.getComputedStyle(css).opacity;}// Remove the style element\nif(css.parentNode){css.parentNode.removeChild(css);}}catch(e){// Silent fail for compatibility\n}}function applyFramerTheme(theme){if(typeof document===\"undefined\")return;try{// Disable all transitions temporarily\nconst transitionDisabler=disableTransitions();// Modern Framer theme switching approach\nif(document.documentElement&&document.documentElement.setAttribute){document.documentElement.setAttribute(\"data-framer-theme\",theme);}// Find and update Framer's style tags\nconst styleTags=document.getElementsByTagName(\"style\");for(let i=0;i<styleTags.length;i++){try{const styleTag=styleTags[i];let innerHTML=\"\";// Cross-browser innerHTML access\nif(styleTag.innerHTML!==undefined){innerHTML=styleTag.innerHTML;}else if(styleTag.styleSheet&&styleTag.styleSheet.cssText){innerHTML=styleTag.styleSheet.cssText;}if(innerHTML.indexOf(\"prefers-color-scheme\")!==-1){const newCSS=innerHTML.replace(/prefers-color-scheme:\\s*(dark|light)/g,\"prefers-color-scheme: \"+theme);// Cross-browser innerHTML setting\nif(styleTag.innerHTML!==undefined){styleTag.innerHTML=newCSS;}else if(styleTag.styleSheet){styleTag.styleSheet.cssText=newCSS;}}}catch(e){continue;}}// Re-enable transitions after theme is applied\nsetTimeout(function(){enableTransitions(transitionDisabler);},50);// Dispatch theme change event\ndispatchCustomEvent(\"framer-theme-change\",{theme:theme});}catch(e){// Silent fail for compatibility\n}}function ToggleButton(props){const[isClient,setIsClient]=useState(false);const[isDark,setIsDark]=useState(false);const[browserSupport,setBrowserSupport]=useState({localStorage:false,matchMedia:false,isLegacy:false});const cleanupRef=useRef([]);// Detect browser capabilities\nuseEffect(()=>{if(typeof window===\"undefined\")return;const userAgent=navigator.userAgent||\"\";const support={localStorage:hasLocalStorageSupport(),matchMedia:hasMatchMediaSupport(),isLegacy:/MSIE|Trident|Edge\\/\\d+/.test(userAgent)};setBrowserSupport(support);setIsClient(true);// Get initial theme with fallbacks\nlet initialTheme=\"light\";if(support.localStorage){try{const savedTheme=localStorage.getItem(\"framer-theme\");if(savedTheme){initialTheme=savedTheme;}else if(support.matchMedia){initialTheme=getSystemTheme();}}catch(e){if(support.matchMedia){initialTheme=getSystemTheme();}}}else if(support.matchMedia){initialTheme=getSystemTheme();}setIsDark(initialTheme===\"dark\");applyFramerTheme(initialTheme);// Save initial theme if localStorage is available\nif(support.localStorage){try{const savedTheme=localStorage.getItem(\"framer-theme\");if(!savedTheme){localStorage.setItem(\"framer-theme\",initialTheme);}}catch(e){// Silent fail if localStorage is restricted\n}}},[]);// Handle theme toggle with cross-browser compatibility\nconst handleToggle=()=>{if(!isClient)return;const newTheme=isDark?\"light\":\"dark\";setIsDark(!isDark);if(browserSupport.localStorage){try{localStorage.setItem(\"framer-theme\",newTheme);}catch(e){// Silent fail if localStorage is restricted\n}}applyFramerTheme(newTheme);};// Listen for system theme changes with cross-browser support\nuseEffect(()=>{if(!isClient||!browserSupport.matchMedia)return;let removeListener;try{const mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");const handleSystemThemeChange=e=>{// Only auto-switch if no manual theme is saved\nlet hasSavedTheme=false;if(browserSupport.localStorage){try{const savedTheme=localStorage.getItem(\"framer-theme\");hasSavedTheme=Boolean(savedTheme);}catch(e){// If can't access localStorage, assume no saved theme\n}}if(!hasSavedTheme){const newTheme=e.matches?\"dark\":\"light\";setIsDark(newTheme===\"dark\");applyFramerTheme(newTheme);}};removeListener=addMediaQueryListener(mediaQuery,handleSystemThemeChange);cleanupRef.current.push(removeListener);}catch(e){// Silent fail for unsupported browsers\n}return()=>{if(removeListener){try{removeListener();}catch(e){// Silent fail\n}}};},[isClient,browserSupport]);// Cleanup on unmount\nuseEffect(()=>{return()=>{cleanupRef.current.forEach(cleanup=>{try{cleanup();}catch(e){// Silent fail\n}});};},[]);// Don't render until client-side\nif(!isClient){return null;}// Cross-browser compatible styles\nconst buttonStyle={cursor:\"pointer\",borderRadius:8,position:\"relative\",width:(props.iconSize||20)+16,height:(props.iconSize||20)+16,display:browserSupport.isLegacy?\"block\":\"flex\",background:\"transparent\",border:\"none\",padding:0,margin:0,outline:\"none\"};// Add flexbox properties only for modern browsers\nif(!browserSupport.isLegacy){buttonStyle.alignItems=\"center\";buttonStyle.justifyContent=\"center\";buttonStyle.transition=\"all 0.2s ease\";}// For legacy browsers, use absolute positioning for centering\nconst iconWrapperStyle=browserSupport.isLegacy?{position:\"absolute\",top:\"50%\",left:\"50%\",marginTop:-(props.iconSize||20)/2,marginLeft:-(props.iconSize||20)/2}:{};const IconComponent=isDark?MoonIcon:SunIcon;const iconColor=isDark?props.darkModeColor:props.lightModeColor;return /*#__PURE__*/_jsx(\"div\",{onClick:handleToggle,style:{...buttonStyle,...props.style||{}},role:\"button\",tabIndex:0,onKeyDown:e=>{if(e.key===\"Enter\"||e.key===\" \"){e.preventDefault();handleToggle();}},children:/*#__PURE__*/_jsx(\"div\",{style:iconWrapperStyle,children:/*#__PURE__*/_jsx(IconComponent,{color:iconColor,size:props.iconSize||20})})});}export default function OptimizedToggleButton(props){return /*#__PURE__*/_jsx(ToggleButton,{...props});}OptimizedToggleButton.displayName=\"Theme Switcher\";addPropertyControls(OptimizedToggleButton,{iconSize:{type:ControlType.Number,title:\"Icon Size\",defaultValue:20,min:12,max:48,step:2},lightModeColor:{type:ControlType.Color,title:\"Light Mode Color\",defaultValue:\"#f59e0b\"},darkModeColor:{type:ControlType.Color,title:\"Dark Mode Color\",defaultValue:\"#1f2937\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"OptimizedToggleButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Light_Dark_Button.map"],"mappings":"6MAMA,SAAS,GAAwB,CAAC,GAAG,CAAC,GAAG,OAAO,QAAU,KAAoB,EAAO,eAAe,OAAa,MAAO,GAAO,IAAM,EAAK,wBAAwF,OAAhE,aAAa,QAAQ,EAAK,OAAO,CAAC,aAAa,WAAW,EAAK,CAAQ,QAAc,CAAC,MAAO,IAAQ,SAAS,GAAsB,CAAC,OAAc,IAAS,QAAa,OAAO,EAAO,YAAa,WAAY,SAAS,GAAgB,CAAC,GAAG,CAAC,GAAsB,CAAE,MAAM,QAAS,GAAG,CAAC,OAAO,EAAO,WAAW,+BAA+B,CAAC,QAAQ,OAAO,aAAiB,CAAC,MAAM,SAC3hB,SAAS,EAAsB,EAAW,EAAQ,CAAmX,OAA9W,EAA2B,OAAO,EAAW,aAAc,YAAY,EAAW,YAAY,EAAQ,KAAW,CAAI,OAAO,EAAW,gBAAiB,YAAY,EAAW,eAAe,EAAQ,GAAa,OAAO,EAAW,kBAAmB,YAAY,EAAW,iBAAiB,SAAS,EAAQ,KAAW,EAAW,oBAAoB,SAAS,EAAQ,MAAY,OAAnW,GAC5E,SAAS,EAAoB,EAAU,EAAO,CAAC,GAAU,IAAS,OAAY,OAAO,IAAI,EAAM,GAAG,CAClG,EAAM,IAAI,YAAY,EAAU,CAAC,SAAO,CAAC,MAAU,CACnD,GAAG,CAAC,EAAM,SAAS,YAAY,cAAc,CAAC,EAAM,gBAAgB,EAAU,GAAM,GAAM,EAAO,MAAW,CAC5G,EAAM,SAAS,YAAY,QAAQ,CAAC,EAAM,UAAU,EAAU,GAAM,GAAM,CAAC,EAAM,OAAO,GAAY,GAAO,EAAO,eAAe,EAAO,cAAc,EAAM,CAAG,SAAS,GAAoB,CAAC,GAAG,OAAO,SAAW,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