{"version":3,"file":"StrokeDrawSVG.BiQfKuIm.mjs","names":["useMemo","useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/u48QNyabxhGmO41K4wlO/il3pRJC7xeIfMKVBnf30/StrokeDrawSVG.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * User request: Create a new Framer code component named StrokeDrawSVG that fetches and inlines an external SVG, scales it to the frame, animates path/line/polyline/polygon strokes in a looping draw effect with stagger and hold timing, supports SSR/static safety, and exposes controls for URL/stroke/timing/fill.\n *//**\n * @framerIntrinsicWidth 264\n * @framerIntrinsicHeight 317\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function StrokeDrawSVG(props){const{svgFile=\"\",svgUrl=\"https://framerusercontent.com/images/8lhvciWVep0tIJie4UlTtf5Xg.svg?width=264&height=317&kb=25\",strokeColor=\"#F5F3EE\",fillColor=\"#F5F3EE\",animateFill=true,fillFadeStart=.6,strokeWidth=1.5,duration=2.5,stagger=.08,holdTime=.6,hideFill=true}=props;const resolvedSvgUrl=useMemo(()=>{const uploadedUrl=typeof svgFile===\"string\"?svgFile.trim():\"\";if(uploadedUrl.length>0)return uploadedUrl;return svgUrl;},[svgFile,svgUrl]);const wrapperRef=useRef(null);const cleanupAnimationRef=useRef(null);const[svgVersion,setSvgVersion]=useState(0);const isStaticRenderer=useIsStaticRenderer();const timings=useMemo(()=>{const safeDuration=Math.max(.1,duration);const safeHold=Math.max(0,holdTime);const safeStagger=Math.max(0,stagger);const cycle=safeDuration+safeHold;const drawEnd=safeDuration/cycle*100;return{safeDuration,safeHold,safeStagger,cycle,drawEnd};},[duration,holdTime,stagger]);const clearAnimation=useCallback(()=>{if(cleanupAnimationRef.current){cleanupAnimationRef.current();cleanupAnimationRef.current=null;}},[]);const applyColorStyles=useCallback(()=>{if(typeof window===\"undefined\")return;if(!wrapperRef.current)return;const svg=wrapperRef.current.querySelector(\"svg\");if(!svg)return;const drawable=Array.from(svg.querySelectorAll(\"path, line, polyline, polygon\"));drawable.forEach(element=>{element.removeAttribute(\"stroke\");element.removeAttribute(\"fill\");element.removeAttribute(\"fill-opacity\");element.style.stroke=strokeColor;element.style.strokeWidth=`${strokeWidth}`;element.style.fill=hideFill?\"transparent\":fillColor;if(!hideFill&&animateFill){element.style.fillOpacity=\"0\";}else{element.style.fillOpacity=\"1\";}});},[animateFill,fillColor,hideFill,strokeColor,strokeWidth]);const setupAnimation=useCallback(()=>{if(typeof window===\"undefined\")return;if(isStaticRenderer)return;if(!wrapperRef.current)return;clearAnimation();const wrapper=wrapperRef.current;const svg=wrapper.querySelector(\"svg\");if(!svg)return;const drawable=Array.from(svg.querySelectorAll(\"path, line, polyline, polygon\"));if(!drawable.length)return;const measured=drawable.map(element=>{try{const length=element.getTotalLength();return{element,length};}catch{return{element,length:0};}}).filter(item=>item.length>0);if(!measured.length)return;const styleTag=document.createElement(\"style\");const animationName=`strokeDrawSvg_${Math.random().toString(36).slice(2)}`;const fillAnimationName=`strokeDrawSvgFill_${Math.random().toString(36).slice(2)}`;const safeFillFadeStart=Math.min(1,Math.max(0,fillFadeStart));const fillStartPercent=timings.drawEnd*safeFillFadeStart;const shouldAnimateFill=!hideFill&&animateFill;styleTag.textContent=`\n            @keyframes ${animationName} {\n                0% { stroke-dashoffset: var(--stroke-path-length); }\n                ${timings.drawEnd}% { stroke-dashoffset: 0; }\n                99.9% { stroke-dashoffset: 0; }\n                100% { stroke-dashoffset: var(--stroke-path-length); }\n            }\n            @keyframes ${fillAnimationName} {\n                0% { fill-opacity: 0; }\n                ${fillStartPercent}% { fill-opacity: 0; }\n                ${timings.drawEnd}% { fill-opacity: 1; }\n                99.9% { fill-opacity: 1; }\n                100% { fill-opacity: 0; }\n            }\n        `;document.head.appendChild(styleTag);const originals=measured.map(({element})=>({element,stroke:element.style.stroke,strokeWidth:element.style.strokeWidth,strokeDasharray:element.style.strokeDasharray,strokeDashoffset:element.style.strokeDashoffset,fill:element.style.fill,fillOpacity:element.style.fillOpacity,animation:element.style.animation,strokeAttr:element.getAttribute(\"stroke\"),fillAttr:element.getAttribute(\"fill\"),fillOpacityAttr:element.getAttribute(\"fill-opacity\")}));measured.forEach(({element,length},index)=>{const delay=timings.safeStagger*index;element.removeAttribute(\"stroke\");element.removeAttribute(\"fill\");element.removeAttribute(\"fill-opacity\");element.style.setProperty(\"--stroke-path-length\",`${length}`);element.style.strokeDasharray=`${length}`;element.style.strokeDashoffset=`${length}`;element.style.stroke=strokeColor;element.style.strokeWidth=`${strokeWidth}`;element.style.fill=hideFill?\"transparent\":fillColor;if(shouldAnimateFill){element.style.fillOpacity=\"0\";element.style.animation=`${animationName} ${timings.cycle}s linear ${delay}s infinite, ${fillAnimationName} ${timings.cycle}s linear ${delay}s infinite`;}else{element.style.fillOpacity=hideFill?\"1\":\"1\";element.style.animation=`${animationName} ${timings.cycle}s linear ${delay}s infinite`;}});cleanupAnimationRef.current=()=>{originals.forEach(item=>{item.element.style.stroke=item.stroke;item.element.style.strokeWidth=item.strokeWidth;item.element.style.strokeDasharray=item.strokeDasharray;item.element.style.strokeDashoffset=item.strokeDashoffset;item.element.style.fill=item.fill;item.element.style.fillOpacity=item.fillOpacity;item.element.style.animation=item.animation;item.element.style.removeProperty(\"--stroke-path-length\");if(item.strokeAttr===null){item.element.removeAttribute(\"stroke\");}else{item.element.setAttribute(\"stroke\",item.strokeAttr);}if(item.fillAttr===null){item.element.removeAttribute(\"fill\");}else{item.element.setAttribute(\"fill\",item.fillAttr);}if(item.fillOpacityAttr===null){item.element.removeAttribute(\"fill-opacity\");}else{item.element.setAttribute(\"fill-opacity\",item.fillOpacityAttr);}});if(styleTag.parentNode)styleTag.parentNode.removeChild(styleTag);};},[animateFill,clearAnimation,fillColor,fillFadeStart,hideFill,isStaticRenderer,strokeColor,strokeWidth,timings]);useEffect(()=>{if(typeof window===\"undefined\")return;if(!wrapperRef.current)return;let canceled=false;const controller=new AbortController;const load=async()=>{try{const response=await fetch(resolvedSvgUrl,{signal:controller.signal});if(!response.ok)return;const text=await response.text();if(canceled||!wrapperRef.current)return;if(!text||!text.toLowerCase().includes(\"<svg\")){wrapperRef.current.innerHTML=\"\";return;}wrapperRef.current.innerHTML=text;const svg=wrapperRef.current.querySelector(\"svg\");if(!svg)return;svg.removeAttribute(\"width\");svg.removeAttribute(\"height\");svg.setAttribute(\"width\",\"100%\");svg.setAttribute(\"height\",\"100%\");svg.setAttribute(\"preserveAspectRatio\",\"xMidYMid meet\");svg.style.width=\"100%\";svg.style.height=\"100%\";svg.style.display=\"block\";applyColorStyles();startTransition(()=>{setSvgVersion(value=>value+1);});}catch{if(!canceled&&wrapperRef.current)wrapperRef.current.innerHTML=\"\";}};load();return()=>{canceled=true;controller.abort();if(wrapperRef.current)wrapperRef.current.innerHTML=\"\";};},[applyColorStyles,resolvedSvgUrl]);useEffect(()=>{applyColorStyles();},[applyColorStyles,svgVersion]);useEffect(()=>{setupAnimation();return()=>{clearAnimation();};},[clearAnimation,setupAnimation,svgVersion]);return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,style:{...props.style,position:\"relative\",width:\"100%\",height:\"100%\",pointerEvents:\"none\",overflow:\"hidden\"}});}addPropertyControls(StrokeDrawSVG,{svgFile:{type:ControlType.File,title:\"SVG File\",allowedFileTypes:[\"svg\"]},svgUrl:{type:ControlType.String,title:\"SVG URL\",defaultValue:\"https://framerusercontent.com/images/8lhvciWVep0tIJie4UlTtf5Xg.svg?width=264&height=317&kb=25\"},strokeColor:{type:ControlType.Color,title:\"Stroke\",defaultValue:\"#F5F3EE\"},fillColor:{type:ControlType.Color,title:\"Fill\",defaultValue:\"#F5F3EE\"},animateFill:{type:ControlType.Boolean,title:\"Animate Fill\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},fillFadeStart:{type:ControlType.Number,title:\"Fill Start\",min:0,max:1,step:.05,defaultValue:.6},strokeWidth:{type:ControlType.Number,title:\"Width\",min:.1,max:20,step:.1,defaultValue:1.5},duration:{type:ControlType.Number,title:\"Duration\",min:.1,max:20,step:.1,defaultValue:2.5},stagger:{type:ControlType.Number,title:\"Stagger\",min:0,max:2,step:.01,defaultValue:.08},holdTime:{type:ControlType.Number,title:\"Hold\",min:0,max:10,step:.1,defaultValue:.6},hideFill:{type:ControlType.Boolean,title:\"Hide Fill\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"StrokeDrawSVG\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"264\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"317\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StrokeDrawSVG.map"],"mappings":"mOAOG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,UAAQ,GAAG,SAAO,gGAAgG,cAAY,UAAU,YAAU,UAAU,cAAY,GAAK,gBAAc,GAAG,cAAY,IAAI,WAAS,IAAI,UAAQ,IAAI,WAAS,GAAG,WAAS,IAAM,EAAY,EAAeA,MAAY,CAAC,IAAM,EAAY,OAAO,GAAU,SAAS,EAAQ,KAAK,EAAE,GAA8C,OAAxC,EAAY,OAAO,EAAS,EAAmB,CAAO,EAAE,CAAC,EAAQ,CAAM,CAAC,EAAQ,EAAWC,EAAO,IAAI,EAAQ,EAAoBA,EAAO,IAAI,EAAO,CAAC,EAAW,GAAeC,EAAS,CAAC,EAAQ,EAAiB,EAAoB,EAAQ,EAAQF,MAAY,CAAC,IAAM,EAAa,KAAK,IAAI,GAAG,CAAQ,EAAQ,EAAS,KAAK,IAAI,EAAE,CAAQ,EAAQ,EAAY,KAAK,IAAI,EAAE,CAAO,EAAQ,EAAM,EAAa,EAA8C,MAAM,CA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