jvs-draw 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/dist/App.vue.d.ts +2 -0
- package/dist/components/BoardName.vue.d.ts +5 -0
- package/dist/components/ContextMenu.vue.d.ts +18 -0
- package/dist/components/ExcalidrawCanvas.vue.d.ts +13 -0
- package/dist/components/FloatingPopovers.vue.d.ts +2 -0
- package/dist/components/FloatingPropertiesBar.vue.d.ts +7 -0
- package/dist/components/Footer.vue.d.ts +2 -0
- package/dist/components/HelpDialog.vue.d.ts +2 -0
- package/dist/components/PropertiesPanel.vue.d.ts +11 -0
- package/dist/components/Toolbar.vue.d.ts +2 -0
- package/dist/components/panelCom/alignStyle.vue.d.ts +2 -0
- package/dist/components/panelCom/arrowStyle.vue.d.ts +2 -0
- package/dist/components/panelCom/borderStyle.vue.d.ts +2 -0
- package/dist/components/panelCom/colorStyle.vue.d.ts +11 -0
- package/dist/components/panelCom/fillStyle.vue.d.ts +2 -0
- package/dist/components/panelCom/lineStyle.vue.d.ts +2 -0
- package/dist/components/panelCom/textStyle.vue.d.ts +2 -0
- package/dist/core/element.d.ts +25 -0
- package/dist/core/renderer.d.ts +7 -0
- package/dist/elbow/algorithms/a-star.d.ts +10 -0
- package/dist/elbow/algorithms/data-structures/graph.d.ts +14 -0
- package/dist/elbow/algorithms/data-structures/index.d.ts +2 -0
- package/dist/elbow/algorithms/data-structures/priority-queue.d.ts +16 -0
- package/dist/elbow/algorithms/index.d.ts +2 -0
- package/dist/elbow/constants/default.d.ts +10 -0
- package/dist/elbow/constants/index.d.ts +4 -0
- package/dist/elbow/constants/media.d.ts +6 -0
- package/dist/elbow/constants/property.d.ts +5 -0
- package/dist/elbow/constants/resize.d.ts +10 -0
- package/dist/elbow/core.d.ts +37 -0
- package/dist/elbow/utils/elbow-line-route.d.ts +38 -0
- package/dist/elbow/utils/index.d.ts +4 -0
- package/dist/elbow/utils/line-path.d.ts +7 -0
- package/dist/elbow/utils/math.d.ts +3 -0
- package/dist/elbow/utils/vector.d.ts +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/jvs-draw.css +1 -0
- package/dist/jvs-draw.es.js +6810 -0
- package/dist/jvs-draw.umd.js +6 -0
- package/dist/jvs-ui-public/icon/icon.ico +0 -0
- package/dist/jvs-ui-public/icon/logo.ico +0 -0
- package/dist/jvs-ui-public/icon-fonts/iconfont.css +627 -0
- package/dist/jvs-ui-public/icon-fonts/iconfont.js +1 -0
- package/dist/jvs-ui-public/icon-fonts/iconfont.json +1080 -0
- package/dist/jvs-ui-public/icon-fonts/iconfont.ttf +0 -0
- package/dist/jvs-ui-public/icon-fonts/iconfont.woff +0 -0
- package/dist/jvs-ui-public/icon-fonts/iconfont.woff2 +0 -0
- package/dist/jvs-ui-public/public-fonts/iconfont.css +265 -0
- package/dist/jvs-ui-public/public-fonts/iconfont.js +1 -0
- package/dist/jvs-ui-public/public-fonts/iconfont.json +443 -0
- package/dist/jvs-ui-public/public-fonts/iconfont.svg +143 -0
- package/dist/jvs-ui-public/public-fonts/iconfont.ttf +0 -0
- package/dist/jvs-ui-public/public-fonts/iconfont.woff +0 -0
- package/dist/jvs-ui-public/public-fonts/iconfont.woff2 +0 -0
- package/dist/main.d.ts +0 -0
- package/dist/store/index.d.ts +1518 -0
- package/dist/types/element.d.ts +128 -0
- package/dist/utils/calcDomHeight.d.ts +6 -0
- package/dist/utils/image.d.ts +10 -0
- package/dist/utils/isPointOnElement.d.ts +1 -0
- package/dist/utils/math.d.ts +71 -0
- package/dist/utils/routing.d.ts +3 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/vite.svg +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(rt,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue"),require("pinia"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","pinia","element-plus"],n):(rt=typeof globalThis<"u"?globalThis:rt||self,n(rt.JvsDraw={},rt.Vue,rt.Pinia,rt.ElementPlus))})(this,(function(rt,n,ys,ks){"use strict";const xs=(a,t,e,s,o)=>[(a-e)*Math.cos(o)-(t-s)*Math.sin(o)+e,(a-e)*Math.sin(o)+(t-s)*Math.cos(o)+s],he=(a,t,e)=>xs(a[0],a[1],t[0],t[1],e),ws=a=>{const t=a.x+a.width/2,e=a.y+a.height/2,o=[[a.x,a.y],[a.x+a.width,a.y],[a.x+a.width,a.y+a.height],[a.x,a.y+a.height]].map(r=>he(r,[t,e],a.angle)),l=o.map(r=>r[0]),i=o.map(r=>r[1]);return{minX:Math.min(...l),minY:Math.min(...i),maxX:Math.max(...l),maxY:Math.max(...i)}},An=(a,t,e,s)=>{const o=e-a,l=s-t;return Math.hypot(o,l)},Ss=(a,t)=>{if(a.length<3)return a.length===2?`M ${a[0][0]} ${a[0][1]} L ${a[1][0]} ${a[1][1]}`:"";let e=`M ${a[0][0]} ${a[0][1]}`;for(let o=1;o<a.length-1;o++){const l=a[o-1],i=a[o],r=a[o+1],c=i[0]-l[0],d=i[1]-l[1],u=Math.hypot(c,d),k=r[0]-i[0],h=r[1]-i[1],m=Math.hypot(k,h),f=Math.min(t,u/2,m/2),M=i[0]-c/u*f,E=i[1]-d/u*f,B=i[0]+k/m*f,b=i[1]+h/m*f;e+=` L ${M} ${E}`,e+=` Q ${i[0]} ${i[1]} ${B} ${b}`}const s=a[a.length-1];return e+=` L ${s[0]} ${s[1]}`,e},yt=(a,t)=>{if(a.length<3)return Ss(a,t);let e="";const s=a.length;for(let o=0;o<s;o++){const l=a[(o-1+s)%s],i=a[o],r=a[(o+1)%s],c=i[0]-l[0],d=i[1]-l[1],u=Math.hypot(c,d),k=r[0]-i[0],h=r[1]-i[1],m=Math.hypot(k,h),f=Math.min(u/2,m/2),M=Math.min(t,f);if(M===0){e+=o===0?`M ${i[0]} ${i[1]}`:` L ${i[0]} ${i[1]}`;continue}const E=i[0]-c/u*M,B=i[1]-d/u*M,b=i[0]+k/m*M,V=i[1]+h/m*M;o===0?e+=`M ${E} ${B}`:e+=` L ${E} ${B}`,e+=` Q ${i[0]} ${i[1]} ${b} ${V}`}return e+=" Z",e},He=(a,t,e,s,o,l,i)=>{const[r,c]=he([a,t],[e+o/2,s+l/2],-i);return r>=e&&r<=e+o&&c>=s&&c<=s+l},ct=(a,t,e,s,o,l,i)=>{const[r,c]=he([a,t],[e+o/2,s+l/2],-i),d=e+o/2,u=s+l/2,k=o/2,h=l/2;return(r-d)**2/k**2+(c-u)**2/h**2<=1},kt=(a,t,e,s,o,l,i)=>{const[r,c]=he([a,t],[e+o/2,s+l/2],-i),d=e+o/2,u=s+l/2,k=Math.abs(r-d)/(o/2),h=Math.abs(c-u)/(l/2);return k+h<=1},bs=(a,t,e,s,o,l,i,r=5)=>{const[c,d]=he([a,t],[e+o/2,s+l/2],-i),u=e+o/2,k=s+l/2,h=o/2,m=l/2,f=Math.abs(c-u),M=Math.abs(d-k),E=f/h+M/m,B=r/Math.max(h,m);return Math.abs(E-1)<=B},pt=(a,t,e,s,o,l)=>{let i=!1;for(let r=0,c=e.length-1;r<e.length;c=r++){const d=e[r][0]+s,u=e[r][1]+o,k=e[c][0]+s,h=e[c][1]+o;u>t!=h>t&&a<(k-d)*(t-u)/(h-u)+d&&(i=!i)}return i},on=(a,t,e)=>{const s=(e[0]-t[0])**2+(e[1]-t[1])**2;if(s===0)return(a[0]-t[0])**2+(a[1]-t[1])**2;let o=((a[0]-t[0])*(e[0]-t[0])+(a[1]-t[1])*(e[1]-t[1]))/s;return o=Math.max(0,Math.min(1,o)),(a[0]-(t[0]+o*(e[0]-t[0])))**2+(a[1]-(t[1]+o*(e[1]-t[1])))**2},Dn=(a,t,e,s,o,l,i=5)=>{const r=i*i;for(let c=0;c<e.length;c++){const d=(c+1)%e.length,u=[e[c][0]+s,e[c][1]+o],k=[e[d][0]+s,e[d][1]+o];if(on([a,t],u,k)<=r)return!0}return!1},Qe=(a,t)=>{const o=[];for(let k=0;k<10;k++){const h=k*Math.PI/5-Math.PI/2,m=k%2===0?1:.4;o.push([m*Math.cos(h),m*Math.sin(h)])}const l=Math.min(...o.map(k=>k[0])),i=Math.max(...o.map(k=>k[0])),r=Math.min(...o.map(k=>k[1])),c=Math.max(...o.map(k=>k[1])),d=i-l,u=c-r;return o.map(k=>[(k[0]-l)/d*a,(k[1]-r)/u*t])},ht=(a,t)=>[[a*.2,0],[a*.8,0],[a,t],[0,t]],ft=(a,t)=>[[a*.25,0],[a,0],[a*.75,t],[0,t]],Fn=(a,t)=>[[a/2,0],[a,t/2],[a/2,t],[0,t/2]],Ln=a=>Math.min(a*.15,20),an=(a,t,e,s,o,l,i)=>{const[r,c]=he([a,t],[e+o/2,s+l/2],-i),d=Ln(l),u=s+d;if((r-(e+o/2))**2/(o/2)**2+(c-u)**2/d**2<=1)return!0;const h=s+l-d;return(r-(e+o/2))**2/(o/2)**2+(c-h)**2/d**2<=1?!0:r>=e&&r<=e+o&&c>=s+d&&c<=s+l-d},vs=(a,t,e,s,o,l,i,r=5)=>{const[c,d]=he([a,t],[e+o/2,s+l/2],-i),u=Ln(l);if(ln(a,t,e,s,o,u*2,i,r))return!0;const k=s+l-u;if(d>=k&&ln(a,t,e,s+l-u*2,o,u*2,i,r))return!0;const h=[e,s+u],m=[e,s+l-u],f=[e+o,s+u],M=[e+o,s+l-u];return on([c,d],h,m)<=r*r||on([c,d],f,M)<=r*r},Es=(a,t,e,s,o,l,i,r=5)=>{const[c,d]=he([a,t],[e+o/2,s+l/2],-i),u=Math.abs(c-e)<=r,k=Math.abs(c-(e+o))<=r,h=Math.abs(d-s)<=r,m=Math.abs(d-(s+l))<=r,f=d>=s-r&&d<=s+l+r,M=c>=e-r&&c<=e+o+r;return(u||k)&&f||(h||m)&&M},ln=(a,t,e,s,o,l,i,r=5)=>{const[c,d]=he([a,t],[e+o/2,s+l/2],-i),u=e+o/2,k=s+l/2,h=o/2,m=l/2,f=c-u,M=d-k,E=f*f/(h+r)**2+M*M/(m+r)**2,B=h-r>0&&m-r>0?f*f/(h-r)**2+M*M/(m-r)**2:2;return E<=1&&B>=1},Is=a=>{if(a.type!=="arrow")return null;const t=a.points;if(t.length<2)return null;const[e,s]=t[t.length-2],[o,l]=t[t.length-1],i=Math.atan2(l-s,o-e),r=20,c=Math.PI/6,d=o-r*Math.cos(i-c),u=l-r*Math.sin(i-c),k=o-r*Math.cos(i+c),h=l-r*Math.sin(i+c);return[[d,u],[o,l],[k,h]]},On=(a,t,e,s)=>{const o=a[0],l=a[1],i=t[0],r=t[1],c=e[0],d=e[1],u=s[0],k=s[1],h=(k-d)*(i-o)-(u-c)*(r-l);if(h===0)return null;const m=((u-c)*(l-d)-(k-d)*(o-c))/h,f=((i-o)*(l-d)-(r-l)*(o-c))/h;return m>=0&&m<=1&&f>=0&&f<=1?[o+m*(i-o),l+m*(r-l)]:null},ut=(a,t,e,s=0)=>{const{x:o,y:l,width:i,height:r,angle:c}=a,d=o+i/2,u=l+r/2,k=he(t,[d,u],-c),h=he(e,[d,u],-c);let m=null;if(["rectangle","image","text","frame","square","process"].includes(a.type)){const f=[[[o-s,l-s],[o+i+s,l-s]],[[o+i+s,l-s],[o+i+s,l+r+s]],[[o+i+s,l+r+s],[o-s,l+r+s]],[[o-s,l+r+s],[o-s,l-s]]];let M=1/0;for(const E of f){const B=On(k,h,E[0],E[1]);if(B){const b=An(k[0],k[1],B[0],B[1]);b<M&&(M=b,m=B)}}}else if(["ellipse","circle","cylinder"].includes(a.type)){const f=i/2+s,M=r/2+s,E=h[0]-k[0],B=h[1]-k[1],b=k[0]-d,V=k[1]-u,O=E*E/(f*f)+B*B/(M*M),H=2*b*E/(f*f)+2*V*B/(M*M),Z=b*b/(f*f)+V*V/(M*M)-1,ne=H*H-4*O*Z;if(ne>=0){const W=(-H-Math.sqrt(ne))/(2*O),J=(-H+Math.sqrt(ne))/(2*O);let Q=-1;W>=0&&W<=1?Q=W:J>=0&&J<=1?Q=J:W>0&&W<J?Q=W:J>0&&(Q=J),Q>=0&&Q<=1&&(m=[k[0]+Q*E,k[1]+Q*B])}}else if(["diamond","decision","star","trapezoid","parallelogram"].includes(a.type)){const f=o+i/2,M=l+r/2;let E=[];if(["diamond","decision"].includes(a.type)){const b=[f,l-s],V=[o+i+s,M],O=[f,l+r+s],H=[o-s,M];E=[[b,V],[V,O],[O,H],[H,b]]}else if(a.type==="trapezoid"){const b=[o+i*.2-s,l-s],V=[o+i*.8+s,l-s],O=[o+i+s,l+r+s],H=[o-s,l+r+s];E=[[b,V],[V,O],[O,H],[H,b]]}else if(a.type==="parallelogram"){const b=[o+i*.25-s,l-s],V=[o+i+s,l-s],O=[o+i*.75+s,l+r+s],H=[o-s,l+r+s];E=[[b,V],[V,O],[O,H],[H,b]]}else if(a.type==="star"){const b=Qe(i,r).map(V=>[V[0]+o,V[1]+l]);for(let V=0;V<b.length;V++)E.push([b[V],b[(V+1)%b.length]])}let B=1/0;for(const b of E){const V=On(k,h,b[0],b[1]);if(V){const O=An(k[0],k[1],V[0],V[1]);O<B&&(B=O,m=V)}}}return m?he(m,[d,u],c):null},Ms=(a,t,e)=>{const s=a[0],o=a[1],l=t[0],i=t[1],r=e[0],c=e[1],d=s-l,u=o-i,k=r-l,h=c-i,m=d*k+u*h,f=k*k+h*h;let M=-1;f!==0&&(M=m/f);let E,B;M<0?(E=l,B=i):M>1?(E=r,B=c):(E=l+M*k,B=i+M*h);const b=s-E,V=o-B;return Math.sqrt(b*b+V*V)};let rn=null;const _e=(a,t,e,s,o)=>{rn||(rn=document.createElement("canvas"));const l=rn.getContext("2d");if(!l)return{width:10,height:t};const i=o?.isItalic?"italic ":"",r=o?.isBold?"bold ":"";if(l.font=`${i}${r}${t}px ${e}`,s){const d=Math.max(0,s-8),u=(a||"").split(`
|
|
2
|
+
`);let k=0,h=0;return u.forEach(m=>{if(!m){k++;return}let f="";for(let M=0;M<m.length;M++){const E=m.charAt(M),B=f+E;l.measureText(B).width>d&&f!==""?(k++,l.measureText(f).width>h&&(h=l.measureText(f).width),f=E):f=B}f!==""&&(k++,l.measureText(f).width>h&&(h=l.measureText(f).width))}),{width:s,height:k*(t*1.25)+10}}else{const c=(a||"").split(`
|
|
3
|
+
`);let d=0;return c.forEach(u=>{const k=l.measureText(u).width;k>d&&(d=k)}),{width:Math.max(d+8,10),height:c.length*(t*1.25)+10}}},Bs=(a,t=.5,e=10)=>{if(a.length<2)return a;const s=[],o=l=>l<0?a[0]:l>=a.length?a[a.length-1]:a[l];for(let l=0;l<a.length-1;l++){const i=o(l-1),r=o(l),c=o(l+1),d=o(l+2);if(!(!i||!r||!c||!d))for(let u=0;u<=e;u++){const k=u/e,h=k*k,m=h*k,f=.5*(2*r[0]+(-i[0]+c[0])*k+(2*i[0]-5*r[0]+4*c[0]-d[0])*h+(-i[0]+3*r[0]-3*c[0]+d[0])*m),M=.5*(2*r[1]+(-i[1]+c[1])*k+(2*i[1]-5*r[1]+4*c[1]-d[1])*h+(-i[1]+3*r[1]-3*c[1]+d[1])*m);if(s.length>0){const E=s[s.length-1];if(Math.abs(E[0]-f)<.1&&Math.abs(E[1]-M)<.1)continue}s.push([f,M])}}return s},Cs=a=>{const{x:t,y:e,width:s,height:o,angle:l}=a;if(l===0)return{minX:t,minY:e,maxX:t+s,maxY:e+o};const i=t+s/2,r=e+o/2,c=[he([t,e],[i,r],l),he([t+s,e],[i,r],l),he([t+s,e+o],[i,r],l),he([t,e+o],[i,r],l)];let d=1/0,u=1/0,k=-1/0,h=-1/0;return c.forEach(m=>{d=Math.min(d,m[0]),u=Math.min(u,m[1]),k=Math.max(k,m[0]),h=Math.max(h,m[1])}),{minX:d,minY:u,maxX:k,maxY:h}},St=a=>{if(a.length===0)return null;let t=1/0,e=1/0,s=-1/0,o=-1/0;return a.forEach(l=>{const i=Cs(l);t=Math.min(t,i.minX),e=Math.min(e,i.minY),s=Math.max(s,i.maxX),o=Math.max(o,i.maxY)}),{x:t,y:e,width:s-t,height:o-e,minX:t,minY:e,maxX:s,maxY:o}},Lt=(a,t,e,s,o)=>{const{x:l,y:i,angle:r,points:c}=s,d=[l+s.width/2,i+s.height/2],[u,k]=he([t,e],d,-r),h=u-l,m=k-i;if(!c||c.length<2)return!1;let f=c;if(s.type==="arrow"){if(s.arrowType==="round"&&c.length>2)f=Bs(c);else if(s.arrowType==="elbow"){let M,E;if(o&&(s.startBinding||s.endBinding)){const B=b=>{if(!b)return;const V=o.find(de=>de.id===b.elementId);if(!V)return;const O=b.focus<0?s.points[0]:s.points[s.points.length-1];if(!O)return;const H=s.x+O[0],Z=s.y+O[1],ne=V.x,W=V.y,J=V.width,Q=V.height,oe=Math.abs(H-ne),Y=Math.abs(H-(ne+J)),A=Math.abs(Z-W),X=Math.abs(Z-(W+Q)),te=Math.min(oe,Y,A,X);if(te===oe)return[-1,0];if(te===Y)return[1,0];if(te===A)return[0,-1];if(te===X)return[0,1]};s.startBinding&&(M=B(s.startBinding)),s.endBinding&&(E=B(s.endBinding))}f=cn(c,M,E)}}for(let M=0;M<f.length-1;M++){const E=f[M],B=f[M+1];if(Ms([h,m],E,B)<=a)return!0}return!1},cn=(a,t,e)=>{if(a.length<2)return[...a];const s=a[0],o=a[a.length-1],l=20;let i=s,r=o;const c=[s];t&&(i=[s[0]+t[0]*l,s[1]+t[1]*l],c.push(i)),e&&(r=[o[0]+e[0]*l,o[1]+e[1]*l]);const[d,u]=i,[k,h]=r,m=(d+k)/2,f=(u+h)/2,M=Math.abs(k-d),E=Math.abs(h-u);return M>E?(c.push([m,u]),c.push([m,h])):(c.push([d,f]),c.push([k,f])),e&&c.push(r),c.push(o),c},Vs=(a,t=20,e,s)=>{const o=cn(a,e,s),l=[];o.length>0&&l.push(o[0]);for(let c=1;c<o.length;c++){const d=l[l.length-1],u=o[c];(Math.abs(u[0]-d[0])>.01||Math.abs(u[1]-d[1])>.01)&&l.push(u)}if(l.length<3)return l.length===2?`M ${l[0][0]} ${l[0][1]} L ${l[1][0]} ${l[1][1]}`:"";let i=`M ${l[0][0]} ${l[0][1]}`;for(let c=1;c<l.length-1;c++){const d=l[c-1],u=l[c],k=l[c+1],h=u[0]-d[0],m=u[1]-d[1],f=Math.sqrt(h*h+m*m),M=k[0]-u[0],E=k[1]-u[1],B=Math.sqrt(M*M+E*E);if(f<.01||B<.01){i+=` L ${u[0]} ${u[1]}`;continue}const b=Math.min(t,f/2,B/2),V=u[0]-h/f*b,O=u[1]-m/f*b,H=u[0]+M/B*b,Z=u[1]+E/B*b;i+=` L ${V} ${O}`,i+=` Q ${u[0]} ${u[1]} ${H} ${Z}`}const r=l[l.length-1];return i+=` L ${r[0]} ${r[1]}`,i},Ns="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let dt=(a=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(a|=0));for(;a--;)t+=Ns[e[a]&63];return t};const je=ys.defineStore("excalidraw",{state:()=>({elements:[],history:[[]],historyStep:0,appState:{lockedTool:!1,viewBackgroundColor:"#FFFFFF",scrollX:0,scrollY:0,zoom:1,activeTool:"selection",activeToolType:"rectangle",currentItemStrokeColor:"#363B4C",currentItemStrokeOpacity:100,currentItemBackgroundColor:"transparent",currentItemFillStyle:"solid",currentItemStrokeWidth:1,currentItemStrokeStyle:"solid",currentItemRoughness:0,currentItemRoundness:0,currentItemOpacity:100,currentItemBackgroundOpacity:100,currentItemFontColor:"#363B4C",currentItemFontSize:20,currentItemFontFamily:"sans-serif",currentItemFontBgColor:"transparent",currentItemTextAlign:"left",currentItemVerticalAlign:"top",currentItemIsBold:!1,currentItemIsItalic:!1,currentItemIsUnderline:!1,currentItemIsStrikethrough:!1,currentItemArrowType:"sharp",selectedElementIds:{},showHelp:!1,viewLocked:!1,lastActiveTool:null,name:"Untitled Document",isDraggingElement:!1,isBoxSelecting:!1,showGrid:!0,gridType:"none",isPropertiesPanelOpen:!1,floatingToolbarOffset:{x:0,y:0},useWheelZoom:!0,rightClickPan:!0,autoSnap:!0,alignmentGuides:!0,showContainerName:!0}}),getters:{shouldShowFloatingToolbar:a=>{if(a.appState.isPropertiesPanelOpen)return!1;const t=a.appState.activeTool;let e=t;if(t==="selection"){const s=Object.keys(a.appState.selectedElementIds);if(s.length===0)e="none";else{const o=s[0],l=a.elements.find(i=>i.id===o);l&&l.locked?e="none":e=l?l.type:"none"}}else return!1;return!["none","hand","laser","eraser","image"].includes(e)}},actions:{toggleGrid(){this.appState.showGrid=!this.appState.showGrid},toggleSelection(a,t){t===void 0?this.appState.selectedElementIds[a]?delete this.appState.selectedElementIds[a]:this.appState.selectedElementIds[a]=!0:t?this.appState.selectedElementIds[a]=!0:delete this.appState.selectedElementIds[a]},setSelectedElementIds(a){a.length==0&&(this.appState.isPropertiesPanelOpen=!1),this.appState.selectedElementIds=a.reduce((t,e)=>(t[e]=!0,t),{})},addElement(a){this.elements=[...this.elements,a]},insertImage(a,t,e,s,o){const l={id:dt(),type:"image",x:t,y:e,width:s,height:o,angle:0,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:"hachure",strokeWidth:1,strokeStyle:"solid",roughness:0,opacity:100,backgroundOpacity:100,seed:Math.floor(Math.random()*2147483648),version:1,isDeleted:!1,groupIds:[],updated:Date.now(),link:null,locked:!1,fileId:dt(),status:"saved",scale:[1,1],dataURL:a};this.elements=[...this.elements,l],this.recordHistory(),this.setSelectedElementIds([l.id])},updateElement(a,t){const e=this.elements.findIndex(s=>s.id===a);if(e!==-1){const s=[...this.elements],o={...s[e],...t};s[e]=o,this.elements=s,this.elements.filter(i=>i.type==="arrow"&&(i.startBinding?.elementId===a||i.endBinding?.elementId===a)).forEach(i=>{const r=i,c=r.points.map(k=>[k[0]+r.x,k[1]+r.y]);let d=!1;if(c.length===3){const k=c[0],h=c[1],m=c[2];if(k&&h&&m){const f=(k[0]+m[0])/2,M=(k[1]+m[1])/2;Math.abs(h[0]-f)<1&&Math.abs(h[1]-M)<1&&(d=!0)}}let u=!1;if(r.startBinding?.elementId===a)if(r.startBinding.fixedPoint&&!r.startBinding.isBorder){const[k,h]=r.startBinding.fixedPoint,m=o.x+o.width/2,f=o.y+o.height/2,M=o.x+k*o.width,E=o.y+h*o.height,B=he([M,E],[m,f],o.angle);c[0]=[B[0],B[1]],u=!0}else{const k=c.length>1?c[1]:[o.x+o.width/2,o.y+o.height/2],h=[o.x+o.width/2,o.y+o.height/2],m=ut(o,k,h,10);m&&(c[0]=[m[0],m[1]],u=!0)}if(r.endBinding?.elementId===a)if(r.endBinding.fixedPoint&&!r.endBinding.isBorder){const[k,h]=r.endBinding.fixedPoint,m=o.x+o.width/2,f=o.y+o.height/2,M=o.x+k*o.width,E=o.y+h*o.height,B=he([M,E],[m,f],o.angle);c[c.length-1]=[B[0],B[1]],u=!0}else{const k=c.length>1?c[c.length-2]:[o.x+o.width/2,o.y+o.height/2],h=[o.x+o.width/2,o.y+o.height/2],m=ut(o,k,h,10);m&&(c[c.length-1]=[m[0],m[1]],u=!0)}if(u){if(d&&c.length===3){const b=c[0],V=c[c.length-1];b&&V&&(c[1]=[(b[0]+V[0])/2,(b[1]+V[1])/2])}const k=c.map(b=>b[0]),h=c.map(b=>b[1]),m=Math.min(...k),f=Math.min(...h),M=Math.max(...k),E=Math.max(...h),B=c.map(b=>[b[0]-m,b[1]-f]);if(this.updateElement(r.id,{x:m,y:f,width:M-m,height:E-f,points:B}),r.frameId){const b=this.elements.find(V=>V.id===r.frameId);b&&(o.x>=b.x&&o.y>=b.y&&o.x+o.width<=b.x+b.width&&o.y+o.height<=b.y+b.height||this.updateElement(r.id,{frameId:null}))}}})}},setTool(a){this.appState.activeTool=a},setToolType(a){this.appState.activeToolType=a||"rectangle"},deleteElement(a){this.elements=this.elements.filter(t=>t.id!==a),this.recordHistory()},clearElements(){this.elements=[],this.recordHistory()},moveElements(a,t,e){const s=a.filter(i=>{const r=this.elements.find(c=>c.id===i);return r&&!r.locked}),o=new Set(s);s.forEach(i=>{const r=this.elements.find(c=>c.id===i);r&&r.type==="frame"?this.elements.forEach(c=>{c.id!==r.id&&(c.isDeleted||o.has(c.id)||c.frameId==r.id&&o.add(c.id))}):r&&this.elements.forEach(c=>{c.isDeleted||o.has(c.id)||c.type==="text"&&c.containerId===r.id&&o.add(c.id)})}),this.elements=this.elements.map(i=>o.has(i.id)?{...i,x:i.x+t,y:i.y+e,updated:Date.now()}:i);const l=o;this.elements=this.elements.map(i=>{if(i.type!=="arrow"&&i.type!=="line"||l.has(i.id))return i;const r=i.points.map(h=>[h[0]+i.x,h[1]+i.y]);let c=!1,d=!1;if(r.length===3&&(i.type==="arrow"||i.type==="line")){const h=r[0],m=r[1],f=r[2];if(h&&m&&f){const M=(h[0]+f[0])/2,E=(h[1]+f[1])/2;Math.abs(m[0]-M)<1&&Math.abs(m[1]-E)<1&&(d=!0)}}const u=i.startBinding&&l.has(i.startBinding.elementId),k=i.endBinding&&l.has(i.endBinding.elementId);if(i.startBinding&&(u||k)){const h=this.elements.find(m=>m.id===i.startBinding.elementId);if(h){let m=null;if(i.startBinding.fixedPoint&&!i.startBinding.isBorder){const[f,M]=i.startBinding.fixedPoint,E=h.x+h.width/2,B=h.y+h.height/2,b=h.x+f*h.width,V=h.y+M*h.height;m=he([b,V],[E,B],h.angle)}else{let f=r.length>1?r[1]:r[0];k&&r.length===2&&(f=[f[0]+t,f[1]+e]);const M=[h.x+h.width/2,h.y+h.height/2],E=ut(h,f,M,10);E&&(m=E)}if(m){r[0]=[m[0],m[1]],c=!0;const f=h.x+h.width/2,M=h.y+h.height/2,E=he(m,[f,M],-h.angle),B=(E[0]-h.x)/h.width,b=(E[1]-h.y)/h.height;i.startBinding&&(i.startBinding={...i.startBinding,fixedPoint:[B,b]})}else{const f=r[0];f&&u&&(r[0]=[f[0]+t,f[1]+e],c=!0)}}}if(i.endBinding&&(l.has(i.endBinding.elementId)||i.startBinding&&l.has(i.startBinding.elementId))){const h=this.elements.find(m=>m.id===i.endBinding.elementId);if(h){let m=null;const f=l.has(i.endBinding.elementId),M=i.startBinding&&l.has(i.startBinding.elementId);if(i.endBinding.fixedPoint&&!i.endBinding.isBorder){const[E,B]=i.endBinding.fixedPoint,b=h.x+h.width/2,V=h.y+h.height/2,O=h.x+E*h.width,H=h.y+B*h.height;m=he([O,H],[b,V],h.angle)}else{let E=r.length>1?r[r.length-2]:r[r.length-1];M&&r.length===2&&(E=[E[0]+t,E[1]+e]);const B=[h.x+h.width/2,h.y+h.height/2],b=ut(h,E,B,10);b&&(m=b)}if(m){r[r.length-1]=[m[0],m[1]],c=!0;const E=h.x+h.width/2,B=h.y+h.height/2,b=he(m,[E,B],-h.angle),V=(b[0]-h.x)/h.width,O=(b[1]-h.y)/h.height;i.endBinding&&(i.endBinding={...i.endBinding,fixedPoint:[V,O]})}else{const E=r[r.length-1];E&&f&&(r[r.length-1]=[E[0]+t,E[1]+e],c=!0)}}}if(c&&d){const h=r[0],m=r[r.length-1];h&&m&&(r[1]=[(h[0]+m[0])/2,(h[1]+m[1])/2])}if(c){const h=r.filter(V=>V&&V[0]!==void 0).map(V=>V[0]),m=r.filter(V=>V&&V[1]!==void 0).map(V=>V[1]);if(h.length===0||m.length===0)return i;const f=Math.min(...h),M=Math.min(...m),E=Math.max(...h),B=Math.max(...m),b=r.map(V=>[V[0]-f,V[1]-M]);return{...i,x:f,y:M,width:E-f,height:B-M,points:b,startBinding:i.startBinding,endBinding:i.endBinding,updated:Date.now()}}return i})},updateSelectedElements(a){const t=new Set(Object.keys(this.appState.selectedElementIds));if(t.size===0)return;this.recordHistory();const e=new Set;this.elements.forEach(s=>{s.type==="text"&&s.containerId&&t.has(s.containerId)&&e.add(s.id)}),this.elements=this.elements.map(s=>{if(t.has(s.id)||e.has(s.id)){let o=a;if(e.has(s.id)&&!t.has(s.id)){const i={};if("isBold"in a&&(i.isBold=a.isBold),"isItalic"in a&&(i.isItalic=a.isItalic),"isUnderline"in a&&(i.isUnderline=a.isUnderline),"isStrikethrough"in a&&(i.isStrikethrough=a.isStrikethrough),"textAlign"in a&&(i.textAlign=a.textAlign),"verticalAlign"in a&&(i.verticalAlign=a.verticalAlign),"fontFamily"in a&&(i.fontFamily=a.fontFamily),"fontSize"in a&&(i.fontSize=a.fontSize),"angle"in a&&(i.angle=a.angle),Object.keys(i).length===0)return s;o=i}let l={...s,...o,updated:Date.now()};if("type"in o&&(o.type==="square"||o.type==="circle")){const i=Math.max(l.width,l.height);l.width=i,l.height=i}if(o.arrowType==="round"&&l.type==="line"&&l.points?.length===2){const i=l.points[0],r=l.points[1],c=(i[0]+r[0])/2,d=(i[1]+r[1])/2,u=[i,[c,d+20],r];l.points=u}if(l.type==="freedraw"){let i=1,r=1;"width"in o&&s.width!==0&&(i=o.width/s.width),"height"in o&&s.height!==0&&(r=o.height/s.height),(i!==1||r!==1)&&(l.points=s.points.map(c=>[c[0]*i,c[1]*r]))}return l}return s})},bringToFront(a){this.recordHistory();const t=new Set(a),e=this.elements.filter(o=>t.has(o.id)),s=this.elements.filter(o=>!t.has(o.id));this.elements=[...s,...e]},sendToBack(a){this.recordHistory();const t=new Set(a),e=this.elements.filter(o=>t.has(o.id)),s=this.elements.filter(o=>!t.has(o.id));this.elements=[...e,...s]},bringForward(a){this.recordHistory();const t=new Set(a),e=this.elements.map((s,o)=>t.has(s.id)?o:-1).filter(s=>s!==-1).sort((s,o)=>o-s);for(const s of e)if(s<this.elements.length-1){const o=this.elements[s],l=this.elements[s+1];o&&l&&(this.elements[s]=l,this.elements[s+1]=o)}},sendBackward(a){this.recordHistory();const t=new Set(a),e=this.elements.map((s,o)=>t.has(s.id)?o:-1).filter(s=>s!==-1).sort((s,o)=>s-o);for(const s of e)if(s>0){const o=this.elements[s],l=this.elements[s-1];o&&l&&(this.elements[s]=l,this.elements[s-1]=o)}},recordHistory(){this.history=this.history.slice(0,this.historyStep+1),this.history.push(JSON.parse(JSON.stringify(this.elements))),this.historyStep=this.history.length-1},undo(){this.historyStep>0&&(this.historyStep--,this.elements=JSON.parse(JSON.stringify(this.history[this.historyStep])),this.appState.selectedElementIds={})},redo(){this.historyStep<this.history.length-1&&(this.historyStep++,this.elements=JSON.parse(JSON.stringify(this.history[this.historyStep])),this.appState.selectedElementIds={})},setZoom(a){this.appState.zoom=Math.min(Math.max(.1,a),3)},zoomIn(){this.setZoom(Math.round((this.appState.zoom+.05)*100)/100)},zoomOut(){this.setZoom(Math.round((this.appState.zoom-.05)*100)/100)},selectAll(){const a=this.elements.filter(t=>!t.isDeleted&&!t.locked).map(t=>t.id);this.setSelectedElementIds(a)},async copyElements(){const a=new Set(Object.keys(this.appState.selectedElementIds));if(a.size===0)return;const t=this.elements.filter(e=>a.has(e.id)||a.has(e.containerId));if(t.length!==0){this._internalClipboard=JSON.stringify(t);try{navigator.clipboard&&navigator.clipboard.writeText&&await navigator.clipboard.writeText(JSON.stringify(t))}catch(e){console.error("Failed to copy to system clipboard",e)}}},async cutElements(){await this.copyElements(),Object.keys(this.appState.selectedElementIds).forEach(t=>this.deleteElement(t))},async pasteElements(a){try{let t,e;a?(t=a.x,e=a.y):(t=window.innerWidth/2/this.appState.zoom-this.appState.scrollX,e=window.innerHeight/2/this.appState.zoom-this.appState.scrollY);let s="";if(navigator.clipboard&&navigator.clipboard.read)try{const B=await navigator.clipboard.read();for(const b of B)if(b.types.includes("text/plain")&&(s=await(await b.getType("text/plain")).text(),s))break}catch(B){console.warn("Clipboard read failed, falling back to readText",B)}if(!s&&navigator.clipboard&&navigator.clipboard.readText)try{s=await navigator.clipboard.readText()}catch(B){console.warn("Clipboard readText failed",B)}if(s||(s=this._internalClipboard||""),!s)return;let o=null;try{const B=JSON.parse(s);Array.isArray(B)&&B.length>0&&B[0].type&&(o=B)}catch{}if(!o){const b="sans-serif",O=s.split(`
|
|
4
|
+
`);let H=10,Z=O.length*25+10;const W=document.createElement("canvas").getContext("2d");if(W){W.font=`20px ${b}`;let Q=0;O.forEach(oe=>{const Y=W.measureText(oe).width;Y>Q&&(Q=Y)}),H=Q+10}const J={id:dt(),type:"text",x:t,y:e,width:H,height:Z,angle:0,strokeColor:"#363B4C",backgroundColor:"transparent",fillStyle:"hachure",strokeWidth:1,strokeStyle:"solid",roughness:0,opacity:100,seed:Math.floor(Math.random()*2**31),version:1,isDeleted:!1,groupIds:[],updated:Date.now(),link:null,locked:!1,text:s,fontSize:20,fontFamily:"sans-serif",textAlign:"left",verticalAlign:"top",containerId:null,originalText:s,autoResize:!0};this.addElement(J),this.recordHistory(),this.setSelectedElementIds([J.id]);return}if(!Array.isArray(o)||o.length===0)return;const l=o[0];if(!l||!l.id||!l.type)return;this.setSelectedElementIds([]);let i=1/0,r=1/0,c=-1/0,d=-1/0;o.forEach(B=>{i=Math.min(i,B.x),r=Math.min(r,B.y),c=Math.max(c,B.x+B.width),d=Math.max(d,B.y+B.height)});const u=(i+c)/2,k=(r+d)/2,h=t-u,m=e-k,f={},M=[];o.forEach(B=>{const b=dt();f[B.id]=b}),o.forEach(B=>{const b={...B,id:f[B.id],x:B.x+h,y:B.y+m,seed:Math.floor(Math.random()*2147483648),version:1,updated:Date.now()};b.containerId&&f[b.containerId]&&(b.containerId=f[b.containerId]),(b.type==="arrow"||b.type==="line")&&(b.startBinding&&f[b.startBinding.elementId]&&(b.startBinding={...b.startBinding,elementId:f[b.startBinding.elementId]}),b.endBinding&&f[b.endBinding.elementId]&&(b.endBinding={...b.endBinding,elementId:f[b.endBinding.elementId]})),M.push(b)}),this.elements=[...this.elements,...M],this.recordHistory();const E=[];M.forEach(B=>{!B.containerId&&!B.frameId&&E.push(B.id)}),this.setSelectedElementIds(E)}catch(t){console.error("Failed to paste",t)}},setScroll(a,t){this.appState.scrollX=a,this.appState.scrollY=t},toggleViewLock(){this.appState.viewLocked=!this.appState.viewLocked},duplicateElements(a,t){if(a.length===0)return;this.recordHistory();const e=new Set(a);this.elements.filter(d=>e.has(d.id)&&d.type==="frame").forEach(d=>{const u=d.x,k=d.y,h=d.width,m=d.height;this.elements.forEach(f=>{if(f.id===d.id||f.isDeleted)return;if(f.type==="text"&&f.containerId===d.id){e.add(f.id);return}const M=f.x+f.width/2,E=f.y+f.height/2;M>=u&&M<=u+h&&E>=k&&E<=k+m&&e.add(f.id)})});const o=this.elements.filter(d=>e.has(d.id)||e.has(d.containerId)),l=new Map,i=o.map(d=>{const u=dt();l.set(d.id,u);const k=JSON.parse(JSON.stringify(d));return delete k.roughElement,delete k.shape,{...k,id:u,x:d.x+20,y:d.y+20,updated:Date.now(),version:k.version?k.version+1:1,seed:Math.floor(Math.random()*2**31)}}),r=new Map;i.forEach(d=>{if(d.containerId&&l.has(d.containerId)&&(d.containerId=l.get(d.containerId)),(d.type==="arrow"||d.type==="line")&&(d.startBinding&&l.has(d.startBinding.elementId)&&(d.startBinding={...d.startBinding,elementId:l.get(d.startBinding.elementId)}),d.endBinding&&l.has(d.endBinding.elementId)&&(d.endBinding={...d.endBinding,elementId:l.get(d.endBinding.elementId)})),d.groupIds&&d.groupIds.length>0){const u=d.groupIds.map(k=>(r.has(k)||r.set(k,dt()),r.get(k)));d.groupIds=u}}),this.elements=[...this.elements,...i];const c={};i.forEach(d=>c[d.id]=!0),this.appState.selectedElementIds=c,t&&t(Object.keys(c))},alignElements(a){if(Object.keys(this.appState.selectedElementIds).length<2)return;this.recordHistory();const e=this.elements.filter(d=>this.appState.selectedElementIds[d.id]);let s=1/0,o=-1/0,l=1/0,i=-1/0;e.forEach(d=>{s=Math.min(s,d.x),o=Math.max(o,d.x+d.width),l=Math.min(l,d.y),i=Math.max(i,d.y+d.height)});const r=(s+o)/2,c=(l+i)/2;this.elements=this.elements.map(d=>{if(!this.appState.selectedElementIds[d.id])return d;let u={};switch(a){case"left":u={x:s};break;case"center":u={x:r-d.width/2};break;case"right":u={x:o-d.width};break;case"top":u={y:l};break;case"middle":u={y:c-d.height/2};break;case"bottom":u={y:i-d.height};break}return{...d,...u,updated:Date.now()}}),this.recordHistory()},groupElements(a){if(a.length===0)return;const t=a.filter(s=>{const o=this.elements.find(l=>l.id===s);return o&&(o.frameId===null||o.frameId===void 0)});if(console.log(`Group Elements: Input ${a.length}, Allowed ${t.length}`),t.length<2)return;this.recordHistory();const e=dt();this.elements=this.elements.map(s=>t.includes(s.id)?{...s,groupIds:[...s.groupIds,e],updated:Date.now()}:s),this.setSelectedElementIds(a)},ungroupElements(a){a.length!==0&&(this.recordHistory(),this.elements=this.elements.map(t=>{if(a.includes(t.id)&&t.groupIds.length>0){const e=[...t.groupIds];return e.pop(),{...t,groupIds:e,updated:Date.now()}}return t}))},setLockedTool(a){this.appState.lockedTool=a},saveToLocalStorage(){const a={elements:this.elements,appState:{...this.appState}};delete a.appState.scrollX,delete a.appState.scrollY,delete a.appState.zoom,delete a.appState.activeTool,delete a.appState.activeToolType,delete a.appState.showHelp,delete a.appState.isDraggingElement,delete a.appState.isBoxSelecting,delete a.appState.showGrid,delete a.appState.isPropertiesPanelOpen,delete a.appState.floatingToolbarOffset,delete a.appState.selectedElementIds;try{localStorage.setItem("jvs-draw-data",JSON.stringify(a))}catch(t){console.error("Failed to save to local storage",t)}},loadFromLocalStorage(){try{const a=localStorage.getItem("jvs-draw-data");if(a){const t=JSON.parse(a);t.elements&&(this.elements=t.elements,this.history=[[...t.elements]],this.historyStep=0),t.appState&&(this.appState={...this.appState,...t.appState,scrollX:this.appState.scrollX,scrollY:this.appState.scrollY,zoom:this.appState.zoom,activeTool:this.appState.activeTool,activeToolType:this.appState.activeToolType,showHelp:this.appState.showHelp,isDraggingElement:this.appState.isDraggingElement,isBoxSelecting:this.appState.isBoxSelecting,showGrid:this.appState.showGrid,isPropertiesPanelOpen:this.appState.isPropertiesPanelOpen,floatingToolbarOffset:this.appState.floatingToolbarOffset,selectedElementIds:this.appState.selectedElementIds})}}catch(a){console.error("Failed to load from local storage",a)}}}}),Rn=()=>new Promise(a=>{const t=document.createElement("input");t.type="file",t.accept="image/*";let e=!1;t.onchange=o=>{e=!0;const l=o.target.files?.[0];if(l){const i=new FileReader;i.onload=r=>{const c=r.target?.result;if(c){const d=new Image;d.onload=()=>{let u=d.naturalWidth,k=d.naturalHeight;const h=500;if(u>h||k>h){const m=u/k;u>k?(u=h,k=h/m):(k=h,u=h*m)}a({dataURL:c,width:u,height:k,file:l})},d.onerror=()=>{a(null)},d.src=c}else a(null)},i.onerror=()=>{a(null)},i.readAsDataURL(l)}else a(null)};const s=()=>{window.removeEventListener("focus",s),setTimeout(()=>{e||a(null)},500)};window.addEventListener("focus",s),t.click()}),Ts={class:"tool-group"},zs={class:"svg-icon"},Ps=["xlink:href"],$s=["title"],_s={class:"svg-icon"},As=["xlink:href"],Ds={key:0,class:"shortcut"},Fs={class:"sub-tools-container"},Ls=["onClick"],Os={class:"svg-icon"},Rs=["xlink:href"],Xs=["onClick","title"],Ys={class:"svg-icon"},js=["xlink:href"],Hs={key:0,class:"shortcut"},Ws=n.defineComponent({__name:"Toolbar",setup(a){const t=je(),e=n.computed(()=>t.appState.activeTool),s=n.computed(()=>t.appState.activeToolType),o=n.ref(!1);n.watch(()=>e.value,h=>{h==="shapes"?o.value=!0:o.value=!1});const l=[{name:"trand"},{name:"selection",label:"Select",icon:"#icon-xuanze",activeIcon:"#icon-xuanze-xuanzhong",key:"1"},{name:"laser",label:"Laser",icon:"#icon-jiguangbi1",activeIcon:"#icon-jiguangbi-xuanzhong1",key:"K"},{name:"trand"},{name:"shapes",label:"Shapes",icon:"#icon-xingzhuang",activeIcon:"#icon-xingzhuang-xuanzhong",key:"2",subTools:[{name:"rectangle",icon:"#icon-yuanjiaojuxing",label:"矩形",key:"2"},{name:"diamond",icon:"#icon-lingxing",label:"菱形",key:"3"},{name:"ellipse",icon:"#icon-tuoyuanxing",label:"椭圆",key:"4"},{name:"square",icon:"#icon-zhengfangxing",label:"正方形",key:"2"},{name:"star",icon:"#icon-wujiaoxing",label:"五角星",key:"3"},{name:"circle",icon:"#icon-yuanxing",label:"圆形",key:"4"},{name:"cylinder",icon:"#icon-yuanzhuti",label:"圆柱体",key:"5"},{name:"trapezoid",icon:"#icon-tixing",label:"梯形",key:"8"},{name:"parallelogram",icon:"#icon-pinghangsibianxing",label:"平行四边形",key:"9"}]},{name:"arrow",label:"Arrow",icon:"#icon-jiantou",activeIcon:"#icon-jiantou-xuanzhong",key:"5"},{name:"line",label:"Line",icon:"#icon-lianxian",activeIcon:"#icon-lianxian-xuanzhong",key:"6"},{name:"freedraw",label:"Draw",icon:"#icon-huabi",activeIcon:"#icon-huabi-xuanzhong",key:"7"},{name:"text",label:"Text",icon:"#icon-wenben",activeIcon:"#icon-wenben-xuanzhong",key:"8"},{name:"image",label:"Image",icon:"#icon-tupian",activeIcon:"#icon-tupian-xuanzhong",key:"I"},{name:"frame",label:"Frame",icon:"#icon-rongqi",activeIcon:"#icon-rongqi-xuanzhong",key:"9"},{name:"eraser",label:"Eraser",icon:"#icon-xiangpica",activeIcon:"#icon-xiangpica-xuanzhong",key:"0"}],i=n.computed(()=>t.appState.lockedTool),r=async h=>{if(o.value=!1,h==="image"){const m=t.appState.activeTool;t.setTool("image");const f=await Rn();if(f){const M=window.innerWidth/2,E=window.innerHeight/2;t.insertImage?t.insertImage(f.dataURL,M-f.width/2,E-f.height/2,f.width,f.height):(console.error("Store action insertImage not found, reloading might fix this."),location.reload()),t.setTool(m)}else t.setTool(m);return}t.setTool(h),t.setSelectedElementIds([])},c=n.computed(()=>t.appState.isDraggingElement||t.appState.isBoxSelecting);function d(h,m){t.setToolType(h),t.setTool(m)}function u(){t.setTool("shapes")}function k(){t.setLockedTool(!t.appState.lockedTool)}return(h,m)=>{const f=n.resolveComponent("el-popover");return n.openBlock(),n.createElementBlock("div",{class:"toolbar glass",style:n.normalizeStyle({pointerEvents:c.value?"none":"auto"})},[n.createElementVNode("div",Ts,[n.createElementVNode("div",{class:n.normalizeClass({"tool-item":!0,active:i.value}),onClick:k,title:"绘制后保持所选工具状态"},[(n.openBlock(),n.createElementBlock("svg",zs,[n.createElementVNode("use",{"xlink:href":`${i.value?"#icon-zujiansuoding":"#icon-zujianjiesuo"}`},null,8,Ps)]))],2),(n.openBlock(),n.createElementBlock(n.Fragment,null,n.renderList(l,M=>(n.openBlock(),n.createElementBlock(n.Fragment,{key:M.name},[M.subTools?(n.openBlock(),n.createBlock(f,{key:0,placement:"right-start",trigger:"click",visible:o.value,"onUpdate:visible":m[0]||(m[0]=E=>o.value=E),width:224,offset:16,"popper-style":"padding: 8px;","show-arrow":!1,onShow:u},{reference:n.withCtx(()=>[n.createElementVNode("div",{class:n.normalizeClass({"tool-item":!0,active:e.value===M.name}),title:M.label},[(n.openBlock(),n.createElementBlock("svg",_s,[n.createElementVNode("use",{"xlink:href":`${e.value===M.name?M.activeIcon:M.icon}`},null,8,As)])),M.key?(n.openBlock(),n.createElementBlock("span",Ds,n.toDisplayString(M.key),1)):n.createCommentVNode("",!0)],10,$s)]),default:n.withCtx(()=>[n.createElementVNode("div",Fs,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(M.subTools,E=>(n.openBlock(),n.createElementBlock("div",{key:E.name,class:n.normalizeClass(["sub-tool-item",{active:e.value===M.name&&s.value===E.name}]),onClick:B=>d(E.name,M.name)},[(n.openBlock(),n.createElementBlock("svg",Os,[n.createElementVNode("use",{"xlink:href":`${E.icon}`},null,8,Rs)]))],10,Ls))),128))])]),_:2},1032,["visible"])):(n.openBlock(),n.createElementBlock("div",{key:1,class:n.normalizeClass({"tool-item":!0,active:e.value===M.name,"trand-line":M.name==="trand"}),onClick:E=>M.name!=="trand"?r(M.name):null,title:M.label},[M.name!=="trand"?(n.openBlock(),n.createElementBlock(n.Fragment,{key:0},[(n.openBlock(),n.createElementBlock("svg",Ys,[n.createElementVNode("use",{"xlink:href":`${e.value===M.name?M.activeIcon:M.icon}`},null,8,js)])),M.key?(n.openBlock(),n.createElementBlock("span",Hs,n.toDisplayString(M.key),1)):n.createCommentVNode("",!0)],64)):n.createCommentVNode("",!0)],10,Xs))],64))),64))])],4)}}}),Ye=(a,t)=>{const e=a.__vccOpts||a;for(const[s,o]of t)e[s]=o;return e},qs=Ye(Ws,[["__scopeId","data-v-b6ea5f5c"]]);function Xn(a){let t;if(a>100&&(a=100),a<0||a>100)throw new Error("Input must be between 0 and 100.");return t=Math.round(a/100*255),t.toString(16).padStart(2,"0")}function Ot(a){if(!a||a.length!==2)return 100;const t=parseInt(a,16);return isNaN(t)?100:Math.round(t/255*100)}const Us={class:"fill-style-box"},Gs=["onClick"],Js={class:"svg-icon"},Ks=["xlink:href"],Yn=Ye(n.defineComponent({__name:"fillStyle",setup(a){const t=je(),e=n.computed(()=>{const i=s();return i?i.fillStyle:t.appState.currentItemFillStyle}),s=()=>{const i=Object.keys(t.appState.selectedElementIds);if(i.length===0)return null;const r=i[i.length-1];return t.elements.find(c=>c.id===r)||null},o=n.ref([{label:"纯色",icon:"icon-chunse",iconActive:"icon-chunse-xuanzhong",value:"solid"},{label:"斜线",icon:"icon-xiexian",iconActive:"icon-xiexian-xuanzhong",value:"hachure"},{label:"交叉线",icon:"icon-jiaochaxian",iconActive:"icon-jiaochaxian-xuanzhong",value:"cross-hatch"}]),l=i=>{t.updateSelectedElements({fillStyle:i})};return(i,r)=>(n.openBlock(),n.createElementBlock("div",Us,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(o.value,(c,d)=>(n.openBlock(),n.createElementBlock("div",{key:d,class:n.normalizeClass(["fill-style-item",{active:e.value===c.value}]),onClick:u=>l(c.value)},[(n.openBlock(),n.createElementBlock("svg",Js,[n.createElementVNode("use",{"xlink:href":`#${e.value===c.value?c.iconActive:c.icon}`},null,8,Ks)]))],10,Gs))),128))]))}}),[["__scopeId","data-v-9356d2e1"]]),Zs={class:"fill-style-box"},Qs=["onClick"],eo={class:"svg-icon"},to=["xlink:href"],jn=Ye(n.defineComponent({__name:"borderStyle",setup(a){const t=je(),e=n.computed(()=>{const i=s();return i?i.strokeStyle:t.appState.currentItemFillStyle}),s=()=>{const i=Object.keys(t.appState.selectedElementIds);if(i.length===0)return null;const r=i[i.length-1];return t.elements.find(c=>c.id===r)||null},o=n.ref([{label:"实线",icon:"icon-shixian",iconActive:"icon-shixian-xuanzhong",value:"solid"},{label:"点虚线",icon:"icon-dianxuxian",iconActive:"icon-dianxuxian-xuanzhong",value:"dotted"},{label:"虚线",icon:"icon-xuxian",iconActive:"icon-xuxian-xuanzhong",value:"dashed"}]),l=i=>{t.updateSelectedElements({strokeStyle:i})};return(i,r)=>(n.openBlock(),n.createElementBlock("div",Zs,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(o.value,(c,d)=>(n.openBlock(),n.createElementBlock("div",{key:d,class:n.normalizeClass(["fill-style-item",{active:e.value===c.value}]),onClick:u=>l(c.value)},[(n.openBlock(),n.createElementBlock("svg",eo,[n.createElementVNode("use",{"xlink:href":`#${e.value===c.value?c.iconActive:c.icon}`},null,8,to)]))],10,Qs))),128))]))}}),[["__scopeId","data-v-dcf857c8"]]),no={class:"fill-style-box"},so=["onClick"],oo={class:"svg-icon"},ao=["xlink:href"],Hn=Ye(n.defineComponent({__name:"lineStyle",setup(a){const t=je(),e=n.computed(()=>{const i=s();return i?i.roughness:t.appState.currentItemRoughness}),s=()=>{const i=Object.keys(t.appState.selectedElementIds);if(i.length===0)return null;const r=i[i.length-1];return t.elements.find(c=>c.id===r)||null},o=n.ref([{label:"标准",icon:"icon-biaozhun",iconActive:"icon-biaozhun-xuanzhong",value:0},{label:"艺术家",icon:"icon-yishujia",iconActive:"icon-yishujia-xuanzhong",value:1},{label:"漫画家",icon:"icon-manhuajia",iconActive:"icon-manhuajia-xuanzhong",value:2}]),l=i=>{t.updateSelectedElements({roughness:i})};return(i,r)=>(n.openBlock(),n.createElementBlock("div",no,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(o.value,(c,d)=>(n.openBlock(),n.createElementBlock("div",{key:d,class:n.normalizeClass(["fill-style-item",{active:e.value===c.value}]),onClick:u=>l(c.value)},[(n.openBlock(),n.createElementBlock("svg",oo,[n.createElementVNode("use",{"xlink:href":`#${e.value===c.value?c.iconActive:c.icon}`},null,8,ao)]))],10,so))),128))]))}}),[["__scopeId","data-v-794ba895"]]),io={class:"fill-style-box"},lo=["onClick"],ro={class:"svg-icon"},co=["xlink:href"],Wn=Ye(n.defineComponent({__name:"textStyle",setup(a){const t=je(),e=()=>{const i=Object.keys(t.appState.selectedElementIds);if(i.length===0)return null;const r=i[i.length-1];return t.elements.find(c=>c.id===r)||null},s=i=>{const r=e();return i==="bold"?r?r.isBold:t.appState.currentItemIsBold:i==="italic"?r?r.isItalic:t.appState.currentItemIsItalic:i==="underline"?r?r.isUnderline:t.appState.currentItemIsUnderline:i==="strikethrough"?r?r.isStrikethrough:t.appState.currentItemIsStrikethrough:!1},o=i=>{const r=e();if(i==="bold"){const c=r?!r.isBold:!t.appState.currentItemIsBold;t.updateSelectedElements({isBold:c}),t.appState.currentItemIsBold=c}else if(i==="italic"){const c=r?!r.isItalic:!t.appState.currentItemIsItalic;t.updateSelectedElements({isItalic:c}),t.appState.currentItemIsItalic=c}else if(i==="underline"){const c=r?!r.isUnderline:!t.appState.currentItemIsUnderline;t.updateSelectedElements({isUnderline:c}),t.appState.currentItemIsUnderline=c}else if(i==="strikethrough"){const c=r?!r.isStrikethrough:!t.appState.currentItemIsStrikethrough;t.updateSelectedElements({isStrikethrough:c}),t.appState.currentItemIsStrikethrough=c}},l=n.ref([{label:"加粗",icon:"icon-jiacu2",iconActive:"icon-jiacu2-copy",value:"bold"},{label:"倾斜",icon:"icon-qingxie1",iconActive:"icon-qingxie1-copy",value:"italic"},{label:"下划线",icon:"icon-xiahuaxian1",iconActive:"icon-xiahuaxian1-copy",value:"underline"},{label:"删除线",icon:"icon-shanchuxian",iconActive:"icon-shanchuxian-copy",value:"strikethrough"}]);return(i,r)=>(n.openBlock(),n.createElementBlock("div",io,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(l.value,(c,d)=>(n.openBlock(),n.createElementBlock("div",{key:d,class:n.normalizeClass(["fill-style-item",{active:s(c.value)}]),onClick:u=>o(c.value)},[(n.openBlock(),n.createElementBlock("svg",ro,[n.createElementVNode("use",{"xlink:href":`#${s(c.value)?c.iconActive:c.icon}`},null,8,co)]))],10,lo))),128))]))}}),[["__scopeId","data-v-36600f47"]]),po=["onClick"],ho={class:"svg-icon"},fo=["xlink:href"],uo=["onClick"],mo={class:"svg-icon"},go=["xlink:href"],qn=Ye(n.defineComponent({__name:"alignStyle",setup(a){const t=je(),e=n.computed(()=>t.appState.activeTool),s=n.computed(()=>Object.keys(t.appState.selectedElementIds)),o=n.computed(()=>s.value.length>0),l=()=>{if(e.value==="selection"){if(!o.value)return"none";const f=s.value[0],M=t.elements.find(E=>E.id===f);return M?M.type:"none"}return e.value==="shapes"?t.appState.activeToolType:e.value},i=n.computed(()=>{const f=l();return["rectangle","ellipse","diamond","square","star","circle","cylinder","process","decision","trapezoid","parallelogram"].includes(f)}),r=n.computed(()=>{const f=d();return f?f.textAlign:t.appState.currentItemTextAlign}),c=n.computed(()=>{const f=d();return f?f.verticalAlign:t.appState.currentItemVerticalAlign}),d=()=>{const f=Object.keys(t.appState.selectedElementIds);if(f.length===0)return null;const M=f[f.length-1];return t.elements.find(E=>E.id===M)||null},u=n.ref([{label:"左对齐",icon:"icon-zuoduiqi3",iconActive:"icon-zuoduiqi3-copy",value:"left"},{label:"居中对齐",icon:"icon-juzhongduiqi",iconActive:"icon-juzhongduiqi-copy",value:"center"},{label:"右对齐",icon:"icon-youduiqi3-copy",iconActive:"icon-youduiqi3-copy-copy",value:"right"}]),k=n.ref([{label:"上对齐",icon:"icon-dingduiqi2",iconActive:"icon-dingduiqi2-copy",value:"top"},{label:"居中对齐",icon:"icon-zhongjianduiqi",iconActive:"icon-zhongjianduiqi-copy",value:"middle"},{label:"下对齐",icon:"icon-diduiqi1",iconActive:"icon-diduiqi1-copy",value:"bottom"}]);function h(f){t.updateSelectedElements({textAlign:f})}function m(f){t.updateSelectedElements({verticalAlign:f})}return(f,M)=>(n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["fill-style-box",{"no-vertical-align":!i.value}])},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(u.value,(E,B)=>(n.openBlock(),n.createElementBlock("div",{key:B,class:n.normalizeClass(["fill-style-item",{active:r.value===E.value}]),onClick:b=>h(E.value)},[(n.openBlock(),n.createElementBlock("svg",ho,[n.createElementVNode("use",{"xlink:href":`#${r.value===E.value?E.iconActive:E.icon}`},null,8,fo)]))],10,po))),128)),i.value?(n.openBlock(!0),n.createElementBlock(n.Fragment,{key:0},n.renderList(k.value,(E,B)=>(n.openBlock(),n.createElementBlock("div",{key:B,class:n.normalizeClass(["fill-style-item",{active:c.value===E.value}]),onClick:b=>m(E.value)},[(n.openBlock(),n.createElementBlock("svg",mo,[n.createElementVNode("use",{"xlink:href":`#${c.value===E.value?E.iconActive:E.icon}`},null,8,go)]))],10,uo))),128)):n.createCommentVNode("",!0)],2))}}),[["__scopeId","data-v-b408686c"]]),yo={class:"fill-style-box"},ko=["onClick"],xo={class:"svg-icon"},wo=["xlink:href"],Un=Ye(n.defineComponent({__name:"arrowStyle",setup(a){const t=je(),e=n.computed(()=>{const i=s();return i?i.arrowType:t.appState.currentItemArrowType}),s=()=>{const i=Object.keys(t.appState.selectedElementIds);if(i.length===0)return null;const r=i[i.length-1];return t.elements.find(c=>c.id===r)||null},o=n.ref([{label:"直线连接",icon:"icon-zhixianlianjiexian",iconActive:"icon-zhixianlianjiexian-xuanzhong",value:"sharp"},{label:"曲线连接",icon:"icon-quxian",iconActive:"icon-quxian-xuanzhong",value:"round"}]),l=i=>{t.updateSelectedElements({arrowType:i})};return(i,r)=>(n.openBlock(),n.createElementBlock("div",yo,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(o.value,(c,d)=>(n.openBlock(),n.createElementBlock("div",{key:d,class:n.normalizeClass(["fill-style-item",{active:e.value===c.value}]),onClick:u=>l(c.value)},[(n.openBlock(),n.createElementBlock("svg",xo,[n.createElementVNode("use",{"xlink:href":`#${e.value===c.value?c.iconActive:c.icon}`},null,8,wo)]))],10,ko))),128))]))}}),[["__scopeId","data-v-b56fafad"]]),So={class:"header"},bo={class:"content"},vo={class:"shape-panel-box"},Eo={class:"input-box"},Io={class:"input-box"},Mo={key:0,class:"input-box"},Bo={key:1,class:"input-box"},Co={key:3,class:"btn-box"},Vo={class:"svg-icon"},No=["xlink:href"],To={key:0,class:"roundness-box"},zo={class:"style-item"},Po={key:0,class:"svg-icon"},$o={class:"color-text"},_o={class:"style-item"},Ao={class:"style-item"},Do={class:"style-item"},Fo={key:0,class:"svg-icon"},Lo={class:"color-text"},Oo={class:"style-item"},Ro={class:"style-item"},Xo={key:0,class:"style-item"},Yo={class:"style-item"},jo={key:1,class:"style-item"},Ho={class:"title"},Wo={class:"style-item"},qo={class:"style-boxs"},Uo={class:"style-boxs-item"},Go={class:"style-boxs-item"},Jo={class:"style-item"},Ko={key:0,class:"svg-icon"},Zo={class:"color-text"},Qo={class:"style-item"},ea={key:0,class:"svg-icon"},ta={class:"color-text"},na=Ye(n.defineComponent({__name:"PropertiesPanel",setup(a){const t=je(),e=n.ref(),s=n.ref(),o=n.ref(),l=n.ref(),i=n.ref(),r=n.ref(),c=n.ref(),d=n.ref(),u=()=>{t.appState.isPropertiesPanelOpen=!1},k=[12,14,16,18,20,24,28,32,36],h=()=>{const z=Object.keys(t.appState.selectedElementIds);if(z.length===0)return null;const $=z[z.length-1];return t.elements.find(pe=>pe.id===$)||null},m=n.computed(()=>t.appState.activeTool),f=n.computed(()=>Object.keys(t.appState.selectedElementIds)),M=n.computed(()=>f.value.length>0),E=()=>{if(m.value==="selection"){if(!M.value)return"none";const z=f.value[0],$=t.elements.find(pe=>pe.id===z);return $?$.type:"none"}return m.value==="shapes"?t.appState.activeToolType:m.value},B=n.computed(()=>Y.value+Xn(X.value)),b=n.computed(()=>Ie.value+Xn(A.value));n.computed(()=>K.value),n.computed(()=>Me.value);const V=n.computed(()=>{const z=E();return!["arrow","line","text","freedraw","image"].includes(z)}),O=n.computed(()=>{const z=E();return!["arrow","line","freedraw","frame","image"].includes(z)}),H=n.computed(()=>{const z=E();return["arrow","line"].includes(z)}),Z=n.computed(()=>{const z=E();return!["arrow","line","freedraw","text"].includes(z)}),ne=n.computed(()=>{const z=E();return!["arrow","line"].includes(z)}),W=n.computed(()=>{const z=E();return["arrow","line"].includes(z)}),J=n.computed(()=>{const z=E();return!["text","image"].includes(z)}),Q=n.computed({get(){const z=h();return z?z.roundness??0:t.appState.currentItemRoundness},set(z){_t(z)}}),oe=n.computed(()=>t.appState.isDraggingElement||t.appState.isBoxSelecting),Y=n.computed({get(){const z=h();return z?z.backgroundColor:t.appState.currentItemBackgroundColor},set(z){de(z)}}),A=n.computed({get(){const z=h();return z?z.strokeOpacity??100:t.appState.currentItemStrokeOpacity??100},set(z){tn(z)}}),X=n.computed({get(){const z=h();return z?z.backgroundOpacity??100:t.appState.currentItemBackgroundOpacity},set(z){fe(z)}}),te=n.computed({get(){const z=h();return z?z.strokeWidth:t.appState.currentItemStrokeWidth},set(z){Tt(z)}}),de=z=>{const $=z||"transparent";t.updateSelectedElements({backgroundColor:$})},fe=z=>{const $=z;t.updateSelectedElements({backgroundOpacity:$})},Ie=n.computed({get(){const z=h();return z?z.strokeColor:t.appState.currentItemStrokeColor},set(z){zt(z)}}),Me=n.computed({get(){const z=h();return z?z?.fontColor:t.appState.currentItemFontColor},set(z){Pt(z)}}),K=n.computed({get(){const z=h();return z&&"fontBgColor"in z?z.fontBgColor:t.appState.currentItemFontBgColor},set(z){$t(z)}}),Le=n.computed({get(){const z=h();return z?z.x:t.appState.currentItemX},set(z){Qt(z)}}),ee=n.computed({get(){const z=h();return z?z.y:t.appState.currentItemY},set(z){en(z)}}),Xe=n.computed({get(){const z=h();return z?z.width:t.appState.currentItemWidth},set(z){Ce(z)}}),et=n.computed({get(){const z=h();return z?z.height:t.appState.currentItemHeight},set(z){ve(z)}}),Ke=n.computed({get:()=>{const z=h();return z&&"fontSize"in z?z.fontSize:t.appState.currentItemFontSize},set:z=>{nn(z)}}),Be=n.computed({get(){const z=h(),$=z?z.angle:t.appState.currentItemAngle;return $?(360*Math.abs(Math.round($*(180/Math.PI)))+Math.round($*(180/Math.PI)))%360:0},set(z){j(z*(Math.PI/180)%360)}}),Ae=n.ref(1);n.watch(()=>Be.value,z=>{Ae.value=String(z||0).length},{immediate:!0});const it=z=>{const $=z.target;$&&$.tagName==="INPUT"&&(Ae.value=$.value.length||1)},D=()=>{Ae.value=String(Be.value||0).length};function j(z){const $=h();if($){const pe=t.elements.find(ke=>ke.type==="text"&&ke.containerId===$.id&&!ke.isDeleted);pe&&t.updateElement(pe.id,{angle:z})}t.updateSelectedElements({angle:z})}function ve(z){const $=h();if($&&$.height>0){const pe={height:z};let ke=$.width;if($.isAspectRatioLocked){const me=$.width/$.height;ke=z*me,pe.width=ke}const se=t.elements.find(me=>me.type==="text"&&me.containerId===$.id&&!me.isDeleted);if(se){const me=_e(se.text||"",se.fontSize||20,se.fontFamily||"sans-serif",ke,{isBold:se.isBold,isItalic:se.isItalic});pe.height=Math.max(z,me.height),t.updateElement(se.id,{width:ke,height:pe.height})}else if($.type==="text"){const me=_e($.text||"",$.fontSize||20,$.fontFamily||"sans-serif",ke,{isBold:$.isBold,isItalic:$.isItalic});pe.height=Math.max(z,me.height)}t.updateSelectedElements(pe)}}function Ce(z){const $=h();if($&&$.width>0){const pe={width:z};let ke=$.height;console.log($.height);const se=t.elements.find(me=>me.type==="text"&&me.containerId===$.id&&!me.isDeleted);if(se||$.type==="text"){const me=_e(",",$.fontSize||20,$.fontFamily||"sans-serif",void 0,{isBold:$.isBold,isItalic:$.isItalic}).width;z<me&&(pe.width=me)}if($.isAspectRatioLocked){const me=$.height/$.width;ke=pe.width*me,pe.height=ke}if(se){const me=_e(se.text||"",se.fontSize||20,se.fontFamily||"sans-serif",pe.width,{isBold:se.isBold,isItalic:se.isItalic});pe.height=Math.max(ke,me.height),t.updateElement(se.id,{width:pe.width,height:pe.height})}else if($.type==="text"){const me=_e($.text||"",$.fontSize||20,$.fontFamily||"sans-serif",pe.width,{isBold:$.isBold,isItalic:$.isItalic});pe.height=Math.max(ke,me.height)}t.updateSelectedElements(pe)}}const ue=n.computed(()=>{const z=h();return z?!!z.isFlippedHorizontal:!1}),Ve=n.computed(()=>{const z=h();return z?!!z.isFlippedVertical:!1});function ce(){const z=h();z&&t.updateSelectedElements({isFlippedHorizontal:!z.isFlippedHorizontal})}function Zt(){const z=h();z&&t.updateSelectedElements({isFlippedVertical:!z.isFlippedVertical})}const tt=n.computed(()=>{const z=h();return z?!!z.isAspectRatioLocked:!1});function bn(){const z=h();z&&t.updateSelectedElements({isAspectRatioLocked:!z.isAspectRatioLocked})}function Qt(z){t.updateSelectedElements({x:z})}function en(z){t.updateSelectedElements({y:z})}function Et(){s.value.openColorPicker(),s.value.initPickerColor(B.value)}function vn(){l.value.openColorPicker(),l.value.initPickerColor(b.value)}function En(z){de(z.hex.substring(0,7)),fe(Ot(z.hex.substring(7,9)))}const Tt=z=>{t.updateSelectedElements({strokeWidth:z})},tn=z=>{t.updateSelectedElements({strokeOpacity:z})};function In(z){zt(z.hex.substring(0,7)),tn(Ot(z.hex.substring(7,9)))}const zt=z=>{t.updateSelectedElements({strokeColor:z})},Pt=z=>{t.updateSelectedElements({fontColor:z}),Object.keys(t.appState.selectedElementIds).forEach(pe=>{const ke=t.elements.find(se=>se.type==="text"&&se.containerId===pe&&!se.isDeleted);ke&&t.updateElement(ke.id,{fontColor:z})})},$t=z=>{t.updateSelectedElements({fontBgColor:z}),Object.keys(t.appState.selectedElementIds).forEach(pe=>{const ke=t.elements.find(se=>se.type==="text"&&se.containerId===pe&&!se.isDeleted);ke&&t.updateElement(ke.id,{fontBgColor:z})})},Mn=()=>{c.value.openColorPicker(),c.value.initPickerColor(K.value)},Bn=()=>{d.value.openColorPicker(),d.value.initPickerColor(Me.value)},Cn=z=>{Ot(z.hex.substring(7,9))==0?Pt("transparent"):Pt(z.hex.substring(0,7))},Vn=z=>{Ot(z.hex.substring(7,9))==0?$t("transparent"):$t(z.hex.substring(0,7))},_t=z=>{t.updateSelectedElements({roundness:z})},nn=z=>{Object.keys(t.appState.selectedElementIds).forEach(pe=>{const ke=t.elements.find(se=>se.id===pe);if(ke&&ke.type==="text"){const se=ke;if(se.autoResize){const me=_e(se.text||"",z,se.fontFamily||"sans-serif",void 0,{isBold:se.isBold,isItalic:se.isItalic});t.updateElement(pe,{fontSize:z,width:me.width,height:me.height})}else{const me=_e(se.text||"",z,se.fontFamily||"sans-serif",ke.width,{isBold:se.isBold,isItalic:se.isItalic});t.updateElement(pe,{fontSize:z,height:me.height})}}else{t.updateElement(pe,{fontSize:z});const se=t.elements.find(me=>me.type==="text"&&me.containerId===pe&&!me.isDeleted);if(se){const me=_e(se.text||"",z,se.fontFamily||"sans-serif",se.width);t.updateElement(se.id,{fontSize:z,height:Math.max(me.height,ke?.height)})}}})};return(z,$)=>{const pe=n.resolveComponent("el-input-number"),ke=n.resolveComponent("el-slider"),se=n.resolveComponent("jvs-picker-color-v3"),me=n.resolveComponent("el-select"),Nn=n.resolveComponent("el-option"),sn=n.resolveComponent("el-input"),Tn=n.resolveComponent("el-scrollbar");return n.unref(t).appState.isPropertiesPanelOpen?(n.openBlock(),n.createElementBlock("div",{key:0,class:"properties-panel",style:n.normalizeStyle({pointerEvents:oe.value?"none":"auto"})},[n.createElementVNode("div",So,[$[16]||($[16]=n.createElementVNode("div",null,"形状",-1)),(n.openBlock(),n.createElementBlock("svg",{onClick:u},[...$[15]||($[15]=[n.createElementVNode("use",{"xlink:href":"#jvs-public-danchuangguanbi1"},null,-1)])]))]),n.createVNode(Tn,null,{default:n.withCtx(()=>[n.createElementVNode("div",bo,[n.createElementVNode("div",vo,[n.createElementVNode("div",{class:n.normalizeClass(["shape-panel-row",{"not-bind-width-height":H.value||!Z.value}])},[n.createElementVNode("div",Eo,[$[17]||($[17]=n.createElementVNode("div",{class:"icon"},"X",-1)),n.createVNode(pe,{modelValue:Le.value,"onUpdate:modelValue":$[0]||($[0]=Ee=>Le.value=Ee),precision:2,"controls-position":"right"},null,8,["modelValue"])]),n.createElementVNode("div",Io,[$[18]||($[18]=n.createElementVNode("div",{class:"icon"},"Y",-1)),n.createVNode(pe,{modelValue:ee.value,"onUpdate:modelValue":$[1]||($[1]=Ee=>ee.value=Ee),precision:2,"controls-position":"right"},null,8,["modelValue"])]),H.value?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("div",Mo,[$[19]||($[19]=n.createElementVNode("div",{class:"icon"},"W",-1)),n.createVNode(pe,{modelValue:Xe.value,"onUpdate:modelValue":$[2]||($[2]=Ee=>Xe.value=Ee),precision:2,"controls-position":"right"},null,8,["modelValue"])])),H.value?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("div",Bo,[$[20]||($[20]=n.createElementVNode("div",{class:"icon"},"H",-1)),n.createVNode(pe,{modelValue:et.value,"onUpdate:modelValue":$[3]||($[3]=Ee=>et.value=Ee),precision:2,"controls-position":"right"},null,8,["modelValue"])])),ne.value?(n.openBlock(),n.createElementBlock("div",{key:2,class:"input-box",onInput:it,onFocusout:D},[$[21]||($[21]=n.createElementVNode("div",{class:"icon"},[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-jiaodu"})])],-1)),n.createVNode(pe,{modelValue:Be.value,"onUpdate:modelValue":$[4]||($[4]=Ee=>Be.value=Ee),"controls-position":"right"},null,8,["modelValue"]),n.createElementVNode("div",{class:"unit",style:n.normalizeStyle({left:32+Ae.value*8+"px"})},"°",4)],32)):n.createCommentVNode("",!0),ne.value?(n.openBlock(),n.createElementBlock("div",Co,[n.createElementVNode("div",{class:n.normalizeClass(["btn-item",{active:ue.value}]),onClick:ce},[...$[22]||($[22]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-shuipingfanzhuan"})],-1)])],2),n.createElementVNode("div",{class:n.normalizeClass(["btn-item",{active:Ve.value}]),onClick:Zt},[...$[23]||($[23]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-chuizhifanzhuan"})],-1)])],2)])):n.createCommentVNode("",!0)],2),H.value?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("div",{key:0,class:n.normalizeClass(["bind-box",{active:tt.value}]),onClick:bn},[(n.openBlock(),n.createElementBlock("svg",Vo,[n.createElementVNode("use",{"xlink:href":tt.value?"#icon-suoding1":"#icon-quxiaosuoding"},null,8,No)]))],2))]),Z.value?(n.openBlock(),n.createElementBlock("div",To,[$[25]||($[25]=n.createElementVNode("div",{class:"item-label",style:{"padding-right":"8px"}},"圆角",-1)),n.createVNode(ke,{modelValue:Q.value,"onUpdate:modelValue":$[5]||($[5]=Ee=>Q.value=Ee),"show-input":"","show-input-controls":!1,min:0,max:100},null,8,["modelValue"]),n.createElementVNode("div",{class:"btn-box",onClick:$[6]||($[6]=Ee=>_t(4))},[...$[24]||($[24]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-biankuang-yincangzhuangtai"})],-1)])])])):n.createCommentVNode("",!0),V.value?(n.openBlock(),n.createElementBlock(n.Fragment,{key:1},[$[30]||($[30]=n.createElementVNode("div",{class:"divider"},null,-1)),$[31]||($[31]=n.createElementVNode("div",{class:"type-item-title"},[n.createElementVNode("div",{class:"title"},"填充")],-1)),n.createElementVNode("div",zo,[$[27]||($[27]=n.createElementVNode("div",{class:"title"},"颜色",-1)),n.createVNode(se,{color:Y.value,ref_key:"bgColorPickerRef",ref:s,options:{openGradual:!1,pickerButtonRef:e.value},onChange:En},{default:n.withCtx(({isGradual:Ee,color:qe,alpha:ge})=>[n.createElementVNode("div",{class:"input-value-box",ref_key:"bgColorRef",ref:e,onClick:$[7]||($[7]=At=>Et())},[Y.value=="transparent"||!Y.value||X.value==0?(n.openBlock(),n.createElementBlock("svg",Po,[...$[26]||($[26]=[n.createElementVNode("use",{"xlink:href":"#icon-wuyanse"},null,-1)])])):(n.openBlock(),n.createElementBlock("div",{key:1,class:"color-box",style:n.normalizeStyle({background:B.value})},null,4)),n.createElementVNode("div",$o,n.toDisplayString(Y.value!="transparent"?Y.value.substring(0,7).toUpperCase():Y.value),1)],512)]),_:1},8,["color","options"])]),n.createElementVNode("div",_o,[$[28]||($[28]=n.createElementVNode("div",{class:"title"},"透明度",-1)),n.createVNode(ke,{modelValue:X.value,"onUpdate:modelValue":$[8]||($[8]=Ee=>X.value=Ee),"show-input":"","show-input-controls":!1,min:0,max:100},null,8,["modelValue"])]),n.createElementVNode("div",Ao,[$[29]||($[29]=n.createElementVNode("div",{class:"title"},"填充样式",-1)),n.createVNode(Yn,{style:{width:"100%"}})])],64)):n.createCommentVNode("",!0),J.value?(n.openBlock(),n.createElementBlock(n.Fragment,{key:2},[$[38]||($[38]=n.createElementVNode("div",{class:"divider"},null,-1)),$[39]||($[39]=n.createElementVNode("div",{class:"type-item-title"},[n.createElementVNode("div",{class:"title"},"描边")],-1)),n.createElementVNode("div",Do,[$[33]||($[33]=n.createElementVNode("div",{class:"title"},"颜色",-1)),n.createVNode(se,{color:Ie.value,ref_key:"strokeColorPickerRef",ref:l,options:{openGradual:!1,pickerButtonRef:o.value},onChange:In},{default:n.withCtx(({isGradual:Ee,color:qe,alpha:ge})=>[n.createElementVNode("div",{class:"input-value-box",ref_key:"strokeColorRef",ref:o,onClick:$[9]||($[9]=At=>vn())},[Ie.value=="transparent"||!Ie.value||A.value==0?(n.openBlock(),n.createElementBlock("svg",Fo,[...$[32]||($[32]=[n.createElementVNode("use",{"xlink:href":"#icon-wuyanse"},null,-1)])])):(n.openBlock(),n.createElementBlock("div",{key:1,class:"color-box",style:n.normalizeStyle({background:b.value})},null,4)),n.createElementVNode("div",Lo,n.toDisplayString(Ie.value!="transparent"?Ie.value.substring(0,7).toUpperCase():Ie.value),1)],512)]),_:1},8,["color","options"])]),n.createElementVNode("div",Oo,[$[34]||($[34]=n.createElementVNode("div",{class:"title"},"粗细",-1)),n.createVNode(ke,{modelValue:te.value,"onUpdate:modelValue":$[10]||($[10]=Ee=>te.value=Ee),"show-input":"","show-input-controls":!1,min:1,max:10},null,8,["modelValue"])]),n.createElementVNode("div",Ro,[$[35]||($[35]=n.createElementVNode("div",{class:"title"},"透明度",-1)),n.createVNode(ke,{modelValue:A.value,"onUpdate:modelValue":$[11]||($[11]=Ee=>A.value=Ee),"show-input":"","show-input-controls":!1,min:0,max:100},null,8,["modelValue"])]),E()!="freedraw"?(n.openBlock(),n.createElementBlock("div",Xo,[$[36]||($[36]=n.createElementVNode("div",{class:"title"},"样式",-1)),n.createVNode(jn,{style:{width:"100%"}})])):n.createCommentVNode("",!0),n.createElementVNode("div",Yo,[$[37]||($[37]=n.createElementVNode("div",{class:"title"},"风格",-1)),n.createVNode(Hn,{style:{width:"100%"}})]),W.value?(n.openBlock(),n.createElementBlock("div",jo,[n.createElementVNode("div",Ho,n.toDisplayString(E()=="arrow"?"箭头":"线条")+"类型",1),n.createVNode(Un,{style:{width:"100%"}})])):n.createCommentVNode("",!0)],64)):n.createCommentVNode("",!0),O.value?(n.openBlock(),n.createElementBlock(n.Fragment,{key:3},[$[45]||($[45]=n.createElementVNode("div",{class:"divider"},null,-1)),$[46]||($[46]=n.createElementVNode("div",{class:"type-item-title"},[n.createElementVNode("div",{class:"title"},"文本设置")],-1)),n.createElementVNode("div",Wo,[$[40]||($[40]=n.createElementVNode("div",{class:"title"},"样式",-1)),n.createElementVNode("div",qo,[n.createElementVNode("div",Uo,[n.createVNode(me,{style:{width:"100%"}}),n.createVNode(me,{style:{width:"100%"},modelValue:Ke.value,"onUpdate:modelValue":$[12]||($[12]=Ee=>Ke.value=Ee),onChange:nn},{default:n.withCtx(()=>[(n.openBlock(),n.createElementBlock(n.Fragment,null,n.renderList(k,Ee=>n.createVNode(Nn,{key:Ee,label:Ee,value:Ee},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),n.createElementVNode("div",Go,[n.createVNode(sn),n.createVNode(sn)]),n.createVNode(Wn),n.createVNode(qn)])]),n.createElementVNode("div",Jo,[$[42]||($[42]=n.createElementVNode("div",{class:"title"},"文本颜色",-1)),n.createVNode(se,{color:Me.value,ref_key:"fontColorPickerRef",ref:d,options:{openGradual:!1,pickerButtonRef:r.value},onChange:Cn},{default:n.withCtx(({isGradual:Ee,color:qe,alpha:ge})=>[n.createElementVNode("div",{class:"input-value-box",ref_key:"fontColorRef",ref:r,onClick:$[13]||($[13]=At=>Bn())},[Me.value=="transparent"||!Me.value?(n.openBlock(),n.createElementBlock("svg",Ko,[...$[41]||($[41]=[n.createElementVNode("use",{"xlink:href":"#icon-wuyanse"},null,-1)])])):(n.openBlock(),n.createElementBlock("div",{key:1,class:"color-box",style:n.normalizeStyle({background:Me.value})},null,4)),n.createElementVNode("div",Zo,n.toDisplayString(Me.value!="transparent"?Me.value.substring(0,7).toUpperCase():Me.value),1)],512)]),_:1},8,["color","options"])]),n.createElementVNode("div",Qo,[$[44]||($[44]=n.createElementVNode("div",{class:"title"},"文本背景色",-1)),n.createVNode(se,{color:K.value,ref_key:"fontBgColorPickerRef",ref:c,options:{openGradual:!1,pickerButtonRef:i.value},onChange:Vn},{default:n.withCtx(({isGradual:Ee,color:qe,alpha:ge})=>[n.createElementVNode("div",{class:"input-value-box",ref_key:"fontBgColorRef",ref:i,onClick:$[14]||($[14]=At=>Mn())},[K.value=="transparent"||!K.value?(n.openBlock(),n.createElementBlock("svg",ea,[...$[43]||($[43]=[n.createElementVNode("use",{"xlink:href":"#icon-wuyanse"},null,-1)])])):(n.openBlock(),n.createElementBlock("div",{key:1,class:"color-box",style:n.normalizeStyle({background:K.value})},null,4)),n.createElementVNode("div",ta,n.toDisplayString(K.value!="transparent"?K.value.substring(0,7).toUpperCase():K.value),1)],512)]),_:1},8,["color","options"])])],64)):n.createCommentVNode("",!0)])]),_:1})],4)):n.createCommentVNode("",!0)}}}),[["__scopeId","data-v-00889af3"]]);function dn(a,t,e){if(a&&a.length){const[s,o]=t,l=Math.PI/180*e,i=Math.cos(l),r=Math.sin(l);for(const c of a){const[d,u]=c;c[0]=(d-s)*i-(u-o)*r+s,c[1]=(d-s)*r+(u-o)*i+o}}}function sa(a,t){return a[0]===t[0]&&a[1]===t[1]}function oa(a,t,e,s=1){const o=e,l=Math.max(t,.1),i=a[0]&&a[0][0]&&typeof a[0][0]=="number"?[a]:a,r=[0,0];if(o)for(const d of i)dn(d,r,o);const c=(function(d,u,k){const h=[];for(const b of d){const V=[...b];sa(V[0],V[V.length-1])||V.push([V[0][0],V[0][1]]),V.length>2&&h.push(V)}const m=[];u=Math.max(u,.1);const f=[];for(const b of h)for(let V=0;V<b.length-1;V++){const O=b[V],H=b[V+1];if(O[1]!==H[1]){const Z=Math.min(O[1],H[1]);f.push({ymin:Z,ymax:Math.max(O[1],H[1]),x:Z===O[1]?O[0]:H[0],islope:(H[0]-O[0])/(H[1]-O[1])})}}if(f.sort(((b,V)=>b.ymin<V.ymin?-1:b.ymin>V.ymin?1:b.x<V.x?-1:b.x>V.x?1:b.ymax===V.ymax?0:(b.ymax-V.ymax)/Math.abs(b.ymax-V.ymax))),!f.length)return m;let M=[],E=f[0].ymin,B=0;for(;M.length||f.length;){if(f.length){let b=-1;for(let V=0;V<f.length&&!(f[V].ymin>E);V++)b=V;f.splice(0,b+1).forEach((V=>{M.push({s:E,edge:V})}))}if(M=M.filter((b=>!(b.edge.ymax<=E))),M.sort(((b,V)=>b.edge.x===V.edge.x?0:(b.edge.x-V.edge.x)/Math.abs(b.edge.x-V.edge.x))),(k!==1||B%u==0)&&M.length>1)for(let b=0;b<M.length;b+=2){const V=b+1;if(V>=M.length)break;const O=M[b].edge,H=M[V].edge;m.push([[Math.round(O.x),E],[Math.round(H.x),E]])}E+=k,M.forEach((b=>{b.edge.x=b.edge.x+k*b.edge.islope})),B++}return m})(i,l,s);if(o){for(const d of i)dn(d,r,-o);(function(d,u,k){const h=[];d.forEach((m=>h.push(...m))),dn(h,u,k)})(c,r,-o)}return c}function Bt(a,t){var e;const s=t.hachureAngle+90;let o=t.hachureGap;o<0&&(o=4*t.strokeWidth),o=Math.round(Math.max(o,.1));let l=1;return t.roughness>=1&&(((e=t.randomizer)===null||e===void 0?void 0:e.next())||Math.random())>.7&&(l=o),oa(a,o,s,l||1)}class pn{constructor(t){this.helper=t}fillPolygons(t,e){return this._fillPolygons(t,e)}_fillPolygons(t,e){const s=Bt(t,e);return{type:"fillSketch",ops:this.renderLines(s,e)}}renderLines(t,e){const s=[];for(const o of t)s.push(...this.helper.doubleLineOps(o[0][0],o[0][1],o[1][0],o[1][1],e));return s}}function Rt(a){const t=a[0],e=a[1];return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}class aa extends pn{fillPolygons(t,e){let s=e.hachureGap;s<0&&(s=4*e.strokeWidth),s=Math.max(s,.1);const o=Bt(t,Object.assign({},e,{hachureGap:s})),l=Math.PI/180*e.hachureAngle,i=[],r=.5*s*Math.cos(l),c=.5*s*Math.sin(l);for(const[d,u]of o)Rt([d,u])&&i.push([[d[0]-r,d[1]+c],[...u]],[[d[0]+r,d[1]-c],[...u]]);return{type:"fillSketch",ops:this.renderLines(i,e)}}}class ia extends pn{fillPolygons(t,e){const s=this._fillPolygons(t,e),o=Object.assign({},e,{hachureAngle:e.hachureAngle+90}),l=this._fillPolygons(t,o);return s.ops=s.ops.concat(l.ops),s}}class la{constructor(t){this.helper=t}fillPolygons(t,e){const s=Bt(t,e=Object.assign({},e,{hachureAngle:0}));return this.dotsOnLines(s,e)}dotsOnLines(t,e){const s=[];let o=e.hachureGap;o<0&&(o=4*e.strokeWidth),o=Math.max(o,.1);let l=e.fillWeight;l<0&&(l=e.strokeWidth/2);const i=o/4;for(const r of t){const c=Rt(r),d=c/o,u=Math.ceil(d)-1,k=c-u*o,h=(r[0][0]+r[1][0])/2-o/4,m=Math.min(r[0][1],r[1][1]);for(let f=0;f<u;f++){const M=m+k+f*o,E=h-i+2*Math.random()*i,B=M-i+2*Math.random()*i,b=this.helper.ellipse(E,B,l,l,e);s.push(...b.ops)}}return{type:"fillSketch",ops:s}}}class ra{constructor(t){this.helper=t}fillPolygons(t,e){const s=Bt(t,e);return{type:"fillSketch",ops:this.dashedLine(s,e)}}dashedLine(t,e){const s=e.dashOffset<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashOffset,o=e.dashGap<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashGap,l=[];return t.forEach((i=>{const r=Rt(i),c=Math.floor(r/(s+o)),d=(r+o-c*(s+o))/2;let u=i[0],k=i[1];u[0]>k[0]&&(u=i[1],k=i[0]);const h=Math.atan((k[1]-u[1])/(k[0]-u[0]));for(let m=0;m<c;m++){const f=m*(s+o),M=f+s,E=[u[0]+f*Math.cos(h)+d*Math.cos(h),u[1]+f*Math.sin(h)+d*Math.sin(h)],B=[u[0]+M*Math.cos(h)+d*Math.cos(h),u[1]+M*Math.sin(h)+d*Math.sin(h)];l.push(...this.helper.doubleLineOps(E[0],E[1],B[0],B[1],e))}})),l}}class ca{constructor(t){this.helper=t}fillPolygons(t,e){const s=e.hachureGap<0?4*e.strokeWidth:e.hachureGap,o=e.zigzagOffset<0?s:e.zigzagOffset,l=Bt(t,e=Object.assign({},e,{hachureGap:s+o}));return{type:"fillSketch",ops:this.zigzagLines(l,o,e)}}zigzagLines(t,e,s){const o=[];return t.forEach((l=>{const i=Rt(l),r=Math.round(i/(2*e));let c=l[0],d=l[1];c[0]>d[0]&&(c=l[1],d=l[0]);const u=Math.atan((d[1]-c[1])/(d[0]-c[0]));for(let k=0;k<r;k++){const h=2*k*e,m=2*(k+1)*e,f=Math.sqrt(2*Math.pow(e,2)),M=[c[0]+h*Math.cos(u),c[1]+h*Math.sin(u)],E=[c[0]+m*Math.cos(u),c[1]+m*Math.sin(u)],B=[M[0]+f*Math.cos(u+Math.PI/4),M[1]+f*Math.sin(u+Math.PI/4)];o.push(...this.helper.doubleLineOps(M[0],M[1],B[0],B[1],s),...this.helper.doubleLineOps(B[0],B[1],E[0],E[1],s))}})),o}}const We={};class da{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}}const pa=0,hn=1,Gn=2,Xt={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function fn(a,t){return a.type===t}function un(a){const t=[],e=(function(i){const r=new Array;for(;i!=="";)if(i.match(/^([ \t\r\n,]+)/))i=i.substr(RegExp.$1.length);else if(i.match(/^([aAcChHlLmMqQsStTvVzZ])/))r[r.length]={type:pa,text:RegExp.$1},i=i.substr(RegExp.$1.length);else{if(!i.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];r[r.length]={type:hn,text:`${parseFloat(RegExp.$1)}`},i=i.substr(RegExp.$1.length)}return r[r.length]={type:Gn,text:""},r})(a);let s="BOD",o=0,l=e[o];for(;!fn(l,Gn);){let i=0;const r=[];if(s==="BOD"){if(l.text!=="M"&&l.text!=="m")return un("M0,0"+a);o++,i=Xt[l.text],s=l.text}else fn(l,hn)?i=Xt[s]:(o++,i=Xt[l.text],s=l.text);if(!(o+i<e.length))throw new Error("Path data ended short");for(let c=o;c<o+i;c++){const d=e[c];if(!fn(d,hn))throw new Error("Param not a number: "+s+","+d.text);r[r.length]=+d.text}if(typeof Xt[s]!="number")throw new Error("Bad segment: "+s);{const c={key:s,data:r};t.push(c),o+=i,l=e[o],s==="M"&&(s="L"),s==="m"&&(s="l")}}return t}function Jn(a){let t=0,e=0,s=0,o=0;const l=[];for(const{key:i,data:r}of a)switch(i){case"M":l.push({key:"M",data:[...r]}),[t,e]=r,[s,o]=r;break;case"m":t+=r[0],e+=r[1],l.push({key:"M",data:[t,e]}),s=t,o=e;break;case"L":l.push({key:"L",data:[...r]}),[t,e]=r;break;case"l":t+=r[0],e+=r[1],l.push({key:"L",data:[t,e]});break;case"C":l.push({key:"C",data:[...r]}),t=r[4],e=r[5];break;case"c":{const c=r.map(((d,u)=>u%2?d+e:d+t));l.push({key:"C",data:c}),t=c[4],e=c[5];break}case"Q":l.push({key:"Q",data:[...r]}),t=r[2],e=r[3];break;case"q":{const c=r.map(((d,u)=>u%2?d+e:d+t));l.push({key:"Q",data:c}),t=c[2],e=c[3];break}case"A":l.push({key:"A",data:[...r]}),t=r[5],e=r[6];break;case"a":t+=r[5],e+=r[6],l.push({key:"A",data:[r[0],r[1],r[2],r[3],r[4],t,e]});break;case"H":l.push({key:"H",data:[...r]}),t=r[0];break;case"h":t+=r[0],l.push({key:"H",data:[t]});break;case"V":l.push({key:"V",data:[...r]}),e=r[0];break;case"v":e+=r[0],l.push({key:"V",data:[e]});break;case"S":l.push({key:"S",data:[...r]}),t=r[2],e=r[3];break;case"s":{const c=r.map(((d,u)=>u%2?d+e:d+t));l.push({key:"S",data:c}),t=c[2],e=c[3];break}case"T":l.push({key:"T",data:[...r]}),t=r[0],e=r[1];break;case"t":t+=r[0],e+=r[1],l.push({key:"T",data:[t,e]});break;case"Z":case"z":l.push({key:"Z",data:[]}),t=s,e=o}return l}function Kn(a){const t=[];let e="",s=0,o=0,l=0,i=0,r=0,c=0;for(const{key:d,data:u}of a){switch(d){case"M":t.push({key:"M",data:[...u]}),[s,o]=u,[l,i]=u;break;case"C":t.push({key:"C",data:[...u]}),s=u[4],o=u[5],r=u[2],c=u[3];break;case"L":t.push({key:"L",data:[...u]}),[s,o]=u;break;case"H":s=u[0],t.push({key:"L",data:[s,o]});break;case"V":o=u[0],t.push({key:"L",data:[s,o]});break;case"S":{let k=0,h=0;e==="C"||e==="S"?(k=s+(s-r),h=o+(o-c)):(k=s,h=o),t.push({key:"C",data:[k,h,...u]}),r=u[0],c=u[1],s=u[2],o=u[3];break}case"T":{const[k,h]=u;let m=0,f=0;e==="Q"||e==="T"?(m=s+(s-r),f=o+(o-c)):(m=s,f=o);const M=s+2*(m-s)/3,E=o+2*(f-o)/3,B=k+2*(m-k)/3,b=h+2*(f-h)/3;t.push({key:"C",data:[M,E,B,b,k,h]}),r=m,c=f,s=k,o=h;break}case"Q":{const[k,h,m,f]=u,M=s+2*(k-s)/3,E=o+2*(h-o)/3,B=m+2*(k-m)/3,b=f+2*(h-f)/3;t.push({key:"C",data:[M,E,B,b,m,f]}),r=k,c=h,s=m,o=f;break}case"A":{const k=Math.abs(u[0]),h=Math.abs(u[1]),m=u[2],f=u[3],M=u[4],E=u[5],B=u[6];k===0||h===0?(t.push({key:"C",data:[s,o,E,B,E,B]}),s=E,o=B):(s!==E||o!==B)&&(Zn(s,o,E,B,k,h,m,f,M).forEach((function(b){t.push({key:"C",data:b})})),s=E,o=B);break}case"Z":t.push({key:"Z",data:[]}),s=l,o=i}e=d}return t}function Ct(a,t,e){return[a*Math.cos(e)-t*Math.sin(e),a*Math.sin(e)+t*Math.cos(e)]}function Zn(a,t,e,s,o,l,i,r,c,d){const u=(k=i,Math.PI*k/180);var k;let h=[],m=0,f=0,M=0,E=0;if(d)[m,f,M,E]=d;else{[a,t]=Ct(a,t,-u),[e,s]=Ct(e,s,-u);const A=(a-e)/2,X=(t-s)/2;let te=A*A/(o*o)+X*X/(l*l);te>1&&(te=Math.sqrt(te),o*=te,l*=te);const de=o*o,fe=l*l,Ie=de*fe-de*X*X-fe*A*A,Me=de*X*X+fe*A*A,K=(r===c?-1:1)*Math.sqrt(Math.abs(Ie/Me));M=K*o*X/l+(a+e)/2,E=K*-l*A/o+(t+s)/2,m=Math.asin(parseFloat(((t-E)/l).toFixed(9))),f=Math.asin(parseFloat(((s-E)/l).toFixed(9))),a<M&&(m=Math.PI-m),e<M&&(f=Math.PI-f),m<0&&(m=2*Math.PI+m),f<0&&(f=2*Math.PI+f),c&&m>f&&(m-=2*Math.PI),!c&&f>m&&(f-=2*Math.PI)}let B=f-m;if(Math.abs(B)>120*Math.PI/180){const A=f,X=e,te=s;f=c&&f>m?m+120*Math.PI/180*1:m+120*Math.PI/180*-1,h=Zn(e=M+o*Math.cos(f),s=E+l*Math.sin(f),X,te,o,l,i,0,c,[f,A,M,E])}B=f-m;const b=Math.cos(m),V=Math.sin(m),O=Math.cos(f),H=Math.sin(f),Z=Math.tan(B/4),ne=4/3*o*Z,W=4/3*l*Z,J=[a,t],Q=[a+ne*V,t-W*b],oe=[e+ne*H,s-W*O],Y=[e,s];if(Q[0]=2*J[0]-Q[0],Q[1]=2*J[1]-Q[1],d)return[Q,oe,Y].concat(h);{h=[Q,oe,Y].concat(h);const A=[];for(let X=0;X<h.length;X+=3){const te=Ct(h[X][0],h[X][1],u),de=Ct(h[X+1][0],h[X+1][1],u),fe=Ct(h[X+2][0],h[X+2][1],u);A.push([te[0],te[1],de[0],de[1],fe[0],fe[1]])}return A}}const ha={randOffset:function(a,t){return ae(a,t)},randOffsetWithRange:function(a,t,e){return jt(a,t,e)},ellipse:function(a,t,e,s,o){const l=ts(e,s,o);return mn(a,t,o,l).opset},doubleLineOps:function(a,t,e,s,o){return mt(a,t,e,s,o,!0)}};function Qn(a,t,e,s,o){return{type:"path",ops:mt(a,t,e,s,o)}}function Yt(a,t,e){const s=(a||[]).length;if(s>2){const o=[];for(let l=0;l<s-1;l++)o.push(...mt(a[l][0],a[l][1],a[l+1][0],a[l+1][1],e));return t&&o.push(...mt(a[s-1][0],a[s-1][1],a[0][0],a[0][1],e)),{type:"path",ops:o}}return s===2?Qn(a[0][0],a[0][1],a[1][0],a[1][1],e):{type:"path",ops:[]}}function fa(a,t,e,s,o){return(function(l,i){return Yt(l,!0,i)})([[a,t],[a+e,t],[a+e,t+s],[a,t+s]],o)}function es(a,t){if(a.length){const e=typeof a[0][0]=="number"?[a]:a,s=Ht(e[0],1*(1+.2*t.roughness),t),o=t.disableMultiStroke?[]:Ht(e[0],1.5*(1+.22*t.roughness),os(t));for(let l=1;l<e.length;l++){const i=e[l];if(i.length){const r=Ht(i,1*(1+.2*t.roughness),t),c=t.disableMultiStroke?[]:Ht(i,1.5*(1+.22*t.roughness),os(t));for(const d of r)d.op!=="move"&&s.push(d);for(const d of c)d.op!=="move"&&o.push(d)}}return{type:"path",ops:s.concat(o)}}return{type:"path",ops:[]}}function ts(a,t,e){const s=Math.sqrt(2*Math.PI*Math.sqrt((Math.pow(a/2,2)+Math.pow(t/2,2))/2)),o=Math.ceil(Math.max(e.curveStepCount,e.curveStepCount/Math.sqrt(200)*s)),l=2*Math.PI/o;let i=Math.abs(a/2),r=Math.abs(t/2);const c=1-e.curveFitting;return i+=ae(i*c,e),r+=ae(r*c,e),{increment:l,rx:i,ry:r}}function mn(a,t,e,s){const[o,l]=is(s.increment,a,t,s.rx,s.ry,1,s.increment*jt(.1,jt(.4,1,e),e),e);let i=Wt(o,null,e);if(!e.disableMultiStroke&&e.roughness!==0){const[r]=is(s.increment,a,t,s.rx,s.ry,1.5,0,e),c=Wt(r,null,e);i=i.concat(c)}return{estimatedPoints:l,opset:{type:"path",ops:i}}}function ns(a,t,e,s,o,l,i,r,c){const d=a,u=t;let k=Math.abs(e/2),h=Math.abs(s/2);k+=ae(.01*k,c),h+=ae(.01*h,c);let m=o,f=l;for(;m<0;)m+=2*Math.PI,f+=2*Math.PI;f-m>2*Math.PI&&(m=0,f=2*Math.PI);const M=2*Math.PI/c.curveStepCount,E=Math.min(M/2,(f-m)/2),B=ls(E,d,u,k,h,m,f,1,c);if(!c.disableMultiStroke){const b=ls(E,d,u,k,h,m,f,1.5,c);B.push(...b)}return i&&(r?B.push(...mt(d,u,d+k*Math.cos(m),u+h*Math.sin(m),c),...mt(d,u,d+k*Math.cos(f),u+h*Math.sin(f),c)):B.push({op:"lineTo",data:[d,u]},{op:"lineTo",data:[d+k*Math.cos(m),u+h*Math.sin(m)]})),{type:"path",ops:B}}function ss(a,t){const e=Kn(Jn(un(a))),s=[];let o=[0,0],l=[0,0];for(const{key:i,data:r}of e)switch(i){case"M":l=[r[0],r[1]],o=[r[0],r[1]];break;case"L":s.push(...mt(l[0],l[1],r[0],r[1],t)),l=[r[0],r[1]];break;case"C":{const[c,d,u,k,h,m]=r;s.push(...ua(c,d,u,k,h,m,l,t)),l=[h,m];break}case"Z":s.push(...mt(l[0],l[1],o[0],o[1],t)),l=[o[0],o[1]]}return{type:"path",ops:s}}function gn(a,t){const e=[];for(const s of a)if(s.length){const o=t.maxRandomnessOffset||0,l=s.length;if(l>2){e.push({op:"move",data:[s[0][0]+ae(o,t),s[0][1]+ae(o,t)]});for(let i=1;i<l;i++)e.push({op:"lineTo",data:[s[i][0]+ae(o,t),s[i][1]+ae(o,t)]})}}return{type:"fillPath",ops:e}}function bt(a,t){return(function(e,s){let o=e.fillStyle||"hachure";if(!We[o])switch(o){case"zigzag":We[o]||(We[o]=new aa(s));break;case"cross-hatch":We[o]||(We[o]=new ia(s));break;case"dots":We[o]||(We[o]=new la(s));break;case"dashed":We[o]||(We[o]=new ra(s));break;case"zigzag-line":We[o]||(We[o]=new ca(s));break;default:o="hachure",We[o]||(We[o]=new pn(s))}return We[o]})(t,ha).fillPolygons(a,t)}function os(a){const t=Object.assign({},a);return t.randomizer=void 0,a.seed&&(t.seed=a.seed+1),t}function as(a){return a.randomizer||(a.randomizer=new da(a.seed||0)),a.randomizer.next()}function jt(a,t,e,s=1){return e.roughness*s*(as(e)*(t-a)+a)}function ae(a,t,e=1){return jt(-a,a,t,e)}function mt(a,t,e,s,o,l=!1){const i=l?o.disableMultiStrokeFill:o.disableMultiStroke,r=yn(a,t,e,s,o,!0,!1);if(i)return r;const c=yn(a,t,e,s,o,!0,!0);return r.concat(c)}function yn(a,t,e,s,o,l,i){const r=Math.pow(a-e,2)+Math.pow(t-s,2),c=Math.sqrt(r);let d=1;d=c<200?1:c>500?.4:-.0016668*c+1.233334;let u=o.maxRandomnessOffset||0;u*u*100>r&&(u=c/10);const k=u/2,h=.2+.2*as(o);let m=o.bowing*o.maxRandomnessOffset*(s-t)/200,f=o.bowing*o.maxRandomnessOffset*(a-e)/200;m=ae(m,o,d),f=ae(f,o,d);const M=[],E=()=>ae(k,o,d),B=()=>ae(u,o,d),b=o.preserveVertices;return i?M.push({op:"move",data:[a+(b?0:E()),t+(b?0:E())]}):M.push({op:"move",data:[a+(b?0:ae(u,o,d)),t+(b?0:ae(u,o,d))]}),i?M.push({op:"bcurveTo",data:[m+a+(e-a)*h+E(),f+t+(s-t)*h+E(),m+a+2*(e-a)*h+E(),f+t+2*(s-t)*h+E(),e+(b?0:E()),s+(b?0:E())]}):M.push({op:"bcurveTo",data:[m+a+(e-a)*h+B(),f+t+(s-t)*h+B(),m+a+2*(e-a)*h+B(),f+t+2*(s-t)*h+B(),e+(b?0:B()),s+(b?0:B())]}),M}function Ht(a,t,e){if(!a.length)return[];const s=[];s.push([a[0][0]+ae(t,e),a[0][1]+ae(t,e)]),s.push([a[0][0]+ae(t,e),a[0][1]+ae(t,e)]);for(let o=1;o<a.length;o++)s.push([a[o][0]+ae(t,e),a[o][1]+ae(t,e)]),o===a.length-1&&s.push([a[o][0]+ae(t,e),a[o][1]+ae(t,e)]);return Wt(s,null,e)}function Wt(a,t,e){const s=a.length,o=[];if(s>3){const l=[],i=1-e.curveTightness;o.push({op:"move",data:[a[1][0],a[1][1]]});for(let r=1;r+2<s;r++){const c=a[r];l[0]=[c[0],c[1]],l[1]=[c[0]+(i*a[r+1][0]-i*a[r-1][0])/6,c[1]+(i*a[r+1][1]-i*a[r-1][1])/6],l[2]=[a[r+1][0]+(i*a[r][0]-i*a[r+2][0])/6,a[r+1][1]+(i*a[r][1]-i*a[r+2][1])/6],l[3]=[a[r+1][0],a[r+1][1]],o.push({op:"bcurveTo",data:[l[1][0],l[1][1],l[2][0],l[2][1],l[3][0],l[3][1]]})}}else s===3?(o.push({op:"move",data:[a[1][0],a[1][1]]}),o.push({op:"bcurveTo",data:[a[1][0],a[1][1],a[2][0],a[2][1],a[2][0],a[2][1]]})):s===2&&o.push(...yn(a[0][0],a[0][1],a[1][0],a[1][1],e,!0,!0));return o}function is(a,t,e,s,o,l,i,r){const c=[],d=[];if(r.roughness===0){a/=4,d.push([t+s*Math.cos(-a),e+o*Math.sin(-a)]);for(let u=0;u<=2*Math.PI;u+=a){const k=[t+s*Math.cos(u),e+o*Math.sin(u)];c.push(k),d.push(k)}d.push([t+s*Math.cos(0),e+o*Math.sin(0)]),d.push([t+s*Math.cos(a),e+o*Math.sin(a)])}else{const u=ae(.5,r)-Math.PI/2;d.push([ae(l,r)+t+.9*s*Math.cos(u-a),ae(l,r)+e+.9*o*Math.sin(u-a)]);const k=2*Math.PI+u-.01;for(let h=u;h<k;h+=a){const m=[ae(l,r)+t+s*Math.cos(h),ae(l,r)+e+o*Math.sin(h)];c.push(m),d.push(m)}d.push([ae(l,r)+t+s*Math.cos(u+2*Math.PI+.5*i),ae(l,r)+e+o*Math.sin(u+2*Math.PI+.5*i)]),d.push([ae(l,r)+t+.98*s*Math.cos(u+i),ae(l,r)+e+.98*o*Math.sin(u+i)]),d.push([ae(l,r)+t+.9*s*Math.cos(u+.5*i),ae(l,r)+e+.9*o*Math.sin(u+.5*i)])}return[d,c]}function ls(a,t,e,s,o,l,i,r,c){const d=l+ae(.1,c),u=[];u.push([ae(r,c)+t+.9*s*Math.cos(d-a),ae(r,c)+e+.9*o*Math.sin(d-a)]);for(let k=d;k<=i;k+=a)u.push([ae(r,c)+t+s*Math.cos(k),ae(r,c)+e+o*Math.sin(k)]);return u.push([t+s*Math.cos(i),e+o*Math.sin(i)]),u.push([t+s*Math.cos(i),e+o*Math.sin(i)]),Wt(u,null,c)}function ua(a,t,e,s,o,l,i,r){const c=[],d=[r.maxRandomnessOffset||1,(r.maxRandomnessOffset||1)+.3];let u=[0,0];const k=r.disableMultiStroke?1:2,h=r.preserveVertices;for(let m=0;m<k;m++)m===0?c.push({op:"move",data:[i[0],i[1]]}):c.push({op:"move",data:[i[0]+(h?0:ae(d[0],r)),i[1]+(h?0:ae(d[0],r))]}),u=h?[o,l]:[o+ae(d[m],r),l+ae(d[m],r)],c.push({op:"bcurveTo",data:[a+ae(d[m],r),t+ae(d[m],r),e+ae(d[m],r),s+ae(d[m],r),u[0],u[1]]});return c}function Vt(a){return[...a]}function rs(a,t=0){const e=a.length;if(e<3)throw new Error("A curve must have at least three points.");const s=[];if(e===3)s.push(Vt(a[0]),Vt(a[1]),Vt(a[2]),Vt(a[2]));else{const o=[];o.push(a[0],a[0]);for(let r=1;r<a.length;r++)o.push(a[r]),r===a.length-1&&o.push(a[r]);const l=[],i=1-t;s.push(Vt(o[0]));for(let r=1;r+2<o.length;r++){const c=o[r];l[0]=[c[0],c[1]],l[1]=[c[0]+(i*o[r+1][0]-i*o[r-1][0])/6,c[1]+(i*o[r+1][1]-i*o[r-1][1])/6],l[2]=[o[r+1][0]+(i*o[r][0]-i*o[r+2][0])/6,o[r+1][1]+(i*o[r][1]-i*o[r+2][1])/6],l[3]=[o[r+1][0],o[r+1][1]],s.push(l[1],l[2],l[3])}}return s}function qt(a,t){return Math.pow(a[0]-t[0],2)+Math.pow(a[1]-t[1],2)}function ma(a,t,e){const s=qt(t,e);if(s===0)return qt(a,t);let o=((a[0]-t[0])*(e[0]-t[0])+(a[1]-t[1])*(e[1]-t[1]))/s;return o=Math.max(0,Math.min(1,o)),qt(a,xt(t,e,o))}function xt(a,t,e){return[a[0]+(t[0]-a[0])*e,a[1]+(t[1]-a[1])*e]}function kn(a,t,e,s){const o=s||[];if((function(r,c){const d=r[c+0],u=r[c+1],k=r[c+2],h=r[c+3];let m=3*u[0]-2*d[0]-h[0];m*=m;let f=3*u[1]-2*d[1]-h[1];f*=f;let M=3*k[0]-2*h[0]-d[0];M*=M;let E=3*k[1]-2*h[1]-d[1];return E*=E,m<M&&(m=M),f<E&&(f=E),m+f})(a,t)<e){const r=a[t+0];o.length?(l=o[o.length-1],i=r,Math.sqrt(qt(l,i))>1&&o.push(r)):o.push(r),o.push(a[t+3])}else{const c=a[t+0],d=a[t+1],u=a[t+2],k=a[t+3],h=xt(c,d,.5),m=xt(d,u,.5),f=xt(u,k,.5),M=xt(h,m,.5),E=xt(m,f,.5),B=xt(M,E,.5);kn([c,h,M,B],0,e,o),kn([B,E,f,k],0,e,o)}var l,i;return o}function ga(a,t){return Ut(a,0,a.length,t)}function Ut(a,t,e,s,o){const l=o||[],i=a[t],r=a[e-1];let c=0,d=1;for(let u=t+1;u<e-1;++u){const k=ma(a[u],i,r);k>c&&(c=k,d=u)}return Math.sqrt(c)>s?(Ut(a,t,d+1,s,l),Ut(a,d,e,s,l)):(l.length||l.push(i),l.push(r)),l}function xn(a,t=.15,e){const s=[],o=(a.length-1)/3;for(let l=0;l<o;l++)kn(a,3*l,t,s);return e&&e>0?Ut(s,0,s.length,e):s}const Je="none";class Gt{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,e,s){return{shape:t,sets:e||[],options:s||this.defaultOptions}}line(t,e,s,o,l){const i=this._o(l);return this._d("line",[Qn(t,e,s,o,i)],i)}rectangle(t,e,s,o,l){const i=this._o(l),r=[],c=fa(t,e,s,o,i);if(i.fill){const d=[[t,e],[t+s,e],[t+s,e+o],[t,e+o]];i.fillStyle==="solid"?r.push(gn([d],i)):r.push(bt([d],i))}return i.stroke!==Je&&r.push(c),this._d("rectangle",r,i)}ellipse(t,e,s,o,l){const i=this._o(l),r=[],c=ts(s,o,i),d=mn(t,e,i,c);if(i.fill)if(i.fillStyle==="solid"){const u=mn(t,e,i,c).opset;u.type="fillPath",r.push(u)}else r.push(bt([d.estimatedPoints],i));return i.stroke!==Je&&r.push(d.opset),this._d("ellipse",r,i)}circle(t,e,s,o){const l=this.ellipse(t,e,s,s,o);return l.shape="circle",l}linearPath(t,e){const s=this._o(e);return this._d("linearPath",[Yt(t,!1,s)],s)}arc(t,e,s,o,l,i,r=!1,c){const d=this._o(c),u=[],k=ns(t,e,s,o,l,i,r,!0,d);if(r&&d.fill)if(d.fillStyle==="solid"){const h=Object.assign({},d);h.disableMultiStroke=!0;const m=ns(t,e,s,o,l,i,!0,!1,h);m.type="fillPath",u.push(m)}else u.push((function(h,m,f,M,E,B,b){const V=h,O=m;let H=Math.abs(f/2),Z=Math.abs(M/2);H+=ae(.01*H,b),Z+=ae(.01*Z,b);let ne=E,W=B;for(;ne<0;)ne+=2*Math.PI,W+=2*Math.PI;W-ne>2*Math.PI&&(ne=0,W=2*Math.PI);const J=(W-ne)/b.curveStepCount,Q=[];for(let oe=ne;oe<=W;oe+=J)Q.push([V+H*Math.cos(oe),O+Z*Math.sin(oe)]);return Q.push([V+H*Math.cos(W),O+Z*Math.sin(W)]),Q.push([V,O]),bt([Q],b)})(t,e,s,o,l,i,d));return d.stroke!==Je&&u.push(k),this._d("arc",u,d)}curve(t,e){const s=this._o(e),o=[],l=es(t,s);if(s.fill&&s.fill!==Je)if(s.fillStyle==="solid"){const i=es(t,Object.assign(Object.assign({},s),{disableMultiStroke:!0,roughness:s.roughness?s.roughness+s.fillShapeRoughnessGain:0}));o.push({type:"fillPath",ops:this._mergedShape(i.ops)})}else{const i=[],r=t;if(r.length){const c=typeof r[0][0]=="number"?[r]:r;for(const d of c)d.length<3?i.push(...d):d.length===3?i.push(...xn(rs([d[0],d[0],d[1],d[2]]),10,(1+s.roughness)/2)):i.push(...xn(rs(d),10,(1+s.roughness)/2))}i.length&&o.push(bt([i],s))}return s.stroke!==Je&&o.push(l),this._d("curve",o,s)}polygon(t,e){const s=this._o(e),o=[],l=Yt(t,!0,s);return s.fill&&(s.fillStyle==="solid"?o.push(gn([t],s)):o.push(bt([t],s))),s.stroke!==Je&&o.push(l),this._d("polygon",o,s)}path(t,e){const s=this._o(e),o=[];if(!t)return this._d("path",o,s);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const l=s.fill&&s.fill!=="transparent"&&s.fill!==Je,i=s.stroke!==Je,r=!!(s.simplification&&s.simplification<1),c=(function(u,k,h){const m=Kn(Jn(un(u))),f=[];let M=[],E=[0,0],B=[];const b=()=>{B.length>=4&&M.push(...xn(B,k)),B=[]},V=()=>{b(),M.length&&(f.push(M),M=[])};for(const{key:H,data:Z}of m)switch(H){case"M":V(),E=[Z[0],Z[1]],M.push(E);break;case"L":b(),M.push([Z[0],Z[1]]);break;case"C":if(!B.length){const ne=M.length?M[M.length-1]:E;B.push([ne[0],ne[1]])}B.push([Z[0],Z[1]]),B.push([Z[2],Z[3]]),B.push([Z[4],Z[5]]);break;case"Z":b(),M.push([E[0],E[1]])}if(V(),!h)return f;const O=[];for(const H of f){const Z=ga(H,h);Z.length&&O.push(Z)}return O})(t,1,r?4-4*(s.simplification||1):(1+s.roughness)/2),d=ss(t,s);if(l)if(s.fillStyle==="solid")if(c.length===1){const u=ss(t,Object.assign(Object.assign({},s),{disableMultiStroke:!0,roughness:s.roughness?s.roughness+s.fillShapeRoughnessGain:0}));o.push({type:"fillPath",ops:this._mergedShape(u.ops)})}else o.push(gn(c,s));else o.push(bt(c,s));return i&&(r?c.forEach((u=>{o.push(Yt(u,!1,s))})):o.push(d)),this._d("path",o,s)}opsToPath(t,e){let s="";for(const o of t.ops){const l=typeof e=="number"&&e>=0?o.data.map((i=>+i.toFixed(e))):o.data;switch(o.op){case"move":s+=`M${l[0]} ${l[1]} `;break;case"bcurveTo":s+=`C${l[0]} ${l[1]}, ${l[2]} ${l[3]}, ${l[4]} ${l[5]} `;break;case"lineTo":s+=`L${l[0]} ${l[1]} `}}return s.trim()}toPaths(t){const e=t.sets||[],s=t.options||this.defaultOptions,o=[];for(const l of e){let i=null;switch(l.type){case"path":i={d:this.opsToPath(l),stroke:s.stroke,strokeWidth:s.strokeWidth,fill:Je};break;case"fillPath":i={d:this.opsToPath(l),stroke:Je,strokeWidth:0,fill:s.fill||Je};break;case"fillSketch":i=this.fillSketch(l,s)}i&&o.push(i)}return o}fillSketch(t,e){let s=e.fillWeight;return s<0&&(s=e.strokeWidth/2),{d:this.opsToPath(t),stroke:e.fill||Je,strokeWidth:s,fill:Je}}_mergedShape(t){return t.filter(((e,s)=>s===0||e.op!=="move"))}}class ya{constructor(t,e){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new Gt(e)}draw(t){const e=t.sets||[],s=t.options||this.getDefaultOptions(),o=this.ctx,l=t.options.fixedDecimalPlaceDigits;for(const i of e)switch(i.type){case"path":o.save(),o.strokeStyle=s.stroke==="none"?"transparent":s.stroke,o.lineWidth=s.strokeWidth,s.strokeLineDash&&o.setLineDash(s.strokeLineDash),s.strokeLineDashOffset&&(o.lineDashOffset=s.strokeLineDashOffset),this._drawToContext(o,i,l),o.restore();break;case"fillPath":{o.save(),o.fillStyle=s.fill||"";const r=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(o,i,l,r),o.restore();break}case"fillSketch":this.fillSketch(o,i,s)}}fillSketch(t,e,s){let o=s.fillWeight;o<0&&(o=s.strokeWidth/2),t.save(),s.fillLineDash&&t.setLineDash(s.fillLineDash),s.fillLineDashOffset&&(t.lineDashOffset=s.fillLineDashOffset),t.strokeStyle=s.fill||"",t.lineWidth=o,this._drawToContext(t,e,s.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,e,s,o="nonzero"){t.beginPath();for(const l of e.ops){const i=typeof s=="number"&&s>=0?l.data.map((r=>+r.toFixed(s))):l.data;switch(l.op){case"move":t.moveTo(i[0],i[1]);break;case"bcurveTo":t.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]);break;case"lineTo":t.lineTo(i[0],i[1])}}e.type==="fillPath"?t.fill(o):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,e,s,o,l){const i=this.gen.line(t,e,s,o,l);return this.draw(i),i}rectangle(t,e,s,o,l){const i=this.gen.rectangle(t,e,s,o,l);return this.draw(i),i}ellipse(t,e,s,o,l){const i=this.gen.ellipse(t,e,s,o,l);return this.draw(i),i}circle(t,e,s,o){const l=this.gen.circle(t,e,s,o);return this.draw(l),l}linearPath(t,e){const s=this.gen.linearPath(t,e);return this.draw(s),s}polygon(t,e){const s=this.gen.polygon(t,e);return this.draw(s),s}arc(t,e,s,o,l,i,r=!1,c){const d=this.gen.arc(t,e,s,o,l,i,r,c);return this.draw(d),d}curve(t,e){const s=this.gen.curve(t,e);return this.draw(s),s}path(t,e){const s=this.gen.path(t,e);return this.draw(s),s}}const Jt="http://www.w3.org/2000/svg";class ka{constructor(t,e){this.svg=t,this.gen=new Gt(e)}draw(t){const e=t.sets||[],s=t.options||this.getDefaultOptions(),o=this.svg.ownerDocument||window.document,l=o.createElementNS(Jt,"g"),i=t.options.fixedDecimalPlaceDigits;for(const r of e){let c=null;switch(r.type){case"path":c=o.createElementNS(Jt,"path"),c.setAttribute("d",this.opsToPath(r,i)),c.setAttribute("stroke",s.stroke),c.setAttribute("stroke-width",s.strokeWidth+""),c.setAttribute("fill","none"),s.strokeLineDash&&c.setAttribute("stroke-dasharray",s.strokeLineDash.join(" ").trim()),s.strokeLineDashOffset&&c.setAttribute("stroke-dashoffset",`${s.strokeLineDashOffset}`);break;case"fillPath":c=o.createElementNS(Jt,"path"),c.setAttribute("d",this.opsToPath(r,i)),c.setAttribute("stroke","none"),c.setAttribute("stroke-width","0"),c.setAttribute("fill",s.fill||""),t.shape!=="curve"&&t.shape!=="polygon"||c.setAttribute("fill-rule","evenodd");break;case"fillSketch":c=this.fillSketch(o,r,s)}c&&l.appendChild(c)}return l}fillSketch(t,e,s){let o=s.fillWeight;o<0&&(o=s.strokeWidth/2);const l=t.createElementNS(Jt,"path");return l.setAttribute("d",this.opsToPath(e,s.fixedDecimalPlaceDigits)),l.setAttribute("stroke",s.fill||""),l.setAttribute("stroke-width",o+""),l.setAttribute("fill","none"),s.fillLineDash&&l.setAttribute("stroke-dasharray",s.fillLineDash.join(" ").trim()),s.fillLineDashOffset&&l.setAttribute("stroke-dashoffset",`${s.fillLineDashOffset}`),l}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,e){return this.gen.opsToPath(t,e)}line(t,e,s,o,l){const i=this.gen.line(t,e,s,o,l);return this.draw(i)}rectangle(t,e,s,o,l){const i=this.gen.rectangle(t,e,s,o,l);return this.draw(i)}ellipse(t,e,s,o,l){const i=this.gen.ellipse(t,e,s,o,l);return this.draw(i)}circle(t,e,s,o){const l=this.gen.circle(t,e,s,o);return this.draw(l)}linearPath(t,e){const s=this.gen.linearPath(t,e);return this.draw(s)}polygon(t,e){const s=this.gen.polygon(t,e);return this.draw(s)}arc(t,e,s,o,l,i,r=!1,c){const d=this.gen.arc(t,e,s,o,l,i,r,c);return this.draw(d)}curve(t,e){const s=this.gen.curve(t,e);return this.draw(s)}path(t,e){const s=this.gen.path(t,e);return this.draw(s)}}var xa={canvas:(a,t)=>new ya(a,t),svg:(a,t)=>new ka(a,t),generator:a=>new Gt(a),newSeed:()=>Gt.newSeed()};const cs=new Map,wn=new Map,wa=a=>{if(wn.has(a))return wn.get(a);const t=document.createElement("canvas");t.width=40,t.height=40;const e=t.getContext("2d");if(!e)return null;const s=8,o=40,l=40;e.fillStyle="white",e.shadowColor="rgba(0, 0, 0, 0.15)",e.shadowBlur=8,e.shadowOffsetY=2,e.beginPath(),e.roundRect?e.roundRect(0,0,o,l,s):(e.moveTo(s,0),e.lineTo(o-s,0),e.quadraticCurveTo(o,0,o,s),e.lineTo(o,l-s),e.quadraticCurveTo(o,l,o-s,l),e.lineTo(s,l),e.quadraticCurveTo(0,l,0,l-s),e.lineTo(0,s),e.quadraticCurveTo(0,0,s,0)),e.fill(),e.shadowColor="transparent",e.save(),e.translate(20,20);const i=.024;e.scale(i,i),e.translate(-512,-512);const r=new Path2D("M771.09045312 471.64751562L252.89970312 471.64751562c-44.7575625 0-81.03670312 36.20432813-81.03670312 80.87625001l0 343.07339062c0 44.67290625 36.27914062 80.87625 81.03670312 80.87625l518.19173438 0c44.75854688 0 81.04753125-36.20334375 81.04753125-80.87625L852.13896875 552.52376563C852.13798437 507.85184375 815.849 471.64751562 771.09045312 471.64751562zM546.12434375 721.73979687l0 90.04964063c0 18.8409375-15.26864062 34.13123438-34.12926563 34.13123438-18.84979688 0-34.12926563-15.29029687-34.12926562-34.13123438l0-90.04964062c-20.37951562-11.804625-34.13025-33.80835938-34.13025-59.06348438 0-37.7015625 30.55795313-68.2605 68.25951562-68.2605s68.27034375 30.5589375 68.27034375 68.2605C580.26542188 687.9314375 566.52551562 709.93517188 546.12434375 721.73979687zM511.99507812 147.37175c-131.95251562 0-238.92946875 105.46889063-238.92946875 244.04034375l1e-8 105.98273437 477.87075 22.75284375L750.93635938 391.41209375C750.93635938 252.84064062 643.95940625 147.37175 511.99507812 147.37175zM341.36745312 491.406875L341.36745312 389.03876562c0-94.2204375 76.395375-170.627625 170.62664063-170.627625 94.24209375 0 170.627625 76.4071875 170.627625 170.627625l0 104.76309375L341.36745312 491.406875z");return e.fillStyle=a,e.fill(r),e.restore(),wn.set(a,t),t},Sa=(a,t,e,s,o,l,i)=>{if(i==="none")return;const r=t.width/l,c=t.height/l,d=-e,u=-s,k=d+r/o,h=u+c/o,m=20,f=Math.floor(d/m)*m,M=Math.floor(u/m)*m;if(a.save(),i==="dot"){a.fillStyle="#cccccc";const E=1.5/o;a.beginPath();for(let B=f;B<k;B+=m)for(let b=M;b<h;b+=m)a.moveTo(B+E,b),a.arc(B,b,E,0,Math.PI*2);a.fill()}else if(i==="solid"||i==="grid"||i==="line"){a.lineWidth=1/o;const B="#cccccc",b="#e0e0e0";if(a.beginPath(),o>.49){a.strokeStyle=b,a.setLineDash([4/o,4/o]);for(let V=f;V<k;V+=m)Math.abs(V%(m*5))<.1||(a.moveTo(V,u),a.lineTo(V,h));for(let V=M;V<h;V+=m)Math.abs(V%(m*5))<.1||(a.moveTo(d,V),a.lineTo(k,V));a.stroke()}a.beginPath(),a.strokeStyle=B,a.setLineDash([]);for(let V=f;V<k;V+=m)Math.abs(V%(m*5))>=.1||(a.moveTo(V,u),a.lineTo(V,h));for(let V=M;V<h;V+=m)Math.abs(V%(m*5))>=.1||(a.moveTo(d,V),a.lineTo(k,V));a.stroke()}a.restore()},ba=(a,t,e,s,o,l={},i=null,r={},c=null,d={},u="none",k=null,h="#FFFFFF")=>{const m=a.getContext("2d");if(!m)return;const f=xa.canvas(a);m.clearRect(0,0,a.width,a.height),m.fillStyle=h,m.fillRect(0,0,a.width,a.height);const M=window.devicePixelRatio||1;m.save(),m.scale(M,M),m.scale(o,o),m.translate(e,s),Sa(m,a,e,s,o,M,u);const E=[],B=[],b=[],V=[],O={};t.forEach(A=>{if(A.isDeleted)return;const X=A.frameId;X&&(O[X]||(O[X]=[]),O[X].push(A))});const H=new Set;t.forEach(A=>{if(!(A.isDeleted||H.has(A.id)))if(A.type==="frame"){V.push(A),H.add(A.id);const X=O[A.id];X&&X.forEach(te=>{H.has(te.id)||(V.push(te),H.add(te.id))})}else A.frameId||(V.push(A),H.add(A.id))}),t.forEach(A=>{!A.isDeleted&&!H.has(A.id)&&(V.push(A),H.add(A.id))}),V.forEach(A=>{if(i&&A.id===i&&A.type!=="frame"&&A.type!=="text")return;const X=A.containerId;A.type==="arrow"||A.type==="line"?b.push(A):l[A.id]||X&&l[X]?B.push(A):E.push(A)}),E.forEach(A=>{const X=(c?A.id===c:!1)||d[A.id],te=i===A.id;Sn(f,m,A,t,!1,r[A.id],"dashed",X,te,k===A.id)});const Z=b.filter(A=>l[A.id]),ne=[...B,...Z],W=ne.length,J=W===2?ne.find(A=>A.type==="text"&&A.containerId):null,Q=!!(J&&ne.find(A=>A.id===J.containerId)),oe=W>1&&ne[0]&&!!ne[0].groupIds.find(A=>ne.every(X=>X.groupIds.includes(A))),Y=W>1&&!Q?"solid":"dashed";if(B.forEach(A=>{const X=A.frameId,te=X&&l[X],de=l[A.id],fe=W===1||!oe&&(!!de||!te),Ie=(c?A.id===c:!1)||d[A.id],Me=i===A.id;Sn(f,m,A,t,fe,r[A.id],Y,Ie,Me,k===A.id)}),b.forEach(A=>{let X=!!l[A.id];(W===1&&X||W>1&&oe)&&(X=!1);const te=(c?A.id===c:!1)||d[A.id],de=i===A.id;Sn(f,m,A,t,X,r[A.id],Y,te,de,k===A.id)}),W>1&&!Q){const A=St(ne);A&&(m.save(),m.translate(A.minX,A.minY),m.strokeStyle="#6965db",m.lineWidth=1,m.setLineDash([5,5]),m.strokeRect(-4,-4,A.width+8,A.height+8),m.restore())}m.restore()},ds=(a,t)=>{if(!a||a==="transparent")return"rgba(0,0,0,0)";if(a.startsWith("rgb"))return a;let e=a.replace("#","");if(e.length===3&&(e=e.split("").map(s=>s+s).join("")),e.length>=6){const s=parseInt(e.substring(0,2),16),o=parseInt(e.substring(2,4),16),l=parseInt(e.substring(4,6),16);return`rgba(${s}, ${o}, ${l}, ${t})`}return a},Sn=(a,t,e,s,o=!1,l=!1,i="dashed",r=!1,c=!1,d=!1)=>{const u=(e.backgroundOpacity??100)/100,k=(e.strokeOpacity??100)/100,h=e.backgroundColor==="transparent"?void 0:ds(e.backgroundColor,u),f={stroke:ds(e.strokeColor,k),fill:h,fillStyle:e.fillStyle==="solid"?"solid":e.fillStyle,strokeWidth:e.strokeWidth,roughness:e.roughness,seed:e.seed,disableMultiStroke:!0,preserveVertices:!0,strokeLineJoin:"round",strokeLineCap:"round",strokeLineDash:e.strokeStyle==="dashed"?[8,8]:e.strokeStyle==="dotted"?[3,6]:void 0};t.save(),t.globalAlpha=l?.3:e.opacity/100,t.translate(e.x+e.width/2,e.y+e.height/2),t.rotate(e.angle);const M=e.isFlippedHorizontal?-1:1,E=e.isFlippedVertical?-1:1;t.scale(M,E),t.translate(-e.width/2,-e.height/2),t.lineJoin="round",t.lineCap="round";const B=()=>e.roundness/100*Math.min(e.width,e.height)*.5;switch(e.type){case"rectangle":case"process":{const Y=[[0,0],[e.width,0],[e.width,e.height],[0,e.height]];e.roundness>0?a.path(yt(Y,B()),f):a.polygon(Y,f);break}case"square":{const Y=Math.max(e.width,e.height),A=[[0,0],[Y,0],[Y,Y],[0,Y]];e.roundness>0?a.path(yt(A,B()),f):a.polygon(A,f);break}case"frame":{const Y=[[0,0],[e.width,0],[e.width,e.height],[0,e.height]];if(e.roundness>0?a.path(yt(Y,B()),f):a.polygon(Y,f),!c){t.save(),t.font="12px sans-serif",t.fillStyle="#aaa";let A=e.name||"Frame";const X=Math.max(0,e.width-10);if(t.measureText(A).width>X){let te=0,de=A.length,fe="";for(;te<=de;){const Ie=Math.floor((te+de)/2),Me=A.slice(0,Ie)+"...";t.measureText(Me).width<=X?(fe=Me,te=Ie+1):de=Ie-1}A=fe}t.fillText(A,4,-4),t.restore()}break}case"ellipse":a.ellipse(e.width/2,e.height/2,e.width,e.height,f);break;case"diamond":case"decision":{const Y=[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]];e.roundness>0?a.path(yt(Y,B()),f):a.polygon(Y,f);break}case"circle":{const Y=Math.max(e.width,e.height);a.ellipse(e.width/2,e.height/2,Y,Y,f);break}case"star":{const Y=Qe(e.width,e.height);e.roundness>0?a.path(yt(Y,B()),f):a.polygon(Y,f);break}case"cylinder":{const Y=e.width,A=e.height,X=Math.min(A*.15,20);a.ellipse(Y/2,X,Y,X*2,f),a.line(0,X,0,A-X,f),a.line(Y,X,Y,A-X,f);const te=`M 0, ${A-X} a ${Y/2},${X} 0 0, 0 ${Y}, 0`;a.path(te,f);break}case"trapezoid":{const Y=[[e.width*.2,0],[e.width*.8,0],[e.width,e.height],[0,e.height]];e.roundness>0?a.path(yt(Y,B()),f):a.polygon(Y,f);break}case"parallelogram":{const Y=[[e.width*.25,0],[e.width,0],[e.width*.75,e.height],[0,e.height]];e.roundness>0?a.path(yt(Y,B()),f):a.polygon(Y,f);break}case"freedraw":e.points.length>1&&a.linearPath(e.points,f);break;case"arrow":if(e.points&&e.points.length>1){const Y={...f,fill:void 0,fillStyle:void 0};let A=[...e.points];if(e.arrowType==="round")a.curve(A,Y);else if(e.arrowType==="elbow"){let fe,Ie;const Me=Le=>{if(!Le)return;const ee=s.find(ce=>ce.id===Le.elementId);if(!ee)return;const Xe=Le.focus<0?e.points[0]:e.points[e.points.length-1];if(!Xe)return;const et=e.x+Xe[0],Ke=e.y+Xe[1],Be=ee.x,Ae=ee.y,it=ee.width,D=ee.height,j=Math.abs(et-Be),ve=Math.abs(et-(Be+it)),Ce=Math.abs(Ke-Ae),ue=Math.abs(Ke-(Ae+D)),Ve=Math.min(j,ve,Ce,ue);if(Ve===j)return[-1,0];if(Ve===ve)return[1,0];if(Ve===Ce)return[0,-1];if(Ve===ue)return[0,1]};e.startBinding&&(fe=Me(e.startBinding)),e.endBinding&&(Ie=Me(e.endBinding));const K=Vs(A,20,fe,Ie);a.path(K,Y)}else a.linearPath(A,Y);let X=e.points;if(e.arrowType==="elbow"){let fe,Ie;const Me=K=>{if(!K)return;const Le=s.find(Ve=>Ve.id===K.elementId);if(!Le)return;const ee=K.focus<0?e.points[0]:e.points[e.points.length-1];if(!ee)return;const Xe=e.x+ee[0],et=e.y+ee[1],Ke=Le.x,Be=Le.y,Ae=Le.width,it=Le.height,D=Math.abs(Xe-Ke),j=Math.abs(Xe-(Ke+Ae)),ve=Math.abs(et-Be),Ce=Math.abs(et-(Be+it)),ue=Math.min(D,j,ve,Ce);if(ue===D)return[-1,0];if(ue===j)return[1,0];if(ue===ve)return[0,-1];if(ue===Ce)return[0,1]};e.startBinding&&(fe=Me(e.startBinding)),e.endBinding&&(Ie=Me(e.endBinding)),X=cn(e.points,fe,Ie)}const te={...e,points:X},de=Is(te);de&&a.linearPath(de,f)}break;case"line":if(e.points&&e.points.length>1){const Y={...f,fill:void 0,fillStyle:void 0};let A=[...e.points];e.arrowType==="round"?a.curve(A,Y):a.linearPath(e.points,Y)}break;case"text":let b="";e.isItalic&&(b+="italic "),e.isBold&&(b+="bold "),t.font=`${b}${e.fontSize}px ${e.fontFamily}`,t.fillStyle=e.fontColor||e.strokeColor,t.textAlign=e.textAlign||"left",t.textBaseline="top";const V=Math.round(e.fontSize*1.25),O=4,H=Math.max(0,e.width-O*2),Z=Math.max(0,e.height-O*2),ne=(e.text||"").split(`
|
|
5
|
+
`),W=[];if(ne.forEach(Y=>{if(!Y){W.push("");return}let A="";for(let X=0;X<Y.length;X++){const te=Y.charAt(X),de=A+te;t.measureText(de).width>H&&A!==""?(W.push(A),A=te):A=de}A!==""&&W.push(A)}),W.length===0)break;const J=W.length*V;let Q;e.verticalAlign==="middle"?(Q=(e.height-J)/2,Q<O&&(Q=O)):e.verticalAlign==="bottom"?(Q=e.height-O-J,Q<O&&(Q=O)):Q=O,Q+=e.fontSize*.15;let oe;if(e.textAlign==="center"?oe=e.width/2:e.textAlign==="right"?oe=e.width-O:oe=O,e.fontBgColor&&e.fontBgColor!=="transparent"){let Y=0;for(let te=0;te<W.length;te++)Y=Math.max(Y,t.measureText(W[te]||"").width);const A=J;let X=oe;e.textAlign==="center"?X=oe-Y/2:e.textAlign==="right"&&(X=oe-Y),t.fillStyle=e.fontBgColor,t.fillRect(X,Q-e.fontSize*.15,Y,A),t.fillStyle=e.fontColor||e.strokeColor}if(!c)for(let Y=0;Y<W.length;Y++){const A=Q+Y*V;if(A+V<O)continue;if(A>O+Z)break;const X=W[Y]||"";if(t.fillText(X,oe,A),e.isUnderline||e.isStrikethrough){const te=t.measureText(X).width;let de=oe;if(e.textAlign==="center"?de-=te/2:e.textAlign==="right"&&(de-=te),t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1,e.fontSize*.08),t.beginPath(),e.isUnderline){const fe=A+e.fontSize*1.05;t.moveTo(de,fe),t.lineTo(de+te,fe)}if(e.isStrikethrough){const fe=A+e.fontSize*.55;t.moveTo(de,fe),t.lineTo(de+te,fe)}t.stroke()}}break;case"image":if(e.dataURL){let Y=cs.get(e.dataURL);Y||(Y=new Image,Y.src=e.dataURL,cs.set(e.dataURL,Y)),Y.complete&&Y.naturalWidth>0&&t.drawImage(Y,0,0,e.width,e.height)}break}if(t.globalAlpha=1,o&&!e.containerId&&(t.strokeStyle=e.locked?"#d2e2ff":"#1e6fff",t.lineWidth=1,i==="dashed"&&t.setLineDash([5,5]),t.strokeRect(-4,-4,e.width+8,e.height+8),t.setLineDash([]),e.locked)){const Z=wa(d?"#1e6fff":"black");Z&&t.drawImage(Z,0,-50,40,40)}if(r){t.strokeStyle="#5d55fa",t.lineWidth=2,t.setLineDash([]),t.lineJoin="round";const b=e.width,V=e.height;switch(t.beginPath(),e.type){case"ellipse":case"circle":t.ellipse(b/2,V/2,b/2,V/2,0,0,2*Math.PI);break;case"diamond":case"decision":t.moveTo(b/2,0),t.lineTo(b,V/2),t.lineTo(b/2,V),t.lineTo(0,V/2),t.closePath();break;case"trapezoid":t.moveTo(b*.2,0),t.lineTo(b*.8,0),t.lineTo(b,V),t.lineTo(0,V),t.closePath();break;case"parallelogram":t.moveTo(b*.25,0),t.lineTo(b,0),t.lineTo(b*.75,V),t.lineTo(0,V),t.closePath();break;case"star":{const O=Qe(b,V);if(O&&O.length>0){const H=O[0];t.moveTo(H[0],H[1]);for(let Z=1;Z<O.length;Z++){const ne=O[Z];t.lineTo(ne[0],ne[1])}t.closePath()}break}case"cylinder":{const O=Math.min(V*.15,20);t.ellipse(b/2,O,b/2,O,0,0,2*Math.PI),t.moveTo(b,O),t.lineTo(b,V-O),t.ellipse(b/2,V-O,b/2,O,0,0,Math.PI,!1),t.lineTo(0,O);break}default:t.rect(0,0,b,V);break}t.stroke()}t.restore()},va=a=>{if(a.length<3)return a;let t=[...a];for(let e=0;e<2;e++){const s=[];s.push(t[0]);for(let o=0;o<t.length-1;o++){const l=t[o],i=t[o+1];s.push({x:.75*l.x+.25*i.x,y:.75*l.y+.25*i.y,time:.75*l.time+.25*i.time}),s.push({x:.25*l.x+.75*i.x,y:.25*l.y+.75*i.y,time:.25*l.time+.75*i.time})}s.push(t[t.length-1]),t=s}return t},Ea=(a,t,e,s,o)=>{const l=a.getContext("2d");if(!l||t.length===0)return;l.save();const i=window.devicePixelRatio||1;l.scale(i,i),l.scale(e,e),l.translate(s,o),l.lineCap="butt",l.lineJoin="round",l.shadowBlur=0,l.shadowBlur=5,l.shadowColor="red";const r=Date.now(),c=1600;t.forEach(d=>{if(d.length<2)return;const u=va(d);for(let k=0;k<u.length-1;k++){const h=u[k],m=u[k+1];if(!h||!m)continue;const M=1-(r-h.time)/c;if(M<=0)continue;const E=Math.max(0,Math.pow(M,1.5));if(E<=0)continue;const B=(6*M+2)/e;l.beginPath(),l.moveTo(h.x,h.y),l.lineTo(m.x,m.y),l.strokeStyle=`rgba(255, 0, 0, ${E})`,l.lineWidth=B,l.stroke()}}),l.restore()},Nt=(a,t,e,s={})=>{const o={id:dt(),x:t,y:e,width:0,height:0,angle:0,strokeColor:s.strokeColor||"#363B4C",backgroundColor:s.backgroundColor||"transparent",fillStyle:s.fillStyle||"hachure",strokeWidth:s.strokeWidth||1,strokeStyle:s.strokeStyle||"solid",roughness:s.roughness||0,roundness:s.roundness||0,opacity:s.opacity??100,strokeOpacity:s.strokeOpacity??100,backgroundOpacity:s.backgroundOpacity??100,fontSize:s.fontSize||20,fontFamily:s.fontFamily||"sans-serif",fontColor:s.fontColor||"#363B4C",fontBgColor:s.fontBgColor||"transparent",textAlign:s.textAlign||"center",verticalAlign:s.verticalAlign||"middle",isBold:s.isBold||!1,isItalic:s.isItalic||!1,isUnderline:s.isUnderline||!1,isStrikethrough:s.isStrikethrough||!1,seed:Math.floor(Math.random()*2147483648),version:1,isDeleted:!1,groupIds:[],updated:Date.now(),link:null,locked:!1,frameId:null};switch(a){case"rectangle":return{...o,type:"rectangle"};case"ellipse":return{...o,type:"ellipse"};case"diamond":return{...o,type:"diamond"};case"square":return{...o,type:"square"};case"star":return{...o,type:"star"};case"circle":return{...o,type:"circle"};case"cylinder":return{...o,type:"cylinder"};case"process":return{...o,type:"process"};case"decision":return{...o,type:"decision"};case"trapezoid":return{...o,type:"trapezoid"};case"parallelogram":return{...o,type:"parallelogram"};case"frame":return{...o,type:"frame",name:"Frame",backgroundColor:"transparent",strokeColor:"#bbb",strokeStyle:"dashed",strokeWidth:1};case"freedraw":return{...o,type:"freedraw",points:[[0,0]],pressures:[],simulatePressure:!0,lastCommittedPoint:null};case"arrow":case"line":return{...o,type:a,points:[[0,0]],lastCommittedPoint:null,startBinding:null,endBinding:null,arrowType:s.arrowType||"sharp"};case"text":return{...o,type:"text",text:"",width:10,height:30,containerId:null,originalText:"",autoResize:!0,textAlign:"left"};case"image":return{...o,type:"image",fileId:"",status:"saved",scale:[1,1],dataURL:""};default:return{...o,type:"rectangle"}}};let Re=null;const Ia={height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",whiteSpace:"pre-wrap"};function Ma(a,t=1,e=null){if(!a)return;Re||(Re=document.createElement("textarea"),(a.parentNode??document.body).appendChild(Re));const{paddingSize:s,borderSize:o,boxSizing:l,contextStyle:i,lineHeight:r}=Ca(a);i.forEach(E=>{const B=E[0],b=E[1]??"";Re&&Re.style.setProperty(B,b)}),Object.entries(Ia).forEach(([E,B])=>{Re&&Re.style.setProperty(E,B,"important")}),Re.style.width=window.getComputedStyle(a).getPropertyValue("width"),Re.value=a.value||(a.placeholder??"");const c=Re.scrollHeight;let d=NaN;!isNaN(r)&&r>0?d=r:(Re.value="x",d=Math.max(1,Re.scrollHeight-s)),Re.value=a.value||(a.placeholder??"");const u=Math.max(0,c-s);let h=Math.max(t,Math.ceil((u+0)/d));e!=null&&(h=Math.min(e,h));let m=h*d+s;l==="border-box"&&(m=m+o);let f=t*d+s;l==="border-box"&&(f=f+o);const M={height:`${Math.max(f,Math.round(m))}px`,minHeight:`${Math.round(f)}px`};return Re&&Re.parentNode&&Re.parentNode.removeChild(Re),Re=null,M}const Ba=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"];function Ca(a){const t=window.getComputedStyle(a),e=t.getPropertyValue("box-sizing"),s=Number.parseFloat(t.getPropertyValue("padding-bottom"))+Number.parseFloat(t.getPropertyValue("padding-top")),o=Number.parseFloat(t.getPropertyValue("border-bottom-width"))+Number.parseFloat(t.getPropertyValue("border-top-width")),l=Ba.map(r=>[r,t.getPropertyValue(r)]),i=parseFloat(t.getPropertyValue("line-height"));return{contextStyle:l,paddingSize:s,borderSize:o,boxSizing:e,lineHeight:i}}const Va={key:0},Na={key:1},Ta=Ye(n.defineComponent({__name:"ContextMenu",props:{visible:{type:Boolean},x:{},y:{},isElementSelected:{type:Boolean},isElementLocked:{type:Boolean},showGrid:{type:Boolean}},emits:["action","close"],setup(a,{emit:t}){const e=a,s=t,o=n.ref(null),l=n.ref(0),i=n.ref(0);n.watch(()=>[e.visible,e.x,e.y],async([c])=>{if(c&&(l.value=e.x,i.value=e.y,await n.nextTick(),o.value)){const d=o.value.getBoundingClientRect(),u=window.innerWidth,k=window.innerHeight;l.value+d.width>u&&(l.value=l.value-d.width,l.value<0&&(l.value=10)),i.value+d.height>k&&(i.value=i.value-d.height,i.value<0&&(i.value=10))}},{immediate:!0});const r=c=>{s("action",c),s("close")};return(c,d)=>a.visible?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"menuRef",ref:o,class:"context-menu",style:n.normalizeStyle({top:i.value+"px",left:l.value+"px"}),onClick:d[12]||(d[12]=n.withModifiers(()=>{},["stop"])),onContextmenu:d[13]||(d[13]=n.withModifiers(()=>{},["prevent"])),onMousedown:d[14]||(d[14]=n.withModifiers(()=>{},["stop"]))},[a.isElementSelected?(n.openBlock(),n.createElementBlock("ul",Va,[n.createElementVNode("li",{onClick:d[0]||(d[0]=u=>r("cut"))},[...d[15]||(d[15]=[n.createElementVNode("span",null,"剪切",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+X",-1)])]),n.createElementVNode("li",{onClick:d[1]||(d[1]=u=>r("copy"))},[...d[16]||(d[16]=[n.createElementVNode("span",null,"拷贝",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+C",-1)])]),d[24]||(d[24]=n.createElementVNode("div",{class:"divider"},null,-1)),n.createElementVNode("li",{onClick:d[2]||(d[2]=u=>r("sendBackward"))},[...d[17]||(d[17]=[n.createElementVNode("span",null,"下移一层",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+[",-1)])]),n.createElementVNode("li",{onClick:d[3]||(d[3]=u=>r("bringForward"))},[...d[18]||(d[18]=[n.createElementVNode("span",null,"上移一层",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+]",-1)])]),n.createElementVNode("li",{onClick:d[4]||(d[4]=u=>r("sendToBack"))},[...d[19]||(d[19]=[n.createElementVNode("span",null,"置于底层",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+Shift+[",-1)])]),n.createElementVNode("li",{onClick:d[5]||(d[5]=u=>r("bringToFront"))},[...d[20]||(d[20]=[n.createElementVNode("span",null,"置于顶层",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+Shift+]",-1)])]),d[25]||(d[25]=n.createElementVNode("div",{class:"divider"},null,-1)),n.createElementVNode("li",{onClick:d[6]||(d[6]=u=>r("duplicate"))},[...d[21]||(d[21]=[n.createElementVNode("span",null,"复制",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+D",-1)])]),n.createElementVNode("li",{onClick:d[7]||(d[7]=u=>r("toggleLock"))},[n.createElementVNode("span",null,n.toDisplayString(a.isElementLocked?"解锁":"锁定"),1),d[22]||(d[22]=n.createElementVNode("span",{class:"shortcut"},"Ctrl+Shift+L",-1))]),d[26]||(d[26]=n.createElementVNode("div",{class:"divider"},null,-1)),n.createElementVNode("li",{class:"delete",onClick:d[8]||(d[8]=u=>r("delete"))},[...d[23]||(d[23]=[n.createElementVNode("span",null,"删除",-1),n.createElementVNode("span",{class:"shortcut"},"Del",-1)])])])):(n.openBlock(),n.createElementBlock("ul",Na,[n.createElementVNode("li",{onClick:d[9]||(d[9]=u=>r("paste"))},[...d[27]||(d[27]=[n.createElementVNode("span",null,"粘贴",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+V",-1)])]),n.createElementVNode("li",{onClick:d[10]||(d[10]=u=>r("selectAll"))},[...d[28]||(d[28]=[n.createElementVNode("span",null,"全选",-1),n.createElementVNode("span",{class:"shortcut"},"Ctrl+A",-1)])]),n.createElementVNode("li",{onClick:d[11]||(d[11]=u=>r("toggleGrid"))},[n.createElementVNode("span",null,n.toDisplayString(a.showGrid?"隐藏网格":"显示网格"),1),d[29]||(d[29]=n.createElementVNode("span",{class:"shortcut"},"Ctrl+'",-1))])]))],36)):n.createCommentVNode("",!0)}}),[["__scopeId","data-v-22c72497"]]),za={class:"excalidraw-container",ref:"container"},Pa=["width","height"],ps=`url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2"><path d="M20 20H7L3 16C2 15 2 13 3 12L13 2L22 11L20 20Z" fill="white"/></svg>') 0 20, auto`,$a=Ye(n.defineComponent({__name:"ExcalidrawCanvas",props:{elements:{},zoom:{},scrollX:{},scrollY:{}},setup(a){const t=a,e=je(),s=n.ref(null),o=n.ref(null),l=n.ref(window.innerWidth),i=n.ref(window.innerHeight),r=n.ref(window.devicePixelRatio||1),c=()=>{l.value=window.innerWidth,i.value=window.innerHeight,r.value=window.devicePixelRatio||1,n.nextTick(()=>{ge()})},d=p=>{p.preventDefault();const{clientX:I,clientY:g}=p,y=s.value?.getBoundingClientRect();if(!y)return;const x=I-y.left,v=g-y.top,T=x/t.zoom-t.scrollX,S=v/t.zoom-t.scrollY,C=e.elements.slice().reverse().find(P=>{if(P.isDeleted)return!1;if(["rectangle","frame","image","text","square","process"].includes(P.type))return He(T,S,P.x,P.y,P.width,P.height,P.angle);if(["ellipse","circle"].includes(P.type))return ct(T,S,P.x,P.y,P.width,P.height,P.angle);if(P.type==="cylinder")return an(T,S,P.x,P.y,P.width,P.height,P.angle);if(["star","trapezoid","parallelogram","diamond","decision"].includes(P.type)){let G=[];return P.type==="star"?G=Qe(P.width,P.height):P.type==="trapezoid"?G=ht(P.width,P.height):P.type==="parallelogram"?G=ft(P.width,P.height):(P.type==="diamond"||P.type==="decision")&&(G=Fn(P.width,P.height)),pt(T,S,G,P.x,P.y,P.angle)}else if(P.type==="line"||P.type==="arrow"||P.type==="freedraw")return Lt(10,T,S,P,e.elements);return!1});let N=!!C;C&&!e.appState.selectedElementIds[C.id]&&e.setSelectedElementIds([C.id]);const R=Object.keys(e.appState.selectedElementIds);let L=e.elements.filter(P=>R.includes(P.id)),_=null;if(L.length===0){const P=p.currentTarget.getBoundingClientRect(),G=(I-P.left)/e.appState.zoom-e.appState.scrollX,U=(g-P.top)/e.appState.zoom-e.appState.scrollY,q=tt(G,U);q&&q.locked&&(L=[q],_=q.id)}N=L.length>0;const w=L.length>0&&L.every(P=>P.locked);Be.value={visible:!0,x:I,y:g,isElementSelected:N,isElementLocked:w,targetId:_||void 0}},u=p=>{const I=()=>{const g=Object.keys(e.appState.selectedElementIds),y=new Set;if(g.length>0)return e.elements.forEach(x=>{g.includes(x.id)&&(y.add(x.id),x.containerId&&y.add(x.containerId))}),Array.from(y);if(Be.value?.targetId){const x=Be.value.targetId,v=e.elements.find(S=>S.id===x),T=[x];return v&&v.containerId&&T.push(v.containerId),T}return[]};switch(p){case"paste":navigator.clipboard.readText().then(y=>{const x=new ClipboardEvent("paste",{clipboardData:new DataTransfer});x.clipboardData?.setData("text/plain",y),window.dispatchEvent(x)}).catch(y=>{console.error("Failed to read clipboard",y)});break;case"selectAll":e.selectAll();break;case"toggleGrid":e.toggleGrid();break;case"duplicate":e.duplicateElements(I(),y=>{e.setSelectedElementIds(y)});break;case"delete":e.elements.length>0&&(I().forEach(x=>{e.deleteElement(x)}),e.setSelectedElementIds([]));break;case"sendToBack":e.sendToBack(I());break;case"bringToFront":e.bringToFront(I());break;case"sendBackward":e.sendBackward(I());break;case"bringForward":e.bringForward(I());break;case"cut":case"copy":{const y=I();if(y.length>0){const x=e.elements.filter(T=>y.includes(T.id)),v=JSON.stringify(x);navigator.clipboard.writeText(v).then(()=>{p==="cut"&&(y.forEach(T=>e.deleteElement(T)),e.setSelectedElementIds([]))}).catch(T=>{console.error("Failed to copy to clipboard",T)})}break}case"toggleLock":const g=I();if(g.length>0){const v=!e.elements.filter(T=>g.includes(T.id)).every(T=>T.locked);g.forEach(T=>{e.updateElement(T,{locked:v})}),e.setSelectedElementIds(g)}break}},k=n.ref(!1),h=n.ref(!1),m=n.ref([]);let f=0;const M=n.ref(!1),E=n.ref(!1),B=n.ref(null),b=n.ref(null),V=n.ref(null),O=n.ref(0),H=n.ref(0),Z=n.ref(0),ne=n.ref(0),W=n.ref(null),J=n.ref(null),Q=n.ref(null),oe=n.ref(null),Y=n.ref(null),A=n.ref(null),X=n.ref(""),te=n.ref(!1),de=n.ref({}),fe=n.ref(null),Ie=n.ref(null),Me=n.ref({}),K=n.ref({x:0,y:0}),Le=n.ref({x:0,y:0}),ee=n.ref({x:0,y:0}),Xe=n.ref("26px"),et=n.computed(()=>e.appState.showGrid),Ke={top:"flex-start",middle:"center",bottom:"flex-end"},Be=n.ref({visible:!1,x:0,y:0,isElementSelected:!1,isElementLocked:!1});n.watch(()=>E.value,p=>{e.appState.isDraggingElement=p});const Ae=n.ref([]);let it=null;const D=n.ref([]),j=()=>{const p=e.appState.activeTool==="shapes"?e.appState.activeToolType:e.appState.activeTool;return p==="hand"?e.appState.viewLocked?"not-allowed":k.value?"grabbing":"grab":p==="selection"?E.value?"move":k.value?en(B.value):"default":p==="text"?"text":p==="eraser"?ps:p==="text"?"text":p==="eraser"?ps:"crosshair"},ve=n.computed(()=>{if(!J.value)return{};const p=e.elements.find(y=>y.id===J.value);if(!p)return{};if(p.type!=="text"&&p.type!=="frame")return{};let I=(p.x+t.scrollX)*t.zoom,g=(p.y+t.scrollY)*t.zoom;if(p.type==="frame"){const y=12*t.zoom,x=X.value||p.name||"Frame",v=_e(x,y,"sans-serif").width+20;return{left:`${I}px`,top:`${g-25*t.zoom}px`,width:`${v}px`,minWidth:`${50*t.zoom}px`,height:`${20*1.25*t.zoom}px`,fontSize:`${y}px`,color:"#363B4C",fontFamily:"sans-serif",overflow:"hidden",textAlign:"left",zIndex:100,background:"rgba(255,255,255,0.8)"}}if(p.type==="text"){let y=0,x=0;if(p.containerId){const T=e.elements.find(S=>S.id===p.containerId);y=T.width*t.zoom,x=T.height*t.zoom,I=T.x*t.zoom+t.scrollX*t.zoom,g=T.y*t.zoom+t.scrollY*t.zoom}else y=p.width*t.zoom,x=p.height*t.zoom;let v="none";return p.isUnderline&&p.isStrikethrough?v="underline line-through":p.isUnderline?v="underline":p.isStrikethrough&&(v="line-through"),{left:`${I}px`,top:`${g}px`,width:`${y}px`,height:`${x}px`,maxWidth:`${l.value-I}px`,maxHeight:`${i.value-g}px`,fontSize:`${(p.fontSize||20)*t.zoom}px`,fontFamily:p.fontFamily||"sans-serif",color:p.fontColor||"#363B4C",background:"transparent",fontWeight:p.isBold?"bold":"normal",fontStyle:p.isItalic?"italic":"normal",textDecoration:v,overflow:"hidden",textAlign:p.textAlign||"left",alignItems:Ke[p.verticalAlign||"middle"],justifyContent:"center",lineHeight:`${(p.fontSize||20)*1.25*t.zoom}px`,transform:`rotate(${p.angle||0}rad)`,transformOrigin:"center center"}}if(["rectangle","diamond","ellipse","arrow","square","star","circle","cylinder","process","decision","trapezoid","parallelogram"].includes(p.type)){const y=I+p.width*t.zoom/2,x=g+p.height*t.zoom/2,v=(e.appState.currentItemFontSize||20)*t.zoom,T=e.appState.currentItemStrokeColor,S=e.appState.currentItemFontFamily||"sans-serif",C=100*t.zoom,N=v*1.5;return{left:`${y-C/2}px`,top:`${x-N/2}px`,width:`${C}px`,height:`${N}px`,fontSize:`${v}px`,color:T,fontFamily:S,overflow:"hidden",textAlign:"center",justifyContent:"center",lineHeight:1.25,zIndex:100,transform:`rotate(${p.angle||0}rad)`,transformOrigin:"center center"}}return{}}),Ce=n.computed(()=>Object.keys(e.appState.selectedElementIds)),ue=n.computed(()=>{if(J.value){const p=e.elements.find(I=>I.id===J.value);if(p)return p.type==="text"&&!p.containerId}else return!1}),Ve=p=>{const I=s.value?.getBoundingClientRect();if(!I)return{x:0,y:0};const g=(p.clientX-I.left)/t.zoom-t.scrollX,y=(p.clientY-I.top)/t.zoom-t.scrollY;return{x:g,y}},ce=(p,I,g)=>{const y=(g.x-I.x)**2+(g.y-I.y)**2;if(y===0)return Math.hypot(p.x-I.x,p.y-I.y);let x=((p.x-I.x)*(g.x-I.x)+(p.y-I.y)*(g.y-I.y))/y;return x=Math.max(0,Math.min(1,x)),Math.hypot(p.x-(I.x+x*(g.x-I.x)),p.y-(I.y+x*(g.y-I.y)))},Zt=(p,I,g)=>{const y=g.x+g.width/2,x=g.y+g.height/2,[v,T]=he([p,I],[y,x],-g.angle),S=v-g.x,C=T-g.y,N=10/t.zoom,R=g.points;if(!R)return!1;for(let L=0;L<R.length-1;L++){const _={x:R[L][0],y:R[L][1]},w={x:R[L+1][0],y:R[L+1][1]};if(ce({x:S,y:C},_,w)<=N)return!0}return!1},tt=(p,I,g=null,y=!1)=>{const x=e.elements;let v=null;for(let T=x.length-1;T>=0;T--){const S=x[T];if(!S||S.isDeleted||g&&S.id===g)continue;let C=!1;const N=e.appState.selectedElementIds[S.id],R=S.backgroundColor&&S.backgroundColor!=="transparent"&&S.fillStyle!=="none"||y&&N;let L=p,_=I;if(S.isFlippedHorizontal||S.isFlippedVertical){const w=S.x+S.width/2,P=S.y+S.height/2,[G,U]=he([p,I],[w,P],-(S.angle||0)),q=S.isFlippedHorizontal?w-(G-w):G,le=S.isFlippedVertical?P-(U-P):U,xe=he([q,le],[w,P],S.angle||0);L=xe[0],_=xe[1]}if(["rectangle","frame","square","process"].includes(S.type))R?C=He(L,_,S.x,S.y,S.width,S.height,S.angle):C=Es(L,_,S.x,S.y,S.width,S.height,S.angle);else if(["ellipse","circle"].includes(S.type))R?C=ct(L,_,S.x,S.y,S.width,S.height,S.angle):C=ln(L,_,S.x,S.y,S.width,S.height,S.angle);else if(S.type==="cylinder")R?C=an(L,_,S.x,S.y,S.width,S.height,S.angle):C=vs(L,_,S.x,S.y,S.width,S.height,S.angle);else if(["diamond","decision"].includes(S.type))R?C=kt(L,_,S.x,S.y,S.width,S.height,S.angle):C=bs(L,_,S.x,S.y,S.width,S.height,S.angle);else if(["star","trapezoid","parallelogram"].includes(S.type)){let w=[];S.type==="star"?w=Qe(S.width,S.height):S.type==="trapezoid"?w=ht(S.width,S.height):S.type==="parallelogram"&&(w=ft(S.width,S.height)),R?C=pt(L,_,w,S.x,S.y,S.angle):C=Dn(L,_,w,S.x,S.y,S.angle)}else S.type==="freedraw"?C=Zt(L,_,S):S.type==="text"||S.type==="image"?C=He(L,_,S.x,S.y,S.width,S.height,S.angle):(S.type==="line"||S.type==="arrow")&&(C=Lt(10,L,_,S,e.elements));if(C)if(y){if(e.appState.selectedElementIds[S.id])return S;v||(v=S)}else return S}return v},bn=(p,I,g,y)=>{const x=g.x,v=g.x+g.width,T=g.y,S=g.y+g.height,C=Math.max(x-p,0,p-v),N=Math.max(T-I,0,I-S);return Math.sqrt(C*C+N*N)<=y},Qt=(p,I,g=null)=>{for(let x=e.elements.length-1;x>=0;x--){const v=e.elements[x];if(v&&!v.isDeleted&&!(g&&v.id===g)&&!(v.type==="line"||v.type==="arrow"||v.type==="freedraw")&&bn(p,I,v,20))return v.id}return null},en=p=>p.startsWith("point-")?"pointer":{n:"ns-resize",s:"ns-resize",w:"ew-resize",e:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",sw:"nesw-resize",se:"nwse-resize",rotation:"grab",start:"pointer",end:"pointer"}[p]||"default",Et=(p,I,g,y)=>{if(p.locked)return null;const x=(p.x+g)*I,v=(p.y+y)*I,T=p.width*I,S=p.height*I,C=p.angle||0,N=x+T/2,R=v+S/2,L=(G,U)=>he([G,U],[N,R],C),_=4,w=8,P={};if(p.type==="line"||p.type==="arrow"){if(p.points&&p.points.length>=2){const G=p.points,U=p.x+p.width/2,q=p.y+p.height/2,le=xe=>{const ye=p.x+xe[0],ze=p.y+xe[1],[Pe,$e]=he([ye,ze],[U,q],C);return[(Pe+g)*I,($e+y)*I]};return G.forEach((xe,ye)=>{const ze=le(xe);P[`point-${ye}`]=[ze[0],ze[1],w,w]}),P}return null}return P.nw=[...L(x-_,v-_),w,w],P.ne=[...L(x+T+_,v-_),w,w],P.sw=[...L(x-_,v+S+_),w,w],P.se=[...L(x+T+_,v+S+_),w,w],P.n=[...L(x+T/2,v-_),w,w],P.s=[...L(x+T/2,v+S+_),w,w],P.w=[...L(x-_,v+S/2),w,w],P.e=[...L(x+T+_,v+S/2),w,w],P.rotation=[...L(x+T/2,v-_*4),w,w],P},vn=p=>{if(Be.value.visible&&(Be.value.visible=!1),J.value)return;if(Ie.value){const v=e.elements.find(T=>T.id===Ie.value);v&&(e.updateElement(v.id,{locked:!1}),v.containerId&&e.updateElement(v.containerId,{locked:!1})),Ie.value=null,ge();return}const I=e.appState.activeTool==="shapes"?e.appState.activeToolType:e.appState.activeTool,{x:g,y}=Ve(p);if(K.value={x:g,y},Le.value={x:g,y},ee.value={x:g,y},I==="selection"){const v=Object.keys(e.appState.selectedElementIds);let T=null;if(v.length===1)T=e.elements.find(S=>S.id===v[0]&&!S.locked);else if(v.length>1){const S=e.elements.filter(N=>e.appState.selectedElementIds[N.id]&&!N.locked),C=St(S);C&&(T={id:"selection-group",type:"rectangle",x:C.x,y:C.y,width:C.width,height:C.height,angle:0})}if(T){const S=s.value.getBoundingClientRect(),C=p.clientX-S.left,N=p.clientY-S.top,R=Et(T,t.zoom,t.scrollX,t.scrollY);if(R){for(const[L,[_,w]]of Object.entries(R))if(Math.hypot(C-_,N-w)<10){if(B.value=L,k.value=!0,O.value=T.angle,b.value=JSON.parse(JSON.stringify(T)),L==="rotation"){const G=T.x+T.width/2,U=T.y+T.height/2;H.value=Math.atan2(y-U,g-G),Z.value=0,ne.value=0}if(v.length>1){const G={};e.elements.forEach(U=>{e.appState.selectedElementIds[U.id]&&(G[U.id]=JSON.parse(JSON.stringify(U)))}),V.value=G}else V.value=null;return}}}}if(I==="eraser"){h.value=!0,_t(g,y);return}if(I==="selection"){let v=null;const T=Object.keys(e.appState.selectedElementIds);if(T.length>0&&!(p.ctrlKey||p.metaKey))for(let C=e.elements.length-1;C>=0;C--){const N=e.elements[C];if(N&&e.appState.selectedElementIds[N.id]&&!N.isDeleted){let R=!1;if(["rectangle","frame","image","text","square","process"].includes(N.type))R=He(g,y,N.x,N.y,N.width,N.height,N.angle);else if(["ellipse","circle"].includes(N.type))R=ct(g,y,N.x,N.y,N.width,N.height,N.angle);else if(N.type==="cylinder")R=an(g,y,N.x,N.y,N.width,N.height,N.angle);else if(["star","trapezoid","parallelogram","diamond","decision"].includes(N.type)){let L=[];N.type==="star"?L=Qe(N.width,N.height):N.type==="trapezoid"?L=ht(N.width,N.height):N.type==="parallelogram"?L=ft(N.width,N.height):(N.type==="diamond"||N.type==="decision")&&(L=Fn(N.width,N.height)),R=pt(g,y,L,N.x,N.y,N.angle)}else N.type==="freedraw"?R=He(g,y,N.x,N.y,N.width,N.height,N.angle):(N.type==="arrow"||N.type==="line")&&(R=Lt(10,g,y,N,e.elements));if(R){v=N;break}}}if(v||(v=tt(g,y)),v&&v.type==="frame"&&!e.appState.selectedElementIds[v.id]){const C=tt(g,y,v.id);C&&(v=C)}let S=!1;if(!v&&T.length>1&&!(p.ctrlKey||p.metaKey)){const C=e.elements.filter(R=>e.appState.selectedElementIds[R.id]),N=St(C);N&&He(g,y,N.x,N.y,N.width,N.height,0)&&(S=!0)}if(v||S){if(v){let N=v.id;if(v.type==="text"&&v.containerId){const w=e.elements.find(P=>P.id===v.containerId);w&&!w.isDeleted&&(N=w.id)}const R=e.elements.find(w=>w.id===N);let L=[N];if(R&&R.groupIds.length>0){const w=R.groupIds[R.groupIds.length-1];L=e.elements.filter(P=>P.groupIds.includes(w)).map(P=>P.id)}if(p.ctrlKey||p.metaKey){const w=!!e.appState.selectedElementIds[N];L.forEach(P=>e.toggleSelection(P,!w))}else e.appState.selectedElementIds[N]||e.setSelectedElementIds(L)}let C=!0;v&&v.locked&&(C=!1),S&&e.elements.filter(R=>e.appState.selectedElementIds[R.id]).some(R=>R.locked)&&(C=!1),C&&(E.value=!0)}else M.value=!0,e.appState.isBoxSelecting=!0,p.ctrlKey||p.metaKey||e.setSelectedElementIds([]);return}if(I==="hand"){k.value=!0;return}if(k.value=!0,I==="laser"){Ae.value.push([{x:g,y,time:Date.now()}]),In();return}console.log("Canvas: creating element with arrowType:",e.appState.currentItemArrowType);const x=Nt(I,g,y,{strokeColor:e.appState.currentItemStrokeColor,backgroundColor:e.appState.currentItemBackgroundColor,fillStyle:e.appState.currentItemFillStyle,strokeWidth:e.appState.currentItemStrokeWidth,strokeStyle:e.appState.currentItemStrokeStyle,roughness:e.appState.currentItemRoughness,opacity:e.appState.currentItemOpacity,backgroundOpacity:e.appState.currentItemBackgroundOpacity,arrowType:I==="arrow"?e.appState.currentItemArrowType:"sharp"});if(I==="arrow"&&oe.value){const v=e.elements.find(T=>T.id===oe.value);if(v&&!v.isDeleted){const T=v.x+v.width/2,S=v.y+v.height/2,[C,N]=he([g,y],[T,S],-v.angle),R=(C-v.x)/v.width,L=(N-v.y)/v.height;x.startBinding={elementId:v.id,focus:0,gap:5,fixedPoint:[R,L]}}Y.value=oe.value}W.value=x.id,e.addElement(x)},En=p=>{if(J.value)return;const I=e.appState.activeTool==="shapes"?e.appState.activeToolType:e.appState.activeTool,{x:g,y}=Ve(p);if(ee.value={x:g,y},I==="laser"&&k.value){const _=Ae.value[Ae.value.length-1];_&&_.push({x:g,y,time:Date.now()});return}const x=Object.keys(e.appState.selectedElementIds);let v=!1,T=null;for(const _ of x){const w=e.elements.find(P=>P.id===_);if(w&&w.locked&&!w.isDeleted){const P=w.x+w.width/2,G=w.y+w.height/2,[U,q]=he([g,y],[P,G],-w.angle),le=w.x,xe=w.y-50,ye=40;if(U>=le&&U<=le+ye&&q>=xe&&q<=xe+ye){v=!0,T=_;break}}}if(Ie.value!==T&&(Ie.value=T,ge()),v){s.value.style.cursor="pointer";return}if(E.value&&I==="selection"){const _=Object.keys(e.appState.selectedElementIds);if(e.elements.some(P=>_.includes(P.id)&&P.type!=="frame")){let P=null;for(let G=e.elements.length-1;G>=0;G--){const U=e.elements[G];if(U&&!(U.isDeleted||U.type!=="frame"||e.appState.selectedElementIds[U.id])&&g>=U.x&&g<=U.x+U.width&&y>=U.y&&y<=U.y+U.height){P=U.id;break}}fe.value!==P&&(fe.value=P,ge())}else fe.value&&(fe.value=null,ge())}else fe.value&&(fe.value=null,ge());if((I==="line"||I==="arrow")&&k.value&&W.value){const _=Qt(g,y,W.value);_!==A.value&&(A.value=_)}if(!k.value&&I==="selection"){s.value.style.cursor="default";const _=Object.keys(e.appState.selectedElementIds);let w=null;if(_.length===1)w=e.elements.find(G=>G.id===_[0]&&!G.locked);else if(_.length>1){const G=e.elements.filter(q=>e.appState.selectedElementIds[q.id]&&!q.locked),U=St(G);U&&(w={id:"selection-group",type:"rectangle",x:U.x,y:U.y,width:U.width,height:U.height,angle:0})}if(w){const G=s.value.getBoundingClientRect(),U=p.clientX-G.left,q=p.clientY-G.top,le=Et(w,t.zoom,t.scrollX,t.scrollY);if(le){let xe=!1;for(const[ye,[ze,Pe]]of Object.entries(le))if(Math.hypot(U-ze,q-Pe)<10){s.value.style.cursor=en(ye),xe=!0;break}if(xe)return}w.id==="selection-group"&&He(g,y,w.x,w.y,w.width,w.height,0)&&(s.value.style.cursor="move")}let P=tt(g,y);if((!P||!e.appState.selectedElementIds[P.id])&&Object.keys(e.appState.selectedElementIds).length>0)for(let U=e.elements.length-1;U>=0;U--){const q=e.elements[U];if(!(!q||q.isDeleted)&&e.appState.selectedElementIds[q.id]){let le=!1;if(["rectangle","image","text","frame","freedraw","square","process"].includes(q.type)?le=He(g,y,q.x,q.y,q.width,q.height,q.angle):["diamond","decision","star","trapezoid","parallelogram"].includes(q.type)?le=kt(g,y,q.x,q.y,q.width,q.height,q.angle):["ellipse","circle","cylinder"].includes(q.type)?le=ct(g,y,q.x,q.y,q.width,q.height,q.angle):["arrow","line"].includes(q.type),le){P=q;break}}}P&&!k.value&&!P.locked?(Q.value=P.id,s.value.style.cursor="move"):Q.value=null,Q.value&&ge()}if((I==="arrow"||I==="line")&&Tt(p,g,y),k.value&&B.value==="rotation"&&b.value){const _=b.value,w=_.id,P=_.x+_.width/2,G=_.y+_.height/2,U=Math.atan2(y-G,g-P);let q=U-H.value;q>Math.PI&&(q-=2*Math.PI),q<-Math.PI&&(q+=2*Math.PI),Z.value+=q,H.value=U;let le=Z.value;if(p.shiftKey){const xe=Math.PI/12;le=Math.round(Z.value/xe)*xe}if(ne.value=le,V.value&&w==="selection-group"){const xe=le;Object.values(V.value).forEach(ye=>{const[ze,Pe]=he([ye.x+ye.width/2,ye.y+ye.height/2],[P,G],xe);e.updateElement(ye.id,{x:ze-ye.width/2,y:Pe-ye.height/2,angle:ye.angle+xe})})}else{const xe=O.value+le,ye=e.elements.find(ze=>ze.type==="text"&&ze.containerId===_.id&&!ze.isDeleted);ye&&e.updateElement(ye.id,{angle:xe}),e.updateElement(_.id,{angle:xe})}ge();return}if(k.value&&B.value&&b.value){const _=B.value,w=b.value;if((w.type==="line"||w.type==="arrow")&&_.startsWith("point-")&&!V.value){let re=g,Se=y;const Ue=w.points,zn=w.x+w.width/2,Pn=w.y+w.height/2,De=Ue.map(ie=>{const Te=w.x+ie[0],st=w.y+ie[1];return he([Te,st],[zn,Pn],w.angle)});let nt=parseInt(_.split("-")[1]||"");if(isNaN(nt)&&(nt=_==="start"?0:De.length-1),p.shiftKey&&De.length>1){const ie=_==="start"?1:De.length-2,Te=De[ie],st=De[nt],be=Math.atan2(st[1]-Te[1],st[0]-Te[0]),Fe=Math.atan2(Se-Te[1],re-Te[0]),ot=Math.hypot(re-Te[0],Se-Te[1]);let Ge=Fe;if(Te&&st){let Ze=Math.abs(Fe-be);Ze>Math.PI&&(Ze=2*Math.PI-Ze);const at=be+Math.PI>Math.PI?be-Math.PI:be+Math.PI;let gt=Math.abs(Fe-at);if(gt>Math.PI&&(gt=2*Math.PI-gt),Ze<.1||gt<.1)Ge=Ze<.1?be:at;else{const Mt=15*Math.PI/180;Ge=Math.round(Fe/Mt)*Mt}re=Te[0]+ot*Math.cos(Ge),Se=Te[1]+ot*Math.sin(Ge)}}Tt(p,re,Se);let lt=null,F=tt(re,Se,w.id);if(F&&["rectangle","diamond","ellipse","image","text","frame","square","star","circle","cylinder","process","decision","trapezoid","parallelogram"].includes(F.type)&&!F.locked){let ie=!0;F.type==="frame"&&re>F.x+10&&re<F.x+F.width-10&&Se>F.y+10&&Se<F.y+F.height-10&&(ie=!1),ie?(lt=F.id,Q.value=F.id):(F=null,lt=null,Q.value=null)}else if(oe.value){const ie=e.elements.find(Te=>Te.id===oe.value);if(ie&&!ie.isDeleted&&["rectangle","diamond","ellipse","image","text","frame"].includes(ie.type)&&!ie.locked){let Te=!0;ie.type==="frame"&&re>ie.x+10&&re<ie.x+ie.width-10&&Se>ie.y+10&&Se<ie.y+ie.height-10&&(Te=!1),Te?(lt=ie.id,F=ie,Q.value=ie.id):Q.value=null}else Q.value=null}else Q.value=null;let It=!1;if(De.length===3&&(nt===0||nt===2)){const ie=De[0],Te=De[1],st=De[2],be=(ie[0]+st[0])/2,Fe=(ie[1]+st[1])/2;Math.abs(Te[0]-be)<1&&Math.abs(Te[1]-Fe)<1&&(It=!0)}if(De[nt]=[re,Se],It){const ie=De[0],Te=De[2];De[1]=[(ie[0]+Te[0])/2,(ie[1]+Te[1])/2]}const Dt=De.map(ie=>ie[0]),hs=De.map(ie=>ie[1]),fs=Math.min(...Dt),Yi=Math.max(...Dt),us=Math.min(...hs),ji=Math.max(...hs),ms=fs,gs=us,Hi=Yi-fs,Wi=ji-us,qi=De.map(ie=>[ie[0]-ms,ie[1]-gs]),Ft={x:ms,y:gs,width:Hi,height:Wi,points:qi,angle:0};if(nt===0){let ie=lt?{elementId:lt,focus:0,gap:5}:null;if(lt&&F)if((()=>{if(["rectangle","image","text","frame","square","process"].includes(F.type))return He(re,Se,F.x+10,F.y+10,F.width-20,F.height-20,F.angle);if(["ellipse","circle","cylinder"].includes(F.type))return ct(re,Se,F.x+10,F.y+10,F.width-20,F.height-20,F.angle);if(["diamond","decision"].includes(F.type))return kt(re,Se,F.x+10,F.y+10,F.width-20,F.height-20,F.angle);if(["star","trapezoid","parallelogram"].includes(F.type)){let be=[];return F.type==="star"?be=Qe(F.width-20,F.height-20):F.type==="trapezoid"?be=ht(F.width-20,F.height-20):F.type==="parallelogram"&&(be=ft(F.width-20,F.height-20)),pt(re,Se,be,F.x+10,F.y+10,F.angle)}return!1})()){const be=F.x+F.width/2,Fe=F.y+F.height/2,[ot,Ge]=he([re,Se],[be,Fe],-F.angle),Ze=(ot-F.x)/F.width,at=(Ge-F.y)/F.height;ie.fixedPoint=[Ze,at],ie.isBorder=!1}else{const be=F.x+F.width/2,Fe=F.y+F.height/2,ot=Math.atan2(Se-Fe,re-be),Ge=Math.max(F.width,F.height)*2,Ze=[be+Math.cos(ot)*Ge,Fe+Math.sin(ot)*Ge],at=ut(F,Ze,[be,Fe]);if(at){const[gt,Mt]=he(at,[be,Fe],-F.angle),$n=(gt-F.x)/F.width,_n=(Mt-F.y)/F.height;ie.fixedPoint=[$n,_n],ie.isBorder=!0}}Ft.startBinding=ie}else w.startBinding&&(Ft.startBinding=w.startBinding);if(nt===De.length-1){let ie=lt?{elementId:lt,focus:0,gap:5}:null;if(lt&&F)if((()=>{if(["rectangle","image","text","frame","square","process"].includes(F.type))return He(re,Se,F.x+10,F.y+10,F.width-20,F.height-20,F.angle);if(["ellipse","circle","cylinder"].includes(F.type))return ct(re,Se,F.x+10,F.y+10,F.width-20,F.height-20,F.angle);if(["diamond","decision"].includes(F.type))return kt(re,Se,F.x+10,F.y+10,F.width-20,F.height-20,F.angle);if(["star","trapezoid","parallelogram"].includes(F.type)){let be=[];return F.type==="star"?be=Qe(F.width-20,F.height-20):F.type==="trapezoid"?be=ht(F.width-20,F.height-20):F.type==="parallelogram"&&(be=ft(F.width-20,F.height-20)),pt(re,Se,be,F.x+10,F.y+10,F.angle)}return!1})()){const be=F.x+F.width/2,Fe=F.y+F.height/2,[ot,Ge]=he([re,Se],[be,Fe],-F.angle),Ze=(ot-F.x)/F.width,at=(Ge-F.y)/F.height;ie.fixedPoint=[Ze,at],ie.isBorder=!1}else{const be=F.x+F.width/2,Fe=F.y+F.height/2,ot=Math.atan2(Se-Fe,re-be),Ge=Math.max(F.width,F.height)*2,Ze=[be+Math.cos(ot)*Ge,Fe+Math.sin(ot)*Ge],at=ut(F,Ze,[be,Fe]);if(at){const[gt,Mt]=he(at,[be,Fe],-F.angle),$n=(gt-F.x)/F.width,_n=(Mt-F.y)/F.height;ie.fixedPoint=[$n,_n],ie.isBorder=!0}}Ft.endBinding=ie}else w.endBinding&&(Ft.endBinding=w.endBinding);e.updateElement(w.id,Ft),(nt===0||nt===De.length-1)&&w.type==="arrow"?Tt(p,g,y):ge();return}const P=w.x+w.width/2,G=w.y+w.height/2,[U,q]=he([g,y],[P,G],-w.angle),[le,xe]=he([K.value.x,K.value.y],[P,G],-w.angle),ye=U-le,ze=q-xe;let Pe=w.x,$e=w.y,we=w.width,Ne=w.height;if(_.includes("e")&&(we+=ye),_.includes("w")&&(Pe+=ye,we-=ye),_.includes("s")&&(Ne+=ze),_.includes("n")&&($e+=ze,Ne-=ze),p.shiftKey&&(["rectangle","diamond","ellipse","star","cylinder","process","decision","trapezoid","parallelogram"].includes(w.type)||w.id==="selection-group")||["square","circle"].includes(w.type)){const re=w.width/w.height;Math.abs(we)/re>Math.abs(Ne)?Ne=(Ne<0?-1:1)*Math.abs(we/re):we=(we<0?-1:1)*Math.abs(Ne*re),_.includes("w")&&(Pe=w.x+w.width-we),_.includes("n")&&($e=w.y+w.height-Ne)}if(we<0&&(Pe+=we,we=Math.abs(we)),Ne<0&&($e+=Ne,Ne=Math.abs(Ne)),V.value&&w.id==="selection-group"){const re=we/w.width,Se=Ne/w.height;Object.values(V.value).forEach(Ue=>{const zn=Ue.x-w.x,Pn=Ue.y-w.y,De=w.x+(Pe-w.x)+zn*re,nt=w.y+($e-w.y)+Pn*Se,lt=Ue.width*re,F=Ue.height*Se,It={x:De,y:nt,width:lt,height:F};Ue.type==="text"&&(It.fontSize=(Ue.fontSize||20)*re),Ue.type==="freedraw"&&(It.points=Ue.points.map(Dt=>[Dt[0]*re,Dt[1]*Se])),e.updateElement(Ue.id,It)}),ge();return}const Oe={x:Pe,y:$e,width:we,height:Ne};if(w.type==="text")if(!w.containerId&&!w.frameId)if(_==="n"||_==="s")Oe.fontSize=Math.round((w.fontSize||20)*(Ne/w.height)),Oe.width=w.width*(Ne/w.height),Oe.height=Ne;else if(_==="e"||_==="w"){const re=_e(",",w.fontSize||20,w.fontFamily||"sans-serif",void 0,{isBold:w.isBold,isItalic:w.isItalic}).width;we<re&&(we=re,_==="w"&&(Pe=w.x+(w.width-re)));const Se=_e(w.text||"",w.fontSize||20,w.fontFamily||"sans-serif",we,{isBold:w.isBold,isItalic:w.isItalic});Oe.height=Se.height,Oe.width=we,Oe.x=Pe,Oe.autoResize=!1}else Oe.fontSize=Math.round((w.fontSize||20)*(we/w.width)),Oe.height=w.height*(we/w.width);else Oe.autoResize=!1;else if(w.type==="freedraw"){const re=w.width===0?1:we/w.width,Se=w.height===0?1:Ne/w.height;Oe.points=w.points.map(Ue=>[Ue[0]*re,Ue[1]*Se])}const wt=e.elements.find(re=>re.type==="text"&&re.containerId===w.id&&!re.isDeleted);if(wt){const re=_e(",",w.fontSize||20,w.fontFamily||"sans-serif",void 0,{isBold:w.isBold,isItalic:w.isItalic}).width;we<re&&(we=re,_.includes("w")&&(Pe=w.x+(w.width-re),Oe.x=Pe)),Oe.width=we;const Se=_e(wt.text||"",wt.fontSize||20,wt.fontFamily||"sans-serif",we,{isBold:wt.isBold,isItalic:wt.isItalic}).height;Ne<Se&&(_.includes("n")&&($e=w.y+(w.height-Se),Oe.y=$e),Ne=Se),Oe.height=Ne,e.updateElement(wt.id,{...Oe,width:we,height:Ne})}e.updateElement(w.id,{...Oe,width:Math.max(we,Oe.width),height:Math.max(Ne,Oe.height)}),ge();return}if(h.value&&I==="eraser"){m.value.push({x:g,y,timestamp:Date.now()}),m.value.length>50&&m.value.shift(),_t(g,y),ge();return}if(I==="hand"&&k.value){if(e.appState.viewLocked)return;const _=p.movementX,w=p.movementY;e.setScroll&&e.setScroll(e.appState.scrollX+_/t.zoom,e.appState.scrollY+w/t.zoom);return}if(E.value&&I==="selection"){if(Math.hypot(g-K.value.x,y-K.value.y)<5)return;const P=Object.keys(e.appState.selectedElementIds);let G=g-Le.value.x,U=y-Le.value.y;D.value=[],e.moveElements(P,G,U),P.forEach(q=>{const le=e.elements.find(xe=>xe.id===q);le&&le.type==="arrow"&&(le.startBinding&&!P.includes(le.startBinding.elementId)&&e.updateElement(le.id,{startBinding:null}),le.endBinding&&!P.includes(le.endBinding.elementId)&&e.updateElement(le.id,{endBinding:null}))}),Le.value={x:g,y};return}if(M.value&&I==="selection"){Vn(),ge();return}if((!k.value||!W.value)&&!k.value){ge();return}let S=g-K.value.x,C=y-K.value.y;const N=p.shiftKey&&["rectangle","diamond","ellipse","star","cylinder","trapezoid","parallelogram","process","decision"].includes(I),R=["square","circle"].includes(I);if(N||R){const _=Math.max(Math.abs(S),Math.abs(C));S=S<0?-_:_,C=C<0?-_:_}const L=e.elements.find(_=>_.id===W.value);if(L){if(L.type==="freedraw")W.value&&e.updateElement(W.value,{points:[...L.points,[g-L.x,y-L.y]]});else if(L.type==="line"||L.type==="arrow"){let _=S,w=C;if(p.shiftKey){const Pe=Math.hypot(_,w),$e=Math.atan2(w,_),we=Math.round($e/(15*Math.PI/180))*(15*Math.PI/180);_=Pe*Math.cos(we),w=Pe*Math.sin(we)}const P=K.value.x+_,G=K.value.y+w,U=_<0?P:K.value.x,q=w<0?G:K.value.y,le=K.value.x-U,xe=K.value.y-q,ye=P-U,ze=G-q;if(W.value){let Pe={x:U,y:q,width:Math.abs(_),height:Math.abs(w),points:[[le,xe],[ye,ze]]};e.updateElement(W.value,Pe)}}else if(W.value&&e.updateElement(W.value,{width:Math.abs(S),height:Math.abs(C),x:S<0?K.value.x+S:K.value.x,y:C<0?K.value.y+C:K.value.y}),L.type==="frame"){const _={x:L.x,y:L.y,width:L.width,height:L.height},w={};e.elements.forEach(P=>{P.id!==L.id&&!P.isDeleted&&P.type!=="frame"&&!P.frameId&&P.x>=_.x&&P.y>=_.y&&P.x+P.width<=_.x+_.width&&P.y+P.height<=_.y+_.height&&(w[P.id]=!0)}),Me.value=w}ge()}},Tt=(p,I,g)=>{const y=p.movementX,x=p.movementY,v=20;if(Math.abs(y)>0||Math.abs(x)>0){let T=null,S=1/0;const C=Math.abs(y)>Math.abs(x);if(e.elements.forEach(N=>{if(N.isDeleted||N.locked||N.type==="frame"||N.type==="line"||N.type==="arrow"||N.type==="freedraw"||N.type==="text"&&N.containerId)return;const R=N.x,L=N.y,_=N.width,w=N.height;if(C){if(g>=L-v&&g<=L+w+v){let P=1/0;if(I>=R&&I<=R+_)P=0;else{const G=Math.abs(I-R),U=Math.abs(I-(R+_));P=Math.min(G,U)}P<=v&&P<S&&(S=P,T=N)}}else if(I>=R-v&&I<=R+_+v){let P=1/0;if(g>=L&&g<=L+w)P=0;else{const G=Math.abs(g-L),U=Math.abs(g-(L+w));P=Math.min(G,U)}P<=v&&P<S&&(S=P,T=N)}}),T)oe.value=T.id;else{let N=W.value;if(!N){const L=Object.keys(e.appState.selectedElementIds);L.length===1&&(N=L[0])}const R=tt(I,g,N);if(R&&R.type!=="freedraw"&&!R.locked)oe.value=R.id;else{const L=Qt(I,g,N);oe.value=L}}ge()}},tn=()=>{if(!J.value){if(k.value&&W.value){const p=e.elements.find(I=>I.id===W.value);if(p&&p.type==="text"){J.value=p.id,X.value=p.text||"",k.value=!1,W.value=null,n.nextTick(()=>{o.value&&o.value.focus()});return}}if(W.value){const p=e.elements.find(I=>I.id===W.value);if(p&&(p.type==="arrow"||p.type==="line")){let I=null,g=tt(K.value.x,K.value.y,p.id);if(g)g.type==="frame"&&K.value.x>g.x+10&&K.value.x<g.x+g.width-10&&K.value.y>g.y+10&&K.value.y<g.y+g.height-10&&(g=null),I=g?g.id:null;else if(Y.value){const C=e.elements.find(N=>N.id===Y.value);C&&!C.isDeleted&&(C.type==="frame"&&K.value.x>C.x+10&&K.value.x<C.x+C.width-10&&K.value.y>C.y+10&&K.value.y<C.y+C.height-10||(I=C.id,g=C))}if(I&&g){let N=!1;if(["rectangle","image","text","frame","square","process"].includes(g.type))N=He(K.value.x,K.value.y,g.x+10,g.y+10,g.width-20,g.height-20,g.angle);else if(["ellipse","circle","cylinder"].includes(g.type))N=ct(K.value.x,K.value.y,g.x+10,g.y+10,g.width-20,g.height-20,g.angle);else if(["diamond","decision"].includes(g.type))N=kt(K.value.x,K.value.y,g.x+10,g.y+10,g.width-20,g.height-20,g.angle);else if(["star","trapezoid","parallelogram"].includes(g.type)){let R=[];g.type==="star"?R=Qe(g.width-20,g.height-20):g.type==="trapezoid"?R=ht(g.width-20,g.height-20):g.type==="parallelogram"&&(R=ft(g.width-20,g.height-20)),N=pt(K.value.x,K.value.y,R,g.x+10,g.y+10,g.angle)}{const R=g.x+g.width/2,L=g.y+g.height/2,[_,w]=he([K.value.x,K.value.y],[R,L],-g.angle),P=(_-g.x)/g.width,G=(w-g.y)/g.height;e.updateElement(p.id,{startBinding:{elementId:I,focus:0,gap:10,fixedPoint:[P,G],isBorder:!N}})}}let y=null,x=tt(ee.value.x,ee.value.y,p.id);if(x)x.type==="frame"&&ee.value.x>x.x+10&&ee.value.x<x.x+x.width-10&&ee.value.y>x.y+10&&ee.value.y<x.y+x.height-10&&(x=null),y=x?x.id:null;else if(oe.value){const C=e.elements.find(N=>N.id===oe.value);C&&!C.isDeleted&&(C.type==="frame"&&ee.value.x>C.x+10&&ee.value.x<C.x+C.width-10&&ee.value.y>C.y+10&&ee.value.y<C.y+C.height-10||(y=C.id,x=C))}if(y&&x){let N=!1;if(["rectangle","image","text","frame","square","process"].includes(x.type))N=He(ee.value.x,ee.value.y,x.x+10,x.y+10,x.width-20,x.height-20,x.angle);else if(["ellipse","circle","cylinder"].includes(x.type))N=ct(ee.value.x,ee.value.y,x.x+10,x.y+10,x.width-20,x.height-20,x.angle);else if(["diamond","decision"].includes(x.type))N=kt(ee.value.x,ee.value.y,x.x+10,x.y+10,x.width-20,x.height-20,x.angle);else if(["star","trapezoid","parallelogram"].includes(x.type)){let R=[];x.type==="star"?R=Qe(x.width-20,x.height-20):x.type==="trapezoid"?R=ht(x.width-20,x.height-20):x.type==="parallelogram"&&(R=ft(x.width-20,x.height-20)),N=pt(ee.value.x,ee.value.y,R,x.x+10,x.y+10,x.angle)}{const R=x.x+x.width/2,L=x.y+x.height/2,[_,w]=he([ee.value.x,ee.value.y],[R,L],-x.angle),P=(_-x.x)/x.width,G=(w-x.y)/x.height;e.updateElement(p.id,{endBinding:{elementId:y,focus:0,gap:10,fixedPoint:[P,G],isBorder:!N}})}}const v=K.value,T=ee.value;let S=null;for(const C of e.elements)if(C.type==="frame"&&!C.isDeleted){const N=v.x>=C.x&&v.x<=C.x+C.width&&v.y>=C.y&&v.y<=C.y+C.height,R=T.x>=C.x&&T.x<=C.x+C.width&&T.y>=C.y&&T.y<=C.y+C.height;N&&R&&(S=C.id)}if(S&&e.updateElement(p.id,{frameId:S}),(p.type==="line"||p.type==="arrow"&&p.arrowType!=="elbow")&&p.points.length===2){const C=p.points[0],N=p.points[1];if(C&&N){const R=(C[0]+N[0])/2,L=(C[1]+N[1])/2,w={points:[C,[R,L],N]};p.type==="line"?w.arrowType="round":p.type,e.updateElement(p.id,w)}}}else if(p&&p.type==="frame"){const I=p.id;Object.keys(Me.value).forEach(y=>{e.updateElement(y,{frameId:I})}),Me.value={}}}if(k.value||E.value){if(W.value){const p=e.elements.find(I=>I.id===W.value);if(p&&p.type==="freedraw"){const I=p.points.map(y=>y[0]),g=p.points.map(y=>y[1]);if(I.length>0&&g.length>0){const y=Math.min(...I),x=Math.min(...g),v=Math.max(...I),T=Math.max(...g);e.updateElement(p.id,{x:p.x+y,y:p.y+x,width:v-y,height:T-x,points:p.points.map(S=>[S[0]-y,S[1]-x])})}}if(["rectangle","diamond","ellipse","frame","square","star","circle","cylinder","process","decision","trapezoid","parallelogram"].includes(p.type)&&(p.width<10||p.height<10)){e.deleteElement(p.id),W.value=null,k.value=!1,ge();return}p.type!=="arrow"&&p.type!=="freedraw"&&e.setSelectedElementIds([W.value]),p.type!=="freedraw"&&!e.appState.lockedTool&&e.setTool("selection"),(W.value||Object.keys(e.appState.selectedElementIds).length>0)&&e.recordHistory()}Ce.value.forEach(p=>{const I=e.elements.find(g=>g.id===p);if(I&&I.type!="frame"){const g=fe.value;let y=!0;if(g===null&&I.frameId)if(e.appState.selectedElementIds[I.frameId])y=!1;else{const x=e.elements.find(v=>v.id===I.frameId);x&&!x.isDeleted&&I.x<x.x+x.width&&I.x+I.width>x.x&&I.y<x.y+x.height&&I.y+I.height>x.y&&(y=!1)}y&&(e.elements.filter(v=>v.containerId===I.id).forEach(v=>{e.updateElement(v.id,{frameId:g})}),e.updateElement(p,{frameId:g}))}})}h.value&&Object.keys(de.value).length>0&&(Object.keys(de.value).forEach(p=>{e.deleteElement(p)}),de.value={},e.recordHistory()),(E.value||B.value)&&e.recordHistory(),k.value=!1,h.value=!1,M.value=!1,e.appState.isBoxSelecting=!1,W.value=null,B.value=null,oe.value=null,Y.value=null,E.value=!1,fe.value=null,Me.value={},e.appState.activeTool==="laser"||ge()}},In=()=>{if(it)return;const p=()=>{const I=Date.now(),g=1e3;let y=!1;Ae.value=Ae.value.map(x=>x.filter(v=>I-v.time<g)).filter(x=>x.length>0),y=Ae.value.length>0,ge(),y||k.value&&e.appState.activeTool==="laser"?it=requestAnimationFrame(p):it=null};p()};n.ref("");const zt=n.ref(""),Pt=p=>{te.value=!0,zt.value=X.value+""},$t=p=>{const I=e.elements.find(g=>g.id===J.value);if(I&&!I.containerId&&I.type==="text"){const g=I.autoResize===!1?I.width:void 0,y=_e(zt.value+p.data,20,"sans-serif",g,{isBold:e.appState.currentItemIsBold,isItalic:e.appState.currentItemIsItalic});e.updateElement(J.value,{width:I.autoResize!==!1?y.width:I.width,height:y.height})}},Mn=p=>{te.value=!1},Bn=p=>{te.value||(X.value=p.target.value)};n.watch(()=>X.value,p=>{if(J.value){p&&o.value?Xe.value=Ma(o.value,1,null).height:Xe.value="23px";const I=e.elements.find(g=>g.id===J.value);if(I&&I.type==="text")if(I.containerId){const g=e.elements.find(y=>y.id===I.containerId);if(g){const y=Number(Xe.value.replace("px",""))+8;y>g.height?(e.updateElement(g.id,{height:y}),e.updateElement(I.id,{height:y,text:p})):e.updateElement(I.id,{text:p})}}else{const g=I.autoResize===!1?I.width:void 0,y=_e(p,I.fontSize||20,I.fontFamily||"sans-serif",g,{isBold:I.isBold,isItalic:I.isItalic}),x=_e("我",I.fontSize||20,I.fontFamily||"sans-serif",void 0,{isBold:I.isBold,isItalic:I.isItalic}).width,v=y.height,T=Math.max(y.width,x);e.updateElement(I.id,{width:I.autoResize!==!1?T:I.width,height:v,text:p})}}});const Cn=()=>{if(J.value)if(X.value.replaceAll(" ","").replaceAll(`
|
|
6
|
+
`,"").trim()){const p=e.elements.find(I=>I.id===J.value);p&&(p.type==="frame"?e.updateElement(J.value,{name:X.value}):X.value.trim()?e.updateElement(J.value,{text:X.value}):e.deleteElement(J.value),e.recordHistory()),J.value=null,e.setTool("selection"),ge()}else e.deleteElement(J.value),J.value=null,e.setTool("selection"),ge()},Vn=()=>{const p=Math.min(K.value.x,ee.value.x),I=Math.min(K.value.y,ee.value.y),g=Math.max(K.value.x,ee.value.x),y=Math.max(K.value.y,ee.value.y);let x=e.elements.filter(S=>!S.isDeleted&&!S.locked).filter(S=>{const C=ws(S);return C.minX>=p&&C.maxX<=g&&C.minY>=I&&C.maxY<=y});const v=new Set(x.map(S=>S.id)),T=new Set;x.forEach(S=>{S.groupIds&&S.groupIds.forEach(C=>T.add(C))}),T.size>0&&e.elements.forEach(S=>{S.isDeleted||S.locked||v.has(S.id)||S.groupIds&&S.groupIds.some(C=>T.has(C))&&v.add(S.id)}),e.setSelectedElementIds(Array.from(v))},_t=(p,I)=>{for(let g=t.elements.length-1;g>=0;g--){const y=t.elements[g];if(!y||y.isDeleted)continue;let x=!1;if(["rectangle","frame","square","process"].includes(y.type))x=He(p,I,y.x,y.y,y.width,y.height,y.angle);else if(["ellipse","circle","cylinder"].includes(y.type))x=ct(p,I,y.x,y.y,y.width,y.height,y.angle);else if(["diamond","decision"].includes(y.type))x=kt(p,I,y.x,y.y,y.width,y.height,y.angle);else if(["star","trapezoid","parallelogram"].includes(y.type)){let v=[];y.type==="star"?v=Qe(y.width,y.height):y.type==="trapezoid"?v=ht(y.width,y.height):y.type==="parallelogram"&&(v=ft(y.width,y.height)),x=pt(p,I,v,y.x,y.y,y.angle)||Dn(p,I,v,y.x,y.y,y.angle)}else y.type==="text"||y.type==="image"?x=p>=y.x&&p<=y.x+y.width&&I>=y.y&&I<=y.y+y.height:(y.type==="line"||y.type==="arrow"||y.type==="freedraw")&&(x=Lt(10,p,I,y));if(x){if(y.groupIds&&y.groupIds.length>0){const v=new Set(y.groupIds);t.elements.forEach(T=>{!T.isDeleted&&T.groupIds&&T.groupIds.some(S=>v.has(S))&&(de.value[T.id]=!0)})}else de.value[y.id]=!0;y.type==="frame"&&t.elements.forEach(v=>{!v.isDeleted&&v.frameId===y.id&&(de.value[v.id]=!0)}),ge()}}},nn=p=>{const I=Object.keys(e.appState.selectedElementIds);if(I.length!==1)return;const g=e.elements.find(we=>we.id===I[0]);if(!g||g.isDeleted||g.type==="line"||g.type==="arrow"||g.type==="freedraw")return;const y=150;let x=g.x,v=g.y;switch(p){case"ArrowRight":x=g.x+g.width+y;break;case"ArrowLeft":x=g.x-g.width-y;break;case"ArrowDown":v=g.y+g.height+y;break;case"ArrowUp":v=g.y-g.height-y;break}const T={...g,id:dt(),x,y:v,seed:Math.floor(Math.random()*2**31),version:1,updated:Date.now()};T.type==="text"&&(T.text=""),e.addElement(T);const S=g.x+g.width/2,C=g.y+g.height/2,N=T.x+T.width/2,R=T.y+T.height/2,L=[S,C],_=[N,R],w=ut(g,_,L,5),P=ut(T,L,_,5);let G=S,U=C,q=N,le=R;w&&(G=w[0],U=w[1]),P&&(q=P[0],le=P[1]);const xe=Math.min(G,q),ye=Math.min(U,le),ze=Math.max(G,q),Pe=Math.max(U,le),$e=Nt("arrow",xe,ye,{strokeColor:g.strokeColor||e.appState.currentItemStrokeColor,backgroundColor:g.backgroundColor||e.appState.currentItemBackgroundColor,strokeWidth:g.strokeWidth||e.appState.currentItemStrokeWidth,strokeStyle:g.strokeStyle||e.appState.currentItemStrokeStyle,roughness:g.roughness||e.appState.currentItemRoughness});$e.width=ze-xe,$e.height=Pe-ye,$e.points=[[G-xe,U-ye],[q-xe,le-ye]],$e.startBinding={elementId:g.id,focus:0,gap:5},$e.endBinding={elementId:T.id,focus:0,gap:5},$e.endArrowhead="arrow",e.addElement($e),e.appState.selectedElementIds={[T.id]:!0},ge()},z=p=>{if(J.value)return;const I=p.target;if(I&&(I.tagName==="INPUT"||I.tagName==="TEXTAREA"||I.isContentEditable))return;if(p.code==="Space"&&!J.value&&!k.value){e.appState.activeTool!=="hand"&&(e.appState.lastActiveTool=e.appState.activeTool,e.setTool("hand"));return}if(p.key==="Escape"){if(!k.value&&W.value&&e.appState.activeTool!=="selection"){p.preventDefault(),e.deleteElement(W.value),W.value=null,k.value=!1,ge();return}if(!k.value&&e.appState.activeTool!=="selection"){p.preventDefault(),e.setTool("selection");return}return}if((p.ctrlKey||p.metaKey)&&(p.key==="d"||p.key==="D")){p.preventDefault(),e.duplicateElements(Object.keys(e.appState.selectedElementIds),v=>{e.setSelectedElementIds(v),ge()});return}if(p.key==="Delete"||p.key==="Backspace"){let v=Object.keys(e.appState.selectedElementIds);e.elements.forEach(T=>{v.includes(T.containerId)&&v.push(T.id)}),v.forEach(T=>e.deleteElement(T)),e.setSelectedElementIds([])}if((p.key==="i"||p.key==="I")&&!(p.metaKey||p.ctrlKey)&&!J.value){p.preventDefault();const v=e.appState.activeTool;e.setTool("image"),Rn().then(T=>{if(T){const S=window.innerWidth/2/e.appState.zoom-e.appState.scrollX,C=window.innerHeight/2/e.appState.zoom-e.appState.scrollY;let N=S-T.width/2,R=C-T.height/2;ee.value.x!==0&&ee.value.y!==0&&(N=ee.value.x-T.width/2,R=ee.value.y-T.height/2),e.insertImage(T.dataURL,N,R,T.width,T.height)}e.setTool(v)});return}const g=p.metaKey||p.ctrlKey,y=p.shiftKey,x=p.altKey;if(g){if(J.value)return;if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(p.key)){p.preventDefault(),nn(p.key);return}(p.key==="a"||p.key==="A")&&(p.preventDefault(),e.selectAll(),ge()),(p.key==="c"||p.key==="C")&&(p.preventDefault(),e.copyElements()),(p.key==="v"||p.key==="V")&&e.pasteElements(ee.value),(p.key==="x"||p.key==="X")&&(p.preventDefault(),e.cutElements()),(p.key==="z"||p.key==="Z")&&(p.preventDefault(),y?e.redo():e.undo()),(p.key==="g"||p.key==="G")&&(p.preventDefault(),y?e.ungroupElements(Object.keys(e.appState.selectedElementIds)):e.groupElements(Object.keys(e.appState.selectedElementIds)),ge()),p.key==="'"&&(p.preventDefault(),e.toggleGrid()),(p.key==="="||p.key==="+")&&(p.preventDefault(),e.zoomIn()),p.key==="-"&&(p.preventDefault(),e.zoomOut()),p.key==="0"&&(p.preventDefault(),e.setZoom(1))}else{if(J.value)return;if(p.key==="["){e.sendToBack(Object.keys(e.appState.selectedElementIds));return}if(p.key==="]"){e.bringToFront(Object.keys(e.appState.selectedElementIds));return}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(p.key)){const v=y?10:1;let T=0,S=0;p.key==="ArrowUp"&&(S=-v),p.key==="ArrowDown"&&(S=v),p.key==="ArrowLeft"&&(T=-v),p.key==="ArrowRight"&&(T=v);const C=Object.keys(e.appState.selectedElementIds);if(C.length>0){p.preventDefault(),p.repeat||e.recordHistory(),e.moveElements(C,T,S),ge();return}}if((p.key==="h"||p.key==="H")&&e.setTool("hand"),(p.key==="v"||p.key==="V"||p.key==="1")&&e.setTool("selection"),(p.key==="r"||p.key==="R"||p.key==="2")&&e.setTool("shapes"),(p.key==="a"||p.key==="A"||p.key==="5")&&e.setTool("arrow"),(p.key==="l"||p.key==="L"||p.key==="6")&&e.setTool("line"),(p.key==="p"||p.key==="P"||p.key==="7")&&e.setTool("freedraw"),(p.key==="t"||p.key==="T"||p.key==="8")&&e.setTool("text"),(p.key==="f"||p.key==="F"||p.key==="9")&&e.setTool("frame"),(p.key==="k"||p.key==="K")&&e.setTool("laser"),(p.key==="e"||p.key==="E"||p.key==="0")&&e.setTool("eraser"),p.key==="Enter"){const v=Object.keys(e.appState.selectedElementIds);if(v.length===1){const T=e.elements.find(S=>S.id===v[0]);p.preventDefault(),ke(T)}}}if(p.key==="]"){const v=Object.keys(e.appState.selectedElementIds);v.length>0&&(x?e.bringForward(v):e.bringToFront(v))}if(p.key==="["){const v=Object.keys(e.appState.selectedElementIds);v.length>0&&(x?e.sendBackward(v):e.sendToBack(v))}},$=p=>{if(p.preventDefault(),e.appState.viewLocked)return;if(p.ctrlKey||p.metaKey){const y=Math.sign(p.deltaY);let v=e.appState.zoom-y*.05;v=Math.round(v*100)/100,v=Math.min(Math.max(.1,v),5);const T=s.value?.getBoundingClientRect();if(T){const S=p.clientX-T.left,C=p.clientY-T.top,N=S/t.zoom-t.scrollX,R=C/t.zoom-t.scrollY,L=S/v-t.scrollX,_=C/v-t.scrollY,w=L-N,P=_-R;e.setZoom(v),e.setScroll&&e.setScroll(t.scrollX+w,t.scrollY+P)}else e.setZoom(v);return}const I=p.deltaX,g=p.deltaY;e.setScroll&&e.setScroll(e.appState.scrollX-I/t.zoom,e.appState.scrollY-g/t.zoom)},pe=p=>{if(e.appState.viewLocked)return;const{x:I,y:g}=Ve(p),y=tt(I,g,null,!0);if(y&&!y.locked&&e.appState.selectedElementIds[y.id]){ke(y);return}if(y&&!y.locked)return;if((e.appState.activeTool==="shapes"?e.appState.activeToolType:e.appState.activeTool)==="selection"){const v=Nt("text",I,g,{strokeColor:e.appState.currentItemStrokeColor,backgroundColor:e.appState.currentItemBackgroundColor,fillStyle:e.appState.currentItemFillStyle,strokeWidth:e.appState.currentItemStrokeWidth,strokeStyle:e.appState.currentItemStrokeStyle,roughness:e.appState.currentItemRoughness,opacity:e.appState.currentItemOpacity,arrowType:e.appState.currentItemArrowType});e.addElement(v),n.nextTick(()=>{J.value=v.id,X.value=v.text||"",k.value=!1,W.value=null,n.nextTick(()=>{o.value&&o.value.focus()})})}},ke=p=>{if(p.type==="text"||p.type==="frame")se(p);else if(["rectangle","diamond","ellipse","square","star","circle","cylinder","process","decision","trapezoid","parallelogram"].includes(p.type)){const I=e.elements.find(g=>g.type==="text"&&g.containerId===p.id&&!g.isDeleted);if(I)se(I);else{const g=p.x,y=p.y;e.setTool("text");const x=Nt("text",g,y,{strokeColor:p.strokeColor||e.appState.currentItemStrokeColor});x.containerId=p.id,x.fontColor=p.fontColor||"#363B4C",x.fontBgColor=p.fontBgColor||"transparent",x.textAlign=p.textAlign||"center",x.verticalAlign=p.verticalAlign||"middle",x.angle=p.angle||0,x.isBold=p.isBold||!1,x.isItalic=p.isItalic||!1,x.isUnderline=p.isUnderline||!1,x.isStrikethrough=p.isStrikethrough||!1,x.x=g,x.y=y,x.width=p.width,x.height=p.height,e.addElement(x),se(x)}}},se=p=>{J.value=p.id,p.type==="frame"?X.value=p.name||"Frame":(X.value=p.text||"",p.type=="text"&&p.containerId&&(Xe.value=_e(p.text,p.fontSize||20,p.fontFamily||"sans-serif",p.width,{isBold:p.isBold,isItalic:p.isItalic}).height+"px")),e.setTool("selection"),n.nextTick(()=>{o.value&&(o.value.focus(),o.value.selectionStart=o.value.value.length,o.value.selectionEnd=o.value.value.length)})};n.onMounted(()=>{if(window.addEventListener("resize",c),document.addEventListener("paste",me),window.addEventListener("keydown",z),window.addEventListener("keyup",Ee),s.value?.addEventListener("wheel",$,{passive:!1}),e.elements.length===0){const p=Nt("rectangle",window.innerWidth/2-100,window.innerHeight/2-50,{});p.width=200,p.height=100,p.fillStyle="solid",p.strokeWidth=2,p.roughness=0,e.addElement(p)}ge()});const me=async p=>{await Nn(p)},Nn=async p=>{if(!J.value){p.preventDefault(),p.stopPropagation();try{const I=p.clipboardData||window.clipboardData;if(!I||!I.items)return;const g=I.items;console.log("剪贴板项目:",Array.from(g).map(y=>y.type));for(let y=0;y<g.length;y++){const x=g[y];if(x.type.startsWith("image/")){const v=x.getAsFile();if(v){await sn(v);return}}}}catch(I){console.error("粘贴处理错误:",I)}}},sn=p=>new Promise((I,g)=>{const y=new FileReader;y.onload=x=>{const v=x.target?.result;if(v){const T=new Image;T.onload=()=>{let S=T.naturalWidth||T.width,C=T.naturalHeight||T.height;const N=500;if(S>N||C>N){const _=S/C;S>C?(S=N,C=N/_):(C=N,S=N*_)}const R=S,L=C;e.insertImage&&e.insertImage(v,ee.value.x-R/2,ee.value.y-L/2,R,L)},T.src=v}},y.onerror=()=>{g(new Error("文件读取失败"))},y.readAsDataURL(p)});n.onUnmounted(()=>{document.removeEventListener("paste",me),window.removeEventListener("resize",c),window.removeEventListener("keydown",z),window.removeEventListener("keyup",Ee),s.value?.removeEventListener("wheel",$),window.removeEventListener("mousedown",Tn)});const Tn=p=>{Be.value.visible&&(Be.value.visible=!1)},Ee=p=>{p.code==="Space"&&e.appState.activeTool==="hand"&&e.appState.lastActiveTool&&(e.setTool(e.appState.lastActiveTool),e.appState.lastActiveTool=null)};let qe=null;const ge=()=>{if(s.value){if(ba(s.value,t.elements,t.scrollX,t.scrollY,t.zoom,e.appState.selectedElementIds,J.value,de.value,fe.value,Me.value,e.appState.showGrid?e.appState.gridType:"none",Ie.value,e.appState.viewBackgroundColor),Ae.value.length>0&&Ea(s.value,Ae.value,e.appState.zoom,e.appState.scrollX,e.appState.scrollY),m.value.length>0){const I=Date.now();m.value=m.value.filter(y=>I-y.timestamp<450);const g=s.value.getContext("2d");if(g&&m.value.length>1){qe||(qe=document.createElement("canvas")),(qe.width!==s.value.width||qe.height!==s.value.height)&&(qe.width=s.value.width,qe.height=s.value.height);const y=qe.getContext("2d");if(y){y.clearRect(0,0,qe.width,qe.height),y.save();const x=window.devicePixelRatio||1;y.setTransform(x,0,0,x,0,0),y.lineCap="round",y.lineJoin="round";const T=(S=>{if(S.length<3)return S;let C=[...S];for(let N=0;N<2;N++){const R=[];R.push(C[0]);for(let L=0;L<C.length-1;L++){const _=C[L],w=C[L+1];R.push({x:.75*_.x+.25*w.x,y:.75*_.y+.25*w.y,timestamp:.75*_.timestamp+.25*w.timestamp}),R.push({x:.25*_.x+.75*w.x,y:.25*_.y+.75*w.y,timestamp:.25*_.timestamp+.75*w.timestamp})}R.push(C[C.length-1]),C=R}return C})(m.value);for(let S=0;S<T.length-1;S++){const C=T[S],N=T[S+1];if(!C||!N)continue;const R=I-C.timestamp,L=Math.max(0,1-R/450);if(L<=0)continue;y.beginPath();const _=(C.x+t.scrollX)*t.zoom,w=(C.y+t.scrollY)*t.zoom,P=(N.x+t.scrollX)*t.zoom,G=(N.y+t.scrollY)*t.zoom;y.moveTo(_,w),y.lineTo(P,G),y.strokeStyle="rgb(204, 204, 204)";const U=Math.pow(L,.8);y.lineWidth=16*t.zoom*U,y.stroke()}y.restore(),g.save(),g.setTransform(1,0,0,1,0,0),g.globalAlpha=.6,g.drawImage(qe,0,0),g.restore()}}m.value.length>0&&(cancelAnimationFrame(f),f=requestAnimationFrame(ge))}if(M.value){const I=s.value.getContext("2d");if(I){I.save();const g=window.devicePixelRatio||1;I.setTransform(g,0,0,g,0,0),I.strokeStyle="rgba(204, 204, 204, 0.4)",I.fillStyle="rgba(204, 204, 204, 0.1)",I.lineWidth=1;const y=Math.min(K.value.x+t.scrollX,ee.value.x+t.scrollX)*t.zoom,x=Math.min(K.value.y+t.scrollY,ee.value.y+t.scrollY)*t.zoom,v=Math.abs(K.value.x-ee.value.x)*t.zoom,T=Math.abs(K.value.y-ee.value.y)*t.zoom;I.strokeRect(y,x,v,T),I.fillRect(y,x,v,T),I.restore()}}if(D.value.length>0){const I=s.value.getContext("2d");if(I){I.save();const g=window.devicePixelRatio||1;I.setTransform(g,0,0,g,0,0),I.strokeStyle="#ff00ff",I.lineWidth=1,I.setLineDash([5,5]),D.value.forEach(y=>{if(I.beginPath(),y.type==="vertical"&&y.x!==void 0){const x=(y.x+t.scrollX)*t.zoom,v=(y.start+t.scrollY)*t.zoom,T=(y.end+t.scrollY)*t.zoom;I.moveTo(x,v),I.lineTo(x,T)}else if(y.type==="horizontal"&&y.y!==void 0){const x=(y.y+t.scrollY)*t.zoom,v=(y.start+t.scrollX)*t.zoom,T=(y.end+t.scrollX)*t.zoom;I.moveTo(v,x),I.lineTo(T,x)}I.stroke()}),I.restore()}}const p=Object.keys(e.appState.selectedElementIds);if(p.length===1){const I=e.elements.find(g=>g.id===p[0]);if(I&&!J.value&&!I.locked){const g=Et(I,t.zoom,t.scrollX,t.scrollY),y=s.value.getContext("2d");if(g&&y){y.save();const x=window.devicePixelRatio||1;y.setTransform(x,0,0,x,0,0),y.fillStyle="#ffffff",y.strokeStyle="#6965db",y.lineWidth=1;for(const[v,T]of Object.entries(g)){const[S,C,N]=T,R=N;y.beginPath(),v==="rotation"||v.startsWith("point-")?y.arc(S,C,R/2,0,Math.PI*2):y.roundRect?y.roundRect(S-R/2,C-R/2,R,R,2):y.rect(S-R/2,C-R/2,R,R),y.fill(),y.stroke()}if(B.value==="rotation"&&g.rotation){const[v,T,S]=g.rotation,C=Math.round(ne.value*180/Math.PI),N=`${C>0?"+":""}${C}°`,R=8,L=22;y.font="12px sans-serif";const w=y.measureText(N).width+R*2,P=v,U=T-S/2-4-L/2;y.save(),y.fillStyle="#363B4C";const q=P-w/2,le=U-L/2;y.roundRect?(y.beginPath(),y.roundRect(q,le,w,L,4),y.fill()):y.fillRect(q,le,w,L),y.textAlign="center",y.textBaseline="middle",y.fillStyle="#ffffff",y.fillText(N,P,U),y.restore()}y.restore()}}}else if(p.length>1){const I=e.elements.filter(y=>e.appState.selectedElementIds[y.id]&&!y.locked),g=St(I);if(g){const y={type:"rectangle",x:g.x,y:g.y,width:g.width,height:g.height,angle:0,locked:!1},x=Et(y,t.zoom,t.scrollX,t.scrollY),v=s.value.getContext("2d");if(v&&x){v.save();const T=window.devicePixelRatio||1;if(v.setTransform(T,0,0,T,0,0),B.value==="rotation"&&x.rotation){const[_,w,P]=x.rotation,G=Math.round(ne.value*180/Math.PI),U=`${G>0?"+":""}${G}°`,q=8,le=22;v.font="12px sans-serif";const ye=v.measureText(U).width+q*2,ze=_,$e=w-P/2-2-le/2;v.save(),v.fillStyle="#363B4C";const we=ze-ye/2,Ne=$e-le/2;v.roundRect?(v.beginPath(),v.roundRect(we,Ne,ye,le,4),v.fill()):v.fillRect(we,Ne,ye,le),v.textAlign="center",v.textBaseline="middle",v.fillStyle="#ffffff",v.fillText(U,ze,$e),v.restore()}const S=(y.x+t.scrollX)*t.zoom,C=(y.y+t.scrollY)*t.zoom,N=y.width*t.zoom,R=y.height*t.zoom;v.strokeStyle="#6965db",v.lineWidth=1,v.setLineDash([5,5]);const L=4;if(v.strokeRect(S-L,C-L,N+L*2,R+L*2),v.setLineDash([]),x){v.fillStyle="#ffffff",v.strokeStyle="#6965db",v.lineWidth=1;for(const[_,w]of Object.entries(x)){const[P,G,U]=w,q=U;v.beginPath(),_==="rotation"?v.arc(P,G,q/2,0,Math.PI*2):v.roundRect?v.roundRect(P-q/2,G-q/2,q,q,2):v.rect(P-q/2,G-q/2,q,q),v.fill(),v.stroke()}}v.restore()}}}if(oe.value){const I=oe.value,g=e.elements.find(x=>x.id===I);let y=!0;if(g&&g.type==="frame"&&(ee.value.x,ee.value.x>g.x+10&&ee.value.x<g.x+g.width-10&&ee.value.y>g.y+10&&ee.value.y<g.y+g.height-10&&(y=!1)),g&&y&&g.type!=="arrow"&&g.type!=="line"&&!g.locked){const x=s.value.getContext("2d");if(x){x.save();const v=window.devicePixelRatio||1;x.setTransform(v,0,0,v,0,0);const T=(g.x+t.scrollX)*t.zoom,S=(g.y+t.scrollY)*t.zoom,C=g.width*t.zoom,N=g.height*t.zoom,R=g.angle,L=T+C/2,_=S+N/2;x.translate(L,_),x.rotate(R),x.translate(-L,-_),x.strokeStyle="#1e6fff",x.lineWidth=3;const w=0;if(["ellipse","circle"].includes(g.type))x.beginPath(),x.ellipse(T+C/2,S+N/2,C/2+w,N/2+w,0,0,2*Math.PI),x.stroke();else if(g.type==="cylinder"){x.beginPath();const P=Math.min(N*.15,20);x.ellipse(T+C/2,S+P-w,C/2+w,P+w,0,0,2*Math.PI),x.moveTo(T+C+w,S+P-w),x.lineTo(T+C+w,S+N-P+w),x.ellipse(T+C/2,S+N-P+w,C/2+w,P+w,0,0,Math.PI,!1),x.lineTo(T-w,S+P-w),x.stroke()}else if(["diamond","decision"].includes(g.type)){x.beginPath();const P=T+C/2,G=S+N/2;x.moveTo(P,S-w),x.lineTo(T+C+w,G),x.lineTo(P,S+N+w),x.lineTo(T-w,G),x.closePath(),x.stroke()}else if(g.type==="trapezoid")x.beginPath(),x.moveTo(T+C*.2-w,S-w),x.lineTo(T+C*.8+w,S-w),x.lineTo(T+C+w,S+N+w),x.lineTo(T-w,S+N+w),x.closePath(),x.stroke();else if(g.type==="parallelogram")x.beginPath(),x.moveTo(T+C*.25-w,S-w),x.lineTo(T+C+w,S-w),x.lineTo(T+C*.75+w,S+N+w),x.lineTo(T-w,S+N+w),x.closePath(),x.stroke();else if(g.type==="star"){x.beginPath();const P=Qe(C,N);if(P&&P.length>0){const G=P[0];x.moveTo(T+G[0],S+G[1]);for(let U=1;U<P.length;U++){const q=P[U];x.lineTo(T+q[0],S+q[1])}x.closePath(),x.stroke()}}else x.strokeRect(T-w,S-w,C+w*2,N+w*2);x.restore()}}}}};function At(){o.value&&o.value.focus()}return n.watch([()=>t.elements,()=>t.zoom,()=>t.scrollX,()=>t.scrollY,l,i,J,()=>e.appState.viewBackgroundColor,()=>e.appState.gridType,()=>e.appState.showGrid],ge,{deep:!0}),n.onMounted(()=>{e.loadFromLocalStorage(),e.$subscribe(()=>{e.saveToLocalStorage()},{detached:!0})}),n.watch(()=>e.elements,()=>{}),(p,I)=>(n.openBlock(),n.createElementBlock("div",za,[n.createElementVNode("canvas",{id:"canvas-container",ref_key:"canvas",ref:s,width:l.value*r.value,height:i.value*r.value,style:n.normalizeStyle({width:l.value+"px",height:i.value+"px",cursor:j()}),onPointerdown:vn,onPointermove:En,onPointerup:tn,onDblclick:pe,onContextmenu:n.withModifiers(d,["prevent"])},null,44,Pa),n.createVNode(Ta,{visible:Be.value.visible,x:Be.value.x,y:Be.value.y,"is-element-selected":Be.value.isElementSelected,"is-element-locked":Be.value.isElementLocked,"show-grid":et.value,onAction:u,onClose:I[0]||(I[0]=g=>Be.value.visible=!1)},null,8,["visible","x","y","is-element-selected","is-element-locked","show-grid"]),n.createElementVNode("div",{class:"excalidraw-textContainer",style:n.normalizeStyle({...ve.value}),onClick:At},[J.value?n.withDirectives((n.openBlock(),n.createElementBlock("textarea",{key:0,ref_key:"textInput",ref:o,"onUpdate:modelValue":I[1]||(I[1]=g=>X.value=g),onCompositionstart:Pt,onCompositionupdate:$t,onCompositionend:Mn,onInput:Bn,class:"text-editor",style:n.normalizeStyle({...ve.value,transform:"rotate(0rad)",...ue.value?{}:{height:`${Xe.value}`}}),onBlur:Cn,onKeydown:I[2]||(I[2]=n.withModifiers(()=>{},["stop"]))},null,36)),[[n.vModelText,X.value]]):n.createCommentVNode("",!0)],4)],512))}}),[["__scopeId","data-v-b4198a57"]]),_a={class:"color-box"},Aa=["onClick"],vt=Ye(n.defineComponent({__name:"colorStyle",props:{modelValue:{},modelModifiers:{}},emits:n.mergeModels(["colorChange"],["update:modelValue"]),setup(a,{emit:t}){const e=n.useModel(a,"modelValue"),s=t,o=n.ref(["#FFFFFF","#1E6FFF","#FF194C","#ED6824","#FBB41B","#14C9C9","#754EFF","#363B4C","#C2C5CF","#02A8FC","#FF0187","#FF9736","#FFD02B","#3AE5E5","#8A4EFA","#6F7588","#36B452","#1CD0FB","#FF4667","#E1A371","#FFE192","#4ADFB0"]),l=function(i){e.value=i,s("colorChange",i)};return(i,r)=>(n.openBlock(),n.createElementBlock("div",_a,[n.createElementVNode("div",{class:n.normalizeClass(["trans-icon",{active:e.value==="transparent"}]),onClick:r[0]||(r[0]=c=>l("transparent"))},[...r[1]||(r[1]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-wuyanse"})],-1)])],2),(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(o.value,(c,d)=>(n.openBlock(),n.createElementBlock("div",{key:d,class:n.normalizeClass(["color-item",{active:e.value===c}]),style:n.normalizeStyle({background:c}),onClick:u=>l(c)},null,14,Aa))),128)),r[2]||(r[2]=n.createElementVNode("div",{class:"color-item-add"},[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-tianjiayanse"})])],-1))]))}}),[["__scopeId","data-v-9b04b94a"]]),Da={class:"menu-list"},Fa={class:"preferences-list"},La={class:"preferences-list grid-list"},Oa=["onClick"],Ra={class:"svg-icon"},Xa=["xlink:href"],Ya={class:"preferences-list",style:{padding:"12px",display:"flex","justify-content":"center"}},ja={class:"preference-item"},Ha={class:"preference-info"},Wa={class:"preference-title"},qa={class:"preference-item"},Ua={class:"preference-info"},Ga={class:"preference-title"},Ja=Ye(n.defineComponent({__name:"BoardName",setup(a){const t=je(),e=n.ref(!1),s=n.ref(),o=n.ref("");n.ref("");const l=n.computed(()=>t.appState.isDraggingElement||t.appState.isBoxSelecting),i=n.ref(),r=n.ref([{label:"无网格",icon:"icon-wuwangge",activeIcon:"icon-wuwangge-xuanzhong",value:"none"},{label:"线性网格",icon:"icon-xianxingwangge",activeIcon:"icon-xianxingwangge-xuanzhong",value:"solid"},{label:"点状网格",icon:"icon-dianzhuangwangge",activeIcon:"icon-dianzhuangwangge-xuanzhong",value:"dot"}]),c=n.computed({get(){return t.appState.gridType||"none"},set(m){t.appState.gridType=m}});n.onMounted(()=>{o.value=t.appState.name+""}),n.watch(()=>t.appState.name,m=>{o.value=m+""});const d=()=>{o.value=t.appState.name+"",e.value=!e.value,s.value.focus()};function u(){o.value?t.appState.name=o.value+"":o.value=t.appState.name+"",e.value=!e.value}function k(){i.value.hide(),t.appState.showHelp=!0}function h(m){c.value=m.value}return(m,f)=>{const M=n.resolveComponent("el-popover"),E=n.resolveComponent("el-switch"),B=n.resolveComponent("el-input");return n.openBlock(),n.createElementBlock("div",{class:"board-name-container",style:n.normalizeStyle({pointerEvents:l.value?"none":"auto"})},[n.createVNode(M,{placement:"bottom-start",ref_key:"firstPopoverRef",ref:i,trigger:"click",width:176,offset:12,"popper-class":"board-settings-popover","show-arrow":!1},{reference:n.withCtx(()=>[...f[4]||(f[4]=[n.createElementVNode("div",{class:"action-item"},[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-shezhi"})])],-1)])]),default:n.withCtx(()=>[n.createElementVNode("div",Da,[n.createVNode(M,{placement:"right-start",trigger:"click",width:320,offset:4,"popper-class":"preferences-popover","show-arrow":!1,teleported:!1},{reference:n.withCtx(()=>[...f[5]||(f[5]=[n.createElementVNode("div",{class:"menu-item has-submenu"},[n.createElementVNode("div",{class:"menu-item-content"},[n.createElementVNode("svg",{class:"menu-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-pianhaoshezhi"})]),n.createElementVNode("span",null,"偏好设置")]),n.createElementVNode("svg",{class:"menu-arrow",viewBox:"0 0 24 24",width:"16",height:"16"},[n.createElementVNode("path",{fill:"currentColor",d:"M13.172 12l-4.586 4.586a1 1 0 001.414 1.414l5.293-5.293a1 1 0 000-1.414L9.999 5.999a1 1 0 10-1.414 1.414L13.172 12z"})])],-1)])]),default:n.withCtx(()=>[n.createElementVNode("div",Fa,[n.createVNode(M,{placement:"right-start",trigger:"click",width:176,offset:4,"popper-class":"sub-preferences-popover","show-arrow":!1,teleported:!1},{reference:n.withCtx(()=>[...f[6]||(f[6]=[n.createElementVNode("div",{class:"menu-item has-submenu"},[n.createElementVNode("div",{class:"menu-item-content"},[n.createElementVNode("svg",{class:"menu-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-beijingwangge"})]),n.createElementVNode("span",null,"背景网格")]),n.createElementVNode("svg",{class:"menu-arrow",viewBox:"0 0 24 24",width:"16",height:"16"},[n.createElementVNode("path",{fill:"currentColor",d:"M13.172 12l-4.586 4.586a1 1 0 001.414 1.414l5.293-5.293a1 1 0 000-1.414L9.999 5.999a1 1 0 10-1.414 1.414L13.172 12z"})])],-1)])]),default:n.withCtx(()=>[n.createElementVNode("div",La,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(r.value,(b,V)=>(n.openBlock(),n.createElementBlock("div",{key:V,class:n.normalizeClass(["grid-item",{active:b.value===c.value}]),onClick:O=>h(b)},[(n.openBlock(),n.createElementBlock("svg",Ra,[n.createElementVNode("use",{"xlink:href":`#${b.value===c.value?b.activeIcon:b.icon}`},null,8,Xa)])),n.createElementVNode("div",null,n.toDisplayString(b.label),1)],10,Oa))),128))])]),_:1}),n.createVNode(M,{placement:"right-start",trigger:"click",width:260,offset:4,"popper-class":"sub-preferences-popover","show-arrow":!1,teleported:!1},{reference:n.withCtx(()=>[...f[7]||(f[7]=[n.createElementVNode("div",{class:"menu-item has-submenu"},[n.createElementVNode("div",{class:"menu-item-content"},[n.createElementVNode("svg",{class:"menu-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-huabubeijing"})]),n.createElementVNode("span",null,"背景颜色")]),n.createElementVNode("svg",{class:"menu-arrow",viewBox:"0 0 24 24",width:"16",height:"16"},[n.createElementVNode("path",{fill:"currentColor",d:"M13.172 12l-4.586 4.586a1 1 0 001.414 1.414l5.293-5.293a1 1 0 000-1.414L9.999 5.999a1 1 0 10-1.414 1.414L13.172 12z"})])],-1)])]),default:n.withCtx(()=>[n.createElementVNode("div",Ya,[f[8]||(f[8]=n.createElementVNode("div",{class:"title"},"背景颜色",-1)),n.createVNode(vt,{modelValue:n.unref(t).appState.viewBackgroundColor,"onUpdate:modelValue":f[0]||(f[0]=b=>n.unref(t).appState.viewBackgroundColor=b)},null,8,["modelValue"])])]),_:1}),f[13]||(f[13]=n.createElementVNode("div",{class:"line"},null,-1)),n.createElementVNode("div",ja,[n.createElementVNode("div",Ha,[n.createElementVNode("div",Wa,[f[9]||(f[9]=n.createElementVNode("div",null,"使用滚轮缩放画布",-1)),n.createVNode(E,{modelValue:n.unref(t).appState.useWheelZoom,"onUpdate:modelValue":f[1]||(f[1]=b=>n.unref(t).appState.useWheelZoom=b),size:"small"},null,8,["modelValue"])]),f[10]||(f[10]=n.createElementVNode("div",{class:"preference-desc"},"开启后,可通过鼠标滚轮进行缩放画布",-1))])]),n.createElementVNode("div",qa,[n.createElementVNode("div",Ua,[n.createElementVNode("div",Ga,[f[11]||(f[11]=n.createElementVNode("div",null," 右键拖拽平移画布 ",-1)),n.createVNode(E,{modelValue:n.unref(t).appState.rightClickPan,"onUpdate:modelValue":f[2]||(f[2]=b=>n.unref(t).appState.rightClickPan=b),size:"small"},null,8,["modelValue"])]),f[12]||(f[12]=n.createElementVNode("div",{class:"preference-desc"},"开启后,可通过鼠标右键进行拖拽平移画布",-1))])])])]),_:1}),n.createElementVNode("div",{class:"menu-item",onClick:k},[...f[14]||(f[14]=[n.createElementVNode("div",{class:"menu-item-content"},[n.createElementVNode("svg",{class:"menu-icon",viewBox:"0 0 24 24"},[n.createElementVNode("use",{"xlink:href":"#icon-kuaijiejian"})]),n.createElementVNode("span",null,"快捷键")],-1)])])])]),_:1},512),n.createVNode(B,{ref_key:"inputRef",ref:s,modelValue:o.value,"onUpdate:modelValue":f[3]||(f[3]=b=>o.value=b),class:"board-name-input",placeholder:"Untitled Document",readonly:!e.value,onBlur:u},null,8,["modelValue","readonly"]),e.value?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("div",{key:0,class:"action-item",onClick:d},[...f[15]||(f[15]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-bianji"})],-1)])]))],4)}}}),[["__scopeId","data-v-772e3fac"]]),Ka={class:"history-controls glass"},Za={class:"svg-icon"},Qa=["xlink:href"],ei={class:"svg-icon"},ti=["xlink:href"],ni={class:"zoom-controls glass"},si=Ye(n.defineComponent({__name:"Footer",setup(a){const t=je(),e=()=>{ks.ElMessageBox.confirm("确定要清空画布吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{t.clearElements()}).catch(()=>{})},s=n.computed(()=>t.appState.isDraggingElement||t.appState.isBoxSelecting),o=()=>{t.historyStep<=0||t.undo()},l=()=>{t.historyStep>=t.history.length-1||t.redo()};function i(){t.appState.activeTool==="hand"?t.setTool("selection"):t.setTool("hand")}return(r,c)=>(n.openBlock(),n.createElementBlock("div",{class:"footer-controls footer",style:n.normalizeStyle({right:n.unref(t).appState.isPropertiesPanelOpen?"345px":"24px",pointerEvents:s.value?"none":"auto"})},[n.createElementVNode("div",Ka,[n.createElementVNode("div",{onClick:o,class:n.normalizeClass(["tool-item",{disabled:n.unref(t).historyStep<=0}])},[(n.openBlock(),n.createElementBlock("svg",Za,[n.createElementVNode("use",{"xlink:href":`${n.unref(t).historyStep<=0?"#icon-chexiao-copy":"#icon-chexiao"}`},null,8,Qa)]))],2),n.createElementVNode("div",{onClick:l,class:n.normalizeClass(["tool-item",{disabled:n.unref(t).historyStep>=n.unref(t).history.length-1}])},[(n.openBlock(),n.createElementBlock("svg",ei,[n.createElementVNode("use",{"xlink:href":`${n.unref(t).historyStep>=n.unref(t).history.length-1?"#icon-huifu-copy":"#icon-huifu"}`},null,8,ti)]))],2)]),n.createElementVNode("div",ni,[n.createElementVNode("div",{class:n.normalizeClass(["tool-item",{active:n.unref(t).appState.activeTool==="hand"}]),onClick:c[0]||(c[0]=d=>i())},[...c[5]||(c[5]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-yidong"})],-1)])],2),c[10]||(c[10]=n.createElementVNode("div",{class:"separator"},null,-1)),n.createElementVNode("div",{onClick:c[1]||(c[1]=d=>n.unref(t).zoomOut()),class:"tool-item"},[...c[6]||(c[6]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-suoxiao"})],-1)])]),n.createElementVNode("span",{onClick:c[2]||(c[2]=d=>n.unref(t).setZoom(1)),title:"Reset Zoom",style:{cursor:"pointer"}},n.toDisplayString(Math.round(n.unref(t).appState.zoom*100))+"%",1),n.createElementVNode("div",{onClick:c[3]||(c[3]=d=>n.unref(t).zoomIn()),class:"tool-item"},[...c[7]||(c[7]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-fangda"})],-1)])]),c[11]||(c[11]=n.createElementVNode("div",{class:"separator"},null,-1)),n.createElementVNode("div",{class:n.normalizeClass(["tool-item",{active:n.unref(t).appState.viewLocked}]),onClick:c[4]||(c[4]=d=>n.unref(t).toggleViewLock())},[...c[8]||(c[8]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-suoding"})],-1)])],2),n.createElementVNode("div",{class:"tool-item",onClick:e},[...c[9]||(c[9]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-qingchu"})],-1)])])])],4))}}),[["__scopeId","data-v-06dd6954"]]),oi=Ye(n.defineComponent({__name:"HelpDialog",setup(a){const t=je(),e=()=>{t.appState.showHelp=!1};return(s,o)=>n.unref(t).appState.showHelp?(n.openBlock(),n.createElementBlock("div",{key:0,class:"modal-overlay",onClick:n.withModifiers(e,["self"]),style:n.normalizeStyle({pointerEvents:n.unref(t).appState.isDraggingElement?"none":"auto"})},[n.createElementVNode("div",{class:"help-dialog glass"},[n.createElementVNode("div",{class:"header"},[o[1]||(o[1]=n.createElementVNode("h2",null,"快捷键列表",-1)),n.createElementVNode("button",{class:"close-btn",onClick:e},[...o[0]||(o[0]=[n.createElementVNode("i",{class:"ri-close-line"},null,-1)])])]),o[2]||(o[2]=n.createStaticVNode('<div class="content" data-v-0caac542><div class="column" data-v-0caac542><h3 data-v-0caac542>工具</h3><div class="shortcut-list" data-v-0caac542><div class="item" data-v-0caac542><span data-v-0caac542>抓手 (平移工具)</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>H</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>选择</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>V</kbd> 或 <kbd data-v-0caac542>1</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>图形</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>R</kbd> 或 <kbd data-v-0caac542>2</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>箭头</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>A</kbd> 或 <kbd data-v-0caac542>5</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>线条</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>L</kbd> 或 <kbd data-v-0caac542>6</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>自由书写</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>P</kbd> 或 <kbd data-v-0caac542>7</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>文字</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>T</kbd> 或 <kbd data-v-0caac542>8</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>橡皮</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>E</kbd> 或 <kbd data-v-0caac542>0</kbd></span></div></div><h3 data-v-0caac542>视图</h3><div class="shortcut-list" data-v-0caac542><div class="item" data-v-0caac542><span data-v-0caac542>放大</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>+</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>缩小</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>-</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>重置缩放</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>0</kbd></span></div></div></div><div class="column" data-v-0caac542><h3 data-v-0caac542>编辑器</h3><div class="shortcut-list" data-v-0caac542><div class="item" data-v-0caac542><span data-v-0caac542>全选</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>A</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>删除</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Delete</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>复制</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>C</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>粘贴</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>V</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>剪切</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>X</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>撤销</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>Z</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>重做</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>Shift</kbd><kbd data-v-0caac542>Z</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>组合</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>G</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>取消组合</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Cmd</kbd><kbd data-v-0caac542>Shift</kbd><kbd data-v-0caac542>G</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>置于顶层</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>]</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>置于底层</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>[</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>上移一层</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Option</kbd><kbd data-v-0caac542>]</kbd></span></div><div class="item" data-v-0caac542><span data-v-0caac542>下移一层</span><span class="keys" data-v-0caac542><kbd data-v-0caac542>Option</kbd><kbd data-v-0caac542>[</kbd></span></div></div></div></div>',1))])],4)):n.createCommentVNode("",!0)}}),[["__scopeId","data-v-0caac542"]]),ai={class:"popovers-container"},ii={class:"popover-content"},li={class:"sub-tools-container"},ri=["onClick"],ci={class:"svg-icon"},di=["xlink:href"],pi={key:1,class:"divider"},hi={class:"settings-btn",title:"背景颜色"},fi={key:0,class:"svg-icon"},ui={class:"popover-content"},mi=["title"],gi={key:0,class:"svg-icon"},yi={key:1,class:"svg-icon"},ki=["xlink:href"],xi={class:"popover-content"},wi={class:"title"},Si={class:"title"},bi={class:"title"},vi={class:"title"},Ei={key:4,class:"divider"},Ii={class:"settings-btn",title:"箭头颜色"},Mi={key:0,class:"svg-icon"},Bi={class:"popover-content"},Ci={class:"popover-content"},Vi={key:7,class:"divider"},Ni={class:"settings-btn",title:"文本颜色"},Ti=["fill"],zi=["fill"],Pi=["fill"],$i={class:"popover-content"},_i={key:9,class:"font-size-select"},Ai=Ye(n.defineComponent({__name:"FloatingPopovers",setup(a){const t=je(),e=n.ref(!1),s=n.ref(!1),o=n.ref(!1),l=n.ref(!1),i=n.ref(!1),r=n.ref(!1),c=n.ref(!1),d=n.ref(null),u=n.ref([{name:"rectangle",icon:"#icon-yuanjiaojuxing",label:"矩形",key:"2"},{name:"diamond",icon:"#icon-lingxing",label:"菱形",key:"3"},{name:"ellipse",icon:"#icon-tuoyuanxing",label:"椭圆",key:"4"},{name:"square",icon:"#icon-zhengfangxing",label:"正方形",key:"2"},{name:"star",icon:"#icon-wujiaoxing",label:"五角星",key:"3"},{name:"circle",icon:"#icon-yuanxing",label:"圆形",key:"4"},{name:"cylinder",icon:"#icon-yuanzhuti",label:"圆柱体",key:"5"},{name:"trapezoid",icon:"#icon-tixing",label:"梯形",key:"8"},{name:"parallelogram",icon:"#icon-pinghangsibianxing",label:"平行四边形",key:"9"}]),k=D=>{if(d.value&&d.value.contains(D.target))return;const j=D.target;j&&j.closest&&j.closest(".el-popper")||(e.value&&(e.value=!1),s.value&&(s.value=!1),o.value&&(o.value=!1),l.value&&(l.value=!1),i.value&&(i.value=!1),r.value&&(r.value=!1),c.value&&(c.value=!1))};n.onMounted(()=>{window.addEventListener("mousedown",k,!0)}),n.onUnmounted(()=>{window.removeEventListener("mousedown",k,!0)});const h=()=>{const D=Object.keys(t.appState.selectedElementIds);if(D.length===0)return null;const j=D[D.length-1];return t.elements.find(ve=>ve.id===j)||null},m=n.computed(()=>t.appState.activeTool),f=n.computed(()=>Object.keys(t.appState.selectedElementIds)),M=n.computed(()=>f.value.length>0),E=()=>{if(m.value==="selection"){if(!M.value)return"none";const D=f.value[0],j=t.elements.find(ve=>ve.id===D);return j?j.type:"none"}return m.value==="shapes"?t.appState.activeToolType:m.value},B=n.computed(()=>{const D=E();return["rectangle","ellipse","diamond","square","star","circle","cylinder","process","decision","trapezoid","parallelogram"].includes(D)}),b=n.computed(()=>{const D=E();return["rectangle","ellipse","diamond","square","star","circle","cylinder","process","decision","trapezoid","parallelogram","frame"].includes(D)}),V=n.computed(()=>{const D=E();return["rectangle","ellipse","diamond","square","star","circle","cylinder","process","decision","trapezoid","parallelogram","arrow","line","freedraw","frame"].includes(D)}),O=n.computed(()=>{const D=E();return["rectangle","ellipse","diamond","square","star","circle","cylinder","process","decision","trapezoid","parallelogram","arrow","line"].includes(D)}),H=n.computed(()=>{const D=E();return["rectangle","diamond","square","star",,"process","decision","trapezoid","parallelogram"].includes(D)}),Z=n.computed(()=>{const D=E();return["rectangle","ellipse","diamond","square","star","circle","cylinder","process","decision","trapezoid","parallelogram","text"].includes(D)}),ne=n.computed(()=>{const D=E();return["arrow","line"].includes(D)}),W=n.computed(()=>{const D=h();return D?D.arrowType:t.appState.currentItemArrowType}),J=n.computed({get(){const D=h();return D?D.strokeColor:t.appState.currentItemStrokeColor},set(D){Me(D)}}),Q=n.computed({get(){const D=h();return D?D.backgroundColor:t.appState.currentItemBackgroundColor},set(D){Le(D)}}),oe=n.computed({get(){const D=h();return D?D.fontColor:t.appState.currentItemFontColor},set(D){Be(D)}}),Y=n.computed({get(){const D=h();return D&&"fontBgColor"in D?D.fontBgColor:t.appState.currentItemFontBgColor},set(D){Ae(D)}}),A=n.computed({get(){const D=h();return D?D.backgroundOpacity??100:t.appState.currentItemBackgroundOpacity},set(D){K(D)}}),X=n.computed({get(){const D=h();return D?D.strokeOpacity??100:t.appState.currentItemStrokeOpacity??100},set(D){Xe(D)}}),te=n.computed({get(){const D=h();return D?D.strokeWidth:t.appState.currentItemStrokeWidth},set(D){ee(D)}});n.computed(()=>{const D=h();return D?D.strokeStyle:t.appState.currentItemStrokeStyle||"solid"}),n.computed(()=>{const D=h();return D?D.roughness:t.appState.currentItemRoughness??0});const de=n.computed({get(){const D=h();return D?D.roundness??0:t.appState.currentItemRoundness},set(D){et(D)}}),fe=n.computed({get:()=>{const D=h();return D&&"fontSize"in D?D.fontSize:t.appState.currentItemFontSize},set:D=>{Ke(D)}});n.computed(()=>{const D=h();return D&&"fontFamily"in D?D.fontFamily:t.appState.currentItemFontFamily}),n.computed(()=>{const D=h();return D&&"textAlign"in D?D.textAlign:t.appState.currentItemTextAlign}),n.computed(()=>{const D=h();return D&&"verticalAlign"in D?D.verticalAlign:t.appState.currentItemVerticalAlign});const Ie=[12,14,16,18,20,24,28,32,36],Me=D=>{t.updateSelectedElements({strokeColor:D})},K=D=>{const j=D;t.updateSelectedElements({backgroundOpacity:j})},Le=D=>{const j=D||"transparent";t.updateSelectedElements({backgroundColor:j})},ee=D=>{t.updateSelectedElements({strokeWidth:D})},Xe=D=>{t.updateSelectedElements({strokeOpacity:D})},et=D=>{t.updateSelectedElements({roundness:D})},Ke=D=>{Object.keys(t.appState.selectedElementIds).forEach(ve=>{const Ce=t.elements.find(ue=>ue.id===ve);if(Ce&&Ce.type==="text"){const ue=Ce;if(ue.autoResize){const Ve=_e(ue.text||"",D,ue.fontFamily||"sans-serif",void 0,{isBold:ue.isBold,isItalic:ue.isItalic});t.updateElement(ve,{fontSize:D,width:Ve.width,height:Ve.height})}else{const Ve=_e(ue.text||"",D,ue.fontFamily||"sans-serif",Ce.width,{isBold:ue.isBold,isItalic:ue.isItalic});t.updateElement(ve,{fontSize:D,height:Ve.height})}}else{t.updateElement(ve,{fontSize:D});const ue=t.elements.find(Ve=>Ve.type==="text"&&Ve.containerId===ve&&!Ve.isDeleted);if(ue){const Ve=_e(ue.text||"",D,ue.fontFamily||"sans-serif",ue.width);t.updateElement(ue.id,{fontSize:D,height:Math.max(Ve.height,Ce?.height)})}}})},Be=D=>{t.updateSelectedElements({fontColor:D}),Object.keys(t.appState.selectedElementIds).forEach(ve=>{const Ce=t.elements.find(ue=>ue.type==="text"&&ue.containerId===ve&&!ue.isDeleted);Ce&&t.updateElement(Ce.id,{fontColor:D})})},Ae=D=>{t.updateSelectedElements({fontBgColor:D}),Object.keys(t.appState.selectedElementIds).forEach(ve=>{const Ce=t.elements.find(ue=>ue.type==="text"&&ue.containerId===ve&&!ue.isDeleted);Ce&&t.updateElement(Ce.id,{fontBgColor:D})})},it=D=>{t.updateSelectedElements({type:D})};return(D,j)=>{const ve=n.resolveComponent("el-popover"),Ce=n.resolveComponent("el-slider"),ue=n.resolveComponent("el-option"),Ve=n.resolveComponent("el-select");return n.openBlock(),n.createElementBlock("div",ai,[B.value?(n.openBlock(),n.createBlock(ve,{key:0,placement:"top",width:224,trigger:"click","show-arrow":!1,"popper-class":"custom-toolbar-popover",visible:c.value,"onUpdate:visible":j[0]||(j[0]=ce=>c.value=ce)},{reference:n.withCtx(()=>[...j[15]||(j[15]=[n.createElementVNode("div",{class:"settings-btn",title:"形状"},[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-xingzhuang"})])],-1)])]),default:n.withCtx(()=>[n.createElementVNode("div",ii,[n.createElementVNode("div",li,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(u.value,ce=>(n.openBlock(),n.createElementBlock("div",{key:ce.name,class:n.normalizeClass(["sub-tool-item",{active:E()===ce.name}]),onClick:Zt=>it(ce.name)},[(n.openBlock(),n.createElementBlock("svg",ci,[n.createElementVNode("use",{"xlink:href":`${ce.icon}`},null,8,di)]))],10,ri))),128))])])]),_:1},8,["visible"])):n.createCommentVNode("",!0),B.value?(n.openBlock(),n.createElementBlock("div",pi)):n.createCommentVNode("",!0),b.value?(n.openBlock(),n.createBlock(ve,{key:2,placement:"top",width:248,trigger:"click","show-arrow":!1,"popper-class":"custom-toolbar-popover",visible:e.value,"onUpdate:visible":j[3]||(j[3]=ce=>e.value=ce)},{reference:n.withCtx(()=>[n.createElementVNode("div",hi,[Q.value=="transparent"||!Q.value?(n.openBlock(),n.createElementBlock("svg",fi,[...j[16]||(j[16]=[n.createElementVNode("use",{"xlink:href":"#icon-wuyanse"},null,-1)])])):(n.openBlock(),n.createElementBlock("div",{key:1,class:"color-box",style:n.normalizeStyle({background:Q.value})},null,4))])]),default:n.withCtx(()=>[n.createElementVNode("div",ui,[j[17]||(j[17]=n.createElementVNode("div",{class:"title"},"填充样式",-1)),n.createVNode(Yn),j[18]||(j[18]=n.createElementVNode("div",{class:"title"},"透明度",-1)),n.createVNode(Ce,{modelValue:A.value,"onUpdate:modelValue":j[1]||(j[1]=ce=>A.value=ce),"show-input":"","show-input-controls":!1},null,8,["modelValue"]),j[19]||(j[19]=n.createElementVNode("div",{class:"title"},[n.createElementVNode("span",null,"默认颜色")],-1)),n.createVNode(vt,{modelValue:Q.value,"onUpdate:modelValue":j[2]||(j[2]=ce=>Q.value=ce)},null,8,["modelValue"])])]),_:1},8,["visible"])):n.createCommentVNode("",!0),V.value?(n.openBlock(),n.createBlock(ve,{key:3,placement:"top",width:248,trigger:"click","show-arrow":!1,"popper-class":"custom-toolbar-popover",visible:s.value,"onUpdate:visible":j[7]||(j[7]=ce=>s.value=ce)},{reference:n.withCtx(()=>[n.createElementVNode("div",{class:"settings-btn",title:E()=="arrow"?"箭头":"边框"},[E()!=="arrow"&&E()!=="line"?(n.openBlock(),n.createElementBlock(n.Fragment,{key:0},[J.value=="transparent"||!J.value?(n.openBlock(),n.createElementBlock("svg",gi,[...j[20]||(j[20]=[n.createElementVNode("use",{"xlink:href":"#icon-wubiankuang"},null,-1)])])):(n.openBlock(),n.createElementBlock("div",{key:1,class:"border-box",style:n.normalizeStyle({borderColor:J.value})},null,4))],64)):(n.openBlock(),n.createElementBlock("svg",yi,[n.createElementVNode("use",{"xlink:href":`#${E()=="line"?"icon-zhixian":W.value=="sharp"?"icon-zhixianlianjiexian":"icon-quxian"}`},null,8,ki)]))],8,mi)]),default:n.withCtx(()=>[n.createElementVNode("div",xi,[O.value?(n.openBlock(),n.createElementBlock(n.Fragment,{key:0},[n.createElementVNode("div",wi,n.toDisplayString(["arrow","line"].includes(E())?"线条":"描边")+"样式",1),n.createVNode(jn)],64)):n.createCommentVNode("",!0),j[22]||(j[22]=n.createElementVNode("div",{class:"title"},"线条风格",-1)),n.createVNode(Hn),n.createElementVNode("div",Si,n.toDisplayString(["arrow","line"].includes(E())?"线条":"描边")+"粗细",1),n.createVNode(Ce,{modelValue:te.value,"onUpdate:modelValue":j[4]||(j[4]=ce=>te.value=ce),"show-input":"","show-input-controls":!1,min:1,max:10},null,8,["modelValue"]),n.createElementVNode("div",bi,n.toDisplayString(["arrow","line"].includes(E())?"":"描边")+"透明度",1),n.createVNode(Ce,{modelValue:X.value,"onUpdate:modelValue":j[5]||(j[5]=ce=>X.value=ce),"show-input":"","show-input-controls":!1},null,8,["modelValue"]),ne.value?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock(n.Fragment,{key:1},[j[21]||(j[21]=n.createElementVNode("div",{class:"title"},[n.createElementVNode("span",null,"默认颜色")],-1)),n.createVNode(vt,{modelValue:J.value,"onUpdate:modelValue":j[6]||(j[6]=ce=>J.value=ce)},null,8,["modelValue"])],64)),ne.value?(n.openBlock(),n.createElementBlock(n.Fragment,{key:2},[n.createElementVNode("div",vi,n.toDisplayString(E()=="arrow"?"箭头":"线条")+"类型",1),n.createVNode(Un)],64)):n.createCommentVNode("",!0)])]),_:1},8,["visible"])):n.createCommentVNode("",!0),ne.value?(n.openBlock(),n.createElementBlock("div",Ei)):n.createCommentVNode("",!0),ne.value?(n.openBlock(),n.createBlock(ve,{key:5,placement:"top",width:248,trigger:"click","show-arrow":!1,"popper-class":"custom-toolbar-popover",visible:o.value,"onUpdate:visible":j[9]||(j[9]=ce=>o.value=ce)},{reference:n.withCtx(()=>[n.createElementVNode("div",Ii,[J.value=="transparent"||!J.value?(n.openBlock(),n.createElementBlock("svg",Mi,[...j[23]||(j[23]=[n.createElementVNode("use",{"xlink:href":"#icon-wuyanse"},null,-1)])])):(n.openBlock(),n.createElementBlock("div",{key:1,class:"color-box",style:n.normalizeStyle({background:J.value})},null,4))])]),default:n.withCtx(()=>[n.createElementVNode("div",Bi,[j[24]||(j[24]=n.createElementVNode("div",{class:"title"},[n.createElementVNode("span",null,"默认颜色")],-1)),n.createVNode(vt,{modelValue:J.value,"onUpdate:modelValue":j[8]||(j[8]=ce=>J.value=ce)},null,8,["modelValue"])])]),_:1},8,["visible"])):n.createCommentVNode("",!0),H.value?(n.openBlock(),n.createBlock(ve,{key:6,placement:"top",width:248,trigger:"click","show-arrow":!1,"popper-class":"custom-toolbar-popover"},{reference:n.withCtx(()=>[...j[25]||(j[25]=[n.createElementVNode("div",{class:"settings-btn",title:"圆角"},[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-yuanjiao"})])],-1)])]),default:n.withCtx(()=>[n.createElementVNode("div",Ci,[j[26]||(j[26]=n.createElementVNode("div",{class:"title"},"圆角",-1)),n.createVNode(Ce,{modelValue:de.value,"onUpdate:modelValue":j[10]||(j[10]=ce=>de.value=ce),"show-input":"","show-input-controls":!1,min:0,max:100},null,8,["modelValue"])])]),_:1})):n.createCommentVNode("",!0),Z.value&&b.value?(n.openBlock(),n.createElementBlock("div",Vi)):n.createCommentVNode("",!0),Z.value?(n.openBlock(),n.createBlock(ve,{key:8,placement:"top",width:248,trigger:"click","show-arrow":!1,"popper-class":"custom-toolbar-popover",visible:i.value,"onUpdate:visible":j[13]||(j[13]=ce=>i.value=ce)},{reference:n.withCtx(()=>[n.createElementVNode("div",Ni,[(n.openBlock(),n.createElementBlock("svg",{class:"svg-icon",viewBox:"0 0 1024 1024",style:n.normalizeStyle({backgroundColor:Y.value})},[n.createElementVNode("path",{d:"M772.144762 747.52L566.369524 223.817143a24.137143 24.137143 0 0 0-24.380953-16.579048H484.449524c-11.702857 0-19.992381 5.36381-24.380953 16.579048L254.293333 747.52c-6.339048 16.579048-4.87619 32.182857 5.36381 46.811429 10.24 14.628571 23.893333 21.942857 41.935238 21.942857 22.918095 0 38.521905-10.727619 47.299048-32.182857l48.761904-123.855239h232.106667l48.761905 123.855239c8.289524 21.455238 23.893333 32.182857 46.811428 32.182857 18.041905 0 31.695238-7.314286 41.935238-21.942857 10.24-14.628571 11.702857-30.232381 5.36381-46.811429h-0.487619z m-25.356191 33.645714c-5.36381 7.801905-12.190476 11.215238-21.455238 11.215238-11.702857 0-19.992381-5.36381-24.380952-16.579047l-49.737143-126.780953a18.870857 18.870857 0 0 0-18.529524-12.678095H394.727619c-9.264762 0-15.60381 4.388571-18.529524 12.678095l-49.737143 126.780953c-4.388571 11.215238-12.678095 16.579048-24.380952 16.579047-9.264762 0-16.579048-3.900952-21.942857-11.702857a24.380952 24.380952 0 0 1-2.925714-24.380952L482.986667 232.594286s0.975238-0.975238 1.950476-0.975238h57.539047s1.462857 0 1.950477 0.975238l205.775238 523.702857a24.380952 24.380952 0 0 1-2.925715 24.380952l-0.487619 0.487619z",fill:oe.value=="transparent"?"#EEEFF0":oe.value,"p-id":"4210"},null,8,Ti),n.createElementVNode("path",{d:"M529.310476 338.895238c-2.925714-7.314286-8.289524-10.727619-16.091428-10.727619s-13.165714 3.413333-16.091429 10.727619l-86.79619 220.40381c-2.438095 5.36381-1.462857 10.727619 1.950476 16.091428 3.413333 4.87619 8.289524 7.314286 14.140952 7.314286h173.104762c5.851429 0 10.727619-2.438095 14.140952-7.314286 3.413333-4.87619 3.900952-10.24 1.950477-16.091428l-86.308572-220.40381z m-91.672381 219.428572l76.068572-193.097143 75.580952 193.097143H437.638095z",fill:oe.value=="transparent"?"#EEEFF0":oe.value,"p-id":"4211"},null,8,zi),n.createElementVNode("path",{d:"M700.952381 775.801905c4.388571 11.215238 12.678095 16.579048 24.380952 16.579047 9.264762 0 16.579048-3.900952 21.455238-11.215238a24.380952 24.380952 0 0 0 2.925715-24.380952L543.939048 233.081905s-0.975238-0.975238-1.950477-0.975238H484.449524s-1.462857 0-1.950476 0.975238L276.72381 756.784762a24.380952 24.380952 0 0 0 2.925714 24.380952c5.36381 7.801905 12.678095 11.702857 21.942857 11.702857 11.702857 0 19.992381-5.36381 24.380952-16.579047l49.737143-126.780953c3.413333-8.289524 9.752381-12.678095 18.529524-12.678095h237.958095c9.264762 0 15.60381 4.388571 18.529524 12.678095l49.737143 126.780953 0.487619-0.487619z m-274.529524-193.097143c-5.851429 0-10.727619-2.438095-14.140952-7.314286a17.066667 17.066667 0 0 1-1.950476-16.091428l86.79619-220.40381c2.925714-7.314286 8.289524-10.727619 16.091429-10.727619s13.165714 3.413333 16.091428 10.727619l86.308572 220.40381c2.438095 5.36381 1.462857 10.727619-1.950477 16.091428-3.413333 4.87619-8.289524 7.314286-14.140952 7.314286H426.422857z",fill:oe.value,"p-id":"4212"},null,8,Pi)],4))])]),default:n.withCtx(()=>[n.createElementVNode("div",$i,[j[27]||(j[27]=n.createElementVNode("div",{class:"title"},[n.createElementVNode("span",null,"文本样式")],-1)),n.createVNode(Wn),j[28]||(j[28]=n.createElementVNode("div",{class:"title"},[n.createElementVNode("span",null,"对齐方式")],-1)),n.createVNode(qn),j[29]||(j[29]=n.createElementVNode("div",{class:"title"},[n.createElementVNode("span",null,"字体颜色")],-1)),n.createVNode(vt,{modelValue:oe.value,"onUpdate:modelValue":j[11]||(j[11]=ce=>oe.value=ce)},null,8,["modelValue"]),j[30]||(j[30]=n.createElementVNode("div",{class:"title"},[n.createElementVNode("span",null,"背景颜色")],-1)),n.createVNode(vt,{modelValue:Y.value,"onUpdate:modelValue":j[12]||(j[12]=ce=>Y.value=ce)},null,8,["modelValue"])])]),_:1},8,["visible"])):n.createCommentVNode("",!0),Z.value?(n.openBlock(),n.createElementBlock("div",_i,[n.createVNode(Ve,{modelValue:fe.value,"onUpdate:modelValue":j[14]||(j[14]=ce=>fe.value=ce),style:{width:"68px"},onChange:Ke},{default:n.withCtx(()=>[(n.openBlock(),n.createElementBlock(n.Fragment,null,n.renderList(Ie,ce=>n.createVNode(ue,{key:ce,label:`${ce}`,value:ce},null,8,["label","value"])),64))]),_:1},8,["modelValue"])])):n.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-1fe4c384"]]),Di={key:0,class:"divider"},Fi=["title"],Li={class:"svg-icon"},Oi=["xlink:href"],Ri=Ye(n.defineComponent({__name:"FloatingPropertiesBar",props:{zoom:{},scrollX:{},scrollY:{}},setup(a){const t=a,e=je(),s=n.ref(!1),o=n.ref({x:0,y:0});n.watch(()=>e.appState.selectedElementIds,()=>{e.appState.floatingToolbarOffset={x:0,y:0}},{deep:!0});const l=n.computed(()=>e.appState.activeTool),i=n.computed(()=>Object.keys(e.appState.selectedElementIds)),r=n.computed(()=>i.value.length>0),c=()=>{if(l.value==="selection"){if(!r.value)return"none";const O=i.value[0],H=e.elements.find(Z=>Z.id===O);return H?H.type:"none"}return l.value==="shapes"?e.appState.activeToolType:l.value},d=n.computed(()=>{const O=c();return["arrow","line"].includes(O)}),u=n.computed(()=>{const O=c();return["rectangle","ellipse","diamond","square","star","circle","cylinder","process","decision","trapezoid","parallelogram"].includes(O)}),k=n.computed(()=>i.value.length>1),h=n.computed(()=>e.appState.isDraggingElement||e.appState.isBoxSelecting),m=n.computed(()=>{const O=e.elements.filter(oe=>e.appState.selectedElementIds[oe.id]);if(O.length===0)return{display:"none"};const H=St(O);if(!H)return{display:"none"};const Z=(H.x+t.scrollX)*t.zoom,ne=(H.y+t.scrollY)*t.zoom,W=H.width*t.zoom,J=Z+W/2+e.appState.floatingToolbarOffset.x,Q=ne-32-40+e.appState.floatingToolbarOffset.y;return{left:`${J}px`,top:`${Math.max(10,Q)}px`,transform:"translateX(-50%)",pointerEvents:h.value?"none":"auto"}}),f=O=>{s.value=!0,o.value={x:O.clientX-e.appState.floatingToolbarOffset.x,y:O.clientY-e.appState.floatingToolbarOffset.y},document.addEventListener("mousemove",M),document.addEventListener("mouseup",E)},M=O=>{s.value&&(e.appState.floatingToolbarOffset={x:O.clientX-o.value.x,y:O.clientY-o.value.y})},E=()=>{s.value=!1,document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",E)},B=()=>{e.appState.isPropertiesPanelOpen=!0},b=n.computed(()=>{if(i.value.length<2)return!1;const O=e.elements.filter(ne=>e.appState.selectedElementIds[ne.id]),H=O[0]?.groupIds||[];return H.length===0?!1:H.filter(ne=>O.every(W=>W.groupIds&&W.groupIds.includes(ne))).length>0}),V=()=>{const O=Object.keys(e.appState.selectedElementIds);b.value?e.ungroupElements(O):e.groupElements(O)};return(O,H)=>n.unref(e).shouldShowFloatingToolbar?(n.openBlock(),n.createElementBlock("div",{key:0,class:"floating-toolbar",style:n.normalizeStyle({...m.value,pointerEvents:h.value?"none":"auto"})},[n.createElementVNode("div",{class:"drag-handle",title:"拖动",onMousedown:n.withModifiers(f,["stop"])},[...H[0]||(H[0]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-tuodong"})],-1)])],32),!d.value&&!u.value?(n.openBlock(),n.createElementBlock("div",Di)):n.createCommentVNode("",!0),n.createVNode(Ai),H[2]||(H[2]=n.createElementVNode("div",{class:"divider"},null,-1)),k.value?(n.openBlock(),n.createElementBlock("div",{key:1,class:"settings-btn",onClick:n.withModifiers(V,["stop"]),title:b.value?"解除编组":"编组"},[(n.openBlock(),n.createElementBlock("svg",Li,[n.createElementVNode("use",{"xlink:href":b.value?"#icon-quxiaobianzu":"#icon-bianzu"},null,8,Oi)]))],8,Fi)):n.createCommentVNode("",!0),n.createElementVNode("div",{class:"settings-btn",onClick:n.withModifiers(B,["stop"]),title:"右侧面板"},[...H[1]||(H[1]=[n.createElementVNode("svg",{class:"svg-icon"},[n.createElementVNode("use",{"xlink:href":"#icon-youcemianban"})],-1)])])],4)):n.createCommentVNode("",!0)}}),[["__scopeId","data-v-206d2632"]]),Xi={class:"app-container"},Kt=n.defineComponent({__name:"App",setup(a){const t=je();return n.onMounted(()=>{t.recordHistory(),window.getExcalidrawCanvasData=()=>{const e=JSON.parse(JSON.stringify(t.elements)),s=JSON.parse(JSON.stringify(t.appState));return console.log("Canvas Elements:",e),console.log("Canvas Config (AppState):",s),{elements:e,appState:s}}}),(e,s)=>(n.openBlock(),n.createElementBlock("div",Xi,[n.createVNode(qs),n.createVNode(na),n.createVNode(Ja),n.createVNode($a,{elements:n.unref(t).elements,zoom:n.unref(t).appState.zoom,scrollX:n.unref(t).appState.scrollX,scrollY:n.unref(t).appState.scrollY},null,8,["elements","zoom","scrollX","scrollY"]),n.createVNode(Ri,{zoom:n.unref(t).appState.zoom,scrollX:n.unref(t).appState.scrollX,scrollY:n.unref(t).appState.scrollY},null,8,["zoom","scrollX","scrollY"]),n.createVNode(si),n.createVNode(oi)]))}});Kt.install=function(a){a.component("JvsDraw",Kt)},rt.JvsDraw=Kt,rt.default=Kt,Object.defineProperties(rt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
Binary file
|
|
Binary file
|