@getv.design/embed 0.2.0 → 0.3.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/README.md +8 -3
- package/THIRD_PARTY_NOTICES.txt +1 -1
- package/dist/auto.js +2 -2
- package/dist/chunks/chunk-ACHGJ7UR.js +2 -0
- package/dist/chunks/{chunk-BESL4IJP.js → chunk-H7KHX34X.js} +1 -1
- package/dist/chunks/chunk-JIHH634P.js +10 -0
- package/dist/chunks/{chunk-62FKKJ5M.js → chunk-JWI4TIMM.js} +2 -2
- package/dist/chunks/{chunk-R6OULTHF.js → chunk-P57LNVS3.js} +2 -2
- package/dist/chunks/{chunk-DSFLLPRE.js → chunk-UAVO4POT.js} +2 -2
- package/dist/chunks/fonts.js +2 -2
- package/dist/cli.js +16 -16
- package/dist/edit.js +253 -32
- package/dist/index.js +2 -2
- package/dist/markdown-it.js +2 -2
- package/dist/markdown.js +2 -2
- package/dist/marked.js +2 -2
- package/dist/rehype.js +2 -2
- package/dist/static.js +2 -2
- package/dist/view.js +3 -3
- package/edit.css +215 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-OMODSFXU.js +0 -10
- package/dist/chunks/chunk-T6H6KLK6.js +0 -2
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ rebundling), so the editor and the font code still load only when needed:
|
|
|
36
36
|
```html
|
|
37
37
|
<div id="design"></div>
|
|
38
38
|
<script type="module">
|
|
39
|
-
import { view } from 'https://cdn.jsdelivr.net/npm/@getv.design/embed@0.
|
|
39
|
+
import { view } from 'https://cdn.jsdelivr.net/npm/@getv.design/embed@0.3.1/dist/view.js';
|
|
40
40
|
|
|
41
41
|
const text = await (await fetch('/designs/home.vd')).text();
|
|
42
42
|
await view(document.querySelector('#design'), text);
|
|
@@ -120,6 +120,11 @@ is a top-level frame that is not hidden, counted the same way by `renderSvg`.
|
|
|
120
120
|
Images are drawn from `blob:` URLs, so a page with a content security policy
|
|
121
121
|
needs `img-src blob:`.
|
|
122
122
|
|
|
123
|
+
The view and `play()` are silent. A video page's music (a `music` line naming
|
|
124
|
+
an audio asset) is read and kept, and its bytes download with the rest of the
|
|
125
|
+
payload, but nothing here plays them: sound is the vDesign app's and its MP4
|
|
126
|
+
export's.
|
|
127
|
+
|
|
123
128
|
`mount(el, source, { mode: 'view' })` from `@getv.design/embed` does the same and loads the
|
|
124
129
|
view code only when called; `mode: 'play'` opens straight into the
|
|
125
130
|
presentation, and that handle's `destroy()` removes the view under it too.
|
|
@@ -225,7 +230,7 @@ has no `problems` or `fonts` event yet to say so.
|
|
|
225
230
|
### Where the faces come from
|
|
226
231
|
|
|
227
232
|
The faces come from `fontBase`, by default this package's `fonts/` folder on
|
|
228
|
-
jsDelivr (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.
|
|
233
|
+
jsDelivr (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.3.1/fonts/`). That means
|
|
229
234
|
your readers' browsers request the faces from jsDelivr, and a content security
|
|
230
235
|
policy needs it in `connect-src`. To keep those requests on your own origin,
|
|
231
236
|
copy `node_modules/@getv.design/embed/fonts/` to your site and point `fontBase` at it:
|
|
@@ -254,7 +259,7 @@ The embed's styles reach the page by one of two routes.
|
|
|
254
259
|
```
|
|
255
260
|
|
|
256
261
|
Link them before the embed runs, from your own origin or from the CDN
|
|
257
|
-
(`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.
|
|
262
|
+
(`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.3.1/view.css`). The id is what
|
|
258
263
|
the embed looks for: linked without it, the stylesheet still works, but
|
|
259
264
|
the embed inserts its `<style>` as well.
|
|
260
265
|
|
package/THIRD_PARTY_NOTICES.txt
CHANGED
package/dist/auto.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import"./chunks/chunk-
|
|
1
|
+
/*! @getv.design/embed v0.3.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import"./chunks/chunk-H7KHX34X.js";var f="data-vd-live";async function L(n=document,s={}){let e=[...n.querySelectorAll('figure.vd-figure[data-vd-mode="view"]')].filter(t=>!t.hasAttribute(f)&&t.dataset.vdSource);if(e.length===0)return[];for(let t of e)t.setAttribute(f,"opening");let{view:r}=await import("./view.js");return(await Promise.all(e.map(t=>w(t,r,s)))).filter(t=>t!==void 0)}async function w(n,s,e){let r;try{let d=atob(n.dataset.vdSource??"");r=new TextDecoder().decode(Uint8Array.from(d,u=>u.charCodeAt(0)))}catch{n.removeAttribute(f);return}let i=n.querySelector(".vd-figure-art"),t=n.ownerDocument.createElement("div");t.className="vd-figure-live",t.style.height=`${x(n,i)}px`,i?.after(t);let o=n.dataset.vdPage;try{let d=await s(t,r,{fit:"page",...o===void 0?{}:{page:/^\d+$/.test(o)?Number(o):o},...e.fonts?{fonts:e.fonts}:{},...e.fontBase?{fontBase:e.fontBase}:{},...e.surface?{surface:e.surface}:{},...e.onLink?{onLink:e.onLink}:{}});return i?.setAttribute("hidden",""),n.setAttribute(f,"true"),d.pages().length>1&&H(n,t,d,o),d}catch{t.remove(),n.removeAttribute(f);return}}function H(n,s,e,r){let i=(a,v,y)=>{let b=n.ownerDocument.createElement(a);return b.className=v,b.textContent=y,b},t=i("div","vd-figure-pager",""),o=i("button","vd-figure-pager__button","\u2039"),d=i("span","vd-figure-pager__label",""),u=i("button","vd-figure-pager__button","\u203A"),m=i("button","vd-figure-pager__button","Present");o.setAttribute("aria-label","Previous page"),u.setAttribute("aria-label","Next page"),d.setAttribute("aria-live","polite");for(let a of[o,u,m])a.setAttribute("type","button");t.append(o,d,u,m),s.after(t);let c=e.pages(),g=r===void 0?-1:/^\d+$/.test(r)?Number(r):c.findIndex(a=>a.id===r),l=g>=0&&g<c.length?g:0,p=()=>{let a=c[l];d.textContent=`${a?.name??a?.id??""} \xB7 ${l+1} of ${c.length}`},h=a=>{l=Math.min(c.length-1,Math.max(0,l+a)),e.goTo(l),p()};e.on("page",a=>{l=Math.max(0,c.findIndex(v=>v.id===a.id)),p()}),o.addEventListener("click",()=>h(-1)),u.addEventListener("click",()=>h(1)),m.addEventListener("click",()=>{e.play()}),p()}function x(n,s){let e=Number(n.dataset.vdHeight);if(Number.isFinite(e)&&e>0)return e;let r=s?.getBoundingClientRect().height??0;return r>0?Math.max(240,Math.round(r)):420}export{L as hydrate};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
1
|
+
/*! @getv.design/embed v0.3.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
2
|
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>{try{return a||b((a={exports:{}}).exports,a),a.exports}catch(c){throw a=0,c}};var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.3.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
var Ie=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=["left","center","right","justify"],fe=["top","middle","bottom"],de=["cover","contain","fill"],Ae=["nonzero","evenodd"],Ne=["butt","round","square"],Pe=["miter","round","bevel"],mn=["canvas","frame","group"];function De(e){return mn.includes(e)}function N(e){return De(e.type)}function le(e){return e.type==="group"}function q(e){return N(e)?e.children:[]}var gn={canvas:["w","h"],ellipse:["x","y","w","h","rotation","strokeWidth","opacity"],frame:["x","y","w","h"],group:[],image:["x","y","w","h","rotation","radius","opacity"],rect:["x","y","w","h","rotation","strokeWidth","radius","opacity"],text:["x","y","w","h","rotation","size","weight","lineHeight","letterSpacing","opacity"],vector:["x","y","w","h","rotation","strokeWidth","opacity"]};function Re(e){return gn[e.type]}function O(e,t,n){if(t(e,n)!==!1&&N(e))for(let r of e.children)O(r,t,e)}function L(e,t){let n;return O(e,r=>{if(n)return!1;r.id===t&&(n=r)}),n}function V(e){let t=e.trim();if(t.startsWith("#")){let r=t.slice(1);return r===""?void 0:{kind:"frame",id:r}}let n;try{n=new URL(t)}catch{return}if(!(n.protocol!=="https:"&&n.protocol!=="mailto:"))return{kind:"url",url:t}}var Z="--- payload base64 ---",lr="sha256-";function yn(e){let t=yr(e);return t===-1?{head:e,payload:""}:{head:e.slice(0,t),payload:e.slice(t+Z.length)}}function pr(e){let{head:t,payload:n}=yn(e);return{head:t,blocks:xn(n)}}function xn(e){let t=new Map;for(let n of e.split(`
|
|
3
|
+
`)){let r=n.indexOf(" ");if(r===-1)continue;let o=n.slice(0,r);o.startsWith(lr)&&t.set(o,n.slice(r+1).trim())}return t}function hr(e,t){return`data:${e};base64,${t}`}function mr(e){let t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function gr(e){let t=Uint8Array.fromBase64;if(typeof t=="function")return t(e);let n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)r[o]=n.charCodeAt(o);return r}function yr(e){if(e.startsWith(Z))return 0;let t=e.indexOf(`
|
|
4
|
+
${Z}`);return t===-1?-1:t+1}function pe(e){return{expr:e}}function P(e){return typeof e=="object"&&e!==null&&typeof e.expr=="string"}var he=["design"],Q="design";var Le=[1,2,3,4],j="doc";function me(e){return{type:"canvas",...e}}function Ce(e={}){return{version:4,kind:e.kind??Q,...e.title===void 0?{}:{title:e.title},tokens:e.tokens??{},fonts:e.fonts??{},assets:e.assets??{},...e.motion===void 0||Object.keys(e.motion).length===0?{}:{motion:e.motion},root:e.root??me({id:j,children:[]})}}var Fe=["beat","bar"];var xr=/^(\d+(?:\.\d+)?)(beats?|bars?)$/;function ee(e){let t=xr.exec(e);if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return{count:n,unit:t[2].startsWith("bar")?"bar":"beat"}}function te(e,t){return`${String(Math.round(e*1e6)/1e6)}${t}${e===1?"":"s"}`}function ne(e){return typeof e=="string"&&ee(e)!==void 0}function U(e){let t=e?.bpm;if(t===void 0)return;let n=e?.meter??4,r=6e4/t;return{bpm:t,meter:n,beat:r,bar:r*n}}function ge(e,t,n){if(e===void 0)return n;if(typeof e=="number")return e;let r=ee(e);return!r||!t?n:r.count*(r.unit==="bar"?t.bar:t.beat)}var ye=36e5;var Ve=["cut","fade","push","slide"],je=["cut","fade","rise","drop","pop","wipe","grow","count","draw"],re=["cut","fade","rise","drop","pop"],Ue=["pulse"],Be=["out","in","inout","linear","spring"],We=["word","letter"],B=["left","right","top","bottom"],$n=400,xe=1e4,ze=18e4,W=7680;function oe(e){let t=e.trim();return t==="back"?{kind:"back"}:t==="next"?{kind:"next"}:V(t)}function $e(e){return e===void 0||e.enter===void 0&&e.duration===void 0&&e.scroll!==!0&&e.length===void 0&&e.w===void 0&&e.h===void 0&&e.bpm===void 0&&e.meter===void 0&&e.music===void 0&&e.lines.length===0}function Xe(e){return e.camera===!0||e.enter!==void 0||e.exit!==void 0||e.emphasis!==void 0||e.go!==void 0}var wr=["camera","emphasis","from","by","stagger","hold","at","after","with","on","ease","pad"];function wn(e){return e===void 0?!1:e.length!==void 0||e.w!==void 0||e.h!==void 0||e.bpm!==void 0||e.meter!==void 0||e.music!==void 0?!0:e.lines.some(t=>wr.some(n=>t[n]!==void 0)||t.enter!==void 0&&!re.includes(t.enter)||t.exit!==void 0&&!re.includes(t.exit))}function Ge(e){let t=e.motion;if(!t)return[];let n=e.root.children.map(o=>o.id).filter(o=>o in t),r=Object.keys(t).filter(o=>!n.includes(o)).sort();return[...n,...r]}function He(e){return new Set(e.root.children.filter(t=>t.type==="frame").map(t=>t.id))}function Ye(e){let t=new Map;for(let n of e.root.children)n.type==="frame"&&O(n,r=>{t.set(r.id,n.id)});return t}function br(e){let t=new Set;return O(e,n=>{t.add(n.id)}),t}function we(e,t){let n=e.motion;if(!n)return[];let r=[],o=He(e),i=Ye(e),s=br(e.root),u=(a,c)=>{let f=t?.(a,c);return f===void 0?"":`Line ${f}: `};for(let a of Ge(e)){let c=n[a];if(!c)continue;if(!o.has(a)){r.push({severity:"warning",code:"motion-not-a-page",message:`${u(a)}motion ${a}: ${a} is not a page (a top-level frame), so none of it plays`,nodeId:a});continue}let f=new Set;for(let d of c.lines){let l=u(a,d.id);for(let h of["after","with"]){let x=d[h];x!==void 0&&!f.has(x)&&r.push({severity:"warning",code:"motion-anchor-missing",message:`${l}motion ${a}: ${h}=${x} names no line above, so it starts after the line above instead`,nodeId:d.id})}d.camera!==!0&&f.add(d.id);let p=s.has(d.id)?L(e.root,d.id):void 0;p&&r.push(...kr(d,p,l,a)),s.has(d.id)?i.get(d.id)!==a&&r.push({severity:"warning",code:"motion-wrong-page",message:`${l}motion ${a}: ${d.id} is not on ${a}, so Play skips it`,nodeId:d.id}):r.push({severity:"warning",code:"unknown-reference",message:`${l}motion ${a}: no node ${d.id}`,nodeId:d.id});let g=d.go===void 0?void 0:oe(d.go);g?.kind==="frame"&&!Sr(e,g.id)&&r.push({severity:"warning",code:"unknown-reference",message:`${l}motion ${a}: go=#${g.id} names no frame`,nodeId:d.id})}}return r}function kr(e,t,n,r){let o=[],i=(u,a)=>{o.push({severity:"warning",code:u,message:`${n}motion ${r}: ${a}`,nodeId:t.id})};if(e.camera===!0)return o;let s=e.enter??e.exit;return s==="count"&&(t.type!=="text"||!/\d/.test(Je(t.content)))&&i("count-no-number",`${t.id} has no number to count, so it fades in instead`),s==="draw"&&!Er(t)&&i("draw-no-stroke",`${t.id} has no stroked vector to draw, so it fades in instead`),e.by!==void 0&&t.type!=="text"?i("by-not-text",`by=${e.by} splits text, and ${t.id} is a ${t.type}`):e.by!==void 0&&t.type==="text"&&vr(t)&&i("by-rotated",`${t.id} is rotated, so by=${e.by} enters it whole`),e.stagger!==void 0&&e.by===void 0&&q(t).length===0&&i("stagger-no-children",`${t.id} has no children to stagger: split a text with by=word`),o}function vr(e){let t=e.rotation;return t!==void 0&&t!==0}function Er(e){let t=!1;return O(e,n=>(n.type==="vector"&&n.stroke!==void 0&&(t=!0),t?!1:void 0)),t}function Je(e){return typeof e=="string"?e:e.map(t=>typeof t=="string"?t:t.text).join("")}function Sr(e,t){let n=!1;return O(e.root,r=>{if(n)return!1;r.id===t&&(n=r.type==="frame")}),n}function m(e){if(!Number.isFinite(e))return"0";let t=Math.round(e*1e4)/1e4,n=Object.is(t,-0)?0:t;return Math.abs(n)>=1e21?n.toFixed(0):String(n)}var Mr={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function kt(e){let t=[],n,r=0,o=0,i=0,s=0,u,a,c=Tr(e),f=()=>(n||(n={anchors:[{x:r,y:o}],closed:!1},t.push(n)),n.anchors[n.anchors.length-1]),d=(h,x)=>{f(),n?.anchors.push({x:h,y:x}),r=h,o=x},l=(h,x,k,$)=>{f().out=h,n?.anchors.push({x:k,y:$,in:x}),r=k,o=$},p="",g=!0;for(;c.more();){let h=c.command();if(h!==void 0)p=h,g=!0;else if(p===""||p.toUpperCase()==="Z")return{contours:Ke(t),error:`Expected a command at ${c.at()}`};let x=p.toUpperCase(),k=p!==x,$=Mr[x];if($===void 0)return{contours:Ke(t),error:`Unknown command ${p}`};if(x==="Z"){n&&(n.closed=!0),n=void 0,r=i,o=s,u=void 0,a=void 0,p="";continue}let A=x==="A"?c.arc():c.numbers($);if(A===void 0)return{contours:Ke(t),error:`${p} expects ${$} numbers at ${c.at()}`};let y=k?r:0,b=k?o:0,w=v=>A[v];switch(x){case"M":g&&(n={anchors:[{x:y+w(0),y:b+w(1)}],closed:!1},t.push(n),r=i=y+w(0),o=s=b+w(1),p=k?"l":"L"),u=a=void 0;break;case"L":d(y+w(0),b+w(1)),u=a=void 0;break;case"H":d(y+w(0),o),u=a=void 0;break;case"V":d(r,b+w(0)),u=a=void 0;break;case"C":{let v={x:y+w(2),y:b+w(3)};l({x:y+w(0),y:b+w(1)},v,y+w(4),b+w(5)),u=v,a=void 0;break}case"S":{let v=u?{x:2*r-u.x,y:2*o-u.y}:{x:r,y:o},S={x:y+w(0),y:b+w(1)};l(v,S,y+w(2),b+w(3)),u=S,a=void 0;break}case"Q":case"T":{let v=x==="Q"?{x:y+w(0),y:b+w(1)}:a?{x:2*r-a.x,y:2*o-a.y}:{x:r,y:o},S=x==="Q"?y+w(2):y+w(0),C=x==="Q"?b+w(3):b+w(1),G={x:r+2/3*(v.x-r),y:o+2/3*(v.y-o)},H={x:S+2/3*(v.x-S),y:C+2/3*(v.y-C)};l(G,H,S,C),a=v,u=void 0;break}case"A":{let v=y+w(5),S=b+w(6);for(let[C,G,H]of _r(r,o,w(0),w(1),w(2),w(3)!==0,w(4)!==0,v,S))l(C,G,H.x,H.y);(r!==v||o!==S)&&d(v,S),u=a=void 0;break}}g=!1}return{contours:Ke(t)}}function Ke(e){return e.map(t=>{let n=[...t.anchors];if(t.closed&&n.length>1){let r=n[0],o=n[n.length-1];be(r,o)&&(n.pop(),n[0]={...r,...o.in?{in:o.in}:{}})}return{anchors:n.map(Or),closed:t.closed}})}function Or(e){let t={x:e.x,y:e.y};return e.in&&!be(e.in,e)&&(t.in=e.in),e.out&&!be(e.out,e)&&(t.out=e.out),t}function be(e,t,n=1e-6){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}function Tr(e){let t=0,n=()=>{for(;t<e.length&&/[\s,]/.test(e[t]);)t+=1},r=()=>{n();let i=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(t));if(i)return t+=i[0].length,Number(i[0])},o=()=>{n();let i=e[t];if(!(i!=="0"&&i!=="1"))return t+=1,Number(i)};return{more(){return n(),t<e.length},command(){n();let i=e[t];if(/[a-zA-Z]/.test(i))return t+=1,i},numbers(i){let s=[];for(let u=0;u<i;u+=1){let a=r();if(a===void 0)return;s.push(a)}return s},arc(){let i=this.numbers(3),s=o(),u=o(),a=this.numbers(2);if(!(!i||s===void 0||u===void 0||!a))return[...i,s,u,...a]},at(){return t}}}function _r(e,t,n,r,o,i,s,u,a){let c=Math.abs(n),f=Math.abs(r);if(c===0||f===0||e===u&&t===a)return[];let d=o*Math.PI/180,l=Math.cos(d),p=Math.sin(d),g=(e-u)/2,h=(t-a)/2,x=l*g+p*h,k=-p*g+l*h,$=x*x/(c*c)+k*k/(f*f);$>1&&(c*=Math.sqrt($),f*=Math.sqrt($));let A=c*c*f*f-c*c*k*k-f*f*x*x,y=c*c*k*k+f*f*x*x,b=(i===s?-1:1)*Math.sqrt(Math.max(0,A/y)),w=b*c*k/f,v=-b*f*x/c,S=l*w-p*v+(e+u)/2,C=p*w+l*v+(t+a)/2,G=(M,F,J,K)=>{let ue=M*J+F*K,_e=Math.hypot(M,F)*Math.hypot(J,K),ae=Math.acos(Math.min(1,Math.max(-1,ue/_e)));return M*K-F*J<0?-ae:ae},H=G(1,0,(x-w)/c,(k-v)/f),Y=G((x-w)/c,(k-v)/f,(-x-w)/c,(-k-v)/f);!s&&Y>0&&(Y-=2*Math.PI),s&&Y<0&&(Y+=2*Math.PI);let wt=Math.max(1,Math.ceil(Math.abs(Y)/(Math.PI/2)-1e-9)),bt=Y/wt,Te=4/3*Math.tan(bt/4),ln=M=>({x:S+c*Math.cos(M)*l-f*Math.sin(M)*p,y:C+c*Math.cos(M)*p+f*Math.sin(M)*l}),pn=M=>({x:-c*Math.sin(M)*l-f*Math.cos(M)*p,y:-c*Math.sin(M)*p+f*Math.cos(M)*l}),hn=[];for(let M=0;M<wt;M+=1){let F=H+M*bt,J=F+bt,K=ln(F),ue=M===wt-1?{x:u,y:a}:ln(J),_e=pn(F),ae=pn(J);hn.push([{x:K.x+Te*_e.x,y:K.y+Te*_e.y},{x:ue.x-Te*ae.x,y:ue.y-Te*ae.y},ue])}return hn}function vt(e){let t=[],n=r=>`${m(r.x)} ${m(r.y)}`;for(let r of e){let{anchors:o}=r,i=o[0];if(!i)continue;t.push(`M${n(i)}`);let s=ke(r);for(let u=0;u<s;u+=1){let a=o[u],c=o[(u+1)%o.length],f=r.closed&&u===o.length-1;!a.out&&!c.in?f||t.push(`L${n(c)}`):t.push(`C${n(a.out??a)} ${n(c.in??c)} ${n(c)}`)}r.closed&&t.push("Z")}return t.join(" ")}function ke(e){let t=e.anchors.length;return t<2?0:e.closed?t:t-1}function qe(e,t){let n=e.anchors[t],r=e.anchors[(t+1)%e.anchors.length];return[{x:n.x,y:n.y},n.out??{x:n.x,y:n.y},r.in??{x:r.x,y:r.y},{x:r.x,y:r.y}]}function Et(e,t){let[n,r,o,i]=e,s=1-t,u=s*s*s,a=3*s*s*t,c=3*s*t*t,f=t*t*t;return{x:u*n.x+a*r.x+c*o.x+f*i.x,y:u*n.y+a*r.y+c*o.y+f*i.y}}function St(e,t){return e.map(n=>({closed:n.closed,anchors:n.anchors.map(r=>{let o=t(r);return{x:o.x,y:o.y,...r.in?{in:t(r.in)}:{},...r.out?{out:t(r.out)}:{}}})}))}function Mt(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=s=>{t=Math.min(t,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),o=Math.max(o,s.y)};for(let s of e){for(let a of s.anchors)i(a);let u=ke(s);for(let a=0;a<u;a+=1){let c=qe(s,a);for(let f of Ir(c))i(Et(c,f))}}if(t!==1/0)return{x:t,y:n,w:r-t,h:o-n}}function Ir(e){let[t,n,r,o]=e,i=[];for(let s of["x","y"]){let u=-t[s]+3*n[s]-3*r[s]+o[s],a=2*(t[s]-2*n[s]+r[s]),c=n[s]-t[s];if(Math.abs(u)<1e-12){Math.abs(a)>1e-12&&i.push(-c/a);continue}let f=a*a-4*u*c;if(f<0)continue;let d=Math.sqrt(f);i.push((-a+d)/(2*u),(-a-d)/(2*u))}return i.filter(s=>s>0&&s<1)}function Ze(e){if(e===void 0)return;let t=e.trim().split(/[\s,]+/).map(Number);if(t.length!==4||t.some(s=>!Number.isFinite(s)))return;let[n,r,o,i]=t;return{x:n,y:r,w:o,h:i}}function Ot(e,t,n){return Ze(e)??{x:0,y:0,w:t,h:n}}function Tt(e,t){let n=e.w===0?1:t.w/e.w,r=e.h===0?1:t.h/e.h;return o=>({x:t.x+(o.x-e.x)*n,y:t.y+(o.y-e.y)*r})}function _t(e,t=.5){let[n,r,o,i]=e;if(be(n,r)&&be(o,i))return[n,i];let u=Math.hypot(r.x-n.x,r.y-n.y)+Math.hypot(o.x-r.x,o.y-r.y)+Math.hypot(i.x-o.x,i.y-o.y),a=Math.min(256,Math.max(4,Math.ceil(Math.sqrt(u/t)))),c=[];for(let f=0;f<=a;f+=1)c.push(Et(e,f/a));return c}function Qe(e){let t=0;for(let n of e)for(let r=0;r<ke(n);r+=1){let o=_t(qe(n,r),.25);for(let i=1;i<o.length;i+=1){let s=o[i-1],u=o[i];t+=Math.hypot(u.x-s.x,u.y-s.y)}}return t}function Ar(e,t,n){let r=0,o=0;for(let i of e){let s=Nr(i);if(s.length!==0){if(n.reach>0){let u=i.closed?s.length:s.length-1;for(let a=0;a<u;a+=1){let c=s[a],f=s[(a+1)%s.length];if(Pr(t,c,f)<=n.reach)return!0}if(s.length===1&&Math.hypot(t.x-s[0].x,t.y-s[0].y)<=n.reach)return!0}if(n.fill)for(let u=0;u<s.length;u+=1){let a=s[u],c=s[(u+1)%s.length];a.y<=t.y!=c.y<=t.y&&a.x+(t.y-a.y)/(c.y-a.y)*(c.x-a.x)>t.x&&(o+=1,r+=c.y>a.y?1:-1)}}}return n.fill?n.rule==="evenodd"?o%2===1:r!==0:!1}function Nr(e){let t=e.anchors[0];if(!t)return[];let n=[{x:t.x,y:t.y}],r=ke(e);for(let o=0;o<r;o+=1)n.push(..._t(qe(e,o)).slice(1));return e.closed&&n.length>1&&n.pop(),n}function Pr(e,t,n){let r=n.x-t.x,o=n.y-t.y,i=r*r+o*o,s=i===0?0:Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*o)/i));return Math.hypot(e.x-(t.x+s*r),e.y-(t.y+s*o))}var et={canvas:[["name","string"],["w","numberValue"],["h","numberValue"],["background","stringValue"]],frame:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["background","stringValue"],["clip","boolean"],["skip","boolean"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],group:[["name","string"],["hidden","boolean"],["locked","boolean"]],ellipse:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],vector:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["view","string"],["d","string"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["opacity","numberValue"],["rule","fillRule"],["cap","lineCap"],["join","lineJoin"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],rect:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["radius","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],image:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["src","stringValue"],["fit","imageFit"],["radius","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],text:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["font","stringValue"],["size","numberValue"],["weight","numberValue"],["lineHeight","numberValue"],["letterSpacing","numberValue"],["align","align"],["valign","valign"],["italic","boolean"],["fill","stringValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]]},tt=[["font","string"],["size","number"],["weight","number"],["italic","boolean"],["underline","boolean"],["strike","boolean"],["fill","string"],["letterSpacing","number"],["link","string"]];var nt=[["enter","pageEffect"],["duration","number"],["scroll","boolean"],["length","time"],["w","number"],["h","number"],["bpm","number"],["meter","number"]],ve=[["enter","nodeEffect"],["exit","nodeEffect"],["emphasis","emphasisEffect"],["from","from"],["by","piece"],["stagger","time"],["duration","time"],["hold","time"],["delay","time"],["at","time"],["after","string"],["with","string"],["step","boolean"],["together","boolean"],["on","on"],["ease","ease"],["pad","number"],["go","string"]],rt=[["from","number"],["volume","number"],["fadein","time"],["fadeout","time"],["loop","boolean"]],vn=Object.keys(et);function ot(e){return vn.includes(e)}function It(e,t){return et[e].find(([n])=>n===t)?.[1]}function _(e,t){if(t==="boolean")return e===""||e==="true"?{value:!0}:e==="false"?{value:!1}:{error:`Expected true or false, got ${e}`};if(e.startsWith('"')){let r=ie(e);return r===void 0?{error:`Malformed quoted string ${e}`}:bn(r,t,e)}if(jr(e)){if(!Cr(t))return{error:Fr(e,t)};let r=Mn(e).trim();return r===""?{error:"Empty expression"}:{value:pe(r)}}return t==="numberValue"&&En.test(e)?{value:pe(e)}:bn(e,t,e)}var En=/^-?\d+(?:\.\d+)?%$/;function Cr(e){return e==="numberValue"||e==="stringValue"}function Fr(e,t){return t==="number"?`Expected a plain number, not an expression, got ${e}`:t==="string"&&/^\$\w+$/.test(e)?`Expected a literal, got ${e} \u2014 name a token without the $: ${e.slice(1)}`:`Expected a literal, not an expression, got ${e} \u2014 quote it if you meant the text`}function Sn(e,t){let n=/^(-?\d+(?:\.\d+)?)([A-Za-z]+)$/.exec(e);return n?/^(?:beats?|bars?)$/.test(n[2])?" \u2014 beats and bars count motion times on a page with bpm=; this is milliseconds":n[2]==="s"&&t==="number"?` \u2014 durations are milliseconds: ${Number(n[1])*1e3}`:/^(?:px|pt|deg|ms)$/.test(n[2])?` \u2014 drop the unit: ${n[1]}`:" \u2014 units are not supported: use a number, a percentage like (100%), or an expression":t==="number"?En.test(e)?" \u2014 a percentage is not allowed here":"":/^-[$@(]/.test(e)?` \u2014 wrap an expression in parentheses: (${e})`:/^-?[A-Za-z_]\w*(?:\.\w+)+$/.test(e)?` \u2014 wrap an expression in parentheses: (${e})`:""}function bn(e,t,n){switch(t){case"numberValue":case"number":{let r=Number(e);return Number.isFinite(r)&&e.trim()!==""?{value:r}:{error:`Expected a number, got ${n}${Sn(e,t)}`}}case"align":return ce.includes(e)?{value:e}:{error:`Expected one of ${ce.join(", ")}, got ${n}`};case"valign":return fe.includes(e)?{value:e}:{error:`Expected one of ${fe.join(", ")}, got ${n}`};case"fontStyle":return e==="normal"||e==="italic"?{value:e}:{error:`Expected normal or italic, got ${n}`};case"imageFit":return de.includes(e)?{value:e}:{error:`Expected one of ${de.join(", ")}, got ${n}`};case"fillRule":return R(Ae,e,n);case"lineCap":return R(Ne,e,n);case"lineJoin":return R(Pe,e,n);case"blendMode":return R(Ie,e,n);case"pageEffect":return R(Ve,e,n);case"nodeEffect":return R(je,e,n);case"emphasisEffect":return R(Ue,e,n);case"ease":return R(Be,e,n);case"piece":return R(We,e,n);case"time":{let r=ee(e);if(r)return{value:te(r.count,r.unit)};let o=Number(e);return Number.isFinite(o)&&e.trim()!==""?{value:o}:{error:`Expected milliseconds or beats, got ${n}${Vr(e)}`}}case"on":return Fe.includes(e)?{value:e}:e==="downbeat"?{error:`Expected beat or bar, got ${n} \u2014 write on=bar: a bar starts on its downbeat`}:e==="beats"||e==="bars"?{error:`Expected beat or bar, got ${n} \u2014 write on=${e.slice(0,-1)}`}:{error:`Expected beat or bar, got ${n}`};case"from":{if(B.includes(e))return{value:e};let r=Number(e);return Number.isFinite(r)&&e.trim()!==""?{value:r}:{error:`Expected a number or one of ${B.join(", ")}, got ${n}`}}default:return{value:e}}}function Vr(e){let t=/^(beat|bar|b)[:\s#]?(\d+(?:\.\d+)?)$/.exec(e);if(t){let r=t[1]==="bar"?"bar":"beat",o=Number(t[2]);return` \u2014 write ${te(Math.max(0,o-1),r)} (counted from the start: ${r} ${o}'s ${r==="bar"?"downbeat":"start"})`}let n=/^(\d+(?:\.\d+)?)\s*(b|bt|beat|bars?|beats?)$/.exec(e);if(n){let r=n[2]?.startsWith("bar")?"bar":"beat";return` \u2014 write ${te(Number(n[1]),r)} (counted from the start)`}return Sn(e,"number")}function R(e,t,n){return e.includes(t)?{value:t}:{error:`Expected one of ${e.join(", ")}, got ${n}`}}function jr(e){return/^[$@(]/.test(e)}function ie(e){try{let t=JSON.parse(e);return typeof t=="string"?t:void 0}catch{return}}function Mn(e){if(!e.startsWith("("))return e;let t=0;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="(")t+=1;else if(r===")"&&(t-=1,t===0))return n===e.length-1?e.slice(1,-1):e}return e}function On(e){let t=[],n="",r=0,o=!1;for(let i=0;i<e.length;i+=1){let s=e[i];if(o){n+=s,s==="\\"?(n+=e[i+1]??"",i+=1):s==='"'&&(o=!1);continue}if(s==='"'){o=!0,n+=s;continue}if(s==="("?r+=1:s===")"&&(r=Math.max(0,r-1)),r===0&&/\s/.test(s)){n!==""&&t.push(n),n="";continue}n+=s}return n!==""&&t.push(n),t}function At(e,t,n){let r=n===void 0?void 0:I(n);if(r?.value===void 0||!kn(e[t]??""))return;let o=t;for(;o<e.length&&kn(e[o]??"");)o+=1;let i=[Mn(r.value),...e.slice(t,o)].join(" ");return{end:o,message:`${r.key}: an expression with spaces needs parentheses \u2014 write ${r.key}=(${i})`}}function kn(e){return!e.includes("=")&&/^(?:[-+*/]|-?\d+(?:\.\d+)?%?|[$@][\w.]*|[A-Za-z_]\w*(?:\.\w+)+|\(.*|.*\))$/.test(e)}function I(e){let t=e.indexOf("=");return t===-1?{key:e,value:void 0}:{key:e.slice(0,t),value:e.slice(t+1)}}var Wr=new Set(["exit","delay","step","together","go","at","after","with"]),_n=["at","after","with","together","step"],zr=new Set(["pad","duration","delay","ease","on",..._n]);function Nt(e){if(e==="at"||e==="length")return ze;if(e==="w"||e==="h")return W;if(e==="duration"||e==="delay"||e==="stagger"||e==="hold")return xe;if(e==="pad")return W}function Pt(e,t){let n=e.words[1];if(n===void 0||n.includes("=")){t(e.number,"invalid-motion","Expected motion <page>, e.g. motion intro enter=fade");return}let r={};for(let i of e.words.slice(2)){let{key:s,value:u}=I(i),a=nt.find(([f])=>f===s)?.[1];if(a===void 0){let f=Wr.has(s)?` \u2014 ${s} goes on a node's line, under the header`:"";t(e.number,"invalid-motion",`motion ${n} has no "${s}"${f}`,n);continue}let c=_(u??"",a);"error"in c?t(e.number,"invalid-motion",`${s}: ${qr(s,u)??c.error}`,n):s==="bpm"&&!Jr(c.value)?t(e.number,"invalid-motion",`bpm: expected ${20} to ${300} beats a minute, got ${u??""}`,n):s==="meter"&&!Kr(c.value)?t(e.number,"invalid-motion",`meter: expected a whole number of beats in a bar, 1 to ${16}, got ${u??""}`,n):c.value!==!1&&(r[s]=c.value)}let o=U({...r,lines:[]});for(let[i]of nt){let s=r[i];if(s===void 0||Nt(i)===void 0)continue;let u=Lt(i,s,o,n);u!==void 0&&(t(e.number,"invalid-motion",u,n),delete r[i])}return{page:n,number:e.number,head:r,lines:[],where:new Map,taken:new Map,numbers:[]}}function Dt(e,t,n){if(t.words[0]==="music"&&!(t.words[1]??"").includes("=")){Gr(e,t,n);return}let r=t.words[0]==="camera"&&t.words[1]!==void 0&&!t.words[1].includes("="),o=r?t.words.slice(1):t.words,i=o[0];if(t.indent!==1){n(t.number,"invalid-motion","A motion line sits one level under its page");return}if(i.includes("=")){n(t.number,"invalid-motion",`Expected a node id first, got ${i}`);return}if(i===e.page&&!r){n(t.number,"invalid-motion",`${i} is the page: its transition goes on the header (motion ${i} enter=fade)`,i);return}let s=r?{id:i,camera:!0}:{id:i},u=!0;for(let f of o.slice(1)){let{key:d,value:l}=I(f),p=ve.find(([x])=>x===d)?.[1];if(p===void 0){n(t.number,"invalid-motion",`A motion line has no "${d}"${Zr(d)}`,i),u=!1;continue}if(r&&!zr.has(d)){n(t.number,"invalid-motion",`A camera line moves the shot and says only pad=, duration=, delay=, ease= and when: not ${d}=`,i),u=!1;continue}let g=_(l??"",p),h="error"in g||Nt(d)===void 0?void 0:Lt(d,g.value,U(In(e)),e.page);"error"in g?(n(t.number,"invalid-motion",`${d}: ${g.error}`,i),u=!1):h!==void 0?(n(t.number,"invalid-motion",`${i}: ${h}`,i),u=!1):d==="on"&&e.head.bpm===void 0?(n(t.number,"invalid-motion",`${i}: on=${String(g.value)} needs a tempo \u2014 motion ${e.page} bpm=120`,i),u=!1):d==="go"&&oe(g.value)===void 0?(n(t.number,"invalid-motion",`go: expected #<page>, back, next, or an https: or mailto: link, got ${l??""}`,i),u=!1):g.value!==!1&&(s[d]=g.value)}s.enter!==void 0&&s.exit!==void 0&&(n(t.number,"invalid-motion",`${i} either enters or exits on one line \u2014 write a second line for the other`,i),u=!1),s.emphasis!==void 0&&(s.enter!==void 0||s.exit!==void 0)&&(n(t.number,"invalid-motion",`${i} either ${s.enter!==void 0?"enters":"exits"} or is stressed on one line \u2014 write a second line for emphasis=`,i),u=!1);let a=_n.filter(f=>s[f]!==void 0);if(s.step===!0&&s.together===!0?(n(t.number,"invalid-motion",`${i} waits for a step or starts together with the line above, not both`,i),u=!1):a.length>1?(n(t.number,"invalid-motion",`${i} says when it starts twice (${a.join(", ")}): keep one`,i),u=!1):s.on!==void 0&&(s.with!==void 0||s.together===!0)&&(n(t.number,"invalid-motion",`${i} starts with another line (${s.with===void 0?"together":"with="}), so on= could only pull it apart: keep one`,i),u=!1),u){let f=Qr(s);f!==void 0&&(n(t.number,"invalid-motion",`${i}: ${f}`,i),u=!1)}if(!u)return;let c=Yr(s);if(!Xe(c)){n(t.number,"invalid-motion",`${i} says nothing: give it enter=, exit=, emphasis= or go=`,i);return}if(r){e.where.has(i)||e.where.set(i,t.number),e.lines.push(c),e.numbers.push(t.number);return}for(let f of["enter","exit","emphasis","go"]){if(c[f]===void 0)continue;let d=e.taken.get(`${i} ${f}`);if(d!==void 0){let l=f==="go"?"has a go=":f==="enter"?"enters":f==="exit"?"exits":"has an emphasis=";n(t.number,"invalid-motion",`${i} already ${l} on line ${d}`,i);return}}for(let f of["enter","exit","emphasis","go"])c[f]!==void 0&&e.taken.set(`${i} ${f}`,t.number);e.where.has(i)||e.where.set(i,t.number),e.lines.push(c),e.numbers.push(t.number)}function Rt(e){let t={...e.head.enter===void 0?{}:{enter:e.head.enter},...e.head.duration===void 0?{}:{duration:e.head.duration},...e.head.scroll===!0?{scroll:!0}:{},...e.head.length===void 0?{}:{length:e.head.length},...e.head.w===void 0?{}:{w:e.head.w},...e.head.h===void 0?{}:{h:e.head.h},...e.head.bpm===void 0?{}:{bpm:e.head.bpm},...e.head.meter===void 0?{}:{meter:e.head.meter},...e.music===void 0?{}:{music:e.music},lines:e.lines};return $e(t)?void 0:t}var Xr=new Set(["loop","step","together"]);function Gr(e,t,n){let r=t.words[1];if(t.indent!==1){n(t.number,"invalid-motion","A motion line sits one level under its page");return}if(r===void 0){n(t.number,"invalid-motion","Expected music <asset>, e.g. music bed fadeout=1500");return}if(Xr.has(r)){n(t.number,"invalid-motion",`music names its track first: music <asset> ${r}`);return}if(e.musicLine!==void 0){n(t.number,"invalid-motion",`motion ${e.page} already has music on line ${e.musicLine}: a page has one track`);return}let o={asset:r},i=U(In(e)),s=!0,u=c=>{n(t.number,"invalid-motion",`music ${r}: ${c}`),s=!1};for(let c of t.words.slice(2)){let{key:f,value:d}=I(c),l=rt.find(([g])=>g===f)?.[1];if(l===void 0){u(`the music line has no "${f}"${Hr(f)}`);continue}if(f==="from"&&d!==void 0&&/\d(?:beats?|bars?)$/.test(d)){u(`from= is where in the track to begin, in milliseconds, not ${d}`);continue}let p=_(d??"",l);if("error"in p){u(`${f}: ${p.error}`);continue}if(f==="from"&&!Tn(p.value,0,ye)){u(`from: expected 0 to ${ye} milliseconds, got ${d??""}`);continue}if(f==="volume"&&!Tn(p.value,0,1)){u(`volume: expected 0 to 1, got ${d??""}`);continue}if(f==="fadein"||f==="fadeout"){let g=Lt(f,p.value,i,e.page);if(g!==void 0){u(g);continue}}p.value!==!1&&(o[f]=p.value)}if(!s)return;let a={asset:r};for(let[c]of rt)o[c]!==void 0&&(a[c]=o[c]);e.music=a,e.musicLine=t.number}function Tn(e,t,n){return typeof e=="number"&&e>=t&&e<=n}function Hr(e){return e==="fade"?" \u2014 write fadein= and fadeout=":e==="fade-in"||e==="fadeIn"||e==="fade_in"?" \u2014 write fadein=":e==="fade-out"||e==="fadeOut"||e==="fade_out"?" \u2014 write fadeout=":e==="start"||e==="offset"||e==="seek"?" \u2014 write from= (where in the track to begin, in milliseconds)":e==="gain"||e==="level"?" \u2014 write volume= (0 to 1)":e==="at"||e==="delay"||e==="after"||e==="with"?": the music starts with the video; from= picks where in the track":": it takes from=, volume=, fadein=, fadeout= and loop"}function Yr(e){let t=e.camera===!0?{id:e.id,camera:!0}:{id:e.id};for(let[n]of ve)e[n]!==void 0&&(t[n]=e[n]);return t}function In(e){let{bpm:t,meter:n}=e.head;return{...t===void 0?{}:{bpm:t},...n===void 0?{}:{meter:n},lines:[]}}function Lt(e,t,n,r){if(ne(t)&&!n)return`${t} needs a tempo \u2014 motion ${r} bpm=120`;let o=typeof t=="number"||ne(t)?ge(t,n):void 0,i=Nt(e)??xe;if(o!==void 0&&o>=(e==="w"||e==="h"?16:0)&&o<=i)return;let u=String(t),a=ne(t)&&o!==void 0?` (${Math.round(o)} ms)`:"";return e==="w"||e==="h"?`${e}: expected 16 to ${W} pixels, got ${u}`:e==="pad"?`pad: expected 0 to ${W}, got ${u}`:`${e}: expected 0 to ${i} milliseconds, got ${u}${a}`}function Jr(e){return typeof e=="number"&&e>=20&&e<=300}function Kr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=16}function qr(e,t){if(e==="meter"&&t!==void 0&&/^\d+\/\d+$/.test(t))return`Expected beats in a bar, got ${t} \u2014 meter is beats per bar: meter=${t.split("/")[0]??""}`;if(e==="duration"&&t!==void 0&&/\d(?:beats?|bars?)$/.test(t))return`Expected milliseconds, got ${t} \u2014 the page transition is milliseconds; beats are for the lines`}function Zr(e){return e==="emphasise"||e==="emphasize"?" \u2014 write emphasis=pulse":e==="easing"?" \u2014 write ease=":e==="split"?" \u2014 write by=word or by=letter":e==="start"?" \u2014 write at= (milliseconds), after= or with=":""}function Qr(e){let t=e.enter,n=e.exit,r=t??n,o=e.from;if(n==="count")return"count only enters: it runs a number up to its written value";if(o!==void 0)if(r==="count"){if(typeof o!="number")return"from= on count is the number it starts at, e.g. from=0"}else if(r==="wipe"||r==="grow"){if(typeof o=="number")return`from= on ${r} is a side: ${B.join(", ")}`}else return"from= goes with count (a number), or wipe and grow (a side)";if(e.by!==void 0&&r!==void 0&&!re.includes(r))return`by= splits a text for ${re.join(", ")}, not ${r}`;if(e.by!==void 0&&r===void 0)return"by= goes with enter= or exit=";if(e.stagger!==void 0&&r===void 0)return"stagger= goes with enter= or exit=";if(e.hold!==void 0&&t===void 0)return"hold= goes with enter=: how long to stay before leaving the way it came"}function Ct(e){return(t,n,r,o)=>{e.push({severity:"error",code:n,message:`Line ${t}: ${r}`,...o===void 0?{}:{nodeId:o}})}}function Ft(e){let t=[],n=e.split(`
|
|
5
|
+
`);for(let r=0;r<n.length;r+=1){let o=n[r],i=o.trim();if(i===Z)break;if(i===""||i.startsWith("```"))continue;let s=o.length-o.trimStart().length;t.push({number:r+1,indent:Math.floor(s/2),text:i,words:On(i)})}return t}function Vt(e){let t=[],n=[],r=o=>{for(;t.length>0&&t[t.length-1].indent>=o;)no(t.pop())};return{push(o){let i=o.words[0];if(i.startsWith('"')){let c=t[t.length-1];if(!c||c.type!=="text")return e(o.number,"invalid-content","A quoted line must sit inside a text node"),!0;let f=oo(o,e);return f!==void 0&&c.runs.push(f),!0}if(!ot(i))return!1;r(o.indent);let s=o.words[1];if(s===void 0||s.includes("="))return e(o.number,"missing-id",`A ${i} needs an id`),!0;let u=to(i,s,o.words.slice(2),o,e),a=t[t.length-1];return a?a.children.push(u.record):n.push(u.record),t.push(u),!0},finish(){return r(0),n}}}function to(e,t,n,r,o){let i={type:e,id:t},s=[];for(let u=0;u<n.length;u+=1){let{key:a,value:c}=I(n[u]),f=It(e,a);if(f===void 0){let l=At(n,u,n[u-1]);l?(o(r.number,"invalid-value",l.message,t),u=l.end-1):o(r.number,"invalid-value",`${e} has no property "${a}"`,t);continue}let d=_(c??"",f);"error"in d?o(r.number,"invalid-value",`${a}: ${d.error}`,t):i[a]=d.value}return De(e)&&(i.children=s),e==="text"&&(i.content=""),{indent:r.indent,type:e,record:i,children:s,runs:[]}}function no(e){e.type==="text"&&(e.record.content=ro(e.runs))}function ro(e){if(e.length===0)return"";let t=e[0];return e.length===1&&typeof t=="string"?t:[...e]}function oo(e,t){let n=ie(e.words[0]);if(n===void 0){t(e.number,"invalid-run","Malformed quoted string");return}if(e.words.length===1)return n;let r={text:n};for(let o of e.words.slice(1)){let{key:i,value:s}=I(o),u=tt.find(([c])=>c===i);if(!u){t(e.number,"invalid-run",`A run has no mark "${i}"`);continue}let a=_(s??"",u[1]);"error"in a?t(e.number,"invalid-run",`${i}: ${a.error}`):r[i]=a.value}return r}function io(e){let t=[],n=Ct(t),r=Q,o,i=!1,s={},u={},a={},c=Vt(n),f,d={},l=new Map,p,g=!1,h=()=>{if(!p)return;let y=p;p=void 0;let b=l.get(y.page);if(b!==void 0){n(y.number,"invalid-motion",`motion ${y.page} is written twice \u2014 put its lines in the block on line ${b}`,y.page);return}l.set(y.page,y.number);for(let[v,S]of y.where)l.set(`${y.page} ${v}`,S);let w=Rt(y);w&&(d[y.page]=w)};for(let y of Ft(e)){let b=y.words[0];if(p&&y.indent>0){Dt(p,y,n);continue}if(!(g&&y.indent>0)){if(g=!1,h(),b==="motion"&&y.indent===0){f=void 0,p=Pt(y,n),g=p===void 0;continue}if(b==="version"){i=!0,uo(y,t);continue}if(b==="kind"&&y.indent===0){r=ao(y,t);continue}if(b==="title"&&y.indent===0){o=An(y,n);continue}if(b.startsWith("$")){f=void 0,co(y,s,n);continue}if(b==="asset"&&y.indent===0){f=void 0,fo(y,a,n);continue}if(b==="font"&&y.indent===0){f=po(y,u,n);continue}if((b==="fallback"||b==="face")&&f){ho(b,y,f,n);continue}f=void 0,!c.push(y)&&n(y.number,"unknown-node-type",`Unknown statement "${b}"`)}}h();let x=so(c.finish(),t),k=Object.keys(d).length===0?{}:{motion:d},$=(y,b)=>l.get(b===void 0?y:`${y} ${b}`);if(!x){i||t.push({severity:"error",code:"invalid-document",message:"No nodes found"});let y=me({id:j,children:[]}),b=Ce({kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...k,root:y});return t.push(...we(b,$)),{document:b,problems:t}}let A={version:4,kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...k,root:x};return t.push(...we(A,$)),{document:A,problems:t}}function so(e,t){let n=e[0];if(n!==void 0){if(e.length===1&&n.type==="canvas")return n;for(let r of e){if(r.type!=="canvas")continue;let o=r.id;t.push({severity:"error",code:"invalid-document",message:"A canvas must be the only top-level node",...typeof o=="string"?{nodeId:o}:{}})}return{type:"canvas",id:j,children:[...e]}}}function uo(e,t){Le.includes(Number(e.words[1]))||t.push({severity:"warning",code:"version-mismatch",message:`Line ${e.number}: expected version ${4} or older, got ${e.words[1]??"nothing"}`})}function ao(e,t){let n=e.words[1];return n!==void 0&&he.includes(n)?n:(t.push({severity:"error",code:"unknown-kind",message:`Line ${e.number}: unknown kind "${n??"nothing"}" \u2014 this build reads ${he.join(", ")}`}),Q)}function An(e,t){let n=e.words.slice(1).join(" ").trim();if(n===""){t(e.number,"invalid-value",'title needs a name, e.g. title "Pitch deck"');return}let r=n.startsWith('"')?ie(n):n;if(r===void 0){t(e.number,"invalid-value",`Could not read the title ${n}`);return}return r.trim()===""?void 0:r}function co(e,t,n){let{name:r,value:o}=jt(e.words);if(r===void 0||o===void 0){n(e.number,"invalid-token","Expected $name = value");return}if(!o.startsWith('"')&&/\s/.test(o)){n(e.number,"invalid-token",`$${r}: expected one value, got "${o}". Quote it if the value has spaces; there are no comments.`);return}let i=_(o,"stringValue");if("error"in i){n(e.number,"invalid-token",`$${r}: ${i.error}`);return}if(typeof i.value!="string"){n(e.number,"invalid-token",`$${r} may not be an expression`);return}t[r]=Nn(i.value,o)}function Nn(e,t){let n=Number(e);return t.startsWith('"')||!Number.isFinite(n)||e.trim()===""?e:n}function jt(e){let t=e[0],n=i=>i.startsWith("$")?i.slice(1):i;if(e[1]==="=")return{name:n(t),value:e.slice(2).join(" ")||void 0};let{key:r,value:o}=I(t);return o!==void 0?{name:n(r),value:o}:{name:n(t)}}function fo(e,t,n){let r=e.words.slice(1),o=r[0],i=r[1]==="=",s=o===void 0?void 0:I(o),u=s?.key,a=i?r[2]:s?.value,c=r.slice(i?3:1);if(u===void 0||u===""||a===void 0){n(e.number,"invalid-asset","Expected asset <name> = <type> hash=\u2026 bytes=\u2026");return}let f={};for(let g of c){let{key:h,value:x}=I(g);if(x===void 0){n(e.number,"invalid-asset",`Asset "${u}" has a stray word "${g}"`);continue}f[h]=lo(x)}let d=f.hash,l=Number(f.bytes);if(d===void 0||!Number.isFinite(l)){n(e.number,"invalid-asset",`Asset "${u}" needs a hash and a bytes count`);return}let p=f.ms===void 0?void 0:Number(f.ms);if(p!==void 0&&!(Number.isFinite(p)&&p>=0)){n(e.number,"invalid-asset",`Asset "${u}": ms is the track's length, in milliseconds`);return}t[u]={type:a,hash:d,bytes:l,...p===void 0?{}:{ms:p},...f.credit===void 0?{}:{credit:f.credit},...f.source===void 0?{}:{source:f.source},...f.license===void 0?{}:{license:f.license}}}function lo(e){return e.startsWith('"')?ie(e)??e:e}function po(e,t,n){let{name:r,value:o}=jt(e.words.slice(1));if(r===void 0||o===void 0){n(e.number,"invalid-font","Expected font <name> = <family>");return}let i=_(o,"string"),s={family:"error"in i?o:i.value};return t[r]=s,{family:s,faces:[]}}function ho(e,t,n,r){if(e==="fallback"){let u=_(t.words.slice(1).join(" "),"string");"error"in u?r(t.number,"invalid-font",`fallback: ${u.error}`):n.family.fallback=u.value;return}let o=t.words[1];if(o===void 0){r(t.number,"invalid-font-face","A face needs a src");return}let i=_(o,"string"),s={src:"error"in i?o:i.value};for(let u of t.words.slice(2)){let{key:a,value:c}=I(u);if(a!=="weight"&&a!=="style"){r(t.number,"invalid-font-face",`A face has no property "${a}"`);continue}let f=_(c??"",a==="weight"?"number":"fontStyle");"error"in f?r(t.number,"invalid-font-face",`${a}: ${f.error}`):s[a]=f.value}n.faces.push(s),n.family.faces=n.faces}var Dn="https://getv.design/ns/vd",zs=`<metadata><vd:document xmlns:vd="${Dn}" version="1"><![CDATA[
|
|
6
|
+
`;var $o=/<vd:document\b[^>]*>([\s\S]*?)<\/vd:document\s*>/;function wo(e){let t=$o.exec(e);if(!t)return;let n=t[1]??"",r="",o=n;for(;;){let i=o.indexOf("<![CDATA[");if(i===-1){r+=Pn(o);break}r+=Pn(o.slice(0,i));let s=o.indexOf("]]>",i);if(s===-1){r+=o.slice(i+9);break}r+=o.slice(i+9,s),o=o.slice(s+3)}return`${r.replace(/^\n/,"").replace(/\n$/,"")}
|
|
7
|
+
`}function bo(e){return/^\uFEFF?\s*</.test(e)}function Pn(e){return e.replace(/&(lt|gt|quot|apos|amp|#\d+|#x[0-9a-fA-F]+);/g,(t,n)=>{switch(n){case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";case"amp":return"&";default:{let r=n.startsWith("#x")?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return Number.isFinite(r)&&r<=1114111?String.fromCodePoint(r):t}}})}var Rn=.04,Ln=.85;var _o=[.2,0,0,1],Io=[.4,0,1,1],Ao=[.4,0,.2,1];function ct(e){return/^\s*(linear|radial|conic|repeating-[a-z]+)-gradient\s*\(/i.test(e)}function Ut(e){let t=e.trim(),n=/^([a-z-]+)-gradient\s*\(([\s\S]*)\)$/i.exec(t);if(!n)return ct(t)?{error:'A gradient needs its closing ")"'}:{kind:"solid",colour:t};let r=n[1].toLowerCase(),o=No(n[2]).map(i=>i.trim());if(o.some(i=>i===""))return{error:"A gradient has an empty argument"};if(r==="linear"){let i=Do(o[0]),s=Fn(i===void 0?o:o.slice(1));return"error"in s?s:{kind:"linear",angle:i??180,stops:s.stops}}if(r==="radial"){let i=Lo(o[0]);if(i&&"error"in i)return i;let s=Fn(i?o.slice(1):o);return"error"in s?s:{kind:"radial",shape:i?.shape??"ellipse",cx:i?.cx??.5,cy:i?.cy??.5,stops:s.stops}}return{error:`${r}-gradient is not supported; use linear-gradient or radial-gradient`}}function Bt(e){let t=e.map(r=>r.at);t[0]===void 0&&(t[0]=0),t[t.length-1]===void 0&&(t[t.length-1]=1);let n=0;for(let r=0;r<t.length;r+=1){let o=t[r];o!==void 0&&(n=Math.max(n,o),t[r]=n)}for(let r=1;r<t.length;r+=1){if(t[r]!==void 0)continue;let o=r-1,i=r;for(;t[i]===void 0;)i+=1;let s=t[o],u=t[i];for(let a=r;a<i;a+=1)t[a]=s+(u-s)*(a-o)/(i-o);r=i}return e.map((r,o)=>({colour:r.colour,at:t[o]}))}function No(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?n+=1:i===")"?n=Math.max(0,n-1):i===","&&n===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}var Po={top:[0,-1],bottom:[0,1],left:[-1,0],right:[1,0]};function Do(e){let t=/^(-?\d*\.?\d+)(deg|turn|rad)$/i.exec(e);if(t){let i=Number(t[1]),s=t[2].toLowerCase();return s==="turn"?i*360:s==="rad"?i*180/Math.PI:i}let n=/^to\s+([a-z]+)(?:\s+([a-z]+))?$/i.exec(e);if(!n)return;let r=0,o=0;for(let i of[n[1],n[2]]){if(i===void 0)continue;let s=Po[i.toLowerCase()];if(!s)return;r+=s[0],o+=s[1]}return(Math.atan2(r,-o)*180/Math.PI+360)%360}var Ro={left:0,top:0,center:.5,right:1,bottom:1};function Lo(e){let t=/^(circle|ellipse)?\s*(?:at\s+(\S+)(?:\s+(\S+))?)?$/i.exec(e);if(!t||t[1]===void 0&&t[2]===void 0)return;let n=t[1]?.toLowerCase();if(t[2]===void 0)return n?{shape:n}:void 0;let r=Cn(t[2]),o=t[3]===void 0?.5:Cn(t[3]);return r===void 0||o===void 0?{error:`A radial centre is two percentages or keywords, not "${e}"`}:{...n?{shape:n}:{},cx:r,cy:o}}function Cn(e){let t=Ro[e.toLowerCase()];if(t!==void 0)return t;let n=/^(-?\d*\.?\d+)%$/.exec(e);return n?Number(n[1])/100:void 0}function Fn(e){if(e.length<2)return{error:"A gradient needs at least two colours"};let t=[];for(let n of e){let r=/^([\s\S]*?\S)\s+(-?\d*\.?\d+)%$/.exec(n);if(r&&Co(r[1]))t.push({colour:r[1],at:Number(r[2])/100});else{if(/\s/.test(n.replace(/\([^)]*\)/g,"")))return{error:`"${n}" is not a colour with an optional percentage`};t.push({colour:n})}}return{stops:t}}function Co(e){let t=0;for(let n of e)if(n==="("&&(t+=1),n===")"&&(t-=1),t<0)return!1;return t===0}function Wt(e){let t=e.trim();if(t===""||t==="none")return{shadows:[]};let n=[];for(let r of Fo(t)){let o=Vo(r.trim());if(o.includes("inset"))return{error:"Inner shadows (inset) are not supported yet"};let i=[],s=[];for(let d of o){let l=/^(-?\d*\.?\d+)(px)?$/.exec(d);l&&s.length===0?i.push(Number(l[1])):s.push(d)}if(i.length<2||i.length>4)return{error:`"${r.trim()}" needs x, y, then optional blur and spread`};if(s.length!==1)return{error:`"${r.trim()}" needs one colour after its numbers`};let[u=0,a=0,c=0,f=0]=i;if(c<0)return{error:"A shadow cannot have a negative blur"};n.push({x:u,y:a,blur:c,spread:f,colour:s[0]})}return{shadows:n}}function Fo(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?n+=1:i===")"?n=Math.max(0,n-1):i===","&&n===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function Vo(e){let t=[],n=0,r="";for(let o of e){if(o==="("&&(n+=1),o===")"&&(n=Math.max(0,n-1)),/\s/.test(o)&&n===0){r!==""&&t.push(r),r="";continue}r+=o}return r!==""&&t.push(r),t}function ft(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function Vn(e,t,n){if(n===0)return e;let r=n*Math.PI/180,o=Math.cos(r),i=Math.sin(r),s=e.x-t.x,u=e.y-t.y;return{x:t.x+s*o-u*i,y:t.y+s*i+u*o}}function zt(e,t,n=ft(e)){if(t%360===0)return e;let r=[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}].map(a=>Vn(a,n,t)),o=r.map(a=>a.x),i=r.map(a=>a.y),s=Math.min(...o),u=Math.min(...i);return{x:s,y:u,w:Math.max(...o)-s,h:Math.max(...i)-u}}var Un="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",Bn=16,Wn=400,zn=1.2,dt="#0F172A";function lt(){return{advance(e,t){return e.length*(t.size*.5+t.letterSpacing)},metrics(e){return{ascent:e.size*.8,descent:e.size*.2,lineGap:0}}}}function Xt(e,t){if(e===void 0)return Un;let n=t[e];return n?n.fallback?`${jn(n.family)}, ${n.fallback}`:jn(n.family):e}function jn(e){return/^[A-Za-z][A-Za-z0-9 -]*$/.test(e)?e:JSON.stringify(e)}function Gt(e,t,n,r){let o={family:Xt(t.font,n),size:t.size,weight:t.weight,italic:t.italic,underline:!1,strike:!1,fill:r(t.fill),letterSpacing:t.letterSpacing},i=typeof e=="string"?[e]:e,s=[];for(let u of i){if(typeof u=="string"){u.length>0&&s.push({text:u,style:o});continue}let a=u;a.text.length!==0&&s.push({text:a.text,style:{family:a.font===void 0?o.family:Xt(a.font,n),size:a.size??o.size,weight:a.weight??o.weight,italic:a.italic??o.italic,underline:a.underline??!1,strike:a.strike??!1,fill:a.fill===void 0?o.fill:r(a.fill),letterSpacing:a.letterSpacing??o.letterSpacing,...a.link!==void 0&&V(a.link)?{link:a.link}:{}}})}return s}function zo(e,t){let n=[];for(let r of e)for(let o of r.text.split(/(\n)/))if(o!==""){if(o===`
|
|
8
|
+
`){let i=n[n.length-1];i&&!i.hardBreak?n[n.length-1]={...i,hardBreak:!0}:n.push({text:"",style:r.style,w:0,hardBreak:!0});continue}for(let i of o.match(/\S+\s*|\s+/g)??[])n.push({text:i,style:r.style,w:t.advance(i,r.style),hardBreak:!1})}return n}function Xo(e,t,n){let r=[...e.text],o=[],i="";for(let s of r){let u=i+s;if(i!==""&&n.advance(u,e.style)>t){o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:!1}),i=s;continue}i=u}return i!==""&&o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:e.hardBreak}),o.length>0?o:[e]}function Xn(e,t){let{width:n,measure:r}=t,o=zo(r.itemize?e.flatMap(c=>r.itemize?.(c)??[c]):e,r);if(o.length===0){let c=e[0]?.style,f=c?t.lineHeight*c.size:0;return{lines:c?[Go(c,t.lineHeight)]:[],width:0,height:f}}let i=[],s=[],u=0,a=()=>{i.push(s),s=[],u=0};for(let c of o){let f=s.length===0&&c.w>n&&n>0?Xo(c,n,r):[c];for(let d of f){let l=d.text.trimEnd(),p=l===d.text?d.w:r.advance(l,d.style);s.length>0&&u+p>n&&a(),s.push(d),u+=d.w,d.hardBreak&&a()}}return s.length>0&&i.push(s),Ho(i,t)}function Go(e,t){let n=t*e.size;return{y:0,h:n,baseline:n*.8,w:0,spans:[],style:e}}function Ho(e,t){let n=[],r=0,o=0;return e.forEach((i,s)=>{let u=i.map(v=>v.style.size),a=Math.max(...u,0),c=t.lineHeight*a,f=i.map(v=>t.measure.metrics(v.style)),d=Math.max(...f.map(v=>v.ascent),0),l=Math.max(...f.map(v=>v.descent),0),p=r+(c-(d+l))/2+d,g=Yo(i,t.measure),h=g.reduce((v,S)=>v+S.w,0);o=Math.max(o,h);let x=s===e.length-1||(i[i.length-1]?.hardBreak??!1),k=t.align==="justify"&&!x&&g.length>1,$=Math.max(0,t.width-h),A=t.align==="center"?$/2:t.align==="right"?$:0,y=k?$/(g.length-1):0,b=[],w=A;g.forEach((v,S)=>{b.push({text:v.text,style:v.style,x:w,w:v.w}),w+=v.w+(S<g.length-1?y:0)}),n.push({y:r,h:c,baseline:p,w:h,spans:Jo(b,k)}),r+=c}),{lines:n,width:o,height:r}}function Yo(e,t){let n=[...e];for(;n.length>0;){let r=n[n.length-1],o=r.text.trimEnd();if(o===r.text)break;if(o===""){n.pop();continue}n[n.length-1]={...r,text:o,w:t.advance(o,r.style)};break}return n}function Jo(e,t){if(t)return[...e];let n=[];for(let r of e){let o=n[n.length-1];if(o&&Gn(o.style,r.style)&&Math.abs(o.x+o.w-r.x)<.01){n[n.length-1]={...o,text:o.text+r.text,w:o.w+r.w};continue}n.push(r)}return n}function Gn(e,t){return e.family===t.family&&e.size===t.size&&e.weight===t.weight&&e.italic===t.italic&&e.underline===t.underline&&e.strike===t.strike&&e.fill===t.fill&&e.letterSpacing===t.letterSpacing&&e.link===t.link}function Ht(e,t,n,r,o,i){let s={size:t.size??Bn,weight:t.weight??Wn,lineHeight:t.lineHeight??zn,letterSpacing:t.letterSpacing??0,italic:e.italic??!1,font:typeof e.font=="string"?e.font:void 0,fill:typeof e.fill=="string"?e.fill:dt},u=Gt(e.content,s,r,o),a=Gt(" ",s,r,o).map(c=>({...c,text:""}));return Xn(u.length>0?u:a,{width:n,align:e.align??"left",lineHeight:s.lineHeight,measure:i})}function Yt(e,t,n){let r=t-n;return e.valign==="middle"?r/2:e.valign==="bottom"?r:0}var Hn=["x","y","w","h","left","right","top","bottom","cx","cy"];function Ee(e){return Hn.includes(e)}var Yn=["parent","prev","next","self","root"];function Jt(e){return Yn.includes(e)}var T=class extends Error{position;constructor(t,n){super(t),this.position=n,this.name="ExprSyntaxError"}},Jn=/[A-Za-z_]/,Kt=/[A-Za-z0-9_]/;function qt(e){let t=[],n=0,r=()=>{if(!Jn.test(e[n]??""))throw new T(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&Kt.test(e[n]??"");)n++;return e.slice(s,n)},o=()=>{if(!Kt.test(e[n]??""))throw new T(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&Kt.test(e[n]??"");)n++;return e.slice(s,n)},i=()=>{let s=[r()];for(;e[n]===".";)n++,s.push(o());return s};for(;n<e.length;){let s=e[n]??"";if(/\s/.test(s)){n++;continue}if(/[0-9]/.test(s)){let u=n;for(;n<e.length&&/[0-9]/.test(e[n]??"");)n++;if(e[n]==="."&&/[0-9]/.test(e[n+1]??""))for(n++;n<e.length&&/[0-9]/.test(e[n]??"");)n++;let a=e.slice(u,n),c=Number(a);if(!Number.isFinite(c))throw new T(`Bad number "${a}"`,u);e[n]==="%"?(n++,t.push({type:"percent",value:c})):t.push({type:"number",value:c});continue}if(s==="$"){n++,t.push({type:"token",name:r()});continue}if(s==="@"){n++,t.push({type:"ref",path:i()});continue}if(Jn.test(s)){t.push({type:"word",path:i()});continue}if("+-*/()".includes(s)){n++,t.push({type:"op",value:s});continue}throw new T(`Unexpected character "${s}" at position ${n}`,n)}return t.push({type:"eof"}),t}var Ko={"+":1,"-":1,"*":2,"/":2};function pt(e){try{let t=qt(e),n=new Zt(t),r=n.parseBinary(0);return n.expectEof(),{ok:!0,ast:r}}catch(t){if(t instanceof T)return{ok:!1,message:t.message};throw t}}var Zt=class{tokens;index=0;constructor(t){this.tokens=t}peek(){return this.tokens[this.index]??{type:"eof"}}next(){let t=this.peek();return this.index++,t}expectEof(){if(this.peek().type!=="eof")throw new T("Unexpected trailing input",this.index)}parseBinary(t){let n=this.parseUnary();for(;;){let r=this.peek();if(r.type!=="op"||!qo(r.value))break;let o=Ko[r.value];if(o<t)break;this.next();let i=this.parseBinary(o+1);n={kind:"binary",op:r.value,left:n,right:i}}return n}parseUnary(){let t=this.peek();return t.type==="op"&&(t.value==="-"||t.value==="+")?(this.next(),{kind:"unary",op:t.value,operand:this.parseUnary()}):this.parsePrimary()}parsePrimary(){let t=this.next();switch(t.type){case"number":return{kind:"number",value:t.value};case"percent":return{kind:"percent",value:t.value};case"token":return{kind:"token",name:t.name};case"ref":{if(t.path.length<2)throw new T(`@${t.path.join(".")} needs an edge, for example @${t.path.join(".")}.right`,this.index);return{kind:"nodeRef",path:t.path}}case"word":{let[n,r,...o]=t.path;if(n===void 0||!Jt(n))throw new T(`Unknown name "${t.path.join(".")}". Use $token for a token or @id.edge for a node.`,this.index);if(r===void 0||!Ee(r)||o.length>0)throw new T(`${n} needs an edge, for example ${n}.w`,this.index);return{kind:"relRef",word:n,edge:r}}case"op":{if(t.value==="("){let n=this.parseBinary(0),r=this.next();if(r.type!=="op"||r.value!==")")throw new T("Missing closing parenthesis",this.index);return n}throw new T(`Unexpected "${t.value}"`,this.index)}case"eof":throw new T("Unexpected end of expression",this.index)}}};function qo(e){return e==="+"||e==="-"||e==="*"||e==="/"}function D(e,t){return`${e} ${t}`}function Qt(e){switch(e){case"x":case"left":return["x"];case"y":case"top":return["y"];case"w":return["w"];case"h":return["h"];case"right":case"cx":return["x","w"];case"bottom":case"cy":return["y","h"]}}function en(e,t,n,r,o){switch(e){case"x":case"left":return t;case"y":case"top":return n;case"w":return r;case"h":return o;case"right":return t+r;case"bottom":return n+o;case"cx":return t+r/2;case"cy":return n+o/2}}function tn(e){switch(e){case"x":case"left":case"right":case"cx":return"x";case"y":case"top":case"bottom":case"cy":return"y";case"w":case"h":return}}function nn(e,t,n){let r=d=>{let l=[];for(let p=n.parentOf.get(d);p!==void 0;p=n.parentOf.get(p))l.push(p);return l},o=r(e),i=r(t),s=new Set(i),u=o.find(d=>s.has(d)),a=d=>u===void 0?d:d.slice(0,d.indexOf(u)),c=new Map([[e,1]]),f=(d,l)=>{let p=(c.get(d)??0)+l;p===0?c.delete(d):c.set(d,p)};for(let d of a(o))f(d,1);for(let d of a(i))f(d,-1);return c}function rn(e){switch(e){case"right":case"bottom":return 1;case"cx":case"cy":return .5;default:return 0}}function ht(e){if(e==="x"||e==="w")return"w";if(e==="y"||e==="h")return"h"}function on(e){let t=new Map,n=new Map,r=new Map,o=new Map,i=[];O(e.root,(f,d)=>{t.has(f.id)||t.set(f.id,f),i.push(f),d&&n.set(f.id,d.id),N(f)&&f.children.forEach((l,p)=>{let g=f.children[p-1],h=f.children[p+1];g&&r.set(l.id,g.id),h&&o.set(l.id,h.id)})});let s=new Map;for(let f of i){let d=n.get(f.id);for(;d!==void 0;){let l=t.get(d);if(!l||!le(l))break;d=n.get(d)}d!==void 0&&s.set(f.id,d)}let u=new Map,a=new Map,c=f=>{if(N(f)){if(!le(f)){let d=Kn(f);d.forEach((l,p)=>{let g=d[p-1],h=d[p+1];g&&u.set(l.id,g.id),h&&a.set(l.id,h.id)})}for(let d of f.children)c(d)}};return c(e.root),{rootId:e.root.id,byId:t,parentOf:n,prevOf:r,nextOf:o,layoutParentOf:s,layoutPrevOf:u,layoutNextOf:a,order:i}}function Kn(e){let t=[];for(let n of e.children)N(n)&&le(n)?t.push(...Kn(n)):t.push(n);return t}function mt(e,t,n){if(e.kind==="relRef"){let i=Zo(e.word,t,n);return i===void 0?{ok:!1,message:`${t} has no ${e.word}`}:{ok:!0,nodeId:i,edge:e.edge}}let r=e.path[e.path.length-1]??"",o=e.path.slice(0,-1).join(".");return Ee(r)?n.byId.has(o)?{ok:!0,nodeId:o,edge:r}:{ok:!1,message:`No node @${o}`}:{ok:!1,message:`"${r}" is not an edge of @${o}`}}function Zo(e,t,n){switch(e){case"self":return t;case"root":return n.rootId;case"parent":return n.layoutParentOf.get(t);case"prev":return n.layoutPrevOf.get(t);case"next":return n.layoutNextOf.get(t)}}function sn(e){let t=[],n=on(e),r=Qo(n),o=new Set;ei(r,t),ti(r,e,n,o,t);let i=ni(r);ri(r,i,t);let s=oi(r,i,e,n,o,t);return{nodes:si(e.root,s,r,t),problems:t}}function Qo(e){let t=new Map;for(let n of e.order){let r=n;for(let o of Re(n)){let i=r[o];i!==void 0&&t.set(D(n.id,o),{nodeId:n.id,prop:o,value:i,deps:[]})}}return t}function ei(e,t){for(let n of e.values()){if(!P(n.value))continue;let r=pt(n.value.expr);if(r.ok){n.ast=r.ast;continue}t.push({severity:"error",code:"expression-syntax",message:r.message,nodeId:n.nodeId,prop:n.prop})}}function ti(e,t,n,r,o){for(let i of e.values()){if(!i.ast)continue;let s=new Set,u=a=>{switch(a.kind){case"number":return;case"token":{let c=t.tokens[a.name];typeof c!="number"&&o.push({severity:"error",code:c===void 0?"unknown-token":"token-not-a-number",message:c===void 0?`Unknown token $${a.name}`:`Token $${a.name} is not a number`,nodeId:i.nodeId,prop:i.prop});return}case"percent":{let c=ht(i.prop);if(!c)return;let f=n.layoutParentOf.get(i.nodeId),d=f===void 0?void 0:D(f,c);if(d===void 0||!e.has(d)){o.push({severity:"error",code:"percent-without-parent",message:`${i.nodeId}.${i.prop} uses a percentage but has no parent to measure against`,nodeId:i.nodeId,prop:i.prop});return}s.add(d);return}case"nodeRef":case"relRef":{let c=mt(a,i.nodeId,n);if(!c.ok){r.add(a),o.push({severity:"error",code:"unknown-reference",message:c.message,nodeId:i.nodeId,prop:i.prop});return}let f=l=>{e.has(l)&&s.add(l)},d=tn(c.edge);if(!d){for(let l of Qt(c.edge))f(D(c.nodeId,l));return}for(let l of nn(c.nodeId,i.nodeId,n).keys())f(D(l,d));rn(c.edge)!==0&&f(D(c.nodeId,d==="x"?"w":"h"));return}case"unary":u(a.operand);return;case"binary":u(a.left),u(a.right);return}};u(i.ast),i.deps=[...s]}}function ni(e){let t=new Map,n=new Map;for(let[i,s]of e){t.set(i,s.deps.length);for(let u of s.deps){let a=n.get(u);a?a.push(i):n.set(u,[i])}}let r=[];for(let[i,s]of t)s===0&&r.push(i);let o=[];for(let i=0;i<r.length;i++){let s=r[i];o.push(s);for(let u of n.get(s)??[]){let a=(t.get(u)??0)-1;t.set(u,a),a===0&&r.push(u)}}return o}function ri(e,t,n){if(t.length===e.size)return;let r=new Set(t);for(let[o,i]of e)r.has(o)||n.push({severity:"error",code:"cycle",message:`${i.nodeId}.${i.prop} is part of a dependency cycle`,nodeId:i.nodeId,prop:i.prop})}function oi(e,t,n,r,o,i){let s=new Map,u=(a,c)=>s.get(D(a,c))??0;for(let a of t){let c=e.get(a);if(c){if(!P(c.value)){s.set(a,c.value);continue}if(!c.ast){s.set(a,0);continue}s.set(a,qn(c.ast,c,n,r,o,i,u))}}return s}function qn(e,t,n,r,o,i,s){let u=a=>qn(a,t,n,r,o,i,s);switch(e.kind){case"number":return e.value;case"token":{let a=n.tokens[e.name];return typeof a=="number"?a:0}case"percent":{let a=ht(t.prop);if(!a)return e.value/100;let c=r.layoutParentOf.get(t.nodeId);return c===void 0?0:e.value/100*s(c,a)}case"nodeRef":case"relRef":{if(o.has(e))return 0;let a=mt(e,t.nodeId,r);if(!a.ok)return 0;let c=tn(a.edge);if(!c)return en(a.edge,s(a.nodeId,"x"),s(a.nodeId,"y"),s(a.nodeId,"w"),s(a.nodeId,"h"));let f=rn(a.edge)*s(a.nodeId,c==="x"?"w":"h");for(let[d,l]of nn(a.nodeId,t.nodeId,r))f+=l*s(d,c);return f}case"unary":{let a=u(e.operand);return e.op==="-"?-a:a}case"binary":{let a=u(e.left),c=u(e.right);if(e.op==="/"&&c===0)return i.push({severity:"error",code:"divide-by-zero",message:`${t.nodeId}.${t.prop} divides by zero`,nodeId:t.nodeId,prop:t.prop}),0;let f=ii(e.op,a,c);return Number.isFinite(f)?f:(i.push({severity:"error",code:"not-a-number",message:`${t.nodeId}.${t.prop} did not produce a finite number`,nodeId:t.nodeId,prop:t.prop}),0)}}}function ii(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n}}function si(e,t,n,r){let o=new Map,i=(u,a)=>t.get(D(u,a))??0,s=(u,a,c)=>{let f=i(u.id,"x"),d=i(u.id,"y"),l=i(u.id,"w"),p=i(u.id,"h"),g={};for(let k of Re(u)){let $=D(u.id,k);n.has($)&&(g[k]=t.get($)??0)}(l<0||p<0)&&r.push({severity:"warning",code:"negative-size",message:`${u.id} resolved to a negative size`,nodeId:u.id});let h=a+f,x=c+d;if(o.set(u.id,{id:u.id,type:u.type,x:f,y:d,w:l,h:p,left:f,top:d,right:f+l,bottom:d+p,cx:f+l/2,cy:d+p/2,absX:h,absY:x,values:g}),N(u))for(let k of u.children)s(k,h,x)};return s(e,0,0),o}function un(e){return e.lines.filter(t=>t.spans.length>0)}function xt(e){switch(e.kind){case"text":{let t=un(e),n=Math.max(e.w,...t.map(o=>o.w)),r=Math.max(e.y+e.h,...t.map(o=>o.y+o.h));return{x:e.x,y:e.y,w:n,h:r-e.y}}case"vector":{let t=Mt(e.contours)??{x:e.x,y:e.y,w:e.w,h:e.h},n=e.stroke!==void 0?e.strokeWidth*2:0;return{x:t.x-n,y:t.y-n,w:t.w+n*2,h:t.h+n*2}}case"rect":case"ellipse":{let t=e.stroke!==void 0?e.strokeWidth/2:0;return{x:e.x-t,y:e.y-t,w:e.w+t*2,h:e.h+t*2}}case"frame":case"image":return{x:e.x,y:e.y,w:e.w,h:e.h}}}function $t(e,t){let n=e.x,r=e.y,o=e.x+e.w,i=e.y+e.h;for(let s of t){let u=s.spread+s.blur;n=Math.min(n,e.x+s.x-u),r=Math.min(r,e.y+s.y-u),o=Math.max(o,e.x+e.w+s.x+u),i=Math.max(i,e.y+e.h+s.y+u)}return{x:n,y:r,w:o-n,h:i-r}}var er="vd-paint-";var yt="#CBD5E1",tr="#FFFFFF";function nr(e,t,n={}){let r=[...t.problems],o=[],i=[],s=n.measure??lt(),u=hi(e.tokens,r),a=u.paint,c=new Map;O(e.root,(h,x)=>{if("hidden"in h&&h.hidden===!0)return!1;let k=x?c.get(x.id):void 0,$=t.nodes.get(h.id);if(!$){c.set(h.id,k);return}if(h.type==="frame"){h.skip===!0&&x!==e.root&&r.push({severity:"warning",code:"skip-not-a-page",message:`${h.id}: skip only applies to a page, a frame at the top level`,nodeId:h.id,prop:"skip"});let y={x:$.absX,y:$.absY,w:Math.max(0,$.w),h:Math.max(0,$.h)};c.set(h.id,h.clip===!0?h.id:k),h.clip===!0&&i.push({id:h.id,...y,parent:k}),o.push({kind:"frame",id:h.id,...y,background:a(h.background,h.id,"background",y),clip:k,blend:h.blend??"normal",shadows:se(h.shadow,h.id,e.tokens,r),rotation:0});return}if(c.set(h.id,k),h.type==="text"){o.push(ai(h,$,e,s,r,k,a));return}if(h.type==="image"){o.push({kind:"image",id:h.id,x:$.absX,y:$.absY,w:Math.max(0,$.w),h:Math.max(0,$.h),href:yi(h,e,n.resolveAsset,r),fit:h.fit??"fill",radius:Math.max(0,$.values.radius??0),opacity:Me($.values.opacity??1),clip:k,blend:h.blend??"normal",shadows:se(h.shadow,h.id,e.tokens,r),rotation:$.values.rotation??0});return}if(h.type==="ellipse"){let y=Qn($);o.push({kind:"ellipse",id:h.id,...y,fill:a(h.fill,h.id,"fill",y)??yt,stroke:a(h.stroke,h.id,"stroke",y),strokeWidth:$.values.strokeWidth??0,opacity:Me($.values.opacity??1),clip:k,blend:h.blend??"normal",shadows:se(h.shadow,h.id,e.tokens,r),rotation:$.values.rotation??0});return}if(h.type==="vector"){o.push(pi(h,$,r,k,a,se(h.shadow,h.id,e.tokens,r)));return}if(h.type!=="rect")return;let A=Qn($);o.push({kind:"rect",id:h.id,...A,fill:a(h.fill,h.id,"fill",A)??yt,stroke:a(h.stroke,h.id,"stroke",A),strokeWidth:$.values.strokeWidth??0,radius:Math.max(0,$.values.radius??0),opacity:Me($.values.opacity??1),clip:k,blend:h.blend??"normal",shadows:se(h.shadow,h.id,e.tokens,r),rotation:$.values.rotation??0})});let f=t.nodes.get(e.root.id),d=e.root.w!==void 0&&e.root.h!==void 0,l=d?{x:0,y:0,width:Math.max(0,f?.w??0),height:Math.max(0,f?.h??0)}:ui(o,i),p={x:l.x,y:l.y,w:l.width,h:l.height},g=a(e.root.background,e.root.id,"background",p);return{...l,background:d?g??tr:g,items:o,clips:i,gradients:u.gradients,problems:r}}function ui(e,t){let n=new Map;for(let u of t){let a=u.parent===void 0?void 0:n.get(u.parent);n.set(u.id,a?Zn(u,a):u)}let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let u of e){let a=u.kind==="text"&&un(u).length>0?Math.max(u.h,u.height):u.h,c=u.clip===void 0?void 0:n.get(u.clip),f=zt($t({x:u.x,y:u.y,w:u.w,h:a},u.shadows),u.rotation,ft(u)),d=c?Zn(f,c):f;d.w<=0||d.h<=0||(r=Math.min(r,d.x),o=Math.min(o,d.y),i=Math.max(i,d.x+d.w),s=Math.max(s,d.y+d.h))}return Number.isFinite(r)?{x:r,y:o,width:i-r,height:s-o}:{x:0,y:0,width:0,height:0}}function Zn(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y);return{x:n,y:r,w:Math.min(e.x+e.w,t.x+t.w)-n,h:Math.min(e.y+e.h,t.y+t.h)-r}}function an(e,t={}){return nr(e,sn(e),t)}function ai(e,t,n,r,o,i,s){let u=Math.max(0,t.w),a=Math.max(0,t.h),c={x:t.absX,y:t.absY,w:u,h:a},f=Ht(e,t.values,u,n.fonts,p=>s(p,e.id,"fill",c)??dt,r);!f.lines.every(p=>p.spans.length===0)&&f.height>a+.5&&o.push({severity:"warning",code:"text-overflow",message:`${e.id} needs ${Math.ceil(f.height)}px but its height is ${Math.round(a)}px`,nodeId:e.id,prop:"h"}),ci(e,n,o);let l=t.absY+Yt(e,a,f.height);return{kind:"text",id:e.id,x:t.absX,y:t.absY,w:u,h:a,clip:i,blend:e.blend??"normal",shadows:se(e.shadow,e.id,n.tokens,o),rotation:t.values.rotation??0,opacity:Me(t.values.opacity??1),height:f.height,lines:f.lines.map(p=>({y:l+p.y,h:p.h,baseline:l+p.baseline,w:p.w,spans:p.spans.map(g=>({text:g.text,x:t.absX+g.x,y:l+p.baseline,w:g.w,style:g.style})),...p.style?{style:p.style}:{}}))}}function ci(e,t,n){if(typeof e.content!="string")for(let r of e.content){if(typeof r=="string"||r.link===void 0)continue;let o=V(r.link);if(!o){n.push({severity:"warning",code:"invalid-link",message:`${e.id}: links go to https:, mailto: or #<frame>, not ${JSON.stringify(r.link)}`,nodeId:e.id,prop:"content"});continue}o.kind==="frame"&&!fi(t,o.id)&&n.push({severity:"warning",code:"link-target-missing",message:`${e.id}: links to #${o.id}, which is not a frame`,nodeId:e.id,prop:"content"})}}function fi(e,t){let n=!1;return O(e.root,r=>{if(n)return!1;r.id===t&&r.type==="frame"&&(n=!0)}),n}var Se=new Map,di=512;function li(e){let t=Se.get(e);if(t)return t;let n=kt(e);return Se.size>=di&&Se.delete(Se.keys().next().value),Se.set(e,n),n}function pi(e,t,n,r,o,i){let s=Math.max(0,t.w),u=Math.max(0,t.h),a={x:t.absX,y:t.absY,w:s,h:u},{contours:c,error:f}=li(e.d);f!==void 0&&n.push({severity:"error",code:"bad-path",message:`${e.id}: ${f}`,nodeId:e.id,prop:"d"}),e.view!==void 0&&Ze(e.view)===void 0&&n.push({severity:"warning",code:"bad-view",message:`${e.id}: view must be four numbers, like "0 0 24 24"`,nodeId:e.id,prop:"view"});let d=St(c,Tt(Ot(e.view,s,u),a));return{kind:"vector",id:e.id,...a,d:vt(d),contours:d,fill:o(e.fill,e.id,"fill",a)??yt,stroke:o(e.stroke,e.id,"stroke",a),strokeWidth:t.values.strokeWidth??0,opacity:Me(t.values.opacity??1),rule:e.rule??"nonzero",cap:e.cap??"butt",join:e.join??"miter",clip:r,blend:e.blend??"normal",shadows:i,rotation:t.values.rotation??0}}function rr(e,t,n,r,o){if(e===void 0)return;if(P(e)){o.push({severity:"warning",code:"expression-not-supported",message:`Expressions are not supported for ${r} yet; grammar v0 is numeric only`,nodeId:n,prop:r});return}let i=t[e];if(i===void 0)return e;if(typeof i=="string")return i;o.push({severity:"error",code:"token-not-a-colour",message:`Token $${e} is a number, not a colour`,nodeId:n,prop:r})}function Qn(e){return{x:e.absX,y:e.absY,w:Math.max(0,e.w),h:Math.max(0,e.h)}}function hi(e,t){let n=[],r=new Map;return{paint:(i,s,u,a)=>{let c=rr(i,e,s,u,t);if(c===void 0)return;if(/url\(/i.test(c)){t.push({severity:"error",code:"invalid-paint",message:`${s}: a paint is a colour or a gradient, not ${JSON.stringify(c)}`,nodeId:s,prop:u});return}let f=Ut(c);if("error"in f){t.push({severity:"error",code:"invalid-paint",message:`${s}: ${f.error}`,nodeId:s,prop:u});return}if(f.kind==="solid")return c;let d=`${s}\0${u}\0${c}`,l=r.get(d);if(l!==void 0)return`url(#${l})`;let p=[...r.keys()].filter(x=>x.startsWith(`${s}\0${u}\0`)).length,g=`${er}${s}-${u}${p===0?"":`-${p+1}`}`;r.set(d,g);let h=Bt(f.stops).map(x=>({offset:x.at,colour:or(x.colour,e,s,u,t)}));return n.push(gi(f,g,a,mi(h))),`url(#${g})`},gradients:n}}function se(e,t,n,r){let o=rr(e,n,t,"shadow",r);if(o===void 0)return[];let i=Wt(o);return"error"in i?(r.push({severity:"error",code:"invalid-shadow",message:`${t}: ${i.error}`,nodeId:t,prop:"shadow"}),[]):i.shadows.map(s=>({...s,colour:or(s.colour,n,t,"shadow",r)}))}function mi(e){return e.map((t,n)=>{if(t.colour.trim().toLowerCase()!=="transparent")return t;let r=[e[n-1],e[n+1]].find(o=>o!==void 0&&o.colour.trim().toLowerCase()!=="transparent");return r===void 0?t:{offset:t.offset,colour:r.colour,opacity:0}})}function or(e,t,n,r,o){let i=t[e];return i===void 0?e:typeof i=="string"&&!ct(i)?i:(o.push({severity:"error",code:"invalid-paint",message:`${n}: a gradient stop names $${e}, which is not a colour`,nodeId:n,prop:r}),"transparent")}function gi(e,t,n,r){if(e.kind==="linear"){let c=e.angle*Math.PI/180,f=Math.sin(c),d=-Math.cos(c),l=(Math.abs(n.w*f)+Math.abs(n.h*d))/2,p=n.x+n.w/2,g=n.y+n.h/2;return{id:t,kind:"linear",x1:gt(p-f*l),y1:gt(g-d*l),x2:gt(p+f*l),y2:gt(g+d*l),stops:r}}let o=n.x+n.w*e.cx,i=n.y+n.h*e.cy,s={x:Math.max(o-n.x,n.x+n.w-o),y:Math.max(i-n.y,n.y+n.h-i)};if(e.shape==="circle"||s.x===0||s.y===0){let c=Math.hypot(s.x,s.y);return{id:t,kind:"radial",cx:o,cy:i,rx:c,ry:c,stops:r}}let u=s.x/s.y,a=Math.hypot(s.x/u,s.y);return{id:t,kind:"radial",cx:o,cy:i,rx:a*u,ry:a,stops:r}}function gt(e){return Math.round(e*1e6)/1e6}function Me(e){return Math.min(Math.max(e,0),1)}function yi(e,t,n,r){let o=P(e.src)?void 0:e.src,i=o===void 0?void 0:t.assets[o];if(!i){r.push({severity:"warning",code:"missing-asset",message:`No picture for ${JSON.stringify(o??e.src)} yet: an image slot waiting for one`,nodeId:e.id,prop:"src"});return}let s=n?.(i,o);return s===void 0&&r.push({severity:"warning",code:"unresolved-asset",message:`The bytes for asset "${o}" are not available here`,nodeId:e.id,prop:"src"}),s}var Oe="vd-clip-";function fn(e,t={}){let n=t.indent??" ",r={ids:t.ids??!0,prefix:t.idPrefix??""},o=m(e.width),i=m(e.height),s=`${m(e.x)} ${m(e.y)} ${o} ${i}`,u=[`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${i}" viewBox="${s}">`],a=e.items.filter(c=>c.shadows.length>0);if(e.clips.length>0||e.gradients.length>0||a.length>0){u.push(`${n}<defs>`);for(let c of e.clips)u.push(n+n+ir(c,r.prefix));for(let c of e.gradients)u.push(n+n+sr(c,r.prefix));for(let c of a)u.push(n+n+ur(c,t.shadowsOnly,r.prefix));u.push(`${n}</defs>`)}e.background!==void 0&&u.push(`${n}<rect x="${m(e.x)}" y="${m(e.y)}" width="${o}" height="${i}" fill="${E(X(e.background,r))}"/>`);for(let c of e.items){let f=vi(c,r);f!==""&&u.push(n+f)}return u.push("</svg>"),`${u.join(`
|
|
9
|
+
`)}
|
|
10
|
+
`}function xi(e){return ir(e,"")}function ir(e,t){let n=e.parent===void 0?"":` clip-path="url(#${E(t+Oe+e.parent)})"`;return`<clipPath id="${E(t+Oe+e.id)}"${n}><rect x="${m(e.x)}" y="${m(e.y)}" width="${m(e.w)}" height="${m(e.h)}"/></clipPath>`}function $i(e){return sr(e,"")}function sr(e,t){let n=e.stops.map(o=>`<stop offset="${m(o.offset)}" stop-color="${E(o.colour)}"${o.opacity===void 0?"":` stop-opacity="${m(o.opacity)}"`}/>`).join(""),r=E(t+e.id);return e.kind==="linear"?`<linearGradient id="${r}" gradientUnits="userSpaceOnUse" x1="${m(e.x1)}" y1="${m(e.y1)}" x2="${m(e.x2)}" y2="${m(e.y2)}">${n}</linearGradient>`:`<radialGradient id="${r}" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="1" gradientTransform="matrix(${m(e.rx)} 0 0 ${m(e.ry)} ${m(e.cx)} ${m(e.cy)})">${n}</radialGradient>`}var wi={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"},bi="#94A3B8";function z(e,t){let n=e.clip===void 0?[]:[`clip-path="url(#${E(t+Oe+e.clip)})"`];return e.rotation!==0&&n.push(`transform="${ar(e)}"`),e.shadows.length>0&&n.push(`filter="url(#${E(t+dn+e.id)})"`),e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`),n}var dn="vd-shadow-";function ki(e,t=!1){return ur(e,t,"")}function ur(e,t,n){let r=$t(xt(e),e.shadows),o=2,i=[];e.shadows.forEach((u,a)=>{let c=`s${a}`,f="SourceAlpha";u.spread!==0&&(i.push(`<feMorphology in="${f}" operator="${u.spread>0?"dilate":"erode"}" radius="${m(Math.abs(u.spread))}" result="${c}m"/>`),f=`${c}m`),u.blur>0&&(i.push(`<feGaussianBlur in="${f}" stdDeviation="${m(u.blur/2)}" result="${c}b"/>`),f=`${c}b`),i.push(`<feOffset in="${f}" dx="${m(u.x)}" dy="${m(u.y)}" result="${c}o"/>`,`<feFlood flood-color="${E(u.colour)}" result="${c}c"/>`,`<feComposite in="${c}c" in2="${c}o" operator="in" result="${c}"/>`)});let s=e.shadows.map((u,a)=>`<feMergeNode in="s${e.shadows.length-1-a}"/>`).join("");return`<filter id="${E(n+dn+e.id)}" filterUnits="userSpaceOnUse" x="${m(r.x-o)}" y="${m(r.y-o)}" width="${m(r.w+o*2)}" height="${m(r.h+o*2)}" color-interpolation-filters="sRGB">`+i.join("")+`<feMerge>${s}${t?"":'<feMergeNode in="SourceGraphic"/>'}</feMerge></filter>`}function ar(e){return`rotate(${m(e.rotation)} ${m(e.x+e.w/2)} ${m(e.y+e.h/2)})`}function cr(e){return e.rotation!==0&&e.clip!==void 0}function vi(e,t){if(e.pose!==void 0)return Ei(e,e.pose,t);if(cr(e)){let n=[`clip-path="url(#${E(t.prefix+Oe+e.clip)})"`];e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`);let r=cn({...e,clip:void 0,blend:"normal"},t);return r===""?"":`<g ${n.join(" ")}>${r}</g>`}return cn(e,t)}function Ei(e,t,n){let r=cn({...e,clip:void 0,blend:"normal",shadows:e.shadows},n);if(r==="")return"";let o=[];e.clip!==void 0&&o.push(`clip-path="url(#${E(n.prefix+Oe+e.clip)})"`),t.opacity<1&&o.push(`opacity="${m(t.opacity)}"`),e.blend!=="normal"&&o.push(`style="mix-blend-mode:${e.blend}"`);let i=t.sx===1&&t.sy===1&&t.tx===0&&t.ty===0?r:`<g transform="${fr(t)}">${r}</g>`;return o.length===0?i:`<g ${o.join(" ")}>${i}</g>`}function fr(e){return`matrix(${m(e.sx)} 0 0 ${m(e.sy)} ${m(e.tx)} ${m(e.ty)})`}function cn(e,t){switch(e.kind){case"ellipse":return Ti(e,t);case"frame":return Si(e,t);case"image":return Mi(e,t);case"rect":return Oi(e,t);case"text":return Ii(e,t);case"vector":return _i(e,t)}}function X(e,t){return/url\(/i.test(e)&&!e.startsWith("url(#")?"none":t.prefix!==""&&e.startsWith("url(#")?`url(#${t.prefix}${e.slice(5)}`:e}function Si(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${m(e.x)}"`,`y="${m(e.y)}"`,`width="${m(e.w)}"`,`height="${m(e.h)}"`,`fill="${e.background===void 0?"none":E(X(e.background,t))}"`,...z(e,t.prefix)),`<rect ${n.join(" ")}/>`}function Mi(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${m(e.x)}"`,`y="${m(e.y)}"`,`width="${m(e.w)}"`,`height="${m(e.h)}"`),e.href===void 0?(e.radius>0&&n.push(`rx="${m(e.radius)}"`),n.push('fill="none"',`stroke="${E(bi)}"`,'stroke-width="1"','stroke-dasharray="4 4"',...z(e,t.prefix)),`<rect ${n.join(" ")}/>`):(n.push(`href="${E(e.href)}"`,`preserveAspectRatio="${wi[e.fit]}"`),e.opacity<1&&n.push(`opacity="${m(e.opacity)}"`),n.push(...z(e,t.prefix)),`<image ${n.join(" ")}/>`)}function Oi(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${m(e.x)}"`,`y="${m(e.y)}"`,`width="${m(e.w)}"`,`height="${m(e.h)}"`),e.radius>0&&n.push(`rx="${m(e.radius)}"`),n.push(`fill="${E(X(e.fill,t))}"`),e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${E(X(e.stroke,t))}"`,`stroke-width="${m(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${m(e.opacity)}"`),n.push(...z(e,t.prefix)),`<rect ${n.join(" ")}/>`}function dr(e,t){let n=[`fill="${E(X(e.fill,t))}"`];return e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${E(X(e.stroke,t))}"`,`stroke-width="${m(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${m(e.opacity)}"`),n}function Ti(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`cx="${m(e.x+e.w/2)}"`,`cy="${m(e.y+e.h/2)}"`,`rx="${m(e.w/2)}"`,`ry="${m(e.h/2)}"`,...dr(e,t),...z(e,t.prefix)),`<ellipse ${n.join(" ")}/>`}function _i(e,t){if(e.d==="")return"";let n=[];t.ids&&n.push(`id="${E(e.id)}"`),n.push(`d="${E(e.d)}"`,...dr(e,t));let r=e.pose?.trace;if(r!==void 0&&e.stroke!==void 0){let i=m(Qe(e.contours)+1);n.push(`stroke-dasharray="${i} ${i}"`,`stroke-dashoffset="${m((Qe(e.contours)+1)*(1-r))}"`)}let o=e.pose?.fillOpacity;return o!==void 0&&o<1&&n.push(`fill-opacity="${m(o)}"`),e.rule!=="nonzero"&&n.push(`fill-rule="${e.rule}"`),e.cap!=="butt"&&n.push(`stroke-linecap="${e.cap}"`),e.join!=="miter"&&n.push(`stroke-linejoin="${e.join}"`),n.push(...z(e,t.prefix)),`<path ${n.join(" ")}/>`}function Ii(e,t){if(e.lines.every(o=>o.spans.length===0))return"";let n=[];t.ids&&n.push(`id="${E(e.id)}"`),n.push('xml:space="preserve"'),e.opacity<1&&n.push(`opacity="${m(e.opacity)}"`),n.push(...z(e,t.prefix));let r=[];for(let o of e.lines)for(let i of o.spans)i.text!==""&&r.push(Ai(i,t));return`<text ${n.join(" ")}>${r.join("")}</text>`}function Ai(e,t){let r=`<tspan ${[`x="${m(e.x)}"`,`y="${m(e.y)}"`,...Ni(e.style,t)].join(" ")}>${Pi(e.text)}</tspan>`;return e.style.link===void 0?r:`<a href="${E(e.style.link)}">${r}</a>`}function Ni(e,t){let n=[`font-family="${E(e.family)}"`,`font-size="${m(e.size)}"`,`fill="${E(X(e.fill,t))}"`];e.weight!==400&&n.push(`font-weight="${m(e.weight)}"`),e.italic&&n.push('font-style="italic"'),e.letterSpacing!==0&&n.push(`letter-spacing="${m(e.letterSpacing)}"`);let r=[e.underline?"underline":"",e.strike?"line-through":""].filter(Boolean).join(" ");return r&&n.push(`text-decoration="${r}"`),n}function Pi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function E(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function rf(e,t={}){let{resolveAsset:n,measure:r,...o}=t;return fn(an(e,{...n?{resolveAsset:n}:{},...r?{measure:r}:{}}),o)}export{O as a,L as b,V as c,U as d,ge as e,$n as f,oe as g,wn as h,He as i,Ye as j,Qe as k,Ar as l,pr as m,hr as n,mr as o,gr as p,io as q,wo as r,bo as s,Rn as t,Ln as u,_o as v,Io as w,Ao as x,Vn as y,sn as z,lt as A,nr as B,an as C,fn as D,xi as E,$i as F,dn as G,ki as H,ar as I,cr as J,fr as K,rf as L};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{f as O}from"./chunk-
|
|
1
|
+
/*! @getv.design/embed v0.3.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{f as O}from"./chunk-P57LNVS3.js";import{a as k,d as P,f as S}from"./chunk-UAVO4POT.js";import{a as x,o as F}from"./chunk-JIHH634P.js";function _(r="vd"){let e=0;return()=>`${r}${++e}-`}var A={bytes:1e6,nodes:5e3};function Z(r){let e=/^\s*([^\s{]+)/.exec(r??"")?.[1]?.toLowerCase();return e==="vd"||e==="vdesign"}function E(r){let e={},s=(r??"").trim().replace(/^\S+/,""),t=/([A-Za-z][\w-]*)(?:=(?:"((?:[^"\\]|\\.)*)"|'([^']*)'|(\S+)))?/g;for(let a of s.matchAll(t)){let i=a[1]?.toLowerCase(),o=a[2]?.replace(/\\(.)/g,"$1")??a[3]??a[4];switch(i){case"page":o!==void 0&&o!==""&&(e.page=/^\d+$/.test(o)?Number(o):o);break;case"src":o&&(e.src=o);break;case"height":{let d=Number(o);Number.isFinite(d)&&d>0&&d<=1e4&&(e.height=d);break}case"mode":(o==="static"||o==="view")&&(e.mode=o);break;case"source":e.source=o===void 0||o==="true";break;case"alt":o!==void 0&&(e.alt=o);break;default:break}}return e}function G(r,e,s={}){let t=typeof e=="string"?E(e):e,a={...A,...s.limits},i=typeof r=="string"?r:"";if(t.src!==void 0){let n;try{n=s.resolveSrc?.(t.src)}catch{n=void 0}if(n===void 0)return l(i,[g("src-unresolved",`Could not read ${t.src}.`)]);i=n}if(i.length>a.bytes)return l(t.src===void 0?i:"",[g("too-large",`This design is over ${a.bytes} characters, the most a fence draws.`)]);let{document:o,problems:d}=k(i),h=P(o).document;if(B(h)>a.nodes)return l(t.src===void 0?i:"",[g("too-large",`This design has over ${a.nodes} shapes, the most a fence draws.`)]);if(S(h).length===0){let n=d.filter(m=>m.severity==="error");return l(t.src===void 0?i:"",[...n,...n.length===0?[g("no-pages","This design has no page to draw.")]:[]])}let R=s.renderer??O(),j=s.idPrefix??z,f,v=[];try{f=R.renderSvg(o,{...t.page===void 0?{}:{page:t.page},idPrefix:j(),onProblems:n=>v.push(...n)})}catch(n){return l(t.src===void 0?i:"",[g("no-such-page",n instanceof Error?n.message:String(n))])}let b=t.mode??s.mode??"static",$=t.alt??h.title??"Design",L=s.output==="img"||s.inlineStyles===!1&&/ style="/.test(f)?`<img class="vd-figure-art" alt="${c($)}" src="data:image/svg+xml;base64,${T(f)}">`:`<div class="vd-figure-art" role="img" aria-label="${c($)}">${N(f).trimEnd()}</div>`,y=["vd-figure"],u=[];for(let[n,m]of s.attributes??[])!/^[a-z][a-z0-9-]*$/i.test(n)||/^on/i.test(n)||n==="style"||(n==="class"?y.push(...m.split(/\s+/).filter(Boolean)):u.push(`${n}="${c(m)}"`));u.unshift(`class="${c(y.join(" "))}"`,`data-vd-mode="${b}"`),t.page!==void 0&&u.push(`data-vd-page="${c(String(t.page))}"`),t.height!==void 0&&u.push(`data-vd-height="${t.height}"`),b==="view"&&u.push(`data-vd-source="${T(i)}"`);let p=[`<figure ${u.join(" ")}>`,L],w=C([...d,...v]);return w.length>0&&p.push(I(w)),t.source&&p.push(`<details class="vd-figure-source"><summary>Source</summary><pre><code class="language-vd">${c(i)}</code></pre></details>`),p.push("</figure>"),`${p.join("")}
|
|
3
3
|
`}function N(r){return r.replace(/<a href="#[^"]*">(<tspan[^>]*>[^<]*<\/tspan>)<\/a>/g,"$1")}function T(r){return F(new TextEncoder().encode(r))}var z=_();function B(r){let e=0;return x(r.root,()=>{e+=1}),e}function l(r,e){let s=e.length>0?I(e):"";return`<pre><code class="language-vd">${c(r)}</code></pre>${s}
|
|
4
4
|
`}function I(r){return`<ul class="vd-problems">${r.map(s=>`<li data-severity="${s.severity}">${c(s.message)}</li>`).join("")}</ul>`}function C(r){let e=new Set;return r.filter(s=>{let t=`${s.code}\0${s.message}`;return e.has(t)?!1:(e.add(t),!0)})}function g(r,e){return{code:r,message:e,severity:"error"}}function c(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export{_ as a,Z as b,E as c,G as d};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{a as m,b as w,d as g,e as O,f as P,g as S,h as y,i as p}from"./chunk-
|
|
1
|
+
/*! @getv.design/embed v0.3.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as m,b as w,d as g,e as O,f as P,g as S,h as y,i as p}from"./chunk-UAVO4POT.js";import{L as R,n as v}from"./chunk-JIHH634P.js";import{b as h}from"./chunk-ACHGJ7UR.js";function E(e){return m(e)}async function L(e,n={}){let t=n.fonts??"approximate";if(!x.includes(t))throw new TypeError(`renderSvg: fonts must be one of ${x.join(", ")}; got ${String(t)}.`);let o=t==="exact"?y(n.fontBase,F()):void 0,{document:i,blocks:a,problems:s}=await O(e),r=n.page===void 0?i:D(i,n.page),u=B(a),f=n.idPrefix,d=[...s],c;if(t==="exact")if(o===void 0)d.push(p([],"no fontBase was given and this build has no default"));else{let{exactSvg:l}=await import("./fonts.js"),b=await l(r,{base:o,resolveAsset:u,...f?{idPrefix:f}:{}});"svg"in b?c=b.svg:d.push(p(b.failures))}return c??=R(r,{ids:!1,resolveAsset:u,...f?{idPrefix:f}:{}}),n.onProblems?.(d),c}function M(e){return typeof e=="string"?w(e).vd:void 0}function C(e){let{document:n,problems:t}=m(e),{document:o}=g(n),{vd:i,offset:a}=typeof e=="string"?w(e):{vd:void 0,offset:0},s=new Map;if(i!==void 0){let r=/^frame\s+(\S+)/;i.split(`
|
|
3
3
|
`).some((u,f)=>{if(u.startsWith("--- payload"))return!0;let d=r.exec(u)?.[1];return d!==void 0&&!s.has(d)&&s.set(d,f+1+a),!1})}return{...o.title===void 0?{}:{title:o.title},pages:P(o).map(r=>({id:r.id,...r.name===void 0?{}:{name:r.name},...s.has(r.id)?{line:s.get(r.id)}:{}})),problems:t}}async function W(e={}){let n=e.fonts??"approximate";if(!x.includes(n))throw new TypeError(`createRenderer: fonts must be one of ${x.join(", ")}; got ${String(n)}.`);let t,o="approximate",i,a;if(n==="exact")if(t=y(e.fontBase,F()),t===void 0)a=p([],"no fontBase was given and this build has no default");else{let s=await import("./fonts.js"),r=await s.exactFontsAt(t).ensureAll();i=s.exactSvgNow,o=r.length<s.BUNDLED_FACE_COUNT?"exact":"approximate",r.length>0&&(a=p(r))}return N({fonts:o,base:t,exactNow:i,failed:a})}function _(){return N({fonts:"approximate",base:void 0,exactNow:void 0,failed:void 0})}function N(e){let{fonts:n,base:t,exactNow:o,failed:i}=e;return{fonts:n,renderSvg(a,s={}){let r=typeof a=="string"?g(m(a).document):g(a),u=s.page===void 0?r.document:D(r.document,s.page),f=B(r.blocks),d=s.idPrefix,c=[...r.problems],l;return n==="exact"&&t!==void 0&&o!==void 0?(l=o(u,{base:t,resolveAsset:f,...d?{idPrefix:d}:{}}),l===void 0&&i&&c.push(i)):i&&c.push(i),l??=R(u,{ids:!1,resolveAsset:f,...d?{idPrefix:d}:{}}),s.onProblems?.(c),l}}}function B(e){return n=>{let t=e.get(n.hash);return t===void 0?void 0:v(n.type,t)}}var x=["approximate","exact"];function F(){let e=import.meta.url;if(typeof e!="string")return h;let t=typeof globalThis.process?.getBuiltinModule=="function",o=/\/dist\/chunks\/[^/]*$/.test(e)?"../../fonts/":"../fonts/";return e.startsWith("file:")&&t?new URL(o,e).href:h}function D(e,n){let t=S(e,n);return{...e,root:{...e.root,children:e.root.children.map(o=>o===t?o:{...o,hidden:!0})}}}export{E as a,L as b,M as c,C as d,W as e,_ as f};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{
|
|
1
|
+
/*! @getv.design/embed v0.3.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{m as l,q as d,r as p,s as g}from"./chunk-JIHH634P.js";import{a as m}from"./chunk-ACHGJ7UR.js";var h=Symbol.for(`vdesign.embed.documents@${m}`),y=globalThis[h]??=new WeakMap,v=/^Line (\d+): /;function w(e){let n=v.exec(e.message);return{...n?{line:Number(n[1])}:{},code:e.code,message:e.message,severity:e.severity}}function f(e){if(typeof e!="string")return c(d("").document,new Map,[{code:"not-text",message:`parse() takes .vd text, not ${e===null?"null":typeof e}.`,severity:"error"}]);let n=D(e);if(n.vd===void 0)return c(d("").document,new Map,[{code:"not-vd",message:"This SVG carries no vDesign document: only a .vd.svg exported from vDesign does.",severity:"error"}]);let{head:t,blocks:o}=l(n.vd),r=d(t),s=r.problems.map(w).map(i=>i.line===void 0?i:{...i,line:i.line+n.offset});return c(r.document,o,s)}function D(e){if(!g(e))return{vd:e,offset:0};let n=p(e);if(n===void 0)return{vd:void 0,offset:0};let t=e.indexOf("<vd:document"),o=e.indexOf("</vd:document",t),r=e.indexOf("<![CDATA[",t);if(r===-1||o!==-1&&r>o){let u=e.indexOf(">",t)+1,b=e.slice(0,u).split(`
|
|
3
3
|
`).length-1;return{vd:n,offset:b+(e[u]===`
|
|
4
4
|
`?1:0)}}let s=r+9,i=e.slice(0,s).split(`
|
|
5
5
|
`).length-1;return{vd:n,offset:i+(e[s]===`
|