anniedrawing 0.3.2 → 0.3.3

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +4 -0
  3. package/dist/agent/index.js +1 -1
  4. package/dist/agent/index.js.map +1 -1
  5. package/dist/agent/toolDefs.d.ts +1 -0
  6. package/dist/board.d.ts +7 -1
  7. package/dist/core/index.js +1 -1
  8. package/dist/core/types.d.ts +12 -0
  9. package/dist/docs/agents-repository.md +1 -1
  10. package/dist/docs/agents.md +4 -0
  11. package/dist/docs/api.md +4 -0
  12. package/dist/docs/board-js.md +4 -0
  13. package/dist/docs/decisions.md +6 -0
  14. package/dist/docs/llms-full.txt +4 -0
  15. package/dist/docs/llms.txt +4 -0
  16. package/dist/fellow.d.ts +2 -2
  17. package/dist/fellow.js +1 -1
  18. package/dist/fellow.js.map +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/shared/board-p60lv7As.js +2 -0
  21. package/dist/shared/board-p60lv7As.js.map +1 -0
  22. package/dist/shared/{cards-DWgSVE54.js → cards-DF0uI4-I.js} +2 -2
  23. package/dist/shared/{cards-DWgSVE54.js.map → cards-DF0uI4-I.js.map} +1 -1
  24. package/dist/shared/{paste-C22i8o-g.js → paste-B8nZA2Gh.js} +2 -2
  25. package/dist/shared/{paste-C22i8o-g.js.map → paste-B8nZA2Gh.js.map} +1 -1
  26. package/dist/shared/{picker-Dv_i4iNP.js → picker-DZpEpkED.js} +2 -2
  27. package/dist/shared/picker-DZpEpkED.js.map +1 -0
  28. package/dist/shared/{ui-DEBI1jv_.js → ui-DWQtW0zJ.js} +2 -2
  29. package/dist/shared/{ui-DEBI1jv_.js.map → ui-DWQtW0zJ.js.map} +1 -1
  30. package/dist/shared/{urlPaste-DN4JtgeB.js → urlPaste-Oc4kZ0P7.js} +2 -2
  31. package/dist/shared/{urlPaste-DN4JtgeB.js.map → urlPaste-Oc4kZ0P7.js.map} +1 -1
  32. package/dist/ui/index.js +1 -1
  33. package/dist/ui/version.d.ts +1 -1
  34. package/llms-full.txt +4 -0
  35. package/llms.txt +4 -0
  36. package/package.json +1 -1
  37. package/dist/shared/board-DV5lzxNR.js +0 -2
  38. package/dist/shared/board-DV5lzxNR.js.map +0 -1
  39. package/dist/shared/picker-Dv_i4iNP.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{g as e,t}from"./defaults-C-aC_B4z.js";var{PI:n}=Math,o=n+1e-4,a=[1,1];function r(e,t,n,o=e=>e){return e*o(.5-t*(.5-n))}var{min:i}=Math;function s(e,t,n){let o=i(1,t/n);return i(1,e+(i(1,1-o)-e)*(.275*o))}function l(e,t){return[e[0]+t[0],e[1]+t[1]]}function d(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function c(e,t){return[e[0]-t[0],e[1]-t[1]]}function p(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function u(e,t){return[e[0]*t,e[1]*t]}function h(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function f(e){return[e[1],-e[0]]}function g(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function m(e,t){return e[0]*t[0]+e[1]*t[1]}function v(e,t){return e[0]===t[0]&&e[1]===t[1]}function y(e,t){let n=e[0]-t[0],o=e[1]-t[1];return n*n+o*o}function b(e){return function(e,t){return[e[0]/t,e[1]/t]}(e,function(e){return Math.hypot(e[0],e[1])}(e))}function k(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function x(e,t,n){let o=Math.sin(n),a=Math.cos(n),r=e[0]-t[0],i=e[1]-t[1],s=r*o+i*a;return[r*a-i*o+t[0],s+t[1]]}function M(e,t,n,o){let a=Math.sin(o),r=Math.cos(o),i=t[0]-n[0],s=t[1]-n[1],l=i*r-s*a,d=i*a+s*r;return e[0]=l+n[0],e[1]=d+n[1],e}function A(e,t,n){return l(e,u(c(t,e),n))}function w(e,t,n,o){let a=n[0]-t[0],r=n[1]-t[1];return e[0]=t[0]+a*o,e[1]=t[1]+r*o,e}function L(e,t,n){return l(e,u(t,n))}var $=[0,0],S=[0,0],E=[0,0];function C(e,t){let n=L(e,b(f(c(e,l(e,[1,1])))),-t),a=[],r=1/13;for(let i=r;i<=1;i+=r)a.push(x(n,e,2*o*i));return a}function F(e,t,n){let a=[],r=1/n;for(let i=r;i<=1;i+=r)a.push(x(t,e,o*i));return a}function T(e,t,n){let o=c(t,n),a=u(o,.5),r=u(o,.51);return[c(e,a),c(e,r),l(e,r),l(e,a)]}function R(e,t,n,a){let r=[],i=L(e,t,n),s=1/a;for(let l=s;l<1;l+=s)r.push(x(i,e,3*o*l));return r}function D(e,t,n){return[l(e,u(t,n)),l(e,u(t,.99*n)),c(e,u(t,.99*n)),c(e,u(t,n))]}function H(e,t,n){return!1===e||void 0===e?0:!0===e?Math.max(t,n):e}function z(e,t={}){let{size:n=16,smoothing:a=.5,thinning:i=.5,simulatePressure:u=!0,easing:v=e=>e,start:b={},end:k={},last:x=!1}=t,{cap:A=!0,easing:L=e=>e*(2-e)}=b,{cap:z=!0,easing:P=e=>--e*e*e+1}=k;if(0===e.length||n<=0)return[];let B,U=e[e.length-1].runningLength,j=H(b.taper,n,U),I=H(k.taper,n,U),V=(n*a)**2,Z=[],q=[],W=function(e,t,n){return e.slice(0,10).reduce((e,o)=>{let a=o.pressure;return t&&(a=s(e,o.distance,n)),(e+a)/2},e[0].pressure)}(e,u,n),O=r(n,i,e[e.length-1].pressure,v),N=e[0].vector,G=e[0].point,Y=G,_=G,X=Y,Q=!1;for(let f=0;f<e.length;f++){let{pressure:t}=e[f],{point:a,vector:b,distance:k,runningLength:x}=e[f],A=f===e.length-1;if(!A&&U-x<3)continue;i?(u&&(t=s(W,k,n)),O=r(n,i,t,v)):O=n/2,void 0===B&&(B=O);let C=x<j?L(x/j):1,F=U-x<I?P((U-x)/I):1;O=Math.max(.01,O*Math.min(C,F));let T=(A?e[f]:e[f+1]).vector,R=A?1:m(b,T),D=null!==R&&R<0;if(m(b,N)<0&&!Q||D){g($,N),h($,$,O);for(let e=0;e<=1;e+=.07692307692307693)p(S,a,$),M(S,S,a,o*e),_=[S[0],S[1]],Z.push(_),d(E,a,$),M(E,E,a,o*-e),X=[E[0],E[1]],q.push(X);G=_,Y=X,D&&(Q=!0)}else Q=!1,A?(g($,b),h($,$,O),Z.push(c(a,$)),q.push(l(a,$))):(w($,T,b,R),g($,$),h($,$,O),p(S,a,$),_=[S[0],S[1]],(f<=1||y(G,_)>V)&&(Z.push(_),G=_),d(E,a,$),X=[E[0],E[1]],(f<=1||y(Y,X)>V)&&(q.push(X),Y=X),W=t,N=b)}let J=[e[0].point[0],e[0].point[1]],K=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:l(e[0].point,[1,1]),ee=[],te=[];if(1===e.length){if(!j&&!I||x)return C(J,B||O)}else{j||I&&1===e.length||(A?ee.push(...F(J,q[0],13)):ee.push(...T(J,Z[0],q[0])));let t=f(function(e){return[-e[0],-e[1]]}(e[e.length-1].vector));I||j&&1===e.length?te.push(K):z?te.push(...R(K,t,O,29)):te.push(...D(K,t,O))}return Z.concat(te,q.reverse(),ee)}var P=[0,0];function B(e){return null!=e&&e>=0}function U(e,t={}){return z(function(e,t={}){let{streamline:n=.5,size:o=16,last:r=!1}=t;if(0===e.length)return[];let i=.15+.85*(1-n),s=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(2===s.length){let e=s[1];s=s.slice(0,-1);for(let t=1;t<5;t++)s.push(A(s[0],e,t/4))}1===s.length&&(s=[...s,[...l(s[0],a),...s[0].slice(2)]]);let d=[{point:[s[0][0],s[0][1]],pressure:B(s[0][2])?s[0][2]:.25,vector:[...a],distance:0,runningLength:0}],c=!1,u=0,h=d[0],f=s.length-1;for(let a=1;a<s.length;a++){let e=r&&a===f?[s[a][0],s[a][1]]:A(h.point,s[a],i);if(v(h.point,e))continue;let t=k(e,h.point);if(u+=t,a<f&&!c){if(u<o)continue;c=!0}p(P,h.point,e),h={point:e,pressure:B(s[a][2])?s[a][2]:.5,vector:b(P),distance:t,runningLength:u},d.push(h)}return d[0].vector=d[1]?.vector||[0,0],d}(e,t),t)}var j="http://www.w3.org/2000/svg",I={sans:"Nunito Variable, Nunito, ui-rounded, system-ui, sans-serif",serif:"Georgia, serif",mono:"ui-monospace, SFMono-Regular, Menlo, monospace",hand:"Comic Sans MS, Chalkboard SE, cursive"};function V(e){return I[e??"hand"]}var Z={ink:"#103639",slate:"#606062",coral:"#FF9302",amber:"#FFC68A",moss:"#AAF1AC",teal:"#05D9AB",sky:"#92CAFF",violet:"#8F93F9",rose:"#F89B97",paper:"#FFFFFF"},q={...Z,ink:"#E9F7F3",slate:"#B6C5C1",paper:"#173D40"};function W(e="ink",t="light"){return("dark"===t?q:Z)[e]??e}function O(e){if(e={black:"#000000",white:"#ffffff",red:"#ff0000",blue:"#0000ff",green:"#008000",yellow:"#ffff00",transparent:"#00000000"}[e.toLowerCase()]??e,/^#[\da-f]{3,4}$/i.test(e)&&(e=`#${[...e.slice(1)].map(e=>e+e).join("")}`),/^#[\da-f]{6}([\da-f]{2})?$/i.test(e))return[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)).concat(9===e.length?parseInt(e.slice(7,9),16)/255:1);if(!/^rgba?\(/i.test(e))return;const t=e.match(/[\d.]+%?/g);return!t||t.length<3?void 0:t.slice(0,3).map(e=>parseFloat(e)*(e.endsWith("%")?2.55:1)).concat(void 0===t[3]?1:parseFloat(t[3])/(t[3].endsWith("%")?100:1))}function N(e){return e.slice(0,3).map(e=>{const t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}).reduce((e,t,n)=>e+t*[.2126,.7152,.0722][n],0)}function G(e,t){if("text"===e.kind)return W(e.style?.stroke??"ink",t);const n=W("ink",t),o=K(e,t);if(["connector","line"].includes(e.kind)||"solid"!==o.fillMode)return n;const a=O(o.fill);if(!a)return n;const r=O(W("paper",t)),i=N(a.slice(0,3).map((e,t)=>e*a[3]+r[t]*(1-a[3]))),s=e=>{const t=N(O(e));return(Math.max(i,t)+.05)/(Math.min(i,t)+.05)};for(const l of[n,W("ink","dark"===t?"light":"dark")])if(s(l)>=4.5)return l;return s("#0F0B0A")>=s("#FFFFFF")?"#0F0B0A":"#FFFFFF"}function Y(e){return"number"==typeof e?.size?e.size:{s:14,m:18,l:26,xl:36}[e?.size??"m"]}function _(e){return String(e??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e]))}function X(e){return Math.round(1e3*e)/1e3}function Q(e,t=!1){return e.map((e,t)=>`${t?"L":"M"}${X(e.x)},${X(e.y)}`).join(" ")+(t?" Z":"")}function J(e){const t=e.w,n=e.h;if("ellipse"===e.kind)return`M${t},${n/2}a${t/2},${n/2} 0 1 0 ${-t},0a${t/2},${n/2} 0 1 0 ${t},0Z`;if("diamond"===e.kind)return`M${t/2},0L${t},${n/2}L${t/2},${n}L0,${n/2}Z`;if("line"===e.kind)return Q((e.points??[[0,0],[t,n]]).map(([e,t])=>({x:e,y:t})));if("path"===e.kind)return function(e){const t=e.points??[];if(!t.length)return"";if(e.closed)return Q(t.map(([e,t])=>({x:e,y:t})),!0);const n=U(t.map(([e,t,n])=>({x:e,y:t,pressure:n})),{size:2.2*(e.style?.strokeWidth??2),thinning:.45,smoothing:.6,streamline:.45,simulatePressure:t.every(e=>void 0===e[2]),last:!0});return n.length?`M${n.map(e=>`${X(e[0])},${X(e[1])}`).join(" L")} Z`:""}(e);const o=Math.max(0,Math.min(e.style?.corner??12,t/2,n/2));return`M${o},0H${t-o}Q${t},0 ${t},${o}V${n-o}Q${t},${n} ${t-o},${n}H${o}Q0,${n} 0,${n-o}V${o}Q0,0 ${o},0Z`}function K(e,t){const n=e.style?.fill??("note"===e.kind?"moss":"none");return{stroke:W(e.style?.stroke??"ink",t),strokeWidth:e.style?.strokeWidth??("note"===e.kind?0:2),dash:e.style?.dash??"solid",fill:W(n,t),fillMode:e.style?.fillMode??"solid",corner:e.style?.corner??12,opacity:e.style?.opacity??1}}function ee(e,t,n,o=J(e)){const a=K(e,t),r="dashed"===a.dash?"8 6":"dotted"===a.dash?"1 6":"",i="path"===e.kind,s="line"===e.kind||"connector"===e.kind?"none":i?e.closed&&"none"!==a.fill?a.fill:a.stroke:a.fill,l=`ad_h_${n.replace(/[^a-z0-9_-]/gi,"_")}`,d="hatch"===a.fillMode&&"none"!==s&&!i,c=d?`url(#${l})`:s;return`${d?`<defs><pattern id="${l}" width="8" height="8" patternUnits="userSpaceOnUse"><path d="M-2 2L2-2M0 8L8 0M6 10L10 6" fill="none" stroke="${_(s)}" stroke-opacity="0.5" stroke-width="1.3"/></pattern></defs>`:""}<path d="${_(o)}" fill="${_(c)}"${"tint"!==a.fillMode||i?"":' fill-opacity="0.22"'} stroke="${i&&!e.closed?"none":_(a.stroke)}" stroke-width="${a.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${r?` stroke-dasharray="${r}"`:""}/>`}function te(e,t,n,o,a){if(!n||"none"===n)return"";if("dot"===n)return`<circle cx="${X(e.x)}" cy="${X(e.y)}" r="${Math.max(3,2*a)}" fill="${_(o)}"/>`;const r=Math.atan2(e.y-t.y,e.x-t.x),i=Math.max(10,4.5*a),s=Math.PI/6;return`<path d="${Q([{x:e.x-Math.cos(r-s)*i,y:e.y-Math.sin(r-s)*i},e,{x:e.x-Math.cos(r+s)*i,y:e.y-Math.sin(r+s)*i}])}" fill="none" stroke="${_(o)}" stroke-width="${a}" stroke-linecap="round" stroke-linejoin="round"/>`}function ne(e,t,n){if(e.length<2)return"";const o=K(t,n);return te(e[0],e[1],t.heads?.start,o.stroke,o.strokeWidth)+te(e[e.length-1],e[e.length-2],t.heads?.end??("connector"===t.kind?"arrow":"none"),o.stroke,o.strokeWidth)}var oe="application/vnd.anniedrawing+json";function ae(e){return JSON.stringify(e,null,2)}var re={select:'<path d="M5.8 3.8c-1-.4-1.7.4-1.4 1.4l4.9 14.4c.4 1.1 1.8 1.1 2.2 0l2.2-5.8 5.8-2.2c1.1-.4 1.1-1.8 0-2.2Z"/>',hand:'<path d="M8 12V6a2 2 0 0 1 4 0v5-7a2 2 0 0 1 4 0v8-5a2 2 0 0 1 4 0v8c0 5-4 7-7 7-3 0-4-2-6-5l-3-4c-1-2 1-4 3-2l2 2"/>',rect:'<rect x="3.75" y="4.75" width="16.5" height="14.5" rx="4"/>',ellipse:'<ellipse cx="12" cy="12" rx="8.25" ry="7.25"/>',diamond:'<path d="m13.4 3.8 6.8 6.8a2 2 0 0 1 0 2.8l-6.8 6.8a2 2 0 0 1-2.8 0l-6.8-6.8a2 2 0 0 1 0-2.8l6.8-6.8a2 2 0 0 1 2.8 0Z"/>',line:'<path d="m5.5 18.5 13-13"/><circle cx="5" cy="19" r="1.5" fill="currentColor" stroke="none"/><circle cx="19" cy="5" r="1.5" fill="currentColor" stroke="none"/>',connector:'<path d="M4 18h5a3 3 0 0 0 3-3V9a3 3 0 0 1 3-3h5m-4-4 4 4-4 4"/>',path:'<path d="M3.5 17.5c1.8-5 3.2-11 6-11 4 0-1 12 3 12 2.8 0 3.2-8 5.5-8 1.6 0 2.3 2 2.5 4"/>',text:'<path d="M5 7V4.5h14V7M12 4.5v15M8.5 19.5h7"/>',note:'<path d="M7 3.75h10a3.25 3.25 0 0 1 3.25 3.25v7.1a2 2 0 0 1-.6 1.4l-4.2 4.2a2 2 0 0 1-1.4.6H7A3.25 3.25 0 0 1 3.75 17V7A3.25 3.25 0 0 1 7 3.75Z"/><path d="M20 14h-3.5a2.5 2.5 0 0 0-2.5 2.5V20"/>',lock:'<rect x="5" y="10" width="14" height="11" rx="3.5"/><path d="M8 10V7a4 4 0 0 1 8 0v3M12 14v3"/>',unlock:'<rect x="5" y="10" width="14" height="11" rx="3.5"/><path d="M8 10V7a4 4 0 0 1 7.5-2M12 14v3"/>',opacity:'<circle cx="12" cy="12" r="8.5"/><path d="M12 3.5a8.5 8.5 0 0 1 0 17Z" fill="currentColor" stroke="none"/>',front:'<rect x="8" y="3.5" width="12.5" height="12.5" rx="3.5"/><path d="M15.5 16v1A3.5 3.5 0 0 1 12 20.5H7A3.5 3.5 0 0 1 3.5 17v-5A3.5 3.5 0 0 1 7 8.5h1"/>',back:'<rect x="3.5" y="8" width="12.5" height="12.5" rx="3.5"/><path d="M8.5 8V7A3.5 3.5 0 0 1 12 3.5h5A3.5 3.5 0 0 1 20.5 7v5A3.5 3.5 0 0 1 17 15.5h-1"/>',eraser:'<path d="m13.2 4.3-9 9a2.4 2.4 0 0 0 0 3.4L7.5 20h4l8.2-8.2a2.4 2.4 0 0 0 0-3.4l-4.1-4.1a1.7 1.7 0 0 0-2.4 0ZM8 10.5l6 6M11.5 20H21"/>',undo:'<path d="m8 5-4.5 4.5L8 14M4 9.5h9.5a5.5 5.5 0 0 1 0 11H11"/>',redo:'<path d="m16 5 4.5 4.5L16 14m4-4.5h-9.5a5.5 5.5 0 0 0 0 11H13"/>',plus:'<path d="M12 5.5v13M5.5 12h13"/>',minus:'<path d="M5.5 12h13"/>',fit:'<path d="M8.5 3.75h-3a1.75 1.75 0 0 0-1.75 1.75v3m11.75-4.75h3a1.75 1.75 0 0 1 1.75 1.75v3M3.75 15.5v3a1.75 1.75 0 0 0 1.75 1.75h3m11.75-4.75v3a1.75 1.75 0 0 1-1.75 1.75h-3"/>',chevron:'<path d="m7 9.5 3.6 3.6a2 2 0 0 0 2.8 0L17 9.5"/>',download:'<path d="M12 3.5v11m-4-4 4 4 4-4M4.5 15.5v2A3 3 0 0 0 7.5 20h9a3 3 0 0 0 3-2.5v-2"/>',upload:'<path d="M12 15V4m-4 4 4-4 4 4M4.5 15.5v2A3 3 0 0 0 7.5 20h9a3 3 0 0 0 3-2.5v-2"/>',code:'<path d="m7 7-4 4a1.4 1.4 0 0 0 0 2l4 4m10-10 4 4a1.4 1.4 0 0 1 0 2l-4 4M14 4l-4 16"/>',close:'<path d="m6.5 6.5 11 11m-11 0 11-11"/>',more:'<circle cx="5" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1.6" fill="currentColor" stroke="none"/>',image:'<rect x="3.5" y="3.5" width="17" height="17" rx="4"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m4 17 3.6-3.6a1.3 1.3 0 0 1 1.8 0l2.1 2.1 3.4-5.1a1.3 1.3 0 0 1 2.2 0L20 15"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2.5v1M12 20.5v1M2.5 12h1m17 0h1M5.3 5.3l.7.7m12 12 .7.7M5.3 18.7l.7-.7M18 6l.7-.7"/>',moon:'<path d="M20 14.5a8.2 8.2 0 0 1-10.5-10c-3.9.7-6.4 3.7-6.4 7.5a8.1 8.1 0 0 0 16.9 2.5Z"/>',trash:'<path d="M4 6.5h16M9 6.5V5a1.5 1.5 0 0 1 1.5-1.5h3A1.5 1.5 0 0 1 15 5v1.5m-9 0 .7 11.2A3 3 0 0 0 9.7 20.5h4.6a3 3 0 0 0 3-2.8L18 6.5M10 10.5v6m4-6v6"/>',copy:'<rect x="8" y="8" width="12.5" height="12.5" rx="3.5"/><path d="M15.5 8V7A3.5 3.5 0 0 0 12 3.5H7A3.5 3.5 0 0 0 3.5 7v5A3.5 3.5 0 0 0 7 15.5h1"/>',grid:'<rect x="3.5" y="3.5" width="17" height="17" rx="4"/><path d="M9 4v16m6-16v16M4 9h16M4 15h16"/>',book:'<path d="M12 5.5c-2.6-2-5.2-2.5-8-2v15c2.8-.5 5.4 0 8 2 2.6-2 5.2-2.5 8-2v-15c-2.8-.5-5.4 0-8 2Zm0 0v15"/>',github:'<path fill="currentColor" stroke="none" d="M12 1C5.922 1 1 5.922 1 12c0 4.867 3.149 8.979 7.521 10.437.55.096.75-.232.75-.546 0-.262-.013-1.13-.013-2.049-3.06.56-3.703-1.31-3.703-1.31-.498-1.316-1.216-1.667-1.216-1.667-.991-.68.075-.668.075-.668 1.109.075 1.688 1.264 1.688 1.264.982 1.686 2.573 1.2 3.201.907.096-.699.381-1.2.695-1.478-2.448-.282-5.022-1.226-5.022-5.451 0-1.2.426-2.187 1.12-2.953-.113-.275-.487-1.392.107-2.9 0 0 .917-.292 3.011 1.12.873-.24 1.809-.36 2.74-.36.93 0 1.867.12 2.74.36 2.077-1.413 3.01-1.12 3.01-1.12.596 1.508.221 2.625.108 2.9.697.766 1.12 1.748 1.12 2.953 0 4.237-2.578 5.163-5.034 5.437.39.338.746 1.016.746 2.056 0 1.478-.014 2.666-.014 3.025 0 .304.202.655.753.545C19.854 20.979 23 16.859 23 12c0-6.078-4.922-11-11-11Z"/>',alignLeft:'<path d="M4 5h16M4 12h10M4 19h16"/>',alignCenter:'<path d="M4 5h16M7 12h10M4 19h16"/>',alignRight:'<path d="M4 5h16M10 12h10M4 19h16"/>',align:'<path d="M4 3.5v17"/><rect x="8" y="5" width="12.5" height="5" rx="1.75"/><rect x="8" y="14" width="8.5" height="5" rx="1.75"/>',shapes:'<rect x="3" y="3" width="8.5" height="8.5" rx="2.5"/><circle cx="17.3" cy="6.7" r="3.7"/><path d="m6 14-3.5 6h8L7 14a.6.6 0 0 0-1 0Z"/><rect x="13.5" y="13.5" width="7" height="7" rx="2" transform="rotate(45 17 17)"/>',link:'<path d="M10 14.5 8.8 15.7a3.6 3.6 0 1 1-5.1-5.1l3.2-3.2a3.6 3.6 0 0 1 5.1 0"/><path d="m14 9.5 1.2-1.2a3.6 3.6 0 0 1 5.1 5.1l-3.2 3.2a3.6 3.6 0 0 1-5.1 0"/>'};function ie(e){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${re[e]??re.select}</svg>`}function se(e,t,n,o="ad-icon-button"){const a=document.createElement("button");return a.type="button",a.className=o,a.title=e,a.setAttribute("aria-label",e),a.innerHTML=ie(t),a.addEventListener("click",()=>{a.focus(),n()}),a}var le="0.3.2",de="https://github.com/Frontierz-AI/AnnieDrawing",ce=["png","svg"];var pe=[["select","Select","V"],["hand","Hand","H"],["rect","Rectangle","R"],["ellipse","Ellipse","O"],["diamond","Diamond","D"],["connector","Arrow","A"],["line","Line","L"],["path","Draw","P"],["text","Text","T"],["note","Sticky note","N"],["eraser","Eraser","E"]],ue=[["ink","Ink"],["paper","Paper"],["teal","Frontierz green"],["moss","Soft green"],["coral","Orange"],["violet","Lavender"],["slate","Slate"],["amber","Peach"],["sky","Sky blue"],["rose","Rose"],["none","No fill"]];function he(e,t){return e<=700||e<=1023&&t<=640}function fe(e,t="",n){const o=document.createElement(e);return o.className=t,n&&(o.textContent=n),o}function ge(e,t,n="ad-button"){const o=fe("button",n,e);return o.type="button",o.addEventListener("click",()=>{o.focus(),t()}),o}function me(e,t){const n=fe("label","ad-field");return n.append(fe("span","ad-field-label",e),t),n}function ve(e,t,n){const o=fe("select");if(e.forEach(([e,t])=>{const n=fe("option","",t);n.value=e,o.append(n)}),!e.some(([e])=>e===t)){const e=fe("option","",t);e.value=t,o.append(e)}return o.value=t,o.onchange=()=>n(o.value),o}function ye(t,n={}){const o=fe("div","ad-ui");t.stage.root.append(o);const a=[];let r,i,s,l;function d(e){c(),r?.close();const n=document.activeElement,a=fe("dialog","ad-dialog"),i=fe("div","ad-dialog-head"),s=fe("div");return s.append(fe("h2","",e)),i.append(s,se("Close","close",()=>a.close())),a.append(i),a.addEventListener("click",e=>{if(e.target===a){const t=a.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&a.close()}}),a.addEventListener("close",()=>{a.remove(),r===a&&(r=void 0),r||(be(),n?.isConnected?n.focus():t.focus())}),o.append(a),r=a,a.showModal(),a}function c(){i?.hidePopover(),i?.remove(),i=void 0,s?.setAttribute("aria-expanded","false"),s&&(s.popoverTargetElement=null),s=void 0}function p(e,n){if(e&&s===e&&i?.matches(":popover-open"))return void c();c();const a=fe("div","ad-popover");a.popover="auto",a.setAttribute("role","group"),a.setAttribute("aria-label",n);const r=document.activeElement;return e&&(e.setAttribute("aria-expanded","true"),e.popoverTargetElement=a,e.popoverTargetAction="show"),i=a,s=e,a.addEventListener("toggle",()=>{i!==a||a.matches(":popover-open")||e?.setAttribute("aria-expanded","false")}),a.addEventListener("keydown",e=>{if(e.stopPropagation(),"Escape"===e.key||"Tab"===e.key&&"manual"===a.popover)"Escape"===e.key&&e.preventDefault(),c(),r?.isConnected?r.focus():t.focus();else if(!(e.target instanceof HTMLInputElement)&&["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key)){const t=h(a),n=t.indexOf(document.activeElement),o="Home"===e.key?0:"End"===e.key?t.length-1:(n+("ArrowDown"===e.key||"ArrowRight"===e.key?1:-1)+t.length)%t.length;e.preventDefault(),t[o]?.focus()}}),o.append(a),a}function u(e,n,o=n){e.showPopover();const a=o.getBoundingClientRect(),r=t.stage.root.getBoundingClientRect(),i=he(r.width,r.height),s=Math.min(228,r.width-24);e.style.width=`${s}px`;const l=e.getBoundingClientRect().height,d=n.closest(".ad-toolbar")&&!i,c=d?a.right+12:n.closest(".ad-header")&&a.left<r.left+r.width/2?a.left:a.right-s,p=d?a.top:a.top>r.top+r.height/2?a.top-l-10:a.bottom+10;e.style.left=`${Math.max(r.left+12,Math.min(c,r.right-s-12))}px`,e.style.top=`${Math.max(r.top+12,Math.min(p,r.bottom-l-12))}px`,h(e)[0]?.focus()}function h(e){return[...e.querySelectorAll("button:not(:disabled), a[href]")]}function f(e,n){const o=p(void 0,e);o.popover="manual",o.classList.add("ad-context-menu"),o.setAttribute("role","menu"),o.tabIndex=-1;return{panel:o,add:(e,n,a,r=!1)=>{const i=ge(e,()=>{c(),t.focus(),a()},"ad-tool-option");i.insertAdjacentHTML("afterbegin",ie(n)),i.setAttribute("role","menuitem"),i.disabled=t.readonly||r,"trash"===n&&i.classList.add("ad-danger"),o.append(i)},show:()=>{o.showPopover();const e=t.stage.root.getBoundingClientRect(),a=Math.min(228,e.width-24);o.style.width=`${a}px`;const r=o.getBoundingClientRect().height;o.style.left=`${Math.max(e.left+12,Math.min(n.x,e.right-a-12))}px`,o.style.top=`${Math.max(e.top+12,Math.min(n.y,e.bottom-r-12))}px`,(o.querySelector("button:not(:disabled)")??o).focus()}}}const g=()=>c(),m=e=>{"manual"!==i?.popover||i.contains(e.target)||c()};window.addEventListener("resize",g),window.addEventListener("pointerdown",m,!0),a.push(()=>{window.removeEventListener("resize",g),window.removeEventListener("pointerdown",m,!0)});const v=!1!==n.menu,y=function(e){if(!1===e)return[];if(!Array.isArray(e))return[...ce];const t=/* @__PURE__ */new Set,n=[];for(const o of e)"png"!==o&&"svg"!==o&&"json"!==o||t.has(o)||(t.add(o),n.push(o));return n}(n.export),b=fe("header","ad-header");let k,x,M;if(v&&(k=se("Board menu","chevron",function(){if(!k)return;const e=p(k,"Board menu");if(!e)return;e.classList.add("ad-tool-options");const n=(t,n,o,a=!1)=>{const r=se(t,n,()=>{c(),o()},"ad-tool-option");r.innerHTML+=`<span>${t}</span>`,r.disabled=a,e.append(r)};n("Open a drawing","upload",()=>x?.click(),t.readonly),he(t.stage.root.clientWidth,t.stage.root.clientHeight)&&n("Hand","hand",()=>{t.setTool("hand"),t.focus()});n(t.grid?"Hide grid":"Show grid","grid",()=>t.setGrid(!t.grid));const o="dark"===t.stage.resolvedTheme;n(o?"Light appearance":"Dark appearance",o?"sun":"moon",()=>t.setTheme(o?"light":"dark")),n("Documentation","book",()=>{window.open("./docs/index.html","_blank","noopener")});const a=fe("a","ad-tool-option");a.href=de,a.target="_blank",a.rel="noopener noreferrer",a.title="GitHub",a.innerHTML=`${ie("github")}<span>GitHub</span>`,a.addEventListener("click",()=>c());const r=fe("div","ad-menu-separator");r.setAttribute("role","separator"),e.append(a,r,fe("p","ad-menu-version",`v${le}`)),u(e,k)},"ad-brand"),k.innerHTML='<span class="ad-brand-mark" aria-hidden="true"><svg viewBox="0 0 40 40"><path d="M9 29 20 8l11 21M14 22h12" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/><circle cx="32" cy="9" r="2.5" fill="currentColor"/></svg></span><span class="ad-brand-name">AnnieDrawing</span>'+ie("chevron"),k.setAttribute("aria-haspopup","true"),k.setAttribute("aria-expanded","false"),x=fe("input"),x.type="file",x.accept=".annie,.json,application/json",x.hidden=!0,x.onchange=()=>{const e=x?.files?.[0];x&&(x.value=""),e&&e.text().then(e=>t.load(JSON.parse(e))).catch(()=>{})},b.append(k)),y.length){const e=fe("div","ad-header-actions");M=ge("Export",function(){if(1===y.length)return void ye(y[0]);if(!M)return;const e=p(M,"Export");if(!e)return;e.classList.add("ad-tool-options");const t={png:["PNG Image","image"],svg:["SVG Image","image"],json:["AnnieDoc format","code"]};for(const n of y){const[o,a]=t[n],r=se(o,a,()=>{c(),ye(n)},"ad-tool-option");r.innerHTML+=`<span>${o}</span>`,e.append(r)}u(e,M)},"ad-button ad-primary"),M.insertAdjacentHTML("afterbegin",ie("download")),y.length>1&&(M.setAttribute("aria-haspopup","true"),M.setAttribute("aria-expanded","false")),e.append(M),b.append(e)}v||b.classList.add("ad-header-end"),(v||y.length)&&o.append(b),x&&o.append(x);const A=fe("nav","ad-toolbar");function w(e,n=!1){const[,o,a]=pe.find(t=>t[0]===e),r=se(o,e,()=>{c(),t.setTool(e),t.focus()},n?"ad-tool-option":"ad-icon-button");return r.dataset.tool=e,r.setAttribute("aria-keyshortcuts",a),r.setAttribute("aria-pressed",String(t.tool===e)),r.innerHTML+=n?`<span>${o}</span>`:`<span class="ad-tooltip">${o}</span>`,t.readonly&&"hand"!==e&&"select"!==e&&(r.disabled=!0),r}A.setAttribute("aria-label","Drawing tools");const L=["rect","ellipse","diamond","line","connector"],$=se("Shapes","shapes",()=>{const e=p($,"Shapes");e&&(e.classList.add("ad-tool-options"),e.append(...L.map(e=>w(e,!0))),u(e,$))});$.setAttribute("aria-haspopup","true"),$.setAttribute("aria-expanded","false"),$.innerHTML+='<span class="ad-tool-corner"></span><span class="ad-tooltip">Shapes</span>';const S=fe("input");S.type="file",S.accept="image/png,image/jpeg,image/webp,image/gif,image/avif",S.hidden=!0,S.onchange=()=>{S.files?.[0]&&t.addImage(S.files[0]).catch(()=>{}),S.value=""};const E=se("Add image","image",()=>{c(),S.click()});E.innerHTML+='<span class="ad-tooltip">Add image</span>',E.disabled=t.readonly;const C=w("hand");v&&C.classList.add("ad-desktop-tool"),A.append(w("select"),C,w("eraser"),fe("div","ad-toolbar-divider"),$,w("path"),w("text"),w("note"),E,S),o.append(A);const F=fe("aside","ad-style-dock");F.setAttribute("aria-label","Selection style"),F.hidden=!0;const T=fe("div","ad-style-panel"),R=se("Deselect","chevron",()=>t.select([]));R.classList.add("ad-style-dismiss"),F.append(R,T),o.append(F);const D=fe("footer","ad-footer"),H=se("Undo","undo",()=>t.undo()),z=se("Redo","redo",()=>t.redo());H.setAttribute("aria-keyshortcuts","Meta+Z Control+Z"),z.setAttribute("aria-keyshortcuts","Meta+Shift+Z Control+Shift+Z");const P=fe("nav","ad-pages");P.setAttribute("aria-label","Pages");const B=fe("div","ad-page-tabs");B.setAttribute("role","tablist"),B.setAttribute("aria-label","Pages");const U=se("All pages","more",function(){const e=p(U,"All pages");if(!e)return;e.classList.add("ad-pages-popover");for(const n of t.read().pages){const t=fe("div","ad-page-row");t.append(q(n.id,n.name));const o=se(`Actions for ${n.name}`,"more",()=>{const e=o.getBoundingClientRect();Z(n.id,n.name,{x:e.left,y:e.top})});t.append(o),e.append(t)}u(e,U),e.querySelector('[aria-current="true"]')?.scrollIntoView({block:"nearest"})});U.setAttribute("aria-haspopup","true"),U.setAttribute("aria-expanded","false"),U.hidden=!0;const j=se("Add page","plus",function(){c();const n=e(),o=t.read().pages;let a=o.length+1;for(;o.some(e=>e.name===`Page ${a}`);)a++;t.apply([{op:"page.add",page:{id:n,name:`Page ${a}`,items:[]}}],{origin:"user",label:"Add page"}).ok&&t.setPage(n)});j.disabled=t.readonly,P.append(B,U,j);let V="";function Z(e,n,o){const a=f("Page actions",o);a.add("Rename page","text",()=>function(e,n){if(t.readonly)return;const o=d("Name this page"),a=fe("input");a.value=n,a.maxLength=100,o.append(me("Page name",a),ge("Save name",()=>{a.value.trim()&&t.apply([{op:"page.set",id:e,patch:{name:a.value.trim()}}],{origin:"user",label:"Rename page"}),o.close()},"ad-button ad-primary")),a.addEventListener("keydown",e=>{"Enter"===e.key&&o.querySelector(".ad-primary")?.click()}),o.addEventListener("close",()=>{const t=B.querySelector(`[data-page-id="${CSS.escape(e)}"]`);t&&!t.hidden?t.focus():U.hidden||U.focus()},{once:!0}),a.focus(),a.select()}(e,n)),a.add("Delete page","trash",()=>{t.apply([{op:"page.remove",id:e}],{origin:"user",label:"Delete page"})},1===t.read().pages.length),a.show()}function q(e,n,o=!1){const a=ge(n,()=>{c(),t.setPage(e),B.querySelector('[aria-selected="true"]')?.focus()},o?"ad-page-tab":"ad-tool-option");a.title=n,a.dataset.pageId=e;let r,i=!1;a.addEventListener("pointerdown",t=>{i=!1,"touch"===t.pointerType&&(r={x:t.clientX,y:t.clientY},clearTimeout(l),l=setTimeout(()=>{i=!0,Z(e,n,r)},500))}),a.addEventListener("pointermove",e=>{r&&Math.hypot(e.clientX-r.x,e.clientY-r.y)>10&&clearTimeout(l)});for(const t of["pointerup","pointercancel"])a.addEventListener(t,()=>clearTimeout(l));return a.addEventListener("click",e=>{i&&(e.preventDefault(),e.stopImmediatePropagation())},!0),o?(a.setAttribute("role","tab"),a.setAttribute("aria-selected",String(t.pageId===e)),a.tabIndex=t.pageId===e?0:-1):a.setAttribute("aria-current",String(t.pageId===e)),a.addEventListener("contextmenu",t=>{t.preventDefault(),Z(e,n,{x:t.clientX,y:t.clientY})}),a.addEventListener("keydown",r=>{if("ContextMenu"===r.key||r.shiftKey&&"F10"===r.key){r.preventDefault();const t=a.getBoundingClientRect();Z(e,n,{x:t.left,y:t.top})}else if(o&&["ArrowLeft","ArrowRight","Home","End"].includes(r.key)){r.preventDefault();const n=t.read().pages,o=n.findIndex(t=>t.id===e),a="Home"===r.key?0:"End"===r.key?n.length-1:(o+("ArrowRight"===r.key?1:-1)+n.length)%n.length;c(),t.setPage(n[a].id),B.querySelector('[aria-selected="true"]')?.focus()}}),a}let O=!1;function N(){if(O)return;O=!0;const e=fe("div","ad-page-tabs");try{const t=[...B.querySelectorAll("button")];e.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:max-content";const n=t.map(e=>{const t=e.cloneNode(!0);return t.hidden=!1,t.style.maxWidth="",t}),a=U.cloneNode(!0);a.hidden=!1,e.append(...n,a),o.append(e);const r=n.map(e=>e.getBoundingClientRect().width),i=a.offsetWidth;e.remove();const s=r.reduce((e,t)=>e+t+4,0)+j.offsetWidth+14,l=P.offsetTop===_.offsetTop?D.clientWidth-_.offsetWidth-16:P.clientWidth,d=Math.min(l,520),c=s<=d,p=t.map(()=>!1),u=t.map(()=>"");if(!c){let e=Math.max(40,d-j.offsetWidth-14-i-4);const n=t.findIndex(e=>"true"===e.getAttribute("aria-selected"));for(const o of[n,...t.map((e,t)=>t).filter(e=>e!==n)])o<0||(o===n?(u[o]=`${e}px`,e-=Math.min(e,r[o])+4):(p[o]=r[o]>e,p[o]||(e-=r[o]+4)))}U.hidden=c,t.forEach((e,t)=>{e.hidden=p[t],e.style.maxWidth=u[t]})}finally{e.remove(),O=!1}}const G=new ResizeObserver(N);!1!==n.pages&&(G.observe(o),a.push(()=>G.disconnect()));const _=fe("div","ad-footer-right"),X=fe("div","ad-zoom"),Q=ge("100%",()=>{const e=p(Q,"Zoom controls");if(!e)return;const n=fe("div","ad-zoom-controls");n.append(se("Zoom out","minus",()=>t.view.zoom/=1.2),ge("100%",()=>t.view.zoom=1,"ad-zoom-value"),se("Zoom in","plus",()=>t.view.zoom*=1.2)),e.append(n),u(e,Q,J)},"ad-zoom-value");Q.setAttribute("aria-label","Zoom controls"),Q.setAttribute("aria-haspopup","true"),Q.setAttribute("aria-expanded","false");const J=se("Fit drawing","fit",()=>t.view.fit());function ee(e){return"video"===e?"Edit Video URL":"Edit URL"}function te(e){if(t.readonly||t.isLocked(e))return;const n=t.get(e);if(!n||"video"!==n.kind&&"link"!==n.kind)return;const o="video"===n.kind,a=d(o?"Edit video URL":"Edit URL"),r=fe("input");r.type="text",r.inputMode="url",r.setAttribute("autocomplete","url"),r.spellcheck=!1,r.maxLength=2e3,r.value=n.href??"",r.setAttribute("aria-label",o?"Video URL":"URL");const i=fe("p","ad-dialog-error");i.setAttribute("role","alert"),i.hidden=!0;const s=ge(o?"Save video URL":"Save URL",()=>{(async()=>{s.disabled=!0;const n=await t.setHref(e,r.value);if(s.disabled=!1,!n.ok){const e=n.errors[0]?.code;return i.textContent="LOCKED"===e||"READONLY"===e?n.errors[0]?.message??"This cannot be edited.":o?"Use a YouTube or Vimeo URL.":"Use an http(s) URL.",i.hidden=!1,r.setAttribute("aria-invalid","true"),void r.focus()}a.close()})()},"ad-button ad-primary");a.append(me(o?"Video URL":"URL",r),i,s),r.addEventListener("input",()=>{i.hidden=!0,r.removeAttribute("aria-invalid")}),r.addEventListener("keydown",e=>{"Enter"===e.key&&a.querySelector(".ad-primary")?.click()}),r.focus(),r.select()}X.append(Q,J,H,z),_.append(X),!1===n.pages?D.append(_):D.append(P,_),o.append(D);let ne="";function ae(){const e=t.selection.some(e=>t.isLocked(e));if("select"!==t.tool)return s&&F.contains(s)&&c(),void(F.hidden=!0);if(r||!e&&document.activeElement instanceof HTMLInputElement&&"range"===document.activeElement.type&&(F.contains(document.activeElement)||i?.contains(document.activeElement)))return;const n=F.contains(document.activeElement)?document.activeElement:void 0,o=s&&F.contains(s)?{label:s.getAttribute("aria-label"),focused:i?.contains(document.activeElement)}:void 0,a=n?.getAttribute("aria-label")??(o?.focused?o.label:void 0),l=n?.closest("label")?.querySelector(".ad-field-label")?.textContent;o&&c();const d=t.selection.map(e=>t.get(e)).filter(Boolean),h=d.map(e=>e.id).join(",");if(ne!==h&&c(),ne=h,T.replaceChildren(),F.hidden=0===d.length,!d.length)return void(o?.focused&&t.focus());const f=d[0],g=1===d.length,m=d.every(e=>["rect","ellipse","diamond","note"].includes(e.kind)),v=d.every(e=>!["image","html","video","link","group","text","note"].includes(e.kind)),y=d.every(e=>"text"===e.kind),b=d.every(e=>!["image","path","line","group","html","video","link"].includes(e.kind)),k=fe("div","ad-color-controls");function x(e,n){const o=f.style?.[n]??("fill"===n?"note"===f.kind?"moss":"none":"ink"),a=ge(e,()=>{const r=p(a,`${e} color`);if(r){r.classList.add("ad-color-popover");for(const[a,i]of ue){const s=fe("button","ad-swatch "+("none"===a?"ad-swatch-none":""));s.type="button",s.style.setProperty("--swatch",W(a,t.stage.resolvedTheme)),s.setAttribute("aria-label",`${e}: ${i}`),s.title=i,s.setAttribute("aria-pressed",String(o===a)),s.onclick=()=>{c(),t.defaultStyle[n]=a,t.updateSelection({style:{[n]:a}}),T.querySelector(`[aria-label="${e}"]`)?.focus()},r.append(s)}u(r,a)}},"ad-color-control");a.setAttribute("aria-label",e),a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-expanded","false");const r=fe("span","ad-color-preview "+("none"===o?"ad-swatch-none":""));r.style.setProperty("--swatch",W(o,t.stage.resolvedTheme)),a.prepend(r),k.append(a)}m&&x("Fill","fill"),v&&x("Line","stroke"),y&&x("Color","stroke");const M=ge("Opacity",()=>{const e=p(M,"Opacity controls");if(!e)return;e.classList.add("ad-opacity-popover");const n=fe("input");n.type="range",n.setAttribute("aria-label","Opacity"),n.min="0",n.max="100",n.value=String(Math.round(100*(t.get(f.id)?.style?.opacity??1)));const o=fe("output","",`${n.value}%`),a=me("Opacity",n);a.querySelector(".ad-field-label").append(o);let r=!0;n.oninput=()=>{o.textContent=`${n.value}%`,t.apply(d.map(({id:e})=>({op:"set",id:e,patch:{style:{opacity:Number(n.value)/100}}})),{origin:"user",label:"Change opacity",merge:!r}),r=!1},n.onchange=()=>{r=!0},e.append(a),u(e,M),n.focus()},"ad-color-control");M.insertAdjacentHTML("afterbegin",ie("opacity")),M.setAttribute("aria-label","Opacity"),M.setAttribute("aria-haspopup","true"),M.setAttribute("aria-expanded","false"),d.every(e=>"group"!==e.kind)&&k.append(M),k.childElementCount&&T.append(k);const A=e=>t.apply(d.map(t=>({op:"set",id:t.id,patch:{text:{value:t.text?.value??"",...e}}})),{origin:"user",label:"Text style"});function w(e){const t=fe("div","ad-style-row"),n=fe("div","ad-segments");return n.setAttribute("role","group"),n.setAttribute("aria-label",e),t.append(fe("span","ad-style-label",e),n),T.append(t),n}function L(e,t,n,o){return t.map(([t,a,r])=>{const i=ge(a,()=>o(t),"ad-segment");return i.setAttribute("aria-label",a),i.title=a,i.setAttribute("aria-pressed",String(d.every(e=>n(e)===t))),i.innerHTML=r,e.append(i),i})}function $(e,t=""){return`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h18" fill="none" stroke="currentColor" stroke-width="${e}" stroke-linecap="round"${t?` stroke-dasharray="${t}"`:""}/></svg>`}if(b){L(w("Text"),[["s","Text size: Small","S"],["m","Text size: Medium","M"],["l","Text size: Large","L"],["xl","Text size: Extra large","XL"]],e=>({14:"s",18:"m",26:"l",36:"xl"}[Y(e.text)]??""),e=>A({size:e})),L(w("Align"),[["start","Align text left",ie("alignLeft")],["center","Align text center",ie("alignCenter")],["end","Align text right",ie("alignRight")]],e=>e.text?.align??("text"===e.kind?"start":"center"),e=>A({align:e}));const e=[["sans","Font: Friendly","Aa"],["serif","Font: Serif","Aa"],["mono","Font: Mono","Aa"],["hand","Font: Handwritten","Aa"]];L(w("Font"),e,e=>e.text?.font??"hand",e=>A({font:e})).forEach((t,n)=>{t.style.fontFamily=I[e[n][0]]})}if(v&&(L(w("Line"),[["1","Line: Fine",$(1)],["2","Line: Regular",$(2)],["4","Line: Bold",$(4)],["8","Line: Extra bold",$(6)]],e=>String(K(e,t.stage.resolvedTheme).strokeWidth),e=>t.updateSelection({style:{strokeWidth:Number(e)}})),d.every(e=>"path"!==e.kind||e.closed)&&L(w("Pattern"),[["solid","Pattern: Solid",$(2)],["dashed","Pattern: Dashed",$(2,"5 4")],["dotted","Pattern: Dotted",$(2,"1 5")]],e=>e.style?.dash??"solid",e=>t.updateSelection({style:{dash:e}}))),g&&"connector"===f.kind&&T.append(me("Route",ve([["straight","Straight"],["elbow","Elbow"],["curve","Curve"]],f.route??"elbow",e=>t.updateSelection({route:e})))),g&&"connector"===f.kind&&T.append(me("Arrowhead",ve([["arrow","Arrow"],["dot","Dot"],["none","None"]],f.heads?.end??"arrow",e=>t.updateSelection({heads:{...f.heads,end:e}})))),g&&("video"===f.kind||"link"===f.kind)){const e=ee(f.kind),t=ge(e,()=>te(f.id),"ad-button ad-href-edit");t.setAttribute("aria-label",e),T.append(t)}const S=se(e?"Unlock selection":"Lock selection",e?"lock":"unlock",()=>t.updateSelection({locked:!e}));S.setAttribute("aria-pressed",String(e));const E=fe("div","ad-selection-actions");E.append(se("Duplicate selection","copy",()=>t.duplicate()),se("More arrangement options","align",re),S,se("Delete selection","trash",()=>t.deleteSelection())),T.append(E),(t.readonly||e)&&T.querySelectorAll("button,input,select").forEach(e=>e.disabled=e!==R&&(e!==S||t.readonly)),"Unlock selection"===a||"Lock selection"===a?S.focus():"Deselect"===a?R.focus():a?T.querySelector(`[aria-label="${CSS.escape(a)}"]`)?.focus():l&&[...T.querySelectorAll("label")].find(e=>e.querySelector(".ad-field-label")?.textContent===l)?.querySelector("input,select")?.focus(),(n||o?.focused)&&(!e||t.readonly||F.contains(document.activeElement)||S.focus())}function re(){const e=d("Give it a little order"),n=fe("div","ad-action-grid");if((1===t.selection.length?t.get(t.selection[0]):void 0)&&n.append(ge("Duplicate",()=>{t.duplicate(),e.close()}),ge("Delete",()=>{t.deleteSelection(),e.close()})),t.selection.length>1)for(const o of["left","center","right","top","middle","bottom","horizontal","vertical"])n.append(ge("horizontal"===o||"vertical"===o?`Distribute ${o}`:`Align ${o}`,()=>{t.align(o),e.close()}));t.selection.length>1&&n.append(ge("Group",()=>{t.group(),e.close()})),t.selection.some(e=>"group"===t.get(e)?.kind)&&n.append(ge("Ungroup",()=>{t.ungroup(),e.close()})),n.append(ge("Bring to front",()=>{t.apply(t.selection.map(e=>({op:"order",id:e,to:"front"})),{origin:"user",label:"Bring to front"}),e.close()}),ge("Send to back",()=>{t.apply(t.selection.map(e=>({op:"order",id:e,to:"back"})),{origin:"user",label:"Send to back"}),e.close()})),t.readonly&&n.querySelectorAll("button").forEach(e=>e.disabled=!0),e.append(n)}function ye(e){t.export(e,{scope:"page",padding:40,background:!0,..."png"===e?{scale:2}:{}}).then(n=>{!function(e,t,n){const o=URL.createObjectURL("string"==typeof e?new Blob([e],{type:n}):e),a=fe("a");a.href=o,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}(n,`${t.read().meta.title.replace(/[^a-z0-9 _-]/gi,"").trim()||"drawing"}.${"json"===e?"annie":e}`,"json"===e?oe:"svg"===e?"image/svg+xml":"image/png")}).catch(()=>{})}function be(){H.disabled=!t.canUndo,z.disabled=!t.canRedo,function(){if(!1===n.pages)return;const e=t.read().pages,o=JSON.stringify([t.pageId,e.map(({id:e,name:t})=>[e,t])]);o!==V&&(V=o,B.replaceChildren(...e.map(e=>q(e.id,e.name,!0))),N())}(),ae()}const ke=e=>{const{x:n,y:o,id:a}=e.detail,r=a?t.get(a):void 0;if(!r)return void c();const i=t.stage.root.getBoundingClientRect(),s=f("Element actions",{x:i.left+n,y:i.top+o}),l=t.isLocked(r.id);"video"!==r.kind&&"link"!==r.kind||s.add(ee(r.kind),"link",()=>te(r.id),l),["image","path","line","group","html","video","link"].includes(r.kind)||s.add("Edit text","text",()=>t.editText(r.id),l);const d=e=>t.apply([{op:"order",id:r.id,to:e}],{origin:"user",label:"front"===e?"Bring to front":"Send to back"});s.add("Bring to front","front",()=>d("front"),l),s.add("Send to back","back",()=>d("back"),l),s.add("Duplicate","copy",()=>{t.select([r.id]),t.duplicate()},l);const p=fe("div","ad-menu-separator");p.setAttribute("role","separator"),s.panel.append(p),s.add("Delete","trash",()=>{t.select([r.id]),t.deleteSelection()},l),s.show()};return t.host.addEventListener("ad-context",ke),a.push(t.on("change",be),t.on("select",()=>{ae()}),t.on("page",be),t.on("view",e=>{"manual"===i?.popover&&c(),Q.textContent=`${Math.round(100*e.zoom)}%`}),t.on("tool",e=>{for(const t of o.querySelectorAll("[data-tool]"))t.setAttribute("aria-pressed",String(e===t.dataset.tool));$.setAttribute("aria-pressed",String(L.includes(e))),t.stage.root.dataset.adTool=e,ae()})),be(),()=>{clearTimeout(l),c(),a.forEach(e=>e()),r?.close(),t.host.removeEventListener("ad-context",ke),o.remove()}}export{W as a,Y as c,G as d,Q as f,j as i,I as l,ee as m,oe as n,_ as o,X as p,ae as r,V as s,ye as t,ne as u};
2
- //# sourceMappingURL=ui-DEBI1jv_.js.map
1
+ import{g as e,t}from"./defaults-C-aC_B4z.js";var{PI:n}=Math,o=n+1e-4,a=[1,1];function r(e,t,n,o=e=>e){return e*o(.5-t*(.5-n))}var{min:i}=Math;function s(e,t,n){let o=i(1,t/n);return i(1,e+(i(1,1-o)-e)*(.275*o))}function l(e,t){return[e[0]+t[0],e[1]+t[1]]}function d(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function c(e,t){return[e[0]-t[0],e[1]-t[1]]}function p(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function u(e,t){return[e[0]*t,e[1]*t]}function h(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function f(e){return[e[1],-e[0]]}function g(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function m(e,t){return e[0]*t[0]+e[1]*t[1]}function v(e,t){return e[0]===t[0]&&e[1]===t[1]}function y(e,t){let n=e[0]-t[0],o=e[1]-t[1];return n*n+o*o}function b(e){return function(e,t){return[e[0]/t,e[1]/t]}(e,function(e){return Math.hypot(e[0],e[1])}(e))}function k(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function x(e,t,n){let o=Math.sin(n),a=Math.cos(n),r=e[0]-t[0],i=e[1]-t[1],s=r*o+i*a;return[r*a-i*o+t[0],s+t[1]]}function M(e,t,n,o){let a=Math.sin(o),r=Math.cos(o),i=t[0]-n[0],s=t[1]-n[1],l=i*r-s*a,d=i*a+s*r;return e[0]=l+n[0],e[1]=d+n[1],e}function A(e,t,n){return l(e,u(c(t,e),n))}function w(e,t,n,o){let a=n[0]-t[0],r=n[1]-t[1];return e[0]=t[0]+a*o,e[1]=t[1]+r*o,e}function L(e,t,n){return l(e,u(t,n))}var $=[0,0],S=[0,0],E=[0,0];function C(e,t){let n=L(e,b(f(c(e,l(e,[1,1])))),-t),a=[],r=1/13;for(let i=r;i<=1;i+=r)a.push(x(n,e,2*o*i));return a}function F(e,t,n){let a=[],r=1/n;for(let i=r;i<=1;i+=r)a.push(x(t,e,o*i));return a}function T(e,t,n){let o=c(t,n),a=u(o,.5),r=u(o,.51);return[c(e,a),c(e,r),l(e,r),l(e,a)]}function R(e,t,n,a){let r=[],i=L(e,t,n),s=1/a;for(let l=s;l<1;l+=s)r.push(x(i,e,3*o*l));return r}function D(e,t,n){return[l(e,u(t,n)),l(e,u(t,.99*n)),c(e,u(t,.99*n)),c(e,u(t,n))]}function H(e,t,n){return!1===e||void 0===e?0:!0===e?Math.max(t,n):e}function z(e,t={}){let{size:n=16,smoothing:a=.5,thinning:i=.5,simulatePressure:u=!0,easing:v=e=>e,start:b={},end:k={},last:x=!1}=t,{cap:A=!0,easing:L=e=>e*(2-e)}=b,{cap:z=!0,easing:P=e=>--e*e*e+1}=k;if(0===e.length||n<=0)return[];let B,U=e[e.length-1].runningLength,j=H(b.taper,n,U),I=H(k.taper,n,U),V=(n*a)**2,Z=[],q=[],W=function(e,t,n){return e.slice(0,10).reduce((e,o)=>{let a=o.pressure;return t&&(a=s(e,o.distance,n)),(e+a)/2},e[0].pressure)}(e,u,n),O=r(n,i,e[e.length-1].pressure,v),N=e[0].vector,G=e[0].point,Y=G,_=G,X=Y,Q=!1;for(let f=0;f<e.length;f++){let{pressure:t}=e[f],{point:a,vector:b,distance:k,runningLength:x}=e[f],A=f===e.length-1;if(!A&&U-x<3)continue;i?(u&&(t=s(W,k,n)),O=r(n,i,t,v)):O=n/2,void 0===B&&(B=O);let C=x<j?L(x/j):1,F=U-x<I?P((U-x)/I):1;O=Math.max(.01,O*Math.min(C,F));let T=(A?e[f]:e[f+1]).vector,R=A?1:m(b,T),D=null!==R&&R<0;if(m(b,N)<0&&!Q||D){g($,N),h($,$,O);for(let e=0;e<=1;e+=.07692307692307693)p(S,a,$),M(S,S,a,o*e),_=[S[0],S[1]],Z.push(_),d(E,a,$),M(E,E,a,o*-e),X=[E[0],E[1]],q.push(X);G=_,Y=X,D&&(Q=!0)}else Q=!1,A?(g($,b),h($,$,O),Z.push(c(a,$)),q.push(l(a,$))):(w($,T,b,R),g($,$),h($,$,O),p(S,a,$),_=[S[0],S[1]],(f<=1||y(G,_)>V)&&(Z.push(_),G=_),d(E,a,$),X=[E[0],E[1]],(f<=1||y(Y,X)>V)&&(q.push(X),Y=X),W=t,N=b)}let J=[e[0].point[0],e[0].point[1]],K=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:l(e[0].point,[1,1]),ee=[],te=[];if(1===e.length){if(!j&&!I||x)return C(J,B||O)}else{j||I&&1===e.length||(A?ee.push(...F(J,q[0],13)):ee.push(...T(J,Z[0],q[0])));let t=f(function(e){return[-e[0],-e[1]]}(e[e.length-1].vector));I||j&&1===e.length?te.push(K):z?te.push(...R(K,t,O,29)):te.push(...D(K,t,O))}return Z.concat(te,q.reverse(),ee)}var P=[0,0];function B(e){return null!=e&&e>=0}function U(e,t={}){return z(function(e,t={}){let{streamline:n=.5,size:o=16,last:r=!1}=t;if(0===e.length)return[];let i=.15+.85*(1-n),s=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(2===s.length){let e=s[1];s=s.slice(0,-1);for(let t=1;t<5;t++)s.push(A(s[0],e,t/4))}1===s.length&&(s=[...s,[...l(s[0],a),...s[0].slice(2)]]);let d=[{point:[s[0][0],s[0][1]],pressure:B(s[0][2])?s[0][2]:.25,vector:[...a],distance:0,runningLength:0}],c=!1,u=0,h=d[0],f=s.length-1;for(let a=1;a<s.length;a++){let e=r&&a===f?[s[a][0],s[a][1]]:A(h.point,s[a],i);if(v(h.point,e))continue;let t=k(e,h.point);if(u+=t,a<f&&!c){if(u<o)continue;c=!0}p(P,h.point,e),h={point:e,pressure:B(s[a][2])?s[a][2]:.5,vector:b(P),distance:t,runningLength:u},d.push(h)}return d[0].vector=d[1]?.vector||[0,0],d}(e,t),t)}var j="http://www.w3.org/2000/svg",I={sans:"Nunito Variable, Nunito, ui-rounded, system-ui, sans-serif",serif:"Georgia, serif",mono:"ui-monospace, SFMono-Regular, Menlo, monospace",hand:"Comic Sans MS, Chalkboard SE, cursive"};function V(e){return I[e??"hand"]}var Z={ink:"#103639",slate:"#606062",coral:"#FF9302",amber:"#FFC68A",moss:"#AAF1AC",teal:"#05D9AB",sky:"#92CAFF",violet:"#8F93F9",rose:"#F89B97",paper:"#FFFFFF"},q={...Z,ink:"#E9F7F3",slate:"#B6C5C1",paper:"#173D40"};function W(e="ink",t="light"){return("dark"===t?q:Z)[e]??e}function O(e){if(e={black:"#000000",white:"#ffffff",red:"#ff0000",blue:"#0000ff",green:"#008000",yellow:"#ffff00",transparent:"#00000000"}[e.toLowerCase()]??e,/^#[\da-f]{3,4}$/i.test(e)&&(e=`#${[...e.slice(1)].map(e=>e+e).join("")}`),/^#[\da-f]{6}([\da-f]{2})?$/i.test(e))return[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)).concat(9===e.length?parseInt(e.slice(7,9),16)/255:1);if(!/^rgba?\(/i.test(e))return;const t=e.match(/[\d.]+%?/g);return!t||t.length<3?void 0:t.slice(0,3).map(e=>parseFloat(e)*(e.endsWith("%")?2.55:1)).concat(void 0===t[3]?1:parseFloat(t[3])/(t[3].endsWith("%")?100:1))}function N(e){return e.slice(0,3).map(e=>{const t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}).reduce((e,t,n)=>e+t*[.2126,.7152,.0722][n],0)}function G(e,t){if("text"===e.kind)return W(e.style?.stroke??"ink",t);const n=W("ink",t),o=K(e,t);if(["connector","line"].includes(e.kind)||"solid"!==o.fillMode)return n;const a=O(o.fill);if(!a)return n;const r=O(W("paper",t)),i=N(a.slice(0,3).map((e,t)=>e*a[3]+r[t]*(1-a[3]))),s=e=>{const t=N(O(e));return(Math.max(i,t)+.05)/(Math.min(i,t)+.05)};for(const l of[n,W("ink","dark"===t?"light":"dark")])if(s(l)>=4.5)return l;return s("#0F0B0A")>=s("#FFFFFF")?"#0F0B0A":"#FFFFFF"}function Y(e){return"number"==typeof e?.size?e.size:{s:14,m:18,l:26,xl:36}[e?.size??"m"]}function _(e){return String(e??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e]))}function X(e){return Math.round(1e3*e)/1e3}function Q(e,t=!1){return e.map((e,t)=>`${t?"L":"M"}${X(e.x)},${X(e.y)}`).join(" ")+(t?" Z":"")}function J(e){const t=e.w,n=e.h;if("ellipse"===e.kind)return`M${t},${n/2}a${t/2},${n/2} 0 1 0 ${-t},0a${t/2},${n/2} 0 1 0 ${t},0Z`;if("diamond"===e.kind)return`M${t/2},0L${t},${n/2}L${t/2},${n}L0,${n/2}Z`;if("line"===e.kind)return Q((e.points??[[0,0],[t,n]]).map(([e,t])=>({x:e,y:t})));if("path"===e.kind)return function(e){const t=e.points??[];if(!t.length)return"";if(e.closed)return Q(t.map(([e,t])=>({x:e,y:t})),!0);const n=U(t.map(([e,t,n])=>({x:e,y:t,pressure:n})),{size:2.2*(e.style?.strokeWidth??2),thinning:.45,smoothing:.6,streamline:.45,simulatePressure:t.every(e=>void 0===e[2]),last:!0});return n.length?`M${n.map(e=>`${X(e[0])},${X(e[1])}`).join(" L")} Z`:""}(e);const o=Math.max(0,Math.min(e.style?.corner??12,t/2,n/2));return`M${o},0H${t-o}Q${t},0 ${t},${o}V${n-o}Q${t},${n} ${t-o},${n}H${o}Q0,${n} 0,${n-o}V${o}Q0,0 ${o},0Z`}function K(e,t){const n=e.style?.fill??("note"===e.kind?"moss":"none");return{stroke:W(e.style?.stroke??"ink",t),strokeWidth:e.style?.strokeWidth??("note"===e.kind?0:2),dash:e.style?.dash??"solid",fill:W(n,t),fillMode:e.style?.fillMode??"solid",corner:e.style?.corner??12,opacity:e.style?.opacity??1}}function ee(e,t,n,o=J(e)){const a=K(e,t),r="dashed"===a.dash?"8 6":"dotted"===a.dash?"1 6":"",i="path"===e.kind,s="line"===e.kind||"connector"===e.kind?"none":i?e.closed&&"none"!==a.fill?a.fill:a.stroke:a.fill,l=`ad_h_${n.replace(/[^a-z0-9_-]/gi,"_")}`,d="hatch"===a.fillMode&&"none"!==s&&!i,c=d?`url(#${l})`:s;return`${d?`<defs><pattern id="${l}" width="8" height="8" patternUnits="userSpaceOnUse"><path d="M-2 2L2-2M0 8L8 0M6 10L10 6" fill="none" stroke="${_(s)}" stroke-opacity="0.5" stroke-width="1.3"/></pattern></defs>`:""}<path d="${_(o)}" fill="${_(c)}"${"tint"!==a.fillMode||i?"":' fill-opacity="0.22"'} stroke="${i&&!e.closed?"none":_(a.stroke)}" stroke-width="${a.strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${r?` stroke-dasharray="${r}"`:""}/>`}function te(e,t,n,o,a){if(!n||"none"===n)return"";if("dot"===n)return`<circle cx="${X(e.x)}" cy="${X(e.y)}" r="${Math.max(3,2*a)}" fill="${_(o)}"/>`;const r=Math.atan2(e.y-t.y,e.x-t.x),i=Math.max(10,4.5*a),s=Math.PI/6;return`<path d="${Q([{x:e.x-Math.cos(r-s)*i,y:e.y-Math.sin(r-s)*i},e,{x:e.x-Math.cos(r+s)*i,y:e.y-Math.sin(r+s)*i}])}" fill="none" stroke="${_(o)}" stroke-width="${a}" stroke-linecap="round" stroke-linejoin="round"/>`}function ne(e,t,n){if(e.length<2)return"";const o=K(t,n);return te(e[0],e[1],t.heads?.start,o.stroke,o.strokeWidth)+te(e[e.length-1],e[e.length-2],t.heads?.end??("connector"===t.kind?"arrow":"none"),o.stroke,o.strokeWidth)}var oe="application/vnd.anniedrawing+json";function ae(e){return JSON.stringify(e,null,2)}var re={select:'<path d="M5.8 3.8c-1-.4-1.7.4-1.4 1.4l4.9 14.4c.4 1.1 1.8 1.1 2.2 0l2.2-5.8 5.8-2.2c1.1-.4 1.1-1.8 0-2.2Z"/>',hand:'<path d="M8 12V6a2 2 0 0 1 4 0v5-7a2 2 0 0 1 4 0v8-5a2 2 0 0 1 4 0v8c0 5-4 7-7 7-3 0-4-2-6-5l-3-4c-1-2 1-4 3-2l2 2"/>',rect:'<rect x="3.75" y="4.75" width="16.5" height="14.5" rx="4"/>',ellipse:'<ellipse cx="12" cy="12" rx="8.25" ry="7.25"/>',diamond:'<path d="m13.4 3.8 6.8 6.8a2 2 0 0 1 0 2.8l-6.8 6.8a2 2 0 0 1-2.8 0l-6.8-6.8a2 2 0 0 1 0-2.8l6.8-6.8a2 2 0 0 1 2.8 0Z"/>',line:'<path d="m5.5 18.5 13-13"/><circle cx="5" cy="19" r="1.5" fill="currentColor" stroke="none"/><circle cx="19" cy="5" r="1.5" fill="currentColor" stroke="none"/>',connector:'<path d="M4 18h5a3 3 0 0 0 3-3V9a3 3 0 0 1 3-3h5m-4-4 4 4-4 4"/>',path:'<path d="M3.5 17.5c1.8-5 3.2-11 6-11 4 0-1 12 3 12 2.8 0 3.2-8 5.5-8 1.6 0 2.3 2 2.5 4"/>',text:'<path d="M5 7V4.5h14V7M12 4.5v15M8.5 19.5h7"/>',note:'<path d="M7 3.75h10a3.25 3.25 0 0 1 3.25 3.25v7.1a2 2 0 0 1-.6 1.4l-4.2 4.2a2 2 0 0 1-1.4.6H7A3.25 3.25 0 0 1 3.75 17V7A3.25 3.25 0 0 1 7 3.75Z"/><path d="M20 14h-3.5a2.5 2.5 0 0 0-2.5 2.5V20"/>',lock:'<rect x="5" y="10" width="14" height="11" rx="3.5"/><path d="M8 10V7a4 4 0 0 1 8 0v3M12 14v3"/>',unlock:'<rect x="5" y="10" width="14" height="11" rx="3.5"/><path d="M8 10V7a4 4 0 0 1 7.5-2M12 14v3"/>',opacity:'<circle cx="12" cy="12" r="8.5"/><path d="M12 3.5a8.5 8.5 0 0 1 0 17Z" fill="currentColor" stroke="none"/>',front:'<rect x="8" y="3.5" width="12.5" height="12.5" rx="3.5"/><path d="M15.5 16v1A3.5 3.5 0 0 1 12 20.5H7A3.5 3.5 0 0 1 3.5 17v-5A3.5 3.5 0 0 1 7 8.5h1"/>',back:'<rect x="3.5" y="8" width="12.5" height="12.5" rx="3.5"/><path d="M8.5 8V7A3.5 3.5 0 0 1 12 3.5h5A3.5 3.5 0 0 1 20.5 7v5A3.5 3.5 0 0 1 17 15.5h-1"/>',eraser:'<path d="m13.2 4.3-9 9a2.4 2.4 0 0 0 0 3.4L7.5 20h4l8.2-8.2a2.4 2.4 0 0 0 0-3.4l-4.1-4.1a1.7 1.7 0 0 0-2.4 0ZM8 10.5l6 6M11.5 20H21"/>',undo:'<path d="m8 5-4.5 4.5L8 14M4 9.5h9.5a5.5 5.5 0 0 1 0 11H11"/>',redo:'<path d="m16 5 4.5 4.5L16 14m4-4.5h-9.5a5.5 5.5 0 0 0 0 11H13"/>',plus:'<path d="M12 5.5v13M5.5 12h13"/>',minus:'<path d="M5.5 12h13"/>',fit:'<path d="M8.5 3.75h-3a1.75 1.75 0 0 0-1.75 1.75v3m11.75-4.75h3a1.75 1.75 0 0 1 1.75 1.75v3M3.75 15.5v3a1.75 1.75 0 0 0 1.75 1.75h3m11.75-4.75v3a1.75 1.75 0 0 1-1.75 1.75h-3"/>',chevron:'<path d="m7 9.5 3.6 3.6a2 2 0 0 0 2.8 0L17 9.5"/>',download:'<path d="M12 3.5v11m-4-4 4 4 4-4M4.5 15.5v2A3 3 0 0 0 7.5 20h9a3 3 0 0 0 3-2.5v-2"/>',upload:'<path d="M12 15V4m-4 4 4-4 4 4M4.5 15.5v2A3 3 0 0 0 7.5 20h9a3 3 0 0 0 3-2.5v-2"/>',code:'<path d="m7 7-4 4a1.4 1.4 0 0 0 0 2l4 4m10-10 4 4a1.4 1.4 0 0 1 0 2l-4 4M14 4l-4 16"/>',close:'<path d="m6.5 6.5 11 11m-11 0 11-11"/>',more:'<circle cx="5" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1.6" fill="currentColor" stroke="none"/>',image:'<rect x="3.5" y="3.5" width="17" height="17" rx="4"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m4 17 3.6-3.6a1.3 1.3 0 0 1 1.8 0l2.1 2.1 3.4-5.1a1.3 1.3 0 0 1 2.2 0L20 15"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2.5v1M12 20.5v1M2.5 12h1m17 0h1M5.3 5.3l.7.7m12 12 .7.7M5.3 18.7l.7-.7M18 6l.7-.7"/>',moon:'<path d="M20 14.5a8.2 8.2 0 0 1-10.5-10c-3.9.7-6.4 3.7-6.4 7.5a8.1 8.1 0 0 0 16.9 2.5Z"/>',trash:'<path d="M4 6.5h16M9 6.5V5a1.5 1.5 0 0 1 1.5-1.5h3A1.5 1.5 0 0 1 15 5v1.5m-9 0 .7 11.2A3 3 0 0 0 9.7 20.5h4.6a3 3 0 0 0 3-2.8L18 6.5M10 10.5v6m4-6v6"/>',copy:'<rect x="8" y="8" width="12.5" height="12.5" rx="3.5"/><path d="M15.5 8V7A3.5 3.5 0 0 0 12 3.5H7A3.5 3.5 0 0 0 3.5 7v5A3.5 3.5 0 0 0 7 15.5h1"/>',grid:'<rect x="3.5" y="3.5" width="17" height="17" rx="4"/><path d="M9 4v16m6-16v16M4 9h16M4 15h16"/>',book:'<path d="M12 5.5c-2.6-2-5.2-2.5-8-2v15c2.8-.5 5.4 0 8 2 2.6-2 5.2-2.5 8-2v-15c-2.8-.5-5.4 0-8 2Zm0 0v15"/>',github:'<path fill="currentColor" stroke="none" d="M12 1C5.922 1 1 5.922 1 12c0 4.867 3.149 8.979 7.521 10.437.55.096.75-.232.75-.546 0-.262-.013-1.13-.013-2.049-3.06.56-3.703-1.31-3.703-1.31-.498-1.316-1.216-1.667-1.216-1.667-.991-.68.075-.668.075-.668 1.109.075 1.688 1.264 1.688 1.264.982 1.686 2.573 1.2 3.201.907.096-.699.381-1.2.695-1.478-2.448-.282-5.022-1.226-5.022-5.451 0-1.2.426-2.187 1.12-2.953-.113-.275-.487-1.392.107-2.9 0 0 .917-.292 3.011 1.12.873-.24 1.809-.36 2.74-.36.93 0 1.867.12 2.74.36 2.077-1.413 3.01-1.12 3.01-1.12.596 1.508.221 2.625.108 2.9.697.766 1.12 1.748 1.12 2.953 0 4.237-2.578 5.163-5.034 5.437.39.338.746 1.016.746 2.056 0 1.478-.014 2.666-.014 3.025 0 .304.202.655.753.545C19.854 20.979 23 16.859 23 12c0-6.078-4.922-11-11-11Z"/>',alignLeft:'<path d="M4 5h16M4 12h10M4 19h16"/>',alignCenter:'<path d="M4 5h16M7 12h10M4 19h16"/>',alignRight:'<path d="M4 5h16M10 12h10M4 19h16"/>',align:'<path d="M4 3.5v17"/><rect x="8" y="5" width="12.5" height="5" rx="1.75"/><rect x="8" y="14" width="8.5" height="5" rx="1.75"/>',shapes:'<rect x="3" y="3" width="8.5" height="8.5" rx="2.5"/><circle cx="17.3" cy="6.7" r="3.7"/><path d="m6 14-3.5 6h8L7 14a.6.6 0 0 0-1 0Z"/><rect x="13.5" y="13.5" width="7" height="7" rx="2" transform="rotate(45 17 17)"/>',link:'<path d="M10 14.5 8.8 15.7a3.6 3.6 0 1 1-5.1-5.1l3.2-3.2a3.6 3.6 0 0 1 5.1 0"/><path d="m14 9.5 1.2-1.2a3.6 3.6 0 0 1 5.1 5.1l-3.2 3.2a3.6 3.6 0 0 1-5.1 0"/>'};function ie(e){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${re[e]??re.select}</svg>`}function se(e,t,n,o="ad-icon-button"){const a=document.createElement("button");return a.type="button",a.className=o,a.title=e,a.setAttribute("aria-label",e),a.innerHTML=ie(t),a.addEventListener("click",()=>{a.focus(),n()}),a}var le="0.3.3",de="https://github.com/Frontierz-AI/AnnieDrawing",ce=["png","svg"];var pe=[["select","Select","V"],["hand","Hand","H"],["rect","Rectangle","R"],["ellipse","Ellipse","O"],["diamond","Diamond","D"],["connector","Arrow","A"],["line","Line","L"],["path","Draw","P"],["text","Text","T"],["note","Sticky note","N"],["eraser","Eraser","E"]],ue=[["ink","Ink"],["paper","Paper"],["teal","Frontierz green"],["moss","Soft green"],["coral","Orange"],["violet","Lavender"],["slate","Slate"],["amber","Peach"],["sky","Sky blue"],["rose","Rose"],["none","No fill"]];function he(e,t){return e<=700||e<=1023&&t<=640}function fe(e,t="",n){const o=document.createElement(e);return o.className=t,n&&(o.textContent=n),o}function ge(e,t,n="ad-button"){const o=fe("button",n,e);return o.type="button",o.addEventListener("click",()=>{o.focus(),t()}),o}function me(e,t){const n=fe("label","ad-field");return n.append(fe("span","ad-field-label",e),t),n}function ve(e,t,n){const o=fe("select");if(e.forEach(([e,t])=>{const n=fe("option","",t);n.value=e,o.append(n)}),!e.some(([e])=>e===t)){const e=fe("option","",t);e.value=t,o.append(e)}return o.value=t,o.onchange=()=>n(o.value),o}function ye(t,n={}){const o=fe("div","ad-ui");t.stage.root.append(o);const a=[];let r,i,s,l;function d(e){c(),r?.close();const n=document.activeElement,a=fe("dialog","ad-dialog"),i=fe("div","ad-dialog-head"),s=fe("div");return s.append(fe("h2","",e)),i.append(s,se("Close","close",()=>a.close())),a.append(i),a.addEventListener("click",e=>{if(e.target===a){const t=a.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&a.close()}}),a.addEventListener("close",()=>{a.remove(),r===a&&(r=void 0),r||(be(),n?.isConnected?n.focus():t.focus())}),o.append(a),r=a,a.showModal(),a}function c(){i?.hidePopover(),i?.remove(),i=void 0,s?.setAttribute("aria-expanded","false"),s&&(s.popoverTargetElement=null),s=void 0}function p(e,n){if(e&&s===e&&i?.matches(":popover-open"))return void c();c();const a=fe("div","ad-popover");a.popover="auto",a.setAttribute("role","group"),a.setAttribute("aria-label",n);const r=document.activeElement;return e&&(e.setAttribute("aria-expanded","true"),e.popoverTargetElement=a,e.popoverTargetAction="show"),i=a,s=e,a.addEventListener("toggle",()=>{i!==a||a.matches(":popover-open")||e?.setAttribute("aria-expanded","false")}),a.addEventListener("keydown",e=>{if(e.stopPropagation(),"Escape"===e.key||"Tab"===e.key&&"manual"===a.popover)"Escape"===e.key&&e.preventDefault(),c(),r?.isConnected?r.focus():t.focus();else if(!(e.target instanceof HTMLInputElement)&&["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key)){const t=h(a),n=t.indexOf(document.activeElement),o="Home"===e.key?0:"End"===e.key?t.length-1:(n+("ArrowDown"===e.key||"ArrowRight"===e.key?1:-1)+t.length)%t.length;e.preventDefault(),t[o]?.focus()}}),o.append(a),a}function u(e,n,o=n){e.showPopover();const a=o.getBoundingClientRect(),r=t.stage.root.getBoundingClientRect(),i=he(r.width,r.height),s=Math.min(228,r.width-24);e.style.width=`${s}px`;const l=e.getBoundingClientRect().height,d=n.closest(".ad-toolbar")&&!i,c=d?a.right+12:n.closest(".ad-header")&&a.left<r.left+r.width/2?a.left:a.right-s,p=d?a.top:a.top>r.top+r.height/2?a.top-l-10:a.bottom+10;e.style.left=`${Math.max(r.left+12,Math.min(c,r.right-s-12))}px`,e.style.top=`${Math.max(r.top+12,Math.min(p,r.bottom-l-12))}px`,h(e)[0]?.focus()}function h(e){return[...e.querySelectorAll("button:not(:disabled), a[href]")]}function f(e,n){const o=p(void 0,e);o.popover="manual",o.classList.add("ad-context-menu"),o.setAttribute("role","menu"),o.tabIndex=-1;return{panel:o,add:(e,n,a,r=!1)=>{const i=ge(e,()=>{c(),t.focus(),a()},"ad-tool-option");i.insertAdjacentHTML("afterbegin",ie(n)),i.setAttribute("role","menuitem"),i.disabled=t.readonly||r,"trash"===n&&i.classList.add("ad-danger"),o.append(i)},show:()=>{o.showPopover();const e=t.stage.root.getBoundingClientRect(),a=Math.min(228,e.width-24);o.style.width=`${a}px`;const r=o.getBoundingClientRect().height;o.style.left=`${Math.max(e.left+12,Math.min(n.x,e.right-a-12))}px`,o.style.top=`${Math.max(e.top+12,Math.min(n.y,e.bottom-r-12))}px`,(o.querySelector("button:not(:disabled)")??o).focus()}}}const g=()=>c(),m=e=>{"manual"!==i?.popover||i.contains(e.target)||c()};window.addEventListener("resize",g),window.addEventListener("pointerdown",m,!0),a.push(()=>{window.removeEventListener("resize",g),window.removeEventListener("pointerdown",m,!0)});const v=!1!==n.menu,y=function(e){if(!1===e)return[];if(!Array.isArray(e))return[...ce];const t=/* @__PURE__ */new Set,n=[];for(const o of e)"png"!==o&&"svg"!==o&&"json"!==o||t.has(o)||(t.add(o),n.push(o));return n}(n.export),b=fe("header","ad-header");let k,x,M;if(v&&(k=se("Board menu","chevron",function(){if(!k)return;const e=p(k,"Board menu");if(!e)return;e.classList.add("ad-tool-options");const n=(t,n,o,a=!1)=>{const r=se(t,n,()=>{c(),o()},"ad-tool-option");r.innerHTML+=`<span>${t}</span>`,r.disabled=a,e.append(r)};n("Open a drawing","upload",()=>x?.click(),t.readonly),he(t.stage.root.clientWidth,t.stage.root.clientHeight)&&n("Hand","hand",()=>{t.setTool("hand"),t.focus()});n(t.grid?"Hide grid":"Show grid","grid",()=>t.setGrid(!t.grid));const o="dark"===t.stage.resolvedTheme;n(o?"Light appearance":"Dark appearance",o?"sun":"moon",()=>t.setTheme(o?"light":"dark")),n("Documentation","book",()=>{window.open("./docs/index.html","_blank","noopener")});const a=fe("a","ad-tool-option");a.href=de,a.target="_blank",a.rel="noopener noreferrer",a.title="GitHub",a.innerHTML=`${ie("github")}<span>GitHub</span>`,a.addEventListener("click",()=>c());const r=fe("div","ad-menu-separator");r.setAttribute("role","separator"),e.append(a,r,fe("p","ad-menu-version",`v${le}`)),u(e,k)},"ad-brand"),k.innerHTML='<span class="ad-brand-mark" aria-hidden="true"><svg viewBox="0 0 40 40"><path d="M9 29 20 8l11 21M14 22h12" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/><circle cx="32" cy="9" r="2.5" fill="currentColor"/></svg></span><span class="ad-brand-name">AnnieDrawing</span>'+ie("chevron"),k.setAttribute("aria-haspopup","true"),k.setAttribute("aria-expanded","false"),x=fe("input"),x.type="file",x.accept=".annie,.json,application/json",x.hidden=!0,x.onchange=()=>{const e=x?.files?.[0];x&&(x.value=""),e&&e.text().then(e=>t.load(JSON.parse(e))).catch(()=>{})},b.append(k)),y.length){const e=fe("div","ad-header-actions");M=ge("Export",function(){if(1===y.length)return void ye(y[0]);if(!M)return;const e=p(M,"Export");if(!e)return;e.classList.add("ad-tool-options");const t={png:["PNG Image","image"],svg:["SVG Image","image"],json:["AnnieDoc format","code"]};for(const n of y){const[o,a]=t[n],r=se(o,a,()=>{c(),ye(n)},"ad-tool-option");r.innerHTML+=`<span>${o}</span>`,e.append(r)}u(e,M)},"ad-button ad-primary"),M.insertAdjacentHTML("afterbegin",ie("download")),y.length>1&&(M.setAttribute("aria-haspopup","true"),M.setAttribute("aria-expanded","false")),e.append(M),b.append(e)}v||b.classList.add("ad-header-end"),(v||y.length)&&o.append(b),x&&o.append(x);const A=fe("nav","ad-toolbar");function w(e,n=!1){const[,o,a]=pe.find(t=>t[0]===e),r=se(o,e,()=>{c(),t.setTool(e),t.focus()},n?"ad-tool-option":"ad-icon-button");return r.dataset.tool=e,r.setAttribute("aria-keyshortcuts",a),r.setAttribute("aria-pressed",String(t.tool===e)),r.innerHTML+=n?`<span>${o}</span>`:`<span class="ad-tooltip">${o}</span>`,t.readonly&&"hand"!==e&&"select"!==e&&(r.disabled=!0),r}A.setAttribute("aria-label","Drawing tools");const L=["rect","ellipse","diamond","line","connector"],$=se("Shapes","shapes",()=>{const e=p($,"Shapes");e&&(e.classList.add("ad-tool-options"),e.append(...L.map(e=>w(e,!0))),u(e,$))});$.setAttribute("aria-haspopup","true"),$.setAttribute("aria-expanded","false"),$.innerHTML+='<span class="ad-tool-corner"></span><span class="ad-tooltip">Shapes</span>';const S=fe("input");S.type="file",S.accept="image/png,image/jpeg,image/webp,image/gif,image/avif",S.hidden=!0,S.onchange=()=>{S.files?.[0]&&t.addImage(S.files[0]).catch(()=>{}),S.value=""};const E=se("Add image","image",()=>{c(),S.click()});E.innerHTML+='<span class="ad-tooltip">Add image</span>',E.disabled=t.readonly;const C=w("hand");v&&C.classList.add("ad-desktop-tool"),A.append(w("select"),C,w("eraser"),fe("div","ad-toolbar-divider"),$,w("path"),w("text"),w("note"),E,S),o.append(A);const F=fe("aside","ad-style-dock");F.setAttribute("aria-label","Selection style"),F.hidden=!0;const T=fe("div","ad-style-panel"),R=se("Deselect","chevron",()=>t.select([]));R.classList.add("ad-style-dismiss"),F.append(R,T),o.append(F);const D=fe("footer","ad-footer"),H=se("Undo","undo",()=>t.undo()),z=se("Redo","redo",()=>t.redo());H.setAttribute("aria-keyshortcuts","Meta+Z Control+Z"),z.setAttribute("aria-keyshortcuts","Meta+Shift+Z Control+Shift+Z");const P=fe("nav","ad-pages");P.setAttribute("aria-label","Pages");const B=fe("div","ad-page-tabs");B.setAttribute("role","tablist"),B.setAttribute("aria-label","Pages");const U=se("All pages","more",function(){const e=p(U,"All pages");if(!e)return;e.classList.add("ad-pages-popover");for(const n of t.read().pages){const t=fe("div","ad-page-row");t.append(q(n.id,n.name));const o=se(`Actions for ${n.name}`,"more",()=>{const e=o.getBoundingClientRect();Z(n.id,n.name,{x:e.left,y:e.top})});t.append(o),e.append(t)}u(e,U),e.querySelector('[aria-current="true"]')?.scrollIntoView({block:"nearest"})});U.setAttribute("aria-haspopup","true"),U.setAttribute("aria-expanded","false"),U.hidden=!0;const j=se("Add page","plus",function(){c();const n=e(),o=t.read().pages;let a=o.length+1;for(;o.some(e=>e.name===`Page ${a}`);)a++;t.apply([{op:"page.add",page:{id:n,name:`Page ${a}`,items:[]}}],{origin:"user",label:"Add page"}).ok&&t.setPage(n)});j.disabled=t.readonly,P.append(B,U,j);let V="";function Z(e,n,o){const a=f("Page actions",o);a.add("Rename page","text",()=>function(e,n){if(t.readonly)return;const o=d("Name this page"),a=fe("input");a.value=n,a.maxLength=100,o.append(me("Page name",a),ge("Save name",()=>{a.value.trim()&&t.apply([{op:"page.set",id:e,patch:{name:a.value.trim()}}],{origin:"user",label:"Rename page"}),o.close()},"ad-button ad-primary")),a.addEventListener("keydown",e=>{"Enter"===e.key&&o.querySelector(".ad-primary")?.click()}),o.addEventListener("close",()=>{const t=B.querySelector(`[data-page-id="${CSS.escape(e)}"]`);t&&!t.hidden?t.focus():U.hidden||U.focus()},{once:!0}),a.focus(),a.select()}(e,n)),a.add("Delete page","trash",()=>{t.apply([{op:"page.remove",id:e}],{origin:"user",label:"Delete page"})},1===t.read().pages.length),a.show()}function q(e,n,o=!1){const a=ge(n,()=>{c(),t.setPage(e),B.querySelector('[aria-selected="true"]')?.focus()},o?"ad-page-tab":"ad-tool-option");a.title=n,a.dataset.pageId=e;let r,i=!1;a.addEventListener("pointerdown",t=>{i=!1,"touch"===t.pointerType&&(r={x:t.clientX,y:t.clientY},clearTimeout(l),l=setTimeout(()=>{i=!0,Z(e,n,r)},500))}),a.addEventListener("pointermove",e=>{r&&Math.hypot(e.clientX-r.x,e.clientY-r.y)>10&&clearTimeout(l)});for(const t of["pointerup","pointercancel"])a.addEventListener(t,()=>clearTimeout(l));return a.addEventListener("click",e=>{i&&(e.preventDefault(),e.stopImmediatePropagation())},!0),o?(a.setAttribute("role","tab"),a.setAttribute("aria-selected",String(t.pageId===e)),a.tabIndex=t.pageId===e?0:-1):a.setAttribute("aria-current",String(t.pageId===e)),a.addEventListener("contextmenu",t=>{t.preventDefault(),Z(e,n,{x:t.clientX,y:t.clientY})}),a.addEventListener("keydown",r=>{if("ContextMenu"===r.key||r.shiftKey&&"F10"===r.key){r.preventDefault();const t=a.getBoundingClientRect();Z(e,n,{x:t.left,y:t.top})}else if(o&&["ArrowLeft","ArrowRight","Home","End"].includes(r.key)){r.preventDefault();const n=t.read().pages,o=n.findIndex(t=>t.id===e),a="Home"===r.key?0:"End"===r.key?n.length-1:(o+("ArrowRight"===r.key?1:-1)+n.length)%n.length;c(),t.setPage(n[a].id),B.querySelector('[aria-selected="true"]')?.focus()}}),a}let O=!1;function N(){if(O)return;O=!0;const e=fe("div","ad-page-tabs");try{const t=[...B.querySelectorAll("button")];e.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:max-content";const n=t.map(e=>{const t=e.cloneNode(!0);return t.hidden=!1,t.style.maxWidth="",t}),a=U.cloneNode(!0);a.hidden=!1,e.append(...n,a),o.append(e);const r=n.map(e=>e.getBoundingClientRect().width),i=a.offsetWidth;e.remove();const s=r.reduce((e,t)=>e+t+4,0)+j.offsetWidth+14,l=P.offsetTop===_.offsetTop?D.clientWidth-_.offsetWidth-16:P.clientWidth,d=Math.min(l,520),c=s<=d,p=t.map(()=>!1),u=t.map(()=>"");if(!c){let e=Math.max(40,d-j.offsetWidth-14-i-4);const n=t.findIndex(e=>"true"===e.getAttribute("aria-selected"));for(const o of[n,...t.map((e,t)=>t).filter(e=>e!==n)])o<0||(o===n?(u[o]=`${e}px`,e-=Math.min(e,r[o])+4):(p[o]=r[o]>e,p[o]||(e-=r[o]+4)))}U.hidden=c,t.forEach((e,t)=>{e.hidden=p[t],e.style.maxWidth=u[t]})}finally{e.remove(),O=!1}}const G=new ResizeObserver(N);!1!==n.pages&&(G.observe(o),a.push(()=>G.disconnect()));const _=fe("div","ad-footer-right"),X=fe("div","ad-zoom"),Q=ge("100%",()=>{const e=p(Q,"Zoom controls");if(!e)return;const n=fe("div","ad-zoom-controls");n.append(se("Zoom out","minus",()=>t.view.zoom/=1.2),ge("100%",()=>t.view.zoom=1,"ad-zoom-value"),se("Zoom in","plus",()=>t.view.zoom*=1.2)),e.append(n),u(e,Q,J)},"ad-zoom-value");Q.setAttribute("aria-label","Zoom controls"),Q.setAttribute("aria-haspopup","true"),Q.setAttribute("aria-expanded","false");const J=se("Fit drawing","fit",()=>t.view.fit());function ee(e){return"video"===e?"Edit Video URL":"Edit URL"}function te(e){if(t.readonly||t.isLocked(e))return;const n=t.get(e);if(!n||"video"!==n.kind&&"link"!==n.kind)return;const o="video"===n.kind,a=d(o?"Edit video URL":"Edit URL"),r=fe("input");r.type="text",r.inputMode="url",r.setAttribute("autocomplete","url"),r.spellcheck=!1,r.maxLength=2e3,r.value=n.href??"",r.setAttribute("aria-label",o?"Video URL":"URL");const i=fe("p","ad-dialog-error");i.setAttribute("role","alert"),i.hidden=!0;const s=ge(o?"Save video URL":"Save URL",()=>{(async()=>{s.disabled=!0;const n=await t.setHref(e,r.value);if(s.disabled=!1,!n.ok){const e=n.errors[0]?.code;return i.textContent="LOCKED"===e||"READONLY"===e?n.errors[0]?.message??"This cannot be edited.":o?"Use a YouTube or Vimeo URL.":"Use an http(s) URL.",i.hidden=!1,r.setAttribute("aria-invalid","true"),void r.focus()}a.close()})()},"ad-button ad-primary");a.append(me(o?"Video URL":"URL",r),i,s),r.addEventListener("input",()=>{i.hidden=!0,r.removeAttribute("aria-invalid")}),r.addEventListener("keydown",e=>{"Enter"===e.key&&a.querySelector(".ad-primary")?.click()}),r.focus(),r.select()}X.append(Q,J,H,z),_.append(X),!1===n.pages?D.append(_):D.append(P,_),o.append(D);let ne="";function ae(){const e=t.selection.some(e=>t.isLocked(e));if("select"!==t.tool)return s&&F.contains(s)&&c(),void(F.hidden=!0);if(r||!e&&document.activeElement instanceof HTMLInputElement&&"range"===document.activeElement.type&&(F.contains(document.activeElement)||i?.contains(document.activeElement)))return;const n=F.contains(document.activeElement)?document.activeElement:void 0,o=s&&F.contains(s)?{label:s.getAttribute("aria-label"),focused:i?.contains(document.activeElement)}:void 0,a=n?.getAttribute("aria-label")??(o?.focused?o.label:void 0),l=n?.closest("label")?.querySelector(".ad-field-label")?.textContent;o&&c();const d=t.selection.map(e=>t.get(e)).filter(Boolean),h=d.map(e=>e.id).join(",");if(ne!==h&&c(),ne=h,T.replaceChildren(),F.hidden=0===d.length,!d.length)return void(o?.focused&&t.focus());const f=d[0],g=1===d.length,m=d.every(e=>["rect","ellipse","diamond","note"].includes(e.kind)),v=d.every(e=>!["image","html","video","link","group","text","note"].includes(e.kind)),y=d.every(e=>"text"===e.kind),b=d.every(e=>!["image","path","line","group","html","video","link"].includes(e.kind)),k=fe("div","ad-color-controls");function x(e,n){const o=f.style?.[n]??("fill"===n?"note"===f.kind?"moss":"none":"ink"),a=ge(e,()=>{const r=p(a,`${e} color`);if(r){r.classList.add("ad-color-popover");for(const[a,i]of ue){const s=fe("button","ad-swatch "+("none"===a?"ad-swatch-none":""));s.type="button",s.style.setProperty("--swatch",W(a,t.stage.resolvedTheme)),s.setAttribute("aria-label",`${e}: ${i}`),s.title=i,s.setAttribute("aria-pressed",String(o===a)),s.onclick=()=>{c(),t.defaultStyle[n]=a,t.updateSelection({style:{[n]:a}}),T.querySelector(`[aria-label="${e}"]`)?.focus()},r.append(s)}u(r,a)}},"ad-color-control");a.setAttribute("aria-label",e),a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-expanded","false");const r=fe("span","ad-color-preview "+("none"===o?"ad-swatch-none":""));r.style.setProperty("--swatch",W(o,t.stage.resolvedTheme)),a.prepend(r),k.append(a)}m&&x("Fill","fill"),v&&x("Line","stroke"),y&&x("Color","stroke");const M=ge("Opacity",()=>{const e=p(M,"Opacity controls");if(!e)return;e.classList.add("ad-opacity-popover");const n=fe("input");n.type="range",n.setAttribute("aria-label","Opacity"),n.min="0",n.max="100",n.value=String(Math.round(100*(t.get(f.id)?.style?.opacity??1)));const o=fe("output","",`${n.value}%`),a=me("Opacity",n);a.querySelector(".ad-field-label").append(o);let r=!0;n.oninput=()=>{o.textContent=`${n.value}%`,t.apply(d.map(({id:e})=>({op:"set",id:e,patch:{style:{opacity:Number(n.value)/100}}})),{origin:"user",label:"Change opacity",merge:!r}),r=!1},n.onchange=()=>{r=!0},e.append(a),u(e,M),n.focus()},"ad-color-control");M.insertAdjacentHTML("afterbegin",ie("opacity")),M.setAttribute("aria-label","Opacity"),M.setAttribute("aria-haspopup","true"),M.setAttribute("aria-expanded","false"),d.every(e=>"group"!==e.kind)&&k.append(M),k.childElementCount&&T.append(k);const A=e=>t.apply(d.map(t=>({op:"set",id:t.id,patch:{text:{value:t.text?.value??"",...e}}})),{origin:"user",label:"Text style"});function w(e){const t=fe("div","ad-style-row"),n=fe("div","ad-segments");return n.setAttribute("role","group"),n.setAttribute("aria-label",e),t.append(fe("span","ad-style-label",e),n),T.append(t),n}function L(e,t,n,o){return t.map(([t,a,r])=>{const i=ge(a,()=>o(t),"ad-segment");return i.setAttribute("aria-label",a),i.title=a,i.setAttribute("aria-pressed",String(d.every(e=>n(e)===t))),i.innerHTML=r,e.append(i),i})}function $(e,t=""){return`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h18" fill="none" stroke="currentColor" stroke-width="${e}" stroke-linecap="round"${t?` stroke-dasharray="${t}"`:""}/></svg>`}if(b){L(w("Text"),[["s","Text size: Small","S"],["m","Text size: Medium","M"],["l","Text size: Large","L"],["xl","Text size: Extra large","XL"]],e=>({14:"s",18:"m",26:"l",36:"xl"}[Y(e.text)]??""),e=>A({size:e})),L(w("Align"),[["start","Align text left",ie("alignLeft")],["center","Align text center",ie("alignCenter")],["end","Align text right",ie("alignRight")]],e=>e.text?.align??("text"===e.kind?"start":"center"),e=>A({align:e}));const e=[["sans","Font: Friendly","Aa"],["serif","Font: Serif","Aa"],["mono","Font: Mono","Aa"],["hand","Font: Handwritten","Aa"]];L(w("Font"),e,e=>e.text?.font??"hand",e=>A({font:e})).forEach((t,n)=>{t.style.fontFamily=I[e[n][0]]})}if(v&&(L(w("Line"),[["1","Line: Fine",$(1)],["2","Line: Regular",$(2)],["4","Line: Bold",$(4)],["8","Line: Extra bold",$(6)]],e=>String(K(e,t.stage.resolvedTheme).strokeWidth),e=>t.updateSelection({style:{strokeWidth:Number(e)}})),d.every(e=>"path"!==e.kind||e.closed)&&L(w("Pattern"),[["solid","Pattern: Solid",$(2)],["dashed","Pattern: Dashed",$(2,"5 4")],["dotted","Pattern: Dotted",$(2,"1 5")]],e=>e.style?.dash??"solid",e=>t.updateSelection({style:{dash:e}}))),g&&"connector"===f.kind&&T.append(me("Route",ve([["straight","Straight"],["elbow","Elbow"],["curve","Curve"]],f.route??"elbow",e=>t.updateSelection({route:e})))),g&&"connector"===f.kind&&T.append(me("Arrowhead",ve([["arrow","Arrow"],["dot","Dot"],["none","None"]],f.heads?.end??"arrow",e=>t.updateSelection({heads:{...f.heads,end:e}})))),g&&("video"===f.kind||"link"===f.kind)){const e=ee(f.kind),t=ge(e,()=>te(f.id),"ad-button ad-href-edit");t.setAttribute("aria-label",e),T.append(t)}const S=se(e?"Unlock selection":"Lock selection",e?"lock":"unlock",()=>t.updateSelection({locked:!e}));S.setAttribute("aria-pressed",String(e));const E=fe("div","ad-selection-actions");E.append(se("Duplicate selection","copy",()=>t.duplicate()),se("More arrangement options","align",re),S,se("Delete selection","trash",()=>t.deleteSelection())),T.append(E),(t.readonly||e)&&T.querySelectorAll("button,input,select").forEach(e=>e.disabled=e!==R&&(e!==S||t.readonly)),"Unlock selection"===a||"Lock selection"===a?S.focus():"Deselect"===a?R.focus():a?T.querySelector(`[aria-label="${CSS.escape(a)}"]`)?.focus():l&&[...T.querySelectorAll("label")].find(e=>e.querySelector(".ad-field-label")?.textContent===l)?.querySelector("input,select")?.focus(),(n||o?.focused)&&(!e||t.readonly||F.contains(document.activeElement)||S.focus())}function re(){const e=d("Give it a little order"),n=fe("div","ad-action-grid");if((1===t.selection.length?t.get(t.selection[0]):void 0)&&n.append(ge("Duplicate",()=>{t.duplicate(),e.close()}),ge("Delete",()=>{t.deleteSelection(),e.close()})),t.selection.length>1)for(const o of["left","center","right","top","middle","bottom","horizontal","vertical"])n.append(ge("horizontal"===o||"vertical"===o?`Distribute ${o}`:`Align ${o}`,()=>{t.align(o),e.close()}));t.selection.length>1&&n.append(ge("Group",()=>{t.group(),e.close()})),t.selection.some(e=>"group"===t.get(e)?.kind)&&n.append(ge("Ungroup",()=>{t.ungroup(),e.close()})),n.append(ge("Bring to front",()=>{t.apply(t.selection.map(e=>({op:"order",id:e,to:"front"})),{origin:"user",label:"Bring to front"}),e.close()}),ge("Send to back",()=>{t.apply(t.selection.map(e=>({op:"order",id:e,to:"back"})),{origin:"user",label:"Send to back"}),e.close()})),t.readonly&&n.querySelectorAll("button").forEach(e=>e.disabled=!0),e.append(n)}function ye(e){t.export(e,{scope:"page",padding:40,background:!0,..."png"===e?{scale:2}:{}}).then(n=>{!function(e,t,n){const o=URL.createObjectURL("string"==typeof e?new Blob([e],{type:n}):e),a=fe("a");a.href=o,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}(n,`${t.read().meta.title.replace(/[^a-z0-9 _-]/gi,"").trim()||"drawing"}.${"json"===e?"annie":e}`,"json"===e?oe:"svg"===e?"image/svg+xml":"image/png")}).catch(()=>{})}function be(){H.disabled=!t.canUndo,z.disabled=!t.canRedo,function(){if(!1===n.pages)return;const e=t.read().pages,o=JSON.stringify([t.pageId,e.map(({id:e,name:t})=>[e,t])]);o!==V&&(V=o,B.replaceChildren(...e.map(e=>q(e.id,e.name,!0))),N())}(),ae()}const ke=e=>{const{x:n,y:o,id:a}=e.detail,r=a?t.get(a):void 0;if(!r)return void c();const i=t.stage.root.getBoundingClientRect(),s=f("Element actions",{x:i.left+n,y:i.top+o}),l=t.isLocked(r.id);"video"!==r.kind&&"link"!==r.kind||s.add(ee(r.kind),"link",()=>te(r.id),l),["image","path","line","group","html","video","link"].includes(r.kind)||s.add("Edit text","text",()=>t.editText(r.id),l);const d=e=>t.apply([{op:"order",id:r.id,to:e}],{origin:"user",label:"front"===e?"Bring to front":"Send to back"});s.add("Bring to front","front",()=>d("front"),l),s.add("Send to back","back",()=>d("back"),l),s.add("Duplicate","copy",()=>{t.select([r.id]),t.duplicate()},l);const p=fe("div","ad-menu-separator");p.setAttribute("role","separator"),s.panel.append(p),s.add("Delete","trash",()=>{t.select([r.id]),t.deleteSelection()},l),s.show()};return t.host.addEventListener("ad-context",ke),a.push(t.on("change",be),t.on("select",()=>{ae()}),t.on("page",be),t.on("view",e=>{"manual"===i?.popover&&c(),Q.textContent=`${Math.round(100*e.zoom)}%`}),t.on("tool",e=>{for(const t of o.querySelectorAll("[data-tool]"))t.setAttribute("aria-pressed",String(e===t.dataset.tool));$.setAttribute("aria-pressed",String(L.includes(e))),t.stage.root.dataset.adTool=e,ae()})),be(),()=>{clearTimeout(l),c(),a.forEach(e=>e()),r?.close(),t.host.removeEventListener("ad-context",ke),o.remove()}}export{W as a,Y as c,G as d,Q as f,j as i,I as l,ee as m,oe as n,_ as o,X as p,ae as r,V as s,ye as t,ne as u};
2
+ //# sourceMappingURL=ui-DWQtW0zJ.js.map