{"version":3,"file":"ImageInversionCursor.C0vBaxkG.mjs","names":["useRef","useState","useCallback","useMemo","_Fragment"],"sources":["https:/framerusercontent.com/modules/2je3g17IiuEIOPWkIwXA/vEEsEaCLEeY3ferziQms/ImageInversionCursor.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{forwardRef,startTransition}from\"react\";import{useCallback,useEffect,useMemo,useRef,useState}from\"react\";import{useInView}from\"framer-motion\";export function withImageInversionCursor(Component){return /*#__PURE__*/forwardRef(function WithImageInversionCursor(props,ref){const{radius=58,borderColor=\"rgba(242,240,234,.68)\",glowColor=\"rgba(229,20,43,.22)\",invertStrength=1,enableHueRotate=false,style,onPointerEnter,onPointerMove,onPointerLeave,...rest}=props;const wrapperRef=useRef(null);const targetRef=useRef({x:0,y:0});const smoothRef=useRef({x:0,y:0});const rafRef=useRef(null);const[isHovering,setIsHovering]=useState(false);const[displayPoint,setDisplayPoint]=useState({x:0,y:0});const[isFinePointer,setIsFinePointer]=useState(false);const[prefersReducedMotion,setPrefersReducedMotion]=useState(false);const inView=useInView(wrapperRef,{amount:.1});useEffect(()=>{if(typeof window!==\"undefined\"){const finePointerQuery=window.matchMedia(\"(hover: hover) and (pointer: fine)\");const reducedMotionQuery=window.matchMedia(\"(prefers-reduced-motion: reduce)\");const updateFinePointer=()=>{startTransition(()=>setIsFinePointer(finePointerQuery.matches));};const updateReducedMotion=()=>{startTransition(()=>setPrefersReducedMotion(reducedMotionQuery.matches));};updateFinePointer();updateReducedMotion();finePointerQuery.addEventListener(\"change\",updateFinePointer);reducedMotionQuery.addEventListener(\"change\",updateReducedMotion);return()=>{finePointerQuery.removeEventListener(\"change\",updateFinePointer);reducedMotionQuery.removeEventListener(\"change\",updateReducedMotion);};}else{startTransition(()=>{setIsFinePointer(false);setPrefersReducedMotion(true);});}},[]);const effectEnabled=isFinePointer&&!prefersReducedMotion;const stopAnimation=useCallback(()=>{if(rafRef.current!==null){cancelAnimationFrame(rafRef.current);rafRef.current=null;}},[]);const animate=useCallback(()=>{const dx=targetRef.current.x-smoothRef.current.x;const dy=targetRef.current.y-smoothRef.current.y;smoothRef.current={x:smoothRef.current.x+dx*.16,y:smoothRef.current.y+dy*.16};startTransition(()=>setDisplayPoint(smoothRef.current));rafRef.current=requestAnimationFrame(animate);},[]);useEffect(()=>{if(!effectEnabled||!isHovering||!inView){stopAnimation();return;}if(rafRef.current===null){rafRef.current=requestAnimationFrame(animate);}return stopAnimation;},[animate,effectEnabled,inView,isHovering,stopAnimation]);useEffect(()=>stopAnimation,[stopAnimation]);const updatePointerCoordinates=useCallback(event=>{const wrapper=wrapperRef.current;if(!wrapper)return;const rect=wrapper.getBoundingClientRect();const x=event.clientX-rect.left;const y=event.clientY-rect.top;targetRef.current={x,y};if(!effectEnabled)return;if(!isHovering){smoothRef.current={x,y};startTransition(()=>setDisplayPoint({x,y}));return;}if(prefersReducedMotion){smoothRef.current={x,y};startTransition(()=>setDisplayPoint({x,y}));}},[effectEnabled,isHovering,prefersReducedMotion]);const handlePointerEnter=useCallback(event=>{onPointerEnter?.(event);if(!effectEnabled||!inView)return;updatePointerCoordinates(event);startTransition(()=>setIsHovering(true));},[effectEnabled,inView,onPointerEnter,updatePointerCoordinates]);const handlePointerMove=useCallback(event=>{onPointerMove?.(event);if(!effectEnabled||!inView)return;updatePointerCoordinates(event);},[effectEnabled,inView,onPointerMove,updatePointerCoordinates]);const handlePointerLeave=useCallback(event=>{onPointerLeave?.(event);if(!effectEnabled)return;startTransition(()=>setIsHovering(false));},[effectEnabled,onPointerLeave]);const diameter=radius*2;const filterValue=`invert(${invertStrength})${enableHueRotate?\" hue-rotate(180deg)\":\"\"} contrast(1.05)`;const maskImage=useMemo(()=>{const{x,y}=displayPoint;return`radial-gradient(circle ${radius}px at ${x}px ${y}px, rgba(0,0,0,1) 72%, rgba(0,0,0,0.9) 84%, rgba(0,0,0,0) 100%)`;},[displayPoint,radius]);return /*#__PURE__*/_jsxs(\"div\",{ref:wrapperRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",cursor:effectEnabled&&isHovering?\"none\":style?.cursor||\"auto\"},onPointerEnter:handlePointerEnter,onPointerMove:handlePointerMove,onPointerLeave:handlePointerLeave,children:[/*#__PURE__*/_jsx(Component,{ref:ref,...rest,style:{...style,cursor:effectEnabled&&isHovering?\"none\":style?.cursor}}),effectEnabled?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":true,style:{position:\"absolute\",inset:0,pointerEvents:\"none\",overflow:\"hidden\",filter:filterValue,WebkitMaskImage:maskImage,maskImage,WebkitMaskRepeat:\"no-repeat\",maskRepeat:\"no-repeat\"},children:/*#__PURE__*/_jsx(Component,{...rest,style:{...style,position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",pointerEvents:\"none\"}})}),/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":true,style:{position:\"absolute\",top:displayPoint.y,left:displayPoint.x,width:diameter,height:diameter,marginLeft:-radius,marginTop:-radius,borderRadius:\"9999px\",border:`1px solid ${borderColor}`,boxShadow:`0 0 10px ${glowColor}`,pointerEvents:\"none\",transform:`scale(${isHovering?1:.92})`,opacity:isHovering?1:0,transition:\"transform 240ms cubic-bezier(.22,.61,.36,1), opacity 180ms ease\"}})]}):null]});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withImageInversionCursor\":{\"type\":\"reactHoc\",\"name\":\"withImageInversionCursor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageInversionCursor.map"],"mappings":"oOAAmO,SAAgB,EAAyB,EAAU,CAAC,OAAoB,EAAW,SAAkC,EAAM,EAAI,CAAC,GAAK,CAAC,SAAO,GAAG,cAAY,wBAAwB,YAAU,sBAAsB,iBAAe,EAAE,kBAAgB,GAAM,QAAM,iBAAe,gBAAc,iBAAe,GAAG,GAAM,EAAY,EAAWA,EAAO,KAA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