@getv.design/embed 0.1.2 → 0.1.4

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 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.1.2/dist/view.js';
39
+ import { view } from 'https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.4/dist/view.js';
40
40
 
41
41
  const text = await (await fetch('/designs/home.vd')).text();
42
42
  await view(document.querySelector('#design'), text);
@@ -187,7 +187,7 @@ has no `problems` or `fonts` event yet to say so.
187
187
  ### Where the faces come from
188
188
 
189
189
  The faces come from `fontBase`, by default this package's `fonts/` folder on
190
- jsDelivr (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.2/fonts/`). That means
190
+ jsDelivr (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.4/fonts/`). That means
191
191
  your readers' browsers request the faces from jsDelivr, and a content security
192
192
  policy needs it in `connect-src`. To keep those requests on your own origin,
193
193
  copy `node_modules/@getv.design/embed/fonts/` to your site and point `fontBase` at it:
@@ -216,7 +216,7 @@ The embed's styles reach the page by one of two routes.
216
216
  ```
217
217
 
218
218
  Link them before the embed runs, from your own origin or from the CDN
219
- (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.2/view.css`). The id is what
219
+ (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.4/view.css`). The id is what
220
220
  the embed looks for: linked without it, the stylesheet still works, but
221
221
  the embed inserts its `<style>` as well.
222
222
 
@@ -1,4 +1,4 @@
1
- @getv.design/embed v0.1.2
1
+ @getv.design/embed v0.1.4
2
2
 
3
3
  Third-party notices.
4
4
 
@@ -0,0 +1,8 @@
1
+ /*! @getv.design/embed v0.1.4. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ function D(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 J="--- payload base64 ---",Ln="sha256-";function Bt(e){let t=jn(e);return t===-1?{head:e,payload:""}:{head:e.slice(0,t),payload:e.slice(t+J.length)}}function Vn(e){let{head:t,payload:n}=Bt(e);return{head:t,blocks:zt(n)}}function zt(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(Ln)&&t.set(o,n.slice(r+1).trim())}return t}function Dn(e,t){return`data:${e};base64,${t}`}function Fn(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 jn(e){if(e.startsWith(J))return 0;let t=e.indexOf(`
4
+ ${J}`);return t===-1?-1:t+1}function ee(e){return{expr:e}}function _(e){return typeof e=="object"&&e!==null&&typeof e.expr=="string"}var me=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],te=["left","center","right","justify"],ne=["top","middle","bottom"],re=["cover","contain","fill"],ge=["nonzero","evenodd"],xe=["butt","round","square"],$e=["miter","round","bevel"],Gt=["canvas","frame","group"];function we(e){return Gt.includes(e)}function P(e){return we(e.type)}function oe(e){return e.type==="group"}var Jt={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 ke(e){return Jt[e.type]}function T(e,t,n){if(t(e,n)!==!1&&P(e))for(let r of e.children)T(r,t,e)}function Ye(e,t){let n;return T(e,r=>{if(n)return!1;r.id===t&&(n=r)}),n}var ie=["design"],X="design";var ve=[1,2,3,4],F="doc";function se(e){return{type:"canvas",...e}}function be(e={}){return{version:4,kind:e.kind??X,...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??se({id:F,children:[]})}}var Ee=["cut","fade","push","slide"],Se=["cut","fade","rise","drop","pop"],Cn=400,ue=1e4;function Y(e){let t=e.trim();return t==="back"?{kind:"back"}:t==="next"?{kind:"next"}:D(t)}function ae(e){return e===void 0||e.enter===void 0&&e.duration===void 0&&e.scroll!==!0&&e.lines.length===0}function Oe(e){return e.enter!==void 0||e.exit!==void 0||e.go!==void 0}function Me(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 Ke(e){let t=new Map;for(let n of e.root.children)n.type==="frame"&&T(n,r=>{t.set(r.id,n.id)});return t}function Un(e){let t=new Set;return T(e,n=>{t.add(n.id)}),t}function ce(e,t){let n=e.motion;if(!n)return[];let r=[],o=He(e),i=Ke(e),s=Un(e.root),a=(u,c)=>{let f=t?.(u,c);return f===void 0?"":`Line ${f}: `};for(let u of Me(e)){let c=n[u];if(c){if(!o.has(u)){r.push({severity:"warning",code:"motion-not-a-page",message:`${a(u)}motion ${u}: ${u} is not a page (a top-level frame), so none of it plays`,nodeId:u});continue}for(let f of c.lines){let d=a(u,f.id);s.has(f.id)?i.get(f.id)!==u&&r.push({severity:"warning",code:"motion-wrong-page",message:`${d}motion ${u}: ${f.id} is not on ${u}, so Play skips it`,nodeId:f.id}):r.push({severity:"warning",code:"unknown-reference",message:`${d}motion ${u}: no node ${f.id}`,nodeId:f.id});let l=f.go===void 0?void 0:Y(f.go);l?.kind==="frame"&&!Wn(e,l.id)&&r.push({severity:"warning",code:"unknown-reference",message:`${d}motion ${u}: go=#${l.id} names no frame`,nodeId:f.id})}}}return r}function Wn(e,t){let n=!1;return T(e.root,r=>{if(n)return!1;r.id===t&&(n=r.type==="frame")}),n}function y(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 Bn={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function qe(e){let t=[],n,r=0,o=0,i=0,s=0,a,u,c=Gn(e),f=()=>(n||(n={anchors:[{x:r,y:o}],closed:!1},t.push(n)),n.anchors[n.anchors.length-1]),d=(p,w)=>{f(),n?.anchors.push({x:p,y:w}),r=p,o=w},l=(p,w,v,g)=>{f().out=p,n?.anchors.push({x:v,y:g,in:w}),r=v,o=g},h="",$=!0;for(;c.more();){let p=c.command();if(p!==void 0)h=p,$=!0;else if(h===""||h.toUpperCase()==="Z")return{contours:Te(t),error:`Expected a command at ${c.at()}`};let w=h.toUpperCase(),v=h!==w,g=Bn[w];if(g===void 0)return{contours:Te(t),error:`Unknown command ${h}`};if(w==="Z"){n&&(n.closed=!0),n=void 0,r=i,o=s,a=void 0,u=void 0,h="";continue}let N=w==="A"?c.arc():c.numbers(g);if(N===void 0)return{contours:Te(t),error:`${h} expects ${g} numbers at ${c.at()}`};let m=v?r:0,k=v?o:0,x=b=>N[b];switch(w){case"M":$&&(n={anchors:[{x:m+x(0),y:k+x(1)}],closed:!1},t.push(n),r=i=m+x(0),o=s=k+x(1),h=v?"l":"L"),a=u=void 0;break;case"L":d(m+x(0),k+x(1)),a=u=void 0;break;case"H":d(m+x(0),o),a=u=void 0;break;case"V":d(r,k+x(0)),a=u=void 0;break;case"C":{let b={x:m+x(2),y:k+x(3)};l({x:m+x(0),y:k+x(1)},b,m+x(4),k+x(5)),a=b,u=void 0;break}case"S":{let b=a?{x:2*r-a.x,y:2*o-a.y}:{x:r,y:o},S={x:m+x(0),y:k+x(1)};l(b,S,m+x(2),k+x(3)),a=S,u=void 0;break}case"Q":case"T":{let b=w==="Q"?{x:m+x(0),y:k+x(1)}:u?{x:2*r-u.x,y:2*o-u.y}:{x:r,y:o},S=w==="Q"?m+x(2):m+x(0),L=w==="Q"?k+x(3):k+x(1),U={x:r+2/3*(b.x-r),y:o+2/3*(b.y-o)},W={x:S+2/3*(b.x-S),y:L+2/3*(b.y-L)};l(U,W,S,L),u=b,a=void 0;break}case"A":{let b=m+x(5),S=k+x(6);for(let[L,U,W]of Jn(r,o,x(0),x(1),x(2),x(3)!==0,x(4)!==0,b,S))l(L,U,W.x,W.y);(r!==b||o!==S)&&d(b,S),a=u=void 0;break}}$=!1}return{contours:Te(t)}}function Te(e){return e.map(t=>{let n=[...t.anchors];if(t.closed&&n.length>1){let r=n[0],o=n[n.length-1];fe(r,o)&&(n.pop(),n[0]={...r,...o.in?{in:o.in}:{}})}return{anchors:n.map(zn),closed:t.closed}})}function zn(e){let t={x:e.x,y:e.y};return e.in&&!fe(e.in,e)&&(t.in=e.in),e.out&&!fe(e.out,e)&&(t.out=e.out),t}function fe(e,t,n=1e-6){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}function Gn(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 a=0;a<i;a+=1){let u=r();if(u===void 0)return;s.push(u)}return s},arc(){let i=this.numbers(3),s=o(),a=o(),u=this.numbers(2);if(!(!i||s===void 0||a===void 0||!u))return[...i,s,a,...u]},at(){return t}}}function Jn(e,t,n,r,o,i,s,a,u){let c=Math.abs(n),f=Math.abs(r);if(c===0||f===0||e===a&&t===u)return[];let d=o*Math.PI/180,l=Math.cos(d),h=Math.sin(d),$=(e-a)/2,p=(t-u)/2,w=l*$+h*p,v=-h*$+l*p,g=w*w/(c*c)+v*v/(f*f);g>1&&(c*=Math.sqrt(g),f*=Math.sqrt(g));let N=c*c*f*f-c*c*v*v-f*f*w*w,m=c*c*v*v+f*f*w*w,k=(i===s?-1:1)*Math.sqrt(Math.max(0,N/m)),x=k*c*v/f,b=-k*f*w/c,S=l*x-h*b+(e+a)/2,L=h*x+l*b+(t+u)/2,U=(O,V,z,G)=>{let Z=O*z+V*G,ye=Math.hypot(O,V)*Math.hypot(z,G),Q=Math.acos(Math.min(1,Math.max(-1,Z/ye)));return O*G-V*z<0?-Q:Q},W=U(1,0,(w-x)/c,(v-b)/f),B=U((w-x)/c,(v-b)/f,(-w-x)/c,(-v-b)/f);!s&&B>0&&(B-=2*Math.PI),s&&B<0&&(B+=2*Math.PI);let Je=Math.max(1,Math.ceil(Math.abs(B)/(Math.PI/2)-1e-9)),Xe=B/Je,he=4/3*Math.tan(Xe/4),Ct=O=>({x:S+c*Math.cos(O)*l-f*Math.sin(O)*h,y:L+c*Math.cos(O)*h+f*Math.sin(O)*l}),Ut=O=>({x:-c*Math.sin(O)*l-f*Math.cos(O)*h,y:-c*Math.sin(O)*h+f*Math.cos(O)*l}),Wt=[];for(let O=0;O<Je;O+=1){let V=W+O*Xe,z=V+Xe,G=Ct(V),Z=O===Je-1?{x:a,y:u}:Ct(z),ye=Ut(V),Q=Ut(z);Wt.push([{x:G.x+he*ye.x,y:G.y+he*ye.y},{x:Z.x-he*Q.x,y:Z.y-he*Q.y},Z])}return Wt}function Ze(e){let t=[],n=r=>`${y(r.x)} ${y(r.y)}`;for(let r of e){let{anchors:o}=r,i=o[0];if(!i)continue;t.push(`M${n(i)}`);let s=Ne(r);for(let a=0;a<s;a+=1){let u=o[a],c=o[(a+1)%o.length],f=r.closed&&a===o.length-1;!u.out&&!c.in?f||t.push(`L${n(c)}`):t.push(`C${n(u.out??u)} ${n(c.in??c)} ${n(c)}`)}r.closed&&t.push("Z")}return t.join(" ")}function Ne(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,a=s*s*s,u=3*s*s*t,c=3*s*t*t,f=t*t*t;return{x:a*n.x+u*r.x+c*o.x+f*i.x,y:a*n.y+u*r.y+c*o.y+f*i.y}}function tt(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 nt(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 u of s.anchors)i(u);let a=Ne(s);for(let u=0;u<a;u+=1){let c=Qe(s,u);for(let f of Xn(c))i(et(c,f))}}if(t!==1/0)return{x:t,y:n,w:r-t,h:o-n}}function Xn(e){let[t,n,r,o]=e,i=[];for(let s of["x","y"]){let a=-t[s]+3*n[s]-3*r[s]+o[s],u=2*(t[s]-2*n[s]+r[s]),c=n[s]-t[s];if(Math.abs(a)<1e-12){Math.abs(u)>1e-12&&i.push(-c/u);continue}let f=u*u-4*a*c;if(f<0)continue;let d=Math.sqrt(f);i.push((-u+d)/(2*a),(-u-d)/(2*a))}return i.filter(s=>s>0&&s<1)}function Ie(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 rt(e,t,n){return Ie(e)??{x:0,y:0,w:t,h:n}}function ot(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 Xt(e,t=.5){let[n,r,o,i]=e;if(fe(n,r)&&fe(o,i))return[n,i];let a=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),u=Math.min(256,Math.max(4,Math.ceil(Math.sqrt(a/t)))),c=[];for(let f=0;f<=u;f+=1)c.push(et(e,f/u));return c}function Yn(e,t,n){let r=0,o=0;for(let i of e){let s=Hn(i);if(s.length!==0){if(n.reach>0){let a=i.closed?s.length:s.length-1;for(let u=0;u<a;u+=1){let c=s[u],f=s[(u+1)%s.length];if(Kn(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 a=0;a<s.length;a+=1){let u=s[a],c=s[(a+1)%s.length];u.y<=t.y!=c.y<=t.y&&u.x+(t.y-u.y)/(c.y-u.y)*(c.x-u.x)>t.x&&(o+=1,r+=c.y>u.y?1:-1)}}}return n.fill?n.rule==="evenodd"?o%2===1:r!==0:!1}function Hn(e){let t=e.anchors[0];if(!t)return[];let n=[{x:t.x,y:t.y}],r=Ne(e);for(let o=0;o<r;o+=1)n.push(...Xt(Qe(e,o)).slice(1));return e.closed&&n.length>1&&n.pop(),n}function Kn(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 Ae={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"]]},Pe=[["font","string"],["size","number"],["weight","number"],["italic","boolean"],["underline","boolean"],["strike","boolean"],["fill","string"],["letterSpacing","number"],["link","string"]];var it=[["enter","pageEffect"],["duration","number"],["scroll","boolean"]],_e=[["enter","nodeEffect"],["exit","nodeEffect"],["duration","number"],["delay","number"],["step","boolean"],["together","boolean"],["go","string"]],Kt=Object.keys(Ae);function Re(e){return Kt.includes(e)}function st(e,t){return Ae[e].find(([n])=>n===t)?.[1]}function I(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=K(e);return r===void 0?{error:`Malformed quoted string ${e}`}:Yt(r,t,e)}if(rr(e)){if(!er(t))return{error:tr(e,t)};let r=Zt(e).trim();return r===""?{error:"Empty expression"}:{value:ee(r)}}return t==="numberValue"&&qt.test(e)?{value:ee(e)}:Yt(e,t,e)}var qt=/^-?\d+(?:\.\d+)?%$/;function er(e){return e==="numberValue"||e==="stringValue"}function tr(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 nr(e,t){let n=/^(-?\d+(?:\.\d+)?)([A-Za-z]+)$/.exec(e);return n?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"?qt.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 Yt(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}${nr(e,t)}`}}case"align":return te.includes(e)?{value:e}:{error:`Expected one of ${te.join(", ")}, got ${n}`};case"valign":return ne.includes(e)?{value:e}:{error:`Expected one of ${ne.join(", ")}, got ${n}`};case"fontStyle":return e==="normal"||e==="italic"?{value:e}:{error:`Expected normal or italic, got ${n}`};case"imageFit":return re.includes(e)?{value:e}:{error:`Expected one of ${re.join(", ")}, got ${n}`};case"fillRule":return H(ge,e,n);case"lineCap":return H(xe,e,n);case"lineJoin":return H($e,e,n);case"blendMode":return H(me,e,n);case"pageEffect":return H(Ee,e,n);case"nodeEffect":return H(Se,e,n);default:return{value:e}}}function H(e,t,n){return e.includes(t)?{value:t}:{error:`Expected one of ${e.join(", ")}, got ${n}`}}function rr(e){return/^[$@(]/.test(e)}function K(e){try{let t=JSON.parse(e);return typeof t=="string"?t:void 0}catch{return}}function Zt(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 Qt(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 ut(e,t,n){let r=n===void 0?void 0:A(n);if(r?.value===void 0||!Ht(e[t]??""))return;let o=t;for(;o<e.length&&Ht(e[o]??"");)o+=1;let i=[Zt(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 Ht(e){return!e.includes("=")&&/^(?:[-+*/]|-?\d+(?:\.\d+)?%?|[$@][\w.]*|[A-Za-z_]\w*(?:\.\w+)+|\(.*|.*\))$/.test(e)}function A(e){let t=e.indexOf("=");return t===-1?{key:e,value:void 0}:{key:e.slice(0,t),value:e.slice(t+1)}}var sr=new Set(["exit","delay","step","together","go"]);function at(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 o of e.words.slice(2)){let{key:i,value:s}=A(o),a=it.find(([c])=>c===i)?.[1];if(a===void 0){let c=sr.has(i)?` \u2014 ${i} goes on a node's line, under the header`:"";t(e.number,"invalid-motion",`motion ${n} has no "${i}"${c}`,n);continue}let u=I(s??"",a);"error"in u?t(e.number,"invalid-motion",`${i}: ${u.error}`,n):i==="duration"&&!en(u.value)?t(e.number,"invalid-motion",tn(i,s),n):u.value!==!1&&(r[i]=u.value)}return{page:n,number:e.number,head:r,lines:[],where:new Map,taken:new Map}}function ct(e,t,n){let r=t.words[0];if(t.indent!==1){n(t.number,"invalid-motion","A motion line sits one level under its page");return}if(r.includes("=")){n(t.number,"invalid-motion",`Expected a node id first, got ${r}`);return}if(r===e.page){n(t.number,"invalid-motion",`${r} is the page: its transition goes on the header (motion ${r} enter=fade)`,r);return}let o={id:r},i=!0;for(let a of t.words.slice(1)){let{key:u,value:c}=A(a),f=_e.find(([l])=>l===u)?.[1];if(f===void 0){n(t.number,"invalid-motion",`A motion line has no "${u}"`,r),i=!1;continue}let d=I(c??"",f);"error"in d?(n(t.number,"invalid-motion",`${u}: ${d.error}`,r),i=!1):(u==="duration"||u==="delay")&&!en(d.value)?(n(t.number,"invalid-motion",tn(u,c),r),i=!1):u==="go"&&Y(d.value)===void 0?(n(t.number,"invalid-motion",`go: expected #<page>, back, next, or an https: or mailto: link, got ${c??""}`,r),i=!1):d.value!==!1&&(o[u]=d.value)}if(o.enter!==void 0&&o.exit!==void 0&&(n(t.number,"invalid-motion",`${r} either enters or exits on one line \u2014 write a second line for the other`,r),i=!1),o.step===!0&&o.together===!0&&(n(t.number,"invalid-motion",`${r} waits for a step or starts together with the line above, not both`,r),i=!1),!i)return;let s=ur(o);if(!Oe(s)){n(t.number,"invalid-motion",`${r} says nothing: give it enter=, exit= or go=`,r);return}for(let a of["enter","exit","go"]){if(s[a]===void 0)continue;let u=e.taken.get(`${r} ${a}`);if(u!==void 0){let c=a==="go"?"has a go=":a==="enter"?"enters":"exits";n(t.number,"invalid-motion",`${r} already ${c} on line ${u}`,r);return}}for(let a of["enter","exit","go"])s[a]!==void 0&&e.taken.set(`${r} ${a}`,t.number);e.where.has(r)||e.where.set(r,t.number),e.lines.push(s)}function ft(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}:{},lines:e.lines};return ae(t)?void 0:t}function ur(e){let t={id:e.id};for(let[n]of _e)e[n]!==void 0&&(t[n]=e[n]);return t}function en(e){return typeof e=="number"&&e>=0&&e<=ue}function tn(e,t){return`${e}: expected 0 to ${ue} milliseconds, got ${t??""}`}function dt(e){return(t,n,r,o)=>{e.push({severity:"error",code:n,message:`Line ${t}: ${r}`,...o===void 0?{}:{nodeId:o}})}}function lt(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===J)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:Qt(i)})}return t}function pt(e){let t=[],n=[],r=o=>{for(;t.length>0&&t[t.length-1].indent>=o;)fr(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=lr(o,e);return f!==void 0&&c.runs.push(f),!0}if(!Re(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 a=cr(i,s,o.words.slice(2),o,e),u=t[t.length-1];return u?u.children.push(a.record):n.push(a.record),t.push(a),!0},finish(){return r(0),n}}}function cr(e,t,n,r,o){let i={type:e,id:t},s=[];for(let a=0;a<n.length;a+=1){let{key:u,value:c}=A(n[a]),f=st(e,u);if(f===void 0){let l=ut(n,a,n[a-1]);l?(o(r.number,"invalid-value",l.message,t),a=l.end-1):o(r.number,"invalid-value",`${e} has no property "${u}"`,t);continue}let d=I(c??"",f);"error"in d?o(r.number,"invalid-value",`${u}: ${d.error}`,t):i[u]=d.value}return we(e)&&(i.children=s),e==="text"&&(i.content=""),{indent:r.indent,type:e,record:i,children:s,runs:[]}}function fr(e){e.type==="text"&&(e.record.content=dr(e.runs))}function dr(e){if(e.length===0)return"";let t=e[0];return e.length===1&&typeof t=="string"?t:[...e]}function lr(e,t){let n=K(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}=A(o),a=Pe.find(([c])=>c===i);if(!a){t(e.number,"invalid-run",`A run has no mark "${i}"`);continue}let u=I(s??"",a[1]);"error"in u?t(e.number,"invalid-run",`${i}: ${u.error}`):r[i]=u.value}return r}function pr(e){let t=[],n=dt(t),r=X,o,i=!1,s={},a={},u={},c=pt(n),f,d={},l=new Map,h,$=!1,p=()=>{if(!h)return;let m=h;h=void 0;let k=l.get(m.page);if(k!==void 0){n(m.number,"invalid-motion",`motion ${m.page} is written twice \u2014 put its lines in the block on line ${k}`,m.page);return}l.set(m.page,m.number);for(let[b,S]of m.where)l.set(`${m.page} ${b}`,S);let x=ft(m);x&&(d[m.page]=x)};for(let m of lt(e)){let k=m.words[0];if(h&&m.indent>0){ct(h,m,n);continue}if(!($&&m.indent>0)){if($=!1,p(),k==="motion"&&m.indent===0){f=void 0,h=at(m,n),$=h===void 0;continue}if(k==="version"){i=!0,yr(m,t);continue}if(k==="kind"&&m.indent===0){r=mr(m,t);continue}if(k==="title"&&m.indent===0){o=rn(m,n);continue}if(k.startsWith("$")){f=void 0,gr(m,s,n);continue}if(k==="asset"&&m.indent===0){f=void 0,xr(m,u,n);continue}if(k==="font"&&m.indent===0){f=wr(m,a,n);continue}if((k==="fallback"||k==="face")&&f){kr(k,m,f,n);continue}f=void 0,!c.push(m)&&n(m.number,"unknown-node-type",`Unknown statement "${k}"`)}}p();let w=hr(c.finish(),t),v=Object.keys(d).length===0?{}:{motion:d},g=(m,k)=>l.get(k===void 0?m:`${m} ${k}`);if(!w){i||t.push({severity:"error",code:"invalid-document",message:"No nodes found"});let m=se({id:F,children:[]}),k=be({kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:a,assets:u,...v,root:m});return t.push(...ce(k,g)),{document:k,problems:t}}let N={version:4,kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:a,assets:u,...v,root:w};return t.push(...ce(N,g)),{document:N,problems:t}}function hr(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:F,children:[...e]}}}function yr(e,t){ve.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 mr(e,t){let n=e.words[1];return n!==void 0&&ie.includes(n)?n:(t.push({severity:"error",code:"unknown-kind",message:`Line ${e.number}: unknown kind "${n??"nothing"}" \u2014 this build reads ${ie.join(", ")}`}),X)}function rn(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('"')?K(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 gr(e,t,n){let{name:r,value:o}=ht(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=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]=on(i.value,o)}function on(e,t){let n=Number(e);return t.startsWith('"')||!Number.isFinite(n)||e.trim()===""?e:n}function ht(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}=A(t);return o!==void 0?{name:n(r),value:o}:{name:n(t)}}function xr(e,t,n){let r=e.words.slice(1),o=r[0],i=r[1]==="=",s=o===void 0?void 0:A(o),a=s?.key,u=i?r[2]:s?.value,c=r.slice(i?3:1);if(a===void 0||a===""||u===void 0){n(e.number,"invalid-asset","Expected asset <name> = <type> hash=\u2026 bytes=\u2026");return}let f={};for(let h of c){let{key:$,value:p}=A(h);if(p===void 0){n(e.number,"invalid-asset",`Asset "${a}" has a stray word "${h}"`);continue}f[$]=$r(p)}let d=f.hash,l=Number(f.bytes);if(d===void 0||!Number.isFinite(l)){n(e.number,"invalid-asset",`Asset "${a}" needs a hash and a bytes count`);return}t[a]={type:u,hash:d,bytes:l,...f.credit===void 0?{}:{credit:f.credit},...f.source===void 0?{}:{source:f.source},...f.license===void 0?{}:{license:f.license}}}function $r(e){return e.startsWith('"')?K(e)??e:e}function wr(e,t,n){let{name:r,value:o}=ht(e.words.slice(1));if(r===void 0||o===void 0){n(e.number,"invalid-font","Expected font <name> = <family>");return}let i=I(o,"string"),s={family:"error"in i?o:i.value};return t[r]=s,{family:s,faces:[]}}function kr(e,t,n,r){if(e==="fallback"){let a=I(t.words.slice(1).join(" "),"string");"error"in a?r(t.number,"invalid-font",`fallback: ${a.error}`):n.family.fallback=a.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=I(o,"string"),s={src:"error"in i?o:i.value};for(let a of t.words.slice(2)){let{key:u,value:c}=A(a);if(u!=="weight"&&u!=="style"){r(t.number,"invalid-font-face",`A face has no property "${u}"`);continue}let f=I(c??"",u==="weight"?"number":"fontStyle");"error"in f?r(t.number,"invalid-font-face",`${u}: ${f.error}`):s[u]=f.value}n.faces.push(s),n.family.faces=n.faces}function Ve(e){return/^\s*(linear|radial|conic|repeating-[a-z]+)-gradient\s*\(/i.test(e)}function yt(e){let t=e.trim(),n=/^([a-z-]+)-gradient\s*\(([\s\S]*)\)$/i.exec(t);if(!n)return Ve(t)?{error:'A gradient needs its closing ")"'}:{kind:"solid",colour:t};let r=n[1].toLowerCase(),o=Or(n[2]).map(i=>i.trim());if(o.some(i=>i===""))return{error:"A gradient has an empty argument"};if(r==="linear"){let i=Tr(o[0]),s=un(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=Ir(o[0]);if(i&&"error"in i)return i;let s=un(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 mt(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],a=t[i];for(let u=r;u<i;u+=1)t[u]=s+(a-s)*(u-o)/(i-o);r=i}return e.map((r,o)=>({colour:r.colour,at:t[o]}))}function Or(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 Mr={top:[0,-1],bottom:[0,1],left:[-1,0],right:[1,0]};function Tr(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=Mr[i.toLowerCase()];if(!s)return;r+=s[0],o+=s[1]}return(Math.atan2(r,-o)*180/Math.PI+360)%360}var Nr={left:0,top:0,center:.5,right:1,bottom:1};function Ir(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=sn(t[2]),o=t[3]===void 0?.5:sn(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 sn(e){let t=Nr[e.toLowerCase()];if(t!==void 0)return t;let n=/^(-?\d*\.?\d+)%$/.exec(e);return n?Number(n[1])/100:void 0}function un(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&&Ar(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 Ar(e){let t=0;for(let n of e)if(n==="("&&(t+=1),n===")"&&(t-=1),t<0)return!1;return t===0}function gt(e){let t=e.trim();if(t===""||t==="none")return{shadows:[]};let n=[];for(let r of Pr(t)){let o=_r(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[a=0,u=0,c=0,f=0]=i;if(c<0)return{error:"A shadow cannot have a negative blur"};n.push({x:a,y:u,blur:c,spread:f,colour:s[0]})}return{shadows:n}}function Pr(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 _r(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 De(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function an(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,a=e.y-t.y;return{x:t.x+s*o-a*i,y:t.y+s*i+a*o}}function xt(e,t,n=De(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(u=>an(u,n,t)),o=r.map(u=>u.x),i=r.map(u=>u.y),s=Math.min(...o),a=Math.min(...i);return{x:s,y:a,w:Math.max(...o)-s,h:Math.max(...i)-a}}var fn="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",dn=16,ln=400,pn=1.2,Fe="#0F172A";function kt(){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 $t(e,t){if(e===void 0)return fn;let n=t[e];return n?n.fallback?`${cn(n.family)}, ${n.fallback}`:cn(n.family):e}function cn(e){return/^[A-Za-z][A-Za-z0-9 -]*$/.test(e)?e:JSON.stringify(e)}function wt(e,t,n,r){let o={family:$t(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 a of i){if(typeof a=="string"){a.length>0&&s.push({text:a,style:o});continue}let u=a;u.text.length!==0&&s.push({text:u.text,style:{family:u.font===void 0?o.family:$t(u.font,n),size:u.size??o.size,weight:u.weight??o.weight,italic:u.italic??o.italic,underline:u.underline??!1,strike:u.strike??!1,fill:u.fill===void 0?o.fill:r(u.fill),letterSpacing:u.letterSpacing??o.letterSpacing,...u.link!==void 0&&D(u.link)?{link:u.link}:{}}})}return s}function Rr(e,t){let n=[];for(let r of e)for(let o of r.text.split(/(\n)/))if(o!==""){if(o===`
6
+ `){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 Lr(e,t,n){let r=[...e.text],o=[],i="";for(let s of r){let a=i+s;if(i!==""&&n.advance(a,e.style)>t){o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:!1}),i=s;continue}i=a}return i!==""&&o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:e.hardBreak}),o.length>0?o:[e]}function hn(e,t){let{width:n,measure:r}=t,o=Rr(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?[Vr(c,t.lineHeight)]:[],width:0,height:f}}let i=[],s=[],a=0,u=()=>{i.push(s),s=[],a=0};for(let c of o){let f=s.length===0&&c.w>n&&n>0?Lr(c,n,r):[c];for(let d of f){let l=d.text.trimEnd(),h=l===d.text?d.w:r.advance(l,d.style);s.length>0&&a+h>n&&u(),s.push(d),a+=d.w,d.hardBreak&&u()}}return s.length>0&&i.push(s),Dr(i,t)}function Vr(e,t){let n=t*e.size;return{y:0,h:n,baseline:n*.8,w:0,spans:[],style:e}}function Dr(e,t){let n=[],r=0,o=0;return e.forEach((i,s)=>{let a=i.map(b=>b.style.size),u=Math.max(...a,0),c=t.lineHeight*u,f=i.map(b=>t.measure.metrics(b.style)),d=Math.max(...f.map(b=>b.ascent),0),l=Math.max(...f.map(b=>b.descent),0),h=r+(c-(d+l))/2+d,$=Fr(i,t.measure),p=$.reduce((b,S)=>b+S.w,0);o=Math.max(o,p);let w=s===e.length-1||(i[i.length-1]?.hardBreak??!1),v=t.align==="justify"&&!w&&$.length>1,g=Math.max(0,t.width-p),N=t.align==="center"?g/2:t.align==="right"?g:0,m=v?g/($.length-1):0,k=[],x=N;$.forEach((b,S)=>{k.push({text:b.text,style:b.style,x,w:b.w}),x+=b.w+(S<$.length-1?m:0)}),n.push({y:r,h:c,baseline:h,w:p,spans:jr(k,v)}),r+=c}),{lines:n,width:o,height:r}}function Fr(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 jr(e,t){if(t)return[...e];let n=[];for(let r of e){let o=n[n.length-1];if(o&&yn(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 yn(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 vt(e,t,n,r,o,i){let s={size:t.size??dn,weight:t.weight??ln,lineHeight:t.lineHeight??pn,letterSpacing:t.letterSpacing??0,italic:e.italic??!1,font:typeof e.font=="string"?e.font:void 0,fill:typeof e.fill=="string"?e.fill:Fe},a=wt(e.content,s,r,o),u=wt(" ",s,r,o).map(c=>({...c,text:""}));return hn(a.length>0?a:u,{width:n,align:e.align??"left",lineHeight:s.lineHeight,measure:i})}function bt(e,t,n){let r=t-n;return e.valign==="middle"?r/2:e.valign==="bottom"?r:0}var mn=["x","y","w","h","left","right","top","bottom","cx","cy"];function de(e){return mn.includes(e)}var gn=["parent","prev","next","self","root"];function Et(e){return gn.includes(e)}var M=class extends Error{position;constructor(t,n){super(t),this.position=n,this.name="ExprSyntaxError"}},xn=/[A-Za-z_]/,St=/[A-Za-z0-9_]/;function Ot(e){let t=[],n=0,r=()=>{if(!xn.test(e[n]??""))throw new M(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&St.test(e[n]??"");)n++;return e.slice(s,n)},o=()=>{if(!St.test(e[n]??""))throw new M(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&St.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 a=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 u=e.slice(a,n),c=Number(u);if(!Number.isFinite(c))throw new M(`Bad number "${u}"`,a);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(xn.test(s)){t.push({type:"word",path:i()});continue}if("+-*/()".includes(s)){n++,t.push({type:"op",value:s});continue}throw new M(`Unexpected character "${s}" at position ${n}`,n)}return t.push({type:"eof"}),t}var Cr={"+":1,"-":1,"*":2,"/":2};function je(e){try{let t=Ot(e),n=new Mt(t),r=n.parseBinary(0);return n.expectEof(),{ok:!0,ast:r}}catch(t){if(t instanceof M)return{ok:!1,message:t.message};throw t}}var Mt=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 M("Unexpected trailing input",this.index)}parseBinary(t){let n=this.parseUnary();for(;;){let r=this.peek();if(r.type!=="op"||!Ur(r.value))break;let o=Cr[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 M(`@${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||!Et(n))throw new M(`Unknown name "${t.path.join(".")}". Use $token for a token or @id.edge for a node.`,this.index);if(r===void 0||!de(r)||o.length>0)throw new M(`${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 M("Missing closing parenthesis",this.index);return n}throw new M(`Unexpected "${t.value}"`,this.index)}case"eof":throw new M("Unexpected end of expression",this.index)}}};function Ur(e){return e==="+"||e==="-"||e==="*"||e==="/"}function R(e,t){return`${e} ${t}`}function Tt(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 Nt(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 It(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 At(e,t,n){let r=d=>{let l=[];for(let h=n.parentOf.get(d);h!==void 0;h=n.parentOf.get(h))l.push(h);return l},o=r(e),i=r(t),s=new Set(i),a=o.find(d=>s.has(d)),u=d=>a===void 0?d:d.slice(0,d.indexOf(a)),c=new Map([[e,1]]),f=(d,l)=>{let h=(c.get(d)??0)+l;h===0?c.delete(d):c.set(d,h)};for(let d of u(o))f(d,1);for(let d of u(i))f(d,-1);return c}function Pt(e){switch(e){case"right":case"bottom":return 1;case"cx":case"cy":return .5;default:return 0}}function Ce(e){if(e==="x"||e==="w")return"w";if(e==="y"||e==="h")return"h"}function _t(e){let t=new Map,n=new Map,r=new Map,o=new Map,i=[];T(e.root,(f,d)=>{t.has(f.id)||t.set(f.id,f),i.push(f),d&&n.set(f.id,d.id),P(f)&&f.children.forEach((l,h)=>{let $=f.children[h-1],p=f.children[h+1];$&&r.set(l.id,$.id),p&&o.set(l.id,p.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||!oe(l))break;d=n.get(d)}d!==void 0&&s.set(f.id,d)}let a=new Map,u=new Map,c=f=>{if(P(f)){if(!oe(f)){let d=$n(f);d.forEach((l,h)=>{let $=d[h-1],p=d[h+1];$&&a.set(l.id,$.id),p&&u.set(l.id,p.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:a,layoutNextOf:u,order:i}}function $n(e){let t=[];for(let n of e.children)P(n)&&oe(n)?t.push(...$n(n)):t.push(n);return t}function Ue(e,t,n){if(e.kind==="relRef"){let i=Wr(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 de(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 Wr(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 Rt(e){let t=[],n=_t(e),r=Br(n),o=new Set;zr(r,t),Gr(r,e,n,o,t);let i=Jr(r);Xr(r,i,t);let s=Yr(r,i,e,n,o,t);return{nodes:Kr(e.root,s,r,t),problems:t}}function Br(e){let t=new Map;for(let n of e.order){let r=n;for(let o of ke(n)){let i=r[o];i!==void 0&&t.set(R(n.id,o),{nodeId:n.id,prop:o,value:i,deps:[]})}}return t}function zr(e,t){for(let n of e.values()){if(!_(n.value))continue;let r=je(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 Gr(e,t,n,r,o){for(let i of e.values()){if(!i.ast)continue;let s=new Set,a=u=>{switch(u.kind){case"number":return;case"token":{let c=t.tokens[u.name];typeof c!="number"&&o.push({severity:"error",code:c===void 0?"unknown-token":"token-not-a-number",message:c===void 0?`Unknown token $${u.name}`:`Token $${u.name} is not a number`,nodeId:i.nodeId,prop:i.prop});return}case"percent":{let c=Ce(i.prop);if(!c)return;let f=n.layoutParentOf.get(i.nodeId),d=f===void 0?void 0:R(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=Ue(u,i.nodeId,n);if(!c.ok){r.add(u),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=It(c.edge);if(!d){for(let l of Tt(c.edge))f(R(c.nodeId,l));return}for(let l of At(c.nodeId,i.nodeId,n).keys())f(R(l,d));Pt(c.edge)!==0&&f(R(c.nodeId,d==="x"?"w":"h"));return}case"unary":a(u.operand);return;case"binary":a(u.left),a(u.right);return}};a(i.ast),i.deps=[...s]}}function Jr(e){let t=new Map,n=new Map;for(let[i,s]of e){t.set(i,s.deps.length);for(let a of s.deps){let u=n.get(a);u?u.push(i):n.set(a,[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 a of n.get(s)??[]){let u=(t.get(a)??0)-1;t.set(a,u),u===0&&r.push(a)}}return o}function Xr(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 Yr(e,t,n,r,o,i){let s=new Map,a=(u,c)=>s.get(R(u,c))??0;for(let u of t){let c=e.get(u);if(c){if(!_(c.value)){s.set(u,c.value);continue}if(!c.ast){s.set(u,0);continue}s.set(u,wn(c.ast,c,n,r,o,i,a))}}return s}function wn(e,t,n,r,o,i,s){let a=u=>wn(u,t,n,r,o,i,s);switch(e.kind){case"number":return e.value;case"token":{let u=n.tokens[e.name];return typeof u=="number"?u:0}case"percent":{let u=Ce(t.prop);if(!u)return e.value/100;let c=r.layoutParentOf.get(t.nodeId);return c===void 0?0:e.value/100*s(c,u)}case"nodeRef":case"relRef":{if(o.has(e))return 0;let u=Ue(e,t.nodeId,r);if(!u.ok)return 0;let c=It(u.edge);if(!c)return Nt(u.edge,s(u.nodeId,"x"),s(u.nodeId,"y"),s(u.nodeId,"w"),s(u.nodeId,"h"));let f=Pt(u.edge)*s(u.nodeId,c==="x"?"w":"h");for(let[d,l]of At(u.nodeId,t.nodeId,r))f+=l*s(d,c);return f}case"unary":{let u=a(e.operand);return e.op==="-"?-u:u}case"binary":{let u=a(e.left),c=a(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=Hr(e.op,u,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 Hr(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n}}function Kr(e,t,n,r){let o=new Map,i=(a,u)=>t.get(R(a,u))??0,s=(a,u,c)=>{let f=i(a.id,"x"),d=i(a.id,"y"),l=i(a.id,"w"),h=i(a.id,"h"),$={};for(let v of ke(a)){let g=R(a.id,v);n.has(g)&&($[v]=t.get(g)??0)}(l<0||h<0)&&r.push({severity:"warning",code:"negative-size",message:`${a.id} resolved to a negative size`,nodeId:a.id});let p=u+f,w=c+d;if(o.set(a.id,{id:a.id,type:a.type,x:f,y:d,w:l,h,left:f,top:d,right:f+l,bottom:d+h,cx:f+l/2,cy:d+h/2,absX:p,absY:w,values:$}),P(a))for(let v of a.children)s(v,p,w)};return s(e,0,0),o}function Lt(e){return e.lines.filter(t=>t.spans.length>0)}function Vt(e){switch(e.kind){case"text":{let t=Lt(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=nt(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 ze(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 a=s.spread+s.blur;n=Math.min(n,e.x+s.x-a),r=Math.min(r,e.y+s.y-a),o=Math.max(o,e.x+e.w+s.x+a),i=Math.max(i,e.y+e.h+s.y+a)}return{x:n,y:r,w:o-n,h:i-r}}var bn="vd-paint-";var Be="#CBD5E1",En="#FFFFFF";function Sn(e,t,n={}){let r=[...t.problems],o=[],i=[],s=n.measure??kt(),a=oo(e.tokens,r),u=a.paint,c=new Map;T(e.root,(p,w)=>{if("hidden"in p&&p.hidden===!0)return!1;let v=w?c.get(w.id):void 0,g=t.nodes.get(p.id);if(!g){c.set(p.id,v);return}if(p.type==="frame"){p.skip===!0&&w!==e.root&&r.push({severity:"warning",code:"skip-not-a-page",message:`${p.id}: skip only applies to a page, a frame at the top level`,nodeId:p.id,prop:"skip"});let m={x:g.absX,y:g.absY,w:Math.max(0,g.w),h:Math.max(0,g.h)};c.set(p.id,p.clip===!0?p.id:v),p.clip===!0&&i.push({id:p.id,...m,parent:v}),o.push({kind:"frame",id:p.id,...m,background:u(p.background,p.id,"background",m),clip:v,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:0});return}if(c.set(p.id,v),p.type==="text"){o.push(Zr(p,g,e,s,r,v,u));return}if(p.type==="image"){o.push({kind:"image",id:p.id,x:g.absX,y:g.absY,w:Math.max(0,g.w),h:Math.max(0,g.h),href:uo(p,e,n.resolveAsset,r),fit:p.fit??"fill",radius:Math.max(0,g.values.radius??0),opacity:pe(g.values.opacity??1),clip:v,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0});return}if(p.type==="ellipse"){let m=vn(g);o.push({kind:"ellipse",id:p.id,...m,fill:u(p.fill,p.id,"fill",m)??Be,stroke:u(p.stroke,p.id,"stroke",m),strokeWidth:g.values.strokeWidth??0,opacity:pe(g.values.opacity??1),clip:v,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0});return}if(p.type==="vector"){o.push(ro(p,g,r,v,u,q(p.shadow,p.id,e.tokens,r)));return}if(p.type!=="rect")return;let N=vn(g);o.push({kind:"rect",id:p.id,...N,fill:u(p.fill,p.id,"fill",N)??Be,stroke:u(p.stroke,p.id,"stroke",N),strokeWidth:g.values.strokeWidth??0,radius:Math.max(0,g.values.radius??0),opacity:pe(g.values.opacity??1),clip:v,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:g.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)}:qr(o,i),h={x:l.x,y:l.y,w:l.width,h:l.height},$=u(e.root.background,e.root.id,"background",h);return{...l,background:d?$??En:$,items:o,clips:i,gradients:a.gradients,problems:r}}function qr(e,t){let n=new Map;for(let a of t){let u=a.parent===void 0?void 0:n.get(a.parent);n.set(a.id,u?kn(a,u):a)}let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let a of e){let u=a.kind==="text"&&Lt(a).length>0?Math.max(a.h,a.height):a.h,c=a.clip===void 0?void 0:n.get(a.clip),f=xt(ze({x:a.x,y:a.y,w:a.w,h:u},a.shadows),a.rotation,De(a)),d=c?kn(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 kn(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 Dt(e,t={}){return Sn(e,Rt(e),t)}function Zr(e,t,n,r,o,i,s){let a=Math.max(0,t.w),u=Math.max(0,t.h),c={x:t.absX,y:t.absY,w:a,h:u},f=vt(e,t.values,a,n.fonts,h=>s(h,e.id,"fill",c)??Fe,r);!f.lines.every(h=>h.spans.length===0)&&f.height>u+.5&&o.push({severity:"warning",code:"text-overflow",message:`${e.id} needs ${Math.ceil(f.height)}px but its height is ${Math.round(u)}px`,nodeId:e.id,prop:"h"}),Qr(e,n,o);let l=t.absY+bt(e,u,f.height);return{kind:"text",id:e.id,x:t.absX,y:t.absY,w:a,h:u,clip:i,blend:e.blend??"normal",shadows:q(e.shadow,e.id,n.tokens,o),rotation:t.values.rotation??0,opacity:pe(t.values.opacity??1),height:f.height,lines:f.lines.map(h=>({y:l+h.y,h:h.h,baseline:l+h.baseline,w:h.w,spans:h.spans.map($=>({text:$.text,x:t.absX+$.x,y:l+h.baseline,w:$.w,style:$.style})),...h.style?{style:h.style}:{}}))}}function Qr(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=D(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"&&!eo(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 eo(e,t){let n=!1;return T(e.root,r=>{if(n)return!1;r.id===t&&r.type==="frame"&&(n=!0)}),n}var le=new Map,to=512;function no(e){let t=le.get(e);if(t)return t;let n=qe(e);return le.size>=to&&le.delete(le.keys().next().value),le.set(e,n),n}function ro(e,t,n,r,o,i){let s=Math.max(0,t.w),a=Math.max(0,t.h),u={x:t.absX,y:t.absY,w:s,h:a},{contours:c,error:f}=no(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&&Ie(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=tt(c,ot(rt(e.view,s,a),u));return{kind:"vector",id:e.id,...u,d:Ze(d),contours:d,fill:o(e.fill,e.id,"fill",u)??Be,stroke:o(e.stroke,e.id,"stroke",u),strokeWidth:t.values.strokeWidth??0,opacity:pe(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 On(e,t,n,r,o){if(e===void 0)return;if(_(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 vn(e){return{x:e.absX,y:e.absY,w:Math.max(0,e.w),h:Math.max(0,e.h)}}function oo(e,t){let n=[],r=new Map;return{paint:(i,s,a,u)=>{let c=On(i,e,s,a,t);if(c===void 0)return;let f=yt(c);if("error"in f){t.push({severity:"error",code:"invalid-paint",message:`${s}: ${f.error}`,nodeId:s,prop:a});return}if(f.kind==="solid")return c;let d=`${s}\0${a}\0${c}`,l=r.get(d);if(l!==void 0)return`url(#${l})`;let h=[...r.keys()].filter(w=>w.startsWith(`${s}\0${a}\0`)).length,$=`${bn}${s}-${a}${h===0?"":`-${h+1}`}`;r.set(d,$);let p=mt(f.stops).map(w=>({offset:w.at,colour:Mn(w.colour,e,s,a,t)}));return n.push(so(f,$,u,io(p))),`url(#${$})`},gradients:n}}function q(e,t,n,r){let o=On(e,n,t,"shadow",r);if(o===void 0)return[];let i=gt(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:Mn(s.colour,n,t,"shadow",r)}))}function io(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 Mn(e,t,n,r,o){let i=t[e];return i===void 0?e:typeof i=="string"&&!Ve(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 so(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,h=n.x+n.w/2,$=n.y+n.h/2;return{id:t,kind:"linear",x1:We(h-f*l),y1:We($-d*l),x2:We(h+f*l),y2:We($+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 a=s.x/s.y,u=Math.hypot(s.x/a,s.y);return{id:t,kind:"radial",cx:o,cy:i,rx:u*a,ry:u,stops:r}}function We(e){return Math.round(e*1e6)/1e6}function pe(e){return Math.min(Math.max(e,0),1)}function uo(e,t,n,r){let o=_(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 Ge="vd-clip-";function Ft(e,t={}){let n=t.indent??" ",r={ids:t.ids??!0,prefix:t.idPrefix??""},o=y(e.width),i=y(e.height),s=`${y(e.x)} ${y(e.y)} ${o} ${i}`,a=[`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${i}" viewBox="${s}">`],u=e.items.filter(c=>c.shadows.length>0);if(e.clips.length>0||e.gradients.length>0||u.length>0){a.push(`${n}<defs>`);for(let c of e.clips)a.push(n+n+Nn(c,r.prefix));for(let c of e.gradients)a.push(n+n+In(c,r.prefix));for(let c of u)a.push(n+n+An(c,t.shadowsOnly,r.prefix));a.push(`${n}</defs>`)}e.background!==void 0&&a.push(`${n}<rect x="${y(e.x)}" y="${y(e.y)}" width="${o}" height="${i}" fill="${E(C(e.background,r))}"/>`);for(let c of e.items){let f=ho(c,r);f!==""&&a.push(n+f)}return a.push("</svg>"),`${a.join(`
7
+ `)}
8
+ `}function ao(e){return Nn(e,"")}function Nn(e,t){let n=e.parent===void 0?"":` clip-path="url(#${E(t+Ge+e.parent)})"`;return`<clipPath id="${E(t+Ge+e.id)}"${n}><rect x="${y(e.x)}" y="${y(e.y)}" width="${y(e.w)}" height="${y(e.h)}"/></clipPath>`}function co(e){return In(e,"")}function In(e,t){let n=e.stops.map(o=>`<stop offset="${y(o.offset)}" stop-color="${E(o.colour)}"${o.opacity===void 0?"":` stop-opacity="${y(o.opacity)}"`}/>`).join(""),r=E(t+e.id);return e.kind==="linear"?`<linearGradient id="${r}" gradientUnits="userSpaceOnUse" x1="${y(e.x1)}" y1="${y(e.y1)}" x2="${y(e.x2)}" y2="${y(e.y2)}">${n}</linearGradient>`:`<radialGradient id="${r}" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="1" gradientTransform="matrix(${y(e.rx)} 0 0 ${y(e.ry)} ${y(e.cx)} ${y(e.cy)})">${n}</radialGradient>`}var fo={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"},lo="#94A3B8";function j(e,t){let n=e.clip===void 0?[]:[`clip-path="url(#${E(t+Ge+e.clip)})"`];return e.rotation!==0&&n.push(`transform="${Pn(e)}"`),e.shadows.length>0&&n.push(`filter="url(#${E(t+jt+e.id)})"`),e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`),n}var jt="vd-shadow-";function po(e,t=!1){return An(e,t,"")}function An(e,t,n){let r=ze(Vt(e),e.shadows),o=2,i=[];e.shadows.forEach((a,u)=>{let c=`s${u}`,f="SourceAlpha";a.spread!==0&&(i.push(`<feMorphology in="${f}" operator="${a.spread>0?"dilate":"erode"}" radius="${y(Math.abs(a.spread))}" result="${c}m"/>`),f=`${c}m`),a.blur>0&&(i.push(`<feGaussianBlur in="${f}" stdDeviation="${y(a.blur/2)}" result="${c}b"/>`),f=`${c}b`),i.push(`<feOffset in="${f}" dx="${y(a.x)}" dy="${y(a.y)}" result="${c}o"/>`,`<feFlood flood-color="${E(a.colour)}" result="${c}c"/>`,`<feComposite in="${c}c" in2="${c}o" operator="in" result="${c}"/>`)});let s=e.shadows.map((a,u)=>`<feMergeNode in="s${e.shadows.length-1-u}"/>`).join("");return`<filter id="${E(n+jt+e.id)}" filterUnits="userSpaceOnUse" x="${y(r.x-o)}" y="${y(r.y-o)}" width="${y(r.w+o*2)}" height="${y(r.h+o*2)}" color-interpolation-filters="sRGB">`+i.join("")+`<feMerge>${s}${t?"":'<feMergeNode in="SourceGraphic"/>'}</feMerge></filter>`}function Pn(e){return`rotate(${y(e.rotation)} ${y(e.x+e.w/2)} ${y(e.y+e.h/2)})`}function _n(e){return e.rotation!==0&&e.clip!==void 0}function ho(e,t){if(_n(e)){let n=[`clip-path="url(#${E(t.prefix+Ge+e.clip)})"`];e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`);let r=Tn({...e,clip:void 0,blend:"normal"},t);return r===""?"":`<g ${n.join(" ")}>${r}</g>`}return Tn(e,t)}function Tn(e,t){switch(e.kind){case"ellipse":return xo(e,t);case"frame":return yo(e,t);case"image":return mo(e,t);case"rect":return go(e,t);case"text":return wo(e,t);case"vector":return $o(e,t)}}function C(e,t){return t.prefix!==""&&e.startsWith("url(#")?`url(#${t.prefix}${e.slice(5)}`:e}function yo(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`,`fill="${e.background===void 0?"none":E(C(e.background,t))}"`,...j(e,t.prefix)),`<rect ${n.join(" ")}/>`}function mo(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`),e.href===void 0?(e.radius>0&&n.push(`rx="${y(e.radius)}"`),n.push('fill="none"',`stroke="${E(lo)}"`,'stroke-width="1"','stroke-dasharray="4 4"',...j(e,t.prefix)),`<rect ${n.join(" ")}/>`):(n.push(`href="${E(e.href)}"`,`preserveAspectRatio="${fo[e.fit]}"`),e.opacity<1&&n.push(`opacity="${y(e.opacity)}"`),n.push(...j(e,t.prefix)),`<image ${n.join(" ")}/>`)}function go(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`),e.radius>0&&n.push(`rx="${y(e.radius)}"`),n.push(`fill="${E(C(e.fill,t))}"`),e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${E(C(e.stroke,t))}"`,`stroke-width="${y(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${y(e.opacity)}"`),n.push(...j(e,t.prefix)),`<rect ${n.join(" ")}/>`}function Rn(e,t){let n=[`fill="${E(C(e.fill,t))}"`];return e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${E(C(e.stroke,t))}"`,`stroke-width="${y(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${y(e.opacity)}"`),n}function xo(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`cx="${y(e.x+e.w/2)}"`,`cy="${y(e.y+e.h/2)}"`,`rx="${y(e.w/2)}"`,`ry="${y(e.h/2)}"`,...Rn(e,t),...j(e,t.prefix)),`<ellipse ${n.join(" ")}/>`}function $o(e,t){if(e.d==="")return"";let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`d="${E(e.d)}"`,...Rn(e,t)),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(...j(e,t.prefix)),`<path ${n.join(" ")}/>`}function wo(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="${y(e.opacity)}"`),n.push(...j(e,t.prefix));let r=[];for(let o of e.lines)for(let i of o.spans)i.text!==""&&r.push(ko(i,t));return`<text ${n.join(" ")}>${r.join("")}</text>`}function ko(e,t){let r=`<tspan ${[`x="${y(e.x)}"`,`y="${y(e.y)}"`,...vo(e.style,t)].join(" ")}>${bo(e.text)}</tspan>`;return e.style.link===void 0?r:`<a href="${E(e.style.link)}">${r}</a>`}function vo(e,t){let n=[`font-family="${E(e.family)}"`,`font-size="${y(e.size)}"`,`fill="${E(C(e.fill,t))}"`];e.weight!==400&&n.push(`font-weight="${y(e.weight)}"`),e.italic&&n.push('font-style="italic"'),e.letterSpacing!==0&&n.push(`letter-spacing="${y(e.letterSpacing)}"`);let r=[e.underline?"underline":"",e.strike?"line-through":""].filter(Boolean).join(" ");return r&&n.push(`text-decoration="${r}"`),n}function bo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function E(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Zu(e,t={}){let{resolveAsset:n,measure:r,...o}=t;return Ft(Dt(e,{...n?{resolveAsset:n}:{},...r?{measure:r}:{}}),o)}export{T as a,Ye as b,D as c,Cn as d,Y as e,He as f,Ke as g,Yn as h,Vn as i,Dn as j,Fn as k,pr as l,an as m,Rt as n,kt as o,Sn as p,Dt as q,Ft as r,ao as s,co as t,jt as u,po as v,Pn as w,_n as x,Zu as y};
@@ -1,2 +1,2 @@
1
- /*! @getv.design/embed v0.1.2. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
1
+ /*! @getv.design/embed v0.1.4. 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,2 @@
1
+ /*! @getv.design/embed v0.1.4. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ var _="0.1.4",e="https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.4/fonts/";export{_ as a,e as b};
@@ -1,2 +1,2 @@
1
- /*! @getv.design/embed v0.1.2. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
- import{a as m}from"./chunk-PCMXJXR4.js";import{i as c,l as a}from"./chunk-JWKZL5KP.js";var l=Symbol.for(`vdesign.embed.documents@${m}`),u=globalThis[l]??=new WeakMap,p=/^Line (\d+): /;function b(e){let t=p.exec(e.message);return{...t?{line:Number(t[1])}:{},code:e.code,message:e.message,severity:e.severity}}function i(e){if(typeof e!="string")return d(a("").document,new Map,[{code:"not-text",message:`parse() takes .vd text, not ${e===null?"null":typeof e}.`,severity:"error"}]);let{head:t,blocks:o}=c(e),n=a(t);return d(n.document,o,n.problems.map(b))}function d(e,t,o){let n=Object.freeze({});return u.set(n,{document:e,blocks:t,problems:o}),{document:n,problems:o}}function P(e,t,o){return d(e,t,[...o]).document}function s(e){let t=u.get(e);if(!t)throw new TypeError("Not a vDesign document: pass .vd text or what parse() returned.");return t}async function x(e){if(typeof e=="string")return s(i(e).document);if(e instanceof URL){let t=await fetch(e);if(!t.ok)throw new Error(`Could not fetch ${e.href}: ${t.status}`);return s(i(await t.text()).document)}return y(e)?s(i(await e.text()).document):s(e)}function y(e){let t=e;return typeof t.text=="function"&&typeof t.size=="number"}function g(e){return e.root.children.filter(t=>t.type==="frame"&&t.hidden!==!0)}function V(e,t){let o=g(e),n=typeof t=="number"?o[t]:o.find(r=>r.id===t);if(!n){let r=o.map(f=>f.id).join(", ")||"none";throw new RangeError(`No page ${JSON.stringify(t)} in this document; its pages: ${r}.`)}return n}function v(e,t,o){let n=e===void 0?t:String(e);if(n===void 0)return;let r;try{r=new URL(n,o??globalThis.location?.href)}catch{throw new TypeError(`fontBase must be a URL, or a path on this page; got ${n}.`)}return r.pathname.endsWith("/")||(r.pathname+="/"),r}function k(e,t){return{code:"fonts-unavailable",message:`Exact fonts could not be loaded: ${t??e.map(n=>`${n.file} (${n.reason})`).join(", ")}. Text is measured without them, so lines may break differently from the app's.`,severity:"warning"}}export{i as a,P as b,x as c,g as d,V as e,v as f,k as g};
1
+ /*! @getv.design/embed v0.1.4. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ import{a as m}from"./chunk-QFKGWML4.js";import{i as c,l as a}from"./chunk-5NSMF3ZC.js";var l=Symbol.for(`vdesign.embed.documents@${m}`),u=globalThis[l]??=new WeakMap,p=/^Line (\d+): /;function b(e){let t=p.exec(e.message);return{...t?{line:Number(t[1])}:{},code:e.code,message:e.message,severity:e.severity}}function i(e){if(typeof e!="string")return d(a("").document,new Map,[{code:"not-text",message:`parse() takes .vd text, not ${e===null?"null":typeof e}.`,severity:"error"}]);let{head:t,blocks:o}=c(e),n=a(t);return d(n.document,o,n.problems.map(b))}function d(e,t,o){let n=Object.freeze({});return u.set(n,{document:e,blocks:t,problems:o}),{document:n,problems:o}}function P(e,t,o){return d(e,t,[...o]).document}function s(e){let t=u.get(e);if(!t)throw new TypeError("Not a vDesign document: pass .vd text or what parse() returned.");return t}async function x(e){if(typeof e=="string")return s(i(e).document);if(e instanceof URL){let t=await fetch(e);if(!t.ok)throw new Error(`Could not fetch ${e.href}: ${t.status}`);return s(i(await t.text()).document)}return y(e)?s(i(await e.text()).document):s(e)}function y(e){let t=e;return typeof t.text=="function"&&typeof t.size=="number"}function g(e){return e.root.children.filter(t=>t.type==="frame"&&t.hidden!==!0)}function V(e,t){let o=g(e),n=typeof t=="number"?o[t]:o.find(r=>r.id===t);if(!n){let r=o.map(f=>f.id).join(", ")||"none";throw new RangeError(`No page ${JSON.stringify(t)} in this document; its pages: ${r}.`)}return n}function v(e,t,o){let n=e===void 0?t:String(e);if(n===void 0)return;let r;try{r=new URL(n,o??globalThis.location?.href)}catch{throw new TypeError(`fontBase must be a URL, or a path on this page; got ${n}.`)}return r.pathname.endsWith("/")||(r.pathname+="/"),r}function k(e,t){return{code:"fonts-unavailable",message:`Exact fonts could not be loaded: ${t??e.map(n=>`${n.file} (${n.reason})`).join(", ")}. Text is measured without them, so lines may break differently from the app's.`,severity:"warning"}}export{i as a,P as b,x as c,g as d,V as e,v as f,k as g};