@getv.design/embed 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/edit.js ADDED
@@ -0,0 +1,2381 @@
1
+ /*! @getv.design/embed v0.1.1. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
2
+ function kt(e){return{expr:e}}function ce(e){return typeof e=="object"&&e!==null&&typeof e.expr=="string"}var Bt=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],St=["left","center","right","justify"],_t=["top","middle","bottom"],Ct=["cover","contain","fill"],Ht=["nonzero","evenodd"],Vt=["butt","round","square"],Ut=["miter","round","bevel"],cf=["canvas","frame","group"];function no(e){return cf.includes(e)}function ue(e){return no(e.type)}function ke(e){return e.type==="group"}function le(e){return ue(e)?e.children:[]}var pf={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 tt(e){return pf[e.type]}function re(e,t,r){if(t(e,r)!==!1&&ue(e))for(let n of e.children)re(n,t,e)}function z(e,t){let r;return re(e,n=>{if(r)return!1;n.id===t&&(r=n)}),r}function rt(e,t){let r;return re(e,(n,o)=>{n.id===t&&o&&(r=o)}),r}function oo(e){return mf(e,"hidden")}function ao(e){return mf(e,"locked")}function mf(e,t){let r=new Set,n=(o,a)=>{let i=a||o[t]===!0;i&&r.add(o.id);for(let l of le(o))n(l,i)};return n(e,!1),r}function Qr(e,t,r){let n,o=(a,i)=>{let l=i??(a[r]===!0?a.id:void 0);return a.id===t?(n=l,!0):le(a).some(d=>o(d,l))};return o(e,void 0),n}var zt=["design"],Et="design";var en=[1,2,3,4],nt="doc";function cr(e){return{type:"canvas",...e}}function Ga(e){return{type:"ellipse",...e}}function Wa(e){return{type:"frame",...e}}function Xa(e){return{type:"group",...e}}function Ya(e){return{type:"image",...e}}function Ja(e){return{type:"rect",...e}}function Za(e){return{type:"text",...e}}function so(e){return{type:"vector",...e}}function tn(e={}){return{version:4,kind:e.kind??Et,...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??cr({id:nt,children:[]})}}function io(e){let t=new Set;return re(e,r=>{t.add(r.id)}),t}function qt(e,t){let r=io(e),n=0;for(let o of r){if(!o.startsWith(`${t}.`))continue;let a=Number(o.slice(t.length+1));Number.isInteger(a)&&a>n&&(n=a)}return`${t}.${n+1}`}function Je(e){let t=e.trim();if(t.startsWith("#")){let n=t.slice(1);return n===""?void 0:{kind:"frame",id:n}}let r;try{r=new URL(t)}catch{return}if(!(r.protocol!=="https:"&&r.protocol!=="mailto:"))return{kind:"url",url:t}}var mr=["cut","fade","push","slide"],rn=["cut","fade","rise","drop","pop"];var jt=1e4;function lt(e){let t=e.trim();return t==="back"?{kind:"back"}:t==="next"?{kind:"next"}:Je(t)}function dt(e){return e===void 0||e.enter===void 0&&e.duration===void 0&&e.lines.length===0}function hr(e){return e.enter!==void 0||e.exit!==void 0||e.go!==void 0}var vm=["id","enter","exit","duration","delay","step","together","go"];function lo(e,t){return e===t?!0:e===void 0||t===void 0||e.enter!==t.enter||e.duration!==t.duration||e.lines.length!==t.lines.length?!1:e.lines.every((r,n)=>{let o=t.lines[n];return vm.every(a=>r[a]===o[a])})}function xr(e){let t=e.motion;if(!t)return[];let r=e.root.children.map(o=>o.id).filter(o=>o in t),n=Object.keys(t).filter(o=>!r.includes(o)).sort();return[...r,...n]}function fo(e){return new Set(e.root.children.filter(t=>t.type==="frame").map(t=>t.id))}function pr(e){let t=new Map;for(let r of e.root.children)r.type==="frame"&&re(r,n=>{t.set(n.id,r.id)});return t}function Qa(e){let t=new Set;return re(e,r=>{t.add(r.id)}),t}function gr(e,t){let r=e.motion;if(!r)return[];let n=[],o=fo(e),a=pr(e),i=Qa(e.root),l=(d,c)=>{let m=t?.(d,c);return m===void 0?"":`Line ${m}: `};for(let d of xr(e)){let c=r[d];if(c){if(!o.has(d)){n.push({severity:"warning",code:"motion-not-a-page",message:`${l(d)}motion ${d}: ${d} is not a page (a top-level frame), so none of it plays`,nodeId:d});continue}for(let m of c.lines){let x=l(d,m.id);i.has(m.id)?a.get(m.id)!==d&&n.push({severity:"warning",code:"motion-wrong-page",message:`${x}motion ${d}: ${m.id} is not on ${d}, so Play skips it`,nodeId:m.id}):n.push({severity:"warning",code:"unknown-reference",message:`${x}motion ${d}: no node ${m.id}`,nodeId:m.id});let y=m.go===void 0?void 0:lt(m.go);y?.kind==="frame"&&!bm(e,y.id)&&n.push({severity:"warning",code:"unknown-reference",message:`${x}motion ${d}: go=#${y.id} names no frame`,nodeId:m.id})}}}return n}function bm(e,t){let r=!1;return re(e.root,n=>{if(r)return!1;n.id===t&&(r=n.type==="frame")}),r}function hf(e,t){let r=t.motion;if(!r||!e.motion)return r;let n=pr(e),o=pr(t),a=Qa(e.root),i=Qa(t.root),l=x=>a.has(x)&&!i.has(x),d=!1,c={},m=[];for(let[x,y]of Object.entries(r)){if(l(x)){d=!0;continue}let w=[];for(let _ of y.lines){let C=_,F=_.go===void 0?void 0:lt(_.go);if(F?.kind==="frame"&&l(F.id)){let N=wm(_);C=hr(N)?N:void 0,d=!0}if(C&&l(_.id))C=void 0,d=!0;else if(C&&n.get(_.id)===x&&o.get(_.id)!==x){let N=o.get(_.id);N!==void 0&&m.push([N,C]),C=void 0,d=!0}C&&w.push(C)}let P={...y,lines:w};dt(P)||(c[x]=P)}for(let[x,y]of m){let w=c[x]??{lines:[]};c[x]={...w,lines:[...w.lines,y]}}return d?Object.keys(c).length===0?void 0:c:r}function wm(e){let t={...e};return delete t.go,t}function es(e,t){let r={...e};return t===void 0||Object.keys(t).length===0?delete r.motion:r.motion=t,r}function ts(e,t){let r=hf(e,t);if(r===t.motion)return[];let n=new Set([...Object.keys(t.motion??{}),...Object.keys(r??{})]),o=[];for(let a of n){let i=r?.[a];lo(t.motion?.[a],i)||o.push({op:"setMotion",page:a,value:i})}return o}var km={canvas:["type","id","name","w","h","background","children"],frame:["type","id","name","x","y","w","h","background","clip","skip","blend","shadow","hidden","locked","children"],ellipse:["type","id","name","x","y","w","h","rotation","fill","stroke","strokeWidth","opacity","blend","shadow","hidden","locked"],group:["type","id","name","hidden","locked","children"],image:["type","id","name","x","y","w","h","rotation","src","fit","radius","opacity","blend","shadow","hidden","locked"],rect:["type","id","name","x","y","w","h","rotation","fill","stroke","strokeWidth","radius","opacity","blend","shadow","hidden","locked"],text:["type","id","name","x","y","w","h","rotation","content","font","size","weight","lineHeight","letterSpacing","align","valign","italic","fill","opacity","blend","shadow","hidden","locked"],vector:["type","id","name","x","y","w","h","rotation","view","d","fill","stroke","strokeWidth","opacity","rule","cap","join","blend","shadow","hidden","locked"]},Sm=["text","font","size","weight","italic","underline","strike","fill","letterSpacing","link"],_m=["family","fallback","faces"],Cm=["src","weight","style"],Se=" ";function rs(e){let t=["{",`${Se}"version": ${Z(e.version)},`,`${Se}"kind": ${JSON.stringify(e.kind)},`,...e.title===void 0?[]:[`${Se}"title": ${JSON.stringify(e.title)},`],`${Se}"tokens": ${Am(e.tokens,Se)},`];return Object.keys(e.fonts).length>0&&t.push(`${Se}"fonts": ${Mm(e.fonts,Se)},`),e.motion!==void 0&&t.push(`${Se}"motion": ${Em(e,Se)},`),t.push(`${Se}"root": ${xf(e.root,Se)}`,"}"),`${t.join(`
3
+ `)}
4
+ `}function Em(e,t){let r=t+Se,n=xr(e).map(o=>`${r}${JSON.stringify(o)}: ${JSON.stringify(e.motion?.[o])}`).join(`,
5
+ `);return n===""?"{}":`{
6
+ ${n}
7
+ ${t}}`}function Am(e,t){let r=Object.keys(e).sort();if(r.length===0)return"{}";let n=t+Se;return`{
8
+ ${r.map(a=>`${n}${JSON.stringify(a)}: ${uo(e[a])}`).join(`,
9
+ `)}
10
+ ${t}}`}function Mm(e,t){let r=Object.keys(e).sort();if(r.length===0)return"{}";let n=t+Se;return`{
11
+ ${r.map(a=>`${n}${JSON.stringify(a)}: ${$m(e[a],n)}`).join(`,
12
+ `)}
13
+ ${t}}`}function $m(e,t){if(!e)return"{}";let r=t+Se,n=e,o=[];for(let a of _m){let i=n[a];if(i!==void 0){if(a==="faces"){o.push(`${r}"faces": ${Tm(i,r)}`);continue}o.push(`${r}${JSON.stringify(a)}: ${uo(i)}`)}}return`{
14
+ ${o.join(`,
15
+ `)}
16
+ ${t}}`}function Tm(e,t){if(e.length===0)return"[]";let r=t+Se;return`[
17
+ ${e.map(o=>r+gf(o,Cm)).join(`,
18
+ `)}
19
+ ${t}]`}function xf(e,t){let r=t+Se,n=e,o=[];for(let a of km[e.type]){let i=n[a];if(i!==void 0){if(a==="children"){o.push(`${r}"children": ${Om(i,r)}`);continue}if(a==="content"){o.push(`${r}"content": ${Lm(i,r)}`);continue}o.push(`${r}${JSON.stringify(a)}: ${uo(i)}`)}}return`{
20
+ ${o.join(`,
21
+ `)}
22
+ ${t}}`}function Lm(e,t){if(typeof e=="string")return JSON.stringify(e);if(e.length===0)return"[]";let r=t+Se;return`[
23
+ ${e.map(o=>typeof o=="string"?r+JSON.stringify(o):r+gf(o,Sm)).join(`,
24
+ `)}
25
+ ${t}]`}function gf(e,t){let r=[];for(let n of t){let o=e[n];o!==void 0&&r.push(`${JSON.stringify(n)}: ${uo(o)}`)}return`{ ${r.join(", ")} }`}function Om(e,t){if(e.length===0)return"[]";let r=t+Se;return`[
26
+ ${e.map(o=>r+xf(o,r)).join(`,
27
+ `)}
28
+ ${t}]`}function uo(e){return ce(e)?JSON.stringify(`=${e.expr}`):typeof e=="number"?Z(e):JSON.stringify(e)}function Z(e){if(!Number.isFinite(e))return"0";let t=Math.round(e*1e4)/1e4,r=Object.is(t,-0)?0:t;return Math.abs(r)>=1e21?r.toFixed(0):String(r)}var Dm={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function an(e){let t=[],r,n=0,o=0,a=0,i=0,l,d,c=Pm(e),m=()=>(r||(r={anchors:[{x:n,y:o}],closed:!1},t.push(r)),r.anchors[r.anchors.length-1]),x=(_,C)=>{m(),r?.anchors.push({x:_,y:C}),n=_,o=C},y=(_,C,F,N)=>{m().out=_,r?.anchors.push({x:F,y:N,in:C}),n=F,o=N},w="",P=!0;for(;c.more();){let _=c.command();if(_!==void 0)w=_,P=!0;else if(w===""||w.toUpperCase()==="Z")return{contours:co(t),error:`Expected a command at ${c.at()}`};let C=w.toUpperCase(),F=w!==C,N=Dm[C];if(N===void 0)return{contours:co(t),error:`Unknown command ${w}`};if(C==="Z"){r&&(r.closed=!0),r=void 0,n=a,o=i,l=void 0,d=void 0,w="";continue}let J=C==="A"?c.arc():c.numbers(N);if(J===void 0)return{contours:co(t),error:`${w} expects ${N} numbers at ${c.at()}`};let A=F?n:0,D=F?o:0,k=V=>J[V];switch(C){case"M":P&&(r={anchors:[{x:A+k(0),y:D+k(1)}],closed:!1},t.push(r),n=a=A+k(0),o=i=D+k(1),w=F?"l":"L"),l=d=void 0;break;case"L":x(A+k(0),D+k(1)),l=d=void 0;break;case"H":x(A+k(0),o),l=d=void 0;break;case"V":x(n,D+k(0)),l=d=void 0;break;case"C":{let V={x:A+k(2),y:D+k(3)};y({x:A+k(0),y:D+k(1)},V,A+k(4),D+k(5)),l=V,d=void 0;break}case"S":{let V=l?{x:2*n-l.x,y:2*o-l.y}:{x:n,y:o},W={x:A+k(0),y:D+k(1)};y(V,W,A+k(2),D+k(3)),l=W,d=void 0;break}case"Q":case"T":{let V=C==="Q"?{x:A+k(0),y:D+k(1)}:d?{x:2*n-d.x,y:2*o-d.y}:{x:n,y:o},W=C==="Q"?A+k(2):A+k(0),pe=C==="Q"?D+k(3):D+k(1),ne={x:n+2/3*(V.x-n),y:o+2/3*(V.y-o)},we={x:W+2/3*(V.x-W),y:pe+2/3*(V.y-pe)};y(ne,we,W,pe),d=V,l=void 0;break}case"A":{let V=A+k(5),W=D+k(6);for(let[pe,ne,we]of Nm(n,o,k(0),k(1),k(2),k(3)!==0,k(4)!==0,V,W))y(pe,ne,we.x,we.y);(n!==V||o!==W)&&x(V,W),l=d=void 0;break}}P=!1}return{contours:co(t)}}function co(e){return e.map(t=>{let r=[...t.anchors];if(t.closed&&r.length>1){let n=r[0],o=r[r.length-1];Kt(n,o)&&(r.pop(),r[0]={...n,...o.in?{in:o.in}:{}})}return{anchors:r.map(nn),closed:t.closed}})}function ot(e,t,r){return nn({x:e.x,y:e.y,...t?{in:t}:{},...r?{out:r}:{}})}function nn(e){let t={x:e.x,y:e.y};return e.in&&!Kt(e.in,e)&&(t.in=e.in),e.out&&!Kt(e.out,e)&&(t.out=e.out),t}function Kt(e,t,r=1e-6){return Math.abs(e.x-t.x)<r&&Math.abs(e.y-t.y)<r}function Pm(e){let t=0,r=()=>{for(;t<e.length&&/[\s,]/.test(e[t]);)t+=1},n=()=>{r();let a=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(t));if(a)return t+=a[0].length,Number(a[0])},o=()=>{r();let a=e[t];if(!(a!=="0"&&a!=="1"))return t+=1,Number(a)};return{more(){return r(),t<e.length},command(){r();let a=e[t];if(/[a-zA-Z]/.test(a))return t+=1,a},numbers(a){let i=[];for(let l=0;l<a;l+=1){let d=n();if(d===void 0)return;i.push(d)}return i},arc(){let a=this.numbers(3),i=o(),l=o(),d=this.numbers(2);if(!(!a||i===void 0||l===void 0||!d))return[...a,i,l,...d]},at(){return t}}}function Nm(e,t,r,n,o,a,i,l,d){let c=Math.abs(r),m=Math.abs(n);if(c===0||m===0||e===l&&t===d)return[];let x=o*Math.PI/180,y=Math.cos(x),w=Math.sin(x),P=(e-l)/2,_=(t-d)/2,C=y*P+w*_,F=-w*P+y*_,N=C*C/(c*c)+F*F/(m*m);N>1&&(c*=Math.sqrt(N),m*=Math.sqrt(N));let J=c*c*m*m-c*c*F*F-m*m*C*C,A=c*c*F*F+m*m*C*C,D=(a===i?-1:1)*Math.sqrt(Math.max(0,J/A)),k=D*c*F/m,V=-D*m*C/c,W=y*k-w*V+(e+l)/2,pe=w*k+y*V+(t+d)/2,ne=(L,H,K,b)=>{let U=L*K+H*b,B=Math.hypot(L,H)*Math.hypot(K,b),R=Math.acos(Math.min(1,Math.max(-1,U/B)));return L*b-H*K<0?-R:R},we=ne(1,0,(C-k)/c,(F-V)/m),xe=ne((C-k)/c,(F-V)/m,(-C-k)/c,(-F-V)/m);!i&&xe>0&&(xe-=2*Math.PI),i&&xe<0&&(xe+=2*Math.PI);let T=Math.max(1,Math.ceil(Math.abs(xe)/(Math.PI/2)-1e-9)),me=xe/T,oe=4/3*Math.tan(me/4),S=L=>({x:W+c*Math.cos(L)*y-m*Math.sin(L)*w,y:pe+c*Math.cos(L)*w+m*Math.sin(L)*y}),$=L=>({x:-c*Math.sin(L)*y-m*Math.cos(L)*w,y:-c*Math.sin(L)*w+m*Math.cos(L)*y}),M=[];for(let L=0;L<T;L+=1){let H=we+L*me,K=H+me,b=S(H),U=L===T-1?{x:l,y:d}:S(K),B=$(H),R=$(K);M.push([{x:b.x+oe*B.x,y:b.y+oe*B.y},{x:U.x-oe*R.x,y:U.y-oe*R.y},U])}return M}function ft(e){let t=[],r=n=>`${Z(n.x)} ${Z(n.y)}`;for(let n of e){let{anchors:o}=n,a=o[0];if(!a)continue;t.push(`M${r(a)}`);let i=sn(n);for(let l=0;l<i;l+=1){let d=o[l],c=o[(l+1)%o.length],m=n.closed&&l===o.length-1;!d.out&&!c.in?m||t.push(`L${r(c)}`):t.push(`C${r(d.out??d)} ${r(c.in??c)} ${r(c)}`)}n.closed&&t.push("Z")}return t.join(" ")}function sn(e){let t=e.anchors.length;return t<2?0:e.closed?t:t-1}function ln(e,t){let r=e.anchors[t],n=e.anchors[(t+1)%e.anchors.length];return[{x:r.x,y:r.y},r.out??{x:r.x,y:r.y},n.in??{x:n.x,y:n.y},{x:n.x,y:n.y}]}function yf(e,t){let r=e.anchors[t],n=e.anchors[(t+1)%e.anchors.length];return!r.out&&!n.in}function on(e,t){let[r,n,o,a]=e,i=1-t,l=i*i*i,d=3*i*i*t,c=3*i*t*t,m=t*t*t;return{x:l*r.x+d*n.x+c*o.x+m*a.x,y:l*r.y+d*n.y+c*o.y+m*a.y}}function ut(e,t){return e.map(r=>({closed:r.closed,anchors:r.anchors.map(n=>{let o=t(n);return{x:o.x,y:o.y,...n.in?{in:t(n.in)}:{},...n.out?{out:t(n.out)}:{}}})}))}function Gt(e){let t=1/0,r=1/0,n=-1/0,o=-1/0,a=i=>{t=Math.min(t,i.x),r=Math.min(r,i.y),n=Math.max(n,i.x),o=Math.max(o,i.y)};for(let i of e){for(let d of i.anchors)a(d);let l=sn(i);for(let d=0;d<l;d+=1){let c=ln(i,d);for(let m of Rm(c))a(on(c,m))}}if(t!==1/0)return{x:t,y:r,w:n-t,h:o-r}}function Rm(e){let[t,r,n,o]=e,a=[];for(let i of["x","y"]){let l=-t[i]+3*r[i]-3*n[i]+o[i],d=2*(t[i]-2*r[i]+n[i]),c=r[i]-t[i];if(Math.abs(l)<1e-12){Math.abs(d)>1e-12&&a.push(-c/d);continue}let m=d*d-4*l*c;if(m<0)continue;let x=Math.sqrt(m);a.push((-d+x)/(2*l),(-d-x)/(2*l))}return a.filter(i=>i>0&&i<1)}function mo(e){if(e===void 0)return;let t=e.trim().split(/[\s,]+/).map(Number);if(t.length!==4||t.some(i=>!Number.isFinite(i)))return;let[r,n,o,a]=t;return{x:r,y:n,w:o,h:a}}function Wt(e){return[e.x,e.y,e.w,e.h].map(Z).join(" ")}function dn(e,t,r){return mo(e)??{x:0,y:0,w:t,h:r}}function fn(e,t){let r=e.w===0?1:t.w/e.w,n=e.h===0?1:t.h/e.h;return o=>({x:t.x+(o.x-e.x)*r,y:t.y+(o.y-e.y)*n})}function ns(e,t){let r=e.w===0||t.w===0?1:e.w/t.w,n=e.h===0||t.h===0?1:e.h/t.h;return o=>({x:e.x+(o.x-t.x)*r,y:e.y+(o.y-t.y)*n})}function vf(e,t=.5){let[r,n,o,a]=e;if(Kt(r,n)&&Kt(o,a))return[r,a];let l=Math.hypot(n.x-r.x,n.y-r.y)+Math.hypot(o.x-n.x,o.y-n.y)+Math.hypot(a.x-o.x,a.y-o.y),d=Math.min(256,Math.max(4,Math.ceil(Math.sqrt(l/t)))),c=[];for(let m=0;m<=d;m+=1)c.push(on(e,m/d));return c}function os(e,t,r){let n=0,o=0;for(let a of e){let i=Im(a);if(i.length!==0){if(r.reach>0){let l=a.closed?i.length:i.length-1;for(let d=0;d<l;d+=1){let c=i[d],m=i[(d+1)%i.length];if(Fm(t,c,m)<=r.reach)return!0}if(i.length===1&&Math.hypot(t.x-i[0].x,t.y-i[0].y)<=r.reach)return!0}if(r.fill)for(let l=0;l<i.length;l+=1){let d=i[l],c=i[(l+1)%i.length];d.y<=t.y!=c.y<=t.y&&d.x+(t.y-d.y)/(c.y-d.y)*(c.x-d.x)>t.x&&(o+=1,n+=c.y>d.y?1:-1)}}}return r.fill?r.rule==="evenodd"?o%2===1:n!==0:!1}function Im(e){let t=e.anchors[0];if(!t)return[];let r=[{x:t.x,y:t.y}],n=sn(e);for(let o=0;o<n;o+=1)r.push(...vf(ln(e,o)).slice(1));return e.closed&&r.length>1&&r.pop(),r}function Fm(e,t,r){let n=r.x-t.x,o=r.y-t.y,a=n*n+o*o,i=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*o)/a));return Math.hypot(e.x-(t.x+i*n),e.y-(t.y+i*o))}function as(e,t){let r;return e.forEach((n,o)=>{let a=sn(n);for(let i=0;i<a;i+=1){let l=ln(n,i),d=_=>{let C=on(l,_);return Math.hypot(C.x-t.x,C.y-t.y)},c=32,m=0;for(let _=1;_<=c;_+=1)d(_/c)<d(m)&&(m=_/c);let x=Math.max(0,m-1/c),y=Math.min(1,m+1/c);for(let _=0;_<24;_+=1){let C=x+(y-x)/3,F=y-(y-x)/3;d(C)<d(F)?y=F:x=C}let w=(x+y)/2,P=d(w);(!r||P<r.distance)&&(r={contour:o,segment:i,t:w,point:on(l,w),distance:P})}}),r}function ss(e,t,r,n){return e.map((o,a)=>{if(a!==t)return o;let i=[...o.anchors],l=i.length,d=i[r],c=(r+1)%l,m=i[c];if(yf(o,r)){let k={x:d.x+(m.x-d.x)*n,y:d.y+(m.y-d.y)*n};return i.splice(r+1,0,k),{...o,anchors:i}}let[x,y,w,P]=ln(o,r),_=(k,V)=>({x:k.x+(V.x-k.x)*n,y:k.y+(V.y-k.y)*n}),C=_(x,y),F=_(y,w),N=_(w,P),J=_(C,F),A=_(F,N),D=_(J,A);return i[r]=nn({...d,out:C}),i[c]=nn({...m,in:N}),i.splice(r+1,0,nn({x:D.x,y:D.y,in:J,out:A})),{...o,anchors:i}})}var po=.5522847498;function is(e,t,r=0){let n=Math.max(0,Math.min(r,e/2,t/2));if(n===0)return[{closed:!0,anchors:[{x:0,y:0},{x:e,y:0},{x:e,y:t},{x:0,y:t}]}];let o=po*n,a=[{x:n,y:0,in:{x:n-o,y:0}},{x:e-n,y:0,out:{x:e-n+o,y:0}},{x:e,y:n,in:{x:e,y:n-o}},{x:e,y:t-n,out:{x:e,y:t-n+o}},{x:e-n,y:t,in:{x:e-n+o,y:t}},{x:n,y:t,out:{x:n-o,y:t}},{x:0,y:t-n,in:{x:0,y:t-n+o}},{x:0,y:n,out:{x:0,y:n-o}}];return[{closed:!0,anchors:Bm(a)}]}function ls(e,t){let r=e/2,n=t/2,o=po*r,a=po*n;return[{closed:!0,anchors:[{x:r,y:0,in:{x:r-o,y:0},out:{x:r+o,y:0}},{x:e,y:n,in:{x:e,y:n-a},out:{x:e,y:n+a}},{x:r,y:t,in:{x:r+o,y:t},out:{x:r-o,y:t}},{x:0,y:n,in:{x:0,y:n+a},out:{x:0,y:n-a}}]}]}function Bm(e){let t=[];for(let o of e){let a=t[t.length-1];if(a&&Kt(a,o)&&!a.out&&!o.in){t[t.length-1]=ot(a,a.in,o.out);continue}t.push(o)}let r=t[0],n=t[t.length-1];return t.length>1&&r&&n&&Kt(r,n)&&!n.out&&!r.in&&(t[0]=ot(r,n.in,r.out),t.pop()),t}var at=class extends Error{op;constructor(t,r){super(t),this.op=r,this.name="OpError"}};function ve(e,t){let r=e,n=[];for(let o of t){let a=kf(r,o);r=a.document,n.push(a.inverse)}return n.reverse(),{document:r,inverse:n}}function kf(e,t){switch(t.op){case"set":{let r=z(e.root,t.id);if(!r)throw new at(`No node ${t.id}`,t);let n=r[t.prop];return{document:ho(e,fs(e.root,t.id,o=>Hm(o,t.prop,t.value),t)),inverse:{op:"set",id:t.id,prop:t.prop,value:n}}}case"insert":{if(z(e.root,t.node.id))throw new at(`Duplicate id ${t.node.id}`,t);let r=xo(e.root,t.parent,n=>{let o=wf(t.index,0,n.length);return[...n.slice(0,o),t.node,...n.slice(o)]},t);return{document:ho(e,r),inverse:{op:"remove",id:t.node.id}}}case"remove":{let r=bf(e,t.id,t),n=xo(e.root,r.parent.id,o=>o.filter(a=>a.id!==t.id),t);return{document:ho(e,n),inverse:{op:"insert",parent:r.parent.id,index:r.index,node:r.node}}}case"move":{let r=bf(e,t.id,t),n=xo(e.root,r.parent.id,a=>a.filter(i=>i.id!==t.id),t),o=xo(n,t.parent,a=>{let i=wf(t.index,0,a.length);return[...a.slice(0,i),r.node,...a.slice(i)]},t);return{document:ho(e,o),inverse:{op:"move",id:t.id,parent:r.parent.id,index:r.index}}}case"setTitle":{let{title:r,...n}=e;return{document:t.value===void 0?n:{...n,title:t.value},inverse:{op:"setTitle",value:r}}}case"setToken":{let r=Object.prototype.hasOwnProperty.call(e.tokens,t.name)?e.tokens[t.name]:void 0,n={...e.tokens};return t.value===void 0?delete n[t.name]:n[t.name]=t.value,{document:{...e,tokens:n},inverse:{op:"setToken",name:t.name,value:r}}}case"setAsset":{let r=Object.prototype.hasOwnProperty.call(e.assets,t.name)?e.assets[t.name]:void 0,n={...e.assets};return t.value===void 0?delete n[t.name]:n[t.name]=t.value,{document:{...e,assets:n},inverse:{op:"setAsset",name:t.name,value:r}}}case"setFont":{let r=Object.prototype.hasOwnProperty.call(e.fonts,t.name)?e.fonts[t.name]:void 0,n={...e.fonts};return t.family===void 0?delete n[t.name]:n[t.name]=t.family,{document:{...e,fonts:n},inverse:{op:"setFont",name:t.name,family:r}}}case"setMotion":{let r=e.motion&&Object.prototype.hasOwnProperty.call(e.motion,t.page)?e.motion[t.page]:void 0,n={...e.motion};return dt(t.value)?delete n[t.page]:n[t.page]=t.value,{document:es(e,n),inverse:{op:"setMotion",page:t.page,value:r}}}}}function go(e,t){if(!e.motion||!t.some(n=>n.op==="remove"||n.op==="move"))return t;let r=ts(e,ve(e,t).document);return r.length===0?t:[...t,...r]}function ho(e,t){if(t.type!=="canvas")throw new Error("The document root must stay a canvas");return{...e,root:t}}function Hm(e,t,r){let n={...e};return r===void 0?delete n[t]:n[t]=r,n}function fs(e,t,r,n){if(e.id===t)return r(e);if(!ue(e))return e;let o=!1,a=e.children.map(i=>{let l=fs(i,t,r,n);return l!==i&&(o=!0),l});return o?{...e,children:a}:e}function xo(e,t,r,n){let o=z(e,t);if(!o)throw new at(`No node ${t}`,n);if(!ue(o))throw new at(`${t} cannot hold children`,n);return fs(e,t,a=>({...a,children:r(a.children)}),n)}function bf(e,t,r){if(t===e.root.id)throw new at("The document root cannot be removed or moved",r);let n,o=a=>{ue(a)&&a.children.forEach((i,l)=>{i.id===t&&(n={node:i,parent:a,index:l}),o(i)})};if(o(e.root),!n)throw new at(`No node ${t}`,r);return n}function wf(e,t,r){return Math.min(Math.max(e,t),r)}function us(e,t){let r=[];e.title!==t.title&&r.push({op:"setTitle",value:t.title});for(let a of yr(e.tokens,t.tokens)){let i=t.tokens[a];e.tokens[a]!==i&&r.push({op:"setToken",name:a,value:i})}for(let a of yr(e.fonts,t.fonts)){let i=t.fonts[a];Um(e.fonts[a],i)||r.push({op:"setFont",name:a,family:i})}for(let a of yr(e.assets,t.assets)){let i=t.assets[a];e.assets[a]?.hash!==i?.hash&&r.push({op:"setAsset",name:a,value:i})}if(!Vm(e.root.children,t.root.children)){for(let a of e.root.children)r.push({op:"remove",id:a.id});t.root.children.forEach((a,i)=>{r.push({op:"insert",parent:e.root.id,index:i,node:a})})}for(let a of yr(e.motion??{},t.motion??{})){let i=t.motion?.[a];lo(e.motion?.[a],i)||r.push({op:"setMotion",page:a,value:i})}let n=e.root,o=t.root;for(let a of yr(n,o))a==="type"||a==="id"||a==="children"||Sf(n[a],o[a])||r.push({op:"set",id:e.root.id,prop:a,value:o[a]});return r}function yr(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])]}function Sf(e,t){return e===t?!0:ce(e)&&ce(t)&&e.expr===t.expr}function Vm(e,t){return e.length===t.length&&e.every((r,n)=>ds(r,t[n]))}function ds(e,t){if(Sf(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((a,i)=>ds(a,t[i]));let r=e,n=t;return yr(r,n).every(a=>ds(r[a],n[a]))}function Um(e,t){if(e===t)return!0;if(!e||!t||e.family!==t.family||e.fallback!==t.fallback)return!1;let r=e.faces??[],n=t.faces??[];return r.length===n.length&&r.every((o,a)=>{let i=n[a];return o.src===i.src&&o.weight===i.weight&&o.style===i.style})}var un={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"]]},cn=[["font","string"],["size","number"],["weight","number"],["italic","boolean"],["underline","boolean"],["strike","boolean"],["fill","string"],["letterSpacing","number"],["link","string"]],cs=[["weight","number"],["style","fontStyle"]],yo=[["enter","pageEffect"],["duration","number"]],pn=[["enter","nodeEffect"],["exit","nodeEffect"],["duration","number"],["delay","number"],["step","boolean"],["together","boolean"],["go","string"]],Ef=Object.keys(un);function vo(e){return Ef.includes(e)}function ps(e,t){return un[e].find(([r])=>r===t)?.[1]}var Xt=" ";function We(e){if(ce(e))return/^[$@]/.test(e.expr)&&!/\s/.test(e.expr)?e.expr:`(${e.expr})`;if(typeof e=="number")return Z(e);let t=String(e);return zm(t)?JSON.stringify(t):t}function zm(e){return e===""||/[\s"=()]/.test(e)||/^[$@]/.test(e)}function Fe(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 n=br(e);return n===void 0?{error:`Malformed quoted string ${e}`}:_f(n,t,e)}if(Gm(e)){if(!qm(t))return{error:jm(e,t)};let n=Mf(e).trim();return n===""?{error:"Empty expression"}:{value:kt(n)}}return t==="numberValue"&&Af.test(e)?{value:kt(e)}:_f(e,t,e)}var Af=/^-?\d+(?:\.\d+)?%$/;function qm(e){return e==="numberValue"||e==="stringValue"}function jm(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 Km(e,t){let r=/^(-?\d+(?:\.\d+)?)([A-Za-z]+)$/.exec(e);return r?r[2]==="s"&&t==="number"?` \u2014 durations are milliseconds: ${Number(r[1])*1e3}`:/^(?:px|pt|deg|ms)$/.test(r[2])?` \u2014 drop the unit: ${r[1]}`:" \u2014 units are not supported: use a number, a percentage like (100%), or an expression":t==="number"?Af.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 _f(e,t,r){switch(t){case"numberValue":case"number":{let n=Number(e);return Number.isFinite(n)&&e.trim()!==""?{value:n}:{error:`Expected a number, got ${r}${Km(e,t)}`}}case"align":return St.includes(e)?{value:e}:{error:`Expected one of ${St.join(", ")}, got ${r}`};case"valign":return _t.includes(e)?{value:e}:{error:`Expected one of ${_t.join(", ")}, got ${r}`};case"fontStyle":return e==="normal"||e==="italic"?{value:e}:{error:`Expected normal or italic, got ${r}`};case"imageFit":return Ct.includes(e)?{value:e}:{error:`Expected one of ${Ct.join(", ")}, got ${r}`};case"fillRule":return vr(Ht,e,r);case"lineCap":return vr(Vt,e,r);case"lineJoin":return vr(Ut,e,r);case"blendMode":return vr(Bt,e,r);case"pageEffect":return vr(mr,e,r);case"nodeEffect":return vr(rn,e,r);default:return{value:e}}}function vr(e,t,r){return e.includes(t)?{value:t}:{error:`Expected one of ${e.join(", ")}, got ${r}`}}function Gm(e){return/^[$@(]/.test(e)}function br(e){try{let t=JSON.parse(e);return typeof t=="string"?t:void 0}catch{return}}function Mf(e){if(!e.startsWith("("))return e;let t=0;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="(")t+=1;else if(n===")"&&(t-=1,t===0))return r===e.length-1?e.slice(1,-1):e}return e}function $f(e){let t=[],r="",n=0,o=!1;for(let a=0;a<e.length;a+=1){let i=e[a];if(o){r+=i,i==="\\"?(r+=e[a+1]??"",a+=1):i==='"'&&(o=!1);continue}if(i==='"'){o=!0,r+=i;continue}if(i==="("?n+=1:i===")"&&(n=Math.max(0,n-1)),n===0&&/\s/.test(i)){r!==""&&t.push(r),r="";continue}r+=i}return r!==""&&t.push(r),t}function ms(e,t,r){let n=r===void 0?void 0:Be(r);if(n?.value===void 0||!Cf(e[t]??""))return;let o=t;for(;o<e.length&&Cf(e[o]??"");)o+=1;let a=[Mf(n.value),...e.slice(t,o)].join(" ");return{end:o,message:`${n.key}: an expression with spaces needs parentheses \u2014 write ${n.key}=(${a})`}}function Cf(e){return!e.includes("=")&&/^(?:[-+*/]|-?\d+(?:\.\d+)?%?|[$@][\w.]*|[A-Za-z_]\w*(?:\.\w+)+|\(.*|.*\))$/.test(e)}function Be(e){let t=e.indexOf("=");return t===-1?{key:e,value:void 0}:{key:e.slice(0,t),value:e.slice(t+1)}}var Wm=new Set(["exit","delay","step","together","go"]);function hs(e,t){let r=e.words[1];if(r===void 0||r.includes("=")){t(e.number,"invalid-motion","Expected motion <page>, e.g. motion intro enter=fade");return}let n={};for(let o of e.words.slice(2)){let{key:a,value:i}=Be(o),l=yo.find(([c])=>c===a)?.[1];if(l===void 0){let c=Wm.has(a)?` \u2014 ${a} goes on a node's line, under the header`:"";t(e.number,"invalid-motion",`motion ${r} has no "${a}"${c}`,r);continue}let d=Fe(i??"",l);"error"in d?t(e.number,"invalid-motion",`${a}: ${d.error}`,r):a==="duration"&&!Lf(d.value)?t(e.number,"invalid-motion",Of(a,i),r):n[a]=d.value}return{page:r,number:e.number,head:n,lines:[],where:new Map,taken:new Map}}function xs(e,t,r){let n=t.words[0];if(t.indent!==1){r(t.number,"invalid-motion","A motion line sits one level under its page");return}if(n.includes("=")){r(t.number,"invalid-motion",`Expected a node id first, got ${n}`);return}if(n===e.page){r(t.number,"invalid-motion",`${n} is the page: its transition goes on the header (motion ${n} enter=fade)`,n);return}let o={id:n},a=!0;for(let l of t.words.slice(1)){let{key:d,value:c}=Be(l),m=pn.find(([y])=>y===d)?.[1];if(m===void 0){r(t.number,"invalid-motion",`A motion line has no "${d}"`,n),a=!1;continue}let x=Fe(c??"",m);"error"in x?(r(t.number,"invalid-motion",`${d}: ${x.error}`,n),a=!1):(d==="duration"||d==="delay")&&!Lf(x.value)?(r(t.number,"invalid-motion",Of(d,c),n),a=!1):d==="go"&&lt(x.value)===void 0?(r(t.number,"invalid-motion",`go: expected #<page>, back, next, or an https: or mailto: link, got ${c??""}`,n),a=!1):x.value!==!1&&(o[d]=x.value)}if(o.enter!==void 0&&o.exit!==void 0&&(r(t.number,"invalid-motion",`${n} either enters or exits on one line \u2014 write a second line for the other`,n),a=!1),o.step===!0&&o.together===!0&&(r(t.number,"invalid-motion",`${n} waits for a step or starts together with the line above, not both`,n),a=!1),!a)return;let i=Xm(o);if(!hr(i)){r(t.number,"invalid-motion",`${n} says nothing: give it enter=, exit= or go=`,n);return}for(let l of["enter","exit","go"]){if(i[l]===void 0)continue;let d=e.taken.get(`${n} ${l}`);if(d!==void 0){let c=l==="go"?"has a go=":l==="enter"?"enters":"exits";r(t.number,"invalid-motion",`${n} already ${c} on line ${d}`,n);return}}for(let l of["enter","exit","go"])i[l]!==void 0&&e.taken.set(`${n} ${l}`,t.number);e.where.has(n)||e.where.set(n,t.number),e.lines.push(i)}function gs(e){let t={...e.head.enter===void 0?{}:{enter:e.head.enter},...e.head.duration===void 0?{}:{duration:e.head.duration},lines:e.lines};return dt(t)?void 0:t}function Tf(e,t){let r=t.motion;if(r)for(let n of xr(t)){let o=r[n];if(o===void 0||dt(o))continue;e.at(-1)!==""&&e.push("");let a=["motion",n];for(let[i]of yo){let l=o[i];l!==void 0&&a.push(`${i}=${We(l)}`)}e.push(a.join(" "));for(let i of o.lines){let l=[i.id];for(let[d,c]of pn){let m=i[d];if(m!==void 0){if(c==="boolean"){m===!0&&l.push(d);continue}l.push(`${d}=${We(m)}`)}}e.push(Xt+l.join(" "))}}}function Xm(e){let t={id:e.id};for(let[r]of pn)e[r]!==void 0&&(t[r]=e[r]);return t}function Lf(e){return typeof e=="number"&&e>=0&&e<=jt}function Of(e,t){return`${e}: expected 0 to ${jt} milliseconds, got ${t??""}`}var Ym=24;function vs(e,t={}){let r=[`version ${Z(e.version)}`,`kind ${e.kind}`];e.title!==void 0&&r.push(`title ${JSON.stringify(e.title)}`);for(let[n,o]of Object.entries(e.tokens))r.push(`$${n} = ${We(o)}`);r.push("");for(let[n,o]of Object.entries(e.fonts))Qm(r,n,o,t),r.push("");if(Object.keys(e.assets).length>0){for(let[n,o]of Object.entries(e.assets))r.push(Zm(n,o));r.push("")}return Jm(e.root)?e.root.children.forEach((n,o)=>{o>0&&r.push(""),ys(r,n,0)}):ys(r,e.root,0),Tf(r,e),r.join(`
29
+ `)}function Jm(e){return e.id===nt&&e.w===void 0&&e.h===void 0&&e.background===void 0&&e.name===void 0}function Zm(e,t){let r=[`asset ${e} = ${t.type}`,`hash=${t.hash}`,`bytes=${Z(t.bytes)}`];for(let n of["credit","source","license"]){let o=t[n];o!==void 0&&r.push(`${n}=${We(o)}`)}return r.join(" ")}function Qm(e,t,r,n){e.push(`font ${t} = ${We(r.family)}`),r.fallback!==void 0&&e.push(`${Xt}fallback ${We(r.fallback)}`);for(let o of r.faces??[]){let a=n.abbreviateFaces?eh(o.src):o.src,i=[`face ${We(a)}`];for(let[l]of cs){let d=o[l];d!==void 0&&i.push(`${l}=${We(d)}`)}e.push(Xt+i.join(" "))}}function eh(e){return e.startsWith("data:")?`${e.slice(0,Ym)}\u2026 ${Z(Math.round(e.length/1024))} kB`:e}function ys(e,t,r){let n=Xt.repeat(r),o=t,a=[t.type,t.id];for(let[i,l]of un[t.type]){let d=o[i];if(d!==void 0){if(l==="boolean"){d===!0&&a.push(i);continue}a.push(`${i}=${We(d)}`)}}if(e.push(n+a.join(" ")),t.type==="text"&&th(e,t.content,r+1),ue(t))for(let i of le(t))ys(e,i,r+1)}function th(e,t,r){let n=Xt.repeat(r),o=typeof t=="string"?[t]:t;for(let a of o){if(typeof a=="string"){e.push(n+JSON.stringify(a));continue}e.push(n+[JSON.stringify(a.text),...rh(a)].join(" "))}}function rh(e){let t=[];for(let[r,n]of cn){let o=e[r];if(o!==void 0){if(n==="boolean"){o===!0&&t.push(r);continue}t.push(`${r}=${We(o)}`)}}return t}var Yt="--- payload base64 ---",Df="sha256-";function Pf(e){let t=nh(e);return t===-1?{head:e,payload:""}:{head:e.slice(0,t),payload:e.slice(t+Yt.length)}}function bs(e){let{head:t,payload:r}=Pf(e);return{head:t,blocks:Nf(r)}}function ws(e,t){let r=new Map;for(let n of oh(e)){let o=t.get(n);o!==void 0&&r.set(n,o)}return r.size===0?e:`${e.trimEnd()}
30
+
31
+ ${Rf(r)}`}function Nf(e){let t=new Map;for(let r of e.split(`
32
+ `)){let n=r.indexOf(" ");if(n===-1)continue;let o=r.slice(0,n);o.startsWith(Df)&&t.set(o,r.slice(n+1).trim())}return t}function Rf(e){let t=[...e.entries()].sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${r} ${n}`);return`${Yt}
33
+ ${t.join(`
34
+ `)}
35
+ `}async function ks(e){let t=await crypto.subtle.digest("SHA-256",e),r=[...new Uint8Array(t)].map(n=>n.toString(16).padStart(2,"0"));return`${Df}${r.join("")}`}function Ss(e,t){return`data:${e};base64,${t}`}function _s(e){let t=e.toBase64;if(typeof t=="function")return t.call(e);let r="";for(let n=0;n<e.length;n+=32768)r+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(r)}function Cs(e){let t=Uint8Array.fromBase64;if(typeof t=="function")return t(e);let r=atob(e),n=new Uint8Array(r.length);for(let o=0;o<r.length;o+=1)n[o]=r.charCodeAt(o);return n}function nh(e){if(e.startsWith(Yt))return 0;let t=e.indexOf(`
36
+ ${Yt}`);return t===-1?-1:t+1}function oh(e){let t=new Set;for(let r of e.matchAll(/sha256-[0-9a-f]{64}/g))t.add(r[0]);return t}function Es(e){return(t,r,n,o)=>{e.push({severity:"error",code:r,message:`Line ${t}: ${n}`,...o===void 0?{}:{nodeId:o}})}}function As(e){let t=[],r=e.split(`
37
+ `);for(let n=0;n<r.length;n+=1){let o=r[n],a=o.trim();if(a===Yt)break;if(a===""||a.startsWith("```"))continue;let i=o.length-o.trimStart().length;t.push({number:n+1,indent:Math.floor(i/2),text:a,words:$f(a)})}return t}function Ms(e){let t=[],r=[],n=o=>{for(;t.length>0&&t[t.length-1].indent>=o;)sh(t.pop())};return{push(o){let a=o.words[0];if(a.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 m=lh(o,e);return m!==void 0&&c.runs.push(m),!0}if(!vo(a))return!1;n(o.indent);let i=o.words[1];if(i===void 0||i.includes("="))return e(o.number,"missing-id",`A ${a} needs an id`),!0;let l=ah(a,i,o.words.slice(2),o,e),d=t[t.length-1];return d?d.children.push(l.record):r.push(l.record),t.push(l),!0},finish(){return n(0),r}}}function ah(e,t,r,n,o){let a={type:e,id:t},i=[];for(let l=0;l<r.length;l+=1){let{key:d,value:c}=Be(r[l]),m=ps(e,d);if(m===void 0){let y=ms(r,l,r[l-1]);y?(o(n.number,"invalid-value",y.message,t),l=y.end-1):o(n.number,"invalid-value",`${e} has no property "${d}"`,t);continue}let x=Fe(c??"",m);"error"in x?o(n.number,"invalid-value",`${d}: ${x.error}`,t):a[d]=x.value}return no(e)&&(a.children=i),e==="text"&&(a.content=""),{indent:n.indent,type:e,record:a,children:i,runs:[]}}function sh(e){e.type==="text"&&(e.record.content=ih(e.runs))}function ih(e){if(e.length===0)return"";let t=e[0];return e.length===1&&typeof t=="string"?t:[...e]}function lh(e,t){let r=br(e.words[0]);if(r===void 0){t(e.number,"invalid-run","Malformed quoted string");return}if(e.words.length===1)return r;let n={text:r};for(let o of e.words.slice(1)){let{key:a,value:i}=Be(o),l=cn.find(([c])=>c===a);if(!l){t(e.number,"invalid-run",`A run has no mark "${a}"`);continue}let d=Fe(i??"",l[1]);"error"in d?t(e.number,"invalid-run",`${a}: ${d.error}`):n[a]=d.value}return n}function bo(e){let t=[],r=Es(t),n=Et,o,a=!1,i={},l={},d={},c=Ms(r),m,x={},y=new Map,w,P=!1,_=()=>{if(!w)return;let A=w;w=void 0;let D=y.get(A.page);if(D!==void 0){r(A.number,"invalid-motion",`motion ${A.page} is written twice \u2014 put its lines in the block on line ${D}`,A.page);return}y.set(A.page,A.number);for(let[V,W]of A.where)y.set(`${A.page} ${V}`,W);let k=gs(A);k&&(x[A.page]=k)};for(let A of As(e)){let D=A.words[0];if(w&&A.indent>0){xs(w,A,r);continue}if(!(P&&A.indent>0)){if(P=!1,_(),D==="motion"&&A.indent===0){m=void 0,w=hs(A,r),P=w===void 0;continue}if(D==="version"){a=!0,fh(A,t);continue}if(D==="kind"&&A.indent===0){n=uh(A,t);continue}if(D==="title"&&A.indent===0){o=If(A,r);continue}if(D.startsWith("$")){m=void 0,ch(A,i,r);continue}if(D==="asset"&&A.indent===0){m=void 0,ph(A,d,r);continue}if(D==="font"&&A.indent===0){m=hh(A,l,r);continue}if((D==="fallback"||D==="face")&&m){xh(D,A,m,r);continue}m=void 0,!c.push(A)&&r(A.number,"unknown-node-type",`Unknown statement "${D}"`)}}_();let C=dh(c.finish(),t),F=Object.keys(x).length===0?{}:{motion:x},N=(A,D)=>y.get(D===void 0?A:`${A} ${D}`);if(!C){a||t.push({severity:"error",code:"invalid-document",message:"No nodes found"});let A=cr({id:nt,children:[]}),D=tn({kind:n,...o===void 0?{}:{title:o},tokens:i,fonts:l,assets:d,...F,root:A});return t.push(...gr(D,N)),{document:D,problems:t}}let J={version:4,kind:n,...o===void 0?{}:{title:o},tokens:i,fonts:l,assets:d,...F,root:C};return t.push(...gr(J,N)),{document:J,problems:t}}function dh(e,t){let r=e[0];if(r!==void 0){if(e.length===1&&r.type==="canvas")return r;for(let n of e){if(n.type!=="canvas")continue;let o=n.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:nt,children:[...e]}}}function fh(e,t){en.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 uh(e,t){let r=e.words[1];return r!==void 0&&zt.includes(r)?r:(t.push({severity:"error",code:"unknown-kind",message:`Line ${e.number}: unknown kind "${r??"nothing"}" \u2014 this build reads ${zt.join(", ")}`}),Et)}function If(e,t){let r=e.words.slice(1).join(" ").trim();if(r===""){t(e.number,"invalid-value",'title needs a name, e.g. title "Pitch deck"');return}let n=r.startsWith('"')?br(r):r;if(n===void 0){t(e.number,"invalid-value",`Could not read the title ${r}`);return}return n.trim()===""?void 0:n}function ch(e,t,r){let{name:n,value:o}=$s(e.words);if(n===void 0||o===void 0){r(e.number,"invalid-token","Expected $name = value");return}if(!o.startsWith('"')&&/\s/.test(o)){r(e.number,"invalid-token",`$${n}: expected one value, got "${o}". Quote it if the value has spaces; there are no comments.`);return}let a=Fe(o,"stringValue");if("error"in a){r(e.number,"invalid-token",`$${n}: ${a.error}`);return}if(typeof a.value!="string"){r(e.number,"invalid-token",`$${n} may not be an expression`);return}t[n]=Ff(a.value,o)}function Ff(e,t){let r=Number(e);return t.startsWith('"')||!Number.isFinite(r)||e.trim()===""?e:r}function $s(e){let t=e[0],r=a=>a.startsWith("$")?a.slice(1):a;if(e[1]==="=")return{name:r(t),value:e.slice(2).join(" ")||void 0};let{key:n,value:o}=Be(t);return o!==void 0?{name:r(n),value:o}:{name:r(t)}}function ph(e,t,r){let n=e.words.slice(1),o=n[0],a=n[1]==="=",i=o===void 0?void 0:Be(o),l=i?.key,d=a?n[2]:i?.value,c=n.slice(a?3:1);if(l===void 0||l===""||d===void 0){r(e.number,"invalid-asset","Expected asset <name> = <type> hash=\u2026 bytes=\u2026");return}let m={};for(let w of c){let{key:P,value:_}=Be(w);if(_===void 0){r(e.number,"invalid-asset",`Asset "${l}" has a stray word "${w}"`);continue}m[P]=mh(_)}let x=m.hash,y=Number(m.bytes);if(x===void 0||!Number.isFinite(y)){r(e.number,"invalid-asset",`Asset "${l}" needs a hash and a bytes count`);return}t[l]={type:d,hash:x,bytes:y,...m.credit===void 0?{}:{credit:m.credit},...m.source===void 0?{}:{source:m.source},...m.license===void 0?{}:{license:m.license}}}function mh(e){return e.startsWith('"')?br(e)??e:e}function hh(e,t,r){let{name:n,value:o}=$s(e.words.slice(1));if(n===void 0||o===void 0){r(e.number,"invalid-font","Expected font <name> = <family>");return}let a=Fe(o,"string"),i={family:"error"in a?o:a.value};return t[n]=i,{family:i,faces:[]}}function xh(e,t,r,n){if(e==="fallback"){let l=Fe(t.words.slice(1).join(" "),"string");"error"in l?n(t.number,"invalid-font",`fallback: ${l.error}`):r.family.fallback=l.value;return}let o=t.words[1];if(o===void 0){n(t.number,"invalid-font-face","A face needs a src");return}let a=Fe(o,"string"),i={src:"error"in a?o:a.value};for(let l of t.words.slice(2)){let{key:d,value:c}=Be(l);if(d!=="weight"&&d!=="style"){n(t.number,"invalid-font-face",`A face has no property "${d}"`);continue}let m=Fe(c??"",d==="weight"?"number":"fontStyle");"error"in m?n(t.number,"invalid-font-face",`${d}: ${m.error}`):i[d]=m.value}r.faces.push(i),r.family.faces=r.faces}function Os(e){let t=[],r=He(e);if(!r)return t.push({severity:"error",code:"invalid-document",message:"Expected an object"}),{document:tn(),problems:t};en.includes(r.version)||t.push({severity:"warning",code:"version-mismatch",message:`Expected version ${4} or older, got ${JSON.stringify(r.version)}`});let n=Hf(r.root,t),o=gh(r.motion,t),a={version:4,kind:vh(r.kind,t),...typeof r.title=="string"&&r.title.trim()!==""?{title:r.title}:{},tokens:bh(r.tokens,t),fonts:kh(r.fonts,t),assets:wh(r.assets,t),...o===void 0?{}:{motion:o},root:n??cr({id:nt,children:[]})};return Ph(a.root,t),t.push(...gr(a)),{document:a,problems:t}}function gh(e,t){if(e===void 0)return;let r=He(e),n=a=>{t.push({severity:"error",code:"invalid-motion",message:a})};if(!r){n("`motion` must be an object");return}let o={};for(let[a,i]of Object.entries(r)){let l=He(i);if(!l||!Array.isArray(l.lines)){n(`motion ${a} must be an object with a lines array`);continue}let d=l.enter,c=l.duration;if(d!==void 0&&!mr.includes(d)){n(`motion ${a}: enter must be one of ${mr.join(", ")}`);continue}if(c!==void 0&&!Ts(c)){n(`motion ${a}: duration must be 0 to ${jt} milliseconds`);continue}let m=l.lines.flatMap(y=>{let w=yh(y);return w===void 0&&n(`motion ${a}: a line that is not one: ${JSON.stringify(y)}`),w===void 0?[]:[w]}),x={...d===void 0?{}:{enter:d},...c===void 0?{}:{duration:c},lines:m};dt(x)||(o[a]=x)}return Object.keys(o).length===0?void 0:o}function yh(e){let t=He(e);if(!t||typeof t.id!="string")return;let{enter:r,exit:n,duration:o,delay:a,step:i,together:l,go:d}=t,c=x=>x===void 0||rn.includes(x);if(!c(r)||!c(n)||r!==void 0&&n!==void 0||o!==void 0&&!Ts(o)||a!==void 0&&!Ts(a)||i!==void 0&&i!==!0||l!==void 0&&l!==!0||i===!0&&l===!0||d!==void 0&&(typeof d!="string"||lt(d)===void 0))return;let m={id:t.id,...r===void 0?{}:{enter:r},...n===void 0?{}:{exit:n},...o===void 0?{}:{duration:o},...a===void 0?{}:{delay:a},...i===void 0?{}:{step:i},...l===void 0?{}:{together:l},...d===void 0?{}:{go:d}};return hr(m)?m:void 0}function Ts(e){return typeof e=="number"&&e>=0&&e<=jt}function vh(e,t){return e==null?Et:typeof e=="string"&&zt.includes(e)?e:(t.push({severity:"error",code:"unknown-kind",message:`Unknown kind ${JSON.stringify(e)} \u2014 this build reads ${zt.join(", ")}`}),Et)}function bh(e,t){let r={};if(e===void 0)return r;let n=He(e);if(!n)return t.push({severity:"error",code:"invalid-tokens",message:"`tokens` must be an object"}),r;for(let[o,a]of Object.entries(n))typeof a=="number"||typeof a=="string"?r[o]=a:t.push({severity:"error",code:"invalid-token",message:`Token $${o} must be a number or string`});return r}function wh(e,t){let r={};if(e===void 0)return r;let n=He(e);if(!n)return t.push({severity:"error",code:"invalid-assets",message:"`assets` must be an object"}),r;for(let[o,a]of Object.entries(n)){let i=He(a);if(!i||typeof i.type!="string"||typeof i.hash!="string"||typeof i.bytes!="number"){t.push({severity:"error",code:"invalid-asset",message:`Asset "${o}" must have a "type", a "hash" and a "bytes" count`});continue}r[o]={type:i.type,hash:i.hash,bytes:i.bytes,...Xe(i.credit,"credit"),...Xe(i.source,"source"),...Xe(i.license,"license")}}return r}function kh(e,t){let r={};if(e===void 0)return r;let n=He(e);if(!n)return t.push({severity:"error",code:"invalid-fonts",message:"`fonts` must be an object"}),r;for(let[o,a]of Object.entries(n)){let i=He(a);if(!i||typeof i.family!="string"){t.push({severity:"error",code:"invalid-font",message:`Font "${o}" must be an object with a "family"`});continue}r[o]={family:i.family,...typeof i.fallback=="string"?{fallback:i.fallback}:{},...Sh(i.faces,o,t)}}return r}function Sh(e,t,r){if(e===void 0)return{};if(!Array.isArray(e))return r.push({severity:"error",code:"invalid-font",message:`Font "${t}" has a "faces" that is not an array`}),{};let n=[];for(let o of e){let a=He(o);if(!a||typeof a.src!="string"){r.push({severity:"error",code:"invalid-font-face",message:`A face of font "${t}" is missing its "src"`});continue}let i=a.style;n.push({src:a.src,...typeof a.weight=="number"?{weight:a.weight}:{},...i==="italic"||i==="normal"?{style:i}:{}})}return n.length>0?{faces:n}:{}}function _h(e,t){let r=He(e);if(!r){t.push({severity:"error",code:"invalid-node",message:"Expected a node object"});return}switch(r.type){case"canvas":return Hf(e,t);case"ellipse":return $h(r,t);case"frame":return Ch(r,t);case"group":return Eh(r,t);case"image":return Ah(r,t);case"rect":return Mh(r,t);case"text":return Lh(r,t);case"vector":return Th(r,t);default:t.push({severity:"error",code:"unknown-node-type",message:`Unknown node type ${JSON.stringify(r.type)}`,...typeof r.id=="string"?{nodeId:r.id}:{}});return}}function Hf(e,t){let r=He(e);if(!r){t.push({severity:"error",code:"invalid-node",message:"`root` must be a canvas node"});return}let n=At(r,nt,t);return{type:"canvas",id:n,...Xe(r.name,"name"),...Bf(r,"w",1280,n,t),...Bf(r,"h",720,n,t),...Ye(r.background,n,"background",t),children:Ds(r.children,n,t)}}function Bf(e,t,r,n,o){return e[t]===void 0?{}:{[t]:he(e[t],n,t,r,o)}}function Ch(e,t){let r=At(e,"frame",t);return{type:"frame",id:r,...Xe(e.name,"name"),x:he(e.x,r,"x",0,t),y:he(e.y,r,"y",0,t),w:he(e.w,r,"w",0,t),h:he(e.h,r,"h",0,t),...Ye(e.background,r,"background",t),...Ls(e.clip,"clip"),...Ls(e.skip,"skip"),...Sr(e,r,t),...Jt(e),children:Ds(e.children,r,t)}}function Eh(e,t){let r=At(e,"group",t);return{type:"group",id:r,...Xe(e.name,"name"),...Jt(e),children:Ds(e.children,r,t)}}function Ds(e,t,r){let n=[];if(Array.isArray(e))for(let o of e){let a=_h(o,r);a&&n.push(a)}else e!==void 0&&r.push({severity:"error",code:"invalid-children",message:"`children` must be an array",nodeId:t});return n}function Ah(e,t){let r=At(e,"image",t),n=e.fit,o=Ye(e.src,r,"src",t);return{type:"image",id:r,...Xe(e.name,"name"),x:he(e.x,r,"x",0,t),y:he(e.y,r,"y",0,t),w:he(e.w,r,"w",100,t),h:he(e.h,r,"h",100,t),..._e(e.rotation,r,"rotation",t),src:o.src??"",...Ct.includes(n)?{fit:n}:{},..._e(e.radius,r,"radius",t),..._e(e.opacity,r,"opacity",t),...Sr(e,r,t),...Jt(e)}}function Mh(e,t){let r=At(e,"rect",t);return{type:"rect",id:r,...Xe(e.name,"name"),x:he(e.x,r,"x",0,t),y:he(e.y,r,"y",0,t),w:he(e.w,r,"w",100,t),h:he(e.h,r,"h",100,t),..._e(e.rotation,r,"rotation",t),...Ye(e.fill,r,"fill",t),...Ye(e.stroke,r,"stroke",t),..._e(e.strokeWidth,r,"strokeWidth",t),..._e(e.radius,r,"radius",t),..._e(e.opacity,r,"opacity",t),...Sr(e,r,t),...Jt(e)}}function $h(e,t){let r=At(e,"ellipse",t);return{type:"ellipse",id:r,...Xe(e.name,"name"),x:he(e.x,r,"x",0,t),y:he(e.y,r,"y",0,t),w:he(e.w,r,"w",100,t),h:he(e.h,r,"h",100,t),..._e(e.rotation,r,"rotation",t),...Ye(e.fill,r,"fill",t),...Ye(e.stroke,r,"stroke",t),..._e(e.strokeWidth,r,"strokeWidth",t),..._e(e.opacity,r,"opacity",t),...Sr(e,r,t),...Jt(e)}}function Th(e,t){let r=At(e,"vector",t);return{type:"vector",id:r,...Xe(e.name,"name"),x:he(e.x,r,"x",0,t),y:he(e.y,r,"y",0,t),w:he(e.w,r,"w",100,t),h:he(e.h,r,"h",100,t),..._e(e.rotation,r,"rotation",t),...Xe(e.view,"view"),d:typeof e.d=="string"?e.d:"",...Ye(e.fill,r,"fill",t),...Ye(e.stroke,r,"stroke",t),..._e(e.strokeWidth,r,"strokeWidth",t),..._e(e.opacity,r,"opacity",t),...kr(e.rule,Ht,r,"rule",t),...kr(e.cap,Vt,r,"cap",t),...kr(e.join,Ut,r,"join",t),...Sr(e,r,t),...Jt(e)}}function Lh(e,t){let r=At(e,"text",t);return{type:"text",id:r,...Xe(e.name,"name"),x:he(e.x,r,"x",0,t),y:he(e.y,r,"y",0,t),w:he(e.w,r,"w",200,t),h:he(e.h,r,"h",40,t),..._e(e.rotation,r,"rotation",t),content:Oh(e.content,r,t),...Ye(e.font,r,"font",t),..._e(e.size,r,"size",t),..._e(e.weight,r,"weight",t),..._e(e.lineHeight,r,"lineHeight",t),..._e(e.letterSpacing,r,"letterSpacing",t),...kr(e.align,St,r,"align",t),...kr(e.valign,_t,r,"valign",t),...Ls(e.italic,"italic"),...Ye(e.fill,r,"fill",t),..._e(e.opacity,r,"opacity",t),...Sr(e,r,t),...Jt(e)}}function Oh(e,t,r){if(e===void 0)return"";if(typeof e=="string")return e;if(!Array.isArray(e))return r.push({severity:"error",code:"invalid-content",message:`Expected a string or an array of runs for content, got ${JSON.stringify(e)}`,nodeId:t,prop:"content"}),"";let n=[];for(let o of e){if(typeof o=="string"){n.push(o);continue}let a=He(o);if(!a||typeof a.text!="string"){r.push({severity:"error",code:"invalid-run",message:'A text run must be a string or an object with a "text"',nodeId:t,prop:"content"});continue}n.push({text:a.text,...ct(a,"font","string"),...ct(a,"size","number"),...ct(a,"weight","number"),...ct(a,"italic","boolean"),...ct(a,"underline","boolean"),...ct(a,"strike","boolean"),...ct(a,"fill","string"),...ct(a,"letterSpacing","number"),...ct(a,"link","string")})}return n}function ct(e,t,r){let n=e[t];return typeof n!==r?{}:r==="number"&&!Number.isFinite(n)?{}:{[t]:n}}function Sr(e,t,r){return{...kr(e.blend,Bt,t,"blend",r),...Ye(e.shadow,t,"shadow",r)}}function Jt(e){return{...e.hidden===!0?{hidden:!0}:{},...e.locked===!0?{locked:!0}:{}}}function Ls(e,t){return typeof e=="boolean"?{[t]:e}:{}}function kr(e,t,r,n,o){return e===void 0?{}:typeof e=="string"&&t.includes(e)?{[n]:e}:(o.push({severity:"error",code:"invalid-value",message:`Expected one of ${t.join(", ")} for ${n}, got ${JSON.stringify(e)}`,nodeId:r,prop:n}),{})}function At(e,t,r){let n=e.id;return typeof n=="string"&&n.length>0?n:(r.push({severity:"error",code:"missing-id",message:`Node is missing an id; using "${t}"`}),t)}function he(e,t,r,n,o){let a=Dh(e);return a!==void 0?a:(o.push({severity:"error",code:"invalid-value",message:`Expected a number or expression for ${r}, got ${JSON.stringify(e)}`,nodeId:t,prop:r}),n)}function Dh(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.startsWith("="))return kt(e.slice(1))}function _e(e,t,r,n){return e===void 0?{}:{[r]:he(e,t,r,0,n)}}function Ye(e,t,r,n){return e===void 0?{}:typeof e=="string"?{[r]:e.startsWith("=")?kt(e.slice(1)):e}:(n.push({severity:"error",code:"invalid-value",message:`Expected a string for ${r}, got ${JSON.stringify(e)}`,nodeId:t,prop:r}),{})}function Xe(e,t){return typeof e=="string"?{[t]:e}:{}}function Ph(e,t){let r=new Set,n=o=>{r.has(o.id)&&t.push({severity:"error",code:"duplicate-id",message:`Duplicate id ${o.id}. Addresses must be unique or patches land on the wrong node.`,nodeId:o.id}),r.add(o.id),ue(o)&&o.children.forEach(n)};n(e)}function He(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function wo(e){return/^\s*(linear|radial|conic|repeating-[a-z]+)-gradient\s*\(/i.test(e)}function mn(e){let t=e.trim(),r=/^([a-z-]+)-gradient\s*\(([\s\S]*)\)$/i.exec(t);if(!r)return wo(t)?{error:'A gradient needs its closing ")"'}:{kind:"solid",colour:t};let n=r[1].toLowerCase(),o=Nh(r[2]).map(a=>a.trim());if(o.some(a=>a===""))return{error:"A gradient has an empty argument"};if(n==="linear"){let a=Ih(o[0]),i=Uf(a===void 0?o:o.slice(1));return"error"in i?i:{kind:"linear",angle:a??180,stops:i.stops}}if(n==="radial"){let a=Bh(o[0]);if(a&&"error"in a)return a;let i=Uf(a?o.slice(1):o);return"error"in i?i:{kind:"radial",shape:a?.shape??"ellipse",cx:a?.cx??.5,cy:a?.cy??.5,stops:i.stops}}return{error:`${n}-gradient is not supported; use linear-gradient or radial-gradient`}}function Ps(e){let t=e.map(n=>n.at);t[0]===void 0&&(t[0]=0),t[t.length-1]===void 0&&(t[t.length-1]=1);let r=0;for(let n=0;n<t.length;n+=1){let o=t[n];o!==void 0&&(r=Math.max(r,o),t[n]=r)}for(let n=1;n<t.length;n+=1){if(t[n]!==void 0)continue;let o=n-1,a=n;for(;t[a]===void 0;)a+=1;let i=t[o],l=t[a];for(let d=n;d<a;d+=1)t[d]=i+(l-i)*(d-o)/(a-o);n=a}return e.map((n,o)=>({colour:n.colour,at:t[o]}))}function Nh(e){let t=[],r=0,n=0;for(let o=0;o<e.length;o+=1){let a=e[o];a==="("?r+=1:a===")"?r=Math.max(0,r-1):a===","&&r===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}var Rh={top:[0,-1],bottom:[0,1],left:[-1,0],right:[1,0]};function Ih(e){let t=/^(-?\d*\.?\d+)(deg|turn|rad)$/i.exec(e);if(t){let a=Number(t[1]),i=t[2].toLowerCase();return i==="turn"?a*360:i==="rad"?a*180/Math.PI:a}let r=/^to\s+([a-z]+)(?:\s+([a-z]+))?$/i.exec(e);if(!r)return;let n=0,o=0;for(let a of[r[1],r[2]]){if(a===void 0)continue;let i=Rh[a.toLowerCase()];if(!i)return;n+=i[0],o+=i[1]}return(Math.atan2(n,-o)*180/Math.PI+360)%360}var Fh={left:0,top:0,center:.5,right:1,bottom:1};function Bh(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 r=t[1]?.toLowerCase();if(t[2]===void 0)return r?{shape:r}:void 0;let n=Vf(t[2]),o=t[3]===void 0?.5:Vf(t[3]);return n===void 0||o===void 0?{error:`A radial centre is two percentages or keywords, not "${e}"`}:{...r?{shape:r}:{},cx:n,cy:o}}function Vf(e){let t=Fh[e.toLowerCase()];if(t!==void 0)return t;let r=/^(-?\d*\.?\d+)%$/.exec(e);return r?Number(r[1])/100:void 0}function Uf(e){if(e.length<2)return{error:"A gradient needs at least two colours"};let t=[];for(let r of e){let n=/^([\s\S]*?\S)\s+(-?\d*\.?\d+)%$/.exec(r);if(n&&Hh(n[1]))t.push({colour:n[1],at:Number(n[2])/100});else{if(/\s/.test(r.replace(/\([^)]*\)/g,"")))return{error:`"${r}" is not a colour with an optional percentage`};t.push({colour:r})}}return{stops:t}}function Hh(e){let t=0;for(let r of e)if(r==="("&&(t+=1),r===")"&&(t-=1),t<0)return!1;return t===0}function ko(e){let t=mn(e);return"error"in t?[]:t.kind==="solid"?[t.colour]:t.stops.map(r=>r.colour)}function _r(e){let t=e.trim();if(t===""||t==="none")return{shadows:[]};let r=[];for(let n of Vh(t)){let o=Uh(n.trim());if(o.includes("inset"))return{error:"Inner shadows (inset) are not supported yet"};let a=[],i=[];for(let x of o){let y=/^(-?\d*\.?\d+)(px)?$/.exec(x);y&&i.length===0?a.push(Number(y[1])):i.push(x)}if(a.length<2||a.length>4)return{error:`"${n.trim()}" needs x, y, then optional blur and spread`};if(i.length!==1)return{error:`"${n.trim()}" needs one colour after its numbers`};let[l=0,d=0,c=0,m=0]=a;if(c<0)return{error:"A shadow cannot have a negative blur"};r.push({x:l,y:d,blur:c,spread:m,colour:i[0]})}return{shadows:r}}function Vh(e){let t=[],r=0,n=0;for(let o=0;o<e.length;o+=1){let a=e[o];a==="("?r+=1:a===")"?r=Math.max(0,r-1):a===","&&r===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function Uh(e){let t=[],r=0,n="";for(let o of e){if(o==="("&&(r+=1),o===")"&&(r=Math.max(0,r-1)),/\s/.test(o)&&r===0){n!==""&&t.push(n),n="";continue}n+=o}return n!==""&&t.push(n),t}var Ns=["rect","ellipse","vector","image","text"];function Ve(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function Pe(e,t,r){if(r===0)return e;let n=r*Math.PI/180,o=Math.cos(n),a=Math.sin(n),i=e.x-t.x,l=e.y-t.y;return{x:t.x+i*o-l*a,y:t.y+i*a+l*o}}function hn(e,t,r=Ve(e)){if(t%360===0)return e;let n=[{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(d=>Pe(d,r,t)),o=n.map(d=>d.x),a=n.map(d=>d.y),i=Math.min(...o),l=Math.min(...a);return{x:i,y:l,w:Math.max(...o)-i,h:Math.max(...a)-l}}function xn(e){let t=(e%360+360)%360,r=Math.round(t*100)/100;return r===360?0:r}var Rs=["x","y","w","h","left","right","top","bottom","cx","cy"];function gn(e){return Rs.includes(e)}var Is=["parent","prev","next","self","root"];function Fs(e){return Is.includes(e)}var $e=class extends Error{position;constructor(t,r){super(t),this.position=r,this.name="ExprSyntaxError"}},qf=/[A-Za-z_]/,Bs=/[A-Za-z0-9_]/;function Hs(e){let t=[],r=0,n=()=>{if(!qf.test(e[r]??""))throw new $e(`Expected a name at position ${r}`,r);let i=r;for(;r<e.length&&Bs.test(e[r]??"");)r++;return e.slice(i,r)},o=()=>{if(!Bs.test(e[r]??""))throw new $e(`Expected a name at position ${r}`,r);let i=r;for(;r<e.length&&Bs.test(e[r]??"");)r++;return e.slice(i,r)},a=()=>{let i=[n()];for(;e[r]===".";)r++,i.push(o());return i};for(;r<e.length;){let i=e[r]??"";if(/\s/.test(i)){r++;continue}if(/[0-9]/.test(i)){let l=r;for(;r<e.length&&/[0-9]/.test(e[r]??"");)r++;if(e[r]==="."&&/[0-9]/.test(e[r+1]??""))for(r++;r<e.length&&/[0-9]/.test(e[r]??"");)r++;let d=e.slice(l,r),c=Number(d);if(!Number.isFinite(c))throw new $e(`Bad number "${d}"`,l);e[r]==="%"?(r++,t.push({type:"percent",value:c})):t.push({type:"number",value:c});continue}if(i==="$"){r++,t.push({type:"token",name:n()});continue}if(i==="@"){r++,t.push({type:"ref",path:a()});continue}if(qf.test(i)){t.push({type:"word",path:a()});continue}if("+-*/()".includes(i)){r++,t.push({type:"op",value:i});continue}throw new $e(`Unexpected character "${i}" at position ${r}`,r)}return t.push({type:"eof"}),t}var Kh={"+":1,"-":1,"*":2,"/":2};function Ze(e){try{let t=Hs(e),r=new Vs(t),n=r.parseBinary(0);return r.expectEof(),{ok:!0,ast:n}}catch(t){if(t instanceof $e)return{ok:!1,message:t.message};throw t}}var Vs=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 $e("Unexpected trailing input",this.index)}parseBinary(t){let r=this.parseUnary();for(;;){let n=this.peek();if(n.type!=="op"||!Gh(n.value))break;let o=Kh[n.value];if(o<t)break;this.next();let a=this.parseBinary(o+1);r={kind:"binary",op:n.value,left:r,right:a}}return r}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 $e(`@${t.path.join(".")} needs an edge, for example @${t.path.join(".")}.right`,this.index);return{kind:"nodeRef",path:t.path}}case"word":{let[r,n,...o]=t.path;if(r===void 0||!Fs(r))throw new $e(`Unknown name "${t.path.join(".")}". Use $token for a token or @id.edge for a node.`,this.index);if(n===void 0||!gn(n)||o.length>0)throw new $e(`${r} needs an edge, for example ${r}.w`,this.index);return{kind:"relRef",word:r,edge:n}}case"op":{if(t.value==="("){let r=this.parseBinary(0),n=this.next();if(n.type!=="op"||n.value!==")")throw new $e("Missing closing parenthesis",this.index);return r}throw new $e(`Unexpected "${t.value}"`,this.index)}case"eof":throw new $e("Unexpected end of expression",this.index)}}};function Gh(e){return e==="+"||e==="-"||e==="*"||e==="/"}var jf={"+":1,"-":1,"*":2,"/":2},Kf=3,Wh=4;function Xh(e){return e.kind==="binary"?jf[e.op]??1:e.kind==="unary"?Kf:Wh}function yn(e){return So(e,0)}function So(e,t){let r=Yh(e);return Xh(e)<t?`(${r})`:r}function Yh(e){switch(e.kind){case"number":return Z(e.value);case"percent":return`${Z(e.value)}%`;case"token":return`$${e.name}`;case"nodeRef":return`@${e.path.join(".")}`;case"relRef":return`${e.word}.${e.edge}`;case"unary":return`${e.op}${So(e.operand,Kf)}`;case"binary":{let t=jf[e.op]??1;return`${So(e.left,t)} ${e.op} ${So(e.right,t+1)}`}}}function Us(e){return e.slice(0,-1).join(".")}function Mt(e,t){switch(e.kind){case"nodeRef":{let r=e.path[e.path.length-1],n=t(Us(e.path));return r===void 0||n===void 0?e:{kind:"nodeRef",path:[...n.split("."),r]}}case"unary":return{...e,operand:Mt(e.operand,t)};case"binary":return{...e,left:Mt(e.left,t),right:Mt(e.right,t)};default:return e}}function Zt(e){let t=new Set,r=new Set,n=o=>{switch(o.kind){case"nodeRef":t.add(Us(o.path));return;case"token":r.add(o.name);return;case"unary":n(o.operand);return;case"binary":n(o.left),n(o.right);return;default:return}};return n(e),{nodes:[...t],tokens:[...r]}}function Oe(e,t){return`${e} ${t}`}function zs(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 _o(e,t,r,n,o){switch(e){case"x":case"left":return t;case"y":case"top":return r;case"w":return n;case"h":return o;case"right":return t+n;case"bottom":return r+o;case"cx":return t+n/2;case"cy":return r+o/2}}function qs(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 js(e,t,r){let n=x=>{let y=[];for(let w=r.parentOf.get(x);w!==void 0;w=r.parentOf.get(w))y.push(w);return y},o=n(e),a=n(t),i=new Set(a),l=o.find(x=>i.has(x)),d=x=>l===void 0?x:x.slice(0,x.indexOf(l)),c=new Map([[e,1]]),m=(x,y)=>{let w=(c.get(x)??0)+y;w===0?c.delete(x):c.set(x,w)};for(let x of d(o))m(x,1);for(let x of d(a))m(x,-1);return c}function Ks(e){switch(e){case"right":case"bottom":return 1;case"cx":case"cy":return .5;default:return 0}}function Co(e){if(e==="x"||e==="w")return"w";if(e==="y"||e==="h")return"h"}function vn(e){let t=new Map,r=new Map,n=new Map,o=new Map,a=[];re(e.root,(m,x)=>{t.has(m.id)||t.set(m.id,m),a.push(m),x&&r.set(m.id,x.id),ue(m)&&m.children.forEach((y,w)=>{let P=m.children[w-1],_=m.children[w+1];P&&n.set(y.id,P.id),_&&o.set(y.id,_.id)})});let i=new Map;for(let m of a){let x=r.get(m.id);for(;x!==void 0;){let y=t.get(x);if(!y||!ke(y))break;x=r.get(x)}x!==void 0&&i.set(m.id,x)}let l=new Map,d=new Map,c=m=>{if(ue(m)){if(!ke(m)){let x=Gf(m);x.forEach((y,w)=>{let P=x[w-1],_=x[w+1];P&&l.set(y.id,P.id),_&&d.set(y.id,_.id)})}for(let x of m.children)c(x)}};return c(e.root),{rootId:e.root.id,byId:t,parentOf:r,prevOf:n,nextOf:o,layoutParentOf:i,layoutPrevOf:l,layoutNextOf:d,order:a}}function Gf(e){let t=[];for(let r of e.children)ue(r)&&ke(r)?t.push(...Gf(r)):t.push(r);return t}function Eo(e,t,r){if(e.kind==="relRef"){let a=Jh(e.word,t,r);return a===void 0?{ok:!1,message:`${t} has no ${e.word}`}:{ok:!0,nodeId:a,edge:e.edge}}let n=e.path[e.path.length-1]??"",o=e.path.slice(0,-1).join(".");return gn(n)?r.byId.has(o)?{ok:!0,nodeId:o,edge:n}:{ok:!1,message:`No node @${o}`}:{ok:!1,message:`"${n}" is not an edge of @${o}`}}function Jh(e,t,r){switch(e){case"self":return t;case"root":return r.rootId;case"parent":return r.layoutParentOf.get(t);case"prev":return r.layoutPrevOf.get(t);case"next":return r.layoutNextOf.get(t)}}function Ee(e){let t=[],r=vn(e),n=Wf(r),o=new Set;Xf(n,t),Yf(n,e,r,o,t);let a=Zh(n);Qh(n,a,t);let i=ex(n,a,e,r,o,t);return{nodes:rx(e.root,i,n,t),problems:t}}function Cr(e){let t=vn(e),r=Wf(t),n=[];Xf(r,n),Yf(r,e,t,new Set,n);let o=new Map;for(let a of r.values())for(let i of a.deps){let l=o.get(i),d={nodeId:a.nodeId,prop:a.prop};l?l.push(d):o.set(i,[d])}return o}function Wf(e){let t=new Map;for(let r of e.order){let n=r;for(let o of tt(r)){let a=n[o];a!==void 0&&t.set(Oe(r.id,o),{nodeId:r.id,prop:o,value:a,deps:[]})}}return t}function Xf(e,t){for(let r of e.values()){if(!ce(r.value))continue;let n=Ze(r.value.expr);if(n.ok){r.ast=n.ast;continue}t.push({severity:"error",code:"expression-syntax",message:n.message,nodeId:r.nodeId,prop:r.prop})}}function Yf(e,t,r,n,o){for(let a of e.values()){if(!a.ast)continue;let i=new Set,l=d=>{switch(d.kind){case"number":return;case"token":{let c=t.tokens[d.name];typeof c!="number"&&o.push({severity:"error",code:c===void 0?"unknown-token":"token-not-a-number",message:c===void 0?`Unknown token $${d.name}`:`Token $${d.name} is not a number`,nodeId:a.nodeId,prop:a.prop});return}case"percent":{let c=Co(a.prop);if(!c)return;let m=r.layoutParentOf.get(a.nodeId),x=m===void 0?void 0:Oe(m,c);if(x===void 0||!e.has(x)){o.push({severity:"error",code:"percent-without-parent",message:`${a.nodeId}.${a.prop} uses a percentage but has no parent to measure against`,nodeId:a.nodeId,prop:a.prop});return}i.add(x);return}case"nodeRef":case"relRef":{let c=Eo(d,a.nodeId,r);if(!c.ok){n.add(d),o.push({severity:"error",code:"unknown-reference",message:c.message,nodeId:a.nodeId,prop:a.prop});return}let m=y=>{e.has(y)&&i.add(y)},x=qs(c.edge);if(!x){for(let y of zs(c.edge))m(Oe(c.nodeId,y));return}for(let y of js(c.nodeId,a.nodeId,r).keys())m(Oe(y,x));Ks(c.edge)!==0&&m(Oe(c.nodeId,x==="x"?"w":"h"));return}case"unary":l(d.operand);return;case"binary":l(d.left),l(d.right);return}};l(a.ast),a.deps=[...i]}}function Zh(e){let t=new Map,r=new Map;for(let[a,i]of e){t.set(a,i.deps.length);for(let l of i.deps){let d=r.get(l);d?d.push(a):r.set(l,[a])}}let n=[];for(let[a,i]of t)i===0&&n.push(a);let o=[];for(let a=0;a<n.length;a++){let i=n[a];o.push(i);for(let l of r.get(i)??[]){let d=(t.get(l)??0)-1;t.set(l,d),d===0&&n.push(l)}}return o}function Qh(e,t,r){if(t.length===e.size)return;let n=new Set(t);for(let[o,a]of e)n.has(o)||r.push({severity:"error",code:"cycle",message:`${a.nodeId}.${a.prop} is part of a dependency cycle`,nodeId:a.nodeId,prop:a.prop})}function ex(e,t,r,n,o,a){let i=new Map,l=(d,c)=>i.get(Oe(d,c))??0;for(let d of t){let c=e.get(d);if(c){if(!ce(c.value)){i.set(d,c.value);continue}if(!c.ast){i.set(d,0);continue}i.set(d,Jf(c.ast,c,r,n,o,a,l))}}return i}function Jf(e,t,r,n,o,a,i){let l=d=>Jf(d,t,r,n,o,a,i);switch(e.kind){case"number":return e.value;case"token":{let d=r.tokens[e.name];return typeof d=="number"?d:0}case"percent":{let d=Co(t.prop);if(!d)return e.value/100;let c=n.layoutParentOf.get(t.nodeId);return c===void 0?0:e.value/100*i(c,d)}case"nodeRef":case"relRef":{if(o.has(e))return 0;let d=Eo(e,t.nodeId,n);if(!d.ok)return 0;let c=qs(d.edge);if(!c)return _o(d.edge,i(d.nodeId,"x"),i(d.nodeId,"y"),i(d.nodeId,"w"),i(d.nodeId,"h"));let m=Ks(d.edge)*i(d.nodeId,c==="x"?"w":"h");for(let[x,y]of js(d.nodeId,t.nodeId,n))m+=y*i(x,c);return m}case"unary":{let d=l(e.operand);return e.op==="-"?-d:d}case"binary":{let d=l(e.left),c=l(e.right);if(e.op==="/"&&c===0)return a.push({severity:"error",code:"divide-by-zero",message:`${t.nodeId}.${t.prop} divides by zero`,nodeId:t.nodeId,prop:t.prop}),0;let m=tx(e.op,d,c);return Number.isFinite(m)?m:(a.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 tx(e,t,r){switch(e){case"+":return t+r;case"-":return t-r;case"*":return t*r;case"/":return t/r}}function rx(e,t,r,n){let o=new Map,a=(l,d)=>t.get(Oe(l,d))??0,i=(l,d,c)=>{let m=a(l.id,"x"),x=a(l.id,"y"),y=a(l.id,"w"),w=a(l.id,"h"),P={};for(let F of tt(l)){let N=Oe(l.id,F);r.has(N)&&(P[F]=t.get(N)??0)}(y<0||w<0)&&n.push({severity:"warning",code:"negative-size",message:`${l.id} resolved to a negative size`,nodeId:l.id});let _=d+m,C=c+x;if(o.set(l.id,{id:l.id,type:l.type,x:m,y:x,w:y,h:w,left:m,top:x,right:m+y,bottom:x+w,cx:m+y/2,cy:x+w/2,absX:_,absY:C,values:P}),ue(l))for(let F of l.children)i(F,_,C)};return i(e,0,0),o}function Ao(e){if(!ce(e))return{kind:"literal",value:e};let t=Ze(e.expr);return t.ok?t.ast.kind==="number"?{kind:"literal",value:t.ast.value}:t.ast.kind==="token"?{kind:"token",name:t.ast.name}:{kind:"complex",source:e.expr,ast:t.ast}:{kind:"complex",source:e.expr,error:t.message}}var Qf="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",eu=16,tu=400,ru=1.2,Mo="#0F172A";function bn(){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 Gs(e,t){if(e===void 0)return Qf;let r=t[e];return r?r.fallback?`${Zf(r.family)}, ${r.fallback}`:Zf(r.family):e}function Zf(e){return/^[A-Za-z][A-Za-z0-9 -]*$/.test(e)?e:JSON.stringify(e)}function nu(e,t,r,n){let o={family:Gs(t.font,r),size:t.size,weight:t.weight,italic:t.italic,underline:!1,strike:!1,fill:n(t.fill),letterSpacing:t.letterSpacing},a=typeof e=="string"?[e]:e,i=[];for(let l of a){if(typeof l=="string"){l.length>0&&i.push({text:l,style:o});continue}let d=l;d.text.length!==0&&i.push({text:d.text,style:{family:d.font===void 0?o.family:Gs(d.font,r),size:d.size??o.size,weight:d.weight??o.weight,italic:d.italic??o.italic,underline:d.underline??!1,strike:d.strike??!1,fill:d.fill===void 0?o.fill:n(d.fill),letterSpacing:d.letterSpacing??o.letterSpacing,...d.link!==void 0&&Je(d.link)?{link:d.link}:{}}})}return i}function nx(e,t){let r=[];for(let n of e)for(let o of n.text.split(/(\n)/))if(o!==""){if(o===`
38
+ `){let a=r[r.length-1];a&&!a.hardBreak?r[r.length-1]={...a,hardBreak:!0}:r.push({text:"",style:n.style,w:0,hardBreak:!0});continue}for(let a of o.match(/\S+\s*|\s+/g)??[])r.push({text:a,style:n.style,w:t.advance(a,n.style),hardBreak:!1})}return r}function ox(e,t,r){let n=[...e.text],o=[],a="";for(let i of n){let l=a+i;if(a!==""&&r.advance(l,e.style)>t){o.push({text:a,style:e.style,w:r.advance(a,e.style),hardBreak:!1}),a=i;continue}a=l}return a!==""&&o.push({text:a,style:e.style,w:r.advance(a,e.style),hardBreak:e.hardBreak}),o.length>0?o:[e]}function ou(e,t){let{width:r,measure:n}=t,o=nx(n.itemize?e.flatMap(c=>n.itemize?.(c)??[c]):e,n);if(o.length===0){let c=e[0]?.style,m=c?t.lineHeight*c.size:0;return{lines:c?[ax(c,t.lineHeight)]:[],width:0,height:m}}let a=[],i=[],l=0,d=()=>{a.push(i),i=[],l=0};for(let c of o){let m=i.length===0&&c.w>r&&r>0?ox(c,r,n):[c];for(let x of m){let y=x.text.trimEnd(),w=y===x.text?x.w:n.advance(y,x.style);i.length>0&&l+w>r&&d(),i.push(x),l+=x.w,x.hardBreak&&d()}}return i.length>0&&a.push(i),sx(a,t)}function ax(e,t){let r=t*e.size;return{y:0,h:r,baseline:r*.8,w:0,spans:[]}}function sx(e,t){let r=[],n=0,o=0;return e.forEach((a,i)=>{let l=a.map(V=>V.style.size),d=Math.max(...l,0),c=t.lineHeight*d,m=a.map(V=>t.measure.metrics(V.style)),x=Math.max(...m.map(V=>V.ascent),0),y=Math.max(...m.map(V=>V.descent),0),w=n+(c-(x+y))/2+x,P=ix(a,t.measure),_=P.reduce((V,W)=>V+W.w,0);o=Math.max(o,_);let C=i===e.length-1||(a[a.length-1]?.hardBreak??!1),F=t.align==="justify"&&!C&&P.length>1,N=Math.max(0,t.width-_),J=t.align==="center"?N/2:t.align==="right"?N:0,A=F?N/(P.length-1):0,D=[],k=J;P.forEach((V,W)=>{D.push({text:V.text,style:V.style,x:k,w:V.w}),k+=V.w+(W<P.length-1?A:0)}),r.push({y:n,h:c,baseline:w,w:_,spans:lx(D,F)}),n+=c}),{lines:r,width:o,height:n}}function ix(e,t){let r=[...e];for(;r.length>0;){let n=r[r.length-1],o=n.text.trimEnd();if(o===n.text)break;if(o===""){r.pop();continue}r[r.length-1]={...n,text:o,w:t.advance(o,n.style)};break}return r}function lx(e,t){if(t)return[...e];let r=[];for(let n of e){let o=r[r.length-1];if(o&&au(o.style,n.style)&&Math.abs(o.x+o.w-n.x)<.01){r[r.length-1]={...o,text:o.text+n.text,w:o.w+n.w};continue}r.push(n)}return r}function au(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 Ws(e,t,r,n,o,a){let i={size:t.size??eu,weight:t.weight??tu,lineHeight:t.lineHeight??ru,letterSpacing:t.letterSpacing??0,italic:e.italic??!1,font:typeof e.font=="string"?e.font:void 0,fill:typeof e.fill=="string"?e.fill:Mo};return ou(nu(e.content,i,n,o),{width:r,align:e.align??"left",lineHeight:i.lineHeight,measure:a})}function Xs(e,t,r){let n=t-r;return e.valign==="middle"?n/2:e.valign==="bottom"?n:0}function Ys(e){switch(e.kind){case"text":{let t=Math.max(e.w,...e.lines.map(n=>n.w)),r=Math.max(e.y+e.h,...e.lines.map(n=>n.y+n.h));return{x:e.x,y:e.y,w:t,h:r-e.y}}case"vector":{let t=Gt(e.contours)??{x:e.x,y:e.y,w:e.w,h:e.h},r=e.stroke!==void 0?e.strokeWidth*2:0;return{x:t.x-r,y:t.y-r,w:t.w+r*2,h:t.h+r*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 Lo(e,t){let r=e.x,n=e.y,o=e.x+e.w,a=e.y+e.h;for(let i of t){let l=i.spread+i.blur;r=Math.min(r,e.x+i.x-l),n=Math.min(n,e.y+i.y-l),o=Math.max(o,e.x+e.w+i.x+l),a=Math.max(a,e.y+e.h+i.y+l)}return{x:r,y:n,w:o-r,h:a-n}}var lu="vd-paint-";var To="#CBD5E1",du="#FFFFFF";function Oo(e,t,r={}){let n=[...t.problems],o=[],a=[],i=r.measure??bn(),l=xx(e.tokens,n),d=l.paint,c=new Map;re(e.root,(_,C)=>{if("hidden"in _&&_.hidden===!0)return!1;let F=C?c.get(C.id):void 0,N=t.nodes.get(_.id);if(!N){c.set(_.id,F);return}if(_.type==="frame"){_.skip===!0&&C!==e.root&&n.push({severity:"warning",code:"skip-not-a-page",message:`${_.id}: skip only applies to a page, a frame at the top level`,nodeId:_.id,prop:"skip"});let A={x:N.absX,y:N.absY,w:Math.max(0,N.w),h:Math.max(0,N.h)};c.set(_.id,_.clip===!0?_.id:F),_.clip===!0&&a.push({id:_.id,...A,parent:F}),o.push({kind:"frame",id:_.id,...A,background:d(_.background,_.id,"background",A),clip:F,blend:_.blend??"normal",shadows:Er(_.shadow,_.id,e.tokens,n),rotation:0});return}if(c.set(_.id,F),_.type==="text"){o.push(fx(_,N,e,i,n,F,d));return}if(_.type==="image"){o.push({kind:"image",id:_.id,x:N.absX,y:N.absY,w:Math.max(0,N.w),h:Math.max(0,N.h),href:vx(_,e,r.resolveAsset,n),fit:_.fit??"fill",radius:Math.max(0,N.values.radius??0),opacity:kn(N.values.opacity??1),clip:F,blend:_.blend??"normal",shadows:Er(_.shadow,_.id,e.tokens,n),rotation:N.values.rotation??0});return}if(_.type==="ellipse"){let A=iu(N);o.push({kind:"ellipse",id:_.id,...A,fill:d(_.fill,_.id,"fill",A)??To,stroke:d(_.stroke,_.id,"stroke",A),strokeWidth:N.values.strokeWidth??0,opacity:kn(N.values.opacity??1),clip:F,blend:_.blend??"normal",shadows:Er(_.shadow,_.id,e.tokens,n),rotation:N.values.rotation??0});return}if(_.type==="vector"){o.push(hx(_,N,n,F,d,Er(_.shadow,_.id,e.tokens,n)));return}if(_.type!=="rect")return;let J=iu(N);o.push({kind:"rect",id:_.id,...J,fill:d(_.fill,_.id,"fill",J)??To,stroke:d(_.stroke,_.id,"stroke",J),strokeWidth:N.values.strokeWidth??0,radius:Math.max(0,N.values.radius??0),opacity:kn(N.values.opacity??1),clip:F,blend:_.blend??"normal",shadows:Er(_.shadow,_.id,e.tokens,n),rotation:N.values.rotation??0})});let m=t.nodes.get(e.root.id),x=e.root.w!==void 0&&e.root.h!==void 0,y=x?{x:0,y:0,width:Math.max(0,m?.w??0),height:Math.max(0,m?.h??0)}:dx(o,a),w={x:y.x,y:y.y,w:y.width,h:y.height},P=d(e.root.background,e.root.id,"background",w);return{...y,background:x?P??du:P,items:o,clips:a,gradients:l.gradients,problems:n}}function dx(e,t){let r=new Map;for(let l of t){let d=l.parent===void 0?void 0:r.get(l.parent);r.set(l.id,d?su(l,d):l)}let n=1/0,o=1/0,a=-1/0,i=-1/0;for(let l of e){let d=l.kind==="text"?Math.max(l.h,l.height):l.h,c=l.clip===void 0?void 0:r.get(l.clip),m=hn(Lo({x:l.x,y:l.y,w:l.w,h:d},l.shadows),l.rotation,Ve(l)),x=c?su(m,c):m;x.w<=0||x.h<=0||(n=Math.min(n,x.x),o=Math.min(o,x.y),a=Math.max(a,x.x+x.w),i=Math.max(i,x.y+x.h))}return Number.isFinite(n)?{x:n,y:o,width:a-n,height:i-o}:{x:0,y:0,width:0,height:0}}function su(e,t){let r=Math.max(e.x,t.x),n=Math.max(e.y,t.y);return{x:r,y:n,w:Math.min(e.x+e.w,t.x+t.w)-r,h:Math.min(e.y+e.h,t.y+t.h)-n}}function fx(e,t,r,n,o,a,i){let l=Math.max(0,t.w),d=Math.max(0,t.h),c={x:t.absX,y:t.absY,w:l,h:d},m=Ws(e,t.values,l,r.fonts,y=>i(y,e.id,"fill",c)??Mo,n);m.height>d+.5&&o.push({severity:"warning",code:"text-overflow",message:`${e.id} needs ${Math.ceil(m.height)}px but its height is ${Math.round(d)}px`,nodeId:e.id,prop:"h"}),ux(e,r,o);let x=t.absY+Xs(e,d,m.height);return{kind:"text",id:e.id,x:t.absX,y:t.absY,w:l,h:d,clip:a,blend:e.blend??"normal",shadows:Er(e.shadow,e.id,r.tokens,o),rotation:t.values.rotation??0,opacity:kn(t.values.opacity??1),height:m.height,lines:m.lines.map(y=>({y:x+y.y,h:y.h,baseline:x+y.baseline,w:y.w,spans:y.spans.map(w=>({text:w.text,x:t.absX+w.x,y:x+y.baseline,w:w.w,style:w.style}))}))}}function ux(e,t,r){if(typeof e.content!="string")for(let n of e.content){if(typeof n=="string"||n.link===void 0)continue;let o=Je(n.link);if(!o){r.push({severity:"warning",code:"invalid-link",message:`${e.id}: links go to https:, mailto: or #<frame>, not ${JSON.stringify(n.link)}`,nodeId:e.id,prop:"content"});continue}o.kind==="frame"&&!cx(t,o.id)&&r.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 cx(e,t){let r=!1;return re(e.root,n=>{if(r)return!1;n.id===t&&n.type==="frame"&&(r=!0)}),r}var wn=new Map,px=512;function mx(e){let t=wn.get(e);if(t)return t;let r=an(e);return wn.size>=px&&wn.delete(wn.keys().next().value),wn.set(e,r),r}function hx(e,t,r,n,o,a){let i=Math.max(0,t.w),l=Math.max(0,t.h),d={x:t.absX,y:t.absY,w:i,h:l},{contours:c,error:m}=mx(e.d);m!==void 0&&r.push({severity:"error",code:"bad-path",message:`${e.id}: ${m}`,nodeId:e.id,prop:"d"}),e.view!==void 0&&mo(e.view)===void 0&&r.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 x=ut(c,fn(dn(e.view,i,l),d));return{kind:"vector",id:e.id,...d,d:ft(x),contours:x,fill:o(e.fill,e.id,"fill",d)??To,stroke:o(e.stroke,e.id,"stroke",d),strokeWidth:t.values.strokeWidth??0,opacity:kn(t.values.opacity??1),rule:e.rule??"nonzero",cap:e.cap??"butt",join:e.join??"miter",clip:n,blend:e.blend??"normal",shadows:a,rotation:t.values.rotation??0}}function fu(e,t,r,n,o){if(e===void 0)return;if(ce(e)){o.push({severity:"warning",code:"expression-not-supported",message:`Expressions are not supported for ${n} yet; grammar v0 is numeric only`,nodeId:r,prop:n});return}let a=t[e];if(a===void 0)return e;if(typeof a=="string")return a;o.push({severity:"error",code:"token-not-a-colour",message:`Token $${e} is a number, not a colour`,nodeId:r,prop:n})}function iu(e){return{x:e.absX,y:e.absY,w:Math.max(0,e.w),h:Math.max(0,e.h)}}function xx(e,t){let r=[],n=new Map;return{paint:(a,i,l,d)=>{let c=fu(a,e,i,l,t);if(c===void 0)return;let m=mn(c);if("error"in m){t.push({severity:"error",code:"invalid-paint",message:`${i}: ${m.error}`,nodeId:i,prop:l});return}if(m.kind==="solid")return c;let x=`${i}\0${l}\0${c}`,y=n.get(x);if(y!==void 0)return`url(#${y})`;let w=[...n.keys()].filter(C=>C.startsWith(`${i}\0${l}\0`)).length,P=`${lu}${i}-${l}${w===0?"":`-${w+1}`}`;n.set(x,P);let _=Ps(m.stops).map(C=>({offset:C.at,colour:uu(C.colour,e,i,l,t)}));return r.push(yx(m,P,d,gx(_))),`url(#${P})`},gradients:r}}function Er(e,t,r,n){let o=fu(e,r,t,"shadow",n);if(o===void 0)return[];let a=_r(o);return"error"in a?(n.push({severity:"error",code:"invalid-shadow",message:`${t}: ${a.error}`,nodeId:t,prop:"shadow"}),[]):a.shadows.map(i=>({...i,colour:uu(i.colour,r,t,"shadow",n)}))}function gx(e){return e.map((t,r)=>{if(t.colour.trim().toLowerCase()!=="transparent")return t;let n=[e[r-1],e[r+1]].find(o=>o!==void 0&&o.colour.trim().toLowerCase()!=="transparent");return n===void 0?t:{offset:t.offset,colour:n.colour,opacity:0}})}function uu(e,t,r,n,o){let a=t[e];return a===void 0?e:typeof a=="string"&&!wo(a)?a:(o.push({severity:"error",code:"invalid-paint",message:`${r}: a gradient stop names $${e}, which is not a colour`,nodeId:r,prop:n}),"transparent")}function yx(e,t,r,n){if(e.kind==="linear"){let c=e.angle*Math.PI/180,m=Math.sin(c),x=-Math.cos(c),y=(Math.abs(r.w*m)+Math.abs(r.h*x))/2,w=r.x+r.w/2,P=r.y+r.h/2;return{id:t,kind:"linear",x1:$o(w-m*y),y1:$o(P-x*y),x2:$o(w+m*y),y2:$o(P+x*y),stops:n}}let o=r.x+r.w*e.cx,a=r.y+r.h*e.cy,i={x:Math.max(o-r.x,r.x+r.w-o),y:Math.max(a-r.y,r.y+r.h-a)};if(e.shape==="circle"||i.x===0||i.y===0){let c=Math.hypot(i.x,i.y);return{id:t,kind:"radial",cx:o,cy:a,rx:c,ry:c,stops:n}}let l=i.x/i.y,d=Math.hypot(i.x/l,i.y);return{id:t,kind:"radial",cx:o,cy:a,rx:d*l,ry:d,stops:n}}function $o(e){return Math.round(e*1e6)/1e6}function kn(e){return Math.min(Math.max(e,0),1)}function vx(e,t,r,n){let o=ce(e.src)?void 0:e.src,a=o===void 0?void 0:t.assets[o];if(!a){n.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 i=r?.(a,o);return i===void 0&&n.push({severity:"warning",code:"unresolved-asset",message:`The bytes for asset "${o}" are not available here`,nodeId:e.id,prop:"src"}),i}function Js(e){return wx(e,"")}function wx(e,t){let r=e.stops.map(o=>`<stop offset="${Z(o.offset)}" stop-color="${Do(o.colour)}"${o.opacity===void 0?"":` stop-opacity="${Z(o.opacity)}"`}/>`).join(""),n=Do(t+e.id);return e.kind==="linear"?`<linearGradient id="${n}" gradientUnits="userSpaceOnUse" x1="${Z(e.x1)}" y1="${Z(e.y1)}" x2="${Z(e.x2)}" y2="${Z(e.y2)}">${r}</linearGradient>`:`<radialGradient id="${n}" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="1" gradientTransform="matrix(${Z(e.rx)} 0 0 ${Z(e.ry)} ${Z(e.cx)} ${Z(e.cy)})">${r}</radialGradient>`}var Po="vd-shadow-";function Zs(e,t=!1){return kx(e,t,"")}function kx(e,t,r){let n=Lo(Ys(e),e.shadows),o=2,a=[];e.shadows.forEach((l,d)=>{let c=`s${d}`,m="SourceAlpha";l.spread!==0&&(a.push(`<feMorphology in="${m}" operator="${l.spread>0?"dilate":"erode"}" radius="${Z(Math.abs(l.spread))}" result="${c}m"/>`),m=`${c}m`),l.blur>0&&(a.push(`<feGaussianBlur in="${m}" stdDeviation="${Z(l.blur/2)}" result="${c}b"/>`),m=`${c}b`),a.push(`<feOffset in="${m}" dx="${Z(l.x)}" dy="${Z(l.y)}" result="${c}o"/>`,`<feFlood flood-color="${Do(l.colour)}" result="${c}c"/>`,`<feComposite in="${c}c" in2="${c}o" operator="in" result="${c}"/>`)});let i=e.shadows.map((l,d)=>`<feMergeNode in="s${e.shadows.length-1-d}"/>`).join("");return`<filter id="${Do(r+Po+e.id)}" filterUnits="userSpaceOnUse" x="${Z(n.x-o)}" y="${Z(n.y-o)}" width="${Z(n.w+o*2)}" height="${Z(n.h+o*2)}" color-interpolation-filters="sRGB">`+a.join("")+`<feMerge>${i}${t?"":'<feMergeNode in="SourceGraphic"/>'}</feMerge></filter>`}function Qs(e){return`rotate(${Z(e.rotation)} ${Z(e.x+e.w/2)} ${Z(e.y+e.h/2)})`}function ei(e){return e.rotation!==0&&e.clip!==void 0}function Do(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var Cx=.8,Ex=.2;function ti(e,t){let n=e.createElement("canvas").getContext("2d"),o=bn(),a=new Map,i=new Map,l=new Set;function d(m){return`${m.italic?"italic ":""}${m.weight} ${m.size}px ${m.family}`}function c(){a.clear(),i.clear()}return{advance(m,x){if(!n)return o.advance(m,x);let y=d(x),w=`${y}\0${x.letterSpacing}\0${m}`,P=a.get(w);if(P!==void 0)return P;n.font=y;let _=n.measureText(m).width+x.letterSpacing*[...m].length;return a.set(w,_),_},metrics(m){if(!n)return o.metrics(m);let x=d(m),y=i.get(x);if(y)return y;n.font=x;let w=n.measureText("Hxg"),P=w.fontBoundingBoxAscent??m.size*Cx,_=w.fontBoundingBoxDescent??m.size*Ex,C={ascent:P,descent:_,lineGap:0};return i.set(x,C),C},load(m,x){let y=e.fonts;if(!y||typeof FontFace!="function")return!1;let w=!1;for(let P of Object.values(m.fonts))for(let _ of Ax(P)){let C=`${P.family}\0${_.src}\0${_.weight??400}\0${_.style??"normal"}`;if(l.has(C))continue;l.add(C);let F=_.src.startsWith("data:")?void 0:x?.(_.src),N={weight:String(_.weight??400),style:_.style??"normal"},J=A=>{let D=new FontFace(P.family,typeof A=="string"?`url(${A})`:Mx(A),N);y.add(D),D.load().then(()=>{c(),t?.()},()=>{y.delete(D)})};F===void 0?J(_.src):(w=!0,F.then(J,()=>{}))}return w},invalidate:c,destroy(){c(),l.clear()}}}function Ax(e){return e.faces??[]}function Mx(e){return e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}var No={x:0,y:0,zoom:1},cu=.02,pu=64;function Sn(e){return Number.isFinite(e)?Math.min(Math.max(e,cu),pu):1}function Ro(e,t){return{x:(t.x-e.x)/e.zoom,y:(t.y-e.y)/e.zoom}}function ri(e,t){return{x:t.x*e.zoom+e.x,y:t.y*e.zoom+e.y}}function Io(e,t,r){let n=Sn(e.zoom*r),o=Ro(e,t);return{zoom:n,x:t.x-o.x*n,y:t.y-o.y*n}}function Qt(e,t,r){return{...e,x:e.x+t,y:e.y+r}}function ni(e){return`translate(${e.x} ${e.y}) scale(${e.zoom})`}function Ar(e,t,r){let n={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)};if(e.width<=0||e.height<=0)return No;let o=Sn(Math.min(n.width/e.width,n.height/e.height));return{zoom:o,x:(t.width-e.width*o)/2-(e.x??0)*o,y:(t.height-e.height*o)/2-(e.y??0)*o}}var te="http://www.w3.org/2000/svg",mu="vd-viewer-styles",hu=`
39
+ .vd-viewer {
40
+ position: relative;
41
+ overflow: hidden;
42
+ touch-action: none;
43
+ user-select: none;
44
+ background: var(--vd-surface, #1b1b1f);
45
+ }
46
+ .vd-viewer__surface {
47
+ display: block;
48
+ width: 100%;
49
+ height: 100%;
50
+ /* Text was measured against real faces; a synthesised bold or slant is not
51
+ one of them, and would draw wider or narrower than it was laid out. */
52
+ font-synthesis: none;
53
+ }
54
+ /* Every space layout measured, drawn. \`xml:space="preserve"\` is also set, but
55
+ Chromium ignores it when set through setAttribute rather than parsed from
56
+ markup, and collapsed double spaces shifted the rest of the line. */
57
+ .vd-viewer__surface text {
58
+ white-space: pre;
59
+ }
60
+ .vd-viewer__camera {
61
+ /* Hints the compositor that this subtree is about to be transformed. */
62
+ will-change: transform;
63
+ }
64
+ .vd-viewer__page {
65
+ /* An embedder with a no-shadow brand sets --vd-page-shadow: none. */
66
+ filter: var(--vd-page-shadow, drop-shadow(0 6px 24px rgb(0 0 0 / 0.35)));
67
+ }
68
+ /* An asset whose bytes are not here. Visible, and obviously not a design choice. */
69
+ .vd-viewer__missing {
70
+ fill: none;
71
+ stroke: #94a3b8;
72
+ stroke-width: 1;
73
+ stroke-dasharray: 4 4;
74
+ }
75
+ /* The player: black around the slide, and nothing else on screen. */
76
+ .vd-player {
77
+ outline: none;
78
+ cursor: default;
79
+ }
80
+ /* A button or a link under the pointer. Before idle, which wins when both apply. */
81
+ .vd-player--link {
82
+ cursor: pointer;
83
+ }
84
+ .vd-player--idle {
85
+ cursor: none;
86
+ }
87
+ /* Positioned, so a transition's still of the page being left can go under or
88
+ over it by document order alone. */
89
+ .vd-player .vd-viewer__surface {
90
+ position: relative;
91
+ }
92
+ /* The page being left, frozen for a transition. Opaque, or the new page would
93
+ show through it. More specific than the rule above, which it also matches. */
94
+ .vd-player .vd-player__still {
95
+ position: absolute;
96
+ inset: 0;
97
+ background: #000;
98
+ pointer-events: none;
99
+ }
100
+ /* Not on screen yet, or gone already: what motion is holding back. */
101
+ .vd-player [data-vd-hidden] {
102
+ visibility: hidden;
103
+ }
104
+ .vd-player .vd-viewer__page {
105
+ filter: none;
106
+ }
107
+ .vd-player__mask {
108
+ pointer-events: none;
109
+ }
110
+ .vd-player__counter {
111
+ position: absolute;
112
+ right: 16px;
113
+ bottom: 16px;
114
+ padding: 4px 10px;
115
+ border-radius: 8px;
116
+ background: rgb(0 0 0 / 0.6);
117
+ color: #fff;
118
+ font: 500 12px/1.4 system-ui, sans-serif;
119
+ font-variant-numeric: tabular-nums;
120
+ opacity: 0;
121
+ transition: opacity 200ms;
122
+ pointer-events: none;
123
+ }
124
+ .vd-player__counter--shown {
125
+ opacity: 1;
126
+ }
127
+ @media (prefers-reduced-motion: reduce) {
128
+ .vd-player__counter {
129
+ transition: none;
130
+ }
131
+ }
132
+ /* Blur filters re-rasterise at every scale; drop it while the camera moves. */
133
+ .vd-viewer--interacting .vd-viewer__page {
134
+ filter: none;
135
+ }
136
+ `;function xu(e){if(e.getElementById(mu))return;let t=e.createElement("style");t.id=mu,t.textContent=hu,e.head.appendChild(t)}function yu(e,t,r,n){return t?Tx(e,t,r,n):$x(e,r,n)}function $x(e,t,r){let n=ti(e,r);return{measurer:n,update:o=>{n.load(o,t)},afterPaint:()=>{},destroy:()=>n.destroy()}}var gu=new WeakMap;function Tx(e,t,r,n){let o,a,i,l=()=>{if(!o)throw new Error("canvasFonts: update() before measuring");return o};return{measurer:{advance:(c,m)=>l().measurer.advance(c,m),metrics:c=>l().measurer.metrics(c),itemize:c=>l().measurer.itemize(c)},update(c){o&&c.fonts===a||(i?.(),o?.dispose(),o=t.forDocument(c,r?{loader:r}:{}),a=c.fonts,i=o.onChange(n))},afterPaint(){let c=e.fonts;if(!o||!c||typeof FontFace!="function")return;let m=gu.get(e);m||gu.set(e,m=new Set);for(let x of o.usedFaces()){if(m.has(x.id))continue;m.add(x.id);let y=new FontFace(x.id,Lx(x.bytes),{weight:String(x.weight),style:x.style});c.add(y),y.load().catch(()=>c.delete(y))}},destroy(){i?.(),o?.dispose(),o=void 0}}}function Lx(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var Ox=.01,Dx=.004,vu=40,Px=16;function Fo(e,t){xu(e.ownerDocument);let r=t.document,n=b=>yu(e.ownerDocument,b,t.loadFont,()=>{A(r)}),o=n(t.fonts),a={advance:(b,U)=>o.measurer.advance(b,U),metrics:b=>o.measurer.metrics(b),itemize:b=>o.measurer.itemize?.(b)??[b]};o.update(r);let i=Ee(r),l=()=>t.resolveAsset?{measure:a,resolveAsset:t.resolveAsset}:{measure:a},d=Oo(r,i,l()),c=t.camera??No,m=t.interactive??!0,x=t.wheel??"always";e.classList.add("vd-viewer"),t.surface&&(e.style.background=t.surface);let y=e.ownerDocument.createElementNS(te,"svg");y.setAttribute("class","vd-viewer__surface"),y.setAttribute("width","100%"),y.setAttribute("height","100%");let w=e.ownerDocument.createElementNS(te,"g");w.setAttribute("class","vd-viewer__camera"),w.style.isolation="isolate",y.appendChild(w);let P=e.ownerDocument.createElementNS(te,"defs");w.appendChild(P);let _=e.ownerDocument.createElementNS(te,"rect");_.setAttribute("class","vd-viewer__page"),w.appendChild(_),e.appendChild(y);let C=new Map;function F(){w.setAttribute("transform",ni(c))}function N(){J();let b=d.background!==void 0;_.setAttribute("x",String(d.x)),_.setAttribute("y",String(d.y)),_.setAttribute("width",String(b?d.width:0)),_.setAttribute("height",String(b?d.height:0)),ye(_,"fill",d.background??null);let U=new Set,B=_;for(let R of d.items){U.add(R.id);let q=C.get(R.id);(!q||q.tagName!==bu(R))&&(q?.remove(),q=e.ownerDocument.createElementNS(te,bu(R)),q.setAttribute("data-vd-id",R.id),C.set(R.id,q)),Rx(q,R),B.nextSibling!==q&&w.insertBefore(q,B.nextSibling),B=q}for(let[R,q]of C)U.has(R)||(q.remove(),C.delete(R));o.afterPaint(),t.onSceneChange?.(d,r)}function J(){P.replaceChildren();let b=d.items.filter(U=>U.shadows.length>0);if(d.gradients.length>0||b.length>0){let U=`<svg xmlns="${te}">${d.gradients.map(Js).join("")}${b.map(R=>Zs(R)).join("")}</svg>`,B=new DOMParser().parseFromString(U,"image/svg+xml");for(let R of[...B.documentElement.children])P.appendChild(e.ownerDocument.importNode(R,!0))}for(let U of d.clips){let B=e.ownerDocument.createElementNS(te,"clipPath");B.setAttribute("id",ku(U.id)),U.parent!==void 0&&B.setAttribute("clip-path",ai(U.parent));let R=e.ownerDocument.createElementNS(te,"rect");R.setAttribute("x",String(U.x)),R.setAttribute("y",String(U.y)),R.setAttribute("width",String(U.w)),R.setAttribute("height",String(U.h)),B.appendChild(R),P.appendChild(B)}}function A(b){r=b,o.update(r),i=Ee(r),d=Oo(r,i,l()),N()}function D(b){let U=e.getBoundingClientRect();return{x:b.clientX-U.left,y:b.clientY-U.top}}let k=0,V=0;function W(){e.classList.add("vd-viewer--interacting"),V&&clearTimeout(V),V=setTimeout(()=>{V=0,e.classList.remove("vd-viewer--interacting")},180)}function pe(){k&&(cancelAnimationFrame(k),k=0),F(),t.onCameraChange?.(c)}function ne(b){c=b,pe()}function we(b){c=b,W(),!k&&(k=requestAnimationFrame(()=>{k=0,F(),t.onCameraChange?.(c)}))}let xe=null,T=null,me=!1,oe=b=>{if(x==="modifier"&&!b.ctrlKey&&!b.metaKey)return;b.preventDefault();let U=D(b),B=b.deltaMode===1?Px:b.deltaMode===2?e.clientHeight||800:1,R=b.deltaX*B,q=b.deltaY*B;if(b.ctrlKey||b.metaKey){let je=b.ctrlKey?Ox:Dx,ae=Math.max(-vu,Math.min(vu,q));we(Io(c,U,Math.exp(-ae*je)));return}if(b.shiftKey&&R===0){we(Qt(c,-q,0));return}we(Qt(c,-R,-q))},S=b=>{(b.button===1||b.button===0&&me)&&(b.preventDefault(),xe=b.pointerId,T=D(b),e.setPointerCapture(b.pointerId))},$=b=>{if(xe!==b.pointerId||!T)return;let U=D(b);we(Qt(c,U.x-T.x,U.y-T.y)),T=U},M=b=>{xe===b.pointerId&&(xe=null,T=null,e.hasPointerCapture(b.pointerId)&&e.releasePointerCapture(b.pointerId))},L=b=>{b.code==="Space"&&(me=!0)},H=b=>{b.code==="Space"&&(me=!1)};m&&(e.addEventListener("wheel",oe,{passive:!1}),e.addEventListener("pointerdown",S),e.addEventListener("pointermove",$),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.ownerDocument.addEventListener("keydown",L),e.ownerDocument.addEventListener("keyup",H)),F(),N();let K={element:e,surface:y,update:A,getDocument:()=>r,getScene:()=>d,getResolution:()=>i,getMeasurer:()=>a,setFonts(b){o.destroy(),o=n(b),A(r)},getCamera:()=>c,setCamera:ne,zoomBy(b,U){let B=e.getBoundingClientRect(),R=U??{x:B.width/2,y:B.height/2};ne(Io(c,R,b))},fitToContent(b=32){let U=e.getBoundingClientRect();ne(Ar({x:d.x,y:d.y,width:d.width,height:d.height},{width:U.width||d.width,height:U.height||d.height},b))},screenToDocument:b=>Ro(c,b),documentToScreen:b=>ri(c,b),pointerPoint:D,hitTest(b,U){for(let B=d.items.length-1;B>=0;B--){let R=d.items[B];if(R&&jx(R,b,qx/c.zoom)&&(!U||U(R.id)))return R.id}return null},linkAt(b,U){for(let B=d.items.length-1;B>=0;B--){let R=d.items[B];if(R?.kind!=="text"||U&&!U(R.id))continue;let q=R.rotation===0?b:Pe(b,{x:R.x+R.w/2,y:R.y+R.h/2},-R.rotation);for(let je of R.lines){if(q.y<je.y||q.y>je.y+je.h)continue;let ae=je.spans.find(Te=>q.x>=Te.x&&q.x<=Te.x+Te.w);if(ae)return ae.style.link}}},itemOf:b=>d.items.find(U=>U.id===b),elementOf:b=>C.get(b),destroy(){m&&(e.removeEventListener("wheel",oe),e.removeEventListener("pointerdown",S),e.removeEventListener("pointermove",$),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.ownerDocument.removeEventListener("keydown",L),e.ownerDocument.removeEventListener("keyup",H)),k&&cancelAnimationFrame(k),V&&clearTimeout(V),k=0,V=0,o.destroy(),e.classList.remove("vd-viewer--interacting"),y.remove(),C.clear(),e.classList.remove("vd-viewer")}};return t.autoFit&&K.fitToContent(),K}var Nx="vd-clip-";function ku(e){return Nx+e}function ai(e){return`url(#${ku(e)})`}function bu(e){return ei(e)?"g":oi(e)}function oi(e){switch(e.kind){case"ellipse":return"ellipse";case"frame":return"rect";case"image":return e.href===void 0?"rect":"image";case"rect":return"rect";case"text":return"text";case"vector":return"path"}}function Rx(e,t){if(e.tagName!=="g"){wu(e,t);return}ye(e,"clip-path",t.clip===void 0?null:ai(t.clip)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend;let r=e.firstElementChild;(!r||r.tagName!==oi(t))&&(r?.remove(),r=e.ownerDocument.createElementNS(te,oi(t)),e.appendChild(r)),wu(r,{...t,clip:void 0,blend:"normal"})}function wu(e,t){switch(ye(e,"clip-path",t.clip===void 0?null:ai(t.clip)),ye(e,"transform",t.rotation===0?null:Qs(t)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend,e.style.filter=t.shadows.length>0?`url(#${Po}${t.id})`:"",t.kind){case"ellipse":Ux(e,t);return;case"frame":Ix(e,t);return;case"image":Fx(e,t);return;case"rect":Vx(e,t);return;case"text":Hx(e,t);return;case"vector":zx(e,t);return}}function Ix(e,t){e.setAttribute("class","vd-viewer__page"),e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),ye(e,"fill",t.background??null)}function Fx(e,t){if(e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),ye(e,"opacity",t.opacity<1?String(t.opacity):null),t.href===void 0){e.setAttribute("class","vd-viewer__missing"),ye(e,"rx",t.radius>0?String(t.radius):null);return}e.setAttribute("href",t.href),e.setAttribute("preserveAspectRatio",Bx[t.fit])}var Bx={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"};function Hx(e,t){ye(e,"opacity",t.opacity<1?String(t.opacity):null),e.setAttribute("xml:space","preserve");let r=t.lines.flatMap(o=>o.spans).filter(o=>o.text!==""),n=e.ownerDocument;for(;e.childNodes.length>r.length;)e.lastChild?.remove();for(;e.childNodes.length<r.length;)e.appendChild(n.createElementNS(te,"tspan"));r.forEach((o,a)=>{let i=e.childNodes[a];i.textContent=o.text,i.setAttribute("x",String(o.x)),i.setAttribute("y",String(o.y)),i.setAttribute("font-family",o.style.family),i.setAttribute("font-size",String(o.style.size)),i.setAttribute("fill",o.style.fill),ye(i,"font-weight",o.style.weight===400?null:String(o.style.weight)),ye(i,"font-style",o.style.italic?"italic":null),ye(i,"letter-spacing",o.style.letterSpacing===0?null:String(o.style.letterSpacing)),ye(i,"data-vd-link",o.style.link??null);let l=[o.style.underline?"underline":"",o.style.strike?"line-through":""].filter(Boolean).join(" ");ye(i,"text-decoration",l===""?null:l)})}function Vx(e,t){e.removeAttribute("class"),e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),e.setAttribute("fill",t.fill),ye(e,"rx",t.radius>0?String(t.radius):null),ye(e,"stroke",t.stroke??null),ye(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),ye(e,"opacity",t.opacity<1?String(t.opacity):null)}function Su(e,t){e.setAttribute("fill",t.fill),ye(e,"stroke",t.stroke??null),ye(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),ye(e,"opacity",t.opacity<1?String(t.opacity):null)}function Ux(e,t){e.setAttribute("cx",String(t.x+t.w/2)),e.setAttribute("cy",String(t.y+t.h/2)),e.setAttribute("rx",String(t.w/2)),e.setAttribute("ry",String(t.h/2)),Su(e,t)}function zx(e,t){e.setAttribute("d",t.d),Su(e,t),ye(e,"fill-rule",t.rule==="nonzero"?null:t.rule),ye(e,"stroke-linecap",t.cap==="butt"?null:t.cap),ye(e,"stroke-linejoin",t.join==="miter"?null:t.join)}function ye(e,t,r){r===null?e.removeAttribute(t):e.setAttribute(t,r)}var qx=4;function jx(e,t,r){let n=e.rotation===0?t:Pe(t,{x:e.x+e.w/2,y:e.y+e.h/2},-e.rotation),o=n.x>=e.x&&n.x<=e.x+e.w&&n.y>=e.y&&n.y<=e.y+e.h;if(e.kind==="ellipse"){let a=e.stroke!==void 0?e.strokeWidth/2:0,i=e.w/2+a,l=e.h/2+a;if(i<=0||l<=0)return!1;let d=(n.x-(e.x+e.w/2))/i,c=(n.y-(e.y+e.h/2))/l;return d*d+c*c<=1}if(e.kind==="vector"){let a=e.stroke!==void 0&&e.strokeWidth>0;return os(e.contours,n,{fill:e.fill!=="none",rule:e.rule,reach:(a?e.strokeWidth/2:0)+r})}return o}function si(e,t){let r=e.root.id;if(r===t)return e;let n=o=>{if(!ce(o))return o;let a=Ze(o.expr);return!a.ok||!Zt(a.ast).nodes.includes(r)?o:{expr:yn(Mt(a.ast,i=>i===r?t:void 0))}};return{...e,root:{..._u(e.root,n),id:t}}}function _u(e,t){let r=e,n={};for(let[o,a]of Object.entries(r)){if(o==="children"&&Array.isArray(a)){n[o]=a.map(i=>_u(i,t));continue}n[o]=t(a)}return n}var li=["nw","n","ne","e","se","s","sw","w"],En=["nw","ne","se","sw"];function Bo(e){let t=[];return e.includes("w")&&t.push("x","w"),e.includes("e")&&t.push("w"),e.includes("n")&&t.push("y","h"),e.includes("s")&&t.push("h"),t}function Mr(e){let t=e.includes("w")?0:e.includes("e")?1:.5,r=e.includes("n")?0:e.includes("s")?1:.5;return{u:t,v:r}}function di(e){switch(e){case"e":case"w":return 0;case"n":case"s":return 90;case"nw":case"se":return 45;case"ne":case"sw":return 135}}var Cn=1;function pt(e,t,r,n){let{x:o,y:a,w:i,h:l}=e;if(t.includes("w")){let d=o+i;o=Math.min(o+r,d-Cn),i=d-o}if(t.includes("e")&&(i=Math.max(Cn,i+r)),t.includes("n")){let d=a+l;a=Math.min(a+n,d-Cn),l=d-a}return t.includes("s")&&(l=Math.max(Cn,l+n)),{x:o,y:a,w:i,h:l}}function er(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}}function Ho(e,t){let r=[];return t.x!==e.x&&r.push("x"),t.y!==e.y&&r.push("y"),t.w!==e.w&&r.push("w"),t.h!==e.h&&r.push("h"),r}function Qe(e){if(e.length===0)return null;let t=1/0,r=1/0,n=-1/0,o=-1/0;for(let a of e)t=Math.min(t,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x+a.w),o=Math.max(o,a.y+a.h);return{x:t,y:r,w:n-t,h:o-r}}function fi(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function et(e,t,r){return t>=e.x&&t<=e.x+e.w&&r>=e.y&&r<=e.y+e.h}var $r=7,ii=15,_n=9;function ui(e){let t=[],r=ii/2;for(let l of En){let{u:d,v:c}=Mr(l);t.push({handle:l,rect:{x:e.x+e.w*d-r,y:e.y+e.h*c-r,w:ii,h:ii}})}let n=r,o=Math.max(0,e.w-n*2),a=Math.max(0,e.h-n*2),i=_n/2;return t.push({handle:"n",rect:{x:e.x+n,y:e.y-i,w:o,h:_n}},{handle:"s",rect:{x:e.x+n,y:e.y+e.h-i,w:o,h:_n}},{handle:"w",rect:{x:e.x-i,y:e.y+n,w:_n,h:a}},{handle:"e",rect:{x:e.x+e.w-i,y:e.y+n,w:_n,h:a}}),t}function Eu(e,t,r,n,o){if(o===0)return pt(e,t,r,n);let a=Pe({x:r,y:n},{x:0,y:0},-o),i=pt(e,t,a.x,a.y),l=Ve(e),d=Ve(i),c={x:l.x-d.x,y:l.y-d.y},m=Pe(c,{x:0,y:0},o);return{...i,x:i.x+c.x-m.x,y:i.y+c.y-m.y}}function Cu(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI}function Au(e,t,r,n,o){let a=Cu(e,r)-Cu(e,t);return o?Math.round((n+a)/o)*o-n:a}function Mu(e,t,r){return e.map(n=>{let o=Ve(n.frame),a=Pe(o,t,r);return{id:n.id,frame:{...n.frame,x:a.x-n.frame.w/2,y:a.y-n.frame.h/2},rotation:xn(n.rotation+r)}})}function $u(e,t,r,n){let o=r.w===0?1:n.w/r.w,a=r.h===0?1:n.h/r.h,i=t*Math.PI/180,l=Math.cos(i),d=Math.sin(i),c=e.w*Math.hypot(o*l,a*d),m=e.h*Math.hypot(o*d,a*l),x=Ve(e),y=n.x+(x.x-r.x)*o,w=n.y+(x.y-r.y)*a;return{x:y-c/2,y:w-m/2,w:c,h:m}}function Ae(e,t){return`${e}:${t}`}function zo(e){let[t,r]=e.split(":").map(Number);if(!(t===void 0||r===void 0||!Number.isInteger(t)||!Number.isInteger(r)))return{contour:t,index:r}}function Tu(e){let t=e.split(":"),r=t[2],n=zo(t.slice(0,2).join(":"));if(!(!n||r!=="in"&&r!=="out"))return{...n,side:r}}function pi(e,t){let r=zo(t);return r?e[r.contour]?.anchors[r.index]:void 0}function mi(e,t){let r=[];for(let n of t){let o=zo(n);o&&e[o.contour]?.anchors[o.index]&&r.push(Ae(o.contour,o.index))}return r}function hi(e){return e.flatMap((t,r)=>t.anchors.map((n,o)=>Ae(r,o)))}function ci(e,t,r,n){return e.map((o,a)=>a===t?{...o,anchors:o.anchors.map((i,l)=>l===r?n:i)}:o)}var An=(e,t,r)=>({x:e.x+t,y:e.y+r});function qo(e,t,r,n){return e.map((o,a)=>({...o,anchors:o.anchors.map((i,l)=>t.has(Ae(a,l))?ot(An(i,r,n),i.in&&An(i.in,r,n),i.out&&An(i.out,r,n)):i)}))}function Vo(e){if(!e.in||!e.out)return!1;let t=e.in.x-e.x,r=e.in.y-e.y,n=e.out.x-e.x,o=e.out.y-e.y,a=Math.hypot(t,r),i=Math.hypot(n,o);return a===0||i===0?!1:(t*n+r*o)/(a*i)<-.995}function Uo(e,t,r,n,o,a){let i=e[t]?.anchors[r];if(!i)return[...e];let d=i[n==="in"?"out":"in"];if(a.smooth&&!a.breakSmooth&&d){let m=Math.hypot(d.x-i.x,d.y-i.y),x=o.x-i.x,y=o.y-i.y,w=Math.hypot(x,y);w>0&&(d={x:i.x-x/w*m,y:i.y-y/w*m})}let c=n==="in"?ot(i,o,d):ot(i,d,o);return ci(e,t,r,c)}function Lu(e,t){let r=zo(t),n=r?e[r.contour]:void 0,o=n?.anchors[r?.index??-1];if(!r||!n||!o)return[...e];if(o.in||o.out)return ci(e,r.contour,r.index,ot(o));let a=n.anchors.length,i=r.index>0?n.anchors[r.index-1]:n.closed?n.anchors[a-1]:void 0,l=r.index<a-1?n.anchors[r.index+1]:n.closed?n.anchors[0]:void 0;if(!i&&!l)return[...e];let d=i??o,c=l??o,m=c.x-d.x,x=c.y-d.y,y=Math.hypot(m,x);if(y===0)return[...e];m/=y,x/=y;let w=i?Math.hypot(o.x-i.x,o.y-i.y)/3:0,P=l?Math.hypot(l.x-o.x,l.y-o.y)/3:0,_=i?{x:o.x-m*w,y:o.y-x*w}:void 0,C=l?{x:o.x+m*P,y:o.y+x*P}:void 0;return ci(e,r.contour,r.index,ot(o,_,C))}function Ou(e,t){let r=[];return e.forEach((n,o)=>{let a=n.anchors.filter((i,l)=>!t.has(Ae(o,l)));a.length>=2&&r.push({closed:n.closed,anchors:a})}),r}function Du(e,t,r,n,o,a,i){let l=e[t];if(!l)return[...e];let d=l.anchors.length,c=(r+1)%d;if(i)return qo(e,new Set([Ae(t,r),Ae(t,c)]),o,a);let m=Math.min(.85,Math.max(.15,n)),x=1/(3*(1-m)*m),y=l.anchors[r],w=l.anchors[c],P=An(y.out??y,o*x,a*x),_=An(w.in??w,o*x,a*x),C=Uo(e,t,r,"out",P,{smooth:Vo(y),breakSmooth:!1});return C=Uo(C,t,c,"in",_,{smooth:Vo(w),breakSmooth:!1}),C}function Pu(e,t){return e.map((r,n)=>r.closed||r.anchors.length<2?r:t.size===0||t.has(Ae(n,0))&&t.has(Ae(n,r.anchors.length-1))?{...r,closed:!0}:r)}function xi(e,t){let r=[],n=new Set,o=(a,i,l)=>{let d=e[a]?.anchors[i],c=d?.[l],m=`${Ae(a,i)}:${l}`;!d||!c||n.has(m)||(n.add(m),r.push({key:m,at:c,anchor:d}))};return e.forEach((a,i)=>{let l=a.anchors.length;a.anchors.forEach((d,c)=>{if(!t.has(Ae(i,c)))return;o(i,c,"in"),o(i,c,"out");let m=c>0?c-1:a.closed?l-1:-1,x=c<l-1?c+1:a.closed?0:-1;m>=0&&o(i,m,"out"),x>=0&&o(i,x,"in")})}),r}function Mn(e,t){let r=t.x-e.x,n=t.y-e.y,o=Math.round(Math.atan2(n,r)/(Math.PI/4))*(Math.PI/4),a=r*Math.cos(o)+n*Math.sin(o);return{x:e.x+Math.cos(o)*a,y:e.y+Math.sin(o)*a}}function Nu(e){return{closed:e.closed,anchors:[...e.anchors].reverse().map(t=>ot(t,t.out,t.in))}}function gi(e){if(!e)return null;for(let t of e.items){if(t.kind!=="file"||!t.type.startsWith("image/"))continue;let r=t.getAsFile();if(r)return r}return null}async function jo(e,t){let r;try{r=await createImageBitmap(e)}catch{return null}try{let n=Math.min(1,t/Math.max(r.width,r.height));return n>=1?{bytes:new Uint8Array(await e.arrayBuffer()),type:e.type||"image/png",width:r.width,height:r.height}:await Gx(r,n,e.type)}finally{r.close()}}async function Gx(e,t,r){let n=Math.max(1,Math.round(e.width*t)),o=Math.max(1,Math.round(e.height*t)),a=document.createElement("canvas");a.width=n,a.height=o;let i=a.getContext("2d");if(!i)return null;i.drawImage(e,0,0,n,o);let l=r==="image/png"?"image/png":"image/webp",d=await new Promise(c=>{a.toBlob(c,l,.9)});return d?{bytes:new Uint8Array(await d.arrayBuffer()),type:d.type||l,width:n,height:o}:null}function Ru(e,t,r,n){let o=Math.min(1,r/e,n/t);return{w:Math.round(e*o),h:Math.round(t*o)}}var Wx={left:"x",hcenter:"x",right:"x",top:"y",vcenter:"y",bottom:"y"};function Ko(e){return Wx[e]}function Xx(e,t,r){switch(e){case"left":return t.x;case"hcenter":return t.x+(t.w-r)/2;case"right":return t.x+t.w-r;case"top":return t.y;case"vcenter":return t.y+(t.h-r)/2;case"bottom":return t.y+t.h-r}}function yi(e,t,r){let n=Ko(r),o=new Map;for(let a of e){let i=n==="x"?a.frame.w:a.frame.h,l=n==="x"?a.frame.x:a.frame.y;o.set(a.id,Xx(r,t,i)-l)}return o}var Iu=[{key:"nw",sx:0,sy:0},{key:"ne",sx:1,sy:0},{key:"se",sx:1,sy:1},{key:"sw",sx:0,sy:1}],Yx={id:"radius",prop:"radius",handles(e,t,r){let n=this.max(e),o=Math.min(Math.max(t,r),Math.max(n,r));return Iu.map(({key:a,sx:i,sy:l})=>({id:`radius:${a}`,at:{x:e.x+(i===0?o:e.w-o),y:e.y+(l===0?o:e.h-o)}}))},valueAt(e,t,r){let n=Zx(t);if(!n)return 0;let o=e.x+(n.sx===0?0:e.w),a=e.y+(n.sy===0?0:e.h),i=Math.max(0,n.sx===0?r.x-o:o-r.x),l=Math.max(0,n.sy===0?r.y-a:a-r.y);return Math.min((i+l)/2,this.max(e))},max(e){return Math.max(0,Math.min(e.w,e.h)/2)}},Jx={canvas:[],frame:[],group:[],rect:[Yx]};function $n(e){return Jx[e.type]??[]}function Go(e,t){let r=t.split(":")[0];return $n(e).find(n=>n.id===r)}function Zx(e){let t=e.split(":")[1];return Iu.find(r=>r.key===t)}var vi=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16"}],["path",{d:"M15.697 14h5.606"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16"}],["path",{d:"M3.304 13h6.392"}]];var bi=[["path",{d:"M2 12h20"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1"}]];var wi=[["path",{d:"M12 2v20"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1"}]];var ki=[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2"}],["path",{d:"M22 22H2"}]];var Si=[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2"}],["path",{d:"M22 22V2"}]];var _i=[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2"}],["path",{d:"M17 22v-5"}],["path",{d:"M17 7V2"}],["path",{d:"M7 22v-3"}],["path",{d:"M7 5V2"}]];var Ci=[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2"}],["path",{d:"M22 2H2"}]];var Ei=[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2"}],["path",{d:"M2 2v20"}]];var Ai=[["path",{d:"M22 17h-3"}],["path",{d:"M22 7h-5"}],["path",{d:"M5 17H2"}],["path",{d:"M7 7H2"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2"}]];var Mi=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"}],["path",{d:"M2 12h20"}]];var $i=[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"}],["path",{d:"M2 22h20"}]];var Ti=[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"}],["path",{d:"M2 2h20"}]];var Li=[["circle",{cx:"15",cy:"9",r:"7"}],["circle",{cx:"9",cy:"15",r:"7"}]];var Oi=[["path",{d:"M20 6 9 17l-5-5"}]];var Di=[["path",{d:"m6 9 6 6 6-6"}]];var Pi=[["path",{d:"m9 18 6-6-6-6"}]];var Ni=[["circle",{cx:"12",cy:"12",r:"10"}]];var Ri=[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"}]];var Ii=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Fi=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}],["path",{d:"m2 2 20 20"}]];var Bi=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var Hi=[["line",{x1:"22",x2:"2",y1:"6",y2:"6"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22"}]];var Vi=[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1"}]];var Ui=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}],["circle",{cx:"9",cy:"9",r:"2"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"}]];var zi=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}]];var Wo=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1"}]];var qi=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var ji=[["path",{d:"M5 12h14"}]];var Ki=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"}]];var Gi=[["path",{d:"m18 8 4 4-4 4"}],["path",{d:"M2 12h20"}],["path",{d:"m6 8-4 4 4 4"}]];var Wi=[["path",{d:"M12 2v20"}],["path",{d:"m8 18 4 4 4-4"}],["path",{d:"m8 6 4-4 4 4"}]];var Xi=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18"}],["path",{d:"m2.3 2.3 7.286 7.286"}],["circle",{cx:"11",cy:"11",r:"2"}]];var Yi=[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z"}],["path",{d:"m2 22 .414-.414"}]];var Ji=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var Zi=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var Qi=[["path",{d:"m15 14 5-5-5-5"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13"}]];var el=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]];var tl=[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}],["path",{d:"M5 17A12 12 0 0 1 17 5"}]];var rl=[["path",{d:"M21 11a8 8 0 0 0-8-8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}]];var nl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Xo=[["path",{d:"M21 5H3"}],["path",{d:"M21 12H9"}],["path",{d:"M21 19H7"}]];var Yo=[["path",{d:"M21 5H3"}],["path",{d:"M17 12H7"}],["path",{d:"M19 19H5"}]];var Jo=[["path",{d:"M3 5h18"}],["path",{d:"M3 12h18"}],["path",{d:"M3 19h18"}]];var Tn=[["path",{d:"M21 5H3"}],["path",{d:"M15 12H3"}],["path",{d:"M17 19H3"}]];var ol=[["path",{d:"M12 4v16"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}],["path",{d:"M9 20h6"}]];var al=[["path",{d:"M9 14 4 9l5-5"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"}]];var sl=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16"}]];var il=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var Ln=e=>e.replace(/\b(?:CmdOrCtrl|CommandOrControl)\b/g,"Ctrl");function Fu(e,t){let n=e.ownerDocument.createElement("div");n.className="vd-chrome",n.setAttribute("role","toolbar"),n.setAttribute("aria-label","Canvas tools"),n.innerHTML=Qx(t),e.appendChild(n);let o=new Map;for(let m of n.querySelectorAll("[data-tool]"))o.set(m.dataset.tool,m);let a=n.querySelector('[data-act="undo"]'),i=n.querySelector('[data-act="redo"]'),l=n.querySelector('[data-act="zoom"]'),d=m=>{let x=m.target?.closest("button");if(!x)return;m.stopPropagation();let y=x.dataset.tool;if(y){t.onTool(y);return}switch(x.dataset.act){case"undo":t.onUndo();return;case"redo":t.onRedo();return;case"zoom":t.onZoomReset();return;case"play":t.onPlay?.();return}},c=m=>m.stopPropagation();return n.addEventListener("click",d),n.addEventListener("pointerdown",c),{element:n,setTool(m){for(let[x,y]of o)y.setAttribute("aria-pressed",String(x===m))},setHistory(m,x){a&&(a.disabled=!m),i&&(i.disabled=!x)},setZoom(m){l&&(l.textContent=`${Math.round(m*100)}%`)},destroy(){n.removeEventListener("click",d),n.removeEventListener("pointerdown",c),n.remove()}}}function Qx(e){let t=e.formatKeys??Ln;return[mt({tool:"select",label:"Select",hint:"V",icon:"select"}),mt({tool:"frame",label:"Frame",hint:"F",icon:"frame"}),mt({tool:"rect",label:"Rectangle",hint:"R",icon:"rect"}),mt({tool:"ellipse",label:"Ellipse",hint:"O",icon:"ellipse"}),mt({tool:"pen",label:"Pen",hint:"P",icon:"pen"}),mt({tool:"text",label:"Text",hint:"T",icon:"text"}),'<span class="vd-chrome__divider"></span>',mt({act:"undo",label:"Undo",hint:t("CmdOrCtrl+Z"),icon:"undo"}),mt({act:"redo",label:"Redo",hint:t("CmdOrCtrl+Shift+Z"),icon:"redo"}),'<span class="vd-chrome__divider"></span>','<button type="button" class="vd-chrome__zoom" data-act="zoom" title="Fit to screen">100%</button>',...e.onPlay?['<span class="vd-chrome__divider"></span>',mt({act:"play",label:"Play",hint:e.playHint,icon:"play"})]:[]].join("")}function mt(e){let t=e.tool?`data-tool="${e.tool}"`:`data-act="${e.act??""}"`,r=e.tool?' aria-pressed="false"':"";return`<button type="button" class="vd-chrome__tool" ${t}${r} title="${e.hint?`${e.label} \xB7 ${e.hint}`:e.label}" aria-label="${e.label}">`+Ue(e.icon)+"</button>"}var eg={select:Ki,frame:Hi,rect:nl,ellipse:Ni,pen:Xi,vector:tl,text:ol,undo:al,redo:Qi,"align-left":Ei,"align-hcenter":wi,"align-right":Si,"align-top":Ci,"align-vcenter":bi,"align-bottom":ki,"distribute-h":_i,"distribute-v":Ai,group:Vi,image:Ui,eye:Ii,"eye-off":Fi,lock:qi,unlock:Wo,chevron:Pi,"text-left":Tn,"text-center":Yo,"text-right":Xo,"text-justify":Jo,"text-top":Ti,"text-middle":Mi,"text-bottom":$i,unlink:sl,rotate:el,opacity:Ri,radius:rl,blend:Li,plus:Zi,minus:ji,close:il,"chevron-down":Di,check:Oi,link:zi,"font-size":vi,"line-height":Wi,"letter-spacing":Gi,eyedropper:Yi,document:Bi,play:Ji};function Ue(e){return`<svg width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">${eg[e].map(([r,n])=>{let o=Object.entries(n).filter(([a])=>a!=="key").map(([a,i])=>` ${a}="${String(i)}"`).join("");return`<${r}${o} vector-effect="non-scaling-stroke"/>`}).join("")}</svg>`}var ll="clipboard";function On(e,t){let r=new Set(t),n=[];return re(e.root,o=>{if(o.id!==e.root.id&&r.has(o.id))return n.push(o),!1}),n}function Bu(e,t){let r={};for(let a of e)re(a,i=>{for(let[l,d]of Object.entries(i)){if(ce(d)){let c=Ze(d.expr);if(!c.ok)continue;for(let m of Zt(c.ast).tokens){let x=t[m];x!==void 0&&(r[m]=x)}continue}typeof d=="string"&&o(d),l==="shadow"&&typeof d=="string"&&n(d)}for(let l of Vu(i.content))o(l)});return r;function n(a){let i=t[a],d=_r(typeof i=="string"?i:a);if(!("error"in d))for(let c of d.shadows)o(c.colour)}function o(a){for(let i of ko(a)){let l=t[i];if(l!==void 0&&(r[i]=l,!(typeof l!="string"||l===a)))for(let d of ko(l)){let c=t[d];c!==void 0&&d!==i&&(r[d]=c)}}}}function tg(e,t){let r={};for(let n of e)re(n,o=>{if(o.type!=="image"||typeof o.src!="string")return;let a=t[o.src];a!==void 0&&(r[o.src]=a)});return r}function Hu(e,t){let r={},n=o=>{if(typeof o!="string")return;let a=t[o];a!==void 0&&(r[o]=a)};for(let o of e)re(o,a=>{let i=a;n(i.font);for(let l of Vu(i.content,"font"))n(l)});return r}function Vu(e,t="fill"){if(!Array.isArray(e))return[];let r=[];for(let n of e){if(typeof n=="string")continue;let o=n[t];o!==void 0&&r.push(o)}return r}function dl(e,t,r){let n=On(e,t);if(n.length===0)return null;let o={};for(let l of n)re(l,d=>{let c=r.nodes.get(d.id)?.values;c&&Object.keys(c).length>0&&(o[d.id]=c)});let a={version:e.version,kind:e.kind,tokens:Bu(n,e.tokens),fonts:Hu(n,e.fonts),assets:tg(n,e.assets),root:{...e.root,children:n}},i=JSON.parse(rs(a));return i[ll]={resolved:o},JSON.stringify(i,null,2)}function fl(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null)return null;let r=t;if(typeof r.root!="object"||r.root===null)return null;let{document:n}=Os(t),o=n.root.children;if(o.length===0)return null;let a=r[ll],i=typeof a=="object"&&a!==null?a.resolved??{}:{};return{nodes:o,tokens:n.tokens,fonts:n.fonts,resolved:typeof i=="object"&&i!==null?i:{}}}function ul(e,t){let r=io(t.root),n=new Map;for(let i of e.nodes)re(i,l=>{let d=rg(l.id,r);r.add(d),n.set(l.id,d)});let o=i=>r.has(i),a={...e.tokens,...t.tokens};return{nodes:e.nodes.map(i=>Uu(i,{payload:e,remap:n,exists:o,tokens:a})),remap:n}}function rg(e,t){let r=e.lastIndexOf("."),n=r===-1?"":e.slice(r+1),o=/^[0-9]+$/.test(n)?e.slice(0,r):e,a=1;for(let i of t){if(!i.startsWith(`${o}.`))continue;let l=Number(i.slice(o.length+1));Number.isInteger(l)&&l>=a&&(a=l+1)}return`${o}.${a}`}function Uu(e,t){let r=e,n={};for(let[o,a]of Object.entries(r))o==="id"||o==="children"||(n[o]=ce(a)?ng(a.expr,e.id,o,t):a);return n.id=t.remap.get(e.id)??e.id,ue(e)&&(n.children=le(e).map(o=>Uu(o,t))),n}function ng(e,t,r,n){let o={expr:e},a=Ze(e);if(!a.ok)return o;let i=Zt(a.ast).nodes.some(m=>n.remap.has(m)),l=i?Mt(a.ast,m=>n.remap.get(m)):a.ast,d=Zt(l);if(d.nodes.some(m=>!n.exists(m))||d.tokens.some(m=>n.tokens[m]===void 0)){let m=n.payload.resolved[t]?.[r];return m===void 0?o:m}return i?{expr:yn(l)}:o}var ht="#ffffff",$t="#0b0d0c",Gu="#c6ff3d",og="#ffb224";var zu=new Map;function Me(e,t={}){let r=t.badge??"none",n=e==="resize"?Wu(t.angle??0):e==="rotate"?sg(t.angle??0):0,o=`${e}:${n}:${r}`,a=zu.get(o);if(a!==void 0)return a;let{at:i,fallback:l}=ag[e],d=dg(ig(e,n,r),i[0],i[1],l);return zu.set(o,d),d}var qu=[2,2],Tr=[12,12],ag={arrow:{at:qu,fallback:"default"},radius:{at:qu,fallback:"default"},resize:{at:Tr,fallback:"ew-resize"},rotate:{at:Tr,fallback:"crosshair"},crosshair:{at:Tr,fallback:"crosshair"},grab:{at:Tr,fallback:"grab"},grabbing:{at:Tr,fallback:"grabbing"},text:{at:Tr,fallback:"text"}};function sg(e){let t=(e%360+360)%360;return Math.round(t/15)*15%360}function Wu(e){let t=(e%180+180)%180;return Math.round(t/15)*15%180}function ig(e,t,r){switch(e){case"arrow":return Xu(r);case"resize":return fg(t,r);case"rotate":return ug(t);case"crosshair":return pg();case"grab":return Ku(!1);case"grabbing":return Ku(!0);case"radius":return mg(r);case"text":return cg()}}function lg(e){return`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">${e}</svg>`}function dg(e,t,r,n){return`url("data:image/svg+xml,${encodeURIComponent(lg(e))}") ${t} ${r}, ${n}`}var ju="M2 2 L2 20.4 L6.7 15.9 L9.9 22.8 L12.6 21.5 L9.5 14.8 L15.4 14.6 Z";function Xu(e){return`<path d="${ju}" fill="${ht}" stroke="${ht}" stroke-width="3" stroke-linejoin="round"/><path d="${ju}" fill="${$t}"/>`+Yu(e)}function fg(e,t){let r=["M6.6 12 H17.4","M9.7 8.7 L6.2 12 L9.7 15.3","M14.3 8.7 L17.8 12 L14.3 15.3"],n=(o,a)=>r.map(i=>`<path d="${i}" stroke="${a}" stroke-width="${o}"/>`).join("");return`<g transform="rotate(${e} 12 12)" fill="none" stroke-linecap="round" stroke-linejoin="round">`+n(3.6,ht)+n(1.6,$t)+"</g>"+Yu(t)}function ug(e){let t=["M7 17.5 A10 10 0 0 0 17.5 7","M14.2 4.6 L17.6 7 L15 10.3","M4.6 14.2 L7 17.6 L10.3 15"],r=(n,o)=>t.map(a=>`<path d="${a}" stroke="${o}" stroke-width="${n}"/>`).join("");return`<g transform="rotate(${e} 12 12)" fill="none" stroke-linecap="round" stroke-linejoin="round">`+r(3.6,ht)+r(1.6,$t)+"</g>"}function cg(){let e=["M12 4.5 V19.5","M9 4.5 H15","M9 19.5 H15"],t=(r,n)=>e.map(o=>`<path d="${o}" stroke="${n}" stroke-width="${r}"/>`).join("");return'<g fill="none" stroke-linecap="round">'+t(3.4,ht)+t(1.5,$t)+"</g>"}function pg(){let e="M12 2.5 V9 M12 15 V21.5 M2.5 12 H9 M15 12 H21.5";return`<g fill="none" stroke-linecap="round"><path d="${e}" stroke="${ht}" stroke-width="3"/><path d="${e}" stroke="${$t}" stroke-width="1.2"/></g>`}function Ku(e){let t=e?"M6.8 13.8v-1.3a1.35 1.35 0 0 1 1.35-1.35h7.7a1.35 1.35 0 0 1 1.35 1.35v2.6c0 3.2-2.2 5.2-5.1 5.2h-1.1c-1.9 0-3-.8-3.9-2.1l-1.4-2":"M9 14.6V6.4a1.25 1.25 0 0 1 2.5 0v5.1V5.1a1.25 1.25 0 0 1 2.5 0v6.4V6.2a1.25 1.25 0 0 1 2.5 0v6.6m0 0v2.3c0 3.1-2.1 5-4.8 5h-.7c-1.6 0-2.7-.6-3.6-1.9l-2.2-3a1.3 1.3 0 0 1 .45-1.85c.6-.35 1.35-.2 1.85.4L9 15.9";return`<g fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="${t}" stroke="${ht}" stroke-width="3.4"/><path d="${t}" stroke="${$t}" stroke-width="1.5"/></g>`}function mg(e){return Xu("none")+hg(e)}function hg(e){return`<g><rect x="17.5" y="17.5" width="14" height="14" rx="4.5" fill="${ht}"/><rect x="18.7" y="18.7" width="11.6" height="11.6" rx="3.4" fill="${e==="none"?Gu:og}"/><path d="M21.6 27.9 V25.4 A3.8 3.8 0 0 1 25.4 21.6 H27.9" fill="none" stroke="${$t}" stroke-width="1.5" stroke-linecap="round"/></g>`}function Yu(e){return e==="none"?"":`<g><rect x="18.5" y="18.5" width="13" height="13" rx="4" fill="${ht}"/><rect x="19.6" y="19.6" width="10.8" height="10.8" rx="3" fill="${Gu}"/><text x="25" y="28.4" text-anchor="middle" fill="${$t}" font-family="ui-sans-serif, system-ui, -apple-system, Helvetica, sans-serif" font-size="10" font-weight="700">${e==="token"?"$":"\u0192"}</text></g>`}function De(e,t){let r=[],n=o=>{if(r.push(o.id),o.id===t)return!0;for(let a of le(o))if(n(a))return!0;return r.pop(),!1};return n(e)?r:[]}function Zo(e,t,r){let n=De(t.root,e);if(n.length===0)return e;let o=r!==null&&n.includes(r)?r:xg(n,t),a=n.indexOf(o);return a===-1?e:n[a+1]??e}function xg(e,t){for(let r=e.length-2;r>=0;r-=1){let n=e[r];if(z(t.root,n)?.type==="frame")return n}return t.root.id}function Ju(e,t){let r=e.map(o=>De(t.root,o)).filter(o=>o.length>0);if(r.length===0)return t.root.id;let n=t.root.id;for(let o=0;;o+=1){let a=r[0]?.[o];if(a===void 0||r.some(i=>i[o]!==a||o===i.length-1))break;n=a}return n}function tr(e,t){let r=z(t.root,e);if(!r)return[];let n=[],o=a=>{if(ke(a)){for(let i of le(a))o(i);return}n.push(a.id)};return o(r),n}function rr(e,t,r){let n=z(t.root,e);if(!n)return;if(!ke(n)){let i=r.nodes.get(e);return i?cl(i):void 0}let o=[],a=i=>{if(!(i.id!==e&&"hidden"in i&&i.hidden===!0)){if(i.id!==e&&!ke(i)){let l=rr(i.id,t,r);l&&o.push(l);return}for(let l of le(i))a(l)}};return a(n),Qe(o)??void 0}function cl(e){let t={x:e.absX,y:e.absY,w:e.w,h:e.h},r=e.values.rotation??0;return r===0?t:hn(t,r)}function Dn(e,t,r){return t.flatMap(n=>{let o=rr(n,e,r);return o?[{id:n,frame:o}]:[]})}function pl(e,t){let r=t.filter(x=>x!==e.root.id&&z(e.root,x));if(r.length<2)return null;let n=Ju(r,e),o=z(e.root,n);if(!o)return null;let a=le(o),i=new Set(r.map(x=>Zo(x,e,n))),l=a.filter(x=>i.has(x.id));if(l.length<2)return null;let d=a.findIndex(x=>x.id===l[l.length-1]?.id),c=qt(e.root,"group"),m=[{op:"insert",parent:n,index:d+1,node:Xa({id:c,children:[]})}];return l.forEach((x,y)=>{m.push({op:"move",id:x.id,parent:c,index:y})}),{ops:m,groupId:c}}function ml(e,t){let r=z(e.root,t);if(!r||!ke(r))return[];let n=De(e.root,t),o=n[n.length-2];if(o===void 0)return[];let a=z(e.root,o);if(!a)return[];let i=le(a).findIndex(d=>d.id===t);if(i===-1)return[];let l=le(r).map((d,c)=>({op:"move",id:d.id,parent:o,index:i+c}));return l.push({op:"remove",id:t}),l}function hl(e,t,r){let n=new Map;for(let a of t){let i=De(e.root,a),l=i[i.length-2];if(l===void 0)continue;let d=n.get(l)??new Set;d.add(a),n.set(l,d)}let o=[];for(let[a,i]of n){let l=z(e.root,a);if(!l)continue;let d=le(l).map(c=>c.id);o.push(...yg(a,d,gg(d,i,r)))}return o}function gg(e,t,r){if(r==="front"||r==="back"){let i=e.filter(d=>t.has(d)),l=e.filter(d=>!t.has(d));return r==="front"?[...l,...i]:[...i,...l]}let n=r==="forward"?1:-1,o=[...e],a=o.flatMap((i,l)=>t.has(i)?[l]:[]);n===1&&a.reverse();for(let i of a){let l=i+n,d=o[l];d===void 0||t.has(d)||(o[l]=o[i],o[i]=d)}return o}function yg(e,t,r){let n=[...t],o=[];for(let a=0;a<r.length;a+=1){let i=r[a];i===void 0||n[a]===i||(n.splice(n.indexOf(i),1),n.splice(a,0,i),o.push({op:"move",id:i,parent:e,index:a}))}return o}function xl(e,t,r){let n=t.w===0?1:r.w/t.w,o=t.h===0?1:r.h/t.h,a=new Map;for(let[i,l]of e)a.set(i,{x:r.x+(l.x-t.x)*n,y:r.y+(l.y-t.y)*o,w:l.w*n,h:l.h*o});return a}var gl=6,xt=.01,ze={dx:0,dy:0,guides:[],measures:[]},Qo=["lo","mid","hi"];function yl(e,t,r){let n=[],o=(a,i)=>{let l=t.nodes.get(a);l&&n.push({id:a,frame:cl(l),isPage:i})};return e.root.w!==void 0&&e.root.h!==void 0&&o(e.root.id,!0),re(e.root,a=>{if(r.has(a.id)||"hidden"in a&&a.hidden===!0)return!1;if(a.id!==e.root.id){if(a.type==="frame"){o(a.id,!0);return}ue(a)||o(a.id,!1)}}),n}function vl(e,t,r){if(r<=0||t.length===0)return ze;let n=Lr("x",e,t,r,Qo,!0),o=Lr("y",e,t,r,Qo,!0);return wl(e,t,n,o)}function ea(e,t,r,n){if(n<=0||r.length===0)return ze;let o=t.includes("w")?["lo"]:t.includes("e")?["hi"]:[],a=t.includes("n")?["lo"]:t.includes("s")?["hi"]:[],i=Lr("x",e,r,n,o,!1),l=Lr("y",e,r,n,a,!1);return wl(e,r,i,l)}function bl(e,t,r){let n={x:e.x,y:e.y,w:0,h:0};if(r<=0||t.length===0)return ze;let o=Lr("x",n,t,r,["lo"],!1),a=Lr("y",n,t,r,["lo"],!1);return wl(n,t,o,a)}function Lr(e,t,r,n,o,a){let i={axis:e,delta:0,kind:"none"};if(o.length===0)return i;let l=vg(e,t,r,n,o),d=a?wg(e,t,r,n):null;return l&&d?Math.abs(d.delta)<Math.abs(l.delta)-xt?{axis:e,delta:d.delta,kind:"space",gap:d.gap}:{axis:e,delta:l.delta,kind:"align",at:l.at}:l?{axis:e,delta:l.delta,kind:"align",at:l.at}:d?{axis:e,delta:d.delta,kind:"space",gap:d.gap}:i}function vg(e,t,r,n,o){let a=null;for(let i of r)for(let l of Qo){let d=de(i.frame,e,l);for(let c of o){let m=d-de(t,e,c);if(Math.abs(m)>n)continue;let x=c==="mid"&&l==="mid";(a===null||bg(m,x,a))&&(a={at:d,delta:m,centred:x})}}return a?{at:a.at,delta:a.delta}:null}function bg(e,t,r){let n=Math.abs(e),o=Math.abs(r.delta);return n<o-xt?!0:n>o+xt?!1:t&&!r.centred}function wg(e,t,r,n){let o=Zu(e,t,r);if(o.length<2)return null;let a=Qu(t,e),i=de(t,e,"lo"),l=[];for(let c of kg(o,e))for(let m of o)l.push({delta:de(m,e,"hi")+c-i,gap:c}),l.push({delta:de(m,e,"lo")-c-a-i,gap:c});for(let c=0;c+1<o.length;c+=1){let m=o[c],x=o[c+1];if(!m||!x)continue;let y=de(x,e,"lo")-de(m,e,"hi")-a;y<=xt||l.push({delta:de(m,e,"hi")+y/2-i,gap:y/2})}let d=null;for(let c of l)Math.abs(c.delta)>n||(d===null||Math.abs(c.delta)<Math.abs(d.delta)-xt)&&(d=c);return d}function Zu(e,t,r){let n=kl(e);return r.filter(o=>!o.isPage&&Cg(o.frame,t,n)).map(o=>o.frame).sort((o,a)=>de(o,e,"lo")-de(a,e,"lo"))}function kg(e,t){let r=[];for(let n=0;n+1<e.length;n+=1){let o=e[n],a=e[n+1];if(!o||!a)continue;let i=de(a,t,"lo")-de(o,t,"hi");i<=xt||r.some(l=>Math.abs(l-i)<xt)||r.push(i)}return r}function wl(e,t,r,n){let o={...e,x:e.x+r.delta,y:e.y+n.delta},a=[],i=[];for(let l of[r,n]){if(l.kind==="align"&&l.at!==void 0){let d=Sg(l.axis,l.at,o,t);d&&a.push(d)}l.kind==="space"&&l.gap!==void 0&&i.push(..._g(l.axis,l.gap,o,t))}return{dx:r.delta,dy:n.delta,guides:a,measures:i}}function Sg(e,t,r,n){let o=kl(e),a=de(r,o,"lo"),i=de(r,o,"hi"),l=!1;for(let d of n)Qo.some(c=>Eg(de(d.frame,e,c),t))&&(l=!0,a=Math.min(a,de(d.frame,o,"lo")),i=Math.max(i,de(d.frame,o,"hi")));return l?{axis:e,at:t,from:a,to:i}:null}function _g(e,t,r,n){let o=kl(e),a=[...Zu(e,r,n),r].sort((l,d)=>de(l,e,"lo")-de(d,e,"lo")),i=[];for(let l=0;l+1<a.length;l+=1){let d=a[l],c=a[l+1];if(!d||!c)continue;let m=de(c,e,"lo")-de(d,e,"hi");if(Math.abs(m-t)>xt)continue;let x=Math.max(de(d,o,"lo"),de(c,o,"lo")),y=Math.min(de(d,o,"hi"),de(c,o,"hi"));i.push({axis:e,at:(x+y)/2,from:de(d,e,"hi"),to:de(c,e,"lo"),label:Ag(m)})}return i}function kl(e){return e==="x"?"y":"x"}function Qu(e,t){return t==="x"?e.w:e.h}function de(e,t,r){let n=t==="x"?e.x:e.y,o=Qu(e,t);return r==="lo"?n:r==="hi"?n+o:n+o/2}function Cg(e,t,r){return de(e,r,"lo")<de(t,r,"hi")&&de(e,r,"hi")>de(t,r,"lo")}function Eg(e,t){return Math.abs(e-t)<xt}function Ag(e){return String(Math.round(e*100)/100)}var Pn=class{limit;past=[];future=[];constructor(t=500){this.limit=t}push(t){this.past.push(t),this.past.length>this.limit&&this.past.shift(),this.future.length=0}amend(t){let r=this.past[this.past.length-1];return r?(this.past[this.past.length-1]={label:t.label,ops:[...r.ops,...t.ops],inverse:[...t.inverse,...r.inverse]},this.future.length=0,!0):!1}get canUndo(){return this.past.length>0}get top(){return this.past[this.past.length-1]??null}isTail(t){if(t.length===0||t.length>this.past.length)return!1;let r=this.past.length-t.length;return t.every((n,o)=>this.past[r+o]===n)}get canRedo(){return this.future.length>0}undo(){let t=this.past.pop();if(t)return this.future.push(t),{entry:t,ops:t.inverse}}redo(){let t=this.future.pop();if(t)return this.past.push(t),{entry:t,ops:t.ops}}snapshot(){return{past:[...this.past],future:[...this.future]}}restore(t){this.past.length=0,this.future.length=0,this.past.push(...t.past),this.future.push(...t.future)}clear(){this.past.length=0,this.future.length=0}};var ec=1,Mg=48,$g=.06,Tg=.5;function tc(e){return Math.max(Mg,Math.min(e.width,e.height)*$g)}function Sl(e,t){let r=new Set(t),n=[];for(let o of e.root.children)(r.has(o.id)||rc(o,r))&&n.push(o.id);return n}function rc(e,t){for(let r of le(e))if(t.has(r.id)||rc(r,t))return!0;return!1}function ta(e){let t=e.filter(i=>i.w>0&&i.h>0);if(t.length===0)return null;let r=Math.min(...t.map(i=>i.x)),n=Math.min(...t.map(i=>i.y)),o=Math.max(...t.map(i=>i.x+i.w)),a=Math.max(...t.map(i=>i.y+i.h));return{x:r,y:n,w:o-r,h:a-n}}function ra(e,t){let r=tc(t),n={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)},o=Sn(Math.min(n.width/e.w,n.height/e.h,ec));return{zoom:o,x:t.width/2-(e.x+e.w/2)*o,y:t.height/2-(e.y+e.h/2)*o}}function _l(e,t,r){let n=ra(e,t);return Lg(e,t,r)&&r.zoom>=n.zoom*Tg?null:n}function Lg(e,t,r){let n=e.x*r.zoom+r.x,o=e.y*r.zoom+r.y,a=(e.x+e.w)*r.zoom+r.x,i=(e.y+e.h)*r.zoom+r.y;return n>=0&&o>=0&&a<=t.width&&i<=t.height}function nc(e,t,r,n){let o=Math.exp(Math.log(e.zoom)+(Math.log(t.zoom)-Math.log(e.zoom))*r),a={x:n.width/2,y:n.height/2},i={x:(a.x-e.x)/e.zoom,y:(a.y-e.y)/e.zoom},l={x:(a.x-t.x)/t.zoom,y:(a.y-t.y)/t.zoom},d={x:i.x+(l.x-i.x)*r,y:i.y+(l.y-i.y)*r};return{zoom:o,x:a.x-d.x*o,y:a.y-d.y*o}}function oc(e){return 1-(1-e)**3}function Og(e){return!("separator"in e)}function Cl(e,t=[]){let r=t.length>0?[{separator:!0},...t]:[];if(e.count===0)return[{id:"paste",label:"Paste",keys:"CmdOrCtrl+V",disabled:!e.canPaste},{separator:!0},{id:"selectAll",label:"Select all",keys:"CmdOrCtrl+A"},...ac(e),{separator:!0},{id:"fit",label:"Fit to screen",keys:"Shift+1"},{id:"zoom100",label:"Zoom to 100%",keys:"CmdOrCtrl+0"},...r];let n=[];e.isText&&e.count===1&&n.push({id:"editText",label:"Edit text",keys:"Enter"},{separator:!0}),e.isVector&&e.count===1&&n.push({id:"editPoints",label:"Edit points",keys:"Enter"},{separator:!0}),(e.convertible??0)>0&&n.push({id:"toVector",label:"Convert to vector",keys:"CmdOrCtrl+Shift+O"},{separator:!0}),n.push({id:"cut",label:"Cut",keys:"CmdOrCtrl+X"},{id:"copy",label:"Copy",keys:"CmdOrCtrl+C"},{id:"paste",label:"Paste",keys:"CmdOrCtrl+V",disabled:!e.canPaste},{id:"duplicate",label:"Duplicate",keys:"CmdOrCtrl+D"},{separator:!0},{id:"group",label:"Group",keys:"CmdOrCtrl+G",disabled:e.count<2},{id:"ungroup",label:"Ungroup",keys:"CmdOrCtrl+Shift+G",disabled:!e.hasGroup});let o=[];if(e.hide&&o.push({id:"toggleHidden",label:e.hide==="show"?"Show":"Hide",keys:"CmdOrCtrl+Shift+H"}),e.lock&&o.push({id:"toggleLock",label:e.lock==="unlock"?"Unlock":"Lock",keys:"CmdOrCtrl+Shift+L"}),o.length>0&&n.push({separator:!0},...o),n.push({separator:!0},{id:"front",label:"Bring to front",keys:"CmdOrCtrl+]"},{id:"forward",label:"Bring forward",keys:"]"},{id:"backward",label:"Send backward",keys:"["},{id:"back",label:"Send to back",keys:"CmdOrCtrl+["}),e.bound.length>0){n.push({separator:!0});for(let a of e.bound)n.push({id:`detach:${a.prop}`,label:`Detach ${a.prop}`,hint:a.source})}return n.push(...ac(e)),n.push(...r),n.push({separator:!0},{id:"delete",label:"Delete",keys:"Delete"}),n}var Dg=4;function ac(e){let t=(e.locksHere??[]).slice(0,Dg).map(n=>({id:`unlock:${n}`,label:`Unlock ${n}`}));e.anyLocked&&t.push({id:"unlockAll",label:"Unlock all"});let r=e.hiddenCount??0;return r>0&&t.push({id:"showAll",label:`Show all hidden (${r})`}),t.length===0?[]:[{separator:!0},...t]}function El(e,t){let r=e.ownerDocument,n=t.formatKeys??Ln,o=r.createElement("div");o.className="vd-menu",o.setAttribute("role","menu"),o.hidden=!0,e.appendChild(o);let a=!1,i=[],l=-1;function d(C){o.replaceChildren(),i=[];for(let F of C){if(!Og(F)){let D=r.createElement("div");D.className="vd-menu__separator",o.appendChild(D);continue}let N=r.createElement("button");N.type="button",N.className="vd-menu__item",N.dataset.command=F.id,N.disabled=F.disabled===!0,N.setAttribute("role","menuitem");let J=r.createElement("span");J.textContent=F.label,N.appendChild(J);let A=F.hint??(F.keys===void 0?void 0:n(F.keys));if(A!==void 0){let D=r.createElement("span");D.className="vd-menu__hint",D.textContent=A,N.appendChild(D)}o.appendChild(N),N.disabled||i.push(N)}}function c(C){o.style.left=`${C.x}px`,o.style.top=`${C.y}px`;let F=e.getBoundingClientRect(),N=o.getBoundingClientRect();if(N.width===0&&N.height===0)return;let J=C.x+N.width-F.width,A=C.y+N.height-F.height;J>0&&(o.style.left=`${Math.max(0,C.x-N.width)}px`),A>0&&(o.style.top=`${Math.max(0,C.y-N.height)}px`)}function m(C){i.length!==0&&(l=(C+i.length)%i.length,i[l]?.focus())}let x=C=>{let F=C.target?.closest("button");if(!F||F.disabled)return;C.stopPropagation();let N=F.dataset.command;_(),N&&t.onCommand(N)},y=C=>C.stopPropagation(),w=C=>{C.key==="ArrowDown"?(C.preventDefault(),m(l+1)):C.key==="ArrowUp"?(C.preventDefault(),m(l-1)):C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),_(),e.focus())},P=C=>{a&&(C.target instanceof Node&&o.contains(C.target)||_())};function _(){a&&(a=!1,l=-1,o.hidden=!0,r.removeEventListener("pointerdown",P,!0),r.removeEventListener("wheel",P,!0))}return o.addEventListener("click",x),o.addEventListener("pointerdown",y),o.addEventListener("keydown",w),{element:o,get isOpen(){return a},open(C,F){d(F),o.hidden=!1,a=!0,c(C),r.addEventListener("pointerdown",P,!0),r.addEventListener("wheel",P,!0),m(0)},close:_,destroy(){_(),o.removeEventListener("click",x),o.removeEventListener("pointerdown",y),o.removeEventListener("keydown",w),o.remove()}}}var Or=2,sc=1.5,ic=1.5,lc=1.5,gc={hover:null,members:[],box:null,spacers:[],rings:[],lead:null,badge:null,caret:null,textSelection:[],draft:null,marquee:null,guides:[],measures:[],presence:null,highlight:[],parked:[],lockHint:null},dc=3.6,Pg=22,na=14,oa=15,Al=4,fc=15,uc=23,Nn=7,Ng=3.5,aa=12,Rg=4.5,sa=16,qe=18,Ml=9,$l=6.1,cc="Drop or double-click",Ig=6.4,pc=16,Tt=3,mc=5,Fg=11,hc=6,xc=6.4;function yc(e,t){let r=e.ownerDocument,n=r.createElementNS(te,"svg");n.setAttribute("class","vd-editor__overlay"),e.appendChild(n);let o=[],a=[],i=[],l=[],d=[],c=null,m=null,x=[],y=[];function w(S){let $=t({x:S.x,y:S.y}),M=t({x:S.x+S.w,y:S.y+S.h});return{x:$.x,y:$.y,w:M.x-$.x,h:M.y-$.y}}function P(S){for(;n.firstChild;)n.removeChild(n.firstChild);o=[],a=[],i=[],l=[],d=[],c=null,m=null,x=[],y=(S.pageLabels??[]).flatMap(M=>ne(M));let $=S.turn&&S.turn.angle!==0?{angle:S.turn.angle,centre:t(S.turn.centre)}:null;for(let M of S.slots??[])xe(M);S.presence&&T(S.presence);for(let M of S.highlight)me("vd-editor__highlight",Dr(w(M),Or),Or);S.lockHint&&we(S.lockHint),S.hover&&me("vd-editor__hover",Rn(w(S.hover)),ic);for(let M of S.parked)me("vd-editor__parked",Rn(w(M)),ic);for(let M of S.members)me("vd-editor__member",Dr(w(M),sc),sc);S.lead&&me("vd-editor__lead",Rn(w(S.lead)),Or);for(let M of S.guides)V(M);for(let M of S.measures)W(M);if(_($,()=>{for(let M of S.textSelection)n.appendChild(oe("vd-editor__text-selection",w(M)))}),S.box&&D(S.box),S.caret&&_($,()=>N(S.caret)),l=S.rings.map(J),i=S.spacers.map(A),S.badge&&S.box){let M=w(S.box.frame),L=c?Math.max(...[{x:M.x,y:M.y},{x:M.x+M.w,y:M.y},{x:M.x,y:M.y+M.h},{x:M.x+M.w,y:M.y+M.h}].map(H=>Pe(H,c.centre,c.angle).y)):M.y+M.h;pe(S.badge,{x:M.x+M.w/2,y:L+Ml+qe/2})}if(S.draft){let M=w(S.draft);if(S.draftEllipse){let L=r.createElementNS(te,"ellipse");L.setAttribute("class","vd-editor__draft"),L.setAttribute("cx",String(M.x+M.w/2)),L.setAttribute("cy",String(M.y+M.h/2)),L.setAttribute("rx",String(Math.abs(M.w)/2)),L.setAttribute("ry",String(Math.abs(M.h)/2)),n.appendChild(L)}else n.appendChild(oe("vd-editor__draft",M))}S.marquee&&n.appendChild(oe("vd-editor__marquee",w(S.marquee))),S.path&&(m=$,_($,()=>F(S.path)))}function _(S,$){if(!S){$();return}let M=n.childNodes.length;$();let L=r.createElementNS(te,"g");for(L.setAttribute("transform",`rotate(${S.angle} ${S.centre.x} ${S.centre.y})`);n.childNodes.length>M;)L.insertBefore(n.childNodes[n.childNodes.length-1],L.firstChild);n.appendChild(L)}function C(S,$){return $?Pe(S,$.centre,-$.angle):S}function F(S){let $=r.createElementNS(te,"path");if($.setAttribute("class","vd-editor__path"),$.setAttribute("d",ft(ut(S.contours,t))),n.appendChild($),S.pending){let L=t(S.pending.from),H=t(S.pending.to),K=S.pending.c1?t(S.pending.c1):L,b=r.createElementNS(te,"path");b.setAttribute("class","vd-editor__pending"),b.setAttribute("d",`M${L.x} ${L.y} C${K.x} ${K.y} ${H.x} ${H.y} ${H.x} ${H.y}`),n.appendChild(b)}for(let L of S.handles){let H=t(L.at),K=t(L.anchor),b=r.createElementNS(te,"line");b.setAttribute("class","vd-editor__arm"),b.setAttribute("x1",String(K.x)),b.setAttribute("y1",String(K.y)),b.setAttribute("x2",String(H.x)),b.setAttribute("y2",String(H.y)),n.appendChild(b)}for(let L of S.handles){let H=t(L.at),K=r.createElementNS(te,"circle");K.setAttribute("class","vd-editor__knob"),K.setAttribute("cx",String(H.x)),K.setAttribute("cy",String(H.y)),K.setAttribute("r",String(Ng)),n.appendChild(K)}for(let L of S.anchors){let H=t(L.at),K=oe(L.selected?"vd-editor__anchor vd-editor__anchor--on":"vd-editor__anchor",{x:Math.round(H.x-Nn/2)+.5,y:Math.round(H.y-Nn/2)+.5,w:Nn,h:Nn});K.setAttribute("data-key",L.key),n.appendChild(K)}if(S.closeAt){let L=t(S.closeAt),H=r.createElementNS(te,"circle");H.setAttribute("class","vd-editor__close"),H.setAttribute("cx",String(L.x)),H.setAttribute("cy",String(L.y)),H.setAttribute("r",String(Nn)),n.appendChild(H)}let M=L=>({x:L.x-aa/2,y:L.y-aa/2,w:aa,h:aa});d=[...[...S.handles].reverse().map(L=>({kind:"handle",key:L.key,rect:M(t(L.at))})),...[...S.anchors].reverse().map(L=>({kind:"anchor",key:L.key,rect:M(t(L.at))}))]}function N(S){let $=t({x:S.x,y:S.y}),M=t({x:S.x,y:S.y+S.h}),L=r.createElementNS(te,"line");L.setAttribute("class","vd-editor__caret");let H=Math.round($.x)+.5;L.setAttribute("x1",String(H)),L.setAttribute("y1",String($.y)),L.setAttribute("x2",String(H)),L.setAttribute("y2",String(M.y)),n.appendChild(L)}function J(S){let $=t(S.at),M=r.createElementNS(te,"circle");return M.setAttribute("class","vd-editor__ring"),M.setAttribute("cx",String($.x)),M.setAttribute("cy",String($.y)),M.setAttribute("r",String(Rg)),n.appendChild(M),{id:S.id,rect:{x:$.x-sa/2,y:$.y-sa/2,w:sa,h:sa}}}function A(S){let $=t(S.at),M=S.axis==="x"?Al:oa,L=S.axis==="x"?oa:Al,H=oe("vd-editor__spacer",{x:$.x-M/2,y:$.y-L/2,w:M,h:L});H.setAttribute("rx",String(Al/2)),n.appendChild(H),S.label!==null&&pe(S.label,S.axis==="x"?{x:$.x,y:$.y-oa/2-Ml-qe/2}:{x:$.x+oa/2+Ml+qe,y:$.y});let K=S.axis==="x"?fc:uc,b=S.axis==="x"?uc:fc;return{id:S.id,rect:{x:$.x-K/2,y:$.y-b/2,w:K,h:b}}}function D(S){let $=w(S.frame),M=S.rotation??0;c=M===0?null:{angle:M,centre:{x:$.x+$.w/2,y:$.y+$.h/2}},_(c,()=>k(S,$)),S.handles&&S.rotatable&&(x=En.map(L=>{let{u:H,v:K}=Mr(L);return{handle:L,at:{x:$.x+$.w*H,y:$.y+$.h*K}}}))}function k(S,$){if(me("vd-editor__outline",Dr($,Or),Or),!!S.handles){o=ui($).map(M=>({...M,bound:S.boundHandles.has(M.handle)}));for(let M of En){let{u:L,v:H}=Mr(M),K={x:$.x+$.w*L-$r/2,y:$.y+$.h*H-$r/2,w:$r,h:$r};n.appendChild(oe("vd-editor__halo",Dr(K,lc+1))),n.appendChild(oe("vd-editor__handle",K))}a=S.adjusters.map(M=>{let L=t(M.at),H=r.createElementNS(te,"circle");H.setAttribute("class","vd-editor__halo"),H.setAttribute("cx",String(L.x)),H.setAttribute("cy",String(L.y)),H.setAttribute("r",String(dc+lc/2+.5)),n.appendChild(H);let K=r.createElementNS(te,"circle");return K.setAttribute("class","vd-editor__adjuster"),K.setAttribute("cx",String(L.x)),K.setAttribute("cy",String(L.y)),K.setAttribute("r",String(dc)),n.appendChild(K),{id:M.id,bound:M.bound,rect:{x:L.x-na/2,y:L.y-na/2,w:na,h:na}}})}}function V(S){let $=t(S.axis==="x"?{x:S.at,y:S.from}:{x:S.from,y:S.at}),M=t(S.axis==="x"?{x:S.at,y:S.to}:{x:S.to,y:S.at}),L=r.createElementNS(te,"line");L.setAttribute("class","vd-editor__guide"),L.setAttribute("x1",String(be($.x))),L.setAttribute("y1",String(be($.y))),L.setAttribute("x2",String(be(M.x))),L.setAttribute("y2",String(be(M.y))),n.appendChild(L)}function W(S){let $=t(S.axis==="x"?{x:S.from,y:S.at}:{x:S.at,y:S.from}),M=t(S.axis==="x"?{x:S.to,y:S.at}:{x:S.at,y:S.to}),L=r.createElementNS(te,"path");L.setAttribute("class","vd-editor__measure"),L.setAttribute("d",S.axis==="x"?`M${be($.x)} ${be($.y)-Tt} V${be($.y)+Tt} M${be($.x)} ${be($.y)} H${be(M.x)} M${be(M.x)} ${be(M.y)-Tt} V${be(M.y)+Tt}`:`M${be($.x)-Tt} ${be($.y)} H${be($.x)+Tt} M${be($.x)} ${be($.y)} V${be(M.y)} M${be(M.x)-Tt} ${be(M.y)} H${be(M.x)+Tt}`),n.appendChild(L);let H=r.createElementNS(te,"text");H.setAttribute("class","vd-editor__measure-text"),H.setAttribute("x",String(($.x+M.x)/2)),H.setAttribute("y",String(($.y+M.y)/2-(S.axis==="x"?mc:0))),S.axis==="y"&&H.setAttribute("dx",String(mc)),H.textContent=S.label,n.appendChild(H)}function pe(S,$){let M=Math.max(34,S.length*$l+14),L=$.x-M/2,H=$.y-qe/2,K=oe("vd-editor__badge",{x:L,y:H,w:M,h:qe});K.setAttribute("rx",String(qe/2)),n.appendChild(K);let b=r.createElementNS(te,"text");b.setAttribute("class","vd-editor__badge-text"),b.setAttribute("x",String(L+M/2)),b.setAttribute("y",String(H+qe/2)),b.textContent=S,n.appendChild(b)}function ne(S){let $=w(S.frame),M=Math.floor($.w/xc);if(M<3)return[];let L=S.label.length>M?`${S.label.slice(0,M-1)}\u2026`:S.label,H=r.createElementNS(te,"text");H.setAttribute("class",`vd-editor__page-label vd-editor__page-label--${S.state}`),H.setAttribute("x",String($.x)),H.setAttribute("y",String($.y-hc)),H.textContent=L,n.appendChild(H);let K=Math.min($.w,L.length*xc+4),b=Fg+6;return[{id:S.id,rect:{x:$.x,y:$.y-hc-b+3,w:K,h:b}}]}function we(S){let $=Rn(w(S.frame));n.appendChild(oe("vd-editor__lock",$));let M=`${S.label} \xB7 locked`,L=M.length*$l+14,H=$.y+4,K=oe("vd-editor__lock-tag",{x:$.x+4,y:H,w:L,h:qe});K.setAttribute("rx","4"),n.appendChild(K);let b=r.createElementNS(te,"text");b.setAttribute("class","vd-editor__lock-text"),b.setAttribute("x",String($.x+4+L/2)),b.setAttribute("y",String(H+qe/2)),b.textContent=M,n.appendChild(b)}function xe(S){let $=Rn(w(S.frame)),M=oe(S.target?"vd-editor__slot vd-editor__slot--target":"vd-editor__slot",$);M.setAttribute("rx","3"),n.appendChild(M);let L=b=>b.length*Ig+16<=$.w,H=[];$.h>=20&&L(S.label)&&H.push([S.label,"vd-editor__slot-label"]),H.length>0&&$.h>=48&&L(cc)&&H.push([cc,"vd-editor__slot-hint"]);let K=$.y+$.h/2-(H.length-1)*pc/2;H.forEach(([b,U],B)=>{let R=r.createElementNS(te,"text");R.setAttribute("class",U),R.setAttribute("x",String($.x+$.w/2)),R.setAttribute("y",String(K+B*pc)),R.textContent=b,n.appendChild(R)})}function T(S){let $=S.frames.map(U=>Dr(w(U),Or));for(let U of $)n.appendChild(oe("vd-editor__presence",U));let M=$[0];if(!M||!S.label)return;let L=Math.max(34,S.label.length*$l+14),H=M.y-qe-3<0?M.y+3:M.y-qe-3,K=oe("vd-editor__presence-tag",{x:M.x,y:H,w:L,h:qe});K.setAttribute("rx","4"),n.appendChild(K);let b=r.createElementNS(te,"text");b.setAttribute("class","vd-editor__presence-text"),b.setAttribute("x",String(M.x+L/2)),b.setAttribute("y",String(H+qe/2)),b.textContent=S.label,n.appendChild(b)}function me(S,$,M){let H=S==="vd-editor__highlight"?"vd-editor__halo vd-editor__halo--highlight":S==="vd-editor__hover"||S==="vd-editor__member"?"vd-editor__halo vd-editor__halo--quiet":"vd-editor__halo";n.appendChild(oe(H,Dr($,M+1))),n.appendChild(oe(S,$))}function oe(S,$){let M=r.createElementNS(te,"rect");return M.setAttribute("class",S),M.setAttribute("x",String($.x)),M.setAttribute("y",String($.y)),M.setAttribute("width",String(Math.max(0,$.w))),M.setAttribute("height",String(Math.max(0,$.h))),M}return{element:n,render:P,hitHandle(S){let $=C(S,c);for(let M of o)if(et(M.rect,$.x,$.y))return{handle:M.handle,bound:M.bound};return null},hitAdjuster(S){let $=C(S,c);for(let M of a)if(et(M.rect,$.x,$.y))return{id:M.id,bound:M.bound};return null},hitSpacer(S){return Tl(i,S)},hitPath(S){let $=C(S,m),M=d.find(L=>et(L.rect,$.x,$.y));return M?{kind:M.kind,key:M.key}:null},hitRotate(S){let $=C(S,c),M=o.length===0?null:x;if(!M)return null;for(let L of M){let H=Math.hypot($.x-L.at.x,$.y-L.at.y);if(H<$r/2+2||H>Pg)continue;let{u:K,v:b}=Mr(L.handle);if(($.x-L.at.x)*(K*2-1)+($.y-L.at.y)*(b*2-1)>0)return L.handle}return null},hitRing(S){return Tl(l,S)},hitPageLabel(S){return Tl(y,S)},pageLabelRect(S){return y.find($=>$.id===S)?.rect??null},destroy(){n.remove(),o=[],a=[],i=[],l=[]}}}function Tl(e,t){for(let r of e)if(et(r.rect,t.x,t.y))return r.id;return null}function be(e){return Math.round(e)+.5}function Rn(e){return{x:e.x+.5,y:e.y+.5,w:Math.max(0,e.w-1),h:Math.max(0,e.h-1)}}function Dr(e,t){let r=t/2;return{x:e.x-r,y:e.y-r,w:e.w+t,h:e.h+t}}function vc(e,t){let r=[];return re(e.root,n=>{if(t.has(n.id))return!1;n.type!=="image"||ce(n.src)||e.assets[n.src]===void 0&&r.push({id:n.id,src:n.src,label:n.name??n.src})}),r}function Ol(e){if(e.length<2)return null;let t=Ll("x",e),r=Ll("y",e);return r.length===1&&t.length===e.length?bc("x",e,t):t.length===1&&r.length===e.length?bc("y",e,r):r.length>=2&&t.length>=2?Bg(e,t,r):null}function Ll(e,t){let r=[...t].sort((o,a)=>Pr(o.frame,e)-Pr(a.frame,e)),n=[];for(let o of r){let a=n[n.length-1];if(a&&Pr(o.frame,e)<a.hi-.01){n[n.length-1]={lo:a.lo,hi:Math.max(a.hi,la(o.frame,e)),from:Math.min(a.from,Pr(o.frame,ia(e))),to:Math.max(a.to,la(o.frame,ia(e))),members:[...a.members,o.id]};continue}n.push({lo:Pr(o.frame,e),hi:la(o.frame,e),from:Pr(o.frame,ia(e)),to:la(o.frame,ia(e)),members:[o.id]})}return n}function bc(e,t,r){return{kind:"run",items:t,series:[da(e,r)],order:r.flatMap(n=>n.members)}}function Bg(e,t,r){if(t.length*r.length!==e.length)return null;let n=[];for(let o of r)for(let a of t){let i=o.members.filter(l=>a.members.includes(l));if(i.length!==1||i[0]===void 0)return null;n.push(i[0])}return{kind:"grid",items:e,series:[da("x",t),da("y",r)],order:n}}function da(e,t){let r=[];for(let n=0;n+1<t.length;n+=1){let o=t[n],a=t[n+1];!o||!a||r.push(a.lo-o.hi)}return{axis:e,tracks:t,gaps:r}}function st(e,t){return e.series.find(r=>r.axis===t)}function Dl(e){let t=e[0];return t===void 0?!1:e.every(r=>Math.abs(r-t)<.01)}function Pl(e){let t=[];for(let r of e.series){let n=e.series.find(o=>o.axis!==r.axis);for(let o=0;o<r.gaps.length;o+=1){let a=r.tracks[o],i=r.tracks[o+1],l=r.gaps[o];if(!a||!i||l===void 0)continue;let d=(a.hi+i.lo)/2,c=n?n.tracks.map(m=>(m.lo+m.hi)/2):[(Math.max(a.from,i.from)+Math.min(a.to,i.to))/2];for(let m of c)t.push({id:wc(r.axis,o),axis:r.axis,index:o,gap:l,at:r.axis==="x"?{x:d,y:m}:{x:m,y:d}})}}return t}function wc(e,t){return`${e}:${t}`}function fa(e){let[t,r]=e.split(":");if(t!=="x"&&t!=="y"||r===void 0)return null;let n=Number(r);return Number.isInteger(n)&&n>=0?{axis:t,index:n}:null}function Nl(e){return e.items.map(t=>({id:t.id,at:{x:t.frame.x+t.frame.w/2,y:t.frame.y+t.frame.h/2}}))}function ua(e,t,r){let n=st(e,t);return n?ca(n,r):new Map}function ca(e,t){let r=new Map,n=e.tracks[0];if(!n)return r;let o=n.hi;for(let a=1;a<e.tracks.length;a+=1){let i=e.tracks[a];if(!i)continue;let l=o+t;for(let d of i.members)r.set(d,l-i.lo);o=l+(i.hi-i.lo)}return r}function Rl(e,t){return da(t,Ll(t,e))}function Il(e){let t=e.tracks,r=t[0],n=t[t.length-1];if(!r||!n||t.length<3)return null;let o=t.reduce((a,i)=>a+(i.hi-i.lo),0);return(n.hi-r.lo-o)/(t.length-1)}function Fl(e,t){let r=Hg(e),n=0,o=1/0;for(let a=0;a<r.length;a+=1){let i=r[a];if(!i)continue;let l=Math.hypot(i.x-t.x,i.y-t.y);l<o&&(o=l,n=a)}return n}function Hg(e){if(e.kind==="grid"){let r=st(e,"x")?.tracks??[];return(st(e,"y")?.tracks??[]).flatMap(o=>r.map(a=>({x:(a.lo+a.hi)/2,y:(o.lo+o.hi)/2})))}let t=e.series[0];return t?t.tracks.map(r=>t.axis==="x"?{x:(r.lo+r.hi)/2,y:(r.from+r.to)/2}:{x:(r.from+r.to)/2,y:(r.lo+r.hi)/2}):[]}function Bl(e,t,r){let n=[...e],[o]=n.splice(t,1);return o===void 0?[...e]:(n.splice(Math.max(0,Math.min(r,n.length)),0,o),n)}function Hl(e,t){let r=new Map(e.items.map(l=>[l.id,l.frame])),n=new Map;if(e.kind==="grid"){let l=st(e,"x")?.tracks??[],d=st(e,"y")?.tracks??[];return t.forEach((c,m)=>{let x=l[m%l.length],y=d[Math.floor(m/l.length)];x&&y&&n.set(c,{x:x.lo,y:y.lo})}),n}let o=e.series[0],a=o?.tracks[0];if(!o||!a)return n;let i=a.lo;return t.forEach((l,d)=>{let c=r.get(l);if(!c)return;let m=o.axis==="x"?c.w:c.h;n.set(l,o.axis==="x"?{x:i,y:c.y}:{x:c.x,y:i}),i+=m+(o.gaps[d]??0)}),n}function Vl(e,t,r){let n=new Map,o=e.items.find(d=>d.id===t),a=e.items.find(d=>d.id===r);if(!o||!a||t===r)return n;let i=e.kind==="grid"?["x","y"]:[e.series[0]?.axis??"x"],l=(d,c)=>({x:i.includes("x")?c.frame.x:d.frame.x,y:i.includes("y")?c.frame.y:d.frame.y});return n.set(t,l(o,a)),n.set(r,l(a,o)),n}function ia(e){return e==="x"?"y":"x"}function Pr(e,t){return t==="x"?e.x:e.y}function la(e,t){return t==="x"?e.x+e.w:e.y+e.h}var kc="vd-editor-styles",Sc=`
137
+ .vd-editor {
138
+ position: relative;
139
+ width: 100%;
140
+ height: 100%;
141
+ }
142
+
143
+ /* --- selection overlay ---------------------------------------------------- */
144
+
145
+ .vd-editor__overlay {
146
+ position: absolute;
147
+ inset: 0;
148
+ width: 100%;
149
+ height: 100%;
150
+ pointer-events: none;
151
+ overflow: visible;
152
+ }
153
+
154
+ /*
155
+ * Weights are a hierarchy, not a uniform value. Loudest first: a guide, which is
156
+ * transient and is the whole answer to "did it align"; then the selection, which
157
+ * is always there; then hover and the members of a multi-selection, which are
158
+ * context rather than the subject.
159
+ *
160
+ * crispEdges turns antialiasing off, so it belongs only on whole-pixel widths \u2014
161
+ * at 1.5 it rounds and the line comes back uneven. The overlay is drawn in
162
+ * screen space, so these are screen pixels at any zoom.
163
+ */
164
+
165
+ /* Under every selection line, just outside it: the opposite colour, so the
166
+ selection reads on a design of either colour (overlay.ts \`line\`). White by
167
+ default, for the default blue. */
168
+ .vd-editor__halo {
169
+ fill: none;
170
+ stroke: var(--vd-selection-halo, #fff);
171
+ stroke-width: 1;
172
+ }
173
+
174
+ /* As quiet as the hover and member lines they sit under. */
175
+ .vd-editor__halo--quiet {
176
+ opacity: 0.5;
177
+ }
178
+
179
+ /* A highlight's line is the agent's colour in both themes, so its edge is
180
+ always dark: a bright line with a dark rim reads on a white page and a
181
+ black one alike. */
182
+ .vd-editor__halo--highlight {
183
+ stroke: var(--vd-highlight-halo, rgb(0 0 0 / 0.6));
184
+ }
185
+
186
+ /* Previews what a click will hit, before it hits it. */
187
+ .vd-editor__hover {
188
+ fill: none;
189
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
190
+ stroke-width: 1.5;
191
+ opacity: 0.7;
192
+ }
193
+
194
+ .vd-editor__outline {
195
+ fill: none;
196
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
197
+ stroke-width: 2;
198
+ shape-rendering: crispEdges;
199
+ }
200
+
201
+ /* Individual members inside a multi-selection, under the shared box. */
202
+ .vd-editor__member {
203
+ fill: none;
204
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
205
+ stroke-width: 1.5;
206
+ opacity: 0.45;
207
+ }
208
+
209
+ .vd-editor__handle {
210
+ fill: var(--vd-handle, #fff);
211
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
212
+ stroke-width: 1.5;
213
+ }
214
+
215
+ .vd-editor__adjuster {
216
+ fill: var(--vd-handle, #fff);
217
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
218
+ stroke-width: 1.5;
219
+ }
220
+
221
+ /* --- spacing handles and rings -------------------------------------------- */
222
+
223
+ /*
224
+ * Figma draws these pink, to say "this chrome belongs to the arrangement rather
225
+ * than to any one shape". We already spend a second colour on guides, so these
226
+ * stay on the accent and earn their separateness by shape instead: a pill lying
227
+ * across the gap it holds open, and a ring at the centre of what it moves.
228
+ */
229
+ .vd-editor__spacer {
230
+ fill: var(--vd-handle, var(--vd-accent, #3b82f6));
231
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
232
+ stroke-width: 1;
233
+ opacity: 0.75;
234
+ }
235
+
236
+ .vd-editor__ring {
237
+ fill: var(--vd-surface, #ffffff);
238
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
239
+ stroke-width: 2;
240
+ }
241
+
242
+ /* The member being dragged to another slot, so it stays findable while the
243
+ others reflow around it. */
244
+ .vd-editor__lead {
245
+ fill: none;
246
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
247
+ stroke-width: 2;
248
+ shape-rendering: crispEdges;
249
+ }
250
+
251
+ /* --- paths: point mode and the pen ---------------------------------------- */
252
+
253
+ .vd-editor__path {
254
+ fill: none;
255
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
256
+ stroke-width: 1.5;
257
+ }
258
+
259
+ .vd-editor__pending {
260
+ fill: none;
261
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
262
+ stroke-width: 1;
263
+ stroke-dasharray: 4 3;
264
+ }
265
+
266
+ .vd-editor__arm {
267
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
268
+ stroke-width: 1;
269
+ }
270
+
271
+ .vd-editor__knob {
272
+ fill: var(--vd-selection, var(--vd-accent, #3b82f6));
273
+ }
274
+
275
+ .vd-editor__anchor {
276
+ fill: #fff;
277
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
278
+ stroke-width: 1;
279
+ }
280
+
281
+ .vd-editor__anchor--on {
282
+ fill: var(--vd-handle, var(--vd-selection, var(--vd-accent, #3b82f6)));
283
+ }
284
+
285
+ .vd-editor__close {
286
+ fill: none;
287
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
288
+ stroke-width: 1.5;
289
+ }
290
+
291
+ .vd-editor__draft {
292
+ fill: var(--vd-selection, var(--vd-accent, #3b82f6));
293
+ fill-opacity: 0.12;
294
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
295
+ stroke-width: 1.5;
296
+ stroke-dasharray: 4 3;
297
+ }
298
+
299
+ /*
300
+ * The caret blinks in hard steps rather than fading: a fade reads as sluggish,
301
+ * and every native text field on every platform blinks hard.
302
+ */
303
+ .vd-editor__caret {
304
+ stroke: var(--vd-ink, #18181b);
305
+ stroke-width: 1.5;
306
+ animation: vd-caret-blink 1.06s steps(2, jump-none) infinite;
307
+ }
308
+
309
+ @keyframes vd-caret-blink {
310
+ to {
311
+ opacity: 0;
312
+ }
313
+ }
314
+
315
+ /* Selected text: a translucent wash. This rule went missing when the text
316
+ styles moved (af00d34), which left the band in SVG's default fill, solid
317
+ black. Its own variable, because a host's handle colour may be too faint at
318
+ this opacity and its outline colour too heavy. */
319
+ .vd-editor__text-selection {
320
+ fill: var(--vd-text-selection, var(--vd-accent, #3b82f6));
321
+ fill-opacity: 0.35;
322
+ stroke: none;
323
+ }
324
+
325
+ /* Suppressed while typing, so the bar never blinks out under a keystroke. */
326
+ .vd-editor--typing .vd-editor__caret {
327
+ animation: none;
328
+ }
329
+
330
+ .vd-editor__marquee {
331
+ fill: var(--vd-selection, var(--vd-accent, #3b82f6));
332
+ fill-opacity: 0.1;
333
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
334
+ stroke-width: 1.25;
335
+ stroke-dasharray: 3 2;
336
+ }
337
+
338
+ .vd-editor__badge {
339
+ fill: var(--vd-selection, var(--vd-accent, #3b82f6));
340
+ /* The halo's edge, or a badge the page's own colour is not there. */
341
+ stroke: var(--vd-selection-halo, #fff);
342
+ stroke-width: 1;
343
+ }
344
+
345
+ .vd-editor__badge-text {
346
+ fill: var(--vd-on-selection, #fff);
347
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
348
+ font-size: 10px;
349
+ font-variant-numeric: tabular-nums;
350
+ dominant-baseline: middle;
351
+ text-anchor: middle;
352
+ }
353
+
354
+ /* --- page names ------------------------------------------------------------ */
355
+
356
+ /* Each page's name above its corner: quiet until the pointer is on it, in the
357
+ selection's colour once the page is chosen. The fallbacks suit the viewer's
358
+ own default surface, which is dark: a host that sets --vd-surface (or a
359
+ light surface) sets these too, as the app does. */
360
+ .vd-editor__page-label {
361
+ fill: var(--vd-page-label, rgb(255 255 255 / 0.55));
362
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
363
+ font-size: 11px;
364
+ font-weight: 500;
365
+ user-select: none;
366
+ }
367
+
368
+ .vd-editor__page-label--hover {
369
+ fill: var(--vd-page-label-hover, rgb(255 255 255 / 0.9));
370
+ }
371
+
372
+ .vd-editor__page-label--selected {
373
+ fill: var(--vd-accent, #3b82f6);
374
+ }
375
+
376
+ .vd-editor__rename {
377
+ position: absolute;
378
+ z-index: 4;
379
+ box-sizing: border-box;
380
+ height: 22px;
381
+ padding: 0 4px;
382
+ border: 1px solid var(--vd-accent, #3b82f6);
383
+ border-radius: 4px;
384
+ background: var(--vd-surface-raised, #ffffff);
385
+ color: var(--vd-ink, #1a1a1f);
386
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
387
+ font-size: 11px;
388
+ font-weight: 500;
389
+ outline: none;
390
+ }
391
+
392
+ /* --- locked and hidden ------------------------------------------------------ */
393
+
394
+ /* Selected, but not the pointer's to move: no handles, and a dashed line that
395
+ says so. The same colour as the selection, because it *is* selected. */
396
+ .vd-editor__parked {
397
+ fill: none;
398
+ stroke: var(--vd-selection, var(--vd-accent, #3b82f6));
399
+ stroke-width: 1.5;
400
+ stroke-dasharray: 4 3;
401
+ }
402
+
403
+ /* Quiet on purpose: this explains a click that went through, and a hint that
404
+ shouted would be the canvas arguing with the person who locked it. */
405
+ .vd-editor__lock {
406
+ fill: none;
407
+ stroke: var(--vd-muted, #8a8f98);
408
+ stroke-width: 1;
409
+ stroke-dasharray: 3 3;
410
+ }
411
+
412
+ .vd-editor__lock-tag {
413
+ fill: var(--vd-muted, #8a8f98);
414
+ opacity: 0.9;
415
+ }
416
+
417
+ .vd-editor__lock-text {
418
+ fill: #fff;
419
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
420
+ font-size: 10px;
421
+ font-weight: 500;
422
+ dominant-baseline: middle;
423
+ text-anchor: middle;
424
+ }
425
+
426
+ /* --- agents ------------------------------------------------------------------ */
427
+
428
+ /*
429
+ * Another hand on the document. Its own colour rather than the selection's, so
430
+ * "Claude is writing this" can never be mistaken for "you selected this" \u2014 and
431
+ * the host uses the same colour in its panel, so the eye links the two.
432
+ */
433
+ .vd-editor__presence {
434
+ fill: none;
435
+ stroke: var(--vd-agent, #8b5cf6);
436
+ stroke-width: 2;
437
+ stroke-dasharray: 6 3;
438
+ opacity: 0.85;
439
+ }
440
+
441
+ .vd-editor__presence-tag {
442
+ fill: var(--vd-agent, #8b5cf6);
443
+ }
444
+
445
+ .vd-editor__presence-text {
446
+ fill: #fff;
447
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
448
+ font-size: 10px;
449
+ font-weight: 600;
450
+ dominant-baseline: middle;
451
+ text-anchor: middle;
452
+ }
453
+
454
+ /* An image waiting for its picture. The agent's colour, because an agent
455
+ usually left it; filled with a wash so it reads as a place, not a line. */
456
+ .vd-editor__slot {
457
+ fill: var(--vd-agent-wash, rgb(139 92 246 / 0.08));
458
+ stroke: var(--vd-agent, #8b5cf6);
459
+ stroke-width: 1.5;
460
+ stroke-dasharray: 5 4;
461
+ }
462
+
463
+ .vd-editor__slot--target {
464
+ fill: var(--vd-agent-wash-strong, rgb(139 92 246 / 0.2));
465
+ stroke-width: 2.5;
466
+ stroke-dasharray: none;
467
+ }
468
+
469
+ .vd-editor__slot-label,
470
+ .vd-editor__slot-hint {
471
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
472
+ font-size: 11px;
473
+ dominant-baseline: middle;
474
+ text-anchor: middle;
475
+ }
476
+
477
+ .vd-editor__slot-label {
478
+ fill: var(--vd-agent, #8b5cf6);
479
+ font-weight: 600;
480
+ }
481
+
482
+ .vd-editor__slot-hint {
483
+ fill: var(--vd-muted, #8a8f98);
484
+ }
485
+
486
+ /* Pointed at from outside the canvas: a hovered step or change row. An
487
+ outline and never a fill: a wash laid over the design hides what it points
488
+ at, and a group's wash stacked on its children's left dark patches that
489
+ matched nothing on the page. */
490
+ .vd-editor__highlight {
491
+ fill: none;
492
+ stroke: var(--vd-highlight, var(--vd-agent, #8b5cf6));
493
+ stroke-width: 2;
494
+ shape-rendering: crispEdges;
495
+ }
496
+
497
+ /* --- guides --------------------------------------------------------------- */
498
+
499
+ /*
500
+ * A colour of their own. Guides are transient feedback about a gesture, not
501
+ * chrome that belongs to the selection, and reusing the accent would make the
502
+ * two read as the same thing.
503
+ */
504
+ /*
505
+ * The loudest thing on the canvas while a drag is happening, and deliberately.
506
+ * A centre-to-centre guide has been drawn since the beginning and was reported
507
+ * as missing, because at one pixel against artwork nobody saw it.
508
+ */
509
+ .vd-editor__guide {
510
+ stroke: var(--vd-guide, #f43f5e);
511
+ stroke-width: 2;
512
+ shape-rendering: crispEdges;
513
+ }
514
+
515
+ .vd-editor__measure {
516
+ fill: none;
517
+ stroke: var(--vd-guide, #f43f5e);
518
+ stroke-width: 1.5;
519
+ }
520
+
521
+ .vd-editor__measure-text {
522
+ fill: var(--vd-guide, #f43f5e);
523
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
524
+ font-size: 10px;
525
+ font-variant-numeric: tabular-nums;
526
+ dominant-baseline: middle;
527
+ text-anchor: middle;
528
+ paint-order: stroke;
529
+ stroke: var(--vd-surface, #ffffff);
530
+ stroke-width: 3px;
531
+ stroke-linejoin: round;
532
+ }
533
+
534
+ /* --- layers --------------------------------------------------------------- */
535
+
536
+ .vd-layers {
537
+ display: flex;
538
+ flex-direction: column;
539
+ min-height: 0;
540
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
541
+ font-size: 12px;
542
+ color: var(--vd-ink, #1a1a1f);
543
+ }
544
+
545
+ .vd-layers__tree {
546
+ flex: 1 1 auto;
547
+ min-height: 0;
548
+ overflow: auto;
549
+ padding: 4px 0 12px;
550
+ outline: none;
551
+ }
552
+
553
+ .vd-layers__tree[hidden],
554
+ .vd-layers__empty[hidden] {
555
+ display: none;
556
+ }
557
+
558
+ .vd-layers__empty {
559
+ margin: 0;
560
+ padding: 16px 14px;
561
+ line-height: 1.5;
562
+ opacity: 0.55;
563
+ }
564
+
565
+ .vd-layers__row {
566
+ --indent: calc(var(--depth, 0) * 14px);
567
+ display: flex;
568
+ align-items: center;
569
+ gap: 4px;
570
+ height: 28px;
571
+ padding: 0 6px 0 calc(4px + var(--indent));
572
+ cursor: default;
573
+ user-select: none;
574
+ position: relative;
575
+ }
576
+
577
+ .vd-layers__row:hover {
578
+ background: var(--vd-row-hover, rgb(0 0 0 / 0.04));
579
+ }
580
+
581
+ .vd-layers__row[aria-selected='true'] {
582
+ background: var(--vd-row-selected, rgb(59 130 246 / 0.14));
583
+ }
584
+
585
+ .vd-layers__tree:focus-visible .vd-layers__row[data-active='true'] {
586
+ box-shadow: inset 0 0 0 1px var(--vd-accent, #3b82f6);
587
+ }
588
+
589
+ .vd-layers__row[data-entered='true'] .vd-layers__label {
590
+ font-weight: 600;
591
+ }
592
+
593
+ /* Hidden rows fade; inherited-hidden ones fade the same, because what you see
594
+ on the canvas is the same either way. */
595
+ .vd-layers__row:not([data-hidden='no']) > :not(.vd-layers__toggles) {
596
+ opacity: 0.45;
597
+ }
598
+
599
+ .vd-layers__twisty {
600
+ display: grid;
601
+ place-items: center;
602
+ flex: 0 0 16px;
603
+ width: 16px;
604
+ height: 16px;
605
+ padding: 0;
606
+ border: 0;
607
+ background: none;
608
+ color: inherit;
609
+ opacity: 0.6;
610
+ cursor: pointer;
611
+ }
612
+
613
+ .vd-layers__twisty:disabled {
614
+ visibility: hidden;
615
+ }
616
+
617
+ .vd-layers__twisty svg {
618
+ width: 10px;
619
+ height: 10px;
620
+ transition: transform 100ms ease;
621
+ }
622
+
623
+ .vd-layers__row[aria-expanded='true'] > .vd-layers__twisty svg {
624
+ transform: rotate(90deg);
625
+ }
626
+
627
+ .vd-layers__icon {
628
+ display: grid;
629
+ place-items: center;
630
+ flex: 0 0 16px;
631
+ opacity: 0.6;
632
+ }
633
+
634
+ .vd-layers__icon svg {
635
+ width: 13px;
636
+ height: 13px;
637
+ }
638
+
639
+ .vd-layers__label {
640
+ flex: 0 1 auto;
641
+ min-width: 0;
642
+ overflow: hidden;
643
+ text-overflow: ellipsis;
644
+ white-space: nowrap;
645
+ }
646
+
647
+ .vd-layers__tag {
648
+ flex: 0 0 auto;
649
+ padding: 0 5px;
650
+ border: 1px solid currentColor;
651
+ border-radius: 4px;
652
+ font-size: 10px;
653
+ line-height: 14px;
654
+ opacity: 0.55;
655
+ }
656
+
657
+ .vd-layers__preview {
658
+ flex: 1 1 0;
659
+ min-width: 0;
660
+ overflow: hidden;
661
+ text-overflow: ellipsis;
662
+ white-space: nowrap;
663
+ opacity: 0.45;
664
+ }
665
+
666
+ .vd-layers__rename {
667
+ flex: 1 1 auto;
668
+ min-width: 0;
669
+ height: 22px;
670
+ padding: 0 6px;
671
+ border: 1px solid var(--vd-accent, #3b82f6);
672
+ border-radius: 4px;
673
+ background: var(--vd-input-bg, #fff);
674
+ color: inherit;
675
+ font: inherit;
676
+ outline: none;
677
+ }
678
+
679
+ .vd-layers__toggles {
680
+ display: flex;
681
+ gap: 2px;
682
+ margin-left: auto;
683
+ flex: 0 0 auto;
684
+ }
685
+
686
+ /* Out of the way until wanted, and never out of the way once set: a hidden or
687
+ locked row has to be recognisable at a glance down a long list. */
688
+ .vd-layers__toggle {
689
+ display: grid;
690
+ place-items: center;
691
+ width: 22px;
692
+ height: 22px;
693
+ padding: 0;
694
+ border: 0;
695
+ border-radius: 4px;
696
+ background: none;
697
+ color: inherit;
698
+ opacity: 0;
699
+ cursor: pointer;
700
+ }
701
+
702
+ .vd-layers__row:hover .vd-layers__toggle,
703
+ .vd-layers__row[data-active='true'] .vd-layers__toggle,
704
+ .vd-layers__toggle[data-state='own'] {
705
+ opacity: 0.7;
706
+ }
707
+
708
+ .vd-layers__toggle[data-state='inherited'] {
709
+ opacity: 0.3;
710
+ cursor: default;
711
+ }
712
+
713
+ .vd-layers__toggle:hover:not(:disabled) {
714
+ opacity: 1;
715
+ background: var(--vd-row-hover, rgb(0 0 0 / 0.06));
716
+ }
717
+
718
+ .vd-layers__toggle svg {
719
+ width: 14px;
720
+ height: 14px;
721
+ }
722
+
723
+ /* Where a drop lands: a line between rows, or the whole row for "inside". */
724
+ .vd-layers__row[data-drop='above']::before,
725
+ .vd-layers__row[data-drop='below']::after {
726
+ content: '';
727
+ position: absolute;
728
+ left: calc(22px + var(--indent));
729
+ right: 6px;
730
+ height: 2px;
731
+ border-radius: 1px;
732
+ background: var(--vd-accent, #3b82f6);
733
+ pointer-events: none;
734
+ }
735
+
736
+ .vd-layers__row[data-drop='above']::before {
737
+ top: -1px;
738
+ }
739
+
740
+ .vd-layers__row[data-drop='below']::after {
741
+ bottom: -1px;
742
+ }
743
+
744
+ .vd-layers__row[data-drop='inside'] {
745
+ box-shadow: inset 0 0 0 2px var(--vd-accent, #3b82f6);
746
+ border-radius: 4px;
747
+ }
748
+
749
+ @media (prefers-reduced-motion: reduce) {
750
+ .vd-layers__twisty svg {
751
+ transition: none;
752
+ }
753
+ }
754
+
755
+ /* --- inspector ------------------------------------------------------------ */
756
+
757
+ .vd-inspector {
758
+ display: flex;
759
+ flex-direction: column;
760
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
761
+ font-size: 12px;
762
+ color: var(--vd-ink, #1a1a1f);
763
+ }
764
+
765
+ .vd-inspector__header {
766
+ display: flex;
767
+ align-items: center;
768
+ gap: 10px;
769
+ padding: 12px 12px 10px;
770
+ }
771
+
772
+ .vd-inspector__type {
773
+ display: inline-grid;
774
+ place-items: center;
775
+ flex: 0 0 auto;
776
+ width: 28px;
777
+ height: 28px;
778
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
779
+ border-radius: 6px;
780
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
781
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
782
+ }
783
+
784
+ .vd-inspector__title {
785
+ display: flex;
786
+ flex-direction: column;
787
+ min-width: 0;
788
+ flex: 1 1 auto;
789
+ }
790
+
791
+ /* The name reads as a title until it is clicked, then as the field it is. */
792
+ .vd-inspector__name {
793
+ width: 100%;
794
+ margin: 0 0 0 -5px;
795
+ padding: 3px 4px;
796
+ border: 1px solid transparent;
797
+ border-radius: 5px;
798
+ background: transparent;
799
+ color: inherit;
800
+ font: inherit;
801
+ font-size: 13px;
802
+ font-weight: 600;
803
+ outline: none;
804
+ text-overflow: ellipsis;
805
+ }
806
+
807
+ .vd-inspector__name::placeholder {
808
+ color: inherit;
809
+ opacity: 1;
810
+ }
811
+
812
+ .vd-inspector__name:hover {
813
+ border-color: var(--vd-rule, rgb(0 0 0 / 0.12));
814
+ }
815
+
816
+ .vd-inspector__name:focus {
817
+ border-color: var(--vd-accent, #3b82f6);
818
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
819
+ }
820
+
821
+ .vd-inspector__name:focus::placeholder {
822
+ opacity: 0.4;
823
+ }
824
+
825
+ .vd-inspector__id {
826
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
827
+ font-size: 10.5px;
828
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
829
+ overflow: hidden;
830
+ text-overflow: ellipsis;
831
+ white-space: nowrap;
832
+ }
833
+
834
+ .vd-inspector__section {
835
+ padding: 12px;
836
+ border-top: 1px solid var(--vd-rule, rgb(0 0 0 / 0.08));
837
+ }
838
+
839
+ /*
840
+ * Every heading one way: the title on the column's left edge, any buttons on
841
+ * the right. Mono capitals, as design.md sets labels.
842
+ */
843
+ .vd-inspector__heading {
844
+ display: flex;
845
+ align-items: center;
846
+ justify-content: space-between;
847
+ gap: 8px;
848
+ height: 24px;
849
+ margin: 0 0 8px;
850
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
851
+ font-size: 10.5px;
852
+ font-weight: 500;
853
+ text-transform: uppercase;
854
+ letter-spacing: 0.06em;
855
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
856
+ }
857
+
858
+ .vd-inspector__heading-text {
859
+ min-width: 0;
860
+ overflow: hidden;
861
+ text-overflow: ellipsis;
862
+ white-space: nowrap;
863
+ }
864
+
865
+ .vd-inspector__heading-tools {
866
+ display: flex;
867
+ gap: 2px;
868
+ margin-right: -6px;
869
+ }
870
+
871
+ .vd-inspector__icon-button.vd-inspector__heading-action {
872
+ width: 24px;
873
+ height: 24px;
874
+ }
875
+
876
+ /* Two equal columns: each control is half a row or the whole of one. */
877
+ .vd-inspector__grid {
878
+ display: grid;
879
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
880
+ gap: 8px;
881
+ }
882
+
883
+ .vd-inspector__wide {
884
+ grid-column: 1 / -1;
885
+ }
886
+
887
+ .vd-inspector__row {
888
+ display: flex;
889
+ gap: 8px;
890
+ }
891
+
892
+ .vd-inspector__row > * {
893
+ flex: 1 1 0;
894
+ min-width: 0;
895
+ }
896
+
897
+ /* None, said quietly: "No stroke", "No shadow". Pressing it adds one. */
898
+ .vd-inspector__empty {
899
+ box-sizing: border-box;
900
+ display: flex;
901
+ align-items: center;
902
+ width: 100%;
903
+ height: 28px;
904
+ padding: 0 10px;
905
+ border: 1px dashed var(--vd-rule, rgb(0 0 0 / 0.12));
906
+ border-radius: 8px;
907
+ background: none;
908
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
909
+ font: inherit;
910
+ text-align: left;
911
+ cursor: default;
912
+ }
913
+
914
+ .vd-inspector__empty:hover {
915
+ border-style: solid;
916
+ color: var(--vd-ink, #1a1a1f);
917
+ }
918
+
919
+ .vd-inspector__empty:focus-visible {
920
+ outline: 2px solid var(--vd-accent, #3b82f6);
921
+ outline-offset: 1px;
922
+ }
923
+
924
+ /* A list inside a section \u2014 shadows, stops \u2014 under a line naming it. */
925
+ .vd-inspector__list {
926
+ display: flex;
927
+ flex-direction: column;
928
+ gap: 8px;
929
+ min-width: 0;
930
+ }
931
+
932
+ .vd-inspector__subhead {
933
+ display: flex;
934
+ align-items: center;
935
+ justify-content: space-between;
936
+ height: 24px;
937
+ margin: 0 -6px -4px 0;
938
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
939
+ }
940
+
941
+ .vd-inspector__subhead > .vd-inspector__icon-button {
942
+ width: 24px;
943
+ height: 24px;
944
+ }
945
+
946
+ /* A list entry\u2019s minus, inside the box at its end. */
947
+ .vd-inspector__icon-button.vd-field__remove {
948
+ width: 20px;
949
+ height: 20px;
950
+ margin-right: -4px;
951
+ border-radius: 4px;
952
+ }
953
+
954
+ .vd-field__remove svg {
955
+ width: 14px;
956
+ height: 14px;
957
+ }
958
+
959
+ .vd-inspector__note {
960
+ margin: 0 0 8px;
961
+ line-height: 1.5;
962
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
963
+ }
964
+
965
+ .vd-inspector > .vd-inspector__section .vd-inspector__subhead:first-child {
966
+ margin-top: 0;
967
+ }
968
+
969
+ p.vd-inspector__subhead {
970
+ margin: 12px 0 8px;
971
+ font-size: 11px;
972
+ }
973
+
974
+ .vd-inspector__readout {
975
+ display: grid;
976
+ grid-template-columns: 18px 1fr 18px 1fr;
977
+ gap: 4px 6px;
978
+ margin: 0 0 10px;
979
+ }
980
+
981
+ .vd-inspector__readout dt {
982
+ opacity: 0.5;
983
+ }
984
+
985
+ .vd-inspector__readout dd {
986
+ margin: 0;
987
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
988
+ font-variant-numeric: tabular-nums;
989
+ }
990
+
991
+ /* Tokens: colours as a grid of swatches ending in a blank one; numbers as
992
+ short fields; other kinds as rows. */
993
+ .vd-token-swatches {
994
+ display: grid;
995
+ grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
996
+ gap: 8px;
997
+ }
998
+
999
+ .vd-token-swatch {
1000
+ position: relative;
1001
+ min-width: 0;
1002
+ }
1003
+
1004
+ .vd-token-swatch__open,
1005
+ .vd-token-swatch--blank {
1006
+ display: flex;
1007
+ flex-direction: column;
1008
+ gap: 4px;
1009
+ width: 100%;
1010
+ min-width: 0;
1011
+ padding: 0;
1012
+ border: 0;
1013
+ background: none;
1014
+ color: inherit;
1015
+ font: inherit;
1016
+ text-align: left;
1017
+ cursor: default;
1018
+ }
1019
+
1020
+ .vd-token-swatch__chip {
1021
+ box-sizing: border-box;
1022
+ display: grid;
1023
+ place-items: center;
1024
+ height: 32px;
1025
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1026
+ border-radius: 8px;
1027
+ }
1028
+
1029
+ /* The blank tile: a dashed outline with a plus, where the next colour goes. */
1030
+ .vd-token-swatch--blank .vd-token-swatch__chip {
1031
+ border-style: dashed;
1032
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1033
+ }
1034
+
1035
+ .vd-token-swatch--blank:hover .vd-token-swatch__chip {
1036
+ border-style: solid;
1037
+ color: var(--vd-ink, #1a1a1f);
1038
+ }
1039
+
1040
+ .vd-token-swatch__open[aria-pressed='true'] .vd-token-swatch__chip,
1041
+ .vd-token-swatch--blank[aria-pressed='true'] .vd-token-swatch__chip,
1042
+ .vd-token-swatch__open:focus-visible .vd-token-swatch__chip,
1043
+ .vd-token-swatch--blank:focus-visible .vd-token-swatch__chip {
1044
+ outline: 2px solid var(--vd-accent, #3b82f6);
1045
+ outline-offset: 1px;
1046
+ }
1047
+
1048
+ .vd-token-swatch__name {
1049
+ overflow: hidden;
1050
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1051
+ font-size: 10.5px;
1052
+ text-overflow: ellipsis;
1053
+ white-space: nowrap;
1054
+ }
1055
+
1056
+ /* A tile's remove: a small x on its own surface in the chip's corner, shown on
1057
+ hover or focus, so twenty tiles are not twenty buttons until you ask. */
1058
+ .vd-inspector__icon-button.vd-token-swatch__remove {
1059
+ position: absolute;
1060
+ top: -6px;
1061
+ right: -6px;
1062
+ width: 18px;
1063
+ height: 18px;
1064
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1065
+ border-radius: 50%;
1066
+ background: var(--vd-surface-raised, #ffffff);
1067
+ opacity: 0;
1068
+ }
1069
+
1070
+ .vd-token-swatch__remove svg {
1071
+ width: 12px;
1072
+ height: 12px;
1073
+ }
1074
+
1075
+ .vd-token-swatch:hover .vd-token-swatch__remove,
1076
+ .vd-token-swatch:focus-within .vd-token-swatch__remove,
1077
+ .vd-asset:hover .vd-token-swatch__remove,
1078
+ .vd-asset:focus-within .vd-token-swatch__remove {
1079
+ opacity: 1;
1080
+ }
1081
+
1082
+ .vd-inspector__icon-button.vd-token-swatch__remove:hover {
1083
+ background: var(--vd-surface-raised, #ffffff);
1084
+ color: var(--vd-error, #dc2626);
1085
+ }
1086
+
1087
+ .vd-token-editor {
1088
+ margin-top: 12px;
1089
+ }
1090
+
1091
+ .vd-token--unused {
1092
+ opacity: 0.5;
1093
+ }
1094
+
1095
+ .vd-inspector__empty-icon {
1096
+ display: inline-flex;
1097
+ margin-right: 6px;
1098
+ }
1099
+
1100
+ .vd-inspector__empty-icon svg {
1101
+ width: 14px;
1102
+ height: 14px;
1103
+ }
1104
+
1105
+ .vd-inspector__doc-title {
1106
+ font-size: 13px;
1107
+ font-weight: 600;
1108
+ }
1109
+
1110
+ /* The document's pictures, as thumbnails. */
1111
+ .vd-asset-grid {
1112
+ display: grid;
1113
+ grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
1114
+ gap: 8px;
1115
+ }
1116
+
1117
+ .vd-asset {
1118
+ position: relative;
1119
+ min-width: 0;
1120
+ }
1121
+
1122
+ .vd-asset__open {
1123
+ display: flex;
1124
+ flex-direction: column;
1125
+ gap: 4px;
1126
+ width: 100%;
1127
+ padding: 0;
1128
+ border: 0;
1129
+ background: none;
1130
+ color: inherit;
1131
+ font: inherit;
1132
+ text-align: left;
1133
+ cursor: default;
1134
+ }
1135
+
1136
+ .vd-asset__thumb {
1137
+ box-sizing: border-box;
1138
+ display: grid;
1139
+ place-items: center;
1140
+ aspect-ratio: 1;
1141
+ overflow: hidden;
1142
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1143
+ border-radius: 8px;
1144
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
1145
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1146
+ }
1147
+
1148
+ .vd-asset__thumb img {
1149
+ width: 100%;
1150
+ height: 100%;
1151
+ object-fit: cover;
1152
+ }
1153
+
1154
+ .vd-asset__open:focus-visible .vd-asset__thumb {
1155
+ outline: 2px solid var(--vd-accent, #3b82f6);
1156
+ outline-offset: 1px;
1157
+ }
1158
+
1159
+ .vd-asset__name {
1160
+ overflow: hidden;
1161
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1162
+ font-size: 10.5px;
1163
+ text-overflow: ellipsis;
1164
+ white-space: nowrap;
1165
+ }
1166
+
1167
+
1168
+ .vd-inspector__button {
1169
+ box-sizing: border-box;
1170
+ height: 28px;
1171
+ padding: 0 12px;
1172
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1173
+ border-radius: 8px;
1174
+ background: transparent;
1175
+ color: inherit;
1176
+ font: inherit;
1177
+ cursor: default;
1178
+ }
1179
+
1180
+ .vd-inspector__button:hover {
1181
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.06));
1182
+ }
1183
+
1184
+ /*
1185
+ * Six alignments spread across the row. With three or more selected, the two
1186
+ * distributions follow after a gap, because "even out the gaps" is a
1187
+ * different question from "line these up against that edge".
1188
+ */
1189
+ .vd-inspector__align {
1190
+ justify-content: space-between;
1191
+ gap: 0;
1192
+ /* The glyphs, not their 28px targets, line up with the column's edges. */
1193
+ margin: 0 -6px;
1194
+ }
1195
+
1196
+ .vd-inspector__align > .vd-inspector__icon-button {
1197
+ flex: 0 0 28px;
1198
+ }
1199
+
1200
+ .vd-inspector__align--spread > .vd-inspector__icon-button:nth-child(7) {
1201
+ margin-left: 8px;
1202
+ }
1203
+
1204
+ .vd-inspector__icon-button {
1205
+ display: inline-flex;
1206
+ align-items: center;
1207
+ justify-content: center;
1208
+ flex: 0 0 auto;
1209
+ box-sizing: border-box;
1210
+ width: 28px;
1211
+ height: 28px;
1212
+ padding: 0;
1213
+ border: 0;
1214
+ border-radius: 6px;
1215
+ background: transparent;
1216
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1217
+ cursor: default;
1218
+ }
1219
+
1220
+ .vd-inspector__icon-button:hover:not(:disabled) {
1221
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.06));
1222
+ color: var(--vd-ink, #1a1a1f);
1223
+ }
1224
+
1225
+ .vd-inspector__icon-button:focus-visible {
1226
+ outline: 2px solid var(--vd-accent, #3b82f6);
1227
+ outline-offset: -2px;
1228
+ }
1229
+
1230
+ .vd-inspector__icon-button:disabled {
1231
+ opacity: 0.35;
1232
+ }
1233
+
1234
+ /* --- fields --------------------------------------------------------------- */
1235
+
1236
+ .vd-field {
1237
+ position: relative;
1238
+ display: flex;
1239
+ flex-wrap: wrap;
1240
+ align-items: center;
1241
+ min-width: 0;
1242
+ margin: 0;
1243
+ }
1244
+
1245
+ /* No label column (design.md): the label is the accessible name and the
1246
+ tooltip, and the box carries a mark or reads by its value. */
1247
+ .vd-field__label {
1248
+ position: absolute;
1249
+ width: 1px;
1250
+ height: 1px;
1251
+ overflow: hidden;
1252
+ clip: rect(0 0 0 0);
1253
+ white-space: nowrap;
1254
+ }
1255
+
1256
+ .vd-field__box {
1257
+ box-sizing: border-box;
1258
+ display: flex;
1259
+ align-items: center;
1260
+ gap: 6px;
1261
+ flex: 1 1 100%;
1262
+ min-width: 0;
1263
+ height: 28px;
1264
+ padding: 0 8px;
1265
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1266
+ border-radius: 8px;
1267
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
1268
+ transition: border-color 80ms ease;
1269
+ }
1270
+
1271
+ .vd-field__box:hover {
1272
+ border-color: color-mix(in srgb, var(--vd-muted, rgb(0 0 0 / 0.55)) 55%, transparent);
1273
+ }
1274
+
1275
+ .vd-field__box:focus-within,
1276
+ .vd-field__box:focus-visible {
1277
+ border-color: var(--vd-accent, #3b82f6);
1278
+ outline: none;
1279
+ }
1280
+
1281
+ .vd-field__prefix {
1282
+ flex: 0 0 auto;
1283
+ min-width: 10px;
1284
+ overflow: hidden;
1285
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1286
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1287
+ font-size: 10.5px;
1288
+ white-space: nowrap;
1289
+ user-select: none;
1290
+ }
1291
+
1292
+ .vd-field__prefix--icon {
1293
+ display: inline-flex;
1294
+ align-items: center;
1295
+ width: 14px;
1296
+ }
1297
+
1298
+ .vd-field__prefix--icon svg {
1299
+ width: 14px;
1300
+ height: 14px;
1301
+ }
1302
+
1303
+ /* Drag the mark to change the value, as in Figma. */
1304
+ .vd-field__prefix--scrub {
1305
+ cursor: ew-resize;
1306
+ }
1307
+
1308
+ .vd-field__input {
1309
+ flex: 1 1 0;
1310
+ min-width: 0;
1311
+ padding: 0;
1312
+ border: 0;
1313
+ background: none;
1314
+ color: inherit;
1315
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1316
+ font-size: 11.5px;
1317
+ font-variant-numeric: tabular-nums;
1318
+ outline: none;
1319
+ text-overflow: ellipsis;
1320
+ }
1321
+
1322
+ .vd-field__input::placeholder {
1323
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1324
+ opacity: 0.7;
1325
+ }
1326
+
1327
+ .vd-field__input:read-only {
1328
+ cursor: default;
1329
+ }
1330
+
1331
+ .vd-field__swatch {
1332
+ box-sizing: border-box;
1333
+ flex: 0 0 auto;
1334
+ width: 16px;
1335
+ height: 16px;
1336
+ border-radius: 4px;
1337
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.15));
1338
+ }
1339
+
1340
+ /*
1341
+ * What the expression currently comes to. Muted, because the expression is the
1342
+ * value and this is only its reading. A half-width box has room for one of
1343
+ * the two, so it shows the expression and the reading waits for the click
1344
+ * that widens it.
1345
+ */
1346
+ .vd-field__resolved {
1347
+ flex: 0 0 auto;
1348
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1349
+ font-size: 10.5px;
1350
+ font-variant-numeric: tabular-nums;
1351
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1352
+ }
1353
+
1354
+ .vd-field__resolved:empty,
1355
+ .vd-inspector__half:not(.vd-field--expanded) .vd-field__resolved {
1356
+ display: none;
1357
+ }
1358
+
1359
+ /* A half-width field widened over its neighbour while it is edited. */
1360
+ .vd-field--compact {
1361
+ min-height: 28px;
1362
+ }
1363
+
1364
+ .vd-field--expanded {
1365
+ z-index: 4;
1366
+ }
1367
+
1368
+ .vd-field--expanded > .vd-field__box {
1369
+ position: absolute;
1370
+ top: 0;
1371
+ }
1372
+
1373
+ .vd-field--expanded > .vd-field__error {
1374
+ margin-top: 32px;
1375
+ }
1376
+
1377
+ /* Detach: shown on a bound field when the pointer or the caret is on it. */
1378
+ .vd-field__detach {
1379
+ display: none;
1380
+ flex: 0 0 auto;
1381
+ align-items: center;
1382
+ justify-content: center;
1383
+ width: 20px;
1384
+ height: 20px;
1385
+ margin-right: -4px;
1386
+ padding: 0;
1387
+ border: 0;
1388
+ border-radius: 4px;
1389
+ background: none;
1390
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1391
+ cursor: default;
1392
+ }
1393
+
1394
+ .vd-field__detach svg {
1395
+ width: 14px;
1396
+ height: 14px;
1397
+ }
1398
+
1399
+ .vd-field:hover .vd-field__detach:not([hidden]),
1400
+ .vd-field:focus-within .vd-field__detach:not([hidden]) {
1401
+ display: inline-flex;
1402
+ }
1403
+
1404
+ .vd-field__detach:hover {
1405
+ background: var(--vd-rule, rgb(0 0 0 / 0.06));
1406
+ color: var(--vd-ink, #1a1a1f);
1407
+ }
1408
+
1409
+ /* Amber, matching the bound handles on the canvas: one colour means "bound". */
1410
+ .vd-field--bound .vd-field__box {
1411
+ border-color: var(--vd-bound, #f0b429);
1412
+ }
1413
+
1414
+ .vd-field--bound .vd-field__input {
1415
+ color: var(--vd-bound-ink, #8a6100);
1416
+ }
1417
+
1418
+ .vd-field--invalid .vd-field__box {
1419
+ border-color: var(--vd-error, #dc2626);
1420
+ }
1421
+
1422
+ .vd-field__error {
1423
+ flex: 1 1 100%;
1424
+ margin-top: 4px;
1425
+ font-size: 11px;
1426
+ color: var(--vd-error, #dc2626);
1427
+ line-height: 1.4;
1428
+ }
1429
+
1430
+ /* A dropdown: our button and list, not the operating system's menu. */
1431
+ .vd-select {
1432
+ width: 100%;
1433
+ margin: 0;
1434
+ color: inherit;
1435
+ font: inherit;
1436
+ text-align: left;
1437
+ cursor: default;
1438
+ }
1439
+
1440
+ .vd-select__value {
1441
+ flex: 1 1 auto;
1442
+ min-width: 0;
1443
+ overflow: hidden;
1444
+ text-overflow: ellipsis;
1445
+ white-space: nowrap;
1446
+ }
1447
+
1448
+ .vd-select__value--mixed {
1449
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1450
+ }
1451
+
1452
+ .vd-select__chevron {
1453
+ display: inline-flex;
1454
+ flex: 0 0 auto;
1455
+ margin-right: -2px;
1456
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1457
+ }
1458
+
1459
+ .vd-select__chevron svg {
1460
+ width: 14px;
1461
+ height: 14px;
1462
+ }
1463
+
1464
+ .vd-listbox.vd-listbox--up {
1465
+ top: auto;
1466
+ bottom: calc(100% + 4px);
1467
+ }
1468
+
1469
+ .vd-listbox {
1470
+ position: absolute;
1471
+ z-index: 6;
1472
+ top: calc(100% + 4px);
1473
+ left: 0;
1474
+ box-sizing: border-box;
1475
+ min-width: 100%;
1476
+ max-height: 264px;
1477
+ margin: 0;
1478
+ padding: 4px;
1479
+ overflow-y: auto;
1480
+ list-style: none;
1481
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1482
+ border-radius: 8px;
1483
+ background: var(--vd-surface-raised, #ffffff);
1484
+ }
1485
+
1486
+ .vd-listbox__item {
1487
+ display: flex;
1488
+ align-items: center;
1489
+ gap: 6px;
1490
+ height: 28px;
1491
+ padding: 0 10px 0 6px;
1492
+ border-radius: 6px;
1493
+ white-space: nowrap;
1494
+ cursor: default;
1495
+ }
1496
+
1497
+ .vd-listbox__item--active {
1498
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.05));
1499
+ }
1500
+
1501
+ .vd-listbox__check {
1502
+ display: inline-flex;
1503
+ width: 14px;
1504
+ visibility: hidden;
1505
+ }
1506
+
1507
+ .vd-listbox__check svg {
1508
+ width: 14px;
1509
+ height: 14px;
1510
+ }
1511
+
1512
+ .vd-listbox__item[aria-selected='true'] .vd-listbox__check {
1513
+ visibility: visible;
1514
+ }
1515
+
1516
+ /* The font menu: a search box on top, a list under it, names in their faces. */
1517
+ .vd-select__detail {
1518
+ flex: 0 1 auto;
1519
+ min-width: 0;
1520
+ overflow: hidden;
1521
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1522
+ font-size: 11px;
1523
+ text-overflow: ellipsis;
1524
+ white-space: nowrap;
1525
+ }
1526
+
1527
+ .vd-listbox--search {
1528
+ display: flex;
1529
+ flex-direction: column;
1530
+ gap: 4px;
1531
+ width: 100%;
1532
+ max-height: 320px;
1533
+ overflow: hidden;
1534
+ }
1535
+
1536
+ .vd-listbox--search[hidden] {
1537
+ display: none;
1538
+ }
1539
+
1540
+ .vd-listbox__search {
1541
+ box-sizing: border-box;
1542
+ flex: 0 0 auto;
1543
+ height: 28px;
1544
+ padding: 0 8px;
1545
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1546
+ border-radius: 6px;
1547
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
1548
+ color: inherit;
1549
+ font: inherit;
1550
+ outline: none;
1551
+ }
1552
+
1553
+ .vd-listbox__search:focus {
1554
+ border-color: var(--vd-accent, #3b82f6);
1555
+ }
1556
+
1557
+ .vd-listbox__list {
1558
+ flex: 1 1 auto;
1559
+ min-height: 0;
1560
+ margin: 0;
1561
+ padding: 0;
1562
+ overflow-y: auto;
1563
+ list-style: none;
1564
+ }
1565
+
1566
+ .vd-listbox__label {
1567
+ flex: 1 1 auto;
1568
+ min-width: 0;
1569
+ overflow: hidden;
1570
+ font-size: 13px;
1571
+ text-overflow: ellipsis;
1572
+ }
1573
+
1574
+ .vd-listbox__detail {
1575
+ flex: 0 1 auto;
1576
+ min-width: 0;
1577
+ overflow: hidden;
1578
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1579
+ font-size: 11px;
1580
+ text-overflow: ellipsis;
1581
+ }
1582
+
1583
+ .vd-listbox__group {
1584
+ padding: 8px 6px 4px;
1585
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1586
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1587
+ font-size: 10px;
1588
+ letter-spacing: 0.06em;
1589
+ text-transform: uppercase;
1590
+ }
1591
+
1592
+ .vd-listbox__group:first-child {
1593
+ padding-top: 2px;
1594
+ }
1595
+
1596
+ .vd-listbox__none {
1597
+ padding: 8px 6px;
1598
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1599
+ }
1600
+
1601
+ /* "Selection \xB7 5 characters": the fields below edit those, not the box. */
1602
+ .vd-inspector__id--run {
1603
+ color: var(--vd-ink, #1a1a1f);
1604
+ font-family: inherit;
1605
+ font-weight: 500;
1606
+ }
1607
+
1608
+ /* A flag: its label on the left in full, the switch on the right. */
1609
+ .vd-field--toggle {
1610
+ justify-content: space-between;
1611
+ gap: 8px;
1612
+ min-height: 28px;
1613
+ flex-wrap: nowrap;
1614
+ }
1615
+
1616
+ .vd-field--toggle > .vd-field__label {
1617
+ position: static;
1618
+ width: auto;
1619
+ height: auto;
1620
+ overflow: hidden;
1621
+ clip: auto;
1622
+ text-overflow: ellipsis;
1623
+ }
1624
+
1625
+ .vd-switch {
1626
+ position: relative;
1627
+ flex: 0 0 auto;
1628
+ width: 28px;
1629
+ height: 16px;
1630
+ margin: 0;
1631
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.2));
1632
+ border-radius: 8px;
1633
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.06));
1634
+ appearance: none;
1635
+ cursor: default;
1636
+ transition: background 120ms ease, border-color 120ms ease;
1637
+ }
1638
+
1639
+ .vd-switch::after {
1640
+ content: '';
1641
+ position: absolute;
1642
+ top: 2px;
1643
+ left: 2px;
1644
+ width: 10px;
1645
+ height: 10px;
1646
+ border-radius: 50%;
1647
+ background: var(--vd-muted, rgb(0 0 0 / 0.55));
1648
+ transition: transform 120ms ease, background 120ms ease;
1649
+ }
1650
+
1651
+ .vd-switch:checked {
1652
+ border-color: var(--vd-chosen, var(--vd-ink, #1a1a1f));
1653
+ background: var(--vd-chosen, var(--vd-ink, #1a1a1f));
1654
+ }
1655
+
1656
+ .vd-switch:checked::after {
1657
+ transform: translateX(12px);
1658
+ background: var(--vd-on-chosen, #ffffff);
1659
+ }
1660
+
1661
+ .vd-switch:indeterminate::after {
1662
+ transform: translateX(6px);
1663
+ }
1664
+
1665
+ .vd-switch:focus-visible {
1666
+ outline: 2px solid var(--vd-accent, #3b82f6);
1667
+ outline-offset: 2px;
1668
+ }
1669
+
1670
+ @media (prefers-reduced-motion: reduce) {
1671
+ .vd-switch,
1672
+ .vd-switch::after {
1673
+ transition: none;
1674
+ }
1675
+ }
1676
+
1677
+ /* Suggestions while typing an expression: a list under the box. */
1678
+ .vd-suggest {
1679
+ position: absolute;
1680
+ z-index: 5;
1681
+ top: calc(100% + 4px);
1682
+ left: 0;
1683
+ right: 0;
1684
+ max-height: 232px;
1685
+ margin: 0;
1686
+ padding: 4px;
1687
+ overflow-y: auto;
1688
+ list-style: none;
1689
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1690
+ border-radius: 8px;
1691
+ background: var(--vd-surface-raised, #ffffff);
1692
+ }
1693
+
1694
+ .vd-suggest__item {
1695
+ display: flex;
1696
+ align-items: center;
1697
+ gap: 8px;
1698
+ min-height: 26px;
1699
+ padding: 0 8px;
1700
+ border-radius: 5px;
1701
+ cursor: default;
1702
+ }
1703
+
1704
+ .vd-suggest__item[aria-selected='true'] {
1705
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.05));
1706
+ box-shadow: inset 0 0 0 1px var(--vd-rule, rgb(0 0 0 / 0.12));
1707
+ }
1708
+
1709
+ .vd-suggest__swatch {
1710
+ flex: 0 0 auto;
1711
+ width: 12px;
1712
+ height: 12px;
1713
+ border: 1px solid rgb(0 0 0 / 0.15);
1714
+ border-radius: 3px;
1715
+ }
1716
+
1717
+ .vd-suggest__label {
1718
+ flex: 1 1 auto;
1719
+ min-width: 0;
1720
+ overflow: hidden;
1721
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1722
+ font-size: 11.5px;
1723
+ text-overflow: ellipsis;
1724
+ white-space: nowrap;
1725
+ }
1726
+
1727
+ /* The sigil carries the kind: amber for tokens, as bound values are. */
1728
+ .vd-suggest__item[data-kind='token'] .vd-suggest__label {
1729
+ color: var(--vd-bound-ink, #8a6100);
1730
+ }
1731
+
1732
+ .vd-suggest__detail {
1733
+ flex: 0 1 auto;
1734
+ min-width: 0;
1735
+ overflow: hidden;
1736
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1737
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1738
+ font-size: 10.5px;
1739
+ text-overflow: ellipsis;
1740
+ white-space: nowrap;
1741
+ }
1742
+
1743
+ /* A swatch that opens the picker. */
1744
+ button.vd-field__swatch {
1745
+ padding: 0;
1746
+ appearance: none;
1747
+ cursor: pointer;
1748
+ }
1749
+
1750
+ button.vd-field__swatch:focus-visible {
1751
+ outline: 2px solid var(--vd-accent, #3b82f6);
1752
+ outline-offset: 1px;
1753
+ }
1754
+
1755
+ /* No colour: a hollow square with a quiet slash, still there to press. It is a
1756
+ state, not an error, so it is muted rather than red. */
1757
+ .vd-field__swatch--empty {
1758
+ background: linear-gradient(
1759
+ to top right,
1760
+ transparent calc(50% - 0.75px),
1761
+ var(--vd-muted, rgb(0 0 0 / 0.55)) calc(50% - 0.75px),
1762
+ var(--vd-muted, rgb(0 0 0 / 0.55)) calc(50% + 0.75px),
1763
+ transparent calc(50% + 0.75px)
1764
+ );
1765
+ }
1766
+
1767
+ /* --- colour picker -------------------------------------------------------- */
1768
+
1769
+ /* The gradient editor: the stops on a bar, the angle on a dial or the centre on
1770
+ a pad, and the selected stop's place. */
1771
+ .vd-picker__gradient-editor {
1772
+ display: flex;
1773
+ flex-direction: column;
1774
+ gap: 10px;
1775
+ }
1776
+
1777
+ .vd-picker__gradient-editor[hidden] {
1778
+ display: none;
1779
+ }
1780
+
1781
+ .vd-picker__stops {
1782
+ position: relative;
1783
+ height: 28px;
1784
+ margin: 0 8px;
1785
+ }
1786
+
1787
+ .vd-picker__track {
1788
+ position: absolute;
1789
+ inset: 4px -8px;
1790
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1791
+ border-radius: 6px;
1792
+ background:
1793
+ var(--vd-picker-gradient, transparent),
1794
+ repeating-conic-gradient(#d4d4d4 0 25%, #ffffff 0 50%) 0 0 / 8px 8px;
1795
+ cursor: copy;
1796
+ }
1797
+
1798
+ /* A stop: its colour in a square with a ring, centred on its place. */
1799
+ .vd-picker__stop {
1800
+ position: absolute;
1801
+ top: 2px;
1802
+ box-sizing: border-box;
1803
+ width: 16px;
1804
+ height: 24px;
1805
+ margin-left: -8px;
1806
+ padding: 0;
1807
+ border: 2px solid var(--vd-surface-raised, #ffffff);
1808
+ border-radius: 5px;
1809
+ background:
1810
+ linear-gradient(var(--vd-picker-stop, #000), var(--vd-picker-stop, #000)),
1811
+ repeating-conic-gradient(#d4d4d4 0 25%, #ffffff 0 50%) 0 0 / 6px 6px;
1812
+ /* A ring, not a shadow: an outline drawn just outside the white border. */
1813
+ outline: 1px solid var(--vd-rule, rgb(0 0 0 / 0.25));
1814
+ cursor: ew-resize;
1815
+ }
1816
+
1817
+ .vd-picker__stop[aria-pressed='true'],
1818
+ .vd-picker__stop:focus-visible {
1819
+ outline: 2px solid var(--vd-accent, #3b82f6);
1820
+ z-index: 1;
1821
+ }
1822
+
1823
+ .vd-picker__stop--leaving {
1824
+ opacity: 0.35;
1825
+ }
1826
+
1827
+ .vd-picker__shape,
1828
+ .vd-picker__stop-row {
1829
+ display: flex;
1830
+ align-items: center;
1831
+ gap: 8px;
1832
+ }
1833
+
1834
+ .vd-picker__stop-label {
1835
+ flex: 1 1 auto;
1836
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1837
+ font-size: 11px;
1838
+ }
1839
+
1840
+ .vd-picker__dial {
1841
+ position: relative;
1842
+ flex: 0 0 auto;
1843
+ box-sizing: border-box;
1844
+ width: 32px;
1845
+ height: 32px;
1846
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1847
+ border-radius: 50%;
1848
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
1849
+ cursor: grab;
1850
+ }
1851
+
1852
+ .vd-picker__dial:focus-visible,
1853
+ .vd-picker__pad:focus-visible {
1854
+ outline: 2px solid var(--vd-accent, #3b82f6);
1855
+ outline-offset: 1px;
1856
+ }
1857
+
1858
+ /* The hand points where the gradient goes: up at 0\xB0, right at 90\xB0. */
1859
+ .vd-picker__hand {
1860
+ position: absolute;
1861
+ top: 3px;
1862
+ left: calc(50% - 1px);
1863
+ width: 2px;
1864
+ height: 13px;
1865
+ border-radius: 1px;
1866
+ background: var(--vd-ink, #1a1a1f);
1867
+ transform-origin: 50% 100%;
1868
+ }
1869
+
1870
+ .vd-picker__angle,
1871
+ .vd-picker__position {
1872
+ box-sizing: border-box;
1873
+ flex: 0 0 64px;
1874
+ width: 64px;
1875
+ height: 26px;
1876
+ padding: 0 8px;
1877
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1878
+ border-radius: 6px;
1879
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
1880
+ color: inherit;
1881
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1882
+ font-size: 11.5px;
1883
+ outline: none;
1884
+ }
1885
+
1886
+ .vd-picker__angle:focus,
1887
+ .vd-picker__position:focus {
1888
+ border-color: var(--vd-accent, #3b82f6);
1889
+ }
1890
+
1891
+ .vd-picker__pad {
1892
+ position: relative;
1893
+ flex: 1 1 auto;
1894
+ height: 72px;
1895
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1896
+ border-radius: 6px;
1897
+ background:
1898
+ var(--vd-picker-gradient, transparent),
1899
+ repeating-conic-gradient(#d4d4d4 0 25%, #ffffff 0 50%) 0 0 / 8px 8px;
1900
+ cursor: crosshair;
1901
+ }
1902
+
1903
+ .vd-picker__icon {
1904
+ display: inline-flex;
1905
+ align-items: center;
1906
+ justify-content: center;
1907
+ flex: 0 0 26px;
1908
+ height: 26px;
1909
+ padding: 0;
1910
+ border: 0;
1911
+ border-radius: 6px;
1912
+ background: none;
1913
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1914
+ }
1915
+
1916
+ .vd-picker__icon svg {
1917
+ width: 14px;
1918
+ height: 14px;
1919
+ }
1920
+
1921
+ .vd-picker__icon:hover:not(:disabled) {
1922
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.06));
1923
+ color: var(--vd-ink, #1a1a1f);
1924
+ }
1925
+
1926
+ .vd-picker__icon:disabled {
1927
+ opacity: 0.35;
1928
+ }
1929
+
1930
+ /* Solid, Linear, Radial: the tabs over a paint that can be a gradient. */
1931
+ .vd-picker__kinds {
1932
+ flex: 0 0 auto;
1933
+ }
1934
+
1935
+ .vd-picker__custom {
1936
+ display: flex;
1937
+ flex-direction: column;
1938
+ gap: 8px;
1939
+ }
1940
+
1941
+ .vd-picker__custom[hidden],
1942
+ .vd-picker__save[hidden] {
1943
+ display: none;
1944
+ }
1945
+
1946
+
1947
+ .vd-picker {
1948
+ position: absolute;
1949
+ z-index: 6;
1950
+ top: calc(100% + 4px);
1951
+ left: 0;
1952
+ right: 0;
1953
+ min-width: 232px;
1954
+ box-sizing: border-box;
1955
+ display: flex;
1956
+ flex-direction: column;
1957
+ gap: 8px;
1958
+ padding: 10px;
1959
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1960
+ border-radius: 10px;
1961
+ background: var(--vd-surface-raised, #ffffff);
1962
+ color: var(--vd-ink, #1a1a1f);
1963
+ }
1964
+
1965
+ .vd-picker--inline {
1966
+ position: static;
1967
+ min-width: 0;
1968
+ margin-top: 8px;
1969
+ }
1970
+
1971
+ .vd-picker__head {
1972
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1973
+ font-size: 10.5px;
1974
+ font-weight: 500;
1975
+ text-transform: uppercase;
1976
+ letter-spacing: 0.06em;
1977
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
1978
+ }
1979
+
1980
+ .vd-picker__filter,
1981
+ .vd-picker__inputs input,
1982
+ .vd-picker__save input {
1983
+ box-sizing: border-box;
1984
+ min-width: 0;
1985
+ height: 26px;
1986
+ padding: 0 8px;
1987
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
1988
+ border-radius: 6px;
1989
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
1990
+ color: inherit;
1991
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1992
+ font-size: 11.5px;
1993
+ outline: none;
1994
+ }
1995
+
1996
+ .vd-picker__filter:focus,
1997
+ .vd-picker__inputs input:focus,
1998
+ .vd-picker__save input:focus {
1999
+ border-color: var(--vd-accent, #3b82f6);
2000
+ }
2001
+
2002
+ /* Tokens as colour rects: the expression shown as the colour it names. */
2003
+ .vd-picker__tokens {
2004
+ display: grid;
2005
+ grid-template-columns: repeat(auto-fill, minmax(22px, 1fr));
2006
+ gap: 6px;
2007
+ }
2008
+
2009
+ .vd-picker__token {
2010
+ aspect-ratio: 1;
2011
+ padding: 0;
2012
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
2013
+ border-radius: 5px;
2014
+ cursor: pointer;
2015
+ }
2016
+
2017
+ .vd-picker__token[aria-pressed='true'],
2018
+ .vd-picker__token:focus-visible {
2019
+ outline: 2px solid var(--vd-accent, #3b82f6);
2020
+ outline-offset: 1px;
2021
+ }
2022
+
2023
+ .vd-picker__square {
2024
+ position: relative;
2025
+ height: 128px;
2026
+ border-radius: 6px;
2027
+ background-image:
2028
+ linear-gradient(to top, #000, transparent),
2029
+ linear-gradient(to right, #fff, transparent);
2030
+ touch-action: none;
2031
+ cursor: crosshair;
2032
+ }
2033
+
2034
+ .vd-picker__strip {
2035
+ position: relative;
2036
+ height: 12px;
2037
+ border-radius: 6px;
2038
+ touch-action: none;
2039
+ cursor: ew-resize;
2040
+ }
2041
+
2042
+ .vd-picker__hue {
2043
+ background: linear-gradient(
2044
+ to right,
2045
+ #f00 0%,
2046
+ #ff0 17%,
2047
+ #0f0 33%,
2048
+ #0ff 50%,
2049
+ #00f 67%,
2050
+ #f0f 83%,
2051
+ #f00 100%
2052
+ );
2053
+ }
2054
+
2055
+ /* Alpha over a checkerboard, so transparency reads as transparency. */
2056
+ .vd-picker__alpha {
2057
+ background:
2058
+ linear-gradient(to right, transparent, var(--vd-picker-solid, #000)),
2059
+ repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 8px 8px;
2060
+ }
2061
+
2062
+ .vd-picker__thumb {
2063
+ position: absolute;
2064
+ top: 50%;
2065
+ width: 12px;
2066
+ height: 12px;
2067
+ border: 2px solid #fff;
2068
+ border-radius: 50%;
2069
+ outline: 1px solid rgb(0 0 0 / 0.35);
2070
+ transform: translate(-50%, -50%);
2071
+ pointer-events: none;
2072
+ }
2073
+
2074
+ .vd-picker__square > .vd-picker__thumb {
2075
+ top: 0;
2076
+ }
2077
+
2078
+ .vd-picker__square:focus-visible,
2079
+ .vd-picker__strip:focus-visible {
2080
+ outline: 2px solid var(--vd-accent, #3b82f6);
2081
+ outline-offset: 2px;
2082
+ }
2083
+
2084
+ .vd-picker__inputs {
2085
+ display: flex;
2086
+ gap: 6px;
2087
+ }
2088
+
2089
+ .vd-picker__hex {
2090
+ flex: 1 1 auto;
2091
+ }
2092
+
2093
+ .vd-picker__percent {
2094
+ flex: 0 0 56px;
2095
+ width: 56px;
2096
+ }
2097
+
2098
+ .vd-picker__dropper {
2099
+ flex: 0 0 26px;
2100
+ height: 26px;
2101
+ padding: 0;
2102
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
2103
+ border-radius: 6px;
2104
+ display: inline-flex;
2105
+ align-items: center;
2106
+ justify-content: center;
2107
+ background: none;
2108
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
2109
+ cursor: pointer;
2110
+ }
2111
+
2112
+ .vd-picker__save {
2113
+ display: flex;
2114
+ flex-direction: column;
2115
+ gap: 4px;
2116
+ }
2117
+
2118
+ .vd-picker__error {
2119
+ color: var(--vd-error, #dc2626);
2120
+ line-height: 1.4;
2121
+ }
2122
+
2123
+ /* A small closed set, shown whole. */
2124
+ .vd-field--segmented {
2125
+ margin-bottom: 0;
2126
+ }
2127
+
2128
+ .vd-segmented {
2129
+ box-sizing: border-box;
2130
+ display: flex;
2131
+ flex: 1 1 0;
2132
+ min-width: 0;
2133
+ height: 28px;
2134
+ padding: 2px;
2135
+ gap: 2px;
2136
+ border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
2137
+ border-radius: 8px;
2138
+ background: var(--vd-input-bg, rgb(0 0 0 / 0.02));
2139
+ }
2140
+
2141
+ .vd-field--segmented > .vd-segmented {
2142
+ flex: 1 1 100%;
2143
+ }
2144
+
2145
+ .vd-segmented__option svg {
2146
+ width: 14px;
2147
+ height: 14px;
2148
+ }
2149
+
2150
+ .vd-segmented__option {
2151
+ display: inline-flex;
2152
+ align-items: center;
2153
+ justify-content: center;
2154
+ flex: 1 1 0;
2155
+ min-width: 0;
2156
+ padding: 0 4px;
2157
+ border: 0;
2158
+ border-radius: 6px;
2159
+ background: none;
2160
+ color: var(--vd-muted, rgb(0 0 0 / 0.55));
2161
+ font: inherit;
2162
+ font-size: 11px;
2163
+ cursor: default;
2164
+ }
2165
+
2166
+ .vd-segmented__option:hover {
2167
+ color: var(--vd-ink, #1a1a1f);
2168
+ }
2169
+
2170
+ .vd-segmented__option[aria-pressed='true'] {
2171
+ background: var(--vd-surface-raised, rgb(0 0 0 / 0.08));
2172
+ color: var(--vd-ink, #1a1a1f);
2173
+ box-shadow: inset 0 0 0 1px var(--vd-rule, rgb(0 0 0 / 0.12));
2174
+ }
2175
+
2176
+ /* --- context menu --------------------------------------------------------- */
2177
+
2178
+ .vd-menu {
2179
+ position: absolute;
2180
+ z-index: 3;
2181
+ min-width: 200px;
2182
+ padding: 4px;
2183
+ border-radius: 8px;
2184
+ background: var(--vd-chrome-bg, #202027);
2185
+ border: 1px solid rgb(255 255 255 / 0.08);
2186
+ box-shadow: var(--vd-chrome-shadow, 0 10px 30px rgb(0 0 0 / 0.35));
2187
+ font-family: var(--vd-font, system-ui, -apple-system, sans-serif);
2188
+ font-size: 12px;
2189
+ user-select: none;
2190
+ }
2191
+
2192
+ .vd-menu[hidden] {
2193
+ display: none;
2194
+ }
2195
+
2196
+ .vd-menu__item {
2197
+ display: flex;
2198
+ align-items: center;
2199
+ justify-content: space-between;
2200
+ gap: 24px;
2201
+ width: 100%;
2202
+ padding: 6px 10px;
2203
+ border: 0;
2204
+ border-radius: 5px;
2205
+ background: none;
2206
+ color: rgb(255 255 255 / 0.86);
2207
+ font: inherit;
2208
+ text-align: left;
2209
+ cursor: default;
2210
+ }
2211
+
2212
+ .vd-menu__item:hover:not(:disabled),
2213
+ .vd-menu__item:focus-visible {
2214
+ background: var(--vd-menu-active, var(--vd-accent, #3b82f6));
2215
+ color: var(--vd-menu-active-ink, #fff);
2216
+ outline: none;
2217
+ }
2218
+
2219
+ .vd-menu__item:disabled {
2220
+ color: rgb(255 255 255 / 0.28);
2221
+ }
2222
+
2223
+ /* The expression you are about to lose, or the shortcut that does the same. */
2224
+ .vd-menu__hint {
2225
+ color: rgb(255 255 255 / 0.4);
2226
+ font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
2227
+ font-size: 11px;
2228
+ max-width: 190px;
2229
+ overflow: hidden;
2230
+ text-overflow: ellipsis;
2231
+ white-space: nowrap;
2232
+ }
2233
+
2234
+ .vd-menu__item:hover:not(:disabled) .vd-menu__hint,
2235
+ .vd-menu__item:focus-visible .vd-menu__hint {
2236
+ color: rgb(255 255 255 / 0.75);
2237
+ }
2238
+
2239
+ .vd-menu__separator {
2240
+ height: 1px;
2241
+ margin: 4px 6px;
2242
+ background: rgb(255 255 255 / 0.1);
2243
+ }
2244
+
2245
+ /* --- floating toolbar ----------------------------------------------------- */
2246
+
2247
+ .vd-chrome {
2248
+ position: absolute;
2249
+ left: 50%;
2250
+ bottom: 20px;
2251
+ transform: translateX(-50%);
2252
+ z-index: 5;
2253
+ display: flex;
2254
+ align-items: center;
2255
+ gap: 2px;
2256
+ padding: 5px;
2257
+ border-radius: 12px;
2258
+ border: 1px solid rgb(255 255 255 / 0.08);
2259
+ background: var(--vd-chrome-bg, #2c2c33);
2260
+ box-shadow: var(
2261
+ --vd-chrome-shadow,
2262
+ 0 1px 2px rgb(0 0 0 / 0.3),
2263
+ 0 10px 30px rgb(0 0 0 / 0.35)
2264
+ );
2265
+ color: var(--vd-chrome-ink, #d8d8de);
2266
+ user-select: none;
2267
+ }
2268
+
2269
+ .vd-chrome__tool {
2270
+ display: grid;
2271
+ place-items: center;
2272
+ width: 32px;
2273
+ height: 32px;
2274
+ padding: 0;
2275
+ border: 0;
2276
+ border-radius: 8px;
2277
+ background: transparent;
2278
+ color: inherit;
2279
+ cursor: pointer;
2280
+ }
2281
+
2282
+ .vd-chrome__tool:hover:not(:disabled) {
2283
+ background: rgb(255 255 255 / 0.09);
2284
+ color: #fff;
2285
+ }
2286
+
2287
+ .vd-chrome__tool[aria-pressed='true'] {
2288
+ background: var(--vd-chrome-active, var(--vd-accent, #3b82f6));
2289
+ color: var(--vd-chrome-active-ink, #fff);
2290
+ }
2291
+
2292
+ .vd-chrome__tool:disabled {
2293
+ opacity: 0.32;
2294
+ cursor: default;
2295
+ }
2296
+
2297
+ .vd-chrome__divider {
2298
+ width: 1px;
2299
+ height: 20px;
2300
+ margin: 0 4px;
2301
+ background: rgb(255 255 255 / 0.12);
2302
+ }
2303
+
2304
+ .vd-chrome__zoom {
2305
+ min-width: 54px;
2306
+ height: 32px;
2307
+ padding: 0 8px;
2308
+ border: 0;
2309
+ border-radius: 8px;
2310
+ background: transparent;
2311
+ color: inherit;
2312
+ font: 500 12px/1 var(--vd-font, ui-sans-serif, system-ui, sans-serif);
2313
+ font-variant-numeric: tabular-nums;
2314
+ cursor: pointer;
2315
+ }
2316
+
2317
+ .vd-chrome__zoom:hover {
2318
+ background: rgb(255 255 255 / 0.09);
2319
+ color: #fff;
2320
+ }
2321
+ `;function pa(e){if(e.getElementById(kc))return;let t=e.createElement("style");t.id=kc,t.textContent=Sc,e.head.appendChild(t)}var Lt=["font","size","weight","italic","underline","strike","fill","letterSpacing","link"];function or(e){return typeof e=="string"?e===""?[]:[{text:e}]:e.flatMap(t=>typeof t=="string"?t===""?[]:[{text:t}]:t.text===""?[]:[t])}function ar(e){return typeof e=="string"?e:e.map(t=>typeof t=="string"?t:t.text).join("")}function sr(e){return ar(e).length}function nr(e){let t={};for(let r of Lt){let n=e[r];n!==void 0&&(t[r]=n)}return t}function Ec(e,t){return Lt.every(r=>e[r]===t[r])}function Vg(e,t){let r={text:e};for(let n of Lt){let o=t[n];o!==void 0&&(r[n]=o)}return r}function In(e){let t=or(e),r=[];for(let o of t){let a=r[r.length-1];if(a&&Ec(nr(a),nr(o))){r[r.length-1]={...a,text:a.text+o.text};continue}r.push(o)}if(r.length===0)return"";let n=r[0];return r.length===1&&_c(n)?n.text:r.map(o=>_c(o)?o.text:o)}function _c(e){return Lt.every(t=>e[t]===void 0)}function Ul(e,t,r){let[n,o]=ma(t,r,sr(e)),a=[],i=0;for(let l of or(e)){let d=i+l.text.length,c=Math.max(n,i),m=Math.min(o,d);m>c&&a.push({...l,text:l.text.slice(c-i,m-i)}),i=d}return In(a)}function Nr(e,t,r,n,o){let a=sr(e),[i,l]=ma(t,r,a),d=o??Fn(e,i),c=[],m=0,x=!1,y=()=>{x||n===""||(c.push(Vg(n,d)),x=!0)};for(let w of or(e)){let P=m+w.text.length,_=Math.min(i,P);_>m&&c.push({...w,text:w.text.slice(0,_-m)}),i>=m&&i<=P&&y();let C=Math.max(l,m);P>C&&c.push({...w,text:w.text.slice(C-m)}),m=P}return y(),In(c)}function Fn(e,t){let r=or(e);if(r.length===0)return{};let n=0,o=r[0];for(let a of r){let i=n+a.text.length;if(t>n&&t<=i)return nr(a);if(t<=n)return nr(o);o=a,n=i}return nr(o)}function zl(e,t,r,n){let[o,a]=ma(t,r,sr(e));if(o===a)return In(e);let i=Object.keys(n),l=[],d=0;for(let c of or(e)){let m=d+c.text.length;for(let[x,y,w]of Ug(d,m,o,a)){if(y<=x)continue;let P=c.text.slice(x-d,y-d);if(!w){l.push({...c,text:P});continue}let _={...c,text:P};for(let C of i)n[C]===void 0?delete _[C]:_[C]=n[C];l.push(_)}d=m}return In(l)}function Ug(e,t,r,n){return[[e,Math.min(t,r),!1],[Math.max(e,r),Math.min(t,n),!0],[Math.max(e,n),t,!1]]}function ql(e,t,r){let[n,o]=ma(t,r,sr(e));if(n===o)return Fn(e,n);let a,i=0;for(let l of or(e)){let d=i+l.text.length;if(Math.min(d,o)>Math.max(i,n)){let c=nr(l);if(!a)a=c;else{let m={};for(let x of Lt)a[x]===c[x]&&a[x]!==void 0&&(m[x]=a[x]);a=m}}i=d}return a??{}}function ma(e,t,r){let n=Cc(Math.min(e,t),r),o=Cc(Math.max(e,t),r);return[n,o]}function Cc(e,t){return Math.max(0,Math.min(Math.round(e),t))}function Rr(e,t){let r=[],n=0;return e.lines.forEach((o,a)=>{let i=o.spans.map(m=>m.text).join(""),l=i===""?n:zg(t,i,n),d=l+i.length,c=a===e.lines.length-1;r.push({start:l,end:c?t.length:d}),n=d}),r.length===0&&r.push({start:0,end:t.length}),r}function zg(e,t,r){let n=e.indexOf(t,r);return n===-1?r:n}function ha(e,t){for(let r=0;r<e.length;r+=1){let n=e[r];if(t<=n.end)return r}return Math.max(0,e.length-1)}function xa(e,t,r,n){let o=Rr(e,t),a=ha(o,r),i=e.lines[a],l=o[a];if(!i||!l)return{x:0,y:0,h:0,line:0};let d=Math.max(0,Math.min(r-l.start,Mc(i)));return{x:jl(i,d,n),y:i.y,h:i.h,line:a}}function Bn(e,t,r,n){let o=Rr(e,t);if(e.lines.length===0)return 0;let a=e.lines.findIndex(d=>r.y<d.y+d.h);a===-1&&(a=e.lines.length-1);let i=e.lines[a];return o[a].start+Ac(i,r.x,n)}function Ac(e,t,r){let n=0,o=1/0,a=0,i=(l,d)=>{let c=Math.abs(d-t);c<o&&(o=c,n=l)};i(0,e.spans[0]?.x??0);for(let l of e.spans){let d=[...l.text],c=0;d.forEach((m,x)=>{c=r.advance(d.slice(0,x+1).join(""),l.style),i(a+x+1,l.x+c)}),a+=d.length}return n}function jl(e,t,r){let n=0,o=e.spans[0]?.x??0;for(let a of e.spans){let i=[...a.text];if(t<=n)return a.x;if(t>=n+i.length){o=a.x+a.w,n+=i.length;continue}let l=i.slice(0,t-n).join("");return a.x+r.advance(l,a.style)}return o}function Mc(e){return e.spans.reduce((t,r)=>t+[...r.text].length,0)}function Kl(e,t,r,n,o){let a=Math.min(r,n),i=Math.max(r,n);if(a===i)return[];let l=Rr(e,t),d=[];return e.lines.forEach((c,m)=>{let x=l[m];if(!x)return;let y=Math.max(a,x.start),w=Math.min(i,x.end);if(w<=y)return;let P=Mc(c),_=jl(c,Math.min(y-x.start,P),o),C=jl(c,Math.min(w-x.start,P),o),F=Math.max(C-_,w>x.end-1&&w>y?4:0);F>0&&d.push({x:_,y:c.y,w:F,h:c.h})}),d}function Gl(e,t,r,n,o){let a=Rr(e,t),l=ha(a,r)+n,d=e.lines[l],c=a[l];if(!d||!c)return n===-1?0:t.length;let m=xa(e,t,r,o);return Math.min(c.start+Ac(d,m.x,o),c.end)}var qg=/[\p{L}\p{N}_]/u;function Wl(e,t){let r=Math.max(0,Math.min(t,e.length)),n=l=>qg.test(e[l]??""),o=r;if(!n(o)&&o>0&&n(o-1)&&(o-=1),!n(o))return{from:r,to:r};let a=o,i=o;for(;a>0&&n(a-1);)a-=1;for(;i<e.length&&n(i);)i+=1;return{from:a,to:i}}function ga(e,t,r){let n=Rr(e,t),o=n[ha(n,r)];return o?{from:o.start,to:o.end}:{from:0,to:t.length}}var Oc=700;function Xl(e){let t=0,r=0,n=null,o=!1,a=0,i=!1,l=0,d=0;function c(){return ar(e.content())}function m(A){return Math.max(0,Math.min(Math.round(A),c().length))}function x(){return{from:Math.min(t,r),to:Math.max(t,r)}}function y(A,D=A){let k=t!==A||r!==D;t=m(A),r=m(D),k&&w(),n=null,e.invalidate()}function w(){o=!1,a&&(clearTimeout(a),a=0)}function P(){a&&clearTimeout(a),a=setTimeout(w,Oc)}function _(A,D){e.write(A,o,D),o=!0,P()}function C(A,D){let{from:k,to:V}=x(),W=n??void 0;_(Nr(e.content(),k,V,A,W),D),t=r=k+A.length,n=null,e.invalidate()}function F(A,D){A!==D&&(_(Nr(e.content(),A,D,""),"Delete text"),t=r=Math.min(A,D),e.invalidate())}function N(A,D){let{from:k,to:V}=x();if(k!==V){F(k,V);return}let W=c();if(A===-1){if(k===0)return;let ne=D?Tc(W,k):k-1;F(ne,k);return}if(k>=W.length)return;let pe=D?Lc(W,k):k+1;F(k,pe)}function J(A,D){let k=c();return D?A===-1?Tc(k,r):Lc(k,r):m(r+A)}return{id:e.id,getSelection:()=>({anchor:t,head:r}),setSelection(A,D){y(A,D??A)},caret(){return xa(e.layout(),c(),r,e.measure())},highlight(){let{from:A,to:D}=x();return Kl(e.layout(),c(),A,D,e.measure())},pointTo(A,D){let k=Bn(e.layout(),c(),A,e.measure());y(D?t:k,k)},selectWordAt(A){let D=Bn(e.layout(),c(),A,e.measure()),k=Wl(c(),D);y(k.from,k.to)},selectLineAt(A){let D=Bn(e.layout(),c(),A,e.measure()),k=ga(e.layout(),c(),D);y(k.from,k.to)},selectAll(){y(0,c().length)},format(A){let{from:D,to:k}=x();if(D===k){n={...Fn(e.content(),D),...A},e.invalidate();return}w(),_(zl(e.content(),D,k,A),"Format text"),w(),e.invalidate()},activeMark(){if(n)return n;let{from:A,to:D}=x();return ql(e.content(),A,D)},composing:()=>i,handleKey(A){if(i)return!1;let D=A.metaKey||A.ctrlKey,k=A.altKey||A.ctrlKey&&!A.metaKey;switch(A.key){case"Escape":return e.close("escape"),!0;case"ArrowLeft":case"ArrowRight":{let V=A.key==="ArrowLeft"?-1:1,{from:W,to:pe}=x();if(!A.shiftKey&&W!==pe)y(V===-1?W:pe);else{let ne=D?$c(e,c(),r,V):J(V,k);y(A.shiftKey?t:ne,ne)}return!0}case"ArrowUp":case"ArrowDown":{let V=A.key==="ArrowUp"?-1:1,W=D?V===-1?0:c().length:Gl(e.layout(),c(),r,V,e.measure());return y(A.shiftKey?t:W,W),!0}case"Home":case"End":{let V=$c(e,c(),r,A.key==="Home"?-1:1);return y(A.shiftKey?t:V,V),!0}case"Backspace":return N(-1,k||D),!0;case"Delete":return N(1,k||D),!0;case"Enter":return D?e.close("done"):C(`
2322
+ `,"Type text"),!0;case"Tab":return!1;case"a":case"A":return D?(y(0,c().length),!0):!1;case"b":case"B":{if(!D)return!1;let V=this.activeMark().weight===700;return this.format({weight:V?void 0:700}),!0}case"i":case"I":return D?(this.format({italic:this.activeMark().italic===!0?void 0:!0}),!0):!1;case"u":case"U":return D?(this.format({underline:this.activeMark().underline===!0?void 0:!0}),!0):!1;default:return!1}},handleInput(A){if(!i)switch(A.inputType){case"insertText":case"insertReplacementText":case"insertFromPaste":case"insertFromDrop":case"insertFromYank":C(jg(A),"Type text");return;case"insertParagraph":case"insertLineBreak":C(`
2323
+ `,"Type text");return;case"deleteContentBackward":case"deleteWordBackward":N(-1,A.inputType==="deleteWordBackward");return;case"deleteContentForward":case"deleteWordForward":N(1,A.inputType==="deleteWordForward");return;case"deleteByCut":case"deleteByDrag":{let{from:D,to:k}=x();F(D,k);return}default:return}},handleCompositionStart(){i=!0;let{from:A,to:D}=x();l=A,d=D,w()},handleCompositionUpdate(A){_(Nr(e.content(),l,d,A),"Type text"),d=l+A.length,t=r=d,e.invalidate()},handleCompositionEnd(A){_(Nr(e.content(),l,d,A),"Type text"),i=!1,d=l+A.length,t=r=d,w(),e.invalidate()},breakBurst:w,destroy(){w()}}}function jg(e){return typeof e.data=="string"?e.data:e.dataTransfer?.getData("text/plain")??""}function $c(e,t,r,n){let o=ga(e.layout(),t,r);return n===-1?o.from:o.to}var ya=/[\p{L}\p{N}_]/u;function Tc(e,t){let r=t;for(;r>0&&!ya.test(e[r-1]??"");)r-=1;for(;r>0&&ya.test(e[r-1]??"");)r-=1;return r}function Lc(e,t){let r=t;for(;r<e.length&&!ya.test(e[r]??"");)r+=1;for(;r<e.length&&ya.test(e[r]??"");)r+=1;return r}function Yl(e){return sr(e)===0}var Jl={v:"select",f:"frame",r:"rect",o:"ellipse",p:"pen",t:"text"};function Ir(e,t){let r=[];for(let n of t){if(!z(e.root,n.nodeId))continue;let o=ee(n.to);ee(n.from)!==o&&r.push({op:"set",id:n.nodeId,prop:n.prop,value:o})}return r}function ee(e){return Math.round(e*100)/100}function Fr(e,t,r,n){let o=new Set,a=[];for(let d of t)d.op==="set"&&(o.add(Oe(d.id,d.prop)),a.push({nodeId:d.id,prop:d.prop}));if(a.length===0)return[];let i=[],l=new Set;for(let d of a)for(let c of r.get(Oe(d.nodeId,d.prop))??[]){let m=Oe(c.nodeId,c.prop);if(o.has(m)||l.has(m)||!z(e.root,c.nodeId))continue;let x=n.nodes.get(c.nodeId)?.values[c.prop];x!==void 0&&(l.add(m),i.push({op:"set",id:c.nodeId,prop:c.prop,value:ee(x)}))}return i}function Zl(e,t,r,n={x:0,y:0}){let o=[],a=new Set,i=e;for(;;){let l=[],d=Ee(i);for(let[c,m]of t){let x=r.get(c),y=z(i.root,m),w=d.nodes.get(m);if(!(!x||!y||!w))for(let P of tt(y)){let _=Oe(m,P);if(a.has(_))continue;let C=x[P],F=w.values[P];if(C===void 0||F===void 0)continue;let N=C+(P==="x"?n.x:P==="y"?n.y:0);ee(N)!==ee(F)&&(a.add(_),l.push({op:"set",id:m,prop:P,value:ee(N)}))}}if(l.length===0)return o;o.push(...l),i=ve(i,l).document}}function Br(e,t,r=new Set){let n=Ee(e),o=Ee(t),a=[];for(let[i,l]of o.nodes){if(r.has(i))continue;let d=n.nodes.get(i),c=z(t.root,i);if(!(!d||!c))for(let m of tt(c)){let x=d.values[m],y=l.values[m];x===void 0||y===void 0||ee(x)!==ee(y)&&a.push({op:"set",id:i,prop:m,value:ee(x)})}}return a}function va(e,t,r){let n=new Set,o=[];for(let a of t)a.op==="set"&&a.prop==="view"&&n.add(a.id);for(let a of t){if(a.op!=="set"||a.prop!=="w"&&a.prop!=="h"||n.has(a.id))continue;let i=z(e.root,a.id);if(i?.type!=="vector"||i.view!==void 0)continue;let l=r(a.id);l&&(n.add(a.id),o.push({op:"set",id:a.id,prop:"view",value:Wt({x:0,y:0,w:l.w,h:l.h})}))}return o.length===0?[...t]:[...o,...t]}var Ql="host:",Kg="#ffffff",ba=20,Gg=15,Wg={ne:0,se:90,sw:180,nw:270,n:0,e:90,s:180,w:270},Dc={w:240,h:28},Xg={text:"Add text",frame:"Add page",rect:"Draw rectangle",ellipse:"Draw ellipse"};function Yg(e,t){let r=t.x-e.x,n=t.y-e.y,o=Math.max(Math.abs(r),Math.abs(n));return{x:e.x+Math.sign(r||1)*o,y:e.y+Math.sign(n||1)*o}}var Jg={KeyA:"left",KeyD:"right",KeyW:"top",KeyS:"bottom",KeyH:"hcenter",KeyV:"vcenter"},Zg={KeyH:"x",KeyV:"y"},Qg={left:"Align left",hcenter:"Align horizontal centres",right:"Align right",top:"Align top",vcenter:"Align vertical centres",bottom:"Align bottom"},ed=null,ey=220,Pc={lock:!0,hide:!0},ty=["x","y","w","h"],ry={front:"Bring to front",forward:"Bring forward",backward:"Send backward",back:"Send to back"},ny=11,Ot=2;function rd(e,t){pa(e.ownerDocument),e.classList.add("vd-editor"),e.hasAttribute("tabindex")||(e.tabIndex=0);let r=t.document,n=[],o=t.tool??"select",a=null,i=null,l=null,d={ids:[],label:null},c=null,m=[],x=!1,y=!1,w=null,P={...Pc,...t.features},_=null,C=new Pn,F=0,N=null,J=null,A=new Map,D=e.ownerDocument.createElement("div");D.style.position="absolute",D.style.inset="0",e.appendChild(D);let k=Fo(D,{document:r,...t.camera?{camera:t.camera}:{},...t.surface?{surface:t.surface}:{},...t.interactive===void 0?{}:{interactive:t.interactive},...t.wheel?{wheel:t.wheel}:{},...t.resolveAsset?{resolveAsset:t.resolveAsset}:{},...t.fonts?{fonts:t.fonts}:{},onSceneChange:(s,f)=>{f===r&&Te("scene",{scene:s,document:f})},onCameraChange:s=>{W?.setZoom(s.zoom),X(),Te("camera",s),!(F>0)&&(_a(),Te("navigate",s))}}),V=yc(e,s=>k.documentToScreen(s)),W=t.chrome===!1?null:Fu(e,{onTool:bt,onUndo:Jr,onRedo:ro,onZoomReset:()=>k.fitToContent(),onPlay:t.onPlay,playHint:t.playHint,formatKeys:t.formatKeys}),pe=t.chrome===!1?null:El(e,{onCommand:Jp,...t.formatKeys?{formatKeys:t.formatKeys}:{}}),ne=r,we=r,xe=[],T=null,me=[],oe=null,S=null,$=new Map,M=null,L=null,H=null,K=[],b=ze,U=null,B=null,R=null,q=null,je=!1,ae=e.ownerDocument.createElement("textarea");ae.className="vd-editor__input",ae.setAttribute("aria-hidden","true"),ae.tabIndex=-1,ae.autocapitalize="off",ae.autocomplete="off",ae.spellcheck=!1,e.appendChild(ae);function Te(s,f){let u=A.get(s);if(u)for(let p of u)p(f)}function op(s,f){let u=A.get(s)??new Set;return u.add(f),A.set(s,u),()=>u.delete(f)}function Un(s){F+=1;try{s()}finally{F-=1}}function _a(){N!==null&&(e.ownerDocument.defaultView?.cancelAnimationFrame(N),N=null)}function ap(s){let f=k.linkAt(s),u=f===void 0?void 0:Je(f);return u?u.kind==="url"?t.onOpenLink?(t.onOpenLink(u.url),!0):!1:z(r.root,u.id)?(ie([u.id]),Ca([u.id]),!0):!1:!1}function Ca(s,f={}){if(T!==null)return J={target:s,options:f},!1;let u=lp(s);if(!u)return!1;let p=e.getBoundingClientRect(),h=p.width>0&&p.height>0,g=h?{width:p.width,height:p.height-sp(p)}:{width:u.w+96,height:u.h+96},v=f.fit==="always"?ra(u,g):_l(u,g,k.getCamera());if(!v)return!1;_a(),f.by==="person"&&Te("navigate",v);let E=e.ownerDocument.defaultView,O=E?.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;if(f.animate===!1||O||!h||!E?.requestAnimationFrame)return Un(()=>k.setCamera(v)),!0;let I=k.getCamera(),j=E.performance.now(),G=se=>{let Y=Math.min(1,Math.max(0,(se-j)/ey));Un(()=>k.setCamera(Y===1?v:nc(I,v,oc(Y),g))),N=Y===1?null:E.requestAnimationFrame(G)};return N=E.requestAnimationFrame(G),!0}function sp(s){let f=W?.element.getBoundingClientRect();return!f||f.height===0?0:Math.max(0,s.bottom-f.top)}function ip(s,f){Un(()=>k.setCamera(Qt(k.getCamera(),s,f)))}function zn(){if(J===null||T!==null)return;let{target:s,options:f}=J;J=null,Ca(s,f)}function lp(s){if(s==="content"){let u=k.getScene();return ta([{x:u.x,y:u.y,w:u.width,h:u.height}])}let f=[];for(let u of Sl(r,s)){let p=Ce(u);p&&f.push(p)}return ta(f)}function it(s){return k.getResolution().nodes.get(s)}function gt(s){let f=it(s);return f?{x:f.x,y:f.y,w:f.w,h:f.h}:void 0}function Ce(s){return rr(s,r,k.getResolution())}function Dt(s){let f=it(s);return f?{x:f.absX,y:f.absY,w:f.w,h:f.h}:void 0}function Pt(s){return it(s)?.values.rotation??0}function cd(){let s=Ur();if(s.length===0)return null;for(let f of s){let u=z(r.root,f);if(!u||!Ns.includes(u.type))return null}return s}function qn(s,f=new Set){let u=k.getResolution(),p=null;return re(r.root,h=>{if(f.has(h.id)||!Rt(h.id))return!1;if(h.type!=="frame")return;let g=u.nodes.get(h.id);if(!g)return!1;let v={x:g.absX,y:g.absY,w:g.w,h:g.h};if(!et(v,s.x,s.y))return!1;p=h.id}),p}function Nt(s){let f=it(s);return f?{x:f.absX,y:f.absY}:{x:0,y:0}}function Ne(){return _?.of!==r&&(_={of:r,hidden:oo(r.root),locked:ao(r.root)}),_}function Rt(s){let{hidden:f,locked:u}=Ne();return!f.has(s)&&!u.has(s)}function Q(){return n.filter(Rt)}function jn(s){let f=k.hitTest(s,p=>!Ne().locked.has(p));if(f===null)return null;let u=w===null||De(r.root,f).includes(w);return Zo(f,r,u?w:null)}function dp(){return Dn(r,Q(),k.getResolution())}function Vr(){return Q().length<2?null:Ol(dp())}function Kn(s){let f=[];for(let u of s)for(let p of tr(u,r)){let h=gt(p);h&&f.push({member:u,node:p,frame:h})}return f}function Gn(s,f){let u=z(r.root,s);if(!u)return"literal";let p=u[f];return p===void 0?"literal":Ao(p).kind}function fp(s){let f=z(r.root,s),u={};if(!f)return u;let p=[...ty,...$n(f).map(h=>h.prop)];for(let h of p)u[h]=Gn(s,h);return u}function pd(s,f){let u="none";for(let p of s){let h=Ea(p,f);if(h==="expression")return"expression";h==="token"&&(u="token")}return u}function Ea(s,f){let u="none";for(let p of f){let h=Gn(s,p);if(h==="complex")return"expression";h==="token"&&(u="token")}return u}let Re=null;function fe(s,f){if(s.length===0)return;let u=go(r,va(r,s,gt)),p=ve(r,u);r=p.document,Re?($a(Re.started,Re.label,u,p.inverse),Re.started=!0):C.push({label:f,ops:u,inverse:p.inverse}),Wn(u,f)}function up(s){Re={label:s,started:!1}}function cp(){Re=null}function md(s,f){s.length!==0&&(r=ve(r,s).document,Wn(s,f))}function Wn(s,f){a=null,L=null,H=null,k.update(r),W?.setHistory(C.canUndo,C.canRedo),X(),Te("change",{document:r,ops:s,label:f}),Te("problems",k.getScene().problems)}function ie(s){let f=s.filter(p=>p!==r.root.id&&z(r.root,p)),u=f.length!==n.length||f.some((p,h)=>n[h]!==p);n=[...f],R&&(f.length!==1||f[0]!==R.id)&&(R=null),u&&(pe?.close(),H=null,Te("selection",n)),X()}function pp(s,f){let u=z(r.root,s);if(!u)return[];let p=k.getCamera().zoom;if(Math.min(f.w,f.h)*p<24)return[];let h=ny/p,g=it(s);return $n(u).flatMap(v=>{let E=g?.values[v.prop]??0,O=Gn(s,v.prop)!=="literal";return v.handles(f,E,h).map(I=>({id:I.id,at:I.at,bound:O}))})}function mp(){let s=[];for(let I of Q()){let j=Ce(I);j&&s.push(j)}let f=Qe(s);if(!f)return null;let u=Q().length===1?Q()[0]:void 0,p=u===void 0?void 0:z(r.root,u),h=u===void 0||!p||ue(p),g=new Set,v=Ur();for(let I of li){let j=Bo(I);v.some(G=>j.some(se=>Gn(G,se)!=="literal"))&&g.add(I)}let E=!h&&u!==void 0?Pt(u):0,O=E!==0&&u!==void 0?Dt(u):void 0;return{frame:O??f,...O?{rotation:E}:{},rotatable:cd()!==null,handles:B===null,boundHandles:g,adjusters:B!==null||h||u===void 0||O?[]:pp(u,f)}}function Ur(){return[...new Set(Q().flatMap(s=>tr(s,r)))]}function hp(s){if(!s)return null;if(T?.kind==="adjust")return`r ${ee(oe??T.from)}`;if(T?.kind==="rotate")return`${ee(S??0)}\xB0`;if(!T&&L&&Q().length===1){let f=it(Q()[0])?.values[L.prop]??0;return`r ${ee(f)}`}return T?.kind==="move"?`${ee(s.frame.x)}, ${ee(s.frame.y)}`:`${ee(s.frame.w)} \xD7 ${ee(s.frame.h)}`}function xp(){let f=T!==null&&T.kind!=="space"&&T.kind!=="reorder"?null:Vr();if(!f)return{spacers:[],rings:[],lead:null};let u=T?.kind==="space"?T.spacer:null;return{spacers:Pl(f).map(p=>({id:p.id,axis:p.axis,at:p.at,label:p.id===(u??H)?String(ee(p.gap)):null})),rings:Nl(f).map(p=>({id:p.id,at:p.at})),lead:T?.kind==="reorder"?Ce(T.id)??null:null}}function X(){if(!y)return;let s=Ip(),f=s?null:mp(),u=a!==null&&!n.includes(a)&&!T?Ce(a)??null:null,p={...gc,...xp(),hover:u,members:Q().length>1?Q().flatMap(h=>Ce(h)??[]):[],box:f,badge:hp(f),caret:hd(),textSelection:xd(),draft:T?.kind==="create"?er(T.origin,T.current):null,draftEllipse:T?.kind==="create"&&o==="ellipse",marquee:T?.kind==="marquee"?er(T.origin,T.current):null,guides:T?b.guides:[],measures:T?b.measures:[],presence:d.ids.length===0?null:{frames:d.ids.flatMap(h=>Ce(h)??[]),label:d.label},highlight:On(r,m).flatMap(h=>Ce(h.id)??[]),slots:sm(),parked:n.filter(h=>!Rt(h)).flatMap(h=>Ce(h)??[]),lockHint:vp(),path:s,turn:bp(),pageLabels:gp()};V.render(p)}function gp(){return i?[]:r.root.children.flatMap(s=>{if(s.type!=="frame")return[];let f=Ce(s.id);if(!f)return[];let u=s.name;return[{id:s.id,frame:f,label:typeof u=="string"&&u!==""?u:s.id,state:n.includes(s.id)?"selected":a===s.id?"hover":"idle"}]})}function yp(s){let f=V.pageLabelRect(s),u=z(r.root,s);if(!f||!u)return;let p=u.name,h=e.ownerDocument.createElement("input");h.className="vd-editor__rename",h.type="text",h.spellcheck=!1,h.value=typeof p=="string"&&p!==""?p:"",h.placeholder=s,h.setAttribute("aria-label",`Name of ${s}`),h.style.left=`${f.x-4}px`,h.style.top=`${f.y-2}px`,h.style.width=`${Math.max(120,f.w+40)}px`;let g=!1,v=E=>{if(g)return;g=!0;let O=h.value.trim();h.remove(),i=null,E&&O!==(typeof p=="string"?p:"")&&rf(s,"name",O===""?void 0:O,"Rename"),X(),e.focus({preventScroll:!0})};h.addEventListener("keydown",E=>{E.stopPropagation(),E.key==="Enter"?(E.preventDefault(),v(!0)):E.key==="Escape"&&(E.preventDefault(),v(!1))}),h.addEventListener("pointerdown",E=>E.stopPropagation()),h.addEventListener("blur",()=>v(!0)),i=h,e.appendChild(h),X(),h.focus(),h.select()}function vp(){if(l===null||T||!Ne().locked.has(l))return null;let s=Ce(l);return s?{frame:s,label:l}:null}function Xn(s){let f=k.itemOf(s);if(f?.kind!=="text")return null;let u=f.lines[0]?.y??f.y,p={lines:f.lines.map(h=>({y:h.y-u,h:h.h,baseline:h.baseline-u,w:h.w,spans:h.spans.map(g=>({text:g.text,style:g.style,x:g.x-f.x,w:g.w}))})),width:Math.max(0,...f.lines.map(h=>h.w)),height:f.height};return{item:f,layout:p,top:u}}function Aa(){return o==="text"?"text":o!=="select"?"crosshair":"arrow"}function hd(){if(!B)return null;let s=Xn(B.id);if(!s)return null;let f=B.caret();return{x:s.item.x+f.x,y:s.top+f.y,h:f.h}}function xd(){if(!B)return[];let s=Xn(B.id);return s?B.highlight().map(f=>({x:s.item.x+f.x,y:s.top+f.y,w:f.w,h:f.h})):[]}function Ma(s){if(!B)return null;let f=Xn(B.id);if(!f)return null;let u=zr(B.id,s);return{x:u.x-f.item.x,y:u.y-f.top}}function zr(s,f){let u=Pt(s),p=u===0?void 0:Dt(s);return p?Pe(f,Ve(p),-u):f}function bp(){let s=B?.id??R?.id;if(s===void 0)return null;let f=Pt(s),u=f===0?void 0:Dt(s);return u?{angle:f,centre:Ve(u)}:null}function wp(s){let f=z(r.root,s);if(!f||f.type!=="text"||typeof f.h!="number")return[];let u=k.itemOf(s);if(u?.kind!=="text")return[];let p=ee(Math.ceil(u.height));return p>f.h?[{op:"set",id:s,prop:"h",value:p}]:[]}function kp(s,f,u,p){let h=Re?Re.started:u,g=Re?.label??p;Re&&(Re.started=!0);let v=[{op:"set",id:s,prop:"content",value:f}],E=ve(r,v);r=E.document,k.update(r);let O=wp(s);if(O.length===0){$a(h,g,v,E.inverse),Wn(v,g);return}let I=ve(r,O);r=I.document,k.update(r);let j=[...v,...O];$a(h,g,j,[...I.inverse,...E.inverse]),Wn(j,g)}function $a(s,f,u,p){let h={label:f,ops:u,inverse:p};s&&C.amend(h)||C.push(h)}function qr(s,f){let u=z(r.root,s);if(!u||u.type!=="text"||B?.id===s)return;ir("done"),bt("select"),ie([s]),B=Xl({id:s,content:()=>{let h=z(r.root,s);return h?.type==="text"?h.content:""},layout:()=>Xn(s)?.layout??{lines:[],width:0,height:0},measure:()=>k.getMeasurer(),write:(h,g,v)=>kp(s,h,g,v),invalidate:()=>{X(),gd(),Te("selection",n)},close:h=>ir(h)});let p=f?Ma(f):null;p?B.pointTo(p,!1):B.selectAll(),e.classList.add("vd-editor--editing"),ae.value="",ae.focus({preventScroll:!0}),X(),gd()}function ir(s){let f=B;if(!f)return;B=null,je=!1,f.destroy(),e.classList.remove("vd-editor--editing","vd-editor--typing"),Te("selection",n);let u=z(r.root,f.id);u?.type==="text"&&Yl(u.content)&&(fe([{op:"remove",id:f.id}],"Remove empty text"),ie([])),e.ownerDocument.activeElement===ae&&e.focus({preventScroll:!0}),X()}function gd(){let s=hd();if(!s)return;let f=k.documentToScreen({x:s.x,y:s.y});ae.style.left=`${Math.round(f.x)}px`,ae.style.top=`${Math.round(f.y)}px`}let lr=0;function yd(){e.classList.add("vd-editor--typing"),lr&&clearTimeout(lr),lr=setTimeout(()=>{lr=0,e.classList.remove("vd-editor--typing")},520)}function Ta(s){let f=Ir(ne,s);return f.length>0&&M?[...f,...Fr(ne,f,$,M)]:f}function It(s){La(Ta(s))}function La(s,f=s){let u=h=>{let g=M?.nodes.get(h);return g?{x:0,y:0,w:g.w,h:g.h}:void 0},p=va(ne,s,u);me=va(ne,f,u),k.update(p.length>0?ve(ne,p).document:ne),X()}function vd(){let s=Qe(Q().flatMap(p=>Ce(p)??[]));if(!s)return null;let f=new Map,u=new Map;for(let p of Ur()){let h=Dt(p),g=gt(p);!h||!g||(f.set(p,h),u.set(p,{x:h.x-g.x,y:h.y-g.y}))}return f.size===0?null:{bounds:s,frames:f,offsets:u}}function bd(s,f){let u=xl(s.frames,s.bounds,f),p=[];for(let[h,g]of u){let v=s.frames.get(h),E=s.offsets.get(h);if(!v||!E)continue;let O=Pt(h),I=O===0?g:$u(v,O,s.bounds,f);p.push({nodeId:h,prop:"x",from:v.x-E.x,to:I.x-E.x},{nodeId:h,prop:"y",from:v.y-E.y,to:I.y-E.y},{nodeId:h,prop:"w",from:v.w,to:I.w},{nodeId:h,prop:"h",from:v.h,to:I.h})}return p}function Sp(s,f){let u=cd();if(!u)return!1;let p=Q().length===1&&u.length===1?u[0]:void 0,h=Qe(Q().flatMap(E=>Ce(E)??[])),g=p!==void 0?Dt(p):h;if(!g)return!1;let v=u.flatMap(E=>{let O=Dt(E),I=gt(E);return!O||!I?[]:[{id:E,frame:O,rotation:Pt(E),offset:{x:O.x-I.x,y:O.y-I.y}}]});return v.length===0?!1:(Ge(f),Ie({kind:"rotate",pointerId:f,origin:s,centre:Ve(g),targets:v}),!0)}function _p(s,f,u){let p=vd();return p?(Ge(u),Ie({kind:"scale",pointerId:u,origin:s,handle:f,...p}),!0):!1}function Cp(s){let f=vd();if(!f)return;let u=Ir(r,bd(f,s));if(u.length===0)return;let p=s.w!==f.bounds.w||s.h!==f.bounds.h;fe([...u,...Fr(r,u,Cr(r),Ee(r))],p?"Resize":"Move")}function Ep(s,f,u){let p=fa(s),h=Vr();if(!p||!h)return!1;let g=st(h,p.axis)?.gaps[p.index],v=Kn(Q());return g===void 0||v.length===0?!1:(Ge(u),Ie({kind:"space",pointerId:u,origin:f,axis:p.axis,spacer:s,layout:h,gap:g,parts:v}),!0)}function Ap(s,f){let u=s.axis==="x"?f.x-s.origin.x:f.y-s.origin.y,p=Math.max(0,s.gap+u);It(Oa(s.parts,s.axis,ua(s.layout,s.axis,p)))}function Mp(s,f){let u=Vr(),p=u?st(u,s):void 0;if(!u||!p||p.gaps.length===0)return;let h=Ir(r,Oa(Kn(Q()),s,ua(u,s,Math.max(0,f))));h.length!==0&&fe([...h,...Fr(r,h,Cr(r),Ee(r))],"Spacing")}function $p(s){let f=Vr(),u=f?st(f,s)?.gaps:void 0;return!u||u.length===0?null:Dl(u)?u[0]??null:"mixed"}function Oa(s,f,u){return s.map(p=>{let h=f==="x"?p.frame.x:p.frame.y;return{nodeId:p.node,prop:f,from:h,to:h+(u.get(p.member)??0)}})}function Tp(s,f,u){let p=Vr();if(!p||!p.order.includes(s))return!1;let h=Kn(Q()),g=p.items.find(v=>v.id===s)?.frame;return h.length===0||!g?!1:(Ge(u),Ie({kind:"reorder",pointerId:u,id:s,layout:p,parts:h,grab:{x:f.x-g.x,y:f.y-g.y},to:p.order.indexOf(s),swap:!1}),!0)}function Lp(s,f,u){s.to=Fl(s.layout,f),s.swap=u;let p=Op(s),h=new Map(p);h.set(s.id,{x:f.x-s.grab.x,y:f.y-s.grab.y}),La(Ta(wd(s,h)),Ta(wd(s,p)))}function Op(s){let f=s.layout.order.indexOf(s.id);if(f===-1||s.to===f)return new Map;if(s.swap){let u=s.layout.order[s.to];return u===void 0?new Map:Vl(s.layout,s.id,u)}return Hl(s.layout,Bl(s.layout.order,f,s.to))}function wd(s,f){let u=new Map(s.layout.items.map(h=>[h.id,h.frame])),p=[];for(let h of s.parts){let g=f.get(h.member),v=u.get(h.member);!g||!v||p.push({nodeId:h.node,prop:"x",from:h.frame.x,to:h.frame.x+(g.x-v.x)},{nodeId:h.node,prop:"y",from:h.frame.y,to:h.frame.y+(g.y-v.y)})}return p}function Ie(s,f=[],u=r){we=u,xe=f,ne=r,T=s,me=[],$=Cr(r),M=Ee(r),b=ze,K=Dp(s)?yl(r,M,Pp(s)):[]}function Dp(s){return s.kind==="move"||s.kind==="resize"||s.kind==="scale"||s.kind==="create"}function Pp(s){return s.kind==="move"||s.kind==="scale"?new Set(Q()):s.kind==="resize"?new Set([s.id]):new Set}function jr(s){return s.metaKey||s.ctrlKey?0:gl/k.getCamera().zoom}function yt(s){let f=[...xe,...me];T=null,me=[],xe=[],oe=null,S=null,b=ze,r=we,k.update(r),fe(f,s),X()}function Np(){let s=me.length>0?ve(ne,me).document:ne,f=new Set(Q().flatMap(h=>kd(h,s))),u=[];for(let h of Q()){let g=z(s.root,h),v=rt(s.root,h);if(!g||!v)continue;let E=Ce(h);if(!E)continue;let O={x:E.x+E.w/2,y:E.y+E.h/2},I=qn(O,f)??r.root.id;if(I===v.id)continue;let j=z(s.root,I);if(!j||!ue(j))continue;u.push({op:"move",id:h,parent:I,index:le(j).length});let G={x:Nt(v.id).x-Nt(I).x,y:Nt(v.id).y-Nt(I).y};if(!(G.x===0&&G.y===0))for(let se of tr(h,s)){let Y=gt(se);Y&&(u.push({op:"set",id:se,prop:"x",value:ee(Y.x+G.x)}),u.push({op:"set",id:se,prop:"y",value:ee(Y.y+G.y)}))}}if(u.length===0)return[];let p=ve(s,u).document;return[...u,...Br(s,p,f)]}function kd(s,f){let u=z(f.root,s);if(!u)return[];let p=[];return re(u,h=>{p.push(h.id)}),p}function Da(){if(!T)return;T=null,me=[],oe=null,S=null,b=ze;let s=xe.length>0;r=we,xe=[],s&&ie(n.filter(f=>z(r.root,f))),k.update(r),X()}let Rp=5,Yn=8;function Sd(s,f=r,u=k.getResolution()){let p=z(f.root,s),h=u.nodes.get(s);if(p?.type!=="vector"||!h)return;let g={x:h.absX,y:h.absY,w:Math.max(0,h.w),h:Math.max(0,h.h)};return{node:p,view:dn(p.view,g.w,g.h),box:g}}function Kr(s,f=r,u=k.getResolution()){let p=Sd(s,f,u);if(p)return ut(an(p.node.d).contours,fn(p.view,p.box))}function vt(s,f,u,p=r,h=k.getResolution()){let g=Sd(s,p,h);if(!g)return[];let{node:v,view:E,box:O}=g,I=ut(f,ns(E,O)),j=[],G=(Ka,uf,ym)=>{uf!==ym&&j.push({op:"set",id:s,prop:Ka,value:uf})};G("d",ft(I),v.d);let se=[v.x,v.y,v.w,v.h].every(Ka=>typeof Ka=="number"),Y=Gt(I),ge=Gt(f);if(!u||!se||!Y||!ge)return j;let wt=O.x-v.x,Zr=O.y-v.y;return G("view",Wt(Y),v.view),G("x",ee(ge.x-wt),v.x),G("y",ee(ge.y-Zr),v.y),G("w",ee(ge.w),v.w),G("h",ee(ge.h),v.h),j}function Ft(s){return z(r.root,s)?.type!=="vector"||!Rt(s)?!1:(B&&ir("done"),q&&Jn(),ie([s]),R={id:s,picked:new Set},o!=="select"&&bt("select"),Ke(null),X(),!0)}function Gr(){R&&(R=null,X())}function Ip(){if(q){let u=q.contours[q.contour],p=u?.anchors??[],h=p[p.length-1],g=p[0],v=q.hover,E=v!==null&&g!==void 0&&p.length>=2&&!u?.closed&&Wr(g,v)<=Yn;return{contours:q.contours,anchors:p.map((O,I)=>({key:Ae(q?.contour??0,I),at:O,selected:I===p.length-1})),handles:h?xi(q.contours,new Set([Ae(q.contour,p.length-1)])):[],pending:h&&v&&!q.dragging&&!u?.closed?{from:h,...h.out?{c1:h.out}:{},to:v}:null,closeAt:E?g:null}}if(!R)return null;let s=Kr(R.id);if(!s)return null;let f=new Set(mi(s,R.picked));return{contours:s,anchors:s.flatMap((u,p)=>u.anchors.map((h,g)=>({key:Ae(p,g),at:h,selected:f.has(Ae(p,g))}))),handles:xi(s,f)}}function Wr(s,f){return Math.hypot(s.x-f.x,s.y-f.y)*k.getCamera().zoom}function Fp(s,f,u,p){if(!R)return!1;let h=R.id,g=Kr(h);if(!g)return R=null,!1;s.preventDefault(),Ge(s.pointerId);let v=V.hitPath(f);if(v?.kind==="handle"){let O=Tu(v.key),I=O?g[O.contour]?.anchors[O.index]:void 0;if(O&&I)return Ie({kind:"pathHandle",pointerId:s.pointerId,id:h,start:g,contour:O.contour,index:O.index,side:O.side,smooth:Vo(I),last:g}),!0}if(v?.kind==="anchor")return s.altKey?(R.picked=new Set([v.key]),fe(vt(h,Lu(g,v.key),!1),"Convert point"),!0):(s.shiftKey?R.picked.has(v.key)?R.picked.delete(v.key):R.picked.add(v.key):R.picked.has(v.key)||(R.picked=new Set([v.key])),Ie({kind:"points",pointerId:s.pointerId,id:h,origin:u,start:g,keys:new Set(R.picked),lead:v.key,moved:!1,last:g}),X(),!0);let E=as(g,u);if(E&&E.distance*k.getCamera().zoom<=Rp){if(p>=2){let G=ss(g,E.contour,E.segment,E.t);return R.picked=new Set([Ae(E.contour,E.segment+1)]),fe(vt(h,G,!1),"Add point"),!0}let O=g[E.contour],I=O.anchors[E.segment],j=O.anchors[(E.segment+1)%O.anchors.length];return Ie({kind:"segment",pointerId:s.pointerId,id:h,origin:u,start:g,contour:E.contour,segment:E.segment,t:E.t,straight:!I?.out&&!j?.in,last:g}),!0}return Ie({kind:"pointMarquee",pointerId:s.pointerId,origin:u,current:u,additive:s.shiftKey}),!0}function Bp(s,f,u,p){let h=pi(s.start,s.lead);if(!h||p===0)return{dx:f,dy:u};let g=h.x+f,v=h.y+u,E=p,O=p,I=f,j=u;return s.start.forEach((G,se)=>G.anchors.forEach((Y,ge)=>{s.keys.has(Ae(se,ge))||(Math.abs(Y.x-g)<E&&(E=Math.abs(Y.x-g),I=Y.x-h.x),Math.abs(Y.y-v)<O&&(O=Math.abs(Y.y-v),j=Y.y-h.y))})),{dx:I,dy:j}}function Hp(s,f){if(!T)return!1;let u=(p,h)=>{M&&La(vt(h,p,!1,ne,M))};switch(T.kind){case"points":{let p=f;s.shiftKey&&(p=Mn(T.origin,f));let h={dx:p.x-T.origin.x,dy:p.y-T.origin.y};if(!T.moved&&Math.hypot(h.dx,h.dy)*k.getCamera().zoom<Ot)return!0;T.moved=!0;let{dx:g,dy:v}=s.shiftKey?h:Bp(T,h.dx,h.dy,jr(s));return T.last=qo(T.start,T.keys,g,v),u(T.last,T.id),!0}case"pathHandle":{let p=T.start[T.contour]?.anchors[T.index],h=s.shiftKey&&p?Mn(p,f):f;return T.last=Uo(T.start,T.contour,T.index,T.side,h,{smooth:T.smooth,breakSmooth:s.altKey}),u(T.last,T.id),!0}case"segment":return T.last=Du(T.start,T.contour,T.segment,T.t,f.x-T.origin.x,f.y-T.origin.y,T.straight),u(T.last,T.id),!0;case"pointMarquee":return T.current=f,X(),!0;default:return!1}}function Vp(s){if(!T)return!1;switch(T.kind){case"points":case"pathHandle":case"segment":{let f=T.kind!=="points"||T.moved,u=T.kind==="points"?T.keys.size===1?"Move point":"Move points":T.kind==="pathHandle"?"Adjust curve":"Reshape";return me=f&&M?vt(T.id,T.last,!0,ne,M):[],yt(u),!0}case"pointMarquee":{let f=er(T.origin,T.current),u=T.additive;if(T=null,b=ze,!R)return!0;let p=k.getCamera().zoom;if(f.w*p<Ot&&f.h*p<Ot){if(k.hitTest(s)===R.id)R.picked=new Set;else{Gr();let v=jn(s);ie(v===null?[]:[v])}return X(),!0}let h=Kr(R.id)??[],g=hi(h).filter(v=>{let E=pi(h,v);return E!==void 0&&et(f,E.x,E.y)});return R.picked=new Set(u?[...R.picked,...g]:g),X(),!0}default:return!1}}function Up(s){if(!R)return!1;let f=R.id,u=s.metaKey||s.ctrlKey;if(s.key==="Escape"||s.key==="Enter"&&!u)return s.preventDefault(),T?Da():Gr(),!0;let p=Kr(f);if(!p)return!1;let h=new Set(mi(p,R.picked));if(s.key==="Delete"||s.key==="Backspace"){if(s.preventDefault(),h.size===0)return!0;let O=Ou(p,h);return R.picked=new Set,O.length===0?(Gr(),ur(),!0):(fe(vt(f,O,!0),h.size===1?"Delete point":"Delete points"),!0)}let g=s.shiftKey?10:1,E={ArrowLeft:[-g,0],ArrowRight:[g,0],ArrowUp:[0,-g],ArrowDown:[0,g]}[s.key];return E&&!u?(s.preventDefault(),h.size>0&&fe(vt(f,qo(p,h,E[0],E[1]),!0),"Nudge points"),!0):u&&s.key.toLowerCase()==="a"?(s.preventDefault(),R.picked=new Set(hi(p)),X(),!0):u&&!s.shiftKey&&s.code==="KeyJ"?(s.preventDefault(),fe(vt(f,Pu(p,h),!0),"Close path"),!0):!1}function zp(s,f){if(s.preventDefault(),Ge(s.pointerId),!q){q=qp(f)??{contours:[{closed:!1,anchors:[{x:f.x,y:f.y}]}],contour:0,target:null,hover:null,dragging:null};let v=q.contours[q.contour];q.dragging={pointerId:s.pointerId,index:v.anchors.length-1,origin:f},X();return}let u=q.contours[q.contour],p=u.anchors[0],h=u.anchors[u.anchors.length-1];if(p&&u.anchors.length>=2&&Wr(p,f)<=Yn){q.contours[q.contour]={...u,closed:!0},q.dragging={pointerId:s.pointerId,index:0,origin:p},X();return}let g=s.shiftKey&&h?Mn(h,f):f;q.contours[q.contour]={...u,anchors:[...u.anchors,{x:g.x,y:g.y}]},q.dragging={pointerId:s.pointerId,index:u.anchors.length,origin:g},X()}function qp(s){let f=n.length===1?n[0]:null;if(f===null||!Rt(f))return null;let u=Kr(f);if(!u)return null;for(let p=0;p<u.length;p+=1){let h=u[p];if(h.closed||h.anchors.length<1)continue;let g=h.anchors[0],v=h.anchors[h.anchors.length-1],E=Wr(v,s)<=Yn,O=!E&&Wr(g,s)<=Yn;if(!E&&!O)continue;let I=[...u];return O&&(I[p]=Nu(h)),{contours:I,contour:p,target:f,hover:null,dragging:null}}return null}function jp(s,f){if(!q)return;let u=q.dragging;if(!u||u.pointerId!==s.pointerId){let O=q.contours[q.contour],I=O?.anchors[O.anchors.length-1];q.hover=s.shiftKey&&I?Mn(I,f):f,X();return}if(Wr(u.origin,f)<Ot)return;let p=q.contours[q.contour],h=p.anchors[u.index];if(!h)return;let g={x:2*h.x-f.x,y:2*h.y-f.y},v=s.altKey?h.in:g,E=[...p.anchors];E[u.index]={x:h.x,y:h.y,...v?{in:v}:{},out:f},q.contours[q.contour]={...p,anchors:E},X()}function Kp(s){!q?.dragging||q.dragging.pointerId!==s.pointerId||(ja(s.pointerId),q.dragging=null,q.contours[q.contour]?.closed?Jn():X())}function Jn(){if(!q)return;let s=q;q=null;let f=s.contours[s.contour];if(!f||f.anchors.length<2){X();return}if(s.target!==null){fe(vt(s.target,s.contours,!0),"Extend path"),bt("select"),Ft(s.target);return}let u=Gt(s.contours),p=f.anchors[0];if(!u)return;let h=qn(p)??w??r.root.id,g=z(r.root,h)??r.root,v=Nt(h),E=ut(s.contours,I=>({x:I.x-u.x,y:I.y-u.y})),O=qt(r.root,"path");fe([{op:"insert",parent:h,index:le(g).length,node:so({id:O,x:ee(u.x-v.x),y:ee(u.y-v.y),w:ee(u.w),h:ee(u.h),view:Wt({x:0,y:0,w:u.w,h:u.h}),d:ft(E),fill:"none",stroke:t.defaultStroke??"#1f2937",strokeWidth:2,cap:"round",join:"round"})}],"Draw path"),bt("select"),Ft(O)}function Pa(s=Q()){let f=[],u=[];for(let p of s){let h=z(r.root,p),g=rt(r.root,p),v=it(p);if(!h||!g||!v||h.type!=="rect"&&h.type!=="ellipse")continue;let E=Math.max(0,v.w),O=Math.max(0,v.h),I=h.type==="rect"?is(E,O,v.values.radius??0):ls(E,O),j=so({id:p,...h.name===void 0?{}:{name:h.name},x:h.x,y:h.y,w:h.w,h:h.h,view:Wt({x:0,y:0,w:E,h:O}),d:ft(I),...h.fill===void 0?{}:{fill:h.fill},...h.stroke===void 0?{}:{stroke:h.stroke},...h.strokeWidth===void 0?{}:{strokeWidth:h.strokeWidth},...h.opacity===void 0?{}:{opacity:h.opacity},...h.hidden?{hidden:!0}:{},...h.locked?{locked:!0}:{}}),G=g.children.findIndex(se=>se.id===p);f.push({op:"remove",id:p},{op:"insert",parent:g.id,index:G,node:j}),u.push(p)}u.length!==0&&(fe(f,u.length===1?"Convert to vector":`Convert ${u.length} to vector`),ie(u),u.length===1&&Ft(u[0]))}function _d(){return Q().filter(s=>{let f=z(r.root,s)?.type;return f==="rect"||f==="ellipse"}).length}let Gp=450,Cd=4,Xr={x:0,y:0,at:0,count:0};function Wp(s){let f=Date.now(),p=Math.abs(s.x-Xr.x)<=Cd&&Math.abs(s.y-Xr.y)<=Cd&&f-Xr.at<=Gp?Xr.count+1:1;return Xr={x:s.x,y:s.y,at:f,count:p},p}let Ed=s=>{if(s.button!==0||x)return;let f=k.pointerPoint(s),u=k.screenToDocument(f);U=u;let p=Wp(f);if(B){let O=Ma(u),I=k.itemOf(B.id),j=zr(B.id,u);if(O&&I&&et(I,j.x,j.y)){s.preventDefault(),Ge(s.pointerId),je=!0,p>=3?B.selectLineAt(O):p===2?B.selectWordAt(O):B.pointTo(O,s.shiftKey),ae.focus({preventScroll:!0}),X();return}ir("blur")}if(e.focus({preventScroll:!0}),o==="select"&&(s.metaKey||s.ctrlKey)&&ap(u)){s.preventDefault();return}if(o==="pen"){zp(s,u);return}if(R&&o==="select"&&Fp(s,f,zr(R.id,u),p))return;if(o!=="select"){s.preventDefault(),Ge(s.pointerId),Ie({kind:"create",pointerId:s.pointerId,origin:u,current:u}),X();return}let h=Q().length===1?Q()[0]:null;if(h!==null){let O=z(r.root,h),I=V.hitAdjuster(f),j=O&&I?Go(O,I.id):void 0,G=j?Ce(h):void 0;if(j&&G&&I){s.preventDefault(),Ge(s.pointerId),Ie({kind:"adjust",pointerId:s.pointerId,id:h,adjuster:j,handleId:I.id,frame:G,from:it(h)?.values[j.prop]??0});return}let se=O&&!ue(O)?V.hitHandle(f):null,Y=se?gt(h):void 0,ge=Y?Dt(h):void 0;if(se&&Y&&ge){s.preventDefault(),Ge(s.pointerId),Ie({kind:"resize",pointerId:s.pointerId,origin:u,id:h,handle:se.handle,frame:Y,offset:{x:ge.x-Y.x,y:ge.y-Y.y},rotation:Pt(h)});return}}let g=Q().length>0?V.hitHandle(f):null;if(g&&_p(u,g.handle,s.pointerId)){s.preventDefault();return}let v=V.hitPageLabel(f);if(v!==null){if(s.preventDefault(),w=null,s.shiftKey){ie(n.includes(v)?n.filter(O=>O!==v):[...n,v]);return}if(n.includes(v)||ie([v]),p===2){yp(v);return}Ad(u,s.pointerId,s.altKey);return}if(Q().length>0&&V.hitRotate(f)!==null&&Sp(u,s.pointerId)){s.preventDefault();return}if(Q().length>1){let O=V.hitRing(f);if(O!==null&&Tp(O,u,s.pointerId)){s.preventDefault();return}let I=V.hitSpacer(f);if(I!==null&&Ep(I,u,s.pointerId)){s.preventDefault();return}}let E=jn(u);if(E===null){s.preventDefault(),Ge(s.pointerId),w=null,s.shiftKey||ie([]),Ie({kind:"marquee",pointerId:s.pointerId,origin:u,current:u});return}w!==null&&!De(r.root,E).includes(w)&&(w=null),s.shiftKey?ie(n.includes(E)?n.filter(O=>O!==E):[...n,E]):n.includes(E)||ie([E]),Ad(u,s.pointerId,s.altKey)&&s.preventDefault()};function Ad(s,f,u){let p=r,h=[];if(u){let v=Wd({x:0,y:0});v&&(h=v.ops,r=ve(r,h).document,k.update(r),ie(v.ids))}let g=new Map;for(let v of Q())for(let E of tr(v,r)){let O=gt(E);O&&g.set(E,O)}return g.size===0?(r=p,k.update(r),!1):(Ge(f),Ie({kind:"move",pointerId:f,origin:s,frames:g,bounds:Qe(Q().flatMap(v=>Ce(v)??[]))},h,p),!0)}let Md=s=>{let f=k.pointerPoint(s);if(U=k.screenToDocument(f),je&&B){let p=Ma(U);p&&B.pointTo(p,!0);return}if(q&&o==="pen"){jp(s,U);return}if(!T){Zp(f);return}if(T.pointerId!==s.pointerId)return;let u=U;if(!Hp(s,R?zr(R.id,u):u))switch(T.kind){case"move":{let p=u.x-T.origin.x,h=u.y-T.origin.y;if(T.bounds){let v={...T.bounds,x:T.bounds.x+p,y:T.bounds.y+h};b=vl(v,K,jr(s)),p+=b.dx,h+=b.dy}let g=[];for(let[v,E]of T.frames)g.push({nodeId:v,prop:"x",from:E.x,to:E.x+p}),g.push({nodeId:v,prop:"y",from:E.y,to:E.y+h});It(g);return}case"resize":{let{id:p,handle:h,frame:g,origin:v,offset:E,rotation:O}=T,I=u.x-v.x,j=u.y-v.y;if(O!==0){b=ze;let Y=Eu(g,h,I,j,O);It(Ho(g,Y).map(ge=>({nodeId:p,prop:ge,from:g[ge],to:Y[ge]})));return}let G=pt(g,h,I,j);b=ea({...G,x:G.x+E.x,y:G.y+E.y},h,K,jr(s)),I+=b.dx,j+=b.dy;let se=pt(g,h,I,j);It(Ho(g,se).map(Y=>({nodeId:p,prop:Y,from:g[Y],to:se[Y]})));return}case"scale":{let{handle:p,bounds:h,origin:g,frames:v,offsets:E}=T,O=u.x-g.x,I=u.y-g.y,j=pt(h,p,O,I);b=ea(j,p,K,jr(s)),O+=b.dx,I+=b.dy,It(bd({bounds:h,frames:v,offsets:E},pt(h,p,O,I)));return}case"space":Ap(T,u);return;case"reorder":Lp(T,u,s.metaKey||s.ctrlKey);return;case"rotate":{let{centre:p,origin:h,targets:g}=T,v=g[0],E=Au(p,h,u,v?.rotation??0,s.shiftKey?Gg:void 0);S=xn((v?.rotation??0)+E);let O=[],I=g.length===1;for(let j of Mu(g,p,E)){let G=g.find(se=>se.id===j.id);G&&(O.push({nodeId:j.id,prop:"rotation",from:G.rotation,to:j.rotation}),!I&&O.push({nodeId:j.id,prop:"x",from:G.frame.x-G.offset.x,to:ee(j.frame.x-G.offset.x)},{nodeId:j.id,prop:"y",from:G.frame.y-G.offset.y,to:ee(j.frame.y-G.offset.y)}))}It(O);return}case"adjust":{let p=T.adjuster.valueAt(T.frame,T.handleId,u);oe=p,It([{nodeId:T.id,prop:T.adjuster.prop,from:T.from,to:p}]);return}case"create":{b=bl(u,K,jr(s));let p={x:u.x+b.dx,y:u.y+b.dy};T.current=s.shiftKey&&o!=="text"?Yg(T.origin,p):p,X();return}case"marquee":{T.current=u,X();return}}},Zn=s=>{if(je){je=!1,ja(s.pointerId),ae.focus({preventScroll:!0});return}if(q){Kp(s);return}if(!T||T.pointerId!==s.pointerId)return;ja(s.pointerId);let f=k.screenToDocument(k.pointerPoint(s));if(!Vp(R?zr(R.id,f):f))switch(T.kind){case"create":{let u=er(T.origin,T.current),p=o==="text"?"text":o==="frame"?"frame":o==="ellipse"?"ellipse":"rect";T=null,b=ze,X();let h=u.w<Ot||u.h<Ot;if(h&&p!=="text")return;let g=h?{x:u.x,y:u.y,w:Dc.w,h:Dc.h}:u,v=qn({x:g.x,y:g.y})??w??r.root.id,E=z(r.root,v)??r.root,O=Nt(v),I={x:Math.round(g.x-O.x),y:Math.round(g.y-O.y),w:Math.round(g.w),h:Math.round(g.h)},j=qt(r.root,p);fe([{op:"insert",parent:v,index:le(E).length,node:p==="text"?Za({...I,id:j,content:""}):p==="frame"?Wa({...I,id:j,background:Kg,children:[]}):p==="ellipse"?Ga({...I,id:j,fill:t.defaultFill??"#3b82f6"}):Ja({...I,id:j,fill:t.defaultFill??"#3b82f6"})}],Xg[p]),ie([j]),bt("select"),p==="text"&&qr(j);return}case"marquee":{let u=er(T.origin,T.current),p=s.shiftKey;if(T=null,b=ze,u.w>=Ot||u.h>=Ot){let h=gm(u);ie(p?[...new Set([...n,...h])]:h)}X();return}case"move":{let u=Np();u.length>0&&(me=[...me,...u]),yt(xe.length>0?"Duplicate":"Move");return}case"resize":yt("Resize");return;case"scale":yt(n.length===1?"Resize group":`Resize ${n.length} elements`);return;case"space":yt("Spacing");return;case"reorder":yt(T.swap?"Swap":"Reorder");return;case"adjust":yt("Corner radius");return;case"rotate":yt("Rotate");return}},$d=s=>{if(wa(s.target))return;if(B){if(!((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="z"))return;s.preventDefault(),B.breakBurst(),s.shiftKey?ro():Jr();return}if(q&&(s.key==="Enter"||s.key==="Escape")){s.preventDefault(),Jn();return}if(Up(s))return;if((s.metaKey||s.ctrlKey)&&s.shiftKey&&s.code==="KeyO"){if(_d()===0)return;s.preventDefault(),Pa();return}if(s.key==="Enter"&&!Nc(s)&&n.length===1){let p=n[0];if(z(r.root,p)?.type==="vector"&&Ft(p)){s.preventDefault();return}}if(s.key==="Enter"&&!Nc(s)&&n.length===1){let p=n[0];if(z(r.root,p)?.type==="text"){s.preventDefault(),qr(p);return}}if(s.code==="Space"&&!x){x=!0,Le(Me("grab"));return}let f=s.metaKey||s.ctrlKey;if(f&&s.key.toLowerCase()==="z"){s.preventDefault(),s.shiftKey?ro():Jr();return}if(f&&s.shiftKey&&!s.altKey&&s.code==="KeyL"){if(!P.lock||n.length===0)return;s.preventDefault(),fr(n,"locked");return}if(f&&s.shiftKey&&!s.altKey&&s.code==="KeyH"){if(!P.hide||n.length===0)return;s.preventDefault(),fr(n,"hidden");return}if(f&&s.key.toLowerCase()==="g"){s.preventDefault(),s.shiftKey?Va():Ha();return}if(f&&s.key.toLowerCase()==="a"){s.preventDefault(),za();return}if(f&&!s.altKey&&s.key.toLowerCase()==="d"){s.preventDefault(),Fa();return}if(s.altKey){let p=Jg[s.code];if(p&&!f){s.preventDefault(),qd(p);return}let h=Zg[s.code];if(h&&s.ctrlKey){s.preventDefault(),Kd(h);return}}if(s.key==="]"||s.key==="["){if(n.length===0)return;s.preventDefault();let p=s.key==="]";Ua(f?p?"front":"back":p?"forward":"backward");return}if(s.key==="Escape"){T?Da():w!==null?ef():ie([]);return}if(s.key==="Delete"||s.key==="Backspace"){if(n.length===0)return;s.preventDefault(),ur();return}let u=f||s.altKey?void 0:Jl[s.key.toLowerCase()];u&&bt(u)};function Td(){if(!B)return null;let s=z(r.root,B.id);if(s?.type!=="text")return null;let{anchor:f,head:u}=B.getSelection();return f===u?null:ar(Ul(s.content,f,u))}let Ld=s=>{if(wa(s.target))return;let f=Td()??Yr();f!==null&&(s.preventDefault(),s.clipboardData?.setData("text/plain",f))},Od=s=>{if(wa(s.target))return;let f=Td();if(f!==null&&B){s.preventDefault(),s.clipboardData?.setData("text/plain",f);let{anchor:p,head:h}=B.getSelection();B.breakBurst(),B.setSelection(p,h),B.handleInput({inputType:"deleteByCut",data:null});return}let u=Yr();u!==null&&(s.preventDefault(),s.clipboardData?.setData("text/plain",u),ur())},Dd=s=>{if(wa(s.target))return;s.preventDefault();let f=gi(s.clipboardData);if(f&&!B){let p=im();p?Ia(p,f):Yd(f,U??void 0);return}let u=s.clipboardData?.getData("text/plain")||void 0;if(B&&u!==void 0){B.handleInput({inputType:"insertFromPaste",data:u});return}Ra(u)},Pd=s=>{s.code==="Space"&&(x=!1,Le(Me(Aa())))},Nd=s=>{if(!pe)return;s.preventDefault(),T&&Da();let f=k.pointerPoint(s),u=k.screenToDocument(f),p=jn(u),h=Xp(u),g=k.hitTest(u),v=g!==null&&n.some(O=>De(r.root,g).includes(O));p===null?v||ie([]):n.includes(p)||ie([p]);let E=(t.menuExtras?.(n)??[]).map(O=>"separator"in O?O:{...O,id:`${Ql}${O.id}`});pe.open(f,Cl(Yp(h),E))};function Xp(s){let{locked:f}=Ne(),u=[];for(let p of[...k.getScene().items].reverse()){if(!f.has(p.id)||!k.hitTest(s,g=>g===p.id))continue;let h=Qr(r.root,p.id,"locked");h!==void 0&&!u.includes(h)&&u.push(h)}return u}function Yp(s=[]){let f=n.length===1?z(r.root,n[0]):void 0,u=[];if(f){let p=f;for(let h of tt(f)){let g=p[h];g===void 0||!ce(g)||Ao(g).kind!=="literal"&&u.push({prop:h,source:`=${g.expr}`})}}return{count:n.length,hasGroup:n.some(p=>{let h=z(r.root,p);return h!==void 0&&ke(h)}),canPaste:ed!==null,isText:n.length===1&&z(r.root,n[0])?.type==="text",isVector:Q().length===1&&z(r.root,Q()[0])?.type==="vector",convertible:_d(),bound:u,lock:P.lock?n.every(p=>Ne().locked.has(p))?"unlock":"lock":null,hide:P.hide?n.every(p=>Ne().hidden.has(p))?"show":"hide":null,locksHere:s,anyLocked:qa("locked").length>0,hiddenCount:qa("hidden").length}}function Jp(s){if(e.focus({preventScroll:!0}),s.startsWith(Ql)){t.onMenuCommand?.(s.slice(Ql.length),[...n]);return}if(s.startsWith("unlock:")){dr([s.slice(7)],"locked",!1);return}if(s.startsWith("detach:")){let f=s.slice(7),u=n[0];u!==void 0&&nf(u,f);return}switch(s){case"copy":Yr();return;case"cut":Xd();return;case"editText":{let f=n[0];f!==void 0&&qr(f);return}case"editPoints":{let f=n[0];f!==void 0&&Ft(f);return}case"toVector":return Pa();case"duplicate":return Fa();case"paste":return Ra();case"group":return Ha();case"ungroup":return Va();case"front":case"forward":case"backward":case"back":return Ua(s);case"delete":return ur();case"selectAll":return za();case"toggleLock":return fr(n,"locked");case"toggleHidden":return fr(n,"hidden");case"unlockAll":return to("locked");case"showAll":return to("hidden");case"fit":return k.fitToContent();case"zoom100":return k.setCamera({...k.getCamera(),zoom:1})}}let Rd=s=>{if(o!=="select"||x||R)return;let f=k.screenToDocument(k.pointerPoint(s)),u=k.hitTest(f,E=>!Ne().locked.has(E));if(u===null)return;let p=eo().find(E=>E.id===u);if(p){s.preventDefault(),lm(p);return}let h=z(r.root,u);if(h?.type==="text"){s.preventDefault(),qr(u,f);return}if(h?.type==="vector"){s.preventDefault(),Ft(u);return}let g=De(r.root,u),v=w===null?1:g.indexOf(w)+1;for(let E=Math.max(v,1);E<g.length;E+=1){let O=g[E];if(O===void 0)break;let I=z(r.root,O);if(!(!I||!ke(I))){s.preventDefault(),Qd(O),ie([g[E+1]??O]);return}}},Id=s=>Array.from(s.dataTransfer?.types??[]).includes("Files"),Fd=s=>{if(!Id(s)||!t.importImage)return;s.preventDefault(),s.dataTransfer&&(s.dataTransfer.dropEffect="copy");let f=k.screenToDocument(k.pointerPoint(s)),u=Jd(f)?.id??null;u!==c&&(c=u,X())},Bd=s=>{s.relatedTarget instanceof Node&&e.contains(s.relatedTarget)||c!==null&&(c=null,X())},Hd=s=>{if(!Id(s)||!t.importImage)return;s.preventDefault();let f=k.screenToDocument(k.pointerPoint(s)),u=Jd(f);c=null,X();let p=Array.from(s.dataTransfer?.files??[]).find(h=>h.type.startsWith("image/"));p&&(u?Ia(u,p):Yd(p,f))},Vd=()=>{U=null,l=null,!T&&(a===null&&L===null&&H===null||(a=null,L=null,H=null,X()))};function Ud(){let s=Q().length===1?Q()[0]:void 0,f=s===void 0?void 0:z(r.root,s);return s!==void 0&&f&&!ue(f)?Pt(s):0}function Zp(s){if(x){Le(Me("grab"));return}if(R){Ke(null),Le(Me("arrow"));return}if(o!=="select"){Ke(null),Na(null),Qn(null),Le(Me(o==="text"?"text":"crosshair"));return}let f=Q().length===1?Q()[0]:null;if(f!==null){let g=V.hitAdjuster(s);if(g){let v=z(r.root,f),E=v?Go(v,g.id):void 0;Ke(null),Na(E?{id:g.id,prop:E.prop}:null),Le(Me("radius",{badge:E?Ea(f,[E.prop]):"none"}));return}Na(null)}if(Q().length>0){let g=V.hitHandle(s);if(g){Ke(null);let O=Bo(g.handle);Le(Me("resize",{angle:di(g.handle)+Ud(),badge:pd(Ur(),O)}));return}let v=V.hitPageLabel(s);if(v!==null){Ke(v),Le(Me("arrow"));return}let E=V.hitRotate(s);if(E!==null){Ke(null),Le(Me("rotate",{angle:Wg[E]+Ud()}));return}}let u=V.hitPageLabel(s);if(u!==null){l=null,Ke(u),Le(Me("arrow"));return}if(Q().length>1){if(V.hitRing(s)!==null){Ke(null),Qn(null),Le(Me("grab"));return}let v=V.hitSpacer(s),E=v===null?null:fa(v);if(v!==null&&E){Ke(null),Qn(v),Le(Me("resize",{angle:E.axis==="x"?0:90,badge:pd(Ur(),[E.axis])}));return}Qn(null)}let p=k.screenToDocument(s),h=jn(p);l=Qp(p,h),Ke(h),X(),Le(Me("arrow",{badge:h===null?"none":Ea(h,["x","y"])}))}function Qp(s,f){let u=k.hitTest(s);if(u===null||!Ne().locked.has(u))return null;let p=Qr(r.root,u,"locked");return p===void 0?null:f===null||De(r.root,p).includes(f)?p:null}function Ke(s){a!==s&&(a=s,X())}function Na(s){L?.id!==s?.id&&(L=s,X())}function Qn(s){H!==s&&(H=s,X())}function Le(s){e.style.cursor!==s&&(e.style.cursor=s)}function bt(s){o!==s&&(o=s,q&&s!=="pen"&&Jn(),s!=="select"&&Gr(),W?.setTool(o),s!=="select"&&Ke(null),Le(Me(Aa())),Te("tool",o))}function em(s){if(s.length===0)return null;if(s.length>1)return Qe(s.map(p=>p.frame))??null;let f=s[0],u=rt(r.root,f.id);return u?rr(u.id,r,k.getResolution())??null:null}function zd(s,f,u){let p=Ir(r,Oa(Kn(n),s,f));p.length!==0&&fe([...p,...Fr(r,p,Cr(r),Ee(r))],u)}function qd(s){let f=Dn(r,n,k.getResolution()),u=em(f);u&&zd(Ko(s),yi(f,u,s),Qg[s])}function jd(s){let f=Dn(r,n,k.getResolution());if(f.length<3)return null;let u=Rl(f,s),p=Il(u);return p===null?null:{gap:p,series:u}}function Kd(s){let f=jd(s);f&&zd(s,ca(f.series,f.gap),s==="x"?"Distribute horizontally":"Distribute vertically")}function tm(){let s=On(r,n);if(s.length===0)return null;let f=k.getResolution(),u={};for(let p of s)re(p,h=>{let g=f.nodes.get(h.id)?.values;g&&(u[h.id]=g)});return{nodes:s,tokens:r.tokens,fonts:r.fonts,resolved:u}}function rm(s){return new Map(Object.entries(s.resolved))}function nm(s){let f=Object.entries(s.tokens).filter(([u])=>r.tokens[u]===void 0).map(([u,p])=>({op:"setToken",name:u,value:p}));for(let[u,p]of Object.entries(s.fonts))r.fonts[u]===void 0&&f.push({op:"setFont",name:u,family:p});return f}function Gd(s,f,u){let{nodes:p,remap:h}=ul(s,r);if(p.length===0)return null;let g=nm(s),v=g.length>0?ve(r,g).document:r;p.forEach((I,j)=>{let G=s.nodes[j];if(!G)return;let se=f(G,j,v),Y={op:"insert",parent:se.parent,index:se.index,node:I};g.push(Y),v=ve(v,[Y]).document});let E=Zl(v,h,rm(s),u);E.length>0&&(v=ve(v,E).document);let O=om(p);return{ops:[...g,...E,...Br(r,v)],ids:[...h.values()].filter(I=>O.has(I))}}function om(s){let f=new Set;for(let u of s)f.add(u.id);return f}function Wd(s){let f=tm();return f?Gd(f,(u,p,h)=>{let g=rt(h.root,u.id)??h.root,v=le(g).findIndex(E=>E.id===u.id);return{parent:g.id,index:v===-1?le(g).length:v+1}},s):null}function Yr(){let s=dl(r,n,k.getResolution());return s!==null&&(ed=s),s}function Xd(){let s=Yr();return s!==null&&ur(),s}function am(s){let f=[];for(let u of s.nodes){let p=s.resolved[u.id];if(!p)continue;let{x:h,y:g,w:v,h:E}=p;h===void 0||g===void 0||v===void 0||E===void 0||f.push({x:h,y:g,w:v,h:E})}return Qe(f)??null}function Ra(s,f){let u=fl(s??ed??"");if(!u)return;let p=f??U,h=am(u),g=p&&h?{x:p.x-(h.x+h.w/2),y:p.y-(h.y+h.h/2)}:{x:ba,y:ba},v=w??r.root.id,E=Gd(u,(O,I,j)=>({parent:v,index:le(z(j.root,v)??j.root).length}),g);E&&(fe(E.ops,E.ids.length===1?"Paste":`Paste ${E.ids.length} elements`),ie(E.ids))}async function Yd(s,f){let u=t.importImage;if(!u)return;let p=await jo(s,t.maxImageEdge??2560);if(!p)return;let h=await u(new File([p.bytes],s.name,{type:p.type}));if(!h)return;let g=(f?qn(f):void 0)??w??r.root.id,v=z(r.root,g)??r.root,E=Nt(g),O=k.getResolution().nodes.get(g),{w:I,h:j}=Ru(p.width,p.height,O?.w&&O.w>0?O.w:p.width,O?.h&&O.h>0?O.h:p.height),G=f??U,se=Math.round((G?G.x-I/2:E.x)-E.x),Y=Math.round((G?G.y-j/2:E.y)-E.y),ge=dm(r,s.name),wt=qt(r.root,"image");fe([{op:"setAsset",name:ge,value:h},{op:"insert",parent:g,index:le(v).length,node:Ya({id:wt,x:se,y:Y,w:I,h:j,src:ge,fit:"cover"})}],"Place image"),ie([wt])}function eo(){return t.importImage?vc(r,Ne().hidden):[]}function sm(){return eo().flatMap(s=>{let f=Ce(s.id);return f?[{frame:f,label:s.label,target:s.id===c}]:[]})}function Jd(s){return eo().filter(u=>{let p=Ce(u.id);return p!==void 0&&et(p,s.x,s.y)}).at(-1)??null}function im(){return n.length!==1?null:eo().find(s=>s.id===n[0])??null}async function Ia(s,f){let u=t.importImage;if(!u)return;let p=await jo(f,t.maxImageEdge??2560);if(!p)return;let h=await u(new File([p.bytes],f.name,{type:p.type}));!h||r.assets[s.src]!==void 0||(fe([{op:"setAsset",name:s.src,value:h}],"Add image"),ie([s.id]))}function lm(s){let f=e.ownerDocument.createElement("input");f.type="file",f.accept="image/*",f.addEventListener("change",()=>{let u=f.files?.[0];u&&Ia(s,u)}),f.click()}function dm(s,f){let u=f.replace(/\.[^.]+$/,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"image";if(s.assets[u]===void 0)return u;for(let p=2;;p+=1){let h=`${u}-${p}`;if(s.assets[h]===void 0)return h}}function Fa(){let s=Wd({x:ba,y:ba});s&&(fe(s.ops,s.ids.length===1?"Duplicate":`Duplicate ${s.ids.length} elements`),ie(s.ids))}function Ba(s,f){if(s.length===0)return;let u=ve(r,s).document;fe([...s,...Br(r,u)],f)}function Ha(){let s=pl(r,n);s&&(Ba(s.ops,"Group"),ie([s.groupId]))}function Va(){let s=n.filter(h=>{let g=z(r.root,h);return g!==void 0&&ke(g)});if(s.length===0)return;let f=r,u=[],p=[];for(let h of s){let g=z(f.root,h);g&&p.push(...le(g).map(E=>E.id));let v=ml(f,h);v.length!==0&&(u.push(...v),f=ve(f,v).document)}w!==null&&s.includes(w)&&(w=null),Ba(u,s.length===1?"Ungroup":`Ungroup ${s.length} groups`),ie(p)}function Ua(s){Ba(hl(r,n,s),ry[s])}function fm(s,f,u){let p=z(r.root,f);if(!p||!ue(p))return;let h=new Set(De(r.root,f)),g=s.filter(G=>G!==r.root.id&&z(r.root,G)&&!h.has(G));if(g.length===0)return;let v=[],E=r;if(g.forEach((G,se)=>{let Y={op:"move",id:G,parent:f,index:u+se};v.push(Y),E=ve(E,[Y]).document}),g.every(G=>um(r,E,G)))return;let O=new Set(g.flatMap(G=>kd(G,E))),I=[];for(let G of g){let se=Zd(r,G),Y=Zd(E,G),ge={x:se.x-Y.x,y:se.y-Y.y};if(!(ge.x===0&&ge.y===0))for(let wt of tr(G,E)){let Zr=gt(wt);Zr&&(I.push({op:"set",id:wt,prop:"x",value:ee(Zr.x+ge.x)}),I.push({op:"set",id:wt,prop:"y",value:ee(Zr.y+ge.y)}))}}let j=ve(E,I).document;fe([...v,...I,...Br(r,j,O)],g.length===1?`Move ${g[0]}`:`Move ${g.length} layers`)}function um(s,f,u){let p=rt(s.root,u),h=rt(f.root,u);return p?.id===h?.id&&p?.children.findIndex(g=>g.id===u)===h?.children.findIndex(g=>g.id===u)}function Zd(s,f){let u=De(s.root,f).slice(0,-1).reverse(),p=Ee(s);for(let h of u){let g=z(s.root,h);if(!g||ke(g))continue;let v=p.nodes.get(h);return v?{x:v.absX,y:v.absY}:{x:0,y:0}}return{x:0,y:0}}function Qd(s){let f=z(r.root,s);!f||!ke(f)||(w=s,X())}function ef(){if(w===null)return;let s=w;w=De(r.root,s).slice(0,-1).reverse().find(u=>{let p=z(r.root,u);return p!==void 0&&ke(p)})??null,ie([s])}function za(){let s=z(r.root,w??r.root.id)??r.root;ie(le(s).map(f=>f.id).filter(Rt))}let cm={locked:["Lock","Unlock"],hidden:["Hide","Show"]};function tf(s){return s==="locked"?Ne().locked:Ne().hidden}function dr(s,f,u){let p=s.filter(v=>v!==r.root.id&&z(r.root,v)),h=u?p.filter(v=>!tf(f).has(v)):[...new Set(p.flatMap(v=>{let E=Qr(r.root,v,f);return E===void 0?[]:[E]}))];if(h.length===0)return;let g=cm[f][u?0:1];fe(h.map(v=>({op:"set",id:v,prop:f,value:u?!0:void 0})),h.length===1?`${g} ${h[0]}`:`${g} ${h.length} layers`)}function fr(s,f){s.length!==0&&dr(s,f,!s.every(u=>tf(f).has(u)))}function qa(s){let f=[];return re(r.root,u=>{u[s]===!0&&f.push(u.id)}),f}function to(s){let f=qa(s);if(f.length===0)return;let u=s==="locked"?"Unlock all":"Show all";fe(f.map(p=>({op:"set",id:p,prop:s,value:void 0})),u)}function pm(s){P={...Pc,...s},pe?.close()}function ur(){let s=n.filter(u=>u!==r.root.id).map(u=>({op:"remove",id:u}));if(s.length===0)return;let f=s.length;ie([]),fe(s,f===1?"Delete element":`Delete ${f} elements`)}function Jr(){Re=null;let s=C.undo();s&&md(s.ops,`Undo ${s.entry.label}`)}function ro(){Re=null;let s=C.redo();s&&md(s.ops,`Redo ${s.entry.label}`)}function mm(s){if(!C.isTail(s))return!1;for(let f=s.length;f>0;f-=1)Jr();return!0}function rf(s,f,u,p){let h=z(r.root,s);if(!h)return;let g=h[f];oy(g,u)||fe([{op:"set",id:s,prop:f,value:u}],p??`Set ${f}`)}function hm(s,f){r.tokens[s]!==f&&fe([{op:"setToken",name:s,value:f}],`Set $${s}`)}function xm(s){s in r.tokens&&fe([{op:"setToken",name:s,value:void 0}],`Remove $${s}`)}function nf(s,f){let u=it(s)?.values[f];u!==void 0&&fe([{op:"set",id:s,prop:f,value:ee(u)}],`Detach ${f}`)}function gm(s){let f=z(r.root,w??r.root.id)??r.root,u=[];for(let p of le(f)){if(!Rt(p.id))continue;let h=Ce(p.id);h&&fi(h,s)&&u.push(p.id)}return u}function Ge(s){typeof e.setPointerCapture=="function"&&e.setPointerCapture(s)}function ja(s){e.hasPointerCapture?.(s)&&e.releasePointerCapture(s)}let of=s=>{B&&(yd(),B.handleKey(s)&&(s.preventDefault(),s.stopPropagation()))},af=s=>{B&&(s.preventDefault(),yd(),B.handleInput(s))},sf=()=>B?.handleCompositionStart(),lf=s=>B?.handleCompositionUpdate(s.data??""),df=s=>B?.handleCompositionEnd(s.data??""),ff=s=>{if(!e.ownerDocument.hasFocus())return;let f=s.relatedTarget;f instanceof Element&&f.closest("[data-vd-keeps-text]")||ir("blur")};return ae.addEventListener("keydown",of),ae.addEventListener("beforeinput",af),ae.addEventListener("compositionstart",sf),ae.addEventListener("compositionupdate",lf),ae.addEventListener("compositionend",df),ae.addEventListener("blur",ff),e.addEventListener("pointerdown",Ed),e.addEventListener("pointermove",Md),e.addEventListener("pointerup",Zn),e.addEventListener("pointercancel",Zn),e.addEventListener("pointerup",zn),e.addEventListener("pointercancel",zn),e.addEventListener("pointerleave",Vd),e.addEventListener("dblclick",Rd),e.addEventListener("contextmenu",Nd),e.addEventListener("keydown",$d),e.addEventListener("keyup",Pd),e.addEventListener("copy",Ld),e.addEventListener("cut",Od),e.addEventListener("paste",Dd),e.addEventListener("dragover",Fd),e.addEventListener("dragleave",Bd),e.addEventListener("drop",Hd),y=!0,W?.setTool(o),W?.setHistory(!1,!1),W?.setZoom(k.getCamera().zoom),Le(Me(Aa())),t.autoFit&&!t.camera&&Un(()=>k.fitToContent()),t.history&&(C.restore(t.history),W?.setHistory(C.canUndo,C.canRedo)),t.selection&&t.selection.length>0&&ie(t.selection),X(),{element:e,viewer:k,getDocument:()=>r,update(s){r=s,k.update(r),ie(n),X(),Te("problems",k.getScene().problems)},applyOps:(s,f)=>fe(s,f??"Apply changes"),setDocument:(s,f)=>fe(us(r,si(s,r.root.id)),f??"Replace document"),getSelection:()=>n,setSelection:ie,selectAll:za,deleteSelection:ur,lock:s=>dr(s??n,"locked",!0),unlock:s=>dr(s??n,"locked",!1),toggleLock:s=>fr(s??n,"locked"),unlockAll:()=>to("locked"),hide:s=>dr(s??n,"hidden",!0),show:s=>dr(s??n,"hidden",!1),toggleHidden:s=>fr(s??n,"hidden"),showAll:()=>to("hidden"),isLocked:s=>Ne().locked.has(s),isHidden:s=>Ne().hidden.has(s),setFeatures:pm,getFeatures:()=>P,moveLayers:fm,copy:Yr,cut:Xd,paste:Ra,duplicate:Fa,group:Ha,ungroup:Va,reorder:Ua,scaleSelection:Cp,getSpacing:$p,setSpacing:Mp,align:qd,distribute:Kd,canDistribute:s=>jd(s)!==null,editText:qr,endTextEditing:()=>ir("done"),getEditingText:()=>B?.id??null,formatText:s=>B?.format(s),getTextFormat:()=>B?.activeMark()??{},getTextSelectionRects:xd,getTextRange:()=>{if(!B)return null;let{anchor:s,head:f}=B.getSelection();return{from:Math.min(s,f),to:Math.max(s,f)}},getEnteredGroup:()=>w,enterGroup:Qd,exitGroup:ef,getTool:()=>o,editPoints:Ft,stopEditingPoints:Gr,getPointEditing:()=>R?.id??null,convertToVector:s=>Pa(s),setTool:bt,beginEdit:up,endEdit:cp,undo:Jr,redo:ro,canUndo:()=>C.canUndo,canRedo:()=>C.canRedo,getHistory:()=>C.snapshot(),setProperty:rf,fontFamilies:()=>{let s=new Map;for(let f of t.fonts?.faces()??[]){let u=s.get(f.family)??{weights:new Set,italic:!1};u.weights.add(f.weight),f.style==="italic"?u.italic=!0:(u.css===void 0||f.weight===400)&&(u.css=f.id),s.set(f.family,u)}return[...s.entries()].sort(([f],[u])=>f.localeCompare(u)).map(([f,u])=>({family:f,weights:[...u.weights].sort((p,h)=>p-h),italic:u.italic,...u.css===void 0?{}:{css:u.css}}))},assetUrl:s=>{let f=r.assets[s];return f?t.resolveAsset?.(f,s):void 0},setToken:hm,removeToken:xm,bindingsOf:fp,unbind:nf,getResolution:()=>k.getResolution(),getCamera:()=>k.getCamera(),getProblems:()=>k.getScene().problems,on:op,reveal:Ca,panBy:ip,setPresence(s,f){d={ids:[...s],label:f??null},X()},setHighlight(s){s.length===0&&m.length===0||(m=[...s],X())},isHistoryTail:s=>C.isTail(s),undoTail:mm,historyTop:()=>C.top,destroy(){_a(),e.removeEventListener("pointerup",zn),e.removeEventListener("pointercancel",zn),e.removeEventListener("pointerdown",Ed),e.removeEventListener("pointermove",Md),e.removeEventListener("pointerup",Zn),e.removeEventListener("pointercancel",Zn),e.removeEventListener("pointerleave",Vd),ae.removeEventListener("keydown",of),ae.removeEventListener("beforeinput",af),ae.removeEventListener("compositionstart",sf),ae.removeEventListener("compositionupdate",lf),ae.removeEventListener("compositionend",df),ae.removeEventListener("blur",ff),ae.remove(),lr&&clearTimeout(lr),e.removeEventListener("dblclick",Rd),e.removeEventListener("contextmenu",Nd),e.removeEventListener("copy",Ld),e.removeEventListener("cut",Od),e.removeEventListener("paste",Dd),e.removeEventListener("dragover",Fd),e.removeEventListener("dragleave",Bd),e.removeEventListener("drop",Hd),e.removeEventListener("keydown",$d),e.removeEventListener("keyup",Pd),pe?.destroy(),W?.destroy(),V.destroy(),k.destroy(),D.remove(),A.clear(),e.style.cursor="",e.classList.remove("vd-editor")}}}function oy(e,t){return e===t?!0:ce(e)&&ce(t)?e.expr===t.expr:!1}function Nc(e){return e.metaKey||e.ctrlKey||e.altKey}function wa(e){if(!(e instanceof HTMLElement)||e.classList.contains("vd-editor__input"))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable}var JS=new Set(Lt);function ad(e){return e.map(t=>({value:t,label:`${t.charAt(0).toUpperCase()}${t.slice(1)}`}))}var iy=[{value:"nonzero",label:"Non-zero"},{value:"evenodd",label:"Even-odd"}].filter(e=>Ht.includes(e.value)),ly=ad(Vt),dy=ad(Ct),fy=ad(Ut),uy=[{value:"left",label:"Left",icon:Ue("text-left")},{value:"center",label:"Centre",icon:Ue("text-center")},{value:"right",label:"Right",icon:Ue("text-right")},{value:"justify",label:"Justify",icon:Ue("text-justify")}].filter(e=>St.includes(e.value)),cy=[{value:"top",label:"Top",icon:Ue("text-top")},{value:"middle",label:"Middle",icon:Ue("text-middle")},{value:"bottom",label:"Bottom",icon:Ue("text-bottom")}].filter(e=>_t.includes(e.value)),Bc={prop:"x",label:"X",kind:"number",prefix:"X"},Hc={prop:"y",label:"Y",kind:"number",prefix:"Y"},nd={prop:"w",label:"W",kind:"number",prefix:"W"},od={prop:"h",label:"H",kind:"number",prefix:"H"},py={prop:"rotation",label:"Rotation",kind:"number",icon:"rotate",fallback:"0"},my={prop:"opacity",label:"Opacity",kind:"number",icon:"opacity",percent:!0,fallback:"100%"},Ic={prop:"radius",label:"Radius",kind:"number",icon:"radius",span:"wide",fallback:"0"},Hn={heading:"Position",props:[Bc,Hc,nd,od,py,my]},ka={prop:"fill",label:"Fill",kind:"colour"},Vc={prop:"stroke",label:"Stroke",kind:"colour",span:"half"},Uc={prop:"strokeWidth",label:"Stroke width",kind:"number",prefix:"Width",fallback:"1"},zc={present:"stroke",empty:"No stroke",add:{stroke:"#000000",strokeWidth:1},clear:["stroke","strokeWidth","cap","join"]},Fc={heading:"Stroke",props:[Vc,Uc],optional:zc},ZS={frame:[{heading:"Frame",props:[Bc,Hc,nd,od,{prop:"clip",label:"Clip content",kind:"toggle"}]},{heading:"Fill",props:[{prop:"background",label:"Fill",kind:"colour"}]}],canvas:[{heading:"Canvas",props:[nd,od,{prop:"background",label:"Fill",kind:"colour"}]}],text:[Hn,{heading:"Text",props:[{prop:"font",label:"Font",kind:"font",fallback:"Default"},{prop:"weight",label:"Style",kind:"style",span:"half"},{prop:"size",label:"Size",kind:"number",icon:"font-size",fallback:"16"},{prop:"lineHeight",label:"Line height",kind:"number",icon:"line-height",fallback:"Auto"},{prop:"letterSpacing",label:"Letter spacing",kind:"number",icon:"letter-spacing",fallback:"0"},{prop:"align",label:"Align",kind:"segmented",options:uy,span:"half"},{prop:"valign",label:"Vertical",kind:"segmented",options:cy,span:"half"}]},{heading:"Fill",props:[ka]},{heading:"Link",props:[{prop:"content",label:"Link",kind:"link",icon:"link"}]}],rect:[{heading:"Position",props:[...Hn.props,Ic]},{heading:"Fill",props:[ka]},Fc],ellipse:[Hn,{heading:"Fill",props:[ka]},Fc],image:[{heading:"Position",props:[...Hn.props,Ic]},{heading:"Image",props:[{prop:"fit",label:"Fit",kind:"select",options:dy,prefix:"Fit"}]}],vector:[Hn,{heading:"Fill",props:[{...ka,span:"half"},{prop:"rule",label:"Fill rule",kind:"select",options:iy,prefix:"Rule",span:"half"}]},{heading:"Stroke",props:[Vc,Uc,{prop:"cap",label:"Cap",kind:"select",options:ly,prefix:"Cap",span:"half"},{prop:"join",label:"Join",kind:"select",options:fy,prefix:"Join",span:"half"}],optional:zc}]};var QS=Bt.map(e=>({value:e,label:e.split("-").map((t,r)=>r===0?t.charAt(0).toUpperCase()+t.slice(1):t).join(" ")}));function qc(e){let t=e,r=new Map,n=typeof URL.createObjectURL=="function"&&typeof URL.revokeObjectURL=="function";return{resolve(o){let a=r.get(o.hash);if(a!==void 0)return a;let i=t.get(o.hash);if(i===void 0)return;if(!n)return Ss(o.type,i);let l;try{l=Cs(i)}catch{return}let d=URL.createObjectURL(new Blob([l],{type:o.type}));return r.set(o.hash,d),d},replace(o){t=o;for(let[a,i]of r)o.has(a)||(URL.revokeObjectURL(i),r.delete(a))},destroy(){for(let o of r.values())URL.revokeObjectURL(o);r.clear(),t=new Map}}}var sd="0.1.1",jc="https://cdn.jsdelivr.net/npm/@getv.design/embed@0.1.1/fonts/";var hy=Symbol.for(`vdesign.embed.documents@${sd}`),Kc=globalThis[hy]??=new WeakMap,xy=/^Line (\d+): /;function dd(e){let t=xy.exec(e.message);return{...t?{line:Number(t[1])}:{},code:e.code,message:e.message,severity:e.severity}}function id(e){if(typeof e!="string")return ld(bo("").document,new Map,[{code:"not-text",message:`parse() takes .vd text, not ${e===null?"null":typeof e}.`,severity:"error"}]);let{head:t,blocks:r}=bs(e),n=bo(t);return ld(n.document,r,n.problems.map(dd))}function ld(e,t,r){let n=Object.freeze({});return Kc.set(n,{document:e,blocks:t,problems:r}),{document:n,problems:r}}function Gc(e,t,r){return ld(e,t,[...r]).document}function Sa(e){let t=Kc.get(e);if(!t)throw new TypeError("Not a vDesign document: pass .vd text or what parse() returned.");return t}async function Wc(e){if(typeof e=="string")return Sa(id(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 Sa(id(await t.text()).document)}return gy(e)?Sa(id(await e.text()).document):Sa(e)}function gy(e){let t=e;return typeof t.text=="function"&&typeof t.size=="number"}function Hr(e){return e.root.children.filter(t=>t.type==="frame"&&t.hidden!==!0)}function Xc(e,t){let r=Hr(e),n=typeof t=="number"?r[t]:r.find(o=>o.id===t);if(!n){let o=r.map(a=>a.id).join(", ")||"none";throw new RangeError(`No page ${JSON.stringify(t)} in this document; its pages: ${o}.`)}return n}var fd=["page","content","none"],Yc=24;function Vn(e){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}function Jc(e,t){let r=t===void 0?void 0:e.itemOf(t);if(!(!r||r.w<=0||r.h<=0))return{x:r.x,y:r.y,width:r.w,height:r.h}}function Zc(e,t,r,n){if(r==="none")return;let o=r==="page"?Jc(e,n):void 0;if(!o){e.fitToContent(Yc);return}let a=Vn(t);e.setCamera(Ar(o,{width:a.width||o.width,height:a.height||o.height},Yc))}function Qc(e,t,r){let n=e.getCamera(),o=Vn(t),a={x:(o.width/2-n.x)/n.zoom,y:(o.height/2-n.y)/n.zoom},i;for(let l of Hr(e.getDocument())){let d=Jc(e,l.id);if(!d)continue;let c=Math.max(d.x-a.x,0,a.x-(d.x+d.width)),m=Math.max(d.y-a.y,0,a.y-(d.y+d.height)),x=Math.hypot(c,m);(!i||x<i.distance)&&(i={id:l.id,distance:x})}return i?.id??r}function ep(e,t,r){let n=e===void 0?t:String(e);if(n===void 0)return;let o;try{o=new URL(n,r??globalThis.location?.href)}catch{throw new TypeError(`fontBase must be a URL, or a path on this page; got ${n}.`)}return o.pathname.endsWith("/")||(o.pathname+="/"),o}var ud=Symbol.for("vdesign.embed.handover");function tp(e){return e[ud]}var rp=["exact","browser"],np=["change"],yy=250;async function cC(e,t,r={}){let n=r.fit??"page";if(!fd.includes(n))throw new TypeError(`edit: fit must be one of ${fd.join(", ")}; got ${String(n)}.`);let o=r.fonts??"exact";if(!rp.includes(o))throw new TypeError(`edit: fonts must be one of ${rp.join(", ")}; got ${String(o)}.`);let a=o==="exact"?ep(r.fontBase,jc,e.ownerDocument.baseURI):void 0,i=tp(r),l=await Wc(t),d=i?.page!==void 0&&Hr(l.document).some(b=>b.id===i.page)?i.page:r.page===void 0?Hr(l.document)[0]?.id:Xc(l.document,r.page).id,c=i?.exact&&a?await vy(a,l.document):void 0,m=e.ownerDocument,x=m.defaultView,y=new Map(l.blocks),w=qc(y),P=m.createElement("div");P.className="vd-embed vd-embed--edit",P.style.position="relative",P.style.width="100%",P.style.height="100%",e.appendChild(P);let _=b=>{r.onLink?r.onLink(b):x?.open(b,"_blank","noopener,noreferrer")},C;try{C=rd(P,{document:l.document,chrome:r.toolbar??!0,interactive:r.interactive??!0,wheel:"modifier",resolveAsset:b=>w.resolve(b),importImage:we,onOpenLink:_,...r.surface?{surface:r.surface}:{},...i?{camera:i.camera}:{},...c?{fonts:c.library}:{}})}catch(b){throw P.remove(),w.destroy(),b}let F=new Set,N=!1,J=!1,A=0,D=i===void 0,k,V,W,pe;function ne(b){return W?.of!==b&&(W={of:b,text:ws(vs(b),y)}),W.text}async function we(b){if(N||!b.type.startsWith("image/"))return null;let U=new Uint8Array(await b.arrayBuffer()),B=await ks(U);return N?null:(y.has(B)||y.set(B,_s(U)),{type:b.type,hash:B,bytes:U.length})}function xe(){A+=1;try{Zc(C.viewer,P,n,d)}finally{A-=1}}let T=C.on("navigate",()=>{A===0&&(D=!1)}),me=C.on("change",({document:b})=>{let U={text:()=>ne(b)};for(let B of[...F])B(U);c&&L()}),oe=Vn(P),S=x&&"ResizeObserver"in x?new x.ResizeObserver(()=>{let b=Vn(P);b.width===oe.width&&b.height===oe.height||(oe=b,D&&xe())}):void 0;S?.observe(P),i||xe(),!c&&o==="exact"&&M();function $(){return V??=(async()=>{if(a)try{let{exactFontsAt:b}=await import("./chunks/fonts.js");return b(a)}catch{return}})(),V}async function M(){let b=await $();if(!(N||!b)){for(;;){let U=C.getDocument(),B=await b.ensure(U);if(N||B.length>0)return;if(C.getDocument()===U)break}c=b,C.viewer.setFonts(b.library)}}function L(){k!==void 0&&clearTimeout(k),k=setTimeout(()=>{k=void 0;let b=c;N||!b||b.ensure(C.getDocument()).then(U=>{N||c!==b||U.length===0||(c=void 0,C.viewer.setFonts(void 0))})},yy)}function H(){N||(N=!0,k!==void 0&&clearTimeout(k),me(),T(),S?.disconnect(),C.destroy(),w.destroy(),P.remove(),F.clear())}let K={getText:()=>ne(C.getDocument()),getDocument(){let b=C.getDocument();return pe?.of!==b&&(pe={of:b,document:Gc(b,new Map(y),C.getProblems().map(dd))}),pe.document},on(b,U){if(!np.includes(b))throw new TypeError(`edit: on() takes one of ${np.join(", ")}; got ${String(b)}.`);return F.add(U),()=>{F.delete(U)}},undo(){N||C.undo()},redo(){N||C.redo()},async view(){if(N)throw new Error("edit: this editor was destroyed.");if(J)throw new Error("edit: view() is already opening a view.");J=!0,P.inert=!0;try{C.endTextEditing();let{view:b}=await import("./view.js");if(N)throw new Error("edit: this editor was destroyed.");d=Qc(C.viewer,P,d);let U={camera:C.viewer.getCamera(),page:d,exact:c!==void 0},B=C.getDocument(),R=await b(e,K.getDocument(),{...by(r),[ud]:U});if(N)throw R.destroy(),new Error("edit: this editor was destroyed.");let q=C.getDocument()===B?void 0:K.getDocument();return H(),q&&await R.load(q),R}finally{J=!1,P.inert=!1}},destroy:H};return K}async function vy(e,t){try{let{exactFontsAt:r}=await import("./chunks/fonts.js"),n=r(e);return(await n.ensure(t)).length===0?n:void 0}catch{return}}function by(e){let{toolbar:t,...r}=e;return r}export{cC as edit,sd as version};
2324
+ /*! Bundled license information:
2325
+
2326
+ lucide/dist/esm/icons/a-large-small.mjs:
2327
+ lucide/dist/esm/icons/align-center-horizontal.mjs:
2328
+ lucide/dist/esm/icons/align-center-vertical.mjs:
2329
+ lucide/dist/esm/icons/align-end-horizontal.mjs:
2330
+ lucide/dist/esm/icons/align-end-vertical.mjs:
2331
+ lucide/dist/esm/icons/align-horizontal-distribute-center.mjs:
2332
+ lucide/dist/esm/icons/align-start-horizontal.mjs:
2333
+ lucide/dist/esm/icons/align-start-vertical.mjs:
2334
+ lucide/dist/esm/icons/align-vertical-distribute-center.mjs:
2335
+ lucide/dist/esm/icons/align-vertical-justify-center.mjs:
2336
+ lucide/dist/esm/icons/align-vertical-justify-end.mjs:
2337
+ lucide/dist/esm/icons/align-vertical-justify-start.mjs:
2338
+ lucide/dist/esm/icons/blend.mjs:
2339
+ lucide/dist/esm/icons/check.mjs:
2340
+ lucide/dist/esm/icons/chevron-down.mjs:
2341
+ lucide/dist/esm/icons/chevron-right.mjs:
2342
+ lucide/dist/esm/icons/circle.mjs:
2343
+ lucide/dist/esm/icons/droplet.mjs:
2344
+ lucide/dist/esm/icons/eye.mjs:
2345
+ lucide/dist/esm/icons/eye-off.mjs:
2346
+ lucide/dist/esm/icons/file-text.mjs:
2347
+ lucide/dist/esm/icons/frame.mjs:
2348
+ lucide/dist/esm/icons/group.mjs:
2349
+ lucide/dist/esm/icons/image.mjs:
2350
+ lucide/dist/esm/icons/link.mjs:
2351
+ lucide/dist/esm/icons/lock-open.mjs:
2352
+ lucide/dist/esm/icons/lock.mjs:
2353
+ lucide/dist/esm/icons/minus.mjs:
2354
+ lucide/dist/esm/icons/mouse-pointer-2.mjs:
2355
+ lucide/dist/esm/icons/move-horizontal.mjs:
2356
+ lucide/dist/esm/icons/move-vertical.mjs:
2357
+ lucide/dist/esm/icons/pen-tool.mjs:
2358
+ lucide/dist/esm/icons/pipette.mjs:
2359
+ lucide/dist/esm/icons/play.mjs:
2360
+ lucide/dist/esm/icons/plus.mjs:
2361
+ lucide/dist/esm/icons/redo-2.mjs:
2362
+ lucide/dist/esm/icons/rotate-cw.mjs:
2363
+ lucide/dist/esm/icons/spline.mjs:
2364
+ lucide/dist/esm/icons/square-round-corner.mjs:
2365
+ lucide/dist/esm/icons/square.mjs:
2366
+ lucide/dist/esm/icons/text-align-end.mjs:
2367
+ lucide/dist/esm/icons/text-align-center.mjs:
2368
+ lucide/dist/esm/icons/text-align-justify.mjs:
2369
+ lucide/dist/esm/icons/text-align-start.mjs:
2370
+ lucide/dist/esm/icons/type.mjs:
2371
+ lucide/dist/esm/icons/undo-2.mjs:
2372
+ lucide/dist/esm/icons/unlink.mjs:
2373
+ lucide/dist/esm/icons/x.mjs:
2374
+ lucide/dist/esm/lucide.mjs:
2375
+ (**
2376
+ * @license lucide v1.49.0 - ISC
2377
+ *
2378
+ * This source code is licensed under the ISC license.
2379
+ * See the LICENSE file in the root directory of this source tree.
2380
+ *)
2381
+ */