@getv.design/embed 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ /*! @getv.design/embed v0.1.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
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.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ var _="0.1.0",e="https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.0/fonts/";export{_ as a,e as b};
@@ -0,0 +1,8 @@
1
+ /*! @getv.design/embed v0.1.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ function D(e){let n=e.trim();if(n.startsWith("#")){let r=n.slice(1);return r===""?void 0:{kind:"frame",id:r}}let t;try{t=new URL(n)}catch{return}if(!(t.protocol!=="https:"&&t.protocol!=="mailto:"))return{kind:"url",url:n}}var G="--- payload base64 ---",_t="sha256-";function Un(e){let n=Vt(e);return n===-1?{head:e,payload:""}:{head:e.slice(0,n),payload:e.slice(n+G.length)}}function Pt(e){let{head:n,payload:t}=Un(e);return{head:n,blocks:Wn(t)}}function Wn(e){let n=new Map;for(let t of e.split(`
3
+ `)){let r=t.indexOf(" ");if(r===-1)continue;let o=t.slice(0,r);o.startsWith(_t)&&n.set(o,t.slice(r+1).trim())}return n}function Rt(e,n){return`data:${e};base64,${n}`}function Lt(e){let n=Uint8Array.fromBase64;if(typeof n=="function")return n(e);let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o+=1)r[o]=t.charCodeAt(o);return r}function Vt(e){if(e.startsWith(G))return 0;let n=e.indexOf(`
4
+ ${G}`);return n===-1?-1:n+1}function Q(e){return{expr:e}}function P(e){return typeof e=="object"&&e!==null&&typeof e.expr=="string"}var ye=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=["left","center","right","justify"],ne=["top","middle","bottom"],te=["cover","contain","fill"],me=["nonzero","evenodd"],ge=["butt","round","square"],xe=["miter","round","bevel"],Bn=["canvas","frame","group"];function $e(e){return Bn.includes(e)}function _(e){return $e(e.type)}function re(e){return e.type==="group"}var zn={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 we(e){return zn[e.type]}function N(e,n,t){if(n(e,t)!==!1&&_(e))for(let r of e.children)N(r,n,e)}function Xe(e,n){let t;return N(e,r=>{if(t)return!1;r.id===n&&(t=r)}),t}var oe=["design"],J="design";var ke=[1,2,3,4],F="doc";function ie(e){return{type:"canvas",...e}}function ve(e={}){return{version:4,kind:e.kind??J,...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??ie({id:F,children:[]})}}var be=["cut","fade","push","slide"],Ee=["cut","fade","rise","drop","pop"],Dt=400,se=1e4;function X(e){let n=e.trim();return n==="back"?{kind:"back"}:n==="next"?{kind:"next"}:D(n)}function ae(e){return e===void 0||e.enter===void 0&&e.duration===void 0&&e.lines.length===0}function Se(e){return e.enter!==void 0||e.exit!==void 0||e.go!==void 0}function Oe(e){let n=e.motion;if(!n)return[];let t=e.root.children.map(o=>o.id).filter(o=>o in n),r=Object.keys(n).filter(o=>!t.includes(o)).sort();return[...t,...r]}function Ye(e){return new Set(e.root.children.filter(n=>n.type==="frame").map(n=>n.id))}function He(e){let n=new Map;for(let t of e.root.children)t.type==="frame"&&N(t,r=>{n.set(r.id,t.id)});return n}function Ft(e){let n=new Set;return N(e,t=>{n.add(t.id)}),n}function ue(e,n){let t=e.motion;if(!t)return[];let r=[],o=Ye(e),i=He(e),s=Ft(e.root),u=(a,c)=>{let f=n?.(a,c);return f===void 0?"":`Line ${f}: `};for(let a of Oe(e)){let c=t[a];if(c){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}for(let f of c.lines){let d=u(a,f.id);s.has(f.id)?i.get(f.id)!==a&&r.push({severity:"warning",code:"motion-wrong-page",message:`${d}motion ${a}: ${f.id} is not on ${a}, so Play skips it`,nodeId:f.id}):r.push({severity:"warning",code:"unknown-reference",message:`${d}motion ${a}: no node ${f.id}`,nodeId:f.id});let l=f.go===void 0?void 0:X(f.go);l?.kind==="frame"&&!jt(e,l.id)&&r.push({severity:"warning",code:"unknown-reference",message:`${d}motion ${a}: go=#${l.id} names no frame`,nodeId:f.id})}}}return r}function jt(e,n){let t=!1;return N(e.root,r=>{if(t)return!1;r.id===n&&(t=r.type==="frame")}),t}function h(e){if(!Number.isFinite(e))return"0";let n=Math.round(e*1e4)/1e4,t=Object.is(n,-0)?0:n;return Math.abs(t)>=1e21?t.toFixed(0):String(t)}var Ct={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Ke(e){let n=[],t,r=0,o=0,i=0,s=0,u,a,c=Wt(e),f=()=>(t||(t={anchors:[{x:r,y:o}],closed:!1},n.push(t)),t.anchors[t.anchors.length-1]),d=(p,$)=>{f(),t?.anchors.push({x:p,y:$}),r=p,o=$},l=(p,$,k,g)=>{f().out=p,t?.anchors.push({x:k,y:g,in:$}),r=k,o=g},y="",b=!0;for(;c.more();){let p=c.command();if(p!==void 0)y=p,b=!0;else if(y===""||y.toUpperCase()==="Z")return{contours:Me(n),error:`Expected a command at ${c.at()}`};let $=y.toUpperCase(),k=y!==$,g=Ct[$];if(g===void 0)return{contours:Me(n),error:`Unknown command ${y}`};if($==="Z"){t&&(t.closed=!0),t=void 0,r=i,o=s,u=void 0,a=void 0,y="";continue}let T=$==="A"?c.arc():c.numbers(g);if(T===void 0)return{contours:Me(n),error:`${y} expects ${g} numbers at ${c.at()}`};let m=k?r:0,w=k?o:0,x=v=>T[v];switch($){case"M":b&&(t={anchors:[{x:m+x(0),y:w+x(1)}],closed:!1},n.push(t),r=i=m+x(0),o=s=w+x(1),y=k?"l":"L"),u=a=void 0;break;case"L":d(m+x(0),w+x(1)),u=a=void 0;break;case"H":d(m+x(0),o),u=a=void 0;break;case"V":d(r,w+x(0)),u=a=void 0;break;case"C":{let v={x:m+x(2),y:w+x(3)};l({x:m+x(0),y:w+x(1)},v,m+x(4),w+x(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:m+x(0),y:w+x(1)};l(v,S,m+x(2),w+x(3)),u=S,a=void 0;break}case"Q":case"T":{let v=$==="Q"?{x:m+x(0),y:w+x(1)}:a?{x:2*r-a.x,y:2*o-a.y}:{x:r,y:o},S=$==="Q"?m+x(2):m+x(0),L=$==="Q"?w+x(3):w+x(1),C={x:r+2/3*(v.x-r),y:o+2/3*(v.y-o)},U={x:S+2/3*(v.x-S),y:L+2/3*(v.y-L)};l(C,U,S,L),a=v,u=void 0;break}case"A":{let v=m+x(5),S=w+x(6);for(let[L,C,U]of Bt(r,o,x(0),x(1),x(2),x(3)!==0,x(4)!==0,v,S))l(L,C,U.x,U.y);(r!==v||o!==S)&&d(v,S),u=a=void 0;break}}b=!1}return{contours:Me(n)}}function Me(e){return e.map(n=>{let t=[...n.anchors];if(n.closed&&t.length>1){let r=t[0],o=t[t.length-1];ce(r,o)&&(t.pop(),t[0]={...r,...o.in?{in:o.in}:{}})}return{anchors:t.map(Ut),closed:n.closed}})}function Ut(e){let n={x:e.x,y:e.y};return e.in&&!ce(e.in,e)&&(n.in=e.in),e.out&&!ce(e.out,e)&&(n.out=e.out),n}function ce(e,n,t=1e-6){return Math.abs(e.x-n.x)<t&&Math.abs(e.y-n.y)<t}function Wt(e){let n=0,t=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n+=1},r=()=>{t();let i=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(n));if(i)return n+=i[0].length,Number(i[0])},o=()=>{t();let i=e[n];if(!(i!=="0"&&i!=="1"))return n+=1,Number(i)};return{more(){return t(),n<e.length},command(){t();let i=e[n];if(/[a-zA-Z]/.test(i))return n+=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 n}}}function Bt(e,n,t,r,o,i,s,u,a){let c=Math.abs(t),f=Math.abs(r);if(c===0||f===0||e===u&&n===a)return[];let d=o*Math.PI/180,l=Math.cos(d),y=Math.sin(d),b=(e-u)/2,p=(n-a)/2,$=l*b+y*p,k=-y*b+l*p,g=$*$/(c*c)+k*k/(f*f);g>1&&(c*=Math.sqrt(g),f*=Math.sqrt(g));let T=c*c*f*f-c*c*k*k-f*f*$*$,m=c*c*k*k+f*f*$*$,w=(i===s?-1:1)*Math.sqrt(Math.max(0,T/m)),x=w*c*k/f,v=-w*f*$/c,S=l*x-y*v+(e+u)/2,L=y*x+l*v+(n+a)/2,C=(O,V,B,z)=>{let q=O*B+V*z,he=Math.hypot(O,V)*Math.hypot(B,z),Z=Math.acos(Math.min(1,Math.max(-1,q/he)));return O*z-V*B<0?-Z:Z},U=C(1,0,($-x)/c,(k-v)/f),W=C(($-x)/c,(k-v)/f,(-$-x)/c,(-k-v)/f);!s&&W>0&&(W-=2*Math.PI),s&&W<0&&(W+=2*Math.PI);let Ge=Math.max(1,Math.ceil(Math.abs(W)/(Math.PI/2)-1e-9)),Je=W/Ge,pe=4/3*Math.tan(Je/4),Fn=O=>({x:S+c*Math.cos(O)*l-f*Math.sin(O)*y,y:L+c*Math.cos(O)*y+f*Math.sin(O)*l}),jn=O=>({x:-c*Math.sin(O)*l-f*Math.cos(O)*y,y:-c*Math.sin(O)*y+f*Math.cos(O)*l}),Cn=[];for(let O=0;O<Ge;O+=1){let V=U+O*Je,B=V+Je,z=Fn(V),q=O===Ge-1?{x:u,y:a}:Fn(B),he=jn(V),Z=jn(B);Cn.push([{x:z.x+pe*he.x,y:z.y+pe*he.y},{x:q.x-pe*Z.x,y:q.y-pe*Z.y},q])}return Cn}function qe(e){let n=[],t=r=>`${h(r.x)} ${h(r.y)}`;for(let r of e){let{anchors:o}=r,i=o[0];if(!i)continue;n.push(`M${t(i)}`);let s=Te(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||n.push(`L${t(c)}`):n.push(`C${t(a.out??a)} ${t(c.in??c)} ${t(c)}`)}r.closed&&n.push("Z")}return n.join(" ")}function Te(e){let n=e.anchors.length;return n<2?0:e.closed?n:n-1}function Ze(e,n){let t=e.anchors[n],r=e.anchors[(n+1)%e.anchors.length];return[{x:t.x,y:t.y},t.out??{x:t.x,y:t.y},r.in??{x:r.x,y:r.y},{x:r.x,y:r.y}]}function Qe(e,n){let[t,r,o,i]=e,s=1-n,u=s*s*s,a=3*s*s*n,c=3*s*n*n,f=n*n*n;return{x:u*t.x+a*r.x+c*o.x+f*i.x,y:u*t.y+a*r.y+c*o.y+f*i.y}}function en(e,n){return e.map(t=>({closed:t.closed,anchors:t.anchors.map(r=>{let o=n(r);return{x:o.x,y:o.y,...r.in?{in:n(r.in)}:{},...r.out?{out:n(r.out)}:{}}})}))}function nn(e){let n=1/0,t=1/0,r=-1/0,o=-1/0,i=s=>{n=Math.min(n,s.x),t=Math.min(t,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=Te(s);for(let a=0;a<u;a+=1){let c=Ze(s,a);for(let f of zt(c))i(Qe(c,f))}}if(n!==1/0)return{x:n,y:t,w:r-n,h:o-t}}function zt(e){let[n,t,r,o]=e,i=[];for(let s of["x","y"]){let u=-n[s]+3*t[s]-3*r[s]+o[s],a=2*(n[s]-2*t[s]+r[s]),c=t[s]-n[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 Ne(e){if(e===void 0)return;let n=e.trim().split(/[\s,]+/).map(Number);if(n.length!==4||n.some(s=>!Number.isFinite(s)))return;let[t,r,o,i]=n;return{x:t,y:r,w:o,h:i}}function tn(e,n,t){return Ne(e)??{x:0,y:0,w:n,h:t}}function rn(e,n){let t=e.w===0?1:n.w/e.w,r=e.h===0?1:n.h/e.h;return o=>({x:n.x+(o.x-e.x)*t,y:n.y+(o.y-e.y)*r})}function Gn(e,n=.5){let[t,r,o,i]=e;if(ce(t,r)&&ce(o,i))return[t,i];let u=Math.hypot(r.x-t.x,r.y-t.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/n)))),c=[];for(let f=0;f<=a;f+=1)c.push(Qe(e,f/a));return c}function Gt(e,n,t){let r=0,o=0;for(let i of e){let s=Jt(i);if(s.length!==0){if(t.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(Xt(n,c,f)<=t.reach)return!0}if(s.length===1&&Math.hypot(n.x-s[0].x,n.y-s[0].y)<=t.reach)return!0}if(t.fill)for(let u=0;u<s.length;u+=1){let a=s[u],c=s[(u+1)%s.length];a.y<=n.y!=c.y<=n.y&&a.x+(n.y-a.y)/(c.y-a.y)*(c.x-a.x)>n.x&&(o+=1,r+=c.y>a.y?1:-1)}}}return t.fill?t.rule==="evenodd"?o%2===1:r!==0:!1}function Jt(e){let n=e.anchors[0];if(!n)return[];let t=[{x:n.x,y:n.y}],r=Te(e);for(let o=0;o<r;o+=1)t.push(...Gn(Ze(e,o)).slice(1));return e.closed&&t.length>1&&t.pop(),t}function Xt(e,n,t){let r=t.x-n.x,o=t.y-n.y,i=r*r+o*o,s=i===0?0:Math.max(0,Math.min(1,((e.x-n.x)*r+(e.y-n.y)*o)/i));return Math.hypot(e.x-(n.x+s*r),e.y-(n.y+s*o))}var Ie={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"]]},Ae=[["font","string"],["size","number"],["weight","number"],["italic","boolean"],["underline","boolean"],["strike","boolean"],["fill","string"],["letterSpacing","number"],["link","string"]];var on=[["enter","pageEffect"],["duration","number"]],_e=[["enter","nodeEffect"],["exit","nodeEffect"],["duration","number"],["delay","number"],["step","boolean"],["together","boolean"],["go","string"]],Yn=Object.keys(Ie);function Pe(e){return Yn.includes(e)}function sn(e,n){return Ie[e].find(([t])=>t===n)?.[1]}function I(e,n){if(n==="boolean")return e===""||e==="true"?{value:!0}:e==="false"?{value:!1}:{error:`Expected true or false, got ${e}`};if(e.startsWith('"')){let r=H(e);return r===void 0?{error:`Malformed quoted string ${e}`}:Jn(r,n,e)}if(er(e)){if(!qt(n))return{error:Zt(e,n)};let r=Kn(e).trim();return r===""?{error:"Empty expression"}:{value:Q(r)}}return n==="numberValue"&&Hn.test(e)?{value:Q(e)}:Jn(e,n,e)}var Hn=/^-?\d+(?:\.\d+)?%$/;function qt(e){return e==="numberValue"||e==="stringValue"}function Zt(e,n){return n==="number"?`Expected a plain number, not an expression, got ${e}`:n==="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 Qt(e,n){let t=/^(-?\d+(?:\.\d+)?)([A-Za-z]+)$/.exec(e);return t?t[2]==="s"&&n==="number"?` \u2014 durations are milliseconds: ${Number(t[1])*1e3}`:/^(?:px|pt|deg|ms)$/.test(t[2])?` \u2014 drop the unit: ${t[1]}`:" \u2014 units are not supported: use a number, a percentage like (100%), or an expression":n==="number"?Hn.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 Jn(e,n,t){switch(n){case"numberValue":case"number":{let r=Number(e);return Number.isFinite(r)&&e.trim()!==""?{value:r}:{error:`Expected a number, got ${t}${Qt(e,n)}`}}case"align":return ee.includes(e)?{value:e}:{error:`Expected one of ${ee.join(", ")}, got ${t}`};case"valign":return ne.includes(e)?{value:e}:{error:`Expected one of ${ne.join(", ")}, got ${t}`};case"fontStyle":return e==="normal"||e==="italic"?{value:e}:{error:`Expected normal or italic, got ${t}`};case"imageFit":return te.includes(e)?{value:e}:{error:`Expected one of ${te.join(", ")}, got ${t}`};case"fillRule":return Y(me,e,t);case"lineCap":return Y(ge,e,t);case"lineJoin":return Y(xe,e,t);case"blendMode":return Y(ye,e,t);case"pageEffect":return Y(be,e,t);case"nodeEffect":return Y(Ee,e,t);default:return{value:e}}}function Y(e,n,t){return e.includes(n)?{value:n}:{error:`Expected one of ${e.join(", ")}, got ${t}`}}function er(e){return/^[$@(]/.test(e)}function H(e){try{let n=JSON.parse(e);return typeof n=="string"?n:void 0}catch{return}}function Kn(e){if(!e.startsWith("("))return e;let n=0;for(let t=0;t<e.length;t+=1){let r=e[t];if(r==="(")n+=1;else if(r===")"&&(n-=1,n===0))return t===e.length-1?e.slice(1,-1):e}return e}function qn(e){let n=[],t="",r=0,o=!1;for(let i=0;i<e.length;i+=1){let s=e[i];if(o){t+=s,s==="\\"?(t+=e[i+1]??"",i+=1):s==='"'&&(o=!1);continue}if(s==='"'){o=!0,t+=s;continue}if(s==="("?r+=1:s===")"&&(r=Math.max(0,r-1)),r===0&&/\s/.test(s)){t!==""&&n.push(t),t="";continue}t+=s}return t!==""&&n.push(t),n}function an(e,n,t){let r=t===void 0?void 0:A(t);if(r?.value===void 0||!Xn(e[n]??""))return;let o=n;for(;o<e.length&&Xn(e[o]??"");)o+=1;let i=[Kn(r.value),...e.slice(n,o)].join(" ");return{end:o,message:`${r.key}: an expression with spaces needs parentheses \u2014 write ${r.key}=(${i})`}}function Xn(e){return!e.includes("=")&&/^(?:[-+*/]|-?\d+(?:\.\d+)?%?|[$@][\w.]*|[A-Za-z_]\w*(?:\.\w+)+|\(.*|.*\))$/.test(e)}function A(e){let n=e.indexOf("=");return n===-1?{key:e,value:void 0}:{key:e.slice(0,n),value:e.slice(n+1)}}var rr=new Set(["exit","delay","step","together","go"]);function un(e,n){let t=e.words[1];if(t===void 0||t.includes("=")){n(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),u=on.find(([c])=>c===i)?.[1];if(u===void 0){let c=rr.has(i)?` \u2014 ${i} goes on a node's line, under the header`:"";n(e.number,"invalid-motion",`motion ${t} has no "${i}"${c}`,t);continue}let a=I(s??"",u);"error"in a?n(e.number,"invalid-motion",`${i}: ${a.error}`,t):i==="duration"&&!Zn(a.value)?n(e.number,"invalid-motion",Qn(i,s),t):r[i]=a.value}return{page:t,number:e.number,head:r,lines:[],where:new Map,taken:new Map}}function cn(e,n,t){let r=n.words[0];if(n.indent!==1){t(n.number,"invalid-motion","A motion line sits one level under its page");return}if(r.includes("=")){t(n.number,"invalid-motion",`Expected a node id first, got ${r}`);return}if(r===e.page){t(n.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 u of n.words.slice(1)){let{key:a,value:c}=A(u),f=_e.find(([l])=>l===a)?.[1];if(f===void 0){t(n.number,"invalid-motion",`A motion line has no "${a}"`,r),i=!1;continue}let d=I(c??"",f);"error"in d?(t(n.number,"invalid-motion",`${a}: ${d.error}`,r),i=!1):(a==="duration"||a==="delay")&&!Zn(d.value)?(t(n.number,"invalid-motion",Qn(a,c),r),i=!1):a==="go"&&X(d.value)===void 0?(t(n.number,"invalid-motion",`go: expected #<page>, back, next, or an https: or mailto: link, got ${c??""}`,r),i=!1):d.value!==!1&&(o[a]=d.value)}if(o.enter!==void 0&&o.exit!==void 0&&(t(n.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&&(t(n.number,"invalid-motion",`${r} waits for a step or starts together with the line above, not both`,r),i=!1),!i)return;let s=or(o);if(!Se(s)){t(n.number,"invalid-motion",`${r} says nothing: give it enter=, exit= or go=`,r);return}for(let u of["enter","exit","go"]){if(s[u]===void 0)continue;let a=e.taken.get(`${r} ${u}`);if(a!==void 0){let c=u==="go"?"has a go=":u==="enter"?"enters":"exits";t(n.number,"invalid-motion",`${r} already ${c} on line ${a}`,r);return}}for(let u of["enter","exit","go"])s[u]!==void 0&&e.taken.set(`${r} ${u}`,n.number);e.where.has(r)||e.where.set(r,n.number),e.lines.push(s)}function fn(e){let n={...e.head.enter===void 0?{}:{enter:e.head.enter},...e.head.duration===void 0?{}:{duration:e.head.duration},lines:e.lines};return ae(n)?void 0:n}function or(e){let n={id:e.id};for(let[t]of _e)e[t]!==void 0&&(n[t]=e[t]);return n}function Zn(e){return typeof e=="number"&&e>=0&&e<=se}function Qn(e,n){return`${e}: expected 0 to ${se} milliseconds, got ${n??""}`}function dn(e){return(n,t,r,o)=>{e.push({severity:"error",code:t,message:`Line ${n}: ${r}`,...o===void 0?{}:{nodeId:o}})}}function ln(e){let n=[],t=e.split(`
5
+ `);for(let r=0;r<t.length;r+=1){let o=t[r],i=o.trim();if(i===G)break;if(i===""||i.startsWith("```"))continue;let s=o.length-o.trimStart().length;n.push({number:r+1,indent:Math.floor(s/2),text:i,words:qn(i)})}return n}function pn(e){let n=[],t=[],r=o=>{for(;n.length>0&&n[n.length-1].indent>=o;)ar(n.pop())};return{push(o){let i=o.words[0];if(i.startsWith('"')){let c=n[n.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=cr(o,e);return f!==void 0&&c.runs.push(f),!0}if(!Pe(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=sr(i,s,o.words.slice(2),o,e),a=n[n.length-1];return a?a.children.push(u.record):t.push(u.record),n.push(u),!0},finish(){return r(0),t}}}function sr(e,n,t,r,o){let i={type:e,id:n},s=[];for(let u=0;u<t.length;u+=1){let{key:a,value:c}=A(t[u]),f=sn(e,a);if(f===void 0){let l=an(t,u,t[u-1]);l?(o(r.number,"invalid-value",l.message,n),u=l.end-1):o(r.number,"invalid-value",`${e} has no property "${a}"`,n);continue}let d=I(c??"",f);"error"in d?o(r.number,"invalid-value",`${a}: ${d.error}`,n):i[a]=d.value}return $e(e)&&(i.children=s),e==="text"&&(i.content=""),{indent:r.indent,type:e,record:i,children:s,runs:[]}}function ar(e){e.type==="text"&&(e.record.content=ur(e.runs))}function ur(e){if(e.length===0)return"";let n=e[0];return e.length===1&&typeof n=="string"?n:[...e]}function cr(e,n){let t=H(e.words[0]);if(t===void 0){n(e.number,"invalid-run","Malformed quoted string");return}if(e.words.length===1)return t;let r={text:t};for(let o of e.words.slice(1)){let{key:i,value:s}=A(o),u=Ae.find(([c])=>c===i);if(!u){n(e.number,"invalid-run",`A run has no mark "${i}"`);continue}let a=I(s??"",u[1]);"error"in a?n(e.number,"invalid-run",`${i}: ${a.error}`):r[i]=a.value}return r}function fr(e){let n=[],t=dn(n),r=J,o,i=!1,s={},u={},a={},c=pn(t),f,d={},l=new Map,y,b=!1,p=()=>{if(!y)return;let m=y;y=void 0;let w=l.get(m.page);if(w!==void 0){t(m.number,"invalid-motion",`motion ${m.page} is written twice \u2014 put its lines in the block on line ${w}`,m.page);return}l.set(m.page,m.number);for(let[v,S]of m.where)l.set(`${m.page} ${v}`,S);let x=fn(m);x&&(d[m.page]=x)};for(let m of ln(e)){let w=m.words[0];if(y&&m.indent>0){cn(y,m,t);continue}if(!(b&&m.indent>0)){if(b=!1,p(),w==="motion"&&m.indent===0){f=void 0,y=un(m,t),b=y===void 0;continue}if(w==="version"){i=!0,lr(m,n);continue}if(w==="kind"&&m.indent===0){r=pr(m,n);continue}if(w==="title"&&m.indent===0){o=nt(m,t);continue}if(w.startsWith("$")){f=void 0,hr(m,s,t);continue}if(w==="asset"&&m.indent===0){f=void 0,yr(m,a,t);continue}if(w==="font"&&m.indent===0){f=gr(m,u,t);continue}if((w==="fallback"||w==="face")&&f){xr(w,m,f,t);continue}f=void 0,!c.push(m)&&t(m.number,"unknown-node-type",`Unknown statement "${w}"`)}}p();let $=dr(c.finish(),n),k=Object.keys(d).length===0?{}:{motion:d},g=(m,w)=>l.get(w===void 0?m:`${m} ${w}`);if(!$){i||n.push({severity:"error",code:"invalid-document",message:"No nodes found"});let m=ie({id:F,children:[]}),w=ve({kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...k,root:m});return n.push(...ue(w,g)),{document:w,problems:n}}let T={version:4,kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...k,root:$};return n.push(...ue(T,g)),{document:T,problems:n}}function dr(e,n){let t=e[0];if(t!==void 0){if(e.length===1&&t.type==="canvas")return t;for(let r of e){if(r.type!=="canvas")continue;let o=r.id;n.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 lr(e,n){ke.includes(Number(e.words[1]))||n.push({severity:"warning",code:"version-mismatch",message:`Line ${e.number}: expected version ${4} or older, got ${e.words[1]??"nothing"}`})}function pr(e,n){let t=e.words[1];return t!==void 0&&oe.includes(t)?t:(n.push({severity:"error",code:"unknown-kind",message:`Line ${e.number}: unknown kind "${t??"nothing"}" \u2014 this build reads ${oe.join(", ")}`}),J)}function nt(e,n){let t=e.words.slice(1).join(" ").trim();if(t===""){n(e.number,"invalid-value",'title needs a name, e.g. title "Pitch deck"');return}let r=t.startsWith('"')?H(t):t;if(r===void 0){n(e.number,"invalid-value",`Could not read the title ${t}`);return}return r.trim()===""?void 0:r}function hr(e,n,t){let{name:r,value:o}=hn(e.words);if(r===void 0||o===void 0){t(e.number,"invalid-token","Expected $name = value");return}if(!o.startsWith('"')&&/\s/.test(o)){t(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){t(e.number,"invalid-token",`$${r}: ${i.error}`);return}if(typeof i.value!="string"){t(e.number,"invalid-token",`$${r} may not be an expression`);return}n[r]=tt(i.value,o)}function tt(e,n){let t=Number(e);return n.startsWith('"')||!Number.isFinite(t)||e.trim()===""?e:t}function hn(e){let n=e[0],t=i=>i.startsWith("$")?i.slice(1):i;if(e[1]==="=")return{name:t(n),value:e.slice(2).join(" ")||void 0};let{key:r,value:o}=A(n);return o!==void 0?{name:t(r),value:o}:{name:t(n)}}function yr(e,n,t){let r=e.words.slice(1),o=r[0],i=r[1]==="=",s=o===void 0?void 0:A(o),u=s?.key,a=i?r[2]:s?.value,c=r.slice(i?3:1);if(u===void 0||u===""||a===void 0){t(e.number,"invalid-asset","Expected asset <name> = <type> hash=\u2026 bytes=\u2026");return}let f={};for(let y of c){let{key:b,value:p}=A(y);if(p===void 0){t(e.number,"invalid-asset",`Asset "${u}" has a stray word "${y}"`);continue}f[b]=mr(p)}let d=f.hash,l=Number(f.bytes);if(d===void 0||!Number.isFinite(l)){t(e.number,"invalid-asset",`Asset "${u}" needs a hash and a bytes count`);return}n[u]={type:a,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 mr(e){return e.startsWith('"')?H(e)??e:e}function gr(e,n,t){let{name:r,value:o}=hn(e.words.slice(1));if(r===void 0||o===void 0){t(e.number,"invalid-font","Expected font <name> = <family>");return}let i=I(o,"string"),s={family:"error"in i?o:i.value};return n[r]=s,{family:s,faces:[]}}function xr(e,n,t,r){if(e==="fallback"){let u=I(n.words.slice(1).join(" "),"string");"error"in u?r(n.number,"invalid-font",`fallback: ${u.error}`):t.family.fallback=u.value;return}let o=n.words[1];if(o===void 0){r(n.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 u of n.words.slice(2)){let{key:a,value:c}=A(u);if(a!=="weight"&&a!=="style"){r(n.number,"invalid-font-face",`A face has no property "${a}"`);continue}let f=I(c??"",a==="weight"?"number":"fontStyle");"error"in f?r(n.number,"invalid-font-face",`${a}: ${f.error}`):s[a]=f.value}t.faces.push(s),t.family.faces=t.faces}function Le(e){return/^\s*(linear|radial|conic|repeating-[a-z]+)-gradient\s*\(/i.test(e)}function yn(e){let n=e.trim(),t=/^([a-z-]+)-gradient\s*\(([\s\S]*)\)$/i.exec(n);if(!t)return Le(n)?{error:'A gradient needs its closing ")"'}:{kind:"solid",colour:n};let r=t[1].toLowerCase(),o=br(t[2]).map(i=>i.trim());if(o.some(i=>i===""))return{error:"A gradient has an empty argument"};if(r==="linear"){let i=Sr(o[0]),s=ot(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=Mr(o[0]);if(i&&"error"in i)return i;let s=ot(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 mn(e){let n=e.map(r=>r.at);n[0]===void 0&&(n[0]=0),n[n.length-1]===void 0&&(n[n.length-1]=1);let t=0;for(let r=0;r<n.length;r+=1){let o=n[r];o!==void 0&&(t=Math.max(t,o),n[r]=t)}for(let r=1;r<n.length;r+=1){if(n[r]!==void 0)continue;let o=r-1,i=r;for(;n[i]===void 0;)i+=1;let s=n[o],u=n[i];for(let a=r;a<i;a+=1)n[a]=s+(u-s)*(a-o)/(i-o);r=i}return e.map((r,o)=>({colour:r.colour,at:n[o]}))}function br(e){let n=[],t=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?t+=1:i===")"?t=Math.max(0,t-1):i===","&&t===0&&(n.push(e.slice(r,o)),r=o+1)}return n.push(e.slice(r)),n}var Er={top:[0,-1],bottom:[0,1],left:[-1,0],right:[1,0]};function Sr(e){let n=/^(-?\d*\.?\d+)(deg|turn|rad)$/i.exec(e);if(n){let i=Number(n[1]),s=n[2].toLowerCase();return s==="turn"?i*360:s==="rad"?i*180/Math.PI:i}let t=/^to\s+([a-z]+)(?:\s+([a-z]+))?$/i.exec(e);if(!t)return;let r=0,o=0;for(let i of[t[1],t[2]]){if(i===void 0)continue;let s=Er[i.toLowerCase()];if(!s)return;r+=s[0],o+=s[1]}return(Math.atan2(r,-o)*180/Math.PI+360)%360}var Or={left:0,top:0,center:.5,right:1,bottom:1};function Mr(e){let n=/^(circle|ellipse)?\s*(?:at\s+(\S+)(?:\s+(\S+))?)?$/i.exec(e);if(!n||n[1]===void 0&&n[2]===void 0)return;let t=n[1]?.toLowerCase();if(n[2]===void 0)return t?{shape:t}:void 0;let r=rt(n[2]),o=n[3]===void 0?.5:rt(n[3]);return r===void 0||o===void 0?{error:`A radial centre is two percentages or keywords, not "${e}"`}:{...t?{shape:t}:{},cx:r,cy:o}}function rt(e){let n=Or[e.toLowerCase()];if(n!==void 0)return n;let t=/^(-?\d*\.?\d+)%$/.exec(e);return t?Number(t[1])/100:void 0}function ot(e){if(e.length<2)return{error:"A gradient needs at least two colours"};let n=[];for(let t of e){let r=/^([\s\S]*?\S)\s+(-?\d*\.?\d+)%$/.exec(t);if(r&&Tr(r[1]))n.push({colour:r[1],at:Number(r[2])/100});else{if(/\s/.test(t.replace(/\([^)]*\)/g,"")))return{error:`"${t}" is not a colour with an optional percentage`};n.push({colour:t})}}return{stops:n}}function Tr(e){let n=0;for(let t of e)if(t==="("&&(n+=1),t===")"&&(n-=1),n<0)return!1;return n===0}function gn(e){let n=e.trim();if(n===""||n==="none")return{shadows:[]};let t=[];for(let r of Nr(n)){let o=Ir(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"};t.push({x:u,y:a,blur:c,spread:f,colour:s[0]})}return{shadows:t}}function Nr(e){let n=[],t=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?t+=1:i===")"?t=Math.max(0,t-1):i===","&&t===0&&(n.push(e.slice(r,o)),r=o+1)}return n.push(e.slice(r)),n}function Ir(e){let n=[],t=0,r="";for(let o of e){if(o==="("&&(t+=1),o===")"&&(t=Math.max(0,t-1)),/\s/.test(o)&&t===0){r!==""&&n.push(r),r="";continue}r+=o}return r!==""&&n.push(r),n}function Ve(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function it(e,n,t){if(t===0)return e;let r=t*Math.PI/180,o=Math.cos(r),i=Math.sin(r),s=e.x-n.x,u=e.y-n.y;return{x:n.x+s*o-u*i,y:n.y+s*i+u*o}}function xn(e,n,t=Ve(e)){if(n%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=>it(a,t,n)),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 at="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",ut=16,ct=400,ft=1.2,De="#0F172A";function wn(){return{advance(e,n){return e.length*(n.size*.5+n.letterSpacing)},metrics(e){return{ascent:e.size*.8,descent:e.size*.2,lineGap:0}}}}function $n(e,n){if(e===void 0)return at;let t=n[e];return t?t.fallback?`${st(t.family)}, ${t.fallback}`:st(t.family):e}function st(e){return/^[A-Za-z][A-Za-z0-9 -]*$/.test(e)?e:JSON.stringify(e)}function dt(e,n,t,r){let o={family:$n(n.font,t),size:n.size,weight:n.weight,italic:n.italic,underline:!1,strike:!1,fill:r(n.fill),letterSpacing:n.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:$n(a.font,t),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&&D(a.link)?{link:a.link}:{}}})}return s}function Ar(e,n){let t=[];for(let r of e)for(let o of r.text.split(/(\n)/))if(o!==""){if(o===`
6
+ `){let i=t[t.length-1];i&&!i.hardBreak?t[t.length-1]={...i,hardBreak:!0}:t.push({text:"",style:r.style,w:0,hardBreak:!0});continue}for(let i of o.match(/\S+\s*|\s+/g)??[])t.push({text:i,style:r.style,w:n.advance(i,r.style),hardBreak:!1})}return t}function _r(e,n,t){let r=[...e.text],o=[],i="";for(let s of r){let u=i+s;if(i!==""&&t.advance(u,e.style)>n){o.push({text:i,style:e.style,w:t.advance(i,e.style),hardBreak:!1}),i=s;continue}i=u}return i!==""&&o.push({text:i,style:e.style,w:t.advance(i,e.style),hardBreak:e.hardBreak}),o.length>0?o:[e]}function lt(e,n){let{width:t,measure:r}=n,o=Ar(r.itemize?e.flatMap(c=>r.itemize?.(c)??[c]):e,r);if(o.length===0){let c=e[0]?.style,f=c?n.lineHeight*c.size:0;return{lines:c?[Pr(c,n.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>t&&t>0?_r(c,t,r):[c];for(let d of f){let l=d.text.trimEnd(),y=l===d.text?d.w:r.advance(l,d.style);s.length>0&&u+y>t&&a(),s.push(d),u+=d.w,d.hardBreak&&a()}}return s.length>0&&i.push(s),Rr(i,n)}function Pr(e,n){let t=n*e.size;return{y:0,h:t,baseline:t*.8,w:0,spans:[]}}function Rr(e,n){let t=[],r=0,o=0;return e.forEach((i,s)=>{let u=i.map(v=>v.style.size),a=Math.max(...u,0),c=n.lineHeight*a,f=i.map(v=>n.measure.metrics(v.style)),d=Math.max(...f.map(v=>v.ascent),0),l=Math.max(...f.map(v=>v.descent),0),y=r+(c-(d+l))/2+d,b=Lr(i,n.measure),p=b.reduce((v,S)=>v+S.w,0);o=Math.max(o,p);let $=s===e.length-1||(i[i.length-1]?.hardBreak??!1),k=n.align==="justify"&&!$&&b.length>1,g=Math.max(0,n.width-p),T=n.align==="center"?g/2:n.align==="right"?g:0,m=k?g/(b.length-1):0,w=[],x=T;b.forEach((v,S)=>{w.push({text:v.text,style:v.style,x,w:v.w}),x+=v.w+(S<b.length-1?m:0)}),t.push({y:r,h:c,baseline:y,w:p,spans:Vr(w,k)}),r+=c}),{lines:t,width:o,height:r}}function Lr(e,n){let t=[...e];for(;t.length>0;){let r=t[t.length-1],o=r.text.trimEnd();if(o===r.text)break;if(o===""){t.pop();continue}t[t.length-1]={...r,text:o,w:n.advance(o,r.style)};break}return t}function Vr(e,n){if(n)return[...e];let t=[];for(let r of e){let o=t[t.length-1];if(o&&pt(o.style,r.style)&&Math.abs(o.x+o.w-r.x)<.01){t[t.length-1]={...o,text:o.text+r.text,w:o.w+r.w};continue}t.push(r)}return t}function pt(e,n){return e.family===n.family&&e.size===n.size&&e.weight===n.weight&&e.italic===n.italic&&e.underline===n.underline&&e.strike===n.strike&&e.fill===n.fill&&e.letterSpacing===n.letterSpacing&&e.link===n.link}function kn(e,n,t,r,o,i){let s={size:n.size??ut,weight:n.weight??ct,lineHeight:n.lineHeight??ft,letterSpacing:n.letterSpacing??0,italic:e.italic??!1,font:typeof e.font=="string"?e.font:void 0,fill:typeof e.fill=="string"?e.fill:De};return lt(dt(e.content,s,r,o),{width:t,align:e.align??"left",lineHeight:s.lineHeight,measure:i})}function vn(e,n,t){let r=n-t;return e.valign==="middle"?r/2:e.valign==="bottom"?r:0}var ht=["x","y","w","h","left","right","top","bottom","cx","cy"];function fe(e){return ht.includes(e)}var yt=["parent","prev","next","self","root"];function bn(e){return yt.includes(e)}var M=class extends Error{position;constructor(n,t){super(n),this.position=t,this.name="ExprSyntaxError"}},mt=/[A-Za-z_]/,En=/[A-Za-z0-9_]/;function Sn(e){let n=[],t=0,r=()=>{if(!mt.test(e[t]??""))throw new M(`Expected a name at position ${t}`,t);let s=t;for(;t<e.length&&En.test(e[t]??"");)t++;return e.slice(s,t)},o=()=>{if(!En.test(e[t]??""))throw new M(`Expected a name at position ${t}`,t);let s=t;for(;t<e.length&&En.test(e[t]??"");)t++;return e.slice(s,t)},i=()=>{let s=[r()];for(;e[t]===".";)t++,s.push(o());return s};for(;t<e.length;){let s=e[t]??"";if(/\s/.test(s)){t++;continue}if(/[0-9]/.test(s)){let u=t;for(;t<e.length&&/[0-9]/.test(e[t]??"");)t++;if(e[t]==="."&&/[0-9]/.test(e[t+1]??""))for(t++;t<e.length&&/[0-9]/.test(e[t]??"");)t++;let a=e.slice(u,t),c=Number(a);if(!Number.isFinite(c))throw new M(`Bad number "${a}"`,u);e[t]==="%"?(t++,n.push({type:"percent",value:c})):n.push({type:"number",value:c});continue}if(s==="$"){t++,n.push({type:"token",name:r()});continue}if(s==="@"){t++,n.push({type:"ref",path:i()});continue}if(mt.test(s)){n.push({type:"word",path:i()});continue}if("+-*/()".includes(s)){t++,n.push({type:"op",value:s});continue}throw new M(`Unexpected character "${s}" at position ${t}`,t)}return n.push({type:"eof"}),n}var Dr={"+":1,"-":1,"*":2,"/":2};function Fe(e){try{let n=Sn(e),t=new On(n),r=t.parseBinary(0);return t.expectEof(),{ok:!0,ast:r}}catch(n){if(n instanceof M)return{ok:!1,message:n.message};throw n}}var On=class{tokens;index=0;constructor(n){this.tokens=n}peek(){return this.tokens[this.index]??{type:"eof"}}next(){let n=this.peek();return this.index++,n}expectEof(){if(this.peek().type!=="eof")throw new M("Unexpected trailing input",this.index)}parseBinary(n){let t=this.parseUnary();for(;;){let r=this.peek();if(r.type!=="op"||!Fr(r.value))break;let o=Dr[r.value];if(o<n)break;this.next();let i=this.parseBinary(o+1);t={kind:"binary",op:r.value,left:t,right:i}}return t}parseUnary(){let n=this.peek();return n.type==="op"&&(n.value==="-"||n.value==="+")?(this.next(),{kind:"unary",op:n.value,operand:this.parseUnary()}):this.parsePrimary()}parsePrimary(){let n=this.next();switch(n.type){case"number":return{kind:"number",value:n.value};case"percent":return{kind:"percent",value:n.value};case"token":return{kind:"token",name:n.name};case"ref":{if(n.path.length<2)throw new M(`@${n.path.join(".")} needs an edge, for example @${n.path.join(".")}.right`,this.index);return{kind:"nodeRef",path:n.path}}case"word":{let[t,r,...o]=n.path;if(t===void 0||!bn(t))throw new M(`Unknown name "${n.path.join(".")}". Use $token for a token or @id.edge for a node.`,this.index);if(r===void 0||!fe(r)||o.length>0)throw new M(`${t} needs an edge, for example ${t}.w`,this.index);return{kind:"relRef",word:t,edge:r}}case"op":{if(n.value==="("){let t=this.parseBinary(0),r=this.next();if(r.type!=="op"||r.value!==")")throw new M("Missing closing parenthesis",this.index);return t}throw new M(`Unexpected "${n.value}"`,this.index)}case"eof":throw new M("Unexpected end of expression",this.index)}}};function Fr(e){return e==="+"||e==="-"||e==="*"||e==="/"}function R(e,n){return`${e} ${n}`}function Mn(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 Tn(e,n,t,r,o){switch(e){case"x":case"left":return n;case"y":case"top":return t;case"w":return r;case"h":return o;case"right":return n+r;case"bottom":return t+o;case"cx":return n+r/2;case"cy":return t+o/2}}function Nn(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 In(e,n,t){let r=d=>{let l=[];for(let y=t.parentOf.get(d);y!==void 0;y=t.parentOf.get(y))l.push(y);return l},o=r(e),i=r(n),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 y=(c.get(d)??0)+l;y===0?c.delete(d):c.set(d,y)};for(let d of a(o))f(d,1);for(let d of a(i))f(d,-1);return c}function An(e){switch(e){case"right":case"bottom":return 1;case"cx":case"cy":return .5;default:return 0}}function je(e){if(e==="x"||e==="w")return"w";if(e==="y"||e==="h")return"h"}function _n(e){let n=new Map,t=new Map,r=new Map,o=new Map,i=[];N(e.root,(f,d)=>{n.has(f.id)||n.set(f.id,f),i.push(f),d&&t.set(f.id,d.id),_(f)&&f.children.forEach((l,y)=>{let b=f.children[y-1],p=f.children[y+1];b&&r.set(l.id,b.id),p&&o.set(l.id,p.id)})});let s=new Map;for(let f of i){let d=t.get(f.id);for(;d!==void 0;){let l=n.get(d);if(!l||!re(l))break;d=t.get(d)}d!==void 0&&s.set(f.id,d)}let u=new Map,a=new Map,c=f=>{if(_(f)){if(!re(f)){let d=gt(f);d.forEach((l,y)=>{let b=d[y-1],p=d[y+1];b&&u.set(l.id,b.id),p&&a.set(l.id,p.id)})}for(let d of f.children)c(d)}};return c(e.root),{rootId:e.root.id,byId:n,parentOf:t,prevOf:r,nextOf:o,layoutParentOf:s,layoutPrevOf:u,layoutNextOf:a,order:i}}function gt(e){let n=[];for(let t of e.children)_(t)&&re(t)?n.push(...gt(t)):n.push(t);return n}function Ce(e,n,t){if(e.kind==="relRef"){let i=jr(e.word,n,t);return i===void 0?{ok:!1,message:`${n} 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 fe(r)?t.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 jr(e,n,t){switch(e){case"self":return n;case"root":return t.rootId;case"parent":return t.layoutParentOf.get(n);case"prev":return t.layoutPrevOf.get(n);case"next":return t.layoutNextOf.get(n)}}function Pn(e){let n=[],t=_n(e),r=Cr(t),o=new Set;Ur(r,n),Wr(r,e,t,o,n);let i=Br(r);zr(r,i,n);let s=Gr(r,i,e,t,o,n);return{nodes:Xr(e.root,s,r,n),problems:n}}function Cr(e){let n=new Map;for(let t of e.order){let r=t;for(let o of we(t)){let i=r[o];i!==void 0&&n.set(R(t.id,o),{nodeId:t.id,prop:o,value:i,deps:[]})}}return n}function Ur(e,n){for(let t of e.values()){if(!P(t.value))continue;let r=Fe(t.value.expr);if(r.ok){t.ast=r.ast;continue}n.push({severity:"error",code:"expression-syntax",message:r.message,nodeId:t.nodeId,prop:t.prop})}}function Wr(e,n,t,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=n.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=je(i.prop);if(!c)return;let f=t.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=Ce(a,i.nodeId,t);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=Nn(c.edge);if(!d){for(let l of Mn(c.edge))f(R(c.nodeId,l));return}for(let l of In(c.nodeId,i.nodeId,t).keys())f(R(l,d));An(c.edge)!==0&&f(R(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 Br(e){let n=new Map,t=new Map;for(let[i,s]of e){n.set(i,s.deps.length);for(let u of s.deps){let a=t.get(u);a?a.push(i):t.set(u,[i])}}let r=[];for(let[i,s]of n)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 t.get(s)??[]){let a=(n.get(u)??0)-1;n.set(u,a),a===0&&r.push(u)}}return o}function zr(e,n,t){if(n.length===e.size)return;let r=new Set(n);for(let[o,i]of e)r.has(o)||t.push({severity:"error",code:"cycle",message:`${i.nodeId}.${i.prop} is part of a dependency cycle`,nodeId:i.nodeId,prop:i.prop})}function Gr(e,n,t,r,o,i){let s=new Map,u=(a,c)=>s.get(R(a,c))??0;for(let a of n){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,xt(c.ast,c,t,r,o,i,u))}}return s}function xt(e,n,t,r,o,i,s){let u=a=>xt(a,n,t,r,o,i,s);switch(e.kind){case"number":return e.value;case"token":{let a=t.tokens[e.name];return typeof a=="number"?a:0}case"percent":{let a=je(n.prop);if(!a)return e.value/100;let c=r.layoutParentOf.get(n.nodeId);return c===void 0?0:e.value/100*s(c,a)}case"nodeRef":case"relRef":{if(o.has(e))return 0;let a=Ce(e,n.nodeId,r);if(!a.ok)return 0;let c=Nn(a.edge);if(!c)return Tn(a.edge,s(a.nodeId,"x"),s(a.nodeId,"y"),s(a.nodeId,"w"),s(a.nodeId,"h"));let f=An(a.edge)*s(a.nodeId,c==="x"?"w":"h");for(let[d,l]of In(a.nodeId,n.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:`${n.nodeId}.${n.prop} divides by zero`,nodeId:n.nodeId,prop:n.prop}),0;let f=Jr(e.op,a,c);return Number.isFinite(f)?f:(i.push({severity:"error",code:"not-a-number",message:`${n.nodeId}.${n.prop} did not produce a finite number`,nodeId:n.nodeId,prop:n.prop}),0)}}}function Jr(e,n,t){switch(e){case"+":return n+t;case"-":return n-t;case"*":return n*t;case"/":return n/t}}function Xr(e,n,t,r){let o=new Map,i=(u,a)=>n.get(R(u,a))??0,s=(u,a,c)=>{let f=i(u.id,"x"),d=i(u.id,"y"),l=i(u.id,"w"),y=i(u.id,"h"),b={};for(let k of we(u)){let g=R(u.id,k);t.has(g)&&(b[k]=n.get(g)??0)}(l<0||y<0)&&r.push({severity:"warning",code:"negative-size",message:`${u.id} resolved to a negative size`,nodeId:u.id});let p=a+f,$=c+d;if(o.set(u.id,{id:u.id,type:u.type,x:f,y:d,w:l,h:y,left:f,top:d,right:f+l,bottom:d+y,cx:f+l/2,cy:d+y/2,absX:p,absY:$,values:b}),_(u))for(let k of u.children)s(k,p,$)};return s(e,0,0),o}function Rn(e){switch(e.kind){case"text":{let n=Math.max(e.w,...e.lines.map(r=>r.w)),t=Math.max(e.y+e.h,...e.lines.map(r=>r.y+r.h));return{x:e.x,y:e.y,w:n,h:t-e.y}}case"vector":{let n=nn(e.contours)??{x:e.x,y:e.y,w:e.w,h:e.h},t=e.stroke!==void 0?e.strokeWidth*2:0;return{x:n.x-t,y:n.y-t,w:n.w+t*2,h:n.h+t*2}}case"rect":case"ellipse":{let n=e.stroke!==void 0?e.strokeWidth/2:0;return{x:e.x-n,y:e.y-n,w:e.w+n*2,h:e.h+n*2}}case"frame":case"image":return{x:e.x,y:e.y,w:e.w,h:e.h}}}function Be(e,n){let t=e.x,r=e.y,o=e.x+e.w,i=e.y+e.h;for(let s of n){let u=s.spread+s.blur;t=Math.min(t,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:t,y:r,w:o-t,h:i-r}}var kt="vd-paint-";var We="#CBD5E1",vt="#FFFFFF";function bt(e,n,t={}){let r=[...n.problems],o=[],i=[],s=t.measure??wn(),u=no(e.tokens,r),a=u.paint,c=new Map;N(e.root,(p,$)=>{if("hidden"in p&&p.hidden===!0)return!1;let k=$?c.get($.id):void 0,g=n.nodes.get(p.id);if(!g){c.set(p.id,k);return}if(p.type==="frame"){p.skip===!0&&$!==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:k),p.clip===!0&&i.push({id:p.id,...m,parent:k}),o.push({kind:"frame",id:p.id,...m,background:a(p.background,p.id,"background",m),clip:k,blend:p.blend??"normal",shadows:K(p.shadow,p.id,e.tokens,r),rotation:0});return}if(c.set(p.id,k),p.type==="text"){o.push(Hr(p,g,e,s,r,k,a));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:oo(p,e,t.resolveAsset,r),fit:p.fit??"fill",radius:Math.max(0,g.values.radius??0),opacity:le(g.values.opacity??1),clip:k,blend:p.blend??"normal",shadows:K(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0});return}if(p.type==="ellipse"){let m=wt(g);o.push({kind:"ellipse",id:p.id,...m,fill:a(p.fill,p.id,"fill",m)??We,stroke:a(p.stroke,p.id,"stroke",m),strokeWidth:g.values.strokeWidth??0,opacity:le(g.values.opacity??1),clip:k,blend:p.blend??"normal",shadows:K(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0});return}if(p.type==="vector"){o.push(eo(p,g,r,k,a,K(p.shadow,p.id,e.tokens,r)));return}if(p.type!=="rect")return;let T=wt(g);o.push({kind:"rect",id:p.id,...T,fill:a(p.fill,p.id,"fill",T)??We,stroke:a(p.stroke,p.id,"stroke",T),strokeWidth:g.values.strokeWidth??0,radius:Math.max(0,g.values.radius??0),opacity:le(g.values.opacity??1),clip:k,blend:p.blend??"normal",shadows:K(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0})});let f=n.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)}:Yr(o,i),y={x:l.x,y:l.y,w:l.width,h:l.height},b=a(e.root.background,e.root.id,"background",y);return{...l,background:d?b??vt:b,items:o,clips:i,gradients:u.gradients,problems:r}}function Yr(e,n){let t=new Map;for(let u of n){let a=u.parent===void 0?void 0:t.get(u.parent);t.set(u.id,a?$t(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"?Math.max(u.h,u.height):u.h,c=u.clip===void 0?void 0:t.get(u.clip),f=xn(Be({x:u.x,y:u.y,w:u.w,h:a},u.shadows),u.rotation,Ve(u)),d=c?$t(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 $t(e,n){let t=Math.max(e.x,n.x),r=Math.max(e.y,n.y);return{x:t,y:r,w:Math.min(e.x+e.w,n.x+n.w)-t,h:Math.min(e.y+e.h,n.y+n.h)-r}}function Ln(e,n={}){return bt(e,Pn(e),n)}function Hr(e,n,t,r,o,i,s){let u=Math.max(0,n.w),a=Math.max(0,n.h),c={x:n.absX,y:n.absY,w:u,h:a},f=kn(e,n.values,u,t.fonts,l=>s(l,e.id,"fill",c)??De,r);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"}),Kr(e,t,o);let d=n.absY+vn(e,a,f.height);return{kind:"text",id:e.id,x:n.absX,y:n.absY,w:u,h:a,clip:i,blend:e.blend??"normal",shadows:K(e.shadow,e.id,t.tokens,o),rotation:n.values.rotation??0,opacity:le(n.values.opacity??1),height:f.height,lines:f.lines.map(l=>({y:d+l.y,h:l.h,baseline:d+l.baseline,w:l.w,spans:l.spans.map(y=>({text:y.text,x:n.absX+y.x,y:d+l.baseline,w:y.w,style:y.style}))}))}}function Kr(e,n,t){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){t.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"&&!qr(n,o.id)&&t.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 qr(e,n){let t=!1;return N(e.root,r=>{if(t)return!1;r.id===n&&r.type==="frame"&&(t=!0)}),t}var de=new Map,Zr=512;function Qr(e){let n=de.get(e);if(n)return n;let t=Ke(e);return de.size>=Zr&&de.delete(de.keys().next().value),de.set(e,t),t}function eo(e,n,t,r,o,i){let s=Math.max(0,n.w),u=Math.max(0,n.h),a={x:n.absX,y:n.absY,w:s,h:u},{contours:c,error:f}=Qr(e.d);f!==void 0&&t.push({severity:"error",code:"bad-path",message:`${e.id}: ${f}`,nodeId:e.id,prop:"d"}),e.view!==void 0&&Ne(e.view)===void 0&&t.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=en(c,rn(tn(e.view,s,u),a));return{kind:"vector",id:e.id,...a,d:qe(d),contours:d,fill:o(e.fill,e.id,"fill",a)??We,stroke:o(e.stroke,e.id,"stroke",a),strokeWidth:n.values.strokeWidth??0,opacity:le(n.values.opacity??1),rule:e.rule??"nonzero",cap:e.cap??"butt",join:e.join??"miter",clip:r,blend:e.blend??"normal",shadows:i,rotation:n.values.rotation??0}}function Et(e,n,t,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:t,prop:r});return}let i=n[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:t,prop:r})}function wt(e){return{x:e.absX,y:e.absY,w:Math.max(0,e.w),h:Math.max(0,e.h)}}function no(e,n){let t=[],r=new Map;return{paint:(i,s,u,a)=>{let c=Et(i,e,s,u,n);if(c===void 0)return;let f=yn(c);if("error"in f){n.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 y=[...r.keys()].filter($=>$.startsWith(`${s}\0${u}\0`)).length,b=`${kt}${s}-${u}${y===0?"":`-${y+1}`}`;r.set(d,b);let p=mn(f.stops).map($=>({offset:$.at,colour:St($.colour,e,s,u,n)}));return t.push(ro(f,b,a,to(p))),`url(#${b})`},gradients:t}}function K(e,n,t,r){let o=Et(e,t,n,"shadow",r);if(o===void 0)return[];let i=gn(o);return"error"in i?(r.push({severity:"error",code:"invalid-shadow",message:`${n}: ${i.error}`,nodeId:n,prop:"shadow"}),[]):i.shadows.map(s=>({...s,colour:St(s.colour,t,n,"shadow",r)}))}function to(e){return e.map((n,t)=>{if(n.colour.trim().toLowerCase()!=="transparent")return n;let r=[e[t-1],e[t+1]].find(o=>o!==void 0&&o.colour.trim().toLowerCase()!=="transparent");return r===void 0?n:{offset:n.offset,colour:r.colour,opacity:0}})}function St(e,n,t,r,o){let i=n[e];return i===void 0?e:typeof i=="string"&&!Le(i)?i:(o.push({severity:"error",code:"invalid-paint",message:`${t}: a gradient stop names $${e}, which is not a colour`,nodeId:t,prop:r}),"transparent")}function ro(e,n,t,r){if(e.kind==="linear"){let c=e.angle*Math.PI/180,f=Math.sin(c),d=-Math.cos(c),l=(Math.abs(t.w*f)+Math.abs(t.h*d))/2,y=t.x+t.w/2,b=t.y+t.h/2;return{id:n,kind:"linear",x1:Ue(y-f*l),y1:Ue(b-d*l),x2:Ue(y+f*l),y2:Ue(b+d*l),stops:r}}let o=t.x+t.w*e.cx,i=t.y+t.h*e.cy,s={x:Math.max(o-t.x,t.x+t.w-o),y:Math.max(i-t.y,t.y+t.h-i)};if(e.shape==="circle"||s.x===0||s.y===0){let c=Math.hypot(s.x,s.y);return{id:n,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:n,kind:"radial",cx:o,cy:i,rx:a*u,ry:a,stops:r}}function Ue(e){return Math.round(e*1e6)/1e6}function le(e){return Math.min(Math.max(e,0),1)}function oo(e,n,t,r){let o=P(e.src)?void 0:e.src,i=o===void 0?void 0:n.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=t?.(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 ze="vd-clip-";function Vn(e,n={}){let t=n.indent??" ",r=n.ids??!0,o=h(e.width),i=h(e.height),s=`${h(e.x)} ${h(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(`${t}<defs>`);for(let c of e.clips)u.push(t+t+io(c));for(let c of e.gradients)u.push(t+t+Mt(c));for(let c of a)u.push(t+t+Tt(c,n.shadowsOnly));u.push(`${t}</defs>`)}e.background!==void 0&&u.push(`${t}<rect x="${h(e.x)}" y="${h(e.y)}" width="${o}" height="${i}" fill="${E(e.background)}"/>`);for(let c of e.items){let f=uo(c,r);f!==""&&u.push(t+f)}return u.push("</svg>"),`${u.join(`
7
+ `)}
8
+ `}function io(e){let n=e.parent===void 0?"":` clip-path="url(#${E(ze+e.parent)})"`;return`<clipPath id="${E(ze+e.id)}"${n}><rect x="${h(e.x)}" y="${h(e.y)}" width="${h(e.w)}" height="${h(e.h)}"/></clipPath>`}function Mt(e){let n=e.stops.map(r=>`<stop offset="${h(r.offset)}" stop-color="${E(r.colour)}"${r.opacity===void 0?"":` stop-opacity="${h(r.opacity)}"`}/>`).join(""),t=E(e.id);return e.kind==="linear"?`<linearGradient id="${t}" gradientUnits="userSpaceOnUse" x1="${h(e.x1)}" y1="${h(e.y1)}" x2="${h(e.x2)}" y2="${h(e.y2)}">${n}</linearGradient>`:`<radialGradient id="${t}" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="1" gradientTransform="matrix(${h(e.rx)} 0 0 ${h(e.ry)} ${h(e.cx)} ${h(e.cy)})">${n}</radialGradient>`}var so={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"},ao="#94A3B8";function j(e){let n=e.clip===void 0?[]:[`clip-path="url(#${E(ze+e.clip)})"`];return e.rotation!==0&&n.push(`transform="${Nt(e)}"`),e.shadows.length>0&&n.push(`filter="url(#${E(Dn+e.id)})"`),e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`),n}var Dn="vd-shadow-";function Tt(e,n=!1){let t=Be(Rn(e),e.shadows),r=2,o=[];e.shadows.forEach((s,u)=>{let a=`s${u}`,c="SourceAlpha";s.spread!==0&&(o.push(`<feMorphology in="${c}" operator="${s.spread>0?"dilate":"erode"}" radius="${h(Math.abs(s.spread))}" result="${a}m"/>`),c=`${a}m`),s.blur>0&&(o.push(`<feGaussianBlur in="${c}" stdDeviation="${h(s.blur/2)}" result="${a}b"/>`),c=`${a}b`),o.push(`<feOffset in="${c}" dx="${h(s.x)}" dy="${h(s.y)}" result="${a}o"/>`,`<feFlood flood-color="${E(s.colour)}" result="${a}c"/>`,`<feComposite in="${a}c" in2="${a}o" operator="in" result="${a}"/>`)});let i=e.shadows.map((s,u)=>`<feMergeNode in="s${e.shadows.length-1-u}"/>`).join("");return`<filter id="${E(Dn+e.id)}" filterUnits="userSpaceOnUse" x="${h(t.x-r)}" y="${h(t.y-r)}" width="${h(t.w+r*2)}" height="${h(t.h+r*2)}" color-interpolation-filters="sRGB">`+o.join("")+`<feMerge>${i}${n?"":'<feMergeNode in="SourceGraphic"/>'}</feMerge></filter>`}function Nt(e){return`rotate(${h(e.rotation)} ${h(e.x+e.w/2)} ${h(e.y+e.h/2)})`}function It(e){return e.rotation!==0&&e.clip!==void 0}function uo(e,n){if(It(e)){let t=[`clip-path="url(#${E(ze+e.clip)})"`];e.blend!=="normal"&&t.push(`style="mix-blend-mode:${e.blend}"`);let r=Ot({...e,clip:void 0,blend:"normal"},n);return r===""?"":`<g ${t.join(" ")}>${r}</g>`}return Ot(e,n)}function Ot(e,n){switch(e.kind){case"ellipse":return po(e,n);case"frame":return co(e,n);case"image":return fo(e,n);case"rect":return lo(e,n);case"text":return yo(e,n);case"vector":return ho(e,n)}}function co(e,n){let t=[];return n&&t.push(`id="${E(e.id)}"`),t.push(`x="${h(e.x)}"`,`y="${h(e.y)}"`,`width="${h(e.w)}"`,`height="${h(e.h)}"`,`fill="${e.background===void 0?"none":E(e.background)}"`,...j(e)),`<rect ${t.join(" ")}/>`}function fo(e,n){let t=[];return n&&t.push(`id="${E(e.id)}"`),t.push(`x="${h(e.x)}"`,`y="${h(e.y)}"`,`width="${h(e.w)}"`,`height="${h(e.h)}"`),e.href===void 0?(e.radius>0&&t.push(`rx="${h(e.radius)}"`),t.push('fill="none"',`stroke="${E(ao)}"`,'stroke-width="1"','stroke-dasharray="4 4"',...j(e)),`<rect ${t.join(" ")}/>`):(t.push(`href="${E(e.href)}"`,`preserveAspectRatio="${so[e.fit]}"`),e.opacity<1&&t.push(`opacity="${h(e.opacity)}"`),t.push(...j(e)),`<image ${t.join(" ")}/>`)}function lo(e,n){let t=[];return n&&t.push(`id="${E(e.id)}"`),t.push(`x="${h(e.x)}"`,`y="${h(e.y)}"`,`width="${h(e.w)}"`,`height="${h(e.h)}"`),e.radius>0&&t.push(`rx="${h(e.radius)}"`),t.push(`fill="${E(e.fill)}"`),e.stroke!==void 0&&e.strokeWidth>0&&t.push(`stroke="${E(e.stroke)}"`,`stroke-width="${h(e.strokeWidth)}"`),e.opacity<1&&t.push(`opacity="${h(e.opacity)}"`),t.push(...j(e)),`<rect ${t.join(" ")}/>`}function At(e){let n=[`fill="${E(e.fill)}"`];return e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${E(e.stroke)}"`,`stroke-width="${h(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${h(e.opacity)}"`),n}function po(e,n){let t=[];return n&&t.push(`id="${E(e.id)}"`),t.push(`cx="${h(e.x+e.w/2)}"`,`cy="${h(e.y+e.h/2)}"`,`rx="${h(e.w/2)}"`,`ry="${h(e.h/2)}"`,...At(e),...j(e)),`<ellipse ${t.join(" ")}/>`}function ho(e,n){if(e.d==="")return"";let t=[];return n&&t.push(`id="${E(e.id)}"`),t.push(`d="${E(e.d)}"`,...At(e)),e.rule!=="nonzero"&&t.push(`fill-rule="${e.rule}"`),e.cap!=="butt"&&t.push(`stroke-linecap="${e.cap}"`),e.join!=="miter"&&t.push(`stroke-linejoin="${e.join}"`),t.push(...j(e)),`<path ${t.join(" ")}/>`}function yo(e,n){if(e.lines.every(o=>o.spans.length===0))return"";let t=[];n&&t.push(`id="${E(e.id)}"`),t.push('xml:space="preserve"'),e.opacity<1&&t.push(`opacity="${h(e.opacity)}"`),t.push(...j(e));let r=[];for(let o of e.lines)for(let i of o.spans)i.text!==""&&r.push(mo(i));return`<text ${t.join(" ")}>${r.join("")}</text>`}function mo(e){let t=`<tspan ${[`x="${h(e.x)}"`,`y="${h(e.y)}"`,...go(e.style)].join(" ")}>${xo(e.text)}</tspan>`;return e.style.link===void 0?t:`<a href="${E(e.style.link)}">${t}</a>`}function go(e){let n=[`font-family="${E(e.family)}"`,`font-size="${h(e.size)}"`,`fill="${E(e.fill)}"`];e.weight!==400&&n.push(`font-weight="${h(e.weight)}"`),e.italic&&n.push('font-style="italic"'),e.letterSpacing!==0&&n.push(`letter-spacing="${h(e.letterSpacing)}"`);let t=[e.underline?"underline":"",e.strike?"line-through":""].filter(Boolean).join(" ");return t&&n.push(`text-decoration="${t}"`),n}function xo(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 Ca(e,n={}){let{resolveAsset:t,measure:r,...o}=n;return Vn(Ln(e,{...t?{resolveAsset:t}:{},...r?{measure:r}:{}}),o)}export{N as a,Xe as b,D as c,Dt as d,X as e,Ye as f,He as g,Gt as h,Pt as i,Rt as j,Lt as k,fr as l,it as m,Pn as n,wn as o,bt as p,Ln as q,Vn as r,Mt as s,Dn as t,Tt as u,Nt as v,It as w,Ca as x};
@@ -0,0 +1,2 @@
1
+ /*! @getv.design/embed v0.1.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ import{a as m}from"./chunk-EPAA36UG.js";import{i as c,l as a}from"./chunk-ZCGIXCW3.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};