{"version":3,"file":"MyAnimatedPath.DunhDfkc.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/HO5quIEBUDTklhzDdpJE/yGoKewNoGdutcOA3Xu8D/MyAnimatedPath.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";function easeIn(t){return t*t;}function easeOut(t){const p=t-1;return 1-p*p;}function easeInOut(t){return t<.5?2*t*t:-1+(4-2*t)*t;}function linearEasing(t){return t;}/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export function MyAnimatedPath({pathData,duration,color,size,loop,showPath,pathColor,pathThickness,easingType,borderRadius,mirror}){const graphicRef=useRef(null);const containerRef=useRef(null);useEffect(()=>{const svgNamespace=\"http://www.w3.org/2000/svg\";const tempSvg=document.createElementNS(svgNamespace,\"svg\");const newPath=document.createElementNS(svgNamespace,\"path\");newPath.setAttribute(\"d\",pathData);tempSvg.appendChild(newPath);document.body.appendChild(tempSvg);const pathLength=newPath.getTotalLength();document.body.removeChild(tempSvg);let startTime=null;let animationFrameID=null;const easingFunction={linear:linearEasing,easeIn:easeIn,easeOut:easeOut,easeInOut:easeInOut}[easingType]||linearEasing;const animate=timestamp=>{if(!startTime)startTime=timestamp;const elapsedTime=timestamp-startTime;let progress=elapsedTime/(duration*1e3);if(loop&&progress>=1){if(mirror){const cycle=Math.floor(progress);const cycleProgress=progress-cycle;progress=cycle%2===0?cycleProgress:1-cycleProgress;}else{startTime=timestamp-elapsedTime%(duration*1e3);progress%=1;}}progress=Math.min(progress,1);const easedProgress=easingFunction(progress);const point=newPath.getPointAtLength(easedProgress*pathLength);const offsetX=point.x-size/2;const offsetY=point.y-size/2;if(graphicRef.current){graphicRef.current.style.transform=`translate(${offsetX}px, ${offsetY}px)`;}if(progress<1||loop){animationFrameID=requestAnimationFrame(animate);}};animationFrameID=requestAnimationFrame(animate);return()=>{if(animationFrameID){cancelAnimationFrame(animationFrameID);}};},[pathData,duration,loop,size,easingType,mirror]);const containerStyle={position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"visible\"};const svgStyle={position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",overflow:\"visible\",pointerEvents:\"none\"};const graphicStyle={position:\"absolute\",width:`${size}px`,height:`${size}px`,backgroundColor:color,borderRadius:`${borderRadius}%`,boxSizing:\"border-box\",willChange:\"transform\"};return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:containerStyle,children:[showPath&&/*#__PURE__*/_jsx(\"svg\",{style:svgStyle,children:/*#__PURE__*/_jsx(\"path\",{d:pathData,fill:\"none\",stroke:pathColor,strokeWidth:pathThickness})}),/*#__PURE__*/_jsx(motion.div,{ref:graphicRef,style:graphicStyle,initial:{scale:0},animate:{scale:1},whileHover:{scale:1.2}})]});}MyAnimatedPath.defaultProps={pathData:\"M10 80 Q 95 10 180 80\",duration:2,color:\"#3B82F6\",size:20,loop:true,showPath:true,pathColor:\"#000000\",pathThickness:2,easingType:\"linear\",borderRadius:50,mirror:false};addPropertyControls(MyAnimatedPath,{pathData:{type:ControlType.String,title:\"Path Data\",defaultValue:\"M10 80 Q 95 10 180 80\",displayTextArea:true},duration:{type:ControlType.Number,title:\"Duration\",min:.1,max:30,step:.1,defaultValue:2,unit:\"s\"},color:{type:ControlType.Color,title:\"Object Color\",defaultValue:\"#3B82F6\"},size:{type:ControlType.Number,title:\"Object Size\",min:1,max:100,step:1,defaultValue:20,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",min:0,max:100,step:1,defaultValue:50,unit:\"%\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true,enabledTitle:\"Enabled\",disabledTitle:\"Disabled\"},mirror:{type:ControlType.Boolean,title:\"Mirror Loop\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\",hidden:props=>!props.loop},showPath:{type:ControlType.Boolean,title:\"Show Path\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},pathColor:{type:ControlType.Color,title:\"Path Color\",defaultValue:\"#000000\",hidden:props=>!props.showPath},pathThickness:{type:ControlType.Number,title:\"Path Thickness\",min:.5,max:20,step:.5,defaultValue:2,unit:\"px\",hidden:props=>!props.showPath},easingType:{type:ControlType.Enum,title:\"Easing Type\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\"],defaultValue:\"linear\",description:\"v1.1 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"MyAnimatedPath\":{\"type\":\"reactComponent\",\"name\":\"MyAnimatedPath\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MyAnimatedPath.map"],"mappings":"0OAAmL,SAAS,EAAO,EAAE,CAAC,OAAO,EAAE,CAAE,CAAC,SAAS,EAAQ,EAAE,CAAC,IAAM,EAAE,EAAE,EAAE,MAAO,GAAE,EAAE,CAAE,CAAC,SAAS,EAAU,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,CAAE,CAAC,SAAS,EAAa,EAAE,CAAC,OAAO,CAAE,CAKrV,SAAgB,EAAe,CAAC,WAAS,WAAS,QAAM,OAAK,OAAK,WAAS,YAAU,gBAAc,aAAW,eAAa,UAAQ,CAAC,IAAM,EAAWA,EAAO,IAAI,EAAQ,EAAaA,EAAO,IAAI,EAAE,MAAc,CAAC,IAAM,EAAa,6BAAmC,EAAQ,SAAS,gBAAgB,EAAa,KAAK,EAAQ,EAAQ,SAAS,gBAAgB,EAAa,MAAM,EAAE,EAAQ,aAAa,IAAI,CAAQ,EA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