svg-scroll-draw 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/angular/index.cjs +3 -3
  2. package/dist/angular/index.d.mts +1 -1
  3. package/dist/angular/index.d.ts +1 -1
  4. package/dist/angular/index.mjs +3 -3
  5. package/dist/astro/index.cjs +3 -3
  6. package/dist/astro/index.d.mts +1 -1
  7. package/dist/astro/index.d.ts +1 -1
  8. package/dist/astro/index.mjs +3 -3
  9. package/dist/cdn/svg-scroll-draw.global.js +3 -3
  10. package/dist/group/index.cjs +2 -2
  11. package/dist/group/index.d.mts +1 -1
  12. package/dist/group/index.d.ts +1 -1
  13. package/dist/group/index.mjs +2 -2
  14. package/dist/index.cjs +3 -3
  15. package/dist/index.d.mts +31 -2
  16. package/dist/index.d.ts +31 -2
  17. package/dist/index.mjs +3 -3
  18. package/dist/nuxt/index.cjs +3 -3
  19. package/dist/nuxt/index.d.mts +1 -1
  20. package/dist/nuxt/index.d.ts +1 -1
  21. package/dist/nuxt/index.mjs +3 -3
  22. package/dist/react/index.cjs +3 -3
  23. package/dist/react/index.d.mts +1 -1
  24. package/dist/react/index.d.ts +1 -1
  25. package/dist/react/index.mjs +3 -3
  26. package/dist/solid/index.cjs +3 -3
  27. package/dist/solid/index.d.mts +1 -1
  28. package/dist/solid/index.d.ts +1 -1
  29. package/dist/solid/index.mjs +3 -3
  30. package/dist/svelte/index.cjs +3 -3
  31. package/dist/svelte/index.d.mts +1 -1
  32. package/dist/svelte/index.d.ts +1 -1
  33. package/dist/svelte/index.mjs +3 -3
  34. package/dist/timeline/index.cjs +1 -1
  35. package/dist/timeline/index.d.mts +1 -1
  36. package/dist/timeline/index.d.ts +1 -1
  37. package/dist/timeline/index.mjs +1 -1
  38. package/dist/vue/index.cjs +3 -3
  39. package/dist/vue/index.d.mts +1 -1
  40. package/dist/vue/index.d.ts +1 -1
  41. package/dist/vue/index.mjs +3 -3
  42. package/dist/web-component/index.cjs +3 -3
  43. package/dist/web-component/index.mjs +3 -3
  44. package/package.json +6 -2
@@ -1,3 +1,3 @@
1
- 'use strict';var ve={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2)};function we(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[s="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:s,viewport:o}}function Ie(e,r,s,o){switch(o){case "top":return e+s;case "center":return e+s+r/2;case "bottom":return e+s+r;default:return e+s}}function Ce(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function $e(e){let r=e.tagName.toLowerCase();if(r==="rect"){let s=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(s+o)}if(r==="circle"){let s=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*s}return e.getTotalLength()}function Ue(e,r,s){return Math.min(s,Math.max(r,e))}function B(e,r,s,o){return s===r?0:Ue((e-r)/(s-r)*o,0,1)}function Ee(e,r,s,o,f){let d=Ie(e.top,e.height,r,o.element)-Ce(o.viewport,s),p=Ie(e.top,e.height,r,f.element)-Ce(f.viewport,s);return {tStart:d,tEnd:p}}function Oe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let s=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(s)return [parseInt(s[1],16),parseInt(s[2],16),parseInt(s[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function xe(e,r,s){let o=Oe(e),f=Oe(r);return !o||!f?e:`rgb(${Math.round(o[0]+(f[0]-o[0])*s)},${Math.round(o[1]+(f[1]-o[1])*s)},${Math.round(o[2]+(f[2]-o[2])*s)})`}function Fe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ne={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},je=0;function Je(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ke(e){let r=e.getAttribute("stroke"),s=e.getAttribute("fill");!r||r==="none"?Fe("Element has no stroke \u2014 path will not be visible.",e):s&&s!=="none"&&s!=="transparent"&&Fe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Qe(e,r,s){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function f(){let d=s==="x"?window.scrollX:window.scrollY,p=e-d,L=r-d,X=s==="x";o.innerHTML=`
2
- <div style="position:absolute;${X?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
- <div style="position:absolute;${X?`left:${L}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${L}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(o),window.addEventListener("scroll",f,{passive:true}),f(),o}function Re(e,r,s){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),f=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let p=parseFloat(d),L=o[f++]??p;return String(+(p+(L-p)*s).toFixed(4))})}function He(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:f=1,fade:d=false,easing:p="linear",trigger:L={},stagger:X=0,direction:y="forward",once:U=false,debug:We=false,axis:$="y",scrollContainer:ce,autoReverse:Z=false,delay:pe=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:Ge=0,rootMargin:ze="0px",repeat:j=0,repeatDelay:Se=0,morphTo:D,clip:me,native:qe=true,onProgress:de,onStart:ye,onComplete:J}=r,W=me===true?"left":typeof me=="string"?me:false,re=typeof p=="function"?p:ve[p]??ve.linear,ke=we(L.start??"top bottom"),Ae=we(L.end??"bottom top"),b=typeof ce=="string"?document.querySelector(ce):ce??null,I=Array.isArray(R)?R[0]:null,E=Array.isArray(R)?R[1]:typeof R=="string"?R:null,x=Array.isArray(H)?H[0]:null,S=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,A=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(t){let n=t*100;switch(W){case "right":return `inset(0 0 0 ${100-n}%)`;case "top":return `inset(0 0 ${100-n}% 0)`;case "bottom":return `inset(${100-n}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-n}% 0 0)`}}let v=W?[]:Array.from(e.querySelectorAll(o)),h=[],C=[],O=0,F=0,P=false,G=false,N=0,ne=false,T=-1,se=-1,z=false,oe=0,K=0,ie,he=null,ae=new Set,le=-1,Te=performance.now();function Q(){return b?$==="x"?b.scrollLeft:b.scrollTop:$==="x"?window.scrollX:window.scrollY}function Me(){return b?$==="x"?b.clientWidth:b.clientHeight:$==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),n,a,m;if(b){let w=b.getBoundingClientRect();n=$==="x"?t.left-w.left+b.scrollLeft:t.top-w.top+b.scrollTop,a=$==="x"?t.width:t.height,m=Q();}else n=$==="x"?t.left:t.top,a=$==="x"?t.width:t.height,m=Q();let q=Ee({top:n,height:a},m,Me(),ke,Ae);O=q.tStart,F=q.tEnd,We&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=Qe(O,F,$));}function Be(t,n){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=n==="reverse"?1-t:t;e.style.clipPath=_(a);return}v.forEach((a,m)=>{a.style.strokeDashoffset=n==="reverse"?`${h[m]*t}`:`${h[m]*(1-t)}`,d&&(a.style.opacity=n==="reverse"?`${1-t}`:`${t}`),I&&E?a.style.stroke=xe(I,E,t):E&&(a.style.stroke=E),x!==null&&S!==null?a.style.strokeWidth=`${x+(S-x)*t}`:S!==null&&(a.style.strokeWidth=`${S}`),k!==null&&A!==null?a.style.fillOpacity=`${k+(A-k)*t}`:A!==null&&(a.style.fillOpacity=`${A}`),D&&a.tagName.toLowerCase()==="path"&&C[m]&&a.setAttribute("d",Re(C[m],D,t));});}function Pe(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}v.forEach((t,n)=>{t.style.strokeDasharray=`${h[n]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${h[n]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`),D&&t.tagName.toLowerCase()==="path"&&C[n]&&t.setAttribute("d",C[n]);});}if(v.forEach(t=>{Ke(t);let n=$e(t);h.push(n),t.tagName.toLowerCase()==="path"?C.push(t.getAttribute("d")??""):C.push(""),s?(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=y==="reverse"?`${n}`:"0",d&&(t.style.opacity="1"),E&&(t.style.stroke=E),S!==null&&(t.style.strokeWidth=`${S}`),A!==null&&(t.style.fillOpacity=`${A}`),D&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",D)):(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=y==="reverse"?"0":`${n}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(s)return e.style.clipPath=_(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(s)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function _e(){return !(qe===false||!Je()||!v.length||typeof p!="string"||!(p in Ne)||W||$!=="y"||b||f!==1||X!==0||U||Z||te!==false||D||ee||j||pe>0||de||ye||J||R!=null||H!=null||V!=null||(L.start??"top bottom").trim()!=="top bottom"||(L.end??"bottom top").trim()!=="bottom top")}function Xe(){let t=`svg-scroll-draw-${++je}`,n=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",m=`stroke-dashoffset:${n};`,q=`stroke-dashoffset:${a};`;d&&(m+=`opacity:${y==="reverse"?1:0};`,q+=`opacity:${y==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${t}{from{${m}}to{${q}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Ne[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(w);function i(u,M){u.style.setProperty("--ssd-len",String(h[M])),u.style.strokeDasharray=`${h[M]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(t);}v.forEach(i);let l=false,g=-1;function c(){if(g>=0)return g;let u=e.getBoundingClientRect(),{tStart:M,tEnd:Y}=Ee({top:u.top,height:u.height},Q(),Me(),ke,Ae);return re(B(Q(),M,Y,f))}return {destroy(){v.forEach(u=>{u.classList.remove(t),u.style.removeProperty("--ssd-len"),u.style.animationPlayState="";}),w.remove();},replay(){l=false,g=-1,v.forEach(i);},pause(){l=true,v.forEach(u=>{u.style.animationPlayState="paused";});},resume(){l&&(l=false,v.forEach(u=>{u.style.animationPlayState="running";}));},seek(u){let M=Math.min(1,Math.max(0,u));g=M,l=true,v.forEach((Y,De)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${h[De]*M}`:`${h[De]*(1-M)}`,d&&(Y.style.opacity=y==="reverse"?`${1-M}`:`${M}`);});},getProgress(){return c()}}}if(_e())return Xe();Le();function ue(){if(!ne||z)return;let t=performance.now(),n=Q(),a=f;if(te!==false){let i=t-Te,l=i>0?Math.abs(n-(le<0?n:le))/i:0;a=f*Math.max(.2,1+l*(typeof te=="number"?te:1)*.04);}le=n,Te=t;let m=Z?se===-1||n>=se?"forward":"reverse":y;se=n;let q=F-O,w=true;if(W){let i=re(B(n,O,F,a));U&&!Z&&(T=Math.max(T,i),i=T),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let l=m==="reverse"?1-i:i;e.style.clipPath=_(l),de?.(i),!G&&B(n,O,F,a)>0&&(G=true,ye?.()),i>=1&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{T=-1,G=false,P=false,e.style.clipPath=_(0);},Se))):i<1&&!U&&(P=false),N=requestAnimationFrame(ue);return}if(v.forEach((i,l)=>{let g=l*X*q,c=re(B(n,O+g,F+g,a));U&&!Z&&(T=Math.max(T,c),c=T),oe=c,i.style.strokeDashoffset=m==="reverse"?`${h[l]*c}`:`${h[l]*(1-c)}`,d&&(i.style.opacity=m==="reverse"?`${1-c}`:`${c}`),I&&E?i.style.stroke=xe(I,E,c):E&&(i.style.stroke=E),x!==null&&S!==null?i.style.strokeWidth=`${x+(S-x)*c}`:S!==null&&(i.style.strokeWidth=`${S}`),k!==null&&A!==null?i.style.fillOpacity=`${k+(A-k)*c}`:A!==null&&(i.style.fillOpacity=`${A}`),D&&i.tagName.toLowerCase()==="path"&&C[l]&&i.setAttribute("d",Re(C[l],D,c)),l===0&&(de?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(w=false);}),ee){let i=re(B(n,O,F,a));for(let l in ee){let g=parseFloat(l);i>=g&&!ae.has(g)&&(ae.add(g),ee[l]?.());}}!G&&B(n,O,F,a)>0&&(G=true,ye?.()),w&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{T=-1,G=false,P=false,ae.clear(),Pe();},Se))):!w&&!U&&(P=false),N=requestAnimationFrame(ue);}let ge=new IntersectionObserver(t=>{t.forEach(n=>{ne=n.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:Ge,rootMargin:ze}),be;function fe(){clearTimeout(be),be=setTimeout(()=>{v.forEach((t,n)=>{h[n]=$e(t),t.style.strokeDasharray=`${h[n]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),pe>0?setTimeout(()=>ge.observe(e),pe):ge.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),ge.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(be),he?.remove();},replay(){T=-1,se=-1,le=-1,G=false,P=false,K=0,z=false,ae.clear(),clearTimeout(ie),Pe();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let n=Math.min(1,Math.max(0,t));oe=n,T=n,z=true,cancelAnimationFrame(N),Be(n,y);},getProgress(){return oe}}}var Ve=class{constructor(){this.instance=null;}init(r,s={}){return this.destroy(),this.instance=He(r,s),this}replay(){return this.instance?.replay(),this}destroy(){return this.instance?.destroy(),this.instance=null,this}};exports.ScrollDrawRef=Ve;
1
+ 'use strict';function Ue({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(o),u=0,p=[];for(let a=0;a<n;a++){let d=Math.pow(c,a);p.push(d),u+=d;}let h=[0],I=0;for(let a=0;a<n;a++)I+=p[a]/u,h.push(I);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=h[d+1]){let U=(a-h[d])/(h[d+1]-h[d]);if(d===0)return U*(2-U);let b=1-Math.pow(o,d);return b+(1-b)*(2*U-1)*(2*U-1)}return 1}}function je({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),o=Math.max(.1,r),c=n<=1?o/4:o/(2*Math.PI)*Math.asin(1/n);return u=>u<=0?0:u>=1?1:n*Math.pow(2,-10*u)*Math.sin((u-c)*(2*Math.PI)/o)+1}var we={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Ue(),elastic:je()};function $e(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Ce(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Oe(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function xe(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Je(e,r,n){return Math.min(n,Math.max(r,e))}function X(e,r,n,o){return n===r?0:Je((e-r)/(n-r)*o,0,1)}function Ee(e,r,n,o,c){let u=Ce(e.top,e.height,r,o.element)-Oe(o.viewport,n),p=Ce(e.top,e.height,r,c.element)-Oe(c.viewport,n);return {tStart:u,tEnd:p}}function Fe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function Se(e,r,n){let o=Fe(e),c=Fe(r);return !o||!c?e:`rgb(${Math.round(o[0]+(c[0]-o[0])*n)},${Math.round(o[1]+(c[1]-o[1])*n)},${Math.round(o[2]+(c[2]-o[2])*n)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ke=0;function Qe(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ye(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ze(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function c(){let u=n==="x"?window.scrollX:window.scrollY,p=e-u,h=r-u,I=n==="x";o.innerHTML=`
2
+ <div style="position:absolute;${I?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
+ <div style="position:absolute;${I?`left:${h}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${h}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(o),window.addEventListener("scroll",c,{passive:true}),c(),o}function We(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let p=parseFloat(u),h=o[c++]??p;return String(+(p+(h-p)*n).toFixed(4))})}function He(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:c=1,fade:u=false,easing:p="linear",trigger:h={},stagger:I=0,direction:a="forward",once:d=false,debug:U=false,axis:b="y",scrollContainer:me,autoReverse:ee=false,delay:pe=0,strokeColor:H,strokeWidth:V,fillOpacity:G,waypoints:te,velocityScale:re=false,threshold:Ge=0,rootMargin:ze="0px",repeat:J=0,repeatDelay:Me=0,morphTo:C,clip:de,native:qe=true,onProgress:ye,onStart:he,onComplete:K}=r,z=de===true?"left":typeof de=="string"?de:false,ne=typeof p=="function"?p:we[p]??we.linear,ke=$e(h.start??"top bottom"),Ae=$e(h.end??"bottom top"),$=typeof me=="string"?document.querySelector(me):me??null,O=Array.isArray(H)?H[0]:null,S=Array.isArray(H)?H[1]:typeof H=="string"?H:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,A=Array.isArray(G)?G[0]:null,T=Array.isArray(G)?G[1]:typeof G=="number"?G:null;function j(t){let s=t*100;switch(z){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let x=z?[]:Array.from(e.querySelectorAll(o)),v=[],F=[],N=0,R=0,D=false,q=false,W=0,se=false,P=-1,oe=-1,B=false,ie=0,Q=0,ae,ge=null,le=new Set,ue=-1,Te=performance.now();function Y(){return $?b==="x"?$.scrollLeft:$.scrollTop:b==="x"?window.scrollX:window.scrollY}function Pe(){return $?b==="x"?$.clientWidth:$.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),s,l,g;if($){let E=$.getBoundingClientRect();s=b==="x"?t.left-E.left+$.scrollLeft:t.top-E.top+$.scrollTop,l=b==="x"?t.width:t.height,g=Y();}else s=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,g=Y();let _=Ee({top:s,height:l},g,Pe(),ke,Ae);N=_.tStart,R=_.tEnd,U&&process.env.NODE_ENV!=="production"&&(ge?.remove(),ge=Ze(N,R,b));}function Be(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),z){let l=s==="reverse"?1-t:t;e.style.clipPath=j(l);return}x.forEach((l,g)=>{l.style.strokeDashoffset=s==="reverse"?`${v[g]*t}`:`${v[g]*(1-t)}`,u&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),O&&S?l.style.stroke=Se(O,S,t):S&&(l.style.stroke=S),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),A!==null&&T!==null?l.style.fillOpacity=`${A+(T-A)*t}`:T!==null&&(l.style.fillOpacity=`${T}`),C&&l.tagName.toLowerCase()==="path"&&F[g]&&l.setAttribute("d",We(F[g],C,t));});}function De(){if(e.style.setProperty("--scroll-draw-progress","0"),z){e.style.clipPath=j(0);return}x.forEach((t,s)=>{t.style.strokeDasharray=`${v[s]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${v[s]}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`),C&&t.tagName.toLowerCase()==="path"&&F[s]&&t.setAttribute("d",F[s]);});}if(x.forEach(t=>{Ye(t);let s=xe(t);v.push(s),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?`${s}`:"0",u&&(t.style.opacity="1"),S&&(t.style.stroke=S),k!==null&&(t.style.strokeWidth=`${k}`),T!==null&&(t.style.fillOpacity=`${T}`),C&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",C)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?"0":`${s}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`));}),z){if(n)return e.style.clipPath=j(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function _e(){return !(qe===false||!Qe()||!x.length||typeof p!="string"||!(p in Re)||z||b!=="y"||$||c!==1||I!==0||d||ee||re!==false||C||te||J||pe>0||ye||he||K||H!=null||V!=null||G!=null||(h.start??"top bottom").trim()!=="top bottom"||(h.end??"bottom top").trim()!=="bottom top")}function Xe(){let t=`svg-scroll-draw-${++Ke}`,s=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${s};`,_=`stroke-dashoffset:${l};`;u&&(g+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let E=document.createElement("style");E.setAttribute("data-svg-scroll-draw",""),E.textContent=`@keyframes ${t}{from{${g}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(E);function i(m,L){m.style.setProperty("--ssd-len",String(v[L])),m.style.strokeDasharray=`${v[L]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(t);}x.forEach(i);let f=false,w=-1;function y(){if(w>=0)return w;let m=e.getBoundingClientRect(),{tStart:L,tEnd:Z}=Ee({top:m.top,height:m.height},Y(),Pe(),ke,Ae);return ne(X(Y(),L,Z,c))}return {destroy(){x.forEach(m=>{m.classList.remove(t),m.style.removeProperty("--ssd-len"),m.style.animationPlayState="";}),E.remove();},replay(){f=false,w=-1,x.forEach(i);},pause(){f=true,x.forEach(m=>{m.style.animationPlayState="paused";});},resume(){f&&(f=false,x.forEach(m=>{m.style.animationPlayState="running";}));},seek(m){let L=Math.min(1,Math.max(0,m));w=L,f=true,x.forEach((Z,Ie)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${v[Ie]*L}`:`${v[Ie]*(1-L)}`,u&&(Z.style.opacity=a==="reverse"?`${1-L}`:`${L}`);});},getProgress(){return y()}}}if(_e())return Xe();Le();function ce(){if(!se||B)return;let t=performance.now(),s=Y(),l=c;if(re!==false){let i=t-Te,f=i>0?Math.abs(s-(ue<0?s:ue))/i:0;l=c*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=s,Te=t;let g=ee?oe===-1||s>=oe?"forward":"reverse":a;oe=s;let _=R-N,E=true;if(z){let i=ne(X(s,N,R,l));d&&!ee&&(P=Math.max(P,i),i=P),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=g==="reverse"?1-i:i;e.style.clipPath=j(f),ye?.(i),!q&&X(s,N,R,l)>0&&(q=true,he?.()),i>=1&&!D?(D=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,q=false,D=false,e.style.clipPath=j(0);},Me))):i<1&&!d&&(D=false),W=requestAnimationFrame(ce);return}if(x.forEach((i,f)=>{let w=f*I*_,y=ne(X(s,N+w,R+w,l));d&&!ee&&(P=Math.max(P,y),y=P),ie=y,i.style.strokeDashoffset=g==="reverse"?`${v[f]*y}`:`${v[f]*(1-y)}`,u&&(i.style.opacity=g==="reverse"?`${1-y}`:`${y}`),O&&S?i.style.stroke=Se(O,S,y):S&&(i.style.stroke=S),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),A!==null&&T!==null?i.style.fillOpacity=`${A+(T-A)*y}`:T!==null&&(i.style.fillOpacity=`${T}`),C&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",We(F[f],C,y)),f===0&&(ye?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(E=false);}),te){let i=ne(X(s,N,R,l));for(let f in te){let w=parseFloat(f);i>=w&&!le.has(w)&&(le.add(w),te[f]?.());}}!q&&X(s,N,R,l)>0&&(q=true,he?.()),E&&!D?(D=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,q=false,D=false,le.clear(),De();},Me))):!E&&!d&&(D=false),W=requestAnimationFrame(ce);}let be=new IntersectionObserver(t=>{t.forEach(s=>{se=s.isIntersecting,se&&!B?W=requestAnimationFrame(ce):cancelAnimationFrame(W);});},{root:$??null,threshold:Ge,rootMargin:ze}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{x.forEach((t,s)=>{v[s]=xe(t),t.style.strokeDasharray=`${v[s]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),pe>0?setTimeout(()=>be.observe(e),pe):be.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ae),be.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),ge?.remove();},replay(){P=-1,oe=-1,ue=-1,q=false,D=false,Q=0,B=false,le.clear(),clearTimeout(ae),De();},pause(){B=true,cancelAnimationFrame(W);},resume(){B&&(B=false,se&&(W=requestAnimationFrame(ce)));},seek(t){let s=Math.min(1,Math.max(0,t));ie=s,P=s,B=true,cancelAnimationFrame(W),Be(s,a);},getProgress(){return ie}}}var Ve=class{constructor(){this.instance=null;}init(r,n={}){return this.destroy(),this.instance=He(r,n),this}replay(){return this.instance?.replay(),this}destroy(){return this.instance?.destroy(),this.instance=null,this}};exports.ScrollDrawRef=Ve;
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface TriggerConfig {
3
3
  start?: string;
4
4
  end?: string;
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface TriggerConfig {
3
3
  start?: string;
4
4
  end?: string;
@@ -1,3 +1,3 @@
1
- var ve={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2)};function we(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[s="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:s,viewport:o}}function Ie(e,r,s,o){switch(o){case "top":return e+s;case "center":return e+s+r/2;case "bottom":return e+s+r;default:return e+s}}function Ce(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function $e(e){let r=e.tagName.toLowerCase();if(r==="rect"){let s=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(s+o)}if(r==="circle"){let s=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*s}return e.getTotalLength()}function Ue(e,r,s){return Math.min(s,Math.max(r,e))}function B(e,r,s,o){return s===r?0:Ue((e-r)/(s-r)*o,0,1)}function Ee(e,r,s,o,f){let d=Ie(e.top,e.height,r,o.element)-Ce(o.viewport,s),p=Ie(e.top,e.height,r,f.element)-Ce(f.viewport,s);return {tStart:d,tEnd:p}}function Oe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let s=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(s)return [parseInt(s[1],16),parseInt(s[2],16),parseInt(s[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function xe(e,r,s){let o=Oe(e),f=Oe(r);return !o||!f?e:`rgb(${Math.round(o[0]+(f[0]-o[0])*s)},${Math.round(o[1]+(f[1]-o[1])*s)},${Math.round(o[2]+(f[2]-o[2])*s)})`}function Fe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ne={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},je=0;function Je(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ke(e){let r=e.getAttribute("stroke"),s=e.getAttribute("fill");!r||r==="none"?Fe("Element has no stroke \u2014 path will not be visible.",e):s&&s!=="none"&&s!=="transparent"&&Fe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Qe(e,r,s){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function f(){let d=s==="x"?window.scrollX:window.scrollY,p=e-d,L=r-d,X=s==="x";o.innerHTML=`
2
- <div style="position:absolute;${X?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
- <div style="position:absolute;${X?`left:${L}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${L}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(o),window.addEventListener("scroll",f,{passive:true}),f(),o}function Re(e,r,s){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),f=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let p=parseFloat(d),L=o[f++]??p;return String(+(p+(L-p)*s).toFixed(4))})}function He(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:f=1,fade:d=false,easing:p="linear",trigger:L={},stagger:X=0,direction:y="forward",once:U=false,debug:We=false,axis:$="y",scrollContainer:ce,autoReverse:Z=false,delay:pe=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:Ge=0,rootMargin:ze="0px",repeat:j=0,repeatDelay:Se=0,morphTo:D,clip:me,native:qe=true,onProgress:de,onStart:ye,onComplete:J}=r,W=me===true?"left":typeof me=="string"?me:false,re=typeof p=="function"?p:ve[p]??ve.linear,ke=we(L.start??"top bottom"),Ae=we(L.end??"bottom top"),b=typeof ce=="string"?document.querySelector(ce):ce??null,I=Array.isArray(R)?R[0]:null,E=Array.isArray(R)?R[1]:typeof R=="string"?R:null,x=Array.isArray(H)?H[0]:null,S=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,A=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(t){let n=t*100;switch(W){case "right":return `inset(0 0 0 ${100-n}%)`;case "top":return `inset(0 0 ${100-n}% 0)`;case "bottom":return `inset(${100-n}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-n}% 0 0)`}}let v=W?[]:Array.from(e.querySelectorAll(o)),h=[],C=[],O=0,F=0,P=false,G=false,N=0,ne=false,T=-1,se=-1,z=false,oe=0,K=0,ie,he=null,ae=new Set,le=-1,Te=performance.now();function Q(){return b?$==="x"?b.scrollLeft:b.scrollTop:$==="x"?window.scrollX:window.scrollY}function Me(){return b?$==="x"?b.clientWidth:b.clientHeight:$==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),n,a,m;if(b){let w=b.getBoundingClientRect();n=$==="x"?t.left-w.left+b.scrollLeft:t.top-w.top+b.scrollTop,a=$==="x"?t.width:t.height,m=Q();}else n=$==="x"?t.left:t.top,a=$==="x"?t.width:t.height,m=Q();let q=Ee({top:n,height:a},m,Me(),ke,Ae);O=q.tStart,F=q.tEnd,We&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=Qe(O,F,$));}function Be(t,n){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=n==="reverse"?1-t:t;e.style.clipPath=_(a);return}v.forEach((a,m)=>{a.style.strokeDashoffset=n==="reverse"?`${h[m]*t}`:`${h[m]*(1-t)}`,d&&(a.style.opacity=n==="reverse"?`${1-t}`:`${t}`),I&&E?a.style.stroke=xe(I,E,t):E&&(a.style.stroke=E),x!==null&&S!==null?a.style.strokeWidth=`${x+(S-x)*t}`:S!==null&&(a.style.strokeWidth=`${S}`),k!==null&&A!==null?a.style.fillOpacity=`${k+(A-k)*t}`:A!==null&&(a.style.fillOpacity=`${A}`),D&&a.tagName.toLowerCase()==="path"&&C[m]&&a.setAttribute("d",Re(C[m],D,t));});}function Pe(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}v.forEach((t,n)=>{t.style.strokeDasharray=`${h[n]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${h[n]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`),D&&t.tagName.toLowerCase()==="path"&&C[n]&&t.setAttribute("d",C[n]);});}if(v.forEach(t=>{Ke(t);let n=$e(t);h.push(n),t.tagName.toLowerCase()==="path"?C.push(t.getAttribute("d")??""):C.push(""),s?(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=y==="reverse"?`${n}`:"0",d&&(t.style.opacity="1"),E&&(t.style.stroke=E),S!==null&&(t.style.strokeWidth=`${S}`),A!==null&&(t.style.fillOpacity=`${A}`),D&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",D)):(t.style.strokeDasharray=`${n}`,t.style.strokeDashoffset=y==="reverse"?"0":`${n}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(s)return e.style.clipPath=_(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(s)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function _e(){return !(qe===false||!Je()||!v.length||typeof p!="string"||!(p in Ne)||W||$!=="y"||b||f!==1||X!==0||U||Z||te!==false||D||ee||j||pe>0||de||ye||J||R!=null||H!=null||V!=null||(L.start??"top bottom").trim()!=="top bottom"||(L.end??"bottom top").trim()!=="bottom top")}function Xe(){let t=`svg-scroll-draw-${++je}`,n=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",m=`stroke-dashoffset:${n};`,q=`stroke-dashoffset:${a};`;d&&(m+=`opacity:${y==="reverse"?1:0};`,q+=`opacity:${y==="reverse"?0:1};`);let w=document.createElement("style");w.setAttribute("data-svg-scroll-draw",""),w.textContent=`@keyframes ${t}{from{${m}}to{${q}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Ne[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(w);function i(u,M){u.style.setProperty("--ssd-len",String(h[M])),u.style.strokeDasharray=`${h[M]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(t);}v.forEach(i);let l=false,g=-1;function c(){if(g>=0)return g;let u=e.getBoundingClientRect(),{tStart:M,tEnd:Y}=Ee({top:u.top,height:u.height},Q(),Me(),ke,Ae);return re(B(Q(),M,Y,f))}return {destroy(){v.forEach(u=>{u.classList.remove(t),u.style.removeProperty("--ssd-len"),u.style.animationPlayState="";}),w.remove();},replay(){l=false,g=-1,v.forEach(i);},pause(){l=true,v.forEach(u=>{u.style.animationPlayState="paused";});},resume(){l&&(l=false,v.forEach(u=>{u.style.animationPlayState="running";}));},seek(u){let M=Math.min(1,Math.max(0,u));g=M,l=true,v.forEach((Y,De)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${h[De]*M}`:`${h[De]*(1-M)}`,d&&(Y.style.opacity=y==="reverse"?`${1-M}`:`${M}`);});},getProgress(){return c()}}}if(_e())return Xe();Le();function ue(){if(!ne||z)return;let t=performance.now(),n=Q(),a=f;if(te!==false){let i=t-Te,l=i>0?Math.abs(n-(le<0?n:le))/i:0;a=f*Math.max(.2,1+l*(typeof te=="number"?te:1)*.04);}le=n,Te=t;let m=Z?se===-1||n>=se?"forward":"reverse":y;se=n;let q=F-O,w=true;if(W){let i=re(B(n,O,F,a));U&&!Z&&(T=Math.max(T,i),i=T),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let l=m==="reverse"?1-i:i;e.style.clipPath=_(l),de?.(i),!G&&B(n,O,F,a)>0&&(G=true,ye?.()),i>=1&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{T=-1,G=false,P=false,e.style.clipPath=_(0);},Se))):i<1&&!U&&(P=false),N=requestAnimationFrame(ue);return}if(v.forEach((i,l)=>{let g=l*X*q,c=re(B(n,O+g,F+g,a));U&&!Z&&(T=Math.max(T,c),c=T),oe=c,i.style.strokeDashoffset=m==="reverse"?`${h[l]*c}`:`${h[l]*(1-c)}`,d&&(i.style.opacity=m==="reverse"?`${1-c}`:`${c}`),I&&E?i.style.stroke=xe(I,E,c):E&&(i.style.stroke=E),x!==null&&S!==null?i.style.strokeWidth=`${x+(S-x)*c}`:S!==null&&(i.style.strokeWidth=`${S}`),k!==null&&A!==null?i.style.fillOpacity=`${k+(A-k)*c}`:A!==null&&(i.style.fillOpacity=`${A}`),D&&i.tagName.toLowerCase()==="path"&&C[l]&&i.setAttribute("d",Re(C[l],D,c)),l===0&&(de?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(w=false);}),ee){let i=re(B(n,O,F,a));for(let l in ee){let g=parseFloat(l);i>=g&&!ae.has(g)&&(ae.add(g),ee[l]?.());}}!G&&B(n,O,F,a)>0&&(G=true,ye?.()),w&&!P?(P=true,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{T=-1,G=false,P=false,ae.clear(),Pe();},Se))):!w&&!U&&(P=false),N=requestAnimationFrame(ue);}let ge=new IntersectionObserver(t=>{t.forEach(n=>{ne=n.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:Ge,rootMargin:ze}),be;function fe(){clearTimeout(be),be=setTimeout(()=>{v.forEach((t,n)=>{h[n]=$e(t),t.style.strokeDasharray=`${h[n]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),pe>0?setTimeout(()=>ge.observe(e),pe):ge.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),ge.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(be),he?.remove();},replay(){T=-1,se=-1,le=-1,G=false,P=false,K=0,z=false,ae.clear(),clearTimeout(ie),Pe();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let n=Math.min(1,Math.max(0,t));oe=n,T=n,z=true,cancelAnimationFrame(N),Be(n,y);},getProgress(){return oe}}}var Ve=class{constructor(){this.instance=null;}init(r,s={}){return this.destroy(),this.instance=He(r,s),this}replay(){return this.instance?.replay(),this}destroy(){return this.instance?.destroy(),this.instance=null,this}};export{Ve as ScrollDrawRef};
1
+ function Ue({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(o),u=0,p=[];for(let a=0;a<n;a++){let d=Math.pow(c,a);p.push(d),u+=d;}let h=[0],I=0;for(let a=0;a<n;a++)I+=p[a]/u,h.push(I);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=h[d+1]){let U=(a-h[d])/(h[d+1]-h[d]);if(d===0)return U*(2-U);let b=1-Math.pow(o,d);return b+(1-b)*(2*U-1)*(2*U-1)}return 1}}function je({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),o=Math.max(.1,r),c=n<=1?o/4:o/(2*Math.PI)*Math.asin(1/n);return u=>u<=0?0:u>=1?1:n*Math.pow(2,-10*u)*Math.sin((u-c)*(2*Math.PI)/o)+1}var we={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Ue(),elastic:je()};function $e(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Ce(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Oe(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function xe(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Je(e,r,n){return Math.min(n,Math.max(r,e))}function X(e,r,n,o){return n===r?0:Je((e-r)/(n-r)*o,0,1)}function Ee(e,r,n,o,c){let u=Ce(e.top,e.height,r,o.element)-Oe(o.viewport,n),p=Ce(e.top,e.height,r,c.element)-Oe(c.viewport,n);return {tStart:u,tEnd:p}}function Fe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function Se(e,r,n){let o=Fe(e),c=Fe(r);return !o||!c?e:`rgb(${Math.round(o[0]+(c[0]-o[0])*n)},${Math.round(o[1]+(c[1]-o[1])*n)},${Math.round(o[2]+(c[2]-o[2])*n)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ke=0;function Qe(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Ye(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ze(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function c(){let u=n==="x"?window.scrollX:window.scrollY,p=e-u,h=r-u,I=n==="x";o.innerHTML=`
2
+ <div style="position:absolute;${I?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
+ <div style="position:absolute;${I?`left:${h}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${h}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(o),window.addEventListener("scroll",c,{passive:true}),c(),o}function We(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let p=parseFloat(u),h=o[c++]??p;return String(+(p+(h-p)*n).toFixed(4))})}function He(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:c=1,fade:u=false,easing:p="linear",trigger:h={},stagger:I=0,direction:a="forward",once:d=false,debug:U=false,axis:b="y",scrollContainer:me,autoReverse:ee=false,delay:pe=0,strokeColor:H,strokeWidth:V,fillOpacity:G,waypoints:te,velocityScale:re=false,threshold:Ge=0,rootMargin:ze="0px",repeat:J=0,repeatDelay:Me=0,morphTo:C,clip:de,native:qe=true,onProgress:ye,onStart:he,onComplete:K}=r,z=de===true?"left":typeof de=="string"?de:false,ne=typeof p=="function"?p:we[p]??we.linear,ke=$e(h.start??"top bottom"),Ae=$e(h.end??"bottom top"),$=typeof me=="string"?document.querySelector(me):me??null,O=Array.isArray(H)?H[0]:null,S=Array.isArray(H)?H[1]:typeof H=="string"?H:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,A=Array.isArray(G)?G[0]:null,T=Array.isArray(G)?G[1]:typeof G=="number"?G:null;function j(t){let s=t*100;switch(z){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let x=z?[]:Array.from(e.querySelectorAll(o)),v=[],F=[],N=0,R=0,D=false,q=false,W=0,se=false,P=-1,oe=-1,B=false,ie=0,Q=0,ae,ge=null,le=new Set,ue=-1,Te=performance.now();function Y(){return $?b==="x"?$.scrollLeft:$.scrollTop:b==="x"?window.scrollX:window.scrollY}function Pe(){return $?b==="x"?$.clientWidth:$.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),s,l,g;if($){let E=$.getBoundingClientRect();s=b==="x"?t.left-E.left+$.scrollLeft:t.top-E.top+$.scrollTop,l=b==="x"?t.width:t.height,g=Y();}else s=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,g=Y();let _=Ee({top:s,height:l},g,Pe(),ke,Ae);N=_.tStart,R=_.tEnd,U&&process.env.NODE_ENV!=="production"&&(ge?.remove(),ge=Ze(N,R,b));}function Be(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),z){let l=s==="reverse"?1-t:t;e.style.clipPath=j(l);return}x.forEach((l,g)=>{l.style.strokeDashoffset=s==="reverse"?`${v[g]*t}`:`${v[g]*(1-t)}`,u&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),O&&S?l.style.stroke=Se(O,S,t):S&&(l.style.stroke=S),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),A!==null&&T!==null?l.style.fillOpacity=`${A+(T-A)*t}`:T!==null&&(l.style.fillOpacity=`${T}`),C&&l.tagName.toLowerCase()==="path"&&F[g]&&l.setAttribute("d",We(F[g],C,t));});}function De(){if(e.style.setProperty("--scroll-draw-progress","0"),z){e.style.clipPath=j(0);return}x.forEach((t,s)=>{t.style.strokeDasharray=`${v[s]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${v[s]}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`),C&&t.tagName.toLowerCase()==="path"&&F[s]&&t.setAttribute("d",F[s]);});}if(x.forEach(t=>{Ye(t);let s=xe(t);v.push(s),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?`${s}`:"0",u&&(t.style.opacity="1"),S&&(t.style.stroke=S),k!==null&&(t.style.strokeWidth=`${k}`),T!==null&&(t.style.fillOpacity=`${T}`),C&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",C)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=a==="reverse"?"0":`${s}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`));}),z){if(n)return e.style.clipPath=j(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function _e(){return !(qe===false||!Qe()||!x.length||typeof p!="string"||!(p in Re)||z||b!=="y"||$||c!==1||I!==0||d||ee||re!==false||C||te||J||pe>0||ye||he||K||H!=null||V!=null||G!=null||(h.start??"top bottom").trim()!=="top bottom"||(h.end??"bottom top").trim()!=="bottom top")}function Xe(){let t=`svg-scroll-draw-${++Ke}`,s=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${s};`,_=`stroke-dashoffset:${l};`;u&&(g+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let E=document.createElement("style");E.setAttribute("data-svg-scroll-draw",""),E.textContent=`@keyframes ${t}{from{${g}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(E);function i(m,L){m.style.setProperty("--ssd-len",String(v[L])),m.style.strokeDasharray=`${v[L]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(t);}x.forEach(i);let f=false,w=-1;function y(){if(w>=0)return w;let m=e.getBoundingClientRect(),{tStart:L,tEnd:Z}=Ee({top:m.top,height:m.height},Y(),Pe(),ke,Ae);return ne(X(Y(),L,Z,c))}return {destroy(){x.forEach(m=>{m.classList.remove(t),m.style.removeProperty("--ssd-len"),m.style.animationPlayState="";}),E.remove();},replay(){f=false,w=-1,x.forEach(i);},pause(){f=true,x.forEach(m=>{m.style.animationPlayState="paused";});},resume(){f&&(f=false,x.forEach(m=>{m.style.animationPlayState="running";}));},seek(m){let L=Math.min(1,Math.max(0,m));w=L,f=true,x.forEach((Z,Ie)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${v[Ie]*L}`:`${v[Ie]*(1-L)}`,u&&(Z.style.opacity=a==="reverse"?`${1-L}`:`${L}`);});},getProgress(){return y()}}}if(_e())return Xe();Le();function ce(){if(!se||B)return;let t=performance.now(),s=Y(),l=c;if(re!==false){let i=t-Te,f=i>0?Math.abs(s-(ue<0?s:ue))/i:0;l=c*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=s,Te=t;let g=ee?oe===-1||s>=oe?"forward":"reverse":a;oe=s;let _=R-N,E=true;if(z){let i=ne(X(s,N,R,l));d&&!ee&&(P=Math.max(P,i),i=P),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=g==="reverse"?1-i:i;e.style.clipPath=j(f),ye?.(i),!q&&X(s,N,R,l)>0&&(q=true,he?.()),i>=1&&!D?(D=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,q=false,D=false,e.style.clipPath=j(0);},Me))):i<1&&!d&&(D=false),W=requestAnimationFrame(ce);return}if(x.forEach((i,f)=>{let w=f*I*_,y=ne(X(s,N+w,R+w,l));d&&!ee&&(P=Math.max(P,y),y=P),ie=y,i.style.strokeDashoffset=g==="reverse"?`${v[f]*y}`:`${v[f]*(1-y)}`,u&&(i.style.opacity=g==="reverse"?`${1-y}`:`${y}`),O&&S?i.style.stroke=Se(O,S,y):S&&(i.style.stroke=S),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),A!==null&&T!==null?i.style.fillOpacity=`${A+(T-A)*y}`:T!==null&&(i.style.fillOpacity=`${T}`),C&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",We(F[f],C,y)),f===0&&(ye?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(E=false);}),te){let i=ne(X(s,N,R,l));for(let f in te){let w=parseFloat(f);i>=w&&!le.has(w)&&(le.add(w),te[f]?.());}}!q&&X(s,N,R,l)>0&&(q=true,he?.()),E&&!D?(D=true,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{P=-1,q=false,D=false,le.clear(),De();},Me))):!E&&!d&&(D=false),W=requestAnimationFrame(ce);}let be=new IntersectionObserver(t=>{t.forEach(s=>{se=s.isIntersecting,se&&!B?W=requestAnimationFrame(ce):cancelAnimationFrame(W);});},{root:$??null,threshold:Ge,rootMargin:ze}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{x.forEach((t,s)=>{v[s]=xe(t),t.style.strokeDasharray=`${v[s]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),pe>0?setTimeout(()=>be.observe(e),pe):be.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ae),be.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),ge?.remove();},replay(){P=-1,oe=-1,ue=-1,q=false,D=false,Q=0,B=false,le.clear(),clearTimeout(ae),De();},pause(){B=true,cancelAnimationFrame(W);},resume(){B&&(B=false,se&&(W=requestAnimationFrame(ce)));},seek(t){let s=Math.min(1,Math.max(0,t));ie=s,P=s,B=true,cancelAnimationFrame(W),Be(s,a);},getProgress(){return ie}}}var Ve=class{constructor(){this.instance=null;}init(r,n={}){return this.destroy(),this.instance=He(r,n),this}replay(){return this.instance?.replay(),this}destroy(){return this.instance?.destroy(),this.instance=null,this}};export{Ve as ScrollDrawRef};
@@ -1,3 +1,3 @@
1
- 'use strict';var ve={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2)};function Se(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Oe(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Ce(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Ee(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Xe(e,r,n){return Math.min(n,Math.max(r,e))}function B(e,r,n,o){return n===r?0:Xe((e-r)/(n-r)*o,0,1)}function $e(e,r,n,o,c){let d=Oe(e.top,e.height,r,o.element)-Ce(o.viewport,n),p=Oe(e.top,e.height,r,c.element)-Ce(c.viewport,n);return {tStart:d,tEnd:p}}function Fe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function xe(e,r,n){let o=Fe(e),c=Fe(r);return !o||!c?e:`rgb(${Math.round(o[0]+(c[0]-o[0])*n)},${Math.round(o[1]+(c[1]-o[1])*n)},${Math.round(o[2]+(c[2]-o[2])*n)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Je=0;function Ue(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function je(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ke(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function c(){let d=n==="x"?window.scrollX:window.scrollY,p=e-d,M=r-d,X=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${X?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
- <div style="position:absolute;${X?`left:${M}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${M}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(o),window.addEventListener("scroll",c,{passive:true}),c(),o}function He(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let p=parseFloat(d),M=o[c++]??p;return String(+(p+(M-p)*n).toFixed(4))})}function fe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:c=1,fade:d=false,easing:p="linear",trigger:M={},stagger:X=0,direction:y="forward",once:J=false,debug:Ve=false,axis:S="y",scrollContainer:pe,autoReverse:Z=false,delay:me=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:We=0,rootMargin:Ge="0px",repeat:U=0,repeatDelay:ke=0,morphTo:P,clip:de,native:ze=true,onProgress:ye,onStart:ge,onComplete:j}=r,W=de===true?"left":typeof de=="string"?de:false,re=typeof p=="function"?p:ve[p]??ve.linear,Ae=Se(M.start??"top bottom"),De=Se(M.end??"bottom top"),b=typeof pe=="string"?document.querySelector(pe):pe??null,I=Array.isArray(R)?R[0]:null,E=Array.isArray(R)?R[1]:typeof R=="string"?R:null,$=Array.isArray(H)?H[0]:null,x=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,A=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(t){let s=t*100;switch(W){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let w=W?[]:Array.from(e.querySelectorAll(o)),g=[],O=[],C=0,F=0,L=false,G=false,N=0,ne=false,D=-1,se=-1,z=false,oe=0,K=0,ie,he=null,ae=new Set,le=-1,Te=performance.now();function Q(){return b?S==="x"?b.scrollLeft:b.scrollTop:S==="x"?window.scrollX:window.scrollY}function Me(){return b?S==="x"?b.clientWidth:b.clientHeight:S==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),s,a,m;if(b){let v=b.getBoundingClientRect();s=S==="x"?t.left-v.left+b.scrollLeft:t.top-v.top+b.scrollTop,a=S==="x"?t.width:t.height,m=Q();}else s=S==="x"?t.left:t.top,a=S==="x"?t.width:t.height,m=Q();let q=$e({top:s,height:a},m,Me(),Ae,De);C=q.tStart,F=q.tEnd,Ve&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=Ke(C,F,S));}function qe(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=s==="reverse"?1-t:t;e.style.clipPath=_(a);return}w.forEach((a,m)=>{a.style.strokeDashoffset=s==="reverse"?`${g[m]*t}`:`${g[m]*(1-t)}`,d&&(a.style.opacity=s==="reverse"?`${1-t}`:`${t}`),I&&E?a.style.stroke=xe(I,E,t):E&&(a.style.stroke=E),$!==null&&x!==null?a.style.strokeWidth=`${$+(x-$)*t}`:x!==null&&(a.style.strokeWidth=`${x}`),k!==null&&A!==null?a.style.fillOpacity=`${k+(A-k)*t}`:A!==null&&(a.style.fillOpacity=`${A}`),P&&a.tagName.toLowerCase()==="path"&&O[m]&&a.setAttribute("d",He(O[m],P,t));});}function Pe(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}w.forEach((t,s)=>{t.style.strokeDasharray=`${g[s]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${g[s]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),$!==null&&(t.style.strokeWidth=`${$}`),k!==null&&(t.style.fillOpacity=`${k}`),P&&t.tagName.toLowerCase()==="path"&&O[s]&&t.setAttribute("d",O[s]);});}if(w.forEach(t=>{je(t);let s=Ee(t);g.push(s),t.tagName.toLowerCase()==="path"?O.push(t.getAttribute("d")??""):O.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?`${s}`:"0",d&&(t.style.opacity="1"),E&&(t.style.stroke=E),x!==null&&(t.style.strokeWidth=`${x}`),A!==null&&(t.style.fillOpacity=`${A}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?"0":`${s}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),$!==null&&(t.style.strokeWidth=`${$}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(n)return e.style.clipPath=_(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(n)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Be(){return !(ze===false||!Ue()||!w.length||typeof p!="string"||!(p in Re)||W||S!=="y"||b||c!==1||X!==0||J||Z||te!==false||P||ee||U||me>0||ye||ge||j||R!=null||H!=null||V!=null||(M.start??"top bottom").trim()!=="top bottom"||(M.end??"bottom top").trim()!=="bottom top")}function _e(){let t=`svg-scroll-draw-${++Je}`,s=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",m=`stroke-dashoffset:${s};`,q=`stroke-dashoffset:${a};`;d&&(m+=`opacity:${y==="reverse"?1:0};`,q+=`opacity:${y==="reverse"?0:1};`);let v=document.createElement("style");v.setAttribute("data-svg-scroll-draw",""),v.textContent=`@keyframes ${t}{from{${m}}to{${q}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(v);function i(u,T){u.style.setProperty("--ssd-len",String(g[T])),u.style.strokeDasharray=`${g[T]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(t);}w.forEach(i);let l=false,h=-1;function f(){if(h>=0)return h;let u=e.getBoundingClientRect(),{tStart:T,tEnd:Y}=$e({top:u.top,height:u.height},Q(),Me(),Ae,De);return re(B(Q(),T,Y,c))}return {destroy(){w.forEach(u=>{u.classList.remove(t),u.style.removeProperty("--ssd-len"),u.style.animationPlayState="";}),v.remove();},replay(){l=false,h=-1,w.forEach(i);},pause(){l=true,w.forEach(u=>{u.style.animationPlayState="paused";});},resume(){l&&(l=false,w.forEach(u=>{u.style.animationPlayState="running";}));},seek(u){let T=Math.min(1,Math.max(0,u));h=T,l=true,w.forEach((Y,Ie)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${g[Ie]*T}`:`${g[Ie]*(1-T)}`,d&&(Y.style.opacity=y==="reverse"?`${1-T}`:`${T}`);});},getProgress(){return f()}}}if(Be())return _e();Le();function ue(){if(!ne||z)return;let t=performance.now(),s=Q(),a=c;if(te!==false){let i=t-Te,l=i>0?Math.abs(s-(le<0?s:le))/i:0;a=c*Math.max(.2,1+l*(typeof te=="number"?te:1)*.04);}le=s,Te=t;let m=Z?se===-1||s>=se?"forward":"reverse":y;se=s;let q=F-C,v=true;if(W){let i=re(B(s,C,F,a));J&&!Z&&(D=Math.max(D,i),i=D),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let l=m==="reverse"?1-i:i;e.style.clipPath=_(l),ye?.(i),!G&&B(s,C,F,a)>0&&(G=true,ge?.()),i>=1&&!L?(L=true,j?.(),K<(U==="infinite"?1/0:U??0)&&(K++,ie=setTimeout(()=>{D=-1,G=false,L=false,e.style.clipPath=_(0);},ke))):i<1&&!J&&(L=false),N=requestAnimationFrame(ue);return}if(w.forEach((i,l)=>{let h=l*X*q,f=re(B(s,C+h,F+h,a));J&&!Z&&(D=Math.max(D,f),f=D),oe=f,i.style.strokeDashoffset=m==="reverse"?`${g[l]*f}`:`${g[l]*(1-f)}`,d&&(i.style.opacity=m==="reverse"?`${1-f}`:`${f}`),I&&E?i.style.stroke=xe(I,E,f):E&&(i.style.stroke=E),$!==null&&x!==null?i.style.strokeWidth=`${$+(x-$)*f}`:x!==null&&(i.style.strokeWidth=`${x}`),k!==null&&A!==null?i.style.fillOpacity=`${k+(A-k)*f}`:A!==null&&(i.style.fillOpacity=`${A}`),P&&i.tagName.toLowerCase()==="path"&&O[l]&&i.setAttribute("d",He(O[l],P,f)),l===0&&(ye?.(f),e.style.setProperty("--scroll-draw-progress",String(f))),f<1&&(v=false);}),ee){let i=re(B(s,C,F,a));for(let l in ee){let h=parseFloat(l);i>=h&&!ae.has(h)&&(ae.add(h),ee[l]?.());}}!G&&B(s,C,F,a)>0&&(G=true,ge?.()),v&&!L?(L=true,j?.(),K<(U==="infinite"?1/0:U??0)&&(K++,ie=setTimeout(()=>{D=-1,G=false,L=false,ae.clear(),Pe();},ke))):!v&&!J&&(L=false),N=requestAnimationFrame(ue);}let be=new IntersectionObserver(t=>{t.forEach(s=>{ne=s.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:We,rootMargin:Ge}),we;function ce(){clearTimeout(we),we=setTimeout(()=>{w.forEach((t,s)=>{g[s]=Ee(t),t.style.strokeDasharray=`${g[s]}`;}),Le();},150);}return window.addEventListener("resize",ce),window.addEventListener("orientationchange",ce),me>0?setTimeout(()=>be.observe(e),me):be.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),be.disconnect(),window.removeEventListener("resize",ce),window.removeEventListener("orientationchange",ce),clearTimeout(we),he?.remove();},replay(){D=-1,se=-1,le=-1,G=false,L=false,K=0,z=false,ae.clear(),clearTimeout(ie),Pe();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let s=Math.min(1,Math.max(0,t));oe=s,D=s,z=true,cancelAnimationFrame(N),qe(s,y);},getProgress(){return oe}}}function Qe(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let o=typeof e=="string"?document.querySelector(e):e;return o?fe(o,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function it(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let o=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";o&&(n=JSON.parse(o));}catch{}return fe(r,n)})}exports.initScrollDraw=it;exports.scrollDraw=Qe;
1
+ 'use strict';function Re({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(s),u=0,m=[];for(let a=0;a<n;a++){let d=Math.pow(c,a);m.push(d),u+=d;}let h=[0],I=0;for(let a=0;a<n;a++)I+=m[a]/u,h.push(I);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=h[d+1]){let J=(a-h[d])/(h[d+1]-h[d]);if(d===0)return J*(2-J);let b=1-Math.pow(s,d);return b+(1-b)*(2*J-1)*(2*J-1)}return 1}}function We({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),c=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return u=>u<=0?0:u>=1?1:n*Math.pow(2,-10*u)*Math.sin((u-c)*(2*Math.PI)/s)+1}var xe={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Re(),elastic:We()};function Ee(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",s="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:s}}function Ce(e,r,n,s){switch(s){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Fe(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Se(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),s=parseFloat(e.getAttribute("height")??"0");return 2*(n+s)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ue(e,r,n){return Math.min(n,Math.max(r,e))}function X(e,r,n,s){return n===r?0:Ue((e-r)/(n-r)*s,0,1)}function $e(e,r,n,s,c){let u=Ce(e.top,e.height,r,s.element)-Fe(s.viewport,n),m=Ce(e.top,e.height,r,c.element)-Fe(c.viewport,n);return {tStart:u,tEnd:m}}function Ne(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function Me(e,r,n){let s=Ne(e),c=Ne(r);return !s||!c?e:`rgb(${Math.round(s[0]+(c[0]-s[0])*n)},${Math.round(s[1]+(c[1]-s[1])*n)},${Math.round(s[2]+(c[2]-s[2])*n)})`}function He(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ve={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},je=0;function Ke(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Qe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?He("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&He("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ye(e,r,n){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function c(){let u=n==="x"?window.scrollX:window.scrollY,m=e-u,h=r-u,I=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${I?`left:${m}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${m}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
+ <div style="position:absolute;${I?`left:${h}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${h}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(s),window.addEventListener("scroll",c,{passive:true}),c(),s}function qe(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let m=parseFloat(u),h=s[c++]??m;return String(+(m+(h-m)*n).toFixed(4))})}function pe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:s="path, polyline, line, polygon, rect, circle",speed:c=1,fade:u=false,easing:m="linear",trigger:h={},stagger:I=0,direction:a="forward",once:d=false,debug:J=false,axis:b="y",scrollContainer:me,autoReverse:ee=false,delay:de=0,strokeColor:H,strokeWidth:V,fillOpacity:q,waypoints:te,velocityScale:re=false,threshold:Ge=0,rootMargin:ze="0px",repeat:j=0,repeatDelay:ke=0,morphTo:O,clip:ye,native:Be=true,onProgress:he,onStart:ge,onComplete:K}=r,G=ye===true?"left":typeof ye=="string"?ye:false,ne=typeof m=="function"?m:xe[m]??xe.linear,Ae=Ee(h.start??"top bottom"),De=Ee(h.end??"bottom top"),x=typeof me=="string"?document.querySelector(me):me??null,C=Array.isArray(H)?H[0]:null,$=Array.isArray(H)?H[1]:typeof H=="string"?H:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,A=Array.isArray(q)?q[0]:null,D=Array.isArray(q)?q[1]:typeof q=="number"?q:null;function U(t){let o=t*100;switch(G){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let E=G?[]:Array.from(e.querySelectorAll(s)),w=[],F=[],N=0,R=0,L=false,z=false,W=0,se=false,T=-1,oe=-1,B=false,ie=0,Q=0,ae,be=null,le=new Set,ue=-1,Te=performance.now();function Y(){return x?b==="x"?x.scrollLeft:x.scrollTop:b==="x"?window.scrollX:window.scrollY}function Pe(){return x?b==="x"?x.clientWidth:x.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),o,l,g;if(x){let S=x.getBoundingClientRect();o=b==="x"?t.left-S.left+x.scrollLeft:t.top-S.top+x.scrollTop,l=b==="x"?t.width:t.height,g=Y();}else o=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,g=Y();let _=$e({top:o,height:l},g,Pe(),Ae,De);N=_.tStart,R=_.tEnd,J&&process.env.NODE_ENV!=="production"&&(be?.remove(),be=Ye(N,R,b));}function _e(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),G){let l=o==="reverse"?1-t:t;e.style.clipPath=U(l);return}E.forEach((l,g)=>{l.style.strokeDashoffset=o==="reverse"?`${w[g]*t}`:`${w[g]*(1-t)}`,u&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),C&&$?l.style.stroke=Me(C,$,t):$&&(l.style.stroke=$),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),A!==null&&D!==null?l.style.fillOpacity=`${A+(D-A)*t}`:D!==null&&(l.style.fillOpacity=`${D}`),O&&l.tagName.toLowerCase()==="path"&&F[g]&&l.setAttribute("d",qe(F[g],O,t));});}function Ie(){if(e.style.setProperty("--scroll-draw-progress","0"),G){e.style.clipPath=U(0);return}E.forEach((t,o)=>{t.style.strokeDasharray=`${w[o]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${w[o]}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`),O&&t.tagName.toLowerCase()==="path"&&F[o]&&t.setAttribute("d",F[o]);});}if(E.forEach(t=>{Qe(t);let o=Se(t);w.push(o),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?`${o}`:"0",u&&(t.style.opacity="1"),$&&(t.style.stroke=$),k!==null&&(t.style.strokeWidth=`${k}`),D!==null&&(t.style.fillOpacity=`${D}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?"0":`${o}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`));}),G){if(n)return e.style.clipPath=U(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=U(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Xe(){return !(Be===false||!Ke()||!E.length||typeof m!="string"||!(m in Ve)||G||b!=="y"||x||c!==1||I!==0||d||ee||re!==false||O||te||j||de>0||he||ge||K||H!=null||V!=null||q!=null||(h.start??"top bottom").trim()!=="top bottom"||(h.end??"bottom top").trim()!=="bottom top")}function Je(){let t=`svg-scroll-draw-${++je}`,o=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${o};`,_=`stroke-dashoffset:${l};`;u&&(g+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let S=document.createElement("style");S.setAttribute("data-svg-scroll-draw",""),S.textContent=`@keyframes ${t}{from{${g}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Ve[m]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(S);function i(p,P){p.style.setProperty("--ssd-len",String(w[P])),p.style.strokeDasharray=`${w[P]}`,p.style.strokeDashoffset="",p.style.opacity="",p.style.animationPlayState="",p.classList.add(t);}E.forEach(i);let f=false,v=-1;function y(){if(v>=0)return v;let p=e.getBoundingClientRect(),{tStart:P,tEnd:Z}=$e({top:p.top,height:p.height},Y(),Pe(),Ae,De);return ne(X(Y(),P,Z,c))}return {destroy(){E.forEach(p=>{p.classList.remove(t),p.style.removeProperty("--ssd-len"),p.style.animationPlayState="";}),S.remove();},replay(){f=false,v=-1,E.forEach(i);},pause(){f=true,E.forEach(p=>{p.style.animationPlayState="paused";});},resume(){f&&(f=false,E.forEach(p=>{p.style.animationPlayState="running";}));},seek(p){let P=Math.min(1,Math.max(0,p));v=P,f=true,E.forEach((Z,Oe)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${w[Oe]*P}`:`${w[Oe]*(1-P)}`,u&&(Z.style.opacity=a==="reverse"?`${1-P}`:`${P}`);});},getProgress(){return y()}}}if(Xe())return Je();Le();function ce(){if(!se||B)return;let t=performance.now(),o=Y(),l=c;if(re!==false){let i=t-Te,f=i>0?Math.abs(o-(ue<0?o:ue))/i:0;l=c*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=o,Te=t;let g=ee?oe===-1||o>=oe?"forward":"reverse":a;oe=o;let _=R-N,S=true;if(G){let i=ne(X(o,N,R,l));d&&!ee&&(T=Math.max(T,i),i=T),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=g==="reverse"?1-i:i;e.style.clipPath=U(f),he?.(i),!z&&X(o,N,R,l)>0&&(z=true,ge?.()),i>=1&&!L?(L=true,K?.(),Q<(j==="infinite"?1/0:j??0)&&(Q++,ae=setTimeout(()=>{T=-1,z=false,L=false,e.style.clipPath=U(0);},ke))):i<1&&!d&&(L=false),W=requestAnimationFrame(ce);return}if(E.forEach((i,f)=>{let v=f*I*_,y=ne(X(o,N+v,R+v,l));d&&!ee&&(T=Math.max(T,y),y=T),ie=y,i.style.strokeDashoffset=g==="reverse"?`${w[f]*y}`:`${w[f]*(1-y)}`,u&&(i.style.opacity=g==="reverse"?`${1-y}`:`${y}`),C&&$?i.style.stroke=Me(C,$,y):$&&(i.style.stroke=$),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),A!==null&&D!==null?i.style.fillOpacity=`${A+(D-A)*y}`:D!==null&&(i.style.fillOpacity=`${D}`),O&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",qe(F[f],O,y)),f===0&&(he?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(S=false);}),te){let i=ne(X(o,N,R,l));for(let f in te){let v=parseFloat(f);i>=v&&!le.has(v)&&(le.add(v),te[f]?.());}}!z&&X(o,N,R,l)>0&&(z=true,ge?.()),S&&!L?(L=true,K?.(),Q<(j==="infinite"?1/0:j??0)&&(Q++,ae=setTimeout(()=>{T=-1,z=false,L=false,le.clear(),Ie();},ke))):!S&&!d&&(L=false),W=requestAnimationFrame(ce);}let we=new IntersectionObserver(t=>{t.forEach(o=>{se=o.isIntersecting,se&&!B?W=requestAnimationFrame(ce):cancelAnimationFrame(W);});},{root:x??null,threshold:Ge,rootMargin:ze}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{E.forEach((t,o)=>{w[o]=Se(t),t.style.strokeDasharray=`${w[o]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),de>0?setTimeout(()=>we.observe(e),de):we.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ae),we.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),be?.remove();},replay(){T=-1,oe=-1,ue=-1,z=false,L=false,Q=0,B=false,le.clear(),clearTimeout(ae),Ie();},pause(){B=true,cancelAnimationFrame(W);},resume(){B&&(B=false,se&&(W=requestAnimationFrame(ce)));},seek(t){let o=Math.min(1,Math.max(0,t));ie=o,T=o,B=true,cancelAnimationFrame(W),_e(o,a);},getProgress(){return ie}}}function Ze(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=typeof e=="string"?document.querySelector(e):e;return s?pe(s,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function lt(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let s=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";s&&(n=JSON.parse(s));}catch{}return pe(r,n)})}exports.initScrollDraw=lt;exports.scrollDraw=Ze;
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface TriggerConfig {
3
3
  start?: string;
4
4
  end?: string;
@@ -1,4 +1,4 @@
1
- type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
2
  interface TriggerConfig {
3
3
  start?: string;
4
4
  end?: string;
@@ -1,3 +1,3 @@
1
- var ve={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2)};function Se(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Oe(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Ce(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Ee(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Xe(e,r,n){return Math.min(n,Math.max(r,e))}function B(e,r,n,o){return n===r?0:Xe((e-r)/(n-r)*o,0,1)}function $e(e,r,n,o,c){let d=Oe(e.top,e.height,r,o.element)-Ce(o.viewport,n),p=Oe(e.top,e.height,r,c.element)-Ce(c.viewport,n);return {tStart:d,tEnd:p}}function Fe(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function xe(e,r,n){let o=Fe(e),c=Fe(r);return !o||!c?e:`rgb(${Math.round(o[0]+(c[0]-o[0])*n)},${Math.round(o[1]+(c[1]-o[1])*n)},${Math.round(o[2]+(c[2]-o[2])*n)})`}function Ne(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Re={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Je=0;function Ue(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function je(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Ne("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Ne("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ke(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function c(){let d=n==="x"?window.scrollX:window.scrollY,p=e-d,M=r-d,X=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${X?`left:${p}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${p}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
- <div style="position:absolute;${X?`left:${M}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${M}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(o),window.addEventListener("scroll",c,{passive:true}),c(),o}function He(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,d=>{let p=parseFloat(d),M=o[c++]??p;return String(+(p+(M-p)*n).toFixed(4))})}function fe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:c=1,fade:d=false,easing:p="linear",trigger:M={},stagger:X=0,direction:y="forward",once:J=false,debug:Ve=false,axis:S="y",scrollContainer:pe,autoReverse:Z=false,delay:me=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=false,threshold:We=0,rootMargin:Ge="0px",repeat:U=0,repeatDelay:ke=0,morphTo:P,clip:de,native:ze=true,onProgress:ye,onStart:ge,onComplete:j}=r,W=de===true?"left":typeof de=="string"?de:false,re=typeof p=="function"?p:ve[p]??ve.linear,Ae=Se(M.start??"top bottom"),De=Se(M.end??"bottom top"),b=typeof pe=="string"?document.querySelector(pe):pe??null,I=Array.isArray(R)?R[0]:null,E=Array.isArray(R)?R[1]:typeof R=="string"?R:null,$=Array.isArray(H)?H[0]:null,x=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,A=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(t){let s=t*100;switch(W){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let w=W?[]:Array.from(e.querySelectorAll(o)),g=[],O=[],C=0,F=0,L=false,G=false,N=0,ne=false,D=-1,se=-1,z=false,oe=0,K=0,ie,he=null,ae=new Set,le=-1,Te=performance.now();function Q(){return b?S==="x"?b.scrollLeft:b.scrollTop:S==="x"?window.scrollX:window.scrollY}function Me(){return b?S==="x"?b.clientWidth:b.clientHeight:S==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),s,a,m;if(b){let v=b.getBoundingClientRect();s=S==="x"?t.left-v.left+b.scrollLeft:t.top-v.top+b.scrollTop,a=S==="x"?t.width:t.height,m=Q();}else s=S==="x"?t.left:t.top,a=S==="x"?t.width:t.height,m=Q();let q=$e({top:s,height:a},m,Me(),Ae,De);C=q.tStart,F=q.tEnd,Ve&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=Ke(C,F,S));}function qe(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let a=s==="reverse"?1-t:t;e.style.clipPath=_(a);return}w.forEach((a,m)=>{a.style.strokeDashoffset=s==="reverse"?`${g[m]*t}`:`${g[m]*(1-t)}`,d&&(a.style.opacity=s==="reverse"?`${1-t}`:`${t}`),I&&E?a.style.stroke=xe(I,E,t):E&&(a.style.stroke=E),$!==null&&x!==null?a.style.strokeWidth=`${$+(x-$)*t}`:x!==null&&(a.style.strokeWidth=`${x}`),k!==null&&A!==null?a.style.fillOpacity=`${k+(A-k)*t}`:A!==null&&(a.style.fillOpacity=`${A}`),P&&a.tagName.toLowerCase()==="path"&&O[m]&&a.setAttribute("d",He(O[m],P,t));});}function Pe(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}w.forEach((t,s)=>{t.style.strokeDasharray=`${g[s]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${g[s]}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),$!==null&&(t.style.strokeWidth=`${$}`),k!==null&&(t.style.fillOpacity=`${k}`),P&&t.tagName.toLowerCase()==="path"&&O[s]&&t.setAttribute("d",O[s]);});}if(w.forEach(t=>{je(t);let s=Ee(t);g.push(s),t.tagName.toLowerCase()==="path"?O.push(t.getAttribute("d")??""):O.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?`${s}`:"0",d&&(t.style.opacity="1"),E&&(t.style.stroke=E),x!==null&&(t.style.strokeWidth=`${x}`),A!==null&&(t.style.fillOpacity=`${A}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?"0":`${s}`,d?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),$!==null&&(t.style.strokeWidth=`${$}`),k!==null&&(t.style.fillOpacity=`${k}`));}),W){if(n)return e.style.clipPath=_(1),j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0);}else if(n)return j?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Be(){return !(ze===false||!Ue()||!w.length||typeof p!="string"||!(p in Re)||W||S!=="y"||b||c!==1||X!==0||J||Z||te!==false||P||ee||U||me>0||ye||ge||j||R!=null||H!=null||V!=null||(M.start??"top bottom").trim()!=="top bottom"||(M.end??"bottom top").trim()!=="bottom top")}function _e(){let t=`svg-scroll-draw-${++Je}`,s=y==="reverse"?"0":"var(--ssd-len)",a=y==="reverse"?"var(--ssd-len)":"0",m=`stroke-dashoffset:${s};`,q=`stroke-dashoffset:${a};`;d&&(m+=`opacity:${y==="reverse"?1:0};`,q+=`opacity:${y==="reverse"?0:1};`);let v=document.createElement("style");v.setAttribute("data-svg-scroll-draw",""),v.textContent=`@keyframes ${t}{from{${m}}to{${q}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Re[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(v);function i(u,T){u.style.setProperty("--ssd-len",String(g[T])),u.style.strokeDasharray=`${g[T]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(t);}w.forEach(i);let l=false,h=-1;function f(){if(h>=0)return h;let u=e.getBoundingClientRect(),{tStart:T,tEnd:Y}=$e({top:u.top,height:u.height},Q(),Me(),Ae,De);return re(B(Q(),T,Y,c))}return {destroy(){w.forEach(u=>{u.classList.remove(t),u.style.removeProperty("--ssd-len"),u.style.animationPlayState="";}),v.remove();},replay(){l=false,h=-1,w.forEach(i);},pause(){l=true,w.forEach(u=>{u.style.animationPlayState="paused";});},resume(){l&&(l=false,w.forEach(u=>{u.style.animationPlayState="running";}));},seek(u){let T=Math.min(1,Math.max(0,u));h=T,l=true,w.forEach((Y,Ie)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${g[Ie]*T}`:`${g[Ie]*(1-T)}`,d&&(Y.style.opacity=y==="reverse"?`${1-T}`:`${T}`);});},getProgress(){return f()}}}if(Be())return _e();Le();function ue(){if(!ne||z)return;let t=performance.now(),s=Q(),a=c;if(te!==false){let i=t-Te,l=i>0?Math.abs(s-(le<0?s:le))/i:0;a=c*Math.max(.2,1+l*(typeof te=="number"?te:1)*.04);}le=s,Te=t;let m=Z?se===-1||s>=se?"forward":"reverse":y;se=s;let q=F-C,v=true;if(W){let i=re(B(s,C,F,a));J&&!Z&&(D=Math.max(D,i),i=D),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let l=m==="reverse"?1-i:i;e.style.clipPath=_(l),ye?.(i),!G&&B(s,C,F,a)>0&&(G=true,ge?.()),i>=1&&!L?(L=true,j?.(),K<(U==="infinite"?1/0:U??0)&&(K++,ie=setTimeout(()=>{D=-1,G=false,L=false,e.style.clipPath=_(0);},ke))):i<1&&!J&&(L=false),N=requestAnimationFrame(ue);return}if(w.forEach((i,l)=>{let h=l*X*q,f=re(B(s,C+h,F+h,a));J&&!Z&&(D=Math.max(D,f),f=D),oe=f,i.style.strokeDashoffset=m==="reverse"?`${g[l]*f}`:`${g[l]*(1-f)}`,d&&(i.style.opacity=m==="reverse"?`${1-f}`:`${f}`),I&&E?i.style.stroke=xe(I,E,f):E&&(i.style.stroke=E),$!==null&&x!==null?i.style.strokeWidth=`${$+(x-$)*f}`:x!==null&&(i.style.strokeWidth=`${x}`),k!==null&&A!==null?i.style.fillOpacity=`${k+(A-k)*f}`:A!==null&&(i.style.fillOpacity=`${A}`),P&&i.tagName.toLowerCase()==="path"&&O[l]&&i.setAttribute("d",He(O[l],P,f)),l===0&&(ye?.(f),e.style.setProperty("--scroll-draw-progress",String(f))),f<1&&(v=false);}),ee){let i=re(B(s,C,F,a));for(let l in ee){let h=parseFloat(l);i>=h&&!ae.has(h)&&(ae.add(h),ee[l]?.());}}!G&&B(s,C,F,a)>0&&(G=true,ge?.()),v&&!L?(L=true,j?.(),K<(U==="infinite"?1/0:U??0)&&(K++,ie=setTimeout(()=>{D=-1,G=false,L=false,ae.clear(),Pe();},ke))):!v&&!J&&(L=false),N=requestAnimationFrame(ue);}let be=new IntersectionObserver(t=>{t.forEach(s=>{ne=s.isIntersecting,ne&&!z?N=requestAnimationFrame(ue):cancelAnimationFrame(N);});},{root:b??null,threshold:We,rootMargin:Ge}),we;function ce(){clearTimeout(we),we=setTimeout(()=>{w.forEach((t,s)=>{g[s]=Ee(t),t.style.strokeDasharray=`${g[s]}`;}),Le();},150);}return window.addEventListener("resize",ce),window.addEventListener("orientationchange",ce),me>0?setTimeout(()=>be.observe(e),me):be.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),be.disconnect(),window.removeEventListener("resize",ce),window.removeEventListener("orientationchange",ce),clearTimeout(we),he?.remove();},replay(){D=-1,se=-1,le=-1,G=false,L=false,K=0,z=false,ae.clear(),clearTimeout(ie),Pe();},pause(){z=true,cancelAnimationFrame(N);},resume(){z&&(z=false,ne&&(N=requestAnimationFrame(ue)));},seek(t){let s=Math.min(1,Math.max(0,t));oe=s,D=s,z=true,cancelAnimationFrame(N),qe(s,y);},getProgress(){return oe}}}function Qe(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let o=typeof e=="string"?document.querySelector(e):e;return o?fe(o,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function it(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let o=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";o&&(n=JSON.parse(o));}catch{}return fe(r,n)})}export{it as initScrollDraw,Qe as scrollDraw};
1
+ function Re({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(s),u=0,m=[];for(let a=0;a<n;a++){let d=Math.pow(c,a);m.push(d),u+=d;}let h=[0],I=0;for(let a=0;a<n;a++)I+=m[a]/u,h.push(I);return a=>{if(a<=0)return 0;if(a>=1)return 1;for(let d=0;d<n;d++)if(a<=h[d+1]){let J=(a-h[d])/(h[d+1]-h[d]);if(d===0)return J*(2-J);let b=1-Math.pow(s,d);return b+(1-b)*(2*J-1)*(2*J-1)}return 1}}function We({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),c=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return u=>u<=0?0:u>=1?1:n*Math.pow(2,-10*u)*Math.sin((u-c)*(2*Math.PI)/s)+1}var xe={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Re(),elastic:We()};function Ee(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",s="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:s}}function Ce(e,r,n,s){switch(s){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Fe(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Se(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),s=parseFloat(e.getAttribute("height")??"0");return 2*(n+s)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function Ue(e,r,n){return Math.min(n,Math.max(r,e))}function X(e,r,n,s){return n===r?0:Ue((e-r)/(n-r)*s,0,1)}function $e(e,r,n,s,c){let u=Ce(e.top,e.height,r,s.element)-Fe(s.viewport,n),m=Ce(e.top,e.height,r,c.element)-Fe(c.viewport,n);return {tStart:u,tEnd:m}}function Ne(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function Me(e,r,n){let s=Ne(e),c=Ne(r);return !s||!c?e:`rgb(${Math.round(s[0]+(c[0]-s[0])*n)},${Math.round(s[1]+(c[1]-s[1])*n)},${Math.round(s[2]+(c[2]-s[2])*n)})`}function He(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ve={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},je=0;function Ke(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Qe(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?He("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&He("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Ye(e,r,n){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function c(){let u=n==="x"?window.scrollX:window.scrollY,m=e-u,h=r-u,I=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${I?`left:${m}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${m}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
+ <div style="position:absolute;${I?`left:${h}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${h}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(s),window.addEventListener("scroll",c,{passive:true}),c(),s}function qe(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let m=parseFloat(u),h=s[c++]??m;return String(+(m+(h-m)*n).toFixed(4))})}function pe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:s="path, polyline, line, polygon, rect, circle",speed:c=1,fade:u=false,easing:m="linear",trigger:h={},stagger:I=0,direction:a="forward",once:d=false,debug:J=false,axis:b="y",scrollContainer:me,autoReverse:ee=false,delay:de=0,strokeColor:H,strokeWidth:V,fillOpacity:q,waypoints:te,velocityScale:re=false,threshold:Ge=0,rootMargin:ze="0px",repeat:j=0,repeatDelay:ke=0,morphTo:O,clip:ye,native:Be=true,onProgress:he,onStart:ge,onComplete:K}=r,G=ye===true?"left":typeof ye=="string"?ye:false,ne=typeof m=="function"?m:xe[m]??xe.linear,Ae=Ee(h.start??"top bottom"),De=Ee(h.end??"bottom top"),x=typeof me=="string"?document.querySelector(me):me??null,C=Array.isArray(H)?H[0]:null,$=Array.isArray(H)?H[1]:typeof H=="string"?H:null,M=Array.isArray(V)?V[0]:null,k=Array.isArray(V)?V[1]:typeof V=="number"?V:null,A=Array.isArray(q)?q[0]:null,D=Array.isArray(q)?q[1]:typeof q=="number"?q:null;function U(t){let o=t*100;switch(G){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let E=G?[]:Array.from(e.querySelectorAll(s)),w=[],F=[],N=0,R=0,L=false,z=false,W=0,se=false,T=-1,oe=-1,B=false,ie=0,Q=0,ae,be=null,le=new Set,ue=-1,Te=performance.now();function Y(){return x?b==="x"?x.scrollLeft:x.scrollTop:b==="x"?window.scrollX:window.scrollY}function Pe(){return x?b==="x"?x.clientWidth:x.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Le(){let t=e.getBoundingClientRect(),o,l,g;if(x){let S=x.getBoundingClientRect();o=b==="x"?t.left-S.left+x.scrollLeft:t.top-S.top+x.scrollTop,l=b==="x"?t.width:t.height,g=Y();}else o=b==="x"?t.left:t.top,l=b==="x"?t.width:t.height,g=Y();let _=$e({top:o,height:l},g,Pe(),Ae,De);N=_.tStart,R=_.tEnd,J&&process.env.NODE_ENV!=="production"&&(be?.remove(),be=Ye(N,R,b));}function _e(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),G){let l=o==="reverse"?1-t:t;e.style.clipPath=U(l);return}E.forEach((l,g)=>{l.style.strokeDashoffset=o==="reverse"?`${w[g]*t}`:`${w[g]*(1-t)}`,u&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),C&&$?l.style.stroke=Me(C,$,t):$&&(l.style.stroke=$),M!==null&&k!==null?l.style.strokeWidth=`${M+(k-M)*t}`:k!==null&&(l.style.strokeWidth=`${k}`),A!==null&&D!==null?l.style.fillOpacity=`${A+(D-A)*t}`:D!==null&&(l.style.fillOpacity=`${D}`),O&&l.tagName.toLowerCase()==="path"&&F[g]&&l.setAttribute("d",qe(F[g],O,t));});}function Ie(){if(e.style.setProperty("--scroll-draw-progress","0"),G){e.style.clipPath=U(0);return}E.forEach((t,o)=>{t.style.strokeDasharray=`${w[o]}`,t.style.strokeDashoffset=a==="reverse"?"0":`${w[o]}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`),O&&t.tagName.toLowerCase()==="path"&&F[o]&&t.setAttribute("d",F[o]);});}if(E.forEach(t=>{Qe(t);let o=Se(t);w.push(o),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),n?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?`${o}`:"0",u&&(t.style.opacity="1"),$&&(t.style.stroke=$),k!==null&&(t.style.strokeWidth=`${k}`),D!==null&&(t.style.fillOpacity=`${D}`),O&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",O)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=a==="reverse"?"0":`${o}`,u?t.style.opacity=a==="reverse"?"1":"0":t.style.opacity="",C&&(t.style.stroke=C),M!==null&&(t.style.strokeWidth=`${M}`),A!==null&&(t.style.fillOpacity=`${A}`));}),G){if(n)return e.style.clipPath=U(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=U(0);}else if(n)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Xe(){return !(Be===false||!Ke()||!E.length||typeof m!="string"||!(m in Ve)||G||b!=="y"||x||c!==1||I!==0||d||ee||re!==false||O||te||j||de>0||he||ge||K||H!=null||V!=null||q!=null||(h.start??"top bottom").trim()!=="top bottom"||(h.end??"bottom top").trim()!=="bottom top")}function Je(){let t=`svg-scroll-draw-${++je}`,o=a==="reverse"?"0":"var(--ssd-len)",l=a==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${o};`,_=`stroke-dashoffset:${l};`;u&&(g+=`opacity:${a==="reverse"?1:0};`,_+=`opacity:${a==="reverse"?0:1};`);let S=document.createElement("style");S.setAttribute("data-svg-scroll-draw",""),S.textContent=`@keyframes ${t}{from{${g}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Ve[m]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(S);function i(p,P){p.style.setProperty("--ssd-len",String(w[P])),p.style.strokeDasharray=`${w[P]}`,p.style.strokeDashoffset="",p.style.opacity="",p.style.animationPlayState="",p.classList.add(t);}E.forEach(i);let f=false,v=-1;function y(){if(v>=0)return v;let p=e.getBoundingClientRect(),{tStart:P,tEnd:Z}=$e({top:p.top,height:p.height},Y(),Pe(),Ae,De);return ne(X(Y(),P,Z,c))}return {destroy(){E.forEach(p=>{p.classList.remove(t),p.style.removeProperty("--ssd-len"),p.style.animationPlayState="";}),S.remove();},replay(){f=false,v=-1,E.forEach(i);},pause(){f=true,E.forEach(p=>{p.style.animationPlayState="paused";});},resume(){f&&(f=false,E.forEach(p=>{p.style.animationPlayState="running";}));},seek(p){let P=Math.min(1,Math.max(0,p));v=P,f=true,E.forEach((Z,Oe)=>{Z.classList.remove(t),Z.style.strokeDashoffset=a==="reverse"?`${w[Oe]*P}`:`${w[Oe]*(1-P)}`,u&&(Z.style.opacity=a==="reverse"?`${1-P}`:`${P}`);});},getProgress(){return y()}}}if(Xe())return Je();Le();function ce(){if(!se||B)return;let t=performance.now(),o=Y(),l=c;if(re!==false){let i=t-Te,f=i>0?Math.abs(o-(ue<0?o:ue))/i:0;l=c*Math.max(.2,1+f*(typeof re=="number"?re:1)*.04);}ue=o,Te=t;let g=ee?oe===-1||o>=oe?"forward":"reverse":a;oe=o;let _=R-N,S=true;if(G){let i=ne(X(o,N,R,l));d&&!ee&&(T=Math.max(T,i),i=T),ie=i,e.style.setProperty("--scroll-draw-progress",String(i));let f=g==="reverse"?1-i:i;e.style.clipPath=U(f),he?.(i),!z&&X(o,N,R,l)>0&&(z=true,ge?.()),i>=1&&!L?(L=true,K?.(),Q<(j==="infinite"?1/0:j??0)&&(Q++,ae=setTimeout(()=>{T=-1,z=false,L=false,e.style.clipPath=U(0);},ke))):i<1&&!d&&(L=false),W=requestAnimationFrame(ce);return}if(E.forEach((i,f)=>{let v=f*I*_,y=ne(X(o,N+v,R+v,l));d&&!ee&&(T=Math.max(T,y),y=T),ie=y,i.style.strokeDashoffset=g==="reverse"?`${w[f]*y}`:`${w[f]*(1-y)}`,u&&(i.style.opacity=g==="reverse"?`${1-y}`:`${y}`),C&&$?i.style.stroke=Me(C,$,y):$&&(i.style.stroke=$),M!==null&&k!==null?i.style.strokeWidth=`${M+(k-M)*y}`:k!==null&&(i.style.strokeWidth=`${k}`),A!==null&&D!==null?i.style.fillOpacity=`${A+(D-A)*y}`:D!==null&&(i.style.fillOpacity=`${D}`),O&&i.tagName.toLowerCase()==="path"&&F[f]&&i.setAttribute("d",qe(F[f],O,y)),f===0&&(he?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(S=false);}),te){let i=ne(X(o,N,R,l));for(let f in te){let v=parseFloat(f);i>=v&&!le.has(v)&&(le.add(v),te[f]?.());}}!z&&X(o,N,R,l)>0&&(z=true,ge?.()),S&&!L?(L=true,K?.(),Q<(j==="infinite"?1/0:j??0)&&(Q++,ae=setTimeout(()=>{T=-1,z=false,L=false,le.clear(),Ie();},ke))):!S&&!d&&(L=false),W=requestAnimationFrame(ce);}let we=new IntersectionObserver(t=>{t.forEach(o=>{se=o.isIntersecting,se&&!B?W=requestAnimationFrame(ce):cancelAnimationFrame(W);});},{root:x??null,threshold:Ge,rootMargin:ze}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{E.forEach((t,o)=>{w[o]=Se(t),t.style.strokeDasharray=`${w[o]}`;}),Le();},150);}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),de>0?setTimeout(()=>we.observe(e),de):we.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ae),we.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),be?.remove();},replay(){T=-1,oe=-1,ue=-1,z=false,L=false,Q=0,B=false,le.clear(),clearTimeout(ae),Ie();},pause(){B=true,cancelAnimationFrame(W);},resume(){B&&(B=false,se&&(W=requestAnimationFrame(ce)));},seek(t){let o=Math.min(1,Math.max(0,t));ie=o,T=o,B=true,cancelAnimationFrame(W),_e(o,a);},getProgress(){return ie}}}function Ze(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=typeof e=="string"?document.querySelector(e):e;return s?pe(s,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function lt(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let s=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";s&&(n=JSON.parse(s));}catch{}return pe(r,n)})}export{lt as initScrollDraw,Ze as scrollDraw};
@@ -1,3 +1,3 @@
1
- "use strict";var SvgScrollDraw=(()=>{var ve=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var Ye=(e,r)=>{for(var n in r)ve(e,n,{get:r[n],enumerable:!0})},Ze=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ke(r))!Qe.call(e,a)&&a!==n&&ve(e,a,{get:()=>r[a],enumerable:!(o=Je(r,a))||o.enumerable});return e};var et=e=>Ze(ve({},"__esModule",{value:!0}),e);var at={};Ye(at,{createSpring:()=>He,scrollDraw:()=>it});var Ee={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2)};function He({tension:e=2.5,friction:r=2.2}={}){return n=>1-Math.cos(n*Math.PI*e)*Math.pow(1-n,r)}function $e(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return{element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return{element:n,viewport:o}}function Fe(e,r,n,o){switch(o){case"top":return e+n;case"center":return e+n+r/2;case"bottom":return e+n+r;default:return e+n}}function Ne(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case"top":return 0;case"center":return r/2;case"bottom":return r;default:return r}}function Se(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function tt(e,r,n){return Math.min(n,Math.max(r,e))}function B(e,r,n,o){return n===r?0:tt((e-r)/(n-r)*o,0,1)}function xe(e,r,n,o,a){let p=Fe(e.top,e.height,r,o.element)-Ne(o.viewport,n),f=Fe(e.top,e.height,r,a.element)-Ne(a.viewport,n);return{tStart:p,tEnd:f}}function Re(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return[parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function Ae(e,r,n){let o=Re(e),a=Re(r);return!o||!a?e:`rgb(${Math.round(o[0]+(a[0]-o[0])*n)},${Math.round(o[1]+(a[1]-o[1])*n)},${Math.round(o[2]+(a[2]-o[2])*n)})`}function Ve(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r)}var We={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},rt=0;function nt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function st(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Ve("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Ve("Element has a fill \u2014 it may obscure the stroke animation.",e)}function ot(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function a(){let p=n==="x"?window.scrollX:window.scrollY,f=e-p,b=r-p,X=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${X?`left:${f}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${f}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
- <div style="position:absolute;${X?`left:${b}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${b}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`}return document.body.appendChild(o),window.addEventListener("scroll",a,{passive:!0}),a(),o}function Ge(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),a=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,p=>{let f=parseFloat(p),b=o[a++]??f;return String(+(f+(b-f)*n).toFixed(4))})}function fe(e,r={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:o="path, polyline, line, polygon, rect, circle",speed:a=1,fade:p=!1,easing:f="linear",trigger:b={},stagger:X=0,direction:y="forward",once:U=!1,debug:ze=!1,axis:$="y",scrollContainer:pe,autoReverse:Z=!1,delay:me=0,strokeColor:R,strokeWidth:H,fillOpacity:V,waypoints:ee,velocityScale:te=!1,threshold:qe=0,rootMargin:Be="0px",repeat:j=0,repeatDelay:Te=0,morphTo:P,clip:de,native:_e=!0,onProgress:ye,onStart:ge,onComplete:J}=r,W=de===!0?"left":typeof de=="string"?de:!1,re=typeof f=="function"?f:Ee[f]??Ee.linear,De=$e(b.start??"top bottom"),Me=$e(b.end??"bottom top"),w=typeof pe=="string"?document.querySelector(pe):pe??null,I=Array.isArray(R)?R[0]:null,S=Array.isArray(R)?R[1]:typeof R=="string"?R:null,x=Array.isArray(H)?H[0]:null,A=Array.isArray(H)?H[1]:typeof H=="number"?H:null,k=Array.isArray(V)?V[0]:null,T=Array.isArray(V)?V[1]:typeof V=="number"?V:null;function _(t){let s=t*100;switch(W){case"right":return`inset(0 0 0 ${100-s}%)`;case"top":return`inset(0 0 ${100-s}% 0)`;case"bottom":return`inset(${100-s}% 0 0 0)`;case"center":return`circle(${t*150}% at 50% 50%)`;default:return`inset(0 ${100-s}% 0 0)`}}let v=W?[]:Array.from(e.querySelectorAll(o)),g=[],C=[],O=0,F=0,L=!1,G=!1,N=0,ne=!1,D=-1,se=-1,z=!1,oe=0,K=0,ie,he=null,ae=new Set,le=-1,Le=performance.now();function Q(){return w?$==="x"?w.scrollLeft:w.scrollTop:$==="x"?window.scrollX:window.scrollY}function Pe(){return w?$==="x"?w.clientWidth:w.clientHeight:$==="x"?window.innerWidth:window.innerHeight}function Ie(){let t=e.getBoundingClientRect(),s,l,d;if(w){let E=w.getBoundingClientRect();s=$==="x"?t.left-E.left+w.scrollLeft:t.top-E.top+w.scrollTop,l=$==="x"?t.width:t.height,d=Q()}else s=$==="x"?t.left:t.top,l=$==="x"?t.width:t.height,d=Q();let q=xe({top:s,height:l},d,Pe(),De,Me);O=q.tStart,F=q.tEnd,ze&&process.env.NODE_ENV!=="production"&&(he?.remove(),he=ot(O,F,$))}function Xe(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),W){let l=s==="reverse"?1-t:t;e.style.clipPath=_(l);return}v.forEach((l,d)=>{l.style.strokeDashoffset=s==="reverse"?`${g[d]*t}`:`${g[d]*(1-t)}`,p&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),I&&S?l.style.stroke=Ae(I,S,t):S&&(l.style.stroke=S),x!==null&&A!==null?l.style.strokeWidth=`${x+(A-x)*t}`:A!==null&&(l.style.strokeWidth=`${A}`),k!==null&&T!==null?l.style.fillOpacity=`${k+(T-k)*t}`:T!==null&&(l.style.fillOpacity=`${T}`),P&&l.tagName.toLowerCase()==="path"&&C[d]&&l.setAttribute("d",Ge(C[d],P,t))})}function Ce(){if(e.style.setProperty("--scroll-draw-progress","0"),W){e.style.clipPath=_(0);return}v.forEach((t,s)=>{t.style.strokeDasharray=`${g[s]}`,t.style.strokeDashoffset=y==="reverse"?"0":`${g[s]}`,p?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`),P&&t.tagName.toLowerCase()==="path"&&C[s]&&t.setAttribute("d",C[s])})}if(v.forEach(t=>{st(t);let s=Se(t);g.push(s),t.tagName.toLowerCase()==="path"?C.push(t.getAttribute("d")??""):C.push(""),n?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?`${s}`:"0",p&&(t.style.opacity="1"),S&&(t.style.stroke=S),A!==null&&(t.style.strokeWidth=`${A}`),T!==null&&(t.style.fillOpacity=`${T}`),P&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",P)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=y==="reverse"?"0":`${s}`,p?t.style.opacity=y==="reverse"?"1":"0":t.style.opacity="",I&&(t.style.stroke=I),x!==null&&(t.style.strokeWidth=`${x}`),k!==null&&(t.style.fillOpacity=`${k}`))}),W){if(n)return e.style.clipPath=_(1),J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=_(0)}else if(n)return J?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Ue(){return!(_e===!1||!nt()||!v.length||typeof f!="string"||!(f in We)||W||$!=="y"||w||a!==1||X!==0||U||Z||te!==!1||P||ee||j||me>0||ye||ge||J||R!=null||H!=null||V!=null||(b.start??"top bottom").trim()!=="top bottom"||(b.end??"bottom top").trim()!=="bottom top")}function je(){let t=`svg-scroll-draw-${++rt}`,s=y==="reverse"?"0":"var(--ssd-len)",l=y==="reverse"?"var(--ssd-len)":"0",d=`stroke-dashoffset:${s};`,q=`stroke-dashoffset:${l};`;p&&(d+=`opacity:${y==="reverse"?1:0};`,q+=`opacity:${y==="reverse"?0:1};`);let E=document.createElement("style");E.setAttribute("data-svg-scroll-draw",""),E.textContent=`@keyframes ${t}{from{${d}}to{${q}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${We[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(E);function i(u,M){u.style.setProperty("--ssd-len",String(g[M])),u.style.strokeDasharray=`${g[M]}`,u.style.strokeDashoffset="",u.style.opacity="",u.style.animationPlayState="",u.classList.add(t)}v.forEach(i);let c=!1,h=-1;function m(){if(h>=0)return h;let u=e.getBoundingClientRect(),{tStart:M,tEnd:Y}=xe({top:u.top,height:u.height},Q(),Pe(),De,Me);return re(B(Q(),M,Y,a))}return{destroy(){v.forEach(u=>{u.classList.remove(t),u.style.removeProperty("--ssd-len"),u.style.animationPlayState=""}),E.remove()},replay(){c=!1,h=-1,v.forEach(i)},pause(){c=!0,v.forEach(u=>{u.style.animationPlayState="paused"})},resume(){c&&(c=!1,v.forEach(u=>{u.style.animationPlayState="running"}))},seek(u){let M=Math.min(1,Math.max(0,u));h=M,c=!0,v.forEach((Y,Oe)=>{Y.classList.remove(t),Y.style.strokeDashoffset=y==="reverse"?`${g[Oe]*M}`:`${g[Oe]*(1-M)}`,p&&(Y.style.opacity=y==="reverse"?`${1-M}`:`${M}`)})},getProgress(){return m()}}}if(Ue())return je();Ie();function ce(){if(!ne||z)return;let t=performance.now(),s=Q(),l=a;if(te!==!1){let i=t-Le,c=i>0?Math.abs(s-(le<0?s:le))/i:0;l=a*Math.max(.2,1+c*(typeof te=="number"?te:1)*.04)}le=s,Le=t;let d=Z?se===-1||s>=se?"forward":"reverse":y;se=s;let q=F-O,E=!0;if(W){let i=re(B(s,O,F,l));U&&!Z&&(D=Math.max(D,i),i=D),oe=i,e.style.setProperty("--scroll-draw-progress",String(i));let c=d==="reverse"?1-i:i;e.style.clipPath=_(c),ye?.(i),!G&&B(s,O,F,l)>0&&(G=!0,ge?.()),i>=1&&!L?(L=!0,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{D=-1,G=!1,L=!1,e.style.clipPath=_(0)},Te))):i<1&&!U&&(L=!1),N=requestAnimationFrame(ce);return}if(v.forEach((i,c)=>{let h=c*X*q,m=re(B(s,O+h,F+h,l));U&&!Z&&(D=Math.max(D,m),m=D),oe=m,i.style.strokeDashoffset=d==="reverse"?`${g[c]*m}`:`${g[c]*(1-m)}`,p&&(i.style.opacity=d==="reverse"?`${1-m}`:`${m}`),I&&S?i.style.stroke=Ae(I,S,m):S&&(i.style.stroke=S),x!==null&&A!==null?i.style.strokeWidth=`${x+(A-x)*m}`:A!==null&&(i.style.strokeWidth=`${A}`),k!==null&&T!==null?i.style.fillOpacity=`${k+(T-k)*m}`:T!==null&&(i.style.fillOpacity=`${T}`),P&&i.tagName.toLowerCase()==="path"&&C[c]&&i.setAttribute("d",Ge(C[c],P,m)),c===0&&(ye?.(m),e.style.setProperty("--scroll-draw-progress",String(m))),m<1&&(E=!1)}),ee){let i=re(B(s,O,F,l));for(let c in ee){let h=parseFloat(c);i>=h&&!ae.has(h)&&(ae.add(h),ee[c]?.())}}!G&&B(s,O,F,l)>0&&(G=!0,ge?.()),E&&!L?(L=!0,J?.(),K<(j==="infinite"?1/0:j??0)&&(K++,ie=setTimeout(()=>{D=-1,G=!1,L=!1,ae.clear(),Ce()},Te))):!E&&!U&&(L=!1),N=requestAnimationFrame(ce)}let be=new IntersectionObserver(t=>{t.forEach(s=>{ne=s.isIntersecting,ne&&!z?N=requestAnimationFrame(ce):cancelAnimationFrame(N)})},{root:w??null,threshold:qe,rootMargin:Be}),we;function ue(){clearTimeout(we),we=setTimeout(()=>{v.forEach((t,s)=>{g[s]=Se(t),t.style.strokeDasharray=`${g[s]}`}),Ie()},150)}return window.addEventListener("resize",ue),window.addEventListener("orientationchange",ue),me>0?setTimeout(()=>be.observe(e),me):be.observe(e),{destroy(){cancelAnimationFrame(N),clearTimeout(ie),be.disconnect(),window.removeEventListener("resize",ue),window.removeEventListener("orientationchange",ue),clearTimeout(we),he?.remove()},replay(){D=-1,se=-1,le=-1,G=!1,L=!1,K=0,z=!1,ae.clear(),clearTimeout(ie),Ce()},pause(){z=!0,cancelAnimationFrame(N)},resume(){z&&(z=!1,ne&&(N=requestAnimationFrame(ce)))},seek(t){let s=Math.min(1,Math.max(0,t));oe=s,D=s,z=!0,cancelAnimationFrame(N),Xe(s,y)},getProgress(){return oe}}}function it(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let o=typeof e=="string"?document.querySelector(e):e;return o?fe(o,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}var ke=class extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let n={},o=this.getAttribute("speed"),a=this.getAttribute("easing"),p=this.getAttribute("stagger"),f=this.getAttribute("direction"),b=this.getAttribute("selector");o&&(n.speed=parseFloat(o)),a&&(n.easing=a),p&&(n.stagger=parseFloat(p)),f&&(n.direction=f),b&&(n.selector=b),this.hasAttribute("fade")&&(n.fade=this.getAttribute("fade")!=="false"),this.instance=fe(this,n)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",ke);return et(at);})();
1
+ "use strict";var SvgScrollDraw=(()=>{var Ee=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var et=(e,n)=>{for(var r in n)Ee(e,r,{get:n[r],enumerable:!0})},tt=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Ye(n))!Ze.call(e,i)&&i!==r&&Ee(e,i,{get:()=>n[i],enumerable:!(s=Qe(n,i))||s.enumerable});return e};var rt=e=>tt(Ee({},"__esModule",{value:!0}),e);var ut={};et(ut,{createBounce:()=>xe,createElastic:()=>$e,createSpring:()=>Ge,scrollDraw:()=>lt});function Ge({tension:e=2.5,friction:n=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,n)}function xe({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,n)),i=Math.sqrt(s),u=0,f=[];for(let l=0;l<r;l++){let y=Math.pow(i,l);f.push(y),u+=y}let d=[0],I=0;for(let l=0;l<r;l++)I+=f[l]/u,d.push(I);return l=>{if(l<=0)return 0;if(l>=1)return 1;for(let y=0;y<r;y++)if(l<=d[y+1]){let U=(l-d[y])/(d[y+1]-d[y]);if(y===0)return U*(2-U);let b=1-Math.pow(s,y);return b+(1-b)*(2*U-1)*(2*U-1)}return 1}}function $e({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),s=Math.max(.1,n),i=r<=1?s/4:s/(2*Math.PI)*Math.asin(1/r);return u=>u<=0?0:u>=1?1:r*Math.pow(2,-10*u)*Math.sin((u-i)*(2*Math.PI)/s)+1}var Se={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:xe(),elastic:$e()};function Ae(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return{element:"top",viewport:n};let[r="top",s="bottom"]=n.split(/\s+/).filter(Boolean);return{element:r,viewport:s}}function We(e,n,r,s){switch(s){case"top":return e+r;case"center":return e+r+n/2;case"bottom":return e+r+n;default:return e+r}}function He(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case"top":return 0;case"center":return n/2;case"bottom":return n;default:return n}}function Me(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),s=parseFloat(e.getAttribute("height")??"0");return 2*(r+s)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function nt(e,n,r){return Math.min(r,Math.max(n,e))}function X(e,n,r,s){return r===n?0:nt((e-n)/(r-n)*s,0,1)}function ke(e,n,r,s,i){let u=We(e.top,e.height,n,s.element)-He(s.viewport,r),f=We(e.top,e.height,n,i.element)-He(i.viewport,r);return{tStart:u,tEnd:f}}function Ve(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function Te(e,n,r){let s=Ve(e),i=Ve(n);return!s||!i?e:`rgb(${Math.round(s[0]+(i[0]-s[0])*r)},${Math.round(s[1]+(i[1]-s[1])*r)},${Math.round(s[2]+(i[2]-s[2])*r)})`}function qe(e,n){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,n)}var ze={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},st=0;function ot(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function it(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?qe("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&qe("Element has a fill \u2014 it may obscure the stroke animation.",e)}function at(e,n,r){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function i(){let u=r==="x"?window.scrollX:window.scrollY,f=e-u,d=n-u,I=r==="x";s.innerHTML=`
2
+ <div style="position:absolute;${I?`left:${f}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${f}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
+ <div style="position:absolute;${I?`left:${d}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${d}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`}return document.body.appendChild(s),window.addEventListener("scroll",i,{passive:!0}),i(),s}function Be(e,n,r){let s=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let f=parseFloat(u),d=s[i++]??f;return String(+(f+(d-f)*r).toFixed(4))})}function pe(e,n={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let r=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:s="path, polyline, line, polygon, rect, circle",speed:i=1,fade:u=!1,easing:f="linear",trigger:d={},stagger:I=0,direction:l="forward",once:y=!1,debug:U=!1,axis:b="y",scrollContainer:me,autoReverse:ee=!1,delay:de=0,strokeColor:H,strokeWidth:V,fillOpacity:G,waypoints:te,velocityScale:re=!1,threshold:_e=0,rootMargin:Xe="0px",repeat:J=0,repeatDelay:Pe=0,morphTo:C,clip:ye,native:Ue=!0,onProgress:ge,onStart:he,onComplete:K}=n,q=ye===!0?"left":typeof ye=="string"?ye:!1,ne=typeof f=="function"?f:Se[f]??Se.linear,Le=Ae(d.start??"top bottom"),Ie=Ae(d.end??"bottom top"),E=typeof me=="string"?document.querySelector(me):me??null,O=Array.isArray(H)?H[0]:null,S=Array.isArray(H)?H[1]:typeof H=="string"?H:null,A=Array.isArray(V)?V[0]:null,M=Array.isArray(V)?V[1]:typeof V=="number"?V:null,k=Array.isArray(G)?G[0]:null,T=Array.isArray(G)?G[1]:typeof G=="number"?G:null;function j(t){let o=t*100;switch(q){case"right":return`inset(0 0 0 ${100-o}%)`;case"top":return`inset(0 0 ${100-o}% 0)`;case"bottom":return`inset(${100-o}% 0 0 0)`;case"center":return`circle(${t*150}% at 50% 50%)`;default:return`inset(0 ${100-o}% 0 0)`}}let x=q?[]:Array.from(e.querySelectorAll(s)),w=[],F=[],N=0,R=0,L=!1,z=!1,W=0,se=!1,D=-1,oe=-1,B=!1,ie=0,Q=0,ae,be=null,le=new Set,ue=-1,Ce=performance.now();function Y(){return E?b==="x"?E.scrollLeft:E.scrollTop:b==="x"?window.scrollX:window.scrollY}function Oe(){return E?b==="x"?E.clientWidth:E.clientHeight:b==="x"?window.innerWidth:window.innerHeight}function Fe(){let t=e.getBoundingClientRect(),o,c,h;if(E){let $=E.getBoundingClientRect();o=b==="x"?t.left-$.left+E.scrollLeft:t.top-$.top+E.scrollTop,c=b==="x"?t.width:t.height,h=Y()}else o=b==="x"?t.left:t.top,c=b==="x"?t.width:t.height,h=Y();let _=ke({top:o,height:c},h,Oe(),Le,Ie);N=_.tStart,R=_.tEnd,U&&process.env.NODE_ENV!=="production"&&(be?.remove(),be=at(N,R,b))}function je(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),q){let c=o==="reverse"?1-t:t;e.style.clipPath=j(c);return}x.forEach((c,h)=>{c.style.strokeDashoffset=o==="reverse"?`${w[h]*t}`:`${w[h]*(1-t)}`,u&&(c.style.opacity=o==="reverse"?`${1-t}`:`${t}`),O&&S?c.style.stroke=Te(O,S,t):S&&(c.style.stroke=S),A!==null&&M!==null?c.style.strokeWidth=`${A+(M-A)*t}`:M!==null&&(c.style.strokeWidth=`${M}`),k!==null&&T!==null?c.style.fillOpacity=`${k+(T-k)*t}`:T!==null&&(c.style.fillOpacity=`${T}`),C&&c.tagName.toLowerCase()==="path"&&F[h]&&c.setAttribute("d",Be(F[h],C,t))})}function Ne(){if(e.style.setProperty("--scroll-draw-progress","0"),q){e.style.clipPath=j(0);return}x.forEach((t,o)=>{t.style.strokeDasharray=`${w[o]}`,t.style.strokeDashoffset=l==="reverse"?"0":`${w[o]}`,u?t.style.opacity=l==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),A!==null&&(t.style.strokeWidth=`${A}`),k!==null&&(t.style.fillOpacity=`${k}`),C&&t.tagName.toLowerCase()==="path"&&F[o]&&t.setAttribute("d",F[o])})}if(x.forEach(t=>{it(t);let o=Me(t);w.push(o),t.tagName.toLowerCase()==="path"?F.push(t.getAttribute("d")??""):F.push(""),r?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=l==="reverse"?`${o}`:"0",u&&(t.style.opacity="1"),S&&(t.style.stroke=S),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`),C&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",C)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=l==="reverse"?"0":`${o}`,u?t.style.opacity=l==="reverse"?"1":"0":t.style.opacity="",O&&(t.style.stroke=O),A!==null&&(t.style.strokeWidth=`${A}`),k!==null&&(t.style.fillOpacity=`${k}`))}),q){if(r)return e.style.clipPath=j(1),K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=j(0)}else if(r)return K?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Je(){return!(Ue===!1||!ot()||!x.length||typeof f!="string"||!(f in ze)||q||b!=="y"||E||i!==1||I!==0||y||ee||re!==!1||C||te||J||de>0||ge||he||K||H!=null||V!=null||G!=null||(d.start??"top bottom").trim()!=="top bottom"||(d.end??"bottom top").trim()!=="bottom top")}function Ke(){let t=`svg-scroll-draw-${++st}`,o=l==="reverse"?"0":"var(--ssd-len)",c=l==="reverse"?"var(--ssd-len)":"0",h=`stroke-dashoffset:${o};`,_=`stroke-dashoffset:${c};`;u&&(h+=`opacity:${l==="reverse"?1:0};`,_+=`opacity:${l==="reverse"?0:1};`);let $=document.createElement("style");$.setAttribute("data-svg-scroll-draw",""),$.textContent=`@keyframes ${t}{from{${h}}to{${_}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${ze[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild($);function a(m,P){m.style.setProperty("--ssd-len",String(w[P])),m.style.strokeDasharray=`${w[P]}`,m.style.strokeDashoffset="",m.style.opacity="",m.style.animationPlayState="",m.classList.add(t)}x.forEach(a);let p=!1,v=-1;function g(){if(v>=0)return v;let m=e.getBoundingClientRect(),{tStart:P,tEnd:Z}=ke({top:m.top,height:m.height},Y(),Oe(),Le,Ie);return ne(X(Y(),P,Z,i))}return{destroy(){x.forEach(m=>{m.classList.remove(t),m.style.removeProperty("--ssd-len"),m.style.animationPlayState=""}),$.remove()},replay(){p=!1,v=-1,x.forEach(a)},pause(){p=!0,x.forEach(m=>{m.style.animationPlayState="paused"})},resume(){p&&(p=!1,x.forEach(m=>{m.style.animationPlayState="running"}))},seek(m){let P=Math.min(1,Math.max(0,m));v=P,p=!0,x.forEach((Z,Re)=>{Z.classList.remove(t),Z.style.strokeDashoffset=l==="reverse"?`${w[Re]*P}`:`${w[Re]*(1-P)}`,u&&(Z.style.opacity=l==="reverse"?`${1-P}`:`${P}`)})},getProgress(){return g()}}}if(Je())return Ke();Fe();function ce(){if(!se||B)return;let t=performance.now(),o=Y(),c=i;if(re!==!1){let a=t-Ce,p=a>0?Math.abs(o-(ue<0?o:ue))/a:0;c=i*Math.max(.2,1+p*(typeof re=="number"?re:1)*.04)}ue=o,Ce=t;let h=ee?oe===-1||o>=oe?"forward":"reverse":l;oe=o;let _=R-N,$=!0;if(q){let a=ne(X(o,N,R,c));y&&!ee&&(D=Math.max(D,a),a=D),ie=a,e.style.setProperty("--scroll-draw-progress",String(a));let p=h==="reverse"?1-a:a;e.style.clipPath=j(p),ge?.(a),!z&&X(o,N,R,c)>0&&(z=!0,he?.()),a>=1&&!L?(L=!0,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{D=-1,z=!1,L=!1,e.style.clipPath=j(0)},Pe))):a<1&&!y&&(L=!1),W=requestAnimationFrame(ce);return}if(x.forEach((a,p)=>{let v=p*I*_,g=ne(X(o,N+v,R+v,c));y&&!ee&&(D=Math.max(D,g),g=D),ie=g,a.style.strokeDashoffset=h==="reverse"?`${w[p]*g}`:`${w[p]*(1-g)}`,u&&(a.style.opacity=h==="reverse"?`${1-g}`:`${g}`),O&&S?a.style.stroke=Te(O,S,g):S&&(a.style.stroke=S),A!==null&&M!==null?a.style.strokeWidth=`${A+(M-A)*g}`:M!==null&&(a.style.strokeWidth=`${M}`),k!==null&&T!==null?a.style.fillOpacity=`${k+(T-k)*g}`:T!==null&&(a.style.fillOpacity=`${T}`),C&&a.tagName.toLowerCase()==="path"&&F[p]&&a.setAttribute("d",Be(F[p],C,g)),p===0&&(ge?.(g),e.style.setProperty("--scroll-draw-progress",String(g))),g<1&&($=!1)}),te){let a=ne(X(o,N,R,c));for(let p in te){let v=parseFloat(p);a>=v&&!le.has(v)&&(le.add(v),te[p]?.())}}!z&&X(o,N,R,c)>0&&(z=!0,he?.()),$&&!L?(L=!0,K?.(),Q<(J==="infinite"?1/0:J??0)&&(Q++,ae=setTimeout(()=>{D=-1,z=!1,L=!1,le.clear(),Ne()},Pe))):!$&&!y&&(L=!1),W=requestAnimationFrame(ce)}let we=new IntersectionObserver(t=>{t.forEach(o=>{se=o.isIntersecting,se&&!B?W=requestAnimationFrame(ce):cancelAnimationFrame(W)})},{root:E??null,threshold:_e,rootMargin:Xe}),ve;function fe(){clearTimeout(ve),ve=setTimeout(()=>{x.forEach((t,o)=>{w[o]=Me(t),t.style.strokeDasharray=`${w[o]}`}),Fe()},150)}return window.addEventListener("resize",fe),window.addEventListener("orientationchange",fe),de>0?setTimeout(()=>we.observe(e),de):we.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ae),we.disconnect(),window.removeEventListener("resize",fe),window.removeEventListener("orientationchange",fe),clearTimeout(ve),be?.remove()},replay(){D=-1,oe=-1,ue=-1,z=!1,L=!1,Q=0,B=!1,le.clear(),clearTimeout(ae),Ne()},pause(){B=!0,cancelAnimationFrame(W)},resume(){B&&(B=!1,se&&(W=requestAnimationFrame(ce)))},seek(t){let o=Math.min(1,Math.max(0,t));ie=o,D=o,B=!0,cancelAnimationFrame(W),je(o,l)},getProgress(){return ie}}}function lt(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let s=typeof e=="string"?document.querySelector(e):e;return s?pe(s,n):(console.warn("[svg-scroll-draw] Container not found:",e),r)}var De=class extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let r={},s=this.getAttribute("speed"),i=this.getAttribute("easing"),u=this.getAttribute("stagger"),f=this.getAttribute("direction"),d=this.getAttribute("selector");s&&(r.speed=parseFloat(s)),i&&(r.easing=i),u&&(r.stagger=parseFloat(u)),f&&(r.direction=f),d&&(r.selector=d),this.hasAttribute("fade")&&(r.fade=this.getAttribute("fade")!=="false"),this.instance=pe(this,r)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",De);return rt(ut);})();