{"version":3,"file":"SvgDrawEffect.BFvgHTWR.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/rYfuYiwaMbiBew7O3sEk/3icqY3kDImLLFOIq5fWv/SvgDrawEffect.js"],"sourcesContent":["// SVG Line Draw effect component for any SVG\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";/**\n * Arrow Draw Effect\n * Supports any SVG via code, animates stroke drawing. Customizable stroke color, width, and transition.\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 200\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function SvgDrawEffect(props){const{svgCode,strokeColor,strokeWidth,transition,style}=props;const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const[drawn,setDrawn]=useState(false);const inViewRef=useRef(null);const inView=useInView(inViewRef,{once:true,amount:.1});// Animate draw on effect\nuseEffect(()=>{if(!containerRef.current)return;const svg=containerRef.current.querySelector(\"svg\");if(!svg)return;// Select all stroke-relevant SVG shapes\nconst selector=\"path, line, polyline, polygon, circle, ellipse, rect\";const nodes=Array.from(svg.querySelectorAll(selector));nodes.forEach(el=>{// Fix: Cast to SVGElement for property access\nconst svgEl=el;let len=0;// getTotalLength works on most shapes\nif(typeof svgEl.getTotalLength===\"function\"){try{len=svgEl.getTotalLength();}catch(_){len=0;}}else if(svgEl.tagName===\"RECT\"||svgEl.tagName===\"rect\"){// Approximate rect length\nconst w=Number(svgEl.getAttribute(\"width\")??0);const h=Number(svgEl.getAttribute(\"height\")??0);len=2*(w+h);}svgEl.style.strokeDasharray=`${len}`;svgEl.style.strokeDashoffset=drawn?\"0\":`${len}`;svgEl.style.stroke=strokeColor;svgEl.style.strokeWidth=`${strokeWidth}px`;// Ensure fills don't interfere (only set if empty or none)\nif(!svgEl.getAttribute(\"fill\")||svgEl.getAttribute(\"fill\")===\"none\"){svgEl.style.fill=\"none\";}// Set transition only on animate\nif(!isStatic&&drawn){// transition prop may be object or number; fallback to 2s duration\nconst dur=typeof transition===\"object\"&&transition?.duration?transition.duration:typeof transition===\"number\"?transition:2;const delay=typeof transition===\"object\"&&transition?.delay?transition.delay:0;svgEl.style.transition=`stroke-dashoffset ${dur}s cubic-bezier(0.77,0,0.175,1)${delay?` ${delay}s`:\"\"}, stroke 0.2s, stroke-width 0.2s`;}else{svgEl.style.transition=\"none\";}});},[svgCode,strokeColor,strokeWidth,drawn,isStatic,transition]);useEffect(()=>{if(isStatic)setDrawn(true);else setDrawn(false);},[svgCode,isStatic]);useEffect(()=>{if(!drawn&&!isStatic&&inView){const timer=setTimeout(()=>{startTransition(()=>setDrawn(true));},120);return()=>clearTimeout(timer);}},[drawn,isStatic,svgCode,inView]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",height:\"100%\",position:\"relative\",...style},children:/*#__PURE__*/_jsx(\"div\",{ref:inViewRef,style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},dangerouslySetInnerHTML:{__html:svgCode}})});}addPropertyControls(SvgDrawEffect,{svgCode:{type:ControlType.String,title:\"SVG Code\",defaultValue:'<svg viewBox=\"0 0 400 200\"><path d=\"M 20 100 Q 150 10 380 100\"/></svg>',displayTextArea:true,placeholder:'Paste SVG markup (Arrow example: <svg viewBox=\"0 0 100 100\"><path d=\"M10 50 L90 50 M90 50 L80 40 M90 50 L80 60\"/></svg>)…'},strokeColor:{type:ControlType.Color,title:\"Stroke Color\",defaultValue:\"#111\"},strokeWidth:{type:ControlType.Number,title:\"Stroke Width\",defaultValue:3,min:1,max:20,unit:\"px\"},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{duration:2}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SvgDrawEffect\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"200\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SvgDrawEffect.map"],"mappings":"wPASG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,UAAQ,cAAY,cAAY,aAAW,SAAO,EAAY,EAAS,GAAqB,CAAO,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAM,GAAUC,EAAS,GAAM,CAAO,EAAUD,EAAO,KAAK,CAAO,EAAO,EAAU,EAAU,CAAC,KAAK,GAAK,OAAO,GAAG,CAAC,CAQuZ,OAPpsB,MAAc,CAAC,GAAG,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAI,EAAa,QAAQ,cAAc,MAAM,CAAK,GACrB,MAAM,KAAK,EAAI,iBAAlF,uDAA4G,CAAC,CAAO,QAAQ,GAAI,CAC/I,IAAM,EAAM,EAAO,EAAI,EACvB,GAAG,OAAO,EAAM,gBAAiB,WAAY,GAAG,CAAC,EAAI,EAAM,gBAAgB,MAAU,CAAC,EAAI,QAAY,EAAM,UAAU,QAAQ,EAAM,UAAU,UAC/C,EAAI,GAA3F,OAAO,EAAM,aAAa,QAAQ,EAAE,EAAE,CAAS,OAAO,EAAM,aAAa,SAAS,EAAE,EAAE,GAE9F,GAF4G,EAAM,MAAM,gBAAgB,GAAG,IAAM,EAAM,MAAM,iBAAiB,EAAM,IAAI,GAAG,IAAM,EAAM,MAAM,OAAO,EAAY,EAAM,MAAM,YAAY,GAAG,EAAY,KACpQ,CAAC,EAAM,aAAa,OAAO,EAAE,EAAM,aAAa,OAAO,GAAG,UAAQ,EAAM,MAAM,KAAK,QACnF,CAAC,GAAU,EAAM,CACpB,IAAM,EAAI,OAAO,GAAa,UAAU,GAAY,SAAS,EAAW,SAAS,OAAO,GAAa,SAAS,EAAW,EAAQ,EAAM,OAAO,GAAa,U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