@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,11 +1,11 @@
|
|
|
1
1
|
var Ce={"16:9":{size:[1920,1080],label:"Landscape"},"1:1":{size:[1080,1080],label:"Square"},"4:5":{size:[1080,1350],label:"Portrait"},"9:16":{size:[1080,1920],label:"Vertical"}},Ae={calm:{label:"Calm",summary:"Slow, soft arrivals and long holds. Lets the message breathe.",tokens:{duration:{base:.8,slow:1.2},stagger:{base:.12},ease_enter:"sine.out",hold:1,transitions:"calm"}},crisp:{label:"Crisp",summary:"Fast arrivals that settle precisely. The library default.",tokens:{duration:{base:.5,slow:.8},stagger:{base:.08},ease_enter:"expo.out",hold:.6}},lively:{label:"Lively",summary:"Quick, springy, a little overshoot. For social and launches.",tokens:{duration:{base:.4,slow:.6},stagger:{base:.05},ease_enter:{spring:{duration:.4,bounce:.3}},hold:.4}}},cn=e=>{let n=e.split("/").pop()??e;return n.charAt(0).toUpperCase()+n.slice(1).replace(/-/g," ")},bt=60,It=e=>`${Number((Math.round(e*bt)/bt).toFixed(2))} s`,gi=e=>(e??"").split(`
|
|
2
2
|
`).map(n=>n.trim()).filter(Boolean);function bi(e,n){let t=0;return e.beats.map((r,a,s)=>{let i=a===s.length-1?n:t+Math.round(n*r.share/100*10)/10,o={name:r.name,start:t,end:i,content:r.content,moves:r.primitives};return t=i,o})}function Wt(e,{library:n}){let t=[];n.narratives.find(a=>a.slug===e.type)||t.push(`Unknown video type "${e.type}". Known: ${n.narratives.map(a=>a.slug).join(", ")}`),n.styles.some(a=>a.slug===e.style)||t.push(`Unknown look "${e.style}". Known: ${n.styles.map(a=>a.slug).join(", ")}`),e.feel in Ae||t.push(`Unknown feel "${e.feel}". Known: ${Object.keys(Ae).join(", ")}`),e.formats.length||t.push("Pick at least one format.");for(let a of e.formats)a in Ce||t.push(`Unknown format "${a}". Known: ${Object.keys(Ce).join(", ")}`);return e.subject.trim()||t.push("Say what the video is about."),e.message.trim()||t.push("Say the one thing a viewer should remember."),e.duration>0||t.push("The length must be a number of seconds."),t}function pn(e,n){let t=Wt(e,n);if(t.length)throw new Error(t.join(`
|
|
3
3
|
`));let{catalog:r,library:a}=n,s=a.narratives.find($=>$.slug===e.type),i=a.styles.find($=>$.slug===e.style),o=Ae[e.feel],u=new Map([...r.primitives,...r.transitions].map($=>[$.slug,$])),d=new Map(a.primitives.map($=>[$.slug,$])),m=[...e.formats].sort(($,C)=>Object.keys(Ce).indexOf($)-Object.keys(Ce).indexOf(C)),[c,p]=Ce[m[0]].size,g=bi(s,e.duration),f=[...new Set([...g.flatMap($=>$.moves),...i.uses,...e.moves??[]])].filter($=>!i.avoids.includes($)),b=f.filter($=>u.has($)).sort(),h=f.filter($=>!u.has($)).sort(),y=$=>{let C=u.get($),A=Object.entries(C.params).map(([B,X])=>`${B} ${JSON.stringify(X.default)}${X.min!==void 0?` (${X.min}\u2013${X.max}${X.unit?` ${X.unit}`:""})`:""}`),V="props"in C?Object.keys(C.props):[];return`- \`${$}\`: ${C.summary}${V.length?` Props: ${V.join(", ")}.`:""}${A.length?` Params: ${A.join(", ")}.`:""}`},v={beat:i.beat??r.tokens.beat,...i.transitions?{transitions:i.transitions}:{},...o.tokens},R={...e.scheme?{scheme:e.scheme}:{},...e.accent?{accent:e.accent}:{}},T=m.length>1?`Make the ${m[0]} film first. Then make one film per other format (${m.slice(1).map($=>`${$} at ${Ce[$].size.join("\xD7")}`).join(", ")}) with the same scenes, re-laid for the frame, not cropped.`:"",F=e.duration<s.duration.min||e.duration>s.duration.max,D=[],S=(...$)=>D.push(...$);S(`# Motion brief: ${e.subject.trim()}`,""),S(e.target==="agent"?"You are directing a short motion video with the bydiorama motion library, in its repository. You write the film as JSON; the runtime draws, checks and renders it. A person will tune it afterwards in the studio and leave notes for you.":"You are directing a short motion video for the bydiorama motion library. You cannot run it: write the film as JSON exactly as described below, and the person will paste it into the library to preview, tune and render it.",""),S("## The video",""),S(`- Type: ${cn(s.slug)}. ${s.summary}`),S(`- Look: ${cn(i.slug)}. ${i.summary}${i.character?` ${i.character}`:""}`),S(`- Feel: ${o.label}. ${o.summary}`),S(`- Length: ${It(e.duration)} at ${bt} fps.${F?` This type usually runs ${s.duration.min}\u2013${s.duration.max} s, so compress or stretch the beats to fit.`:""}`),S(`- Formats: ${m.map($=>`${$} (${Ce[$].size.join("\xD7")})`).join(", ")}.${T?` ${T}`:""}`),Object.keys(R).length&&S(`- Brand: ${[e.scheme?`${e.scheme} scheme`:"",e.accent?`accent ${e.accent}`:""].filter(Boolean).join(", ")}. Use the accent once per scene at most.`),S(""),S("## What it says",""),S(`- About: ${e.subject.trim()}`,`- Remember: ${e.message.trim()}`),e.intent.trim()&&S(`- Afterwards the viewer should: ${e.intent.trim()}`),e.audience?.trim()&&S(`- Audience: ${e.audience.trim()}`);let j=gi(e.content);j.length&&S("- Use this content, word for word where it is quoted:",...j.map($=>` - ${$}`)),e.avoid?.trim()&&S(`- Avoid: ${e.avoid.trim()}`),S("- Every word on screen must be short enough to read twice in the time it stays.",""),S("## Story","","| # | Beat | Time | What happens | Suggested moves |","|---|---|---|---|---|"),g.forEach(($,C)=>S(`| ${C+1} | ${$.name} | ${It($.start)}\u2013${It($.end)} | ${$.content} | ${$.moves.map(A=>`\`${A}\``).join(", ")||"\u2013"} |`)),S("","One scene per beat is a good start; merge beats that are shorter than 1.5 s. Scenes hand over with a transition (`out`), and the overlap counts toward both.",""),S("## Moves","","Drawable now (use these slugs in `use`):",""),S(...b.map(y));let Z=[...u.keys()].filter($=>$.startsWith("el/")).sort();S(`- Plain elements for anything else: ${Z.map($=>`\`${$}\``).join(", ")}.`),h.length&&(S("","In the library but not drawable yet. Get the effect from the moves above, or say which one you would need:",""),S(...h.map($=>`- \`${$}\`: ${d.get($)?.summary??"no entry yet"}`))),i.avoids.length&&S("",`Do not use: ${i.avoids.map($=>`\`${$}\``).join(", ")}.`),S(""),S("## Timing","",'Put these in the film\'s `tokens` and refer to them (`"$duration.base"`) instead of writing numbers:',"","```json",JSON.stringify(v,null,2),"```",""),S("## The film","");let x={motion:r.motion,title:e.subject.trim(),size:[c,p],fps:bt,narrative:s.slug,style:i.slug,...Object.keys(R).length?{theme:R}:{},tokens:v,scenes:g.slice(0,2).map(($,C)=>({id:$.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||`scene-${C+1}`,intent:$.content,layers:[{id:"title",use:b.find(A=>A.startsWith("type/"))??"el/text",props:{text:C===0?e.message.trim():"\u2026"},style:{size:C===0?"headline":"title"}}],...C===0?{out:{use:b.find(A=>A.startsWith("transition/"))??"transition/blur-dissolve"}}:{}}))};return S("Start from this shape and complete every beat:","","```json",JSON.stringify(x,null,2),"```",""),S('Rules: ids are lowercase with dashes. `props` hold content, `params` hold motion. A layer starts at `at` (seconds, or relative such as `"title.end + 0.2"`). Moves are `enter`/`exit`: `fade`, `rise`, `drop`, `scale`, `blur`, `slide-left`, `slide-right`. Text sizes: `hero`, `headline`, `title`, `body`, `caption`.'),S(""),S("## How to deliver",""),e.target==="agent"?S("1. Read `catalog.json` (every prop, param, ease and token) and `library.json` (styles and narratives). Use the motion-film skill if it is installed.","2. Write `films/<name>.film.json`. Run `node bin/motion.mjs validate films/<name>.film.json` and fix every error; the hints name the fix.","3. Run `node bin/motion.mjs stills films/<name>.film.json` and look at the contact sheet. Fix text that collides, leaves the frame or cannot be read.","4. Run `node bin/motion.mjs check films/<name>.film.json`. It must say the frames repeat exactly.","5. Tell the person to open the studio: `node bin/motion.mjs preview films/<name>.film.json`. Never edit the `.tune.json` file; read its notes with `node bin/motion.mjs notes` and answer them in the film."):S("1. Reply with the complete film as one JSON code block, and nothing else in the block.","2. Under it, list any beat you could not draw with the moves above and what you would need.","3. The person saves it as `films/<name>.film.json` and runs `node bin/motion.mjs validate` on it. If they paste errors back, fix exactly those and return the whole film again."),S("","## Done when","","- Every beat above is on screen, in order, inside the length.","- The message is readable for at least 1.5 s.","- Only drawable moves are used, with params inside their ranges.","- Nothing leaves the frame by accident, and the last frame can hold as a poster.",""),D.join(`
|
|
4
|
-
`)}var Ue=(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,P=(e,n="")=>typeof e=="string"?e:e==null?n:String(e),te=e=>Array.isArray(e)?e.map(n=>String(n)):[],be=e=>Array.isArray(e)?e.map(n=>l(n)):[];var xi={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)"},hn={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=P(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=xi[r]??r,{seek(){}}}};var G=(e,n=0,t=1)=>Math.min(t,Math.max(n,e)),ke=(e,n,t)=>e+(n-e)*t;function rt(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,d=1-o-u,m=p=>((i*p+s)*p+a)*p,c=p=>((d*p+u)*p+o)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let g=p;for(let f=0;f<8;f++){let b=(3*i*g+2*s)*g+a;if(Math.abs(b)<1e-6)break;g-=(m(g)-p)/b}if(g<0||g>1||Math.abs(m(g)-p)>1e-4){let f=0,b=1;for(let h=0;h<24;h++)g=(f+b)/2,m(g)<p?f=g:b=g}return c(g)}}function yi({duration:e,bounce:n=0}){let t=2*Math.PI/(Math.max(.05,e)*1.2),r=G(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 Nt={"ui.default":[.2,0,0,1],"ui.in":[.4,0,1,1],"ui.out":[0,0,.2,1],"ui.spring":[.22,1,.36,1]},Ht={"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]},Fo={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],...Ht,...Nt},jt={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},at=[...Object.keys(jt),...Object.keys(Ht),...Object.keys(Nt)],fn=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 Ne(e,n={}){if(e===void 0)return jt["expo.out"];if(typeof e=="string"){let t=n[e]??Nt[e]??Ht[e];if(t)return rt(...t);let r=jt[e];if(!r)throw new Error(`Unknown ease "${e}". Known: ${at.join(", ")}`);return a=>r(G(a))}return Array.isArray(e)?rt(...e):yi(e.spring)}function se(e,n,t,r){return t<=0?e>=n?1:0:r(G((e-n)/t))}function Se(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}}var wi=(e,n)=>e.replace(/%(?:0(\d+))?d/,(t,r)=>String(n).padStart(r?Number(r):0,"0"));function vi(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)*G(t,0,r)}var gn=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)}),bn={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=gn(n);return t.delay+(Math.abs(t.last-t.first)+1)/t.fps/t.rate},build(e,n,t){let r=e.ownerDocument,a=gn(t),s=P(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 m=o;m<=u;m++){let c=r.createElement("img");c.src=wi(s,m),c.alt=m===a.first?P(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 d=-1;return{seek(m){let c=vi(m,a)-o;c!==d&&(d>=0&&(i[d].style.visibility="hidden"),i[c].style.visibility="inherit",d=c)}}}};var xn={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=P(n.html),{seek(){}}}};var yn={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=P(n.src),s.alt=P(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 d=r.createElement("div"),m=[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(", ");d.style.cssText=`position:absolute;inset:0;border-radius:${a};box-shadow:${m};pointer-events:none`,e.appendChild(d)}return{seek(){}}}};var wn={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=P(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 vn={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=P(n.text),{seek(){}}}};function ki(e){let n=be(e);return n.length===4&&n[2]>0&&n[3]>0?[n[0],n[1],n[2],n[3]]:[0,0,100,100]}function it(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 kn={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=be(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=P(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]=ki(n.crop),d=l(t.width),m=l(t.height),c=l(t.radius),p=a.createElement("div");p.style.cssText=`position:relative;overflow:hidden;width:${d}px;border-radius:${c}px;${m>0?`height:${m}px`:"aspect-ratio:16 / 9"}`,e.style.borderRadius=`${c}px`;let g=a.createElement("div");g.style.cssText=`position:absolute;left:${-s/o*100}%;top:${-i/u*100}%;width:${100/o*100}%;height:${100/u*100}%`,p.appendChild(g),e.appendChild(p);let f="object-fit:fill;display:block;width:100%;height:100%",b=(Z,x)=>{if(!(Z>0&&x>0))return;if(m<=0){p.style.aspectRatio=`${(Z*o).toFixed(3)} / ${(x*u).toFixed(3)}`;return}let $=Z*o/(x*u)/(d/m);g.style.transformOrigin=`${s+o/2}% ${i+u/2}%`,g.style.transform=`scale(${Math.max(1,$).toFixed(5)}, ${Math.max(1,1/$).toFixed(5)})`},h=r.frames;if(h){let Z=a.createElement("img");Z.decoding="sync",Z.alt="",Z.style.cssText=f,Z.src=Ue(h,0),g.appendChild(Z),b(h.width,h.height);let x=0,$=0,C=Promise.resolve(),A=(V,B)=>Z.decode().catch(()=>{if(!(V!==$||Z.complete&&Z.naturalWidth>0))return new Promise((X,W)=>{Z.addEventListener("load",()=>X(),{once:!0}),Z.addEventListener("error",()=>V===$?W(new Error(`Video frame did not load: ${B}`)):X(),{once:!0})})});return{seek(V){let B=Math.round((it(V,n,t)-h.start)*h.rate+1e-6),X=Math.min(h.count-1,Math.max(0,B));if(X===x)return;x=X;let W=Ue(h,X);Z.src=W,C=A(++$,W)},pending:()=>C}}let y=a.createElement("video");y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=P(n.src),y.style.cssText=f,g.appendChild(y),y.addEventListener("loadedmetadata",()=>b(y.videoWidth,y.videoHeight));let v=()=>a.documentElement.classList.contains("render"),R=l(t.rate,1),T=Promise.resolve(),F=-1,D=0,S,j=Z=>{Math.abs(y.currentTime-Z)<.5/r.fps||(T=new Promise(x=>{let $=()=>{y.removeEventListener("seeked",$),x()};y.addEventListener("seeked",$),y.currentTime=Z}))};return{seek(Z){let x=it(Z,n,t);if(v()){j(x);return}let $=performance.now(),C=Z-F,A=($-D)/1e3;F=Z,D=$,C>0&&C<.25&&Math.abs(C-A)<.1?(Math.abs(y.currentTime-x)>.2&&(y.currentTime=x),y.playbackRate=R,y.paused&&y.play().catch(()=>{}),clearTimeout(S),S=setTimeout(()=>y.pause(),120)):(y.pause(),j(x))},pending:()=>T}}};var Mn={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(d){let m=d>=u?s:i+(s-i)*se(d,0,u,a);e.textContent=`${P(n.prefix)}${m.toFixed(o)}${P(n.suffix)}`}}}};var Fn={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),d=Se(r.seed*101+7),m=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 g=te(n.items).map((f,b,h)=>{let y=(b+d()*.6)/h.length*Math.PI*2,v=.3+d()*.14,R=a/2+Math.cos(y)*a*v,T=s/2+Math.sin(y)*s*(v+.04),F=b%o,D=o===1?1:1-F/o,S=document.createElement("span");return S.textContent=f,S.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)${F===0&&o>1?`;filter:blur(${.06*i}px)`:""}`,e.appendChild(S),{n:S,x:R,y:T,depth:D,delay:b*p}});return{seek(f){for(let b of g){let h=(f-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(m(Math.min(1,Math.max(0,(f-b.delay)/c)))*(.35+b.depth*.5))}}}}};var $n={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 d=document.createElement("span");return d.textContent=u,d.style.cssText="padding:0.45em 0.9em;border-radius:999px;background:var(--m-bg-surface);white-space:nowrap;will-change:transform,opacity",e.appendChild(d),d});return{seek(u){o.forEach((d,m)=>{let c=se(u,m*i,s,a);d.style.opacity=String(c),d.style.transform=`scale(${.9+.1*c})`})}}}};var Tn=["inverse","plain","accent","tint"],En={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,d=l(t.tile)*s,m=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 g=Array.from({length:i},(f,b)=>{let h=document.createElement("div"),y=o.length?o[b%o.length]:"",v=Tn[b%Tn.length],R=[...y].length>3,T=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:${-d/2}px;top:${-d/2}px;width:${d}px;height:${d}px;border-radius:${d*.12}px;display:grid;place-items:center;overflow:hidden;font:${R?`500 ${d*.14}px var(--m-font-mono)`:`600 ${d*.4}px var(--m-font-display)`};letter-spacing:${R?"0":"-0.03em"};${T}`,p.appendChild(h),h});return e.appendChild(p),{seek(f){let b=f/c*360;g.forEach((h,y)=>{let v=y*360/i+b,R=(Math.cos(v*Math.PI/180)+1)/2;h.style.transform=`rotateY(${v}deg) translateZ(${u}px)`,h.style.opacity=String(m+(1-m)*R),h.style.filter=R<.999?`saturate(${.35+.65*R})`:""})}}}};var Sn=[1,1.24,.6,1.1,.9,1.3],Cn=[.1,.5,.92,.3,.7,.2],An={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=P(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,g)=>{let f=a.filter((F,D)=>D%s===g),b=f.length?f:a,h=document.createElement("div");h.style.cssText="display:flex;width:max-content;will-change:transform";let y=F=>b.forEach(D=>{let S=document.createElement("span");if(S.textContent=D,S.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)",D===o){let j=document.createElement("span");j.textContent=D,j.setAttribute("aria-hidden","true"),j.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)",S.appendChild(j),S.style.transform="scale(calc(1 + 0.08 * var(--k, 0)))",S.style.zIndex="1"}else S.style.opacity="calc(1 - var(--dim, 0) * var(--k, 0))";F.appendChild(S)}),v=document.createElement("div");v.style.cssText="display:flex;flex:none",y(v),h.appendChild(v),e.appendChild(h);let R=Math.max(1,v.getBoundingClientRect().width/Mi(e)),T=Math.ceil(r.size[0]/R)+1;for(let F=0;F<T;F++)h.appendChild(v.cloneNode(!0));return{track:h,width:R,dir:g%2?-1:1,rate:Sn[g%Sn.length],off:Cn[g%Cn.length]}}),d=r.ease(r.tokens.ease_move),m=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?se(p,m,c,d):0));for(let g of u){let f=(p*i*g.rate+g.off*g.width)%g.width;g.track.style.transform=`translateX(${-(g.dir>0?f:g.width-f)}px)`}}}}};function Mi(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}var Ve=["start","end","center","edges","random"];function Pn(e,n="start",t=1,r){if(e<=0)return[];if(n==="random"){let c=Se(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 g=r&&e>1?Math.hypot(r[0]-1,r[1]-1)/(e-1):1,f=new Array(e);return p.forEach((b,h)=>{f[b]=h*g}),f}let[a,s]=r??[e,1],i=c=>[c%a,Math.floor(c/a)],o=(a-1)/2,u=(s-1)/2,d=c=>{let[p,g]=i(c);return n==="end"?Math.hypot(a-1-p,s-1-g):n==="center"?Math.hypot(p-o,g-u):n==="edges"?Math.hypot(o,u)-Math.hypot(p-o,g-u):Math.hypot(p,g)},m=Array.from({length:e},(c,p)=>d(p));return r?m:m.map(c=>Math.floor(c+1e-9))}function $e(e,n,t="start",r=1,a){let s=Pn(e,t,r,a),i=Math.max(0,...s);return s.map(o=>i>0?o*n:0)}function Oe(e,n="start",t=1,r){return Math.max(0,...Pn(e,n,t,r))}function zn(e,n,t=.5){let a=e.map(([u,d])=>Math.hypot(u-n[0],d-n[1])).map((u,d)=>[u,d]).sort((u,d)=>u[0]-d[0]||u[1]-d[1]),s=new Array(e.length),i=-1,o=-1/0;for(let[u,d]of a)u-o>t&&(i++,o=u),s[d]=i;return s}function Fi(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 d=0;for(let p=1;p<a;p++)i[p]<i[d]-.5&&(d=p);let m=s/(u>0?u:1),c={x:d*(s+r),y:i[d],w:s,h:m};return i[d]=i[d]+m+r,c}),height:Math.max(0,Math.max(...i)-r)}}function qt(e,n,t){let r=zn(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 Rn={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=be(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=be(n.ratios),o=l(t.width)/100*r.size[0],u=l(t.gap),d=l(t.columns),m=l(t.stagger),c=r.tokens.duration.slow,p=l(t.drift_speed),g=r.ease(r.tokens.ease_enter),f=a.createElement("div");f.style.cssText=`position:relative;width:${o}px`;let b=s.map(T=>{let F=a.createElement("img");return F.src=T,F.alt="",F.decoding="sync",F.style.cssText=`position:absolute;display:block;object-fit:cover;border-radius:var(--m-card-radius, ${Math.round(u*.75)}px)`,f.appendChild(F),F});e.appendChild(f);let h="",y=[],v=[],R=()=>{let T=b.map((j,Z)=>i[Z]??(j.naturalWidth>0?j.naturalWidth/j.naturalHeight:1)),F=T.map(j=>j.toFixed(4)).join();if(F===h)return;h=F;let{cards:D,height:S}=Fi(T,d,o,u);f.style.height=`${S}px`,D.forEach((j,Z)=>Object.assign(b[Z].style,{left:`${j.x}px`,top:`${j.y}px`,width:`${j.w}px`,height:`${j.h}px`})),v=D.map(j=>j.y),y=qt(D,[l(t.focus_x)/100*o,l(t.focus_y)/100*S],m)};return R(),{seek(T){R(),b.forEach((F,D)=>{let S=se(T,y[D],c,g);F.style.opacity=S.toFixed(4),F.style.top=`${(v[D]+(1-S)*24).toFixed(2)}px`}),f.style.transform=p>0?`translateY(${(-p*Math.max(0,T)).toFixed(2)}px)`:""}}}};var st=["slide-up","slide-left","flip","stack","fade"],Ln=["slide-up","flip","slide-left","stack","fade"],$i=e=>e.split(/[/|\n]/).map(n=>n.trim().split(/\s+/).filter(Boolean)).filter(n=>n.length>0);function ot(e){let n=$i(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((d,m)=>{let c=i.get(d);if(!c){let f={name:d,col:m,row:u,cols:1,rows:1};i.set(d,f),s.push(f);return}let p=Math.max(c.col+c.cols,m+1),g=Math.max(c.row+c.rows,u+1);c.col=Math.min(c.col,m),c.cols=p-c.col,c.rows=g-c.row}));for(let o of s){let u=0;if(n.forEach((d,m)=>d.forEach((c,p)=>{c===o.name?u++:p>=o.col&&p<o.col+o.cols&&m>=o.row&&m<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 xt(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 Ti(e,n,t,[r,a]){let{tiles:s,cols:i,rows:o}=ot(e),u=n/100*r,d=Math.max(a*.1,a-(r-u)),m=(u-t*(i-1))/Math.max(1,i),c=(d-t*(o-1))/Math.max(1,o);return s.map(p=>(p.cols*m+(p.cols-1)*t)*(p.rows*c+(p.rows-1)*t)/(r*a))}function On(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 Ei(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 Si=/^(data:image\/|[^<\s]+\.(png|jpe?g|webp|gif|avif|svg)(\?\S*)?$)/i;function yt(e,n){if(Si.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 Ci(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 Ai=.06,Dn={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",...st],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}=ot(P(e.areas)),a=xt(te(e.items).length,r.length,be(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}=ot(P(e.areas)),a=xt(te(e.items).length,r.length,be(e.counts)),s=l(n.hold),i=l(n.swap_time),o=s+i,u=l(n.stagger),d=u>0?Math.max(0,r.length-1)*u+t.tokens.duration.slow:0,m=Math.max(0,...a.map(f=>f.length));if(m<2)return[];let c=d+m*o,p=a.map((f,b)=>f.length>1?b:-1).filter(f=>f>=0),g=Ti(P(e.areas),l(n.width),l(n.gap),t.size);return On(p.length,d,s,l(n.offset)).flatMap((f,b)=>{let h=[],y=+g[p[b]].toFixed(4);for(let v=f;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}=ot(P(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=be(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(m=>m.name).join(", ")}).`,hint:"Give one count per tile, in reading order."}):s.length&&s.reduce((m,c)=>m+c,0)!==a&&n.push({path:"props.counts",message:`counts add up to ${s.reduce((m,c)=>m+c,0)}, but there are ${a} items.`,hint:"Make the counts add up to the number of items."}),s.some(m=>!(m>=1)||m!==Math.round(m))&&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=xt(a,t.length,s).map(m=>m.length).filter(m=>m>1),u=Math.max(0,...o),d=o.filter(m=>u%m!==0);return d.length&&n.push({path:"props.counts",message:`Tiles cycle ${[...new Set(o)].join(", ")} items: at the end, the tiles with ${[...new Set(d)].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((m,c)=>{st.includes(m)||n.push({path:`props.swaps[${c}]`,message:`"${m}" is not a swap move.`,hint:`Use one of ${st.join(", ")}.`})}),n},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,{tiles:o,cols:u,rows:d}=ot(P(n.areas)),m=te(n.items),c=xt(m.length,o.length,be(n.counts)),p=te(n.swaps),g=l(t.width)/100*s,f=(s-g)/2,b=Math.max(i*.1,i-2*f),h=l(t.gap),y=(g-h*(u-1))/Math.max(1,u),v=(b-h*(d-1))/Math.max(1,d),R=l(t.hold),T=Math.max(.01,l(t.swap_time)),F=l(t.stagger),D=R+T,S=s/1080,j=r.ease(r.tokens.ease_enter),Z=r.ease(r.tokens.ease_move),x=r.tokens.duration.slow,$=o.map(H=>({x:H.col*(y+h),y:H.row*(v+h),w:H.cols*y+(H.cols-1)*h,h:H.rows*v+(H.rows-1)*h})),C=F>0?qt($,[g/2,b/2],F):$.map(()=>0),A=F>0?Math.max(0,o.length-1)*F+x:0,V=c.map((H,Y)=>H.length>1?Y:-1).filter(H=>H>=0),B=On(V.length,A,R,l(t.offset)),X=`var(--m-card-radius, ${Math.max(4,Math.round(h*.75))}px)`,W=a.createElement("div");W.style.cssText=`position:relative;width:${g}px;height:${b}px`;let M=o.map((H,Y)=>{let K=$[Y],k=a.createElement("div");k.style.cssText=`position:absolute;left:${K.x}px;top:${K.y}px;width:${K.w}px;height:${K.h}px;overflow:hidden;border-radius:${X};background:var(--m-bg-sunken);perspective:${(2.5*Math.max(K.w,K.h)).toFixed(0)}px;isolation:isolate`;let E=V.indexOf(Y),L=st.includes(p[Y]??"")?p[Y]:P(t.swap)==="mixed"||!st.includes(P(t.swap))?Ln[Math.max(0,E)%Ln.length]:P(t.swap),z=c[Y].map(I=>{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*S).toFixed(2)}px`;let Q=yt(U,m[I]??"");return k.appendChild(U),{face:U,img:Q}});return W.appendChild(k),{tile:k,faces:z,move:L,start:E>=0?B[E]:1/0,top:K.y}});return e.appendChild(W),{seek(H){M.forEach((Y,K)=>{let k=F>0?se(H,C[K],x,j):1;Y.tile.style.opacity=k<1?k.toFixed(4):"",Y.tile.style.top=`${(Y.top+(1-k)*24*S).toFixed(2)}px`;let E=Ei(H,Y.start,Y.faces.length,R,T);Y.faces.forEach(({face:L,img:z},I)=>{let U=I===E.from||I===E.to;if(L.style.visibility=U?"inherit":"hidden",L.style.transform="",L.style.opacity="",L.style.zIndex="",z){let Q=I===E.to?E.age:E.age+D;z.style.transform=U?`scale(${(1+Ai*(1-G(Q/(D+T)))).toFixed(4)})`:""}}),E.from!==E.to&&Ci(Y.move,Y.faces[E.from].face,Y.faces[E.to].face,Z(E.k))})}}}};var Pi=["4:5","1:1","9:16","3:4","16:9"],Wn=e=>{let[n,t]=P(e,"4:5").split(":").map(Number);return n>0&&t>0?n/t:.8},jn=.14;function Bn(e,n,t){let r=Wn(e.ratio),a=P(e.chrome)!=="none"?2*jn:0,s=Math.min(l(e.width)/100*n,.92*t/(1/r+a));return{w:s,h:s/r}}var zi=.05;function Ri(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(G((e-t-u*i)/r))}function In(e,n,t,r){let a=e-n;return!r||t<3?a:((a+t/2)%t+t)%t-t/2}var Nn={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:Pi,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:d,h:m}=Bn(n,o,u),c=+Math.min(1,1.5*d*m/(o*u)).toFixed(4);return Array.from({length:i},(p,g)=>({at:a+g*(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,d=P(t.chrome)!=="none",m=Wn(t.ratio),c=t.loop===!0,{w:p,h:g}=Bn(t,s,i),f=d?jn*p:0,b=.035*p,h=.035*p,y=p/1e3,v=l(t.hold),R=Math.max(.01,l(t.turn)),T=v+R,F=l(t.angle),D=r.ease(r.tokens.ease_move),S=a.createElement("div");S.style.cssText=`position:relative;width:${p}px;height:${g+2*f}px;text-align:left`;let j=a.createElement("div");j.style.cssText=`position:absolute;left:0;top:${f}px;width:${p}px;height:${g}px;perspective:${(2.5*p).toFixed(0)}px;transform-style:preserve-3d`;let Z=o.map(A=>{let V=a.createElement("div");V.style.cssText=`position:absolute;inset:0;overflow:hidden;background:var(--m-bg-surface);border-radius:${d?"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 B=a.createElement("div");return B.style.cssText="position:absolute;inset:0;display:grid;place-items:center;transform-origin:50% 50%",yt(B,A),V.appendChild(B),j.appendChild(V),{card:V,inner:B}});S.appendChild(j);let x=[];if(d){let A="var(--m-font-body)",V=(Q,ee)=>`position:absolute;left:0;top:${Q}px;width:${p}px;height:${f}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:${ee};font:600 ${34*y}px/1 ${A}`,B=a.createElement("div");B.style.cssText=V(0,`${h}px ${h}px 0 0`)+";box-shadow:inset 0 -1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let X=a.createElement("div"),W=64*y;X.style.cssText=`flex:none;width:${W}px;height:${W}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 ${A}`;let M=P(n.avatar);M?yt(X,M):X.textContent=(P(n.handle,"y").trim()[0]??"y").toUpperCase();let H=a.createElement("span");H.textContent=P(n.handle,"yourbrand"),H.style.cssText="flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis";let Y=a.createElement("span");Y.textContent="\u2022\u2022\u2022",Y.style.cssText=`letter-spacing:${2*y}px;font-size:${22*y}px;color:var(--m-text-muted)`,B.append(X,H,Y);let K=a.createElement("div");K.style.cssText=V(f+g,`0 0 ${h}px ${h}px`)+";box-shadow:inset 0 1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let k=(Q,ee="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="${Q}" fill="${ee}" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/>`,ie},E=k("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");E.style.color="var(--m-accent)";let L=k("M20 11.5a8 8 0 0 1-11.6 7.1L4 20l1.4-4.2A8 8 0 1 1 20 11.5Z"),z=k("M21 3 10 13.5M21 3l-6.5 18-4.5-7.5L3 9.5 21 3Z"),I=a.createElement("div");I.style.cssText=`flex:1;display:flex;justify-content:center;gap:${10*y}px`;for(let Q=0;Q<Math.min(u,12);Q++){let ee=a.createElement("i");ee.style.cssText=`display:block;width:${11*y}px;height:${11*y}px;border-radius:50%;background:var(--m-text-primary)`,I.appendChild(ee),x.push(ee)}let U=k("M6 3.5h12v17l-6-4.5-6 4.5v-17Z");K.append(E,L,z,I,U),S.append(B,K)}e.appendChild(S);let $=A=>A===0?-R:v+(A-1)*T,C=u*T;return{seek(A){let V=Ri(A,u,v,R,c,D);Z.forEach(({card:B,inner:X},W)=>{let M=In(W,V,u,c),H=G(M,-1,1),Y=Math.max(0,Math.abs(M)-1);B.style.transformOrigin=M>=0?"0% 50%":"100% 50%",B.style.transform=`translateX(${(H*(p+b)).toFixed(2)}px) translateZ(${(-(Math.abs(H)*.06+Y*1.5)*p).toFixed(2)}px) rotateY(${(F*H).toFixed(3)}deg)`,B.style.opacity=Y>0?G((.6-Y)/.6).toFixed(4):"",B.style.visibility=Y<1?"inherit":"hidden",B.style.zIndex=String(10-Math.round(Math.abs(M)*2));let K=c?((A-$(W))%C+C)%C:A-$(W);X.style.transform=`scale(${(1+zi*(1-G(K/(T+R)))).toFixed(4)})`}),x.forEach((B,X)=>{let W=Math.max(0,1-Math.abs(In(X,V,u,c)));B.style.opacity=ke(.22,1,W).toFixed(3)})}}}};var Hn={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${P(n.edge)==="bottom"?";transform:scaleY(-1)":""}`,e.appendChild(u),{seek(d){let c=`radial-gradient(ellipse 62% 52% at 50% -6%, #000 0%, transparent ${se(d,0,i,a)*o*100}%)`;u.style.maskImage=c,u.style.setProperty("-webkit-mask-image",c)}}}};var qn={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 Zn={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(G(t/i)),u=s(G((t-(1-i))/i)),d=l(r.blur);e.style.opacity=String(1-o),e.style.filter=o>0?`blur(${o*d}px)`:"",n.style.opacity=String(u),n.style.filter=u<1?`blur(${(1-u)*d}px)`:""},clear(e){e.style.opacity="",e.style.filter=""}};var Xn={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,d=.5/i,m=[];for(let c=0;c<i;c++){let p=s(G((t-c*d)/(1-(i-1)*d)))*o,g=c*u/i,f=(c+1)*u/i+(c<i-1?1:0);m.push(`M0 ${g}H${p}V${f}H0Z`)}n.style.clipPath=`path('${m.join("")}')`},clear(e){e.style.clipPath=""}};var Un="ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&/+",Li=1/20,Vn={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=[...P(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)/Li);e.textContent=a.map((d,m)=>{if(m<o||d===" ")return d;let c=Se(r.seed*7919+u*131+m);return Un[Math.floor(c()*Un.length)]??d}).join("")}}}};var Yn={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)=>[...P(e.text)].length/Math.max(1,l(n.chars_per_s)),build(e,n,t){let r=[...P(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 d=Math.min(r.length,Math.floor(u*a+1e-6));s.textContent=r.slice(0,d).join(""),i.textContent=r.slice(d).join("");let m=u-r.length/a;o.style.opacity=m>0&&m%1>=.5?"0":"1"}}}};var Kn=e=>P(e.text).split(/\s+/).filter(Boolean),Gn={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,Kn(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(m=>m.toLowerCase()));e.style.cssText+=";display:flex;flex-wrap:wrap;justify-content:center;gap:0 0.26em";let i=Kn(n).map(m=>{let c=document.createElement("span");return c.textContent=m,c.style.cssText="display:inline-block;will-change:transform,opacity",s.has(m.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),d=l(t.rise);return{seek(m){i.forEach((c,p)=>{let g=se(m,p*o,u,a);c.style.opacity=String(Math.min(1,g*1.6)),c.style.transform=`translateY(${(1-g)*d}px)`})}}}};var wt=(e,n)=>{let t=Math.max(2,Math.round(l(e.cols)));return[t,Math.max(2,Math.round(t*n[1]/n[0]))]},Jn={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:Ve,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)=>Oe(wt(n,t.size)[0]*wt(n,t.size)[1],P(n.from),t.seed,wt(n,t.size))*l(n.stagger)+.6,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,[o,u]=wt(t,r.size),d=s/o,m=i/u,c=o*u,p=P(n.cell,"dot"),g=l(t.size)*Math.min(d,m),f=$e(c,l(t.stagger),P(t.from),r.seed,[o,u]),b=Math.max(...f,.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},(F,D)=>{let S=a.createElement("div"),j=D%o*d+d/2,Z=Math.floor(D/o)*m+m/2,x=p==="square"?`border-radius:${g*.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 S.style.cssText=`position:absolute;left:${j-g/2}px;top:${Z-g/2}px;width:${g}px;height:${g}px;${x}`,h.appendChild(S),S}),v=r.ease({spring:{duration:.45,bounce:.25}}),R=l(t.pulse),T=Math.max(1.2,b*1.6);return{seek(F){y.forEach((D,S)=>{let j=se(F,f[S],.6,v),Z=F>f[S]+.6?Math.sin((F-f[S])/T*Math.PI*2)*.5*R:0,x=Math.max(0,j*(1+Z*.6));D.style.transform=`scale(${x.toFixed(4)})`,D.style.opacity=Math.min(1,Math.max(0,(F-f[S])/.2)*(1-R*.3+Z*.6)).toFixed(3)})}}}};function Qn(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 _n={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=Qn(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=Qn(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)),d=r.ease("expressive.out");e.style.cssText+=";display:inline-flex;align-items:baseline;font-variant-numeric:tabular-nums;white-space:pre";let m=f=>{if(!f)return;let b=a.createElement("span");b.textContent=f,e.appendChild(b)};m(P(n.prefix));let p=s.filter(f=>/\d/.test(f)).length,g=[];for(let f of s){if(!/\d/.test(f)){m(f);continue}p--;let h=Number(f)+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 R=0;R<=h;R++){let T=a.createElement("span");T.textContent=String(R%10),T.style.cssText="display:block;height:1.1em;text-align:center",v.appendChild(T)}y.appendChild(v),e.appendChild(y),g.push({strip:v,travel:h,delay:p*o})}return m(P(n.suffix)),{seek(f){for(let b of g){let h=se(f,b.delay,i,d),y=b.travel*h;b.strip.style.transform=`translateY(${(-y*1.1).toFixed(4)}em)`;let v=b.travel*(se(f+1/60,b.delay,i,d)-h)*60,R=G(Math.abs(v)*.012,0,.06);b.strip.style.filter=R>.004?`blur(${R.toFixed(3)}em)`:""}}}}};var er="http://www.w3.org/2000/svg",tr={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=P(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=P(n.fill,"none"),i=s==="accent"?"var(--m-bg-accent)":s==="primary"?"var(--m-text-primary)":s,o=P(n.viewbox,"0 0 100 100").split(/[\s,]+/).map(Number),u=o[2]||100,d=o[3]||100,m=l(t.width)/100*r.size[0],c=a.createElementNS(er,"svg");c.setAttribute("viewBox",P(n.viewbox,"0 0 100 100")),c.setAttribute("width",String(m)),c.setAttribute("height",String(m*d/u)),c.style.cssText="display:block;overflow:visible";let p=l(t.stroke)*(u/m),g=te(n.paths).map(S=>{let j=a.createElementNS(er,"path");return j.setAttribute("d",S),j.setAttribute("pathLength","1"),j.setAttribute("stroke-dasharray","1 1"),j.setAttribute("stroke","currentColor"),j.setAttribute("stroke-width",String(p)),j.setAttribute("stroke-linecap","round"),j.setAttribute("stroke-linejoin","round"),j.setAttribute("fill",s==="none"?"none":i),c.appendChild(j),j});e.appendChild(c);let f=$e(g.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"),R=m/u,T=256,F=g.map(S=>{let j=0;try{j=S.getTotalLength()}catch{return[]}return Array.from({length:T+1},(Z,x)=>{let $=S.getPointAtLength(j*x/T);return[($.x-(o[0]??0))*R,($.y-(o[1]??0))*R]})}),D=(S,j)=>{let Z=F[S];if(!Z?.length)return;let x=Math.min(1,Math.max(0,j))*T,$=Math.floor(x),C=Math.min(T,$+1),A=x-$,[V,B]=Z[$],[X,W]=Z[C];return[V+(X-V)*A,B+(W-B)*A]};return{tip(S){let j=0;for(let Z=0;Z<g.length;Z++)S>=f[Z]&&(j=Z);return D(j,se(S,f[j],b,y))},seek(S){g.forEach((j,Z)=>{let x=se(S,f[Z],b,y);if(j.setAttribute("stroke-dashoffset",(1-x).toFixed(4)),j.style.visibility=S<f[Z]?"hidden":"inherit",s!=="none"){let $=se(S,f[Z]+b*.8,h,v);j.setAttribute("fill-opacity",$.toFixed(3)),j.setAttribute("stroke-opacity",(1-$).toFixed(3))}})}}}};var rr=["circle","square","squircle","triangle","diamond","hexagon","star","pill","plus","blob"],nr=e=>e,vt=(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 Oi(e,n){let t=e.map((u,d)=>[u,e[(d+1)%e.length]]),r=t.map(([u,d])=>Math.hypot(d[0]-u[0],d[1]-u[1])),a=r.reduce((u,d)=>u+d,0),s=[],i=0,o=0;for(let u=0;u<n;u++){let d=u/n*a;for(;i<t.length-1&&o+r[i]<d;)o+=r[i],i++;let[m,c]=t[i],p=r[i]>0?(d-o)/r[i]:0;s.push([m[0]+(c[0]-m[0])*p,m[1]+(c[1]-m[1])*p])}return s}function Di(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 Bi(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 nr([[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 vt(3,1.12,0).map(([r,a])=>[r,a+.14]);case"diamond":return vt(4,1.1);case"hexagon":return vt(6,1.04);case"star":return vt(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,d=2;for(let m=0;m<30;m++){let c=(u+d)/2,p=a*c,g=s*c,f=Math.max(0,Math.abs(p)-o);Math.hypot(f,g)>i?d=c:u=c}return u*1.9});case"plus":return nr([[-.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=Se(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 kt(e,n=120,t=1){return Di(Oi(Bi(e,t),n))}var ar=(e,n,t)=>e.map(([r,a],s)=>[r+(n[s][0]-r)*t,a+(n[s][1]-a)*t]),Mt=(e,n,t,r)=>`M${e.map(([a,s])=>`${(n+a*r).toFixed(2)},${(t+s*r).toFixed(2)}`).join("L")}Z`;var ir="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)"},sr={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: ${rr.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=>kt(v,160,r.seed)),o=r.size[0],u=l(t.size)/100*o,d=u/2,m=l(t.hold),c=l(t.morph),p=l(t.turn),g=P(n.fill,"accent"),f=a.createElementNS(ir,"svg");f.setAttribute("width",String(u*1.3)),f.setAttribute("height",String(u*1.3)),f.setAttribute("viewBox",`${-u*.65} ${-u*.65} ${u*1.3} ${u*1.3}`),f.style.cssText="display:block;overflow:visible";let b=a.createElementNS(ir,"path");g==="outline"?(b.setAttribute("fill","none"),b.setAttribute("stroke","currentColor"),b.setAttribute("stroke-width",String(Math.max(2,u*.02)))):b.setAttribute("fill",Ii[g]??g),f.appendChild(b),e.appendChild(f);let h=r.ease({spring:{duration:.6,bounce:.3}}),y=r.ease("quint.inOut");return{seek(v){let R=se(v,0,.6,h),T=Math.max(0,v-.6),F=m+c,D=Math.min(s.length-1,Math.floor(T/F)),S=0;D<s.length-1?S=se(T-D*F,m,c,y):D=s.length-1;let j=Math.min(s.length-1,D+1),Z=ar(i[D],i[j],S);b.setAttribute("d",Mt(Z,0,0,d*Math.max(0,R))),b.setAttribute("transform",`rotate(${((D+S)*p).toFixed(3)})`)}}}};var Wi=(e,n)=>e.toFixed(n),or={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,be(e.values).length-1)*l(n.stagger)+l(n.grow),build(e,n,t,r){let a=e.ownerDocument,s=be(n.values),i=te(n.labels),o=P(n.highlight),u=Math.max(0,Math.round(l(n.decimals))),d=P(n.suffix),[m,c]=r.size,p=l(t.width)/100*m,g=l(t.height)/100*c,f=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:${g}px;font-variant-numeric:tabular-nums`;let v=a.createElement("div");v.style.cssText=`position:absolute;background:var(--m-border);${f?"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 R=s.map((j,Z)=>{let x=(f?g:p)/h,$=x*(1-y),C=Z*x+x*y/2,A=o!==""&&i[Z]===o,V=a.createElement("div"),B=o===""||A?"var(--m-bg-accent)":"color-mix(in srgb, var(--m-text-primary) 18%, var(--m-bg-base))";V.style.cssText=f?`position:absolute;left:2px;top:${C}px;height:${$}px;width:${Math.abs(j)/b*(p-160)}px;transform-origin:0 50%;border-radius:0 ${$*.12}px ${$*.12}px 0;background:${B}`:`position:absolute;bottom:2px;left:${C}px;width:${$}px;height:${Math.abs(j)/b*(g-70)}px;transform-origin:50% 100%;border-radius:${$*.1}px ${$*.1}px 0 0;background:${B}`;let X=a.createElement("div");X.style.cssText=f?`position:absolute;top:${C+$/2}px;transform:translateY(-50%);font-size:0.62em;font-weight:600;white-space:nowrap`:`position:absolute;left:${C+$/2}px;width:${x}px;margin-left:${-x/2}px;text-align:center;font-size:0.62em;font-weight:600;white-space:nowrap`,A&&(X.style.color="var(--m-accent)");let W=a.createElement("div");W.textContent=i[Z]??"",W.style.cssText=f?`position:absolute;right:calc(100% + 0.8em);top:${C+$/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:${C}px;width:${$}px;text-align:center;font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.append(V,X,W);let M=parseFloat(f?V.style.width:V.style.height);return{bar:V,value:X,label:W,v:j,full:M}}),T=$e(h,l(t.stagger)),F=l(t.grow),D=r.ease("quint.out"),S=r.ease("quart.inOut");return{seek(j){let Z=se(j,0,.5,S);v.style.transform=f?`scaleY(${Z})`:`scaleX(${Z})`,R.forEach((x,$)=>{let C=se(j,.4+T[$],F,D);x.bar.style.transform=f?`scaleX(${C})`:`scaleY(${C})`;let A=j>=.4+T[$]+F?x.v:x.v*C;x.value.textContent=`${Wi(A,u)}${d}`;let V=Math.min(1,Math.max(0,(j-.4-T[$])/.25));x.value.style.opacity=V.toFixed(3),f?x.value.style.left=`${2+x.full*C+12}px`:x.value.style.bottom=`${2+x.full*C+10}px`,x.label.style.opacity=Math.min(1,Math.max(0,(j-T[$]*.5)/.4)).toFixed(3)})}}}};var Ye="http://www.w3.org/2000/svg",lr={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=be(n.values),i=te(n.labels),[o,u]=r.size,d=l(t.width)/100*o,m=l(t.height)/100*u,c=Math.min(...s,0),p=Math.max(...s,1e-9),g=m*.08,f=s.map((B,X)=>[s.length>1?X/(s.length-1)*d:d/2,g+(1-(B-c)/(p-c||1))*(m-g*2)]);e.style.cssText+=`;position:relative;width:${d}px;height:${m}px`;let b=a.createElementNS(Ye,"svg");b.setAttribute("width",String(d)),b.setAttribute("height",String(m)),b.style.cssText="position:absolute;inset:0;overflow:visible";let h=Math.round(l(t.grid)),y=Array.from({length:h},(B,X)=>{let W=a.createElementNS(Ye,"line"),M=m*(X+1)/(h+1);return W.setAttribute("x1","0"),W.setAttribute("x2",String(d)),W.setAttribute("y1",String(M)),W.setAttribute("y2",String(M)),W.setAttribute("stroke","var(--m-border)"),W.setAttribute("stroke-width","1.5"),W.setAttribute("stroke-dasharray","4 8"),b.appendChild(W),W}),v=f.map(([B,X],W)=>`${W?"L":"M"}${B.toFixed(2)},${X.toFixed(2)}`).join(""),R=a.createElementNS(Ye,"path");R.setAttribute("d",`${v}L${d},${m}L0,${m}Z`),R.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 16%, transparent)");let T=a.createElementNS(Ye,"path");T.setAttribute("d",v),T.setAttribute("fill","none"),T.setAttribute("stroke","var(--m-bg-accent)"),T.setAttribute("stroke-width",String(Math.max(3,o*.0028))),T.setAttribute("stroke-linejoin","round"),T.setAttribute("stroke-linecap","round");let F=a.createElementNS(Ye,"circle");F.setAttribute("r",String(o*.0055)),F.setAttribute("fill","var(--m-bg-accent)");let D=a.createElementNS(Ye,"circle");D.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 25%, transparent)"),t.area!==!1&&b.appendChild(R),b.append(T,D,F),e.appendChild(b);let S=a.createElement("div"),j=f[f.length-1]??[0,0];S.textContent=`${(s[s.length-1]??0).toFixed(Math.max(0,Math.round(l(n.decimals))))}${P(n.suffix)}`,S.style.cssText=`position:absolute;left:${j[0]}px;top:${j[1]}px;transform:translate(-50%, -150%);font-weight:650;color:var(--m-accent);white-space:nowrap;font-variant-numeric:tabular-nums`,e.appendChild(S);let Z=i.map((B,X)=>{let W=a.createElement("div"),M=i.length===2&&s.length>2?X===0?0:d:f[X]?.[0]??0;return W.textContent=B,W.style.cssText=`position:absolute;top:calc(100% + 0.6em);left:${M}px;transform:translateX(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.appendChild(W),{l:W,x:M}}),x=f.map(B=>B[0]),$=B=>{if(f.length<2)return f[0]??[0,0];let X=1;for(;X<f.length-1&&x[X]<B;)X++;let W=f[X-1],M=f[X],H=M[0]===W[0]?1:Math.min(1,Math.max(0,(B-W[0])/(M[0]-W[0])));return[W[0]+(M[0]-W[0])*H,W[1]+(M[1]-W[1])*H]},C=l(t.draw),A=r.ease("sine.inOut"),V=r.ease("expressive.out");return{seek(B){y.forEach((L,z)=>L.setAttribute("opacity",se(B,z*.05,.4,V).toFixed(3)));let X=se(B,.4,C,A),W=X*d;T.style.clipPath=X>=1?"":`inset(-20px ${(d-W).toFixed(2)}px -20px -20px)`;let[M,H]=$(W),Y=B>=.4;F.setAttribute("cx",M.toFixed(2)),F.setAttribute("cy",H.toFixed(2)),F.setAttribute("opacity",Y?"1":"0");let K=se(B,.4+C,.6,V);D.setAttribute("cx",M.toFixed(2)),D.setAttribute("cy",H.toFixed(2)),D.setAttribute("r",(o*.0055*(1+2.6*K)).toFixed(2)),D.setAttribute("opacity",(K>0?1-K:0).toFixed(3));let k=se(B,.4+C*.6,.6+C*.4,V);R.setAttribute("opacity",k.toFixed(3)),R.style.clipPath=`inset(0 ${(d-W).toFixed(2)}px 0 0)`;let E=se(B,.4+C-.1,.5,V);S.style.opacity=E.toFixed(3),S.style.transform=`translate(-50%, ${(-150+(1-E)*40).toFixed(2)}%)`;for(let{l:L,x:z}of Z)L.style.opacity=Math.min(1,Math.max(0,(W-z+d*.08)/(d*.08))).toFixed(3)}}}};var ur="http://www.w3.org/2000/svg",dr=(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}},mr={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)=>dr(n,!!P(e.name),!!P(e.tagline)).end,build(e,n,t,r){let a=e.ownerDocument,s=P(n.name),i=P(n.tagline),o=P(t.mode),u=dr(t,!!s,!!i);e.style.cssText+=";display:flex;flex-direction:column;align-items:center";let d=a.createElement("div");d.style.cssText=`display:flex;align-items:center;gap:${l(t.gap)}em;white-space:nowrap`;let m=l(t.mark_size),c=a.createElementNS(ur,"svg"),p=P(n.mark_path);c.setAttribute("viewBox",p?P(n.mark_viewbox,"0 0 100 100"):"-1 -1 2 2"),c.style.cssText=`display:block;height:${m}em;width:${m}em;overflow:visible;position:relative;z-index:1;flex:none`;let g=a.createElementNS(ur,"path");g.setAttribute("d",p||Mt(kt(P(n.mark_shape,"squircle"),160,r.seed),0,0,1)),g.setAttribute("fill","var(--m-bg-accent)"),g.setAttribute("pathLength","1"),g.setAttribute("stroke-dasharray","1 1"),g.setAttribute("stroke","var(--m-bg-accent)"),g.setAttribute("stroke-width",p?"2":"0.05"),g.setAttribute("vector-effect","non-scaling-stroke"),c.appendChild(g),d.appendChild(c);let f,b;s&&(b=a.createElement("span"),b.style.cssText="display:block;overflow:hidden;padding:0.12em 0.04em;margin:-0.12em -0.04em",f=a.createElement("span"),f.textContent=s,f.style.cssText="display:block",b.appendChild(f),d.appendChild(b)),e.appendChild(d);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=f?(d.offsetWidth-c.getBoundingClientRect().width/ji(e))/2:0,v=r.ease({spring:{duration:.55,bounce:.32}}),R=r.ease("quint.inOut"),T=r.ease("expressive.out");return{seek(F){let D=se(F,0,u.arrive,o==="pop"?v:T);if(o==="pop")c.style.transform=`scale(${Math.max(0,D).toFixed(4)}) rotate(${((1-D)*-30).toFixed(3)}deg)`,g.setAttribute("stroke-dashoffset","0"),g.setAttribute("fill-opacity","1");else if(o==="draw"){let Z=se(F,0,u.arrive*.8,R),x=se(F,u.arrive*.65,u.arrive*.35,T);g.setAttribute("stroke-dashoffset",(1-Z).toFixed(4)),g.setAttribute("fill-opacity",x.toFixed(3)),c.style.transform=""}else c.style.clipPath=D>=1?"":`circle(${(D*75).toFixed(3)}% at 50% 50%)`,c.style.transform=`scale(${(1.25-.25*D).toFixed(4)})`,g.setAttribute("stroke-dashoffset","0");let S=se(F,u.nameAt,u.slide,R),j=y*(1-S);if(d.style.transform=j===0?"":`translateX(${j.toFixed(2)}px)`,f&&b){let Z=se(F,u.nameAt,u.slide,T);f.style.transform=Z>=1?"":`translateX(${(-(1-Z)*105).toFixed(3)}%)`,b.style.visibility=F<u.nameAt?"hidden":"inherit"}if(h){let Z=se(F,u.tagAt,.7,T);h.style.opacity=Z.toFixed(3),h.style.transform=Z>=1?"":`translateY(${((1-Z)*.6).toFixed(3)}em)`}}}}};function ji(e){let n=e.closest(".m-stage");return!n||!n.offsetWidth?1:n.getBoundingClientRect().width/n.offsetWidth}var Ni=["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)"],cr={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):Ni,u=Math.max(1,Math.round(l(t.fields))),d=Math.max(1,l(t.period)),m=l(t.reach),c=Se(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 g=Array.from({length:u},(f,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(f){let b=f/d*Math.PI*2;for(let h of g){let y=h.hx+Math.cos(b*h.fx+h.ph)*m*s-h.size/2,v=h.hy+Math.sin(b*h.fy+h.ph*1.3)*m*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 lt="http://www.w3.org/2000/svg",Hi=0,pr={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 d=a.createElementNS(lt,"svg");d.setAttribute("width",String(s)),d.setAttribute("height",String(i)),d.style.cssText=`position:absolute;inset:0;opacity:${l(t.amount)};mix-blend-mode:overlay`;let m=`m-grain-${++Hi}`,c=a.createElementNS(lt,"filter");c.setAttribute("id",m),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","100%"),c.setAttribute("height","100%");let p=a.createElementNS(lt,"feTurbulence");p.setAttribute("type","fractalNoise"),p.setAttribute("baseFrequency",String(.9/o*(s/1920))),p.setAttribute("numOctaves","2"),p.setAttribute("stitchTiles","stitch");let g=a.createElementNS(lt,"feColorMatrix");g.setAttribute("type","saturate"),g.setAttribute("values","0"),c.append(p,g);let f=a.createElementNS(lt,"rect");return f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.setAttribute("filter",`url(#${m})`),d.append(c,f),e.appendChild(d),{seek(b){let h=u>0?Math.floor(b*u+1e-6):0;p.setAttribute("seed",String(r.seed*1e3+h))}}}};var hr={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 Ft(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 qi(e,n){let t=e-Math.floor(e),r=.6+.4*Math.exp(-t*n.decay),a=G(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 fr(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 gr={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 d=u.getContext("2d"),m=fr(e,"currentColor"),c=fr(e,"var(--m-accent)"),p=r.beat??Math.max(.05,l(t.period)),g=r.filmStart??0,f=l(t.pitch)*o,b=l(t.dot)*f,h=l(t.paper),y=l(t.glow),v=l(t.glow_radius)*o,R={decay:l(t.decay),ring:l(t.ring),reach:l(t.ring_reach),life:l(t.ring_life)},T=l(t.center_x)/100*s,F=l(t.center_y)/100*i,D=[],S=Math.ceil(T/f)+1,j=Math.ceil(F/f)+1;for(let $=-j;$<=Math.ceil((i-F)/f)+1;$++)for(let C=-S;C<=Math.ceil((s-T)/f)+1;C++){let A=T+C*f,V=F+$*f;D.push([A,V,Math.hypot(A-T,V-F)])}let Z,x=te(n.clear);return{seek($){if(!d)return;if(!Z){let M=x.map(H=>r.boxOf?.(H)).filter(H=>!!H);Z=D.filter(([H,Y])=>!M.some(K=>H>K.x-b&&H<K.x+K.w+b&&Y>K.y-b&&Y<K.y+K.h+b))}Ft(u,d,r.size,r),d.clearRect(0,0,s,i);let{breathe:C,ringR:A,ringA:V}=qi((g+$)/p,R),B=A*o,X=40*o,W=d.createRadialGradient(T,F,0,T,F,v);W.addColorStop(0,`rgba(${c},${(.07*C).toFixed(4)})`),W.addColorStop(.55,`rgba(${c},${(.025*C).toFixed(4)})`),W.addColorStop(1,`rgba(${c},0)`),d.fillStyle=W,d.fillRect(T-v,F-v,v*2,v*2);for(let[M,H,Y]of Z){let K=Y/v,k=K>=1?0:K<.45?1-K/.45*(1-.05/.13):.05/.13*(1-(K-.45)/.55),E=V>0?V*Math.max(0,1-Math.abs(Y-B)/X):0,L=y*C*k+E;d.beginPath(),d.arc(M,H,b,0,Math.PI*2),h>0&&(d.fillStyle=`rgba(${m},${h})`,d.fill()),L>.002&&(d.fillStyle=`rgba(${c},${Math.min(1,L).toFixed(4)})`,d.fill())}}}}};var br=e=>/^data:image\/|\.(png|jpe?g|webp|avif|gif|svg)(\?|#|$)/i.test(e);function Zi(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 Xi(e,n){return e.length<2||!(n>0)?0:G(Math.log2(e[0]/n),0,e.length-1)}function Ui(e,n,t,r,a,s,i){let o=Math.sin(r*Math.PI/180),u=Math.sin(t*Math.PI/180),d=Math.hypot(o,u);if(d<1e-4||i<=0)return"linear-gradient(transparent, transparent)";let m=o/d,c=u/d,p=Math.atan2(m,-c)*180/Math.PI,g=Math.abs(e*m)+Math.abs(n*c),f=((a-e/2)*m+(s-n/2)*c)/g+.5,b=v=>Math.min(1,Math.abs(v-f)*g*d/i),h=[[0,b(0)]],y=i/(g*d);return f-y>0&&h.push([f-y,1]),f>0&&f<1&&h.push([f,0]),f+y<1&&h.push([f+y,1]),h.push([1,b(1)]),`linear-gradient(${p.toFixed(2)}deg, ${h.map(([v,R])=>`rgba(0,0,0,${R.toFixed(3)}) ${(v*100).toFixed(2)}%`).join(", ")})`}function Vi(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 xr={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."}),P(e.focus)&&!P(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,d=r.frames?r.frames.height/r.frames.width:u?u.size[1]/u.size[0]:16/9,m=s*d;e.style.cssText+=";max-width:none";let c=a.createElement("div");c.style.cssText=`position:relative;width:${s}px;height:${m}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",g=0,f=Promise.resolve(),b=o.map(()=>{let W=a.createElement("img");return W.decoding="sync",W.alt="",W.style.cssText=`${p};opacity:0`,c.appendChild(W),W}),h=(W,M)=>{if(W.getAttribute("src")===M)return;W.src=M;let H=++g;f=Promise.all([f,W.decode().catch(()=>{if(!(H!==g||W.complete&&W.naturalWidth>0))return new Promise((Y,K)=>{W.addEventListener("load",()=>Y(),{once:!0}),W.addEventListener("error",()=>K(new Error(`Footage frame did not load: ${M}`)),{once:!0})})})]).then(()=>{})};if(!o.length&&br(P(n.src))){let W=a.createElement("img");W.decoding="sync",W.alt="",W.src=P(n.src),W.style.cssText=p,c.appendChild(W)}let y;!o.length&&!br(P(n.src))&&(y=a.createElement("video"),y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=P(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 R=a.createElement("div");R.style.cssText=`${p};pointer-events:none`;let T=a.createElement("div");T.style.cssText=`${p};pointer-events:none;mix-blend-mode:screen`,c.append(R,T);let F=u?.fps??60,D=u?s/u.size[0]:1,S=(W,M)=>{let H=u?.marks[W]??u?.marks[`#${W}`]??u?.marks[`.${W}`],Y=Zi(H,Math.round(it(M,n,t)*F));return Y?[Y[0]*D,Y[1]*D,Y[2]*D,Y[3]*D]:void 0},j=typeof window<"u"&&window.devicePixelRatio||1,Z=l(t.aperture),x=l(t.depth),$=l(t.shade),C=l(t.sheen),A=l(t.shadow),V=l(t.light),B=P(n.focus),X=o.map(W=>W.width);return{seek(W){let M=r.cameraPose?.()??{scale:1,rotateX:0,rotateY:0},H=it(W,n,t);if(o.length){let E=Xi(X,s*M.scale*j),L=Math.floor(E),z=Math.min(o.length-1,L+1),I=E-L;if(b.forEach((U,Q)=>{let ee=Q===L||Q===z&&I>.001;if(U.style.opacity=ee?Q===L?"1":I.toFixed(3):"0",U.style.zIndex=Q===z&&Q!==L?"1":"0",ee){let ie=o[Q];h(U,Ue(ie,Math.round((H-ie.start)*ie.rate+1e-6)))}}),v){let U=Math.hypot(M.rotateX,M.rotateY);if(Z>0&&U>.05){let Q=o[Math.min(o.length-1,z+1)];h(v,Ue(Q,Math.round((H-Q.start)*Q.rate+1e-6)));let ee=B?S(B,W):void 0,[ie,de]=ee?[ee[0]+ee[2]/2,ee[1]+ee[3]/2]:[s/2,m/2],ce=Ui(s,m,M.rotateX,M.rotateY,ie,de,x);v.style.maskImage=ce,v.style.opacity="1",v.style.zIndex="2"}else v.style.opacity="0"}}else y&&Math.abs(y.currentTime-H)>.5/r.fps&&(y.currentTime=H);let Y=Vi(M.rotateX,M.rotateY,V)*$*2;R.style.background=Y>=0?`rgba(255,255,255,${G(Y*.5).toFixed(3)})`:`rgba(0,0,0,${G(-Y).toFixed(3)})`,R.style.zIndex="3";let K=50+M.rotateY*3-M.rotateX*3;T.style.background=C>0?`linear-gradient(${(V+90).toFixed(0)}deg, transparent ${(K-22).toFixed(1)}%, rgba(255,255,255,${C}) ${K.toFixed(1)}%, transparent ${(K+22).toFixed(1)}%)`:"",T.style.zIndex="4";let k=Math.hypot(M.rotateX,M.rotateY);c.style.boxShadow=A>0?`0 ${(10+k*1.6).toFixed(1)}px ${(30+k*3).toFixed(1)}px rgba(0,0,0,${A})`:"",c.style.overflow="hidden"},pending:()=>f,markAt:S}}};function De(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 Be(e,n){e.parentElement?.querySelectorAll(`:scope > [data-m-overlay^="${n}-"]`).forEach(t=>t.remove())}var Ke=e=>["base","surface","sunken","accent","inverse"].includes(e)?`var(--m-bg-${e})`:e;var yr="cover",wr={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=De(e,yr,s),d=a.ease("quart.inOut"),m=P(r.direction),c=1-i*(s-1);u.forEach((f,b)=>{f.style.background=Ke(te([o[(s-1-b)%o.length]])[0]);let h=G((t-b*i)/c),y=d(G(h*2)),v=d(G(h*2-1)),R=y*100,T=v*100,F=m==="up"?`${100-R}% 0 ${T}% 0`:m==="down"?`${T}% 0 ${100-R}% 0`:m==="left"?`0 ${T}% 0 ${100-R}%`:`0 ${100-R}% 0 ${T}%`;f.style.clipPath=`inset(${F})`,f.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 g=d(G((t-p)/(1-p)));n.style.transform=t>=p?`scale(${(1.04-.04*g).toFixed(4)})`:""},clear(e){Be(e,yr),e.style.transform="",e.style.opacity=""}};var vr="curtain",kr={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]=De(e,vr,2);if(!s||!i)return;let o=a.ease("quint.inOut"),u=o(G(t/.46)),d=o(G((t-.54)/.46)),m=(u-d)*50,c=P(r.axis)!=="horizontal";for(let g of[s,i])g.style.background=Ke(P(r.fill,"inverse"));s.style.clipPath=c?`inset(0 ${100-m}% 0 0)`:`inset(0 0 ${100-m}% 0)`,i.style.clipPath=c?`inset(0 0 0 ${100-m}%)`:`inset(${100-m}% 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*d).toFixed(4)})`:""},clear(e){Be(e,vr),e.style.opacity="",e.style.transform=""}};var Mr={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`,P(r.pace)==="glide"){let f=a.ease("sine.inOut")(t),b=Math.pow(l(r.scale_to),f),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")(G((t-.55)/.35))),n.style.transform=`scale(${(1.12-.12*a.ease("expo.out")(G((t-.5)/.5))).toFixed(4)})`,n.style.filter=h>.05?`blur(${h.toFixed(2)}px)`:"",n.style.opacity=String(a.ease("smooth")(G((t-.5)/.35)));return}let d=a.ease("expo.in"),m=a.ease("expo.out"),c=d(G(t/.55)),p=m(G((t-.45)/.55)),g=1+(l(r.scale_to)-1)*c;e.style.transform=`scale(${g.toFixed(4)})`,e.style.filter=c>.02?`blur(${(c*14).toFixed(2)}px)`:"",e.style.opacity=String(1-G((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(G((t-.45)/.12))},clear(e){e.style.transform="",e.style.transformOrigin="",e.style.filter="",e.style.opacity=""}};var Fr={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,d=l(r.y)/100*o,m=s(t),c=Math.max(Math.hypot(u,d),Math.hypot(i-u,d),Math.hypot(u,o-d),Math.hypot(i-u,o-d)),p=m*c*1.02;if(P(r.shape)==="rounded"){let g=p*.9,f=p*.9;n.style.clipPath=`inset(${(d-f).toFixed(1)}px ${(i-u-g).toFixed(1)}px ${(o-d-f).toFixed(1)}px ${(u-g).toFixed(1)}px round ${(p*.25).toFixed(1)}px)`}else n.style.clipPath=`circle(${p.toFixed(2)}px at ${u.toFixed(1)}px ${d.toFixed(1)}px)`;n.style.transform=`scale(${(1.08-.08*m).toFixed(4)})`,n.style.transformOrigin=`${u}px ${d}px`,e.style.transform=`scale(${(1+l(r.push_in)*m).toFixed(4)})`,e.style.transformOrigin=`${u}px ${d}px`},clear(e){e.style.clipPath="",e.style.transform="",e.style.transformOrigin=""}};var Zt="http://www.w3.org/2000/svg",$r=new WeakMap,Yi=0,Me=(e,n)=>Math.abs(e)*Math.max(0,n)/Math.sqrt(12),Tr=.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<Tr&&s<Tr)return"";let i=$r.get(e);if(!i){let c=e.ownerDocument,p=e.closest(".m-stage")??c.body,g=p.querySelector(":scope > svg.m-filters");g||(g=c.createElementNS(Zt,"svg"),g.setAttribute("class","m-filters"),g.setAttribute("aria-hidden","true"),g.style.cssText="position:absolute;width:0;height:0;overflow:hidden;pointer-events:none",p.appendChild(g));let f=`m-dblur-${++Yi}`,b=c.createElementNS(Zt,"filter");b.setAttribute("id",f),b.setAttribute("color-interpolation-filters","sRGB");let h=c.createElementNS(Zt,"feGaussianBlur");b.appendChild(h),g.appendChild(b),i={id:f,filter:b,blur:h},$r.set(e,i)}let o=Math.max(1,e.offsetWidth),u=Math.max(1,e.offsetHeight),d=3*a/o,m=3*s/u;return i.filter.setAttribute("x",(-d).toFixed(4)),i.filter.setAttribute("y",(-m).toFixed(4)),i.filter.setAttribute("width",(1+2*d).toFixed(4)),i.filter.setAttribute("height",(1+2*m).toFixed(4)),i.blur.setAttribute("stdDeviation",`${a.toFixed(2)} ${s.toFixed(2)}`),`url(#${i.id})`}var Er={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},Sr={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,d]=Er[P(r.direction)]??Er.left,m=s(t),c=u?i:o,p=a.fps||30,g=1/120,f=(s(Math.min(1,t+g))-s(Math.max(0,t-g)))/(2*g)*c/(l(r.duration)*p),b=1-l(r.parallax),h=l(r.blur),y=Me(f,h),v=Me(f*b,h);n.style.transform=`translate(${(-u*(1-m)*i).toFixed(2)}px, ${(-d*(1-m)*o).toFixed(2)}px)`,e.style.transform=`translate(${(u*m*i*b).toFixed(2)}px, ${(d*m*o*b).toFixed(2)}px)`,e.style.filter=[Te(e,u?v:0,d?v:0),`brightness(${(1-.35*m).toFixed(3)})`].filter(Boolean).join(" "),n.style.filter=Te(n,u?y:0,d?y:0)},clear(e){e.style.transform="",e.style.filter=""}};var Cr={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=P(r.direction)!=="right",d=100+o,m=u?100-i*d:i*d-o,c=m+o;n.style.clipPath=u?`polygon(${m}% 0, 100% 0, 100% 100%, ${c}% 100%)`:`polygon(0 0, ${m+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 Ar={up:[0,1],down:[0,-1],left:[1,0],right:[-1,0]},Pr={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,[d,m]=Ar[P(r.direction)]??Ar.up,c=l(r.radius)/100*o,p=Math.min(1,Math.max(0,(t-.75)/.25)),g=c*(1-p*p*(3-2*p));n.style.transform=`translate(${(d*(1-i)*o).toFixed(2)}px, ${(m*(1-i)*u).toFixed(2)}px)`,n.style.borderRadius=g>.5?`${g.toFixed(1)}px`:"";let f=.3*Math.min(1,(1-i)*4);n.style.boxShadow=f>.002?`${(-d*24).toFixed(0)}px ${(-m*24).toFixed(0)}px 90px rgba(0,0,0,${f.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 ut=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Pe(e,n,t={}){let r=e.ownerDocument,a=new Set([...t.accent??[]].map(ut)),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=[],d=[],m=[],c=[];n.split(`
|
|
4
|
+
`)}var Ue=(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,P=(e,n="")=>typeof e=="string"?e:e==null?n:String(e),te=e=>Array.isArray(e)?e.map(n=>String(n)):[],be=e=>Array.isArray(e)?e.map(n=>l(n)):[];var xi={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)"},hn={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=P(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=xi[r]??r,{seek(){}}}};var G=(e,n=0,t=1)=>Math.min(t,Math.max(n,e)),ke=(e,n,t)=>e+(n-e)*t;function rt(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,d=1-o-u,m=p=>((i*p+s)*p+a)*p,c=p=>((d*p+u)*p+o)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let g=p;for(let f=0;f<8;f++){let b=(3*i*g+2*s)*g+a;if(Math.abs(b)<1e-6)break;g-=(m(g)-p)/b}if(g<0||g>1||Math.abs(m(g)-p)>1e-4){let f=0,b=1;for(let h=0;h<24;h++)g=(f+b)/2,m(g)<p?f=g:b=g}return c(g)}}function yi({duration:e,bounce:n=0}){let t=2*Math.PI/(Math.max(.05,e)*1.2),r=G(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 Nt={"ui.default":[.2,0,0,1],"ui.in":[.4,0,1,1],"ui.out":[0,0,.2,1],"ui.spring":[.22,1,.36,1]},Ht={"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]},Fo={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],...Ht,...Nt},jt={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},at=[...Object.keys(jt),...Object.keys(Ht),...Object.keys(Nt)],fn=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 Ne(e,n={}){if(e===void 0)return jt["expo.out"];if(typeof e=="string"){let t=n[e]??Nt[e]??Ht[e];if(t)return rt(...t);let r=jt[e];if(!r)throw new Error(`Unknown ease "${e}". Known: ${at.join(", ")}`);return a=>r(G(a))}return Array.isArray(e)?rt(...e):yi(e.spring)}function se(e,n,t,r){return t<=0?e>=n?1:0:r(G((e-n)/t))}function Se(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}}var wi=(e,n)=>e.replace(/%(?:0(\d+))?d/,(t,r)=>String(n).padStart(r?Number(r):0,"0"));function vi(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)*G(t,0,r)}var gn=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)}),bn={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=gn(n);return t.delay+(Math.abs(t.last-t.first)+1)/t.fps/t.rate},build(e,n,t){let r=e.ownerDocument,a=gn(t),s=P(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 m=o;m<=u;m++){let c=r.createElement("img");c.src=wi(s,m),c.alt=m===a.first?P(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 d=-1;return{seek(m){let c=vi(m,a)-o;c!==d&&(d>=0&&(i[d].style.visibility="hidden"),i[c].style.visibility="inherit",d=c)}}}};var xn={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=P(n.html),{seek(){}}}};var yn={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=P(n.src),s.alt=P(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 d=r.createElement("div"),m=[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(", ");d.style.cssText=`position:absolute;inset:0;border-radius:${a};box-shadow:${m};pointer-events:none`,e.appendChild(d)}return{seek(){}}}};var wn={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=P(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 vn={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=P(n.text),{seek(){}}}};function ki(e){let n=be(e);return n.length===4&&n[2]>0&&n[3]>0?[n[0],n[1],n[2],n[3]]:[0,0,100,100]}function it(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 kn={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=be(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=P(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]=ki(n.crop),d=l(t.width),m=l(t.height),c=l(t.radius),p=a.createElement("div");p.style.cssText=`position:relative;overflow:hidden;width:${d}px;border-radius:${c}px;${m>0?`height:${m}px`:"aspect-ratio:16 / 9"}`,e.style.borderRadius=`${c}px`;let g=a.createElement("div");g.style.cssText=`position:absolute;left:${-s/o*100}%;top:${-i/u*100}%;width:${100/o*100}%;height:${100/u*100}%`,p.appendChild(g),e.appendChild(p);let f="object-fit:fill;display:block;width:100%;height:100%",b=(Z,x)=>{if(!(Z>0&&x>0))return;if(m<=0){p.style.aspectRatio=`${(Z*o).toFixed(3)} / ${(x*u).toFixed(3)}`;return}let $=Z*o/(x*u)/(d/m);g.style.transformOrigin=`${s+o/2}% ${i+u/2}%`,g.style.transform=`scale(${Math.max(1,$).toFixed(5)}, ${Math.max(1,1/$).toFixed(5)})`},h=r.frames;if(h){let Z=a.createElement("img");Z.decoding="sync",Z.alt="",Z.style.cssText=f,Z.src=Ue(h,0),g.appendChild(Z),b(h.width,h.height);let x=0,$=0,C=Promise.resolve(),A=(V,B)=>Z.decode().catch(()=>{if(!(V!==$||Z.complete&&Z.naturalWidth>0))return new Promise((X,W)=>{Z.addEventListener("load",()=>X(),{once:!0}),Z.addEventListener("error",()=>V===$?W(new Error(`Video frame did not load: ${B}`)):X(),{once:!0})})});return{seek(V){let B=Math.round((it(V,n,t)-h.start)*h.rate+1e-6),X=Math.min(h.count-1,Math.max(0,B));if(X===x)return;x=X;let W=Ue(h,X);Z.src=W,C=A(++$,W)},pending:()=>C}}let y=a.createElement("video");y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=P(n.src),y.style.cssText=f,g.appendChild(y),y.addEventListener("loadedmetadata",()=>b(y.videoWidth,y.videoHeight));let v=()=>a.documentElement.classList.contains("render"),R=l(t.rate,1),T=Promise.resolve(),F=-1,D=0,S,j=Z=>{Math.abs(y.currentTime-Z)<.5/r.fps||(T=new Promise(x=>{let $=()=>{y.removeEventListener("seeked",$),x()};y.addEventListener("seeked",$),y.currentTime=Z}))};return{seek(Z){let x=it(Z,n,t);if(v()){j(x);return}let $=performance.now(),C=Z-F,A=($-D)/1e3;F=Z,D=$,C>0&&C<.25&&Math.abs(C-A)<.1?(Math.abs(y.currentTime-x)>.2&&(y.currentTime=x),y.playbackRate=R,y.paused&&y.play().catch(()=>{}),clearTimeout(S),S=setTimeout(()=>y.pause(),120)):(y.pause(),j(x))},pending:()=>T}}};var Mn={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(d){let m=d>=u?s:i+(s-i)*se(d,0,u,a);e.textContent=`${P(n.prefix)}${m.toFixed(o)}${P(n.suffix)}`}}}};var Fn={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),d=Se(r.seed*101+7),m=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 g=te(n.items).map((f,b,h)=>{let y=(b+d()*.6)/h.length*Math.PI*2,v=.3+d()*.14,R=a/2+Math.cos(y)*a*v,T=s/2+Math.sin(y)*s*(v+.04),F=b%o,D=o===1?1:1-F/o,S=document.createElement("span");return S.textContent=f,S.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)${F===0&&o>1?`;filter:blur(${.06*i}px)`:""}`,e.appendChild(S),{n:S,x:R,y:T,depth:D,delay:b*p}});return{seek(f){for(let b of g){let h=(f-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(m(Math.min(1,Math.max(0,(f-b.delay)/c)))*(.35+b.depth*.5))}}}}};var $n={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 d=document.createElement("span");return d.textContent=u,d.style.cssText="padding:0.45em 0.9em;border-radius:999px;background:var(--m-bg-surface);white-space:nowrap;will-change:transform,opacity",e.appendChild(d),d});return{seek(u){o.forEach((d,m)=>{let c=se(u,m*i,s,a);d.style.opacity=String(c),d.style.transform=`scale(${.9+.1*c})`})}}}};var Tn=["inverse","plain","accent","tint"],En={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,d=l(t.tile)*s,m=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 g=Array.from({length:i},(f,b)=>{let h=document.createElement("div"),y=o.length?o[b%o.length]:"",v=Tn[b%Tn.length],R=[...y].length>3,T=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:${-d/2}px;top:${-d/2}px;width:${d}px;height:${d}px;border-radius:${d*.12}px;display:grid;place-items:center;overflow:hidden;font:${R?`500 ${d*.14}px var(--m-font-mono)`:`600 ${d*.4}px var(--m-font-display)`};letter-spacing:${R?"0":"-0.03em"};${T}`,p.appendChild(h),h});return e.appendChild(p),{seek(f){let b=f/c*360;g.forEach((h,y)=>{let v=y*360/i+b,R=(Math.cos(v*Math.PI/180)+1)/2;h.style.transform=`rotateY(${v}deg) translateZ(${u}px)`,h.style.opacity=String(m+(1-m)*R),h.style.filter=R<.999?`saturate(${.35+.65*R})`:""})}}}};var Sn=[1,1.24,.6,1.1,.9,1.3],Cn=[.1,.5,.92,.3,.7,.2],An={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=P(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,g)=>{let f=a.filter((F,D)=>D%s===g),b=f.length?f:a,h=document.createElement("div");h.style.cssText="display:flex;width:max-content;will-change:transform";let y=F=>b.forEach(D=>{let S=document.createElement("span");if(S.textContent=D,S.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)",D===o){let j=document.createElement("span");j.textContent=D,j.setAttribute("aria-hidden","true"),j.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)",S.appendChild(j),S.style.transform="scale(calc(1 + 0.08 * var(--k, 0)))",S.style.zIndex="1"}else S.style.opacity="calc(1 - var(--dim, 0) * var(--k, 0))";F.appendChild(S)}),v=document.createElement("div");v.style.cssText="display:flex;flex:none",y(v),h.appendChild(v),e.appendChild(h);let R=Math.max(1,v.getBoundingClientRect().width/Mi(e)),T=Math.ceil(r.size[0]/R)+1;for(let F=0;F<T;F++)h.appendChild(v.cloneNode(!0));return{track:h,width:R,dir:g%2?-1:1,rate:Sn[g%Sn.length],off:Cn[g%Cn.length]}}),d=r.ease(r.tokens.ease_move),m=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?se(p,m,c,d):0));for(let g of u){let f=(p*i*g.rate+g.off*g.width)%g.width;g.track.style.transform=`translateX(${-(g.dir>0?f:g.width-f)}px)`}}}}};function Mi(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}var Ve=["start","end","center","edges","random"];function Pn(e,n="start",t=1,r){if(e<=0)return[];if(n==="random"){let c=Se(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 g=r&&e>1?Math.hypot(r[0]-1,r[1]-1)/(e-1):1,f=new Array(e);return p.forEach((b,h)=>{f[b]=h*g}),f}let[a,s]=r??[e,1],i=c=>[c%a,Math.floor(c/a)],o=(a-1)/2,u=(s-1)/2,d=c=>{let[p,g]=i(c);return n==="end"?Math.hypot(a-1-p,s-1-g):n==="center"?Math.hypot(p-o,g-u):n==="edges"?Math.hypot(o,u)-Math.hypot(p-o,g-u):Math.hypot(p,g)},m=Array.from({length:e},(c,p)=>d(p));return r?m:m.map(c=>Math.floor(c+1e-9))}function $e(e,n,t="start",r=1,a){let s=Pn(e,t,r,a),i=Math.max(0,...s);return s.map(o=>i>0?o*n:0)}function Oe(e,n="start",t=1,r){return Math.max(0,...Pn(e,n,t,r))}function zn(e,n,t=.5){let a=e.map(([u,d])=>Math.hypot(u-n[0],d-n[1])).map((u,d)=>[u,d]).sort((u,d)=>u[0]-d[0]||u[1]-d[1]),s=new Array(e.length),i=-1,o=-1/0;for(let[u,d]of a)u-o>t&&(i++,o=u),s[d]=i;return s}function Fi(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 d=0;for(let p=1;p<a;p++)i[p]<i[d]-.5&&(d=p);let m=s/(u>0?u:1),c={x:d*(s+r),y:i[d],w:s,h:m};return i[d]=i[d]+m+r,c}),height:Math.max(0,Math.max(...i)-r)}}function qt(e,n,t){let r=zn(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 Rn={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=be(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=be(n.ratios),o=l(t.width)/100*r.size[0],u=l(t.gap),d=l(t.columns),m=l(t.stagger),c=r.tokens.duration.slow,p=l(t.drift_speed),g=r.ease(r.tokens.ease_enter),f=a.createElement("div");f.style.cssText=`position:relative;width:${o}px`;let b=s.map(T=>{let F=a.createElement("img");return F.src=T,F.alt="",F.decoding="sync",F.style.cssText=`position:absolute;display:block;object-fit:cover;border-radius:var(--m-card-radius, ${Math.round(u*.75)}px)`,f.appendChild(F),F});e.appendChild(f);let h="",y=[],v=[],R=()=>{let T=b.map((j,Z)=>i[Z]??(j.naturalWidth>0?j.naturalWidth/j.naturalHeight:1)),F=T.map(j=>j.toFixed(4)).join();if(F===h)return;h=F;let{cards:D,height:S}=Fi(T,d,o,u);f.style.height=`${S}px`,D.forEach((j,Z)=>Object.assign(b[Z].style,{left:`${j.x}px`,top:`${j.y}px`,width:`${j.w}px`,height:`${j.h}px`})),v=D.map(j=>j.y),y=qt(D,[l(t.focus_x)/100*o,l(t.focus_y)/100*S],m)};return R(),{seek(T){R(),b.forEach((F,D)=>{let S=se(T,y[D],c,g);F.style.opacity=S.toFixed(4),F.style.top=`${(v[D]+(1-S)*24).toFixed(2)}px`}),f.style.transform=p>0?`translateY(${(-p*Math.max(0,T)).toFixed(2)}px)`:""}}}};var st=["slide-up","slide-left","flip","stack","fade"],Ln=["slide-up","flip","slide-left","stack","fade"],$i=e=>e.split(/[/|\n]/).map(n=>n.trim().split(/\s+/).filter(Boolean)).filter(n=>n.length>0);function ot(e){let n=$i(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((d,m)=>{let c=i.get(d);if(!c){let f={name:d,col:m,row:u,cols:1,rows:1};i.set(d,f),s.push(f);return}let p=Math.max(c.col+c.cols,m+1),g=Math.max(c.row+c.rows,u+1);c.col=Math.min(c.col,m),c.cols=p-c.col,c.rows=g-c.row}));for(let o of s){let u=0;if(n.forEach((d,m)=>d.forEach((c,p)=>{c===o.name?u++:p>=o.col&&p<o.col+o.cols&&m>=o.row&&m<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 xt(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 Ti(e,n,t,[r,a]){let{tiles:s,cols:i,rows:o}=ot(e),u=n/100*r,d=Math.max(a*.1,a-(r-u)),m=(u-t*(i-1))/Math.max(1,i),c=(d-t*(o-1))/Math.max(1,o);return s.map(p=>(p.cols*m+(p.cols-1)*t)*(p.rows*c+(p.rows-1)*t)/(r*a))}function On(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 Ei(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 Si=/^(data:image\/|[^<\s]+\.(png|jpe?g|webp|gif|avif|svg)(\?\S*)?$)/i;function yt(e,n){if(Si.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 Ci(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 Ai=.06,Dn={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",...st],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}=ot(P(e.areas)),a=xt(te(e.items).length,r.length,be(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}=ot(P(e.areas)),a=xt(te(e.items).length,r.length,be(e.counts)),s=l(n.hold),i=l(n.swap_time),o=s+i,u=l(n.stagger),d=u>0?Math.max(0,r.length-1)*u+t.tokens.duration.slow:0,m=Math.max(0,...a.map(f=>f.length));if(m<2)return[];let c=d+m*o,p=a.map((f,b)=>f.length>1?b:-1).filter(f=>f>=0),g=Ti(P(e.areas),l(n.width),l(n.gap),t.size);return On(p.length,d,s,l(n.offset)).flatMap((f,b)=>{let h=[],y=+g[p[b]].toFixed(4);for(let v=f;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}=ot(P(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=be(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(m=>m.name).join(", ")}).`,hint:"Give one count per tile, in reading order."}):s.length&&s.reduce((m,c)=>m+c,0)!==a&&n.push({path:"props.counts",message:`counts add up to ${s.reduce((m,c)=>m+c,0)}, but there are ${a} items.`,hint:"Make the counts add up to the number of items."}),s.some(m=>!(m>=1)||m!==Math.round(m))&&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=xt(a,t.length,s).map(m=>m.length).filter(m=>m>1),u=Math.max(0,...o),d=o.filter(m=>u%m!==0);return d.length&&n.push({path:"props.counts",message:`Tiles cycle ${[...new Set(o)].join(", ")} items: at the end, the tiles with ${[...new Set(d)].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((m,c)=>{st.includes(m)||n.push({path:`props.swaps[${c}]`,message:`"${m}" is not a swap move.`,hint:`Use one of ${st.join(", ")}.`})}),n},build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,{tiles:o,cols:u,rows:d}=ot(P(n.areas)),m=te(n.items),c=xt(m.length,o.length,be(n.counts)),p=te(n.swaps),g=l(t.width)/100*s,f=(s-g)/2,b=Math.max(i*.1,i-2*f),h=l(t.gap),y=(g-h*(u-1))/Math.max(1,u),v=(b-h*(d-1))/Math.max(1,d),R=l(t.hold),T=Math.max(.01,l(t.swap_time)),F=l(t.stagger),D=R+T,S=s/1080,j=r.ease(r.tokens.ease_enter),Z=r.ease(r.tokens.ease_move),x=r.tokens.duration.slow,$=o.map(H=>({x:H.col*(y+h),y:H.row*(v+h),w:H.cols*y+(H.cols-1)*h,h:H.rows*v+(H.rows-1)*h})),C=F>0?qt($,[g/2,b/2],F):$.map(()=>0),A=F>0?Math.max(0,o.length-1)*F+x:0,V=c.map((H,Y)=>H.length>1?Y:-1).filter(H=>H>=0),B=On(V.length,A,R,l(t.offset)),X=`var(--m-card-radius, ${Math.max(4,Math.round(h*.75))}px)`,W=a.createElement("div");W.style.cssText=`position:relative;width:${g}px;height:${b}px`;let M=o.map((H,Y)=>{let K=$[Y],k=a.createElement("div");k.style.cssText=`position:absolute;left:${K.x}px;top:${K.y}px;width:${K.w}px;height:${K.h}px;overflow:hidden;border-radius:${X};background:var(--m-bg-sunken);perspective:${(2.5*Math.max(K.w,K.h)).toFixed(0)}px;isolation:isolate`;let E=V.indexOf(Y),L=st.includes(p[Y]??"")?p[Y]:P(t.swap)==="mixed"||!st.includes(P(t.swap))?Ln[Math.max(0,E)%Ln.length]:P(t.swap),z=c[Y].map(I=>{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*S).toFixed(2)}px`;let Q=yt(U,m[I]??"");return k.appendChild(U),{face:U,img:Q}});return W.appendChild(k),{tile:k,faces:z,move:L,start:E>=0?B[E]:1/0,top:K.y}});return e.appendChild(W),{seek(H){M.forEach((Y,K)=>{let k=F>0?se(H,C[K],x,j):1;Y.tile.style.opacity=k<1?k.toFixed(4):"",Y.tile.style.top=`${(Y.top+(1-k)*24*S).toFixed(2)}px`;let E=Ei(H,Y.start,Y.faces.length,R,T);Y.faces.forEach(({face:L,img:z},I)=>{let U=I===E.from||I===E.to;if(L.style.visibility=U?"inherit":"hidden",L.style.transform="",L.style.opacity="",L.style.zIndex="",z){let Q=I===E.to?E.age:E.age+D;z.style.transform=U?`scale(${(1+Ai*(1-G(Q/(D+T)))).toFixed(4)})`:""}}),E.from!==E.to&&Ci(Y.move,Y.faces[E.from].face,Y.faces[E.to].face,Z(E.k))})}}}};var Pi=["4:5","1:1","9:16","3:4","16:9"],Wn=e=>{let[n,t]=P(e,"4:5").split(":").map(Number);return n>0&&t>0?n/t:.8},jn=.14;function Bn(e,n,t){let r=Wn(e.ratio),a=P(e.chrome)!=="none"?2*jn:0,s=Math.min(l(e.width)/100*n,.92*t/(1/r+a));return{w:s,h:s/r}}var zi=.05;function Ri(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(G((e-t-u*i)/r))}function In(e,n,t,r){let a=e-n;return!r||t<3?a:((a+t/2)%t+t)%t-t/2}var Nn={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:Pi,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:d,h:m}=Bn(n,o,u),c=+Math.min(1,1.5*d*m/(o*u)).toFixed(4);return Array.from({length:i},(p,g)=>({at:a+g*(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,d=P(t.chrome)!=="none",m=Wn(t.ratio),c=t.loop===!0,{w:p,h:g}=Bn(t,s,i),f=d?jn*p:0,b=.035*p,h=.035*p,y=p/1e3,v=l(t.hold),R=Math.max(.01,l(t.turn)),T=v+R,F=l(t.angle),D=r.ease(r.tokens.ease_move),S=a.createElement("div");S.style.cssText=`position:relative;width:${p}px;height:${g+2*f}px;text-align:left`;let j=a.createElement("div");j.style.cssText=`position:absolute;left:0;top:${f}px;width:${p}px;height:${g}px;perspective:${(2.5*p).toFixed(0)}px;transform-style:preserve-3d`;let Z=o.map(A=>{let V=a.createElement("div");V.style.cssText=`position:absolute;inset:0;overflow:hidden;background:var(--m-bg-surface);border-radius:${d?"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 B=a.createElement("div");return B.style.cssText="position:absolute;inset:0;display:grid;place-items:center;transform-origin:50% 50%",yt(B,A),V.appendChild(B),j.appendChild(V),{card:V,inner:B}});S.appendChild(j);let x=[];if(d){let A="var(--m-font-body)",V=(Q,ee)=>`position:absolute;left:0;top:${Q}px;width:${p}px;height:${f}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:${ee};font:600 ${34*y}px/1 ${A}`,B=a.createElement("div");B.style.cssText=V(0,`${h}px ${h}px 0 0`)+";box-shadow:inset 0 -1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let X=a.createElement("div"),W=64*y;X.style.cssText=`flex:none;width:${W}px;height:${W}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 ${A}`;let M=P(n.avatar);M?yt(X,M):X.textContent=(P(n.handle,"y").trim()[0]??"y").toUpperCase();let H=a.createElement("span");H.textContent=P(n.handle,"yourbrand"),H.style.cssText="flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis";let Y=a.createElement("span");Y.textContent="\u2022\u2022\u2022",Y.style.cssText=`letter-spacing:${2*y}px;font-size:${22*y}px;color:var(--m-text-muted)`,B.append(X,H,Y);let K=a.createElement("div");K.style.cssText=V(f+g,`0 0 ${h}px ${h}px`)+";box-shadow:inset 0 1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)";let k=(Q,ee="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="${Q}" fill="${ee}" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/>`,ie},E=k("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");E.style.color="var(--m-accent)";let L=k("M20 11.5a8 8 0 0 1-11.6 7.1L4 20l1.4-4.2A8 8 0 1 1 20 11.5Z"),z=k("M21 3 10 13.5M21 3l-6.5 18-4.5-7.5L3 9.5 21 3Z"),I=a.createElement("div");I.style.cssText=`flex:1;display:flex;justify-content:center;gap:${10*y}px`;for(let Q=0;Q<Math.min(u,12);Q++){let ee=a.createElement("i");ee.style.cssText=`display:block;width:${11*y}px;height:${11*y}px;border-radius:50%;background:var(--m-text-primary)`,I.appendChild(ee),x.push(ee)}let U=k("M6 3.5h12v17l-6-4.5-6 4.5v-17Z");K.append(E,L,z,I,U),S.append(B,K)}e.appendChild(S);let $=A=>A===0?-R:v+(A-1)*T,C=u*T;return{seek(A){let V=Ri(A,u,v,R,c,D);Z.forEach(({card:B,inner:X},W)=>{let M=In(W,V,u,c),H=G(M,-1,1),Y=Math.max(0,Math.abs(M)-1);B.style.transformOrigin=M>=0?"0% 50%":"100% 50%",B.style.transform=`translateX(${(H*(p+b)).toFixed(2)}px) translateZ(${(-(Math.abs(H)*.06+Y*1.5)*p).toFixed(2)}px) rotateY(${(F*H).toFixed(3)}deg)`,B.style.opacity=Y>0?G((.6-Y)/.6).toFixed(4):"",B.style.visibility=Y<1?"inherit":"hidden",B.style.zIndex=String(10-Math.round(Math.abs(M)*2));let K=c?((A-$(W))%C+C)%C:A-$(W);X.style.transform=`scale(${(1+zi*(1-G(K/(T+R)))).toFixed(4)})`}),x.forEach((B,X)=>{let W=Math.max(0,1-Math.abs(In(X,V,u,c)));B.style.opacity=ke(.22,1,W).toFixed(3)})}}}};var Hn={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${P(n.edge)==="bottom"?";transform:scaleY(-1)":""}`,e.appendChild(u),{seek(d){let c=`radial-gradient(ellipse 62% 52% at 50% -6%, #000 0%, transparent ${se(d,0,i,a)*o*100}%)`;u.style.maskImage=c,u.style.setProperty("-webkit-mask-image",c)}}}};var qn={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 Zn={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(G(t/i)),u=s(G((t-(1-i))/i)),d=l(r.blur);e.style.opacity=String(1-o),e.style.filter=o>0?`blur(${o*d}px)`:"",n.style.opacity=String(u),n.style.filter=u<1?`blur(${(1-u)*d}px)`:""},clear(e){e.style.opacity="",e.style.filter=""}};var Xn={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,d=.5/i,m=[];for(let c=0;c<i;c++){let p=s(G((t-c*d)/(1-(i-1)*d)))*o,g=c*u/i,f=(c+1)*u/i+(c<i-1?1:0);m.push(`M0 ${g}H${p}V${f}H0Z`)}n.style.clipPath=`path('${m.join("")}')`},clear(e){e.style.clipPath=""}};var Un="ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&/+",Li=1/20,Vn={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=[...P(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)/Li);e.textContent=a.map((d,m)=>{if(m<o||d===" ")return d;let c=Se(r.seed*7919+u*131+m);return Un[Math.floor(c()*Un.length)]??d}).join("")}}}};var Yn={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)=>[...P(e.text)].length/Math.max(1,l(n.chars_per_s)),build(e,n,t){let r=[...P(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 d=Math.min(r.length,Math.floor(u*a+1e-6));s.textContent=r.slice(0,d).join(""),i.textContent=r.slice(d).join("");let m=u-r.length/a;o.style.opacity=m>0&&m%1>=.5?"0":"1"}}}};var Kn=e=>P(e.text).split(/\s+/).filter(Boolean),Gn={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,Kn(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(m=>m.toLowerCase()));e.style.cssText+=";display:flex;flex-wrap:wrap;justify-content:center;gap:0 0.26em";let i=Kn(n).map(m=>{let c=document.createElement("span");return c.textContent=m,c.style.cssText="display:inline-block;will-change:transform,opacity",s.has(m.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),d=l(t.rise);return{seek(m){i.forEach((c,p)=>{let g=se(m,p*o,u,a);c.style.opacity=String(Math.min(1,g*1.6)),c.style.transform=`translateY(${(1-g)*d}px)`})}}}};var wt=(e,n)=>{let t=Math.max(2,Math.round(l(e.cols)));return[t,Math.max(2,Math.round(t*n[1]/n[0]))]},Jn={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:Ve,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)=>Oe(wt(n,t.size)[0]*wt(n,t.size)[1],P(n.from),t.seed,wt(n,t.size))*l(n.stagger)+.6,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,[o,u]=wt(t,r.size),d=s/o,m=i/u,c=o*u,p=P(n.cell,"dot"),g=l(t.size)*Math.min(d,m),f=$e(c,l(t.stagger),P(t.from),r.seed,[o,u]),b=Math.max(...f,.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},(F,D)=>{let S=a.createElement("div"),j=D%o*d+d/2,Z=Math.floor(D/o)*m+m/2,x=p==="square"?`border-radius:${g*.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 S.style.cssText=`position:absolute;left:${j-g/2}px;top:${Z-g/2}px;width:${g}px;height:${g}px;${x}`,h.appendChild(S),S}),v=r.ease({spring:{duration:.45,bounce:.25}}),R=l(t.pulse),T=Math.max(1.2,b*1.6);return{seek(F){y.forEach((D,S)=>{let j=se(F,f[S],.6,v),Z=F>f[S]+.6?Math.sin((F-f[S])/T*Math.PI*2)*.5*R:0,x=Math.max(0,j*(1+Z*.6));D.style.transform=`scale(${x.toFixed(4)})`,D.style.opacity=Math.min(1,Math.max(0,(F-f[S])/.2)*(1-R*.3+Z*.6)).toFixed(3)})}}}};function Qn(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 _n={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=Qn(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=Qn(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)),d=r.ease("expressive.out");e.style.cssText+=";display:inline-flex;align-items:baseline;font-variant-numeric:tabular-nums;white-space:pre";let m=f=>{if(!f)return;let b=a.createElement("span");b.textContent=f,e.appendChild(b)};m(P(n.prefix));let p=s.filter(f=>/\d/.test(f)).length,g=[];for(let f of s){if(!/\d/.test(f)){m(f);continue}p--;let h=Number(f)+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 R=0;R<=h;R++){let T=a.createElement("span");T.textContent=String(R%10),T.style.cssText="display:block;height:1.1em;text-align:center",v.appendChild(T)}y.appendChild(v),e.appendChild(y),g.push({strip:v,travel:h,delay:p*o})}return m(P(n.suffix)),{seek(f){for(let b of g){let h=se(f,b.delay,i,d),y=b.travel*h;b.strip.style.transform=`translateY(${(-y*1.1).toFixed(4)}em)`;let v=b.travel*(se(f+1/60,b.delay,i,d)-h)*60,R=G(Math.abs(v)*.012,0,.06);b.strip.style.filter=R>.004?`blur(${R.toFixed(3)}em)`:""}}}}};var er="http://www.w3.org/2000/svg",tr={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=P(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=P(n.fill,"none"),i=s==="accent"?"var(--m-bg-accent)":s==="primary"?"var(--m-text-primary)":s,o=P(n.viewbox,"0 0 100 100").split(/[\s,]+/).map(Number),u=o[2]||100,d=o[3]||100,m=l(t.width)/100*r.size[0],c=a.createElementNS(er,"svg");c.setAttribute("viewBox",P(n.viewbox,"0 0 100 100")),c.setAttribute("width",String(m)),c.setAttribute("height",String(m*d/u)),c.style.cssText="display:block;overflow:visible";let p=l(t.stroke)*(u/m),g=te(n.paths).map(S=>{let j=a.createElementNS(er,"path");return j.setAttribute("d",S),j.setAttribute("pathLength","1"),j.setAttribute("stroke-dasharray","1 1"),j.setAttribute("stroke","currentColor"),j.setAttribute("stroke-width",String(p)),j.setAttribute("stroke-linecap","round"),j.setAttribute("stroke-linejoin","round"),j.setAttribute("fill",s==="none"?"none":i),c.appendChild(j),j});e.appendChild(c);let f=$e(g.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"),R=m/u,T=256,F=g.map(S=>{let j=0;try{j=S.getTotalLength()}catch{return[]}return Array.from({length:T+1},(Z,x)=>{let $=S.getPointAtLength(j*x/T);return[($.x-(o[0]??0))*R,($.y-(o[1]??0))*R]})}),D=(S,j)=>{let Z=F[S];if(!Z?.length)return;let x=Math.min(1,Math.max(0,j))*T,$=Math.floor(x),C=Math.min(T,$+1),A=x-$,[V,B]=Z[$],[X,W]=Z[C];return[V+(X-V)*A,B+(W-B)*A]};return{tip(S){let j=0;for(let Z=0;Z<g.length;Z++)S>=f[Z]&&(j=Z);return D(j,se(S,f[j],b,y))},seek(S){g.forEach((j,Z)=>{let x=se(S,f[Z],b,y);if(j.setAttribute("stroke-dashoffset",(1-x).toFixed(4)),j.style.visibility=S<f[Z]?"hidden":"inherit",s!=="none"){let $=se(S,f[Z]+b*.8,h,v);j.setAttribute("fill-opacity",$.toFixed(3)),j.setAttribute("stroke-opacity",(1-$).toFixed(3))}})}}}};var rr=["circle","square","squircle","triangle","diamond","hexagon","star","pill","plus","blob"],nr=e=>e,vt=(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 Oi(e,n){let t=e.map((u,d)=>[u,e[(d+1)%e.length]]),r=t.map(([u,d])=>Math.hypot(d[0]-u[0],d[1]-u[1])),a=r.reduce((u,d)=>u+d,0),s=[],i=0,o=0;for(let u=0;u<n;u++){let d=u/n*a;for(;i<t.length-1&&o+r[i]<d;)o+=r[i],i++;let[m,c]=t[i],p=r[i]>0?(d-o)/r[i]:0;s.push([m[0]+(c[0]-m[0])*p,m[1]+(c[1]-m[1])*p])}return s}function Di(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 Bi(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 nr([[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 vt(3,1.12,0).map(([r,a])=>[r,a+.14]);case"diamond":return vt(4,1.1);case"hexagon":return vt(6,1.04);case"star":return vt(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,d=2;for(let m=0;m<30;m++){let c=(u+d)/2,p=a*c,g=s*c,f=Math.max(0,Math.abs(p)-o);Math.hypot(f,g)>i?d=c:u=c}return u*1.9});case"plus":return nr([[-.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=Se(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 kt(e,n=120,t=1){return Di(Oi(Bi(e,t),n))}var ar=(e,n,t)=>e.map(([r,a],s)=>[r+(n[s][0]-r)*t,a+(n[s][1]-a)*t]),Mt=(e,n,t,r)=>`M${e.map(([a,s])=>`${(n+a*r).toFixed(2)},${(t+s*r).toFixed(2)}`).join("L")}Z`;var ir="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)"},sr={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: ${rr.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=>kt(v,160,r.seed)),o=r.size[0],u=l(t.size)/100*o,d=u/2,m=l(t.hold),c=l(t.morph),p=l(t.turn),g=P(n.fill,"accent"),f=a.createElementNS(ir,"svg");f.setAttribute("width",String(u*1.3)),f.setAttribute("height",String(u*1.3)),f.setAttribute("viewBox",`${-u*.65} ${-u*.65} ${u*1.3} ${u*1.3}`),f.style.cssText="display:block;overflow:visible";let b=a.createElementNS(ir,"path");g==="outline"?(b.setAttribute("fill","none"),b.setAttribute("stroke","currentColor"),b.setAttribute("stroke-width",String(Math.max(2,u*.02)))):b.setAttribute("fill",Ii[g]??g),f.appendChild(b),e.appendChild(f);let h=r.ease({spring:{duration:.6,bounce:.3}}),y=r.ease("quint.inOut");return{seek(v){let R=se(v,0,.6,h),T=Math.max(0,v-.6),F=m+c,D=Math.min(s.length-1,Math.floor(T/F)),S=0;D<s.length-1?S=se(T-D*F,m,c,y):D=s.length-1;let j=Math.min(s.length-1,D+1),Z=ar(i[D],i[j],S);b.setAttribute("d",Mt(Z,0,0,d*Math.max(0,R))),b.setAttribute("transform",`rotate(${((D+S)*p).toFixed(3)})`)}}}};var Wi=(e,n)=>e.toFixed(n),or={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,be(e.values).length-1)*l(n.stagger)+l(n.grow),build(e,n,t,r){let a=e.ownerDocument,s=be(n.values),i=te(n.labels),o=P(n.highlight),u=Math.max(0,Math.round(l(n.decimals))),d=P(n.suffix),[m,c]=r.size,p=l(t.width)/100*m,g=l(t.height)/100*c,f=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:${g}px;font-variant-numeric:tabular-nums`;let v=a.createElement("div");v.style.cssText=`position:absolute;background:var(--m-border);${f?"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 R=s.map((j,Z)=>{let x=(f?g:p)/h,$=x*(1-y),C=Z*x+x*y/2,A=o!==""&&i[Z]===o,V=a.createElement("div"),B=o===""||A?"var(--m-bg-accent)":"color-mix(in srgb, var(--m-text-primary) 18%, var(--m-bg-base))";V.style.cssText=f?`position:absolute;left:2px;top:${C}px;height:${$}px;width:${Math.abs(j)/b*(p-160)}px;transform-origin:0 50%;border-radius:0 ${$*.12}px ${$*.12}px 0;background:${B}`:`position:absolute;bottom:2px;left:${C}px;width:${$}px;height:${Math.abs(j)/b*(g-70)}px;transform-origin:50% 100%;border-radius:${$*.1}px ${$*.1}px 0 0;background:${B}`;let X=a.createElement("div");X.style.cssText=f?`position:absolute;top:${C+$/2}px;transform:translateY(-50%);font-size:0.62em;font-weight:600;white-space:nowrap`:`position:absolute;left:${C+$/2}px;width:${x}px;margin-left:${-x/2}px;text-align:center;font-size:0.62em;font-weight:600;white-space:nowrap`,A&&(X.style.color="var(--m-accent)");let W=a.createElement("div");W.textContent=i[Z]??"",W.style.cssText=f?`position:absolute;right:calc(100% + 0.8em);top:${C+$/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:${C}px;width:${$}px;text-align:center;font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.append(V,X,W);let M=parseFloat(f?V.style.width:V.style.height);return{bar:V,value:X,label:W,v:j,full:M}}),T=$e(h,l(t.stagger)),F=l(t.grow),D=r.ease("quint.out"),S=r.ease("quart.inOut");return{seek(j){let Z=se(j,0,.5,S);v.style.transform=f?`scaleY(${Z})`:`scaleX(${Z})`,R.forEach((x,$)=>{let C=se(j,.4+T[$],F,D);x.bar.style.transform=f?`scaleX(${C})`:`scaleY(${C})`;let A=j>=.4+T[$]+F?x.v:x.v*C;x.value.textContent=`${Wi(A,u)}${d}`;let V=Math.min(1,Math.max(0,(j-.4-T[$])/.25));x.value.style.opacity=V.toFixed(3),f?x.value.style.left=`${2+x.full*C+12}px`:x.value.style.bottom=`${2+x.full*C+10}px`,x.label.style.opacity=Math.min(1,Math.max(0,(j-T[$]*.5)/.4)).toFixed(3)})}}}};var Ye="http://www.w3.org/2000/svg",lr={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=be(n.values),i=te(n.labels),[o,u]=r.size,d=l(t.width)/100*o,m=l(t.height)/100*u,c=Math.min(...s,0),p=Math.max(...s,1e-9),g=m*.08,f=s.map((B,X)=>[s.length>1?X/(s.length-1)*d:d/2,g+(1-(B-c)/(p-c||1))*(m-g*2)]);e.style.cssText+=`;position:relative;width:${d}px;height:${m}px`;let b=a.createElementNS(Ye,"svg");b.setAttribute("width",String(d)),b.setAttribute("height",String(m)),b.style.cssText="position:absolute;inset:0;overflow:visible";let h=Math.round(l(t.grid)),y=Array.from({length:h},(B,X)=>{let W=a.createElementNS(Ye,"line"),M=m*(X+1)/(h+1);return W.setAttribute("x1","0"),W.setAttribute("x2",String(d)),W.setAttribute("y1",String(M)),W.setAttribute("y2",String(M)),W.setAttribute("stroke","var(--m-border)"),W.setAttribute("stroke-width","1.5"),W.setAttribute("stroke-dasharray","4 8"),b.appendChild(W),W}),v=f.map(([B,X],W)=>`${W?"L":"M"}${B.toFixed(2)},${X.toFixed(2)}`).join(""),R=a.createElementNS(Ye,"path");R.setAttribute("d",`${v}L${d},${m}L0,${m}Z`),R.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 16%, transparent)");let T=a.createElementNS(Ye,"path");T.setAttribute("d",v),T.setAttribute("fill","none"),T.setAttribute("stroke","var(--m-bg-accent)"),T.setAttribute("stroke-width",String(Math.max(3,o*.0028))),T.setAttribute("stroke-linejoin","round"),T.setAttribute("stroke-linecap","round");let F=a.createElementNS(Ye,"circle");F.setAttribute("r",String(o*.0055)),F.setAttribute("fill","var(--m-bg-accent)");let D=a.createElementNS(Ye,"circle");D.setAttribute("fill","color-mix(in srgb, var(--m-bg-accent) 25%, transparent)"),t.area!==!1&&b.appendChild(R),b.append(T,D,F),e.appendChild(b);let S=a.createElement("div"),j=f[f.length-1]??[0,0];S.textContent=`${(s[s.length-1]??0).toFixed(Math.max(0,Math.round(l(n.decimals))))}${P(n.suffix)}`,S.style.cssText=`position:absolute;left:${j[0]}px;top:${j[1]}px;transform:translate(-50%, -150%);font-weight:650;color:var(--m-accent);white-space:nowrap;font-variant-numeric:tabular-nums`,e.appendChild(S);let Z=i.map((B,X)=>{let W=a.createElement("div"),M=i.length===2&&s.length>2?X===0?0:d:f[X]?.[0]??0;return W.textContent=B,W.style.cssText=`position:absolute;top:calc(100% + 0.6em);left:${M}px;transform:translateX(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`,e.appendChild(W),{l:W,x:M}}),x=f.map(B=>B[0]),$=B=>{if(f.length<2)return f[0]??[0,0];let X=1;for(;X<f.length-1&&x[X]<B;)X++;let W=f[X-1],M=f[X],H=M[0]===W[0]?1:Math.min(1,Math.max(0,(B-W[0])/(M[0]-W[0])));return[W[0]+(M[0]-W[0])*H,W[1]+(M[1]-W[1])*H]},C=l(t.draw),A=r.ease("sine.inOut"),V=r.ease("expressive.out");return{seek(B){y.forEach((L,z)=>L.setAttribute("opacity",se(B,z*.05,.4,V).toFixed(3)));let X=se(B,.4,C,A),W=X*d;T.style.clipPath=X>=1?"":`inset(-20px ${(d-W).toFixed(2)}px -20px -20px)`;let[M,H]=$(W),Y=B>=.4;F.setAttribute("cx",M.toFixed(2)),F.setAttribute("cy",H.toFixed(2)),F.setAttribute("opacity",Y?"1":"0");let K=se(B,.4+C,.6,V);D.setAttribute("cx",M.toFixed(2)),D.setAttribute("cy",H.toFixed(2)),D.setAttribute("r",(o*.0055*(1+2.6*K)).toFixed(2)),D.setAttribute("opacity",(K>0?1-K:0).toFixed(3));let k=se(B,.4+C*.6,.6+C*.4,V);R.setAttribute("opacity",k.toFixed(3)),R.style.clipPath=`inset(0 ${(d-W).toFixed(2)}px 0 0)`;let E=se(B,.4+C-.1,.5,V);S.style.opacity=E.toFixed(3),S.style.transform=`translate(-50%, ${(-150+(1-E)*40).toFixed(2)}%)`;for(let{l:L,x:z}of Z)L.style.opacity=Math.min(1,Math.max(0,(W-z+d*.08)/(d*.08))).toFixed(3)}}}};var ur="http://www.w3.org/2000/svg",dr=(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}},mr={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)=>dr(n,!!P(e.name),!!P(e.tagline)).end,build(e,n,t,r){let a=e.ownerDocument,s=P(n.name),i=P(n.tagline),o=P(t.mode),u=dr(t,!!s,!!i);e.style.cssText+=";display:flex;flex-direction:column;align-items:center";let d=a.createElement("div");d.style.cssText=`display:flex;align-items:center;gap:${l(t.gap)}em;white-space:nowrap`;let m=l(t.mark_size),c=a.createElementNS(ur,"svg"),p=P(n.mark_path);c.setAttribute("viewBox",p?P(n.mark_viewbox,"0 0 100 100"):"-1 -1 2 2"),c.style.cssText=`display:block;height:${m}em;width:${m}em;overflow:visible;position:relative;z-index:1;flex:none`;let g=a.createElementNS(ur,"path");g.setAttribute("d",p||Mt(kt(P(n.mark_shape,"squircle"),160,r.seed),0,0,1)),g.setAttribute("fill","var(--m-bg-accent)"),g.setAttribute("pathLength","1"),g.setAttribute("stroke-dasharray","1 1"),g.setAttribute("stroke","var(--m-bg-accent)"),g.setAttribute("stroke-width",p?"2":"0.05"),g.setAttribute("vector-effect","non-scaling-stroke"),c.appendChild(g),d.appendChild(c);let f,b;s&&(b=a.createElement("span"),b.style.cssText="display:block;overflow:hidden;padding:0.12em 0.04em;margin:-0.12em -0.04em",f=a.createElement("span"),f.textContent=s,f.style.cssText="display:block",b.appendChild(f),d.appendChild(b)),e.appendChild(d);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=f?(d.offsetWidth-c.getBoundingClientRect().width/ji(e))/2:0,v=r.ease({spring:{duration:.55,bounce:.32}}),R=r.ease("quint.inOut"),T=r.ease("expressive.out");return{seek(F){let D=se(F,0,u.arrive,o==="pop"?v:T);if(o==="pop")c.style.transform=`scale(${Math.max(0,D).toFixed(4)}) rotate(${((1-D)*-30).toFixed(3)}deg)`,g.setAttribute("stroke-dashoffset","0"),g.setAttribute("fill-opacity","1");else if(o==="draw"){let Z=se(F,0,u.arrive*.8,R),x=se(F,u.arrive*.65,u.arrive*.35,T);g.setAttribute("stroke-dashoffset",(1-Z).toFixed(4)),g.setAttribute("fill-opacity",x.toFixed(3)),c.style.transform=""}else c.style.clipPath=D>=1?"":`circle(${(D*75).toFixed(3)}% at 50% 50%)`,c.style.transform=`scale(${(1.25-.25*D).toFixed(4)})`,g.setAttribute("stroke-dashoffset","0");let S=se(F,u.nameAt,u.slide,R),j=y*(1-S);if(d.style.transform=j===0?"":`translateX(${j.toFixed(2)}px)`,f&&b){let Z=se(F,u.nameAt,u.slide,T);f.style.transform=Z>=1?"":`translateX(${(-(1-Z)*105).toFixed(3)}%)`,b.style.visibility=F<u.nameAt?"hidden":"inherit"}if(h){let Z=se(F,u.tagAt,.7,T);h.style.opacity=Z.toFixed(3),h.style.transform=Z>=1?"":`translateY(${((1-Z)*.6).toFixed(3)}em)`}}}}};function ji(e){let n=e.closest(".m-stage");return!n||!n.offsetWidth?1:n.getBoundingClientRect().width/n.offsetWidth}var Ni=["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)"],cr={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):Ni,u=Math.max(1,Math.round(l(t.fields))),d=Math.max(1,l(t.period)),m=l(t.reach),c=Se(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 g=Array.from({length:u},(f,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(f){let b=f/d*Math.PI*2;for(let h of g){let y=h.hx+Math.cos(b*h.fx+h.ph)*m*s-h.size/2,v=h.hy+Math.sin(b*h.fy+h.ph*1.3)*m*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 lt="http://www.w3.org/2000/svg",Hi=0,pr={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 d=a.createElementNS(lt,"svg");d.setAttribute("width",String(s)),d.setAttribute("height",String(i)),d.style.cssText=`position:absolute;inset:0;opacity:${l(t.amount)};mix-blend-mode:overlay`;let m=`m-grain-${++Hi}`,c=a.createElementNS(lt,"filter");c.setAttribute("id",m),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","100%"),c.setAttribute("height","100%");let p=a.createElementNS(lt,"feTurbulence");p.setAttribute("type","fractalNoise"),p.setAttribute("baseFrequency",String(.9/o*(s/1920))),p.setAttribute("numOctaves","2"),p.setAttribute("stitchTiles","stitch");let g=a.createElementNS(lt,"feColorMatrix");g.setAttribute("type","saturate"),g.setAttribute("values","0"),c.append(p,g);let f=a.createElementNS(lt,"rect");return f.setAttribute("width","100%"),f.setAttribute("height","100%"),f.setAttribute("filter",`url(#${m})`),d.append(c,f),e.appendChild(d),{seek(b){let h=u>0?Math.floor(b*u+1e-6):0;p.setAttribute("seed",String(r.seed*1e3+h))}}}};var hr={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 Ft(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 qi(e,n){let t=e-Math.floor(e),r=.6+.4*Math.exp(-t*n.decay),a=G(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 fr(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 gr={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 d=u.getContext("2d"),m=fr(e,"currentColor"),c=fr(e,"var(--m-accent)"),p=r.beat??Math.max(.05,l(t.period)),g=r.filmStart??0,f=l(t.pitch)*o,b=l(t.dot)*f,h=l(t.paper),y=l(t.glow),v=l(t.glow_radius)*o,R={decay:l(t.decay),ring:l(t.ring),reach:l(t.ring_reach),life:l(t.ring_life)},T=l(t.center_x)/100*s,F=l(t.center_y)/100*i,D=[],S=Math.ceil(T/f)+1,j=Math.ceil(F/f)+1;for(let $=-j;$<=Math.ceil((i-F)/f)+1;$++)for(let C=-S;C<=Math.ceil((s-T)/f)+1;C++){let A=T+C*f,V=F+$*f;D.push([A,V,Math.hypot(A-T,V-F)])}let Z,x=te(n.clear);return{seek($){if(!d)return;if(!Z){let M=x.map(H=>r.boxOf?.(H)).filter(H=>!!H);Z=D.filter(([H,Y])=>!M.some(K=>H>K.x-b&&H<K.x+K.w+b&&Y>K.y-b&&Y<K.y+K.h+b))}Ft(u,d,r.size,r),d.clearRect(0,0,s,i);let{breathe:C,ringR:A,ringA:V}=qi((g+$)/p,R),B=A*o,X=40*o,W=d.createRadialGradient(T,F,0,T,F,v);W.addColorStop(0,`rgba(${c},${(.07*C).toFixed(4)})`),W.addColorStop(.55,`rgba(${c},${(.025*C).toFixed(4)})`),W.addColorStop(1,`rgba(${c},0)`),d.fillStyle=W,d.fillRect(T-v,F-v,v*2,v*2);for(let[M,H,Y]of Z){let K=Y/v,k=K>=1?0:K<.45?1-K/.45*(1-.05/.13):.05/.13*(1-(K-.45)/.55),E=V>0?V*Math.max(0,1-Math.abs(Y-B)/X):0,L=y*C*k+E;d.beginPath(),d.arc(M,H,b,0,Math.PI*2),h>0&&(d.fillStyle=`rgba(${m},${h})`,d.fill()),L>.002&&(d.fillStyle=`rgba(${c},${Math.min(1,L).toFixed(4)})`,d.fill())}}}}};var br=e=>/^data:image\/|\.(png|jpe?g|webp|avif|gif|svg)(\?|#|$)/i.test(e);function Zi(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 Xi(e,n){return e.length<2||!(n>0)?0:G(Math.log2(e[0]/n),0,e.length-1)}function Ui(e,n,t,r,a,s,i){let o=Math.sin(r*Math.PI/180),u=Math.sin(t*Math.PI/180),d=Math.hypot(o,u);if(d<1e-4||i<=0)return"linear-gradient(transparent, transparent)";let m=o/d,c=u/d,p=Math.atan2(m,-c)*180/Math.PI,g=Math.abs(e*m)+Math.abs(n*c),f=((a-e/2)*m+(s-n/2)*c)/g+.5,b=v=>Math.min(1,Math.abs(v-f)*g*d/i),h=[[0,b(0)]],y=i/(g*d);return f-y>0&&h.push([f-y,1]),f>0&&f<1&&h.push([f,0]),f+y<1&&h.push([f+y,1]),h.push([1,b(1)]),`linear-gradient(${p.toFixed(2)}deg, ${h.map(([v,R])=>`rgba(0,0,0,${R.toFixed(3)}) ${(v*100).toFixed(2)}%`).join(", ")})`}function Vi(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 xr={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."}),P(e.focus)&&!P(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,d=r.frames?r.frames.height/r.frames.width:u?u.size[1]/u.size[0]:16/9,m=s*d;e.style.cssText+=";max-width:none";let c=a.createElement("div");c.style.cssText=`position:relative;width:${s}px;height:${m}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",g=0,f=Promise.resolve(),b=o.map(()=>{let W=a.createElement("img");return W.decoding="sync",W.alt="",W.style.cssText=`${p};opacity:0`,c.appendChild(W),W}),h=(W,M)=>{if(W.getAttribute("src")===M)return;W.src=M;let H=++g;f=Promise.all([f,W.decode().catch(()=>{if(!(H!==g||W.complete&&W.naturalWidth>0))return new Promise((Y,K)=>{W.addEventListener("load",()=>Y(),{once:!0}),W.addEventListener("error",()=>K(new Error(`Footage frame did not load: ${M}`)),{once:!0})})})]).then(()=>{})};if(!o.length&&br(P(n.src))){let W=a.createElement("img");W.decoding="sync",W.alt="",W.src=P(n.src),W.style.cssText=p,c.appendChild(W)}let y;!o.length&&!br(P(n.src))&&(y=a.createElement("video"),y.muted=!0,y.playsInline=!0,y.preload="auto",y.src=P(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 R=a.createElement("div");R.style.cssText=`${p};pointer-events:none`;let T=a.createElement("div");T.style.cssText=`${p};pointer-events:none;mix-blend-mode:screen`,c.append(R,T);let F=u?.fps??60,D=u?s/u.size[0]:1,S=(W,M)=>{let H=u?.marks[W]??u?.marks[`#${W}`]??u?.marks[`.${W}`],Y=Zi(H,Math.round(it(M,n,t)*F));return Y?[Y[0]*D,Y[1]*D,Y[2]*D,Y[3]*D]:void 0},j=typeof window<"u"&&window.devicePixelRatio||1,Z=l(t.aperture),x=l(t.depth),$=l(t.shade),C=l(t.sheen),A=l(t.shadow),V=l(t.light),B=P(n.focus),X=o.map(W=>W.width);return{seek(W){let M=r.cameraPose?.()??{scale:1,rotateX:0,rotateY:0},H=it(W,n,t);if(o.length){let E=Xi(X,s*M.scale*j),L=Math.floor(E),z=Math.min(o.length-1,L+1),I=E-L;if(b.forEach((U,Q)=>{let ee=Q===L||Q===z&&I>.001;if(U.style.opacity=ee?Q===L?"1":I.toFixed(3):"0",U.style.zIndex=Q===z&&Q!==L?"1":"0",ee){let ie=o[Q];h(U,Ue(ie,Math.round((H-ie.start)*ie.rate+1e-6)))}}),v){let U=Math.hypot(M.rotateX,M.rotateY);if(Z>0&&U>.05){let Q=o[Math.min(o.length-1,z+1)];h(v,Ue(Q,Math.round((H-Q.start)*Q.rate+1e-6)));let ee=B?S(B,W):void 0,[ie,de]=ee?[ee[0]+ee[2]/2,ee[1]+ee[3]/2]:[s/2,m/2],ce=Ui(s,m,M.rotateX,M.rotateY,ie,de,x);v.style.maskImage=ce,v.style.opacity="1",v.style.zIndex="2"}else v.style.opacity="0"}}else y&&Math.abs(y.currentTime-H)>.5/r.fps&&(y.currentTime=H);let Y=Vi(M.rotateX,M.rotateY,V)*$*2;R.style.background=Y>=0?`rgba(255,255,255,${G(Y*.5).toFixed(3)})`:`rgba(0,0,0,${G(-Y).toFixed(3)})`,R.style.zIndex="3";let K=50+M.rotateY*3-M.rotateX*3;T.style.background=C>0?`linear-gradient(${(V+90).toFixed(0)}deg, transparent ${(K-22).toFixed(1)}%, rgba(255,255,255,${C}) ${K.toFixed(1)}%, transparent ${(K+22).toFixed(1)}%)`:"",T.style.zIndex="4";let k=Math.hypot(M.rotateX,M.rotateY);c.style.boxShadow=A>0?`0 ${(10+k*1.6).toFixed(1)}px ${(30+k*3).toFixed(1)}px rgba(0,0,0,${A})`:"",c.style.overflow="hidden"},pending:()=>f,markAt:S}}};function De(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 Be(e,n){e.parentElement?.querySelectorAll(`:scope > [data-m-overlay^="${n}-"]`).forEach(t=>t.remove())}var Ke=e=>["base","surface","sunken","accent","inverse"].includes(e)?`var(--m-bg-${e})`:e;var yr="cover",wr={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=De(e,yr,s),d=a.ease("quart.inOut"),m=P(r.direction),c=1-i*(s-1);u.forEach((f,b)=>{f.style.background=Ke(te([o[(s-1-b)%o.length]])[0]);let h=G((t-b*i)/c),y=d(G(h*2)),v=d(G(h*2-1)),R=y*100,T=v*100,F=m==="up"?`${100-R}% 0 ${T}% 0`:m==="down"?`${T}% 0 ${100-R}% 0`:m==="left"?`0 ${T}% 0 ${100-R}%`:`0 ${100-R}% 0 ${T}%`;f.style.clipPath=`inset(${F})`,f.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 g=d(G((t-p)/(1-p)));n.style.transform=t>=p?`scale(${(1.04-.04*g).toFixed(4)})`:""},clear(e){Be(e,yr),e.style.transform="",e.style.opacity=""}};var vr="curtain",kr={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]=De(e,vr,2);if(!s||!i)return;let o=a.ease("quint.inOut"),u=o(G(t/.46)),d=o(G((t-.54)/.46)),m=(u-d)*50,c=P(r.axis)!=="horizontal";for(let g of[s,i])g.style.background=Ke(P(r.fill,"inverse"));s.style.clipPath=c?`inset(0 ${100-m}% 0 0)`:`inset(0 0 ${100-m}% 0)`,i.style.clipPath=c?`inset(0 0 0 ${100-m}%)`:`inset(${100-m}% 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*d).toFixed(4)})`:""},clear(e){Be(e,vr),e.style.opacity="",e.style.transform=""}};var Mr={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`,P(r.pace)==="glide"){let f=a.ease("sine.inOut")(t),b=Math.pow(l(r.scale_to),f),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")(G((t-.55)/.35))),n.style.transform=`scale(${(1.12-.12*a.ease("expo.out")(G((t-.5)/.5))).toFixed(4)})`,n.style.filter=h>.05?`blur(${h.toFixed(2)}px)`:"",n.style.opacity=String(a.ease("smooth")(G((t-.5)/.35)));return}let d=a.ease("expo.in"),m=a.ease("expo.out"),c=d(G(t/.55)),p=m(G((t-.45)/.55)),g=1+(l(r.scale_to)-1)*c;e.style.transform=`scale(${g.toFixed(4)})`,e.style.filter=c>.02?`blur(${(c*14).toFixed(2)}px)`:"",e.style.opacity=String(1-G((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(G((t-.45)/.12))},clear(e){e.style.transform="",e.style.transformOrigin="",e.style.filter="",e.style.opacity=""}};var Fr={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,d=l(r.y)/100*o,m=s(t),c=Math.max(Math.hypot(u,d),Math.hypot(i-u,d),Math.hypot(u,o-d),Math.hypot(i-u,o-d)),p=m*c*1.02;if(P(r.shape)==="rounded"){let g=p*.9,f=p*.9;n.style.clipPath=`inset(${(d-f).toFixed(1)}px ${(i-u-g).toFixed(1)}px ${(o-d-f).toFixed(1)}px ${(u-g).toFixed(1)}px round ${(p*.25).toFixed(1)}px)`}else n.style.clipPath=`circle(${p.toFixed(2)}px at ${u.toFixed(1)}px ${d.toFixed(1)}px)`;n.style.transform=`scale(${(1.08-.08*m).toFixed(4)})`,n.style.transformOrigin=`${u}px ${d}px`,e.style.transform=`scale(${(1+l(r.push_in)*m).toFixed(4)})`,e.style.transformOrigin=`${u}px ${d}px`},clear(e){e.style.clipPath="",e.style.transform="",e.style.transformOrigin=""}};var Zt="http://www.w3.org/2000/svg",$r=new WeakMap,Yi=0,Me=(e,n)=>Math.abs(e)*Math.max(0,n)/Math.sqrt(12),Tr=.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<Tr&&s<Tr)return"";let i=$r.get(e);if(!i){let c=e.ownerDocument,p=e.closest(".m-stage")??c.body,g=p.querySelector(":scope > svg.m-filters");g||(g=c.createElementNS(Zt,"svg"),g.setAttribute("class","m-filters"),g.setAttribute("aria-hidden","true"),g.style.cssText="position:absolute;width:0;height:0;overflow:hidden;pointer-events:none",p.appendChild(g));let f=`m-dblur-${++Yi}`,b=c.createElementNS(Zt,"filter");b.setAttribute("id",f),b.setAttribute("color-interpolation-filters","sRGB");let h=c.createElementNS(Zt,"feGaussianBlur");b.appendChild(h),g.appendChild(b),i={id:f,filter:b,blur:h},$r.set(e,i)}let o=Math.max(1,e.offsetWidth),u=Math.max(1,e.offsetHeight),d=3*a/o,m=3*s/u;return i.filter.setAttribute("x",(-d).toFixed(4)),i.filter.setAttribute("y",(-m).toFixed(4)),i.filter.setAttribute("width",(1+2*d).toFixed(4)),i.filter.setAttribute("height",(1+2*m).toFixed(4)),i.blur.setAttribute("stdDeviation",`${a.toFixed(2)} ${s.toFixed(2)}`),`url(#${i.id})`}var Er={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},Sr={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,d]=Er[P(r.direction)]??Er.left,m=s(t),c=u?i:o,p=a.fps||30,g=1/120,f=(s(Math.min(1,t+g))-s(Math.max(0,t-g)))/(2*g)*c/(l(r.duration)*p),b=1-l(r.parallax),h=l(r.blur),y=Me(f,h),v=Me(f*b,h);n.style.transform=`translate(${(-u*(1-m)*i).toFixed(2)}px, ${(-d*(1-m)*o).toFixed(2)}px)`,e.style.transform=`translate(${(u*m*i*b).toFixed(2)}px, ${(d*m*o*b).toFixed(2)}px)`,e.style.filter=[Te(e,u?v:0,d?v:0),`brightness(${(1-.35*m).toFixed(3)})`].filter(Boolean).join(" "),n.style.filter=Te(n,u?y:0,d?y:0)},clear(e){e.style.transform="",e.style.filter=""}};var Cr={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=P(r.direction)!=="right",d=100+o,m=u?100-i*d:i*d-o,c=m+o;n.style.clipPath=u?`polygon(${m}% 0, 100% 0, 100% 100%, ${c}% 100%)`:`polygon(0 0, ${m+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 Ar={up:[0,1],down:[0,-1],left:[1,0],right:[-1,0]},Pr={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,[d,m]=Ar[P(r.direction)]??Ar.up,c=l(r.radius)/100*o,p=Math.min(1,Math.max(0,(t-.75)/.25)),g=c*(1-p*p*(3-2*p));n.style.transform=`translate(${(d*(1-i)*o).toFixed(2)}px, ${(m*(1-i)*u).toFixed(2)}px)`,n.style.borderRadius=g>.5?`${g.toFixed(1)}px`:"";let f=.3*Math.min(1,(1-i)*4);n.style.boxShadow=f>.002?`${(-d*24).toFixed(0)}px ${(-m*24).toFixed(0)}px 90px rgba(0,0,0,${f.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 ut=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Pe(e,n,t={}){let r=e.ownerDocument,a=new Set([...t.accent??[]].map(ut)),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=[],d=[],m=[],c=[];n.split(`
|
|
5
5
|
`).forEach((h,y)=>{y>0&&(e.appendChild(r.createElement("br")),c.push(u.length)),h.split(/\s+/).filter(Boolean).forEach((v,R)=>{R>0&&e.appendChild(r.createTextNode(" "));let T=r.createElement("span");if(T.style.display="inline-block",T.style.whiteSpace="pre",a.has(ut(v))&&(T.style.color="var(--m-accent)"),t.chars)for(let F of[...v]){let D=r.createElement("span");D.textContent=F,D.style.display="inline-block",T.appendChild(D),d.push(D),m.push(u.length)}else T.textContent=v;e.appendChild(T),u.push(T)})});let p=[],g=-1,f=-1/0;u.forEach((h,y)=>{let v=h.offsetTop;(c.includes(y)||v>f+1)&&(g++,f=v),p.push(g)}),e.textContent="",e.style.display="flex",e.style.flexDirection="column";let b=[];return u.forEach((h,y)=>{let v=p[y],R=b[v];if(R)R.appendChild(r.createTextNode(" "));else{if(R=r.createElement("span"),R.style.display="block",s==="line"){let T=r.createElement("span");T.style.cssText=o("block"),T.appendChild(R),e.appendChild(T)}else e.appendChild(R);b[v]=R}if(s==="word"){let T=r.createElement("span");T.style.cssText=o("inline-block","vertical-align:top;"),T.appendChild(h),R.appendChild(T)}else R.appendChild(h)}),{lines:b,words:u,chars:d,wordLine:p,charWord:m}}var Xt=e=>e.split(/\s+/).filter(Boolean).length,zr=e=>[...e.replace(/\s+/g,"")].length,Ge=e=>Math.max(1,e.split(`
|
|
6
6
|
`).filter(n=>n.trim()).length);var Ki={accent:"var(--m-bg-accent)",inverse:"var(--m-bg-inverse)",primary:"var(--m-text-primary)"},Rr={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)=>(Ge(P(e.text))-1)*l(n.stagger)+l(n.duration)*2.35,build(e,n,t,r){let a=e.ownerDocument,{lines:s}=Pe(e,P(n.text),{accent:te(n.accent)}),i=P(t.direction)!=="left",o=Ki[P(n.fill,"accent")]??P(n.fill,"accent"),u=s.map(f=>{f.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";f.firstChild;)h.appendChild(f.firstChild);return f.append(h,b),{block:b,words:h}}),d=(Ge(P(n.text))-1)*l(t.stagger),m=$e(u.length,u.length>1?Math.min(l(t.stagger),d/(u.length-1)):0),c=l(t.duration),p=r.ease("expo.inOut"),g=r.ease("snap.out");return{seek(f){u.forEach(({block:b,words:h},y)=>{let v=se(f,m[y],c,p),R=se(f,m[y]+c,c,p);b.style.transformOrigin=R>0?i?"100% 50%":"0% 50%":i?"0% 50%":"100% 50%",b.style.transform=`scaleX(${(R>0?1-R:v).toFixed(4)})`;let T=se(f,m[y]+c*1.35,c,g),F=f>=m[y]+c;h.style.visibility=F?"inherit":"hidden",h.style.transform=T>=1?"":`translateX(${((i?-1:1)*(1-T)*.6).toFixed(4)}em)`,h.style.opacity=F?Math.min(1,.4+T).toFixed(3):"0"})}}}};var Lr={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:Ve,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)=>Oe(zr(P(e.text)),P(n.from),t.seed)*l(n.stagger)+l(n.char_duration),build(e,n,t,r){let{chars:a}=Pe(e,P(n.text),{chars:!0,accent:te(n.accent)}),s=$e(a.length,l(t.stagger),P(t.from),r.seed),i=r.ease(r.tokens.ease_enter),o=l(t.char_duration),u=l(t.rise),d=l(t.rotate),m=l(t.scale),c=l(t.blur);for(let p of a)p.style.transformOrigin="50% 70%";return{seek(p){a.forEach((g,f)=>{let b=se(p,s[f],o,i),h=Math.min(1,Math.max(0,(p-s[f])/(o*.45))),y=1-b;g.style.opacity=h>=1?"":String(h),g.style.transform=y===0?"":`translateY(${(y*u).toFixed(4)}em) rotate(${(y*d).toFixed(3)}deg) scale(${(m+(1-m)*b).toFixed(4)})`;let v=Math.max(0,y)*c;g.style.filter=v>.05?`blur(${v.toFixed(2)}px)`:""})}}}};var Or={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),d=r.tokens.duration.slow+.4,m=r.ease("expressive.out");e.style.display="grid";let c=f=>{let b=a.createElement("span");return b.textContent=P(n.text),b.style.cssText="grid-area:1/1;white-space:pre-line",f&&(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(f=>e.appendChild(f)),p.reverse();let g=c(!1);return e.appendChild(g),{seek(f){let b=se(f,s*i,d,m);g.style.transform=b>=1?"":`translateY(${((1-b)*o).toFixed(4)}em)`,g.style.opacity=String(Math.min(1,Math.max(0,(f-s*i)/(d*.3)))),p.forEach((h,y)=>{let v=s-1-y,R=se(f,v*i,d,m),T=(y+1)*u;h.style.transform=`translateY(${(T+(1-R)*o).toFixed(4)}em)`;let F=Math.min(1,Math.max(0,(f-v*i)/(d*.25))),D=1-(y+1)/(s+1),S=u===0?1-se(f,s*i+d*.6,d*.4,j=>j):1;h.style.opacity=(F*D*S).toFixed(3)})}}}};var Dr=(e,n,t)=>{let r=P(e.text);return n.unit==="word"?Oe(Xt(r),P(n.from),t):Oe(Ge(r),P(n.from),t)+(Ge(r)>1||Xt(r)>3?1:0)},Br={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:Ve,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)=>Dr(e,n,t.seed)*l(n.stagger)+l(n.duration),build(e,n,t,r){let a=t.unit==="word",s=Pe(e,P(n.text),{mask:a?"word":"line",accent:te(n.accent),feather:l(t.feather)}),i=a?s.words:s.lines,o=Oe(i.length,P(t.from),r.seed),u=Dr(n,t,r.seed),d=o>u&&o>0?l(t.stagger)*u/o:l(t.stagger),m=$e(i.length,d,P(t.from),r.seed),c=r.ease(t.ease),p=l(t.duration),g=l(t.tilt),f=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 R=1-se(b,m[y],p,c);h.style.transform=R===0?"":`translateY(${f>0?`calc(${(R*110).toFixed(3)}% + ${(R*f).toFixed(4)}em)`:`${(R*110).toFixed(3)}%`}) rotate(${(R*g).toFixed(3)}deg)`})}}}};var Ir="http://www.w3.org/2000/svg";function Gi(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,d=t*.72,m=[];for(let c=0;c<=28;c++){let p=-Math.PI*.62+c/28*Math.PI*2.18,g=1+a(.06);m.push(`${(i+Math.cos(p)*u*g).toFixed(1)},${(o+Math.sin(p)*d*g+c/28*t*.08).toFixed(1)}`)}return`M${m.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 Wr={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(ut)),{words:s}=Pe(e,P(n.text));e.style.position="relative";let i=s.filter(j=>a.has(ut(j.textContent??"")));if(!i.length)return{seek(){}};let o=i[0],u=i[i.length-1],d=e.getBoundingClientRect(),m=o.getBoundingClientRect(),c=u.getBoundingClientRect(),p=e.offsetWidth>0?d.width/e.offsetWidth:1,g=(m.left-d.left)/p,f=(m.top-d.top)/p,b=(c.right-m.left)/p,h=m.height/p,y=P(t.kind),v=parseFloat(getComputedStyle(e).fontSize)||16,R=e.ownerDocument.createElementNS(Ir,"svg");R.setAttribute("width",String(b)),R.setAttribute("height",String(h)),R.style.cssText=`position:absolute;left:${g}px;top:${f}px;overflow:visible;pointer-events:none;${y==="marker"?"z-index:-1;mix-blend-mode:multiply":""}`;let T=e.ownerDocument.createElementNS(Ir,"path");T.setAttribute("d",Gi(y,b,h,Se(r.seed*31+b))),T.setAttribute("fill","none"),T.setAttribute("stroke",y==="marker"?"color-mix(in srgb, var(--m-accent) 45%, transparent)":"var(--m-accent)"),T.setAttribute("stroke-width",String(l(t.weight)*v*(y==="marker"?4.4:1))),T.setAttribute("stroke-linecap","round"),T.setAttribute("stroke-linejoin","round"),T.setAttribute("pathLength","1"),T.setAttribute("stroke-dasharray","1 1"),R.appendChild(T),e.style.isolation="isolate",e.appendChild(R);let F=r.ease("quart.inOut"),D=l(t.delay),S=l(t.duration);return{seek(j){let Z=se(j,D,S,F);T.setAttribute("stroke-dashoffset",(1-Z).toFixed(4)),R.style.visibility=Z<=0?"hidden":"inherit"}}}};var jr={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=P(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(d){let m=(d%i+i)%i/i,c=u(Math.min(1,m/.7));a.style.backgroundPosition=`${(100-c*100).toFixed(3)}% 0`}}}};var Nr={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=P(n.text),u.style.cssText="display:inline-block;white-space:pre-line",e.appendChild(u);let d=parseFloat(getComputedStyle(e).letterSpacing)||0,m=parseFloat(getComputedStyle(e).fontSize)||16;return{seek(c){let p=se(c,0,s,a),g=Math.min(1,c/(s*.5)),f=(1-p)*i;u.style.letterSpacing=`${(d/m+f).toFixed(4)}em`,u.style.marginRight=`${(-f).toFixed(4)}em`,u.style.opacity=g>=1?"":String(Math.max(0,g));let b=(1-p)*o;u.style.filter=b>.05?`blur(${b.toFixed(2)}px)`:""}}}};var Hr={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,d=r.ease("quint.inOut"),m=t.style==="lift",c=r.ease("cubic.inOut"),p=Math.min(l(t.gap),o*.5),g=(o-p)/2;e.style.whiteSpace="nowrap";let f=a.createElement("span"),b=a.createElement("span");f.textContent=P(n.before)?`${P(n.before)} `:"",b.textContent=P(n.after)?` ${P(n.after)}`:"";let h=a.createElement("span");h.style.cssText=`display:inline-block;position:relative;overflow:${m?"visible":"hidden"};vertical-align:bottom;padding:0.14em 0;margin:-0.14em 0;color:var(--m-accent)`;let y=s.map(T=>{let F=a.createElement("span");return F.textContent=T,F.style.cssText="position:absolute;left:0;top:0.14em;white-space:pre",h.appendChild(F),F}),v=a.createElement("span");v.style.cssText="visibility:hidden;white-space:pre",v.textContent=s.reduce((T,F)=>F.length>T.length?F:T,""),h.appendChild(v),e.append(f,h,b);let R=y.map(T=>T.offsetWidth);return v.style.display="inline-block",v.style.width="0px",{seek(T){let F=Math.max(0,Math.min(s.length-1,Math.floor(T/i+1e-9))),D=F===0?1:se(T-F*i,0,o,d);if(m){let j=T-F*i,Z=F===0?1:se(j,0,g,c),x=F===0?1:se(j,g+p,g,c);y.forEach((C,A)=>{let V=A===F?1-x:A===F-1?-Z:1,B=A===F?x:A===F-1?1-Z:0;C.style.visibility=B<=0?"hidden":"inherit",C.style.opacity=B>=1?"":B.toFixed(4),C.style.transform=V===0?"":`translateY(${(u*V*8).toFixed(3)}px)`,C.style.filter=V===0?"":`blur(${(Math.abs(V)*2).toFixed(3)}px)`});let $=F===0?R[0]:R[F-1]+(R[F]-R[F-1])*D;h.style.width=`${$.toFixed(2)}px`;return}y.forEach((j,Z)=>{let x=Z===F?1-D:Z===F-1?-D:1;j.style.transform=x===0?"":`translateY(${(u*x*110).toFixed(3)}%)`,j.style.visibility=Math.abs(x)>=1?"hidden":"inherit"});let S=F===0?R[0]:R[F-1]+(R[F]-R[F-1])*D;h.style.width=`${S.toFixed(2)}px`}}}};var Ji="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",qr=e=>$t(e).at+$t(e).press;function $t(e){let n=l(e.travel),t=.08;return{travel:n,press:t,at:n+.06,end:n+.06+t*2+.55}}var Zr={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)=>$t(n).end,build(e,n,t,r){let a=e.ownerDocument,[s,i]=r.size,o=$t(t),u=l(t.from_x)/100*s,d=l(t.from_y)/100*i,m=l(t.to_x)/100*s,c=l(t.to_y)/100*i,p=Math.hypot(m-u,c-d),g=l(t.arc)*p,f=(u+m)/2-(c-d)/(p||1)*g,b=(d+c)/2+(m-u)/(p||1)*g,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:${m}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="${Ji}" fill="var(--m-text-primary)" stroke="var(--m-bg-base)" stroke-width="1.5" stroke-linejoin="round"/></svg>`,P(n.label)){let D=a.createElement("span");D.textContent=P(n.label),D.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(D)}let R=!P(n.target);e.append(...R?[y]:[],v);let T=r.ease([.45,0,.15,1]),F=r.ease("expressive.out");return{seek(D){let S=se(D,0,o.travel,T),j=(1-S)*(1-S)*u+2*(1-S)*S*f+S*S*m,Z=(1-S)*(1-S)*d+2*(1-S)*S*b+S*S*c,x=se(D,o.at,o.press,V=>V),$=se(D,o.at+o.press,o.press*1.5,F),C=1-.14*(x-$);v.style.transform=`translate(${(j-h*.08).toFixed(2)}px, ${(Z-h*.06).toFixed(2)}px) scale(${C.toFixed(4)})`,v.style.opacity=Math.min(1,D/.15).toFixed(3);let A=se(D,o.at+o.press,.55,F);y.style.opacity=A>0?(.9*(1-A)).toFixed(3):"0",y.style.transform=`scale(${(.3+A*1.1).toFixed(4)})`}}}};var Qi=e=>1+2.4*(e-1)**3+1.4*(e-1)**2,Xr=e=>Math.floor(be(e.points).length/2),Ur={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,Xr(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=be(n.points),d=te(n.labels),m=l(t.size)*o,c=l(t.glow),p=l(t.stem)*o,g=(R,T)=>{let F=a.createElement("div");return F.style.cssText=T,R.appendChild(F),F},f=Array.from({length:Xr(n)},(R,T)=>{let F=u[T*2]/100*s,D=u[T*2+1]/100*i,S=`position:absolute;left:${F}px;top:${D}px;`,j=g(e,`${S}width:${m*6}px;height:${m*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)`),Z=g(e,`${S}width:${m*2.5}px;height:${m*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=g(e,`${S}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))`),$=g(e,`${S}width:${m}px;height:${m}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)`),C=d[T]??"",A=C?g(e,`${S}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(A){g(A,`flex:none;width:${m*.7}px;height:${m*.7}px;border-radius:50%;background:var(--m-accent)`);let V=a.createElement("span");V.textContent=C,A.appendChild(V)}return{y:D,halo:j,ring:Z,stem:x,dot:$,card:A}}),b=l(t.stagger),h=l(t.ripple),y=r.ease("expo.out"),v=r.ease("smooth");return{seek(R){let T=Math.max(0,R)/h%1;f.forEach((F,D)=>{let S=D*b,j=G((R-S)/.42),Z=G((R-S)/.14),x=y(G((R-S-.14)/.81));if(F.dot.style.opacity=Z.toFixed(3),F.dot.style.scale=String(Math.max(0,j<1?Qi(j):1).toFixed(4)),F.halo.style.opacity=Z.toFixed(3),F.halo.style.scale=ke(.5,1,y(j)).toFixed(4),F.ring.style.opacity=((1-T)**1.4*G((R-S-.1)/.3)).toFixed(3),F.ring.style.scale=(.3+T*1.25).toFixed(4),!F.card){F.stem.style.height="0px";return}let $=p*ke(.3,1,x),C=m*.5+5*o,A=Math.max(0,$-C);F.stem.style.top=`${F.y-$}px`,F.stem.style.height=`${A}px`;let V=v(G((R-S-.2)/.35));F.stem.style.opacity=V.toFixed(3),F.card.style.top=`${F.y-$}px`,F.card.style.scale=ke(.84,1,x).toFixed(4),F.card.style.opacity=V.toFixed(3)})}}}};var _i=["in","out","in-out","hold"];function Je(e){return{path:{type:"choice",default:e.path,options:_i,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 He(e){let n=P(e.path),t=l(e.move);return n==="hold"?0:n==="in-out"?2*t+l(e.hold):t}function es(e,n,t){let r=P(n.path),a=Math.max(.01,l(n.move));return r==="hold"?1:r==="out"?1-t(G(e/a)):r==="in-out"?e<a?t(G(e/a)):e<a+l(n.hold)?1:1-t(G((e-a-l(n.hold))/a)):t(G(e/a))}function Qe(e,n,t){let r=es(e,n,t),a=l(n.tilt),s=l(n.pitch),i={rx:s*r,ry:a*r,rz:l(n.roll)*r,zoom:ke(1,l(n.zoom),r),x:l(n.pan_x)/100*r,y:l(n.pan_y)/100*r},o=Math.max(0,e-He(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 _e(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 Ie=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`;function ts(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,d,m=999)=>r(`left:${s}%;top:${i}%;width:${o}%;height:${u}%;border-radius:${m}px;background:${Ie(d)}`);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 ${Ie(8)}`),u=(m,c,p)=>{let g=t.createElement("div");g.style.cssText=`position:absolute;left:9%;top:${m}%;width:${c}%;height:6%;border-radius:999px;background:${Ie(p)}`,o.appendChild(g)};u(64,70,30),u(76,46,16);let d=t.createElement("div");d.style.cssText=`position:absolute;left:9%;top:12%;width:14%;aspect-ratio:1;border-radius:50%;background:${s===36?"var(--m-accent)":Ie(20)}`,o.appendChild(d)})}var Vr={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)"},...Je({path:"in",tilt:-24,pitch:10,roll:-2.4,zoom:.92,move:1})},duration:(e,n)=>Math.max(He(n),be(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))),d=o*l(t.aspect),m=d+u,c=16*i,p=o*2.2,g=P(n.src),f=a.createElement("div");f.style.cssText=`position:relative;width:${o}px;height:${m}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 ${Ie(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 ${Ie(6)}`;for(let C=0;C<3;C++){let A=a.createElement("i");A.style.cssText=`display:block;width:${11*i}px;height:${11*i}px;border-radius:50%;background:${Ie(16)}`,y.appendChild(A)}let v=a.createElement("b");v.textContent=P(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:${Ie(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 R=C=>{if(g){let A=a.createElement("img");A.src=g,A.alt="",A.decoding="sync",A.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:top",C.appendChild(A)}else ts(C,12*i)},T=a.createElement("div");T.style.cssText=`position:absolute;left:0;top:${u}px;width:${o}px;height:${d}px;overflow:hidden`,R(T);let F=a.createElement("div");F.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,T);let D=be(n.lift),S;if(D.length===4){let[C,A,V,B]=[D[0]/100*o,D[1]/100*d,D[2]/100*o,D[3]/100*d],X=a.createElement("div");X.style.cssText=`position:absolute;left:${C}px;top:${A+u}px;width:${V}px;height:${B}px;border-radius:${12*i}px;background:#000;opacity:0;filter:blur(${14*i}px)`,h.appendChild(X);let W=a.createElement("div");W.style.cssText=`position:absolute;left:${C}px;top:${A+u}px;width:${V}px;height:${B}px;overflow:hidden;border-radius:${12*i}px;transform-origin:50% 50%;visibility:hidden`;let M=a.createElement("div");M.style.cssText=`position:absolute;left:${-C}px;top:${-A}px;width:${o}px;height:${d}px`,R(M),W.appendChild(M),S={box:W,dim:X}}h.appendChild(F),b.appendChild(h),S&&b.appendChild(S.box),f.appendChild(b),e.appendChild(f);let j=r.ease(t.ease),Z=r.ease("expo.out"),x=l(t.lift)*i,$=l(t.lift_at);return{seek(C){if(b.style.transform=_e(Qe(C,t,j),p,o,m),!S)return;let A=Z(G((C-$)/.8)),V=x*A,B=G(V/(140*i));S.box.style.visibility=A>0?"inherit":"hidden",S.box.style.transform=`translateZ(${V.toFixed(2)}px) scale(${(1+.04*A).toFixed(4)})`,S.box.style.boxShadow=`0 0 0 1px rgba(255,255,255,${(.08*B).toFixed(3)}),0 ${40*i*B}px ${90*i*B}px rgba(0,0,0,${(.6*B).toFixed(3)}),0 ${12*i*B}px ${28*i*B}px rgba(0,0,0,${(.35*B).toFixed(3)})`,S.dim.style.opacity=(.3*A).toFixed(3)}}}};var qe=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`,et=e=>{let n=G(e);return n*n*(3-2*n)},dt=e=>e*Math.PI/180,Gr=["close","open","open-close"],ns=["solid","wire"];function Yr(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 rs(e,n,t,r=a=>a){let a=Math.max(.01,t.travel),s=u=>Array.from({length:e},(d,m)=>m===0?0:r(G((n-u-(e-1-m)*t.stagger)/a))),i=u=>Array.from({length:e},(d,m)=>m===0?0:1-r(G((n-u-(m-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 as([e,n,t],r){let a=(i,o,u)=>{let d=dt(u),m=Math.cos(d),c=Math.sin(d);return[i*m-o*c,i*c+o*m]};[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 Kr=e=>({order:Gr.includes(P(e.order))?P(e.order):"close",start:l(e.start),travel:l(e.travel),stagger:l(e.stagger),apart:l(e.apart)}),Jr={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:Gr,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:ns,label:"Solid surfaces with shadows, or a wire drawing with guides and numbered labels"},...Je({path:"hold",tilt:0,pitch:0,roll:0,zoom:1,move:1.6})},duration:(e,n)=>{let t=te(e.items).length,r=Kr(n);return Math.max(He(n),Yr(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),d=o.length,m=Kr(t),c=l(t.width)/100*s,p=c*l(t.aspect),g=l(t.gap)*i,f=l(t.radius)*i,b=l(t.lay),h=l(t.turn),y=l(t.spin),v=dt(h),R=Math.cos(dt(b)),T=Math.sin(dt(b)),F=Math.abs(c*Math.cos(v))+Math.abs(p*Math.sin(v)),D=(Math.abs(c*Math.sin(v))+Math.abs(p*Math.cos(v)))*R+(d-1)*g*T,S=Math.max(F,D)*l(t.lens),j=P(t.look)==="wire",Z=-((d-1)*g)/2,x=a.createElement("div");x.style.cssText=`position:relative;width:${F}px;height:${D}px;perspective:${S>0?`${S}px`:"none"}`;let $=a.createElement("div");$.style.cssText=`position:absolute;left:${(F-c)/2}px;top:${(D-p)/2}px;width:${c}px;height:${p}px;transform-style:preserve-3d;transform-origin:50% 50%`;let C=a.createElement("div");C.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%",$.appendChild(C);let A=a.createElement("div");A.style.cssText="position:absolute;inset:0";let V="var(--m-font-body)",B=(z,I,U,Q="")=>{let ee=a.createElement("div");ee.style.cssText=`position:absolute;left:0;top:0;transform-origin:0 0;display:flex;align-items:center;gap:${12*i}px;white-space:nowrap;`+(j?`font:500 ${21*i}px/1 var(--m-font-mono);letter-spacing:0.06em;text-transform:uppercase;color:${I}`:`font:500 ${27*i}px/1 ${V};letter-spacing:-0.01em;color:${I}`);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 de=a.createElement("i");de.style.cssText=j?`display:block;flex:none;width:${44*i}px;height:0;border-top:${1.5*i}px dotted ${qe(45)}`:`display:block;flex:none;width:${34*i}px;height:${1.5*i}px;background:${qe(22)}`;let ce=a.createElement("span");if(ce.textContent=z,ee.append(ie,de),Q){let w=a.createElement("span");w.textContent=Q,w.style.color=qe(45),ee.appendChild(w)}ee.appendChild(ce);let pe=a.createElement("div");return pe.style.cssText="position:absolute;left:0;top:0;transform-origin:0 0",ee.style.transform="translateY(-50%)",pe.appendChild(ee),A.appendChild(pe),pe},X=a.createElement("div");X.style.cssText=`position:absolute;inset:0;border-radius:${f}px;box-shadow:0 0 0 ${2*i}px var(--m-accent);visibility:hidden`,C.appendChild(X);let W=o.map((z,I)=>{let U=a.createElement("div");if(U.style.cssText=`position:absolute;inset:0;border-radius:${f}px;overflow:hidden;background:color-mix(in srgb, var(${j?"--m-bg-base":"--m-bg-surface"}) ${j?86:92}%, transparent)`,u[I]){let ee=a.createElement("img");ee.src=u[I],ee.alt=z,ee.decoding="sync",ee.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block",U.appendChild(ee)}let Q=a.createElement("div");return Q.style.cssText=`position:absolute;inset:0;border-radius:inherit;background:color-mix(in srgb, var(--m-accent) ${j?20:16}%, transparent);box-shadow:inset 0 0 0 ${2*i}px var(--m-accent)${j?"":`, inset 0 0 ${90*i}px color-mix(in srgb, var(--m-accent) 30%, transparent)`};opacity:0`,U.appendChild(Q),C.appendChild(U),{plane:U,lit:Q,tag:B(z,"var(--m-text-secondary)",qe(j?80:55),j?String(I+1).padStart(2,"0"):"")}}),M=P(n.name)?B(P(n.name),"var(--m-text-primary)","var(--m-accent)"):null;M&&(M.firstElementChild.style.fontWeight="600");let H="http://www.w3.org/2000/svg",Y=j?[0,1,2].map(()=>{let z=A.querySelector("svg")??A.insertBefore(a.createElementNS(H,"svg"),A.firstChild);z.setAttribute("width",String(F)),z.setAttribute("height",String(D)),z.style.cssText="position:absolute;left:0;top:0;overflow:visible";let I=a.createElementNS(H,"line");return I.setAttribute("stroke",qe(55)),I.setAttribute("stroke-width",String(1.5*i)),I.setAttribute("stroke-dasharray",`${1.5*i} ${7*i}`),I.setAttribute("stroke-linecap","round"),z.appendChild(I),I}):[];x.append($,A),e.appendChild(x);let K=r.ease(t.ease),k=r.ease("quint.inOut"),E=r.ease("expo.out"),L=Yr(d,m);return{seek(z){let I=Qe(z,t,K);$.style.transform=_e(I,S,c,p);let U=h+y*z;C.style.transform=`rotateX(${b.toFixed(3)}deg) rotateZ(${U.toFixed(3)}deg)`;let Q=(re,ne,oe)=>{let[le,ue]=as([re-c/2,ne-p/2,oe],{lay:b,turn:U,cam:I,P:S,w:c,h:p});return[F/2+le,D/2+ue]},ee=(re,ne,oe)=>{let[le,ue]=Q(re,ne,oe);return`translate(${le.toFixed(2)}px, ${ue.toFixed(2)}px)`},ie=dt(U),de=Math.cos(ie),ce=Math.sin(ie),pe=c,w=p,O=-1/0;for(let[re,ne]of[[0,0],[c,0],[c,p],[0,p]]){let oe=(re-c/2)*de-(ne-p/2)*ce;oe>O&&(O=oe,pe=re,w=ne)}let J=rs(d,z,m,k),N=J[d-1]??0,_=1-N;if(W.forEach((re,ne)=>{let oe=J[ne],le=Z+ne*g*oe;re.plane.style.transform=`translateZ(${le.toFixed(2)}px)`;let ue=ne===0?1:G(oe*ne-(J[ne-1]??0)*(ne-1));re.plane.style.boxShadow=j?`inset 0 0 0 ${1.5*i}px ${qe(ne===0?85:62)}`:`0 0 0 ${1.5*i}px ${qe(ne===0?14:10+8*ue)},0 0 ${70*i*ue}px rgba(0,0,0,${(.38*ue).toFixed(3)})`,re.plane.style.opacity=ne===0||ne===d-1?"1":et(oe/.25).toFixed(3),re.lit.style.opacity=ne===d-1?et((_-.55)/.45).toFixed(3):"0",re.tag.style.transform=ee(pe,w,le),re.tag.style.opacity=et(ne===0?N/.3:(oe-.15)/.35).toFixed(3)}),M&&(M.style.transform=ee(pe,w,Z),M.style.opacity=et((_-.7)/.3).toFixed(3)),Y.length){let re=[[0,0],[c,0],[c,p],[0,p]].map(([oe,le])=>({a:Q(oe,le,Z),b:Q(oe,le,Z+(d-1)*g*N)})),ne=re.reduce((oe,le,ue)=>le.a[1]<re[oe].a[1]?ue:oe,0);re.filter((oe,le)=>le!==ne).forEach((oe,le)=>{let ue=Y[le];ue.setAttribute("x1",oe.a[0].toFixed(2)),ue.setAttribute("y1",oe.a[1].toFixed(2)),ue.setAttribute("x2",oe.b[0].toFixed(2)),ue.setAttribute("y2",oe.b[1].toFixed(2)),ue.setAttribute("opacity",et(N/.3).toFixed(3))})}let q=m.order==="open"?0:G((z-L+.12)/.9);X.style.visibility=q>0&&q<1?"inherit":"hidden",X.style.transform=`translateZ(${Z.toFixed(2)}px) scale(${(1+.32*E(q)).toFixed(4)})`,X.style.opacity=((1-q)*(1-q)*.9).toFixed(3)}}}};var mt=e=>`color-mix(in srgb, var(--m-text-primary) ${e}%, transparent)`,is=e=>(1-Math.cos(Math.PI*G(e)))/2;function Qr(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 ss(e,n){return Array.from({length:e},(t,r)=>Math.max(0,1-Math.abs(n-r)))}var _r={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"},...Je({path:"out",tilt:-19,pitch:13,roll:-1.5,zoom:.9,move:1.6})},duration:(e,n)=>{let[t,r]=Qr(e);return Math.max(He(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),d=o.length,[m,c]=Qr(n),p=l(t.width)/100*s,g=18*i,f=12*i,b=78*i,h=b+118*i,y=14*i,v=d*b+(d>0?h-b:0)+Math.max(0,d-1)*f+2*g,R=Math.max(p,v)*2.4,T=a.createElement("div");T.style.cssText=`position:relative;width:${p}px;height:${v}px;perspective:${R}px;text-align:left`;let F=a.createElement("div");F.style.cssText="position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%";let D=a.createElement("div");D.style.cssText=`position:absolute;inset:0;border-radius:${y+g}px;background:var(--m-bg-sunken);box-shadow:0 0 0 1px ${mt(9)},0 ${60*i}px ${120*i}px rgba(0,0,0,.55)`,F.appendChild(D);let S="var(--m-font-body)",j=o.map((B,X)=>{let W=a.createElement("div");W.style.cssText=`position:absolute;left:${g}px;width:${p-2*g}px;overflow:hidden;border-radius:${y}px;background:var(--m-bg-surface)`;let M=(I,U)=>{let Q=a.createElement("div");Q.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 ${S};color:${I};white-space:nowrap`;let ee=a.createElement("i");ee.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=B,ie.style.flex="1",Q.append(ee,ie),Q},H=M("var(--m-text-muted)",mt(22)),Y=a.createElement("span");Y.textContent="+",Y.style.cssText=`font-size:${28*i}px;color:${mt(40)}`,H.appendChild(Y);let K=a.createElement("div");K.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 k=M("var(--m-text-primary)","var(--m-accent)");k.firstElementChild.style.boxShadow=`0 0 ${10*i}px color-mix(in srgb, var(--m-accent) 60%, transparent)`;let E=a.createElement("p");E.textContent=u[X]??"",E.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 ${S};color:var(--m-text-secondary)`;let L=a.createElement("div");L.style.cssText=`position:absolute;left:${24*i}px;right:${24*i}px;bottom:${16*i}px;height:${2*i}px;border-radius:9px;background:${mt(10)};overflow:hidden`;let z=a.createElement("div");return z.style.cssText="height:100%;width:100%;background:var(--m-accent);transform-origin:0 50%",L.appendChild(z),K.append(k,E,L),W.append(H,K),F.appendChild(W),{card:W,open:K,fill:z}});T.appendChild(F),e.appendChild(T);let Z=r.ease(t.ease),x=r.ease("expo.out"),$=l(t.stack)*i,C=l(t.pop)*i,A=l(t.slide_at),V=Math.max(.01,l(t.slide));return{seek(B){F.style.transform=_e(Qe(B,t,Z),R,p,v);let X=is((B-A)/V),W=m===c?m:ke(m,c,X),M=ss(d,W),H=m===c?0:x(G((B-A-V)/.7)),Y=g;j.forEach((K,k)=>{let E=M[k],L=ke(b,h,E),z=$*(k+1)+(k===c?C*H:0);K.card.style.top=`${Y.toFixed(2)}px`,K.card.style.height=`${L.toFixed(2)}px`,K.card.style.transform=`translateZ(${z.toFixed(2)}px)`;let I=G(($+(k===c?C*H:0))/(60*i));K.card.style.boxShadow=`0 0 0 1px ${mt(8)},0 ${18*i*I}px ${40*i*I}px rgba(0,0,0,${(.45*I).toFixed(3)})`;let U=G(E/.2);K.open.style.opacity=(U*U*(3-2*U)).toFixed(3),K.open.style.visibility=E>0?"inherit":"hidden",K.fill.style.transform=`scaleX(${E.toFixed(4)})`,Y+=L+f})}}}};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},ea=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2;function ta(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 na=e=>(e.match(/[\d.]+/g)?.slice(0,3)??["255","255","255"]).join(","),ra={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 d=a.createElement("canvas");d.style.cssText=`position:absolute;left:0;top:0;width:${s}px;height:${i}px`,e.appendChild(d);let m=d.getContext("2d"),c=na(ta(e,"currentColor")),p=na(ta(e,"var(--m-accent)")),g=Math.max(2,Math.round(l(t.cols))),f=Math.max(2,Math.round(g*i/s)),b=g*f,h=Math.round(b*1.6),y=r.seed*7919,v=Math.hypot(s/2,i/2),R=l(t.accent),T=Array.from({length:h},(x,$)=>{let C=$%b,A=$+y,V=(C%g+.5)*(s/g),B=(Math.floor(C/g)+.5)*(i/f);return{x:Ee(A,1)*s,y:Ee(A,2)*i,vx:(Ee(A,3)-.5)*40*o,vy:(Ee(A,4)-.5)*24*o,gx:V,gy:B,d:Math.hypot(V-s/2,B-i/2)/v,r:(.7+Ee(A,5)*1.5)*o,a:.18+Ee(A,6)*.5,hot:Ee(A,7)<R}}),F=l(t.settle_at),D=Math.max(.01,l(t.settle)),S=l(t.jitter)*o,j=l(t.glitch),Z=l(t.pulse);return{seek(x){if(!m)return;let $=Math.round(x*u);Ft(d,m,r.size,r),m.clearRect(0,0,s,i);let C=ea(G((x-F)/D)),A=(1-C)**1.5,V=Math.floor($/5)+y,B=Ee(V,11)*i,X=(20+Ee(V,12)*120)*o,W=(Ee(V,13)-.5)*140*o*A*(Ee(V,14)<j?1:0);for(let M=0;M<h;M++){let H=T[M],Y=M+y,K=(H.x+H.vx*x+(Ee(Y,$)-.5)*S*A)%s,k=(H.y+H.vy*x+(Ee(Y,$+7777)-.5)*S*A)%i;K<0&&(K+=s),k<0&&(k+=i),k>B&&k<B+X&&(K+=W);let E=ea(G(C*1.35-H.d*.35)),L=ke(K,H.gx+Math.sin(x*.8+H.gy*.01)*2*o,E),z=ke(k,H.gy,E),I=Math.max(0,Math.sin(H.gy/i*7-x*3.2))**6*E*Z,U=ke(.35+Ee(Y,$+3)*.9,.55,E),Q=ke(H.a*U*1.25,.17+I,E),ee=ke(H.r,1.05*o,E);m.fillStyle=`rgba(${H.hot?p:c},${G(H.hot?Q*1.6:Q).toFixed(3)})`,m.fillRect(L-ee,z-ee,ee*2,ee*2)}}}}};var aa={down:[0,1],up:[0,-1],right:[1,0],left:[-1,0]};function Ut(e,n,t){let r=t.ease("smooth")(e),a=Math.sin(Math.PI*G(e))**2;return{travel:r,scale:1-l(n.pull)*a,tilt:l(n.tilt)*a,edge:a}}var ia={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]=aa[P(r.direction)]??aa.down,d=(u?i:s)*(1+l(r.gap)),m=Math.max(s,i)*2.2,c=(v,R)=>{let T=(R-v.travel)*d,F=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(${m}px) scale(${v.scale.toFixed(5)}) ${F} translate(${(o*T).toFixed(2)}px, ${(u*T).toFixed(2)}px)`},p=Ut(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 g=.5/a.fps/l(r.duration),f=Ut(G(t-g),r,a),h=(Ut(G(t+g),r,a).travel-f.travel)*d*p.scale,y=Me(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 ct=new WeakMap,sa={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(),d=u.width>0?u.width/s:1,m=[...e.querySelectorAll(":scope > .m-cam > .m-layer")].filter(h=>h.style.visibility!=="hidden"),c=m.length,p=l(r.spread),g=1-p;m.forEach((h,y)=>{let v=c-1-y,R=c>1?v/(c-1)*p:0,T=G((t-R)/g),F=T**2.3;if(T<=0)return;let D=h.getBoundingClientRect(),S=((D.left+D.width/2-u.left)/d-s/2)/(s/2),j=((D.top+D.height/2-u.top)/d-i/2)/(i/2),Z=Math.hypot(S,j);Z<.15?(S=.12,j=-1):(S/=Z,j/=Z);let x=Math.max(s,i)*.9*F,$=o*.82*F,C=l(r.tumble),A=`perspective(${o}px) translate3d(${(S*x).toFixed(2)}px, ${(j*x).toFixed(2)}px, ${$.toFixed(2)}px) rotateX(${(-j*C*F).toFixed(3)}deg) rotateY(${(S*C*F).toFixed(3)}deg) rotate(${((y%2?12:-12)*F).toFixed(3)}deg)`;h.style.transform=`${A} ${h.style.transform}`,h.style.opacity=String(Number(h.style.opacity||1)*(1-a.ease("smooth")(G((T-.7)/.3))));let V=l(r.defocus)*F*F;V>.05&&(h.style.filter=`${h.style.filter} blur(${V.toFixed(2)}px)`.trim())});let f=a.ease("expo.out")(G(t/.85));n.style.transformOrigin="50% 50%",n.style.transform=`scale(${(1+l(r.settle)*(1-f)).toFixed(4)})`,ct.has(e)||ct.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")(G(t/.45));e.style.background=b>.001?`color-mix(in srgb, ${ct.get(e).ground} ${(b*100).toFixed(2)}%, transparent)`:"transparent"},clear(e){e.style.transform="",e.style.transformOrigin="";let n=ct.get(e);n&&(e.style.zIndex=n.zIndex,e.style.background=n.background,ct.delete(e))}};var Tt=new WeakMap,oa={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=P(r.direction)||"down",u=a.ease("quint.inOut")(G(t)),d=o==="down"||o==="up",m=d?i:s,c=30,p=-c+u*(m+2*c),g=G(p,0,m),f={down:`0 0 ${m-g}px 0`,up:`${m-g}px 0 0 0`,right:`0 ${m-g}px 0 0`,left:`0 0 0 ${m-g}px`}[o];n.style.clipPath=g>=m?"":`inset(${f})`,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 D=n.ownerDocument.createElement("div");h.appendChild(D),b.appendChild(h),Tt.set(n,h)}let y=l(r.glow),v=l(r.trail)*m,R=o==="down"||o==="right"?p:m-p,T={down:"to top",up:"to bottom",right:"to left",left:"to right"}[o],F=h.firstElementChild;h.style.cssText="position:absolute;z-index:999;pointer-events:none;background:color-mix(in srgb, var(--m-accent) 70%, white);"+(d?`left:0;right:0;height:2px;top:${(R-1).toFixed(2)}px;`:`top:0;bottom:0;width:2px;left:${(R-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}`,F.style.cssText=`position:absolute;${d?`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(${T}, 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 la={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]},ua={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]=la[P(r.direction)]??la.left,d=o?s:i,m=l(r.anticipation)*d,c=a.ease("expo.inOut"),p=v=>(v<.3?-m*Math.sin(Math.PI*G(v/.3)):0)+d*c(G((v-.12)/.88)),g=.5/(a.fps||30)/l(r.duration),f=p(G(t+g))-p(G(t-g)),b=p(t);e.style.transform=`translate(${(o*b).toFixed(2)}px, ${(u*b).toFixed(2)}px)`,n.style.transform=`translate(${(o*(b-d)).toFixed(2)}px, ${(u*(b-d)).toFixed(2)}px)`;let h=Me(f,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 os(e,n){let t=n+(1-n)*.55,r=G(e);return r<.5?n+(t-n)*r*2:t+(1-t)*(r-.5)*2}function ls(e,n,t){let r=Math.max(1,t),a=G(n)*(e-1+r);return Array.from({length:e},(s,i)=>G((a-i)/r))}var da={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}=Pe(e,P(n.text),{accent:te(n.accent)}),s=a.map(f=>{let b=/^\{(.+)\}([^\p{L}\p{N}]*)$/u.exec(f.textContent??"");return b?(f.textContent=b[1],f.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"),d=Math.max(.001,l(t.duration)),m=l(t.dim),c=l(t.soft),p=l(t.blur),g=l(t.rise);return{seek(f){let b=ls(a.length,i(G(f/d)),c);a.forEach((h,y)=>{let v=o(b[y]);if(s[y]){let T=G(v*3);h.style.opacity=T>=1?"":T.toFixed(4),h.style.transform=v>=1?"":`scale(${(.5+.5*u(v)).toFixed(4)})`;return}let R=os(v,m);h.style.opacity=R>=1?"":R.toFixed(4),h.style.filter=p>0&&v<1?`blur(${((1-v)*p).toFixed(3)}px)`:"",h.style.transform=g>0&&v<1?`translateY(${((1-v)*g).toFixed(3)}px)`:""})}}}};function us(e,n){let t=G(e),r=Math.max(1,n.from+(n.to-n.from)*t),a=(r-1)/2,s=i=>G(i/100*(t-.5),-a,a);return{scale:r,x:s(n.pan_x),y:s(n.pan_y)}}var ma={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=P(n.src),a.alt=P(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(d){let m=us(i(G(d/o)),u);a.style.transform=`translate(${(m.x*100).toFixed(4)}%, ${(m.y*100).toFixed(4)}%) scale(${m.scale.toFixed(5)})`}}}};function ca(e,n,t=1){let[r,a]=e,s=Math.max(.01,n),i=Math.max(1,t);if(s>=r/a){let d=a*i,m=d*s;return{axis:"x",w:m,h:d,spare:Math.max(0,m-r)}}let o=r*i,u=o/s;return{axis:"y",w:o,h:u,spare:Math.max(0,u-a)}}function ds(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 ms(e,n,t,r,a){return Math.abs(t-n)/100*e.spare*ds(a)/Math.max(.01,r)}var pa=(e,n)=>[l(e.width)||n[0],l(e.height)||n[1]],ha={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=ca(pa(n,t.size),l(n.aspect,1.78),l(n.scale,1));return ms(r,l(n.from,20),l(n.to,80),l(n.duration,4),Ne(n.ease??"sine.inOut"))},build(e,n,t,r){let[a,s]=pa(t,r.size),i=ca([a,s],l(t.aspect,1.78),l(t.scale,1)),o=e.ownerDocument.createElement("img");o.src=P(n.src),o.alt=P(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 d=r.ease(t.ease),m=l(t.duration,4),c=l(t.from,20),p=l(t.to,80);return{seek(g){let f=-i.spare*((c+(p-c)*d(G(g/m)))/100),[b,h]=i.axis==="x"?[f,u]:[u,f];o.style.transform=`translate3d(${b.toFixed(3)}px, ${h.toFixed(3)}px, 0)`}}}};function cs(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 ps(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=cs(r,n.duration-s*(a-1)),o=e-n.delay;if(o<=0)return r[0];for(let u=0;u<a;u++){let d=i[u];if(o<d)return r[u]+(r[u+1]-r[u])*t(G(o/d));if(o-=d,u<a-1){if(o<s)return r[u+1];o-=s}}return r[a]}var fa=(e,n)=>({from:l(n.from),to:l(n.to,100),stops:be(e.stops),duration:l(n.duration,3),rest:l(n.rest,.4),delay:l(n.delay)}),Vt=150,ga={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=fa(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:${-Vt}px;width:${s}px;height:${i+2*Vt}px;overflow:hidden`;let d=a.createElement("div");d.style.cssText=`position:absolute;left:0;top:${Vt}px;width:${s}px;will-change:transform`,te(n.srcs).forEach((f,b)=>{let h=a.createElement("img");h.src=f,h.alt=b===0?P(n.alt):"",h.decoding="sync",h.style.cssText="display:block;width:100%;height:auto",d.appendChild(h)}),u.appendChild(d),o.appendChild(u),e.appendChild(o);let m=fa(n,t),c=r.ease(t.ease),p=l(t.shutter,.5),g=.5/r.fps;return{seek(f){let b=Math.max(0,d.offsetHeight-i),h=y=>ps(y,m,c)/100*b;d.style.transform=`translateY(${(-h(f)).toFixed(2)}px)`,u.style.filter=Te(u,0,Me(h(f+g)-h(f-g),p))}}}};var hs=["down","up","center","edges","random"],fs=["left","right","alternate","weave"],gs=["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 bs=.6;function xs(e,n,t,r,a=1){let s=$e(e,t,ys(r),a),i=Math.max(0,...s),o=bs*n,u=i>o?o/i:1;return{delays:s.map(d=>d*u),travel:n-i*u}}var ys=e=>e==="down"?"start":e==="up"?"end":e;function Yt(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 Kt=(e,n,t)=>e.map(r=>r===null&&t>0?t:n);function ws(e,n,t){return e==="left"?1:e==="right"?-1:(e==="weave"?n+t:n)%2===0?1:-1}function vs(e,n,t,r,a,s){let i=t[r]??0;for(let u=0;u<n.changes.length;u++){let d=n.changes[u]+i;if(e<d)return{from:u,to:u,u:0};if(e<d+a)return{from:u,to:u+1,u:s(G((e-d)/a))}}let o=n.changes.length;return{from:o,to:o,u:0}}var ba={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:hs,label:"Which strips change first"},direction:{type:"choice",default:"left",options:fs,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:gs,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,P(n.empty,"none"));return Yt(t.length,Kt(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,P(n.empty,"none")),r=Yt(t.length,Kt(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,P(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),d=Math.round(l(t.rows,8)),m=te(n.images),c=te(n.fills).length?te(n.fills):["accent"],p=Et(m.length,P(t.empty,"none")),g=l(t.shift,1),f=l(t.hold,1.2),b=l(t.lead,.35),h=l(t.drag,.12),y=l(t.push,1.06),v=P(t.order,"down"),R=P(t.direction,"left"),{delays:T,travel:F}=xs(d,g,l(t.stagger,.05),v,r.seed),D=Yt(p.length,Kt(p,f,l(t.ground_hold,0)),g),S=r.ease(t.ease),j=B=>["base","surface","sunken","accent","inverse"].includes(B)?`var(--m-bg-${B})`:B;e.style.cssText+=`;width:${o}px;height:${u}px;position:relative;overflow:hidden`;let Z=Array.from({length:d+1},(B,X)=>Math.round(X*u/d)),x=p.map((B,X)=>{let W=X===0?0:D.changes[X-1],M=X===p.length-1?D.duration:D.changes[X]+D.change;return[W,Math.max(W+1e-6,M)]}),$=Z.slice(0,-1).map((B,X)=>{let W=Z[X+1]-B,M=a.createElement("div");M.style.cssText=`position:absolute;left:0;top:${B}px;width:${o}px;height:${W}px;overflow:hidden`;let H=p.map((Y,K)=>{let k=a.createElement("div");k.style.cssText=`position:absolute;left:0;top:0;width:${o}px;height:${W}px;visibility:hidden;will-change:transform`;let E=a.createElement("div"),L=j(c[Math.max(0,K-1)%c.length]);E.style.cssText=`position:absolute;top:0;height:${W}px;width:${Math.ceil(o*b)+1}px;background:${L}`,k.appendChild(E);let z;if(Y!==null){let I=a.createElement("div");I.style.cssText=`position:absolute;left:0;top:0;width:${o}px;height:${W}px;overflow:hidden`,z=a.createElement("img"),z.src=m[Y],z.alt="",z.decoding="sync",z.style.cssText=`position:absolute;left:0;top:${-B}px;width:${o}px;height:${u}px;object-fit:cover;transform-origin:${o/2}px ${u/2}px;max-width:none`,I.appendChild(z),k.appendChild(I)}return M.appendChild(k),{box:k,img:z,field:E}});return e.appendChild(M),{panes:H,h:W}}),C=l(t.rule_width,2);if(C>0){let B=t.edges?0:1,X=t.edges?d:d-1;for(let W=B;W<=X;W++){let M=Math.min(u-C,Math.max(0,Z[W]-C/2)),H=a.createElement("div");H.style.cssText=`position:absolute;left:0;top:${M}px;width:${o}px;height:${C}px;background:${P(n.rule,"var(--m-text-primary)")};opacity:${l(t.rule_opacity,.6)};pointer-events:none`,e.appendChild(H)}}let A=Math.ceil(o*b)+1,V=(B,X,W,M,H,Y="",K=!1)=>{if(B.box.style.visibility="inherit",B.field.style.visibility=K?"inherit":"hidden",B.box.style.transform=`translate3d(${X.toFixed(2)}px,0,0)`,B.box.style.clipPath=Y,B.field.style.left=W===1?`${-A+1}px`:`${o-1}px`,B.img){let[k,E]=x[H],L=G((M-k)/(E-k));B.img.style.transform=`scale(${(y+(1-y)*L).toFixed(5)})`}};return{seek(B){$.forEach(({panes:X},W)=>{let{from:M,to:H,u:Y}=vs(B,D,T,W,F,S);if(X.forEach(I=>{I.box.style.visibility="hidden"}),M===H){V(X[M],0,1,B,M);return}let K=ws(R,W,M),k=o*(1+b),E=K*k*(1-Y),L=-K*h*o*Y,z=K===1?Math.max(0,L+o-(E-A+1)):Math.max(0,E+o+A-1-L);V(X[M],L,K,B,M,K===1?`inset(0 ${z.toFixed(2)}px 0 -${A}px)`:`inset(0 -${A}px 0 ${z.toFixed(2)}px)`),V(X[H],E,K,B,H,"",!0)})}}}};var xa="bands",ya=["var(--m-bg-accent)","var(--m-bg-inverse)","var(--m-bg-surface)","var(--m-bg-sunken)"],Gt=e=>`var(--m-band-${e%6+1}, ${ya[e%ya.length]})`;function ks(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 Ms(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 Fs(e,n,t,r,a){let s=Math.max(.05,.5-(t-1)*r),i=a(G((e-n*r)/s)),o=a(G((e-.5-n*r)/s)),u=Math.min(G((e-n*r-s*.35)/(.5-n*r-s*.35)),1-G((e-.5)/(s*.65)));return{lead:i,trail:o,swell:a(G(u))}}var wa={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=P(r.direction,"left"),[u,d]=a.size,m=o==="left"||o==="right",c=m?u:d,p=m?d:u,g=ks(s,l(r.angle,14)),f=l(r.width,9)/100*Math.min(u,d),b=Math.max(f,Ms(s,p,c,l(r.angle,14))),h=Math.hypot(u,d)*1.25,y=a.ease("quart.inOut"),v=o==="left"||o==="up"?-1:1;De(e,xa,s).forEach((D,S)=>{let{lead:j,trail:Z,swell:x}=Fs(t,S,s,i,y),$=f+(b-f)*x,C=(S+.5)/s*p,A=m?u/2:C,V=m?C:d/2,B=(m?0:90)+g[S];D.style.background=Gt(S),D.style.inset="auto",D.style.left=`${(A-h/2).toFixed(2)}px`,D.style.top=`${(V-$/2).toFixed(2)}px`,D.style.width=`${h.toFixed(2)}px`,D.style.height=`${$.toFixed(2)}px`;let X=j*100,W=Z*100;D.style.clipPath=v<0?`inset(0 ${W.toFixed(3)}% 0 ${(100-X).toFixed(3)}%)`:`inset(0 ${(100-X).toFixed(3)}% 0 ${W.toFixed(3)}%)`,D.style.transform=`rotate(${B.toFixed(3)}deg)`,D.style.visibility=j<=0||Z>=1?"hidden":"visible"});let T=t>=.5;e.style.opacity=T?"0":"1",n.style.opacity=T?"1":"0";let F=y(G((t-.5)/.5));n.style.transform=T?`scale(${(1.03-.03*F).toFixed(4)})`:"",e.style.transform=T?"":`scale(${(1+.02*y(G(t/.5))).toFixed(4)})`},clear(e){Be(e,xa),e.style.transform="",e.style.opacity=""}};var va="strips",$s=["band-1","band-2","band-3","band-4","band-5","band-6","accent","inverse","surface","sunken"],Ts=e=>/^band-[1-6]$/.test(e)?Gt(Number(e.slice(5))-1):Ke(e),Es=(e,n)=>Math.min(Math.max(0,n),.5/Math.max(1,e-1));function Jt(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(G((e-i*r)/o))}function Ss(e,n,t){let r=n-e*(n+t);return{front:r,back:r+t}}function Cs(e,n,t,r,a){if(a.mode==="cover"){if(e<.5){let d=Jt(e*2,n,t,a.lag,a.order,a.ease);return{field:[r-d*r,r],shown:null}}let o=Jt(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}=Ss(Jt(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 ka={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:$s,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:P(r.mode,"lead"),field:Math.ceil(l(r.lead,.35)*s),lag:Es(o,l(r.stagger,.04)),order:P(r.order,"down"),ease:a.ease(P(r.mode,"lead")==="cover"?"cubic.inOut":"quart.inOut")},d=P(r.direction,"left")!=="right",m=r.alternate===!0,c=Ts(P(r.colour,"band-1")),p=De(e,va,o),g=[];for(let f=0;f<o;f++){let b=Math.floor(f/o*i),h=Math.min(i,Math.ceil((f+1)/o*i)+1),y=Cs(t,f,o,s,u),v=m&&f%2===1?d:!d,R=([Z,x])=>v?[s-x,s-Z]:[Z,x],[T,F]=R(y.field),D=p[f],S=Math.max(0,T),j=Math.min(s,F);if(D.style.inset="auto",D.style.left=`${S.toFixed(2)}px`,D.style.top=`${b}px`,D.style.width=`${Math.max(0,j-S).toFixed(2)}px`,D.style.height=`${h-b}px`,D.style.background=c,D.style.visibility=j>S?"visible":"hidden",y.shown){let[Z,x]=R(y.shown);x>Z&&g.push(`M${Math.max(0,Z).toFixed(2)} ${b}H${Math.min(s,x).toFixed(2)}V${h}H${Math.max(0,Z).toFixed(2)}Z`)}}e.style.opacity="1",n.style.opacity=g.length?"1":"0",n.style.zIndex="2",e.style.zIndex="1",n.style.clipPath=t>=1?"":g.length?`path('${g.join(" ")}')`:""},clear(e){Be(e,va),e.style.clipPath="",e.style.zIndex="",e.style.opacity=""}};var Ma=e=>Object.fromEntries(e.map(n=>[n.slug,n])),pt=Ma([vn,hn,yn,bn,kn,xn,wn,Gn,Yn,Vn,Mn,$n,Fn,An,En,Hn,Br,Lr,Rr,Hr,Nr,jr,Or,Wr,_n,tr,sr,Jn,mr,or,lr,cr,pr,hr,gr,xr,Zr,da,ra,Vr,_r,Jr,Ur,Rn,ma,ha,ga,Dn,Nn,ba]),ze=Ma([qn,Zn,Xn,Sr,Fr,wr,Mr,kr,Pr,Cr,ia,ua,oa,sa,wa,ka]);var As=[1920,1080],Ct=(e,n,t,r={})=>({motion:"0.4",title:e,size:As,fps:30,loop:!0,...r,theme:{ui:"graphite",scheme:t,...r.theme},scenes:n}),ft=(e,n,t={})=>({id:e,layers:n,...t}),ht=["Comments","Cursors","History","Branches","Review","Share","Export","Search"],St=(e,n,t)=>`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${n}" width="${e}" height="${n}">${t}</svg>`)}`,Ze=St(800,600,'<rect width="800" height="600" fill="#B9B9B8"/><circle cx="590" cy="170" r="54" fill="#E4E4E3"/><path d="M0 600 L0 420 L210 230 L380 400 L520 300 L800 520 L800 600Z" fill="#8A8A89"/><path d="M0 600 L0 520 L300 380 L560 520 L800 440 L800 600Z" fill="#5E5E5D"/>'),tt=[St(800,520,'<rect width="800" height="520" fill="#3B3B3A"/><rect x="200" y="200" width="400" height="44" rx="8" fill="#E4E4E3"/><rect x="290" y="270" width="220" height="24" rx="6" fill="#9C9C9B"/>'),St(800,620,'<rect width="800" height="620" fill="#F3F3F2"/><rect x="60" y="70" width="360" height="40" rx="8" fill="#3B3B3A"/><rect x="60" y="170" width="210" height="360" rx="12" fill="#C9C9C8"/><rect x="295" y="170" width="210" height="360" rx="12" fill="#B0B0AF"/><rect x="530" y="170" width="210" height="360" rx="12" fill="#C9C9C8"/>'),St(800,560,'<rect width="800" height="560" fill="#E0E0DF"/><rect x="60" y="80" width="300" height="40" rx="8" fill="#3B3B3A"/><rect x="60" y="170" width="680" height="18" rx="6" fill="#9C9C9B"/><rect x="60" y="215" width="640" height="18" rx="6" fill="#9C9C9B"/><rect x="60" y="260" width="560" height="18" rx="6" fill="#9C9C9B"/><rect x="60" y="360" width="180" height="56" rx="10" fill="#5E5E5D"/>')],Re={"font-size":"calc(var(--m-u) * 7.4)","line-height":"1.05"};function Fa(e,n="move",t){switch(e){case"type/word-build":return{id:n,use:e,props:{text:t??"Edit together, live",accent:t?[]:["live"]},style:{size:"headline",width:86,css:Re}};case"type/typed-title":return{id:n,use:e,props:{text:t??"Atlas"},style:t?{size:"headline",width:86,css:Re}:{size:"hero"}};case"type/scramble":return{id:n,use:e,props:{text:t??"Launch day"},style:{size:"headline",width:86,css:Re}};case"fx/counter-roll":return{id:n,use:e,props:{value:98,suffix:"%"},style:{size:"hero"}};case"fx/stagger-fill":return{id:n,use:e,props:{items:ht.slice(0,6)},style:{size:"title",width:80}};case"fx/depth-drift":return{id:n,use:e,props:{items:ht},style:{size:"title"}};case"scene/marquee-wall":return{id:n,use:e,props:{items:[...ht,...ht],highlight:"Review"},params:{highlight_at:1.2},style:{size:"title"}};case"rig/orbit-ring":return{id:n,use:e,props:{items:ht.slice(0,6)}};case"texture/halftone-field":return{id:n,use:e,params:{cell:20,reach:1}};case"type/mask-reveal":return{id:n,use:e,props:{text:t??`Motion that
|
|
7
7
|
feels designed`},style:{size:"headline",width:86,css:Re}};case"type/char-cascade":return{id:n,use:e,props:{text:t&&t.length<=12?t:"Kinetic"},params:{from:"center"},style:{size:"hero"}};case"type/block-reveal":return{id:n,use:e,props:{text:t??`Brand.
|
|
8
|
-
Motion.`},style:{size:"headline",width:86,css:Re}};case"type/word-roller":return{id:n,use:e,props:{before:"Made for",words:["teams","films","brands"]},style:{size:"headline",css:Re}};case"type/tracking-in":return{id:n,use:e,props:{text:t??"ATLAS"},style:{size:"hero"}};case"type/shimmer":return{id:n,use:e,props:{text:t??"Shipped"},style:{size:"hero"}};case"type/echo":return{id:n,use:e,props:{text:t&&t.length<=12?t:"Again"},style:{size:"hero"}};case"type/scribble-highlight":return{id:n,use:e,props:{text:t??"Ship it today",mark:[(t??"Ship it today").split(/\s+/).pop()??""]},params:{delay:.1},style:{size:"headline",width:86,css:Re}};case"fx/odometer":return{id:n,use:e,props:{value:12480},style:{size:"hero"}};case"scene/grid-wall":{let r=s=>`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4"><rect width="4" height="4" fill="${s}"/></svg>`)}`,a=[1.3,.75,1,1.5,.8,1.2,.7,1.4,1,.9,1.6,.8];return{id:n,use:e,props:{images:a.map((s,i)=>r(["#9C9C9B","#B5B5B4","#7A7A79"][i%3])),ratios:a},params:{columns:4,width:70,gap:20,drift_speed:0}}}case"fx/path-draw":return{id:n,use:e,props:{paths:["M10 50 C 30 10, 70 10, 90 50 S 70 90, 50 70","M20 80 L 80 20"],viewbox:"0 0 100 100"},params:{width:30,stroke:4}};case"fx/shape-morph":return{id:n,use:e,props:{shapes:["circle","squircle","star"]},params:{size:34}};case"fx/grid-ripple":return{id:n,use:e,params:{cols:20,opacity:.8}};case"scene/logo-reveal":return{id:n,use:e,props:{name:"Atlas",tagline:t??""},style:{size:"hero"}};case"scene/bar-chart":return{id:n,use:e,props:{values:[32,48,41,76,58],labels:["A","B","C","D","E"],highlight:"D"},params:{width:70,height:62},style:{size:"headline"}};case"scene/line-chart":return{id:n,use:e,props:{values:[12,18,15,24,22,31,29,42]},params:{width:80,height:60,draw:1.4},style:{size:"headline"}};case"texture/gradient-drift":return{id:n,use:e,params:{period:6}};case"texture/grain":return{id:n,use:e,params:{amount:.22}};case"texture/vignette":return{id:n,use:e,screen:!0,params:{strength:1,mid:.7}};case"texture/beat-field":return{id:n,use:e,params:{glow:.3,ring:.45,paper:.08}};case"ui/cursor-click":return{id:n,use:e,params:{size:4}};case"type/fill-text":return{id:n,use:e,props:{text:t??"Noise into signal",accent:t?[]:["signal"]},style:{size:"headline",width:86,css:Re}};case"texture/signal-field":return{id:n,use:e,params:{cols:24,settle_at:.4}};case"rig/tab-stack":return{id:n,use:e,props:{items:["Monitor","Detect","Respond","Report"],details:["","","","Every signal, in one place."]},params:{width:80,slide_at:.5,slide:1.2}};case"rig/layer-stack":return{id:n,use:e,props:{items:["Base","Rules","Parts","Uses"],name:"One layer"},params:{width:46,gap:150,start:.5,travel:.7}};case"rig/footage-plane":return{id:n,use:e,place:{x:50,y:50},props:{src:Ze},params:{width:900,radius:20}};case"rig/browser-window":return{id:n,use:e,props:{lift:[36,54,28,38]},params:{width:90,move:.9}};case"fx/slow-push":return{id:n,use:e,props:{src:Ze},params:{width:1040,height:780,radius:24,from:1,to:1.16,pan_x:-6,duration:3}};case"fx/pan-across":return{id:n,use:e,props:{src:Ze},params:{width:560,height:780,aspect:800/600,from:10,to:90,duration:3}};case"ui/page-scroll":return{id:n,use:e,props:{srcs:tt,stops:[45]},params:{width:1e3,height:820,radius:24,duration:2.6,rest:.5,delay:.3}};case"scene/bento-grid":{let r=a=>`<b style="font:700 calc(var(--m-u) * 6)/1 var(--m-font-display);color:var(--m-text-primary)">${a}</b>`;return{id:n,use:e,props:{areas:"a b c / d b e",counts:[1,2,2,2,2],items:[r("Atlas"),Ze,tt[1],r("01"),r("02"),tt[0],Ze,r("Go"),r("On")]},params:{width:84,hold:1.25,swap_time:.5,offset:.2,stagger:0}}}case"scene/post-carousel":return{id:n,use:e,props:{slides:[Ze,tt[1],tt[0]],handle:"atlas"},params:{width:30,hold:.8,turn:.6,loop:!0}};case"scene/strip-cycle":return{id:n,use:e,props:{images:[Ze,tt[0]],fills:["accent","inverse"]},params:{rows:6,hold:.6,shift:.7,stagger:.05,empty:"both"}};case"fx/pin-drop":return{id:n,use:e,props:{points:[28,70,70,55],labels:["Found","Here"]},params:{size:28,stem:220}};default:return}}var Ps=new Set(["scene/marquee-wall","scene/bento-grid","texture/halftone-field","texture/gradient-drift","texture/grain","texture/vignette","texture/beat-field","fx/grid-ripple","ui/cursor-click","texture/signal-field","fx/pin-drop","scene/strip-cycle"]),zs=e=>{let n=ze[e]?.duration;return typeof n=="number"?n:.8};function $a(e,n){if(e.startsWith("transition/"))return Ct(e,[ft("before",[{id:"a",use:"el/text",props:{text:"Before"},style:{size:"hero"}}],{length:Math.max(1.4,zs(e)+.6),background:"base",out:{use:e}}),ft("after",[{id:"b",use:"el/text",props:{text:"After"},style:{size:"hero"}}],{length:1.6,background:"inverse"})],n);let t=Fa(e);if(!t)return;let r=Ps.has(e);return Ct(e,[ft("only",[t],{hold:1.2,background:e==="rig/orbit-ring"?"sunken":"base",...r?{length:3.5,layout:{padding:0,justify:"center"}}:{}})],n)}function Ta(e,n){return Ct(e,[ft("feel",[{id:"line",use:"type/word-build",props:{text:"Every move, on time"},style:{size:"headline"}},{id:"chips",use:"fx/stagger-fill",at:"line.end - 0.2",props:{items:["One","Two","Three","Four"]},style:{size:"title"}}],{hold:"$hold_end"})],n,{tokens:Ae[e].tokens})}function Ea(e,n,t=7){let r=e.beats.map((a,s)=>{let i=a.primitives.map(m=>Fa(m,"beat",a.content)).find(Boolean),o={id:"label",use:"el/text",props:{text:`${s+1}/${e.beats.length} ${a.name}`},place:{x:5,y:8,anchor:"top-left"},style:{size:"title",color:"muted",css:{"font-size":"calc(var(--m-u) * 4.4)"}}},u=i??{id:"beat",use:"el/text",props:{text:a.content},style:{size:"headline",width:86,css:Re},enter:{move:"rise",amount:40}},d=Math.max(.6,Math.round(a.share/100*t*10)/10);return ft(`b${s+1}`,[o,u],{length:d,background:s%2?"sunken":"base"})});return Ct(e.slug,r,n)}function Sa(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=>Ne(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 d=r[u-1],m=r[u],c=m[0]-d[0],p=c<=0?1:a[u]((s-d[0])/c);return d[1]+(m[1]-d[1])*p}}var We=(e,n,t)=>e+(n-e)*t;function Ca(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(We(Math.log(r.zoom),Math.log(a.zoom),s))*Math.max(.01,i),u=[We(r.target[0],a.target[0],s),We(r.target[1],a.target[1],s)],d=[We(r.anchor[0],a.anchor[0],s),We(r.anchor[1],a.anchor[1],s)],m=We(r.rotate,a.rotate,s);return{...Rs(u,d,o,m,t),scale:o,rotate:m,rotateX:We(r.tilt[0],a.tilt[0],s),rotateY:We(r.tilt[1],a.tilt[1],s),pivot:[d[0]-t[0]/2,d[1]-t[1]/2]}}function Rs(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 Qt=.08,Aa=.35,_t=.07,Pa=.5,Ls=12,Os=.7,Ds=rt(.34,1.36,.64,1),Bs=rt(.22,1,.36,1);function za(e,n){let t=1;for(let r of e){let a=n-r;a<-Qt||a>Aa||(t*=a<0?1-_t*((a+Qt)/Qt):1-_t+_t*Ds(a/Aa))}return t}function Ra(e,n){let t;for(let a of e)n>=a&&n-a<=Pa&&(t===void 0||a>t)&&(t=a);if(t===void 0)return;let r=(n-t)/Pa;return{grow:Ls*Bs(r),opacity:Os*(1-r)}}var At=["x","y","scale","rotate","opacity","blur","rotateX","rotateY","skew"],Pt=["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"],La=["wipe","slide"],en=["hero","headline","title","body","caption"],tn=["primary","secondary","muted","accent","inverse","on-accent"],nn=["center","top-left","top","top-right","left","right","bottom-left","bottom","bottom-right"],Oa=["%","px"],rn=["cover","contain","width","height"];var an=["zero","graphite","hockney"];var Is={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}},zt=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Rt(e,n){if(!zt(e)||!zt(n))return n===void 0?e:n;let t={...e};for(let[r,a]of Object.entries(n))t[r]=Rt(t[r],a);return t}var Lt=(...e)=>e.reduce((n,t)=>Rt(n,t),Is);function sn(e){let n=[],t=(r,a)=>{if(zt(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 gt(e,n){let t=e;for(let r of n.replace(/^\$/,"").split(".")){if(!zt(t)||!(r in t))return;t=t[r]}return t}var Xe=e=>typeof e=="string"&&e.startsWith("$");var Ba=/^\s*(\d+(?:\.\d+)?)\s*(b|beats?|bars?)\s*$/,Le=e=>typeof e=="string"&&Ba.test(e),Da=e=>60/e.bpm;function Ia(e,n){let t=Ba.exec(e);if(!t)return;let r=Number(t[1]);return t[2].startsWith("bar")?r*n.bar*Da(n):r*Da(n)}var Wa=(e,n)=>n*60/e.bpm;function ja(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 Na=/^[a-z][a-z0-9-]*$/;function Ha(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 qa(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 ge=e=>!!e&&typeof e=="object"&&!Array.isArray(e),he=e=>typeof e=="number"&&Number.isFinite(e),Ws=["$schema","motion","title","size","fps","seed","poster","loop","narrative","style","tokens","tempo","audio","theme","scenes"],js=["id","length","hold","background","scheme","layout","artboard","layers","tracks","follow","camera","perspective","motionBlur","out","uses","intent"],Ot=["fx/path-draw"],Ns=["id","use","props","params","at","style","place","enter","exit","tracks","motionBlur","parallax","screen","taps","reflow"],Hs=["size","color","font","weight","align","width","css"],qs={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},Zs={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 Xs(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=Xs(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 ve=e=>e.join(", ");function Za(e){let n=[],t=(x,$,C,A)=>n.push({level:"error",code:$,path:x,message:C,...A?{hint:A}:{}}),r=(x,$,C,A)=>n.push({level:"warning",code:$,path:x,message:C,...A?{hint:A}:{}}),a=(x,$)=>{let C=!n.some(A=>A.level==="error");return{ok:C,issues:n,tokens:x,...C&&$?{timeline:$}:{}}},s=(x,$,C)=>{for(let A of Object.keys(x)){if($.includes(A))continue;let V=Fe(A,$);t(C?`${C}.${A}`:A,"unknown-key",`"${A}" is not a field here.`,V?`Did you mean "${V}"?`:`Fields: ${ve($.filter(B=>B!=="$schema"))}.`)}};if(!ge(e))return t("","not-a-film","A film is a JSON object."),a(Lt());let i=e;s(e,Ws,""),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 d=Lt(ge(i.tokens)?i.tokens:void 0);if(i.tokens!==void 0)if(!ge(i.tokens))t("tokens","bad-tokens","tokens is an object of overrides.");else{let x=sn(Lt()),$=(C,A)=>{if(ge(C)&&!("spring"in C)){for(let[V,B]of Object.entries(C))$(B,A?`${A}.${V}`:V);return}if(!x.includes(A)){let V=Fe(A,x);t(`tokens.${A}`,"unknown-token",`There is no token "${A}".`,V?`Did you mean "${V}"?`:`Tokens: ${ve(x)}.`)}};$(i.tokens,"")}d.transitions!=="standard"&&d.transitions!=="calm"&&t("tokens.transitions","bad-value",'transitions is "standard" or "calm".',"Calm swaps every transition's defaults for its quiet preset.");let m=i.fps??d.fps;(!Number.isInteger(m)||m<=0)&&t("fps","bad-fps","fps is a whole number above zero.");let c;if(i.tempo!==void 0){let x=i.tempo;if(!ge(x)||!he(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 $=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($)||$<2||$>12)t("tempo.bar","bad-value","bar is a whole number of beats, 2 to 12.");else{c={bpm:x.bpm,bar:$};let C=Number.isInteger(m)&&m>0?Wa(c,m):1;Math.abs(C-Math.round(C))>1e-6&&i.audio===void 0&&r("tempo.bpm","beat-off-frame",`At ${m} fps a beat of ${c.bpm} bpm is ${C.toFixed(2)} frames, so beats fall between frames and drift.`,`Tempos with a whole number of frames per beat near it: ${ja(c.bpm,m).join(", ")} bpm.`)}}}let p;if(i.audio!==void 0){let x=i.audio;if(!ge(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 $=(C,A,V,B,X)=>{let W=x[C]===void 0?A:x[C];return!he(W)||W<V||W>B?(t(`audio.${C}`,"bad-value",`${C} is ${X}, ${V} to ${B}.`),A):W};p={src:x.src,from:$("from",0,0,36e3,"seconds into the file"),gain:$("gain",0,-30,6,"a level in dB"),fade_in:$("fade_in",0,0,10,"seconds"),fade_out:$("fade_out",0,0,10,"seconds")}}}let g=(x,$)=>{if(!c){t($,"needs-tempo",`"${x}" is in beats, but the film has no tempo.`,'Add "tempo": {"bpm": 120} to the film, or write seconds.');return}return Ia(x,c)};if(i.theme!==void 0)if(!ge(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&&!an.includes(i.theme.ui)&&t("theme.ui","bad-value",`ui is one of the bydiorama/ui themes: ${an.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(d);if(!u||!Number.isInteger(m)||m<=0)return a(d);let f=1/m,b=x=>Math.round(x*m)/m,h={tokens:d,seed:i.seed??1,size:[o[0],o[1]]},y=(x,$,C)=>{if(Le(x))return g(x,$);let A=Xe(x)?gt(d,x):x;if(Xe(x)&&A===void 0){let V=sn(d).map(X=>`$${X}`),B=Fe(x,V);t($,"unknown-token",`There is no token "${x}".`,B?`Did you mean "${B}"?`:void 0);return}if(!he(A)||A<0){t($,"bad-time",`${C} is a number of seconds, zero or more, a $token, or beats such as "2b" or "1bar".`);return}return A},v=(x,$)=>{let C=Xe(x)?gt(d,x):x;if(!fn(C)||typeof C=="string"&&!at.includes(C)){let A=typeof C=="string"?Fe(C,at):void 0;t($,"bad-ease",'An ease is a name, a [x1, y1, x2, y2] bezier, or {"spring": {"duration", "bounce"}}.',A?`Did you mean "${A}"?`:`Names: ${ve(at)}.`);return}return C},R=(x,$)=>{if(x===void 0)return;if(!ge(x)){t($,"bad-tracks","tracks is an object of keyframe lists by property.");return}let C={};for(let[A,V]of Object.entries(x)){let B=`${$}.${A}`;if(!At.includes(A)){let X=Fe(A,At);t(B,"unknown-track",`"${A}" cannot be animated by a track.`,X?`Did you mean "${X}"?`:`Properties: ${ve(At)}.`);continue}if(!Array.isArray(V)||V.length===0){t(B,"bad-track","A track is a list of [seconds, value] keys.");continue}C[A]=V.map((X,W)=>{let M=Array.isArray(X)&&Le(X[0])?g(X[0],`${B}.${W}`):Array.isArray(X)?X[0]:void 0;return!Array.isArray(X)||!he(M)||!he(X[1])?(t(`${B}.${W}`,"bad-key",'A key is [time, value] or [time, value, ease]; time in seconds or beats ("2b").'),X):(X[2]!==void 0&&v(X[2],`${B}.${W}`),X.length>2?[M,X[1],X[2]]:[M,X[1]])})}return C},T=(x,$,C,A)=>{let V={};for(let[B,X]of Object.entries($)){let W=X.default;V[B]=Xe(W)?gt(d,W):W}if(x===void 0)return V;if(!ge(x))return t(C,"bad-params","params is an object."),V;for(let[B,X]of Object.entries(x)){let W=`${C}.${B}`,M=$[B];if(!M){let Y=Object.keys($),K=Fe(B,Y);t(W,"unknown-param",`${A} has no param "${B}".`,K?`Did you mean "${K}"?`:Y.length?`Params: ${ve(Y)}.`:`${A} has no params.`);continue}if(Le(X)&&!(M.type==="number"&&M.unit==="s")){t(W,"bad-param",`${B} is not a time, so it cannot be in beats.`);continue}let H=Le(X)?g(X,W):Xe(X)?gt(d,X):X;if(!(Le(X)&&H===void 0)){if(Xe(X)&&H===void 0){t(W,"unknown-token",`There is no token "${X}".`);continue}if(M.type==="number"){if(!he(H)){t(W,"bad-param",`${B} is a number${M.unit?` (${M.unit})`:""}.`);continue}(M.min!==void 0&&H<M.min||M.max!==void 0&&H>M.max)&&r(W,"out-of-range",`${B} is ${H}; the library's range is ${M.min}\u2013${M.max}${M.unit?` ${M.unit}`:""}.`,"Allowed, but outside what has been seen to look right. Check the frames.")}else if(M.type==="ease"){if(v(H,W)===void 0)continue}else if(M.type==="boolean"){if(typeof H!="boolean"){t(W,"bad-param",`${B} is true or false.`);continue}}else if(M.type==="choice"&&!(M.options??[]).includes(String(H))){t(W,"bad-param",`${B} is one of: ${ve(M.options??[])}.`);continue}V[B]=H}}return V},F=new Set,D=[],S=new Map;i.scenes.forEach((x,$)=>{let C=ge(x)&&typeof x.id=="string"?x.id:String($),A=`scenes.${C}`;if(!ge(x)){t(A,"bad-scene","A scene is an object.");return}if(s(x,js,A),typeof x.id!="string"||!Na.test(x.id)?t(`${A}.id`,"bad-id",Ha(x.id,"scene"),qa(x.id,"scene",'For example "title" or "stat-2".')):F.has(x.id)&&t(`${A}.id`,"duplicate-id",`Two scenes are called "${x.id}".`),F.add(C),x.scheme!==void 0&&x.scheme!=="light"&&x.scheme!=="dark"&&t(`${A}.scheme`,"bad-value",'scheme is "light" or "dark".'),x.layout!==void 0&&(ge(x.layout)?s(x.layout,["align","justify","gap","padding"],`${A}.layout`):t(`${A}.layout`,"bad-layout","layout is { align, justify, gap, padding }.")),x.artboard!==void 0){let w=x.artboard,O=`${A}.artboard`;if(!ge(w))t(O,"bad-artboard","artboard is { width, height } in the design's pixels, with an optional fit and align.");else{s(w,["width","height","fit","align"],O);for(let J of["width","height"])(!he(w[J])||w[J]<1||w[J]>2e4)&&t(`${O}.${J}`,"bad-value",`${J} is the design's ${J} in its own pixels, 1 to 20000.`);w.fit!==void 0&&!rn.includes(w.fit)&&t(`${O}.fit`,"bad-value",`fit is one of: ${ve(rn)}.`),w.align!==void 0&&!(Array.isArray(w.align)&&w.align.length===2&&w.align.every(J=>he(J)&&J>=0&&J<=100))&&t(`${O}.align`,"bad-value","align is [x, y], each 0 to 100: where the artboard sits along each side of the stage.")}}let V=R(x.tracks,`${A}.tracks`);if(!Array.isArray(x.layers)){t(`${A}.layers`,"no-layers","A scene has a list of layers. It may be empty.");return}let B=new Map;x.layers.forEach((w,O)=>{let J=ge(w)&&typeof w.id=="string"?w.id:String(O),N=`${A}.layers.${J}`;if(!ge(w)){t(N,"bad-layer","A layer is an object.");return}if(s(w,Ns,N),typeof w.id!="string"||!Na.test(w.id)||w.id==="scene"){t(`${N}.id`,"bad-id",Ha(w.id,"layer"),qa(w.id,"layer",'For example "headline" or "photo-2".'));return}if(B.has(w.id)){t(`${N}.id`,"duplicate-id",`Two layers in scene "${C}" are called "${w.id}".`);return}let _=typeof w.use=="string"?pt[w.use]:void 0;if(!_){let me=Object.keys(pt),xe=typeof w.use=="string"?Fe(w.use,me):void 0,we=typeof w.use=="string"&&w.use in ze;t(`${N}.use`,"unknown-primitive",`There is no code for "${String(w.use)}".`,we?'That is a transition. Put it on the scene as "out": {"use": ...}.':xe?`Did you mean "${xe}"?`:`Drawable: ${ve(me)}. Compose anything else from el/* layers with enter, exit and tracks.`);return}let q={},re=w.props??{};if(!ge(re))t(`${N}.props`,"bad-props","props is an object.");else{for(let me of Object.keys(re)){if(me in _.props)continue;let xe=Object.keys(_.props),we=Fe(me,xe),mn=me in _.params;t(`${N}.props.${me}`,"unknown-prop",`${_.slug} has no prop "${me}".`,mn?`"${me}" is a motion value. Move it to params.`:we?`Did you mean "${we}"?`:`Props: ${ve(xe)}.`)}for(let[me,xe]of Object.entries(_.props)){let we=re[me];if(we===void 0){xe.required?t(`${N}.props.${me}`,"missing-prop",`${_.slug} needs "${me}": ${xe.label}.`):q[me]=xe.default;continue}if(!(xe.type==="number"?he(we):xe.type==="string[]"?Array.isArray(we)&&we.every(fi=>typeof fi=="string"):xe.type==="number[]"?Array.isArray(we)&&we.every(he):typeof we=="string")){t(`${N}.props.${me}`,"bad-prop",`"${me}" is ${xe.type==="string[]"?"a list of strings":xe.type==="number[]"?"a list of numbers":`a ${xe.type==="html"?"string":xe.type}`}.`);continue}(xe.type==="string[]"||xe.type==="number[]")&&xe.required&&we.length===0&&r(`${N}.props.${me}`,"empty",`"${me}" is empty, so nothing is drawn.`),q[me]=we}}let ne=T(w.params,_.params,`${N}.params`,_.slug);if(w.style!==void 0)if(!ge(w.style))t(`${N}.style`,"bad-style","style is an object.");else{s(w.style,Hs,`${N}.style`);let me=w.style;me.size!==void 0&&!en.includes(me.size)&&t(`${N}.style.size`,"bad-value",`size is one of: ${ve(en)}.`),me.color!==void 0&&!tn.includes(me.color)&&t(`${N}.style.color`,"bad-value",`color is one of: ${ve(tn)}.`,"For any other colour use style.css or a theme variable."),me.width!==void 0&&(!he(me.width)||me.width<=0||me.width>100)&&t(`${N}.style.width`,"bad-value","width is a percentage of the stage, 1 to 100.")}if(w.place!==void 0){let me=w.place;!ge(me)||!he(me.x)||!he(me.y)?t(`${N}.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"],`${N}.place`),me.anchor!==void 0&&!nn.includes(me.anchor)&&t(`${N}.place.anchor`,"bad-value",`anchor is one of: ${ve(nn)}.`),me.unit!==void 0&&!Oa.includes(me.unit)&&t(`${N}.place.unit`,"bad-value",`unit is "%" (of the stage) or "px" (of the scene's artboard).`))}let oe=R(w.tracks,`${N}.tracks`);if(w.reflow!==void 0&&(w.reflow!=="glide"?t(`${N}.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(`${N}.reflow`,"unused",`Layer "${J}" 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(`${N}.screen`,"bad-value","screen is true (fixed to the screen, outside the camera) or false."),w.screen===!0&&w.parallax!==void 0&&t(`${N}.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"&&!(he(w.motionBlur)&&w.motionBlur>=0&&w.motionBlur<=1)&&t(`${N}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1."),_.check)try{for(let me of _.check(q,ne,h))t(`${N}.${me.path}`,"bad-value",me.message,me.hint)}catch{}let le=0;try{le=_.duration(q,ne,h)}catch{}let ue;try{ue=_.cues?.(q,ne,h)}catch{}let fe;try{fe=_.speed?.(q,ne,h)}catch{}let ye=oe?{...w,tracks:oe}:w;B.set(w.id,{layer:ye,path:N,duration:Number.isFinite(le)?le:0,params:ne,props:q,...ue?{cues:ue}:{},..._.cycles?{cycles:!0}:{},...fe!==void 0&&Number.isFinite(fe)?{speed:fe}:{}})});let X=(w,O,J)=>{if(w===void 0)return;let N=typeof w=="string"?{move:w}:w;if(!ge(N)||!Pt.includes(N.move)){let ue=ge(N)&&typeof N.move=="string"?Fe(N.move,Pt):void 0;t(O,"unknown-move",`A move is one of: ${ve(Pt)}.`,ue?`Did you mean "${ue}"?`:void 0);return}s(N,J?["move","duration","ease","amount","angle","feather","at"]:["move","duration","ease","amount","angle","feather"],O);let _=N.move.startsWith("mask-")||N.move.startsWith("wipe-"),q;N.feather!==void 0&&N.feather!==!1&&(N.feather!==!0&&!(he(N.feather)&&N.feather>=0&&N.feather<=200)?t(`${O}.feather`,"bad-value","feather is a soft edge in px (0 to 200), or true for a tenth of the line height."):_?(N.feather===!0||N.feather>0)&&(q=N.feather):r(`${O}.feather`,"unused",`${N.move} has no edge to soften, so feather is ignored.`,"Feather mask-up, mask-down and the wipe-* moves."));let re=La.includes(N.move);N.angle!==void 0&&(he(N.angle)?re||r(`${O}.angle`,"unused",`${N.move} has a fixed direction, so angle is ignored.`,'Use "wipe" or "slide" to travel at an angle.'):t(`${O}.angle`,"bad-value","angle is degrees: 0 rightwards, 90 downwards, 180 leftwards, 270 upwards."));let ne=N.duration===void 0?J?d.duration.fast:d.duration.base:y(N.duration,`${O}.duration`,"duration"),oe=Zs[N.move],le=N.ease===void 0?oe?oe[J?"exit":"enter"]:J?d.ease_exit:d.ease_enter:v(N.ease,`${O}.ease`);if(N.amount!==void 0&&!he(N.amount)&&t(`${O}.amount`,"bad-value","amount is a number."),!(ne===void 0||le===void 0))return{move:N.move,duration:ne,ease:le,amount:he(N.amount)?N.amount:qs[N.move],...re?{angle:he(N.angle)?N.angle:0}:{},...q!==void 0?{feather:q}:{}}},W=new Map;for(let[w,O]of B){let J=X(O.layer.enter,`${O.path}.enter`,!1);J&&W.set(w,J)}let M=w=>Math.max(B.get(w).duration,W.get(w)?.duration??0),H=/^\s*([a-z][a-z0-9-]*)\.(start|end)\s*(?:([+-])\s*(\d+(?:\.\d+)?\s*(?:b|beats?|bars?)?))?\s*$/,Y=new Set,K,k,E=(w,O,J)=>{if(he(w)){if(w<0){t(O,"bad-time","Times are seconds from the scene start, zero or more.");return}return w}if(Le(w))return g(w,O);let N=typeof w=="string"?H.exec(w):null;if(!N){t(O,"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[,_,q,re,ne]=N,oe=ne===void 0?0:Le(ne)?g(ne,O):Number(ne);if(oe===void 0)return;let le=(re==="-"?-1:1)*oe;if(_==="scene"){if(q==="start")return Math.max(0,le);if(K===void 0){t(O,"needs-length",'"scene.end" can only place a layer when the scene has a length.',`Add "length" to scene "${C}", or refer to a layer instead.`);return}return Math.max(0,K+le)}if(_===J){t(O,"self-reference","A layer cannot be timed against itself.");return}if(!B.has(_)){let fe=[...B.keys()].filter(me=>me!==J),ye=Fe(_,fe);t(O,"unknown-layer",`Scene "${C}" has no layer "${_}".`,ye?`Did you mean "${ye}"?`:`Layers here: ${ve(fe)||"none"}.`);return}let ue=L(_);if(ue!==void 0)return Math.max(0,ue+(q==="end"?M(_):0)+le)},L=w=>{let O=B.get(w);if(O.start!==void 0)return O.start;if(Y.has(w)){t(`${O.path}.at`,"time-cycle",`Layers ${[...Y].join(" \u2192 ")} \u2192 ${w} are timed against each other in a circle.`,"Give one of them a number.");return}Y.add(w);let J=O.layer.at===void 0?0:E(O.layer.at,`${O.path}.at`,w);return Y.delete(w),J!==void 0&&(O.start=b(J)),O.start};if(x.length!==void 0){let w=Le(x.length)?g(x.length,`${A}.length`):x.length;w===void 0||(!he(w)||w<=0?t(`${A}.length`,"bad-time",'length is seconds above zero, or beats ("8b", "2bars").'):(K=Math.max(f,b(w)),k=Math.max(f,w)))}for(let w of B.keys())L(w);let z=x.hold===void 0?d.hold:y(x.hold,`${A}.hold`,"hold")??d.hold;if(K===void 0){let w=Math.max(0,...[...B.entries()].map(([O,J])=>(J.start??0)+M(O)));K=Math.max(f,b(w+z))}else x.hold!==void 0&&r(`${A}.hold`,"unused","hold is ignored when the scene has a length.");let I=K,U=[],Q=!!x.follow||Array.isArray(x.camera)&&x.camera.length>0||["x","y"].some(w=>(x.tracks?.[w]?.length??0)>1),ee=[];for(let[w,O]of B){if(O.start===void 0)continue;let J=O.start+M(w);if(O.start>=I){let le=Math.max(0,I-f);t(`${O.path}.at`,"never-seen",O.start-I<f/2?`Layer "${w}" starts at ${O.start.toFixed(3)} s, the moment scene "${C}" ends, so it is never on screen.`:`Layer "${w}" starts at ${O.start.toFixed(3)} s, after scene "${C}" ends at ${I.toFixed(3)} s.`,`Times snap to whole frames at ${m} fps, so the last frame a layer can start on is ${le.toFixed(3)} s. Start it earlier or make the scene longer.`);continue}O.cycles&&O.cues?ee.push({path:O.path,id:w,start:O.start,cues:O.cues}):J>I+1e-6&&r(O.path,"cut-off",`Layer "${w}" finishes at ${J.toFixed(2)} s, ${(J-I).toFixed(2)} s after scene "${C}" ends.`,x.length!==void 0?`Raise the scene length to at least ${J.toFixed(2)}, or start the layer earlier.`:"Start the layer earlier.");let N=W.get(w),_=X(O.layer.exit,`${O.path}.exit`,!0),q;if(_){let le=typeof O.layer.exit=="object"&&O.layer.exit.at!==void 0?E(O.layer.exit.at,`${O.path}.exit.at`,void 0):I-_.duration;le!==void 0&&(q={..._,start:b(Math.max(0,le))},q.start<O.start?t(`${O.path}.exit.at`,"exit-before-enter",`Layer "${w}" leaves at ${q.start.toFixed(2)} s, before it arrives at ${O.start.toFixed(2)} s.`):q.start<J-1e-6&&r(`${O.path}.exit`,"exit-early",`Layer "${w}" starts leaving at ${q.start.toFixed(2)} s while it is still arriving (until ${J.toFixed(2)} s).`))}let re;if(O.layer.parallax!==void 0){let le=`${O.path}.parallax`,ue=O.layer.parallax,fe=he(ue)?{depth:ue}:ue;if(!ge(fe)||!he(fe.depth)||fe.depth<0||fe.depth>10)t(le,"bad-value","parallax is a depth from 0 to 10 (1 travels with the scene, above 1 is nearer), or { depth, home }.");else{s(fe,["depth","home"],le);let ye=fe.home===void 0?I:E(fe.home,`${le}.home`,void 0);ye!==void 0&&(re={depth:fe.depth,home:Math.min(ye,I)}),Q||r(le,"unused",`Scene "${C}"'s camera does not travel, so parallax has nothing to follow.`,"Give the scene x or y tracks, or a follow."),x.follow&&ge(x.follow)&&x.follow.layer===w&&t(le,"bad-follow",`The camera follows "${w}", so it cannot also travel against the camera.`)}}let ne,oe=O.start;if(O.layer.taps!==void 0){let le=`${O.path}.taps`;Array.isArray(O.layer.taps)?(ne=[],O.layer.taps.forEach((ue,fe)=>{let ye=`${le}.${fe}`,me=ge(ue)?ue:{at:ue};ge(ue)&&s(ue,["at","ring","mark"],ye);let xe=ge(ue)&&typeof ue.mark=="string"?ue.mark:void 0;xe!==void 0&&O.layer.use!=="rig/footage-plane"&&t(`${ye}.mark`,"bad-value","Only a rig/footage-plane has marks to tap.");let we=E(me.at,ge(ue)?`${ye}.at`:ye,void 0);me.ring!==void 0&&me.ring!==!1&&typeof me.ring!="string"&&t(`${ye}.ring`,"bad-value","ring is the id of a layer in this scene, or false for no ring."),we!==void 0&&((we<oe||q&&we>q.start)&&r(ye,"tap-hidden",`Layer "${w}" is tapped at ${we.toFixed(2)} s, when it is not on screen.`),ne.push({t:b(we),ring:me.ring===!1?null:typeof me.ring=="string"?me.ring:w,...xe?{mark:xe}:{}}))}),ne.sort((ue,fe)=>ue.t-fe.t)):t(le,"bad-value","taps is a list of times, or of { at, ring }.",'e.g. "taps": ["3.25b"]')}U.push({id:w,use:O.layer.use,start:O.start,duration:O.duration,end:J,props:O.props,params:O.params,...O.cues?{cues:O.cues}:{},...O.speed!==void 0?{speed:O.speed}:{},...N?{enter:{...N,start:O.start}}:{},...q?{exit:q}:{},...re?{parallax:re}:{},...ne?.length?{taps:ne}:{},source:O.layer})}for(let w of U){if(w.use!=="ui/cursor-click"||typeof w.props.target!="string"||!w.props.target)continue;let O=U.find(J=>J.id===w.props.target);if(!O){let J=Fe(w.props.target,U.map(N=>N.id));t(`${A}.layers.${w.id}.props.target`,"unknown-layer",`Scene "${C}" has no layer "${w.props.target}" for the cursor to click.`,J?`Did you mean "${J}"?`:void 0);continue}(O.taps??=[]).push({t:b(w.start+qr(w.params)),ring:O.id}),O.taps.sort((J,N)=>J.t-N.t)}if(U.forEach(w=>w.taps?.forEach((O,J)=>{if(O.ring!==null&&!U.some(N=>N.id===O.ring)){let N=Fe(O.ring,U.map(_=>_.id));t(`${A}.layers.${w.id}.taps.${J}.ring`,"unknown-layer",`Scene "${C}" has no layer "${O.ring}" to draw a tap's ring around.`,N?`Did you mean "${N}"?`:void 0)}})),x.follow!==void 0){let w=`${A}.follow`,O=x.follow;if(!ge(O))t(w,"bad-follow","follow is { layer, at, lag, blend }.");else{s(O,["layer","at","lag","blend"],w);let J=typeof O.layer=="string"?U.find(N=>N.id===O.layer):void 0;if(J)Ot.includes(J.use)||t(`${w}.layer`,"bad-follow",`${J.use} has no tip to follow.`,`The camera can follow: ${ve(Ot)}.`);else{let N=U.filter(q=>Ot.includes(q.use)).map(q=>q.id),_=typeof O.layer=="string"?Fe(O.layer,N):void 0;t(`${w}.layer`,"unknown-layer",`Scene "${C}" has no layer "${String(O.layer)}" to follow.`,_?`Did you mean "${_}"?`:N.length?`Lines here: ${ve(N)}.`:`Add a line to follow: ${ve(Ot)}.`)}O.at!==void 0&&!(Array.isArray(O.at)&&O.at.length===2&&O.at.every(N=>he(N)&&N>=0&&N<=100))&&t(`${w}.at`,"bad-value","at is [x, y] in % of the stage, 0 to 100.","The middle is [50, 50].");for(let N of["lag","blend"])O[N]!==void 0&&!(he(O[N])&&O[N]>=0)&&t(`${w}.${N}`,"bad-time",`${N} is seconds, zero or more.`)}}let ie;if(x.camera!==void 0){let w=`${A}.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 O=["x","y","scale"].filter(q=>x.tracks?.[q]!==void 0);O.length&&t(`${A}.tracks`,"bad-camera",`The framing camera sets x, y and scale itself, so tracks ${O.join(", ")} would fight it.`,"Move them into camera keys: frame, offset and zoom. rotate, rotateX and rotateY tracks still apply.");let J=U.map(q=>q.id),N=(q,re,ne)=>Array.isArray(q)&&q.length===2&&q.every(oe=>he(oe)&&oe>=re&&oe<=ne),_={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((q,re)=>{let ne=`${w}.${re}`;if(!ge(q)){t(ne,"bad-camera","A camera key is an object: { at, frame, zoom, anchor, tilt, ease }.");return}s(q,["at","frame","point","offset","zoom","anchor","tilt","rotate","ease","drift"],ne);let oe=y(q.at,`${ne}.at`,"at");if(oe===void 0)return;ie.length&&oe<ie[ie.length-1].t&&t(`${ne}.at`,"bad-order",`Camera keys run in time order; this one (${oe.toFixed(2)} s) comes before the key above it.`),oe>I+1e-6&&r(`${ne}.at`,"after-end",`This key (${oe.toFixed(2)} s) is after scene "${C}" ends (${I.toFixed(2)} s).`,"A key past the cut is fine for a camera that keeps moving through the cut; otherwise move it earlier.");let le={..._,t:oe,drift:0};if(q.ease!==void 0){let ue=v(q.ease,`${ne}.ease`);ue!==void 0&&(le.ease=ue)}else delete le.ease;if(q.frame!==void 0)if(typeof q.frame=="string"){let[ue,fe]=q.frame.split("#");if(J.includes(ue))fe!==void 0&&U.find(ye=>ye.id===ue)?.use!=="rig/footage-plane"?t(`${ne}.frame`,"bad-camera",`"${q.frame}" frames a mark, and only a rig/footage-plane has marks.`,`Frame the layer itself: "${ue}".`):fe===""&&t(`${ne}.frame`,"bad-camera",'Name the mark after the #: "plane#send", as given to motion record --marks.');else{let ye=Fe(ue,J);t(`${ne}.frame`,"unknown-layer",`Scene "${C}" has no layer "${ue}" to frame.`,ye?`Did you mean "${ye}"?`:`Layers: ${ve(J)}.`)}le.frame=q.frame}else N(q.frame,0,100)?le.frame=[q.frame[0],q.frame[1]]:t(`${ne}.frame`,"bad-value","frame is a layer id, or [x, y] in % of the stage.");q.point!==void 0&&(N(q.point,0,1)?le.point=[q.point[0],q.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].")),q.offset!==void 0&&(Array.isArray(q.offset)&&q.offset.length===2&&q.offset.every(he)?le.offset=[q.offset[0],q.offset[1]]:t(`${ne}.offset`,"bad-value","offset is [dx, dy] in px.")),q.anchor!==void 0&&(N(q.anchor,0,100)?le.anchor=[q.anchor[0],q.anchor[1]]:t(`${ne}.anchor`,"bad-value","anchor is [x, y] in % of the stage, 0 to 100.")),q.tilt!==void 0&&(N(q.tilt,-80,80)?le.tilt=[q.tilt[0],q.tilt[1]]:t(`${ne}.tilt`,"bad-value","tilt is [about x, about y] in degrees, -80 to 80.")),q.zoom!==void 0&&(he(q.zoom)&&q.zoom>0?le.zoom=q.zoom:t(`${ne}.zoom`,"bad-value","zoom is a number above 0; 1 is the stage as laid out.")),q.rotate!==void 0&&(he(q.rotate)?le.rotate=q.rotate:t(`${ne}.rotate`,"bad-value","rotate is degrees.")),q.drift!==void 0&&(he(q.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."):le.drift=q.drift:t(`${ne}.drift`,"bad-value","drift is zoom per second, such as 0.02.")),ie.push(le),_=le}),x.perspective!==void 0&&!(he(x.perspective)&&x.perspective>=100)&&t(`${A}.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"&&!(he(x.motionBlur)&&x.motionBlur>=0&&x.motionBlur<=1)&&t(`${A}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1.");let de,ce=0;if(x.out!==void 0){let w=`${A}.out`,O=ge(x.out)&&typeof x.out.use=="string"?ze[x.out.use]:void 0;if(O){s(x.out,["use","duration","params"],w);let J=d.transitions==="calm"&&O.calm?Object.fromEntries(Object.entries(O.params).map(([q,re])=>[q,q in O.calm?{...re,default:O.calm[q]}:re])):O.params,N=T(x.out.params,J,`${w}.params`,O.slug);if(x.out.duration!==void 0){let q=y(x.out.duration,`${w}.duration`,"duration");q!==void 0&&(N.duration=q)}let _=b(he(N.duration)?N.duration:0);$===i.scenes.length-1?r(w,"unused",'The last scene has nothing to hand over to, so "out" is ignored.'):_>=I?t(`${w}.duration`,"too-long",`The hand-over (${_.toFixed(2)} s) is not shorter than scene "${C}" (${I.toFixed(2)} s).`):(de={use:O.slug,duration:_,params:N},ce=he(N.duration)?N.duration:0)}else{let J=Object.keys(ze),N=ge(x.out)?String(x.out.use):"",_=Fe(N,J);t(`${w}.use`,"unknown-transition",`There is no code for transition "${N}".`,_?`Did you mean "${_}"?`:`Transitions: ${ve(J)}.`)}}let pe=I-(de?de.duration/2:0);for(let w of ee){let O=w.cues.find(J=>w.start+J.at<pe-1e-6&&w.start+J.at+J.length>pe+1e-6);O&&r(w.path,"cut-mid-change",`Scene "${C}" is last seen at ${pe.toFixed(2)} s, in the middle of a change of layer "${w.id}" (${(w.start+O.at).toFixed(2)}\u2013${(w.start+O.at+O.length).toFixed(2)} s).`,"End the scene on a rest: after the change, or before it begins.")}S.set(C,{length:k??I,out:ce}),D.push({id:C,start:0,length:I,end:I,layers:U,...de?{out:de}:{},...ie?{camera:ie}:{},source:V?{...x,tracks:V}:x})});let j=0;D.forEach((x,$)=>{let C=D[$-1];C?.out&&(C.out.duration>=x.length&&t(`scenes.${C.id}.out.duration`,"too-long",`The hand-over (${C.out.duration.toFixed(2)} s) is not shorter than the next scene "${x.id}" (${x.length.toFixed(2)} s).`),j-=S.get(C.id)?.out??C.out.duration),x.start=b(j),j+=S.get(x.id)?.length??x.length,x.end=b(j),x.length=x.end-x.start}),Us(D,f,t);let Z=b(j);return i.poster!==void 0&&(!he(i.poster)||i.poster<0||i.poster>Z)&&t("poster","bad-time",`poster is a time inside the film, 0 to ${Z.toFixed(2)} s.`),a(d,{duration:Z,fps:m,frames:Math.round(Z*m),size:[o[0],o[1]],scenes:D,...c?{tempo:c}:{},...i.loop?{loop:!0}:{},...p?{audio:p}:{}})}function Us(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("."),d=e.find(y=>y.id===o),m=d?.layers.find(y=>y.id===u);if(!d||!m){t(i,"unknown-layer",`There is no layer "${s}" to continue.`,'Name a video layer as "scene.layer".');continue}if(m.use!=="el/video"){t(i,"bad-value",`"${s}" is ${m.use}, not el/video.`);continue}if(m===a){t(i,"self-reference","A video layer cannot continue itself.");continue}m.props.src!==a.props.src&&t(i,"bad-value",`"${s}" plays ${String(m.props.src)}, a different file.`,"A continuation plays the same footage.");let c=Math.min(d.length,m.exit?m.exit.start+m.exit.duration:d.length)-n,p=typeof m.params.rate=="number"?m.params.rate:1,g=Math.max(0,c-m.start),f=typeof m.props.from=="number"?m.props.from:0,b=typeof m.props.to=="number"?m.props.to:0,h=f+g*p;m.params.loop===!0&&b>f?h=f+g*p%(b-f):b>f&&(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.")}}var Xa=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Vs=new Set(["scenes","layers"]);function Ys(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(d=>Xa(d)&&d.id===i);if(!u||o)return!1;a=u;continue}if(!Xa(a))return!1;if(o)return t===null?delete a[i]:a[i]=t,!0;if(a[i]===void 0){if(Vs.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 Ua(e,n){let t=structuredClone(e),r=[],a=[];for(let[s,i]of Object.entries(n?.set??{}))(Ys(t,s,structuredClone(i))?a:r).push(s);return{film:t,orphans:r,applied:a}}var Va=`
|
|
8
|
+
Motion.`},style:{size:"headline",width:86,css:Re}};case"type/word-roller":return{id:n,use:e,props:{before:"Made for",words:["teams","films","brands"]},style:{size:"headline",css:Re}};case"type/tracking-in":return{id:n,use:e,props:{text:t??"ATLAS"},style:{size:"hero"}};case"type/shimmer":return{id:n,use:e,props:{text:t??"Shipped"},style:{size:"hero"}};case"type/echo":return{id:n,use:e,props:{text:t&&t.length<=12?t:"Again"},style:{size:"hero"}};case"type/scribble-highlight":return{id:n,use:e,props:{text:t??"Ship it today",mark:[(t??"Ship it today").split(/\s+/).pop()??""]},params:{delay:.1},style:{size:"headline",width:86,css:Re}};case"fx/odometer":return{id:n,use:e,props:{value:12480},style:{size:"hero"}};case"scene/grid-wall":{let r=s=>`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4"><rect width="4" height="4" fill="${s}"/></svg>`)}`,a=[1.3,.75,1,1.5,.8,1.2,.7,1.4,1,.9,1.6,.8];return{id:n,use:e,props:{images:a.map((s,i)=>r(["#9C9C9B","#B5B5B4","#7A7A79"][i%3])),ratios:a},params:{columns:4,width:70,gap:20,drift_speed:0}}}case"fx/path-draw":return{id:n,use:e,props:{paths:["M10 50 C 30 10, 70 10, 90 50 S 70 90, 50 70","M20 80 L 80 20"],viewbox:"0 0 100 100"},params:{width:30,stroke:4}};case"fx/shape-morph":return{id:n,use:e,props:{shapes:["circle","squircle","star"]},params:{size:34}};case"fx/grid-ripple":return{id:n,use:e,params:{cols:20,opacity:.8}};case"scene/logo-reveal":return{id:n,use:e,props:{name:"Atlas",tagline:t??""},style:{size:"hero"}};case"scene/bar-chart":return{id:n,use:e,props:{values:[32,48,41,76,58],labels:["A","B","C","D","E"],highlight:"D"},params:{width:70,height:62},style:{size:"headline"}};case"scene/line-chart":return{id:n,use:e,props:{values:[12,18,15,24,22,31,29,42]},params:{width:80,height:60,draw:1.4},style:{size:"headline"}};case"texture/gradient-drift":return{id:n,use:e,params:{period:6}};case"texture/grain":return{id:n,use:e,params:{amount:.22}};case"texture/vignette":return{id:n,use:e,screen:!0,params:{strength:1,mid:.7}};case"texture/beat-field":return{id:n,use:e,params:{glow:.3,ring:.45,paper:.08}};case"ui/cursor-click":return{id:n,use:e,params:{size:4}};case"type/fill-text":return{id:n,use:e,props:{text:t??"Noise into signal",accent:t?[]:["signal"]},style:{size:"headline",width:86,css:Re}};case"texture/signal-field":return{id:n,use:e,params:{cols:24,settle_at:.4}};case"rig/tab-stack":return{id:n,use:e,props:{items:["Monitor","Detect","Respond","Report"],details:["","","","Every signal, in one place."]},params:{width:80,slide_at:.5,slide:1.2}};case"rig/layer-stack":return{id:n,use:e,props:{items:["Base","Rules","Parts","Uses"],name:"One layer"},params:{width:46,gap:150,start:.5,travel:.7}};case"rig/footage-plane":return{id:n,use:e,place:{x:50,y:50},props:{src:Ze},params:{width:900,radius:20}};case"rig/browser-window":return{id:n,use:e,props:{lift:[36,54,28,38]},params:{width:90,move:.9}};case"fx/slow-push":return{id:n,use:e,props:{src:Ze},params:{width:1040,height:780,radius:24,from:1,to:1.16,pan_x:-6,duration:3}};case"fx/pan-across":return{id:n,use:e,props:{src:Ze},params:{width:560,height:780,aspect:800/600,from:10,to:90,duration:3}};case"ui/page-scroll":return{id:n,use:e,props:{srcs:tt,stops:[45]},params:{width:1e3,height:820,radius:24,duration:2.6,rest:.5,delay:.3}};case"scene/bento-grid":{let r=a=>`<b style="font:700 calc(var(--m-u) * 6)/1 var(--m-font-display);color:var(--m-text-primary)">${a}</b>`;return{id:n,use:e,props:{areas:"a b c / d b e",counts:[1,2,2,2,2],items:[r("Atlas"),Ze,tt[1],r("01"),r("02"),tt[0],Ze,r("Go"),r("On")]},params:{width:84,hold:1.25,swap_time:.5,offset:.2,stagger:0}}}case"scene/post-carousel":return{id:n,use:e,props:{slides:[Ze,tt[1],tt[0]],handle:"atlas"},params:{width:30,hold:.8,turn:.6,loop:!0}};case"scene/strip-cycle":return{id:n,use:e,props:{images:[Ze,tt[0]],fills:["accent","inverse"]},params:{rows:6,hold:.6,shift:.7,stagger:.05,empty:"both"}};case"fx/pin-drop":return{id:n,use:e,props:{points:[28,70,70,55],labels:["Found","Here"]},params:{size:28,stem:220}};default:return}}var Ps=new Set(["scene/marquee-wall","scene/bento-grid","texture/halftone-field","texture/gradient-drift","texture/grain","texture/vignette","texture/beat-field","fx/grid-ripple","ui/cursor-click","texture/signal-field","fx/pin-drop","scene/strip-cycle"]),zs=e=>{let n=ze[e]?.duration;return typeof n=="number"?n:.8};function $a(e,n){if(e.startsWith("transition/"))return Ct(e,[ft("before",[{id:"a",use:"el/text",props:{text:"Before"},style:{size:"hero"}}],{length:Math.max(1.4,zs(e)+.6),background:"base",out:{use:e}}),ft("after",[{id:"b",use:"el/text",props:{text:"After"},style:{size:"hero"}}],{length:1.6,background:"inverse"})],n);let t=Fa(e);if(!t)return;let r=Ps.has(e);return Ct(e,[ft("only",[t],{hold:1.2,background:e==="rig/orbit-ring"?"sunken":"base",...r?{length:3.5,layout:{padding:0,justify:"center"}}:{}})],n)}function Ta(e,n){return Ct(e,[ft("feel",[{id:"line",use:"type/word-build",props:{text:"Every move, on time"},style:{size:"headline"}},{id:"chips",use:"fx/stagger-fill",at:"line.end - 0.2",props:{items:["One","Two","Three","Four"]},style:{size:"title"}}],{hold:"$hold_end"})],n,{tokens:Ae[e].tokens})}function Ea(e,n,t=7){let r=e.beats.map((a,s)=>{let i=a.primitives.map(m=>Fa(m,"beat",a.content)).find(Boolean),o={id:"label",use:"el/text",props:{text:`${s+1}/${e.beats.length} ${a.name}`},place:{x:5,y:8,anchor:"top-left"},style:{size:"title",color:"muted",css:{"font-size":"calc(var(--m-u) * 4.4)"}}},u=i??{id:"beat",use:"el/text",props:{text:a.content},style:{size:"headline",width:86,css:Re},enter:{move:"rise",amount:40}},d=Math.max(.6,Math.round(a.share/100*t*10)/10);return ft(`b${s+1}`,[o,u],{length:d,background:s%2?"sunken":"base"})});return Ct(e.slug,r,n)}function Sa(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=>Ne(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 d=r[u-1],m=r[u],c=m[0]-d[0],p=c<=0?1:a[u]((s-d[0])/c);return d[1]+(m[1]-d[1])*p}}var We=(e,n,t)=>e+(n-e)*t;function Ca(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(We(Math.log(r.zoom),Math.log(a.zoom),s))*Math.max(.01,i),u=[We(r.target[0],a.target[0],s),We(r.target[1],a.target[1],s)],d=[We(r.anchor[0],a.anchor[0],s),We(r.anchor[1],a.anchor[1],s)],m=We(r.rotate,a.rotate,s);return{...Rs(u,d,o,m,t),scale:o,rotate:m,rotateX:We(r.tilt[0],a.tilt[0],s),rotateY:We(r.tilt[1],a.tilt[1],s),pivot:[d[0]-t[0]/2,d[1]-t[1]/2]}}function Rs(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 Qt=.08,Aa=.35,_t=.07,Pa=.5,Ls=12,Os=.7,Ds=rt(.34,1.36,.64,1),Bs=rt(.22,1,.36,1);function za(e,n){let t=1;for(let r of e){let a=n-r;a<-Qt||a>Aa||(t*=a<0?1-_t*((a+Qt)/Qt):1-_t+_t*Ds(a/Aa))}return t}function Ra(e,n){let t;for(let a of e)n>=a&&n-a<=Pa&&(t===void 0||a>t)&&(t=a);if(t===void 0)return;let r=(n-t)/Pa;return{grow:Ls*Bs(r),opacity:Os*(1-r)}}var At=["x","y","scale","rotate","opacity","blur","rotateX","rotateY","skew"],Pt=["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"],La=["wipe","slide"],en=["hero","headline","title","body","caption"],tn=["primary","secondary","muted","accent","inverse","on-accent"],nn=["center","top-left","top","top-right","left","right","bottom-left","bottom","bottom-right"],Oa=["%","px"],rn=["cover","contain","width","height"];var an=["zero","graphite","hockney"];var Is={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}},zt=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Rt(e,n){if(!zt(e)||!zt(n))return n===void 0?e:n;let t={...e};for(let[r,a]of Object.entries(n))t[r]=Rt(t[r],a);return t}var Lt=(...e)=>e.reduce((n,t)=>Rt(n,t),Is);function sn(e){let n=[],t=(r,a)=>{if(zt(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 gt(e,n){let t=e;for(let r of n.replace(/^\$/,"").split(".")){if(!zt(t)||!(r in t))return;t=t[r]}return t}var Xe=e=>typeof e=="string"&&e.startsWith("$");var Ba=/^\s*(\d+(?:\.\d+)?)\s*(b|beats?|bars?)\s*$/,Le=e=>typeof e=="string"&&Ba.test(e),Da=e=>60/e.bpm;function Ia(e,n){let t=Ba.exec(e);if(!t)return;let r=Number(t[1]);return t[2].startsWith("bar")?r*n.bar*Da(n):r*Da(n)}var Wa=(e,n)=>n*60/e.bpm;function ja(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 Na=/^[a-z][a-z0-9-]*$/;function Ha(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 qa(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 ge=e=>!!e&&typeof e=="object"&&!Array.isArray(e),he=e=>typeof e=="number"&&Number.isFinite(e),Ws=["$schema","motion","title","size","fps","seed","poster","loop","narrative","style","tokens","tempo","audio","theme","scenes"],js=["id","length","hold","background","scheme","layout","artboard","layers","tracks","follow","camera","perspective","motionBlur","out","uses","intent"],Ot=["fx/path-draw"],Ns=["id","use","props","params","at","style","place","enter","exit","tracks","motionBlur","parallax","screen","taps","reflow"],Hs=["size","color","font","weight","align","width","css"],qs={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},Zs={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 Xs(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=Xs(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 ve=e=>e.join(", ");function Za(e){let n=[],t=(x,$,C,A)=>n.push({level:"error",code:$,path:x,message:C,...A?{hint:A}:{}}),r=(x,$,C,A)=>n.push({level:"warning",code:$,path:x,message:C,...A?{hint:A}:{}}),a=(x,$)=>{let C=!n.some(A=>A.level==="error");return{ok:C,issues:n,tokens:x,...C&&$?{timeline:$}:{}}},s=(x,$,C)=>{for(let A of Object.keys(x)){if($.includes(A))continue;let V=Fe(A,$);t(C?`${C}.${A}`:A,"unknown-key",`"${A}" is not a field here.`,V?`Did you mean "${V}"?`:`Fields: ${ve($.filter(B=>B!=="$schema"))}.`)}};if(!ge(e))return t("","not-a-film","A film is a JSON object."),a(Lt());let i=e;s(e,Ws,""),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 d=Lt(ge(i.tokens)?i.tokens:void 0);if(i.tokens!==void 0)if(!ge(i.tokens))t("tokens","bad-tokens","tokens is an object of overrides.");else{let x=sn(Lt()),$=(C,A)=>{if(ge(C)&&!("spring"in C)){for(let[V,B]of Object.entries(C))$(B,A?`${A}.${V}`:V);return}if(!x.includes(A)){let V=Fe(A,x);t(`tokens.${A}`,"unknown-token",`There is no token "${A}".`,V?`Did you mean "${V}"?`:`Tokens: ${ve(x)}.`)}};$(i.tokens,"")}d.transitions!=="standard"&&d.transitions!=="calm"&&t("tokens.transitions","bad-value",'transitions is "standard" or "calm".',"Calm swaps every transition's defaults for its quiet preset.");let m=i.fps??d.fps;(!Number.isInteger(m)||m<=0)&&t("fps","bad-fps","fps is a whole number above zero.");let c;if(i.tempo!==void 0){let x=i.tempo;if(!ge(x)||!he(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 $=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($)||$<2||$>12)t("tempo.bar","bad-value","bar is a whole number of beats, 2 to 12.");else{c={bpm:x.bpm,bar:$};let C=Number.isInteger(m)&&m>0?Wa(c,m):1;Math.abs(C-Math.round(C))>1e-6&&i.audio===void 0&&r("tempo.bpm","beat-off-frame",`At ${m} fps a beat of ${c.bpm} bpm is ${C.toFixed(2)} frames, so beats fall between frames and drift.`,`Tempos with a whole number of frames per beat near it: ${ja(c.bpm,m).join(", ")} bpm.`)}}}let p;if(i.audio!==void 0){let x=i.audio;if(!ge(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 $=(C,A,V,B,X)=>{let W=x[C]===void 0?A:x[C];return!he(W)||W<V||W>B?(t(`audio.${C}`,"bad-value",`${C} is ${X}, ${V} to ${B}.`),A):W};p={src:x.src,from:$("from",0,0,36e3,"seconds into the file"),gain:$("gain",0,-30,6,"a level in dB"),fade_in:$("fade_in",0,0,10,"seconds"),fade_out:$("fade_out",0,0,10,"seconds")}}}let g=(x,$)=>{if(!c){t($,"needs-tempo",`"${x}" is in beats, but the film has no tempo.`,'Add "tempo": {"bpm": 120} to the film, or write seconds.');return}return Ia(x,c)};if(i.theme!==void 0)if(!ge(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&&!an.includes(i.theme.ui)&&t("theme.ui","bad-value",`ui is one of the bundled themes: ${an.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(d);if(!u||!Number.isInteger(m)||m<=0)return a(d);let f=1/m,b=x=>Math.round(x*m)/m,h={tokens:d,seed:i.seed??1,size:[o[0],o[1]]},y=(x,$,C)=>{if(Le(x))return g(x,$);let A=Xe(x)?gt(d,x):x;if(Xe(x)&&A===void 0){let V=sn(d).map(X=>`$${X}`),B=Fe(x,V);t($,"unknown-token",`There is no token "${x}".`,B?`Did you mean "${B}"?`:void 0);return}if(!he(A)||A<0){t($,"bad-time",`${C} is a number of seconds, zero or more, a $token, or beats such as "2b" or "1bar".`);return}return A},v=(x,$)=>{let C=Xe(x)?gt(d,x):x;if(!fn(C)||typeof C=="string"&&!at.includes(C)){let A=typeof C=="string"?Fe(C,at):void 0;t($,"bad-ease",'An ease is a name, a [x1, y1, x2, y2] bezier, or {"spring": {"duration", "bounce"}}.',A?`Did you mean "${A}"?`:`Names: ${ve(at)}.`);return}return C},R=(x,$)=>{if(x===void 0)return;if(!ge(x)){t($,"bad-tracks","tracks is an object of keyframe lists by property.");return}let C={};for(let[A,V]of Object.entries(x)){let B=`${$}.${A}`;if(!At.includes(A)){let X=Fe(A,At);t(B,"unknown-track",`"${A}" cannot be animated by a track.`,X?`Did you mean "${X}"?`:`Properties: ${ve(At)}.`);continue}if(!Array.isArray(V)||V.length===0){t(B,"bad-track","A track is a list of [seconds, value] keys.");continue}C[A]=V.map((X,W)=>{let M=Array.isArray(X)&&Le(X[0])?g(X[0],`${B}.${W}`):Array.isArray(X)?X[0]:void 0;return!Array.isArray(X)||!he(M)||!he(X[1])?(t(`${B}.${W}`,"bad-key",'A key is [time, value] or [time, value, ease]; time in seconds or beats ("2b").'),X):(X[2]!==void 0&&v(X[2],`${B}.${W}`),X.length>2?[M,X[1],X[2]]:[M,X[1]])})}return C},T=(x,$,C,A)=>{let V={};for(let[B,X]of Object.entries($)){let W=X.default;V[B]=Xe(W)?gt(d,W):W}if(x===void 0)return V;if(!ge(x))return t(C,"bad-params","params is an object."),V;for(let[B,X]of Object.entries(x)){let W=`${C}.${B}`,M=$[B];if(!M){let Y=Object.keys($),K=Fe(B,Y);t(W,"unknown-param",`${A} has no param "${B}".`,K?`Did you mean "${K}"?`:Y.length?`Params: ${ve(Y)}.`:`${A} has no params.`);continue}if(Le(X)&&!(M.type==="number"&&M.unit==="s")){t(W,"bad-param",`${B} is not a time, so it cannot be in beats.`);continue}let H=Le(X)?g(X,W):Xe(X)?gt(d,X):X;if(!(Le(X)&&H===void 0)){if(Xe(X)&&H===void 0){t(W,"unknown-token",`There is no token "${X}".`);continue}if(M.type==="number"){if(!he(H)){t(W,"bad-param",`${B} is a number${M.unit?` (${M.unit})`:""}.`);continue}(M.min!==void 0&&H<M.min||M.max!==void 0&&H>M.max)&&r(W,"out-of-range",`${B} is ${H}; the library's range is ${M.min}\u2013${M.max}${M.unit?` ${M.unit}`:""}.`,"Allowed, but outside what has been seen to look right. Check the frames.")}else if(M.type==="ease"){if(v(H,W)===void 0)continue}else if(M.type==="boolean"){if(typeof H!="boolean"){t(W,"bad-param",`${B} is true or false.`);continue}}else if(M.type==="choice"&&!(M.options??[]).includes(String(H))){t(W,"bad-param",`${B} is one of: ${ve(M.options??[])}.`);continue}V[B]=H}}return V},F=new Set,D=[],S=new Map;i.scenes.forEach((x,$)=>{let C=ge(x)&&typeof x.id=="string"?x.id:String($),A=`scenes.${C}`;if(!ge(x)){t(A,"bad-scene","A scene is an object.");return}if(s(x,js,A),typeof x.id!="string"||!Na.test(x.id)?t(`${A}.id`,"bad-id",Ha(x.id,"scene"),qa(x.id,"scene",'For example "title" or "stat-2".')):F.has(x.id)&&t(`${A}.id`,"duplicate-id",`Two scenes are called "${x.id}".`),F.add(C),x.scheme!==void 0&&x.scheme!=="light"&&x.scheme!=="dark"&&t(`${A}.scheme`,"bad-value",'scheme is "light" or "dark".'),x.layout!==void 0&&(ge(x.layout)?s(x.layout,["align","justify","gap","padding"],`${A}.layout`):t(`${A}.layout`,"bad-layout","layout is { align, justify, gap, padding }.")),x.artboard!==void 0){let w=x.artboard,O=`${A}.artboard`;if(!ge(w))t(O,"bad-artboard","artboard is { width, height } in the design's pixels, with an optional fit and align.");else{s(w,["width","height","fit","align"],O);for(let J of["width","height"])(!he(w[J])||w[J]<1||w[J]>2e4)&&t(`${O}.${J}`,"bad-value",`${J} is the design's ${J} in its own pixels, 1 to 20000.`);w.fit!==void 0&&!rn.includes(w.fit)&&t(`${O}.fit`,"bad-value",`fit is one of: ${ve(rn)}.`),w.align!==void 0&&!(Array.isArray(w.align)&&w.align.length===2&&w.align.every(J=>he(J)&&J>=0&&J<=100))&&t(`${O}.align`,"bad-value","align is [x, y], each 0 to 100: where the artboard sits along each side of the stage.")}}let V=R(x.tracks,`${A}.tracks`);if(!Array.isArray(x.layers)){t(`${A}.layers`,"no-layers","A scene has a list of layers. It may be empty.");return}let B=new Map;x.layers.forEach((w,O)=>{let J=ge(w)&&typeof w.id=="string"?w.id:String(O),N=`${A}.layers.${J}`;if(!ge(w)){t(N,"bad-layer","A layer is an object.");return}if(s(w,Ns,N),typeof w.id!="string"||!Na.test(w.id)||w.id==="scene"){t(`${N}.id`,"bad-id",Ha(w.id,"layer"),qa(w.id,"layer",'For example "headline" or "photo-2".'));return}if(B.has(w.id)){t(`${N}.id`,"duplicate-id",`Two layers in scene "${C}" are called "${w.id}".`);return}let _=typeof w.use=="string"?pt[w.use]:void 0;if(!_){let me=Object.keys(pt),xe=typeof w.use=="string"?Fe(w.use,me):void 0,we=typeof w.use=="string"&&w.use in ze;t(`${N}.use`,"unknown-primitive",`There is no code for "${String(w.use)}".`,we?'That is a transition. Put it on the scene as "out": {"use": ...}.':xe?`Did you mean "${xe}"?`:`Drawable: ${ve(me)}. Compose anything else from el/* layers with enter, exit and tracks.`);return}let q={},re=w.props??{};if(!ge(re))t(`${N}.props`,"bad-props","props is an object.");else{for(let me of Object.keys(re)){if(me in _.props)continue;let xe=Object.keys(_.props),we=Fe(me,xe),mn=me in _.params;t(`${N}.props.${me}`,"unknown-prop",`${_.slug} has no prop "${me}".`,mn?`"${me}" is a motion value. Move it to params.`:we?`Did you mean "${we}"?`:`Props: ${ve(xe)}.`)}for(let[me,xe]of Object.entries(_.props)){let we=re[me];if(we===void 0){xe.required?t(`${N}.props.${me}`,"missing-prop",`${_.slug} needs "${me}": ${xe.label}.`):q[me]=xe.default;continue}if(!(xe.type==="number"?he(we):xe.type==="string[]"?Array.isArray(we)&&we.every(fi=>typeof fi=="string"):xe.type==="number[]"?Array.isArray(we)&&we.every(he):typeof we=="string")){t(`${N}.props.${me}`,"bad-prop",`"${me}" is ${xe.type==="string[]"?"a list of strings":xe.type==="number[]"?"a list of numbers":`a ${xe.type==="html"?"string":xe.type}`}.`);continue}(xe.type==="string[]"||xe.type==="number[]")&&xe.required&&we.length===0&&r(`${N}.props.${me}`,"empty",`"${me}" is empty, so nothing is drawn.`),q[me]=we}}let ne=T(w.params,_.params,`${N}.params`,_.slug);if(w.style!==void 0)if(!ge(w.style))t(`${N}.style`,"bad-style","style is an object.");else{s(w.style,Hs,`${N}.style`);let me=w.style;me.size!==void 0&&!en.includes(me.size)&&t(`${N}.style.size`,"bad-value",`size is one of: ${ve(en)}.`),me.color!==void 0&&!tn.includes(me.color)&&t(`${N}.style.color`,"bad-value",`color is one of: ${ve(tn)}.`,"For any other colour use style.css or a theme variable."),me.width!==void 0&&(!he(me.width)||me.width<=0||me.width>100)&&t(`${N}.style.width`,"bad-value","width is a percentage of the stage, 1 to 100.")}if(w.place!==void 0){let me=w.place;!ge(me)||!he(me.x)||!he(me.y)?t(`${N}.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"],`${N}.place`),me.anchor!==void 0&&!nn.includes(me.anchor)&&t(`${N}.place.anchor`,"bad-value",`anchor is one of: ${ve(nn)}.`),me.unit!==void 0&&!Oa.includes(me.unit)&&t(`${N}.place.unit`,"bad-value",`unit is "%" (of the stage) or "px" (of the scene's artboard).`))}let oe=R(w.tracks,`${N}.tracks`);if(w.reflow!==void 0&&(w.reflow!=="glide"?t(`${N}.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(`${N}.reflow`,"unused",`Layer "${J}" 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(`${N}.screen`,"bad-value","screen is true (fixed to the screen, outside the camera) or false."),w.screen===!0&&w.parallax!==void 0&&t(`${N}.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"&&!(he(w.motionBlur)&&w.motionBlur>=0&&w.motionBlur<=1)&&t(`${N}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1."),_.check)try{for(let me of _.check(q,ne,h))t(`${N}.${me.path}`,"bad-value",me.message,me.hint)}catch{}let le=0;try{le=_.duration(q,ne,h)}catch{}let ue;try{ue=_.cues?.(q,ne,h)}catch{}let fe;try{fe=_.speed?.(q,ne,h)}catch{}let ye=oe?{...w,tracks:oe}:w;B.set(w.id,{layer:ye,path:N,duration:Number.isFinite(le)?le:0,params:ne,props:q,...ue?{cues:ue}:{},..._.cycles?{cycles:!0}:{},...fe!==void 0&&Number.isFinite(fe)?{speed:fe}:{}})});let X=(w,O,J)=>{if(w===void 0)return;let N=typeof w=="string"?{move:w}:w;if(!ge(N)||!Pt.includes(N.move)){let ue=ge(N)&&typeof N.move=="string"?Fe(N.move,Pt):void 0;t(O,"unknown-move",`A move is one of: ${ve(Pt)}.`,ue?`Did you mean "${ue}"?`:void 0);return}s(N,J?["move","duration","ease","amount","angle","feather","at"]:["move","duration","ease","amount","angle","feather"],O);let _=N.move.startsWith("mask-")||N.move.startsWith("wipe-"),q;N.feather!==void 0&&N.feather!==!1&&(N.feather!==!0&&!(he(N.feather)&&N.feather>=0&&N.feather<=200)?t(`${O}.feather`,"bad-value","feather is a soft edge in px (0 to 200), or true for a tenth of the line height."):_?(N.feather===!0||N.feather>0)&&(q=N.feather):r(`${O}.feather`,"unused",`${N.move} has no edge to soften, so feather is ignored.`,"Feather mask-up, mask-down and the wipe-* moves."));let re=La.includes(N.move);N.angle!==void 0&&(he(N.angle)?re||r(`${O}.angle`,"unused",`${N.move} has a fixed direction, so angle is ignored.`,'Use "wipe" or "slide" to travel at an angle.'):t(`${O}.angle`,"bad-value","angle is degrees: 0 rightwards, 90 downwards, 180 leftwards, 270 upwards."));let ne=N.duration===void 0?J?d.duration.fast:d.duration.base:y(N.duration,`${O}.duration`,"duration"),oe=Zs[N.move],le=N.ease===void 0?oe?oe[J?"exit":"enter"]:J?d.ease_exit:d.ease_enter:v(N.ease,`${O}.ease`);if(N.amount!==void 0&&!he(N.amount)&&t(`${O}.amount`,"bad-value","amount is a number."),!(ne===void 0||le===void 0))return{move:N.move,duration:ne,ease:le,amount:he(N.amount)?N.amount:qs[N.move],...re?{angle:he(N.angle)?N.angle:0}:{},...q!==void 0?{feather:q}:{}}},W=new Map;for(let[w,O]of B){let J=X(O.layer.enter,`${O.path}.enter`,!1);J&&W.set(w,J)}let M=w=>Math.max(B.get(w).duration,W.get(w)?.duration??0),H=/^\s*([a-z][a-z0-9-]*)\.(start|end)\s*(?:([+-])\s*(\d+(?:\.\d+)?\s*(?:b|beats?|bars?)?))?\s*$/,Y=new Set,K,k,E=(w,O,J)=>{if(he(w)){if(w<0){t(O,"bad-time","Times are seconds from the scene start, zero or more.");return}return w}if(Le(w))return g(w,O);let N=typeof w=="string"?H.exec(w):null;if(!N){t(O,"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[,_,q,re,ne]=N,oe=ne===void 0?0:Le(ne)?g(ne,O):Number(ne);if(oe===void 0)return;let le=(re==="-"?-1:1)*oe;if(_==="scene"){if(q==="start")return Math.max(0,le);if(K===void 0){t(O,"needs-length",'"scene.end" can only place a layer when the scene has a length.',`Add "length" to scene "${C}", or refer to a layer instead.`);return}return Math.max(0,K+le)}if(_===J){t(O,"self-reference","A layer cannot be timed against itself.");return}if(!B.has(_)){let fe=[...B.keys()].filter(me=>me!==J),ye=Fe(_,fe);t(O,"unknown-layer",`Scene "${C}" has no layer "${_}".`,ye?`Did you mean "${ye}"?`:`Layers here: ${ve(fe)||"none"}.`);return}let ue=L(_);if(ue!==void 0)return Math.max(0,ue+(q==="end"?M(_):0)+le)},L=w=>{let O=B.get(w);if(O.start!==void 0)return O.start;if(Y.has(w)){t(`${O.path}.at`,"time-cycle",`Layers ${[...Y].join(" \u2192 ")} \u2192 ${w} are timed against each other in a circle.`,"Give one of them a number.");return}Y.add(w);let J=O.layer.at===void 0?0:E(O.layer.at,`${O.path}.at`,w);return Y.delete(w),J!==void 0&&(O.start=b(J)),O.start};if(x.length!==void 0){let w=Le(x.length)?g(x.length,`${A}.length`):x.length;w===void 0||(!he(w)||w<=0?t(`${A}.length`,"bad-time",'length is seconds above zero, or beats ("8b", "2bars").'):(K=Math.max(f,b(w)),k=Math.max(f,w)))}for(let w of B.keys())L(w);let z=x.hold===void 0?d.hold:y(x.hold,`${A}.hold`,"hold")??d.hold;if(K===void 0){let w=Math.max(0,...[...B.entries()].map(([O,J])=>(J.start??0)+M(O)));K=Math.max(f,b(w+z))}else x.hold!==void 0&&r(`${A}.hold`,"unused","hold is ignored when the scene has a length.");let I=K,U=[],Q=!!x.follow||Array.isArray(x.camera)&&x.camera.length>0||["x","y"].some(w=>(x.tracks?.[w]?.length??0)>1),ee=[];for(let[w,O]of B){if(O.start===void 0)continue;let J=O.start+M(w);if(O.start>=I){let le=Math.max(0,I-f);t(`${O.path}.at`,"never-seen",O.start-I<f/2?`Layer "${w}" starts at ${O.start.toFixed(3)} s, the moment scene "${C}" ends, so it is never on screen.`:`Layer "${w}" starts at ${O.start.toFixed(3)} s, after scene "${C}" ends at ${I.toFixed(3)} s.`,`Times snap to whole frames at ${m} fps, so the last frame a layer can start on is ${le.toFixed(3)} s. Start it earlier or make the scene longer.`);continue}O.cycles&&O.cues?ee.push({path:O.path,id:w,start:O.start,cues:O.cues}):J>I+1e-6&&r(O.path,"cut-off",`Layer "${w}" finishes at ${J.toFixed(2)} s, ${(J-I).toFixed(2)} s after scene "${C}" ends.`,x.length!==void 0?`Raise the scene length to at least ${J.toFixed(2)}, or start the layer earlier.`:"Start the layer earlier.");let N=W.get(w),_=X(O.layer.exit,`${O.path}.exit`,!0),q;if(_){let le=typeof O.layer.exit=="object"&&O.layer.exit.at!==void 0?E(O.layer.exit.at,`${O.path}.exit.at`,void 0):I-_.duration;le!==void 0&&(q={..._,start:b(Math.max(0,le))},q.start<O.start?t(`${O.path}.exit.at`,"exit-before-enter",`Layer "${w}" leaves at ${q.start.toFixed(2)} s, before it arrives at ${O.start.toFixed(2)} s.`):q.start<J-1e-6&&r(`${O.path}.exit`,"exit-early",`Layer "${w}" starts leaving at ${q.start.toFixed(2)} s while it is still arriving (until ${J.toFixed(2)} s).`))}let re;if(O.layer.parallax!==void 0){let le=`${O.path}.parallax`,ue=O.layer.parallax,fe=he(ue)?{depth:ue}:ue;if(!ge(fe)||!he(fe.depth)||fe.depth<0||fe.depth>10)t(le,"bad-value","parallax is a depth from 0 to 10 (1 travels with the scene, above 1 is nearer), or { depth, home }.");else{s(fe,["depth","home"],le);let ye=fe.home===void 0?I:E(fe.home,`${le}.home`,void 0);ye!==void 0&&(re={depth:fe.depth,home:Math.min(ye,I)}),Q||r(le,"unused",`Scene "${C}"'s camera does not travel, so parallax has nothing to follow.`,"Give the scene x or y tracks, or a follow."),x.follow&&ge(x.follow)&&x.follow.layer===w&&t(le,"bad-follow",`The camera follows "${w}", so it cannot also travel against the camera.`)}}let ne,oe=O.start;if(O.layer.taps!==void 0){let le=`${O.path}.taps`;Array.isArray(O.layer.taps)?(ne=[],O.layer.taps.forEach((ue,fe)=>{let ye=`${le}.${fe}`,me=ge(ue)?ue:{at:ue};ge(ue)&&s(ue,["at","ring","mark"],ye);let xe=ge(ue)&&typeof ue.mark=="string"?ue.mark:void 0;xe!==void 0&&O.layer.use!=="rig/footage-plane"&&t(`${ye}.mark`,"bad-value","Only a rig/footage-plane has marks to tap.");let we=E(me.at,ge(ue)?`${ye}.at`:ye,void 0);me.ring!==void 0&&me.ring!==!1&&typeof me.ring!="string"&&t(`${ye}.ring`,"bad-value","ring is the id of a layer in this scene, or false for no ring."),we!==void 0&&((we<oe||q&&we>q.start)&&r(ye,"tap-hidden",`Layer "${w}" is tapped at ${we.toFixed(2)} s, when it is not on screen.`),ne.push({t:b(we),ring:me.ring===!1?null:typeof me.ring=="string"?me.ring:w,...xe?{mark:xe}:{}}))}),ne.sort((ue,fe)=>ue.t-fe.t)):t(le,"bad-value","taps is a list of times, or of { at, ring }.",'e.g. "taps": ["3.25b"]')}U.push({id:w,use:O.layer.use,start:O.start,duration:O.duration,end:J,props:O.props,params:O.params,...O.cues?{cues:O.cues}:{},...O.speed!==void 0?{speed:O.speed}:{},...N?{enter:{...N,start:O.start}}:{},...q?{exit:q}:{},...re?{parallax:re}:{},...ne?.length?{taps:ne}:{},source:O.layer})}for(let w of U){if(w.use!=="ui/cursor-click"||typeof w.props.target!="string"||!w.props.target)continue;let O=U.find(J=>J.id===w.props.target);if(!O){let J=Fe(w.props.target,U.map(N=>N.id));t(`${A}.layers.${w.id}.props.target`,"unknown-layer",`Scene "${C}" has no layer "${w.props.target}" for the cursor to click.`,J?`Did you mean "${J}"?`:void 0);continue}(O.taps??=[]).push({t:b(w.start+qr(w.params)),ring:O.id}),O.taps.sort((J,N)=>J.t-N.t)}if(U.forEach(w=>w.taps?.forEach((O,J)=>{if(O.ring!==null&&!U.some(N=>N.id===O.ring)){let N=Fe(O.ring,U.map(_=>_.id));t(`${A}.layers.${w.id}.taps.${J}.ring`,"unknown-layer",`Scene "${C}" has no layer "${O.ring}" to draw a tap's ring around.`,N?`Did you mean "${N}"?`:void 0)}})),x.follow!==void 0){let w=`${A}.follow`,O=x.follow;if(!ge(O))t(w,"bad-follow","follow is { layer, at, lag, blend }.");else{s(O,["layer","at","lag","blend"],w);let J=typeof O.layer=="string"?U.find(N=>N.id===O.layer):void 0;if(J)Ot.includes(J.use)||t(`${w}.layer`,"bad-follow",`${J.use} has no tip to follow.`,`The camera can follow: ${ve(Ot)}.`);else{let N=U.filter(q=>Ot.includes(q.use)).map(q=>q.id),_=typeof O.layer=="string"?Fe(O.layer,N):void 0;t(`${w}.layer`,"unknown-layer",`Scene "${C}" has no layer "${String(O.layer)}" to follow.`,_?`Did you mean "${_}"?`:N.length?`Lines here: ${ve(N)}.`:`Add a line to follow: ${ve(Ot)}.`)}O.at!==void 0&&!(Array.isArray(O.at)&&O.at.length===2&&O.at.every(N=>he(N)&&N>=0&&N<=100))&&t(`${w}.at`,"bad-value","at is [x, y] in % of the stage, 0 to 100.","The middle is [50, 50].");for(let N of["lag","blend"])O[N]!==void 0&&!(he(O[N])&&O[N]>=0)&&t(`${w}.${N}`,"bad-time",`${N} is seconds, zero or more.`)}}let ie;if(x.camera!==void 0){let w=`${A}.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 O=["x","y","scale"].filter(q=>x.tracks?.[q]!==void 0);O.length&&t(`${A}.tracks`,"bad-camera",`The framing camera sets x, y and scale itself, so tracks ${O.join(", ")} would fight it.`,"Move them into camera keys: frame, offset and zoom. rotate, rotateX and rotateY tracks still apply.");let J=U.map(q=>q.id),N=(q,re,ne)=>Array.isArray(q)&&q.length===2&&q.every(oe=>he(oe)&&oe>=re&&oe<=ne),_={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((q,re)=>{let ne=`${w}.${re}`;if(!ge(q)){t(ne,"bad-camera","A camera key is an object: { at, frame, zoom, anchor, tilt, ease }.");return}s(q,["at","frame","point","offset","zoom","anchor","tilt","rotate","ease","drift"],ne);let oe=y(q.at,`${ne}.at`,"at");if(oe===void 0)return;ie.length&&oe<ie[ie.length-1].t&&t(`${ne}.at`,"bad-order",`Camera keys run in time order; this one (${oe.toFixed(2)} s) comes before the key above it.`),oe>I+1e-6&&r(`${ne}.at`,"after-end",`This key (${oe.toFixed(2)} s) is after scene "${C}" ends (${I.toFixed(2)} s).`,"A key past the cut is fine for a camera that keeps moving through the cut; otherwise move it earlier.");let le={..._,t:oe,drift:0};if(q.ease!==void 0){let ue=v(q.ease,`${ne}.ease`);ue!==void 0&&(le.ease=ue)}else delete le.ease;if(q.frame!==void 0)if(typeof q.frame=="string"){let[ue,fe]=q.frame.split("#");if(J.includes(ue))fe!==void 0&&U.find(ye=>ye.id===ue)?.use!=="rig/footage-plane"?t(`${ne}.frame`,"bad-camera",`"${q.frame}" frames a mark, and only a rig/footage-plane has marks.`,`Frame the layer itself: "${ue}".`):fe===""&&t(`${ne}.frame`,"bad-camera",'Name the mark after the #: "plane#send", as given to motion record --marks.');else{let ye=Fe(ue,J);t(`${ne}.frame`,"unknown-layer",`Scene "${C}" has no layer "${ue}" to frame.`,ye?`Did you mean "${ye}"?`:`Layers: ${ve(J)}.`)}le.frame=q.frame}else N(q.frame,0,100)?le.frame=[q.frame[0],q.frame[1]]:t(`${ne}.frame`,"bad-value","frame is a layer id, or [x, y] in % of the stage.");q.point!==void 0&&(N(q.point,0,1)?le.point=[q.point[0],q.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].")),q.offset!==void 0&&(Array.isArray(q.offset)&&q.offset.length===2&&q.offset.every(he)?le.offset=[q.offset[0],q.offset[1]]:t(`${ne}.offset`,"bad-value","offset is [dx, dy] in px.")),q.anchor!==void 0&&(N(q.anchor,0,100)?le.anchor=[q.anchor[0],q.anchor[1]]:t(`${ne}.anchor`,"bad-value","anchor is [x, y] in % of the stage, 0 to 100.")),q.tilt!==void 0&&(N(q.tilt,-80,80)?le.tilt=[q.tilt[0],q.tilt[1]]:t(`${ne}.tilt`,"bad-value","tilt is [about x, about y] in degrees, -80 to 80.")),q.zoom!==void 0&&(he(q.zoom)&&q.zoom>0?le.zoom=q.zoom:t(`${ne}.zoom`,"bad-value","zoom is a number above 0; 1 is the stage as laid out.")),q.rotate!==void 0&&(he(q.rotate)?le.rotate=q.rotate:t(`${ne}.rotate`,"bad-value","rotate is degrees.")),q.drift!==void 0&&(he(q.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."):le.drift=q.drift:t(`${ne}.drift`,"bad-value","drift is zoom per second, such as 0.02.")),ie.push(le),_=le}),x.perspective!==void 0&&!(he(x.perspective)&&x.perspective>=100)&&t(`${A}.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"&&!(he(x.motionBlur)&&x.motionBlur>=0&&x.motionBlur<=1)&&t(`${A}.motionBlur`,"bad-value","motionBlur is true (a half-frame shutter) or the share of a frame the shutter is open, 0 to 1.");let de,ce=0;if(x.out!==void 0){let w=`${A}.out`,O=ge(x.out)&&typeof x.out.use=="string"?ze[x.out.use]:void 0;if(O){s(x.out,["use","duration","params"],w);let J=d.transitions==="calm"&&O.calm?Object.fromEntries(Object.entries(O.params).map(([q,re])=>[q,q in O.calm?{...re,default:O.calm[q]}:re])):O.params,N=T(x.out.params,J,`${w}.params`,O.slug);if(x.out.duration!==void 0){let q=y(x.out.duration,`${w}.duration`,"duration");q!==void 0&&(N.duration=q)}let _=b(he(N.duration)?N.duration:0);$===i.scenes.length-1?r(w,"unused",'The last scene has nothing to hand over to, so "out" is ignored.'):_>=I?t(`${w}.duration`,"too-long",`The hand-over (${_.toFixed(2)} s) is not shorter than scene "${C}" (${I.toFixed(2)} s).`):(de={use:O.slug,duration:_,params:N},ce=he(N.duration)?N.duration:0)}else{let J=Object.keys(ze),N=ge(x.out)?String(x.out.use):"",_=Fe(N,J);t(`${w}.use`,"unknown-transition",`There is no code for transition "${N}".`,_?`Did you mean "${_}"?`:`Transitions: ${ve(J)}.`)}}let pe=I-(de?de.duration/2:0);for(let w of ee){let O=w.cues.find(J=>w.start+J.at<pe-1e-6&&w.start+J.at+J.length>pe+1e-6);O&&r(w.path,"cut-mid-change",`Scene "${C}" is last seen at ${pe.toFixed(2)} s, in the middle of a change of layer "${w.id}" (${(w.start+O.at).toFixed(2)}\u2013${(w.start+O.at+O.length).toFixed(2)} s).`,"End the scene on a rest: after the change, or before it begins.")}S.set(C,{length:k??I,out:ce}),D.push({id:C,start:0,length:I,end:I,layers:U,...de?{out:de}:{},...ie?{camera:ie}:{},source:V?{...x,tracks:V}:x})});let j=0;D.forEach((x,$)=>{let C=D[$-1];C?.out&&(C.out.duration>=x.length&&t(`scenes.${C.id}.out.duration`,"too-long",`The hand-over (${C.out.duration.toFixed(2)} s) is not shorter than the next scene "${x.id}" (${x.length.toFixed(2)} s).`),j-=S.get(C.id)?.out??C.out.duration),x.start=b(j),j+=S.get(x.id)?.length??x.length,x.end=b(j),x.length=x.end-x.start}),Us(D,f,t);let Z=b(j);return i.poster!==void 0&&(!he(i.poster)||i.poster<0||i.poster>Z)&&t("poster","bad-time",`poster is a time inside the film, 0 to ${Z.toFixed(2)} s.`),a(d,{duration:Z,fps:m,frames:Math.round(Z*m),size:[o[0],o[1]],scenes:D,...c?{tempo:c}:{},...i.loop?{loop:!0}:{},...p?{audio:p}:{}})}function Us(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("."),d=e.find(y=>y.id===o),m=d?.layers.find(y=>y.id===u);if(!d||!m){t(i,"unknown-layer",`There is no layer "${s}" to continue.`,'Name a video layer as "scene.layer".');continue}if(m.use!=="el/video"){t(i,"bad-value",`"${s}" is ${m.use}, not el/video.`);continue}if(m===a){t(i,"self-reference","A video layer cannot continue itself.");continue}m.props.src!==a.props.src&&t(i,"bad-value",`"${s}" plays ${String(m.props.src)}, a different file.`,"A continuation plays the same footage.");let c=Math.min(d.length,m.exit?m.exit.start+m.exit.duration:d.length)-n,p=typeof m.params.rate=="number"?m.params.rate:1,g=Math.max(0,c-m.start),f=typeof m.props.from=="number"?m.props.from:0,b=typeof m.props.to=="number"?m.props.to:0,h=f+g*p;m.params.loop===!0&&b>f?h=f+g*p%(b-f):b>f&&(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.")}}var Xa=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Vs=new Set(["scenes","layers"]);function Ys(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(d=>Xa(d)&&d.id===i);if(!u||o)return!1;a=u;continue}if(!Xa(a))return!1;if(o)return t===null?delete a[i]:a[i]=t,!0;if(a[i]===void 0){if(Vs.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 Ua(e,n){let t=structuredClone(e),r=[],a=[];for(let[s,i]of Object.entries(n?.set??{}))(Ys(t,s,structuredClone(i))?a:r).push(s);return{film:t,orphans:r,applied:a}}var Va=`
|
|
9
9
|
.m-stage {
|
|
10
10
|
position: relative; overflow: hidden; transform-origin: 0 0; box-sizing: border-box; isolation: isolate;
|
|
11
11
|
color-scheme: light;
|