@bydiorama/motion 0.4.0 → 0.4.1
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/CREDITS.md +5 -14
- package/README.md +4 -9
- package/catalog.json +2 -2
- package/dist/npm/browser/motion.js +3 -3
- package/dist/npm/browser/page.js +2 -2
- package/dist/npm/browser/wizard.js +2 -2
- package/dist/npm/cli/main.js +1 -1
- package/dist/npm/core/ease.d.ts +1 -1
- package/dist/npm/core/ease.js +1 -1
- package/dist/npm/dom/mount.js +1 -1
- package/dist/npm/dom/stage.css.js +1 -1
- package/dist/npm/dom/ui-themes.css.js +2 -2
- package/dist/npm/film/resolve.js +1 -1
- package/dist/npm/film/types.d.ts +2 -2
- package/dist/npm/film/types.js +1 -1
- package/dist/npm/primitives/el/slot.js +1 -1
- package/dist/npm/tokens.d.ts +1 -1
- package/dist/npm/version.d.ts +1 -1
- package/dist/npm/version.js +1 -1
- package/package.json +1 -1
- package/schema/film.schema.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Z=(e,n=0,t=1)=>Math.min(t,Math.max(n,e)),ve=(e,n,t)=>e+(n-e)*t;function je(e,n,t,r){let a=3*e,s=3*(t-e)-a,i=1-a-s,o=3*n,u=3*(r-n)-o,m=1-o-u,d=p=>((i*p+s)*p+a)*p,c=p=>((m*p+u)*p+o)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let f=p;for(let g=0;g<8;g++){let b=(3*i*f+2*s)*f+a;if(Math.abs(b)<1e-6)break;f-=(d(f)-p)/b}if(f<0||f>1||Math.abs(d(f)-p)>1e-4){let g=0,b=1;for(let h=0;h<24;h++)f=(g+b)/2,d(f)<p?g=f:b=f}return c(f)}}function en({duration:e,bounce:n=0}){let t=2*Math.PI/(Math.max(.05,e)*1.2),r=Z(1-n,.05,1);return a=>{if(a<=0)return 0;if(a>=1)return 1;let s=a*e*(1+2*n);if(r<1){let i=t*Math.sqrt(1-r*r);return 1-Math.exp(-r*t*s)*(Math.cos(i*s)+r*t/i*Math.sin(i*s))}return 1-Math.exp(-t*s)*(1+t*s)}}var pt={"ui.default":[.2,0,0,1],"ui.in":[.4,0,1,1],"ui.out":[0,0,.2,1],"ui.spring":[.22,1,.36,1]},zt={"expressive.out":[.05,.7,.1,1],"expressive.in":[.3,0,.8,.15],"expressive.inOut":[.7,0,.1,1],"snap.out":[.3,.9,.1,1],"anticipate.in":[.45,-.48,1,-.82],punch:[.16,1,.3,1],"bounce.out":[.34,1.36,.64,1]},Bs={linear:[0,0,1,1],smooth:[.45,0,.55,1],"sine.in":[.12,0,.39,0],"sine.out":[.61,1,.88,1],"sine.inOut":[.37,0,.63,1],"cubic.in":[.32,0,.67,0],"cubic.out":[.33,1,.68,1],"cubic.inOut":[.65,0,.35,1],"expo.in":[.7,0,.84,0],"expo.out":[.16,1,.3,1],"expo.inOut":[.87,0,.13,1],"quad.in":[.11,0,.5,0],"quad.out":[.5,1,.89,1],"quad.inOut":[.45,0,.55,1],"quart.in":[.5,0,.75,0],"quart.out":[.25,1,.5,1],"quart.inOut":[.76,0,.24,1],"quint.in":[.64,0,.78,0],"quint.out":[.22,1,.36,1],"quint.inOut":[.83,0,.17,1],"circ.in":[.55,0,1,.45],"circ.out":[0,.55,.45,1],"circ.inOut":[.85,0,.15,1],"back.in":[.36,0,.66,-.56],"back.out":[.34,1.56,.64,1],"back.inOut":[.68,-.6,.32,1.6],"elastic.out":[.34,1.56,.64,1],...zt,...pt},Rt={linear:e=>e,"sine.in":e=>1-Math.cos(e*Math.PI/2),"sine.out":e=>Math.sin(e*Math.PI/2),"sine.inOut":e=>-(Math.cos(Math.PI*e)-1)/2,"cubic.in":e=>e*e*e,"cubic.out":e=>1-Math.pow(1-e,3),"cubic.inOut":e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,"expo.in":e=>e<=0?0:Math.pow(2,10*e-10),"expo.out":e=>e>=1?1:1-Math.pow(2,-10*e),"expo.inOut":e=>e<=0?0:e>=1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2,"back.out":e=>1+2.70158*Math.pow(e-1,3)+1.70158*Math.pow(e-1,2),smooth:e=>e*e*e*(e*(e*6-15)+10),"quad.in":e=>e*e,"quad.out":e=>1-(1-e)*(1-e),"quad.inOut":e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,"quart.in":e=>e*e*e*e,"quart.out":e=>1-Math.pow(1-e,4),"quart.inOut":e=>e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2,"quint.in":e=>e*e*e*e*e,"quint.out":e=>1-Math.pow(1-e,5),"quint.inOut":e=>e<.5?16*Math.pow(e,5):1-Math.pow(-2*e+2,5)/2,"circ.in":e=>1-Math.sqrt(1-e*e),"circ.out":e=>Math.sqrt(1-Math.pow(e-1,2)),"circ.inOut":e=>e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2,"back.in":e=>2.70158*e*e*e-1.70158*e*e,"back.inOut":e=>{let n=2.5949095;return e<.5?Math.pow(2*e,2)*((n+1)*2*e-n)/2:(Math.pow(2*e-2,2)*((n+1)*(e*2-2)+n)+2)/2},"elastic.out":e=>e<=0?0:e>=1?1:Math.pow(2,-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1},Pe=[...Object.keys(Rt),...Object.keys(zt),...Object.keys(pt)],tn=e=>{if(typeof e=="string")return!0;if(Array.isArray(e))return e.length===4&&e.every(n=>typeof n=="number");if(e&&typeof e=="object"&&"spring"in e){let n=e.spring;return!!n&&typeof n=="object"&&typeof n.duration=="number"}return!1};function Re(e,n={}){if(e===void 0)return Rt["expo.out"];if(typeof e=="string"){let t=n[e]??pt[e]??zt[e];if(t)return je(...t);let r=Rt[e];if(!r)throw new Error(`Unknown ease "${e}". Known: ${Pe.join(", ")}`);return a=>r(Z(a))}return Array.isArray(e)?je(...e):en(e.spring)}function ae(e,n,t,r){return t<=0?e>=n?1:0:r(Z((e-n)/t))}function $e(e=1){let n=e>>>0||1;return()=>{n=n+1831565813>>>0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function Ot(e,n="sine.inOut",t={}){if(e.length===0)throw new Error("A track needs at least one key");let r=[...e].sort((s,i)=>s[0]-i[0]),a=r.map(s=>Re(s[2]??n,t));return s=>{let i=r[0],o=r[r.length-1];if(s<=i[0])return i[1];if(s>=o[0])return o[1];let u=1;for(;r[u][0]<s;)u++;let m=r[u-1],d=r[u],c=d[0]-m[0],p=c<=0?1:a[u]((s-m[0])/c);return m[1]+(d[1]-m[1])*p}}var qe=["start","end","center","edges","random"];function Dt(e,n="start",t=1,r){if(e<=0)return[];if(n==="random"){let c=$e(t*977+e),p=Array.from({length:e},(b,h)=>h);for(let b=e-1;b>0;b--){let h=Math.floor(c()*(b+1));[p[b],p[h]]=[p[h],p[b]]}let f=r&&e>1?Math.hypot(r[0]-1,r[1]-1)/(e-1):1,g=new Array(e);return p.forEach((b,h)=>{g[b]=h*f}),g}let[a,s]=r??[e,1],i=c=>[c%a,Math.floor(c/a)],o=(a-1)/2,u=(s-1)/2,m=c=>{let[p,f]=i(c);return n==="end"?Math.hypot(a-1-p,s-1-f):n==="center"?Math.hypot(p-o,f-u):n==="edges"?Math.hypot(o,u)-Math.hypot(p-o,f-u):Math.hypot(p,f)},d=Array.from({length:e},(c,p)=>m(p));return r?d:d.map(c=>Math.floor(c+1e-9))}function Me(e,n,t="start",r=1,a){let s=Dt(e,t,r,a),i=Math.max(0,...s);return s.map(o=>i>0?o*n:0)}function ze(e,n="start",t=1,r){return Math.max(0,...Dt(e,n,t,r))}function Lt(e,n,t=.5){let a=e.map(([u,m])=>Math.hypot(u-n[0],m-n[1])).map((u,m)=>[u,m]).sort((u,m)=>u[0]-m[0]||u[1]-m[1]),s=new Array(e.length),i=-1,o=-1/0;for(let[u,m]of a)u-o>t&&(i++,o=u),s[m]=i;return s}var ft={fps:30,beat:2.5,hold:.6,hold_end:1.5,duration:{instant:0,fast:.3,base:.5,slow:.8},stagger:{tight:.03,base:.08,loose:.12},ease_enter:"expo.out",ease_exit:"cubic.in",ease_move:"cubic.inOut",ease_loop:"linear",transitions:"standard",ui:{duration:{fast:.12,base:.2,slow:.32,enter:.4},stagger:.1}},ht=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function gt(e,n){if(!ht(e)||!ht(n))return n===void 0?e:n;let t={...e};for(let[r,a]of Object.entries(n))t[r]=gt(t[r],a);return t}var et=(...e)=>e.reduce((n,t)=>gt(n,t),ft);function It(e){let n=[],t=(r,a)=>{if(ht(r)&&!("spring"in r))for(let[s,i]of Object.entries(r))t(i,a?`${a}.${s}`:s);else n.push(a)};return t(e,""),n}function tt(e,n){let t=e;for(let r of n.replace(/^\$/,"").split(".")){if(!ht(t)||!(r in t))return;t=t[r]}return t}var We=e=>typeof e=="string"&&e.startsWith("$");var Ze=(e,n)=>`${e.base}${String(Math.min(e.count-1,Math.max(0,n))+1).padStart(5,"0")}.${e.ext}`,l=(e,n=0)=>typeof e=="number"&&Number.isFinite(e)?e:n,F=(e,n="")=>typeof e=="string"?e:e==null?n:String(e),te=e=>Array.isArray(e)?e.map(n=>String(n)):[],ge=e=>Array.isArray(e)?e.map(n=>l(n)):[];var Na={base:"var(--m-bg-base)",surface:"var(--m-bg-surface)",sunken:"var(--m-bg-sunken)",accent:"var(--m-bg-accent)",inverse:"var(--m-bg-inverse)"},nn={slug:"el/box",summary:"A plain rectangle: a card, a rule, a colour field.",props:{fill:{type:"string",default:"surface",label:"Surface name (base, surface, sunken, accent, inverse) or a CSS colour"}},params:{width:{type:"number",default:480,min:1,max:4e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:270,min:1,max:4e3,step:1,unit:"px",label:"Height"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"}},duration:()=>0,build(e,n,t){let r=F(n.fill,"surface");return e.style.width=`${l(t.width)}px`,e.style.height=`${l(t.height)}px`,e.style.borderRadius=`${l(t.radius)}px`,e.style.background=Na[r]??r,{seek(){}}}};var Ha=(e,n)=>e.replace(/%(?:0(\d+))?d/,(t,r)=>String(n).padStart(r?Number(r):0,"0"));function ja(e,n){let t=Math.floor(Math.max(0,e-n.delay)*n.rate*n.fps+1e-6),r=Math.abs(n.last-n.first);return n.first+Math.sign(n.last-n.first)*Z(t,0,r)}var rn=e=>({first:Math.round(l(e.first)),last:Math.round(l(e.last)),fps:l(e.fps,24),rate:l(e.rate,1),delay:l(e.delay)}),an={slug:"el/frames",summary:"Footage as a numbered run of stills, played at its own frame rate. Holds its first and last frame.",props:{src:{type:"string",required:!0,label:"Path pattern with the frame number, e.g. footage/shot/f%03d.jpg"},alt:{type:"string",default:"",label:"Description of the footage"}},params:{first:{type:"number",default:0,min:0,max:1e5,step:1,unit:"frame",label:"First frame played"},last:{type:"number",default:23,min:0,max:1e5,step:1,unit:"frame",label:"Last frame played, then held. Before the first frame, the run plays backwards"},fps:{type:"number",default:24,min:1,max:120,step:1,unit:"fps",label:"Frame rate the footage was shot at"},rate:{type:"number",default:1,min:.1,max:4,step:.01,unit:"\xD7",label:"Playback speed"},delay:{type:"number",default:0,min:0,max:30,step:.05,unit:"s",label:"Time held on the first frame before it plays"},width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Width"},radius:{type:"number",default:0,min:0,max:400,step:1,unit:"px",label:"Corner radius"}},cues:()=>[],duration:(e,n)=>{let t=rn(n);return t.delay+(Math.abs(t.last-t.first)+1)/t.fps/t.rate},build(e,n,t){let r=e.ownerDocument,a=rn(t),s=F(n.src);e.style.cssText+=`;display:grid;width:${l(t.width)}px;border-radius:${l(t.radius)}px;overflow:hidden`;let i=[],o=Math.min(a.first,a.last),u=Math.max(a.first,a.last);for(let d=o;d<=u;d++){let c=r.createElement("img");c.src=Ha(s,d),c.alt=d===a.first?F(n.alt):"",c.decoding="sync",c.style.cssText="grid-area:1/1;display:block;width:100%;height:auto;visibility:hidden",e.appendChild(c),i.push(c)}let m=-1;return{seek(d){let c=ja(d,a)-o;c!==m&&(m>=0&&(i[m].style.visibility="hidden"),i[c].style.visibility="inherit",m=c)}}}};var sn={slug:"el/html",summary:"Static markup, for content no primitive covers. Style it with --ui-* tokens.",props:{html:{type:"html",required:!0,label:"Markup"}},params:{},duration:()=>0,build(e,n){return e.innerHTML=F(n.html),{seek(){}}}};var on={slug:"el/image",summary:"A picture. The path is relative to the film file.",props:{src:{type:"string",required:!0,label:"Image path or URL"},alt:{type:"string",default:"",label:"Description of the picture"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:0,min:0,max:4e3,step:1,unit:"px",label:"Height; 0 keeps the picture's own proportions, otherwise it is cropped to fill"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"},frame:{type:"number",default:0,min:0,max:24,step:.5,unit:"px",label:"Ring drawn inside the edge, in the border colour (--m-frame to change it)"},bevel:{type:"number",default:0,min:0,max:1,step:.05,unit:"strength",label:"A light top edge and a dark bottom edge, as on a printed card"}},duration:()=>0,build(e,n,t){let r=e.ownerDocument,a=`${l(t.radius)}px`,s=r.createElement("img");s.src=F(n.src),s.alt=F(n.alt),s.decoding="sync";let i=l(t.height);s.style.cssText=`display:block;width:${l(t.width)}px;height:${i>0?`${i}px`:"auto"};object-fit:cover;border-radius:${a}`,e.appendChild(s),e.style.borderRadius=a;let o=l(t.frame),u=l(t.bevel);if(o>0||u>0){let m=r.createElement("div"),d=[o>0?`inset 0 0 0 ${o}px var(--m-frame, var(--m-border))`:"",u>0?`inset 0 1px 0 rgb(255 255 255 / ${(.55*u).toFixed(3)}), inset 0 -1px 0 rgb(0 0 0 / ${(.35*u).toFixed(3)})`:""].filter(Boolean).join(", ");m.style.cssText=`position:absolute;inset:0;border-radius:${a};box-shadow:${d};pointer-events:none`,e.appendChild(m)}return{seek(){}}}};var ln={slug:"el/slot",summary:"An empty frame the host page fills, e.g. with a rendered bydiorama/ui component.",props:{name:{type:"string",required:!0,label:"Slot name the host fills"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:360,min:1,max:4e3,step:1,unit:"px",label:"Height"}},duration:()=>0,build(e,n,t,r){let a=F(n.name);e.dataset.motionSlot=a,e.style.width=`${l(t.width)}px`,e.style.minHeight=`${l(t.height)}px`;let s=r.slots[a];return s?s(e):(e.style.cssText+=";display:grid;place-items:center;border:2px dashed var(--m-border);border-radius:16px;font:500 24px var(--m-font-mono);color:var(--m-text-muted)",e.textContent=`slot: ${a}`),{seek(){}}}};var un={slug:"el/text",summary:"A block of text. Animate it with enter, exit and tracks.",props:{text:{type:"string",required:!0,label:"Text. Use \\n for a line break."}},params:{},duration:()=>0,build(e,n){return e.style.whiteSpace="pre-line",e.textContent=F(n.text),{seek(){}}}};function qa(e){let n=ge(e);return n.length===4&&n[2]>0&&n[3]>0?[n[0],n[1],n[2],n[3]]:[0,0,100,100]}function nt(e,n,t){let r=l(n.from),a=l(n.to),s=l(t.rate,1),i=Math.max(0,e)*s;return t.loop===!0&&a>r?r+i%(a-r):a>r?Math.min(a,r+i):r+i}var mn={slug:"el/video",summary:"Footage. Plays a stretch of a video file; the path is relative to the film file.",props:{src:{type:"string",required:!0,label:"Video path or URL"},from:{type:"number",default:0,label:"Source time the layer opens on, in seconds"},to:{type:"number",default:0,label:"Source time it ends on, in seconds; 0 plays on until the scene ends"},crop:{type:"number[]",default:[],label:"Part of the picture to show: [x, y, width, height] in % of the source"},continues:{type:"string",default:"",label:'Open on the frame after another video layer ends, as "scene.layer": a seamless loop through footage'}},params:{rate:{type:"number",default:1,min:.1,max:4,step:.05,unit:"\xD7",label:"Playback speed"},loop:{type:"boolean",default:!1,label:'Wrap from "to" back to "from" until the scene ends'},width:{type:"number",default:1280,min:1,max:8e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:0,min:0,max:8e3,step:1,unit:"px",label:"Height; 0 keeps the shot's proportions"},radius:{type:"number",default:0,min:0,max:400,step:1,unit:"px",label:"Corner radius"}},cues:()=>[],duration:(e,n)=>{let t=l(e.from),r=l(e.to);return n.loop===!0||!(r>t)?0:(r-t)/l(n.rate,1)},check(e,n){let t=[],r=l(e.from),a=l(e.to);r<0&&t.push({path:"props.from",message:"from is a source time in seconds, zero or more."}),a!==0&&a<=r&&t.push({path:"props.to",message:`to (${a} s) must come after from (${r} s).`,hint:"Leave it at 0 to play on until the scene ends."}),n.loop===!0&&!(a>r)&&t.push({path:"params.loop",message:"A loop needs both ends: set props.to after props.from."});let s=ge(e.crop);s.length&&(s.length!==4||s[2]<=0||s[3]<=0||s[0]<0||s[1]<0||s[0]+s[2]>100.001||s[1]+s[3]>100.001)&&t.push({path:"props.crop",message:"crop is [x, y, width, height] in % of the source, inside 0\u2013100.",hint:"For the middle half: [25, 25, 50, 50]."});let i=F(e.continues);return i&&!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/.test(i)&&t.push({path:"props.continues",message:'continues names a video layer as "scene.layer".'}),i&&l(e.from)!==0&&t.push({path:"props.from",message:'from is worked out from "continues"; the value given is ignored.',hint:"Remove from, or remove continues."}),t},build(e,n,t,r){let a=e.ownerDocument,[s,i,o,u]=qa(n.crop),m=l(t.width),d=l(t.height),c=l(t.radius),p=a.createElement("div");p.style.cssText=`position:relative;overflow:hidden;width:${m}px;border-radius:${c}px;${d>0?`height:${d}px`:"aspect-ratio:16 / 9"}`,e.style.borderRadius=`${c}px`;let f=a.createElement("div");f.style.cssText=`position:absolute;left:${-s/o*100}%;top:${-i/u*100}%;width:${100/o*100}%;height:${100/u*100}%`,p.appendChild(f),e.appendChild(p);let g="object-fit:fill;display:block;width:100%;height:100%",b=(j,x)=>{if(!(j>0&&x>0))return;if(d<=0){p.style.aspectRatio=`${(j*o).toFixed(3)} / ${(x*u).toFixed(3)}`;return}let N=j*o/(x*u)/(m/d);f.style.transformOrigin=`${s+o/2}% ${i+u/2}%`,f.style.transform=`scale(${Math.max(1,N).toFixed(5)}, ${Math.max(1,1/N).toFixed(5)})`},h=r.frames;if(h){let j=a.createElement("img");j.decoding="sync",j.alt="",j.style.cssText=g,j.src=Ze(h,0),f.appendChild(j),b(h.width,h.height);let x=0,N=0,S=Promise.resolve(),$=(X,C)=>j.decode().catch(()=>{if(!(X!==N||j.complete&&j.naturalWidth>0))return new Promise((q,P)=>{j.addEventListener("load",()=>q(),{once:!0}),j.addEventListener("error",()=>X===N?P(new Error(`Video frame did not load: ${C}`)):q(),{once:!0})})});return{seek(X){let C=Math.round((nt(X,n,t)-h.start)*h.rate+1e-6),q=Math.min(h.count-1,Math.max(0,C));if(q===x)return;x=q;let P=Ze(h,q);j.src=P,S=$(++N,P)},pending:()=>S}}let y=a.createElement("video");y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=F(n.src),y.style.cssText=g,f.appendChild(y),y.addEventListener("loadedmetadata",()=>b(y.videoWidth,y.videoHeight));let v=()=>a.documentElement.classList.contains("render"),E=l(t.rate,1),M=Promise.resolve(),k=-1,R=0,z,L=j=>{Math.abs(y.currentTime-j)<.5/r.fps||(M=new Promise(x=>{let N=()=>{y.removeEventListener("seeked",N),x()};y.addEventListener("seeked",N),y.currentTime=j}))};return{seek(j){let x=nt(j,n,t);if(v()){L(x);return}let N=performance.now(),S=j-k,$=(N-R)/1e3;k=j,R=N,S>0&&S<.25&&Math.abs(S-$)<.1?(Math.abs(y.currentTime-x)>.2&&(y.currentTime=x),y.playbackRate=E,y.paused&&y.play().catch(()=>{}),clearTimeout(z),z=setTimeout(()=>y.pause(),120)):(y.pause(),L(x))},pending:()=>M}}};var dn={slug:"fx/counter-roll",summary:"A number rolls up to its value.",props:{value:{type:"number",required:!0,label:"The number to land on"},from:{type:"number",default:0,label:"The number to start from"},decimals:{type:"number",default:0,label:"Decimal places"},prefix:{type:"string",default:"",label:"Text before the number"},suffix:{type:"string",default:"",label:"Text after the number"}},params:{duration:{type:"number",default:1,min:.6,max:1.5,step:.05,unit:"s",label:"Time to roll"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=l(n.value),i=l(n.from),o=Math.max(0,Math.round(l(n.decimals))),u=l(t.duration);return e.style.fontVariantNumeric="tabular-nums",e.style.whiteSpace="pre",{seek(m){let d=m>=u?s:i+(s-i)*ae(m,0,u,a);e.textContent=`${F(n.prefix)}${d.toFixed(o)}${F(n.suffix)}`}}}};var cn={slug:"fx/depth-drift",summary:"A floating collage on several depth planes.",props:{items:{type:"string[]",required:!0,label:"Labels of the floating pieces"}},params:{planes:{type:"number",default:3,min:2,max:3,step:1,unit:"planes",label:"Depth planes"},speed:{type:"number",default:20,min:10,max:30,step:1,unit:"px/s",label:"Drift speed of the nearest plane"}},duration:()=>0,build(e,n,t,r){let[a,s]=r.size,i=a/100,o=Math.max(1,Math.round(l(t.planes))),u=l(t.speed),m=$e(r.seed*101+7),d=r.ease(r.tokens.ease_enter),c=r.tokens.duration.base,p=r.tokens.stagger.base;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let f=te(n.items).map((g,b,h)=>{let y=(b+m()*.6)/h.length*Math.PI*2,v=.3+m()*.14,E=a/2+Math.cos(y)*a*v,M=s/2+Math.sin(y)*s*(v+.04),k=b%o,R=o===1?1:1-k/o,z=document.createElement("span");return z.textContent=g,z.style.cssText=`position:absolute;left:0;top:0;padding:${.7*i}px ${1.4*i}px;border-radius:999px;white-space:nowrap;background:var(--m-bg-surface);font:500 ${1.4*i}px var(--m-font-mono);color:var(--m-text-primary)${k===0&&o>1?`;filter:blur(${.06*i}px)`:""}`,e.appendChild(z),{n:z,x:E,y:M,depth:R,delay:b*p}});return{seek(g){for(let b of f){let h=(g-2)*u*b.depth;b.n.style.transform=`translate(${b.x+h}px, ${b.y}px) translate(-50%, -50%) scale(${.72+b.depth*.42})`,b.n.style.opacity=String(d(Math.min(1,Math.max(0,(g-b.delay)/c)))*(.35+b.depth*.5))}}}}};var pn={slug:"fx/stagger-fill",summary:"Items appear one after another.",props:{items:{type:"string[]",required:!0,label:"The items, in reading order"}},params:{stagger:{type:"number",default:.04,min:.02,max:.06,step:.005,unit:"s",label:"Delay between items"}},duration:(e,n,t)=>Math.max(0,te(e.items).length-1)*l(n.stagger)+t.tokens.duration.base,build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=r.tokens.duration.base,i=l(t.stagger);e.style.cssText+=";display:flex;flex-wrap:wrap;justify-content:center;gap:0.5em";let o=te(n.items).map(u=>{let m=document.createElement("span");return m.textContent=u,m.style.cssText="padding:0.45em 0.9em;border-radius:999px;background:var(--m-bg-surface);white-space:nowrap;will-change:transform,opacity",e.appendChild(m),m});return{seek(u){o.forEach((m,d)=>{let c=ae(u,d*i,s,a);m.style.opacity=String(c),m.style.transform=`scale(${.9+.1*c})`})}}}};var hn=["inverse","plain","accent","tint"],fn={slug:"rig/orbit-ring",summary:"Tiles on a tilted ring that rotates forever.",props:{items:{type:"string[]",default:[],label:"Tile labels. Repeated to fill the ring; empty tiles when left out."}},params:{tiles:{type:"number",default:12,min:8,max:16,step:1,unit:"tiles",label:"Tiles"},tilt_x:{type:"number",default:25,min:15,max:35,step:1,unit:"deg",label:"Pitch",pad:{name:"tilt",axis:"y"}},tilt_z:{type:"number",default:-20,min:-30,max:-10,step:1,unit:"deg",label:"Roll",pad:{name:"tilt",axis:"x"}},period:{type:"number",default:15,min:12,max:18,step:.5,unit:"s",label:"Time for one turn"},min_opacity:{type:"number",default:.4,min:.3,max:.6,step:.01,unit:"ratio",label:"Opacity of tiles facing away",from:"texture/depth-fade"},radius:{type:"number",default:24,min:14,max:34,step:.5,unit:"% of stage width",label:"Ring radius"},tile:{type:"number",default:11,min:6,max:16,step:.5,unit:"% of stage width",label:"Tile size"}},duration:()=>0,build(e,n,t,r){let[a]=r.size,s=a/100,i=Math.max(1,Math.round(l(t.tiles))),o=te(n.items),u=l(t.radius)*s,m=l(t.tile)*s,d=l(t.min_opacity),c=Math.max(.1,l(t.period));e.style.cssText+=`;position:absolute;inset:0;max-width:none;perspective:${120*s}px;perspective-origin:50% 42%`;let p=document.createElement("div");p.style.cssText=`position:absolute;left:50%;top:47%;width:0;height:0;transform-style:preserve-3d;transform:rotateX(${-l(t.tilt_x)}deg) rotateZ(${l(t.tilt_z)}deg)`;let f=Array.from({length:i},(g,b)=>{let h=document.createElement("div"),y=o.length?o[b%o.length]:"",v=hn[b%hn.length],E=[...y].length>3,M=v==="inverse"?"background:var(--m-bg-inverse);color:var(--m-text-inverse)":v==="accent"?"background:var(--m-bg-accent);color:var(--m-text-on-accent)":v==="tint"?"background:color-mix(in srgb, var(--m-bg-accent) 24%, var(--m-bg-base));color:var(--m-accent)":"background:var(--m-bg-surface);color:var(--m-text-primary)";return h.textContent=y,h.style.cssText=`position:absolute;left:${-m/2}px;top:${-m/2}px;width:${m}px;height:${m}px;border-radius:${m*.12}px;display:grid;place-items:center;overflow:hidden;font:${E?`500 ${m*.14}px var(--m-font-mono)`:`600 ${m*.4}px var(--m-font-display)`};letter-spacing:${E?"0":"-0.03em"};${M}`,p.appendChild(h),h});return e.appendChild(p),{seek(g){let b=g/c*360;f.forEach((h,y)=>{let v=y*360/i+b,E=(Math.cos(v*Math.PI/180)+1)/2;h.style.transform=`rotateY(${v}deg) translateZ(${u}px)`,h.style.opacity=String(d+(1-d)*E),h.style.filter=E<.999?`saturate(${.35+.65*E})`:""})}}}};var gn=[1,1.24,.6,1.1,.9,1.3],bn=[.1,.5,.92,.3,.7,.2],xn={slug:"scene/marquee-wall",summary:"Rows of chips or logos scrolling sideways.",props:{items:{type:"string[]",required:!0,label:"Chip labels"},highlight:{type:"string",default:"",label:"One label to emphasise while the others dim"}},params:{rows:{type:"number",default:5,min:4,max:6,step:1,unit:"rows",label:"Rows"},speed:{type:"number",default:60,min:30,max:120,step:5,unit:"px/s",label:"Scroll speed"},dim_opacity:{type:"number",default:.5,min:.4,max:.6,step:.01,unit:"ratio",label:"Opacity of the other items once one is emphasised",from:"fx/marquee-highlight"},highlight_at:{type:"number",default:1.5,min:0,max:10,step:.1,unit:"s",label:"When the emphasis starts"}},duration:()=>0,build(e,n,t,r){let a=te(n.items),s=Math.max(1,Math.round(l(t.rows))),i=l(t.speed),o=F(n.highlight);e.style.cssText+=`;width:${r.size[0]}px;display:flex;flex-direction:column;gap:0.55em;overflow:hidden`;let u=Array.from({length:s},(p,f)=>{let g=a.filter((k,R)=>R%s===f),b=g.length?g:a,h=document.createElement("div");h.style.cssText="display:flex;width:max-content;will-change:transform";let y=k=>b.forEach(R=>{let z=document.createElement("span");if(z.textContent=R,z.style.cssText="position:relative;flex:none;margin-right:0.5em;padding:0.45em 0.9em;border-radius:999px;white-space:nowrap;background:var(--m-bg-surface)",R===o){let L=document.createElement("span");L.textContent=R,L.setAttribute("aria-hidden","true"),L.style.cssText="position:absolute;inset:0;display:grid;place-items:center;border-radius:inherit;background:var(--m-bg-accent);color:var(--m-text-on-accent);opacity:var(--k, 0)",z.appendChild(L),z.style.transform="scale(calc(1 + 0.08 * var(--k, 0)))",z.style.zIndex="1"}else z.style.opacity="calc(1 - var(--dim, 0) * var(--k, 0))";k.appendChild(z)}),v=document.createElement("div");v.style.cssText="display:flex;flex:none",y(v),h.appendChild(v),e.appendChild(h);let E=Math.max(1,v.getBoundingClientRect().width/Za(e)),M=Math.ceil(r.size[0]/E)+1;for(let k=0;k<M;k++)h.appendChild(v.cloneNode(!0));return{track:h,width:E,dir:f%2?-1:1,rate:gn[f%gn.length],off:bn[f%bn.length]}}),m=r.ease(r.tokens.ease_move),d=l(t.highlight_at),c=r.tokens.duration.slow;return e.style.setProperty("--dim",String(o?1-l(t.dim_opacity):0)),{seek(p){e.style.setProperty("--k",String(o?ae(p,d,c,m):0));for(let f of u){let g=(p*i*f.rate+f.off*f.width)%f.width;f.track.style.transform=`translateX(${-(f.dir>0?g:f.width-g)}px)`}}}}};function Za(e){let n=e.closest(".m-stage");if(!n)return 1;let t=n.getBoundingClientRect().width;return t>0&&n.offsetWidth>0?t/n.offsetWidth:1}function Xa(e,n,t,r){let a=Math.max(1,Math.round(n)),s=(t-r*(a-1))/a,i=new Array(a).fill(0);return{cards:e.map(u=>{let m=0;for(let p=1;p<a;p++)i[p]<i[m]-.5&&(m=p);let d=s/(u>0?u:1),c={x:m*(s+r),y:i[m],w:s,h:d};return i[m]=i[m]+d+r,c}),height:Math.max(0,Math.max(...i)-r)}}function Bt(e,n,t){let r=Lt(e.map(i=>[i.x+i.w/2,i.y+i.h/2]),n),a=Math.max(0,...r),s=Math.max(0,e.length-1)*t;return r.map(i=>a>0?i/a*s:0)}var yn={slug:"scene/grid-wall",summary:"A masonry or regular grid of media.",props:{images:{type:"string[]",required:!0,label:"Pictures, in order: each goes under the shortest column"},ratios:{type:"number[]",default:[],label:"Width \xF7 height of each picture. Left out, read from the files once they load"}},params:{columns:{type:"number",default:4,min:2,max:8,step:1,unit:"cols",label:"Columns"},width:{type:"number",default:90,min:20,max:200,step:1,unit:"% of stage width",label:"Width of the wall"},gap:{type:"number",default:16,min:0,max:80,step:1,unit:"px",label:"Space between pictures (corners are \xBE of it, or --m-card-radius)"},stagger:{type:"number",default:.05,min:.01,max:.15,step:.005,unit:"s",label:"Delay between pictures"},focus_x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of the wall",label:"Where the opening starts, across",pad:{name:"focus",axis:"x"}},focus_y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of the wall",label:"Where the opening starts, down",pad:{name:"focus",axis:"y"}},drift_speed:{type:"number",default:20,min:0,max:40,step:1,unit:"px/s",label:"Upward drift of the whole wall; 0 holds it still"}},duration:(e,n,t)=>Math.max(0,te(e.images).length-1)*l(n.stagger)+t.tokens.duration.slow,check(e){let n=te(e.images).length,t=ge(e.ratios);return t.length&&t.length!==n?[{path:"props.ratios",message:`ratios has ${t.length} values for ${n} pictures.`,hint:"Give one per picture, or leave ratios out."}]:t.some(r=>!(r>0))?[{path:"props.ratios",message:"Each ratio is width \xF7 height, above zero."}]:[]},build(e,n,t,r){let a=e.ownerDocument,s=te(n.images),i=ge(n.ratios),o=l(t.width)/100*r.size[0],u=l(t.gap),m=l(t.columns),d=l(t.stagger),c=r.tokens.duration.slow,p=l(t.drift_speed),f=r.ease(r.tokens.ease_enter),g=a.createElement("div");g.style.cssText=`position:relative;width:${o}px`;let b=s.map(M=>{let k=a.createElement("img");return k.src=M,k.alt="",k.decoding="sync",k.style.cssText=`position:absolute;display:block;object-fit:cover;border-radius:var(--m-card-radius, ${Math.round(u*.75)}px)`,g.appendChild(k),k});e.appendChild(g);let h="",y=[],v=[],E=()=>{let M=b.map((L,j)=>i[j]??(L.naturalWidth>0?L.naturalWidth/L.naturalHeight:1)),k=M.map(L=>L.toFixed(4)).join();if(k===h)return;h=k;let{cards:R,height:z}=Xa(M,m,o,u);g.style.height=`${z}px`,R.forEach((L,j)=>Object.assign(b[j].style,{left:`${L.x}px`,top:`${L.y}px`,width:`${L.w}px`,height:`${L.h}px`})),v=R.map(L=>L.y),y=Bt(R,[l(t.focus_x)/100*o,l(t.focus_y)/100*z],d)};return E(),{seek(M){E(),b.forEach((k,R)=>{let z=ae(M,y[R],c,f);k.style.opacity=z.toFixed(4),k.style.top=`${(v[R]+(1-z)*24).toFixed(2)}px`}),g.style.transform=p>0?`translateY(${(-p*Math.max(0,M)).toFixed(2)}px)`:""}}}};var rt=["slide-up","slide-left","flip","stack","fade"],wn=["slide-up","flip","slide-left","stack","fade"],Ya=e=>e.split(/[/|\n]/).map(n=>n.trim().split(/\s+/).filter(Boolean)).filter(n=>n.length>0);function at(e){let n=Ya(e),t=n.length,r=n[0]?.length??0;if(!t)return{tiles:[],cols:0,rows:0,problem:"areas is empty."};let a=n.findIndex(o=>o.length!==r);if(a>=0)return{tiles:[],cols:r,rows:t,problem:`Row ${a+1} has ${n[a].length} cells; the first has ${r}.`};let s=[],i=new Map;n.forEach((o,u)=>o.forEach((m,d)=>{let c=i.get(m);if(!c){let g={name:m,col:d,row:u,cols:1,rows:1};i.set(m,g),s.push(g);return}let p=Math.max(c.col+c.cols,d+1),f=Math.max(c.row+c.rows,u+1);c.col=Math.min(c.col,d),c.cols=p-c.col,c.rows=f-c.row}));for(let o of s){let u=0;if(n.forEach((m,d)=>m.forEach((c,p)=>{c===o.name?u++:p>=o.col&&p<o.col+o.cols&&d>=o.row&&d<o.row+o.rows&&(u=-1/0)})),u!==o.cols*o.rows)return{tiles:[],cols:r,rows:t,problem:`Tile "${o.name}" does not cover one rectangle.`}}return{tiles:s,cols:r,rows:t}}function bt(e,n,t){let r=Array.from({length:n},()=>[]);if(t.length){let a=0;t.forEach((s,i)=>{if(i<n)for(let o=0;o<Math.max(0,Math.round(s))&&a<e;o++)r[i].push(a++)})}else for(let a=0;a<e;a++)r[a%Math.max(1,n)].push(a);return r}function Ua(e,n,t,[r,a]){let{tiles:s,cols:i,rows:o}=at(e),u=n/100*r,m=Math.max(a*.1,a-(r-u)),d=(u-t*(i-1))/Math.max(1,i),c=(m-t*(o-1))/Math.max(1,o);return s.map(p=>(p.cols*d+(p.cols-1)*t)*(p.rows*c+(p.rows-1)*t)/(r*a))}function vn(e,n,t,r){let a=Math.max(1e-6,t);return Array.from({length:e},(s,i)=>n+a-(r*(e-1-i)%a+a)%a)}function Va(e,n,t,r,a){let s=r+a;if(t<2)return{from:0,to:0,k:1,age:0};if(e<n)return{from:0,to:0,k:1,age:Math.max(0,e-n+s)};let i=Math.floor((e-n)/s),o=e-n-i*s;return o<a?{from:i%t,to:(i+1)%t,k:o/a,age:o}:{from:(i+1)%t,to:(i+1)%t,k:1,age:o}}var Ga=/^(data:image\/|[^<\s]+\.(png|jpe?g|webp|gif|avif|svg)(\?\S*)?$)/i;function xt(e,n){if(Ga.test(n.trim())){let t=e.ownerDocument.createElement("img");return t.src=n.trim(),t.alt="",t.decoding="sync",t.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:cover",e.appendChild(t),t}e.innerHTML=n}function Ka(e,n,t,r){switch(t.style.zIndex="2",n.style.zIndex="1",e){case"slide-up":n.style.transform=`translateY(${(-100*r).toFixed(3)}%)`,t.style.transform=`translateY(${(100*(1-r)).toFixed(3)}%)`;break;case"slide-left":n.style.transform=`translateX(${(-100*r).toFixed(3)}%)`,t.style.transform=`translateX(${(100*(1-r)).toFixed(3)}%)`;break;case"flip":{let a=1-.08*Math.sin(Math.PI*r);n.style.transform=`scale(${a.toFixed(4)}) rotateY(${(180*r).toFixed(3)}deg)`,t.style.transform=`scale(${a.toFixed(4)}) rotateY(${(180*r-180).toFixed(3)}deg)`;break}case"stack":n.style.transform=`translateY(${(6*r).toFixed(3)}%) scale(${(1-.1*r).toFixed(4)})`,n.style.opacity=(1-.6*r).toFixed(4),t.style.transform=`translateY(${(-100*(1-r)).toFixed(3)}%)`;break;case"fade":t.style.opacity=r.toFixed(4),t.style.transform=`scale(${(1.04-.04*r).toFixed(4)})`;break}}var Ja=.06,kn={slug:"scene/bento-grid",summary:"Tiles of different sizes on one grid, each cycling its own content on its own clock.",props:{areas:{type:"string",required:!0,label:'The grid as named areas, rows split by "/": "a b c / d b e". A name over several cells is one larger tile'},items:{type:"string[]",required:!0,label:"What the tiles show: markup or a picture path each. Dealt to tiles in turn, or by counts"},counts:{type:"number[]",default:[],label:"How many items each tile cycles, in tile order (reading order of first appearance). 1 holds still"},swaps:{type:"string[]",default:[],label:"Swap move per tile: slide-up, slide-left, flip, stack or fade. Left out, the swap param decides"}},params:{width:{type:"number",default:92,min:30,max:100,step:1,unit:"% of stage width",label:"Width of the grid; the margin is the same all round"},gap:{type:"number",default:14,min:0,max:60,step:1,unit:"px",label:"Space between tiles (corners are \xBE of it, or --m-card-radius)"},hold:{type:"number",default:1.6,min:.4,max:6,step:.05,unit:"s",label:"How long each item rests before its tile swaps again"},swap:{type:"choice",default:"mixed",options:["mixed",...rt],label:"Swap move for tiles without their own: mixed gives neighbours different moves"},swap_time:{type:"number",default:.7,min:.2,max:2,step:.05,unit:"s",label:"Length of one swap"},offset:{type:"number",default:.3,min:0,max:2,step:.05,unit:"s",label:"Phase between one tile\u2019s swap and the next, in reading order"},stagger:{type:"number",default:.06,min:0,max:.2,step:.005,unit:"s",label:"Delay between tiles opening from the centre; 0: the grid is there from the first frame (for loops)"}},duration(e,n,t){let{tiles:r}=at(F(e.areas)),a=bt(te(e.items).length,r.length,ge(e.counts)),s=l(n.stagger),i=s>0?Math.max(0,r.length-1)*s+t.tokens.duration.slow:0,o=Math.max(0,...a.map(u=>u.length));return i+(o>1?o*(l(n.hold)+l(n.swap_time)):l(n.hold))},cycles:!0,cues(e,n,t){let{tiles:r}=at(F(e.areas)),a=bt(te(e.items).length,r.length,ge(e.counts)),s=l(n.hold),i=l(n.swap_time),o=s+i,u=l(n.stagger),m=u>0?Math.max(0,r.length-1)*u+t.tokens.duration.slow:0,d=Math.max(0,...a.map(g=>g.length));if(d<2)return[];let c=m+d*o,p=a.map((g,b)=>g.length>1?b:-1).filter(g=>g>=0),f=Ua(F(e.areas),l(n.width),l(n.gap),t.size);return vn(p.length,m,s,l(n.offset)).flatMap((g,b)=>{let h=[],y=+f[p[b]].toFixed(4);for(let v=g;v+i<=c+1e-6;v+=o)h.push({at:v,length:i,lane:b,share:y});return h})},check(e){let n=[],{tiles:t,problem:r}=at(F(e.areas));if(r)return[{path:"props.areas",message:r,hint:'Write rows of equal length, split by "/", and let each name cover one rectangle: "a a b / c d b".'}];let a=te(e.items).length,s=ge(e.counts);s.length&&s.length!==t.length?n.push({path:"props.counts",message:`counts has ${s.length} values for ${t.length} tiles (${t.map(d=>d.name).join(", ")}).`,hint:"Give one count per tile, in reading order."}):s.length&&s.reduce((d,c)=>d+c,0)!==a&&n.push({path:"props.counts",message:`counts add up to ${s.reduce((d,c)=>d+c,0)}, but there are ${a} items.`,hint:"Make the counts add up to the number of items."}),s.some(d=>!(d>=1)||d!==Math.round(d))&&n.push({path:"props.counts",message:"Each count is a whole number, 1 or more."}),!s.length&&a<t.length&&n.push({path:"props.items",message:`${a} items for ${t.length} tiles: some tiles would be empty.`,hint:"Give at least one item per tile."});let o=bt(a,t.length,s).map(d=>d.length).filter(d=>d>1),u=Math.max(0,...o),m=o.filter(d=>u%d!==0);return m.length&&n.push({path:"props.counts",message:`Tiles cycle ${[...new Set(o)].join(", ")} items: at the end, the tiles with ${[...new Set(m)].join(", ")} are not back on their first item, so a loop would jump.`,hint:`For a loop, give each tile a count that divides ${u}.`}),te(e.swaps).forEach((d,c)=>{rt.includes(d)||n.push({path:`props.swaps[${c}]`,message:`"${d}" is not a swap move.`,hint:`Use one of ${rt.join(", ")}.`})}),n},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,{tiles:o,cols:u,rows:m}=at(F(n.areas)),d=te(n.items),c=bt(d.length,o.length,ge(n.counts)),p=te(n.swaps),f=l(t.width)/100*s,g=(s-f)/2,b=Math.max(i*.1,i-2*g),h=l(t.gap),y=(f-h*(u-1))/Math.max(1,u),v=(b-h*(m-1))/Math.max(1,m),E=l(t.hold),M=Math.max(.01,l(t.swap_time)),k=l(t.stagger),R=E+M,z=s/1080,L=r.ease(r.tokens.ease_enter),j=r.ease(r.tokens.ease_move),x=r.tokens.duration.slow,N=o.map(K=>({x:K.col*(y+h),y:K.row*(v+h),w:K.cols*y+(K.cols-1)*h,h:K.rows*v+(K.rows-1)*h})),S=k>0?Bt(N,[f/2,b/2],k):N.map(()=>0),$=k>0?Math.max(0,o.length-1)*k+x:0,X=c.map((K,_)=>K.length>1?_:-1).filter(K=>K>=0),C=vn(X.length,$,E,l(t.offset)),q=`var(--m-card-radius, ${Math.max(4,Math.round(h*.75))}px)`,P=a.createElement("div");P.style.cssText=`position:relative;width:${f}px;height:${b}px`;let Y=o.map((K,_)=>{let ee=N[_],A=a.createElement("div");A.style.cssText=`position:absolute;left:${ee.x}px;top:${ee.y}px;width:${ee.w}px;height:${ee.h}px;overflow:hidden;border-radius:${q};background:var(--m-bg-sunken);perspective:${(2.5*Math.max(ee.w,ee.h)).toFixed(0)}px;isolation:isolate`;let O=X.indexOf(_),B=rt.includes(p[_]??"")?p[_]:F(t.swap)==="mixed"||!rt.includes(F(t.swap))?wn[Math.max(0,O)%wn.length]:F(t.swap),W=c[_].map(H=>{let U=a.createElement("div");U.style.cssText=`position:absolute;inset:0;overflow:hidden;border-radius:inherit;background:var(--m-bg-surface);display:grid;place-items:center;visibility:hidden;backface-visibility:hidden;font-size:${(28*z).toFixed(2)}px`;let G=xt(U,d[H]??"");return A.appendChild(U),{face:U,img:G}});return P.appendChild(A),{tile:A,faces:W,move:B,start:O>=0?C[O]:1/0,top:ee.y}});return e.appendChild(P),{seek(K){Y.forEach((_,ee)=>{let A=k>0?ae(K,S[ee],x,L):1;_.tile.style.opacity=A<1?A.toFixed(4):"",_.tile.style.top=`${(_.top+(1-A)*24*z).toFixed(2)}px`;let O=Va(K,_.start,_.faces.length,E,M);_.faces.forEach(({face:B,img:W},H)=>{let U=H===O.from||H===O.to;if(B.style.visibility=U?"inherit":"hidden",B.style.transform="",B.style.opacity="",B.style.zIndex="",W){let G=H===O.to?O.age:O.age+R;W.style.transform=U?`scale(${(1+Ja*(1-Z(G/(R+M)))).toFixed(4)})`:""}}),O.from!==O.to&&Ka(_.move,_.faces[O.from].face,_.faces[O.to].face,j(O.k))})}}}};var Qa=["4:5","1:1","9:16","3:4","16:9"],Tn=e=>{let[n,t]=F(e,"4:5").split(":").map(Number);return n>0&&t>0?n/t:.8},En=.14;function Mn(e,n,t){let r=Tn(e.ratio),a=F(e.chrome)!=="none"?2*En:0,s=Math.min(l(e.width)/100*n,.92*t/(1/r+a));return{w:s,h:s/r}}var _a=.05;function ei(e,n,t,r,a,s=i=>i){if(n<2||e<t)return 0;let i=t+r,o=a?n:n-1,u=Math.min(o-1,Math.floor((e-t)/i));return u+s(Z((e-t-u*i)/r))}function Fn(e,n,t,r){let a=e-n;return!r||t<3?a:((a+t/2)%t+t)%t-t/2}var $n={slug:"scene/post-carousel",summary:"Slides shown one at a time as a post or posters, turning past in depth.",props:{slides:{type:"string[]",required:!0,label:"The slides, in order: markup or a picture path each"},handle:{type:"string",default:"yourbrand",label:"Account name in the post header"},avatar:{type:"string",default:"",label:"Picture for the avatar. Left out: the handle\u2019s first letter on the accent"}},params:{width:{type:"number",default:54,min:20,max:100,step:1,unit:"% of stage width",label:"Width of a slide (made smaller if the post would not fit the stage height)"},ratio:{type:"choice",default:"4:5",options:Qa,label:"Shape of a slide, width : height"},chrome:{type:"choice",default:"post",options:["post","none"],label:"post: a header and footer frame the slides; none: bare posters"},hold:{type:"number",default:1.4,min:.4,max:6,step:.05,unit:"s",label:"How long each slide rests in front"},turn:{type:"number",default:.8,min:.3,max:2,step:.05,unit:"s",label:"Length of one turn to the next slide"},angle:{type:"number",default:72,min:0,max:85,step:1,unit:"deg",label:"How far the neighbours are turned away; 0 lays them flat beside the frame"},loop:{type:"boolean",default:!1,label:"Turn on from the last slide back to the first, so the film can loop"}},duration(e,n){let t=te(e.slides).length,r=l(n.hold),a=r+l(n.turn);return t<2?r:n.loop===!0?t*a:r+(t-1)*a},cues(e,n,t){let r=te(e.slides).length,a=l(n.hold),s=l(n.turn),i=r<2?0:n.loop===!0?r:r-1,[o,u]=t.size,{w:m,h:d}=Mn(n,o,u),c=+Math.min(1,1.5*m*d/(o*u)).toFixed(4);return Array.from({length:i},(p,f)=>({at:a+f*(a+s),length:s,share:c}))},check(e,n){let t=[],r=te(e.slides).length;return r<1&&t.push({path:"props.slides",message:"There are no slides.",hint:"Give at least two: one alone has nothing to turn to."}),n.loop===!0&&r>0&&r<3&&t.push({path:"params.loop",message:`A loop of ${r} slide${r===1?"":"s"} has no slide waiting on each side.`,hint:"Give three slides or more, or set loop to false."}),t},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=te(n.slides),u=o.length,m=F(t.chrome)!=="none",d=Tn(t.ratio),c=t.loop===!0,{w:p,h:f}=Mn(t,s,i),g=m?En*p:0,b=.035*p,h=.035*p,y=p/1e3,v=l(t.hold),E=Math.max(.01,l(t.turn)),M=v+E,k=l(t.angle),R=r.ease(r.tokens.ease_move),z=a.createElement("div");z.style.cssText=`position:relative;width:${p}px;height:${f+2*g}px;text-align:left`;let L=a.createElement("div");L.style.cssText=`position:absolute;left:0;top:${g}px;width:${p}px;height:${f}px;perspective:${(2.5*p).toFixed(0)}px;transform-style:preserve-3d`;let j=o.map($=>{let X=a.createElement("div");X.style.cssText=`position:absolute;inset:0;overflow:hidden;background:var(--m-bg-surface);border-radius:${m?"0":`var(--m-card-radius, ${h}px)`};backface-visibility:hidden;font-size:${(64*y).toFixed(2)}px;box-shadow:var(--m-card-shadow, 0 ${24*y}px ${60*y}px rgba(0,0,0,.28))`;let C=a.createElement("div");return C.style.cssText="position:absolute;inset:0;display:grid;place-items:center;transform-origin:50% 50%",xt(C,$),X.appendChild(C),L.appendChild(X),{card:X,inner:C}});z.appendChild(L);let x=[];if(m){let $="var(--m-font-body)",X=(G,Q)=>`position:absolute;left:0;top:${G}px;width:${p}px;height:${g}px;box-sizing:border-box;display:flex;align-items:center;gap:${22*y}px;padding:0 ${36*y}px;background:var(--m-bg-surface);color:var(--m-text-primary);border-radius:${Q};font:600 ${34*y}px/1 ${$}`,C=a.createElement("div");C.style.cssText=X(0,`${h}px ${h}px 0 0`)+";box-shadow:inset 0 -1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let q=a.createElement("div"),P=64*y;q.style.cssText=`flex:none;width:${P}px;height:${P}px;border-radius:50%;overflow:hidden;position:relative;display:grid;place-items:center;background:var(--m-accent);color:var(--m-text-on-accent);font:700 ${30*y}px/1 ${$}`;let Y=F(n.avatar);Y?xt(q,Y):q.textContent=(F(n.handle,"y").trim()[0]??"y").toUpperCase();let K=a.createElement("span");K.textContent=F(n.handle,"yourbrand"),K.style.cssText="flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis";let _=a.createElement("span");_.textContent="\u2022\u2022\u2022",_.style.cssText=`letter-spacing:${2*y}px;font-size:${22*y}px;color:var(--m-text-muted)`,C.append(q,K,_);let ee=a.createElement("div");ee.style.cssText=X(g+f,`0 0 ${h}px ${h}px`)+";box-shadow:inset 0 1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let A=(G,Q="none")=>{let ie=a.createElementNS("http://www.w3.org/2000/svg","svg");return ie.setAttribute("viewBox","0 0 24 24"),ie.setAttribute("width",String(50*y)),ie.setAttribute("height",String(50*y)),ie.style.cssText="flex:none;display:block",ie.innerHTML=`<path d="${G}" fill="${Q}" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/>`,ie},O=A("M12 20.5s-7.5-4.6-7.5-10.2A4.3 4.3 0 0 1 12 7.6a4.3 4.3 0 0 1 7.5 2.7c0 5.6-7.5 10.2-7.5 10.2Z","currentColor");O.style.color="var(--m-accent)";let B=A("M20 11.5a8 8 0 0 1-11.6 7.1L4 20l1.4-4.2A8 8 0 1 1 20 11.5Z"),W=A("M21 3 10 13.5M21 3l-6.5 18-4.5-7.5L3 9.5 21 3Z"),H=a.createElement("div");H.style.cssText=`flex:1;display:flex;justify-content:center;gap:${10*y}px`;for(let G=0;G<Math.min(u,12);G++){let Q=a.createElement("i");Q.style.cssText=`display:block;width:${11*y}px;height:${11*y}px;border-radius:50%;background:var(--m-text-primary)`,H.appendChild(Q),x.push(Q)}let U=A("M6 3.5h12v17l-6-4.5-6 4.5v-17Z");ee.append(O,B,W,H,U),z.append(C,ee)}e.appendChild(z);let N=$=>$===0?-E:v+($-1)*M,S=u*M;return{seek($){let X=ei($,u,v,E,c,R);j.forEach(({card:C,inner:q},P)=>{let Y=Fn(P,X,u,c),K=Z(Y,-1,1),_=Math.max(0,Math.abs(Y)-1);C.style.transformOrigin=Y>=0?"0% 50%":"100% 50%",C.style.transform=`translateX(${(K*(p+b)).toFixed(2)}px) translateZ(${(-(Math.abs(K)*.06+_*1.5)*p).toFixed(2)}px) rotateY(${(k*K).toFixed(3)}deg)`,C.style.opacity=_>0?Z((.6-_)/.6).toFixed(4):"",C.style.visibility=_<1?"inherit":"hidden",C.style.zIndex=String(10-Math.round(Math.abs(Y)*2));let ee=c?(($-N(P))%S+S)%S:$-N(P);q.style.transform=`scale(${(1+_a*(1-Z(ee/(M+E)))).toFixed(4)})`}),x.forEach((C,q)=>{let P=Math.max(0,1-Math.abs(Fn(q,X,u,c)));C.style.opacity=ve(.22,1,P).toFixed(3)})}}}};var Sn={slug:"texture/halftone-field",summary:"Squares or dots sized by a gradient.",props:{edge:{type:"string",default:"top",label:"Edge the field grows from: top or bottom"}},params:{cell:{type:"number",default:12,min:8,max:20,step:1,unit:"px",label:"Cell size"},grow:{type:"number",default:1.6,min:0,max:4,step:.1,unit:"s",label:"Time to grow in"},reach:{type:"number",default:.6,min:.2,max:1,step:.02,unit:"ratio",label:"How far into the frame it reaches"},strength:{type:"number",default:1,min:0,max:1,step:.05,unit:"ratio",label:"Opacity"}},duration:(e,n)=>l(n.grow),build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=l(t.cell)*(r.size[0]/1080)*1.6,i=l(t.grow),o=l(t.reach);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let u=document.createElement("div");return u.style.cssText=`position:absolute;inset:0;opacity:${l(t.strength)};background-image:radial-gradient(circle, var(--m-accent) ${s*.13}px, transparent ${s*.15}px),radial-gradient(circle, var(--m-text-muted) ${s*.08}px, transparent ${s*.1}px);background-size:${s}px ${s}px;background-position:0 0, ${s/2}px ${s/2}px${F(n.edge)==="bottom"?";transform:scaleY(-1)":""}`,e.appendChild(u),{seek(m){let c=`radial-gradient(ellipse 62% 52% at 50% -6%, #000 0%, transparent ${ae(m,0,i,a)*o*100}%)`;u.style.maskImage=c,u.style.setProperty("-webkit-mask-image",c)}}}};var An={slug:"transition/beat-cut",summary:"A plain cut placed on a music beat.",duration:0,params:{duration:{type:"number",default:0,min:0,max:0,step:0,unit:"s",label:"Always zero: a cut"}},apply(){},clear(){}};var Cn={slug:"transition/blur-dissolve",summary:"One scene blurs out while the next blurs in.",duration:.4,calm:{blur:12},params:{duration:{type:"number",default:.4,min:.3,max:.6,step:.05,unit:"s",label:"Length of the hand-over"},blur:{type:"number",default:20,min:12,max:30,step:1,unit:"px",label:"Blur at the midpoint"},overlap:{type:"number",default:.5,min:.3,max:.7,step:.05,unit:"ratio",label:"Share of the time both scenes are visible"}},apply(e,n,t,r,a){let s=a.ease(a.tokens.ease_move),i=.5+l(r.overlap)/2,o=s(Z(t/i)),u=s(Z((t-(1-i))/i)),m=l(r.blur);e.style.opacity=String(1-o),e.style.filter=o>0?`blur(${o*m}px)`:"",n.style.opacity=String(u),n.style.filter=u<1?`blur(${(1-u)*m}px)`:""},clear(e){e.style.opacity="",e.style.filter=""}};var Pn={slug:"transition/step-wipe",summary:"Stepped bars sweep across the frame.",duration:.5,params:{duration:{type:"number",default:.5,min:.4,max:.7,step:.05,unit:"s",label:"Length of the hand-over"},steps:{type:"number",default:6,min:4,max:10,step:1,unit:"bars",label:"Number of bars"}},apply(e,n,t,r,a){let s=a.ease(a.tokens.ease_move),i=Math.max(1,Math.round(l(r.steps))),[o,u]=a.size,m=.5/i,d=[];for(let c=0;c<i;c++){let p=s(Z((t-c*m)/(1-(i-1)*m)))*o,f=c*u/i,g=(c+1)*u/i+(c<i-1?1:0);d.push(`M0 ${f}H${p}V${g}H0Z`)}n.style.clipPath=`path('${d.join("")}')`},clear(e){e.style.clipPath=""}};var Rn="ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&/+",ti=1/20,zn={slug:"type/scramble",summary:"Characters cycle randomly before settling.",props:{text:{type:"string",required:!0,label:"The text to settle on"}},params:{duration:{type:"number",default:.8,min:.6,max:1,step:.05,unit:"s",label:"Time to settle"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let a=[...F(n.text)],s=l(t.duration);return e.style.whiteSpace="pre",e.style.fontVariantNumeric="tabular-nums",{seek(i){let o=s<=0?a.length:Math.floor(Math.max(0,i)/s*a.length+1e-6),u=Math.floor(Math.max(0,i)/ti);e.textContent=a.map((m,d)=>{if(d<o||m===" ")return m;let c=$e(r.seed*7919+u*131+d);return Rn[Math.floor(c()*Rn.length)]??m}).join("")}}}};var On={slug:"type/typed-title",summary:"Characters appear one by one with a caret.",props:{text:{type:"string",required:!0,label:"The text to type"}},params:{chars_per_s:{type:"number",default:20,min:12,max:30,step:1,unit:"chars/s",label:"Typing speed"}},duration:(e,n)=>[...F(e.text)].length/Math.max(1,l(n.chars_per_s)),build(e,n,t){let r=[...F(n.text)],a=Math.max(1,l(t.chars_per_s)),s=document.createElement("span"),i=document.createElement("span"),o=document.createElement("span");return i.style.visibility="hidden",o.style.cssText="display:inline-block;width:0.06em;height:1em;margin:0 -0.03em;vertical-align:-0.12em;background:var(--m-accent)",e.style.whiteSpace="pre-wrap",e.append(s,o,i),{seek(u){let m=Math.min(r.length,Math.floor(u*a+1e-6));s.textContent=r.slice(0,m).join(""),i.textContent=r.slice(m).join("");let d=u-r.length/a;o.style.opacity=d>0&&d%1>=.5?"0":"1"}}}};var Dn=e=>F(e.text).split(/\s+/).filter(Boolean),Ln={slug:"type/word-build",summary:"Words rise and fade in one by one.",props:{text:{type:"string",required:!0,label:"The line to build"},accent:{type:"string[]",default:[],label:"Words set in the accent colour"}},params:{rise:{type:"number",default:16,min:12,max:20,step:1,unit:"px",label:"Rise"},stagger:{type:"number",default:.1,min:.08,max:.12,step:.005,unit:"s",label:"Delay between words"},word_duration:{type:"number",default:.5,min:.3,max:.6,step:.01,unit:"s",label:"Time per word"}},duration:(e,n)=>Math.max(0,Dn(e).length-1)*l(n.stagger)+l(n.word_duration),build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=new Set(te(n.accent).map(d=>d.toLowerCase()));e.style.cssText+=";display:flex;flex-wrap:wrap;justify-content:center;gap:0 0.26em";let i=Dn(n).map(d=>{let c=document.createElement("span");return c.textContent=d,c.style.cssText="display:inline-block;will-change:transform,opacity",s.has(d.toLowerCase().replace(/[^\p{L}\p{N}]/gu,""))&&(c.style.color="var(--m-accent)"),e.appendChild(c),c}),o=l(t.stagger),u=l(t.word_duration),m=l(t.rise);return{seek(d){i.forEach((c,p)=>{let f=ae(d,p*o,u,a);c.style.opacity=String(Math.min(1,f*1.6)),c.style.transform=`translateY(${(1-f)*m}px)`})}}}};var yt=(e,n)=>{let t=Math.max(2,Math.round(l(e.cols)));return[t,Math.max(2,Math.round(t*n[1]/n[0]))]},In={slug:"fx/grid-ripple",summary:"A field of dots or tiles appears in a wave from one point, then keeps breathing.",props:{cell:{type:"string",default:"dot",label:"dot, square or plus"}},params:{cols:{type:"number",default:24,min:8,max:48,step:1,unit:"columns",label:"Columns (rows follow the frame)"},stagger:{type:"number",default:.05,min:.02,max:.1,step:.005,unit:"s",label:"Delay per cell of distance"},from:{type:"choice",default:"center",options:qe,label:"Where the wave starts"},size:{type:"number",default:.22,min:.05,max:.9,step:.01,unit:"ratio of cell",label:"Mark size"},pulse:{type:"number",default:.35,min:0,max:1,step:.05,unit:"ratio",label:"How much the field keeps breathing afterwards"},opacity:{type:"number",default:.5,min:.1,max:1,step:.05,unit:"ratio",label:"Opacity"}},duration:(e,n,t)=>ze(yt(n,t.size)[0]*yt(n,t.size)[1],F(n.from),t.seed,yt(n,t.size))*l(n.stagger)+.6,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,[o,u]=yt(t,r.size),m=s/o,d=i/u,c=o*u,p=F(n.cell,"dot"),f=l(t.size)*Math.min(m,d),g=Me(c,l(t.stagger),F(t.from),r.seed,[o,u]),b=Math.max(...g,.001);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let h=a.createElement("div");h.style.cssText=`position:absolute;inset:0;opacity:${l(t.opacity)}`,e.appendChild(h);let y=Array.from({length:c},(k,R)=>{let z=a.createElement("div"),L=R%o*m+m/2,j=Math.floor(R/o)*d+d/2,x=p==="square"?`border-radius:${f*.12}px;background:currentColor`:p==="plus"?"background:linear-gradient(currentColor,currentColor) center/100% 18% no-repeat,linear-gradient(currentColor,currentColor) center/18% 100% no-repeat":"border-radius:50%;background:currentColor";return z.style.cssText=`position:absolute;left:${L-f/2}px;top:${j-f/2}px;width:${f}px;height:${f}px;${x}`,h.appendChild(z),z}),v=r.ease({spring:{duration:.45,bounce:.25}}),E=l(t.pulse),M=Math.max(1.2,b*1.6);return{seek(k){y.forEach((R,z)=>{let L=ae(k,g[z],.6,v),j=k>g[z]+.6?Math.sin((k-g[z])/M*Math.PI*2)*.5*E:0,x=Math.max(0,L*(1+j*.6));R.style.transform=`scale(${x.toFixed(4)})`,R.style.opacity=Math.min(1,Math.max(0,(k-g[z])/.2)*(1-E*.3+j*.6)).toFixed(3)})}}}};function Bn(e,n,t){let r=Math.abs(e).toFixed(n),[a,s]=r.split("."),i=t?a.replace(/\B(?=(\d{3})+(?!\d))/g,","):a;return[...e<0?"-":"",...i,...s?[".",...s]:[]]}var Wn={slug:"fx/odometer",summary:"Each digit rolls in its own column and lands on the value.",props:{value:{type:"number",required:!0,label:"The number to land on"},decimals:{type:"number",default:0,label:"Decimal places"},prefix:{type:"string",default:"",label:"Text before the number"},suffix:{type:"string",default:"",label:"Text after the number"}},params:{duration:{type:"number",default:1.6,min:.8,max:3,step:.05,unit:"s",label:"Time for the last column to land"},stagger:{type:"number",default:.08,min:0,max:.2,step:.01,unit:"s",label:"Delay between columns, right to left"},spins:{type:"number",default:1,min:0,max:3,step:1,unit:"turns",label:"Extra turns per column to its right"},group:{type:"boolean",default:!0,label:"Thousands separators"}},duration:(e,n)=>{let t=Bn(l(e.value),Math.max(0,Math.round(l(e.decimals))),n.group!==!1).filter(r=>/\d/.test(r)).length;return Math.max(0,t-1)*l(n.stagger)+l(n.duration)},build(e,n,t,r){let a=e.ownerDocument,s=Bn(l(n.value),Math.max(0,Math.round(l(n.decimals))),t.group!==!1),i=l(t.duration),o=l(t.stagger),u=Math.round(l(t.spins)),m=r.ease("expressive.out");e.style.cssText+=";display:inline-flex;align-items:baseline;font-variant-numeric:tabular-nums;white-space:pre";let d=g=>{if(!g)return;let b=a.createElement("span");b.textContent=g,e.appendChild(b)};d(F(n.prefix));let p=s.filter(g=>/\d/.test(g)).length,f=[];for(let g of s){if(!/\d/.test(g)){d(g);continue}p--;let h=Number(g)+10*u*p,y=a.createElement("span");y.style.cssText="display:inline-block;overflow:hidden;height:1.1em;line-height:1.1em;vertical-align:bottom;padding:0 0.01em";let v=a.createElement("span");v.style.cssText="display:flex;flex-direction:column;will-change:transform";for(let E=0;E<=h;E++){let M=a.createElement("span");M.textContent=String(E%10),M.style.cssText="display:block;height:1.1em;text-align:center",v.appendChild(M)}y.appendChild(v),e.appendChild(y),f.push({strip:v,travel:h,delay:p*o})}return d(F(n.suffix)),{seek(g){for(let b of f){let h=ae(g,b.delay,i,m),y=b.travel*h;b.strip.style.transform=`translateY(${(-y*1.1).toFixed(4)}em)`;let v=b.travel*(ae(g+1/60,b.delay,i,m)-h)*60,E=Z(Math.abs(v)*.012,0,.06);b.strip.style.filter=E>.004?`blur(${E.toFixed(3)}em)`:""}}}}};var Nn="http://www.w3.org/2000/svg",Hn={slug:"fx/path-draw",summary:"Lines draw themselves along their paths, then the shapes fill.",props:{paths:{type:"string[]",required:!0,label:"SVG path data, one path per item, drawn in order"},viewbox:{type:"string",default:"0 0 100 100",label:"SVG viewBox the paths are drawn in"},fill:{type:"string",default:"none",label:"Fill once drawn: none, accent, primary or a CSS colour"}},params:{draw:{type:"number",default:1,min:.4,max:2.5,step:.05,unit:"s",label:"Time to draw one path"},stagger:{type:"number",default:.12,min:0,max:.5,step:.01,unit:"s",label:"Delay between paths"},width:{type:"number",default:30,min:4,max:100,step:1,unit:"% of stage width",label:"Drawing width"},stroke:{type:"number",default:2,min:.5,max:12,step:.25,unit:"px",label:"Stroke weight"},fill_time:{type:"number",default:.4,min:.1,max:1,step:.05,unit:"s",label:"Time for the fill to arrive"},ease:{type:"ease",default:"quart.inOut",label:"Curve of each stroke; a camera that follows the tip moves with it"}},duration:(e,n)=>{let t=te(e.paths).length,r=F(e.fill,"none")!=="none";return Math.max(0,t-1)*l(n.stagger)+l(n.draw)+(r?l(n.fill_time)*.8:0)},build(e,n,t,r){let a=e.ownerDocument,s=F(n.fill,"none"),i=s==="accent"?"var(--m-bg-accent)":s==="primary"?"var(--m-text-primary)":s,o=F(n.viewbox,"0 0 100 100").split(/[\s,]+/).map(Number),u=o[2]||100,m=o[3]||100,d=l(t.width)/100*r.size[0],c=a.createElementNS(Nn,"svg");c.setAttribute("viewBox",F(n.viewbox,"0 0 100 100")),c.setAttribute("width",String(d)),c.setAttribute("height",String(d*m/u)),c.style.cssText="display:block;overflow:visible";let p=l(t.stroke)*(u/d),f=te(n.paths).map(z=>{let L=a.createElementNS(Nn,"path");return L.setAttribute("d",z),L.setAttribute("pathLength","1"),L.setAttribute("stroke-dasharray","1 1"),L.setAttribute("stroke","currentColor"),L.setAttribute("stroke-width",String(p)),L.setAttribute("stroke-linecap","round"),L.setAttribute("stroke-linejoin","round"),L.setAttribute("fill",s==="none"?"none":i),c.appendChild(L),L});e.appendChild(c);let g=Me(f.length,l(t.stagger)),b=l(t.draw),h=l(t.fill_time),y=r.ease(t.ease??"quart.inOut"),v=r.ease("cubic.out"),E=d/u,M=256,k=f.map(z=>{let L=0;try{L=z.getTotalLength()}catch{return[]}return Array.from({length:M+1},(j,x)=>{let N=z.getPointAtLength(L*x/M);return[(N.x-(o[0]??0))*E,(N.y-(o[1]??0))*E]})}),R=(z,L)=>{let j=k[z];if(!j?.length)return;let x=Math.min(1,Math.max(0,L))*M,N=Math.floor(x),S=Math.min(M,N+1),$=x-N,[X,C]=j[N],[q,P]=j[S];return[X+(q-X)*$,C+(P-C)*$]};return{tip(z){let L=0;for(let j=0;j<f.length;j++)z>=g[j]&&(L=j);return R(L,ae(z,g[L],b,y))},seek(z){f.forEach((L,j)=>{let x=ae(z,g[j],b,y);if(L.setAttribute("stroke-dashoffset",(1-x).toFixed(4)),L.style.visibility=z<g[j]?"hidden":"inherit",s!=="none"){let N=ae(z,g[j]+b*.8,h,v);L.setAttribute("fill-opacity",N.toFixed(3)),L.setAttribute("stroke-opacity",(1-N).toFixed(3))}})}}}};var qn=["circle","square","squircle","triangle","diamond","hexagon","star","pill","plus","blob"],jn=e=>e,wt=(e,n=1,t=0)=>Array.from({length:e},(r,a)=>{let s=-Math.PI/2+t+a/e*Math.PI*2;return[Math.cos(s)*n,Math.sin(s)*n]});function ni(e,n){let t=e.map((u,m)=>[u,e[(m+1)%e.length]]),r=t.map(([u,m])=>Math.hypot(m[0]-u[0],m[1]-u[1])),a=r.reduce((u,m)=>u+m,0),s=[],i=0,o=0;for(let u=0;u<n;u++){let m=u/n*a;for(;i<t.length-1&&o+r[i]<m;)o+=r[i],i++;let[d,c]=t[i],p=r[i]>0?(m-o)/r[i]:0;s.push([d[0]+(c[0]-d[0])*p,d[1]+(c[1]-d[1])*p])}return s}function ri(e){let n=0,t=1/0;return e.forEach(([r,a],s)=>{let i=Math.abs(Math.atan2(r,-a));i<t&&(t=i,n=s)}),[...e.slice(n),...e.slice(0,n)]}function ai(e,n){let t=(r,a=360)=>Array.from({length:a},(s,i)=>{let o=-Math.PI/2+i/a*Math.PI*2,u=r(o);return[Math.cos(o)*u,Math.sin(o)*u]});switch(e){case"square":return jn([[0,-1],[1,-1],[1,1],[-1,1],[-1,-1]]);case"squircle":return t(r=>1/Math.pow(Math.pow(Math.abs(Math.cos(r)),5)+Math.pow(Math.abs(Math.sin(r)),5),1/5));case"triangle":return wt(3,1.12,0).map(([r,a])=>[r,a+.14]);case"diamond":return wt(4,1.1);case"hexagon":return wt(6,1.04);case"star":return wt(10,1).map(([r,a],s)=>s%2?[r*.46,a*.46]:[r*1.08,a*1.08]);case"pill":return t(r=>{let a=Math.cos(r),s=Math.sin(r),i=.5,o=.5,u=0,m=2;for(let d=0;d<30;d++){let c=(u+m)/2,p=a*c,f=s*c,g=Math.max(0,Math.abs(p)-o);Math.hypot(g,f)>i?m=c:u=c}return u*1.9});case"plus":return jn([[-.36,-1],[.36,-1],[.36,-.36],[1,-.36],[1,.36],[.36,.36],[.36,1],[-.36,1],[-.36,.36],[-1,.36],[-1,-.36],[-.36,-.36]]);case"blob":{let r=$e(n*53+11),a=[r(),r(),r(),r()].map(s=>s*Math.PI*2);return t(s=>.9+.08*Math.sin(2*s+a[0])+.06*Math.sin(3*s+a[1])+.04*Math.sin(5*s+a[2])+.02*Math.sin(7*s+a[3]))}default:return t(()=>1)}}function vt(e,n=120,t=1){return ri(ni(ai(e,t),n))}var Zn=(e,n,t)=>e.map(([r,a],s)=>[r+(n[s][0]-r)*t,a+(n[s][1]-a)*t]),kt=(e,n,t,r)=>`M${e.map(([a,s])=>`${(n+a*r).toFixed(2)},${(t+s*r).toFixed(2)}`).join("L")}Z`;var Xn="http://www.w3.org/2000/svg",ii={accent:"var(--m-bg-accent)",primary:"var(--m-text-primary)",surface:"var(--m-bg-surface)",inverse:"var(--m-bg-inverse)"},Yn={slug:"fx/shape-morph",summary:"One shape grows in, then turns into the next, and the next.",props:{shapes:{type:"string[]",default:["circle","squircle","star"],label:`Shapes in order: ${qn.join(", ")}`},fill:{type:"string",default:"accent",label:"accent, primary, surface, inverse, outline or a CSS colour"}},params:{hold:{type:"number",default:.6,min:.2,max:2,step:.05,unit:"s",label:"Time each shape holds"},morph:{type:"number",default:.7,min:.4,max:1.2,step:.05,unit:"s",label:"Time to turn into the next"},size:{type:"number",default:22,min:6,max:60,step:.5,unit:"% of stage width",label:"Size"},turn:{type:"number",default:90,min:0,max:180,step:5,unit:"deg",label:"Rotation per morph"}},duration:(e,n)=>.6+(Math.max(1,te(e.shapes).length)-1)*(l(n.hold)+l(n.morph)),build(e,n,t,r){let a=e.ownerDocument,s=te(n.shapes).length?te(n.shapes):["circle"],i=s.map(v=>vt(v,160,r.seed)),o=r.size[0],u=l(t.size)/100*o,m=u/2,d=l(t.hold),c=l(t.morph),p=l(t.turn),f=F(n.fill,"accent"),g=a.createElementNS(Xn,"svg");g.setAttribute("width",String(u*1.3)),g.setAttribute("height",String(u*1.3)),g.setAttribute("viewBox",`${-u*.65} ${-u*.65} ${u*1.3} ${u*1.3}`),g.style.cssText="display:block;overflow:visible";let b=a.createElementNS(Xn,"path");f==="outline"?(b.setAttribute("fill","none"),b.setAttribute("stroke","currentColor"),b.setAttribute("stroke-width",String(Math.max(2,u*.02)))):b.setAttribute("fill",ii[f]??f),g.appendChild(b),e.appendChild(g);let h=r.ease({spring:{duration:.6,bounce:.3}}),y=r.ease("quint.inOut");return{seek(v){let E=ae(v,0,.6,h),M=Math.max(0,v-.6),k=d+c,R=Math.min(s.length-1,Math.floor(M/k)),z=0;R<s.length-1?z=ae(M-R*k,d,c,y):R=s.length-1;let L=Math.min(s.length-1,R+1),j=Zn(i[R],i[L],z);b.setAttribute("d",kt(j,0,0,m*Math.max(0,E))),b.setAttribute("transform",`rotate(${((R+z)*p).toFixed(3)})`)}}}};var si=(e,n)=>e.toFixed(n),Un={slug:"scene/bar-chart",summary:"Bars grow from the baseline one after another, each value counting up with it.",props:{values:{type:"number[]",required:!0,label:"Bar values"},labels:{type:"string[]",default:[],label:"Bar labels, in the same order"},highlight:{type:"string",default:"",label:"Label of the one bar set in the accent"},suffix:{type:"string",default:"",label:"Text after each value, e.g. %"},decimals:{type:"number",default:0,label:"Decimal places"}},params:{grow:{type:"number",default:.9,min:.5,max:1.4,step:.05,unit:"s",label:"Time for one bar to grow"},stagger:{type:"number",default:.07,min:.03,max:.15,step:.005,unit:"s",label:"Delay between bars"},orientation:{type:"choice",default:"vertical",options:["vertical","horizontal"],label:"Bars stand or lie"},width:{type:"number",default:64,min:30,max:90,step:1,unit:"% of stage width",label:"Chart width"},height:{type:"number",default:46,min:20,max:75,step:1,unit:"% of stage height",label:"Chart height"}},duration:(e,n)=>.4+Math.max(0,ge(e.values).length-1)*l(n.stagger)+l(n.grow),build(e,n,t,r){let a=e.ownerDocument,s=ge(n.values),i=te(n.labels),o=F(n.highlight),u=Math.max(0,Math.round(l(n.decimals))),m=F(n.suffix),[d,c]=r.size,p=l(t.width)/100*d,f=l(t.height)/100*c,g=t.orientation==="horizontal",b=Math.max(...s.map(Math.abs),1e-9),h=s.length,y=.32;e.style.cssText+=`;position:relative;width:${p}px;height:${f}px;font-variant-numeric:tabular-nums`;let v=a.createElement("div");v.style.cssText=`position:absolute;background:var(--m-border);${g?"left:0;top:0;bottom:0;width:2px;transform-origin:50% 0":"left:0;right:0;bottom:0;height:2px;transform-origin:0 50%"}`,e.appendChild(v);let E=s.map((L,j)=>{let x=(g?f:p)/h,N=x*(1-y),S=j*x+x*y/2,$=o!==""&&i[j]===o,X=a.createElement("div"),C=o===""||$?"var(--m-bg-accent)":"color-mix(in srgb, var(--m-text-primary) 18%, var(--m-bg-base))";X.style.cssText=g?`position:absolute;left:2px;top:${S}px;height:${N}px;width:${Math.abs(L)/b*(p-160)}px;transform-origin:0 50%;border-radius:0 ${N*.12}px ${N*.12}px 0;background:${C}`:`position:absolute;bottom:2px;left:${S}px;width:${N}px;height:${Math.abs(L)/b*(f-70)}px;transform-origin:50% 100%;border-radius:${N*.1}px ${N*.1}px 0 0;background:${C}`;let q=a.createElement("div");q.style.cssText=g?`position:absolute;top:${S+N/2}px;transform:translateY(-50%);font-size:0.62em;font-weight:600;white-space:nowrap`:`position:absolute;left:${S+N/2}px;width:${x}px;margin-left:${-x/2}px;text-align:center;font-size:0.62em;font-weight:600;white-space:nowrap`,$&&(q.style.color="var(--m-accent)");let P=a.createElement("div");P.textContent=i[j]??"",P.style.cssText=g?`position:absolute;right:calc(100% + 0.8em);top:${S+N/2}px;transform:translateY(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`:`position:absolute;top:calc(100% + 0.7em);left:${S}px;width:${N}px;text-align:center;font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.append(X,q,P);let Y=parseFloat(g?X.style.width:X.style.height);return{bar:X,value:q,label:P,v:L,full:Y}}),M=Me(h,l(t.stagger)),k=l(t.grow),R=r.ease("quint.out"),z=r.ease("quart.inOut");return{seek(L){let j=ae(L,0,.5,z);v.style.transform=g?`scaleY(${j})`:`scaleX(${j})`,E.forEach((x,N)=>{let S=ae(L,.4+M[N],k,R);x.bar.style.transform=g?`scaleX(${S})`:`scaleY(${S})`;let $=L>=.4+M[N]+k?x.v:x.v*S;x.value.textContent=`${si($,u)}${m}`;let X=Math.min(1,Math.max(0,(L-.4-M[N])/.25));x.value.style.opacity=X.toFixed(3),g?x.value.style.left=`${2+x.full*S+12}px`:x.value.style.bottom=`${2+x.full*S+10}px`,x.label.style.opacity=Math.min(1,Math.max(0,(L-M[N]*.5)/.4)).toFixed(3)})}}}};var Xe="http://www.w3.org/2000/svg",Vn={slug:"scene/line-chart",summary:"A line draws left to right behind a leading dot, the area fills, the last value lands.",props:{values:{type:"number[]",required:!0,label:"Values, left to right"},labels:{type:"string[]",default:[],label:"Labels under the first and last points (two items), or one per point"},suffix:{type:"string",default:"",label:"Text after the end value"},decimals:{type:"number",default:0,label:"Decimal places of the end value"}},params:{draw:{type:"number",default:2,min:1.2,max:3.5,step:.1,unit:"s",label:"Time to draw the line"},width:{type:"number",default:70,min:30,max:90,step:1,unit:"% of stage width",label:"Chart width"},height:{type:"number",default:44,min:20,max:75,step:1,unit:"% of stage height",label:"Chart height"},area:{type:"boolean",default:!0,label:"Fill under the line"},grid:{type:"number",default:4,min:0,max:8,step:1,unit:"lines",label:"Guide lines"}},duration:(e,n)=>.4+l(n.draw)+.6,build(e,n,t,r){let a=e.ownerDocument,s=ge(n.values),i=te(n.labels),[o,u]=r.size,m=l(t.width)/100*o,d=l(t.height)/100*u,c=Math.min(...s,0),p=Math.max(...s,1e-9),f=d*.08,g=s.map((C,q)=>[s.length>1?q/(s.length-1)*m:m/2,f+(1-(C-c)/(p-c||1))*(d-f*2)]);e.style.cssText+=`;position:relative;width:${m}px;height:${d}px`;let b=a.createElementNS(Xe,"svg");b.setAttribute("width",String(m)),b.setAttribute("height",String(d)),b.style.cssText="position:absolute;inset:0;overflow:visible";let h=Math.round(l(t.grid)),y=Array.from({length:h},(C,q)=>{let P=a.createElementNS(Xe,"line"),Y=d*(q+1)/(h+1);return P.setAttribute("x1","0"),P.setAttribute("x2",String(m)),P.setAttribute("y1",String(Y)),P.setAttribute("y2",String(Y)),P.setAttribute("stroke","var(--m-border)"),P.setAttribute("stroke-width","1.5"),P.setAttribute("stroke-dasharray","4 8"),b.appendChild(P),P}),v=g.map(([C,q],P)=>`${P?"L":"M"}${C.toFixed(2)},${q.toFixed(2)}`).join(""),E=a.createElementNS(Xe,"path");E.setAttribute("d",`${v}L${m},${d}L0,${d}Z`),E.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 16%, transparent)");let M=a.createElementNS(Xe,"path");M.setAttribute("d",v),M.setAttribute("fill","none"),M.setAttribute("stroke","var(--m-bg-accent)"),M.setAttribute("stroke-width",String(Math.max(3,o*.0028))),M.setAttribute("stroke-linejoin","round"),M.setAttribute("stroke-linecap","round");let k=a.createElementNS(Xe,"circle");k.setAttribute("r",String(o*.0055)),k.setAttribute("fill","var(--m-bg-accent)");let R=a.createElementNS(Xe,"circle");R.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 25%, transparent)"),t.area!==!1&&b.appendChild(E),b.append(M,R,k),e.appendChild(b);let z=a.createElement("div"),L=g[g.length-1]??[0,0];z.textContent=`${(s[s.length-1]??0).toFixed(Math.max(0,Math.round(l(n.decimals))))}${F(n.suffix)}`,z.style.cssText=`position:absolute;left:${L[0]}px;top:${L[1]}px;transform:translate(-50%, -150%);font-weight:650;color:var(--m-accent);white-space:nowrap;font-variant-numeric:tabular-nums`,e.appendChild(z);let j=i.map((C,q)=>{let P=a.createElement("div"),Y=i.length===2&&s.length>2?q===0?0:m:g[q]?.[0]??0;return P.textContent=C,P.style.cssText=`position:absolute;top:calc(100% + 0.6em);left:${Y}px;transform:translateX(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.appendChild(P),{l:P,x:Y}}),x=g.map(C=>C[0]),N=C=>{if(g.length<2)return g[0]??[0,0];let q=1;for(;q<g.length-1&&x[q]<C;)q++;let P=g[q-1],Y=g[q],K=Y[0]===P[0]?1:Math.min(1,Math.max(0,(C-P[0])/(Y[0]-P[0])));return[P[0]+(Y[0]-P[0])*K,P[1]+(Y[1]-P[1])*K]},S=l(t.draw),$=r.ease("sine.inOut"),X=r.ease("expressive.out");return{seek(C){y.forEach((B,W)=>B.setAttribute("opacity",ae(C,W*.05,.4,X).toFixed(3)));let q=ae(C,.4,S,$),P=q*m;M.style.clipPath=q>=1?"":`inset(-20px ${(m-P).toFixed(2)}px -20px -20px)`;let[Y,K]=N(P),_=C>=.4;k.setAttribute("cx",Y.toFixed(2)),k.setAttribute("cy",K.toFixed(2)),k.setAttribute("opacity",_?"1":"0");let ee=ae(C,.4+S,.6,X);R.setAttribute("cx",Y.toFixed(2)),R.setAttribute("cy",K.toFixed(2)),R.setAttribute("r",(o*.0055*(1+2.6*ee)).toFixed(2)),R.setAttribute("opacity",(ee>0?1-ee:0).toFixed(3));let A=ae(C,.4+S*.6,.6+S*.4,X);E.setAttribute("opacity",A.toFixed(3)),E.style.clipPath=`inset(0 ${(m-P).toFixed(2)}px 0 0)`;let O=ae(C,.4+S-.1,.5,X);z.style.opacity=O.toFixed(3),z.style.transform=`translate(-50%, ${(-150+(1-O)*40).toFixed(2)}%)`;for(let{l:B,x:W}of j)B.style.opacity=Math.min(1,Math.max(0,(P-W+m*.08)/(m*.08))).toFixed(3)}}}};var Gn="http://www.w3.org/2000/svg",Kn=(e,n,t)=>{let r=l(e.arrive),a=n?l(e.slide):0,s=r+.15,i=s+a*.7;return{arrive:r,slide:a,nameAt:s,tagAt:i,end:t?i+.7:s+a}},Jn={slug:"scene/logo-reveal",summary:"The mark lands, then moves aside as the name slides out from behind it.",props:{name:{type:"string",default:"",label:"Wordmark text. Left out, the mark lands alone"},tagline:{type:"string",default:"",label:"One short line under the lockup"},mark_path:{type:"string",default:"",label:"SVG path data of the mark. Left out, a shape is used"},mark_viewbox:{type:"string",default:"0 0 100 100",label:"viewBox of mark_path"},mark_shape:{type:"string",default:"squircle",label:"Shape used when there is no mark_path"}},params:{mode:{type:"choice",default:"pop",options:["pop","draw","iris"],label:"How the mark arrives"},arrive:{type:"number",default:.8,min:.5,max:1.6,step:.05,unit:"s",label:"Time for the mark to land"},slide:{type:"number",default:.8,min:.5,max:1.2,step:.05,unit:"s",label:"Time for the name to slide out"},mark_size:{type:"number",default:1.1,min:.6,max:2,step:.05,unit:"em",label:"Mark height, relative to the name"},gap:{type:"number",default:.35,min:.1,max:1,step:.05,unit:"em",label:"Gap between mark and name"}},duration:(e,n)=>Kn(n,!!F(e.name),!!F(e.tagline)).end,build(e,n,t,r){let a=e.ownerDocument,s=F(n.name),i=F(n.tagline),o=F(t.mode),u=Kn(t,!!s,!!i);e.style.cssText+=";display:flex;flex-direction:column;align-items:center";let m=a.createElement("div");m.style.cssText=`display:flex;align-items:center;gap:${l(t.gap)}em;white-space:nowrap`;let d=l(t.mark_size),c=a.createElementNS(Gn,"svg"),p=F(n.mark_path);c.setAttribute("viewBox",p?F(n.mark_viewbox,"0 0 100 100"):"-1 -1 2 2"),c.style.cssText=`display:block;height:${d}em;width:${d}em;overflow:visible;position:relative;z-index:1;flex:none`;let f=a.createElementNS(Gn,"path");f.setAttribute("d",p||kt(vt(F(n.mark_shape,"squircle"),160,r.seed),0,0,1)),f.setAttribute("fill","var(--m-bg-accent)"),f.setAttribute("pathLength","1"),f.setAttribute("stroke-dasharray","1 1"),f.setAttribute("stroke","var(--m-bg-accent)"),f.setAttribute("stroke-width",p?"2":"0.05"),f.setAttribute("vector-effect","non-scaling-stroke"),c.appendChild(f),m.appendChild(c);let g,b;s&&(b=a.createElement("span"),b.style.cssText="display:block;overflow:hidden;padding:0.12em 0.04em;margin:-0.12em -0.04em",g=a.createElement("span"),g.textContent=s,g.style.cssText="display:block",b.appendChild(g),m.appendChild(b)),e.appendChild(m);let h;i&&(h=a.createElement("div"),h.textContent=i,h.style.cssText="font-size:0.32em;font-weight:450;letter-spacing:0.01em;color:var(--m-text-muted);margin-top:0.9em",e.appendChild(h));let y=g?(m.offsetWidth-c.getBoundingClientRect().width/oi(e))/2:0,v=r.ease({spring:{duration:.55,bounce:.32}}),E=r.ease("quint.inOut"),M=r.ease("expressive.out");return{seek(k){let R=ae(k,0,u.arrive,o==="pop"?v:M);if(o==="pop")c.style.transform=`scale(${Math.max(0,R).toFixed(4)}) rotate(${((1-R)*-30).toFixed(3)}deg)`,f.setAttribute("stroke-dashoffset","0"),f.setAttribute("fill-opacity","1");else if(o==="draw"){let j=ae(k,0,u.arrive*.8,E),x=ae(k,u.arrive*.65,u.arrive*.35,M);f.setAttribute("stroke-dashoffset",(1-j).toFixed(4)),f.setAttribute("fill-opacity",x.toFixed(3)),c.style.transform=""}else c.style.clipPath=R>=1?"":`circle(${(R*75).toFixed(3)}% at 50% 50%)`,c.style.transform=`scale(${(1.25-.25*R).toFixed(4)})`,f.setAttribute("stroke-dashoffset","0");let z=ae(k,u.nameAt,u.slide,E),L=y*(1-z);if(m.style.transform=L===0?"":`translateX(${L.toFixed(2)}px)`,g&&b){let j=ae(k,u.nameAt,u.slide,M);g.style.transform=j>=1?"":`translateX(${(-(1-j)*105).toFixed(3)}%)`,b.style.visibility=k<u.nameAt?"hidden":"inherit"}if(h){let j=ae(k,u.tagAt,.7,M);h.style.opacity=j.toFixed(3),h.style.transform=j>=1?"":`translateY(${((1-j)*.6).toFixed(3)}em)`}}}}};function oi(e){let n=e.closest(".m-stage");return!n||!n.offsetWidth?1:n.getBoundingClientRect().width/n.offsetWidth}var li=["var(--m-bg-accent)","color-mix(in oklab, var(--m-bg-accent) 55%, var(--m-bg-base))","color-mix(in oklab, var(--m-bg-accent) 60%, #FFFFFF)","color-mix(in oklab, var(--m-bg-accent) 70%, #000000)"],Qn={slug:"texture/gradient-drift",summary:"Soft fields of colour drift and blend behind the content, looping without a seam.",props:{colors:{type:"string[]",default:[],label:"CSS colours of the fields. Left out, shades of the accent"}},params:{period:{type:"number",default:12,min:6,max:24,step:.5,unit:"s",label:"Time for one full loop"},fields:{type:"number",default:4,min:2,max:6,step:1,unit:"fields",label:"Colour fields"},softness:{type:"number",default:14,min:6,max:24,step:.5,unit:"% of stage width",label:"Blur"},reach:{type:"number",default:.18,min:.05,max:.35,step:.01,unit:"ratio",label:"How far the fields wander"},strength:{type:"number",default:.85,min:.2,max:1,step:.05,unit:"ratio",label:"Opacity"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=te(n.colors).length?te(n.colors):li,u=Math.max(1,Math.round(l(t.fields))),m=Math.max(1,l(t.period)),d=l(t.reach),c=$e(r.seed*389+3);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none;overflow:hidden";let p=a.createElement("div");p.style.cssText=`position:absolute;inset:-10%;filter:blur(${l(t.softness)/100*s}px) saturate(1.15);opacity:${l(t.strength)}`,e.appendChild(p);let f=Array.from({length:u},(g,b)=>{let h=a.createElement("div"),y=(.45+c()*.35)*s;return h.style.cssText=`position:absolute;left:0;top:0;width:${y}px;height:${y*(.7+c()*.4)}px;border-radius:50%;background:${o[b%o.length]}`,p.appendChild(h),{b:h,size:y,hx:(.15+c()*.9)*s,hy:(.1+c()*.95)*i,fx:1+Math.floor(c()*2),fy:1+Math.floor(c()*2),ph:c()*Math.PI*2,rot:(c()-.5)*2}});return{seek(g){let b=g/m*Math.PI*2;for(let h of f){let y=h.hx+Math.cos(b*h.fx+h.ph)*d*s-h.size/2,v=h.hy+Math.sin(b*h.fy+h.ph*1.3)*d*i-h.size/2;h.b.style.transform=`translate(${y.toFixed(1)}px, ${v.toFixed(1)}px) rotate(${(Math.sin(b+h.ph)*30*h.rot).toFixed(2)}deg)`}}}}};var it="http://www.w3.org/2000/svg",ui=0,_n={slug:"texture/grain",summary:"Fine film grain over the frame, changing a set number of times a second.",props:{},params:{amount:{type:"number",default:.08,min:.02,max:.25,step:.01,unit:"ratio",label:"Strength"},rate:{type:"number",default:12,min:0,max:24,step:1,unit:"per s",label:"Changes per second (0 holds still)"},size:{type:"number",default:1,min:.5,max:3,step:.1,unit:"x",label:"Grain size"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=l(t.size),u=l(t.rate);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none;z-index:50";let m=a.createElementNS(it,"svg");m.setAttribute("width",String(s)),m.setAttribute("height",String(i)),m.style.cssText=`position:absolute;inset:0;opacity:${l(t.amount)};mix-blend-mode:overlay`;let d=`m-grain-${++ui}`,c=a.createElementNS(it,"filter");c.setAttribute("id",d),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","100%"),c.setAttribute("height","100%");let p=a.createElementNS(it,"feTurbulence");p.setAttribute("type","fractalNoise"),p.setAttribute("baseFrequency",String(.9/o*(s/1920))),p.setAttribute("numOctaves","2"),p.setAttribute("stitchTiles","stitch");let f=a.createElementNS(it,"feColorMatrix");f.setAttribute("type","saturate"),f.setAttribute("values","0"),c.append(p,f);let g=a.createElementNS(it,"rect");return g.setAttribute("width","100%"),g.setAttribute("height","100%"),g.setAttribute("filter",`url(#${d})`),m.append(c,g),e.appendChild(m),{seek(b){let h=u>0?Math.floor(b*u+1e-6):0;p.setAttribute("seed",String(r.seed*1e3+h))}}}};var er={slug:"texture/vignette",summary:"The frame darkens towards its edges, holding the eye on the middle. Fixed to the screen.",props:{color:{type:"string",default:"#000000",label:"CSS colour the edges darken to"}},params:{inner:{type:"number",default:48,min:0,max:90,step:1,unit:"%",label:"Where the darkening starts, from the centre to the corner"},outer:{type:"number",default:82,min:10,max:100,step:1,unit:"%",label:"Where it reaches its middle strength"},strength:{type:"number",default:.85,min:0,max:1,step:.05,unit:"ratio",label:"Opacity at the corners"},mid:{type:"number",default:.55,min:0,max:1,step:.05,unit:"ratio",label:"Opacity at `outer`"},center_x:{type:"number",default:50,min:0,max:100,step:1,unit:"%",label:"Centre, across"},center_y:{type:"number",default:46,min:0,max:100,step:1,unit:"%",label:"Centre, down: a little above the middle reads as level"}},duration:()=>0,build(e,n,t){let r=String(n.color??"#000000"),a=s=>`color-mix(in srgb, ${r} ${Math.round(s*100)}%, transparent)`;return e.style.cssText+=`;position:absolute;inset:0;max-width:none;pointer-events:none;background:radial-gradient(farthest-corner at ${l(t.center_x)}% ${l(t.center_y)}%, transparent ${l(t.inner)}%, ${a(l(t.mid))} ${Math.max(l(t.inner)+1,l(t.outer))}%, ${a(l(t.strength))} 100%)`,{seek(){}}}};function Mt(e,n,t,r){let[a,s]=t,i=Math.min(2*Math.max(1,r.cameraScale?.()??1),8192/Math.max(a,s)),o=Math.round(a*i),u=Math.round(s*i);(e.width!==o||e.height!==u)&&(e.width=o,e.height=u),n.setTransform(o/a,0,0,u/s,0,0)}function mi(e,n){let t=e-Math.floor(e),r=.6+.4*Math.exp(-t*n.decay),a=Z(t/n.life),s=1-(1-a)**3;return{breathe:r,ringR:60+s*(n.reach-60),ringA:a>=1?0:n.ring*(1-s)}}function tr(e,n){let t=e.ownerDocument.createElement("span");t.style.color=n,t.style.display="none",e.appendChild(t);let r=getComputedStyle(t).color;return t.remove(),(r.match(/[\d.]+/g)?.slice(0,3)??["255","255","255"]).join(",")}var nr={slug:"texture/beat-field",summary:"A dim dot lattice whose light breathes on the beat, with a ring leaving the centre.",props:{clear:{type:"string[]",default:[],label:"Ids of layers on the field: no dot is drawn under them"}},params:{pitch:{type:"number",default:18,min:8,max:60,step:1,unit:"px",label:"Distance between dots"},dot:{type:"number",default:.33,min:.1,max:.5,step:.01,unit:"ratio",label:"Dot radius, as a share of the pitch"},paper:{type:"number",default:.045,min:0,max:.2,step:.005,unit:"opacity",label:"How much every dot shows, unlit"},glow:{type:"number",default:.13,min:0,max:.4,step:.01,unit:"opacity",label:"The light at the centre, at the top of a breath"},glow_radius:{type:"number",default:320,min:80,max:1200,step:10,unit:"px",label:"How far the centre light reaches"},decay:{type:"number",default:3.2,min:.5,max:8,step:.1,unit:"per beat",label:"How fast a breath dies away"},ring:{type:"number",default:.22,min:0,max:.6,step:.01,unit:"opacity",label:"The ring of light at its start (0: no ring)"},ring_reach:{type:"number",default:620,min:120,max:2e3,step:10,unit:"px",label:"How far the ring travels in a beat"},ring_life:{type:"number",default:.95,min:.3,max:1,step:.05,unit:"beats",label:"Share of a beat the ring takes to fade"},center_x:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of width",label:"Centre of the light, across"},center_y:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of height",label:"Centre of the light, down"},period:{type:"number",default:.5,min:.2,max:2,step:.01,unit:"s",label:"Seconds per beat when the film has no tempo"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=s/1080;e.style.cssText+=";position:absolute;left:0;top:0;width:100%;height:100%;max-width:none;pointer-events:none";let u=a.createElement("canvas");u.style.cssText=`position:absolute;left:0;top:0;width:${s}px;height:${i}px`,e.appendChild(u);let m=u.getContext("2d"),d=tr(e,"currentColor"),c=tr(e,"var(--m-accent)"),p=r.beat??Math.max(.05,l(t.period)),f=r.filmStart??0,g=l(t.pitch)*o,b=l(t.dot)*g,h=l(t.paper),y=l(t.glow),v=l(t.glow_radius)*o,E={decay:l(t.decay),ring:l(t.ring),reach:l(t.ring_reach),life:l(t.ring_life)},M=l(t.center_x)/100*s,k=l(t.center_y)/100*i,R=[],z=Math.ceil(M/g)+1,L=Math.ceil(k/g)+1;for(let N=-L;N<=Math.ceil((i-k)/g)+1;N++)for(let S=-z;S<=Math.ceil((s-M)/g)+1;S++){let $=M+S*g,X=k+N*g;R.push([$,X,Math.hypot($-M,X-k)])}let j,x=te(n.clear);return{seek(N){if(!m)return;if(!j){let Y=x.map(K=>r.boxOf?.(K)).filter(K=>!!K);j=R.filter(([K,_])=>!Y.some(ee=>K>ee.x-b&&K<ee.x+ee.w+b&&_>ee.y-b&&_<ee.y+ee.h+b))}Mt(u,m,r.size,r),m.clearRect(0,0,s,i);let{breathe:S,ringR:$,ringA:X}=mi((f+N)/p,E),C=$*o,q=40*o,P=m.createRadialGradient(M,k,0,M,k,v);P.addColorStop(0,`rgba(${c},${(.07*S).toFixed(4)})`),P.addColorStop(.55,`rgba(${c},${(.025*S).toFixed(4)})`),P.addColorStop(1,`rgba(${c},0)`),m.fillStyle=P,m.fillRect(M-v,k-v,v*2,v*2);for(let[Y,K,_]of j){let ee=_/v,A=ee>=1?0:ee<.45?1-ee/.45*(1-.05/.13):.05/.13*(1-(ee-.45)/.55),O=X>0?X*Math.max(0,1-Math.abs(_-C)/q):0,B=y*S*A+O;m.beginPath(),m.arc(Y,K,b,0,Math.PI*2),h>0&&(m.fillStyle=`rgba(${d},${h})`,m.fill()),B>.002&&(m.fillStyle=`rgba(${c},${Math.min(1,B).toFixed(4)})`,m.fill())}}}}};var rr=e=>/^data:image\/|\.(png|jpe?g|webp|avif|gif|svg)(\?|#|$)/i.test(e);function di(e,n){if(!e?.length)return;let t=Math.min(e.length-1,Math.max(0,n));for(let r=0;r<e.length;r++){let a=e[t-r],s=e[t+r];if(a)return a;if(s)return s}}function ci(e,n){return e.length<2||!(n>0)?0:Z(Math.log2(e[0]/n),0,e.length-1)}function pi(e,n,t,r,a,s,i){let o=Math.sin(r*Math.PI/180),u=Math.sin(t*Math.PI/180),m=Math.hypot(o,u);if(m<1e-4||i<=0)return"linear-gradient(transparent, transparent)";let d=o/m,c=u/m,p=Math.atan2(d,-c)*180/Math.PI,f=Math.abs(e*d)+Math.abs(n*c),g=((a-e/2)*d+(s-n/2)*c)/f+.5,b=v=>Math.min(1,Math.abs(v-g)*f*m/i),h=[[0,b(0)]],y=i/(f*m);return g-y>0&&h.push([g-y,1]),g>0&&g<1&&h.push([g,0]),g+y<1&&h.push([g+y,1]),h.push([1,b(1)]),`linear-gradient(${p.toFixed(2)}deg, ${h.map(([v,E])=>`rgba(0,0,0,${E.toFixed(3)}) ${(v*100).toFixed(2)}%`).join(", ")})`}function hi(e,n,t){let r=Math.PI/180,a=t*r,s=Math.PI/4,i=[Math.sin(n*r),-Math.sin(e*r)*Math.cos(n*r),Math.cos(e*r)*Math.cos(n*r)],o=[Math.cos(a)*Math.cos(s),Math.sin(a)*Math.cos(s),Math.sin(s)];return i[0]*o[0]+i[1]*o[1]+i[2]*o[2]-Math.sin(s)}var ar={slug:"rig/footage-plane",summary:"Flat screen footage on a plane the camera moves over, with depth of field and light.",props:{src:{type:"string",required:!0,label:"Video recorded flat (motion record), or a still picture of a screen"},from:{type:"number",default:0,label:"Source time the plane opens on, in seconds"},to:{type:"number",default:0,label:"Source time it ends on; 0 plays on until the scene ends"},marks:{type:"string",default:"",label:'The marks file motion record --marks wrote, for camera keys ("plane#mark") and taps to aim at'},focus:{type:"string",default:"",label:"The mark the lens focuses on; the middle of the picture when empty"}},params:{width:{type:"number",default:1080,min:100,max:8e3,step:1,unit:"px",label:"Width of the plane on the stage at zoom 1"},radius:{type:"number",default:0,min:0,max:200,step:1,unit:"px",label:"Corner radius"},rate:{type:"number",default:1,min:.1,max:4,step:.05,unit:"\xD7",label:"Playback speed"},loop:{type:"boolean",default:!1,label:'Wrap from "to" back to "from" until the scene ends'},aperture:{type:"number",default:6,min:0,max:24,step:.5,unit:"px",label:"Blur where the tilted plane is furthest out of focus (0: all sharp)"},depth:{type:"number",default:260,min:40,max:2e3,step:10,unit:"px",label:"Depth from the focal plane at which the blur is full"},light:{type:"number",default:235,min:0,max:360,step:5,unit:"deg",label:"Where the light comes from, on the screen (0 right, 90 below, 270 above)"},shade:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"How much the tilt lights and darkens the plane"},sheen:{type:"number",default:.06,min:0,max:.3,step:.01,unit:"opacity",label:"A soft band of reflected light that slides as the plane turns"},shadow:{type:"number",default:.35,min:0,max:1,step:.05,unit:"opacity",label:"The plane's shadow on what is behind it"}},cues:()=>[],duration:(e,n)=>{let t=l(e.from),r=l(e.to);return n.loop===!0||!(r>t)?0:(r-t)/l(n.rate,1)},check(e,n){let t=[],r=l(e.from),a=l(e.to);return r<0&&t.push({path:"props.from",message:"from is a source time in seconds, zero or more."}),a!==0&&a<=r&&t.push({path:"props.to",message:`to (${a} s) must come after from (${r} s).`}),n.loop===!0&&!(a>r)&&t.push({path:"params.loop",message:"A loop needs both ends: set props.to after props.from."}),F(e.focus)&&!F(e.marks)&&t.push({path:"props.focus",message:"focus names a mark, so the plane needs its marks file.",hint:"Record with motion record --marks and set props.marks."}),t},build(e,n,t,r){let a=e.ownerDocument,s=l(t.width),i=l(t.radius),o=r.frames?[r.frames,...r.mips??[]]:[],u=r.frames?.marks,m=r.frames?r.frames.height/r.frames.width:u?u.size[1]/u.size[0]:16/9,d=s*m;e.style.cssText+=";max-width:none";let c=a.createElement("div");c.style.cssText=`position:relative;width:${s}px;height:${d}px;border-radius:${i}px;overflow:hidden;background:#000`,e.appendChild(c),e.style.borderRadius=`${i}px`;let p="position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:fill",f=0,g=Promise.resolve(),b=o.map(()=>{let P=a.createElement("img");return P.decoding="sync",P.alt="",P.style.cssText=`${p};opacity:0`,c.appendChild(P),P}),h=(P,Y)=>{if(P.getAttribute("src")===Y)return;P.src=Y;let K=++f;g=Promise.all([g,P.decode().catch(()=>{if(!(K!==f||P.complete&&P.naturalWidth>0))return new Promise((_,ee)=>{P.addEventListener("load",()=>_(),{once:!0}),P.addEventListener("error",()=>ee(new Error(`Footage frame did not load: ${Y}`)),{once:!0})})})]).then(()=>{})};if(!o.length&&rr(F(n.src))){let P=a.createElement("img");P.decoding="sync",P.alt="",P.src=F(n.src),P.style.cssText=p,c.appendChild(P)}let y;!o.length&&!rr(F(n.src))&&(y=a.createElement("video"),y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=F(n.src),y.style.cssText=p,c.appendChild(y));let v=o.length?a.createElement("img"):void 0;v&&(v.decoding="sync",v.alt="",v.style.cssText=`${p};opacity:0;filter:blur(${l(t.aperture)}px);transform:scale(1.02)`,c.appendChild(v));let E=a.createElement("div");E.style.cssText=`${p};pointer-events:none`;let M=a.createElement("div");M.style.cssText=`${p};pointer-events:none;mix-blend-mode:screen`,c.append(E,M);let k=u?.fps??60,R=u?s/u.size[0]:1,z=(P,Y)=>{let K=u?.marks[P]??u?.marks[`#${P}`]??u?.marks[`.${P}`],_=di(K,Math.round(nt(Y,n,t)*k));return _?[_[0]*R,_[1]*R,_[2]*R,_[3]*R]:void 0},L=typeof window<"u"&&window.devicePixelRatio||1,j=l(t.aperture),x=l(t.depth),N=l(t.shade),S=l(t.sheen),$=l(t.shadow),X=l(t.light),C=F(n.focus),q=o.map(P=>P.width);return{seek(P){let Y=r.cameraPose?.()??{scale:1,rotateX:0,rotateY:0},K=nt(P,n,t);if(o.length){let O=ci(q,s*Y.scale*L),B=Math.floor(O),W=Math.min(o.length-1,B+1),H=O-B;if(b.forEach((U,G)=>{let Q=G===B||G===W&&H>.001;if(U.style.opacity=Q?G===B?"1":H.toFixed(3):"0",U.style.zIndex=G===W&&G!==B?"1":"0",Q){let ie=o[G];h(U,Ze(ie,Math.round((K-ie.start)*ie.rate+1e-6)))}}),v){let U=Math.hypot(Y.rotateX,Y.rotateY);if(j>0&&U>.05){let G=o[Math.min(o.length-1,W+1)];h(v,Ze(G,Math.round((K-G.start)*G.rate+1e-6)));let Q=C?z(C,P):void 0,[ie,ue]=Q?[Q[0]+Q[2]/2,Q[1]+Q[3]/2]:[s/2,d/2],pe=pi(s,d,Y.rotateX,Y.rotateY,ie,ue,x);v.style.maskImage=pe,v.style.opacity="1",v.style.zIndex="2"}else v.style.opacity="0"}}else y&&Math.abs(y.currentTime-K)>.5/r.fps&&(y.currentTime=K);let _=hi(Y.rotateX,Y.rotateY,X)*N*2;E.style.background=_>=0?`rgba(255,255,255,${Z(_*.5).toFixed(3)})`:`rgba(0,0,0,${Z(-_).toFixed(3)})`,E.style.zIndex="3";let ee=50+Y.rotateY*3-Y.rotateX*3;M.style.background=S>0?`linear-gradient(${(X+90).toFixed(0)}deg, transparent ${(ee-22).toFixed(1)}%, rgba(255,255,255,${S}) ${ee.toFixed(1)}%, transparent ${(ee+22).toFixed(1)}%)`:"",M.style.zIndex="4";let A=Math.hypot(Y.rotateX,Y.rotateY);c.style.boxShadow=$>0?`0 ${(10+A*1.6).toFixed(1)}px ${(30+A*3).toFixed(1)}px rgba(0,0,0,${$})`:"",c.style.overflow="hidden"},pending:()=>g,markAt:z}}};function Oe(e,n,t=1){let r=e.parentElement;if(!r)return[];let a=[];for(let s=0;s<t;s++){let i=r.querySelector(`:scope > [data-m-overlay="${n}-${s}"]`);i||(i=e.ownerDocument.createElement("div"),i.dataset.mOverlay=`${n}-${s}`,i.style.cssText=`position:absolute;inset:0;z-index:${1e3+s};pointer-events:none;will-change:transform,clip-path`,r.appendChild(i)),a.push(i)}return a}function De(e,n){e.parentElement?.querySelectorAll(`:scope > [data-m-overlay^="${n}-"]`).forEach(t=>t.remove())}var Ye=e=>["base","surface","sunken","accent","inverse"].includes(e)?`var(--m-bg-${e})`:e;var ir="cover",sr={slug:"transition/cover-reveal",summary:"Colour panels sweep across and cover the cut, then sweep on to uncover the next scene.",duration:1,calm:{lag:.06},params:{duration:{type:"number",default:1,min:.6,max:1.6,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"up",options:["up","down","left","right"],label:"Which way the panels travel"},panels:{type:"number",default:2,min:1,max:3,step:1,unit:"panels",label:"Panels, one behind the other"},lag:{type:"number",default:.12,min:0,max:.3,step:.01,unit:"ratio",label:"How far each panel trails the one before"}},apply(e,n,t,r,a){let s=Math.max(1,Math.round(l(r.panels))),i=l(r.lag),o=["accent","inverse","surface"],u=Oe(e,ir,s),m=a.ease("quart.inOut"),d=F(r.direction),c=1-i*(s-1);u.forEach((g,b)=>{g.style.background=Ye(te([o[(s-1-b)%o.length]])[0]);let h=Z((t-b*i)/c),y=m(Z(h*2)),v=m(Z(h*2-1)),E=y*100,M=v*100,k=d==="up"?`${100-E}% 0 ${M}% 0`:d==="down"?`${M}% 0 ${100-E}% 0`:d==="left"?`0 ${M}% 0 ${100-E}%`:`0 ${100-E}% 0 ${M}%`;g.style.clipPath=`inset(${k})`,g.style.visibility=h<=0||h>=1?"hidden":"visible"});let p=(s-1)*i+c/2;n.style.opacity=t>=p?"1":"0",e.style.opacity=t>=p?"0":"1";let f=m(Z((t-p)/(1-p)));n.style.transform=t>=p?`scale(${(1.04-.04*f).toFixed(4)})`:""},clear(e){De(e,ir),e.style.transform="",e.style.opacity=""}};var or="curtain",lr={slug:"transition/curtain",summary:"Two panels part or close.",duration:.8,params:{duration:{type:"number",default:.8,min:.5,max:1.4,step:.05,unit:"s",label:"Length of the hand-over"},axis:{type:"choice",default:"vertical",options:["vertical","horizontal"],label:"Panels meet along a vertical or a horizontal line"},fill:{type:"choice",default:"inverse",options:["inverse","accent","surface","base"],label:"Panel colour"}},apply(e,n,t,r,a){let[s,i]=Oe(e,or,2);if(!s||!i)return;let o=a.ease("quint.inOut"),u=o(Z(t/.46)),m=o(Z((t-.54)/.46)),d=(u-m)*50,c=F(r.axis)!=="horizontal";for(let f of[s,i])f.style.background=Ye(F(r.fill,"inverse"));s.style.clipPath=c?`inset(0 ${100-d}% 0 0)`:`inset(0 0 ${100-d}% 0)`,i.style.clipPath=c?`inset(0 0 0 ${100-d}%)`:`inset(${100-d}% 0 0 0)`;let p=t>=.5;e.style.opacity=p?"0":"1",n.style.opacity=p?"1":"0",n.style.transform=p?`scale(${(1.05-.05*m).toFixed(4)})`:""},clear(e){De(e,or),e.style.opacity="",e.style.transform=""}};var ur={slug:"transition/dive-in",summary:"The camera pushes into a point until it fills the frame.",duration:.5,calm:{scale_to:3},params:{duration:{type:"number",default:.5,min:.4,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},scale_to:{type:"number",default:8,min:3,max:12,step:.5,unit:"x",label:"How far the camera pushes in"},x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of width",label:"Point to dive into, across",pad:{name:"point",axis:"x"}},y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of height",label:"Point to dive into, down",pad:{name:"point",axis:"y"}},pace:{type:"choice",default:"accelerate",options:["accelerate","glide"],label:"accelerate hits the cut at speed; glide eases in and out and arrives at rest"}},apply(e,n,t,r,a){let[s,i]=a.size,o=l(r.x)/100*s,u=l(r.y)/100*i;if(e.style.transformOrigin=`${o}px ${u}px`,n.style.transformOrigin=`${o}px ${u}px`,F(r.pace)==="glide"){let g=a.ease("sine.inOut")(t),b=Math.pow(l(r.scale_to),g),h=7*Math.sin(Math.PI*t);e.style.transform=`scale(${b.toFixed(4)})`,e.style.filter=h>.05?`blur(${h.toFixed(2)}px)`:"",e.style.opacity=String(1-a.ease("smooth")(Z((t-.55)/.35))),n.style.transform=`scale(${(1.12-.12*a.ease("expo.out")(Z((t-.5)/.5))).toFixed(4)})`,n.style.filter=h>.05?`blur(${h.toFixed(2)}px)`:"",n.style.opacity=String(a.ease("smooth")(Z((t-.5)/.35)));return}let m=a.ease("expo.in"),d=a.ease("expo.out"),c=m(Z(t/.55)),p=d(Z((t-.45)/.55)),f=1+(l(r.scale_to)-1)*c;e.style.transform=`scale(${f.toFixed(4)})`,e.style.filter=c>.02?`blur(${(c*14).toFixed(2)}px)`:"",e.style.opacity=String(1-Z((t-.4)/.15)),n.style.transform=`scale(${(1.35-.35*p).toFixed(4)})`,n.style.filter=p<.98?`blur(${((1-p)*12).toFixed(2)}px)`:"",n.style.opacity=String(Z((t-.45)/.12))},clear(e){e.style.transform="",e.style.transformOrigin="",e.style.filter="",e.style.opacity=""}};var mr={slug:"transition/iris",summary:"The next scene opens from a point in a growing circle.",duration:.8,calm:{push_in:.02},params:{duration:{type:"number",default:.8,min:.4,max:1.4,step:.05,unit:"s",label:"Length of the hand-over"},x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of width",label:"Centre, across",pad:{name:"centre",axis:"x"}},y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of height",label:"Centre, down",pad:{name:"centre",axis:"y"}},shape:{type:"choice",default:"circle",options:["circle","rounded"],label:"Opening shape"},push_in:{type:"number",default:.06,min:0,max:.2,step:.01,unit:"ratio",label:"How much the outgoing scene pushes in"}},apply(e,n,t,r,a){let s=a.ease("expressive.inOut"),[i,o]=a.size,u=l(r.x)/100*i,m=l(r.y)/100*o,d=s(t),c=Math.max(Math.hypot(u,m),Math.hypot(i-u,m),Math.hypot(u,o-m),Math.hypot(i-u,o-m)),p=d*c*1.02;if(F(r.shape)==="rounded"){let f=p*.9,g=p*.9;n.style.clipPath=`inset(${(m-g).toFixed(1)}px ${(i-u-f).toFixed(1)}px ${(o-m-g).toFixed(1)}px ${(u-f).toFixed(1)}px round ${(p*.25).toFixed(1)}px)`}else n.style.clipPath=`circle(${p.toFixed(2)}px at ${u.toFixed(1)}px ${m.toFixed(1)}px)`;n.style.transform=`scale(${(1.08-.08*d).toFixed(4)})`,n.style.transformOrigin=`${u}px ${m}px`,e.style.transform=`scale(${(1+l(r.push_in)*d).toFixed(4)})`,e.style.transformOrigin=`${u}px ${m}px`},clear(e){e.style.clipPath="",e.style.transform="",e.style.transformOrigin=""}};var Wt="http://www.w3.org/2000/svg",dr=new WeakMap,fi=0,ke=(e,n)=>Math.abs(e)*Math.max(0,n)/Math.sqrt(12),cr=.25;function Te(e,n,t,r=48){let a=Math.min(r,Math.abs(n)),s=Math.min(r,Math.abs(t));if(a<cr&&s<cr)return"";let i=dr.get(e);if(!i){let c=e.ownerDocument,p=e.closest(".m-stage")??c.body,f=p.querySelector(":scope > svg.m-filters");f||(f=c.createElementNS(Wt,"svg"),f.setAttribute("class","m-filters"),f.setAttribute("aria-hidden","true"),f.style.cssText="position:absolute;width:0;height:0;overflow:hidden;pointer-events:none",p.appendChild(f));let g=`m-dblur-${++fi}`,b=c.createElementNS(Wt,"filter");b.setAttribute("id",g),b.setAttribute("color-interpolation-filters","sRGB");let h=c.createElementNS(Wt,"feGaussianBlur");b.appendChild(h),f.appendChild(b),i={id:g,filter:b,blur:h},dr.set(e,i)}let o=Math.max(1,e.offsetWidth),u=Math.max(1,e.offsetHeight),m=3*a/o,d=3*s/u;return i.filter.setAttribute("x",(-m).toFixed(4)),i.filter.setAttribute("y",(-d).toFixed(4)),i.filter.setAttribute("width",(1+2*m).toFixed(4)),i.filter.setAttribute("height",(1+2*d).toFixed(4)),i.blur.setAttribute("stdDeviation",`${a.toFixed(2)} ${s.toFixed(2)}`),`url(#${i.id})`}var pr={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},hr={slug:"transition/push",summary:"The next scene pushes the current one out of frame, with parallax and motion blur.",duration:.7,calm:{parallax:.15,blur:.25},params:{duration:{type:"number",default:.7,min:.3,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"left",options:["left","right","up","down"],label:"Which way the frame travels"},parallax:{type:"number",default:.35,min:0,max:1,step:.05,unit:"ratio",label:"How much less the outgoing scene travels"},blur:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Shutter: share of a frame the motion smears over (0.5 = film)"}},apply(e,n,t,r,a){let s=a.ease("quint.inOut"),[i,o]=a.size,[u,m]=pr[F(r.direction)]??pr.left,d=s(t),c=u?i:o,p=a.fps||30,f=1/120,g=(s(Math.min(1,t+f))-s(Math.max(0,t-f)))/(2*f)*c/(l(r.duration)*p),b=1-l(r.parallax),h=l(r.blur),y=ke(g,h),v=ke(g*b,h);n.style.transform=`translate(${(-u*(1-d)*i).toFixed(2)}px, ${(-m*(1-d)*o).toFixed(2)}px)`,e.style.transform=`translate(${(u*d*i*b).toFixed(2)}px, ${(m*d*o*b).toFixed(2)}px)`,e.style.filter=[Te(e,u?v:0,m?v:0),`brightness(${(1-.35*d).toFixed(3)})`].filter(Boolean).join(" "),n.style.filter=Te(n,u?y:0,m?y:0)},clear(e){e.style.transform="",e.style.filter=""}};var fr={slug:"transition/slant-wipe",summary:"A slanted edge cuts across the frame, uncovering the next scene; the old one drifts back.",duration:.6,calm:{slant:10,drift:3},params:{duration:{type:"number",default:.6,min:.4,max:.9,step:.05,unit:"s",label:"Length of the hand-over"},slant:{type:"number",default:20,min:0,max:40,step:1,unit:"% of width",label:"Slant of the edge"},direction:{type:"choice",default:"left",options:["left","right"],label:"Which way the edge travels"},drift:{type:"number",default:8,min:0,max:15,step:1,unit:"% of width",label:"How far the old scene drifts"}},apply(e,n,t,r,a){let i=a.ease([.77,0,.175,1])(t),o=l(r.slant),u=F(r.direction)!=="right",m=100+o,d=u?100-i*m:i*m-o,c=d+o;n.style.clipPath=u?`polygon(${d}% 0, 100% 0, 100% 100%, ${c}% 100%)`:`polygon(0 0, ${d+o}% 0, ${c-o}% 100%, 0 100%)`,e.style.transform=`translateX(${((u?-1:1)*l(r.drift)*i).toFixed(3)}%)`},clear(e){e.style.clipPath="",e.style.transform=""}};var gr={up:[0,1],down:[0,-1],left:[1,0],right:[-1,0]},br={slug:"transition/stack-over",summary:"The next scene slides over the current one, which recedes and dims beneath it.",duration:.7,calm:{recede:.97,dim:.4},params:{duration:{type:"number",default:.7,min:.4,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"up",options:["up","down","left","right"],label:"Which way the new scene travels"},recede:{type:"number",default:.94,min:.88,max:.98,step:.01,unit:"x",label:"Scale the old scene shrinks to"},dim:{type:"number",default:.7,min:.2,max:.8,step:.05,unit:"ratio",label:"Brightness the old scene dims to"},radius:{type:"number",default:2,min:0,max:6,step:.5,unit:"% of width",label:"Corner radius while moving"}},apply(e,n,t,r,a){let i=a.ease([.4,0,.1,1])(t),[o,u]=a.size,[m,d]=gr[F(r.direction)]??gr.up,c=l(r.radius)/100*o,p=Math.min(1,Math.max(0,(t-.75)/.25)),f=c*(1-p*p*(3-2*p));n.style.transform=`translate(${(m*(1-i)*o).toFixed(2)}px, ${(d*(1-i)*u).toFixed(2)}px)`,n.style.borderRadius=f>.5?`${f.toFixed(1)}px`:"";let g=.3*Math.min(1,(1-i)*4);n.style.boxShadow=g>.002?`${(-m*24).toFixed(0)}px ${(-d*24).toFixed(0)}px 90px rgba(0,0,0,${g.toFixed(3)})`:"",e.style.transform=`scale(${(1-(1-l(r.recede))*i).toFixed(4)})`,e.style.filter=`brightness(${(1-(1-l(r.dim))*i).toFixed(3)}) blur(${(i*2).toFixed(2)}px)`,e.style.clipPath=`inset(0 round ${(l(r.radius)/100*o*i).toFixed(1)}px)`},clear(e){e.style.transform="",e.style.clipPath="",e.style.boxShadow="",e.style.filter="",e.style.borderRadius=""}};var st=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Se(e,n,t={}){let r=e.ownerDocument,a=new Set([...t.accent??[]].map(st)),s=t.mask??"none",i=Math.max(0,t.feather??0),o=(h,y="")=>i>0?`display:${h};overflow:hidden;${y}padding:${.14}em 0.06em ${.14+i}em;margin:-${.14}em -0.06em -${.14+i}em;mask-image:linear-gradient(to bottom, #000 calc(100% - ${i}em), transparent);-webkit-mask-image:linear-gradient(to bottom, #000 calc(100% - ${i}em), transparent)`:`display:${h};overflow:hidden;${y}padding:${.14}em 0.06em;margin:-${.14}em -0.06em`;e.textContent="";let u=[],m=[],d=[],c=[];n.split(`
|
|
1
|
+
var Z=(e,n=0,t=1)=>Math.min(t,Math.max(n,e)),ve=(e,n,t)=>e+(n-e)*t;function je(e,n,t,r){let a=3*e,s=3*(t-e)-a,i=1-a-s,o=3*n,u=3*(r-n)-o,m=1-o-u,d=p=>((i*p+s)*p+a)*p,c=p=>((m*p+u)*p+o)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let f=p;for(let g=0;g<8;g++){let b=(3*i*f+2*s)*f+a;if(Math.abs(b)<1e-6)break;f-=(d(f)-p)/b}if(f<0||f>1||Math.abs(d(f)-p)>1e-4){let g=0,b=1;for(let h=0;h<24;h++)f=(g+b)/2,d(f)<p?g=f:b=f}return c(f)}}function en({duration:e,bounce:n=0}){let t=2*Math.PI/(Math.max(.05,e)*1.2),r=Z(1-n,.05,1);return a=>{if(a<=0)return 0;if(a>=1)return 1;let s=a*e*(1+2*n);if(r<1){let i=t*Math.sqrt(1-r*r);return 1-Math.exp(-r*t*s)*(Math.cos(i*s)+r*t/i*Math.sin(i*s))}return 1-Math.exp(-t*s)*(1+t*s)}}var pt={"ui.default":[.2,0,0,1],"ui.in":[.4,0,1,1],"ui.out":[0,0,.2,1],"ui.spring":[.22,1,.36,1]},zt={"expressive.out":[.05,.7,.1,1],"expressive.in":[.3,0,.8,.15],"expressive.inOut":[.7,0,.1,1],"snap.out":[.3,.9,.1,1],"anticipate.in":[.45,-.48,1,-.82],punch:[.16,1,.3,1],"bounce.out":[.34,1.36,.64,1]},Bs={linear:[0,0,1,1],smooth:[.45,0,.55,1],"sine.in":[.12,0,.39,0],"sine.out":[.61,1,.88,1],"sine.inOut":[.37,0,.63,1],"cubic.in":[.32,0,.67,0],"cubic.out":[.33,1,.68,1],"cubic.inOut":[.65,0,.35,1],"expo.in":[.7,0,.84,0],"expo.out":[.16,1,.3,1],"expo.inOut":[.87,0,.13,1],"quad.in":[.11,0,.5,0],"quad.out":[.5,1,.89,1],"quad.inOut":[.45,0,.55,1],"quart.in":[.5,0,.75,0],"quart.out":[.25,1,.5,1],"quart.inOut":[.76,0,.24,1],"quint.in":[.64,0,.78,0],"quint.out":[.22,1,.36,1],"quint.inOut":[.83,0,.17,1],"circ.in":[.55,0,1,.45],"circ.out":[0,.55,.45,1],"circ.inOut":[.85,0,.15,1],"back.in":[.36,0,.66,-.56],"back.out":[.34,1.56,.64,1],"back.inOut":[.68,-.6,.32,1.6],"elastic.out":[.34,1.56,.64,1],...zt,...pt},Rt={linear:e=>e,"sine.in":e=>1-Math.cos(e*Math.PI/2),"sine.out":e=>Math.sin(e*Math.PI/2),"sine.inOut":e=>-(Math.cos(Math.PI*e)-1)/2,"cubic.in":e=>e*e*e,"cubic.out":e=>1-Math.pow(1-e,3),"cubic.inOut":e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,"expo.in":e=>e<=0?0:Math.pow(2,10*e-10),"expo.out":e=>e>=1?1:1-Math.pow(2,-10*e),"expo.inOut":e=>e<=0?0:e>=1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2,"back.out":e=>1+2.70158*Math.pow(e-1,3)+1.70158*Math.pow(e-1,2),smooth:e=>e*e*e*(e*(e*6-15)+10),"quad.in":e=>e*e,"quad.out":e=>1-(1-e)*(1-e),"quad.inOut":e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,"quart.in":e=>e*e*e*e,"quart.out":e=>1-Math.pow(1-e,4),"quart.inOut":e=>e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2,"quint.in":e=>e*e*e*e*e,"quint.out":e=>1-Math.pow(1-e,5),"quint.inOut":e=>e<.5?16*Math.pow(e,5):1-Math.pow(-2*e+2,5)/2,"circ.in":e=>1-Math.sqrt(1-e*e),"circ.out":e=>Math.sqrt(1-Math.pow(e-1,2)),"circ.inOut":e=>e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2,"back.in":e=>2.70158*e*e*e-1.70158*e*e,"back.inOut":e=>{let n=2.5949095;return e<.5?Math.pow(2*e,2)*((n+1)*2*e-n)/2:(Math.pow(2*e-2,2)*((n+1)*(e*2-2)+n)+2)/2},"elastic.out":e=>e<=0?0:e>=1?1:Math.pow(2,-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1},Pe=[...Object.keys(Rt),...Object.keys(zt),...Object.keys(pt)],tn=e=>{if(typeof e=="string")return!0;if(Array.isArray(e))return e.length===4&&e.every(n=>typeof n=="number");if(e&&typeof e=="object"&&"spring"in e){let n=e.spring;return!!n&&typeof n=="object"&&typeof n.duration=="number"}return!1};function Re(e,n={}){if(e===void 0)return Rt["expo.out"];if(typeof e=="string"){let t=n[e]??pt[e]??zt[e];if(t)return je(...t);let r=Rt[e];if(!r)throw new Error(`Unknown ease "${e}". Known: ${Pe.join(", ")}`);return a=>r(Z(a))}return Array.isArray(e)?je(...e):en(e.spring)}function ae(e,n,t,r){return t<=0?e>=n?1:0:r(Z((e-n)/t))}function $e(e=1){let n=e>>>0||1;return()=>{n=n+1831565813>>>0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function Ot(e,n="sine.inOut",t={}){if(e.length===0)throw new Error("A track needs at least one key");let r=[...e].sort((s,i)=>s[0]-i[0]),a=r.map(s=>Re(s[2]??n,t));return s=>{let i=r[0],o=r[r.length-1];if(s<=i[0])return i[1];if(s>=o[0])return o[1];let u=1;for(;r[u][0]<s;)u++;let m=r[u-1],d=r[u],c=d[0]-m[0],p=c<=0?1:a[u]((s-m[0])/c);return m[1]+(d[1]-m[1])*p}}var qe=["start","end","center","edges","random"];function Dt(e,n="start",t=1,r){if(e<=0)return[];if(n==="random"){let c=$e(t*977+e),p=Array.from({length:e},(b,h)=>h);for(let b=e-1;b>0;b--){let h=Math.floor(c()*(b+1));[p[b],p[h]]=[p[h],p[b]]}let f=r&&e>1?Math.hypot(r[0]-1,r[1]-1)/(e-1):1,g=new Array(e);return p.forEach((b,h)=>{g[b]=h*f}),g}let[a,s]=r??[e,1],i=c=>[c%a,Math.floor(c/a)],o=(a-1)/2,u=(s-1)/2,m=c=>{let[p,f]=i(c);return n==="end"?Math.hypot(a-1-p,s-1-f):n==="center"?Math.hypot(p-o,f-u):n==="edges"?Math.hypot(o,u)-Math.hypot(p-o,f-u):Math.hypot(p,f)},d=Array.from({length:e},(c,p)=>m(p));return r?d:d.map(c=>Math.floor(c+1e-9))}function Me(e,n,t="start",r=1,a){let s=Dt(e,t,r,a),i=Math.max(0,...s);return s.map(o=>i>0?o*n:0)}function ze(e,n="start",t=1,r){return Math.max(0,...Dt(e,n,t,r))}function Lt(e,n,t=.5){let a=e.map(([u,m])=>Math.hypot(u-n[0],m-n[1])).map((u,m)=>[u,m]).sort((u,m)=>u[0]-m[0]||u[1]-m[1]),s=new Array(e.length),i=-1,o=-1/0;for(let[u,m]of a)u-o>t&&(i++,o=u),s[m]=i;return s}var ft={fps:30,beat:2.5,hold:.6,hold_end:1.5,duration:{instant:0,fast:.3,base:.5,slow:.8},stagger:{tight:.03,base:.08,loose:.12},ease_enter:"expo.out",ease_exit:"cubic.in",ease_move:"cubic.inOut",ease_loop:"linear",transitions:"standard",ui:{duration:{fast:.12,base:.2,slow:.32,enter:.4},stagger:.1}},ht=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function gt(e,n){if(!ht(e)||!ht(n))return n===void 0?e:n;let t={...e};for(let[r,a]of Object.entries(n))t[r]=gt(t[r],a);return t}var et=(...e)=>e.reduce((n,t)=>gt(n,t),ft);function It(e){let n=[],t=(r,a)=>{if(ht(r)&&!("spring"in r))for(let[s,i]of Object.entries(r))t(i,a?`${a}.${s}`:s);else n.push(a)};return t(e,""),n}function tt(e,n){let t=e;for(let r of n.replace(/^\$/,"").split(".")){if(!ht(t)||!(r in t))return;t=t[r]}return t}var We=e=>typeof e=="string"&&e.startsWith("$");var Ze=(e,n)=>`${e.base}${String(Math.min(e.count-1,Math.max(0,n))+1).padStart(5,"0")}.${e.ext}`,l=(e,n=0)=>typeof e=="number"&&Number.isFinite(e)?e:n,F=(e,n="")=>typeof e=="string"?e:e==null?n:String(e),te=e=>Array.isArray(e)?e.map(n=>String(n)):[],ge=e=>Array.isArray(e)?e.map(n=>l(n)):[];var Na={base:"var(--m-bg-base)",surface:"var(--m-bg-surface)",sunken:"var(--m-bg-sunken)",accent:"var(--m-bg-accent)",inverse:"var(--m-bg-inverse)"},nn={slug:"el/box",summary:"A plain rectangle: a card, a rule, a colour field.",props:{fill:{type:"string",default:"surface",label:"Surface name (base, surface, sunken, accent, inverse) or a CSS colour"}},params:{width:{type:"number",default:480,min:1,max:4e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:270,min:1,max:4e3,step:1,unit:"px",label:"Height"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"}},duration:()=>0,build(e,n,t){let r=F(n.fill,"surface");return e.style.width=`${l(t.width)}px`,e.style.height=`${l(t.height)}px`,e.style.borderRadius=`${l(t.radius)}px`,e.style.background=Na[r]??r,{seek(){}}}};var Ha=(e,n)=>e.replace(/%(?:0(\d+))?d/,(t,r)=>String(n).padStart(r?Number(r):0,"0"));function ja(e,n){let t=Math.floor(Math.max(0,e-n.delay)*n.rate*n.fps+1e-6),r=Math.abs(n.last-n.first);return n.first+Math.sign(n.last-n.first)*Z(t,0,r)}var rn=e=>({first:Math.round(l(e.first)),last:Math.round(l(e.last)),fps:l(e.fps,24),rate:l(e.rate,1),delay:l(e.delay)}),an={slug:"el/frames",summary:"Footage as a numbered run of stills, played at its own frame rate. Holds its first and last frame.",props:{src:{type:"string",required:!0,label:"Path pattern with the frame number, e.g. footage/shot/f%03d.jpg"},alt:{type:"string",default:"",label:"Description of the footage"}},params:{first:{type:"number",default:0,min:0,max:1e5,step:1,unit:"frame",label:"First frame played"},last:{type:"number",default:23,min:0,max:1e5,step:1,unit:"frame",label:"Last frame played, then held. Before the first frame, the run plays backwards"},fps:{type:"number",default:24,min:1,max:120,step:1,unit:"fps",label:"Frame rate the footage was shot at"},rate:{type:"number",default:1,min:.1,max:4,step:.01,unit:"\xD7",label:"Playback speed"},delay:{type:"number",default:0,min:0,max:30,step:.05,unit:"s",label:"Time held on the first frame before it plays"},width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Width"},radius:{type:"number",default:0,min:0,max:400,step:1,unit:"px",label:"Corner radius"}},cues:()=>[],duration:(e,n)=>{let t=rn(n);return t.delay+(Math.abs(t.last-t.first)+1)/t.fps/t.rate},build(e,n,t){let r=e.ownerDocument,a=rn(t),s=F(n.src);e.style.cssText+=`;display:grid;width:${l(t.width)}px;border-radius:${l(t.radius)}px;overflow:hidden`;let i=[],o=Math.min(a.first,a.last),u=Math.max(a.first,a.last);for(let d=o;d<=u;d++){let c=r.createElement("img");c.src=Ha(s,d),c.alt=d===a.first?F(n.alt):"",c.decoding="sync",c.style.cssText="grid-area:1/1;display:block;width:100%;height:auto;visibility:hidden",e.appendChild(c),i.push(c)}let m=-1;return{seek(d){let c=ja(d,a)-o;c!==m&&(m>=0&&(i[m].style.visibility="hidden"),i[c].style.visibility="inherit",m=c)}}}};var sn={slug:"el/html",summary:"Static markup, for content no primitive covers. Style it with --ui-* tokens.",props:{html:{type:"html",required:!0,label:"Markup"}},params:{},duration:()=>0,build(e,n){return e.innerHTML=F(n.html),{seek(){}}}};var on={slug:"el/image",summary:"A picture. The path is relative to the film file.",props:{src:{type:"string",required:!0,label:"Image path or URL"},alt:{type:"string",default:"",label:"Description of the picture"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:0,min:0,max:4e3,step:1,unit:"px",label:"Height; 0 keeps the picture's own proportions, otherwise it is cropped to fill"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"},frame:{type:"number",default:0,min:0,max:24,step:.5,unit:"px",label:"Ring drawn inside the edge, in the border colour (--m-frame to change it)"},bevel:{type:"number",default:0,min:0,max:1,step:.05,unit:"strength",label:"A light top edge and a dark bottom edge, as on a printed card"}},duration:()=>0,build(e,n,t){let r=e.ownerDocument,a=`${l(t.radius)}px`,s=r.createElement("img");s.src=F(n.src),s.alt=F(n.alt),s.decoding="sync";let i=l(t.height);s.style.cssText=`display:block;width:${l(t.width)}px;height:${i>0?`${i}px`:"auto"};object-fit:cover;border-radius:${a}`,e.appendChild(s),e.style.borderRadius=a;let o=l(t.frame),u=l(t.bevel);if(o>0||u>0){let m=r.createElement("div"),d=[o>0?`inset 0 0 0 ${o}px var(--m-frame, var(--m-border))`:"",u>0?`inset 0 1px 0 rgb(255 255 255 / ${(.55*u).toFixed(3)}), inset 0 -1px 0 rgb(0 0 0 / ${(.35*u).toFixed(3)})`:""].filter(Boolean).join(", ");m.style.cssText=`position:absolute;inset:0;border-radius:${a};box-shadow:${d};pointer-events:none`,e.appendChild(m)}return{seek(){}}}};var ln={slug:"el/slot",summary:"An empty frame the host page fills, e.g. with a rendered UI component.",props:{name:{type:"string",required:!0,label:"Slot name the host fills"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:360,min:1,max:4e3,step:1,unit:"px",label:"Height"}},duration:()=>0,build(e,n,t,r){let a=F(n.name);e.dataset.motionSlot=a,e.style.width=`${l(t.width)}px`,e.style.minHeight=`${l(t.height)}px`;let s=r.slots[a];return s?s(e):(e.style.cssText+=";display:grid;place-items:center;border:2px dashed var(--m-border);border-radius:16px;font:500 24px var(--m-font-mono);color:var(--m-text-muted)",e.textContent=`slot: ${a}`),{seek(){}}}};var un={slug:"el/text",summary:"A block of text. Animate it with enter, exit and tracks.",props:{text:{type:"string",required:!0,label:"Text. Use \\n for a line break."}},params:{},duration:()=>0,build(e,n){return e.style.whiteSpace="pre-line",e.textContent=F(n.text),{seek(){}}}};function qa(e){let n=ge(e);return n.length===4&&n[2]>0&&n[3]>0?[n[0],n[1],n[2],n[3]]:[0,0,100,100]}function nt(e,n,t){let r=l(n.from),a=l(n.to),s=l(t.rate,1),i=Math.max(0,e)*s;return t.loop===!0&&a>r?r+i%(a-r):a>r?Math.min(a,r+i):r+i}var mn={slug:"el/video",summary:"Footage. Plays a stretch of a video file; the path is relative to the film file.",props:{src:{type:"string",required:!0,label:"Video path or URL"},from:{type:"number",default:0,label:"Source time the layer opens on, in seconds"},to:{type:"number",default:0,label:"Source time it ends on, in seconds; 0 plays on until the scene ends"},crop:{type:"number[]",default:[],label:"Part of the picture to show: [x, y, width, height] in % of the source"},continues:{type:"string",default:"",label:'Open on the frame after another video layer ends, as "scene.layer": a seamless loop through footage'}},params:{rate:{type:"number",default:1,min:.1,max:4,step:.05,unit:"\xD7",label:"Playback speed"},loop:{type:"boolean",default:!1,label:'Wrap from "to" back to "from" until the scene ends'},width:{type:"number",default:1280,min:1,max:8e3,step:1,unit:"px",label:"Width"},height:{type:"number",default:0,min:0,max:8e3,step:1,unit:"px",label:"Height; 0 keeps the shot's proportions"},radius:{type:"number",default:0,min:0,max:400,step:1,unit:"px",label:"Corner radius"}},cues:()=>[],duration:(e,n)=>{let t=l(e.from),r=l(e.to);return n.loop===!0||!(r>t)?0:(r-t)/l(n.rate,1)},check(e,n){let t=[],r=l(e.from),a=l(e.to);r<0&&t.push({path:"props.from",message:"from is a source time in seconds, zero or more."}),a!==0&&a<=r&&t.push({path:"props.to",message:`to (${a} s) must come after from (${r} s).`,hint:"Leave it at 0 to play on until the scene ends."}),n.loop===!0&&!(a>r)&&t.push({path:"params.loop",message:"A loop needs both ends: set props.to after props.from."});let s=ge(e.crop);s.length&&(s.length!==4||s[2]<=0||s[3]<=0||s[0]<0||s[1]<0||s[0]+s[2]>100.001||s[1]+s[3]>100.001)&&t.push({path:"props.crop",message:"crop is [x, y, width, height] in % of the source, inside 0\u2013100.",hint:"For the middle half: [25, 25, 50, 50]."});let i=F(e.continues);return i&&!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/.test(i)&&t.push({path:"props.continues",message:'continues names a video layer as "scene.layer".'}),i&&l(e.from)!==0&&t.push({path:"props.from",message:'from is worked out from "continues"; the value given is ignored.',hint:"Remove from, or remove continues."}),t},build(e,n,t,r){let a=e.ownerDocument,[s,i,o,u]=qa(n.crop),m=l(t.width),d=l(t.height),c=l(t.radius),p=a.createElement("div");p.style.cssText=`position:relative;overflow:hidden;width:${m}px;border-radius:${c}px;${d>0?`height:${d}px`:"aspect-ratio:16 / 9"}`,e.style.borderRadius=`${c}px`;let f=a.createElement("div");f.style.cssText=`position:absolute;left:${-s/o*100}%;top:${-i/u*100}%;width:${100/o*100}%;height:${100/u*100}%`,p.appendChild(f),e.appendChild(p);let g="object-fit:fill;display:block;width:100%;height:100%",b=(j,x)=>{if(!(j>0&&x>0))return;if(d<=0){p.style.aspectRatio=`${(j*o).toFixed(3)} / ${(x*u).toFixed(3)}`;return}let N=j*o/(x*u)/(m/d);f.style.transformOrigin=`${s+o/2}% ${i+u/2}%`,f.style.transform=`scale(${Math.max(1,N).toFixed(5)}, ${Math.max(1,1/N).toFixed(5)})`},h=r.frames;if(h){let j=a.createElement("img");j.decoding="sync",j.alt="",j.style.cssText=g,j.src=Ze(h,0),f.appendChild(j),b(h.width,h.height);let x=0,N=0,S=Promise.resolve(),$=(X,C)=>j.decode().catch(()=>{if(!(X!==N||j.complete&&j.naturalWidth>0))return new Promise((q,P)=>{j.addEventListener("load",()=>q(),{once:!0}),j.addEventListener("error",()=>X===N?P(new Error(`Video frame did not load: ${C}`)):q(),{once:!0})})});return{seek(X){let C=Math.round((nt(X,n,t)-h.start)*h.rate+1e-6),q=Math.min(h.count-1,Math.max(0,C));if(q===x)return;x=q;let P=Ze(h,q);j.src=P,S=$(++N,P)},pending:()=>S}}let y=a.createElement("video");y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=F(n.src),y.style.cssText=g,f.appendChild(y),y.addEventListener("loadedmetadata",()=>b(y.videoWidth,y.videoHeight));let v=()=>a.documentElement.classList.contains("render"),E=l(t.rate,1),M=Promise.resolve(),k=-1,R=0,z,L=j=>{Math.abs(y.currentTime-j)<.5/r.fps||(M=new Promise(x=>{let N=()=>{y.removeEventListener("seeked",N),x()};y.addEventListener("seeked",N),y.currentTime=j}))};return{seek(j){let x=nt(j,n,t);if(v()){L(x);return}let N=performance.now(),S=j-k,$=(N-R)/1e3;k=j,R=N,S>0&&S<.25&&Math.abs(S-$)<.1?(Math.abs(y.currentTime-x)>.2&&(y.currentTime=x),y.playbackRate=E,y.paused&&y.play().catch(()=>{}),clearTimeout(z),z=setTimeout(()=>y.pause(),120)):(y.pause(),L(x))},pending:()=>M}}};var dn={slug:"fx/counter-roll",summary:"A number rolls up to its value.",props:{value:{type:"number",required:!0,label:"The number to land on"},from:{type:"number",default:0,label:"The number to start from"},decimals:{type:"number",default:0,label:"Decimal places"},prefix:{type:"string",default:"",label:"Text before the number"},suffix:{type:"string",default:"",label:"Text after the number"}},params:{duration:{type:"number",default:1,min:.6,max:1.5,step:.05,unit:"s",label:"Time to roll"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=l(n.value),i=l(n.from),o=Math.max(0,Math.round(l(n.decimals))),u=l(t.duration);return e.style.fontVariantNumeric="tabular-nums",e.style.whiteSpace="pre",{seek(m){let d=m>=u?s:i+(s-i)*ae(m,0,u,a);e.textContent=`${F(n.prefix)}${d.toFixed(o)}${F(n.suffix)}`}}}};var cn={slug:"fx/depth-drift",summary:"A floating collage on several depth planes.",props:{items:{type:"string[]",required:!0,label:"Labels of the floating pieces"}},params:{planes:{type:"number",default:3,min:2,max:3,step:1,unit:"planes",label:"Depth planes"},speed:{type:"number",default:20,min:10,max:30,step:1,unit:"px/s",label:"Drift speed of the nearest plane"}},duration:()=>0,build(e,n,t,r){let[a,s]=r.size,i=a/100,o=Math.max(1,Math.round(l(t.planes))),u=l(t.speed),m=$e(r.seed*101+7),d=r.ease(r.tokens.ease_enter),c=r.tokens.duration.base,p=r.tokens.stagger.base;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let f=te(n.items).map((g,b,h)=>{let y=(b+m()*.6)/h.length*Math.PI*2,v=.3+m()*.14,E=a/2+Math.cos(y)*a*v,M=s/2+Math.sin(y)*s*(v+.04),k=b%o,R=o===1?1:1-k/o,z=document.createElement("span");return z.textContent=g,z.style.cssText=`position:absolute;left:0;top:0;padding:${.7*i}px ${1.4*i}px;border-radius:999px;white-space:nowrap;background:var(--m-bg-surface);font:500 ${1.4*i}px var(--m-font-mono);color:var(--m-text-primary)${k===0&&o>1?`;filter:blur(${.06*i}px)`:""}`,e.appendChild(z),{n:z,x:E,y:M,depth:R,delay:b*p}});return{seek(g){for(let b of f){let h=(g-2)*u*b.depth;b.n.style.transform=`translate(${b.x+h}px, ${b.y}px) translate(-50%, -50%) scale(${.72+b.depth*.42})`,b.n.style.opacity=String(d(Math.min(1,Math.max(0,(g-b.delay)/c)))*(.35+b.depth*.5))}}}}};var pn={slug:"fx/stagger-fill",summary:"Items appear one after another.",props:{items:{type:"string[]",required:!0,label:"The items, in reading order"}},params:{stagger:{type:"number",default:.04,min:.02,max:.06,step:.005,unit:"s",label:"Delay between items"}},duration:(e,n,t)=>Math.max(0,te(e.items).length-1)*l(n.stagger)+t.tokens.duration.base,build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=r.tokens.duration.base,i=l(t.stagger);e.style.cssText+=";display:flex;flex-wrap:wrap;justify-content:center;gap:0.5em";let o=te(n.items).map(u=>{let m=document.createElement("span");return m.textContent=u,m.style.cssText="padding:0.45em 0.9em;border-radius:999px;background:var(--m-bg-surface);white-space:nowrap;will-change:transform,opacity",e.appendChild(m),m});return{seek(u){o.forEach((m,d)=>{let c=ae(u,d*i,s,a);m.style.opacity=String(c),m.style.transform=`scale(${.9+.1*c})`})}}}};var hn=["inverse","plain","accent","tint"],fn={slug:"rig/orbit-ring",summary:"Tiles on a tilted ring that rotates forever.",props:{items:{type:"string[]",default:[],label:"Tile labels. Repeated to fill the ring; empty tiles when left out."}},params:{tiles:{type:"number",default:12,min:8,max:16,step:1,unit:"tiles",label:"Tiles"},tilt_x:{type:"number",default:25,min:15,max:35,step:1,unit:"deg",label:"Pitch",pad:{name:"tilt",axis:"y"}},tilt_z:{type:"number",default:-20,min:-30,max:-10,step:1,unit:"deg",label:"Roll",pad:{name:"tilt",axis:"x"}},period:{type:"number",default:15,min:12,max:18,step:.5,unit:"s",label:"Time for one turn"},min_opacity:{type:"number",default:.4,min:.3,max:.6,step:.01,unit:"ratio",label:"Opacity of tiles facing away",from:"texture/depth-fade"},radius:{type:"number",default:24,min:14,max:34,step:.5,unit:"% of stage width",label:"Ring radius"},tile:{type:"number",default:11,min:6,max:16,step:.5,unit:"% of stage width",label:"Tile size"}},duration:()=>0,build(e,n,t,r){let[a]=r.size,s=a/100,i=Math.max(1,Math.round(l(t.tiles))),o=te(n.items),u=l(t.radius)*s,m=l(t.tile)*s,d=l(t.min_opacity),c=Math.max(.1,l(t.period));e.style.cssText+=`;position:absolute;inset:0;max-width:none;perspective:${120*s}px;perspective-origin:50% 42%`;let p=document.createElement("div");p.style.cssText=`position:absolute;left:50%;top:47%;width:0;height:0;transform-style:preserve-3d;transform:rotateX(${-l(t.tilt_x)}deg) rotateZ(${l(t.tilt_z)}deg)`;let f=Array.from({length:i},(g,b)=>{let h=document.createElement("div"),y=o.length?o[b%o.length]:"",v=hn[b%hn.length],E=[...y].length>3,M=v==="inverse"?"background:var(--m-bg-inverse);color:var(--m-text-inverse)":v==="accent"?"background:var(--m-bg-accent);color:var(--m-text-on-accent)":v==="tint"?"background:color-mix(in srgb, var(--m-bg-accent) 24%, var(--m-bg-base));color:var(--m-accent)":"background:var(--m-bg-surface);color:var(--m-text-primary)";return h.textContent=y,h.style.cssText=`position:absolute;left:${-m/2}px;top:${-m/2}px;width:${m}px;height:${m}px;border-radius:${m*.12}px;display:grid;place-items:center;overflow:hidden;font:${E?`500 ${m*.14}px var(--m-font-mono)`:`600 ${m*.4}px var(--m-font-display)`};letter-spacing:${E?"0":"-0.03em"};${M}`,p.appendChild(h),h});return e.appendChild(p),{seek(g){let b=g/c*360;f.forEach((h,y)=>{let v=y*360/i+b,E=(Math.cos(v*Math.PI/180)+1)/2;h.style.transform=`rotateY(${v}deg) translateZ(${u}px)`,h.style.opacity=String(d+(1-d)*E),h.style.filter=E<.999?`saturate(${.35+.65*E})`:""})}}}};var gn=[1,1.24,.6,1.1,.9,1.3],bn=[.1,.5,.92,.3,.7,.2],xn={slug:"scene/marquee-wall",summary:"Rows of chips or logos scrolling sideways.",props:{items:{type:"string[]",required:!0,label:"Chip labels"},highlight:{type:"string",default:"",label:"One label to emphasise while the others dim"}},params:{rows:{type:"number",default:5,min:4,max:6,step:1,unit:"rows",label:"Rows"},speed:{type:"number",default:60,min:30,max:120,step:5,unit:"px/s",label:"Scroll speed"},dim_opacity:{type:"number",default:.5,min:.4,max:.6,step:.01,unit:"ratio",label:"Opacity of the other items once one is emphasised",from:"fx/marquee-highlight"},highlight_at:{type:"number",default:1.5,min:0,max:10,step:.1,unit:"s",label:"When the emphasis starts"}},duration:()=>0,build(e,n,t,r){let a=te(n.items),s=Math.max(1,Math.round(l(t.rows))),i=l(t.speed),o=F(n.highlight);e.style.cssText+=`;width:${r.size[0]}px;display:flex;flex-direction:column;gap:0.55em;overflow:hidden`;let u=Array.from({length:s},(p,f)=>{let g=a.filter((k,R)=>R%s===f),b=g.length?g:a,h=document.createElement("div");h.style.cssText="display:flex;width:max-content;will-change:transform";let y=k=>b.forEach(R=>{let z=document.createElement("span");if(z.textContent=R,z.style.cssText="position:relative;flex:none;margin-right:0.5em;padding:0.45em 0.9em;border-radius:999px;white-space:nowrap;background:var(--m-bg-surface)",R===o){let L=document.createElement("span");L.textContent=R,L.setAttribute("aria-hidden","true"),L.style.cssText="position:absolute;inset:0;display:grid;place-items:center;border-radius:inherit;background:var(--m-bg-accent);color:var(--m-text-on-accent);opacity:var(--k, 0)",z.appendChild(L),z.style.transform="scale(calc(1 + 0.08 * var(--k, 0)))",z.style.zIndex="1"}else z.style.opacity="calc(1 - var(--dim, 0) * var(--k, 0))";k.appendChild(z)}),v=document.createElement("div");v.style.cssText="display:flex;flex:none",y(v),h.appendChild(v),e.appendChild(h);let E=Math.max(1,v.getBoundingClientRect().width/Za(e)),M=Math.ceil(r.size[0]/E)+1;for(let k=0;k<M;k++)h.appendChild(v.cloneNode(!0));return{track:h,width:E,dir:f%2?-1:1,rate:gn[f%gn.length],off:bn[f%bn.length]}}),m=r.ease(r.tokens.ease_move),d=l(t.highlight_at),c=r.tokens.duration.slow;return e.style.setProperty("--dim",String(o?1-l(t.dim_opacity):0)),{seek(p){e.style.setProperty("--k",String(o?ae(p,d,c,m):0));for(let f of u){let g=(p*i*f.rate+f.off*f.width)%f.width;f.track.style.transform=`translateX(${-(f.dir>0?g:f.width-g)}px)`}}}}};function Za(e){let n=e.closest(".m-stage");if(!n)return 1;let t=n.getBoundingClientRect().width;return t>0&&n.offsetWidth>0?t/n.offsetWidth:1}function Xa(e,n,t,r){let a=Math.max(1,Math.round(n)),s=(t-r*(a-1))/a,i=new Array(a).fill(0);return{cards:e.map(u=>{let m=0;for(let p=1;p<a;p++)i[p]<i[m]-.5&&(m=p);let d=s/(u>0?u:1),c={x:m*(s+r),y:i[m],w:s,h:d};return i[m]=i[m]+d+r,c}),height:Math.max(0,Math.max(...i)-r)}}function Bt(e,n,t){let r=Lt(e.map(i=>[i.x+i.w/2,i.y+i.h/2]),n),a=Math.max(0,...r),s=Math.max(0,e.length-1)*t;return r.map(i=>a>0?i/a*s:0)}var yn={slug:"scene/grid-wall",summary:"A masonry or regular grid of media.",props:{images:{type:"string[]",required:!0,label:"Pictures, in order: each goes under the shortest column"},ratios:{type:"number[]",default:[],label:"Width \xF7 height of each picture. Left out, read from the files once they load"}},params:{columns:{type:"number",default:4,min:2,max:8,step:1,unit:"cols",label:"Columns"},width:{type:"number",default:90,min:20,max:200,step:1,unit:"% of stage width",label:"Width of the wall"},gap:{type:"number",default:16,min:0,max:80,step:1,unit:"px",label:"Space between pictures (corners are \xBE of it, or --m-card-radius)"},stagger:{type:"number",default:.05,min:.01,max:.15,step:.005,unit:"s",label:"Delay between pictures"},focus_x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of the wall",label:"Where the opening starts, across",pad:{name:"focus",axis:"x"}},focus_y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of the wall",label:"Where the opening starts, down",pad:{name:"focus",axis:"y"}},drift_speed:{type:"number",default:20,min:0,max:40,step:1,unit:"px/s",label:"Upward drift of the whole wall; 0 holds it still"}},duration:(e,n,t)=>Math.max(0,te(e.images).length-1)*l(n.stagger)+t.tokens.duration.slow,check(e){let n=te(e.images).length,t=ge(e.ratios);return t.length&&t.length!==n?[{path:"props.ratios",message:`ratios has ${t.length} values for ${n} pictures.`,hint:"Give one per picture, or leave ratios out."}]:t.some(r=>!(r>0))?[{path:"props.ratios",message:"Each ratio is width \xF7 height, above zero."}]:[]},build(e,n,t,r){let a=e.ownerDocument,s=te(n.images),i=ge(n.ratios),o=l(t.width)/100*r.size[0],u=l(t.gap),m=l(t.columns),d=l(t.stagger),c=r.tokens.duration.slow,p=l(t.drift_speed),f=r.ease(r.tokens.ease_enter),g=a.createElement("div");g.style.cssText=`position:relative;width:${o}px`;let b=s.map(M=>{let k=a.createElement("img");return k.src=M,k.alt="",k.decoding="sync",k.style.cssText=`position:absolute;display:block;object-fit:cover;border-radius:var(--m-card-radius, ${Math.round(u*.75)}px)`,g.appendChild(k),k});e.appendChild(g);let h="",y=[],v=[],E=()=>{let M=b.map((L,j)=>i[j]??(L.naturalWidth>0?L.naturalWidth/L.naturalHeight:1)),k=M.map(L=>L.toFixed(4)).join();if(k===h)return;h=k;let{cards:R,height:z}=Xa(M,m,o,u);g.style.height=`${z}px`,R.forEach((L,j)=>Object.assign(b[j].style,{left:`${L.x}px`,top:`${L.y}px`,width:`${L.w}px`,height:`${L.h}px`})),v=R.map(L=>L.y),y=Bt(R,[l(t.focus_x)/100*o,l(t.focus_y)/100*z],d)};return E(),{seek(M){E(),b.forEach((k,R)=>{let z=ae(M,y[R],c,f);k.style.opacity=z.toFixed(4),k.style.top=`${(v[R]+(1-z)*24).toFixed(2)}px`}),g.style.transform=p>0?`translateY(${(-p*Math.max(0,M)).toFixed(2)}px)`:""}}}};var rt=["slide-up","slide-left","flip","stack","fade"],wn=["slide-up","flip","slide-left","stack","fade"],Ya=e=>e.split(/[/|\n]/).map(n=>n.trim().split(/\s+/).filter(Boolean)).filter(n=>n.length>0);function at(e){let n=Ya(e),t=n.length,r=n[0]?.length??0;if(!t)return{tiles:[],cols:0,rows:0,problem:"areas is empty."};let a=n.findIndex(o=>o.length!==r);if(a>=0)return{tiles:[],cols:r,rows:t,problem:`Row ${a+1} has ${n[a].length} cells; the first has ${r}.`};let s=[],i=new Map;n.forEach((o,u)=>o.forEach((m,d)=>{let c=i.get(m);if(!c){let g={name:m,col:d,row:u,cols:1,rows:1};i.set(m,g),s.push(g);return}let p=Math.max(c.col+c.cols,d+1),f=Math.max(c.row+c.rows,u+1);c.col=Math.min(c.col,d),c.cols=p-c.col,c.rows=f-c.row}));for(let o of s){let u=0;if(n.forEach((m,d)=>m.forEach((c,p)=>{c===o.name?u++:p>=o.col&&p<o.col+o.cols&&d>=o.row&&d<o.row+o.rows&&(u=-1/0)})),u!==o.cols*o.rows)return{tiles:[],cols:r,rows:t,problem:`Tile "${o.name}" does not cover one rectangle.`}}return{tiles:s,cols:r,rows:t}}function bt(e,n,t){let r=Array.from({length:n},()=>[]);if(t.length){let a=0;t.forEach((s,i)=>{if(i<n)for(let o=0;o<Math.max(0,Math.round(s))&&a<e;o++)r[i].push(a++)})}else for(let a=0;a<e;a++)r[a%Math.max(1,n)].push(a);return r}function Ua(e,n,t,[r,a]){let{tiles:s,cols:i,rows:o}=at(e),u=n/100*r,m=Math.max(a*.1,a-(r-u)),d=(u-t*(i-1))/Math.max(1,i),c=(m-t*(o-1))/Math.max(1,o);return s.map(p=>(p.cols*d+(p.cols-1)*t)*(p.rows*c+(p.rows-1)*t)/(r*a))}function vn(e,n,t,r){let a=Math.max(1e-6,t);return Array.from({length:e},(s,i)=>n+a-(r*(e-1-i)%a+a)%a)}function Va(e,n,t,r,a){let s=r+a;if(t<2)return{from:0,to:0,k:1,age:0};if(e<n)return{from:0,to:0,k:1,age:Math.max(0,e-n+s)};let i=Math.floor((e-n)/s),o=e-n-i*s;return o<a?{from:i%t,to:(i+1)%t,k:o/a,age:o}:{from:(i+1)%t,to:(i+1)%t,k:1,age:o}}var Ga=/^(data:image\/|[^<\s]+\.(png|jpe?g|webp|gif|avif|svg)(\?\S*)?$)/i;function xt(e,n){if(Ga.test(n.trim())){let t=e.ownerDocument.createElement("img");return t.src=n.trim(),t.alt="",t.decoding="sync",t.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:cover",e.appendChild(t),t}e.innerHTML=n}function Ka(e,n,t,r){switch(t.style.zIndex="2",n.style.zIndex="1",e){case"slide-up":n.style.transform=`translateY(${(-100*r).toFixed(3)}%)`,t.style.transform=`translateY(${(100*(1-r)).toFixed(3)}%)`;break;case"slide-left":n.style.transform=`translateX(${(-100*r).toFixed(3)}%)`,t.style.transform=`translateX(${(100*(1-r)).toFixed(3)}%)`;break;case"flip":{let a=1-.08*Math.sin(Math.PI*r);n.style.transform=`scale(${a.toFixed(4)}) rotateY(${(180*r).toFixed(3)}deg)`,t.style.transform=`scale(${a.toFixed(4)}) rotateY(${(180*r-180).toFixed(3)}deg)`;break}case"stack":n.style.transform=`translateY(${(6*r).toFixed(3)}%) scale(${(1-.1*r).toFixed(4)})`,n.style.opacity=(1-.6*r).toFixed(4),t.style.transform=`translateY(${(-100*(1-r)).toFixed(3)}%)`;break;case"fade":t.style.opacity=r.toFixed(4),t.style.transform=`scale(${(1.04-.04*r).toFixed(4)})`;break}}var Ja=.06,kn={slug:"scene/bento-grid",summary:"Tiles of different sizes on one grid, each cycling its own content on its own clock.",props:{areas:{type:"string",required:!0,label:'The grid as named areas, rows split by "/": "a b c / d b e". A name over several cells is one larger tile'},items:{type:"string[]",required:!0,label:"What the tiles show: markup or a picture path each. Dealt to tiles in turn, or by counts"},counts:{type:"number[]",default:[],label:"How many items each tile cycles, in tile order (reading order of first appearance). 1 holds still"},swaps:{type:"string[]",default:[],label:"Swap move per tile: slide-up, slide-left, flip, stack or fade. Left out, the swap param decides"}},params:{width:{type:"number",default:92,min:30,max:100,step:1,unit:"% of stage width",label:"Width of the grid; the margin is the same all round"},gap:{type:"number",default:14,min:0,max:60,step:1,unit:"px",label:"Space between tiles (corners are \xBE of it, or --m-card-radius)"},hold:{type:"number",default:1.6,min:.4,max:6,step:.05,unit:"s",label:"How long each item rests before its tile swaps again"},swap:{type:"choice",default:"mixed",options:["mixed",...rt],label:"Swap move for tiles without their own: mixed gives neighbours different moves"},swap_time:{type:"number",default:.7,min:.2,max:2,step:.05,unit:"s",label:"Length of one swap"},offset:{type:"number",default:.3,min:0,max:2,step:.05,unit:"s",label:"Phase between one tile\u2019s swap and the next, in reading order"},stagger:{type:"number",default:.06,min:0,max:.2,step:.005,unit:"s",label:"Delay between tiles opening from the centre; 0: the grid is there from the first frame (for loops)"}},duration(e,n,t){let{tiles:r}=at(F(e.areas)),a=bt(te(e.items).length,r.length,ge(e.counts)),s=l(n.stagger),i=s>0?Math.max(0,r.length-1)*s+t.tokens.duration.slow:0,o=Math.max(0,...a.map(u=>u.length));return i+(o>1?o*(l(n.hold)+l(n.swap_time)):l(n.hold))},cycles:!0,cues(e,n,t){let{tiles:r}=at(F(e.areas)),a=bt(te(e.items).length,r.length,ge(e.counts)),s=l(n.hold),i=l(n.swap_time),o=s+i,u=l(n.stagger),m=u>0?Math.max(0,r.length-1)*u+t.tokens.duration.slow:0,d=Math.max(0,...a.map(g=>g.length));if(d<2)return[];let c=m+d*o,p=a.map((g,b)=>g.length>1?b:-1).filter(g=>g>=0),f=Ua(F(e.areas),l(n.width),l(n.gap),t.size);return vn(p.length,m,s,l(n.offset)).flatMap((g,b)=>{let h=[],y=+f[p[b]].toFixed(4);for(let v=g;v+i<=c+1e-6;v+=o)h.push({at:v,length:i,lane:b,share:y});return h})},check(e){let n=[],{tiles:t,problem:r}=at(F(e.areas));if(r)return[{path:"props.areas",message:r,hint:'Write rows of equal length, split by "/", and let each name cover one rectangle: "a a b / c d b".'}];let a=te(e.items).length,s=ge(e.counts);s.length&&s.length!==t.length?n.push({path:"props.counts",message:`counts has ${s.length} values for ${t.length} tiles (${t.map(d=>d.name).join(", ")}).`,hint:"Give one count per tile, in reading order."}):s.length&&s.reduce((d,c)=>d+c,0)!==a&&n.push({path:"props.counts",message:`counts add up to ${s.reduce((d,c)=>d+c,0)}, but there are ${a} items.`,hint:"Make the counts add up to the number of items."}),s.some(d=>!(d>=1)||d!==Math.round(d))&&n.push({path:"props.counts",message:"Each count is a whole number, 1 or more."}),!s.length&&a<t.length&&n.push({path:"props.items",message:`${a} items for ${t.length} tiles: some tiles would be empty.`,hint:"Give at least one item per tile."});let o=bt(a,t.length,s).map(d=>d.length).filter(d=>d>1),u=Math.max(0,...o),m=o.filter(d=>u%d!==0);return m.length&&n.push({path:"props.counts",message:`Tiles cycle ${[...new Set(o)].join(", ")} items: at the end, the tiles with ${[...new Set(m)].join(", ")} are not back on their first item, so a loop would jump.`,hint:`For a loop, give each tile a count that divides ${u}.`}),te(e.swaps).forEach((d,c)=>{rt.includes(d)||n.push({path:`props.swaps[${c}]`,message:`"${d}" is not a swap move.`,hint:`Use one of ${rt.join(", ")}.`})}),n},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,{tiles:o,cols:u,rows:m}=at(F(n.areas)),d=te(n.items),c=bt(d.length,o.length,ge(n.counts)),p=te(n.swaps),f=l(t.width)/100*s,g=(s-f)/2,b=Math.max(i*.1,i-2*g),h=l(t.gap),y=(f-h*(u-1))/Math.max(1,u),v=(b-h*(m-1))/Math.max(1,m),E=l(t.hold),M=Math.max(.01,l(t.swap_time)),k=l(t.stagger),R=E+M,z=s/1080,L=r.ease(r.tokens.ease_enter),j=r.ease(r.tokens.ease_move),x=r.tokens.duration.slow,N=o.map(K=>({x:K.col*(y+h),y:K.row*(v+h),w:K.cols*y+(K.cols-1)*h,h:K.rows*v+(K.rows-1)*h})),S=k>0?Bt(N,[f/2,b/2],k):N.map(()=>0),$=k>0?Math.max(0,o.length-1)*k+x:0,X=c.map((K,_)=>K.length>1?_:-1).filter(K=>K>=0),C=vn(X.length,$,E,l(t.offset)),q=`var(--m-card-radius, ${Math.max(4,Math.round(h*.75))}px)`,P=a.createElement("div");P.style.cssText=`position:relative;width:${f}px;height:${b}px`;let Y=o.map((K,_)=>{let ee=N[_],A=a.createElement("div");A.style.cssText=`position:absolute;left:${ee.x}px;top:${ee.y}px;width:${ee.w}px;height:${ee.h}px;overflow:hidden;border-radius:${q};background:var(--m-bg-sunken);perspective:${(2.5*Math.max(ee.w,ee.h)).toFixed(0)}px;isolation:isolate`;let O=X.indexOf(_),B=rt.includes(p[_]??"")?p[_]:F(t.swap)==="mixed"||!rt.includes(F(t.swap))?wn[Math.max(0,O)%wn.length]:F(t.swap),W=c[_].map(H=>{let U=a.createElement("div");U.style.cssText=`position:absolute;inset:0;overflow:hidden;border-radius:inherit;background:var(--m-bg-surface);display:grid;place-items:center;visibility:hidden;backface-visibility:hidden;font-size:${(28*z).toFixed(2)}px`;let G=xt(U,d[H]??"");return A.appendChild(U),{face:U,img:G}});return P.appendChild(A),{tile:A,faces:W,move:B,start:O>=0?C[O]:1/0,top:ee.y}});return e.appendChild(P),{seek(K){Y.forEach((_,ee)=>{let A=k>0?ae(K,S[ee],x,L):1;_.tile.style.opacity=A<1?A.toFixed(4):"",_.tile.style.top=`${(_.top+(1-A)*24*z).toFixed(2)}px`;let O=Va(K,_.start,_.faces.length,E,M);_.faces.forEach(({face:B,img:W},H)=>{let U=H===O.from||H===O.to;if(B.style.visibility=U?"inherit":"hidden",B.style.transform="",B.style.opacity="",B.style.zIndex="",W){let G=H===O.to?O.age:O.age+R;W.style.transform=U?`scale(${(1+Ja*(1-Z(G/(R+M)))).toFixed(4)})`:""}}),O.from!==O.to&&Ka(_.move,_.faces[O.from].face,_.faces[O.to].face,j(O.k))})}}}};var Qa=["4:5","1:1","9:16","3:4","16:9"],Tn=e=>{let[n,t]=F(e,"4:5").split(":").map(Number);return n>0&&t>0?n/t:.8},En=.14;function Mn(e,n,t){let r=Tn(e.ratio),a=F(e.chrome)!=="none"?2*En:0,s=Math.min(l(e.width)/100*n,.92*t/(1/r+a));return{w:s,h:s/r}}var _a=.05;function ei(e,n,t,r,a,s=i=>i){if(n<2||e<t)return 0;let i=t+r,o=a?n:n-1,u=Math.min(o-1,Math.floor((e-t)/i));return u+s(Z((e-t-u*i)/r))}function Fn(e,n,t,r){let a=e-n;return!r||t<3?a:((a+t/2)%t+t)%t-t/2}var $n={slug:"scene/post-carousel",summary:"Slides shown one at a time as a post or posters, turning past in depth.",props:{slides:{type:"string[]",required:!0,label:"The slides, in order: markup or a picture path each"},handle:{type:"string",default:"yourbrand",label:"Account name in the post header"},avatar:{type:"string",default:"",label:"Picture for the avatar. Left out: the handle\u2019s first letter on the accent"}},params:{width:{type:"number",default:54,min:20,max:100,step:1,unit:"% of stage width",label:"Width of a slide (made smaller if the post would not fit the stage height)"},ratio:{type:"choice",default:"4:5",options:Qa,label:"Shape of a slide, width : height"},chrome:{type:"choice",default:"post",options:["post","none"],label:"post: a header and footer frame the slides; none: bare posters"},hold:{type:"number",default:1.4,min:.4,max:6,step:.05,unit:"s",label:"How long each slide rests in front"},turn:{type:"number",default:.8,min:.3,max:2,step:.05,unit:"s",label:"Length of one turn to the next slide"},angle:{type:"number",default:72,min:0,max:85,step:1,unit:"deg",label:"How far the neighbours are turned away; 0 lays them flat beside the frame"},loop:{type:"boolean",default:!1,label:"Turn on from the last slide back to the first, so the film can loop"}},duration(e,n){let t=te(e.slides).length,r=l(n.hold),a=r+l(n.turn);return t<2?r:n.loop===!0?t*a:r+(t-1)*a},cues(e,n,t){let r=te(e.slides).length,a=l(n.hold),s=l(n.turn),i=r<2?0:n.loop===!0?r:r-1,[o,u]=t.size,{w:m,h:d}=Mn(n,o,u),c=+Math.min(1,1.5*m*d/(o*u)).toFixed(4);return Array.from({length:i},(p,f)=>({at:a+f*(a+s),length:s,share:c}))},check(e,n){let t=[],r=te(e.slides).length;return r<1&&t.push({path:"props.slides",message:"There are no slides.",hint:"Give at least two: one alone has nothing to turn to."}),n.loop===!0&&r>0&&r<3&&t.push({path:"params.loop",message:`A loop of ${r} slide${r===1?"":"s"} has no slide waiting on each side.`,hint:"Give three slides or more, or set loop to false."}),t},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=te(n.slides),u=o.length,m=F(t.chrome)!=="none",d=Tn(t.ratio),c=t.loop===!0,{w:p,h:f}=Mn(t,s,i),g=m?En*p:0,b=.035*p,h=.035*p,y=p/1e3,v=l(t.hold),E=Math.max(.01,l(t.turn)),M=v+E,k=l(t.angle),R=r.ease(r.tokens.ease_move),z=a.createElement("div");z.style.cssText=`position:relative;width:${p}px;height:${f+2*g}px;text-align:left`;let L=a.createElement("div");L.style.cssText=`position:absolute;left:0;top:${g}px;width:${p}px;height:${f}px;perspective:${(2.5*p).toFixed(0)}px;transform-style:preserve-3d`;let j=o.map($=>{let X=a.createElement("div");X.style.cssText=`position:absolute;inset:0;overflow:hidden;background:var(--m-bg-surface);border-radius:${m?"0":`var(--m-card-radius, ${h}px)`};backface-visibility:hidden;font-size:${(64*y).toFixed(2)}px;box-shadow:var(--m-card-shadow, 0 ${24*y}px ${60*y}px rgba(0,0,0,.28))`;let C=a.createElement("div");return C.style.cssText="position:absolute;inset:0;display:grid;place-items:center;transform-origin:50% 50%",xt(C,$),X.appendChild(C),L.appendChild(X),{card:X,inner:C}});z.appendChild(L);let x=[];if(m){let $="var(--m-font-body)",X=(G,Q)=>`position:absolute;left:0;top:${G}px;width:${p}px;height:${g}px;box-sizing:border-box;display:flex;align-items:center;gap:${22*y}px;padding:0 ${36*y}px;background:var(--m-bg-surface);color:var(--m-text-primary);border-radius:${Q};font:600 ${34*y}px/1 ${$}`,C=a.createElement("div");C.style.cssText=X(0,`${h}px ${h}px 0 0`)+";box-shadow:inset 0 -1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let q=a.createElement("div"),P=64*y;q.style.cssText=`flex:none;width:${P}px;height:${P}px;border-radius:50%;overflow:hidden;position:relative;display:grid;place-items:center;background:var(--m-accent);color:var(--m-text-on-accent);font:700 ${30*y}px/1 ${$}`;let Y=F(n.avatar);Y?xt(q,Y):q.textContent=(F(n.handle,"y").trim()[0]??"y").toUpperCase();let K=a.createElement("span");K.textContent=F(n.handle,"yourbrand"),K.style.cssText="flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis";let _=a.createElement("span");_.textContent="\u2022\u2022\u2022",_.style.cssText=`letter-spacing:${2*y}px;font-size:${22*y}px;color:var(--m-text-muted)`,C.append(q,K,_);let ee=a.createElement("div");ee.style.cssText=X(g+f,`0 0 ${h}px ${h}px`)+";box-shadow:inset 0 1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let A=(G,Q="none")=>{let ie=a.createElementNS("http://www.w3.org/2000/svg","svg");return ie.setAttribute("viewBox","0 0 24 24"),ie.setAttribute("width",String(50*y)),ie.setAttribute("height",String(50*y)),ie.style.cssText="flex:none;display:block",ie.innerHTML=`<path d="${G}" fill="${Q}" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/>`,ie},O=A("M12 20.5s-7.5-4.6-7.5-10.2A4.3 4.3 0 0 1 12 7.6a4.3 4.3 0 0 1 7.5 2.7c0 5.6-7.5 10.2-7.5 10.2Z","currentColor");O.style.color="var(--m-accent)";let B=A("M20 11.5a8 8 0 0 1-11.6 7.1L4 20l1.4-4.2A8 8 0 1 1 20 11.5Z"),W=A("M21 3 10 13.5M21 3l-6.5 18-4.5-7.5L3 9.5 21 3Z"),H=a.createElement("div");H.style.cssText=`flex:1;display:flex;justify-content:center;gap:${10*y}px`;for(let G=0;G<Math.min(u,12);G++){let Q=a.createElement("i");Q.style.cssText=`display:block;width:${11*y}px;height:${11*y}px;border-radius:50%;background:var(--m-text-primary)`,H.appendChild(Q),x.push(Q)}let U=A("M6 3.5h12v17l-6-4.5-6 4.5v-17Z");ee.append(O,B,W,H,U),z.append(C,ee)}e.appendChild(z);let N=$=>$===0?-E:v+($-1)*M,S=u*M;return{seek($){let X=ei($,u,v,E,c,R);j.forEach(({card:C,inner:q},P)=>{let Y=Fn(P,X,u,c),K=Z(Y,-1,1),_=Math.max(0,Math.abs(Y)-1);C.style.transformOrigin=Y>=0?"0% 50%":"100% 50%",C.style.transform=`translateX(${(K*(p+b)).toFixed(2)}px) translateZ(${(-(Math.abs(K)*.06+_*1.5)*p).toFixed(2)}px) rotateY(${(k*K).toFixed(3)}deg)`,C.style.opacity=_>0?Z((.6-_)/.6).toFixed(4):"",C.style.visibility=_<1?"inherit":"hidden",C.style.zIndex=String(10-Math.round(Math.abs(Y)*2));let ee=c?(($-N(P))%S+S)%S:$-N(P);q.style.transform=`scale(${(1+_a*(1-Z(ee/(M+E)))).toFixed(4)})`}),x.forEach((C,q)=>{let P=Math.max(0,1-Math.abs(Fn(q,X,u,c)));C.style.opacity=ve(.22,1,P).toFixed(3)})}}}};var Sn={slug:"texture/halftone-field",summary:"Squares or dots sized by a gradient.",props:{edge:{type:"string",default:"top",label:"Edge the field grows from: top or bottom"}},params:{cell:{type:"number",default:12,min:8,max:20,step:1,unit:"px",label:"Cell size"},grow:{type:"number",default:1.6,min:0,max:4,step:.1,unit:"s",label:"Time to grow in"},reach:{type:"number",default:.6,min:.2,max:1,step:.02,unit:"ratio",label:"How far into the frame it reaches"},strength:{type:"number",default:1,min:0,max:1,step:.05,unit:"ratio",label:"Opacity"}},duration:(e,n)=>l(n.grow),build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=l(t.cell)*(r.size[0]/1080)*1.6,i=l(t.grow),o=l(t.reach);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let u=document.createElement("div");return u.style.cssText=`position:absolute;inset:0;opacity:${l(t.strength)};background-image:radial-gradient(circle, var(--m-accent) ${s*.13}px, transparent ${s*.15}px),radial-gradient(circle, var(--m-text-muted) ${s*.08}px, transparent ${s*.1}px);background-size:${s}px ${s}px;background-position:0 0, ${s/2}px ${s/2}px${F(n.edge)==="bottom"?";transform:scaleY(-1)":""}`,e.appendChild(u),{seek(m){let c=`radial-gradient(ellipse 62% 52% at 50% -6%, #000 0%, transparent ${ae(m,0,i,a)*o*100}%)`;u.style.maskImage=c,u.style.setProperty("-webkit-mask-image",c)}}}};var An={slug:"transition/beat-cut",summary:"A plain cut placed on a music beat.",duration:0,params:{duration:{type:"number",default:0,min:0,max:0,step:0,unit:"s",label:"Always zero: a cut"}},apply(){},clear(){}};var Cn={slug:"transition/blur-dissolve",summary:"One scene blurs out while the next blurs in.",duration:.4,calm:{blur:12},params:{duration:{type:"number",default:.4,min:.3,max:.6,step:.05,unit:"s",label:"Length of the hand-over"},blur:{type:"number",default:20,min:12,max:30,step:1,unit:"px",label:"Blur at the midpoint"},overlap:{type:"number",default:.5,min:.3,max:.7,step:.05,unit:"ratio",label:"Share of the time both scenes are visible"}},apply(e,n,t,r,a){let s=a.ease(a.tokens.ease_move),i=.5+l(r.overlap)/2,o=s(Z(t/i)),u=s(Z((t-(1-i))/i)),m=l(r.blur);e.style.opacity=String(1-o),e.style.filter=o>0?`blur(${o*m}px)`:"",n.style.opacity=String(u),n.style.filter=u<1?`blur(${(1-u)*m}px)`:""},clear(e){e.style.opacity="",e.style.filter=""}};var Pn={slug:"transition/step-wipe",summary:"Stepped bars sweep across the frame.",duration:.5,params:{duration:{type:"number",default:.5,min:.4,max:.7,step:.05,unit:"s",label:"Length of the hand-over"},steps:{type:"number",default:6,min:4,max:10,step:1,unit:"bars",label:"Number of bars"}},apply(e,n,t,r,a){let s=a.ease(a.tokens.ease_move),i=Math.max(1,Math.round(l(r.steps))),[o,u]=a.size,m=.5/i,d=[];for(let c=0;c<i;c++){let p=s(Z((t-c*m)/(1-(i-1)*m)))*o,f=c*u/i,g=(c+1)*u/i+(c<i-1?1:0);d.push(`M0 ${f}H${p}V${g}H0Z`)}n.style.clipPath=`path('${d.join("")}')`},clear(e){e.style.clipPath=""}};var Rn="ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&/+",ti=1/20,zn={slug:"type/scramble",summary:"Characters cycle randomly before settling.",props:{text:{type:"string",required:!0,label:"The text to settle on"}},params:{duration:{type:"number",default:.8,min:.6,max:1,step:.05,unit:"s",label:"Time to settle"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let a=[...F(n.text)],s=l(t.duration);return e.style.whiteSpace="pre",e.style.fontVariantNumeric="tabular-nums",{seek(i){let o=s<=0?a.length:Math.floor(Math.max(0,i)/s*a.length+1e-6),u=Math.floor(Math.max(0,i)/ti);e.textContent=a.map((m,d)=>{if(d<o||m===" ")return m;let c=$e(r.seed*7919+u*131+d);return Rn[Math.floor(c()*Rn.length)]??m}).join("")}}}};var On={slug:"type/typed-title",summary:"Characters appear one by one with a caret.",props:{text:{type:"string",required:!0,label:"The text to type"}},params:{chars_per_s:{type:"number",default:20,min:12,max:30,step:1,unit:"chars/s",label:"Typing speed"}},duration:(e,n)=>[...F(e.text)].length/Math.max(1,l(n.chars_per_s)),build(e,n,t){let r=[...F(n.text)],a=Math.max(1,l(t.chars_per_s)),s=document.createElement("span"),i=document.createElement("span"),o=document.createElement("span");return i.style.visibility="hidden",o.style.cssText="display:inline-block;width:0.06em;height:1em;margin:0 -0.03em;vertical-align:-0.12em;background:var(--m-accent)",e.style.whiteSpace="pre-wrap",e.append(s,o,i),{seek(u){let m=Math.min(r.length,Math.floor(u*a+1e-6));s.textContent=r.slice(0,m).join(""),i.textContent=r.slice(m).join("");let d=u-r.length/a;o.style.opacity=d>0&&d%1>=.5?"0":"1"}}}};var Dn=e=>F(e.text).split(/\s+/).filter(Boolean),Ln={slug:"type/word-build",summary:"Words rise and fade in one by one.",props:{text:{type:"string",required:!0,label:"The line to build"},accent:{type:"string[]",default:[],label:"Words set in the accent colour"}},params:{rise:{type:"number",default:16,min:12,max:20,step:1,unit:"px",label:"Rise"},stagger:{type:"number",default:.1,min:.08,max:.12,step:.005,unit:"s",label:"Delay between words"},word_duration:{type:"number",default:.5,min:.3,max:.6,step:.01,unit:"s",label:"Time per word"}},duration:(e,n)=>Math.max(0,Dn(e).length-1)*l(n.stagger)+l(n.word_duration),build(e,n,t,r){let a=r.ease(r.tokens.ease_enter),s=new Set(te(n.accent).map(d=>d.toLowerCase()));e.style.cssText+=";display:flex;flex-wrap:wrap;justify-content:center;gap:0 0.26em";let i=Dn(n).map(d=>{let c=document.createElement("span");return c.textContent=d,c.style.cssText="display:inline-block;will-change:transform,opacity",s.has(d.toLowerCase().replace(/[^\p{L}\p{N}]/gu,""))&&(c.style.color="var(--m-accent)"),e.appendChild(c),c}),o=l(t.stagger),u=l(t.word_duration),m=l(t.rise);return{seek(d){i.forEach((c,p)=>{let f=ae(d,p*o,u,a);c.style.opacity=String(Math.min(1,f*1.6)),c.style.transform=`translateY(${(1-f)*m}px)`})}}}};var yt=(e,n)=>{let t=Math.max(2,Math.round(l(e.cols)));return[t,Math.max(2,Math.round(t*n[1]/n[0]))]},In={slug:"fx/grid-ripple",summary:"A field of dots or tiles appears in a wave from one point, then keeps breathing.",props:{cell:{type:"string",default:"dot",label:"dot, square or plus"}},params:{cols:{type:"number",default:24,min:8,max:48,step:1,unit:"columns",label:"Columns (rows follow the frame)"},stagger:{type:"number",default:.05,min:.02,max:.1,step:.005,unit:"s",label:"Delay per cell of distance"},from:{type:"choice",default:"center",options:qe,label:"Where the wave starts"},size:{type:"number",default:.22,min:.05,max:.9,step:.01,unit:"ratio of cell",label:"Mark size"},pulse:{type:"number",default:.35,min:0,max:1,step:.05,unit:"ratio",label:"How much the field keeps breathing afterwards"},opacity:{type:"number",default:.5,min:.1,max:1,step:.05,unit:"ratio",label:"Opacity"}},duration:(e,n,t)=>ze(yt(n,t.size)[0]*yt(n,t.size)[1],F(n.from),t.seed,yt(n,t.size))*l(n.stagger)+.6,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,[o,u]=yt(t,r.size),m=s/o,d=i/u,c=o*u,p=F(n.cell,"dot"),f=l(t.size)*Math.min(m,d),g=Me(c,l(t.stagger),F(t.from),r.seed,[o,u]),b=Math.max(...g,.001);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let h=a.createElement("div");h.style.cssText=`position:absolute;inset:0;opacity:${l(t.opacity)}`,e.appendChild(h);let y=Array.from({length:c},(k,R)=>{let z=a.createElement("div"),L=R%o*m+m/2,j=Math.floor(R/o)*d+d/2,x=p==="square"?`border-radius:${f*.12}px;background:currentColor`:p==="plus"?"background:linear-gradient(currentColor,currentColor) center/100% 18% no-repeat,linear-gradient(currentColor,currentColor) center/18% 100% no-repeat":"border-radius:50%;background:currentColor";return z.style.cssText=`position:absolute;left:${L-f/2}px;top:${j-f/2}px;width:${f}px;height:${f}px;${x}`,h.appendChild(z),z}),v=r.ease({spring:{duration:.45,bounce:.25}}),E=l(t.pulse),M=Math.max(1.2,b*1.6);return{seek(k){y.forEach((R,z)=>{let L=ae(k,g[z],.6,v),j=k>g[z]+.6?Math.sin((k-g[z])/M*Math.PI*2)*.5*E:0,x=Math.max(0,L*(1+j*.6));R.style.transform=`scale(${x.toFixed(4)})`,R.style.opacity=Math.min(1,Math.max(0,(k-g[z])/.2)*(1-E*.3+j*.6)).toFixed(3)})}}}};function Bn(e,n,t){let r=Math.abs(e).toFixed(n),[a,s]=r.split("."),i=t?a.replace(/\B(?=(\d{3})+(?!\d))/g,","):a;return[...e<0?"-":"",...i,...s?[".",...s]:[]]}var Wn={slug:"fx/odometer",summary:"Each digit rolls in its own column and lands on the value.",props:{value:{type:"number",required:!0,label:"The number to land on"},decimals:{type:"number",default:0,label:"Decimal places"},prefix:{type:"string",default:"",label:"Text before the number"},suffix:{type:"string",default:"",label:"Text after the number"}},params:{duration:{type:"number",default:1.6,min:.8,max:3,step:.05,unit:"s",label:"Time for the last column to land"},stagger:{type:"number",default:.08,min:0,max:.2,step:.01,unit:"s",label:"Delay between columns, right to left"},spins:{type:"number",default:1,min:0,max:3,step:1,unit:"turns",label:"Extra turns per column to its right"},group:{type:"boolean",default:!0,label:"Thousands separators"}},duration:(e,n)=>{let t=Bn(l(e.value),Math.max(0,Math.round(l(e.decimals))),n.group!==!1).filter(r=>/\d/.test(r)).length;return Math.max(0,t-1)*l(n.stagger)+l(n.duration)},build(e,n,t,r){let a=e.ownerDocument,s=Bn(l(n.value),Math.max(0,Math.round(l(n.decimals))),t.group!==!1),i=l(t.duration),o=l(t.stagger),u=Math.round(l(t.spins)),m=r.ease("expressive.out");e.style.cssText+=";display:inline-flex;align-items:baseline;font-variant-numeric:tabular-nums;white-space:pre";let d=g=>{if(!g)return;let b=a.createElement("span");b.textContent=g,e.appendChild(b)};d(F(n.prefix));let p=s.filter(g=>/\d/.test(g)).length,f=[];for(let g of s){if(!/\d/.test(g)){d(g);continue}p--;let h=Number(g)+10*u*p,y=a.createElement("span");y.style.cssText="display:inline-block;overflow:hidden;height:1.1em;line-height:1.1em;vertical-align:bottom;padding:0 0.01em";let v=a.createElement("span");v.style.cssText="display:flex;flex-direction:column;will-change:transform";for(let E=0;E<=h;E++){let M=a.createElement("span");M.textContent=String(E%10),M.style.cssText="display:block;height:1.1em;text-align:center",v.appendChild(M)}y.appendChild(v),e.appendChild(y),f.push({strip:v,travel:h,delay:p*o})}return d(F(n.suffix)),{seek(g){for(let b of f){let h=ae(g,b.delay,i,m),y=b.travel*h;b.strip.style.transform=`translateY(${(-y*1.1).toFixed(4)}em)`;let v=b.travel*(ae(g+1/60,b.delay,i,m)-h)*60,E=Z(Math.abs(v)*.012,0,.06);b.strip.style.filter=E>.004?`blur(${E.toFixed(3)}em)`:""}}}}};var Nn="http://www.w3.org/2000/svg",Hn={slug:"fx/path-draw",summary:"Lines draw themselves along their paths, then the shapes fill.",props:{paths:{type:"string[]",required:!0,label:"SVG path data, one path per item, drawn in order"},viewbox:{type:"string",default:"0 0 100 100",label:"SVG viewBox the paths are drawn in"},fill:{type:"string",default:"none",label:"Fill once drawn: none, accent, primary or a CSS colour"}},params:{draw:{type:"number",default:1,min:.4,max:2.5,step:.05,unit:"s",label:"Time to draw one path"},stagger:{type:"number",default:.12,min:0,max:.5,step:.01,unit:"s",label:"Delay between paths"},width:{type:"number",default:30,min:4,max:100,step:1,unit:"% of stage width",label:"Drawing width"},stroke:{type:"number",default:2,min:.5,max:12,step:.25,unit:"px",label:"Stroke weight"},fill_time:{type:"number",default:.4,min:.1,max:1,step:.05,unit:"s",label:"Time for the fill to arrive"},ease:{type:"ease",default:"quart.inOut",label:"Curve of each stroke; a camera that follows the tip moves with it"}},duration:(e,n)=>{let t=te(e.paths).length,r=F(e.fill,"none")!=="none";return Math.max(0,t-1)*l(n.stagger)+l(n.draw)+(r?l(n.fill_time)*.8:0)},build(e,n,t,r){let a=e.ownerDocument,s=F(n.fill,"none"),i=s==="accent"?"var(--m-bg-accent)":s==="primary"?"var(--m-text-primary)":s,o=F(n.viewbox,"0 0 100 100").split(/[\s,]+/).map(Number),u=o[2]||100,m=o[3]||100,d=l(t.width)/100*r.size[0],c=a.createElementNS(Nn,"svg");c.setAttribute("viewBox",F(n.viewbox,"0 0 100 100")),c.setAttribute("width",String(d)),c.setAttribute("height",String(d*m/u)),c.style.cssText="display:block;overflow:visible";let p=l(t.stroke)*(u/d),f=te(n.paths).map(z=>{let L=a.createElementNS(Nn,"path");return L.setAttribute("d",z),L.setAttribute("pathLength","1"),L.setAttribute("stroke-dasharray","1 1"),L.setAttribute("stroke","currentColor"),L.setAttribute("stroke-width",String(p)),L.setAttribute("stroke-linecap","round"),L.setAttribute("stroke-linejoin","round"),L.setAttribute("fill",s==="none"?"none":i),c.appendChild(L),L});e.appendChild(c);let g=Me(f.length,l(t.stagger)),b=l(t.draw),h=l(t.fill_time),y=r.ease(t.ease??"quart.inOut"),v=r.ease("cubic.out"),E=d/u,M=256,k=f.map(z=>{let L=0;try{L=z.getTotalLength()}catch{return[]}return Array.from({length:M+1},(j,x)=>{let N=z.getPointAtLength(L*x/M);return[(N.x-(o[0]??0))*E,(N.y-(o[1]??0))*E]})}),R=(z,L)=>{let j=k[z];if(!j?.length)return;let x=Math.min(1,Math.max(0,L))*M,N=Math.floor(x),S=Math.min(M,N+1),$=x-N,[X,C]=j[N],[q,P]=j[S];return[X+(q-X)*$,C+(P-C)*$]};return{tip(z){let L=0;for(let j=0;j<f.length;j++)z>=g[j]&&(L=j);return R(L,ae(z,g[L],b,y))},seek(z){f.forEach((L,j)=>{let x=ae(z,g[j],b,y);if(L.setAttribute("stroke-dashoffset",(1-x).toFixed(4)),L.style.visibility=z<g[j]?"hidden":"inherit",s!=="none"){let N=ae(z,g[j]+b*.8,h,v);L.setAttribute("fill-opacity",N.toFixed(3)),L.setAttribute("stroke-opacity",(1-N).toFixed(3))}})}}}};var qn=["circle","square","squircle","triangle","diamond","hexagon","star","pill","plus","blob"],jn=e=>e,wt=(e,n=1,t=0)=>Array.from({length:e},(r,a)=>{let s=-Math.PI/2+t+a/e*Math.PI*2;return[Math.cos(s)*n,Math.sin(s)*n]});function ni(e,n){let t=e.map((u,m)=>[u,e[(m+1)%e.length]]),r=t.map(([u,m])=>Math.hypot(m[0]-u[0],m[1]-u[1])),a=r.reduce((u,m)=>u+m,0),s=[],i=0,o=0;for(let u=0;u<n;u++){let m=u/n*a;for(;i<t.length-1&&o+r[i]<m;)o+=r[i],i++;let[d,c]=t[i],p=r[i]>0?(m-o)/r[i]:0;s.push([d[0]+(c[0]-d[0])*p,d[1]+(c[1]-d[1])*p])}return s}function ri(e){let n=0,t=1/0;return e.forEach(([r,a],s)=>{let i=Math.abs(Math.atan2(r,-a));i<t&&(t=i,n=s)}),[...e.slice(n),...e.slice(0,n)]}function ai(e,n){let t=(r,a=360)=>Array.from({length:a},(s,i)=>{let o=-Math.PI/2+i/a*Math.PI*2,u=r(o);return[Math.cos(o)*u,Math.sin(o)*u]});switch(e){case"square":return jn([[0,-1],[1,-1],[1,1],[-1,1],[-1,-1]]);case"squircle":return t(r=>1/Math.pow(Math.pow(Math.abs(Math.cos(r)),5)+Math.pow(Math.abs(Math.sin(r)),5),1/5));case"triangle":return wt(3,1.12,0).map(([r,a])=>[r,a+.14]);case"diamond":return wt(4,1.1);case"hexagon":return wt(6,1.04);case"star":return wt(10,1).map(([r,a],s)=>s%2?[r*.46,a*.46]:[r*1.08,a*1.08]);case"pill":return t(r=>{let a=Math.cos(r),s=Math.sin(r),i=.5,o=.5,u=0,m=2;for(let d=0;d<30;d++){let c=(u+m)/2,p=a*c,f=s*c,g=Math.max(0,Math.abs(p)-o);Math.hypot(g,f)>i?m=c:u=c}return u*1.9});case"plus":return jn([[-.36,-1],[.36,-1],[.36,-.36],[1,-.36],[1,.36],[.36,.36],[.36,1],[-.36,1],[-.36,.36],[-1,.36],[-1,-.36],[-.36,-.36]]);case"blob":{let r=$e(n*53+11),a=[r(),r(),r(),r()].map(s=>s*Math.PI*2);return t(s=>.9+.08*Math.sin(2*s+a[0])+.06*Math.sin(3*s+a[1])+.04*Math.sin(5*s+a[2])+.02*Math.sin(7*s+a[3]))}default:return t(()=>1)}}function vt(e,n=120,t=1){return ri(ni(ai(e,t),n))}var Zn=(e,n,t)=>e.map(([r,a],s)=>[r+(n[s][0]-r)*t,a+(n[s][1]-a)*t]),kt=(e,n,t,r)=>`M${e.map(([a,s])=>`${(n+a*r).toFixed(2)},${(t+s*r).toFixed(2)}`).join("L")}Z`;var Xn="http://www.w3.org/2000/svg",ii={accent:"var(--m-bg-accent)",primary:"var(--m-text-primary)",surface:"var(--m-bg-surface)",inverse:"var(--m-bg-inverse)"},Yn={slug:"fx/shape-morph",summary:"One shape grows in, then turns into the next, and the next.",props:{shapes:{type:"string[]",default:["circle","squircle","star"],label:`Shapes in order: ${qn.join(", ")}`},fill:{type:"string",default:"accent",label:"accent, primary, surface, inverse, outline or a CSS colour"}},params:{hold:{type:"number",default:.6,min:.2,max:2,step:.05,unit:"s",label:"Time each shape holds"},morph:{type:"number",default:.7,min:.4,max:1.2,step:.05,unit:"s",label:"Time to turn into the next"},size:{type:"number",default:22,min:6,max:60,step:.5,unit:"% of stage width",label:"Size"},turn:{type:"number",default:90,min:0,max:180,step:5,unit:"deg",label:"Rotation per morph"}},duration:(e,n)=>.6+(Math.max(1,te(e.shapes).length)-1)*(l(n.hold)+l(n.morph)),build(e,n,t,r){let a=e.ownerDocument,s=te(n.shapes).length?te(n.shapes):["circle"],i=s.map(v=>vt(v,160,r.seed)),o=r.size[0],u=l(t.size)/100*o,m=u/2,d=l(t.hold),c=l(t.morph),p=l(t.turn),f=F(n.fill,"accent"),g=a.createElementNS(Xn,"svg");g.setAttribute("width",String(u*1.3)),g.setAttribute("height",String(u*1.3)),g.setAttribute("viewBox",`${-u*.65} ${-u*.65} ${u*1.3} ${u*1.3}`),g.style.cssText="display:block;overflow:visible";let b=a.createElementNS(Xn,"path");f==="outline"?(b.setAttribute("fill","none"),b.setAttribute("stroke","currentColor"),b.setAttribute("stroke-width",String(Math.max(2,u*.02)))):b.setAttribute("fill",ii[f]??f),g.appendChild(b),e.appendChild(g);let h=r.ease({spring:{duration:.6,bounce:.3}}),y=r.ease("quint.inOut");return{seek(v){let E=ae(v,0,.6,h),M=Math.max(0,v-.6),k=d+c,R=Math.min(s.length-1,Math.floor(M/k)),z=0;R<s.length-1?z=ae(M-R*k,d,c,y):R=s.length-1;let L=Math.min(s.length-1,R+1),j=Zn(i[R],i[L],z);b.setAttribute("d",kt(j,0,0,m*Math.max(0,E))),b.setAttribute("transform",`rotate(${((R+z)*p).toFixed(3)})`)}}}};var si=(e,n)=>e.toFixed(n),Un={slug:"scene/bar-chart",summary:"Bars grow from the baseline one after another, each value counting up with it.",props:{values:{type:"number[]",required:!0,label:"Bar values"},labels:{type:"string[]",default:[],label:"Bar labels, in the same order"},highlight:{type:"string",default:"",label:"Label of the one bar set in the accent"},suffix:{type:"string",default:"",label:"Text after each value, e.g. %"},decimals:{type:"number",default:0,label:"Decimal places"}},params:{grow:{type:"number",default:.9,min:.5,max:1.4,step:.05,unit:"s",label:"Time for one bar to grow"},stagger:{type:"number",default:.07,min:.03,max:.15,step:.005,unit:"s",label:"Delay between bars"},orientation:{type:"choice",default:"vertical",options:["vertical","horizontal"],label:"Bars stand or lie"},width:{type:"number",default:64,min:30,max:90,step:1,unit:"% of stage width",label:"Chart width"},height:{type:"number",default:46,min:20,max:75,step:1,unit:"% of stage height",label:"Chart height"}},duration:(e,n)=>.4+Math.max(0,ge(e.values).length-1)*l(n.stagger)+l(n.grow),build(e,n,t,r){let a=e.ownerDocument,s=ge(n.values),i=te(n.labels),o=F(n.highlight),u=Math.max(0,Math.round(l(n.decimals))),m=F(n.suffix),[d,c]=r.size,p=l(t.width)/100*d,f=l(t.height)/100*c,g=t.orientation==="horizontal",b=Math.max(...s.map(Math.abs),1e-9),h=s.length,y=.32;e.style.cssText+=`;position:relative;width:${p}px;height:${f}px;font-variant-numeric:tabular-nums`;let v=a.createElement("div");v.style.cssText=`position:absolute;background:var(--m-border);${g?"left:0;top:0;bottom:0;width:2px;transform-origin:50% 0":"left:0;right:0;bottom:0;height:2px;transform-origin:0 50%"}`,e.appendChild(v);let E=s.map((L,j)=>{let x=(g?f:p)/h,N=x*(1-y),S=j*x+x*y/2,$=o!==""&&i[j]===o,X=a.createElement("div"),C=o===""||$?"var(--m-bg-accent)":"color-mix(in srgb, var(--m-text-primary) 18%, var(--m-bg-base))";X.style.cssText=g?`position:absolute;left:2px;top:${S}px;height:${N}px;width:${Math.abs(L)/b*(p-160)}px;transform-origin:0 50%;border-radius:0 ${N*.12}px ${N*.12}px 0;background:${C}`:`position:absolute;bottom:2px;left:${S}px;width:${N}px;height:${Math.abs(L)/b*(f-70)}px;transform-origin:50% 100%;border-radius:${N*.1}px ${N*.1}px 0 0;background:${C}`;let q=a.createElement("div");q.style.cssText=g?`position:absolute;top:${S+N/2}px;transform:translateY(-50%);font-size:0.62em;font-weight:600;white-space:nowrap`:`position:absolute;left:${S+N/2}px;width:${x}px;margin-left:${-x/2}px;text-align:center;font-size:0.62em;font-weight:600;white-space:nowrap`,$&&(q.style.color="var(--m-accent)");let P=a.createElement("div");P.textContent=i[j]??"",P.style.cssText=g?`position:absolute;right:calc(100% + 0.8em);top:${S+N/2}px;transform:translateY(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`:`position:absolute;top:calc(100% + 0.7em);left:${S}px;width:${N}px;text-align:center;font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.append(X,q,P);let Y=parseFloat(g?X.style.width:X.style.height);return{bar:X,value:q,label:P,v:L,full:Y}}),M=Me(h,l(t.stagger)),k=l(t.grow),R=r.ease("quint.out"),z=r.ease("quart.inOut");return{seek(L){let j=ae(L,0,.5,z);v.style.transform=g?`scaleY(${j})`:`scaleX(${j})`,E.forEach((x,N)=>{let S=ae(L,.4+M[N],k,R);x.bar.style.transform=g?`scaleX(${S})`:`scaleY(${S})`;let $=L>=.4+M[N]+k?x.v:x.v*S;x.value.textContent=`${si($,u)}${m}`;let X=Math.min(1,Math.max(0,(L-.4-M[N])/.25));x.value.style.opacity=X.toFixed(3),g?x.value.style.left=`${2+x.full*S+12}px`:x.value.style.bottom=`${2+x.full*S+10}px`,x.label.style.opacity=Math.min(1,Math.max(0,(L-M[N]*.5)/.4)).toFixed(3)})}}}};var Xe="http://www.w3.org/2000/svg",Vn={slug:"scene/line-chart",summary:"A line draws left to right behind a leading dot, the area fills, the last value lands.",props:{values:{type:"number[]",required:!0,label:"Values, left to right"},labels:{type:"string[]",default:[],label:"Labels under the first and last points (two items), or one per point"},suffix:{type:"string",default:"",label:"Text after the end value"},decimals:{type:"number",default:0,label:"Decimal places of the end value"}},params:{draw:{type:"number",default:2,min:1.2,max:3.5,step:.1,unit:"s",label:"Time to draw the line"},width:{type:"number",default:70,min:30,max:90,step:1,unit:"% of stage width",label:"Chart width"},height:{type:"number",default:44,min:20,max:75,step:1,unit:"% of stage height",label:"Chart height"},area:{type:"boolean",default:!0,label:"Fill under the line"},grid:{type:"number",default:4,min:0,max:8,step:1,unit:"lines",label:"Guide lines"}},duration:(e,n)=>.4+l(n.draw)+.6,build(e,n,t,r){let a=e.ownerDocument,s=ge(n.values),i=te(n.labels),[o,u]=r.size,m=l(t.width)/100*o,d=l(t.height)/100*u,c=Math.min(...s,0),p=Math.max(...s,1e-9),f=d*.08,g=s.map((C,q)=>[s.length>1?q/(s.length-1)*m:m/2,f+(1-(C-c)/(p-c||1))*(d-f*2)]);e.style.cssText+=`;position:relative;width:${m}px;height:${d}px`;let b=a.createElementNS(Xe,"svg");b.setAttribute("width",String(m)),b.setAttribute("height",String(d)),b.style.cssText="position:absolute;inset:0;overflow:visible";let h=Math.round(l(t.grid)),y=Array.from({length:h},(C,q)=>{let P=a.createElementNS(Xe,"line"),Y=d*(q+1)/(h+1);return P.setAttribute("x1","0"),P.setAttribute("x2",String(m)),P.setAttribute("y1",String(Y)),P.setAttribute("y2",String(Y)),P.setAttribute("stroke","var(--m-border)"),P.setAttribute("stroke-width","1.5"),P.setAttribute("stroke-dasharray","4 8"),b.appendChild(P),P}),v=g.map(([C,q],P)=>`${P?"L":"M"}${C.toFixed(2)},${q.toFixed(2)}`).join(""),E=a.createElementNS(Xe,"path");E.setAttribute("d",`${v}L${m},${d}L0,${d}Z`),E.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 16%, transparent)");let M=a.createElementNS(Xe,"path");M.setAttribute("d",v),M.setAttribute("fill","none"),M.setAttribute("stroke","var(--m-bg-accent)"),M.setAttribute("stroke-width",String(Math.max(3,o*.0028))),M.setAttribute("stroke-linejoin","round"),M.setAttribute("stroke-linecap","round");let k=a.createElementNS(Xe,"circle");k.setAttribute("r",String(o*.0055)),k.setAttribute("fill","var(--m-bg-accent)");let R=a.createElementNS(Xe,"circle");R.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 25%, transparent)"),t.area!==!1&&b.appendChild(E),b.append(M,R,k),e.appendChild(b);let z=a.createElement("div"),L=g[g.length-1]??[0,0];z.textContent=`${(s[s.length-1]??0).toFixed(Math.max(0,Math.round(l(n.decimals))))}${F(n.suffix)}`,z.style.cssText=`position:absolute;left:${L[0]}px;top:${L[1]}px;transform:translate(-50%, -150%);font-weight:650;color:var(--m-accent);white-space:nowrap;font-variant-numeric:tabular-nums`,e.appendChild(z);let j=i.map((C,q)=>{let P=a.createElement("div"),Y=i.length===2&&s.length>2?q===0?0:m:g[q]?.[0]??0;return P.textContent=C,P.style.cssText=`position:absolute;top:calc(100% + 0.6em);left:${Y}px;transform:translateX(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.appendChild(P),{l:P,x:Y}}),x=g.map(C=>C[0]),N=C=>{if(g.length<2)return g[0]??[0,0];let q=1;for(;q<g.length-1&&x[q]<C;)q++;let P=g[q-1],Y=g[q],K=Y[0]===P[0]?1:Math.min(1,Math.max(0,(C-P[0])/(Y[0]-P[0])));return[P[0]+(Y[0]-P[0])*K,P[1]+(Y[1]-P[1])*K]},S=l(t.draw),$=r.ease("sine.inOut"),X=r.ease("expressive.out");return{seek(C){y.forEach((B,W)=>B.setAttribute("opacity",ae(C,W*.05,.4,X).toFixed(3)));let q=ae(C,.4,S,$),P=q*m;M.style.clipPath=q>=1?"":`inset(-20px ${(m-P).toFixed(2)}px -20px -20px)`;let[Y,K]=N(P),_=C>=.4;k.setAttribute("cx",Y.toFixed(2)),k.setAttribute("cy",K.toFixed(2)),k.setAttribute("opacity",_?"1":"0");let ee=ae(C,.4+S,.6,X);R.setAttribute("cx",Y.toFixed(2)),R.setAttribute("cy",K.toFixed(2)),R.setAttribute("r",(o*.0055*(1+2.6*ee)).toFixed(2)),R.setAttribute("opacity",(ee>0?1-ee:0).toFixed(3));let A=ae(C,.4+S*.6,.6+S*.4,X);E.setAttribute("opacity",A.toFixed(3)),E.style.clipPath=`inset(0 ${(m-P).toFixed(2)}px 0 0)`;let O=ae(C,.4+S-.1,.5,X);z.style.opacity=O.toFixed(3),z.style.transform=`translate(-50%, ${(-150+(1-O)*40).toFixed(2)}%)`;for(let{l:B,x:W}of j)B.style.opacity=Math.min(1,Math.max(0,(P-W+m*.08)/(m*.08))).toFixed(3)}}}};var Gn="http://www.w3.org/2000/svg",Kn=(e,n,t)=>{let r=l(e.arrive),a=n?l(e.slide):0,s=r+.15,i=s+a*.7;return{arrive:r,slide:a,nameAt:s,tagAt:i,end:t?i+.7:s+a}},Jn={slug:"scene/logo-reveal",summary:"The mark lands, then moves aside as the name slides out from behind it.",props:{name:{type:"string",default:"",label:"Wordmark text. Left out, the mark lands alone"},tagline:{type:"string",default:"",label:"One short line under the lockup"},mark_path:{type:"string",default:"",label:"SVG path data of the mark. Left out, a shape is used"},mark_viewbox:{type:"string",default:"0 0 100 100",label:"viewBox of mark_path"},mark_shape:{type:"string",default:"squircle",label:"Shape used when there is no mark_path"}},params:{mode:{type:"choice",default:"pop",options:["pop","draw","iris"],label:"How the mark arrives"},arrive:{type:"number",default:.8,min:.5,max:1.6,step:.05,unit:"s",label:"Time for the mark to land"},slide:{type:"number",default:.8,min:.5,max:1.2,step:.05,unit:"s",label:"Time for the name to slide out"},mark_size:{type:"number",default:1.1,min:.6,max:2,step:.05,unit:"em",label:"Mark height, relative to the name"},gap:{type:"number",default:.35,min:.1,max:1,step:.05,unit:"em",label:"Gap between mark and name"}},duration:(e,n)=>Kn(n,!!F(e.name),!!F(e.tagline)).end,build(e,n,t,r){let a=e.ownerDocument,s=F(n.name),i=F(n.tagline),o=F(t.mode),u=Kn(t,!!s,!!i);e.style.cssText+=";display:flex;flex-direction:column;align-items:center";let m=a.createElement("div");m.style.cssText=`display:flex;align-items:center;gap:${l(t.gap)}em;white-space:nowrap`;let d=l(t.mark_size),c=a.createElementNS(Gn,"svg"),p=F(n.mark_path);c.setAttribute("viewBox",p?F(n.mark_viewbox,"0 0 100 100"):"-1 -1 2 2"),c.style.cssText=`display:block;height:${d}em;width:${d}em;overflow:visible;position:relative;z-index:1;flex:none`;let f=a.createElementNS(Gn,"path");f.setAttribute("d",p||kt(vt(F(n.mark_shape,"squircle"),160,r.seed),0,0,1)),f.setAttribute("fill","var(--m-bg-accent)"),f.setAttribute("pathLength","1"),f.setAttribute("stroke-dasharray","1 1"),f.setAttribute("stroke","var(--m-bg-accent)"),f.setAttribute("stroke-width",p?"2":"0.05"),f.setAttribute("vector-effect","non-scaling-stroke"),c.appendChild(f),m.appendChild(c);let g,b;s&&(b=a.createElement("span"),b.style.cssText="display:block;overflow:hidden;padding:0.12em 0.04em;margin:-0.12em -0.04em",g=a.createElement("span"),g.textContent=s,g.style.cssText="display:block",b.appendChild(g),m.appendChild(b)),e.appendChild(m);let h;i&&(h=a.createElement("div"),h.textContent=i,h.style.cssText="font-size:0.32em;font-weight:450;letter-spacing:0.01em;color:var(--m-text-muted);margin-top:0.9em",e.appendChild(h));let y=g?(m.offsetWidth-c.getBoundingClientRect().width/oi(e))/2:0,v=r.ease({spring:{duration:.55,bounce:.32}}),E=r.ease("quint.inOut"),M=r.ease("expressive.out");return{seek(k){let R=ae(k,0,u.arrive,o==="pop"?v:M);if(o==="pop")c.style.transform=`scale(${Math.max(0,R).toFixed(4)}) rotate(${((1-R)*-30).toFixed(3)}deg)`,f.setAttribute("stroke-dashoffset","0"),f.setAttribute("fill-opacity","1");else if(o==="draw"){let j=ae(k,0,u.arrive*.8,E),x=ae(k,u.arrive*.65,u.arrive*.35,M);f.setAttribute("stroke-dashoffset",(1-j).toFixed(4)),f.setAttribute("fill-opacity",x.toFixed(3)),c.style.transform=""}else c.style.clipPath=R>=1?"":`circle(${(R*75).toFixed(3)}% at 50% 50%)`,c.style.transform=`scale(${(1.25-.25*R).toFixed(4)})`,f.setAttribute("stroke-dashoffset","0");let z=ae(k,u.nameAt,u.slide,E),L=y*(1-z);if(m.style.transform=L===0?"":`translateX(${L.toFixed(2)}px)`,g&&b){let j=ae(k,u.nameAt,u.slide,M);g.style.transform=j>=1?"":`translateX(${(-(1-j)*105).toFixed(3)}%)`,b.style.visibility=k<u.nameAt?"hidden":"inherit"}if(h){let j=ae(k,u.tagAt,.7,M);h.style.opacity=j.toFixed(3),h.style.transform=j>=1?"":`translateY(${((1-j)*.6).toFixed(3)}em)`}}}}};function oi(e){let n=e.closest(".m-stage");return!n||!n.offsetWidth?1:n.getBoundingClientRect().width/n.offsetWidth}var li=["var(--m-bg-accent)","color-mix(in oklab, var(--m-bg-accent) 55%, var(--m-bg-base))","color-mix(in oklab, var(--m-bg-accent) 60%, #FFFFFF)","color-mix(in oklab, var(--m-bg-accent) 70%, #000000)"],Qn={slug:"texture/gradient-drift",summary:"Soft fields of colour drift and blend behind the content, looping without a seam.",props:{colors:{type:"string[]",default:[],label:"CSS colours of the fields. Left out, shades of the accent"}},params:{period:{type:"number",default:12,min:6,max:24,step:.5,unit:"s",label:"Time for one full loop"},fields:{type:"number",default:4,min:2,max:6,step:1,unit:"fields",label:"Colour fields"},softness:{type:"number",default:14,min:6,max:24,step:.5,unit:"% of stage width",label:"Blur"},reach:{type:"number",default:.18,min:.05,max:.35,step:.01,unit:"ratio",label:"How far the fields wander"},strength:{type:"number",default:.85,min:.2,max:1,step:.05,unit:"ratio",label:"Opacity"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=te(n.colors).length?te(n.colors):li,u=Math.max(1,Math.round(l(t.fields))),m=Math.max(1,l(t.period)),d=l(t.reach),c=$e(r.seed*389+3);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none;overflow:hidden";let p=a.createElement("div");p.style.cssText=`position:absolute;inset:-10%;filter:blur(${l(t.softness)/100*s}px) saturate(1.15);opacity:${l(t.strength)}`,e.appendChild(p);let f=Array.from({length:u},(g,b)=>{let h=a.createElement("div"),y=(.45+c()*.35)*s;return h.style.cssText=`position:absolute;left:0;top:0;width:${y}px;height:${y*(.7+c()*.4)}px;border-radius:50%;background:${o[b%o.length]}`,p.appendChild(h),{b:h,size:y,hx:(.15+c()*.9)*s,hy:(.1+c()*.95)*i,fx:1+Math.floor(c()*2),fy:1+Math.floor(c()*2),ph:c()*Math.PI*2,rot:(c()-.5)*2}});return{seek(g){let b=g/m*Math.PI*2;for(let h of f){let y=h.hx+Math.cos(b*h.fx+h.ph)*d*s-h.size/2,v=h.hy+Math.sin(b*h.fy+h.ph*1.3)*d*i-h.size/2;h.b.style.transform=`translate(${y.toFixed(1)}px, ${v.toFixed(1)}px) rotate(${(Math.sin(b+h.ph)*30*h.rot).toFixed(2)}deg)`}}}}};var it="http://www.w3.org/2000/svg",ui=0,_n={slug:"texture/grain",summary:"Fine film grain over the frame, changing a set number of times a second.",props:{},params:{amount:{type:"number",default:.08,min:.02,max:.25,step:.01,unit:"ratio",label:"Strength"},rate:{type:"number",default:12,min:0,max:24,step:1,unit:"per s",label:"Changes per second (0 holds still)"},size:{type:"number",default:1,min:.5,max:3,step:.1,unit:"x",label:"Grain size"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=l(t.size),u=l(t.rate);e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none;z-index:50";let m=a.createElementNS(it,"svg");m.setAttribute("width",String(s)),m.setAttribute("height",String(i)),m.style.cssText=`position:absolute;inset:0;opacity:${l(t.amount)};mix-blend-mode:overlay`;let d=`m-grain-${++ui}`,c=a.createElementNS(it,"filter");c.setAttribute("id",d),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","100%"),c.setAttribute("height","100%");let p=a.createElementNS(it,"feTurbulence");p.setAttribute("type","fractalNoise"),p.setAttribute("baseFrequency",String(.9/o*(s/1920))),p.setAttribute("numOctaves","2"),p.setAttribute("stitchTiles","stitch");let f=a.createElementNS(it,"feColorMatrix");f.setAttribute("type","saturate"),f.setAttribute("values","0"),c.append(p,f);let g=a.createElementNS(it,"rect");return g.setAttribute("width","100%"),g.setAttribute("height","100%"),g.setAttribute("filter",`url(#${d})`),m.append(c,g),e.appendChild(m),{seek(b){let h=u>0?Math.floor(b*u+1e-6):0;p.setAttribute("seed",String(r.seed*1e3+h))}}}};var er={slug:"texture/vignette",summary:"The frame darkens towards its edges, holding the eye on the middle. Fixed to the screen.",props:{color:{type:"string",default:"#000000",label:"CSS colour the edges darken to"}},params:{inner:{type:"number",default:48,min:0,max:90,step:1,unit:"%",label:"Where the darkening starts, from the centre to the corner"},outer:{type:"number",default:82,min:10,max:100,step:1,unit:"%",label:"Where it reaches its middle strength"},strength:{type:"number",default:.85,min:0,max:1,step:.05,unit:"ratio",label:"Opacity at the corners"},mid:{type:"number",default:.55,min:0,max:1,step:.05,unit:"ratio",label:"Opacity at `outer`"},center_x:{type:"number",default:50,min:0,max:100,step:1,unit:"%",label:"Centre, across"},center_y:{type:"number",default:46,min:0,max:100,step:1,unit:"%",label:"Centre, down: a little above the middle reads as level"}},duration:()=>0,build(e,n,t){let r=String(n.color??"#000000"),a=s=>`color-mix(in srgb, ${r} ${Math.round(s*100)}%, transparent)`;return e.style.cssText+=`;position:absolute;inset:0;max-width:none;pointer-events:none;background:radial-gradient(farthest-corner at ${l(t.center_x)}% ${l(t.center_y)}%, transparent ${l(t.inner)}%, ${a(l(t.mid))} ${Math.max(l(t.inner)+1,l(t.outer))}%, ${a(l(t.strength))} 100%)`,{seek(){}}}};function Mt(e,n,t,r){let[a,s]=t,i=Math.min(2*Math.max(1,r.cameraScale?.()??1),8192/Math.max(a,s)),o=Math.round(a*i),u=Math.round(s*i);(e.width!==o||e.height!==u)&&(e.width=o,e.height=u),n.setTransform(o/a,0,0,u/s,0,0)}function mi(e,n){let t=e-Math.floor(e),r=.6+.4*Math.exp(-t*n.decay),a=Z(t/n.life),s=1-(1-a)**3;return{breathe:r,ringR:60+s*(n.reach-60),ringA:a>=1?0:n.ring*(1-s)}}function tr(e,n){let t=e.ownerDocument.createElement("span");t.style.color=n,t.style.display="none",e.appendChild(t);let r=getComputedStyle(t).color;return t.remove(),(r.match(/[\d.]+/g)?.slice(0,3)??["255","255","255"]).join(",")}var nr={slug:"texture/beat-field",summary:"A dim dot lattice whose light breathes on the beat, with a ring leaving the centre.",props:{clear:{type:"string[]",default:[],label:"Ids of layers on the field: no dot is drawn under them"}},params:{pitch:{type:"number",default:18,min:8,max:60,step:1,unit:"px",label:"Distance between dots"},dot:{type:"number",default:.33,min:.1,max:.5,step:.01,unit:"ratio",label:"Dot radius, as a share of the pitch"},paper:{type:"number",default:.045,min:0,max:.2,step:.005,unit:"opacity",label:"How much every dot shows, unlit"},glow:{type:"number",default:.13,min:0,max:.4,step:.01,unit:"opacity",label:"The light at the centre, at the top of a breath"},glow_radius:{type:"number",default:320,min:80,max:1200,step:10,unit:"px",label:"How far the centre light reaches"},decay:{type:"number",default:3.2,min:.5,max:8,step:.1,unit:"per beat",label:"How fast a breath dies away"},ring:{type:"number",default:.22,min:0,max:.6,step:.01,unit:"opacity",label:"The ring of light at its start (0: no ring)"},ring_reach:{type:"number",default:620,min:120,max:2e3,step:10,unit:"px",label:"How far the ring travels in a beat"},ring_life:{type:"number",default:.95,min:.3,max:1,step:.05,unit:"beats",label:"Share of a beat the ring takes to fade"},center_x:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of width",label:"Centre of the light, across"},center_y:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of height",label:"Centre of the light, down"},period:{type:"number",default:.5,min:.2,max:2,step:.01,unit:"s",label:"Seconds per beat when the film has no tempo"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=s/1080;e.style.cssText+=";position:absolute;left:0;top:0;width:100%;height:100%;max-width:none;pointer-events:none";let u=a.createElement("canvas");u.style.cssText=`position:absolute;left:0;top:0;width:${s}px;height:${i}px`,e.appendChild(u);let m=u.getContext("2d"),d=tr(e,"currentColor"),c=tr(e,"var(--m-accent)"),p=r.beat??Math.max(.05,l(t.period)),f=r.filmStart??0,g=l(t.pitch)*o,b=l(t.dot)*g,h=l(t.paper),y=l(t.glow),v=l(t.glow_radius)*o,E={decay:l(t.decay),ring:l(t.ring),reach:l(t.ring_reach),life:l(t.ring_life)},M=l(t.center_x)/100*s,k=l(t.center_y)/100*i,R=[],z=Math.ceil(M/g)+1,L=Math.ceil(k/g)+1;for(let N=-L;N<=Math.ceil((i-k)/g)+1;N++)for(let S=-z;S<=Math.ceil((s-M)/g)+1;S++){let $=M+S*g,X=k+N*g;R.push([$,X,Math.hypot($-M,X-k)])}let j,x=te(n.clear);return{seek(N){if(!m)return;if(!j){let Y=x.map(K=>r.boxOf?.(K)).filter(K=>!!K);j=R.filter(([K,_])=>!Y.some(ee=>K>ee.x-b&&K<ee.x+ee.w+b&&_>ee.y-b&&_<ee.y+ee.h+b))}Mt(u,m,r.size,r),m.clearRect(0,0,s,i);let{breathe:S,ringR:$,ringA:X}=mi((f+N)/p,E),C=$*o,q=40*o,P=m.createRadialGradient(M,k,0,M,k,v);P.addColorStop(0,`rgba(${c},${(.07*S).toFixed(4)})`),P.addColorStop(.55,`rgba(${c},${(.025*S).toFixed(4)})`),P.addColorStop(1,`rgba(${c},0)`),m.fillStyle=P,m.fillRect(M-v,k-v,v*2,v*2);for(let[Y,K,_]of j){let ee=_/v,A=ee>=1?0:ee<.45?1-ee/.45*(1-.05/.13):.05/.13*(1-(ee-.45)/.55),O=X>0?X*Math.max(0,1-Math.abs(_-C)/q):0,B=y*S*A+O;m.beginPath(),m.arc(Y,K,b,0,Math.PI*2),h>0&&(m.fillStyle=`rgba(${d},${h})`,m.fill()),B>.002&&(m.fillStyle=`rgba(${c},${Math.min(1,B).toFixed(4)})`,m.fill())}}}}};var rr=e=>/^data:image\/|\.(png|jpe?g|webp|avif|gif|svg)(\?|#|$)/i.test(e);function di(e,n){if(!e?.length)return;let t=Math.min(e.length-1,Math.max(0,n));for(let r=0;r<e.length;r++){let a=e[t-r],s=e[t+r];if(a)return a;if(s)return s}}function ci(e,n){return e.length<2||!(n>0)?0:Z(Math.log2(e[0]/n),0,e.length-1)}function pi(e,n,t,r,a,s,i){let o=Math.sin(r*Math.PI/180),u=Math.sin(t*Math.PI/180),m=Math.hypot(o,u);if(m<1e-4||i<=0)return"linear-gradient(transparent, transparent)";let d=o/m,c=u/m,p=Math.atan2(d,-c)*180/Math.PI,f=Math.abs(e*d)+Math.abs(n*c),g=((a-e/2)*d+(s-n/2)*c)/f+.5,b=v=>Math.min(1,Math.abs(v-g)*f*m/i),h=[[0,b(0)]],y=i/(f*m);return g-y>0&&h.push([g-y,1]),g>0&&g<1&&h.push([g,0]),g+y<1&&h.push([g+y,1]),h.push([1,b(1)]),`linear-gradient(${p.toFixed(2)}deg, ${h.map(([v,E])=>`rgba(0,0,0,${E.toFixed(3)}) ${(v*100).toFixed(2)}%`).join(", ")})`}function hi(e,n,t){let r=Math.PI/180,a=t*r,s=Math.PI/4,i=[Math.sin(n*r),-Math.sin(e*r)*Math.cos(n*r),Math.cos(e*r)*Math.cos(n*r)],o=[Math.cos(a)*Math.cos(s),Math.sin(a)*Math.cos(s),Math.sin(s)];return i[0]*o[0]+i[1]*o[1]+i[2]*o[2]-Math.sin(s)}var ar={slug:"rig/footage-plane",summary:"Flat screen footage on a plane the camera moves over, with depth of field and light.",props:{src:{type:"string",required:!0,label:"Video recorded flat (motion record), or a still picture of a screen"},from:{type:"number",default:0,label:"Source time the plane opens on, in seconds"},to:{type:"number",default:0,label:"Source time it ends on; 0 plays on until the scene ends"},marks:{type:"string",default:"",label:'The marks file motion record --marks wrote, for camera keys ("plane#mark") and taps to aim at'},focus:{type:"string",default:"",label:"The mark the lens focuses on; the middle of the picture when empty"}},params:{width:{type:"number",default:1080,min:100,max:8e3,step:1,unit:"px",label:"Width of the plane on the stage at zoom 1"},radius:{type:"number",default:0,min:0,max:200,step:1,unit:"px",label:"Corner radius"},rate:{type:"number",default:1,min:.1,max:4,step:.05,unit:"\xD7",label:"Playback speed"},loop:{type:"boolean",default:!1,label:'Wrap from "to" back to "from" until the scene ends'},aperture:{type:"number",default:6,min:0,max:24,step:.5,unit:"px",label:"Blur where the tilted plane is furthest out of focus (0: all sharp)"},depth:{type:"number",default:260,min:40,max:2e3,step:10,unit:"px",label:"Depth from the focal plane at which the blur is full"},light:{type:"number",default:235,min:0,max:360,step:5,unit:"deg",label:"Where the light comes from, on the screen (0 right, 90 below, 270 above)"},shade:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"How much the tilt lights and darkens the plane"},sheen:{type:"number",default:.06,min:0,max:.3,step:.01,unit:"opacity",label:"A soft band of reflected light that slides as the plane turns"},shadow:{type:"number",default:.35,min:0,max:1,step:.05,unit:"opacity",label:"The plane's shadow on what is behind it"}},cues:()=>[],duration:(e,n)=>{let t=l(e.from),r=l(e.to);return n.loop===!0||!(r>t)?0:(r-t)/l(n.rate,1)},check(e,n){let t=[],r=l(e.from),a=l(e.to);return r<0&&t.push({path:"props.from",message:"from is a source time in seconds, zero or more."}),a!==0&&a<=r&&t.push({path:"props.to",message:`to (${a} s) must come after from (${r} s).`}),n.loop===!0&&!(a>r)&&t.push({path:"params.loop",message:"A loop needs both ends: set props.to after props.from."}),F(e.focus)&&!F(e.marks)&&t.push({path:"props.focus",message:"focus names a mark, so the plane needs its marks file.",hint:"Record with motion record --marks and set props.marks."}),t},build(e,n,t,r){let a=e.ownerDocument,s=l(t.width),i=l(t.radius),o=r.frames?[r.frames,...r.mips??[]]:[],u=r.frames?.marks,m=r.frames?r.frames.height/r.frames.width:u?u.size[1]/u.size[0]:16/9,d=s*m;e.style.cssText+=";max-width:none";let c=a.createElement("div");c.style.cssText=`position:relative;width:${s}px;height:${d}px;border-radius:${i}px;overflow:hidden;background:#000`,e.appendChild(c),e.style.borderRadius=`${i}px`;let p="position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:fill",f=0,g=Promise.resolve(),b=o.map(()=>{let P=a.createElement("img");return P.decoding="sync",P.alt="",P.style.cssText=`${p};opacity:0`,c.appendChild(P),P}),h=(P,Y)=>{if(P.getAttribute("src")===Y)return;P.src=Y;let K=++f;g=Promise.all([g,P.decode().catch(()=>{if(!(K!==f||P.complete&&P.naturalWidth>0))return new Promise((_,ee)=>{P.addEventListener("load",()=>_(),{once:!0}),P.addEventListener("error",()=>ee(new Error(`Footage frame did not load: ${Y}`)),{once:!0})})})]).then(()=>{})};if(!o.length&&rr(F(n.src))){let P=a.createElement("img");P.decoding="sync",P.alt="",P.src=F(n.src),P.style.cssText=p,c.appendChild(P)}let y;!o.length&&!rr(F(n.src))&&(y=a.createElement("video"),y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=F(n.src),y.style.cssText=p,c.appendChild(y));let v=o.length?a.createElement("img"):void 0;v&&(v.decoding="sync",v.alt="",v.style.cssText=`${p};opacity:0;filter:blur(${l(t.aperture)}px);transform:scale(1.02)`,c.appendChild(v));let E=a.createElement("div");E.style.cssText=`${p};pointer-events:none`;let M=a.createElement("div");M.style.cssText=`${p};pointer-events:none;mix-blend-mode:screen`,c.append(E,M);let k=u?.fps??60,R=u?s/u.size[0]:1,z=(P,Y)=>{let K=u?.marks[P]??u?.marks[`#${P}`]??u?.marks[`.${P}`],_=di(K,Math.round(nt(Y,n,t)*k));return _?[_[0]*R,_[1]*R,_[2]*R,_[3]*R]:void 0},L=typeof window<"u"&&window.devicePixelRatio||1,j=l(t.aperture),x=l(t.depth),N=l(t.shade),S=l(t.sheen),$=l(t.shadow),X=l(t.light),C=F(n.focus),q=o.map(P=>P.width);return{seek(P){let Y=r.cameraPose?.()??{scale:1,rotateX:0,rotateY:0},K=nt(P,n,t);if(o.length){let O=ci(q,s*Y.scale*L),B=Math.floor(O),W=Math.min(o.length-1,B+1),H=O-B;if(b.forEach((U,G)=>{let Q=G===B||G===W&&H>.001;if(U.style.opacity=Q?G===B?"1":H.toFixed(3):"0",U.style.zIndex=G===W&&G!==B?"1":"0",Q){let ie=o[G];h(U,Ze(ie,Math.round((K-ie.start)*ie.rate+1e-6)))}}),v){let U=Math.hypot(Y.rotateX,Y.rotateY);if(j>0&&U>.05){let G=o[Math.min(o.length-1,W+1)];h(v,Ze(G,Math.round((K-G.start)*G.rate+1e-6)));let Q=C?z(C,P):void 0,[ie,ue]=Q?[Q[0]+Q[2]/2,Q[1]+Q[3]/2]:[s/2,d/2],pe=pi(s,d,Y.rotateX,Y.rotateY,ie,ue,x);v.style.maskImage=pe,v.style.opacity="1",v.style.zIndex="2"}else v.style.opacity="0"}}else y&&Math.abs(y.currentTime-K)>.5/r.fps&&(y.currentTime=K);let _=hi(Y.rotateX,Y.rotateY,X)*N*2;E.style.background=_>=0?`rgba(255,255,255,${Z(_*.5).toFixed(3)})`:`rgba(0,0,0,${Z(-_).toFixed(3)})`,E.style.zIndex="3";let ee=50+Y.rotateY*3-Y.rotateX*3;M.style.background=S>0?`linear-gradient(${(X+90).toFixed(0)}deg, transparent ${(ee-22).toFixed(1)}%, rgba(255,255,255,${S}) ${ee.toFixed(1)}%, transparent ${(ee+22).toFixed(1)}%)`:"",M.style.zIndex="4";let A=Math.hypot(Y.rotateX,Y.rotateY);c.style.boxShadow=$>0?`0 ${(10+A*1.6).toFixed(1)}px ${(30+A*3).toFixed(1)}px rgba(0,0,0,${$})`:"",c.style.overflow="hidden"},pending:()=>g,markAt:z}}};function Oe(e,n,t=1){let r=e.parentElement;if(!r)return[];let a=[];for(let s=0;s<t;s++){let i=r.querySelector(`:scope > [data-m-overlay="${n}-${s}"]`);i||(i=e.ownerDocument.createElement("div"),i.dataset.mOverlay=`${n}-${s}`,i.style.cssText=`position:absolute;inset:0;z-index:${1e3+s};pointer-events:none;will-change:transform,clip-path`,r.appendChild(i)),a.push(i)}return a}function De(e,n){e.parentElement?.querySelectorAll(`:scope > [data-m-overlay^="${n}-"]`).forEach(t=>t.remove())}var Ye=e=>["base","surface","sunken","accent","inverse"].includes(e)?`var(--m-bg-${e})`:e;var ir="cover",sr={slug:"transition/cover-reveal",summary:"Colour panels sweep across and cover the cut, then sweep on to uncover the next scene.",duration:1,calm:{lag:.06},params:{duration:{type:"number",default:1,min:.6,max:1.6,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"up",options:["up","down","left","right"],label:"Which way the panels travel"},panels:{type:"number",default:2,min:1,max:3,step:1,unit:"panels",label:"Panels, one behind the other"},lag:{type:"number",default:.12,min:0,max:.3,step:.01,unit:"ratio",label:"How far each panel trails the one before"}},apply(e,n,t,r,a){let s=Math.max(1,Math.round(l(r.panels))),i=l(r.lag),o=["accent","inverse","surface"],u=Oe(e,ir,s),m=a.ease("quart.inOut"),d=F(r.direction),c=1-i*(s-1);u.forEach((g,b)=>{g.style.background=Ye(te([o[(s-1-b)%o.length]])[0]);let h=Z((t-b*i)/c),y=m(Z(h*2)),v=m(Z(h*2-1)),E=y*100,M=v*100,k=d==="up"?`${100-E}% 0 ${M}% 0`:d==="down"?`${M}% 0 ${100-E}% 0`:d==="left"?`0 ${M}% 0 ${100-E}%`:`0 ${100-E}% 0 ${M}%`;g.style.clipPath=`inset(${k})`,g.style.visibility=h<=0||h>=1?"hidden":"visible"});let p=(s-1)*i+c/2;n.style.opacity=t>=p?"1":"0",e.style.opacity=t>=p?"0":"1";let f=m(Z((t-p)/(1-p)));n.style.transform=t>=p?`scale(${(1.04-.04*f).toFixed(4)})`:""},clear(e){De(e,ir),e.style.transform="",e.style.opacity=""}};var or="curtain",lr={slug:"transition/curtain",summary:"Two panels part or close.",duration:.8,params:{duration:{type:"number",default:.8,min:.5,max:1.4,step:.05,unit:"s",label:"Length of the hand-over"},axis:{type:"choice",default:"vertical",options:["vertical","horizontal"],label:"Panels meet along a vertical or a horizontal line"},fill:{type:"choice",default:"inverse",options:["inverse","accent","surface","base"],label:"Panel colour"}},apply(e,n,t,r,a){let[s,i]=Oe(e,or,2);if(!s||!i)return;let o=a.ease("quint.inOut"),u=o(Z(t/.46)),m=o(Z((t-.54)/.46)),d=(u-m)*50,c=F(r.axis)!=="horizontal";for(let f of[s,i])f.style.background=Ye(F(r.fill,"inverse"));s.style.clipPath=c?`inset(0 ${100-d}% 0 0)`:`inset(0 0 ${100-d}% 0)`,i.style.clipPath=c?`inset(0 0 0 ${100-d}%)`:`inset(${100-d}% 0 0 0)`;let p=t>=.5;e.style.opacity=p?"0":"1",n.style.opacity=p?"1":"0",n.style.transform=p?`scale(${(1.05-.05*m).toFixed(4)})`:""},clear(e){De(e,or),e.style.opacity="",e.style.transform=""}};var ur={slug:"transition/dive-in",summary:"The camera pushes into a point until it fills the frame.",duration:.5,calm:{scale_to:3},params:{duration:{type:"number",default:.5,min:.4,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},scale_to:{type:"number",default:8,min:3,max:12,step:.5,unit:"x",label:"How far the camera pushes in"},x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of width",label:"Point to dive into, across",pad:{name:"point",axis:"x"}},y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of height",label:"Point to dive into, down",pad:{name:"point",axis:"y"}},pace:{type:"choice",default:"accelerate",options:["accelerate","glide"],label:"accelerate hits the cut at speed; glide eases in and out and arrives at rest"}},apply(e,n,t,r,a){let[s,i]=a.size,o=l(r.x)/100*s,u=l(r.y)/100*i;if(e.style.transformOrigin=`${o}px ${u}px`,n.style.transformOrigin=`${o}px ${u}px`,F(r.pace)==="glide"){let g=a.ease("sine.inOut")(t),b=Math.pow(l(r.scale_to),g),h=7*Math.sin(Math.PI*t);e.style.transform=`scale(${b.toFixed(4)})`,e.style.filter=h>.05?`blur(${h.toFixed(2)}px)`:"",e.style.opacity=String(1-a.ease("smooth")(Z((t-.55)/.35))),n.style.transform=`scale(${(1.12-.12*a.ease("expo.out")(Z((t-.5)/.5))).toFixed(4)})`,n.style.filter=h>.05?`blur(${h.toFixed(2)}px)`:"",n.style.opacity=String(a.ease("smooth")(Z((t-.5)/.35)));return}let m=a.ease("expo.in"),d=a.ease("expo.out"),c=m(Z(t/.55)),p=d(Z((t-.45)/.55)),f=1+(l(r.scale_to)-1)*c;e.style.transform=`scale(${f.toFixed(4)})`,e.style.filter=c>.02?`blur(${(c*14).toFixed(2)}px)`:"",e.style.opacity=String(1-Z((t-.4)/.15)),n.style.transform=`scale(${(1.35-.35*p).toFixed(4)})`,n.style.filter=p<.98?`blur(${((1-p)*12).toFixed(2)}px)`:"",n.style.opacity=String(Z((t-.45)/.12))},clear(e){e.style.transform="",e.style.transformOrigin="",e.style.filter="",e.style.opacity=""}};var mr={slug:"transition/iris",summary:"The next scene opens from a point in a growing circle.",duration:.8,calm:{push_in:.02},params:{duration:{type:"number",default:.8,min:.4,max:1.4,step:.05,unit:"s",label:"Length of the hand-over"},x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of width",label:"Centre, across",pad:{name:"centre",axis:"x"}},y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of height",label:"Centre, down",pad:{name:"centre",axis:"y"}},shape:{type:"choice",default:"circle",options:["circle","rounded"],label:"Opening shape"},push_in:{type:"number",default:.06,min:0,max:.2,step:.01,unit:"ratio",label:"How much the outgoing scene pushes in"}},apply(e,n,t,r,a){let s=a.ease("expressive.inOut"),[i,o]=a.size,u=l(r.x)/100*i,m=l(r.y)/100*o,d=s(t),c=Math.max(Math.hypot(u,m),Math.hypot(i-u,m),Math.hypot(u,o-m),Math.hypot(i-u,o-m)),p=d*c*1.02;if(F(r.shape)==="rounded"){let f=p*.9,g=p*.9;n.style.clipPath=`inset(${(m-g).toFixed(1)}px ${(i-u-f).toFixed(1)}px ${(o-m-g).toFixed(1)}px ${(u-f).toFixed(1)}px round ${(p*.25).toFixed(1)}px)`}else n.style.clipPath=`circle(${p.toFixed(2)}px at ${u.toFixed(1)}px ${m.toFixed(1)}px)`;n.style.transform=`scale(${(1.08-.08*d).toFixed(4)})`,n.style.transformOrigin=`${u}px ${m}px`,e.style.transform=`scale(${(1+l(r.push_in)*d).toFixed(4)})`,e.style.transformOrigin=`${u}px ${m}px`},clear(e){e.style.clipPath="",e.style.transform="",e.style.transformOrigin=""}};var Wt="http://www.w3.org/2000/svg",dr=new WeakMap,fi=0,ke=(e,n)=>Math.abs(e)*Math.max(0,n)/Math.sqrt(12),cr=.25;function Te(e,n,t,r=48){let a=Math.min(r,Math.abs(n)),s=Math.min(r,Math.abs(t));if(a<cr&&s<cr)return"";let i=dr.get(e);if(!i){let c=e.ownerDocument,p=e.closest(".m-stage")??c.body,f=p.querySelector(":scope > svg.m-filters");f||(f=c.createElementNS(Wt,"svg"),f.setAttribute("class","m-filters"),f.setAttribute("aria-hidden","true"),f.style.cssText="position:absolute;width:0;height:0;overflow:hidden;pointer-events:none",p.appendChild(f));let g=`m-dblur-${++fi}`,b=c.createElementNS(Wt,"filter");b.setAttribute("id",g),b.setAttribute("color-interpolation-filters","sRGB");let h=c.createElementNS(Wt,"feGaussianBlur");b.appendChild(h),f.appendChild(b),i={id:g,filter:b,blur:h},dr.set(e,i)}let o=Math.max(1,e.offsetWidth),u=Math.max(1,e.offsetHeight),m=3*a/o,d=3*s/u;return i.filter.setAttribute("x",(-m).toFixed(4)),i.filter.setAttribute("y",(-d).toFixed(4)),i.filter.setAttribute("width",(1+2*m).toFixed(4)),i.filter.setAttribute("height",(1+2*d).toFixed(4)),i.blur.setAttribute("stdDeviation",`${a.toFixed(2)} ${s.toFixed(2)}`),`url(#${i.id})`}var pr={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},hr={slug:"transition/push",summary:"The next scene pushes the current one out of frame, with parallax and motion blur.",duration:.7,calm:{parallax:.15,blur:.25},params:{duration:{type:"number",default:.7,min:.3,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"left",options:["left","right","up","down"],label:"Which way the frame travels"},parallax:{type:"number",default:.35,min:0,max:1,step:.05,unit:"ratio",label:"How much less the outgoing scene travels"},blur:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Shutter: share of a frame the motion smears over (0.5 = film)"}},apply(e,n,t,r,a){let s=a.ease("quint.inOut"),[i,o]=a.size,[u,m]=pr[F(r.direction)]??pr.left,d=s(t),c=u?i:o,p=a.fps||30,f=1/120,g=(s(Math.min(1,t+f))-s(Math.max(0,t-f)))/(2*f)*c/(l(r.duration)*p),b=1-l(r.parallax),h=l(r.blur),y=ke(g,h),v=ke(g*b,h);n.style.transform=`translate(${(-u*(1-d)*i).toFixed(2)}px, ${(-m*(1-d)*o).toFixed(2)}px)`,e.style.transform=`translate(${(u*d*i*b).toFixed(2)}px, ${(m*d*o*b).toFixed(2)}px)`,e.style.filter=[Te(e,u?v:0,m?v:0),`brightness(${(1-.35*d).toFixed(3)})`].filter(Boolean).join(" "),n.style.filter=Te(n,u?y:0,m?y:0)},clear(e){e.style.transform="",e.style.filter=""}};var fr={slug:"transition/slant-wipe",summary:"A slanted edge cuts across the frame, uncovering the next scene; the old one drifts back.",duration:.6,calm:{slant:10,drift:3},params:{duration:{type:"number",default:.6,min:.4,max:.9,step:.05,unit:"s",label:"Length of the hand-over"},slant:{type:"number",default:20,min:0,max:40,step:1,unit:"% of width",label:"Slant of the edge"},direction:{type:"choice",default:"left",options:["left","right"],label:"Which way the edge travels"},drift:{type:"number",default:8,min:0,max:15,step:1,unit:"% of width",label:"How far the old scene drifts"}},apply(e,n,t,r,a){let i=a.ease([.77,0,.175,1])(t),o=l(r.slant),u=F(r.direction)!=="right",m=100+o,d=u?100-i*m:i*m-o,c=d+o;n.style.clipPath=u?`polygon(${d}% 0, 100% 0, 100% 100%, ${c}% 100%)`:`polygon(0 0, ${d+o}% 0, ${c-o}% 100%, 0 100%)`,e.style.transform=`translateX(${((u?-1:1)*l(r.drift)*i).toFixed(3)}%)`},clear(e){e.style.clipPath="",e.style.transform=""}};var gr={up:[0,1],down:[0,-1],left:[1,0],right:[-1,0]},br={slug:"transition/stack-over",summary:"The next scene slides over the current one, which recedes and dims beneath it.",duration:.7,calm:{recede:.97,dim:.4},params:{duration:{type:"number",default:.7,min:.4,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"up",options:["up","down","left","right"],label:"Which way the new scene travels"},recede:{type:"number",default:.94,min:.88,max:.98,step:.01,unit:"x",label:"Scale the old scene shrinks to"},dim:{type:"number",default:.7,min:.2,max:.8,step:.05,unit:"ratio",label:"Brightness the old scene dims to"},radius:{type:"number",default:2,min:0,max:6,step:.5,unit:"% of width",label:"Corner radius while moving"}},apply(e,n,t,r,a){let i=a.ease([.4,0,.1,1])(t),[o,u]=a.size,[m,d]=gr[F(r.direction)]??gr.up,c=l(r.radius)/100*o,p=Math.min(1,Math.max(0,(t-.75)/.25)),f=c*(1-p*p*(3-2*p));n.style.transform=`translate(${(m*(1-i)*o).toFixed(2)}px, ${(d*(1-i)*u).toFixed(2)}px)`,n.style.borderRadius=f>.5?`${f.toFixed(1)}px`:"";let g=.3*Math.min(1,(1-i)*4);n.style.boxShadow=g>.002?`${(-m*24).toFixed(0)}px ${(-d*24).toFixed(0)}px 90px rgba(0,0,0,${g.toFixed(3)})`:"",e.style.transform=`scale(${(1-(1-l(r.recede))*i).toFixed(4)})`,e.style.filter=`brightness(${(1-(1-l(r.dim))*i).toFixed(3)}) blur(${(i*2).toFixed(2)}px)`,e.style.clipPath=`inset(0 round ${(l(r.radius)/100*o*i).toFixed(1)}px)`},clear(e){e.style.transform="",e.style.clipPath="",e.style.boxShadow="",e.style.filter="",e.style.borderRadius=""}};var st=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Se(e,n,t={}){let r=e.ownerDocument,a=new Set([...t.accent??[]].map(st)),s=t.mask??"none",i=Math.max(0,t.feather??0),o=(h,y="")=>i>0?`display:${h};overflow:hidden;${y}padding:${.14}em 0.06em ${.14+i}em;margin:-${.14}em -0.06em -${.14+i}em;mask-image:linear-gradient(to bottom, #000 calc(100% - ${i}em), transparent);-webkit-mask-image:linear-gradient(to bottom, #000 calc(100% - ${i}em), transparent)`:`display:${h};overflow:hidden;${y}padding:${.14}em 0.06em;margin:-${.14}em -0.06em`;e.textContent="";let u=[],m=[],d=[],c=[];n.split(`
|
|
2
2
|
`).forEach((h,y)=>{y>0&&(e.appendChild(r.createElement("br")),c.push(u.length)),h.split(/\s+/).filter(Boolean).forEach((v,E)=>{E>0&&e.appendChild(r.createTextNode(" "));let M=r.createElement("span");if(M.style.display="inline-block",M.style.whiteSpace="pre",a.has(st(v))&&(M.style.color="var(--m-accent)"),t.chars)for(let k of[...v]){let R=r.createElement("span");R.textContent=k,R.style.display="inline-block",M.appendChild(R),m.push(R),d.push(u.length)}else M.textContent=v;e.appendChild(M),u.push(M)})});let p=[],f=-1,g=-1/0;u.forEach((h,y)=>{let v=h.offsetTop;(c.includes(y)||v>g+1)&&(f++,g=v),p.push(f)}),e.textContent="",e.style.display="flex",e.style.flexDirection="column";let b=[];return u.forEach((h,y)=>{let v=p[y],E=b[v];if(E)E.appendChild(r.createTextNode(" "));else{if(E=r.createElement("span"),E.style.display="block",s==="line"){let M=r.createElement("span");M.style.cssText=o("block"),M.appendChild(E),e.appendChild(M)}else e.appendChild(E);b[v]=E}if(s==="word"){let M=r.createElement("span");M.style.cssText=o("inline-block","vertical-align:top;"),M.appendChild(h),E.appendChild(M)}else E.appendChild(h)}),{lines:b,words:u,chars:m,wordLine:p,charWord:d}}var Nt=e=>e.split(/\s+/).filter(Boolean).length,xr=e=>[...e.replace(/\s+/g,"")].length,Ue=e=>Math.max(1,e.split(`
|
|
3
|
-
`).filter(n=>n.trim()).length);var gi={accent:"var(--m-bg-accent)",inverse:"var(--m-bg-inverse)",primary:"var(--m-text-primary)"},yr={slug:"type/block-reveal",summary:"A solid block covers each line, then retracts as the line slides out from behind it.",props:{text:{type:"string",required:!0,label:"The text. Use \\n to set the line breaks"},accent:{type:"string[]",default:[],label:"Words set in the accent colour"},fill:{type:"string",default:"accent",label:"Block colour: accent, inverse, primary or a CSS colour"}},params:{duration:{type:"number",default:.8,min:.5,max:1.2,step:.05,unit:"s",label:"Time for one block to grow and retract"},stagger:{type:"number",default:.08,min:.03,max:.2,step:.01,unit:"s",label:"Delay between lines"},direction:{type:"choice",default:"right",options:["right","left"],label:"Which way the block travels"}},duration:(e,n)=>(Ue(F(e.text))-1)*l(n.stagger)+l(n.duration)*2.35,build(e,n,t,r){let a=e.ownerDocument,{lines:s}=Se(e,F(n.text),{accent:te(n.accent)}),i=F(t.direction)!=="left",o=gi[F(n.fill,"accent")]??F(n.fill,"accent"),u=s.map(g=>{g.style.cssText+=";position:relative;display:block;width:fit-content;margin-inline:auto;text-align:inherit";let b=a.createElement("span");b.setAttribute("aria-hidden","true"),b.style.cssText=`position:absolute;inset:0.06em -0.08em;border-radius:0.06em;background:${o};transform:scaleX(0)`;let h=a.createElement("span");for(h.style.cssText="display:inline-block";g.firstChild;)h.appendChild(g.firstChild);return g.append(h,b),{block:b,words:h}}),m=(Ue(F(n.text))-1)*l(t.stagger),d=Me(u.length,u.length>1?Math.min(l(t.stagger),m/(u.length-1)):0),c=l(t.duration),p=r.ease("expo.inOut"),f=r.ease("snap.out");return{seek(g){u.forEach(({block:b,words:h},y)=>{let v=ae(g,d[y],c,p),E=ae(g,d[y]+c,c,p);b.style.transformOrigin=E>0?i?"100% 50%":"0% 50%":i?"0% 50%":"100% 50%",b.style.transform=`scaleX(${(E>0?1-E:v).toFixed(4)})`;let M=ae(g,d[y]+c*1.35,c,f),k=g>=d[y]+c;h.style.visibility=k?"inherit":"hidden",h.style.transform=M>=1?"":`translateX(${((i?-1:1)*(1-M)*.6).toFixed(4)}em)`,h.style.opacity=k?Math.min(1,.4+M).toFixed(3):"0"})}}}};var wr={slug:"type/char-cascade",summary:"Letters arrive one by one: rising, turning, growing or coming into focus.",props:{text:{type:"string",required:!0,label:"The text"},accent:{type:"string[]",default:[],label:"Words set in the accent colour"}},params:{stagger:{type:"number",default:.03,min:.015,max:.06,step:.005,unit:"s",label:"Delay between letters"},char_duration:{type:"number",default:.6,min:.3,max:1,step:.05,unit:"s",label:"Time per letter"},from:{type:"choice",default:"start",options:qe,label:"Which letter goes first"},rise:{type:"number",default:.6,min:-1,max:1.2,step:.05,unit:"em",label:"Rise (negative drops in)"},rotate:{type:"number",default:0,min:-90,max:90,step:1,unit:"deg",label:"Turn that settles"},scale:{type:"number",default:1,min:0,max:1.6,step:.05,unit:"x",label:"Start scale"},blur:{type:"number",default:8,min:0,max:24,step:1,unit:"px",label:"Start blur"}},duration:(e,n,t)=>ze(xr(F(e.text)),F(n.from),t.seed)*l(n.stagger)+l(n.char_duration),build(e,n,t,r){let{chars:a}=Se(e,F(n.text),{chars:!0,accent:te(n.accent)}),s=Me(a.length,l(t.stagger),F(t.from),r.seed),i=r.ease(r.tokens.ease_enter),o=l(t.char_duration),u=l(t.rise),m=l(t.rotate),d=l(t.scale),c=l(t.blur);for(let p of a)p.style.transformOrigin="50% 70%";return{seek(p){a.forEach((f,g)=>{let b=ae(p,s[g],o,i),h=Math.min(1,Math.max(0,(p-s[g])/(o*.45))),y=1-b;f.style.opacity=h>=1?"":String(h),f.style.transform=y===0?"":`translateY(${(y*u).toFixed(4)}em) rotate(${(y*m).toFixed(3)}deg) scale(${(d+(1-d)*b).toFixed(4)})`;let v=Math.max(0,y)*c;f.style.filter=v>.05?`blur(${v.toFixed(2)}px)`:""})}}}};var vr={slug:"type/echo",summary:"Copies of a headline trail behind it.",props:{text:{type:"string",required:!0,label:"The headline"}},params:{copies:{type:"number",default:4,min:3,max:6,step:1,unit:"copies",label:"Outlined copies"},lag:{type:"number",default:.06,min:.03,max:.12,step:.005,unit:"s",label:"Delay between copies"},distance:{type:"number",default:1.2,min:.4,max:3,step:.1,unit:"em",label:"How far below they start"},settle:{type:"number",default:0,min:0,max:.6,step:.02,unit:"em",label:"Gap between copies at rest (0 hides them under the headline)"}},duration:(e,n,t)=>Math.round(l(n.copies))*l(n.lag)+t.tokens.duration.slow+.4,build(e,n,t,r){let a=e.ownerDocument,s=Math.max(1,Math.round(l(t.copies))),i=l(t.lag),o=l(t.distance),u=l(t.settle),m=r.tokens.duration.slow+.4,d=r.ease("expressive.out");e.style.display="grid";let c=g=>{let b=a.createElement("span");return b.textContent=F(n.text),b.style.cssText="grid-area:1/1;white-space:pre-line",g&&(b.style.color="transparent",b.style.setProperty("-webkit-text-stroke","0.018em currentColor"),b.setAttribute("aria-hidden","true")),b},p=Array.from({length:s},()=>c(!0)).reverse();p.forEach(g=>e.appendChild(g)),p.reverse();let f=c(!1);return e.appendChild(f),{seek(g){let b=ae(g,s*i,m,d);f.style.transform=b>=1?"":`translateY(${((1-b)*o).toFixed(4)}em)`,f.style.opacity=String(Math.min(1,Math.max(0,(g-s*i)/(m*.3)))),p.forEach((h,y)=>{let v=s-1-y,E=ae(g,v*i,m,d),M=(y+1)*u;h.style.transform=`translateY(${(M+(1-E)*o).toFixed(4)}em)`;let k=Math.min(1,Math.max(0,(g-v*i)/(m*.25))),R=1-(y+1)/(s+1),z=u===0?1-ae(g,s*i+m*.6,m*.4,L=>L):1;h.style.opacity=(k*R*z).toFixed(3)})}}}};var kr=(e,n,t)=>{let r=F(e.text);return n.unit==="word"?ze(Nt(r),F(n.from),t):ze(Ue(r),F(n.from),t)+(Ue(r)>1||Nt(r)>3?1:0)},Mr={slug:"type/mask-reveal",summary:"Lines or words slide up from under an edge, one after another.",props:{text:{type:"string",required:!0,label:"The text. Use \\n to set the line breaks yourself."},accent:{type:"string[]",default:[],label:"Words set in the accent colour"}},params:{unit:{type:"choice",default:"line",options:["line","word"],label:"What rises together"},stagger:{type:"number",default:.08,min:.04,max:.16,step:.005,unit:"s",label:"Delay between units"},duration:{type:"number",default:.9,min:.5,max:1.4,step:.05,unit:"s",label:"Time per unit"},tilt:{type:"number",default:0,min:0,max:8,step:.5,unit:"deg",label:"Tilt that settles as it rises"},from:{type:"choice",default:"start",options:qe,label:"Which unit goes first"},ease:{type:"ease",default:"expressive.out",label:"Curve of each rise"},feather:{type:"number",default:0,min:0,max:.4,step:.01,unit:"em",label:"A soft edge to rise out of, instead of a hard line (0.1\u20130.12 em reads as soft)"}},duration:(e,n,t)=>kr(e,n,t.seed)*l(n.stagger)+l(n.duration),build(e,n,t,r){let a=t.unit==="word",s=Se(e,F(n.text),{mask:a?"word":"line",accent:te(n.accent),feather:l(t.feather)}),i=a?s.words:s.lines,o=ze(i.length,F(t.from),r.seed),u=kr(n,t,r.seed),m=o>u&&o>0?l(t.stagger)*u/o:l(t.stagger),d=Me(i.length,m,F(t.from),r.seed),c=r.ease(t.ease),p=l(t.duration),f=l(t.tilt),g=l(t.feather);for(let b of i)b.style.transformOrigin="0% 100%",b.style.willChange="transform";return{seek(b){i.forEach((h,y)=>{let E=1-ae(b,d[y],p,c);h.style.transform=E===0?"":`translateY(${g>0?`calc(${(E*110).toFixed(3)}% + ${(E*g).toFixed(4)}em)`:`${(E*110).toFixed(3)}%`}) rotate(${(E*f).toFixed(3)}deg)`})}}}};var Fr="http://www.w3.org/2000/svg";function bi(e,n,t,r){let a=i=>(r()-.5)*i;if(e==="circle"){let i=n/2,o=t/2,u=n/2+t*.35,m=t*.72,d=[];for(let c=0;c<=28;c++){let p=-Math.PI*.62+c/28*Math.PI*2.18,f=1+a(.06);d.push(`${(i+Math.cos(p)*u*f).toFixed(1)},${(o+Math.sin(p)*m*f+c/28*t*.08).toFixed(1)}`)}return`M${d.join("L")}`}if(e==="strike")return`M${-t*.1},${t*.56+a(4)} C${n*.3},${t*.5+a(6)} ${n*.7},${t*.6+a(6)} ${n+t*.1},${t*.5+a(4)}`;if(e==="marker"){let i=t*.42,o=t*.7;return`M${-t*.08},${i+a(4)} L${n+t*.1},${i+a(5)} L${-t*.05},${o+a(5)} L${n+t*.06},${o+a(4)}`}let s=t*1.02;return`M${-t*.05},${s+a(3)} C${n*.35},${s+t*.06+a(4)} ${n*.65},${s-t*.02+a(4)} ${n+t*.12},${s-t*.12+a(3)}`}var Tr={slug:"type/scribble-highlight",summary:"A hand-drawn mark draws under or around a word.",props:{text:{type:"string",required:!0,label:"The sentence"},mark:{type:"string[]",required:!0,label:"Words to mark (a run of words gets one mark)"}},params:{duration:{type:"number",default:.5,min:.3,max:.9,step:.05,unit:"s",label:"Time to draw the mark"},kind:{type:"choice",default:"underline",options:["underline","circle","marker","strike"],label:"Mark"},delay:{type:"number",default:.3,min:0,max:2,step:.05,unit:"s",label:"Wait before drawing"},weight:{type:"number",default:.08,min:.03,max:.4,step:.01,unit:"em",label:"Stroke weight (a marker uses about 0.35)"}},duration:(e,n)=>l(n.delay)+l(n.duration),build(e,n,t,r){let a=new Set(te(n.mark).map(st)),{words:s}=Se(e,F(n.text));e.style.position="relative";let i=s.filter(L=>a.has(st(L.textContent??"")));if(!i.length)return{seek(){}};let o=i[0],u=i[i.length-1],m=e.getBoundingClientRect(),d=o.getBoundingClientRect(),c=u.getBoundingClientRect(),p=e.offsetWidth>0?m.width/e.offsetWidth:1,f=(d.left-m.left)/p,g=(d.top-m.top)/p,b=(c.right-d.left)/p,h=d.height/p,y=F(t.kind),v=parseFloat(getComputedStyle(e).fontSize)||16,E=e.ownerDocument.createElementNS(Fr,"svg");E.setAttribute("width",String(b)),E.setAttribute("height",String(h)),E.style.cssText=`position:absolute;left:${f}px;top:${g}px;overflow:visible;pointer-events:none;${y==="marker"?"z-index:-1;mix-blend-mode:multiply":""}`;let M=e.ownerDocument.createElementNS(Fr,"path");M.setAttribute("d",bi(y,b,h,$e(r.seed*31+b))),M.setAttribute("fill","none"),M.setAttribute("stroke",y==="marker"?"color-mix(in srgb, var(--m-accent) 45%, transparent)":"var(--m-accent)"),M.setAttribute("stroke-width",String(l(t.weight)*v*(y==="marker"?4.4:1))),M.setAttribute("stroke-linecap","round"),M.setAttribute("stroke-linejoin","round"),M.setAttribute("pathLength","1"),M.setAttribute("stroke-dasharray","1 1"),E.appendChild(M),e.style.isolation="isolate",e.appendChild(E);let k=r.ease("quart.inOut"),R=l(t.delay),z=l(t.duration);return{seek(L){let j=ae(L,R,z,k);M.setAttribute("stroke-dashoffset",(1-j).toFixed(4)),E.style.visibility=j<=0?"hidden":"inherit"}}}};var Er={slug:"type/shimmer",summary:"A band of light passes across the letters, again and again.",props:{text:{type:"string",required:!0,label:"The text"}},params:{period:{type:"number",default:2.4,min:1.2,max:4,step:.1,unit:"s",label:"Time between passes"},band:{type:"number",default:.22,min:.1,max:.5,step:.01,unit:"ratio",label:"Width of the band"},strength:{type:"number",default:.65,min:.3,max:1,step:.05,unit:"ratio",label:"How dim the text is outside the band"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument.createElement("span");a.textContent=F(n.text);let s=l(t.band),i=Math.max(.2,l(t.period)),o=100-Math.round(l(t.strength)*100),u=r.ease("sine.inOut");return a.style.cssText=`display:inline-block;white-space:pre-line;-webkit-background-clip:text;background-clip:text;background-image:linear-gradient(100deg, color-mix(in srgb, currentColor ${o}%, transparent) 0%, color-mix(in srgb, currentColor ${o}%, transparent) ${50-s*50}%, currentColor 50%, color-mix(in srgb, currentColor ${o}%, transparent) ${50+s*50}%, color-mix(in srgb, currentColor ${o}%, transparent) 100%);background-size:300% 100%;background-repeat:no-repeat`,a.style.setProperty("-webkit-text-fill-color","transparent"),e.appendChild(a),{seek(m){let d=(m%i+i)%i/i,c=u(Math.min(1,d/.7));a.style.backgroundPosition=`${(100-c*100).toFixed(3)}% 0`}}}};var $r={slug:"type/tracking-in",summary:"Wide-spaced letters close up to their set spacing while coming into focus.",props:{text:{type:"string",required:!0,label:"The title"}},params:{duration:{type:"number",default:1.6,min:.8,max:3,step:.1,unit:"s",label:"Time to close up"},spread:{type:"number",default:.5,min:.1,max:1.2,step:.05,unit:"em",label:"Extra spacing at the start"},blur:{type:"number",default:12,min:0,max:30,step:1,unit:"px",label:"Start blur"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let a=r.ease("expressive.out"),s=l(t.duration),i=l(t.spread),o=l(t.blur),u=e.ownerDocument.createElement("span");u.textContent=F(n.text),u.style.cssText="display:inline-block;white-space:pre-line",e.appendChild(u);let m=parseFloat(getComputedStyle(e).letterSpacing)||0,d=parseFloat(getComputedStyle(e).fontSize)||16;return{seek(c){let p=ae(c,0,s,a),f=Math.min(1,c/(s*.5)),g=(1-p)*i;u.style.letterSpacing=`${(m/d+g).toFixed(4)}em`,u.style.marginRight=`${(-g).toFixed(4)}em`,u.style.opacity=f>=1?"":String(Math.max(0,f));let b=(1-p)*o;u.style.filter=b>.05?`blur(${b.toFixed(2)}px)`:""}}}};var Sr={slug:"type/word-roller",summary:"Words roll vertically in a slot.",props:{before:{type:"string",default:"",label:"Text before the slot"},words:{type:"string[]",required:!0,label:"Words that take turns in the slot; the last one stays"},after:{type:"string",default:"",label:"Text after the slot"}},params:{per_word:{type:"number",default:.9,min:.5,max:1.6,step:.05,unit:"s",label:"Time each word stays"},roll:{type:"number",default:.5,min:.3,max:.7,step:.05,unit:"s",label:"Time to roll to the next"},direction:{type:"choice",default:"up",options:["up","down"],label:"Roll direction"},style:{type:"choice",default:"roll",options:["roll","lift"],label:"Roll through a clipped slot, or lift: the word lifts away out of focus, a beat, the next settles in (a status line)"},gap:{type:"number",default:.05,min:0,max:.2,step:.01,unit:"s",label:"For lift: the empty beat between the words"}},duration:(e,n)=>Math.max(0,te(e.words).length-1)*l(n.per_word)+l(n.roll),build(e,n,t,r){let a=e.ownerDocument,s=te(n.words),i=l(t.per_word),o=l(t.roll),u=t.direction==="down"?-1:1,m=r.ease("quint.inOut"),d=t.style==="lift",c=r.ease("cubic.inOut"),p=Math.min(l(t.gap),o*.5),f=(o-p)/2;e.style.whiteSpace="nowrap";let g=a.createElement("span"),b=a.createElement("span");g.textContent=F(n.before)?`${F(n.before)} `:"",b.textContent=F(n.after)?` ${F(n.after)}`:"";let h=a.createElement("span");h.style.cssText=`display:inline-block;position:relative;overflow:${d?"visible":"hidden"};vertical-align:bottom;padding:0.14em 0;margin:-0.14em 0;color:var(--m-accent)`;let y=s.map(M=>{let k=a.createElement("span");return k.textContent=M,k.style.cssText="position:absolute;left:0;top:0.14em;white-space:pre",h.appendChild(k),k}),v=a.createElement("span");v.style.cssText="visibility:hidden;white-space:pre",v.textContent=s.reduce((M,k)=>k.length>M.length?k:M,""),h.appendChild(v),e.append(g,h,b);let E=y.map(M=>M.offsetWidth);return v.style.display="inline-block",v.style.width="0px",{seek(M){let k=Math.max(0,Math.min(s.length-1,Math.floor(M/i+1e-9))),R=k===0?1:ae(M-k*i,0,o,m);if(d){let L=M-k*i,j=k===0?1:ae(L,0,f,c),x=k===0?1:ae(L,f+p,f,c);y.forEach((S,$)=>{let X=$===k?1-x:$===k-1?-j:1,C=$===k?x:$===k-1?1-j:0;S.style.visibility=C<=0?"hidden":"inherit",S.style.opacity=C>=1?"":C.toFixed(4),S.style.transform=X===0?"":`translateY(${(u*X*8).toFixed(3)}px)`,S.style.filter=X===0?"":`blur(${(Math.abs(X)*2).toFixed(3)}px)`});let N=k===0?E[0]:E[k-1]+(E[k]-E[k-1])*R;h.style.width=`${N.toFixed(2)}px`;return}y.forEach((L,j)=>{let x=j===k?1-R:j===k-1?-R:1;L.style.transform=x===0?"":`translateY(${(u*x*110).toFixed(3)}%)`,L.style.visibility=Math.abs(x)>=1?"hidden":"inherit"});let z=k===0?E[0]:E[k-1]+(E[k]-E[k-1])*R;h.style.width=`${z.toFixed(2)}px`}}}};var xi="M2 1.5 L2 20.5 L7.2 15.6 L10.6 23.2 L14 21.7 L10.7 14.2 L17.6 14.2 Z",Ar=e=>Ft(e).at+Ft(e).press;function Ft(e){let n=l(e.travel),t=.08;return{travel:n,press:t,at:n+.06,end:n+.06+t*2+.55}}var Cr={slug:"ui/cursor-click",summary:"A drawn cursor moves to a target and clicks.",props:{label:{type:"string",default:"",label:"A name tag beside the cursor, for a collaborator"},target:{type:"string",default:"",label:"The id of the layer it clicks: that layer presses, and the ring leaves it in its own shape"}},params:{from_x:{type:"number",default:78,min:0,max:100,step:.5,unit:"% of width",label:"Start, across",pad:{name:"start",axis:"x"}},from_y:{type:"number",default:82,min:0,max:100,step:.5,unit:"% of height",label:"Start, down",pad:{name:"start",axis:"y"}},to_x:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of width",label:"Target, across",pad:{name:"target",axis:"x"}},to_y:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of height",label:"Target, down",pad:{name:"target",axis:"y"}},travel:{type:"number",default:.7,min:.3,max:1.8,step:.05,unit:"s",label:"Time to reach the target"},arc:{type:"number",default:.06,min:0,max:.2,step:.01,unit:"ratio",label:"Bow of the path"},size:{type:"number",default:2.4,min:1.5,max:4,step:.1,unit:"% of width",label:"Cursor size"}},duration:(e,n)=>Ft(n).end,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=Ft(t),u=l(t.from_x)/100*s,m=l(t.from_y)/100*i,d=l(t.to_x)/100*s,c=l(t.to_y)/100*i,p=Math.hypot(d-u,c-m),f=l(t.arc)*p,g=(u+d)/2-(c-m)/(p||1)*f,b=(m+c)/2+(d-u)/(p||1)*f,h=l(t.size)/100*s;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none;z-index:40";let y=a.createElement("div");y.style.cssText=`position:absolute;left:${d}px;top:${c}px;width:${h*1.6}px;height:${h*1.6}px;margin:${-h*.8}px 0 0 ${-h*.8}px;border-radius:50%;border:${h*.08}px solid var(--m-accent);opacity:0`;let v=a.createElement("div");if(v.style.cssText=`position:absolute;left:0;top:0;width:${h}px;height:${h}px;transform-origin:8% 6%;filter:drop-shadow(0 ${h*.06}px ${h*.12}px rgba(0,0,0,0.28))`,v.innerHTML=`<svg viewBox="0 0 24 24" width="${h}" height="${h}" style="display:block;overflow:visible"><path d="${xi}" fill="var(--m-text-primary)" stroke="var(--m-bg-base)" stroke-width="1.5" stroke-linejoin="round"/></svg>`,F(n.label)){let R=a.createElement("span");R.textContent=F(n.label),R.style.cssText=`position:absolute;left:${h*.7}px;top:${h*.9}px;padding:${h*.12}px ${h*.3}px;border-radius:${h*.3}px;background:var(--m-bg-accent);color:var(--m-text-on-accent);font:600 ${h*.42}px var(--m-font-body);white-space:nowrap`,v.appendChild(R)}let E=!F(n.target);e.append(...E?[y]:[],v);let M=r.ease([.45,0,.15,1]),k=r.ease("expressive.out");return{seek(R){let z=ae(R,0,o.travel,M),L=(1-z)*(1-z)*u+2*(1-z)*z*g+z*z*d,j=(1-z)*(1-z)*m+2*(1-z)*z*b+z*z*c,x=ae(R,o.at,o.press,X=>X),N=ae(R,o.at+o.press,o.press*1.5,k),S=1-.14*(x-N);v.style.transform=`translate(${(L-h*.08).toFixed(2)}px, ${(j-h*.06).toFixed(2)}px) scale(${S.toFixed(4)})`,v.style.opacity=Math.min(1,R/.15).toFixed(3);let $=ae(R,o.at+o.press,.55,k);y.style.opacity=$>0?(.9*(1-$)).toFixed(3):"0",y.style.transform=`scale(${(.3+$*1.1).toFixed(4)})`}}}};var yi=e=>1+2.4*(e-1)**3+1.4*(e-1)**2,Pr=e=>Math.floor(ge(e.points).length/2),Rr={slug:"fx/pin-drop",summary:"Markers land on places one by one, ripple together, and raise their labels on stems.",props:{points:{type:"number[]",required:!0,label:"Places as x, y pairs in % of the stage: [x1, y1, x2, y2, \u2026]"},labels:{type:"string[]",default:[],label:"A short label for each place, in the same order. Left out, no card"}},params:{stagger:{type:"number",default:.28,min:.1,max:.6,step:.01,unit:"s",label:"Delay between places"},stem:{type:"number",default:120,min:0,max:260,step:5,unit:"px",label:"How high each card stands over its marker"},size:{type:"number",default:16,min:8,max:32,step:1,unit:"px",label:"Marker size"},ripple:{type:"number",default:1.3,min:.8,max:2.4,step:.05,unit:"s",label:"Time between ripples"},glow:{type:"number",default:1,min:0,max:2,step:.05,unit:"ratio",label:"Strength of the glow under each marker"}},duration:(e,n)=>Math.max(0,Pr(e)-1)*l(n.stagger)+.95,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=s/1080;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let u=ge(n.points),m=te(n.labels),d=l(t.size)*o,c=l(t.glow),p=l(t.stem)*o,f=(E,M)=>{let k=a.createElement("div");return k.style.cssText=M,E.appendChild(k),k},g=Array.from({length:Pr(n)},(E,M)=>{let k=u[M*2]/100*s,R=u[M*2+1]/100*i,z=`position:absolute;left:${k}px;top:${R}px;`,L=f(e,`${z}width:${d*6}px;height:${d*6}px;translate:-50% -50%;border-radius:50%;background:radial-gradient(closest-side,color-mix(in srgb,var(--m-accent) ${Math.round(42*Math.min(1,c))}%,transparent),color-mix(in srgb,var(--m-accent) ${Math.round(12*c)}%,transparent) 45%,transparent)`),j=f(e,`${z}width:${d*2.5}px;height:${d*2.5}px;translate:-50% -50%;border-radius:50%;border:${1.5*o}px solid var(--m-accent);box-shadow:0 0 ${12*o}px color-mix(in srgb,var(--m-accent) 45%,transparent)`),x=f(e,`${z}width:${1.5*o}px;translate:-50% 0;transform-origin:50% 100%;background:linear-gradient(color-mix(in srgb,var(--m-accent) 95%,transparent),color-mix(in srgb,var(--m-accent) 25%,transparent))`),N=f(e,`${z}width:${d}px;height:${d}px;translate:-50% -50%;border-radius:50%;background:var(--m-accent);box-shadow:0 0 0 ${3*o}px var(--m-bg-base),0 0 ${6*o}px ${2*o}px rgba(0,0,0,.5)`),S=m[M]??"",$=S?f(e,`${z}translate:-50% -100%;transform-origin:50% 100%;display:flex;align-items:center;gap:${10*o}px;white-space:nowrap;padding:${12*o}px ${16*o}px;border-radius:${10*o}px;background:color-mix(in srgb,var(--m-bg-surface) 82%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--m-text-primary) 9%,transparent),0 ${30*o}px ${60*o}px rgba(0,0,0,.45);font:var(--ui-weight-medium,500) calc(var(--m-u)*1.6)/1.25 var(--m-font-body);color:var(--m-text-primary)`):void 0;if($){f($,`flex:none;width:${d*.7}px;height:${d*.7}px;border-radius:50%;background:var(--m-accent)`);let X=a.createElement("span");X.textContent=S,$.appendChild(X)}return{y:R,halo:L,ring:j,stem:x,dot:N,card:$}}),b=l(t.stagger),h=l(t.ripple),y=r.ease("expo.out"),v=r.ease("smooth");return{seek(E){let M=Math.max(0,E)/h%1;g.forEach((k,R)=>{let z=R*b,L=Z((E-z)/.42),j=Z((E-z)/.14),x=y(Z((E-z-.14)/.81));if(k.dot.style.opacity=j.toFixed(3),k.dot.style.scale=String(Math.max(0,L<1?yi(L):1).toFixed(4)),k.halo.style.opacity=j.toFixed(3),k.halo.style.scale=ve(.5,1,y(L)).toFixed(4),k.ring.style.opacity=((1-M)**1.4*Z((E-z-.1)/.3)).toFixed(3),k.ring.style.scale=(.3+M*1.25).toFixed(4),!k.card){k.stem.style.height="0px";return}let N=p*ve(.3,1,x),S=d*.5+5*o,$=Math.max(0,N-S);k.stem.style.top=`${k.y-N}px`,k.stem.style.height=`${$}px`;let X=v(Z((E-z-.2)/.35));k.stem.style.opacity=X.toFixed(3),k.card.style.top=`${k.y-N}px`,k.card.style.scale=ve(.84,1,x).toFixed(4),k.card.style.opacity=X.toFixed(3)})}}}};var wi=["in","out","in-out","hold"];function Ve(e){return{path:{type:"choice",default:e.path,options:wi,label:"Camera path: in turns from square-on to the pose, out from the pose to square-on, in-out goes and comes back, hold stays in the pose"},tilt:{type:"number",default:e.tilt,min:-40,max:40,step:1,unit:"deg, negative faces left",label:"Turn",pad:{name:"angle",axis:"x"}},pitch:{type:"number",default:e.pitch,min:-15,max:30,step:1,unit:"deg",label:"Lean",pad:{name:"angle",axis:"y"}},roll:{type:"number",default:e.roll,min:-12,max:12,step:.5,unit:"deg",label:"Camera roll"},zoom:{type:"number",default:e.zoom,min:.5,max:1.8,step:.01,unit:"x",label:"Camera zoom in the pose (below 1 stands back)"},pan_x:{type:"number",default:0,min:-50,max:50,step:.5,unit:"% of the rig",label:"Across",pad:{name:"look",axis:"x"}},pan_y:{type:"number",default:0,min:-50,max:50,step:.5,unit:"% of the rig",label:"Down",pad:{name:"look",axis:"y"}},move:{type:"number",default:e.move,min:.4,max:3,step:.05,unit:"s",label:"Time the camera takes for each move"},hold:{type:"number",default:1,min:0,max:6,step:.05,unit:"s",label:"For in-out: time in the pose before it comes back"},ease:{type:"ease",default:"cubic.inOut",label:"Curve of each camera move"},drift:{type:"number",default:1.2,min:0,max:4,step:.1,unit:"deg/s",label:"Slow drift once the camera has arrived"}}}function Ne(e){let n=F(e.path),t=l(e.move);return n==="hold"?0:n==="in-out"?2*t+l(e.hold):t}function vi(e,n,t){let r=F(n.path),a=Math.max(.01,l(n.move));return r==="hold"?1:r==="out"?1-t(Z(e/a)):r==="in-out"?e<a?t(Z(e/a)):e<a+l(n.hold)?1:1-t(Z((e-a-l(n.hold))/a)):t(Z(e/a))}function Ge(e,n,t){let r=vi(e,n,t),a=l(n.tilt),s=l(n.pitch),i={rx:s*r,ry:a*r,rz:l(n.roll)*r,zoom:ve(1,l(n.zoom),r),x:l(n.pan_x)/100*r,y:l(n.pan_y)/100*r},o=Math.max(0,e-Ne(n)),u=l(n.drift);return o>0&&u>0&&(r>.5?(i.ry-=Math.sign(a)*Math.min(Math.abs(a)*.5,u*o),i.rx-=Math.sign(s)*Math.min(Math.abs(s)*.5,u*.4*o)):i.zoom*=1+Math.min(.06,.015*u*o)),i}function Ke(e,n,t,r){return`translateZ(${(n*(1-1/Math.max(.05,e.zoom))).toFixed(2)}px) rotateX(${e.rx.toFixed(3)}deg) rotateY(${e.ry.toFixed(3)}deg) rotateZ(${e.rz.toFixed(3)}deg) translate(${(-e.x*t).toFixed(2)}px, ${(-e.y*r).toFixed(2)}px)`}var Le=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`;function ki(e,n){let t=e.ownerDocument,r=s=>{let i=t.createElement("div");return i.style.cssText=`position:absolute;${s}`,e.appendChild(i),i};e.style.background="var(--m-bg-base)";let a=(s,i,o,u,m,d=999)=>r(`left:${s}%;top:${i}%;width:${o}%;height:${u}%;border-radius:${d}px;background:${Le(m)}`);a(5,6,9,3.6,34),[52,61,70].forEach(s=>a(s,7,6,2,18)),r("left:82%;top:5.4%;width:13%;height:5%;border-radius:999px;background:var(--m-bg-inverse)"),a(22,22,56,6.4,30),a(30,31.5,40,6.4,30),a(33,42,34,2.4,14),[[6,"var(--m-bg-surface)"],[36,"color-mix(in srgb, var(--m-accent) 22%, var(--m-bg-surface))"],[66,"var(--m-bg-surface)"]].forEach(([s,i])=>{let o=r(`left:${s}%;top:54%;width:28%;height:38%;border-radius:${n}px;background:${i};box-shadow:inset 0 0 0 1px ${Le(8)}`),u=(d,c,p)=>{let f=t.createElement("div");f.style.cssText=`position:absolute;left:9%;top:${d}%;width:${c}%;height:6%;border-radius:999px;background:${Le(p)}`,o.appendChild(f)};u(64,70,30),u(76,46,16);let m=t.createElement("div");m.style.cssText=`position:absolute;left:9%;top:12%;width:14%;aspect-ratio:1;border-radius:50%;background:${s===36?"var(--m-accent)":Le(20)}`,o.appendChild(m)})}var zr={slug:"rig/browser-window",summary:"A page in a browser window turns into perspective, then lifts one of its parts.",props:{src:{type:"string",default:"",label:"Screenshot of the page (path or URL). Left out, a placeholder page is drawn"},url:{type:"string",default:"example.com",label:"Address shown in the bar"},lift:{type:"number[]",default:[],label:"Part to lift: [x, y, width, height] in % of the page"}},params:{width:{type:"number",default:80,min:40,max:100,step:1,unit:"% of stage width",label:"Width of the window"},aspect:{type:"number",default:.625,min:.4,max:1.4,step:.005,unit:"height / width",label:"Shape of the page"},lift:{type:"number",default:140,min:0,max:320,step:5,unit:"px",label:"How far the part rises off the page"},lift_at:{type:"number",default:.8,min:0,max:6,step:.05,unit:"s",label:"When the part starts to rise (it takes 0.8 s)"},...Ve({path:"in",tilt:-24,pitch:10,roll:-2.4,zoom:.92,move:1})},duration:(e,n)=>Math.max(Ne(n),ge(e.lift).length===4&&l(n.lift)>0?l(n.lift_at)+.8:0),build(e,n,t,r){let a=e.ownerDocument,[s]=r.size,i=s/1080,o=l(t.width)/100*s,u=Math.round(40*i*(o/(s*.8))),m=o*l(t.aspect),d=m+u,c=16*i,p=o*2.2,f=F(n.src),g=a.createElement("div");g.style.cssText=`position:relative;width:${o}px;height:${d}px;perspective:${p}px`;let b=a.createElement("div");b.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%";let h=a.createElement("div");h.style.cssText=`position:absolute;inset:0;overflow:hidden;border-radius:${c}px;background:var(--m-bg-sunken);box-shadow:0 0 0 1px ${Le(9)},0 ${60*i}px ${120*i}px rgba(0,0,0,.55),0 ${20*i}px ${40*i}px rgba(0,0,0,.35)`;let y=a.createElement("div");y.style.cssText=`position:absolute;left:0;top:0;right:0;height:${u}px;display:flex;align-items:center;gap:${8*i}px;padding:0 ${16*i}px;background:var(--m-bg-surface);border-bottom:1px solid ${Le(6)}`;for(let S=0;S<3;S++){let $=a.createElement("i");$.style.cssText=`display:block;width:${11*i}px;height:${11*i}px;border-radius:50%;background:${Le(16)}`,y.appendChild($)}let v=a.createElement("b");v.textContent=F(n.url),v.style.cssText=`position:absolute;left:50%;top:50%;translate:-50% -50%;height:${u*.55}px;min-width:${o*.28}px;padding:0 ${12*i}px;border-radius:${6*i}px;background:${Le(7)};color:var(--m-text-muted);font:500 ${u*.3}px/${u*.55}px var(--m-font-body);text-align:center;letter-spacing:0.01em;white-space:nowrap`,y.appendChild(v);let E=S=>{if(f){let $=a.createElement("img");$.src=f,$.alt="",$.decoding="sync",$.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:top",S.appendChild($)}else ki(S,12*i)},M=a.createElement("div");M.style.cssText=`position:absolute;left:0;top:${u}px;width:${o}px;height:${m}px;overflow:hidden`,E(M);let k=a.createElement("div");k.style.cssText="position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(135deg,rgba(255,255,255,.06),transparent 38%);box-shadow:inset 0 1px 0 rgba(255,255,255,.1)",h.append(y,M);let R=ge(n.lift),z;if(R.length===4){let[S,$,X,C]=[R[0]/100*o,R[1]/100*m,R[2]/100*o,R[3]/100*m],q=a.createElement("div");q.style.cssText=`position:absolute;left:${S}px;top:${$+u}px;width:${X}px;height:${C}px;border-radius:${12*i}px;background:#000;opacity:0;filter:blur(${14*i}px)`,h.appendChild(q);let P=a.createElement("div");P.style.cssText=`position:absolute;left:${S}px;top:${$+u}px;width:${X}px;height:${C}px;overflow:hidden;border-radius:${12*i}px;transform-origin:50% 50%;visibility:hidden`;let Y=a.createElement("div");Y.style.cssText=`position:absolute;left:${-S}px;top:${-$}px;width:${o}px;height:${m}px`,E(Y),P.appendChild(Y),z={box:P,dim:q}}h.appendChild(k),b.appendChild(h),z&&b.appendChild(z.box),g.appendChild(b),e.appendChild(g);let L=r.ease(t.ease),j=r.ease("expo.out"),x=l(t.lift)*i,N=l(t.lift_at);return{seek(S){if(b.style.transform=Ke(Ge(S,t,L),p,o,d),!z)return;let $=j(Z((S-N)/.8)),X=x*$,C=Z(X/(140*i));z.box.style.visibility=$>0?"inherit":"hidden",z.box.style.transform=`translateZ(${X.toFixed(2)}px) scale(${(1+.04*$).toFixed(4)})`,z.box.style.boxShadow=`0 0 0 1px rgba(255,255,255,${(.08*C).toFixed(3)}),0 ${40*i*C}px ${90*i*C}px rgba(0,0,0,${(.6*C).toFixed(3)}),0 ${12*i*C}px ${28*i*C}px rgba(0,0,0,${(.35*C).toFixed(3)})`,z.dim.style.opacity=(.3*$).toFixed(3)}}}};var He=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`,Je=e=>{let n=Z(e);return n*n*(3-2*n)},ot=e=>e*Math.PI/180,Lr=["close","open","open-close"],Mi=["solid","wire"];function Or(e,n){let t=n.travel+Math.max(0,e-2)*n.stagger;return n.start+(n.order==="open-close"?2*t+n.apart:t)}function Fi(e,n,t,r=a=>a){let a=Math.max(.01,t.travel),s=u=>Array.from({length:e},(m,d)=>d===0?0:r(Z((n-u-(e-1-d)*t.stagger)/a))),i=u=>Array.from({length:e},(m,d)=>d===0?0:1-r(Z((n-u-(d-1)*t.stagger)/a)));if(t.order==="open")return s(t.start);if(t.order==="close")return i(t.start);let o=t.start+a+Math.max(0,e-2)*t.stagger+t.apart;return n<o?s(t.start):i(o)}function Ti([e,n,t],r){let a=(i,o,u)=>{let m=ot(u),d=Math.cos(m),c=Math.sin(m);return[i*d-o*c,i*c+o*d]};[e,n]=a(e,n,r.turn),[n,t]=a(n,t,r.lay),e-=r.cam.x*r.w,n-=r.cam.y*r.h,[e,n]=a(e,n,r.cam.rz),[t,e]=a(t,e,r.cam.ry),[n,t]=a(n,t,r.cam.rx),r.P>0&&(t+=r.P*(1-1/Math.max(.05,r.cam.zoom)));let s=r.P>0?r.P/Math.max(1,r.P-t):1;return[e*s,n*s]}var Dr=e=>({order:Lr.includes(F(e.order))?F(e.order):"close",start:l(e.start),travel:l(e.travel),stagger:l(e.stagger),apart:l(e.apart)}),Ir={slug:"rig/layer-stack",summary:"Named planes float one above the other, then close onto the lowest and become one layer.",props:{items:{type:"string[]",required:!0,label:"Plane names, from the base up"},faces:{type:"string[]",default:[],label:"A picture for each plane, in the same order (paths relative to the film)"},name:{type:"string",default:"",label:"What the closed stack is called"}},params:{width:{type:"number",default:42,min:15,max:90,step:1,unit:"% of stage width",label:"Width of a plane"},aspect:{type:"number",default:1,min:.4,max:1.6,step:.01,unit:"depth \xF7 width",label:"Proportions of a plane"},gap:{type:"number",default:120,min:20,max:320,step:1,unit:"px",label:"Space between planes when apart"},lay:{type:"number",default:60,min:0,max:80,step:1,unit:"deg",label:"How far the planes lie back (0 faces the camera)"},turn:{type:"number",default:-45,min:-90,max:90,step:1,unit:"deg",label:"Turn of the planes about their own axis"},spin:{type:"number",default:1.2,min:-8,max:8,step:.1,unit:"deg/s",label:"Slow turn that never stops"},order:{type:"choice",default:"close",options:Lr,label:"Close starts apart and ends as one, open the reverse, open-close does both"},start:{type:"number",default:1.4,min:0,max:10,step:.05,unit:"s",label:"When the planes start to move"},travel:{type:"number",default:.9,min:.3,max:3,step:.05,unit:"s",label:"Time one plane takes to land or lift"},stagger:{type:"number",default:.14,min:0,max:.6,step:.01,unit:"s",label:"Delay between one plane and the next"},apart:{type:"number",default:1.2,min:0,max:6,step:.05,unit:"s",label:"For open-close: time held apart"},radius:{type:"number",default:28,min:0,max:120,step:1,unit:"px",label:"Corner radius of a plane"},lens:{type:"number",default:4,min:0,max:12,step:.5,unit:"\xD7 the rig",label:"Length of the lens; 0 is parallel, as in an isometric drawing"},look:{type:"choice",default:"solid",options:Mi,label:"Solid surfaces with shadows, or a wire drawing with guides and numbered labels"},...Ve({path:"hold",tilt:0,pitch:0,roll:0,zoom:1,move:1.6})},duration:(e,n)=>{let t=te(e.items).length,r=Dr(n);return Math.max(Ne(n),Or(t,r)+(r.order==="open"?0:.9))},check(e){let n=te(e.items).length,t=te(e.faces).length,r=[];return n<2&&r.push({path:"props.items",message:"A stack needs at least two planes.",hint:"Name two to seven planes, from the base up."}),t>0&&t!==n&&r.push({path:"props.faces",message:`There are ${t} faces for ${n} planes.`,hint:"Give one picture per plane, or none."}),r},build(e,n,t,r){let a=e.ownerDocument,[s]=r.size,i=s/1080,o=te(n.items),u=te(n.faces),m=o.length,d=Dr(t),c=l(t.width)/100*s,p=c*l(t.aspect),f=l(t.gap)*i,g=l(t.radius)*i,b=l(t.lay),h=l(t.turn),y=l(t.spin),v=ot(h),E=Math.cos(ot(b)),M=Math.sin(ot(b)),k=Math.abs(c*Math.cos(v))+Math.abs(p*Math.sin(v)),R=(Math.abs(c*Math.sin(v))+Math.abs(p*Math.cos(v)))*E+(m-1)*f*M,z=Math.max(k,R)*l(t.lens),L=F(t.look)==="wire",j=-((m-1)*f)/2,x=a.createElement("div");x.style.cssText=`position:relative;width:${k}px;height:${R}px;perspective:${z>0?`${z}px`:"none"}`;let N=a.createElement("div");N.style.cssText=`position:absolute;left:${(k-c)/2}px;top:${(R-p)/2}px;width:${c}px;height:${p}px;transform-style:preserve-3d;transform-origin:50% 50%`;let S=a.createElement("div");S.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%",N.appendChild(S);let $=a.createElement("div");$.style.cssText="position:absolute;inset:0";let X="var(--m-font-body)",C=(W,H,U,G="")=>{let Q=a.createElement("div");Q.style.cssText=`position:absolute;left:0;top:0;transform-origin:0 0;display:flex;align-items:center;gap:${12*i}px;white-space:nowrap;`+(L?`font:500 ${21*i}px/1 var(--m-font-mono);letter-spacing:0.06em;text-transform:uppercase;color:${H}`:`font:500 ${27*i}px/1 ${X};letter-spacing:-0.01em;color:${H}`);let ie=a.createElement("i");ie.style.cssText=`display:block;flex:none;width:${9*i}px;height:${9*i}px;border-radius:50%;background:${U};margin-left:${-4.5*i}px`;let ue=a.createElement("i");ue.style.cssText=L?`display:block;flex:none;width:${44*i}px;height:0;border-top:${1.5*i}px dotted ${He(45)}`:`display:block;flex:none;width:${34*i}px;height:${1.5*i}px;background:${He(22)}`;let pe=a.createElement("span");if(pe.textContent=W,Q.append(ie,ue),G){let w=a.createElement("span");w.textContent=G,w.style.color=He(45),Q.appendChild(w)}Q.appendChild(pe);let de=a.createElement("div");return de.style.cssText="position:absolute;left:0;top:0;transform-origin:0 0",Q.style.transform="translateY(-50%)",de.appendChild(Q),$.appendChild(de),de},q=a.createElement("div");q.style.cssText=`position:absolute;inset:0;border-radius:${g}px;box-shadow:0 0 0 ${2*i}px var(--m-accent);visibility:hidden`,S.appendChild(q);let P=o.map((W,H)=>{let U=a.createElement("div");if(U.style.cssText=`position:absolute;inset:0;border-radius:${g}px;overflow:hidden;background:color-mix(in srgb, var(${L?"--m-bg-base":"--m-bg-surface"}) ${L?86:92}%, transparent)`,u[H]){let Q=a.createElement("img");Q.src=u[H],Q.alt=W,Q.decoding="sync",Q.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block",U.appendChild(Q)}let G=a.createElement("div");return G.style.cssText=`position:absolute;inset:0;border-radius:inherit;background:color-mix(in srgb, var(--m-accent) ${L?20:16}%, transparent);box-shadow:inset 0 0 0 ${2*i}px var(--m-accent)${L?"":`, inset 0 0 ${90*i}px color-mix(in srgb, var(--m-accent) 30%, transparent)`};opacity:0`,U.appendChild(G),S.appendChild(U),{plane:U,lit:G,tag:C(W,"var(--m-text-secondary)",He(L?80:55),L?String(H+1).padStart(2,"0"):"")}}),Y=F(n.name)?C(F(n.name),"var(--m-text-primary)","var(--m-accent)"):null;Y&&(Y.firstElementChild.style.fontWeight="600");let K="http://www.w3.org/2000/svg",_=L?[0,1,2].map(()=>{let W=$.querySelector("svg")??$.insertBefore(a.createElementNS(K,"svg"),$.firstChild);W.setAttribute("width",String(k)),W.setAttribute("height",String(R)),W.style.cssText="position:absolute;left:0;top:0;overflow:visible";let H=a.createElementNS(K,"line");return H.setAttribute("stroke",He(55)),H.setAttribute("stroke-width",String(1.5*i)),H.setAttribute("stroke-dasharray",`${1.5*i} ${7*i}`),H.setAttribute("stroke-linecap","round"),W.appendChild(H),H}):[];x.append(N,$),e.appendChild(x);let ee=r.ease(t.ease),A=r.ease("quint.inOut"),O=r.ease("expo.out"),B=Or(m,d);return{seek(W){let H=Ge(W,t,ee);N.style.transform=Ke(H,z,c,p);let U=h+y*W;S.style.transform=`rotateX(${b.toFixed(3)}deg) rotateZ(${U.toFixed(3)}deg)`;let G=(re,ne,se)=>{let[oe,le]=Ti([re-c/2,ne-p/2,se],{lay:b,turn:U,cam:H,P:z,w:c,h:p});return[k/2+oe,R/2+le]},Q=(re,ne,se)=>{let[oe,le]=G(re,ne,se);return`translate(${oe.toFixed(2)}px, ${le.toFixed(2)}px)`},ie=ot(U),ue=Math.cos(ie),pe=Math.sin(ie),de=c,w=p,T=-1/0;for(let[re,ne]of[[0,0],[c,0],[c,p],[0,p]]){let se=(re-c/2)*ue-(ne-p/2)*pe;se>T&&(T=se,de=re,w=ne)}let V=Fi(m,W,d,A),D=V[m-1]??0,J=1-D;if(P.forEach((re,ne)=>{let se=V[ne],oe=j+ne*f*se;re.plane.style.transform=`translateZ(${oe.toFixed(2)}px)`;let le=ne===0?1:Z(se*ne-(V[ne-1]??0)*(ne-1));re.plane.style.boxShadow=L?`inset 0 0 0 ${1.5*i}px ${He(ne===0?85:62)}`:`0 0 0 ${1.5*i}px ${He(ne===0?14:10+8*le)},0 0 ${70*i*le}px rgba(0,0,0,${(.38*le).toFixed(3)})`,re.plane.style.opacity=ne===0||ne===m-1?"1":Je(se/.25).toFixed(3),re.lit.style.opacity=ne===m-1?Je((J-.55)/.45).toFixed(3):"0",re.tag.style.transform=Q(de,w,oe),re.tag.style.opacity=Je(ne===0?D/.3:(se-.15)/.35).toFixed(3)}),Y&&(Y.style.transform=Q(de,w,j),Y.style.opacity=Je((J-.7)/.3).toFixed(3)),_.length){let re=[[0,0],[c,0],[c,p],[0,p]].map(([se,oe])=>({a:G(se,oe,j),b:G(se,oe,j+(m-1)*f*D)})),ne=re.reduce((se,oe,le)=>oe.a[1]<re[se].a[1]?le:se,0);re.filter((se,oe)=>oe!==ne).forEach((se,oe)=>{let le=_[oe];le.setAttribute("x1",se.a[0].toFixed(2)),le.setAttribute("y1",se.a[1].toFixed(2)),le.setAttribute("x2",se.b[0].toFixed(2)),le.setAttribute("y2",se.b[1].toFixed(2)),le.setAttribute("opacity",Je(D/.3).toFixed(3))})}let I=d.order==="open"?0:Z((W-B+.12)/.9);q.style.visibility=I>0&&I<1?"inherit":"hidden",q.style.transform=`translateZ(${j.toFixed(2)}px) scale(${(1+.32*O(I)).toFixed(4)})`,q.style.opacity=((1-I)*(1-I)*.9).toFixed(3)}}}};var lt=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`,Ei=e=>(1-Math.cos(Math.PI*Z(e)))/2;function Br(e){let n=te(e.items).length,t=Math.max(0,n-1),r=(a,s)=>typeof a=="number"&&a>=1?Math.min(t,Math.round(a)-1):s;return[r(e.from,0),r(e.to,t)]}function $i(e,n){return Array.from({length:e},(t,r)=>Math.max(0,1-Math.abs(n-r)))}var Wr={slug:"rig/tab-stack",summary:"Tabs stacked as stairs in depth; the open tab slides through them, then pops forward.",props:{items:{type:"string[]",required:!0,label:"Tab titles, in order"},details:{type:"string[]",default:[],label:"What each tab shows when open, in the same order"},from:{type:"number",default:1,label:"Tab open at the start (1 is the first)"},to:{type:"number",default:0,label:"Tab open at the end (0 is the last)"}},params:{width:{type:"number",default:64,min:30,max:100,step:1,unit:"% of stage width",label:"Width of the stack"},stack:{type:"number",default:34,min:0,max:90,step:1,unit:"px",label:"Height of each step towards the camera"},slide_at:{type:"number",default:.9,min:0,max:6,step:.05,unit:"s",label:"When the open tab starts to slide"},slide:{type:"number",default:1.6,min:.3,max:5,step:.05,unit:"s",label:"Time for the open tab to slide from first to last"},pop:{type:"number",default:46,min:0,max:140,step:1,unit:"px",label:"How far the tab that ends open pops forward"},...Ve({path:"out",tilt:-19,pitch:13,roll:-1.5,zoom:.9,move:1.6})},duration:(e,n)=>{let[t,r]=Br(e);return Math.max(Ne(n),t===r?0:l(n.slide_at)+l(n.slide)+(l(n.pop)>0?.7:0))},build(e,n,t,r){let a=e.ownerDocument,[s]=r.size,i=s/1080,o=te(n.items),u=te(n.details),m=o.length,[d,c]=Br(n),p=l(t.width)/100*s,f=18*i,g=12*i,b=78*i,h=b+118*i,y=14*i,v=m*b+(m>0?h-b:0)+Math.max(0,m-1)*g+2*f,E=Math.max(p,v)*2.4,M=a.createElement("div");M.style.cssText=`position:relative;width:${p}px;height:${v}px;perspective:${E}px;text-align:left`;let k=a.createElement("div");k.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%";let R=a.createElement("div");R.style.cssText=`position:absolute;inset:0;border-radius:${y+f}px;background:var(--m-bg-sunken);box-shadow:0 0 0 1px ${lt(9)},0 ${60*i}px ${120*i}px rgba(0,0,0,.55)`,k.appendChild(R);let z="var(--m-font-body)",L=o.map((C,q)=>{let P=a.createElement("div");P.style.cssText=`position:absolute;left:${f}px;width:${p-2*f}px;overflow:hidden;border-radius:${y}px;background:var(--m-bg-surface)`;let Y=(H,U)=>{let G=a.createElement("div");G.style.cssText=`position:absolute;left:0;right:0;top:0;height:${b}px;display:flex;align-items:center;gap:${12*i}px;padding:0 ${24*i}px;font:500 ${26*i}px/1.2 ${z};color:${H};white-space:nowrap`;let Q=a.createElement("i");Q.style.cssText=`display:block;flex:none;width:${10*i}px;height:${10*i}px;border-radius:50%;background:${U}`;let ie=a.createElement("span");return ie.textContent=C,ie.style.flex="1",G.append(Q,ie),G},K=Y("var(--m-text-muted)",lt(22)),_=a.createElement("span");_.textContent="+",_.style.cssText=`font-size:${28*i}px;color:${lt(40)}`,K.appendChild(_);let ee=a.createElement("div");ee.style.cssText="position:absolute;inset:0;background:color-mix(in srgb, var(--m-accent) 9%, var(--m-bg-surface));box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--m-accent) 28%, transparent);border-radius:inherit";let A=Y("var(--m-text-primary)","var(--m-accent)");A.firstElementChild.style.boxShadow=`0 0 ${10*i}px color-mix(in srgb, var(--m-accent) 60%, transparent)`;let O=a.createElement("p");O.textContent=u[q]??"",O.style.cssText=`position:absolute;left:${46*i}px;right:${40*i}px;top:${b-14*i}px;margin:0;font:400 ${21*i}px/1.42 ${z};color:var(--m-text-secondary)`;let B=a.createElement("div");B.style.cssText=`position:absolute;left:${24*i}px;right:${24*i}px;bottom:${16*i}px;height:${2*i}px;border-radius:9px;background:${lt(10)};overflow:hidden`;let W=a.createElement("div");return W.style.cssText="height:100%;width:100%;background:var(--m-accent);transform-origin:0 50%",B.appendChild(W),ee.append(A,O,B),P.append(K,ee),k.appendChild(P),{card:P,open:ee,fill:W}});M.appendChild(k),e.appendChild(M);let j=r.ease(t.ease),x=r.ease("expo.out"),N=l(t.stack)*i,S=l(t.pop)*i,$=l(t.slide_at),X=Math.max(.01,l(t.slide));return{seek(C){k.style.transform=Ke(Ge(C,t,j),E,p,v);let q=Ei((C-$)/X),P=d===c?d:ve(d,c,q),Y=$i(m,P),K=d===c?0:x(Z((C-$-X)/.7)),_=f;L.forEach((ee,A)=>{let O=Y[A],B=ve(b,h,O),W=N*(A+1)+(A===c?S*K:0);ee.card.style.top=`${_.toFixed(2)}px`,ee.card.style.height=`${B.toFixed(2)}px`,ee.card.style.transform=`translateZ(${W.toFixed(2)}px)`;let H=Z((N+(A===c?S*K:0))/(60*i));ee.card.style.boxShadow=`0 0 0 1px ${lt(8)},0 ${18*i*H}px ${40*i*H}px rgba(0,0,0,${(.45*H).toFixed(3)})`;let U=Z(O/.2);ee.open.style.opacity=(U*U*(3-2*U)).toFixed(3),ee.open.style.visibility=O>0?"inherit":"hidden",ee.fill.style.transform=`scaleX(${O.toFixed(4)})`,_+=B+g})}}}};var Ee=(e,n=0)=>{let t=Math.imul(e|0,668265261)^Math.imul((n|0)+2654435769,2246822507);return t=Math.imul(t^t>>>15,739982445),t=Math.imul(t^t>>>12,695872825),((t^t>>>15)>>>0)/4294967296},Nr=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2;function Hr(e,n){let t=e.ownerDocument.createElement("span");t.style.color=n,t.style.display="none",e.appendChild(t);let r=getComputedStyle(t).color;return t.remove(),r}var jr=e=>(e.match(/[\d.]+/g)?.slice(0,3)??["255","255","255"]).join(","),qr={slug:"texture/signal-field",summary:"Points jitter like static, then fall into a calm dot grid from the centre out.",props:{},params:{cols:{type:"number",default:36,min:16,max:60,step:1,unit:"columns",label:"Columns of the grid (rows follow the frame)"},settle_at:{type:"number",default:.6,min:0,max:4,step:.05,unit:"s",label:"When the noise starts to settle"},settle:{type:"number",default:1.2,min:.4,max:3,step:.05,unit:"s",label:"How long it takes to fall into the grid"},jitter:{type:"number",default:26,min:0,max:60,step:1,unit:"px",label:"How hard the static shakes"},glitch:{type:"number",default:.55,min:0,max:1,step:.05,unit:"ratio",label:"How often a glitch band tears the noise"},pulse:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Strength of the pulse that travels the grid once in order"},accent:{type:"number",default:.07,min:0,max:.2,step:.01,unit:"share",label:"Share of points in the accent colour"}},duration:(e,n)=>l(n.settle_at)+l(n.settle),build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=s/1080,u=r.fps||30;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let m=a.createElement("canvas");m.style.cssText=`position:absolute;left:0;top:0;width:${s}px;height:${i}px`,e.appendChild(m);let d=m.getContext("2d"),c=jr(Hr(e,"currentColor")),p=jr(Hr(e,"var(--m-accent)")),f=Math.max(2,Math.round(l(t.cols))),g=Math.max(2,Math.round(f*i/s)),b=f*g,h=Math.round(b*1.6),y=r.seed*7919,v=Math.hypot(s/2,i/2),E=l(t.accent),M=Array.from({length:h},(x,N)=>{let S=N%b,$=N+y,X=(S%f+.5)*(s/f),C=(Math.floor(S/f)+.5)*(i/g);return{x:Ee($,1)*s,y:Ee($,2)*i,vx:(Ee($,3)-.5)*40*o,vy:(Ee($,4)-.5)*24*o,gx:X,gy:C,d:Math.hypot(X-s/2,C-i/2)/v,r:(.7+Ee($,5)*1.5)*o,a:.18+Ee($,6)*.5,hot:Ee($,7)<E}}),k=l(t.settle_at),R=Math.max(.01,l(t.settle)),z=l(t.jitter)*o,L=l(t.glitch),j=l(t.pulse);return{seek(x){if(!d)return;let N=Math.round(x*u);Mt(m,d,r.size,r),d.clearRect(0,0,s,i);let S=Nr(Z((x-k)/R)),$=(1-S)**1.5,X=Math.floor(N/5)+y,C=Ee(X,11)*i,q=(20+Ee(X,12)*120)*o,P=(Ee(X,13)-.5)*140*o*$*(Ee(X,14)<L?1:0);for(let Y=0;Y<h;Y++){let K=M[Y],_=Y+y,ee=(K.x+K.vx*x+(Ee(_,N)-.5)*z*$)%s,A=(K.y+K.vy*x+(Ee(_,N+7777)-.5)*z*$)%i;ee<0&&(ee+=s),A<0&&(A+=i),A>C&&A<C+q&&(ee+=P);let O=Nr(Z(S*1.35-K.d*.35)),B=ve(ee,K.gx+Math.sin(x*.8+K.gy*.01)*2*o,O),W=ve(A,K.gy,O),H=Math.max(0,Math.sin(K.gy/i*7-x*3.2))**6*O*j,U=ve(.35+Ee(_,N+3)*.9,.55,O),G=ve(K.a*U*1.25,.17+H,O),Q=ve(K.r,1.05*o,O);d.fillStyle=`rgba(${K.hot?p:c},${Z(K.hot?G*1.6:G).toFixed(3)})`,d.fillRect(B-Q,W-Q,Q*2,Q*2)}}}}};var Zr={down:[0,1],up:[0,-1],right:[1,0],left:[-1,0]};function Ht(e,n,t){let r=t.ease("smooth")(e),a=Math.sin(Math.PI*Z(e))**2;return{travel:r,scale:1-l(n.pull)*a,tilt:l(n.tilt)*a,edge:a}}var Xr={slug:"transition/camera-travel",summary:"The camera pulls back and travels to the next scene, laid beside this one in one world.",duration:1.4,calm:{pull:.04,tilt:5,gap:0,shutter:.3},params:{duration:{type:"number",default:1.4,min:.8,max:2.4,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"down",options:["down","up","right","left"],label:"Where the next scene lies"},pull:{type:"number",default:.32,min:0,max:.6,step:.01,unit:"ratio",label:"How far the camera pulls back on the way"},tilt:{type:"number",default:14,min:0,max:30,step:1,unit:"deg",label:"How far the world leans while it travels"},gap:{type:"number",default:.18,min:0,max:.6,step:.01,unit:"of the frame",label:"Space between the two scenes"},shutter:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Motion blur: share of a frame the move smears over"}},apply(e,n,t,r,a){let[s,i]=a.size,[o,u]=Zr[F(r.direction)]??Zr.down,m=(u?i:s)*(1+l(r.gap)),d=Math.max(s,i)*2.2,c=(v,E)=>{let M=(E-v.travel)*m,k=u?`rotateX(${(u*v.tilt).toFixed(3)}deg) rotateZ(${(-.12*v.tilt).toFixed(3)}deg)`:`rotateY(${(-o*v.tilt).toFixed(3)}deg) rotateZ(${(.12*v.tilt).toFixed(3)}deg)`;return`perspective(${d}px) scale(${v.scale.toFixed(5)}) ${k} translate(${(o*M).toFixed(2)}px, ${(u*M).toFixed(2)}px)`},p=Ht(t,r,a);e.style.transform=c(p,0),n.style.transform=c(p,1);for(let v of[e,n])v.style.transformOrigin="50% 50%",v.style.borderRadius=`${(Math.min(s,i)*.03*p.edge).toFixed(2)}px`,v.style.boxShadow=p.edge>.01?`0 0 0 1px rgba(255,255,255,${(.08*p.edge).toFixed(3)}), 0 ${(60*p.edge).toFixed(1)}px ${(120*p.edge).toFixed(1)}px rgba(0,0,0,${(.5*p.edge).toFixed(3)})`:"";let f=.5/a.fps/l(r.duration),g=Ht(Z(t-f),r,a),h=(Ht(Z(t+f),r,a).travel-g.travel)*m*p.scale,y=ke(h,l(r.shutter));e.style.filter=Te(e,o?y:0,u?y:0),n.style.filter=Te(n,o?y:0,u?y:0)},clear(e){e.style.transform="",e.style.transformOrigin="",e.style.borderRadius="",e.style.boxShadow="",e.style.filter=""}};var ut=new WeakMap,Yr={slug:"transition/fly-past",summary:"The layers of a scene fly out past the camera, front first, revealing the next beneath.",duration:1.1,calm:{spread:.15,tumble:15,defocus:2},params:{duration:{type:"number",default:1.1,min:.6,max:1.8,step:.05,unit:"s",label:"Length of the hand-over"},spread:{type:"number",default:.35,min:0,max:.6,step:.01,unit:"ratio",label:"Share of the time between the first layer leaving and the last"},tumble:{type:"number",default:50,min:0,max:80,step:1,unit:"deg",label:"How far each layer turns away as it passes"},defocus:{type:"number",default:4,min:0,max:10,step:.5,unit:"px",label:"Blur as a layer reaches the lens"},settle:{type:"number",default:.05,min:0,max:.12,step:.005,unit:"ratio",label:"How much closer the next scene starts"}},apply(e,n,t,r,a){let[s,i]=a.size,o=Math.max(s,i)*1.6,u=e.getBoundingClientRect(),m=u.width>0?u.width/s:1,d=[...e.querySelectorAll(":scope > .m-cam > .m-layer")].filter(h=>h.style.visibility!=="hidden"),c=d.length,p=l(r.spread),f=1-p;d.forEach((h,y)=>{let v=c-1-y,E=c>1?v/(c-1)*p:0,M=Z((t-E)/f),k=M**2.3;if(M<=0)return;let R=h.getBoundingClientRect(),z=((R.left+R.width/2-u.left)/m-s/2)/(s/2),L=((R.top+R.height/2-u.top)/m-i/2)/(i/2),j=Math.hypot(z,L);j<.15?(z=.12,L=-1):(z/=j,L/=j);let x=Math.max(s,i)*.9*k,N=o*.82*k,S=l(r.tumble),$=`perspective(${o}px) translate3d(${(z*x).toFixed(2)}px, ${(L*x).toFixed(2)}px, ${N.toFixed(2)}px) rotateX(${(-L*S*k).toFixed(3)}deg) rotateY(${(z*S*k).toFixed(3)}deg) rotate(${((y%2?12:-12)*k).toFixed(3)}deg)`;h.style.transform=`${$} ${h.style.transform}`,h.style.opacity=String(Number(h.style.opacity||1)*(1-a.ease("smooth")(Z((M-.7)/.3))));let X=l(r.defocus)*k*k;X>.05&&(h.style.filter=`${h.style.filter} blur(${X.toFixed(2)}px)`.trim())});let g=a.ease("expo.out")(Z(t/.85));n.style.transformOrigin="50% 50%",n.style.transform=`scale(${(1+l(r.settle)*(1-g)).toFixed(4)})`,ut.has(e)||ut.set(e,{zIndex:e.style.zIndex,background:e.style.background,ground:getComputedStyle(e).backgroundColor}),e.style.zIndex=String((Number(n.style.zIndex)||0)+1);let b=1-a.ease("smooth")(Z(t/.45));e.style.background=b>.001?`color-mix(in srgb, ${ut.get(e).ground} ${(b*100).toFixed(2)}%, transparent)`:"transparent"},clear(e){e.style.transform="",e.style.transformOrigin="";let n=ut.get(e);n&&(e.style.zIndex=n.zIndex,e.style.background=n.background,ut.delete(e))}};var Tt=new WeakMap,Ur={slug:"transition/signal-wipe",summary:"A glowing accent line sweeps across and leaves the next scene behind it.",duration:.55,calm:{glow:.5,push:.01},params:{duration:{type:"number",default:.55,min:.35,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"down",options:["down","up","right","left"],label:"Which way the line travels"},glow:{type:"number",default:1,min:0,max:2,step:.05,unit:"ratio",label:"Strength of the glow and its trailing wash"},trail:{type:"number",default:.16,min:0,max:.4,step:.01,unit:"of the frame",label:"Length of the wash behind the line"},push:{type:"number",default:.04,min:0,max:.1,step:.005,unit:"ratio",label:"How much the outgoing scene grows as it is covered"}},apply(e,n,t,r,a){let[s,i]=a.size,o=F(r.direction)||"down",u=a.ease("quint.inOut")(Z(t)),m=o==="down"||o==="up",d=m?i:s,c=30,p=-c+u*(d+2*c),f=Z(p,0,d),g={down:`0 0 ${d-f}px 0`,up:`${d-f}px 0 0 0`,right:`0 ${d-f}px 0 0`,left:`0 0 0 ${d-f}px`}[o];n.style.clipPath=f>=d?"":`inset(${g})`,e.style.transformOrigin="50% 50%",e.style.transform=`scale(${(1+l(r.push)*u).toFixed(4)})`;let b=n.parentElement;if(!b)return;let h=Tt.get(n);if(!h){h=n.ownerDocument.createElement("div"),h.className="m-signal-line";let R=n.ownerDocument.createElement("div");h.appendChild(R),b.appendChild(h),Tt.set(n,h)}let y=l(r.glow),v=l(r.trail)*d,E=o==="down"||o==="right"?p:d-p,M={down:"to top",up:"to bottom",right:"to left",left:"to right"}[o],k=h.firstElementChild;h.style.cssText="position:absolute;z-index:999;pointer-events:none;background:color-mix(in srgb, var(--m-accent) 70%, white);"+(m?`left:0;right:0;height:2px;top:${(E-1).toFixed(2)}px;`:`top:0;bottom:0;width:2px;left:${(E-1).toFixed(2)}px;`)+`box-shadow:0 0 ${22*y}px ${5*y}px color-mix(in srgb, var(--m-accent) ${Math.round(55*Math.min(1,y))}%, transparent),0 0 4px 1px color-mix(in srgb, var(--m-accent) 40%, white);opacity:${t<=0||t>=1?0:1}`,k.style.cssText=`position:absolute;${m?`left:0;right:0;height:${v}px;`:`top:0;bottom:0;width:${v}px;`}`+{down:"bottom:2px;",up:"top:2px;",right:"right:2px;",left:"left:2px;"}[o]+`background:linear-gradient(${M}, color-mix(in srgb, var(--m-accent) ${Math.round(16*y)}%, transparent), transparent)`},clear(e){e.style.clipPath="",e.style.transform="",e.style.transformOrigin="",Tt.get(e)?.remove(),Tt.delete(e)}};var Vr={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},Gr={slug:"transition/whip-pan",summary:"The camera whips to the next scene with a streak along the pan only, then brakes.",duration:.5,calm:{anticipation:0,shutter:.3},params:{duration:{type:"number",default:.5,min:.3,max:.9,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"left",options:["left","right","up","down"],label:"Which way the frame travels"},anticipation:{type:"number",default:.03,min:0,max:.08,step:.005,unit:"of the frame",label:"How far it pulls back before it goes"},shutter:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Motion blur: share of a frame the whip smears over"}},apply(e,n,t,r,a){let[s,i]=a.size,[o,u]=Vr[F(r.direction)]??Vr.left,m=o?s:i,d=l(r.anticipation)*m,c=a.ease("expo.inOut"),p=v=>(v<.3?-d*Math.sin(Math.PI*Z(v/.3)):0)+m*c(Z((v-.12)/.88)),f=.5/(a.fps||30)/l(r.duration),g=p(Z(t+f))-p(Z(t-f)),b=p(t);e.style.transform=`translate(${(o*b).toFixed(2)}px, ${(u*b).toFixed(2)}px)`,n.style.transform=`translate(${(o*(b-m)).toFixed(2)}px, ${(u*(b-m)).toFixed(2)}px)`;let h=ke(g,l(r.shutter)),y=h;e.style.filter=Te(e,o?h:0,u?h:0,90),n.style.filter=Te(n,o?y:0,u?y:0,90)},clear(e){e.style.transform="",e.style.filter=""}};function Si(e,n){let t=n+(1-n)*.55,r=Z(e);return r<.5?n+(t-n)*r*2:t+(1-t)*(r-.5)*2}function Ai(e,n,t){let r=Math.max(1,t),a=Z(n)*(e-1+r);return Array.from({length:e},(s,i)=>Z((a-i)/r))}var Kr={slug:"type/fill-text",summary:"The whole line is there, dim; each word fills to full in reading order.",props:{text:{type:"string",required:!0,label:"The text. Use \\n to set the line breaks yourself."},accent:{type:"string[]",default:[],label:"Words that fill to the accent colour"}},params:{duration:{type:"number",default:1.7,min:.4,max:4,step:.05,unit:"s",label:"Time for the whole fill"},dim:{type:"number",default:.35,min:0,max:.6,step:.01,unit:"opacity",label:"How dim the words wait (0: unseen, so the text streams in)"},blur:{type:"number",default:0,min:0,max:6,step:.1,unit:"px",label:"Soft focus a word fills out of"},rise:{type:"number",default:0,min:0,max:12,step:.5,unit:"px",label:"How far a word rises as it fills"},word_ease:{type:"ease",default:"linear",label:"Pace of each word's own fill"},soft:{type:"number",default:1.5,min:1,max:8,step:.1,unit:"words",label:"How many words fill at once"},ease:{type:"ease",default:"smooth",label:"Pace of the fill along the line"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let{words:a}=Se(e,F(n.text),{accent:te(n.accent)}),s=a.map(g=>{let b=/^\{(.+)\}([^\p{L}\p{N}]*)$/u.exec(g.textContent??"");return b?(g.textContent=b[1],g.style.cssText+=";padding:0 0.38em;margin:0 0.05em;border-radius:999px;font-size:0.62em;line-height:1.55;vertical-align:0.18em;font-weight:600;color:var(--m-accent);background:color-mix(in srgb, var(--m-accent) 16%, transparent)",!0):!1}),i=r.ease(t.ease),o=r.ease(t.word_ease),u=r.ease("bounce.out"),m=Math.max(.001,l(t.duration)),d=l(t.dim),c=l(t.soft),p=l(t.blur),f=l(t.rise);return{seek(g){let b=Ai(a.length,i(Z(g/m)),c);a.forEach((h,y)=>{let v=o(b[y]);if(s[y]){let M=Z(v*3);h.style.opacity=M>=1?"":M.toFixed(4),h.style.transform=v>=1?"":`scale(${(.5+.5*u(v)).toFixed(4)})`;return}let E=Si(v,d);h.style.opacity=E>=1?"":E.toFixed(4),h.style.filter=p>0&&v<1?`blur(${((1-v)*p).toFixed(3)}px)`:"",h.style.transform=f>0&&v<1?`translateY(${((1-v)*f).toFixed(3)}px)`:""})}}}};function Ci(e,n){let t=Z(e),r=Math.max(1,n.from+(n.to-n.from)*t),a=(r-1)/2,s=i=>Z(i/100*(t-.5),-a,a);return{scale:r,x:s(n.pan_x),y:s(n.pan_y)}}var Jr={slug:"fx/slow-push",summary:"A still picture in a fixed frame slowly pushes in, pulls out or pans while it is held.",props:{src:{type:"string",required:!0,label:"Image path or URL"},alt:{type:"string",default:"",label:"Description of the picture"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Frame width"},height:{type:"number",default:800,min:1,max:4e3,step:1,unit:"px",label:"Frame height"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"},from:{type:"number",default:1.08,min:1,max:1.6,step:.01,unit:"\xD7",label:"Scale at the start"},to:{type:"number",default:1,min:1,max:1.6,step:.01,unit:"\xD7",label:"Scale at the end"},pan_x:{type:"number",default:0,min:-30,max:30,step:.5,unit:"% of frame",label:"Sideways travel over the move",pad:{name:"pan",axis:"x"}},pan_y:{type:"number",default:0,min:-30,max:30,step:.5,unit:"% of frame",label:"Vertical travel over the move",pad:{name:"pan",axis:"y"}},focus_x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of picture",label:"Point of the picture to keep in frame, across",pad:{name:"focus",axis:"x"}},focus_y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of picture",label:"Point of the picture to keep in frame, down",pad:{name:"focus",axis:"y"}},duration:{type:"number",default:4,min:.5,max:30,step:.1,unit:"s",label:"Length of the move"},ease:{type:"ease",default:"linear",label:"Curve of the move; linear reads as drift, sine.inOut as a camera that starts and settles"}},cues:()=>[],duration:(e,n)=>l(n.duration,4),build(e,n,t,r){let a=e.ownerDocument.createElement("img");a.src=F(n.src),a.alt=F(n.alt),a.decoding="sync",e.style.cssText+=`;width:${l(t.width)}px;height:${l(t.height)}px;border-radius:${l(t.radius)}px;overflow:hidden`;let s=`${l(t.focus_x,50)}% ${l(t.focus_y,50)}%`;a.style.cssText=`display:block;width:100%;height:100%;object-fit:cover;object-position:${s};transform-origin:${s};will-change:transform`,e.appendChild(a);let i=r.ease(t.ease),o=l(t.duration,4),u={from:l(t.from,1.08),to:l(t.to,1),pan_x:l(t.pan_x),pan_y:l(t.pan_y)};return{seek(m){let d=Ci(i(Z(m/o)),u);a.style.transform=`translate(${(d.x*100).toFixed(4)}%, ${(d.y*100).toFixed(4)}%) scale(${d.scale.toFixed(5)})`}}}};function Qr(e,n,t=1){let[r,a]=e,s=Math.max(.01,n),i=Math.max(1,t);if(s>=r/a){let m=a*i,d=m*s;return{axis:"x",w:d,h:m,spare:Math.max(0,d-r)}}let o=r*i,u=o/s;return{axis:"y",w:o,h:u,spare:Math.max(0,u-a)}}function Pi(e,n=200){let t=0;for(let r=0;r<n;r++)t=Math.max(t,Math.abs(e((r+1)/n)-e(r/n))*n);return t}function Ri(e,n,t,r,a){return Math.abs(t-n)/100*e.spare*Pi(a)/Math.max(.01,r)}var _r=(e,n)=>[l(e.width)||n[0],l(e.height)||n[1]],ea={slug:"fx/pan-across",summary:"The camera travels along a picture wider or taller than its frame.",props:{src:{type:"string",required:!0,label:"Image path or URL"},alt:{type:"string",default:"",label:"Description of the picture"}},params:{width:{type:"number",default:0,min:0,max:4e3,step:1,unit:"px",label:"Frame width; 0 is the stage"},height:{type:"number",default:0,min:0,max:4e3,step:1,unit:"px",label:"Frame height; 0 is the stage"},aspect:{type:"number",default:1.78,min:.2,max:6,step:.01,unit:"w \xF7 h",label:"The picture's width over its height"},from:{type:"number",default:20,min:0,max:100,step:1,unit:"% of travel",label:"Where the view starts: 0 one end of the picture, 100 the other"},to:{type:"number",default:80,min:0,max:100,step:1,unit:"% of travel",label:"Where the view ends"},scale:{type:"number",default:1,min:1,max:1.3,step:.01,unit:"\xD7",label:"Extra size, to leave room across the travel"},duration:{type:"number",default:4,min:.5,max:30,step:.1,unit:"s",label:"Length of the travel"},ease:{type:"ease",default:"sine.inOut",label:"Curve of the travel: sine.inOut starts and settles like a camera"}},cues:()=>[],duration:(e,n)=>l(n.duration,4),speed(e,n,t){let r=Qr(_r(n,t.size),l(n.aspect,1.78),l(n.scale,1));return Ri(r,l(n.from,20),l(n.to,80),l(n.duration,4),Re(n.ease??"sine.inOut"))},build(e,n,t,r){let[a,s]=_r(t,r.size),i=Qr([a,s],l(t.aspect,1.78),l(t.scale,1)),o=e.ownerDocument.createElement("img");o.src=F(n.src),o.alt=F(n.alt),o.decoding="sync",e.style.cssText+=`;position:relative;width:${a}px;height:${s}px;overflow:hidden`;let u=i.axis==="x"?(s-i.h)/2:(a-i.w)/2;o.style.cssText=`position:absolute;left:0;top:0;display:block;width:${i.w}px;height:${i.h}px;object-fit:cover;max-width:none;will-change:transform`,e.appendChild(o);let m=r.ease(t.ease),d=l(t.duration,4),c=l(t.from,20),p=l(t.to,80);return{seek(f){let g=-i.spare*((c+(p-c)*m(Z(f/d)))/100),[b,h]=i.axis==="x"?[g,u]:[u,g];o.style.transform=`translate3d(${b.toFixed(3)}px, ${h.toFixed(3)}px, 0)`}}}};function zi(e,n){let t=e.slice(1).map((a,s)=>Math.sqrt(Math.abs(a-e[s]))),r=t.reduce((a,s)=>a+s,0);return t.map(a=>r>0?n*a/r:n/t.length)}function Oi(e,n,t){let r=[n.from,...n.stops,n.to],a=r.length-1,s=a>1?Math.min(n.rest,n.duration*.5/(a-1)):0,i=zi(r,n.duration-s*(a-1)),o=e-n.delay;if(o<=0)return r[0];for(let u=0;u<a;u++){let m=i[u];if(o<m)return r[u]+(r[u+1]-r[u])*t(Z(o/m));if(o-=m,u<a-1){if(o<s)return r[u+1];o-=s}}return r[a]}var ta=(e,n)=>({from:l(n.from),to:l(n.to,100),stops:ge(e.stops),duration:l(n.duration,3),rest:l(n.rest,.4),delay:l(n.delay)}),jt=150,na={slug:"ui/page-scroll",summary:"A page scrolls inside a window, resting on its sections, blurred only by its own speed.",props:{srcs:{type:"string[]",required:!0,label:"The page: one tall capture, or its sections from top to bottom"},alt:{type:"string",default:"",label:"Description of the page"},stops:{type:"number[]",default:[],label:"Where the scroll rests on the way, in % of the scrollable height"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Window width"},height:{type:"number",default:800,min:1,max:4e3,step:1,unit:"px",label:"Window height"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"},from:{type:"number",default:0,min:0,max:100,step:.5,unit:"% of scroll",label:"Where the scroll starts"},to:{type:"number",default:100,min:0,max:100,step:.5,unit:"% of scroll",label:"Where the scroll ends"},duration:{type:"number",default:3,min:.4,max:30,step:.05,unit:"s",label:"Length of the scroll, rests included"},rest:{type:"number",default:.4,min:0,max:3,step:.05,unit:"s",label:"Time resting at each stop"},delay:{type:"number",default:0,min:0,max:30,step:.05,unit:"s",label:"Time held at the start before it scrolls"},ease:{type:"ease",default:"sine.inOut",label:"Curve of each leg"},shutter:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Motion blur: share of a frame the scroll smears over"}},duration:(e,n)=>{let t=ta(e,n);return t.delay+t.duration},build(e,n,t,r){let a=e.ownerDocument,s=l(t.width),i=l(t.height);e.style.cssText+=`;width:${s}px;height:${i}px;border-radius:${l(t.radius)}px;overflow:hidden`;let o=a.createElement("div");o.style.cssText=`position:relative;width:${s}px;height:${i}px`;let u=a.createElement("div");u.style.cssText=`position:absolute;left:0;top:${-jt}px;width:${s}px;height:${i+2*jt}px;overflow:hidden`;let m=a.createElement("div");m.style.cssText=`position:absolute;left:0;top:${jt}px;width:${s}px;will-change:transform`,te(n.srcs).forEach((g,b)=>{let h=a.createElement("img");h.src=g,h.alt=b===0?F(n.alt):"",h.decoding="sync",h.style.cssText="display:block;width:100%;height:auto",m.appendChild(h)}),u.appendChild(m),o.appendChild(u),e.appendChild(o);let d=ta(n,t),c=r.ease(t.ease),p=l(t.shutter,.5),f=.5/r.fps;return{seek(g){let b=Math.max(0,m.offsetHeight-i),h=y=>Oi(y,d,c)/100*b;m.style.transform=`translateY(${(-h(g)).toFixed(2)}px)`,u.style.filter=Te(u,0,ke(h(g+f)-h(g-f),p))}}}};var Di=["down","up","center","edges","random"],Li=["left","right","alternate","weave"],Ii=["none","start","end","both"];function Et(e,n){let t=Array.from({length:e},(r,a)=>a);return(n==="start"||n==="both")&&t.unshift(null),(n==="end"||n==="both")&&t.push(null),t}var Bi=.6;function Wi(e,n,t,r,a=1){let s=Me(e,t,Ni(r),a),i=Math.max(0,...s),o=Bi*n,u=i>o?o/i:1;return{delays:s.map(m=>m*u),travel:n-i*u}}var Ni=e=>e==="down"?"start":e==="up"?"end":e;function qt(e,n,t){let r=Math.max(1,e),a=o=>typeof n=="number"?n:n[o]??n[n.length-1]??0,s=[],i=0;for(let o=0;o<r-1;o++)i+=a(o),s.push(i),i+=t;return{changes:s,change:t,duration:i+a(r-1)}}var Zt=(e,n,t)=>e.map(r=>r===null&&t>0?t:n);function Hi(e,n,t){return e==="left"?1:e==="right"?-1:(e==="weave"?n+t:n)%2===0?1:-1}function ji(e,n,t,r,a,s){let i=t[r]??0;for(let u=0;u<n.changes.length;u++){let m=n.changes[u]+i;if(e<m)return{from:u,to:u,u:0};if(e<m+a)return{from:u,to:u+1,u:s(Z((e-m)/a))}}let o=n.changes.length;return{from:o,to:o,u:0}}var ra={slug:"scene/strip-cycle",summary:"Pictures change strip by strip across a ruled grid, each change led by a field of colour.",props:{images:{type:"string[]",required:!0,label:"Pictures, in the order they fill the frame"},fills:{type:"string[]",default:["accent"],label:"Colours that lead each change, in turn (surface names or CSS colours)"},rule:{type:"string",default:"var(--m-text-primary)",label:"Colour of the rules"}},params:{rows:{type:"number",default:8,min:2,max:16,step:1,unit:"strips",label:"Strips in the grid"},width:{type:"number",default:100,min:20,max:100,step:1,unit:"% of stage",label:"Frame width"},height:{type:"number",default:100,min:20,max:100,step:1,unit:"% of stage",label:"Frame height"},hold:{type:"number",default:1.2,min:.3,max:6,step:.05,unit:"s",label:"Time each picture stays whole"},ground_hold:{type:"number",default:0,min:0,max:6,step:.05,unit:"s",label:"Time the bare ground holds at a start or end (0: as long as a picture)"},shift:{type:"number",default:1,min:.3,max:2.5,step:.05,unit:"s",label:"Time one change takes, first strip to last"},stagger:{type:"number",default:.05,min:0,max:.3,step:.01,unit:"s",label:"Delay between strips"},order:{type:"choice",default:"down",options:Di,label:"Which strips change first"},direction:{type:"choice",default:"left",options:Li,label:"Which way the strips run: left is forward, in the reading direction"},lead:{type:"number",default:.35,min:0,max:1,step:.01,unit:"\xD7 frame width",label:"Length of the colour field ahead of the picture"},drag:{type:"number",default:.12,min:0,max:.5,step:.01,unit:"\xD7 frame width",label:"How far the leaving picture is pushed along"},push:{type:"number",default:1.06,min:1,max:1.3,step:.01,unit:"\xD7",label:"Scale a picture arrives at, settling to 1 while it is seen"},rule_width:{type:"number",default:2,min:0,max:12,step:.5,unit:"px",label:"Weight of the rules (0 for none)"},rule_opacity:{type:"number",default:.6,min:0,max:1,step:.05,unit:"ratio",label:"Opacity of the rules"},edges:{type:"boolean",default:!1,label:"Rule the top and bottom edges too"},empty:{type:"choice",default:"none",options:Ii,label:"Begin and/or end on the bare ruled ground"},ease:{type:"ease",default:"quart.inOut",label:"Curve of each strip"}},duration(e,n){let t=Et(te(e.images).length,F(n.empty,"none"));return qt(t.length,Zt(t,l(n.hold,1.2),l(n.ground_hold,0)),l(n.shift,1)).duration},cues(e,n){let t=Et(te(e.images).length,F(n.empty,"none")),r=qt(t.length,Zt(t,l(n.hold,1.2),l(n.ground_hold,0)),l(n.shift,1));return r.changes.map(a=>({at:a,length:r.change}))},check(e,n){let t=[];return te(e.images).length||t.push({path:"props.images",message:"The strips need at least one picture.",hint:"Add picture paths to images."}),Et(te(e.images).length,F(n.empty,"none")).length<2&&t.push({path:"props.images",message:"With one picture and no empty ground, nothing ever changes.",hint:"Add a picture, or set empty to start, end or both."}),t},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=Math.round(s*l(t.width,100)/100),u=Math.round(i*l(t.height,100)/100),m=Math.round(l(t.rows,8)),d=te(n.images),c=te(n.fills).length?te(n.fills):["accent"],p=Et(d.length,F(t.empty,"none")),f=l(t.shift,1),g=l(t.hold,1.2),b=l(t.lead,.35),h=l(t.drag,.12),y=l(t.push,1.06),v=F(t.order,"down"),E=F(t.direction,"left"),{delays:M,travel:k}=Wi(m,f,l(t.stagger,.05),v,r.seed),R=qt(p.length,Zt(p,g,l(t.ground_hold,0)),f),z=r.ease(t.ease),L=C=>["base","surface","sunken","accent","inverse"].includes(C)?`var(--m-bg-${C})`:C;e.style.cssText+=`;width:${o}px;height:${u}px;position:relative;overflow:hidden`;let j=Array.from({length:m+1},(C,q)=>Math.round(q*u/m)),x=p.map((C,q)=>{let P=q===0?0:R.changes[q-1],Y=q===p.length-1?R.duration:R.changes[q]+R.change;return[P,Math.max(P+1e-6,Y)]}),N=j.slice(0,-1).map((C,q)=>{let P=j[q+1]-C,Y=a.createElement("div");Y.style.cssText=`position:absolute;left:0;top:${C}px;width:${o}px;height:${P}px;overflow:hidden`;let K=p.map((_,ee)=>{let A=a.createElement("div");A.style.cssText=`position:absolute;left:0;top:0;width:${o}px;height:${P}px;visibility:hidden;will-change:transform`;let O=a.createElement("div"),B=L(c[Math.max(0,ee-1)%c.length]);O.style.cssText=`position:absolute;top:0;height:${P}px;width:${Math.ceil(o*b)+1}px;background:${B}`,A.appendChild(O);let W;if(_!==null){let H=a.createElement("div");H.style.cssText=`position:absolute;left:0;top:0;width:${o}px;height:${P}px;overflow:hidden`,W=a.createElement("img"),W.src=d[_],W.alt="",W.decoding="sync",W.style.cssText=`position:absolute;left:0;top:${-C}px;width:${o}px;height:${u}px;object-fit:cover;transform-origin:${o/2}px ${u/2}px;max-width:none`,H.appendChild(W),A.appendChild(H)}return Y.appendChild(A),{box:A,img:W,field:O}});return e.appendChild(Y),{panes:K,h:P}}),S=l(t.rule_width,2);if(S>0){let C=t.edges?0:1,q=t.edges?m:m-1;for(let P=C;P<=q;P++){let Y=Math.min(u-S,Math.max(0,j[P]-S/2)),K=a.createElement("div");K.style.cssText=`position:absolute;left:0;top:${Y}px;width:${o}px;height:${S}px;background:${F(n.rule,"var(--m-text-primary)")};opacity:${l(t.rule_opacity,.6)};pointer-events:none`,e.appendChild(K)}}let $=Math.ceil(o*b)+1,X=(C,q,P,Y,K,_="",ee=!1)=>{if(C.box.style.visibility="inherit",C.field.style.visibility=ee?"inherit":"hidden",C.box.style.transform=`translate3d(${q.toFixed(2)}px,0,0)`,C.box.style.clipPath=_,C.field.style.left=P===1?`${-$+1}px`:`${o-1}px`,C.img){let[A,O]=x[K],B=Z((Y-A)/(O-A));C.img.style.transform=`scale(${(y+(1-y)*B).toFixed(5)})`}};return{seek(C){N.forEach(({panes:q},P)=>{let{from:Y,to:K,u:_}=ji(C,R,M,P,k,z);if(q.forEach(H=>{H.box.style.visibility="hidden"}),Y===K){X(q[Y],0,1,C,Y);return}let ee=Hi(E,P,Y),A=o*(1+b),O=ee*A*(1-_),B=-ee*h*o*_,W=ee===1?Math.max(0,B+o-(O-$+1)):Math.max(0,O+o+$-1-B);X(q[Y],B,ee,C,Y,ee===1?`inset(0 ${W.toFixed(2)}px 0 -${$}px)`:`inset(0 -${$}px 0 ${W.toFixed(2)}px)`),X(q[K],O,ee,C,K,"",!0)})}}}};var aa="bands",ia=["var(--m-bg-accent)","var(--m-bg-inverse)","var(--m-bg-surface)","var(--m-bg-sunken)"],Xt=e=>`var(--m-band-${e%6+1}, ${ia[e%ia.length]})`;function qi(e,n){return Array.from({length:e},(t,r)=>{let a=r%2===0?1:-1,s=1-.55*(r*7%e)/Math.max(1,e);return a*n*s})}function Zi(e,n,t,r){let a=n/Math.max(1,e);if(r===0)return a+1;let s=Math.tan(Math.abs(r)*2*Math.PI/180)*t*.5;return a+s+a*.2}function Xi(e,n,t,r,a){let s=Math.max(.05,.5-(t-1)*r),i=a(Z((e-n*r)/s)),o=a(Z((e-.5-n*r)/s)),u=Math.min(Z((e-n*r-s*.35)/(.5-n*r-s*.35)),1-Z((e-.5)/(s*.65)));return{lead:i,trail:o,swell:a(Z(u))}}var sa={slug:"transition/band-sweep",summary:"Bands of colour run across the frame at angles, swell to cover the cut, then run on.",duration:1,calm:{angle:6,lag:.03},params:{duration:{type:"number",default:1,min:.5,max:2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"left",options:["left","right","up","down"],label:"Which way the bands run"},bands:{type:"number",default:5,min:2,max:8,step:1,unit:"bands",label:"Bands across the frame"},width:{type:"number",default:9,min:2,max:30,step:.5,unit:"% of frame",label:"Thickness of a band as it enters"},angle:{type:"number",default:14,min:0,max:30,step:.5,unit:"deg",label:"Largest tilt of a band"},lag:{type:"number",default:.05,min:0,max:.09,step:.005,unit:"ratio",label:"How far each band trails the one before"}},apply(e,n,t,r,a){let s=Math.max(2,Math.round(l(r.bands,5))),i=Math.min(l(r.lag,.05),.45/(s-1)),o=F(r.direction,"left"),[u,m]=a.size,d=o==="left"||o==="right",c=d?u:m,p=d?m:u,f=qi(s,l(r.angle,14)),g=l(r.width,9)/100*Math.min(u,m),b=Math.max(g,Zi(s,p,c,l(r.angle,14))),h=Math.hypot(u,m)*1.25,y=a.ease("quart.inOut"),v=o==="left"||o==="up"?-1:1;Oe(e,aa,s).forEach((R,z)=>{let{lead:L,trail:j,swell:x}=Xi(t,z,s,i,y),N=g+(b-g)*x,S=(z+.5)/s*p,$=d?u/2:S,X=d?S:m/2,C=(d?0:90)+f[z];R.style.background=Xt(z),R.style.inset="auto",R.style.left=`${($-h/2).toFixed(2)}px`,R.style.top=`${(X-N/2).toFixed(2)}px`,R.style.width=`${h.toFixed(2)}px`,R.style.height=`${N.toFixed(2)}px`;let q=L*100,P=j*100;R.style.clipPath=v<0?`inset(0 ${P.toFixed(3)}% 0 ${(100-q).toFixed(3)}%)`:`inset(0 ${(100-q).toFixed(3)}% 0 ${P.toFixed(3)}%)`,R.style.transform=`rotate(${C.toFixed(3)}deg)`,R.style.visibility=L<=0||j>=1?"hidden":"visible"});let M=t>=.5;e.style.opacity=M?"0":"1",n.style.opacity=M?"1":"0";let k=y(Z((t-.5)/.5));n.style.transform=M?`scale(${(1.03-.03*k).toFixed(4)})`:"",e.style.transform=M?"":`scale(${(1+.02*y(Z(t/.5))).toFixed(4)})`},clear(e){De(e,aa),e.style.transform="",e.style.opacity=""}};var oa="strips",Yi=["band-1","band-2","band-3","band-4","band-5","band-6","accent","inverse","surface","sunken"],Ui=e=>/^band-[1-6]$/.test(e)?Xt(Number(e.slice(5))-1):Ye(e),Vi=(e,n)=>Math.min(Math.max(0,n),.5/Math.max(1,e-1));function Yt(e,n,t,r,a,s){let i=a==="up"?t-1-n:a==="centre"?Math.abs(n-(t-1)/2)*2:n,o=Math.max(.05,1-(t-1)*r);return s(Z((e-i*r)/o))}function Gi(e,n,t){let r=n-e*(n+t);return{front:r,back:r+t}}function Ki(e,n,t,r,a){if(a.mode==="cover"){if(e<.5){let m=Yt(e*2,n,t,a.lag,a.order,a.ease);return{field:[r-m*r,r],shown:null}}let o=Yt(e*2-1,n,t,a.lag,a.order,a.ease),u=r-o*r;return{field:[0,u],shown:u<r?[u,r]:null}}let{front:s,back:i}=Gi(Yt(e,n,t,a.lag,a.order,a.ease),r,a.field);return{field:[s,i],shown:i<r?[Math.max(0,i),r]:null}}var la={slug:"transition/strip-wipe",summary:"The next scene arrives row by row, each row led by a field of colour.",duration:1,params:{duration:{type:"number",default:1,min:.5,max:2,step:.05,unit:"s",label:"Length of the hand-over"},mode:{type:"choice",default:"lead",options:["lead","cover"],label:"lead: a field of colour runs ahead of the next scene; cover: colour covers the frame, then uncovers the next scene"},direction:{type:"choice",default:"left",options:["left","right"],label:"Which way the strips run: left enters from the right"},alternate:{type:"boolean",default:!1,label:"Every other row runs the other way, like strands woven across"},rows:{type:"number",default:8,min:2,max:16,step:1,unit:"rows",label:"Strips across the frame: the rows of the grid"},order:{type:"choice",default:"down",options:["down","up","centre"],label:"Which row goes first"},stagger:{type:"number",default:.04,min:0,max:.1,step:.005,unit:"ratio",label:"How far each row trails the one before, as a share of the hand-over"},lead:{type:"number",default:.35,min:.05,max:1,step:.01,unit:"\xD7 frame width",label:"Length of the colour field ahead of the next scene"},colour:{type:"choice",default:"band-1",options:Yi,label:"Colour of the field: a band of the palette (--m-band-1 \u2026) or a surface"}},apply(e,n,t,r,a){let[s,i]=a.size,o=Math.max(2,Math.round(l(r.rows,8))),u={mode:F(r.mode,"lead"),field:Math.ceil(l(r.lead,.35)*s),lag:Vi(o,l(r.stagger,.04)),order:F(r.order,"down"),ease:a.ease(F(r.mode,"lead")==="cover"?"cubic.inOut":"quart.inOut")},m=F(r.direction,"left")!=="right",d=r.alternate===!0,c=Ui(F(r.colour,"band-1")),p=Oe(e,oa,o),f=[];for(let g=0;g<o;g++){let b=Math.floor(g/o*i),h=Math.min(i,Math.ceil((g+1)/o*i)+1),y=Ki(t,g,o,s,u),v=d&&g%2===1?m:!m,E=([j,x])=>v?[s-x,s-j]:[j,x],[M,k]=E(y.field),R=p[g],z=Math.max(0,M),L=Math.min(s,k);if(R.style.inset="auto",R.style.left=`${z.toFixed(2)}px`,R.style.top=`${b}px`,R.style.width=`${Math.max(0,L-z).toFixed(2)}px`,R.style.height=`${h-b}px`,R.style.background=c,R.style.visibility=L>z?"visible":"hidden",y.shown){let[j,x]=E(y.shown);x>j&&f.push(`M${Math.max(0,j).toFixed(2)} ${b}H${Math.min(s,x).toFixed(2)}V${h}H${Math.max(0,j).toFixed(2)}Z`)}}e.style.opacity="1",n.style.opacity=f.length?"1":"0",n.style.zIndex="2",e.style.zIndex="1",n.style.clipPath=t>=1?"":f.length?`path('${f.join(" ")}')`:""},clear(e){De(e,oa),e.style.clipPath="",e.style.zIndex="",e.style.opacity=""}};var ua=e=>Object.fromEntries(e.map(n=>[n.slug,n])),Ie=ua([un,nn,on,an,mn,sn,ln,Ln,On,zn,dn,pn,cn,xn,fn,Sn,Mr,wr,yr,Sr,$r,Er,vr,Tr,Wn,Hn,Yn,In,Jn,Un,Vn,Qn,_n,er,nr,ar,Cr,Kr,qr,zr,Wr,Ir,Rr,yn,Jr,ea,na,kn,$n,ra]),Ae=ua([An,Cn,Pn,hr,mr,sr,ur,lr,br,fr,Xr,Gr,Ur,Yr,sa,la]);var Qe=["x","y","scale","rotate","opacity","blur","rotateX","rotateY","skew"],_e=["fade","rise","drop","scale","blur","slide-left","slide-right","zoom","pop","focus","mask-up","mask-down","wipe-up","wipe-down","wipe-left","wipe-right","swing","slot-up","wipe","slide","pop-check"],ma=["wipe","slide"],mt=["hero","headline","title","body","caption"],dt=["primary","secondary","muted","accent","inverse","on-accent"],ct=["center","top-left","top","top-right","left","right","bottom-left","bottom","bottom-right"],da=["%","px"],Ut=["cover","contain","width","height"],ca=["base","surface","sunken","accent","inverse"],Vt=["zero","graphite","hockney"];var ha=/^\s*(\d+(?:\.\d+)?)\s*(b|beats?|bars?)\s*$/,Ce=e=>typeof e=="string"&&ha.test(e),pa=e=>60/e.bpm;function fa(e,n){let t=ha.exec(e);if(!t)return;let r=Number(t[1]);return t[2].startsWith("bar")?r*n.bar*pa(n):r*pa(n)}var ga=(e,n)=>n*60/e.bpm;function ba(e,n,t=3){let r=[];for(let a=1;a<=n*2;a++){let s=n*60/a;s>=40&&s<=240&&Number.isInteger(Math.round(s*1e3)/1e3)&&r.push(Math.round(s*1e3)/1e3)}return r.sort((a,s)=>Math.abs(a-e)-Math.abs(s-e)).slice(0,t)}var xa=/^[a-z][a-z0-9-]*$/;function ya(e,n){let t=`Give the ${n} an id: lower-case letters, digits and dashes, starting with a letter.`;if(typeof e!="string"||e==="")return`${t} It has none.`;if(n==="layer"&&e==="scene")return'"scene" cannot be a layer id: times use "scene.end" for the scene itself.';if(/^[0-9]/.test(e))return`The ${n} id "${e}" starts with a digit. ${t}`;if(/[A-Z]/.test(e))return`The ${n} id "${e}" has capital letters. ${t}`;let r=[...new Set(e.replace(/[a-z0-9-]/g,""))].map(a=>a===" "?"a space":`"${a}"`);return`The ${n} id "${e}" contains ${r.join(", ")}. ${t}`}function wa(e,n,t){if(typeof e!="string"||e===""||e==="scene")return t;let r=e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"");return/^[0-9]/.test(r)&&(r=`${n}-${r}`),r&&r!==e?`For example "${r}".`:t}var fe=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ce=e=>typeof e=="number"&&Number.isFinite(e),Ji=["$schema","motion","title","size","fps","seed","poster","loop","narrative","style","tokens","tempo","audio","theme","scenes"],Qi=["id","length","hold","background","scheme","layout","artboard","layers","tracks","follow","camera","perspective","motionBlur","out","uses","intent"],$t=["fx/path-draw"],_i=["id","use","props","params","at","style","place","enter","exit","tracks","motionBlur","parallax","screen","taps","reflow"],es=["size","color","font","weight","align","width","css"],ts={fade:0,rise:40,drop:40,scale:.08,blur:16,"slide-left":120,"slide-right":120,zoom:.12,pop:.5,focus:24,"mask-up":0,"mask-down":0,"wipe-up":0,"wipe-down":0,"wipe-left":0,"wipe-right":0,swing:70,"slot-up":48,wipe:0,slide:120,"pop-check":.65},ns={pop:{enter:{spring:{duration:.5,bounce:.35}},exit:"back.in"},"mask-up":{enter:"expressive.out",exit:"expressive.in"},"slot-up":{enter:"cubic.out",exit:"cubic.in"},"mask-down":{enter:"expressive.out",exit:"expressive.in"},"wipe-up":{enter:"quart.inOut",exit:"quart.inOut"},"wipe-down":{enter:"quart.inOut",exit:"quart.inOut"},"wipe-left":{enter:"quart.inOut",exit:"quart.inOut"},"wipe-right":{enter:"quart.inOut",exit:"quart.inOut"},wipe:{enter:"quart.inOut",exit:"quart.inOut"},swing:{enter:{spring:{duration:.6,bounce:.2}},exit:"cubic.in"},"pop-check":{enter:"bounce.out",exit:"back.in"}};function rs(e,n){let t=Array.from({length:n.length+1},(r,a)=>a);for(let r=1;r<=e.length;r++){let a=t[0];t[0]=r;for(let s=1;s<=n.length;s++){let i=t[s];t[s]=Math.min(t[s]+1,t[s-1]+1,a+(e[r-1]===n[s-1]?0:1)),a=i}}return t[n.length]}function Fe(e,n){let t,r=1/0;for(let a of n){let s=rs(e,a);s<r&&(t=a,r=s)}return t!==void 0&&r<=Math.max(2,Math.floor(e.length/3))?t:void 0}var we=e=>e.join(", ");function Gt(e){let n=[],t=(x,N,S,$)=>n.push({level:"error",code:N,path:x,message:S,...$?{hint:$}:{}}),r=(x,N,S,$)=>n.push({level:"warning",code:N,path:x,message:S,...$?{hint:$}:{}}),a=(x,N)=>{let S=!n.some($=>$.level==="error");return{ok:S,issues:n,tokens:x,...S&&N?{timeline:N}:{}}},s=(x,N,S)=>{for(let $ of Object.keys(x)){if(N.includes($))continue;let X=Fe($,N);t(S?`${S}.${$}`:$,"unknown-key",`"${$}" is not a field here.`,X?`Did you mean "${X}"?`:`Fields: ${we(N.filter(C=>C!=="$schema"))}.`)}};if(!fe(e))return t("","not-a-film","A film is a JSON object."),a(et());let i=e;s(e,Ji,""),typeof i.motion!="string"&&t("motion","missing","State the library version the film is written for.",'Add "motion": "0.4".');let o=i.size,u=Array.isArray(o)&&o.length===2&&o.every(x=>Number.isInteger(x)&&x>0);u||t("size","bad-size","size is [width, height] in whole px.","For example [1920, 1080] or [1080, 1350].");let m=et(fe(i.tokens)?i.tokens:void 0);if(i.tokens!==void 0)if(!fe(i.tokens))t("tokens","bad-tokens","tokens is an object of overrides.");else{let x=It(et()),N=(S,$)=>{if(fe(S)&&!("spring"in S)){for(let[X,C]of Object.entries(S))N(C,$?`${$}.${X}`:X);return}if(!x.includes($)){let X=Fe($,x);t(`tokens.${$}`,"unknown-token",`There is no token "${$}".`,X?`Did you mean "${X}"?`:`Tokens: ${we(x)}.`)}};N(i.tokens,"")}m.transitions!=="standard"&&m.transitions!=="calm"&&t("tokens.transitions","bad-value",'transitions is "standard" or "calm".',"Calm swaps every transition's defaults for its quiet preset.");let d=i.fps??m.fps;(!Number.isInteger(d)||d<=0)&&t("fps","bad-fps","fps is a whole number above zero.");let c;if(i.tempo!==void 0){let x=i.tempo;if(!fe(x)||!ce(x.bpm))t("tempo","bad-tempo","tempo is { bpm, bar }: beats per minute, and beats in a bar (4 if left out).",'For example {"bpm": 120, "bar": 4}.');else{s(x,["bpm","bar"],"tempo");let N=x.bar===void 0?4:x.bar;if(x.bpm<40||x.bpm>240)t("tempo.bpm","bad-value","bpm is 40 to 240.","Medium swing is 120\u2013150; a calm film 80\u2013100.");else if(!Number.isInteger(N)||N<2||N>12)t("tempo.bar","bad-value","bar is a whole number of beats, 2 to 12.");else{c={bpm:x.bpm,bar:N};let S=Number.isInteger(d)&&d>0?ga(c,d):1;Math.abs(S-Math.round(S))>1e-6&&i.audio===void 0&&r("tempo.bpm","beat-off-frame",`At ${d} fps a beat of ${c.bpm} bpm is ${S.toFixed(2)} frames, so beats fall between frames and drift.`,`Tempos with a whole number of frames per beat near it: ${ba(c.bpm,d).join(", ")} bpm.`)}}}let p;if(i.audio!==void 0){let x=i.audio;if(!fe(x)||typeof x.src!="string"||!x.src)t("audio","bad-audio","audio is { src, from, gain, fade_in, fade_out }: a sound file relative to the film, and where in it the film starts.",'For example {"src": "music/track.mp3", "from": 51.18}.');else{s(x,["src","from","gain","fade_in","fade_out"],"audio");let N=(S,$,X,C,q)=>{let P=x[S]===void 0?$:x[S];return!ce(P)||P<X||P>C?(t(`audio.${S}`,"bad-value",`${S} is ${q}, ${X} to ${C}.`),$):P};p={src:x.src,from:N("from",0,0,36e3,"seconds into the file"),gain:N("gain",0,-30,6,"a level in dB"),fade_in:N("fade_in",0,0,10,"seconds"),fade_out:N("fade_out",0,0,10,"seconds")}}}let f=(x,N)=>{if(!c){t(N,"needs-tempo",`"${x}" is in beats, but the film has no tempo.`,'Add "tempo": {"bpm": 120} to the film, or write seconds.');return}return fa(x,c)};if(i.theme!==void 0)if(!fe(i.theme))t("theme","bad-theme","theme is { scheme, vars }.");else{s(i.theme,["scheme","accent","onAccent","ui","vars"],"theme"),i.theme.ui!==void 0&&!Vt.includes(i.theme.ui)&&t("theme.ui","bad-value",`ui is one of the bydiorama/ui themes: ${Vt.join(", ")}.`,`Use "zero", Diorama's own theme, unless the brief names another.`);for(let x of["accent","onAccent"])i.theme[x]!==void 0&&typeof i.theme[x]!="string"&&t(`theme.${x}`,"bad-value",`${x} is a CSS colour.`);i.theme.scheme!==void 0&&i.theme.scheme!=="light"&&i.theme.scheme!=="dark"&&t("theme.scheme","bad-value",'scheme is "light" or "dark".');for(let x of Object.keys(i.theme.vars??{}))x.startsWith("--")||t(`theme.vars.${x}`,"bad-var","Theme variables are CSS custom properties.",`Write "--${x}".`)}if(!Array.isArray(i.scenes)||i.scenes.length===0)return t("scenes","no-scenes","A film needs at least one scene."),a(m);if(!u||!Number.isInteger(d)||d<=0)return a(m);let g=1/d,b=x=>Math.round(x*d)/d,h={tokens:m,seed:i.seed??1,size:[o[0],o[1]]},y=(x,N,S)=>{if(Ce(x))return f(x,N);let $=We(x)?tt(m,x):x;if(We(x)&&$===void 0){let X=It(m).map(q=>`$${q}`),C=Fe(x,X);t(N,"unknown-token",`There is no token "${x}".`,C?`Did you mean "${C}"?`:void 0);return}if(!ce($)||$<0){t(N,"bad-time",`${S} is a number of seconds, zero or more, a $token, or beats such as "2b" or "1bar".`);return}return $},v=(x,N)=>{let S=We(x)?tt(m,x):x;if(!tn(S)||typeof S=="string"&&!Pe.includes(S)){let $=typeof S=="string"?Fe(S,Pe):void 0;t(N,"bad-ease",'An ease is a name, a [x1, y1, x2, y2] bezier, or {"spring": {"duration", "bounce"}}.',$?`Did you mean "${$}"?`:`Names: ${we(Pe)}.`);return}return S},E=(x,N)=>{if(x===void 0)return;if(!fe(x)){t(N,"bad-tracks","tracks is an object of keyframe lists by property.");return}let S={};for(let[$,X]of Object.entries(x)){let C=`${N}.${$}`;if(!Qe.includes($)){let q=Fe($,Qe);t(C,"unknown-track",`"${$}" cannot be animated by a track.`,q?`Did you mean "${q}"?`:`Properties: ${we(Qe)}.`);continue}if(!Array.isArray(X)||X.length===0){t(C,"bad-track","A track is a list of [seconds, value] keys.");continue}S[$]=X.map((q,P)=>{let Y=Array.isArray(q)&&Ce(q[0])?f(q[0],`${C}.${P}`):Array.isArray(q)?q[0]:void 0;return!Array.isArray(q)||!ce(Y)||!ce(q[1])?(t(`${C}.${P}`,"bad-key",'A key is [time, value] or [time, value, ease]; time in seconds or beats ("2b").'),q):(q[2]!==void 0&&v(q[2],`${C}.${P}`),q.length>2?[Y,q[1],q[2]]:[Y,q[1]])})}return S},M=(x,N,S,$)=>{let X={};for(let[C,q]of Object.entries(N)){let P=q.default;X[C]=We(P)?tt(m,P):P}if(x===void 0)return X;if(!fe(x))return t(S,"bad-params","params is an object."),X;for(let[C,q]of Object.entries(x)){let P=`${S}.${C}`,Y=N[C];if(!Y){let _=Object.keys(N),ee=Fe(C,_);t(P,"unknown-param",`${$} has no param "${C}".`,ee?`Did you mean "${ee}"?`:_.length?`Params: ${we(_)}.`:`${$} has no params.`);continue}if(Ce(q)&&!(Y.type==="number"&&Y.unit==="s")){t(P,"bad-param",`${C} is not a time, so it cannot be in beats.`);continue}let K=Ce(q)?f(q,P):We(q)?tt(m,q):q;if(!(Ce(q)&&K===void 0)){if(We(q)&&K===void 0){t(P,"unknown-token",`There is no token "${q}".`);continue}if(Y.type==="number"){if(!ce(K)){t(P,"bad-param",`${C} is a number${Y.unit?` (${Y.unit})`:""}.`);continue}(Y.min!==void 0&&K<Y.min||Y.max!==void 0&&K>Y.max)&&r(P,"out-of-range",`${C} is ${K}; the library's range is ${Y.min}\u2013${Y.max}${Y.unit?` ${Y.unit}`:""}.`,"Allowed, but outside what has been seen to look right. Check the frames.")}else if(Y.type==="ease"){if(v(K,P)===void 0)continue}else if(Y.type==="boolean"){if(typeof K!="boolean"){t(P,"bad-param",`${C} is true or false.`);continue}}else if(Y.type==="choice"&&!(Y.options??[]).includes(String(K))){t(P,"bad-param",`${C} is one of: ${we(Y.options??[])}.`);continue}X[C]=K}}return X},k=new Set,R=[],z=new Map;i.scenes.forEach((x,N)=>{let S=fe(x)&&typeof x.id=="string"?x.id:String(N),$=`scenes.${S}`;if(!fe(x)){t($,"bad-scene","A scene is an object.");return}if(s(x,Qi,$),typeof x.id!="string"||!xa.test(x.id)?t(`${$}.id`,"bad-id",ya(x.id,"scene"),wa(x.id,"scene",'For example "title" or "stat-2".')):k.has(x.id)&&t(`${$}.id`,"duplicate-id",`Two scenes are called "${x.id}".`),k.add(S),x.scheme!==void 0&&x.scheme!=="light"&&x.scheme!=="dark"&&t(`${$}.scheme`,"bad-value",'scheme is "light" or "dark".'),x.layout!==void 0&&(fe(x.layout)?s(x.layout,["align","justify","gap","padding"],`${$}.layout`):t(`${$}.layout`,"bad-layout","layout is { align, justify, gap, padding }.")),x.artboard!==void 0){let w=x.artboard,T=`${$}.artboard`;if(!fe(w))t(T,"bad-artboard","artboard is { width, height } in the design's pixels, with an optional fit and align.");else{s(w,["width","height","fit","align"],T);for(let V of["width","height"])(!ce(w[V])||w[V]<1||w[V]>2e4)&&t(`${T}.${V}`,"bad-value",`${V} is the design's ${V} in its own pixels, 1 to 20000.`);w.fit!==void 0&&!Ut.includes(w.fit)&&t(`${T}.fit`,"bad-value",`fit is one of: ${we(Ut)}.`),w.align!==void 0&&!(Array.isArray(w.align)&&w.align.length===2&&w.align.every(V=>ce(V)&&V>=0&&V<=100))&&t(`${T}.align`,"bad-value","align is [x, y], each 0 to 100: where the artboard sits along each side of the stage.")}}let X=E(x.tracks,`${$}.tracks`);if(!Array.isArray(x.layers)){t(`${$}.layers`,"no-layers","A scene has a list of layers. It may be empty.");return}let C=new Map;x.layers.forEach((w,T)=>{let V=fe(w)&&typeof w.id=="string"?w.id:String(T),D=`${$}.layers.${V}`;if(!fe(w)){t(D,"bad-layer","A layer is an object.");return}if(s(w,_i,D),typeof w.id!="string"||!xa.test(w.id)||w.id==="scene"){t(`${D}.id`,"bad-id",ya(w.id,"layer"),wa(w.id,"layer",'For example "headline" or "photo-2".'));return}if(C.has(w.id)){t(`${D}.id`,"duplicate-id",`Two layers in scene "${S}" are called "${w.id}".`);return}let J=typeof w.use=="string"?Ie[w.use]:void 0;if(!J){let me=Object.keys(Ie),be=typeof w.use=="string"?Fe(w.use,me):void 0,ye=typeof w.use=="string"&&w.use in Ae;t(`${D}.use`,"unknown-primitive",`There is no code for "${String(w.use)}".`,ye?'That is a transition. Put it on the scene as "out": {"use": ...}.':be?`Did you mean "${be}"?`:`Drawable: ${we(me)}. Compose anything else from el/* layers with enter, exit and tracks.`);return}let I={},re=w.props??{};if(!fe(re))t(`${D}.props`,"bad-props","props is an object.");else{for(let me of Object.keys(re)){if(me in J.props)continue;let be=Object.keys(J.props),ye=Fe(me,be),_t=me in J.params;t(`${D}.props.${me}`,"unknown-prop",`${J.slug} has no prop "${me}".`,_t?`"${me}" is a motion value. Move it to params.`:ye?`Did you mean "${ye}"?`:`Props: ${we(be)}.`)}for(let[me,be]of Object.entries(J.props)){let ye=re[me];if(ye===void 0){be.required?t(`${D}.props.${me}`,"missing-prop",`${J.slug} needs "${me}": ${be.label}.`):I[me]=be.default;continue}if(!(be.type==="number"?ce(ye):be.type==="string[]"?Array.isArray(ye)&&ye.every(Wa=>typeof Wa=="string"):be.type==="number[]"?Array.isArray(ye)&&ye.every(ce):typeof ye=="string")){t(`${D}.props.${me}`,"bad-prop",`"${me}" is ${be.type==="string[]"?"a list of strings":be.type==="number[]"?"a list of numbers":`a ${be.type==="html"?"string":be.type}`}.`);continue}(be.type==="string[]"||be.type==="number[]")&&be.required&&ye.length===0&&r(`${D}.props.${me}`,"empty",`"${me}" is empty, so nothing is drawn.`),I[me]=ye}}let ne=M(w.params,J.params,`${D}.params`,J.slug);if(w.style!==void 0)if(!fe(w.style))t(`${D}.style`,"bad-style","style is an object.");else{s(w.style,es,`${D}.style`);let me=w.style;me.size!==void 0&&!mt.includes(me.size)&&t(`${D}.style.size`,"bad-value",`size is one of: ${we(mt)}.`),me.color!==void 0&&!dt.includes(me.color)&&t(`${D}.style.color`,"bad-value",`color is one of: ${we(dt)}.`,"For any other colour use style.css or a theme variable."),me.width!==void 0&&(!ce(me.width)||me.width<=0||me.width>100)&&t(`${D}.style.width`,"bad-value","width is a percentage of the stage, 1 to 100.")}if(w.place!==void 0){let me=w.place;!fe(me)||!ce(me.x)||!ce(me.y)?t(`${D}.place`,"bad-place",'place is { x, y } in percent of the stage (or artboard pixels with unit "px"), with an optional anchor.'):(s(me,["x","y","anchor","unit"],`${D}.place`),me.anchor!==void 0&&!ct.includes(me.anchor)&&t(`${D}.place.anchor`,"bad-value",`anchor is one of: ${we(ct)}.`),me.unit!==void 0&&!da.includes(me.unit)&&t(`${D}.place.unit`,"bad-value",`unit is "%" (of the stage) or "px" (of the scene's artboard).`))}let se=E(w.tracks,`${D}.tracks`);if(w.reflow!==void 0&&(w.reflow!=="glide"?t(`${D}.reflow`,"bad-value",'reflow is "glide": the layer takes no room until it enters, and the layers around it glide over.'):(w.place||w.screen)&&r(`${D}.reflow`,"unused",`Layer "${V}" is placed on its own, so it takes no room in the stack and nothing glides around it.`)),w.screen!==void 0&&typeof w.screen!="boolean"&&t(`${D}.screen`,"bad-value","screen is true (fixed to the screen, outside the camera) or false."),w.screen===!0&&w.parallax!==void 0&&t(`${D}.parallax`,"bad-value","A layer fixed to the screen does not travel with the camera, so it has no parallax."),w.motionBlur!==void 0&&typeof w.motionBlur!="boolean"&&!(ce(w.motionBlur)&&w.motionBlur>=0&&w.motionBlur<=1)&&t(`${D}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1."),J.check)try{for(let me of J.check(I,ne,h))t(`${D}.${me.path}`,"bad-value",me.message,me.hint)}catch{}let oe=0;try{oe=J.duration(I,ne,h)}catch{}let le;try{le=J.cues?.(I,ne,h)}catch{}let he;try{he=J.speed?.(I,ne,h)}catch{}let xe=se?{...w,tracks:se}:w;C.set(w.id,{layer:xe,path:D,duration:Number.isFinite(oe)?oe:0,params:ne,props:I,...le?{cues:le}:{},...J.cycles?{cycles:!0}:{},...he!==void 0&&Number.isFinite(he)?{speed:he}:{}})});let q=(w,T,V)=>{if(w===void 0)return;let D=typeof w=="string"?{move:w}:w;if(!fe(D)||!_e.includes(D.move)){let le=fe(D)&&typeof D.move=="string"?Fe(D.move,_e):void 0;t(T,"unknown-move",`A move is one of: ${we(_e)}.`,le?`Did you mean "${le}"?`:void 0);return}s(D,V?["move","duration","ease","amount","angle","feather","at"]:["move","duration","ease","amount","angle","feather"],T);let J=D.move.startsWith("mask-")||D.move.startsWith("wipe-"),I;D.feather!==void 0&&D.feather!==!1&&(D.feather!==!0&&!(ce(D.feather)&&D.feather>=0&&D.feather<=200)?t(`${T}.feather`,"bad-value","feather is a soft edge in px (0 to 200), or true for a tenth of the line height."):J?(D.feather===!0||D.feather>0)&&(I=D.feather):r(`${T}.feather`,"unused",`${D.move} has no edge to soften, so feather is ignored.`,"Feather mask-up, mask-down and the wipe-* moves."));let re=ma.includes(D.move);D.angle!==void 0&&(ce(D.angle)?re||r(`${T}.angle`,"unused",`${D.move} has a fixed direction, so angle is ignored.`,'Use "wipe" or "slide" to travel at an angle.'):t(`${T}.angle`,"bad-value","angle is degrees: 0 rightwards, 90 downwards, 180 leftwards, 270 upwards."));let ne=D.duration===void 0?V?m.duration.fast:m.duration.base:y(D.duration,`${T}.duration`,"duration"),se=ns[D.move],oe=D.ease===void 0?se?se[V?"exit":"enter"]:V?m.ease_exit:m.ease_enter:v(D.ease,`${T}.ease`);if(D.amount!==void 0&&!ce(D.amount)&&t(`${T}.amount`,"bad-value","amount is a number."),!(ne===void 0||oe===void 0))return{move:D.move,duration:ne,ease:oe,amount:ce(D.amount)?D.amount:ts[D.move],...re?{angle:ce(D.angle)?D.angle:0}:{},...I!==void 0?{feather:I}:{}}},P=new Map;for(let[w,T]of C){let V=q(T.layer.enter,`${T.path}.enter`,!1);V&&P.set(w,V)}let Y=w=>Math.max(C.get(w).duration,P.get(w)?.duration??0),K=/^\s*([a-z][a-z0-9-]*)\.(start|end)\s*(?:([+-])\s*(\d+(?:\.\d+)?\s*(?:b|beats?|bars?)?))?\s*$/,_=new Set,ee,A,O=(w,T,V)=>{if(ce(w)){if(w<0){t(T,"bad-time","Times are seconds from the scene start, zero or more.");return}return w}if(Ce(w))return f(w,T);let D=typeof w=="string"?K.exec(w):null;if(!D){t(T,"bad-time",'A time is seconds from the scene start, or a reference such as "headline.end + 0.2".','References: "<layer id>.start", "<layer id>.end", "scene.end", each with an optional + or - seconds or beats ("+ 1b"). With a tempo, "4b" alone is a time too.');return}let[,J,I,re,ne]=D,se=ne===void 0?0:Ce(ne)?f(ne,T):Number(ne);if(se===void 0)return;let oe=(re==="-"?-1:1)*se;if(J==="scene"){if(I==="start")return Math.max(0,oe);if(ee===void 0){t(T,"needs-length",'"scene.end" can only place a layer when the scene has a length.',`Add "length" to scene "${S}", or refer to a layer instead.`);return}return Math.max(0,ee+oe)}if(J===V){t(T,"self-reference","A layer cannot be timed against itself.");return}if(!C.has(J)){let he=[...C.keys()].filter(me=>me!==V),xe=Fe(J,he);t(T,"unknown-layer",`Scene "${S}" has no layer "${J}".`,xe?`Did you mean "${xe}"?`:`Layers here: ${we(he)||"none"}.`);return}let le=B(J);if(le!==void 0)return Math.max(0,le+(I==="end"?Y(J):0)+oe)},B=w=>{let T=C.get(w);if(T.start!==void 0)return T.start;if(_.has(w)){t(`${T.path}.at`,"time-cycle",`Layers ${[..._].join(" \u2192 ")} \u2192 ${w} are timed against each other in a circle.`,"Give one of them a number.");return}_.add(w);let V=T.layer.at===void 0?0:O(T.layer.at,`${T.path}.at`,w);return _.delete(w),V!==void 0&&(T.start=b(V)),T.start};if(x.length!==void 0){let w=Ce(x.length)?f(x.length,`${$}.length`):x.length;w===void 0||(!ce(w)||w<=0?t(`${$}.length`,"bad-time",'length is seconds above zero, or beats ("8b", "2bars").'):(ee=Math.max(g,b(w)),A=Math.max(g,w)))}for(let w of C.keys())B(w);let W=x.hold===void 0?m.hold:y(x.hold,`${$}.hold`,"hold")??m.hold;if(ee===void 0){let w=Math.max(0,...[...C.entries()].map(([T,V])=>(V.start??0)+Y(T)));ee=Math.max(g,b(w+W))}else x.hold!==void 0&&r(`${$}.hold`,"unused","hold is ignored when the scene has a length.");let H=ee,U=[],G=!!x.follow||Array.isArray(x.camera)&&x.camera.length>0||["x","y"].some(w=>(x.tracks?.[w]?.length??0)>1),Q=[];for(let[w,T]of C){if(T.start===void 0)continue;let V=T.start+Y(w);if(T.start>=H){let oe=Math.max(0,H-g);t(`${T.path}.at`,"never-seen",T.start-H<g/2?`Layer "${w}" starts at ${T.start.toFixed(3)} s, the moment scene "${S}" ends, so it is never on screen.`:`Layer "${w}" starts at ${T.start.toFixed(3)} s, after scene "${S}" ends at ${H.toFixed(3)} s.`,`Times snap to whole frames at ${d} fps, so the last frame a layer can start on is ${oe.toFixed(3)} s. Start it earlier or make the scene longer.`);continue}T.cycles&&T.cues?Q.push({path:T.path,id:w,start:T.start,cues:T.cues}):V>H+1e-6&&r(T.path,"cut-off",`Layer "${w}" finishes at ${V.toFixed(2)} s, ${(V-H).toFixed(2)} s after scene "${S}" ends.`,x.length!==void 0?`Raise the scene length to at least ${V.toFixed(2)}, or start the layer earlier.`:"Start the layer earlier.");let D=P.get(w),J=q(T.layer.exit,`${T.path}.exit`,!0),I;if(J){let oe=typeof T.layer.exit=="object"&&T.layer.exit.at!==void 0?O(T.layer.exit.at,`${T.path}.exit.at`,void 0):H-J.duration;oe!==void 0&&(I={...J,start:b(Math.max(0,oe))},I.start<T.start?t(`${T.path}.exit.at`,"exit-before-enter",`Layer "${w}" leaves at ${I.start.toFixed(2)} s, before it arrives at ${T.start.toFixed(2)} s.`):I.start<V-1e-6&&r(`${T.path}.exit`,"exit-early",`Layer "${w}" starts leaving at ${I.start.toFixed(2)} s while it is still arriving (until ${V.toFixed(2)} s).`))}let re;if(T.layer.parallax!==void 0){let oe=`${T.path}.parallax`,le=T.layer.parallax,he=ce(le)?{depth:le}:le;if(!fe(he)||!ce(he.depth)||he.depth<0||he.depth>10)t(oe,"bad-value","parallax is a depth from 0 to 10 (1 travels with the scene, above 1 is nearer), or { depth, home }.");else{s(he,["depth","home"],oe);let xe=he.home===void 0?H:O(he.home,`${oe}.home`,void 0);xe!==void 0&&(re={depth:he.depth,home:Math.min(xe,H)}),G||r(oe,"unused",`Scene "${S}"'s camera does not travel, so parallax has nothing to follow.`,"Give the scene x or y tracks, or a follow."),x.follow&&fe(x.follow)&&x.follow.layer===w&&t(oe,"bad-follow",`The camera follows "${w}", so it cannot also travel against the camera.`)}}let ne,se=T.start;if(T.layer.taps!==void 0){let oe=`${T.path}.taps`;Array.isArray(T.layer.taps)?(ne=[],T.layer.taps.forEach((le,he)=>{let xe=`${oe}.${he}`,me=fe(le)?le:{at:le};fe(le)&&s(le,["at","ring","mark"],xe);let be=fe(le)&&typeof le.mark=="string"?le.mark:void 0;be!==void 0&&T.layer.use!=="rig/footage-plane"&&t(`${xe}.mark`,"bad-value","Only a rig/footage-plane has marks to tap.");let ye=O(me.at,fe(le)?`${xe}.at`:xe,void 0);me.ring!==void 0&&me.ring!==!1&&typeof me.ring!="string"&&t(`${xe}.ring`,"bad-value","ring is the id of a layer in this scene, or false for no ring."),ye!==void 0&&((ye<se||I&&ye>I.start)&&r(xe,"tap-hidden",`Layer "${w}" is tapped at ${ye.toFixed(2)} s, when it is not on screen.`),ne.push({t:b(ye),ring:me.ring===!1?null:typeof me.ring=="string"?me.ring:w,...be?{mark:be}:{}}))}),ne.sort((le,he)=>le.t-he.t)):t(oe,"bad-value","taps is a list of times, or of { at, ring }.",'e.g. "taps": ["3.25b"]')}U.push({id:w,use:T.layer.use,start:T.start,duration:T.duration,end:V,props:T.props,params:T.params,...T.cues?{cues:T.cues}:{},...T.speed!==void 0?{speed:T.speed}:{},...D?{enter:{...D,start:T.start}}:{},...I?{exit:I}:{},...re?{parallax:re}:{},...ne?.length?{taps:ne}:{},source:T.layer})}for(let w of U){if(w.use!=="ui/cursor-click"||typeof w.props.target!="string"||!w.props.target)continue;let T=U.find(V=>V.id===w.props.target);if(!T){let V=Fe(w.props.target,U.map(D=>D.id));t(`${$}.layers.${w.id}.props.target`,"unknown-layer",`Scene "${S}" has no layer "${w.props.target}" for the cursor to click.`,V?`Did you mean "${V}"?`:void 0);continue}(T.taps??=[]).push({t:b(w.start+Ar(w.params)),ring:T.id}),T.taps.sort((V,D)=>V.t-D.t)}if(U.forEach(w=>w.taps?.forEach((T,V)=>{if(T.ring!==null&&!U.some(D=>D.id===T.ring)){let D=Fe(T.ring,U.map(J=>J.id));t(`${$}.layers.${w.id}.taps.${V}.ring`,"unknown-layer",`Scene "${S}" has no layer "${T.ring}" to draw a tap's ring around.`,D?`Did you mean "${D}"?`:void 0)}})),x.follow!==void 0){let w=`${$}.follow`,T=x.follow;if(!fe(T))t(w,"bad-follow","follow is { layer, at, lag, blend }.");else{s(T,["layer","at","lag","blend"],w);let V=typeof T.layer=="string"?U.find(D=>D.id===T.layer):void 0;if(V)$t.includes(V.use)||t(`${w}.layer`,"bad-follow",`${V.use} has no tip to follow.`,`The camera can follow: ${we($t)}.`);else{let D=U.filter(I=>$t.includes(I.use)).map(I=>I.id),J=typeof T.layer=="string"?Fe(T.layer,D):void 0;t(`${w}.layer`,"unknown-layer",`Scene "${S}" has no layer "${String(T.layer)}" to follow.`,J?`Did you mean "${J}"?`:D.length?`Lines here: ${we(D)}.`:`Add a line to follow: ${we($t)}.`)}T.at!==void 0&&!(Array.isArray(T.at)&&T.at.length===2&&T.at.every(D=>ce(D)&&D>=0&&D<=100))&&t(`${w}.at`,"bad-value","at is [x, y] in % of the stage, 0 to 100.","The middle is [50, 50].");for(let D of["lag","blend"])T[D]!==void 0&&!(ce(T[D])&&T[D]>=0)&&t(`${w}.${D}`,"bad-time",`${D} is seconds, zero or more.`)}}let ie;if(x.camera!==void 0){let w=`${$}.camera`;if(!Array.isArray(x.camera)||x.camera.length===0)t(w,"bad-camera","camera is a list of keys: { at, frame, zoom, anchor, tilt, ease }.");else{x.follow!==void 0&&t(w,"bad-camera","A scene has a framing camera or a follow, not both.","Frame the line's layer with camera keys, or follow its tip.");let T=["x","y","scale"].filter(I=>x.tracks?.[I]!==void 0);T.length&&t(`${$}.tracks`,"bad-camera",`The framing camera sets x, y and scale itself, so tracks ${T.join(", ")} would fight it.`,"Move them into camera keys: frame, offset and zoom. rotate, rotateX and rotateY tracks still apply.");let V=U.map(I=>I.id),D=(I,re,ne)=>Array.isArray(I)&&I.length===2&&I.every(se=>ce(se)&&se>=re&&se<=ne),J={t:0,frame:[50,50],point:[.5,.5],offset:[0,0],zoom:1,anchor:[50,50],tilt:[0,0],rotate:0,drift:0};ie=[],x.camera.forEach((I,re)=>{let ne=`${w}.${re}`;if(!fe(I)){t(ne,"bad-camera","A camera key is an object: { at, frame, zoom, anchor, tilt, ease }.");return}s(I,["at","frame","point","offset","zoom","anchor","tilt","rotate","ease","drift"],ne);let se=y(I.at,`${ne}.at`,"at");if(se===void 0)return;ie.length&&se<ie[ie.length-1].t&&t(`${ne}.at`,"bad-order",`Camera keys run in time order; this one (${se.toFixed(2)} s) comes before the key above it.`),se>H+1e-6&&r(`${ne}.at`,"after-end",`This key (${se.toFixed(2)} s) is after scene "${S}" ends (${H.toFixed(2)} s).`,"A key past the cut is fine for a camera that keeps moving through the cut; otherwise move it earlier.");let oe={...J,t:se,drift:0};if(I.ease!==void 0){let le=v(I.ease,`${ne}.ease`);le!==void 0&&(oe.ease=le)}else delete oe.ease;if(I.frame!==void 0)if(typeof I.frame=="string"){let[le,he]=I.frame.split("#");if(V.includes(le))he!==void 0&&U.find(xe=>xe.id===le)?.use!=="rig/footage-plane"?t(`${ne}.frame`,"bad-camera",`"${I.frame}" frames a mark, and only a rig/footage-plane has marks.`,`Frame the layer itself: "${le}".`):he===""&&t(`${ne}.frame`,"bad-camera",'Name the mark after the #: "plane#send", as given to motion record --marks.');else{let xe=Fe(le,V);t(`${ne}.frame`,"unknown-layer",`Scene "${S}" has no layer "${le}" to frame.`,xe?`Did you mean "${xe}"?`:`Layers: ${we(V)}.`)}oe.frame=I.frame}else D(I.frame,0,100)?oe.frame=[I.frame[0],I.frame[1]]:t(`${ne}.frame`,"bad-value","frame is a layer id, or [x, y] in % of the stage.");I.point!==void 0&&(D(I.point,0,1)?oe.point=[I.point[0],I.point[1]]:t(`${ne}.point`,"bad-value","point is [x, y] as shares of the layer box, 0 to 1.","The middle is [0.5, 0.5].")),I.offset!==void 0&&(Array.isArray(I.offset)&&I.offset.length===2&&I.offset.every(ce)?oe.offset=[I.offset[0],I.offset[1]]:t(`${ne}.offset`,"bad-value","offset is [dx, dy] in px.")),I.anchor!==void 0&&(D(I.anchor,0,100)?oe.anchor=[I.anchor[0],I.anchor[1]]:t(`${ne}.anchor`,"bad-value","anchor is [x, y] in % of the stage, 0 to 100.")),I.tilt!==void 0&&(D(I.tilt,-80,80)?oe.tilt=[I.tilt[0],I.tilt[1]]:t(`${ne}.tilt`,"bad-value","tilt is [about x, about y] in degrees, -80 to 80.")),I.zoom!==void 0&&(ce(I.zoom)&&I.zoom>0?oe.zoom=I.zoom:t(`${ne}.zoom`,"bad-value","zoom is a number above 0; 1 is the stage as laid out.")),I.rotate!==void 0&&(ce(I.rotate)?oe.rotate=I.rotate:t(`${ne}.rotate`,"bad-value","rotate is degrees.")),I.drift!==void 0&&(ce(I.drift)?re!==x.camera.length-1?r(`${ne}.drift`,"unused","drift runs from the last key to the end of the scene; on an earlier key it does nothing."):oe.drift=I.drift:t(`${ne}.drift`,"bad-value","drift is zoom per second, such as 0.02.")),ie.push(oe),J=oe}),x.perspective!==void 0&&!(ce(x.perspective)&&x.perspective>=100)&&t(`${$}.perspective`,"bad-value","perspective is px from the viewer to the stage, 100 or more.",`The default is ${Math.round(o[0]*1.2)} (1.2 \xD7 the stage width).`),ie.length||(ie=void 0)}}x.motionBlur!==void 0&&typeof x.motionBlur!="boolean"&&!(ce(x.motionBlur)&&x.motionBlur>=0&&x.motionBlur<=1)&&t(`${$}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1.");let ue,pe=0;if(x.out!==void 0){let w=`${$}.out`,T=fe(x.out)&&typeof x.out.use=="string"?Ae[x.out.use]:void 0;if(T){s(x.out,["use","duration","params"],w);let V=m.transitions==="calm"&&T.calm?Object.fromEntries(Object.entries(T.params).map(([I,re])=>[I,I in T.calm?{...re,default:T.calm[I]}:re])):T.params,D=M(x.out.params,V,`${w}.params`,T.slug);if(x.out.duration!==void 0){let I=y(x.out.duration,`${w}.duration`,"duration");I!==void 0&&(D.duration=I)}let J=b(ce(D.duration)?D.duration:0);N===i.scenes.length-1?r(w,"unused",'The last scene has nothing to hand over to, so "out" is ignored.'):J>=H?t(`${w}.duration`,"too-long",`The hand-over (${J.toFixed(2)} s) is not shorter than scene "${S}" (${H.toFixed(2)} s).`):(ue={use:T.slug,duration:J,params:D},pe=ce(D.duration)?D.duration:0)}else{let V=Object.keys(Ae),D=fe(x.out)?String(x.out.use):"",J=Fe(D,V);t(`${w}.use`,"unknown-transition",`There is no code for transition "${D}".`,J?`Did you mean "${J}"?`:`Transitions: ${we(V)}.`)}}let de=H-(ue?ue.duration/2:0);for(let w of Q){let T=w.cues.find(V=>w.start+V.at<de-1e-6&&w.start+V.at+V.length>de+1e-6);T&&r(w.path,"cut-mid-change",`Scene "${S}" is last seen at ${de.toFixed(2)} s, in the middle of a change of layer "${w.id}" (${(w.start+T.at).toFixed(2)}\u2013${(w.start+T.at+T.length).toFixed(2)} s).`,"End the scene on a rest: after the change, or before it begins.")}z.set(S,{length:A??H,out:pe}),R.push({id:S,start:0,length:H,end:H,layers:U,...ue?{out:ue}:{},...ie?{camera:ie}:{},source:X?{...x,tracks:X}:x})});let L=0;R.forEach((x,N)=>{let S=R[N-1];S?.out&&(S.out.duration>=x.length&&t(`scenes.${S.id}.out.duration`,"too-long",`The hand-over (${S.out.duration.toFixed(2)} s) is not shorter than the next scene "${x.id}" (${x.length.toFixed(2)} s).`),L-=z.get(S.id)?.out??S.out.duration),x.start=b(L),L+=z.get(x.id)?.length??x.length,x.end=b(L),x.length=x.end-x.start}),as(R,g,t);let j=b(L);return i.poster!==void 0&&(!ce(i.poster)||i.poster<0||i.poster>j)&&t("poster","bad-time",`poster is a time inside the film, 0 to ${j.toFixed(2)} s.`),a(m,{duration:j,fps:d,frames:Math.round(j*d),size:[o[0],o[1]],scenes:R,...c?{tempo:c}:{},...i.loop?{loop:!0}:{},...p?{audio:p}:{}})}function as(e,n,t){for(let r of e)for(let a of r.layers){let s=a.use==="el/video"&&typeof a.props.continues=="string"?a.props.continues:"";if(!s)continue;let i=`scenes.${r.id}.layers.${a.id}.props.continues`,[o,u]=s.split("."),m=e.find(y=>y.id===o),d=m?.layers.find(y=>y.id===u);if(!m||!d){t(i,"unknown-layer",`There is no layer "${s}" to continue.`,'Name a video layer as "scene.layer".');continue}if(d.use!=="el/video"){t(i,"bad-value",`"${s}" is ${d.use}, not el/video.`);continue}if(d===a){t(i,"self-reference","A video layer cannot continue itself.");continue}d.props.src!==a.props.src&&t(i,"bad-value",`"${s}" plays ${String(d.props.src)}, a different file.`,"A continuation plays the same footage.");let c=Math.min(m.length,d.exit?d.exit.start+d.exit.duration:m.length)-n,p=typeof d.params.rate=="number"?d.params.rate:1,f=Math.max(0,c-d.start),g=typeof d.props.from=="number"?d.props.from:0,b=typeof d.props.to=="number"?d.props.to:0,h=g+f*p;d.params.loop===!0&&b>g?h=g+f*p%(b-g):b>g&&(h=Math.min(b,h)),a.props={...a.props,from:Number((h+n*p).toFixed(6))},typeof a.props.to=="number"&&a.props.to!==0&&a.props.to<=a.props.from&&t(`scenes.${r.id}.layers.${a.id}.props.to`,"bad-value",`to (${a.props.to} s) comes before the continuation starts (${a.props.from.toFixed(3)} s).`,"Leave it at 0, or move it later.")}}function is(e){let n=r=>r.toFixed(2).padStart(6),t=[`${e.duration.toFixed(2)} s \xB7 ${e.frames} frames at ${e.fps} fps \xB7 ${e.size[0]}\xD7${e.size[1]}`,""];for(let r of e.scenes){t.push(`${n(r.start)} \u2013 ${n(r.end)} scene ${r.id}${r.out?` \u2192 ${r.out.use} ${r.out.duration.toFixed(2)} s`:""}`);for(let a of r.layers){let s=[a.use,a.enter?`enter ${a.enter.move}`:"",a.exit?`exit ${a.exit.move} @${(r.start+a.exit.start).toFixed(2)}`:""].filter(Boolean);t.push(` ${n(r.start+a.start)} \u2013 ${n(r.start+a.end)} ${a.id.padEnd(14)} ${s.join(" \xB7 ")}`)}}return t.join(`
|
|
4
|
-
`)}var St=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ss=new Set(["scenes","layers"]);function os(e,n,t){let r=n.split("."),a=e;for(let s=0;s<r.length;s++){let i=r[s],o=s===r.length-1;if(Array.isArray(a)){let u=a.find(m=>St(m)&&m.id===i);if(!u||o)return!1;a=u;continue}if(!St(a))return!1;if(o)return t===null?delete a[i]:a[i]=t,!0;if(a[i]===void 0){if(ss.has(i))return!1;a[i]={}}(i==="enter"||i==="exit")&&typeof a[i]=="string"&&(a[i]={move:a[i]}),a=a[i]}return!1}function At(e,n){let t=structuredClone(e),r=[],a=[];for(let[s,i]of Object.entries(n?.set??{}))(os(t,s,structuredClone(i))?a:r).push(s);return{film:t,orphans:r,applied:a}}function ls(e,n){let t=e;for(let r of n.split("."))if(Array.isArray(t))t=t.find(a=>St(a)&&a.id===r);else if(St(t))t=t[r];else return;return t}function us(e,n){let{film:t,orphans:r}=At(e,n),a=Object.fromEntries(Object.entries(n?.set??{}).filter(([s])=>r.includes(s)));return{film:t,tune:{set:a,notes:n?.notes??[]},orphans:r}}var va="0.4.
|
|
3
|
+
`).filter(n=>n.trim()).length);var gi={accent:"var(--m-bg-accent)",inverse:"var(--m-bg-inverse)",primary:"var(--m-text-primary)"},yr={slug:"type/block-reveal",summary:"A solid block covers each line, then retracts as the line slides out from behind it.",props:{text:{type:"string",required:!0,label:"The text. Use \\n to set the line breaks"},accent:{type:"string[]",default:[],label:"Words set in the accent colour"},fill:{type:"string",default:"accent",label:"Block colour: accent, inverse, primary or a CSS colour"}},params:{duration:{type:"number",default:.8,min:.5,max:1.2,step:.05,unit:"s",label:"Time for one block to grow and retract"},stagger:{type:"number",default:.08,min:.03,max:.2,step:.01,unit:"s",label:"Delay between lines"},direction:{type:"choice",default:"right",options:["right","left"],label:"Which way the block travels"}},duration:(e,n)=>(Ue(F(e.text))-1)*l(n.stagger)+l(n.duration)*2.35,build(e,n,t,r){let a=e.ownerDocument,{lines:s}=Se(e,F(n.text),{accent:te(n.accent)}),i=F(t.direction)!=="left",o=gi[F(n.fill,"accent")]??F(n.fill,"accent"),u=s.map(g=>{g.style.cssText+=";position:relative;display:block;width:fit-content;margin-inline:auto;text-align:inherit";let b=a.createElement("span");b.setAttribute("aria-hidden","true"),b.style.cssText=`position:absolute;inset:0.06em -0.08em;border-radius:0.06em;background:${o};transform:scaleX(0)`;let h=a.createElement("span");for(h.style.cssText="display:inline-block";g.firstChild;)h.appendChild(g.firstChild);return g.append(h,b),{block:b,words:h}}),m=(Ue(F(n.text))-1)*l(t.stagger),d=Me(u.length,u.length>1?Math.min(l(t.stagger),m/(u.length-1)):0),c=l(t.duration),p=r.ease("expo.inOut"),f=r.ease("snap.out");return{seek(g){u.forEach(({block:b,words:h},y)=>{let v=ae(g,d[y],c,p),E=ae(g,d[y]+c,c,p);b.style.transformOrigin=E>0?i?"100% 50%":"0% 50%":i?"0% 50%":"100% 50%",b.style.transform=`scaleX(${(E>0?1-E:v).toFixed(4)})`;let M=ae(g,d[y]+c*1.35,c,f),k=g>=d[y]+c;h.style.visibility=k?"inherit":"hidden",h.style.transform=M>=1?"":`translateX(${((i?-1:1)*(1-M)*.6).toFixed(4)}em)`,h.style.opacity=k?Math.min(1,.4+M).toFixed(3):"0"})}}}};var wr={slug:"type/char-cascade",summary:"Letters arrive one by one: rising, turning, growing or coming into focus.",props:{text:{type:"string",required:!0,label:"The text"},accent:{type:"string[]",default:[],label:"Words set in the accent colour"}},params:{stagger:{type:"number",default:.03,min:.015,max:.06,step:.005,unit:"s",label:"Delay between letters"},char_duration:{type:"number",default:.6,min:.3,max:1,step:.05,unit:"s",label:"Time per letter"},from:{type:"choice",default:"start",options:qe,label:"Which letter goes first"},rise:{type:"number",default:.6,min:-1,max:1.2,step:.05,unit:"em",label:"Rise (negative drops in)"},rotate:{type:"number",default:0,min:-90,max:90,step:1,unit:"deg",label:"Turn that settles"},scale:{type:"number",default:1,min:0,max:1.6,step:.05,unit:"x",label:"Start scale"},blur:{type:"number",default:8,min:0,max:24,step:1,unit:"px",label:"Start blur"}},duration:(e,n,t)=>ze(xr(F(e.text)),F(n.from),t.seed)*l(n.stagger)+l(n.char_duration),build(e,n,t,r){let{chars:a}=Se(e,F(n.text),{chars:!0,accent:te(n.accent)}),s=Me(a.length,l(t.stagger),F(t.from),r.seed),i=r.ease(r.tokens.ease_enter),o=l(t.char_duration),u=l(t.rise),m=l(t.rotate),d=l(t.scale),c=l(t.blur);for(let p of a)p.style.transformOrigin="50% 70%";return{seek(p){a.forEach((f,g)=>{let b=ae(p,s[g],o,i),h=Math.min(1,Math.max(0,(p-s[g])/(o*.45))),y=1-b;f.style.opacity=h>=1?"":String(h),f.style.transform=y===0?"":`translateY(${(y*u).toFixed(4)}em) rotate(${(y*m).toFixed(3)}deg) scale(${(d+(1-d)*b).toFixed(4)})`;let v=Math.max(0,y)*c;f.style.filter=v>.05?`blur(${v.toFixed(2)}px)`:""})}}}};var vr={slug:"type/echo",summary:"Copies of a headline trail behind it.",props:{text:{type:"string",required:!0,label:"The headline"}},params:{copies:{type:"number",default:4,min:3,max:6,step:1,unit:"copies",label:"Outlined copies"},lag:{type:"number",default:.06,min:.03,max:.12,step:.005,unit:"s",label:"Delay between copies"},distance:{type:"number",default:1.2,min:.4,max:3,step:.1,unit:"em",label:"How far below they start"},settle:{type:"number",default:0,min:0,max:.6,step:.02,unit:"em",label:"Gap between copies at rest (0 hides them under the headline)"}},duration:(e,n,t)=>Math.round(l(n.copies))*l(n.lag)+t.tokens.duration.slow+.4,build(e,n,t,r){let a=e.ownerDocument,s=Math.max(1,Math.round(l(t.copies))),i=l(t.lag),o=l(t.distance),u=l(t.settle),m=r.tokens.duration.slow+.4,d=r.ease("expressive.out");e.style.display="grid";let c=g=>{let b=a.createElement("span");return b.textContent=F(n.text),b.style.cssText="grid-area:1/1;white-space:pre-line",g&&(b.style.color="transparent",b.style.setProperty("-webkit-text-stroke","0.018em currentColor"),b.setAttribute("aria-hidden","true")),b},p=Array.from({length:s},()=>c(!0)).reverse();p.forEach(g=>e.appendChild(g)),p.reverse();let f=c(!1);return e.appendChild(f),{seek(g){let b=ae(g,s*i,m,d);f.style.transform=b>=1?"":`translateY(${((1-b)*o).toFixed(4)}em)`,f.style.opacity=String(Math.min(1,Math.max(0,(g-s*i)/(m*.3)))),p.forEach((h,y)=>{let v=s-1-y,E=ae(g,v*i,m,d),M=(y+1)*u;h.style.transform=`translateY(${(M+(1-E)*o).toFixed(4)}em)`;let k=Math.min(1,Math.max(0,(g-v*i)/(m*.25))),R=1-(y+1)/(s+1),z=u===0?1-ae(g,s*i+m*.6,m*.4,L=>L):1;h.style.opacity=(k*R*z).toFixed(3)})}}}};var kr=(e,n,t)=>{let r=F(e.text);return n.unit==="word"?ze(Nt(r),F(n.from),t):ze(Ue(r),F(n.from),t)+(Ue(r)>1||Nt(r)>3?1:0)},Mr={slug:"type/mask-reveal",summary:"Lines or words slide up from under an edge, one after another.",props:{text:{type:"string",required:!0,label:"The text. Use \\n to set the line breaks yourself."},accent:{type:"string[]",default:[],label:"Words set in the accent colour"}},params:{unit:{type:"choice",default:"line",options:["line","word"],label:"What rises together"},stagger:{type:"number",default:.08,min:.04,max:.16,step:.005,unit:"s",label:"Delay between units"},duration:{type:"number",default:.9,min:.5,max:1.4,step:.05,unit:"s",label:"Time per unit"},tilt:{type:"number",default:0,min:0,max:8,step:.5,unit:"deg",label:"Tilt that settles as it rises"},from:{type:"choice",default:"start",options:qe,label:"Which unit goes first"},ease:{type:"ease",default:"expressive.out",label:"Curve of each rise"},feather:{type:"number",default:0,min:0,max:.4,step:.01,unit:"em",label:"A soft edge to rise out of, instead of a hard line (0.1\u20130.12 em reads as soft)"}},duration:(e,n,t)=>kr(e,n,t.seed)*l(n.stagger)+l(n.duration),build(e,n,t,r){let a=t.unit==="word",s=Se(e,F(n.text),{mask:a?"word":"line",accent:te(n.accent),feather:l(t.feather)}),i=a?s.words:s.lines,o=ze(i.length,F(t.from),r.seed),u=kr(n,t,r.seed),m=o>u&&o>0?l(t.stagger)*u/o:l(t.stagger),d=Me(i.length,m,F(t.from),r.seed),c=r.ease(t.ease),p=l(t.duration),f=l(t.tilt),g=l(t.feather);for(let b of i)b.style.transformOrigin="0% 100%",b.style.willChange="transform";return{seek(b){i.forEach((h,y)=>{let E=1-ae(b,d[y],p,c);h.style.transform=E===0?"":`translateY(${g>0?`calc(${(E*110).toFixed(3)}% + ${(E*g).toFixed(4)}em)`:`${(E*110).toFixed(3)}%`}) rotate(${(E*f).toFixed(3)}deg)`})}}}};var Fr="http://www.w3.org/2000/svg";function bi(e,n,t,r){let a=i=>(r()-.5)*i;if(e==="circle"){let i=n/2,o=t/2,u=n/2+t*.35,m=t*.72,d=[];for(let c=0;c<=28;c++){let p=-Math.PI*.62+c/28*Math.PI*2.18,f=1+a(.06);d.push(`${(i+Math.cos(p)*u*f).toFixed(1)},${(o+Math.sin(p)*m*f+c/28*t*.08).toFixed(1)}`)}return`M${d.join("L")}`}if(e==="strike")return`M${-t*.1},${t*.56+a(4)} C${n*.3},${t*.5+a(6)} ${n*.7},${t*.6+a(6)} ${n+t*.1},${t*.5+a(4)}`;if(e==="marker"){let i=t*.42,o=t*.7;return`M${-t*.08},${i+a(4)} L${n+t*.1},${i+a(5)} L${-t*.05},${o+a(5)} L${n+t*.06},${o+a(4)}`}let s=t*1.02;return`M${-t*.05},${s+a(3)} C${n*.35},${s+t*.06+a(4)} ${n*.65},${s-t*.02+a(4)} ${n+t*.12},${s-t*.12+a(3)}`}var Tr={slug:"type/scribble-highlight",summary:"A hand-drawn mark draws under or around a word.",props:{text:{type:"string",required:!0,label:"The sentence"},mark:{type:"string[]",required:!0,label:"Words to mark (a run of words gets one mark)"}},params:{duration:{type:"number",default:.5,min:.3,max:.9,step:.05,unit:"s",label:"Time to draw the mark"},kind:{type:"choice",default:"underline",options:["underline","circle","marker","strike"],label:"Mark"},delay:{type:"number",default:.3,min:0,max:2,step:.05,unit:"s",label:"Wait before drawing"},weight:{type:"number",default:.08,min:.03,max:.4,step:.01,unit:"em",label:"Stroke weight (a marker uses about 0.35)"}},duration:(e,n)=>l(n.delay)+l(n.duration),build(e,n,t,r){let a=new Set(te(n.mark).map(st)),{words:s}=Se(e,F(n.text));e.style.position="relative";let i=s.filter(L=>a.has(st(L.textContent??"")));if(!i.length)return{seek(){}};let o=i[0],u=i[i.length-1],m=e.getBoundingClientRect(),d=o.getBoundingClientRect(),c=u.getBoundingClientRect(),p=e.offsetWidth>0?m.width/e.offsetWidth:1,f=(d.left-m.left)/p,g=(d.top-m.top)/p,b=(c.right-d.left)/p,h=d.height/p,y=F(t.kind),v=parseFloat(getComputedStyle(e).fontSize)||16,E=e.ownerDocument.createElementNS(Fr,"svg");E.setAttribute("width",String(b)),E.setAttribute("height",String(h)),E.style.cssText=`position:absolute;left:${f}px;top:${g}px;overflow:visible;pointer-events:none;${y==="marker"?"z-index:-1;mix-blend-mode:multiply":""}`;let M=e.ownerDocument.createElementNS(Fr,"path");M.setAttribute("d",bi(y,b,h,$e(r.seed*31+b))),M.setAttribute("fill","none"),M.setAttribute("stroke",y==="marker"?"color-mix(in srgb, var(--m-accent) 45%, transparent)":"var(--m-accent)"),M.setAttribute("stroke-width",String(l(t.weight)*v*(y==="marker"?4.4:1))),M.setAttribute("stroke-linecap","round"),M.setAttribute("stroke-linejoin","round"),M.setAttribute("pathLength","1"),M.setAttribute("stroke-dasharray","1 1"),E.appendChild(M),e.style.isolation="isolate",e.appendChild(E);let k=r.ease("quart.inOut"),R=l(t.delay),z=l(t.duration);return{seek(L){let j=ae(L,R,z,k);M.setAttribute("stroke-dashoffset",(1-j).toFixed(4)),E.style.visibility=j<=0?"hidden":"inherit"}}}};var Er={slug:"type/shimmer",summary:"A band of light passes across the letters, again and again.",props:{text:{type:"string",required:!0,label:"The text"}},params:{period:{type:"number",default:2.4,min:1.2,max:4,step:.1,unit:"s",label:"Time between passes"},band:{type:"number",default:.22,min:.1,max:.5,step:.01,unit:"ratio",label:"Width of the band"},strength:{type:"number",default:.65,min:.3,max:1,step:.05,unit:"ratio",label:"How dim the text is outside the band"}},duration:()=>0,build(e,n,t,r){let a=e.ownerDocument.createElement("span");a.textContent=F(n.text);let s=l(t.band),i=Math.max(.2,l(t.period)),o=100-Math.round(l(t.strength)*100),u=r.ease("sine.inOut");return a.style.cssText=`display:inline-block;white-space:pre-line;-webkit-background-clip:text;background-clip:text;background-image:linear-gradient(100deg, color-mix(in srgb, currentColor ${o}%, transparent) 0%, color-mix(in srgb, currentColor ${o}%, transparent) ${50-s*50}%, currentColor 50%, color-mix(in srgb, currentColor ${o}%, transparent) ${50+s*50}%, color-mix(in srgb, currentColor ${o}%, transparent) 100%);background-size:300% 100%;background-repeat:no-repeat`,a.style.setProperty("-webkit-text-fill-color","transparent"),e.appendChild(a),{seek(m){let d=(m%i+i)%i/i,c=u(Math.min(1,d/.7));a.style.backgroundPosition=`${(100-c*100).toFixed(3)}% 0`}}}};var $r={slug:"type/tracking-in",summary:"Wide-spaced letters close up to their set spacing while coming into focus.",props:{text:{type:"string",required:!0,label:"The title"}},params:{duration:{type:"number",default:1.6,min:.8,max:3,step:.1,unit:"s",label:"Time to close up"},spread:{type:"number",default:.5,min:.1,max:1.2,step:.05,unit:"em",label:"Extra spacing at the start"},blur:{type:"number",default:12,min:0,max:30,step:1,unit:"px",label:"Start blur"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let a=r.ease("expressive.out"),s=l(t.duration),i=l(t.spread),o=l(t.blur),u=e.ownerDocument.createElement("span");u.textContent=F(n.text),u.style.cssText="display:inline-block;white-space:pre-line",e.appendChild(u);let m=parseFloat(getComputedStyle(e).letterSpacing)||0,d=parseFloat(getComputedStyle(e).fontSize)||16;return{seek(c){let p=ae(c,0,s,a),f=Math.min(1,c/(s*.5)),g=(1-p)*i;u.style.letterSpacing=`${(m/d+g).toFixed(4)}em`,u.style.marginRight=`${(-g).toFixed(4)}em`,u.style.opacity=f>=1?"":String(Math.max(0,f));let b=(1-p)*o;u.style.filter=b>.05?`blur(${b.toFixed(2)}px)`:""}}}};var Sr={slug:"type/word-roller",summary:"Words roll vertically in a slot.",props:{before:{type:"string",default:"",label:"Text before the slot"},words:{type:"string[]",required:!0,label:"Words that take turns in the slot; the last one stays"},after:{type:"string",default:"",label:"Text after the slot"}},params:{per_word:{type:"number",default:.9,min:.5,max:1.6,step:.05,unit:"s",label:"Time each word stays"},roll:{type:"number",default:.5,min:.3,max:.7,step:.05,unit:"s",label:"Time to roll to the next"},direction:{type:"choice",default:"up",options:["up","down"],label:"Roll direction"},style:{type:"choice",default:"roll",options:["roll","lift"],label:"Roll through a clipped slot, or lift: the word lifts away out of focus, a beat, the next settles in (a status line)"},gap:{type:"number",default:.05,min:0,max:.2,step:.01,unit:"s",label:"For lift: the empty beat between the words"}},duration:(e,n)=>Math.max(0,te(e.words).length-1)*l(n.per_word)+l(n.roll),build(e,n,t,r){let a=e.ownerDocument,s=te(n.words),i=l(t.per_word),o=l(t.roll),u=t.direction==="down"?-1:1,m=r.ease("quint.inOut"),d=t.style==="lift",c=r.ease("cubic.inOut"),p=Math.min(l(t.gap),o*.5),f=(o-p)/2;e.style.whiteSpace="nowrap";let g=a.createElement("span"),b=a.createElement("span");g.textContent=F(n.before)?`${F(n.before)} `:"",b.textContent=F(n.after)?` ${F(n.after)}`:"";let h=a.createElement("span");h.style.cssText=`display:inline-block;position:relative;overflow:${d?"visible":"hidden"};vertical-align:bottom;padding:0.14em 0;margin:-0.14em 0;color:var(--m-accent)`;let y=s.map(M=>{let k=a.createElement("span");return k.textContent=M,k.style.cssText="position:absolute;left:0;top:0.14em;white-space:pre",h.appendChild(k),k}),v=a.createElement("span");v.style.cssText="visibility:hidden;white-space:pre",v.textContent=s.reduce((M,k)=>k.length>M.length?k:M,""),h.appendChild(v),e.append(g,h,b);let E=y.map(M=>M.offsetWidth);return v.style.display="inline-block",v.style.width="0px",{seek(M){let k=Math.max(0,Math.min(s.length-1,Math.floor(M/i+1e-9))),R=k===0?1:ae(M-k*i,0,o,m);if(d){let L=M-k*i,j=k===0?1:ae(L,0,f,c),x=k===0?1:ae(L,f+p,f,c);y.forEach((S,$)=>{let X=$===k?1-x:$===k-1?-j:1,C=$===k?x:$===k-1?1-j:0;S.style.visibility=C<=0?"hidden":"inherit",S.style.opacity=C>=1?"":C.toFixed(4),S.style.transform=X===0?"":`translateY(${(u*X*8).toFixed(3)}px)`,S.style.filter=X===0?"":`blur(${(Math.abs(X)*2).toFixed(3)}px)`});let N=k===0?E[0]:E[k-1]+(E[k]-E[k-1])*R;h.style.width=`${N.toFixed(2)}px`;return}y.forEach((L,j)=>{let x=j===k?1-R:j===k-1?-R:1;L.style.transform=x===0?"":`translateY(${(u*x*110).toFixed(3)}%)`,L.style.visibility=Math.abs(x)>=1?"hidden":"inherit"});let z=k===0?E[0]:E[k-1]+(E[k]-E[k-1])*R;h.style.width=`${z.toFixed(2)}px`}}}};var xi="M2 1.5 L2 20.5 L7.2 15.6 L10.6 23.2 L14 21.7 L10.7 14.2 L17.6 14.2 Z",Ar=e=>Ft(e).at+Ft(e).press;function Ft(e){let n=l(e.travel),t=.08;return{travel:n,press:t,at:n+.06,end:n+.06+t*2+.55}}var Cr={slug:"ui/cursor-click",summary:"A drawn cursor moves to a target and clicks.",props:{label:{type:"string",default:"",label:"A name tag beside the cursor, for a collaborator"},target:{type:"string",default:"",label:"The id of the layer it clicks: that layer presses, and the ring leaves it in its own shape"}},params:{from_x:{type:"number",default:78,min:0,max:100,step:.5,unit:"% of width",label:"Start, across",pad:{name:"start",axis:"x"}},from_y:{type:"number",default:82,min:0,max:100,step:.5,unit:"% of height",label:"Start, down",pad:{name:"start",axis:"y"}},to_x:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of width",label:"Target, across",pad:{name:"target",axis:"x"}},to_y:{type:"number",default:50,min:0,max:100,step:.5,unit:"% of height",label:"Target, down",pad:{name:"target",axis:"y"}},travel:{type:"number",default:.7,min:.3,max:1.8,step:.05,unit:"s",label:"Time to reach the target"},arc:{type:"number",default:.06,min:0,max:.2,step:.01,unit:"ratio",label:"Bow of the path"},size:{type:"number",default:2.4,min:1.5,max:4,step:.1,unit:"% of width",label:"Cursor size"}},duration:(e,n)=>Ft(n).end,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=Ft(t),u=l(t.from_x)/100*s,m=l(t.from_y)/100*i,d=l(t.to_x)/100*s,c=l(t.to_y)/100*i,p=Math.hypot(d-u,c-m),f=l(t.arc)*p,g=(u+d)/2-(c-m)/(p||1)*f,b=(m+c)/2+(d-u)/(p||1)*f,h=l(t.size)/100*s;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none;z-index:40";let y=a.createElement("div");y.style.cssText=`position:absolute;left:${d}px;top:${c}px;width:${h*1.6}px;height:${h*1.6}px;margin:${-h*.8}px 0 0 ${-h*.8}px;border-radius:50%;border:${h*.08}px solid var(--m-accent);opacity:0`;let v=a.createElement("div");if(v.style.cssText=`position:absolute;left:0;top:0;width:${h}px;height:${h}px;transform-origin:8% 6%;filter:drop-shadow(0 ${h*.06}px ${h*.12}px rgba(0,0,0,0.28))`,v.innerHTML=`<svg viewBox="0 0 24 24" width="${h}" height="${h}" style="display:block;overflow:visible"><path d="${xi}" fill="var(--m-text-primary)" stroke="var(--m-bg-base)" stroke-width="1.5" stroke-linejoin="round"/></svg>`,F(n.label)){let R=a.createElement("span");R.textContent=F(n.label),R.style.cssText=`position:absolute;left:${h*.7}px;top:${h*.9}px;padding:${h*.12}px ${h*.3}px;border-radius:${h*.3}px;background:var(--m-bg-accent);color:var(--m-text-on-accent);font:600 ${h*.42}px var(--m-font-body);white-space:nowrap`,v.appendChild(R)}let E=!F(n.target);e.append(...E?[y]:[],v);let M=r.ease([.45,0,.15,1]),k=r.ease("expressive.out");return{seek(R){let z=ae(R,0,o.travel,M),L=(1-z)*(1-z)*u+2*(1-z)*z*g+z*z*d,j=(1-z)*(1-z)*m+2*(1-z)*z*b+z*z*c,x=ae(R,o.at,o.press,X=>X),N=ae(R,o.at+o.press,o.press*1.5,k),S=1-.14*(x-N);v.style.transform=`translate(${(L-h*.08).toFixed(2)}px, ${(j-h*.06).toFixed(2)}px) scale(${S.toFixed(4)})`,v.style.opacity=Math.min(1,R/.15).toFixed(3);let $=ae(R,o.at+o.press,.55,k);y.style.opacity=$>0?(.9*(1-$)).toFixed(3):"0",y.style.transform=`scale(${(.3+$*1.1).toFixed(4)})`}}}};var yi=e=>1+2.4*(e-1)**3+1.4*(e-1)**2,Pr=e=>Math.floor(ge(e.points).length/2),Rr={slug:"fx/pin-drop",summary:"Markers land on places one by one, ripple together, and raise their labels on stems.",props:{points:{type:"number[]",required:!0,label:"Places as x, y pairs in % of the stage: [x1, y1, x2, y2, \u2026]"},labels:{type:"string[]",default:[],label:"A short label for each place, in the same order. Left out, no card"}},params:{stagger:{type:"number",default:.28,min:.1,max:.6,step:.01,unit:"s",label:"Delay between places"},stem:{type:"number",default:120,min:0,max:260,step:5,unit:"px",label:"How high each card stands over its marker"},size:{type:"number",default:16,min:8,max:32,step:1,unit:"px",label:"Marker size"},ripple:{type:"number",default:1.3,min:.8,max:2.4,step:.05,unit:"s",label:"Time between ripples"},glow:{type:"number",default:1,min:0,max:2,step:.05,unit:"ratio",label:"Strength of the glow under each marker"}},duration:(e,n)=>Math.max(0,Pr(e)-1)*l(n.stagger)+.95,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=s/1080;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let u=ge(n.points),m=te(n.labels),d=l(t.size)*o,c=l(t.glow),p=l(t.stem)*o,f=(E,M)=>{let k=a.createElement("div");return k.style.cssText=M,E.appendChild(k),k},g=Array.from({length:Pr(n)},(E,M)=>{let k=u[M*2]/100*s,R=u[M*2+1]/100*i,z=`position:absolute;left:${k}px;top:${R}px;`,L=f(e,`${z}width:${d*6}px;height:${d*6}px;translate:-50% -50%;border-radius:50%;background:radial-gradient(closest-side,color-mix(in srgb,var(--m-accent) ${Math.round(42*Math.min(1,c))}%,transparent),color-mix(in srgb,var(--m-accent) ${Math.round(12*c)}%,transparent) 45%,transparent)`),j=f(e,`${z}width:${d*2.5}px;height:${d*2.5}px;translate:-50% -50%;border-radius:50%;border:${1.5*o}px solid var(--m-accent);box-shadow:0 0 ${12*o}px color-mix(in srgb,var(--m-accent) 45%,transparent)`),x=f(e,`${z}width:${1.5*o}px;translate:-50% 0;transform-origin:50% 100%;background:linear-gradient(color-mix(in srgb,var(--m-accent) 95%,transparent),color-mix(in srgb,var(--m-accent) 25%,transparent))`),N=f(e,`${z}width:${d}px;height:${d}px;translate:-50% -50%;border-radius:50%;background:var(--m-accent);box-shadow:0 0 0 ${3*o}px var(--m-bg-base),0 0 ${6*o}px ${2*o}px rgba(0,0,0,.5)`),S=m[M]??"",$=S?f(e,`${z}translate:-50% -100%;transform-origin:50% 100%;display:flex;align-items:center;gap:${10*o}px;white-space:nowrap;padding:${12*o}px ${16*o}px;border-radius:${10*o}px;background:color-mix(in srgb,var(--m-bg-surface) 82%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--m-text-primary) 9%,transparent),0 ${30*o}px ${60*o}px rgba(0,0,0,.45);font:var(--ui-weight-medium,500) calc(var(--m-u)*1.6)/1.25 var(--m-font-body);color:var(--m-text-primary)`):void 0;if($){f($,`flex:none;width:${d*.7}px;height:${d*.7}px;border-radius:50%;background:var(--m-accent)`);let X=a.createElement("span");X.textContent=S,$.appendChild(X)}return{y:R,halo:L,ring:j,stem:x,dot:N,card:$}}),b=l(t.stagger),h=l(t.ripple),y=r.ease("expo.out"),v=r.ease("smooth");return{seek(E){let M=Math.max(0,E)/h%1;g.forEach((k,R)=>{let z=R*b,L=Z((E-z)/.42),j=Z((E-z)/.14),x=y(Z((E-z-.14)/.81));if(k.dot.style.opacity=j.toFixed(3),k.dot.style.scale=String(Math.max(0,L<1?yi(L):1).toFixed(4)),k.halo.style.opacity=j.toFixed(3),k.halo.style.scale=ve(.5,1,y(L)).toFixed(4),k.ring.style.opacity=((1-M)**1.4*Z((E-z-.1)/.3)).toFixed(3),k.ring.style.scale=(.3+M*1.25).toFixed(4),!k.card){k.stem.style.height="0px";return}let N=p*ve(.3,1,x),S=d*.5+5*o,$=Math.max(0,N-S);k.stem.style.top=`${k.y-N}px`,k.stem.style.height=`${$}px`;let X=v(Z((E-z-.2)/.35));k.stem.style.opacity=X.toFixed(3),k.card.style.top=`${k.y-N}px`,k.card.style.scale=ve(.84,1,x).toFixed(4),k.card.style.opacity=X.toFixed(3)})}}}};var wi=["in","out","in-out","hold"];function Ve(e){return{path:{type:"choice",default:e.path,options:wi,label:"Camera path: in turns from square-on to the pose, out from the pose to square-on, in-out goes and comes back, hold stays in the pose"},tilt:{type:"number",default:e.tilt,min:-40,max:40,step:1,unit:"deg, negative faces left",label:"Turn",pad:{name:"angle",axis:"x"}},pitch:{type:"number",default:e.pitch,min:-15,max:30,step:1,unit:"deg",label:"Lean",pad:{name:"angle",axis:"y"}},roll:{type:"number",default:e.roll,min:-12,max:12,step:.5,unit:"deg",label:"Camera roll"},zoom:{type:"number",default:e.zoom,min:.5,max:1.8,step:.01,unit:"x",label:"Camera zoom in the pose (below 1 stands back)"},pan_x:{type:"number",default:0,min:-50,max:50,step:.5,unit:"% of the rig",label:"Across",pad:{name:"look",axis:"x"}},pan_y:{type:"number",default:0,min:-50,max:50,step:.5,unit:"% of the rig",label:"Down",pad:{name:"look",axis:"y"}},move:{type:"number",default:e.move,min:.4,max:3,step:.05,unit:"s",label:"Time the camera takes for each move"},hold:{type:"number",default:1,min:0,max:6,step:.05,unit:"s",label:"For in-out: time in the pose before it comes back"},ease:{type:"ease",default:"cubic.inOut",label:"Curve of each camera move"},drift:{type:"number",default:1.2,min:0,max:4,step:.1,unit:"deg/s",label:"Slow drift once the camera has arrived"}}}function Ne(e){let n=F(e.path),t=l(e.move);return n==="hold"?0:n==="in-out"?2*t+l(e.hold):t}function vi(e,n,t){let r=F(n.path),a=Math.max(.01,l(n.move));return r==="hold"?1:r==="out"?1-t(Z(e/a)):r==="in-out"?e<a?t(Z(e/a)):e<a+l(n.hold)?1:1-t(Z((e-a-l(n.hold))/a)):t(Z(e/a))}function Ge(e,n,t){let r=vi(e,n,t),a=l(n.tilt),s=l(n.pitch),i={rx:s*r,ry:a*r,rz:l(n.roll)*r,zoom:ve(1,l(n.zoom),r),x:l(n.pan_x)/100*r,y:l(n.pan_y)/100*r},o=Math.max(0,e-Ne(n)),u=l(n.drift);return o>0&&u>0&&(r>.5?(i.ry-=Math.sign(a)*Math.min(Math.abs(a)*.5,u*o),i.rx-=Math.sign(s)*Math.min(Math.abs(s)*.5,u*.4*o)):i.zoom*=1+Math.min(.06,.015*u*o)),i}function Ke(e,n,t,r){return`translateZ(${(n*(1-1/Math.max(.05,e.zoom))).toFixed(2)}px) rotateX(${e.rx.toFixed(3)}deg) rotateY(${e.ry.toFixed(3)}deg) rotateZ(${e.rz.toFixed(3)}deg) translate(${(-e.x*t).toFixed(2)}px, ${(-e.y*r).toFixed(2)}px)`}var Le=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`;function ki(e,n){let t=e.ownerDocument,r=s=>{let i=t.createElement("div");return i.style.cssText=`position:absolute;${s}`,e.appendChild(i),i};e.style.background="var(--m-bg-base)";let a=(s,i,o,u,m,d=999)=>r(`left:${s}%;top:${i}%;width:${o}%;height:${u}%;border-radius:${d}px;background:${Le(m)}`);a(5,6,9,3.6,34),[52,61,70].forEach(s=>a(s,7,6,2,18)),r("left:82%;top:5.4%;width:13%;height:5%;border-radius:999px;background:var(--m-bg-inverse)"),a(22,22,56,6.4,30),a(30,31.5,40,6.4,30),a(33,42,34,2.4,14),[[6,"var(--m-bg-surface)"],[36,"color-mix(in srgb, var(--m-accent) 22%, var(--m-bg-surface))"],[66,"var(--m-bg-surface)"]].forEach(([s,i])=>{let o=r(`left:${s}%;top:54%;width:28%;height:38%;border-radius:${n}px;background:${i};box-shadow:inset 0 0 0 1px ${Le(8)}`),u=(d,c,p)=>{let f=t.createElement("div");f.style.cssText=`position:absolute;left:9%;top:${d}%;width:${c}%;height:6%;border-radius:999px;background:${Le(p)}`,o.appendChild(f)};u(64,70,30),u(76,46,16);let m=t.createElement("div");m.style.cssText=`position:absolute;left:9%;top:12%;width:14%;aspect-ratio:1;border-radius:50%;background:${s===36?"var(--m-accent)":Le(20)}`,o.appendChild(m)})}var zr={slug:"rig/browser-window",summary:"A page in a browser window turns into perspective, then lifts one of its parts.",props:{src:{type:"string",default:"",label:"Screenshot of the page (path or URL). Left out, a placeholder page is drawn"},url:{type:"string",default:"example.com",label:"Address shown in the bar"},lift:{type:"number[]",default:[],label:"Part to lift: [x, y, width, height] in % of the page"}},params:{width:{type:"number",default:80,min:40,max:100,step:1,unit:"% of stage width",label:"Width of the window"},aspect:{type:"number",default:.625,min:.4,max:1.4,step:.005,unit:"height / width",label:"Shape of the page"},lift:{type:"number",default:140,min:0,max:320,step:5,unit:"px",label:"How far the part rises off the page"},lift_at:{type:"number",default:.8,min:0,max:6,step:.05,unit:"s",label:"When the part starts to rise (it takes 0.8 s)"},...Ve({path:"in",tilt:-24,pitch:10,roll:-2.4,zoom:.92,move:1})},duration:(e,n)=>Math.max(Ne(n),ge(e.lift).length===4&&l(n.lift)>0?l(n.lift_at)+.8:0),build(e,n,t,r){let a=e.ownerDocument,[s]=r.size,i=s/1080,o=l(t.width)/100*s,u=Math.round(40*i*(o/(s*.8))),m=o*l(t.aspect),d=m+u,c=16*i,p=o*2.2,f=F(n.src),g=a.createElement("div");g.style.cssText=`position:relative;width:${o}px;height:${d}px;perspective:${p}px`;let b=a.createElement("div");b.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%";let h=a.createElement("div");h.style.cssText=`position:absolute;inset:0;overflow:hidden;border-radius:${c}px;background:var(--m-bg-sunken);box-shadow:0 0 0 1px ${Le(9)},0 ${60*i}px ${120*i}px rgba(0,0,0,.55),0 ${20*i}px ${40*i}px rgba(0,0,0,.35)`;let y=a.createElement("div");y.style.cssText=`position:absolute;left:0;top:0;right:0;height:${u}px;display:flex;align-items:center;gap:${8*i}px;padding:0 ${16*i}px;background:var(--m-bg-surface);border-bottom:1px solid ${Le(6)}`;for(let S=0;S<3;S++){let $=a.createElement("i");$.style.cssText=`display:block;width:${11*i}px;height:${11*i}px;border-radius:50%;background:${Le(16)}`,y.appendChild($)}let v=a.createElement("b");v.textContent=F(n.url),v.style.cssText=`position:absolute;left:50%;top:50%;translate:-50% -50%;height:${u*.55}px;min-width:${o*.28}px;padding:0 ${12*i}px;border-radius:${6*i}px;background:${Le(7)};color:var(--m-text-muted);font:500 ${u*.3}px/${u*.55}px var(--m-font-body);text-align:center;letter-spacing:0.01em;white-space:nowrap`,y.appendChild(v);let E=S=>{if(f){let $=a.createElement("img");$.src=f,$.alt="",$.decoding="sync",$.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:top",S.appendChild($)}else ki(S,12*i)},M=a.createElement("div");M.style.cssText=`position:absolute;left:0;top:${u}px;width:${o}px;height:${m}px;overflow:hidden`,E(M);let k=a.createElement("div");k.style.cssText="position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(135deg,rgba(255,255,255,.06),transparent 38%);box-shadow:inset 0 1px 0 rgba(255,255,255,.1)",h.append(y,M);let R=ge(n.lift),z;if(R.length===4){let[S,$,X,C]=[R[0]/100*o,R[1]/100*m,R[2]/100*o,R[3]/100*m],q=a.createElement("div");q.style.cssText=`position:absolute;left:${S}px;top:${$+u}px;width:${X}px;height:${C}px;border-radius:${12*i}px;background:#000;opacity:0;filter:blur(${14*i}px)`,h.appendChild(q);let P=a.createElement("div");P.style.cssText=`position:absolute;left:${S}px;top:${$+u}px;width:${X}px;height:${C}px;overflow:hidden;border-radius:${12*i}px;transform-origin:50% 50%;visibility:hidden`;let Y=a.createElement("div");Y.style.cssText=`position:absolute;left:${-S}px;top:${-$}px;width:${o}px;height:${m}px`,E(Y),P.appendChild(Y),z={box:P,dim:q}}h.appendChild(k),b.appendChild(h),z&&b.appendChild(z.box),g.appendChild(b),e.appendChild(g);let L=r.ease(t.ease),j=r.ease("expo.out"),x=l(t.lift)*i,N=l(t.lift_at);return{seek(S){if(b.style.transform=Ke(Ge(S,t,L),p,o,d),!z)return;let $=j(Z((S-N)/.8)),X=x*$,C=Z(X/(140*i));z.box.style.visibility=$>0?"inherit":"hidden",z.box.style.transform=`translateZ(${X.toFixed(2)}px) scale(${(1+.04*$).toFixed(4)})`,z.box.style.boxShadow=`0 0 0 1px rgba(255,255,255,${(.08*C).toFixed(3)}),0 ${40*i*C}px ${90*i*C}px rgba(0,0,0,${(.6*C).toFixed(3)}),0 ${12*i*C}px ${28*i*C}px rgba(0,0,0,${(.35*C).toFixed(3)})`,z.dim.style.opacity=(.3*$).toFixed(3)}}}};var He=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`,Je=e=>{let n=Z(e);return n*n*(3-2*n)},ot=e=>e*Math.PI/180,Lr=["close","open","open-close"],Mi=["solid","wire"];function Or(e,n){let t=n.travel+Math.max(0,e-2)*n.stagger;return n.start+(n.order==="open-close"?2*t+n.apart:t)}function Fi(e,n,t,r=a=>a){let a=Math.max(.01,t.travel),s=u=>Array.from({length:e},(m,d)=>d===0?0:r(Z((n-u-(e-1-d)*t.stagger)/a))),i=u=>Array.from({length:e},(m,d)=>d===0?0:1-r(Z((n-u-(d-1)*t.stagger)/a)));if(t.order==="open")return s(t.start);if(t.order==="close")return i(t.start);let o=t.start+a+Math.max(0,e-2)*t.stagger+t.apart;return n<o?s(t.start):i(o)}function Ti([e,n,t],r){let a=(i,o,u)=>{let m=ot(u),d=Math.cos(m),c=Math.sin(m);return[i*d-o*c,i*c+o*d]};[e,n]=a(e,n,r.turn),[n,t]=a(n,t,r.lay),e-=r.cam.x*r.w,n-=r.cam.y*r.h,[e,n]=a(e,n,r.cam.rz),[t,e]=a(t,e,r.cam.ry),[n,t]=a(n,t,r.cam.rx),r.P>0&&(t+=r.P*(1-1/Math.max(.05,r.cam.zoom)));let s=r.P>0?r.P/Math.max(1,r.P-t):1;return[e*s,n*s]}var Dr=e=>({order:Lr.includes(F(e.order))?F(e.order):"close",start:l(e.start),travel:l(e.travel),stagger:l(e.stagger),apart:l(e.apart)}),Ir={slug:"rig/layer-stack",summary:"Named planes float one above the other, then close onto the lowest and become one layer.",props:{items:{type:"string[]",required:!0,label:"Plane names, from the base up"},faces:{type:"string[]",default:[],label:"A picture for each plane, in the same order (paths relative to the film)"},name:{type:"string",default:"",label:"What the closed stack is called"}},params:{width:{type:"number",default:42,min:15,max:90,step:1,unit:"% of stage width",label:"Width of a plane"},aspect:{type:"number",default:1,min:.4,max:1.6,step:.01,unit:"depth \xF7 width",label:"Proportions of a plane"},gap:{type:"number",default:120,min:20,max:320,step:1,unit:"px",label:"Space between planes when apart"},lay:{type:"number",default:60,min:0,max:80,step:1,unit:"deg",label:"How far the planes lie back (0 faces the camera)"},turn:{type:"number",default:-45,min:-90,max:90,step:1,unit:"deg",label:"Turn of the planes about their own axis"},spin:{type:"number",default:1.2,min:-8,max:8,step:.1,unit:"deg/s",label:"Slow turn that never stops"},order:{type:"choice",default:"close",options:Lr,label:"Close starts apart and ends as one, open the reverse, open-close does both"},start:{type:"number",default:1.4,min:0,max:10,step:.05,unit:"s",label:"When the planes start to move"},travel:{type:"number",default:.9,min:.3,max:3,step:.05,unit:"s",label:"Time one plane takes to land or lift"},stagger:{type:"number",default:.14,min:0,max:.6,step:.01,unit:"s",label:"Delay between one plane and the next"},apart:{type:"number",default:1.2,min:0,max:6,step:.05,unit:"s",label:"For open-close: time held apart"},radius:{type:"number",default:28,min:0,max:120,step:1,unit:"px",label:"Corner radius of a plane"},lens:{type:"number",default:4,min:0,max:12,step:.5,unit:"\xD7 the rig",label:"Length of the lens; 0 is parallel, as in an isometric drawing"},look:{type:"choice",default:"solid",options:Mi,label:"Solid surfaces with shadows, or a wire drawing with guides and numbered labels"},...Ve({path:"hold",tilt:0,pitch:0,roll:0,zoom:1,move:1.6})},duration:(e,n)=>{let t=te(e.items).length,r=Dr(n);return Math.max(Ne(n),Or(t,r)+(r.order==="open"?0:.9))},check(e){let n=te(e.items).length,t=te(e.faces).length,r=[];return n<2&&r.push({path:"props.items",message:"A stack needs at least two planes.",hint:"Name two to seven planes, from the base up."}),t>0&&t!==n&&r.push({path:"props.faces",message:`There are ${t} faces for ${n} planes.`,hint:"Give one picture per plane, or none."}),r},build(e,n,t,r){let a=e.ownerDocument,[s]=r.size,i=s/1080,o=te(n.items),u=te(n.faces),m=o.length,d=Dr(t),c=l(t.width)/100*s,p=c*l(t.aspect),f=l(t.gap)*i,g=l(t.radius)*i,b=l(t.lay),h=l(t.turn),y=l(t.spin),v=ot(h),E=Math.cos(ot(b)),M=Math.sin(ot(b)),k=Math.abs(c*Math.cos(v))+Math.abs(p*Math.sin(v)),R=(Math.abs(c*Math.sin(v))+Math.abs(p*Math.cos(v)))*E+(m-1)*f*M,z=Math.max(k,R)*l(t.lens),L=F(t.look)==="wire",j=-((m-1)*f)/2,x=a.createElement("div");x.style.cssText=`position:relative;width:${k}px;height:${R}px;perspective:${z>0?`${z}px`:"none"}`;let N=a.createElement("div");N.style.cssText=`position:absolute;left:${(k-c)/2}px;top:${(R-p)/2}px;width:${c}px;height:${p}px;transform-style:preserve-3d;transform-origin:50% 50%`;let S=a.createElement("div");S.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%",N.appendChild(S);let $=a.createElement("div");$.style.cssText="position:absolute;inset:0";let X="var(--m-font-body)",C=(W,H,U,G="")=>{let Q=a.createElement("div");Q.style.cssText=`position:absolute;left:0;top:0;transform-origin:0 0;display:flex;align-items:center;gap:${12*i}px;white-space:nowrap;`+(L?`font:500 ${21*i}px/1 var(--m-font-mono);letter-spacing:0.06em;text-transform:uppercase;color:${H}`:`font:500 ${27*i}px/1 ${X};letter-spacing:-0.01em;color:${H}`);let ie=a.createElement("i");ie.style.cssText=`display:block;flex:none;width:${9*i}px;height:${9*i}px;border-radius:50%;background:${U};margin-left:${-4.5*i}px`;let ue=a.createElement("i");ue.style.cssText=L?`display:block;flex:none;width:${44*i}px;height:0;border-top:${1.5*i}px dotted ${He(45)}`:`display:block;flex:none;width:${34*i}px;height:${1.5*i}px;background:${He(22)}`;let pe=a.createElement("span");if(pe.textContent=W,Q.append(ie,ue),G){let w=a.createElement("span");w.textContent=G,w.style.color=He(45),Q.appendChild(w)}Q.appendChild(pe);let de=a.createElement("div");return de.style.cssText="position:absolute;left:0;top:0;transform-origin:0 0",Q.style.transform="translateY(-50%)",de.appendChild(Q),$.appendChild(de),de},q=a.createElement("div");q.style.cssText=`position:absolute;inset:0;border-radius:${g}px;box-shadow:0 0 0 ${2*i}px var(--m-accent);visibility:hidden`,S.appendChild(q);let P=o.map((W,H)=>{let U=a.createElement("div");if(U.style.cssText=`position:absolute;inset:0;border-radius:${g}px;overflow:hidden;background:color-mix(in srgb, var(${L?"--m-bg-base":"--m-bg-surface"}) ${L?86:92}%, transparent)`,u[H]){let Q=a.createElement("img");Q.src=u[H],Q.alt=W,Q.decoding="sync",Q.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block",U.appendChild(Q)}let G=a.createElement("div");return G.style.cssText=`position:absolute;inset:0;border-radius:inherit;background:color-mix(in srgb, var(--m-accent) ${L?20:16}%, transparent);box-shadow:inset 0 0 0 ${2*i}px var(--m-accent)${L?"":`, inset 0 0 ${90*i}px color-mix(in srgb, var(--m-accent) 30%, transparent)`};opacity:0`,U.appendChild(G),S.appendChild(U),{plane:U,lit:G,tag:C(W,"var(--m-text-secondary)",He(L?80:55),L?String(H+1).padStart(2,"0"):"")}}),Y=F(n.name)?C(F(n.name),"var(--m-text-primary)","var(--m-accent)"):null;Y&&(Y.firstElementChild.style.fontWeight="600");let K="http://www.w3.org/2000/svg",_=L?[0,1,2].map(()=>{let W=$.querySelector("svg")??$.insertBefore(a.createElementNS(K,"svg"),$.firstChild);W.setAttribute("width",String(k)),W.setAttribute("height",String(R)),W.style.cssText="position:absolute;left:0;top:0;overflow:visible";let H=a.createElementNS(K,"line");return H.setAttribute("stroke",He(55)),H.setAttribute("stroke-width",String(1.5*i)),H.setAttribute("stroke-dasharray",`${1.5*i} ${7*i}`),H.setAttribute("stroke-linecap","round"),W.appendChild(H),H}):[];x.append(N,$),e.appendChild(x);let ee=r.ease(t.ease),A=r.ease("quint.inOut"),O=r.ease("expo.out"),B=Or(m,d);return{seek(W){let H=Ge(W,t,ee);N.style.transform=Ke(H,z,c,p);let U=h+y*W;S.style.transform=`rotateX(${b.toFixed(3)}deg) rotateZ(${U.toFixed(3)}deg)`;let G=(re,ne,se)=>{let[oe,le]=Ti([re-c/2,ne-p/2,se],{lay:b,turn:U,cam:H,P:z,w:c,h:p});return[k/2+oe,R/2+le]},Q=(re,ne,se)=>{let[oe,le]=G(re,ne,se);return`translate(${oe.toFixed(2)}px, ${le.toFixed(2)}px)`},ie=ot(U),ue=Math.cos(ie),pe=Math.sin(ie),de=c,w=p,T=-1/0;for(let[re,ne]of[[0,0],[c,0],[c,p],[0,p]]){let se=(re-c/2)*ue-(ne-p/2)*pe;se>T&&(T=se,de=re,w=ne)}let V=Fi(m,W,d,A),D=V[m-1]??0,J=1-D;if(P.forEach((re,ne)=>{let se=V[ne],oe=j+ne*f*se;re.plane.style.transform=`translateZ(${oe.toFixed(2)}px)`;let le=ne===0?1:Z(se*ne-(V[ne-1]??0)*(ne-1));re.plane.style.boxShadow=L?`inset 0 0 0 ${1.5*i}px ${He(ne===0?85:62)}`:`0 0 0 ${1.5*i}px ${He(ne===0?14:10+8*le)},0 0 ${70*i*le}px rgba(0,0,0,${(.38*le).toFixed(3)})`,re.plane.style.opacity=ne===0||ne===m-1?"1":Je(se/.25).toFixed(3),re.lit.style.opacity=ne===m-1?Je((J-.55)/.45).toFixed(3):"0",re.tag.style.transform=Q(de,w,oe),re.tag.style.opacity=Je(ne===0?D/.3:(se-.15)/.35).toFixed(3)}),Y&&(Y.style.transform=Q(de,w,j),Y.style.opacity=Je((J-.7)/.3).toFixed(3)),_.length){let re=[[0,0],[c,0],[c,p],[0,p]].map(([se,oe])=>({a:G(se,oe,j),b:G(se,oe,j+(m-1)*f*D)})),ne=re.reduce((se,oe,le)=>oe.a[1]<re[se].a[1]?le:se,0);re.filter((se,oe)=>oe!==ne).forEach((se,oe)=>{let le=_[oe];le.setAttribute("x1",se.a[0].toFixed(2)),le.setAttribute("y1",se.a[1].toFixed(2)),le.setAttribute("x2",se.b[0].toFixed(2)),le.setAttribute("y2",se.b[1].toFixed(2)),le.setAttribute("opacity",Je(D/.3).toFixed(3))})}let I=d.order==="open"?0:Z((W-B+.12)/.9);q.style.visibility=I>0&&I<1?"inherit":"hidden",q.style.transform=`translateZ(${j.toFixed(2)}px) scale(${(1+.32*O(I)).toFixed(4)})`,q.style.opacity=((1-I)*(1-I)*.9).toFixed(3)}}}};var lt=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`,Ei=e=>(1-Math.cos(Math.PI*Z(e)))/2;function Br(e){let n=te(e.items).length,t=Math.max(0,n-1),r=(a,s)=>typeof a=="number"&&a>=1?Math.min(t,Math.round(a)-1):s;return[r(e.from,0),r(e.to,t)]}function $i(e,n){return Array.from({length:e},(t,r)=>Math.max(0,1-Math.abs(n-r)))}var Wr={slug:"rig/tab-stack",summary:"Tabs stacked as stairs in depth; the open tab slides through them, then pops forward.",props:{items:{type:"string[]",required:!0,label:"Tab titles, in order"},details:{type:"string[]",default:[],label:"What each tab shows when open, in the same order"},from:{type:"number",default:1,label:"Tab open at the start (1 is the first)"},to:{type:"number",default:0,label:"Tab open at the end (0 is the last)"}},params:{width:{type:"number",default:64,min:30,max:100,step:1,unit:"% of stage width",label:"Width of the stack"},stack:{type:"number",default:34,min:0,max:90,step:1,unit:"px",label:"Height of each step towards the camera"},slide_at:{type:"number",default:.9,min:0,max:6,step:.05,unit:"s",label:"When the open tab starts to slide"},slide:{type:"number",default:1.6,min:.3,max:5,step:.05,unit:"s",label:"Time for the open tab to slide from first to last"},pop:{type:"number",default:46,min:0,max:140,step:1,unit:"px",label:"How far the tab that ends open pops forward"},...Ve({path:"out",tilt:-19,pitch:13,roll:-1.5,zoom:.9,move:1.6})},duration:(e,n)=>{let[t,r]=Br(e);return Math.max(Ne(n),t===r?0:l(n.slide_at)+l(n.slide)+(l(n.pop)>0?.7:0))},build(e,n,t,r){let a=e.ownerDocument,[s]=r.size,i=s/1080,o=te(n.items),u=te(n.details),m=o.length,[d,c]=Br(n),p=l(t.width)/100*s,f=18*i,g=12*i,b=78*i,h=b+118*i,y=14*i,v=m*b+(m>0?h-b:0)+Math.max(0,m-1)*g+2*f,E=Math.max(p,v)*2.4,M=a.createElement("div");M.style.cssText=`position:relative;width:${p}px;height:${v}px;perspective:${E}px;text-align:left`;let k=a.createElement("div");k.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%";let R=a.createElement("div");R.style.cssText=`position:absolute;inset:0;border-radius:${y+f}px;background:var(--m-bg-sunken);box-shadow:0 0 0 1px ${lt(9)},0 ${60*i}px ${120*i}px rgba(0,0,0,.55)`,k.appendChild(R);let z="var(--m-font-body)",L=o.map((C,q)=>{let P=a.createElement("div");P.style.cssText=`position:absolute;left:${f}px;width:${p-2*f}px;overflow:hidden;border-radius:${y}px;background:var(--m-bg-surface)`;let Y=(H,U)=>{let G=a.createElement("div");G.style.cssText=`position:absolute;left:0;right:0;top:0;height:${b}px;display:flex;align-items:center;gap:${12*i}px;padding:0 ${24*i}px;font:500 ${26*i}px/1.2 ${z};color:${H};white-space:nowrap`;let Q=a.createElement("i");Q.style.cssText=`display:block;flex:none;width:${10*i}px;height:${10*i}px;border-radius:50%;background:${U}`;let ie=a.createElement("span");return ie.textContent=C,ie.style.flex="1",G.append(Q,ie),G},K=Y("var(--m-text-muted)",lt(22)),_=a.createElement("span");_.textContent="+",_.style.cssText=`font-size:${28*i}px;color:${lt(40)}`,K.appendChild(_);let ee=a.createElement("div");ee.style.cssText="position:absolute;inset:0;background:color-mix(in srgb, var(--m-accent) 9%, var(--m-bg-surface));box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--m-accent) 28%, transparent);border-radius:inherit";let A=Y("var(--m-text-primary)","var(--m-accent)");A.firstElementChild.style.boxShadow=`0 0 ${10*i}px color-mix(in srgb, var(--m-accent) 60%, transparent)`;let O=a.createElement("p");O.textContent=u[q]??"",O.style.cssText=`position:absolute;left:${46*i}px;right:${40*i}px;top:${b-14*i}px;margin:0;font:400 ${21*i}px/1.42 ${z};color:var(--m-text-secondary)`;let B=a.createElement("div");B.style.cssText=`position:absolute;left:${24*i}px;right:${24*i}px;bottom:${16*i}px;height:${2*i}px;border-radius:9px;background:${lt(10)};overflow:hidden`;let W=a.createElement("div");return W.style.cssText="height:100%;width:100%;background:var(--m-accent);transform-origin:0 50%",B.appendChild(W),ee.append(A,O,B),P.append(K,ee),k.appendChild(P),{card:P,open:ee,fill:W}});M.appendChild(k),e.appendChild(M);let j=r.ease(t.ease),x=r.ease("expo.out"),N=l(t.stack)*i,S=l(t.pop)*i,$=l(t.slide_at),X=Math.max(.01,l(t.slide));return{seek(C){k.style.transform=Ke(Ge(C,t,j),E,p,v);let q=Ei((C-$)/X),P=d===c?d:ve(d,c,q),Y=$i(m,P),K=d===c?0:x(Z((C-$-X)/.7)),_=f;L.forEach((ee,A)=>{let O=Y[A],B=ve(b,h,O),W=N*(A+1)+(A===c?S*K:0);ee.card.style.top=`${_.toFixed(2)}px`,ee.card.style.height=`${B.toFixed(2)}px`,ee.card.style.transform=`translateZ(${W.toFixed(2)}px)`;let H=Z((N+(A===c?S*K:0))/(60*i));ee.card.style.boxShadow=`0 0 0 1px ${lt(8)},0 ${18*i*H}px ${40*i*H}px rgba(0,0,0,${(.45*H).toFixed(3)})`;let U=Z(O/.2);ee.open.style.opacity=(U*U*(3-2*U)).toFixed(3),ee.open.style.visibility=O>0?"inherit":"hidden",ee.fill.style.transform=`scaleX(${O.toFixed(4)})`,_+=B+g})}}}};var Ee=(e,n=0)=>{let t=Math.imul(e|0,668265261)^Math.imul((n|0)+2654435769,2246822507);return t=Math.imul(t^t>>>15,739982445),t=Math.imul(t^t>>>12,695872825),((t^t>>>15)>>>0)/4294967296},Nr=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2;function Hr(e,n){let t=e.ownerDocument.createElement("span");t.style.color=n,t.style.display="none",e.appendChild(t);let r=getComputedStyle(t).color;return t.remove(),r}var jr=e=>(e.match(/[\d.]+/g)?.slice(0,3)??["255","255","255"]).join(","),qr={slug:"texture/signal-field",summary:"Points jitter like static, then fall into a calm dot grid from the centre out.",props:{},params:{cols:{type:"number",default:36,min:16,max:60,step:1,unit:"columns",label:"Columns of the grid (rows follow the frame)"},settle_at:{type:"number",default:.6,min:0,max:4,step:.05,unit:"s",label:"When the noise starts to settle"},settle:{type:"number",default:1.2,min:.4,max:3,step:.05,unit:"s",label:"How long it takes to fall into the grid"},jitter:{type:"number",default:26,min:0,max:60,step:1,unit:"px",label:"How hard the static shakes"},glitch:{type:"number",default:.55,min:0,max:1,step:.05,unit:"ratio",label:"How often a glitch band tears the noise"},pulse:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Strength of the pulse that travels the grid once in order"},accent:{type:"number",default:.07,min:0,max:.2,step:.01,unit:"share",label:"Share of points in the accent colour"}},duration:(e,n)=>l(n.settle_at)+l(n.settle),build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=s/1080,u=r.fps||30;e.style.cssText+=";position:absolute;inset:0;max-width:none;pointer-events:none";let m=a.createElement("canvas");m.style.cssText=`position:absolute;left:0;top:0;width:${s}px;height:${i}px`,e.appendChild(m);let d=m.getContext("2d"),c=jr(Hr(e,"currentColor")),p=jr(Hr(e,"var(--m-accent)")),f=Math.max(2,Math.round(l(t.cols))),g=Math.max(2,Math.round(f*i/s)),b=f*g,h=Math.round(b*1.6),y=r.seed*7919,v=Math.hypot(s/2,i/2),E=l(t.accent),M=Array.from({length:h},(x,N)=>{let S=N%b,$=N+y,X=(S%f+.5)*(s/f),C=(Math.floor(S/f)+.5)*(i/g);return{x:Ee($,1)*s,y:Ee($,2)*i,vx:(Ee($,3)-.5)*40*o,vy:(Ee($,4)-.5)*24*o,gx:X,gy:C,d:Math.hypot(X-s/2,C-i/2)/v,r:(.7+Ee($,5)*1.5)*o,a:.18+Ee($,6)*.5,hot:Ee($,7)<E}}),k=l(t.settle_at),R=Math.max(.01,l(t.settle)),z=l(t.jitter)*o,L=l(t.glitch),j=l(t.pulse);return{seek(x){if(!d)return;let N=Math.round(x*u);Mt(m,d,r.size,r),d.clearRect(0,0,s,i);let S=Nr(Z((x-k)/R)),$=(1-S)**1.5,X=Math.floor(N/5)+y,C=Ee(X,11)*i,q=(20+Ee(X,12)*120)*o,P=(Ee(X,13)-.5)*140*o*$*(Ee(X,14)<L?1:0);for(let Y=0;Y<h;Y++){let K=M[Y],_=Y+y,ee=(K.x+K.vx*x+(Ee(_,N)-.5)*z*$)%s,A=(K.y+K.vy*x+(Ee(_,N+7777)-.5)*z*$)%i;ee<0&&(ee+=s),A<0&&(A+=i),A>C&&A<C+q&&(ee+=P);let O=Nr(Z(S*1.35-K.d*.35)),B=ve(ee,K.gx+Math.sin(x*.8+K.gy*.01)*2*o,O),W=ve(A,K.gy,O),H=Math.max(0,Math.sin(K.gy/i*7-x*3.2))**6*O*j,U=ve(.35+Ee(_,N+3)*.9,.55,O),G=ve(K.a*U*1.25,.17+H,O),Q=ve(K.r,1.05*o,O);d.fillStyle=`rgba(${K.hot?p:c},${Z(K.hot?G*1.6:G).toFixed(3)})`,d.fillRect(B-Q,W-Q,Q*2,Q*2)}}}}};var Zr={down:[0,1],up:[0,-1],right:[1,0],left:[-1,0]};function Ht(e,n,t){let r=t.ease("smooth")(e),a=Math.sin(Math.PI*Z(e))**2;return{travel:r,scale:1-l(n.pull)*a,tilt:l(n.tilt)*a,edge:a}}var Xr={slug:"transition/camera-travel",summary:"The camera pulls back and travels to the next scene, laid beside this one in one world.",duration:1.4,calm:{pull:.04,tilt:5,gap:0,shutter:.3},params:{duration:{type:"number",default:1.4,min:.8,max:2.4,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"down",options:["down","up","right","left"],label:"Where the next scene lies"},pull:{type:"number",default:.32,min:0,max:.6,step:.01,unit:"ratio",label:"How far the camera pulls back on the way"},tilt:{type:"number",default:14,min:0,max:30,step:1,unit:"deg",label:"How far the world leans while it travels"},gap:{type:"number",default:.18,min:0,max:.6,step:.01,unit:"of the frame",label:"Space between the two scenes"},shutter:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Motion blur: share of a frame the move smears over"}},apply(e,n,t,r,a){let[s,i]=a.size,[o,u]=Zr[F(r.direction)]??Zr.down,m=(u?i:s)*(1+l(r.gap)),d=Math.max(s,i)*2.2,c=(v,E)=>{let M=(E-v.travel)*m,k=u?`rotateX(${(u*v.tilt).toFixed(3)}deg) rotateZ(${(-.12*v.tilt).toFixed(3)}deg)`:`rotateY(${(-o*v.tilt).toFixed(3)}deg) rotateZ(${(.12*v.tilt).toFixed(3)}deg)`;return`perspective(${d}px) scale(${v.scale.toFixed(5)}) ${k} translate(${(o*M).toFixed(2)}px, ${(u*M).toFixed(2)}px)`},p=Ht(t,r,a);e.style.transform=c(p,0),n.style.transform=c(p,1);for(let v of[e,n])v.style.transformOrigin="50% 50%",v.style.borderRadius=`${(Math.min(s,i)*.03*p.edge).toFixed(2)}px`,v.style.boxShadow=p.edge>.01?`0 0 0 1px rgba(255,255,255,${(.08*p.edge).toFixed(3)}), 0 ${(60*p.edge).toFixed(1)}px ${(120*p.edge).toFixed(1)}px rgba(0,0,0,${(.5*p.edge).toFixed(3)})`:"";let f=.5/a.fps/l(r.duration),g=Ht(Z(t-f),r,a),h=(Ht(Z(t+f),r,a).travel-g.travel)*m*p.scale,y=ke(h,l(r.shutter));e.style.filter=Te(e,o?y:0,u?y:0),n.style.filter=Te(n,o?y:0,u?y:0)},clear(e){e.style.transform="",e.style.transformOrigin="",e.style.borderRadius="",e.style.boxShadow="",e.style.filter=""}};var ut=new WeakMap,Yr={slug:"transition/fly-past",summary:"The layers of a scene fly out past the camera, front first, revealing the next beneath.",duration:1.1,calm:{spread:.15,tumble:15,defocus:2},params:{duration:{type:"number",default:1.1,min:.6,max:1.8,step:.05,unit:"s",label:"Length of the hand-over"},spread:{type:"number",default:.35,min:0,max:.6,step:.01,unit:"ratio",label:"Share of the time between the first layer leaving and the last"},tumble:{type:"number",default:50,min:0,max:80,step:1,unit:"deg",label:"How far each layer turns away as it passes"},defocus:{type:"number",default:4,min:0,max:10,step:.5,unit:"px",label:"Blur as a layer reaches the lens"},settle:{type:"number",default:.05,min:0,max:.12,step:.005,unit:"ratio",label:"How much closer the next scene starts"}},apply(e,n,t,r,a){let[s,i]=a.size,o=Math.max(s,i)*1.6,u=e.getBoundingClientRect(),m=u.width>0?u.width/s:1,d=[...e.querySelectorAll(":scope > .m-cam > .m-layer")].filter(h=>h.style.visibility!=="hidden"),c=d.length,p=l(r.spread),f=1-p;d.forEach((h,y)=>{let v=c-1-y,E=c>1?v/(c-1)*p:0,M=Z((t-E)/f),k=M**2.3;if(M<=0)return;let R=h.getBoundingClientRect(),z=((R.left+R.width/2-u.left)/m-s/2)/(s/2),L=((R.top+R.height/2-u.top)/m-i/2)/(i/2),j=Math.hypot(z,L);j<.15?(z=.12,L=-1):(z/=j,L/=j);let x=Math.max(s,i)*.9*k,N=o*.82*k,S=l(r.tumble),$=`perspective(${o}px) translate3d(${(z*x).toFixed(2)}px, ${(L*x).toFixed(2)}px, ${N.toFixed(2)}px) rotateX(${(-L*S*k).toFixed(3)}deg) rotateY(${(z*S*k).toFixed(3)}deg) rotate(${((y%2?12:-12)*k).toFixed(3)}deg)`;h.style.transform=`${$} ${h.style.transform}`,h.style.opacity=String(Number(h.style.opacity||1)*(1-a.ease("smooth")(Z((M-.7)/.3))));let X=l(r.defocus)*k*k;X>.05&&(h.style.filter=`${h.style.filter} blur(${X.toFixed(2)}px)`.trim())});let g=a.ease("expo.out")(Z(t/.85));n.style.transformOrigin="50% 50%",n.style.transform=`scale(${(1+l(r.settle)*(1-g)).toFixed(4)})`,ut.has(e)||ut.set(e,{zIndex:e.style.zIndex,background:e.style.background,ground:getComputedStyle(e).backgroundColor}),e.style.zIndex=String((Number(n.style.zIndex)||0)+1);let b=1-a.ease("smooth")(Z(t/.45));e.style.background=b>.001?`color-mix(in srgb, ${ut.get(e).ground} ${(b*100).toFixed(2)}%, transparent)`:"transparent"},clear(e){e.style.transform="",e.style.transformOrigin="";let n=ut.get(e);n&&(e.style.zIndex=n.zIndex,e.style.background=n.background,ut.delete(e))}};var Tt=new WeakMap,Ur={slug:"transition/signal-wipe",summary:"A glowing accent line sweeps across and leaves the next scene behind it.",duration:.55,calm:{glow:.5,push:.01},params:{duration:{type:"number",default:.55,min:.35,max:1.2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"down",options:["down","up","right","left"],label:"Which way the line travels"},glow:{type:"number",default:1,min:0,max:2,step:.05,unit:"ratio",label:"Strength of the glow and its trailing wash"},trail:{type:"number",default:.16,min:0,max:.4,step:.01,unit:"of the frame",label:"Length of the wash behind the line"},push:{type:"number",default:.04,min:0,max:.1,step:.005,unit:"ratio",label:"How much the outgoing scene grows as it is covered"}},apply(e,n,t,r,a){let[s,i]=a.size,o=F(r.direction)||"down",u=a.ease("quint.inOut")(Z(t)),m=o==="down"||o==="up",d=m?i:s,c=30,p=-c+u*(d+2*c),f=Z(p,0,d),g={down:`0 0 ${d-f}px 0`,up:`${d-f}px 0 0 0`,right:`0 ${d-f}px 0 0`,left:`0 0 0 ${d-f}px`}[o];n.style.clipPath=f>=d?"":`inset(${g})`,e.style.transformOrigin="50% 50%",e.style.transform=`scale(${(1+l(r.push)*u).toFixed(4)})`;let b=n.parentElement;if(!b)return;let h=Tt.get(n);if(!h){h=n.ownerDocument.createElement("div"),h.className="m-signal-line";let R=n.ownerDocument.createElement("div");h.appendChild(R),b.appendChild(h),Tt.set(n,h)}let y=l(r.glow),v=l(r.trail)*d,E=o==="down"||o==="right"?p:d-p,M={down:"to top",up:"to bottom",right:"to left",left:"to right"}[o],k=h.firstElementChild;h.style.cssText="position:absolute;z-index:999;pointer-events:none;background:color-mix(in srgb, var(--m-accent) 70%, white);"+(m?`left:0;right:0;height:2px;top:${(E-1).toFixed(2)}px;`:`top:0;bottom:0;width:2px;left:${(E-1).toFixed(2)}px;`)+`box-shadow:0 0 ${22*y}px ${5*y}px color-mix(in srgb, var(--m-accent) ${Math.round(55*Math.min(1,y))}%, transparent),0 0 4px 1px color-mix(in srgb, var(--m-accent) 40%, white);opacity:${t<=0||t>=1?0:1}`,k.style.cssText=`position:absolute;${m?`left:0;right:0;height:${v}px;`:`top:0;bottom:0;width:${v}px;`}`+{down:"bottom:2px;",up:"top:2px;",right:"right:2px;",left:"left:2px;"}[o]+`background:linear-gradient(${M}, color-mix(in srgb, var(--m-accent) ${Math.round(16*y)}%, transparent), transparent)`},clear(e){e.style.clipPath="",e.style.transform="",e.style.transformOrigin="",Tt.get(e)?.remove(),Tt.delete(e)}};var Vr={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},Gr={slug:"transition/whip-pan",summary:"The camera whips to the next scene with a streak along the pan only, then brakes.",duration:.5,calm:{anticipation:0,shutter:.3},params:{duration:{type:"number",default:.5,min:.3,max:.9,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"left",options:["left","right","up","down"],label:"Which way the frame travels"},anticipation:{type:"number",default:.03,min:0,max:.08,step:.005,unit:"of the frame",label:"How far it pulls back before it goes"},shutter:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Motion blur: share of a frame the whip smears over"}},apply(e,n,t,r,a){let[s,i]=a.size,[o,u]=Vr[F(r.direction)]??Vr.left,m=o?s:i,d=l(r.anticipation)*m,c=a.ease("expo.inOut"),p=v=>(v<.3?-d*Math.sin(Math.PI*Z(v/.3)):0)+m*c(Z((v-.12)/.88)),f=.5/(a.fps||30)/l(r.duration),g=p(Z(t+f))-p(Z(t-f)),b=p(t);e.style.transform=`translate(${(o*b).toFixed(2)}px, ${(u*b).toFixed(2)}px)`,n.style.transform=`translate(${(o*(b-m)).toFixed(2)}px, ${(u*(b-m)).toFixed(2)}px)`;let h=ke(g,l(r.shutter)),y=h;e.style.filter=Te(e,o?h:0,u?h:0,90),n.style.filter=Te(n,o?y:0,u?y:0,90)},clear(e){e.style.transform="",e.style.filter=""}};function Si(e,n){let t=n+(1-n)*.55,r=Z(e);return r<.5?n+(t-n)*r*2:t+(1-t)*(r-.5)*2}function Ai(e,n,t){let r=Math.max(1,t),a=Z(n)*(e-1+r);return Array.from({length:e},(s,i)=>Z((a-i)/r))}var Kr={slug:"type/fill-text",summary:"The whole line is there, dim; each word fills to full in reading order.",props:{text:{type:"string",required:!0,label:"The text. Use \\n to set the line breaks yourself."},accent:{type:"string[]",default:[],label:"Words that fill to the accent colour"}},params:{duration:{type:"number",default:1.7,min:.4,max:4,step:.05,unit:"s",label:"Time for the whole fill"},dim:{type:"number",default:.35,min:0,max:.6,step:.01,unit:"opacity",label:"How dim the words wait (0: unseen, so the text streams in)"},blur:{type:"number",default:0,min:0,max:6,step:.1,unit:"px",label:"Soft focus a word fills out of"},rise:{type:"number",default:0,min:0,max:12,step:.5,unit:"px",label:"How far a word rises as it fills"},word_ease:{type:"ease",default:"linear",label:"Pace of each word's own fill"},soft:{type:"number",default:1.5,min:1,max:8,step:.1,unit:"words",label:"How many words fill at once"},ease:{type:"ease",default:"smooth",label:"Pace of the fill along the line"}},duration:(e,n)=>l(n.duration),build(e,n,t,r){let{words:a}=Se(e,F(n.text),{accent:te(n.accent)}),s=a.map(g=>{let b=/^\{(.+)\}([^\p{L}\p{N}]*)$/u.exec(g.textContent??"");return b?(g.textContent=b[1],g.style.cssText+=";padding:0 0.38em;margin:0 0.05em;border-radius:999px;font-size:0.62em;line-height:1.55;vertical-align:0.18em;font-weight:600;color:var(--m-accent);background:color-mix(in srgb, var(--m-accent) 16%, transparent)",!0):!1}),i=r.ease(t.ease),o=r.ease(t.word_ease),u=r.ease("bounce.out"),m=Math.max(.001,l(t.duration)),d=l(t.dim),c=l(t.soft),p=l(t.blur),f=l(t.rise);return{seek(g){let b=Ai(a.length,i(Z(g/m)),c);a.forEach((h,y)=>{let v=o(b[y]);if(s[y]){let M=Z(v*3);h.style.opacity=M>=1?"":M.toFixed(4),h.style.transform=v>=1?"":`scale(${(.5+.5*u(v)).toFixed(4)})`;return}let E=Si(v,d);h.style.opacity=E>=1?"":E.toFixed(4),h.style.filter=p>0&&v<1?`blur(${((1-v)*p).toFixed(3)}px)`:"",h.style.transform=f>0&&v<1?`translateY(${((1-v)*f).toFixed(3)}px)`:""})}}}};function Ci(e,n){let t=Z(e),r=Math.max(1,n.from+(n.to-n.from)*t),a=(r-1)/2,s=i=>Z(i/100*(t-.5),-a,a);return{scale:r,x:s(n.pan_x),y:s(n.pan_y)}}var Jr={slug:"fx/slow-push",summary:"A still picture in a fixed frame slowly pushes in, pulls out or pans while it is held.",props:{src:{type:"string",required:!0,label:"Image path or URL"},alt:{type:"string",default:"",label:"Description of the picture"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Frame width"},height:{type:"number",default:800,min:1,max:4e3,step:1,unit:"px",label:"Frame height"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"},from:{type:"number",default:1.08,min:1,max:1.6,step:.01,unit:"\xD7",label:"Scale at the start"},to:{type:"number",default:1,min:1,max:1.6,step:.01,unit:"\xD7",label:"Scale at the end"},pan_x:{type:"number",default:0,min:-30,max:30,step:.5,unit:"% of frame",label:"Sideways travel over the move",pad:{name:"pan",axis:"x"}},pan_y:{type:"number",default:0,min:-30,max:30,step:.5,unit:"% of frame",label:"Vertical travel over the move",pad:{name:"pan",axis:"y"}},focus_x:{type:"number",default:50,min:0,max:100,step:1,unit:"% of picture",label:"Point of the picture to keep in frame, across",pad:{name:"focus",axis:"x"}},focus_y:{type:"number",default:50,min:0,max:100,step:1,unit:"% of picture",label:"Point of the picture to keep in frame, down",pad:{name:"focus",axis:"y"}},duration:{type:"number",default:4,min:.5,max:30,step:.1,unit:"s",label:"Length of the move"},ease:{type:"ease",default:"linear",label:"Curve of the move; linear reads as drift, sine.inOut as a camera that starts and settles"}},cues:()=>[],duration:(e,n)=>l(n.duration,4),build(e,n,t,r){let a=e.ownerDocument.createElement("img");a.src=F(n.src),a.alt=F(n.alt),a.decoding="sync",e.style.cssText+=`;width:${l(t.width)}px;height:${l(t.height)}px;border-radius:${l(t.radius)}px;overflow:hidden`;let s=`${l(t.focus_x,50)}% ${l(t.focus_y,50)}%`;a.style.cssText=`display:block;width:100%;height:100%;object-fit:cover;object-position:${s};transform-origin:${s};will-change:transform`,e.appendChild(a);let i=r.ease(t.ease),o=l(t.duration,4),u={from:l(t.from,1.08),to:l(t.to,1),pan_x:l(t.pan_x),pan_y:l(t.pan_y)};return{seek(m){let d=Ci(i(Z(m/o)),u);a.style.transform=`translate(${(d.x*100).toFixed(4)}%, ${(d.y*100).toFixed(4)}%) scale(${d.scale.toFixed(5)})`}}}};function Qr(e,n,t=1){let[r,a]=e,s=Math.max(.01,n),i=Math.max(1,t);if(s>=r/a){let m=a*i,d=m*s;return{axis:"x",w:d,h:m,spare:Math.max(0,d-r)}}let o=r*i,u=o/s;return{axis:"y",w:o,h:u,spare:Math.max(0,u-a)}}function Pi(e,n=200){let t=0;for(let r=0;r<n;r++)t=Math.max(t,Math.abs(e((r+1)/n)-e(r/n))*n);return t}function Ri(e,n,t,r,a){return Math.abs(t-n)/100*e.spare*Pi(a)/Math.max(.01,r)}var _r=(e,n)=>[l(e.width)||n[0],l(e.height)||n[1]],ea={slug:"fx/pan-across",summary:"The camera travels along a picture wider or taller than its frame.",props:{src:{type:"string",required:!0,label:"Image path or URL"},alt:{type:"string",default:"",label:"Description of the picture"}},params:{width:{type:"number",default:0,min:0,max:4e3,step:1,unit:"px",label:"Frame width; 0 is the stage"},height:{type:"number",default:0,min:0,max:4e3,step:1,unit:"px",label:"Frame height; 0 is the stage"},aspect:{type:"number",default:1.78,min:.2,max:6,step:.01,unit:"w \xF7 h",label:"The picture's width over its height"},from:{type:"number",default:20,min:0,max:100,step:1,unit:"% of travel",label:"Where the view starts: 0 one end of the picture, 100 the other"},to:{type:"number",default:80,min:0,max:100,step:1,unit:"% of travel",label:"Where the view ends"},scale:{type:"number",default:1,min:1,max:1.3,step:.01,unit:"\xD7",label:"Extra size, to leave room across the travel"},duration:{type:"number",default:4,min:.5,max:30,step:.1,unit:"s",label:"Length of the travel"},ease:{type:"ease",default:"sine.inOut",label:"Curve of the travel: sine.inOut starts and settles like a camera"}},cues:()=>[],duration:(e,n)=>l(n.duration,4),speed(e,n,t){let r=Qr(_r(n,t.size),l(n.aspect,1.78),l(n.scale,1));return Ri(r,l(n.from,20),l(n.to,80),l(n.duration,4),Re(n.ease??"sine.inOut"))},build(e,n,t,r){let[a,s]=_r(t,r.size),i=Qr([a,s],l(t.aspect,1.78),l(t.scale,1)),o=e.ownerDocument.createElement("img");o.src=F(n.src),o.alt=F(n.alt),o.decoding="sync",e.style.cssText+=`;position:relative;width:${a}px;height:${s}px;overflow:hidden`;let u=i.axis==="x"?(s-i.h)/2:(a-i.w)/2;o.style.cssText=`position:absolute;left:0;top:0;display:block;width:${i.w}px;height:${i.h}px;object-fit:cover;max-width:none;will-change:transform`,e.appendChild(o);let m=r.ease(t.ease),d=l(t.duration,4),c=l(t.from,20),p=l(t.to,80);return{seek(f){let g=-i.spare*((c+(p-c)*m(Z(f/d)))/100),[b,h]=i.axis==="x"?[g,u]:[u,g];o.style.transform=`translate3d(${b.toFixed(3)}px, ${h.toFixed(3)}px, 0)`}}}};function zi(e,n){let t=e.slice(1).map((a,s)=>Math.sqrt(Math.abs(a-e[s]))),r=t.reduce((a,s)=>a+s,0);return t.map(a=>r>0?n*a/r:n/t.length)}function Oi(e,n,t){let r=[n.from,...n.stops,n.to],a=r.length-1,s=a>1?Math.min(n.rest,n.duration*.5/(a-1)):0,i=zi(r,n.duration-s*(a-1)),o=e-n.delay;if(o<=0)return r[0];for(let u=0;u<a;u++){let m=i[u];if(o<m)return r[u]+(r[u+1]-r[u])*t(Z(o/m));if(o-=m,u<a-1){if(o<s)return r[u+1];o-=s}}return r[a]}var ta=(e,n)=>({from:l(n.from),to:l(n.to,100),stops:ge(e.stops),duration:l(n.duration,3),rest:l(n.rest,.4),delay:l(n.delay)}),jt=150,na={slug:"ui/page-scroll",summary:"A page scrolls inside a window, resting on its sections, blurred only by its own speed.",props:{srcs:{type:"string[]",required:!0,label:"The page: one tall capture, or its sections from top to bottom"},alt:{type:"string",default:"",label:"Description of the page"},stops:{type:"number[]",default:[],label:"Where the scroll rests on the way, in % of the scrollable height"}},params:{width:{type:"number",default:640,min:1,max:4e3,step:1,unit:"px",label:"Window width"},height:{type:"number",default:800,min:1,max:4e3,step:1,unit:"px",label:"Window height"},radius:{type:"number",default:16,min:0,max:400,step:1,unit:"px",label:"Corner radius"},from:{type:"number",default:0,min:0,max:100,step:.5,unit:"% of scroll",label:"Where the scroll starts"},to:{type:"number",default:100,min:0,max:100,step:.5,unit:"% of scroll",label:"Where the scroll ends"},duration:{type:"number",default:3,min:.4,max:30,step:.05,unit:"s",label:"Length of the scroll, rests included"},rest:{type:"number",default:.4,min:0,max:3,step:.05,unit:"s",label:"Time resting at each stop"},delay:{type:"number",default:0,min:0,max:30,step:.05,unit:"s",label:"Time held at the start before it scrolls"},ease:{type:"ease",default:"sine.inOut",label:"Curve of each leg"},shutter:{type:"number",default:.5,min:0,max:1,step:.05,unit:"ratio",label:"Motion blur: share of a frame the scroll smears over"}},duration:(e,n)=>{let t=ta(e,n);return t.delay+t.duration},build(e,n,t,r){let a=e.ownerDocument,s=l(t.width),i=l(t.height);e.style.cssText+=`;width:${s}px;height:${i}px;border-radius:${l(t.radius)}px;overflow:hidden`;let o=a.createElement("div");o.style.cssText=`position:relative;width:${s}px;height:${i}px`;let u=a.createElement("div");u.style.cssText=`position:absolute;left:0;top:${-jt}px;width:${s}px;height:${i+2*jt}px;overflow:hidden`;let m=a.createElement("div");m.style.cssText=`position:absolute;left:0;top:${jt}px;width:${s}px;will-change:transform`,te(n.srcs).forEach((g,b)=>{let h=a.createElement("img");h.src=g,h.alt=b===0?F(n.alt):"",h.decoding="sync",h.style.cssText="display:block;width:100%;height:auto",m.appendChild(h)}),u.appendChild(m),o.appendChild(u),e.appendChild(o);let d=ta(n,t),c=r.ease(t.ease),p=l(t.shutter,.5),f=.5/r.fps;return{seek(g){let b=Math.max(0,m.offsetHeight-i),h=y=>Oi(y,d,c)/100*b;m.style.transform=`translateY(${(-h(g)).toFixed(2)}px)`,u.style.filter=Te(u,0,ke(h(g+f)-h(g-f),p))}}}};var Di=["down","up","center","edges","random"],Li=["left","right","alternate","weave"],Ii=["none","start","end","both"];function Et(e,n){let t=Array.from({length:e},(r,a)=>a);return(n==="start"||n==="both")&&t.unshift(null),(n==="end"||n==="both")&&t.push(null),t}var Bi=.6;function Wi(e,n,t,r,a=1){let s=Me(e,t,Ni(r),a),i=Math.max(0,...s),o=Bi*n,u=i>o?o/i:1;return{delays:s.map(m=>m*u),travel:n-i*u}}var Ni=e=>e==="down"?"start":e==="up"?"end":e;function qt(e,n,t){let r=Math.max(1,e),a=o=>typeof n=="number"?n:n[o]??n[n.length-1]??0,s=[],i=0;for(let o=0;o<r-1;o++)i+=a(o),s.push(i),i+=t;return{changes:s,change:t,duration:i+a(r-1)}}var Zt=(e,n,t)=>e.map(r=>r===null&&t>0?t:n);function Hi(e,n,t){return e==="left"?1:e==="right"?-1:(e==="weave"?n+t:n)%2===0?1:-1}function ji(e,n,t,r,a,s){let i=t[r]??0;for(let u=0;u<n.changes.length;u++){let m=n.changes[u]+i;if(e<m)return{from:u,to:u,u:0};if(e<m+a)return{from:u,to:u+1,u:s(Z((e-m)/a))}}let o=n.changes.length;return{from:o,to:o,u:0}}var ra={slug:"scene/strip-cycle",summary:"Pictures change strip by strip across a ruled grid, each change led by a field of colour.",props:{images:{type:"string[]",required:!0,label:"Pictures, in the order they fill the frame"},fills:{type:"string[]",default:["accent"],label:"Colours that lead each change, in turn (surface names or CSS colours)"},rule:{type:"string",default:"var(--m-text-primary)",label:"Colour of the rules"}},params:{rows:{type:"number",default:8,min:2,max:16,step:1,unit:"strips",label:"Strips in the grid"},width:{type:"number",default:100,min:20,max:100,step:1,unit:"% of stage",label:"Frame width"},height:{type:"number",default:100,min:20,max:100,step:1,unit:"% of stage",label:"Frame height"},hold:{type:"number",default:1.2,min:.3,max:6,step:.05,unit:"s",label:"Time each picture stays whole"},ground_hold:{type:"number",default:0,min:0,max:6,step:.05,unit:"s",label:"Time the bare ground holds at a start or end (0: as long as a picture)"},shift:{type:"number",default:1,min:.3,max:2.5,step:.05,unit:"s",label:"Time one change takes, first strip to last"},stagger:{type:"number",default:.05,min:0,max:.3,step:.01,unit:"s",label:"Delay between strips"},order:{type:"choice",default:"down",options:Di,label:"Which strips change first"},direction:{type:"choice",default:"left",options:Li,label:"Which way the strips run: left is forward, in the reading direction"},lead:{type:"number",default:.35,min:0,max:1,step:.01,unit:"\xD7 frame width",label:"Length of the colour field ahead of the picture"},drag:{type:"number",default:.12,min:0,max:.5,step:.01,unit:"\xD7 frame width",label:"How far the leaving picture is pushed along"},push:{type:"number",default:1.06,min:1,max:1.3,step:.01,unit:"\xD7",label:"Scale a picture arrives at, settling to 1 while it is seen"},rule_width:{type:"number",default:2,min:0,max:12,step:.5,unit:"px",label:"Weight of the rules (0 for none)"},rule_opacity:{type:"number",default:.6,min:0,max:1,step:.05,unit:"ratio",label:"Opacity of the rules"},edges:{type:"boolean",default:!1,label:"Rule the top and bottom edges too"},empty:{type:"choice",default:"none",options:Ii,label:"Begin and/or end on the bare ruled ground"},ease:{type:"ease",default:"quart.inOut",label:"Curve of each strip"}},duration(e,n){let t=Et(te(e.images).length,F(n.empty,"none"));return qt(t.length,Zt(t,l(n.hold,1.2),l(n.ground_hold,0)),l(n.shift,1)).duration},cues(e,n){let t=Et(te(e.images).length,F(n.empty,"none")),r=qt(t.length,Zt(t,l(n.hold,1.2),l(n.ground_hold,0)),l(n.shift,1));return r.changes.map(a=>({at:a,length:r.change}))},check(e,n){let t=[];return te(e.images).length||t.push({path:"props.images",message:"The strips need at least one picture.",hint:"Add picture paths to images."}),Et(te(e.images).length,F(n.empty,"none")).length<2&&t.push({path:"props.images",message:"With one picture and no empty ground, nothing ever changes.",hint:"Add a picture, or set empty to start, end or both."}),t},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=Math.round(s*l(t.width,100)/100),u=Math.round(i*l(t.height,100)/100),m=Math.round(l(t.rows,8)),d=te(n.images),c=te(n.fills).length?te(n.fills):["accent"],p=Et(d.length,F(t.empty,"none")),f=l(t.shift,1),g=l(t.hold,1.2),b=l(t.lead,.35),h=l(t.drag,.12),y=l(t.push,1.06),v=F(t.order,"down"),E=F(t.direction,"left"),{delays:M,travel:k}=Wi(m,f,l(t.stagger,.05),v,r.seed),R=qt(p.length,Zt(p,g,l(t.ground_hold,0)),f),z=r.ease(t.ease),L=C=>["base","surface","sunken","accent","inverse"].includes(C)?`var(--m-bg-${C})`:C;e.style.cssText+=`;width:${o}px;height:${u}px;position:relative;overflow:hidden`;let j=Array.from({length:m+1},(C,q)=>Math.round(q*u/m)),x=p.map((C,q)=>{let P=q===0?0:R.changes[q-1],Y=q===p.length-1?R.duration:R.changes[q]+R.change;return[P,Math.max(P+1e-6,Y)]}),N=j.slice(0,-1).map((C,q)=>{let P=j[q+1]-C,Y=a.createElement("div");Y.style.cssText=`position:absolute;left:0;top:${C}px;width:${o}px;height:${P}px;overflow:hidden`;let K=p.map((_,ee)=>{let A=a.createElement("div");A.style.cssText=`position:absolute;left:0;top:0;width:${o}px;height:${P}px;visibility:hidden;will-change:transform`;let O=a.createElement("div"),B=L(c[Math.max(0,ee-1)%c.length]);O.style.cssText=`position:absolute;top:0;height:${P}px;width:${Math.ceil(o*b)+1}px;background:${B}`,A.appendChild(O);let W;if(_!==null){let H=a.createElement("div");H.style.cssText=`position:absolute;left:0;top:0;width:${o}px;height:${P}px;overflow:hidden`,W=a.createElement("img"),W.src=d[_],W.alt="",W.decoding="sync",W.style.cssText=`position:absolute;left:0;top:${-C}px;width:${o}px;height:${u}px;object-fit:cover;transform-origin:${o/2}px ${u/2}px;max-width:none`,H.appendChild(W),A.appendChild(H)}return Y.appendChild(A),{box:A,img:W,field:O}});return e.appendChild(Y),{panes:K,h:P}}),S=l(t.rule_width,2);if(S>0){let C=t.edges?0:1,q=t.edges?m:m-1;for(let P=C;P<=q;P++){let Y=Math.min(u-S,Math.max(0,j[P]-S/2)),K=a.createElement("div");K.style.cssText=`position:absolute;left:0;top:${Y}px;width:${o}px;height:${S}px;background:${F(n.rule,"var(--m-text-primary)")};opacity:${l(t.rule_opacity,.6)};pointer-events:none`,e.appendChild(K)}}let $=Math.ceil(o*b)+1,X=(C,q,P,Y,K,_="",ee=!1)=>{if(C.box.style.visibility="inherit",C.field.style.visibility=ee?"inherit":"hidden",C.box.style.transform=`translate3d(${q.toFixed(2)}px,0,0)`,C.box.style.clipPath=_,C.field.style.left=P===1?`${-$+1}px`:`${o-1}px`,C.img){let[A,O]=x[K],B=Z((Y-A)/(O-A));C.img.style.transform=`scale(${(y+(1-y)*B).toFixed(5)})`}};return{seek(C){N.forEach(({panes:q},P)=>{let{from:Y,to:K,u:_}=ji(C,R,M,P,k,z);if(q.forEach(H=>{H.box.style.visibility="hidden"}),Y===K){X(q[Y],0,1,C,Y);return}let ee=Hi(E,P,Y),A=o*(1+b),O=ee*A*(1-_),B=-ee*h*o*_,W=ee===1?Math.max(0,B+o-(O-$+1)):Math.max(0,O+o+$-1-B);X(q[Y],B,ee,C,Y,ee===1?`inset(0 ${W.toFixed(2)}px 0 -${$}px)`:`inset(0 -${$}px 0 ${W.toFixed(2)}px)`),X(q[K],O,ee,C,K,"",!0)})}}}};var aa="bands",ia=["var(--m-bg-accent)","var(--m-bg-inverse)","var(--m-bg-surface)","var(--m-bg-sunken)"],Xt=e=>`var(--m-band-${e%6+1}, ${ia[e%ia.length]})`;function qi(e,n){return Array.from({length:e},(t,r)=>{let a=r%2===0?1:-1,s=1-.55*(r*7%e)/Math.max(1,e);return a*n*s})}function Zi(e,n,t,r){let a=n/Math.max(1,e);if(r===0)return a+1;let s=Math.tan(Math.abs(r)*2*Math.PI/180)*t*.5;return a+s+a*.2}function Xi(e,n,t,r,a){let s=Math.max(.05,.5-(t-1)*r),i=a(Z((e-n*r)/s)),o=a(Z((e-.5-n*r)/s)),u=Math.min(Z((e-n*r-s*.35)/(.5-n*r-s*.35)),1-Z((e-.5)/(s*.65)));return{lead:i,trail:o,swell:a(Z(u))}}var sa={slug:"transition/band-sweep",summary:"Bands of colour run across the frame at angles, swell to cover the cut, then run on.",duration:1,calm:{angle:6,lag:.03},params:{duration:{type:"number",default:1,min:.5,max:2,step:.05,unit:"s",label:"Length of the hand-over"},direction:{type:"choice",default:"left",options:["left","right","up","down"],label:"Which way the bands run"},bands:{type:"number",default:5,min:2,max:8,step:1,unit:"bands",label:"Bands across the frame"},width:{type:"number",default:9,min:2,max:30,step:.5,unit:"% of frame",label:"Thickness of a band as it enters"},angle:{type:"number",default:14,min:0,max:30,step:.5,unit:"deg",label:"Largest tilt of a band"},lag:{type:"number",default:.05,min:0,max:.09,step:.005,unit:"ratio",label:"How far each band trails the one before"}},apply(e,n,t,r,a){let s=Math.max(2,Math.round(l(r.bands,5))),i=Math.min(l(r.lag,.05),.45/(s-1)),o=F(r.direction,"left"),[u,m]=a.size,d=o==="left"||o==="right",c=d?u:m,p=d?m:u,f=qi(s,l(r.angle,14)),g=l(r.width,9)/100*Math.min(u,m),b=Math.max(g,Zi(s,p,c,l(r.angle,14))),h=Math.hypot(u,m)*1.25,y=a.ease("quart.inOut"),v=o==="left"||o==="up"?-1:1;Oe(e,aa,s).forEach((R,z)=>{let{lead:L,trail:j,swell:x}=Xi(t,z,s,i,y),N=g+(b-g)*x,S=(z+.5)/s*p,$=d?u/2:S,X=d?S:m/2,C=(d?0:90)+f[z];R.style.background=Xt(z),R.style.inset="auto",R.style.left=`${($-h/2).toFixed(2)}px`,R.style.top=`${(X-N/2).toFixed(2)}px`,R.style.width=`${h.toFixed(2)}px`,R.style.height=`${N.toFixed(2)}px`;let q=L*100,P=j*100;R.style.clipPath=v<0?`inset(0 ${P.toFixed(3)}% 0 ${(100-q).toFixed(3)}%)`:`inset(0 ${(100-q).toFixed(3)}% 0 ${P.toFixed(3)}%)`,R.style.transform=`rotate(${C.toFixed(3)}deg)`,R.style.visibility=L<=0||j>=1?"hidden":"visible"});let M=t>=.5;e.style.opacity=M?"0":"1",n.style.opacity=M?"1":"0";let k=y(Z((t-.5)/.5));n.style.transform=M?`scale(${(1.03-.03*k).toFixed(4)})`:"",e.style.transform=M?"":`scale(${(1+.02*y(Z(t/.5))).toFixed(4)})`},clear(e){De(e,aa),e.style.transform="",e.style.opacity=""}};var oa="strips",Yi=["band-1","band-2","band-3","band-4","band-5","band-6","accent","inverse","surface","sunken"],Ui=e=>/^band-[1-6]$/.test(e)?Xt(Number(e.slice(5))-1):Ye(e),Vi=(e,n)=>Math.min(Math.max(0,n),.5/Math.max(1,e-1));function Yt(e,n,t,r,a,s){let i=a==="up"?t-1-n:a==="centre"?Math.abs(n-(t-1)/2)*2:n,o=Math.max(.05,1-(t-1)*r);return s(Z((e-i*r)/o))}function Gi(e,n,t){let r=n-e*(n+t);return{front:r,back:r+t}}function Ki(e,n,t,r,a){if(a.mode==="cover"){if(e<.5){let m=Yt(e*2,n,t,a.lag,a.order,a.ease);return{field:[r-m*r,r],shown:null}}let o=Yt(e*2-1,n,t,a.lag,a.order,a.ease),u=r-o*r;return{field:[0,u],shown:u<r?[u,r]:null}}let{front:s,back:i}=Gi(Yt(e,n,t,a.lag,a.order,a.ease),r,a.field);return{field:[s,i],shown:i<r?[Math.max(0,i),r]:null}}var la={slug:"transition/strip-wipe",summary:"The next scene arrives row by row, each row led by a field of colour.",duration:1,params:{duration:{type:"number",default:1,min:.5,max:2,step:.05,unit:"s",label:"Length of the hand-over"},mode:{type:"choice",default:"lead",options:["lead","cover"],label:"lead: a field of colour runs ahead of the next scene; cover: colour covers the frame, then uncovers the next scene"},direction:{type:"choice",default:"left",options:["left","right"],label:"Which way the strips run: left enters from the right"},alternate:{type:"boolean",default:!1,label:"Every other row runs the other way, like strands woven across"},rows:{type:"number",default:8,min:2,max:16,step:1,unit:"rows",label:"Strips across the frame: the rows of the grid"},order:{type:"choice",default:"down",options:["down","up","centre"],label:"Which row goes first"},stagger:{type:"number",default:.04,min:0,max:.1,step:.005,unit:"ratio",label:"How far each row trails the one before, as a share of the hand-over"},lead:{type:"number",default:.35,min:.05,max:1,step:.01,unit:"\xD7 frame width",label:"Length of the colour field ahead of the next scene"},colour:{type:"choice",default:"band-1",options:Yi,label:"Colour of the field: a band of the palette (--m-band-1 \u2026) or a surface"}},apply(e,n,t,r,a){let[s,i]=a.size,o=Math.max(2,Math.round(l(r.rows,8))),u={mode:F(r.mode,"lead"),field:Math.ceil(l(r.lead,.35)*s),lag:Vi(o,l(r.stagger,.04)),order:F(r.order,"down"),ease:a.ease(F(r.mode,"lead")==="cover"?"cubic.inOut":"quart.inOut")},m=F(r.direction,"left")!=="right",d=r.alternate===!0,c=Ui(F(r.colour,"band-1")),p=Oe(e,oa,o),f=[];for(let g=0;g<o;g++){let b=Math.floor(g/o*i),h=Math.min(i,Math.ceil((g+1)/o*i)+1),y=Ki(t,g,o,s,u),v=d&&g%2===1?m:!m,E=([j,x])=>v?[s-x,s-j]:[j,x],[M,k]=E(y.field),R=p[g],z=Math.max(0,M),L=Math.min(s,k);if(R.style.inset="auto",R.style.left=`${z.toFixed(2)}px`,R.style.top=`${b}px`,R.style.width=`${Math.max(0,L-z).toFixed(2)}px`,R.style.height=`${h-b}px`,R.style.background=c,R.style.visibility=L>z?"visible":"hidden",y.shown){let[j,x]=E(y.shown);x>j&&f.push(`M${Math.max(0,j).toFixed(2)} ${b}H${Math.min(s,x).toFixed(2)}V${h}H${Math.max(0,j).toFixed(2)}Z`)}}e.style.opacity="1",n.style.opacity=f.length?"1":"0",n.style.zIndex="2",e.style.zIndex="1",n.style.clipPath=t>=1?"":f.length?`path('${f.join(" ")}')`:""},clear(e){De(e,oa),e.style.clipPath="",e.style.zIndex="",e.style.opacity=""}};var ua=e=>Object.fromEntries(e.map(n=>[n.slug,n])),Ie=ua([un,nn,on,an,mn,sn,ln,Ln,On,zn,dn,pn,cn,xn,fn,Sn,Mr,wr,yr,Sr,$r,Er,vr,Tr,Wn,Hn,Yn,In,Jn,Un,Vn,Qn,_n,er,nr,ar,Cr,Kr,qr,zr,Wr,Ir,Rr,yn,Jr,ea,na,kn,$n,ra]),Ae=ua([An,Cn,Pn,hr,mr,sr,ur,lr,br,fr,Xr,Gr,Ur,Yr,sa,la]);var Qe=["x","y","scale","rotate","opacity","blur","rotateX","rotateY","skew"],_e=["fade","rise","drop","scale","blur","slide-left","slide-right","zoom","pop","focus","mask-up","mask-down","wipe-up","wipe-down","wipe-left","wipe-right","swing","slot-up","wipe","slide","pop-check"],ma=["wipe","slide"],mt=["hero","headline","title","body","caption"],dt=["primary","secondary","muted","accent","inverse","on-accent"],ct=["center","top-left","top","top-right","left","right","bottom-left","bottom","bottom-right"],da=["%","px"],Ut=["cover","contain","width","height"],ca=["base","surface","sunken","accent","inverse"],Vt=["zero","graphite","hockney"];var ha=/^\s*(\d+(?:\.\d+)?)\s*(b|beats?|bars?)\s*$/,Ce=e=>typeof e=="string"&&ha.test(e),pa=e=>60/e.bpm;function fa(e,n){let t=ha.exec(e);if(!t)return;let r=Number(t[1]);return t[2].startsWith("bar")?r*n.bar*pa(n):r*pa(n)}var ga=(e,n)=>n*60/e.bpm;function ba(e,n,t=3){let r=[];for(let a=1;a<=n*2;a++){let s=n*60/a;s>=40&&s<=240&&Number.isInteger(Math.round(s*1e3)/1e3)&&r.push(Math.round(s*1e3)/1e3)}return r.sort((a,s)=>Math.abs(a-e)-Math.abs(s-e)).slice(0,t)}var xa=/^[a-z][a-z0-9-]*$/;function ya(e,n){let t=`Give the ${n} an id: lower-case letters, digits and dashes, starting with a letter.`;if(typeof e!="string"||e==="")return`${t} It has none.`;if(n==="layer"&&e==="scene")return'"scene" cannot be a layer id: times use "scene.end" for the scene itself.';if(/^[0-9]/.test(e))return`The ${n} id "${e}" starts with a digit. ${t}`;if(/[A-Z]/.test(e))return`The ${n} id "${e}" has capital letters. ${t}`;let r=[...new Set(e.replace(/[a-z0-9-]/g,""))].map(a=>a===" "?"a space":`"${a}"`);return`The ${n} id "${e}" contains ${r.join(", ")}. ${t}`}function wa(e,n,t){if(typeof e!="string"||e===""||e==="scene")return t;let r=e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"");return/^[0-9]/.test(r)&&(r=`${n}-${r}`),r&&r!==e?`For example "${r}".`:t}var fe=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ce=e=>typeof e=="number"&&Number.isFinite(e),Ji=["$schema","motion","title","size","fps","seed","poster","loop","narrative","style","tokens","tempo","audio","theme","scenes"],Qi=["id","length","hold","background","scheme","layout","artboard","layers","tracks","follow","camera","perspective","motionBlur","out","uses","intent"],$t=["fx/path-draw"],_i=["id","use","props","params","at","style","place","enter","exit","tracks","motionBlur","parallax","screen","taps","reflow"],es=["size","color","font","weight","align","width","css"],ts={fade:0,rise:40,drop:40,scale:.08,blur:16,"slide-left":120,"slide-right":120,zoom:.12,pop:.5,focus:24,"mask-up":0,"mask-down":0,"wipe-up":0,"wipe-down":0,"wipe-left":0,"wipe-right":0,swing:70,"slot-up":48,wipe:0,slide:120,"pop-check":.65},ns={pop:{enter:{spring:{duration:.5,bounce:.35}},exit:"back.in"},"mask-up":{enter:"expressive.out",exit:"expressive.in"},"slot-up":{enter:"cubic.out",exit:"cubic.in"},"mask-down":{enter:"expressive.out",exit:"expressive.in"},"wipe-up":{enter:"quart.inOut",exit:"quart.inOut"},"wipe-down":{enter:"quart.inOut",exit:"quart.inOut"},"wipe-left":{enter:"quart.inOut",exit:"quart.inOut"},"wipe-right":{enter:"quart.inOut",exit:"quart.inOut"},wipe:{enter:"quart.inOut",exit:"quart.inOut"},swing:{enter:{spring:{duration:.6,bounce:.2}},exit:"cubic.in"},"pop-check":{enter:"bounce.out",exit:"back.in"}};function rs(e,n){let t=Array.from({length:n.length+1},(r,a)=>a);for(let r=1;r<=e.length;r++){let a=t[0];t[0]=r;for(let s=1;s<=n.length;s++){let i=t[s];t[s]=Math.min(t[s]+1,t[s-1]+1,a+(e[r-1]===n[s-1]?0:1)),a=i}}return t[n.length]}function Fe(e,n){let t,r=1/0;for(let a of n){let s=rs(e,a);s<r&&(t=a,r=s)}return t!==void 0&&r<=Math.max(2,Math.floor(e.length/3))?t:void 0}var we=e=>e.join(", ");function Gt(e){let n=[],t=(x,N,S,$)=>n.push({level:"error",code:N,path:x,message:S,...$?{hint:$}:{}}),r=(x,N,S,$)=>n.push({level:"warning",code:N,path:x,message:S,...$?{hint:$}:{}}),a=(x,N)=>{let S=!n.some($=>$.level==="error");return{ok:S,issues:n,tokens:x,...S&&N?{timeline:N}:{}}},s=(x,N,S)=>{for(let $ of Object.keys(x)){if(N.includes($))continue;let X=Fe($,N);t(S?`${S}.${$}`:$,"unknown-key",`"${$}" is not a field here.`,X?`Did you mean "${X}"?`:`Fields: ${we(N.filter(C=>C!=="$schema"))}.`)}};if(!fe(e))return t("","not-a-film","A film is a JSON object."),a(et());let i=e;s(e,Ji,""),typeof i.motion!="string"&&t("motion","missing","State the library version the film is written for.",'Add "motion": "0.4".');let o=i.size,u=Array.isArray(o)&&o.length===2&&o.every(x=>Number.isInteger(x)&&x>0);u||t("size","bad-size","size is [width, height] in whole px.","For example [1920, 1080] or [1080, 1350].");let m=et(fe(i.tokens)?i.tokens:void 0);if(i.tokens!==void 0)if(!fe(i.tokens))t("tokens","bad-tokens","tokens is an object of overrides.");else{let x=It(et()),N=(S,$)=>{if(fe(S)&&!("spring"in S)){for(let[X,C]of Object.entries(S))N(C,$?`${$}.${X}`:X);return}if(!x.includes($)){let X=Fe($,x);t(`tokens.${$}`,"unknown-token",`There is no token "${$}".`,X?`Did you mean "${X}"?`:`Tokens: ${we(x)}.`)}};N(i.tokens,"")}m.transitions!=="standard"&&m.transitions!=="calm"&&t("tokens.transitions","bad-value",'transitions is "standard" or "calm".',"Calm swaps every transition's defaults for its quiet preset.");let d=i.fps??m.fps;(!Number.isInteger(d)||d<=0)&&t("fps","bad-fps","fps is a whole number above zero.");let c;if(i.tempo!==void 0){let x=i.tempo;if(!fe(x)||!ce(x.bpm))t("tempo","bad-tempo","tempo is { bpm, bar }: beats per minute, and beats in a bar (4 if left out).",'For example {"bpm": 120, "bar": 4}.');else{s(x,["bpm","bar"],"tempo");let N=x.bar===void 0?4:x.bar;if(x.bpm<40||x.bpm>240)t("tempo.bpm","bad-value","bpm is 40 to 240.","Medium swing is 120\u2013150; a calm film 80\u2013100.");else if(!Number.isInteger(N)||N<2||N>12)t("tempo.bar","bad-value","bar is a whole number of beats, 2 to 12.");else{c={bpm:x.bpm,bar:N};let S=Number.isInteger(d)&&d>0?ga(c,d):1;Math.abs(S-Math.round(S))>1e-6&&i.audio===void 0&&r("tempo.bpm","beat-off-frame",`At ${d} fps a beat of ${c.bpm} bpm is ${S.toFixed(2)} frames, so beats fall between frames and drift.`,`Tempos with a whole number of frames per beat near it: ${ba(c.bpm,d).join(", ")} bpm.`)}}}let p;if(i.audio!==void 0){let x=i.audio;if(!fe(x)||typeof x.src!="string"||!x.src)t("audio","bad-audio","audio is { src, from, gain, fade_in, fade_out }: a sound file relative to the film, and where in it the film starts.",'For example {"src": "music/track.mp3", "from": 51.18}.');else{s(x,["src","from","gain","fade_in","fade_out"],"audio");let N=(S,$,X,C,q)=>{let P=x[S]===void 0?$:x[S];return!ce(P)||P<X||P>C?(t(`audio.${S}`,"bad-value",`${S} is ${q}, ${X} to ${C}.`),$):P};p={src:x.src,from:N("from",0,0,36e3,"seconds into the file"),gain:N("gain",0,-30,6,"a level in dB"),fade_in:N("fade_in",0,0,10,"seconds"),fade_out:N("fade_out",0,0,10,"seconds")}}}let f=(x,N)=>{if(!c){t(N,"needs-tempo",`"${x}" is in beats, but the film has no tempo.`,'Add "tempo": {"bpm": 120} to the film, or write seconds.');return}return fa(x,c)};if(i.theme!==void 0)if(!fe(i.theme))t("theme","bad-theme","theme is { scheme, vars }.");else{s(i.theme,["scheme","accent","onAccent","ui","vars"],"theme"),i.theme.ui!==void 0&&!Vt.includes(i.theme.ui)&&t("theme.ui","bad-value",`ui is one of the bundled themes: ${Vt.join(", ")}.`,`Use "zero", Diorama's own theme, unless the brief names another.`);for(let x of["accent","onAccent"])i.theme[x]!==void 0&&typeof i.theme[x]!="string"&&t(`theme.${x}`,"bad-value",`${x} is a CSS colour.`);i.theme.scheme!==void 0&&i.theme.scheme!=="light"&&i.theme.scheme!=="dark"&&t("theme.scheme","bad-value",'scheme is "light" or "dark".');for(let x of Object.keys(i.theme.vars??{}))x.startsWith("--")||t(`theme.vars.${x}`,"bad-var","Theme variables are CSS custom properties.",`Write "--${x}".`)}if(!Array.isArray(i.scenes)||i.scenes.length===0)return t("scenes","no-scenes","A film needs at least one scene."),a(m);if(!u||!Number.isInteger(d)||d<=0)return a(m);let g=1/d,b=x=>Math.round(x*d)/d,h={tokens:m,seed:i.seed??1,size:[o[0],o[1]]},y=(x,N,S)=>{if(Ce(x))return f(x,N);let $=We(x)?tt(m,x):x;if(We(x)&&$===void 0){let X=It(m).map(q=>`$${q}`),C=Fe(x,X);t(N,"unknown-token",`There is no token "${x}".`,C?`Did you mean "${C}"?`:void 0);return}if(!ce($)||$<0){t(N,"bad-time",`${S} is a number of seconds, zero or more, a $token, or beats such as "2b" or "1bar".`);return}return $},v=(x,N)=>{let S=We(x)?tt(m,x):x;if(!tn(S)||typeof S=="string"&&!Pe.includes(S)){let $=typeof S=="string"?Fe(S,Pe):void 0;t(N,"bad-ease",'An ease is a name, a [x1, y1, x2, y2] bezier, or {"spring": {"duration", "bounce"}}.',$?`Did you mean "${$}"?`:`Names: ${we(Pe)}.`);return}return S},E=(x,N)=>{if(x===void 0)return;if(!fe(x)){t(N,"bad-tracks","tracks is an object of keyframe lists by property.");return}let S={};for(let[$,X]of Object.entries(x)){let C=`${N}.${$}`;if(!Qe.includes($)){let q=Fe($,Qe);t(C,"unknown-track",`"${$}" cannot be animated by a track.`,q?`Did you mean "${q}"?`:`Properties: ${we(Qe)}.`);continue}if(!Array.isArray(X)||X.length===0){t(C,"bad-track","A track is a list of [seconds, value] keys.");continue}S[$]=X.map((q,P)=>{let Y=Array.isArray(q)&&Ce(q[0])?f(q[0],`${C}.${P}`):Array.isArray(q)?q[0]:void 0;return!Array.isArray(q)||!ce(Y)||!ce(q[1])?(t(`${C}.${P}`,"bad-key",'A key is [time, value] or [time, value, ease]; time in seconds or beats ("2b").'),q):(q[2]!==void 0&&v(q[2],`${C}.${P}`),q.length>2?[Y,q[1],q[2]]:[Y,q[1]])})}return S},M=(x,N,S,$)=>{let X={};for(let[C,q]of Object.entries(N)){let P=q.default;X[C]=We(P)?tt(m,P):P}if(x===void 0)return X;if(!fe(x))return t(S,"bad-params","params is an object."),X;for(let[C,q]of Object.entries(x)){let P=`${S}.${C}`,Y=N[C];if(!Y){let _=Object.keys(N),ee=Fe(C,_);t(P,"unknown-param",`${$} has no param "${C}".`,ee?`Did you mean "${ee}"?`:_.length?`Params: ${we(_)}.`:`${$} has no params.`);continue}if(Ce(q)&&!(Y.type==="number"&&Y.unit==="s")){t(P,"bad-param",`${C} is not a time, so it cannot be in beats.`);continue}let K=Ce(q)?f(q,P):We(q)?tt(m,q):q;if(!(Ce(q)&&K===void 0)){if(We(q)&&K===void 0){t(P,"unknown-token",`There is no token "${q}".`);continue}if(Y.type==="number"){if(!ce(K)){t(P,"bad-param",`${C} is a number${Y.unit?` (${Y.unit})`:""}.`);continue}(Y.min!==void 0&&K<Y.min||Y.max!==void 0&&K>Y.max)&&r(P,"out-of-range",`${C} is ${K}; the library's range is ${Y.min}\u2013${Y.max}${Y.unit?` ${Y.unit}`:""}.`,"Allowed, but outside what has been seen to look right. Check the frames.")}else if(Y.type==="ease"){if(v(K,P)===void 0)continue}else if(Y.type==="boolean"){if(typeof K!="boolean"){t(P,"bad-param",`${C} is true or false.`);continue}}else if(Y.type==="choice"&&!(Y.options??[]).includes(String(K))){t(P,"bad-param",`${C} is one of: ${we(Y.options??[])}.`);continue}X[C]=K}}return X},k=new Set,R=[],z=new Map;i.scenes.forEach((x,N)=>{let S=fe(x)&&typeof x.id=="string"?x.id:String(N),$=`scenes.${S}`;if(!fe(x)){t($,"bad-scene","A scene is an object.");return}if(s(x,Qi,$),typeof x.id!="string"||!xa.test(x.id)?t(`${$}.id`,"bad-id",ya(x.id,"scene"),wa(x.id,"scene",'For example "title" or "stat-2".')):k.has(x.id)&&t(`${$}.id`,"duplicate-id",`Two scenes are called "${x.id}".`),k.add(S),x.scheme!==void 0&&x.scheme!=="light"&&x.scheme!=="dark"&&t(`${$}.scheme`,"bad-value",'scheme is "light" or "dark".'),x.layout!==void 0&&(fe(x.layout)?s(x.layout,["align","justify","gap","padding"],`${$}.layout`):t(`${$}.layout`,"bad-layout","layout is { align, justify, gap, padding }.")),x.artboard!==void 0){let w=x.artboard,T=`${$}.artboard`;if(!fe(w))t(T,"bad-artboard","artboard is { width, height } in the design's pixels, with an optional fit and align.");else{s(w,["width","height","fit","align"],T);for(let V of["width","height"])(!ce(w[V])||w[V]<1||w[V]>2e4)&&t(`${T}.${V}`,"bad-value",`${V} is the design's ${V} in its own pixels, 1 to 20000.`);w.fit!==void 0&&!Ut.includes(w.fit)&&t(`${T}.fit`,"bad-value",`fit is one of: ${we(Ut)}.`),w.align!==void 0&&!(Array.isArray(w.align)&&w.align.length===2&&w.align.every(V=>ce(V)&&V>=0&&V<=100))&&t(`${T}.align`,"bad-value","align is [x, y], each 0 to 100: where the artboard sits along each side of the stage.")}}let X=E(x.tracks,`${$}.tracks`);if(!Array.isArray(x.layers)){t(`${$}.layers`,"no-layers","A scene has a list of layers. It may be empty.");return}let C=new Map;x.layers.forEach((w,T)=>{let V=fe(w)&&typeof w.id=="string"?w.id:String(T),D=`${$}.layers.${V}`;if(!fe(w)){t(D,"bad-layer","A layer is an object.");return}if(s(w,_i,D),typeof w.id!="string"||!xa.test(w.id)||w.id==="scene"){t(`${D}.id`,"bad-id",ya(w.id,"layer"),wa(w.id,"layer",'For example "headline" or "photo-2".'));return}if(C.has(w.id)){t(`${D}.id`,"duplicate-id",`Two layers in scene "${S}" are called "${w.id}".`);return}let J=typeof w.use=="string"?Ie[w.use]:void 0;if(!J){let me=Object.keys(Ie),be=typeof w.use=="string"?Fe(w.use,me):void 0,ye=typeof w.use=="string"&&w.use in Ae;t(`${D}.use`,"unknown-primitive",`There is no code for "${String(w.use)}".`,ye?'That is a transition. Put it on the scene as "out": {"use": ...}.':be?`Did you mean "${be}"?`:`Drawable: ${we(me)}. Compose anything else from el/* layers with enter, exit and tracks.`);return}let I={},re=w.props??{};if(!fe(re))t(`${D}.props`,"bad-props","props is an object.");else{for(let me of Object.keys(re)){if(me in J.props)continue;let be=Object.keys(J.props),ye=Fe(me,be),_t=me in J.params;t(`${D}.props.${me}`,"unknown-prop",`${J.slug} has no prop "${me}".`,_t?`"${me}" is a motion value. Move it to params.`:ye?`Did you mean "${ye}"?`:`Props: ${we(be)}.`)}for(let[me,be]of Object.entries(J.props)){let ye=re[me];if(ye===void 0){be.required?t(`${D}.props.${me}`,"missing-prop",`${J.slug} needs "${me}": ${be.label}.`):I[me]=be.default;continue}if(!(be.type==="number"?ce(ye):be.type==="string[]"?Array.isArray(ye)&&ye.every(Wa=>typeof Wa=="string"):be.type==="number[]"?Array.isArray(ye)&&ye.every(ce):typeof ye=="string")){t(`${D}.props.${me}`,"bad-prop",`"${me}" is ${be.type==="string[]"?"a list of strings":be.type==="number[]"?"a list of numbers":`a ${be.type==="html"?"string":be.type}`}.`);continue}(be.type==="string[]"||be.type==="number[]")&&be.required&&ye.length===0&&r(`${D}.props.${me}`,"empty",`"${me}" is empty, so nothing is drawn.`),I[me]=ye}}let ne=M(w.params,J.params,`${D}.params`,J.slug);if(w.style!==void 0)if(!fe(w.style))t(`${D}.style`,"bad-style","style is an object.");else{s(w.style,es,`${D}.style`);let me=w.style;me.size!==void 0&&!mt.includes(me.size)&&t(`${D}.style.size`,"bad-value",`size is one of: ${we(mt)}.`),me.color!==void 0&&!dt.includes(me.color)&&t(`${D}.style.color`,"bad-value",`color is one of: ${we(dt)}.`,"For any other colour use style.css or a theme variable."),me.width!==void 0&&(!ce(me.width)||me.width<=0||me.width>100)&&t(`${D}.style.width`,"bad-value","width is a percentage of the stage, 1 to 100.")}if(w.place!==void 0){let me=w.place;!fe(me)||!ce(me.x)||!ce(me.y)?t(`${D}.place`,"bad-place",'place is { x, y } in percent of the stage (or artboard pixels with unit "px"), with an optional anchor.'):(s(me,["x","y","anchor","unit"],`${D}.place`),me.anchor!==void 0&&!ct.includes(me.anchor)&&t(`${D}.place.anchor`,"bad-value",`anchor is one of: ${we(ct)}.`),me.unit!==void 0&&!da.includes(me.unit)&&t(`${D}.place.unit`,"bad-value",`unit is "%" (of the stage) or "px" (of the scene's artboard).`))}let se=E(w.tracks,`${D}.tracks`);if(w.reflow!==void 0&&(w.reflow!=="glide"?t(`${D}.reflow`,"bad-value",'reflow is "glide": the layer takes no room until it enters, and the layers around it glide over.'):(w.place||w.screen)&&r(`${D}.reflow`,"unused",`Layer "${V}" is placed on its own, so it takes no room in the stack and nothing glides around it.`)),w.screen!==void 0&&typeof w.screen!="boolean"&&t(`${D}.screen`,"bad-value","screen is true (fixed to the screen, outside the camera) or false."),w.screen===!0&&w.parallax!==void 0&&t(`${D}.parallax`,"bad-value","A layer fixed to the screen does not travel with the camera, so it has no parallax."),w.motionBlur!==void 0&&typeof w.motionBlur!="boolean"&&!(ce(w.motionBlur)&&w.motionBlur>=0&&w.motionBlur<=1)&&t(`${D}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1."),J.check)try{for(let me of J.check(I,ne,h))t(`${D}.${me.path}`,"bad-value",me.message,me.hint)}catch{}let oe=0;try{oe=J.duration(I,ne,h)}catch{}let le;try{le=J.cues?.(I,ne,h)}catch{}let he;try{he=J.speed?.(I,ne,h)}catch{}let xe=se?{...w,tracks:se}:w;C.set(w.id,{layer:xe,path:D,duration:Number.isFinite(oe)?oe:0,params:ne,props:I,...le?{cues:le}:{},...J.cycles?{cycles:!0}:{},...he!==void 0&&Number.isFinite(he)?{speed:he}:{}})});let q=(w,T,V)=>{if(w===void 0)return;let D=typeof w=="string"?{move:w}:w;if(!fe(D)||!_e.includes(D.move)){let le=fe(D)&&typeof D.move=="string"?Fe(D.move,_e):void 0;t(T,"unknown-move",`A move is one of: ${we(_e)}.`,le?`Did you mean "${le}"?`:void 0);return}s(D,V?["move","duration","ease","amount","angle","feather","at"]:["move","duration","ease","amount","angle","feather"],T);let J=D.move.startsWith("mask-")||D.move.startsWith("wipe-"),I;D.feather!==void 0&&D.feather!==!1&&(D.feather!==!0&&!(ce(D.feather)&&D.feather>=0&&D.feather<=200)?t(`${T}.feather`,"bad-value","feather is a soft edge in px (0 to 200), or true for a tenth of the line height."):J?(D.feather===!0||D.feather>0)&&(I=D.feather):r(`${T}.feather`,"unused",`${D.move} has no edge to soften, so feather is ignored.`,"Feather mask-up, mask-down and the wipe-* moves."));let re=ma.includes(D.move);D.angle!==void 0&&(ce(D.angle)?re||r(`${T}.angle`,"unused",`${D.move} has a fixed direction, so angle is ignored.`,'Use "wipe" or "slide" to travel at an angle.'):t(`${T}.angle`,"bad-value","angle is degrees: 0 rightwards, 90 downwards, 180 leftwards, 270 upwards."));let ne=D.duration===void 0?V?m.duration.fast:m.duration.base:y(D.duration,`${T}.duration`,"duration"),se=ns[D.move],oe=D.ease===void 0?se?se[V?"exit":"enter"]:V?m.ease_exit:m.ease_enter:v(D.ease,`${T}.ease`);if(D.amount!==void 0&&!ce(D.amount)&&t(`${T}.amount`,"bad-value","amount is a number."),!(ne===void 0||oe===void 0))return{move:D.move,duration:ne,ease:oe,amount:ce(D.amount)?D.amount:ts[D.move],...re?{angle:ce(D.angle)?D.angle:0}:{},...I!==void 0?{feather:I}:{}}},P=new Map;for(let[w,T]of C){let V=q(T.layer.enter,`${T.path}.enter`,!1);V&&P.set(w,V)}let Y=w=>Math.max(C.get(w).duration,P.get(w)?.duration??0),K=/^\s*([a-z][a-z0-9-]*)\.(start|end)\s*(?:([+-])\s*(\d+(?:\.\d+)?\s*(?:b|beats?|bars?)?))?\s*$/,_=new Set,ee,A,O=(w,T,V)=>{if(ce(w)){if(w<0){t(T,"bad-time","Times are seconds from the scene start, zero or more.");return}return w}if(Ce(w))return f(w,T);let D=typeof w=="string"?K.exec(w):null;if(!D){t(T,"bad-time",'A time is seconds from the scene start, or a reference such as "headline.end + 0.2".','References: "<layer id>.start", "<layer id>.end", "scene.end", each with an optional + or - seconds or beats ("+ 1b"). With a tempo, "4b" alone is a time too.');return}let[,J,I,re,ne]=D,se=ne===void 0?0:Ce(ne)?f(ne,T):Number(ne);if(se===void 0)return;let oe=(re==="-"?-1:1)*se;if(J==="scene"){if(I==="start")return Math.max(0,oe);if(ee===void 0){t(T,"needs-length",'"scene.end" can only place a layer when the scene has a length.',`Add "length" to scene "${S}", or refer to a layer instead.`);return}return Math.max(0,ee+oe)}if(J===V){t(T,"self-reference","A layer cannot be timed against itself.");return}if(!C.has(J)){let he=[...C.keys()].filter(me=>me!==V),xe=Fe(J,he);t(T,"unknown-layer",`Scene "${S}" has no layer "${J}".`,xe?`Did you mean "${xe}"?`:`Layers here: ${we(he)||"none"}.`);return}let le=B(J);if(le!==void 0)return Math.max(0,le+(I==="end"?Y(J):0)+oe)},B=w=>{let T=C.get(w);if(T.start!==void 0)return T.start;if(_.has(w)){t(`${T.path}.at`,"time-cycle",`Layers ${[..._].join(" \u2192 ")} \u2192 ${w} are timed against each other in a circle.`,"Give one of them a number.");return}_.add(w);let V=T.layer.at===void 0?0:O(T.layer.at,`${T.path}.at`,w);return _.delete(w),V!==void 0&&(T.start=b(V)),T.start};if(x.length!==void 0){let w=Ce(x.length)?f(x.length,`${$}.length`):x.length;w===void 0||(!ce(w)||w<=0?t(`${$}.length`,"bad-time",'length is seconds above zero, or beats ("8b", "2bars").'):(ee=Math.max(g,b(w)),A=Math.max(g,w)))}for(let w of C.keys())B(w);let W=x.hold===void 0?m.hold:y(x.hold,`${$}.hold`,"hold")??m.hold;if(ee===void 0){let w=Math.max(0,...[...C.entries()].map(([T,V])=>(V.start??0)+Y(T)));ee=Math.max(g,b(w+W))}else x.hold!==void 0&&r(`${$}.hold`,"unused","hold is ignored when the scene has a length.");let H=ee,U=[],G=!!x.follow||Array.isArray(x.camera)&&x.camera.length>0||["x","y"].some(w=>(x.tracks?.[w]?.length??0)>1),Q=[];for(let[w,T]of C){if(T.start===void 0)continue;let V=T.start+Y(w);if(T.start>=H){let oe=Math.max(0,H-g);t(`${T.path}.at`,"never-seen",T.start-H<g/2?`Layer "${w}" starts at ${T.start.toFixed(3)} s, the moment scene "${S}" ends, so it is never on screen.`:`Layer "${w}" starts at ${T.start.toFixed(3)} s, after scene "${S}" ends at ${H.toFixed(3)} s.`,`Times snap to whole frames at ${d} fps, so the last frame a layer can start on is ${oe.toFixed(3)} s. Start it earlier or make the scene longer.`);continue}T.cycles&&T.cues?Q.push({path:T.path,id:w,start:T.start,cues:T.cues}):V>H+1e-6&&r(T.path,"cut-off",`Layer "${w}" finishes at ${V.toFixed(2)} s, ${(V-H).toFixed(2)} s after scene "${S}" ends.`,x.length!==void 0?`Raise the scene length to at least ${V.toFixed(2)}, or start the layer earlier.`:"Start the layer earlier.");let D=P.get(w),J=q(T.layer.exit,`${T.path}.exit`,!0),I;if(J){let oe=typeof T.layer.exit=="object"&&T.layer.exit.at!==void 0?O(T.layer.exit.at,`${T.path}.exit.at`,void 0):H-J.duration;oe!==void 0&&(I={...J,start:b(Math.max(0,oe))},I.start<T.start?t(`${T.path}.exit.at`,"exit-before-enter",`Layer "${w}" leaves at ${I.start.toFixed(2)} s, before it arrives at ${T.start.toFixed(2)} s.`):I.start<V-1e-6&&r(`${T.path}.exit`,"exit-early",`Layer "${w}" starts leaving at ${I.start.toFixed(2)} s while it is still arriving (until ${V.toFixed(2)} s).`))}let re;if(T.layer.parallax!==void 0){let oe=`${T.path}.parallax`,le=T.layer.parallax,he=ce(le)?{depth:le}:le;if(!fe(he)||!ce(he.depth)||he.depth<0||he.depth>10)t(oe,"bad-value","parallax is a depth from 0 to 10 (1 travels with the scene, above 1 is nearer), or { depth, home }.");else{s(he,["depth","home"],oe);let xe=he.home===void 0?H:O(he.home,`${oe}.home`,void 0);xe!==void 0&&(re={depth:he.depth,home:Math.min(xe,H)}),G||r(oe,"unused",`Scene "${S}"'s camera does not travel, so parallax has nothing to follow.`,"Give the scene x or y tracks, or a follow."),x.follow&&fe(x.follow)&&x.follow.layer===w&&t(oe,"bad-follow",`The camera follows "${w}", so it cannot also travel against the camera.`)}}let ne,se=T.start;if(T.layer.taps!==void 0){let oe=`${T.path}.taps`;Array.isArray(T.layer.taps)?(ne=[],T.layer.taps.forEach((le,he)=>{let xe=`${oe}.${he}`,me=fe(le)?le:{at:le};fe(le)&&s(le,["at","ring","mark"],xe);let be=fe(le)&&typeof le.mark=="string"?le.mark:void 0;be!==void 0&&T.layer.use!=="rig/footage-plane"&&t(`${xe}.mark`,"bad-value","Only a rig/footage-plane has marks to tap.");let ye=O(me.at,fe(le)?`${xe}.at`:xe,void 0);me.ring!==void 0&&me.ring!==!1&&typeof me.ring!="string"&&t(`${xe}.ring`,"bad-value","ring is the id of a layer in this scene, or false for no ring."),ye!==void 0&&((ye<se||I&&ye>I.start)&&r(xe,"tap-hidden",`Layer "${w}" is tapped at ${ye.toFixed(2)} s, when it is not on screen.`),ne.push({t:b(ye),ring:me.ring===!1?null:typeof me.ring=="string"?me.ring:w,...be?{mark:be}:{}}))}),ne.sort((le,he)=>le.t-he.t)):t(oe,"bad-value","taps is a list of times, or of { at, ring }.",'e.g. "taps": ["3.25b"]')}U.push({id:w,use:T.layer.use,start:T.start,duration:T.duration,end:V,props:T.props,params:T.params,...T.cues?{cues:T.cues}:{},...T.speed!==void 0?{speed:T.speed}:{},...D?{enter:{...D,start:T.start}}:{},...I?{exit:I}:{},...re?{parallax:re}:{},...ne?.length?{taps:ne}:{},source:T.layer})}for(let w of U){if(w.use!=="ui/cursor-click"||typeof w.props.target!="string"||!w.props.target)continue;let T=U.find(V=>V.id===w.props.target);if(!T){let V=Fe(w.props.target,U.map(D=>D.id));t(`${$}.layers.${w.id}.props.target`,"unknown-layer",`Scene "${S}" has no layer "${w.props.target}" for the cursor to click.`,V?`Did you mean "${V}"?`:void 0);continue}(T.taps??=[]).push({t:b(w.start+Ar(w.params)),ring:T.id}),T.taps.sort((V,D)=>V.t-D.t)}if(U.forEach(w=>w.taps?.forEach((T,V)=>{if(T.ring!==null&&!U.some(D=>D.id===T.ring)){let D=Fe(T.ring,U.map(J=>J.id));t(`${$}.layers.${w.id}.taps.${V}.ring`,"unknown-layer",`Scene "${S}" has no layer "${T.ring}" to draw a tap's ring around.`,D?`Did you mean "${D}"?`:void 0)}})),x.follow!==void 0){let w=`${$}.follow`,T=x.follow;if(!fe(T))t(w,"bad-follow","follow is { layer, at, lag, blend }.");else{s(T,["layer","at","lag","blend"],w);let V=typeof T.layer=="string"?U.find(D=>D.id===T.layer):void 0;if(V)$t.includes(V.use)||t(`${w}.layer`,"bad-follow",`${V.use} has no tip to follow.`,`The camera can follow: ${we($t)}.`);else{let D=U.filter(I=>$t.includes(I.use)).map(I=>I.id),J=typeof T.layer=="string"?Fe(T.layer,D):void 0;t(`${w}.layer`,"unknown-layer",`Scene "${S}" has no layer "${String(T.layer)}" to follow.`,J?`Did you mean "${J}"?`:D.length?`Lines here: ${we(D)}.`:`Add a line to follow: ${we($t)}.`)}T.at!==void 0&&!(Array.isArray(T.at)&&T.at.length===2&&T.at.every(D=>ce(D)&&D>=0&&D<=100))&&t(`${w}.at`,"bad-value","at is [x, y] in % of the stage, 0 to 100.","The middle is [50, 50].");for(let D of["lag","blend"])T[D]!==void 0&&!(ce(T[D])&&T[D]>=0)&&t(`${w}.${D}`,"bad-time",`${D} is seconds, zero or more.`)}}let ie;if(x.camera!==void 0){let w=`${$}.camera`;if(!Array.isArray(x.camera)||x.camera.length===0)t(w,"bad-camera","camera is a list of keys: { at, frame, zoom, anchor, tilt, ease }.");else{x.follow!==void 0&&t(w,"bad-camera","A scene has a framing camera or a follow, not both.","Frame the line's layer with camera keys, or follow its tip.");let T=["x","y","scale"].filter(I=>x.tracks?.[I]!==void 0);T.length&&t(`${$}.tracks`,"bad-camera",`The framing camera sets x, y and scale itself, so tracks ${T.join(", ")} would fight it.`,"Move them into camera keys: frame, offset and zoom. rotate, rotateX and rotateY tracks still apply.");let V=U.map(I=>I.id),D=(I,re,ne)=>Array.isArray(I)&&I.length===2&&I.every(se=>ce(se)&&se>=re&&se<=ne),J={t:0,frame:[50,50],point:[.5,.5],offset:[0,0],zoom:1,anchor:[50,50],tilt:[0,0],rotate:0,drift:0};ie=[],x.camera.forEach((I,re)=>{let ne=`${w}.${re}`;if(!fe(I)){t(ne,"bad-camera","A camera key is an object: { at, frame, zoom, anchor, tilt, ease }.");return}s(I,["at","frame","point","offset","zoom","anchor","tilt","rotate","ease","drift"],ne);let se=y(I.at,`${ne}.at`,"at");if(se===void 0)return;ie.length&&se<ie[ie.length-1].t&&t(`${ne}.at`,"bad-order",`Camera keys run in time order; this one (${se.toFixed(2)} s) comes before the key above it.`),se>H+1e-6&&r(`${ne}.at`,"after-end",`This key (${se.toFixed(2)} s) is after scene "${S}" ends (${H.toFixed(2)} s).`,"A key past the cut is fine for a camera that keeps moving through the cut; otherwise move it earlier.");let oe={...J,t:se,drift:0};if(I.ease!==void 0){let le=v(I.ease,`${ne}.ease`);le!==void 0&&(oe.ease=le)}else delete oe.ease;if(I.frame!==void 0)if(typeof I.frame=="string"){let[le,he]=I.frame.split("#");if(V.includes(le))he!==void 0&&U.find(xe=>xe.id===le)?.use!=="rig/footage-plane"?t(`${ne}.frame`,"bad-camera",`"${I.frame}" frames a mark, and only a rig/footage-plane has marks.`,`Frame the layer itself: "${le}".`):he===""&&t(`${ne}.frame`,"bad-camera",'Name the mark after the #: "plane#send", as given to motion record --marks.');else{let xe=Fe(le,V);t(`${ne}.frame`,"unknown-layer",`Scene "${S}" has no layer "${le}" to frame.`,xe?`Did you mean "${xe}"?`:`Layers: ${we(V)}.`)}oe.frame=I.frame}else D(I.frame,0,100)?oe.frame=[I.frame[0],I.frame[1]]:t(`${ne}.frame`,"bad-value","frame is a layer id, or [x, y] in % of the stage.");I.point!==void 0&&(D(I.point,0,1)?oe.point=[I.point[0],I.point[1]]:t(`${ne}.point`,"bad-value","point is [x, y] as shares of the layer box, 0 to 1.","The middle is [0.5, 0.5].")),I.offset!==void 0&&(Array.isArray(I.offset)&&I.offset.length===2&&I.offset.every(ce)?oe.offset=[I.offset[0],I.offset[1]]:t(`${ne}.offset`,"bad-value","offset is [dx, dy] in px.")),I.anchor!==void 0&&(D(I.anchor,0,100)?oe.anchor=[I.anchor[0],I.anchor[1]]:t(`${ne}.anchor`,"bad-value","anchor is [x, y] in % of the stage, 0 to 100.")),I.tilt!==void 0&&(D(I.tilt,-80,80)?oe.tilt=[I.tilt[0],I.tilt[1]]:t(`${ne}.tilt`,"bad-value","tilt is [about x, about y] in degrees, -80 to 80.")),I.zoom!==void 0&&(ce(I.zoom)&&I.zoom>0?oe.zoom=I.zoom:t(`${ne}.zoom`,"bad-value","zoom is a number above 0; 1 is the stage as laid out.")),I.rotate!==void 0&&(ce(I.rotate)?oe.rotate=I.rotate:t(`${ne}.rotate`,"bad-value","rotate is degrees.")),I.drift!==void 0&&(ce(I.drift)?re!==x.camera.length-1?r(`${ne}.drift`,"unused","drift runs from the last key to the end of the scene; on an earlier key it does nothing."):oe.drift=I.drift:t(`${ne}.drift`,"bad-value","drift is zoom per second, such as 0.02.")),ie.push(oe),J=oe}),x.perspective!==void 0&&!(ce(x.perspective)&&x.perspective>=100)&&t(`${$}.perspective`,"bad-value","perspective is px from the viewer to the stage, 100 or more.",`The default is ${Math.round(o[0]*1.2)} (1.2 \xD7 the stage width).`),ie.length||(ie=void 0)}}x.motionBlur!==void 0&&typeof x.motionBlur!="boolean"&&!(ce(x.motionBlur)&&x.motionBlur>=0&&x.motionBlur<=1)&&t(`${$}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1.");let ue,pe=0;if(x.out!==void 0){let w=`${$}.out`,T=fe(x.out)&&typeof x.out.use=="string"?Ae[x.out.use]:void 0;if(T){s(x.out,["use","duration","params"],w);let V=m.transitions==="calm"&&T.calm?Object.fromEntries(Object.entries(T.params).map(([I,re])=>[I,I in T.calm?{...re,default:T.calm[I]}:re])):T.params,D=M(x.out.params,V,`${w}.params`,T.slug);if(x.out.duration!==void 0){let I=y(x.out.duration,`${w}.duration`,"duration");I!==void 0&&(D.duration=I)}let J=b(ce(D.duration)?D.duration:0);N===i.scenes.length-1?r(w,"unused",'The last scene has nothing to hand over to, so "out" is ignored.'):J>=H?t(`${w}.duration`,"too-long",`The hand-over (${J.toFixed(2)} s) is not shorter than scene "${S}" (${H.toFixed(2)} s).`):(ue={use:T.slug,duration:J,params:D},pe=ce(D.duration)?D.duration:0)}else{let V=Object.keys(Ae),D=fe(x.out)?String(x.out.use):"",J=Fe(D,V);t(`${w}.use`,"unknown-transition",`There is no code for transition "${D}".`,J?`Did you mean "${J}"?`:`Transitions: ${we(V)}.`)}}let de=H-(ue?ue.duration/2:0);for(let w of Q){let T=w.cues.find(V=>w.start+V.at<de-1e-6&&w.start+V.at+V.length>de+1e-6);T&&r(w.path,"cut-mid-change",`Scene "${S}" is last seen at ${de.toFixed(2)} s, in the middle of a change of layer "${w.id}" (${(w.start+T.at).toFixed(2)}\u2013${(w.start+T.at+T.length).toFixed(2)} s).`,"End the scene on a rest: after the change, or before it begins.")}z.set(S,{length:A??H,out:pe}),R.push({id:S,start:0,length:H,end:H,layers:U,...ue?{out:ue}:{},...ie?{camera:ie}:{},source:X?{...x,tracks:X}:x})});let L=0;R.forEach((x,N)=>{let S=R[N-1];S?.out&&(S.out.duration>=x.length&&t(`scenes.${S.id}.out.duration`,"too-long",`The hand-over (${S.out.duration.toFixed(2)} s) is not shorter than the next scene "${x.id}" (${x.length.toFixed(2)} s).`),L-=z.get(S.id)?.out??S.out.duration),x.start=b(L),L+=z.get(x.id)?.length??x.length,x.end=b(L),x.length=x.end-x.start}),as(R,g,t);let j=b(L);return i.poster!==void 0&&(!ce(i.poster)||i.poster<0||i.poster>j)&&t("poster","bad-time",`poster is a time inside the film, 0 to ${j.toFixed(2)} s.`),a(m,{duration:j,fps:d,frames:Math.round(j*d),size:[o[0],o[1]],scenes:R,...c?{tempo:c}:{},...i.loop?{loop:!0}:{},...p?{audio:p}:{}})}function as(e,n,t){for(let r of e)for(let a of r.layers){let s=a.use==="el/video"&&typeof a.props.continues=="string"?a.props.continues:"";if(!s)continue;let i=`scenes.${r.id}.layers.${a.id}.props.continues`,[o,u]=s.split("."),m=e.find(y=>y.id===o),d=m?.layers.find(y=>y.id===u);if(!m||!d){t(i,"unknown-layer",`There is no layer "${s}" to continue.`,'Name a video layer as "scene.layer".');continue}if(d.use!=="el/video"){t(i,"bad-value",`"${s}" is ${d.use}, not el/video.`);continue}if(d===a){t(i,"self-reference","A video layer cannot continue itself.");continue}d.props.src!==a.props.src&&t(i,"bad-value",`"${s}" plays ${String(d.props.src)}, a different file.`,"A continuation plays the same footage.");let c=Math.min(m.length,d.exit?d.exit.start+d.exit.duration:m.length)-n,p=typeof d.params.rate=="number"?d.params.rate:1,f=Math.max(0,c-d.start),g=typeof d.props.from=="number"?d.props.from:0,b=typeof d.props.to=="number"?d.props.to:0,h=g+f*p;d.params.loop===!0&&b>g?h=g+f*p%(b-g):b>g&&(h=Math.min(b,h)),a.props={...a.props,from:Number((h+n*p).toFixed(6))},typeof a.props.to=="number"&&a.props.to!==0&&a.props.to<=a.props.from&&t(`scenes.${r.id}.layers.${a.id}.props.to`,"bad-value",`to (${a.props.to} s) comes before the continuation starts (${a.props.from.toFixed(3)} s).`,"Leave it at 0, or move it later.")}}function is(e){let n=r=>r.toFixed(2).padStart(6),t=[`${e.duration.toFixed(2)} s \xB7 ${e.frames} frames at ${e.fps} fps \xB7 ${e.size[0]}\xD7${e.size[1]}`,""];for(let r of e.scenes){t.push(`${n(r.start)} \u2013 ${n(r.end)} scene ${r.id}${r.out?` \u2192 ${r.out.use} ${r.out.duration.toFixed(2)} s`:""}`);for(let a of r.layers){let s=[a.use,a.enter?`enter ${a.enter.move}`:"",a.exit?`exit ${a.exit.move} @${(r.start+a.exit.start).toFixed(2)}`:""].filter(Boolean);t.push(` ${n(r.start+a.start)} \u2013 ${n(r.start+a.end)} ${a.id.padEnd(14)} ${s.join(" \xB7 ")}`)}}return t.join(`
|
|
4
|
+
`)}var St=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ss=new Set(["scenes","layers"]);function os(e,n,t){let r=n.split("."),a=e;for(let s=0;s<r.length;s++){let i=r[s],o=s===r.length-1;if(Array.isArray(a)){let u=a.find(m=>St(m)&&m.id===i);if(!u||o)return!1;a=u;continue}if(!St(a))return!1;if(o)return t===null?delete a[i]:a[i]=t,!0;if(a[i]===void 0){if(ss.has(i))return!1;a[i]={}}(i==="enter"||i==="exit")&&typeof a[i]=="string"&&(a[i]={move:a[i]}),a=a[i]}return!1}function At(e,n){let t=structuredClone(e),r=[],a=[];for(let[s,i]of Object.entries(n?.set??{}))(os(t,s,structuredClone(i))?a:r).push(s);return{film:t,orphans:r,applied:a}}function ls(e,n){let t=e;for(let r of n.split("."))if(Array.isArray(t))t=t.find(a=>St(a)&&a.id===r);else if(St(t))t=t[r];else return;return t}function us(e,n){let{film:t,orphans:r}=At(e,n),a=Object.fromEntries(Object.entries(n?.set??{}).filter(([s])=>r.includes(s)));return{film:t,tune:{set:a,notes:n?.notes??[]},orphans:r}}var va="0.4.1";function ms(){return{motion:va,tokens:ft,eases:Pe,moves:_e,tracks:Qe,sizes:mt,colors:dt,surfaces:ca,anchors:ct,primitives:Object.values(Ie).map(({slug:e,summary:n,props:t,params:r})=>({slug:e,summary:n,props:t,params:r})),transitions:Object.values(Ae).map(({slug:e,summary:n,params:t,calm:r})=>({slug:e,summary:n,params:t,...r?{calm:r}:{}}))}}var Be=(e,n,t)=>e+(n-e)*t;function ka(e,n,t){if(!e.length)throw new Error("frameAt needs at least one key");let r=e[0],a=r,s=0;if(n>r.t){let c=1;for(;c<e.length&&e[c].t<n;)c++;if(c>=e.length)r=a=e[e.length-1],s=0;else{r=e[c-1],a=e[c];let p=a.t-r.t;s=p<=0?1:a.ease((n-r.t)/p)}}let i=r===a&&n>r.t?1+r.drift*(n-r.t):1,o=Math.exp(Be(Math.log(r.zoom),Math.log(a.zoom),s))*Math.max(.01,i),u=[Be(r.target[0],a.target[0],s),Be(r.target[1],a.target[1],s)],m=[Be(r.anchor[0],a.anchor[0],s),Be(r.anchor[1],a.anchor[1],s)],d=Be(r.rotate,a.rotate,s);return{...ds(u,m,o,d,t),scale:o,rotate:d,rotateX:Be(r.tilt[0],a.tilt[0],s),rotateY:Be(r.tilt[1],a.tilt[1],s),pivot:[m[0]-t[0]/2,m[1]-t[1]/2]}}function ds(e,n,t,r,a){let s=[a[0]/2,a[1]/2],i=r*Math.PI/180,o=e[0]-s[0],u=e[1]-s[1];return{x:n[0]-s[0]-t*(Math.cos(i)*o-Math.sin(i)*u),y:n[1]-s[1]-t*(Math.sin(i)*o+Math.cos(i)*u)}}var Kt=.08,Ma=.35,Jt=.07,Fa=.5,cs=12,ps=.7,hs=je(.34,1.36,.64,1),fs=je(.22,1,.36,1);function Ta(e,n){let t=1;for(let r of e){let a=n-r;a<-Kt||a>Ma||(t*=a<0?1-Jt*((a+Kt)/Kt):1-Jt+Jt*hs(a/Ma))}return t}function Ea(e,n){let t;for(let a of e)n>=a&&n-a<=Fa&&(t===void 0||a>t)&&(t=a);if(t===void 0)return;let r=(n-t)/Fa;return{grow:cs*fs(r),opacity:ps*(1-r)}}var $a=`
|
|
5
5
|
.m-stage {
|
|
6
6
|
position: relative; overflow: hidden; transform-origin: 0 0; box-sizing: border-box; isolation: isolate;
|
|
7
7
|
color-scheme: light;
|