@algorisys/tinyfly 0.64.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.
- package/LICENSE +21 -0
- package/README.md +672 -0
- package/bin/tinyfly.mjs +59 -0
- package/lib/addons/adapters.js +756 -0
- package/lib/addons/dom-adapter-ChrbtkLC.js +243 -0
- package/lib/addons/drivers.js +72 -0
- package/lib/addons/export.js +1169 -0
- package/lib/addons/gsap-compat.js +2576 -0
- package/lib/addons/interaction.js +225 -0
- package/lib/addons/smooth-scroll-DaSacemU.js +671 -0
- package/lib/addons/teach.js +215 -0
- package/lib/browser/tinyfly.iife.js +2 -0
- package/lib/browser/tinyfly.js +6372 -0
- package/lib/browser/tinyfly.umd.js +2 -0
- package/lib/cli/tools.js +2325 -0
- package/lib/embed/tinyfly-embed.iife.js +18 -0
- package/lib/embed/tinyfly-embed.js +2316 -0
- package/lib/engine/tinyfly-engine.js +1972 -0
- package/lib/engine/tinyfly-engine.umd.cjs +2 -0
- package/lib/frameworks/react.js +32 -0
- package/lib/frameworks/solid.js +27 -0
- package/lib/frameworks/svelte.js +15 -0
- package/lib/frameworks/vue.js +29 -0
- package/lib/player/tinyfly-player.es.js +2306 -0
- package/lib/player/tinyfly-player.iife.js +2 -0
- package/lib/player/tinyfly-player.umd.js +2 -0
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +238 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/adapters/dom/dom-adapter.d.ts +50 -0
- package/lib/types/adapters/dom/flip.d.ts +60 -0
- package/lib/types/adapters/dom/index.d.ts +2 -0
- package/lib/types/adapters/filter-utils.d.ts +32 -0
- package/lib/types/adapters/index.d.ts +5 -0
- package/lib/types/adapters/shine-utils.d.ts +26 -0
- package/lib/types/adapters/svg/index.d.ts +1 -0
- package/lib/types/adapters/svg/svg-adapter.d.ts +47 -0
- package/lib/types/adapters/svg-transform-box.d.ts +13 -0
- package/lib/types/adapters/text-content.d.ts +11 -0
- package/lib/types/adapters/webgl/index.d.ts +1 -0
- package/lib/types/adapters/webgl/webgl-adapter.d.ts +69 -0
- package/lib/types/browser/index.d.ts +41 -0
- package/lib/types/compat/gsap/custom-eases.d.ts +28 -0
- package/lib/types/compat/gsap/defaults.d.ts +19 -0
- package/lib/types/compat/gsap/draw-svg-vars.d.ts +36 -0
- package/lib/types/compat/gsap/ease-map.d.ts +51 -0
- package/lib/types/compat/gsap/image-sequence.d.ts +61 -0
- package/lib/types/compat/gsap/index.d.ts +65 -0
- package/lib/types/compat/gsap/inertia-vars.d.ts +39 -0
- package/lib/types/compat/gsap/keyframes-vars.d.ts +8 -0
- package/lib/types/compat/gsap/layout.d.ts +6 -0
- package/lib/types/compat/gsap/live-context.d.ts +87 -0
- package/lib/types/compat/gsap/live-draggable.d.ts +75 -0
- package/lib/types/compat/gsap/live-flip.d.ts +73 -0
- package/lib/types/compat/gsap/live-morph.d.ts +18 -0
- package/lib/types/compat/gsap/live-motion-path.d.ts +33 -0
- package/lib/types/compat/gsap/live-scroll-to.d.ts +52 -0
- package/lib/types/compat/gsap/live-scroll.d.ts +108 -0
- package/lib/types/compat/gsap/live-transition.d.ts +40 -0
- package/lib/types/compat/gsap/live.d.ts +341 -0
- package/lib/types/compat/gsap/morph-vars.d.ts +21 -0
- package/lib/types/compat/gsap/motion-path-vars.d.ts +38 -0
- package/lib/types/compat/gsap/playhead-crossings.d.ts +47 -0
- package/lib/types/compat/gsap/position.d.ts +37 -0
- package/lib/types/compat/gsap/quick-play.d.ts +38 -0
- package/lib/types/compat/gsap/split-text.d.ts +66 -0
- package/lib/types/compat/gsap/spring-vars.d.ts +34 -0
- package/lib/types/compat/gsap/stage.d.ts +182 -0
- package/lib/types/compat/gsap/stagger-grid.d.ts +30 -0
- package/lib/types/compat/gsap/text-vars.d.ts +39 -0
- package/lib/types/compat/gsap/timeline.d.ts +161 -0
- package/lib/types/compat/gsap/utils.d.ts +60 -0
- package/lib/types/compat/gsap/vars.d.ts +79 -0
- package/lib/types/drivers/index.d.ts +8 -0
- package/lib/types/drivers/scroll-driver.d.ts +218 -0
- package/lib/types/drivers/scroll-markers.d.ts +41 -0
- package/lib/types/drivers/scroll-math.d.ts +87 -0
- package/lib/types/drivers/scroll-pin.d.ts +45 -0
- package/lib/types/drivers/scroll-snap.d.ts +47 -0
- package/lib/types/drivers/smooth-scroll.d.ts +118 -0
- package/lib/types/drivers/types.d.ts +23 -0
- package/lib/types/drivers/visibility-driver.d.ts +56 -0
- package/lib/types/embed/controls.d.ts +46 -0
- package/lib/types/embed/index.d.ts +17 -0
- package/lib/types/embed/mount.d.ts +41 -0
- package/lib/types/embed/tools.d.ts +33 -0
- package/lib/types/engine/authoring/custom-ease.d.ts +49 -0
- package/lib/types/engine/authoring/index.d.ts +3 -0
- package/lib/types/engine/authoring/random.d.ts +38 -0
- package/lib/types/engine/authoring/resolve-values.d.ts +57 -0
- package/lib/types/engine/core/bake.d.ts +66 -0
- package/lib/types/engine/core/clock.d.ts +44 -0
- package/lib/types/engine/core/index.d.ts +8 -0
- package/lib/types/engine/core/inertia.d.ts +30 -0
- package/lib/types/engine/core/playhead-crossings.d.ts +47 -0
- package/lib/types/engine/core/spring.d.ts +132 -0
- package/lib/types/engine/core/stagger.d.ts +40 -0
- package/lib/types/engine/core/timeline.d.ts +203 -0
- package/lib/types/engine/core/track.d.ts +90 -0
- package/lib/types/engine/export/byte-writer.d.ts +36 -0
- package/lib/types/engine/export/css.d.ts +31 -0
- package/lib/types/engine/export/gif-decode.test-helper.d.ts +24 -0
- package/lib/types/engine/export/gif.d.ts +134 -0
- package/lib/types/engine/export/index.d.ts +9 -0
- package/lib/types/engine/export/lottie.d.ts +104 -0
- package/lib/types/engine/export/mp4.d.ts +64 -0
- package/lib/types/engine/export/quantize.d.ts +56 -0
- package/lib/types/engine/export/sprite-sheet.d.ts +46 -0
- package/lib/types/engine/export/video.d.ts +99 -0
- package/lib/types/engine/export/webp.d.ts +82 -0
- package/lib/types/engine/index.d.ts +7 -0
- package/lib/types/engine/interpolation/easing.d.ts +65 -0
- package/lib/types/engine/interpolation/index.d.ts +2 -0
- package/lib/types/engine/interpolation/interpolators.d.ts +25 -0
- package/lib/types/engine/path/index.d.ts +11 -0
- package/lib/types/engine/path/motion-path.d.ts +24 -0
- package/lib/types/engine/path/path-builders.d.ts +38 -0
- package/lib/types/engine/path/path-morph.d.ts +47 -0
- package/lib/types/engine/path/path-utils.d.ts +73 -0
- package/lib/types/engine/serialization/index.d.ts +1 -0
- package/lib/types/engine/serialization/json.d.ts +30 -0
- package/lib/types/engine/text/index.d.ts +2 -0
- package/lib/types/engine/text/text-value.d.ts +16 -0
- package/lib/types/engine/types.d.ts +401 -0
- package/lib/types/frameworks/react.d.ts +35 -0
- package/lib/types/frameworks/solid.d.ts +16 -0
- package/lib/types/frameworks/svelte.d.ts +19 -0
- package/lib/types/frameworks/vue.d.ts +27 -0
- package/lib/types/interaction/draggable.d.ts +133 -0
- package/lib/types/interaction/index.d.ts +3 -0
- package/lib/types/interaction/observer.d.ts +80 -0
- package/lib/types/interaction/snap.d.ts +30 -0
- package/lib/types/player/index.d.ts +7 -0
- package/lib/types/player/media-sync.d.ts +60 -0
- package/lib/types/player/player.d.ts +238 -0
- package/lib/types/player/sequence-types.d.ts +68 -0
- package/lib/types/player/sequencer.d.ts +91 -0
- package/lib/types/teach/diagrams.d.ts +137 -0
- package/lib/types/teach/index.d.ts +11 -0
- package/lib/types/teach/lesson.d.ts +55 -0
- package/package.json +170 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var tinyfly=(function($){"use strict";function ce(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function le(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const B=1;function wt(e){return e.property==="text"&&"textConfig"in e}function ct(e){return e.kind==="inertia"&&"inertia"in e}function lt(e){return e.kind==="spring"&&"spring"in e}function he(e){return e.property==="motionPath"&&"motionPathConfig"in e}function _t(e,t,s="start"){if(t<=1)return 0;if(typeof s=="number"){const n=Math.max(0,Math.min(t-1,s));return Math.abs(e-n)}switch(s){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function ue(e,t="start"){if(e<=1)return 0;let s=0;for(let n=0;n<e;n++)s=Math.max(s,_t(n,e,t));return s}function xt(e,t,s){if(s.offsets)return s.offsets[e]??0;const n=s.from??"start",i=_t(e,t,n);if(s.amount!==void 0){const r=ue(t,n);return r===0?0:s.amount*i/r}return s.each!==void 0?s.each*i:0}function fe(e,t){return Array.from({length:e},(s,n)=>xt(n,e,t))}function ht(e,t){return e<=1?0:Math.max(...fe(e,t))}const U=1,vt=6e4,J=vt/U,q={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class de{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??q.stiffness,this.damping=t.damping??q.damping,this.mass=t.mass??q.mass,this.restDelta=t.restDelta??q.restDelta,this.restSpeed=t.restSpeed??q.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??q.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const s=Math.floor(t/U);if(this.simulateTo(s+1),this.settledStep!==null&&s>=this.settledStep)return this.to;const n=this.samples[Math.min(s,this.samples.length-1)],i=this.samples[Math.min(s+1,this.samples.length-1)],r=t/U-s;return n+(i-n)*r}settleTime(){return this.simulateTo(J+1),this.settledStep!==null?this.settledStep*U:vt}simulateTo(t){if(this.settledStep!==null)return;const s=Math.min(t,J+1),n=U/1e3;for(;this.samples.length<s;){const i=this.samples[this.samples.length-1],r=i-this.to,a=-this.stiffness*r,o=-this.damping*this.velocity,l=(a+o)/this.mass;this.velocity+=l*n;const c=i+this.velocity*n;if(this.samples.push(c),this.isAtRest(c)){this.settledStep=this.samples.length-1;return}}this.samples.length>J&&(this.settledStep=J)}}const At=4,pe=.002,me=1e-4,ge=6e4;function ut(e){const t=e.friction??At;return t>0?t:At}function ye(e){return e.from+e.velocity/ut(e)}function be(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let s=t[0];for(const n of t)Math.abs(n-e)<Math.abs(s-e)&&(s=n);return s}function Pt(e){let t=be(ye(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function It(e){const t=Math.abs(Pt(e)-e.from);if(t===0)return 0;const s=e.restDelta??Math.max(me,t*pe);if(s>=t)return 0;const n=Math.log(t/s)/ut(e);return Math.min(ge,n*1e3)}function Ct(e,t){if(t<=0)return e.from;const s=Pt(e);if(t>=It(e))return s;const n=ut(e);return e.from+(s-e.from)*(1-Math.exp(-n*t/1e3))}const ft=e=>e,ke=e=>e*e,Me=e=>1-(1-e)*(1-e),Te=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Rt=e=>e*e*e,Et=e=>1-Math.pow(1-e,3),$t=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Se={linear:ft,"ease-in":Rt,"ease-out":Et,"ease-in-out":$t,"ease-in-quad":ke,"ease-out-quad":Me,"ease-in-out-quad":Te,"ease-in-cubic":Rt,"ease-out-cubic":Et,"ease-in-out-cubic":$t};function we(e){const[t,s,n,i]=e,r=3*t,a=3*(n-t)-r,o=1-r-a,l=3*s,c=3*(i-s)-l,u=1-l-c,h=p=>((o*p+a)*p+r)*p,f=p=>((u*p+c)*p+l)*p,d=p=>(3*o*p+2*a)*p+r,k=p=>{let m=p;for(let T=0;T<8;T++){const _=h(m)-p;if(Math.abs(_)<1e-7)return m;const g=d(m);if(Math.abs(g)<1e-7)break;m-=_/g}let y=0,b=1;for(m=p;y<b;){const T=h(m);if(Math.abs(T-p)<1e-7)return m;p>T?y=m:b=m,m=(y+b)/2}return m};return p=>{if(p<=0)return 0;if(p>=1)return 1;const m=k(p);return f(m)}}function dt(e,t="out"){if(t==="out")return e;const s=n=>1-e(1-n);return t==="in"?s:n=>n<.5?s(n*2)/2:e(n*2-1)/2+.5}function _e(e=1,t=.3){const s=Math.max(1,e),n=t/(2*Math.PI)*Math.asin(1/s);return i=>i<=0?0:i>=1?1:s*Math.pow(2,-10*i)*Math.sin((i-n)*(2*Math.PI)/t)+1}const xe=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const i=e-.5454545454545454;return 7.5625*i*i+.75}if(e<2.5/2.75){const i=e-.8181818181818182;return 7.5625*i*i+.9375}const n=e-2.625/2.75;return 7.5625*n*n+.984375};function ve(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const s=t-1;return s*s*((e+1)*s+e)+1}}function Ae(e,t="end"){const s=Math.max(1,Math.floor(e));return n=>{if(n>=1)return 1;if(n<=0)return t==="start"||t==="both"?t==="start"?1/s:1/(s+1):0;const i=Math.floor(n*s);switch(t){case"start":return Math.min(1,(i+1)/s);case"both":return(i+1)/(s+1);case"none":return s===1?0:Math.min(1,i/(s-1));default:return i/s}}}function Pe(e){switch(e.type){case"steps":return Ae(e.count,e.position);case"elastic":return dt(_e(e.amplitude,e.period),e.mode);case"bounce":return dt(xe,e.mode);case"back":return dt(ve(e.overshoot),e.mode)}}function Ie(e){return e===void 0?ft:ce(e)?we(e.points):le(e)?Pe(e):Se[e]??ft}const Dt=32,Ce=256,j=new Map,Re=/[MmLlHhVvCcSsQqTtAaZz]/,Ee=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,$e={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function De(e){const t=[];let s=0,n=null;const i=()=>{for(;s<e.length&&/[\s,]/.test(e[s]);)s++};for(;s<e.length&&(i(),!(s>=e.length));){const r=e[s];if(Re.test(r)){n={type:r,args:[]},t.push(n),s++;continue}if(!n)break;const a=n.type==="A"||n.type==="a",o=n.args.length%7;if(a&&(o===3||o===4)){if(r!=="0"&&r!=="1")break;n.args.push(r==="1"?1:0),s++;continue}const l=Ee.exec(e.slice(s));if(!l)break;n.args.push(parseFloat(l[0])),s+=l[0].length}return t}function Oe(e,t,s,n,i,r,a,o,l){if(e===o&&t===l)return[];let c=Math.abs(s),u=Math.abs(n);if(c===0||u===0)return[[e,t,o,l,o,l]];const h=i*Math.PI/180,f=Math.cos(h),d=Math.sin(h),k=(e-o)/2,p=(t-l)/2,m=f*k+d*p,y=-d*k+f*p,b=m*m/(c*c)+y*y/(u*u);if(b>1){const P=Math.sqrt(b);c*=P,u*=P}const T=r===a?-1:1,_=c*c*u*u-c*c*y*y-u*u*m*m,g=c*c*y*y+u*u*m*m,x=T*Math.sqrt(Math.max(0,_/g)),S=x*c*y/u,I=-x*u*m/c,L=f*S-d*I+(e+o)/2,v=d*S+f*I+(t+l)/2,A=(P,E,D,W)=>{const St=P*D+E*W,ot=Math.sqrt((P*P+E*E)*(D*D+W*W)),K=Math.acos(Math.max(-1,Math.min(1,St/ot)));return P*W-E*D<0?-K:K},M=A(1,0,(m-S)/c,(y-I)/u);let w=A((m-S)/c,(y-I)/u,(-m-S)/c,(-y-I)/u);!a&&w>0&&(w-=2*Math.PI),a&&w<0&&(w+=2*Math.PI);const C=Math.max(1,Math.ceil(Math.abs(w)/(Math.PI/2))),O=w/C,R=4/3*Math.tan(O/4),Q=P=>{const E=c*Math.cos(P),D=u*Math.sin(P);return[f*E-d*D+L,d*E+f*D+v]},Z=P=>{const E=-c*Math.sin(P),D=u*Math.cos(P);return[f*E-d*D,d*E+f*D]},oe=[];for(let P=0;P<C;P++){const E=M+P*O,D=E+O,[W,St]=Q(E),[ot,K]=P===C-1?[o,l]:Q(D),[Vs,Ws]=Z(E),[Bs,Us]=Z(D);oe.push([W+R*Vs,St+R*Ws,ot-R*Bs,K-R*Us,ot,K])}return oe}function X(e,t,s,n,i){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*s+i*i*i*n}function Ot(e,t,s,n,i){const r=1-i;return 3*r*r*(t-e)+6*r*i*(s-t)+3*i*i*(n-s)}function H(e,t,s,n){return{subpath:0,type:"L",points:[s,n],startX:e,startY:t,endX:s,endY:n,length:Math.hypot(s-e,n-t)}}function tt(e,t,s){const[n,i,r,a,o,l]=s,c=[0];let u=e,h=t,f=0;for(let d=1;d<=Dt;d++){const k=d/Dt,p=X(e,n,r,o,k),m=X(t,i,a,l,k);f+=Math.hypot(p-u,m-h),c.push(f),u=p,h=m}return{subpath:0,type:"C",points:[n,i,r,a,o,l],startX:e,startY:t,endX:o,endY:l,length:f,lengths:c}}function et(e){const t=j.get(e);if(t)return t;const s=[];let n=0,i=0,r=0,a=0,o=null,l=null,c=-1;const u=new Set,h=p=>{c<0&&(c=0),p.subpath=c,s.push(p)};for(const{type:p,args:m}of De(e)){const y=p.toUpperCase(),b=p!==y,T=$e[y];if(y==="Z"){(n!==r||i!==a)&&h(H(n,i,r,a)),c>=0&&u.add(c),n=r,i=a,o=l=null;continue}for(let _=0;_+T<=m.length;_+=T){const g=m.slice(_,_+T),x=b?n:0,S=b?i:0;let I=null,L=null;switch(y){case"M":_===0?(n=g[0]+x,i=g[1]+S,r=n,a=i,(c<0||s[s.length-1]?.subpath===c)&&c++):(h(H(n,i,g[0]+x,g[1]+S)),n=g[0]+x,i=g[1]+S);break;case"L":h(H(n,i,g[0]+x,g[1]+S)),n=g[0]+x,i=g[1]+S;break;case"H":h(H(n,i,g[0]+x,i)),n=g[0]+x;break;case"V":h(H(n,i,n,g[0]+S)),i=g[0]+S;break;case"C":{const v=[g[0]+x,g[1]+S,g[2]+x,g[3]+S,g[4]+x,g[5]+S];h(tt(n,i,v)),I=[v[2],v[3]],n=v[4],i=v[5];break}case"S":{const[v,A]=o?[2*n-o[0],2*i-o[1]]:[n,i],M=[v,A,g[0]+x,g[1]+S,g[2]+x,g[3]+S];h(tt(n,i,M)),I=[M[2],M[3]],n=M[4],i=M[5];break}case"Q":case"T":{let v=n,A=i;y==="Q"?(v=g[0]+x,A=g[1]+S):l&&(v=2*n-l[0],A=2*i-l[1]);const M=y==="Q"?g[2]+x:g[0]+x,w=y==="Q"?g[3]+S:g[1]+S;h(tt(n,i,[n+.6666666666666666*(v-n),i+.6666666666666666*(A-i),M+.6666666666666666*(v-M),w+.6666666666666666*(A-w),M,w])),L=[v,A],n=M,i=w;break}case"A":{const v=g[5]+x,A=g[6]+S;let M=n,w=i;for(const C of Oe(n,i,g[0],g[1],g[2],g[3],g[4],v,A))h(tt(M,w,C)),M=C[4],w=C[5];n=v,i=A;break}}o=I,l=L}}const f=s.reduce((p,m)=>p+m.length,0),d=[];for(let p=0;p<s.length;){const m=s[p].subpath;let y=p,b=0;for(;y<s.length&&s[y].subpath===m;)b+=s[y++].length;const T=s[p],_=s[y-1],g=u.has(m)||Math.abs(_.endX-T.startX)<1e-9&&Math.abs(_.endY-T.startY)<1e-9;d.push({start:p,end:y,length:b,closed:g}),p=y}const k={segments:s,totalLength:f,subpaths:d};return j.size>=Ce&&j.delete(j.keys().next().value),j.set(e,k),k}function Le(e,t){const s=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let n=0,i=s.length-1;for(;n<i-1;){const o=n+i>>1;s[o]<t?n=o:i=o}const r=s[i]-s[n],a=r>0?(t-s[n])/r:0;return(n+a)/(s.length-1)}function Ne(e,t){if(e.type==="L"){const h=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*h,y:e.startY+(e.endY-e.startY)*h,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[s,n,i,r,a,o]=e.points,l=Le(e,t);let c=Ot(e.startX,s,i,a,l),u=Ot(e.startY,n,r,o,l);if(Math.hypot(c,u)<1e-9){const h=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),f=X(e.startX,s,i,a,h),d=X(e.startY,n,r,o,h),k=X(e.startX,s,i,a,l),p=X(e.startY,n,r,o,l);c=l<.5?f-k:k-f,u=l<.5?d-p:p-d}return{x:X(e.startX,s,i,a,l),y:X(e.startY,n,r,o,l),angle:Math.atan2(u,c)*180/Math.PI}}function Lt(e,t,s=0,n=e.length){if(n<=s)return{x:0,y:0,angle:0};let i=0;for(let r=s;r<n;r++){const a=e[r];if(i+a.length>=t||r===n-1)return Ne(a,t-i);i+=a.length}return{x:0,y:0,angle:0}}function Xe(e,t){const{segments:s,totalLength:n}=et(e);return Lt(s,Math.max(0,Math.min(1,t))*n)}const Fe=24,Ye=320,qe=2.5,z=72,Ve=.2,We=128,st=new Map;let pt=0,F;const Nt=e=>Math.round(e*100)/100;function Xt(e,t){const{segments:s,subpaths:n,totalLength:i}=et(e);if(s.length===0)return[];if(t){const r=n.every(a=>a.closed);return[{segments:s,start:0,end:s.length,length:i,closed:r}]}return n.filter(r=>r.length>0).map(r=>({segments:s,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function mt(e,t){const s=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),n=Lt(e.segments,s*e.length,e.start,e.end);return[n.x,n.y]}function Ft(e){const t=[];let s=0;for(let n=e.start;n<e.end;n++)s+=e.segments[n].length,e.length>0&&t.push(s/e.length);return t}function Yt(e,t){const s=[];for(let n=0;n<t;n++)s.push(mt(e,e.closed?n/t:n/(t-1)));return s}function qt(e){let t=0,s=0;for(const[n,i]of e)t+=n,s+=i;return t/=e.length,s/=e.length,e.map(([n,i])=>[n-t,i-s])}function Be(e,t,s){const n=e.closed&&t.closed;if(s!==void 0)return{offset:n?Math.abs(s)%z/z:0,reversed:s<0};const i=qt(Yt(e,z)),r=qt(Yt(t,z)),a=z;let o={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const u=n?a:1;for(let h=0;h<u;h++){let f=0;for(let d=0;d<a&&f<l;d++){const k=n?c?(h-d+a)%a:(d+h)%a:c?a-1-d:d,p=i[d][0]-r[k][0],m=i[d][1]-r[k][1];f+=p*p+m*m}f<l&&(l=f,o={offset:n?h/a:0,reversed:c})}}return o}function Ue(e,t,s){return s?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function je(e,t,s){return s?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function He(e,t,s){const n=e.closed&&t.closed,i=Be(e,t,s.shapeIndex),r=Math.max(Fe,Math.min(Ye,Math.ceil(Math.max(e.length,t.length)/qe))),a=new Set,o=h=>a.add(Math.round(h*1e7)/1e7);for(let h=0;h<=r;h++)o(h/r);for(const h of Ft(e))o(h);for(const h of Ft(t))o(je(h,i,n));let l=[...a].sort((h,f)=>h-f);n&&(l=l.filter(h=>h<1));const c=[],u=[];for(const h of l)c.push(...mt(e,h)),u.push(...mt(t,Ue(h,i,n)));return ze({from:c,to:u,closed:n})}function ze(e){const t=e.from.length/2;if(t<=3)return e;const s=new Uint8Array(t);s[0]=1,s[t-1]=1;const n=[[0,t-1]];for(;n.length>0;){const[a,o]=n.pop();let l=-1,c=Ve;for(let u=a+1;u<o;u++){const h=Math.max(Vt(e.from,a,o,u),Vt(e.to,a,o,u));h>c&&(c=h,l=u)}l!==-1&&(s[l]=1,n.push([a,l],[l,o]))}const i=[],r=[];for(let a=0;a<t;a++)s[a]&&(i.push(e.from[a*2],e.from[a*2+1]),r.push(e.to[a*2],e.to[a*2+1]));return{from:i,to:r,closed:e.closed}}function Vt(e,t,s,n){const i=e[t*2],r=e[t*2+1],a=e[s*2]-i,o=e[s*2+1]-r,l=e[n*2]-i,c=e[n*2+1]-r,u=a*a+o*o,h=u===0?0:Math.max(0,Math.min(1,(l*a+c*o)/u));return Math.hypot(l-h*a,c-h*o)}function Ge(e,t,s){const n=s.shapeIndex;if(F&&F.from===e&&F.to===t&&F.shapeIndex===n)return F.plan;const r=st.get(String(n??"auto"))?.get(e)?.get(t);if(r)return F={from:e,to:t,shapeIndex:n,plan:r},r;const a=et(e).subpaths.filter(d=>d.length>0).length===et(t).subpaths.filter(d=>d.length>0).length,o=Xt(e,!a),l=Xt(t,!a),c={pairs:o.map((d,k)=>He(d,l[k],s))};pt>=We&&(st.clear(),pt=0);const u=String(n??"auto"),h=st.get(u)??new Map;st.set(u,h);const f=h.get(e)??new Map;return h.set(e,f),f.set(t,c),pt++,F={from:e,to:t,shapeIndex:n,plan:c},c}function Qe(e,t,s,n={}){if(!e)return t;if(!t)return e;const i=Math.max(0,Math.min(1,s));if(i===0)return e;if(i===1)return t;const r=Ge(e,t,n);if(r.pairs.length===0)return i<.5?e:t;let a="";for(const o of r.pairs){for(let l=0;l<o.from.length;l+=2){const c=Nt(o.from[l]+(o.to[l]-o.from[l])*i),u=Nt(o.from[l+1]+(o.to[l+1]-o.from[l+1])*i);a+=`${l===0?a?" M":"M":" L"}${c} ${u}`}o.closed&&(a+=" Z")}return a}function Ze(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const N=(e,t,s)=>e+(t-e)*s,Wt=512,gt=new Map,yt=new Map;function Bt(e){const t=gt.get(e);if(t)return t;const s=e.replace("#",""),n=[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16)];return gt.size<Wt&>.set(e,n),n}const Ut=e=>e.charCodeAt(0)===35,jt=e=>e.startsWith("rgb"),Ht=e=>e.startsWith("rgba"),Ke=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,bt=e=>Math.round(e).toString(16).padStart(2,"0");function Je(e,t,s){return`#${bt(e)}${bt(t)}${bt(s)}`}function zt(e){const t=yt.get(e);if(t)return t;const s=e.match(Ke);if(!s)throw new Error(`Invalid rgb color: ${e}`);const n=parseInt(s[1],10),i=parseInt(s[2],10),r=parseInt(s[3],10),a=s[4]!==void 0?[n,i,r,parseFloat(s[4])]:[n,i,r];return yt.size<Wt&&yt.set(e,a),a}const ts=(e,t,s)=>{if(Ut(e)&&Ut(t)){const[n,i,r]=Bt(e),[a,o,l]=Bt(t),c=N(n,a,s),u=N(i,o,s),h=N(r,l,s);return Je(c,u,h)}if((jt(e)||Ht(e))&&(jt(t)||Ht(t))){const n=zt(e),i=zt(t),r=Math.round(N(n[0],i[0],s)),a=Math.round(N(n[1],i[1],s)),o=Math.round(N(n[2],i[2],s));if(n.length===4||i.length===4){const l=n[3]??1,c=i[3]??1,u=N(l,c,s);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return s<1?e:t},es=(e,t,s)=>{const n=Math.min(e.length,t.length),i=[];for(let r=0;r<n;r++)i.push(N(e[r],t[r],s));return i},Gt=(e,t,s)=>s<1?e:t,ss=(e,t,s)=>Qe(e,t,s);function ns(e){return typeof e=="number"?N:Array.isArray(e)?es:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?ts:Ze(e)?ss:Gt:Gt}function is(e){const t=[...e.keyframes].sort((s,n)=>s.time-n.time);return{...e,keyframes:t}}function Y(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function V(e,t,s,n){const i=s??0;return!n||t<=1?i:i+xt(e,t,n)}class kt{track;targets;constructor(t){this.track=t,this.targets=Y(t)}getValueAtTime(t){return this.valueForOffset(t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&n.push({target:this.targets[i],value:a,start:r+this.track.keyframes[0].time})}return n}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const s=t[t.length-1].time,n=this.track.stagger?ht(this.targets.length,this.track.stagger):0;return s+(this.track.delay??0)+n+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:s}=this.track;if(s.length===0)return;if(s.length===1||t<=s[0].time)return s[0].value;if(t>=s[s.length-1].time)return s[s.length-1].value;const{from:n,to:i}=this.findSurroundingKeyframes(t);if(!n||!i)return;if(n.time===t)return n.value;const r=i.time-n.time,a=(t-n.time)/r,l=Ie(i.easing)(a);return ns(n.value)(n.value,i.value,l)}findSurroundingKeyframes(t){const{keyframes:s}=this.track;for(let n=0;n<s.length-1;n++)if(t>=s[n].time&&t<=s[n+1].time)return{from:s[n],to:s[n+1]};return{from:null,to:null}}}class rs{track;targets;sampler;constructor(t){this.track=t,this.targets=Y(t),this.sampler=new de(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger);n.push({target:this.targets[i],value:this.sampler.valueAt(t-r),start:r})}return n}getDuration(){const t=this.track.stagger?ht(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class as{track;targets;duration;constructor(t){this.track=t,this.targets=Y(t),this.duration=It(t.inertia)}getValueAtTime(t){return Ct(this.track.inertia,t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger);n.push({target:this.targets[i],value:Ct(this.track.inertia,t-r),start:r})}return n}getDuration(){const t=this.track.stagger?ht(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function os(e,t){const s={...Xe(e.pathData,t)};if(e.matrix){const[n,i,r,a,o,l]=e.matrix,{x:c,y:u}=s;s.x=n*c+r*u+o,s.y=i*c+a*u+l;const h=s.angle*Math.PI/180,f=Math.cos(h),d=Math.sin(h);s.angle=Math.atan2(i*f+a*d,n*f+r*d)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(s.angle+=e.rotateOffset),s}const Mt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},cs=20;function ls(e){const t=Mt[e??"upperCase"]??e??Mt.upperCase,s=Array.from(t);return s.length>0?s:Array.from(Mt.upperCase)}function hs(e,t,s){let n=(e|0)^Math.imul(t+1,2654435761)^Math.imul(s+1,2246822507);return n=Math.imul(n^n>>>16,2146121005),n=Math.imul(n^n>>>15,2221713035),(n^n>>>16)>>>0}function us(e,t,s=0){const n=e.from??"",i=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return n;if(r>=1)return i;const a=Array.from(n),o=Array.from(i),l=e.rightToLeft??!1;if(e.mode==="type"){const b=Math.round(r*Math.max(a.length,o.length));return l?a.slice(0,Math.max(0,a.length-b)).join("")+o.slice(Math.max(0,o.length-b)).join(""):o.slice(0,b).join("")+a.slice(b).join("")}const c=Math.max(0,Math.min(.999,e.revealDelay??0)),u=Math.max(0,(r-c)/(1-c)),h=Math.floor(u*o.length),f=e.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),d=ls(e.chars),k=e.refreshRate??cs,p=k>0?Math.floor(s*k/1e3):0,m=e.seed??1;let y="";for(let b=0;b<f;b++){const T=l?b>=f-h:b<h,_=l?o[o.length-(f-b)]:o[b];T&&_!==void 0||_===" "||_===`
|
|
2
|
+
`?y+=_:y+=d[hs(m,b,p)%d.length]}return y}class fs{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(t){if(this.id=t.id,this.name=t.name,this.captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const s of t.tracks)this.addTrack(s)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const s={...this._config};delete s.duration,this._config=s}}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(t){this._config.speed=t}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,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(t){const s=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,s)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const s=this.duration;if(s<=0)return;let i=t*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,i);if(this._repeatDelayRemaining-=o,i-=o,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let o=0;o<r&&i>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const l=s-this._currentTime;if(i>=l){if(i-=l,this._currentTime=s,!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 a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(t){const s=new Map;if(this._hasSharedWrites())this._resolveShared(t,s);else for(const[n,i]of this._trackPlayers){const r=i.getTrack().property;for(const{target:a,value:o,start:l}of i.getTargetValues(t))this._write(s,n,a,r,o,t-l)}return{values:s,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,s){const n=new Map;for(const[i,r]of this._trackPlayers){const a=r.getTrack().property;for(const{target:o,value:l,start:c}of r.getTargetValues(t)){const u=`${o}\0${a}`,h=c<=t,f=n.get(u);(!f||(h!==f.started?h:h?c>=f.start:c<=f.start))&&n.set(u,{trackId:i,target:o,property:a,value:l,start:c,started:h})}}for(const{trackId:i,target:r,property:a,value:o,start:l}of n.values())this._write(s,i,r,a,o,t-l)}_write(t,s,n,i,r,a){if(r===void 0)return;let o=t.get(n);o||(o=new Map,t.set(n,o));const l=this._textTracks.get(s);if(l&&typeof r=="number"){o.set("text",us(l.textConfig,r,Math.max(0,a)));return}const c=this._motionPathTracks.get(s);if(c&&typeof r=="number"){const u=os(c.motionPathConfig,r);o.set("motionPathX",u.x),o.set("motionPathY",u.y),c.motionPathConfig.autoRotate&&o.set("motionPathRotate",u.angle)}else o.set(i,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const s of this._tracks)for(const n of Y(s)){const i=`${n}\0${s.property}`;if(t.has(i)){this._sharedWrites=!0;break t}t.add(i)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,ct(t)){this._trackPlayers.set(t.id,new as(t));return}if(lt(t)){this._trackPlayers.set(t.id,new rs(t)),this._springTracks.set(t.id,t);return}if(wt(t))this._trackPlayers.set(t.id,new kt(t)),this._textTracks.set(t.id,t);else if(he(t)){const s={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new kt(s)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new kt(t))}replaceTrack(t,s){const n=this._tracks.findIndex(r=>r.id===t);if(n<0)return;const i=this._tracks.slice(n+1);this.removeTrack(t);for(const r of i)this.removeTrack(r.id);this.addTrack(s);for(const r of i)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(s=>s.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(s=>this._matches(s,t))}removeTracks(t={}){const s=this.getTracks(t).map(n=>n.id);for(const n of s)this.removeTrack(n);return s}getTrackSpan(t){const s=this._trackPlayers.get(t);if(!s)return;const n=s.getTrack(),i=n.delay??0;if(lt(n)||ct(n))return{from:i,to:s.getDuration()};const r=n.keyframes;if(!(!r||r.length===0))return{from:r[0].time+i,to:s.getDuration()}}findConflicts(){const t=[];for(let s=0;s<this._tracks.length;s++){const n=this._tracks[s],i=this.getTrackSpan(n.id);if(i)for(let r=0;r<s;r++){const a=this._tracks[r];if(a.property!==n.property)continue;const o=Y(a).filter(h=>Y(n).includes(h));if(o.length===0)continue;const l=this.getTrackSpan(a.id);if(!l||!(l.from<=i.to&&i.from<=l.to))continue;const u=i.from>=l.from;for(const h of o)t.push({target:h,property:n.property,losingTrackId:u?a.id:n.id,winningTrackId:u?n.id:a.id})}}return t}_matches(t,s){if(s.id!==void 0&&t.id!==s.id||s.property!==void 0&&t.property!==s.property||s.target!==void 0&&!Y(t).includes(s.target))return!1;if(s.timeRange){const n=this.getTrackSpan(t.id);if(!n||n.to<s.timeRange.from||n.from>s.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:B,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((t,s)=>t.time-s.time)}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,s]of this._trackPlayers)t=Math.max(t,s.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(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 t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const ds=100;function ps(e,t,s,n){const i=[],r=[],{duration:a,alternate:o}=n,l=(d,k,p,m)=>{r.push([d,k]);const y=[];e.forEach((b,T)=>{(p==="forward"?(m?b>=d:b>d)&&b<=k:(m?b<=d:b<d)&&b>=k)&&y.push(T)}),y.sort((b,T)=>(p==="forward"?e[b]-e[T]:e[T]-e[b])||b-T);for(const b of y)i.push({kind:"event",index:b,direction:p})};let c=t.time,u=t.direction,h=t.fresh===!0;const f=Math.min(ds,Math.max(0,s.iteration-t.iteration));for(let d=0;d<f;d++){const k=u==="forward"?a:0;l(c,k,u,h),i.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",c=k,h=!1):(c=u==="forward"?0:a,h=!0)}return f>0&&n.holding&&!o?{crossings:i,passes:r}:(l(c,s.time,u,h),{crossings:i,passes:r})}function ms(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function G(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function gs(e){if(ct(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:ms(t.inertia),...G(t)}}if(lt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...G(t)}}if(wt(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((s,n)=>s.time-n.time),...G(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,s=[...t.keyframes].sort((n,i)=>n.time-i.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:s,...G(t)}}return is({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...G(e)})}function nt(e){const t=e.formatVersion??1;if(t>B)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${B}. Update tinyfly to play it.`);return new fs({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(gs),captions:e.captions})}const ys=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),bs="#ffffff",ks="rgba(0, 0, 0, 0.5)";function Ms(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??bs})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const s=e.shadowX??0,n=e.shadowY??0,i=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${s}px ${n}px ${i}px ${e.shadowColor??ks})`)}return t.length>0?t.join(" "):null}function Ts(e,t){const s=e.childNodes.length===1?e.firstChild:null;if(s&&s.nodeType===3){const n=s;n.data!==t&&(n.data=t);return}e.textContent!==t&&(e.textContent=t)}function Ss(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Qt=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"]),ws=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),_s=new Set(["originX","originY"]),xs=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),vs={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},Zt={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},As="http://www.w3.org/2000/svg";class Tt{targets=new Map;registerTarget(t,s){this.targets.set(t,s)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[s,n]of t.values){const i=this.targets.get(s);i&&this.applyProperties(i,n)}}applyProperties(t,s){const n=[];let i=null,r=null,a=null;const o=s.has("motionPathX"),l=s.has("motionPathY"),c=s.has("motionPathRotate");for(const[f,d]of s)if(!(f==="x"&&o)&&!(f==="y"&&l)&&!((f==="rotate"||f==="rotateZ")&&c)){if(ws.has(f)){const k=this.buildTransformPart(f,d);k&&n.push(k)}else if(_s.has(f))typeof d=="number"&&((i??={})[f]=d);else if(xs.has(f))typeof d=="number"&&((r??={})[f]=d);else if(ys.has(f))(a??={})[f]=d;else if(f!=="perspective"){if(f!=="shine")if(f==="text"&&typeof d=="string")Ts(t,d);else if(f==="d"&&typeof d=="string"){const k=t;(k.tagName?.toLowerCase()==="path"?k:k.querySelector?.("path"))?.setAttribute?.("d",d)}else this.applyStyleProperty(t,f,d)}}const u=s.get("shine");typeof u=="number"&&this.applyShine(t,u);const h=s.get("perspective");if(typeof h=="number"&&n.unshift(`perspective(${h}px)`),n.length>0&&(t.style.transform=n.join(" "),Ss(t)),i){const f=i.originX??50,d=i.originY??50;t.style.transformOrigin=`${f}% ${d}%`}if(r){const f=r.clipTop??0,d=r.clipRight??0,k=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${f}% ${d}% ${k}% ${p}%)`}if(a){const f=Ms(a);f&&(t.style.filter=f)}}buildTransformPart(t,s){if(typeof s!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${s}px)`;case"y":case"motionPathY":return`translateY(${s}px)`;case"z":return`translateZ(${s}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${s}deg)`;case"rotateX":return`rotateX(${s}deg)`;case"rotateY":return`rotateY(${s}deg)`;case"scale":return`scale(${s})`;case"scaleX":return`scaleX(${s})`;case"scaleY":return`scaleY(${s})`;case"scaleZ":return`scaleZ(${s})`;case"skewX":return`skewX(${s}deg)`;case"skewY":return`skewY(${s}deg)`;default:return null}}applyShine(t,s){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const n=t.dataset.shineBase,i=-20+s*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${n}, ${n})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${i}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,s,n){let i;if(t.namespaceURI===As&&s in Zt){const o=Array.isArray(n)?n.join(", "):String(n);t.style[Zt[s]]=o;return}else s==="fill"&&t.dataset?.elementType==="text"?i="color":i=vs[s]??s;let a;typeof n=="number"?Qt.has(s)||Qt.has(i)?a=`${n}px`:a=String(n):Array.isArray(n)?a=n.join(", "):a=n,t.style[i]=a}}class Kt{media;offset;driftTolerance;constructor(t,s={}){this.media=t,this.offset=s.offset??0,this.driftTolerance=Math.max(0,s.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,s){const n=this.targetTime(t);s?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-n)>this.driftTolerance&&(this.media.currentTime=n)):(this.media.paused||this.media.pause(),this.media.currentTime!==n&&(this.media.currentTime=n))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function Ps(e,t,s,n,i){const r=s-i;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,n)}class it{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];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(t,s={}){if(typeof t=="string"){const n=document.querySelector(t);if(!n)throw new Error(`Container not found: ${t}`);this.container=n}else this.container=t;this.options=s,this.adapter=new Tt}async load(t){let s;if(typeof t=="string"){const n=await fetch(t);if(!n.ok)throw new Error(`Failed to load animation: ${n.statusText}`);s=await n.json()}else s=t;this.options.speed!==void 0&&(s.config={...s.config,speed:this.options.speed}),this.options.loop!==void 0&&(s.config={...s.config,loop:this.options.loop}),this.options.alternate!==void 0&&(s.config={...s.config,alternate:this.options.alternate}),this.timeline=nt(s),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(),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let s;for(const n of this.markers)if(n.time<=t+.5)s=n;else break;return s}caption(t,s){const n=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!n)return;const i=s??this.language(),r=a=>a?.[i]?.[n.id]??a?.[i.split("-")[0]]?.[n.id];return r(this.options.captions)??r(this.timeline?.captions)??n.label}next(){if(!this.timeline)return;const t=this.currentTime,s=this.markers.find(n=>n.time>t+.5);if(this.reducedMotion){this.seek(s?s.time:this.duration);return}t>=this.duration-.5||(this.stepping=s!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,s=[...this.markers].reverse().find(n=>n.time<t-.5);this.pause(),this.seek(s?s.time:0)}goToMarker(t){const s=this.markers.find(n=>n.id===t);s&&(this.pause(),this.seek(s.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const s=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,s))),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.listeners.clear(),this.visibilityObserver=new IntersectionObserver(s=>{for(const n of s)this.onScreen=n.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,s=t?.id;s!==this.lastMarkerId&&(this.lastMarkerId=s,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(s=>{const n=s,i=Number(n.getAttribute("data-tinyfly-start")??"0")||0,r=n.getAttribute("data-volume");r!==null&&(n.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:n,startTime:i,sync:new Kt(n)})})}syncAllMedia(t,s){for(const n of this.mediaTargets)Ps(n.sync,n.el,t,s,n.startTime)}loadFromString(t){const s=JSON.parse(t);this.load(s)}registerTarget(t,s){if(typeof s=="string"){const n=this.container.querySelector(s);n&&(this.targets[t]=n,this.adapter.registerTarget(t,n))}else this.targets[t]=s,this.adapter.registerTarget(t,s)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(s=>{const n=s.closest("[data-tinyfly-symbol]");if(n&&n!==s)return;const i=s.getAttribute("data-tinyfly");i&&this.registerTarget(i,s)}),this.timeline&&new Set(this.timeline.tracks.map(n=>n.target)).forEach(n=>{if(!this.targets[n]){const i=this.container.querySelector(`[data-tinyfly="${n}"]`)||this.container.querySelector(`.${n}`)||this.container.querySelector(`#${n}`);i&&this.registerTarget(n,i)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const s=new Map(t.map(n=>[n.id,n]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(n=>{const i=n.getAttribute("data-tinyfly-symbol");if(!i)return;const r=s.get(i);if(!r||!r.timeline.tracks?.length)return;const a=new Tt;n.querySelectorAll("[data-tinyfly]").forEach(o=>{const l=o.getAttribute("data-tinyfly");l&&a.registerTarget(l,o)}),this.symbolInstances.push({adapter:a,timeline:nt(r.timeline)})})}attachMedia(t,s){this.mediaSync=new Kt(t,s),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 t=this.timeline.playbackState==="idle";this.timeline.play(),t&&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(t){this.timeline&&(this.timeline.seek(t),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(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}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 t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=s=>{if(this.isDestroyed||!this.timeline)return;const n=s-(this.lastTime??s);this.lastTime=s;const i=this.playhead;this.timeline.tick(n),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(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const s=this.timeline,n={time:s.currentTime,iteration:s.loopIteration,direction:s.direction};this.playhead=n;const i=this.markers;if(i.length===0)return;const{crossings:r}=ps(i.map(a=>a.time),t,n,{duration:s.duration,alternate:s.config.alternate===!0,holding:s.repeatDelayRemaining>0});for(const a of r){if(a.kind!=="event")continue;const o=i[a.index];if(this.stepping||o.pause){this.stepping=!1,s.pause(),s.seek(o.time),this.playhead={time:o.time,iteration:s.loopIteration,direction:s.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const s of this.symbolInstances){const n=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(n>0?t%n:t))}}}async function Is(e,t,s={}){const n=new it(e,{...s,autoplay:!0});return await n.load(t),n}function Cs(e,t={}){return new it(e,t)}const Jt={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of"},te="tinyfly-controls-style",Rs=`
|
|
3
|
+
.tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
|
|
4
|
+
font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
|
|
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); }
|
|
6
|
+
.tf-ctl-btn { min-width: 36px; height: 36px; padding: 0 10px; border: 0; border-radius: calc(var(--tf-ctl-radius) - 2px); background: transparent; color: inherit; font: inherit; cursor: pointer; }
|
|
7
|
+
.tf-ctl-btn:hover { background: color-mix(in srgb, var(--tf-ctl-fg) 8%, transparent); }
|
|
8
|
+
.tf-ctl-btn:focus-visible, .tf-ctl-scrub:focus-visible, .tf-ctl-speed:focus-visible { outline: 2px solid var(--tf-ctl-accent); outline-offset: 2px; }
|
|
9
|
+
.tf-ctl-btn[disabled] { opacity: 0.4; cursor: default; }
|
|
10
|
+
.tf-ctl-primary { background: var(--tf-ctl-accent); color: #fff; }
|
|
11
|
+
.tf-ctl-primary:hover { background: var(--tf-ctl-accent); filter: brightness(1.08); }
|
|
12
|
+
.tf-ctl-scrub { flex: 1 1 120px; min-width: 80px; accent-color: var(--tf-ctl-accent); }
|
|
13
|
+
.tf-ctl-speed { height: 32px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; }
|
|
14
|
+
.tf-ctl-step { font-variant-numeric: tabular-nums; opacity: 0.75; padding: 0 4px; }
|
|
15
|
+
.tf-ctl-caption { margin: 6px 2px 0; min-height: 1.4em; }
|
|
16
|
+
.tf-ctl-question { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 2px 0; font-weight: 600; }
|
|
17
|
+
.tf-ctl-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
18
|
+
`;function Es(e){if(e.getElementById(te))return;const t=e.createElement("style");t.id=te,t.textContent=Rs,e.head.appendChild(t)}function ee(e,t,s={}){const n=t.ownerDocument;Es(n);const i={...Jt,...s.labels},r=s.speeds??[.5,1,2],a=()=>e.markers.length>0,o=n.createElement("div");o.className="tf-ctl";const l=n.createElement("div");l.className="tf-ctl-bar",l.setAttribute("role","group");const c=(M,w,C,O="")=>{const R=n.createElement("button");return R.type="button",R.className=`tf-ctl-btn ${O}`.trim(),R.setAttribute("aria-label",M),R.title=M,R.textContent=w,R.addEventListener("click",C),R},u=c(i.restart,"⟲",()=>{e.pause(),e.seek(0)}),h=c(i.prev,"◀",()=>e.prev()),f=c(i.play,"▶",()=>e.isPlaying?e.pause():k(),"tf-ctl-primary"),d=c(i.next,"▶|",()=>e.next()),k=()=>{e.currentTime>=e.duration-.5&&e.seek(0),e.play()},p=n.createElement("input");p.type="range",p.className="tf-ctl-scrub",p.min="0",p.max="1000",p.step="1",p.setAttribute("aria-label",i.scrub),p.addEventListener("input",()=>{e.pause(),e.seek(Number(p.value)/1e3*e.duration)});const m=n.createElement("span");m.className="tf-ctl-step";const y=n.createElement("select");y.className="tf-ctl-speed",y.setAttribute("aria-label",i.speed);for(const M of r){const w=n.createElement("option");w.value=String(M),w.textContent=`${M}×`,M===1&&(w.selected=!0),y.appendChild(w)}y.addEventListener("change",()=>e.setSpeed(Number(y.value))),l.append(u,h,f,d,p,m),r.length>0&&l.append(y),o.append(l);const b=n.createElement("p");b.className="tf-ctl-caption",b.setAttribute("aria-live","polite"),s.captions!==!1&&o.append(b);const T=n.createElement("div");T.className="tf-ctl-question",T.hidden=!0;const _=n.createElement("span"),g=c(i.reveal,i.reveal,()=>e.play(),"tf-ctl-primary");T.append(_,g),o.append(T);const x=s.mount;x?x.appendChild(o):t.insertAdjacentElement("afterend",o);const S=()=>{const M=e.isPlaying;f.textContent=M?"❚❚":"▶",f.setAttribute("aria-label",M?i.pause:i.play),f.title=M?i.pause:i.play;const w=e.duration;n.activeElement!==p&&(p.value=String(w>0?Math.round(e.currentTime/w*1e3):0));const C=e.markers;if(h.hidden=d.hidden=m.hidden=C.length===0,C.length>0){const O=e.currentMarker,R=O?C.indexOf(O)+1:0;m.textContent=`${R} / ${C.length}`,m.setAttribute("aria-label",`${i.step} ${R} ${i.of} ${C.length}`),h.disabled=e.currentTime<=.5,d.disabled=e.currentTime>=w-.5;const Q=e.caption()??"";b.textContent!==Q&&(b.textContent=Q);const Z=!M&&O?.question!==void 0&&Math.abs(e.currentTime-O.time)<1;T.hidden=!Z,Z&&_.textContent!==O.question&&(_.textContent=O.question)}else T.hidden=!0},I=e.subscribe(S);S();const L=s.keyboardScope??t;!L.hasAttribute("tabindex")&&L.tabIndex<0&&(L.tabIndex=0);const v=new WeakSet,A=M=>{if(v.has(M)||(v.add(M),M.defaultPrevented||M.altKey||M.ctrlKey||M.metaKey))return;const w=M.target;if(!(w.tagName==="INPUT"||w.tagName==="SELECT")&&!(M.key===" "&&w.tagName==="BUTTON"))switch(M.key){case" ":M.preventDefault(),e.isPlaying?e.pause():k();break;case"ArrowRight":if(!a())return;M.preventDefault(),e.next();break;case"ArrowLeft":if(!a())return;M.preventDefault(),e.prev();break;case"Home":M.preventDefault(),e.pause(),e.seek(0);break}};return L.addEventListener("keydown",A),o.addEventListener("keydown",A),{element:o,destroy(){I(),L.removeEventListener("keydown",A),o.removeEventListener("keydown",A),o.remove()}}}const rt=new WeakMap;let $s=0;function at(e,t,s){if(e)try{return JSON.parse(e)}catch(n){console.warn(`tinyfly: invalid ${t} JSON on`,s,n);return}}async function se(e,t={}){const s=rt.get(e);if(s)return s;const n=e.querySelector("script[data-tinyfly-timeline]"),i=e.getAttribute("data-src"),r=n?at(n.textContent,"timeline",e):void 0;if(!r&&!i){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const a=at(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),o={playWhenVisible:!0,...t.player,...a&&{captions:a},...at(e.getAttribute("data-options"),"data-options",e)};Os(e);const l=new it(e,o),c={element:e,player:l};if(rt.set(e,c),e.setAttribute("data-tinyfly-mounted",""),await l.load(r??i),e.getAttribute("data-controls")!=="false"){const u=at(e.getAttribute("data-labels"),"data-labels",e),h=e.querySelector("figcaption");c.controls=ee(l,e,{...t.controls,labels:{...t.controls?.labels,...u},mount:void 0}),h?e.insertBefore(c.controls.element,h):e.appendChild(c.controls.element)}return c}async function ne(e=document,t={}){const s=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(s.map(i=>se(i,t)))).filter(i=>i!==void 0)}function Ds(e){const t=rt.get(e);t&&(t.controls?.destroy(),t.player.destroy(),rt.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function Os(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const s=e.getAttribute("data-alt"),n=e.querySelector("figcaption");t.setAttribute("role","img"),s?t.setAttribute("aria-label",s):n&&(n.id||=`tinyfly-caption-${++$s}`,t.setAttribute("aria-labelledby",n.id))}function ie(e){const t=new Set;for(const s of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g))t.add(s[2]??s[3]);return[...t]}function Ls(e,t={}){const s=[],n=c=>s.push({level:"error",message:c}),i=c=>s.push({level:"warning",message:c});if((e.formatVersion??1)>B)return n(`format version ${e.formatVersion} is newer than this tinyfly reads (${B})`),s;let r=0;try{r=nt(e).duration}catch(c){return n(`the timeline does not load: ${c instanceof Error?c.message:String(c)}`),s}const a=e.config?.duration;if(a!==void 0)for(const c of e.tracks){if(!("keyframes"in c))continue;const u=c.keyframes.filter(h=>h.time>a);u.length>0&&n(`track "${c.id}" has a keyframe at ${u[0].time}ms, after the ${a}ms duration`)}const o=e.config?.markers??[],l=new Set;o.forEach((c,u)=>{l.has(c.id)&&n(`marker id "${c.id}" is used more than once`),l.add(c.id),(c.time<0||c.time>r)&&n(`marker "${c.id}" at ${c.time}ms is outside the animation (0–${r}ms)`),u>0&&c.time<o[u-1].time&&n(`marker "${c.id}" comes before "${o[u-1].id}" in time; list markers in order`)});for(const[c,u]of Object.entries(e.captions??{})){for(const h of Object.keys(u))l.has(h)||n(`caption "${h}" (${c}) has no marker with that id`);for(const h of l)h in u||i(`marker "${h}" has no ${c} caption; its label is shown instead`)}if(t.markup!==void 0){const c=new Set(ie(t.markup)),u=new Set;for(const h of e.tracks)for(const f of[h.target,...h.targets??[]])u.add(f),c.has(f)||n(`track "${h.id}" targets "${f}", but no element has data-tinyfly="${f}"`);for(const h of c)u.has(h)||i(`data-tinyfly="${h}" is never animated`)}return s}function Ns(e,t,s="end"){const n=nt(t),i=t.config?.markers??[],r=s==="start"?0:s==="end"?n.duration:typeof s=="number"?s:i.find(f=>f.id===s)?.time??n.duration,a=n.getStateAtTime(Math.max(0,Math.min(n.duration,r))),o=new Tt,l=new Map,c=Fs(e);for(const f of e.matchAll(re)){const d=/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(f[2]??"");if(!d)continue;const k=d[2]??d[3];if(l.has(k))continue;const p=Xs(c(f.index??0));l.set(k,p),o.registerTarget(k,p)}o.applyState(a);let u="",h=0;for(const f of e.matchAll(re)){const[d,k,p="",m]=f,y=f.index??0,b=/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(p),T=b?l.get(b[2]??b[3]):void 0;if(!T||Object.keys(T.style).length===0&&T.text===void 0)continue;u+=e.slice(h,y);const _=Object.entries(T.style).map(([S,I])=>`${Ys(S)}: ${I}`).join("; "),g=/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(p);let x=p;if(_)if(g){const S=`${(g[2]??g[3]).trim().replace(/;?$/,";")} ${_}`.trim();x=p.replace(g[0],` style="${ae(S)}"`)}else x=`${p} style="${ae(_)}"`;if(u+=`<${k}${x}${m?" /":""}>`,h=y+d.length,T.text!==void 0&&!m){const S=e.indexOf(`</${k}`,h),I=S===-1?"":e.slice(h,S);S!==-1&&!I.includes("<")&&(u+=qs(T.text),h=S)}}return u+e.slice(h)}const re=/<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;function Xs(e){const t={style:{},dataset:{},namespaceURI:e?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",childNodes:[],get textContent(){return t.text??""},set textContent(s){t.text=s}};return e&&(t.ownerSVGElement=null),t}function Fs(e){const t=[],s=/<svg[\s>]/gi;let n;for(;n=s.exec(e);){const i=e.toLowerCase().indexOf("</svg>",n.index);t.push([n.index+1,i===-1?e.length:i])}return i=>t.some(([r,a])=>i>r&&i<a)}function Ys(e){const t=e.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return/^(webkit|moz|ms)-/.test(t)?`-${t}`:t}function ae(e){return e.replace(/&/g,"&").replace(/"/g,""")}function qs(e){return e.replace(/&/g,"&").replace(/</g,"<")}if((typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto")){const e=()=>{ne()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}return $.DEFAULT_LABELS=Jt,$.TinyflyPlayer=it,$.create=Cs,$.createControls=ee,$.mount=se,$.mountAll=ne,$.play=Is,$.renderFrame=Ns,$.targetNamesIn=ie,$.unmount=Ds,$.validateEmbed=Ls,Object.defineProperty($,Symbol.toStringTag,{value:"Module"}),$})({});
|