{"version":3,"file":"Theme_changing.C5DBWr3X.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/0OGJe2j1238EYBAwaqvC/U8UiUs2a3tFMYIlYf5Nl/Theme_changing.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Helper function to get theme from localStorage or system default\nconst getStoredValueOrDefault=()=>{const storedValue=localStorage.getItem(\"theme\");const validValues=[\"dark\",\"light\"];if(storedValue===null||!validValues.includes(storedValue)){return\"system\";}return storedValue;};// Change theme helper\nconst changeTheme=theme=>{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);return;};// Create a theme store\nconst useStore=createStore({theme:getStoredValueOrDefault()});export const withResponsiveTheme=Component=>{return props=>{const[store,setStore]=useStore();const[isDarkTheme,setIsDarkTheme]=useState(null);useEffect(()=>{const mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");const updateTheme=()=>{const currentStoredTheme=localStorage.getItem(\"theme\");if(currentStoredTheme===\"dark\"||currentStoredTheme===\"light\"){setIsDarkTheme(currentStoredTheme===\"dark\");}else{// Fallback to system theme\nsetIsDarkTheme(mediaQuery.matches);}};const osThemeChange=e=>{const currentStoredTheme=localStorage.getItem(\"theme\");if(currentStoredTheme===null){setIsDarkTheme(e.matches);}};updateTheme();window.addEventListener(\"themeChange\",updateTheme);mediaQuery.addEventListener(\"change\",osThemeChange);return()=>{window.removeEventListener(\"themeChange\",updateTheme);mediaQuery.removeEventListener(\"change\",osThemeChange);};},[]);const handleClick=()=>{const newTheme=isDarkTheme?\"light\":\"dark\";setStore({theme:newTheme});changeTheme(newTheme);};if(isDarkTheme===null){return null;}const variant=isDarkTheme?\"Dark\":\"Light\";return /*#__PURE__*/_jsx(Component,{...props,variant:variant,whileHover:{scale:1}});};};\nexport const __FramerMetadata__ = {\"exports\":{\"withResponsiveTheme\":{\"type\":\"reactHoc\",\"name\":\"withResponsiveTheme\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Theme_changing.map"],"mappings":"sTAA2C,IAAsC,IAAqE,CAChJ,MAA4B,CAAC,IAAM,EAAY,aAAa,QAAQ,QAAQ,CAA+G,OAAxE,IAAc,MAAM,CAAxC,CAAC,OAAO,QAAQ,CAAqC,SAAS,EAAY,CAAQ,SAAiB,GAElM,EAAS,EAAY,CAAC,MAAM,GAAyB,CAAC,CAAC,CAAc,EAAoB,GAAmB,GAAO,CAAC,GAAK,CAAC,EAAM,GAAU,GAAU,CAAM,CAAC,EAAY,GAAgBA,EAAS,KAAK,CAC8U,GAD7U,MAAc,CAAC,IAAM,EAAW,EAAO,WAAW,+BAA+B,CAAO,MAAgB,CAAC,IAAM,EAAmB,aAAa,QAAQ,QAAQ,CAA+D,EAA3D,IAAqB,QAAQ,IAAqB,QAAwB,IAAqB,OAC/b,EAAW,QAAQ,EAAU,EAAc,GAAG,CAA0B,aAAa,QAAQ,QAAQ,GAAyB,MAAM,EAAe,EAAE,QAAQ,EAAyH,OAArH,GAAa,CAAC,EAAO,iBAAiB,cAAc,EAAY,CAAC,EAAW,iBAAiB,SAAS,EAAc,KAAW,CAAC,EAAO,oBAAoB,cAAc,EAAY,CAAC,EAAW,oBAAoB,SAAS,EAAc,GAAK,EAAE,CAAC,CAAwH,IAAc,KAAM,OAAO,KAAM,IAAM,EAAQ,EAAY,OAAO,QAAQ,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAc,UAAQ,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC"}