@algorisys/tinyfly 0.115.0 → 0.116.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 (61) hide show
  1. package/README.md +11 -6
  2. package/docs/api-reference.md +2 -1
  3. package/docs/editor-guide.md +1 -1
  4. package/docs/examples.md +1 -1
  5. package/docs/getting-started.md +1 -1
  6. package/docs/gsap-compat.md +1 -1
  7. package/docs/llm-guide.md +16 -0
  8. package/docs/maps.md +2 -2
  9. package/docs/math.md +280 -0
  10. package/docs/teaching.md +1 -1
  11. package/lib/addons/characters.js +2607 -2548
  12. package/lib/addons/math.js +2864 -0
  13. package/lib/browser/tinyfly-math.iife.js +53 -0
  14. package/lib/browser/tinyfly.iife.js +3 -3
  15. package/lib/browser/tinyfly.js +705 -638
  16. package/lib/browser/tinyfly.umd.js +3 -3
  17. package/lib/embed/tinyfly-embed.iife.js +1 -1
  18. package/lib/embed/tinyfly-embed.js +8 -0
  19. package/lib/player/tinyfly-player.es.js +8 -0
  20. package/lib/player/tinyfly-player.iife.js +1 -1
  21. package/lib/player/tinyfly-player.umd.js +1 -1
  22. package/lib/types/characters/capabilities.d.ts +8 -0
  23. package/lib/types/math/browser-entry.d.ts +3 -0
  24. package/lib/types/math/embed/auto-mount-math.d.ts +7 -0
  25. package/lib/types/math/embed/explorable.d.ts +46 -0
  26. package/lib/types/math/embed/mount-math.d.ts +31 -0
  27. package/lib/types/math/expr/differentiate.d.ts +7 -0
  28. package/lib/types/math/expr/evaluate.d.ts +21 -0
  29. package/lib/types/math/expr/parse-expression.d.ts +50 -0
  30. package/lib/types/math/figure/derived.d.ts +17 -0
  31. package/lib/types/math/figure/display-list.d.ts +87 -0
  32. package/lib/types/math/figure/figure-spec.d.ts +239 -0
  33. package/lib/types/math/figure/item-context.d.ts +33 -0
  34. package/lib/types/math/figure/items/calculus.d.ts +7 -0
  35. package/lib/types/math/figure/items/curves.d.ts +7 -0
  36. package/lib/types/math/figure/items/grid.d.ts +5 -0
  37. package/lib/types/math/figure/items/regions.d.ts +5 -0
  38. package/lib/types/math/figure/items/text.d.ts +5 -0
  39. package/lib/types/math/figure/items/vectors.d.ts +9 -0
  40. package/lib/types/math/figure/layout-figure.d.ts +13 -0
  41. package/lib/types/math/figure/plane.d.ts +20 -0
  42. package/lib/types/math/figure/validate-spec.d.ts +2 -0
  43. package/lib/types/math/index.d.ts +43 -0
  44. package/lib/types/math/linear/mat2.d.ts +41 -0
  45. package/lib/types/math/linear/vec2.d.ts +18 -0
  46. package/lib/types/math/presets/calculus.d.ts +59 -0
  47. package/lib/types/math/presets/linear-algebra.d.ts +42 -0
  48. package/lib/types/math/render/arrow.d.ts +10 -0
  49. package/lib/types/math/render/display-list-to-svg.d.ts +10 -0
  50. package/lib/types/math/render/draw-display-list.d.ts +6 -0
  51. package/lib/types/math/steps/math-steps.d.ts +34 -0
  52. package/lib/types/math/targets/math-target.d.ts +43 -0
  53. package/lib/types/math/tex/equation-morph.d.ts +21 -0
  54. package/lib/types/math/tex/glyph-metrics.d.ts +24 -0
  55. package/lib/types/math/tex/tex-layout.d.ts +59 -0
  56. package/lib/types/math/tex/tex-parser.d.ts +88 -0
  57. package/lib/types/player/player.d.ts +6 -0
  58. package/llms-full.txt +358 -10
  59. package/llms.txt +32 -31
  60. package/package.json +6 -2
  61. package/skills/tinyfly/SKILL.md +10 -0
@@ -1,5 +1,5 @@
1
1
  (function(b){"use strict";function Xh(t){return typeof t=="object"&&t!==null&&t.type==="cubic-bezier"}function Fs(t){return typeof t=="object"&&t!==null&&t.type!=="cubic-bezier"}const ta=2;function ea(t){return t.some(e=>e.interpolation!==void 0)?2:1}function Ji(t){return t.property==="text"&&"textConfig"in t}function Be(t){return t.kind==="inertia"&&"inertia"in t}function ze(t){return t.kind==="spring"&&"spring"in t}function na(t){return t.property==="motionPath"&&"motionPathConfig"in t}function A1(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function Gh(t){return"keyframes"in t}class P1{_currentTime=0;_isRunning=!1;onTick=null;get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}start(){this._isRunning=!0}stop(){this._isRunning=!1}tick(e){this._currentTime+=e,this.onTick?.(e,this._currentTime)}reset(){this._currentTime=0}seek(e){this._currentTime=e}}class $1{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(e={}){this._speed=e.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(e){this._speed=e}start(){this._isRunning||(this._isRunning=!0,this._lastFrameTime=null,this._scheduleFrame())}stop(){this._isRunning=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}reset(){this._currentTime=0,this._lastFrameTime=null}seek(e){this._currentTime=e}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(e){if(this._isRunning){if(this._lastFrameTime!==null){const s=(e-this._lastFrameTime)*this._speed;this._currentTime+=s,this.onTick?.(s,this._currentTime)}this._lastFrameTime=e,this._scheduleFrame()}}}function Uh(t,e){if(!(e>0))return t;const n=1e3/e;return Math.floor(t/n+1e-9)*n}function sa(t,e,n="start"){if(e<=1)return 0;if(typeof n=="number"){const s=Math.max(0,Math.min(e-1,n));return Math.abs(t-s)}switch(n){case"end":return e-1-t;case"center":return Math.abs(t-(e-1)/2);case"edges":return(e-1)/2-Math.abs(t-(e-1)/2);default:return t}}function ia(t,e="start"){if(t<=1)return 0;let n=0;for(let s=0;s<t;s++)n=Math.max(n,sa(s,t,e));return n}function Zi(t,e,n){if(n.offsets)return n.offsets[t]??0;const s=n.from??"start",i=sa(t,e,s);if(n.amount!==void 0){const r=ia(e,s);return r===0?0:n.amount*i/r}return n.each!==void 0?n.each*i:0}function Qi(t,e){return Array.from({length:t},(n,s)=>Zi(s,t,e))}function Ns(t,e){return t<=1?0:Math.max(...Qi(t,e))}const Dn=1,ra=6e4,tr=ra/Dn,ce={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},er={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class Ws{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(e){this.from=e.from,this.to=e.to,this.stiffness=e.stiffness??ce.stiffness,this.damping=e.damping??ce.damping,this.mass=e.mass??ce.mass,this.restDelta=e.restDelta??ce.restDelta,this.restSpeed=e.restSpeed??ce.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=e.velocity??ce.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(e){return Math.abs(e-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(e){if(e<=0)return this.from;const n=Math.floor(e/Dn);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const s=this.samples[Math.min(n,this.samples.length-1)],i=this.samples[Math.min(n+1,this.samples.length-1)],r=e/Dn-n;return s+(i-s)*r}settleTime(){return this.simulateTo(tr+1),this.settledStep!==null?this.settledStep*Dn:ra}simulateTo(e){if(this.settledStep!==null)return;const n=Math.min(e,tr+1),s=Dn/1e3;for(;this.samples.length<n;){const i=this.samples[this.samples.length-1],r=i-this.to,o=-this.stiffness*r,a=-this.damping*this.velocity,l=(o+a)/this.mass;this.velocity+=l*s;const c=i+this.velocity*s;if(this.samples.push(c),this.isAtRest(c)){this.settledStep=this.samples.length-1;return}}this.samples.length>tr&&(this.settledStep=tr)}}function I1(t,e){return new Ws(t).valueAt(e)}function Vh(t){return new Ws(t).settleTime()}function O1(t){const e=t.stiffness??ce.stiffness,n=t.damping??ce.damping,s=t.mass??ce.mass;return n<2*Math.sqrt(e*s)}function C1(t){const e=t.stiffness??ce.stiffness,n=t.mass??ce.mass;return 2*Math.sqrt(e*n)}const oa=4,_1=.002,H1=1e-4,Jh=6e4;function nr(t){const e=t.friction??oa;return e>0?e:oa}function Ds(t){return t.from+t.velocity/nr(t)}function R1(t,e){if(e===void 0)return t;if(typeof e=="number")return e>0?Math.round(t/e)*e:t;if(e.length===0)return t;let n=e[0];for(const s of e)Math.abs(s-t)<Math.abs(n-t)&&(n=s);return n}function Bn(t){let e=R1(Ds(t),t.end);return t.min!==void 0&&(e=Math.max(t.min,e)),t.max!==void 0&&(e=Math.min(t.max,e)),e}function zn(t){const e=Math.abs(Bn(t)-t.from);if(e===0)return 0;const n=t.restDelta??Math.max(H1,e*_1);if(n>=e)return 0;const s=Math.log(e/n)/nr(t);return Math.min(Jh,s*1e3)}function sr(t,e){if(e<=0)return t.from;const n=Bn(t);if(e>=zn(t))return n;const s=nr(t);return t.from+(n-t.from)*(1-Math.exp(-s*e/1e3))}function L1(t,e){const n=nr(t),s=Bn(t);return e>=zn(t)?0:(s-t.from)*n*Math.exp(-n*Math.max(0,e)/1e3)}const ir=t=>t,Zh=t=>t*t,Qh=t=>1-(1-t)*(1-t),t0=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,aa=t=>t*t*t,la=t=>1-Math.pow(1-t,3),Bs=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,e0=aa,n0=la,s0=Bs,F1={linear:ir,"ease-in":e0,"ease-out":n0,"ease-in-out":s0,"ease-in-quad":Zh,"ease-out-quad":Qh,"ease-in-out-quad":t0,"ease-in-cubic":aa,"ease-out-cubic":la,"ease-in-out-cubic":Bs};function i0(t){const[e,n,s,i]=t,r=3*e,o=3*(s-e)-r,a=1-r-o,l=3*n,c=3*(i-n)-l,h=1-l-c,u=g=>((a*g+o)*g+r)*g,d=g=>((h*g+c)*g+l)*g,f=g=>(3*a*g+2*o)*g+r,p=g=>{let m=g;for(let k=0;k<8;k++){const w=u(m)-g;if(Math.abs(w)<1e-7)return m;const T=f(m);if(Math.abs(T)<1e-7)break;m-=w/T}let y=0,v=1;for(m=g;y<v;){const k=u(m);if(Math.abs(k-g)<1e-7)return m;g>k?y=m:v=m,m=(y+v)/2}return m};return g=>{if(g<=0)return 0;if(g>=1)return 1;const m=p(g);return d(m)}}function ca(t,e="out"){if(e==="out")return t;const n=s=>1-t(1-s);return e==="in"?n:s=>s<.5?n(s*2)/2:t(s*2-1)/2+.5}function r0(t=1,e=.3){const n=Math.max(1,t),s=e/(2*Math.PI)*Math.asin(1/n);return i=>i<=0?0:i>=1?1:n*Math.pow(2,-10*i)*Math.sin((i-s)*(2*Math.PI)/e)+1}const o0=t=>{if(t<=0)return 0;if(t>=1)return 1;if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const i=t-.5454545454545454;return 7.5625*i*i+.75}if(t<2.5/2.75){const i=t-.8181818181818182;return 7.5625*i*i+.9375}const s=t-2.625/2.75;return 7.5625*s*s+.984375};function a0(t=1.70158){return e=>{if(e<=0)return 0;if(e>=1)return 1;const n=e-1;return n*n*((t+1)*n+t)+1}}function l0(t,e="end"){const n=Math.max(1,Math.floor(t));return s=>{if(s>=1)return 1;if(s<=0)return e==="start"||e==="both"?e==="start"?1/n:1/(n+1):0;const i=Math.floor(s*n);switch(e){case"start":return Math.min(1,(i+1)/n);case"both":return(i+1)/(n+1);case"none":return n===1?0:Math.min(1,i/(n-1));default:return i/n}}}function c0(t){switch(t.type){case"steps":return l0(t.count,t.position);case"elastic":return ca(r0(t.amplitude,t.period),t.mode);case"bounce":return ca(o0,t.mode);case"back":return ca(a0(t.overshoot),t.mode)}}function Wt(t){return t===void 0?ir:Xh(t)?i0(t.points):Fs(t)?c0(t):F1[t]??ir}const h0=32,N1=256,qn=new Map,W1=/[MmLlHhVvCcSsQqTtAaZz]/,D1=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,B1={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function z1(t){const e=[];let n=0,s=null;const i=()=>{for(;n<t.length&&/[\s,]/.test(t[n]);)n++};for(;n<t.length&&(i(),!(n>=t.length));){const r=t[n];if(W1.test(r)){s={type:r,args:[]},e.push(s),n++;continue}if(!s)break;const o=s.type==="A"||s.type==="a",a=s.args.length%7;if(o&&(a===3||a===4)){if(r!=="0"&&r!=="1")break;s.args.push(r==="1"?1:0),n++;continue}const l=D1.exec(t.slice(n));if(!l)break;s.args.push(parseFloat(l[0])),n+=l[0].length}return e}function q1(t,e,n,s,i,r,o,a,l){if(t===a&&e===l)return[];let c=Math.abs(n),h=Math.abs(s);if(c===0||h===0)return[[t,e,a,l,a,l]];const u=i*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=(t-a)/2,g=(e-l)/2,m=d*p+f*g,y=-f*p+d*g,v=m*m/(c*c)+y*y/(h*h);if(v>1){const L=Math.sqrt(v);c*=L,h*=L}const k=r===o?-1:1,w=c*c*h*h-c*c*y*y-h*h*m*m,T=c*c*y*y+h*h*m*m,A=k*Math.sqrt(Math.max(0,w/T)),M=A*c*y/h,x=-A*h*m/c,S=d*M-f*x+(t+a)/2,E=f*M+d*x+(e+l)/2,P=(L,B,K,_)=>{const Y=L*K+B*_,st=Math.sqrt((L*L+B*B)*(K*K+_*_)),$=Math.acos(Math.max(-1,Math.min(1,Y/st)));return L*_-B*K<0?-$:$},I=P(1,0,(m-M)/c,(y-x)/h);let O=P((m-M)/c,(y-x)/h,(-m-M)/c,(-y-x)/h);!o&&O>0&&(O-=2*Math.PI),o&&O<0&&(O+=2*Math.PI);const H=Math.max(1,Math.ceil(Math.abs(O)/(Math.PI/2))),W=O/H,j=4/3*Math.tan(W/4),J=L=>{const B=c*Math.cos(L),K=h*Math.sin(L);return[d*B-f*K+S,f*B+d*K+E]},et=L=>{const B=-c*Math.sin(L),K=h*Math.cos(L);return[d*B-f*K,f*B+d*K]},V=[];for(let L=0;L<H;L++){const B=I+L*W,K=B+W,[_,Y]=J(B),[st,$]=L===H-1?[a,l]:J(K),[C,z]=et(B),[X,N]=et(K);V.push([_+j*C,Y+j*z,st-j*X,$-j*N,st,$])}return V}function qe(t,e,n,s,i){const r=1-i;return r*r*r*t+3*r*r*i*e+3*r*i*i*n+i*i*i*s}function u0(t,e,n,s,i){const r=1-i;return 3*r*r*(e-t)+6*r*i*(n-e)+3*i*i*(s-n)}function zs(t,e,n,s){return{subpath:0,type:"L",points:[n,s],startX:t,startY:e,endX:n,endY:s,length:Math.hypot(n-t,s-e)}}function rr(t,e,n){const[s,i,r,o,a,l]=n,c=[0];let h=t,u=e,d=0;for(let f=1;f<=h0;f++){const p=f/h0,g=qe(t,s,r,a,p),m=qe(e,i,o,l,p);d+=Math.hypot(g-h,m-u),c.push(d),h=g,u=m}return{subpath:0,type:"C",points:[s,i,r,o,a,l],startX:t,startY:e,endX:a,endY:l,length:d,lengths:c}}function pn(t){const e=qn.get(t);if(e)return e;const n=[];let s=0,i=0,r=0,o=0,a=null,l=null,c=-1;const h=new Set,u=g=>{c<0&&(c=0),g.subpath=c,n.push(g)};for(const{type:g,args:m}of z1(t)){const y=g.toUpperCase(),v=g!==y,k=B1[y];if(y==="Z"){(s!==r||i!==o)&&u(zs(s,i,r,o)),c>=0&&h.add(c),s=r,i=o,a=l=null;continue}for(let w=0;w+k<=m.length;w+=k){const T=m.slice(w,w+k),A=v?s:0,M=v?i:0;let x=null,S=null;switch(y){case"M":w===0?(s=T[0]+A,i=T[1]+M,r=s,o=i,(c<0||n[n.length-1]?.subpath===c)&&c++):(u(zs(s,i,T[0]+A,T[1]+M)),s=T[0]+A,i=T[1]+M);break;case"L":u(zs(s,i,T[0]+A,T[1]+M)),s=T[0]+A,i=T[1]+M;break;case"H":u(zs(s,i,T[0]+A,i)),s=T[0]+A;break;case"V":u(zs(s,i,s,T[0]+M)),i=T[0]+M;break;case"C":{const E=[T[0]+A,T[1]+M,T[2]+A,T[3]+M,T[4]+A,T[5]+M];u(rr(s,i,E)),x=[E[2],E[3]],s=E[4],i=E[5];break}case"S":{const[E,P]=a?[2*s-a[0],2*i-a[1]]:[s,i],I=[E,P,T[0]+A,T[1]+M,T[2]+A,T[3]+M];u(rr(s,i,I)),x=[I[2],I[3]],s=I[4],i=I[5];break}case"Q":case"T":{let E=s,P=i;y==="Q"?(E=T[0]+A,P=T[1]+M):l&&(E=2*s-l[0],P=2*i-l[1]);const I=y==="Q"?T[2]+A:T[0]+A,O=y==="Q"?T[3]+M:T[1]+M;u(rr(s,i,[s+2/3*(E-s),i+2/3*(P-i),I+2/3*(E-I),O+2/3*(P-O),I,O])),S=[E,P],s=I,i=O;break}case"A":{const E=T[5]+A,P=T[6]+M;let I=s,O=i;for(const H of q1(s,i,T[0],T[1],T[2],T[3],T[4],E,P))u(rr(I,O,H)),I=H[4],O=H[5];s=E,i=P;break}}a=x,l=S}}const d=n.reduce((g,m)=>g+m.length,0),f=[];for(let g=0;g<n.length;){const m=n[g].subpath;let y=g,v=0;for(;y<n.length&&n[y].subpath===m;)v+=n[y++].length;const k=n[g],w=n[y-1],T=h.has(m)||Math.abs(w.endX-k.startX)<1e-9&&Math.abs(w.endY-k.startY)<1e-9;f.push({start:g,end:y,length:v,closed:T}),g=y}const p={segments:n,totalLength:d,subpaths:f};return qn.size>=N1&&qn.delete(qn.keys().next().value),qn.set(t,p),p}function j1(t,e){const n=t.lengths;if(e<=0)return 0;if(e>=t.length)return 1;let s=0,i=n.length-1;for(;s<i-1;){const a=s+i>>1;n[a]<e?s=a:i=a}const r=n[i]-n[s],o=r>0?(e-n[s])/r:0;return(s+o)/(n.length-1)}function Y1(t,e){if(t.type==="L"){const u=t.length>0?Math.max(0,Math.min(1,e/t.length)):0;return{x:t.startX+(t.endX-t.startX)*u,y:t.startY+(t.endY-t.startY)*u,angle:Math.atan2(t.endY-t.startY,t.endX-t.startX)*180/Math.PI}}const[n,s,i,r,o,a]=t.points,l=j1(t,e);let c=u0(t.startX,n,i,o,l),h=u0(t.startY,s,r,a,l);if(Math.hypot(c,h)<1e-9){const u=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),d=qe(t.startX,n,i,o,u),f=qe(t.startY,s,r,a,u),p=qe(t.startX,n,i,o,l),g=qe(t.startY,s,r,a,l);c=l<.5?d-p:p-d,h=l<.5?f-g:g-f}return{x:qe(t.startX,n,i,o,l),y:qe(t.startY,s,r,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function ha(t,e,n=0,s=t.length){if(s<=n)return{x:0,y:0,angle:0};let i=0;for(let r=n;r<s;r++){const o=t[r];if(i+o.length>=e||r===s-1)return Y1(o,e-i);i+=o.length}return{x:0,y:0,angle:0}}function d0(t,e){const{segments:n,totalLength:s}=pn(t);return ha(n,Math.max(0,Math.min(1,e))*s)}function K1(){qn.clear()}function X1(t){return pn(t).totalLength}const G1=24,U1=320,V1=2.5,qs=72,J1=64,Z1=.2,Q1=128,js=new Map;let or=0,je;const f0=t=>Math.round(t*100)/100;function g0(t,e){const{segments:n,subpaths:s,totalLength:i}=pn(t);if(n.length===0)return[];if(e){const r=s.every(o=>o.closed);return[{segments:n,start:0,end:n.length,length:i,closed:r}]}return s.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function ua(t,e){const n=t.closed?(e%1+1)%1:Math.max(0,Math.min(1,e)),s=ha(t.segments,n*t.length,t.start,t.end);return[s.x,s.y]}function p0(t){const e=[];let n=0;for(let s=t.start;s<t.end;s++)n+=t.segments[s].length,t.length>0&&e.push(n/t.length);return e}function m0(t,e){const n=[];for(let s=0;s<e;s++)n.push(ua(t,t.closed?s/e:s/(e-1)));return n}function y0(t){let e=0,n=0;for(const[s,i]of t)e+=s,n+=i;return e/=t.length,n/=t.length,t.map(([s,i])=>[s-e,i-n])}function tb(t,e,n){const s=t.closed&&e.closed;if(n!==void 0)return{offset:s?Math.abs(n)%qs/qs:0,reversed:n<0};const i=y0(m0(t,qs)),r=y0(m0(e,qs)),o=qs;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=s?o:1;for(let u=0;u<h;u++){let d=0;for(let f=0;f<o&&d<l;f++){const p=s?c?(u-f+o)%o:(f+u)%o:c?o-1-f:f,g=i[f][0]-r[p][0],m=i[f][1]-r[p][1];d+=g*g+m*m}d<l&&(l=d,a={offset:s?u/o:0,reversed:c})}}return a}function eb(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function nb(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function sb(t,e,n){const s=t.closed&&e.closed,i=tb(t,e,n.shapeIndex),r=Math.max(G1,Math.min(U1,Math.ceil(Math.max(t.length,e.length)/V1))),o=new Set,a=u=>o.add(Math.round(u*1e7)/1e7);for(let u=0;u<=r;u++)a(u/r);for(const u of p0(t))a(u);for(const u of p0(e))a(nb(u,i,s));let l=[...o].sort((u,d)=>u-d);s&&(l=l.filter(u=>u<1));const c=[],h=[];for(const u of l)c.push(...ua(t,u)),h.push(...ua(e,eb(u,i,s)));return ib({from:c,to:h,closed:s})}function ib(t){const e=t.from.length/2;if(e<=3)return t;const n=new Uint8Array(e);n[0]=1,n[e-1]=1;const s=[[0,e-1]];for(;s.length>0;){const[o,a]=s.pop();let l=-1,c=Z1;for(let h=o+1;h<a;h++){const u=Math.max(b0(t.from,o,a,h),b0(t.to,o,a,h));u>c&&(c=u,l=h)}l!==-1&&(n[l]=1,s.push([o,l],[l,a]))}const i=[],r=[];for(let o=0;o<e;o++)n[o]&&(i.push(t.from[o*2],t.from[o*2+1]),r.push(t.to[o*2],t.to[o*2+1]));return{from:i,to:r,closed:t.closed}}function b0(t,e,n,s){const i=t[e*2],r=t[e*2+1],o=t[n*2]-i,a=t[n*2+1]-r,l=t[s*2]-i,c=t[s*2+1]-r,h=o*o+a*a,u=h===0?0:Math.max(0,Math.min(1,(l*o+c*a)/h));return Math.hypot(l-u*o,c-u*a)}function rb(t,e,n){const s=n.shapeIndex;if(je&&je.from===t&&je.to===e&&je.shapeIndex===s)return je.plan;const r=js.get(String(s??"auto"))?.get(t)?.get(e);if(r)return je={from:t,to:e,shapeIndex:s,plan:r},r;const o=pn(t).subpaths.filter(f=>f.length>0).length===pn(e).subpaths.filter(f=>f.length>0).length,a=g0(t,!o),l=g0(e,!o),c={pairs:a.map((f,p)=>sb(f,l[p],n))};or>=Q1&&(js.clear(),or=0);const h=String(s??"auto"),u=js.get(h)??new Map;js.set(h,u);const d=u.get(t)??new Map;return u.set(t,d),d.set(e,c),or++,je={from:t,to:e,shapeIndex:s,plan:c},c}function w0(t,e,n,s={}){if(!t)return e;if(!e)return t;const i=Math.max(0,Math.min(1,n));if(i===0)return t;if(i===1)return e;const r=rb(t,e,s);if(r.pairs.length===0)return i<.5?t:e;let o="";for(const a of r.pairs){for(let l=0;l<a.from.length;l+=2){const c=f0(a.from[l]+(a.to[l]-a.from[l])*i),h=f0(a.from[l+1]+(a.to[l+1]-a.from[l+1])*i);o+=`${l===0?o?" M":"M":" L"}${c} ${h}`}a.closed&&(o+=" Z")}return o}function ob(){js.clear(),or=0,je=void 0}function jn(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const Yn=Math.PI/180,ab=.9995;function da(){return[0,0,0,1]}function Vt(t,e){const n=Math.hypot(t[0],t[1],t[2]);if(n===0)return da();const s=e*Yn/2,i=Math.sin(s)/n;return[t[0]*i,t[1]*i,t[2]*i,Math.cos(s)]}function lb(t,e,n){return fa(fa(Vt([0,1,0],e),Vt([1,0,0],t)),Vt([0,0,1],n))}function cb(t){const[e,n,s,i]=Ye(t),r=2*(e*s+n*i),o=2*(e*n+s*i),a=1-2*(e*e+s*s),l=2*(n*s-e*i),c=1-2*(n*n+s*s),h=2*(e*s-n*i),u=1-2*(e*e+n*n),d=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[d/Yn,Math.atan2(r,u)/Yn,Math.atan2(o,a)/Yn]:[d/Yn,Math.atan2(-h,c)/Yn,0]}function fa(t,e){const[n,s,i,r]=t,[o,a,l,c]=e;return[r*o+n*c+s*l-i*a,r*a-n*l+s*c+i*o,r*l+n*a-s*o+i*c,r*c-n*o-s*a-i*l]}function k0(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function v0(t){return Math.hypot(t[0],t[1],t[2],t[3])}function Ye(t){const e=v0(t);return e===0?da():[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}function hb(t){return[-t[0],-t[1],-t[2],t[3]]}function M0(t,e,n){const s=Ye(t);let i=Ye(e),r=k0(s,i);if(r<0&&(i=[-i[0],-i[1],-i[2],-i[3]],r=-r),r>ab)return Ye([s[0]+(i[0]-s[0])*n,s[1]+(i[1]-s[1])*n,s[2]+(i[2]-s[2])*n,s[3]+(i[3]-s[3])*n]);const o=Math.acos(r),a=Math.sin(o),l=Math.sin((1-n)*o)/a,c=Math.sin(n*o)/a;return Ye([s[0]*l+i[0]*c,s[1]*l+i[1]*c,s[2]*l+i[2]*c,s[3]*l+i[3]*c])}function ub(t,e){const[n,s,i,r]=Ye(t),o=2*(s*e[2]-i*e[1]),a=2*(i*e[0]-n*e[2]),l=2*(n*e[1]-s*e[0]);return[e[0]+r*o+(s*l-i*a),e[1]+r*a+(i*o-n*l),e[2]+r*l+(n*a-s*o)]}const db=Object.freeze(Object.defineProperty({__proto__:null,conjugate:hb,dot:k0,fromAxisAngle:Vt,fromEuler:lb,identity:da,length:v0,multiply:fa,normalize:Ye,rotateVec3:ub,slerp:M0,toEuler:cb},Symbol.toStringTag,{value:"Module"})),ve=(t,e,n)=>t+(e-t)*n,S0=512,ga=new Map,pa=new Map;function x0(t){const e=ga.get(t);if(e)return e;const n=t.replace("#",""),s=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return ga.size<S0&&ga.set(t,s),s}const T0=t=>t.charCodeAt(0)===35,E0=t=>t.startsWith("rgb"),A0=t=>t.startsWith("rgba"),fb=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,ma=t=>Math.round(t).toString(16).padStart(2,"0");function gb(t,e,n){return`#${ma(t)}${ma(e)}${ma(n)}`}function P0(t){const e=pa.get(t);if(e)return e;const n=t.match(fb);if(!n)throw new Error(`Invalid rgb color: ${t}`);const s=parseInt(n[1],10),i=parseInt(n[2],10),r=parseInt(n[3],10),o=n[4]!==void 0?[s,i,r,parseFloat(n[4])]:[s,i,r];return pa.size<S0&&pa.set(t,o),o}const $0=(t,e,n)=>{if(T0(t)&&T0(e)){const[s,i,r]=x0(t),[o,a,l]=x0(e),c=ve(s,o,n),h=ve(i,a,n),u=ve(r,l,n);return gb(c,h,u)}if((E0(t)||A0(t))&&(E0(e)||A0(e))){const s=P0(t),i=P0(e),r=Math.round(ve(s[0],i[0],n)),o=Math.round(ve(s[1],i[1],n)),a=Math.round(ve(s[2],i[2],n));if(s.length===4||i.length===4){const l=s[3]??1,c=i[3]??1,h=ve(l,c,n);return`rgba(${r}, ${o}, ${a}, ${h})`}return`rgb(${r}, ${o}, ${a})`}return n<1?t:e},I0=(t,e,n)=>{const s=Math.min(t.length,e.length),i=[];for(let r=0;r<s;r++)i.push(ve(t[r],e[r],n));return i},O0=(t,e,n)=>M0(t,e,n),ya=(t,e,n)=>n<1?t:e,C0=(t,e,n)=>w0(t,e,n);function Ys(t,e){return e==="slerp"?O0:typeof t=="number"?ve:Array.isArray(t)?I0:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?$0:jn(t)?C0:ya:ya}const ba=1e3/60;function wa(t,e={}){if(!ze(t))throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);const n=new Ws(t.spring);return _0(t,s=>n.valueAt(s),n.settleTime(),t.spring.from,t.spring.to,e)}function ka(t,e={}){if(!Be(t))throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);const n=t.inertia;return _0(t,s=>sr(n,s),zn(n),n.from,Bn(n),e)}function _0(t,e,n,s,i,r){const o=r.intervalMs??ba,a=r.tolerance??.01,l=t.delay??0,c=[];for(let u=0;u<=n;u+=o)c.push({time:u+l,value:e(u),easing:"linear"});const h=c[c.length-1];return!h||h.time<n+l?c.push({time:n+l,value:i,easing:"linear"}):h.value=i,l>0&&c.unshift({time:0,value:s,easing:"linear"}),{id:t.id,target:t.target,property:t.property,keyframes:a>0?R0(c,a):c,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function va(t,e,n,s={}){const i=s.intervalMs??ba,r=typeof n=="function"?n:Wt(n),o=Ys(t.value,s.interpolation),a=e.time-t.time;if(a<=0)return[e];const l=[];for(let h=i;h<a;h+=i){const u=h/a;l.push({time:t.time+h,value:o(t.value,e.value,r(u)),easing:"linear"})}const c=r(1);return l.push({...e,...c!==1&&{value:o(t.value,e.value,c)},easing:"linear"}),l}function pb(t,e){return ze(t)?wa(t,e):Be(t)?ka(t,e):t}function H0(t,e={}){const n=t.keyframes;if(!n.some(r=>Fs(r.easing)))return t;const s=n.length>0?[n[0]]:[],i={...e,interpolation:t.interpolation??e.interpolation};for(let r=1;r<n.length;r++){const o=n[r];Fs(o.easing)?s.push(...va(n[r-1],o,o.easing,i)):s.push(o)}return{...t,keyframes:s}}function mb(t,e){return t.filter(Gh).map(n=>H0(n,e)).concat(t.filter(ze).map(n=>wa(n,e)),t.filter(Be).map(n=>ka(n,e)))}function R0(t,e){if(t.length<=2)return t;const n=[t[0]];for(let s=1;s<t.length-1;s++){const i=n[n.length-1],r=t[s],o=t[s+1],a=o.time-i.time;if(a<=0)continue;const l=(r.time-i.time)/a,c=i.value+(o.value-i.value)*l;Math.abs(r.value-c)>e&&n.push(r)}return n.push(t[t.length-1]),n}function ar(t){const e=[...t.keyframes].sort((n,s)=>n.time-s.time);return{...t,keyframes:e}}function Ke(t){return t.targets&&t.targets.length>0?t.targets:[t.target]}function Kn(t,e,n,s){const i=n??0;return!s||e<=1?i:i+Zi(t,e,s)}class Xe{track;targets;constructor(e){this.track=e,this.targets=Ke(e)}getValueAtTime(e){return this.valueForOffset(e-Kn(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,s=[];for(let i=0;i<n;i++){const r=Kn(i,n,this.track.delay,this.track.stagger),o=this.valueForOffset(e-r);o!==void 0&&s.push({target:this.targets[i],value:o,start:r+this.track.keyframes[0].time})}return s}getDuration(){const{keyframes:e}=this.track;if(e.length===0)return 0;const n=e[e.length-1].time,s=this.track.stagger?Ns(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+s+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(e){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||e<=n[0].time)return n[0].value;if(e>=n[n.length-1].time)return n[n.length-1].value;const{from:s,to:i}=this.findSurroundingKeyframes(e);if(!s||!i)return;if(s.time===e)return s.value;const r=i.time-s.time,o=(e-s.time)/r,l=Wt(i.easing)(o);return Ys(s.value,this.track.interpolation)(s.value,i.value,l)}findSurroundingKeyframes(e){const{keyframes:n}=this.track;for(let s=0;s<n.length-1;s++)if(e>=n[s].time&&e<=n[s+1].time)return{from:n[s],to:n[s+1]};return{from:null,to:null}}}class L0{track;targets;sampler;constructor(e){this.track=e,this.targets=Ke(e),this.sampler=new Ws(e.spring)}getValueAtTime(e){return this.sampler.valueAt(e-Kn(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,s=[];for(let i=0;i<n;i++){const r=Kn(i,n,this.track.delay,this.track.stagger);s.push({target:this.targets[i],value:this.sampler.valueAt(e-r),start:r})}return s}getDuration(){const e=this.track.stagger?Ns(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+e}getTrack(){return this.track}}class F0{track;targets;duration;constructor(e){this.track=e,this.targets=Ke(e),this.duration=zn(e.inertia)}getValueAtTime(e){return sr(this.track.inertia,e-Kn(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,s=[];for(let i=0;i<n;i++){const r=Kn(i,n,this.track.delay,this.track.stagger);s.push({target:this.targets[i],value:sr(this.track.inertia,e-r),start:r})}return s}getDuration(){const e=this.track.stagger?Ns(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+e}getTrack(){return this.track}}function Ma(t,e){const n={...d0(t.pathData,e)};if(t.matrix){const[s,i,r,o,a,l]=t.matrix,{x:c,y:h}=n;n.x=s*c+r*h+a,n.y=i*c+o*h+l;const u=n.angle*Math.PI/180,d=Math.cos(u),f=Math.sin(u);n.angle=Math.atan2(i*d+o*f,s*d+r*f)*180/Math.PI}return t.autoRotate&&t.rotateOffset&&(n.angle+=t.rotateOffset),n}function yb(t,e,n,s){const i=e+(n-e)*s;return Ma(t,i)}const Sa={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},bb=20;function N0(t){const e=Sa[t??"upperCase"]??t??Sa.upperCase,n=Array.from(e);return n.length>0?n:Array.from(Sa.upperCase)}function wb(t,e,n){let s=(t|0)^Math.imul(e+1,2654435761)^Math.imul(n+1,2246822507);return s=Math.imul(s^s>>>16,2146121005),s=Math.imul(s^s>>>15,2221713035),(s^s>>>16)>>>0}function W0(t,e,n=0){const s=t.from??"",i=t.to,r=Math.max(0,Math.min(1,e));if(r<=0)return s;if(r>=1)return i;const o=Array.from(s),a=Array.from(i),l=t.rightToLeft??!1;if(t.mode==="type"){const v=Math.round(r*Math.max(o.length,a.length));return l?o.slice(0,Math.max(0,o.length-v)).join("")+a.slice(Math.max(0,a.length-v)).join(""):a.slice(0,v).join("")+o.slice(v).join("")}const c=Math.max(0,Math.min(.999,t.revealDelay??0)),h=Math.max(0,(r-c)/(1-c)),u=Math.floor(h*a.length),d=t.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),f=N0(t.chars),p=t.refreshRate??bb,g=p>0?Math.floor(n*p/1e3):0,m=t.seed??1;let y="";for(let v=0;v<d;v++){const k=l?v>=d-u:v<u,w=l?a[a.length-(d-v)]:a[v];k&&w!==void 0||w===" "||w===`
2
- `?y+=w:y+=f[wb(m,v,g)%f.length]}return y}class Ht{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(e){if(this.id=e.id,this.name=e.name,this._captions=e.captions,this._config=e.config??{},this._explicitDuration=e.config?.duration,e.tracks)for(const n of e.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(e){if(this._explicitDuration=e,e!==void 0)this._config={...this._config,duration:e};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(e){this._config.speed=e}get drawingRate(){return this._config.drawingRate??0}set drawingRate(e){const n={...this._config};e>0?n.drawingRate=e:delete n.drawingRate,this._config=n}play(){const e=this.duration;this._direction==="forward"&&this._currentTime>=e&&e>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&e>0&&(this._currentTime=e,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(e){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(e,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(e){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let i=e*this.speed;if(this._repeatDelayRemaining>0){const a=Math.min(this._repeatDelayRemaining,i);if(this._repeatDelayRemaining-=a,i-=a,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let a=0;a<r&&i>0&&this._playbackState==="playing";a++)if(this._direction==="forward"){const l=n-this._currentTime;if(i>=l){if(i-=l,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=i,i=0}else{const l=this._currentTime;if(i>=l){if(i-=l,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=i,i=0}const o=this.getStateAtTime(this._currentTime);this.onUpdate?.(o)}getStateAtTime(e){const n=new Map;if(e=Uh(e,this._config.drawingRate??0),this._hasSharedWrites())this._resolveShared(e,n);else for(const[s,i]of this._trackPlayers){const r=i.getTrack().property;for(const{target:o,value:a,start:l}of i.getTargetValues(e))this._write(n,s,o,r,a,e-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(e,n){const s=new Map;for(const[i,r]of this._trackPlayers){const o=r.getTrack().property;for(const{target:a,value:l,start:c}of r.getTargetValues(e)){const h=`${a}\0${o}`,u=c<=e,d=s.get(h);(!d||(u!==d.started?u:u?c>=d.start:c<=d.start))&&s.set(h,{trackId:i,target:a,property:o,value:l,start:c,started:u})}}for(const{trackId:i,target:r,property:o,value:a,start:l}of s.values())this._write(n,i,r,o,a,e-l)}_write(e,n,s,i,r,o){if(r===void 0)return;let a=e.get(s);a||(a=new Map,e.set(s,a));const l=this._textTracks.get(n);if(l&&typeof r=="number"){a.set("text",W0(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=Ma(c.motionPathConfig,r);a.set("motionPathX",h.x),a.set("motionPathY",h.y),c.motionPathConfig.autoRotate&&a.set("motionPathRotate",h.angle)}else a.set(i,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const e=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const s of Ke(n)){const i=`${s}\0${n.property}`;if(e.has(i)){this._sharedWrites=!0;break t}e.add(i)}}return this._sharedWrites}addTrack(e){if(this._tracks.push(e),this._sharedWrites=null,Be(e)){this._trackPlayers.set(e.id,new F0(e));return}if(ze(e)){this._trackPlayers.set(e.id,new L0(e)),this._springTracks.set(e.id,e);return}if(Ji(e))this._trackPlayers.set(e.id,new Xe(e)),this._textTracks.set(e.id,e);else if(na(e)){const n={id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,delay:e.delay,endDelay:e.endDelay,targets:e.targets,stagger:e.stagger};this._trackPlayers.set(e.id,new Xe(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new Xe(e))}replaceTrack(e,n){const s=this._tracks.findIndex(r=>r.id===e);if(s<0)return;const i=this._tracks.slice(s+1);this.removeTrack(e);for(const r of i)this.removeTrack(r.id);this.addTrack(n);for(const r of i)this.addTrack(r)}removeTrack(e){this._tracks=this._tracks.filter(n=>n.id!==e),this._sharedWrites=null,this._trackPlayers.delete(e),this._motionPathTracks.delete(e),this._springTracks.delete(e),this._textTracks.delete(e)}getTracks(e={}){return this._tracks.filter(n=>this._matches(n,e))}removeTracks(e={}){const n=this.getTracks(e).map(s=>s.id);for(const s of n)this.removeTrack(s);return n}getTrackSpan(e){const n=this._trackPlayers.get(e);if(!n)return;const s=n.getTrack(),i=s.delay??0;if(ze(s)||Be(s))return{from:i,to:n.getDuration()};const r=s.keyframes;if(!(!r||r.length===0))return{from:r[0].time+i,to:n.getDuration()}}findConflicts(){const e=[];for(let n=0;n<this._tracks.length;n++){const s=this._tracks[n],i=this.getTrackSpan(s.id);if(i)for(let r=0;r<n;r++){const o=this._tracks[r];if(o.property!==s.property)continue;const a=Ke(o).filter(u=>Ke(s).includes(u));if(a.length===0)continue;const l=this.getTrackSpan(o.id);if(!l||!(l.from<=i.to&&i.from<=l.to))continue;const h=i.from>=l.from;for(const u of a)e.push({target:u,property:s.property,losingTrackId:h?o.id:s.id,winningTrackId:h?s.id:o.id})}}return e}_matches(e,n){if(n.id!==void 0&&e.id!==n.id||n.property!==void 0&&e.property!==n.property||n.target!==void 0&&!Ke(e).includes(n.target))return!1;if(n.timeRange){const s=this.getTrackSpan(e.id);if(!s||s.to<n.timeRange.from||s.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:ea(this._tracks),id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((e,n)=>e.time-n.time)}setMarkers(e){const n=e&&e.length>0?[...e].sort((i,r)=>i.time-r.time).map(i=>({...i})):void 0,s={...this._config};n?s.markers=n:delete s.markers,this._config=s}get captions(){return this._captions}setCaptions(e){const n={};for(const[s,i]of Object.entries(e??{}))n[s]={...i};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let e=0;for(const[,n]of this._trackPlayers)e=Math.max(e,n.getDuration());return e}_handleEndReached(){const e=this._config.loop??0;return e===-1||this._loopIteration<e?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const e=this._config.loop??0;return this._config.alternate&&(e===-1||this._loopIteration<e)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const kb=100;function xa(t,e,n,s){const i=[],r=[],{duration:o,alternate:a}=s,l=(f,p,g,m)=>{r.push([f,p]);const y=[];t.forEach((v,k)=>{(g==="forward"?(m?v>=f:v>f)&&v<=p:(m?v<=f:v<f)&&v>=p)&&y.push(k)}),y.sort((v,k)=>(g==="forward"?t[v]-t[k]:t[k]-t[v])||v-k);for(const v of y)i.push({kind:"event",index:v,direction:g})};let c=e.time,h=e.direction,u=e.fresh===!0;const d=Math.min(kb,Math.max(0,n.iteration-e.iteration));for(let f=0;f<d;f++){const p=h==="forward"?o:0;l(c,p,h,u),i.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=p,u=!1):(c=h==="forward"?0:o,u=!0)}return d>0&&s.holding&&!a?{crossings:i,passes:r}:(l(c,n.time,h,u),{crossings:i,passes:r})}function D0(t){return Be(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:B0(t.inertia),...Me(t)}:ze(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...Me(t)}:Ji(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(Ta),...Me(t)}:na(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(Ta),...Me(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(Ta),...t.interpolation!==void 0&&{interpolation:t.interpolation},...Me(t)}}function B0(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function Ta(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function Me(t){const e=t.endDelay;return{...t.delay!==void 0&&{delay:t.delay},...e!==void 0&&{endDelay:e},...t.targets!==void 0&&{targets:[...t.targets]},...t.stagger!==void 0&&{stagger:{...t.stagger}}}}function z0(t){if(Be(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:B0(e.inertia),...Me(e)}}if(ze(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...Me(e)}}if(Ji(t)){const e=t;return{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:[...e.keyframes].sort((n,s)=>n.time-s.time),...Me(e)}}if(t.property==="motionPath"&&"motionPathConfig"in t){const e=t,n=[...e.keyframes].sort((s,i)=>s.time-i.time);return{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:n,...Me(e)}}return ar({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...t.interpolation!==void 0&&{interpolation:t.interpolation},...Me(t)})}function q0(t){const e=t._config.markers;return{formatVersion:ea(t.tracks),id:t.id,name:t.name,config:{duration:t.duration>0?t.duration:void 0,loop:t._config.loop,speed:t._config.speed,alternate:t._config.alternate,repeatDelay:t._config.repeatDelay,...t._config.drawingRate?{drawingRate:t._config.drawingRate}:{},...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(D0),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function Xn(t){const e=t.formatVersion??1;if(e>ta)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${ta}. Update tinyfly to play it.`);return new Ht({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(z0),captions:t.captions})}function vb(t){return JSON.stringify(q0(t))}function Mb(t){const e=JSON.parse(t);return Xn(e)}function ne(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function Ge(t){let e=t>>>0||2654435769;return{seed:t>>>0,next(){return e^=e<<13,e>>>=0,e^=e>>17,e^=e<<5,e>>>=0,e/4294967296}}}function Ea(t,e,n){return e+t.next()*(n-e)}function j0(t,e,n,s){if(s<=0)return Ea(t,e,n);const i=Math.floor((n-e)/s),r=Math.round(t.next()*i);return e+r*s}function Sb(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const Y0=/^([+\-*/])=\s*(-?[\d.]+)$/,K0=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function xb(t){return typeof t!="string"?!1:Y0.test(t.trim())||K0.test(t.trim())}function Aa(t,e={}){if(typeof t!="string")return t;const n=t.trim(),s=Y0.exec(n);if(s){const[,r,o]=s,a=e.base??0,l=Number.parseFloat(o);switch(r){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const i=K0.exec(n);if(i){if(!e.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const r=Number.parseFloat(i[1]),o=Number.parseFloat(i[2]),a=i[3]!==void 0?Number.parseFloat(i[3]):void 0;return a!==void 0?j0(e.random,r,o,a):Ea(e.random,r,o)}return t}function X0(t,e=0,n){const s=[];let i=e;for(const r of t){const o=Aa(r,{base:i,random:n});s.push(o),typeof o=="number"&&(i=o)}return s}class Tb{random;constructor(e){this.random=Ge(e)}get seed(){return this.random.seed}resolve(e,n=0){return Aa(e,{base:n,random:this.random})}resolveSequence(e,n=0){return X0(e,n,this.random)}}const Eb=600;function G0(t){if(Array.isArray(t)){const[d,f,p,g]=t;return{fn:J0(d,f,p,g),bezier:[d,f,p,g]}}const{segments:e}=pn(t);if(e.length===0)throw new Error(`customEase: no curve in "${t}"`);const n=e[0].startX,s=e[0].startY,i=e[e.length-1],r=i.endX-n,o=i.endY-s;if(r===0||o===0)throw new Error(`customEase: "${t}" must move along both axes`);const a=d=>(d-n)/r,l=d=>(d-s)/o;if(e.length===1&&i.type==="C"){const[d,f,p,g]=i.points,m=[a(d),l(f),a(p),l(g)];return{fn:J0(...m),bezier:m}}const c=[],h=[],u=Math.max(8,Math.ceil(Eb/e.length));for(const d of e)for(let f=c.length===0?0:1;f<=u;f++){const[p,g]=Ab(d,f/u);c.push(a(p)),h.push(l(g))}return{fn:Pb(c,h)}}function U0(t={}){const n=.1+Math.max(0,Math.min(1,t.strength??.7))*.7,s=[1];for(let r=n;r>.002;r*=n)s.push(2*Math.sqrt(r));const i=s.reduce((r,o)=>r+o,0);return r=>{if(r<=0)return 0;if(r>=1)return 1;let o=r*i;for(let a=0;a<s.length;a++){if(o<=s[a]){if(a===0)return(o/s[0])**2;const l=s[a]/2,c=l*l,h=o-l;return 1-(c-h*h)}o-=s[a]}return 1}}function V0(t={}){const e=Math.max(1,t.wiggles??10),n=t.type??"easeOut",s=i=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*i):(1-i)**2;return i=>i<=0||i>=1?0:Math.sin(i*e*Math.PI*2)*s(i)}function Ab(t,e){if(t.type==="L"){const[c,h]=t.points;return[t.startX+(c-t.startX)*e,t.startY+(h-t.startY)*e]}const[n,s,i,r,o,a]=t.points,l=1-e;return[l*l*l*t.startX+3*l*l*e*n+3*l*e*e*i+e*e*e*o,l*l*l*t.startY+3*l*l*e*s+3*l*e*e*r+e*e*e*a]}function Pb(t,e){return n=>{if(n<=t[0])return e[0];if(n>=t[t.length-1])return e[e.length-1];let s=0,i=t.length-1;for(;i-s>1;){const o=s+i>>1;t[o]<=n?s=o:i=o}const r=t[i]-t[s];return r===0?e[i]:e[s]+(n-t[s])/r*(e[i]-e[s])}}function J0(t,e,n,s){const i=(o,a,l)=>3*(1-o)*(1-o)*o*a+3*(1-o)*o*o*l+o*o*o,r=(o,a,l)=>3*(1-o)*(1-o)*a+6*(1-o)*o*(l-a)+3*o*o*(1-l);return o=>{if(o<=0)return 0;if(o>=1)return 1;let a=o;for(let h=0;h<8;h++){const u=i(a,t,n)-o,d=r(a,t,n);if(Math.abs(u)<1e-6)return i(a,e,s);if(Math.abs(d)<1e-6)break;a-=u/d}let l=0,c=1;a=o;for(let h=0;h<40;h++)i(a,t,n)<o?l=a:c=a,a=(l+c)/2;return i(a,e,s)}}const $b=350,Ib=300,Ob=550;function Cb(t,e={}){const n=e.lead??$b,s=e.gap??Ib,i=e.tail??Ob,r=[];let o=0;return t.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((d,f)=>{if(!(d.duration>=0))throw new Error(`narration: scene ${l} line ${f} has an invalid duration (${d.duration})`);f>0&&(h+=s),c.push({id:d.id??`s${l}-l${f}`,scene:l,line:f,start:h,end:h+d.duration,text:d.text}),h+=d.duration});const u=h+i+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:u-o,cues:c}),o=u}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function _b(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function Hb(t,e){let n=t.scenes[0];for(const s of t.scenes)if(e>=s.start)n=s;else break;return n}const Ks=t=>6e4/t.bpm;function lr(t,e){return t.offset+e*Ks(t)}function Xs(t,e){return(e-t.offset)/Ks(t)}function Rb(t,e){return lr(t,Math.round(Xs(t,e)))}function Lb(t,e){return lr(t,Math.ceil(Xs(t,e)-1e-9))}function Fb(t,e,n){const s=Math.max(1,Math.round(t.beatsPerBar??4)),i=[];if(!(t.bpm>0)||n<e)return i;for(let r=Math.ceil(Xs(t,e)-1e-9);;r++){const o=lr(t,r);if(o>n+1e-9)break;i.push({time:o,bar:(r%s+s)%s===0,n:r})}return i}const Gn=100;function Nb(t,e,n={}){const s=n.minBpm??70,i=n.maxBpm??180,r=Math.max(1,Math.round(e/Gn)),o=Math.min(t.length,Math.round((n.maxSeconds??60)*e)),a=Math.floor(o/r);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let S=0;S<a;S++){let E=0;for(let P=S*r;P<(S+1)*r;P++)E+=t[P]*t[P];l[S]=Math.log(1e-6+E/r)}const c=new Float64Array(a);for(let S=1;S<a;S++)c[S]=Math.max(0,l[S]-l[S-1]);const h=c.reduce((S,E)=>S+E,0)/a;for(let S=0;S<a;S++)c[S]=Math.max(0,c[S]-h);const u=Math.max(1,Math.floor(60*Gn/i)),d=Math.min(a-1,Math.ceil(60*Gn/s)),f=S=>{let E=0;for(let P=S;P<a;P++)E+=c[P]*c[P-S];return E/(a-S)};let p=0;for(let S=0;S<a;S++)p+=c[S]*c[S];p/=a;let g=u,m=-1/0;for(let S=u;S<=d;S++){const E=60*Gn/S,P=Math.exp(-.5*(Math.log2(E/120)/.9)**2),I=f(S)*P;I>m&&(m=I,g=S)}const y=S=>{const E=Math.floor(S);return E<0||E+1>=a?0:c[E]+(c[E+1]-c[E])*(S-E)},v=(S,E)=>{let P=0;for(let I=E;I<a;I+=S)P+=y(I);return P};let k=g,w=0,T=-1/0;for(let S=g-.6;S<=g+.6+1e-9;S+=.02){if(S<1)continue;const E=Math.max(1,Math.round(S*4));for(let P=0;P<E;P++){const I=P/E*S,O=v(S,I);O>T&&(T=O,w=I,k=S)}}const A=60*Gn/k,M=p>0?Math.max(0,Math.min(1,f(g)/p)):0,x=(w+.5)*1e3/Gn;return{bpm:Math.round(A*100)/100,offset:Math.round(x%(6e4/A)),confidence:M}}const Wb=600,Db=250,Z0=1;function Bb(t,e){const n=e.target??"Camera",s={x:e.stage.width/2,y:e.stage.height/2},i={},r=(u,d,f,p)=>{const g=i[u]??=[];for(;g.length>0&&g[g.length-1].time>=d;)g.pop();g.push({time:d,value:f,...p?{easing:p}:{}})},o=u=>{const d=u.rotate*Math.PI/180,f=(u.focusX-s.x)*u.scale,p=(u.focusY-s.y)*u.scale;return{x:-(f*Math.cos(d)-p*Math.sin(d)),y:-(f*Math.sin(d)+p*Math.cos(d)),scale:u.scale,rotate:u.rotate}},a=(u,d,f)=>{const p=o(d);for(const g of["x","y","scale","rotate"])r(g,u,p[g],f)};let l={focusX:s.x,focusY:s.y,scale:1,rotate:0};const c=[...t].sort((u,d)=>u.at-d.at),h=c.filter(u=>!("shake"in u));h.length>0&&a(0,l);for(const u of h)if("frame"in u){const d=Math.max(Z0,u.duration??Wb);a(u.at,l),l={focusX:u.frame.focus?.x??s.x,focusY:u.frame.focus?.y??s.y,scale:u.frame.scale??1,rotate:u.frame.rotate??0},a(u.at+d,l,u.easing??(d>Z0?"ease-in-out":void 0))}else{const{follow:d}=u,f=d.lag??Db,p=new Ht({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:d.x}]}),g=v=>p.getStateAtTime(v).values.get("s")?.get("x")??l.focusX,m=[u.at,...d.x.map(v=>v.time).filter(v=>v>u.at&&v<u.until),u.until];a(u.at,l);const y=v=>({focusX:g(v)+(d.lead??0),focusY:d.y??l.focusY,scale:d.scale??l.scale,rotate:l.rotate});for(const v of m){const k=d.x.find(w=>w.time===v)?.easing;a(v+f,y(v),v===u.at?"ease-in-out":k)}l=y(u.until)}for(const u of c.filter(d=>"shake"in d)){const d=u.shake.strength??12,f=u.shake.roll??1.5,p=1e3/(u.shake.frequency??24),g=Ge(u.shake.seed??Math.round(u.at)+1),m=()=>g.next()*2-1;for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at,0);for(let y=u.at+p;y<u.at+u.duration;y+=p){const v=1-(y-u.at)/u.duration;r("shakeX",y,m()*d*v),r("shakeY",y,m()*d*v),r("shakeRotate",y,m()*f*v)}for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at+u.duration,0,"ease-out")}return Object.entries(i).map(([u,d])=>({id:`${n}-${u}`,target:n,property:u,keyframes:d}))}function Q0(t,e){const n=t.toLowerCase(),s=e.toLowerCase();let i=Array.from({length:s.length+1},(r,o)=>o);for(let r=1;r<=n.length;r++){const o=[r];for(let a=1;a<=s.length;a++)o[a]=Math.min(i[a]+1,o[a-1]+1,i[a-1]+(n[r-1]===s[a-1]?0:1));i=o}return i[s.length]}function Gs(t,e){const n=t.toLowerCase(),s=e.find(o=>o.toLowerCase().includes(n)||n.includes(o.toLowerCase()));if(s&&Math.min(t.length,s.length)>=3)return s;let i,r=1/0;for(const o of e){const a=Q0(t,o);a<r&&(r=a,i=o)}return i!==void 0&&r<=Math.max(2,Math.floor(t.length/3))?i:void 0}function ft(t,e,n,s){const i=typeof e=="string"?s??Gs(e,n):void 0;return`Unknown ${t} ${JSON.stringify(e)}${i?`: did you mean "${i}"?`:"."} Known: ${n.join(", ")}`}function Us(t,e){const n=e.step??33,s=e.stiffness??120,i=e.damping??9,r=e.mass??1;let o=t(e.start),a=0;const l=[{time:e.start,value:o}];let c=e.start+n;for(let h=e.start+1;h<=e.end;h++){const d=s*(t(h)-o)-i*a;a+=d/r*.001,o+=a*.001,(h>=c||h===e.end)&&(l.push({time:h,value:o}),c+=n)}return l}function mn(t,e,n=1){if(!(e>0))return 0;const s=t*n/e;return s-Math.floor(s)}function Pa(t){const e=t-Math.floor(t);return 1-Math.abs(e*2-1)}function zb(t,e){const n=Math.max(1,Math.round(e.cycles??1)),s=e.amplitude??1,i=mn(t,e.period,n)+(e.phase??0),r=i-Math.floor(i);switch(e.shape??"sine"){case"triangle":return s*(Pa(r+.25)*2-1);case"square":return r<.5?s:-s;default:return s*Math.sin(r*Math.PI*2)}}function qb(t,e){const n=Math.max(1,Math.round(e.cycles??1)),s=typeof e.easing=="function"?e.easing:Wt(e.easing??"ease-in-out"),i=mn(t,e.period,n)+(e.phase??0);return s(Pa(i))}function jb(t,e){const n=tu(e.seed),s=Math.max(1,Math.round(e.cycles??1)),i=(mn(t,e.period,1)+(e.phase??0))*Math.PI*2,r=s/Math.PI;return eu([Math.cos(i)*r+7.31,Math.sin(i)*r+3.17],n,e.octaves??1)}function Yb(t,e,n){const s=tu(n.seed),i=Math.max(1,Math.round(n.cycles??1)),r=Math.max(1,Math.round(n.cyclesAlong??1)),o=mn(t,n.period,1)*Math.PI*2,a=mn(e,n.periodAlong,1)*Math.PI*2,l=i/Math.PI,c=r/Math.PI;return eu([Math.cos(o)*l+5.13,Math.sin(o)*l+9.47,Math.cos(a)*c+2.71,Math.sin(a)*c+6.29],s,n.octaves??1)}const tu=t=>typeof t=="string"?ne(t):(t??0)>>>0;function eu(t,e,n){const s=Math.max(1,Math.min(6,Math.round(n)));let i=0,r=1,o=0;for(let a=0;a<s;a++){const l=2**a;i+=r*Kb(t.map(c=>c*l),e+a*1013),o+=r,r*=.5}return i/o}function Kb(t,e){const n=t.length,s=t.map(Math.floor),r=t.map((a,l)=>a-s[l]).map(a=>a*a*(3-2*a));let o=0;for(let a=0;a<1<<n;a++){let l=1;const c=[];for(let h=0;h<n;h++){const u=a>>h&1;l*=u?r[h]:1-r[h],c.push(s[h]+u)}l!==0&&(o+=l*Xb(c,e))}return o}function Xb(t,e){let n=(e^2654435769)>>>0;for(const s of t)n=Math.imul(n^(s|0),2246822507)>>>0,n=(n^n>>>13)>>>0,n=Math.imul(n,3266489909)>>>0,n=(n^n>>>16)>>>0;return n/4294967296*2-1}function Gb(t,e={}){if(t.length===0)throw new Error("curve: needs at least one key");const s={id:"curve",target:"curve",property:"value",keyframes:t.map(r=>({time:r.at,value:r.value,easing:r.easing})).sort((r,o)=>r.time-o.time),interpolation:e.interpolation},i=new Xe(s);return r=>i.getValueAtTime(r)}function Ub(t,e){return e*Ks({bpm:t.bpm})}function Vb(t,e){const n=Math.max(1,Math.round(t/Ks(e)));return{beats:n,grid:{...e,bpm:n*6e4/t}}}function Jb(t,e,n={}){const s=Math.max(1e-6,n.attack??.05),i=Math.max(1e-6,n.decay??.4),r=Xs(e,t),o=r-Math.floor(r),a=o<s?o/s:Math.max(0,1-(o-s)/i),l=n.barAccent??0;if(l<=0)return a;const c=Math.max(1,Math.round(e.beatsPerBar??4)),u=(Math.floor(r)%c+c)%c===0;return a*(u?1+l:1)/(1+l)}function Zb(t,e,n={}){const s=n.fps??30,i=Math.max(1,Math.round(e/s)),r=Math.max(1,Math.ceil(t.length/i)),o=new Float32Array(r),a=Math.min(.99,Math.max(0,n.smoothing??.5));let l=0,c=0;for(let h=0;h<r;h++){let u=0;const d=h*i,f=Math.min(t.length,d+i);for(let g=d;g<f;g++)u+=t[g]*t[g];const p=f>d?Math.sqrt(u/(f-d)):0;l=p>l?p:l*a+p*(1-a),o[h]=l,c=Math.max(c,l)}if(n.normalize!==!1&&c>0)for(let h=0;h<r;h++)o[h]/=c;return o}function Qb(t,e,n=30,s){if(t.length===0)return 0;const r=(s?mn(e,s)*s:e)*n/1e3,o=Math.floor(r),a=t[Math.min(t.length-1,Math.max(0,o))],l=t[Math.min(t.length-1,Math.max(0,o+1))];return a+(l-a)*(r-o)}const nu={"16:9":16/9,"2.39:1":2.39,"4:3":4/3,"1:1":1,"9:16":9/16,"4:5":4/5},$a=t=>typeof t=="number"?t:nu[t];function tw(t,e){const n=$a(e),s=t.width/t.height;if(n>=s){const r=t.width/n;return{x:0,y:(t.height-r)/2,width:t.width,height:r}}const i=t.height*n;return{x:(t.width-i)/2,y:0,width:i,height:t.height}}function ew(t,e){const n=$a(t),s=i=>Math.max(2,Math.round(i/2)*2);return"width"in e?{width:s(e.width),height:s(e.width/n)}:{width:s(e.height*n),height:s(e.height)}}function nw(t,e={}){const n=s=>({x:t.x+t.width*(1-s)/2,y:t.y+t.height*(1-s)/2,width:t.width*s,height:t.height*s});return{action:n(e.action??.9),title:n(e.title??.8)}}const Se=t=>Math.round(t*1e3)/1e3;function su(t,e={}){if(t.length===0)return"";const n=e.curviness??1,s=e.closed??!1,i=t.length;let r=`M${Se(t[0].x)} ${Se(t[0].y)}`;if(i===1)return r;const o=l=>s?t[(l%i+i)%i]:t[Math.max(0,Math.min(i-1,l))],a=s?i:i-1;for(let l=0;l<a;l++){const c=o(l-1),h=o(l),u=o(l+1),d=o(l+2);if(n===0){r+=` L${Se(u.x)} ${Se(u.y)}`;continue}const f=n/6,p=h.x+(u.x-c.x)*f,g=h.y+(u.y-c.y)*f,m=u.x-(d.x-h.x)*f,y=u.y-(d.y-h.y)*f;r+=` C${Se(p)} ${Se(g)} ${Se(m)} ${Se(y)} ${Se(u.x)} ${Se(u.y)}`}return s?`${r} Z`:r}const Bt=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function sw(t){const e=(t??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let s=0;s+1<e.length;s+=2)n.push({x:e[s],y:e[s+1]});return n}function cr(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=Bt(e.cx),s=Bt(e.cy),i=t.tag.toLowerCase()==="circle"?Bt(e.r):Bt(e.rx),r=t.tag.toLowerCase()==="circle"?Bt(e.r):Bt(e.ry);return`M${n+i} ${s} A${i} ${r} 0 1 1 ${n-i} ${s} A${i} ${r} 0 1 1 ${n+i} ${s} Z`}case"rect":{const n=Bt(e.x),s=Bt(e.y),i=Bt(e.width),r=Bt(e.height);let o=e.rx!=null?Bt(e.rx):e.ry!=null?Bt(e.ry):0,a=e.ry!=null?Bt(e.ry):o;return o=Math.min(o,i/2),a=Math.min(a,r/2),o===0||a===0?`M${n} ${s} H${n+i} V${s+r} H${n} Z`:`M${n+o} ${s} H${n+i-o} A${o} ${a} 0 0 1 ${n+i} ${s+a} V${s+r-a} A${o} ${a} 0 0 1 ${n+i-o} ${s+r} H${n+o} A${o} ${a} 0 0 1 ${n} ${s+r-a} V${s+a} A${o} ${a} 0 0 1 ${n+o} ${s} Z`}case"line":return`M${Bt(e.x1)} ${Bt(e.y1)} L${Bt(e.x2)} ${Bt(e.y2)}`;case"polyline":case"polygon":{const n=sw(e.points);if(n.length===0)return null;const s=n.map((i,r)=>`${r===0?"M":"L"}${i.x} ${i.y}`).join(" ");return t.tag.toLowerCase()==="polygon"?`${s} Z`:s}default:return null}}function iw(t,e,n){const s=Math.max(2,Math.round(n.samples??32)),i=Math.max(0,n.length),r=n.since!==void 0?Math.max(e-i,n.since):e-i;if(r>=e)return[];const o=n.period,a=[];for(let l=0;l<s;l++){const c=r+(e-r)*l/(s-1),h=o&&o>0&&l<s-1?(c%o+o)%o:c;a.push({at:t(h),time:c,age:i>0?(e-c)/i:0})}return a}const rw=2.5;function iu(t){const e=[],n=[],s=t.length,i=(r,o)=>{for(let a=r+o;a>=0&&a<s;a+=o){const l=(t[a].x-t[r].x)*o,c=(t[a].y-t[r].y)*o,h=Math.hypot(l,c);if(h>1e-9)return[l/h,c/h]}return null};for(let r=0;r<s;r++){const o=t[r],a=i(r,-1),l=i(r,1),c=a??l??[1,0],h=l??a??[1,0];let u=c[0]+h[0],d=c[1]+h[1];const f=Math.hypot(u,d);f<1e-9?(u=c[0],d=c[1]):(u/=f,d/=f);const p=u*c[0]+d*c[1],g=Math.min(rw,1/Math.max(p,1e-6)),m=o.width/2*g;e.push({x:o.x-d*m,y:o.y+u*m}),n.push({x:o.x+d*m,y:o.y-u*m})}return{left:e,right:n}}function ru(t){const e=t.length;if(e<2)return null;const n=t[e-1];for(let s=e-2;s>=0;s--){const i=n.x-t[s].x,r=n.y-t[s].y,o=Math.hypot(i,r);if(o>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(i/o,-r/o)}}return null}const ow={scale:1,turn:0,x:0,y:0};function aw(t={}){return{scale:t.scale??1,turn:t.turn??0,x:t.x??0,y:t.y??0}}function ou(t,e,n){const{ax:s,ay:i}=hr(t,e);return{scale:t,turn:e,x:n.x-(s*n.x-i*n.y),y:n.y-(i*n.x+s*n.y)}}function Ia(t,e){const{ax:n,ay:s}=hr(t.scale,t.turn);return{x:n*e.x-s*e.y+t.x,y:s*e.x+n*e.y+t.y}}function lw(t,e){const n=Ia(e,{x:t.x,y:t.y});return{scale:t.scale*e.scale,turn:t.turn+e.turn,x:n.x,y:n.y}}function cw(t){if(t.scale===0)throw new Error("invertSimilarity: a scale of 0 cannot be undone");const e={scale:1/t.scale,turn:-t.turn,x:0,y:0},n=Ia(e,{x:t.x,y:t.y});return{...e,x:-n.x,y:-n.y}}function au(t){const{ax:e,ay:n}=hr(t.scale,t.turn),s=1-e,i=-n,r=s*s+i*i;return r<1e-18?null:{x:(t.x*s+t.y*i)/r,y:(t.y*s-t.x*i)/r}}function hw(t,e){if(t.scale<=0)throw new Error("powSimilarity: the scale must be positive");const n=Math.pow(t.scale,e),s=t.turn*e,i=au(t);return i?ou(n,s,i):{scale:n,turn:s,x:t.x*e,y:t.y*e}}function uw(t){const{ax:e,ay:n}=hr(t.scale,t.turn);return[e,n,-n,e,t.x,t.y]}const hr=(t,e)=>{const n=e*Math.PI/180;return{ax:t*Math.cos(n),ay:t*Math.sin(n)}};function ur([t,e,n],s={}){const i=s.scale??1,r=s.centre??{x:0,y:0},o=Math.sqrt(3)/2;return{x:r.x+(t-e)*o*i,y:r.y+((t+e)*.5-n)*i}}const Oa=([t,e,n])=>t+e+n;function Ca(t,e={}){const[n,s,i]=t.min,[r,o,a]=t.max,l=d=>ur(d,e),c=[(n+r)/2,(s+o)/2,(i+a)/2],h=Oa(c),u=[{side:"top",depth:h,tag:t.tag,points:[l([n,s,a]),l([r,s,a]),l([r,o,a]),l([n,o,a])]},{side:"left",depth:h,tag:t.tag,points:[l([n,o,i]),l([r,o,i]),l([r,o,a]),l([n,o,a])]},{side:"right",depth:h,tag:t.tag,points:[l([r,s,i]),l([r,o,i]),l([r,o,a]),l([r,s,a])]}];return t.hide?u.filter(d=>!t.hide.includes(d.side)):u}function _a(t,e={}){return t.map(n=>({box:n,depth:Oa([(n.min[0]+n.max[0])/2,(n.min[1]+n.max[1])/2,(n.min[2]+n.max[2])/2])})).sort((n,s)=>n.depth-s.depth).flatMap(({box:n})=>Ca(n,e))}function dw(t={}){const e=t.size??10,s=(t.thickness??2)/2,i=[{tag:0,min:[-s,-s,-s],max:[e-s,s,s]},{tag:1,min:[e-s,-s,-s],max:[e+s,e-s,s]},{tag:2,min:[e-s,e-s,-s],max:[e+s,e+s,e]}],r=t.centre??{x:0,y:0},o=ur([2*e/3,e/3,e/3],{scale:t.scale}),a={centre:{x:r.x-o.x,y:r.y-o.y},scale:t.scale};return{boxes:i,faces:[..._a(i,a),...Ca({...i[0],hide:["right"]},a)]}}function fw(t={}){const e=Math.max(2,Math.round(t.steps??8)),n=t.tread??1.5,s=t.rise??.25,i=t.width??3,r=t.base??1.5,o=Math.max(1,Math.round(e*(n-2*s)/(n+2*s))),a=2*(e+o),l=n*(e-o)/a,c=[{dir:[1,0,0],across:[0,1,0],count:e},{dir:[0,1,0],across:[-1,0,0],count:e},{dir:[-1,0,0],across:[0,-1,0],count:o},{dir:[0,-1,0],across:[1,0,0],count:o}],h=[];let u=[0,0,0],d=0;for(const y of c){for(let v=0;v<y.count;v++){const k=d*l,w=[u[0]+y.dir[0]*v*n,u[1]+y.dir[1]*v*n,0],T=[w[0]+y.dir[0]*n+y.across[0]*i,w[1]+y.dir[1]*n+y.across[1]*i,0];h.push({tag:d,min:[Math.min(w[0],T[0]),Math.min(w[1],T[1]),0],max:[Math.max(w[0],T[0]),Math.max(w[1],T[1]),k+r]}),d++}u=[u[0]+y.dir[0]*y.count*n,u[1]+y.dir[1]*y.count*n,0]}const f=a*l,p=t.centre??{x:0,y:0},g=ur([e*n/2,e*n/2,f/2+r],{scale:t.scale}),m={centre:{x:p.x-g.x,y:p.y-g.y},scale:t.scale};return{boxes:h,faces:_a(h,m),rise:l}}function lu(t,e,n){let s=0;for(const i of t){const r=(e-i.x)**2+(n-i.y)**2;s+=r>1e-9?i.r*i.r/r:1e9}return s}function gw(t,e={}){if(t.length===0)return[];const n=e.threshold??1,s=Math.max(.5,e.cell??4),i=Math.sqrt(1/n)*1.6,r=e.bounds??{x:Math.min(...t.map(f=>f.x-f.r*i)),y:Math.min(...t.map(f=>f.y-f.r*i)),width:Math.max(...t.map(f=>f.x+f.r*i))-Math.min(...t.map(f=>f.x-f.r*i)),height:Math.max(...t.map(f=>f.y+f.r*i))-Math.min(...t.map(f=>f.y-f.r*i))},o=Math.max(2,Math.ceil(r.width/s)+1),a=Math.max(2,Math.ceil(r.height/s)+1),l=new Float64Array(o*a);for(let f=0;f<a;f++)for(let p=0;p<o;p++)l[f*o+p]=lu(t,r.x+p*s,r.y+f*s)-n;const c=(f,p)=>l[p*o+f],h=(f,p,g,m,y,v)=>{const k=g===v?.5:g/(g-v);return{x:f+(m-f)*k,y:p+(y-p)*k}},u=[];for(let f=0;f+1<a;f++)for(let p=0;p+1<o;p++){const g=r.x+p*s,m=r.y+f*s,y=g+s,v=m+s,k=[c(p,f),c(p+1,f),c(p+1,f+1),c(p,f+1)],w=(k[0]>0?1:0)|(k[1]>0?2:0)|(k[2]>0?4:0)|(k[3]>0?8:0);if(w===0||w===15)continue;const T=()=>h(g,m,k[0],y,m,k[1]),A=()=>h(y,m,k[1],y,v,k[2]),M=()=>h(g,v,k[3],y,v,k[2]),x=()=>h(g,m,k[0],g,v,k[3]),S=(k[0]+k[1]+k[2]+k[3])/4>0;switch(w){case 1:case 14:u.push([x(),T()]);break;case 2:case 13:u.push([T(),A()]);break;case 3:case 12:u.push([x(),A()]);break;case 4:case 11:u.push([A(),M()]);break;case 6:case 9:u.push([T(),M()]);break;case 7:case 8:u.push([x(),M()]);break;case 5:S?u.push([x(),M()],[T(),A()]):u.push([x(),T()],[A(),M()]);break;case 10:S?u.push([x(),T()],[A(),M()]):u.push([x(),M()],[T(),A()]);break}}const d=pw(u);return e.smooth===!1?d:d.map(f=>cu(cu(f)))}function pw(t){const e=r=>`${Math.round(r.x*1e3)},${Math.round(r.y*1e3)}`,n=new Map;t.forEach(([r,o],a)=>{for(const l of[r,o]){const c=e(l);n.has(c)||n.set(c,[]),n.get(c).push(a)}});const s=new Array(t.length).fill(!1),i=[];for(let r=0;r<t.length;r++){if(s[r])continue;s[r]=!0;const o=[t[r][0],t[r][1]];let a=t[r][1];for(;;){const l=(n.get(e(a))??[]).find(u=>!s[u]);if(l===void 0)break;s[l]=!0;const[c,h]=t[l];if(a=e(c)===e(a)?h:c,e(a)===e(o[0]))break;o.push(a)}o.length>=3&&i.push(o)}return i}function cu(t){const e=[];for(let n=0;n<t.length;n++){const s=t[n],i=t[(n+1)%t.length];e.push({x:s.x*.75+i.x*.25,y:s.y*.75+i.y*.25},{x:s.x*.25+i.x*.75,y:s.y*.25+i.y*.75})}return e}function mw(t){const e=Math.min(1,Math.max(0,t.progress));if(e<=0)return[];const n=t.width/2,s=n*(.55+.75*e),i=Math.max(t.length*e,s*1.2),r=t.x,o=t.y+i-s,a=Math.max(.1,n*(.35-.3*e)),l=o-Math.sqrt(Math.max(0,s*s-a*a)),c=Math.max(0,l-t.y),h=8,u=[],d=[];for(let v=0;v<=h;v++){const k=v/h,w=a+(n-a)*Math.pow(1-k,1.6+1.4*e);u.push({x:r-w,y:t.y+c*k}),d.push({x:r+w,y:t.y+c*k})}const f=Math.max(8,Math.round(t.segments??12)),p=Math.acos(Math.min(1,a/s)),g=-p,m=Math.PI+p,y=[];for(let v=1;v<f;v++){const k=g+(m-g)*v/f;y.push({x:r+Math.cos(k)*s,y:o+Math.sin(k)*s})}return[...d,...y,...u.reverse()]}function yw(t){const e=Math.min(1,Math.max(0,t.grow??1)),n=e>=1?1:1-Math.pow(1-e,3)+.08*Math.sin(e*Math.PI)*e,s=t.r*Math.max(0,n);if(s<=0)return[];const i=Math.max(12,Math.round(t.segments??48)),r=t.wobble??.05,o=t.time??0,a=t.period?o/t.period:o/2500,l=(a-Math.floor(a))*Math.PI*2,c=t.seed??0,h=[];for(let u=0;u<i;u++){const d=u/i*Math.PI*2,f=1+r*(Math.sin(2*d+l+c)*.6+Math.sin(3*d-2*l+c*1.7)*.4);h.push({x:t.x+Math.cos(d)*s*f,y:t.y+Math.sin(d)*s*f})}return h}function bw(t){const e=t.progress;if(e<=0||e>=1)return[];const n=Math.max(3,Math.round(t.pieces??8)),s=[],i=t.r*(1+1.2*e),r=Math.PI*2/n*.6*(1-e);for(let o=0;o<n;o++){const a=o/n*Math.PI*2+.3,l=[];for(let c=0;c<=4;c++){const h=a-r/2+r*c/4;l.push({x:t.x+Math.cos(h)*i,y:t.y+Math.sin(h)*i})}s.push(l)}return s}function ww(t,e={}){const n=Math.max(.05,1+t);return{sx:e.keep==="volume"?1/Math.sqrt(n):1/n,sy:n}}function kw(t,e,n={x:0,y:0}){return t.map(s=>({x:n.x+(s.x-n.x)*e.sx,y:n.y+(s.y-n.y)*e.sy}))}function Vs(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function se(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function yn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Ie(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Js(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function dr(t){return Math.hypot(t[0],t[1],t[2])}function Zs(t,e){return dr(se(t,e))}function Jt(t){const e=dr(t);return e===0?[0,0,0]:yn(t,1/e)}function bn(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n,t[2]+(e[2]-t[2])*n]}const vw=Object.freeze(Object.defineProperty({__proto__:null,add:Vs,cross:Js,distance:Zs,dot:Ie,length:dr,lerp:bn,normalize:Jt,scale:yn,subtract:se},Symbol.toStringTag,{value:"Module"})),Mw=Math.PI/180;function fr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Rt(t,e){const n=new Array(16);for(let s=0;s<4;s++)for(let i=0;i<4;i++){let r=0;for(let o=0;o<4;o++)r+=t[o*4+i]*e[s*4+o];n[s*4+i]=r}return n}function wn(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t[0],t[1],t[2],1]}function kn(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function me(t){const[e,n,s,i]=t;return[1-2*(n*n+s*s),2*(e*n+s*i),2*(e*s-n*i),0,2*(e*n-s*i),1-2*(e*e+s*s),2*(n*s+e*i),0,2*(e*s+n*i),2*(n*s-e*i),1-2*(e*e+n*n),0,0,0,0,1]}function Ha(t,e,n){const s=me(e);for(let i=0;i<3;i++)s[i]*=n[0],s[4+i]*=n[1],s[8+i]*=n[2];return s[12]=t[0],s[13]=t[1],s[14]=t[2],s}function Sw(t){const e=new Array(16);for(let n=0;n<4;n++)for(let s=0;s<4;s++)e[s*4+n]=t[n*4+s];return e}function Ra(t){const[e,n,s,i,r,o,a,l,c,h,u,d,f,p,g,m]=t,y=e*o-n*r,v=e*a-s*r,k=e*l-i*r,w=n*a-s*o,T=n*l-i*o,A=s*l-i*a,M=c*p-h*f,x=c*g-u*f,S=c*m-d*f,E=h*g-u*p,P=h*m-d*p,I=u*m-d*g,O=y*I-v*P+k*E+w*S-T*x+A*M;if(Math.abs(O)<1e-12)return null;const H=1/O;return[(o*I-a*P+l*E)*H,(s*P-n*I-i*E)*H,(p*A-g*T+m*w)*H,(u*T-h*A-d*w)*H,(a*S-r*I-l*x)*H,(e*I-s*S+i*x)*H,(g*k-f*A-m*v)*H,(c*A-u*k+d*v)*H,(r*P-o*S+l*M)*H,(n*S-e*P-i*M)*H,(f*T-p*k+m*y)*H,(h*k-c*T-d*y)*H,(o*x-r*E-a*M)*H,(e*E-n*x+s*M)*H,(p*v-f*w-g*y)*H,(c*w-h*v+u*y)*H]}function xw(t,e,n,s){const i=1/Math.tan(t*Mw/2),r=1/(n-s);return[i/e,0,0,0,0,i,0,0,0,0,(s+n)*r,-1,0,0,2*s*n*r,0]}function Tw(t,e,n,s,i,r){const o=1/(e-t),a=1/(s-n),l=1/(r-i);return[2*o,0,0,0,0,2*a,0,0,0,0,-2*l,0,-(e+t)*o,-(s+n)*a,-(r+i)*l,1]}function Ew(t,e,n=[0,1,0]){const s=Jt(se(t,e)),i=Jt(Js(n,s)),r=Js(s,i);return[i[0],r[0],s[0],0,i[1],r[1],s[1],0,i[2],r[2],s[2],0,-Ie(i,t),-Ie(r,t),-Ie(s,t),1]}function ie(t,e){const n=t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12],s=t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13],i=t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14],r=t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15];return r===1||r===0?[n,s,i]:[n/r,s/r,i/r]}const Aw=Object.freeze(Object.defineProperty({__proto__:null,compose:Ha,fromQuat:me,identity:fr,invert:Ra,lookAt:Ew,multiply:Rt,orthographic:Tw,perspective:xw,scaling:kn,transformPoint:ie,translation:wn,transpose:Sw},Symbol.toStringTag,{value:"Module"})),gr={"power1.in":[.55,.085,.68,.53],"power1.out":[.25,.46,.45,.94],"power1.inout":[.455,.03,.515,.955],"power2.in":[.55,.055,.675,.19],"power2.out":[.215,.61,.355,1],"power2.inout":[.645,.045,.355,1],"power3.in":[.895,.03,.685,.22],"power3.out":[.165,.84,.44,1],"power3.inout":[.77,0,.175,1],"power4.in":[.755,.05,.855,.06],"power4.out":[.23,1,.32,1],"power4.inout":[.86,0,.07,1],"sine.in":[.47,0,.745,.715],"sine.out":[.39,.575,.565,1],"sine.inout":[.445,.05,.55,.95],"expo.in":[.95,.05,.795,.035],"expo.out":[.19,1,.22,1],"expo.inout":[1,0,0,1],"circ.in":[.6,.04,.98,.335],"circ.out":[.075,.82,.165,1],"circ.inout":[.785,.135,.15,.86],"back.in":[.6,-.28,.735,.045],"back.out":[.175,.885,.32,1.275],"back.inout":[.68,-.55,.265,1.55]},hu={none:"linear",linear:"linear","linear.none":"linear","power1.in":"ease-in-quad","power1.out":"ease-out-quad","power1.inout":"ease-in-out-quad","power2.in":"ease-in-cubic","power2.out":"ease-out-cubic","power2.inout":"ease-in-out-cubic"};function Pw(t){let e=t.trim().toLowerCase();e=e.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(e);return n&&n[1]!=="steps"&&e!=="none"&&e!=="linear"&&(e=`${n[1]}.out${n[2]??""}`),e}Wt({type:"bounce",mode:"in"}),Wt({type:"bounce",mode:"in-out"});function Qs(t){const e=uu.get(t.trim().toLowerCase());if(e)return e;const n=Pw(t),s=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(s){const o={type:"steps",count:Math.max(1,Number.parseInt(s[1],10))+1,position:"none"};return{easing:o,fn:Wt(o)}}const i=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(i){const[,r,o,a]=i,l=(a??"").split(",").map(u=>Number.parseFloat(u)).filter(u=>Number.isFinite(u)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in gr)return{easing:{type:"cubic-bezier",points:gr[n]}};const h=r==="elastic"?{type:"elastic",mode:c,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:r==="bounce"?{type:"bounce",mode:c}:{type:"back",mode:c,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:h,fn:Wt(h)}}return n in hu?{easing:hu[n]}:n in gr?{easing:{type:"cubic-bezier",points:gr[n]}}:{easing:"ease-out"}}const uu=new Map;function La(t,e){return uu.set(t.trim().toLowerCase(),e.bezier?{easing:{type:"cubic-bezier",points:e.bezier},fn:e.fn}:{fn:e.fn,requiresBaking:"custom"}),t}function Fa(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const du=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function fu(t){return typeof t=="string"&&du.test(t)}function $w(t=1){let e=Fa(t);const n=(l,c)=>((...h)=>h.length>=l?c(...h):u=>c(...h,u)),s=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),i=(l,c,h,u,d)=>c===l?h:h+(d-l)/(c-l)*(u-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return gu(l,c,1/0);if("values"in l)return gu(l.values,c,l.radius??1/0);const h=Math.round(c/l.increment)*l.increment;return Math.abs(h-c)<=(l.radius??1/0)?h:c},o=(l,c,h)=>{const u=l+e()*(c-l);return h?Math.round(u/h)*h:u};return{clamp:n(3,s),mapRange:n(5,i),normalize:n(3,(l,c,h)=>i(l,c,0,1,h)),interpolate:n(3,(l,c,h)=>{if(typeof l=="object"&&!Array.isArray(l)){const u={};for(const d of Object.keys(l))u[d]=Ys(l[d])(l[d],c[d],h);return u}return Ys(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const g=l,m=y=>g[(Math.round(y)%g.length+g.length)%g.length];return c===void 0?m:m(c)}const u=l,f=c-u,p=g=>f===0?u:((g-u)%f+f)%f+u;return h===void 0?p:p(h)}),wrapYoyo:n(3,(l,c,h)=>{const u=c-l;if(u===0)return l;const d=((h-l)%(u*2)+u*2)%(u*2);return l+(d>u?u*2-d:d)}),snap:n(2,r),random:((l,c,h,u)=>{if(Array.isArray(l)){const f=()=>l[Math.floor(e()*l.length)];return c===!0?f:f()}const d=()=>o(l,c,h);return u?d:d()}),shuffle:l=>{for(let c=l.length-1;c>0;c--){const h=Math.floor(e()*(c+1));[l[c],l[h]]=[l[h],l[c]]}return l},distribute:({base:l=0,amount:c,each:h,from:u="start",ease:d})=>(f,p,g)=>{const m=g.length,v=Zi(f,m,{...c!==void 0?{amount:c}:{each:h??1},from:u}),k=c!==void 0?c:(h??1)*ia(m,u),w=d&&k>0?d(v/k)*k:v;return l+w},pipe:(...l)=>c=>l.reduce((h,u)=>u(h),c),splitColor:l=>Iw(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{e=Fa(l)},resolveRandomString:l=>{const c=du.exec(l)?.[1]??"";if(c.startsWith("[")){const p=c.slice(1,-1).split(",").map(g=>g.trim()).filter(Boolean).map(g=>Number.isFinite(Number(g))?Number(g):g.replace(/^['"]|['"]$/g,""));return p[Math.floor(e()*p.length)]}const[h,u,d]=c.split(",").map(f=>Number.parseFloat(f));return o(h,u,Number.isFinite(d)?d:void 0)}}}function gu(t,e,n){let s=e,i=1/0;for(const r of t){const o=Math.abs(r-e);o<i&&(i=o,s=r)}return i<=n?s:e}function Iw(t){const e=t.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(e)?.[1];if(n){const r=(n.length<=4?[...n].map(o=>o+o).join(""):n).match(/../g).map(o=>Number.parseInt(o,16));return r.length>=4?[r[0],r[1],r[2],Math.round(r[3]/255*1e3)/1e3]:[r[0],r[1],r[2]]}const s=(/rgba?\(([^)]+)\)/i.exec(e)?.[1]??"0,0,0").split(/[\s,/]+/).filter(Boolean).map(i=>Number.parseFloat(i));return s.length>=4?[s[0],s[1],s[2],s[3]]:[s[0]??0,s[1]??0,s[2]??0]}const Ow=/^([+-])=\s*(-?[\d.]+)$/,Cw=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function ti(t,e){const n=e.scale??1,s=c=>Number.parseFloat(c)*n;if(t===void 0)return e.cursor;if(typeof t=="number")return t*n;const i=t.trim();if(i==="")return e.cursor;const r=Ow.exec(i);if(r){const c=s(r[2]);return e.cursor+(r[1]==="-"?-c:c)}const o=Cw.exec(i);if(o){const c=o[1]==="<"?e.previousStart:e.previousEnd;if(o[3]===void 0)return c;const h=s(o[3]);return c+(o[2]==="-"?-h:h)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(i);if(a){const c=e.labels.get(a[1].trim());if(c!==void 0){const h=s(a[3]);return c+(a[2]==="-"?-h:h)}}const l=e.labels.get(i);return l!==void 0?l:/^-?[\d.]+$/.test(i)?s(i):e.cursor}function _w(t){if(typeof t!="object"||t===null)return!1;const e=t;return e.grid!==void 0||e.from==="random"||Array.isArray(e.from)||e.ease!==void 0||e.axis!==void 0}function Hw(t,e,n={}){if(t===0)return[];const s=e.grid==="auto"?Math.max(1,Math.min(t,n.columnsFromLayout?.()??t)):Array.isArray(e.grid)?Math.max(1,e.grid[1]):t,i=Array.isArray(e.grid)?Math.max(1,e.grid[0]):Math.ceil(t/s),r=p=>({x:p%s,y:Math.floor(p/s)}),o=e.from??"start",a=Array.isArray(o)?{x:o[0]*(s-1),y:o[1]*(i-1)}:typeof o=="number"?r(Math.max(0,Math.min(t-1,o))):o==="end"?r(t-1):o==="center"||o==="edges"?{x:(s-1)/2,y:(i-1)/2}:{x:0,y:0},l=p=>{const{x:g,y:m}=r(p),y=Math.abs(g-a.x),v=Math.abs(m-a.y);return e.axis==="x"?y:e.axis==="y"?v:Math.hypot(y,v)};let c=Array.from({length:t},(p,g)=>l(g));const h=Math.max(...c);if(o==="edges"&&(c=c.map(p=>h-p)),o==="random"){const p=n.random??Math.random;c=c.map(()=>p()*h)}const u=e.amount!==void 0?e.amount:(e.each??0)*h,d=e.ease?Qs(e.ease):void 0,f=d?d.fn??Wt(d.easing):void 0;return c.map(p=>{const g=h===0?0:p/h;return(f?f(g):g)*u})}const Na=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),Rw={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function pr(t){const e={},n={};for(const[s,i]of Object.entries(t))Na.has(s)?e[s]=i:n[Rw[s]??s]=i;return{config:e,properties:n}}function mr(t,e){return t===void 0?e:t*1e3}function Wa(t,e){if(t!==void 0)return typeof t=="number"?{each:t*1e3}:_w(t)?{offsets:Hw(e?.count??0,t,e??{}).map(s=>s*1e3)}:{...t.each!==void 0&&{each:t.each*1e3},...t.amount!==void 0&&{amount:t.amount*1e3},...t.from!==void 0&&{from:t.from}}}const Lw={opacity:1,x:0,y:0,z:0,rotate:0,rotateX:0,rotateY:0,rotateZ:0,scale:1,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0,originX:50,originY:50,perspective:0,blur:0,glow:0,clipTop:0,clipRight:0,clipBottom:0,clipLeft:0};function pu(t){return Lw[t]}function Fw(t){const e=typeof t=="string"||Array.isArray(t)?{path:t}:t;if(!e||typeof e.path!="string"&&!Array.isArray(e.path))throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");let n;if(Array.isArray(e.path))n=su(e.path,{curviness:e.curviness});else if(jn(e.path))n=e.path;else throw new Error(`gsap-compat: motionPath "${e.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);const s={pathData:n};return e.autoRotate!==void 0&&e.autoRotate!==!1&&(s.autoRotate=!0,typeof e.autoRotate=="number"&&(s.rotateOffset=e.autoRotate)),e.matrix&&(s.matrix=e.matrix),{config:s,start:e.start??0,end:e.end??1}}function Nw(t){const e=typeof t=="string"||Array.isArray(t)?{path:t}:{...t};return{...e,start:e.end??1,end:e.start??0}}function mu(t){return typeof t=="object"&&t!==null&&"shape"in t?t.shape:t}function Ww(t){if(t.morphSVG===void 0)return t;const{morphSVG:e,...n}=t,s=mu(e);if(typeof s!="string"||!jn(s))throw new Error(`gsap-compat: morphSVG "${String(s)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);return{...n,d:s}}function Dw(t,e){if(t===!0)return[0,e];if(t===!1)return[0,0];if(typeof t=="number")return[0,yu(t,e)];const n=t.trim().split(/[\s,]+/).filter(Boolean),s=o=>{const a=Number.parseFloat(o);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${t}" is not a length or percentage`);return yu(o.endsWith("%")?e*a/100:a,e)};if(n.length===0)return[0,e];if(n.length===1)return[0,s(n[0])];const i=s(n[0]),r=s(n[1]);return i<=r?[i,r]:[r,i]}function Bw(t,e){const[n,s]=Dw(t,e);return{strokeDasharray:[s-n,e],strokeDashoffset:-n}}function zw(t,e){if(t.drawSVG===void 0)return t;const{drawSVG:n,...s}=t;return{...s,...Bw(n,e)}}function qw(t){if(t.drawSVG!==void 0)throw new Error("gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties).");return t}function yu(t,e){return Math.max(0,Math.min(e,t))}function jw(t){let e=2166136261;for(let n=0;n<t.length;n++)e=Math.imul(e^t.charCodeAt(n),16777619);return e>>>0}function Yw(t,e,n){if(t.scrambleText!==void 0){const s=t.scrambleText,i=typeof s=="string"?{text:s}:s;if(typeof i?.text!="string")throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");const r=i.revealDelay&&n>0?i.revealDelay*1e3/n:void 0;return{to:i.text,mode:"scramble",...i.chars!==void 0&&{chars:i.chars},...i.speed!==void 0&&{refreshRate:20*i.speed},...r!==void 0&&{revealDelay:Math.min(r,.999)},...i.tweenLength!==void 0&&{tweenLength:i.tweenLength},...i.rightToLeft!==void 0&&{rightToLeft:i.rightToLeft},seed:i.seed??jw(`${e}|${i.text}`)}}if(t.text!==void 0){const s=t.text,i=typeof s=="string"?{value:s}:s;if(typeof i?.value!="string")throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");return{to:i.value,mode:"type",...i.rightToLeft!==void 0&&{rightToLeft:i.rightToLeft}}}}function Da(t){return Math.max(.1,t/25)}function Kw(t,e){const n=typeof e=="number"?{velocity:e}:e;if(typeof n?.velocity!="number"||!Number.isFinite(n.velocity))throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");const s=n.friction??(n.resistance!==void 0?Da(n.resistance):void 0),i={from:t,velocity:n.velocity,...s!==void 0&&{friction:s},...n.min!==void 0&&{min:n.min},...n.max!==void 0&&{max:n.max}};return typeof n.end=="function"?i.end=[n.end(Ds(i))]:n.end!==void 0&&(i.end=Array.isArray(n.end)?[...n.end]:n.end),i}function Xw(t){const e=t===!0?{}:typeof t=="string"?{preset:t}:t;if(e.preset!==void 0&&!(e.preset in er))throw new Error(`gsap-compat: unknown spring preset "${e.preset}" — use one of ${Object.keys(er).join(", ")}`);return{...e.preset?er[e.preset]:{},...e.stiffness!==void 0&&{stiffness:e.stiffness},...e.damping!==void 0&&{damping:e.damping},...e.mass!==void 0&&{mass:e.mass},...e.restDelta!==void 0&&{restDelta:e.restDelta}}}function Gw(t,e){if(t===!0||typeof t=="string")return;const n=t.velocity;return typeof n=="number"?n:n?.[e]}class vn{timeline;options;cursor=0;fallbackRandom=Fa(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(e={}){this.options=e,this.timeline=new Ht({id:e.id??"gsap-compat",name:e.name,config:{...e.repeat!==void 0&&{loop:e.repeat},...e.yoyo!==void 0&&{alternate:e.yoyo},...e.repeatDelay!==void 0&&{repeatDelay:e.repeatDelay*1e3},...e.timeScale!==void 0&&{speed:e.timeScale}}})}to(e,n,s){return this.build(e,void 0,ei(n),s)}from(e,n,s){const{config:i,properties:r}=pr(ei(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(e)[0],u={...i};for(const p of Object.keys(c))u[p]=this.resolveStart(h,p);o!==void 0&&(u.motionPath=Nw(o));const d={},f=String(this.resolveStart(h,"text"));return a!==void 0&&(d.text=Ba(a),u.text=typeof a=="object"?{...a,value:f}:f),l!==void 0&&(d.text=Ba(l),u.scrambleText=typeof l=="object"?{...l,text:f}:f),this.build(e,{...c,...d},u,s)}fromTo(e,n,s,i){const{properties:r}=pr(ei(n));return this.build(e,r,ei(s),i)}set(e,n,s){return this.build(e,void 0,{...ei(n),duration:0},s)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(e){const n=Math.max(0,ti(e,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(e){return ti(e,this.context())}addLabel(e,n){return this.labels.set(e,ti(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((e,n)=>e-n)}labelTime(e){return this.labels.get(e)}add(e,n){const s=ti(n,this.context());for(const r of e.timeline.tracks){if(!("keyframes"in r))continue;const o=ar({...r,id:this.nextTrackId(`nested-${r.id}`),keyframes:r.keyframes.map(a=>({...a,time:a.time+s}))});this.timeline.addTrack(o)}const i=s+e.timeline.duration;return this.previousStart=s,this.previousEnd=i,this.cursor=Math.max(this.cursor,i),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.stop(),this.timeline.play(),this}reverse(){return this.timeline.reverse(),this}kill(){return this.timeline.removeTracks(),this}reset(){return this.timeline.removeTracks(),this.cursor=0,this.previousStart=0,this.previousEnd=0,this.labels.clear(),this.lastValues.clear(),this.trackCounter=0,this}seek(e){if(typeof e=="string"){const n=this.labels.get(e);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(e*1e3),this}progress(e){const n=this.timeline.duration;return e!==void 0&&n>0&&this.timeline.seek(e*n),n>0?this.timeline.currentTime/n:0}timeScale(e){return e!==void 0&&(this.timeline.speed=e),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(e){return this.timeline.tick(e),this}toDefinition(){return this.timeline.toDefinition()}build(e,n,s,i){const{config:r,properties:o}=pr(s),{motionPath:a,text:l,scrambleText:c,inertia:h,...u}=o,d=this.targetsOf(e),f=ti(i,this.context()),p=mr(r.delay,0),g=mr(r.duration,500),m=Wa(r.stagger,{count:d.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(d):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),v=[],k=r.spring;let w=0,T=!1;for(const[P,I]of Object.entries(u)){const O=I;let H=n?.[P]!==void 0?n[P]:this.resolveStart(d[0],P);if(typeof H!=typeof O&&(this.warn(`no usable start value for "${P}" on "${d[0]}" — it will snap to ${String(O)}. Use fromTo() to animate it.`),H=O),k!==void 0&&(typeof H!="number"||typeof O!="number")&&this.warn(`spring works on numbers, so "${P}" on "${d[0]}" eases instead`),k!==void 0&&typeof H=="number"&&typeof O=="number"){const J={...Xw(k),from:H,to:O,velocity:Gw(k,P)??this.options.startVelocity?.(d[0],P)??0},et=this.nextTrackId(`${d[0]}-${P}-spring`),V={id:et,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:P,kind:"spring",spring:J,delay:f+p};this.timeline.addTrack(V),v.push(et),w=Math.max(w,Vh(J));for(const L of d)this.lastValues.set(`${L}|${P}`,O);continue}T=!0;const W=this.keyframesFor(H,O,g,y,r.ease),j=this.nextTrackId(`${d[0]}-${P}`);this.timeline.addTrack(ar({id:j,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:P,delay:f+p,keyframes:W,...P==="quaternion"&&{interpolation:"slerp"}})),v.push(j);for(const J of d)this.lastValues.set(`${J}|${P}`,O)}const A=Yw({text:l,scrambleText:c},d[0],g);if(A){const P=n?.text??n?.scrambleText,I=P!==void 0?Ba(P):this.resolveStart(d[0],"text"),O=this.nextTrackId(`${d[0]}-text`),H={id:O,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:"text",textConfig:{from:typeof I=="string"?I:String(I??""),...A},delay:f+p,keyframes:this.keyframesFor(0,1,g,y,r.ease)};this.timeline.addTrack(H),v.push(O);for(const W of d)this.lastValues.set(`${W}|text`,A.to)}if(a!==void 0){const{config:P,start:I,end:O}=Fw(a),H=this.nextTrackId(`${d[0]}-motionPath`),W={id:H,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:"motionPath",motionPathConfig:P,delay:f+p,keyframes:this.keyframesFor(I,O,g,y,r.ease)};this.timeline.addTrack(W),v.push(H)}if(h!==void 0)for(const[P,I]of Object.entries(h)){const O=this.resolveStart(d[0],P);if(typeof O!="number"){this.warn(`inertia on "${P}" needs a numeric start value; skipped`);continue}const H=Kw(O,I),W=this.nextTrackId(`${d[0]}-${P}-inertia`),j={id:W,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:P,kind:"inertia",inertia:H,delay:f+p};this.timeline.addTrack(j),v.push(W),w=Math.max(w,zn(H));for(const J of d)this.lastValues.set(`${J}|${P}`,Bn(H))}const S=((h!==void 0||k!==void 0)&&!T&&!A&&a===void 0?w:Math.max(g,w))+(m&&d.length>1?Ns(d.length,m):0),E=f+p+S;return this.previousStart=f+p,this.previousEnd=E,this.cursor=Math.max(this.cursor,E),{trackIds:v,start:f+p,end:E,kill:()=>{for(const P of v)this.timeline.removeTrack(P)}}}keyframesFor(e,n,s,i,r){const o={time:0,value:e};if(s<=0)return[{time:0,value:n}];const a=typeof r=="string"?Qs(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&Fs(i)){const c=a?.fn??Wt(i);return[o,...va(o,{time:s,value:n},c,{intervalMs:this.options.bakeIntervalMs})]}return[o,{time:s,value:n,...i&&{easing:i}}]}resolveStart(e,n){const s=this.lastValues.get(`${e}|${n}`);if(s!==void 0)return s;const i=this.options.startValue?.(e,n);if(i!==void 0)return i;const r=this.options.defaults?.[n];if(r!==void 0)return r;if(n==="text")return"";if(n==="quaternion")return[0,0,0,1];if(n==="d")throw new Error(`gsap-compat: no starting shape for "${e}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const o=pu(n);return o!==void 0?(this.warn(`no start value for "${n}" on "${e}" — using the static default ${o}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),o):(this.warn(`no start value or default for "${n}" on "${e}" — using 0`),0)}easingFor(e){if(e!==void 0){if(typeof e=="string")return Qs(e).easing;if(typeof e=="function")throw new Error('gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.');return e}}targetsOf(e){return Array.isArray(e)?e:[e]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(e){return this.trackCounter+=1,`${e}-${this.trackCounter}`}warn(e){this.options.onWarning?.(`gsap-compat: ${e}`)}}function Ba(t){if(typeof t=="string")return t;if(t&&typeof t=="object"){const e=t;return String(e.value??e.text??"")}return String(t??"")}function Uw(t){return new vn(t)}function ei(t){return qw(Ww(t))}function Vw(t){return!Array.isArray(t)||t.length!==4?null:`matrix3d(${me(Ye(t)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const Jw=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Zw="#ffffff",Qw="rgba(0, 0, 0, 0.5)";function t2(t){const e=[];if(t.blur!==void 0&&e.push(`blur(${Math.max(0,t.blur)}px)`),t.brightness!==void 0&&e.push(`brightness(${Math.max(0,t.brightness)})`),t.glow!==void 0&&e.push(`drop-shadow(0 0 ${Math.max(0,t.glow)}px ${t.glowColor??Zw})`),t.shadowX!==void 0||t.shadowY!==void 0||t.shadowBlur!==void 0){const n=t.shadowX??0,s=t.shadowY??0,i=Math.max(0,t.shadowBlur??0);e.push(`drop-shadow(${n}px ${s}px ${i}px ${t.shadowColor??Qw})`)}return e.length>0?e.join(" "):null}function e2(t,e){const n=t.childNodes.length===1?t.firstChild:null;if(n&&n.nodeType===3){const s=n;s.data!==e&&(s.data=e);return}t.textContent!==e&&(t.textContent=e)}function n2(t){if(!("ownerSVGElement"in t))return;const e=t.style;!e||e.transformBox||(e.transformBox="fill-box",e.transformOrigin||(e.transformOrigin="50% 50%"))}const bu=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),s2=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),i2=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],r2=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),o2=new Set(["originX","originY"]),a2=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),l2=new Set(["drawOn"]),c2={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},wu={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},h2="http://www.w3.org/2000/svg";class Mn{targets=new Map;registerTarget(e,n){this.targets.set(e,n)}unregisterTarget(e){this.targets.delete(e)}getTarget(e){return this.targets.get(e)}clearTargets(){this.targets.clear()}applyState(e){for(const[n,s]of e.values){const i=this.targets.get(n);i&&this.applyProperties(i,s)}}applyProperties(e,n){let s=null,i=null,r=null,o=null,a=null;const l=n.has("motionPathX"),c=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[p,g]of n)if(!(p==="x"&&l)&&!(p==="y"&&c)&&!((p==="rotate"||p==="rotateZ")&&h)&&!l2.has(p)){if(s2.has(p))(s??={})[p]=g;else if(r2.has(p))typeof g=="number"&&((i??={})[p]=g);else if(o2.has(p))typeof g=="number"&&((r??={})[p]=g);else if(a2.has(p))typeof g=="number"&&((o??={})[p]=g);else if(Jw.has(p))(a??={})[p]=g;else if(p!=="perspective"){if(p!=="shine")if(p==="text"&&typeof g=="string")e2(e,g);else if(p==="d"&&typeof g=="string"){const m=e;(m.tagName?.toLowerCase()==="path"?m:m.querySelector?.("path"))?.setAttribute?.("d",g)}else this.applyStyleProperty(e,p,g)}}const u=n.get("shine");typeof u=="number"&&this.applyShine(e,u);const d=[],f=n.get("perspective");if(typeof f=="number"&&f>0&&d.push(`perspective(${f}px)`),s)for(const p of i2){const g=s[p];if(g===void 0)continue;const m=this.buildTransformPart(p,g);m&&d.push(m)}if(d.length>0&&(e.style.transform=d.join(" "),n2(e)),i&&(i.childPerspective!==void 0&&(e.style.perspective=`${i.childPerspective}px`),(i.perspectiveOriginX!==void 0||i.perspectiveOriginY!==void 0)&&(e.style.perspectiveOrigin=`${i.perspectiveOriginX??50}% ${i.perspectiveOriginY??50}%`)),r){const p=r.originX??50,g=r.originY??50;e.style.transformOrigin=`${p}% ${g}%`}if(o){const p=o.clipTop??0,g=o.clipRight??0,m=o.clipBottom??0,y=o.clipLeft??0;e.style.clipPath=`inset(${p}% ${g}% ${m}% ${y}%)`}if(a){const p=t2(a);p&&(e.style.filter=p)}}buildTransformPart(e,n){if(e==="quaternion")return Vw(n);if(typeof n!="number")return null;switch(e){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(e,n){e.dataset.shineBase||(e.dataset.shineBase=e.style.color||"currentColor");const s=e.dataset.shineBase,i=-20+n*140,r=e.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${s}, ${s})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${i}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(e,n,s){let i;if(e.namespaceURI===h2&&n in wu){const a=Array.isArray(s)?s.join(", "):String(s);e.style[wu[n]]=a;return}else n==="fill"&&e.dataset?.elementType==="text"?i="color":i=c2[n]??n;let o;typeof s=="number"?bu.has(n)||bu.has(i)?o=`${s}px`:o=String(s):Array.isArray(s)?o=s.join(", "):o=s,e.style[i]=o}}const u2={request:t=>requestAnimationFrame(t),cancel:t=>cancelAnimationFrame(t)};class ku{adapter=new Mn;scheduler;rootOption;onWarning;names=new WeakMap;elements=new Map;nameCounter=0;objectNames=new WeakMap;objects=new Map;owned=new Set;currentCollector;tickerCallbacks=new Set;tickerTime=0;tickerFrame=0;liveTimelines=new Set;utils=$w();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(e={}){this.scheduler=e.scheduler??u2,this.rootOption=e.root,this.onWarning=e.onWarning}get root(){return this.rootOption??document}resolveTargets(e){const n=[];for(const s of this.targetsOf(e)){const i=this.nameFor(s);za(s)&&this.currentCollector?.touch(s,i),n.push(i)}return n}query(e){return this.selectorRoot.querySelector(e)}get collector(){return this.currentCollector}setCollector(e){this.currentCollector=e}forget(e){this.applied.delete(e),this.dirty.delete(e)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(e){return this.elements.get(e)}objectFor(e){return this.objects.get(e)}appliedValue(e,n){return this.applied.get(e)?.get(n)}velocityOf(e,n){for(const i of[...this.active.keys()].reverse()){if(i.getTracks({target:e,property:n}).length===0)continue;const r=i.currentTime;if(r<4)return 0;const o=i.getStateAtTime(r).values.get(e)?.get(n),a=i.getStateAtTime(r-4).values.get(e)?.get(n);if(typeof o!="number"||typeof a!="number")return;const l=(o-a)/4;return(i.direction==="reverse"?-l:l)*1e3}}ticker={add:e=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(e),this.currentCollector?.track({revert:()=>this.ticker.remove(e)}),this.startLoop())},remove:e=>{this.tickerCallbacks.delete(e),this.running||this.stopLoop()}};activate(e,n={}){this.destroyed||(e.onUpdate=s=>this.write(s),this.active.delete(e),this.active.set(e,n),this.startLoop())}deactivate(e){this.active.delete(e),this.running||this.stopLoop()}own(e){return this.destroyed?e.destroy():this.owned.add(e),e}destroy(){this.destroyed=!0;for(const e of this.owned)e.destroy();this.owned.clear();for(const e of this.active.keys())e.stop();this.active.clear(),this.stopLoop(),this.adapter.clearTargets(),this.elements.clear(),this.names=new WeakMap,this.objects.clear(),this.objectNames=new WeakMap,this.tickerCallbacks.clear(),this.liveTimelines.clear(),this.applied.clear(),this.dirty.clear()}apply(e,n){if(this.destroyed)return;const s=new Map(Object.entries(n));this.write({values:new Map([[e,s]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(e){this.destroyed||(this.write(e.getStateAtTime(e.currentTime)),this.flush())}tick(e){const n=[...this.active];for(const[s]of n)s.duration<=0?(this.write(s.getStateAtTime(0)),s.stop()):s.tick(e);this.flush();for(const[s,i]of n)i.onUpdate?.(),s.playbackState!=="playing"&&this.active.get(s)===i&&this.active.delete(s);this.flush(),this.runTicker(e),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(e){if(this.tickerCallbacks.size!==0){this.tickerTime+=e,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,e,this.tickerFrame)}}write(e){for(const[n,s]of e.values){let i=this.applied.get(n);i||(i=new Map,this.applied.set(n,i));for(const[r,o]of s)i.set(r,o);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const e=new Map;for(const n of this.dirty){const s=this.applied.get(n),i=this.objects.get(n);if(i)for(const[r,o]of s)i[r]=o;else e.set(n,s)}this.dirty.clear(),e.size!==0&&this.adapter.applyState({values:e,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=e=>{this.frameId=null;const n=this.lastTimestamp===null?0:e-this.lastTimestamp;this.lastTimestamp=e,n>0&&this.tick(n),this.running&&this.frameId===null&&(this.frameId=this.scheduler.request(this.frame))};startLoop(){this.frameId===null&&(this.lastTimestamp=null,this.frameId=this.scheduler.request(this.frame))}stopLoop(){this.frameId!==null&&this.scheduler.cancel(this.frameId),this.frameId=null,this.lastTimestamp=null}targetsOf(e){if(typeof e=="string")return Array.from(this.selectorRoot.querySelectorAll(e));if(za(e))return[e];if(!d2(e))return[e];const n=[];for(const s of Array.from(e))n.push(...this.targetsOf(s));return n}nameFor(e){return za(e)?this.elementName(e):this.objectName(e)}objectName(e){const n=this.objectNames.get(e);if(n)return n;let s;do this.nameCounter+=1,s=`obj-${this.nameCounter}`;while(this.objects.has(s)||this.elements.has(s));return this.objectNames.set(e,s),this.objects.set(s,e),s}elementName(e){const n=this.names.get(e);if(n)return n;let s=e.id?`#${e.id}`:"";if(!s||this.elements.has(s))do this.nameCounter+=1,s=`el-${this.nameCounter}`;while(this.elements.has(s));return this.names.set(e,s),this.elements.set(s,e),this.adapter.registerTarget(s,e),s}}function za(t){return typeof t=="object"&&t!==null&&t.nodeType===1}function d2(t){if(Array.isArray(t))return!0;const e=t;return typeof e.length=="number"&&typeof e.item=="function"}function yr(t){const e=t.style;if(!e)return t.getBoundingClientRect();const n=e.transform;e.transform="none";const s=t.getBoundingClientRect();return e.transform=n,s}const vu=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function f2(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function g2(t){const e=t.getScreenCTM?.();if(e)return[e.a,e.b,e.c,e.d,e.e,e.f];const n=t.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function p2(t,e){const n=typeof t=="string"||Array.isArray(t)||vu(t)?{path:t}:t,{align:s,alignOrigin:i,path:r,...o}=n,a=A=>{const M=vu(A)?A:e.query(A);return M||e.warn(`gsap-compat: motionPath could not find "${String(A)}"`),M};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&jn(r))c=r;else{l=a(r);const A=l&&cr({tag:l.localName,attributes:f2(l)});l&&!A&&e.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=A??""}const h={...o,path:c};if(s===void 0||s===!1)return h;const u=s===!0?l:a(s);if(!u)return s===!0&&e.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const d=e.targets[0];if(!d)return h;const[f,p,g,m,y,v]=g2(u),k=yr(d),[w,T]=i??[.5,.5];for(const A of e.targets.slice(1)){const M=yr(A);if(Math.abs(M.left-k.left)>.5||Math.abs(M.top-k.top)>.5){e.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[f,p,g,m,y-k.left-w*k.width,v-k.top-T*k.height],h}const Mu=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function Su(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function xu(t){if(!t)return null;const e=cr({tag:t.localName,attributes:Su(t)});return e||(t.querySelector("path")?.getAttribute("d")??null)}function m2(t,e,n){const s=mu(t);if(typeof s=="string"&&jn(s))return s;const i=Mu(s)?s:typeof s=="string"?e(s):null,r=xu(i);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(s)}"`),"")}const y2=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function b2(t,e=document){return(typeof t=="string"?Array.from(e.querySelectorAll(t)):Mu(t)?[t]:Array.from(t)).map(s=>{if(s.localName==="path")return s;const i=cr({tag:s.localName,attributes:Su(s)});if(!i||!s.parentNode)return s;const r=s.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const o of Array.from(s.attributes))y2.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",i),s.parentNode.replaceChild(r,s),r})}const Tu=.3;class Eu{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(e){this.options=e,this.target=e.target}start(){if(this.running)return;this.running=!0;const e=this.options.type??["pointer","touch"];e.includes("pointer")&&(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerUp)),e.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),e.includes("wheel")&&this.target.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){this.running&&(this.running=!1,this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerUp),this.target.removeEventListener("touchstart",this.onTouchStart),this.target.removeEventListener("touchmove",this.onTouchMove),this.target.removeEventListener("touchend",this.onTouchEnd),this.target.removeEventListener("wheel",this.onWheel))}destroy(){this.stop()}get velocity(){return{x:this.velocityX,y:this.velocityY}}begin(e,n,s){this.dragging=!0,this.passedTolerance=!1,this.startX=e,this.startY=n,this.lastX=e,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=Au(),this.options.onPress?.(this.stateFrom(0,0,s))}move(e,n,s){if(!this.dragging)return;const i=e-this.lastX,r=n-this.lastY;this.lastX=e,this.lastY=n;const o=e-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(o,a)<l)return;this.passedTolerance=!0}this.updateVelocity(i,r),this.options.preventDefault!==!1&&s.cancelable&&s.preventDefault(),this.options.onMove?.(this.stateFrom(i,r,s))}end(e){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,e)))}updateVelocity(e,n){const s=Au(),i=Math.max(1,s-this.lastTime);this.lastTime=s;const r=e/i*1e3,o=n/i*1e3;this.velocityX+=(r-this.velocityX)*Tu,this.velocityY+=(o-this.velocityY)*Tu}stateFrom(e,n,s){return{deltaX:e,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:s}}onPointerDown=e=>{const n=e,s=this.target;if(typeof n.pointerId=="number"&&typeof s.setPointerCapture=="function")try{s.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,e)};onPointerMove=e=>{const n=e;this.move(n.clientX,n.clientY,e)};onPointerUp=e=>this.end(e);onTouchStart=e=>{const n=e.touches[0];n&&this.begin(n.clientX,n.clientY,e)};onTouchMove=e=>{const n=e.touches[0];n&&this.move(n.clientX,n.clientY,e)};onTouchEnd=e=>this.end(e);onWheel=e=>{const n=e;this.options.preventDefault!==!1&&n.cancelable&&n.preventDefault(),this.updateVelocity(n.deltaX,n.deltaY),this.options.onMove?.({deltaX:n.deltaX,deltaY:n.deltaY,velocityX:this.velocityX,velocityY:this.velocityY,totalX:0,totalY:0,isDragging:!1,event:e})}}function Au(){return typeof performance<"u"?performance.now():Date.now()}function Pu(t,e,n){let s={delta:0,line:null},i=n;for(const r of t)for(const o of e){const a=Math.abs(o-r);a<=i&&(i=a,s={delta:o-r,line:o})}return s}function $u(t,e){return e<=0?[]:t.map(n=>Math.round(n/e)*e)}class qa{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(e){this.options=e,this.x=e.initialX??0,this.y=e.initialY??0,this.observer=new Eu({target:e.target,onPress:n=>{const s=e.getPosition?.();s&&(this.x=s.x,this.y=s.y),this.originX=this.x,this.originY=this.y,e.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>e.onRelease?.(n)})}start(){this.observer.start()}stop(){this.observer.stop()}destroy(){this.observer.destroy()}get position(){return{x:this.x,y:this.y}}get velocity(){return this.observer.velocity}setPosition(e,n){const s=this.options.axis??"both";this.x=s==="y"?this.x:this.applyConstraints(e,"x"),this.y=s==="x"?this.y:this.applyConstraints(n,"y")}get snapLines(){return{x:this.snappedX,y:this.snappedY}}snapThreshold(){if(this.options.snapThreshold!==void 0)return this.options.snapThreshold;const e=this.options.snap??0;return e>0?e/2:8}handleMove(e){this.setPosition(this.originX+e.totalX,this.originY+e.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,e),this.options.onSnap?.(this.snapLines)}scrub(){const e=this.options.timeline;if(!e)return;const n=e.duration;if(n<=0)return;const s=this.options.scrubDistance??500;if(s===0)return;const i=(this.options.axis??"both")==="y"?this.y:this.x,r=w2(i/s);e.pause(),e.seek(r*n)}applyConstraints(e,n){let s=e;const i=[...$u([s],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=Pu([s],i,this.snapThreshold());s+=r.delta,n==="x"?this.snappedX=r.line:this.snappedY=r.line;const o=this.options.bounds;if(o){const a=n==="x"?o.minX:o.minY,l=n==="x"?o.maxX:o.maxY;a!==void 0&&(s=Math.max(a,s)),l!==void 0&&(s=Math.min(l,s))}return s}}function w2(t){return t<0?0:t>1?1:t}function k2(t){const e=new qa(t);return e.start(),e}const v2={x:"x",y:"y","x,y":"both"},ja=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function Iu(t,e){const n=yr(t),s=e.getBoundingClientRect();return{minX:s.left-n.left,maxX:s.right-n.right,minY:s.top-n.top,maxY:s.bottom-n.bottom}}function Ou(t){return Array.isArray(t)?[...t]:t}function M2(t,e,n,s={}){const[i]=e.resolveTargets(n),r=i?e.elementFor(i):void 0;if(!i||!r)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(s.type==="rotation")return S2(t,e,i,r,s);const o=v2[s.type??"x,y"],a=()=>{const g=e.appliedValue(i,"x"),m=e.appliedValue(i,"y");return{x:typeof g=="number"?g:0,y:typeof m=="number"?m:0}},l=typeof s.bounds=="string"?e.query(s.bounds):ja(s.bounds)?s.bounds:null,h={bounds:(!l&&s.bounds&&!ja(s.bounds)?s.bounds:void 0)??(l?Iu(r,l):void 0)};let u=null;const d=()=>{u?.kill(),u=null},f=g=>{const m=s.inertia===!0?{}:s.inertia,y=m.friction??(m.resistance!==void 0?Da(m.resistance):4),v=a(),k=h.bounds??{};let w,T;const A=m.end;if(Array.isArray(A)){const x=Ds({from:v.x,velocity:o==="y"?0:g.x,friction:y}),S=Ds({from:v.y,velocity:o==="x"?0:g.y,friction:y});let E=A[0];for(const P of A)Math.hypot(P.x-x,P.y-S)<Math.hypot(E.x-x,E.y-S)&&(E=P);E&&(w=[E.x],T=[E.y])}else typeof A=="number"?(w=A,T=A):A&&(w=Ou(A.x),T=Ou(A.y));const M={};o!=="y"&&(M.x={velocity:g.x,friction:y,min:k.minX,max:k.maxX,end:w}),o!=="x"&&(M.y={velocity:g.y,friction:y,min:k.minY,max:k.maxY,end:T}),u=t.to(r,{inertia:M,onComplete:()=>s.onThrowComplete?.()})},p=new qa({target:r,axis:o,snap:s.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{d(),l&&(h.bounds=Iu(r,l)),s.onPress?.()},onDrag:g=>{e.apply(i,o==="x"?{x:g.x}:o==="y"?{y:g.y}:{x:g.x,y:g.y}),s.onDrag?.(g)},onRelease:()=>{const g=p.velocity;s.onRelease?.(g),s.inertia&&f(g)}});return p.start(),{draggable:p,get position(){return a()},get rotation(){const g=e.appliedValue(i,"rotate");return typeof g=="number"?g:0},destroy(){d(),p.destroy()}}}function S2(t,e,n,s,i){const r=typeof i.bounds=="object"&&i.bounds!==null&&!ja(i.bounds)?i.bounds:{},o=()=>{const k=e.appliedValue(n,"rotate");return typeof k=="number"?k:0},a=k=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,k));let l=null,c=!1,h,u={x:0,y:0},d=0,f=0,p=[];const g=k=>Math.atan2(k.clientY-u.y,k.clientX-u.x)*180/Math.PI,m=k=>{if(c)return;l?.kill(),l=null,c=!0,h=k.pointerId,s.setPointerCapture?.(k.pointerId);const w=s.getBoundingClientRect();u={x:w.left+w.width/2,y:w.top+w.height/2},d=g(k),f=o(),p=[{time:performance.now(),rotation:f}],i.onPress?.()},y=k=>{if(!c||k.pointerId!==h)return;const w=g(k);let T=w-d;T>180&&(T-=360),T<-180&&(T+=360),d=w,f+=T;let A=a(f);i.snap&&(A=a(Math.round(A/i.snap)*i.snap)),e.apply(n,{rotate:A});const M=performance.now();for(p.push({time:M,rotation:A});p.length>2&&M-p[0].time>100;)p.shift();const x={x:0,y:0};i.onDrag?.(x)},v=k=>{if(!c||k.pointerId!==h)return;c=!1;const w=p[0],T=p[p.length-1],A=w&&T?(T.time-w.time)/1e3:0,M=A>0?(T.rotation-w.rotation)/A:0;if(i.onRelease?.({x:M,y:0}),!i.inertia)return;const x=i.inertia===!0?{}:i.inertia,S=x.friction??(x.resistance!==void 0?Da(x.resistance):4),E=typeof x.end=="number"||Array.isArray(x.end)?x.end:void 0;l=t.to(s,{inertia:{rotate:{velocity:M,friction:S,min:r.minRotation,max:r.maxRotation,end:Array.isArray(E)?E.filter(P=>typeof P=="number"):E}},onComplete:()=>i.onThrowComplete?.()})};return s.addEventListener("pointerdown",m),s.addEventListener("pointermove",y),s.addEventListener("pointerup",v),s.addEventListener("pointercancel",v),s.style.touchAction="none",{draggable:void 0,position:{x:0,y:0},get rotation(){return o()},destroy(){l?.kill(),s.removeEventListener("pointerdown",m),s.removeEventListener("pointermove",y),s.removeEventListener("pointerup",v),s.removeEventListener("pointercancel",v)}}}const x2={opacity:0,scale:.6};function T2(t){const e=t.getBoundingClientRect();return e.width===0&&e.height===0?null:{cx:e.left+e.width/2,cy:e.top+e.height/2,width:e.width,height:e.height}}function Cu(t){const e=yr(t);return e.width===0&&e.height===0?null:{cx:e.left+e.width/2,cy:e.top+e.height/2,width:e.width,height:e.height}}function Ya(t,e){const s=t.resolveTargets(e).map(o=>t.elementFor(o)).filter(o=>!!o),i=new Map,r=new Map;for(const o of s){const a=T2(o);i.set(o,a);const l=_u(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:s,boxes:i,ids:r}}const Ka=new WeakMap;function Xa(t,e,n,s={}){const i=s.duration??.6,r=s.ease??"power2.inOut",o=s.stagger??0,a=s.scale!==!1,l=s.enter===void 0?x2:s.enter,c=new Set(n.elements);if(s.targets!==void 0)for(const f of t.resolveTargets(s.targets)){const p=t.elementFor(f);p&&c.add(p)}const h=[...c].sort((f,p)=>f===p?0:f.compareDocumentPosition(p)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),u=e({onComplete:s.onComplete});let d=0;for(const f of h){const p=Cu(f);if(!p)continue;let g=n.boxes.get(f)??null,m;const y=_u(f),v=!g&&y!==void 0?n.ids.get(y):void 0;v&&v.element!==f&&(g=v.box,m=v.element);const[k]=t.resolveTargets(f);Ka.get(f)?.timeline.removeTracks({target:k});const w=d*o;if(!g){if(l===!1)continue;u.fromTo(f,{x:0,y:0,scaleX:1,scaleY:1,...l},{...Hu(l),x:0,y:0,scaleX:1,scaleY:1,duration:i,ease:r,delay:w},0),Ka.set(f,u),d++;continue}const T=g.cx-p.cx,A=g.cy-p.cy,M=a?g.width/p.width:1,x=a?g.height/p.height:1;if(!(Math.abs(T)>.5||Math.abs(A)>.5||Math.abs(M-1)>.001||Math.abs(x-1)>.001)){const P=(I,O)=>{const H=t.appliedValue(k,I);return typeof H=="number"&&Math.abs(H-O)>1e-6};(P("x",0)||P("y",0)||P("scaleX",1)||P("scaleY",1))&&u.set(f,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const E=s.fade===!0&&m!==void 0;u.fromTo(f,{x:T,y:A,scaleX:M,scaleY:x,...E&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...E&&{opacity:1},duration:i,ease:r,delay:w},0),E&&m&&Cu(m)&&u.fromTo(m,{opacity:1},{opacity:0,duration:i,ease:r,delay:w},0),Ka.set(f,u),d++}return u}function _u(t){return t.dataset?.flipId}function Hu(t){const e={};for(const n of Object.keys(t))e[n]=n==="opacity"||n.startsWith("scale")?1:0;return e}function E2(t,e={}){const n=new Set((e.type??"chars,words,lines").split(",").map(g=>g.trim())),s={chars:e.charsClass??"char",words:e.wordsClass??"word",lines:e.linesClass??"line"},i=e.aria!==!1,r=t.map(g=>({element:g,html:g.innerHTML,ariaLabel:g.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:g,html:m,ariaLabel:y}of r)g.innerHTML=m,y===null?g.removeAttribute("aria-label"):g.setAttribute("aria-label",y)},u=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},d=()=>{const g={chars:[],words:[],lines:[],masks:[]};for(const{element:m}of r){const y=(m.textContent??"").replace(/\s+/g," ").trim(),v=A2(m,s.words),k=n.has("chars")?v.flatMap(A=>P2(A,s.chars)):[],w=n.has("lines")?I2(m,v,s.lines):[];if(i){!m.hasAttribute("aria-label")&&y&&m.setAttribute("aria-label",y);for(const A of v)A.setAttribute("aria-hidden","true")}if(n.has("words"))g.words.push(...v);else for(const A of v)A.removeAttribute("class");g.chars.push(...k),g.lines.push(...w);const T=e.mask==="lines"?w:e.mask==="words"?v:e.mask==="chars"?k:[];for(const A of T)g.masks.push(O2(A,`${s[e.mask]}-mask`))}o=g},f={elements:t,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(u(),h(),d(),a=e.onSplit?.(f))},revert(){c=!0,l?.disconnect(),u(),h()}};d(),a=e.onSplit?.(f),e.autoSplit&&p();function p(){const g=new Map;let m=!1;const y=()=>{if(m)return;m=!0;const k=()=>{m=!1,f.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(k):setTimeout(k,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(k=>{let w=!1;for(const T of k){const A=Math.round(T.contentRect.width),M=g.get(T.target);g.set(T.target,A),M!==void 0&&M!==A&&(w=!0)}w&&y()});for(const k of t)l.observe(k)}const v=t[0]?.ownerDocument?.fonts;v&&v.status!=="loaded"&&v.ready.then(()=>y())}return f}function A2(t,e){const n=t.ownerDocument,s=[],i=n.createTreeWalker(t,4),r=[];for(let o=i.nextNode();o;o=i.nextNode())r.push(o);for(const o of r){const a=o.data.match(/\s+|\S+/g)??[];if(a.length===0)continue;const l=n.createDocumentFragment();for(const c of a){if(/^\s/.test(c)){l.appendChild(n.createTextNode(c));continue}const h=n.createElement("span");h.className=e,h.style.display="inline-block",h.textContent=c,l.appendChild(h),s.push(h)}o.replaceWith(l)}return s}function P2(t,e){const n=t.ownerDocument,s=$2(t.textContent??"").map(i=>{const r=n.createElement("span");return r.className=e,r.style.display="inline-block",r.textContent=i,r});return t.replaceChildren(...s),s}function $2(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),n=>n.segment):Array.from(t)}function I2(t,e,n){const s=t.ownerDocument,i=new Map(e.map(p=>[p,p.getBoundingClientRect()])),r=[],o=p=>{for(const g of Array.from(p.childNodes))g.nodeType===3||i.has(g)||g.tagName==="BR"?r.push(g):o(g)};o(t);const a=[];let l=null,c=0,h=0,u=!1,d=[];const f=()=>{l=s.createElement("span"),l.className=n,l.style.display="block",a.push(l),d=[]};for(const p of r){if(p.tagName==="BR"){u=!0;continue}const g=i.get(p);if(g&&(!l||u||g.top>c+h)&&(f(),c=g.top,h=g.height/2,u=!1),!l)continue;const m=[];for(let k=p.parentNode;k&&k!==t;k=k.parentNode)m.unshift(k);let y=0;for(;y<d.length&&y<m.length&&d[y].original===m[y];)y++;d.length=y;let v=y===0?l:d[y-1].clone;for(const k of m.slice(y)){const w=k.cloneNode(!1);v.appendChild(w),d.push({original:k,clone:w}),v=w}v.appendChild(p)}return t.replaceChildren(...a),a}function O2(t,e){const n=t.ownerDocument.createElement("span");return n.className=e,n.style.display=t.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",t.replaceWith(n),n.appendChild(t),n}const Ru={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function Ga(t){const e=t.trim().toLowerCase();if(e in Ru)return Ru[e];if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function Ua(t){if(typeof t=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:t};let e=0;const s=t.replace(/([+-])=\s*(-?[\d.]+)/g,(o,a,l)=>(e+=(a==="-"?-1:1)*Number.parseFloat(l),"")).trim().split(/\s+/).filter(Boolean);if(s.length===1&&/^-?[\d.]+$/.test(s[0]))return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:Number.parseFloat(s[0])+e};const i=s[0]!==void 0?Ga(s[0]):void 0,r=s[1]!==void 0?Ga(s[1]):void 0;return{elementFraction:i??0,viewportFraction:r??0,offsetPx:e}}function Un(t,e,n){const s=Ua(n),i=s.absolutePx!==void 0?t.top+s.absolutePx:t.top+t.height*s.elementFraction,r=e*s.viewportFraction;return i-r+s.offsetPx}function C2(t,e,n,s){const i=Un(t,e,n),o=Un(t,e,s)-i;return o<=0?i<=0?1:0:Va(-i/o)}function Va(t){return t<0?0:t>1?1:t===0?0:t}function Lu(t,e,n,s){if(n<=0)return e;const i=1-Math.exp(-(s/1e3)/n);return t+(e-t)*i}function Ja(t,e,n,s,i){const r=h=>Un({top:t+i(h),bottom:t+i(h)+e,height:e},n,s),o=r(0),a=r(1);if(Math.sign(o)===Math.sign(a)||o===0||a===0)return o===0?0:a===0?1:Math.abs(o)<Math.abs(a)?0:1;let l=0,c=1;for(let h=0;h<40;h++){const u=(l+c)/2;Math.sign(r(u))===Math.sign(o)?l=u:c=u}return(l+c)/2}class Fu{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(e){this.timeline=e.timeline,this.trigger=e.trigger,this.behaviour=e.behaviour??"once",this.options=e}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(e=>{for(const n of e)n.isIntersecting?this.enter():this.leave()},{threshold:this.options.threshold??.15,rootMargin:this.options.rootMargin,root:this.options.root??null}),this.observer.observe(this.trigger)}}stop(){this.running=!1,this.observer?.disconnect(),this.observer=null}destroy(){this.stop()}reset(){this.hasPlayed=!1,this.timeline.stop()}enter(){this.options.onEnter?.(),!(this.behaviour==="once"&&this.hasPlayed)&&(this.hasPlayed=!0,this.behaviour!=="once"&&this.timeline.seek(0),this.timeline.play())}leave(){this.options.onLeave?.(),this.behaviour==="reset"&&this.timeline.stop()}}function _2(t){const e=new Fu(t);return e.start(),e}class Nu{element;spacer;saved;axis;spacing;constructor(e,n={}){this.element=e,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const s=e.ownerDocument;this.spacer=s.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:e.style.position,top:e.style.top,left:e.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),e.replaceWith(this.spacer),this.spacer.appendChild(e)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(e,n){const s=Math.max(0,n);this.element.style.position="sticky",this.axis==="x"?(this.spacer.style.width=`${this.element.offsetWidth+s}px`,this.spacer.style.marginRight=this.spacing?"":`-${s}px`,this.element.style.left=`${e}px`):(this.spacer.style.height=`${this.element.offsetHeight+s}px`,this.spacer.style.marginBottom=this.spacing?"":`-${s}px`,this.element.style.top=`${e}px`)}destroy(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left,this.spacer.parentNode&&this.spacer.replaceWith(this.element)}}const H2=.15;function Wu(t){return typeof t=="object"&&!Array.isArray(t)?t:{snapTo:t}}function Du(t,e,n){const s=br(t+e*H2);if(typeof n=="function")return br(n(s));if(typeof n=="number")return n<=0?t:br(Math.round(s/n)*n);if(n.length===0)return t;let i=n[0];for(const r of n)Math.abs(r-s)<Math.abs(i-s)&&(i=r);return br(i)}function Bu(t,e,n){const s=t.duration??{min:.2,max:.8};if(typeof s=="number")return s;const i=Math.min(1,Math.abs(e)/Math.max(1,n));return s.min+(s.max-s.min)*i}class zu{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(e,n){this.write=e,this.eventTarget=n}get active(){return this.rafId!==null}animate(e,n,s,i=Bs,r){if(this.cancel(),typeof requestAnimationFrame>"u"||s<=0){this.write(n),r?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let o=null;const a=l=>{o??=l;const c=Math.min(1,(l-o)/(s*1e3));this.write(e+(n-e)*i(c)),c<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),r?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const e of this.cancelEvents)this.eventTarget?.removeEventListener(e,this.onInterrupt)}}function br(t){return Math.max(0,Math.min(1,t))}class qu{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(e,n,s){this.options=s===!0?{}:s,this.scroller=n;const{startColor:i="#3ecf7a",endColor:r="#ff5a5a",id:o}=this.options,a=o?`${o} `:"",l=(c,h,u)=>{const d=e.createElement("div");return d.textContent=`${a}${c}`,d.setAttribute("aria-hidden","true"),d.className="scroll-marker",Object.assign(d.style,{position:u?"fixed":"absolute",right:`${this.options.indent??0}px`,zIndex:"2147483646",pointerEvents:"none",borderTop:`1px solid ${h}`,color:h,font:`${this.options.fontSize??"11px"} ui-monospace, monospace`,padding:"2px 6px",whiteSpace:"nowrap",background:"rgba(0, 0, 0, 0.35)"}),(n??e.body).appendChild(d),this.nodes.push(d),d};this.scrollerStart=l("scroller-start",i,!n),this.scrollerEnd=l("scroller-end",r,!n),this.start=l("start",i,!1),this.end=l("end",r,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(e,n){this.start.style.top=`${e.startPage}px`,this.end.style.top=`${e.endPage}px`;const s=this.scroller?n:0;this.scrollerStart.style.top=`${s+e.startViewport}px`,this.scrollerEnd.style.top=`${s+e.endViewport}px`}follow(e,n){this.scroller&&this.place(e,n)}destroy(){for(const e of this.nodes.splice(0))e.remove()}}const R2=120,Vn=[],Jn=new Set;let Za=!1;const L2=()=>{Za||Jn.size===0||(Za=!0,queueMicrotask(()=>{Za=!1;for(const t of Jn)t.afterRefresh()}))},ju=()=>{for(const t of Jn)t.beforeRefresh();for(const t of Vn)t.refresh();for(const t of Jn)t.afterRefresh()};let Zn={width:0,height:0};const Yu=()=>{const t=window.innerWidth,e=window.innerHeight,n=t===Zn.width&&e!==Zn.height,s=Math.abs(e-Zn.height)<Zn.height*.25,i=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&s&&i||(Zn={width:t,height:e},ju())};class ni{timeline;options;running=!1;pin=null;startPx=0;endPx=0;targetProgress=0;displayProgress=0;zone="before";measured=!1;lastScroll=null;lastScrollTime=0;velocityPxPerSecond=0;idleTimer=null;lastEmitted=null;rafId=null;lastFrameTime=null;onScroll=()=>this.update();releaseVelocity=0;snapper;snapTimer=null;markers=null;markerGeometry=null;constructor(e){this.timeline=e.timeline,this.options=e,this.snapper=new zu(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const e=this.options.pin===!0?this.options.trigger:this.options.pin||null;e&&!this.options.container&&(this.pin=new Nu(e,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new qu(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Vn.length===0&&typeof window<"u"&&(Zn={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Yu,{passive:!0})),Vn.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Vn.splice(Vn.indexOf(this),1),Vn.length===0&&typeof window<"u"&&window.removeEventListener("resize",Yu),this.stopSmoothing(),this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null,this.snapTimer!==null&&clearTimeout(this.snapTimer),this.snapTimer=null,this.snapper.cancel())}destroy(){this.stop(),this.pin?.destroy(),this.pin=null,this.markers?.destroy(),this.markers=null}get startOffset(){return this.startPx}get endOffset(){return this.endPx}static refreshAll(){ju()}static onRefresh(e){return Jn.add(e),()=>Jn.delete(e)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const e=this.scrollPosition();this.pin?.release();const n=this.triggerRect();if(n&&this.options.container)this.measureInContainer(this.options.container);else if(n){const s=this.viewportHeight();if(this.startPx=e+Un(n,s,si(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,s,e),this.pin){const i=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(i.top-(this.startPx-e),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(s):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,e),this.lastScroll=null,this.updateFrom(e,!this.measured),this.measured=!0,L2()}sample(){this.refresh()}update(e){this.running&&this.updateFrom(e??this.scrollPosition(),!1)}updateFrom(e,n){this.trackVelocity(e),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,e);const s=this.endPx-this.startPx,i=this.zone;this.targetProgress=s>0?Va((e-this.startPx)/s):e>=this.startPx?1:0,this.zone=s>0?e<=this.startPx?"before":e>=this.endPx?"after":"active":e>=this.startPx?"after":"before",this.fireBoundaryCallbacks(i,this.zone),n||this.smoothing()<=0?(this.displayProgress=this.targetProgress,this.applyProgress()):(this.emitUpdate(),this.startSmoothing())}smoothing(){const e=this.options.scrub;return typeof e=="number"?Math.max(0,e):0}resolveEnd(e,n,s){const i=si(this.options.end)??"bottom top",r=typeof i=="string"?i.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(r){const o=Number.parseFloat(r[1]);return this.startPx+(r[2]==="%"?n*o/100:o)}return s+Un(e,n,i)}applyProgress(){const e=this.timeline?.duration??0;this.timeline&&e>0&&this.timeline.seek(this.displayProgress*e),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const e=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===e[0]&&this.lastEmitted[1]===e[1]||(this.lastEmitted=e,this.options.onUpdate(e[0],e[1]))}trackVelocity(e){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&e!==this.lastScroll&&(this.velocityPxPerSecond=(e-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||e!==this.lastScroll)&&(this.lastScroll=e,this.lastScrollTime=n),!(this.velocityPxPerSecond===0||typeof setTimeout>"u")&&(this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.idleTimer=null,this.releaseVelocity=this.velocityPxPerSecond,this.velocityPxPerSecond=0,this.emitUpdate(),this.scheduleSnap()},R2))}fireBoundaryCallbacks(e,n){if(e===n)return;const{onEnter:s,onLeave:i,onEnterBack:r,onLeaveBack:o}=this.options;e==="before"?(s?.(),n==="after"&&i?.()):e==="after"?(r?.(),n==="before"&&o?.()):n==="after"?i?.():o?.()}scheduleSnap(){const e=this.options.snap;if(e===void 0||this.snapper.active)return;const n=Wu(e),s=()=>{this.snapTimer=null;const i=this.endPx-this.startPx,r=this.scrollPosition();if(!this.running||i<=0||r<=this.startPx||r>=this.endPx)return;const o=(r-this.startPx)/i,a=this.startPx+Du(o,this.releaseVelocity/i,n.snapTo)*i;Math.abs(a-r)<1||this.snapper.animate(r,a,Bu(n,a-r,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(s,n.delay*1e3):s()}scrollTo(e){const n=this.options.scroller,s=this.options.horizontal?{left:e}:{top:e};n?typeof n.scrollTo=="function"?n.scrollTo({...s,behavior:"instant"}):this.options.horizontal?n.scrollLeft=e:n.scrollTop=e:typeof window<"u"&&window.scrollTo({...s,behavior:"instant"})}measureInContainer(e){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const s=n.getBoundingClientRect(),i=this.options.scroller?.getBoundingClientRect?.().left??0,r=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,o=s.left-i-e.shiftAt(e.progress()),{start:a,end:l}=e.range(),c=f=>a+f*(l-a),h=Ja(o,s.width,r,si(this.options.start)??"left right",e.shiftAt);this.startPx=c(h);const u=si(this.options.end)??"right left",d=typeof u=="string"?u.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=d?this.startPx+Number.parseFloat(d[1]):c(Ja(o,s.width,r,u,e.shiftAt)),this.markerGeometry=null}markersFor(e){const n=(r,o)=>{const a=si(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=Ua(a);return e*l.viewportFraction-l.offsetPx},s=n(this.options.start,"top bottom")??0,i=n(this.options.end,"bottom top")??s;return{startViewport:s,endViewport:i,startPage:this.startPx+s,endPage:this.endPx+i}}startSmoothing(){if(this.rafId!==null||typeof requestAnimationFrame>"u")return;const e=n=>{if(this.rafId=null,!this.running)return;const s=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=Lu(this.displayProgress,this.targetProgress,this.smoothing(),s);const i=Math.abs(this.targetProgress-this.displayProgress)<1e-4;i&&(this.displayProgress=this.targetProgress),this.applyProgress(),i?this.lastFrameTime=null:this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}stopSmoothing(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.lastFrameTime=null}scrollTarget(){return this.options.scroller??(typeof window<"u"?window:null)}scrollPosition(){const e=this.options.scroller,n=this.options.horizontal;return e?(n?e.scrollLeft:e.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const e=this.options.trigger;return typeof e?.getBoundingClientRect!="function"?null:this.relativeRect(e.getBoundingClientRect())}relativeRect(e){const n=this.options.horizontal,s=n?e.left??0:e.top,i=n?e.right??0:e.bottom,r=n?e.width??0:e.height,o=this.options.scroller;if(o&&typeof o.getBoundingClientRect=="function"){const a=o.getBoundingClientRect(),l=n?a.left:a.top;return{top:s-l,bottom:i-l,height:r}}return{top:s,bottom:i,height:r}}viewportHeight(){const e=this.options.scroller,n=this.options.horizontal;return e?n?e.clientWidth:e.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function si(t){return typeof t=="function"?t():t}function F2(t){const e=new ni(t);return e.start(),e}const Qa=new Set,N2=16,Ku=.5,W2=2;class tl{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=e=>this.wheel(e);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(e={}){this.options=e,this.frames=e.frames??{request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)}}start(){if(this.running||typeof window>"u")return this;this.running=!0,this.reduced=this.options.reducedMotion??(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),this.current=this.target=this.position();const e=this.options.scroller??window;return e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),Qa.add(this),this.stopListening=ni.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const e of Qa)e.refresh()}stop(){if(!this.running)return this;this.running=!1;const e=this.options.scroller??window;return e.removeEventListener("wheel",this.onWheel),e.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),Qa.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const e of this.effects)el(e.element,e.saved);this.effects=[]}kill(){this.destroy()}get state(){const e=this.limit();return{scroll:this.current,target:this.target,progress:e>0?this.current/e:0,velocity:this.velocityPxPerSecond}}paused(e){return e!==void 0&&(this.pausedState=e,e&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(e,n={}){if(!this.running)return;const s=this.clamp(this.resolve(e)+(n.offset??0)),i=Math.abs(s-this.current),r=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,i/2500));if(r<=0){this.journey=null,this.current=this.target=s,this.write(s),this.applyEffects(0);return}this.target=s,this.journey={from:this.current,to:s,ms:r*1e3,ease:n.ease??Bs,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const e=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(e&&!this.reduced){const n=this.options.scroller??document,s=this.position(),i=this.viewportHeight(),r=this.options.scroller?.getBoundingClientRect().top??0;for(const o of n.querySelectorAll(e)){const a=Number.parseFloat(o.dataset.speed??""),l=Number.parseFloat(o.dataset.lag??""),c=o.getBoundingClientRect(),h=c.top-r+s;this.effects.push({element:o,speed:Number.isFinite(a)?a:void 0,lag:Number.isFinite(l)&&l>0?l:void 0,centre:h+c.height/2-i/2,lagged:s,shift:0,saved:o.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const e of this.effects)el(e.element,e.saved)}wheel(e){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||e.ctrlKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||this.nestedScrollerTakes(e))return;const n=e.deltaMode===1?N2:e.deltaMode===2?this.viewportHeight():1,s=e.deltaY*n*(this.options.wheelMultiplier??1),i=this.clamp(this.target+s);i===this.target&&i===this.current||(e.preventDefault(),this.journey=null,this.target=i,this.requestFrame())}nativeScroll(){const e=this.position();this.written!==null&&Math.abs(e-this.written)<=W2||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=e,this.requestFrame())}nestedScrollerTakes(e){const n=this.options.scroller??document.documentElement;for(let s=e.target;s&&s!==n&&s!==document.body;s=s.parentElement){if(s.hasAttribute?.("data-smooth-ignore"))return!0;const i=getComputedStyle(s);if(!/(auto|scroll)/.test(i.overflowY)||s.scrollHeight<=s.clientHeight)continue;if(e.deltaY<0?s.scrollTop>0:s.scrollTop+s.clientHeight<s.scrollHeight-1)return!0}return!1}requestFrame(){this.frameId!==null||!this.running||(this.frameId=this.frames.request(e=>this.frame(e)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(e){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,e-this.lastTime);this.lastTime=e;const s=this.current;if(this.journey){const r=this.journey;r.elapsed+=n;const o=Math.min(1,r.elapsed/r.ms);this.current=r.from+(r.to-r.from)*r.ease(o),o>=1&&(this.journey=null)}else if(this.current!==this.target){const r=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/r)),Math.abs(this.target-this.current)<Ku&&(this.current=this.target)}this.current!==s&&this.write(this.current),this.velocityPxPerSecond=n>0?(this.current-s)*1e3/n:0;const i=this.applyEffects(n);this.current!==s&&this.options.onUpdate?.(this.state),this.journey||this.current!==this.target||i?this.requestFrame():(this.lastTime=null,this.velocityPxPerSecond=0)}applyEffects(e){let n=!1;const s=this.current;for(const i of this.effects){let r=0;if(i.speed!==void 0&&(r+=(s-i.centre)*(1-i.speed)),i.lag!==void 0){const o=i.lag*1e3/3;i.lagged=e===0?s:i.lagged+(s-i.lagged)*(1-Math.exp(-e/o)),Math.abs(s-i.lagged)<Ku?i.lagged=s:n=!0,r+=s-i.lagged}el(i.element,r===0?i.saved:`0 ${D2(r)}px`),i.shift=r}return n}write(e){const n=Math.round(e);this.written=n;const s=this.options.scroller;s?s.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const e=this.options.scroller;return e?e.scrollTop:window.scrollY}viewportHeight(){const e=this.options.scroller;return e?e.clientHeight:window.innerHeight}limit(){const e=this.options.scroller??document.documentElement;return Math.max(0,e.scrollHeight-this.viewportHeight())}clamp(e){return Math.max(0,Math.min(this.limit(),e))}resolve(e){if(typeof e=="number")return e;const n=this.options.scroller??document,s=typeof e=="string"?n.querySelector(e):e;if(!s)return this.current;const i=this.options.scroller?.getBoundingClientRect().top??0,r=this.effects.find(o=>o.element===s)?.shift??0;return s.getBoundingClientRect().top-i+this.position()-r}}function el(t,e){e?t.style.setProperty("translate",e):t.style.removeProperty("translate")}function D2(t){return Math.round(t*100)/100}function B2(t,e){switch(e){case"play":if(t.progress()>=1)break;t.reversed()?t.reverse():t.play();break;case"reverse":if(t.progress()<=0)break;t.reversed()?t.play():t.reverse();break;case"pause":t.pause();break;case"resume":t.resume();break;case"restart":t.restart();break;case"reset":t.pause(),t.progress(0);break;case"complete":t.pause(),t.progress(1);break}}function nl(t,e,n,s,i=()=>{}){const r=f=>typeof f=="string"?t.query(f)??void 0:f,o=r(e.trigger)??s;if(!o){i(`gsap-compat: scrollTrigger has no trigger element${typeof e.trigger=="string"?` for "${e.trigger}"`:""}`);return}const a=e.scrub===void 0||e.scrub===!1?!1:e.scrub,l=(e.toggleActions??"play none none none").trim().split(/\s+/);let c=0,h;const u=(f,p)=>()=>{p?.(),n&&!a&&B2(n,l[f]??"none"),e.once&&f===0&&queueMicrotask(()=>h.destroy())},d=e.containerAnimation?j2(t,e.containerAnimation,o,i):void 0;return h=new ni({trigger:o,start:e.start,end:e.end,scrub:a===!1?void 0:a,pin:e.pin===!0?!0:r(e.pin),scroller:r(e.scroller),horizontal:e.horizontal,pinSpacing:e.pinSpacing,onRefresh:e.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:e.snap===void 0?void 0:z2(e.snap,n),markers:e.markers,container:d,onUpdate:(f,p)=>{if(n&&a!==!1&&n.progress(f),e.onUpdate){const g=f<c||p<0?-1:1;e.onUpdate({progress:f,velocity:p,direction:g})}c=f},onEnter:u(0,e.onEnter),onLeave:u(1,e.onLeave),onEnterBack:u(2,e.onEnterBack),onLeaveBack:u(3,e.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),t.own(h)}function z2(t,e){const n=i=>i==="labels"?r=>q2(r,e?.labelProgresses?.()??[]):i;if(typeof t!="object"||Array.isArray(t))return n(t);const s=t.ease?Qs(t.ease):void 0;return{snapTo:n(t.snapTo),duration:t.duration,delay:t.delay,ease:s?s.fn??Wt(s.easing):void 0}}function q2(t,e){return e.reduce((n,s)=>Math.abs(s-t)<Math.abs(n-t)?s:n,e[0]??t)}function j2(t,e,n,s){const i=()=>e.timeline.getTracks({property:"x"}).map(r=>r.target).filter(r=>{const o=t.elementFor(r);return!!o&&o!==n&&o.contains(n)});return i().length===0&&s("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const r=e.scrollTrigger;return r||s("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:r?.startOffset??0,end:r?.endOffset??0}},progress:()=>e.progress(),shiftAt:r=>{const o=e.timeline.getStateAtTime(r*e.timeline.duration);let a=0;for(const l of i()){const c=o.values.get(l)?.get("x");typeof c=="number"&&(a+=c)}return a}}}class Xu{conditions={};scope;host;items=[];snapshots=new Map;constructor(e,n){this.host=e,this.scope=n}add(e){const n=this.host.collector;this.host.setCollector(this);try{const s=e();return typeof s=="function"&&this.items.push({revert:s}),s}finally{this.host.setCollector(n)}}track(e){this.items.push(e)}touch(e,n){this.snapshots.has(e)||this.snapshots.set(e,{name:n,style:e.getAttribute("style"),d:e.getAttribute("d")})}revert(){for(const e of this.items.splice(0).reverse())e.revert?e.revert():e.kill?e.kill():e.destroy?.();for(const[e,{name:n,style:s,d:i}]of this.snapshots)s===null?e.removeAttribute("style"):e.setAttribute("style",s),i!==null&&e.setAttribute("d",i),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class Y2{host;scope;entries=[];listeners=[];scheduled=!1;constructor(e,n){this.host=e,this.scope=n}add(e,n){const s={conditions:e,setup:n,queries:new Map},i=typeof e=="string"?{matches:e}:e;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[r,o]of Object.entries(i)){const a=window.matchMedia(o);s.queries.set(r,a);const l=()=>this.scheduleUpdate();a.addEventListener("change",l),this.listeners.push(()=>a.removeEventListener("change",l))}return this.entries.push(s),this.update(s),this}revert(){for(const e of this.listeners.splice(0))e();for(const e of this.entries.splice(0))e.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const e of this.entries)this.update(e)}))}update(e){const n={};for(const[o,a]of e.queries)n[o]=a.matches;const s=Object.values(n).some(Boolean),i=s?JSON.stringify(n):void 0;if(i===e.key||(e.context?.revert(),e.context=void 0,e.key=i,!s))return;const r=new Xu(this.host,this.scope);r.conditions=n,r.add(()=>e.setup(r)),e.context=r}}class K2{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(e,n){this.canvas=e,this.context=e.getContext("2d"),this.options=n,this.frames=Math.max(1,Math.floor(n.frames)),this.images=new Array(this.frames),this.ready=new Array(this.frames).fill(!1),typeof window<"u"&&window.addEventListener("resize",this.onResize,{passive:!0}),this.resize(),this.pump()}get frame(){return this.current}set frame(e){this.current=Math.max(0,Math.min(this.frames-1,e)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const e of this.images)e&&(e.src="")}resize(){const e=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*e),s=Math.round(this.canvas.clientHeight*e);n>0&&s>0&&(this.canvas.width!==n||this.canvas.height!==s)&&(this.canvas.width=n,this.canvas.height=s),this.drawn=-1,this.draw()}draw(){const e=Math.round(this.current),n=this.nearestReady(e);if(n===-1||n===this.drawn||!this.context)return;const s=this.images[n],{width:i,height:r}=this.canvas,o=(this.options.fit??"cover")==="cover"?Math.max(i/s.naturalWidth,r/s.naturalHeight):Math.min(i/s.naturalWidth,r/s.naturalHeight),a=s.naturalWidth*o,l=s.naturalHeight*o;this.context.clearRect(0,0,i,r),this.context.drawImage(s,(i-a)/2,(r-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(e){for(let n=0;n<this.frames;n++){if(e-n>=0&&this.ready[e-n])return e-n;if(e+n<this.frames&&this.ready[e+n])return e+n}return-1}pump(){const e=this.options.concurrency??6,n=Math.round(this.current);for(let s=0;s<this.frames&&this.inFlight<e;s++)for(const i of s===0?[n]:[n+s,n-s])i<0||i>=this.frames||this.images[i]||this.inFlight>=e||this.load(i)}load(e){const n=new Image;n.decoding="async",this.images[e]=n,this.inFlight++;const s=i=>{if(!this.destroyed){if(this.inFlight--,i){this.ready[e]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const r=Math.round(this.current);(Math.abs(e-r)<Math.abs(this.drawn-r)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>s(!0),n.onerror=()=>s(!1),n.src=this.options.url(e)}}const X2={opacity:0,y:-16},G2={opacity:0,y:16};async function U2(t,e,n,s){const i=e.collector?.scope??e.root,r=i.ownerDocument??i,o=()=>s.shared?[...i.querySelectorAll(s.shared)]:[];if(s.native&&typeof r.startViewTransition=="function")return V2(r,s,o);const a=s.duration??.35,l=s.ease??"power2.inOut",c=m=>new Promise(y=>{m(y)||y()}),h=o(),u=h.length?Ya(e,h):void 0,d=s.from!==void 0?Gu(e,s.from,s.shared):[];if(d.length&&s.leave!==!1){const m=s.leave??X2;await c(y=>t.to(d,{...m,duration:a,ease:l,onComplete:y}))}await s.update();const f=[],p=typeof s.to=="function"?s.to():s.to,g=p!==void 0?Gu(e,p,s.shared):[];if(g.length&&s.enter!==!1){const m=s.enter??G2;f.push(c(y=>t.fromTo(g,m,{...Hu(m),duration:a,ease:l,onComplete:y})))}if(u){const m=o().filter(y=>!h.includes(y));m.length&&f.push(c(y=>Xa(e,n,u,{targets:m,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(f)}function Gu(t,e,n){const s=t.resolveTargets(e).map(i=>t.elementFor(i)).filter(i=>!!i);return n?s.flatMap(i=>!i.querySelector(n)&&!i.matches(n)?[i]:[...i.children].filter(r=>!r.matches(n)&&!r.querySelector(n))):s}async function V2(t,e,n){const s=(a,l)=>{const c=a.dataset?.flipId;c&&a.style.setProperty("view-transition-name",l?`tf-${c.replace(/[^\w-]/g,"-")}`:"")},i=n();i.forEach(a=>s(a,!0));let r=[];await t.startViewTransition(async()=>{i.forEach(a=>s(a,!1)),await e.update(),r=n(),r.forEach(a=>s(a,!0))}).finished,r.forEach(a=>s(a,!1))}const Uu={create:(t,e)=>La(t,G0(e))},Vu={create:(t,e)=>La(t,{fn:U0(e)})},Ju={create:(t,e)=>La(t,{fn:V0(e)})},J2=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Zu=.5,Z2="power1.inOut";function Q2(t){return t.keyframes!==void 0&&t.keyframes!==null}function tk(t){const e=t.keyframes,n={};for(const[c,h]of Object.entries(t))J2.has(c)||(n[c]=h);if(Array.isArray(e))return e.map(c=>({...n,...c,duration:c.duration??t.duration??Zu}));const s=Object.entries(e),i=t.duration??Zu,r=e.easeEach??t.easeEach??Z2;if(s.length>0&&s.every(([c])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(c)||c==="easeEach")){const c=s.filter(([d])=>d!=="easeEach").map(([d,f])=>({at:Number.parseFloat(d)/100,step:f})).sort((d,f)=>d.at-f.at),h=[];let u=0;for(const{at:d,step:f}of c){const p=Math.max(0,d-u);h.push({...n,ease:r,...f,duration:p*i}),u=d}return h}const o=s.filter(([c,h])=>c!=="easeEach"&&Array.isArray(h)),a=Math.max(0,...o.map(([,c])=>c.length)),l=[];for(let c=0;c<a;c++){const h={...n,ease:r,duration:i/a};for(const[u,d]of o)c<d.length&&(h[u]=d[c]);l.push(h)}return l}function Qu(t,e,n,s={}){const i=e.collector?.scope??e.root,r=typeof s.scroller=="string"?i.querySelector(s.scroller):s.scroller??null,o={x:r?r.scrollLeft:window.scrollX,y:r?r.scrollTop:window.scrollY},a={x:r?r.scrollWidth-r.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:r?r.scrollHeight-r.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(v,k)=>{if(k===void 0)return o[v];if(typeof k=="number")return k;if(k==="max")return a[v];const w=typeof k=="string"?i.querySelector(k):k;if(!w)return o[v];const T=w.getBoundingClientRect(),A=r?.getBoundingClientRect(),M=(v==="x"?s.offsetX:s.offsetY)??s.offset??0;return v==="x"?T.left-(A?.left??0)+o.x-M:T.top-(A?.top??0)+o.y-M},c=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:o.x,y:l("y",n)},h={x:Math.max(0,Math.min(a.x,c.x)),y:Math.max(0,Math.min(a.y,c.y))},u={...o},d=()=>{r?(r.scrollLeft=u.x,r.scrollTop=u.y):window.scrollTo({left:u.x,top:u.y,behavior:"instant"})},f=["wheel","touchstart","keydown"],p=r??window,g=()=>{y.kill(),m()},m=()=>{for(const v of f)p.removeEventListener(v,g)},y=t.to(u,{x:h.x,y:h.y,duration:s.duration??1,ease:s.ease??"power2.inOut",onStart:s.onStart,onUpdate:()=>{d(),s.onUpdate?.()},onComplete:()=>{m(),s.onComplete?.()}});if(s.autoKill!==!1)for(const v of f)p.addEventListener(v,g,{passive:!0});return y}function ek(t,e,n){const s=t.collector?.scope??t.root,i=typeof e=="string"?[...s.querySelectorAll(e)]:"nodeType"in e?[e]:Array.from(e),{interval:r=.1,batchMax:o,onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h,...u}=n,d={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},f={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},p={},g=y=>{p[y]!==void 0&&clearTimeout(p[y]),p[y]=void 0;const v=f[y].splice(0);v.length>0&&d[y]?.(v)},m=(y,v)=>{if(d[y]){if(f[y].push(v),o!==void 0&&f[y].length>=o)return g(y);p[y]===void 0&&(p[y]=setTimeout(()=>g(y),r*1e3))}};return i.map(y=>nl(t,{...u,trigger:y,onEnter:()=>m("onEnter",y),onLeave:()=>m("onLeave",y),onEnterBack:()=>m("onEnterBack",y),onLeaveBack:()=>m("onLeaveBack",y)})).filter(y=>y!==void 0)}class xe{compat;stage;options;autoplayPending;started=!1;killed=!1;recipe=[];firstElement;scrollDriver;events=[];ranges=[];playhead={time:0,iteration:0,direction:"forward",fresh:!0};waitingToWrap=!1;finishedThisFrame=!1;backwards=!1;constructor(e,n={}){this.stage=e;const s={...n,onWarning:n.onWarning??e.onWarning};if(this.options=s,this.compat=new vn({...s,startValue:(i,r)=>{const o=e.objectFor(i);if(o)return ik(o[r]);const a=e.appliedValue(i,r);if(a!==void 0)return a;if(r==="d")return xu(e.elementFor(i))??void 0;if(r==="text")return e.elementFor(i)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=id(e.elementFor(i));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(i,r)=>e.velocityOf(i,r),layoutColumns:i=>sd(i.map(r=>e.elementFor(r))),random:()=>e.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},e.collector?.track(this),e.liveTimelines.add(this),this.autoplayPending=!s.paused&&!s.scrollTrigger,s.scrollTrigger){const i=s.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=nl(e,i,this,this.firstElement,r=>s.onWarning?.(r)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(e,n,s){return Q2(n)?this.record(()=>this.keyframed(e,n,s)):this.record(()=>this.tween(e,[n],s,([i],r,o)=>this.compat.to(r,i,o)))}from(e,n,s){return this.record(()=>this.tween(e,[n],s,([i],r,o)=>this.compat.from(r,i,o)))}fromTo(e,n,s,i){return this.record(()=>this.tween(e,[n,s],i,([r,o],a,l)=>this.compat.fromTo(a,r,o,l)))}set(e,n,s){return this.record(()=>this.tween(e,[n],s,([i],r,o)=>this.compat.set(r,i,o)))}addLabel(e,n){return this.record(()=>this.compat.addLabel(e,n))}add(e,n){return this.record(()=>{e.autoplayPending=!1,e.timeline.stop(),e.stage.deactivate(e.timeline),this.compat.add(e.compat,n)})}invalidate(){const e=this.compat.progress();this.compat.progress(0),this.stage.render(this.timeline),this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();return this.syncDuration(),this.compat.progress(e),this.stage.render(this.timeline),this}call(e,n=[],s){return this.record(()=>{const i=this.compat.addEvent(s);this.events.push({time:i,run:()=>e(...n)})})}addPause(e,n,s=[]){return this.record(()=>{const i=this.compat.addEvent(e);this.events.push({time:i,pause:!0,run:()=>n?.(...s)})})}tweenTo(e,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,e,n)}tweenFromTo(e,n,s={}){this.pause(),this.seek(e);const i=this.timeline.currentTime,r=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),o={time:i},a=s.duration??Math.abs(r-i)/1e3/(this.timeScale()||1),l=new xe(this.stage,{onStart:s.onStart,onComplete:s.onComplete});return l.to(o,{time:r,duration:a,ease:s.ease??"none",onUpdate:()=>{this.moveTo(o.time),s.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const e=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!e){const s=this.timeline,i=s.direction==="forward"?s.currentTime===0:s.currentTime===s.duration;this.playhead={...this.readPlayhead(),fresh:i&&!n},this.waitingToWrap=!1}return this.stage.liveTimelines.add(this),this.stage.render(this.timeline),this.stage.activate(this.timeline,{onUpdate:()=>this.afterFrame()}),this}pause(){return this.autoplayPending=!1,this.timeline.pause(),this.stage.deactivate(this.timeline),this}resume(){return this.play()}restart(){return this.timeline.stop(),this.backwards=!1,this.play()}reverse(){this.backwards=!this.backwards;const e=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),e&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const e=this.timeline.duration;return e>0?this.compat.labelTimes().map(n=>n/e):[]}reversed(){return this.timeline.direction==="reverse"}seek(e){return this.autoplayPending=!1,this.compat.seek(e),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(e){return e===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,e))*this.timeline.duration),this.compat.progress())}timeScale(e){return this.compat.timeScale(e)}duration(){return this.compat.duration()}isActive(){return this.timeline.playbackState==="playing"}kill(){return this.killed=!0,this.stage.liveTimelines.delete(this),this.scrollDriver?.destroy(),this.scrollDriver=void 0,this.autoplayPending=!1,this.timeline.stop(),this.stage.deactivate(this.timeline),this.compat.kill(),this}toDefinition(){return this.compat.toDefinition()}killTweensOf(e,n){for(const s of e)for(const i of n??[void 0])this.timeline.removeTracks({target:s,...i!==void 0&&{property:i}});this.timeline.tracks.length===0&&this.events.length===0&&this.kill()}record(e){return this.recipe.push(e),e(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const e=Math.max(...this.events.map(n=>n.time));e>this.timeline.duration&&this.timeline.setDuration(e)}readPlayhead(){const e=this.timeline;return{time:e.currentTime,iteration:e.loopIteration,direction:e.direction}}moveTo(e){const n=this.playhead;this.timeline.seek(e),this.stage.render(this.timeline);const s={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:e>=n.time?"forward":"reverse"},i={...n,iteration:s.iteration,direction:s.direction};this.playhead={...this.readPlayhead()},this.waitingToWrap=!1,this.runCrossings(i,s,!1),this.options.onUpdate?.()}refreshForRepeat(){const e=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(e,this.timeline.duration))}afterFrame(){const e=this.timeline,n=e.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const s=this.playhead,i=this.readPlayhead();this.playhead=i;const r=this.options.yoyo===!0;n&&!r&&i.iteration>s.iteration&&(this.playhead={time:0,iteration:i.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const o=this.runCrossings(s,i,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!o){this.finishedThisFrame=!1;const a=e.currentTime===0&&e.direction==="reverse";!this.scrollDriver&&!r&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(e,n,s){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const i=this.events,{crossings:r,passes:o}=xa(i.map(a=>a.time),e,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:s});for(const a of r){if(this.killed)return!0;if(a.kind==="repeat"){this.options.repeatRefresh&&this.refreshForRepeat(),this.options.onRepeat?.();continue}const l=i[a.index];if(!(l.direction&&l.direction!==a.direction)){if(l.pause)return this.timeline.seek(l.time),this.stage.render(this.timeline),this.pause(),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,l.run(),!0;l.run()}}for(const a of this.ranges)o.some(([c,h])=>c!==h&&Math.max(c,h)>=a.start&&Math.min(c,h)<=a.end)&&a.run();return!1}tween(e,n,s,i){const r=this.resolve(e);if(!r)return;const{onStart:o,onUpdate:a,onComplete:l}=n[n.length-1];if(o||a||l){let c=1/0,h=-1/0;const u=(d,f,p)=>{i(d,f,p),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,s,u),c===1/0)return;o&&this.events.push({time:c,direction:"forward",run:o}),a&&this.ranges.push({start:c,end:h,run:a}),l&&this.events.push({time:h,direction:"forward",run:l});return}this.buildTween(r,n,s,i)}keyframed(e,n,s){const i=this.resolve(e);if(!i)return;const r=tk(n);if(r.length===0)return;const o=i.length>1?Wa(n.stagger,this.staggerContext(i)):void 0,a=i.map(m=>this.targetFor(m)).filter(m=>m!==void 0),l=o?a.map(m=>[m]):[a],c=o?Qi(i.length,o).map(m=>m/1e3):[0],h=this.compat.timeOf(s)/1e3+mr(n.delay,0)/1e3;let u=1/0,d=-1/0;if(l.forEach((m,y)=>{r.forEach((v,k)=>{const w=k===0?h+c[y]:">";this.tween(m,[v],w,([T],A,M)=>this.compat.to(A,T,M)),u=Math.min(u,this.compat.lastStart),d=Math.max(d,this.compat.lastEnd)})}),u===1/0)return;const{onStart:f,onUpdate:p,onComplete:g}=n;f&&this.events.push({time:u,direction:"forward",run:f}),p&&this.ranges.push({start:u,end:d,run:p}),g&&this.events.push({time:d,direction:"forward",run:g})}staggerContext(e){return{count:e.length,columnsFromLayout:()=>sd(e.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(e,n,s,i){const r=e.map(d=>this.targetFor(d));if(!(e.length>1&&(n.some(sk)||e.some(d=>this.stage.objectFor(d)!==void 0)))){const d=this.targetFor(e[0]);i(n.map(f=>this.prepare(nd(f,0,d,this.stage.utils,r),e)),e,s);return}const a=n.length-1,{stagger:l,...c}=n[a],h=Wa(l,this.staggerContext(e)),u=h?Qi(e.length,h).map(d=>d/1e3):e.map(()=>0);e.forEach((d,f)=>{const p=f===0?mr(c.delay,0)/1e3+u[0]:0,g=f===0?0:u[f]-u[f-1],m=f===0?s:`<${g<0?"-":"+"}${Math.abs(g).toFixed(6)}`,v=n.map((k,w)=>w===a?{...c,delay:p}:k).map(k=>this.prepare(nd(k,f,this.targetFor(d),this.stage.utils,r),[d]));i(v,[d],m)})}targetFor(e){return this.stage.elementFor(e)??this.stage.objectFor(e)}prepare(e,n){const s=o=>this.options.onWarning?.(o),i=o=>this.stage.query(o);let r=e;if(e.motionPath!==void 0){const o=p2(e.motionPath,{query:i,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:s});r={...r,motionPath:o}}if(e.morphSVG!==void 0){const o=m2(e.morphSVG,i,s),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(e.drawSVG!==void 0){const o=id(this.stage.elementFor(n[0]));if(o===void 0){s("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=r;r=l}else r=zw(r,o)}return r}resolve(e){const n=this.stage.resolveTargets(e);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${rk(e)}`);return}return this.firstElement??=n.map(s=>this.stage.elementFor(s)).find(s=>s!==void 0),n}}function td(t=new ku){const e=r=>{const{config:o}=pr(r);return new xe(t,{repeat:o.repeat,yoyo:o.yoyo,repeatDelay:o.repeatDelay,paused:o.paused,onStart:o.onStart,onUpdate:o.onUpdate,onComplete:o.onComplete,onRepeat:o.onRepeat,onReverseComplete:o.onReverseComplete,repeatRefresh:o.repeatRefresh,scrollTrigger:o.scrollTrigger})},n=r=>{const{onStart:o,onUpdate:a,onComplete:l,onRepeat:c,onReverseComplete:h,repeatRefresh:u,...d}=r;return d},s=r=>(r&&t.collector?.track(r),r),i={stage:t,ticker:t.ticker,utils:t.utils,getProperty:(r,o)=>{const[a]=t.resolveTargets(r);if(a===void 0)return;const l=t.objectFor(a);return l?l[o]:t.appliedValue(a,o)??pu(o)},scrollTrigger:r=>s(nl(t,r)),scrollBatch:(r,o)=>ek(t,r,o).map(a=>s(a)),scrollTo:(r,o)=>Qu(i,t,r,o),refreshScroll:()=>{ni.refreshAll(),tl.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(t.collector?.scope??t.root).querySelector(r.scroller):r.scroller;return s(new tl({...r,scroller:o}).start())},context:(r,o)=>{const a=new Xu(t,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new Y2(t,r),customEase:Uu.create,customBounce:Vu.create,customWiggle:Ju.create,pageTransition:r=>U2(i,t,o=>new xe(t,o),r),imageSequence:(r,o)=>{const a=typeof r=="string"?(t.collector?.scope??t.root).querySelector(r):r;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(r)}`);return s(new K2(a,o))},quickTo:(r,o,a={})=>{const l=new xe(t,{paused:!0}),[c]=t.resolveTargets(r);return Object.assign(u=>{if(!c)return;const d=a.spring!==void 0?t.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:u,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:nk(a.spring,o,d)}}),l.timeline.stop(),l.timeline.play(),t.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new xe(t,r),to:(r,o)=>{if(o.scrollTo!==void 0){const{scrollTo:a,...l}=o,c=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},h=typeof r!="string"&&r!==window&&r.nodeType===1;return Qu(i,t,a,{...l,offsetX:c.offsetX,offsetY:c.offsetY,scroller:h?r:void 0})}return e(o).to(r,n(o))},from:(r,o)=>e(o).from(r,n(o)),fromTo:(r,o,a)=>e(a).fromTo(r,o,n(a)),set:(r,o)=>e(o).set(r,n(o)),delayedCall:(r,o,a)=>new xe(t).call(o,a,r),killTweensOf:(r,o)=>{const a=t.resolveTargets(r),l=typeof o=="string"?o.split(",").map(c=>c.trim()).filter(Boolean):o;for(const c of[...t.liveTimelines])c.killTweensOf(a,l)},convertToPath:r=>b2(r,t.root),splitText:(r,o)=>{const a=t.collector?.scope??t.root,l=typeof r=="string"?Array.from(a.querySelectorAll(r)):"nodeType"in r?[r]:Array.from(r);return s(E2(l,o))},draggable:(r,o)=>s(M2(i,t,r,o)),getFlipState:r=>Ya(t,r),flipFrom:(r,o)=>Xa(t,a=>new xe(t,a),r,o),flip:(r,o,a)=>{const l=Ya(t,r);return o(),Xa(t,c=>new xe(t,c),l,{targets:r,...a})}};return i}const re=td();function nk(t,e,n){return t===!0?{velocity:{[e]:n}}:typeof t=="string"?{preset:t,velocity:{[e]:n}}:{...t,velocity:{[e]:n}}}function sk(t){return t.morphSVG!==void 0||t.drawSVG!==void 0||t.text!==void 0||t.scrambleText!==void 0||ed(t)}function ed(t){return Object.entries(t).some(([e,n])=>(typeof n=="function"||fu(n))&&!Na.has(e))}function nd(t,e,n,s,i){if(!ed(t))return t;const r={};for(const[o,a]of Object.entries(t))Na.has(o)?r[o]=a:typeof a=="function"?r[o]=a(e,n,i):fu(a)?r[o]=s.resolveRandomString(a):r[o]=a;return r}function sd(t){const e=t.map(s=>s?.getBoundingClientRect().top);if(e[0]===void 0)return t.length;let n=0;for(const s of e){if(s===void 0||Math.abs(s-e[0])>1)break;n++}return Math.max(1,n)}function id(t){const e=t;if(typeof e?.getTotalLength=="function")return e.getTotalLength()}function ik(t){if(typeof t=="number"||typeof t=="string"||Array.isArray(t)&&t.every(e=>typeof e=="number"))return t}function rk(t){return typeof t=="string"?`"${t}"`:String(t)}class sl{media;offset;driftTolerance;constructor(e,n={}){this.media=e,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(e){return Math.max(0,e/1e3+this.offset)}update(e,n){const s=this.targetTime(e);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-s)>this.driftTolerance&&(this.media.currentTime=s)):(this.media.paused||this.media.pause(),this.media.currentTime!==s&&(this.media.currentTime=s))}seek(e){this.media.currentTime=this.targetTime(e)}setRate(e){this.media.playbackRate=e}dispose(){this.media.paused||this.media.pause()}safePlay(){const e=this.media.play();e&&typeof e.catch=="function"&&e.catch(()=>{})}}function rd(t,e,n,s,i){const r=n-i;if(r<0){e.paused||e.pause(),e.currentTime=0;return}t.update(r,s)}class wr{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(e,n={}){if(typeof e=="string"){const s=document.querySelector(e);if(!s)throw new Error(`Container not found: ${e}`);this.container=s}else this.container=e;this.options=n,this.adapter=new Mn}async load(e){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(e)}async loadSource(e){let n;if(typeof e=="string"){const s=await fetch(e);if(!s.ok)throw new Error(`Failed to load animation: ${s.statusText}`);n=await s.json()}else n=e;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(e){const n={...e.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=Xn({...e,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(e,n={}){if(e.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const s=new Set;for(const r of e){if(s.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);s.add(r.id)}const i=n.initial===void 0?e[0]:e.find(r=>r.id===n.initial);if(!i)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...e],this.scenarioId=i.id,await this.loadSource(i.timeline)}get scenarios(){return this.scenarioList.map(e=>({id:e.id,label:e.label??e.id}))}get scenario(){return this.scenarioId}setScenario(e){const n=this.scenarioList.find(a=>a.id===e);if(!n||!this.timeline)return!1;if(e===this.scenarioId)return!0;const s=this.isPlaying,i=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=e,this.useDefinition(n.timeline),this.lastMarkerId=null;let o=0;return this.reducedMotion||i?o=this.duration:r!==void 0&&(o=this.markers.find(a=>a.id===r)?.time??0),this.seek(o),s&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(e){if(this.authored.has(e))return;const n={style:e.getAttribute("style")};e.children.length===0&&(n.text=e.textContent??"");const s=e.tagName.toLowerCase()==="path"?e:e.querySelector("path");s&&(n.path={element:s,d:s.getAttribute("d")}),this.authored.set(e,n)}restoreAuthored(){for(const[e,n]of this.authored){n.style===null?e.removeAttribute("style"):e.setAttribute("style",n.style),n.text!==void 0&&e.textContent!==n.text&&(e.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const s=e.dataset;s&&delete s.shineBase}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){for(const e of this.listeners)e()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const e=this.currentTime;let n;for(const s of this.markers)if(s.time<=e+.5)n=s;else break;return n}caption(e,n){const s=e?this.markers.find(o=>o.id===e):this.currentMarker;if(!s)return;const i=n??this.language(),r=o=>o?.[i]?.[s.id]??o?.[i.split("-")[0]]?.[s.id];return r(this.options.captions)??r(this.timeline?.captions)??s.label}next(){if(!this.timeline)return;const e=this.currentTime,n=this.markers.find(s=>s.time>e+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}e>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const e=this.currentTime,n=[...this.markers].reverse().find(s=>s.time<e-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(e){const n=this.markers.find(s=>s.id===e);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const e=this.options.initialFrame??"start";if(e==="none")return;const n=e==="end"?this.timeline.duration:e==="start"?0:e;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const s of n)this.onScreen=s.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const e=this.container.getBoundingClientRect?.();e&&(e.width>0||e.height>0)&&(this.onScreen=e.bottom>0&&e.top<window.innerHeight&&e.right>0&&e.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const e=this.onScreen&&document.visibilityState!=="hidden";!e&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):e&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const e=this.currentMarker,n=e?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(e))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const s=n,i=Number(s.getAttribute("data-tinyfly-start")??"0")||0,r=s.getAttribute("data-volume");r!==null&&(s.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:s,startTime:i,sync:new sl(s)})})}syncAllMedia(e,n){for(const s of this.mediaTargets)rd(s.sync,s.el,e,n,s.startTime)}loadFromString(e){const n=JSON.parse(e);this.load(n)}registerTarget(e,n){if(typeof n=="string"){const s=this.container.querySelector(n);s&&(this.rememberAuthored(s),this.targets[e]=s,this.adapter.registerTarget(e,s))}else this.rememberAuthored(n),this.targets[e]=n,this.adapter.registerTarget(e,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const s=n.closest("[data-tinyfly-symbol]");if(s&&s!==n)return;const i=n.getAttribute("data-tinyfly");i&&this.registerTarget(i,n)}),this.timeline&&new Set(this.timeline.tracks.map(s=>s.target)).forEach(s=>{if(!this.targets[s]){const i=this.container.querySelector(`[data-tinyfly="${s}"]`)||this.container.querySelector(`.${s}`)||this.container.querySelector(`#${s}`);i&&this.registerTarget(s,i)}})}setupSymbolInstances(){this.symbolInstances=[];const e=this.options.symbols;if(!e||e.length===0)return;const n=new Map(e.map(s=>[s.id,s]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const i=s.getAttribute("data-tinyfly-symbol");if(!i)return;const r=n.get(i);if(!r||!r.timeline.tracks?.length)return;const o=new Mn;s.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:Xn(r.timeline)})})}attachMedia(e,n){this.mediaSync=new sl(e,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const e=this.timeline.playbackState==="idle";this.timeline.play(),e&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(e){this.timeline&&(this.timeline.seek(e),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(e){this.timeline&&(this.timeline.speed=e,this.mediaSync?.setRate(e))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const e of this.mediaTargets)e.el.paused||e.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const e of this.symbolInstances)e.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const e=n=>{if(this.isDestroyed||!this.timeline)return;const s=n-(this.lastTime??n);this.lastTime=n;const i=this.playhead;this.timeline.tick(s),this.stopAtMarker(i),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(e):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(e)}stopAtMarker(e){const n=this.timeline,s={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=s;const i=this.markers;if(i.length===0)return;const{crossings:r}=xa(i.map(o=>o.time),e,s,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const o of r){if(o.kind!=="event")continue;const a=i[o.index];if(this.stepping||a.pause){this.stepping=!1,n.pause(),n.seek(a.time),this.playhead={time:a.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const e=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(e)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const s=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(s>0?e%s:e))}}}async function ok(t,e,n={}){const s=new wr(t,{...n,autoplay:!0});return await s.load(e),s}function ak(t,e={}){return new wr(t,e)}const od={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},ad="tinyfly-controls-style",lk=`
2
+ `?y+=w:y+=f[wb(m,v,g)%f.length]}return y}class Ht{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(e){if(this.id=e.id,this.name=e.name,this._captions=e.captions,this._config=e.config??{},this._explicitDuration=e.config?.duration,e.tracks)for(const n of e.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(e){if(this._explicitDuration=e,e!==void 0)this._config={...this._config,duration:e};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(e){this._config.speed=e}get drawingRate(){return this._config.drawingRate??0}set drawingRate(e){const n={...this._config};e>0?n.drawingRate=e:delete n.drawingRate,this._config=n}play(){const e=this.duration;this._direction==="forward"&&this._currentTime>=e&&e>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&e>0&&(this._currentTime=e,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(e){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(e,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(e){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let i=e*this.speed;if(this._repeatDelayRemaining>0){const a=Math.min(this._repeatDelayRemaining,i);if(this._repeatDelayRemaining-=a,i-=a,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let a=0;a<r&&i>0&&this._playbackState==="playing";a++)if(this._direction==="forward"){const l=n-this._currentTime;if(i>=l){if(i-=l,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=i,i=0}else{const l=this._currentTime;if(i>=l){if(i-=l,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=i,i=0}const o=this.getStateAtTime(this._currentTime);this.onUpdate?.(o)}getStateAtTime(e){const n=new Map;if(e=Uh(e,this._config.drawingRate??0),this._hasSharedWrites())this._resolveShared(e,n);else for(const[s,i]of this._trackPlayers){const r=i.getTrack().property;for(const{target:o,value:a,start:l}of i.getTargetValues(e))this._write(n,s,o,r,a,e-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(e,n){const s=new Map;for(const[i,r]of this._trackPlayers){const o=r.getTrack().property;for(const{target:a,value:l,start:c}of r.getTargetValues(e)){const h=`${a}\0${o}`,u=c<=e,d=s.get(h);(!d||(u!==d.started?u:u?c>=d.start:c<=d.start))&&s.set(h,{trackId:i,target:a,property:o,value:l,start:c,started:u})}}for(const{trackId:i,target:r,property:o,value:a,start:l}of s.values())this._write(n,i,r,o,a,e-l)}_write(e,n,s,i,r,o){if(r===void 0)return;let a=e.get(s);a||(a=new Map,e.set(s,a));const l=this._textTracks.get(n);if(l&&typeof r=="number"){a.set("text",W0(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=Ma(c.motionPathConfig,r);a.set("motionPathX",h.x),a.set("motionPathY",h.y),c.motionPathConfig.autoRotate&&a.set("motionPathRotate",h.angle)}else a.set(i,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const e=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const s of Ke(n)){const i=`${s}\0${n.property}`;if(e.has(i)){this._sharedWrites=!0;break t}e.add(i)}}return this._sharedWrites}addTrack(e){if(this._tracks.push(e),this._sharedWrites=null,Be(e)){this._trackPlayers.set(e.id,new F0(e));return}if(ze(e)){this._trackPlayers.set(e.id,new L0(e)),this._springTracks.set(e.id,e);return}if(Ji(e))this._trackPlayers.set(e.id,new Xe(e)),this._textTracks.set(e.id,e);else if(na(e)){const n={id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,delay:e.delay,endDelay:e.endDelay,targets:e.targets,stagger:e.stagger};this._trackPlayers.set(e.id,new Xe(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new Xe(e))}replaceTrack(e,n){const s=this._tracks.findIndex(r=>r.id===e);if(s<0)return;const i=this._tracks.slice(s+1);this.removeTrack(e);for(const r of i)this.removeTrack(r.id);this.addTrack(n);for(const r of i)this.addTrack(r)}removeTrack(e){this._tracks=this._tracks.filter(n=>n.id!==e),this._sharedWrites=null,this._trackPlayers.delete(e),this._motionPathTracks.delete(e),this._springTracks.delete(e),this._textTracks.delete(e)}getTracks(e={}){return this._tracks.filter(n=>this._matches(n,e))}removeTracks(e={}){const n=this.getTracks(e).map(s=>s.id);for(const s of n)this.removeTrack(s);return n}getTrackSpan(e){const n=this._trackPlayers.get(e);if(!n)return;const s=n.getTrack(),i=s.delay??0;if(ze(s)||Be(s))return{from:i,to:n.getDuration()};const r=s.keyframes;if(!(!r||r.length===0))return{from:r[0].time+i,to:n.getDuration()}}findConflicts(){const e=[];for(let n=0;n<this._tracks.length;n++){const s=this._tracks[n],i=this.getTrackSpan(s.id);if(i)for(let r=0;r<n;r++){const o=this._tracks[r];if(o.property!==s.property)continue;const a=Ke(o).filter(u=>Ke(s).includes(u));if(a.length===0)continue;const l=this.getTrackSpan(o.id);if(!l||!(l.from<=i.to&&i.from<=l.to))continue;const h=i.from>=l.from;for(const u of a)e.push({target:u,property:s.property,losingTrackId:h?o.id:s.id,winningTrackId:h?s.id:o.id})}}return e}_matches(e,n){if(n.id!==void 0&&e.id!==n.id||n.property!==void 0&&e.property!==n.property||n.target!==void 0&&!Ke(e).includes(n.target))return!1;if(n.timeRange){const s=this.getTrackSpan(e.id);if(!s||s.to<n.timeRange.from||s.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:ea(this._tracks),id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((e,n)=>e.time-n.time)}setMarkers(e){const n=e&&e.length>0?[...e].sort((i,r)=>i.time-r.time).map(i=>({...i})):void 0,s={...this._config};n?s.markers=n:delete s.markers,this._config=s}get captions(){return this._captions}setCaptions(e){const n={};for(const[s,i]of Object.entries(e??{}))n[s]={...i};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let e=0;for(const[,n]of this._trackPlayers)e=Math.max(e,n.getDuration());return e}_handleEndReached(){const e=this._config.loop??0;return e===-1||this._loopIteration<e?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const e=this._config.loop??0;return this._config.alternate&&(e===-1||this._loopIteration<e)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const kb=100;function xa(t,e,n,s){const i=[],r=[],{duration:o,alternate:a}=s,l=(f,p,g,m)=>{r.push([f,p]);const y=[];t.forEach((v,k)=>{(g==="forward"?(m?v>=f:v>f)&&v<=p:(m?v<=f:v<f)&&v>=p)&&y.push(k)}),y.sort((v,k)=>(g==="forward"?t[v]-t[k]:t[k]-t[v])||v-k);for(const v of y)i.push({kind:"event",index:v,direction:g})};let c=e.time,h=e.direction,u=e.fresh===!0;const d=Math.min(kb,Math.max(0,n.iteration-e.iteration));for(let f=0;f<d;f++){const p=h==="forward"?o:0;l(c,p,h,u),i.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=p,u=!1):(c=h==="forward"?0:o,u=!0)}return d>0&&s.holding&&!a?{crossings:i,passes:r}:(l(c,n.time,h,u),{crossings:i,passes:r})}function D0(t){return Be(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:B0(t.inertia),...Me(t)}:ze(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...Me(t)}:Ji(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(Ta),...Me(t)}:na(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(Ta),...Me(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(Ta),...t.interpolation!==void 0&&{interpolation:t.interpolation},...Me(t)}}function B0(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function Ta(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function Me(t){const e=t.endDelay;return{...t.delay!==void 0&&{delay:t.delay},...e!==void 0&&{endDelay:e},...t.targets!==void 0&&{targets:[...t.targets]},...t.stagger!==void 0&&{stagger:{...t.stagger}}}}function z0(t){if(Be(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:B0(e.inertia),...Me(e)}}if(ze(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...Me(e)}}if(Ji(t)){const e=t;return{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:[...e.keyframes].sort((n,s)=>n.time-s.time),...Me(e)}}if(t.property==="motionPath"&&"motionPathConfig"in t){const e=t,n=[...e.keyframes].sort((s,i)=>s.time-i.time);return{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:n,...Me(e)}}return ar({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...t.interpolation!==void 0&&{interpolation:t.interpolation},...Me(t)})}function q0(t){const e=t._config.markers;return{formatVersion:ea(t.tracks),id:t.id,name:t.name,config:{duration:t.duration>0?t.duration:void 0,loop:t._config.loop,speed:t._config.speed,alternate:t._config.alternate,repeatDelay:t._config.repeatDelay,...t._config.drawingRate?{drawingRate:t._config.drawingRate}:{},...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(D0),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function Xn(t){const e=t.formatVersion??1;if(e>ta)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${ta}. Update tinyfly to play it.`);return new Ht({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(z0),captions:t.captions})}function vb(t){return JSON.stringify(q0(t))}function Mb(t){const e=JSON.parse(t);return Xn(e)}function ne(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function Ge(t){let e=t>>>0||2654435769;return{seed:t>>>0,next(){return e^=e<<13,e>>>=0,e^=e>>17,e^=e<<5,e>>>=0,e/4294967296}}}function Ea(t,e,n){return e+t.next()*(n-e)}function j0(t,e,n,s){if(s<=0)return Ea(t,e,n);const i=Math.floor((n-e)/s),r=Math.round(t.next()*i);return e+r*s}function Sb(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const Y0=/^([+\-*/])=\s*(-?[\d.]+)$/,K0=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function xb(t){return typeof t!="string"?!1:Y0.test(t.trim())||K0.test(t.trim())}function Aa(t,e={}){if(typeof t!="string")return t;const n=t.trim(),s=Y0.exec(n);if(s){const[,r,o]=s,a=e.base??0,l=Number.parseFloat(o);switch(r){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const i=K0.exec(n);if(i){if(!e.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const r=Number.parseFloat(i[1]),o=Number.parseFloat(i[2]),a=i[3]!==void 0?Number.parseFloat(i[3]):void 0;return a!==void 0?j0(e.random,r,o,a):Ea(e.random,r,o)}return t}function X0(t,e=0,n){const s=[];let i=e;for(const r of t){const o=Aa(r,{base:i,random:n});s.push(o),typeof o=="number"&&(i=o)}return s}class Tb{random;constructor(e){this.random=Ge(e)}get seed(){return this.random.seed}resolve(e,n=0){return Aa(e,{base:n,random:this.random})}resolveSequence(e,n=0){return X0(e,n,this.random)}}const Eb=600;function G0(t){if(Array.isArray(t)){const[d,f,p,g]=t;return{fn:J0(d,f,p,g),bezier:[d,f,p,g]}}const{segments:e}=pn(t);if(e.length===0)throw new Error(`customEase: no curve in "${t}"`);const n=e[0].startX,s=e[0].startY,i=e[e.length-1],r=i.endX-n,o=i.endY-s;if(r===0||o===0)throw new Error(`customEase: "${t}" must move along both axes`);const a=d=>(d-n)/r,l=d=>(d-s)/o;if(e.length===1&&i.type==="C"){const[d,f,p,g]=i.points,m=[a(d),l(f),a(p),l(g)];return{fn:J0(...m),bezier:m}}const c=[],h=[],u=Math.max(8,Math.ceil(Eb/e.length));for(const d of e)for(let f=c.length===0?0:1;f<=u;f++){const[p,g]=Ab(d,f/u);c.push(a(p)),h.push(l(g))}return{fn:Pb(c,h)}}function U0(t={}){const n=.1+Math.max(0,Math.min(1,t.strength??.7))*.7,s=[1];for(let r=n;r>.002;r*=n)s.push(2*Math.sqrt(r));const i=s.reduce((r,o)=>r+o,0);return r=>{if(r<=0)return 0;if(r>=1)return 1;let o=r*i;for(let a=0;a<s.length;a++){if(o<=s[a]){if(a===0)return(o/s[0])**2;const l=s[a]/2,c=l*l,h=o-l;return 1-(c-h*h)}o-=s[a]}return 1}}function V0(t={}){const e=Math.max(1,t.wiggles??10),n=t.type??"easeOut",s=i=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*i):(1-i)**2;return i=>i<=0||i>=1?0:Math.sin(i*e*Math.PI*2)*s(i)}function Ab(t,e){if(t.type==="L"){const[c,h]=t.points;return[t.startX+(c-t.startX)*e,t.startY+(h-t.startY)*e]}const[n,s,i,r,o,a]=t.points,l=1-e;return[l*l*l*t.startX+3*l*l*e*n+3*l*e*e*i+e*e*e*o,l*l*l*t.startY+3*l*l*e*s+3*l*e*e*r+e*e*e*a]}function Pb(t,e){return n=>{if(n<=t[0])return e[0];if(n>=t[t.length-1])return e[e.length-1];let s=0,i=t.length-1;for(;i-s>1;){const o=s+i>>1;t[o]<=n?s=o:i=o}const r=t[i]-t[s];return r===0?e[i]:e[s]+(n-t[s])/r*(e[i]-e[s])}}function J0(t,e,n,s){const i=(o,a,l)=>3*(1-o)*(1-o)*o*a+3*(1-o)*o*o*l+o*o*o,r=(o,a,l)=>3*(1-o)*(1-o)*a+6*(1-o)*o*(l-a)+3*o*o*(1-l);return o=>{if(o<=0)return 0;if(o>=1)return 1;let a=o;for(let h=0;h<8;h++){const u=i(a,t,n)-o,d=r(a,t,n);if(Math.abs(u)<1e-6)return i(a,e,s);if(Math.abs(d)<1e-6)break;a-=u/d}let l=0,c=1;a=o;for(let h=0;h<40;h++)i(a,t,n)<o?l=a:c=a,a=(l+c)/2;return i(a,e,s)}}const $b=350,Ib=300,Ob=550;function Cb(t,e={}){const n=e.lead??$b,s=e.gap??Ib,i=e.tail??Ob,r=[];let o=0;return t.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((d,f)=>{if(!(d.duration>=0))throw new Error(`narration: scene ${l} line ${f} has an invalid duration (${d.duration})`);f>0&&(h+=s),c.push({id:d.id??`s${l}-l${f}`,scene:l,line:f,start:h,end:h+d.duration,text:d.text}),h+=d.duration});const u=h+i+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:u-o,cues:c}),o=u}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function _b(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function Hb(t,e){let n=t.scenes[0];for(const s of t.scenes)if(e>=s.start)n=s;else break;return n}const Ks=t=>6e4/t.bpm;function lr(t,e){return t.offset+e*Ks(t)}function Xs(t,e){return(e-t.offset)/Ks(t)}function Rb(t,e){return lr(t,Math.round(Xs(t,e)))}function Lb(t,e){return lr(t,Math.ceil(Xs(t,e)-1e-9))}function Fb(t,e,n){const s=Math.max(1,Math.round(t.beatsPerBar??4)),i=[];if(!(t.bpm>0)||n<e)return i;for(let r=Math.ceil(Xs(t,e)-1e-9);;r++){const o=lr(t,r);if(o>n+1e-9)break;i.push({time:o,bar:(r%s+s)%s===0,n:r})}return i}const Gn=100;function Nb(t,e,n={}){const s=n.minBpm??70,i=n.maxBpm??180,r=Math.max(1,Math.round(e/Gn)),o=Math.min(t.length,Math.round((n.maxSeconds??60)*e)),a=Math.floor(o/r);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let S=0;S<a;S++){let E=0;for(let P=S*r;P<(S+1)*r;P++)E+=t[P]*t[P];l[S]=Math.log(1e-6+E/r)}const c=new Float64Array(a);for(let S=1;S<a;S++)c[S]=Math.max(0,l[S]-l[S-1]);const h=c.reduce((S,E)=>S+E,0)/a;for(let S=0;S<a;S++)c[S]=Math.max(0,c[S]-h);const u=Math.max(1,Math.floor(60*Gn/i)),d=Math.min(a-1,Math.ceil(60*Gn/s)),f=S=>{let E=0;for(let P=S;P<a;P++)E+=c[P]*c[P-S];return E/(a-S)};let p=0;for(let S=0;S<a;S++)p+=c[S]*c[S];p/=a;let g=u,m=-1/0;for(let S=u;S<=d;S++){const E=60*Gn/S,P=Math.exp(-.5*(Math.log2(E/120)/.9)**2),I=f(S)*P;I>m&&(m=I,g=S)}const y=S=>{const E=Math.floor(S);return E<0||E+1>=a?0:c[E]+(c[E+1]-c[E])*(S-E)},v=(S,E)=>{let P=0;for(let I=E;I<a;I+=S)P+=y(I);return P};let k=g,w=0,T=-1/0;for(let S=g-.6;S<=g+.6+1e-9;S+=.02){if(S<1)continue;const E=Math.max(1,Math.round(S*4));for(let P=0;P<E;P++){const I=P/E*S,O=v(S,I);O>T&&(T=O,w=I,k=S)}}const A=60*Gn/k,M=p>0?Math.max(0,Math.min(1,f(g)/p)):0,x=(w+.5)*1e3/Gn;return{bpm:Math.round(A*100)/100,offset:Math.round(x%(6e4/A)),confidence:M}}const Wb=600,Db=250,Z0=1;function Bb(t,e){const n=e.target??"Camera",s={x:e.stage.width/2,y:e.stage.height/2},i={},r=(u,d,f,p)=>{const g=i[u]??=[];for(;g.length>0&&g[g.length-1].time>=d;)g.pop();g.push({time:d,value:f,...p?{easing:p}:{}})},o=u=>{const d=u.rotate*Math.PI/180,f=(u.focusX-s.x)*u.scale,p=(u.focusY-s.y)*u.scale;return{x:-(f*Math.cos(d)-p*Math.sin(d)),y:-(f*Math.sin(d)+p*Math.cos(d)),scale:u.scale,rotate:u.rotate}},a=(u,d,f)=>{const p=o(d);for(const g of["x","y","scale","rotate"])r(g,u,p[g],f)};let l={focusX:s.x,focusY:s.y,scale:1,rotate:0};const c=[...t].sort((u,d)=>u.at-d.at),h=c.filter(u=>!("shake"in u));h.length>0&&a(0,l);for(const u of h)if("frame"in u){const d=Math.max(Z0,u.duration??Wb);a(u.at,l),l={focusX:u.frame.focus?.x??s.x,focusY:u.frame.focus?.y??s.y,scale:u.frame.scale??1,rotate:u.frame.rotate??0},a(u.at+d,l,u.easing??(d>Z0?"ease-in-out":void 0))}else{const{follow:d}=u,f=d.lag??Db,p=new Ht({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:d.x}]}),g=v=>p.getStateAtTime(v).values.get("s")?.get("x")??l.focusX,m=[u.at,...d.x.map(v=>v.time).filter(v=>v>u.at&&v<u.until),u.until];a(u.at,l);const y=v=>({focusX:g(v)+(d.lead??0),focusY:d.y??l.focusY,scale:d.scale??l.scale,rotate:l.rotate});for(const v of m){const k=d.x.find(w=>w.time===v)?.easing;a(v+f,y(v),v===u.at?"ease-in-out":k)}l=y(u.until)}for(const u of c.filter(d=>"shake"in d)){const d=u.shake.strength??12,f=u.shake.roll??1.5,p=1e3/(u.shake.frequency??24),g=Ge(u.shake.seed??Math.round(u.at)+1),m=()=>g.next()*2-1;for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at,0);for(let y=u.at+p;y<u.at+u.duration;y+=p){const v=1-(y-u.at)/u.duration;r("shakeX",y,m()*d*v),r("shakeY",y,m()*d*v),r("shakeRotate",y,m()*f*v)}for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at+u.duration,0,"ease-out")}return Object.entries(i).map(([u,d])=>({id:`${n}-${u}`,target:n,property:u,keyframes:d}))}function Q0(t,e){const n=t.toLowerCase(),s=e.toLowerCase();let i=Array.from({length:s.length+1},(r,o)=>o);for(let r=1;r<=n.length;r++){const o=[r];for(let a=1;a<=s.length;a++)o[a]=Math.min(i[a]+1,o[a-1]+1,i[a-1]+(n[r-1]===s[a-1]?0:1));i=o}return i[s.length]}function Gs(t,e){const n=t.toLowerCase(),s=e.find(o=>o.toLowerCase().includes(n)||n.includes(o.toLowerCase()));if(s&&Math.min(t.length,s.length)>=3)return s;let i,r=1/0;for(const o of e){const a=Q0(t,o);a<r&&(r=a,i=o)}return i!==void 0&&r<=Math.max(2,Math.floor(t.length/3))?i:void 0}function ft(t,e,n,s){const i=typeof e=="string"?s??Gs(e,n):void 0;return`Unknown ${t} ${JSON.stringify(e)}${i?`: did you mean "${i}"?`:"."} Known: ${n.join(", ")}`}function Us(t,e){const n=e.step??33,s=e.stiffness??120,i=e.damping??9,r=e.mass??1;let o=t(e.start),a=0;const l=[{time:e.start,value:o}];let c=e.start+n;for(let h=e.start+1;h<=e.end;h++){const d=s*(t(h)-o)-i*a;a+=d/r*.001,o+=a*.001,(h>=c||h===e.end)&&(l.push({time:h,value:o}),c+=n)}return l}function mn(t,e,n=1){if(!(e>0))return 0;const s=t*n/e;return s-Math.floor(s)}function Pa(t){const e=t-Math.floor(t);return 1-Math.abs(e*2-1)}function zb(t,e){const n=Math.max(1,Math.round(e.cycles??1)),s=e.amplitude??1,i=mn(t,e.period,n)+(e.phase??0),r=i-Math.floor(i);switch(e.shape??"sine"){case"triangle":return s*(Pa(r+.25)*2-1);case"square":return r<.5?s:-s;default:return s*Math.sin(r*Math.PI*2)}}function qb(t,e){const n=Math.max(1,Math.round(e.cycles??1)),s=typeof e.easing=="function"?e.easing:Wt(e.easing??"ease-in-out"),i=mn(t,e.period,n)+(e.phase??0);return s(Pa(i))}function jb(t,e){const n=tu(e.seed),s=Math.max(1,Math.round(e.cycles??1)),i=(mn(t,e.period,1)+(e.phase??0))*Math.PI*2,r=s/Math.PI;return eu([Math.cos(i)*r+7.31,Math.sin(i)*r+3.17],n,e.octaves??1)}function Yb(t,e,n){const s=tu(n.seed),i=Math.max(1,Math.round(n.cycles??1)),r=Math.max(1,Math.round(n.cyclesAlong??1)),o=mn(t,n.period,1)*Math.PI*2,a=mn(e,n.periodAlong,1)*Math.PI*2,l=i/Math.PI,c=r/Math.PI;return eu([Math.cos(o)*l+5.13,Math.sin(o)*l+9.47,Math.cos(a)*c+2.71,Math.sin(a)*c+6.29],s,n.octaves??1)}const tu=t=>typeof t=="string"?ne(t):(t??0)>>>0;function eu(t,e,n){const s=Math.max(1,Math.min(6,Math.round(n)));let i=0,r=1,o=0;for(let a=0;a<s;a++){const l=2**a;i+=r*Kb(t.map(c=>c*l),e+a*1013),o+=r,r*=.5}return i/o}function Kb(t,e){const n=t.length,s=t.map(Math.floor),r=t.map((a,l)=>a-s[l]).map(a=>a*a*(3-2*a));let o=0;for(let a=0;a<1<<n;a++){let l=1;const c=[];for(let h=0;h<n;h++){const u=a>>h&1;l*=u?r[h]:1-r[h],c.push(s[h]+u)}l!==0&&(o+=l*Xb(c,e))}return o}function Xb(t,e){let n=(e^2654435769)>>>0;for(const s of t)n=Math.imul(n^(s|0),2246822507)>>>0,n=(n^n>>>13)>>>0,n=Math.imul(n,3266489909)>>>0,n=(n^n>>>16)>>>0;return n/4294967296*2-1}function Gb(t,e={}){if(t.length===0)throw new Error("curve: needs at least one key");const s={id:"curve",target:"curve",property:"value",keyframes:t.map(r=>({time:r.at,value:r.value,easing:r.easing})).sort((r,o)=>r.time-o.time),interpolation:e.interpolation},i=new Xe(s);return r=>i.getValueAtTime(r)}function Ub(t,e){return e*Ks({bpm:t.bpm})}function Vb(t,e){const n=Math.max(1,Math.round(t/Ks(e)));return{beats:n,grid:{...e,bpm:n*6e4/t}}}function Jb(t,e,n={}){const s=Math.max(1e-6,n.attack??.05),i=Math.max(1e-6,n.decay??.4),r=Xs(e,t),o=r-Math.floor(r),a=o<s?o/s:Math.max(0,1-(o-s)/i),l=n.barAccent??0;if(l<=0)return a;const c=Math.max(1,Math.round(e.beatsPerBar??4)),u=(Math.floor(r)%c+c)%c===0;return a*(u?1+l:1)/(1+l)}function Zb(t,e,n={}){const s=n.fps??30,i=Math.max(1,Math.round(e/s)),r=Math.max(1,Math.ceil(t.length/i)),o=new Float32Array(r),a=Math.min(.99,Math.max(0,n.smoothing??.5));let l=0,c=0;for(let h=0;h<r;h++){let u=0;const d=h*i,f=Math.min(t.length,d+i);for(let g=d;g<f;g++)u+=t[g]*t[g];const p=f>d?Math.sqrt(u/(f-d)):0;l=p>l?p:l*a+p*(1-a),o[h]=l,c=Math.max(c,l)}if(n.normalize!==!1&&c>0)for(let h=0;h<r;h++)o[h]/=c;return o}function Qb(t,e,n=30,s){if(t.length===0)return 0;const r=(s?mn(e,s)*s:e)*n/1e3,o=Math.floor(r),a=t[Math.min(t.length-1,Math.max(0,o))],l=t[Math.min(t.length-1,Math.max(0,o+1))];return a+(l-a)*(r-o)}const nu={"16:9":16/9,"2.39:1":2.39,"4:3":4/3,"1:1":1,"9:16":9/16,"4:5":4/5},$a=t=>typeof t=="number"?t:nu[t];function tw(t,e){const n=$a(e),s=t.width/t.height;if(n>=s){const r=t.width/n;return{x:0,y:(t.height-r)/2,width:t.width,height:r}}const i=t.height*n;return{x:(t.width-i)/2,y:0,width:i,height:t.height}}function ew(t,e){const n=$a(t),s=i=>Math.max(2,Math.round(i/2)*2);return"width"in e?{width:s(e.width),height:s(e.width/n)}:{width:s(e.height*n),height:s(e.height)}}function nw(t,e={}){const n=s=>({x:t.x+t.width*(1-s)/2,y:t.y+t.height*(1-s)/2,width:t.width*s,height:t.height*s});return{action:n(e.action??.9),title:n(e.title??.8)}}const Se=t=>Math.round(t*1e3)/1e3;function su(t,e={}){if(t.length===0)return"";const n=e.curviness??1,s=e.closed??!1,i=t.length;let r=`M${Se(t[0].x)} ${Se(t[0].y)}`;if(i===1)return r;const o=l=>s?t[(l%i+i)%i]:t[Math.max(0,Math.min(i-1,l))],a=s?i:i-1;for(let l=0;l<a;l++){const c=o(l-1),h=o(l),u=o(l+1),d=o(l+2);if(n===0){r+=` L${Se(u.x)} ${Se(u.y)}`;continue}const f=n/6,p=h.x+(u.x-c.x)*f,g=h.y+(u.y-c.y)*f,m=u.x-(d.x-h.x)*f,y=u.y-(d.y-h.y)*f;r+=` C${Se(p)} ${Se(g)} ${Se(m)} ${Se(y)} ${Se(u.x)} ${Se(u.y)}`}return s?`${r} Z`:r}const Bt=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function sw(t){const e=(t??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let s=0;s+1<e.length;s+=2)n.push({x:e[s],y:e[s+1]});return n}function cr(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=Bt(e.cx),s=Bt(e.cy),i=t.tag.toLowerCase()==="circle"?Bt(e.r):Bt(e.rx),r=t.tag.toLowerCase()==="circle"?Bt(e.r):Bt(e.ry);return`M${n+i} ${s} A${i} ${r} 0 1 1 ${n-i} ${s} A${i} ${r} 0 1 1 ${n+i} ${s} Z`}case"rect":{const n=Bt(e.x),s=Bt(e.y),i=Bt(e.width),r=Bt(e.height);let o=e.rx!=null?Bt(e.rx):e.ry!=null?Bt(e.ry):0,a=e.ry!=null?Bt(e.ry):o;return o=Math.min(o,i/2),a=Math.min(a,r/2),o===0||a===0?`M${n} ${s} H${n+i} V${s+r} H${n} Z`:`M${n+o} ${s} H${n+i-o} A${o} ${a} 0 0 1 ${n+i} ${s+a} V${s+r-a} A${o} ${a} 0 0 1 ${n+i-o} ${s+r} H${n+o} A${o} ${a} 0 0 1 ${n} ${s+r-a} V${s+a} A${o} ${a} 0 0 1 ${n+o} ${s} Z`}case"line":return`M${Bt(e.x1)} ${Bt(e.y1)} L${Bt(e.x2)} ${Bt(e.y2)}`;case"polyline":case"polygon":{const n=sw(e.points);if(n.length===0)return null;const s=n.map((i,r)=>`${r===0?"M":"L"}${i.x} ${i.y}`).join(" ");return t.tag.toLowerCase()==="polygon"?`${s} Z`:s}default:return null}}function iw(t,e,n){const s=Math.max(2,Math.round(n.samples??32)),i=Math.max(0,n.length),r=n.since!==void 0?Math.max(e-i,n.since):e-i;if(r>=e)return[];const o=n.period,a=[];for(let l=0;l<s;l++){const c=r+(e-r)*l/(s-1),h=o&&o>0&&l<s-1?(c%o+o)%o:c;a.push({at:t(h),time:c,age:i>0?(e-c)/i:0})}return a}const rw=2.5;function iu(t){const e=[],n=[],s=t.length,i=(r,o)=>{for(let a=r+o;a>=0&&a<s;a+=o){const l=(t[a].x-t[r].x)*o,c=(t[a].y-t[r].y)*o,h=Math.hypot(l,c);if(h>1e-9)return[l/h,c/h]}return null};for(let r=0;r<s;r++){const o=t[r],a=i(r,-1),l=i(r,1),c=a??l??[1,0],h=l??a??[1,0];let u=c[0]+h[0],d=c[1]+h[1];const f=Math.hypot(u,d);f<1e-9?(u=c[0],d=c[1]):(u/=f,d/=f);const p=u*c[0]+d*c[1],g=Math.min(rw,1/Math.max(p,1e-6)),m=o.width/2*g;e.push({x:o.x-d*m,y:o.y+u*m}),n.push({x:o.x+d*m,y:o.y-u*m})}return{left:e,right:n}}function ru(t){const e=t.length;if(e<2)return null;const n=t[e-1];for(let s=e-2;s>=0;s--){const i=n.x-t[s].x,r=n.y-t[s].y,o=Math.hypot(i,r);if(o>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(i/o,-r/o)}}return null}const ow={scale:1,turn:0,x:0,y:0};function aw(t={}){return{scale:t.scale??1,turn:t.turn??0,x:t.x??0,y:t.y??0}}function ou(t,e,n){const{ax:s,ay:i}=hr(t,e);return{scale:t,turn:e,x:n.x-(s*n.x-i*n.y),y:n.y-(i*n.x+s*n.y)}}function Ia(t,e){const{ax:n,ay:s}=hr(t.scale,t.turn);return{x:n*e.x-s*e.y+t.x,y:s*e.x+n*e.y+t.y}}function lw(t,e){const n=Ia(e,{x:t.x,y:t.y});return{scale:t.scale*e.scale,turn:t.turn+e.turn,x:n.x,y:n.y}}function cw(t){if(t.scale===0)throw new Error("invertSimilarity: a scale of 0 cannot be undone");const e={scale:1/t.scale,turn:-t.turn,x:0,y:0},n=Ia(e,{x:t.x,y:t.y});return{...e,x:-n.x,y:-n.y}}function au(t){const{ax:e,ay:n}=hr(t.scale,t.turn),s=1-e,i=-n,r=s*s+i*i;return r<1e-18?null:{x:(t.x*s+t.y*i)/r,y:(t.y*s-t.x*i)/r}}function hw(t,e){if(t.scale<=0)throw new Error("powSimilarity: the scale must be positive");const n=Math.pow(t.scale,e),s=t.turn*e,i=au(t);return i?ou(n,s,i):{scale:n,turn:s,x:t.x*e,y:t.y*e}}function uw(t){const{ax:e,ay:n}=hr(t.scale,t.turn);return[e,n,-n,e,t.x,t.y]}const hr=(t,e)=>{const n=e*Math.PI/180;return{ax:t*Math.cos(n),ay:t*Math.sin(n)}};function ur([t,e,n],s={}){const i=s.scale??1,r=s.centre??{x:0,y:0},o=Math.sqrt(3)/2;return{x:r.x+(t-e)*o*i,y:r.y+((t+e)*.5-n)*i}}const Oa=([t,e,n])=>t+e+n;function Ca(t,e={}){const[n,s,i]=t.min,[r,o,a]=t.max,l=d=>ur(d,e),c=[(n+r)/2,(s+o)/2,(i+a)/2],h=Oa(c),u=[{side:"top",depth:h,tag:t.tag,points:[l([n,s,a]),l([r,s,a]),l([r,o,a]),l([n,o,a])]},{side:"left",depth:h,tag:t.tag,points:[l([n,o,i]),l([r,o,i]),l([r,o,a]),l([n,o,a])]},{side:"right",depth:h,tag:t.tag,points:[l([r,s,i]),l([r,o,i]),l([r,o,a]),l([r,s,a])]}];return t.hide?u.filter(d=>!t.hide.includes(d.side)):u}function _a(t,e={}){return t.map(n=>({box:n,depth:Oa([(n.min[0]+n.max[0])/2,(n.min[1]+n.max[1])/2,(n.min[2]+n.max[2])/2])})).sort((n,s)=>n.depth-s.depth).flatMap(({box:n})=>Ca(n,e))}function dw(t={}){const e=t.size??10,s=(t.thickness??2)/2,i=[{tag:0,min:[-s,-s,-s],max:[e-s,s,s]},{tag:1,min:[e-s,-s,-s],max:[e+s,e-s,s]},{tag:2,min:[e-s,e-s,-s],max:[e+s,e+s,e]}],r=t.centre??{x:0,y:0},o=ur([2*e/3,e/3,e/3],{scale:t.scale}),a={centre:{x:r.x-o.x,y:r.y-o.y},scale:t.scale};return{boxes:i,faces:[..._a(i,a),...Ca({...i[0],hide:["right"]},a)]}}function fw(t={}){const e=Math.max(2,Math.round(t.steps??8)),n=t.tread??1.5,s=t.rise??.25,i=t.width??3,r=t.base??1.5,o=Math.max(1,Math.round(e*(n-2*s)/(n+2*s))),a=2*(e+o),l=n*(e-o)/a,c=[{dir:[1,0,0],across:[0,1,0],count:e},{dir:[0,1,0],across:[-1,0,0],count:e},{dir:[-1,0,0],across:[0,-1,0],count:o},{dir:[0,-1,0],across:[1,0,0],count:o}],h=[];let u=[0,0,0],d=0;for(const y of c){for(let v=0;v<y.count;v++){const k=d*l,w=[u[0]+y.dir[0]*v*n,u[1]+y.dir[1]*v*n,0],T=[w[0]+y.dir[0]*n+y.across[0]*i,w[1]+y.dir[1]*n+y.across[1]*i,0];h.push({tag:d,min:[Math.min(w[0],T[0]),Math.min(w[1],T[1]),0],max:[Math.max(w[0],T[0]),Math.max(w[1],T[1]),k+r]}),d++}u=[u[0]+y.dir[0]*y.count*n,u[1]+y.dir[1]*y.count*n,0]}const f=a*l,p=t.centre??{x:0,y:0},g=ur([e*n/2,e*n/2,f/2+r],{scale:t.scale}),m={centre:{x:p.x-g.x,y:p.y-g.y},scale:t.scale};return{boxes:h,faces:_a(h,m),rise:l}}function lu(t,e,n){let s=0;for(const i of t){const r=(e-i.x)**2+(n-i.y)**2;s+=r>1e-9?i.r*i.r/r:1e9}return s}function gw(t,e={}){if(t.length===0)return[];const n=e.threshold??1,s=Math.max(.5,e.cell??4),i=Math.sqrt(1/n)*1.6,r=e.bounds??{x:Math.min(...t.map(f=>f.x-f.r*i)),y:Math.min(...t.map(f=>f.y-f.r*i)),width:Math.max(...t.map(f=>f.x+f.r*i))-Math.min(...t.map(f=>f.x-f.r*i)),height:Math.max(...t.map(f=>f.y+f.r*i))-Math.min(...t.map(f=>f.y-f.r*i))},o=Math.max(2,Math.ceil(r.width/s)+1),a=Math.max(2,Math.ceil(r.height/s)+1),l=new Float64Array(o*a);for(let f=0;f<a;f++)for(let p=0;p<o;p++)l[f*o+p]=lu(t,r.x+p*s,r.y+f*s)-n;const c=(f,p)=>l[p*o+f],h=(f,p,g,m,y,v)=>{const k=g===v?.5:g/(g-v);return{x:f+(m-f)*k,y:p+(y-p)*k}},u=[];for(let f=0;f+1<a;f++)for(let p=0;p+1<o;p++){const g=r.x+p*s,m=r.y+f*s,y=g+s,v=m+s,k=[c(p,f),c(p+1,f),c(p+1,f+1),c(p,f+1)],w=(k[0]>0?1:0)|(k[1]>0?2:0)|(k[2]>0?4:0)|(k[3]>0?8:0);if(w===0||w===15)continue;const T=()=>h(g,m,k[0],y,m,k[1]),A=()=>h(y,m,k[1],y,v,k[2]),M=()=>h(g,v,k[3],y,v,k[2]),x=()=>h(g,m,k[0],g,v,k[3]),S=(k[0]+k[1]+k[2]+k[3])/4>0;switch(w){case 1:case 14:u.push([x(),T()]);break;case 2:case 13:u.push([T(),A()]);break;case 3:case 12:u.push([x(),A()]);break;case 4:case 11:u.push([A(),M()]);break;case 6:case 9:u.push([T(),M()]);break;case 7:case 8:u.push([x(),M()]);break;case 5:S?u.push([x(),M()],[T(),A()]):u.push([x(),T()],[A(),M()]);break;case 10:S?u.push([x(),T()],[A(),M()]):u.push([x(),M()],[T(),A()]);break}}const d=pw(u);return e.smooth===!1?d:d.map(f=>cu(cu(f)))}function pw(t){const e=r=>`${Math.round(r.x*1e3)},${Math.round(r.y*1e3)}`,n=new Map;t.forEach(([r,o],a)=>{for(const l of[r,o]){const c=e(l);n.has(c)||n.set(c,[]),n.get(c).push(a)}});const s=new Array(t.length).fill(!1),i=[];for(let r=0;r<t.length;r++){if(s[r])continue;s[r]=!0;const o=[t[r][0],t[r][1]];let a=t[r][1];for(;;){const l=(n.get(e(a))??[]).find(u=>!s[u]);if(l===void 0)break;s[l]=!0;const[c,h]=t[l];if(a=e(c)===e(a)?h:c,e(a)===e(o[0]))break;o.push(a)}o.length>=3&&i.push(o)}return i}function cu(t){const e=[];for(let n=0;n<t.length;n++){const s=t[n],i=t[(n+1)%t.length];e.push({x:s.x*.75+i.x*.25,y:s.y*.75+i.y*.25},{x:s.x*.25+i.x*.75,y:s.y*.25+i.y*.75})}return e}function mw(t){const e=Math.min(1,Math.max(0,t.progress));if(e<=0)return[];const n=t.width/2,s=n*(.55+.75*e),i=Math.max(t.length*e,s*1.2),r=t.x,o=t.y+i-s,a=Math.max(.1,n*(.35-.3*e)),l=o-Math.sqrt(Math.max(0,s*s-a*a)),c=Math.max(0,l-t.y),h=8,u=[],d=[];for(let v=0;v<=h;v++){const k=v/h,w=a+(n-a)*Math.pow(1-k,1.6+1.4*e);u.push({x:r-w,y:t.y+c*k}),d.push({x:r+w,y:t.y+c*k})}const f=Math.max(8,Math.round(t.segments??12)),p=Math.acos(Math.min(1,a/s)),g=-p,m=Math.PI+p,y=[];for(let v=1;v<f;v++){const k=g+(m-g)*v/f;y.push({x:r+Math.cos(k)*s,y:o+Math.sin(k)*s})}return[...d,...y,...u.reverse()]}function yw(t){const e=Math.min(1,Math.max(0,t.grow??1)),n=e>=1?1:1-Math.pow(1-e,3)+.08*Math.sin(e*Math.PI)*e,s=t.r*Math.max(0,n);if(s<=0)return[];const i=Math.max(12,Math.round(t.segments??48)),r=t.wobble??.05,o=t.time??0,a=t.period?o/t.period:o/2500,l=(a-Math.floor(a))*Math.PI*2,c=t.seed??0,h=[];for(let u=0;u<i;u++){const d=u/i*Math.PI*2,f=1+r*(Math.sin(2*d+l+c)*.6+Math.sin(3*d-2*l+c*1.7)*.4);h.push({x:t.x+Math.cos(d)*s*f,y:t.y+Math.sin(d)*s*f})}return h}function bw(t){const e=t.progress;if(e<=0||e>=1)return[];const n=Math.max(3,Math.round(t.pieces??8)),s=[],i=t.r*(1+1.2*e),r=Math.PI*2/n*.6*(1-e);for(let o=0;o<n;o++){const a=o/n*Math.PI*2+.3,l=[];for(let c=0;c<=4;c++){const h=a-r/2+r*c/4;l.push({x:t.x+Math.cos(h)*i,y:t.y+Math.sin(h)*i})}s.push(l)}return s}function ww(t,e={}){const n=Math.max(.05,1+t);return{sx:e.keep==="volume"?1/Math.sqrt(n):1/n,sy:n}}function kw(t,e,n={x:0,y:0}){return t.map(s=>({x:n.x+(s.x-n.x)*e.sx,y:n.y+(s.y-n.y)*e.sy}))}function Vs(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function se(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function yn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Ie(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Js(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function dr(t){return Math.hypot(t[0],t[1],t[2])}function Zs(t,e){return dr(se(t,e))}function Jt(t){const e=dr(t);return e===0?[0,0,0]:yn(t,1/e)}function bn(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n,t[2]+(e[2]-t[2])*n]}const vw=Object.freeze(Object.defineProperty({__proto__:null,add:Vs,cross:Js,distance:Zs,dot:Ie,length:dr,lerp:bn,normalize:Jt,scale:yn,subtract:se},Symbol.toStringTag,{value:"Module"})),Mw=Math.PI/180;function fr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Rt(t,e){const n=new Array(16);for(let s=0;s<4;s++)for(let i=0;i<4;i++){let r=0;for(let o=0;o<4;o++)r+=t[o*4+i]*e[s*4+o];n[s*4+i]=r}return n}function wn(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t[0],t[1],t[2],1]}function kn(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function me(t){const[e,n,s,i]=t;return[1-2*(n*n+s*s),2*(e*n+s*i),2*(e*s-n*i),0,2*(e*n-s*i),1-2*(e*e+s*s),2*(n*s+e*i),0,2*(e*s+n*i),2*(n*s-e*i),1-2*(e*e+n*n),0,0,0,0,1]}function Ha(t,e,n){const s=me(e);for(let i=0;i<3;i++)s[i]*=n[0],s[4+i]*=n[1],s[8+i]*=n[2];return s[12]=t[0],s[13]=t[1],s[14]=t[2],s}function Sw(t){const e=new Array(16);for(let n=0;n<4;n++)for(let s=0;s<4;s++)e[s*4+n]=t[n*4+s];return e}function Ra(t){const[e,n,s,i,r,o,a,l,c,h,u,d,f,p,g,m]=t,y=e*o-n*r,v=e*a-s*r,k=e*l-i*r,w=n*a-s*o,T=n*l-i*o,A=s*l-i*a,M=c*p-h*f,x=c*g-u*f,S=c*m-d*f,E=h*g-u*p,P=h*m-d*p,I=u*m-d*g,O=y*I-v*P+k*E+w*S-T*x+A*M;if(Math.abs(O)<1e-12)return null;const H=1/O;return[(o*I-a*P+l*E)*H,(s*P-n*I-i*E)*H,(p*A-g*T+m*w)*H,(u*T-h*A-d*w)*H,(a*S-r*I-l*x)*H,(e*I-s*S+i*x)*H,(g*k-f*A-m*v)*H,(c*A-u*k+d*v)*H,(r*P-o*S+l*M)*H,(n*S-e*P-i*M)*H,(f*T-p*k+m*y)*H,(h*k-c*T-d*y)*H,(o*x-r*E-a*M)*H,(e*E-n*x+s*M)*H,(p*v-f*w-g*y)*H,(c*w-h*v+u*y)*H]}function xw(t,e,n,s){const i=1/Math.tan(t*Mw/2),r=1/(n-s);return[i/e,0,0,0,0,i,0,0,0,0,(s+n)*r,-1,0,0,2*s*n*r,0]}function Tw(t,e,n,s,i,r){const o=1/(e-t),a=1/(s-n),l=1/(r-i);return[2*o,0,0,0,0,2*a,0,0,0,0,-2*l,0,-(e+t)*o,-(s+n)*a,-(r+i)*l,1]}function Ew(t,e,n=[0,1,0]){const s=Jt(se(t,e)),i=Jt(Js(n,s)),r=Js(s,i);return[i[0],r[0],s[0],0,i[1],r[1],s[1],0,i[2],r[2],s[2],0,-Ie(i,t),-Ie(r,t),-Ie(s,t),1]}function ie(t,e){const n=t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12],s=t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13],i=t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14],r=t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15];return r===1||r===0?[n,s,i]:[n/r,s/r,i/r]}const Aw=Object.freeze(Object.defineProperty({__proto__:null,compose:Ha,fromQuat:me,identity:fr,invert:Ra,lookAt:Ew,multiply:Rt,orthographic:Tw,perspective:xw,scaling:kn,transformPoint:ie,translation:wn,transpose:Sw},Symbol.toStringTag,{value:"Module"})),gr={"power1.in":[.55,.085,.68,.53],"power1.out":[.25,.46,.45,.94],"power1.inout":[.455,.03,.515,.955],"power2.in":[.55,.055,.675,.19],"power2.out":[.215,.61,.355,1],"power2.inout":[.645,.045,.355,1],"power3.in":[.895,.03,.685,.22],"power3.out":[.165,.84,.44,1],"power3.inout":[.77,0,.175,1],"power4.in":[.755,.05,.855,.06],"power4.out":[.23,1,.32,1],"power4.inout":[.86,0,.07,1],"sine.in":[.47,0,.745,.715],"sine.out":[.39,.575,.565,1],"sine.inout":[.445,.05,.55,.95],"expo.in":[.95,.05,.795,.035],"expo.out":[.19,1,.22,1],"expo.inout":[1,0,0,1],"circ.in":[.6,.04,.98,.335],"circ.out":[.075,.82,.165,1],"circ.inout":[.785,.135,.15,.86],"back.in":[.6,-.28,.735,.045],"back.out":[.175,.885,.32,1.275],"back.inout":[.68,-.55,.265,1.55]},hu={none:"linear",linear:"linear","linear.none":"linear","power1.in":"ease-in-quad","power1.out":"ease-out-quad","power1.inout":"ease-in-out-quad","power2.in":"ease-in-cubic","power2.out":"ease-out-cubic","power2.inout":"ease-in-out-cubic"};function Pw(t){let e=t.trim().toLowerCase();e=e.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(e);return n&&n[1]!=="steps"&&e!=="none"&&e!=="linear"&&(e=`${n[1]}.out${n[2]??""}`),e}Wt({type:"bounce",mode:"in"}),Wt({type:"bounce",mode:"in-out"});function Qs(t){const e=uu.get(t.trim().toLowerCase());if(e)return e;const n=Pw(t),s=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(s){const o={type:"steps",count:Math.max(1,Number.parseInt(s[1],10))+1,position:"none"};return{easing:o,fn:Wt(o)}}const i=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(i){const[,r,o,a]=i,l=(a??"").split(",").map(u=>Number.parseFloat(u)).filter(u=>Number.isFinite(u)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in gr)return{easing:{type:"cubic-bezier",points:gr[n]}};const h=r==="elastic"?{type:"elastic",mode:c,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:r==="bounce"?{type:"bounce",mode:c}:{type:"back",mode:c,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:h,fn:Wt(h)}}return n in hu?{easing:hu[n]}:n in gr?{easing:{type:"cubic-bezier",points:gr[n]}}:{easing:"ease-out"}}const uu=new Map;function La(t,e){return uu.set(t.trim().toLowerCase(),e.bezier?{easing:{type:"cubic-bezier",points:e.bezier},fn:e.fn}:{fn:e.fn,requiresBaking:"custom"}),t}function Fa(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const du=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function fu(t){return typeof t=="string"&&du.test(t)}function $w(t=1){let e=Fa(t);const n=(l,c)=>((...h)=>h.length>=l?c(...h):u=>c(...h,u)),s=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),i=(l,c,h,u,d)=>c===l?h:h+(d-l)/(c-l)*(u-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return gu(l,c,1/0);if("values"in l)return gu(l.values,c,l.radius??1/0);const h=Math.round(c/l.increment)*l.increment;return Math.abs(h-c)<=(l.radius??1/0)?h:c},o=(l,c,h)=>{const u=l+e()*(c-l);return h?Math.round(u/h)*h:u};return{clamp:n(3,s),mapRange:n(5,i),normalize:n(3,(l,c,h)=>i(l,c,0,1,h)),interpolate:n(3,(l,c,h)=>{if(typeof l=="object"&&!Array.isArray(l)){const u={};for(const d of Object.keys(l))u[d]=Ys(l[d])(l[d],c[d],h);return u}return Ys(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const g=l,m=y=>g[(Math.round(y)%g.length+g.length)%g.length];return c===void 0?m:m(c)}const u=l,f=c-u,p=g=>f===0?u:((g-u)%f+f)%f+u;return h===void 0?p:p(h)}),wrapYoyo:n(3,(l,c,h)=>{const u=c-l;if(u===0)return l;const d=((h-l)%(u*2)+u*2)%(u*2);return l+(d>u?u*2-d:d)}),snap:n(2,r),random:((l,c,h,u)=>{if(Array.isArray(l)){const f=()=>l[Math.floor(e()*l.length)];return c===!0?f:f()}const d=()=>o(l,c,h);return u?d:d()}),shuffle:l=>{for(let c=l.length-1;c>0;c--){const h=Math.floor(e()*(c+1));[l[c],l[h]]=[l[h],l[c]]}return l},distribute:({base:l=0,amount:c,each:h,from:u="start",ease:d})=>(f,p,g)=>{const m=g.length,v=Zi(f,m,{...c!==void 0?{amount:c}:{each:h??1},from:u}),k=c!==void 0?c:(h??1)*ia(m,u),w=d&&k>0?d(v/k)*k:v;return l+w},pipe:(...l)=>c=>l.reduce((h,u)=>u(h),c),splitColor:l=>Iw(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{e=Fa(l)},resolveRandomString:l=>{const c=du.exec(l)?.[1]??"";if(c.startsWith("[")){const p=c.slice(1,-1).split(",").map(g=>g.trim()).filter(Boolean).map(g=>Number.isFinite(Number(g))?Number(g):g.replace(/^['"]|['"]$/g,""));return p[Math.floor(e()*p.length)]}const[h,u,d]=c.split(",").map(f=>Number.parseFloat(f));return o(h,u,Number.isFinite(d)?d:void 0)}}}function gu(t,e,n){let s=e,i=1/0;for(const r of t){const o=Math.abs(r-e);o<i&&(i=o,s=r)}return i<=n?s:e}function Iw(t){const e=t.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(e)?.[1];if(n){const r=(n.length<=4?[...n].map(o=>o+o).join(""):n).match(/../g).map(o=>Number.parseInt(o,16));return r.length>=4?[r[0],r[1],r[2],Math.round(r[3]/255*1e3)/1e3]:[r[0],r[1],r[2]]}const s=(/rgba?\(([^)]+)\)/i.exec(e)?.[1]??"0,0,0").split(/[\s,/]+/).filter(Boolean).map(i=>Number.parseFloat(i));return s.length>=4?[s[0],s[1],s[2],s[3]]:[s[0]??0,s[1]??0,s[2]??0]}const Ow=/^([+-])=\s*(-?[\d.]+)$/,Cw=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function ti(t,e){const n=e.scale??1,s=c=>Number.parseFloat(c)*n;if(t===void 0)return e.cursor;if(typeof t=="number")return t*n;const i=t.trim();if(i==="")return e.cursor;const r=Ow.exec(i);if(r){const c=s(r[2]);return e.cursor+(r[1]==="-"?-c:c)}const o=Cw.exec(i);if(o){const c=o[1]==="<"?e.previousStart:e.previousEnd;if(o[3]===void 0)return c;const h=s(o[3]);return c+(o[2]==="-"?-h:h)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(i);if(a){const c=e.labels.get(a[1].trim());if(c!==void 0){const h=s(a[3]);return c+(a[2]==="-"?-h:h)}}const l=e.labels.get(i);return l!==void 0?l:/^-?[\d.]+$/.test(i)?s(i):e.cursor}function _w(t){if(typeof t!="object"||t===null)return!1;const e=t;return e.grid!==void 0||e.from==="random"||Array.isArray(e.from)||e.ease!==void 0||e.axis!==void 0}function Hw(t,e,n={}){if(t===0)return[];const s=e.grid==="auto"?Math.max(1,Math.min(t,n.columnsFromLayout?.()??t)):Array.isArray(e.grid)?Math.max(1,e.grid[1]):t,i=Array.isArray(e.grid)?Math.max(1,e.grid[0]):Math.ceil(t/s),r=p=>({x:p%s,y:Math.floor(p/s)}),o=e.from??"start",a=Array.isArray(o)?{x:o[0]*(s-1),y:o[1]*(i-1)}:typeof o=="number"?r(Math.max(0,Math.min(t-1,o))):o==="end"?r(t-1):o==="center"||o==="edges"?{x:(s-1)/2,y:(i-1)/2}:{x:0,y:0},l=p=>{const{x:g,y:m}=r(p),y=Math.abs(g-a.x),v=Math.abs(m-a.y);return e.axis==="x"?y:e.axis==="y"?v:Math.hypot(y,v)};let c=Array.from({length:t},(p,g)=>l(g));const h=Math.max(...c);if(o==="edges"&&(c=c.map(p=>h-p)),o==="random"){const p=n.random??Math.random;c=c.map(()=>p()*h)}const u=e.amount!==void 0?e.amount:(e.each??0)*h,d=e.ease?Qs(e.ease):void 0,f=d?d.fn??Wt(d.easing):void 0;return c.map(p=>{const g=h===0?0:p/h;return(f?f(g):g)*u})}const Na=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),Rw={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function pr(t){const e={},n={};for(const[s,i]of Object.entries(t))Na.has(s)?e[s]=i:n[Rw[s]??s]=i;return{config:e,properties:n}}function mr(t,e){return t===void 0?e:t*1e3}function Wa(t,e){if(t!==void 0)return typeof t=="number"?{each:t*1e3}:_w(t)?{offsets:Hw(e?.count??0,t,e??{}).map(s=>s*1e3)}:{...t.each!==void 0&&{each:t.each*1e3},...t.amount!==void 0&&{amount:t.amount*1e3},...t.from!==void 0&&{from:t.from}}}const Lw={opacity:1,x:0,y:0,z:0,rotate:0,rotateX:0,rotateY:0,rotateZ:0,scale:1,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0,originX:50,originY:50,perspective:0,blur:0,glow:0,clipTop:0,clipRight:0,clipBottom:0,clipLeft:0};function pu(t){return Lw[t]}function Fw(t){const e=typeof t=="string"||Array.isArray(t)?{path:t}:t;if(!e||typeof e.path!="string"&&!Array.isArray(e.path))throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");let n;if(Array.isArray(e.path))n=su(e.path,{curviness:e.curviness});else if(jn(e.path))n=e.path;else throw new Error(`gsap-compat: motionPath "${e.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);const s={pathData:n};return e.autoRotate!==void 0&&e.autoRotate!==!1&&(s.autoRotate=!0,typeof e.autoRotate=="number"&&(s.rotateOffset=e.autoRotate)),e.matrix&&(s.matrix=e.matrix),{config:s,start:e.start??0,end:e.end??1}}function Nw(t){const e=typeof t=="string"||Array.isArray(t)?{path:t}:{...t};return{...e,start:e.end??1,end:e.start??0}}function mu(t){return typeof t=="object"&&t!==null&&"shape"in t?t.shape:t}function Ww(t){if(t.morphSVG===void 0)return t;const{morphSVG:e,...n}=t,s=mu(e);if(typeof s!="string"||!jn(s))throw new Error(`gsap-compat: morphSVG "${String(s)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);return{...n,d:s}}function Dw(t,e){if(t===!0)return[0,e];if(t===!1)return[0,0];if(typeof t=="number")return[0,yu(t,e)];const n=t.trim().split(/[\s,]+/).filter(Boolean),s=o=>{const a=Number.parseFloat(o);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${t}" is not a length or percentage`);return yu(o.endsWith("%")?e*a/100:a,e)};if(n.length===0)return[0,e];if(n.length===1)return[0,s(n[0])];const i=s(n[0]),r=s(n[1]);return i<=r?[i,r]:[r,i]}function Bw(t,e){const[n,s]=Dw(t,e);return{strokeDasharray:[s-n,e],strokeDashoffset:-n}}function zw(t,e){if(t.drawSVG===void 0)return t;const{drawSVG:n,...s}=t;return{...s,...Bw(n,e)}}function qw(t){if(t.drawSVG!==void 0)throw new Error("gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties).");return t}function yu(t,e){return Math.max(0,Math.min(e,t))}function jw(t){let e=2166136261;for(let n=0;n<t.length;n++)e=Math.imul(e^t.charCodeAt(n),16777619);return e>>>0}function Yw(t,e,n){if(t.scrambleText!==void 0){const s=t.scrambleText,i=typeof s=="string"?{text:s}:s;if(typeof i?.text!="string")throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");const r=i.revealDelay&&n>0?i.revealDelay*1e3/n:void 0;return{to:i.text,mode:"scramble",...i.chars!==void 0&&{chars:i.chars},...i.speed!==void 0&&{refreshRate:20*i.speed},...r!==void 0&&{revealDelay:Math.min(r,.999)},...i.tweenLength!==void 0&&{tweenLength:i.tweenLength},...i.rightToLeft!==void 0&&{rightToLeft:i.rightToLeft},seed:i.seed??jw(`${e}|${i.text}`)}}if(t.text!==void 0){const s=t.text,i=typeof s=="string"?{value:s}:s;if(typeof i?.value!="string")throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");return{to:i.value,mode:"type",...i.rightToLeft!==void 0&&{rightToLeft:i.rightToLeft}}}}function Da(t){return Math.max(.1,t/25)}function Kw(t,e){const n=typeof e=="number"?{velocity:e}:e;if(typeof n?.velocity!="number"||!Number.isFinite(n.velocity))throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");const s=n.friction??(n.resistance!==void 0?Da(n.resistance):void 0),i={from:t,velocity:n.velocity,...s!==void 0&&{friction:s},...n.min!==void 0&&{min:n.min},...n.max!==void 0&&{max:n.max}};return typeof n.end=="function"?i.end=[n.end(Ds(i))]:n.end!==void 0&&(i.end=Array.isArray(n.end)?[...n.end]:n.end),i}function Xw(t){const e=t===!0?{}:typeof t=="string"?{preset:t}:t;if(e.preset!==void 0&&!(e.preset in er))throw new Error(`gsap-compat: unknown spring preset "${e.preset}" — use one of ${Object.keys(er).join(", ")}`);return{...e.preset?er[e.preset]:{},...e.stiffness!==void 0&&{stiffness:e.stiffness},...e.damping!==void 0&&{damping:e.damping},...e.mass!==void 0&&{mass:e.mass},...e.restDelta!==void 0&&{restDelta:e.restDelta}}}function Gw(t,e){if(t===!0||typeof t=="string")return;const n=t.velocity;return typeof n=="number"?n:n?.[e]}class vn{timeline;options;cursor=0;fallbackRandom=Fa(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(e={}){this.options=e,this.timeline=new Ht({id:e.id??"gsap-compat",name:e.name,config:{...e.repeat!==void 0&&{loop:e.repeat},...e.yoyo!==void 0&&{alternate:e.yoyo},...e.repeatDelay!==void 0&&{repeatDelay:e.repeatDelay*1e3},...e.timeScale!==void 0&&{speed:e.timeScale}}})}to(e,n,s){return this.build(e,void 0,ei(n),s)}from(e,n,s){const{config:i,properties:r}=pr(ei(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(e)[0],u={...i};for(const p of Object.keys(c))u[p]=this.resolveStart(h,p);o!==void 0&&(u.motionPath=Nw(o));const d={},f=String(this.resolveStart(h,"text"));return a!==void 0&&(d.text=Ba(a),u.text=typeof a=="object"?{...a,value:f}:f),l!==void 0&&(d.text=Ba(l),u.scrambleText=typeof l=="object"?{...l,text:f}:f),this.build(e,{...c,...d},u,s)}fromTo(e,n,s,i){const{properties:r}=pr(ei(n));return this.build(e,r,ei(s),i)}set(e,n,s){return this.build(e,void 0,{...ei(n),duration:0},s)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(e){const n=Math.max(0,ti(e,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(e){return ti(e,this.context())}addLabel(e,n){return this.labels.set(e,ti(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((e,n)=>e-n)}labelTime(e){return this.labels.get(e)}add(e,n){const s=ti(n,this.context());for(const r of e.timeline.tracks){if(!("keyframes"in r))continue;const o=ar({...r,id:this.nextTrackId(`nested-${r.id}`),keyframes:r.keyframes.map(a=>({...a,time:a.time+s}))});this.timeline.addTrack(o)}const i=s+e.timeline.duration;return this.previousStart=s,this.previousEnd=i,this.cursor=Math.max(this.cursor,i),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.stop(),this.timeline.play(),this}reverse(){return this.timeline.reverse(),this}kill(){return this.timeline.removeTracks(),this}reset(){return this.timeline.removeTracks(),this.cursor=0,this.previousStart=0,this.previousEnd=0,this.labels.clear(),this.lastValues.clear(),this.trackCounter=0,this}seek(e){if(typeof e=="string"){const n=this.labels.get(e);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(e*1e3),this}progress(e){const n=this.timeline.duration;return e!==void 0&&n>0&&this.timeline.seek(e*n),n>0?this.timeline.currentTime/n:0}timeScale(e){return e!==void 0&&(this.timeline.speed=e),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(e){return this.timeline.tick(e),this}toDefinition(){return this.timeline.toDefinition()}build(e,n,s,i){const{config:r,properties:o}=pr(s),{motionPath:a,text:l,scrambleText:c,inertia:h,...u}=o,d=this.targetsOf(e),f=ti(i,this.context()),p=mr(r.delay,0),g=mr(r.duration,500),m=Wa(r.stagger,{count:d.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(d):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),v=[],k=r.spring;let w=0,T=!1;for(const[P,I]of Object.entries(u)){const O=I;let H=n?.[P]!==void 0?n[P]:this.resolveStart(d[0],P);if(typeof H!=typeof O&&(this.warn(`no usable start value for "${P}" on "${d[0]}" — it will snap to ${String(O)}. Use fromTo() to animate it.`),H=O),k!==void 0&&(typeof H!="number"||typeof O!="number")&&this.warn(`spring works on numbers, so "${P}" on "${d[0]}" eases instead`),k!==void 0&&typeof H=="number"&&typeof O=="number"){const J={...Xw(k),from:H,to:O,velocity:Gw(k,P)??this.options.startVelocity?.(d[0],P)??0},et=this.nextTrackId(`${d[0]}-${P}-spring`),V={id:et,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:P,kind:"spring",spring:J,delay:f+p};this.timeline.addTrack(V),v.push(et),w=Math.max(w,Vh(J));for(const L of d)this.lastValues.set(`${L}|${P}`,O);continue}T=!0;const W=this.keyframesFor(H,O,g,y,r.ease),j=this.nextTrackId(`${d[0]}-${P}`);this.timeline.addTrack(ar({id:j,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:P,delay:f+p,keyframes:W,...P==="quaternion"&&{interpolation:"slerp"}})),v.push(j);for(const J of d)this.lastValues.set(`${J}|${P}`,O)}const A=Yw({text:l,scrambleText:c},d[0],g);if(A){const P=n?.text??n?.scrambleText,I=P!==void 0?Ba(P):this.resolveStart(d[0],"text"),O=this.nextTrackId(`${d[0]}-text`),H={id:O,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:"text",textConfig:{from:typeof I=="string"?I:String(I??""),...A},delay:f+p,keyframes:this.keyframesFor(0,1,g,y,r.ease)};this.timeline.addTrack(H),v.push(O);for(const W of d)this.lastValues.set(`${W}|text`,A.to)}if(a!==void 0){const{config:P,start:I,end:O}=Fw(a),H=this.nextTrackId(`${d[0]}-motionPath`),W={id:H,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:"motionPath",motionPathConfig:P,delay:f+p,keyframes:this.keyframesFor(I,O,g,y,r.ease)};this.timeline.addTrack(W),v.push(H)}if(h!==void 0)for(const[P,I]of Object.entries(h)){const O=this.resolveStart(d[0],P);if(typeof O!="number"){this.warn(`inertia on "${P}" needs a numeric start value; skipped`);continue}const H=Kw(O,I),W=this.nextTrackId(`${d[0]}-${P}-inertia`),j={id:W,target:d[0],...d.length>1&&{targets:d},...m&&d.length>1&&{stagger:m},property:P,kind:"inertia",inertia:H,delay:f+p};this.timeline.addTrack(j),v.push(W),w=Math.max(w,zn(H));for(const J of d)this.lastValues.set(`${J}|${P}`,Bn(H))}const S=((h!==void 0||k!==void 0)&&!T&&!A&&a===void 0?w:Math.max(g,w))+(m&&d.length>1?Ns(d.length,m):0),E=f+p+S;return this.previousStart=f+p,this.previousEnd=E,this.cursor=Math.max(this.cursor,E),{trackIds:v,start:f+p,end:E,kill:()=>{for(const P of v)this.timeline.removeTrack(P)}}}keyframesFor(e,n,s,i,r){const o={time:0,value:e};if(s<=0)return[{time:0,value:n}];const a=typeof r=="string"?Qs(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&Fs(i)){const c=a?.fn??Wt(i);return[o,...va(o,{time:s,value:n},c,{intervalMs:this.options.bakeIntervalMs})]}return[o,{time:s,value:n,...i&&{easing:i}}]}resolveStart(e,n){const s=this.lastValues.get(`${e}|${n}`);if(s!==void 0)return s;const i=this.options.startValue?.(e,n);if(i!==void 0)return i;const r=this.options.defaults?.[n];if(r!==void 0)return r;if(n==="text")return"";if(n==="quaternion")return[0,0,0,1];if(n==="d")throw new Error(`gsap-compat: no starting shape for "${e}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const o=pu(n);return o!==void 0?(this.warn(`no start value for "${n}" on "${e}" — using the static default ${o}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),o):(this.warn(`no start value or default for "${n}" on "${e}" — using 0`),0)}easingFor(e){if(e!==void 0){if(typeof e=="string")return Qs(e).easing;if(typeof e=="function")throw new Error('gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.');return e}}targetsOf(e){return Array.isArray(e)?e:[e]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(e){return this.trackCounter+=1,`${e}-${this.trackCounter}`}warn(e){this.options.onWarning?.(`gsap-compat: ${e}`)}}function Ba(t){if(typeof t=="string")return t;if(t&&typeof t=="object"){const e=t;return String(e.value??e.text??"")}return String(t??"")}function Uw(t){return new vn(t)}function ei(t){return qw(Ww(t))}function Vw(t){return!Array.isArray(t)||t.length!==4?null:`matrix3d(${me(Ye(t)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const Jw=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Zw="#ffffff",Qw="rgba(0, 0, 0, 0.5)";function t2(t){const e=[];if(t.blur!==void 0&&e.push(`blur(${Math.max(0,t.blur)}px)`),t.brightness!==void 0&&e.push(`brightness(${Math.max(0,t.brightness)})`),t.glow!==void 0&&e.push(`drop-shadow(0 0 ${Math.max(0,t.glow)}px ${t.glowColor??Zw})`),t.shadowX!==void 0||t.shadowY!==void 0||t.shadowBlur!==void 0){const n=t.shadowX??0,s=t.shadowY??0,i=Math.max(0,t.shadowBlur??0);e.push(`drop-shadow(${n}px ${s}px ${i}px ${t.shadowColor??Qw})`)}return e.length>0?e.join(" "):null}function e2(t,e){const n=t.childNodes.length===1?t.firstChild:null;if(n&&n.nodeType===3){const s=n;s.data!==e&&(s.data=e);return}t.textContent!==e&&(t.textContent=e)}function n2(t){if(!("ownerSVGElement"in t))return;const e=t.style;!e||e.transformBox||(e.transformBox="fill-box",e.transformOrigin||(e.transformOrigin="50% 50%"))}const bu=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),s2=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),i2=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],r2=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),o2=new Set(["originX","originY"]),a2=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),l2=new Set(["drawOn"]),c2={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},wu={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},h2="http://www.w3.org/2000/svg";class Mn{targets=new Map;registerTarget(e,n){this.targets.set(e,n)}unregisterTarget(e){this.targets.delete(e)}getTarget(e){return this.targets.get(e)}clearTargets(){this.targets.clear()}applyState(e){for(const[n,s]of e.values){const i=this.targets.get(n);i&&this.applyProperties(i,s)}}applyProperties(e,n){let s=null,i=null,r=null,o=null,a=null;const l=n.has("motionPathX"),c=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[p,g]of n)if(!(p==="x"&&l)&&!(p==="y"&&c)&&!((p==="rotate"||p==="rotateZ")&&h)&&!l2.has(p)){if(s2.has(p))(s??={})[p]=g;else if(r2.has(p))typeof g=="number"&&((i??={})[p]=g);else if(o2.has(p))typeof g=="number"&&((r??={})[p]=g);else if(a2.has(p))typeof g=="number"&&((o??={})[p]=g);else if(Jw.has(p))(a??={})[p]=g;else if(p!=="perspective"){if(p!=="shine")if(p==="text"&&typeof g=="string")e2(e,g);else if(p==="d"&&typeof g=="string"){const m=e;(m.tagName?.toLowerCase()==="path"?m:m.querySelector?.("path"))?.setAttribute?.("d",g)}else this.applyStyleProperty(e,p,g)}}const u=n.get("shine");typeof u=="number"&&this.applyShine(e,u);const d=[],f=n.get("perspective");if(typeof f=="number"&&f>0&&d.push(`perspective(${f}px)`),s)for(const p of i2){const g=s[p];if(g===void 0)continue;const m=this.buildTransformPart(p,g);m&&d.push(m)}if(d.length>0&&(e.style.transform=d.join(" "),n2(e)),i&&(i.childPerspective!==void 0&&(e.style.perspective=`${i.childPerspective}px`),(i.perspectiveOriginX!==void 0||i.perspectiveOriginY!==void 0)&&(e.style.perspectiveOrigin=`${i.perspectiveOriginX??50}% ${i.perspectiveOriginY??50}%`)),r){const p=r.originX??50,g=r.originY??50;e.style.transformOrigin=`${p}% ${g}%`}if(o){const p=o.clipTop??0,g=o.clipRight??0,m=o.clipBottom??0,y=o.clipLeft??0;e.style.clipPath=`inset(${p}% ${g}% ${m}% ${y}%)`}if(a){const p=t2(a);p&&(e.style.filter=p)}}buildTransformPart(e,n){if(e==="quaternion")return Vw(n);if(typeof n!="number")return null;switch(e){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(e,n){e.dataset.shineBase||(e.dataset.shineBase=e.style.color||"currentColor");const s=e.dataset.shineBase,i=-20+n*140,r=e.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${s}, ${s})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${i}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(e,n,s){let i;if(e.namespaceURI===h2&&n in wu){const a=Array.isArray(s)?s.join(", "):String(s);e.style[wu[n]]=a;return}else n==="fill"&&e.dataset?.elementType==="text"?i="color":i=c2[n]??n;let o;typeof s=="number"?bu.has(n)||bu.has(i)?o=`${s}px`:o=String(s):Array.isArray(s)?o=s.join(", "):o=s,e.style[i]=o}}const u2={request:t=>requestAnimationFrame(t),cancel:t=>cancelAnimationFrame(t)};class ku{adapter=new Mn;scheduler;rootOption;onWarning;names=new WeakMap;elements=new Map;nameCounter=0;objectNames=new WeakMap;objects=new Map;owned=new Set;currentCollector;tickerCallbacks=new Set;tickerTime=0;tickerFrame=0;liveTimelines=new Set;utils=$w();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(e={}){this.scheduler=e.scheduler??u2,this.rootOption=e.root,this.onWarning=e.onWarning}get root(){return this.rootOption??document}resolveTargets(e){const n=[];for(const s of this.targetsOf(e)){const i=this.nameFor(s);za(s)&&this.currentCollector?.touch(s,i),n.push(i)}return n}query(e){return this.selectorRoot.querySelector(e)}get collector(){return this.currentCollector}setCollector(e){this.currentCollector=e}forget(e){this.applied.delete(e),this.dirty.delete(e)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(e){return this.elements.get(e)}objectFor(e){return this.objects.get(e)}appliedValue(e,n){return this.applied.get(e)?.get(n)}velocityOf(e,n){for(const i of[...this.active.keys()].reverse()){if(i.getTracks({target:e,property:n}).length===0)continue;const r=i.currentTime;if(r<4)return 0;const o=i.getStateAtTime(r).values.get(e)?.get(n),a=i.getStateAtTime(r-4).values.get(e)?.get(n);if(typeof o!="number"||typeof a!="number")return;const l=(o-a)/4;return(i.direction==="reverse"?-l:l)*1e3}}ticker={add:e=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(e),this.currentCollector?.track({revert:()=>this.ticker.remove(e)}),this.startLoop())},remove:e=>{this.tickerCallbacks.delete(e),this.running||this.stopLoop()}};activate(e,n={}){this.destroyed||(e.onUpdate=s=>this.write(s),this.active.delete(e),this.active.set(e,n),this.startLoop())}deactivate(e){this.active.delete(e),this.running||this.stopLoop()}own(e){return this.destroyed?e.destroy():this.owned.add(e),e}destroy(){this.destroyed=!0;for(const e of this.owned)e.destroy();this.owned.clear();for(const e of this.active.keys())e.stop();this.active.clear(),this.stopLoop(),this.adapter.clearTargets(),this.elements.clear(),this.names=new WeakMap,this.objects.clear(),this.objectNames=new WeakMap,this.tickerCallbacks.clear(),this.liveTimelines.clear(),this.applied.clear(),this.dirty.clear()}apply(e,n){if(this.destroyed)return;const s=new Map(Object.entries(n));this.write({values:new Map([[e,s]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(e){this.destroyed||(this.write(e.getStateAtTime(e.currentTime)),this.flush())}tick(e){const n=[...this.active];for(const[s]of n)s.duration<=0?(this.write(s.getStateAtTime(0)),s.stop()):s.tick(e);this.flush();for(const[s,i]of n)i.onUpdate?.(),s.playbackState!=="playing"&&this.active.get(s)===i&&this.active.delete(s);this.flush(),this.runTicker(e),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(e){if(this.tickerCallbacks.size!==0){this.tickerTime+=e,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,e,this.tickerFrame)}}write(e){for(const[n,s]of e.values){let i=this.applied.get(n);i||(i=new Map,this.applied.set(n,i));for(const[r,o]of s)i.set(r,o);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const e=new Map;for(const n of this.dirty){const s=this.applied.get(n),i=this.objects.get(n);if(i)for(const[r,o]of s)i[r]=o;else e.set(n,s)}this.dirty.clear(),e.size!==0&&this.adapter.applyState({values:e,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=e=>{this.frameId=null;const n=this.lastTimestamp===null?0:e-this.lastTimestamp;this.lastTimestamp=e,n>0&&this.tick(n),this.running&&this.frameId===null&&(this.frameId=this.scheduler.request(this.frame))};startLoop(){this.frameId===null&&(this.lastTimestamp=null,this.frameId=this.scheduler.request(this.frame))}stopLoop(){this.frameId!==null&&this.scheduler.cancel(this.frameId),this.frameId=null,this.lastTimestamp=null}targetsOf(e){if(typeof e=="string")return Array.from(this.selectorRoot.querySelectorAll(e));if(za(e))return[e];if(!d2(e))return[e];const n=[];for(const s of Array.from(e))n.push(...this.targetsOf(s));return n}nameFor(e){return za(e)?this.elementName(e):this.objectName(e)}objectName(e){const n=this.objectNames.get(e);if(n)return n;let s;do this.nameCounter+=1,s=`obj-${this.nameCounter}`;while(this.objects.has(s)||this.elements.has(s));return this.objectNames.set(e,s),this.objects.set(s,e),s}elementName(e){const n=this.names.get(e);if(n)return n;let s=e.id?`#${e.id}`:"";if(!s||this.elements.has(s))do this.nameCounter+=1,s=`el-${this.nameCounter}`;while(this.elements.has(s));return this.names.set(e,s),this.elements.set(s,e),this.adapter.registerTarget(s,e),s}}function za(t){return typeof t=="object"&&t!==null&&t.nodeType===1}function d2(t){if(Array.isArray(t))return!0;const e=t;return typeof e.length=="number"&&typeof e.item=="function"}function yr(t){const e=t.style;if(!e)return t.getBoundingClientRect();const n=e.transform;e.transform="none";const s=t.getBoundingClientRect();return e.transform=n,s}const vu=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function f2(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function g2(t){const e=t.getScreenCTM?.();if(e)return[e.a,e.b,e.c,e.d,e.e,e.f];const n=t.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function p2(t,e){const n=typeof t=="string"||Array.isArray(t)||vu(t)?{path:t}:t,{align:s,alignOrigin:i,path:r,...o}=n,a=A=>{const M=vu(A)?A:e.query(A);return M||e.warn(`gsap-compat: motionPath could not find "${String(A)}"`),M};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&jn(r))c=r;else{l=a(r);const A=l&&cr({tag:l.localName,attributes:f2(l)});l&&!A&&e.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=A??""}const h={...o,path:c};if(s===void 0||s===!1)return h;const u=s===!0?l:a(s);if(!u)return s===!0&&e.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const d=e.targets[0];if(!d)return h;const[f,p,g,m,y,v]=g2(u),k=yr(d),[w,T]=i??[.5,.5];for(const A of e.targets.slice(1)){const M=yr(A);if(Math.abs(M.left-k.left)>.5||Math.abs(M.top-k.top)>.5){e.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[f,p,g,m,y-k.left-w*k.width,v-k.top-T*k.height],h}const Mu=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function Su(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function xu(t){if(!t)return null;const e=cr({tag:t.localName,attributes:Su(t)});return e||(t.querySelector("path")?.getAttribute("d")??null)}function m2(t,e,n){const s=mu(t);if(typeof s=="string"&&jn(s))return s;const i=Mu(s)?s:typeof s=="string"?e(s):null,r=xu(i);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(s)}"`),"")}const y2=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function b2(t,e=document){return(typeof t=="string"?Array.from(e.querySelectorAll(t)):Mu(t)?[t]:Array.from(t)).map(s=>{if(s.localName==="path")return s;const i=cr({tag:s.localName,attributes:Su(s)});if(!i||!s.parentNode)return s;const r=s.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const o of Array.from(s.attributes))y2.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",i),s.parentNode.replaceChild(r,s),r})}const Tu=.3;class Eu{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(e){this.options=e,this.target=e.target}start(){if(this.running)return;this.running=!0;const e=this.options.type??["pointer","touch"];e.includes("pointer")&&(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerUp)),e.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),e.includes("wheel")&&this.target.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){this.running&&(this.running=!1,this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerUp),this.target.removeEventListener("touchstart",this.onTouchStart),this.target.removeEventListener("touchmove",this.onTouchMove),this.target.removeEventListener("touchend",this.onTouchEnd),this.target.removeEventListener("wheel",this.onWheel))}destroy(){this.stop()}get velocity(){return{x:this.velocityX,y:this.velocityY}}begin(e,n,s){this.dragging=!0,this.passedTolerance=!1,this.startX=e,this.startY=n,this.lastX=e,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=Au(),this.options.onPress?.(this.stateFrom(0,0,s))}move(e,n,s){if(!this.dragging)return;const i=e-this.lastX,r=n-this.lastY;this.lastX=e,this.lastY=n;const o=e-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(o,a)<l)return;this.passedTolerance=!0}this.updateVelocity(i,r),this.options.preventDefault!==!1&&s.cancelable&&s.preventDefault(),this.options.onMove?.(this.stateFrom(i,r,s))}end(e){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,e)))}updateVelocity(e,n){const s=Au(),i=Math.max(1,s-this.lastTime);this.lastTime=s;const r=e/i*1e3,o=n/i*1e3;this.velocityX+=(r-this.velocityX)*Tu,this.velocityY+=(o-this.velocityY)*Tu}stateFrom(e,n,s){return{deltaX:e,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:s}}onPointerDown=e=>{const n=e,s=this.target;if(typeof n.pointerId=="number"&&typeof s.setPointerCapture=="function")try{s.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,e)};onPointerMove=e=>{const n=e;this.move(n.clientX,n.clientY,e)};onPointerUp=e=>this.end(e);onTouchStart=e=>{const n=e.touches[0];n&&this.begin(n.clientX,n.clientY,e)};onTouchMove=e=>{const n=e.touches[0];n&&this.move(n.clientX,n.clientY,e)};onTouchEnd=e=>this.end(e);onWheel=e=>{const n=e;this.options.preventDefault!==!1&&n.cancelable&&n.preventDefault(),this.updateVelocity(n.deltaX,n.deltaY),this.options.onMove?.({deltaX:n.deltaX,deltaY:n.deltaY,velocityX:this.velocityX,velocityY:this.velocityY,totalX:0,totalY:0,isDragging:!1,event:e})}}function Au(){return typeof performance<"u"?performance.now():Date.now()}function Pu(t,e,n){let s={delta:0,line:null},i=n;for(const r of t)for(const o of e){const a=Math.abs(o-r);a<=i&&(i=a,s={delta:o-r,line:o})}return s}function $u(t,e){return e<=0?[]:t.map(n=>Math.round(n/e)*e)}class qa{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(e){this.options=e,this.x=e.initialX??0,this.y=e.initialY??0,this.observer=new Eu({target:e.target,onPress:n=>{const s=e.getPosition?.();s&&(this.x=s.x,this.y=s.y),this.originX=this.x,this.originY=this.y,e.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>e.onRelease?.(n)})}start(){this.observer.start()}stop(){this.observer.stop()}destroy(){this.observer.destroy()}get position(){return{x:this.x,y:this.y}}get velocity(){return this.observer.velocity}setPosition(e,n){const s=this.options.axis??"both";this.x=s==="y"?this.x:this.applyConstraints(e,"x"),this.y=s==="x"?this.y:this.applyConstraints(n,"y")}get snapLines(){return{x:this.snappedX,y:this.snappedY}}snapThreshold(){if(this.options.snapThreshold!==void 0)return this.options.snapThreshold;const e=this.options.snap??0;return e>0?e/2:8}handleMove(e){this.setPosition(this.originX+e.totalX,this.originY+e.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,e),this.options.onSnap?.(this.snapLines)}scrub(){const e=this.options.timeline;if(!e)return;const n=e.duration;if(n<=0)return;const s=this.options.scrubDistance??500;if(s===0)return;const i=(this.options.axis??"both")==="y"?this.y:this.x,r=w2(i/s);e.pause(),e.seek(r*n)}applyConstraints(e,n){let s=e;const i=[...$u([s],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=Pu([s],i,this.snapThreshold());s+=r.delta,n==="x"?this.snappedX=r.line:this.snappedY=r.line;const o=this.options.bounds;if(o){const a=n==="x"?o.minX:o.minY,l=n==="x"?o.maxX:o.maxY;a!==void 0&&(s=Math.max(a,s)),l!==void 0&&(s=Math.min(l,s))}return s}}function w2(t){return t<0?0:t>1?1:t}function k2(t){const e=new qa(t);return e.start(),e}const v2={x:"x",y:"y","x,y":"both"},ja=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function Iu(t,e){const n=yr(t),s=e.getBoundingClientRect();return{minX:s.left-n.left,maxX:s.right-n.right,minY:s.top-n.top,maxY:s.bottom-n.bottom}}function Ou(t){return Array.isArray(t)?[...t]:t}function M2(t,e,n,s={}){const[i]=e.resolveTargets(n),r=i?e.elementFor(i):void 0;if(!i||!r)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(s.type==="rotation")return S2(t,e,i,r,s);const o=v2[s.type??"x,y"],a=()=>{const g=e.appliedValue(i,"x"),m=e.appliedValue(i,"y");return{x:typeof g=="number"?g:0,y:typeof m=="number"?m:0}},l=typeof s.bounds=="string"?e.query(s.bounds):ja(s.bounds)?s.bounds:null,h={bounds:(!l&&s.bounds&&!ja(s.bounds)?s.bounds:void 0)??(l?Iu(r,l):void 0)};let u=null;const d=()=>{u?.kill(),u=null},f=g=>{const m=s.inertia===!0?{}:s.inertia,y=m.friction??(m.resistance!==void 0?Da(m.resistance):4),v=a(),k=h.bounds??{};let w,T;const A=m.end;if(Array.isArray(A)){const x=Ds({from:v.x,velocity:o==="y"?0:g.x,friction:y}),S=Ds({from:v.y,velocity:o==="x"?0:g.y,friction:y});let E=A[0];for(const P of A)Math.hypot(P.x-x,P.y-S)<Math.hypot(E.x-x,E.y-S)&&(E=P);E&&(w=[E.x],T=[E.y])}else typeof A=="number"?(w=A,T=A):A&&(w=Ou(A.x),T=Ou(A.y));const M={};o!=="y"&&(M.x={velocity:g.x,friction:y,min:k.minX,max:k.maxX,end:w}),o!=="x"&&(M.y={velocity:g.y,friction:y,min:k.minY,max:k.maxY,end:T}),u=t.to(r,{inertia:M,onComplete:()=>s.onThrowComplete?.()})},p=new qa({target:r,axis:o,snap:s.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{d(),l&&(h.bounds=Iu(r,l)),s.onPress?.()},onDrag:g=>{e.apply(i,o==="x"?{x:g.x}:o==="y"?{y:g.y}:{x:g.x,y:g.y}),s.onDrag?.(g)},onRelease:()=>{const g=p.velocity;s.onRelease?.(g),s.inertia&&f(g)}});return p.start(),{draggable:p,get position(){return a()},get rotation(){const g=e.appliedValue(i,"rotate");return typeof g=="number"?g:0},destroy(){d(),p.destroy()}}}function S2(t,e,n,s,i){const r=typeof i.bounds=="object"&&i.bounds!==null&&!ja(i.bounds)?i.bounds:{},o=()=>{const k=e.appliedValue(n,"rotate");return typeof k=="number"?k:0},a=k=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,k));let l=null,c=!1,h,u={x:0,y:0},d=0,f=0,p=[];const g=k=>Math.atan2(k.clientY-u.y,k.clientX-u.x)*180/Math.PI,m=k=>{if(c)return;l?.kill(),l=null,c=!0,h=k.pointerId,s.setPointerCapture?.(k.pointerId);const w=s.getBoundingClientRect();u={x:w.left+w.width/2,y:w.top+w.height/2},d=g(k),f=o(),p=[{time:performance.now(),rotation:f}],i.onPress?.()},y=k=>{if(!c||k.pointerId!==h)return;const w=g(k);let T=w-d;T>180&&(T-=360),T<-180&&(T+=360),d=w,f+=T;let A=a(f);i.snap&&(A=a(Math.round(A/i.snap)*i.snap)),e.apply(n,{rotate:A});const M=performance.now();for(p.push({time:M,rotation:A});p.length>2&&M-p[0].time>100;)p.shift();const x={x:0,y:0};i.onDrag?.(x)},v=k=>{if(!c||k.pointerId!==h)return;c=!1;const w=p[0],T=p[p.length-1],A=w&&T?(T.time-w.time)/1e3:0,M=A>0?(T.rotation-w.rotation)/A:0;if(i.onRelease?.({x:M,y:0}),!i.inertia)return;const x=i.inertia===!0?{}:i.inertia,S=x.friction??(x.resistance!==void 0?Da(x.resistance):4),E=typeof x.end=="number"||Array.isArray(x.end)?x.end:void 0;l=t.to(s,{inertia:{rotate:{velocity:M,friction:S,min:r.minRotation,max:r.maxRotation,end:Array.isArray(E)?E.filter(P=>typeof P=="number"):E}},onComplete:()=>i.onThrowComplete?.()})};return s.addEventListener("pointerdown",m),s.addEventListener("pointermove",y),s.addEventListener("pointerup",v),s.addEventListener("pointercancel",v),s.style.touchAction="none",{draggable:void 0,position:{x:0,y:0},get rotation(){return o()},destroy(){l?.kill(),s.removeEventListener("pointerdown",m),s.removeEventListener("pointermove",y),s.removeEventListener("pointerup",v),s.removeEventListener("pointercancel",v)}}}const x2={opacity:0,scale:.6};function T2(t){const e=t.getBoundingClientRect();return e.width===0&&e.height===0?null:{cx:e.left+e.width/2,cy:e.top+e.height/2,width:e.width,height:e.height}}function Cu(t){const e=yr(t);return e.width===0&&e.height===0?null:{cx:e.left+e.width/2,cy:e.top+e.height/2,width:e.width,height:e.height}}function Ya(t,e){const s=t.resolveTargets(e).map(o=>t.elementFor(o)).filter(o=>!!o),i=new Map,r=new Map;for(const o of s){const a=T2(o);i.set(o,a);const l=_u(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:s,boxes:i,ids:r}}const Ka=new WeakMap;function Xa(t,e,n,s={}){const i=s.duration??.6,r=s.ease??"power2.inOut",o=s.stagger??0,a=s.scale!==!1,l=s.enter===void 0?x2:s.enter,c=new Set(n.elements);if(s.targets!==void 0)for(const f of t.resolveTargets(s.targets)){const p=t.elementFor(f);p&&c.add(p)}const h=[...c].sort((f,p)=>f===p?0:f.compareDocumentPosition(p)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),u=e({onComplete:s.onComplete});let d=0;for(const f of h){const p=Cu(f);if(!p)continue;let g=n.boxes.get(f)??null,m;const y=_u(f),v=!g&&y!==void 0?n.ids.get(y):void 0;v&&v.element!==f&&(g=v.box,m=v.element);const[k]=t.resolveTargets(f);Ka.get(f)?.timeline.removeTracks({target:k});const w=d*o;if(!g){if(l===!1)continue;u.fromTo(f,{x:0,y:0,scaleX:1,scaleY:1,...l},{...Hu(l),x:0,y:0,scaleX:1,scaleY:1,duration:i,ease:r,delay:w},0),Ka.set(f,u),d++;continue}const T=g.cx-p.cx,A=g.cy-p.cy,M=a?g.width/p.width:1,x=a?g.height/p.height:1;if(!(Math.abs(T)>.5||Math.abs(A)>.5||Math.abs(M-1)>.001||Math.abs(x-1)>.001)){const P=(I,O)=>{const H=t.appliedValue(k,I);return typeof H=="number"&&Math.abs(H-O)>1e-6};(P("x",0)||P("y",0)||P("scaleX",1)||P("scaleY",1))&&u.set(f,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const E=s.fade===!0&&m!==void 0;u.fromTo(f,{x:T,y:A,scaleX:M,scaleY:x,...E&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...E&&{opacity:1},duration:i,ease:r,delay:w},0),E&&m&&Cu(m)&&u.fromTo(m,{opacity:1},{opacity:0,duration:i,ease:r,delay:w},0),Ka.set(f,u),d++}return u}function _u(t){return t.dataset?.flipId}function Hu(t){const e={};for(const n of Object.keys(t))e[n]=n==="opacity"||n.startsWith("scale")?1:0;return e}function E2(t,e={}){const n=new Set((e.type??"chars,words,lines").split(",").map(g=>g.trim())),s={chars:e.charsClass??"char",words:e.wordsClass??"word",lines:e.linesClass??"line"},i=e.aria!==!1,r=t.map(g=>({element:g,html:g.innerHTML,ariaLabel:g.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:g,html:m,ariaLabel:y}of r)g.innerHTML=m,y===null?g.removeAttribute("aria-label"):g.setAttribute("aria-label",y)},u=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},d=()=>{const g={chars:[],words:[],lines:[],masks:[]};for(const{element:m}of r){const y=(m.textContent??"").replace(/\s+/g," ").trim(),v=A2(m,s.words),k=n.has("chars")?v.flatMap(A=>P2(A,s.chars)):[],w=n.has("lines")?I2(m,v,s.lines):[];if(i){!m.hasAttribute("aria-label")&&y&&m.setAttribute("aria-label",y);for(const A of v)A.setAttribute("aria-hidden","true")}if(n.has("words"))g.words.push(...v);else for(const A of v)A.removeAttribute("class");g.chars.push(...k),g.lines.push(...w);const T=e.mask==="lines"?w:e.mask==="words"?v:e.mask==="chars"?k:[];for(const A of T)g.masks.push(O2(A,`${s[e.mask]}-mask`))}o=g},f={elements:t,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(u(),h(),d(),a=e.onSplit?.(f))},revert(){c=!0,l?.disconnect(),u(),h()}};d(),a=e.onSplit?.(f),e.autoSplit&&p();function p(){const g=new Map;let m=!1;const y=()=>{if(m)return;m=!0;const k=()=>{m=!1,f.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(k):setTimeout(k,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(k=>{let w=!1;for(const T of k){const A=Math.round(T.contentRect.width),M=g.get(T.target);g.set(T.target,A),M!==void 0&&M!==A&&(w=!0)}w&&y()});for(const k of t)l.observe(k)}const v=t[0]?.ownerDocument?.fonts;v&&v.status!=="loaded"&&v.ready.then(()=>y())}return f}function A2(t,e){const n=t.ownerDocument,s=[],i=n.createTreeWalker(t,4),r=[];for(let o=i.nextNode();o;o=i.nextNode())r.push(o);for(const o of r){const a=o.data.match(/\s+|\S+/g)??[];if(a.length===0)continue;const l=n.createDocumentFragment();for(const c of a){if(/^\s/.test(c)){l.appendChild(n.createTextNode(c));continue}const h=n.createElement("span");h.className=e,h.style.display="inline-block",h.textContent=c,l.appendChild(h),s.push(h)}o.replaceWith(l)}return s}function P2(t,e){const n=t.ownerDocument,s=$2(t.textContent??"").map(i=>{const r=n.createElement("span");return r.className=e,r.style.display="inline-block",r.textContent=i,r});return t.replaceChildren(...s),s}function $2(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),n=>n.segment):Array.from(t)}function I2(t,e,n){const s=t.ownerDocument,i=new Map(e.map(p=>[p,p.getBoundingClientRect()])),r=[],o=p=>{for(const g of Array.from(p.childNodes))g.nodeType===3||i.has(g)||g.tagName==="BR"?r.push(g):o(g)};o(t);const a=[];let l=null,c=0,h=0,u=!1,d=[];const f=()=>{l=s.createElement("span"),l.className=n,l.style.display="block",a.push(l),d=[]};for(const p of r){if(p.tagName==="BR"){u=!0;continue}const g=i.get(p);if(g&&(!l||u||g.top>c+h)&&(f(),c=g.top,h=g.height/2,u=!1),!l)continue;const m=[];for(let k=p.parentNode;k&&k!==t;k=k.parentNode)m.unshift(k);let y=0;for(;y<d.length&&y<m.length&&d[y].original===m[y];)y++;d.length=y;let v=y===0?l:d[y-1].clone;for(const k of m.slice(y)){const w=k.cloneNode(!1);v.appendChild(w),d.push({original:k,clone:w}),v=w}v.appendChild(p)}return t.replaceChildren(...a),a}function O2(t,e){const n=t.ownerDocument.createElement("span");return n.className=e,n.style.display=t.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",t.replaceWith(n),n.appendChild(t),n}const Ru={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function Ga(t){const e=t.trim().toLowerCase();if(e in Ru)return Ru[e];if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function Ua(t){if(typeof t=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:t};let e=0;const s=t.replace(/([+-])=\s*(-?[\d.]+)/g,(o,a,l)=>(e+=(a==="-"?-1:1)*Number.parseFloat(l),"")).trim().split(/\s+/).filter(Boolean);if(s.length===1&&/^-?[\d.]+$/.test(s[0]))return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:Number.parseFloat(s[0])+e};const i=s[0]!==void 0?Ga(s[0]):void 0,r=s[1]!==void 0?Ga(s[1]):void 0;return{elementFraction:i??0,viewportFraction:r??0,offsetPx:e}}function Un(t,e,n){const s=Ua(n),i=s.absolutePx!==void 0?t.top+s.absolutePx:t.top+t.height*s.elementFraction,r=e*s.viewportFraction;return i-r+s.offsetPx}function C2(t,e,n,s){const i=Un(t,e,n),o=Un(t,e,s)-i;return o<=0?i<=0?1:0:Va(-i/o)}function Va(t){return t<0?0:t>1?1:t===0?0:t}function Lu(t,e,n,s){if(n<=0)return e;const i=1-Math.exp(-(s/1e3)/n);return t+(e-t)*i}function Ja(t,e,n,s,i){const r=h=>Un({top:t+i(h),bottom:t+i(h)+e,height:e},n,s),o=r(0),a=r(1);if(Math.sign(o)===Math.sign(a)||o===0||a===0)return o===0?0:a===0?1:Math.abs(o)<Math.abs(a)?0:1;let l=0,c=1;for(let h=0;h<40;h++){const u=(l+c)/2;Math.sign(r(u))===Math.sign(o)?l=u:c=u}return(l+c)/2}class Fu{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(e){this.timeline=e.timeline,this.trigger=e.trigger,this.behaviour=e.behaviour??"once",this.options=e}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(e=>{for(const n of e)n.isIntersecting?this.enter():this.leave()},{threshold:this.options.threshold??.15,rootMargin:this.options.rootMargin,root:this.options.root??null}),this.observer.observe(this.trigger)}}stop(){this.running=!1,this.observer?.disconnect(),this.observer=null}destroy(){this.stop()}reset(){this.hasPlayed=!1,this.timeline.stop()}enter(){this.options.onEnter?.(),!(this.behaviour==="once"&&this.hasPlayed)&&(this.hasPlayed=!0,this.behaviour!=="once"&&this.timeline.seek(0),this.timeline.play())}leave(){this.options.onLeave?.(),this.behaviour==="reset"&&this.timeline.stop()}}function _2(t){const e=new Fu(t);return e.start(),e}class Nu{element;spacer;saved;axis;spacing;constructor(e,n={}){this.element=e,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const s=e.ownerDocument;this.spacer=s.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:e.style.position,top:e.style.top,left:e.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),e.replaceWith(this.spacer),this.spacer.appendChild(e)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(e,n){const s=Math.max(0,n);this.element.style.position="sticky",this.axis==="x"?(this.spacer.style.width=`${this.element.offsetWidth+s}px`,this.spacer.style.marginRight=this.spacing?"":`-${s}px`,this.element.style.left=`${e}px`):(this.spacer.style.height=`${this.element.offsetHeight+s}px`,this.spacer.style.marginBottom=this.spacing?"":`-${s}px`,this.element.style.top=`${e}px`)}destroy(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left,this.spacer.parentNode&&this.spacer.replaceWith(this.element)}}const H2=.15;function Wu(t){return typeof t=="object"&&!Array.isArray(t)?t:{snapTo:t}}function Du(t,e,n){const s=br(t+e*H2);if(typeof n=="function")return br(n(s));if(typeof n=="number")return n<=0?t:br(Math.round(s/n)*n);if(n.length===0)return t;let i=n[0];for(const r of n)Math.abs(r-s)<Math.abs(i-s)&&(i=r);return br(i)}function Bu(t,e,n){const s=t.duration??{min:.2,max:.8};if(typeof s=="number")return s;const i=Math.min(1,Math.abs(e)/Math.max(1,n));return s.min+(s.max-s.min)*i}class zu{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(e,n){this.write=e,this.eventTarget=n}get active(){return this.rafId!==null}animate(e,n,s,i=Bs,r){if(this.cancel(),typeof requestAnimationFrame>"u"||s<=0){this.write(n),r?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let o=null;const a=l=>{o??=l;const c=Math.min(1,(l-o)/(s*1e3));this.write(e+(n-e)*i(c)),c<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),r?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const e of this.cancelEvents)this.eventTarget?.removeEventListener(e,this.onInterrupt)}}function br(t){return Math.max(0,Math.min(1,t))}class qu{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(e,n,s){this.options=s===!0?{}:s,this.scroller=n;const{startColor:i="#3ecf7a",endColor:r="#ff5a5a",id:o}=this.options,a=o?`${o} `:"",l=(c,h,u)=>{const d=e.createElement("div");return d.textContent=`${a}${c}`,d.setAttribute("aria-hidden","true"),d.className="scroll-marker",Object.assign(d.style,{position:u?"fixed":"absolute",right:`${this.options.indent??0}px`,zIndex:"2147483646",pointerEvents:"none",borderTop:`1px solid ${h}`,color:h,font:`${this.options.fontSize??"11px"} ui-monospace, monospace`,padding:"2px 6px",whiteSpace:"nowrap",background:"rgba(0, 0, 0, 0.35)"}),(n??e.body).appendChild(d),this.nodes.push(d),d};this.scrollerStart=l("scroller-start",i,!n),this.scrollerEnd=l("scroller-end",r,!n),this.start=l("start",i,!1),this.end=l("end",r,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(e,n){this.start.style.top=`${e.startPage}px`,this.end.style.top=`${e.endPage}px`;const s=this.scroller?n:0;this.scrollerStart.style.top=`${s+e.startViewport}px`,this.scrollerEnd.style.top=`${s+e.endViewport}px`}follow(e,n){this.scroller&&this.place(e,n)}destroy(){for(const e of this.nodes.splice(0))e.remove()}}const R2=120,Vn=[],Jn=new Set;let Za=!1;const L2=()=>{Za||Jn.size===0||(Za=!0,queueMicrotask(()=>{Za=!1;for(const t of Jn)t.afterRefresh()}))},ju=()=>{for(const t of Jn)t.beforeRefresh();for(const t of Vn)t.refresh();for(const t of Jn)t.afterRefresh()};let Zn={width:0,height:0};const Yu=()=>{const t=window.innerWidth,e=window.innerHeight,n=t===Zn.width&&e!==Zn.height,s=Math.abs(e-Zn.height)<Zn.height*.25,i=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&s&&i||(Zn={width:t,height:e},ju())};class ni{timeline;options;running=!1;pin=null;startPx=0;endPx=0;targetProgress=0;displayProgress=0;zone="before";measured=!1;lastScroll=null;lastScrollTime=0;velocityPxPerSecond=0;idleTimer=null;lastEmitted=null;rafId=null;lastFrameTime=null;onScroll=()=>this.update();releaseVelocity=0;snapper;snapTimer=null;markers=null;markerGeometry=null;constructor(e){this.timeline=e.timeline,this.options=e,this.snapper=new zu(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const e=this.options.pin===!0?this.options.trigger:this.options.pin||null;e&&!this.options.container&&(this.pin=new Nu(e,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new qu(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Vn.length===0&&typeof window<"u"&&(Zn={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Yu,{passive:!0})),Vn.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Vn.splice(Vn.indexOf(this),1),Vn.length===0&&typeof window<"u"&&window.removeEventListener("resize",Yu),this.stopSmoothing(),this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null,this.snapTimer!==null&&clearTimeout(this.snapTimer),this.snapTimer=null,this.snapper.cancel())}destroy(){this.stop(),this.pin?.destroy(),this.pin=null,this.markers?.destroy(),this.markers=null}get startOffset(){return this.startPx}get endOffset(){return this.endPx}static refreshAll(){ju()}static onRefresh(e){return Jn.add(e),()=>Jn.delete(e)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const e=this.scrollPosition();this.pin?.release();const n=this.triggerRect();if(n&&this.options.container)this.measureInContainer(this.options.container);else if(n){const s=this.viewportHeight();if(this.startPx=e+Un(n,s,si(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,s,e),this.pin){const i=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(i.top-(this.startPx-e),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(s):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,e),this.lastScroll=null,this.updateFrom(e,!this.measured),this.measured=!0,L2()}sample(){this.refresh()}update(e){this.running&&this.updateFrom(e??this.scrollPosition(),!1)}updateFrom(e,n){this.trackVelocity(e),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,e);const s=this.endPx-this.startPx,i=this.zone;this.targetProgress=s>0?Va((e-this.startPx)/s):e>=this.startPx?1:0,this.zone=s>0?e<=this.startPx?"before":e>=this.endPx?"after":"active":e>=this.startPx?"after":"before",this.fireBoundaryCallbacks(i,this.zone),n||this.smoothing()<=0?(this.displayProgress=this.targetProgress,this.applyProgress()):(this.emitUpdate(),this.startSmoothing())}smoothing(){const e=this.options.scrub;return typeof e=="number"?Math.max(0,e):0}resolveEnd(e,n,s){const i=si(this.options.end)??"bottom top",r=typeof i=="string"?i.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(r){const o=Number.parseFloat(r[1]);return this.startPx+(r[2]==="%"?n*o/100:o)}return s+Un(e,n,i)}applyProgress(){const e=this.timeline?.duration??0;this.timeline&&e>0&&this.timeline.seek(this.displayProgress*e),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const e=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===e[0]&&this.lastEmitted[1]===e[1]||(this.lastEmitted=e,this.options.onUpdate(e[0],e[1]))}trackVelocity(e){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&e!==this.lastScroll&&(this.velocityPxPerSecond=(e-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||e!==this.lastScroll)&&(this.lastScroll=e,this.lastScrollTime=n),!(this.velocityPxPerSecond===0||typeof setTimeout>"u")&&(this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.idleTimer=null,this.releaseVelocity=this.velocityPxPerSecond,this.velocityPxPerSecond=0,this.emitUpdate(),this.scheduleSnap()},R2))}fireBoundaryCallbacks(e,n){if(e===n)return;const{onEnter:s,onLeave:i,onEnterBack:r,onLeaveBack:o}=this.options;e==="before"?(s?.(),n==="after"&&i?.()):e==="after"?(r?.(),n==="before"&&o?.()):n==="after"?i?.():o?.()}scheduleSnap(){const e=this.options.snap;if(e===void 0||this.snapper.active)return;const n=Wu(e),s=()=>{this.snapTimer=null;const i=this.endPx-this.startPx,r=this.scrollPosition();if(!this.running||i<=0||r<=this.startPx||r>=this.endPx)return;const o=(r-this.startPx)/i,a=this.startPx+Du(o,this.releaseVelocity/i,n.snapTo)*i;Math.abs(a-r)<1||this.snapper.animate(r,a,Bu(n,a-r,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(s,n.delay*1e3):s()}scrollTo(e){const n=this.options.scroller,s=this.options.horizontal?{left:e}:{top:e};n?typeof n.scrollTo=="function"?n.scrollTo({...s,behavior:"instant"}):this.options.horizontal?n.scrollLeft=e:n.scrollTop=e:typeof window<"u"&&window.scrollTo({...s,behavior:"instant"})}measureInContainer(e){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const s=n.getBoundingClientRect(),i=this.options.scroller?.getBoundingClientRect?.().left??0,r=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,o=s.left-i-e.shiftAt(e.progress()),{start:a,end:l}=e.range(),c=f=>a+f*(l-a),h=Ja(o,s.width,r,si(this.options.start)??"left right",e.shiftAt);this.startPx=c(h);const u=si(this.options.end)??"right left",d=typeof u=="string"?u.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=d?this.startPx+Number.parseFloat(d[1]):c(Ja(o,s.width,r,u,e.shiftAt)),this.markerGeometry=null}markersFor(e){const n=(r,o)=>{const a=si(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=Ua(a);return e*l.viewportFraction-l.offsetPx},s=n(this.options.start,"top bottom")??0,i=n(this.options.end,"bottom top")??s;return{startViewport:s,endViewport:i,startPage:this.startPx+s,endPage:this.endPx+i}}startSmoothing(){if(this.rafId!==null||typeof requestAnimationFrame>"u")return;const e=n=>{if(this.rafId=null,!this.running)return;const s=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=Lu(this.displayProgress,this.targetProgress,this.smoothing(),s);const i=Math.abs(this.targetProgress-this.displayProgress)<1e-4;i&&(this.displayProgress=this.targetProgress),this.applyProgress(),i?this.lastFrameTime=null:this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}stopSmoothing(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.lastFrameTime=null}scrollTarget(){return this.options.scroller??(typeof window<"u"?window:null)}scrollPosition(){const e=this.options.scroller,n=this.options.horizontal;return e?(n?e.scrollLeft:e.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const e=this.options.trigger;return typeof e?.getBoundingClientRect!="function"?null:this.relativeRect(e.getBoundingClientRect())}relativeRect(e){const n=this.options.horizontal,s=n?e.left??0:e.top,i=n?e.right??0:e.bottom,r=n?e.width??0:e.height,o=this.options.scroller;if(o&&typeof o.getBoundingClientRect=="function"){const a=o.getBoundingClientRect(),l=n?a.left:a.top;return{top:s-l,bottom:i-l,height:r}}return{top:s,bottom:i,height:r}}viewportHeight(){const e=this.options.scroller,n=this.options.horizontal;return e?n?e.clientWidth:e.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function si(t){return typeof t=="function"?t():t}function F2(t){const e=new ni(t);return e.start(),e}const Qa=new Set,N2=16,Ku=.5,W2=2;class tl{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=e=>this.wheel(e);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(e={}){this.options=e,this.frames=e.frames??{request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)}}start(){if(this.running||typeof window>"u")return this;this.running=!0,this.reduced=this.options.reducedMotion??(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),this.current=this.target=this.position();const e=this.options.scroller??window;return e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),Qa.add(this),this.stopListening=ni.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const e of Qa)e.refresh()}stop(){if(!this.running)return this;this.running=!1;const e=this.options.scroller??window;return e.removeEventListener("wheel",this.onWheel),e.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),Qa.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const e of this.effects)el(e.element,e.saved);this.effects=[]}kill(){this.destroy()}get state(){const e=this.limit();return{scroll:this.current,target:this.target,progress:e>0?this.current/e:0,velocity:this.velocityPxPerSecond}}paused(e){return e!==void 0&&(this.pausedState=e,e&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(e,n={}){if(!this.running)return;const s=this.clamp(this.resolve(e)+(n.offset??0)),i=Math.abs(s-this.current),r=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,i/2500));if(r<=0){this.journey=null,this.current=this.target=s,this.write(s),this.applyEffects(0);return}this.target=s,this.journey={from:this.current,to:s,ms:r*1e3,ease:n.ease??Bs,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const e=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(e&&!this.reduced){const n=this.options.scroller??document,s=this.position(),i=this.viewportHeight(),r=this.options.scroller?.getBoundingClientRect().top??0;for(const o of n.querySelectorAll(e)){const a=Number.parseFloat(o.dataset.speed??""),l=Number.parseFloat(o.dataset.lag??""),c=o.getBoundingClientRect(),h=c.top-r+s;this.effects.push({element:o,speed:Number.isFinite(a)?a:void 0,lag:Number.isFinite(l)&&l>0?l:void 0,centre:h+c.height/2-i/2,lagged:s,shift:0,saved:o.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const e of this.effects)el(e.element,e.saved)}wheel(e){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||e.ctrlKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||this.nestedScrollerTakes(e))return;const n=e.deltaMode===1?N2:e.deltaMode===2?this.viewportHeight():1,s=e.deltaY*n*(this.options.wheelMultiplier??1),i=this.clamp(this.target+s);i===this.target&&i===this.current||(e.preventDefault(),this.journey=null,this.target=i,this.requestFrame())}nativeScroll(){const e=this.position();this.written!==null&&Math.abs(e-this.written)<=W2||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=e,this.requestFrame())}nestedScrollerTakes(e){const n=this.options.scroller??document.documentElement;for(let s=e.target;s&&s!==n&&s!==document.body;s=s.parentElement){if(s.hasAttribute?.("data-smooth-ignore"))return!0;const i=getComputedStyle(s);if(!/(auto|scroll)/.test(i.overflowY)||s.scrollHeight<=s.clientHeight)continue;if(e.deltaY<0?s.scrollTop>0:s.scrollTop+s.clientHeight<s.scrollHeight-1)return!0}return!1}requestFrame(){this.frameId!==null||!this.running||(this.frameId=this.frames.request(e=>this.frame(e)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(e){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,e-this.lastTime);this.lastTime=e;const s=this.current;if(this.journey){const r=this.journey;r.elapsed+=n;const o=Math.min(1,r.elapsed/r.ms);this.current=r.from+(r.to-r.from)*r.ease(o),o>=1&&(this.journey=null)}else if(this.current!==this.target){const r=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/r)),Math.abs(this.target-this.current)<Ku&&(this.current=this.target)}this.current!==s&&this.write(this.current),this.velocityPxPerSecond=n>0?(this.current-s)*1e3/n:0;const i=this.applyEffects(n);this.current!==s&&this.options.onUpdate?.(this.state),this.journey||this.current!==this.target||i?this.requestFrame():(this.lastTime=null,this.velocityPxPerSecond=0)}applyEffects(e){let n=!1;const s=this.current;for(const i of this.effects){let r=0;if(i.speed!==void 0&&(r+=(s-i.centre)*(1-i.speed)),i.lag!==void 0){const o=i.lag*1e3/3;i.lagged=e===0?s:i.lagged+(s-i.lagged)*(1-Math.exp(-e/o)),Math.abs(s-i.lagged)<Ku?i.lagged=s:n=!0,r+=s-i.lagged}el(i.element,r===0?i.saved:`0 ${D2(r)}px`),i.shift=r}return n}write(e){const n=Math.round(e);this.written=n;const s=this.options.scroller;s?s.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const e=this.options.scroller;return e?e.scrollTop:window.scrollY}viewportHeight(){const e=this.options.scroller;return e?e.clientHeight:window.innerHeight}limit(){const e=this.options.scroller??document.documentElement;return Math.max(0,e.scrollHeight-this.viewportHeight())}clamp(e){return Math.max(0,Math.min(this.limit(),e))}resolve(e){if(typeof e=="number")return e;const n=this.options.scroller??document,s=typeof e=="string"?n.querySelector(e):e;if(!s)return this.current;const i=this.options.scroller?.getBoundingClientRect().top??0,r=this.effects.find(o=>o.element===s)?.shift??0;return s.getBoundingClientRect().top-i+this.position()-r}}function el(t,e){e?t.style.setProperty("translate",e):t.style.removeProperty("translate")}function D2(t){return Math.round(t*100)/100}function B2(t,e){switch(e){case"play":if(t.progress()>=1)break;t.reversed()?t.reverse():t.play();break;case"reverse":if(t.progress()<=0)break;t.reversed()?t.play():t.reverse();break;case"pause":t.pause();break;case"resume":t.resume();break;case"restart":t.restart();break;case"reset":t.pause(),t.progress(0);break;case"complete":t.pause(),t.progress(1);break}}function nl(t,e,n,s,i=()=>{}){const r=f=>typeof f=="string"?t.query(f)??void 0:f,o=r(e.trigger)??s;if(!o){i(`gsap-compat: scrollTrigger has no trigger element${typeof e.trigger=="string"?` for "${e.trigger}"`:""}`);return}const a=e.scrub===void 0||e.scrub===!1?!1:e.scrub,l=(e.toggleActions??"play none none none").trim().split(/\s+/);let c=0,h;const u=(f,p)=>()=>{p?.(),n&&!a&&B2(n,l[f]??"none"),e.once&&f===0&&queueMicrotask(()=>h.destroy())},d=e.containerAnimation?j2(t,e.containerAnimation,o,i):void 0;return h=new ni({trigger:o,start:e.start,end:e.end,scrub:a===!1?void 0:a,pin:e.pin===!0?!0:r(e.pin),scroller:r(e.scroller),horizontal:e.horizontal,pinSpacing:e.pinSpacing,onRefresh:e.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:e.snap===void 0?void 0:z2(e.snap,n),markers:e.markers,container:d,onUpdate:(f,p)=>{if(n&&a!==!1&&n.progress(f),e.onUpdate){const g=f<c||p<0?-1:1;e.onUpdate({progress:f,velocity:p,direction:g})}c=f},onEnter:u(0,e.onEnter),onLeave:u(1,e.onLeave),onEnterBack:u(2,e.onEnterBack),onLeaveBack:u(3,e.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),t.own(h)}function z2(t,e){const n=i=>i==="labels"?r=>q2(r,e?.labelProgresses?.()??[]):i;if(typeof t!="object"||Array.isArray(t))return n(t);const s=t.ease?Qs(t.ease):void 0;return{snapTo:n(t.snapTo),duration:t.duration,delay:t.delay,ease:s?s.fn??Wt(s.easing):void 0}}function q2(t,e){return e.reduce((n,s)=>Math.abs(s-t)<Math.abs(n-t)?s:n,e[0]??t)}function j2(t,e,n,s){const i=()=>e.timeline.getTracks({property:"x"}).map(r=>r.target).filter(r=>{const o=t.elementFor(r);return!!o&&o!==n&&o.contains(n)});return i().length===0&&s("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const r=e.scrollTrigger;return r||s("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:r?.startOffset??0,end:r?.endOffset??0}},progress:()=>e.progress(),shiftAt:r=>{const o=e.timeline.getStateAtTime(r*e.timeline.duration);let a=0;for(const l of i()){const c=o.values.get(l)?.get("x");typeof c=="number"&&(a+=c)}return a}}}class Xu{conditions={};scope;host;items=[];snapshots=new Map;constructor(e,n){this.host=e,this.scope=n}add(e){const n=this.host.collector;this.host.setCollector(this);try{const s=e();return typeof s=="function"&&this.items.push({revert:s}),s}finally{this.host.setCollector(n)}}track(e){this.items.push(e)}touch(e,n){this.snapshots.has(e)||this.snapshots.set(e,{name:n,style:e.getAttribute("style"),d:e.getAttribute("d")})}revert(){for(const e of this.items.splice(0).reverse())e.revert?e.revert():e.kill?e.kill():e.destroy?.();for(const[e,{name:n,style:s,d:i}]of this.snapshots)s===null?e.removeAttribute("style"):e.setAttribute("style",s),i!==null&&e.setAttribute("d",i),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class Y2{host;scope;entries=[];listeners=[];scheduled=!1;constructor(e,n){this.host=e,this.scope=n}add(e,n){const s={conditions:e,setup:n,queries:new Map},i=typeof e=="string"?{matches:e}:e;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[r,o]of Object.entries(i)){const a=window.matchMedia(o);s.queries.set(r,a);const l=()=>this.scheduleUpdate();a.addEventListener("change",l),this.listeners.push(()=>a.removeEventListener("change",l))}return this.entries.push(s),this.update(s),this}revert(){for(const e of this.listeners.splice(0))e();for(const e of this.entries.splice(0))e.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const e of this.entries)this.update(e)}))}update(e){const n={};for(const[o,a]of e.queries)n[o]=a.matches;const s=Object.values(n).some(Boolean),i=s?JSON.stringify(n):void 0;if(i===e.key||(e.context?.revert(),e.context=void 0,e.key=i,!s))return;const r=new Xu(this.host,this.scope);r.conditions=n,r.add(()=>e.setup(r)),e.context=r}}class K2{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(e,n){this.canvas=e,this.context=e.getContext("2d"),this.options=n,this.frames=Math.max(1,Math.floor(n.frames)),this.images=new Array(this.frames),this.ready=new Array(this.frames).fill(!1),typeof window<"u"&&window.addEventListener("resize",this.onResize,{passive:!0}),this.resize(),this.pump()}get frame(){return this.current}set frame(e){this.current=Math.max(0,Math.min(this.frames-1,e)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const e of this.images)e&&(e.src="")}resize(){const e=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*e),s=Math.round(this.canvas.clientHeight*e);n>0&&s>0&&(this.canvas.width!==n||this.canvas.height!==s)&&(this.canvas.width=n,this.canvas.height=s),this.drawn=-1,this.draw()}draw(){const e=Math.round(this.current),n=this.nearestReady(e);if(n===-1||n===this.drawn||!this.context)return;const s=this.images[n],{width:i,height:r}=this.canvas,o=(this.options.fit??"cover")==="cover"?Math.max(i/s.naturalWidth,r/s.naturalHeight):Math.min(i/s.naturalWidth,r/s.naturalHeight),a=s.naturalWidth*o,l=s.naturalHeight*o;this.context.clearRect(0,0,i,r),this.context.drawImage(s,(i-a)/2,(r-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(e){for(let n=0;n<this.frames;n++){if(e-n>=0&&this.ready[e-n])return e-n;if(e+n<this.frames&&this.ready[e+n])return e+n}return-1}pump(){const e=this.options.concurrency??6,n=Math.round(this.current);for(let s=0;s<this.frames&&this.inFlight<e;s++)for(const i of s===0?[n]:[n+s,n-s])i<0||i>=this.frames||this.images[i]||this.inFlight>=e||this.load(i)}load(e){const n=new Image;n.decoding="async",this.images[e]=n,this.inFlight++;const s=i=>{if(!this.destroyed){if(this.inFlight--,i){this.ready[e]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const r=Math.round(this.current);(Math.abs(e-r)<Math.abs(this.drawn-r)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>s(!0),n.onerror=()=>s(!1),n.src=this.options.url(e)}}const X2={opacity:0,y:-16},G2={opacity:0,y:16};async function U2(t,e,n,s){const i=e.collector?.scope??e.root,r=i.ownerDocument??i,o=()=>s.shared?[...i.querySelectorAll(s.shared)]:[];if(s.native&&typeof r.startViewTransition=="function")return V2(r,s,o);const a=s.duration??.35,l=s.ease??"power2.inOut",c=m=>new Promise(y=>{m(y)||y()}),h=o(),u=h.length?Ya(e,h):void 0,d=s.from!==void 0?Gu(e,s.from,s.shared):[];if(d.length&&s.leave!==!1){const m=s.leave??X2;await c(y=>t.to(d,{...m,duration:a,ease:l,onComplete:y}))}await s.update();const f=[],p=typeof s.to=="function"?s.to():s.to,g=p!==void 0?Gu(e,p,s.shared):[];if(g.length&&s.enter!==!1){const m=s.enter??G2;f.push(c(y=>t.fromTo(g,m,{...Hu(m),duration:a,ease:l,onComplete:y})))}if(u){const m=o().filter(y=>!h.includes(y));m.length&&f.push(c(y=>Xa(e,n,u,{targets:m,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(f)}function Gu(t,e,n){const s=t.resolveTargets(e).map(i=>t.elementFor(i)).filter(i=>!!i);return n?s.flatMap(i=>!i.querySelector(n)&&!i.matches(n)?[i]:[...i.children].filter(r=>!r.matches(n)&&!r.querySelector(n))):s}async function V2(t,e,n){const s=(a,l)=>{const c=a.dataset?.flipId;c&&a.style.setProperty("view-transition-name",l?`tf-${c.replace(/[^\w-]/g,"-")}`:"")},i=n();i.forEach(a=>s(a,!0));let r=[];await t.startViewTransition(async()=>{i.forEach(a=>s(a,!1)),await e.update(),r=n(),r.forEach(a=>s(a,!0))}).finished,r.forEach(a=>s(a,!1))}const Uu={create:(t,e)=>La(t,G0(e))},Vu={create:(t,e)=>La(t,{fn:U0(e)})},Ju={create:(t,e)=>La(t,{fn:V0(e)})},J2=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Zu=.5,Z2="power1.inOut";function Q2(t){return t.keyframes!==void 0&&t.keyframes!==null}function tk(t){const e=t.keyframes,n={};for(const[c,h]of Object.entries(t))J2.has(c)||(n[c]=h);if(Array.isArray(e))return e.map(c=>({...n,...c,duration:c.duration??t.duration??Zu}));const s=Object.entries(e),i=t.duration??Zu,r=e.easeEach??t.easeEach??Z2;if(s.length>0&&s.every(([c])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(c)||c==="easeEach")){const c=s.filter(([d])=>d!=="easeEach").map(([d,f])=>({at:Number.parseFloat(d)/100,step:f})).sort((d,f)=>d.at-f.at),h=[];let u=0;for(const{at:d,step:f}of c){const p=Math.max(0,d-u);h.push({...n,ease:r,...f,duration:p*i}),u=d}return h}const o=s.filter(([c,h])=>c!=="easeEach"&&Array.isArray(h)),a=Math.max(0,...o.map(([,c])=>c.length)),l=[];for(let c=0;c<a;c++){const h={...n,ease:r,duration:i/a};for(const[u,d]of o)c<d.length&&(h[u]=d[c]);l.push(h)}return l}function Qu(t,e,n,s={}){const i=e.collector?.scope??e.root,r=typeof s.scroller=="string"?i.querySelector(s.scroller):s.scroller??null,o={x:r?r.scrollLeft:window.scrollX,y:r?r.scrollTop:window.scrollY},a={x:r?r.scrollWidth-r.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:r?r.scrollHeight-r.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(v,k)=>{if(k===void 0)return o[v];if(typeof k=="number")return k;if(k==="max")return a[v];const w=typeof k=="string"?i.querySelector(k):k;if(!w)return o[v];const T=w.getBoundingClientRect(),A=r?.getBoundingClientRect(),M=(v==="x"?s.offsetX:s.offsetY)??s.offset??0;return v==="x"?T.left-(A?.left??0)+o.x-M:T.top-(A?.top??0)+o.y-M},c=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:o.x,y:l("y",n)},h={x:Math.max(0,Math.min(a.x,c.x)),y:Math.max(0,Math.min(a.y,c.y))},u={...o},d=()=>{r?(r.scrollLeft=u.x,r.scrollTop=u.y):window.scrollTo({left:u.x,top:u.y,behavior:"instant"})},f=["wheel","touchstart","keydown"],p=r??window,g=()=>{y.kill(),m()},m=()=>{for(const v of f)p.removeEventListener(v,g)},y=t.to(u,{x:h.x,y:h.y,duration:s.duration??1,ease:s.ease??"power2.inOut",onStart:s.onStart,onUpdate:()=>{d(),s.onUpdate?.()},onComplete:()=>{m(),s.onComplete?.()}});if(s.autoKill!==!1)for(const v of f)p.addEventListener(v,g,{passive:!0});return y}function ek(t,e,n){const s=t.collector?.scope??t.root,i=typeof e=="string"?[...s.querySelectorAll(e)]:"nodeType"in e?[e]:Array.from(e),{interval:r=.1,batchMax:o,onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h,...u}=n,d={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},f={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},p={},g=y=>{p[y]!==void 0&&clearTimeout(p[y]),p[y]=void 0;const v=f[y].splice(0);v.length>0&&d[y]?.(v)},m=(y,v)=>{if(d[y]){if(f[y].push(v),o!==void 0&&f[y].length>=o)return g(y);p[y]===void 0&&(p[y]=setTimeout(()=>g(y),r*1e3))}};return i.map(y=>nl(t,{...u,trigger:y,onEnter:()=>m("onEnter",y),onLeave:()=>m("onLeave",y),onEnterBack:()=>m("onEnterBack",y),onLeaveBack:()=>m("onLeaveBack",y)})).filter(y=>y!==void 0)}class xe{compat;stage;options;autoplayPending;started=!1;killed=!1;recipe=[];firstElement;scrollDriver;events=[];ranges=[];playhead={time:0,iteration:0,direction:"forward",fresh:!0};waitingToWrap=!1;finishedThisFrame=!1;backwards=!1;constructor(e,n={}){this.stage=e;const s={...n,onWarning:n.onWarning??e.onWarning};if(this.options=s,this.compat=new vn({...s,startValue:(i,r)=>{const o=e.objectFor(i);if(o)return ik(o[r]);const a=e.appliedValue(i,r);if(a!==void 0)return a;if(r==="d")return xu(e.elementFor(i))??void 0;if(r==="text")return e.elementFor(i)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=id(e.elementFor(i));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(i,r)=>e.velocityOf(i,r),layoutColumns:i=>sd(i.map(r=>e.elementFor(r))),random:()=>e.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},e.collector?.track(this),e.liveTimelines.add(this),this.autoplayPending=!s.paused&&!s.scrollTrigger,s.scrollTrigger){const i=s.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=nl(e,i,this,this.firstElement,r=>s.onWarning?.(r)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(e,n,s){return Q2(n)?this.record(()=>this.keyframed(e,n,s)):this.record(()=>this.tween(e,[n],s,([i],r,o)=>this.compat.to(r,i,o)))}from(e,n,s){return this.record(()=>this.tween(e,[n],s,([i],r,o)=>this.compat.from(r,i,o)))}fromTo(e,n,s,i){return this.record(()=>this.tween(e,[n,s],i,([r,o],a,l)=>this.compat.fromTo(a,r,o,l)))}set(e,n,s){return this.record(()=>this.tween(e,[n],s,([i],r,o)=>this.compat.set(r,i,o)))}addLabel(e,n){return this.record(()=>this.compat.addLabel(e,n))}add(e,n){return this.record(()=>{e.autoplayPending=!1,e.timeline.stop(),e.stage.deactivate(e.timeline),this.compat.add(e.compat,n)})}invalidate(){const e=this.compat.progress();this.compat.progress(0),this.stage.render(this.timeline),this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();return this.syncDuration(),this.compat.progress(e),this.stage.render(this.timeline),this}call(e,n=[],s){return this.record(()=>{const i=this.compat.addEvent(s);this.events.push({time:i,run:()=>e(...n)})})}addPause(e,n,s=[]){return this.record(()=>{const i=this.compat.addEvent(e);this.events.push({time:i,pause:!0,run:()=>n?.(...s)})})}tweenTo(e,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,e,n)}tweenFromTo(e,n,s={}){this.pause(),this.seek(e);const i=this.timeline.currentTime,r=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),o={time:i},a=s.duration??Math.abs(r-i)/1e3/(this.timeScale()||1),l=new xe(this.stage,{onStart:s.onStart,onComplete:s.onComplete});return l.to(o,{time:r,duration:a,ease:s.ease??"none",onUpdate:()=>{this.moveTo(o.time),s.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const e=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!e){const s=this.timeline,i=s.direction==="forward"?s.currentTime===0:s.currentTime===s.duration;this.playhead={...this.readPlayhead(),fresh:i&&!n},this.waitingToWrap=!1}return this.stage.liveTimelines.add(this),this.stage.render(this.timeline),this.stage.activate(this.timeline,{onUpdate:()=>this.afterFrame()}),this}pause(){return this.autoplayPending=!1,this.timeline.pause(),this.stage.deactivate(this.timeline),this}resume(){return this.play()}restart(){return this.timeline.stop(),this.backwards=!1,this.play()}reverse(){this.backwards=!this.backwards;const e=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),e&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const e=this.timeline.duration;return e>0?this.compat.labelTimes().map(n=>n/e):[]}reversed(){return this.timeline.direction==="reverse"}seek(e){return this.autoplayPending=!1,this.compat.seek(e),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(e){return e===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,e))*this.timeline.duration),this.compat.progress())}timeScale(e){return this.compat.timeScale(e)}duration(){return this.compat.duration()}isActive(){return this.timeline.playbackState==="playing"}kill(){return this.killed=!0,this.stage.liveTimelines.delete(this),this.scrollDriver?.destroy(),this.scrollDriver=void 0,this.autoplayPending=!1,this.timeline.stop(),this.stage.deactivate(this.timeline),this.compat.kill(),this}toDefinition(){return this.compat.toDefinition()}killTweensOf(e,n){for(const s of e)for(const i of n??[void 0])this.timeline.removeTracks({target:s,...i!==void 0&&{property:i}});this.timeline.tracks.length===0&&this.events.length===0&&this.kill()}record(e){return this.recipe.push(e),e(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const e=Math.max(...this.events.map(n=>n.time));e>this.timeline.duration&&this.timeline.setDuration(e)}readPlayhead(){const e=this.timeline;return{time:e.currentTime,iteration:e.loopIteration,direction:e.direction}}moveTo(e){const n=this.playhead;this.timeline.seek(e),this.stage.render(this.timeline);const s={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:e>=n.time?"forward":"reverse"},i={...n,iteration:s.iteration,direction:s.direction};this.playhead={...this.readPlayhead()},this.waitingToWrap=!1,this.runCrossings(i,s,!1),this.options.onUpdate?.()}refreshForRepeat(){const e=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(e,this.timeline.duration))}afterFrame(){const e=this.timeline,n=e.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const s=this.playhead,i=this.readPlayhead();this.playhead=i;const r=this.options.yoyo===!0;n&&!r&&i.iteration>s.iteration&&(this.playhead={time:0,iteration:i.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const o=this.runCrossings(s,i,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!o){this.finishedThisFrame=!1;const a=e.currentTime===0&&e.direction==="reverse";!this.scrollDriver&&!r&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(e,n,s){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const i=this.events,{crossings:r,passes:o}=xa(i.map(a=>a.time),e,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:s});for(const a of r){if(this.killed)return!0;if(a.kind==="repeat"){this.options.repeatRefresh&&this.refreshForRepeat(),this.options.onRepeat?.();continue}const l=i[a.index];if(!(l.direction&&l.direction!==a.direction)){if(l.pause)return this.timeline.seek(l.time),this.stage.render(this.timeline),this.pause(),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,l.run(),!0;l.run()}}for(const a of this.ranges)o.some(([c,h])=>c!==h&&Math.max(c,h)>=a.start&&Math.min(c,h)<=a.end)&&a.run();return!1}tween(e,n,s,i){const r=this.resolve(e);if(!r)return;const{onStart:o,onUpdate:a,onComplete:l}=n[n.length-1];if(o||a||l){let c=1/0,h=-1/0;const u=(d,f,p)=>{i(d,f,p),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,s,u),c===1/0)return;o&&this.events.push({time:c,direction:"forward",run:o}),a&&this.ranges.push({start:c,end:h,run:a}),l&&this.events.push({time:h,direction:"forward",run:l});return}this.buildTween(r,n,s,i)}keyframed(e,n,s){const i=this.resolve(e);if(!i)return;const r=tk(n);if(r.length===0)return;const o=i.length>1?Wa(n.stagger,this.staggerContext(i)):void 0,a=i.map(m=>this.targetFor(m)).filter(m=>m!==void 0),l=o?a.map(m=>[m]):[a],c=o?Qi(i.length,o).map(m=>m/1e3):[0],h=this.compat.timeOf(s)/1e3+mr(n.delay,0)/1e3;let u=1/0,d=-1/0;if(l.forEach((m,y)=>{r.forEach((v,k)=>{const w=k===0?h+c[y]:">";this.tween(m,[v],w,([T],A,M)=>this.compat.to(A,T,M)),u=Math.min(u,this.compat.lastStart),d=Math.max(d,this.compat.lastEnd)})}),u===1/0)return;const{onStart:f,onUpdate:p,onComplete:g}=n;f&&this.events.push({time:u,direction:"forward",run:f}),p&&this.ranges.push({start:u,end:d,run:p}),g&&this.events.push({time:d,direction:"forward",run:g})}staggerContext(e){return{count:e.length,columnsFromLayout:()=>sd(e.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(e,n,s,i){const r=e.map(d=>this.targetFor(d));if(!(e.length>1&&(n.some(sk)||e.some(d=>this.stage.objectFor(d)!==void 0)))){const d=this.targetFor(e[0]);i(n.map(f=>this.prepare(nd(f,0,d,this.stage.utils,r),e)),e,s);return}const a=n.length-1,{stagger:l,...c}=n[a],h=Wa(l,this.staggerContext(e)),u=h?Qi(e.length,h).map(d=>d/1e3):e.map(()=>0);e.forEach((d,f)=>{const p=f===0?mr(c.delay,0)/1e3+u[0]:0,g=f===0?0:u[f]-u[f-1],m=f===0?s:`<${g<0?"-":"+"}${Math.abs(g).toFixed(6)}`,v=n.map((k,w)=>w===a?{...c,delay:p}:k).map(k=>this.prepare(nd(k,f,this.targetFor(d),this.stage.utils,r),[d]));i(v,[d],m)})}targetFor(e){return this.stage.elementFor(e)??this.stage.objectFor(e)}prepare(e,n){const s=o=>this.options.onWarning?.(o),i=o=>this.stage.query(o);let r=e;if(e.motionPath!==void 0){const o=p2(e.motionPath,{query:i,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:s});r={...r,motionPath:o}}if(e.morphSVG!==void 0){const o=m2(e.morphSVG,i,s),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(e.drawSVG!==void 0){const o=id(this.stage.elementFor(n[0]));if(o===void 0){s("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=r;r=l}else r=zw(r,o)}return r}resolve(e){const n=this.stage.resolveTargets(e);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${rk(e)}`);return}return this.firstElement??=n.map(s=>this.stage.elementFor(s)).find(s=>s!==void 0),n}}function td(t=new ku){const e=r=>{const{config:o}=pr(r);return new xe(t,{repeat:o.repeat,yoyo:o.yoyo,repeatDelay:o.repeatDelay,paused:o.paused,onStart:o.onStart,onUpdate:o.onUpdate,onComplete:o.onComplete,onRepeat:o.onRepeat,onReverseComplete:o.onReverseComplete,repeatRefresh:o.repeatRefresh,scrollTrigger:o.scrollTrigger})},n=r=>{const{onStart:o,onUpdate:a,onComplete:l,onRepeat:c,onReverseComplete:h,repeatRefresh:u,...d}=r;return d},s=r=>(r&&t.collector?.track(r),r),i={stage:t,ticker:t.ticker,utils:t.utils,getProperty:(r,o)=>{const[a]=t.resolveTargets(r);if(a===void 0)return;const l=t.objectFor(a);return l?l[o]:t.appliedValue(a,o)??pu(o)},scrollTrigger:r=>s(nl(t,r)),scrollBatch:(r,o)=>ek(t,r,o).map(a=>s(a)),scrollTo:(r,o)=>Qu(i,t,r,o),refreshScroll:()=>{ni.refreshAll(),tl.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(t.collector?.scope??t.root).querySelector(r.scroller):r.scroller;return s(new tl({...r,scroller:o}).start())},context:(r,o)=>{const a=new Xu(t,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new Y2(t,r),customEase:Uu.create,customBounce:Vu.create,customWiggle:Ju.create,pageTransition:r=>U2(i,t,o=>new xe(t,o),r),imageSequence:(r,o)=>{const a=typeof r=="string"?(t.collector?.scope??t.root).querySelector(r):r;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(r)}`);return s(new K2(a,o))},quickTo:(r,o,a={})=>{const l=new xe(t,{paused:!0}),[c]=t.resolveTargets(r);return Object.assign(u=>{if(!c)return;const d=a.spring!==void 0?t.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:u,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:nk(a.spring,o,d)}}),l.timeline.stop(),l.timeline.play(),t.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new xe(t,r),to:(r,o)=>{if(o.scrollTo!==void 0){const{scrollTo:a,...l}=o,c=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},h=typeof r!="string"&&r!==window&&r.nodeType===1;return Qu(i,t,a,{...l,offsetX:c.offsetX,offsetY:c.offsetY,scroller:h?r:void 0})}return e(o).to(r,n(o))},from:(r,o)=>e(o).from(r,n(o)),fromTo:(r,o,a)=>e(a).fromTo(r,o,n(a)),set:(r,o)=>e(o).set(r,n(o)),delayedCall:(r,o,a)=>new xe(t).call(o,a,r),killTweensOf:(r,o)=>{const a=t.resolveTargets(r),l=typeof o=="string"?o.split(",").map(c=>c.trim()).filter(Boolean):o;for(const c of[...t.liveTimelines])c.killTweensOf(a,l)},convertToPath:r=>b2(r,t.root),splitText:(r,o)=>{const a=t.collector?.scope??t.root,l=typeof r=="string"?Array.from(a.querySelectorAll(r)):"nodeType"in r?[r]:Array.from(r);return s(E2(l,o))},draggable:(r,o)=>s(M2(i,t,r,o)),getFlipState:r=>Ya(t,r),flipFrom:(r,o)=>Xa(t,a=>new xe(t,a),r,o),flip:(r,o,a)=>{const l=Ya(t,r);return o(),Xa(t,c=>new xe(t,c),l,{targets:r,...a})}};return i}const re=td();function nk(t,e,n){return t===!0?{velocity:{[e]:n}}:typeof t=="string"?{preset:t,velocity:{[e]:n}}:{...t,velocity:{[e]:n}}}function sk(t){return t.morphSVG!==void 0||t.drawSVG!==void 0||t.text!==void 0||t.scrambleText!==void 0||ed(t)}function ed(t){return Object.entries(t).some(([e,n])=>(typeof n=="function"||fu(n))&&!Na.has(e))}function nd(t,e,n,s,i){if(!ed(t))return t;const r={};for(const[o,a]of Object.entries(t))Na.has(o)?r[o]=a:typeof a=="function"?r[o]=a(e,n,i):fu(a)?r[o]=s.resolveRandomString(a):r[o]=a;return r}function sd(t){const e=t.map(s=>s?.getBoundingClientRect().top);if(e[0]===void 0)return t.length;let n=0;for(const s of e){if(s===void 0||Math.abs(s-e[0])>1)break;n++}return Math.max(1,n)}function id(t){const e=t;if(typeof e?.getTotalLength=="function")return e.getTotalLength()}function ik(t){if(typeof t=="number"||typeof t=="string"||Array.isArray(t)&&t.every(e=>typeof e=="number"))return t}function rk(t){return typeof t=="string"?`"${t}"`:String(t)}class sl{media;offset;driftTolerance;constructor(e,n={}){this.media=e,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(e){return Math.max(0,e/1e3+this.offset)}update(e,n){const s=this.targetTime(e);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-s)>this.driftTolerance&&(this.media.currentTime=s)):(this.media.paused||this.media.pause(),this.media.currentTime!==s&&(this.media.currentTime=s))}seek(e){this.media.currentTime=this.targetTime(e)}setRate(e){this.media.playbackRate=e}dispose(){this.media.paused||this.media.pause()}safePlay(){const e=this.media.play();e&&typeof e.catch=="function"&&e.catch(()=>{})}}function rd(t,e,n,s,i){const r=n-i;if(r<0){e.paused||e.pause(),e.currentTime=0;return}t.update(r,s)}class wr{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(e,n={}){if(typeof e=="string"){const s=document.querySelector(e);if(!s)throw new Error(`Container not found: ${e}`);this.container=s}else this.container=e;this.options=n,this.adapter=new Mn}async load(e){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(e)}async loadSource(e){let n;if(typeof e=="string"){const s=await fetch(e);if(!s.ok)throw new Error(`Failed to load animation: ${s.statusText}`);n=await s.json()}else n=e;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(e){const n={...e.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=Xn({...e,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(e,n={}){if(e.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const s=new Set;for(const r of e){if(s.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);s.add(r.id)}const i=n.initial===void 0?e[0]:e.find(r=>r.id===n.initial);if(!i)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...e],this.scenarioId=i.id,await this.loadSource(i.timeline)}get scenarios(){return this.scenarioList.map(e=>({id:e.id,label:e.label??e.id}))}get scenario(){return this.scenarioId}setScenario(e){const n=this.scenarioList.find(a=>a.id===e);if(!n||!this.timeline)return!1;if(e===this.scenarioId)return!0;const s=this.isPlaying,i=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=e,this.useDefinition(n.timeline),this.lastMarkerId=null;let o=0;return this.reducedMotion||i?o=this.duration:r!==void 0&&(o=this.markers.find(a=>a.id===r)?.time??0),this.seek(o),s&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(e){if(this.authored.has(e))return;const n={style:e.getAttribute("style")};e.children.length===0&&(n.text=e.textContent??"");const s=e.tagName.toLowerCase()==="path"?e:e.querySelector("path");s&&(n.path={element:s,d:s.getAttribute("d")}),this.authored.set(e,n)}restoreAuthored(){for(const[e,n]of this.authored){n.style===null?e.removeAttribute("style"):e.setAttribute("style",n.style),n.text!==void 0&&e.textContent!==n.text&&(e.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const s=e.dataset;s&&delete s.shineBase}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){for(const e of this.listeners)e()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const e=this.currentTime;let n;for(const s of this.markers)if(s.time<=e+.5)n=s;else break;return n}caption(e,n){const s=e?this.markers.find(o=>o.id===e):this.currentMarker;if(!s)return;const i=n??this.language(),r=o=>o?.[i]?.[s.id]??o?.[i.split("-")[0]]?.[s.id];return r(this.options.captions)??r(this.timeline?.captions)??s.label}next(){if(!this.timeline)return;const e=this.currentTime,n=this.markers.find(s=>s.time>e+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}e>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const e=this.currentTime,n=[...this.markers].reverse().find(s=>s.time<e-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(e){const n=this.markers.find(s=>s.id===e);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const e=this.options.initialFrame??"start";if(e==="none")return;const n=e==="end"?this.timeline.duration:e==="start"?0:e;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const s of n)this.onScreen=s.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const e=this.container.getBoundingClientRect?.();e&&(e.width>0||e.height>0)&&(this.onScreen=e.bottom>0&&e.top<window.innerHeight&&e.right>0&&e.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const e=this.onScreen&&document.visibilityState!=="hidden";!e&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):e&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const e=this.currentMarker,n=e?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(e))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const s=n,i=Number(s.getAttribute("data-tinyfly-start")??"0")||0,r=s.getAttribute("data-volume");r!==null&&(s.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:s,startTime:i,sync:new sl(s)})})}syncAllMedia(e,n){for(const s of this.mediaTargets)rd(s.sync,s.el,e,n,s.startTime)}loadFromString(e){const n=JSON.parse(e);this.load(n)}registerTarget(e,n){if(typeof n=="string"){const s=this.container.querySelector(n);s&&(this.rememberAuthored(s),this.targets[e]=s,this.adapter.registerTarget(e,s))}else this.rememberAuthored(n),this.targets[e]=n,this.adapter.registerTarget(e,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const s=n.closest("[data-tinyfly-symbol]");if(s&&s!==n)return;const i=n.getAttribute("data-tinyfly");i&&this.registerTarget(i,n)}),this.timeline&&new Set(this.timeline.tracks.map(s=>s.target)).forEach(s=>{if(!this.targets[s]){const i=this.container.querySelector(`[data-tinyfly="${s}"]`)||this.container.querySelector(`.${s}`)||this.container.querySelector(`#${s}`);i&&this.registerTarget(s,i)}})}setupSymbolInstances(){this.symbolInstances=[];const e=this.options.symbols;if(!e||e.length===0)return;const n=new Map(e.map(s=>[s.id,s]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const i=s.getAttribute("data-tinyfly-symbol");if(!i)return;const r=n.get(i);if(!r||!r.timeline.tracks?.length)return;const o=new Mn;s.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:Xn(r.timeline)})})}attachMedia(e,n){this.mediaSync=new sl(e,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const e=this.timeline.playbackState==="idle";this.timeline.play(),e&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(e){this.timeline&&(this.timeline.seek(e),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(e){this.timeline&&(this.timeline.speed=e,this.mediaSync?.setRate(e))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get state(){return this.timeline?.getStateAtTime(this.timeline.currentTime)}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const e of this.mediaTargets)e.el.paused||e.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const e of this.symbolInstances)e.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const e=n=>{if(this.isDestroyed||!this.timeline)return;const s=n-(this.lastTime??n);this.lastTime=n;const i=this.playhead;this.timeline.tick(s),this.stopAtMarker(i),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(e):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(e)}stopAtMarker(e){const n=this.timeline,s={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=s;const i=this.markers;if(i.length===0)return;const{crossings:r}=xa(i.map(o=>o.time),e,s,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const o of r){if(o.kind!=="event")continue;const a=i[o.index];if(this.stepping||a.pause){this.stepping=!1,n.pause(),n.seek(a.time),this.playhead={time:a.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const e=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(e)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const s=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(s>0?e%s:e))}}}async function ok(t,e,n={}){const s=new wr(t,{...n,autoplay:!0});return await s.load(e),s}function ak(t,e={}){return new wr(t,e)}const od={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},ad="tinyfly-controls-style",lk=`
3
3
  .tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
4
4
  font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
5
5
  .tf-ctl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); }
@@ -59,8 +59,8 @@ ${s.map(i=>` ${i.beat>=0?`beat ${i.beat}: `:""}${i.message}`).join(`
59
59
  ${i.map(d=>` ${d.beat>=0?`beat ${d.beat}: `:""}${d.message}`).join(`
60
60
  `)}`);const r=n.map(d=>Hm(d,e)),o=Ho(t,r,s),a=mx(r,o.beats,s),l=s.ground??0,c=d=>s.ride===!1?d:Object.values(e).reduce((f,p)=>p.ride(f,t,{ground:l}),d);n.forEach((d,f)=>{for(const p of gx(d)){const g=w=>new Error(`surfaceScript: beat ${f} (${d.do}), ${p.edit} on ${p.surface}: ${w}`),m=(w,T)=>{const A=typeof w=="object"?w.beat:f,M=(typeof w=="object"?w.at:w)??T??"start",x=a[A][M];if(x===void 0){const S=Ts.filter(E=>a[A][E]!==void 0).join(", ");throw g(`beat ${A} (${n[A].do}) has no ${M} (it has ${S})`)}return x},y=e[p.surface],v=m(p.at??(a[f].contact!==void 0?"contact":"start")),k=p.until===void 0?void 0:m(p.until,"end");if(k!==void 0&&k<v)throw g(`it ends (${k} ms) before it starts (${v} ms)`);try{if(p.edit==="carry"){const T=y.piece(p.anchor),A=ch(t,c(o.tracks),{x:s.from??0,y:l,style:s.figureStyle??(s.height?{height:s.height}:void 0),cast:s,start:v,end:k});y.follow(T,A);continue}const w=Object.fromEntries(Object.entries(p).filter(([T])=>!dx.includes(T)));y.edit(p.edit,p.anchor,{...w,at:v,...k!==void 0?{duration:k-v}:{}})}catch(w){throw g(w.message)}}});const h=c(o.tracks),u=Object.entries(e).flatMap(([d,f])=>f.tracks(d));return{...o,tracks:[...h,...u],figureTracks:h}}function _m(t,e,n={}){if(!Array.isArray(t))return Di(t,n);const s=[],i=Object.keys(e),r=(c,h,u)=>{const d=typeof h=="string"?e[h]:void 0;return d||s.push({level:"error",beat:c,message:`${u}: ${ft("surface",h,i)}`}),d},o=(c,h,u,d)=>{if(typeof u!="string"){s.push({level:"error",beat:c,message:`${d}: \`anchor\` is a place name such as ${Object.keys(h.about.anchors).join(", ")} (got ${JSON.stringify(u)}).`});return}try{h.anchor(u,0)}catch(f){s.push({level:"error",beat:c,message:`${d}: ${f.message}`})}},a=(c,h,u)=>{const d=typeof h=="object"&&h!==null?h.at:h;if(typeof h=="object"&&h!==null){const f=h.beat;if((typeof f!="number"||!Number.isInteger(f)||f<c||f>=t.length)&&s.push({level:"error",beat:c,message:`${u}: \`beat\` is the index of this beat or a later one, ${c} to ${t.length-1} (got ${JSON.stringify(f)}).`}),d===void 0)return}typeof d=="number"?s.push({level:"error",beat:c,message:`${u}: a cue starts at a moment of its beat (${Ts.join(", ")}), not at ms; set the beat's own \`at\` to move it.`}):(typeof d!="string"||!Ts.includes(d))&&s.push({level:"error",beat:c,message:`${u}: ${ft("moment",d,Ts)}`})};t.forEach((c,h)=>{if(!c||typeof c!="object"||Array.isArray(c))return;const u=c;for(const f of["target","to","onto"]){if(!Ro(u[f]))continue;const p=u[f],g=r(h,p.surface,`\`${f}\``);g&&o(h,g,p.anchor,`\`${f}\``)}if(u.then===void 0)return;(Array.isArray(u.then)?u.then:[u.then]).forEach(f=>{if(!f||typeof f!="object"||Array.isArray(f)){s.push({level:"error",beat:h,message:"`then` is a cue, { surface, edit, anchor, at?, until? }, or a list of them."});return}const p=f,g=r(h,p.surface,"`then`");if(!g)return;const m=`\`then\` (${String(p.edit)} on ${String(p.surface)})`,y=[...Object.keys(g.about.edits),...fx];if(typeof p.edit!="string"||!y.includes(p.edit)){s.push({level:"error",beat:h,message:`\`then\`: ${ft("edit",p.edit,y)}`});return}for(const v of Array.isArray(p.anchor)?p.anchor:[p.anchor])o(h,g,v,m);p.edit==="carry"&&typeof p.anchor!="string"&&s.push({level:"error",beat:h,message:`${m}: \`carry\` takes one anchor, the piece it carries.`}),p.edit==="carry"&&p.until===void 0&&s.push({level:"error",beat:h,message:`${m}: \`carry\` needs \`until\` (when it lets go, such as { beat: ${h+1}, at: 'release' }).`}),p.at!==void 0&&a(h,p.at,`${m} \`at\``),p.until!==void 0&&a(h,p.until,`${m} \`until\``),p.until!==void 0&&p.duration!==void 0&&s.push({level:"error",beat:h,message:`${m}: give \`until\` or \`duration\`, not both.`})})});const l=t.map(c=>c&&typeof c=="object"&&!Array.isArray(c)?Hm(c,e,!0):c);return[...Di(l,n),...s]}function Hm(t,e,n=!1){const{then:s,...i}=t,r=a=>{try{return e[a.surface].anchor(a.anchor,0)}catch(l){if(n)return{x:0,y:0,left:0,right:0,top:0,bottom:0,width:0,height:0};throw l}},o={...i};return Ro(t.target)&&(o.target=r(t.target)),Ro(t.to)&&(o.to=r(t.to).x),Ro(t.onto)&&(o.onto=r(t.onto).top),o}function mx(t,e,n){let s=0;return t.map(i=>{const r=Co([i],n.actions).length,o=e.slice(s,s+r);s+=r;const a=o.find(c=>c.contact!==void 0)?.contact,l=[...o].reverse().find(c=>c.release!==void 0)?.release;return{start:o[0]?.start,end:o[o.length-1]?.end,...a!==void 0?{contact:a}:{},...l!==void 0?{release:l}:{}}})}function yx(t){const e={actions:t.actions,gaits:t.gaits},n=Zc(e);if(n.length>0)throw new Error(`persona "${t.name}": ${n.join(" ")}`);const s=[...Object.keys(Xt),...Object.keys(t.gaits??{})],i=t.gait??"walk";if(!s.includes(i))throw new Error(`persona "${t.name}": ${ft("gait",i,s)}`);if(t.mood&&!(t.mood in vt))throw new Error(`persona "${t.name}": ${ft("mood",t.mood,Object.keys(vt))}`);const r=t.acting??"snappy";if(typeof r=="string"&&!(r in Ln))throw new Error(`persona "${t.name}": ${ft("acting style",r,Object.keys(Ln))}`);if(typeof t.stance=="string"&&!(t.stance in ae))throw new Error(`persona "${t.name}": ${ft("stance",t.stance,Object.keys(ae))}`);const o=t.height??120,a=typeof t.stance=="string"?ae[t.stance]:Dt(t.stance??{}),l=t.mood?Je(a,t.mood):a,c={...t.look,height:o},h=t.summary??`${t.name}, a stick figure`;return{name:t.name,summary:h,cast:e,rest:l,height:o,figure:u=>vl({x:u.x,y:u.y,pose:l,style:{...c,...u.facing?{facing:u.facing}:{}},cast:e}),script:(u,d,f={})=>Ho(u,d,{...e,from:f.from,ground:f.ground,facing:f.facing,height:o,style:r,gait:i,start:l,rest:l,energy:t.energy}),check:u=>Di(u,e),handPath:(u,d,f)=>ch(u,d,{...f,style:c,cast:e}),describe:()=>({name:t.name,summary:h,habits:{height:o,acting:typeof r=="string"?r:"custom",gait:i,...t.mood?{mood:t.mood}:{},stance:typeof t.stance=="string"?t.stance:t.stance?"custom":"rest"},actions:Qc(e),own:{actions:Object.keys(t.actions??{}),gaits:Object.keys(t.gaits??{})}})}}const bx=new Set(["x","y","walking","gait"]),Rm=.215+.205;function Lm(t,e,n=1){const{points:s}=fe(t,lt),i=s["hip.left"],r=s["knee.left"],o=s["ankle.left"],a=i&&r&&o?Math.hypot(r.x-i.x,r.y-i.y)+Math.hypot(o.x-r.x,o.y-r.y):Rm*t.height;return so(e,a/Rm,n)}function wx(t,e,n,s={}){const i=Ho(t,n,{...s,height:e.height,reach:s.reach??Fm(e)}),r=i.tracks.find(y=>y.property==="facing")?.keyframes??[],o=y=>{let v=s.facing??1;for(const k of r)k.time<=y&&(v=k.value);return v},a=Cr(i.keys),l=i.keys.map((y,v)=>{const k=ip(a[v]);return{time:y.time,pose:o(y.time)<0?kf(k):k,...y.easing?{easing:y.easing}:{},...y.act===!1?{act:!1}:{}}}),{rest:c,start:h,...u}=s;Mx(l,a,n,i,e,o,s);const d=dm(t,l,u),f=wo(t,d,i.lines,{energy:s.energy}),p=i.tracks.filter(y=>bx.has(y.property)),g=i.tracks.find(y=>y.property==="walk");return{tracks:g?[...f,...p,Px(t,g,i.tracks,e,s)]:[...f,...p],duration:i.duration,lines:i.lines,keys:l,beats:i.beats,effects:i.effects}}function Fm(t){const e=kt({"arm.left.spread":90,"arm.left.elbow":0,"arm.left.bend":0,"leg.left.knee":0}),n=fe(t,e).points,s=Math.hypot(n["hand.left"].x-n["shoulder.left"].x,n["hand.left"].y-n["shoulder.left"].y),i=Math.hypot(n["toe.left"].x-n["hip.left"].x,n["toe.left"].y-n["hip.left"].y),r=ye({...ut,rightShoulder:90,rightElbow:0,rightWrist:0},{height:t.height,facing:1}),o=ye({...ut,rightHip:90,rightKnee:0},{height:t.height,facing:1}),a={x:(r.hands.right.x+r.fingertips.right.x)/2,y:(r.hands.right.y+r.fingertips.right.y)/2},l=Math.hypot(a.x-r.shoulders.right.x,a.y-r.shoulders.right.y),c=Math.hypot(o.feet.right.x-o.hip.x,o.feet.right.y-o.hip.y);return{arm:l>0?s/l:1,leg:c>0?i/c:1}}const kx={point:"arm",grab:"arm",put:"arm",write:"arm",swipe:"arm",push:"arm",kick:"leg"},vx=new Set(["point","grab","put","kick"]);function Mx(t,e,n,s,i,r,o){const a=s.beats;if(n.length!==a.length)return;const l=new Ht({id:"placed",tracks:s.tracks.filter(h=>h.property==="x"||h.property==="y")}),c=h=>{const u=l.getStateAtTime(h).values.get(s.tracks[0]?.target??"");return{x:(o.from??0)+Number(u?.get("x")??0),y:(o.ground??0)+Number(u?.get("y")??0)}};n.forEach((h,u)=>{const d=kx[h.do],f=a[u];if(!d||f.contact===void 0||h.do!=="swipe"&&!h.target)return;const p=f.contact,g=f.release??f.contact;t.forEach((m,y)=>{if(m.time<p-1||m.time>g+1)return;const v=r(m.time),k=ye(e[y],{height:i.height,facing:v<0?-1:1}),w=c(m.time),T=vx.has(h.do)&&h.target?{x:h.target.x-w.x,y:h.target.y-w.y}:void 0,A={x:(k.hands.right.x+k.fingertips.right.x)/2,y:(k.hands.right.y+k.fingertips.right.y)/2},M=T??(d==="arm"?A:k.toes.right),x=v<0?"right":"left",S=`${d}.${x}`;let E=m.pose;if(h.do==="point")E=He(i,E,S,M);else if(d==="arm")E=He(i,Ax(i,E,x,M),S,M);else for(let P=0;P<3;P++){const I=fe(i,E).points,O=I[`ankle.${x}`],H=I[`toe.${x}`];E=He(i,E,S,{x:M.x-(H.x-O.x),y:M.y-(H.y-O.y)})}t[y]={...m,pose:E}})})}function Sx(t,e){const n=kt({[`arm.${e}.spread`]:90,[`arm.${e}.elbow`]:0,[`arm.${e}.bend`]:0}),s=fe(t,n).points;return Math.hypot(s[`hand.${e}`].x-s[`shoulder.${e}`].x,s[`hand.${e}`].y-s[`shoulder.${e}`].y)}const xx=5,Tx=4,Ex=8;function Ax(t,e,n,s){const i=Sx(t,n)*.9,r=a=>{const l=fe(t,a).points[`shoulder.${n}`];return Math.hypot(s.x-l.x,s.y-l.y)<=i};if(r(e))return e;let o=e;for(let a=1;a<=Ex;a++)if(o={...e,lean:(e.lean??0)+xx*a,bend:(e.bend??0)+Tx*a},r(o))return o;return o}function Px(t,e,n,s,i){const r=n.find(u=>u.property==="gait"),o=r?new Ht({id:`${t}-gait-of`,tracks:[r]}):void 0,a=u=>{const d=o?.getStateAtTime(u).values.get(t)?.get("gait");if(typeof d=="string")return Xt[d]??i.gaits?.[d]??d},l=e.keyframes,c=[];let h=l[0]?.value??0;return l.forEach((u,d)=>{if(d>0){const f=l[d-1],p=a((f.time+u.time)/2),g=$r(p,s.height),m=Lm(s,p);h+=(u.value-f.value)*(m>0?g/m:1)}else h=u.value;c.push({...u,value:h})}),{...e,keyframes:c}}const mt=["rect","circle","text","line","path","image","custom"],Lo={x:{description:"Moves it right by this much from where it was placed (an offset; the target’s own x is its place)",unit:"px",types:mt},y:{description:"Moves it down by this much from where it was placed (an offset)",unit:"px",types:mt},opacity:{description:"How opaque it is",unit:"0..1",min:0,max:1,types:mt},rotate:{description:"Turns it clockwise about its origin",unit:"degrees",types:mt},rotateX:{description:"Tips it about the horizontal axis (3D; shows with perspective)",unit:"degrees",types:mt},rotateY:{description:"Turns it about the vertical axis (3D; shows with perspective)",unit:"degrees",types:mt},z:{description:"Depth toward the viewer (shows with perspective)",unit:"px",types:mt},perspective:{description:"Distance from the viewer: nearer parts grow, further ones shrink",unit:"px",min:1,types:mt},scale:{description:"Size, both ways",unit:"factor",types:mt},scaleX:{description:"Width factor",unit:"factor",types:mt},scaleY:{description:"Height factor",unit:"factor",types:mt},skewX:{description:"Slants it sideways",unit:"degrees",types:mt},skewY:{description:"Slants it up and down",unit:"degrees",types:mt},originX:{description:"Transform pivot across its box",unit:"% (0 left, 50 centre, 100 right)",min:0,max:100,types:mt},originY:{description:"Transform pivot down its box",unit:"% (0 top, 50 centre, 100 bottom)",min:0,max:100,types:mt},fill:{description:"Fill colour (also written fillStyle)",kind:"color",types:mt},stroke:{description:"Outline colour (also written strokeStyle)",kind:"color",types:mt},strokeWidth:{description:"Outline width (also written lineWidth)",unit:"px",min:0,types:mt},clipTop:{description:"Hides this much from the top edge, for reveals",unit:"% of its height",min:0,max:100,types:mt},clipRight:{description:"Hides this much from the right edge",unit:"% of its width",min:0,max:100,types:mt},clipBottom:{description:"Hides this much from the bottom edge",unit:"% of its height",min:0,max:100,types:mt},clipLeft:{description:"Hides this much from the left edge",unit:"% of its width",min:0,max:100,types:mt},blur:{description:"Gaussian blur",unit:"px",min:0,types:mt},brightness:{description:"Brightness factor (1 unchanged)",unit:"factor",min:0,types:mt},glow:{description:"Soft glow around it, in glowColor",unit:"px",min:0,types:mt},glowColor:{description:"Colour of the glow",kind:"color",types:mt},shadowX:{description:"Drop shadow offset right",unit:"px",types:mt},shadowY:{description:"Drop shadow offset down",unit:"px",types:mt},shadowBlur:{description:"Drop shadow softness",unit:"px",min:0,types:mt},shadowColor:{description:"Drop shadow colour",kind:"color",types:mt},shine:{description:"A highlight sweeping across the fill",unit:"0..1 (progress)",min:0,max:1,types:mt},drawOn:{description:"How much of the outline is drawn, for drawing a shape on; the fill appears when it is complete",unit:"0..1",min:0,max:1,types:["rect","circle","line","path"]},width:{description:"Box width",unit:"px",min:0,types:["rect","image"]},height:{description:"Box height",unit:"px",min:0,types:["rect","image"]},borderRadius:{description:"Rounded corners",unit:"px",min:0,types:["rect","image"]},radius:{description:"Circle radius",unit:"px",min:0,types:["circle"]},x2:{description:"Line end, x",unit:"px",types:["line"]},y2:{description:"Line end, y",unit:"px",types:["line"]},d:{description:"SVG path data; tween between paths to morph",kind:"string",types:["path"]},text:{description:"The text shown (a text track types or scrambles it)",kind:"string",types:["text"]},fontSize:{description:"Font size",unit:"px",min:0,types:["text"]},fontWeight:{description:"Font weight",unit:"100..900",min:100,max:900,types:["text"]},motionPath:{description:"Moves it along an SVG path (a motion-path track writes motionPathX/Y and, aligned, rotate)",kind:"string",types:mt},quaternion:{description:'A rotation as [x, y, z, w] (a track with interpolation: "slerp")',kind:"list",types:mt}},hh={fillStyle:"fill",strokeStyle:"stroke",lineWidth:"strokeWidth",rotateZ:"rotate",motionPathX:"x",motionPathY:"y",motionPathRotate:"rotate"},$x={rotation:"rotate",angle:"rotate",alpha:"opacity",fade:"opacity",color:"fill",colour:"fill",background:"fill",size:"scale",left:"x",top:"y",translateX:"x",translateY:"y",r:"radius",path:"d",content:"text"};function Nm(t){const e=t,n=Object.entries(Lo).filter(([,i])=>i.types.includes(t.type)).map(([i,{types:r,...o}])=>({name:i,...o,...e[i]!==void 0&&typeof e[i]!="object"?{value:e[i]}:{}}));if(t.type!=="custom")return{type:t.type,properties:n};const s=t.about;for(const[i,r]of Object.entries(t.props??{}))n.push({name:i,description:s?.props?.[i]?.description??"",...s?.props?.[i],value:r});return{type:"custom",...s?{kind:s.kind,summary:s.summary}:{},properties:n,...s?.actions?{actions:s.actions}:{}}}function Wm(t){const e=Nm(t).properties.map(n=>n.name);return[...e,...Object.keys(hh).filter(n=>e.includes(hh[n]))]}function Ix(t,e){const n=[],s=Object.keys(e);for(const i of t){const r=d=>n.push({level:"error",track:i.id,message:d}),o=e[i.target];if(!o){r(ft("target",i.target,s));continue}const a=Wm(o),l=o.type==="custom"&&o.acceptsProp?.(i.property);if(!a.includes(i.property)&&!l){r(`${i.target}: ${ft("property",i.property,a,$x[i.property])}`);continue}const c=i.keyframes??[];for(let d=1;d<c.length;d++)c[d].time<c[d-1].time&&r(`${i.target}.${i.property}: keyframes out of time order (${c[d-1].time} ms, then ${c[d].time} ms).`);const h=Lo[hh[i.property]??i.property]??o.about?.props?.[i.property],u=h&&(h.kind??"number")==="number";for(const d of c){if(u&&typeof d.value!="number"){r(`${i.target}.${i.property}: values are numbers${h.unit?` (${h.unit})`:""} (got ${JSON.stringify(d.value)} at ${d.time} ms).`);break}if(u&&typeof d.value=="number"&&(h.min!==void 0&&d.value<h.min||h.max!==void 0&&d.value>h.max)){n.push({level:"warning",track:i.id,message:`${i.target}.${i.property}: ${d.value} at ${d.time} ms is outside ${h.min??"−∞"}..${h.max??"∞"}${h.unit?` (${h.unit})`:""}.`});break}}}return n}const Es=(t,e)=>t[2]<=-e;function uh(t,e,n){const s=(-n-t[2])/(e[2]-t[2]);return[t[0]+(e[0]-t[0])*s,t[1]+(e[1]-t[1])*s,-n]}function Dm(t,e){if(t.every(s=>Es(s,e)))return t;const n=[];return t.forEach((s,i)=>{const r=t[(i+t.length-1)%t.length],o=Es(s,e),a=Es(r,e);o!==a&&n.push(uh(r,s,e)),o&&n.push(s)}),n.length>=3?n:[]}function Ox(t,e){if(t.every(i=>Es(i,e)))return[t];const n=[];let s=[];return t.forEach((i,r)=>{const o=Es(i,e);if(r>0){const a=t[r-1],l=Es(a,e);l&&!o?(s.push(uh(a,i,e)),n.push(s),s=[]):!l&&o&&s.push(uh(a,i,e))}o&&s.push(i)}),s.length>0&&n.push(s),n.filter(i=>i.length>=2)}function Bm(t,e,n){const s=e-t;if(!(s>=n*1.5))return[t,e];const i=Math.round(s/n);return Array.from({length:i+1},(r,o)=>t+s*o/i)}function Cx(t,e,n){const s=(i,r)=>Math.max(0,Math.min(i.length-2,i.findIndex((o,a)=>a>0&&r<=o)-1));return[s(t,n[0]),s(e,n[2])]}function _x(t,e){const n=s=>{const i=[e[0]*s[0]+e[4]*s[1]+e[8]*s[2],e[1]*s[0]+e[5]*s[1]+e[9]*s[2],e[2]*s[0]+e[6]*s[1]+e[10]*s[2]],r=Math.hypot(...i)||1;return[i[0]/r,i[1]/r,i[2]/r]};return{...t,vertices:t.vertices.map(s=>ie(e,s)),faces:t.faces.map(s=>({corners:s.corners,normal:n(s.normal)}))}}function Fo(t,e,n,s){const i=o=>(o[e]-n)*s>=0;if(t.every(i))return t;const r=[];return t.forEach((o,a)=>{const l=t[(a+t.length-1)%t.length];if(i(o)!==i(l)){const c=(n-l[e])/(o[e]-l[e]);r.push([0,1,2].map(h=>h===e?n:l[h]+(o[h]-l[h])*c))}i(o)&&r.push(o)}),r.length>=3?r:[]}function Hx(t,e,n){const s=t.faces.map(o=>({points:o.corners.map(a=>t.vertices[a]),normal:o.normal})),i=[],r={x:e.slice(1,-1),z:n.slice(1,-1)};for(let o=0;o+1<e.length;o++)for(let a=0;a+1<n.length;a++){const l=[],c=new Map,h=p=>{const g=p.map(y=>Math.round(y*1e6)).join(",");let m=c.get(g);return m===void 0&&(m=l.length,l.push(p),c.set(g,m)),m},u=[],d=p=>p===0,f=(p,g)=>p+2===g.length;for(const p of s){let g=p.points;d(o)||(g=Fo(g,0,e[o],1)),g.length&&!f(o,e)&&(g=Fo(g,0,e[o+1],-1)),g.length&&!d(a)&&(g=Fo(g,2,n[a],1)),g.length&&!f(a,n)&&(g=Fo(g,2,n[a+1],-1)),g.length>=3&&u.push({corners:g.map(h),normal:p.normal})}u.length>0&&i.push({cell:[o,a],mesh:{vertices:l,faces:u,creases:t.creases,joined:t.joined,walls:r}})}return i}const Rx=new WeakMap,Lx=new WeakMap,Fx=48,zm=t=>t.map(e=>Math.round(e*1e5)).join(",");function qm(t,e,n,s){let i=t.get(e);i||t.set(e,i=new Map);let r=i.get(n);return r===void 0&&(i.size>=Fx&&i.clear(),i.set(n,r=s())),r}function dh(t,e){const n=zm(e);return qm(Rx,t,n,()=>{const s=_x(t,e),i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const o of s.vertices)for(const a of[0,1,2])i[a]=Math.min(i[a],o[a]),r[a]=Math.max(r[a],o[a]);return{key:n,inSpace:s,low:i,high:r}})}function Nx(t,e){const n=t.map(h=>({...h,...dh(h.mesh,h.local)})),s=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const h of n)for(const u of[0,1,2])s[u]=Math.min(s[u],h.low[u]),i[u]=Math.max(i[u],h.high[u]);const r=Bm(s[0],i[0],e),o=Bm(s[2],i[2],e),a=`${r.join(",")}|${o.join(",")}`,l=n.flatMap(h=>{if(h.high[0]-h.low[0]<=e*2.5&&h.high[2]-h.low[2]<=e*2.5||h.whole||h.mesh.joined||(h.mesh.marks?.length??0)>0){const d=[(h.low[0]+h.high[0])/2,(h.low[1]+h.high[1])/2,(h.low[2]+h.high[2])/2];return[{part:h.part,mesh:h.mesh,cut:!1,cell:Cx(r,o,d)}]}return qm(Lx,h.inSpace,a,()=>Hx(h.inSpace,r,o)).map(d=>({part:h.part,mesh:d.mesh,cut:!0,cell:d.cell}))}),c=(s[1]+i[1])/2;return{pieces:l,middle:([h,u])=>[(r[h]+r[h+1])/2,c,(o[u]+o[u+1])/2]}}const jm=.004,fh=.05,Ym=new WeakMap;function Wx(t){let e=Ym.get(t);return e===void 0&&(e=!t.joined&&!t.walls&&t.faces.length>=4&&t.faces.every(n=>{const s=t.vertices[n.corners[0]];return t.vertices.every(i=>n.normal[0]*(i[0]-s[0])+n.normal[1]*(i[1]-s[1])+n.normal[2]*(i[2]-s[2])<=1e-6)}),Ym.set(t,e)),e}const Km=new WeakMap;function Xm(t){return t.filter(({mesh:e})=>Wx(e)).map(({part:e,key:n,inSpace:s,low:i,high:r})=>{let o=Km.get(s);return o||(o=s.faces.map(a=>{const l=s.vertices[a.corners[0]];return{normal:a.normal,offset:a.normal[0]*l[0]+a.normal[1]*l[1]+a.normal[2]*l[2]}}),Km.set(s,o)),{part:e,key:n,planes:o,low:i,high:r}})}function Dx(t,e,n,s){const i=e.reduce((r,o)=>[r[0]+o[0]/e.length,r[1]+o[1]/e.length,r[2]+o[2]/e.length],[0,0,0]);for(const r of s){if(r.part===t||[0,1,2].some(a=>i[a]<r.low[a]-fh||i[a]>r.high[a]+fh))continue;if(r.planes.every(a=>{const l=a.normal[0]*n[0]+a.normal[1]*n[1]+a.normal[2]*n[2],c=e.map(u=>a.normal[0]*u[0]+a.normal[1]*u[1]+a.normal[2]*u[2]-a.offset);if(c.every(u=>Math.abs(u)<=jm))return l<-.9;const h=Math.abs(l)<.5?fh:jm;return c.every(u=>u<=h)}))return!0}return!1}const Gm=new WeakMap;function Um(t,e,n,s,i){const r=`${s}|${i.map(l=>l.key).join(";")}`;let o=Gm.get(e);o||Gm.set(e,o=new Map);let a=o.get(r);if(!a){o.size>=48&&o.clear();const l=h=>{const u=[n[0]*h[0]+n[4]*h[1]+n[8]*h[2],n[1]*h[0]+n[5]*h[1]+n[9]*h[2],n[2]*h[0]+n[6]*h[1]+n[10]*h[2]],d=Math.hypot(...u)||1;return[u[0]/d,u[1]/d,u[2]/d]},c=e.vertices.map(h=>ie(n,h));a=e.faces.map(h=>Dx(t,h.corners.map(u=>c[u]),l(h.normal),i)),o.set(r,a)}return a}const As={turn:{description:"Which way it faces: 0 toward the viewer, 1 screen-right, 2 away, 3 (or −1) screen-left; in between turns it in 3D",unit:"quarter turns"},tilt:{description:"How far the camera looks down on it: 0 level, 12 the ¾ look, 90 straight down",unit:"degrees",default:12,min:-90,max:90},pitch:{description:"Nose up (+) or down (−), about its middle on the ground",unit:"degrees"},roll:{description:"Tipped onto its right (+) or left (−) side",unit:"degrees"},squash:{description:"Squash and stretch about the ground, keeping its volume: 1 normal, below squashed, above stretched",unit:"factor",default:1,min:.3,max:3},lift:{description:"Off the ground",unit:"metres"},lean:{description:"The top sheared forward (+) or back (−): speed and drag",unit:"shear"},size:{description:"Its size, about the ground: 1 as built, 0 gone (pop it in or out)",unit:"factor",default:1,min:0}},gh=Math.PI/180;function Vm(t,e,n){return{toView:s=>Il(Qt(s,t*90*gh),-e*gh),toScreen:s=>({x:s[0]*n,y:-s[1]*n})}}const Jm=new WeakMap,zi=t=>No(t),No=t=>{let e=Jm.get(t);return e||Jm.set(t,e=$p(t)),e};function It(t,e,n){return e[n]??t.controls[n]?.default??As[n]?.default??0}function qi(t,e){const n=Math.max(.05,It(t,e,"squash")),s=1/Math.sqrt(n),r=[1,0,0,0,0,1,It(t,e,"lean"),0,0,0,1,0,0,0,0,1];return[wn([0,It(t,e,"lift"),0]),me(Vt([1,0,0],-It(t,e,"pitch"))),me(Vt([0,0,1],It(t,e,"roll"))),r,kn([s,n,s]),kn(Array(3).fill(Math.max(0,It(t,e,"size"))))].reduce((o,a)=>Rt(o,a))}function ph(t,e){const n=qi(t,e),s=new Map,i=Object.entries(t.controls).flatMap(([o,a])=>(a.bind??[]).map(l=>({value:It(t,e,o),bind:l}))),r=o=>{const a=s.get(o.id);if(a)return a;const l=o.parent?t.parts.find(h=>h.id===o.parent):void 0;if(o.parent&&!l)throw new Error(`prop rig: part "${o.id}" hangs from "${o.parent}", which is not a part`);let c=Rt(l?r(l):n,wn(o.at??[0,0,0]));if(o.rotate){const[h,u,d]=o.rotate;h&&(c=Rt(c,me(Vt([1,0,0],h)))),u&&(c=Rt(c,me(Vt([0,1,0],u)))),d&&(c=Rt(c,me(Vt([0,0,1],d))))}for(const{value:h,bind:u}of i)if(!(!u.parts.includes(o.id)||h===0)){if(u.translate&&(c=Rt(c,wn([u.translate[0]*h,u.translate[1]*h,u.translate[2]*h]))),u.rotate){const d=u.rotate.pivot??[0,0,0],f=u.rotate.axis==="x"?[1,0,0]:u.rotate.axis==="y"?[0,1,0]:[0,0,1];c=[c,wn(d),me(Vt(f,u.rotate.degrees*h)),wn([-d[0],-d[1],-d[2]])].reduce((p,g)=>Rt(p,g))}u.scale&&(c=Rt(c,kn([1+(u.scale[0]-1)*h,1+(u.scale[1]-1)*h,1+(u.scale[2]-1)*h])))}return s.set(o.id,c),c};for(const o of t.parts)r(o);return s}const mh=(()=>{const t=[-.45,.75,.5],e=Math.hypot(...t);return[t[0]/e,t[1]/e,t[2]/e]})(),Bx=Math.cos(35*gh);function yh(t,e,n,s,i={}){const r=t.derive?{...e,...t.derive(e)}:e,o=ph(t,r),a=n.toView([0,0,0]),l=H=>W=>[H[0]*W[0]+H[4]*W[1]+H[8]*W[2],H[1]*W[0]+H[5]*W[1]+H[9]*W[2],H[2]*W[0]+H[6]*W[1]+H[10]*W[2]],c=qi(t,r),h=i.slice===void 0?null:Ra(c),u=h?t.parts.map(H=>({part:H,mesh:No(H.shape),local:Rt(h,o.get(H.id)),whole:H.shape.type==="tube"})):void 0,d=u?Nx(u,i.slice):void 0,f=u?Xm(u.map(H=>({part:H.part.id,mesh:H.mesh,...dh(H.mesh,H.local)}))):void 0,p=(H,W,j,J)=>{const et=Q=>n.toView(ie(j,Q)),V=W.vertices.map(et),L=V.map(Q=>n.toScreen(Q)),B=i.perspective?i.near:void 0,K=Q=>Q.map(ot=>n.toScreen(ot)),_=Q=>B===void 0?Q:Dm(Q,B),Y=Q=>B===void 0?[Q]:Ox(Q,B),st=l(j),$=W.faces.map(Q=>{const ot=n.toView(st(Q.normal)),ht=[ot[0]-a[0],ot[1]-a[1],ot[2]-a[2]],dt=Math.hypot(...ht)||1;return[ht[0]/dt,ht[1]/dt,ht[2]/dt]}),C=f&&J?Um(H.id,W,J,zm(J),f):void 0,z=Q=>C?.[Q]??!1,X=$.map((Q,ot)=>{if(z(ot))return!1;if(!i.perspective)return Q[2]>1e-6;const dt=W.faces[ot].corners.reduce((bt,wt)=>[bt[0]+V[wt][0],bt[1]+V[wt][1],bt[2]+V[wt][2]],[0,0,0]);return-(Q[0]*dt[0]+Q[1]*dt[1]+Q[2]*dt[2])>1e-9}),N=Q=>W.faces[Q].corners.reduce((ot,ht)=>ot+V[ht][2],0)/W.faces[Q].corners.length,F=W.faces.map((Q,ot)=>({face:Q,i:ot})).filter(({i:Q})=>X[Q]).map(({face:Q,i:ot})=>({i:ot,solved:{points:B===void 0?Q.corners.map(ht=>L[ht]):K(_(Q.corners.map(ht=>V[ht]))),depth:N(ot),tone:.72+.33*Math.max(0,$[ot][0]*mh[0]+$[ot][1]*mh[1]+$[ot][2]*mh[2])}})).filter(Q=>Q.solved.points.length>=3).sort((Q,ot)=>Q.solved.depth-ot.solved.depth);if(i.light){const Q=l(j);for(const{i:ot,solved:ht}of F){const dt=W.faces[ot].corners,bt=dt.reduce((Yh,KT)=>{const Kh=ie(j,W.vertices[KT]);return[Yh[0]+Kh[0]/dt.length,Yh[1]+Kh[1]/dt.length,Yh[2]+Kh[2]/dt.length]},[0,0,0]),wt=Q(W.faces[ot].normal),pe=Math.hypot(...wt)||1,Vi=i.light(bt,[wt[0]/pe,wt[1]/pe,wt[2]/pe]);ht.light=Vi.light,ht.fog=Vi.fog}}const D=F.map(Q=>Q.solved),G=zx(W),q=[],Z=[];for(const[Q,ot]of G){const ht=ot.filter(bt=>X[bt]).length;if(ht===0)continue;const dt=ot.length===2&&ht===2&&W.creases!==!1&&$[ot[0]][0]*$[ot[1]][0]+$[ot[0]][1]*$[ot[1]][1]+$[ot[0]][2]*$[ot[1]][2]<Bx;ot.length===1&&(W.joined||qx(W,Q))||(ot.length===1||ht===1||dt)&&(q.push(Q.split("-").map(Number)),Z.push(ot.filter(bt=>X[bt]).reduce((bt,wt)=>N(wt)>N(bt)?wt:bt)))}const tt=Q=>W.faces.findIndex(ot=>ot.corners.length>4&&Math.sign(Yx(W.vertices[Q],ot.normal))>0),R=(W.marks??[]).filter(([Q])=>tt(Q)<0||X[tt(Q)]),U=([Q,ot])=>B===void 0?[[L[Q],L[ot]]]:Y([V[Q],V[ot]]).map(K),nt=R.flatMap(U),at=Q=>B===void 0?[Q.map(ot=>L[ot])]:Y(Q.map(ot=>V[ot])).map(K);if(i.slice!==void 0){const Q=new Map;q.forEach((ot,ht)=>Q.set(Z[ht],[...Q.get(Z[ht])??[],ot]));for(const{i:ot,solved:ht}of F){ht.edges=ey(Q.get(ot)??[]).flatMap(at);const dt=W.faces[ot].corners;ht.center=dt.reduce((wt,pe)=>[wt[0]+V[pe][0]/dt.length,wt[1]+V[pe][1]/dt.length,wt[2]+V[pe][2]/dt.length],[0,0,0]),ht.normal=$[ot];const bt=F[F.length-1].i;ht.marks=R.filter(([wt])=>(tt(wt)>=0?tt(wt):bt)===ot).flatMap(U)}}const rt=H.glow?Math.max(0,Math.min(1,It(t,r,H.glow.control))):0,ct=H.fade?Math.max(0,Math.min(1,It(t,r,H.fade.control))):0,it=H.fade?Math.max(0,Math.min(1,H.fade.from+(H.fade.to-H.fade.from)*ct)):1;return{part:H,depth:V.reduce((Q,ot)=>Q+ot[2],0)/Math.max(1,V.length),faces:D,edges:ey(q).flatMap(at),marks:nt,glow:rt,opacity:it,...H.shape.type==="tube"?{spine:jx(Y(H.shape.points.map(et)).map(K))}:{},...W.walls?{cut:!0}:{}}},g=new Map(u?.map(H=>[H.part.id,H.local])),y=(d?d.pieces.map(H=>({part:H.part,mesh:H.mesh,m:H.cut?c:o.get(H.part.id),local:H.cut?fr():g.get(H.part.id),cell:H.cell})):t.parts.map(H=>({part:H,mesh:No(H.shape),m:o.get(H.id),local:void 0,cell:void 0}))).map(H=>({cell:H.cell,solved:p(H.part,H.mesh,H.m,H.local)})),v=y.map(H=>H.solved),k=H=>H.filter(W=>W.faces.length>0&&W.opacity>.01).sort((W,j)=>W.depth-j.depth);let w;if(d){const H=new Map(t.parts.map(j=>{const J=o.get(j.id),et=No(j.shape).vertices;return[j.id,et.reduce((V,L)=>V+n.toView(ie(J,L))[2],0)/Math.max(1,et.length)]})),W=new Map;for(const j of y){const J=j.cell.join(",");W.has(J)||W.set(J,{cell:j.cell,parts:[]}),W.get(J).parts.push(j.solved),j.solved.depth=H.get(j.solved.part.id)}w=[...W.values()].map(({cell:j,parts:J})=>({depth:n.toView(ie(c,d.middle(j)))[2],parts:k(J)})).filter(j=>j.parts.length>0)}const T={};for(const[H,W]of Object.entries(t.anchors??{})){const j=W.part?o.get(W.part):qi(t,r);if(!j)throw new Error(`prop rig: anchor "${H}" is on "${W.part}", which is not a part`);const J=n.toView(ie(j,W.at));T[H]={point:n.toScreen(J),depth:J[2]}}const[A,M]=t.footprint??[t.length*.45,t.length],x=Math.max(0,It(t,r,"lift")),S=Math.max(0,It(t,r,"size"))/(1+x*.8),E=Array.from({length:24},(H,W)=>{const j=Math.PI*2*W/24;return n.toView([Math.cos(j)*A*.55*S,0,Math.sin(j)*M*.55*S])}),P=i.perspective?i.near:void 0,I={points:(P===void 0?E:Dm(E,P)).map(H=>n.toScreen(H)),opacity:.16*S},O=v.filter(H=>H.part.seeThrough&&H.opacity>.01).flatMap(H=>H.faces.map(W=>W.points));return{under:k(v.filter(H=>!H.part.overRider)),over:k(v.filter(H=>H.part.overRider)),...w?{cells:w}:{},anchors:T,openings:O,shadow:I,pxPerUnit:s,sizePx:t.height*s}}const Zm=new WeakMap;function zx(t){let e=Zm.get(t);if(!e){e=new Map;for(let n=0;n<t.faces.length;n++){const s=t.faces[n].corners;for(let i=0;i<s.length;i++){const r=s[i],o=s[(i+1)%s.length],a=r<o?`${r}-${o}`:`${o}-${r}`,l=e.get(a);l?l.push(n):e.set(a,[n])}}Zm.set(t,e)}return e}function Qm(t,e){const n=t.derive?{...e,...t.derive(e)}:e,s=ph(t,n),i=Ra(qi(t,n))??fr(),r=o=>Math.max(0,Math.min(1,o));return t.parts.map(o=>{const a=o.fade?r(It(t,n,o.fade.control)):0;return{part:o,matrix:s.get(o.id),local:Rt(i,s.get(o.id)),glow:o.glow?r(It(t,n,o.glow.control)):0,opacity:o.fade?r(o.fade.from+(o.fade.to-o.fade.from)*a):1}})}function ty(t,e){const n=t.derive?{...e,...t.derive(e)}:e,s=ph(t,n),i=qi(t,n),r={};for(const[o,a]of Object.entries(t.anchors??{})){const l=a.part?s.get(a.part):i;if(!l)throw new Error(`prop rig: anchor "${o}" is on "${a.part}", which is not a part`);r[o]=ie(l,a.at)}return r}function qx(t,e){if(!t.walls)return!1;const[n,s]=e.split("-").map(r=>t.vertices[Number(r)]),i=(r,o)=>o.some(a=>Math.abs(n[r]-a)<1e-6&&Math.abs(s[r]-a)<1e-6);return i(0,t.walls.x)||i(2,t.walls.z)}function jx(t){return t.reduce((e,n)=>!e||n.length>e.length?n:e,void 0)}const Yx=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2];function ey(t){const e=t.map(s=>[...s]),n=[];for(;e.length>0;){const s=[...e.shift()];let i=!0;for(;i;){i=!1;for(let r=0;r<e.length;r++){const[o,a]=e[r],l=s[s.length-1],c=s[0];if(o===l)s.push(a);else if(a===l)s.push(o);else if(a===c)s.unshift(o);else if(o===c)s.unshift(a);else continue;e.splice(r,1),i=!0;break}}n.push(s)}return n}function bh(t,e){if(!t.loose?.size)return;const n={};for(const[s,i]of t.loose)n[s]={x:e[`piece.${i}.x`]??0,y:e[`piece.${i}.y`]??0,rotate:e[`piece.${i}.rotate`]??0,opacity:e[`piece.${i}.opacity`]??1};return n}function wh(t){const e={};for(const[n,s]of Object.entries({...As,...t.rig.controls})){const{bind:i,...r}=s;e[n]=r}return e}function ny(t){const{prop:e}=t,n=t.scale??60,s=e.rig.length*n*1.4,i=e.rig.height*n*1.6,r=wh(e),o={};for(const[l,c]of Object.entries(r))o[l]=t.values?.[l]??c.default??0;const a={look:t.look,ink:t.ink,lineWidth:t.lineWidth,pencil:t.pencil,seed:t.seed,style:t.style,paper:t.paper};return{type:"custom",x:t.x-s/2,y:t.y-i,width:s,height:i,props:o,prop:e,propScale:n,propDraw:a,about:{kind:e.kind,summary:e.summary,props:r,actions:Object.fromEntries(Object.entries(e.actions).map(([l,c])=>[l,c.summary]))},draw(l,c,h){const u=c.props??{};l.translate(s/2,i),yc(l,Ps(e,u,n),{...a,time:h,loose:bh(c,u)})}}}function Ps(t,e,n){const s=Vm(It(t.rig,e,"turn"),It(t.rig,e,"tilt"),n);return yh(t.rig,e,s,n)}function Wo(t,e,n){const s={...t.props};let i=0,r=0;for(const[l,c]of e.state?.values.get(n)??[])typeof c=="number"&&(l==="x"?i=c:l==="y"?r=c:l in s&&(s[l]=c));const o={x:t.x+t.width/2+i,y:t.y+t.height+r},a=Ps(t.prop,s,t.propScale);return{values:s,origin:o,solved:a,anchor(l){const c=a.anchors[l];if(!c)throw new Error(`${t.prop.kind}: no anchor "${l}" (it has ${Object.keys(a.anchors).join(", ")||"none"})`);return{x:o.x+c.point.x,y:o.y+c.point.y,depth:c.depth}}}}function Kx(t,e,n,s,i={}){const r=Wo(e,n,s);return t.save(),t.translate(r.origin.x,r.origin.y),yc(t,r.solved,{...e.propDraw,time:n.time,loose:bh(e,r.values),rider:i.rider?o=>{o.save(),o.translate(-r.origin.x,-r.origin.y),i.rider(o),o.restore()}:void 0}),t.restore(),r}const $s={kind:"prop",create:"propSurface(propTarget({ x, y, prop }), { tracks? }): its controls and anchors are those the catalog lists for its preset",anchors:{box:"the prop’s whole box","anchor:NAME":"one of its rig’s anchors (door, seat, branch, ridge…), as posed at the time","part:ID":"one of its parts as seen at the time (window-1, door-left, wheel-0-left…); it can come loose as a piece","control:NAME":"where the parts a control moves or lights are (control:door is the doors, control:lights the lamps; a control of the whole prop, like lift, is its box)"},edits:{set:"control anchors; { at, value, duration? }: move a control to a value",switch:"control anchors; { at, on?, duration? }: a control to its full value (open, on), or back to its rest value with on: false",move:"a part; { at, to: an anchor name or { x, y }, duration? }: carry the part there, loose",fling:"a part; { at, velocity?, spin?, gravity?, duration? }: knock the part off on a spinning arc"}},Xx=400,Gx=.2;function Ux(t,e={}){const{prop:n}=t,s=wh(n),i=Object.keys(s),r=Object.keys(n.rig.anchors??{}),o=n.rig.parts.map(A=>A.id),a=ks(),l=Oi(a),c=e.tracks?.length?new Ht({id:`${n.kind}-surface`,tracks:e.tracks}):void 0,h=Math.max(0,...(e.tracks??[]).flatMap(A=>A.keyframes.map(M=>M.time))),u=new Map,d=new Map;t.loose=d;const f=t.props,p=A=>{const M={...t.props};let x=0,S=0;if(c){const E=c.getStateAtTime(Math.min(A,h));for(const P of E.values.values())for(const[I,O]of P)typeof O=="number"&&(I==="x"?x=O:I==="y"?S=O:I in M&&(M[I]=O))}for(const E of i)a.keys(E)?.length&&(M[E]=a.valueAt(E,A));return{values:M,origin:{x:t.x+t.width/2+x,y:t.y+t.height+S}}},g=A=>{const{kind:M,rest:x}=_n(A),S=E=>rn(n.kind,A,$s,E);if(M==="box"){if(x)throw S("box takes no arguments");return{kind:M}}if(M==="anchor"){if(!r.includes(x))throw S(ft(`${n.kind} anchor`,x,r));return{kind:M,name:x}}if(M==="part"){if(!o.includes(x))throw S(ft(`${n.kind} part`,x,o));return{kind:M,name:x}}if(M==="control"){if(!i.includes(x))throw S(ft(`${n.kind} control`,x,i));return{kind:M,name:x}}throw S()},m=A=>{const M=(n.rig.controls[A]?.bind??[]).flatMap(S=>S.parts),x=n.rig.parts.filter(S=>S.glow?.control===A).map(S=>S.id);return new Set([...M,...x])},y=new Map,v=A=>{let M=y.get(A);if(!M){const x=p(A);y.set(A,M={...x,solved:Ps(n,x.values,t.propScale)})}return M},k=(A,M)=>{const x=g(A),{values:S,origin:E,solved:P}=v(M);if(x.kind==="box")return Mt(E.x-t.width/2,E.y-t.height,t.width,t.height);if(x.kind==="anchor"){const H=P.anchors[x.name].point,W=Gx*t.propScale;return Mt(E.x+H.x-W/2,E.y+H.y-W/2,W,W)}if(x.kind==="part")return O(new Set([x.name]),`part "${x.name}" is`);const I=m(x.name);if(I.size===0)return Mt(E.x-t.width/2,E.y-t.height,t.width,t.height);return O(I,`the parts control "${x.name}" moves are`);function O(H,W){const j=[...P.under,...P.over].filter(B=>H.has(B.part.id)).flatMap(B=>B.faces.flatMap(K=>K.points));if(j.length===0){const B=Number.isFinite(M)?`at ${M} ms`:"after its edits";throw new Error(`${n.kind}: ${W} turned away from the viewer ${B}; aim at an anchor (${r.map(K=>`anchor:${K}`).join(", ")||"none"}) or box`)}const J=j.map(B=>B.x),et=j.map(B=>B.y),V=Math.min(...J),L=Math.min(...et);return Mt(E.x+V,E.y+L,Math.max(...J)-V,Math.max(...et)-L)}},w=(A,M)=>{try{return k(A,M)}catch{return}},T={kind:"prop",prop:t,about:$s,target:t,box:Mt(t.x,t.y,t.width,t.height),anchor(A,M=1/0){return k(A,M)},piece(A){const M=g(A);if(M.kind!=="part")throw new Error(`${n.kind}: a piece is a part, part:ID (${o.slice(0,6).map(P=>`part:${P}`).join(", ")}…), not "${A}"`);const x=u.get(M.name);if(x)return x;const S=[M.name];for(let P=0;P<S.length;P++)for(const I of n.rig.parts)I.parent===S[P]&&!S.includes(I.id)&&S.push(I.id);const E={id:u.size+1,part:M.name,home:k(A,0)};u.set(M.name,E);for(const P of S)d.set(P,E.id);for(const P of["x","y","rotate"])f[`piece.${E.id}.${P}`]=0;return f[`piece.${E.id}.opacity`]=1,E},edit(A,M,x){if(!(A in $s.edits))throw Ci(n.kind,A,$s);const S=Array.isArray(M)?M:[M];if(S.length===0)throw new Error(`${n.kind}.edit: ${A} takes at least one anchor`);if(y.clear(),A==="move"||A==="fling"){if(S.length>1)throw new Error(`${n.kind}.edit: ${A} takes one part anchor`);const E=T.piece(S[0]);if(A==="fling")return T.fling(E,x);const P=x.to;if(!P)throw new Error(`${n.kind}.edit: move needs \`to\`, an anchor name or { x, y }`);const I=typeof P=="string"?k(P,x.at):void 0;return T.move(E,{...x,to:I?{x:I.left+I.width/2,y:I.top+I.height/2}:P})}for(const E of S){const P=g(E);if(P.kind!=="control")throw new Error(`${n.kind}.edit: ${A} takes control anchors (control:${i.join(", control:")}), not "${E}"`);const I=s[P.name];let O;if(A==="set"){if(typeof x.value!="number"||!Number.isFinite(x.value))throw new Error(`${n.kind}.edit: set needs \`value\`, a number (${P.name}: ${I.description})`);O=x.value}else O=x.on===!1?I.default??I.min??0:I.max??1;a.tween(P.name,p(x.at).values[P.name],O,x,Xx)}return T},follow(A,M){return y.clear(),l.follow(A,M),T},fling(A,M){return y.clear(),l.fling(A,M),T},move(A,M){return y.clear(),l.move(A,M),T},ride(A,M,x){const S=[...i.flatMap(P=>vs(a.keys(P))),...(e.tracks??[]).flatMap(P=>vs(P.keyframes.filter(I=>typeof I.value=="number")))];if(S.length===0)return A;const E=[...r.map(P=>`anchor:${P}`),...o.map(P=>`part:${P}`)].flatMap(P=>{const I=w(P,0);return I?[{top:I.top,offset:O=>(w(P,O)?.top??I.top)-I.top,windows:S}]:[]});return So(A,M,{ground:x.ground,every:x.every??sn,floors:E})},tracks:a.tracks};return T}const Vx={body:"#e8574a",trim:"#3b3b44",glass:"#bfe3f2",tyre:"#2c2c33",hub:"#c9ccd3",light:"#fff4b8",tail:"#ff5a4f",inside:"#3b3640",seat:"#6d5d55"};function Ne(t){const e={...Vx,...t.colors},n=[],{forwardMost:s,backMost:i,top:r}=sy(t);t.body&&n.push({id:"body",shape:{type:"extrude",profile:t.body,width:t.width},fill:e.body});for(const[h,u]of(t.frame??[]).entries())n.push({id:`frame-${h}`,shape:{type:"tube",points:u.points,radius:u.radius??.035,segments:6},fill:u.color??e.body,outline:.7});for(const[h,u]of(t.windows??[]).entries())for(const d of[1,-1])n.push({id:`window-${h}-${d>0?"left":"right"}`,shape:{type:"panel",points:[[u.from,u.low],[u.to,u.low],[u.to,u.high],[u.from,u.high]],facing:d>0?"left":"right"},at:[d*(t.width/2+.01),0,0],fill:e.glass,outline:.7,seeThrough:!0,glow:t.lights?{control:"lights",color:"#ffe9a3"}:void 0});for(const h of t.extras??[])n.push(h);if(t.cabin){const h=t.cabin.width??t.width*.85;n.push({id:"cabin",shape:{type:"extrude",profile:t.cabin.profile,width:h},fill:e.glass,outline:.9,seeThrough:!0,layer:1});const u=Math.min(...t.cabin.profile.map(([,f])=>f)),d=Math.max(...t.cabin.profile.map(([,f])=>f));for(const[f,p]of(t.cabin.pillars??[]).entries())n.push({id:`pillar-${f}`,shape:{type:"box",size:[h+.02,d-u,.1]},at:[0,(u+d)/2,p],fill:e.body,outline:.8,layer:1})}const o=t.wheels[0]?.radius??.4,a=[];t.wheels.forEach((h,u)=>{const d=h.side===0?[0]:[1,-1],f=h.thickness??(h.style==="spoked"?.05:.26);for(const p of d){const g=`wheel-${u}-${p>0?"left":p<0?"right":"middle"}`;if(a.push({parts:[g],rotate:{axis:"x",degrees:o/h.radius}}),n.push({id:g,shape:{type:"cylinder",radius:h.radius,length:f,axis:"x",segments:20,spokes:h.style==="spoked"?8:0},at:[p*h.side,h.radius,h.forward],fill:h.style==="spoked"?void 0:e.tyre,ink:h.style==="spoked"?e.tyre:void 0,outline:h.style==="spoked"?1.3:1}),h.style!=="spoked")for(const m of p===0?[1,-1]:[p])n.push({id:`${g}-hub${p===0?m>0?"-left":"-right":""}`,parent:g,shape:{type:"cylinder",radius:h.radius*.55,length:.02,axis:"x",segments:14,spokes:5},at:[m*(f/2+.012),0,0],fill:e.hub,outline:.6})}});const l={wheelSpin:{description:"How far the wheels have turned (keyed exactly with the distance driven, so they never skate)",unit:"degrees",bind:a}};if(t.door){const{from:h,to:u,low:d,high:f}=t.door,p=[[h,d],[u,d],[u,f],[h,f]];for(const g of[1,-1]){const m=g>0?"left":"right";n.push({id:`doorway-${m}`,shape:{type:"panel",points:p,facing:g>0?"left":"right"},at:[g*(t.width/2+.004),0,0],fill:e.inside,outline:.5,seeThrough:!0});const y=h+(u-h)*.15,v=h+(u-h)*.55;n.push({id:`seat-back-${m}`,shape:{type:"panel",points:[[y,d+.05],[v,d+.05],[v-.08,f-.06],[y+.06,f-.04]],facing:g>0?"left":"right"},at:[g*(t.width/2+.006),0,0],fill:e.seat,outline:.4}),n.push({id:`door-${m}`,shape:{type:"panel",points:p.map(([k,w])=>[k-u,w]),facing:g>0?"left":"right"},at:[g*(t.width/2+.01),0,u],fill:e.body,outline:.7,overRider:!0})}l.door={description:"Doors open: 0 shut, 1 open (hinged at the front)",unit:"0..1",min:0,max:1,bind:[{parts:["door-left"],rotate:{axis:"y",degrees:-70}},{parts:["door-right"],rotate:{axis:"y",degrees:70}}]}}if(t.lights){const{across:h,low:u,high:d,front:f,back:p}=t.lights,g=(t.lights.size??.32)/2,m=[[-g,u],[g,u],[g,d],[-g,d]];for(const y of[1,-1])n.push({id:`headlight-${y}`,shape:{type:"panel",points:m,facing:"front"},at:[y*h,0,f],fill:e.light,outline:.6,glow:{control:"lights",color:"#ffffff"}}),n.push({id:`taillight-${y}`,shape:{type:"panel",points:m,facing:"back"},at:[y*h,0,p],fill:yo(e.tail,.62),outline:.6,glow:{control:"lights",color:e.tail}});l.lights={description:"Lights on: 0 off, 1 on",unit:"0..1",min:0,max:1}}t.antenna&&(n.push({id:"antenna",shape:{type:"tube",points:[[0,0,0],[0,.75,0]],radius:.018,segments:5},at:t.antenna,fill:e.trim,outline:.6}),n.push({id:"antenna-tip",parent:"antenna",shape:{type:"ellipsoid",radii:[.05,.05,.05],segments:8},at:[0,.77,0],fill:e.tail,outline:.6}),l.antenna={description:"Antenna bend (follow-through: it trails the motion on a spring)",unit:"degrees",bind:[{parts:["antenna"],rotate:{axis:"x",degrees:1}}]});const c={parts:n,controls:l,length:s-i,height:r,footprint:[t.width,s-i],anchors:{...t.seat?{seat:{at:t.seat}}:{},front:{at:[0,r*.45,s]},back:{at:[0,r*.45,i]},roof:{at:[0,r,0]},...t.door?{door:{at:[-t.width/2,(t.door.low+t.door.high)/2,(t.door.from+t.door.to)/2]}}:{},...t.anchors}};return{kind:t.kind??"vehicle",family:"vehicle",summary:t.summary??"A wheeled vehicle",rig:c,actions:Jx(t),acting:iy,colors:{body:e.body,ink:"#26262b"},follow:t.antenna?[{control:"antenna",of:"x",per:.9,stiffness:140,damping:7,limit:35}]:void 0,wheelRadius:o,...t.wheels.length>0?{moves:{drive:{speed:t.speed??6,perMetre:{wheelSpin:180/(Math.PI*o)}}}}:{}}}function sy(t){const e=[...(t.body??[]).map(([s])=>s),...(t.frame??[]).flatMap(s=>s.points.map(i=>i[2])),...t.wheels.flatMap(s=>[s.forward+s.radius,s.forward-s.radius])],n=[...(t.body??[]).map(([,s])=>s),...(t.cabin?.profile??[]).map(([,s])=>s),...(t.frame??[]).flatMap(s=>s.points.map(i=>i[1])),...t.wheels.map(s=>s.radius*2)];return{forwardMost:Math.max(...e),backMost:Math.min(...e),top:Math.max(...n)}}const iy={depth:{turn:0,lift:0,lights:0,pitch:1,roll:1,squash:1,lean:1,door:2},limits:{turn:.08,pitch:5,roll:4,lean:.1,squash:.06,door:.12,lift:0},eyes:[],headTurns:{},drift:[]};function Do(t,e,n,s,i,r,o=!1){const a=t.facing()||Math.sign(s-t.x)||1,l=t.values.wheelSpin??0,c=(s-t.x)*a/t.scale;t.set("wheelSpin",e,l),t.move(e,n,s,{easing:i}),t.set("wheelSpin",n,o?l:l+c/r*(180/Math.PI),i)}const ry=.4;function Jx(t){const e=t.wheels[0]?.radius??.4,{forwardMost:n,backMost:s}=sy(t),i=(n-s)/2,r=(a,l,c)=>{const h=a.exaggeration;let u=l;return a.facing()!==c&&(u=a.turnTo(u,c>0?"right":"left")),a.key(u+200,{pitch:4*h,squash:1-.07*h,lean:-.1*h},{act:!1,easing:"ease-out"}),Do(a,u,u+200,a.x-c*.15*h*a.scale,"ease-out",e),a.effect({kind:"exhaust",time:u+150,x:a.x-c*i*a.scale,y:a.floor-.3*a.scale,length:900,direction:-c}),u+260},o=(a,l,c)=>{const h=a.exaggeration*(c?1.8:1);a.key(l,{pitch:-5*h,lean:-.08*h,squash:.95},{act:!1,easing:"ease-out"}),a.key(l+380,{pitch:0,lean:0,squash:1})};return{drive:{summary:"Drives to `to`: rocks back and squats, lunges forward stretched, and stops with a nose-dive that settles; wheels roll exactly the distance.",needs:["to"],uses:["speed","for"],run(a,l,c){const h=Math.sign(l.to-a.x);if(h===0)return{end:c};const u=r(a,c,h),d=a.exaggeration,f=Math.abs(l.to-a.x),p=l.for??Math.max(500,f/(l.speed??ry));return a.effect({kind:"dust",time:u,x:a.x-h*i*a.scale,y:a.floor,length:600,direction:-h}),a.key(u+140,{pitch:-1.5*d,squash:1+.05*d,lean:.12*d},{act:!1,easing:"ease-out"}),a.key(u+Math.max(160,p-160),{pitch:0,lean:.08*d,squash:1.02},{act:!1}),Do(a,u,u+p,l.to,"ease-in-out",e),o(a,u+p,!1),{end:u+p+380,contact:u,release:u+p}}},brake:{summary:"Drives toward `to` and slams on the brakes: the wheels lock and it skids the last stretch, nose diving, leaving skid marks.",needs:["to"],uses:["speed","for"],run(a,l,c){const h=Math.sign(l.to-a.x);if(h===0)return{end:c};const u=r(a,c,h),d=a.exaggeration,f=a.x,p=Math.abs(l.to-f),g=l.for??Math.max(600,p/(l.speed??ry*1.2)),m=u+g*.55,y=f+(l.to-f)*.65;return a.key(u+140,{pitch:-1.5*d,squash:1+.06*d,lean:.14*d},{act:!1,easing:"ease-out"}),Do(a,u,m,y,"ease-in",e),a.key(m+80,{pitch:-7*d,lean:-.12*d,squash:.94},{act:!1,easing:"ease-out"}),Do(a,m,u+g,l.to,"ease-out",e,!0),a.effect({kind:"skid",time:m,x:y,toX:l.to,y:a.floor,length:g*.45+1500}),a.effect({kind:"dust",time:u+g,x:l.to+h*i*a.scale,y:a.floor,length:600,direction:h}),o(a,u+g,!0),{end:u+g+380,contact:m,release:u+g}}},bump:{summary:"Hits a bump: squashes, hops up stretched, lands squashed with dust, and springs back.",uses:["for"],run(a,l,c){const h=a.exaggeration;return a.key(c+90,{squash:1-.16*h,pitch:3*h},{act:!1,easing:"ease-out"}),a.key(c+300,{lift:.35*h,squash:1+.12*h,pitch:-3*h},{act:!1,easing:"ease-out"}),a.key(c+540,{lift:0,squash:1-.2*h,pitch:0},{act:!1,easing:"ease-in"}),a.key(c+820,{squash:1}),a.effect({kind:"dust",time:c+540,x:a.x,y:a.floor,length:500}),{end:c+820,contact:c+540}}},honk:{summary:"Honks: a stretch and squash pulse, with honk lines from the front.",run(a,l,c){const h=a.exaggeration;a.key(c+110,{squash:1+.12*h,lean:.04*h},{act:!1,easing:"ease-out"}),a.key(c+240,{squash:1-.06*h,lean:0},{act:!1}),a.key(c+520,{squash:1});const u=a.facing();return a.effect({kind:"honk",time:c+60,x:a.x+(u||1)*i*a.scale,y:a.floor-.7*a.scale,length:700,direction:u||1}),{end:c+520,contact:c+60}}},...t.door?{door:{summary:"Opens the doors (`open: true`) or shuts them (`open: false`).",needs:["open"],run(a,l,c){return a.key(c+450,{door:l.open?1:0}),{end:c+600,contact:c+450}}}}:{},...t.lights?{lights:{summary:"Switches the lights on (`on: true`) or off.",needs:["on"],run(a,l,c){return a.key(c+120,{lights:l.on?1:0},{act:!1}),{end:c+300,contact:c+120}}}}:{}}}function oy(t={}){return Ne({kind:"car",summary:"A cartoon car: drives, brakes, bumps, honks, opens its doors, lights up, and turns toward the camera.",body:[[-2,.32],[2,.32],[2.08,.52],[1.98,.82],[1.05,.95],[-1.72,.98],[-2.02,.86],[-2.08,.5]],width:1.8,cabin:{profile:[[-1.5,.94],[.92,.94],[.3,1.52],[-1.22,1.54]],width:1.56,pillars:[-.42]},wheels:[{forward:1.28,side:.8,radius:.4},{forward:-1.28,side:.8,radius:.4}],door:{from:-.4,to:.88,low:.36,high:.92},lights:{across:.58,low:.55,high:.72,front:2.05,back:-2.06},antenna:t.antenna===!1?void 0:[.5,1.5,-1.05],seat:[0,.3,-.15],colors:t.colors})}function ay(t={}){return Ne({kind:"truck",summary:"A box truck: drives, brakes, bumps, honks, opens its cab doors, lights up, turns toward the camera.",body:[[-3.2,.5],[3.1,.5],[3.15,.95],[3,1.85],[2.3,2.25],[1.2,2.25],[1.2,1],[-3.2,1]],width:2,cabin:{profile:[[1.6,1.35],[2.95,1.35],[2.85,1.85],[2.3,2.15],[1.6,2.15]],width:2.04},extras:[{id:"cargo",shape:{type:"box",size:[2.1,1.75,4.2]},at:[0,1.9,-1.05],fill:t.cargo??"#f1f1ee"}],wheels:[{forward:2.2,side:.85,radius:.48,thickness:.32},{forward:-1.4,side:.85,radius:.48,thickness:.32},{forward:-2.45,side:.85,radius:.48,thickness:.32}],door:{from:1.4,to:2.25,low:.6,high:1.9},lights:{across:.7,low:.62,high:.82,front:3.13,back:-3.22,size:.28},seat:[0,1.15,1.9],colors:{body:"#2f6fb7",...t.colors}})}function ly(t={}){return Ne({kind:"bus",summary:"A bus: drives, brakes, bumps, honks, opens its front doors, lights its windows, turns toward the camera.",body:[[-4.5,.45],[4.5,.45],[4.6,.9],[4.55,2.9],[4.3,3],[-4.4,3],[-4.55,2.75],[-4.55,.6]],width:2.4,windows:Array.from({length:6},(e,n)=>({from:-4+n*1.18,to:-4+n*1.18+1,low:1.55,high:2.6})),extras:[{id:"windscreen",shape:{type:"panel",points:[[-1.05,1.35],[1.05,1.35],[1.05,2.75],[-1.05,2.75]],facing:"front"},at:[0,0,4.58],fill:"#bfe3f2",outline:.8,seeThrough:!0}],wheels:[{forward:3,side:1,radius:.5,thickness:.34},{forward:-2.8,side:1,radius:.5,thickness:.34}],door:{from:3.2,to:4.2,low:.5,high:2.6},lights:{across:.85,low:.65,high:.85,front:4.6,back:-4.56,size:.3},seat:[0,1.2,3.6],colors:{body:"#f2c230",...t.colors}})}function cy(t={}){return Ne({kind:"tractor",summary:"A tractor: big rear wheels and small front ones turning at their own rates; drives, brakes, bumps, honks.",body:[[-.5,.75],[2,.75],[2.12,1.25],[1.9,1.52],[-.5,1.52]],width:1,cabin:{profile:[[-1.35,1],[-.25,1],[-.25,2.55],[-1.35,2.55]],width:1.35},extras:[{id:"roof",shape:{type:"box",size:[1.55,.1,1.35]},at:[0,2.62,-.8],fill:"#3f9b47"},{id:"exhaust",shape:{type:"tube",points:[[.28,1.5,1.25],[.28,2.35,1.25]],radius:.06,segments:6},fill:"#3b3b44",outline:.7}],wheels:[{forward:-.85,side:.85,radius:.78,thickness:.45},{forward:1.55,side:.7,radius:.42,thickness:.26}],lights:{across:.3,low:1,high:1.18,front:2.1,back:-.52,size:.2},seat:[0,1.25,-.8],colors:{body:"#3f9b47",hub:"#e9c64a",...t.colors}})}function hy(t={}){const e=t.colors?.body??"#a8743f";return Ne({kind:"cart",summary:"A wooden cart on spoked wheels with shafts: rolls when pulled (drive), bumps, tips.",body:[[-1.25,.78],[1.25,.78],[1.35,1.18],[-1.35,1.18]],width:1.4,frame:[{points:[[.5,.9,1],[.5,.95,2.7]],radius:.05,color:e},{points:[[-.5,.9,1],[-.5,.95,2.7]],radius:.05,color:e}],wheels:[{forward:0,side:.82,radius:.66,style:"spoked"}],seat:[0,1.2,0],anchors:{shafts:{at:[0,.95,2.7]}},colors:{body:e,tyre:"#5a3a1f",...t.colors}})}function uy(t={}){return Ne({kind:"train carriage",summary:"A railway carriage: rolls along (drive), brakes, lights its windows, turns toward the camera.",body:[[-4,.72],[4,.72],[4,2.8],[3.6,3.12],[-3.6,3.12],[-4,2.8]],width:2.6,windows:Array.from({length:5},(e,n)=>({from:-3.3+n*1.4,to:-3.3+n*1.4+1,low:1.7,high:2.5})),wheels:[{forward:3,side:1,radius:.36,thickness:.16},{forward:2.2,side:1,radius:.36,thickness:.16},{forward:-2.2,side:1,radius:.36,thickness:.16},{forward:-3,side:1,radius:.36,thickness:.16}],lights:{across:.9,low:1,high:1.2,front:4.01,back:-4.01,size:.22},seat:[0,1,1.5],colors:{body:"#2f7d6d",...t.colors}})}function dy(t={}){const e=t.colors?.body??"#e0473b",n=[0,.32,-.05],s=[0,.86,-.22],i=[0,.9,.42],r=[0,.34,.56],o=[0,.34,-.56];return Ne({kind:"bike",summary:"A bicycle: rides (drive) with its wire wheels turning, brakes, bumps, rings its bell (honk).",width:.5,frame:[{points:[o,n]},{points:[n,s]},{points:[s,o]},{points:[s,i]},{points:[n,i]},{points:[i,r]},{points:[[.24,.98,.44],[-.24,.98,.44]],radius:.025,color:"#3b3b44"},{points:[i,[0,.98,.44]],radius:.025,color:"#3b3b44"}],extras:[{id:"saddle",shape:{type:"ellipsoid",radii:[.08,.035,.15],segments:10},at:[0,.89,-.22],fill:"#3b3b44",outline:.7}],wheels:[{forward:.56,side:0,radius:.34,style:"spoked"},{forward:-.56,side:0,radius:.34,style:"spoked"}],seat:[0,.9,-.22],colors:{body:e,tyre:"#2c2c33",...t.colors}})}function fy(t={}){return Ne({kind:"motorbike",summary:"A motorbike: rides (drive) with a lunge, brakes into a skid, bumps, honks, lights up.",body:[[-.62,.62],[.42,.62],[.55,.95],[.3,1.02],[-.1,.92],[-.8,.88],[-.86,.72]],width:.4,frame:[{points:[[0,.33,.78],[0,1.05,.5]],radius:.04,color:"#8c8f98"},{points:[[.3,1.08,.48],[-.3,1.08,.48]],radius:.025,color:"#3b3b44"},{points:[[.12,.42,-.2],[.12,.5,-.95]],radius:.04,color:"#8c8f98"}],extras:[{id:"engine",shape:{type:"box",size:[.38,.34,.5]},at:[0,.45,.05],fill:"#5b5f6a",outline:.8}],wheels:[{forward:.78,side:0,radius:.33,thickness:.14},{forward:-.72,side:0,radius:.33,thickness:.14}],lights:{across:0,low:.9,high:1.04,front:.62,back:-.87,size:.14},seat:[0,.92,-.3],colors:{body:"#1f1f26",hub:"#c9ccd3",...t.colors}})}function gy(t={}){const e=t.height??2.4,n=t.trunkRadius??.16,s=t.canopy?.radius??1.1,i=t.canopy?.shape==="tall",r={trunk:"#8a5a3b",leaves:"#5cae5a",...t.colors},o=Ge(t.canopy?.seed??7),a=[{id:"trunk",shape:{type:"tube",points:[[0,0,0],[.06,e*.5,0],[-.02,e,0]],radius:n,segments:8},fill:r.trunk},{id:"branch",parent:"trunk",shape:{type:"tube",points:[[0,0,0],[.45,.4,.1]],radius:n*.45,segments:6},at:[.04,e*.62,0],fill:r.trunk},{id:"canopy",parent:"trunk",shape:{type:"ellipsoid",radii:[s,s*(i?1.35:.88),s],segments:14},at:[-.02,e+s*.55,0],fill:r.leaves}],l=t.canopy?.lobes??7;for(let h=0;h<l;h++){const u=Math.PI*2*h/l+o.next()*.6,d=(o.next()-.25)*s*(i?1.1:.7),f=s*(.48+o.next()*.22),p=[Math.cos(u)*s*.78,d,Math.sin(u)*s*.6];a.push({id:`lobe-${h}`,parent:"canopy",shape:{type:"ellipsoid",radii:[f,f*.86,f],segments:12},at:p,fill:r.leaves})}const c={parts:a,controls:{sway:{description:"The whole tree bending in the wind, about its base",unit:"degrees",bind:[{parts:["trunk"],rotate:{axis:"z",degrees:1}}]},canopySway:{description:"The canopy bending further than the trunk (it trails the sway)",unit:"degrees",bind:[{parts:["canopy"],rotate:{axis:"z",degrees:1,pivot:[0,-s*.8,0]}}]}},length:s*2.2,height:e+s*2,footprint:[s*1.6,s*1.6],anchors:{canopy:{part:"canopy",at:[0,0,0]},top:{part:"canopy",at:[0,s*.9,0]},base:{at:[0,0,0]},branch:{part:"branch",at:[.45,.4,.1]}}};return{kind:t.kind??"tree",family:"plant",summary:t.summary??"A tree: sways in the wind with its canopy trailing, shakes, sheds leaves, pops up.",rig:c,actions:Zx(),acting:py,colors:{body:r.leaves}}}const py={depth:{sway:1,canopySway:2,size:0,squash:1},limits:{sway:2,canopySway:3,squash:.08},eyes:[],headTurns:{},drift:[]};function Zx(){const t=(e,n,s,i)=>{const r=e.anchor("canopy");e.effect({kind:"leaves",time:n,x:r.x,y:r.y,length:s,direction:i,toY:e.floor})};return{sway:{summary:"Sways in gusts of `wind` (0..1, default 0.5) for `for` ms (default 3000); the canopy trails the trunk, and a strong wind sheds leaves.",uses:["wind","for"],run(e,n,s){const i=n.wind??.5,r=n.for??3e3,o=e.exaggeration,a=260;let l=0;for(let c=a;c<r;c+=a){const h=.55+.45*Math.sin(c/r*Math.PI*2.3),u=Math.sin(c/170)*.35,d=-i*9*o*(h+u*i);e.key(s+c,{sway:d,canopySway:l*1.3},{act:!1,easing:"ease-in-out"}),l=d}if(e.key(s+r,{sway:0,canopySway:0}),i>.45)for(let c=0;c<r;c+=700)t(e,s+c,2200,1);return{end:s+r}}},shake:{summary:"Shakes (something hit it): a quick wobble that dies away, shedding leaves.",uses:["for"],run(e,n,s){const i=n.for??900,r=e.exaggeration,o=6;for(let a=1;a<=o;a++){const l=1-a/(o+1),c=a%2===0?1:-1;e.key(s+i*a/(o+1),{sway:c*5*r*l,canopySway:-c*6*r*l},{act:!1,easing:"ease-in-out"})}return e.key(s+i,{sway:0,canopySway:0}),t(e,s+60,1800,1),t(e,s+260,1800,-1),{end:s+i,contact:s}}},shedLeaves:{summary:"Leaves fall from the canopy for `for` ms (default 2000).",uses:["for"],run(e,n,s){const i=n.for??2e3;for(let r=0;r<i;r+=500)t(e,s+r,2e3,r%1e3===0?1:-1);return{end:s+i}}}}}function my(t={}){const e=t.width??4,n=t.depth??3.2,s=t.wallHeight??2.5,i=t.roofHeight??1.5,r=t.overhang??.25,o={walls:"#f1d9a8",roof:"#b8433a",door:"#7a4b2a",doorway:"#3a2a22",glass:"#bfe3f2",lit:"#ffd66b",chimney:"#9b5a45",...t.colors},a=n/2+.01,l=t.door?.width??.9,c=t.door?.height??1.9,h=t.door?.at??0,u=t.windows??[{at:-1.25,low:1,width:.8,height:.8},{at:1.25,low:1,width:.8,height:.8}],d=[{id:"walls",shape:{type:"box",size:[e,s,n]},at:[0,s/2,0],fill:o.walls},{id:"roof",shape:{type:"extrude",profile:[[-n/2-r,s],[n/2+r,s],[0,s+i]],width:e+r*2},fill:o.roof,layer:1},{id:"doorway",shape:{type:"panel",points:[[0,0],[l,0],[l,c],[0,c]],facing:"front"},at:[h-l/2,0,a-.005],fill:o.doorway,outline:.6,seeThrough:!0},{id:"door",shape:{type:"panel",points:[[0,0],[l,0],[l,c],[0,c]],facing:"front"},at:[h-l/2,0,a+.005],fill:o.door,outline:.8,overRider:!0}];u.forEach((g,m)=>{d.push({id:`window-${m}`,shape:{type:"panel",points:[[-g.width/2,g.low],[g.width/2,g.low],[g.width/2,g.low+g.height],[-g.width/2,g.low+g.height]],facing:"front"},at:[g.at,0,a+.01],fill:o.glass,outline:.8,glow:{control:"lights",color:o.lit}})});for(const g of[1,-1])d.push({id:`side-window-${g>0?"left":"right"}`,shape:{type:"panel",points:[[-.4,1],[.4,1],[.4,1.8],[-.4,1.8]],facing:g>0?"left":"right"},at:[g*(e/2+.01),0,0],fill:o.glass,outline:.8,glow:{control:"lights",color:o.lit}});const f=t.chimney===!1?void 0:{at:t.chimney?.at??e*.28,back:t.chimney?.back??-n*.18};if(f){const g=s+i*(1-Math.abs(f.back)/(n/2+r)),m=s+i+.45;d.push({id:"chimney",shape:{type:"box",size:[.42,m-g+.3,.42]},at:[f.at,(m+g-.3)/2,f.back],fill:o.chimney,layer:1})}const p={parts:d,controls:{door:{description:"The front door open: 0 shut, 1 open",unit:"0..1",min:0,max:1,bind:[{parts:["door"],rotate:{axis:"y",degrees:-80}}]},lights:{description:"The windows lit: 0 dark, 1 lit",unit:"0..1",min:0,max:1}},length:n+r*2,height:s+i+.6,footprint:[e+.6,n+.6],anchors:{door:{at:[h,c/2,a]},doorstep:{at:[h,0,a+.4]},ridge:{at:[0,s+i,0]},...f?{chimney:{at:[f.at,s+i+.5,f.back]}}:{}}};return{kind:t.kind??"house",family:"building",summary:t.summary??"A house: opens its door, lights its windows, puffs chimney smoke, shakes, pops up.",rig:p,actions:Qx(!!f),acting:yy,colors:{body:o.walls}}}const yy={depth:{door:1,lights:0,roll:1,squash:1,size:0},limits:{door:.1,roll:1.5,squash:.05},eyes:[],headTurns:{},drift:[]};function Qx(t){return{door:{summary:"Opens the front door (`open: true`) or shuts it (`open: false`).",needs:["open"],run(e,n,s){return e.key(s+500,{door:n.open?1:0}),{end:s+650,contact:s+500}}},lights:{summary:"Lights the windows (`on: true`) or puts them out.",needs:["on"],run(e,n,s){return e.key(s+150,{lights:n.on?1:0},{act:!1}),{end:s+300,contact:s+150}}},shake:{summary:"Shakes, as when a door slams or something lands on it: a squash and a wobble that dies away, with dust.",uses:["for"],run(e,n,s){const i=n.for??700,r=e.exaggeration;e.key(s+80,{squash:1-.06*r},{act:!1,easing:"ease-out"});for(let o=1;o<=5;o++){const a=1-o/6;e.key(s+80+i*o/6,{roll:(o%2===0?1:-1)*2.2*r*a,squash:1+.02*a},{act:!1,easing:"ease-in-out"})}return e.key(s+i+80,{roll:0,squash:1}),e.effect({kind:"dust",time:s+80,x:e.x,y:e.floor,length:600}),{end:s+i+80,contact:s+80}}},...t?{smoke:{summary:"Starts smoke puffing from the chimney for `for` ms (default 3000), drifting with the wind; the next beat starts at once (the smoke carries on).",uses:["for","wind"],run(e,n,s){const i=n.for??3e3,r=e.anchor("chimney");return e.effect({kind:"smoke",time:s,x:r.x,y:r.y,length:i+1500,direction:(n.wind??.4)>=0?1:-1}),{end:s+50,release:s+i}}}}:{}}}function by(t={}){const e=t.width??.46,n=t.depth??.46,s=t.seatHeight??.46,i=t.backHeight??.95,r={wood:"#8a5a3b",seat:"#c48a4a",...t.colors},o=.05,a=.025,l=[{id:"seat",shape:{type:"box",size:[e,o,n]},at:[0,s-o/2,0],fill:r.seat},{id:"back",shape:{type:"box",size:[e,i-s,o]},at:[0,(i+s)/2,-n/2+o/2],fill:r.wood}];for(const[h,u,d]of[[-1,1,"front-left"],[1,1,"front-right"],[-1,-1,"back-left"],[1,-1,"back-right"]])l.push({id:`leg-${d}`,shape:{type:"tube",points:[[0,0,0],[0,s-o,0]],radius:a,segments:6},at:[h*(e/2-a*1.5),0,u*(n/2-a*1.5)],fill:r.wood});const c={parts:l,controls:{tip:{description:"Tipped back on its rear legs (+), degrees",unit:"degrees",min:0,max:60,bind:[{parts:l.map(h=>h.id),rotate:{axis:"x",degrees:1,pivot:[0,0,-n/2+a*1.5]}}]}},length:n,height:i,footprint:[e,n],anchors:{seat:{at:[0,s,0]},back:{at:[0,i,-n/2]},front:{at:[0,0,n/2+.3]}}};return{kind:t.kind??"chair",family:"furniture",summary:t.summary??"A chair: a seat to sit on (`seat`), tips back on its rear legs and settles, or falls over.",rig:c,actions:t4(),acting:wy,colors:{body:r.seat}}}const wy={depth:{tip:1,roll:1,squash:1,size:0},limits:{tip:2,roll:1,squash:.05},eyes:[],headTurns:{},drift:[]};function t4(){return{tip:{summary:"Tips back on its rear legs for `for` ms (default 1200), rocking a little, then settles down.",uses:["for"],run(t,e,n){const s=18*t.exaggeration,i=e.for??1200;return t.key(n+350,{tip:s},{easing:"ease-out"}),t.key(n+350+i*.4,{tip:s*.85},{act:!1,easing:"ease-in-out"}),t.key(n+350+i*.7,{tip:s},{act:!1,easing:"ease-in-out"}),t.key(n+350+i,{tip:0},{easing:"ease-in"}),{end:n+350+i,contact:n+350}}},fall:{summary:"Falls over backwards onto its back and bounces, with dust.",uses:["for"],run(t,e,n){const s=e.for??700;return t.key(n+s*.6,{tip:90},{act:!1,easing:"ease-in"}),t.key(n+s*.75,{tip:82},{act:!1,easing:"ease-out"}),t.key(n+s,{tip:90},{act:!1,easing:"ease-in"}),t.effect({kind:"dust",time:n+s*.6,x:t.x,y:t.floor,length:600}),{end:n+s,contact:n+s*.6}}}}}function ky(t={}){const e=t.width??1.4,n=t.depth??.7,s=t.height??.75,i={wood:"#8a5a3b",top:"#a9754a",knob:"#2b2b2b",...t.colors},r=.04,o=.03,a=.14,l=e*.4,c=[{id:"top",shape:{type:"box",size:[e,r,n]},at:[0,s-r/2,0],fill:i.top},{id:"drawer",shape:{type:"box",size:[l,a,n*.8]},at:[-e/2+l/2+.05,s-r-a/2,0],fill:i.wood},{id:"knob",parent:"drawer",shape:{type:"ellipsoid",radii:[.02,.02,.015],segments:8},at:[0,0,n*.4+.012],fill:i.knob,outline:.6}];for(const[u,d,f]of[[-1,1,"front-left"],[1,1,"front-right"],[-1,-1,"back-left"],[1,-1,"back-right"]])c.push({id:`leg-${f}`,shape:{type:"tube",points:[[0,0,0],[0,s-r,0]],radius:o,segments:6},at:[u*(e/2-o*2),0,d*(n/2-o*2)],fill:i.wood});const h={parts:c,controls:{drawer:{description:"The drawer out: 0 shut, 1 open",unit:"0..1",min:0,max:1,bind:[{parts:["drawer"],translate:[0,0,n*.5]}]}},length:n,height:s,footprint:[e,n],anchors:{top:{at:[0,s,0]},edge:{at:[0,s,n/2]},drawer:{part:"drawer",at:[0,0,n*.4]},chair:{at:[0,0,n/2+.35]}}};return{kind:t.kind??"desk",family:"furniture",summary:t.summary??"A desk: a top to work at (`top`, `edge`), a drawer that opens (`drawer`), a place for a chair in front (`chair`).",rig:h,actions:{drawer:{summary:"Opens the drawer (`open: true`) or shuts it (`open: false`).",needs:["open"],run(u,d,f){return u.key(f+400,{drawer:d.open?1:0},{easing:d.open?"ease-out":"ease-in"}),{end:f+500,contact:f+400}}}},acting:vy,colors:{body:i.top}}}const vy={depth:{drawer:1,roll:1,squash:1,size:0},limits:{drawer:.08,roll:1,squash:.04},eyes:[],headTurns:{},drift:[]};function My(t={}){const e=t.length??2,n=t.width??1,s=t.height??.55,i=t.headboard??.95,r={wood:"#8a5a3b",mattress:"#f1ece2",blanket:"#5b7fb0",pillow:"#fbf8f2",...t.colors},o=.3,a=s-o,c={parts:[{id:"frame",shape:{type:"box",size:[n,o,e]},at:[0,o/2,0],fill:r.wood},{id:"headboard",shape:{type:"box",size:[n+.06,i-o,.06]},at:[0,(i+o)/2,-e/2-.03],fill:r.wood},{id:"mattress",shape:{type:"box",size:[n-.04,a,e-.04]},at:[0,o+a/2,0],fill:r.mattress},{id:"blanket",parent:"mattress",shape:{type:"box",size:[n-.02,.04,e*.62]},at:[0,a/2+.02,e*.19],fill:r.blanket,outline:.7},{id:"pillow",parent:"mattress",shape:{type:"ellipsoid",radii:[n*.32,.07,.22],segments:12},at:[0,a/2+.06,-e/2+.32],fill:r.pillow,outline:.7}],controls:{give:{description:"The mattress pressed down: 1 as made, below squashed (someone landed on it)",unit:"factor",default:1,min:.5,max:1.2,bind:[{parts:["mattress"],scale:[1,1,1]}]}},length:e,height:i,footprint:[n,e],anchors:{mattress:{part:"mattress",at:[0,a/2,0]},pillow:{part:"mattress",at:[0,a/2+.1,-e/2+.32]},foot:{at:[0,s,e/2]},side:{at:[n/2+.25,0,0]}}};return{kind:t.kind??"bed",family:"furniture",summary:t.summary??"A bed: a mattress to lie on (`mattress`, `pillow`) that gives and springs back when someone lands on it (`bounce`), a side to sit on (`side`).",rig:c,actions:{bounce:{summary:"The mattress gives (someone landed on it) and springs back over `for` ms (default 700).",uses:["for"],run(h,u,d){const f=u.for??700,p=h.exaggeration;return h.key(d+90,{give:1-.18*p},{act:!1,easing:"ease-out"}),h.key(d+f*.45,{give:1+.05*p},{act:!1,easing:"ease-in-out"}),h.key(d+f*.7,{give:1-.04*p},{act:!1,easing:"ease-in-out"}),h.key(d+f,{give:1}),{end:d+f,contact:d+90}}}},acting:Sy,colors:{body:r.blanket}}}const Sy={depth:{give:1,roll:1,squash:1,size:0},limits:{give:.03,roll:.5,squash:.03},eyes:[],headTurns:{},drift:[]};function xy(t={}){const e=t.width??.9,n=t.height??2.05,s=t.hinge??"left",i={frame:"#d9d2c3",door:"#7a4b2a",handle:"#c9a227",beyond:"#2a2f3a",...t.colors},r=.1,o=s==="left"?1:-1,a=o>0?[[0,0],[-e,0],[-e,n],[0,n]]:[[0,0],[e,0],[e,n],[0,n]],c={parts:[{id:"post-left",shape:{type:"box",size:[r,n+r,r]},at:[e/2+r/2,(n+r)/2,0],fill:i.frame},{id:"post-right",shape:{type:"box",size:[r,n+r,r]},at:[-e/2-r/2,(n+r)/2,0],fill:i.frame},{id:"lintel",shape:{type:"box",size:[e+r*2,r,r]},at:[0,n+r/2,0],fill:i.frame},{id:"beyond",shape:{type:"panel",points:[[-e/2,0],[e/2,0],[e/2,n],[-e/2,n]],facing:"front"},at:[0,0,-.03],fill:i.beyond,outline:.4,seeThrough:!0},{id:"door",shape:{type:"panel",points:a,facing:"front"},at:[o*e/2,0,.005],fill:i.door,outline:.9,overRider:!0},{id:"handle",parent:"door",shape:{type:"ellipsoid",radii:[.03,.03,.03],segments:8},at:[-o*(e-.1),n*.47,.03],fill:i.handle,outline:.5}],controls:{open:{description:"How far the door is open: 0 shut, 1 open wide",unit:"0..1",min:0,max:1,bind:[{parts:["door"],rotate:{axis:"y",degrees:o*-95}}]}},length:.3,height:n+r,footprint:[e+r*2,.3],anchors:{handle:{part:"door",at:[-o*(e-.1),n*.47,.03]},doorway:{at:[0,0,0]},front:{at:[0,0,.5]},beyond:{at:[0,0,-.5]}}};return{kind:t.kind??"door",family:"furniture",summary:t.summary??"A door in its frame: opens and shuts on its hinge (`open`), slams, rattles when knocked; a figure goes through the `doorway` from `front` to `beyond`.",rig:c,actions:e4(),acting:Ty,colors:{body:i.door}}}const Ty={depth:{open:1,roll:1,squash:1,size:0},limits:{open:.08,roll:.6,squash:.03},eyes:[],headTurns:{},drift:[]};function e4(){return{open:{summary:"Opens the door (`open: true`, default) or shuts it (`open: false`), over `for` ms (default 600).",uses:["open","for"],run(t,e,n){const s=e.for??600;return t.key(n+s,{open:e.open===!1?0:1},{easing:"ease-in-out"}),{end:n+s+80,contact:n+s}}},slam:{summary:"Slams shut: a fast swing, a shudder in the frame, dust.",run(t,e,n){const s=t.exaggeration;t.key(n+180,{open:0},{act:!1,easing:"ease-in"});for(let i=1;i<=4;i++)t.key(n+180+i*70,{roll:(i%2===0?1:-1)*1.2*s*(1-i/5)},{act:!1});return t.key(n+180+350,{roll:0}),t.effect({kind:"dust",time:n+180,x:t.x,y:t.floor,length:500}),{end:n+180+350,contact:n+180}}},knock:{summary:"Someone knocks three times: the door rattles over `for` ms (default 700).",uses:["for"],run(t,e,n){const i=e.for??700,r=t.exaggeration;for(let o=0;o<3;o++){const a=n+i*(o+.5)/3;t.key(a,{open:.03*r},{act:!1,easing:"ease-out"}),t.key(a+60,{open:0},{act:!1,easing:"ease-in"})}return{end:n+i,contact:n+i/6}}}}}const Ey=1.4;function Ay(t={}){const e=t.width??.5,n=t.seatHeight??.5,s=t.wheelRadius??.3,i=.08,r={frame:"#2b2f36",seat:"#3c6ea5",tyre:"#1f2328",...t.colors},o=.04,a=.018,l=.44,c=n+.5,h=-.08,u=e/2+.06,d=[{id:"seat",shape:{type:"box",size:[e,o,l]},at:[0,n-o/2,0],fill:r.seat},{id:"back",shape:{type:"box",size:[e,c-n-.02,o]},at:[0,(c+n)/2,-l/2+o/2],fill:r.seat},{id:"footrest",shape:{type:"box",size:[e*.8,.02,.14]},at:[0,.12,l/2+.22],fill:r.frame}];for(const[g,m]of[[-1,"left"],[1,"right"]]){const y=g*u,v=(k,w,T=a)=>{d.push({id:k,shape:{type:"tube",points:w,radius:T,segments:6},fill:r.frame,outline:.7})};v(`post-${m}`,[[y,n-.1,-l/2],[y,c+.04,-l/2],[y,c+.04,-l/2-.14]]),v(`rail-${m}`,[[y,n-.03,-l/2],[y,n-.03,l/2]]),v(`leg-${m}`,[[y,n-.03,l/2],[y*.85,i,l/2+.06]]),v(`strut-${m}`,[[y*.85,i+.08,l/2+.04],[y*.8,.13,l/2+.22]]),v(`armrest-${m}`,[[y,n+.22,-l/2+.02],[y,n+.22,l/2-.08]],a*1.3),d.push({id:`wheel-${m}`,shape:{type:"cylinder",radius:s,length:.04,axis:"x",segments:20,spokes:8},at:[y+g*.03,s,h],ink:r.tyre,outline:1.3}),d.push({id:`rim-${m}`,shape:{type:"cylinder",radius:s*.9,length:.012,axis:"x",segments:20},at:[g*.045,0,0],parent:`wheel-${m}`,ink:r.frame,outline:.8}),d.push({id:`castor-${m}`,shape:{type:"cylinder",radius:i,length:.03,axis:"x",segments:12,spokes:3},at:[y*.85,i,l/2+.06],fill:r.tyre})}const f=d.map(g=>g.id).filter(g=>!g.startsWith("rim-")),p={parts:d,controls:{wheelSpin:{description:"How far the big wheels have turned, degrees (keyed with the distance rolled, so they never skate); the castors turn faster",unit:"degrees",bind:[{parts:["wheel-left","wheel-right"],rotate:{axis:"x",degrees:1}},{parts:["castor-left","castor-right"],rotate:{axis:"x",degrees:s/i}}]},tip:{description:"Tipped back on its big wheels (+), degrees: a wheelie, or a helper tipping it up a kerb",unit:"degrees",min:0,max:45,bind:[{parts:f,rotate:{axis:"x",degrees:1,pivot:[0,s,h]}}]}},length:l+.4,height:c+.04,footprint:[u*2+.1,l+.4],anchors:{seat:{at:[0,n,.02]},handles:{at:[0,0,-l/2-.5]},front:{at:[0,0,l/2+.6]},footrest:{at:[0,.13,l/2+.22]}}};return{kind:t.kind??"wheelchair",family:"furniture",summary:t.summary??"A wheelchair: rolls to `to` with its wheels turning the distance (roll), brakes, tips back on its big wheels (wheelie); its `seat` is ridden in the `wheeling` pose and a pusher stands at `handles`.",rig:p,actions:n4(s),acting:Py,colors:{body:r.seat,ink:r.frame},wheelRadius:s,moves:{roll:{speed:Ey,perMetre:{wheelSpin:180/(Math.PI*s)}}}}}const Py={depth:{wheelSpin:0,tip:1,roll:1,squash:1,size:0},limits:{tip:2,roll:1,squash:.03},eyes:[],headTurns:{},drift:[]};function $y(t,e,n,s,i,r,o=!1){const a=t.facing()||Math.sign(s-t.x)||1,l=t.values.wheelSpin??0,c=(s-t.x)*a/t.scale;t.set("wheelSpin",e,l),t.move(e,n,s,{easing:i}),t.set("wheelSpin",n,o?l:l+c/r*(180/Math.PI),i)}function n4(t){return{roll:{summary:"Rolls to `to` at `speed` px/ms (or over `for` ms): a small push-off, the wheels turning exactly the distance, and a gentle stop.",needs:["to"],uses:["speed","for"],run(e,n,s){const i=Math.sign(n.to-e.x);if(i===0)return{end:s};let r=s;e.facing()!==i&&(r=e.turnTo(r,i>0?"right":"left"));const o=Math.abs(n.to-e.x),a=n.for??Math.max(300,o/(n.speed??Ey*e.scale/1e3));return e.key(r+150,{tip:1.5*e.exaggeration},{act:!1,easing:"ease-out"}),$y(e,r,r+a,n.to,"ease-in-out",t),e.key(r+a,{tip:0},{easing:"ease-out"}),{end:r+a}}},brake:{summary:"Stops short at `to`: the wheels lock and it skids the last bit, tipping forward a touch.",needs:["to"],uses:["for"],run(e,n,s){if(Math.sign(n.to-e.x)===0)return{end:s};const r=n.for??500;return $y(e,s,s+r,n.to,"ease-out",t,!0),e.key(s+r,{tip:0},{easing:"ease-out"}),e.effect({kind:"dust",time:s+r*.5,x:n.to,y:e.floor,length:500}),{end:s+r,contact:s+r}}},wheelie:{summary:"Tips back onto its big wheels, balances there for `for` ms (default 1200), and drops down.",uses:["for"],run(e,n,s){const i=24*e.exaggeration,r=n.for??1200;return e.key(s+300,{tip:i},{easing:"ease-out"}),e.key(s+300+r*.5,{tip:i*.9},{act:!1,easing:"ease-in-out"}),e.key(s+300+r,{tip:i},{act:!1,easing:"ease-in-out"}),e.key(s+300+r+250,{tip:0},{easing:"ease-in"}),e.effect({kind:"dust",time:s+300+r+250,x:e.x,y:e.floor,length:400}),{end:s+300+r+250,contact:s+300+r+250}}}}}function Iy(t={}){const e={body:"#3f86c8",glass:"#cfeaf5",trim:"#2c2c33",rotor:"#3b3b44",...t.colors},n=2.15,i={parts:[{id:"cabin",shape:{type:"extrude",profile:[[-1.2,.6],[.9,.55],[1.6,.85],[1.65,1.25],[1.2,1.75],[-.6,1.85],[-1.3,1.45]],width:1.5},fill:e.body},{id:"window",shape:{type:"extrude",profile:[[.75,1],[1.6,.95],[1.6,1.3],[1.15,1.72],[.6,1.72]],width:1.54},fill:e.glass,outline:.8},{id:"boom",shape:{type:"tube",points:[[0,1.4,-1.2],[0,1.55,-3.4]],radius:.16,segments:8},fill:e.body},{id:"fin",shape:{type:"extrude",profile:[[-3.55,1.45],[-3.2,1.5],[-3.35,2.25],[-3.6,2.25]],width:.12},fill:e.body},{id:"mast",shape:{type:"tube",points:[[0,1.82,.1],[0,n,.1]],radius:.07,segments:6},fill:e.trim},{id:"rotor-disc",shape:{type:"cylinder",radius:2.4,length:.01,axis:"y",segments:28},at:[0,n+.02,.1],fill:"#c9d4dd",outline:.4,fade:{control:"blur",from:0,to:.45}},{id:"blades",shape:{type:"box",size:[.16,.03,4.8]},at:[0,n+.05,.1],fill:e.rotor,outline:.7,fade:{control:"blur",from:1,to:.3}},{id:"tail-rotor",shape:{type:"box",size:[.04,.9,.12]},at:[.12,1.85,-3.45],fill:e.rotor,outline:.6},{id:"skid-left",shape:{type:"tube",points:[[0,.08,-1.1],[0,.08,1.2],[0,.22,1.45]],radius:.05,segments:6},at:[.7,0,0],fill:e.trim},{id:"skid-right",shape:{type:"tube",points:[[0,.08,-1.1],[0,.08,1.2],[0,.22,1.45]],radius:.05,segments:6},at:[-.7,0,0],fill:e.trim},{id:"strut-left",shape:{type:"tube",points:[[.7,.08,.6],[.55,.62,.5]],radius:.04,segments:5},fill:e.trim},{id:"strut-right",shape:{type:"tube",points:[[-.7,.08,.6],[-.55,.62,.5]],radius:.04,segments:5},fill:e.trim}],controls:{rotor:{description:"How far the rotors have turned (keyed exactly, not acted; the blades blur into a disc when they spin fast)",unit:"degrees",bind:[{parts:["blades"],rotate:{axis:"y",degrees:1}},{parts:["tail-rotor"],rotate:{axis:"x",degrees:3,pivot:[0,0,0]}}]},blur:{description:"How blurred the main rotor is: 0 still blades, 1 a spinning disc",unit:"0..1",min:0,max:1}},length:5.2,height:2.4,footprint:[1.8,3.4],anchors:{seat:{at:[0,.75,.7]},door:{at:[-.76,1,.2]},rotor:{at:[0,n,.1]},skids:{at:[0,0,.2]},hook:{at:[0,.4,0]}}};return{kind:t.kind??"helicopter",family:"aircraft",summary:t.summary??"A cartoon helicopter: spools up and takes off, flies nose-down banking into its moves, hovers with a bob, and lands with a squash.",rig:i,actions:s4(),acting:kh,colors:{body:e.body,ink:"#26262b"},moves:{fly:{speed:15,flies:!0,hold:{blur:1},perSecond:{rotor:an*1e3}}}}}const kh={depth:{turn:0,lift:0,blur:0,pitch:1,roll:1,squash:1,lean:1,size:0},limits:{turn:.08,pitch:6,roll:6,squash:.06,lift:.15},eyes:[],headTurns:{},drift:[]},an=2.6;function s4(){const t=(n,s,i,r,o)=>{const a=n.values.rotor??0;n.set("rotor",s,a);const l=o?r*(i-s)*.5:r*(i-s);n.set("rotor",i,a+l,o)},e=n=>n.values.lift>.05;return{takeOff:{summary:"Spools the rotor up (the skids squash as it bites), then lifts off nose-down to `height` metres (default 3).",uses:["height"],run(n,s,i){const r=n.exaggeration,o=s.height??3;t(n,i,i+900,an,"ease-in"),n.key(i+900,{blur:1},{act:!1,easing:"ease-in"}),n.key(i+700,{squash:1-.08*r},{act:!1,easing:"ease-in"});const a=i+1e3;return n.key(a+150,{squash:1+.06*r,lift:.3},{act:!1,easing:"ease-out"}),n.key(a+1300,{squash:1,lift:o,pitch:-4*r},{act:!1,easing:"ease-in-out"}),n.key(a+1700,{pitch:0}),t(n,i+900,a+1700,an),n.effect({kind:"dust",time:a,x:n.x,y:n.floor,length:900}),{end:a+1700,contact:a}}},fly:{summary:"Flies to `to` (and to `height`, if given): nose down and banked into the move, nose up and leveling as it stops.",needs:["to"],uses:["height","speed","for"],run(n,s,i){const r=n.exaggeration,o=Math.sign(s.to-n.x);let a=i;o!==0&&n.facing()!==o&&(a=n.turnTo(a,o>0?"right":"left"));const l=Math.abs(s.to-n.x),c=s.for??Math.max(700,l/(s.speed??.3)),h=s.height??n.values.lift;return n.key(a+300,{pitch:-9*r,roll:6*r},{act:!1,easing:"ease-out"}),n.key(a+c-250,{pitch:-4*r,roll:3*r,lift:h},{act:!1}),n.key(a+c,{pitch:7*r,roll:0},{act:!1,easing:"ease-out"}),n.key(a+c+450,{pitch:0}),n.move(a,a+c,s.to,{easing:"ease-in-out"}),t(n,i,a+c+450,an),{end:a+c+450,contact:a,release:a+c}}},hover:{summary:"Hovers in place for `for` ms (default 2000), bobbing gently.",uses:["for"],run(n,s,i){const r=s.for??2e3,o=n.values.lift,a=n.exaggeration;for(let l=350,c=0;l<r;l+=350,c++)n.key(i+l,{lift:o+(c%2===0?.12:-.06)*a,roll:(c%2===0?1.5:-1.5)*a},{act:!1,easing:"ease-in-out"});return n.key(i+r,{lift:o,roll:0},{act:!1,easing:"ease-in-out"}),(e(n)||o>0)&&t(n,i,i+r,an),{end:i+r}}},land:{summary:"Settles down onto its skids: a flare, a squash on touchdown with dust, and the rotor spools down.",run(n,s,i){const r=n.exaggeration,o=i+Math.max(900,n.values.lift*450);return n.key(i+400,{pitch:3*r},{act:!1,easing:"ease-out"}),n.key(o,{lift:0,pitch:0,squash:1-.14*r},{act:!1,easing:"ease-in"}),n.key(o+280,{squash:1}),t(n,i,o,an),t(n,o,o+1600,an,"ease-out"),n.key(o+1600,{blur:0},{act:!1,easing:"ease-out"}),n.effect({kind:"dust",time:o,x:n.x,y:n.floor,length:800}),{end:o+1600,contact:o}}}}}function Oy(t={}){const e={body:"#e9e4d8",wings:"#d9483b",glass:"#cfeaf5",trim:"#2c2c33",...t.colors},n=3.15,i={parts:[{id:"fuselage",shape:{type:"extrude",profile:[[-3.7,1.55],[-2.6,1.05],[2.4,.85],[3,1],[3.1,1.4],[2.7,1.75],[1.4,1.9],[-2.9,1.85]],width:1},fill:e.body},{id:"canopy",shape:{type:"extrude",profile:[[.4,1.85],[1.6,1.85],[1.1,2.3],[.5,2.3]],width:.7},fill:e.glass,outline:.8},{id:"wing-left",shape:{type:"box",size:[3.6,.1,1.35]},at:[2.05,1.15,.55],fill:e.wings},{id:"wing-right",shape:{type:"box",size:[3.6,.1,1.35]},at:[-2.05,1.15,.55],fill:e.wings},{id:"tailplane-left",shape:{type:"box",size:[1.1,.07,.65]},at:[.6,1.7,-3.35],fill:e.wings},{id:"tailplane-right",shape:{type:"box",size:[1.1,.07,.65]},at:[-.6,1.7,-3.35],fill:e.wings},{id:"fin",shape:{type:"extrude",profile:[[-3.75,1.75],[-3,1.82],[-3.45,2.75],[-3.8,2.75]],width:.1},fill:e.wings},{id:"gear-left",shape:{type:"tube",points:[[.55,.95,1.2],[.75,.28,1.3]],radius:.04,segments:5},fill:e.trim},{id:"gear-right",shape:{type:"tube",points:[[-.55,.95,1.2],[-.75,.28,1.3]],radius:.04,segments:5},fill:e.trim},{id:"wheel-left",shape:{type:"cylinder",radius:.26,length:.14,axis:"x",segments:14},at:[.78,.26,1.3],fill:e.trim},{id:"wheel-right",shape:{type:"cylinder",radius:.26,length:.14,axis:"x",segments:14},at:[-.78,.26,1.3],fill:e.trim},{id:"tail-wheel",shape:{type:"cylinder",radius:.12,length:.08,axis:"x",segments:10},at:[0,.12,-3],fill:e.trim},{id:"tail-strut",shape:{type:"tube",points:[[0,.12,-3],[0,1.2,-2.9]],radius:.03,segments:5},fill:e.trim},{id:"spinner",shape:{type:"ellipsoid",radii:[.18,.18,.22],segments:10},at:[0,1.22,n],fill:e.wings,outline:.7},{id:"prop-disc",shape:{type:"cylinder",radius:.95,length:.01,axis:"z",segments:24},at:[0,1.22,n+.08],fill:"#c9d4dd",outline:.4,fade:{control:"blur",from:0,to:.45}},{id:"propeller",shape:{type:"box",size:[.12,1.85,.04]},at:[0,1.22,n+.1],fill:e.trim,outline:.6,fade:{control:"blur",from:1,to:.3}}],controls:{rotor:{description:"How far the propeller has turned (keyed exactly; it blurs into a disc at speed)",unit:"degrees",bind:[{parts:["propeller"],rotate:{axis:"z",degrees:1}}]},blur:{description:"How blurred the propeller is: 0 still, 1 a spinning disc",unit:"0..1",min:0,max:1}},length:7,height:2.8,footprint:[7.2,6.5],anchors:{seat:{at:[0,1.55,1]},nose:{at:[0,1.22,n+.2]},tail:{at:[0,1.6,-3.7]},wingtip:{at:[3.6,1.15,.55]}}};return{kind:t.kind??"airplane",family:"aircraft",summary:t.summary??"A propeller plane: takes off from a run, flies banked, loops the loop, and lands with a flare and a squash.",rig:i,actions:r4(),acting:kh,colors:{body:e.body,ink:"#26262b"},moves:{fly:{speed:30,flies:!0,hold:{blur:1},perSecond:{rotor:an*1e3}}}}}const i4=3.2;function r4(){const t=(n,s,i,r)=>{const o=n.values.rotor??0;n.set("rotor",s,o),n.set("rotor",i,o+i4*(i-s)*(r?.5:1),r)},e=(n,s,i)=>{const r=Math.sign(i-n.x);return r!==0&&n.facing()!==r?n.turnTo(s,r>0?"right":"left"):s};return{takeOff:{summary:"Spins the propeller up, runs along the ground toward `to`, lifts its nose and climbs to `height` metres (default 4).",needs:["to"],uses:["height","for"],run(n,s,i){const r=n.exaggeration,o=e(n,i,s.to);t(n,o,o+700,"ease-in"),n.key(o+700,{blur:1},{act:!1,easing:"ease-in"});const a=s.for??2600,l=n.x,c=o+700+a*.55,h=l+(s.to-l)*.45;return n.move(o+700,c,h,{easing:"ease-in"}),n.key(c,{pitch:8*r,squash:1+.04*r},{act:!1,easing:"ease-out"}),n.key(o+700+a,{lift:s.height??4,pitch:10*r,squash:1},{act:!1,easing:"ease-in-out"}),n.move(c,o+700+a,s.to),n.key(o+700+a+500,{pitch:0}),t(n,o+700,o+700+a+500),n.effect({kind:"dust",time:c,x:h,y:n.floor,length:700}),{end:o+700+a+500,contact:c}}},fly:{summary:"Flies to `to` (and `height`), banking into the move and leveling out.",needs:["to"],uses:["height","speed","for"],run(n,s,i){const r=n.exaggeration,o=e(n,i,s.to),a=s.for??Math.max(800,Math.abs(s.to-n.x)/(s.speed??.45)),l=s.height??n.values.lift;return n.key(o+350,{roll:10*r,pitch:l>n.values.lift?6*r:-3*r},{act:!1,easing:"ease-out"}),n.key(o+a-300,{roll:4*r,lift:l},{act:!1}),n.key(o+a,{roll:0,pitch:0}),n.move(o,o+a,s.to,{easing:"ease-in-out"}),t(n,i,o+a),{end:o+a,contact:o,release:o+a}}},loop:{summary:"Loops the loop: pulls up and over in a full circle (`for` ms, default 2400), carrying on the way it was going.",uses:["for"],run(n,s,i){const r=s.for??2400,o=2.2*n.exaggeration,a=n.facing()||1,l=16,c=n.x,h=n.values.lift,u=n.values.pitch;for(let d=1;d<=l;d++){const f=Math.PI*2*d/l,p=i+r*d/l;n.key(p,{lift:h+o*(1-Math.cos(f)),pitch:u+360*d/l},{act:!1}),n.move(i+r*(d-1)/l,p,c+a*(o*Math.sin(f)+d/l*o*1.2)*n.scale)}return n.key(i+r+1,{pitch:u},{act:!1}),t(n,i,i+r),{end:i+r+1}}},land:{summary:"Comes down toward `to`: descends, flares nose-up, touches down with a squash and dust, rolls to a stop and the propeller spools down.",needs:["to"],uses:["for"],run(n,s,i){const r=n.exaggeration,o=e(n,i,s.to),a=n.x,l=s.for??2200,c=o+l,h=a+(s.to-a)*.7;return n.key(o+l*.4,{pitch:-4*r},{act:!1,easing:"ease-out"}),n.key(c-250,{pitch:6*r,lift:.15},{act:!1,easing:"ease-in-out"}),n.key(c,{lift:0,pitch:0,squash:1-.12*r},{act:!1,easing:"ease-in"}),n.key(c+260,{squash:1}),n.move(o,c,h),n.move(c,c+1200,s.to,{easing:"ease-out"}),t(n,i,c),t(n,c,c+1600,"ease-out"),n.key(c+1600,{blur:0},{act:!1,easing:"ease-out"}),n.effect({kind:"dust",time:c,x:h,y:n.floor,length:700}),{end:c+1600,contact:c}}}}}const Is=["walk","trot","canter","gallop"],o4=Is,Cy=["fl","fr","hl","hr"],Bo={walk:{offsets:{hl:0,fl:.25,hr:.5,fr:.75},swing:16,lift:45,bob:.02,rock:0,cycle:1100},trot:{offsets:{fl:0,hr:0,fr:.5,hl:.5},swing:22,lift:75,bob:.05,rock:0,cycle:640},canter:{offsets:{hr:0,hl:.33,fr:.33,fl:.66},swing:30,lift:70,bob:.08,rock:5,cycle:560},gallop:{offsets:{hr:0,hl:.1,fr:.5,fl:.6},swing:40,lift:80,bob:.1,rock:7,cycle:460}},ln=Math.PI/180;function zo(t,e){return 4*t*Math.sin(Bo[e].swing*ln)}function cn(t){const{legs:e,colors:n}=t,s=e.upper+e.lower+e.foot,i=s+t.body.rise,r=(u,d)=>[d*u[0],u[1],u[2]],o=[{id:"body",shape:{type:"ellipsoid",radii:t.body.radii,segments:18},at:[0,i,0],fill:n.coat},{id:"neck",shape:{type:"tube",points:t.neck.points,radius:t.neck.points.map((u,d,f)=>t.neck.radius*(1.25-.4*d/Math.max(1,f.length-1))),segments:12},at:t.neck.at,fill:n.coat},{id:"head",parent:"neck",shape:{type:"ellipsoid",radii:t.head.radii,segments:14},at:t.head.at,rotate:t.head.rotate,fill:n.coat},...l4(t,n,i)];t.mane&&o.push({id:"mane",parent:"neck",shape:{type:"tube",points:t.mane.points,radius:t.mane.radius,segments:6},fill:n.dark,outline:.7}),t.muzzle&&o.push({id:"muzzle",parent:"head",shape:{type:"ellipsoid",radii:t.muzzle.radii,segments:10},at:t.muzzle.at,fill:n.muzzle,outline:.8});for(const u of[1,-1]){const d=u>0?"left":"right",f=t.ears.rotate?r(t.ears.rotate,1).map((p,g)=>g===2?u*p:p):void 0;o.push({id:`ear-${d}`,parent:"head",shape:{type:"ellipsoid",radii:t.ears.radii,segments:8},at:r(t.ears.at,u),rotate:f,fill:n.coat,outline:.7},{id:`eye-${d}`,parent:"head",shape:{type:"ellipsoid",radii:[t.eyes.size*.8,t.eyes.size,t.eyes.size*.9],segments:8},at:r(t.eyes.at,u),fill:"#1d1d22",outline:.4})}o.push(...t.extras?.(n)??[]);const a={walk:{description:"Phase of the stride, in full cycles (keyed in step with the distance covered)",unit:"cycles"},walking:{description:"How much of the gait is applied: 0 standing, 1 moving",unit:"0..1",min:0,max:1},gait:{description:`Which gait: ${t.gaits.map(u=>`${Is.indexOf(u)} ${u}`).join(", ")}`,unit:"index",min:0,max:3},neck:{description:"Neck bent down (+, eating, sniffing) or up (−, alert)",unit:"degrees",bind:[{parts:["neck"],rotate:{axis:"x",degrees:1}}]},tail:{description:"Tail flicked up and back (+), curling along its length, on a spring behind the motion",unit:"degrees",bind:[{parts:ke,rotate:{axis:"x",degrees:1/ke.length}}]},wag:{description:"Tail swung side to side, curling",unit:"degrees",bind:[{parts:ke,rotate:{axis:"y",degrees:1/ke.length}}]},ears:{description:"Ears pricked forward (+) or laid back (−), on a spring behind the motion",unit:"degrees",bind:[{parts:["ear-left","ear-right"],rotate:{axis:"x",degrees:1,pivot:[0,-t.ears.radii[1],0]}}]}};for(const u of Cy){const d=u[0]==="f",f=u[1]==="l"?1:-1,p=d?e.thickness[0]:e.thickness[1];o.push({id:`${u}-upper`,shape:{type:"tube",points:[[0,e.upper*.2,0],[0,-e.upper*.5,0],[0,-e.upper,0]],radius:[p,p*.85,e.lowerThickness*1.15],segments:10},at:[f*e.across,s,d?e.front:e.hind],fill:n.coat},{id:`${u}-knee`,parent:`${u}-upper`,shape:{type:"ellipsoid",radii:Array(3).fill(e.lowerThickness*1.08),segments:10},at:[0,-e.upper,0],fill:n.coat,solidOnly:!0},{id:`${u}-lower`,parent:`${u}-upper`,shape:{type:"tube",points:[[0,0,0],[0,-e.lower,0]],radius:[e.lowerThickness*1.1,e.lowerThickness*.85],segments:10},at:[0,-e.upper,0],fill:n.coat},{id:`${u}-foot`,parent:`${u}-lower`,shape:{type:"ellipsoid",radii:[e.footSize[0]/2,e.foot/2+.004,e.footSize[1]/2],segments:12},at:[0,-e.lower-e.foot/2,e.footSize[1]*.12],fill:n.foot,outline:.8});const g=`${d?"Front":"Hind"} ${f>0?"left":"right"} leg`;a[`${u}.swing`]={description:`${g}: forward (+) or back (−) from the hip`,unit:"degrees",bind:[{parts:[`${u}-upper`],rotate:{axis:"x",degrees:-1}}]},a[`${u}.knee`]={description:`${g}: knee (hock) folded`,unit:"degrees",bind:[{parts:[`${u}-lower`],rotate:{axis:"x",degrees:d?1:-1}}]},a[`${u}.ankle`]={description:`${g}: foot turned at the ankle (+ toe forward)`,unit:"degrees",bind:[{parts:[`${u}-foot`],rotate:{axis:"x",degrees:-1,pivot:[0,e.foot/2,-e.footSize[1]*.12]}}]}}const l=t.neck.points[t.neck.points.length-1],c={parts:o,controls:a,length:t.body.radii[2]*2+Math.max(0,t.neck.at[2]+l[2]+t.head.radii[2]-t.body.radii[2])+.3,height:t.neck.at[1]+l[1]+t.head.radii[1]*2,footprint:[e.across*2+t.body.radii[0],(e.front-e.hind)*1.4],anchors:{back:{at:[0,i+t.body.radii[1],-t.body.radii[2]*.05]},head:{part:"head",at:[0,0,0]},mouth:{part:t.muzzle?"muzzle":"head",at:t.muzzle?[0,0,t.muzzle.radii[2]]:[0,0,t.head.radii[2]]},front:{at:[0,i,t.body.radii[2]]},...t.anchors},derive:u=>c4(u,t,s)},h={legLength:s,upper:e.upper,lower:e.lower,foot:e.foot,tailHangs:t.tail.points[t.tail.points.length-1][1]<0,front:e.front,hind:e.hind,call(u,d){const f=u.anchor("mouth");u.effect({kind:"honk",time:d,x:f.x,y:f.y,length:800,direction:u.facing()||1})}};return{kind:t.kind,family:"animal",summary:t.summary,rig:c,actions:{...u4(t,h),...t.actions?.(h)},acting:Mh,colors:{body:n.coat,ink:"#26262b"},follow:[{control:"tail",of:"x",per:.6,stiffness:90,damping:6,limit:40},{control:"ears",of:"x",per:1.4,stiffness:150,damping:8,limit:45}],moves:a4(t,s)}}function a4(t,e){const n=i=>{const r=zo(e,i);return{speed:r/(Bo[i].cycle*(t.cycleScale??1)/1e3),set:{gait:Is.indexOf(i)},hold:{walking:1},perMetre:{walk:1/r}}},s=Object.fromEntries(t.gaits.map(i=>[i==="gallop"&&!t.gaits.includes("canter")?"run":i,n(i)]));return t.gaits.includes("gallop")&&!s.gallop&&(s.gallop=n("gallop")),s}const ke=Array.from({length:7},(t,e)=>e===0?"tail":`tail-${e}`);function l4(t,e,n){const s=Ac(t.tail.points,ke.length+1),[,i,r]=t.body.radii,o=(t.tail.at[1]-n)/i,a=Math.abs(o)<1?-r*Math.sqrt(1-o*o):t.tail.at[2],l=[t.tail.at[0],t.tail.at[1],a+Math.min(.04,r*.08)],c=f=>t.tail.radius*(1-.5*f/ke.length),h=ke.map((f,p)=>{const g=s[p],m=s[p+1],y=[m[0]-g[0],m[1]-g[1],m[2]-g[2]],v=p===0?void 0:s[p-1];return{id:f,...p>0?{parent:ke[p-1]}:{},shape:{type:"tube",points:[[0,0,0],y],radius:[c(p),c(p+1)],segments:8,joined:!0},at:p===0?l:[g[0]-v[0],g[1]-v[1],g[2]-v[2]],fill:e.dark,outline:.8}}),u=s[s.length-1],d=s[s.length-2];return h.push({id:"tail-tip",parent:ke[ke.length-1],shape:{type:"ellipsoid",radii:Array(3).fill(c(ke.length)*1.05),segments:8},at:[u[0]-d[0],u[1]-d[1],u[2]-d[2]],fill:e.dark,outline:.8,solidOnly:!0}),h}function c4(t,e,n){const s=Math.max(0,Math.min(1,t.walking??0));if(s===0)return{};const i=Is[Math.max(0,Math.min(3,Math.round(t.gait??0)))],r=Bo[e.gaits.includes(i)?i:e.gaits[0]],o=t.walk??0,a={};for(const c of Cy){const h=Math.PI*2*(o+r.offsets[c]);a[`${c}.swing`]=(t[`${c}.swing`]??0)+s*r.swing*Math.sin(h),a[`${c}.knee`]=(t[`${c}.knee`]??0)+s*r.lift*Math.max(0,Math.cos(h))}const l=Math.PI*2*o;return a.lift=(t.lift??0)+s*r.bob*n*Math.abs(Math.sin(l*2)),a.pitch=(t.pitch??0)+s*r.rock*Math.sin(l),a.neck=(t.neck??0)+s*(r.rock>0?-r.rock*1.4:5)*Math.sin(l*2),a}function vh(t){const n=Math.sin(32*ln),s=t.legLength-(t.front-t.hind)*n,i=72,o=(s-t.upper*Math.cos(i*ln)-t.foot)/t.lower,a=o>=1?0:o<=-1?180:Math.acos(o)/ln,l={pitch:32,lift:t.legLength*(1-Math.cos(32*ln))-t.front*n,neck:-10,tail:t.tailHangs?35:-40,"fl.swing":-32,"fr.swing":-32};for(const c of["hl","hr"])l[`${c}.swing`]=i-32,l[`${c}.knee`]=-(i+a),l[`${c}.ankle`]=a;return l}const Mh={depth:{turn:0,lift:0,pitch:1,roll:1,squash:1,neck:2,tail:3,wag:3,"fl.swing":2,"fr.swing":2,"hl.swing":2,"hr.swing":2,"fl.knee":3,"fr.knee":3,"hl.knee":3,"hr.knee":3},limits:{pitch:6,neck:8,tail:10,wag:8,"fl.swing":8,"fr.swing":8,"hl.swing":8,"hr.swing":8,lift:0},eyes:[],headTurns:{},drift:[]},h4=Mh;function _y(t){const e=(t.upper+t.lower)*.32,n=Math.asin(Math.min(1,e/(t.upper+t.lower+t.foot)))/ln,s={pitch:0,lift:e-t.legLength,neck:-14,tail:t.tailHangs?60:-60,"fl.swing":90-n,"fr.swing":90-n,"fl.knee":0,"fr.knee":0,"fl.ankle":n,"fr.ankle":n};for(const i of["hl","hr"])s[`${i}.swing`]=70,s[`${i}.knee`]=-155,s[`${i}.ankle`]=85;return s}function u4(t,e){const n=t.cycleScale??1,s=o=>({summary:{walk:"Walks to `to` (four beats), its head bobbing.",trot:"Trots to `to`: legs in diagonal pairs, the body bouncing.",canter:"Canters to `to`: three beats, the body rocking.",gallop:"Gallops (runs) to `to`: legs reaching, the body rocking hard, kicking up dust."}[o],needs:["to"],uses:["for"],run(a,l,c){const h=Math.sign(l.to-a.x);if(h===0)return{end:c};let u=c;a.facing()!==h&&(u=a.turnTo(u,h>0?"right":"left"));const d=a.exaggeration;a.key(u+180,{neck:-12*d},{act:!1,easing:"ease-out"});const p=Math.abs(l.to-a.x)/a.scale/zo(e.legLength,o),g=l.for??Math.max(500,p*Bo[o].cycle*n),m=a.values.walk??0;return a.set("gait",u,a.values.gait??0),a.set("gait",u+1,Is.indexOf(o)),a.set("walking",u,0),a.set("walking",u+240,1,"ease-out"),a.set("walking",u+g-240,1),a.set("walking",u+g,0,"ease-in"),a.set("walk",u,m),a.move(u,u+g,l.to,{easing:"ease-in-out"}),a.set("walk",u+g,m+p,"ease-in-out"),a.key(u+g+300,{neck:0}),(o==="gallop"||o==="canter")&&(a.effect({kind:"dust",time:u+200,x:a.x-h*e.legLength*a.scale,y:a.floor,length:700,direction:-h}),a.effect({kind:"dust",time:u+g,x:l.to+h*e.legLength*.6*a.scale,y:a.floor,length:600,direction:h})),{end:u+g+300,contact:u,release:u+g}}}),i=Object.fromEntries(t.gaits.map(o=>[o==="gallop"&&!t.gaits.includes("canter")?"run":o,s(o)]));t.gaits.includes("gallop")&&!i.gallop&&(i.gallop=s("gallop"));const r={...i,[t.call]:{summary:`Throws its head up and ${t.call}s.`,run(o,a,l){const c=o.exaggeration;return o.key(l+150,{neck:10*c},{act:!1,easing:"ease-out"}),o.key(l+380,{neck:-28*c,squash:1.05},{act:!1,easing:"ease-out"}),o.key(l+680,{neck:-20*c},{act:!1}),o.key(l+980,{neck:0,squash:1}),e.call(o,l+380),{end:l+980,contact:l+380}}},sit:{summary:"Sits on its haunches for `for` ms (default 1500): the rump goes down onto folded hind legs, paws flat on the ground, the front legs stay planted; then it gets up.",uses:["for"],run(o,a,l){const c=vh(e),h=l+450;o.key(h,c,{act:!1,easing:"ease-in-out"}),o.key(h+(a.for??1500),c,{act:!1});const u=h+(a.for??1500)+450,d={};for(const f of Object.keys(c))d[f]=0;return o.key(u,d),{end:u,contact:h,release:u-450}}},lie:{summary:"Lies down for `for` ms (default 2000), head up and front paws forward (sinking back onto its haunches first), then gets up.",uses:["for"],run(o,a,l){const c=_y(e),h={...vh(e)},u=l+400,d=u+450;o.key(u,h,{act:!1,easing:"ease-in-out"}),o.key(d,c,{act:!1,easing:"ease-in-out"}),o.key(d+(a.for??2e3),c,{act:!1});const f=d+(a.for??2e3)+600,p={};for(const g of new Set([...Object.keys(c),...Object.keys(h)]))p[g]=0;return o.key(f,p),{end:f,contact:d,release:f-600}}},jump:{summary:"Crouches and jumps (forward to `to`, or up on the spot), legs tucked in the air, landing with a squash and dust.",uses:["to"],run(o,a,l){const c=o.exaggeration,h=e.legLength*.8*c,u=l+260,d=u+90,f=d+520;if(o.key(u,{squash:.86,"hl.knee":40,"hr.knee":40,"fl.knee":25,"fr.knee":25,neck:8},{act:!1,easing:"ease-out"}),o.key(d,{squash:1.12,"hl.knee":0,"hr.knee":0,"fl.knee":0,"fr.knee":0,pitch:8,"fl.swing":35,"fr.swing":35,"hl.swing":-35,"hr.swing":-35},{act:!1,easing:"ease-out"}),o.key((d+f)/2,{lift:h,squash:1,pitch:0,"fl.knee":60,"fr.knee":60,"hl.knee":60,"hr.knee":60,"fl.swing":25,"fr.swing":25,"hl.swing":-20,"hr.swing":-20},{act:!1,easing:"ease-out"}),o.key(f,{lift:0,squash:.85,pitch:-4,"fl.knee":0,"fr.knee":0,"hl.knee":0,"hr.knee":0,"fl.swing":0,"fr.swing":0,"hl.swing":0,"hr.swing":0},{act:!1,easing:"ease-in"}),o.key(f+280,{squash:1,pitch:0,neck:0}),a.to!==void 0){const p=Math.sign(a.to-o.x);p!==0&&o.facing()!==p&&o.turnTo(l,p>0?"right":"left"),o.move(d,f,a.to)}return o.effect({kind:"dust",time:f,x:o.x,y:o.floor,length:550}),{end:f+280,contact:f}}},nod:{summary:"Nods its head twice.",run(o,a,l){return o.key(l+200,{neck:20},{act:!1,easing:"ease-out"}),o.key(l+400,{neck:-5},{act:!1,easing:"ease-in-out"}),o.key(l+600,{neck:18},{act:!1,easing:"ease-in-out"}),o.key(l+900,{neck:0}),{end:l+900}}},swish:{summary:"Swishes its tail a few times.",uses:["for"],run(o,a,l){const c=a.for??900;for(let h=1;h<=4;h++)o.key(l+c*h/5,{tail:h%2===0?10:35},{act:!1,easing:"ease-in-out"});return o.key(l+c,{tail:0}),{end:l+c}}}};return t.grazes&&(r.graze={summary:"Lowers its head to graze for `for` ms (default 1800), nibbling, then looks up.",uses:["for"],run(o,a,l){const c=a.for??1800;o.key(l+600,{neck:75},{act:!1,easing:"ease-in-out"});for(let h=900;h<600+c;h+=400)o.key(l+h,{neck:h%800===100?70:78},{act:!1,easing:"ease-in-out"});return o.key(l+600+c+500,{neck:0}),{end:l+600+c+500}}}),r}function Hy(t={}){return cn({kind:t.kind??"horse",summary:t.summary??"A cartoon horse: walks, trots, canters and gallops with its hooves in step with the ground, rears, bucks, neighs, grazes and swishes its tail.",legs:{upper:.5,lower:.42,foot:.08,footSize:[.12,.16],front:.62,hind:-.62,across:.2,thickness:[.075,.09],lowerThickness:.05},body:{radii:[.32,.36,.95],rise:.25},neck:{at:[0,1.42,.7],points:[[0,0,0],[0,.5,.3]],radius:.15},head:{at:[0,.48,.5],radii:[.13,.14,.3],rotate:[38,0,0]},muzzle:{at:[0,-.02,.24],radii:[.11,.1,.1]},ears:{at:[.07,.16,-.17],radii:[.035,.1,.05]},eyes:{at:[.115,.05,-.04],size:.04},tail:{at:[0,1.4,-.9],points:[[0,0,0],[0,-.22,-.2],[0,-.62,-.24]],radius:.08},mane:{points:[[0,.1,-.12],[0,.55,.17]],radius:.07},colors:{coat:"#b5763a",dark:"#4a2e1a",foot:"#3a2a22",muzzle:"#8d5a2c",accent:"#e8c9a0",...t.colors},gaits:["walk","trot","canter","gallop"],call:"neigh",grazes:!0,anchors:{hitch:{at:[0,.95,-.15]},saddle:{at:[0,1.6,-.05]}},actions:e=>({rear:{summary:"Rears up on its hind legs, front legs tucked and pawing, neighs, and drops back down with dust.",uses:["for"],run(n,s,i){const r=n.exaggeration,o=Math.min(55,32*r),a=-e.hind*Math.sin(o*ln),l=s.for??700;n.key(i+200,{pitch:-4,neck:6,"hl.knee":12,"hr.knee":12},{act:!1,easing:"ease-out"}),n.key(i+520,{pitch:o,lift:a,neck:-25,"fl.swing":55,"fl.knee":95,"fr.swing":40,"fr.knee":80,"hl.knee":0,"hr.knee":0},{act:!1,easing:"ease-out"}),n.key(i+520+l*.5,{"fl.swing":35,"fl.knee":70,"fr.swing":58,"fr.knee":100},{act:!1,easing:"ease-in-out"}),n.key(i+520+l,{"fl.swing":55,"fl.knee":95,"fr.swing":40,"fr.knee":80},{act:!1,easing:"ease-in-out"});const c=i+520+l+380;return n.key(c,{pitch:0,lift:0,neck:8,squash:.94,"fl.swing":0,"fl.knee":0,"fr.swing":0,"fr.knee":0},{act:!1,easing:"ease-in"}),n.key(c+320,{neck:0,squash:1}),e.call(n,i+520),n.effect({kind:"dust",time:c,x:n.x+(n.facing()||1)*e.front*n.scale,y:n.floor,length:600}),{end:c+320,contact:c}}},buck:{summary:"Bucks: drops its head and kicks both hind legs up and back.",run(n,s,i){const r=n.exaggeration,o=Math.min(35,18*r),a=e.front*Math.sin(o*ln);return n.key(i+220,{pitch:3,squash:.95},{act:!1,easing:"ease-out"}),n.key(i+480,{pitch:-o,lift:a,neck:30,"hl.swing":-65,"hr.swing":-60,"hl.knee":10,"hr.knee":10},{act:!1,easing:"ease-out"}),n.key(i+900,{pitch:0,lift:0,neck:0,squash:.95,"hl.swing":0,"hr.swing":0,"hl.knee":0,"hr.knee":0},{act:!1,easing:"ease-in"}),n.key(i+1150,{squash:1}),n.effect({kind:"dust",time:i+900,x:n.x-(n.facing()||1)*.6*n.scale,y:n.floor,length:600}),{end:i+1150,contact:i+480}}}})})}function Ry(t={}){return cn({kind:t.kind??"dog",summary:t.summary??"A cartoon dog: walks, trots and runs, barks, wags its tail, sits, jumps, sniffs the ground.",legs:{upper:.19,lower:.16,foot:.05,footSize:[.07,.1],front:.24,hind:-.24,across:.09,thickness:[.04,.05],lowerThickness:.032},body:{radii:[.14,.15,.36],rise:.1},neck:{at:[0,.56,.27],points:[[0,0,0],[0,.14,.06]],radius:.075},head:{at:[0,.15,.08],radii:[.12,.11,.13]},muzzle:{at:[0,-.03,.13],radii:[.065,.055,.08]},ears:{at:[.11,0,-.02],radii:[.025,.09,.05],rotate:[0,0,18]},eyes:{at:[.08,.04,.08],size:.025},tail:{at:[0,.58,-.34],points:[[0,0,0],[0,.1,-.08],[0,.2,-.1]],radius:.03},extras:e=>[{id:"nose",parent:"muzzle",shape:{type:"ellipsoid",radii:[.025,.02,.02],segments:8},at:[0,.03,.08],fill:"#1d1d22",outline:.4},{id:"patch",parent:"body",shape:{type:"ellipsoid",radii:[.012,.09,.11],segments:10},at:[.135,.04,-.06],fill:e.accent,outline:.5}],colors:{coat:"#d9a066",dark:"#a8703a",foot:"#a8703a",muzzle:"#f0d2a8",accent:"#f6ead8",...t.colors},gaits:["walk","trot","gallop"],cycleScale:.55,call:"bark",anchors:{leash:{part:"neck",at:[0,.06,0]}},actions:()=>({wag:{summary:"Wags its tail fast for `for` ms (default 1200).",uses:["for"],run(e,n,s){const i=n.for??1200;for(let r=80,o=0;r<i;r+=80,o++)e.key(s+r,{wag:o%2===0?35:-35,tail:25},{act:!1,easing:"ease-in-out"});return e.key(s+i,{wag:0,tail:0}),{end:s+i}}},sniff:{summary:"Puts its nose to the ground and sniffs (`for` ms, default 1400).",uses:["for"],run(e,n,s){const i=n.for??1400;e.key(s+350,{neck:70,pitch:-6},{act:!1,easing:"ease-in-out"});for(let r=500,o=0;r<i;r+=140,o++)e.key(s+r,{neck:o%2===0?74:66},{act:!1});return e.key(s+i+300,{neck:0,pitch:0}),{end:s+i+300}}}})})}function Ly(t={}){return cn({kind:t.kind??"cat",summary:t.summary??"A cartoon cat: walks, trots and runs, meows, arches its back, pounces, sits and swishes its tail.",legs:{upper:.13,lower:.11,foot:.035,footSize:[.05,.07],front:.17,hind:-.18,across:.06,thickness:[.028,.035],lowerThickness:.022},body:{radii:[.1,.105,.27],rise:.07},neck:{at:[0,.39,.2],points:[[0,0,0],[0,.08,.04]],radius:.05},head:{at:[0,.1,.05],radii:[.095,.085,.085]},muzzle:{at:[0,-.03,.07],radii:[.04,.03,.03]},ears:{at:[.055,.085,-.01],radii:[.03,.055,.02],rotate:[0,0,-12]},eyes:{at:[.045,.02,.07],size:.022},tail:{at:[0,.42,-.26],points:[[0,0,0],[0,.08,-.12],[0,.24,-.16],[0,.34,-.1]],radius:.022},extras:()=>[{id:"nose",parent:"muzzle",shape:{type:"ellipsoid",radii:[.014,.01,.01],segments:8},at:[0,.015,.03],fill:"#e48a9a",outline:.4}],colors:{coat:"#8f8a86",dark:"#5f5a57",foot:"#f2efe9",muzzle:"#f2efe9",accent:"#f2efe9",...t.colors},gaits:["walk","trot","gallop"],cycleScale:.5,call:"meow",actions:e=>({arch:{summary:"Arches its back, fur up and tail high, for `for` ms (default 1200): a startled cat.",uses:["for"],run(n,s,i){const r=n.exaggeration,o=s.for??1200,a={squash:1+.25*r,neck:25,tail:-45,"fl.swing":-8,"fr.swing":-8,"hl.swing":8,"hr.swing":8};return n.key(i+180,a,{act:!1,easing:"ease-out"}),n.key(i+180+o,a,{act:!1}),n.key(i+o+520,{squash:1,neck:0,tail:0,"fl.swing":0,"fr.swing":0,"hl.swing":0,"hr.swing":0}),{end:i+o+520,contact:i+180}}},pounce:{summary:"Crouches low, wiggles, and pounces to `to`, landing with a squash.",needs:["to"],run(n,s,i){const r=n.exaggeration,o=Math.sign(s.to-n.x);let a=i;o!==0&&n.facing()!==o&&(a=n.turnTo(a,o>0?"right":"left"));const l={squash:.75,"hl.knee":60,"hr.knee":60,"fl.knee":45,"fr.knee":45,neck:10,tail:-15};n.key(a+300,l,{act:!1,easing:"ease-out"});for(let u=1;u<=4;u++)n.key(a+300+u*110,{roll:u%2===0?3:-3},{act:!1});const c=a+300+550,h=c+480;return n.key(c,{roll:0,squash:1.2,"hl.knee":0,"hr.knee":0,"fl.knee":0,"fr.knee":0,"fl.swing":45,"fr.swing":45,"hl.swing":-45,"hr.swing":-45,tail:20},{act:!1,easing:"ease-out"}),n.key((c+h)/2,{lift:e.legLength*.9*r,squash:1.1,pitch:-6},{act:!1,easing:"ease-out"}),n.key(h,{lift:0,squash:.8,pitch:0,"fl.swing":0,"fr.swing":0,"hl.swing":0,"hr.swing":0,neck:0,tail:0},{act:!1,easing:"ease-in"}),n.key(h+260,{squash:1}),n.move(c,h,s.to),n.effect({kind:"dust",time:h,x:s.to,y:n.floor,length:450}),{end:h+260,contact:h}}}})})}function Fy(t={}){return cn({kind:t.kind??"cow",summary:t.summary??"A cartoon cow: walks and trots, moos, grazes, sits and swishes its tail.",legs:{upper:.42,lower:.36,foot:.08,footSize:[.13,.15],front:.68,hind:-.66,across:.24,thickness:[.085,.1],lowerThickness:.06},body:{radii:[.4,.42,1],rise:.32},neck:{at:[0,1.3,.85],points:[[0,0,0],[0,.22,.25]],radius:.19},head:{at:[0,.18,.4],radii:[.17,.19,.27],rotate:[30,0,0]},muzzle:{at:[0,-.06,.22],radii:[.15,.11,.1]},ears:{at:[.17,.06,-.12],radii:[.11,.035,.05],rotate:[0,0,-15]},eyes:{at:[.13,.06,.02],size:.04},tail:{at:[0,1.48,-1],points:[[0,0,0],[0,-.25,-.12],[0,-.7,-.14]],radius:.035},extras:e=>[{id:"horn-left",parent:"head",shape:{type:"tube",points:[[0,0,0],[.08,.12,.02]],radius:.025,segments:6},at:[.1,.16,-.14],fill:"#efe6d2",outline:.6},{id:"horn-right",parent:"head",shape:{type:"tube",points:[[0,0,0],[-.08,.12,.02]],radius:.025,segments:6},at:[-.1,.16,-.14],fill:"#efe6d2",outline:.6},{id:"udder",shape:{type:"ellipsoid",radii:[.16,.12,.18],segments:10},at:[0,.98,-.45],fill:"#f0a6b6",outline:.6},{id:"spot-1",parent:"body",shape:{type:"ellipsoid",radii:[.02,.2,.26],segments:10},at:[.39,.06,.2],fill:e.accent,outline:.4},{id:"spot-2",parent:"body",shape:{type:"ellipsoid",radii:[.02,.16,.22],segments:10},at:[-.39,.1,-.35],fill:e.accent,outline:.4},{id:"spot-3",parent:"body",shape:{type:"ellipsoid",radii:[.2,.02,.24],segments:10},at:[0,.41,-.2],fill:e.accent,outline:.4}],colors:{coat:"#f4f1ea",dark:"#2e2b2a",foot:"#3a3330",muzzle:"#f0b8c4",accent:"#2e2b2a",...t.colors},gaits:["walk","trot"],cycleScale:1.15,call:"moo",grazes:!0})}function d4(t){return zo(1,t)}function Ny(t={}){return cn({kind:t.kind??"goat",summary:t.summary??"A goat: walks, trots and gallops, bleats, grazes, sits, lies, jumps, and swishes its stubby tail.",legs:{upper:.22,lower:.2,foot:.05,footSize:[.07,.09],front:.26,hind:-.26,across:.1,thickness:[.045,.05],lowerThickness:.03},body:{radii:[.15,.17,.38],rise:.1},neck:{at:[0,.62,.3],points:[[0,0,0],[0,.16,.1]],radius:.07},head:{at:[0,.16,.1],radii:[.09,.1,.15],rotate:[-20,0,0]},muzzle:{at:[0,-.05,.13],radii:[.055,.05,.07]},ears:{at:[.1,.03,-.02],radii:[.06,.025,.03],rotate:[0,0,-20]},eyes:{at:[.065,.05,.09],size:.022},tail:{at:[0,.64,-.37],points:[[0,0,0],[0,.06,-.05]],radius:.025},extras:e=>[{id:"horn-left",parent:"head",shape:{type:"tube",points:[[0,0,0],[.01,.07,-.03],[.015,.12,-.08]],radius:.014,segments:6},at:[.045,.08,-.02],fill:e.dark},{id:"horn-right",parent:"head",shape:{type:"tube",points:[[0,0,0],[-.01,.07,-.03],[-.015,.12,-.08]],radius:.014,segments:6},at:[-.045,.08,-.02],fill:e.dark},{id:"beard",parent:"head",shape:{type:"ellipsoid",radii:[.025,.05,.02],segments:8},at:[0,-.12,.06],fill:e.accent,outline:.5}],colors:{coat:"#e9e2d3",dark:"#8c7b66",foot:"#4f4339",muzzle:"#d8cdb8",accent:"#cfc4b0",...t.colors},gaits:["walk","trot","gallop"],cycleScale:.8,call:"bleat",grazes:!0})}function Wy(t={}){return cn({kind:t.kind??"rabbit",summary:t.summary??"A rabbit: walks and hops (gallop), squeaks, nibbles the ground (graze), sits, lies and jumps; long ears and a puff of a tail.",legs:{upper:.07,lower:.07,foot:.03,footSize:[.04,.07],front:.11,hind:-.12,across:.06,thickness:[.028,.04],lowerThickness:.02},body:{radii:[.1,.11,.19],rise:.05},neck:{at:[0,.22,.14],points:[[0,0,0],[0,.06,.04]],radius:.05},head:{at:[0,.07,.04],radii:[.08,.075,.09]},muzzle:{at:[0,-.02,.07],radii:[.035,.028,.03]},ears:{at:[.035,.08,-.02],radii:[.022,.1,.03],rotate:[-15,0,-8]},eyes:{at:[.045,.015,.06],size:.02},tail:{at:[0,.2,-.18],points:[[0,0,0],[0,.03,-.02]],radius:.03},extras:()=>[{id:"nose",parent:"muzzle",shape:{type:"ellipsoid",radii:[.012,.009,.009],segments:8},at:[0,.012,.03],fill:"#e48a9a",outline:.4}],colors:{coat:"#c9b8a6",dark:"#9a8574",foot:"#b5a493",muzzle:"#eadfd2",accent:"#f4ece2",...t.colors},gaits:["walk","gallop"],cycleScale:.4,call:"squeak",grazes:!0})}function Dy(t={}){return cn({kind:t.kind??"squirrel",summary:t.summary??"A squirrel: scampers (gallop) and walks, chatters, sits up, nibbles (graze), with a bushy tail curled over its back.",legs:{upper:.05,lower:.05,foot:.02,footSize:[.025,.04],front:.08,hind:-.08,across:.04,thickness:[.02,.025],lowerThickness:.014},body:{radii:[.065,.07,.14],rise:.03},neck:{at:[0,.16,.1],points:[[0,0,0],[0,.04,.03]],radius:.035},head:{at:[0,.05,.03],radii:[.055,.05,.06]},muzzle:{at:[0,-.015,.05],radii:[.025,.02,.02]},ears:{at:[.03,.05,-.01],radii:[.015,.03,.012],rotate:[0,0,-5]},eyes:{at:[.035,.012,.04],size:.015},tail:{at:[0,.14,-.13],points:[[0,0,0],[0,.08,-.06],[0,.2,-.04],[0,.26,.04]],radius:.045},colors:{coat:"#a9663a",dark:"#7a4523",foot:"#7a4523",muzzle:"#e9c9a8",accent:"#f0dcc4",...t.colors},gaits:["walk","gallop"],cycleScale:.3,call:"chatter",grazes:!0})}const hn=.6,By=75,Sh=80;function un(t){const{colors:e}=t,[n,s,i]=t.body.radii,r=(t.tail.raised??15)*Math.PI/180,o=t.tail.length*.4,a=[{id:"body",shape:{type:"ellipsoid",radii:t.body.radii,segments:16},at:[0,t.body.height,0],fill:e.body},{id:"neck",shape:{type:"ellipsoid",radii:[n*.55,s*.55,i*.3],segments:10},at:[0,t.body.height+s*.45,i*.65],fill:e.body,outline:.5,solidOnly:!0},{id:"head",parent:"neck",shape:{type:"ellipsoid",radii:[t.head.radius,t.head.radius*1.02,t.head.radius*1.05],segments:14},at:[t.head.at[0],t.head.at[1]-(t.body.height+s*.45),t.head.at[2]-i*.65],fill:e.body},{id:"beak",parent:"head",shape:{type:"tube",points:[[0,0,0],[0,-t.beak.thickness*.4,t.beak.length]],radius:[t.beak.thickness,t.beak.thickness*.08],segments:8},at:[0,-t.head.radius*.1,t.head.radius*.8],fill:e.beak,outline:.8},{id:"tail",shape:{type:"ellipsoid",radii:[t.tail.width/2,.012*(i/.08),t.tail.length/2],segments:10},at:[t.tail.at[0],t.tail.at[1]+o*Math.sin(r),t.tail.at[2]-o*Math.cos(r)],rotate:[t.tail.raised??15,0,0],fill:e.wing,outline:.8}];if(e.belly&&a.push({id:"belly",parent:"body",shape:{type:"ellipsoid",radii:[n*.82,s*.7,i*.75],segments:12},at:[0,-s*.25,i*.12],fill:e.belly,outline:.4}),t.comb){const h=t.head.radius;a.push({id:"comb",parent:"head",shape:{type:"extrude",profile:[[-h*.5,h*.6],[h*.6,h*.6],[h*.5,h*1.3],[h*.15,h*1.05],[-h*.05,h*1.4],[-h*.3,h*1.05],[-h*.6,h*1.25]],width:h*.25},fill:e.comb??"#d9372e",outline:.7},{id:"wattle",parent:"head",shape:{type:"ellipsoid",radii:[h*.15,h*.35,h*.2],segments:8},at:[0,-h*.7,h*.6],fill:e.comb??"#d9372e",outline:.6})}for(const h of[1,-1]){const u=h>0?"left":"right",d=t.head.radius;a.push({id:`eye-${u}`,parent:"head",shape:{type:"ellipsoid",radii:[d*.16,d*.2,d*.18],segments:8},at:[h*d*.72,d*.18,d*.42],fill:"#1d1d22",outline:.3}),a.push({id:`wing-${u}`,shape:{type:"ellipsoid",radii:[.004,.004,.004],segments:4},at:[h*t.wing.shoulder[0],t.wing.shoulder[1],t.wing.shoulder[2]],rotate:[-8,h*90,0],outline:0}),a.push({id:`wing-${u}-blade`,parent:`wing-${u}`,shape:{type:"ellipsoid",radii:[t.wing.span*hn/2,t.wing.chord*.1,t.wing.chord/2],segments:12},at:[h*t.wing.span*hn/2,0,-t.wing.chord*.1],rotate:[-Sh,0,0],fill:e.wing,outline:.8}),a.push({id:`wing-${u}-tip`,parent:`wing-${u}-blade`,shape:{type:"ellipsoid",radii:[t.wing.span*hn/2.4,t.wing.chord*.06,t.wing.chord*.3],segments:10},at:[h*t.wing.span*hn/4,0,-t.wing.chord*.3],rotate:[0,h*14,0],fill:e.wing,outline:.8}),a.push({id:`leg-${u}`,shape:{type:"tube",points:[[0,0,0],[0,-t.legs.length,0]],radius:Math.max(.004,t.legs.length*.05),segments:5},at:[h*t.legs.across,t.legs.length,0],fill:e.legs,outline:.6}),a.push({id:`toes-${u}`,parent:`leg-${u}`,shape:{type:"tube",points:[[0,0,-t.legs.length*.15],[0,0,t.legs.length*.35]],radius:Math.max(.003,t.legs.length*.04),segments:5},at:[0,-t.legs.length,0],fill:e.legs,outline:.6})}const l={spread:{description:"Wings: 0 folded back along the body, 1 spread out",unit:"0..1",min:0,max:1,bind:[{parts:["wing-left"],rotate:{axis:"y",degrees:-90}},{parts:["wing-right"],rotate:{axis:"y",degrees:90}},{parts:["wing-left-blade"],translate:[t.wing.span*(1-hn)/2,0,0],rotate:{axis:"x",degrees:Sh},scale:[1/hn,1,1]},{parts:["wing-right-blade"],translate:[-t.wing.span*(1-hn)/2,0,0],rotate:{axis:"x",degrees:Sh},scale:[1/hn,1,1]}]},flap:{description:"Wings raised (+) or lowered (−) at the shoulders",unit:"degrees",bind:[{parts:["wing-left"],rotate:{axis:"z",degrees:1}},{parts:["wing-right"],rotate:{axis:"z",degrees:-1}}]},wingbeat:{description:"Phase of the wingbeat, in beats (keyed steadily while flapping)",unit:"beats"},flapping:{description:"How hard the wings beat: 0 still, 1 full beats",unit:"0..1",min:0,max:1},peck:{description:"Head bobbed down and forward (+, pecking) or up (−)",unit:"degrees",bind:[{parts:["neck"],rotate:{axis:"x",degrees:1},translate:[0,-(t.neckReach??0)/By,0]}]},step:{description:"Phase of a walk, in steps (a chicken’s legs)",unit:"steps"},stepping:{description:"How much of the walk is applied",unit:"0..1",min:0,max:1},"leg.left":{description:"Left leg swung forward (+)",unit:"degrees",bind:[{parts:["leg-left"],rotate:{axis:"x",degrees:-1}}]},"leg.right":{description:"Right leg swung forward (+)",unit:"degrees",bind:[{parts:["leg-right"],rotate:{axis:"x",degrees:-1}}]},grip:{description:"The toes curled down round a perch: 0 flat on the ground, 1 gripping",unit:"0..1",min:0,max:1,bind:[{parts:["toes-left","toes-right"],rotate:{axis:"x",degrees:55}}]}},c={parts:a,controls:l,length:i*2+t.tail.length+t.beak.length,height:t.head.at[1]+t.head.radius,footprint:[n*2.2,i*2.4],anchors:{beak:{part:"beak",at:[0,0,t.beak.length]},head:{part:"head",at:[0,0,0]},back:{at:[0,t.body.height+s,0]},feet:{at:[0,0,0]}},derive:h=>{const u={},d=Math.max(0,Math.min(1,h.flapping??0));d>0&&(u.flap=(h.flap??0)+d*48*Math.sin(Math.PI*2*(h.wingbeat??0)));const f=Math.max(0,Math.min(1,h.stepping??0));if(f>0){const p=Math.sin(Math.PI*2*(h.step??0));u["leg.left"]=(h["leg.left"]??0)+f*28*p,u["leg.right"]=(h["leg.right"]??0)-f*28*p,u.peck=(h.peck??0)+f*12*Math.sin(Math.PI*4*(h.step??0))}return u}};return{kind:t.kind,family:"bird",summary:t.summary,rig:c,actions:g4(t),acting:zy,colors:{body:e.body,ink:"#26262b"},moves:f4(t)}}function f4(t){const e=t.legs.length*1.2,n={walk:{speed:e/.42,hold:{stepping:1},perMetre:{step:.5/e}}};return t.flies!==!1&&(n.fly={speed:4+t.wing.span*12,flies:!0,hold:{flapping:1,spread:1},perSecond:{wingbeat:t.beatsPerSecond??4}}),n}const zy={depth:{turn:0,lift:0,pitch:1,roll:1,squash:1,spread:1,flap:2,peck:2},limits:{pitch:6,roll:6,squash:.06,peck:8,flap:10,lift:0},eyes:[],headTurns:{},drift:[]};function g4(t){const e=(t.beatsPerSecond??4)/1e3,n=(o,a,l)=>{const c=o.values.wingbeat??0;o.set("wingbeat",a,c),o.set("wingbeat",l,c+(l-a)*e)},s=(o,a,l)=>{const c=Math.sign(l-o.x);return c!==0&&o.facing()!==c?o.turnTo(a,c>0?"right":"left"):a},i=(o,a)=>{const l=o.anchor("beak");o.effect({kind:"honk",time:a,x:l.x,y:l.y,length:600,direction:o.facing()||1})},r={hop:{summary:"Hops to `to` in little bounces, wings twitching.",needs:["to"],run(o,a,l){const c=s(o,l,a.to),h=o.x,u=Math.abs(a.to-h),d=Math.max(1,Math.round(u/(t.body.radii[2]*3*o.scale))),f=260;for(let p=0;p<d;p++){const g=c+p*f;o.key(g+60,{squash:.85},{act:!1,easing:"ease-out"}),o.key(g+150,{squash:1.1,lift:t.legs.length*1.4,spread:.15},{act:!1,easing:"ease-out"}),o.key(g+f,{squash:.9,lift:0,spread:0},{act:!1,easing:"ease-in"}),o.move(g+60,g+f,h+(a.to-h)*(p+1)/d,{easing:"ease-in-out"})}return o.key(c+d*f+120,{squash:1}),{end:c+d*f+120}}},walk:{summary:"Walks to `to` on its two legs, its head bobbing with each step.",needs:["to"],uses:["for"],run(o,a,l){const c=s(o,l,a.to),h=Math.abs(a.to-o.x)/o.scale,u=t.legs.length*1.2,d=h/u,f=a.for??Math.max(400,d*420),p=o.values.step??0;return o.set("stepping",c,0),o.set("stepping",c+150,1,"ease-out"),o.set("stepping",c+f-150,1),o.set("stepping",c+f,0,"ease-in"),o.set("step",c,p),o.move(c,c+f,a.to,{easing:"ease-in-out"}),o.set("step",c+f,p+d/2,"ease-in-out"),{end:c+f,contact:c,release:c+f}}},peck:{summary:"Pecks at the ground (`for` ms, default 900): quick jabs of the head.",uses:["for"],run(o,a,l){const c=a.for??900,h=Math.max(1,Math.round(c/300));o.key(l+120,{pitch:-(t.stoop??12)},{act:!1,easing:"ease-out"});for(let u=0;u<h;u++)o.key(l+120+u*300+90,{peck:By},{act:!1,easing:"ease-in"}),o.key(l+120+u*300+260,{peck:20},{act:!1,easing:"ease-out"});return o.key(l+120+h*300+200,{peck:0,pitch:0}),{end:l+120+h*300+200,contact:l+210}}},flap:{summary:"Flaps its wings on the spot (`for` ms, default 900), lifting a little.",uses:["for"],run(o,a,l){const c=a.for??900;return o.key(l+120,{spread:1},{act:!1,easing:"ease-out"}),o.set("flapping",l,0),o.set("flapping",l+150,1,"ease-out"),o.set("flapping",l+c-150,1),o.set("flapping",l+c,0,"ease-in"),n(o,l,l+c),o.key(l+c*.5,{lift:t.legs.length*.6},{act:!1,easing:"ease-out"}),o.key(l+c,{lift:0,spread:0},{act:!1,easing:"ease-in"}),{end:l+c+80}}},[t.call]:{summary:`${t.call[0].toUpperCase()}${t.call.slice(1)}s: its head comes up and its beak opens to call.`,run(o,a,l){return o.key(l+120,{peck:-25,squash:1.06},{act:!1,easing:"ease-out"}),o.key(l+500,{peck:-20},{act:!1}),o.key(l+760,{peck:0,squash:1}),i(o,l+150),{end:l+760,contact:l+150}}}};return t.flies!==!1?(r.fly={summary:"Takes off (a crouch and a leap, wings beating) and flies to `to` at `height` metres (default 2); `land` brings it down.",needs:["to"],uses:["height","for"],run(o,a,l){const c=o.exaggeration;o.key(l+60,{grip:0},{act:!1});const h=s(o,l,a.to),u=a.height??2,d=a.for??Math.max(700,Math.abs(a.to-o.x)/.35),f=o.values.lift>t.legs.length,p=f?h:h+200;return f||(o.key(h+160,{squash:1-.18*c,spread:.6},{act:!1,easing:"ease-out"}),o.effect({kind:"dust",time:p,x:o.x,y:o.floor,length:400})),o.key(p+100,{spread:1,squash:1.08,pitch:10},{act:!1,easing:"ease-out"}),o.set("flapping",p,o.values.flapping??0),o.set("flapping",p+100,1,"ease-out"),o.set("flapping",p+d,.6),n(o,p,p+d),o.key(p+d*.4,{lift:u,pitch:-5,squash:1},{act:!1,easing:"ease-out"}),o.key(p+d,{lift:u,pitch:0},{act:!1,easing:"ease-in-out"}),o.move(p,p+d,a.to,{easing:"ease-in-out"}),{end:p+d,contact:p,release:p+d}}},r.glide={summary:"Glides to `to` on still, spread wings, sinking gently to `height` metres (default: a third lower than it is); from the ground it takes off first, flying the first stretch.",needs:["to"],uses:["height","for"],run(o,a,l){let c=l;if(o.values.lift<=t.legs.length){const f=o.x+(a.to-o.x)/3;c=r.fly.run(o,{do:"fly",to:f,height:(a.height??1.5)*1.3},l).end}c=s(o,c,a.to);const h=o.values.lift,u=a.height??h*.67,d=a.for??Math.max(900,Math.abs(a.to-o.x)/.3);return o.set("flapping",c,o.values.flapping??1),o.set("flapping",c+250,0,"ease-out"),n(o,c,c+250),o.key(c+300,{spread:1,flap:10,pitch:-6},{act:!1,easing:"ease-out"}),o.key(c+d,{lift:u,pitch:-3,flap:10},{act:!1,easing:"ease-in-out"}),o.move(c,c+d,a.to,{easing:"ease-in-out"}),{end:c+d,contact:c,release:c+d}}},r.land={summary:"Comes down to the floor it is over (or to `height` metres above it, a branch or a roof): wings braking, a squash on touchdown.",uses:["height","to"],run(o,a,l){const h=a.height??0;return o.set("flapping",l,o.values.flapping??1),o.set("flapping",l+700-120,1),o.set("flapping",l+700,0,"ease-in"),n(o,l,l+700),o.key(l+700*.6,{pitch:14},{act:!1,easing:"ease-out"}),o.key(l+700,{lift:h,pitch:0,squash:.85,grip:h>0?1:0},{act:!1,easing:"ease-in"}),a.to!==void 0&&o.move(l,l+700,a.to,{easing:"ease-out"}),o.key(l+700+160,{squash:1,spread:0,flap:0}),{end:l+700+200,contact:l+700}}}):r.flutter={summary:"Flutters up a little way and back down, wings beating hard (a chicken’s flight).",run(o,a,l){return o.key(l+100,{spread:1,squash:.9},{act:!1,easing:"ease-out"}),o.set("flapping",l+80,0),o.set("flapping",l+160,1,"ease-out"),o.set("flapping",l+900-100,1),o.set("flapping",l+900,0,"ease-in"),n(o,l+80,l+900),o.key(l+900*.5,{lift:t.legs.length*2.5,squash:1.08},{act:!1,easing:"ease-out"}),o.key(l+900,{lift:0,squash:.85,spread:0},{act:!1,easing:"ease-in"}),o.key(l+900+160,{squash:1}),{end:l+900+160,contact:l+900}}},r}function qy(t={}){return un({kind:"songbird",summary:"A small songbird: hops, pecks, tweets, flaps, flies and lands (on the ground, a branch or a roof).",body:{radii:[.05,.05,.075],height:.085},head:{at:[0,.145,.065],radius:.036},beak:{length:.03,thickness:.01},wing:{shoulder:[.04,.1,.03],span:.11,chord:.06},tail:{at:[0,.095,-.07],length:.07,width:.045},legs:{length:.04,across:.018},colors:{body:"#7b6a58",wing:"#5c4c3d",beak:"#e7a43a",legs:"#c47a35",belly:"#e9c8a3",...t.colors},call:"tweet",beatsPerSecond:9})}function jy(t={}){return un({kind:"crow",summary:"A crow: walks and hops, pecks, caws, flaps, flies and lands (on the ground, a branch or a roof).",body:{radii:[.09,.09,.17],height:.2},head:{at:[0,.32,.15],radius:.065},beak:{length:.08,thickness:.022},wing:{shoulder:[.07,.24,.06],span:.32,chord:.14},tail:{at:[0,.2,-.15],length:.16,width:.09},legs:{length:.1,across:.035},colors:{body:"#2b2b33",wing:"#1e1e25",beak:"#3b3b44",legs:"#3b3b44",...t.colors},call:"caw",beatsPerSecond:4})}function Yy(t={}){return un({kind:"chicken",summary:"A chicken: walks with a bobbing head, pecks, clucks, and flutters up and down (it cannot really fly).",body:{radii:[.13,.14,.19],height:.3},head:{at:[0,.5,.16],radius:.07},beak:{length:.05,thickness:.02},wing:{shoulder:[.11,.34,.04],span:.24,chord:.15},tail:{at:[0,.38,-.15],length:.16,width:.13,raised:50},legs:{length:.17,across:.05},comb:!0,stoop:20,neckReach:.12,colors:{body:"#f4ede0",wing:"#e6dccb",beak:"#e7a43a",legs:"#e7a43a",comb:"#d9372e",...t.colors},call:"cluck",flies:!1})}function Ky(t={}){return un({kind:"pigeon",summary:"A pigeon: walks with a bobbing head, pecks at crumbs, coos, flaps, flies and lands (on the ground, a ledge or a branch).",body:{radii:[.08,.075,.14],height:.14},head:{at:[0,.24,.12],radius:.045},beak:{length:.035,thickness:.014},wing:{shoulder:[.065,.17,.05],span:.24,chord:.11},tail:{at:[0,.13,-.13],length:.12,width:.08,raised:8},legs:{length:.06,across:.03},colors:{body:"#8d93a3",wing:"#6f7586",beak:"#5a5a66",legs:"#d9627a",belly:"#b9bdc8",...t.colors},call:"coo",beatsPerSecond:6,stoop:16})}function Xy(t={}){return un({kind:"duck",summary:"A duck: waddles, dabbles with its bill (peck), quacks, flaps, flies and lands (on the ground or the water’s edge).",body:{radii:[.11,.1,.2],height:.16},head:{at:[0,.33,.15],radius:.055},beak:{length:.075,thickness:.028},wing:{shoulder:[.09,.22,.06],span:.28,chord:.13},tail:{at:[0,.17,-.19],length:.1,width:.09,raised:30},legs:{length:.07,across:.045},colors:{body:"#c9b48b",wing:"#8f7a55",beak:"#f2a71b",legs:"#f2a71b",belly:"#e8dcc0",...t.colors},call:"quack",beatsPerSecond:7,stoop:22,neckReach:.04})}function Gy(t={}){return un({kind:"owl",summary:"An owl: a big round head, slow silent wingbeats; hoots, turns its head, flies and lands on a branch.",body:{radii:[.1,.12,.13],height:.19},head:{at:[0,.37,.07],radius:.085},beak:{length:.025,thickness:.02},wing:{shoulder:[.085,.27,.03],span:.34,chord:.18},tail:{at:[0,.14,-.12],length:.1,width:.1,raised:-10},legs:{length:.07,across:.04},colors:{body:"#9c7a55",wing:"#6e5538",beak:"#3d3028",legs:"#c9a76a",belly:"#e3cda8",...t.colors},call:"hoot",beatsPerSecond:3,stoop:6})}function Uy(t={}){return un({kind:"parrot",summary:"A parrot: bright, with a big hooked beak and a long tail; squawks, bobs, flies and lands on a perch, gripping it.",body:{radii:[.07,.08,.13],height:.15},head:{at:[0,.29,.1],radius:.055},beak:{length:.045,thickness:.03},wing:{shoulder:[.06,.2,.05],span:.26,chord:.11},tail:{at:[0,.12,-.12],length:.22,width:.06,raised:-20},legs:{length:.06,across:.03},colors:{body:"#4caf50",wing:"#2e7d32",beak:"#5a5a66",legs:"#8d8d8d",belly:"#a5d66f",comb:"#d9372e",...t.colors},call:"squawk",beatsPerSecond:6,stoop:10})}const Os={car:oy,truck:ay,bus:ly,tractor:cy,cart:hy,trainCar:uy,bike:dy,motorbike:fy,tree:gy,house:my,chair:by,desk:ky,bed:My,door:xy,wheelchair:Ay,helicopter:Iy,airplane:Oy,horse:Hy,dog:Ry,cat:Ly,cow:Fy,goat:Ny,rabbit:Wy,squirrel:Dy,songbird:qy,crow:jy,chicken:Yy,pigeon:Ky,duck:Xy,owl:Gy,parrot:Uy};function xh(t,e={}){const n=Os[t];if(!n)throw new Error(ft("prop preset",t,Object.keys(Os)));return n(e)}const qo=["do","at","for","to","toward","speed","open","on","height","wind"],Th={viewer:0,right:1,away:2,left:3},p4=420,Eh={hold:{summary:"Holds still (`for` ms, default 1000).",run:(t,e,n)=>({end:n+(e.for??1e3)})},turn:{summary:"Turns to face `toward`: viewer, right, away, left, or a quarter-turn value (it turns in 3D, through the nearer way).",needs:["toward"],run:(t,e,n)=>({end:t.turnTo(n,e.toward)})},pop:{summary:"Pops into being: grows from nothing, stretched, overshoots and settles (`for` ms, default 500).",uses:["for"],run(t,e,n){const s=e.for??500,i=t.exaggeration;return t.key(n,{size:0,squash:1},{act:!1}),t.key(n+s*.6,{size:1+.15*i,squash:1+.15*i},{act:!1,easing:"ease-out"}),t.key(n+s,{size:1,squash:1}),{end:n+s,contact:n}}},vanish:{summary:"Shrinks away to nothing, with a little stretch first (`for` ms, default 400).",uses:["for"],run(t,e,n){const s=e.for??400,i=t.exaggeration;return t.key(n+s*.3,{size:1+.08*i,squash:1+.12*i},{act:!1,easing:"ease-out"}),t.key(n+s,{size:0,squash:1},{act:!1,easing:"ease-in"}),{end:n+s,release:n+s}}}};function jo(t){return{...Eh,...t.actions}}const Ah=t=>typeof t=="number"&&Number.isFinite(t);function Vy(t,e){if(!Array.isArray(t))return[{level:"error",beat:-1,message:`Beats must be an array of { do: … } objects (got ${typeof t}).`}];const n=jo(e),s=Object.keys(n),i=[];return t.forEach((r,o)=>{const a=c=>i.push({level:"error",beat:o,message:c});if(!r||typeof r!="object"||Array.isArray(r))return a(`Each beat must be an object like { do: '${s[s.length-1]}' }.`);const l=r;for(const c of Object.keys(l))qo.includes(c)||a(ft("beat field",c,qo,c==="duration"?"for":c==="direction"?"toward":void 0));if(typeof l.do!="string"||!s.includes(l.do))return a(ft(`${e.kind} action`,l.do,s));for(const c of n[l.do].needs??[])l[c]===void 0&&a(`\`${l.do}\` needs \`${c}\`.`);for(const c of["at","for","speed","height","wind"])l[c]!==void 0&&!(Ah(l[c])&&l[c]>=0)&&a(`\`${c}\` must be a number ≥ 0 (got ${JSON.stringify(l[c])}).`);if(l.to!==void 0&&!Ah(l.to)&&a(`\`to\` is a scene x in px (got ${JSON.stringify(l.to)}).`),l.toward!==void 0&&!Ah(l.toward)&&!(typeof l.toward=="string"&&l.toward in Th)){const c=typeof l.toward=="string"?Gs(l.toward,Object.keys(Th)):void 0;a(`\`toward\` is viewer, right, away, left or a quarter-turn number${c?` (did you mean "${c}"?)`:""} (got ${JSON.stringify(l.toward)}).`)}for(const c of["open","on"])l[c]!==void 0&&typeof l[c]!="boolean"&&a(`\`${c}\` is true or false (got ${JSON.stringify(l[c])}).`)}),i}function Jy(t,e,n,s={}){const i=Vy(n,e).filter(S=>S.level==="error");if(i.length>0)throw new Error(`propScript (${e.kind}): ${i.length} problem(s) in the beats:
61
61
  ${i.map(S=>` beat ${S.beat}: ${S.message}`).join(`
62
- `)}`);const r=s.from??0,o=s.ground??0,a=s.scale??60,l=s.exaggeration??1,c=jo(e),h={};for(const S of[...Object.keys(As),...Object.keys(e.rig.controls)])h[S]=s.start?.[S]??It(e.rig,{},S);const u=[{time:0,pose:{...h}}],d=new Map,f=[];let p=r,g=o;const m=(S,E,P,I)=>{const O=d.get(S)??[{time:0,value:S==="x"||S==="y"?0:h[S]}];O.push({time:E,value:P,...I?{easing:I}:{}}),d.set(S,O),S!=="x"&&S!=="y"&&(h[S]=P)},y=(S,E)=>{const P=S==="x"?p-r:S==="y"?g-o:h[S],I=d.get(S);(!I||I[I.length-1].time<E)&&m(S,E,P)},v={prop:e,scale:a,exaggeration:l,get x(){return p},get floor(){return g},values:h,facing(){const S=Math.sin(h.turn*Math.PI/2);return Math.abs(S)<.5?0:S>0?1:-1},key(S,E,P={}){Object.assign(h,E),u.push({time:S,pose:{...h},...P.act===!1?{act:!1}:{},...P.easing?{easing:P.easing}:{}})},move(S,E,P,I={}){y("x",S),m("x",E,P-r,I.easing),p=P,I.floor!==void 0&&(y("y",S),m("y",E,I.floor-o,I.easing),g=I.floor)},set(S,E,P,I){m(S,E,P,I)},turnTo(S,E){const P=typeof E=="number"?E:Th[E],I=h.turn,H=[P-4,P,P+4].map(j=>({t:j,d:Math.abs(j-I)})).sort((j,J)=>j.d-J.d||Math.abs(j.t)-Math.abs(J.t))[0];if(H.d<.001)return S;const W=S+p4*Math.max(1,H.d);return v.key(W,{turn:H.t}),W},effect(S){f.push(S)},anchor(S){const P=Ps(e,h,a).anchors[S];if(!P)throw new Error(`${e.kind}: no anchor "${S}"`);return{x:p+P.point.x,y:g+P.point.y}}},k=[];let w=0;for(const S of n){const E=Math.max(S.at??w,u[u.length-1].time),P=c[S.do].run(v,S,E);P.end>u[u.length-1].time&&u.push({time:P.end,pose:{...h}}),k.push({start:E,end:P.end,...P.contact!==void 0?{contact:P.contact}:{},...P.release!==void 0?{release:P.release}:{}}),w=P.end}const T=Kc(s.style??"snappy"),A={...T,anticipation:T.anticipation*l,overshoot:T.overshoot*l},M=$o(w4(u),e.acting,{style:A}),x=[...Object.entries(M).filter(([S])=>!d.has(S)).map(([S,E])=>({id:`${t}-${S}`,target:t,property:S,keyframes:E})),...[...d].map(([S,E])=>({id:`${t}-${S}`,target:t,property:S,keyframes:k4(E)}))];for(const S of y4(t,e,x,w,u[0].pose)){const E=x.findIndex(O=>O.property===S.property);if(E<0){x.push(S);continue}const P=new Ht({id:`${t}-own`,tracks:[x[E]]}),I=O=>Number(P.getStateAtTime(O).values.get(t)?.get(S.property)??0);x[E]={...S,keyframes:S.keyframes.map(O=>({time:O.time,value:Number(O.value)+I(O.time)}))}}return{tracks:x,duration:w,beats:k,effects:f}}const m4=1500;function y4(t,e,n,s,i){if(!e.follow?.length)return[];const r=new Ht({id:`${t}-follow`,tracks:n.filter(a=>a.property==="turn"||e.follow.some(l=>l.of===a.property))}),o=(a,l)=>{const c=r.getStateAtTime(a).values.get(t)?.get(l);return typeof c=="number"?c:i[l]??0};return e.follow.map(a=>{const l=s+m4,c=Us(d=>o(d,a.of),{start:0,end:l,stiffness:a.stiffness,damping:a.damping}),h=a.limit??1/0,u=c.map(({time:d,value:f})=>{const p=Math.sin(o(d,"turn")*Math.PI/2),g=(f-o(d,a.of))*p;return{time:d,value:Math.max(-h,Math.min(h,g*a.per))}});return{id:`${t}-${a.control}`,target:t,property:a.control,keyframes:u}})}const b4=20;function w4(t){const e=[...t].sort((s,i)=>s.time-i.time),n=[];for(const s of e){const i=n[n.length-1];i&&s.time-i.time<b4?n[n.length-1]={...s,time:i.time}:n.push(s)}return n}function k4(t){const e=t.map((s,i)=>({k:s,i})).sort((s,i)=>s.k.time-i.k.time||s.i-i.i),n=[];for(const{k:s}of e)n.length>0&&n[n.length-1].time===s.time?n[n.length-1]=s:n.push(s);return n}const We=Object.freeze({test:Object.freeze({name:"Test",inningsPerSide:2,oversPerInnings:null,ballsPerOver:6,freeHitAfterNoBall:!1,summary:"Multi-day cricket. Each side can have two innings; there is no innings over limit."}),odi:Object.freeze({name:"ODI",inningsPerSide:1,oversPerInnings:50,ballsPerOver:6,freeHitAfterNoBall:!0,summary:"One innings per side, up to 50 overs. A no-ball gives a free hit on the next legitimate delivery."}),t20:Object.freeze({name:"T20",inningsPerSide:1,oversPerInnings:20,ballsPerOver:6,freeHitAfterNoBall:!0,summary:"One innings per side, up to 20 overs. A no-ball gives a free hit on the next legitimate delivery."})}),Ph=Object.freeze({adults:"Adults",men:"Men",children:"Children",mixed:"Mixed cast"}),Cs=Object.freeze({bowler:"Bowler",keeper:"Wicketkeeper",fielder:"Extra cover",slip:"Slip",point:"Point",cover:"Cover","mid-off":"Mid-off","mid-on":"Mid-on","square-leg":"Square leg","fine-leg":"Fine leg","third-man":"Third man"}),Wn=Object.freeze(Object.fromEntries(Object.entries({bowling:{name:"Pace bowling",summary:"Run up, deliver with a straight arm, bounce and follow through."},spin:{name:"Spin bowling",summary:"A shorter approach and a curved illustrative flight before the bounce."},batting:{name:"Drive",summary:"Two hands on the bat, a backlift, contact and a follow-through."},defend:{name:"Defensive block",summary:"Meet the ball with a controlled bat and keep it close."},running:{name:"Running between wickets",summary:"Both batters make the opposite ground to complete one run."},four:{name:"Boundary four",summary:"A struck ball reaches the boundary after touching the ground."},six:{name:"Boundary six",summary:"A struck ball clears the boundary before touching the ground."},catch:{name:"Catch",summary:"A fielder controls the struck ball before it touches the ground."},fielding:{name:"Ground field",summary:"A fielder moves to the ball, bends and gathers it."},throw:{name:"Field and throw",summary:"Gather, wind up, release and return the ball to the keeper."},bowled:{name:"Bowled",summary:"A legal delivery hits the wicket and removes a bail."},lbw:{name:"LBW illustration",summary:"Pad contact and a projected path to the stumps illustrate an authored LBW decision."},stumping:{name:"Stumping",summary:"The keeper holds the ball and breaks the wicket while the striker is out of ground, not attempting a run."},"run-out":{name:"Run-out",summary:"A direct throw breaks the wicket before the running batter makes that ground."},"no-ball":{name:"Front-foot no-ball",summary:"The landing front foot oversteps the popping crease at release; one extra, no legal ball."},wide:{name:"Wide ball",summary:"An untouched delivery passes beyond reach for a normal stroke; one extra, no legal ball."}}).map(([t,e])=>[t,Object.freeze(e)])));function ge(t,e,n){if(!Object.prototype.hasOwnProperty.call(t,e))throw new Error(`${n}: unknown choice '${e}'`);return e}const _t=(t,e,n)=>Math.max(0,Math.min(1,(t-e)/(n-e))),Ft=t=>t*t*(3-2*t),Tt=(t,e)=>Vs(t,e),$h=(t,e)=>yn(t,e);function Ih(t,e){const n=e+((t-e+2)%4+4)%4-2;return n===0?0:n}function _s(t,e,n=0){return Math.hypot(e[0]-t[0],e[2]-t[2])<.001?n:Ih(Math.atan2(e[0]-t[0],e[2]-t[2])*2/Math.PI,n)}function Zy(){return{turn:1,"head.turn":90,"leg.left.spread":12,"leg.right.spread":12,"leg.left.swing":6,"leg.right.swing":6,"leg.left.knee":12,"leg.right.knee":12}}function Oh(t,e){const n=t.objects.find(s=>s.id===e);if(!n||n.kind!=="character")throw new Error(`cricketAction: required character '${e}' is missing`);if(n.parent||n.rotation?.some(s=>s!==0)||n.quaternion||n.scale!==void 0)throw new Error(`cricketAction: '${e}' must use position and pose.turn, without a transformed parent, scale or object rotation`);return{object:n,who:ps({...n.character,height:n.height??1.78})}}function Qy(t){return{position:[...t.object.position??[0,0,0]],pose:{...lt,...t.object.pose}}}function Hs(t,e,n,s){const i=Qe(t.who.plan,e.pose,{height:t.who.height,contact:t.who.contact});return Tt(e.position,i.chains[n][s])}function ji(t,e,n){const s=Hs(t,e,`arm.${n}`,2),i=Hs(t,e,`arm.${n}`,1);return Tt(s,$h(Jt(se(s,i)),t.who.lineWidth*.5))}function v4(t,e,n){const s={...e.pose,"head.turn":0,"head.nod":0,"head.tilt":0},i=Qe(t.who.plan,s,{height:t.who.height,contact:t.who.contact}).head,r=se(n,Tt(e.position,i.center)),o=i.axes.map(c=>Ie(r,c)),a=Math.atan2(o[0],o[2])*180/Math.PI,l=Math.atan2(-o[1],Math.hypot(o[0],o[2]))*180/Math.PI;return{...e,pose:{...e.pose,"head.turn":Math.max(-90,Math.min(90,a)),"head.nod":Math.max(-25,Math.min(30,l)),"head.tilt":0}}}function dn(t,e,n,s,i="hold"){let r={...e.pose};for(let o=0;o<10;o++){const a={...e,pose:r},l=Qe(t.who.plan,r,{height:t.who.height,contact:t.who.contact}),c=ss(t.who.plan,r,t.who.height),h=se(ji(t,a,n),Hs(t,a,`arm.${n}`,2)),u=se(se(se(s,h),e.position),l.hip),d=ns(u,(r.roll??0)*Math.PI/180),f=Tt(c.root,Qt(d,-(r.turn??0)*Math.PI/2));r=mi(t.who.plan,r,`arm.${n}`,f,{height:t.who.height})}for(const[o,a]of Object.entries(St[i]))r[`hand.${n}.${o}`]=a;return{...e,pose:r}}function M4(t,e,n,s){const i=Jt(s),r=t.who.height/1.78;let o=dn(t,e,"left",n);return o=dn(t,o,"right",Tt(ji(t,o,"left"),$h(i,.105*r))),{...o,bat:{grip:ji(t,o,"left"),axis:i,scale:r}}}function S4(t){return Tt(t.grip,$h(t.axis,.51*t.scale))}function t1(t){const e=Jt(t),n=Math.max(-1,Math.min(1,e[1]));return n>.999999?[0,0,0,1]:n<-.999999?Vt([1,0,0],180):Vt(Jt(Js([0,1,0],e)),Math.acos(n)*180/Math.PI).map(s=>s===0?0:s)}function Yo(t,e,n){const s={};for(const i of Object.keys({...t,...e})){const r=t[i]??lt[i]??0;s[i]=r+((e[i]??lt[i]??0)-r)*n}return s}function Ch(t,e){if(t<=e[0][0])return{...lt,...e[0][1]};for(let n=1;n<e.length;n++)if(t<=e[n][0])return Yo({...lt,...e[n-1][1]},{...lt,...e[n][1]},Ft(_t(t,e[n-1][0],e[n][0])));return{...lt,...e.at(-1)[1]}}function De(t,e){if(!Array.isArray(t)||t.length!==3||!t.every(Number.isFinite))throw new Error(`${e}: expected three finite coordinates`)}function e1(t,e,n=40,s=[]){if(!Number.isFinite(t)||!Number.isFinite(e)||t<0||e<t)throw new Error("sampleTimes: expected finite ordered nonnegative times");if(!Number.isFinite(n)||n<16||n>1e3)throw new Error("sampleTimes: every must be between 16 and 1000 ms");if((e-t)/n>2e4)throw new Error("sampleTimes: too many samples");const i=new Set([t,e,...s.filter(r=>r>=t&&r<=e&&Number.isFinite(r))]);for(let r=t+n;r<e;r+=n)i.add(r);return[...i].sort((r,o)=>r-o)}function _h(t,e){if(n1(t),!Number.isFinite(e))throw new Error("ballFlightPoint: time must be finite");const n=Math.max(0,Math.min(1,(e-t.start)/(t.end-t.start))),s=4*n*(1-n),i=t.to[0]-t.from[0],r=t.to[2]-t.from[2],o=Math.hypot(i,r)||1;return[t.from[0]+i*n-r/o*(t.curve??0)*s,t.from[1]+(t.to[1]-t.from[1])*n+(t.arc??0)*s,t.from[2]+r*n+i/o*(t.curve??0)*s]}function n1(t){if(!t.target?.trim())throw new Error("ballFlight: target is required");if(De(t.from,"ballFlight.from"),De(t.to,"ballFlight.to"),!Number.isFinite(t.start)||!Number.isFinite(t.end)||t.start<0||t.end<=t.start)throw new Error("ballFlight: end must be greater than start, both finite and nonnegative");if(!Number.isFinite(t.arc??0)||(t.arc??0)<0||!Number.isFinite(t.curve??0))throw new Error("ballFlight: arc must be finite and nonnegative; curve must be finite")}function x4(t){n1(t);const e=e1(t.start,t.end,t.every),n=e.map(s=>_h(t,s));return["x","y","z"].map((s,i)=>({id:`${t.id??"flight"}-${s}`,target:t.target,property:s,keyframes:e.map((r,o)=>({time:r,value:n[o][i]}))}))}const Yi=Object.freeze({"front-foot":Object.freeze({name:"Front-foot review",summary:"A fixed side view of the landing front foot and bowler’s popping crease at release."}),"striker-crease":Object.freeze({name:"Striker crease",summary:"A fixed side view of the striker’s popping crease, wicket and keeper arrival."}),"bowler-crease":Object.freeze({name:"Bowler crease",summary:"A fixed side view of the other crease and wicket for a running batter and return throw."})});function Hh(t){return Object.prototype.hasOwnProperty.call(Yi,t)}function Ko(t,e){if(!Hh(e))return;const n=i=>t.events.find(r=>r.id===i),s=e==="front-foot"?n("release"):e==="bowler-crease"?t.action==="run-out"?n("wicket"):n("run")??n("release"):(t.action!=="run-out"?n("wicket"):void 0)??n("run")??n("keeper")??n("return")??t.events.find(i=>i.kind==="contact");if(s){if(!Number.isFinite(s.time)||s.time<0||s.time>t.duration)throw new Error("cricketCameraReview: event time must be within the clip");return{...s}}}function Xo(t,e,n){const s=Oh(t.scene,e),i=Qy(s);for(const r of t.timeline.tracks){if(r.target!==t.scene.id+"/"+e)continue;if(!("keyframes"in r))throw new Error("cricketCamera: review requires baked actor tracks");const o=new Xe(r).getValueAtTime(n);if(typeof o!="number"||!Number.isFinite(o))continue;const a=["x","y","z"].indexOf(r.property);a>=0?i.position[a]=o:i.pose[r.property]=o}return{actor:s,sample:i}}function s1(t){const e=Ko(t,"front-foot");if(!e)throw new Error("cricketCamera: front-foot view requires a release event");const{actor:n,sample:s}=Xo(t,"bowler",e.time);return{point:Hs(n,s,"leg.right",2),height:n.who.height}}function i1(t,e){const n=e==="striker-crease"?"striker":"bowler",s=t.landmarks[n+"-crease"];return De(s,"cricketCamera.crease"),[...s]}function T4(t,e){if(!Hh(e))return[];const n=i1(t,e),s=e==="front-foot"?s1(t).point[0]:0;return[{id:"decision-review-"+e,name:Yi[e].name+": crease reference",kind:"line",color:"#f4b83f",width:.035,points:[[s-1.1,.045,n[2]],[s+1.1,.045,n[2]]]}]}function Rh(t,e,n,s){const i=e*Math.PI/180,r=n*Math.PI/180;return[t[0]+s*Math.cos(r)*Math.sin(i),t[1]+s*Math.sin(r),t[2]+s*Math.cos(r)*Math.cos(i)]}const Lh=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n,t[2]+(e[2]-t[2])*n];function E4(t,e,n){const s={target:[0,0,0],yaw:0,pitch:15,distance:8,...t},i={...s,...e},r=Lh(s.target,i.target,n),o=s.position||i.position?Lh(s.position??Rh(s.target,s.yaw,s.pitch,s.distance),i.position??Rh(i.target,i.yaw,i.pitch,i.distance),n):Rh(r,s.yaw+(i.yaw-s.yaw)*n,s.pitch+(i.pitch-s.pitch)*n,s.distance+(i.distance-s.distance)*n),a=Lh(s.lookAt??s.target,i.lookAt??i.target,n),l=s.fov!==void 0||i.fov!==void 0?(s.fov??i.fov)+((i.fov??s.fov)-(s.fov??i.fov))*n:void 0;return{position:o,lookAt:a,fov:l}}function A4(t){const e=Math.max(1,t.every??33),n=Wt(t.easing??"ease-in-out"),s=`${t.scene}/${t.camera}`,i=[],r=[],o=[];for(let l=t.start;;l=Math.min(t.end,l+e)){const c=t.end>t.start?n((l-t.start)/(t.end-t.start)):1,h=E4(t.from,t.to,c);if(i.push({time:l,value:h.position}),r.push({time:l,value:h.lookAt}),h.fov!==void 0&&o.push({time:l,value:h.fov}),l>=t.end)break}const a=[{id:`${s}-move-position`,target:s,property:"position",keyframes:i},{id:`${s}-move-lookAt`,target:s,property:"lookAt",keyframes:r}];return o.length>0&&a.push({id:`${s}-move-fov`,target:s,property:"fov",keyframes:o}),a}function P4(t){const e=Math.max(1,t.every??33),n=t.offset??[0,2,6],s=t.lag??0,i=`${t.scene}/${t.camera}`,r=[],o=[];for(let a=t.start;;a=Math.min(t.end,a+e)){const l=t.subjectAt(a),c=t.subjectAt(Math.max(t.start,a-s));if(r.push({time:a,value:[c[0]+n[0],c[1]+n[1],c[2]+n[2]]}),o.push({time:a,value:l}),a>=t.end)break}return[{id:`${i}-follow-position`,target:i,property:"position",keyframes:r},{id:`${i}-follow-lookAt`,target:i,property:"lookAt",keyframes:o}]}const Go=Object.freeze({pitch:"Whole pitch",batter:"Batter close-up",bowler:"Bowler close-up",keeper:"Keeper close-up",field:"Whole ground",overhead:"Overhead ground",orbit:"360° ground orbit","follow-ball":"Follow the ball",...Object.fromEntries(Object.entries(Yi).map(([t,e])=>[t,e.name]))}),Uo=Object.freeze({pitch:75,batter:145,bowler:35,keeper:145,field:75,overhead:75,orbit:75,"follow-ball":75,"front-foot":90,"striker-crease":90,"bowler-crease":90});function r1(t,e="pitch"){const n=ge(Go,e,"cricketCamera.view");if(Hh(n)){const i=i1(t,n);if(n==="front-foot"){const c=s1(t);return{target:[c.point[0],.12,(c.point[2]+i[2])/2],pitch:25,distance:Math.max(2.2,2.6*c.height/1.78),fov:40}}const r=t.landmarks[n==="striker-crease"?"striker-wicket":"bowler-wicket"];De(r,"cricketCamera.wicket");let o=(i[2]+r[2])/2,a=4;if(t.action==="run-out"&&n==="bowler-crease"||t.action==="running"){const c=Ko(t,n);if(c){const u=Xo(t,n==="bowler-crease"?"batter":"non-striker",c.time).sample.position;o=(Math.min(i[2],r[2],u[2])+Math.max(i[2],r[2],u[2]))/2,a=Math.max(4,Math.abs(r[2]-u[2])*1.8)}}let l=0;if(n==="striker-crease"&&t.action==="wide"){const c=Ko(t,n);if(c){const h=Xo(t,"keeper",c.time).sample.position,u=Xo(t,"batter",c.time).sample.position,d=Math.min(i[0],r[0],h[0],u[0]),f=Math.max(i[0],r[0],h[0],u[0]),p=Math.min(i[2],r[2],h[2],u[2]),g=Math.max(i[2],r[2],h[2],u[2]);l=(d+f)/2,o=(p+g)/2,a=Math.max(4,Math.hypot(f-d,g-p)*1.8)}}return{target:[l,.42,o],pitch:12,distance:a,fov:44}}if(n==="follow-ball"){const i=t.scene.objects.find(r=>r.id==="camera"&&r.kind==="camera");return{pitch:Math.atan2(3,Math.hypot(5,6))*180/Math.PI,distance:Math.sqrt(70),fov:i?.kind==="camera"&&i.projection==="perspective"?i.fov:48}}const s=n==="field"||n==="overhead"||n==="orbit";return{target:n==="batter"?[.1,.85,9.3]:n==="bowler"?[.68,1,-9.55]:n==="keeper"?[0,.7,10.1]:[0,.65,0],distance:s?t.boundaryRadius*2.8:n==="pitch"?29:4.3,pitch:n==="overhead"?89:s?52:n==="pitch"?16:12,fov:s?48:n==="pitch"?50:46}}function Fh(t,e,n,s){if(t!==void 0&&(!Number.isFinite(t)||t<e||t>n))throw new Error("cricketCamera: "+s+" must be between "+e+" and "+n)}function $4(t,e={}){const n=ge(Go,e.view??"pitch","cricketCamera.view"),s=e.yaw??Uo[n];if(!Number.isFinite(s))throw new Error("cricketCamera: yaw must be finite");const i=(s%360+360)%360,r=e.zoom??1;if(!Number.isFinite(r)||r<.25||r>4)throw new Error("cricketCamera: zoom must be between 0.25 and 4");const o=g=>r===1?g:Math.atan(Math.tan(g*Math.PI/360)/r)*360/Math.PI,a=e.every??40;if(!Number.isFinite(a)||a<16||a>1e3)throw new Error("cricketCamera: every must be between 16 and 1000 ms");if(Fh(e.pitch,0,89,"pitch"),Fh(e.distance,.5,2e3,"distance"),Fh(e.fov,10,100,"fov"),e.target!==void 0&&(De(e.target,"cricketCamera.target"),n==="follow-ball"))throw new Error("cricketCamera: target override is not supported by follow-ball");const l=r1(t,n),c=e.pitch??l.pitch,h=e.distance??l.distance,u=o(e.fov??l.fov),d=e.target?[...e.target]:l.target??[0,0,0],f=t.scene.id+"/camera",p=g=>{if(e.distance===void 0&&e.target===void 0)return g;const m=g.find(k=>k.property==="position");if(!m||!("keyframes"in m))return g;const y=t.scene.objects.find(k=>k.id==="camera"&&k.kind==="camera");let v=y?.kind==="camera"?Math.max(600,y.far):600;for(const k of m.keyframes)v=Math.max(v,Math.hypot(...k.value)+t.boundaryRadius+10);if(!Number.isFinite(v))throw new Error("cricketCamera: framing exceeds finite camera range");return[...g,{id:f+"-framing-far",target:f,property:"far",keyframes:[{time:0,value:v},{time:t.duration,value:v}]}]};if(n==="follow-ball"){const g=["x","y","z"].map(w=>{const T=t.timeline.tracks.find(S=>S.target===t.scene.id+"/ball"&&S.property===w);if(!T||!("keyframes"in T)||!T.keyframes.length)throw new Error("cricketCamera: missing ball "+w+" keyframes");const A=T.keyframes;let M=0,x=new Xe({...T,keyframes:A.slice(0,2)});return S=>{const E=M;for(;M<A.length-2&&S-(T.delay??0)>A[M+1].time;)M++;return M!==E&&(x=new Xe({...T,keyframes:A.slice(M,M+2)})),x.getValueAtTime(S)}}),m=(Math.atan2(5,6)*180/Math.PI+i-Uo["follow-ball"])*Math.PI/180,y=c*Math.PI/180,v=i===Uo["follow-ball"]&&(e.pitch===void 0||e.pitch===l.pitch)&&(e.distance===void 0||e.distance===l.distance)?[5,3,6]:[Math.sin(m)*Math.cos(y)*h,Math.sin(y)*h,Math.cos(m)*Math.cos(y)*h],k=P4({scene:t.scene.id,camera:"camera",start:0,end:t.duration,every:a,offset:v,subjectAt:w=>g.map(T=>T(w))});return p([...k,{id:f+"-zoom-fov",target:f,property:"fov",keyframes:[{time:0,value:u},{time:t.duration,value:u}]}])}return p(A4({scene:t.scene.id,camera:"camera",start:0,end:t.duration,every:a,easing:"linear",from:{target:d,yaw:i,pitch:c,distance:h,fov:u},to:{yaw:n==="orbit"?i+360:i}}))}const Vo=Object.freeze({mcc:Object.freeze({name:"MCC",poppingCreaseHalfWidth:1.83,fieldingRadius:null,summary:"MCC minimum crease markings. The base Laws do not prescribe a limited-over restriction area."}),"icc-men":Object.freeze({name:"ICC men",poppingCreaseHalfWidth:7.5,fieldingRadius:27.43,summary:"ICC men: extended crease markings; ODI/T20 restriction-area arcs have a 27.43 m radius."}),"icc-women":Object.freeze({name:"ICC women",poppingCreaseHalfWidth:7.5,fieldingRadius:23,summary:"ICC women: extended crease markings; ODI/T20 restriction-area arcs have a 23 m radius."})});function I4(t){const[e,n]=t.centres,s=Math.hypot(n[0]-e[0],n[2]-e[2]),i=(n[0]-e[0])/s,r=(n[2]-e[2])/s,o=[];for(let a=0;a<2;a++){const l=a===0?n:e;for(let c=0;c<=64;c++){const h=(a+c/64)*Math.PI,u=Math.cos(h)*t.radius,d=Math.sin(h)*t.radius;o.push([l[0]+r*u+i*d,.018,l[2]-i*u+r*d])}}return o}function o1(t,e){De(e,"cricketFieldingAreaContains.point");const n=t.fieldingArea;if(n==null)return null;if(!Number.isFinite(n.radius)||n.radius<=0)throw new Error("cricketFieldingAreaContains: radius must be positive and finite");if(!Array.isArray(n.centres)||n.centres.length!==2)throw new Error("cricketFieldingAreaContains: two centres are required");const[s,i]=n.centres;De(s,"cricketFieldingAreaContains.centre"),De(i,"cricketFieldingAreaContains.centre");const r=i[0]-s[0],o=i[2]-s[2],a=r*r+o*o,l=a?Math.max(0,Math.min(1,((e[0]-s[0])*r+(e[2]-s[2])*o)/a)):0;return Math.hypot(e[0]-s[0]-l*r,e[2]-s[2]-l*o)<=n.radius+1e-9}function a1(t){return Object.keys(Cs).flatMap(e=>{const n=t.scene.objects.find(i=>i.id===e&&i.kind==="character");if(!n)return[];if(n.parent)throw new Error(`cricketFieldingPositions: '${e}' must be unparented for setup markers`);const s=[...n.position??[0,0,0]];return[{id:e,name:n.name??Cs[e],position:s,inside:o1(t,s)}]})}function O4(t){return t.fieldingArea?a1(t).map(e=>({id:`fielding-review-${e.id}`,name:`${e.name}: ${e.inside?"inside":"outside"} restriction area`,kind:"line",closed:!0,width:.12,color:e.inside?"#d8eb8a":"#ee9670",points:Array.from({length:32},(n,s)=>[e.position[0]+Math.cos(s*Math.PI/16)*.7,.06,e.position[2]+Math.sin(s*Math.PI/16)*.7])})):[]}const Yt=Object.freeze({length:20.12,width:3.05,poppingCrease:1.22,returnCrease:1.32,stumpHeight:.711,wicketWidth:.2286});function l1(t){if(!t.id?.trim())throw new Error("cricketPlayer: id is required");ge({batter:1,bowler:1,keeper:1,fielder:1,umpire:1},t.role,"cricketPlayer.role");const e=ge(Li,t.preset??"youngMan","cricketPlayer.preset"),n=ge(We,t.format??"t20","cricketPlayer.format"),s=ge({none:1,cap:1,"sun-hat":1},t.headwear??"none","cricketPlayer.headwear"),i=e==="childBoy"||e==="childGirl",r=t.height??(i?1.24:1.78);if(!Number.isFinite(r)||r<.5||r>3)throw new Error("cricketPlayer: height must be between .5 and 3 metres");De(t.position??[0,0,0],"cricketPlayer.position");const o=t.role==="umpire"?"#f5ebd5":n==="test"?"#f5f0df":t.color??"#3577b5",a=JSON.parse(JSON.stringify({...Li[e],...t.appearance,outfit:rm("casual",{top:"shirt",shirt:o,trousers:t.role==="umpire"?"#405058":o,bottom:"trousers",trouserStyle:"plain",sleeves:"short",collar:!0,tie:null,shoes:"boots",shoeColor:"#f3ead7"}),hat:s==="none"?null:{style:s==="sun-hat"?"sunHat":"cap",color:o}}));return{id:t.id,name:t.role,kind:"character",look:"pen",height:r,position:[...t.position??[0,0,0]],character:a,pose:t.role==="batter"?Zy():{turn:t.role==="keeper"?2:0}}}function Jo(t,e,n,s,i=0){return{id:t,kind:"mesh",position:e,geometry:{type:"box",size:n},material:s,layer:i}}function C4(t,e){const n=Yt.stumpHeight,s=(Yt.wicketWidth-.036)/2;return[...[-1,0,1].map((i,r)=>({id:`${t}-stump-${r}`,kind:"mesh",position:[i*s,n/2,e],geometry:{type:"cylinder",radius:.018,height:n,segments:10},material:"wicket"})),...[-1,1].map((i,r)=>Jo(`${t}-bail-${r}`,[i*s/2,n+.015,e],[.105,.025,.035],"bail"))]}function c1(t,e){return[{id:t,kind:"group",scale:e,visible:!1},Jo(`${t}-grip`,[0,.1,0],[.036,.28,.036],"bat-grip"),Jo(`${t}-blade`,[0,.51,0],[.108,.54,.055],"bat-blade"),Jo(`${t}-label`,[0,.41,.029],[.07,.16,.004],"bat-label")].map((s,i)=>i===0?s:{...s,parent:t})}function Nh(t={}){const e=ge(We,t.format??"t20","cricketField.format"),n=ge(Ph,t.cast??"adults","cricketField.cast"),s=ge(Vo,t.markingProfile??"icc-men","cricketField.markingProfile"),i=Vo[s],r=t.boundaryRadius??64;if(!Number.isFinite(r)||r<24||r>250)throw new Error("cricketField: boundaryRadius must be between 24 and 250 metres");const o=t.id??"cricket";if(!o.trim())throw new Error("cricketField: id is required");const a=Yt.length/2,l=e!=="test"&&i.fieldingRadius!==null?{radius:i.fieldingRadius,centres:[[0,0,-a],[0,0,a]]}:null,c={"striker-wicket":[0,0,a],"bowler-wicket":[0,0,-a],"striker-crease":[0,0,a-Yt.poppingCrease],"bowler-crease":[0,0,-a+Yt.poppingCrease]},h=[{id:"camera",kind:"camera",projection:"perspective",position:[25,9,6],lookAt:[0,.65,0],fov:48,near:.02,far:Math.max(600,r*4)},{id:"sun",kind:"light",light:"directional",position:[4,8,5],intensity:.8,color:"#fff2dd"},{id:"ambient",kind:"light",light:"ambient",intensity:.85,color:"#eaf6f4"},{id:"outfield",kind:"mesh",layer:-4,position:[0,-.04,0],geometry:{type:"cylinder",radius:r+1,height:.06,segments:80},material:"grass"},{id:"square",kind:"mesh",layer:-3,geometry:{type:"plane",size:[8,25]},position:[0,.003,0],material:"square"},{id:"pitch",kind:"mesh",layer:-2,geometry:{type:"plane",size:[Yt.width,Yt.length]},position:[0,.008,0],material:"pitch"},{id:"boundary",kind:"line",layer:-1,closed:!0,width:.15,color:"#f8f2db",points:Array.from({length:96},(p,g)=>[Math.cos(g*Math.PI/48)*r,.022,Math.sin(g*Math.PI/48)*r])}];l&&h.push({id:"fielding-circle",kind:"line",layer:-1,closed:!0,width:.06,color:"#d6e4c8",points:I4(l)});for(const p of[-1,1]){const g=p>0?"striker":"bowler",m=p*a,y=m-p*Yt.poppingCrease;h.push(...C4(g,m));const v=(k,w)=>h.push({id:`${g}-${k}`,kind:"line",layer:-1,color:"#fffdf0",width:.045,points:w});v("popping-line",[[-i.poppingCreaseHalfWidth,.02,y],[i.poppingCreaseHalfWidth,.02,y]]),v("bowling-line",[[-1.32,.02,m],[1.32,.02,m]]);for(const k of[-1,1])v(`return-line-${k<0?"left":"right"}`,[[k*1.32,.02,y],[k*1.32,.02,m+p*2.5]])}const u=[["batter","batter",[-.38,0,9.3]],["non-striker","batter",[-.85,0,-9.3]],["bowler","bowler",[.68,0,-17]],["keeper","keeper",[0,0,11.25]],["fielder","fielder",[12,0,-3]],["slip","fielder",[3.5,0,12]],["point","fielder",[20,0,6]],["cover","fielder",[22,0,-16]],["mid-off","fielder",[9,0,-25]],["mid-on","fielder",[-9,0,-25]],["square-leg","fielder",[-20,0,7]],["fine-leg","fielder",[-20,0,35]],["third-man","fielder",[23,0,35]],["umpire","umpire",[0,0,-12.4]],["square-umpire","umpire",[-15,0,8.84]]];u.forEach(([p,g,m],y)=>{const v=n==="children"||n==="mixed"&&y%3===0,k=n==="men"?"youngMan":v?y%2?"childGirl":"childBoy":y%2?"youngWoman":"youngMan",w=Math.hypot(m[0],m[2]),T=w>r*.88?[m[0]*r*.88/w,0,m[2]*r*.88/w]:[...m];c[p]=[...T];const A=l1({id:p,role:g,preset:k,format:e,position:T,color:g==="batter"?t.battingColor??"#397cb9":t.fieldingColor??"#bf604e"});if(Object.hasOwn(Cs,p)&&(A.name=Cs[p]),p!=="batter"){const M=p==="non-striker"||p==="bowler"?u[0][2]:u.find(([x])=>x==="bowler")[2];A.pose={turn:_s(T,M)}}h.push(A)});const d=p=>h.find(g=>g.id===p).height/1.78;h.push(...c1("bat",d("batter")),...c1("non-striker-bat",d("non-striker"))),h.push({id:"ball",kind:"mesh",position:[0,.075,0],geometry:{type:"sphere",radius:.075,segments:12},material:"ball"}),h.push({id:"lbw-guide",kind:"group",visible:!1},{id:"lbw-projection",kind:"line",parent:"lbw-guide",points:[[0,0,0],[0,1,0]],width:.04,color:"#e9ae38"});const f=p=>({color:p,shading:"toon",outline:{color:"#69513a",width:.8}});return{format:e,boundaryRadius:r,landmarks:c,markingProfile:s,fieldingArea:l,scene:{id:o,formatVersion:1,camera:"camera",background:{top:"#c8e5ef",bottom:"#e9efcc"},ground:0,objects:h,materials:{grass:{color:"#81a95c",shading:"unlit"},square:{color:"#a6b76a",shading:"unlit",doubleSided:!0},pitch:{color:"#ddbd85",shading:"unlit",doubleSided:!0},wicket:f("#edd99e"),bail:f("#bd8c4d"),"bat-grip":f("#385b5c"),"bat-blade":f("#e8c58d"),"bat-label":f("#c34d4c"),ball:{color:e==="test"?"#b32d36":"#fff9e7",shading:"toon",outline:{color:"#9b3840",width:1}}}}}}const Kt=1900,Ki=2450,Et=2900,Xi=4100,fn=4200,Rs=4600,Zo=5300,Wh=5500;function Qo(t,e,n,s,i,r,o=t.object.pose?.turn??0){const a=_t(e,n,s),l=Zs(i,r),c=_s(i,r,o),h=o+(c-o)*Ft(_t(e,n,n+200)),u={...lt,...t.object.pose,turn:h},d=so("run",t.who.height,1,t.object.character?.legLength??1),f=no("run",l*a/d,u),p=Math.min(a*12,(1-a)*12,1);return{position:bn(i,r,a),pose:Yo(u,f,Math.max(0,p))}}function Dh(t,e,n){const s=(t.pose.turn??0)*Math.PI/2;return Tt(t.position,[Math.sin(s)*e,n,Math.cos(s)*e])}function _4(t,e,n,s,i){const r=`${e}/${n.object.id}`,o={...lt,...n.object.pose},a=new Set(i.flatMap(l=>Object.keys(l.pose)));for(const l of a){const c=o[l]??0;i.some(h=>h.pose[l]!==c)&&t.push({id:`${n.object.id}-${l}`,target:r,property:l,keyframes:s.map((h,u)=>({time:h,value:i[u].pose[l]??c}))})}for(const[l,c]of["x","y","z"].entries())i.some(h=>h.position[l]!==(n.object.position?.[l]??0))&&t.push({id:`${n.object.id}-${c}`,target:r,property:c,keyframes:s.map((h,u)=>({time:h,value:i[u].position[l]}))});if(i[0].bat){const l=n.object.id==="batter"?"bat":"non-striker-bat",c=`${e}/${l}`;t.push({id:`${l}-visible`,target:c,property:"visible",keyframes:[{time:0,value:1}]}),t.push({id:`${l}-position`,target:c,property:"position",keyframes:s.map((h,u)=>({time:h,value:[...i[u].bat.grip]}))}),t.push({id:`${l}-rotation`,target:c,property:"quaternion",interpolation:"slerp",keyframes:s.map((h,u)=>({time:h,value:t1(i[u].bat.axis)}))})}}function H4(t,e){const n={runs:0,extras:0,wickets:0,legalBall:!0,freeHitNext:!1};t==="running"&&(n.runs=1),t==="four"&&(n.runs=4),t==="six"&&(n.runs=6),(t==="wide"||t==="no-ball")&&(n.extras=1,n.legalBall=!1),t==="no-ball"&&(n.freeHitNext=We[e].freeHitAfterNoBall);const i={catch:"caught",bowled:"bowled",lbw:"lbw",stumping:"stumped","run-out":"run-out"}[t];return i&&(n.wickets=1,n.dismissal=i),n}function h1(t,e={}){return u1(t,e)}function u1(t,e,n){const s=ge(Wn,e.action??"bowling","cricketAction.action"),i=n?n.delivery.legality==="no-ball":s==="no-ball",r=n?n.delivery.legality==="wide":s==="wide",o=n?n.delivery.style==="spin":s==="spin";ge(We,t.format,"cricketAction.format");const a=n?.result??H4(s,t.format),l=e.duration??6e3;if(!Number.isFinite(l)||l<4e3||l>6e4)throw new Error("cricketAction: duration must be between 4000 and 60000 ms");const c=t.scene.id;for(const $ of["ball","bat","non-striker-bat","lbw-guide","striker-bail-0","striker-bail-1","bowler-bail-0","bowler-bail-1"])if(!t.scene.objects.some(C=>C.id===$))throw new Error(`cricketAction: required equipment '${$}' is missing`);const h=Object.fromEntries(["batter","non-striker","bowler","keeper","fielder","umpire"].map($=>[$,Oh(t.scene,$)]));for(const $ of["slip","point","cover","mid-off","mid-on","square-leg","fine-leg","third-man","square-umpire"])t.scene.objects.some(C=>C.id===$&&C.kind==="character")&&(h[$]=Oh(t.scene,$));const u=$=>h[$].who.height,d=$=>Qy(h[$]),f=$=>Math.round($*6e3/l*1e9)/1e9,p=$=>$*l/6e3,g=["batting","defend","running","four","six","catch","fielding","throw","run-out"].includes(s),m=["bowling","spin","no-ball","stumping"].includes(s),y=["catch","fielding","throw","run-out","batting","running"].includes(s),v=s==="running"||s==="run-out",k=new Map,w=[d("bowler").position[0],0,i?-8.25:-9.55],T=s==="fielding"?[10.5,0,2]:[9,0,-1],A=d("fielder").position,M=($,C)=>{let z=k.get($);z||(z=new Map,k.set($,z));const X=z.get(C);if(X)return X;const N=h[$];let F=d($);if($==="bowler"){const D=F.position;if(C<1400){const G=Tt(w,[0,0,-.65]);F=Qo(N,C,0,1400,D,G),F.pose["arm.right.swing"]=45,F.pose["arm.right.elbow"]=80}else F.position=C<=Kt?bn(Tt(w,[0,0,-.65]),w,Ft(_t(C,1400,Kt))):Tt(w,[0,0,.8*Ft(_t(C,Kt,2600))]),F.pose=Ch(C,[[1400,{turn:0,"arm.right.swing":285,"arm.right.elbow":8,"arm.left.swing":115,"leg.right.swing":15,"leg.left.knee":45}],[1800,{turn:0,"arm.right.swing":180,"arm.right.elbow":0,"arm.left.swing":80,"leg.right.swing":25,"leg.right.knee":0,"leg.left.swing":-25,"leg.left.knee":60}],[Kt,{turn:0,lean:8,"arm.right.swing":155,"arm.right.elbow":0,"arm.left.swing":45,"leg.right.swing":25,"leg.right.knee":0,"leg.left.swing":-25,"leg.left.knee":60}],[2250,{turn:0,lean:26,bend:12,"arm.right.swing":40,"arm.right.elbow":0,"arm.left.swing":-35,"leg.left.swing":-35,"leg.left.knee":55}],[3e3,{turn:0,"head.turn":10}],[6e3,{turn:0,"head.turn":10}]]);o&&(F.pose={...F.pose,"arm.right.spread":18,"head.tilt":-5});for(const[G,q]of Object.entries(C<Kt?St.hold:St.open))F.pose[`hand.right.${G}`]=q}else if($==="batter"||$==="non-striker"){const D=u($);if(s==="lbw"&&$==="batter"&&(F.position[0]=0),s==="stumping"&&$==="batter"&&(F.position[2]-=1.1*Ft(_t(C,2150,2800))),v&&C>3050){const G=M($,3050),q=$==="batter"?[1,0,-9.5]:[-1,0,9.5];F=Qo(N,C,3050,s==="run-out"?6e3:Wh,G.position,q,G.pose.turn);const tt=ji(N,F,"right");F.bat={grip:tt,axis:Jt([.7,-.35,.5]),scale:D/1.78}}else{F.pose={...F.pose,...$==="batter"?Zy():{turn:.15,"leg.left.knee":8,"leg.right.knee":8}};let q=[0,-1,$==="batter"?.05:.12],Z=Tt(F.position,[D*.15,D*.44,D*.04]);if($==="non-striker"&&(Z=Tt(F.position,[D*.08,D*.44,D*.17])),$==="batter"){const tt=Ft(_t(C,2100,2600))*(1-Ft(_t(C,2600,Et))),R=Ft(_t(C,2600,Et))*(1-Ft(_t(C,Et,3800))),U=Ft(_t(C,Et,3250))*(1-Ft(_t(C,3250,4e3)));if(g){Z=Tt(F.position,[D*(.15+.03*tt-.02*R-.03*U),D*(.44+.14*tt+.07*R+.23*U),D*(.04+.16*tt-.12*R-.06*U)]),q=Jt([.15*tt+.25*U,-1+1.85*tt+1.6*U,.05+.55*tt-.4*R-.8*U]),F.pose.turn=1+.12*R+.3*U,F.pose.lean=3+4*R;const nt=12+4*R;F.pose["leg.left.spread"]=nt,F.pose["leg.right.spread"]=nt,s==="defend"&&(q=[0,-1,-.08],Z=Tt(F.position,[D*.1,D*.5,-D*.12]))}else if(["stumping","bowled","lbw"].includes(s)){const nt=Ft(_t(C,2100,2700))*(1-Ft(_t(C,4e3,4500)));q=Jt([.15*nt,-1+1.85*nt,.05+.55*nt]),Z=Tt(F.position,[D*(.15+.03*nt),D*(.44+.14*nt),D*(.04+.16*nt)])}}F=M4(N,F,Z,q)}}else if($==="keeper"){F.pose={...F.pose,turn:_s(F.position,d("bowler").position,2),lean:20,"leg.left.swing":22,"leg.right.swing":22,"leg.left.knee":50,"leg.right.knee":50},r&&(F.position[0]=2.15*Ft(_t(C,2900,3500))),s==="stumping"&&(F.position[2]-=.85*Ft(_t(C,3400,3900)));const D=Dh(F,u($)*.27,u($)*.44);if(s==="stumping"&&C>=3500){const G=Dh({...F,position:d($).position},u($)*.27,u($)*.44),q=[0,Yt.stumpHeight,Yt.length/2],Z=bn(G,q,Ft(_t(C,3500,3900)));F=dn(N,F,"right",Z),F=dn(N,F,"left",Tt(Z,[.045,0,0]))}else F=dn(N,F,"right",D),F=dn(N,F,"left",Tt(D,[.045,0,0]))}else if($==="fielder"&&y){if(F=Qo(N,C,3050,s==="catch"?3800:3950,A,T),C>=3800){const D={...lt,turn:_s(T,d("batter").position,F.pose.turn),lean:s==="catch"?5:42,bend:s==="catch"?0:18,"leg.left.swing":s==="catch"?0:45,"leg.right.swing":s==="catch"?0:45,"leg.left.knee":s==="catch"?0:85,"leg.right.knee":s==="catch"?0:85,smile:.7};F.pose=Yo(F.pose,D,Ft(_t(C,3800,fn)));const G=Dh(F,u($)*.22,u($)*(s==="catch"?.73:.2));if(F=dn(N,F,"right",G),F=dn(N,F,"left",Tt(G,[.035,0,0])),(s==="throw"||s==="run-out")&&C>fn){const q={...lt,turn:_s(T,s==="throw"?d("keeper").position:t.landmarks["bowler-wicket"],F.pose.turn),"arm.right.swing":225,"arm.right.elbow":60,"arm.left.spread":70,"leg.left.swing":15},Z={...q,"arm.right.swing":110,"arm.right.elbow":0,lean:15};F.pose=Ch(C,[[fn,F.pose],[4450,q],[Rs,Z],[4900,{...lt,turn:q.turn,"arm.right.swing":25,lean:22}],[6e3,{...lt,turn:q.turn}]])}}}else if($==="umpire"){let D={...lt};const G=s==="stumping"?4150:s==="run-out"?5150:s==="bowled"||s==="lbw"?3500:s==="catch"?4350:5100;if(s==="no-ball")D={...D,"arm.right.spread":90,"arm.right.elbow":0};else if(s==="wide")D={...D,"arm.right.spread":90,"arm.left.spread":90,"arm.right.elbow":0,"arm.left.elbow":0};else if(s==="six")D={...D,"arm.right.spread":180,"arm.left.spread":180,"arm.right.elbow":0,"arm.left.elbow":0};else if(s==="four")D={...D,"arm.right.spread":90-70*(.5+Math.sin((C-5100)/180)*.5),"arm.right.elbow":12};else if(["catch","bowled","lbw","stumping","run-out"].includes(s)){D={...D,"arm.right.swing":165,"arm.right.elbow":0};for(const[q,Z]of Object.entries(St.point))D[`hand.right.${q}`]=Z}if(n){const q={...lt},Z=[[0,q]];let tt=q;if(i||r){const R=i?Kt:3100;tt=i?{...q,"arm.right.spread":90,"arm.right.elbow":0}:{...q,"arm.right.spread":90,"arm.left.spread":90,"arm.right.elbow":0,"arm.left.elbow":0},Z.push([R,q],[R+350,tt])}if(a.wickets||s==="four"||s==="six"){const R=a.wickets?G:5100;let U=D;if(a.wickets){U={...q,"arm.right.swing":165,"arm.right.elbow":0};for(const[nt,at]of Object.entries(St.point))U[`hand.right.${nt}`]=at}Z.push([R,tt],[R+350,U])}F.pose=Ch(C,Z)}else F.pose=Yo(F.pose,D,Ft(_t(C,s==="no-ball"?Kt:s==="wide"?3100:G,(s==="no-ball"?Kt:s==="wide"?3100:G)+350)))}return z.set(C,F),F},x=($,C)=>ji(h[$],M($,C),"right"),S=g?S4(M("batter",Et).bat):s==="lbw"?bn(Hs(h.batter,M("batter",Et),"leg.right",1),Hs(h.batter,M("batter",Et),"leg.right",2),.6):[m?Yt.wicketWidth/2+.075+.15:0,.45,9.25],E=x("bowler",Kt),P=[r?.85:o?-.35:s==="lbw"?S[0]*.6:0,.075,3.9],I=x("keeper",s==="stumping"?3400:3500),O=x("fielder",Xi),H=x("fielder",fn),W=s==="run-out"?"bowler":"striker",j=s==="run-out"?5e3:s==="stumping"?3900:3200,J=[t.boundaryRadius*.8,s==="six"?2.1:.075,-t.boundaryRadius*.6],et=($,C,z,X,N,F=0,D=0)=>_h({target:`${c}/ball`,start:C,end:z,from:X,to:N,arc:F,curve:D},$),V=$=>{if($<=Kt)return x("bowler",$);if($<=Ki)return et($,Kt,Ki,E,P,.15,o?.35:0);const C=r?Tt(I,[0,0,-.6]):S;if($<=Et)return et($,Ki,Et,P,C,.08);if(s==="bowled"){const X=[0,.36,Yt.length/2];return $<=j?et($,Et,j,S,X):et($,j,4100,X,[0,.075,12.5],.2)}if(s==="lbw")return[...S];if(["bowling","spin","no-ball","wide","stumping"].includes(s)){const X=s==="stumping"?3400:3500;if(m&&$<=X){const N=[C[0],I[1],Yt.length/2+.2];return $<=3200?et($,Et,3200,C,N,.04):et($,3200,X,N,I,.04)}return $<=X?et($,Et,X,C,I,.04):x("keeper",$)}if(s==="defend")return et($,Et,3400,S,Tt(S,[-.5,-S[1]+.075,-.7]),.12);if(s==="four"||s==="six"){if(s==="six")return $<=5e3?et($,Et,5e3,S,J,12):et($,5e3,5700,J,Tt(J,[2,-2.025,-1.5]));const X=[5,.075,5];return $<=3300?et($,Et,3300,S,X,.5):et($,3300,5e3,X,J)}if(s==="catch")return $<=Xi?et($,Et,Xi,S,O,5):x("fielder",$);const z=[4,.075,5];if($<=3300)return et($,Et,3300,S,z,.8);if($<=fn)return et($,3300,fn,z,H);if(s==="throw"||s==="run-out"){if($<=Rs)return x("fielder",$);const X=x("fielder",Rs),N=s==="run-out"?[0,.42,-Yt.length/2]:x("keeper",Zo),F=s==="run-out"?j:Zo;return $<=F?et($,Rs,F,X,N,1.2):s==="run-out"?et($,F,5700,N,[0,.075,-12],.18):x("keeper",$)}return[...H]},L=[],B=($,C,z,X,N)=>L.push({id:$,time:p(C),kind:z,label:X,caption:N}),K=n?{bowled:"Delivery hits stumps",lbw:"Pad contact",stumping:"Keeper breaks wicket","run-out":"Throw breaks wicket"}[s]??Wn[s].name:Wn[s].name;if(B("setup",0,"setup",K,n?`${n.delivery.style} delivery · ${n.delivery.legality}${n.freeHit?" · free hit":""}. ${Wn[s].summary.replace("A legal delivery","A delivery")}`:Wn[s].summary),B("release",Kt,"release","Ball released",i?"The front foot has landed beyond the popping crease. No-ball.":"The bowler releases the ball; the front foot is behind the popping crease."),B("bounce",Ki,"bounce","Pitch bounce",o?"The curved flight is illustrative. Spin can change the ball’s path after it bounces.":"The delivery bounces on the pitch on its way to the striker."),g?B("contact",Et,"contact","Bat contact","The ball meets the blade. The bat is keyed from the same two hand grips."):s==="lbw"?B("pad-contact",Et,"contact","Pad contact",n?"The ball contacts the pad. The highlighted path is illustrative; the authored decision is resolved separately.":"The highlighted path illustrates a ball that would hit the stumps. This is an authored LBW example."):B("miss",Et,"contact",s==="wide"?"Beyond normal reach":"The batter misses",s==="wide"?"The untouched ball is too far away for a normal stroke. The umpire calls Wide.":"The untouched delivery passes the striker."),s==="catch"&&B("catch",Xi,"collect","Catch controlled",n?"The fielder controls the ball before it touches the ground. The authored decision is resolved separately.":"The fielder controls the ball before it touches the ground: caught."),["fielding","throw","run-out","batting","running"].includes(s)&&B("gather",fn,"collect","Ground ball gathered","The ball has touched the ground. Gathering it is fielding, not a catch dismissal."),["bowling","spin","wide","no-ball","stumping"].includes(s)&&B("keeper",s==="stumping"?3400:3500,"collect","Keeper gathers","The keeper controls the ball behind the striker’s wicket."),(s==="throw"||s==="run-out")&&B("throw",Rs,"throw","Throw released","The fielder releases the gathered ball toward the wicket."),s==="throw"&&B("return",Zo,"collect","Return received","The keeper receives and controls the return throw."),s==="stumping"&&B("wicket",j,"wicket",n?"Wicket broken":"Stumped","Holding the ball, the keeper removes a bail. The striker is out of ground and is not attempting a run."),s==="run-out"&&B("wicket",j,"wicket",n?"Wicket broken":"Run out","The direct throw removes a bail before the running batter makes this ground."),s==="bowled"&&B("wicket",j,"wicket",n?"Stumps hit":"Bowled",n?"The delivery hits the wicket and removes a bail. A broken wicket does not by itself decide a dismissal.":"The legal delivery hits the wicket and removes a bail."),(s==="four"||s==="six")&&B("boundary",5e3,"boundary",s==="four"?"Four runs":"Six runs",s==="four"?"The struck ball reaches the boundary after touching the ground: four.":"The struck ball clears the boundary without touching the ground: six."),s==="running"&&B("run",Wh,"result","One run completed","Both batters have reached the opposite ground. One run is completed."),B("result",5700,"result","Illustrated result",s==="no-ball"?`One no-ball extra; it does not count in the over.${a.freeHitNext?" The next legitimate delivery is a free hit.":" Test cricket has no automatic free hit."}`:s==="wide"?"One wide extra; the delivery does not count in the over.":s==="lbw"?"LBW is declared for this illustrated legal delivery. A full decision also checks pitching, impact and any bat contact.":`${a.runs} bat runs · ${a.extras} extras · ${a.wickets} wicket${a.wickets===1?"":"s"}.`),n){const $={"no-dismissal":"No dismissal was authored for this play.",dismissal:`The authored ${n.ruling.dismissal} decision is allowed in this delivery context.`,"no-ball":`Not out: ${s==="catch"?"a catch":"this dismissal"} cannot dismiss the striker on a no-ball.`,"free-hit":`Not out: ${s==="catch"?"a catch":"this dismissal"} cannot dismiss the striker on a free hit.`,wide:"Not out: this dismissal is not available from a Wide."},C=L.find(z=>z.id==="result");C.label=a.wickets?"Out":"Not out",C.caption=`${$[n.ruling.reason]} ${a.runs} bat runs · ${a.extras} extras · ${a.wickets} wickets. ${a.legalBall?"Counts as a legal ball.":"Does not count in the over."}${a.freeHitNext?" The next delivery is a free hit; an illegal delivery carries it forward.":n.freeHit?" This legal delivery consumes the free hit.":""}`}L.sort(($,C)=>$.time-C.time);const _=e1(0,l,e.every,[1400,1800,Kt,2100,2150,2250,Ki,2600,2800,Et,3050,3100,3200,3250,3300,3400,3500,3800,3900,3950,4e3,Xi,fn,4350,4450,Rs,4900,5e3,5100,5150,Zo,Wh,5700].map(p)),Y=_.map($=>V(f($))),st=[];for(const[$,C]of Object.entries(h)){let z=C.object.pose?.turn??0,X=z;const N=_.map((F,D)=>{const G=f(F);let q=$==="fielder"&&y&&G>3050&&G<3250?Qo(C,G,3050,s==="catch"?3800:3950,A,T,X):M($,G),Z=Y[D];const tt=!["batter","non-striker","bowler","keeper"].includes($);if(tt){const U=M("bowler",Math.min(G,Kt)),nt=Tt(U.position,[0,u("bowler")*.8,0]);Z=G<=Kt?nt:G<2100?bn(nt,Z,Ft(_t(G,Kt,2100))):Z}if(v&&($==="batter"||$==="non-striker")&&G>3050&&(Z=$==="batter"?[1,u($)*.8,-10.5]:[-1,u($)*.8,10.5]),$==="bowler"&&G<=Et&&(Z=Tt(M("batter",G).position,[0,u("batter")*.65,0])),tt&&($!=="fielder"||!y||G<=3050)||$==="bowler"&&G>=3e3){const U=_s(q.position,Z,z);z=$==="bowler"&&G<3500?(q.pose.turn??0)+(Ih(U,q.pose.turn??0)-(q.pose.turn??0))*Ft(_t(G,3e3,3500)):U,q={...q,pose:{...q.pose,turn:z}}}return $==="fielder"&&y&&(G===3050?X=z:G>3050&&(z=Ih(q.pose.turn??0,z),q={...q,pose:{...q.pose,turn:z}})),v4(C,q,Z)});_4(st,c,C,_,N)}for(const[$,C]of["x","y","z"].entries())st.push({id:`ball-${C}`,target:`${c}/ball`,property:C,keyframes:_.map((z,X)=>({time:z,value:Y[X][$]}))});if(["bowled","stumping","run-out"].includes(s))for(let $=0;$<2;$++){const C=`${W}-bail-${$}`,X=t.scene.objects.find(N=>N.id===C).position;st.push({id:`${C}-fall`,target:`${c}/${C}`,property:"position",keyframes:[{time:0,value:[...X]},{time:p(j),value:[...X]},{time:p(j+180),value:Tt(X,[$?.25:-.25,.22,W==="striker"?.22:-.22]),easing:"ease-out"},{time:p(j+650),value:[X[0]+($?.4:-.4),.035,X[2]+(W==="striker"?.45:-.45)],easing:"ease-in"}]}),st.push({id:`${C}-spin`,target:`${c}/${C}`,property:"rotateZ",keyframes:[{time:0,value:0},{time:p(j),value:0},{time:p(j+650),value:$?145:-145}]})}if(s==="lbw"){const $=[S[0]*.8,S[1],Yt.length/2],C=se($,S);st.push({id:"lbw-position",target:`${c}/lbw-guide`,property:"position",keyframes:[{time:0,value:[...S]}]},{id:"lbw-rotation",target:`${c}/lbw-guide`,property:"quaternion",interpolation:"slerp",keyframes:[{time:0,value:t1(C)}]},{id:"lbw-length",target:`${c}/lbw-guide`,property:"scaleY",keyframes:[{time:0,value:Zs(S,$)}]},{id:"lbw-visible",target:`${c}/lbw-guide`,property:"visible",keyframes:[{time:0,value:0},{time:p(Et)-.001,value:0},{time:p(Et),value:1}]})}return{action:s,duration:l,events:L,result:a,timeline:{id:`${c}-${s}`,formatVersion:2,name:K,config:{duration:l,markers:L.map($=>({id:$.id,time:$.time,label:$.label}))},captions:{en:Object.fromEntries(L.map($=>[$.id,$.caption]))},tracks:st}}}function R4(t={}){const e=Nh(t);return{...e,...h1(e,t)}}function L4(t,e){if(!Number.isFinite(e))throw new Error("cricketEventAt: time must be finite");let n;for(const s of t){if(s.time>e)break;n=s}return n}const gn=Object.freeze({deliveryStyles:Object.freeze(["pace","spin"]),deliveryLegalities:Object.freeze(["legal","no-ball","wide"]),shots:Object.freeze(["miss","drive","defend"]),finishes:Object.freeze(["none","single","four","six","stumps","pad"]),fielding:Object.freeze(["none","keeper","catch","gather","throw","stumping","run-out"]),dismissals:Object.freeze(["caught","bowled","lbw","stumped","run-out"])});function Ls(t,e,n){if(!t.includes(e))throw new Error(`cricketPlay.${n}: unknown choice '${e}'`);return e}function F4(t){const{shot:e,finish:n,fielding:s}=t;if(t.delivery.legality==="wide"){if(e!=="miss"||n!=="none"||s!=="keeper")throw new Error("cricketPlay: Wide currently supports only an untouched delivery gathered by the keeper");return"wide"}if(e==="miss"){if(s==="none"&&n==="stumps")return"bowled";if(s==="none"&&n==="pad")return"lbw";if(n==="none"&&s==="stumping")return"stumping";if(n==="none"&&s==="keeper")return t.delivery.style==="spin"?"spin":"bowling"}if(e==="defend"&&n==="none"&&s==="none")return"defend";if(e==="drive"){if(s==="none"&&(n==="four"||n==="six"))return n;if(s==="gather"&&n==="single")return"running";if(n==="none"){if(s==="catch")return"catch";if(s==="gather")return"fielding";if(s==="throw")return"throw";if(s==="run-out")return"run-out"}}throw new Error(`cricketPlay: unsupported motion combination (${e}, ${n}, ${s})`)}function N4(t){const e=Ls(gn.shots,t.shot??"miss","shot"),n=Ls(gn.finishes,t.finish??"none","finish");let s=e==="miss"?"keeper":"gather";(e==="defend"||n!=="none")&&(s=n==="single"?"gather":"none");const i=Ls(gn.fielding,t.fielding??s,"fielding"),r=t.context?.freeHit??!1;if(typeof r!="boolean")throw new Error("cricketPlay.context.freeHit must be boolean");const o=t.decision?.dismissal??null;return o!==null&&Ls(gn.dismissals,o,"decision.dismissal"),{delivery:{style:Ls(gn.deliveryStyles,t.delivery?.style??"pace","delivery.style"),legality:Ls(gn.deliveryLegalities,t.delivery?.legality??"legal","delivery.legality")},shot:e,finish:n,fielding:i,context:{freeHit:r},decision:{dismissal:o}}}function W4(t,e){const n=t.decision.dismissal;if(!n)return{dismissal:null,reason:"no-dismissal"};if({catch:"caught",bowled:"bowled",lbw:"lbw",stumping:"stumped","run-out":"run-out"}[e]!==n)throw new Error(`cricketPlay: '${n}' decision does not match '${e}' motion`);if(n!=="run-out"){if(t.context.freeHit)return{dismissal:null,reason:"free-hit"};if(t.delivery.legality==="no-ball")return{dismissal:null,reason:"no-ball"};if(t.delivery.legality==="wide"&&n!=="stumped")return{dismissal:null,reason:"wide"}}return{dismissal:n,reason:"dismissal"}}function d1(t,e={}){const n=ge(We,t.format,"cricketPlay.format"),s=N4(e);if(s.context.freeHit&&!We[n].freeHitAfterNoBall)throw new Error("cricketPlay: Test format does not support free-hit context");const i=F4(s),r=W4(s,i),o=s.delivery.legality==="legal",a={runs:s.finish==="single"?1:s.finish==="four"?4:s.finish==="six"?6:0,extras:o?0:1,wickets:r.dismissal?1:0,legalBall:o,freeHitNext:We[n].freeHitAfterNoBall&&(s.delivery.legality==="no-ball"||s.context.freeHit&&!o),...r.dismissal?{dismissal:r.dismissal}:{}};return{...u1(t,{action:i,duration:e.duration,every:e.every},{delivery:s.delivery,result:a,ruling:r,freeHit:s.context.freeHit}),play:s,ruling:r}}function D4(t={}){const e=Nh(t);return{...e,...d1(e,t)}}const f1=Object.freeze({"no-ball-stumps":Object.freeze({name:"No-ball + stumps hit",options:Object.freeze({delivery:Object.freeze({legality:"no-ball"}),finish:"stumps",decision:Object.freeze({dismissal:"bowled"})})}),"free-hit-catch":Object.freeze({name:"Free hit + catch",options:Object.freeze({context:Object.freeze({freeHit:!0}),shot:"drive",fielding:"catch",decision:Object.freeze({dismissal:"caught"})})}),"no-ball-four":Object.freeze({name:"No-ball + four",options:Object.freeze({delivery:Object.freeze({legality:"no-ball"}),shot:"drive",finish:"four"})}),"free-hit-run-out":Object.freeze({name:"Free hit + run-out",options:Object.freeze({context:Object.freeze({freeHit:!0}),shot:"drive",fielding:"run-out",decision:Object.freeze({dismissal:"run-out"})})}),"free-hit-wide":Object.freeze({name:"Free hit + Wide",options:Object.freeze({context:Object.freeze({freeHit:!0}),delivery:Object.freeze({legality:"wide"})})})}),B4={linear:!0,"ease-in":!0,"ease-out":!0,"ease-in-out":!0,"ease-in-quad":!0,"ease-out-quad":!0,"ease-in-out-quad":!0,"ease-in-cubic":!0,"ease-out-cubic":!0,"ease-in-out-cubic":!0};function g1(t,e={}){const n={};for(const s of Object.keys(Xt))n[s]={summary:`Walks to \`to\` in the ${s} gait.`,needs:["to"]};for(const s of Object.keys(ae))n[s]={summary:`Moves into the ${s} pose and holds it (\`for\` ms).`};for(const s of Object.keys(on))n[s]={summary:`The ${s} gag (${Ni(s)} ms).`};for(const[s,i]of Object.entries(Wi))n[s]={...i};return{sports:{cricket:{actions:{...Wn},formats:{...We},casts:{...Ph},fieldingPositions:{...Cs},markingProfiles:{...Vo},cameras:{...Go},decisionCameras:Yi,playComponents:gn,playExamples:f1}},...t?{version:t}:{},timing:"JSON timelines and tracks are in milliseconds; the GSAP-style API (live.to, tf.timeline) takes seconds. Scene x grows right, y grows down, in px.",easings:{named:Object.keys(B4),parametric:{"cubic-bezier":'{ type: "cubic-bezier", points: [x1, y1, x2, y2] }',steps:'{ type: "steps", count, position?: start | end | none | both }',elastic:'{ type: "elastic", mode?: in | out | in-out, amplitude?, period? }',bounce:'{ type: "bounce", mode?: in | out | in-out }',back:'{ type: "back", mode?: in | out | in-out, overshoot? }'}},trackKinds:{keyframe:"{ id, target, property, keyframes: [{ time, value, easing? }] }: values between keys are interpolated (numbers, colours, paths)",spring:'{ id, target, property, kind: "spring", spring: { from, to, stiffness?, damping?, mass?, velocity? }, delay? }: physics settle',inertia:'{ id, target, property, kind: "inertia", inertia: { from, velocity, friction?, min?, max?, end? }, delay? }: a flick that slows (end snaps to a value or the nearest of a list)',motionPath:'{ property: "motionPath", path, align? }: moves along an SVG path',text:'{ property: "text", … }: types or scrambles text'},canvasProperties:Lo,stickFigure:{poseFields:pd,props:md,handFields:yd,poses:Object.keys(ae),expressions:Object.keys(vt),gags:Object.fromEntries(Object.keys(on).map(s=>[s,Ni(s)])),gaits:Object.keys(Xt),actingStyles:Object.keys(Ln),beatFields:Io,actions:n,dances:Object.fromEntries(Object.entries(Ze).map(([s,i])=>[s,Object.keys(i.moves)])),flips:Object.fromEntries(Object.entries(Ai).map(([s,i])=>[s,i.label])),handShapes:Object.keys(St),mudras:Object.keys(_r)},props:{api:{"car() · truck() · bus() · tractor() · cart() · trainCar() · bike() · motorbike()":"wheeled vehicles (vehicle(spec) makes your own)","tree() · house()":"environment (tree(spec), house(spec))","helicopter() · airplane()":"aircraft","horse() · dog() · cat() · cow()":"animals (quadruped(spec) makes your own): gaits with footfall patterns keyed in step with the distance, sit, jump, their calls, species actions","songbird() · crow() · chicken()":"birds (bird(spec) makes your own): hop, walk, peck, flap, fly and land (a chicken flutters), their calls; wings fold and beat in rhythm","{ kind: 'prop', prop: 'car', position, rotation, values } with loadScene3D(scene, { kinds: [characterObjects, propObjects] })":"props in 3D scenes, by preset name, seen in perspective by the scene camera; controls are tracks on the object","characterScript3D(id, beats, { scene, position?, heading?, height?, pose? })":"a v2 character in world metres: gaits, face (shortest turn), spin (signed turns and duration), dance (native style, bpm, beats), hold, pose, gag; checkCharacterBeats3D checks the beats","propRide3D({ prop, propId, propTracks, scene, placement, anchor, riderId, pose, start, end, mount?, dismount? })":"a character riding a prop in a 3D scene: hips on a seat anchor (saddle, seat) as it moves, hopping on and off; RIDING_POSES.astride / .seated / .driving / .cycling / .wheeling (a wheelchair)","propScript3D(id, prop, beats, { scene, position?, heading?, values? })":"props scripted in world metres for 3D scenes: moves to [x, z] or through points (wheels and strides keyed with the distance), face, hold, and their actions; checkPropBeats3D checks the beats","propPreset(name, options?)":"a prop preset by name (did-you-mean on a wrong one)","propTarget({ …, style: 'stick' })":"line art to go with stick figures: tubes as single strokes, shapes outlined over paper","propTow({ leader, leaderId, leaderTracks, hitch, towed, towedId, anchor, start, end })":"a prop towed by another (a cart behind a horse): turns with it, its wheels roll exactly","propTarget({ x, y, prop, scale?, values?, look?, ink? })":"a canvas target that draws a prop (x, y: its middle on the ground; scale px per metre, default 60)","propScript(id, prop, beats, { from, ground, scale, style?, exaggeration?, start? })":"beats → acted tracks, with contact times and effect cues; checkPropBeats(beats, prop) checks them","drawProp(ctx, target, frame, id, { rider? })":"draw it as it is in a frame (a rider is drawn between its far and near parts)","propAt(target, frame, id).anchor(name)":"where an anchor (seat, door, chimney…) is, in scene px","propRide({ prop, propId, propTracks, anchor, figure, figureId, start, end, offset? })":"a figure carried at an anchor, turning with the prop; spliceTracks() puts it into the figure’s tracks","drawPropEffects(ctx, effects, time)":"dust, exhaust, skid marks, honk lines, leaves, smoke"},beatFields:qo,commonControls:Object.fromEntries(Object.entries(As).map(([s,i])=>[s,`${i.description}${i.unit?` (${i.unit})`:""}`])),commonActions:Object.fromEntries(Object.entries(Eh).map(([s,i])=>[s,i.summary])),presets:Object.fromEntries(Object.entries(Os).map(([s,i])=>{const r=i();return[s,{family:r.family,summary:r.summary,actions:Object.fromEntries(Object.entries(r.actions).map(([o,a])=>[o,{summary:a.summary,...a.needs?{needs:a.needs}:{}}])),controls:Object.keys(r.rig.controls),anchors:Object.keys(r.rig.anchors??{})}]}))},custom:{api:{"defineAction({ summary, needs?, steps: (from, beat) => [{ after, pose, easing? }] })":"a new action written as timed pose steps from the current pose, like a gag","defineAction({ summary, needs?, beats: (beat) => [beats] })":"a new action built from other beats (which may be custom too)","defineGait({ swing, knee, arm, elbow, lean, cycle?, … })":"a new gait (the Gait fields in degrees; cycle is ms per two steps)","scriptTracks(id, beats, { actions, gaits })":"beats may then use those names; checkBeats(beats, { actions, gaits }) knows them","stickFigureTarget({ …, cast: { actions, gaits } })":"a figure that draws the gaits and lists the actions in describeTarget","persona({ name, summary?, height?, look?, acting?, gait?, mood?, stance?, energy?, actions?, gaits? })":"a character’s look, acting style and habits: .figure({ x, y }), .script(id, beats, { from, ground }), .check(beats), .handPath(…), .describe(); `go` walks in its gait, `stand` returns to its stance and face"},actions:Object.fromEntries(Object.entries(e.actions??{}).map(([s,i])=>[s,{summary:i.summary,...i.needs?{needs:i.needs}:{}}])),gaits:Object.fromEntries(Object.entries(e.gaits??{}).map(([s,i])=>[s,i.summary??"custom gait"]))},character:{figureStyles:["fluid","stick","organic"],body:{"body.torso · body.arm · body.leg · body.neck":"Organic half-width profiles: [{ at: 0..1, width: fractionOfHeight }], increasing from 0 to 1; independent of ink width.","body.measurements":`Organic torso from tape-measure girths { height, bust, underbust?, waist, hip } in any one unit, or a named shape (${Object.keys(Xr).join(" | ")}). Sets the front width, the side depth (bust forward, seat back, belly) and the hip and thigh spacing; reads correctly at every turn. An explicit torso / torsoFront / torsoBack / hipWidth still wins.`,"body.torsoFront · body.torsoBack":"Organic side-view depth from the spine line toward the chest/belly and toward the back/seat, same profile format; default torso × depth.","body.fill · body.outline · body.shading":"Shared skin fill, outline { color, width }, cel material { mode: cel | none, light: [x,y], shadow, opacity, highlight }.","softCartoonCharacter(name, options?)":"Original youngMan / youngWoman / childBoy / childGirl story presets. Children have larger head proportions, shorter limbs and rounded torsos; every face, hair, build, hand, clothing and material option can be overridden.","face.projection":"Organic default volume follows the head axes, keeps both eyes in three-quarter views and projects a small nose above the mouth; opaque hair covers features. cartoon keeps the classic face slide.","outfitPreset(category, overrides?)":"Fresh JSON Everyday / Formal / Casual wardrobe defaults for every actor; top: tshirt | shirt | blouse | dress, trouserStyle: plain | jeans | cargo, colours, sleeves, bottoms, collar and tie are editable.",leafOutfit:"Organic-only JSON garment { top?, color?, accent?, length? }; curved leaves follow torso/thighs at native part depths. Everyday basicOutfit also follows organic contours."},poses:Object.keys(be),dances:Object.keys(An),expressions:Object.keys($l),faceStyles:["simple","anime"],faceShapes:["round","angular"],gags:Object.keys(io),builds:Object.keys(Wr),hair:Object.keys(Ul),hairColors:{...Ae},facialHair:Object.keys(tc),glasses:Object.keys(nc),hats:Object.keys(eo),feet:[...vf],cast:Object.keys(qc),heldItems:Object.fromEntries(Object.entries(oc).map(([s,i])=>[s,i.hands])),handMeetings:Object.keys(Fi)},codePanel:{languages:Eo,removeStyles:xo,anchors:{"line(n, time?)":"line n’s text box { x, y, left, right, top, bottom, width, height }: stand on top, point at x, y","token(n, text, occurrence?, time?)":"a word on a line","spot(n, column, width?, time?)":"a place in a line, for put and write","landing(piece, n, column)":"where a dropped piece will land",box:"the whole panel"},edits:Fc},surfaces:{code:_i,board:Re,chart:Hn,prop:$s},surfaceScript:{"surfaceScript(figureId, { name: surface }, beats, options)":"compiles beats that act on surfaces: returns the script result with `tracks` (the figure’s, ridden, then every surface’s, keyed by its name) and `figureTracks`; options are scriptTracks’ plus `figureStyle` (for carry) and `ride` (default true)","checkSurfaceBeats(beats, surfaces, cast?)":"every problem checkBeats finds, plus unknown surfaces, places, edits and moments, with suggestions","{ surface, anchor }":"a named place, where a beat takes `target` (its box), `to` (its centre x) or `onto` (its top); as laid out, before any edit moves it","then: { surface, edit, anchor, at?, until?, …options }":"what the surface does in answer to the beat (or a list of them): one of its edits, or `carry` (the piece follows the hand until `until`); the other fields are the edit’s options",at:`a moment of the beat: ${Ts.join(", ")} (default contact, or start when the beat has none); not ms`,until:"a moment of this beat, or { beat: index, at? } of a later one; sets the edit’s duration (carry needs it)"},cameraShots:{frame:"{ at, duration?, easing?, frame: { focus?: { x, y }, scale?, rotate? } }: push in, pull out, or cut (duration 0)",shake:"{ at, duration, shake: { strength?, frequency?, roll?, seed? } }",follow:"{ at, until, follow: { x: <the subject’s x keyframes>, lead?, y?, lag?, scale? } }: keeps a subject centred"},teach:{"lesson({ id })":"steps as timeline JSON: to, set, together, wait, marker (with pause, question, captions)","cells, pointer, stack, queue, table, pipeline":"diagram primitives (SVG markup + step helpers)","figure({ width, height, children })":"the SVG holding the pieces"},cli:{"tinyfly capabilities [--json]":"this catalog","tinyfly check <beats.json>":"check a beat script (names, fields) with suggestions","tinyfly validate <timeline.json> [--markup file]":"check a timeline against its markup","tinyfly render <timeline.json> <markup> [--at …]":"a frame as static markup","tinyfly video <scene.mjs> [--stills dir --times …]":"MP4, or PNG stills to look at"}}}const yt=t=>t.map(e=>`\`${e}\``).join(", "),p1=t=>Object.entries(t).map(([e,n])=>`| \`${e}\` | ${n.unit??n.kind??""} | ${n.description} |`).join(`
63
- `);function z4(t,e={}){const n=g1(t,e),s=n.stickFigure;return[`# tinyfly capabilities${n.version?` (v${n.version})`:""}`,"","Generated from the library itself: every name below is accepted, and names not listed are rejected (beat scripts, code panels and `checkTracks` say which name was probably meant).","",`**Timing.** ${n.timing}`,"","## Easings","",`Named: ${yt(n.easings.named)}.`,"",...Object.entries(n.easings.parametric).map(([r,o])=>`- ${r}: \`${o}\``),"","## Track kinds","",...Object.entries(n.trackKinds).map(([r,o])=>`- **${r}**: ${o}`),"","## Canvas targets","","Types: `rect`, `circle`, `text`, `line`, `path`, `image`, `custom`. `describeTarget(target)` lists what one can animate with its values; `checkTracks(tracks, targets)` checks tracks before playing them.","","| Property | Unit | What it does | Types |","|---|---|---|---|",...Object.entries(n.canvasProperties).map(([r,o])=>`| \`${r}\` | ${o.unit??o.kind??""} | ${o.description} | ${o.types.length===7?"all":o.types.join(", ")} |`),"","## Stick figure (`@algorisys/tinyfly/characters`)","","`stickFigureTarget({ x, y, style })` is a custom canvas target; its props are the pose fields and the props below. Pose it with tracks (`poseTracks`), or write beats (`scriptTracks`).","","Style proportions: `headSize` is a fraction of height; `armLength` multiplies both upper arm and forearm lengths (default 1, positive finite). Hands, shoulders, torso and legs retain their sizes.","","### Pose fields","","| Field | Unit | What it does |","|---|---|---|",p1(s.poseFields),"","### Other props","","| Prop | Unit | What it does |","|---|---|---|",p1(s.props),"",`With \`style.hands\`, each hand has \`hand.left.<field>\` / \`hand.right.<field>\` props: ${yt(Object.keys(s.handFields))}.`,"",`**Poses** (a beat's \`do\`, or a pose key): ${yt(s.poses)}.`,"",`**Expressions** (a beat's \`mood\`): ${yt(s.expressions)}.`,"",`**Gags** (ms): ${Object.entries(s.gags).map(([r,o])=>`\`${r}\` (${o})`).join(", ")}.`,"",`**Gaits**: ${yt(s.gaits)}. **Acting styles** (\`style\`): ${yt(s.actingStyles)}.`,"","### Beat scripts","",`\`scriptTracks(target, beats, { from, ground, height, facing, style })\`. A beat has these fields only: ${yt(s.beatFields)}. Times are ms; \`to\` and \`target\` are scene px; \`onto\` is a floor's scene y.`,"","`characterScript(target, who, beats, options)` compiles the same beats for a v2 `character()` on a `characterTarget` (every option but `height`; the same result, its key poses on the human body; the walk phase keyed to that character's stride, and `walk` / `walking` / `gait` tracks that step the gait as the target draws). Add `hairFollowTracks(target, tracks, who)` after it so hanging hair swings.","","| `do` | Needs | What happens |","|---|---|---|",...Object.entries(s.actions).map(([r,o])=>`| \`${r}\` | ${(o.needs??[]).map(a=>`\`${a}\``).join(", ")} | ${o.summary} |`),"","Beats that touch something report `contact` (and `release`) times in `result.beats[i]`; key the thing they touch to those.","",`**Dances** (\`dancer(style, { move })\`): ${Object.entries(s.dances).map(([r,o])=>`\`${r}\` (${o.join(", ")})`).join("; ")}.`,"",`**Flips**: ${Object.entries(s.flips).map(([r,o])=>`\`${r}\` (${o})`).join(", ")}.`,"",`**Hand shapes**: ${yt(s.handShapes)}. **Mudras**: ${yt(s.mudras)}.`,"","### Your own actions, gaits and personas","","Nothing is registered globally: pass your definitions where they are used.","",...Object.entries(n.custom.api).map(([r,o])=>`- \`${r}\`: ${o}`),"",...Object.keys(n.custom.actions).length||Object.keys(n.custom.gaits).length?["**This cast’s own:**","",...Object.entries(n.custom.actions).map(([r,o])=>`- \`${r}\`${o.needs?.length?` (needs ${o.needs.map(a=>`\`${a}\``).join(", ")})`:""}: ${o.summary}`),...Object.entries(n.custom.gaits).map(([r,o])=>`- \`${r}\` (gait): ${o}`),""]:[],"## Props (everyday objects with behaviours)","","A prop is a 3D rig of simple parts drawn with the characters’ pens (clean, pencil, silhouette), so it turns toward the camera (`turn`), and its beats go through the same acting pass (anticipation, overshoot, overlap; `exaggeration` scales them).","",...Object.entries(n.props.api).map(([r,o])=>`- \`${r}\`: ${o}`),"",`Prop beat fields: ${yt(n.props.beatFields)}. Every prop has the controls ${Object.keys(n.props.commonControls).map(r=>`\`${r}\``).join(", ")} and the actions ${Object.keys(n.props.commonActions).map(r=>`\`${r}\``).join(", ")}.`,"","Scenery: `scenery({ x, y, width, height, kind: sky | room, hour, clouds, wind, rain, snow, horizon: hills | city | flat })` is a canvas target whose values `hour` (0–24), `clouds`, `rain`, `snow` (0–1) and `wind` (−1..1) are tracks (`set(prop, { at, value, duration })`, `tracks(id)`; `anchor('sun' | 'moon' | 'horizon' | 'ground', time)`); the same `wind` streams hair (`hairFollowTracks(…, { wind })`). `scenePreset('park' | 'street' | 'office' | 'home', { width, height })` lays out scenery and props as data; `buildScene` builds them into targets.","","| Preset | Family | Actions (needs) | Controls | Anchors |","|---|---|---|---|---|",...Object.entries(n.props.presets).map(([r,o])=>`| \`${r}()\` | ${o.family} | ${Object.entries(o.actions).map(([a,l])=>`\`${a}\`${l.needs?.length?` (${l.needs.join(", ")})`:""}`).join(", ")} | ${o.controls.map(a=>`\`${a}\``).join(", ")} | ${o.anchors.join(", ")} |`),"","## Character (v2 human)","",`Poses: ${yt(n.character.poses)}. Expressions: ${yt(n.character.expressions)}. Gags: ${yt(n.character.gags)}.`,`Native dances: ${yt(n.character.dances)}; \`humanDanceFrame(style, beat, base)\` keeps body heading independent; \`humanDanceTracks(target, options)\` bakes JSON pose tracks. \`danceCircleAt(beat, { radius, count, beatsPerTurn, facing, spins })\` gives a formation with planted toes; \`danceCircleTracks(targets, options)\` bakes scene tracks. \`plantDanceFoot(partner, side, worldPoint)\` returns pose AND position; \`meetDandiya(a, b)\` solves both stick tips to one shared world point and reports unreachable contacts.`,"","Appearance options of `character({ … })`, all plain data that turns with the head (see docs/character-appearance.md):","",`- \`build\`: ${yt(n.character.builds)}`,`- \`figure\`: ${yt(n.character.figureStyles)}`,"- `look`: `clean` (default), `pencil`, `silhouette`, `illustrated` (inked and painted: line weight follows the light, brush-tapered strokes, shadow/core/highlight tones from each fill; `illustrated: { light: [x, y], weight, taper, shadow, highlight }`, each 0–1)",...Object.entries(n.character.body).map(([r,o])=>`- \`${r}\`: ${o}`),`- \`hair\`: ${yt(n.character.hair)} (colours: ${yt(Object.keys(n.character.hairColors))} in \`HAIR_COLORS\`)`,"- Flowing hair: `softSweep`, `flowingBob`, `cascadingWaves`; editable `locks: [{ path, width, follow? }]` with cubic `{ around, up, lift? }` points (around in degrees, dimensions in head radii), `fall: { taper, wave }` and `shine` (0–1). Roots stay attached; `hairFollowTracks` also drives flexible short locks.",`- \`facialHair\`: ${yt(n.character.facialHair)}`,`- \`glasses\`: ${yt(n.character.glasses)}; \`hat\`: ${yt(n.character.hats)}; \`ears: true\`; \`face: { teeth, tongue }\` (shown when the mouth opens); \`feet\`: ${yt(n.character.feet)}`,"- `outfit`: `{ top: tshirt | shirt | blouse | dress, trouserStyle: plain | jeans | cargo, shirt: top colour, trousers: bottom colour, sleeves: short | long | none, bottom: trousers | shorts | skirt, collar, tie: colour, over: apron | labCoat | hoodie | cardigan | overalls | sari, overColor, shoes: boots, shoeColor }`",`- \`castMember(name, height)\`: ${yt(n.character.cast)}`,"- Face marks (pose fields, 0–1): `blush`, `tears`, `sweat`; close-up fields `pupil` (size, 1 usual), `lid` (upper lids lowered, 0–1), `bulge` (eyes out of the head, 0–1); `face: { nose: true, inPupil(ctx, pupil) }`; `drawCharacterHead(ctx, who, pose, { x, y, radius })` draws just the head big",`- Face styles: ${yt(n.character.faceStyles)}; \`face: { style: 'anime', iris: '#4b7fce', lashes: true, ageLines: 0.8 }\` uses coloured eyes and the same expressions, blinks and gaze. \`ANIME_CAST\` contains eight age presets, also available through \`castMember\`.`,`- Face shapes: ${yt(n.character.faceShapes)}; \`face: { shape: 'angular', jawWidth: 0.74, chinWidth: 0.14, eyeScale: 0.8, eyeAspect: 0.65 }\` sets a tapered 3D jaw and narrower anime eyes; \`jawRoundness: 1\` softens the cheek/chin corners (default 0 keeps sharp jaws). \`MANGA_CAST\` contains four original young adult presets; hair styles \`mangaSpikes\` and \`mangaSweep\` remain editable.`,"- Hair in motion (pose fields): `hair.swing` (degrees round the head, + toward its left), `hair.trail` (head radii back), `hair.lift` (head radii up); key them with `hairFollowTracks(target, tracks, who)` after the character's tracks, or `hairFollow` + `hairMotionAt` when posing per frame",`- \`holding\`: ${Object.entries(n.character.heldItems).map(([r,o])=>`\`${r}\` (${o==="both"?"both":o==="either"?"one hand or both":"left or right"})`).join(", ")}; pose fields \`held.left\`, \`held.right\`, \`held.both\` (below 0.5 lets go); \`handGrip(joints, side)\``,`- \`meetHands(kind, a, b)\` (stand them \`meetingSpacing(kind, a, b)\` apart): ${yt(n.character.handMeetings)}; \`embrace(a, b)\` (a hug, \`embraceSpacing\` apart); \`helpUp(helper, sitter, progress)\` (0 on the floor, hand taken; 1 standing; \`helpUpSpacing\` apart)`,"- Everyday cycles like a gait: `humanCyclePose('sweeping' | 'brushing', phase, base)` (0 → 1 is one stroke and back; sweeping with `holding: { right: 'broom' }`)","","## Code panel","",`\`codePanel({ code, language, x, y, fontSize?, lineHeight?, width? })\`: a code listing as a scene object. Languages: ${yt(n.codePanel.languages)}. Remove styles: ${yt(n.codePanel.removeStyles)}.`,"",...Object.entries(n.codePanel.anchors).map(([r,o])=>`- \`${r}\`: ${o}`),"",...Object.values(n.codePanel.edits).map(r=>`- \`${r.split(":")[0]}\`:${r.split(":").slice(1).join(":")}`),"","## Surfaces","","Scene objects figures act on. Places are named `kind:args`: `surface.anchor(name)` gives the box there (stand on `top`, point at `x`, `y`; pass it as a beat `target`), `surface.piece(name)` makes the part there come loose, and `surface.edit(name, anchor, options)` changes the surface at a time (`at`, ms).","","Beats name places and say what surfaces do in answer (`surfaceScript`):","",...Object.entries(n.surfaceScript).map(([r,o])=>`- \`${r}\`: ${o}`),"",...Object.entries(n.surfaces).flatMap(([r,o])=>[`### ${r}`,"",...o.create?[`\`${o.create}\``,""]:[],"Anchors:",...Object.entries(o.anchors).map(([a,l])=>`- \`${a}\`: ${l}`),"","Edits:",...Object.entries(o.edits).map(([a,l])=>`- \`${a}\`: ${l}`),""]),"## Cricket stories (`@algorisys/tinyfly/sports`)","","`cricketClip({ format, action, cast })` returns an organic-player scene, JSON tracks, timed events/captions and a declared result. `cricketField`, `cricketPlayer` and `cricketAction` compose separately; `cricketCameraTracks` adds camera tracks. These are authored tutorial plays, not physics or automatic umpiring. See docs/cricket.md.","",`Marking profiles: ${yt(Object.keys(n.sports.cricket.markingProfiles))}; default ICC men, independently of cast. Limited-over ICC profiles draw a wicket-centred capsule; Test/MCC have no restriction-area line. \`cricketFieldingAreaContains(field, point)\` returns true/false/null; \`cricketFieldingPositions\` and \`cricketFieldingOverlay\` provide owned setup markers, not umpiring decisions.`,"","`cricketPlay(field, options)` / `cricketPlayClip(options)` independently author delivery style/legality, shot, finish, fielding, current free-hit context and candidate dismissal. Omitted dismissal means no dismissal. Unsupported motion combinations throw; no-ball/free-hit protection changes result/signals without removing physical catches or wicket breaks. Run-out remains available. Illegal free hits carry forward; legal ones consume context. Test rejects free-hit context. Keep innings/score/strike in the consuming app.","",...Object.entries(n.sports.cricket.playComponents).map(([r,o])=>`Play ${r}: ${yt(o)}`),...Object.entries(n.sports.cricket.playExamples).map(([r,o])=>`- Composed example \`${r}\`: ${o.name}`),"",...Object.entries(n.sports.cricket.actions).map(([r,o])=>`- \`${r}\`: ${o.summary}`),"",`Formats: ${yt(Object.keys(n.sports.cricket.formats))}. Casts: ${yt(Object.keys(n.sports.cricket.casts))}. Cameras: ${yt(Object.keys(n.sports.cricket.cameras))}. Orbit turns 360° around the whole ground. \`cricketCameraTracks(clip, { view, zoom })\` supports 0.25–4× optical magnification (default 1) in every view.`,"",`Stock fielding labels (\`CRICKET_FIELDING_POSITIONS\`): ${Object.entries(n.sports.cricket.fieldingPositions).map(([r,o])=>`\`${r}\`: ${o}`).join(", ")}. Eleven fielders, two on-field batters and two umpires; nine batting teammates wait off-field. Mid-on is closer to the pitch; long-on is its deeper boundary alternative, not an extra stock fielder. For the right-handed striker, +x is off side and -x is on/leg side.`,"","Decision review cameras: front-foot, striker-crease, bowler-crease. cricketCameraFraming returns owned defaults; cricketCameraReview returns a physical event without seeking. Optional cricketDecisionOverlay marks the crease reference. pitch 0–89, distance 0.5–2000, fov 10–100 before zoom, and fixed-view target customize framing. Ball-follow yaw rotates its default offset relative to 75 degrees; pitch/distance apply too. Export all camera tracks, including far for distant framing. These APIs never alter motion or rulings.","","## Camera shots (`cameraTracks(shots, { stage })`)","",...Object.entries(n.cameraShots).map(([r,o])=>`- **${r}**: \`${o}\``),"","## Teaching (`@algorisys/tinyfly/teach`)","",...Object.entries(n.teach).map(([r,o])=>`- \`${r}\`: ${o}`),"","## Command line","",...Object.entries(n.cli).map(([r,o])=>`- \`${r}\`: ${o}`),""].join(`
62
+ `)}`);const r=s.from??0,o=s.ground??0,a=s.scale??60,l=s.exaggeration??1,c=jo(e),h={};for(const S of[...Object.keys(As),...Object.keys(e.rig.controls)])h[S]=s.start?.[S]??It(e.rig,{},S);const u=[{time:0,pose:{...h}}],d=new Map,f=[];let p=r,g=o;const m=(S,E,P,I)=>{const O=d.get(S)??[{time:0,value:S==="x"||S==="y"?0:h[S]}];O.push({time:E,value:P,...I?{easing:I}:{}}),d.set(S,O),S!=="x"&&S!=="y"&&(h[S]=P)},y=(S,E)=>{const P=S==="x"?p-r:S==="y"?g-o:h[S],I=d.get(S);(!I||I[I.length-1].time<E)&&m(S,E,P)},v={prop:e,scale:a,exaggeration:l,get x(){return p},get floor(){return g},values:h,facing(){const S=Math.sin(h.turn*Math.PI/2);return Math.abs(S)<.5?0:S>0?1:-1},key(S,E,P={}){Object.assign(h,E),u.push({time:S,pose:{...h},...P.act===!1?{act:!1}:{},...P.easing?{easing:P.easing}:{}})},move(S,E,P,I={}){y("x",S),m("x",E,P-r,I.easing),p=P,I.floor!==void 0&&(y("y",S),m("y",E,I.floor-o,I.easing),g=I.floor)},set(S,E,P,I){m(S,E,P,I)},turnTo(S,E){const P=typeof E=="number"?E:Th[E],I=h.turn,H=[P-4,P,P+4].map(j=>({t:j,d:Math.abs(j-I)})).sort((j,J)=>j.d-J.d||Math.abs(j.t)-Math.abs(J.t))[0];if(H.d<.001)return S;const W=S+p4*Math.max(1,H.d);return v.key(W,{turn:H.t}),W},effect(S){f.push(S)},anchor(S){const P=Ps(e,h,a).anchors[S];if(!P)throw new Error(`${e.kind}: no anchor "${S}"`);return{x:p+P.point.x,y:g+P.point.y}}},k=[];let w=0;for(const S of n){const E=Math.max(S.at??w,u[u.length-1].time),P=c[S.do].run(v,S,E);P.end>u[u.length-1].time&&u.push({time:P.end,pose:{...h}}),k.push({start:E,end:P.end,...P.contact!==void 0?{contact:P.contact}:{},...P.release!==void 0?{release:P.release}:{}}),w=P.end}const T=Kc(s.style??"snappy"),A={...T,anticipation:T.anticipation*l,overshoot:T.overshoot*l},M=$o(w4(u),e.acting,{style:A}),x=[...Object.entries(M).filter(([S])=>!d.has(S)).map(([S,E])=>({id:`${t}-${S}`,target:t,property:S,keyframes:E})),...[...d].map(([S,E])=>({id:`${t}-${S}`,target:t,property:S,keyframes:k4(E)}))];for(const S of y4(t,e,x,w,u[0].pose)){const E=x.findIndex(O=>O.property===S.property);if(E<0){x.push(S);continue}const P=new Ht({id:`${t}-own`,tracks:[x[E]]}),I=O=>Number(P.getStateAtTime(O).values.get(t)?.get(S.property)??0);x[E]={...S,keyframes:S.keyframes.map(O=>({time:O.time,value:Number(O.value)+I(O.time)}))}}return{tracks:x,duration:w,beats:k,effects:f}}const m4=1500;function y4(t,e,n,s,i){if(!e.follow?.length)return[];const r=new Ht({id:`${t}-follow`,tracks:n.filter(a=>a.property==="turn"||e.follow.some(l=>l.of===a.property))}),o=(a,l)=>{const c=r.getStateAtTime(a).values.get(t)?.get(l);return typeof c=="number"?c:i[l]??0};return e.follow.map(a=>{const l=s+m4,c=Us(d=>o(d,a.of),{start:0,end:l,stiffness:a.stiffness,damping:a.damping}),h=a.limit??1/0,u=c.map(({time:d,value:f})=>{const p=Math.sin(o(d,"turn")*Math.PI/2),g=(f-o(d,a.of))*p;return{time:d,value:Math.max(-h,Math.min(h,g*a.per))}});return{id:`${t}-${a.control}`,target:t,property:a.control,keyframes:u}})}const b4=20;function w4(t){const e=[...t].sort((s,i)=>s.time-i.time),n=[];for(const s of e){const i=n[n.length-1];i&&s.time-i.time<b4?n[n.length-1]={...s,time:i.time}:n.push(s)}return n}function k4(t){const e=t.map((s,i)=>({k:s,i})).sort((s,i)=>s.k.time-i.k.time||s.i-i.i),n=[];for(const{k:s}of e)n.length>0&&n[n.length-1].time===s.time?n[n.length-1]=s:n.push(s);return n}const We=Object.freeze({test:Object.freeze({name:"Test",inningsPerSide:2,oversPerInnings:null,ballsPerOver:6,freeHitAfterNoBall:!1,summary:"Multi-day cricket. Each side can have two innings; there is no innings over limit."}),odi:Object.freeze({name:"ODI",inningsPerSide:1,oversPerInnings:50,ballsPerOver:6,freeHitAfterNoBall:!0,summary:"One innings per side, up to 50 overs. A no-ball gives a free hit on the next legitimate delivery."}),t20:Object.freeze({name:"T20",inningsPerSide:1,oversPerInnings:20,ballsPerOver:6,freeHitAfterNoBall:!0,summary:"One innings per side, up to 20 overs. A no-ball gives a free hit on the next legitimate delivery."})}),Ph=Object.freeze({adults:"Adults",men:"Men",children:"Children",mixed:"Mixed cast"}),Cs=Object.freeze({bowler:"Bowler",keeper:"Wicketkeeper",fielder:"Extra cover",slip:"Slip",point:"Point",cover:"Cover","mid-off":"Mid-off","mid-on":"Mid-on","square-leg":"Square leg","fine-leg":"Fine leg","third-man":"Third man"}),Wn=Object.freeze(Object.fromEntries(Object.entries({bowling:{name:"Pace bowling",summary:"Run up, deliver with a straight arm, bounce and follow through."},spin:{name:"Spin bowling",summary:"A shorter approach and a curved illustrative flight before the bounce."},batting:{name:"Drive",summary:"Two hands on the bat, a backlift, contact and a follow-through."},defend:{name:"Defensive block",summary:"Meet the ball with a controlled bat and keep it close."},running:{name:"Running between wickets",summary:"Both batters make the opposite ground to complete one run."},four:{name:"Boundary four",summary:"A struck ball reaches the boundary after touching the ground."},six:{name:"Boundary six",summary:"A struck ball clears the boundary before touching the ground."},catch:{name:"Catch",summary:"A fielder controls the struck ball before it touches the ground."},fielding:{name:"Ground field",summary:"A fielder moves to the ball, bends and gathers it."},throw:{name:"Field and throw",summary:"Gather, wind up, release and return the ball to the keeper."},bowled:{name:"Bowled",summary:"A legal delivery hits the wicket and removes a bail."},lbw:{name:"LBW illustration",summary:"Pad contact and a projected path to the stumps illustrate an authored LBW decision."},stumping:{name:"Stumping",summary:"The keeper holds the ball and breaks the wicket while the striker is out of ground, not attempting a run."},"run-out":{name:"Run-out",summary:"A direct throw breaks the wicket before the running batter makes that ground."},"no-ball":{name:"Front-foot no-ball",summary:"The landing front foot oversteps the popping crease at release; one extra, no legal ball."},wide:{name:"Wide ball",summary:"An untouched delivery passes beyond reach for a normal stroke; one extra, no legal ball."}}).map(([t,e])=>[t,Object.freeze(e)])));function ge(t,e,n){if(!Object.prototype.hasOwnProperty.call(t,e))throw new Error(`${n}: unknown choice '${e}'`);return e}const _t=(t,e,n)=>Math.max(0,Math.min(1,(t-e)/(n-e))),Ft=t=>t*t*(3-2*t),Tt=(t,e)=>Vs(t,e),$h=(t,e)=>yn(t,e);function Ih(t,e){const n=e+((t-e+2)%4+4)%4-2;return n===0?0:n}function _s(t,e,n=0){return Math.hypot(e[0]-t[0],e[2]-t[2])<.001?n:Ih(Math.atan2(e[0]-t[0],e[2]-t[2])*2/Math.PI,n)}function Zy(){return{turn:1,"head.turn":90,"leg.left.spread":12,"leg.right.spread":12,"leg.left.swing":6,"leg.right.swing":6,"leg.left.knee":12,"leg.right.knee":12}}function Oh(t,e){const n=t.objects.find(s=>s.id===e);if(!n||n.kind!=="character")throw new Error(`cricketAction: required character '${e}' is missing`);if(n.parent||n.rotation?.some(s=>s!==0)||n.quaternion||n.scale!==void 0)throw new Error(`cricketAction: '${e}' must use position and pose.turn, without a transformed parent, scale or object rotation`);return{object:n,who:ps({...n.character,height:n.height??1.78})}}function Qy(t){return{position:[...t.object.position??[0,0,0]],pose:{...lt,...t.object.pose}}}function Hs(t,e,n,s){const i=Qe(t.who.plan,e.pose,{height:t.who.height,contact:t.who.contact});return Tt(e.position,i.chains[n][s])}function ji(t,e,n){const s=Hs(t,e,`arm.${n}`,2),i=Hs(t,e,`arm.${n}`,1);return Tt(s,$h(Jt(se(s,i)),t.who.lineWidth*.5))}function v4(t,e,n){const s={...e.pose,"head.turn":0,"head.nod":0,"head.tilt":0},i=Qe(t.who.plan,s,{height:t.who.height,contact:t.who.contact}).head,r=se(n,Tt(e.position,i.center)),o=i.axes.map(c=>Ie(r,c)),a=Math.atan2(o[0],o[2])*180/Math.PI,l=Math.atan2(-o[1],Math.hypot(o[0],o[2]))*180/Math.PI;return{...e,pose:{...e.pose,"head.turn":Math.max(-90,Math.min(90,a)),"head.nod":Math.max(-25,Math.min(30,l)),"head.tilt":0}}}function dn(t,e,n,s,i="hold"){let r={...e.pose};for(let o=0;o<10;o++){const a={...e,pose:r},l=Qe(t.who.plan,r,{height:t.who.height,contact:t.who.contact}),c=ss(t.who.plan,r,t.who.height),h=se(ji(t,a,n),Hs(t,a,`arm.${n}`,2)),u=se(se(se(s,h),e.position),l.hip),d=ns(u,(r.roll??0)*Math.PI/180),f=Tt(c.root,Qt(d,-(r.turn??0)*Math.PI/2));r=mi(t.who.plan,r,`arm.${n}`,f,{height:t.who.height})}for(const[o,a]of Object.entries(St[i]))r[`hand.${n}.${o}`]=a;return{...e,pose:r}}function M4(t,e,n,s){const i=Jt(s),r=t.who.height/1.78;let o=dn(t,e,"left",n);return o=dn(t,o,"right",Tt(ji(t,o,"left"),$h(i,.105*r))),{...o,bat:{grip:ji(t,o,"left"),axis:i,scale:r}}}function S4(t){return Tt(t.grip,$h(t.axis,.51*t.scale))}function t1(t){const e=Jt(t),n=Math.max(-1,Math.min(1,e[1]));return n>.999999?[0,0,0,1]:n<-.999999?Vt([1,0,0],180):Vt(Jt(Js([0,1,0],e)),Math.acos(n)*180/Math.PI).map(s=>s===0?0:s)}function Yo(t,e,n){const s={};for(const i of Object.keys({...t,...e})){const r=t[i]??lt[i]??0;s[i]=r+((e[i]??lt[i]??0)-r)*n}return s}function Ch(t,e){if(t<=e[0][0])return{...lt,...e[0][1]};for(let n=1;n<e.length;n++)if(t<=e[n][0])return Yo({...lt,...e[n-1][1]},{...lt,...e[n][1]},Ft(_t(t,e[n-1][0],e[n][0])));return{...lt,...e.at(-1)[1]}}function De(t,e){if(!Array.isArray(t)||t.length!==3||!t.every(Number.isFinite))throw new Error(`${e}: expected three finite coordinates`)}function e1(t,e,n=40,s=[]){if(!Number.isFinite(t)||!Number.isFinite(e)||t<0||e<t)throw new Error("sampleTimes: expected finite ordered nonnegative times");if(!Number.isFinite(n)||n<16||n>1e3)throw new Error("sampleTimes: every must be between 16 and 1000 ms");if((e-t)/n>2e4)throw new Error("sampleTimes: too many samples");const i=new Set([t,e,...s.filter(r=>r>=t&&r<=e&&Number.isFinite(r))]);for(let r=t+n;r<e;r+=n)i.add(r);return[...i].sort((r,o)=>r-o)}function _h(t,e){if(n1(t),!Number.isFinite(e))throw new Error("ballFlightPoint: time must be finite");const n=Math.max(0,Math.min(1,(e-t.start)/(t.end-t.start))),s=4*n*(1-n),i=t.to[0]-t.from[0],r=t.to[2]-t.from[2],o=Math.hypot(i,r)||1;return[t.from[0]+i*n-r/o*(t.curve??0)*s,t.from[1]+(t.to[1]-t.from[1])*n+(t.arc??0)*s,t.from[2]+r*n+i/o*(t.curve??0)*s]}function n1(t){if(!t.target?.trim())throw new Error("ballFlight: target is required");if(De(t.from,"ballFlight.from"),De(t.to,"ballFlight.to"),!Number.isFinite(t.start)||!Number.isFinite(t.end)||t.start<0||t.end<=t.start)throw new Error("ballFlight: end must be greater than start, both finite and nonnegative");if(!Number.isFinite(t.arc??0)||(t.arc??0)<0||!Number.isFinite(t.curve??0))throw new Error("ballFlight: arc must be finite and nonnegative; curve must be finite")}function x4(t){n1(t);const e=e1(t.start,t.end,t.every),n=e.map(s=>_h(t,s));return["x","y","z"].map((s,i)=>({id:`${t.id??"flight"}-${s}`,target:t.target,property:s,keyframes:e.map((r,o)=>({time:r,value:n[o][i]}))}))}const Yi=Object.freeze({"front-foot":Object.freeze({name:"Front-foot review",summary:"A fixed side view of the landing front foot and bowler’s popping crease at release."}),"striker-crease":Object.freeze({name:"Striker crease",summary:"A fixed side view of the striker’s popping crease, wicket and keeper arrival."}),"bowler-crease":Object.freeze({name:"Bowler crease",summary:"A fixed side view of the other crease and wicket for a running batter and return throw."})});function Hh(t){return Object.prototype.hasOwnProperty.call(Yi,t)}function Ko(t,e){if(!Hh(e))return;const n=i=>t.events.find(r=>r.id===i),s=e==="front-foot"?n("release"):e==="bowler-crease"?t.action==="run-out"?n("wicket"):n("run")??n("release"):(t.action!=="run-out"?n("wicket"):void 0)??n("run")??n("keeper")??n("return")??t.events.find(i=>i.kind==="contact");if(s){if(!Number.isFinite(s.time)||s.time<0||s.time>t.duration)throw new Error("cricketCameraReview: event time must be within the clip");return{...s}}}function Xo(t,e,n){const s=Oh(t.scene,e),i=Qy(s);for(const r of t.timeline.tracks){if(r.target!==t.scene.id+"/"+e)continue;if(!("keyframes"in r))throw new Error("cricketCamera: review requires baked actor tracks");const o=new Xe(r).getValueAtTime(n);if(typeof o!="number"||!Number.isFinite(o))continue;const a=["x","y","z"].indexOf(r.property);a>=0?i.position[a]=o:i.pose[r.property]=o}return{actor:s,sample:i}}function s1(t){const e=Ko(t,"front-foot");if(!e)throw new Error("cricketCamera: front-foot view requires a release event");const{actor:n,sample:s}=Xo(t,"bowler",e.time);return{point:Hs(n,s,"leg.right",2),height:n.who.height}}function i1(t,e){const n=e==="striker-crease"?"striker":"bowler",s=t.landmarks[n+"-crease"];return De(s,"cricketCamera.crease"),[...s]}function T4(t,e){if(!Hh(e))return[];const n=i1(t,e),s=e==="front-foot"?s1(t).point[0]:0;return[{id:"decision-review-"+e,name:Yi[e].name+": crease reference",kind:"line",color:"#f4b83f",width:.035,points:[[s-1.1,.045,n[2]],[s+1.1,.045,n[2]]]}]}function Rh(t,e,n,s){const i=e*Math.PI/180,r=n*Math.PI/180;return[t[0]+s*Math.cos(r)*Math.sin(i),t[1]+s*Math.sin(r),t[2]+s*Math.cos(r)*Math.cos(i)]}const Lh=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n,t[2]+(e[2]-t[2])*n];function E4(t,e,n){const s={target:[0,0,0],yaw:0,pitch:15,distance:8,...t},i={...s,...e},r=Lh(s.target,i.target,n),o=s.position||i.position?Lh(s.position??Rh(s.target,s.yaw,s.pitch,s.distance),i.position??Rh(i.target,i.yaw,i.pitch,i.distance),n):Rh(r,s.yaw+(i.yaw-s.yaw)*n,s.pitch+(i.pitch-s.pitch)*n,s.distance+(i.distance-s.distance)*n),a=Lh(s.lookAt??s.target,i.lookAt??i.target,n),l=s.fov!==void 0||i.fov!==void 0?(s.fov??i.fov)+((i.fov??s.fov)-(s.fov??i.fov))*n:void 0;return{position:o,lookAt:a,fov:l}}function A4(t){const e=Math.max(1,t.every??33),n=Wt(t.easing??"ease-in-out"),s=`${t.scene}/${t.camera}`,i=[],r=[],o=[];for(let l=t.start;;l=Math.min(t.end,l+e)){const c=t.end>t.start?n((l-t.start)/(t.end-t.start)):1,h=E4(t.from,t.to,c);if(i.push({time:l,value:h.position}),r.push({time:l,value:h.lookAt}),h.fov!==void 0&&o.push({time:l,value:h.fov}),l>=t.end)break}const a=[{id:`${s}-move-position`,target:s,property:"position",keyframes:i},{id:`${s}-move-lookAt`,target:s,property:"lookAt",keyframes:r}];return o.length>0&&a.push({id:`${s}-move-fov`,target:s,property:"fov",keyframes:o}),a}function P4(t){const e=Math.max(1,t.every??33),n=t.offset??[0,2,6],s=t.lag??0,i=`${t.scene}/${t.camera}`,r=[],o=[];for(let a=t.start;;a=Math.min(t.end,a+e)){const l=t.subjectAt(a),c=t.subjectAt(Math.max(t.start,a-s));if(r.push({time:a,value:[c[0]+n[0],c[1]+n[1],c[2]+n[2]]}),o.push({time:a,value:l}),a>=t.end)break}return[{id:`${i}-follow-position`,target:i,property:"position",keyframes:r},{id:`${i}-follow-lookAt`,target:i,property:"lookAt",keyframes:o}]}const Go=Object.freeze({pitch:"Whole pitch",batter:"Batter close-up",bowler:"Bowler close-up",keeper:"Keeper close-up",field:"Whole ground",overhead:"Overhead ground",orbit:"360° ground orbit","follow-ball":"Follow the ball",...Object.fromEntries(Object.entries(Yi).map(([t,e])=>[t,e.name]))}),Uo=Object.freeze({pitch:75,batter:145,bowler:35,keeper:145,field:75,overhead:75,orbit:75,"follow-ball":75,"front-foot":90,"striker-crease":90,"bowler-crease":90});function r1(t,e="pitch"){const n=ge(Go,e,"cricketCamera.view");if(Hh(n)){const i=i1(t,n);if(n==="front-foot"){const c=s1(t);return{target:[c.point[0],.12,(c.point[2]+i[2])/2],pitch:25,distance:Math.max(2.2,2.6*c.height/1.78),fov:40}}const r=t.landmarks[n==="striker-crease"?"striker-wicket":"bowler-wicket"];De(r,"cricketCamera.wicket");let o=(i[2]+r[2])/2,a=4;if(t.action==="run-out"&&n==="bowler-crease"||t.action==="running"){const c=Ko(t,n);if(c){const u=Xo(t,n==="bowler-crease"?"batter":"non-striker",c.time).sample.position;o=(Math.min(i[2],r[2],u[2])+Math.max(i[2],r[2],u[2]))/2,a=Math.max(4,Math.abs(r[2]-u[2])*1.8)}}let l=0;if(n==="striker-crease"&&t.action==="wide"){const c=Ko(t,n);if(c){const h=Xo(t,"keeper",c.time).sample.position,u=Xo(t,"batter",c.time).sample.position,d=Math.min(i[0],r[0],h[0],u[0]),f=Math.max(i[0],r[0],h[0],u[0]),p=Math.min(i[2],r[2],h[2],u[2]),g=Math.max(i[2],r[2],h[2],u[2]);l=(d+f)/2,o=(p+g)/2,a=Math.max(4,Math.hypot(f-d,g-p)*1.8)}}return{target:[l,.42,o],pitch:12,distance:a,fov:44}}if(n==="follow-ball"){const i=t.scene.objects.find(r=>r.id==="camera"&&r.kind==="camera");return{pitch:Math.atan2(3,Math.hypot(5,6))*180/Math.PI,distance:Math.sqrt(70),fov:i?.kind==="camera"&&i.projection==="perspective"?i.fov:48}}const s=n==="field"||n==="overhead"||n==="orbit";return{target:n==="batter"?[.1,.85,9.3]:n==="bowler"?[.68,1,-9.55]:n==="keeper"?[0,.7,10.1]:[0,.65,0],distance:s?t.boundaryRadius*2.8:n==="pitch"?29:4.3,pitch:n==="overhead"?89:s?52:n==="pitch"?16:12,fov:s?48:n==="pitch"?50:46}}function Fh(t,e,n,s){if(t!==void 0&&(!Number.isFinite(t)||t<e||t>n))throw new Error("cricketCamera: "+s+" must be between "+e+" and "+n)}function $4(t,e={}){const n=ge(Go,e.view??"pitch","cricketCamera.view"),s=e.yaw??Uo[n];if(!Number.isFinite(s))throw new Error("cricketCamera: yaw must be finite");const i=(s%360+360)%360,r=e.zoom??1;if(!Number.isFinite(r)||r<.25||r>4)throw new Error("cricketCamera: zoom must be between 0.25 and 4");const o=g=>r===1?g:Math.atan(Math.tan(g*Math.PI/360)/r)*360/Math.PI,a=e.every??40;if(!Number.isFinite(a)||a<16||a>1e3)throw new Error("cricketCamera: every must be between 16 and 1000 ms");if(Fh(e.pitch,0,89,"pitch"),Fh(e.distance,.5,2e3,"distance"),Fh(e.fov,10,100,"fov"),e.target!==void 0&&(De(e.target,"cricketCamera.target"),n==="follow-ball"))throw new Error("cricketCamera: target override is not supported by follow-ball");const l=r1(t,n),c=e.pitch??l.pitch,h=e.distance??l.distance,u=o(e.fov??l.fov),d=e.target?[...e.target]:l.target??[0,0,0],f=t.scene.id+"/camera",p=g=>{if(e.distance===void 0&&e.target===void 0)return g;const m=g.find(k=>k.property==="position");if(!m||!("keyframes"in m))return g;const y=t.scene.objects.find(k=>k.id==="camera"&&k.kind==="camera");let v=y?.kind==="camera"?Math.max(600,y.far):600;for(const k of m.keyframes)v=Math.max(v,Math.hypot(...k.value)+t.boundaryRadius+10);if(!Number.isFinite(v))throw new Error("cricketCamera: framing exceeds finite camera range");return[...g,{id:f+"-framing-far",target:f,property:"far",keyframes:[{time:0,value:v},{time:t.duration,value:v}]}]};if(n==="follow-ball"){const g=["x","y","z"].map(w=>{const T=t.timeline.tracks.find(S=>S.target===t.scene.id+"/ball"&&S.property===w);if(!T||!("keyframes"in T)||!T.keyframes.length)throw new Error("cricketCamera: missing ball "+w+" keyframes");const A=T.keyframes;let M=0,x=new Xe({...T,keyframes:A.slice(0,2)});return S=>{const E=M;for(;M<A.length-2&&S-(T.delay??0)>A[M+1].time;)M++;return M!==E&&(x=new Xe({...T,keyframes:A.slice(M,M+2)})),x.getValueAtTime(S)}}),m=(Math.atan2(5,6)*180/Math.PI+i-Uo["follow-ball"])*Math.PI/180,y=c*Math.PI/180,v=i===Uo["follow-ball"]&&(e.pitch===void 0||e.pitch===l.pitch)&&(e.distance===void 0||e.distance===l.distance)?[5,3,6]:[Math.sin(m)*Math.cos(y)*h,Math.sin(y)*h,Math.cos(m)*Math.cos(y)*h],k=P4({scene:t.scene.id,camera:"camera",start:0,end:t.duration,every:a,offset:v,subjectAt:w=>g.map(T=>T(w))});return p([...k,{id:f+"-zoom-fov",target:f,property:"fov",keyframes:[{time:0,value:u},{time:t.duration,value:u}]}])}return p(A4({scene:t.scene.id,camera:"camera",start:0,end:t.duration,every:a,easing:"linear",from:{target:d,yaw:i,pitch:c,distance:h,fov:u},to:{yaw:n==="orbit"?i+360:i}}))}const Vo=Object.freeze({mcc:Object.freeze({name:"MCC",poppingCreaseHalfWidth:1.83,fieldingRadius:null,summary:"MCC minimum crease markings. The base Laws do not prescribe a limited-over restriction area."}),"icc-men":Object.freeze({name:"ICC men",poppingCreaseHalfWidth:7.5,fieldingRadius:27.43,summary:"ICC men: extended crease markings; ODI/T20 restriction-area arcs have a 27.43 m radius."}),"icc-women":Object.freeze({name:"ICC women",poppingCreaseHalfWidth:7.5,fieldingRadius:23,summary:"ICC women: extended crease markings; ODI/T20 restriction-area arcs have a 23 m radius."})});function I4(t){const[e,n]=t.centres,s=Math.hypot(n[0]-e[0],n[2]-e[2]),i=(n[0]-e[0])/s,r=(n[2]-e[2])/s,o=[];for(let a=0;a<2;a++){const l=a===0?n:e;for(let c=0;c<=64;c++){const h=(a+c/64)*Math.PI,u=Math.cos(h)*t.radius,d=Math.sin(h)*t.radius;o.push([l[0]+r*u+i*d,.018,l[2]-i*u+r*d])}}return o}function o1(t,e){De(e,"cricketFieldingAreaContains.point");const n=t.fieldingArea;if(n==null)return null;if(!Number.isFinite(n.radius)||n.radius<=0)throw new Error("cricketFieldingAreaContains: radius must be positive and finite");if(!Array.isArray(n.centres)||n.centres.length!==2)throw new Error("cricketFieldingAreaContains: two centres are required");const[s,i]=n.centres;De(s,"cricketFieldingAreaContains.centre"),De(i,"cricketFieldingAreaContains.centre");const r=i[0]-s[0],o=i[2]-s[2],a=r*r+o*o,l=a?Math.max(0,Math.min(1,((e[0]-s[0])*r+(e[2]-s[2])*o)/a)):0;return Math.hypot(e[0]-s[0]-l*r,e[2]-s[2]-l*o)<=n.radius+1e-9}function a1(t){return Object.keys(Cs).flatMap(e=>{const n=t.scene.objects.find(i=>i.id===e&&i.kind==="character");if(!n)return[];if(n.parent)throw new Error(`cricketFieldingPositions: '${e}' must be unparented for setup markers`);const s=[...n.position??[0,0,0]];return[{id:e,name:n.name??Cs[e],position:s,inside:o1(t,s)}]})}function O4(t){return t.fieldingArea?a1(t).map(e=>({id:`fielding-review-${e.id}`,name:`${e.name}: ${e.inside?"inside":"outside"} restriction area`,kind:"line",closed:!0,width:.12,color:e.inside?"#d8eb8a":"#ee9670",points:Array.from({length:32},(n,s)=>[e.position[0]+Math.cos(s*Math.PI/16)*.7,.06,e.position[2]+Math.sin(s*Math.PI/16)*.7])})):[]}const Yt=Object.freeze({length:20.12,width:3.05,poppingCrease:1.22,returnCrease:1.32,stumpHeight:.711,wicketWidth:.2286});function l1(t){if(!t.id?.trim())throw new Error("cricketPlayer: id is required");ge({batter:1,bowler:1,keeper:1,fielder:1,umpire:1},t.role,"cricketPlayer.role");const e=ge(Li,t.preset??"youngMan","cricketPlayer.preset"),n=ge(We,t.format??"t20","cricketPlayer.format"),s=ge({none:1,cap:1,"sun-hat":1},t.headwear??"none","cricketPlayer.headwear"),i=e==="childBoy"||e==="childGirl",r=t.height??(i?1.24:1.78);if(!Number.isFinite(r)||r<.5||r>3)throw new Error("cricketPlayer: height must be between .5 and 3 metres");De(t.position??[0,0,0],"cricketPlayer.position");const o=t.role==="umpire"?"#f5ebd5":n==="test"?"#f5f0df":t.color??"#3577b5",a=JSON.parse(JSON.stringify({...Li[e],...t.appearance,outfit:rm("casual",{top:"shirt",shirt:o,trousers:t.role==="umpire"?"#405058":o,bottom:"trousers",trouserStyle:"plain",sleeves:"short",collar:!0,tie:null,shoes:"boots",shoeColor:"#f3ead7"}),hat:s==="none"?null:{style:s==="sun-hat"?"sunHat":"cap",color:o}}));return{id:t.id,name:t.role,kind:"character",look:"pen",height:r,position:[...t.position??[0,0,0]],character:a,pose:t.role==="batter"?Zy():{turn:t.role==="keeper"?2:0}}}function Jo(t,e,n,s,i=0){return{id:t,kind:"mesh",position:e,geometry:{type:"box",size:n},material:s,layer:i}}function C4(t,e){const n=Yt.stumpHeight,s=(Yt.wicketWidth-.036)/2;return[...[-1,0,1].map((i,r)=>({id:`${t}-stump-${r}`,kind:"mesh",position:[i*s,n/2,e],geometry:{type:"cylinder",radius:.018,height:n,segments:10},material:"wicket"})),...[-1,1].map((i,r)=>Jo(`${t}-bail-${r}`,[i*s/2,n+.015,e],[.105,.025,.035],"bail"))]}function c1(t,e){return[{id:t,kind:"group",scale:e,visible:!1},Jo(`${t}-grip`,[0,.1,0],[.036,.28,.036],"bat-grip"),Jo(`${t}-blade`,[0,.51,0],[.108,.54,.055],"bat-blade"),Jo(`${t}-label`,[0,.41,.029],[.07,.16,.004],"bat-label")].map((s,i)=>i===0?s:{...s,parent:t})}function Nh(t={}){const e=ge(We,t.format??"t20","cricketField.format"),n=ge(Ph,t.cast??"adults","cricketField.cast"),s=ge(Vo,t.markingProfile??"icc-men","cricketField.markingProfile"),i=Vo[s],r=t.boundaryRadius??64;if(!Number.isFinite(r)||r<24||r>250)throw new Error("cricketField: boundaryRadius must be between 24 and 250 metres");const o=t.id??"cricket";if(!o.trim())throw new Error("cricketField: id is required");const a=Yt.length/2,l=e!=="test"&&i.fieldingRadius!==null?{radius:i.fieldingRadius,centres:[[0,0,-a],[0,0,a]]}:null,c={"striker-wicket":[0,0,a],"bowler-wicket":[0,0,-a],"striker-crease":[0,0,a-Yt.poppingCrease],"bowler-crease":[0,0,-a+Yt.poppingCrease]},h=[{id:"camera",kind:"camera",projection:"perspective",position:[25,9,6],lookAt:[0,.65,0],fov:48,near:.02,far:Math.max(600,r*4)},{id:"sun",kind:"light",light:"directional",position:[4,8,5],intensity:.8,color:"#fff2dd"},{id:"ambient",kind:"light",light:"ambient",intensity:.85,color:"#eaf6f4"},{id:"outfield",kind:"mesh",layer:-4,position:[0,-.04,0],geometry:{type:"cylinder",radius:r+1,height:.06,segments:80},material:"grass"},{id:"square",kind:"mesh",layer:-3,geometry:{type:"plane",size:[8,25]},position:[0,.003,0],material:"square"},{id:"pitch",kind:"mesh",layer:-2,geometry:{type:"plane",size:[Yt.width,Yt.length]},position:[0,.008,0],material:"pitch"},{id:"boundary",kind:"line",layer:-1,closed:!0,width:.15,color:"#f8f2db",points:Array.from({length:96},(p,g)=>[Math.cos(g*Math.PI/48)*r,.022,Math.sin(g*Math.PI/48)*r])}];l&&h.push({id:"fielding-circle",kind:"line",layer:-1,closed:!0,width:.06,color:"#d6e4c8",points:I4(l)});for(const p of[-1,1]){const g=p>0?"striker":"bowler",m=p*a,y=m-p*Yt.poppingCrease;h.push(...C4(g,m));const v=(k,w)=>h.push({id:`${g}-${k}`,kind:"line",layer:-1,color:"#fffdf0",width:.045,points:w});v("popping-line",[[-i.poppingCreaseHalfWidth,.02,y],[i.poppingCreaseHalfWidth,.02,y]]),v("bowling-line",[[-1.32,.02,m],[1.32,.02,m]]);for(const k of[-1,1])v(`return-line-${k<0?"left":"right"}`,[[k*1.32,.02,y],[k*1.32,.02,m+p*2.5]])}const u=[["batter","batter",[-.38,0,9.3]],["non-striker","batter",[-.85,0,-9.3]],["bowler","bowler",[.68,0,-17]],["keeper","keeper",[0,0,11.25]],["fielder","fielder",[12,0,-3]],["slip","fielder",[3.5,0,12]],["point","fielder",[20,0,6]],["cover","fielder",[22,0,-16]],["mid-off","fielder",[9,0,-25]],["mid-on","fielder",[-9,0,-25]],["square-leg","fielder",[-20,0,7]],["fine-leg","fielder",[-20,0,35]],["third-man","fielder",[23,0,35]],["umpire","umpire",[0,0,-12.4]],["square-umpire","umpire",[-15,0,8.84]]];u.forEach(([p,g,m],y)=>{const v=n==="children"||n==="mixed"&&y%3===0,k=n==="men"?"youngMan":v?y%2?"childGirl":"childBoy":y%2?"youngWoman":"youngMan",w=Math.hypot(m[0],m[2]),T=w>r*.88?[m[0]*r*.88/w,0,m[2]*r*.88/w]:[...m];c[p]=[...T];const A=l1({id:p,role:g,preset:k,format:e,position:T,color:g==="batter"?t.battingColor??"#397cb9":t.fieldingColor??"#bf604e"});if(Object.hasOwn(Cs,p)&&(A.name=Cs[p]),p!=="batter"){const M=p==="non-striker"||p==="bowler"?u[0][2]:u.find(([x])=>x==="bowler")[2];A.pose={turn:_s(T,M)}}h.push(A)});const d=p=>h.find(g=>g.id===p).height/1.78;h.push(...c1("bat",d("batter")),...c1("non-striker-bat",d("non-striker"))),h.push({id:"ball",kind:"mesh",position:[0,.075,0],geometry:{type:"sphere",radius:.075,segments:12},material:"ball"}),h.push({id:"lbw-guide",kind:"group",visible:!1},{id:"lbw-projection",kind:"line",parent:"lbw-guide",points:[[0,0,0],[0,1,0]],width:.04,color:"#e9ae38"});const f=p=>({color:p,shading:"toon",outline:{color:"#69513a",width:.8}});return{format:e,boundaryRadius:r,landmarks:c,markingProfile:s,fieldingArea:l,scene:{id:o,formatVersion:1,camera:"camera",background:{top:"#c8e5ef",bottom:"#e9efcc"},ground:0,objects:h,materials:{grass:{color:"#81a95c",shading:"unlit"},square:{color:"#a6b76a",shading:"unlit",doubleSided:!0},pitch:{color:"#ddbd85",shading:"unlit",doubleSided:!0},wicket:f("#edd99e"),bail:f("#bd8c4d"),"bat-grip":f("#385b5c"),"bat-blade":f("#e8c58d"),"bat-label":f("#c34d4c"),ball:{color:e==="test"?"#b32d36":"#fff9e7",shading:"toon",outline:{color:"#9b3840",width:1}}}}}}const Kt=1900,Ki=2450,Et=2900,Xi=4100,fn=4200,Rs=4600,Zo=5300,Wh=5500;function Qo(t,e,n,s,i,r,o=t.object.pose?.turn??0){const a=_t(e,n,s),l=Zs(i,r),c=_s(i,r,o),h=o+(c-o)*Ft(_t(e,n,n+200)),u={...lt,...t.object.pose,turn:h},d=so("run",t.who.height,1,t.object.character?.legLength??1),f=no("run",l*a/d,u),p=Math.min(a*12,(1-a)*12,1);return{position:bn(i,r,a),pose:Yo(u,f,Math.max(0,p))}}function Dh(t,e,n){const s=(t.pose.turn??0)*Math.PI/2;return Tt(t.position,[Math.sin(s)*e,n,Math.cos(s)*e])}function _4(t,e,n,s,i){const r=`${e}/${n.object.id}`,o={...lt,...n.object.pose},a=new Set(i.flatMap(l=>Object.keys(l.pose)));for(const l of a){const c=o[l]??0;i.some(h=>h.pose[l]!==c)&&t.push({id:`${n.object.id}-${l}`,target:r,property:l,keyframes:s.map((h,u)=>({time:h,value:i[u].pose[l]??c}))})}for(const[l,c]of["x","y","z"].entries())i.some(h=>h.position[l]!==(n.object.position?.[l]??0))&&t.push({id:`${n.object.id}-${c}`,target:r,property:c,keyframes:s.map((h,u)=>({time:h,value:i[u].position[l]}))});if(i[0].bat){const l=n.object.id==="batter"?"bat":"non-striker-bat",c=`${e}/${l}`;t.push({id:`${l}-visible`,target:c,property:"visible",keyframes:[{time:0,value:1}]}),t.push({id:`${l}-position`,target:c,property:"position",keyframes:s.map((h,u)=>({time:h,value:[...i[u].bat.grip]}))}),t.push({id:`${l}-rotation`,target:c,property:"quaternion",interpolation:"slerp",keyframes:s.map((h,u)=>({time:h,value:t1(i[u].bat.axis)}))})}}function H4(t,e){const n={runs:0,extras:0,wickets:0,legalBall:!0,freeHitNext:!1};t==="running"&&(n.runs=1),t==="four"&&(n.runs=4),t==="six"&&(n.runs=6),(t==="wide"||t==="no-ball")&&(n.extras=1,n.legalBall=!1),t==="no-ball"&&(n.freeHitNext=We[e].freeHitAfterNoBall);const i={catch:"caught",bowled:"bowled",lbw:"lbw",stumping:"stumped","run-out":"run-out"}[t];return i&&(n.wickets=1,n.dismissal=i),n}function h1(t,e={}){return u1(t,e)}function u1(t,e,n){const s=ge(Wn,e.action??"bowling","cricketAction.action"),i=n?n.delivery.legality==="no-ball":s==="no-ball",r=n?n.delivery.legality==="wide":s==="wide",o=n?n.delivery.style==="spin":s==="spin";ge(We,t.format,"cricketAction.format");const a=n?.result??H4(s,t.format),l=e.duration??6e3;if(!Number.isFinite(l)||l<4e3||l>6e4)throw new Error("cricketAction: duration must be between 4000 and 60000 ms");const c=t.scene.id;for(const $ of["ball","bat","non-striker-bat","lbw-guide","striker-bail-0","striker-bail-1","bowler-bail-0","bowler-bail-1"])if(!t.scene.objects.some(C=>C.id===$))throw new Error(`cricketAction: required equipment '${$}' is missing`);const h=Object.fromEntries(["batter","non-striker","bowler","keeper","fielder","umpire"].map($=>[$,Oh(t.scene,$)]));for(const $ of["slip","point","cover","mid-off","mid-on","square-leg","fine-leg","third-man","square-umpire"])t.scene.objects.some(C=>C.id===$&&C.kind==="character")&&(h[$]=Oh(t.scene,$));const u=$=>h[$].who.height,d=$=>Qy(h[$]),f=$=>Math.round($*6e3/l*1e9)/1e9,p=$=>$*l/6e3,g=["batting","defend","running","four","six","catch","fielding","throw","run-out"].includes(s),m=["bowling","spin","no-ball","stumping"].includes(s),y=["catch","fielding","throw","run-out","batting","running"].includes(s),v=s==="running"||s==="run-out",k=new Map,w=[d("bowler").position[0],0,i?-8.25:-9.55],T=s==="fielding"?[10.5,0,2]:[9,0,-1],A=d("fielder").position,M=($,C)=>{let z=k.get($);z||(z=new Map,k.set($,z));const X=z.get(C);if(X)return X;const N=h[$];let F=d($);if($==="bowler"){const D=F.position;if(C<1400){const G=Tt(w,[0,0,-.65]);F=Qo(N,C,0,1400,D,G),F.pose["arm.right.swing"]=45,F.pose["arm.right.elbow"]=80}else F.position=C<=Kt?bn(Tt(w,[0,0,-.65]),w,Ft(_t(C,1400,Kt))):Tt(w,[0,0,.8*Ft(_t(C,Kt,2600))]),F.pose=Ch(C,[[1400,{turn:0,"arm.right.swing":285,"arm.right.elbow":8,"arm.left.swing":115,"leg.right.swing":15,"leg.left.knee":45}],[1800,{turn:0,"arm.right.swing":180,"arm.right.elbow":0,"arm.left.swing":80,"leg.right.swing":25,"leg.right.knee":0,"leg.left.swing":-25,"leg.left.knee":60}],[Kt,{turn:0,lean:8,"arm.right.swing":155,"arm.right.elbow":0,"arm.left.swing":45,"leg.right.swing":25,"leg.right.knee":0,"leg.left.swing":-25,"leg.left.knee":60}],[2250,{turn:0,lean:26,bend:12,"arm.right.swing":40,"arm.right.elbow":0,"arm.left.swing":-35,"leg.left.swing":-35,"leg.left.knee":55}],[3e3,{turn:0,"head.turn":10}],[6e3,{turn:0,"head.turn":10}]]);o&&(F.pose={...F.pose,"arm.right.spread":18,"head.tilt":-5});for(const[G,q]of Object.entries(C<Kt?St.hold:St.open))F.pose[`hand.right.${G}`]=q}else if($==="batter"||$==="non-striker"){const D=u($);if(s==="lbw"&&$==="batter"&&(F.position[0]=0),s==="stumping"&&$==="batter"&&(F.position[2]-=1.1*Ft(_t(C,2150,2800))),v&&C>3050){const G=M($,3050),q=$==="batter"?[1,0,-9.5]:[-1,0,9.5];F=Qo(N,C,3050,s==="run-out"?6e3:Wh,G.position,q,G.pose.turn);const tt=ji(N,F,"right");F.bat={grip:tt,axis:Jt([.7,-.35,.5]),scale:D/1.78}}else{F.pose={...F.pose,...$==="batter"?Zy():{turn:.15,"leg.left.knee":8,"leg.right.knee":8}};let q=[0,-1,$==="batter"?.05:.12],Z=Tt(F.position,[D*.15,D*.44,D*.04]);if($==="non-striker"&&(Z=Tt(F.position,[D*.08,D*.44,D*.17])),$==="batter"){const tt=Ft(_t(C,2100,2600))*(1-Ft(_t(C,2600,Et))),R=Ft(_t(C,2600,Et))*(1-Ft(_t(C,Et,3800))),U=Ft(_t(C,Et,3250))*(1-Ft(_t(C,3250,4e3)));if(g){Z=Tt(F.position,[D*(.15+.03*tt-.02*R-.03*U),D*(.44+.14*tt+.07*R+.23*U),D*(.04+.16*tt-.12*R-.06*U)]),q=Jt([.15*tt+.25*U,-1+1.85*tt+1.6*U,.05+.55*tt-.4*R-.8*U]),F.pose.turn=1+.12*R+.3*U,F.pose.lean=3+4*R;const nt=12+4*R;F.pose["leg.left.spread"]=nt,F.pose["leg.right.spread"]=nt,s==="defend"&&(q=[0,-1,-.08],Z=Tt(F.position,[D*.1,D*.5,-D*.12]))}else if(["stumping","bowled","lbw"].includes(s)){const nt=Ft(_t(C,2100,2700))*(1-Ft(_t(C,4e3,4500)));q=Jt([.15*nt,-1+1.85*nt,.05+.55*nt]),Z=Tt(F.position,[D*(.15+.03*nt),D*(.44+.14*nt),D*(.04+.16*nt)])}}F=M4(N,F,Z,q)}}else if($==="keeper"){F.pose={...F.pose,turn:_s(F.position,d("bowler").position,2),lean:20,"leg.left.swing":22,"leg.right.swing":22,"leg.left.knee":50,"leg.right.knee":50},r&&(F.position[0]=2.15*Ft(_t(C,2900,3500))),s==="stumping"&&(F.position[2]-=.85*Ft(_t(C,3400,3900)));const D=Dh(F,u($)*.27,u($)*.44);if(s==="stumping"&&C>=3500){const G=Dh({...F,position:d($).position},u($)*.27,u($)*.44),q=[0,Yt.stumpHeight,Yt.length/2],Z=bn(G,q,Ft(_t(C,3500,3900)));F=dn(N,F,"right",Z),F=dn(N,F,"left",Tt(Z,[.045,0,0]))}else F=dn(N,F,"right",D),F=dn(N,F,"left",Tt(D,[.045,0,0]))}else if($==="fielder"&&y){if(F=Qo(N,C,3050,s==="catch"?3800:3950,A,T),C>=3800){const D={...lt,turn:_s(T,d("batter").position,F.pose.turn),lean:s==="catch"?5:42,bend:s==="catch"?0:18,"leg.left.swing":s==="catch"?0:45,"leg.right.swing":s==="catch"?0:45,"leg.left.knee":s==="catch"?0:85,"leg.right.knee":s==="catch"?0:85,smile:.7};F.pose=Yo(F.pose,D,Ft(_t(C,3800,fn)));const G=Dh(F,u($)*.22,u($)*(s==="catch"?.73:.2));if(F=dn(N,F,"right",G),F=dn(N,F,"left",Tt(G,[.035,0,0])),(s==="throw"||s==="run-out")&&C>fn){const q={...lt,turn:_s(T,s==="throw"?d("keeper").position:t.landmarks["bowler-wicket"],F.pose.turn),"arm.right.swing":225,"arm.right.elbow":60,"arm.left.spread":70,"leg.left.swing":15},Z={...q,"arm.right.swing":110,"arm.right.elbow":0,lean:15};F.pose=Ch(C,[[fn,F.pose],[4450,q],[Rs,Z],[4900,{...lt,turn:q.turn,"arm.right.swing":25,lean:22}],[6e3,{...lt,turn:q.turn}]])}}}else if($==="umpire"){let D={...lt};const G=s==="stumping"?4150:s==="run-out"?5150:s==="bowled"||s==="lbw"?3500:s==="catch"?4350:5100;if(s==="no-ball")D={...D,"arm.right.spread":90,"arm.right.elbow":0};else if(s==="wide")D={...D,"arm.right.spread":90,"arm.left.spread":90,"arm.right.elbow":0,"arm.left.elbow":0};else if(s==="six")D={...D,"arm.right.spread":180,"arm.left.spread":180,"arm.right.elbow":0,"arm.left.elbow":0};else if(s==="four")D={...D,"arm.right.spread":90-70*(.5+Math.sin((C-5100)/180)*.5),"arm.right.elbow":12};else if(["catch","bowled","lbw","stumping","run-out"].includes(s)){D={...D,"arm.right.swing":165,"arm.right.elbow":0};for(const[q,Z]of Object.entries(St.point))D[`hand.right.${q}`]=Z}if(n){const q={...lt},Z=[[0,q]];let tt=q;if(i||r){const R=i?Kt:3100;tt=i?{...q,"arm.right.spread":90,"arm.right.elbow":0}:{...q,"arm.right.spread":90,"arm.left.spread":90,"arm.right.elbow":0,"arm.left.elbow":0},Z.push([R,q],[R+350,tt])}if(a.wickets||s==="four"||s==="six"){const R=a.wickets?G:5100;let U=D;if(a.wickets){U={...q,"arm.right.swing":165,"arm.right.elbow":0};for(const[nt,at]of Object.entries(St.point))U[`hand.right.${nt}`]=at}Z.push([R,tt],[R+350,U])}F.pose=Ch(C,Z)}else F.pose=Yo(F.pose,D,Ft(_t(C,s==="no-ball"?Kt:s==="wide"?3100:G,(s==="no-ball"?Kt:s==="wide"?3100:G)+350)))}return z.set(C,F),F},x=($,C)=>ji(h[$],M($,C),"right"),S=g?S4(M("batter",Et).bat):s==="lbw"?bn(Hs(h.batter,M("batter",Et),"leg.right",1),Hs(h.batter,M("batter",Et),"leg.right",2),.6):[m?Yt.wicketWidth/2+.075+.15:0,.45,9.25],E=x("bowler",Kt),P=[r?.85:o?-.35:s==="lbw"?S[0]*.6:0,.075,3.9],I=x("keeper",s==="stumping"?3400:3500),O=x("fielder",Xi),H=x("fielder",fn),W=s==="run-out"?"bowler":"striker",j=s==="run-out"?5e3:s==="stumping"?3900:3200,J=[t.boundaryRadius*.8,s==="six"?2.1:.075,-t.boundaryRadius*.6],et=($,C,z,X,N,F=0,D=0)=>_h({target:`${c}/ball`,start:C,end:z,from:X,to:N,arc:F,curve:D},$),V=$=>{if($<=Kt)return x("bowler",$);if($<=Ki)return et($,Kt,Ki,E,P,.15,o?.35:0);const C=r?Tt(I,[0,0,-.6]):S;if($<=Et)return et($,Ki,Et,P,C,.08);if(s==="bowled"){const X=[0,.36,Yt.length/2];return $<=j?et($,Et,j,S,X):et($,j,4100,X,[0,.075,12.5],.2)}if(s==="lbw")return[...S];if(["bowling","spin","no-ball","wide","stumping"].includes(s)){const X=s==="stumping"?3400:3500;if(m&&$<=X){const N=[C[0],I[1],Yt.length/2+.2];return $<=3200?et($,Et,3200,C,N,.04):et($,3200,X,N,I,.04)}return $<=X?et($,Et,X,C,I,.04):x("keeper",$)}if(s==="defend")return et($,Et,3400,S,Tt(S,[-.5,-S[1]+.075,-.7]),.12);if(s==="four"||s==="six"){if(s==="six")return $<=5e3?et($,Et,5e3,S,J,12):et($,5e3,5700,J,Tt(J,[2,-2.025,-1.5]));const X=[5,.075,5];return $<=3300?et($,Et,3300,S,X,.5):et($,3300,5e3,X,J)}if(s==="catch")return $<=Xi?et($,Et,Xi,S,O,5):x("fielder",$);const z=[4,.075,5];if($<=3300)return et($,Et,3300,S,z,.8);if($<=fn)return et($,3300,fn,z,H);if(s==="throw"||s==="run-out"){if($<=Rs)return x("fielder",$);const X=x("fielder",Rs),N=s==="run-out"?[0,.42,-Yt.length/2]:x("keeper",Zo),F=s==="run-out"?j:Zo;return $<=F?et($,Rs,F,X,N,1.2):s==="run-out"?et($,F,5700,N,[0,.075,-12],.18):x("keeper",$)}return[...H]},L=[],B=($,C,z,X,N)=>L.push({id:$,time:p(C),kind:z,label:X,caption:N}),K=n?{bowled:"Delivery hits stumps",lbw:"Pad contact",stumping:"Keeper breaks wicket","run-out":"Throw breaks wicket"}[s]??Wn[s].name:Wn[s].name;if(B("setup",0,"setup",K,n?`${n.delivery.style} delivery · ${n.delivery.legality}${n.freeHit?" · free hit":""}. ${Wn[s].summary.replace("A legal delivery","A delivery")}`:Wn[s].summary),B("release",Kt,"release","Ball released",i?"The front foot has landed beyond the popping crease. No-ball.":"The bowler releases the ball; the front foot is behind the popping crease."),B("bounce",Ki,"bounce","Pitch bounce",o?"The curved flight is illustrative. Spin can change the ball’s path after it bounces.":"The delivery bounces on the pitch on its way to the striker."),g?B("contact",Et,"contact","Bat contact","The ball meets the blade. The bat is keyed from the same two hand grips."):s==="lbw"?B("pad-contact",Et,"contact","Pad contact",n?"The ball contacts the pad. The highlighted path is illustrative; the authored decision is resolved separately.":"The highlighted path illustrates a ball that would hit the stumps. This is an authored LBW example."):B("miss",Et,"contact",s==="wide"?"Beyond normal reach":"The batter misses",s==="wide"?"The untouched ball is too far away for a normal stroke. The umpire calls Wide.":"The untouched delivery passes the striker."),s==="catch"&&B("catch",Xi,"collect","Catch controlled",n?"The fielder controls the ball before it touches the ground. The authored decision is resolved separately.":"The fielder controls the ball before it touches the ground: caught."),["fielding","throw","run-out","batting","running"].includes(s)&&B("gather",fn,"collect","Ground ball gathered","The ball has touched the ground. Gathering it is fielding, not a catch dismissal."),["bowling","spin","wide","no-ball","stumping"].includes(s)&&B("keeper",s==="stumping"?3400:3500,"collect","Keeper gathers","The keeper controls the ball behind the striker’s wicket."),(s==="throw"||s==="run-out")&&B("throw",Rs,"throw","Throw released","The fielder releases the gathered ball toward the wicket."),s==="throw"&&B("return",Zo,"collect","Return received","The keeper receives and controls the return throw."),s==="stumping"&&B("wicket",j,"wicket",n?"Wicket broken":"Stumped","Holding the ball, the keeper removes a bail. The striker is out of ground and is not attempting a run."),s==="run-out"&&B("wicket",j,"wicket",n?"Wicket broken":"Run out","The direct throw removes a bail before the running batter makes this ground."),s==="bowled"&&B("wicket",j,"wicket",n?"Stumps hit":"Bowled",n?"The delivery hits the wicket and removes a bail. A broken wicket does not by itself decide a dismissal.":"The legal delivery hits the wicket and removes a bail."),(s==="four"||s==="six")&&B("boundary",5e3,"boundary",s==="four"?"Four runs":"Six runs",s==="four"?"The struck ball reaches the boundary after touching the ground: four.":"The struck ball clears the boundary without touching the ground: six."),s==="running"&&B("run",Wh,"result","One run completed","Both batters have reached the opposite ground. One run is completed."),B("result",5700,"result","Illustrated result",s==="no-ball"?`One no-ball extra; it does not count in the over.${a.freeHitNext?" The next legitimate delivery is a free hit.":" Test cricket has no automatic free hit."}`:s==="wide"?"One wide extra; the delivery does not count in the over.":s==="lbw"?"LBW is declared for this illustrated legal delivery. A full decision also checks pitching, impact and any bat contact.":`${a.runs} bat runs · ${a.extras} extras · ${a.wickets} wicket${a.wickets===1?"":"s"}.`),n){const $={"no-dismissal":"No dismissal was authored for this play.",dismissal:`The authored ${n.ruling.dismissal} decision is allowed in this delivery context.`,"no-ball":`Not out: ${s==="catch"?"a catch":"this dismissal"} cannot dismiss the striker on a no-ball.`,"free-hit":`Not out: ${s==="catch"?"a catch":"this dismissal"} cannot dismiss the striker on a free hit.`,wide:"Not out: this dismissal is not available from a Wide."},C=L.find(z=>z.id==="result");C.label=a.wickets?"Out":"Not out",C.caption=`${$[n.ruling.reason]} ${a.runs} bat runs · ${a.extras} extras · ${a.wickets} wickets. ${a.legalBall?"Counts as a legal ball.":"Does not count in the over."}${a.freeHitNext?" The next delivery is a free hit; an illegal delivery carries it forward.":n.freeHit?" This legal delivery consumes the free hit.":""}`}L.sort(($,C)=>$.time-C.time);const _=e1(0,l,e.every,[1400,1800,Kt,2100,2150,2250,Ki,2600,2800,Et,3050,3100,3200,3250,3300,3400,3500,3800,3900,3950,4e3,Xi,fn,4350,4450,Rs,4900,5e3,5100,5150,Zo,Wh,5700].map(p)),Y=_.map($=>V(f($))),st=[];for(const[$,C]of Object.entries(h)){let z=C.object.pose?.turn??0,X=z;const N=_.map((F,D)=>{const G=f(F);let q=$==="fielder"&&y&&G>3050&&G<3250?Qo(C,G,3050,s==="catch"?3800:3950,A,T,X):M($,G),Z=Y[D];const tt=!["batter","non-striker","bowler","keeper"].includes($);if(tt){const U=M("bowler",Math.min(G,Kt)),nt=Tt(U.position,[0,u("bowler")*.8,0]);Z=G<=Kt?nt:G<2100?bn(nt,Z,Ft(_t(G,Kt,2100))):Z}if(v&&($==="batter"||$==="non-striker")&&G>3050&&(Z=$==="batter"?[1,u($)*.8,-10.5]:[-1,u($)*.8,10.5]),$==="bowler"&&G<=Et&&(Z=Tt(M("batter",G).position,[0,u("batter")*.65,0])),tt&&($!=="fielder"||!y||G<=3050)||$==="bowler"&&G>=3e3){const U=_s(q.position,Z,z);z=$==="bowler"&&G<3500?(q.pose.turn??0)+(Ih(U,q.pose.turn??0)-(q.pose.turn??0))*Ft(_t(G,3e3,3500)):U,q={...q,pose:{...q.pose,turn:z}}}return $==="fielder"&&y&&(G===3050?X=z:G>3050&&(z=Ih(q.pose.turn??0,z),q={...q,pose:{...q.pose,turn:z}})),v4(C,q,Z)});_4(st,c,C,_,N)}for(const[$,C]of["x","y","z"].entries())st.push({id:`ball-${C}`,target:`${c}/ball`,property:C,keyframes:_.map((z,X)=>({time:z,value:Y[X][$]}))});if(["bowled","stumping","run-out"].includes(s))for(let $=0;$<2;$++){const C=`${W}-bail-${$}`,X=t.scene.objects.find(N=>N.id===C).position;st.push({id:`${C}-fall`,target:`${c}/${C}`,property:"position",keyframes:[{time:0,value:[...X]},{time:p(j),value:[...X]},{time:p(j+180),value:Tt(X,[$?.25:-.25,.22,W==="striker"?.22:-.22]),easing:"ease-out"},{time:p(j+650),value:[X[0]+($?.4:-.4),.035,X[2]+(W==="striker"?.45:-.45)],easing:"ease-in"}]}),st.push({id:`${C}-spin`,target:`${c}/${C}`,property:"rotateZ",keyframes:[{time:0,value:0},{time:p(j),value:0},{time:p(j+650),value:$?145:-145}]})}if(s==="lbw"){const $=[S[0]*.8,S[1],Yt.length/2],C=se($,S);st.push({id:"lbw-position",target:`${c}/lbw-guide`,property:"position",keyframes:[{time:0,value:[...S]}]},{id:"lbw-rotation",target:`${c}/lbw-guide`,property:"quaternion",interpolation:"slerp",keyframes:[{time:0,value:t1(C)}]},{id:"lbw-length",target:`${c}/lbw-guide`,property:"scaleY",keyframes:[{time:0,value:Zs(S,$)}]},{id:"lbw-visible",target:`${c}/lbw-guide`,property:"visible",keyframes:[{time:0,value:0},{time:p(Et)-.001,value:0},{time:p(Et),value:1}]})}return{action:s,duration:l,events:L,result:a,timeline:{id:`${c}-${s}`,formatVersion:2,name:K,config:{duration:l,markers:L.map($=>({id:$.id,time:$.time,label:$.label}))},captions:{en:Object.fromEntries(L.map($=>[$.id,$.caption]))},tracks:st}}}function R4(t={}){const e=Nh(t);return{...e,...h1(e,t)}}function L4(t,e){if(!Number.isFinite(e))throw new Error("cricketEventAt: time must be finite");let n;for(const s of t){if(s.time>e)break;n=s}return n}const gn=Object.freeze({deliveryStyles:Object.freeze(["pace","spin"]),deliveryLegalities:Object.freeze(["legal","no-ball","wide"]),shots:Object.freeze(["miss","drive","defend"]),finishes:Object.freeze(["none","single","four","six","stumps","pad"]),fielding:Object.freeze(["none","keeper","catch","gather","throw","stumping","run-out"]),dismissals:Object.freeze(["caught","bowled","lbw","stumped","run-out"])});function Ls(t,e,n){if(!t.includes(e))throw new Error(`cricketPlay.${n}: unknown choice '${e}'`);return e}function F4(t){const{shot:e,finish:n,fielding:s}=t;if(t.delivery.legality==="wide"){if(e!=="miss"||n!=="none"||s!=="keeper")throw new Error("cricketPlay: Wide currently supports only an untouched delivery gathered by the keeper");return"wide"}if(e==="miss"){if(s==="none"&&n==="stumps")return"bowled";if(s==="none"&&n==="pad")return"lbw";if(n==="none"&&s==="stumping")return"stumping";if(n==="none"&&s==="keeper")return t.delivery.style==="spin"?"spin":"bowling"}if(e==="defend"&&n==="none"&&s==="none")return"defend";if(e==="drive"){if(s==="none"&&(n==="four"||n==="six"))return n;if(s==="gather"&&n==="single")return"running";if(n==="none"){if(s==="catch")return"catch";if(s==="gather")return"fielding";if(s==="throw")return"throw";if(s==="run-out")return"run-out"}}throw new Error(`cricketPlay: unsupported motion combination (${e}, ${n}, ${s})`)}function N4(t){const e=Ls(gn.shots,t.shot??"miss","shot"),n=Ls(gn.finishes,t.finish??"none","finish");let s=e==="miss"?"keeper":"gather";(e==="defend"||n!=="none")&&(s=n==="single"?"gather":"none");const i=Ls(gn.fielding,t.fielding??s,"fielding"),r=t.context?.freeHit??!1;if(typeof r!="boolean")throw new Error("cricketPlay.context.freeHit must be boolean");const o=t.decision?.dismissal??null;return o!==null&&Ls(gn.dismissals,o,"decision.dismissal"),{delivery:{style:Ls(gn.deliveryStyles,t.delivery?.style??"pace","delivery.style"),legality:Ls(gn.deliveryLegalities,t.delivery?.legality??"legal","delivery.legality")},shot:e,finish:n,fielding:i,context:{freeHit:r},decision:{dismissal:o}}}function W4(t,e){const n=t.decision.dismissal;if(!n)return{dismissal:null,reason:"no-dismissal"};if({catch:"caught",bowled:"bowled",lbw:"lbw",stumping:"stumped","run-out":"run-out"}[e]!==n)throw new Error(`cricketPlay: '${n}' decision does not match '${e}' motion`);if(n!=="run-out"){if(t.context.freeHit)return{dismissal:null,reason:"free-hit"};if(t.delivery.legality==="no-ball")return{dismissal:null,reason:"no-ball"};if(t.delivery.legality==="wide"&&n!=="stumped")return{dismissal:null,reason:"wide"}}return{dismissal:n,reason:"dismissal"}}function d1(t,e={}){const n=ge(We,t.format,"cricketPlay.format"),s=N4(e);if(s.context.freeHit&&!We[n].freeHitAfterNoBall)throw new Error("cricketPlay: Test format does not support free-hit context");const i=F4(s),r=W4(s,i),o=s.delivery.legality==="legal",a={runs:s.finish==="single"?1:s.finish==="four"?4:s.finish==="six"?6:0,extras:o?0:1,wickets:r.dismissal?1:0,legalBall:o,freeHitNext:We[n].freeHitAfterNoBall&&(s.delivery.legality==="no-ball"||s.context.freeHit&&!o),...r.dismissal?{dismissal:r.dismissal}:{}};return{...u1(t,{action:i,duration:e.duration,every:e.every},{delivery:s.delivery,result:a,ruling:r,freeHit:s.context.freeHit}),play:s,ruling:r}}function D4(t={}){const e=Nh(t);return{...e,...d1(e,t)}}const f1=Object.freeze({"no-ball-stumps":Object.freeze({name:"No-ball + stumps hit",options:Object.freeze({delivery:Object.freeze({legality:"no-ball"}),finish:"stumps",decision:Object.freeze({dismissal:"bowled"})})}),"free-hit-catch":Object.freeze({name:"Free hit + catch",options:Object.freeze({context:Object.freeze({freeHit:!0}),shot:"drive",fielding:"catch",decision:Object.freeze({dismissal:"caught"})})}),"no-ball-four":Object.freeze({name:"No-ball + four",options:Object.freeze({delivery:Object.freeze({legality:"no-ball"}),shot:"drive",finish:"four"})}),"free-hit-run-out":Object.freeze({name:"Free hit + run-out",options:Object.freeze({context:Object.freeze({freeHit:!0}),shot:"drive",fielding:"run-out",decision:Object.freeze({dismissal:"run-out"})})}),"free-hit-wide":Object.freeze({name:"Free hit + Wide",options:Object.freeze({context:Object.freeze({freeHit:!0}),delivery:Object.freeze({legality:"wide"})})})}),B4={linear:!0,"ease-in":!0,"ease-out":!0,"ease-in-out":!0,"ease-in-quad":!0,"ease-out-quad":!0,"ease-in-out-quad":!0,"ease-in-cubic":!0,"ease-out-cubic":!0,"ease-in-out-cubic":!0};function g1(t,e={}){const n={};for(const s of Object.keys(Xt))n[s]={summary:`Walks to \`to\` in the ${s} gait.`,needs:["to"]};for(const s of Object.keys(ae))n[s]={summary:`Moves into the ${s} pose and holds it (\`for\` ms).`};for(const s of Object.keys(on))n[s]={summary:`The ${s} gag (${Ni(s)} ms).`};for(const[s,i]of Object.entries(Wi))n[s]={...i};return{sports:{cricket:{actions:{...Wn},formats:{...We},casts:{...Ph},fieldingPositions:{...Cs},markingProfiles:{...Vo},cameras:{...Go},decisionCameras:Yi,playComponents:gn,playExamples:f1}},...t?{version:t}:{},timing:"JSON timelines and tracks are in milliseconds; the GSAP-style API (live.to, tf.timeline) takes seconds. Scene x grows right, y grows down, in px.",easings:{named:Object.keys(B4),parametric:{"cubic-bezier":'{ type: "cubic-bezier", points: [x1, y1, x2, y2] }',steps:'{ type: "steps", count, position?: start | end | none | both }',elastic:'{ type: "elastic", mode?: in | out | in-out, amplitude?, period? }',bounce:'{ type: "bounce", mode?: in | out | in-out }',back:'{ type: "back", mode?: in | out | in-out, overshoot? }'}},trackKinds:{keyframe:"{ id, target, property, keyframes: [{ time, value, easing? }] }: values between keys are interpolated (numbers, colours, paths)",spring:'{ id, target, property, kind: "spring", spring: { from, to, stiffness?, damping?, mass?, velocity? }, delay? }: physics settle',inertia:'{ id, target, property, kind: "inertia", inertia: { from, velocity, friction?, min?, max?, end? }, delay? }: a flick that slows (end snaps to a value or the nearest of a list)',motionPath:'{ property: "motionPath", path, align? }: moves along an SVG path',text:'{ property: "text", … }: types or scrambles text'},canvasProperties:Lo,stickFigure:{poseFields:pd,props:md,handFields:yd,poses:Object.keys(ae),expressions:Object.keys(vt),gags:Object.fromEntries(Object.keys(on).map(s=>[s,Ni(s)])),gaits:Object.keys(Xt),actingStyles:Object.keys(Ln),beatFields:Io,actions:n,dances:Object.fromEntries(Object.entries(Ze).map(([s,i])=>[s,Object.keys(i.moves)])),flips:Object.fromEntries(Object.entries(Ai).map(([s,i])=>[s,i.label])),handShapes:Object.keys(St),mudras:Object.keys(_r)},props:{api:{"car() · truck() · bus() · tractor() · cart() · trainCar() · bike() · motorbike()":"wheeled vehicles (vehicle(spec) makes your own)","tree() · house()":"environment (tree(spec), house(spec))","helicopter() · airplane()":"aircraft","horse() · dog() · cat() · cow()":"animals (quadruped(spec) makes your own): gaits with footfall patterns keyed in step with the distance, sit, jump, their calls, species actions","songbird() · crow() · chicken()":"birds (bird(spec) makes your own): hop, walk, peck, flap, fly and land (a chicken flutters), their calls; wings fold and beat in rhythm","{ kind: 'prop', prop: 'car', position, rotation, values } with loadScene3D(scene, { kinds: [characterObjects, propObjects] })":"props in 3D scenes, by preset name, seen in perspective by the scene camera; controls are tracks on the object","characterScript3D(id, beats, { scene, position?, heading?, height?, pose? })":"a v2 character in world metres: gaits, face (shortest turn), spin (signed turns and duration), dance (native style, bpm, beats), hold, pose, gag; checkCharacterBeats3D checks the beats","propRide3D({ prop, propId, propTracks, scene, placement, anchor, riderId, pose, start, end, mount?, dismount? })":"a character riding a prop in a 3D scene: hips on a seat anchor (saddle, seat) as it moves, hopping on and off; RIDING_POSES.astride / .seated / .driving / .cycling / .wheeling (a wheelchair)","propScript3D(id, prop, beats, { scene, position?, heading?, values? })":"props scripted in world metres for 3D scenes: moves to [x, z] or through points (wheels and strides keyed with the distance), face, hold, and their actions; checkPropBeats3D checks the beats","propPreset(name, options?)":"a prop preset by name (did-you-mean on a wrong one)","propTarget({ …, style: 'stick' })":"line art to go with stick figures: tubes as single strokes, shapes outlined over paper","propTow({ leader, leaderId, leaderTracks, hitch, towed, towedId, anchor, start, end })":"a prop towed by another (a cart behind a horse): turns with it, its wheels roll exactly","propTarget({ x, y, prop, scale?, values?, look?, ink? })":"a canvas target that draws a prop (x, y: its middle on the ground; scale px per metre, default 60)","propScript(id, prop, beats, { from, ground, scale, style?, exaggeration?, start? })":"beats → acted tracks, with contact times and effect cues; checkPropBeats(beats, prop) checks them","drawProp(ctx, target, frame, id, { rider? })":"draw it as it is in a frame (a rider is drawn between its far and near parts)","propAt(target, frame, id).anchor(name)":"where an anchor (seat, door, chimney…) is, in scene px","propRide({ prop, propId, propTracks, anchor, figure, figureId, start, end, offset? })":"a figure carried at an anchor, turning with the prop; spliceTracks() puts it into the figure’s tracks","drawPropEffects(ctx, effects, time)":"dust, exhaust, skid marks, honk lines, leaves, smoke"},beatFields:qo,commonControls:Object.fromEntries(Object.entries(As).map(([s,i])=>[s,`${i.description}${i.unit?` (${i.unit})`:""}`])),commonActions:Object.fromEntries(Object.entries(Eh).map(([s,i])=>[s,i.summary])),presets:Object.fromEntries(Object.entries(Os).map(([s,i])=>{const r=i();return[s,{family:r.family,summary:r.summary,actions:Object.fromEntries(Object.entries(r.actions).map(([o,a])=>[o,{summary:a.summary,...a.needs?{needs:a.needs}:{}}])),controls:Object.keys(r.rig.controls),anchors:Object.keys(r.rig.anchors??{})}]}))},custom:{api:{"defineAction({ summary, needs?, steps: (from, beat) => [{ after, pose, easing? }] })":"a new action written as timed pose steps from the current pose, like a gag","defineAction({ summary, needs?, beats: (beat) => [beats] })":"a new action built from other beats (which may be custom too)","defineGait({ swing, knee, arm, elbow, lean, cycle?, … })":"a new gait (the Gait fields in degrees; cycle is ms per two steps)","scriptTracks(id, beats, { actions, gaits })":"beats may then use those names; checkBeats(beats, { actions, gaits }) knows them","stickFigureTarget({ …, cast: { actions, gaits } })":"a figure that draws the gaits and lists the actions in describeTarget","persona({ name, summary?, height?, look?, acting?, gait?, mood?, stance?, energy?, actions?, gaits? })":"a character’s look, acting style and habits: .figure({ x, y }), .script(id, beats, { from, ground }), .check(beats), .handPath(…), .describe(); `go` walks in its gait, `stand` returns to its stance and face"},actions:Object.fromEntries(Object.entries(e.actions??{}).map(([s,i])=>[s,{summary:i.summary,...i.needs?{needs:i.needs}:{}}])),gaits:Object.fromEntries(Object.entries(e.gaits??{}).map(([s,i])=>[s,i.summary??"custom gait"]))},character:{figureStyles:["fluid","stick","organic"],body:{"body.torso · body.arm · body.leg · body.neck":"Organic half-width profiles: [{ at: 0..1, width: fractionOfHeight }], increasing from 0 to 1; independent of ink width.","body.measurements":`Organic torso from tape-measure girths { height, bust, underbust?, waist, hip } in any one unit, or a named shape (${Object.keys(Xr).join(" | ")}). Sets the front width, the side depth (bust forward, seat back, belly) and the hip and thigh spacing; reads correctly at every turn. An explicit torso / torsoFront / torsoBack / hipWidth still wins.`,"body.torsoFront · body.torsoBack":"Organic side-view depth from the spine line toward the chest/belly and toward the back/seat, same profile format; default torso × depth.","body.fill · body.outline · body.shading":"Shared skin fill, outline { color, width }, cel material { mode: cel | none, light: [x,y], shadow, opacity, highlight }.","softCartoonCharacter(name, options?)":"Original youngMan / youngWoman / childBoy / childGirl story presets. Children have larger head proportions, shorter limbs and rounded torsos; every face, hair, build, hand, clothing and material option can be overridden.","face.projection":"Organic default volume follows the head axes, keeps both eyes in three-quarter views and projects a small nose above the mouth; opaque hair covers features. cartoon keeps the classic face slide.","outfitPreset(category, overrides?)":"Fresh JSON Everyday / Formal / Casual wardrobe defaults for every actor; top: tshirt | shirt | blouse | dress, trouserStyle: plain | jeans | cargo, colours, sleeves, bottoms, collar and tie are editable.",leafOutfit:"Organic-only JSON garment { top?, color?, accent?, length? }; curved leaves follow torso/thighs at native part depths. Everyday basicOutfit also follows organic contours."},poses:Object.keys(be),dances:Object.keys(An),expressions:Object.keys($l),faceStyles:["simple","anime"],faceShapes:["round","angular"],gags:Object.keys(io),builds:Object.keys(Wr),hair:Object.keys(Ul),hairColors:{...Ae},facialHair:Object.keys(tc),glasses:Object.keys(nc),hats:Object.keys(eo),feet:[...vf],cast:Object.keys(qc),heldItems:Object.fromEntries(Object.entries(oc).map(([s,i])=>[s,i.hands])),handMeetings:Object.keys(Fi)},codePanel:{languages:Eo,removeStyles:xo,anchors:{"line(n, time?)":"line n’s text box { x, y, left, right, top, bottom, width, height }: stand on top, point at x, y","token(n, text, occurrence?, time?)":"a word on a line","spot(n, column, width?, time?)":"a place in a line, for put and write","landing(piece, n, column)":"where a dropped piece will land",box:"the whole panel"},edits:Fc},surfaces:{code:_i,board:Re,chart:Hn,prop:$s},surfaceScript:{"surfaceScript(figureId, { name: surface }, beats, options)":"compiles beats that act on surfaces: returns the script result with `tracks` (the figure’s, ridden, then every surface’s, keyed by its name) and `figureTracks`; options are scriptTracks’ plus `figureStyle` (for carry) and `ride` (default true)","checkSurfaceBeats(beats, surfaces, cast?)":"every problem checkBeats finds, plus unknown surfaces, places, edits and moments, with suggestions","{ surface, anchor }":"a named place, where a beat takes `target` (its box), `to` (its centre x) or `onto` (its top); as laid out, before any edit moves it","then: { surface, edit, anchor, at?, until?, …options }":"what the surface does in answer to the beat (or a list of them): one of its edits, or `carry` (the piece follows the hand until `until`); the other fields are the edit’s options",at:`a moment of the beat: ${Ts.join(", ")} (default contact, or start when the beat has none); not ms`,until:"a moment of this beat, or { beat: index, at? } of a later one; sets the edit’s duration (carry needs it)"},cameraShots:{frame:"{ at, duration?, easing?, frame: { focus?: { x, y }, scale?, rotate? } }: push in, pull out, or cut (duration 0)",shake:"{ at, duration, shake: { strength?, frequency?, roll?, seed? } }",follow:"{ at, until, follow: { x: <the subject’s x keyframes>, lead?, y?, lag?, scale? } }: keeps a subject centred"},teach:{"lesson({ id })":"steps as timeline JSON: to, set, together, wait, marker (with pause, question, captions)","cells, pointer, stack, queue, table, pipeline":"diagram primitives (SVG markup + step helpers)","figure({ width, height, children })":"the SVG holding the pieces"},math:{api:{"mathFigure(spec)":"checks a figure (JSON: width, height, x?, y?, theme?: dark | light | chalk, values, items) and says how to fix it","layoutFigure(spec, props)":"the figure at some values as shapes; drawDisplayList(ctx, list) or displayListToSvg(list) draws them","mathTarget(spec, { x, y })":"a canvas target for videos and canvas pages; tracks animate its values and item props","mathSteps(lesson, target, spec, { hidden })":"lesson steps: toValue, applyMatrix, drawOn, fadeIn, fadeOut, showStep (equations)","mountMath(element) / mountAllMath()":"lesson-page embeds: <figure data-tinyfly-math> with data-tinyfly-figure and data-tinyfly-timeline JSON scripts, stepped like any embed","mathExplorable(element, spec, { sliders, drag })":"reader-driven figures: sliders on number values, drag vector tips or matrix columns","mathFigureToSvg(spec, props)":"a standalone SVG of a figure at some values","linearMapFigure, determinantFigure, eigenFigure, vectorSumFigure, spanFigure":"ready linear algebra figures; the matrix is the value M","tangentFigure, secantFigure, riemannFigure, areaFigure, taylorFigure, limitFigure":"ready calculus figures; their moving parts are number values (a, h, n, b, order, p)","differentiate / compileDerivative / integrate":"exact symbolic derivatives of expressions; Simpson integration","layoutTex(tex) / morphEquation(a, b, t)":"the built-in TeX subset, and term-by-term transitions","vec2, mat2":"2D vectors and 2×2 matrices (apply, multiply, determinant, inverse, eigen)"},items:{grid:"{ step?, transform?: matrix value, ghost? }: lines of the plane, warped by a matrix",axes:"{ ticks?, labels? }",vector:"{ to, from?, transform?, label? (TeX), labelAt?: tip | middle }",basis:"{ transform? }: î and ĵ",point:"{ at, transform?, label?, hollow? } or { on: expr, x } (a point riding a curve)",function:'{ expr: "sin(k x)", domain?, derivative?, dashed? }: y = f(x); number values are its parameters',parametric:"{ x, y (expressions in t), t?, transform? }",polygon:"{ points? (default the unit square), transform?, label? }: \\val{M.det} shows the determinant",line:"{ along } or { eigen: matrix value }: a span, or eigenlines",label:"{ tex, at, screen?, size?, align?, backdrop? }",equation:"{ steps: [TeX…], at, screen? }: ITEM.step moves between steps, terms gliding",tangent:"{ expr, at, h? (secant), label? }: \\val{ID.slope} is the exact slope",riemann:"{ expr, from, to, n, rule?: left | right | midpoint | trapezoid }: \\val{ID.sum}, \\val{ID.exact}",area:"{ expr, from, to, lower? }: signed, coloured by sign; \\val{ID.value}",taylor:"{ expr, at, order }: exact Taylor polynomials; a fractional order grows the next term in"},props:{NAME:"a value: a number, [x, y] vector or [a, b, c, d] matrix (row by row; columns are where î and ĵ land)","ITEM.draw":"0..1, draws an item on","ITEM.opacity":"0..1","ITEM.step":"an equation's step; fractional values are part way"},functions:["sin","cos","tan","asin","acos","atan","atan2","sinh","cosh","tanh","exp","ln","log","log2","sqrt","abs","floor","ceil","round","sign","min","max","sigmoid","relu"],tex:"^ _ \\frac \\sqrt \\vec \\hat \\bar, \\sum \\prod \\int with limits, \\sin \\lim … , Greek, \\cdot \\times \\le \\to \\infty …, pmatrix / bmatrix / vmatrix, \\text, \\color{c}{…}, \\id{name}{…} (names a term for transitions), \\val{name:digits} (a live value)"},cli:{"tinyfly capabilities [--json]":"this catalog","tinyfly check <beats.json>":"check a beat script (names, fields) with suggestions","tinyfly validate <timeline.json> [--markup file]":"check a timeline against its markup","tinyfly render <timeline.json> <markup> [--at …]":"a frame as static markup","tinyfly video <scene.mjs> [--stills dir --times …]":"MP4, or PNG stills to look at"}}}const yt=t=>t.map(e=>`\`${e}\``).join(", "),p1=t=>Object.entries(t).map(([e,n])=>`| \`${e}\` | ${n.unit??n.kind??""} | ${n.description} |`).join(`
63
+ `);function z4(t,e={}){const n=g1(t,e),s=n.stickFigure;return[`# tinyfly capabilities${n.version?` (v${n.version})`:""}`,"","Generated from the library itself: every name below is accepted, and names not listed are rejected (beat scripts, code panels and `checkTracks` say which name was probably meant).","",`**Timing.** ${n.timing}`,"","## Easings","",`Named: ${yt(n.easings.named)}.`,"",...Object.entries(n.easings.parametric).map(([r,o])=>`- ${r}: \`${o}\``),"","## Track kinds","",...Object.entries(n.trackKinds).map(([r,o])=>`- **${r}**: ${o}`),"","## Canvas targets","","Types: `rect`, `circle`, `text`, `line`, `path`, `image`, `custom`. `describeTarget(target)` lists what one can animate with its values; `checkTracks(tracks, targets)` checks tracks before playing them.","","| Property | Unit | What it does | Types |","|---|---|---|---|",...Object.entries(n.canvasProperties).map(([r,o])=>`| \`${r}\` | ${o.unit??o.kind??""} | ${o.description} | ${o.types.length===7?"all":o.types.join(", ")} |`),"","## Stick figure (`@algorisys/tinyfly/characters`)","","`stickFigureTarget({ x, y, style })` is a custom canvas target; its props are the pose fields and the props below. Pose it with tracks (`poseTracks`), or write beats (`scriptTracks`).","","Style proportions: `headSize` is a fraction of height; `armLength` multiplies both upper arm and forearm lengths (default 1, positive finite). Hands, shoulders, torso and legs retain their sizes.","","### Pose fields","","| Field | Unit | What it does |","|---|---|---|",p1(s.poseFields),"","### Other props","","| Prop | Unit | What it does |","|---|---|---|",p1(s.props),"",`With \`style.hands\`, each hand has \`hand.left.<field>\` / \`hand.right.<field>\` props: ${yt(Object.keys(s.handFields))}.`,"",`**Poses** (a beat's \`do\`, or a pose key): ${yt(s.poses)}.`,"",`**Expressions** (a beat's \`mood\`): ${yt(s.expressions)}.`,"",`**Gags** (ms): ${Object.entries(s.gags).map(([r,o])=>`\`${r}\` (${o})`).join(", ")}.`,"",`**Gaits**: ${yt(s.gaits)}. **Acting styles** (\`style\`): ${yt(s.actingStyles)}.`,"","### Beat scripts","",`\`scriptTracks(target, beats, { from, ground, height, facing, style })\`. A beat has these fields only: ${yt(s.beatFields)}. Times are ms; \`to\` and \`target\` are scene px; \`onto\` is a floor's scene y.`,"","`characterScript(target, who, beats, options)` compiles the same beats for a v2 `character()` on a `characterTarget` (every option but `height`; the same result, its key poses on the human body; the walk phase keyed to that character's stride, and `walk` / `walking` / `gait` tracks that step the gait as the target draws). Add `hairFollowTracks(target, tracks, who)` after it so hanging hair swings.","","| `do` | Needs | What happens |","|---|---|---|",...Object.entries(s.actions).map(([r,o])=>`| \`${r}\` | ${(o.needs??[]).map(a=>`\`${a}\``).join(", ")} | ${o.summary} |`),"","Beats that touch something report `contact` (and `release`) times in `result.beats[i]`; key the thing they touch to those.","",`**Dances** (\`dancer(style, { move })\`): ${Object.entries(s.dances).map(([r,o])=>`\`${r}\` (${o.join(", ")})`).join("; ")}.`,"",`**Flips**: ${Object.entries(s.flips).map(([r,o])=>`\`${r}\` (${o})`).join(", ")}.`,"",`**Hand shapes**: ${yt(s.handShapes)}. **Mudras**: ${yt(s.mudras)}.`,"","### Your own actions, gaits and personas","","Nothing is registered globally: pass your definitions where they are used.","",...Object.entries(n.custom.api).map(([r,o])=>`- \`${r}\`: ${o}`),"",...Object.keys(n.custom.actions).length||Object.keys(n.custom.gaits).length?["**This cast’s own:**","",...Object.entries(n.custom.actions).map(([r,o])=>`- \`${r}\`${o.needs?.length?` (needs ${o.needs.map(a=>`\`${a}\``).join(", ")})`:""}: ${o.summary}`),...Object.entries(n.custom.gaits).map(([r,o])=>`- \`${r}\` (gait): ${o}`),""]:[],"## Props (everyday objects with behaviours)","","A prop is a 3D rig of simple parts drawn with the characters’ pens (clean, pencil, silhouette), so it turns toward the camera (`turn`), and its beats go through the same acting pass (anticipation, overshoot, overlap; `exaggeration` scales them).","",...Object.entries(n.props.api).map(([r,o])=>`- \`${r}\`: ${o}`),"",`Prop beat fields: ${yt(n.props.beatFields)}. Every prop has the controls ${Object.keys(n.props.commonControls).map(r=>`\`${r}\``).join(", ")} and the actions ${Object.keys(n.props.commonActions).map(r=>`\`${r}\``).join(", ")}.`,"","Scenery: `scenery({ x, y, width, height, kind: sky | room, hour, clouds, wind, rain, snow, horizon: hills | city | flat })` is a canvas target whose values `hour` (0–24), `clouds`, `rain`, `snow` (0–1) and `wind` (−1..1) are tracks (`set(prop, { at, value, duration })`, `tracks(id)`; `anchor('sun' | 'moon' | 'horizon' | 'ground', time)`); the same `wind` streams hair (`hairFollowTracks(…, { wind })`). `scenePreset('park' | 'street' | 'office' | 'home', { width, height })` lays out scenery and props as data; `buildScene` builds them into targets.","","| Preset | Family | Actions (needs) | Controls | Anchors |","|---|---|---|---|---|",...Object.entries(n.props.presets).map(([r,o])=>`| \`${r}()\` | ${o.family} | ${Object.entries(o.actions).map(([a,l])=>`\`${a}\`${l.needs?.length?` (${l.needs.join(", ")})`:""}`).join(", ")} | ${o.controls.map(a=>`\`${a}\``).join(", ")} | ${o.anchors.join(", ")} |`),"","## Character (v2 human)","",`Poses: ${yt(n.character.poses)}. Expressions: ${yt(n.character.expressions)}. Gags: ${yt(n.character.gags)}.`,`Native dances: ${yt(n.character.dances)}; \`humanDanceFrame(style, beat, base)\` keeps body heading independent; \`humanDanceTracks(target, options)\` bakes JSON pose tracks. \`danceCircleAt(beat, { radius, count, beatsPerTurn, facing, spins })\` gives a formation with planted toes; \`danceCircleTracks(targets, options)\` bakes scene tracks. \`plantDanceFoot(partner, side, worldPoint)\` returns pose AND position; \`meetDandiya(a, b)\` solves both stick tips to one shared world point and reports unreachable contacts.`,"","Appearance options of `character({ … })`, all plain data that turns with the head (see docs/character-appearance.md):","",`- \`build\`: ${yt(n.character.builds)}`,`- \`figure\`: ${yt(n.character.figureStyles)}`,"- `look`: `clean` (default), `pencil`, `silhouette`, `illustrated` (inked and painted: line weight follows the light, brush-tapered strokes, shadow/core/highlight tones from each fill; `illustrated: { light: [x, y], weight, taper, shadow, highlight }`, each 0–1)",...Object.entries(n.character.body).map(([r,o])=>`- \`${r}\`: ${o}`),`- \`hair\`: ${yt(n.character.hair)} (colours: ${yt(Object.keys(n.character.hairColors))} in \`HAIR_COLORS\`)`,"- Flowing hair: `softSweep`, `flowingBob`, `cascadingWaves`; editable `locks: [{ path, width, follow? }]` with cubic `{ around, up, lift? }` points (around in degrees, dimensions in head radii), `fall: { taper, wave }` and `shine` (0–1). Roots stay attached; `hairFollowTracks` also drives flexible short locks.",`- \`facialHair\`: ${yt(n.character.facialHair)}`,`- \`glasses\`: ${yt(n.character.glasses)}; \`hat\`: ${yt(n.character.hats)}; \`ears: true\`; \`face: { teeth, tongue }\` (shown when the mouth opens); \`feet\`: ${yt(n.character.feet)}`,"- `outfit`: `{ top: tshirt | shirt | blouse | dress, trouserStyle: plain | jeans | cargo, shirt: top colour, trousers: bottom colour, sleeves: short | long | none, bottom: trousers | shorts | skirt, collar, tie: colour, over: apron | labCoat | hoodie | cardigan | overalls | sari, overColor, shoes: boots, shoeColor }`",`- \`castMember(name, height)\`: ${yt(n.character.cast)}`,"- Face marks (pose fields, 0–1): `blush`, `tears`, `sweat`; close-up fields `pupil` (size, 1 usual), `lid` (upper lids lowered, 0–1), `bulge` (eyes out of the head, 0–1); `face: { nose: true, inPupil(ctx, pupil) }`; `drawCharacterHead(ctx, who, pose, { x, y, radius })` draws just the head big",`- Face styles: ${yt(n.character.faceStyles)}; \`face: { style: 'anime', iris: '#4b7fce', lashes: true, ageLines: 0.8 }\` uses coloured eyes and the same expressions, blinks and gaze. \`ANIME_CAST\` contains eight age presets, also available through \`castMember\`.`,`- Face shapes: ${yt(n.character.faceShapes)}; \`face: { shape: 'angular', jawWidth: 0.74, chinWidth: 0.14, eyeScale: 0.8, eyeAspect: 0.65 }\` sets a tapered 3D jaw and narrower anime eyes; \`jawRoundness: 1\` softens the cheek/chin corners (default 0 keeps sharp jaws). \`MANGA_CAST\` contains four original young adult presets; hair styles \`mangaSpikes\` and \`mangaSweep\` remain editable.`,"- Hair in motion (pose fields): `hair.swing` (degrees round the head, + toward its left), `hair.trail` (head radii back), `hair.lift` (head radii up); key them with `hairFollowTracks(target, tracks, who)` after the character's tracks, or `hairFollow` + `hairMotionAt` when posing per frame",`- \`holding\`: ${Object.entries(n.character.heldItems).map(([r,o])=>`\`${r}\` (${o==="both"?"both":o==="either"?"one hand or both":"left or right"})`).join(", ")}; pose fields \`held.left\`, \`held.right\`, \`held.both\` (below 0.5 lets go); \`handGrip(joints, side)\``,`- \`meetHands(kind, a, b)\` (stand them \`meetingSpacing(kind, a, b)\` apart): ${yt(n.character.handMeetings)}; \`embrace(a, b)\` (a hug, \`embraceSpacing\` apart); \`helpUp(helper, sitter, progress)\` (0 on the floor, hand taken; 1 standing; \`helpUpSpacing\` apart)`,"- Everyday cycles like a gait: `humanCyclePose('sweeping' | 'brushing', phase, base)` (0 → 1 is one stroke and back; sweeping with `holding: { right: 'broom' }`)","","## Code panel","",`\`codePanel({ code, language, x, y, fontSize?, lineHeight?, width? })\`: a code listing as a scene object. Languages: ${yt(n.codePanel.languages)}. Remove styles: ${yt(n.codePanel.removeStyles)}.`,"",...Object.entries(n.codePanel.anchors).map(([r,o])=>`- \`${r}\`: ${o}`),"",...Object.values(n.codePanel.edits).map(r=>`- \`${r.split(":")[0]}\`:${r.split(":").slice(1).join(":")}`),"","## Surfaces","","Scene objects figures act on. Places are named `kind:args`: `surface.anchor(name)` gives the box there (stand on `top`, point at `x`, `y`; pass it as a beat `target`), `surface.piece(name)` makes the part there come loose, and `surface.edit(name, anchor, options)` changes the surface at a time (`at`, ms).","","Beats name places and say what surfaces do in answer (`surfaceScript`):","",...Object.entries(n.surfaceScript).map(([r,o])=>`- \`${r}\`: ${o}`),"",...Object.entries(n.surfaces).flatMap(([r,o])=>[`### ${r}`,"",...o.create?[`\`${o.create}\``,""]:[],"Anchors:",...Object.entries(o.anchors).map(([a,l])=>`- \`${a}\`: ${l}`),"","Edits:",...Object.entries(o.edits).map(([a,l])=>`- \`${a}\`: ${l}`),""]),"## Cricket stories (`@algorisys/tinyfly/sports`)","","`cricketClip({ format, action, cast })` returns an organic-player scene, JSON tracks, timed events/captions and a declared result. `cricketField`, `cricketPlayer` and `cricketAction` compose separately; `cricketCameraTracks` adds camera tracks. These are authored tutorial plays, not physics or automatic umpiring. See docs/cricket.md.","",`Marking profiles: ${yt(Object.keys(n.sports.cricket.markingProfiles))}; default ICC men, independently of cast. Limited-over ICC profiles draw a wicket-centred capsule; Test/MCC have no restriction-area line. \`cricketFieldingAreaContains(field, point)\` returns true/false/null; \`cricketFieldingPositions\` and \`cricketFieldingOverlay\` provide owned setup markers, not umpiring decisions.`,"","`cricketPlay(field, options)` / `cricketPlayClip(options)` independently author delivery style/legality, shot, finish, fielding, current free-hit context and candidate dismissal. Omitted dismissal means no dismissal. Unsupported motion combinations throw; no-ball/free-hit protection changes result/signals without removing physical catches or wicket breaks. Run-out remains available. Illegal free hits carry forward; legal ones consume context. Test rejects free-hit context. Keep innings/score/strike in the consuming app.","",...Object.entries(n.sports.cricket.playComponents).map(([r,o])=>`Play ${r}: ${yt(o)}`),...Object.entries(n.sports.cricket.playExamples).map(([r,o])=>`- Composed example \`${r}\`: ${o.name}`),"",...Object.entries(n.sports.cricket.actions).map(([r,o])=>`- \`${r}\`: ${o.summary}`),"",`Formats: ${yt(Object.keys(n.sports.cricket.formats))}. Casts: ${yt(Object.keys(n.sports.cricket.casts))}. Cameras: ${yt(Object.keys(n.sports.cricket.cameras))}. Orbit turns 360° around the whole ground. \`cricketCameraTracks(clip, { view, zoom })\` supports 0.25–4× optical magnification (default 1) in every view.`,"",`Stock fielding labels (\`CRICKET_FIELDING_POSITIONS\`): ${Object.entries(n.sports.cricket.fieldingPositions).map(([r,o])=>`\`${r}\`: ${o}`).join(", ")}. Eleven fielders, two on-field batters and two umpires; nine batting teammates wait off-field. Mid-on is closer to the pitch; long-on is its deeper boundary alternative, not an extra stock fielder. For the right-handed striker, +x is off side and -x is on/leg side.`,"","Decision review cameras: front-foot, striker-crease, bowler-crease. cricketCameraFraming returns owned defaults; cricketCameraReview returns a physical event without seeking. Optional cricketDecisionOverlay marks the crease reference. pitch 0–89, distance 0.5–2000, fov 10–100 before zoom, and fixed-view target customize framing. Ball-follow yaw rotates its default offset relative to 75 degrees; pitch/distance apply too. Export all camera tracks, including far for distant framing. These APIs never alter motion or rulings.","","## Camera shots (`cameraTracks(shots, { stage })`)","",...Object.entries(n.cameraShots).map(([r,o])=>`- **${r}**: \`${o}\``),"","## Teaching (`@algorisys/tinyfly/teach`)","",...Object.entries(n.teach).map(([r,o])=>`- \`${r}\`: ${o}`),"","## Maths (`@algorisys/tinyfly/math`)","","A figure is JSON: a plane and items. Tracks on its target animate values by name and item props. One layout feeds a canvas (videos) and SVG (lesson embeds), so they match.","",...Object.entries(n.math.api).map(([r,o])=>`- \`${r}\`: ${o}`),"","Items (each has `id`, `kind`, and optional `color`, `draw`, `opacity`):","",...Object.entries(n.math.items).map(([r,o])=>`- \`${r}\` ${o}`),"","Props a timeline animates:","",...Object.entries(n.math.props).map(([r,o])=>`- \`${r}\`: ${o}`),"",`Expression functions: ${n.math.functions.map(r=>`\`${r}\``).join(", ")}; constants \`pi\`, \`e\`, \`tau\`.`,"",`TeX subset: ${n.math.tex}`,"","## Command line","",...Object.entries(n.cli).map(([r,o])=>`- \`${r}\`: ${o}`),""].join(`
64
64
  `)}function q4(t,e,n,s={}){const i=s.color??"#555",r=s.size??60;for(const o of e){const a=(n-o.time)/o.length;if(a<=0||a>=1)continue;const l=ne(`${o.kind}:${o.time}:${o.x}`);o.kind==="dust"?pm(t,{x:o.x,y:o.y},a,{size:r,color:i,seed:l}):o.kind==="exhaust"?K4(t,o,a,r,i,l):o.kind==="skid"?X4(t,o,a,n,i):o.kind==="honk"?G4(t,o,a,r,i):o.kind==="smoke"?j4(t,o,n,r,i):o.kind==="leaves"&&Y4(t,o,a,r,s.leafColor??"#5cae5a",i,l)}}function j4(t,e,n,s,i,r){const o=e.direction??1,a=380,l=1500;t.save(),t.strokeStyle=i,t.lineWidth=Math.max(1,s*.025);for(let c=e.time;c<=e.time+e.length-l;c+=a){const h=(n-c)/l;if(h<=0||h>=1)continue;const u=Math.sin(c/97+h*4)*s*.06,d=e.x+o*h*s*.7+u,f=e.y-h*s*1.6;t.globalAlpha=Math.min(1,h*6)*(1-h)*.85,t.beginPath(),t.arc(d,f,s*(.07+h*.2),0,Math.PI*2),t.stroke()}t.restore()}function Y4(t,e,n,s,i,r,o){const a=e.direction??1,l=e.toY??e.y+s*3;t.save(),t.lineWidth=Math.max(1,s*.02),t.strokeStyle=r,t.fillStyle=i;for(let c=0;c<4;c++){const h=ne(`${o}:${c}`)%1e3/1e3,u=Math.min(1,n*(1.1+h*.4)),d=e.x+(h-.5)*s*1.2,f=e.y+(h-.3)*s*.4,p=u*u*.4+u*.6,g=d+a*u*s*(.6+h)+Math.sin(u*9+h*6)*s*.18,m=Math.min(l-2,f+(l-f)*p);t.globalAlpha=n>.85?(1-n)/.15:1,t.save(),t.translate(g,m),t.rotate(Math.sin(u*7+h*5)*1.2),t.beginPath(),t.ellipse(0,0,s*.07,s*.035,0,0,Math.PI*2),t.fill(),t.stroke(),t.restore()}t.restore()}function K4(t,e,n,s,i,r){const o=e.direction??-1;t.save(),t.strokeStyle=i,t.lineWidth=Math.max(1,s*.025);for(let a=0;a<3;a++){const l=n*1.6-a*.25;if(l<=0||l>=1)continue;const c=(ne(`${r}:${a}`)%100/100-.5)*s*.1,h=e.x+o*l*s*.9,u=e.y-l*s*.45+c;t.globalAlpha=(1-l)*.9,t.beginPath(),t.arc(h,u,s*(.06+l*.14),0,Math.PI*2),t.stroke()}t.restore()}function X4(t,e,n,s,i){const r=e.toX??e.x,o=Math.min(1,(s-e.time)/e.length*3),a=e.x+(r-e.x)*o;t.save(),t.strokeStyle=i,t.lineCap="round",t.globalAlpha=n<.6?.8:.8*(1-(n-.6)/.4),t.lineWidth=3;for(const l of[-2,4])t.beginPath(),t.moveTo(e.x,e.y+l),t.lineTo(a,e.y+l),t.stroke();t.restore()}function G4(t,e,n,s,i){const r=e.direction??1;t.save(),t.strokeStyle=i,t.lineWidth=Math.max(1.5,s*.04),t.lineCap="round",t.globalAlpha=n<.7?1:(1-n)/.3;const o=s*(.15+.5*(1-(1-n)**2));for(let a=-1;a<=1;a++){const l=a*Math.PI/7,c=e.x+r*Math.cos(l)*o,h=e.y+Math.sin(l)*o;t.beginPath(),t.arc(c,h,s*.12,r>0?-Math.PI/3:Math.PI*2/3,r>0?Math.PI/3:Math.PI*4/3),t.stroke()}t.restore()}function U4(t){const e=new Ht({id:`${t.propId}-ride`,tracks:t.propTracks.filter(h=>h.target===t.propId)}),n=t.every??33,s=[],i=[],r=[],o=[];let a=1;for(let h=t.start;;h=Math.min(t.end,h+n)){const u=Wo(t.prop,{state:e.getStateAtTime(h)},t.propId),d=u.anchor(t.anchor);s.push({time:h,value:d.x+(t.offset?.x??0)-t.figure.x}),i.push({time:h,value:d.y+(t.offset?.y??0)-t.figure.y});const f=Math.sin(u.values.turn*Math.PI/2);if(Math.abs(f)>.15&&(a=f>0?1:-1),r.push({time:h,value:Math.abs(f)}),o.push({time:h,value:a}),h>=t.end)break}const l=t.figureId,c=[{id:`${l}-x`,target:l,property:"x",keyframes:s},{id:`${l}-y`,target:l,property:"y",keyframes:i}];return t.turn!==!1&&c.push({id:`${l}-turn`,target:l,property:"turn",keyframes:r},{id:`${l}-facing`,target:l,property:"facing",keyframes:V4(o)}),c}function V4(t){const e=[];for(const n of t){const s=e[e.length-1];s&&s.value!==n.value&&e.push({time:n.time-1,value:s.value}),(!s||s.value!==n.value||n===t[t.length-1])&&e.push(n)}return e}function J4(t,e,n){const s=o=>`${o.target}\0${o.property}`,i=new Map(e.map(o=>[s(o),o]));return[...t.map(o=>{const a=i.get(s(o));if(!a)return o;i.delete(s(o));const c=[...(o.keyframes??[]).filter(h=>h.time<n.from||h.time>n.to),...a.keyframes??[]].sort((h,u)=>h.time-u.time);return{...o,keyframes:c}}),...i.values()]}function Z4(t){const e=new Ht({id:`${t.leaderId}-tow`,tracks:t.leaderTracks.filter(f=>f.target===t.leaderId)}),n=t.every??33,s=t.towed,i=s.x+s.width/2,r=s.props,o=s.prop.wheelRadius,a=[],l=[],c=[];let h=r.wheelSpin??0,u;for(let f=t.start;;f=Math.min(t.end,f+n)){const p=Wo(t.leader,{state:e.getStateAtTime(f)},t.leaderId),g=p.anchor(t.hitch),m=p.values.turn,y=Ps(s.prop,{...r,turn:m},s.propScale).anchors[t.anchor];if(!y)throw new Error(`propTow: ${s.prop.kind} has no anchor "${t.anchor}"`);const v=g.x-y.point.x;if(u!==void 0&&o){const k=Math.sin(m*Math.PI/2);h+=(v-u)*(k||1)/s.propScale/o*(180/Math.PI)}if(u=v,a.push({time:f,value:v-i}),l.push({time:f,value:m}),c.push({time:f,value:h}),f>=t.end)break}const d=t.towedId;return[{id:`${d}-x`,target:d,property:"x",keyframes:a},{id:`${d}-turn`,target:d,property:"turn",keyframes:l},...o?[{id:`${d}-wheelSpin`,target:d,property:"wheelSpin",keyframes:c}]:[]]}const m1=new WeakMap;function Q4(t,e){const n=e?.some(Boolean)?e.map(d=>d?1:0).join(""):"";let s=m1.get(t);s||m1.set(t,s=new Map);const i=s.get(n);if(i)return i;const r=zi(t),o={vertices:r.vertices,faces:r.faces.filter((d,f)=>!e?.[f])},a=o.vertices.flatMap(d=>[d[0],d[1],d[2]]),l=o.vertices.map(()=>[0,0,0]),c=[];o.faces.forEach(d=>{for(const g of d.corners)for(const m of[0,1,2])l[g][m]+=d.normal[m];const[f,...p]=d.corners;for(let g=0;g+1<p.length;g++){const[m,y,v]=[f,p[g],p[g+1]],[k,w,T]=[o.vertices[m],o.vertices[y],o.vertices[v]],A=[w[0]-k[0],w[1]-k[1],w[2]-k[2]],M=[T[0]-k[0],T[1]-k[1],T[2]-k[2]],x=[A[1]*M[2]-A[2]*M[1],A[2]*M[0]-A[0]*M[2],A[0]*M[1]-A[1]*M[0]],S=x[0]*d.normal[0]+x[1]*d.normal[1]+x[2]*d.normal[2];c.push(...S>=0?[m,y,v]:[m,v,y])}});const h=l.flatMap(d=>{const f=Math.hypot(...d)||1;return[d[0]/f,d[1]/f,d[2]/f]}),u=po({positions:a,normals:h,indices:c});return s.size>=16&&s.clear(),s.set(n,u),u}function tT(t,e,n={}){const s=t.ink??n.ink??"#26262b",i=(n.outline??2)*(t.outline??1),r=t.glow&&e.glow>0?eT(t.glow.color,e.glow):void 0;return{color:t.fill??s,creases:zi(t.shape).creases!==!1,shading:n.shading??"toon",...i>0?{outline:{width:i,color:s}}:{},...r?{emissive:r}:{},...t.seeThrough?{opacity:.45*e.opacity}:e.opacity<1?{opacity:e.opacity}:{}}}function eT(t,e){const n=/^#([0-9a-f]{6})$/i.exec(t.trim());return n?`#${[0,2,4].map(i=>Math.round(parseInt(n[1].slice(i,i+2),16)*Math.max(0,Math.min(1,e)))).map(i=>i.toString(16).padStart(2,"0")).join("")}`:t}const nT=po(ap(1,.002,28));function sT(t,e,n){const s=t.rig,[i,r]=s.footprint??[s.length*.45,s.length],o=Math.max(0,It(s,e,"lift")),a=Math.max(0,It(s,e,"size"))/(1+o*.8);return{mesh:nT,world:Rt(n,Ha([0,.004,0],[0,0,0,1],[i*.55*a||1e-4,1,r*.55*a||1e-4])),material:{color:"#000000",shading:"unlit",opacity:.16*a}}}const iT=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),rT=1,oT={kind:"prop",validate(t){const e=t,n=typeof e.prop=="string"&&e.prop in Os?[]:[ft("prop preset",e.prop,Object.keys(Os))];for(const[s,i]of[[0,"rotateX"],[1,"rotateY"],[2,"rotateZ"]])i in e&&n.push(`${i} is a track, not a field: place it turned with rotation: [${[0,1,2].map(r=>r===s?e[i]:0).join(", ")}]`);return n},prepare(t){const e=t;return xh(e.prop,e.options)},resolve({object:t,prepared:e,values:n,world:s,camera:i,lights:r=[],fog:o,toScreen:a}){const l=t,c=e,h={...l.values};for(const[M,x]of n)typeof x=="number"&&!iT.has(M)&&(h[M]=x);h.turn=0,h.tilt=0;const u=Rt(i.view,s),d={toView:M=>ie(u,M),toScreen:M=>a(M)},f=d.toView([0,c.rig.height/2,0]);if(-f[2]<=i.near)return null;if(l.look==="mesh"){const M=Qm(c.rig,h),x=M.map(({part:P,local:I})=>({part:P.id,mesh:zi(P.shape),...dh(zi(P.shape),I)})),S=Xm(x),E=M.map((P,I)=>({...P,hidden:Um(P.part.id,x[I].mesh,P.local,x[I].key,S)})).filter(({opacity:P})=>P>.01).map(({part:P,matrix:I,glow:O,opacity:H,hidden:W})=>({mesh:Q4(P.shape,W),world:Rt(s,I),material:tT(P,{glow:O,opacity:H},{shading:l.shading,ink:l.ink,outline:l.outline})}));return{meshes:l.shadow===!1?E:[sT(c,h,s),...E]}}const p=a(f),g=a(d.toView([0,c.rig.height/2+1,0])),m=Math.hypot(g.x-p.x,g.y-p.y),y=r.length===0?void 0:(M,x)=>{const S=ie(s,M),E=[s[0]*x[0]+s[4]*x[1]+s[8]*x[2],s[1]*x[0]+s[5]*x[1]+s[9]*x[2],s[2]*x[0]+s[6]*x[1]+s[10]*x[2]],P=Math.hypot(...E)||1;return{light:Md(S,[E[0]/P,E[1]/P,E[2]/P],r),fog:Sd(o,Math.hypot(S[0]-i.position[0],S[1]-i.position[1],S[2]-i.position[2]))}},v=yh(c.rig,h,d,m,{perspective:!0,near:i.near,slice:rT,light:y}),k={look:l.look,style:l.style,ink:l.ink,paper:l.paper,fog:o?.color},w=bc(v),T=v.cells??[],A=Math.max(...T.map(M=>-M.depth),-f[2]);return{drawables:[...l.shadow===!1?[]:[{depth:A+c.rig.length,draw:M=>wc(M,v,k)}],...T.map(M=>({depth:-M.depth,draw(x,S){x.lineCap="round",x.lineJoin="round",cp(x,M.parts,w,{...k,time:S.time})}}))]}}},Bh=["do","at","for","to","through","toward","speed","height","open","on","wind"],aT=.25,lT=800/180,cT=220,hT=300,uT=["turn"];function dT(t){const e=jo(t),n=Object.keys(t.moves??{});return Object.keys(e).filter(s=>!n.includes(s)&&!uT.includes(s)&&!(e[s].needs??[]).includes("to"))}function y1(t,e){if(!Array.isArray(t))return[{beat:-1,message:`Beats must be an array of { do: … } objects (got ${typeof t}).`}];const n=Object.keys(e.moves??{}),s=dT(e),i=[...n,"face","hold",...s.filter(o=>o!=="hold")],r=[];return t.forEach((o,a)=>{const l=u=>r.push({beat:a,message:u});if(!o||typeof o!="object"||Array.isArray(o))return l(`Each beat must be an object like { do: '${i[0]??"hold"}' }.`);const c=o,h={duration:"for",path:"through",points:"through",position:"to",heading:"toward",direction:"toward"};for(const u of Object.keys(c))Bh.includes(u)||l(ft("beat field",u,Bh,h[u]));if(typeof c.do!="string"||!i.includes(c.do)){const u=c.do==="turn"?"face":void 0;return l(ft(`${e.kind} 3D beat`,c.do,i,u))}n.includes(c.do)&&(c.to===void 0&&c.through===void 0&&l(`\`${c.do}\` needs \`to\` ([x, z] metres) or \`through\` (a list of them).`),c.to!==void 0&&!Cn(c.to)&&l(`\`to\` is a point on the ground, [x, z] metres (got ${JSON.stringify(c.to)}).`),c.through!==void 0&&!(Array.isArray(c.through)&&c.through.length>0&&c.through.every(Cn))&&l("`through` is a list of points on the ground, each [x, z] metres.")),c.do==="face"&&!(Cn(c.toward)||typeof c.toward=="number")&&l("`face` needs `toward`: a point [x, z] or a heading in degrees.")}),r}function fT(t,e,n,s){const i=y1(n,e);if(i.length>0)throw new Error(`propScript3D (${e.kind}): ${i.length} problem(s) in the beats:
65
65
  ${i.map(k=>` beat ${k.beat}: ${k.message}`).join(`
66
66
  `)}`);const r={};for(const k of[...Object.keys(As),...Object.keys(e.rig.controls)])r[k]=s.values?.[k]??It(e.rig,{},k);let[o,a]=s.position??[0,0],l=s.heading??0;const c=new Map,h=(k,w,T,A="linear")=>{const M=c.get(k)??[];M.push({time:w,value:T,easing:A}),c.set(k,M)},u=(k,w,T)=>h(k,w,T);h("x",0,o),h("z",0,a),h("rotateY",0,l);const d=(k,w)=>{const T=ko(l,w);if(Math.abs(T)<1)return k;const A=Math.max(cT,Math.abs(T)*lT);return u("rotateY",k,l),l+=T,h("rotateY",k+A,l,"ease-in-out"),k+A},f=(k,w,T)=>{const A=Op([[o,a],...w.through??[w.to]]);if(A.length<2)return T;const M=d(T,ws(A[0].point,A[1].point)),x=A[A.length-1].at,S=w.for??x/(w.speed??k.speed)*1e3,E=Wt("ease-in-out"),P=Math.min(hT,S/4);for(const[J,et]of Object.entries(k.set??{}))u(J,M,r[J]),h(J,M+1,et),r[J]=et;const I=k.flies?w.height??(r.lift>.05?r.lift:2):void 0,O=I!==void 0&&I>.05;for(const[J,et]of Object.entries(k.hold??{}))u(J,M,r[J]),h(J,M+P,et,"ease-out"),O||(h(J,M+S-P,et),h(J,M+S,0,"ease-in")),r[J]=O?et:0;I!==void 0&&(u("lift",M,r.lift),h("lift",M+Math.min(S*.35,1400),I,"ease-out"),h("lift",M+S,I),r.lift=I);const H={...r};let W=l;for(let J=0;;J=Math.min(x,J+aT)){const et=M+_p(E,J/x)*S,{point:V,direction:L}=Cp(A,J);W+=ko(W,ws([0,0],L)),h("x",et,V[0]),h("z",et,V[1]),h("rotateY",et,W);for(const[B,K]of Object.entries(k.perMetre??{}))h(B,et,H[B]+J*K);for(const[B,K]of Object.entries(k.perSecond??{}))h(B,et,H[B]+(et-M)/1e3*K);if(J>=x)break}for(const[J,et]of Object.entries(k.perMetre??{}))r[J]=H[J]+x*et;for(const[J,et]of Object.entries(k.perSecond??{}))r[J]=H[J]+S/1e3*et;return[o,a]=A[A.length-1].point,l=W,M+S},p=(k,w)=>{const T=Object.fromEntries(Object.entries(k).filter(([M])=>!["at","to","through","toward"].includes(M))),A=Jy(t,e,[T],{start:{...r,turn:1},scale:100,style:s.style,exaggeration:s.exaggeration});for(const M of A.tracks){if(gT.includes(M.property))continue;const x=M.keyframes??[],S=r[M.property];if(!x.every(E=>E.value===S)){u(M.property,w,S);for(const E of x)E.time>0&&c.get(M.property).push({...E,time:w+E.time});r[M.property]=x[x.length-1].value}}return w+A.duration},g=[];let m=0;for(const k of n){const w=k.at??m;let T=w;const A=e.moves?.[k.do];A?T=f(A,k,w):k.do==="face"?T=d(w,typeof k.toward=="number"?k.toward:ws([o,a],k.toward)):k.do==="hold"?T=w+(k.for??1e3):T=p(k,w),g.push({do:k.do,start:w,end:T}),m=T}const y=`${s.scene}/${t}`;return{tracks:[...c].map(([k,w])=>({id:`${t}-${k}`,target:y,property:k,keyframes:Ip(w)})),duration:m,beats:g,end:{position:[o,a],heading:l,values:{...r}}}}const gT=["x","y","turn","facing","tilt"],pT=.35,zh={seated:be.sit,astride:{...be.sit,"leg.left.spread":26,"leg.right.spread":26,"leg.left.swing":40,"leg.right.swing":40,"leg.left.knee":70,"leg.right.knee":70},driving:{...be.sit,"arm.left.swing":52,"arm.right.swing":52,"arm.left.spread":8,"arm.right.spread":8,"arm.left.elbow":38,"arm.right.elbow":38,lean:4},wheeling:{...be.sit,"arm.left.swing":-6,"arm.right.swing":-6,"arm.left.spread":16,"arm.right.spread":16,"arm.left.elbow":28,"arm.right.elbow":28,"leg.left.knee":80,"leg.right.knee":80},cycling:{...be.sit,lean:22,bend:10,"head.nod":-14,"arm.left.swing":58,"arm.right.swing":58,"arm.left.spread":10,"arm.right.spread":10,"arm.left.elbow":22,"arm.right.elbow":22,"leg.left.spread":6,"leg.right.spread":6}},mT=22,b1=38;function qh(t,e=zh.cycling){const n=t*Math.PI*2,s=o=>({swing:(e["leg.left.swing"]??40)+mT*Math.cos(n+o),knee:(e["leg.left.knee"]??70)+b1*(.5+.5*Math.cos(n+o))-b1*.5,ankle:12*Math.sin(n+o)}),i=s(0),r=s(Math.PI);return{...e,"leg.left.swing":i.swing,"leg.left.knee":i.knee,"leg.left.ankle":i.ankle,"leg.right.swing":r.swing,"leg.right.knee":r.knee,"leg.right.ankle":r.ankle}}function yT(t){const e=t.cadence??1.2,n=Math.max(2,t.samplesPerTurn??8),s=1e3/e/n,i=[];for(let r=t.start,o=0;r<t.end;r+=s,o++)i.push({time:Math.round(r),pose:qh((r-t.start)/1e3*e,t.base),...o>0?{act:!1}:{}});return i.push({time:t.end,pose:qh((t.end-t.start)/1e3*e,t.base),act:!1}),i}const w1=(t,e)=>{const n=e*Math.PI/180;return[t[0]*Math.cos(n)+t[2]*Math.sin(n),t[1],-t[0]*Math.sin(n)+t[2]*Math.cos(n)]};function bT(t){const e=`${t.scene}/${t.propId}`,n=new Ht({id:`${t.propId}-ride-3d`,tracks:t.propTracks.filter(m=>m.target===e)}),s=t.placement??{},[i,r,o]=s.position??[0,0,0],a=t.prop.rig,l=ps({...t.character,height:1}),c={...lt,...t.pose??zh.seated},h=Qe(l.plan,c,{height:t.height??1.7,contact:l.contact}).hip,u=t.facing??0,d=t.every??33,f={x:[],y:[],z:[],rotateY:[]};for(let m=t.start;;m=Math.min(t.end,m+d)){const y=n.getStateAtTime(m).values.get(e)??new Map,v=(H,W)=>{const j=y.get(H);return typeof j=="number"?j:W},k={...s.values};for(const H of Object.keys(a.controls))k[H]=v(H,s.values?.[H]??It(a,{},H));for(const H of["pitch","roll","squash","lift","lean","size"])k[H]=v(H,s.values?.[H]??It(a,{},H));const w=ty(a,k)[t.anchor];if(!w)throw new Error(`propRide3D: ${t.prop.kind} has no anchor "${t.anchor}" (it has ${Object.keys(a.anchors??{}).join(", ")||"none"})`);const T=v("rotateY",s.heading??0),A=w1(w,T),M=[v("x",i)+A[0],v("y",r)+A[1],v("z",o)+A[2]],x=T+u,S=w1(h,x);let E=[M[0]-S[0],M[1]-S[1],M[2]-S[2]];const P=(H,W)=>{const j=W*W*(3-2*W);return[H[0]+(E[0]-H[0])*j,E[1]*j+pT*Math.sin(Math.PI*W),H[1]+(E[2]-H[1])*j]},I=t.mount?Math.max(1,t.mount.for??450):0,O=t.dismount?Math.max(1,t.dismount.for??450):0;if(t.mount&&m<t.start+I?E=P(t.mount.from,(m-t.start)/I):t.dismount&&m>t.end-O&&(E=P(t.dismount.to,(t.end-m)/O)),f.x.push({time:m,value:E[0]}),f.y.push({time:m,value:E[1]}),f.z.push({time:m,value:E[2]}),f.rotateY.push({time:m,value:x}),m>=t.end)break}const p=t.riderId,g=`${t.scene}/${p}`;return Object.keys(f).map(m=>({id:`${p}-${m}`,target:g,property:m,keyframes:f[m]}))}const k1={ground:"#7fb56a",hills:"#5f9a58",city:"#4b5468",cloud:"#ffffff",sun:"#ffd45c",moon:"#f3f0e0",rain:"#9fc4e8",snow:"#ffffff",wall:"#e9e1cf",floor:"#b08a5e",skirting:"#8a6a44",frame:"#f7f3ea"},Gi=[[0,"#0b1530","#1b2a4a"],[4.5,"#141a3e","#2a2f5a"],[6,"#4a3f7a","#f0a070"],[7.5,"#86c2ee","#d8ecf8"],[12,"#5aaef2","#c0e2f8"],[16.5,"#69b0e6","#f5d79a"],[18.5,"#4c3f78","#f08a5a"],[20.5,"#17203f","#2d3660"],[24,"#0b1530","#1b2a4a"]],Ui=(t,e,n)=>{const s=o=>[1,3,5].map(a=>parseInt(o.slice(a,a+2),16)),[i,r]=[s(t),s(e)];return`#${i.map((o,a)=>Math.round(o+(r[a]-o)*n).toString(16).padStart(2,"0")).join("")}`},wT=t=>{const e=(t%24+24)%24;return e<5||e>20?0:e<7?(e-5)/2:e>18?(20-e)/2:1};function v1(t){const e=(t%24+24)%24;for(let n=1;n<Gi.length;n++){const[s,i,r]=Gi[n-1],[o,a,l]=Gi[n];if(e<=o){const c=(e-s)/(o-s);return{top:Ui(i,a,c),bottom:Ui(r,l,c)}}}return{top:Gi[0][1],bottom:Gi[0][2]}}const kT=(t,e)=>{const n=((t-e)%24+24)%24;return n<=12?n/12:-1},vT=9,MT=55,ST=28;function M1(t){const{x:e,y:n,width:s,height:i}=t,r=t.kind??"sky",o=t.ground??n+i*.85,a={...k1,...t.colors},l=t.horizon??"hills",c=t.window!==!1,h=Ge(t.seed??1),u=s*i/1e5,d=Array.from({length:Math.ceil(vT*u)+2},()=>({u:h.next(),v:h.next(),size:.6+h.next()*.8,puffs:2+Math.floor(h.next()*3)})),f=Array.from({length:Math.ceil(MT*u)+4},()=>({u:h.next(),v:h.next(),speed:.8+h.next()*.5})),p=Array.from({length:Math.ceil(ST*u)+4},()=>({u:h.next(),v:h.next(),speed:.7+h.next()*.6,sway:h.next()*Math.PI*2,size:1.5+h.next()*2})),g=Array.from({length:Math.ceil(30*u)+10},()=>({u:h.next(),v:h.next()*.6,size:.6+h.next()*1.2})),m=Array.from({length:6},()=>({phase:h.next()*Math.PI*2,amp:.5+h.next()})),y=Array.from({length:24},()=>({h:.35+h.next()*.65,w:.6+h.next()*.8,windows:h.next()>.3})),v={hour:t.hour??12,clouds:t.clouds??.3,wind:t.wind??0,rain:t.rain??0,snow:t.snow??0},k=ks(),w=(E,P)=>k.keys(E)?.length?k.valueAt(E,P):v[E],T=(E,P)=>{const I=kT(E,P),O=I<0?.5:I,H=o-n;return{x:.1*s+.8*s*O,y:I<0?H+i*.2:H-Math.sin(O*Math.PI)*H*.8,up:I>=0}},A=(E,P,I,O,H)=>{const W=P("hour"),{top:j,bottom:J}=v1(W),et=E.createLinearGradient(0,O.y,0,O.ground);et.addColorStop(0,j),et.addColorStop(1,J),E.fillStyle=et,E.fillRect(O.x,O.y,O.w,O.ground-O.y);const V=wT(W);if(V<.6){E.fillStyle="#ffffff",E.globalAlpha=(.6-V)/.6*.9;for(const C of g)E.beginPath(),E.arc(O.x+C.u*O.w,O.y+C.v*(O.ground-O.y),C.size,0,Math.PI*2),E.fill();E.globalAlpha=1}const L=T(W,6),B=T(W,18),K=Math.min(O.w,O.h)*.06;if(L.up&&(E.fillStyle=a.sun,E.beginPath(),E.arc(O.x+L.x/s*O.w,O.y+L.y/i*O.h,K,0,Math.PI*2),E.fill()),B.up){const C=O.x+B.x/s*O.w,z=O.y+B.y/i*O.h;E.fillStyle=a.moon,E.beginPath(),E.arc(C,z,K*.8,0,Math.PI*2),E.fill(),E.fillStyle=j,E.beginPath(),E.arc(C-K*.35,z-K*.15,K*.7,0,Math.PI*2),E.fill()}const _=Math.max(0,Math.min(1,P("clouds"))),Y=Math.max(-1,Math.min(1,P("wind"))),st=Math.round(_*d.length);E.fillStyle=Ui("#ffffff",a.cloud==="#ffffff"?"#ffffff":a.cloud,1),E.globalAlpha=.55+.4*V;for(let C=0;C<st;C++){const z=d[C],X=((z.u*O.w+Y*I*.012*(.6+z.size*.5))%(O.w*1.4)+O.w*1.4)%(O.w*1.4)-O.w*.2,N=O.x+X,F=O.y+(.08+z.v*.42)*(O.ground-O.y),D=Math.min(O.w,O.h)*.07*z.size;for(let G=0;G<z.puffs;G++)E.beginPath(),E.ellipse(N+(G-(z.puffs-1)/2)*D*.9,F+G%2*D*.25,D*(G%2?.8:1),D*.62,0,0,Math.PI*2),E.fill()}E.globalAlpha=1;const $=C=>Ui(Ui(C,"#0b1530",.65),C,V);if(l==="hills"){E.fillStyle=$(a.hills),E.beginPath(),E.moveTo(O.x,O.ground);const C=40;for(let z=0;z<=C;z++){const X=z/C;let N=0;m.forEach((F,D)=>N+=Math.sin(X*Math.PI*(1.5+D*.7)+F.phase)*F.amp),E.lineTo(O.x+X*O.w,O.ground-Math.max(0,N)*O.h*.045-O.h*.03)}E.lineTo(O.x+O.w,O.ground),E.closePath(),E.fill()}else if(l==="city"){E.fillStyle=$(a.city);let C=O.x;const z=O.w/18;for(const X of y){if(C>O.x+O.w)break;const N=z*X.w,F=O.h*.22*X.h;if(E.fillRect(C,O.ground-F,N,F),X.windows&&V<.5){E.fillStyle="#ffd66b",E.globalAlpha=.5-V;for(let D=O.ground-F+6;D<O.ground-8;D+=9)for(let G=C+4;G<C+N-4;G+=8)E.fillRect(G,D,3,4);E.globalAlpha=1,E.fillStyle=$(a.city)}C+=N+z*.15}}E.fillStyle=$(a.ground),E.fillRect(O.x,O.ground,O.w,O.y+O.h-O.ground)},M=(E,P,I,O)=>{const H=Math.max(-1,Math.min(1,P("wind"))),W=Math.max(0,Math.min(1,P("rain"))),j=Math.max(0,Math.min(1,P("snow")));if(W>0){E.strokeStyle=a.rain,E.globalAlpha=.35+.45*W,E.lineWidth=1.2,E.lineCap="round";const J=O.h*.05,et=H*.45,V=Math.round(W*f.length);E.beginPath();for(let L=0;L<V;L++){const B=f[L],K=((B.v*O.h+I*B.speed*.9)%O.h+O.h)%O.h,_=((B.u*O.w+K*et)%O.w+O.w)%O.w;E.moveTo(O.x+_,O.y+K),E.lineTo(O.x+_+et*J,O.y+K+J)}E.stroke(),E.globalAlpha=1}if(j>0){E.fillStyle=a.snow,E.globalAlpha=.85;const J=Math.round(j*p.length);for(let et=0;et<J;et++){const V=p[et],L=((V.v*O.h+I*V.speed*.08)%O.h+O.h)%O.h,B=Math.sin(I*.002+V.sway)*O.w*.02,K=((V.u*O.w+B+H*L*.3)%O.w+O.w)%O.w;E.beginPath(),E.arc(O.x+K,O.y+L,V.size,0,Math.PI*2),E.fill()}E.globalAlpha=1}},S={kind:"scenery",target:{type:"custom",x:e,y:n,width:s,height:i,props:v,about:{kind:r==="room"?"room":"sky",summary:r==="room"?"A room: a wall, a floor and a window on the sky. Its values are tracks: hour, clouds, wind, rain, snow (seen through the window).":`A sky over ${l==="flat"?"the ground":l}: the sun and moon on their arcs, stars, clouds on the wind, rain and snow. Its values are tracks: hour (0–24), clouds, wind (−1..1), rain, snow (0..1).`,props:Object.fromEntries(Object.keys(v).map(E=>[E,xT(E)]))},draw(E,P,I){const O=P.props??{},H=j=>Number(O[j]??v[j]??0);E.save();const W={x:0,y:0,w:s,h:i,ground:o-n};if(r==="sky")A(E,H,I,W),M(E,H,I,W);else if(E.fillStyle=a.wall,E.fillRect(0,0,s,W.ground),E.fillStyle=a.floor,E.fillRect(0,W.ground,s,i-W.ground),E.fillStyle=a.skirting,E.fillRect(0,W.ground-i*.012,s,i*.012),c){const j=s*.26,J=W.ground*.5,et=s*.62,V=W.ground*.14;E.fillStyle=a.frame,E.fillRect(et-6,V-6,j+12,J+12),E.save(),E.beginPath(),E.rect(et,V,j,J),E.clip(),A(E,H,I,{x:et,y:V,w:j,h:J,ground:V+J*.8}),M(E,H,I,{x:et,y:V,w:j,h:J}),E.restore(),E.strokeStyle=a.frame,E.lineWidth=4,E.beginPath(),E.moveTo(et+j/2,V),E.lineTo(et+j/2,V+J),E.moveTo(et,V+J/2),E.lineTo(et+j,V+J/2),E.stroke()}E.restore()}},ground:o,anchor(E,P=1/0){const I=w("hour",P);if(E==="sun"||E==="moon"){const O=T(I,E==="sun"?6:18);return{x:e+O.x,y:n+O.y}}if(E==="horizon")return{x:e+s/2,y:o-i*.03};if(E==="ground")return{x:e+s/2,y:o};throw new Error(`scenery: ${ft("place",E,["sun","moon","horizon","ground"])}`)},set(E,P){if(!(E in v))throw new Error(`scenery: ${ft("value",E,Object.keys(v))}`);if(typeof P.value!="number"||!Number.isFinite(P.value))throw new Error("scenery.set needs `value`, a number");return k.tween(E,w(E,P.at),P.value,P,1e3),S},tracks:k.tracks};return S}function xT(t){switch(t){case"hour":return{description:"The time of day, 0–24: the sky’s colours, the sun and the moon on their arcs, stars at night",unit:"hours",min:0,max:24};case"clouds":return{description:"Cloud cover",unit:"0..1",min:0,max:1};case"wind":return{description:"The wind, blowing left (−) or right (+): clouds drift, rain slants, snow drifts",unit:"-1..1",min:-1,max:1};case"rain":return{description:"How hard it rains",unit:"0..1",min:0,max:1};default:return{description:"How hard it snows",unit:"0..1",min:0,max:1}}}function S1(t,e){const{width:n,height:s}=e,i=e.ground??s*.85,r=e.scale??s/4.5,o={x:0,y:0,width:n,height:s,ground:i},a=(l,c,h={})=>({preset:l,x:n*c,scale:r,...h});switch(t){case"park":return{scenery:{...o,hour:10.5,clouds:.35,horizon:"hills",...e.scenery},props:[a("tree",.14,{scale:r*1.1}),a("chair",.5,{turn:0}),a("tree",.86,{scale:r*.9})]};case"street":return{scenery:{...o,hour:16,clouds:.25,horizon:"city",colors:{ground:"#8a8f99"},...e.scenery},props:[a("house",.2,{scale:r*.75,turn:.1}),a("car",.5,{turn:1,scale:r*.9}),a("house",.78,{scale:r*.7,turn:.1}),a("tree",.95,{scale:r*.8})]};case"office":return{scenery:{...o,kind:"room",hour:11,clouds:.3,colors:{wall:"#dfe5ec",floor:"#9aa3ad",skirting:"#6c757d"},...e.scenery},props:[a("door",.1,{turn:.15}),a("chair",.46,{turn:0}),a("desk",.58,{turn:0})]};case"home":return{scenery:{...o,kind:"room",hour:20,clouds:.2,...e.scenery},props:[a("door",.08,{turn:.15}),a("chair",.35,{turn:.3}),a("bed",.72,{turn:.25})]};default:throw new Error(ft("scene preset",t,["park","street","office","home"]))}}function TT(t,e){const n=S1(t,e),s=M1(n.scenery),i=n.props.map(r=>ny({x:r.x,y:s.ground,prop:xh(r.preset),scale:r.scale,values:{turn:r.turn??0,...r.values}}));return{scenery:s,props:i,ground:s.ground}}function ET(t){const{timeline:e}=t,n=new Mn;for(const[c,h]of Object.entries(t.targets)){const u=typeof h=="string"?document.querySelector(h):h;if(!u)throw new Error(`quickPlay: no element found for target "${c}" (${String(h)})`);n.registerTarget(c,u)}e.onUpdate=c=>{n.applyState(c),t.onUpdate?.(c)},t.onComplete&&(e.onComplete=t.onComplete);let s=null,i=null,r=!1;const o=c=>{if(r)return;const h=i===null?0:c-i;i=c,h>0&&e.tick(h),s=requestAnimationFrame(o)},a=()=>{s!==null||r||(i=null,s=requestAnimationFrame(o))},l=()=>{s!==null&&cancelAnimationFrame(s),s=null,i=null};return n.applyState(e.getStateAtTime(e.currentTime)),t.autoplay!==!1&&(e.play(),a()),{timeline:e,adapter:n,play(){e.play(),a()},pause(){e.pause(),l()},restart(){e.stop(),e.play(),a()},seek(c){e.seek(c*1e3),n.applyState(e.getStateAtTime(e.currentTime))},destroy(){r=!0,l(),e.stop(),n.clearTargets()}}}const AT={timeline:Uw,to(t,e,n){const s=new vn(n);return s.to(t,e),s},from(t,e,n){const s=new vn(n);return s.from(t,e),s},fromTo(t,e,n,s){const i=new vn(s);return i.fromTo(t,e,n),i},set(t,e,n){const s=new vn(n);return s.set(t,e),s}};function x1(t,e,n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,n);const s=t.canvas;if(s?.ownerDocument){const i=s.ownerDocument.createElement("canvas");return i.width=e,i.height=n,i}try{return s?.constructor?new s.constructor(e,n):null}catch{return null}}function PT(t,e){const n=t.length/4,s=new Float32Array(n*3),i=Math.min(.999,Math.max(0,e));for(let r=0;r<n;r++){const o=t[r*4]/255,a=t[r*4+1]/255,l=t[r*4+2]/255,c=t[r*4+3]/255,h=Math.max(o,a,l);if(h<=i)continue;const u=(h-i)/(1-i)*c/h;s[r*3]=o*u,s[r*3+1]=a*u,s[r*3+2]=l*u}return s}function T1(t,e,n,s,i){const r=new Float32Array(t.length),o=i?n:e,a=i?e:n,l=(h,u)=>(i?h*e+u:u*e+h)*3,c=s*2+1;for(let h=0;h<o;h++)for(let u=0;u<3;u++){let d=0;for(let f=-s;f<=s;f++)d+=t[l(h,Math.min(a-1,Math.max(0,f)))+u];for(let f=0;f<a;f++){r[l(h,f)+u]=d/c;const p=t[l(h,Math.max(0,f-s))+u],g=t[l(h,Math.min(a-1,f+s+1))+u];d+=g-p}}return r}function E1(t,e,n,s){const i=Math.max(1,Math.round(s/Math.sqrt(3)));let r=t;for(let o=0;o<3;o++)r=T1(r,e,n,i,!0),r=T1(r,e,n,i,!1);return r}function $T(t,e={}){const n=t.canvas,s=n.width,i=n.height;if(!(s>0&&i>0))return;const r=Math.max(1,Math.round(e.downsample??4)),o=Math.max(1,Math.ceil(s/r)),a=Math.max(1,Math.ceil(i/r)),l=x1(t,o,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(t.canvas,0,0,o,a);const h=PT(c.getImageData(0,0,o,a).data,e.threshold??.55),u=(e.radius??Math.max(s,i)*.02)/r,d=E1(h,o,a,u),f=E1(h,o,a,u*3),p=e.halo??.6,g=c.createImageData(o,a);for(let m=0;m<o*a;m++){for(let y=0;y<3;y++)g.data[m*4+y]=Math.round(Math.min(1,d[m*3+y]+f[m*3+y]*p)*255);g.data[m*4+3]=255}c.putImageData(g,0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="lighter",t.globalAlpha=Math.max(0,e.strength??.9),t.imageSmoothingEnabled=!0,t.drawImage(l,0,0,s,i),t.restore()}function IT(t,e,n){const s=n.width??6,i=n.taper??1,r=n.fade??1,o=n.opacity??1,a=n.blend==="add";if(t.save(),e.length>=2){const c=CT(e,s,i,r,o);a?(t.globalCompositeOperation="lighter",jh(t,c,n.color)):_T(t,c,n.color)}const l=e[e.length-1];if(n.head&&l&&n.head.radius>0){a&&(t.globalCompositeOperation="lighter");const c=n.head.color??n.color,h=t.createRadialGradient(l.at.x,l.at.y,0,l.at.x,l.at.y,n.head.radius);h.addColorStop(0,c),h.addColorStop(.35,c),h.addColorStop(1,OT(t,c)),t.globalAlpha=o,t.fillStyle=h,t.beginPath(),t.arc(l.at.x,l.at.y,n.head.radius,0,Math.PI*2),t.fill()}t.restore()}function OT(t,e){t.fillStyle=e;const n=String(t.fillStyle),s=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(n);if(s)return`rgba(${parseInt(s[1],16)}, ${parseInt(s[2],16)}, ${parseInt(s[3],16)}, 0)`;const i=/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i.exec(n);return i?`rgba(${i[1]}, ${i[2]}, ${i[3]}, 0)`:"rgba(0, 0, 0, 0)"}function CT(t,e,n,s,i){const r=t.map(c=>({x:c.at.x,y:c.at.y,width:e*(1-n*c.age)})),o=iu(r),a=ru(r)??void 0,l=[];for(let c=0;c+1<t.length;c++){const h=(t[c].age+t[c+1].age)/2,u=i*(1-s*h);if(u<=0)continue;const d=c+2===t.length;l.push({corners:[o.left[c],o.left[c+1],o.right[c+1],o.right[c]],alpha:u,...d&&a&&{cap:a}})}return l}function jh(t,e,n){t.fillStyle=n;for(const s of e){const[i,r,o,a]=s.corners;t.globalAlpha=Math.min(1,s.alpha),t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(r.x,r.y),s.cap&&t.arc(s.cap.x,s.cap.y,s.cap.radius,s.cap.start,s.cap.start-Math.PI,!0),t.lineTo(o.x,o.y),t.lineTo(a.x,a.y),t.closePath(),t.fill()}}function _T(t,e,n){const s=typeof t.getTransform=="function"?t.getTransform():null,i=g=>s?{x:s.a*g.x+s.c*g.y+s.e,y:s.b*g.x+s.d*g.y+s.f}:g,r=s?Math.sqrt(Math.abs(s.a*s.d-s.b*s.c)):1,o=e.map(g=>({...g,corners:g.corners.map(i),...g.cap&&{cap:{...g.cap,...i(g.cap),radius:g.cap.radius*r,start:g.cap.start+(s?Math.atan2(s.b,s.a):0)}}}));let a=1/0,l=1/0,c=-1/0,h=-1/0;for(const g of o){const m=g.cap?[{x:g.cap.x-g.cap.radius,y:g.cap.y-g.cap.radius},{x:g.cap.x+g.cap.radius,y:g.cap.y+g.cap.radius}]:[];for(const y of[...g.corners,...m])a=Math.min(a,y.x),l=Math.min(l,y.y),c=Math.max(c,y.x),h=Math.max(h,y.y)}if(!(c>a&&h>l))return;const u=Math.floor(a)-1,d=Math.floor(l)-1,f=s?x1(t,Math.ceil(c)+1-u,Math.ceil(h)+1-d):null,p=f?.getContext("2d");if(!f||!p){jh(t,e,n);return}p.translate(-u,-d),p.globalCompositeOperation="lighter",jh(p,o,n),t.save(),t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.drawImage(f,u,d),t.restore()}const HT=re.to,RT=re.from,LT=re.fromTo,FT=re.set,NT=re.timeline,WT=re.ticker,DT=re.splitText,BT=re.context,zT=re.matchMedia,qT=re.quickTo,jT=re.imageSequence,YT=re.pageTransition;Mk(),b.ACTING_STYLES=Ln,b.AIRCRAFT_ACTING=kh,b.ANIMAL_GAITS=Is,b.ANIME_CAST=nm,b.BEAT_FIELDS=Io,b.BEAT_MOMENTS=Ts,b.BED_ACTING=Sy,b.BIRD_ACTING=zy,b.BOARD_MARKS=Wc,b.BOARD_THEMES=Hi,b.BODY_SHAPES=Xr,b.CANVAS_PROPERTIES=Lo,b.CHAIR_ACTING=wy,b.CHARACTER_BEAT_3D_FIELDS=Pc,b.CHARACTER_CAST=qc,b.CHARACTER_GAIT_SPEEDS=Fp,b.CHART_KINDS=Bc,b.CHART_SURFACE=Hn,b.CHART_THEMES=Ri,b.CODE_LANGUAGES=Eo,b.CODE_PANEL_EDITS=Fc,b.CODE_SURFACE=_i,b.CODE_THEME=jp,b.CRICKET_ACTIONS=Wn,b.CRICKET_CAMERA_ANGLES=Uo,b.CRICKET_CASTS=Ph,b.CRICKET_DECISION_VIEWS=Yi,b.CRICKET_FIELDING_POSITIONS=Cs,b.CRICKET_FORMATS=We,b.CRICKET_MARKING_PROFILES=Vo,b.CRICKET_PITCH=Yt,b.CRICKET_PLAY_COMPONENTS=gn,b.CRICKET_PLAY_EXAMPLES=f1,b.CRICKET_VIEWS=Go,b.Clock=$1,b.CompatTimeline=vn,b.CustomBounce=Vu,b.CustomEase=Uu,b.CustomWiggle=Ju,b.DANCE_STYLES=Ze,b.DEFAULT_BAKE_INTERVAL_MS=ba,b.DEFAULT_INERTIA_FRICTION=oa,b.DEFAULT_LABELS=od,b.DEFAULT_SPRING=ce,b.DEFAULT_TRANSITION=xk,b.DESK_ACTING=vy,b.DOOR_ACTING=Ty,b.Draggable=qa,b.EMBRACE=Ao,b.EXPRESSIONS=vt,b.FACIAL_HAIR_STYLES=tc,b.FINGERS=$d,b.FLIPS=Ai,b.FOOT_SHAPES=vf,b.FORMAT_VERSION=ta,b.FRAME_ASPECTS=nu,b.GAGS=on,b.GAITS=Xt,b.GAIT_CYCLE_MS=eh,b.GLASSES_STYLES=nc,b.HAIR_COLORS=Ae,b.HAIR_STILL=hs,b.HAIR_STYLES=Ul,b.HAND_MEETINGS=Fi,b.HAND_REST=Ot,b.HAND_SHAPES=St,b.HAT_STYLES=eo,b.HELD_ITEMS=oc,b.HELP_UP=Rn,b.HORSE_ACTING=h4,b.HORSE_GAITS=o4,b.HOUSE_ACTING=yy,b.HUMAN_ACTING_RIG=cm,b.HUMAN_BUILDS=Wr,b.HUMAN_CYCLES=sc,b.HUMAN_DANCES=An,b.HUMAN_EXPRESSIONS=$l,b.HUMAN_GAGS=io,b.HUMAN_POSES=be,b.HUMAN_REST=lt,b.IDENTITY_CAMERA=Wp,b.IDENTITY_SIMILARITY=ow,b.INERTIA_MAX_DURATION_MS=Jh,b.InertiaTrackPlayer=F0,b.LiveTimeline=xe,b.MANGA_CAST=sm,b.MORPH_SAMPLES=J1,b.MUDRAS=_r,b.ManualClock=P1,b.MediaSync=sl,b.OUTFIT_PRESETS=jc,b.Observer=Eu,b.POSES=ae,b.PROP_BEAT_3D_FIELDS=Bh,b.PROP_BEAT_FIELDS=qo,b.PROP_COMMON_ACTIONS=Eh,b.PROP_COMMON_CONTROLS=As,b.PROP_PRESETS=Os,b.PROP_SURFACE=$s,b.QUADRUPED_ACTING=Mh,b.REMOVE_STYLES=xo,b.REST_POSE=ut,b.RIDING_POSES=zh,b.SAMPLE_STEP=sn,b.SCENERY_COLORS=k1,b.SCRIPT_ACTIONS=Wi,b.SOFT_CARTOON_CAST=Li,b.SPRING_MAX_DURATION_MS=ra,b.SPRING_PRESETS=er,b.SPRING_STEP_MS=Dn,b.STICK_ACTING_RIG=lm,b.ScrollAnimator=zu,b.ScrollDriver=ni,b.ScrollMarkers=qu,b.ScrollPin=Nu,b.SmoothScroll=tl,b.SpringSampler=Ws,b.SpringTrackPlayer=L0,b.Stage=ku,b.TREE_ACTING=py,b.Timeline=Ht,b.TinyflyPlayer=wr,b.TinyflySequencer=gd,b.TrackPlayer=Xe,b.VEHICLE_ACTING=iy,b.VISEMES=nn,b.ValueResolver=Tb,b.VisibilityDriver=Fu,b.WHEELCHAIR_ACTING=Py,b.WHITEBOARD_SURFACE=Re,b.actCharacterTracks=dm,b.actKeyframes=$o,b.actTracks=um,b.actionNames=Jc,b.airplane=Oy,b.anchorError=rn,b.animalStrideLength=zo,b.animatableProperties=Wm,b.applyBloom=$T,b.applyCamera=vS,b.applyGroove=ff,b.applySimilarity=Ia,b.aspectOf=$a,b.assertBeats=th,b.audioEnvelope=Zb,b.backOut=a0,b.bakeDanceTracks=Y5,b.bakeEasing=va,b.bakeInertiaTrack=ka,b.bakeSpringTrack=wa,b.ballFlightPoint=_h,b.ballFlightTracks=x4,b.basicOutfit=Wg,b.beatAt=z5,b.beatAtTime=Xs,b.beatLength=Ks,b.beatPeriod=Ub,b.beatPulse=Jb,b.beatTime=lr,b.beatsBetween=Fb,b.bed=My,b.bike=dy,b.bindChoiceHotspots=hd,b.bird=un,b.blendPose=es,b.bodyProfileWidth=wi,b.bodyShapeProfiles=Of,b.boilFrame=rl,b.bounceOut=o0,b.boxMesh=Mp,b.brushingPose=Ig,b.bubblePath=yw,b.bubblePop=bw,b.buildScene=TT,b.bus=ly,b.cameraFromValues=kS,b.cameraPoint=MS,b.cameraTracks=Bb,b.capabilities=g1,b.capabilitiesMarkdown=z4,b.car=oy,b.cart=hy,b.castMember=r3,b.cat=Ly,b.chair=by,b.changingWindows=vs,b.character=ps,b.characterAt=CM,b.characterHandPose=Yg,b.characterJoints=fe,b.characterJointsInView=PM,b.characterLookAtTracks=bS,b.characterObjects=oS,b.characterPartsInView=Gg,b.characterPoseOf=lo,b.characterPoseTracks=_M,b.characterScript=wx,b.characterScript3D=yS,b.characterStrideLength=Lm,b.characterTarget=OM,b.charactersFor=N0,b.chart=t3,b.checkBeats=Di,b.checkCast=Zc,b.checkCharacterBeats3D=Np,b.checkPropBeats=Vy,b.checkPropBeats3D=y1,b.checkSurfaceBeats=_m,b.checkTracks=Ix,b.chicken=Yy,b.circlePath=ES,b.clamp01=Va,b.clearMorphCache=ob,b.clearPathCache=K1,b.clipErased=Lc,b.closestName=Gs,b.codePanel=FS,b.codeTokens=Kp,b.composeSimilarity=lw,b.containerProgressAt=Ja,b.context=BT,b.controlValue=It,b.cow=Fy,b.create=ak,b.createControls=ld,b.createCubicBezier=i0,b.createLive=td,b.createPen=ai,b.createRandom=Ge,b.createTrack=ar,b.cricketAction=h1,b.cricketCameraFraming=r1,b.cricketCameraReview=Ko,b.cricketCameraTracks=$4,b.cricketClip=R4,b.cricketDecisionOverlay=T4,b.cricketEventAt=L4,b.cricketField=Nh,b.cricketFieldingAreaContains=o1,b.cricketFieldingOverlay=O4,b.cricketFieldingPositions=a1,b.cricketPlay=d1,b.cricketPlayClip=D4,b.cricketPlayer=l1,b.criticalDamping=C1,b.crow=jy,b.curve=Gb,b.customBounce=U0,b.customEase=G0,b.customWiggle=V0,b.cylinderMesh=Sp,b.danceCircleAt=ep,b.danceCircleTracks=RM,b.danceFrame=Lr,b.danceJoint=On,b.dancePose=F5,b.danceStance=Rr,b.danceTaps=W5,b.danceTracks=j5,b.danceTravel=Nr,b.danceTravelTrack=bf,b.dancer=q5,b.defineAction=N3,b.defineGait=W3,b.describeTarget=Nm,b.deserializeTimeline=Xn,b.deserializeTrack=z0,b.desk=ky,b.detectTempo=Nb,b.dog=Ry,b.door=xy,b.draggable=k2,b.drawCartoonHand=Pr,b.drawCharacter=Xg,b.drawCharacterHead=IM,b.drawCharacterInView=$M,b.drawDustPuff=pm,b.drawEraser=Hc,b.drawHand=Rc,b.drawHeldItem=ac,b.drawImpactStars=R3,b.drawPencil=Dp,b.drawProp=Kx,b.drawPropEffects=q4,b.drawPropShadow=wc,b.drawSolvedFaces=cp,b.drawSolvedPart=VM,b.drawSolvedProp=yc,b.drawSpeedLines=gm,b.drawStickFigure=lf,b.drawStickSmear=H3,b.drawTrail=IT,b.drawnPathTarget=AS,b.dripPath=mw,b.duck=Xy,b.easeIn=e0,b.easeInCubic=aa,b.easeInOut=s0,b.easeInOutCubic=Bs,b.easeInOutQuad=t0,b.easeInQuad=Zh,b.easeOut=n0,b.easeOutCubic=la,b.easeOutQuad=Qh,b.editDistance=Q0,b.editError=Ci,b.editLog=ks,b.elasticOut=r0,b.ellipsePoints=oi,b.ellipsoidMesh=xp,b.embrace=c3,b.embraceSpacing=l3,b.envelopeAt=Qb,b.erasable=OS,b.expandBeats=Co,b.expandParametricEasings=H0,b.extrudeMesh=Tp,b.flipPose=np,b.flipTracks=DM,b.flipTravel=sp,b.formatVersionFor=ea,b.frameRect=tw,b.frameSize=ew,b.from=RT,b.fromJSON=Mb,b.fromTo=LT,b.gag=Uc,b.gagDuration=Ni,b.gaitPose=Hd,b.gaitStrideLength=$r,b.getEasingFunction=Wt,b.getInterpolator=Ys,b.getMotionPathPoint=Ma,b.getPathLength=X1,b.getPointAtProgress=d0,b.goat=Ny,b.gridLinesFor=$u,b.hairFollow=om,b.hairFollowTracks=S3,b.hairHangs=tg,b.hairMotionAt=v3,b.hairMotionOf=Si,b.hairlineAt=xi,b.handAt=TS,b.handGrip=ro,b.handJoints=Ar,b.handJointsAt=Cd,b.handPath=ch,b.handPose=Nt,b.handProp=gi,b.hasKeyframes=Gh,b.hashSeed=ne,b.headPoint=A5,b.heldTime=Uh,b.helicopter=Iy,b.helpUp=u3,b.helpUpSpacing=h3,b.holdingLayers=zg,b.horse=Hy,b.horseStrideLength=d4,b.house=my,b.humanCyclePose=wM,b.humanDanceFrame=yi,b.humanDanceTracks=mv,b.humanFieldLabel=dv,b.humanGag=Pg,b.humanGaitPose=no,b.humanGaitStrideLength=so,b.humanPlan=Pl,b.humanPose=kt,b.illustrationTones=hl,b.imageSequence=jT,b.inertiaDuration=zn,b.inertiaRest=Bn,b.inertiaValueAt=sr,b.inertiaVelocityAt=L1,b.interpolateArray=I0,b.interpolateColor=$0,b.interpolateMotionPath=yb,b.interpolateNumber=ve,b.interpolatePathString=C0,b.interpolateQuaternion=O0,b.interpolateString=ya,b.invertSimilarity=cw,b.isCubicBezierEasing=Xh,b.isHeld=lc,b.isInertiaTrack=Be,b.isMotionPathPoint=A1,b.isMotionPathTrack=na,b.isParametricEasing=Fs,b.isPathData=jn,b.isSpringTrack=ze,b.isTextTrack=Ji,b.isUnderdamped=O1,b.isUnresolved=xb,b.isoDepth=Oa,b.isometricBoxFaces=Ca,b.isometricFaces=_a,b.jointsInScene=Vg,b.jointsToScene=af,b.leafOutfit=Rg,b.leafOutfitContours=ic,b.linear=ir,b.lipSyncKeyframes=Ec,b.lipSyncOver=wo,b.lipSyncTracks=uS,b.lit=xc,b.live=re,b.lookFields=$c,b.loopBeats=Vb,b.loopEase=qb,b.loopNoise=jb,b.loosePartsOf=bh,b.lyingPose=_y,b.mapEase=Qs,b.mat4=Aw,b.matchMedia=zT,b.maxStaggerDistance=ia,b.measuredHipWidth=_f,b.meetDandiya=HM,b.meetHands=a3,b.meetingSpacing=o3,b.metaballContours=gw,b.metaballField=lu,b.mirrorHumanPose=kf,b.mirrorPose=df,b.mixColors=Tc,b.mixHandPoses=ts,b.mixPoses=dc,b.morphPath=w0,b.motorbike=fy,b.mount=ud,b.mountAll=fd,b.narrationMarkers=_b,b.narrationSceneAt=Hb,b.naturalRest=Ds,b.nearestBeat=Rb,b.nextBeat=Lb,b.niceCeiling=Qp,b.objectPositionAt=_c,b.organicBodyContours=Lf,b.organicCenterLine=vi,b.outfitPreset=rm,b.owl=Gy,b.pageTransition=YT,b.panelMesh=Ep,b.parametricEasing=c0,b.parrot=Uy,b.parseAnchor=_n,b.parseEdge=Ga,b.parsePath=pn,b.parseTrigger=Ua,b.partialPath=Qn,b.pathLength=wd,b.pedallingKeys=yT,b.pedallingPose=qh,b.penroseStairs=fw,b.penroseTriangle=dw,b.persona=yx,b.phaseOf=mn,b.pieceMotion=Oi,b.pigeon=Ky,b.pingPong=Pa,b.planNarration=Cb,b.plantDanceFoot=Qg,b.play=ok,b.playSequence=Sk,b.playWhenVisible=_2,b.playheadCrossings=xa,b.pointAlong=vr,b.pointAtDistance=ha,b.pointOnHead=TM,b.pointsToPath=su,b.pose=Dt,b.poseTracks=O5,b.powSimilarity=hw,b.projectIsometric=ur,b.propActions=jo,b.propAnchors3D=ty,b.propAt=Wo,b.propControls=wh,b.propLineWidth=bc,b.propObjects=oT,b.propPartsInSpace=Qm,b.propPreset=xh,b.propRide=U4,b.propRide3D=bT,b.propScript=Jy,b.propScript3D=fT,b.propShapeMesh=zi,b.propSurface=Ux,b.propTarget=ny,b.propTow=Z4,b.propView=Vm,b.quadruped=cn,b.quat=db,b.quickPlay=ET,b.quickTo=qT,b.rabbit=Wy,b.randomBetween=Ea,b.randomChoice=Sb,b.randomSnapped=j0,b.reachCharacter=He,b.reachOf=Fm,b.resolveActingStyle=Kc,b.resolveCharacterPoseKeys=fc,b.resolveFacialHair=pg,b.resolveGait=ui,b.resolveGlasses=yg,b.resolveHair=sg,b.resolveHat=wg,b.resolveHeadLook=vg,b.resolveHolding=Dg,b.resolveIllustration=Td,b.resolveMeasurements=Wl,b.resolveOrganicBody=Hf,b.resolvePoseKeys=Cr,b.resolveSequence=X0,b.resolveStickFrame=kl,b.resolveStickPose=cf,b.resolveValue=Aa,b.ribbon=iu,b.ribbonHeadCap=ru,b.rideFloors=So,b.rotateAbout=Ve,b.routineBeats=Fr,b.rubberLimb=Sn,b.safeAreas=nw,b.scalePoints=kw,b.scenePreset=S1,b.scenery=M1,b.scriptActionSummaries=Qc,b.scriptTracks=Ho,b.scrollProgress=C2,b.scrubOnScroll=F2,b.scrubPath=$S,b.seatHeight=v5,b.serializeTimeline=q0,b.serializeTrack=D0,b.set=FT,b.shade=yo,b.shapeMesh=$p,b.shapeToPathData=cr,b.similarity=aw,b.similarityAbout=ou,b.similarityFixedPoint=au,b.similarityMatrix=uw,b.simplifyKeyframes=R0,b.sittingPose=vh,b.skeletonInView=jr,b.sketchPen=Mr,b.skyColors=v1,b.smoothPath=Ac,b.smoothToward=Lu,b.snapAxis=Pu,b.snapConfig=Wu,b.snapDuration=Bu,b.snapProgress=Du,b.softCartoonCharacter=i3,b.solveAt=Ps,b.solvePlanSpace=ss,b.solveProp=yh,b.songbird=qy,b.soundsOf=vp,b.speechDuration=Cm,b.speechLength=Hp,b.spliceTracks=J4,b.splitText=DT,b.springDuration=Vh,b.springFollow=Us,b.springValueAt=I1,b.squashStretch=ww,b.squirrel=Dy,b.stagePlanSpace=Qe,b.stageSpots=wS,b.staggerDistance=sa,b.staggerOffset=Zi,b.staggerOffsets=Qi,b.staggerSpan=Ns,b.stepsDuration=ym,b.stepsEasing=l0,b.stepsToKeys=Vc,b.stickFigureAt=Ml,b.stickFigureJoints=ye,b.stickFigureTarget=vl,b.stickToHuman=ip,b.strideLength=Dd,b.surfaceBox=Mt,b.surfaceScript=px,b.sweepingPose=$g,b.syncMediaElement=rd,b.talkingMouth=Bd,b.taperedLine=ri,b.taperedOutline=zt,b.textAt=W0,b.tf=AT,b.ticker=WT,b.timeline=NT,b.to=HT,b.toJSON=vb,b.toKeyframedTrack=pb,b.toKeyframedTracks=mb,b.torusNoise=Yb,b.trackTargets=Ke,b.tractor=cy,b.trailSamples=iw,b.trainCar=uy,b.tree=gy,b.triggerDistance=Un,b.truck=ay,b.tubeMesh=Ap,b.unknownName=ft,b.unmount=kk,b.valueAt=Mo,b.vec3=vw,b.vehicle=Ne,b.walkPose=Wd,b.wheelchair=Ay,b.whiteboard=zS,b.withErased=IS,b.withExpression=Je,b.wobble=zb,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});