{"version":3,"file":"ThemeSwitch.BAvddNoY.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/zZ5SqTS2wGJeVocJzB0n/gMgrGUQlobpfQJwskVKK/ThemeSwitch.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useCallback,useEffect,useRef,useState}from\"react\";import{useInView,useMotionValue,useSpring}from\"framer-motion\";// Get the user's preferred theme\nconst getUserPreferredTheme=()=>{if(typeof window!==\"undefined\"){return window.matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";}return\"light\";};export function themeSwitcher(Component){return props=>{const[theme,setTheme]=useState(()=>{if(typeof window!==\"undefined\"){return sessionStorage.getItem(\"currentToggleState\")||getUserPreferredTheme();}return\"light\";});const toggle=()=>{const newTheme=theme===\"light\"?\"dark\":\"light\";setTheme(newTheme);if(typeof window!==\"undefined\"){sessionStorage.setItem(\"currentToggleState\",newTheme);window.dispatchEvent(new CustomEvent(\"themeChange\",{detail:newTheme}));}};useEffect(()=>{if(typeof document!==\"undefined\"){const styleSheets=Array.from(document.styleSheets);styleSheets.forEach(styleSheet=>{try{const cssRules=Array.from(styleSheet.cssRules);cssRules.forEach((rule,index)=>{if(rule instanceof CSSMediaRule&&rule.conditionText.includes(\"prefers-color-scheme\")){const newRule=`@media (prefers-color-scheme: ${getUserPreferredTheme()===\"light\"?theme===\"dark\"?\"light\":\"dark\":theme}) { ${rule.cssText.replace(/^@media[^{]+{|}$/g,\"\")} }`;styleSheet.deleteRule(index);styleSheet.insertRule(newRule,index);}});}catch(e){console.warn(e.message);}});}},[theme]);return /*#__PURE__*/_jsx(Component,{...props,onClick:toggle});};}export function variantSwitcher(Component){return props=>{const[isLoading,setIsLoading]=useState(true);const[currentToggleState,setCurrentToggleState]=useState(null);useEffect(()=>{if(typeof window!==\"undefined\"){const initialTheme=sessionStorage.getItem(\"currentToggleState\")||getUserPreferredTheme();setCurrentToggleState(initialTheme);setIsLoading(false);}},[]);useEffect(()=>{const handleThemeChange=event=>{setCurrentToggleState(event.detail);};window.addEventListener(\"themeChange\",handleThemeChange);return()=>window.removeEventListener(\"themeChange\",handleThemeChange);},[]);//Opacity based component transition for preventing race condition.\nreturn /*#__PURE__*/_jsx(\"div\",{className:\"transition-opacity duration-200\",style:{opacity:isLoading||currentToggleState===null?0:1},children:/*#__PURE__*/_jsx(Component,{...props,variant:currentToggleState===\"dark\"?\"Dark\":\"Light\"})});};}export function MagneticHover(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const elementRef=useRef(null);const isInView=useInView(elementRef,{once:false,amount:0});const x=useMotionValue(0);const y=useMotionValue(0);const scale=useMotionValue(1);const springX=useSpring(x,{stiffness:420,damping:32,mass:.35});const springY=useSpring(y,{stiffness:420,damping:32,mass:.35});const springScale=useSpring(scale,{stiffness:380,damping:30,mass:.3});const setRefs=useCallback(node=>{elementRef.current=node;if(typeof ref===\"function\"){ref(node);}else if(ref&&\"current\"in ref){ref.current=node;}},[ref]);const runHandler=useCallback((handler,event)=>{if(typeof handler===\"function\"){handler(event);}},[]);const updateMagnet=useCallback(event=>{const target=event.currentTarget;if(!target)return;const rect=target.getBoundingClientRect();const centerX=rect.left+rect.width/2;const centerY=rect.top+rect.height/2;const rawOffsetX=event.clientX-centerX;const rawOffsetY=event.clientY-centerY;const strength=.22;const maxOffset=Math.min(rect.width,rect.height)*.12;const nextX=Math.max(-maxOffset,Math.min(maxOffset,rawOffsetX*strength));const nextY=Math.max(-maxOffset,Math.min(maxOffset,rawOffsetY*strength));x.set(nextX);y.set(nextY);},[]);const handlePointerEnter=useCallback(event=>{runHandler(props.onPointerEnter,event);if(!isInView)return;scale.set(1.03);updateMagnet(event);},[isInView,props.onPointerEnter,runHandler,scale,updateMagnet]);const handlePointerMove=useCallback(event=>{runHandler(props.onPointerMove,event);if(!isInView)return;updateMagnet(event);},[isInView,props.onPointerMove,runHandler,updateMagnet]);const handlePointerLeave=useCallback(event=>{runHandler(props.onPointerLeave,event);x.set(0);y.set(0);scale.set(1);},[props.onPointerLeave,runHandler,scale,x,y]);return /*#__PURE__*/_jsx(Component,{...props,ref:setRefs,onPointerEnter:handlePointerEnter,onPointerMove:handlePointerMove,onPointerLeave:handlePointerLeave,style:{...props.style,x:springX,y:springY,scale:springScale,willChange:\"transform\"}});});}\nexport const __FramerMetadata__ = {\"exports\":{\"variantSwitcher\":{\"type\":\"reactHoc\",\"name\":\"variantSwitcher\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"themeSwitcher\":{\"type\":\"reactHoc\",\"name\":\"themeSwitcher\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"MagneticHover\":{\"type\":\"reactHoc\",\"name\":\"MagneticHover\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ThemeSwitch.map"],"mappings":"2NACkK,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAM,GAAUA,MAAwB,IAAS,OAAiG,QAA7E,eAAe,QAAQ,oBAAoB,GAAG,EAAsB,CAAkB,EAAQ,MAAW,CAAC,IAAM,EAAS,IAAQ,QAAQ,OAAO,QAAQ,EAAS,CAAQ,EAAY,IAAS,SAAa,eAAe,QAAQ,qBAAqB,CAAQ,EAAE,EAAO,cAAc,IAAI,YAAY,cAAc,CAAC,OAAO,CAAQ,CAAC,CAAC,EAAG,EAAolB,OAAllB,MAAc,CAAI,OAAO,SAAW,KAAgE,MAA3B,KAAK,SAAS,WAAuB,CAAC,CAAC,QAAQ,GAAY,CAAC,GAAG,CAAgD,MAA1B,KAAK,EAAW,QAAiB,CAAC,CAAC,SAAS,EAAK,IAAQ,CAAC,GAAG,aAAgB,cAAc,EAAK,cAAc,SAAS,sBAAsB,EAAE,CAAC,IAAM,EAAQ,iCAAiC,EAAsB,IAAI,QAAQ,IAAQ,OAAO,QAAQ,OAAO,EAAM,MAAM,EAAK,QAAQ,QAAQ,oBAAoB,EAAE,EAAE,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