@wcardinal/wcardinal-ui 0.452.0 → 0.453.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 +1 -1
- package/dist/types/wcardinal/ui/util/util-clipboard.d.ts +1 -1
- package/dist/wcardinal/ui/util/util-clipboard.js +13 -8
- package/dist/wcardinal/ui/util/util-clipboard.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +14 -9
- package/dist/wcardinal-ui.js +14 -9
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
package/dist/wcardinal-ui.min.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Winter Cardinal UI v0.
|
|
2
|
+
Winter Cardinal UI v0.453.0
|
|
3
3
|
Copyright (C) 2019 Toshiba Corporation
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
6
6
|
Material Design icons by Google
|
|
7
7
|
Apache license version 2.0.
|
|
8
8
|
*/
|
|
9
|
-
!function(t){"use strict";const e={},i={},s={CIRCLE:0,RECTANGLE:1,RECTANGLE_ROUNDED:2,TRIANGLE:3,TRIANGLE_ROUNDED:4,LINE:5,IMAGE:6,IMAGE_SDF:7,GROUP:8,BAR:9,LABEL:10,NULL:11,GROUP_SHADOWED:12,LINE_OF_CIRCLES:13,LINE_OF_RECTANGLES:14,LINE_OF_RECTANGLE_ROUNDEDS:15,LINE_OF_TRIANGLES:16,LINE_OF_TRIANGLE_ROUNDEDS:17,EMBEDDED:18,EMBEDDED_LAYER:19,BUTTON:20,RECTANGLE_PIVOTED:21,CONNECTOR_LINE:22,CONNECTOR_ELBOW:23,SEMICIRCLE:24,EMBEDDED_ACCEPTOR_EDGE:25,EXTENSION:1e3},n={};class o{constructor(t,e,i,s,n,o){this._builders=o,this._vertexOffset=e,this._indexOffset=i,this._vertexCount=s,this._indexCount=n}init(t){t.uploaded=this;const e=this._builders;for(let t=0,i=e.length;t<i;++t)e[t].init();return this.update(t),this}reinit(t,e,i,s){const n=this._builders;let o=i,r=s;for(let i=0,s=n.length;i<s;++i){const s=n[i];if(!s.reinit(t,e,o,r))return!1;o+=s.vertexCount,r+=s.indexCount}return this._vertexCount=o-i,this._indexCount=r-s,this.update(e),!0}update(t){const e=this._builders;for(let i=0,s=e.length;i<s;++i)e[i].update(t);return this}isCompatible(t){const e=this._builders;for(let i=0,s=e.length;i<s;++i)if(!e[i].isCompatible(t))return!1;return!0}getVertexOffset(){return this._vertexOffset}getVertexCount(){return this._vertexCount}getIndexOffset(){return this._indexOffset}getIndexCount(){return this._indexCount}buildUnit(t){const e=this._builders;for(let i=0,s=e.length;i<s;++i)e[i].buildUnit(t)}}const r={NONE:0,NON_EXPANDING_WIDTH:2,NON_SHRINKING_WIDTH:4,NON_SCALING_DOT_AND_DASH:8,NON_SCALING:14,NON_SCALING_MASK:14,DOTTED:16,DOTTED_DENSELY:32,DOTTED_LOOSELY:64,DOTTED_MASK:112,DASHED:128,DASHED_DENSELY:256,DASHED_LOOSELY:512,DASHED_MASK:896},a=t=>t&r.DOTTED_MASK?t&r.DOTTED?1:t&r.DOTTED_DENSELY?2:3:t&r.DASHED_MASK?t&r.DASHED?4:t&r.DASHED_DENSELY?5:6:0,h=t=>{const e=t&r.NON_EXPANDING_WIDTH?1:0,i=t&r.NON_SHRINKING_WIDTH?2:0;return t&(r.DOTTED_MASK||r.DASHED_MASK)?e|i|(t&r.NON_SCALING_DOT_AND_DASH?4:0):e|i},l=(t,e,i,s,n)=>(n[0]=i-t,n[1]=s-e,n),c=(t,e)=>{if(1e-5<e){const i=1/e,s=t[0]*i,n=t[1]*i;t[0]=-n,t[1]=+s}else t[0]=0,t[1]=1;return t},u=(t,e)=>Math.round(511.5*(1+t[0]))+(Math.round(511.5*(1+e[0]))<<10)+((0<=t[1]?1:0)+(0<=e[1]?2:0)<<20),d=(t,e,i,s)=>t+(e<<6)+(i<<12)+(s<<18),p=(t,e)=>Math.round(1023*t)+(Math.round(1023*e)<<10),_=[0,1],g=[0,1],f=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+2,t[++s]=e+1,t[++s]=e+1,t[++s]=e+2,t[++s]=e+3},m=(t,e,i,s,n,o,r,p)=>{const f=p.a,m=p.b,v=p.c,T=p.d,w=p.tx,E=p.ty,y=s[0],x=s[1],C=f*y+v*x+w,D=m*y+T*x+E,S=s[2],b=s[3];let I=f*S+v*b+w,O=m*S+T*b+E,A=I-C,R=O-D;const M=Math.sqrt(A*A+R*R);let k=M;if(0<=n&&1e-5<M){const t=n/M;A*=t,R*=t,I=C+A,O=D+R,k=n}const L=_,N=g;l(C-A,D-R,C,D,L),l(C,D,I,O,N),c(L,k),c(N,k);const P=u(L,N),B=h(r),z=a(r),U=d(3,B,z,0),F=d(5,B,z,0);let H=(i<<1)-1,G=6*i-1;t[++H]=C,t[++H]=D,t[++H]=C,t[++H]=D,e[++G]=o,e[++G]=U,e[++G]=P,e[++G]=0,e[++G]=k,e[++G]=0,e[++G]=o,e[++G]=F,e[++G]=P,e[++G]=0,e[++G]=k,e[++G]=0,t[++H]=I,t[++H]=O,t[++H]=I,t[++H]=O,e[++G]=o,e[++G]=U,e[++G]=P,e[++G]=k,e[++G]=k,e[++G]=0,e[++G]=o,e[++G]=F,e[++G]=P,e[++G]=k,e[++G]=k,e[++G]=0},v=(t,e,i)=>{let s=(e<<1)-1;t[++s]=i.x0,t[++s]=i.y0,t[++s]=i.x3,t[++s]=i.y3,t[++s]=i.x1,t[++s]=i.y1,t[++s]=i.x2,t[++s]=i.y2},T={NORMAL:0,BOLD:1},w={NORMAL:0,ITALIC:1},E={LEFT:0,CENTER:1,RIGHT:2,OUTSIDE_LEFT:3,OUTSIDE_RIGHT:4},y={TOP:0,MIDDLE:1,BOTTOM:2,OUTSIDE_TOP:3,OUTSIDE_BOTTOM:4},x={LEFT_TO_RIGHT:0,TOP_TO_BOTTOM:1,BOTTOM_TO_TOP:2,RIGHT_TO_LEFT:3},C=(t,e,i,s)=>{const n=i-t,o=s-e;return Math.sqrt(n*n+o*o)},D={ASCII:"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",SPACE:" ",TAB:"\t",SOFT_TAB:" ",DOTS:"...",NEW_LINE:"\n"},S=1e-5,b=new t.Point,I=t=>{const e=t.text.plength;return(e>>3)+(0<(7&e)?1:0)<<3},O=(t,e,i,s)=>{let n=3*i-1;const o=3*(i+s)-1;let r=e;for(;n<o;)t[++n]=r,t[++n]=r+1,t[++n]=r+3,t[++n]=r+1,t[++n]=r+2,t[++n]=r+3,r+=4},A=(t,e,i,s,n,o,a,l,c)=>{let u=6*e-1;const p=6*(e+i)-1,_=h(r.NONE),g=d(2,_,1,1);if(null!=s){const e=s.font.size/(n*(l+c)*.5),i=a===T.NORMAL?0:.05;for(;u<p;)t[++u]=o,t[++u]=g,t[++u]=e,t[++u]=0,t[++u]=i,t[++u]=0}else for(;u<p;)t[++u]=0,t[++u]=g,t[++u]=0,t[++u]=0,t[++u]=0,t[++u]=0},R=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f,m,v,T,w)=>{switch(t){case E.LEFT:switch(e){case y.TOP:w.x=h+f*(i+n)+v*(s+o),w.y=l+m*(i+n)+T*(s+o);break;case y.MIDDLE:w.x=.5*(h+_)+f*(i+n)+v*(s-.5*a),w.y=.5*(l+g)+m*(i+n)+T*(s-.5*a);break;case y.BOTTOM:w.x=_+f*(i+n)+v*(s-o-a),w.y=g+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=h+f*(i+n)+v*(s-o-a),w.y=l+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=_+f*(i+n)+v*(s+o),w.y=g+m*(i+n)+T*(s+o)}break;case E.CENTER:switch(e){case y.TOP:w.x=.5*(h+c)+f*(i-.5*r)+v*(s+o),w.y=.5*(l+u)+m*(i-.5*r)+T*(s+o);break;case y.MIDDLE:w.x=.5*(h+d)+f*(i-.5*r)+v*(s-.5*a),w.y=.5*(l+p)+m*(i-.5*r)+T*(s-.5*a);break;case y.BOTTOM:w.x=.5*(_+d)+f*(i-.5*r)+v*(s-o-a),w.y=.5*(g+p)+m*(i-.5*r)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=.5*(h+c)+f*(i-.5*r)+v*(s-o-a),w.y=.5*(l+u)+m*(i-.5*r)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=.5*(_+d)+f*(i-.5*r)+v*(s+o),w.y=.5*(g+p)+m*(i-.5*r)+T*(s+o)}break;case E.RIGHT:switch(e){case y.TOP:w.x=c+f*(i-n-r)+v*(s+o),w.y=u+m*(i-n-r)+T*(s+o);break;case y.MIDDLE:w.x=.5*(c+d)+f*(i-n-r)+v*(s-.5*a),w.y=.5*(u+p)+m*(i-n-r)+T*(s-.5*a);break;case y.BOTTOM:w.x=d+f*(i-n-r)+v*(s-o-a),w.y=p+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=c+f*(i-n-r)+v*(s-o-a),w.y=u+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=d+f*(i-n-r)+v*(s+o),w.y=p+m*(i-n-r)+T*(s+o)}break;case E.OUTSIDE_LEFT:switch(e){case y.TOP:w.x=h+f*(i-n-r)+v*(s+o),w.y=l+m*(i-n-r)+T*(s+o);break;case y.MIDDLE:w.x=.5*(h+_)+f*(i-n-r)+v*(s-.5*a),w.y=.5*(l+g)+m*(i-n-r)+T*(s-.5*a);break;case y.BOTTOM:w.x=_+f*(i-n-r)+v*(s-o-a),w.y=g+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=h+f*(i-n-r)+v*(s-o-a),w.y=l+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=_+f*(i-n-r)+v*(s+o),w.y=g+m*(i-n-r)+T*(s+o)}break;case E.OUTSIDE_RIGHT:switch(e){case y.TOP:w.x=c+f*(i+n)+v*(s+o),w.y=u+m*(i+n)+T*(s+o);break;case y.MIDDLE:w.x=.5*(c+d)+f*(i+n)+v*(s-.5*a),w.y=.5*(u+p)+m*(i+n)+T*(s-.5*a);break;case y.BOTTOM:w.x=d+f*(i+n)+v*(s-o-a),w.y=p+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=c+f*(i+n)+v*(s-o-a),w.y=u+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=d+f*(i+n)+v*(s+o),w.y=p+m*(i+n)+T*(s+o)}}},M=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f,m,v,T,I,O,A,M,P,B)=>{const z=.5*r,F=.5*a,H=B.a,G=B.b,V=B.c,W=B.d,K=B.tx,X=B.ty,Y=n-z,j=o-F,$=n+z,q=o-F,Z=n+z,J=o+F,Q=H*Y+V*j+K,tt=G*Y+W*j+X,et=H*$+V*q+K,it=G*$+W*q+X,st=H*Z+V*J+K,nt=G*Z+W*J+X,ot=Q+(st-et),rt=tt+(nt-it),at=C(Q,tt,et,it);let ht=C(0,0,H,G),lt=1,ct=0;if(S<ht){const t=1/ht;lt=H*t,ct=G*t}const ut=C(Q,tt,ot,rt);let dt=C(0,0,V,W),pt=0,_t=1;if(S<ht){const t=1/dt;pt=V*t,_t=W*t}const gt=b;switch(v){case x.LEFT_TO_RIGHT:break;case x.TOP_TO_BOTTOM:gt.set(pt,_t),pt=-lt,_t=-ct,lt=gt.x,ct=gt.y,gt.x=dt,dt=ht,ht=gt.x;break;case x.BOTTOM_TO_TOP:gt.set(pt,_t),pt=lt,_t=ct,lt=-gt.x,ct=-gt.y,gt.x=dt,dt=ht,ht=gt.x;break;case x.RIGHT_TO_LEFT:lt=-lt,ct=-ct,pt=-pt,_t=-_t}let ft=0,mt=0,vt=0,Tt=l*dt,wt=Math.max(0,l+m)*dt,Et=0,yt=1;const xt=h.characters;let Ct=0;for(let t=0,e=c.length;t<e;++t){const e=c[t];if(e!==D.NEW_LINE){0<Ct&&(Et+=Math.max(0,Ct+f));const t=xt.get(e);t?(Ct=t.advance,vt=t.height):Ct=0}else Et+=Ct,Ct=0,ft=Math.max(ft,Et),Et=0,mt+=wt,yt+=1}if(Et+=Ct,ft=Math.max(ft,Et),mt+=Tt,Et=0,A&&k(d,p)){let t=0,e=0;switch(v){case x.LEFT_TO_RIGHT:case x.RIGHT_TO_LEFT:t=Math.max(0,at-2*T),e=Math.max(0,ut-2*I);break;case x.TOP_TO_BOTTOM:case x.BOTTOM_TO_TOP:t=Math.max(0,ut-2*I),e=Math.max(0,at-2*T)}const i=ft*ht*(l/h.font.size),s=mt,n=Math.min(1,Math.min(t/i,e/s));l*=n,Tt*=n,wt*=n,mt*=n}const Dt=l/h.font.size,St=ht*Dt;ft*=St,vt*=dt*Dt;let bt=0,It=0,Ot=ft;switch(v){case x.LEFT_TO_RIGHT:R(d,p,_,g,T,I,ft,mt,Q,tt,et,it,st,nt,ot,rt,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=at-2*T);break;case x.TOP_TO_BOTTOM:R((t=>{switch(t){case y.TOP:return E.LEFT;case y.MIDDLE:return E.CENTER;case y.BOTTOM:return E.RIGHT;case y.OUTSIDE_TOP:return E.OUTSIDE_LEFT;case y.OUTSIDE_BOTTOM:return E.OUTSIDE_RIGHT}})(p),(t=>{switch(t){case E.LEFT:return y.BOTTOM;case E.CENTER:return y.MIDDLE;case E.RIGHT:return y.TOP;case E.OUTSIDE_LEFT:return y.OUTSIDE_BOTTOM;case E.OUTSIDE_RIGHT:return y.OUTSIDE_TOP}})(d),g,_,I,T,ft,mt,et,it,st,nt,ot,rt,Q,tt,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=ut-2*I);break;case x.BOTTOM_TO_TOP:R((t=>{switch(t){case y.TOP:return E.RIGHT;case y.MIDDLE:return E.CENTER;case y.BOTTOM:return E.LEFT;case y.OUTSIDE_TOP:return E.OUTSIDE_RIGHT;case y.OUTSIDE_BOTTOM:return E.OUTSIDE_LEFT}})(p),(t=>{switch(t){case E.LEFT:return y.TOP;case E.CENTER:return y.MIDDLE;case E.RIGHT:return y.BOTTOM;case E.OUTSIDE_LEFT:return y.OUTSIDE_TOP;case E.OUTSIDE_RIGHT:return y.OUTSIDE_BOTTOM}})(d),g,_,I,T,ft,mt,ot,rt,Q,tt,et,it,st,nt,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=ut-2*I);break;case x.RIGHT_TO_LEFT:R((t=>{switch(t){case E.LEFT:return E.RIGHT;case E.CENTER:return E.CENTER;case E.RIGHT:return E.LEFT;case E.OUTSIDE_LEFT:return E.OUTSIDE_RIGHT;case E.OUTSIDE_RIGHT:return E.OUTSIDE_LEFT}})(d),(t=>{switch(t){case y.TOP:return y.BOTTOM;case y.MIDDLE:return y.MIDDLE;case y.BOTTOM:return y.TOP;case y.OUTSIDE_TOP:return y.OUTSIDE_BOTTOM;case y.OUTSIDE_BOTTOM:return y.OUTSIDE_TOP}})(p),_,g,T,I,ft,mt,st,nt,ot,rt,Q,tt,et,it,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=at-2*T)}if(Ot<ft){const t=.5*(ft-Ot);M[0]=bt+lt*t,M[1]=It+ct*t,M[2]=lt,M[3]=ct,M[4]=pt,M[5]=_t,M[6]=Ot,M[7]=mt,M[8]=ht,M[9]=dt}else M[0]=bt,M[1]=It,M[2]=lt,M[3]=ct,M[4]=pt,M[5]=_t,M[6]=ft,M[7]=mt,M[8]=ht,M[9]=dt;const At=P.x0,Rt=P.x1,Mt=P.x3,kt=P.y0,Lt=P.y1,Nt=P.y3,Pt=Rt-At,Bt=Lt-kt,zt=Mt-At,Ut=Nt-kt,Ft=wt*pt,Ht=wt*_t,Gt=St*lt,Vt=St*ct,Wt=.5*(vt-Tt),Kt=Wt*pt,Xt=Wt*_t,Yt=u===w.NORMAL?0:.25*l;let jt=bt-Kt+Yt*Gt,$t=It-Xt+Yt*Vt,qt=bt+Kt+Tt*pt,Zt=It+Xt+Tt*_t,Jt=jt,Qt=$t,te=qt,ee=Zt;Et=0,Ct=0,yt=0;let ie=2*i;for(let i=0,s=c.length;i<s;i+=1,ie+=8){const n=c[i];if(n!==D.NEW_LINE){const o=Et;0<Ct&&(Et+=Math.max(0,Ct+f));const r=Et*Gt,a=Et*Vt;Jt=jt+r,Qt=$t+a,te=qt+r,ee=Zt+a;const l=xt.get(n);if(yt+=1,l){const n=l.advance;if(Ot<(Et+n)*St){const r=xt.get(D.DOTS);if(r){if(1<yt&&Ot<(Et+r.advance)*St){Et=o,ie-=8,yt-=1;const t=Et*Gt,e=Et*Vt;Jt=jt+t,Qt=$t+e,te=qt+t,ee=Zt+e}for(Ct=r.advance,N(t,e,ie,r,h,Gt,Vt,Jt,Qt,te,ee,Pt,Bt,zt,Ut,At,kt),ie+=8;;ie+=8){if(!(i+1<s&&c[i+1]!==D.NEW_LINE)){ie-=8;break}L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt),yt+=1,i+=1}}else Ct=n,L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt)}else Ct=n,N(t,e,ie,l,h,Gt,Vt,Jt,Qt,te,ee,Pt,Bt,zt,Ut,At,kt)}else Ct=0,L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt)}else Et+=Ct,Ct=0,jt+=Ft,$t+=Ht,qt+=Ft,Zt+=Ht,Jt=jt,Qt=$t,te=qt,ee=Zt,L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt),U(t,lt,ct,yt,ie,ft-Et*St,v,d,p),Et=0,yt=0}Et+=Ct,U(t,lt,ct,yt,ie,ft-Et*St,v,d,p);for(const n=2*(i+s);ie<n;ie+=2)t[ie+0]=bt,t[ie+1]=It,e[ie+0]=At,e[ie+1]=kt},k=(t,e)=>{switch(t){case E.LEFT:case E.CENTER:case E.RIGHT:switch(e){case y.TOP:case y.MIDDLE:case y.BOTTOM:return!0}}return!1},L=(t,e,i,s,n,o,r,a,h,l,c)=>{t[i+0]=s,t[i+1]=n,t[i+2]=s,t[i+3]=n,t[i+4]=o,t[i+5]=r,t[i+6]=o,t[i+7]=r,e[i+0]=a,e[i+1]=h,e[i+2]=a,e[i+3]=h,e[i+4]=l,e[i+5]=c,e[i+6]=l,e[i+7]=c},N=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f)=>{const m=s.x-s.origin.x,v=s.width,T=m*o,w=m*r,E=(m+v)*o,y=(m+v)*r;t[i+0]=a+T,t[i+1]=h+w,t[i+2]=a+E,t[i+3]=h+y,t[i+4]=l+E,t[i+5]=c+y,t[i+6]=l+T,t[i+7]=c+w;const x=s.x/n.width,C=s.y/n.height,D=(s.x+s.width)/n.width,S=(s.y+s.height)/n.height,b=u*x,I=d*x,O=u*D,A=d*D,R=p*C,M=_*C,k=p*S,L=_*S;e[i+0]=g+b+R,e[i+1]=f+I+M,e[i+2]=g+O+R,e[i+3]=f+A+M,e[i+4]=g+O+k,e[i+5]=f+A+L,e[i+6]=g+b+k,e[i+7]=f+I+L},P=(t,e,i,s,n)=>{let o=e-8*i-1;for(let e=0;e<i;++e)t[++o]+=s,t[++o]+=n,t[++o]+=s,t[++o]+=n,t[++o]+=s,t[++o]+=n,t[++o]+=s,t[++o]+=n},B=(t,e,i,s,n,o)=>{P(t,e,i,(s*=.5)*n,s*o)},z=(t,e,i,s,n,o)=>{P(t,e,i,s*n,s*o)},U=(t,e,i,s,n,o,r,a,h)=>{if(S<o)switch(r){case x.LEFT_TO_RIGHT:switch(a){case E.OUTSIDE_RIGHT:case E.LEFT:break;case E.CENTER:B(t,n,s,o,e,i);break;case E.OUTSIDE_LEFT:case E.RIGHT:z(t,n,s,o,e,i)}break;case x.TOP_TO_BOTTOM:switch(h){case y.OUTSIDE_BOTTOM:case y.TOP:break;case y.MIDDLE:B(t,n,s,o,e,i);break;case y.OUTSIDE_TOP:case y.BOTTOM:z(t,n,s,o,e,i)}break;case x.BOTTOM_TO_TOP:switch(h){case y.OUTSIDE_BOTTOM:case y.TOP:z(t,n,s,o,e,i);break;case y.MIDDLE:B(t,n,s,o,e,i)}break;case x.RIGHT_TO_LEFT:switch(a){case E.OUTSIDE_RIGHT:case E.LEFT:z(t,n,s,o,e,i);break;case E.CENTER:B(t,n,s,o,e,i)}}},F={NONE:0,CLOSED:1,NON_EXPANDING_WIDTH:2,NON_SHRINKING_WIDTH:4,NON_SCALING_DOT_AND_DASH:8,NON_SCALING_MASK:14,DOTTED:16,DOTTED_DENSELY:32,DOTTED_LOOSELY:64,DOTTED_MASK:112,DASHED:128,DASHED_DENSELY:256,DASHED_LOOSELY:512,DASHED_MASK:896,CURVE:1024,CURVE_SPLINE:1024,CURVE_BEZIER_QUADRATIC:2048,FORMATTER_SHIFT:10,FORMATTER_MASK:1047552,FORMATTER_EXTENSION_LOWEST:512,FORMATTER_EXTENSION_HIGHEST:1023,FORMATTER_CURVE:1,FORMATTER_CURVE_SPLINE:1,FORMATTER_CURVE_BEZIER_QUADRATIC:2},H={NONE:0,VERTEX:1,STEP:2,COLOR:4,UV:8,INDEX:16,VERTEX_AND_STEP:3,VERTEX_STEP_AND_UV:11,ALL:31},G=(t,e,i,s,n,o,r)=>{const a=p(Math.max(0,Math.min(1,e)),Math.max(0,Math.min(1,s)));let h=3*n-1;const l=3*(n+o)-1;for(;h<l;)r[++h]=t,r[++h]=i,r[++h]=a},V={NONE:0,TOP:1,RIGHT:2,BOTTOM:4,LEFT:8,TOP_OR_LEFT:9,TOP_OR_RIGHT:3,BOTTOM_OR_LEFT:12,BOTTOM_OR_RIGHT:6,ALL:15};class W{constructor(t,e,i,s,n){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=s,this.indexCount=n,this.inited=H.NONE,this.sizeX=0,this.sizeY=0,this.transformLocalId=-1,this.strokeAlign=0,this.strokeWidth=0,this.strokeSide=V.NONE,this.strokeStyle=r.NONE,this.colorFill=0,this.alphaFill=0,this.colorStroke=0,this.alphaStroke=0,this.texture=null,this.textureTransformId=-1}reinit(t,e,i,s){return this.buffer===t&&this.vertexOffset===i&&this.indexOffset===s||!!t.check(i,s,this.vertexCount,this.indexCount)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.init(),!0)}isCompatible(t){return!0}updateColor(t,e){const i=e.fill,s=i.color,n=e.visible&&i.enable?i.alpha:0,o=e.stroke,r=o.color,a=e.visible&&o.enable&&0<o.width?o.alpha:0;(!(this.inited&H.COLOR)||s!==this.colorFill||n!==this.alphaFill||r!==this.colorStroke||a!==this.alphaStroke)&&(this.inited|=H.COLOR,this.colorFill=s,this.alphaFill=n,this.colorStroke=r,this.alphaStroke=a,t.updateColors(),G(s,n,r,a,this.vertexOffset,this.vertexCount,t.colors))}buildUnit(e){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;if(s!==e.baseTexture){e.baseTexture=s;const t=this.indexOffset;e.push(i,t)}}}const K=t=>(t.updateTransform(),t.transform.getLocalId()),X=e=>e.texture||t.Texture.WHITE,Y=t=>{const e=t;return null==e._uvs&&t.updateUvs(),e._updateID},j=t=>t._uvs;class ${static setDefaultThemeClass(t){this.DEFAULT_THEME_CLASS=t}static getDefaultThemeClass(){return this.DEFAULT_THEME_CLASS}static getInstance(){if(null==this.INSTANCE){const t=this.getDefaultThemeClass();if(null==t)throw new Error("No default theme class found");this.INSTANCE=new t}return this.INSTANCE}static setInstance(t){const e=this.INSTANCE;return this.INSTANCE=t,e}static get(t){return this.getInstance().get(t)}static set(t,e){this.getInstance().set(t,e)}static getClass(t){return this.getInstance().getClass(t)}static setClass(t,e){this.getInstance().setClass(t,e)}static getAtlas(){return this.getInstance().getAtlas()}}$.DEFAULT_THEME_CLASS=null,$.INSTANCE=null;class q{static get THEME(){const t=this._THEME;if(null!=t)return t;const e=$.getInstance().get("EShape");return this._THEME=e,e}static get FILL_COLOR(){return this.THEME.getFillColor()}static get FILL_ALPHA(){return this.THEME.getFillAlpha()}static get STROKE_COLOR(){return this.THEME.getStrokeColor()}static get STROKE_ALPHA(){return this.THEME.getStrokeAlpha()}static get STROKE_WIDTH(){return this.THEME.getStrokeWidth()}static get STROKE_ALIGN(){return this.THEME.getStrokeAlign()}static get STROKE_SIDE(){return this.THEME.getStrokeSide()}static get STROKE_STYLE(){return this.THEME.getStrokeStyle()}static get TEXT_VALUE(){return this.THEME.getTextValue()}static get TEXT_COLOR(){return this.THEME.getTextColor()}static get TEXT_ALPHA(){return this.THEME.getTextAlpha()}static get TEXT_FAMILY(){return this.THEME.getTextFamily()}static get TEXT_SIZE(){return this.THEME.getTextSize()}static get RADIUS(){return this.THEME.getRadius()}static get SIZE_X(){return this.THEME.getSizeX()}static get SIZE_Y(){return this.THEME.getSizeY()}static get HIGHLIGHT_COLOR(){return this.THEME.getHighlightColor()}static get CURVE_SEGMENT_COUNT(){return this.THEME.getCurveSegmentCount()}}const Z={NONE:0,CIRCLE:1,TRIANGLE:2,RECTANGLE:3};class J{constructor(t,e,i,s){this._parent=t,this._enable=e,this._color=i,this._alpha=s}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.enable,t.color,t.alpha)}set(t,e,i){let s=!1;void 0!==t&&this._enable!==t&&(this._enable=t,s=!0),void 0!==e&&this._color!==e&&(this._color=e,s=!0),void 0!==i&&this._alpha!==i&&(this._alpha=i,s=!0),s&&this._parent.updateUploaded()}clone(){return new J(this._parent,this._enable,this._color,this._alpha)}toObject(){return{enable:this._enable,color:this._color,alpha:this._alpha}}serialize(t){const e=`[${this._enable?1:0},${this._color},${this._alpha}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getFill(t);if(null!=s)this.set(!!s[0],s[1],s[2]);else{const s=JSON.parse(i[t]);e.setFill(t,s),this.set(!!s[0],s[1],s[2])}}}}class Q{lock(){return this}unlock(){return this}get type(){return Z.NONE}set type(t){}get size(){let e=this._size;return null==e&&(e=new t.Point,this._size=e),e}get transform(){let e=this._transform;return null==e&&(e=new t.Matrix,this._transform=e),e}get fill(){let t=this._fill;return null==t&&(t=new J(this,!0,q.FILL_COLOR,1),this._fill=t),t}updateUploaded(){}copy(t){return this}set(t,e,i){return this}serialize(t){return-1}deserialize(t,e){}}class tt{constructor(){this._marker=new Q}lock(){return this}unlock(){return this}get head(){return this._marker}get tail(){return this._marker}copy(t){return this}serialize(t){return-1}deserialize(t,e){}static getInstance(){let t=this.INSTANCE;return null==t&&(t=new tt,this.INSTANCE=t),t}}const et={TOP:0,LEFT:1,RIGHT:2,BOTTOM:3};class it{constructor(t){this._parent=t,this._id=0,this._values=[0,0,0,0],this._segments=[],this._style=F.NONE,this._size=-1,this._position=et.TOP,this._updatedSize=NaN,this._updatedParentSizeX=NaN,this._updatedParentSizeY=NaN,this._updatedPosition=NaN}getComputedSize(t,e,i,s){if(0<=t)return t;switch(e){case et.TOP:case et.BOTTOM:return Math.abs(s);case et.RIGHT:case et.LEFT:return Math.abs(i)}return 0}onSizeChange(){this.update()}update(){const t=this._parent.size,e=t.x,i=t.y,s=this._position,n=this._size;if(this._updatedSize!==n||this._updatedParentSizeX!==e||this._updatedParentSizeY!==i||this._updatedPosition!==s){this._id+=1,this._updatedSize=n,this._updatedParentSizeX=e,this._updatedParentSizeY=i,this._updatedPosition=s;const t=.5*e,o=.5*i,r=this.getComputedSize(n,s,e,i),a=this._values;switch(s){case et.TOP:a[0]=0,a[1]=-o,a[2]=0,a[3]=-o+r;break;case et.RIGHT:a[0]=t,a[1]=0,a[2]=t-r,a[3]=0;break;case et.BOTTOM:a[0]=0,a[1]=o,a[2]=0,a[3]=o-r;break;case et.LEFT:a[0]=-t,a[1]=0,a[2]=-t+r,a[3]=0}}}get length(){return 2}get plength(){return 2}get id(){return this.update(),this._id}get values(){return this.update(),this._values}set values(t){}get segments(){return this._segments}set segments(t){}get size(){return this._size}set size(t){this.moveTo(void 0,t,void 0)}get position(){return this._position}set position(t){this.moveTo(t,void 0,void 0)}get style(){return this._style}set style(t){this.moveTo(void 0,void 0,t)}get marker(){let t=this._marker;return null==t&&(t=tt.getInstance(),this._marker=t),t}getMarker(){}get formatter(){return null}set formatter(t){}get formatted(){return this}copy(t){return t instanceof it?this.moveTo(t.position,t.size,t.style):this.moveTo(void 0,void 0,t.style)}set(t,e,i){let s,n;if(null!=t){const e=t[0];if(0===e){const e=t[1];s=e<=0?et.TOP:et.BOTTOM,n=Math.abs(t[3]-e)}else s=e<=0?et.LEFT:et.RIGHT,n=Math.abs(t[2]-e)}return this.moveTo(s,n,i)}moveTo(t,e,i){let s=!1;return null!=i&&this._style!==i&&(this._style=i,s=!0),null!=t&&this._position!==t&&(this._position=t,s=!0),null!=e&&this._size!==e&&(this._size=e,s=!0),s&&this._parent.updateUploaded(),this}clone(t){return new it(t).copy(this)}toPoints(e){const i=[],s=this.values;for(let n=0,o=s.length;n<o;n+=2){const o=new t.Point(s[n+0],s[n+1]);i.push(e.apply(o,o))}return i}serialize(t){return t.addResource(`[${this._position},${this._size},${this._style}]`)}deserialize(t,e){if(0<=t&&t<e.resources.length){const i=e.resources[t],s=JSON.parse(i);this.moveTo(s[0],s[1],s[2])}}calcHitPointAbs(t,e,i,s,n,o,r,a){if(2<=this.length){const i=this._values;if(r(t,e,i[0],i[1],i[2],i[3],0,n,a))return!0}return!1}}const st={NONE:0,LINE:1,MARKER_TAIL:2,MARKER_HEAD:3,TEXT:4,CHILDREN:5},nt={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_LEFT:4,BOTTOM_RIGHT:8,TOP:3,BOTTOM:12,LEFT:5,RIGHT:10,ALL:15};class ot{static add(t){ot.INSTANCES.push(t)}static first(){const t=ot.INSTANCES;if(0<t.length)return t[0];throw new Error("No application found.")}static last(){const t=ot.INSTANCES;if(0<t.length)return t[t.length-1];throw new Error("No application found.")}static get(t){const e=ot.INSTANCES;return 0<=t&&t<e.length?e[t]:null}static indexOf(t){return ot.INSTANCES.indexOf(t)}static size(){return ot.INSTANCES.length}static getStage(t){let e=t;for(;e.parent;)e=e.parent;return"application"in e&&"layer"in e?e:null}static find(t){const e=this.getStage(t);return e?e.layer.application:null}static getLayerBase(t){const e=this.getStage(t);return e?e.layer.application.getLayerBase():null}static getLayerOverlay(t){const e=this.getStage(t);return e?e.layer.application.getLayerOverlay():null}static getLayer(t){const e=this.getStage(t);return e?e.layer:null}static getResolution(t){var e;const i=this.getLayer(t);return i?i.renderer.resolution:null!==(e=window.devicePixelRatio)&&void 0!==e?e:1}static update(t){if(t){const e=this.getStage(t);e&&e.layer.update()}else{const t=ot.INSTANCES;for(let e=0,i=t.length;e<i;++e)t[e].update()}}static render(t){if(t){const e=this.getStage(t);e&&e.layer.render()}else{const t=ot.INSTANCES;for(let e=0,i=t.length;e<i;++e)t[e].render()}}}ot.INSTANCES=[];class rt{constructor(){this.values=[]}add(t,e){const i=this.values;return null!=e?i.splice(e,0,t):i.push(t),this}addAll(t){const e=this.values;for(let i=0,s=t.length;i<s;++i)e.push(t[i]);return this}clearAndAdd(t){return this.clear(),this.add(t),this}clearAndAddAll(t){return this.clear(),this.addAll(t),this}indexOf(t){const e=this.values;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return i;for(let i=0,s=e.length;i<s;++i)if(e[i].isEquals(t))return i;return-1}get(t){const e=this.values;return 0<=t||t<e.length?e[t]:null}set(t,e){const i=this.values;if(0<=t||t<i.length){const s=i[t];return i[t]=e,s}return null}remove(t){const e=this.values;return 0<=t||t<e.length?e.splice(t,1)[0]:null}clear(){return this.values.length=0,this}size(){return this.values.length}swap(t,e){const i=this.values,s=i[e];return i[e]=i[t],i[t]=s,this}serialize(t){const e=[],i=this.values;for(let s=0,n=i.length;s<n;++s)e.push(i[s].serialize(t));return e}}class at{constructor(t){this._parent=t,this._edges=new Set}add(t){const e=this._edges;return!e.has(t)&&(e.add(t),!0)}contains(t){return this._edges.has(t)}size(){return this._edges.size}remove(t){return this._edges.delete(t)}clear(){return 0<this._edges.size&&(this._edges.clear(),!0)}copy(t){const e=this._edges;return e.clear(),t.each(t=>{e.add(t)}),this}each(t){return this._edges.forEach(t),this}fit(t){this._edges.forEach(this.toOnFitBound(t))}toOnFitBound(t){if(t){let t=this._onFitBoundForcibly;return null==t&&(t=this.newOnFitBound(!0),this._onFitBoundForcibly=t),t}{let t=this._onFitBound;return null==t&&(t=this.newOnFitBound(!1),this._onFitBound=t),t}}newOnFitBound(t){return e=>{this.onFit(e,t)}}onFit(t,e){t.fit(e)}attach(){const t=this._parent;return this._edges.forEach(e=>{e.set(t)}),this}detach(t){return this._edges.forEach(e=>{null!=t&&t.has(e.parent)||e.set(null)}),this}}const ht={NONE:0,TRANSFORM:1,SIZE:2,STYLE:4,ACTION:8,POINTS:16,STATE:32,IMAGE:64,DATA:128,TAG:128,CONNECTOR:256,CAPABILITY:512,ALL:1023},lt={HOVERED:"HOVERED",ACTIVE:"ACTIVE",FOCUSED:"FOCUSED",UNFOCUSABLE:"UNFOCUSABLE",FOCUS_ROOT:"FOCUS_ROOT",FOCUS_REVERSE:"FOCUS_REVERSE",READ_ONLY:"READ_ONLY",DISABLED:"DISABLED",GESTURING:"GESTURING",PRESSED:"PRESSED",INVALID:"INVALID",PROCESSING:"PROCESSING",SUCCEEDED:"SUCCEEDED",FAILED:"FAILED",WARNED:"WARNED",CHANGED:"CHANGED",ALTERNATED:"ALTERNATED",NEW_WINDOW:"NEW_WINDOW"};class ct{constructor(t){this._stateToTargets=new Map,this._interval=t,this._onTimeBound=()=>this.onTime()}get interval(){return this._interval}add(t,e){const i=this._stateToTargets;let s=i.get(t);return null==s?(s=new Set,s.add(e),i.set(t,s),i.size<=1&&this.start()):s.add(e),this}remove(t,e){const i=this._stateToTargets,s=i.get(t);return null!=s&&s.has(e)&&(s.delete(e),e.remove(t),s.size<=0&&i.delete(t),i.size<=0&&this.stop()),this}start(){return null==this._timeoutId&&this.onTime(),this}stop(){const t=this._timeoutId;return null!=t&&(clearTimeout(t),this._timeoutId=void 0),this}onTime(){const t=Date.now(),e=this.interval,i=this.newValue(t,e),s=this.newOn(t,e);this._stateToTargets.forEach((t,e)=>{t.forEach(t=>{t.set(e,i,s)})}),this._timeoutId=window.setTimeout(this._onTimeBound,Math.max(0,e-t%e))}}class ut extends ct{newValue(t,e){return null}newOn(t,e){return Math.round(t/e)%2==0}}class dt{constructor(t,e){this._parent=t,this._stateToInterval=new Map,this._intervalToDatum=e}add(t,e){const i=this._stateToInterval,s=i.get(t);if(s===e)return this;if(null!=s){i.delete(t);const e=this._intervalToDatum.get(s);null!=e&&e.remove(t,this._parent)}i.set(t,e);let n=this._intervalToDatum.get(e);return null==n&&(n=this.newDatum(e),this._intervalToDatum.set(e,n)),n.add(t,this._parent),this}remove(t){const e=this._stateToInterval.get(t);if(null==e)return this;this._stateToInterval.delete(t);const i=this._intervalToDatum.get(e);return null==i||i.remove(t,this._parent),this}set(t,e,i){return i?this.add(t,e):this.remove(t)}has(t){return this._stateToInterval.has(t)}clear(){const t=this._parent,e=this._stateToInterval;return e.forEach((e,i)=>{const s=this._intervalToDatum.get(e);null!=s&&s.remove(i,t)}),e.clear(),this}}let pt,_t;class gt extends dt{constructor(t){super(t,null!=pt?pt:pt=new Map)}newDatum(t){return new ut(t)}}class ft extends ct{newValue(t,e){return Math.round(t/e)}newOn(t,e){return!0}}class mt extends dt{constructor(t){super(t,null!=_t?_t:_t=new Map)}newDatum(t){return new ft(t)}}const vt=Array.isArray||(t=>"[object Array]"===Object.prototype.toString.call(t)),Tt=t=>"function"==typeof t,wt=t=>"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t),Et=t=>"string"==typeof t||"[object String]"===Object.prototype.toString.call(t);class yt{constructor(){this._local=new Map,this._parent=null}get local(){return this._local}get parent(){return this._parent}set parent(t){this._parent!==t&&(this.begin(),this._parent=t,this.end())}onParentChange(t,e){this._parent=e,this.begin(),this._parent=t,this.end()}get blinker(){let t=this._blinker;return null==t&&(t=this.newBlinker(),this._blinker=t),t}newBlinker(){return new gt(this)}get ticker(){let t=this._ticker;return null==t&&(t=this.newTicker(),this._ticker=t),t}newTicker(){return new mt(this)}is(t,e){const i=this._local.get(t);return void 0!==i&&(void 0===e||e===i)}in(t,e){return this.is(t,e)||this.under(t,e)}on(t,e){const i=this._parent;return null!=i&&i.is(t,e)}under(t,e){const i=this._parent;return null!=i&&i.in(t,e)}lock(t){return this}unlock(){return this}begin(){return this}end(){return this}checkAdded(t,e){const i=this._local.get(t);return void 0===i||i!==e}add(t,e=null){return this.checkAdded(t,e)&&(this.begin(),this._local.set(t,e),this.end()),this}checkAddedsString(t){const e=this._local;for(let i=0,s=t.length;i<s;++i){const s=e.get(t[i]);if(void 0===s||null!==s)return!0}return!1}checkAddedsObject(t){const e=this._local;for(let i=0,s=t.length;i<s;++i){const s=t[i],n=e.get(s.state);if(void 0===n||n!==s.value)return!0}return!1}addAll(t){if(Et(t))return this.addAllString(arguments);if(vt(t)){if(0<t.length){const e=t[0];return Et(e)?this.addAllString(t):this.addAllObject(t)}return this}return this.addAllObject(arguments)}addAllString(t){if(this.checkAddedsString(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i)e.set(t[i],null);this.end()}return this}addAllObject(t){if(this.checkAddedsObject(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i){const s=t[i];e.set(s.state,s.value)}this.end()}return this}checkRemoved(t){return this._local.has(t)}remove(t){return this.checkRemoved(t)&&(this.begin(),this._local.delete(t),this.end()),this}checkRemovedsString(t){const e=this._local;for(let i=0,s=t.length;i<s;++i)if(e.has(t[i]))return!0;return!1}checkRemovedsObject(t){const e=this._local;for(let i=0,s=t.length;i<s;++i)if(e.has(t[i].state))return!0;return!1}removeAll(t){if(Tt(t))return this.removeAllMatcher(t);if(Et(t))return this.removeAllString(arguments);if(vt(t)){if(0<t.length){const e=t[0];return Et(e)?this.removeAllString(t):this.removeAllObject(t)}return this}return this.removeAllObject(arguments)}removeAllMatcher(t){let e=!1;const i=this._local;return i.forEach((s,n)=>{t(n)&&(e||(e=!0,this.begin()),i.delete(n))}),e&&this.end(),this}removeAllString(t){if(this.checkRemovedsString(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i)e.delete(t[i]);this.end()}return this}removeAllObject(t){if(this.checkRemovedsObject(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i)e.delete(t[i].state);this.end()}return this}set(t,e,i){if(!0===e)null!=t&&this.add(t);else if(!1===e)null!=t&&this.remove(t);else{if(null!=e&&!wt(e))return this.doSet(t,null,e);if(!0===i)null!=t&&this.add(t,e);else{if(!1!==i)return this.doSet(t,e,i);null!=t&&this.remove(t)}}return this}doSet(t,e,i){return null!=t?null!=i?(this.checkAdded(t,e)||this.checkRemoved(i))&&(this.begin(),this._local.set(t,e).delete(i),this.end()):this.add(t,e):null!=i&&this.remove(i),this}setAll(t,e){if(!0===e)null!=t&&this.addAll(t);else if(!1===e)null!=t&&this.removeAll(t);else if(null!=t&&0<t.length){if(null!=e&&0<e.length){const i=t[0];return Et(i)?this.setAllString(t,e):this.setAllObject(t,e)}this.addAll(t)}else null!=e&&this.removeAll(e);return this}setAllString(t,e){if(this.checkAddedsString(t)||this.checkRemovedsString(e)){this.begin();const i=this._local;for(let e=0,s=t.length;e<s;++e)i.set(t[e],null);for(let t=0,s=e.length;t<s;++t)i.delete(e[t]);this.end()}return this}setAllObject(t,e){if(this.checkAddedsObject(t)||this.checkRemovedsString(e)){this.begin();const i=this._local;for(let e=0,s=t.length;e<s;++e){const s=t[e];i.set(s.state,s.value)}for(let t=0,s=e.length;t<s;++t)i.delete(e[t]);this.end()}return this}clear(){const t=this._local;return 0<t.size&&(this.begin(),t.clear(),this.end()),this}valueOf(t,e){const i=this._local.get(t);if(void 0!==i)return null==i&&void 0!==e?e:i;const s=this._parent;return null!=s?void 0!==e?s.valueOf(t,e):s.valueOf(t):e}each(t){return this._local.forEach((e,i)=>{t(i,e)}),this}size(){return this._local.size}copy(t){if(t instanceof yt){this.begin();const e=this._local;e.clear(),t.local.forEach((t,i)=>{e.set(i,t)}),this._parent=t.parent,this.end()}return this}get isHovered(){return this.is(lt.HOVERED)}set isHovered(t){this.set(lt.HOVERED,t)}get inHovered(){return this.in(lt.HOVERED)}get onHovered(){return this.on(lt.HOVERED)}get underHovered(){return this.under(lt.HOVERED)}get isActive(){return this.is(lt.ACTIVE)}set isActive(t){this.set(lt.ACTIVE,t)}get inActive(){return this.in(lt.ACTIVE)}get onActive(){return this.on(lt.ACTIVE)}get underActive(){return this.under(lt.ACTIVE)}get isPressed(){return this.is(lt.PRESSED)}set isPressed(t){this.set(lt.PRESSED,t)}get inPressed(){return this.in(lt.PRESSED)}get onPressed(){return this.on(lt.PRESSED)}get underPressed(){return this.under(lt.PRESSED)}get isReadOnly(){return this.is(lt.READ_ONLY)}set isReadOnly(t){this.set(lt.READ_ONLY,t)}get inReadOnly(){return this.in(lt.READ_ONLY)}get onReadOnly(){return this.on(lt.READ_ONLY)}get underReadOnly(){return this.under(lt.READ_ONLY)}get isEnabled(){return!this.is(lt.DISABLED)}set isEnabled(t){this.set(lt.DISABLED,!t)}get inEnabled(){return!this.in(lt.DISABLED)}get onEnabled(){return!this.on(lt.DISABLED)}get underEnabled(){return!this.under(lt.DISABLED)}get isDisabled(){return this.is(lt.DISABLED)}set isDisabled(t){this.set(lt.DISABLED,t)}get inDisabled(){return this.in(lt.DISABLED)}get onDisabled(){return this.on(lt.DISABLED)}get underDisabled(){return this.under(lt.DISABLED)}get isActionable(){return!this.in(lt.DISABLED)&&!this.in(lt.READ_ONLY)}get isGesturing(){return this.is(lt.GESTURING)}set isGesturing(t){this.set(lt.GESTURING,t)}get inGesturing(){return this.in(lt.GESTURING)}get onGesturing(){return this.on(lt.GESTURING)}get underGesturing(){return this.under(lt.GESTURING)}get isFocused(){return this.is(lt.FOCUSED)}set isFocused(t){this.set(lt.FOCUSED,t)}get inFocused(){return this.in(lt.FOCUSED)}get onFocused(){return this.on(lt.FOCUSED)}get underFocused(){return this.under(lt.FOCUSED)}get isFocusRoot(){return this.is(lt.FOCUS_ROOT)}set isFocusRoot(t){this.set(lt.FOCUS_ROOT,t)}get inFocusRoot(){return this.in(lt.FOCUS_ROOT)}get onFocusRoot(){return this.on(lt.FOCUS_ROOT)}get underFocusRoot(){return this.under(lt.FOCUS_ROOT)}get isFocusReverse(){return this.is(lt.FOCUS_REVERSE)}set isFocusReverse(t){this.set(lt.FOCUS_REVERSE,t)}get inFocusReverse(){return this.in(lt.FOCUS_REVERSE)}get onFocusReverse(){return this.on(lt.FOCUS_REVERSE)}get underFocusReverse(){return this.under(lt.FOCUS_REVERSE)}get isFocusable(){return!this.is(lt.UNFOCUSABLE)}set isFocusable(t){this.set(lt.UNFOCUSABLE,!t)}get inFocusable(){return!this.in(lt.UNFOCUSABLE)}get onFocusable(){return!this.on(lt.UNFOCUSABLE)}get underFocusable(){return!this.under(lt.UNFOCUSABLE)}get isUnfocusable(){return this.is(lt.UNFOCUSABLE)}set isUnfocusable(t){this.set(lt.UNFOCUSABLE,t)}get inUnfocusable(){return this.in(lt.UNFOCUSABLE)}get onUnfocusable(){return this.on(lt.UNFOCUSABLE)}get underUnfocusable(){return this.under(lt.UNFOCUSABLE)}get isInvalid(){return this.is(lt.INVALID)}set isInvalid(t){this.set(lt.INVALID,t)}get inInvalid(){return this.in(lt.INVALID)}get onInvalid(){return this.on(lt.INVALID)}get underInvalid(){return this.on(lt.INVALID)}get isProcessing(){return this.is(lt.PROCESSING)}set isProcessing(t){this.set(lt.PROCESSING,t)}get inProcessing(){return this.in(lt.PROCESSING)}get onProcessing(){return this.on(lt.PROCESSING)}get underProcessing(){return this.under(lt.PROCESSING)}get isSucceeded(){return this.is(lt.SUCCEEDED)}set isSucceeded(t){this.set(lt.SUCCEEDED,t)}get inSucceeded(){return this.in(lt.SUCCEEDED)}get onSucceeded(){return this.on(lt.SUCCEEDED)}get underSucceeded(){return this.under(lt.SUCCEEDED)}get isFailed(){return this.is(lt.FAILED)}set isFailed(t){this.set(lt.FAILED,t)}get inFailed(){return this.in(lt.FAILED)}get onFailed(){return this.on(lt.FAILED)}get underFailed(){return this.under(lt.FAILED)}get isWarned(){return this.is(lt.WARNED)}set isWarned(t){this.set(lt.WARNED,t)}get inWarned(){return this.in(lt.WARNED)}get onWarned(){return this.on(lt.WARNED)}get underWarned(){return this.on(lt.WARNED)}get isChanged(){return this.is(lt.CHANGED)}set isChanged(t){this.set(lt.CHANGED,t)}get inChanged(){return this.in(lt.CHANGED)}get onChanged(){return this.on(lt.CHANGED)}get underChanged(){return this.on(lt.CHANGED)}get isAlternated(){return this.is(lt.ALTERNATED)}set isAlternated(t){this.set(lt.ALTERNATED,t)}get inAlternated(){return this.in(lt.ALTERNATED)}get onAlternated(){return this.on(lt.ALTERNATED)}get underAlternated(){return this.on(lt.ALTERNATED)}toObject(){const t=[];return this._local.forEach((e,i)=>{t.push(i)}),{local:t}}toString(){return JSON.stringify(this.toObject())}}class xt extends yt{constructor(t){super(),this._onChange=t,this._isLocked=0,this._isSaved=!1,this._doSave=!0}lock(t){return this._isLocked+=1,!1===t&&(this._doSave=!1),this}unlock(){return this._isLocked-=1,this.end()}get saved(){let t=this._saved;return null==t&&(t=new yt,this._saved=t),t}begin(){return this._doSave&&!this._isSaved&&(this._isSaved=!0,this.saved.copy(this)),this}end(){return this._isLocked<=0&&(this._doSave=!0,this._isSaved&&(this._isSaved=!1,this.onChange(this,this.saved))),this}onChange(t,e){this._onChange(t,e)}}const Ct={CLICKED:"CLICKED",DBL_CLICKED:"DBL_CLICKED",DOWN:"DOWN",UP:"UP",UP_OUTSIDE:"UP_OUTSIDE",RIGHT_CLICKED:"RIGHT_CLICKED",RIGHT_DOWN:"RIGHT_DOWN",RIGHT_UP:"RIGHT_UP",RIGHT_UP_OUTSIDE:"RIGHT_UP_OUTSIDE",RIGHT_PRESSED:"RIGHT_PRESSED",ACTIVATED:"ACTIVATED",DEACTIVATED:"DEACTIVATED"};class Dt extends xt{onChange(t,e){t.isActive?e.isActive||this._local.set(Ct.ACTIVATED,null).delete(Ct.DEACTIVATED):e.isActive&&this._local.set(Ct.DEACTIVATED,null).delete(Ct.ACTIVATED),super.onChange(t,e)}get isClicked(){return this.is(Ct.CLICKED)}set isClicked(t){this.set(Ct.CLICKED,t)}get inClicked(){return this.in(Ct.CLICKED)}get onClicked(){return this.on(Ct.CLICKED)}get underClicked(){return this.under(Ct.CLICKED)}get isDblClicked(){return this.is(Ct.DBL_CLICKED)}set isDblClicked(t){this.set(Ct.DBL_CLICKED,t)}get inDblClicked(){return this.in(Ct.DBL_CLICKED)}get onDblClicked(){return this.on(Ct.DBL_CLICKED)}get underDblClicked(){return this.under(Ct.DBL_CLICKED)}get isDown(){return this.is(Ct.DOWN)}set isDown(t){this.set(Ct.DOWN,t)}get inDown(){return this.in(Ct.DOWN)}get onDown(){return this.on(Ct.DOWN)}get underDown(){return this.under(Ct.DOWN)}get isUp(){return this.is(Ct.UP)}set isUp(t){this.set(Ct.UP,t)}get inUp(){return this.in(Ct.UP)}get onUp(){return this.on(Ct.UP)}get underUp(){return this.under(Ct.UP)}get isUpOutside(){return this.is(Ct.UP_OUTSIDE)}set isUpOutside(t){this.set(Ct.UP_OUTSIDE,t)}get inUpOutside(){return this.in(Ct.UP_OUTSIDE)}get onUpOutside(){return this.on(Ct.UP_OUTSIDE)}get underUpOutside(){return this.under(Ct.UP_OUTSIDE)}get isRightClicked(){return this.is(Ct.RIGHT_CLICKED)}set isRightClicked(t){this.set(Ct.RIGHT_CLICKED,t)}get inRightClicked(){return this.in(Ct.RIGHT_CLICKED)}get onRightClicked(){return this.on(Ct.RIGHT_CLICKED)}get underRightClicked(){return this.under(Ct.RIGHT_CLICKED)}get isRightDown(){return this.is(Ct.RIGHT_DOWN)}set isRightDown(t){this.set(Ct.RIGHT_DOWN,t)}get inRightDown(){return this.in(Ct.RIGHT_DOWN)}get onRightDown(){return this.on(Ct.RIGHT_DOWN)}get underRightDown(){return this.under(Ct.RIGHT_DOWN)}get isRightUp(){return this.is(Ct.RIGHT_UP)}set isRightUp(t){this.set(Ct.RIGHT_UP,t)}get inRightUp(){return this.in(Ct.RIGHT_UP)}get onRightUp(){return this.on(Ct.RIGHT_UP)}get underRightUp(){return this.under(Ct.RIGHT_UP)}get isRightUpOutside(){return this.is(Ct.RIGHT_UP_OUTSIDE)}set isRightUpOutside(t){this.set(Ct.RIGHT_UP_OUTSIDE,t)}get inRightUpOutside(){return this.in(Ct.RIGHT_UP_OUTSIDE)}get onRightUpOutside(){return this.on(Ct.RIGHT_UP_OUTSIDE)}get underRightUpOutside(){return this.under(Ct.RIGHT_UP_OUTSIDE)}get isRightPressed(){return this.is(Ct.RIGHT_PRESSED)}set isRightPressed(t){this.set(Ct.RIGHT_PRESSED,t)}get inRightPressed(){return this.in(Ct.RIGHT_PRESSED)}get onRightPressed(){return this.on(Ct.RIGHT_PRESSED)}get underRightPressed(){return this.under(Ct.RIGHT_PRESSED)}get isActivated(){return this.is(Ct.ACTIVATED)}set isActivated(t){this.set(Ct.ACTIVATED,t)}get inActivated(){return this.in(Ct.ACTIVATED)}get onActivated(){return this.on(Ct.ACTIVATED)}get underActivated(){return this.under(Ct.ACTIVATED)}get isDeactivated(){return this.is(Ct.DEACTIVATED)}set isDeactivated(t){this.set(Ct.DEACTIVATED,t)}get inDeactivated(){return this.in(Ct.DEACTIVATED)}get onDeactivated(){return this.on(Ct.DEACTIVATED)}get underDeactivated(){return this.under(Ct.DEACTIVATED)}}class St extends t.Transform{constructor(e){super(),this.internalTransform=new t.Matrix,this._parent=e}onChange(){super.onChange(),this._parent.onTransformChange()}updateSkew(){super.updateSkew(),this._parent.onTransformChange()}getLocalIdCurrent(){return this._currentLocalID}getLocalId(){return this._localID}getParentId(){return this._parentID}getWorldId(){return this._worldID}updateTransform(t){const e=this._currentLocalID,i=this._worldID;super.updateTransform(t);const s=this._currentLocalID,n=this._worldID;if(e!==s){const e=this.localTransform,i=this.internalTransform;e.copyTo(i),t instanceof St&&i.prepend(t.internalTransform)}else if(i!==n){const e=this.localTransform,i=this.internalTransform;t instanceof St&&(e.copyTo(i).prepend(t.internalTransform),this._currentLocalID+=1,this._localID=this._currentLocalID)}}}class bt{constructor(){this.x=0,this.y=0,this.width=0,this.height=0,this.strokeWidth=0,this.strokeScale=1,this.strokeAlign=0}set(t,e,i,s,n,o,r){return this.x=t,this.y=e,this.width=i,this.height=s,this.strokeWidth=n,this.strokeScale=o,this.strokeAlign=r,this}}const It=(t,e,i,s)=>-i<=t&&t<=+i&&-s<=e&&e<=+s,Ot={NONE:0,ID:1,POSITION:2,WIDTH:4,HEIGHT:8,ROTATION:16,SKEW:32,ALIGN:0,REPLACING:64,GROUPING:128,UNGROUPING:256,FILL:512,STROKE:1024,STROKE_SIDE:2048,BORDER_RADIUS:4096,TEXT:8192,TEXTURE:16384,TAG:32768,DATA:32768,DATA_MAPPING:1048576,ACTION:65536,CURSOR:131072,ORDER_IN_LAYER:262144,CHILDREN:524288,LINE:2097152,LINE_TAIL:4194304,LINE_HEAD:8388608,COORDINATE:62,SHAPE:14681792,LAYER:262144,PRIMITIVE:15722239,GROUP:15722495,EMBEDDED:1417471,EMBEDDED_ACCEPTOR_EDGE:517759,CONNECTOR:15722177,ALL:16777215};class At{constructor(){this.added=Ot.NONE,this.removed=Ot.NONE,this.locked=Ot.NONE}add(t){return this.removed&=~t,this.added|=t,this}remove(t){return this.added&=~t,this.removed|=t,this}lock(t){return this.locked|=t,this}unlock(t){return this.locked&=~t,this}clear(){return this.added=Ot.NONE,this.removed=Ot.NONE,this.locked=Ot.NONE,this}set(t,e,i){return null!=t&&(this.added=t),null!=e&&(this.removed=e),null!=i&&(this.locked=i),this}copy(t){return this.added=t.added,this.removed=t.removed,this.locked=t.locked,this}}class Rt{constructor(){this._count=0,this._flag=0}lock(){return this._count+=1,1===this._count&&(this._flag=0,!0)}unlock(){return this._count-=1,this._count<=0&&0!==this._flag}isLocked(t){return 0<this._count&&(this._flag|=t?3:1,!0)}isHigh(){return 1<this._flag}}const Mt={TRANSFORM_CHILD:1,TRANSFORM_THIS:2,TRANSFORM_PARENT:4,TRANSFORM:7,UPLOADED:8,TRANSFORM_AND_UPLOADED:15,CONNECTOR:16,ALL:31};class kt extends t.utils.EventEmitter{constructor(t){super(),this.id="",this.uuid=0,this.type=t,this.transform=this.newTransform(),this.action=new rt,this._visible=!0,this._lockTransformChild=new Rt,this._lockTransformThis=new Rt,this._lockTransformParent=new Rt,this._lockUploaded=new Rt,this._boundsTransformId=-1,this._boundsInternalTransformId=-1,this._boundsLocalTransformId=-1,this.interactive=!1,this.parent=null,this.children=[],this.selected=!1,this.index=0,this.reference=0}newTransform(){return new St(this)}onSizeChange(){this._boundsTransformId=-1,this._boundsInternalTransformId=-1,this._boundsLocalTransformId=-1,this._lockTransformChild.isLocked()||this.callChildTransformChange();const t=this._points;null!=t&&t.onSizeChange(),this.updateUploaded();const e=this._connector;null!=e&&e.fit(!0);const i=this.runtime;null!=i&&i.onResize(this)}onTransformChange(){this._lockTransformChild.isLocked()||this.callChildTransformChange(),this._lockTransformThis.isLocked()||this.onThisTransformChange(),this._lockTransformParent.isLocked()||this.callParentTransformChange()}callChildTransformChange(){const t=this.parent;null!=t&&t.onChildTransformChange()}onThisTransformChange(){this.updateUploaded();const t=this._connector;null!=t&&t.fit(!0)}callParentTransformChange(){const t=this.children;for(let e=0,i=t.length;e<i;++e)t[e].onParentTransformChange()}onParentTransformChange(){this._lockTransformThis.isLocked()||this.onThisTransformChange(),this._lockTransformParent.isLocked()||this.callParentTransformChange()}lock(t){return t&Mt.UPLOADED&&this._lockUploaded.lock(),t&Mt.TRANSFORM_PARENT&&this._lockTransformParent.lock(),t&Mt.TRANSFORM_THIS&&this._lockTransformThis.lock(),t&Mt.TRANSFORM_CHILD&&this._lockTransformChild.lock(),this}unlock(t,e){if(t&Mt.TRANSFORM_CHILD&&this._lockTransformChild.unlock()&&e){const t=this.parent;null!=t&&t.onChildTransformChange()}if(t&Mt.TRANSFORM_THIS&&this._lockTransformThis.unlock()&&e&&this.onThisTransformChange(),t&Mt.TRANSFORM_PARENT&&this._lockTransformParent.unlock()&&e){const t=this.children;for(let e=0,i=t.length;e<i;++e)t[e].onParentTransformChange()}if(t&Mt.UPLOADED){const t=this._lockUploaded;t.unlock()&&e&&this.updateUploaded(t.isHigh())}return this}onChildTransformChange(){}updateUploaded(t){if(this._lockUploaded.isLocked(t))return;const e=this.uploaded;if(null!=e&&e.update(this),!0===t){const t=this.children;for(let e=0,i=t.length;e<i;++e)t[e].updateUploaded(!0)}}get points(){return this._points}get root(){let t=this;for(;t.parent instanceof kt;)t=t.parent;return t}get connector(){let t=this._connector;return null==t&&(t=new at(this),this._connector=t),t}get visible(){if(this._visible){const t=this.parent;return!(t instanceof kt)||t.visible}return!1}set visible(t){this._visible!==t&&(this._visible=t,this.updateUploaded(!0))}get worldVisible(){if(this._visible){const t=this.parent;return!t||t.worldVisible}return!1}toDirty(){const t=this.parent;null!=t&&t.toDirty()}attach(t,e){this.detach(),this.parent=t;const i=t.children;return null!=e&&0<=e&&e<i.length?i.splice(e,0,this):i.push(this),t.onChildTransformChange(),t.toDirty(),this.onAttach(),this}onAttach(){this.uploaded=void 0;const t=this._connector;t&&(t.attach(),t.fit(!0));const e=this.children;for(let t=0,i=e.length;t<i;++t)e[t].onAttach()}detach(t){const e=this.parent;if(e){this.parent=null;const i=e.children,s=i.indexOf(this);0<=s&&(i.splice(s,1),e.onChildTransformChange(),e.toDirty(),this.onDetach(t))}return this}onDetach(t){this.uploaded=void 0;const e=this._connector;e&&e.detach(t);const i=this.children;for(let e=0,s=i.length;e<s;++e)i[e].onDetach(t)}updateTransform(){const e=this.parent;e?(e.parent&&e.updateTransform(),this.transform.updateTransform(e.transform)):this.transform.updateTransform(t.Transform.IDENTITY)}serializeChildren(t){const e=this.children,i=[];for(let s=0,n=e.length;s<n;++s){const n=e[s];i.push(n.serialize(t))}return i}serializeState(t){const e=this.state;return(this.interactive?1:0)|(e.isFocusable?0:2)|(e.isActive?4:0)}serialize(t){const e=this.transform,i=e.position,s=e.pivot,n=this.size,o=this.shortcut,r=null!=o?t.addResource(o):-1,a=this.cursor,h=null!=a?t.addResource(a):-1,l=this.title,c=null!=l?t.addResource(l):-1;let u=Ot.NONE,d=Ot.NONE,p=Ot.NONE;const _=this._capability;return null!=_&&(u=_.added,d=_.removed,p=_.locked),[this.type,t.addResource(this.id),i.x,i.y,n.x,n.y,e.rotation,e.skew.x,this.fill.serialize(t),this.stroke.serialize(t),h,this.text.serialize(t),this.data.serialize(t),this.radius,this.corner,-1,-1,this.action.serialize(t),this.serializeImage(t),this.serializeGradient(t),this.serializeChildren(t),s.x,s.y,this.serializeState(t),r,c,this.uuid,u,d,p]}addUuid(t){this.uuid=t.addUuid(this.uuid);const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].addUuid(t)}updateUuid(t){this.uuid=t.updateUuid(this.uuid);const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].updateUuid(t)}getShapeScale(){const t=this.root.parent;return null!=t&&null!=t.getShapeScale?t.getShapeScale():1}getStrokeWidthScale(t){return t&r.NON_EXPANDING_WIDTH?t&r.NON_SHRINKING_WIDTH?this.getShapeScale():Math.min(1,this.getShapeScale()):t&r.NON_SHRINKING_WIDTH?Math.max(1,this.getShapeScale()):1}getHitTestSize(t){const e=this.size;return t.width=.5*e.x,t.height=.5*e.y,t}toHitTestData(t,e){var i;const s=this.getHitTestSize(null!==(i=kt.WORK_HIT_TEST_DATA)&&void 0!==i?i:kt.WORK_HIT_TEST_DATA=new bt),n=s.width,o=s.height,r=this.transform.pivot,a=t-r.x,h=e-r.y,l=this.stroke,c=l.enable?l.width:0,u=this.getStrokeWidthScale(l.style),d=l.align,p=c*u*d;return s.set(0<=n?+a:-a,0<=o?+h:-h,Math.abs(n)+p,Math.abs(o)+p,c,u,d)}contains(t,e){const i=this.toHitTestData(t,e);return this.containsAbs(i.x,i.y,i.width,i.height,i.strokeWidth,i.strokeScale,i.strokeAlign)?this:this.containsText(t,e)||this.containsChildren(t,e)}containsText(t,e){const i=this.text;if(null!=i.atlas){const s=i.world;if(null!=s){const i=this.transform.internalTransform,n=i.a*t+i.c*e+i.tx-s[0],o=i.b*t+i.d*e+i.ty-s[1],r=s[2]*n+s[3]*o,a=s[4]*n+s[5]*o,h=s[6],l=s[7];if(0<=r&&r<=h&&0<=a&&a<=l)return this}}return null}containsChildren(t,e){const i=this.children;for(let s=i.length-1;0<=s;--s){const n=i[s];n.updateTransform();const o=n.transform.localTransform,r=o.a,a=o.b,h=o.c,l=o.d,c=o.tx,u=o.ty,d=1/(r*l-h*a),p=(l*t-h*e+u*h-c*l)*d,_=(r*e-a*t-u*r+c*a)*d,g=n.contains(p,_);if(null!=g)return g}return null}containsBBox(t,e){const i=this.toHitTestData(t,e);return this.containsAbsBBox(i.x,i.y,i.width,i.height)}containsAbs(t,e,i,s,n,o,r){return this.containsAbsBBox(t,e,i,s)}containsAbsBBox(t,e,i,s){return It(t,e,i,s)}select(t){return!1}toGlobal(t,e,i){return!0!==i&&this.updateTransform(),e.copyFrom(t),this.transform.worldTransform.apply(e,e),e}toLocal(e,i,s,n){return!0!==n&&this.updateTransform(),void 0===s&&(s=new t.Point),s.copyFrom(e),this.transform.worldTransform.applyInverse(s,s),s}getBounds(e,i){!0!==e&&this.updateTransform();const s=this._bounds||new t.Rectangle;this._bounds=s;const n=this.transform.getWorldId();return n!==this._boundsTransformId&&(this._boundsTransformId=n,this.getBounds_(this.transform.worldTransform,s)),null!=i||(i=new t.Rectangle),i.copyFrom(s),i}getBoundsInternal(e,i){!0!==e&&this.updateTransform();const s=this._boundsInternal||new t.Rectangle;this._boundsInternal=s;const n=this.transform.getLocalIdCurrent();return n!==this._boundsInternalTransformId&&(this._boundsInternalTransformId=n,this.getBounds_(this.transform.internalTransform,s)),null!=i||(i=new t.Rectangle),i.copyFrom(s),i}getBoundsLocal(e,i){!0!==e&&this.updateTransform();const s=this._boundsLocal||new t.Rectangle;this._boundsLocal=s;const n=this.transform.getLocalIdCurrent();return n!==this._boundsLocalTransformId&&(this._boundsLocalTransformId=n,this.getBounds_(this.transform.localTransform,s)),null!=i||(i=new t.Rectangle),i.copyFrom(s),i}getBoundsSize(){return this.size}getBounds_(t,e){const i=this.transform.pivot,s=i.x,n=i.y,o=this.getBoundsSize(),r=.5*o.x,a=.5*o.y,h=t.a,l=t.b,c=t.c,u=t.d;let d=-r+s,p=-a+n;const _=h*d+c*p,g=l*d+u*p;d=+r+s,p=-a+n;const f=h*d+c*p,m=l*d+u*p;d=-r+s,p=+a+n;const v=h*d+c*p,T=l*d+u*p;d=+r+s,p=+a+n;const w=h*d+c*p,E=l*d+u*p,y=Math.min(_,f,v,w),x=Math.min(g,m,T,E),C=Math.max(_,f,v,w),D=Math.max(g,m,T,E);return e.x=y+t.tx,e.y=x+t.ty,e.width=C-y,e.height=D-x,e}destroy(){const t=this.children;for(let e=t.length-1;0<=e;--e)t[e].destroy();t.length=0}onStateChange(t,e){const i=this.runtime;null!=i&&i.onStateChange(this,t,e);const s=this.children;for(let i=0,n=s.length;i<n;++i){const n=s[i];n instanceof kt&&n.state.onParentChange(t,e)}}get state(){let t=this._state;return null==t&&(t=new Dt((t,e)=>{this.onStateChange(t,e)}),this._state=t),t}get capability(){let t=this._capability;return null==t&&(t=new At,this._capability=t),t}getCapability(){return this._capability}focus(){return this.setFocused(!0),this}blur(){return this.setFocused(!1),this}setFocused(t){if(this.state.isFocused!==t){const e=ot.getLayer(this);e&&e.getFocusController().set(this,t)}}onKeyDown(t){const e=this.runtime;return!!e&&e.onKeyDown(this,t)}onKeyUp(t){const e=this.runtime;return!!e&&e.onKeyUp(this,t)}update(t){const e=this.runtime;e&&e.update(this,t)}onRender(t,e){const i=this.runtime;i&&i.onRender(this,t,e)}copy(t,e=ht.ALL){if(this.lock(Mt.ALL),this.id=t.id,this.uuid=t.uuid,this.visible=t.visible,e&ht.TRANSFORM){const e=this.transform,i=t.transform;e.position.copyFrom(i.position),e.rotation=i.rotation,e.skew.copyFrom(i.skew),e.pivot.copyFrom(i.pivot),e.scale.copyFrom(i.scale)}if(e&ht.SIZE&&this.size.copyFrom(t.size),e&ht.STYLE&&(this.fill.copy(t.fill),this.stroke.copy(t.stroke),this.text.copy(t.text),this.radius=t.radius,this.corner=t.corner),e&ht.DATA&&this.data.copy(t.data),e&ht.IMAGE&&(this.image=t.image),e&ht.ACTION&&(this.action.clearAndAddAll(t.action.values),this.interactive=t.interactive,this.title=t.title,this.cursor=t.cursor,this.shortcut=t.shortcut),e&ht.POINTS){const e=t.points;if(null!=e){const t=this.points;null!=t&&t.copy(e)}}if(e&ht.STATE&&this.state.lock(!1).copy(t.state).unlock(),e&ht.CONNECTOR)if(t instanceof kt){const e=t._connector;if(e)this.connector.copy(e);else{const t=this._connector;t&&t.clear()}}else{const t=this._connector;t&&t.clear()}if(e&ht.CAPABILITY){const e=t.getCapability();if(null!=e)this.capability.copy(e);else{const t=this._capability;null!=t&&t.clear()}}return this.unlock(Mt.ALL,!0),this}}class Lt{constructor(t,e,i,s,n,o,r,a){this._parent=t,this._enable=e,this._color=i,this._alpha=s,this._width=n,this._align=o,this._side=r,this._style=a}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this._parent.updateUploaded())}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this._parent.updateUploaded())}get side(){return this._side}set side(t){this._side!==t&&(this._side=t,this._parent.updateUploaded())}get style(){return this._style}set style(t){this._style!==t&&(this._style=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.enable,t.color,t.alpha,t.width,t.align,t.side,t.style)}set(t,e,i,s,n,o,r){let a=!1;void 0!==t&&this._enable!==t&&(this._enable=t,a=!0),void 0!==e&&this._color!==e&&(this._color=e,a=!0),void 0!==i&&this._alpha!==i&&(this._alpha=i,a=!0),void 0!==s&&this._width!==s&&(this._width=s,a=!0),void 0!==n&&this._align!==n&&(this._align=n,a=!0),void 0!==o&&this._side!==o&&(this._side=o,a=!0),void 0!==r&&this._style!==r&&(this._style=r,a=!0),a&&this._parent.updateUploaded()}clone(){return new Lt(this._parent,this._enable,this._color,this._alpha,this._width,this._align,this._side,this._style)}toObject(){return{enable:this._enable,color:this._color,alpha:this._alpha,width:this._width,align:this._align,side:this._side,style:this._style}}serialize(t){const e=`[${this._enable?1:0},${this._color},${this._alpha},${this._width},${this._align},${this._side},${this._style}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getStroke(t);if(null!=s)this.set(!!s[0],s[1],s[2],s[3],s[4],s[5],s[6]);else{const s=JSON.parse(i[t]);e.setStroke(t,s),this.set(!!s[0],s[1],s[2],s[3],s[4],s[5],s[6])}}}}const Nt={NONE:0,FROM:1,TO:2,FROM_TO:3};class Pt{constructor(){this._type=Nt.NONE,this._from=0,this._to=1}get type(){return this._type}set type(t){if(this._type!==t){this._type=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}get from(){return this._from}set from(t){if(this._from!==t){this._from=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}get to(){return this._to}set to(t){if(this._to!==t){this._to=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}set(t,e){let i=!1;if(void 0!==t&&void 0!==e)if(null!==t&&null!==e){const s=this._type|Nt.FROM|Nt.TO;this._type===s&&this._from===t&&this._to===e||(this._type=s,this._from=t,this._to=e,i=!0)}else if(null!==t){const e=(this._type|Nt.FROM)&~Nt.TO;this._type===e&&this._from===t||(this._type=e,this._from=t,i=!0)}else if(null!==e){const s=(this._type|Nt.TO)&~Nt.FROM;this._type===s&&this._from===t||(this._type=s,this._to=e,i=!0)}else{const t=this._type&~(Nt.TO|Nt.FROM);this._type!==t&&(this._type=t,i=!0)}else if(void 0!==t)if(null!==t){const e=this._type|Nt.FROM;this._type===e&&this._from===t||(this._type=e,this._from=t,i=!0)}else{const t=this._type&~Nt.FROM;this._type!==t&&(this._type=t,i=!0)}else if(void 0!==e)if(null!==e){const t=this._type|Nt.TO;this._type===t&&this._to===e||(this._type=t,this._to=e,i=!0)}else{const t=this._type&~Nt.TO;this._type!==t&&(this._type=t,i=!0)}if(i){const t=this.parent;null!=t&&(t.isChanged=!0)}return i}normalize(t){const e=this._type,i=this._from,s=this._to;switch(e){case Nt.FROM_TO:return(t-i)/(s-i);case Nt.FROM:return t-i;case Nt.TO:return s-t;case Nt.NONE:default:return t}}isEquals(t){return this._type===t.type&&this._from===t.from&&this._to===t.to}copy(t){return this.copy_(t.type,t.from,t.to)}copy_(t,e,i){let s=!1;if(this._type!==t&&(this._type=t,s=!0),this._from!==e&&(this._from=e,s=!0),this._to!==i&&(this._to=i,s=!0),s){const t=this.parent;null!=t&&(t.isChanged=!0)}return this}toObject(){return{type:this.type,from:this.from,to:this.to}}serialize(t){const e=`[${this._type},${this._from},${this._to}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getRange(t);if(null!=s)this.copy_(s[0],s[1],s[2]);else{const s=JSON.parse(i[t]);e.setRange(t,s),this.copy_(s[0],s[1],s[2])}}}}const Bt={ASCENDING:0,DESCENDING:1},zt={BOOLEAN:7,BOOLEAN_ARRAY:8,NUMBER:0,NUMBER_ARRAY:1,STRING:2,STRING_ARRAY:3,OBJECT:4,OBJECT_ARRAY:5,TICKER:6,EXTENSION:1e3},Ut={PRIVATE:0,PUBLIC:1,PROTECTED:2},Ft={UNKNOWN:-1,FOUND:0,NOT_FOUND:1,BAD_REQUEST:2,SERVER_ERROR:3,SERVICE_UNAVAILABLE:4,FORBIDDEN:5,NOT_DEFINED:6},Ht=(t,e)=>t-e;class Gt{constructor(){this.id="",this.as="",this.type=zt.NUMBER,this.scope=Ut.PUBLIC,this.initial="",this.format="",this.range=new Pt,this._value=0,this._time=0,this._state=Ft.UNKNOWN,this._capacity=0,this._order=Bt.ASCENDING}get parent(){return this._parent}set parent(t){this._parent!==t&&(this._parent=t,this.range.parent=t)}get value(){return this._value}set value(t){const e=this.formatter;null!=e&&(t=e(t));const i=this._capacity;if(i<=0){if(this._value!==t){this._value=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}else{let e=this._values;null==e&&(e=[],this._values=e),this._value=t;const s=this._order;s===Bt.ASCENDING?e.push(t):e.unshift(t);const n=e.length-i;if(0<n)if(s===Bt.ASCENDING)for(let t=0;t<n;++t)e.shift();else e.length=i;const o=this.parent;null!=o&&(o.isChanged=!0)}}get nvalue(){return this.range.normalize(this._value)}get values(){let t=this._values;return null==t&&(t=[],this._values=t),t}set values(t){const e=t.length;if(0<e){const i=this._capacity;if(i<=0){let i=t[e-1];const s=this.formatter;if(null!=s&&(i=s(i)),this._value!==i){this._value=i;const t=this.parent;null!=t&&(t.isChanged=!0)}}else{let s=this._values;null==s&&(s=[],this._values=s);const n=this._order,o=this.formatter;if(null!=o)if(this._value=o(t[e-1]),n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(o(t[i]));else for(let i=0;i<e;++i)s.unshift(o(t[i]));else if(this._value=t[e-1],n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(t[i]);else for(let i=0;i<e;++i)s.unshift(t[i]);const r=s.length-i;if(0<r)if(n===Bt.ASCENDING)for(let t=0;t<r;++t)s.shift();else s.length=i;const a=this.parent;null!=a&&(a.isChanged=!0)}}}get time(){return this._time}set time(t){const e=this._capacity;if(e<=0){if(this._time!==t){this._time=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}else{let i=this._times;null==i&&(i=[],this._times=i),this._time=t;const s=this._order;s===Bt.ASCENDING?i.push(t):i.unshift(t);const n=i.length-e;if(0<n)if(s===Bt.ASCENDING)for(let t=0;t<n;++t)i.shift();else i.length=e;const o=this.parent;null!=o&&(o.isChanged=!0)}}get times(){let t=this._times;return null==t&&(t=[],this._times=t),t}set times(t){const e=t.length;if(0<e){const i=this._capacity;if(i<=0){const i=t[e-1];if(this._time!==i){this._time=i;const t=this.parent;null!=t&&(t.isChanged=!0)}}else{let s=this._times;null==s&&(s=[],this._times=s),this._time=t[e-1];const n=this._order;if(n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(t[i]);else for(let i=0;i<e;++i)s.unshift(t[i]);const o=s.length-i;if(0<o)if(n===Bt.ASCENDING)for(let t=0;t<o;++t)s.shift();else s.length=i;const r=this.parent;null!=r&&(r.isChanged=!0)}}}get state(){return this._state}set state(t){const e=this._capacity;if(e<=0){if(this._state!==t){this._state=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}else{let i=this._states;null==i&&(i=[],this._states=i),this._state=t;const s=this._order;s===Bt.ASCENDING?i.push(t):i.unshift(t);const n=i.length-e;if(0<n)if(s===Bt.ASCENDING)for(let t=0;t<n;++t)i.shift();else i.length=e;const o=this.parent;null!=o&&(o.isChanged=!0)}}get states(){let t=this._states;return null==t&&(t=[],this._states=t),t}set states(t){const e=t.length;if(0<e){const i=this._capacity;if(i<=0){const i=t[e-1];if(this._state!==i){this._state=i;const t=this.parent;null!=t&&(t.isChanged=!0)}}else{let s=this._states;null==s&&(s=[],this._states=s),this._state=t[e-1];const n=this._order;if(n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(t[i]);else for(let i=0;i<e;++i)s.unshift(t[i]);const o=s.length-i;if(0<o)if(n===Bt.ASCENDING)for(let t=0;t<o;++t)s.shift();else s.length=i;const r=this.parent;null!=r&&(r.isChanged=!0)}}}get capacity(){return this._capacity}set capacity(t){if(this._capacity<t)this._capacity=t;else if(t<this._capacity){this._capacity=t;let e=!1;const i=this._order,s=this._values;if(null!=s){const n=s.length-t;if(0<n){if(i===Bt.ASCENDING)for(let t=0;t<n;++t)s.shift();else s.length=t;e=!0}}const n=this._times;if(null!=n){const s=n.length-t;if(0<s){if(i===Bt.ASCENDING)for(let t=0;t<s;++t)n.shift();else n.length=t;e=!0}}const o=this._states;if(null!=o){const s=o.length-t;if(0<s){if(i===Bt.ASCENDING)for(let t=0;t<s;++t)o.shift();else o.length=t;e=!0}}if(e){const t=this.parent;null!=t&&(t.isChanged=!0)}}}get order(){return this._order}set order(t){this._order=t}remove(t){let e=!1;const i=this._values;null!=i&&0<=t&&t<i.length&&(i.splice(t,1),e=!0);const s=this._times;null!=s&&0<=t&&t<s.length&&(s.splice(t,1),e=!0);const n=this._states;if(null!=n&&0<=t&&t<n.length&&(n.splice(t,1),e=!0),e){const t=this.parent;null!=t&&(t.isChanged=!0)}}removeAll(t){let e=!1;const i=t.slice(0).sort(Ht),s=i.length,n=this._values;if(null!=n)for(let t=s-1;0<=t;--t){const s=i[t];0<=s&&s<n.length&&(n.splice(s,1),e=!0)}const o=this._times;if(null!=o)for(let t=s-1;0<=t;--t){const s=i[t];0<=s&&s<o.length&&(o.splice(s,1),e=!0)}const r=this._states;if(null!=r)for(let t=s-1;0<=t;--t){const s=i[t];0<=s&&s<r.length&&(r.splice(s,1),e=!0)}if(e){const t=this.parent;null!=t&&(t.isChanged=!0)}}clear(){let t=!1;const e=this._values;null!=e&&(e.length=0,t=!0);const i=this._times;null!=i&&(i.length=0,t=!0);const s=this._states;if(null!=s&&(s.length=0,t=!0),t){const t=this.parent;null!=t&&(t.isChanged=!0)}}toDirty(){const t=this.parent;null!=t&&(t.isChanged=!0)}copy(t){return this.id=t.id,this.as=t.as,this.type=t.type,this.scope=t.scope,this.initial=t.initial,this.format=t.format,this.formatter=t.formatter,this.range.copy(t.range),this._value=t.value,this._time=t.time,this._state=t.state,this._capacity=t.capacity,this}isEquals(t){return this.id===t.id&&this.as===t.as&&this.type===t.type&&this.scope===t.scope&&this.initial===t.initial&&this.formatter===t.formatter&&this.range.isEquals(t.range)}serialize(t){const e=t.addData(this.id),i=t.addResource(this.as),s=t.addResource(this.initial),n=t.addResource(this.format.trim()),o=this.range.serialize(t);return t.addResource(`[${e},${s},${n},${o},${this._capacity},${this._order},${this.type},${this.scope},${i}]`)}deserialize(t,e){var i,s;const n=e.resources;if(0<=t&&t<n.length){let o=e.getDataValue(t);null==o&&(o=JSON.parse(n[t]),e.setDataValue(t,o)),this.id=e.data[o[0]]||"";const r=o[8];this.as=null!=r&&n[r]||"",this.type=null!==(i=o[6])&&void 0!==i?i:zt.NUMBER,this.scope=null!==(s=o[7])&&void 0!==s?s:Ut.PUBLIC,this.initial=n[o[1]]||"",this.format=n[o[2]]||"",this.range.deserialize(o[3],e),this._capacity=o[4],this._order=o[5]}return this}}class Vt{constructor(){this.values=[]}add(t,e){const i=this.values;return null!=e?i.splice(e,0,t):i.push(t),this}addAll(t){const e=this.values;for(let i=0,s=t.length;i<s;++i)e.push(t[i]);return this}clearAndAdd(t){return this.clear(),this.add(t),this}clearAndAddAll(t){return this.clear(),this.addAll(t),this}indexOf(t){const e=this.values;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return i;for(let i=0,s=e.length;i<s;++i){const s=e[i];if(s[0]===t[0]&&s[1]===t[1]&&s[2]===t[2])return i}return-1}get(t){const e=this.values;return 0<=t||t<e.length?e[t]:null}set(t,e){const i=this.values;if(0<=t||t<i.length){const s=i[t];return i[t]=e,s}return null}remove(t){const e=this.values;return 0<=t||t<e.length?e.splice(t,1)[0]:null}clear(){return this.values.length=0,this}size(){return this.values.length}swap(t,e){const i=this.values,s=i[e];return i[e]=i[t],i[t]=s,this}copy(t){this.clearAndAddAll(t.values)}serialize(t){const e=this.values;if(e.length<=0)return-1;let i="[",s="";for(let n=0,o=e.length;n<o;++n){const o=e[n];i+=`${s}${t.addResource(o[0])},${t.addResource(o[1])},${t.addResource(o[2])}`,s=","}return i+="]",t.addResource(i)}deserialize(t,e){const i=this.values;i.length=0;const s=e.resources,n=s.length;if(0<=t&&t<n){let o=e.getDataMapping(t);null==o&&(o=JSON.parse(s[t]),e.setDataMapping(t,o));for(let t=0,e=o.length;t<e;t+=3){const e=o[t],r=o[t+1],a=o[t+2];i.push([0<=e&&e<n?s[e]:"",0<=r&&r<n?s[r]:"",0<=a&&a<n?s[a]:""])}}}}class Wt{get ids(){const t=this._data;if(null==t)return[];const e=[];return t.forEach((t,i)=>{e.push(i)}),e}add(t,e){var i;const s=null!==(i=this._data)&&void 0!==i?i:this._data=new Map,n=s.get(t);null==n?s.set(t,[e]):n.push(e)}set(t,e,i,s,n,o){const r=this._data;if(null==r)return!1;const a=r.get(t);if(null==a)return!1;const h=a.length;if(h<=0)return!1;for(let t=0;t<h;++t){const r=a[t];r.range.set(n,o),void 0!==i&&(r.time=i),void 0!==s&&(r.state=s),r.value=e}return!0}toDirty(t){const e=this._data;if(null==e)return!1;const i=e.get(t);if(null==i)return!1;const s=i.length;if(s<=0)return!1;for(let t=0;t<s;++t)i[t].toDirty();return!0}each(t){const e=this._data;if(null==e)return null;let i=null;return e.forEach((e,s)=>{null==i&&!1===t(s)&&(i=s)}),i}}class Kt{constructor(){this._data=new Map}set(t,e){return this._data.set(t,e),this}get(t){var e;return null!==(e=this._data.get(t))&&void 0!==e?e:null}contains(t){return this._data.has(t)}remove(t){const e=this._data,i=e.get(t);return e.delete(t),null!=i?i:null}clear(){return this._data.clear(),this}size(){return this._data.size}each(t){let e=!1;return this._data.forEach((i,s)=>{e||!1===t(i,s)&&(e=!0)}),this}copy(t){const e=this._data;return e.clear(),t.each((t,i)=>{e.set(i,t)}),this}serialize(t){const e=this._data;if(e.size<=0)return-1;const i=[];return e.forEach((e,s)=>{const n=t.addResource(e),o=t.addResource(s);i.push(o,n)}),t.addResource(JSON.stringify(i))}deserialize(t,e){const i=this._data;i.clear();const s=e.resources,n=s.length;if(0<=t&&t<n){let o=e.getDataSystem(t);null==o&&(o=JSON.parse(s[t]),e.setDataSystem(t,o));for(let t=0,e=o.length;t<e;t+=2){const e=o[t];if(0<=e&&e<n){const r=s[e],a=o[t+1];0<=a&&a<n&&i.set(r,s[a])}}}}}let Xt,Yt;class jt{constructor(){this._values=[],this._isChanged=!0}get values(){return this._values}get isChanged(){return this._isChanged}set isChanged(t){this._isChanged=t}get id(){const t=this._values;return 0<t.length?t[0].id:""}get as(){const t=this._values;return 0<t.length?t[0].as:""}get type(){const t=this._values;return 0<t.length?t[0].type:zt.NUMBER}get scope(){const t=this._values;return 0<t.length?t[0].scope:Ut.PRIVATE}get initial(){const t=this._values;return 0<t.length?t[0].initial:""}get format(){const t=this._values;return 0<t.length?t[0].format:""}get range(){const t=this._values;return 0<t.length?t[0].range:null!=Xt?Xt:Xt=new Pt}get value(){const t=this._values;return 0<t.length?t[0].value:0}set value(t){const e=this._values;0<e.length&&(e[0].value=t)}get nvalue(){const t=this._values;return 0<t.length?t[0].nvalue:0}get time(){const t=this._values;return 0<t.length?t[0].time:0}set time(t){const e=this._values;0<e.length&&(e[0].time=t)}get state(){const t=this._values;return 0<t.length?t[0].state:Ft.UNKNOWN}set state(t){const e=this._values;0<e.length&&(e[0].state=t)}get capacity(){const t=this._values;return 0<t.length?t[0].capacity:0}set capacity(t){const e=this._values;0<e.length&&(e[0].capacity=t)}get alias(){let t=this._alias;return null==t&&(t=this.newAlias(),this._alias=t),t}newAlias(){const t=this._values,e=t.length;if(0<e){const i={};for(let s=0;s<e;++s){const e=t[s];i[e.as||e.id]=e}return i}return null!=Yt?Yt:Yt={}}get mapping(){let t=this._mapping;return null==t&&(t=this.newMapping(),this._mapping=t),t}newMapping(){return new Vt}getMapping(){return this._mapping}get private(){let t=this._private;return null==t&&(t=this.newPrivate(),this._private=t),t}newPrivate(){return new Wt}getPrivate(){return this._private}get system(){let t=this._system;return null==t&&(t=this.newSystem(),this._system=t),t}newSystem(){return new Kt}getSystem(){return this._system}add(t,e){const i=this._values;t.parent=this,void 0===e?i.push(t):i.splice(e,0,t)}set(t,e){const i=this._values;if(0<=t&&t<i.length){const s=i[t];return e.parent=this,i[t]=e,s.parent=void 0,s}return null}remove(t){const e=this._values;0<=t&&t<e.length&&(e.splice(t,1)[0].parent=void 0)}indexOf(t){const e=this._values,i=e.length;for(let s=0;s<i;++s)if(e[s]===t)return s;for(let s=0;s<i;++s)if(e[s].isEquals(t))return s;for(let s=0;s<i;++s)if(e[s].id===t.id)return s;return-1}get(t){const e=this._values;return 0<=t&&t<e.length?e[t]:null}size(){return this._values.length}swap(t,e){const i=this._values,s=i[e];i[e]=i[t],i[t]=s}copy(t){const e=this._values;e.length=0;for(let i=0,s=t.size();i<s;++i){const s=t.get(i);if(null!=s){const t=(new Gt).copy(s);t.parent=this,e.push(t)}}const i=t.getMapping();i&&this.mapping.copy(i);const s=t.getSystem();return s&&this.system.copy(s),this}serialize(t){const e=this._values,i=[];for(let s=0,n=e.length;s<n;++s)i.push(e[s].serialize(t));const s=this._mapping;if(null!=s){i.push(s.serialize(t));const e=this._system;return null!=e?t.addResource(`[${JSON.stringify(i)},${e.serialize(t)}]`):t.addResource(`[${JSON.stringify(i)}]`)}{const e=this._system;return null!=e?(i.push(-1),t.addResource(`[${JSON.stringify(i)},${e.serialize(t)}]`)):t.addResource(JSON.stringify(i))}}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getData(t);null==s&&(s=JSON.parse(i[t]),e.setData(t,s));const n=this._values;if(n.length=0,this.isMapped(s)){const t=s[0],i=t.length;for(let s=0,o=i-1;s<o;++s){const i=t[s],o=new Gt;o.parent=this,o.deserialize(i,e),n.push(o)}const o=t[i-1];0<=o&&this.mapping.deserialize(o,e);const r=s[1];null!=r&&0<=r&&this.system.deserialize(r,e)}else for(let t=0,i=s.length;t<i;++t){const i=s[t],o=new Gt;o.parent=this,o.deserialize(i,e),n.push(o)}}}isMapped(t){return 0<t.length&&vt(t[0])}}class $t{constructor(t,e,i){this._parent=t,this._horizontal=e,this._vertical=i}get horizontal(){return this._horizontal}set horizontal(t){this._horizontal!==t&&(this._horizontal=t,this._parent.updateUploaded())}get vertical(){return this._vertical}set vertical(t){this._vertical!==t&&(this._vertical=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.horizontal,t.vertical)}set(t,e){let i=!1;null!=t&&this._horizontal!==t&&(this._horizontal=t,i=!0),null!=e&&this._vertical!==e&&(this._vertical=e,i=!0),i&&this._parent.updateUploaded()}toObject(){return{horizontal:this._horizontal,vertical:this._vertical}}serialize(t){return t.addResource(`[${this._horizontal},${this._vertical}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getAlign(t);if(null!=s)this.set(s[0],s[1]);else{const s=JSON.parse(i[t]);e.setAlign(t,s),this.set(s[0],s[1])}}}}class qt{constructor(t,e,i){this._parent=t,this._horizontal=e,this._vertical=i}get horizontal(){return this._horizontal}set horizontal(t){this._horizontal!==t&&(this._horizontal=t,this._parent.updateUploaded())}get vertical(){return this._vertical}set vertical(t){this._vertical!==t&&(this._vertical=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.horizontal,t.vertical)}set(t,e){let i=!1;null!=t&&this._horizontal!==t&&(this._horizontal=t,i=!0),null!=e&&this._vertical!==e&&(this._vertical=e,i=!0),i&&this._parent.updateUploaded()}toObject(){return{horizontal:this._horizontal,vertical:this._vertical}}serialize(t){return t.addResource(`[${this._horizontal},${this._vertical}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getMargin(t);if(null!=s)this.set(s[0],s[1]);else{const s=JSON.parse(i[t]);e.setMargin(t,s),this.set(s[0],s[1])}}}}class Zt{constructor(t,e,i,s,n){this._parent=t,this._enable=e,this._color=i,this._alpha=s,this._width=n}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.enable,t.color,t.alpha,t.width)}set(t,e,i,s){let n=!1;void 0!==t&&this._enable!==t&&(this._enable=t,n=!0),void 0!==e&&this._color!==e&&(this._color=e,n=!0),void 0!==i&&this._alpha!==i&&(this._alpha=i,n=!0),void 0!==s&&this._width!==s&&(this._width=s,n=!0),n&&this._parent.updateUploaded()}clone(){return new Zt(this._parent,this._enable,this._color,this._alpha,this._width)}toObject(){return{enable:this._enable,color:this._color,alpha:this._alpha,width:this._width}}serialize(t){const e=`[${this._enable?1:0},${this._color},${this._alpha},${this._width}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getTextOutline(t);if(null!=s)this.set(!!s[0],s[1],s[2],s[3]);else{const s=JSON.parse(i[t]);e.setTextOutline(t,s),this.set(!!s[0],s[1],s[2],s[3])}}}}class Jt{constructor(t,e,i,s,n,o){this._parent=t,this._enable=!0,this._value=e,this._plength=this._length=e.length,this._color=i,this._alpha=s,this._family=n,this._size=o,this._weight=T.NORMAL,this.align=new $t(t,E.CENTER,y.MIDDLE),this.offset=new qt(t,0,0),this._style=w.NORMAL,this.spacing=new qt(t,0,0),this.outline=new Zt(t,!1,16777215,1,.5),this._direction=x.LEFT_TO_RIGHT,this.padding=new qt(t,10,10),this._clipping=!1,this._fitting=!1,this._characters=[],this._nacharacters=[],this.updateCharacters(e)}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get value(){return this._value}set value(t){if(this._value!==t){this._value=t;const e=t.length;this._length=e,this._plength<e&&(this._plength=e),this.updateCharacters(t),this.isCompatible()?this._parent.updateUploaded():(this.atlas=void 0,this._parent.toDirty())}}get characters(){return this._characters}get nacharacters(){return this._nacharacters}updateCharacters(t){const e=this._characters,i=e.length;let s=0;const n=this._nacharacters,o=n.length;let r=0;for(let a=0,h=t.length;a<h;){if(t.charCodeAt(a)<=255){const n=t.substring(a,a+1);s<i?e[s]=n:e.push(n),s+=1,a+=1;continue}let l=a+1;for(;l<h;++l){const e=t.charCodeAt(l);if(!(56320<=e&&e<=57343||65024<=e&&e<=65039))break}const c=t.substring(a,l);s<i?e[s]=c:e.push(c),s+=1,r<o?n[r]=c:n.push(c),r+=1,a=l}s<i&&(e.length=s),r<o&&(n.length=r)}isCompatible(){const t=this._parent,e=t.uploaded;if(null==e||!e.isCompatible(t))return!1;const i=this.atlas;if(null==i)return!1;const s=i.characters,n=this._nacharacters;for(let t=0,e=n.length;t<e;++t)if(!s.has(n[t]))return!1;return!0}get length(){return this._length}get plength(){return this._plength}get family(){return this._family}set family(t){this._family!==t&&(this._family=t,this._parent.toDirty())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}get size(){return this._size}set size(t){this._size!==t&&(this._size=t,this._parent.updateUploaded())}get weight(){return this._weight}set weight(t){this._weight!==t&&(this._weight=t,this._parent.updateUploaded())}get style(){return this._style}set style(t){this._style!==t&&(this._style=t,this._parent.updateUploaded())}get direction(){return this._direction}set direction(t){this._direction!==t&&(this._direction=t,this._parent.updateUploaded())}get clipping(){return this._clipping}set clipping(t){this._clipping!==t&&(this._clipping=t,this._parent.updateUploaded())}get fitting(){return this._fitting}set fitting(t){this._fitting!==t&&(this._fitting=t,this._parent.updateUploaded())}copy(t){return t&&(this.set(t.value,t.color,t.alpha,t.family,t.size,t.weight,t.style,t.direction,t.clipping,t.fitting),this.align.copy(t.align),this.offset.copy(t.offset),this.outline.copy(t.outline),this.spacing.copy(t.spacing),this.padding.copy(t.padding)),this}set(t,e,i,s,n,o,r,a,h,l){let c=!1,u=!1;if(null!=t&&this._value!==t){this._value=t;const e=t.length;this._length=e,this._plength<e&&(this._plength=e),this.updateCharacters(t),this.isCompatible()?u=!0:(this.atlas=void 0,c=!0)}return null!=e&&this._color!==e&&(this._color=e,u=!0),null!=i&&this._alpha!==i&&(this._alpha=i,u=!0),null!=s&&this._family!==s&&(this._family=s,c=!0),null!=n&&this._size!==n&&(this._size=n,u=!0),null!=o&&this._weight!==o&&(this._weight=o,u=!0),null!=r&&this._style!==r&&(this._style=r,u=!0),null!=a&&this._direction!==a&&(this._direction=a,u=!0),null!=h&&this._clipping!==h&&(this._clipping=h,u=!0),null!=l&&this._fitting!==l&&(this._fitting=l,u=!0),c?this._parent.toDirty():u&&this._parent.updateUploaded(),this}toObject(){return{value:this._value,color:this._color,alpha:this._alpha,family:this._family,size:this._size,weight:this._weight,align:this.align.toObject(),offset:this.offset.toObject(),style:this._style,outline:this.outline.toObject(),direction:this._direction,spacing:this.spacing.toObject(),padding:this.padding.toObject(),clipping:this._clipping,fitting:this._fitting}}serialize(t){const e=t.addResource(this._value),i=t.addResource(this._family),s=this.align.serialize(t),n=this.offset.serialize(t),o=this.outline.serialize(t),r=this.spacing.serialize(t),a=this.padding.serialize(t),h=this._clipping?1:0,l=this._fitting?1:0,c=`[${e},${this._color},${this._alpha},${i},${this._size},${this._weight},${s},${n},${this._style},${o},${r},${this._direction},${a},${h},${l}]`;return t.addResource(c)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getText(t);null==s&&(s=JSON.parse(i[t]),e.setText(t,s)),this.set(i[s[0]]||"",s[1],s[2],i[s[3]]||"auto",s[4],s[5],s[8],s[11],!!s[13],!!s[14]),this.align.deserialize(s[6],e),this.offset.deserialize(s[7],e),this.outline.deserialize(s[9],e),this.spacing.deserialize(s[10],e),this.padding.deserialize(s[12],e)}}}const Qt=t=>{const e=t.points;let i="["+t.direction;for(let t=0,s=e.length,n=1;t<s;t+=1,n+=3){const s=e[t];i+=`,${s.color},${s.alpha},${s.position}`}return i+="]",i};class te extends kt{constructor(t){super(t),this.size=this.newSize(),this.fill=this.newFill(),this.stroke=this.newStroke(),this._radius=q.RADIUS,this._corner=nt.ALL;const e=new jt;this.data=e,this.tag=e,this.text=this.newText()}newSize(){return new t.ObservablePoint(()=>{this.onSizeChange()},void 0,q.SIZE_X,q.SIZE_Y)}newFill(){return new J(this,!0,q.FILL_COLOR,q.FILL_ALPHA)}newStroke(){return new Lt(this,!0,q.STROKE_COLOR,q.STROKE_ALPHA,q.STROKE_WIDTH,q.STROKE_ALIGN,q.STROKE_SIDE,q.STROKE_STYLE)}newText(){return new Jt(this,q.TEXT_VALUE,q.TEXT_COLOR,q.TEXT_ALPHA,q.TEXT_FAMILY,q.TEXT_SIZE)}get corner(){return this._corner}set corner(t){this._corner!==t&&(this._corner=t,this.updateUploaded())}get radius(){return this._radius}set radius(t){this._radius!==t&&(this._radius=t,this.updateUploaded())}get image(){return this._image}set image(t){if(this._image!==t){this._image=null!=t?t:void 0;const e=this.parent;null!=e&&e.toDirty()}}serializeImage(t){const e=this._image;return null!=e?t.addResource(e.url):-1}serializeGradient(t){const e=this.gradient;return null!=e?(null==e.serialized&&(e.serialized=Qt(e)),t.addResource(e.serialized)):-1}}const ee=(t,e,i,s,n,o,r)=>{if(t.fill.enable){const t=s*s,o=n*n;if(e*e*o+i*i*t<=t*o)return!0}else if(0<o){const t=o*r,a=e*e,h=i*i,l=Math.max(0,s-t),c=Math.max(0,n-t),u=l*l,d=c*c;if(u*d<=a*d+h*u){const t=s*s,e=n*n;if(a*e+h*t<=t*e)return!0}}return!1},ie=(t,e,i,s,n,o,r)=>{if(It(e,i,s,n)){if(t.fill.enable)return!0;{const a=t.stroke.side;if(0<o&&a!==V.NONE){const t=o*r,h=Math.max(0,s-t),l=Math.max(0,n-t);if(!It(e,i,h,l))return!(a!==V.ALL&&!(e<=-h?i<=-l?a&V.TOP_OR_LEFT:+l<=i?a&V.BOTTOM_OR_LEFT:a&V.LEFT:+h<=e?i<=-l?a&V.TOP_OR_RIGHT:+l<=i?a&V.BOTTOM_OR_RIGHT:a&V.RIGHT:i<=-l?a&V.TOP:+l<=i&&a&V.BOTTOM))}}}return!1},se=(t,e,i,s,n)=>+i*t+s-e<=0&&-i*t+s-e<=0&&e<=n,ne=(t,e,i,s,n,o,r)=>{const a=2*n/s;if(t.fill.enable){if(se(e,i,a,-n,+n))return!0}else if(0<o){const t=o*r;if(se(e,i,a,-n,+n)){const o=2*s*n/(s+Math.sqrt(s*s+4*n*n)),r=n-o,h=r+(-n-r)*Math.max(0,o-t)/o;if(!se(e,i,a,h,n-t))return!0}}return!1},oe=(t,e,i)=>.5*(i+t*e);class re extends te{getHitTestSize(t){const e=this._points.formatted;if("boundary"in e){const i=e.boundary;t.width=Math.max(Math.abs(i[0]),Math.abs(i[2])),t.height=Math.max(Math.abs(i[1]),Math.abs(i[3]))}else super.getHitTestSize(t);return t}toMarkerSize(t){let e=0;const i=t.getMarker();if(i){const t=i.head;if(t.type!==Z.NONE){const i=t.size;e=Math.max(e,2*Math.max(Math.abs(i.x),Math.abs(i.y)))}const s=i.tail;if(s.type!==Z.NONE){const t=s.size;e=Math.max(e,2*Math.max(Math.abs(t.x),Math.abs(t.y)))}}return e}containsAbsMarker(t,e,i,s,n,o){const r=t.type;if(r!==Z.NONE){const a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,p=a.ty,_=1/(h*u-c*l),g=(u*e-c*i+p*c-d*u)*_,f=(h*i-l*e-p*h+d*l)*_,m=t.size;let v=.5*m.x,T=.5*m.y;v<0&&(v=-v,e=-e),T<0&&(T=-T,i=-i);const w=s*n*o;switch(v+=w,T+=w,r){case Z.CIRCLE:return ee(this,g,f,v,T,s,n);case Z.TRIANGLE:return ne(this,g,f,v,T,s,n);case Z.RECTANGLE:return ie(this,g,f,v,T,s,n)}}return!1}containsAbs(t,e,i,s,n,o,r){const a=this._points,h=oe(n,o,0),l=h+this.toMarkerSize(a);if(this.containsAbsBBox(t,e,i+l,s+l)){const l=a.getMarker();if(l){if(this.containsAbsMarker(l.head,t,e,n,o,r))return!0;if(this.containsAbsMarker(l.tail,t,e,n,o,r))return!0}const c=this.calcHitPointAbsHitTester;return a.calcHitPointAbs(t,e,i,s,h,null,c,null)}return!1}calcHitPart(t,e){const i=this.toHitTestData(t,e),s=i.strokeWidth,n=i.strokeScale,o=oe(s,n,0),r=this._points,a=o+this.toMarkerSize(r),h=i.x,l=i.y,c=i.width,u=i.height;if(this.containsAbsBBox(h,l,c+a,u+a)){const t=r.getMarker();if(t){const e=i.strokeAlign;if(this.containsAbsMarker(t.head,h,l,s,n,e))return st.MARKER_HEAD;if(this.containsAbsMarker(t.tail,h,l,s,n,e))return st.MARKER_TAIL}const e=this.calcHitPointAbsHitTester;if(r.calcHitPointAbs(h,l,c,u,o,null,e,null))return st.LINE}return this.containsText(t,e)?st.TEXT:this.containsChildren(t,e)?st.CHILDREN:st.NONE}calcHitPoint(t,e,i,s,n,o){const r=this._points,a=this.toHitTestData(t,e),h=(i||oe)(a.strokeWidth,a.strokeScale,0);return!!this.containsAbsBBox(a.x,a.y,a.width+h,a.height+h)&&r.calcHitPointAbs(a.x,a.y,a.width,a.height,h,s,n,o)}calcHitPointAbsHitTester(t,e,i,s,n,o,r,a,h){const l=n-i,c=o-s,u=t-i,d=e-s,p=l*l+c*c,_=l*u+c*d,g=u*u+d*d;if(1e-4<p){const t=Math.max(0,Math.min(1,_/p));if(p*t*t-2*_*t+g<a*a)return!0}return!1}}class ae extends re{constructor(t=s.BAR){super(t),this._points=new it(this)}get points(){return this._points}clone(){return new ae(this.type).copy(this)}containsAbsBBox(t,e,i,s){const n=Math.max(0,this._points.size);return super.containsAbsBBox(t,e,i+n,s+n)}serialize(t){const e=super.serialize(t);return e[15]=this._points.serialize(t),e}}class he extends W{constructor(t,e,i){super(t,e,i,4,2),this.pointsId=-1,this.pointsStyle=F.NONE}init(){const t=this.vertexOffset,e=this.indexOffset,i=this.buffer;i.updateIndices(),f(i.indices,t,e),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexStep(t,e){if(e instanceof ae){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=e.stroke,a=r.enable?r.width:0,h=r.style,l=a!==this.strokeWidth||h!==this.strokeStyle,c=K(e),u=this.transformLocalId!==c,d=e.points,p=d.id,_=p!==this.pointsId,g=d.style,f=g!==this.pointsStyle;(!(this.inited&H.VERTEX_AND_STEP)||o||u||l||_||f)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.strokeWidth=a,this.strokeStyle=h,this.transformLocalId=c,this.pointsId=p,this.pointsStyle=g,_&&(this.inited&=~H.UV),t.updateVertices(),t.updateSteps(),m(t.vertices,t.steps,this.vertexOffset,d.values,d.size,a,h,e.transform.internalTransform))}}updateUv(t,e){const i=X(e),s=Y(i);(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId)&&(this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs(),v(t.uvs,this.vertexOffset,j(i)))}}class le{constructor(t,e,i,s,n){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=s,this.indexCount=n,this.inited=H.NONE,this.sizeX=0,this.sizeY=0,this.transformLocalId=0,this.scaleX=1,this.scaleY=1,this.size=0,this.family="auto",this.value="",this.texture=null,this.textureTransformId=0,this.color=0,this.alpha=0,this.weight=0,this.style=0,this.alignHorizontal=0,this.alignVertical=0,this.offsetHorizontal=0,this.offsetVertical=0,this.outlineWidth=0,this.outlineColor=0,this.outlineAlpha=0,this.spacingHorizontal=0,this.spacingVertical=0,this.direction=0,this.paddingHorizontal=0,this.paddingVertical=0,this.clipping=!1,this.fitting=!1}init(){if(0<this.vertexCount){const t=this.buffer,e=this.vertexOffset;t.updateIndices(),O(t.indices,e,this.indexOffset,this.indexCount)}return this.inited|=H.INDEX,this}reinit(t,e,i,s){const n=I(e),o=n<<2,r=n<<1;return this.buffer===t&&this.vertexOffset===i&&this.indexOffset===s&&this.vertexCount===o&&this.indexCount===r||!!t.check(i,s,o,r)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.vertexCount=o,this.indexCount=r,this.init(),!0)}isCompatible(t){return I(t)<<2===this.vertexCount}update(t){if(0<this.vertexCount){const e=t.text.atlas;if(null!=e){const i=this.buffer;this.updateVertex(i,t,e),this.updateColor(i,t),this.updateStep(i,t)}}return this}updateVertex(e,i,s){const n=i.size,o=n.x,r=n.y,a=o!==this.sizeX||r!==this.sizeY,h=K(i),l=this.transformLocalId!==h,c=i.text,u=c.size,d=c.family,p=c.value,_=c.style,g=c.align.horizontal,f=c.align.vertical,m=c.offset.horizontal,v=c.offset.vertical,T=c.spacing.horizontal,w=c.spacing.vertical,E=c.direction,y=c.padding.horizontal,x=c.padding.vertical,C=c.clipping,D=c.fitting,S=c.texture||t.Texture.WHITE,b=Y(S),I=p!==this.value||d!==this.family,O=u!==this.size,A=_!==this.style,R=g!==this.alignHorizontal||f!==this.alignVertical,k=m!==this.offsetHorizontal||v!==this.offsetVertical,L=T!==this.spacingHorizontal||w!==this.spacingVertical||y!==this.paddingHorizontal||x!==this.paddingVertical,N=E!==this.direction,P=this.clipping!==C,B=this.fitting!==D,z=S!==this.texture||b!==this.textureTransformId;if(!(this.inited&H.VERTEX)||a||l||I||O||A||R||k||L||N||P||B||z){this.inited|=H.VERTEX,this.size=u,this.family=d,this.value=p,this.style=_,this.alignHorizontal=g,this.alignVertical=f,this.offsetHorizontal=m,this.offsetVertical=v,this.spacingHorizontal=T,this.spacingVertical=w,this.direction=E,this.paddingHorizontal=y,this.paddingVertical=x,this.clipping=C,this.fitting=D,this.texture=S,this.textureTransformId=b,(O||B||D&&a)&&(this.inited&=~H.STEP),e.updateVertices(),e.updateUvs();const t=i.size;let n=c.world;null==n&&(n=[0,0,0,0,0,0,0,0],c.world=n),M(e.vertices,e.uvs,this.vertexOffset,this.vertexCount,0,0,t.x,t.y,s,u,c.characters,_,g,f,m,v,T,w,E,y,x,C,D,n,j(S),i.transform.internalTransform)}}updateColor(t,e){const i=e.text,s=i.color,n=e.visible&&i.enable?i.alpha:0,o=i.outline,r=o.color,a=e.visible&&i.enable?o.alpha:0;(!(this.inited&H.COLOR)||s!==this.color||n!==this.alpha||s!==this.outlineColor||n!==this.outlineAlpha)&&(this.inited|=H.COLOR,this.color=s,this.alpha=n,this.outlineColor=r,this.outlineAlpha=a,t.updateColors(),G(s,n,r,a,this.vertexOffset,this.vertexCount,t.colors))}updateStep(t,e){const i=e.text,s=i.outline,n=s.enable?s.width:0,o=n!==this.outlineWidth,r=i.weight,a=r!==this.weight;let h=1,l=1;const c=i.world;null!=c&&(h=c[8],l=c[9]);const u=S<Math.abs(this.scaleX-h)||S<Math.abs(this.scaleY-l);(!(this.inited&H.STEP)||a||o||u)&&(this.inited|=H.STEP,this.weight=r,this.outlineWidth=n,this.scaleX=h,this.scaleY=l,t.updateSteps(),A(t.steps,this.vertexOffset,this.vertexCount,i.atlas,i.size,n,r,this.scaleX,this.scaleY))}buildUnit(e){if(0<this.vertexCount){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;s!==e.baseTexture&&(e.baseTexture=s,e.push(i,this.indexOffset))}}}const ce=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=4+a,c=2+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new he(t,i,s),new le(t,i+4,s+2,a,h)]).init(e):null},ue=(t,e,i)=>{const s=t.length;if(e<s)return t;let n="";for(let t=0,o=e-s;t<o;++t)n+=i;return n+t};class de{static toCode(t){return ue(t.toString(16).toUpperCase(),6,"0")}static fromCode(t){const e=t.trim().toLowerCase();if(6===e.length){const t=Number("0x"+e);if(t==t)return t}return null}static fromRgb(t,e,i){return 255*t<<16|255*e<<8|255*i|0}static blend(t,e,i){const s=t>>16&255,n=t>>8&255,o=255&(0|t),r=e>>16&255,a=e>>8&255,h=255&(0|e),l=Math.max(0,Math.min(1,i)),c=1-l;return Math.max(0,Math.min(255,s*c+r*l))<<16|Math.max(0,Math.min(255,n*c+a*l))<<8|0|Math.max(0,Math.min(255,o*c+h*l))}static brighten(t,e){return 0<=e?this.blend(t,16777215,e):this.blend(t,0,-e)}static darken(t,e){return 0<=e?this.blend(t,0,e):this.blend(t,16777215,-e)}static toGrayscale(t){const e=this.toLuma(t);return e<<16|e<<8|e}static toLuma(t){return.2126*(t>>16&255)+.7152*(t>>8&255)+.0722*(255&(0|t))&255}}const pe={NONE:0,POSITION_X:1,POSITION_Y:2,POSITION:3,ROTATION:4,COLOR_FILL:8,COLOR_STROKE:16,COLOR_FILL_AND_STROKE:24,COLOR_TEXT:32,COLOR_TEXT_OUTLINE:64,COLOR:120,VISIBILITY:128,HEIGHT:256,WIDTH:512,SIZE:768,TEXT:1024,CURSOR:2048};class _e{static toBaseFill(t,e){return(e.written&pe.COLOR_FILL?t:e).fill}static toBaseStroke(t,e){return(e.written&pe.COLOR_STROKE?t:e).stroke}static toBaseText(t,e){return(e.written&pe.COLOR_TEXT?t:e).text}static toBaseTextOutline(t,e){return(e.written&pe.COLOR_TEXT_OUTLINE?t:e).text.outline}}const ge={isInitializing:!1};class fe{static from(t,e,i,s,n,o){if(t.trim().length<=0)return i;try{const i="try {with (shape) {with (state) {with (data.alias) {with (environment) {"+(n?`var result = (${t});return (result != null ? ${e}(result) : null);`:`return ${e}(${t});`)+"}}}}} catch (e) {"+`return ${s};}`;return null==o?Function("shape","time","environment",i):Function("shape","time","environment",o,i)}catch(t){return i}}static ofNumberOrNull(t){return this.from(t,"Number",this.NULL,"null",!0)}static ofStringOrNull(t){return this.from(t,"String",this.NULL,"null",!0)}static ofUnknown(t){return this.from(t,"",this.NULL,"null",!1)}static ofNumber(t){return this.from(t,"Number",this.ZERO,"0",!1)}static ofNumberOrOne(t){return this.from(t,"Number",this.ONE,"1",!1)}static ofNumberOrOneHundred(t){return this.from(t,"Number",this.ONE_HUNDRED,"100",!1)}static ofString(t){return this.from(t,"String",this.EMPTY,'""',!1)}static ofBoolean(t){return this.from(t,"Boolean",this.TRUE,"true",!1)}static ofBooleanOrTrue(t){return this.from(t,"Boolean",this.TRUE,"true",!1)}static ofBooleanOrFalse(t){return this.from(t,"Boolean",this.FALSE,"false",!1)}static ofElementOrNull(t){return this.from(t,"",void 0,"null",!1,"container")}}fe.NULL=()=>null,fe.ZERO=()=>0,fe.ONE=()=>1,fe.ONE_HUNDRED=()=>100,fe.EMPTY=()=>"",fe.TRUE=()=>!0,fe.FALSE=()=>!1;class me{constructor(t){this.reset=t||pe.NONE}initialize(t,e){}execute(t,e,i){}onResize(t,e){}onFocus(t,e){}onBlur(t,e){}onClick(t,e,i){}onDblClick(t,e,i,s){}onDowning(t,e,i){}onDown(t,e,i){}onMove(t,e,i){}onOver(t,e,i){}onOut(t,e,i){}onUp(t,e,i){}onUpOutside(t,e,i){}onPressed(t,e,i){}onUnpressed(t,e,i){}onKeyDown(t,e,i){}onKeyUp(t,e,i){}onRightClick(t,e,i){}onRightDowning(t,e,i){}onRightDown(t,e,i){}onRightUp(t,e,i){}onRightUpOutside(t,e,i){}onRightPressed(t,e,i){}onRightUnpressed(t,e,i){}onRender(t,e,i,s){}}class ve extends me{constructor(t,e){super(e),this.condition=fe.ofBoolean(t.condition)}}class Te extends ve{constructor(t,e){super(t,e),this.interval=t.interval}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.interval,n=s<<1,o=i%n;o<s?(this.toOff(t,e),e.effect=i+(s-o)):(this.toOn(t,e),e.effect=i+(n-o))}}toOn(t,e){}toOff(t,e){}}class we extends Te{constructor(t){super(t,pe.COLOR)}toOn(t,e){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.brighten(i.color,.5),i.alpha);const s=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.brighten(s.color,.5),s.alpha);const n=_e.toBaseText(t,e);t.text.set(void 0,de.brighten(n.color,.5),n.alpha);const o=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.brighten(o.color,.5),o.alpha),e.written|=this.reset}}class Ee extends Te{constructor(t){super(t,pe.COLOR_FILL),this.color=t.color,this.alpha=t.alpha}toOn(t,e){t.fill.set(void 0,this.color,this.alpha),e.written|=this.reset}}class ye extends Te{constructor(t){super(t,pe.COLOR_STROKE),this.color=t.color,this.alpha=t.alpha}toOn(t,e){t.stroke.set(void 0,this.color,this.alpha),e.written|=this.reset}}class xe extends Te{constructor(t){super(t,pe.COLOR)}toOn(t,e){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.darken(i.color,.5),i.alpha);const s=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.darken(s.color,.5),s.alpha);const n=_e.toBaseText(t,e);t.text.set(void 0,de.darken(n.color,.5),n.alpha);const o=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.darken(o.color,.5),o.alpha),e.written|=this.reset}}class Ce extends Te{constructor(t){super(t,pe.COLOR_FILL_AND_STROKE)}toOn(t,e){const i=_e.toBaseFill(t,e);t.fill.set(void 0,i.color,.5*i.alpha);const s=_e.toBaseStroke(t,e);t.stroke.set(void 0,s.color,.5*s.alpha),e.written|=this.reset}}class De extends Te{constructor(t){super(t,pe.VISIBILITY)}toOn(t,e){t.visible=!0,e.written|=this.reset}toOff(t,e){t.visible=!1,e.written|=this.reset}}const Se={VISIBILITY:0,BRIGHTEN:1,DARKEN:2,OPACITY:3,COLOR_FILL:4,COLOR_STROKE:5};class be{constructor(t,e){this.type=t,this.condition=e}isEquals(t){return this.type===t.type&&this.condition===t.condition}toLabel(){return this.getTheme().toLabel(this)}getTheme(){var t;return null!==(t=be.THEME)&&void 0!==t?t:be.THEME=$.getInstance().get("EShapeActionValue")}}class Ie extends be{constructor(t,e,i){super(t,e),this.subtype=i}isEquals(t){return super.isEquals(t)&&t instanceof Ie&&this.subtype===t.subtype}}const Oe={SHOW_HIDE:0,BLINK:1,TRANSFORM:2,OPEN:3,EMIT_EVENT:4,CHANGE_COLOR_LEGACY:5,CHANGE_TEXT:6,CHANGE_CURSOR:7,MISC:8,CHANGE_COLOR:9,GESTURE:10,EXTENSION:1e3};class Ae{static toResource(t,e,i){if(0<=t&&t<e.length){const s=e[t];if(wt(s)&&0<=s&&s<i.length)return i[s]}return""}}class Re extends Ie{constructor(t,e,i,s,n){super(Oe.BLINK,e,t),this.interval=i,this.color=s,this.alpha=n}isEquals(t){return super.isEquals(t)&&t instanceof Re&&this.interval===t.interval&&this.color===t.color&&this.alpha===t.alpha}toRuntime(){switch(this.subtype){case Se.BRIGHTEN:return new we(this);case Se.COLOR_FILL:return new Ee(this);case Se.COLOR_STROKE:return new ye(this);case Se.DARKEN:return new xe(this);case Se.OPACITY:return new Ce(this);case Se.VISIBILITY:return new De(this)}}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype},${this.interval},${this.color},${this.alpha}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources);return new Re(t[2],i,t[3],t[4],t[5])}}class Me{static blend(t,e,i){const s=Math.max(0,Math.min(1,i));return Math.max(0,Math.min(1,t*(1-s)+e*s))}}class ke extends ve{constructor(t){super(t,t.subtype<<3)}set(t,e,i,s,n,o){const r=this.reset;if(null!=s){if(null!=n)if(null!=o){if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}}else r&pe.COLOR_FILL&&t.fill.set(void 0,s,n),r&pe.COLOR_STROKE&&t.stroke.set(void 0,s,n),r&pe.COLOR_TEXT&&t.text.set(void 0,s,n),r&pe.COLOR_TEXT_OUTLINE&&t.text.outline.set(void 0,s,n);else if(null!=o){if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.blend(i.color,s,o),i.alpha)}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.blend(i.color,s,o),i.alpha)}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,de.blend(i.color,s,o),i.alpha)}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.blend(i.color,s,o),i.alpha)}}else{if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,s,i.alpha)}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,s,i.alpha)}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,s,i.alpha)}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,s,i.alpha)}}e.written|=r}else if(null!=n){if(null!=o){if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,i.color,Me.blend(i.alpha,n,o))}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,i.color,Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,i.color,Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,i.color,Me.blend(i.alpha,n,o))}}else{if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,i.color,n)}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,i.color,n)}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,i.color,n)}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,i.color,n)}}e.written|=r}}}const Le={COLOR_AND_ALPHA:0,COLOR:1,ALPHA:2,CODE:3,BRIGHTNESS:4};class Ne extends ke{constructor(t){switch(super(t),t.target){case Le.COLOR:this.color=t.color,this.alpha=null;break;case Le.ALPHA:this.color=null,this.alpha=t.alpha;break;default:this.color=t.color,this.alpha=t.alpha}this.blend=fe.ofNumberOrNull(t.blend)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.color,n=this.alpha,o=this.blend(t,i,ge);this.set(t,e,i,s,n,o)}}}const Pe={NONE:0,FILL:1,STROKE:2,TEXT:4,TEXT_OUTLINE:8,FILL_AND_STROKE:3,ALL:15},Be={FILL:0,STROKE:1,FILL_AND_STROKE:2,TEXT:3,TEXT_OUTLINE:4,ALL:5};class ze{static from(t){if(t[0]===Oe.CHANGE_COLOR)return t[2];switch(t[2]){case Be.FILL:return Pe.FILL;case Be.STROKE:return Pe.STROKE;case Be.FILL_AND_STROKE:return Pe.FILL_AND_STROKE;case Be.TEXT:return Pe.TEXT;case Be.TEXT_OUTLINE:return Pe.TEXT_OUTLINE;case Be.ALL:return Pe.ALL}}static unpack(t){const e=[];return t&Pe.FILL&&e.push(Pe.FILL),t&Pe.STROKE&&e.push(Pe.STROKE),t&Pe.TEXT&&e.push(Pe.TEXT),t&Pe.TEXT_OUTLINE&&e.push(Pe.TEXT_OUTLINE),e}static pack(t){let e=Pe.NONE;for(let i=0,s=t.length;i<s;++i)e|=t[i];return e}}class Ue extends Ie{constructor(t,e,i,s,n,o){super(Oe.CHANGE_COLOR,e,t),this.target=i,this.color=s,this.alpha=n,this.blend=o}isEquals(t){return super.isEquals(t)&&t instanceof Ue&&this.target===t.target&&this.color===t.color&&this.alpha===t.alpha&&this.blend===t.blend}toRuntime(){return new Ne(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.blend);return t.addResource(`[${this.type},${e},${this.subtype},${this.target},${this.color},${this.alpha},${i}]`)}static deserialize(t,e){const i=ze.from(t),s=Ae.toResource(1,t,e.resources),n=Ae.toResource(6,t,e.resources);return new Ue(i,s,t[3],t[4],t[5],n)}}class Fe extends ke{constructor(t){super(t),this.brightness=fe.ofNumberOrNull(t.brightness)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.brightness(t,i,ge);this.set(t,e,i,s)}}set(t,e,i,s){const n=this.reset;if(null!=s){const i=this.toAdjusted;if(n&pe.COLOR_FILL){const n=_e.toBaseFill(t,e);t.fill.set(void 0,i(n.color,s),n.alpha)}if(n&pe.COLOR_STROKE){const n=_e.toBaseStroke(t,e);t.stroke.set(void 0,i(n.color,s),n.alpha)}if(n&pe.COLOR_TEXT){const n=_e.toBaseText(t,e);t.text.set(void 0,i(n.color,s),n.alpha)}if(n&pe.COLOR_TEXT_OUTLINE){const n=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,i(n.color,s),n.alpha)}e.written|=n}}toAdjusted(t,e){return 0<=e?de.brighten(t,+e):de.darken(t,-e)}}class He extends Ie{constructor(t,e,i){super(Oe.CHANGE_COLOR,e,t),this.brightness=i}isEquals(t){return super.isEquals(t)&&t instanceof He&&this.brightness===t.brightness}toRuntime(){return new Fe(this)}serialize(t){const e=t.addResource(this.condition),i=Le.BRIGHTNESS,s=t.addResource(this.brightness);return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}static deserialize(t,e){const i=ze.from(t),s=Ae.toResource(1,t,e.resources),n=Ae.toResource(4,t,e.resources);return new He(i,s,n)}}class Ge extends ke{constructor(t){super(t),this.color=fe.ofNumberOrNull(t.color),this.alpha=fe.ofNumberOrNull(t.alpha),this.blend=fe.ofNumberOrNull(t.blend)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.color(t,i,ge),n=this.alpha(t,i,ge),o=this.blend(t,i,ge);this.set(t,e,i,s,n,o)}}}class Ve extends Ie{constructor(t,e,i,s,n){super(Oe.CHANGE_COLOR,e,t),this.color=i,this.alpha=s,this.blend=n}isEquals(t){return super.isEquals(t)&&t instanceof Ve&&this.color===t.color&&this.alpha===t.alpha&&this.blend===t.blend}toRuntime(){return new Ge(this)}serialize(t){const e=t.addResource(this.condition),i=Le.CODE,s=t.addResource(this.color),n=t.addResource(this.alpha),o=t.addResource(this.blend);return t.addResource(`[${this.type},${e},${this.subtype},${i},${s},${n},${o}]`)}static deserialize(t,e){const i=ze.from(t),s=Ae.toResource(1,t,e.resources),n=Ae.toResource(4,t,e.resources),o=Ae.toResource(5,t,e.resources),r=Ae.toResource(6,t,e.resources);return new Ve(i,s,n,o,r)}}class We extends ve{constructor(t){super(t,pe.CURSOR),this.name=fe.ofStringOrNull(t.name)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.name(t,i,ge);null!=s&&(t.cursor=s,e.written|=this.reset)}}}class Ke extends be{constructor(t,e){super(Oe.CHANGE_CURSOR,t),this.name=e}isEquals(t){return super.isEquals(t)&&t instanceof Ke&&this.name===t.name}toRuntime(){return new We(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.name);return t.addResource(`[${this.type},${e},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(2,t,e.resources);return new Ke(i,s)}}class Xe{format(t,e,i){return i.getHours()<12?"AM":"PM"}}class Ye{format(t,e,i){return i.getHours()<12?"am":"pm"}}class je{format(t,e,i){return String(i.getDate())}}class $e{format(t,e,i){return""+(0|t)}}class qe{constructor(t){this.precision=null!=t?+t.substring(1,t.length):void 0}}class Ze extends qe{format(t,e,i){return t.toExponential(this.precision)}}class Je extends qe{format(t,e,i){return t.toFixed(this.precision)}}class Qe extends qe{format(t,e,i){const s=this.toAbs(t,e,i);return s<1e-24?this.format_(t,1,""):s<1e-21?this.format_(t,1e24,"y"):s<1e-18?this.format_(t,1e21,"z"):s<1e-15?this.format_(t,1e18,"a"):s<1e-12?this.format_(t,1e15,"f"):s<1e-9?this.format_(t,1e12,"p"):s<1e-6?this.format_(t,1e9,"n"):s<.001?this.format_(t,1e6,"μ"):s<1?this.format_(t,1e3,"m"):s<1e3?this.format_(t,1,""):s<1e6?this.format_(t,.001,"k"):s<1e9?this.format_(t,1e-6,"M"):s<1e12?this.format_(t,1e-9,"G"):s<1e15?this.format_(t,1e-12,"T"):s<1e18?this.format_(t,1e-15,"P"):s<1e21?this.format_(t,1e-18,"E"):s<1e24?this.format_(t,1e-21,"Z"):this.format_(t,1e-24,"Y")}toAbs(t,e,i){return Math.abs(t)}format_(t,e,i){return`${(t*e).toFixed(this.precision)}${i}`}}class ti extends qe{format(t,e,i){return t.toPrecision(this.precision)}}class ei{format(t,e,i){return String(i.getHours())}}class ii{format(t,e,i){return String(i.getHours()%12)}}class si{format(t,e,i){return String(i.getMonth()+1)}}class ni{format(t,e,i){return String(i.getMinutes())}}class oi{format(t,e,i){return String(i.getMilliseconds())}}class ri{format(t,e,i){return(100*t|0)+"%"}}class ai{format(t,e,i){return(0|t)+"%"}}class hi{constructor(t,e,i){this.length=t,this.character=e,this.node=i}format(t,e,i){return ue(this.node.format(t,e,i),this.length,this.character)}}class li{constructor(t){this.node=t}format(t,e,i){const s=this.node.format(t,e,i);return 0<s.length&&"-"===s[0]?`(${s.substring(1,s.length)})`:s}}class ci{constructor(t){this.node=t}format(t,e,i){const s=this.node.format(t,e,i);return 0<s.length&&"-"!==s[0]?"+"+s:s}}class ui{format(t,e,i){return Math.round(100*t)+"%"}}class di{format(t,e,i){return Math.round(t)+"%"}}class pi{constructor(t,e,i,s,n,o,r){this.Y=t,this.M=e,this.D=i,this.H=s,this.m=n,this.s=o,this.mi=r}format(t,e,i){return e<1e3?`${this.s.format(t,e,i)}.${this.mi.format(t,e,i)}`:e<6e4?`${this.m.format(t,e,i)}:${this.s.format(t,e,i)}`:e<36e5?`${this.H.format(t,e,i)}:${this.m.format(t,e,i)}`:e<864e5?`${this.M.format(t,e,i)}/${this.D.format(t,e,i)} ${this.H.format(t,e,i)}`:e<2592e6?`${this.M.format(t,e,i)}/${this.D.format(t,e,i)}`:`${this.Y.format(t,e,i)}/${this.M.format(t,e,i)}`}}class _i{constructor(t){this.node=t}format(t,e,i){const s=this.node.format(t,e,i);return 0<s.length&&"-"!==s[0]?" "+s:s}}class gi extends Qe{toAbs(t,e,i){return Math.abs(e)}}class fi{constructor(t){this.str=t}format(t,e,i){return this.str}}class mi{format(t,e,i){return String(i.getFullYear())}}class vi{format(t,e,i){return String(i.getFullYear()%100)}}class Ti{format(t,e,i){const s=i.getTimezoneOffset();return`${s<=0?"+":"-"}${ue(String(Math.floor(Math.abs(s)/60)),2,"0")}:${ue(String(Math.floor(Math.abs(s)%60)),2,"0")}`}}class wi{format(t,e,i){return""+Math.round(t)}}class Ei{format(t,e,i){return String(i.getSeconds())}}let yi=void 0;const xi=(t,e,i)=>{switch(t){case"_":return new hi(e," ",i);case"-":return i;default:return new hi(e,"0",i)}},Ci=(t,e)=>{switch(t){case"_":return new _i(e);case"+":return new ci(e);case"(":return new li(e);default:return e}};class Di{constructor(t){const e=(t=>{let e=0,i=!1;const s=[],n=(()=>{let t=yi;return t?t.lastIndex=0:(t=/%(0|_|-|\+|\()?(\.\d+)?(Y(?:MD?)?|y(?:MD?)?|MD?|D|H(?:ms?)?|h(?:ms?)?|m(?:i|s)?|a|A|s(?:s?i|dt)?|z|%|f(?:si)?|e|g|d|r(?:d|p)|p|P|RP)/g,yi=t),t})();for(;;){const o=n.exec(t);if(null==o){e<t.length&&s.push(new fi(t.substring(e,t.length)));break}{const n=o.index;e<n&&s.push(new fi(t.substring(e,n))),e=n+o[0].length;const r=o[0],a=o[1],h=o[2];switch(o[3]){case"Y":i=!0,s.push(new mi);break;case"YM":i=!0,s.push(new mi,new fi("/"),xi(a,2,new si));break;case"YMD":i=!0,s.push(new mi,new fi("/"),xi(a,2,new si),new fi("/"),xi(a,2,new je));break;case"y":i=!0,s.push(xi(a,2,new vi));break;case"yM":i=!0,s.push(xi(a,2,new vi),new fi("/"),xi(a,2,new si));break;case"yMD":s.push(xi(a,2,new vi),new fi("/"),xi(a,2,new si),new fi("/"),xi(a,2,new je));break;case"M":i=!0,s.push(xi(a,2,new si));break;case"MD":i=!0,s.push(xi(a,2,new si),new fi("/"),xi(a,2,new je));break;case"D":i=!0,s.push(xi(a,2,new je));break;case"H":i=!0,s.push(xi(a,2,new ei));break;case"Hm":i=!0,s.push(xi(a,2,new ei),new fi(":"),xi(a,2,new ni));break;case"Hms":i=!0,s.push(xi(a,2,new ei),new fi(":"),xi(a,2,new ni),new fi(":"),xi(a,2,new Ei));break;case"h":i=!0,s.push(xi(a,2,new ii));break;case"hm":i=!0,s.push(xi(a,2,new ii),new fi(":"),xi(a,2,new ni));break;case"hms":i=!0,s.push(xi(a,2,new ii),new fi(":"),xi(a,2,new ni),new fi(":"),xi(a,2,new Ei));break;case"m":i=!0,s.push(xi(a,2,new ni));break;case"ms":i=!0,s.push(xi(a,2,new ni),new fi(":"),xi(a,2,new Ei));break;case"mi":i=!0,s.push(xi(a,3,new oi));break;case"a":i=!0,s.push(new Ye);break;case"A":i=!0,s.push(new Xe);break;case"s":i=!0,s.push(xi(a,2,new Ei));break;case"sdt":i=!0,s.push(new pi(new mi,xi(a,2,new si),xi(a,2,new je),xi(a,2,new ei),xi(a,2,new ni),xi(a,2,new Ei),xi(a,3,new oi)));break;case"z":i=!0,s.push(new Ti);break;case"%":s.push(new fi("%"));break;case"f":s.push(Ci(a,new Je(h)));break;case"e":s.push(Ci(a,new Ze(h)));break;case"g":s.push(Ci(a,new ti(h)));break;case"rd":s.push(Ci(a,new wi));break;case"d":s.push(Ci(a,new $e));break;case"P":s.push(Ci(a,new ri));break;case"p":s.push(Ci(a,new ai));break;case"RP":s.push(Ci(a,new ui));break;case"rp":s.push(Ci(a,new di));break;case"fsi":s.push(Ci(a,new Qe(h)));break;case"ssi":s.push(Ci(a,new gi(h)));break;default:s.push(new fi(r))}}}return{nodes:s,date:i}})(t);this.date=e.date,this.nodes=e.nodes}format(t,e){const i=this.nodes;let s=Di.DATE;null==s&&(s=new Date,Di.DATE=s),this.date&&s.setTime(t);let n="";for(let o=0,r=i.length;o<r;++o)n+=i[o].format(t,e,s);return n}}class Si{static create(t){return new Di(t)}}class bi extends ve{constructor(t){super(t,pe.TEXT),this.number=fe.ofNumber(t.value),this.formatters=new Map}getFormatter(t,e){const i=this.formatters,s=e.text.value;let n=i.get(s);return void 0===n&&(n=this.newFormatter(s),i.set(s,n)),n}newFormatter(t){return 0<(t=t.trim()).length?Si.create(t):null}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.number(t,i,ge),n=this.getFormatter(t,e);t.text.value=null!=n?n.format(s,0):String(s),e.written|=this.reset}}}class Ii extends ve{constructor(t){super(t,pe.TEXT),this.text=fe.ofString(t.value)}execute(t,e,i){this.condition(t,i,ge)&&(t.text.value=this.text(t,i,ge),e.written|=this.reset)}}const Oi={TEXT:0,NUMBER:1};class Ai extends Ie{constructor(t,e,i){super(Oe.CHANGE_TEXT,e,t),this.value=i}isEquals(t){return super.isEquals(t)&&t instanceof Ai&&this.value===t.value}toRuntime(){switch(this.subtype){case Oi.TEXT:return new Ii(this);case Oi.NUMBER:return new bi(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.value);return t.addResource(`[${this.type},${e},${this.subtype},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources);return new Ai(t[2],i,s)}}const Ri={DIAGRAM:0,PAGE:1,EXTENSION:1e3};class Mi{constructor(t){this._sources=this.newSources(t)}map(t,e,i){const s=this._sources;if(null==s)return!1;const n=t.id,o=n.toLowerCase(),r=o.length;if(r!==n.length)return!1;const a=s[0],h=a.length;if(0!==h&&0!==o.indexOf(a))return!1;const l=Mi.SPANS;l[0]=0,l[1]=h;const c=s.length;for(let t=1;t<c;++t){const e=t<<1,i=s[t],n=i.length;if(0===n)l[e]=r,l[e+1]=r;else{const t=o.indexOf(i,l[e-1]);if(t<0)return!1;l[e]=t,l[e+1]=t+n}}if(null!=e){const i=e.length;let o="";for(let t=0,a=c;t<a;++t){const h=t<i?e[t]:s[t],c=t<<1,u=l[c+1],d=l[c+2];o+=h+n.substring(u,t+1<a?d:r)}t.id=o}return 0<i.length&&(t.initial=i),!0}newSources(t){if(null==t)return null;const e=t.trim();return e.length<=0?null:e.toLowerCase().split(Mi.WILDCARD)}static split(t){if(null==t)return null;const e=t.trim();return e.length<=0?null:e.split(this.WILDCARD)}}Mi.WILDCARD="*",Mi.SPANS=[];class ki{constructor(t,e,i,s,n){this.resources=t.resources,this.data=t.data||t.tags||t.resources,this.pieces=e,this.pieceData=i,this.mode=s,this.depth=n,this._actions=new Map,this._fills=new Map,this._strokes=new Map,this._data=new Map,this._dataValues=new Map,this._dataMapping=new Map,this._dataMappers=new Map,this._dataDestinations=new Map,this._dataSystem=new Map,this._ranges=new Map,this._aligns=new Map,this._margins=new Map,this._texts=new Map,this._textOutlines=new Map,this._capabilities=new Map,this._extensions=new Map}getAction(t){return this._actions.get(t)}setAction(t,e){this._actions.set(t,e)}getFill(t){return this._fills.get(t)}setFill(t,e){this._fills.set(t,e)}getStroke(t){return this._strokes.get(t)}setStroke(t,e){this._strokes.set(t,e)}getData(t){return this._data.get(t)}setData(t,e){this._data.set(t,e)}getDataValue(t){return this._dataValues.get(t)}setDataValue(t,e){this._dataValues.set(t,e)}getDataMapping(t){return this._dataMapping.get(t)}setDataMapping(t,e){this._dataMapping.set(t,e)}getDataMapper(t){const e=this._dataMappers;let i=e.get(t);return void 0===i&&(i=new Mi(t),e.set(t,i)),i}getDataDestination(t){const e=this._dataDestinations;let i=e.get(t);return void 0===i&&(i=Mi.split(t),e.set(t,i)),i}getDataSystem(t){return this._dataSystem.get(t)}setDataSystem(t,e){this._dataSystem.set(t,e)}getRange(t){return this._ranges.get(t)}setRange(t,e){this._ranges.set(t,e)}getAlign(t){return this._aligns.get(t)}setAlign(t,e){this._aligns.set(t,e)}getMargin(t){return this._margins.get(t)}setMargin(t,e){this._margins.set(t,e)}getText(t){return this._texts.get(t)}setText(t,e){this._texts.set(t,e)}getTextOutline(t){return this._textOutlines.get(t)}setTextOutline(t,e){this._textOutlines.set(t,e)}getCapability(t){return this._capabilities.get(t)}setCapability(t,e){this._capabilities.set(t,e)}getExtension(t){return this._extensions.get(t)}setExtension(t,e){this._extensions.set(t,e)}}const Li={VIEWER:0,EDITOR_DATA_MAPPED:1,EDITOR:2},Ni={NONE:0,TOP:1,RIGHT:2,BOTTOM:4,LEFT:8,ALL:15},Pi={TAIL:1,HEAD:2,ALL:3};class Bi extends te{constructor(t=s.CIRCLE){super(t)}clone(){return new Bi(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&ee(this,t,e,i,s,n,o)}}class zi extends Bi{constructor(t=s.EMBEDDED_ACCEPTOR_EDGE){super(t),this._subtype=Pi.HEAD,this._side=Ni.ALL,this._vvisible=!0}get subtype(){return this._subtype}set subtype(t){this._subtype=t}get side(){return this._side}set side(t){this._side=t}get vvisible(){return this._vvisible}set vvisible(t){this._vvisible=t}clone(){return new zi(this.type).copy(this)}copy(t,e=ht.ALL){return super.copy(t,e),t instanceof zi&&(this._subtype=t.subtype,this._side=t.side,this._vvisible=t.vvisible),this}serialize(t){const e=super.serialize(t);return e[15]=this._subtype|this._side<<2|(this._vvisible?64:0),e}}class Ui{static get(t){const e=this.mappings[t];return null!=e?e:Ot.PRIMITIVE}static contains(t,e){if(null!=t){let i=this.get(t.type);const s=t.getCapability();return null!=s&&(i&=~s.removed,i|=s.added,i&=~s.locked),(i&e)===e}return!1}static set(t,e){this.mappings[t]=e}}Ui.mappings={};const Fi=t=>Math.abs(t)<.001?t<0?-.001:.001:t;class Hi{constructor(e,i,s){this.shape=e,this.base=new t.Point(i,s);const n=e.size;this.shapeBase=new t.Point(n.x,n.y),this.transform=new t.Matrix,e.updateTransform(),e.transform.localTransform.copyTo(this.transform),this.capable=Ui.contains(e,Ot.POSITION)&&Ui.contains(e,Ot.WIDTH)&&Ui.contains(e,Ot.HEIGHT)&&Ui.contains(e,Ot.ROTATION)&&Ui.contains(e,Ot.SKEW)}isCompatible(t){return this.shape===t}reset(t,e,i){this.base.set(e,i);const s=t.size;this.shapeBase.copyFrom(s),t.updateTransform(),t.transform.localTransform.copyTo(this.transform)}update(t,e,i,s,n){if(!this.capable)return;const o=e/this.base.x,r=i/this.base.y,a=this.shapeBase,h=Hi.WORK_TRANSFORM;h.identity().append(this.transform).translate(-s,-n).scale(o,r).translate(+s,+n),t.lock(Mt.TRANSFORM_AND_UPLOADED),this.apply(t,h,Ot.ALL,a),t.unlock(Mt.TRANSFORM_CHILD,!1),t.unlock(Mt.TRANSFORM_THIS|Mt.TRANSFORM_PARENT|Mt.UPLOADED,!0)}apply(t,e,i,s){const n=e.a,o=e.b,r=e.c,a=e.d,h=e.tx,l=e.ty,c=t.transform,u=!!(i&Ot.POSITION),d=!!(i&Ot.ROTATION),p=!!(i&Ot.SKEW),_=!!(i&Ot.WIDTH),g=!!(i&Ot.HEIGHT);if(d||p){const t=Math.atan2(-r,a),e=Math.atan2(+o,n);if(d&&(c.rotation=.5*(t+e)),p){const i=.5*(e-t);c.skew.set(i,i)}}if(u){const t=c.pivot,e=t.x,i=t.y;c.position.set(h+(n*e+r*i),l+(o*e+a*i))}if(null!=s&&(_||g)){const e=Fi(s.x*Math.sqrt(n*n+o*o)),i=Fi(s.y*Math.sqrt(r*r+a*a)),h=t.size;_&&g?h.set(e,i):_?h.x=e:h.y=i}}}Hi.WORK_TRANSFORM=new t.Matrix;class Gi{constructor(e,i,s,n){this._workRectForCalcRect=new t.Rectangle,this._workRectForFit=new t.Rectangle,this._parent=e,this._layouts=[],this._size=new t.Point(i,s),this._isFittable=n}init(){return this}get x(){return this._size.x}set x(t){const e=this._size;if(e.x!==t){const i=e.x;e.x=t,this.onChange(i,e.y)}}get y(){return this._size.y}set y(t){const e=this._size;if(e.y!==t){const i=e.y;e.y=t,this.onChange(e.x,i)}}set(t,e){let i=!1;const s=this._size,n=s.x,o=s.y;return null!=t&&n!==t&&(i=!0,s.x=t),null!=e&&o!==e&&(i=!0,s.y=e),i&&this.onChange(n,o),this}clone(){const t=this._size;return new Gi(this._parent,t.x,t.y,this._isFittable)}copy(){}copyFrom(t){const e=t.x,i=t.y,s=this._size,n=s.x,o=s.y;return n===e&&o===i||(s.x=e,s.y=i,this.onChange(n,o)),this}copyTo(t){return this._size.copyTo(t)}equals(t){return this._size.equals(t)}fit(){return this._isFittable&&this.doFit(),this}doFit(){const t=this._parent;t.lock(Mt.TRANSFORM);const e=this.calcRect(this._workRectForFit),i=this._size;i.set(e.width,e.height),t.updateTransform();const s=t.transform,n=e.x+.5*e.width,o=e.y+.5*e.height,r=s.position,a=s.localTransform,h=a.a,l=a.b,c=a.c,u=a.d,d=s.pivot,p=n-d.x,_=o-d.y;r.set(r.x+(h*p+c*_),r.y+(l*p+u*_)),d.set(n,o),this.reset(t.children,this._layouts,i),t.unlock(Mt.TRANSFORM_CHILD|Mt.TRANSFORM_THIS,!0),t.unlock(Mt.TRANSFORM_PARENT,!1)}reset(t,e,i){for(let s=0,n=Math.min(e.length,t.length);s<n;++s){const n=t[s],o=e[s];if(!o.isCompatible(n)){e.length=s;break}o.reset(n,i.x,i.y)}t.length<e.length&&(e.length=t.length)}calcRect(t){const e=this._parent.children;if(e.length<=0)t.x=0,t.y=0,t.width=0,t.height=0;else{const i=this._workRectForCalcRect;e[0].getBoundsLocal(!1,t);for(let s=1,n=e.length;s<n;++s)e[s].getBoundsLocal(!1,i),t.enlarge(i)}return t}onChange(t,e){const i=this._parent,s=this._size,n=i.transform.pivot;this.onChange_(i.children,this._layouts,s.x,s.y,n.x,n.y,t,e),i.onSizeChange()}onChange_(t,e,i,s,n,o,r,a){for(let r=0,a=Math.min(e.length,t.length);r<a;++r){const a=t[r],h=e[r];if(!h.isCompatible(a)){e.length=r;break}h.update(a,i,s,n,o)}for(let h=e.length,l=t.length;h<l;++h){const l=t[h],c=this.newLayout(l,r,a);c.update(l,i,s,n,o),e.push(c)}e.length!==t.length&&(e.length=t.length)}newLayout(t,e,i){return t.layout||new Hi(t,e,i)}}class Vi{constructor(e,i,s,n,o){this._parent=e,this._x=i,this._y=s,this._base=new t.Point(n,o)}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.onChange())}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.onChange())}get base(){return this._base}init(){return this._base.copyFrom(this),this.onChange(),this}clone(){const t=this._base;return new Vi(this._parent,this._x,this._y,t.x,t.y)}set(t,e){let i=!1;return null!=t&&this._x!==t&&(this._x=t,i=!0),null!=e&&this._y!==e&&(this._y=e,i=!0),i&&this.onChange(),this}copyFrom(t){return t instanceof Vi&&this._base.copyFrom(t.base),this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this.onChange()),this}copyTo(t){return t instanceof Vi&&this._base.copyTo(t.base),t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}fit(){return this}onChange(){const t=this._base;this._parent.transform.scale.set(this._x/t.x,this._y/t.y)}}class Wi{constructor(){}get enable(){return!0}set enable(t){}get color(){return 16777215}set color(t){}get alpha(){return 1}set alpha(t){}copy(t){}set(t,e,i){}clone(){return new Wi}toObject(){return{enable:!0,color:16777215,alpha:1}}serialize(t){return-1}deserialize(t,e){}}class Ki{constructor(){}get enable(){return!1}set enable(t){}get color(){return 16777215}set color(t){}get alpha(){return 1}set alpha(t){}get width(){return 1}set width(t){}get align(){return 0}set align(t){}get side(){return V.NONE}set side(t){}get style(){return r.NONE}set style(t){}copy(t){}set(t,e,i,s,n,o,r){}clone(){return new Ki}toObject(){return{enable:!1,color:16777215,alpha:1,width:1,align:0,side:V.NONE,style:r.NONE}}serialize(t){return-1}deserialize(t,e){}}class Xi extends kt{constructor(t,e,i){super(i),this._mode=t,this._depth=e;const s=this.newData();this.data=s,this.tag=s,this.size=this.newGroupSize(t,e),this.fill=this.newGroupFill(),this.stroke=this.newGroupStroke(),this.text=this.newGroupText()}get mode(){return this._mode}get depth(){return this._depth}newGroupSize(t,e){const i=q.SIZE_X,s=q.SIZE_Y;return t!==Li.VIEWER?new Gi(this,i,s,this.isGroupSizeFittable()):new Vi(this,i,s,i,s)}isGroupSizeFittable(){return!0}newData(){return new jt}newGroupFill(){return new Wi}newGroupStroke(){return new Ki}newGroupText(){return new Jt(this,q.TEXT_VALUE,q.TEXT_COLOR,q.TEXT_ALPHA,q.TEXT_FAMILY,q.TEXT_SIZE)}getBoundsSize(){const t=this.size;return t instanceof Vi?t.base:t}onChildTransformChange(){super.onChildTransformChange(),this.size.fit()}get corner(){return nt.NONE}set corner(t){}get gradient(){}set gradient(t){}serializeGradient(t){return-1}get radius(){return 0}set radius(t){}get image(){}set image(t){}serializeImage(t){return-1}get points(){}set points(t){}containsAbs(t,e,i,s,n,o,r){return!1}}class Yi extends Xi{constructor(t,e,i,n=s.EMBEDDED){super(e,i,n),this._name=t,this._depth=i}get name(){return this._name}get edges(){var t;return null!==(t=this._edges)&&void 0!==t?t:this._edges=this.newEdges()}newEdges(){const t=new Map,e=this.children;if(null!=e){const i=this.size,s=i.x,n=i.y,o=.5*s,r=.5*n;for(let i=0,a=e.length;i<a;++i){const a=e[i],h=a.transform.position,l=h.x+o,c=h.y+r,u=a.children;for(let e=0,i=u.length;e<i;++e){const i=u[e];if(i instanceof zi){i.transform.updateLocalTransform();const e=i.transform.localTransform;t.set(i.id,{type:i.subtype,x:this.toEdgePosition(l,e.tx,o,s),y:this.toEdgePosition(c,e.ty,r,n),normal:this.toEdgeNormal(-e.c,-e.d),size:{x:0,y:0},side:i.side})}}}}return t}toEdgePosition(t,e,i,s){return 1e-5<Math.abs(s)?(t+e-i)/s:0}toEdgeNormal(t,e){const i=t*t+e*e;if(1e-5<i){const s=1/i;return{x:t*s,y:e*s}}return{x:0,y:-1}}isGroupSizeFittable(){return!1}newGroupSize(t,e){const i=q.SIZE_X,s=q.SIZE_Y;return t!==Li.VIEWER&&e<=0?new Gi(this,i,s,this.isGroupSizeFittable()):new Vi(this,i,s,i,s)}clone(){const t=this.newClone().copy(this),e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].clone();s.parent=t,t.children.push(s)}return t.onChildTransformChange(),t.toDirty(),t}newClone(){return new(0,this.constructor)(this._name,this._mode,this._depth,this.type)}serializeChildren(t){return[]}serializeImage(t){return-1}serializeGradient(t){return-1}serialize(t){const e=super.serialize(t);return e[15]=t.addPiece(this._name),e}addUuid(t){this.uuid=t.addUuid(this.uuid)}updateUuid(t){this.uuid=t.updateUuid(this.uuid)}}class ji{constructor(t){this._shapes=t}find(t){return this.getUuidToShape().get(t)}getUuidToShape(){let t=this._uuidToShape;return null==t&&(t=this.newUuidToShape(),this._uuidToShape=t),t}newUuidToShape(){const t=new Map;return this.fillUuidToShape(this._shapes,t),t}fillUuidToShape(t,e){for(let i=0,s=t.length;i<s;++i){const s=t[i];if(e.set(s.uuid,s),!(s instanceof Yi)){const t=s.children;0<t.length&&this.fillUuidToShape(t,e)}}}}const $i=(t,i)=>{const n=e[t[0]]||e[s.NULL];if(null!=n){const e=n(t,i);if(null!=e)return e}throw new Error("Missing shape deserializers")},qi=(t,e)=>{const i=[];for(let s=0,n=t.length;s<n;++s)i.push($i(t[s],e));return 0<i.length?Promise.all(i).then(i=>(Zi(t,i,new ji(i),e),i)):null},Zi=(t,e,s,n)=>{for(let o=0,r=t.length;o<r;++o){const r=t[o],a=e[o],h=i[r[0]];h&&h(r,a,s,n),Zi(r[20],a.children,s,n)}};class Ji{constructor(t,e,i,s){this.name=t,this.width=e,this.height=i,this.layer=s}}const Qi=(t,e)=>Et(t)?e[t]:t;class ts{constructor(){this._edges=new Map}add(t,e,i,s,n,o,r,a,h){return this._edges.set(t,{type:Qi(e,Pi),x:i,y:s,normal:this.toNormal(i,s,n,o),size:{x:null!=r?r:0,y:null!=a?a:0},side:this.toSide(h)}),!0}toNormal(t,e,i,s){if(null!=i&&null!=s)return{x:i,y:s};{const i=t*t+e*e;if(1e-5<i){const s=1/Math.sqrt(i);return{x:t*s,y:e*s}}return{x:0,y:0}}}toSide(t){if(null==t)return Ni.TOP;if(wt(t))return t;if(Et(t))return Qi(t,Ni);{let e=Ni.NONE;for(let i=0,s=t.length;i<s;++i)e|=Qi(t[i],Ni);return e}}remove(t){const e=this._edges,i=e.get(t);return null!=i?(e.delete(t),i):null}size(){return this._edges.size}get(t,e){return this._edges.get(e)||null}each(t,e){return this._edges.forEach(e),this}contains(t){return this._edges.has(t)}clear(){const t=this._edges;return 0<t.size&&(t.clear(),!0)}}class es extends ts{get(t,e){const i=this.getEdges(t);if(null!=i){const t=i.get(e);if(null!=t)return t}return super.get(t,e)}each(t,e){const i=this.getEdges(t);return null!=i&&i.forEach((t,i)=>{e(t,i)}),super.each(t,e)}getEdges(t){return t instanceof Yi?t.edges:null}}class is{static set(t,e){let i=this._acceptors;null==i&&(i=new Map,this._acceptors=i),i.set(t,e)}static get(t){var e;const i=this._acceptors;if(null!=i){const e=i.get(t);if(null!=e)return e}const n=null!==(e=this._defaults)&&void 0!==e?e:this._defaults=new Map;switch(t){case s.EMBEDDED:let e=n.get(t);return null==e&&(e=this.newDefaultEmbedded(),n.set(t,e)),e;case s.EMBEDDED_ACCEPTOR_EDGE:let i=n.get(t);return null==i&&(i=this.newDefaultEmbeddedAcceptorEdge(),n.set(t,i)),i;default:let o=n.get(null);return null==o&&(o=this.newDefaultOther(),n.set(null,o)),o}}static newDefaultEmbedded(){return this.initDefault(new es)}static newDefaultEmbeddedAcceptorEdge(){const t=new ts;return t.add("CENTER",Pi.ALL,0,0,0,0),t}static newDefaultOther(){return this.initDefault(new ts)}static initDefault(t){const e=1/Math.sqrt(2);return t.add("TOP",Pi.ALL,0,-.5,0,-1),t.add("LEFT",Pi.ALL,-.5,0,-1,0),t.add("RIGHT",Pi.ALL,.5,0,1,0),t.add("BOTTOM",Pi.ALL,0,.5,0,1),t.add("CENTER",Pi.ALL,0,0,0,0),t.add("TOP_LEFT",Pi.ALL,-.5,-.5,-e,-e),t.add("TOP_RIGHT",Pi.ALL,.5,-.5,e,-e),t.add("BOTTOM_LEFT",Pi.ALL,-.5,.5,-e,e),t.add("BOTTOM_RIGHT",Pi.ALL,.5,.5,e,e),t}}class ss{constructor(t){this._parent=t,this._shape=null,this._edge=null,this._x=null,this._y=null}get shape(){return this._shape}set shape(t){this.set(t)}get edge(){return this._edge}set edge(t){this.set(void 0,t)}get x(){return this._x}set x(t){this.set(void 0,void 0,t)}get y(){return this._y}set y(t){this.set(void 0,void 0,void 0,t)}copy(t){return this.set(t.shape,t.edge,t.x,t.y)}set(t,e,i,s){let n=!1;return void 0!==t&&this._shape!==t&&(this._shape=t,n=!0),void 0!==e&&this._edge!==e&&(this._edge=e,n=!0),void 0!==i&&this._x!==i&&(this._x=i,n=!0),void 0!==s&&this._y!==s&&(this._y=s,n=!0),n&&this._parent.onAcceptorChange(),this}}class ns{constructor(e,i){this._parent=e,this._onChange=i,this._acceptor=new ss(this),this._acceptorTransformNew=new t.Matrix,this._acceptorTransformOld=new t.Matrix,this._hasAcceptorTransformOld=!1,this._local=new t.ObservablePoint(()=>{this.onLocalChange()},void 0),this._localIdRequired=0,this._localId=0,this._normal=new t.ObservablePoint(()=>{this.onNormalChange()},void 0),this._normalIdRequired=0,this._normalId=0,this._side=Ni.TOP,this._margin=0,this._other=null,this._lockCount=0,this._isAcceptorChanged=!1,this._isLocalChanged=!1,this._isNormalChanged=!1,this._isOtherChanged=!1}lock(){this._lockCount+=1,1===this._lockCount&&(this._isAcceptorChanged=!1,this._isLocalChanged=!1,this._isNormalChanged=!1,this._isOtherChanged=!1)}unlock(){if(this._lockCount-=1,0===this._lockCount){let t=!1;this._isLocalChanged&&(this._localIdRequired+=1,this._localId=this._localIdRequired,t=!0),this._isNormalChanged&&(this._normalIdRequired+=1,this._normalId=this._normalIdRequired,t=!0),this._isOtherChanged&&(t=!0),this._isAcceptorChanged&&(this._hasAcceptorTransformOld=!1,this._isLocalChanged||(this._localIdRequired+=1),this._isNormalChanged||(this._normalIdRequired+=1),this.doFit()&&(t=!1)),t&&this._onChange()}}get parent(){return this._parent}get acceptor(){return this._acceptor}get local(){return this._local}get localId(){return this._localId}get normal(){return this._normal}get normalId(){return this._normalId}get side(){return this._side}set side(t){this._side!==t&&(this._side=t,this.onOtherChange())}get margin(){return this._margin}set margin(t){this._margin!==t&&(this._margin=t,this.onOtherChange())}get other(){return this._other}set other(t){this._other=t}set(t,e,i,s,n,o,r,a,h,l){this.lock(),this._acceptor.set(t,e,i,s);const c=this._local;null!=o&&null!=r?c.set(o,r):null!=o?c.x=o:null!=r&&(c.y=r);const u=this._normal;return null!=a&&null!=h?u.set(a,h):null!=a?u.x=a:null!=h&&(u.y=h),null!=l&&(this.side=l),null!=n&&(this.margin=n),this.unlock(),this}copy(t){return this.lock(),this._acceptor.copy(t.acceptor),this._local.copyFrom(t.local),this._normal.copyFrom(t.normal),this.side=t.side,this.margin=t.margin,this.unlock(),this}serialize(t){const e=this._acceptor,i=e.shape,s=i?i.uuid:null,n=e.edge,o=null!=n?t.addResource(n):-1,r=this._local,a=this._normal,h=this._side;return t.addResource(`[${s},${o},${r.x},${r.y},${this._margin},${a.x},${a.y},${e.x},${e.y},${h}]`)}deserialize(t,e,i){var s,n,o;const r=i.resources;if(0<=t&&t<r.length){let a=i.getExtension(t);null==a&&(a=JSON.parse(r[t]),i.setExtension(t,a));let h=null;const l=a[0];null!=l&&(h=e.find(l)||null),this.lock();const c=this._acceptor;c.shape=h;const u=a[1];c.edge=0<=u&&u<r.length?r[u]:null,c.x=null!==(s=a[7])&&void 0!==s?s:null,c.y=null!==(n=a[8])&&void 0!==n?n:null,this._local.set(a[2],a[3]);const d=a[5],p=a[6],_=this._normal;null!=d&&null!=p?_.set(d,p):_.set(1,0),this.side=null!==(o=a[9])&&void 0!==o?o:Ni.TOP,this.margin=a[4]||0,this.unlock(),h&&h.connector.add(this)}}fit(t){return t&&(this._localIdRequired+=1,this._normalIdRequired+=1),this.doFit(),this}doFit(){var e,i,s;const n=this._localIdRequired,o=this._localId!==n,r=this._normalIdRequired,a=this._normalId!==r;if(o||a){this._localId=n,this._normalId=r;const h=this._acceptor,l=h.shape,c=h.edge;if(null!=l&&null!=c){const n=is.get(l.type).get(l,c);if(n){const r=this._acceptorTransformOld,c=this._acceptorTransformNew;this.toAcceptorTransform(l,c);const u=this._other,d=this._hasAcceptorTransformOld&&null!=u&&null==u.acceptor.shape,p=null!==(e=ns.WORK_MATRIX)&&void 0!==e?e:ns.WORK_MATRIX=new t.Matrix;if(d&&r.copyTo(p).invert().prepend(c),this._acceptorTransformNew=r,this._acceptorTransformOld=c,this._hasAcceptorTransformOld=!0,this.lock(),o){const t=this._local,e=t.x,o=t.y,r=l.size,a=l.transform.pivot,_=a.x+r.x*(null!==(i=h.x)&&void 0!==i?i:n.x),g=a.y+r.y*(null!==(s=h.y)&&void 0!==s?s:n.y),f=c.a*_+c.c*g+c.tx,m=c.b*_+c.d*g+c.ty;if(t.set(f,m),d){const t=u.local,i=t.x,s=t.y,n=p.a*i+p.c*s+p.tx,r=p.b*i+p.d*s+p.ty,a=i-e,h=s-o,l=n-f,c=r-m,d=a*a+h*h,_=l*l+c*c;if(1e-6<_){const e=Math.sqrt(d/_);t.set(f+l*e,m+c*e)}else t.set(n,r)}}if(a){const t=n.normal,e=t.x,i=t.y,s=c.a*e+c.c*i,o=c.b*e+c.d*i,r=s*s+o*o,a=this._normal;if(1e-6<r){const t=1/Math.sqrt(r);a.set(s*t,o*t)}else a.set(e,i);if(d){const t=u.normal,e=t.x,i=t.y,s=p.a*e+p.c*i,n=p.b*e+p.d*i,o=s*s+n*n;if(1e-6<o){const e=1/Math.sqrt(o);t.set(s*e,n*e)}else t.set(e,i)}}const _=this._isLocalChanged||this._isNormalChanged;return this.unlock(),_}}}return!1}toAcceptorTransform(t,e){t.updateTransform();const i=this._parent,s=i.parent;return s instanceof kt?(i.updateTransform(),e.copyFrom(s.transform.internalTransform).invert().append(t.transform.internalTransform)):e.copyFrom(t.transform.internalTransform)}onAcceptorChange(){if(0<this._lockCount)return this._isLocalChanged=!1,this._isNormalChanged=!1,void(this._isAcceptorChanged=!0);this._hasAcceptorTransformOld=!1,this.fit(!0)}onLocalChange(){0<this._lockCount?this._isLocalChanged=!0:(this._localIdRequired+=1,this._localId=this._localIdRequired,this._onChange())}onNormalChange(){0<this._lockCount?this._isNormalChanged=!0:(this._normalIdRequired+=1,this._normalId=this._normalIdRequired,this._onChange())}onOtherChange(){0<this._lockCount?this._isOtherChanged=!0:this._onChange()}attach(){const t=this._acceptor.shape;return t&&t.connector.add(this)&&this.onAcceptorChange(),this}detach(t){const e=this._acceptor.shape;return null==e||null!=t&&t.has(e)||e.connector.remove(this)&&this.onAcceptorChange(),this}}class os{constructor(t,e){this._parent=t,this._lockCount=0,this._isChanged=!1,this._onChange=e;const i=()=>{this.onChange()},s=new ns(t,i),n=new ns(t,i);s.other=n,n.other=s,this._tail=s,this._head=n}lock(){return this._lockCount+=1,1===this._lockCount&&(this._isChanged=!1),this}unlock(){return this._lockCount-=1,0===this._lockCount&&this._isChanged&&this._onChange(),this}onChange(){0<this._lockCount?this._isChanged=!0:this._onChange()}get tail(){return this._tail}get head(){return this._head}copy(t){return this.lock(),this._tail.copy(t.tail),this._head.copy(t.head),this.unlock(),this}fit(t){return this.lock(),this._tail.fit(t),this._head.fit(t),this.unlock(),this}serialize(t){const e=this._tail.serialize(t),i=this._head.serialize(t);return t.addResource(`[${e},${i}]`)}deserialize(t,e,i){const s=i.resources;if(0<=t&&t<s.length){let n=i.getExtension(t);null==n&&(n=JSON.parse(s[t]),i.setExtension(t,n)),this.lock(),this._tail.deserialize(n[0],e,i),this._head.deserialize(n[1],e,i),this.unlock()}}attach(){this.lock();const t=this._tail,e=this._head;return t.attach(),e.attach(),t.fit(!0),e.fit(!0),this.unlock(),this}detach(t){return this.lock(),this._tail.detach(t),this._head.detach(t),this.unlock(),this}}const rs=(t,e)=>{let i=0,s=t.length-1;for(;i<=s;){const n=i+(s-i>>1),o=t[n];if(e<o)s=n-1;else{if(!(o<e))return n;i=n+1}}return-1},as=(t,e)=>{if(2<=t.length){let i=t[0],s=t[1],n=i,o=s;for(let e=2,r=t.length;e<r;e+=2){const r=t[e],a=t[e+1];i=Math.min(i,r),s=Math.min(s,a),n=Math.max(n,r),o=Math.max(o,a)}e[0]=i,e[1]=s,e[2]=n,e[3]=o}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e};class hs{constructor(e){this._parent=e,this._lockCount=0,this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1,this._type=Z.NONE,this._size=new t.ObservablePoint(()=>{this.onSizeChange()},void 0,.15*q.SIZE_X,.15*q.SIZE_Y),this._fill=this.newFill(),this._transformId=0}newFill(){return new J(this,!0,q.FILL_COLOR,1)}lock(){return this._lockCount+=1,1===this._lockCount&&(this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}unlock(){return this._lockCount-=1,0===this._lockCount&&(this._isTypeChanged?this.onTypeChange():this._isSizeChanged?this.onSizeChange():this._isFillChanged&&this.onFillChange(),this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}get type(){return this._type}set type(t){this._type!==t&&(this._type=t,this.onTypeChange())}onTypeChange(){0<this._lockCount?this._isTypeChanged=!0:this._parent.onTypeChange()}get size(){return this._size}onSizeChange(){0<this._lockCount?this._isSizeChanged=!0:this._parent.onSizeChange()}get transform(){return this.updateTransform()}updateTransform(){let e=this._transform;null==e&&(e=new t.Matrix,this._transform=e);const i=this._parent.parent,s=i.id;if(this._transformId!==s){this._transformId=s;const t=i.formatted;2<=t.length?this.toTransform(t.values,e):e.identity()}return e}toTransformMatrix(t,e,i,s,n){const o=t-i,r=e-s,a=o*o+r*r;if(1e-5<a){const i=1/Math.sqrt(a),s=o*i,h=r*i;n.set(h,-s,-s,-h,t,e)}else n.set(1,0,0,1,t,e);return n}get fill(){return this._fill}onFillChange(){0<this._lockCount?this._isFillChanged=!0:this._parent.onFillChange()}updateUploaded(){this.onFillChange()}copy(t){const e=t.size;return this.set(t.type,e.x,e.y),this}set(t,e,i){return this.lock(),null!=t&&(this.type=t),this.size.set(e,i),this.unlock(),this}serialize(t){const e=this._size,i=this._fill.serialize(t);return t.addResource(`[${this._type},${e.x},${e.y},${i}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getExtension(t);null==s&&(s=JSON.parse(i[t]),e.setExtension(t,s)),this.lock(),this.type=s[0],this._size.set(s[1],s[2]),this._fill.deserialize(s[3],e),this.unlock()}}}class ls extends hs{toTransform(t,e){const i=t.length;return 4<=i?this.toTransformMatrix(t[i-2],t[i-1],t[i-4],t[i-3],e):(e.identity(),e)}}class cs extends hs{toTransform(t,e){return 4<=t.length?this.toTransformMatrix(t[0],t[1],t[2],t[3],e):(e.identity(),e)}}class us{constructor(t){this._parent=t,this._lockCount=0,this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1,this._head=new ls(this),this._tail=new cs(this)}lock(){return this._lockCount+=1,1===this._lockCount&&(this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}unlock(){return this._lockCount-=1,0===this._lockCount&&(this._isTypeChanged?this.onTypeChange():this._isSizeChanged?this.onSizeChange():this._isFillChanged&&this.onFillChange(),this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}get parent(){return this._parent}get head(){return this._head}get tail(){return this._tail}onTypeChange(){0<this._lockCount?this._isTypeChanged=!0:this._parent.onMarkerTypeChange()}onSizeChange(){0<this._lockCount?this._isSizeChanged=!0:this._parent.onMarkerSizeChange()}onFillChange(){0<this._lockCount?this._isFillChanged=!0:this._parent.onMarkerFillChange()}copy(t){return this.lock(),this._head.copy(t.head),this._tail.copy(t.tail),this.unlock(),this}serialize(t){const e=this._head.serialize(t),i=this._tail.serialize(t);return t.addResource(`[${e},${i}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getExtension(t);null==s&&(s=JSON.parse(i[t]),e.setExtension(t,s)),this.lock(),this._head.deserialize(s[0],e),this._tail.deserialize(s[1],e),this.unlock()}}}const ds=2*Math.PI,ps=.5*Math.PI,_s=(t,e,i,s)=>t*i+e*s,gs=(t,e)=>Math.sqrt(_s(t,e,t,e)),fs=(t,e,i,s)=>t*s-e*i,ms=(t,e,i,s,n,o,r,a,h,l)=>{const c=l.center;c[0]=t,c[1]=e;const u=l.axis1;u[0]=i,u[1]=s;const d=l.axis2;d[0]=n,d[1]=o;const p=l.angle;return p[0]=r,p[1]=a,p[2]=h,l},vs=(t,e)=>{const i=t.center,s=t.axis1,n=t.axis2,o=t.angle;return ms(i[0],i[1],s[0],s[1],n[0],n[1],o[0],o[1],o[2],e)},Ts=(t,e)=>{const i=t.length;for(let s=0;s<i;++s)e[s]=t[s];return e.length!==i&&(e.length=i),e};class ws{static set(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_){const g=Math.max(Math.abs(e-i),Math.abs(r-a)),f=u?Math.max(1,Math.round(c*(g/ps))):c,m=d?f+1:f;for(let c=0;c<m;++c){const u=c/f,d=1-u,g=u,m=d*e+g*i,v=Math.cos(m),T=Math.sin(m),w=t[0]+v*s[0]+T*n[0],E=t[1]+v*s[1]+T*n[1],y=d*r+g*a,x=Math.cos(y),C=Math.sin(y),D=o[0]+x*h[0]+C*l[0],S=o[1]+x*h[1]+C*l[1],b=ps*u,I=Math.cos(b),O=Math.sin(b),A=I*I,R=O*O,M=A*w+R*D,k=A*E+R*S;p[++_]=M,p[++_]=k}return _}static interpolate(t,e,i,s,n,o,r,a){const h=a.values,l=a.segments;if(t<=2)return Ts(e,h),Ts(i,l),a;const c=this.WORK_P0||{center:[0,0],axis1:[0,0],axis2:[0,0],angle:[0,0,0]};let u=this.WORK_P1||{center:[0,0],axis1:[0,0],axis2:[0,0],angle:[0,0,0]},d=this.WORK_P2||{center:[0,0],axis1:[0,0],axis2:[0,0],angle:[0,0,0]};this.WORK_P0=c,this.WORK_P1=u,this.WORK_P2=d;let p=-1,_=-1;if(n){s(0,t,e,c),vs(c,u);for(let n=1;n<t;++n){if(s(n,t,e,d),0<=rs(i,n)){const t=n-1<<1;h[++p]=e[t+0],h[++p]=e[t+1],l[++_]=p+1>>1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,d.center,d.angle[0],d.angle[1],d.axis1,d.axis2,o,r,!1,h,p);const a=u;u=d,d=a}if(0<=rs(i,0)){const i=t-1<<1;h[++p]=e[i+0],h[++p]=e[i+1],l.unshift(0),_+=1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,c.center,c.angle[0],c.angle[1],c.axis1,c.axis2,o,r,!1,h,p)}else{s(1,t,e,c),0<=rs(i,1)?(h[++p]=e[0],h[++p]=e[1],l[++_]=1):p=this.set(c.center,c.angle[0],c.angle[1],c.axis1,c.axis2,c.center,c.angle[0],c.angle[1],c.axis1,c.axis2,o,r,!1,h,p),vs(c,u);for(let n=2,a=t-1;n<a;++n){if(s(n,t,e,d),0<=rs(i,n)){const t=n-1<<1;h[++p]=e[t+0],h[++p]=e[t+1],l[++_]=p+1>>1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,d.center,d.angle[0],d.angle[1],d.axis1,d.axis2,o,r,!1,h,p);const a=u;u=d,d=a}if(0<=rs(i,t-1)){const i=t-2<<1;h[++p]=e[i+0],h[++p]=e[i+1],l[++_]=p+1>>1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,o,r,!0,h,p)}return p+=1,h.length!==p&&(h.length=p),_+=1,l.length!==_&&(l.length=_),a}}ws.toCircle=(t,e,i,s)=>{const n=(0<t?t-1:e-1)<<1,o=t<<1,r=(t<e-1?t+1:0)<<1,a=i[n+0],h=i[n+1],l=i[o+0],c=i[o+1],u=i[r+0],d=i[r+1],p=l-a,_=c-h,g=u-l,f=d-c,m=a+.5*p,v=h+.5*_,T=l+.5*g,w=c+.5*f,E=-_,y=+p,x=-f,C=+g;let D=fs(E,y,x,C);if(Math.abs(D)<.001){if(0<=_s(p,_,g,f)||e<=2){const t=.01,e=Math.sin(t),i=gs(p,_),n=gs(g,f);return ms(l,c,0,0,g/e,f/e,-t*i/n,0,t,s)}D=.001}const S=(C*(T-m)+x*(v-w))/D,b=m+S*E,I=v+S*y,O=l-b,A=c-I,R=-A,M=+O,k=u-b,L=d-I;let N=Math.atan2(_s(R,M,k,L),_s(O,A,k,L));const P=a-b,B=h-I;let z=Math.atan2(_s(R,M,P,B),_s(O,A,P,B));return 0<z*N&&(Math.abs(z)<Math.abs(N)&&(0<N?N-=ds:N+=ds),Math.abs(N)<Math.abs(z)&&(0<z?z-=ds:z+=ds)),ms(b,I,O,A,R,M,z,0,N,s)},ws.toEllipse=(t,e,i,s)=>{const n=(0<t?t-1:e-1)<<1,o=t<<1,r=(t<e-1?t+1:0)<<1,a=i[n+0],h=i[n+1],l=i[o+0],c=i[o+1],u=i[r+0],d=i[r+1],p=a-l,_=h-c,g=u-l,f=d-c;if(e<=2){const t=.01,e=Math.sin(t);return ms(l,c,0,0,g/e,f/e,-t,0,t,s)}const m=gs(p,_),v=gs(g,f),T=_s(p,_,g,f)/(m*v),w=Math.acos(T);let E=.5*w,y=.25*w,x=0,C=0,D=0,S=0;const b=Math.max(m,v),I=Math.min(m,v);for(let t=0;t<16;++t){const t=.5*E,e=w-t;x=b*Math.sin(t),C=b*Math.cos(t),D=I*Math.sin(e),S=I*Math.cos(e),1<(1-S/C)*(1-S/C)+D*D/(x*x)?E+=y:E-=y,y*=.5}const O=Math.asin(Math.min(D/x,1));if(m<v){const t=g/v,e=f/v;let i,n;0<fs(p,_,g,f)?(i=+e,n=-t):(i=-e,n=+t);const o=-C*C/v,r=-C*x/v,a=o*t+r*i,h=o*e+r*n,m=l-a,T=c-h;return ms(m,T,a,h,u-m,d-T,-O,0,ps,s)}{const t=p/m,e=_/m;let i,n;fs(p,_,g,f)<0?(i=+e,n=-t):(i=-e,n=+t);const o=-C*C/m,r=-C*x/m,u=o*t+r*i,d=o*e+r*n,v=l-u,T=c-d;return ms(v,T,u,d,-(a-v),-(h-T),-ps,0,O,s)}},ws.toHybrid=(t,e,i,s)=>{const n=ws.toCircle(t,e,i,s),o=n.angle[0],r=n.angle[2],a=Math.min(o,r),h=Math.max(o,r);return a<-ps||ps<h?ws.toEllipse(t,e,i,s):n};const Es=(t,e,i,s,n)=>(ws.interpolate(t,e,i,ws.toHybrid,!!(s&F.CLOSED),q.CURVE_SEGMENT_COUNT,!0,n),n.length=n.values.length>>1,n.style=s,n),ys=(t,e)=>{const i=t.length;for(let s=0;s<i;++s)e[s]=t[s];return e.length!==i&&(e.length=i),e},xs=(t,e,i,s,n,o)=>{const r=1-n;return o[0]=t*r+i*n,o[1]=e*r+s*n,o},Cs=(t,e,i,s,n,o,r,a,h,l,c)=>{const u=[0,0],d=[0,0],p=[0,0];for(let _=r;_<a;++_){const r=_/h;xs(t,e,i,s,r,u),xs(i,s,n,o,r,d),xs(u[0],u[1],d[0],d[1],r,p),l[++c]=p[0],l[++c]=p[1]}return c},Ds=(t,e,i,s,n)=>(((t,e,i,s,n,o)=>{const r=o.values,a=o.segments;if(t<=2)return ys(e,r),ys(i,a),o;let h=-1,l=-1;const c=n>>1;if(s){let s=0;for(;s+2<t;s+=2){const t=s<<1,o=0<=rs(i,s+1),u=0<=rs(i,s+2);o&&u?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1)):o?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1),h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],c,n,n,r,h)):u?(h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,c,n,r,h),a[++l]=1+(h>>1)):h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,n,n,r,h)}if(s+1<t){const t=s<<1,o=0<=rs(i,s+1),u=0<=rs(i,0);o&&u?(r[++h]=e[0],r[++h]=e[1],a.unshift(0),l+=1):o?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1),h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[0],e[1],c,n,n,r,h)):u?(h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[0],e[1],0,c,n,r,h),a[++l]=1+(h>>1)):h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[0],e[1],0,n,n,r,h)}else if(s<t){const t=s<<1;r[++h]=e[t+0],r[++h]=e[t+1],0<=rs(i,0)&&(a.unshift(0),l+=1)}}else{let s=0;for(;s+2<t;s+=2){const t=s<<1,o=0<=rs(i,s+1),u=0<=rs(i,s+2);o&&u?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1)):o?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1),h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],c,n,n,r,h)):u?(h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,c,n,r,h),a[++l]=1+(h>>1)):h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,n,n,r,h)}for(;s+1<t;++s){const t=s<<1;r[++h]=e[t+0],r[++h]=e[t+1],r[++h]=e[t+2],r[++h]=e[t+3],0<=rs(i,s+1)&&(a[++l]=1+(h>>1))}for(;s<t;++s){const t=s<<1;r[++h]=e[t+0],r[++h]=e[t+1]}}h+=1,r.length!==h&&(r.length=h),l+=1,a.length!==l&&(a.length=l)})(t,e,i,!!(s&F.CLOSED),q.CURVE_SEGMENT_COUNT,n),n.length=n.values.length>>1,n.style=s,n);class Ss{static set(t,e){null==this.data&&(this.data=this.newData()),this.data.set(t,e)}static get(t){return null==this.data&&(this.data=this.newData()),this.data.get(t)}static each(t){null==this.data&&(this.data=this.newData()),this.data.forEach((e,i)=>{t(i,e)})}static find(t){return this.get((t&F.FORMATTER_MASK)>>F.FORMATTER_SHIFT)}static newData(){const t=new Map,e=$.get("EShapePointsFormatter");return t.set(F.FORMATTER_CURVE_SPLINE,{label:e.getCurveSplineLabel(),formatter:Es}),t.set(F.FORMATTER_CURVE_BEZIER_QUADRATIC,{label:e.getCurveBezierQuadraticLabel(),formatter:Ds}),t}}class bs{constructor(e){this._parent=e,this._valuesBaseLength=0,this._values=[],this._segments=[],this._length=0,this._plength=0;const i=e.size,s=i.x,n=i.y;this._parentSizeBase=new t.Point(s,n),this._parentSizeFitted=new t.Point(s,n),this._id=0,this._style=F.NONE,this._formattedId=-1}get length(){return this._length}get plength(){return this._plength}toFitted(t,e){this._valuesBase=void 0,this._parentSizeFitted.set(t,e),this._parentSizeBase.set(t,e)}onSizeChange(){this.fit()}fit(){const t=this._parent,e=this._parentSizeFitted,i=t.size,s=i.x,n=i.y,o=1e-5;if(Math.abs(s-e.x)<=o&&Math.abs(n-e.y)<=o)return;e.set(s,n);const r=this._parentSizeBase,a=o<Math.abs(r.x),h=o<Math.abs(r.y);if(!a&&!h)return;const l=a?s/r.x:1,c=h?n/r.y:1,u=this._values;let d=this._valuesBase;if(null==d){d=[],this._valuesBase=d;for(let t=0,e=u.length;t<e;t+=2){const e=u[t],i=u[t+1];u[t]=e*l,u[t+1]=i*c,d.push(e,i)}}else for(let t=0,e=u.length;t<e;t+=2)u[t]=d[t]*l,u[t+1]=d[t+1]*c;if(this._id+=1,this._formatter||this._style&F.FORMATTER_MASK){const e=t.uploaded;e&&!e.isCompatible(t)&&t.toDirty()}}get id(){return this.fit(),this._id}get values(){return this.fit(),this._values}set values(t){this.set(t,void 0,void 0)}get segments(){return this._segments}set segments(t){this.set(void 0,t,void 0)}get style(){return this._style}set style(t){this.set(void 0,void 0,t)}get marker(){let t=this._marker;return null==t&&(t=this.newMarker(),this._marker=t),t}getMarker(){return this._marker}newMarker(){return new us(this)}onMarkerTypeChange(){const t=this._parent;t.uploaded=void 0,t.toDirty()}onMarkerSizeChange(){this._parent.updateUploaded()}onMarkerFillChange(){this._parent.updateUploaded()}get formatter(){return this._formatter||null}set formatter(t){this._formatter!==t&&(this._formattedId=-1,this._formatter=t,this.toDirty(!0))}get formatted(){var t,e;this.fit();const i=this._id;let s=this._formatted;if(this._formattedId!==i){this._formattedId=i;const n=this._style,o=null!==(t=this._formatter)&&void 0!==t?t:null===(e=Ss.find(n))||void 0===e?void 0:e.formatter;if(null!=o){null==s&&(s={length:0,plength:0,values:[],segments:[],boundary:[0,0,0,0],style:F.NONE});const t=this._values,e=this._segments;o(t.length>>1,t,e,n,s),s.plength<s.length&&(s.plength=s.length),as(s.values,s.boundary)}else s=void 0;this._formatted=s}return s||this}toScaled(t,e,i,s){const n=this._parentSizeFitted,o=this._parentSizeBase,r=1e-5,a=r<Math.abs(o.x),h=r<Math.abs(o.y);if(a||h){const r=a?n.x/o.x:1,l=h?n.y/o.y:1;for(let i=0,s=e.length;i<s;i+=2)t[i]=e[i]*r,t[i+1]=e[i+1]*l;for(let t=0,e=s.length;t<e;t+=2)i[t]=s[t]*r,i[t+1]=s[t+1]*l}}copy(t){this.set(t.values,t.segments,t.style);const e=t.getMarker();return e&&this.marker.copy(e),this}set(t,e,i){let s=!1,n=!1;const o=this._style,r=o&F.FORMATTER_MASK,a=this._formatter;if(null!=t){const e=this._values,i=this._valuesBaseLength,o=t.length,h=Math.min(o,i),l=this._parent.size;if(this.toFitted(l.x,l.y),e!==t){for(let i=0;i<h;++i)e[i]=t[i];for(let i=h;i<o;++i)e.push(t[i]);i!==o?(e.length=o,this._valuesBaseLength=o,s=!0):null!=a||r?s=!0:n=!0}else i!==o?(this._valuesBaseLength=o,s=!0):null!=a||r?s=!0:n=!0;const c=o>>1;this._length=c,this._plength<c&&(this._plength=c)}if(null!=e){const t=this._segments;if(t!==e){const i=e.length,s=Math.min(t.length,i);for(let i=0;i<s;++i)t[i]=e[i];for(let n=s;n<i;++n)t.push(e[n]);t.length!==i&&(t.length=i)}null!=a||r?s=!0:n=!0}return null!=i&&o!==i&&(r!==(i&F.FORMATTER_MASK)||(null!=a||r)&&(o&F.CLOSED)!=(i&F.CLOSED)?s=!0:n=!0,this._style=i),(n||s)&&this.toDirty(s),this}toDirty(t){if(t){this._id+=1;const t=this._parent,e=t.uploaded;e?e.isCompatible(t)?t.updateUploaded():t.toDirty():t.updateUploaded()}else this._id+=1,this._parent.updateUploaded()}clone(t){return new bs(t).copy(this)}toPoints(e){const i=[],s=this.values;for(let n=0,o=s.length;n<o;n+=2){const o=new t.Point(s[n+0],s[n+1]);i.push(e.apply(o,o))}return i}serialize(t){const e=JSON.stringify(this._values),i=JSON.stringify(this._segments),s=this._style;let n=-1;const o=this._marker;return o&&(n=o.serialize(t)),t.addResource(`[${e},${i},${s},${n}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getExtension(t);null==s&&(s=JSON.parse(i[t]),e.setExtension(t,s)),this.set(s[0],s[1],s[2]);const n=s[3];null!=n&&0<=n&&this.marker.deserialize(n,e)}}calcHitPointAbs(t,e,i,s,n,o,r,a){const h=this.formatted,l=h.length;if(2<=l){const i=h.values,s=h.segments,c=h.style;let u=0,d=l;if(o){const s=bs.WORK_RANGE;o(t,e,n,i,s),u=s[0],d=s[1]}for(let o=u,h=Math.min(d,l-1);o<h;++o)if(rs(s,o+1)<0){const s=o<<1;if(r(t,e,i[s+0],i[s+1],i[s+2],i[s+3],o,n,a))return!0}if(2<l&&l<=d&&c&F.CLOSED&&rs(s,0)<0){const s=l-1,o=s<<1;if(r(t,e,i[o+0],i[o+1],i[0],i[1],s,n,a))return!0}}return!1}}bs.WORK_RANGE=[0,0];class Is{constructor(t,e){this._parent=t,this._id=0,this._values=[],this._lockCount=0,this._isChanged=!1,this._onChange=e}lock(){this._lockCount+=1,1===this._lockCount&&(this._isChanged=!1)}unlock(){this._lockCount-=1,0===this._lockCount&&(this._isChanged&&this.onChange(),this._isChanged=!1)}get id(){return this._id}get values(){return this._values}set values(t){this.set(t)}set(t){if(null!=t){if(this._id+=1,this._values!==t){const e=t.length,i=this._values;for(let s=0;s<e;++s)i[s]=t[s];i.length=e}this.onChange()}return this}copy(t){return this.set(t.values)}serialize(t){return t.addResource(JSON.stringify(this._values))}deserialize(t,e,i){const s=i.resources;if(0<=t&&t<s.length){let e=i.getExtension(t);null==e&&(e=JSON.parse(s[t]),i.setExtension(t,e)),this.set(e)}}onChange(){0<this._lockCount?this._isChanged=!0:this._onChange()}}class Os extends re{constructor(t=s.CONNECTOR_LINE){super(t),this._tailLocalId=0,this._tailNormalId=0,this._tailMargin=0,this._headLocalId=0,this._headNormalId=0,this._headMargin=0,this._bodyId=0,this._lockConnector=new Rt;const e=.5*q.SIZE_X,i=.5*q.SIZE_Y;this._points=new bs(this).set([-e,-i,+e,+i]);const n=()=>{this.onChange()};this._edge=new os(this,n),this._body=new Is(this,n)}lock(t){return t&Mt.CONNECTOR&&this._lockConnector.lock(),super.lock(t),this}unlock(t,e){return super.unlock(t,e),t&Mt.CONNECTOR&&this._lockConnector.unlock()&&e&&this.onChange(),this}get points(){return this._points}get edge(){return this._edge}get body(){return this._body}onAttach(){super.onAttach(),this._edge.attach()}onDetach(t){this._edge.detach(t),super.onDetach(t)}onChange(){var t;if(this._lockConnector.isLocked())return;const e=this._edge,i=e.tail,s=i.localId,n=i.normalId,o=i.margin,r=e.head,a=r.localId,h=r.normalId,l=r.margin,c=this._body,u=c.id;if(this._tailLocalId!==s||this._tailNormalId!==n||this._tailMargin!==o||this._headLocalId!==a||this._headNormalId!==h||this._headMargin!==l||this._bodyId!==u){this._tailLocalId=s,this._tailNormalId=n,this._tailMargin=o,this._headLocalId=a,this._headNormalId=h,this._headMargin=l,this._bodyId;const e=this.transform,u=e.position,d=u.x,p=u.y,_=this._points,g=_.values;this.fillPoints(i,o,r,l,c,d,p,g);const f=null!==(t=Os.WORK_BOUNDARY)&&void 0!==t?t:Os.WORK_BOUNDARY=[0,0,0,0];as(g,f);const m=.5*(f[2]+f[0]),v=.5*(f[3]+f[1]),T=f[2]-f[0],w=f[3]-f[1];for(let t=0,e=g.length;t<e;t+=2)g[t+0]-=m,g[t+1]-=v;this.lock(Mt.TRANSFORM_AND_UPLOADED),u.set(d+m,p+v),e.scale.set(1,1),e.rotation=0,e.skew.set(0,0),_.toFitted(T,w),this.size.set(T,w),_.set(g),this.unlock(Mt.TRANSFORM_AND_UPLOADED,!0)}}fillPoints(t,e,i,s,n,o,r,a){const h=1e-6,l=t.local,c=l.x-o,u=l.y-r,d=i.local,p=d.x-o,_=d.y-r,g=n.values,f=g.length;if(a[0]=c,a[1]=u,0<f){const t=.5*(p+c),e=.5*(_+u),i=p-c,s=_-u,n=Math.atan2(s,i),o=Math.cos(n),r=Math.sin(n),h=Math.sqrt(i*i+s*s);for(let i=0;i<f;i+=2){const s=g[i+0],n=g[i+1];a[i+2]=t+(o*s-r*n)*h,a[i+3]=e+(o*n+r*s)*h}}if(a[2+f]=p,a[3+f]=_,0!==e){const t=a[2]-c,i=a[3]-u;if(h<t*t+i*i){const s=e/Math.sqrt(t*t+i*i);a[0]=c+t*s,a[1]=u+i*s}}if(0!==s){const t=a[0+f]-p,e=a[1+f]-_;if(h<t*t+e*e){const i=s/Math.sqrt(t*t+e*e);a[2+f]=p+t*i,a[3+f]=_+e*i}}a.length=f+4}copy(t,e=ht.ALL){return this.lock(Mt.ALL),super.copy(t,e),t instanceof Os&&(this._edge.copy(t.edge),this._body.copy(t.body)),this.unlock(Mt.ALL,!0),this}clone(){return new(0,this.constructor)(this.type).copy(this)}serialize(t){const e=super.serialize(t),i=this._edge.serialize(t),s=this._body.serialize(t),n=this._points.serialize(t);return e[15]=t.addResource(`[${i},${n},${s}]`),e}}class As{static isConnector(t){return t instanceof Os}static newMapping(t,e,i){var s;null==i&&(i=null!==(s=As._MAPPING)&&void 0!==s?s:As._MAPPING=new Map).clear();for(let s=0,n=t.length;s<n;++s){const n=t[s],o=e[s];i.set(n,o),this.newMapping(n.children,o.children,i)}return i}static moveAll(t,e,i,s,n){for(let o=0,r=i.length;o<r;++o){const r=i[o],a=s[o];if(this.isConnector(r)&&this.isConnector(a)){const i=r.edge,s=a.edge,o=i.head,h=o.acceptor.shape;if(h){null==n&&(n=this.newMapping(t,e));const i=n.get(h);if(i){const t=s.head;t.detach(),t.set(i),t.attach(),i.connector.remove(o)}}const l=i.tail,c=l.acceptor.shape;if(c){null==n&&(n=this.newMapping(t,e));const i=n.get(c);if(i){const t=s.tail;t.detach(),t.set(i),t.attach(),i.connector.remove(l)}}}n=this.moveAll(t,e,r.children,a.children,n)}return n}static move(t,e){const i=t.children,s=e.children;this.moveAll(i,s,i,s)}}class Rs{constructor(e,i,s,n,o){this.id=e,this.ref=0;const r=o.resolution;this.frame=new t.Rectangle(0,0,i*r,s*r),this.texture=new t.Texture(o,new t.Rectangle(0,0,1,1)),this.width=i,this.height=s,this.strokeWidth=n}applyFrame(){const t=1/this.texture.baseTexture.resolution;this.texture.frame.x=this.frame.x*t,this.texture.frame.y=this.frame.y*t,this.texture.frame.width=this.width,this.texture.frame.height=this.height,this.texture.updateUvs(),this.texture.emit("update",this)}destroy(){this.texture.destroy()}}class Ms extends Rs{render(t){}}class ks extends Rs{render(t){const e=this.frame;t.save(),t.fillStyle="#ffffff",t.fillRect(e.x-1,e.y-1,e.width+2,e.height+2),t.restore()}}class Ls{constructor(e){const i=this._canvas=document.createElement("canvas");i.width=i.height=256;const s=t.BaseTexture.from(i,{mipmap:t.MIPMAP_MODES.OFF,resolution:e});this._baseTexture=s,this._idToDatum={},this._sortedData=[],this._predefined={empty:new Ms("empty",10,10,0,s),white:new ks("white",10,10,0,s)},this._isDirty=!0}updateFrames(t,e){let i=4,s=4,n=0;for(let o=0,r=e.length;o<r;++o){const r=e[o];t<i+r.frame.width+4&&(i=4,s+=n+4,n=0),r.frame.x=0|i,r.frame.y=0|s,i+=r.frame.width+4,n=Math.max(n,r.frame.height)}const o=s+n+4;let r=256;for(;r<o;)r<<=1;return Math.min(4096,r)}renderFrames(t,e,i){const s=this._canvas;s.width=t,s.height=e;const n=s.getContext("2d");if(null!=n)for(let t=0,e=i.length;t<e;++t)i[t].render(n)}applyFrames(t){for(let e=0,i=t.length;e<i;++e)t[e].applyFrame()}calcCanvasWidth(t){let e=512;for(let i=t.length-1;0<=i;--i){const s=t[i],n=Math.max(s.frame.width,s.frame.height);for(;e<n;)e<<=1}return Math.min(4096,e<<1)}cleanup(t){t.sort(Ls.ITEM_COMPARATOR);for(let e=t.length-1;0<=e;--e)if(0<t[e].ref)return void(t.length=e+1);t.length=0}begin(){const t=this._sortedData;for(let e=0,i=t.length;e<i;++e)t[e].ref=0;this._isDirty=!1}end(){const t=this._idToDatum,e=this._sortedData;for(let i=0,s=e.length;i<s;++i){const s=e[i];s.ref<=0&&(s.id in this._predefined||s.destroy(),delete t[s.id],this._isDirty=!0)}}repack(t){if(!0===t||this._isDirty){this._isDirty=!1;const t=this._sortedData;this.cleanup(t);const e=this.calcCanvasWidth(t),i=this.updateFrames(e,t);this.renderFrames(e,i,t),this._baseTexture.setRealSize(e,i),this.applyFrames(t)}}get(t){const e=this._idToDatum[t];if(null!=e)return e.ref+=1,e;{const e=this._predefined[t];if(null!=e)return this.set(t,e),e}return null}contains(t){return t in this._idToDatum}set(t,e){const i=this._idToDatum[t];return e.ref+=1,this._idToDatum[t]=e,this._sortedData.push(e),this._isDirty=!0,i}toDirty(){this._isDirty=!0}getDefaultTexture(){return this.get("white").texture}getBaseTexture(){return this._baseTexture}release(t){const e=this._idToDatum,i=e[t];null!=i&&(i.ref-=1,i.ref<=0&&(i.id in this._predefined||i.destroy(),delete e[t],this._isDirty=!0))}destroy(){const t=this._baseTexture;null!=t&&t.destroy()}}Ls.ITEM_COMPARATOR=(t,e)=>t.ref<=0?e.ref<=0?0:1:e.ref<=0||t.frame.height<e.frame.height?-1:e.frame.height<t.frame.height?1:t.frame.width-e.frame.width;class Ns extends Rs{constructor(t,e){super(t.id,t.width/e.resolution,t.height/e.resolution,0,e),this.canvas=t.canvas}render(t){const e=this.canvas;if(null!=e){const i=this.frame;t.drawImage(e,i.x,i.y,i.width,i.height)}}}class Ps{constructor(t,e){this.x=t,this.y=e}}class Bs{constructor(t,e,i,s,n,o,r){this.ref=1,this.life=Bs.LIFE,this.character=e,this.x=i,this.y=s,this.width=n,this.height=o,this.advance=r,this.origin=new Ps(0,0),this.type=t}}Bs.LIFE=10;const zs={RESERVED:1,NON_BREAKING:2,SPACE:4,SPACE_R:5,SPACE_NB:6,SPACE_RNB:7,LETTER:8,LETTER_R:9,LETTER_NB:10,LETTER_RNB:11};class Us{constructor(t){this.id=Us.toFontFamily(t),this.size=32,this.italic=!1,this.measured=!1,this.ascent=0,this.descent=0}static toFontFamily(t){return"auto"===t?Us.getAutoFontFamily():t}static getAutoFontFamily(){return null==Us.FONT_FAMILY_AUTO&&(Us.FONT_FAMILY_AUTO=$.getInstance().get("DBase").getFontFamilly()),Us.FONT_FAMILY_AUTO}}Us.FONT_FAMILY_AUTO=null;class Fs{constructor(){this._gl=null,this._texture=null,this._shaderProgram=null,this._vertexPositionAttribute=0,this._textureCoordAttribute=1,this._samplerUniform=null,this._sizeUniform=null,this._vb=null,this._uvb=null;const t=this._canvas=document.createElement("canvas");t.width=64,t.height=64,this._onLostBound=t=>{t.preventDefault()},this._onRestoreBound=()=>{this.restore()},this._onUnloadBound=()=>{this.destroy()},t.addEventListener("webglcontextlost",this._onLostBound,!1),t.addEventListener("webglcontextrestored",this._onRestoreBound,!1),window.addEventListener("unload",this._onUnloadBound,!1)}init(){const t=this._canvas;if(null!=t&&(null==this._gl||this._gl.isContextLost())){const e={alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1},i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);this._gl=i,null!=i&&(i.clearColor(1,1,1,0),this.makeVertexBuffer(),this.makeUvBuffer(),this.makeShaders(),this._texture=null)}return this}restore(){this.init()}getCanvas(){return this._canvas}getShader(t,e,i){const s=i?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);return null==s||(t.shaderSource(s,e),t.compileShader(s),t.getShaderParameter(s,t.COMPILE_STATUS))?s:(console&&console.error("Failed to compile the shader: "+t.getShaderInfoLog(s)),null)}makeShaders(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this.getShader(t,"\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nvarying mediump vec2 vTextureCoord;\nvoid main(void) {\n\tgl_Position = vec4(aVertexPosition, 0.0, 1.0);\n\tvTextureCoord = aTextureCoord;\n}\n",!1);if(null!=e){const i=this.getShader(t,"\nprecision mediump float;\n\nvarying mediump vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec2 uSize;\n\nfloat norm(vec2 v) {\n\treturn dot(v, v);\n}\n\nfloat norm(vec2 p, vec2 dp) {\n\tvec2 xy = p + dp;\n\tvec2 uvi = vec2(1.0) / uSize;\n\tvec2 uv = xy * uvi;\n\tvec4 t0 = vec4(texture2D(uSampler, uv).a);\n\tvec4 t1 = vec4(\n\t\ttexture2D(uSampler, uv + vec2(-uvi.x, 0.0 )).a,\n\t\ttexture2D(uSampler, uv + vec2(0.0 , -uvi.y)).a,\n\t\ttexture2D(uSampler, uv + vec2(+uvi.x, 0.0 )).a,\n\t\ttexture2D(uSampler, uv + vec2(0.0 , +uvi.y)).a\n\t);\n\tvec4 t2 = vec4(0.5);\n\tvec4 t3 = min(t1,t0);\n\tvec4 t4 = max(t1,t0);\n\n\tvec4 w0 = (t2 - t0) / (t1 - t0);\n\tvec4 s0 = vec4(\n\t\tt3.x < 0.5 && 0.5 <= t4.x,\n\t\tt3.y < 0.5 && 0.5 <= t4.y,\n\t\tt3.z < 0.5 && 0.5 <= t4.z,\n\t\tt3.w < 0.5 && 0.5 <= t4.w\n\t);\n\tvec4 l0 = vec4(\n\t\tnorm(dp + vec2(-w0.x, 0.0 )),\n\t\tnorm(dp + vec2(0.0 , -w0.y)),\n\t\tnorm(dp + vec2(+w0.z, 0.0 )),\n\t\tnorm(dp + vec2(0.0 , +w0.w))\n\t);\n\tvec4 c0 = vec4(100.0);\n\tvec4 r0 = mix(c0, l0, s0);\n\n\tvec4 w1 = w0 * vec4(0.5);\n\tvec4 s1 = vec4(\n\t\t0.5 < s0.x && 0.5 < s0.y,\n\t\t0.5 < s0.y && 0.5 < s0.z,\n\t\t0.5 < s0.z && 0.5 < s0.w,\n\t\t0.5 < s0.w && 0.5 < s0.x\n\t);\n\tvec4 l1 = vec4(\n\t\tnorm(dp + vec2(-w1.x, -w1.y)),\n\t\tnorm(dp + vec2(+w1.z, -w1.y)),\n\t\tnorm(dp + vec2(+w1.z, +w1.w)),\n\t\tnorm(dp + vec2(-w1.x, +w1.w))\n\t);\n\tvec4 r1 = mix(c0, l1, s1);\n\tvec4 r2 = min(r0, r1);\n\tvec2 r3 = min(r2.xy, r2.zw);\n\treturn min(r3.x, r3.y);\n}\n\nfloat normY(vec2 p, float dx) {\n\tfloat result = 100.0;\n\tfor (float dy=-6.0; dy < 6.5; dy += 1.0) {\n\t\tresult = min(result, norm(p, vec2(dx, dy)));\n\t}\n\treturn result;\n}\n\nfloat normX(vec2 p) {\n\tfloat result = 100.0;\n\tfor (float dx=-6.0; dx < 6.5; dx += 1.0) {\n\t\tresult = min(result, normY(p, dx));\n\t}\n\treturn result;\n}\n\nvoid main(void) {\n\tfloat t = texture2D(uSampler, vTextureCoord).a;\n\tfloat d = min( 6.0, sqrt(normX( vTextureCoord * uSize )) ) / 12.0;\n\td = clamp( mix( 0.5 - d, 0.5 + d, step( 0.5, t ) ), 0.0, 1.0 ) * 255.0;\n\tfloat r = floor(d);\n\td = (d - r) * 255.0;\n\tfloat g = floor(d);\n\tgl_FragColor = vec4(r * 0.00392156862745098, g * 0.00392156862745098, d - g, 1.0);\n}\n",!0);if(null!=i){const s=this._shaderProgram=t.createProgram();if(null!=s)return t.attachShader(s,e),t.attachShader(s,i),t.bindAttribLocation(s,0,"aVertexPosition"),t.bindAttribLocation(s,1,"aTextureCoord"),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)?(t.deleteShader(e),t.deleteShader(i),t.useProgram(s),this._samplerUniform=t.getUniformLocation(s,"uSampler"),this._sizeUniform=t.getUniformLocation(s,"uSize"),t.useProgram(null),s):(console&&console.error("Failed to link the program: "+t.getError()),t.deleteShader(e),t.deleteShader(i),null);t.deleteShader(e),t.deleteShader(i)}else t.deleteShader(e)}}return null}destroyShaders(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this._shaderProgram;null!=e&&(this._shaderProgram=null,t.useProgram(null),t.deleteProgram(e))}}updateTexture(t,e,i){const s=this._gl,n=this._canvas;if(null!=s&&!0!==s.isContextLost()&&null!=n){n.width===t&&n.height===e||(n.width=t,n.height=e,s.viewport(0,0,t,e));let o=this._texture;return null==o?(o=this._texture=s.createTexture(),s.bindTexture(s.TEXTURE_2D,o),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,i),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.bindTexture(s.TEXTURE_2D,null)):(s.bindTexture(s.TEXTURE_2D,o),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,i),s.bindTexture(s.TEXTURE_2D,null)),o}return null}destroyTexture(){const t=this._gl,e=this._texture;null!=t&&!0!==t.isContextLost()&&null!=e&&(this._texture=null,t.bindTexture(t.TEXTURE_2D,null),t.deleteTexture(e))}makeVertexBuffer(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this._vb=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e);const i=[-1,1,1,1,-1,-1,1,-1];return t.bufferData(t.ARRAY_BUFFER,new Float32Array(i),t.STATIC_DRAW),e}return null}destroyVertexBuffer(){const t=this._gl,e=this._vb;null!=t&&!0!==t.isContextLost()&&null!=e&&(this._vb=null,t.bindBuffer(t.ARRAY_BUFFER,null),t.deleteBuffer(e))}makeUvBuffer(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this._uvb=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e);const i=[0,0,1,0,0,1,1,1];return t.bufferData(t.ARRAY_BUFFER,new Float32Array(i),t.STATIC_DRAW),e}return null}destroyUvBuffer(){const t=this._gl,e=this._uvb;null!=t&&!0!==t.isContextLost()&&null!=e&&(this._uvb=null,t.bindBuffer(t.ARRAY_BUFFER,null),t.deleteBuffer(e))}render(){const t=this._gl,e=this._canvas,i=this._shaderProgram,s=this._vb,n=this._uvb,o=this._texture;if(null!=t&&!0!==t.isContextLost()&&null!=e&&null!=i&&null!=s&&null!=n&&null!=o){t.clear(t.COLOR_BUFFER_BIT),t.useProgram(i),t.bindBuffer(t.ARRAY_BUFFER,s);const r=this._vertexPositionAttribute;t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,n);const a=this._textureCoordAttribute;t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o),t.uniform1i(this._samplerUniform,0),t.uniform2f(this._sizeUniform,e.width,e.height),t.drawArrays(t.TRIANGLE_STRIP,0,4),t.bindTexture(t.TEXTURE_2D,null),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null)}}read(t){const e=this._gl,i=this._canvas;if(null!=e&&!0!==e.isContextLost()&&null!=i){const e=i.width,s=i.height;t.width=e,t.height=s;const n=t.getContext("2d");null!=n&&n.drawImage(i,0,0)}}destroy(){this.destroyVertexBuffer(),this.destroyUvBuffer(),this.destroyShaders();const t=this._canvas;null!=t&&(this._canvas=null,t.removeEventListener("webglcontextlost",this._onLostBound,!1),t.removeEventListener("webglcontextrestored",this._onRestoreBound,!1),window.removeEventListener("unload",this._onUnloadBound,!1));const e=this._gl;if(null!=e){this._gl=null;const t=e.getExtension("WEBGL_lose_context");null!=t&&t.loseContext()}}static getInstance(){return null==Fs._INSTANCE&&(Fs._INSTANCE=new Fs),Fs._INSTANCE}}Fs._INSTANCE=null;class Hs{static measure(e,i){if(!i.measured){if("fontBoundingBoxAscent"in window.TextMetrics.prototype){const s=e.measureText(t.TextMetrics.METRICS_STRING);i.ascent=s.fontBoundingBoxAscent,i.descent=s.fontBoundingBoxDescent}else{const e=t.TextMetrics.measureFont(i.id);i.ascent=e.ascent,i.descent=e.descent}i.measured=!0}}static toSize(t){return this.setup(t),parseFloat(window.getComputedStyle(this._span).fontSize)}static setup(t){let e=this._span;null==e&&(e=document.createElement("span"),e.innerText="|ÉqÅ",e.style.border="none",e.style.margin="0px",this._span=e);let i=this._block;null==i&&(i=document.createElement("div"),i.style.display="inline-block",i.style.width="0px",i.style.height="0px",i.style.border="none",i.style.margin="0px",i.style.verticalAlign="baseline",this._block=i);let s=this._div;null==s&&(s=document.createElement("div"),s.style.position="absolute",s.style.padding="0px",s.style.margin="0px",s.style.visibility="hidden",s.appendChild(e),s.appendChild(i),document.body.appendChild(s),this._div=s),e.style.font=t}}class Gs{constructor(t){this._id="font-atlas:"+t,this._generator=Fs.getInstance().init(),this._canvas=document.createElement("canvas"),this._font=new Us(t),this._width=1,this._height=1;const e=new Map;e.set(D.SPACE,this.newChar(D.SPACE,zs.SPACE_R)),e.set(D.TAB,this.newChar(D.SOFT_TAB,zs.SPACE_R)),e.set(D.DOTS,this.newChar(D.DOTS,zs.LETTER_RNB));for(let t=0,i=D.ASCII.length;t<i;++t){const i=D.ASCII[t];e.set(i,this.newChar(i,zs.LETTER_RNB))}this._characters=e,this._isDirty=!0,this._isTouched=!1,this._life=Bs.LIFE}get id(){return this._id}get font(){return this._font}set font(t){this._font.id=t.id,this._font.size=t.size,this._font.italic=t.italic}get width(){return this._width}get height(){return this._height}get canvas(){return this._canvas}get generator(){return this._generator}get characters(){return this._characters}begin(){this._isTouched=!1,this._characters.forEach(t=>{t.type&zs.RESERVED||(t.ref=0)})}end(){const t=this._characters;this._isTouched?(this._life=Bs.LIFE,t.forEach((e,i)=>{e.ref<=0&&!(e.type&zs.RESERVED)&&(e.life-=1,e.life<=0&&(t.delete(i),this._isDirty=!0))})):(this._life-=1,this._life<=0&&0<t.size&&(t.clear(),this._isDirty=!0))}newChar(t,e){return new Bs(e,t,0,0,1,1,0)}add(t,e){const i=this._characters;for(let t=0,s=e.length;t<s;++t){const s=e[t],n=i.get(s);null!=n?(n.ref+=1,n.life=Bs.LIFE):(i.set(s,this.newChar(s,zs.LETTER)),this._isDirty=!0)}0<t.length&&(this._isTouched=!0)}get(t){return this._characters.get(t)}update(){if(this._isDirty){const t=this._canvas,e=this._generator;if(null!=t&&null!=e){const i=t.getContext("2d");if(null!=i){this._isDirty=!1;const s=this._font,n=s.size+14,o=this._characters,r=this.toPowerOf2(Math.ceil(Math.sqrt(o.size))*n);this._width=r;const a=(s.italic?"italic ":"")+s.size+"px "+s.id;i.font=a,i.textAlign="left",i.textBaseline="alphabetic",i.lineWidth=0,i.lineCap="round",i.lineJoin="miter",i.miterLimit=10,i.fillStyle="#FFFFFF",Hs.measure(i,s);const h=7,l=Math.round(.5*(n-(s.ascent+s.descent))+s.ascent);let c=0,u=0;o.forEach(t=>{const e=i.measureText(t.character).width,s=Math.ceil(h+e+h),o=n;r<=c+s&&(c=0,u+=n),t.x=c,t.y=u,t.width=s,t.height=o,t.advance=e,t.origin.x=c+h,t.origin.y=u+l,c+=s});const d=this._height=u+n;return t.width=r,t.height=d,i.font=a,i.textAlign="left",i.textBaseline="alphabetic",i.lineWidth=0,i.lineCap="round",i.lineJoin="miter",i.miterLimit=10,i.fillStyle="#FFFFFF",i.clearRect(0,0,r,d),o.forEach(t=>{i.fillText(t.character,t.origin.x,t.origin.y)}),e.updateTexture(r,d,t),e.render(),e.read(t),!0}}}return!1}get length(){return this._characters.size}toJson(){return{width:this._width,height:this._height,font:this._font,characters:this._characters}}toString(){return JSON.stringify(this.toJson())}destroy(){null!=this._generator&&(this._generator=null),null!=this._canvas&&(this._canvas=null),this._characters.clear()}toPowerOf2(t){let e=32;for(;e<t;)e<<=1;return e}}class Vs{constructor(){this._atlases=new Map}begin(){this._atlases.forEach(t=>{t.begin()})}end(){const t=this._atlases;t.forEach((e,i)=>{e.end(),e.length<=0&&(e.destroy(),t.delete(i))})}add(t,e,i){const s=this._atlases,n=s.get(t);if(null!=n)n.add(e,i);else{const n=new Gs(t);n.add(e,i),s.set(t,n)}}get(t){const e=this._atlases.get(t);return null!=e?e:null}update(t){const e=t.getBaseTexture();this._atlases.forEach(i=>{const s=i.id;if(i.update()){const n=t.get(s);if(null!=n){const s=i.width,o=i.height,r=e.resolution;n.frame.width=s,n.frame.height=o,n.width=s/r,n.height=o/r,t.toDirty()}else t.set(s,new Ns(i,e))}else t.contains(s)||t.set(s,new Ns(i,e))})}destroy(){const t=this._atlases;t.forEach(t=>{t.destroy()}),t.clear()}}class Ws extends Rs{constructor(t,e,i,s,n){super(t,e/n.resolution,i/n.resolution,0,n),this.source=s}render(t){const e=this.frame,i=e.x,s=e.y,n=e.width,o=e.height,r=this.source;r instanceof ImageData?(t.putImageData(r,i,s),t.putImageData(r,i-1,s,0,0,1,o),t.putImageData(r,i,s-1,0,0,n,1),t.putImageData(r,i+n,s,n-1,0,1,o),t.putImageData(r,i,s+o,0,o-1,n,1)):(t.drawImage(r,i,s,n,o),t.drawImage(r,0,0,1,o,i-1,s-1,1,o+2),t.drawImage(r,0,0,n,1,i,s-1,n,1),t.drawImage(r,n-1,0,1,o,i+n,s-1,1,o+2),t.drawImage(r,0,o-1,n,1,i,s+o,n,1))}}class Ks{constructor(t,e){this.texture=t,this.indexOffset=e}}class Xs{constructor(){this.index=0,this.baseTexture=null,this.units=[]}begin(){this.index=0,this.baseTexture=null}push(t,e){if(this.index<this.units.length){const i=this.units[this.index];i.texture=t,i.indexOffset=e}else this.units.push(new Ks(t,e));this.index+=1}end(){this.units.length!==this.index&&(this.units.length=this.index)}destroy(){this.units.length=0}}class Ys{constructor(t,e){const i=3*t,s=i;this.vertices=new Float32Array(2*s),this._vertexCapacity=s,this._vertexCount=0,this._vertexBuffer=null,this.steps=new Float32Array(6*s),this._stepBuffer=null,this.colors=new Float32Array(3*s),this._colorBuffer=null,this.uvs=new Float32Array(2*s),this._uvBuffer=null;const n=s<=65535;this.indices=n?new Uint16Array(i):new Uint32Array(i),this._indexCapacity=t,this._indexCount=0,this.indexCountRequested=0,this._indexBuffer=null,this._renderer=e,this._builder=new Xs,this._geometry=null}updateVertices(){const t=this._vertexBuffer;t&&t.update()}updateSteps(){const t=this._stepBuffer;t&&t.update()}updateColors(){const t=this._colorBuffer;t&&t.update()}updateUvs(){const t=this._uvBuffer;t&&t.update()}updateIndices(){const t=this._indexBuffer;t&&t.update()}getGeometry(){let e=this._geometry;return null==e&&(this._vertexBuffer=new t.Buffer(this.vertices,!1,!1),this._stepBuffer=new t.Buffer(this.steps,!1,!1),this._colorBuffer=new t.Buffer(this.colors,!1,!1),this._uvBuffer=new t.Buffer(this.uvs,!1,!1),this._indexBuffer=new t.Buffer(this.indices,!1,!0),this._geometry=e=(new t.Geometry).addIndex(this._indexBuffer).addAttribute("aPosition",this._vertexBuffer,2).addAttribute("aStepA",this._stepBuffer,2).addAttribute("aStepB",this._stepBuffer,4).addAttribute("aColor",this._colorBuffer,3).addAttribute("aUv",this._uvBuffer,2)),e}upload(){this._renderer.geometry.bind(this.getGeometry())}render(e){const i=this._renderer;i.geometry.bind(this.getGeometry());const s=this._builder.units,n=s.length;if(0<n){const o=t.DRAW_MODES.TRIANGLES;let r=null,a=s[0],h=0,l=3*a.indexOffset,c=0,u=t.Texture.WHITE;for(let d=0,p=n-1;d<p;++d)r=a,a=s[d+1],h=l,l=3*a.indexOffset,c=l-h,u=r.texture||t.Texture.WHITE,0<c&&u.valid&&(e.uniforms.sampler=i.texture.bind(u),i.geometry.draw(o,c,h));c=3*this._indexCount-l,u=a.texture||t.Texture.WHITE,0<c&&u.valid&&(e.uniforms.sampler=i.texture.bind(u),i.geometry.draw(o,c,l))}}update(t,e,i){const o=this._builder;o.begin();let r=0,a=0,h=t.get();for(;null!=h;h=t.next()){let l=h.uploaded;if(null==l){const t=n[h.type]||n[s.GROUP];if(null==t)break;const i=t(this,h,r,a,e);if(null==i)break;l=i}else if(!l.reinit(this,h,r,a))break;if(l.buildUnit(o),r+=l.getVertexCount(),a+=l.getIndexCount(),i){t.next();break}}return o.end(),this._vertexCount=r,this._indexCount=a,0<o.units.length}check(t,e,i,s){return this.indexCountRequested=s,t+i<=this._vertexCapacity&&e+s<=this._indexCapacity}destroy(){const t=this._geometry;t&&t.destroy(),this._builder.destroy()}}const js=[];class $s{constructor(){this.index=0,this.shapes=js,this.current=null}}class qs{constructor(){this._index=-1,this._datum=new $s,this._data=[this._datum],this._current=null}reset(t,e){this._index=0;const i=this._data[0];return i.index=-1,i.shapes=e,i.current=null,this._datum=i,null!=t?(this._current=t,t):this.next()}get(){return this._current}next(){for(;;){const t=this._datum,e=t.index+=1,i=t.shapes,s=e<i.length?t.current=i[e]:t.current=null;if(null==s){const t=this._index-=1,e=this._data;if(0<=t){const i=e[t];return this._datum=i,this._current=i.current}return this._current=null}{const t=s.children;if(!(0<t.length))return this._current=s,s;{const e=this._index+=1,i=this._data;if(e<i.length){const s=i[e];s.index=-1,s.shapes=t,s.current=null,this._datum=s}else{const e=new $s;i.push(e),e.index=-1,e.shapes=t,e.current=null,this._datum=e}}}}}}class Zs extends t.ObjectRenderer{constructor(e){super(e),Zs.SHADER=Zs.SHADER||t.Shader.from("\nattribute highp vec2 aPosition;\nattribute highp vec2 aStepA;\nattribute highp vec4 aStepB;\nattribute highp vec3 aColor;\nattribute highp vec2 aUv;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mediump float shapeScale;\nuniform mediump float antialiasWeight;\n\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nvec2 toInverse(in vec2 v) {\n\treturn vec2(-v.y, v.x);\n}\n\nvec4 toGeneral(in float v) {\n\tvec4 c = vec4(1.0, 1.0/64.0, 1.0/64.0/64.0, 1.0/64.0/64.0/64.0) * v;\n\tc -= fract(c);\n\tc -= c.yzwx * vec4(64.0, 64.0, 64.0, 0.0);\n\treturn c;\n}\n\nfloat toStrokeWidthScale(in float scale) {\n\treturn (\n\t\tscale == 3.0 || scale == 7.0 ?\n\t\tshapeScale : (\n\t\t\tscale == 1.0 || scale == 5.0 ?\n\t\t\tmin(1.0, shapeScale) : (\n\t\t\t\tscale == 2.0 || scale == 6.0 ?\n\t\t\t\tmax(1.0, shapeScale) : 1.0\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec2 toUnpackedF2x1024(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(1023.0, 1023.0);\n\treturn c;\n}\n\nvec3 toUnpackedF3x256(in float v) {\n\tvec3 c = vec3(1.0, 1.0/256.0, 1.0/256.0/256.0) * v;\n\tc -= fract(c);\n\tc -= c.yzx * vec3(256.0, 256.0, 0.0);\n\tc /= 255.0;\n\treturn c;\n}\n\nvec2 toPosition012(in vec2 v) {\n\treturn (projectionMatrix * translationMatrix * vec3(v, 1.0)).xy;\n}\n\nvec4 toStepB01(in vec4 sb) {\n\treturn vec4(sb.xy, toUnpackedF2x1024(sb.z));\n}\n\nvec4 toStepB2(in vec4 sb, in float strokeWidth) {\n\tfloat x = min(0.4, 0.4 / 12.0 * sb.x * antialiasWeight);\n\tfloat w = clamp(strokeWidth, 0.0, 1.0) * 0.4;\n\tfloat p = w * sb.y + sb.z;\n\tfloat y = 0.5 - p;\n\tfloat z = 0.5 - p - w;\n\treturn vec4(y, z, y - max(0.01, y - x), z - max(0.01, z - x));\n}\n\nvec2 toPosition3(in float type, in vec2 p, in float npacked, in float length, in float strokeWidth, out float shift) {\n\tvec3 t = vec3(1.0, 1.0/1024.0, 1.0/1024.0/1024.0) * npacked;\n\tt -= fract(t);\n\tt -= t.yzx * vec3(1024.0, 1024.0, 0.0);\n\tt *= vec3(1.0/511.5, 1.0/511.5, 1.0);\n\tt -= vec3(1.0, 1.0, 0.0);\n\tvec2 n0 = vec2(t.x, ((0.5 < t.z && t.z < 1.5) || 2.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.x * t.x)));\n\tvec2 n1 = vec2(t.y, (1.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.y * t.y)));\n\n\tvec2 n0i = toInverse(n0);\n\tvec2 n1i = toInverse(n1);\n\tfloat direction = sign(4.5 - type);\n\n\t// Offset\n\tfloat cross = dot(n0i, n1);\n\tbool bcross = 0.00001 < abs(cross);\n\tfloat crossi = (bcross ? 1.0 / cross : 0.0);\n\tfloat b = dot(n1 - n0, n0) * crossi;\n\tfloat offsetSize = direction * strokeWidth * 0.5;\n\tvec2 offset = n1 + n1i * b;\n\n\t// Miter\n\tvec2 pmiter = p + offsetSize * offset;\n\tfloat miterAngle0 = dot( n0i, offsetSize * offset - length * n0i );\n\tfloat miterAngle1 = dot( n1i, offsetSize * offset + length * n1i );\n\tfloat miterLength = dot( offset, offset );\n\tfloat miterSide = direction * cross;\n\n\t// Bevel\n\tvec2 n = (type == 4.0 || type == 6.0 ? n1 : n0);\n\tvec2 pbevel = p + offsetSize * n;\n\n\t//\n\tvec2 presult = (\n\t\t0.0 <= miterSide ?\n\t\t(miterAngle0 < 0.0 && 0.0 <= miterAngle1 && bcross ? pmiter : pbevel) :\n\t\t(miterLength < 6.0 && bcross ? pmiter : pbevel)\n\t);\n\tvec2 ni = (type == 4.0 || type == 6.0 ? n1i : n0i);\n\tshift = dot(ni, p - presult);\n\treturn toPosition012(presult);\n}\n\nvec2 toStepA3(in float type, in float strokeWidth) {\n\treturn vec2(type < 4.5 ? 1.0 : 0.0, strokeWidth);\n}\n\nvec4 toStepB3(in float shift, in float dash, in float strokeScaling, in float strokeWidthScale) {\n\tfloat l = aStepB.y + shift;\n\tfloat s = aStepA.x * (\n\t\tstrokeScaling == 4.0 || strokeScaling == 5.0 ||\n\t\tstrokeScaling == 6.0 || strokeScaling == 7.0 ?\n\t\tstrokeWidthScale : 1.0\n\t);\n\tfloat lt = aStepB.z;\n\treturn (dash < 0.5 ?\n\t\tvec4(l, 2.0 * abs(lt), 0.0, lt) :\n\t\t(dash < 3.5 ?\n\t\t\t(dash < 1.5 ?\n\t\t\t\tvec4(l, s, s, lt) :\n\t\t\t\t(2.5 < dash ?\n\t\t\t\t\tvec4(l, s, 2.0 * s, lt) :\n\t\t\t\t\tvec4(l, s, 0.5 * s, lt)\n\t\t\t\t)\n\t\t\t) :\n\t\t\t(dash < 4.5 ?\n\t\t\t\tvec4(l, 2.0 * s, s, lt) :\n\t\t\t\t(5.5 < dash ?\n\t\t\t\t\tvec4(l, 2.0 * s, 2.0 * s, lt) :\n\t\t\t\t\tvec4(l, 2.0 * s, 0.5 * s, lt)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t);\n}\n\nvoid toColors(in vec3 source, out vec4 fillColor, out vec4 strokeColor) {\n\tvec2 a = toUnpackedF2x1024(source.z);\n\tfillColor.xyz = toUnpackedF3x256(source.x).zyx * a.x;\n\tfillColor.w = a.x;\n\tstrokeColor.xyz = toUnpackedF3x256(source.y).zyx * a.y;\n\tstrokeColor.w = a.y;\n}\n\nvoid main(void) {\n\tvec4 general = toGeneral(aStepA.y);\n\tfloat type = general.x;\n\tfloat strokeScaling = general.y;\n\tfloat strokeWidthScale = toStrokeWidthScale(strokeScaling);\n\tfloat strokeWidth = strokeWidthScale * aStepA.x;\n\n\t// Type 0, 1\n\tvec2 p012 = toPosition012(aPosition);\n\tvec2 sa012 = strokeWidth * general.zw;\n\tvec4 sb01 = toStepB01(aStepB);\n\n\t// Type 2\n\tvec4 sb2 = toStepB2(aStepB, strokeWidth);\n\n\t// Type 3 ~ 6\n\tfloat shift3 = 0.0;\n\tvec2 p3 = toPosition3(type, aPosition, aStepB.x, aStepB.w, strokeWidth, shift3);\n\tvec2 sa3 = toStepA3(type, strokeWidth);\n\tvec4 sb3 = toStepB3(shift3, general.z, strokeScaling, strokeWidthScale);\n\n\t//\n\tgl_Position = vec4((2.5 < type ? p3 : p012), 0.0, 1.0);\n\tvType = type;\n\tvStepA = (2.5 < type ? sa3 : sa012);\n\tvStepB = (1.5 < type ? (2.5 < type ? sb3 : sb2) : sb01);\n\ttoColors(aColor, vColorFill, vColorStroke);\n\tvUv = aUv;\n}","\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nuniform sampler2D sampler;\nuniform mediump float antialiasWeight;\n\nvec4 toColor0(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tvec2 p0 = clamp(one - awd, zero, one);\n\tvec2 p1 = clamp(one - swd, zero, one);\n\tvec2 p2 = clamp(one - swd - awd, zero, one);\n\tvec2 s0 = smoothstep(p0, one, c);\n\tvec2 s1 = smoothstep(p2, p1, c);\n\tfloat s2 = max(s0.x, s0.y);\n\tfloat s3 = max(s1.x, s1.y);\n\treturn texture * (\n\t\tvColorStroke * (s3 - s2) +\n\t\tvColorFill * (1.0 - s3)\n\t);\n}\n\nvec4 toColor1(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tfloat s0 = smoothstep(length(c), length(c/clamp(one - awd, zero, one)), 1.0);\n\tfloat s1 = smoothstep(length(c/clamp(one - swd, zero, one)), length(c/clamp(one - swd - awd, zero, one)), 1.0);\n\treturn texture * (\n\t\tvColorStroke * (s0 - s1) +\n\t\tvColorFill * s1\n\t);\n}\n\nvec4 toColor2(in vec4 texture) {\n\tvec2 p0 = vStepB.xy;\n\tvec2 p1 = vStepB.zw;\n\tvec2 d = vec2(dot(texture, vec4(1.0, 1.0/255.0, 1.0/255.0/255.0, 0.0)));\n\tvec2 s = smoothstep(p0 - p1, p0 + p1, d);\n\treturn vColorStroke * (s.y - s.x) + vColorFill * s.x;\n}\n\nvec4 toColor3(in vec4 texture) {\n\tfloat l = vStepB.x;\n\tfloat lp0 = vStepB.y;\n\tfloat lp1 = vStepB.z;\n\tfloat lt = vStepB.w;\n\tfloat ld = antialiasWeight;\n\tfloat lm = mod(l, lp0 + lp1);\n\tfloat ls0 = (0.0 < lp1 ? smoothstep(0.0, ld, lm) - smoothstep(lp0, lp0 + ld, lm) : 1.0);\n\tfloat ls1 = (0.0 <= lt ? smoothstep(0.0, ld, l) - smoothstep(lt - ld, lt, l) : 1.0);\n\n\tfloat c = vStepA.x;\n\tfloat awd = antialiasWeight / vStepA.y;\n\tfloat p0 = clamp(awd, 0.0, 1.0);\n\tfloat p1 = clamp(1.0 - awd, 0.0, 1.0);\n\tfloat s0 = smoothstep(0.0, p0, c);\n\tfloat s1 = smoothstep(p1, 1.0, c);\n\treturn texture * vColorStroke * (s0 - s1) * ls0 * ls1;\n}\n\nvoid main(void) {\n\tvec4 texture = texture2D(sampler, vUv);\n\tgl_FragColor = (vType < 1.5 ?\n\t\t(vType < 0.5 ?\n\t\t\ttoColor0(texture) :\n\t\t\ttoColor1(texture)\n\t\t) :\n\t\t(vType < 2.5 ?\n\t\t\ttoColor2(texture) :\n\t\t\ttoColor3(texture)\n\t\t)\n\t);\n}"),this._shader=Zs.SHADER,this._iterator=new qs,this._bufferSizeMax=this.getBufferSizeMax(e)}getBufferSizeMax(t){const e=t.context,i=e.extensions;return 1<e.webGLVersion||i.uint32ElementIndex?1431655765:21845}updateAtlas(t,e,i,s,n){const o=t.image;if(null!=o){const i=e.get(o.url);if(null!=i)t.texture=i.texture;else{const i=new Ws(o.url,o.width,o.height,o.source,n);t.texture=i.texture,e.set(i.id,i)}}else t.texture=s;const r=t.text,a=r.characters;0<a.length&&i.add(r.family,a,r.nacharacters)}updateAtlases(t,e,i,s,n){for(let o=0,r=t.length;o<r;++o){const r=t[o];this.updateAtlas(r,e,i,s,n);const a=r.children;for(let t=0,o=a.length;t<o;++t){const o=a[t];this.updateAtlas(o,e,i,s,n),this.updateAtlases(o.children,e,i,s,n)}}}updateFontAtlas(t,e,i,s){const n=t.text,o=i.get(n.family);if(null!=o){const t=e.get(o.id);null!=t?(n.atlas=o,n.texture=t.texture):(n.atlas=void 0,n.texture=s)}else n.atlas=void 0,n.texture=s}updateFontAtlases(t,e,i,s){for(let n=0,o=t.length;n<o;++n){const o=t[n];this.updateFontAtlas(o,e,i,s);const r=o.children;for(let t=0,n=r.length;t<n;++t){const n=r[t];this.updateFontAtlas(n,e,i,s),this.updateFontAtlases(n.children,e,i,s)}}}render_(e,i,s,n){const o=this.renderer,r=this._shader;if(null!=r&&(null!=i||0<s.length)){const a=o.resolution,h=e.getBuffers(),l=e.toAntialiasWeight(a);if(n){const t=e.getAtlas(a),n=e.getFontAtlases();t.begin(),n.begin();const r=t.getDefaultTexture(),c=t.getBaseTexture();this.updateAtlases(s,t,n,r,c),n.end(),n.update(t),this.updateFontAtlases(s,t,n,r),t.end(),t.repack(),this.updateBuffers(i,s,h,o,l)}r.uniforms.shapeScale=e.toShapeScale(),r.uniforms.antialiasWeight=e.toPixelScale(a)*l,r.uniforms.translationMatrix=e.worldTransform.toArray(!0),o.shader.bind(r,!1),o.state.setBlendMode(t.utils.correctBlendMode(t.BLEND_MODES.NORMAL,!0));const c=h.length;if(1<c)for(let t=0;t<c;++t)h[t].upload();for(let t=0;t<c;++t)h[t].render(r)}}updateBuffers(t,e,i,s,n){const o=this._iterator;o.reset(t,e);let r=0,a=0;const h=5e3,l=this._bufferSizeMax;for(;null!=o.get();){let t=null,e=!1;if(0<a?(t=new Ys(a,s),i.splice(r,0,t),e=!0):r<i.length?(t=i[r],e=!1):(t=new Ys(h,s),i.push(t),e=!1),t.update(o,n,e))a=0,r+=1;else{if(a=t.indexCountRequested,!(a<=l))break;a=Math.ceil(a/h)*h,a=Math.min(a,l)}}if(r<i.length){for(let t=r,e=i.length;t<e;++t)i[t].destroy();i.length=r}}}Zs.SHADER=null;class Js extends t.DisplayObject{constructor(){super(),this._shapeRenderer=null,this.children=[],this._shape=null,this._childrenId=0,this._childrenIdRendered=-1,this._atlas=null,this._fontAtlases=new Vs,this._pixelScale=1,this._pixelScaleId=-2,this._shapeScale=1,this._shapeScaleId=-1,this._work=new t.Point,this._buffers=[]}calculateBounds(){this._bounds.clear()}onChildTransformChange(){}toDirty(){return this._childrenId+=1}isDirty(){return this._childrenIdRendered<this._childrenId}render(t){if(!this.visible||this.worldAlpha<=0||!this.renderable)return;const e=this._childrenId,i=this._childrenIdRendered;this._childrenIdRendered=e;const s=i<e;let n=this._shapeRenderer;null==n&&(n=this._shapeRenderer=new Zs(t)),t.batch.setObjectRenderer(n);const o=this.mask,r=this._shape,a=this.children;o?(t.mask.push(this,o),n.render_(this,r,a,s),t.mask.pop(this)):n.render_(this,r,a,s)}containsPoint(t){return!1}getFontAtlases(){return this._fontAtlases}getAtlas(t){let e=this._atlas;return null==e&&(e=new Ls(t),this._atlas=e),e}getBuffers(){return this._buffers}toShapeScale(){this.updateTransform();const t=this.transform,e=t._worldID;if(e!==this._shapeScaleId){this._shapeScaleId=e;const i=t.worldTransform,s=i.a,n=i.b;this._shapeScale=1/Math.sqrt(s*s+n*n)}return this._shapeScale}getShapeScale(){return this._shapeScale}toPixelScale(t){const e=this.toShapeScale(),i=this._shapeScaleId;return this._pixelScaleId!==i&&(this._pixelScaleId=i,this._pixelScale=1/t*e),this._pixelScale}getPixelScale(){return this._pixelScale}toAntialiasWeight(t){return 1.25/t}hitTest(t,e){const i=this._work,s=this.children;for(let n=s.length-1;0<=n;--n){const o=s[n];if(o.visible){o.toLocal(t,void 0,i);const s=o.contains(i.x,i.y);if(null!=s&&(null==e||e(s)))return s}}return null}hitTestBBox(t,e){const i=this._work,s=this.children;for(let n=s.length-1;0<=n;--n){const o=s[n];if(o.visible&&(o.toLocal(t,void 0,i),o.containsBBox(i.x,i.y)&&(null==e||e(o))))return o}return null}destroy(){const t=this._buffers;if(null!=t)for(let e=0,i=t.length;e<i;++e)t[e].destroy();this._buffers.length=0;const e=this.children;for(let t=e.length-1;0<=t;--t)e[t].destroy();e.length=0;const i=this._atlas;null!=i&&i.destroy(),this._fontAtlases.destroy(),super.destroy()}}class Qs extends Xi{constructor(t,e,i,n=s.EMBEDDED_LAYER){super(e,i,n),this._name=t}get name(){return this._name}newGroupFill(){return new J(this,!1,16777215,1)}isGroupSizeFittable(){return!1}newGroupSize(t,e){const i=q.SIZE_X,s=q.SIZE_Y;return new Vi(this,i,s,i,s)}clone(){const t=this.newClone().copy(this),e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].clone();s.parent=t,t.children.push(s)}t.onChildTransformChange(),t.toDirty();const i=this.size;if(i instanceof Vi){const e=i.base;t.size.set(e.x,e.y).init().set(i.x,i.y)}else t.size.init();return t}newClone(){return new(0,this.constructor)(this._name,this._mode,this._depth,this.type)}serializeChildren(t){return[]}serializeImage(t){return-1}serializeGradient(t){return-1}}class tn{static toLayers(t,e){const i=[],s=this.toLayer(t);if(s){const t=s.parent;if(t){const s=t.children,n=s.length;for(let t=0,o=e.length;t<o;++t){const o=e[t];0<=o&&o<n&&i.push(s[o])}}}return i}static toLayer(t){let e=t.parent;for(;null!=e;){if(e instanceof Js)return e;if(e instanceof Qs)return e;e=e.parent}return null}static show(t){return!t.visible&&(t.visible=!0,!0)}static showAll(t){let e=!1;for(let i=0,s=t.length;i<s;++i){const s=t[i];s.visible||(s.visible=!0,e=!0)}return e}static hide(t){return!!t.visible&&(t.visible=!1,!0)}static hideAll(t){let e=!1;for(let i=0,s=t.length;i<s;++i){const s=t[i];s.visible&&(s.visible=!1,e=!0)}return e}static bringToFront(t){const e=t.parent;return!!e&&this.doBringToFront(t,e.children,0)}static bringAllToFront(t){const e=t.length;if(0<e){const i=t[0].parent;if(i){let s=!1;const n=i.children;for(let i=0;i<e;++i){const o=t[e-1-i];this.doBringToFront(o,n,i)&&(s=!0)}return s}}return!1}static doBringToFront(t,e,i){const s=e.length-1-i;for(let i=s;0<=i;--i){const n=e[i];if(n===t){if(i!==s){for(let t=i+1;t<=s;++t)e[t-1]=e[t];return e[s]=n,!0}return!1}}return!1}}const en={NONE:0,CTRL:1,SHIFT:2,ALT:4,AND:8,OR:16,NOT_NONE:23};class sn{static from(t){const e="data"in t?t.data.originalEvent:t;return(e.ctrlKey?en.CTRL:en.NONE)|(e.altKey?en.ALT:en.NONE)|(e.shiftKey?en.SHIFT:en.NONE)}static match(t,e){return e&en.OR?!!(sn.from(t)&e):sn.from(t)===e}}class nn{static get touchable(){return"ontouchstart"in document}static get tap(){return"pointertap"}static get down(){return"pointerdown"}static get enter(){return"pointerenter"}static get leave(){return"pointerleave"}static get move(){return"pointermove"}static get out(){return"pointerout"}static get over(){return"pointerover"}static get up(){return"pointerup"}static get upoutside(){return"pointerupoutside"}static get cancel(){return"pointercancel"}static get righttap(){return"rightclick"}static get rightdown(){return"rightdown"}static get rightup(){return"rightup"}static get rightupoutside(){return"rightupoutside"}static toGlobal(t,e,i){if("touches"in t){const s=t.changedTouches,n=s[s.length-1];null!=n?e.mapPositionToPoint(i,n.clientX,n.clientY):e.mapPositionToPoint(i,0,0)}else e.mapPositionToPoint(i,t.clientX,t.clientY);return i}static onDblClick(t,e){if(t.addEventListener("dblclick",t=>e(t,!1)),this.touchable){let i=0,s=0,n=0,o=0;t.addEventListener("touchstart",t=>{if(0!==i&&2!==i)return void(i=0);const e=t.touches,o=e.length;if(o<=0)return void(i=0);const r=e.item(o-1);null!=r?(i+=1,s=r.clientX,n=r.clientY):i=0}),t.addEventListener("touchend",t=>{if(1!==i&&3!==i)return void(i=0);const r=t.changedTouches,a=r.length;if(a<=0)return void(i=0);const h=r[a-1];if(null==h)return void(i=0);const l=s-h.clientX,c=n-h.clientY;this.CLICK_DISTANCE_THRESHOLD<=Math.abs(l)+Math.abs(c)?i=0:1===i?(o=t.timeStamp,i=2):t.timeStamp-o<this.DBLCLICK_INTERVAL_THRESHOLD?(i=0,e(t,!0)):(o=t.timeStamp,i=2)}),t.addEventListener("touchcancel",()=>{i=0})}}static contains(t,e){let i=e;for(;null!=i&&i!==t;)i=i.parent;return i===t}}nn.CLICK_DISTANCE_THRESHOLD=10,nn.DBLCLICK_INTERVAL_THRESHOLD=333,nn.LONG_CLICK_THRESHOLD=750;class on{constructor(){this.pointers=new Map,this.center=new t.Point,this.scale=0,this.time=0,this.distance=0}start(t){const e=t.data.originalEvent;"pointerId"in e&&this.pointers.set(e.pointerId,e),this.doUpdate(t)}isUpdatable(t){const e=t.data.originalEvent;return!("pointerId"in e)||this.pointers.has(e.pointerId)}update(t){const e=t.data.originalEvent;"pointerId"in e&&this.pointers.set(e.pointerId,e),this.doUpdate(t)}end(t){let e=!0;const i=t.data.originalEvent;if("touches"in i)e=i.touches.length<=0;else if("pointerId"in i){const t=this.pointers;t.delete(i.pointerId),e=t.size<=0}return this.doUpdate(t),e}bind(t){const e=this.interactionManager;if(e){const t=this.onMove;t&&e.on(nn.move,t);const i=this.onEnd;i&&(e.on(nn.up,i),e.on(nn.upoutside,i),e.on(nn.cancel,i))}}unbind(){const t=this.interactionManager;if(t){const e=this.onMove;e&&t.off(nn.move,e);const i=this.onEnd;i&&(t.off(nn.up,i),t.off(nn.upoutside,i),t.off(nn.cancel,i))}}doUpdate(t){const e=this.interactionManager,i=this.center,s=t.data.originalEvent;if(this.scale=0,this.time=s.timeStamp,"touches"in s){const t=s.touches,n=t.length;if(0<n){let s=0,o=0;for(let e=0,i=t.length;e<i;++e){const i=t[e];s+=i.clientX,o+=i.clientY}if(s/=n,o/=n,e?e.mapPositionToPoint(i,s,o):i.set(s,o),1<n){let e=0;for(let i=1,n=t.length;i<n;++i){const n=t[i],r=n.clientX-s,a=n.clientY-o;e=Math.max(e,r*r+a*a)}this.scale=Math.sqrt(e)}}}else if("pointerId"in s){const t=this.pointers,s=t.size;if(0<s){let n=0,o=0;if(t.forEach(t=>{n+=t.clientX,o+=t.clientY}),n/=s,o/=s,e?e.mapPositionToPoint(i,n,o):i.set(n,o),1<s){let e=0;t.forEach(t=>{const i=t.clientX-n,s=t.clientY-o;e=Math.max(e,i*i+s*s)}),this.scale=Math.sqrt(e)}}}else i.copyFrom(t.data.global)}}class rn{static LINEAR(t){return t}static ELASTIC(t){return t*(3*(1-t)*(1-t)+t*(3*(1-t)+t))}static QUAD_IN_OUT(t){return t<.5?2*t*t:(4-2*t)*t-1}}class an extends t.utils.EventEmitter{constructor(t){var e,i,s;super(),this._id=null,this._target=null!==(e=null==t?void 0:t.target)&&void 0!==e?e:null,this._startTime=0,this._duration=null!==(i=null==t?void 0:t.duration)&&void 0!==i?i:200,this._durationInverse=1/Math.max(1,this._duration),this._reverse=!1,this._onTime=null==t?void 0:t.onTime,this._onTimeBaseBound=()=>{this.onTimeBase()},this._onStart=null==t?void 0:t.onStart,this._onEnd=null==t?void 0:t.onEnd,this._onStop=null==t?void 0:t.onStop,this._timing=null!==(s=null==t?void 0:t.timing)&&void 0!==s?s:rn.ELASTIC;const n=null==t?void 0:t.on;if(n)for(const t in n){const e=n[t];e&&this.on(t,e)}}get target(){return this._target}set target(t){this._target=t}get duration(){return this._duration}set duration(t){this._duration=t,this._durationInverse=1/Math.max(1,t)}start(t=!1){this.stop(),this._startTime=Date.now(),this._reverse=t,this._id=window.setTimeout(this._onTimeBaseBound,0),this.onStart(t);const e=this._duration,i=this.toTime(t?e:0);this.onTime(i,t,0)}onStart(t){const e=this._onStart;null!=e&&e(t,this),this.emit("start",t,this)}onTime(t,e,i){const s=this._onTime;null!=s&&s(t,e,i,this),this.emit("time",t,e,i,this)}onEnd(t){const e=this._onEnd;null!=e&&e(t,this),this.emit("end",t,this)}onStop(t){const e=this._onStop;null!=e&&e(t,this),this.emit("stop",t,this)}isStarted(){return null!=this._id}isReverse(){return this._reverse}onTimeBase(){if(null!=this._id){this._id=null;const t=Date.now()-this._startTime,e=this._duration,i=this._reverse;if(t<e){this._id=window.setTimeout(this._onTimeBaseBound,0);const s=this.toTime(i?e-t:t);this.onTime(s,i,t)}else{const s=this.toTime(i?0:e);this.onTime(s,i,t),this.onEnd(i)}}}toTime(t){return this._timing(t*this._durationInverse,this)}stop(){const t=this._id;null!=t&&(this._id=null,window.clearTimeout(t),this.onStop(this._reverse))}end(){const t=this._id;if(null!=t){this._id=null,window.clearTimeout(t);const e=this._reverse,i=Date.now()-this._startTime,s=this._duration,n=this.toTime(e?0:s);this.onTime(n,e,i),this.onEnd(e)}}}class hn{constructor(t,e,i,s){this.dx=t,this.dy=e,this.ds=i,this.dt=s}set(t,e,i,s){this.dx=t,this.dy=e,this.ds=i,this.dt=s}}class ln{constructor(t,e,i){var s;this._histories=[],this._historiesSorted=[],this._historyBegin=0,this._historyEnd=-1,this._dx=0,this._dy=0,this._ds=0,this._dt=0,this._dtw=0,this._t=0,this._duration=333*(null!==(s=null==i?void 0:i.duration)&&void 0!==s?s:1),this._animation=new an({onTime:t=>{this.onEase(t)},onEnd:()=>{this.onEaseEnd()},timing:rn.LINEAR,duration:this._duration}),this._onMove=t,this._onEnd=e}onStart(){const t=this._histories;for(let e=t.length,i=ln.HISTORY_CAPACITY;e<i;++e)t.push(new hn(0,0,1,0));this._historyBegin=0,this._historyEnd=-1,this._animation.stop()}onMove(t,e,i,s){const n=ln.HISTORY_CAPACITY,o=this._historyEnd,r=(o+1)%n;this._historyEnd=r;const a=this._historyBegin;(r<o||0<=o&&o<a)&&(this._historyBegin=(a+1)%n),this._histories[r].set(t,e,i,s)}updateHistoriesSorted(t){const e=this._histories,i=this._historiesSorted,s=this._historyBegin,n=this._historyEnd,o=e.length;if(n<0)return i.length=0,t;if(n<s){let r=t;i.length=0;for(let t=n;0<=t;--t){const s=e[t];if(!(r+s.dt<160))return r;r+=s.dt,i.push(s)}for(let t=o-1;s<=t;--t){const s=e[t];if(!(r+s.dt<160))return r;r+=s.dt,i.push(s)}return r}{let o=t;i.length=0;for(let t=n;s<=t;--t){const s=e[t];if(!(o+s.dt<160))return o;o+=s.dt,i.push(s)}return o}}onEnd(t){const e=this._duration,i=e-t;if(i<=0)return this.onEaseEnd();this.updateHistoriesSorted(t);const s=this._historiesSorted,n=s.length;if(n<=0)return this.onEaseEnd();let o=0,r=0,a=0,h=0;for(let t=0;t<n;++t){const e=s[t];o+=e.dx,r+=e.dy,a+=e.ds,h+=e.dt}if(h<=0)return this.onEaseEnd();const l=1/n;o*=l,r*=l,a*=l,h*=l*(e/i),this._dx=o,this._dy=r,this._ds=a,this._dt=h;const c=this._animation;c.duration=i,this._t=0,this._dtw=i/h,c.start()}onEase(t){const e=this._t;this._t=t;const i=(1-.5*(t+e))*(t-e)*this._dtw;this._onMove(this._dx*i,this._dy*i,1+(this._ds-1)*i,t)}onEaseEnd(){this._onEnd()}stop(){this._animation.stop()}}ln.HISTORY_CAPACITY=5;class cn{constructor(t,e){null!=t&&(this._onTap=t.tap,this._onLongPress=t.longpress),this._threshold=this.toThreshold(e),this._unused=[],this._used=new Map}toThreshold(t){var e,i;if(null!=t){const s=t.threshold;if(null!=s)return{distance:null!==(e=s.distance)&&void 0!==e?e:10,long:null!==(i=s.long)&&void 0!==i?i:500}}return{distance:10,long:500}}newData(t){const e=this._used,i=e.get(t);if(null!=i)return i;const s=this._unused.pop();if(null!=s)return e.set(t,s),s;const n=new on;return n.easing=void 0,n.onMove=this.newOnMove(n),n.onEnd=this.newOnEnd(n),e.set(t,n),n}deleteData(t){const e=t.target;if(e&&this._used.delete(e)){const e=t.timeoutId;null!=e&&(t.timeoutId=void 0,window.clearTimeout(e)),t.target=void 0,t.pointers.clear(),this._unused.push(t)}}newOnMove(t){return e=>{this.onMove(e,t)}}newOnEnd(t){return e=>{this.onEnd(e,t)}}onDown(t,e){var i;if(null==this._onTap&&null==this._onLongPress)return;const s=ot.getLayer(t);if(null!=s)if(e.stopPropagation(),t.state.isGesturing)null===(i=this._used.get(t))||void 0===i||i.start(e);else{const i=this.newData(t);i.target=t,i.distance=0,t.state.isGesturing=!0;const n=s.renderer.plugins.interaction;i.interactionManager=n,i.start(e),i.bind(e),this.start(t,i,e)}}onMove(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;if(!e.isUpdatable(t))return;const s=e.center,n=s.x,o=s.y;e.update(t);const r=s.x-n,a=s.y-o;e.distance+=Math.abs(r)+Math.abs(a)}onEnd(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;if(!e.end(t))return;i.state.isGesturing=!1;const s=e.interactionManager;if(e.interactionManager=void 0,s){const t=e.onMove;t&&s.off(nn.move,t);const i=e.onEnd;i&&(s.off(nn.up,i),s.off(nn.cancel,i))}this.end(i,e,t),this.deleteData(e)}onLongPress(t,e,i){if(e.timeoutId=void 0,e.distance<this._threshold.distance){e.distance=this._threshold.distance;const s=this._onLongPress;null!=s&&s(t,i)}}start(t,e,i){const s=this._threshold.long;0<=s&&(e.timeoutId=window.setTimeout(()=>{this.onLongPress(t,e,i)},s))}end(t,e,i){const s=e.timeoutId;if(null!=s&&(e.timeoutId=void 0,window.clearTimeout(s)),e.distance<this._threshold.distance){const e=this._onTap;e&&e(t,i)}}stop(t){const e=this._used.get(t);null!=e&&this.deleteData(e)}}class un{constructor(t){var e,i,s;const n=t.on;if(n){this._onStart=n.start,this._onMove=n.move,this._onEnd=n.end,this._onStop=n.stop;const t=n.easing;null!=t&&(this._onEasingStart=t.start,this._onEasingEnd=t.end)}this._modifier=null!==(e=null==t?void 0:t.modifier)&&void 0!==e?e:en.NONE;const o=t.checker,r=sn.match;this._checkerStart=null!==(i=null==o?void 0:o.start)&&void 0!==i?i:r,this._checkerMove=null!==(s=null==o?void 0:o.move)&&void 0!==s?s:r,this._easing=t.easing,this._touch=!!t.touch,this._unused=[],this._used=new Map,this._tap=new cn(t.on,t.tap);const a=t.bind;null!=a&&this.bind(a)}newData(t){const e=this._used,i=e.get(t);if(null!=i)return i;const s=this._unused.pop();if(null!=s)return e.set(t,s),s;const n=new on;return n.easing=this.newEasing(n),n.onMove=this.newOnMove(n),n.onEnd=this.newOnEnd(n),e.set(t,n),n}newEasing(t){const e=this._easing;if(null==e||!1!==e)return new ln((e,i,s,n)=>{this.onEasingMove(e,i,s,n,t)},()=>{this.onEasingEnd(t)},this.toEasingOptions(e))}toEasingOptions(t){return null==t||!0===t?void 0:t}deleteData(t){const e=t.target;e&&this._used.delete(e)&&(t.target=void 0,t.pointers.clear(),this._unused.push(t))}bind(t){return t.on(nn.down,e=>{this.onDown(t,e)}),this}isTouch(t){const e=t.data.originalEvent;return"touches"in e||"pointerId"in e&&"mouse"!==e.pointerType}onDown(t,e){var i;if(this._touch&&!this.isTouch(e))return;if(!this._checkerStart(e,this._modifier,t))return this._tap.onDown(t,e);const s=ot.getLayer(t);if(null!=s)if(e.stopPropagation(),t.state.isGesturing)null===(i=this._used.get(t))||void 0===i||i.start(e);else{const i=this._onStart;null!=i&&i(t);const n=this.newData(t);n.target=t,n.distance=0,t.state.isGesturing=!0;const o=s.renderer.plugins.interaction;n.interactionManager=o,n.start(e);const r=n.easing;r&&r.onStart(),n.bind(e),this._tap.start(t,n,e)}}newOnMove(t){return e=>{this.onMove(e,t)}}newOnEnd(t){return e=>{this.onEnd(e,t)}}onMove(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;if(!e.isUpdatable(t)||!this._checkerMove(t,this._modifier,i))return;const s=e.center,n=s.x,o=s.y,r=e.scale,a=e.time;e.update(t);const h=s.x,l=s.y,c=e.scale,u=h-n,d=l-o,p=e.time-a,_=1e-5,g=_<r&&_<c?c/r:1;e.distance+=Math.abs(u)+Math.abs(d);const f=e.easing;f&&f.onMove(u,d,g,p);const m=this._onMove;null!=m&&(0===u&&0===d&&1===g||m(i,u,d,h,l,g))}onEnd(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;const s=e.time;if(!e.end(t))return;i.state.isGesturing=!1;const n=e.interactionManager;if(e.interactionManager=void 0,n){const t=e.onMove;t&&n.off(nn.move,t);const i=e.onEnd;i&&(n.off(nn.up,i),n.off(nn.cancel,i))}const o=this._onEnd;null!=o&&o(i),this._tap.end(i,e,t);const r=this._onEasingStart;r&&r(e.target);const a=e.easing;if(a)a.onEnd(e.time-s);else{this.deleteData(e);const t=this._onEasingEnd;t&&t(e.target)}}onEasingMove(t,e,i,s,n){const o=n.target;if(null==o)return;const r=this._onMove;if(null==r)return;if(0===t&&0===e&&1===i)return;const a=n.center,h=a.x+t,l=a.y+e;a.set(h,l),r(o,t,e,h,l,i)}onEasingEnd(t){const e=t.target;if(this.deleteData(t),null!=e){const t=this._onEasingEnd;t&&t(e)}}stop(t){this._tap.stop(t);const e=this._used.get(t);if(null!=e){const i=e.easing;null!=i&&i.stop(),this.deleteData(e);const s=this._onStop;s&&s(t)}}}const dn={NONE:0,DRAG:1,PINCH:2,ALL:3};class pn extends ve{constructor(t){super(t,pe.NONE),this._layers=new Map,this._operationType=t.operationType,this._scaleMin=t.scaleMin,this._scaleMax=t.scaleMax}initialize(t,e){if(super.initialize(t,e),null==this._layers.get(t)){const e=tn.toLayer(t);null!=e&&this._layers.set(t,e)}}onDown(e,i,s){if(super.onDown(e,i,s),s instanceof t.InteractionEvent){const t=this._layers.get(e),i=s.data.originalEvent.timeStamp;t&&this.condition(e,i,ge)&&this.getGestureUtil().onDown(t,s)}}getGestureUtil(){var t;return null!==(t=pn.GESTURE_UTIL)&&void 0!==t?t:pn.GESTURE_UTIL=this.newGestureUtil()}newGestureUtil(){const e=new t.Point;return new un({on:{move:(t,i,s,n,o,r)=>{this.onGestureMove(t,i,s,n,o,r,e)}}})}onGestureMove(t,e,i,s,n,o,r){const a=t.parent;if(a){const h=t.transform,l=this._operationType;let c=!1,u=1;if(l&dn.PINCH){const t=h.scale,e=t.y,i=Math.min(this._scaleMax,Math.max(this._scaleMin,e*o));u=i/e,t.set(i,i),c=!0}if(l&dn.DRAG){a.toLocal(r.set(s,n),void 0,r);const t=r.x,o=r.y,l=s-e,d=n-i;a.toLocal(r.set(l,d),void 0,r);const p=r.x,_=r.y,g=h.position,f=(g.x-p)*u+t,m=(g.y-_)*u+o;g.set(f,m),c=!0}c&&ot.update(t)}}toSize(t,e){return"size"in t?e.copyFrom(t.size):e.set(t.width,t.height),e}}class _n extends ve{constructor(t){super(t,pe.NONE),this._operationType=t.operationType,this._scaleMin=t.scaleMin,this._scaleMax=t.scaleMax}onDown(e,i,s){super.onDown(e,i,s),s instanceof t.InteractionEvent&&this.condition(e,s.data.originalEvent.timeStamp,ge)&&this.getGestureUtil().onDown(e,s)}getGestureUtil(){var t;return null!==(t=_n.GESTURE_UTIL)&&void 0!==t?t:_n.GESTURE_UTIL=this.newGestureUtil()}newGestureUtil(){const e=new t.Point;return new un({on:{move:(t,i,s,n,o,r)=>{this.onGestureMove(t,i,s,n,o,r,e)}}})}onGestureMove(t,e,i,s,n,o,r){const a=t.parent;if(a){const h=t.transform,l=this._operationType;let c=!1,u=1;if(l&dn.PINCH){const t=h.scale,e=t.y,i=Math.min(this._scaleMax,Math.max(this._scaleMin,e*o));u=i/e,t.set(i,i),c=!0}if(l&dn.DRAG){a.toLocal(r.set(s,n),void 0,r);const t=r.x,o=r.y,l=s-e,d=n-i;a.toLocal(r.set(l,d),void 0,r);const p=r.x,_=r.y,g=h.position,f=(g.x-p)*u+t,m=(g.y-_)*u+o;g.set(f,m),c=!0}c&&ot.update(t)}}}const gn={SHAPE:0,LAYER:1},fn={INPUT_TEXT:0,INPUT_INTEGER:1,INPUT_REAL:2,EMIT_EVENT:3,WRITE_BOTH:4,WRITE_LOCAL:5,WRITE_REMOTE:6,HTML_ELEMENT:7,HTML_ELEMENT_WITHOUT_POINTER_EVENTS:8,SHOW_HIDE_LAYER:9,GESTURE_LAYER:10,GESTURE:11,EXECUTE:12,EXTENSION:1e3};class mn extends Ie{constructor(t="",e,i,s=.05,n=20){super(Oe.GESTURE,t,e),this.operationType=i,this.scaleMin=s,this.scaleMax=n}toRuntime(){switch(this.subtype){case gn.SHAPE:return new _n(this);case gn.LAYER:return new pn(this)}}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype},${this.operationType},${this.scaleMin},${this.scaleMax}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=this.toSubType(t),n=t[3],o=t[4],r=t[5];return new mn(i,s,n,o,r)}static toSubType(t){if(t[0]!==Oe.MISC)return t[2];switch(t[2]){case fn.GESTURE:return gn.SHAPE;case fn.GESTURE_LAYER:return gn.LAYER}}}const vn={INVISIBLE:"INVISIBLE",INTERACTIVE:"INTERACTIVE",DRAGGABLE:"DRAGGABLE",PINCHABLE:"PINCHABLE"},Tn=(t,e,i,s,n)=>{var o,r,a;const h=((t,e)=>{if(Et(t))return t;{const i=e.resources;return 0<=t&&t<=i.length?i[t]:""}})(t[0],e),l=n?n(h,e):new Qs(h,e.mode,e.depth),c=t[1];null==c||2&c||(l.visible=!1,l.state.add(vn.INVISIBLE));const u=-.5*i+(t[2]||0),d=-.5*s+(t[3]||0);l.transform.position.set(u,d);const p=null!==(o=t[4])&&void 0!==o?o:i,_=null!==(r=t[5])&&void 0!==r?r:s;l.size.set(p,_),l.size.init();const g=t[6];if(null!=g&&l.fill.deserialize(g,e),e.mode===Li.VIEWER){const e=null!==(a=t[7])&&void 0!==a?a:1,i=1&e,s=2&e,n=4&e;if(s||n){const t=(s?dn.DRAG:dn.NONE)|(n?dn.PINCH:dn.NONE);l.action.add(new mn("",gn.LAYER,t))}(i||s||n)&&(l.interactive=!0)}return l};class wn{constructor(t,e){this.children=[],this._width=t,this._height=e}hasConnectors(t){for(let e=0,i=t.length;e<i;++e){const i=t[e];if(i instanceof Os)return!0;const s=i.children;if(0<s.length&&this.hasConnectors(s))return!0}return!1}newHasConnectors(){const t=new Map,e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i];t.set(s,this.hasConnectors(s.children))}return t}copyTo(t){var e;const i=null!==(e=this._hasConnectors)&&void 0!==e?e:this._hasConnectors=this.newHasConnectors(),s=this.children,n=t.children;for(let e=0,o=s.length;e<o;++e){const o=s[e],r=o.clone();r.parent=t,n.push(r),i.get(o)&&As.move(o,r)}t.onChildTransformChange(),t.toDirty(),t.onAttach()}deserialize(t,e){const i=t.length;if(0<i){const s=this._width,n=this._height;for(let o=0;o<i;++o)this.children.push(Tn(t[o],e,s,n))}}}class En{static parse(t){if(null!=t&&Et(t))try{const e=JSON.parse(t);if(null!=e&&wt(e.version)&&Et(e.name)){if(wt(e.width)&&wt(e.height)&&vt(e.items)&&vt(e.resources))return e;if(Et(e.data))return this.toSerialized(e)}}catch(t){}return null}static toSimple(t){return{version:t.version,id:t.id,name:t.name,label:t.label,category:t.category,summary:t.summary,description:t.description,thumbnail:t.thumbnail,data:JSON.stringify({width:t.width,height:t.height,background:t.background,tile:t.tile,resources:t.resources,data:t.data||t.tags,pieces:t.pieces,layers:t.layers,items:t.items,snap:t.snap})}}static toSerialized(t){if(!("items"in t)){const e=JSON.parse(t.data),i={version:t.version,id:t.id,name:t.name,label:t.label,width:e.width,height:e.height,category:t.category,summary:t.summary,description:t.description,background:e.background,tile:e.tile,resources:e.resources,data:e.data||e.tags,pieces:e.pieces,layers:e.layers,items:e.items,snap:e.snap,thumbnail:t.thumbnail};if(null==i.data){const e=t.tags;null!=e&&(i.data=JSON.parse(e))}if(null==i.pieces){const e=t.pieces;null!=e&&(i.pieces=JSON.parse(e))}return i}return t}static newLayer(t,e,i){e.deserialize(t.layers,i);const s=t.items,n=qi(s,i);return null!=n?n.then(t=>{const i=e.children;for(let e=0,n=t.length;e<n;++e){const n=s[e],o=t[e],r=i[n[16]];null!=r&&(o.parent=r,o.uploaded=void 0,r.children.push(o))}for(let t=0,e=i.length;t<e;++t){const e=i[t];e.onChildTransformChange(),e.toDirty();const s=e.children;for(let t=0,e=s.length;t<e;++t)s[t].onAttach()}return t}):Promise.resolve([])}static toPieceData(t,e,i){const s=new Map,n=new Map,o=()=>s;return this.toPieceData_(t,e,s,n,i,0).then(o,o)}static toPieceData_(t,e,i,s,n,o){const r=[];if(e&&0<e.length&&t)for(let a=0,h=e.length;a<h;++a){const h=e[a],l=s.get(h);if(null!=l)r.push(l);else{const e=t.piece.getByName(h).then(e=>this.toPieceData__(t,h,e,n,o+1,i,s),()=>null);s.set(h,e),r.push(e)}}return Promise.all(r)}static toPieceData__(t,e,i,s,n,o,r){const a=this.toSerialized(i),h=a.width,l=a.height,c=new wn(h,l);o.set(e,new Ji(e,h,l,c));const u=a.pieces;return this.toPieceData_(t,u,o,r,s,n).then(()=>this.newLayer(a,c,new ki(a,u,o,s,n)))}}const yn={};class xn{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.background;s&&(this._color=s.color,this._alpha=s.alpha)}getTheme(){return this._theme}setTheme(t){this._theme=t}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBackgroundColor(t)}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onChange())}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBackgroundAlpha(t)}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onChange())}onChange(){const t=this._callback;null!=t&&t()}}const Cn={NONE:0,TOP:1,RIGHT:2,BOTTOM:4,LEFT:8,TOP_RIGHT:3,TOP_BOTTOM:5,TOP_LEFT:9,RIGHT_BOTTOM:6,RIGHT_LEFT:10,BOTTOM_LEFT:12,NOT_TOP:14,NOT_RIGHT:13,NOT_BOTTOM:11,NOT_LEFT:7,ALL:15};class Dn{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.border;s&&(this._color=s.color,this._alpha=s.alpha,this._width=s.width,this._align=s.align,this._mask=Qi(s.mask,Cn))}getTheme(){return this._theme}setTheme(t){this._theme=t}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderColor(t)}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onChange())}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderAlpha(t)}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onChange())}getWidth(t){const e=this._width;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderWidth(t)}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this.onChange())}getAlign(t){const e=this._align;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderAlign(t)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.onChange())}getMask(t){const e=this._mask;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderMask(t)}get mask(){return this._mask}set mask(t){this._mask!==t&&(this._mask=t,this.onChange())}onChange(){const t=this._callback;null!=t&&t()}}const Sn={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_LEFT:4,BOTTOM_RIGHT:8,TOP:3,BOTTOM:12,LEFT:5,RIGHT:10,ALL:15};class bn{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.corner;s&&(wt(s)?(this._radius=s,this._mask=void 0):(this._radius=s.radius,this._mask=Qi(s.mask,Sn)))}getTheme(){return this._theme}setTheme(t){this._theme=t}getRadius(){var t;return null!==(t=this._radius)&&void 0!==t?t:this._theme.getCornerRadius()}get radius(){return this._radius}set radius(t){if(this._radius!==t){this._radius=t;const e=this._callback;null!=e&&e()}}getMask(){var t;return null!==(t=this._mask)&&void 0!==t?t:this._theme.getCornerMask()}get mask(){return this._mask}set mask(t){if(this._mask!==t){this._mask=t;const e=this._callback;null!=e&&e()}}set(t,e){let i=!1;this._radius!==t&&(this._radius=t,i=!0),this._mask!==e&&(this._mask=e,i=!0);const s=this._callback;i&&null!=s&&s()}}const In={NONE:0,SELF:1,CHILDREN:2,BOTH:3};class On{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.outline;s&&(this._color=s.color,this._alpha=s.alpha,this._width=s.width,this._offset=s.offset,this._align=s.align,this._mask=Qi(s.mask,Cn))}getTheme(){return this._theme}setTheme(t){this._theme=t}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineColor(t)}get color(){return this._color}set color(t){if(this._color!==t){this._color=t;const e=this._callback;null!=e&&e()}}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineAlpha(t)}get alpha(){return this._alpha}set alpha(t){if(this._alpha!==t){this._alpha=t;const e=this._callback;null!=e&&e()}}getWidth(t){const e=this._width;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineWidth(t)}get width(){return this._width}set width(t){if(this._width!==t){this._width=t;const e=this._callback;null!=e&&e()}}getOffset(t){const e=this._offset;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineOffset(t)}get offset(){return this._offset}set offset(t){if(this._offset!==t){this._offset=t;const e=this._callback;null!=e&&e()}}getAlign(t){const e=this._align;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineAlign(t)}get align(){return this._align}set align(t){if(this._align!==t){this._align=t;const e=this._callback;null!=e&&e()}}getMask(t){const e=this._mask;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineMask(t)}get mask(){return this._mask}set mask(t){if(this._mask!==t){this._mask=t;const e=this._callback;null!=e&&e()}}}class An{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.padding;null!=s&&(wt(s)?(this._left=s,this._top=s,this._right=s,this._bottom=s):(this._left=s.left,this._top=s.top,this._right=s.right,this._bottom=s.bottom))}getTheme(){return this._theme}setTheme(t){this._theme=t}getCallback(){return this._callback}getLeft(){var t;return null!==(t=this._left)&&void 0!==t?t:this._theme.getPaddingLeft()}get left(){return this._left}set left(t){this._left!==t&&(this._left=t,null!=this._callback&&this._callback())}getTop(){var t;return null!==(t=this._top)&&void 0!==t?t:this._theme.getPaddingTop()}get top(){return this._top}set top(t){this._top!==t&&(this._top=t,null!=this._callback&&this._callback())}getRight(){var t;return null!==(t=this._right)&&void 0!==t?t:this._theme.getPaddingRight()}get right(){return this._right}set right(t){this._right!==t&&(this._right=t,null!=this._callback&&this._callback())}getBottom(){var t;return null!==(t=this._bottom)&&void 0!==t?t:this._theme.getPaddingBottom()}get bottom(){return this._bottom}set bottom(t){this._bottom!==t&&(this._bottom=t,null!=this._callback&&this._callback())}set(t,e,i,s){null==e?(this.top=t,this.right=t,this.bottom=t,this.left=t):null==i?(this.top=t,this.right=e,this.bottom=t,this.left=e):null==s?(this.top=t,this.right=e,this.bottom=i,this.left=e):(this.top=t,this.right=e,this.bottom=i,this.left=s),null!=this._callback&&this._callback()}}class Rn{constructor(t,e){this._point=t,this._onChange=e}get x(){return this._point.x}set x(t){const e=this._point,i=e.x;if(i!==t){e.x=t;const s=e.y;this._onChange(t,s,i,s)}}get y(){return this._point.y}set y(t){const e=this._point,i=e.y;if(i!==t){e.y=t;const s=e.x;this._onChange(s,t,s,i)}}set(t,e){const i=this._point,s=i.x,n=i.y;return s===t&&n===e||(i.set(t,e),this._onChange(t,e,s,n)),this}copyFrom(t){const e=t.x,i=t.y,s=this._point,n=s.x,o=s.y;return n===e&&o===i||(s.copyFrom(t),this._onChange(e,i,n,o)),this}copyTo(t){return t.copyFrom(this._point)}copy(){return this.copyFrom(arguments[0])}clone(t){return new Rn(this._point,t||this._onChange)}equals(t){return this._point.equals(t)}}class Mn extends t.MeshGeometry{constructor(t,e,i){super(t,e,i),this._width=100,this._height=100,this._cornerRadius=0,this._cornerMask=Sn.NONE,this._isDirty=!0,this._resolution=1,this._vertexBuffer=this.getBuffer("aVertexPosition"),this._vertices=this._vertexBuffer.data,this._uvBuffer=this.getBuffer("aTextureCoord"),this._uvs=this._uvBuffer.data,this._indexBuffer=this.getIndex(),this._indices=this._indexBuffer.data}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this._isDirty=!0)}get height(){return this._height}set height(t){this._height!==t&&(this._height=t,this._isDirty=!0)}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){this._cornerRadius!==t&&(this._cornerRadius=t,this._isDirty=!0)}get cornerMask(){return this._cornerMask}set cornerMask(t){this._cornerMask!==t&&(this._cornerMask=t,this._isDirty=!0)}getTables(){let t=Mn.TABLES;return null==t&&(t=this.newTables(Mn.N),Mn.TABLES=t),t}newTables(t){const e=1/(t-1)*.5;return[this.newTable(t,1,e),this.newTable(t,.5,e),this.newTable(t,0,e),this.newTable(t,1.5,e)]}newTable(t,e,i){const s=[],n=[],o=Math.PI;for(let r=0,a=e;r<t;r+=1,a-=i){const t=a*o,e=+Math.cos(t),i=-Math.sin(t);s.push(e),n.push(i)}return{cos:s,sin:n}}}Mn.N=5;class kn extends Mn{constructor(){super(new Float32Array(16*Mn.N),new Float32Array(16*Mn.N),new Uint16Array(3*(12*Mn.N-2)))}fillVertices(t,e,i,s,n,o,r,a,h,l){const c=l.cos,u=l.sin,d=a+h;for(let h=0;h<n;++h){const n=c[h],l=u[h];t[++i]=o+n*a,t[++i]=r+l*a,t[++i]=o+n*d,t[++i]=r+l*d,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+l)}}fillIndices(t,e,i,s){for(let n=0;n<s;++n)t[++i]=e+0,t[++i]=e+1,t[++i]=e+2,t[++i]=e+2,t[++i]=e+1,t[++i]=e+3,e+=2}fillIndicesEnd(t,e,i,s){for(let n=0,o=s-1;n<o;++n)t[++i]=e+0,t[++i]=e+1,t[++i]=e+2,t[++i]=e+2,t[++i]=e+1,t[++i]=e+3,e+=2;t[++i]=e+0,t[++i]=e+1,t[++i]=0,t[++i]=0,t[++i]=e+1,t[++i]=1,e+=2}update(t){const e=t.resolution;if(this._isDirty||this._resolution!==e){this._isDirty=!1,this._resolution=e;const t=this._vertices,i=this._uvs,s=this._indices,n=this._width,o=this._height,r=Math.min(.5*n,.5*o,this._cornerRadius),a=.5/e,h=0,l=r,c=n-r,u=n,d=0,p=r,_=o-r,g=o,f=this._cornerMask,m=!(f&Sn.TOP_LEFT),v=!(f&Sn.TOP_RIGHT),T=!(f&Sn.BOTTOM_LEFT),w=!(f&Sn.BOTTOM_RIGHT);let E=-1,y=-1,x=0,C=-1;const D=Mn.N,S=D<<2,b=D<<1,I=6*D,O=this.getTables(),A=O[0],R=O[1],M=O[2],k=O[3];m?this.fillVertices(t,i,E,y,D,l,p,r,a,A):this.fillVertices(t,i,E,y,D,h,d,0,a,A),this.fillIndices(s,x,C,D),E+=S,y+=S,x+=b,C+=I,v?this.fillVertices(t,i,E,y,D,c,p,r,a,R):this.fillVertices(t,i,E,y,D,u,d,0,a,R),this.fillIndices(s,x,C,D),E+=S,y+=S,x+=b,C+=I,w?this.fillVertices(t,i,E,y,D,c,_,r,a,M):this.fillVertices(t,i,E,y,D,u,g,0,a,M),this.fillIndices(s,x,C,D),E+=S,y+=S,x+=b,C+=I,T?this.fillVertices(t,i,E,y,D,l,_,r,a,k):this.fillVertices(t,i,E,y,D,h,g,0,a,k),this.fillIndicesEnd(s,x,C,D),E+=S,y+=S,x+=b,C+=I,x=2;for(let t=1,e=4*D-1;t<e;t+=1,x+=2)s[++C]=0,s[++C]=x,s[++C]=x+2;this._vertexBuffer.update(),this._uvBuffer.update(),this._indexBuffer.update()}}}class Ln extends t.Mesh{constructor(e){super(new kn,new t.MeshMaterial(e)),e.on("update",()=>{ot.update(this)})}get width(){return this.geometry.width}set width(t){this.geometry.width=t}get height(){return this.geometry.height}set height(t){this.geometry.height=t}get cornerRadius(){return this.geometry.cornerRadius}set cornerRadius(t){this.geometry.cornerRadius=t}get cornerMask(){return this.geometry.cornerMask}set cornerMask(t){this.geometry.cornerMask=t}_render(t){this.geometry.update(t),super._render(t)}}class Nn{get(t,e){let i=this._mesh;return null==i&&(i=new Ln(e.getBackgroundTexture()),i.parent=t,this._mesh=i),i}hide(){const t=this._mesh;null!=t&&(t.visible=!1)}onReflow(t,e,i,s,n,o,r){const a=t.background,h=a.getColor(n);if(null!=h){const l=a.getAlpha(n);if(0<l){const n=this.get(t,s);n.tint=h,n.alpha=l,n.width=e,n.height=i,n.cornerRadius=o,n.cornerMask=r,n.visible=!0}else this.hide()}else this.hide()}render(t){var e;null===(e=this._mesh)||void 0===e||e.render(t)}updateTransform(){var t;null===(t=this._mesh)||void 0===t||t.updateTransform()}}class Pn extends Mn{constructor(){super(new Float32Array(32*Mn.N),new Float32Array(32*Mn.N),new Uint16Array(72*Mn.N)),this._borderWidth=0,this._borderMask=Cn.NONE}get borderWidth(){return this._borderWidth}set borderWidth(t){this._borderWidth!==t&&(this._borderWidth=t,this._isDirty=!0)}get borderMask(){return this._borderMask}set borderMask(t){this._borderMask!==t&&(this._borderMask=t,this._isDirty=!0)}fillVertices(t,e,i,s,n,o,r,a,h,l,c){const u=.5*l,d=a-u,p=a+u,_=d-h,g=p+h,f=c.cos,m=c.sin;if(_<=0){const h=f[0]+f[n-1],l=m[0]+m[n-1];if(d<=0)if(a<=0)for(let a=0;a<n;++a){const n=f[a],c=m[a];t[++i]=o+h*_,t[++i]=r+l*_,t[++i]=o+h*d,t[++i]=r+l*d,t[++i]=o+h*p,t[++i]=r+l*p,t[++i]=o+h*g,t[++i]=r+l*g,e[++s]=.5*(1+n),e[++s]=.5*(1+c),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+c)}else for(let a=0;a<n;++a){const n=f[a],c=m[a];t[++i]=o+h*_,t[++i]=r+l*_,t[++i]=o+h*d,t[++i]=r+l*d,t[++i]=o+n*p,t[++i]=r+c*p,t[++i]=o+n*g,t[++i]=r+c*g,e[++s]=.5*(1+n),e[++s]=.5*(1+c),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+c)}else for(let a=0;a<n;++a){const n=f[a],c=m[a];t[++i]=o+h*_,t[++i]=r+l*_,t[++i]=o+n*d,t[++i]=r+c*d,t[++i]=o+n*p,t[++i]=r+c*p,t[++i]=o+n*g,t[++i]=r+c*g,e[++s]=.5*(1+n),e[++s]=.5*(1+c),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+c)}}else for(let a=0;a<n;++a){const n=f[a],h=m[a];t[++i]=o+n*_,t[++i]=r+h*_,t[++i]=o+n*d,t[++i]=r+h*d,t[++i]=o+n*p,t[++i]=r+h*p,t[++i]=o+n*g,t[++i]=r+h*g,e[++s]=.5*(1+n),e[++s]=.5*(1+h),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+h)}}fillIndices(t,e,i,s,n,o){for(let n=0,o=s-1;n<o;++n)t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=2;n?o?(t[++i]=e+0,t[++i]=e+1,t[++i]=0,t[++i]=0,t[++i]=e+1,t[++i]=1,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=1,t[++i]=1,t[++i]=e+1,t[++i]=2,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=2,t[++i]=2,t[++i]=e+1,t[++i]=3,e+=2):(t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=2):(t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,e+=1,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,e+=1,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,e+=2)}update(t){const e=t.resolution;if(this._isDirty||this._resolution!==e){this._isDirty=!1,this._resolution=e;const t=this._vertices,i=this._uvs,s=this._indices,n=this._width,o=this._height,r=this._borderWidth,a=Math.min(.5*n,.5*o,this._cornerRadius),h=.5/e,l=0,c=a,u=n-a,d=n,p=0,_=a,g=o-a,f=o,m=this._borderMask,v=!(m&Cn.TOP),T=!(m&Cn.BOTTOM),w=!(m&Cn.LEFT),E=!(m&Cn.RIGHT),y=this._cornerMask,x=!(y&Sn.TOP_LEFT),C=!(y&Sn.TOP_RIGHT),D=!(y&Sn.BOTTOM_LEFT),S=!(y&Sn.BOTTOM_RIGHT);let b=-1,I=-1,O=0,A=-1;const R=Mn.N,M=R<<2,k=R<<3,L=18*R,N=this.getTables(),P=N[0],B=N[1],z=N[2],U=N[3];x?w||v?this.fillVertices(t,i,b,I,R,c,_,a,h,r,P):this.fillVertices(t,i,b,I,R,c,_,a,h,0,P):w||v?this.fillVertices(t,i,b,I,R,l,p,0,h,r,P):this.fillVertices(t,i,b,I,R,l,p,0,h,0,P),this.fillIndices(s,O,A,R,v,!1),b+=k,I+=k,O+=M,A+=L,C?v||E?this.fillVertices(t,i,b,I,R,u,_,a,h,r,B):this.fillVertices(t,i,b,I,R,u,_,a,h,0,B):v||E?this.fillVertices(t,i,b,I,R,d,p,0,h,r,B):this.fillVertices(t,i,b,I,R,d,p,0,h,0,B),this.fillIndices(s,O,A,R,E,!1),b+=k,I+=k,O+=M,A+=L,S?E||T?this.fillVertices(t,i,b,I,R,u,g,a,h,r,z):this.fillVertices(t,i,b,I,R,u,g,a,h,0,z):E||T?this.fillVertices(t,i,b,I,R,d,f,0,h,r,z):this.fillVertices(t,i,b,I,R,d,f,0,h,0,z),this.fillIndices(s,O,A,R,T,!1),b+=k,I+=k,O+=M,A+=L,D?T||w?this.fillVertices(t,i,b,I,R,c,g,a,h,r,U):this.fillVertices(t,i,b,I,R,c,g,a,h,0,U):T||w?this.fillVertices(t,i,b,I,R,l,f,0,h,r,U):this.fillVertices(t,i,b,I,R,l,f,0,h,0,U),this.fillIndices(s,O,A,R,w,!0),b+=k,I+=k,O+=M,A+=L,this._vertexBuffer.update(),this._uvBuffer.update(),this._indexBuffer.update()}}}class Bn extends t.Mesh{constructor(e){super(new Pn,new t.MeshMaterial(e)),e.on("update",()=>{ot.update(this)})}get width(){return this.geometry.width}set width(t){this.geometry.width=t}get height(){return this.geometry.height}set height(t){this.geometry.height=t}get cornerRadius(){return this.geometry.cornerRadius}set cornerRadius(t){this.geometry.cornerRadius=t}get cornerMask(){return this.geometry.cornerMask}set cornerMask(t){this.geometry.cornerMask=t}get borderWidth(){return this.geometry.borderWidth}set borderWidth(t){this.geometry.borderWidth=t}get borderMask(){return this.geometry.borderMask}set borderMask(t){this.geometry.borderMask=t}_render(t){this.geometry.update(t),super._render(t)}}class zn{get(t,e){let i=this._mesh;return null==i&&(i=new Bn(e.getBorderTexture()),i.parent=t,this._mesh=i),i}hide(){const t=this._mesh;null!=t&&(t.visible=!1)}onReflow(t,e,i,s,n,o,r){const a=t.border,h=a.getColor(n);if(null!=h){const l=a.getAlpha(n);if(0<l){const c=a.getWidth(n),u=a.getMask(n),d=this.get(t,s),p=(a.getAlign(n)-.5)*c;d.tint=h,d.alpha=l,d.x=-p,d.y=-p,d.width=e+2*p,d.height=i+2*p,d.cornerRadius=Math.max(0,o+p),d.cornerMask=r,d.borderWidth=c,d.borderMask=u,d.visible=!0}else this.hide()}else this.hide()}render(t){var e;null===(e=this._mesh)||void 0===e||e.render(t)}updateTransform(){var t;null===(t=this._mesh)||void 0===t||t.updateTransform()}}class Un{get(t,e){let i=this._mesh;return null==i&&(i=new Bn(e.getBorderTexture()),i.parent=t,this._mesh=i),i}hide(){const t=this._mesh;null!=t&&(t.visible=!1)}onReflow(t,e,i,s,n,o,r){const a=t.outline,h=a.getColor(n);if(null!=h){const l=a.getAlpha(n);if(0<l){const c=a.getWidth(n),u=a.getMask(n),d=this.get(t,s),p=a.getOffset(n)+(a.getAlign(n)-.5)*c;d.tint=h,d.alpha=l,d.x=-p,d.y=-p,d.width=e+2*p,d.height=i+2*p,d.cornerRadius=Math.max(0,o+p),d.cornerMask=r,d.borderWidth=c,d.borderMask=u,d.visible=!0}else this.hide()}else this.hide()}render(t){var e;null===(e=this._mesh)||void 0===e||e.render(t)}updateTransform(){var t;null===(t=this._mesh)||void 0===t||t.updateTransform()}}class Fn{constructor(t){const e=new Nn;this._background=e,t.snippet.add(e,!0);const i=new zn;this._border=i,t.snippet.add(i,!0);const s=new Un;this._outline=s,t.snippet.add(s,!1),t.reflowable.add(this)}onReflow(t,e,i){const s=t.theme,n=t.state,o=t.corner,r=o.getRadius(),a=o.getMask();this._background.onReflow(t,e,i,s,n,r,a),this._border.onReflow(t,e,i,s,n,r,a),this._outline.onReflow(t,e,i,s,n,r,a)}}const Hn={NONE:0,BEFORE:1,AFTER:2,BOTH:3},Gn={OPEN:0,CLOSE:1,PARENSESIS:2,ADD_OR_PLUS:3,SUB_OR_MINUS:4,PLUS:5,MINUS:6,ADD:7,SUB:8,MUL:9,DIV:10,MIN:11,MAX:12,COMMA:13,PARENT:14,SELF:15,PADDING:16,CURRENT:17,NUMBER:18};class Vn{constructor(t){const e=this.toToken(t);let i=0;do{i=this.toParensesis(e,i)}while(i<e.length);if(this.toUnary(e),this.toArithmetic(e,Gn.MUL,Gn.DIV),this.toArithmetic(e,Gn.ADD,Gn.SUB),1===e.length){const t=e[0];if(!wt(t))return void(this._node=t)}throw new Error(`Failed to parse '${t}'`)}toParensesis(t,e){let i=t.length;for(let s=e;s<i;++s)if(t[s]===Gn.OPEN){let e=s,n=Gn.PARENSESIS;if(0<s){const i=t[s-1];i!==Gn.MIN&&i!==Gn.MAX||(e-=1,n=i)}for(let o=s+1;o<i;++o){const r=t[o];if(r===Gn.CLOSE)return t[e]=[n,this.toComma(t,s+1,o)],t.splice(e+1,o-e),e+1;r===Gn.OPEN&&(o=this.toParensesis(t,o)-1,i=t.length)}throw new Error("Malformed parensesis")}return i}toCommaOf(t,e,i){const s=i-e;if(s<=0)return[Gn.NUMBER,0];if(s<=1)return t[e];{const s=[];for(let n=e;n<i;++n)s.push(t[n]);return[Gn.PARENSESIS,s]}}toComma(t,e,i){let s=null,n=e;for(let o=e;o<i;++o)t[o]===Gn.COMMA&&(s=s||[],s.push(this.toCommaOf(t,n,o)),n=o+1);if(n<i){if(null==s){const e=[];for(let s=n;s<i;++s)e.push(t[s]);return e}s.push(this.toCommaOf(t,n,i))}return s||[]}toUnaryNode(t){wt(t)||t[0]!==Gn.PARENSESIS&&t[0]!==Gn.MIN&&t[0]!==Gn.MAX||this.toUnary(t[1])}toUnary(t){for(let e=0,i=t.length;e<i;++e){const s=t[e];if(s===Gn.ADD_OR_PLUS||s===Gn.SUB_OR_MINUS)if(e<=0||wt(t[e-1])){if(!(e+1<i)||wt(t[e+1]))throw new Error("Malformed unary operator");{const n=t.splice(e+1,1)[0],o=s===Gn.ADD_OR_PLUS?Gn.PLUS:Gn.MINUS;t[e]=[o,n],i=t.length,this.toUnaryNode(n)}}else{const i=s===Gn.ADD_OR_PLUS?Gn.ADD:Gn.SUB;t[e]=i}else this.toUnaryNode(s),i=t.length}}toArithmeticNode(t,e,i){wt(t)||(t[0]===Gn.PARENSESIS||t[0]===Gn.MIN||t[0]===Gn.MAX?this.toArithmetic(t[1],e,i):t[0]===Gn.PLUS||t[0]===Gn.MINUS?this.toArithmeticNode(t[1],e,i):t[0]!==Gn.ADD&&t[0]!==Gn.SUB&&t[0]!==Gn.MUL&&t[0]!==Gn.DIV||(this.toArithmeticNode(t[1],e,i),this.toArithmeticNode(t[2],e,i)))}toArithmetic(t,e,i){for(let s=0,n=t.length;s<n;++s){const o=t[s];if(o===e||o===i){if(0<s&&s+1<n){const r=t[s-1],a=t[s+1];if(!wt(r)&&!wt(a)){t.splice(s,2),t[s-1]=[o,r,a],s-=1,n=t.length,this.toArithmeticNode(r,e,i),this.toArithmeticNode(a,e,i);continue}}throw new Error("Malformed operands for the operator "+o)}this.toArithmeticNode(o,e,i),n=t.length}}toToken(t){const e=[];for(;;){const i=Vn.TOKEN_REGEX.exec(t);if(null==i)break;{const s=i[0],n=this.toTokenOperator(s);if(null!=n)e.push(n);else{const n=parseFloat(s);if(n!=n)throw new Error(`Unexpected token '${s}' at ${i.index} in '${t}'`);const o=this.toTokenLiteral(s);null!=o?e.push([o,.01*n]):e.push([Gn.NUMBER,n])}}}return e}toTokenOperator(t){switch(t){case"+":return Gn.ADD_OR_PLUS;case"-":return Gn.SUB_OR_MINUS;case"*":return Gn.MUL;case"/":return Gn.DIV;case"(":return Gn.OPEN;case")":return Gn.CLOSE;case",":return Gn.COMMA;case"min":return Gn.MIN;case"max":return Gn.MAX}return null}toTokenLiteral(t){const e=t.length;if(0<e)switch(t[e-1]){case"%":return Gn.PARENT;case"s":return Gn.SELF;case"p":return Gn.PADDING;case"c":return Gn.CURRENT}return null}evaluate(t,e,i,s,n){switch(t[0]){case Gn.PARENSESIS:const o=t[1];return this.evaluate(o[o.length-1],e,i,s,n);case Gn.PLUS:return+this.evaluate(t[1],e,i,s,n);case Gn.MINUS:return-this.evaluate(t[1],e,i,s,n);case Gn.ADD:return this.evaluate(t[1],e,i,s,n)+this.evaluate(t[2],e,i,s,n);case Gn.SUB:return this.evaluate(t[1],e,i,s,n)-this.evaluate(t[2],e,i,s,n);case Gn.MUL:return this.evaluate(t[1],e,i,s,n)*this.evaluate(t[2],e,i,s,n);case Gn.DIV:return this.evaluate(t[1],e,i,s,n)/this.evaluate(t[2],e,i,s,n);case Gn.MIN:if(0<t[1].length){const o=t[1];let r=this.evaluate(o[0],e,i,s,n);for(let t=1,a=o.length;t<a;++t)r=Math.min(r,this.evaluate(o[t],e,i,s,n));return r}return 0;case Gn.MAX:if(0<t[1].length){const o=t[1];let r=this.evaluate(o[0],e,i,s,n);for(let t=1,a=o.length;t<a;++t)r=Math.max(r,this.evaluate(o[t],e,i,s,n));return r}return 0;case Gn.PARENT:return t[1]*e;case Gn.SELF:return t[1]*i;case Gn.PADDING:return t[1]*s;case Gn.CURRENT:return t[1]*n;case Gn.NUMBER:return t[1]}return 0}calculate(t,e,i,s){return this.evaluate(this._node,t,e,i,s)}}Vn.TOKEN_REGEX=/(?:\+|-|\*|\/|\(|\)|min|max|,|(?:\d+(?:\.\d*)?[%psc]?))/g;const Wn=(t,e)=>.5*(t-e),Kn=(t,e,i)=>i,Xn=t=>t,Yn=(t,e,i)=>t-i;class jn{static position(t){if(null==t||wt(t))return null;if(Et(t)){switch(t){case"center":case"CENTER":return Wn;case"padding":case"PADDING":return Kn}const e=new Vn(t);return(t,i,s,n)=>e.calculate(t,i,s,n)}if(Tt(t))return t;{const e=t;return(t,i,s,n)=>e.calculate(t,i,s,n)}}static size(t){if(null==t||wt(t))return null;if(Et(t)){switch(t){case"100%":case"maximized":case"MAXIMIZED":return Xn;case"padding":case"PADDING":return Yn}const e=new Vn(t);return(t,i,s,n)=>e.calculate(t,i,s,n)}if(Tt(t))return t;{const e=t;return(t,i,s,n)=>e.calculate(t,i,s,n)}}}class $n{static isActivateKey(t){return"Space"===t.key||"Enter"===t.key||32===t.which||13===t.which}static isArrowUpKey(t){return"ArrowUp"===t.key||38===t.which}static isArrowDownKey(t){return"ArrowDown"===t.key||40===t.which}static isArrowLeftKey(t){return"ArrowLeft"===t.key||37===t.which}static isArrowRightKey(t){return"ArrowRight"===t.key||39===t.which}static isCancelKey(t){return"Esc"===t.key||27===t.which}static isFocusKey(t){return"Tab"===t.key||9===t.which}static isUndoKey(t){return t.ctrlKey&&("z"===t.key||90===t.which)}static isRedoKey(t){return t.ctrlKey&&("y"===t.key||89===t.which)}static isSaveKey(t){return t.ctrlKey&&!t.shiftKey&&("s"===t.key||83===t.which)}static isSaveAsKey(t){return t.ctrlKey&&t.shiftKey&&("S"===t.key||83===t.which)}static isDeleteKey(t){return"Delete"===t.key||46===t.which}static isSelectAllKey(t){return t.ctrlKey&&!t.shiftKey&&("a"===t.key||65===t.which)}static isOkKey(t){return"Enter"===t.key||13===t.which}static getFocusDirection(t){return!0!==t.shiftKey}static toShortcut(t){if(Et(t)){const e=t,i=e.indexOf("->");let s,n;0<=i?(s=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+2).trim()):s=e.trim().toLowerCase();let o=!1,r=!1,a=!1,h="a";const l=s.length;let c=0,u=1;for(;u<l;++u)if("+"===s.charAt(u)){const t=s.substring(c,u);switch(t){case"alt":o=!0;break;case"ctrl":r=!0;break;case"shift":a=!0;break;default:h=t}u+=1,c=u}return c!==u&&(h=s.substring(c,u)),(t=>{const e=t.key;if(e.length<=1){t.shift&&(t.key=e.toUpperCase());const i=e.charCodeAt(0);t.which=97<=i&&i<=122?i-32:i}else switch(e){case"enter":t.key="Enter",t.which=13;break;case"space":t.key=" ",t.which=32;break;case"escape":t.key="Escape",t.which=27;break;case"f1":t.key="F1",t.which=112;break;case"f2":t.key="F2",t.which=113;break;case"f3":t.key="F3",t.which=114;break;case"f4":t.key="F4",t.which=115;break;case"f5":t.key="F5",t.which=116;break;case"f6":t.key="F6",t.which=117;break;case"f7":t.key="F7",t.which=118;break;case"f8":t.key="F8",t.which=119;break;case"f9":t.key="F9",t.which=120;break;case"f10":t.key="F10",t.which=121;break;case"f11":t.key="F11",t.which=122;break;case"f12":t.key="F12",t.which=123;break;case"capslock":t.key="CapsLock",t.shift?t.which=20:t.which=240;break;case"arrowup":t.key="ArrowUp",t.which=38;break;case"arrowdown":t.key="ArrowDown",t.which=40;break;case"arrowleft":t.key="ArrowLeft",t.which=37;break;case"arrowright":t.key="ArrowRight",t.which=39;break;case"insert":t.key="Insert",t.which=45;break;case"delete":t.key="Delete",t.which=46;break;case"pageup":t.key="PageUp",t.which=33;break;case"pagedown":t.key="PageDown",t.which=34;break;case"backspace":t.key="Backspace",t.which=8;break;case"colon":t.key=":",t.which=186;break;case"semicolon":t.key=";",t.which=187;break;case"pause":t.key="Pause",t.which=19;break;case"scrolllock":t.key="ScrollLock",t.which=145;break;case"tab":t.key="Tab",t.which=9;break;case"plus":t.key="+",t.which=187;break;case"minus":t.key="-",t.which=189}return t})({alt:o,ctrl:r,shift:a,key:h,which:0,event:n})}return t}static toString(t){const e=[];return t.ctrl&&e.push("Ctrl"),t.shift&&e.push("Shift"),t.alt&&e.push("Alt"),e.push(t.key.toUpperCase()),e.join("+")}static on(t,e,i){const s=this.toShortcut(e);document.body.addEventListener("keydown",e=>{e.altKey!==s.alt||e.ctrlKey!==s.ctrl||e.shiftKey!==s.shift||e.key!==s.key&&e.which!==s.which||(t.state.isActionable&&(null!=s.event?t.emit(s.event):null!=i&&i(e)),e.preventDefault())})}static moveFocusVertically(t,e,i){if(e.state.isActionable){const s=$n.isArrowUpKey(t),n=$n.isArrowDownKey(t);if(s||n)return this.moveFocus(n,e,i)}return!1}static moveFocusHorizontally(t,e,i){if(e.state.isActionable){const s=$n.isArrowLeftKey(t),n=$n.isArrowRightKey(t);if(s||n)return this.moveFocus(n,e,i)}return!1}static moveFocus(t,e,i){var s;const n=null!==(s=null==i?void 0:i.picked)&&void 0!==s?s:ot.getLayer(e);if(n){const i=n.getFocusController(),s=i.get();if(null!=s){const n=i.find(s,!1,s.state.isFocusRoot||t,t,e);if(null!=n)return i.focus(n),!0}}return!1}}class qn{constructor(){this._isOn=!1}get isOff(){return!this._isOn}get isOn(){return this._isOn}toCoordinate(t){return this._isOn?"auto":t}from(t){return"auto"===t||"AUTO"===t?(this._isOn=!0,!0):(this._isOn=!1,!1)}}class Zn{constructor(){this.width=new qn,this.height=new qn}}class Jn{constructor(t){this._parent=t,this._befores=[],this._afters=[],this._renderable=!0}get renderable(){return this._renderable}set renderable(t){this._renderable=t}add(t,e){(e?this._befores:this._afters).push(t),"parent"in t&&(t.parent=this._parent)}addAt(t,e,i){const s=e?this._befores:this._afters;0===i?s.unshift(t):0<i&&i<s.length?s.splice(i,0,t):s.push(t),"parent"in t&&(t.parent=this._parent)}remove(t,e){const i=e?this._befores:this._afters,s=i.indexOf(t);0<=s&&(i.splice(s,1),"parent"in t&&(t.parent=null))}render(t,e){if(this._renderable){const i=e?this._befores:this._afters;for(let e=0,s=i.length;e<s;++e)i[e].render(t)}}updateTransform(){const t=this._befores;for(let e=0,i=t.length;e<i;++e)t[e].updateTransform();const e=this._afters;for(let t=0,i=e.length;t<i;++t)e[t].updateTransform()}}class Qn{constructor(){this._list=[]}add(t){this._list.push(t)}remove(t){const e=this._list,i=e.indexOf(t);0<=i&&e.splice(i,1)}onReflow(t,e,i){const s=this._list;for(let n=0,o=s.length;n<o;++n)s[n].onReflow(t,e,i)}}class to extends t.Container{constructor(t){var e,i,s,n,o,r,a,h,l;super();const c=this.transform;this._position=new Rn(c.position,(t,e,i,s)=>{this.onMove(t,e,i,s)}),this._scale=new Rn(c.scale,(t,e,i,s)=>{this.onScale(t,e,i,s)}),this._skew=new Rn(c.skew,(t,e,i,s)=>{this.onSkew(t,e,i,s)}),this._options=t;const u=this._scalarSet={};this._auto=new Zn,this._isDirty=!0,this._hasDirty=!1,this._isHierarchyDirty=!1,this._shadow=null,this.name=null!==(e=null==t?void 0:t.name)&&void 0!==e?e:"";const d=(t=>{const e=null==t?void 0:t.theme;if(e)return Et(e)?$.getInstance().get(e):e})(t)||this.getThemeDefault();this._theme=d,this._snippet=new Jn(this),this._reflowable=new Qn,this._clearType=Qi(null!==(i=null==t?void 0:t.clear)&&void 0!==i?i:d.getClearType(),Hn),this._padding=this.newPadding(d,t,()=>{this.toDirty(),this.toParentResized(),this.toHierarchyDirty(),ot.update(this)});const p=()=>{this.toDirty(),ot.update(this)};this._background=new xn(d,t,p),this._border=new Dn(d,t,p),this._outline=new On(d,t,p),this._corner=new bn(d,t,p);const _=c.position,g=null!==(s=null==t?void 0:t.x)&&void 0!==s?s:d.getX();wt(g)?_.x=g:(_.x=0,u.x=jn.position(g));const f=null!==(n=null==t?void 0:t.y)&&void 0!==n?n:d.getY();wt(f)?_.y=f:(_.y=0,u.y=jn.position(f));const m=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:d.getWidth();this._auto.width.from(m)?this._width=100:wt(m)?this._width=m:(this._width=100,u.width=jn.size(m));const v=null!==(r=null==t?void 0:t.height)&&void 0!==r?r:d.getHeight();if(this._auto.height.from(v)?this._height=100:wt(v)?this._height=v:(this._height=100,u.height=jn.size(v)),null!=t){const e=t.visible;null!=e&&(this.visible=e)}if(null!=t){const e=t.renderable;null!=e&&(this.renderable=e)}this._state=new xt((t,e)=>{this.onStateChange(t,e)});const T=Qi(null!==(a=null==t?void 0:t.interactive)&&void 0!==a?a:d.getInteractive(),In);if(this.interactive=!!(T&In.SELF),this.interactiveChildren=!!(T&In.CHILDREN),null!=t){const e=t.on;if(null!=e)for(const t in e){const i=e[t];i&&this.on(t,i)}}let w;if(this._title=null!==(h=null==t?void 0:t.title)&&void 0!==h?h:d.getTitle(),this._weight=null!==(l=null==t?void 0:t.weight)&&void 0!==l?l:d.getWeight(),this.initReflowable(),this._onShadowUpdateBound=()=>{ot.update(this)},null!=t&&(w=t.shadow),void 0===w&&(w=d.getShadow()),w)if(Et(w))switch(w){case"WEAK":this.shadow=d.newShadowWeak();break;case"DEFAULT":this.shadow=d.newShadow()}else this.shadow=w;this.on(nn.over,t=>{this.onOver(t)}),this.on(nn.out,t=>{this.onOut(t)}),this.on(nn.down,t=>{this.onDown(t)}),this.on(nn.up,t=>{this.onUp(t)}),this.on("added",()=>{this.toParentResized(),(this.isDirty()||this.hasDirty())&&this.toParentHasDirty(),this._isHierarchyDirty&&this.toParentHierarchyDirty();const t=this.parent;t instanceof to&&(this.state.parent=t.state),ot.update(this)}),this.on("removed",()=>{this.blur(!0),this.state.parent=null,ot.update(this)});const E=(t=>{if(t){const e=t.shortcut,i=t.shortcuts;if(null!=i||null!=e){const t=[];if(null!=e&&t.push($n.toShortcut(e)),null!=i)for(let e=0,s=i.length;e<s;++e)t.push($n.toShortcut(i[e]));return t}}})(t);if(this._shortcuts=E,null!=E){const t=t=>{this.onShortcut(t)};for(let e=0,i=E.length;e<i;++e)$n.on(this,E[e],t)}if(this.init(t),d.newState(this._state),null!=t){const e=t.state;if(null!=e){const t=this._state;if(Et(e))t.add(e);else if(vt(e))t.addAll(e);else{const i=e.values;null!=i&&(Et(i)?t.add(i):t.addAll(i));const s=e.blinkers;if(null!=s){const e=t.blinker;for(let t=0,i=s.length;t<i;++t){const i=s[t];e.add(i.state,i.interval)}}const n=e.tickers;if(null!=n){const e=t.ticker;for(let t=0,i=n.length;t<i;++t){const i=n[t];e.add(i.state,i.interval)}}}}}if(null!=t){const e=t.parent;null!=e&&e.addChild(this)}if(null!=t){const e=t.children;if(null!=e)for(let t=0,i=e.length;t<i;++t){const i=e[t];null!=i&&this.addChild(i)}}let y;null!=t&&(y=t.cursor,this._cursor=y),this.cursor=this.toCursor(y,this._state),this.emit("init",this)}newPadding(t,e,i){return new An(t,e,i)}toCursor(t,e){if(t)if(Tt(t)){const i=t(e);if(void 0!==i)return i}else if(void 0!==t)return t;return this.theme.getCursor(e)}get snippet(){return this._snippet}get reflowable(){return this._reflowable}initReflowable(){new Fn(this)}onChildrenChange(){this.toHierarchyDirty(),super.onChildrenChange()}onShortcut(t){this.emit("shortcut",t,this)}init(t){}get weight(){return this._weight}set weight(t){this._weight!==t&&(this._weight=t,this.toHierarchyDirty(),ot.update(this))}onMove(t,e,i,s){const n=this.children;for(let o=0,r=n.length;o<r;++o){const r=n[o];r instanceof to&&r.onParentMove(t,e,i,s)}ot.update(this),this.emit("move",t,e,i,s,this)}resize(t,e){const i=this._width,s=this._height,n=null!=t?t:i,o=null!=e?e:s,r=i!==n,a=s!==o;r&&(this._width=n),a&&(this._height=o);const h=r||a;if(h&&this.onResize(n,o,i,s),r){const t=this._scalarSet;if(null!=t.x){const e=this._position,i=this.getParentOfSize();i&&(this._position.x=t.x(i.width,n,i.padding.getLeft(),e.x))}}if(a){const t=this._scalarSet;if(null!=t.y){const e=this._position,i=this.getParentOfSize();i&&(this._position.y=t.y(i.height,o,i.padding.getTop(),e.y))}}return h}getClearType(){return this._clearType}onResize(t,e,i,s){this.toDirty(),this.toHierarchyDirty();const n=this._padding,o=this.children;for(let i=0,s=o.length;i<s;++i){const s=o[i];s instanceof to&&s.onParentResize(t,e,n)}ot.update(this),this.emit("resize",t,e,i,s,this)}onScale(t,e,i,s){ot.update(this),this.emit("scale",t,e,i,s,this)}onSkew(t,e,i,s){ot.update(this),this.emit("skew",t,e,i,s,this)}get type(){return this.getType()}get x(){return this._position.x}set x(t){this.setX(t)}getX(){const t=this._scalarSet;return null!=t.x?t.x:this._position.x}setX(t){const e=this._scalarSet;if(wt(t)){const i=this._position;i.x!==t?(e.x=void 0,i.x=t):void 0!==e.x&&(e.x=void 0,this.toParentResized())}else{const i=jn.position(t);e.x!==i&&(e.x=i,this.toParentResized())}}get y(){return this._position.y}set y(t){this.setY(t)}getY(){const t=this._scalarSet;return null!=t.y?t.y:this._position.y}setY(t){const e=this._scalarSet;if(wt(t)){const i=this._position;i.y!==t?(e.y=void 0,i.y=t):void 0!==e.y&&(e.y=void 0,this.toParentResized())}else{const i=jn.position(t);e.y!==i&&(e.y=i,this.toParentResized())}}get width(){return this._width}set width(t){this.setWidth(t)}getWidth(){return this._auto.width.toCoordinate(this._scalarSet.width||this._width)}setWidth(t){const e=this._auto.width,i=e.isOn,s=e.from(t);if(e.isOn!==i&&(this.toHierarchyDirty(),ot.update(this)),!s){const e=this._scalarSet;if(wt(t)){const i=this._width;if(i!==t){e.width=void 0,this._width=t;const s=this._height;if(this.onResize(t,s,i,s),null!=e.x){const i=this._position,s=this.getParentOfSize();s&&(i.x=e.x(s.width,t,s.padding.getLeft(),i.x))}}else void 0!==e.width&&(e.width=void 0,this.toParentResized())}else{const i=jn.size(t);e.width!==i&&(e.width=i,this.toParentResized())}}}get height(){return this._height}set height(t){this.setHeight(t)}getHeight(){return this._auto.height.toCoordinate(this._scalarSet.height||this._height)}setHeight(t){const e=this._auto.height,i=e.isOn,s=e.from(t);if(e.isOn!==i&&(this.toHierarchyDirty(),ot.update(this)),!s){const e=this._scalarSet;if(wt(t)){const i=this._height;if(i!==t){e.height=void 0,this._height=t;const s=this._width;if(this.onResize(s,t,s,i),null!=e.y){const i=this._position,s=this.getParentOfSize();s&&(i.y=e.y(s.height,t,s.padding.getTop(),i.y))}}else void 0!==e.height&&(e.height=void 0,this.toParentResized())}else{const i=jn.size(t);e.height!==i&&(e.height=i,this.toParentResized())}}}get position(){return this._position}get scale(){return this._scale}get skew(){return this._skew}get padding(){return this._padding}get corner(){return this._corner}get background(){return this._background}get border(){return this._border}get outline(){return this._outline}get unsafe(){return this.transform}get title(){return this._title}set title(t){this._title!==t&&(this._title=t,this.state.isHovered&&this.applyTitle())}applyTitle(){const t=ot.getLayer(this);t&&(t.view.title=this._title)}show(){return this.visible||(this.visible=!0,this.toParentHierarchyDirty(),ot.update(this)),this}isShown(){return this.visible}hide(){return this.visible&&(this.visible=!1,this.toParentHierarchyDirty(),this.blur(!0),ot.update(this)),this}isHidden(){return!this.visible}toDirty(){return!this._isDirty&&(this._isDirty=!0,this.toParentHasDirty(),!0)}toHasDirty(){return!this._hasDirty&&(this._hasDirty=!0,this.toParentHasDirty(),!0)}toParentHasDirty(){const t=this.parent;t instanceof to&&t.toHasDirty()}toHierarchyDirty(){return!this._isHierarchyDirty&&(this._isHierarchyDirty=!0,this.onHierarchyDirty(),this.toParentHierarchyDirty(),!0)}toParentHierarchyDirty(){const t=this.parent;t instanceof to&&t.toHierarchyDirty()}isHierarchyDirty(){return this._isHierarchyDirty}onHierarchyDirty(){}isDirty(){return this._isDirty}hasDirty(){return this._hasDirty}setFocused(t){if(this.state.isFocused!==t){const e=ot.getLayer(this);e&&e.getFocusController().set(this,t)}return this}focus(){return this.setFocused(!0)}blur(t){if(t){const t=ot.getLayer(this);if(t){const e=t.getFocusController().get();if(e instanceof to){let t=e;for(;t;){if(t===this){e.setFocused(!1);break}t=t.parent}}}}else this.setFocused(!1);return this}onStateChange(t,e){this.toDirty(),ot.update(this),this.emit("statechange",t,e,this);const i=this.children;for(let s=0,n=i.length;s<n;++s){const n=i[s];n instanceof to&&n.state.onParentChange(t,e)}t.isFocused?(e.isFocused||this.onFocus(),t.inDisabled&&!e.inDisabled&&setTimeout(()=>{this.blur()},0)):e.isFocused&&this.onBlur(),this.cursor=this.toCursor(this._cursor,t)}onChildFocus(t){const e=this.parent;e instanceof to&&e.onChildFocus(t)}onFocus(){const t=this.parent;t instanceof to&&t.onChildFocus(this)}onChildBlur(t){const e=this.parent;e instanceof to&&e.onChildBlur(t)}onBlur(){const t=this.parent;t instanceof to&&t.onChildBlur(this)}get state(){return this._state}get options(){return this._options}get theme(){return this._theme}set theme(t){this._theme!==t&&(this._theme=t,this._padding.setTheme(t),this._background.setTheme(t),this._border.setTheme(t),this._outline.setTheme(t),this._corner.setTheme(t),this.toDirty(),ot.update(this))}reflow(){const t=this._isDirty;t&&(this.onReflow(),this._isDirty=!1);const e=this._hasDirty,i=this._isHierarchyDirty;if(e||i){this._hasDirty=!1,this._isHierarchyDirty=!1;const t=this.children;for(let e=0,i=t.length;e<i;++e){const i=t[e];i instanceof to&&i.reflow()}}(t||e||i)&&this.onRefit()}onRefit(){const e=this._auto,i=e.width.isOn,s=e.height.isOn;if(i&&s){let e=0,i=0;const s=this.children;for(let n=0,o=s.length;n<o;++n){const o=s[n];if(o.visible){const s=this.hasRefitableWidth(o),n=this.hasRefitableHeight(o);if(s||n)if(o instanceof to)s&&(e=Math.max(e,o.x+o.width)),n&&(i=Math.max(i,o.y+o.height));else if(o instanceof t.Container){const t=o.getLocalBounds(void 0,!0);s&&(e=Math.max(e,o.x+t.x+t.width)),n&&(i=Math.max(i,o.y+t.y+t.height))}else{const t=o.getLocalBounds();s&&(e=Math.max(e,o.x+t.x+t.width)),n&&(i=Math.max(i,o.y+t.y+t.height))}}}const n=this.padding;this.resize(e+n.getRight(),i+n.getBottom())}else if(i){let e=0;const i=this.children;for(let s=0,n=i.length;s<n;++s){const n=i[s];if(n.visible&&this.hasRefitableWidth(n))if(n instanceof to)e=Math.max(e,n.x+n.width);else if(n instanceof t.Container){const t=n.getLocalBounds(void 0,!0);e=Math.max(e,n.x+t.x+t.width)}else{const t=n.getLocalBounds();e=Math.max(e,n.x+t.x+t.width)}}this.resize(e+this.padding.getRight(),void 0)}else if(s){let e=0;const i=this.children;for(let s=0,n=i.length;s<n;++s){const n=i[s];if(n.visible&&this.hasRefitableHeight(n))if(n instanceof to)e=Math.max(e,n.y+n.height);else if(n instanceof t.Container){const t=n.getLocalBounds(void 0,!0);e=Math.max(e,n.y+t.y+t.height)}else{const t=n.getLocalBounds();e=Math.max(e,n.y+t.y+t.height)}}this.resize(void 0,e+this.padding.getBottom())}}isRefitable(t){return t instanceof to}hasRefitableHeight(t){return this.isRefitable(t)&&!(t instanceof to&&Tt(t.getHeight()))}hasRefitableWidth(t){return this.isRefitable(t)&&!(t instanceof to&&Tt(t.getWidth()))}onReflow(){this._reflowable.onReflow(this,this._width,this._height)}get shadow(){return this._shadow}set shadow(t){const e=this._shadow;if(e!==t){const i=this._reflowable,s=this._snippet,n=this._onShadowUpdateBound;null!=e&&(e.off("update",n),i.remove(e),s.remove(e,!0)),this._shadow=t,null!=t&&(t.on("update",n),i.add(t),s.addAt(t,!0,0)),ot.update(this)}}toParentResized(){const t=this.getParentOfSize();t&&this.onParentResize(t.width,t.height,t.padding)}getParentOfSize(){const t=this.parent;return t instanceof to?t:ot.getLayer(this)}onParentResize(t,e,i){const s=this._scalarSet,n=this.transform.position,o=n.x,r=n.y,a=this._width,h=this._height,l=i.getLeft()+i.getRight(),c=i.getTop()+i.getBottom(),u=null!=s.width?s.width(t,a,l,a):a,d=null!=s.height?s.height(e,h,c,h):h;this.resize(u,d);const p=null!=s.x?s.x(t,this._width,i.getLeft(),o):o,_=null!=s.y?s.y(e,this._height,i.getTop(),r):r;this.position.set(p,_)}onParentMove(t,e,i,s){}onWheel(t,e,i){return this.emit("wheel",t,e,i,this),!1}onKeyDown(t){return this.emit("keydown",t,this),!1}onKeyUp(t){return this.emit("keyup",t,this),!1}isEventTarget(t){const e=t.target;if(e===this)return!0;if(null!=e&&!(e instanceof to&&e.interactive)){let t=e.parent;for(;null!=t&&!(t instanceof to&&t.interactive);)t=t.parent;return t===this}return!1}onDown(t){this.isEventTarget(t)&&this.onDownThis(t),this.emit("down",t,this)}onDownThis(e){var i;"touches"in e.data.originalEvent?(null!==(i=this._lastDownPoint)&&void 0!==i?i:this._lastDownPoint=new t.Point).copyFrom(e.data.global):this.focusOnClosest()}onUp(t){this.isEventTarget(t)&&this.onUpThis(t),this.emit("up",t,this)}onUpThis(t){if("touches"in t.data.originalEvent){const e=this._lastDownPoint;if(e){const i=t.data.global,s=Math.abs(i.x-e.x),n=Math.abs(i.y-e.y),o=nn.CLICK_DISTANCE_THRESHOLD;s<o&&n<o&&this.focusOnClosest()}}}focusOnClosest(){const t=ot.getLayer(this);if(t){const e=t.getFocusController();e.focus(e.findParent(this))}}onOver(t){this.state.isHovered=!0,t.target===this&&this.applyTitle(),this.emit("over",t,this)}onOut(t){this.state.isHovered=!1,this.emit("out",t,this)}onDblClick(t,e){return this.emit("dblclick",t,e,this),!1}render(t){if(this.visible&&0<this.worldAlpha&&this.renderable){const e=this._snippet;e.render(t,!0),super.render(t),e.render(t,!1)}}updateTransform(){super.updateTransform(),this._snippet.updateTransform()}getThemeDefault(){return $.getInstance().get(this.getType())}getType(){return"DBase"}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this._width,this._height),super._calculateBounds()}containsPoint(t){return this.containsGlobalPoint(t)||this.containsLocalPoint(this.worldTransform.applyInverse(t,to.WORK_CONTAINS_POINT))}containsGlobalPoint(t){return!1}containsLocalPoint(t){const e=t.x,i=t.y,s=this._width,n=this._height;return 0<=e&&e<=s&&0<=i&&i<=n}getClippingRect(t,e){e.x=0,e.y=0,e.width=this._width,e.height=this._height}destroy(){const t=this._scalarSet;t.x=null,t.y=null,t.width=null,t.height=null;const e=this._shadow;e&&(this._shadow=null,e.destroy());const i=this.children;for(let t=i.length-1;0<=t;--t)i[t].destroy();i.length=0,super.destroy()}}to.WORK_CONTAINS_POINT=new t.Point;class eo extends t.Graphics{constructor(t){super(),this.parent=t,this._isInitialized=!1,this._width=0,this._height=0,this._cornderRadius=0,this._cornerMask=Sn.NONE}render(t){this.updateTransform(),super.render(t)}onReflow(t,e,i){const s=t.corner,n=Math.max(0,s.getRadius()-.5),o=s.getMask();if(this._isInitialized&&this._width===e&&this._height===i&&this._cornderRadius===n&&this._cornerMask===o)return;this._isInitialized=!0,this._width=e,this._height=i,this._cornderRadius=n,this._cornerMask=o;const r=o&Sn.TOP_LEFT?0:n,a=o&Sn.TOP_RIGHT?0:n,h=o&Sn.BOTTOM_LEFT?0:n,l=o&Sn.BOTTOM_RIGHT?0:n;this.clear(),this.beginFill(16777215,1),this.lineStyle(0,0,0,0,!1),r<=0&&a<=0&&h<=0&&l<=0?this.drawRect(0,0,e,i):(this.moveTo(0+r,0),0<a?this.arcTo(0+e,0,0+e,0+i,a):this.lineTo(0+e,0),0<l?this.arcTo(0+e,0+i,0,0+i,l):this.lineTo(0+e,0+i),0<h?this.arcTo(0,0+i,0,0,h):this.lineTo(0,0+i),0<r?this.arcTo(0,0,0+e,0,r):this.lineTo(0,0)),this.endFill()}}const io={OFF:0,ON:1,TOUCH:2};class so{constructor(e,i,s,n,o,r){var a,h;this._owner=e,this._parent=s,this._constraint=n;const l=Qi(null!==(a=null==r?void 0:r.mode)&&void 0!==a?a:o.getGestureMode(),io),c=Qi(null!==(h=null==r?void 0:r.modifier)&&void 0!==h?h:o.getGestureModifier(),en);if(l===io.ON||l===io.TOUCH){const s=new t.Point;this._gestureUtil=new un({touch:l===io.TOUCH,modifier:c,checker:r&&r.checker,easing:{duration:null==r?void 0:r.duration},on:{start:t=>{this.onStart(t)},move:(t,n,o,r,a,h)=>{this.onGestureMove(i(e),n,o,r,a,h,s)},easing:{end:t=>{this.onEnd(t)}},stop:t=>{this.onStop(t)},tap:(t,e)=>{this.onTap(t,e)},longpress:(t,e)=>{this.onLongPress(t,e)}}})}}onStart(t){const e=this._parent;e.stop(),e.emit("gesturestart",t,e)}onEnd(t){const e=this._parent;e.emit("gestureend",t,e)}onStop(t){const e=this._parent;e.emit("gesturestop",t,e)}onTap(t,e){const i=this._parent;i.emit("gesturetap",t,e,i)}onLongPress(t,e){const i=this._parent;i.emit("gesturelongpress",t,e,i)}onGestureMove(t,e,i,s,n,o,r){if(null!=t){const a=this._parent,h=t.scale,l=h.x,c=h.y;let u=a.toNormalizedScale(l*o),d=a.toNormalizedScale(c*o);const p=u/l,_=d/c,g=o<1?Math.max(p,_):Math.min(p,_);u=g*l,d=g*c;const f=t.parent;null!=f&&(f.toLocal(r.set(s,n),void 0,r),s=r.x,n=r.y);const m=s-e,v=n-i,T=t.position,w=(T.x-m)*g+s,E=(T.y-v)*g+n;this._constraint(t,w,E,u,d)}}stop(){var t;null===(t=this._gestureUtil)||void 0===t||t.stop(this._owner)}onDown(t){var e;null===(e=this._gestureUtil)||void 0===e||e.onDown(this._owner,t)}}class no{constructor(t,e,i,s,n){this._owner=t,this._toTarget=e,this._constraint=s,this._newScaleX=1,this._newScaleY=1,this._newX=0,this._newY=0,this._oldScaleX=1,this._oldScaleY=1,this._oldX=0,this._oldY=0,this._isStarted=!1,this._animation=new an({onStart:()=>{this.onStart()},onTime:t=>{this.onTime(t)},onEnd:()=>{this.onEnd()},onStop:()=>{this.onStop()},duration:n}),this._parent=i,this._duration=n}onStart(){const t=this._parent;t.emit("transformstart",this._owner,t)}onTime(t){const e=1-t,i=t,s=this._oldScaleX*e+this._newScaleX*i,n=this._oldScaleY*e+this._newScaleY*i,o=this._oldX*e+this._newX*i,r=this._oldY*e+this._newY*i,a=this._toTarget(this._owner);null!=a&&this._constraint(a,o,r,s,n)}onEnd(){const t=this._parent;t.emit("transformend",this._owner,t)}onStop(){const t=this._parent;t.emit("transformstop",this._owner,t)}start(t,e,i,s,n,o,r){const a=this._parent;if(!1!==r&&a.stop(),null==o&&(o=this._duration),o<=0)this.onStart(),this._constraint(t,e,i,s,n),this.onEnd();else{const r=t.position,a=t.scale;this._oldX=r.x,this._oldY=r.y,this._oldScaleX=a.x,this._oldScaleY=a.y,this._newX=e,this._newY=i,this._newScaleX=s,this._newScaleY=n,this._animation.duration=o,this._animation.start()}}stop(){this._animation.stop()}}class oo extends t.utils.EventEmitter{constructor(e,i,s){var n,o,r,a,h,l,c,u,d,p,_,g,f,m,v,T,w;super(),this._parent=e,this._toTarget=i,this._constraint=s&&s.constraint||oo.CONSTRAINT,this._workRect=new t.Rectangle;const E=this.toTheme(s)||this.getThemeDefault(),y=null==s?void 0:s.zoom;this._zoomPoint=new t.Point,this._zoomMin=null!==(n=null==y?void 0:y.min)&&void 0!==n?n:E.getZoomMin(),this._zoomMax=null!==(o=null==y?void 0:y.max)&&void 0!==o?o:E.getZoomMax(),this._zoomKeepRatio=null!==(r=null==y?void 0:y.keepRatio)&&void 0!==r?r:E.getZoomKeepRatio();const x=null==y?void 0:y.wheel;this._isWheelZoomEnabled=null!==(a=null==x?void 0:x.enable)&&void 0!==a?a:E.isWheelZoomEnabled(),this._wheelZoomSpeed=null!==(h=null==x?void 0:x.speed)&&void 0!==h?h:E.getWheelZoomSpeed(),this._wheelZoomModifier=Qi(null!==(l=null==x?void 0:x.modifier)&&void 0!==l?l:E.getWheelZoomModifier(),en),this._wheelZoomChecker=null!==(c=null==x?void 0:x.checker)&&void 0!==c?c:sn.match;const C=null==y?void 0:y.dblclick;this._isDblClickZoomEnabled=null!==(u=null==C?void 0:C.enable)&&void 0!==u?u:E.isDblClickZoomEnabled(),this._dblClickZoomSpeed=null!==(d=null==C?void 0:C.amount)&&void 0!==d?d:E.getDblClickZoomSpeed(),this._dblClickZoomModifier=Qi(null!==(p=null==C?void 0:C.modifier)&&void 0!==p?p:E.getDblClickZoomModifier(),en),this._dblClickZoomChecker=null!==(_=null==C?void 0:C.checker)&&void 0!==_?_:sn.match,this._dblclickZoomDuration=null!==(g=null==C?void 0:C.duration)&&void 0!==g?g:E.getDblClickZoomDuration();const D=null===(f=null==s?void 0:s.translation)||void 0===f?void 0:f.wheel;if(this._isWheelTranslationEnabled=null!==(m=null==D?void 0:D.enable)&&void 0!==m?m:E.isWheelTranslationEnabled(),this._wheelTranslationSpeed=null!==(v=null==D?void 0:D.speed)&&void 0!==v?v:E.getWheelTranslationSpeed(),this._wheelTranslationModifier=Qi(null!==(T=null==D?void 0:D.modifier)&&void 0!==T?T:E.getWheelTranslationModifier(),en),this._wheelTranslationChecker=null!==(w=null==D?void 0:D.checker)&&void 0!==w?w:sn.match,this._gesture=new so(e,i,this,this._constraint,E,null==s?void 0:s.gesture),this._transform=new no(e,i,this,this._constraint,this._dblclickZoomDuration),null!=s){const t=s.on;if(null!=t)for(const e in t){const i=t[e];i&&this.on(e,i)}}}get gesture(){return this._gesture}stop(){this._gesture.stop(),this._transform.stop()}reset(t,e){const i=this._parent,s=this._toTarget(i);if(s){const n=i.padding,o=n.getLeft(),r=n.getTop(),a=n.getRight(),h=n.getBottom(),l=i.width-o-a,c=i.height-r-h,u=s.getLocalBounds(this._workRect),d=u.x,p=u.y,_=o+.5*(l-u.width)-d,g=r+.5*(c-u.height)-p;this._transform.start(s,_,g,1,1,t,e)}}fit(t,e){const i=this._parent,s=this._toTarget(i);if(s){const n=i.padding,o=n.getLeft(),r=n.getTop(),a=n.getRight(),h=n.getBottom(),l=i.width-o-a,c=i.height-r-h,u=s.getLocalBounds(this._workRect),d=u.x,p=u.y,_=u.width,g=u.height;let f=l/_,m=c/g;if(this._zoomKeepRatio){const t=this.toNormalizedScale(Math.min(f,m));f=t,m=t}else f=this.toNormalizedScale(f),m=this.toNormalizedScale(m);const v=o+.5*(l-_*f)-d*f,T=r+.5*(c-g*m)-p*m;this._transform.start(s,v,T,f,m,t,e)}}zoomIn(t,e){const i=this._toTarget(this._parent);if(i){const s=this._dblClickZoomSpeed,n=i.scale;this.zoom(n.x*s,n.y*s,t,e)}}zoomOut(t,e){const i=this._toTarget(this._parent);if(i){const s=1/this._dblClickZoomSpeed,n=i.scale;this.zoom(n.x*s,n.y*s,t,e)}}zoomAt(t,e,i,s,n,o){const r=this._toTarget(this._parent);if(r){const a=r.scale.x,h=r.scale.y,l=this.toNormalizedScale(i),c=this.toNormalizedScale(s),u=l/a,d=c/h,p=(r.position.x-t)*u+t,_=(r.position.y-e)*d+e;this._transform.start(r,p,_,l,c,n,o)}}zoomAtGlobal(t,e,i,s,n,o){const r=this._zoomPoint;r.set(t,e),this.toLocal(r,r),this.zoomAt(r.x,r.y,i,s,n,o)}zoom(t,e,i,s){const n=this._parent;this.zoomAt(.5*n.width,.5*n.height,t,e,i,s)}get scale(){const e=this._toTarget(this._parent);return e?e.scale:new t.Point(1,1)}set scale(t){const e=this._toTarget(this._parent);if(e){const i=this.toNormalizedScale(t.x),s=this.toNormalizedScale(t.y),n=e.position;this._constraint(e,n.x,n.y,i,s)}}moveTo(t,e,i,s){const n=this._toTarget(this._parent);if(n){const o=n.scale;this._transform.start(n,t,e,o.x,o.y,i,s)}}get position(){const e=this._toTarget(this._parent);return e?e.position:new t.Point(0,0)}set position(t){const e=this._toTarget(this._parent);if(e){const i=e.scale;this._constraint(e,t.x,t.y,i.x,i.y)}}transform(t,e,i,s,n,o){const r=this._toTarget(this._parent);r&&this._transform.start(r,t,e,i,s,n,o)}toLocal(t,e,i){return this._parent.toLocal(t,void 0,e,i)}toGlobal(t,e,i){return this._parent.toGlobal(t,e,i)}toNormalizedScale(t){return Math.min(this._zoomMax,Math.max(this._zoomMin,t))}onWheel(t,e,i){if(this._isWheelZoomEnabled&&this._wheelZoomChecker(t,this._wheelZoomModifier,this._parent)&&0!==e.deltaY){const t=this._toTarget(this._parent);if(t){const s=e.lowest*this._wheelZoomSpeed,n=1+e.deltaY*s,o=t.scale;return this.zoomAtGlobal(i.x,i.y,o.x*n,o.y*n,0),!0}}if(this._isWheelTranslationEnabled&&this._wheelTranslationChecker(t,this._wheelTranslationModifier,this._parent)){const t=this._toTarget(this._parent);if(t){this.stop(),this.emit("wheeltranslationstart",this._parent,this);const i=e.lowest*this._wheelTranslationSpeed,s=t.position,n=s.x-e.deltaX*i,o=s.y+e.deltaY*i,r=t.scale;return this._constraint(t,n,o,r.x,r.y),this.emit("wheeltranslationend",this._parent,this),!0}}return!1}onDown(t){this._gesture.onDown(t)}onDblClick(t,e){if(this._isDblClickZoomEnabled&&this._dblClickZoomChecker(t,this._dblClickZoomModifier,this._parent)){const i=this._toTarget(this._parent);if(i){const s=this._zoomPoint;nn.toGlobal(t,e,s);const n=this._dblClickZoomSpeed,o=i.scale;return this.zoomAtGlobal(s.x,s.y,o.x*n,o.y*n,this._dblclickZoomDuration),!0}}return!1}toTheme(t){if(t&&t.theme){const e=t.theme;return Et(e)?$.getInstance().get(e):e}return null}getThemeDefault(){return $.getInstance().get(this.getType())}getType(){return"DView"}}oo.CONSTRAINT=(t,e,i,s,n)=>{t.scale.set(s,n),t.position.set(e,i)};class ro extends to{init(t){var e;super.init(t),this._canvas=null;const i=this.theme;this._view=new oo(this,()=>this._canvas,null==t?void 0:t.view);const s=null==t?void 0:t.canvas;s&&(this.canvas=s),(null!==(e=null==t?void 0:t.mask)&&void 0!==e?e:i.isOverflowMaskEnabled())&&(this.mask=this.getOverflowMask())}getType(){return"DCanvasContainer"}onResize(t,e,i,s){super.onResize(t,e,i,s),this.updateContentSize(t,e,i,s)}get canvas(){return this._canvas}set canvas(t){const e=this._canvas;null!=e&&(this._canvas=null,this.removeChild(e),this.emit("unset",e,this),e.destroy()),this._canvas=t,null!=t?(this.addChild(t),this._view.reset(0),this.emit("set",t,this)):ot.update(this)}getOverflowMask(){return null==this._overflowMask&&(this._overflowMask=new eo(this),this._reflowable.add(this._overflowMask),this.toDirty()),this._overflowMask}updateContentSize(t,e,i,s){const n=this._canvas;if(null!=n){const o=n.x+.5*(t-i),r=n.y+.5*(e-s);n.position.set(o,r)}}get view(){return this._view}onWheel(t,e,i){const s=this._view.onWheel(t,e,i),n=super.onWheel(t,e,i);return s||n}onDblClick(t,e,i){if(!0!==i){const i=this._view.onDblClick(t,e),s=super.onDblClick(t,e);return i||s}return super.onDblClick(t,e)}onDown(t,e){!0!==e&&this._view.onDown(t),super.onDown(t)}destroy(){const t=this._overflowMask;null!=t&&(this._overflowMask=null,t.destroy()),this.mask=null,super.destroy()}}class ao{constructor(t,e){const i=document.createElement("canvas");this._element=i;const s=this._element.getContext("2d",{willReadFrequently:!0});this._context=s,i.width=t,i.height=e}get element(){const t=this._element;if(null!=t)return t;throw new Error("No Element Available")}getElement(){return this._element}get canvas(){return this.element}get context(){const t=this._context;if(null!=t)return t;throw new Error("No Context Available")}getContext(){return this._context}get resolution(){return 1}get width(){const t=this._element;return null!=t?t.width:0}set width(t){const e=this._element;null!=e&&(e.width=t)}get height(){const t=this._element;return null!=t?t.height:0}set height(t){const e=this._element;null!=e&&(e.height=t)}clear(){const t=this._element,e=this._context;null!=t&&null!=e&&(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height))}resize(t,e){const i=this._element;null!=i&&(i.width=t,i.height=e)}destroy(){this._context=null,this._element=null}}class ho{static toTexture(e,i,s,n){const o=e.transform.scale,r=Math.max(1,Math.ceil(e.width*o.x)),a=Math.max(1,Math.ceil(e.height*o.y)),h=t.RenderTexture.create({width:r,height:a,scaleMode:t.SCALE_MODES.LINEAR,resolution:i}),l=new t.Matrix(void 0,void 0,void 0,void 0,-e.position.x,-e.position.y),c=ot.getLayer(e);return c&&c.renderer.render(e,h,s,l,n),h}static toPixels(t,e){const i=t.baseTexture,s=i.realWidth,n=i.realHeight,o=t.resolution,r=t.frame,a=Math.floor(r.x*o),h=Math.floor(r.y*o),l=Math.floor((r.x+r.width)*o),c=Math.floor((r.y+r.height)*o),u=Math.min(l-a,s),d=Math.min(c-h,n),p=new Uint8Array(4*u*d);if(0<u&&0<d){const i=e.renderTexture.current;e.renderTexture.bind(t);const s=e.gl;s.readPixels(a,h,u,d,s.RGBA,s.UNSIGNED_BYTE,p),e.renderTexture.bind(i)}return{width:u,height:d,array:p}}static toCanvas(e,i,s,n){const o=e.width,r=e.height,a=e.array;if(null==n?n=new ao(o,r):n.resize(o,r),o<=0||r<=0)return n;const h=n.getContext(),l=n.getElement();if(null==h||null==l)return n;const c=h.getImageData(0,0,o,r);if(s?c.data.set(a):t.Extract.arrayPostDivide(a,c.data),h.putImageData(c,0,0),null!=i&&1!==i){h.scale(i,i),h.drawImage(l,0,0);const t=Math.floor(o*i),e=Math.floor(r*i),s=h.getImageData(0,0,t,e);n.resize(t,e),h.putImageData(s,0,0)}return n}static toBase64(t,e,i){return t.toDataURL(e,i)}}class lo{static downloadUrl(t,e){const i=document.createElement("a");"download"in i?(i.href=e,i.setAttribute("download",t),i.style.display="none",document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i)},66)):window.open(e)||(location.href=e)}static download(t,e,i){const s=new Blob(!1!==i?["\ufeff",e]:[e],{type:"text/plain"}),n=window.navigator;"msSaveBlob"in n?n.msSaveBlob(s,t):this.downloadUrl(t,URL.createObjectURL(s))}}const co=t=>{var e;const i=t.target,s=t.resolution;if(null!=s){if(wt(s))return s;{const t=i.transform.scale,e=Math.max(i.width*t.x,i.height*t.y);return Math.min(1,s.size/e)}}return null!==(e=window.devicePixelRatio)&&void 0!==e?e:1},uo=(t,e)=>{const i=e.scale;if(null!=i){if(wt(i))return i;{const e=i.size;return Math.min(1,e/t.width,e/t.height)}}};class po{static texture(t){var e;const i=t.target,s=co(t),n=null===(e=t.transform)||void 0===e?void 0:e.update;return ho.toTexture(i,s,t.clear,n)}static pixels(e){var i;const s=(t=>{const e=t.renderer;if(e)return e;const i=t.application;if(i)return i.getLayerBase().renderer;const s=t.layer||ot.getLayer(t.target);if(s)return s.renderer;throw new Error("No renderer / application / layer found.")})(e),n=e.target,o=n.transform.scale,r=Math.ceil(n.width*o.x),a=Math.ceil(n.height*o.y);if(r<=0||a<=0)return{width:r,height:a,array:new Uint8Array(0)};const h=co(e);let l=po.WORK_RENDER_TEXTURE;if(null==l)l=t.RenderTexture.create({width:r,height:a,scaleMode:t.SCALE_MODES.LINEAR,resolution:h}),po.WORK_RENDER_TEXTURE=l;else{const t=l.baseTexture,e=t.width,i=t.height,s=e<r,n=i<a,o=l.resolution!==h;(o||s||n)&&(o&&(t.resolution=h),l.resize(Math.max(r,e),Math.max(a,i),!0))}const c=l.frame;0===c.x&&0===c.y&&c.width===r&&c.height===a||(c.x=0,c.y=0,c.width=r,c.height=a,l.frame=c);const u=n.position,d=new t.Matrix(1,0,0,1,-u.x,-u.y);return s.render(n,l,e.clear,d,null===(i=e.transform)||void 0===i?void 0:i.update),ho.toPixels(l,s)}static canvas(t){var e,i;const s=this.pixels(t),n=null===(i=null===(e=t.alpha)||void 0===e?void 0:e.premultiplied)||void 0===i?void 0:i.ignore,o=uo(s,t);return ho.toCanvas(s,o,n)}static base64(t){var e,i,s;const n=this.pixels(t),o=null===(i=null===(e=t.alpha)||void 0===e?void 0:e.premultiplied)||void 0===i?void 0:i.ignore,r=uo(n,t),a=null!==(s=this.WORK_CANVAS)&&void 0!==s?s:this.WORK_CANVAS=new ao(n.width,n.height);ho.toCanvas(n,r,o,a);const h=a.getElement();return null!=h?ho.toBase64(h,t.format,t.quality):"data:,"}static file(t){lo.downloadUrl(t.filename,this.base64(t))}static destroy(){const t=this.WORK_RENDER_TEXTURE;null!=t&&(this.WORK_RENDER_TEXTURE=void 0,t.destroy(!0));const e=this.WORK_CANVAS;null!=e&&(this.WORK_CANVAS=void 0,e.destroy())}}class _o extends t.utils.EventEmitter{constructor(t,e){super(),this._parent=t;const i=null==e?void 0:e.on;if(i)for(const t in i){const e=i[t];e&&this.on(t,e)}}createAsUrl(t){return null==t||wt(t)?this.create({size:t,extractor:t=>po.base64({target:t})}):this.create({size:t.size,cleanup:t.cleanup,extractor:t=>po.base64({target:t})})}createAsFile(t,e){Et(t)?this.create({extractor:e=>{po.file({target:e,filename:t})}}):null===t||wt(t)?this.create({size:t,extractor:t=>{po.file({target:t,filename:e})}}):this.create({size:t.size,cleanup:t.cleanup,extractor:e=>{po.file({target:e,filename:t.filename})}})}toScale(t,e){return null==t?1:t/ot.getResolution(e)/Math.max(e.width,e.height)}toCleanupSnap(t){if(null==t)return!0;const e=t.cleanup;return null==e||!0===e||!1!==e&&!1!==e.snap}toCleanupBackground(t){if(null==t)return!1;const e=t.cleanup;return null!=e&&!1!==e&&(!0===e||!0===e.background)}toCleanupReflow(t){if(null==t)return!0;const e=t.cleanup;return null==e||!0===e||!1!==e&&!1!==e.reflow}create(t){const e=this._parent,i=e.canvas;if(i){const s=e.view,n=s.position,o=s.scale,r=n.x,a=n.y,h=o.x,l=o.y,c=this.toScale(t.size,i);let u,d;if(s.transform(0,0,c,c,0),this.toCleanupSnap(t)&&"snap"in i){const t=i.snap;null!=t&&(u=t.container,u.renderable?u.renderable=!1:u=void 0)}if(this.toCleanupBackground(t)&&(d=i.snippet,d.renderable?d.renderable=!1:d=void 0),this.toCleanupReflow(t)){const t=ot.getLayer(i);t&&t.reflow()}this.emit("taking",i,this);const p=t.extractor(i);return this.emit("took",i,null,this),d&&(d.renderable=!0),null!=u&&(u.renderable=!0),s.transform(r,a,h,l,0),p}}}class go extends ro{constructor(t){var e;super(t),this._serialized=null,this._tileFactory=null==t?void 0:t.tile,this._controller=null==t?void 0:t.controller,this._isAmbient=null!==(e=null==t?void 0:t.ambient)&&void 0!==e?e:this.theme.isAmbient(),this._snapshot=new _o(this,null==t?void 0:t.snapshot),this._mode=this.toMode(t)}get snapshot(){return this._snapshot}get controller(){return this._controller||null}set(t){const e=this._serialized;if(e!==t){if(e&&(this._serialized=null,this.canvas&&(this.canvas=null),this.onUnset()),this._serialized=t,t){const e=this.newCanvas(t),i=t.pieces,s=this._mode,n=En.toPieceData(this._controller,i,s).then(n=>this.newLayer(t,e,s,i,n));return this.onSet(t,e),this.canvas=e,n}return Promise.resolve(null)}return Promise.resolve(this.canvas)}onSet(t,e){}newLayer(t,e,i,s,n){const o=new ki(t,s,n,i,0),r=En.newLayer(t,e.layer,o).then(t=>this.initLayer(e,t));if(this._isAmbient){const e=this.toCanvasBaseBackgroundOptions(t,this.theme,!1);this.background.color=e.color,this.background.alpha=e.alpha}return r}initLayer(t,e,i){return t.layer.init(),t.initialize(e,i),ot.update(this),this.emit("ready",this),t}toCanvasBaseOptions(t){var e;const i=this.theme,s=this._isAmbient;return{name:t.name,label:t.label,width:t.width,height:t.height,category:t.category,summary:t.summary,description:t.description,background:this.toCanvasBaseBackgroundOptions(t,i,s),border:s?{color:null}:void 0,outline:s?{color:null}:void 0,shadow:s?null:i.getCanvasShadow(),tile:{factory:this._tileFactory,mapping:null===(e=t.tile)||void 0===e?void 0:e.mapping},ambient:s}}toCanvasBaseBackgroundOptions(t,e,i){var s,n;if(i)return{color:null};const o=t.background;return{color:null!==(s=null==o?void 0:o.color)&&void 0!==s?s:e.getCanvasBackgroundColor(),alpha:null!==(n=null==o?void 0:o.alpha)&&void 0!==n?n:e.getCanvasBackgroundAlpha()}}onUnset(){}get(){return this._serialized}get layer(){const t=this.canvas;return t?t.layer.active:null}getType(){return"DDiagramBase"}}class fo extends to{getType(){return"DCanvas"}}class mo{constructor(t,e){this._target=t,this._base=e}getTheme(){return this._target.getTheme()}setTheme(t){this._target.setTheme(t)}getBaseColor(){return this._base}setBaseColor(t){this._base=t}getColor(t){const e=this._target,i=this._base,s=e.getColor(t);return null!=i?null!=s?de.blend(i,s,e.getAlpha(t)):i:s}get color(){return this._target.color}set color(t){this._target.color=t}getAlpha(t){return null!=this._base?1:this._target.getAlpha(t)}get alpha(){return this._target.alpha}set alpha(t){this._target.alpha=t}}class vo extends t.ObservablePoint{get lon(){return this.x}set lon(t){this.x=t}get lat(){return this.y}set lat(t){this.y=t}toObject(){return{lon:this.x,lat:this.y}}}class To{constructor(t,e,i,s,n,o){if(this._cb=t,!0===e||!1===e)this._enable=e,this._from=new vo(t,null,i,s),this._to=new vo(t,null,n,o);else if(null!=e){this._enable=e.enable;const i=e.from,s=e.to;this._from=new vo(t,null,i.lon,i.lat),this._to=new vo(t,null,s.lon,s.lat)}else this._enable=!1,this._from=new vo(t,null,-180,85.05112877980659),this._to=new vo(t,null,180,-85.05112877980659)}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._cb())}get from(){return this._from}get to(){return this._to}serialize(){return{enable:this._enable,from:this._from.toObject(),to:this._to.toObject()}}}class wo{constructor(t,e){this._canvas=t,this._factory=null==e?void 0:e.factory,this._mapping=new To(()=>{this.onMappingChange()},null==e?void 0:e.mapping)}init(){this.onMappingChange()}onMappingChange(){const t=this._factory;if(t){const e=this._mapping;if(e.enable){const i=this._pyramid;i?i.mapping=e:this._pyramid=t(this._canvas).fit()}else{const t=this._pyramid;t&&(this._pyramid=void 0,t.destroy())}}}get pyramid(){return this._pyramid}get factory(){return this._factory}get mapping(){return this._mapping}serialize(){return{mapping:this._mapping.serialize()}}destroy(){const t=this._pyramid;null!=t&&(this._pyramid=void 0,t.destroy())}}class Eo{constructor(t){const e=t.transform,i=e.position;this.x=i.x,this.y=i.y;const s=t.size;this.sizeX=s.x,this.sizeY=s.y,this.rotation=e.rotation,this.actions=[],this.fill=t.fill.toObject(),this.stroke=t.stroke.toObject(),this.text=t.text.toObject(),this.cursor=t.cursor,this.reset=pe.NONE,this.written=pe.NONE,this.effect=-1,this.isStateChanged=!1,this.interactive=!1}initialize(t){t.lock(Mt.UPLOADED);const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].initialize(t,this);t.unlock(Mt.UPLOADED,!0)}isActionable(){return 0<this.actions.length}onResize(t){const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].onResize(t,this)}onClick(t,e){const i=t.state;i.isActionable&&(i.isClicked=!0);const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onClick(t,this,e)}onDblClick(t,e,i){const s=t.state;s.isActionable&&(s.isDblClicked=!0);const n=this.actions;for(let s=0,o=n.length;s<o;++s)n[s].onDblClick(t,this,e,i);return!1}onOver(t,e){const i=t.state;if(!i.isHovered){i.isHovered=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onOver(t,this,e)}}onOut(t,e){if(t.state.isHovered){t.state.isHovered=!1;const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onOut(t,this,e)}}onDown(t,e){const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onDowning(t,this,e);const s=t.state;if(!s.isDown)if(s.isPressed){s.isDown=!0;const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s)i[s].onDown(t,this,e)}else{s.addAll(Ct.DOWN,lt.PRESSED);const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s){const n=i[s];n.onDown(t,this,e),n.onPressed(t,this,e)}}}onUp(t,e){const i=t.state;if(!i.isUp)if(i.isPressed){i.set(Ct.UP,lt.PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onUp(t,this,e),n.onUnpressed(t,this,e)}}else{i.isUp=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onUp(t,this,e)}}onUpOutside(t,e){const i=t.state;if(i.isPressed){i.set(Ct.UP_OUTSIDE,lt.PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onUpOutside(t,this,e),n.onUnpressed(t,this,e)}}else{i.isUpOutside=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onUpOutside(t,this,e)}}onMove(t,e){const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onMove(t,this,e)}onKeyDown(t,e){$n.isActivateKey(e)&&this.onDown(t,e);const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onKeyDown(t,this,e);return!1}onKeyUp(t,e){if($n.isActivateKey(e)){const i=t.state;if(i.isPressed){const s=i.isUp;this.onUp(t,e),!s&&i.isUp&&this.onClick(t,e)}}const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onKeyUp(t,this,e);return!1}onStateChange(t,e,i){this.isStateChanged=!0,ot.update(t),e.isFocused?i.isFocused||this.onFocus(t):i.isFocused&&this.onBlur(t)}onFocus(t){const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].onFocus(t,this)}onBlur(t){const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].onBlur(t,this)}onRightClick(t,e){const i=t.state;i.isActionable&&(i.isRightClicked=!0);const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onRightClick(t,this,e)}onRightDown(t,e){const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onRightDowning(t,this,e);const s=t.state;if(!s.isRightDown)if(s.isRightPressed){s.addAll(Ct.RIGHT_DOWN,Ct.RIGHT_PRESSED);const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s){const n=i[s];n.onRightDown(t,this,e),n.onRightPressed(t,this,e)}}else{s.isRightDown=!1;const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s)i[s].onRightDown(t,this,e)}}onRightUp(t,e){const i=t.state;if(!i.isRightUp)if(i.isRightPressed){i.set(Ct.RIGHT_UP,Ct.RIGHT_PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onRightUp(t,this,e),n.onRightUnpressed(t,this,e)}}else{i.isRightUp=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onRightUp(t,this,e)}}onRightUpOutside(t,e){const i=t.state;if(i.isRightPressed){i.set(Ct.RIGHT_UP_OUTSIDE,Ct.RIGHT_PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onRightUpOutside(t,this,e),n.onRightUnpressed(t,this,e)}}else{i.isRightUpOutside=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onRightUpOutside(t,this,e)}}update(t,e){const i=t.data,s=this.effect,n=0<=s&&s<=e;if(i.isChanged||this.isStateChanged||n){this.isStateChanged=!1,i.isChanged=!1,n&&(this.effect=-1),t.lock(Mt.UPLOADED),this.onUpdate(t,e),t.unlock(Mt.UPLOADED,!0);const s=this.isStateChanged;t.state.removeAll(Eo.TRANSIENT_STATES),this.isStateChanged=s}}onRender(t,e,i){const s=this.actions;for(let n=0,o=s.length;n<o;++n)s[n].onRender(t,this,e,i);this.update(t,e)}onUpdate(t,e){const i=this.actions;if(0<i.length){this.written=pe.NONE;for(let s=0,n=i.length;s<n;++s)i[s].execute(t,this,e);this.doReset(t)}}doReset(t){const e=~this.written&this.reset;if(e!==pe.NONE){if(e&pe.POSITION_X&&(t.transform.position.x=this.x),e&pe.POSITION_Y&&(t.transform.position.y=this.y),e&pe.VISIBILITY&&(t.visible=!0),e&pe.COLOR_FILL){const e=this.fill;t.fill.set(void 0,e.color,e.alpha)}if(e&pe.COLOR_STROKE){const e=this.stroke;t.stroke.set(void 0,e.color,e.alpha)}if(e&pe.COLOR_TEXT){const e=this.text;t.text.set(void 0,e.color,e.alpha)}if(e&pe.COLOR_TEXT_OUTLINE){const e=this.text.outline;t.text.outline.set(void 0,e.color,e.alpha)}e&pe.HEIGHT&&(t.size.y=this.sizeY),e&pe.WIDTH&&(t.size.x=this.sizeX),e&pe.ROTATION&&(t.transform.rotation=this.rotation),e&pe.TEXT&&(t.text.value=this.text.value),e&pe.CURSOR&&(t.cursor=this.cursor)}}}Eo.TRANSIENT_STATES=[Ct.CLICKED,Ct.DBL_CLICKED,Ct.DOWN,Ct.UP,Ct.UP_OUTSIDE,Ct.RIGHT_CLICKED,Ct.RIGHT_DOWN,Ct.RIGHT_UP,Ct.RIGHT_UP_OUTSIDE,Ct.ACTIVATED,Ct.DEACTIVATED];class yo extends te{constructor(t=s.RECTANGLE){super(t)}clone(){return new yo(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&ie(this,t,e,i,s,n,o)}}class xo extends yo{constructor(t=s.RECTANGLE_PIVOTED){super(t)}toHitTestData(t,e){const i=super.toHitTestData(t,e);return i.x-=i.width,i.y-=i.height,i}}class Co extends Js{constructor(t){super(),this.name=t,this.interactive=!1,this.reference=0;const e=this.newShape();e.parent=this,this._shape=e,this.interactives=[]}get width(){return this._shape.size.x}set width(t){this._shape.size.x=t}get height(){return this._shape.size.y}set height(t){this._shape.size.y=t}get background(){return this._shape.fill}get state(){return this._shape.state}newShape(){const t=new xo;return t.fill.set(!1,16777215,1),t.stroke.set(!1),t.state.add(vn.INTERACTIVE),t}initialize(t){const e=this.interactives,i=this._shape,s=i.state.is(vn.INTERACTIVE),n=i.state.is(vn.DRAGGABLE),o=i.state.is(vn.PINCHABLE);if(n||o){const e=new Eo(i);i.runtime=e;const s=(n?dn.DRAG:dn.NONE)|(o?dn.PINCH:dn.NONE);e.actions.push(new mn("",gn.LAYER,s).toRuntime()),t.push(i),e.initialize(i)}(s||n||o)&&(i.interactive=!0,e.push(i)),this.doInitialize(this.children,e)}doInitialize(t,e){for(let i=0,s=t.length;i<s;++i){const s=t[i],n=s.runtime;if(n)if(s.interactive||n.interactive)e.push(s);else{const t=s.cursor;null!=t&&0<t.length&&e.push(s)}const o=s.children;0<o.length&&this.doInitialize(o,e)}}update(t){this.doUpdate(this.children,t)}doUpdate(t,e){for(let i=0,s=t.length;i<s;++i){const s=t[i];s.update(e);const n=s.children;0<n.length&&this.doUpdate(n,e)}}hitTestInteractives(t){const e=this._work,i=this.interactives;for(let s=i.length-1;0<=s;--s){const n=i[s];if(n.visible&&(n.toLocal(t,void 0,e),null!=n.contains(e.x,e.y)))return n}return null}addUuid(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].addUuid(t)}updateUuid(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].updateUuid(t)}destroy(){if(!this._destroyed){const t=this.children;for(let e=t.length-1;0<=e;--e)t[e].destroy();t.length=0,super.destroy()}}serialize(t,e,i){const s=this.children;for(let n=0,o=s.length;n<o;++n){const o=s[n].serialize(e);o[16]=t,i.push(o)}const n=this._shape,o=e.addResource(this.name||""),r=(this.visible?1:0)|(n.state.is(vn.INVISIBLE)?0:2),a=this.position,h=n.size,l=n.fill.serialize(e),c=n.state.is(vn.INTERACTIVE)?1:0,u=n.state.is(vn.DRAGGABLE)?2:0,d=n.state.is(vn.PINCHABLE)?4:0;return[o,r,a.x,a.y,h.x,h.y,l,c|u|d]}static deserialize(t,e,i,s){var n,o,r;const a=new Co(this.deserializeName(t[0],e)),h=a._shape,l=t[1];if(null!=l){const t=e.mode!==Li.VIEWER;!t||1&l||(a.visible=!1),2&l||(h.state.add(vn.INVISIBLE),t||(a.visible=!1))}const c=t[2],u=t[3];a.position.set(c,u);const d=null!==(n=t[4])&&void 0!==n?n:i,p=null!==(o=t[5])&&void 0!==o?o:s;h.size.set(d,p);const _=t[6];null!=_&&h.fill.deserialize(_,e);const g=null!==(r=t[7])&&void 0!==r?r:1;return h.state.set(vn.INTERACTIVE,!!(1&g)),h.state.set(vn.DRAGGABLE,!!(2&g)),h.state.set(vn.PINCHABLE,!!(4&g)),a}static deserializeName(t,e){if(Et(t))return t;{const i=e.resources;return 0<=t&&t<=i.length?i[t]:""}}}class Do extends t.Container{constructor(t,e){super(),this._active=null,this._width=t,this._height=e,this.interactive=!1,this.interactiveChildren=!1}init(){if(null==this._active){const t=this.children,e=t.length;0<e&&(this._active=t[e-1])}}get active(){return this._active}set active(t){this._active!==t&&(null==t||0<=this.children.indexOf(t))&&(this._active=t,this.onLayerChange())}create(t,e){const i=new Co(t);return this.attach(i,e),i}attach(t,e){this.addChild(t),!0===e&&(this._active=t),this.onLayerChange(),ot.update(this)}attachAt(t,e,i){this.addChildAt(t,e),!0===i&&(this._active=t),this.onLayerChange(),ot.update(this)}detach(t,e){const i=this.children,s=i.indexOf(t);0<=s&&(this._active=e,i.splice(s,1),t.parent=void 0,this.onLayerChange(),ot.update(this))}delete(t,e){const i=this.children,s=i.indexOf(t);return 0<=s&&(i.splice(s,1),t.parent=void 0,this._active===t&&(!0===e?s<i.length?this._active=i[s]:0<i.length?this._active=i[s-1]:this._active=null:this._active=null),this.onLayerChange(),ot.update(this)),s}get(t){const e=this.children[t];return null!=e?e:null}clear(){const t=this.children;if(0<t.length){for(let e=t.length-1;0<=e;--e){const i=t[e];i.parent=null,i.destroy()}t.length=0,this.onLayerChange(),ot.update(this)}}destroy(){this._destroyed||(this.clear(),super.destroy())}size(){return this.children.length}onLayerChange(){this.emit("change",this)}serialize(t,e){const i=[],s=this.children;for(let e=0,i=s.length;e<i;++e)s[e].addUuid(t);for(let e=0,i=s.length;e<i;++e)s[e].updateUuid(t);for(let n=0,o=s.length;n<o;++n)i.push(s[n].serialize(n,t,e));return i}deserialize(t,e){const i=t.length;if(0<i){const s=this._width,n=this._height;for(let o=0;o<i;++o)this.addChild(Co.deserialize(t[o],e,s,n));this.onLayerChange(),ot.update(this)}}}class So extends fo{constructor(t){var e,i,s,n;super(t);const o=this.theme;this.isAmbient(o,t)||(this._background=new mo(this._background,this.toBackgroundBase(o,t)));const r=new Do(this.width,this.height);this._layer=r,this.addChild(r),null!=t?(this._label=null!==(e=t.label)&&void 0!==e?e:"",this._category=null!==(i=t.category)&&void 0!==i?i:null,this._summary=null!==(s=t.summary)&&void 0!==s?s:"",this._description=null!==(n=t.description)&&void 0!==n?n:""):(this._label="",this._category=null,this._summary="",this._description="");const a=new wo(this,null==t?void 0:t.tile);this._tile=a,a.init(),this._localBoundsLimit=o.getLocalBoundsLimit()}isAmbient(t,e){var i;return null!==(i=null==e?void 0:e.ambient)&&void 0!==i?i:t.isAmbient()}toBackgroundBase(t,e){var i,s;return null!==(s=null===(i=null==e?void 0:e.background)||void 0===i?void 0:i.base)&&void 0!==s?s:t.getBackgroundBase()}get label(){return this._label}set label(t){this._label=t}get category(){return this._category}set category(t){this._category=t}get summary(){return this._summary}set summary(t){this._summary=t}get description(){return this._description}set description(t){this._description=t}get tile(){return this._tile}get layer(){return this._layer}initialize(t,e){}destroy(){this._destroyed||(this.onDestroy(),super.destroy())}onDestroy(){this._tile.destroy(),this._layer.destroy()}hitTest(t,e){const i=this._layer.children;for(let s=i.length-1;0<=s;--s){const n=i[s];if(n.visible){const i=n.hitTest(t,e);if(null!=i)return i}}return null}getLocalBounds(e){var i,s;null==e&&(e=null!==(i=this._localBoundsRect)&&void 0!==i?i:this._localBoundsRect=new t.Rectangle),e.x=0,e.y=0,e.width=this.width,e.height=this.height;const n=this._localBoundsLimit;if(0===n)return e;const o=this.layer.children,r=o.length,a=null!==(s=So.WORK_LOCAL_BOUNDS)&&void 0!==s?s:So.WORK_LOCAL_BOUNDS=new t.Rectangle;if(0<n){let t=0;for(let i=0;i<r;++i){const s=o[i],n=s.transform.position;a.x=n.x,a.y=n.y,a.width=s.width,a.height=s.height,e.enlarge(a),t+=s.children.length}if(n<t)return e;for(let t=0;t<r;++t){const i=o[t],s=i.transform.position,n=s.x,r=s.y,h=i.children;for(let t=0,i=h.length;t<i;++t)h[t].getBoundsInternal(!0,a),a.x+=n,a.y+=r,e.enlarge(a)}}else for(let t=0;t<r;++t){const i=o[t],s=i.transform.position,n=s.x,r=s.y;a.x=n,a.y=r,a.width=i.width,a.height=i.height,e.enlarge(a);const h=i.children;for(let t=0,i=h.length;t<i;++t)h[t].getBoundsInternal(!0,a),a.x+=n,a.y+=r,e.enlarge(a)}return e}getType(){return"DDiagramCanvasBase"}}const bo={};class Io{get private(){let t=this._private;return null==t&&(t=this.newPrivate(),this._private=t),t}newPrivate(){return new Wt}get protected(){let t=this._protected;return null==t&&(t=this.newProtected(),this._protected=t),t}newProtected(){return new Wt}get extended(){let t=this._extended;return null==t&&(t=this.newExtended(),this._extended=t),t}newExtended(){return new Wt}get ids(){const t=this._data;if(null==t)return[];const e=[];return t.forEach((t,i)=>{e.push(i)}),e}each(t){const e=this._data;if(null==e)return null;let i=null;return e.forEach((e,s)=>{null==i&&!1===t(s)&&(i=s)}),i}add(t,e){var i;const s=null!==(i=this._data)&&void 0!==i?i:this._data=new Map,n=s.get(t);null==n?s.set(t,[e]):n.push(e)}set(t,e,i,s,n,o){const r=this._data;if(null==r)return!1;const a=r.get(t);if(null==a)return!1;const h=a.length;if(h<=0)return!1;for(let t=0;t<h;++t){const r=a[t];r.range.set(n,o),void 0!==i&&(r.time=i),void 0!==s&&(r.state=s),void 0!==e&&(r.value=e)}return!0}get(t){const e=this._data;if(null==e)return null;const i=e.get(t);return null==i?null:i}clear(t){const e=this._data;if(null==e)return!1;const i=e.get(t);if(null==i)return!1;const s=i.length;if(s<=0)return!1;for(let t=0;t<s;++t)i[t].clear();return!0}toDirty(t){const e=this._data;if(null==e)return!1;const i=e.get(t);if(null==i)return!1;const s=i.length;if(s<=0)return!1;for(let t=0;t<s;++t)i[t].toDirty();return!0}setAll(t,e,i,s,n,o){const r=this._data;if(null==r)return!1;const a=r.get(t);if(null==a)return!1;const h=a.length;if(h<=0)return!1;for(let t=0;t<h;++t){const r=a[t];r.range.set(n,o),void 0!==i&&(r.times=i),void 0!==s&&(r.states=s),void 0!==e&&(r.values=e)}return!0}setValue(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].value=e;return!0}setValues(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].values=e;return!0}setTime(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].time=e;return!0}setTimes(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].times=e;return!0}setState(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].state=e;return!0}setStates(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].states=e;return!0}setRange(t,e,i){const s=this._data;if(null==s)return!1;const n=s.get(t);if(null==n)return!1;const o=n.length;if(o<=0)return!1;for(let t=0;t<o;++t){const s=n[t].range;void 0!==e&&(null!==e?(s.type|=Nt.FROM,s.from=e):s.type&=~Nt.FROM),void 0!==i&&(null!==i?(s.type|=Nt.TO,s.to=i):s.type&=~Nt.TO)}return!0}}class Oo{constructor(t){this._canvas=t}each(t,e){const i=this._canvas.layer.children;for(let s=0,n=i.length;s<n&&!1!==this.each_(i[s].children,t,e);++s);return this}each_(t,e,i){for(let s=0,n=t.length;s<n;++s){const n=t[s];if(!1===e(n))return!1;if(i||Ui.contains(n,Ot.CHILDREN)){const t=n.children;if(0<t.length&&!1===this.each_(t,e,i))return!1}}}}class Ao extends Oo{constructor(t){super(t),this._data=new Map}add(t,e){const i=this._data,s=i.get(t);null==s?i.set(t,[e]):s.push(e)}get(t){const e=this._data.get(t);return e&&0<e.length?e[0]:null}getAll(t){return this._data.get(t)||[]}}class Ro{constructor(t,e){this._parent=t,this._values=[],this._interval=e,this._onTimeBound=()=>{this.onTime()}}add(t){this._values.push(t)}start(){null==this._timeoutId&&this.onTime()}getInterval(){const t=Date.now(),e=this._interval;return Math.max(0,e-t%e)}onTime(){const t=this._values;if(0<t.length){const e=Date.now()/this._interval;for(let i=0,s=t.length;i<s;++i)t[i].value=e;ot.update(this._parent)}this._timeoutId=window.setTimeout(this._onTimeBound,this.getInterval())}stop(){const t=this._timeoutId;null!=t&&(clearTimeout(t),this._timeoutId=void 0)}}class Mo{constructor(t){this._parent=t,this._data=new Map}add(t){const e=this._data,i=this.toNormalized(t),s=e.get(i);if(null!=s)return s;const n=new Ro(this._parent,i);return e.set(i,n),n}toNormalized(t){return wt(t)?Math.max(1,Math.round(t)):1e3}start(){this._data.forEach(t=>{t.start()})}stop(){this._data.forEach(t=>{t.stop()})}}class ko{static add(t){var e,i,s;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._idToDatum)&&void 0!==i?i:this._idToDatum=new Map).set(t.id,t),(null!==(s=this._data)&&void 0!==s?s:this._data=[]).push(t)}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static getById(t){const e=this._idToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Lo{static add(t,e){let i=this._typeToRuntimes;null==i&&(i=new Map,this._typeToRuntimes=i);let s=i.get(t);null==s?(s=[e],i.set(t,s)):s.push(e)}static get(t){const e=this._typeToRuntimes;if(null!=e)return e.get(t)}}const No="[]",Po=()=>0,Bo=()=>[],zo=()=>"",Uo=()=>({}),Fo=()=>!1;class Ho extends So{constructor(t){super(t),this._data=new Io,this._shape=new Ao(this),this._ticker=new Mo(this),this._actionables=[],this._downeds=new Set,this._updateBound=()=>{ot.update(this)}}get data(){return this._data}get shape(){return this._shape}get ticker(){return this._ticker}initialize(t,e){const i=this._actionables,s=this._data;this.initialize_(t,null,null,e,new Map,new Map,new Map,this._ticker,this._shape,s,i);const n=this._layer.children,o=n.length;for(let t=0;t<o;++t)n[t].initialize(i);ge.isInitializing=!0;const r=Date.now();for(let t=0;t<o;++t)n[t].update(r);ge.isInitializing=!1,s.extended.each(t=>{const e=ko.getById(t);if(e){const t=e.start;t&&t(this)}}),this._ticker.start()}initialize_(t,e,i,s,n,o,r,a,h,l,c){for(let u=0,d=t.length;u<d;++u){const d=t[u],p=d.id;0<p.length&&h.add(p,d),this.initData(d,e,i,s,n,o,a,l);const _=new(bo[d.type]||Eo)(d);d.runtime=_,this.initActions(d,_,r),_.initialize(d);const g=d.shortcut;null!=g&&$n.on(d,g,t=>{_.onClick(d,t)}),_.isActionable()&&c.push(d);const f=d.children;if(0<f.length){let t=e,u=i;d instanceof Yi&&(null==t&&(t=d),u=d),this.initialize_(f,t,u,s,n,o,r,a,h,l,c)}}}initData(t,e,i,s,n,o,r,a){const h=t.data;for(let l=0,c=h.size();l<c;++l){const c=h.get(l);if(null!=c)switch(c.type){case zt.BOOLEAN:case zt.BOOLEAN_ARRAY:case zt.NUMBER:case zt.NUMBER_ARRAY:case zt.STRING:case zt.STRING_ARRAY:case zt.OBJECT:case zt.OBJECT_ARRAY:this.initDataValue(c,t,e,i,s,n,o,a);break;case zt.TICKER:this.initDataTicker(c,o,r);break;default:this.initDataExtension(c,a)}}}initDataValue(t,e,i,s,n,o,r,a){if(t.scope===Ut.PRIVATE){const e=t.id;0<e.length&&(s?s.data.private.add(e,t):a.private.add(e,t))}else if(t.scope===Ut.PROTECTED){const e=t.id;0<e.length&&a.protected.add(e,t)}else{n&&n(t,i||e);const s=t.id;0<s.length&&a.add(s,t)}const h=t.format,l=t.initial;let c=o.get(t.type);null==c&&(c=new Map,o.set(t.type,c));const u=c.get(h);if(null!=u)t.formatter=u;else if(0<h.length){const e=this.calcFormatter(t,h,l);c.set(h,e),t.formatter=e}let d=r.get(t.type);null==d&&(d=new Map,r.set(t.type,d));const p=d.get(l);if(null!=p)t.value=p();else{const e=this.calcInitial(t,l);d.set(l,e),t.value=e()}}initDataTicker(t,e,i){const s=t.initial;let n=e.get(t.type);null==n&&(n=new Map,e.set(t.type,n));const o=n.get(s);if(void 0!==o)t.value=0,i.add(o()).add(t);else{const e=this.calcInitial(t,s);n.set(s,e),t.value=0,i.add(e()).add(t)}}initDataExtension(t,e){const i=ko.get(t.type);i&&(e.extended.add(i.id,t),t.value=i.initial)}initActions(t,e,i){const s=t.action.values,n=e.actions,o=Lo.get(t.type);if(null!=o)for(let t=0,i=o.length;t<i;++t){const i=o[t];n.push(i),e.reset|=i.reset}for(let t=0,o=s.length;t<o;++t){const o=s[t];let r=i.get(o);null==r?(r=o.toRuntime(),null!=r&&(i.set(o,r),n.push(r),e.reset|=r.reset)):(n.push(r),e.reset|=r.reset)}}calcFormatter(t,e,i){const s=this.toInitial(t);try{return Function("value",`try {return (${e});} catch( e1 ) {try {return (${0<i.length?i:s});} catch( e2 ) {return ${s};}}`)}catch(e){return this.toInitializer(t)}}calcInitial(t,e){if(e.length<=0)return this.toInitializer(t);try{return Function(`try {return (${e});} catch( e ) {return ${this.toInitial(t)};}`)}catch(e){return this.toInitializer(t)}}toInitial(t){switch(t.type){case zt.BOOLEAN:return"false";case zt.BOOLEAN_ARRAY:return No;case zt.NUMBER:return"0";case zt.NUMBER_ARRAY:return No;case zt.STRING:return'""';case zt.STRING_ARRAY:return No;case zt.OBJECT:return"{}";case zt.OBJECT_ARRAY:return No;case zt.TICKER:default:return"0"}}toInitializer(t){switch(t.type){case zt.BOOLEAN:return Fo;case zt.BOOLEAN_ARRAY:return Bo;case zt.NUMBER:return Po;case zt.NUMBER_ARRAY:return Bo;case zt.STRING:return zo;case zt.STRING_ARRAY:return Bo;case zt.OBJECT:return Uo;case zt.OBJECT_ARRAY:return Bo;case zt.TICKER:default:return Po}}onDestroy(){this._data.extended.each(t=>{const e=ko.getById(t);if(e){const t=e.stop;t&&t(this)}}),this._ticker.stop(),super.onDestroy()}hitTestInteractives(t){const e=this._layer.children;for(let i=e.length-1;0<=i;--i){const s=e[i];if(s.visible){const e=s.hitTestInteractives(t);if(null!=e)return e}}return null}onShapeMove(t){const e=this.hitTestInteractives(t.data.global);this.cursor=this._cursor=this.toShapeCursor(e);const i=ot.getLayer(this);if(i){const t=this.toShapeTitle(e),s=i.view;s.title!==t&&(s.title=t)}const s=this._overed;if(this._overed=e,e===s){if(null!=e){const i=e.runtime;i&&i.onMove(e,t)}}else this.onShapeOut(t,s,e),this.onShapeOver(t,e);return null!=e}toShapeCursor(t){if(null!=t){let e=t;for(;;){const t=e.cursor;if(null!=t&&0<t.length)return t;const i=e.parent;if(!(i instanceof kt))break;e=i}}return"auto"}toShapeTitle(t){if(null!=t){let e=t;for(;;){const t=e.title;if(null!=t&&0<t.length)return t;const i=e.parent;if(!(i instanceof kt))break;e=i}}return""}onShapeOut(t,e,i){for(;null!=e&&e!==i&&e instanceof kt;){const i=e.runtime;i&&i.onOut(e,t),e=e.parent}}onShapeOver(t,e,i){for(;null!=e&&e!==i&&e instanceof kt;){const i=e.runtime;i&&i.onOver(e,t),e=e.parent}}onShapeDown(t){const e=this.hitTestInteractives(t.data.global);if(this._downed=e,e){this._downeds.add(e);let i=e;for(;;){const e=i.runtime;e&&e.onDown(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeUp(t){const e=this._downeds,i=this.hitTestInteractives(t.data.global);if(i){e.delete(i);let s=i;for(;;){const e=s.runtime;e&&e.onUp(s,t);const i=s.parent;if(!(i instanceof kt))break;s=i}}return this.onShapeCancel(t),null!=i}onShapeCancel(t){const e=this._downeds;return 0<e.size&&(e.forEach(e=>{let i=e;for(;;){const e=i.runtime;e&&e.onUpOutside(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}}),e.clear(),!0)}onShapeClick(t){const e=this.hitTestInteractives(t.data.global);if(e&&this._downed===e){let i=e;for(;;){const e=i.runtime;e&&e.onClick(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeDblClick(e,i){var s;const n=null!==(s=Ho.WORK_DBLCLICK)&&void 0!==s?s:Ho.WORK_DBLCLICK=new t.Point;nn.toGlobal(e,i,n);const o=this.hitTestInteractives(n);if(o){let t=o;for(;;){const s=t.runtime;s&&s.onDblClick(t,e,i);const n=t.parent;if(!(n instanceof kt))break;t=n}return!0}return!1}onShapeRightClick(t){const e=this.hitTestInteractives(t.data.global);if(e&&this._downed===e){let i=e;for(;;){const e=i.runtime;e&&e.onRightClick(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeRightDown(t){const e=this.hitTestInteractives(t.data.global);if(this._downed=e,e){this._downeds.add(e);let i=e;for(;;){const e=i.runtime;e&&e.onRightDown(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeRightUp(t){const e=this._downeds,i=this.hitTestInteractives(t.data.global);if(i){e.delete(i);let s=i;for(;;){const e=s.runtime;e&&e.onRightUp(s,t);const i=s.parent;if(!(i instanceof kt))break;s=i}}return this.onShapeRightCancel(t),null!=i}onShapeRightCancel(t){const e=this._downeds;return 0<e.size&&(e.forEach(e=>{let i=e;for(;;){const e=i.runtime;e&&e.onRightUpOutside(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}}),e.clear(),!0)}update(){const t=this._actionables;if(0<t.length){let e=-1;const i=Date.now();for(let s=0,n=t.length;s<n;++s){const n=t[s];n.update(i);const o=n.runtime;if(o){const t=o.effect;0<=t&&i<t&&(e=e<0?t:Math.min(e,t))}}0<=e&&window.setTimeout(this._updateBound,e-Date.now())}}onRender(t){const e=this._actionables;if(0<e.length){let i=-1;const s=Date.now();for(let n=0,o=e.length;n<o;++n){const o=e[n];o.onRender(s,t);const r=o.runtime;if(r){const t=r.effect;0<=t&&s<t&&(i=i<0?t:Math.min(i,t))}}0<=i&&window.setTimeout(this._updateBound,i-Date.now())}}getType(){return"DDiagramCanvas"}}class Go extends t.utils.EventEmitter{constructor(t){super(),this._diagram=t,this._updateBound=()=>{ot.update(t)}}update(){const t=this._diagram.canvas;t&&t.update()}get(t){const e=this._diagram.canvas;return e?e.shape.get(t):null}getAll(t){const e=this._diagram.canvas;return e?e.shape.getAll(t):[]}each(t,e=!1){const i=this._diagram.canvas;if(null!=i){const s=i.layer.children;if(e)for(let e=s.length-1;0<=e;--e){const i=s[e].children;for(let e=i.length-1;0<=e;--e){const s=i[e];if(!1===t(s))return s}}else for(let e=0,i=s.length;e<i;++e){const i=s[e].children;for(let e=0,s=i.length;e<s;++e){const s=i[e];if(!1===t(s))return s}}}return null}}class Vo{constructor(t){this._diagram=t}get ids(){const t=this._diagram.canvas;return null!=t?t.data.private.ids:[]}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.private.set(t,e,i,s,n,o)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.private.toDirty(t)}each(t){const e=this._diagram.canvas;return null!=e?e.data.private.each(t):null}}class Wo{constructor(t){this._diagram=t}get ids(){const t=this._diagram.canvas;return null!=t?t.data.protected.ids:[]}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.protected.set(t,e,i,s,n,o)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.protected.toDirty(t)}each(t){const e=this._diagram.canvas;return null!=e?e.data.protected.each(t):null}}class Ko{constructor(t){this._controller=t&&t.controller}set(t,e){const i=this._controller;return!!i&&(i.write(t,e),!0)}}class Xo{constructor(t){this._diagram=t}get ids(){const t=this._diagram.canvas;return null!=t?t.data.extended.ids:[]}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.extended.set(t,e,i,s,n,o)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.extended.toDirty(t)}each(t){const e=this._diagram.canvas;return null!=e?e.data.extended.each(t):null}}class Yo{constructor(t,e){this._diagram=t,this._mapper=e&&e.mapper||null,this._remote=new Ko(e&&e.remote),this._private=new Vo(t),this._protected=new Wo(t),this._extended=new Xo(t)}update(){}get mapper(){return this._mapper}set mapper(t){this._mapper=t}get remote(){return this._remote}get private(){return this._private}get protected(){return this._protected}get extended(){return this._extended}get ids(){const t=this._diagram.canvas;return t?t.data.ids:[]}each(t){const e=this._diagram.canvas;return null!=e?e.data.each(t):null}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.set(t,e,i,s,n,o)}get(t){const e=this._diagram.canvas;return null!=e?e.data.get(t):null}clear(t){const e=this._diagram.canvas;return null!=e&&e.data.clear(t)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.toDirty(t)}setAll(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.setAll(t,e,i,s,n,o)}setValue(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setValue(t,e)}setValues(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setValues(t,e)}setTime(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setTime(t,e)}setTimes(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setTimes(t,e)}setState(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setState(t,e)}setStates(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setStates(t,e)}setRange(t,e,i){const s=this._diagram.canvas;return null!=s&&s.data.setRange(t,e,i)}}class jo extends go{constructor(t){super(t),this.on(nn.move,t=>{this.onShapeMove(t)}),this.on(nn.up,t=>{this.onShapeUp(t)}),this.on(nn.upoutside,t=>{this.onShapeCancel(t)}),this.on(nn.cancel,t=>{this.onShapeCancel(t)}),this.on(nn.tap,t=>{this.onShapeClick(t)}),this.on(nn.righttap,t=>{this.onShapeRightClick(t)}),this.on(nn.rightdown,t=>{this.onShapeRightDown(t)}),this.on(nn.rightup,t=>{this.onShapeRightUp(t)}),this.on(nn.rightupoutside,t=>{this.onShapeRightCancel(t)});const e=new Yo(this,t&&(t.data||t.tag));this.data=e,this.tag=e,this.shape=new Go(this)}initLayer(t,e,i){return super.initLayer(t,e,i||this.data.mapper)}toMode(t){return Li.VIEWER}newCanvas(t){return new Ho(this.toCanvasOptions(t))}toCanvasOptions(t){return this.toCanvasBaseOptions(t)}onDown(t){const e=this.canvas;if(e){const i=t.target;i===this||i===e?super.onDown(t,e.onShapeDown(t)):super.onDown(t)}else super.onDown(t)}onShapeMove(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeMove(t)}}onShapeUp(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeUp(t)}}onShapeCancel(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeCancel(t)}}onShapeClick(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeClick(t)}}onShapeRightClick(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightClick(t)}}onShapeRightDown(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightDown(t)}}onShapeRightUp(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightUp(t)}}onShapeRightCancel(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightCancel(t)}}onDblClick(t,e){const i=this.canvas;return i?super.onDblClick(t,e,i.onShapeDblClick(t,e)):super.onDblClick(t,e)}onPrerender(t){const e=this._canvas;e&&e.onRender(t)}render(t){var e;const i=this._rendererBound;if(i!==t){const s=null!==(e=this._onPrerenderBound)&&void 0!==e?e:this._onPrerenderBound=t=>{this.onPrerender(t)};null!=i&&i.off("prerender",s),this._rendererBound=t,null!=t&&(t.on("prerender",s),null!=this._canvas&&ot.update(this))}super.render(t)}destroy(){const t=this._rendererBound;if(null!=t){this._rendererBound=void 0;const e=this._onPrerenderBound;null!=e&&t.off("prerender",e)}super.destroy()}getType(){return"DDiagram"}}class $o{static isDiagram(t){return t instanceof jo}static isEmbedded(t){return t instanceof Yi}static toDiagram(t){let e=t;for(;null!=e;){if(this.isDiagram(e))return e;e=e.parent}return null}static open(t,e,i,s,n){const o=yn[e];if(null!=o){const e=this.toDiagram(t);e&&o(i,s,t,e,n)}else if(Et(i))switch(e){case Ri.DIAGRAM:const e=this.toDiagram(t);if(e){const t=e.controller;t&&t.getByName(i).then(t=>{e.set(En.toSerialized(t))})}break;case Ri.PAGE:s?window.open(i):window.location.href=i}}static writeLocal(t,e,i,s,n=Ft.FOUND){var o;let r=t;for(;null!=r;){if(this.isDiagram(r))return(r.data.private.set(e,i,s,n)||r.data.protected.set(e,i,s,n)||!!r.data.set(e,i,s,n))&&(ot.update(r),!0);if(this.isEmbedded(r)&&(null===(o=r.data.getPrivate())||void 0===o?void 0:o.set(e,i,s,n)))return ot.update(r),!0;r=r.parent}return!1}static writeRemote(t,e,i){const s=this.toDiagram(t);return!!s&&s.data.remote.set(e,i)}static emit(t,e,i,s){const n=$o.toDiagram(t);void 0===s?(t.emit(e,t),n&&n.shape.emit(e,t)):(t.emit(e,i,s,t),n&&n.shape.emit(e,i,s,t))}}class qo extends ve{constructor(t){super(t,pe.NONE),this.name=fe.ofStringOrNull(t.name)}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.name(t,i,ge);null!=e&&$o.emit(t,e)}}}class Zo extends be{constructor(t,e){super(Oe.EMIT_EVENT,t),this.name=e}isEquals(t){return super.isEquals(t)&&t instanceof Zo&&this.name===t.name}toRuntime(){return new qo(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.name);return t.addResource(`[${this.type},${e},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(2,t,e.resources);return new Zo(i,s)}}class Jo extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target)}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.target(t,i,ge);null!=e&&$o.emit(t,e)}}}const Qo={NO_POINTER_EVENTS:"NO_POINTER_EVENTS"};class tr{constructor(t){const e="http://www.w3.org/2000/svg",i=document.createElementNS(e,"svg");i.setAttribute("style","position: absolute;"),i.setAttribute("width","0px"),i.setAttribute("height","0px");const s=document.createElementNS(e,"defs"),n=document.createElementNS(e,"clipPath"),o="clipper_ex_"+Math.random().toString(32).substring(2);n.setAttribute("id",o),n.setAttribute("clipPathUnits","objectBoundingBox");const r=document.createElementNS(e,"path");this._path=r,this._pathD="",r.setAttribute("clip-rule","evenodd"),n.appendChild(r),s.appendChild(n),i.appendChild(s),this._id=o,t.appendChild(i)}get id(){return this._id}update(t,e,i){const s=this.toD(t,e,i);this._pathD!=s&&(this._path.setAttribute("d",s),this._pathD=s)}toD(e,i,s){var n,o;if(null==e)return"";const r=e.width,a=e.height,h=1e-4;if(r<h||a<h)return"";if(s.size<=0)return"M0,0 h1 v1 h-1z";const l=null!==(n=tr.WORK_MATRIX)&&void 0!==n?n:tr.WORK_MATRIX=new t.Matrix;null!=i?(l.copyFrom(i),l.invert()):l.identity(),l.translate(-e.x,-e.y),l.scale(1/r,1/a);let c=-1,u=2,d=-1,p=2,_="";const g=l.a,f=l.b,m=l.c,v=l.d,T=l.tx,w=l.ty,E=null!==(o=tr.WORK_RECTS)&&void 0!==o?o:tr.WORK_RECTS=[],y=this.toRects(s,E);for(let t=0;t<y;t+=4){const e=E[t+0],i=E[t+1],s=E[t+2],n=E[t+3],o=g*e+m*i+T,r=f*e+v*i+w,a=g*s+m*i+T,h=f*s+v*i+w,l=g*s+m*n+T,y=f*s+v*n+w,x=g*e+m*n+T,C=f*e+v*n+w;c=Math.min(c,o,a,l,x),u=Math.max(u,o,a,l,x),d=Math.min(d,r,h,y,C),p=Math.max(p,r,h,y,C),_+=` M${o.toFixed(5)},${r.toFixed(5)} L${a.toFixed(5)},${h.toFixed(5)} L${l.toFixed(5)},${y.toFixed(5)} L${x.toFixed(5)},${C.toFixed(5)}Z`}return`M${c},${d} L${u},${d} L${u},${p} L${c},${p}Z`+_}toRects(t,e){const i=t.data;let s=t.size<<2;for(let t=0;t<s;t+=4){const s=i[t+0],n=i[t+1],o=i[t+2],r=i[t+3];s<o?(e[t+0]=s,e[t+2]=o):(e[t+0]=o,e[t+2]=s),n<r?(e[t+1]=n,e[t+3]=r):(e[t+1]=r,e[t+3]=n)}for(let t=4;t<s;t+=4){let i=e[t+0],n=e[t+1],o=e[t+2],r=e[t+3];for(let a=0;a<t;a+=4){const h=e[a+0],l=e[a+1],c=e[a+2],u=e[a+3];let d=0,p=0;if(i<=h)if(o<=c){if(o<=h)continue;d=2,p=1}else p=3;else if(o<=c)d=3;else{if(c<=i)continue;d=1,p=2}let _=0,g=0;if(n<=l)if(r<=u){if(r<=l)continue;_=2,g=1}else g=3;else if(r<=u)_=3;else{if(u<=n)continue;_=1,g=2}let f=0;if(f=0===d||0===_?0:1===d||2===d?3===_?2:1:3===_?4:2,4===f){t+4<s&&(e[t+0]=e[s+0],e[t+1]=e[s+1],e[t+2]=e[s+2],e[t+3]=e[s+3]),t-=4,s-=4;break}let m=0;if(m=0===p||0===g?0:1===p||2===p?3===g?2:1:3===g?4:2,4!==m)if(0===f)if(0===m){for(let t=s-4;a<t;t-=4)e[t+4]=e[t+0],e[t+5]=e[t+1],e[t+6]=e[t+2],e[t+7]=e[t+3];0===p?(e[a+3]=n,e[a+4]=h,e[a+5]=r,e[a+6]=c,e[a+7]=u):(e[a+2]=i,e[a+4]=o,e[a+5]=l,e[a+6]=c,e[a+7]=u),t+=4,s+=4,a+=4}else 2===m&&(1===p?e[a+0]=o:2===p?e[a+2]=i:1===g?e[a+1]=r:2===g&&(e[a+3]=n));else if(1===f){for(let t=s-4;a<t;t-=4)e[t+4]=e[t+0],e[t+5]=e[t+1],e[t+6]=e[t+2],e[t+7]=e[t+3];1===p?1===g?(e[a+0]=o,e[a+4]=h,e[a+5]=r,e[a+6]=o,e[a+7]=u):(e[a+0]=o,e[a+4]=h,e[a+5]=l,e[a+6]=o,e[a+7]=n):1===g?(e[a+2]=i,e[a+4]=i,e[a+5]=r,e[a+6]=c,e[a+7]=u):(e[a+2]=i,e[a+4]=i,e[a+5]=l,e[a+6]=c,e[a+7]=n),t+=4,s+=4,a+=4}else 2===f&&(1===d?(e[t+0]=c,i=c):2===d?(e[t+2]=h,o=h):1===_?(e[t+1]=u,n=u):2===_&&(e[t+3]=l,r=l));else{for(let t=a+4;t<s;t+=4)e[t-4]=e[t+0],e[t-3]=e[t+1],e[t-2]=e[t+2],e[t-1]=e[t+3];t-=4,s-=4,a-=4}}}return s}}class er{constructor(){this._data=[],this._size=0,this._index=0,this._isDirty=!0}get data(){return this._data}get size(){return this._size}isDirty(){return this._isDirty}toClean(){this._isDirty=!1}begin(){return this._index=0,this}end(){const t=this._index;this._size=t;const e=this._data,i=t<<2;return e.length!==i&&(e.length=i,this._isDirty=!0),this}add(t,e,i,s){const n=this._index<<2;this._index+=1;const o=this._data;return n<o.length?o[n+0]===t&&o[n+1]===e&&o[n+2]===i&&o[n+3]===s||(o[n+0]=t,o[n+1]=e,o[n+2]=i,o[n+3]=s,this._isDirty=!0):(o.push(t,e,i,s),this._isDirty=!0),this}}const ir={CLICKED:0,DOUBLE_CLICKED:1,FOCUSED:2,ALWAYS:3};class sr{constructor(t,e,i,s){this._target=t,this._operation=e;const n=this.toData(i,s);this._data=n,this._isElementShown=!1,this._onElementFocusBound=t=>{this.onElementFocus(t)},this._onBeforeFocusBound=t=>{this.onBeforeFocus(t)},this._onAfterFocusBound=t=>{this.onAfterFocus(t)},this._isStarted=!1,this._wasStarted=!1,this._doSelectBound=()=>{this.doSelect()},this._isStartRequested=this._data.when===ir.ALWAYS,this._onPostRenderBound=()=>{this.updateElement(this._rendererBound)}}toData(t,e){var i,s;return{element:this.toElementData(t,null==e?void 0:e.element),clipper:this.toClipperData(t,null==e?void 0:e.clipper),before:this.toBeforeData(t,null==e?void 0:e.before),after:this.toAfterData(t,null==e?void 0:e.after),when:Qi(null!==(i=null==e?void 0:e.when)&&void 0!==i?i:t.getWhen(),ir),select:null!==(s=null==e?void 0:e.select)&&void 0!==s?s:t.getSelect()}}toElementData(t,e){var i,s;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getElementCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newElementStyler(t)}}newElementStyler(t){return(e,i,s,n,o,r,a)=>t.setElementStyle(e,i,s,n,o,r,a)}toClipperData(t,e){var i,s,n;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getClipperCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newClipperStyler(t),extended:null!==(n=null==e?void 0:e.extended)&&void 0!==n?n:t.isClipperExEnabled()}}newClipperStyler(t){return(e,i,s,n,o,r,a)=>t.setClipperStyle(e,i,s,n,o,r,a)}toBeforeData(t,e){var i,s;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getBeforeCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newBeforeStyler(t)}}newBeforeStyler(t){return e=>{t.setBeforeStyle(e)}}toAfterData(t,e){var i,s;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getAfterCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newAfterStyler(t)}}newAfterStyler(t){return e=>{t.setAfterStyle(e)}}get element(){var t;return null!==(t=this._element)&&void 0!==t?t:null}get when(){return this._data.when}onDowning(t){switch(this._wasStarted=this._isStarted,this.when){case ir.CLICKED:this.start();break;case ir.FOCUSED:this._target.state.isFocused&&this.start()}}onDown(t){!this._wasStarted&&this._isStarted&&("data"in t?t.data.originalEvent.preventDefault():t.preventDefault())}onDblClick(t,e){switch(this.when){case ir.DOUBLE_CLICKED:this.start()}}onFocus(){var t;switch(this.when){case ir.FOCUSED:this.start();break;default:null===(t=this._element)||void 0===t||t.focus()}}onBlur(){var t;switch(this.when){case ir.CLICKED:case ir.DOUBLE_CLICKED:case ir.FOCUSED:this.onEndByBlur(),this.cancel();break;default:null===(t=this._element)||void 0===t||t.blur()}}isStartable(){switch(this.when){case ir.CLICKED:case ir.DOUBLE_CLICKED:case ir.FOCUSED:return this._target.state.isActionable;default:return!0}}start(){!this._isStarted&&this.isStartable()&&(this._isStarted=!0,this._target.worldVisible?this.doStart():this._isStartRequested=!0,ot.update(this._target))}isShown(){return this._isElementShown}onRender(t){(this._isStartRequested||!this._isElementShown&&this.when===ir.ALWAYS)&&(this._isStartRequested=!1,this.doStart(t)),this._isStarted&&(this._isStarted=!1)}getElementRect(e){const i=this._point||new t.Point(0,0);this._point=i;const s=this._elementRectResult||new t.Rectangle;return this._elementRectResult=s,this._operation.getElementRect(e,i,s)}getElementMatrix(){return this._operation.getElementMatrix()}getClipperRect(e){const i=this._point||new t.Point(0,0);this._point=i;const s=this._clipperRectResult||new t.Rectangle;return this._clipperRectResult=s,this._operation.getClipperRect(e,i,s)}fillClipperExRects(t,e){const i=this._operation;return i.getClipperExRects&&i.getClipperExRects(e),e.isDirty()}doStart(t){var e,i;if(!this._isElementShown){this._isElementShown=!0;const s=this._rendererBound;null!=s&&(this._rendererBound=void 0,s.off("postrender",this._onPostRenderBound));const n=this._target;null==t&&(t=null===(e=ot.getLayer(n))||void 0===e?void 0:e.renderer),t&&(this._rendererBound=t,t.on("postrender",this._onPostRenderBound)),this.onStart();const o=this.getClipper();if(o){const e=this.getBefore(o),s=this.getElement(o),r=this.getAfter(o),a=this.getClipperEx(o);if(s){const h=null!==(i=null==t?void 0:t.resolution)&&void 0!==i?i:ot.getResolution(n),l=this.getElementRect(h),c=this.getElementMatrix(),u=this.toClipperRectAdjusted(l,c,this.getClipperRect(h)),d=n.state,p=this._operation.getPadding(),_=this._data;if(_.clipper.styler(o,d,p,l,c,u,a),_.element.styler(s,d,p,l,c,u,a),e&&_.before.styler(e),r&&_.after.styler(r),this.onElementAttached(s,e,r),a){const t=this.getClipperExRects();t&&this.fillClipperExRects(h,t)&&(a.update(l,c,t),t.toClean())}o.style.display="",d.isFocused&&this.toElementFocused(s),o.scrollTop=0,o.scrollLeft=0,this._data.select&&setTimeout(this._doSelectBound,0)}}}}toElementFocused(t){t.focus({preventScroll:!0})}onStart(){this._operation.onStart()}doSelect(){const t=this._element;t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.select()}cancel(){var t;if(this._isElementShown){this._isElementShown=!1;const e=this._rendererBound;null!=e&&(this._rendererBound=void 0,e.off("postrender",this._onPostRenderBound)),this.onCancel();const i=this._target,s=ot.getLayer(i);if(s){const e=s.view;switch(this.when){case ir.CLICKED:case ir.DOUBLE_CLICKED:case ir.FOCUSED:document.activeElement===this._element&&e.focus()}const n=i.state,o=s.renderer.plugins.interaction;this._operation.containsPoint(o.mouse.global)&&!n.isHovered&&(n.isHovered=!0,e.style.cursor=null!==(t=i.cursor)&&void 0!==t?t:""),s.update()}const n=this._element;null!=n&&this.onElementDetached(n,this._before,this._after);const o=this._clipper;null!=o&&(o.style.display="none")}}onCancel(){this._operation.onCancel()}onElementAttached(t,e,i){null==e||e.addEventListener("focus",this._onBeforeFocusBound),null==i||i.addEventListener("focus",this._onAfterFocusBound),t.addEventListener("focus",this._onElementFocusBound,!0)}onElementDetached(t,e,i){null==e||e.removeEventListener("focus",this._onBeforeFocusBound),null==i||i.removeEventListener("focus",this._onAfterFocusBound),t.removeEventListener("focus",this._onElementFocusBound,!0)}getClipper(){let t=this._clipper;if(null==t){const e=ot.getLayer(this._target);t=e?this._data.clipper.creator(e.getElementContainer()):null,this._clipper=t}return t}getClipperEx(t){let e=this._clipperEx;return void 0===e&&(e=null!=this.getClipperExRects()?new tr(t):null,this._clipperEx=e),e}getClipperExRects(){let t=this._clipperExRects;return void 0===t&&(t=this._data.clipper.extended?new er:null,this._clipperExRects=t),t}getElement(t){let e=this._element;return null==e&&(e=this._data.element.creator(t),this._element=e),e}getBefore(t){let e=this._before;return null==e&&(e=this._data.before.creator(t),this._before=e),e}getAfter(t){let e=this._after;return null==e&&(e=this._data.after.creator(t),this._after=e),e}onBeforeFocus(t){const e=this._target,i=ot.getLayer(e);if(i){const s=i.getFocusController(),n=s.find(e,!1,!1,!1);i.view.focus(),s.focus(n),t.preventDefault(),t.stopImmediatePropagation()}}onAfterFocus(t){const e=this._target,i=ot.getLayer(e);if(i){const s=i.getFocusController(),n=s.find(e,!1,!1,!0);i.view.focus(),s.focus(n),t.preventDefault(),t.stopImmediatePropagation()}}onElementFocus(t){if(this.when===ir.ALWAYS){const t=this._target;t.state.isFocused||t.focus()}}onEndByBlur(){this.onEnd()}onEnd(){this._operation.onEnd()}end(){this.onEnd(),this.cancel()}select(){return this._isElementShown&&this._data.select&&this.doSelect(),this}toClipperRectAdjusted(t,e,i){if(i&&t&&null==e){const e=t.x,s=t.y,n=e+t.width,o=s+t.height,r=i.x,a=i.y,h=r+i.width,l=a+i.height,c=Math.min(Math.max(r,e),h),u=Math.min(Math.max(r,n),h),d=Math.min(Math.max(a,s),l),p=Math.min(Math.max(a,o),l);i.x=c,i.y=d,i.width=u-c,i.height=p-d}return i}updateElement(t){if(this._isElementShown){const e=this._target;if(e.worldVisible){const i=this._element,s=this._clipper,n=this._clipperEx;if(i&&s){const o=t.resolution,r=this.getElementRect(o),a=this.getElementMatrix(),h=this.toClipperRectAdjusted(r,a,this.getClipperRect(o)),l=e.state,c=this._operation.getPadding(),u=this._data;if(u.clipper.styler(s,l,c,r,a,h,n),u.element.styler(i,l,c,r,a,h,n),n){const t=this.getClipperExRects();t&&this.fillClipperExRects(o,t)&&(n.update(r,a,t),t.toClean())}}}else switch(this.when){case ir.ALWAYS:const t=this._clipper;t&&(t.style.display="none");break;default:this.cancel()}}}static getClipperRect(t,e,i,s,n){let o=!0,r=0,a=0,h=0,l=0,c=t;for(;c instanceof to;){c.getClippingRect(e,n),s.set(n.x,n.y),c.toGlobal(s,s,!1);const t=(s.x*i|0)/i,u=(s.y*i|0)/i;s.set(n.x+n.width,n.y+n.height),c.toGlobal(s,s,!0);const d=s.x,p=s.y,_=Math.min(t,d),g=Math.min(u,p),f=Math.max(t,d),m=Math.max(u,p);o?(o=!1,r=_,a=g,h=f,l=m):(r=Math.min(Math.max(r,_),f),a=Math.min(Math.max(a,g),m),h=Math.min(Math.max(h,_),f),l=Math.min(Math.max(l,g),m)),c=c.parent}return o?null:(n.x=r,n.y=a,n.width=h-r,n.height=l-a,n)}}let nr=!1;const or=()=>nr;class rr extends me{constructor(t){super(),this.condition=fe.ofString(t.condition),this.utils=new Map}getUtil(t,e){const i=this.utils;let s=i.get(t);return null==s&&(s=this.newUtil(t,e),i.set(t,s)),s}newUtil(t,e){return new sr(t,this.newOperation(t,e),$.getInstance().get("DHtmlElement"),this.newUtilOptions(t,e))}newOperation(t,e){return{getElementRect:(i,s,n)=>this.getElementRect(t,e,i,s,n),getElementMatrix:()=>this.getElementMatrix(t,e),getClipperRect:(i,s,n)=>this.getClipperToRect(t,e,i,s,n),getClipperExRects:e=>{this.getClipperExRects(t,e)},getPadding:()=>this.getPadding(t,e),containsPoint:i=>this.containsPoint(t,e,i),onStart:()=>{},onCancel:()=>{},onEnd:()=>{}}}newUtilOptions(t,e){return{element:{creator:this.newElementCreator(t,e)},when:this.toWhen(t,e),clipper:{extended:or()}}}toWhen(t,e){const i=this.condition(t,Date.now(),ge);if(null!=i&&i in ir)return ir[i]}containsPoint(e,i,s){var n;if(e.visible){const i=null!==(n=rr.WORK)&&void 0!==n?n:rr.WORK=new t.Point;return e.toLocal(s,void 0,i),null!=e.contains(i.x,i.y)}return!1}getPadding(t,e){return null}getElementRect(t,e,i,s,n){const o=t.transform.pivot,r=t.size,a=r.x,h=r.y;return n.x=-.5*a+o.x,n.y=-.5*h+o.y,n.width=a,n.height=h,n}getElementMatrix(t,e){return t.updateTransform(),t.transform.worldTransform}getClipperToRect(t,e,i,s,n){const o=$o.toDiagram(t);return sr.getClipperRect(o,t,i,s,n)}getClipperExRects(t,e){e.begin();const i=t.root.parent;if(i instanceof Co){const t=i.parent;if(null!=t){const s=t.children,n=s.indexOf(i);if(0<=n)for(let t=n+1,i=s.length;t<i;++t){const i=s[t];if(i.visible){const t=i.width,s=i.height,n=i.transform.worldTransform,o=n.a,r=n.b,a=n.c,h=n.d,l=n.tx,c=n.ty;e.add(l,c,o*t+a*s+l,r*t+h*s+c)}}}}e.end()}onRender(t,e,i,s){this.getUtil(t,e).onRender(s)}onFocus(t,e){this.getUtil(t,e).onFocus()}onBlur(t,e){this.getUtil(t,e).onBlur()}onDowning(t,e,i){this.getUtil(t,e).onDowning(i)}onDown(t,e,i){this.getUtil(t,e).onDown(i)}onDblClick(t,e,i,s){this.getUtil(t,e).onDblClick(i,s)}}class ar extends rr{constructor(t){super(t),this.elementCreator=fe.ofElementOrNull(t.value),this.noPointerEvent=t.subtype===fn.HTML_ELEMENT_WITHOUT_POINTER_EVENTS}newUtil(t,e){return this.noPointerEvent&&t.state.add(Qo.NO_POINTER_EVENTS),super.newUtil(t,e)}newElementCreator(t,e){const i=this.elementCreator;if(i)return e=>i(t,Date.now(),ge,e)}}class hr extends sr{constructor(t,e,i,s){var n,o,r,a,h,l;super(t,e,i,s),this._operation=e,this._onInputKeyDownBound=t=>{this.onInputKeyDown(t)},this._onInputChangeBound=()=>{this.onInputChange()},this._onInputInputBound=t=>{this.onInputInput(t)},this._description=null!==(n=null==s?void 0:s.description)&&void 0!==n?n:"";const c=null==s?void 0:s.editing;this._editingFormatter=null!==(a=null!==(o=null==c?void 0:c.formatter)&&void 0!==o?o:null===(r=null==s?void 0:s.text)||void 0===r?void 0:r.formatter)&&void 0!==a?a:i.getEditingFormatter(),this._editingUnformatter=null!==(h=null==c?void 0:c.unformatter)&&void 0!==h?h:i.getEditingUnformatter(),this._editingValidator=null!==(l=null==c?void 0:c.validator)&&void 0!==l?l:i.getEditingValidator()}onEnd(){super.onEnd(),this.onInputChange()}onElementAttached(t,e,i){t.value=this.fromValue(this._operation.getValue()),t.addEventListener("change",this._onInputChangeBound),t.addEventListener("input",this._onInputInputBound),super.onElementAttached(t,e,i)}onElementDetached(t,e,i){super.onElementDetached(t,e,i),t.removeEventListener("change",this._onInputChangeBound),t.removeEventListener("input",this._onInputInputBound)}onInputKeyDown(t){$n.isOkKey(t)?(this.end(),this._operation.onEnter()):$n.isCancelKey(t)&&this.cancel()}toElementFocused(t){super.toElementFocused(t),t.scrollTop=0,t.scrollLeft=0}onInputChange(){if(this.isShown()){const t=this.element;if(null!=t){const e=this._operation,i=this.toValue(t.value),s=e.getValue();s!==i&&e.onValueChange(i,s)}}}toValue(t){return this._editingUnformatter(t,this)}fromValue(t){return void 0!==t?this._editingFormatter(t,this):""}onInputInput(t){const e=t.target;(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&this._operation.onValueInput(this.toValue(e.value))}validate(){const t=this._operation.getValue();if(void 0!==t){const e=this._editingValidator(t,this);if(this._editingValidationResult!==e){this._editingValidationResult=e;const t=this._target.state;t.isInvalid=null!=e,t.isHovered&&this._operation.applyTitle()}return e}return null}applyTitle(){const t=this._editingValidationResult;if(Et(t)){const e=ot.getLayer(this._target);return e&&(e.view.title=t),!0}return!1}}class lr extends hr{onElementAttached(t,e,i){t.addEventListener("keydown",this._onInputKeyDownBound),super.onElementAttached(t,e,i)}onElementDetached(t,e,i){t.removeEventListener("keydown",this._onInputKeyDownBound),super.onElementDetached(t,e,i)}}class cr extends lr{constructor(t,e,i,s){var n,o,r;super(t,e,i,s),this._step=null!==(n=null==s?void 0:s.step)&&void 0!==n?n:i.getStep(),this._min=null!==(o=null==s?void 0:s.min)&&void 0!==o?o:i.getMin(),this._max=null!==(r=null==s?void 0:s.max)&&void 0!==r?r:i.getMax()}get step(){return this._step}set step(t){this._step!==t&&(this._step=t,this.onStepChange())}get min(){return this._min}set min(t){this._min!==t&&(this._min=t,this.onMinChange())}get max(){return this._max}set max(t){this._max!==t&&(this._max=t,this.onMaxChange())}toValue(t){const e=super.toValue(t);if(e==e){const t=this._min;if(null!=t&&e<t)return t;const i=this._max;return null!=i&&i<e?i:e}return 0}fromValue(t){return void 0!==t?this._editingFormatter(t,this):"0"}onStepChange(){if(this.isShown()){const t=this.element;t&&this.updateStep(t)}}onMinChange(){if(this.isShown()){const t=this.element;t&&this.updateMin(t)}}onMaxChange(){if(this.isShown()){const t=this.element;t&&this.updateMax(t)}}updateStep(t){const e=this.step;t.step=null!=e?""+e:"any"}updateMin(t){const e=this.min;null!=e?t.min=""+e:t.removeAttribute("min")}updateMax(t){const e=this.max;null!=e?t.max=""+e:t.removeAttribute("max")}onElementAttached(t,e,i){t.type="number",super.onElementAttached(t,e,i),this.updateStep(t),this.updateMin(t),this.updateMax(t)}}const ur={EMIT_EVENT:0,WRITE_BOTH:1,WRITE_LOCAL:2,WRITE_REMOTE:3};class dr{static execute(t,e,i,s,n){switch(e){case ur.EMIT_EVENT:t.emit(i,t,s),$o.emit(t,i,s,n);break;case ur.WRITE_LOCAL:$o.writeLocal(t,i,s,n);break;case ur.WRITE_REMOTE:$o.writeRemote(t,i,s);break;case ur.WRITE_BOTH:$o.writeLocal(t,i,s,n),$o.writeRemote(t,i,s)}}}class pr extends rr{constructor(t){super(t),this.target=fe.ofStringOrNull(t.target),this.onInputAction=t.onInputAction}newOperation(t,e){return{getElementRect:(i,s,n)=>this.getElementRect(t,e,i,s,n),getElementMatrix:()=>this.getElementMatrix(t,e),getClipperRect:(i,s,n)=>this.getClipperToRect(t,e,i,s,n),getClipperExRects:e=>{this.getClipperExRects(t,e)},getPadding:()=>this.getPadding(t,e),containsPoint:i=>this.containsPoint(t,e,i),onStart:()=>{t.text.enable=!1},onCancel:()=>{t.text.enable=!0},onEnd:()=>{},getValue:()=>this.getUtil(t,e).toValue(t.text.value),onValueInput:t=>{},onValueChange:(i,s)=>{this.onValueChange(t,e,i,s)},onEnter:()=>{},applyTitle:()=>{}}}newElementCreator(t,e){}getPadding(t,e){return t.text.padding}onValueChange(t,e,i,s){t.text.value=this.getUtil(t,e).fromValue(i);const n=Date.now(),o=this.target(t,n,ge);null!=o&&dr.execute(t,this.onInputAction,o,i,n)}}class _r extends pr{}class gr extends _r{}class fr extends gr{newUtil(t,e){return new cr(t,this.newOperation(t,e),$.getInstance().get("DInputInteger"),this.newUtilOptions(t,e))}}class mr extends gr{newUtil(t,e){return new cr(t,this.newOperation(t,e),$.getInstance().get("DInputReal"),this.newUtilOptions(t,e))}}class vr extends lr{onElementAttached(t,e,i){t.type="text",super.onElementAttached(t,e,i)}}class Tr extends _r{newUtil(t,e){return new vr(t,this.newOperation(t,e),$.getInstance().get("DInputText"),this.newUtilOptions(t,e))}}class wr extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target),this.value=fe.ofUnknown(t.value)}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.target(t,i,ge);null!=e&&this.write(t,e,this.value(t,i,ge),i)}}}class Er extends wr{write(t,e,i,s){$o.writeLocal(t,e,i,s),$o.writeRemote(t,e,i)}}class yr extends wr{write(t,e,i,s){$o.writeLocal(t,e,i,s)}}class xr extends wr{write(t,e,i,s){$o.writeRemote(t,e,i)}}class Cr extends Ie{constructor(t,e,i,s,n){super(Oe.MISC,e,t),this.target=i,this.onInputAction=s,this.value=n}toRuntime(){switch(this.subtype){case fn.INPUT_TEXT:return new Tr(this);case fn.INPUT_INTEGER:return new fr(this);case fn.INPUT_REAL:return new mr(this);case fn.EMIT_EVENT:return new Jo(this);case fn.WRITE_BOTH:return new Er(this);case fn.WRITE_LOCAL:return new yr(this);case fn.WRITE_REMOTE:return new xr(this);case fn.HTML_ELEMENT:case fn.HTML_ELEMENT_WITHOUT_POINTER_EVENTS:return new ar(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=t.addResource(this.value);return t.addResource(`[${this.type},${e},${this.subtype},${i},${this.onInputAction},${s}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i),o=Ae.toResource(5,t,i);return new Cr(t[2],s,n,t[4],o)}}class Dr extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofUnknown(t.target)}execute(t,e,i){this.condition(t,i,ge)&&this.target(t,i,ge)}}class Sr extends Ie{constructor(t,e){super(Oe.MISC,t,fn.EXECUTE),this.target=e}toRuntime(){return new Dr(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target);return t.addResource(`[${this.type},${e},${this.subtype},${i}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i);return new Sr(s,n)}}class br{static add(t){var e,i;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._data)&&void 0!==i?i:this._data=[]).push(t)}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Ir extends ve{constructor(t){super(t,pe.NONE),this.argument=fe.ofUnknown(t.argument),this.extension=br.get(t.subtype)}execute(t,e,i){const s=this.extension;if(null!=s&&this.condition(t,i,ge)){const e=$o.toDiagram(t);null!=e&&s.executor(this.argument(t,i,ge),t,e,ge)}}}class Or extends Ie{constructor(t,e,i){super(Oe.MISC,e,t),this.argument=i}toRuntime(){return new Ir(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.argument);return t.addResource(`[${this.type},${e},${this.subtype},${i}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i);return new Or(t[2],s,n)}}class Ar extends ve{constructor(t,e){super(t,pe.NONE),this.subtype=e,this.target=fe.ofUnknown(t.target),this.inNewWindow=t.inNewWindow}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.target(t,i,ge);null!=e&&$o.open(t,this.subtype,e,this.inNewWindow,ge)}}}const Rr={DIAGRAM_LEGACY:0,PAGE_LEGACY:1,PAGE_INPLACE_LEGACY:2,DIALOG_TEXT:3,DIALOG_INTEGER:4,DIALOG_REAL:5,DIALOG_BOOLEAN:6,DIALOG_DATE:7,DIALOG_TIME:8,DIALOG_DATETIME:9,DIAGRAM:10,PAGE:11,DIALOG:12,EXTENSION:Ri.EXTENSION};class Mr extends Ie{constructor(t,e,i,s){super(Oe.OPEN,e,t),this.target=i,this.inNewWindow=s}isEquals(t){return super.isEquals(t)&&t instanceof Mr&&this.target===t.target&&this.inNewWindow===t.inNewWindow}toRuntime(){switch(this.subtype){case Rr.DIAGRAM:return new Ar(this,Ri.DIAGRAM);case Rr.PAGE:return new Ar(this,Ri.PAGE)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=this.inNewWindow?1:0;return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources);return new Mr(this.toSubType(t),i,s,this.inNewWindow(t))}static toSubType(t){switch(t[2]){case Rr.DIAGRAM_LEGACY:return Rr.DIAGRAM;case Rr.PAGE_LEGACY:case Rr.PAGE_INPLACE_LEGACY:return Rr.PAGE;case Rr.DIAGRAM:return Rr.DIAGRAM;case Rr.PAGE:return Rr.PAGE}return Rr.DIAGRAM}static inNewWindow(t){switch(t[2]){case Rr.DIAGRAM_LEGACY:return!1;case Rr.PAGE_LEGACY:return!0;case Rr.PAGE_INPLACE_LEGACY:return!1;case Rr.DIAGRAM:case Rr.PAGE:return!!t[4]}return!1}}const kr={TOP:0,TOP_LEFT:1,TOP_CENTER:2,TOP_RIGHT:3,LEFT:4,LEFT_TOP:5,LEFT_MIDDLE:6,LEFT_BOTTOM:7,RIGHT:8,RIGHT_TOP:9,RIGHT_MIDDLE:10,RIGHT_BOTTOM:11,BOTTOM:12,BOTTOM_LEFT:13,BOTTOM_CENTER:14,BOTTOM_RIGHT:15,OVER:16,NONE:17};class Lr{static attach(t,e,i,s,n,o,r){if(r===kr.NONE)return;const a=t.width,h=t.height;let l=0;switch(r){case kr.LEFT:case kr.LEFT_TOP:case kr.LEFT_MIDDLE:case kr.LEFT_BOTTOM:l=e.left-a-i,l<i&&(l=e.right+i,n-i<l+a&&(l=i));break;case kr.RIGHT:case kr.RIGHT_TOP:case kr.RIGHT_MIDDLE:case kr.RIGHT_BOTTOM:l=e.right+i,n-i<l+a&&(l=e.left-a-i,l<i&&(l=n-a-i));break;case kr.TOP:case kr.TOP_LEFT:case kr.BOTTOM:case kr.BOTTOM_LEFT:l=this.adjust(e.left,a,i,n);break;case kr.TOP_RIGHT:case kr.BOTTOM_RIGHT:l=this.adjust(e.right-a,a,i,n);break;case kr.TOP_CENTER:case kr.BOTTOM_CENTER:case kr.OVER:l=this.adjust(.5*(e.left+e.right-a),a,i,n)}let c=0;switch(r){case kr.LEFT:case kr.LEFT_TOP:case kr.RIGHT:case kr.RIGHT_TOP:c=this.adjust(e.top,h,s,o);break;case kr.LEFT_MIDDLE:case kr.RIGHT_MIDDLE:case kr.OVER:c=this.adjust(.5*(e.top+e.bottom-h),h,s,o);break;case kr.LEFT_BOTTOM:case kr.RIGHT_BOTTOM:c=this.adjust(e.bottom,h,s,o);break;case kr.TOP:case kr.TOP_LEFT:case kr.TOP_RIGHT:case kr.TOP_CENTER:c=e.top-h-s,c<s&&(c=e.bottom+s,o<c+h&&(c=s));break;case kr.BOTTOM:case kr.BOTTOM_LEFT:case kr.BOTTOM_RIGHT:case kr.BOTTOM_CENTER:c=e.bottom+s,o-s<c+h&&(c=e.top-h-s,c<s&&(c=o-h-s))}t.position.set(l,c)}static adjust(t,e,i,s){return t<i?s-i<t+e?.5*(s-e):i:s-i<t+e?s<e?.5*(s-e):s-e-i:t}}const Nr={NONE:0,ESC:1,CLICK_OUTSIDE:2},Pr={DIRTY:0,CLEAN:1};class Br{constructor(t,e){var i;this._parent=t,this._options=e,e.enable&&(this._util=this.newUtil()),this._mode=Qi(null!==(i=e.mode)&&void 0!==i?i:Pr.DIRTY,Pr),this._isEnabled=!0,this._isDirty=!1}get parent(){return this._parent}get mode(){return this._mode}set mode(t){this._mode=t}get constraint(){var t,e;let i=this._constraint;return null==i&&(i=null!==(e=null===(t=this._options)||void 0===t?void 0:t.constraint)&&void 0!==e?e:this.newConstraint(),this._constraint=i),i}set constraint(t){this._constraint=t}newConstraint(){return(t,e,i,s)=>{this.toConstrained(t,e,i,s)}}isDirty(){return this._isDirty}isClean(){return!this._isDirty}toClean(){this._isDirty&&(this._isDirty=!1)}newUtil(){const e=new t.Point,i=this._parent,s=i.position;return new un({bind:i,checker:{start:t=>{if(t.target!==i)return!1;e.copyFrom(t.data.global),i.toLocal(e,void 0,e,!0);const s=e.x,n=e.y;return!(s<0||n<0||i.width<s||i.height<n)}},on:{start:()=>{e.copyFrom(s)},move:(t,n,o)=>{e.set(e.x+n,e.y+o),this._isDirty||(this._isDirty=!0,i.setX(s.x),i.setY(s.y));const r=i.layer;null!=r&&this.constraint(i,r,e.x,e.y)}}})}toConstrained(e,i,s,n){var o;const r=e.position;if(i){const a=e.getBounds(!1,null!==(o=Br.WORK_BOUNDS)&&void 0!==o?o:Br.WORK_BOUNDS=new t.Rectangle),h=a.x+s-r.x,l=a.y+n-r.y,c=Math.min(Math.max(0,h),i.width-a.width),u=Math.min(Math.max(0,l),i.height-a.height);r.set(s+c-h,n+u-l)}else r.set(s,n)}}const zr={MODAL:0,MODELESS:1,MENU:2},Ur={MODAL:"MODAL",MODELESS:"MODELESS",MENU:"MENU"};class Fr{static apply(t,e){t.on(nn.down,i=>{if(i.target===t){const s=this.point;s.copyFrom(i.data.global),t.toLocal(s,void 0,s,!0);const n=s.x,o=s.y;(n<0||o<0||t.width<n||t.height<o)&&setTimeout(()=>{e(i)},0)}})}}Fr.point=new t.Point;class Hr{constructor(t){this._layer=null,this._application=null==(null==t?void 0:t.parent)?ot.last():null}get picked(){return this._layer}pick(t,e){let i=this._layer;if(null==i){if(i=ot.getLayerOverlay(t),null==i&&null!=e&&(i=ot.getLayerOverlay(e)),null==i){const t=this._application;i=t?t.getLayerOverlay():ot.last().getLayerOverlay()}this._layer=i}return i}}class Gr extends to{init(t){var e,i,s;super.init(t),this._onPrerenderBound=()=>{this.onPrerender()},this._layer=null;const n=this.theme,o=Qi(null!==(e=null==t?void 0:t.mode)&&void 0!==e?e:n.getMode(),zr);this._mode=o,this._alwaysOnTop=null!==(i=null==t?void 0:t.alwaysOnTop)&&void 0!==i?i:n.isAlwaysOnTop(),this._sticky=null!==(s=null==t?void 0:t.sticky)&&void 0!==s?s:n.isSticky(o);const r=this.toCloseOn(o,n,t);switch(this._closeOn=r,this._align=this.toAlign(o,n,t),this._overlay=new Hr,this._gesture=new Br(this,this.toGestureOptions(o,n,t)),this.visible=!1,o){case zr.MODAL:this.state.addAll(lt.FOCUS_ROOT,Ur.MODAL);break;case zr.MODELESS:this.state.add(Ur.MODELESS);break;case zr.MENU:this.state.addAll(lt.FOCUS_ROOT,Ur.MENU)}r&Nr.CLICK_OUTSIDE&&Fr.apply(this,()=>{this.onCloseOn()})}toCloseOn(t,e,i){const s=null==i?void 0:i.closeOn;if(null==s)return e.closeOn(t);if(vt(s)){let t=Nr.NONE;for(let e=0,i=s.length;e<i;++e)t|=Nr[s[e]];return t}return Et(s)?Nr[s]:s}toAlign(t,e,i){const s=null==i?void 0:i.align;return null===s?null:void 0===s?e.getAlign(t):Qi(s,kr)}get mode(){return this._mode}get align(){return this._align}set algin(t){this._align=t}get alwaysOnTop(){return this._alwaysOnTop}set alwaysOnTop(t){this._alwaysOnTop=t}get gesture(){return this._gesture}get layer(){return this._layer}toGestureOptions(t,e,i){const s=null==i?void 0:i.gesture;return!0===s?{enable:!0,mode:e.getGestureMode(t)}:!1===s?{enable:!1,mode:e.getGestureMode(t)}:null!=s?(void 0===s.enable&&(s.enable=e.isGestureEnabled(t)),void 0===s.mode&&(s.mode=e.getGestureMode(t)),s):{enable:e.isGestureEnabled(t),mode:e.getGestureMode(t)}}onParentResize(t,e,i){if(this.isOpened()){const t=this._layer;if(null!=t){const e=this._gesture;if(e.isDirty()){const i=this.position;e.constraint(this,t,i.x,i.y)}}}super.onParentResize(t,e,i)}getAnimation(){var t,e;let i=this._animation;return void 0===i&&(i=null!==(e=null===(t=this._options)||void 0===t?void 0:t.animation)&&void 0!==e?e:this.theme.newAnimation(this._mode),i&&(i.target=this,i.on("end",t=>{this.onAnimationEnd(t)})),this._animation=i),i}onAnimationEnd(t){if(t)if(this._mode===zr.MODELESS)this.hide();else{const t=this.parent;t&&t.removeChild(this)}else{const t=ot.getLayer(this);if(t){const e=t.getFocusController();this._focused=e.get(),e.focus(this.findFirstFocusable(e)||this)}}}findFirstFocusable(t){return t.find(this,!1,!0,!0)}open(t){let e=this._promise;if(null==e){e=new Promise((t,e)=>{this._resolve=t,this._reject=e}),this._promise=e,this._opener=t;let i=null;switch(this._mode){case zr.MODAL:case zr.MENU:i=this._overlay.pick(this,t),i.stage.addChild(this);break;case zr.MODELESS:i=ot.getLayer(this),this.show()}this._layer=i;const s=this._gesture;if(s.mode===Pr.CLEAN&&s.toClean(),null!=i)if(s.isClean()){const t=i.renderer,e=this._onPrerenderBound;this._sticky?t.on("prerender",e):t.once("prerender",e)}else{const t=this.position;s.constraint(this,i,t.x,t.y)}this.bringToFront(),this.onOpen()}return e}onChildFocus(t){super.onChildFocus(t),this.bringToFront()}onFocus(){super.onFocus(),this.bringToFront()}bringToFront(){const t=this.parent;if(null==t)return;const e=t.children,i=e.length;let s=i-1;for(;0<=s&&e[s]!==this;--s);if(!(s<0)){for(let t=s+1;t<i;++t)e[t-1]=e[t];e[i-1]=this,e.sort((t,e)=>(t instanceof Gr?t._alwaysOnTop?2:1:0)-(e instanceof Gr?e._alwaysOnTop?2:1:0))}}onPrerender(){var e;const i=this._layer;if(null==i)return;const s=this._align;if(s===kr.NONE)return;const n=this._opener;if(null!=s&&null!=n){const o=this._mode,r=n.getBounds(!1,null!==(e=Gr.WORK_BOUNDS)&&void 0!==e?e:Gr.WORK_BOUNDS=new t.Rectangle),a=this.theme;Lr.attach(this,r,a.getOffsetX(o),a.getOffsetY(o),i.width,i.height,s)}else this.position.set(.5*(i.width-this.width),.5*(i.height-this.height))}onOpen(){this.emit("open",this);const t=this.getAnimation();t?t.start():this._mode===zr.MENU&&(this.visible=!0,this.onAnimationEnd(!1))}isOpened(){return null!=this._promise}close(){this.doReject()}doResolve(t){const e=this._resolve;e&&(this._promise=void 0,this._resolve=void 0,this._reject=void 0,this.onClose(),e(t))}doReject(t){const e=this._reject;e&&(this._promise=void 0,this._resolve=void 0,this._reject=void 0,this.onClose(),e(t))}onClose(){const t=this._layer,e=this._focused;if(null!=e)if(this._focused=null,t){const i=ot.getLayer(e);null!=i&&t!==i&&i.view.focus(),t.getFocusController().focus(e)}else this.blur(!0);else this.blur(!0);t&&(t.renderer.off("prerender",this._onPrerenderBound),this._layer=null),this._opener=null;const i=this.getAnimation();if(i?i.start(!0):(this.visible=!1,this.onAnimationEnd(!0)),this._alwaysOnTop){const t=this.parent;null!=t&&t.off("childAdded",this._onParentChildAddedBound)}this.emit("close",this)}onKeyDown(t){return this._closeOn&Nr.ESC&&$n.isCancelKey(t)&&this.onCloseOn(),super.onKeyDown(t)}onCloseOn(){this.close()}containsGlobalPoint(t){switch(this._mode){case zr.MODAL:case zr.MENU:return!0;case zr.MODELESS:return super.containsGlobalPoint(t)}}getType(){return"DDialog"}}const Vr={VERTICAL:0,HORIZONTAL:1};class Wr extends to{constructor(t){super(t),this.visible=!1}getType(){return"DLayoutSpace"}}const Kr=t=>t instanceof to&&(t.visible||t instanceof Wr);class Xr extends to{init(t){super.init(t);const e=this.theme;this._margin=((t,e)=>{var i,s;const n=null==e?void 0:e.margin;if(null!=n){if(wt(n))return{horizontal:n,vertical:n};{const e=t.getMargin();return{horizontal:null!==(i=n.horizontal)&&void 0!==i?i:e,vertical:null!==(s=n.vertical)&&void 0!==s?s:e}}}{const e=t.getMargin();return{horizontal:e,vertical:e}}})(e,t),this._direction=((t,e)=>{const i=null==e?void 0:e.direction;return null!=i?Et(i)?Vr[i]:i:t.getDirection()})(e,t),this._cornerAdjust=((t,e)=>{const i=null==e?void 0:e.corner;if(null!=i&&!wt(i)){const t=i.adjust;if(null!=t)return t}return t.getCornerAdjust()})(e,t),this._multiplicity=((t,e)=>{if(e){const t=e.row;if(null!=t)return t;const i=e.column;if(null!=i)return i}return t.getMultiplicity()})(e,t),this._reverse=((t,e)=>{var i;return null!==(i=null==e?void 0:e.reverse)&&void 0!==i?i:t.getReverse()})(e,t)}get margin(){return this._margin}get multiplicity(){return this._multiplicity}getWeightTotal(){const t=this.children;let e=0;const i=this._multiplicity,s=this._reverse;for(let n=0,o=t.length;n<o;){let r=-1,a=0;for(;a<i&&n+a<o;++a){const e=t[s?o-1-(n+a):n+a];if(Kr(e)){const t=e.getClearType();if(0!==a&&t&Hn.BEFORE)break;if(r=Math.max(r,e.weight),t&&Hn.AFTER){a+=1;break}}else n+=1,a-=1}n+=a,0<=r&&(e+=r)}return e}getSpaceLeft(t,e){const i=this.children,s=this._multiplicity,n=this._reverse;if(this._direction===Vr.VERTICAL){let o=t,r=0;for(let t=0,a=i.length;t<a;){let h=0,l=-1,c=0;for(;c<s&&t+c<a;++c){const e=i[n?a-1-(t+c):t+c];if(Kr(e)){const t=e.getClearType();if(0!==c&&t&Hn.BEFORE)break;if(l=Math.max(l,e.weight),h=l<0?Math.max(h,e.height+r):r,t&Hn.AFTER){c+=1;break}}else t+=1,c-=1}t+=c,o-=h,r=e}return Math.max(0,o)}{let o=t,r=0;for(let t=0,a=i.length;t<a;){let h=0,l=-1,c=0;for(;c<s&&t+c<a;++c){const e=i[n?a-1-(t+c):t+c];if(Kr(e)){const t=e.getClearType();if(0!==c&&t&Hn.BEFORE)break;if(l=Math.max(l,e.weight),h=l<0?Math.max(h,e.width+r):r,t&Hn.AFTER){c+=1;break}}else t+=1,c-=1}t+=c,o-=h,r=e}return Math.max(0,o)}}calcSpaceLeft(t,e,i,s){return t?0:this.getSpaceLeft(e-i,s)}onRefit(){const t=this.children,e=this._padding,i=e.getTop(),s=e.getBottom(),n=e.getLeft(),o=e.getRight(),r=this._margin,a=r.vertical,h=r.horizontal,l=this.getWeightTotal(),c=this._multiplicity,u=this._reverse,d=this._auto;let p=null;if(this._cornerAdjust){const e=4+(t.length<<1);(null==Xr.CORNER_ADJUST_WORK||Xr.CORNER_ADJUST_WORK.length<e)&&(Xr.CORNER_ADJUST_WORK=new Float32Array(e)),p=Xr.CORNER_ADJUST_WORK,p[0]=-2,p[1]=-2,p[e-2]=-3,p[e-1]=-3}if(this._direction===Vr.VERTICAL){let e=0,o=i-a;if(0<l){const r=1/l,_=this.calcSpaceLeft(d.height.isOn,this.height,i+s,a);for(let i=0,s=t.length;i<s;){let l=n-h,d=0,g=0;for(;g<c&&i+g<s;++g){const n=t[u?s-1-(i+g):i+g];if(Kr(n)){const t=n.getClearType();if(0!==g&&t&Hn.BEFORE)break;{n.position.set(h+l,a+o);const s=n.weight;if(0<=s&&(n.height=_*(s*r)),l+=h+n.width,d=Math.max(d,n.height),t&Hn.AFTER){if(null!=p){const t=i+g+1<<1;p[t+0]=g,p[t+1]=e}g+=1;break}if(null!=p){const t=i+g+1<<1;p[t+0]=g,p[t+1]=e}}}else{if(null!=p){const t=i+g+1<<1;p[t+0]=g-1,p[t+1]=e}i+=1,g-=1}}o+=a+d,i+=g,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findRowIndexPrevious(i,o,p);this.hasClearTypeAfter(t,e)||(a=p[e])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findRowIndexNext(i,o,p);this.hasClearTypeBefore(t,e)||(h=p[e])}const l=this.countColumn(i,o,p);s.corner.mask=this.toCornerMaskColumn(a,n,h,l)}}}else{for(let i=0,s=t.length;i<s;){let r=n-h,l=0,d=0;for(;d<c&&i+d<s;++d){const n=t[u?s-1-(i+d):i+d];if(Kr(n)){const t=n.getClearType();if(0!==d&&t&Hn.BEFORE)break;if(n.position.set(h+r,a+o),0<=n.weight&&(n.height=0),r+=h+n.width,l=Math.max(l,n.height),t&Hn.AFTER){if(null!=p){const t=i+d+1<<1;p[t+0]=d,p[t+1]=e}d+=1;break}if(null!=p){const t=i+d+1<<1;p[t+0]=d,p[t+1]=e}}else{if(null!=p){const t=i+d+1<<1;p[t+0]=d-1,p[t+1]=e}i+=1,d-=1}}o+=a+l,i+=d,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findRowIndexPrevious(i,o,p);this.hasClearTypeAfter(t,e)||(a=p[e])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findRowIndexNext(i,o,p);this.hasClearTypeBefore(t,e)||(h=p[e])}const l=this.countColumn(i,o,p);s.corner.mask=this.toCornerMaskColumn(a,n,h,l)}}}}else{let e=0,s=n-h;if(0<l){const r=1/l,_=this.calcSpaceLeft(d.width.isOn,this.width,n+o,h);for(let n=0,o=t.length;n<o;){let l=i-a,d=0,g=0;for(;g<c&&n+g<o;++g){const i=t[u?o-1-(n+g):n+g];if(Kr(i)){const t=i.getClearType();if(0!==g&&t&Hn.BEFORE)break;{i.position.set(h+s,a+l);const o=i.weight;if(0<=o&&(i.width=_*(o*r)),d=Math.max(d,i.width),l+=a+i.height,t&Hn.AFTER){if(null!=p){const t=n+g+1<<1;p[t+0]=e,p[t+1]=g}g+=1;break}if(null!=p){const t=n+g+1<<1;p[t+0]=e,p[t+1]=g}}}else{if(null!=p){const t=n+g+1<<1;p[t+0]=e,p[t+1]=g-1}n+=1,g-=1}}s+=h+d,n+=g,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findColumnIndexPrevious(i,n,p);this.hasClearTypeAfter(t,e)||(a=p[e+1])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findColumnIndexNext(i,n,p);this.hasClearTypeBefore(t,e)||(h=p[e+1])}const l=this.countRow(i,n,p);s.corner.mask=this.toCornerMaskRow(a,o,h,l)}}}else{for(let n=0,o=t.length;n<o;){let r=i-a,l=0,d=0;for(;d<c&&n+d<o;++d){const i=t[u?o-1-(n+d):n+d];if(Kr(i)){const t=i.getClearType();if(0!==d&&t&Hn.BEFORE)break;if(i.position.set(h+s,a+r),0<=i.weight&&(i.width=0),l=Math.max(l,i.width),r+=a+i.height,t&Hn.AFTER){if(null!=p){const t=n+d+1<<1;p[t+0]=e,p[t+1]=d}d+=1;break}if(null!=p){const t=n+d+1<<1;p[t+0]=e,p[t+1]=d}}else{if(null!=p){const t=n+d+1<<1;p[t+0]=e,p[t+1]=d-1}n+=1,d-=1}}s+=h+l,n+=d,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findColumnIndexPrevious(i,n,p);this.hasClearTypeAfter(t,e)||(a=p[e+1])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findColumnIndexNext(i,n,p);this.hasClearTypeBefore(t,e)||(h=p[e+1])}const l=this.countRow(i,n,p);s.corner.mask=this.toCornerMaskRow(a,o,h,l)}}}}super.onRefit()}hasClearTypeBefore(t,e){return this.hasClearType(t,e,Hn.BEFORE)}hasClearTypeAfter(t,e){return this.hasClearType(t,e,Hn.AFTER)}hasClearType(t,e,i){if(2<=e){const s=e-2>>1;if(0<=s&&s<t.length){const e=t[s];if(e instanceof to)return!!(e.getClearType()&i)}}return!1}findColumnIndexPrevious(t,e,i){for(let s=t-2;0<=s;s-=2)if(i[s]!==e)return s;return 0}findColumnIndexNext(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2){const t=i[s];if(t!==e){for(let e=s+2;e<n;e+=2)if(i[e]!==t)return e-2;return s}}return i.length-2}countRow(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2)if(i[s]!==e)return i[s-2+1]+1;return 0}findRowIndexPrevious(t,e,i){for(let s=t-2;0<=s;s-=2)if(i[s+1]!==e)return s;return 0}findRowIndexNext(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2){const t=i[s+1];if(t!==e){for(let e=s+2;e<n;e+=2)if(i[e+1]!==t)return e-2;return s}}return i.length-2}countColumn(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2)if(i[s+1]!==e)return i[s-2+0]+1;return 0}toCornerMaskColumn(t,e,i,s){let n=Sn.NONE;return t+1<e&&0===e&&(n|=Sn.TOP_LEFT),i+1<e&&0===e&&(n|=Sn.BOTTOM_LEFT),t<e&&e+1===s&&(n|=Sn.TOP_RIGHT),i<e&&e+1===s&&(n|=Sn.BOTTOM_RIGHT),Sn.ALL&~n}toCornerMaskRow(t,e,i,s){let n=Sn.NONE;return t+1<e&&0===e&&(n|=Sn.TOP_LEFT),i+1<e&&0===e&&(n|=Sn.TOP_RIGHT),t<e&&e+1===s&&(n|=Sn.BOTTOM_LEFT),i<e&&e+1===s&&(n|=Sn.BOTTOM_RIGHT),Sn.ALL&~n}addSpace(t){return this.addChild(new Wr(t))}getType(){return"DLayout"}}Xr.CORNER_ADJUST_WORK=null;class Yr extends Xr{getType(){return"DLayoutVertical"}}class jr extends Yr{getType(){return"DDialogLayeredContent"}}const $r={CLICKED:0,DOUBLE_CLICKED:1},qr={TEXT:0,PADDING:1,BORDER:2},Zr={LEFT:0,CENTER:1,RIGHT:2},Jr={TOP:0,MIDDLE:1,BOTTOM:2};class Qr{constructor(){this._pieces=[],this._bounds=[],this._size=0,this._margin=0}clear(){this._pieces.length=0,this._bounds.length=0,this._size=0,this._margin=0,this._text=void 0}set(t){this._text=t}get size(){return this._size-(null===this._text?this._margin:0)}}class ta extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.height,this._margin=i}execute(t,e){const i=this._pieces,s=this._bounds;let n=e-t;if(void 0!==this._text){let t=0;for(let e=0,o=i.length;e<o;++e){const o=i[e],r=s[e],a=o.object;n-=t+r.height,a.y=n-r.y,t=o.margin.horizontal}}else for(let t=0,e=i.length;t<e;++t){const e=i[t],o=s[t],r=e.object;n-=e.margin.horizontal+o.height,r.y=n-o.y}}}class ea extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size=Math.max(this.size,e.width)}execute(t,e,i){const s=t+.5*(i-t-e),n=this._pieces,o=this._bounds;for(let t=0,e=n.length;t<e;++t){const e=n[t],i=o[t];e.object.x=s-i.x-.5*i.width}}}class ia extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.width,this._margin=i}execute(t){const e=this._pieces,i=this._bounds;let s=t;if(void 0!==this._text)for(let t=0,n=e.length;t<n;++t){const n=e[t],o=i[t];n.object.x=s-o.x,s+=o.width+n.margin.horizontal}else for(let t=0,n=e.length;t<n;++t){const n=e[t],o=i[t],r=n.object;s+=n.margin.horizontal,r.x=s-o.x,s+=o.width}}}class sa extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size=Math.max(this.size,e.height)}execute(t,e,i){const s=t+.5*(i-t-e),n=this._pieces,o=this._bounds;for(let t=0,e=n.length;t<e;++t){const e=n[t],i=o[t];e.object.y=s-i.y-.5*i.height}}}class na extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.width,this._margin=i}execute(t,e){const i=this._pieces,s=this._bounds;let n=e-t;if(void 0!==this._text){let t=0;for(let e=0,o=i.length;e<o;++e){const o=i[e],r=s[e],a=o.object;n-=t+r.width,a.x=n-r.x,t=o.margin.horizontal}}else for(let t=0,e=i.length;t<e;++t){const e=i[t],o=s[t],r=e.object;n-=e.margin.horizontal+o.width,r.x=n-o.x}}}class oa extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.height,this._margin=i}execute(t){const e=this._pieces,i=this._bounds;let s=t;if(void 0!==this._text){let t=0;for(let n=0,o=e.length;n<o;++n){const o=e[n],r=i[n];o.object.y=t+s-r.y,s+=r.height,t=o.margin.vertical}}else for(let t=0,n=e.length;t<n;++t){const n=e[t],o=i[t],r=n.object;s+=n.margin.vertical,r.y=s-o.y,s+=o.height}}}class ra{constructor(){this.left=new ia,this.center=new ea,this.right=new na,this.top=new oa,this.middle=new sa,this.bottom=new ta}clear(){this.left.clear(),this.center.clear(),this.right.clear(),this.top.clear(),this.middle.clear(),this.bottom.clear(),this.text=void 0}add(t){const e=t.object;if(null!=e){const i=e.getLocalBounds(),s=t.margin,n=t.align;switch(n.horizontal){case Zr.LEFT:this.left.add(t,i,s.horizontal);break;case Zr.CENTER:this.center.add(t,i,s.horizontal);break;case Zr.RIGHT:this.right.add(t,i,s.horizontal)}switch(n.vertical){case Jr.TOP:this.top.add(t,i,s.vertical);break;case Jr.MIDDLE:this.middle.add(t,i,s.vertical);break;case Jr.BOTTOM:this.bottom.add(t,i,s.vertical)}}}set(t){this.left.set(t),this.center.set(t),this.right.set(t),this.top.set(t),this.middle.set(t),this.bottom.set(t),this.text=t}get width(){const t=this.text,e=this.left.size,i=this.center.size,s=this.right.size;return void 0!==t?null!==t?Math.max(e+t.width+s,i):Math.max(e+s,i):Math.max(e,s,i)}get height(){const t=this.text,e=this.top.size,i=this.middle.size,s=this.bottom.size;return void 0!==t?null!==t?Math.max(e+t.height+s,i):Math.max(e+s,i):Math.max(e,s,i)}execute(t,e,i,s,n,o,r){const a=this.left,h=this.center,l=this.right,c=this.top,u=this.middle,d=this.bottom,p=this.text;if(void 0!==p){const _=a.size,g=l.size,f=c.size,m=d.size;let v=0,T=0,w=0;switch(null!=p&&(p.setClippingDelta(_+g,f+m),T=p.width,w=p.height),n.horizontal){case Zr.LEFT:v=t+_;break;case Zr.CENTER:v=t+.5*(o-t-i-(_+T+g))+_;break;case Zr.RIGHT:v=o-i-g-T}let E=0;switch(n.vertical){case Jr.TOP:E=e+f;break;case Jr.MIDDLE:E=e+.5*(r-e-s-(f+w+m))+f;break;case Jr.BOTTOM:E=r-s-m-w}null!=p&&p.position.set(v,E),a.execute(v-_),h.execute(0,0,2*v+T),l.execute(0,v+T+g),c.execute(E-f),u.execute(0,0,2*E+w),d.execute(0,E+w+m)}else a.execute(t),h.execute(t,i,o),l.execute(i,o),c.execute(e),u.execute(e,s,r),d.execute(s,r)}}class aa{constructor(){this.text=new ra,this.padding=new ra,this.border=new ra}clear(){this.text.clear(),this.padding.clear(),this.border.clear()}add(t){if(t.object)switch(t.align.with){case qr.TEXT:this.text.add(t);break;case qr.PADDING:this.padding.add(t);break;case qr.BORDER:this.border.add(t)}}set(t){this.text.set(t)}execute(t,e,i,s){const n=t.getLeft(),o=t.getTop(),r=t.getRight(),a=t.getBottom();null==i&&(i=n+this.width+r),null==s&&(s=o+this.height+a),this.border.execute(0,0,0,0,e,i,s),this.padding.execute(n,o,r,a,e,i,s),this.text.execute(n,o,r,a,e,i,s)}get width(){return Math.max(this.border.width,this.padding.width,this.text.width)}get height(){return Math.max(this.border.height,this.padding.height,this.text.height)}}class ha extends t.Graphics{constructor(t){super(),this.parent=t,this._isInitialized=!1,this._width=this.width,this._height=this.height}render(t){this.updateTransform(),super.render(t)}onReflow(t,e,i){this._isInitialized&&this._width===e&&this._height===i||(this._isInitialized=!0,this._width=e,this._height=i,this.clear(),this.beginFill(16777215,1),this.drawRect(0,0,e,i),this.endFill())}}class la{constructor(t,e,i,s){this.x=t,this.y=e,this.character=i,this.wrappable=s}set(t,e,i,s){this.x=t,this.y=e,this.character=i,this.wrappable=s}}class ca{constructor(){this.count=0,this.countPerLine=0,this.width=0,this.height=0,this.characters=[],this.scale=1,this.scaled=!1,this.clipped=!1,this.x=0,this.y=0}start(t,e){this.count=0,this.countPerLine=0,this.width=0,this.height=0,this.scale=1,this.scaled=!1,this.clipped=!1,this.x=0,this.y=.5*(t-e)}isPushable(t,e){return!(t<this.x+e.advance&&!(e.type&zs.SPACE))}isPushableAtNewLine(t,e,i){return this.y+1.5*e+.5*i<=t}push(t,e){const i=this.x;this.x+=t.advance;const s=this.y,n=this.count,o=this.characters;n<o.length?o[n].set(i,s,t,e):o.push(new la(i,s,t,e)),this.count+=1,this.countPerLine+=1}newLine(t){this.width=Math.max(this.width,this.x),this.x=0,this.y+=t,this.countPerLine=0}wordWrap(t){const e=this.countPerLine,i=this.characters;if(0<e){const s=this.count;for(let n=s-1,o=s-e;o<n;--n){let e=i[n];if(e.wrappable){let o=e.character.advance;const r=e.y+t;e.x=0,e.y=r;for(let t=n+1;t<s;++t)e=i[t],e.x=o,e.y=r,o+=e.character.advance;return this.x=o,this.y=r,this.countPerLine=s-n,!0}}const n=i[s-1];return n.x=0,n.y=n.y+t,this.x=n.character.advance,this.y=n.y,this.countPerLine=1,!1}return!1}pop(){const t=this.countPerLine,e=this.characters;if(0<t){const t=e[this.count-1];return this.x-=t.character.advance,this.count-=1,this.countPerLine-=1,!0}return!1}fit(t,e){const i=this.width,s=this.height;1e-4<i&&t<i?1e-4<s&&e<s?(this.scale=Math.min(t/i,e/s),this.scaled=!0):(this.scale=t/i,this.scaled=!0):1e-4<s&&e<s&&(this.scale=e/s,this.scaled=!0)}end(t,e){this.newLine(t),this.y-=.5*(t-e),this.height=this.y}}class ua{constructor(){this.target="",this.position=0}init(t){this.target=t,this.position=0}hasNext(){return this.position<this.target.length}findNextBreak(t,e){const i=t.length;for(let s=e;s<i;++s){const e=t.charCodeAt(s);if(!this.isLowSurrogate(e)&&!this.isVariationSelector(e))return s}return i}isHighSurrogate(t){return 55296<=t&&t<=56319}isLowSurrogate(t){return 56320<=t&&t<=57343}isVariationSelector(t){return 65024<=t&&t<=65039}next(){const t=this.target,e=this.position,i=this.findNextBreak(t,e+1),s=t.substring(e,i);return this.position=i,s}close(){const t=this.target.length;return this.position<t&&(this.position=t,!0)}static from(t){null==ua._instance&&(ua._instance=new ua);const e=ua._instance;return e.init(t),e}}ua._instance=null;const da={NONE:0,NORMAL:1,BREAK_ALL:2};class pa{static measure(t,e,i){const s=pa.RESULT||new ca;if(pa.RESULT=s,null!=e){const n=ua.from(t),o=e.font.height,r=i.lineHeight,a=i.fitting,h=!a&&i.clipping,l=i.width,c=i.height,u=!a&&i.wordWrap;switch(s.start(r,o),u){case da.BREAK_ALL:h?this.measure1(n,l,c,o,r,e,s):this.measure2(n,l,r,e,s);break;case da.NORMAL:const i=this.newLineBreaker(t);i?h?this.measure1a(i,n,l,c,o,r,e,s):this.measure2a(i,n,l,r,e,s):h?this.measure1b(n,l,c,o,r,e,s):this.measure2b(n,l,r,e,s);break;default:h?this.measure3(n,l,c,o,r,e,s):this.measure4(n,r,e,s)}s.end(r,o),a&&s.fit(l,c)}else s.start(0,0),s.end(0,0);return s}static measure1a(t,e,i,s,n,o,r,a){let h=t.next();for(;e.hasNext();){const l=e.position,c=e.next();if(c===D.NEW_LINE)a.isPushableAtNewLine(s,o,n)?a.newLine(o):this.measure5(e,i,o,r,a,!0);else{const u=r.get(c);if(null==u)continue;h=this.advance(l,h,t);const d=this.isWrappable1(l,h);a.isPushable(i,u)?a.push(u,d):a.isPushableAtNewLine(s,o,n)?(a.push(u,d),a.wordWrap(o)):this.measure5(e,i,o,r,a,!0)}}}static measure1b(t,e,i,s,n,o,r){for(;t.hasNext();){const a=t.next();if(a===D.NEW_LINE)r.isPushableAtNewLine(i,n,s)?r.newLine(n):this.measure5(t,e,n,o,r,!0);else{const h=o.get(a);if(null==h)continue;const l=this.isWrappable2(r,h);r.isPushable(e,h)?r.push(h,l):r.isPushableAtNewLine(i,n,s)?(r.push(h,l),r.wordWrap(n)):this.measure5(t,e,n,o,r,!0)}}}static measure1(t,e,i,s,n,o,r){for(;t.hasNext();){const a=t.next();if(a===D.NEW_LINE)r.isPushableAtNewLine(i,n,s)?r.newLine(n):this.measure5(t,e,n,o,r,!0);else{const h=o.get(a);if(null==h)continue;r.isPushable(e,h)?r.push(h,!0):r.isPushableAtNewLine(i,n,s)?(r.newLine(n),r.push(h,!0)):this.measure5(t,e,n,o,r,!0)}}}static measure2a(t,e,i,s,n,o){let r=t.next();for(;e.hasNext();){const a=e.position,h=e.next();if(h===D.NEW_LINE)o.newLine(s);else{const e=n.get(h);if(null==e)continue;r=this.advance(a,r,t);const l=this.isWrappable1(a,r);o.isPushable(i,e)?o.push(e,l):(o.push(e,l),o.wordWrap(s))}}}static measure2b(t,e,i,s,n){for(;t.hasNext();){const o=t.next();if(o===D.NEW_LINE)n.newLine(i);else{const t=s.get(o);if(null==t)continue;const r=this.isWrappable2(n,t);n.isPushable(e,t)?n.push(t,r):(n.push(t,r),n.wordWrap(i))}}}static measure2(t,e,i,s,n){for(;t.hasNext();){const o=t.next();if(o===D.NEW_LINE)n.newLine(i);else{const t=s.get(o);if(null==t)continue;n.isPushable(e,t)||n.newLine(i),n.push(t,!1)}}}static measure3(t,e,i,s,n,o,r){for(;t.hasNext();){const a=t.next();if(a===D.NEW_LINE)r.isPushableAtNewLine(i,n,s)?r.newLine(n):this.measure5(t,e,n,o,r,!0);else{const i=o.get(a);if(null==i)continue;r.isPushable(e,i)?r.push(i,!1):this.measure5(t,e,n,o,r,!1)}}}static measure4(t,e,i,s){for(;t.hasNext();){const n=t.next();if(n===D.NEW_LINE)s.newLine(e);else{const t=i.get(n);if(null==t)continue;s.push(t,!1)}}}static measure5(t,e,i,s,n,o){n.clipped=!0;const r=s.get(D.DOTS);if(null!=r){for(;!n.isPushable(e,r)&&n.pop(););n.isPushable(e,r)&&n.push(r,!1)}if(o)t.close();else for(;t.hasNext();)if(t.next()===D.NEW_LINE){n.newLine(i);break}}static isWrappable2(t,e){if(t.countPerLine<=0)return!1;const i=t.characters[t.count-1].character.type,s=e.type;return i&zs.SPACE?!(s&zs.SPACE||i&zs.NON_BREAKING):!(s&zs.SPACE||i&zs.NON_BREAKING&&s&zs.NON_BREAKING)}static advance(t,e,i){return e.done||t<=e.value.end?e:e=i.next()}static isWrappable1(t,e){if(e.done)return!1;const i=e.value;return i.start===t||i.end===t}static newLineBreaker(t){return"css-line-break"in window?window["css-line-break"].LineBreaker(t,{lineBreak:"strict",wordBreak:"normal"}):null}}pa.RESULT=null;class _a extends t.MeshGeometry{constructor(){var t,e,i;super(null!==(t=_a.VERTICES)&&void 0!==t?t:_a.VERTICES=new Float32Array(0),null!==(e=_a.UVS)&&void 0!==e?e:_a.UVS=new Float32Array(0),null!==(i=_a.INDICES)&&void 0!==i?i:_a.INDICES=new Uint16Array(0)),this.width=0,this.height=0,this.scale=1,this.scaled=!1,this.clipped=!1,this.vertexBuffer=this.getBuffer("aVertexPosition"),this.vertices=_a.VERTICES,this.uvBuffer=this.getBuffer("aTextureCoord"),this.uvs=_a.UVS,this.indexBuffer=this.getIndex(),this.indices=_a.INDICES,this.nchars=0}update(t,e,i){const s=pa.measure(t,e,i),n=s.count;let o=(n>>3)+(7&n?1:0)<<3;if(this.nchars<o){this.nchars=o;const t=o<<3;this.vertices=new Float32Array(t),this.uvs=new Float32Array(t),this.vertexBuffer.data=this.vertices,this.uvBuffer.data=this.uvs;const e=(o<<2)+(o<<1);this.indices=new Uint16Array(e),this.indexBuffer.data=this.indices,this.initIndices(this.indices),this.indexBuffer.update()}else o=this.nchars;if(o<=0)return;const r=this.vertices,a=this.uvs;if(null!=e){const t=s.characters,i=s.scale,h=1/e.width,l=1/e.height;for(let e=0;e<n;++e){const s=t[e],n=s.x,o=s.y,c=s.character;this.fill(r,a,e,n,o,i,c,h,l)}for(let t=n;t<o;++t)this.fillBlank(r,a,t);this.width=s.width*i,this.height=s.height*i,this.scale=i,this.scaled=s.scaled,this.clipped=s.clipped}else{for(let t=0;t<o;++t)this.fillBlank(r,a,t);this.width=0,this.height=0,this.scale=1,this.scaled=!1,this.clipped=!1}this.vertexBuffer.update(),this.uvBuffer.update()}fill(t,e,i,s,n,o,r,a,h){const l=r.x,c=r.y,u=r.width,d=r.height,p=(s+(l-r.origin.x))*o,_=n*o,g=p+u*o,f=_+d*o,m=i<<3;t[m+0]=p,t[m+1]=_,t[m+2]=g,t[m+3]=_,t[m+4]=g,t[m+5]=f,t[m+6]=p,t[m+7]=f;const v=l*a,T=c*h,w=(l+u)*a,E=(c+d)*h;e[m+0]=v,e[m+1]=T,e[m+2]=w,e[m+3]=T,e[m+4]=w,e[m+5]=E,e[m+6]=v,e[m+7]=E}fillBlank(t,e,i){const s=i<<3;t[s+0]=0,t[s+1]=0,t[s+2]=0,t[s+3]=0,t[s+4]=0,t[s+5]=0,t[s+6]=0,t[s+7]=0,e[s+0]=0,e[s+1]=0,e[s+2]=0,e[s+3]=0,e[s+4]=0,e[s+5]=0,e[s+6]=0,e[s+7]=0}initIndices(t){for(let e=0,i=this.nchars<<2,s=0;e<i;e+=4,s+=6)t[s]=e,t[s+1]=e+1,t[s+2]=e+3,t[s+3]=e+1,t[s+4]=e+2,t[s+5]=e+3}}class ga extends t.Mesh{constructor(e){super(new _a,new t.MeshMaterial(t.Texture.EMPTY)),this._style=e,e.on("change",()=>{this.onStyleChange()}),this._text="",this._textApproved="",this._isDirty=!0,this._isGeometryDirty=!0,this._atlas=null,this._atlasRevisionUpdated=0,this._width=0,this._height=0,this._modifier={clipping:!1,fitting:!1,wordWrap:da.NONE,width:0,height:0,lineHeight:0,delta:{width:0,height:0}}}onStyleChange(){this._isDirty=!0,this._isGeometryDirty=!0,this._atlas=null,this.update_()}update_(){const t=ot.getLayer(this);if(t&&this._isDirty){this._isDirty=!1;const e=this._text,i=this._textApproved;this._textApproved=e;const s=this._style,n=s.fontId,o=s.fontIdApproved,r=s.fontIdFontSize,a=s.fill,h=s.fillApproved;s.approve();const l=t.getDynamicFontAtlases();e===i&&n===o&&a===h||(l.add(n,r,a,e),l.remove(o,h,i))}}get text(){return this._text}set text(t){this._text!==t&&(this._text=t,this._style.unfit()||(this._isDirty=!0,this._isGeometryDirty=!0,this.update_()))}get width(){return this.update(),Math.abs(this.scale.x)*this.geometry.width}set width(t){this.update();const e=this.geometry.width;if(1e-4<e){const i=t/e;this.scale.x=0<=this.scale.x?+i:-i}}get height(){return this.update(),Math.abs(this.scale.y)*this.geometry.height}set height(t){this.update();const e=this.geometry.height;if(1e-4<e){const i=t/e;this.scale.y=0<=this.scale.y?+i:-i}}get clipped(){return this.geometry.clipped}get style(){return this._style}update(){this.update_();const t=this._style;let e=this._atlas;if(null==e){const i=ot.getLayer(this);i&&(e=i.getDynamicFontAtlases().get(t.fontId,t.fill),null!=e&&(this._atlasRevisionUpdated=e.getRevisionUpdate(),this._atlas=e,this.texture=e.texture,this._isGeometryDirty=!0))}else{const t=e.getRevisionUpdate();t!==this._atlasRevisionUpdated&&(this._atlasRevisionUpdated=t,this._isGeometryDirty=!0)}const i=this._modifier;if(this.updateClipping(t,i)&&(this._isGeometryDirty=!0),this._isGeometryDirty){this._isGeometryDirty=!1;const s=this.geometry;if(s.update(this._text,e,i),i.fitting&&!t.isFontFitted&&s.scaled){const e=s.scale,i=t.fontSize,n=t.toFontId(Math.ceil(i*e*1e3)/1e3),o=Hs.toSize(n),r=o/i,a=t.lineHeight*r;t.fit(o,a)&&setTimeout(()=>{ot.update(this)},0)}}}updateClipping(t,e){let i=!1;const s=t.clipping;e.clipping!==s&&(e.clipping=s,i=!0);const n=t.fitting;e.fitting!==n&&(e.fitting=n,i=!0);const o=t.wordWrap;e.wordWrap!==o&&(e.wordWrap=o,i=!0);const r=n?t.lineHeightFitted:t.lineHeight;if(e.lineHeight!==r&&(e.lineHeight=r,i=!0),s||n||o){const t=this.parent;if(t instanceof to){const s=t.padding,n=t.width-s.getLeft()-s.getRight()-e.delta.width;e.width!==n&&(e.width=n,i=!0);const o=t.height-s.getTop()-s.getBottom()-e.delta.height;e.height!==o&&(e.height=o,i=!0)}}return i}setClippingDelta(t,e){const i=this._modifier.delta;i.width=t,i.height=e}_calculateBounds(){this.update();const t=this.geometry;this._bounds.addFrame(this.transform,0,0,t.width,t.height)}_render(t){this.update(),super._render(t)}}class fa extends t.utils.EventEmitter{constructor(t,e,i){var s,n,o,r,a,h,l,c,u;super(),this._id=0,this._idApproved=-1,i?(this._fontFamily=null!==(s=i.fontFamily)&&void 0!==s?s:e.getFontFamilly(),this._fontSize=null!==(n=i.fontSize)&&void 0!==n?n:e.getFontSize(),this._fontStyle=null!==(o=i.fontStyle)&&void 0!==o?o:e.getFontStyle(),this._fontVariant=null!==(r=i.fontVariant)&&void 0!==r?r:e.getFontVariant(),this._fontWeight=null!==(a=i.fontWeight)&&void 0!==a?a:e.getFontWeight(),this._clipping=null!==(h=i.clipping)&&void 0!==h?h:e.getTextStyleClipping(),this._fitting=null!==(l=i.fitting)&&void 0!==l?l:e.getTextStyleFitting(),this._wordWrap=Qi(null!==(c=i.wordWrap)&&void 0!==c?c:e.getTextStyleWordWrap(),da),this._lineHeight=null!==(u=i.lineHeight)&&void 0!==u?u:e.getLineHeight()):(this._fontFamily=e.getFontFamilly(),this._fontSize=e.getFontSize(),this._fontStyle=e.getFontStyle(),this._fontVariant=e.getFontVariant(),this._fontWeight=e.getFontWeight(),this._clipping=e.getTextStyleClipping(),this._fitting=e.getTextStyleFitting(),this._wordWrap=e.getTextStyleWordWrap(),this._lineHeight=e.getLineHeight()),this._fill=e.getColor(t.state),this._fontSizeFitted=this._fontSize,this._lineHeightFitted=this._lineHeight,this._isFontFitted=!1,this._fontIdFontSize=this._fontSize,this._fontIdId=-1,this._fontId="",this._fontIdApproved="",this._fillApproved=0}get id(){return this._id}get idApproved(){return this._idApproved}get fontId(){return this.update(),this._fontId}get fontIdFontSize(){return this.update(),this._fontSizeFitted}get fontIdApproved(){return this._fontIdApproved}get fill(){return this._fill}set fill(t){this._fill!==t&&(this._fill=t,this.onChange())}onChange(){this._id+=1,this.emit("change",this)}get fillApproved(){return this._fillApproved}approve(){this.update(),this._idApproved=this._id,this._fontIdApproved=this._fontId,this._fillApproved=this._fill}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.onChange())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this._fontSizeFitted=t,this._lineHeightFitted=this._lineHeight,this._isFontFitted=!1,this.onChange())}get fontSizeFitted(){return this._fontSizeFitted}get isFontFitted(){return this._isFontFitted}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.onChange())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.onChange())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.onChange())}update(){if(this._fontIdId!==this._id){this._fontIdId=this._id;const t=this._fitting?this._fontSizeFitted:this._fontSize;this._fontIdFontSize=t,this._fontId=this.toFontId(t)}}toFontId(t){return`${this._fontStyle} ${this._fontVariant} ${this._fontWeight} ${t}px ${this._fontFamily}`}get clipping(){return this._clipping}set clipping(t){this._clipping!==t&&(this._clipping=t,this.onChange())}get fitting(){return this._fitting}set fitting(t){this._fitting!==t&&(this._fitting=t,this.onChange())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.onChange())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this._fontSizeFitted=this._fontSize,this._lineHeightFitted=t,this._isFontFitted=!1,this.onChange())}get lineHeightFitted(){return this._lineHeightFitted}set lineHeightFitted(t){this._lineHeightFitted!==t&&(this._lineHeightFitted=t,this.onChange())}fit(t,e){let i=!1;return t<this._fontSizeFitted&&(this._fontSizeFitted=t,i=!0),this._lineHeightFitted!==e&&(this._lineHeightFitted=e,i=!0),!0!==this._isFontFitted&&(this._isFontFitted=!0,i=!0),i&&this.onChange(),i}unfit(){let t=!1;return!1!==this._isFontFitted&&(this._isFontFitted=!1,t=!0),this._fontSizeFitted!==this._fontSize&&(this._fontSizeFitted=this._fontSize,t=!0),this._lineHeightFitted!==this._lineHeight&&(this._lineHeightFitted=this._lineHeight,t=!0),t&&this.onChange(),t}}class ma{constructor(t,e,i){var s,n;this._parent=t,this._vertical=Qi(null!==(s=null==i?void 0:i.vertical)&&void 0!==s?s:e.getTextAlignVertical(),Jr),this._horizontal=Qi(null!==(n=null==i?void 0:i.horizontal)&&void 0!==n?n:e.getTextAlignHorizontal(),Zr)}get vertical(){return this._vertical}set vertical(t){t=Qi(t,Jr),this._vertical!==t&&(this._vertical=t,this.onChange())}get horizontal(){return this._horizontal}set horizontal(t){t=Qi(t,Zr),this._horizontal!==t&&(this._horizontal=t,this.onChange())}set(t,e){let i=!1;return null!=t&&(t=Qi(t,Jr),this._vertical!==t&&(this._vertical=t,i=!0)),null!=e&&(e=Qi(e,Zr),this._horizontal!==e&&(this._horizontal=e,i=!0)),i&&this.onChange(),this}onChange(){const t=this._parent;t.toDirty(),ot.update(t)}}class va{constructor(t,e){this._parent=t,this._style=e}get fontFamily(){return this._style.fontFamily}set fontFamily(t){const e=this._style;e.fontFamily!==t&&(e.fontFamily=t,this.onChange())}get fontSize(){return this._style.fontSize}set fontSize(t){const e=this._style;e.fontSize!==t&&(e.fontSize=t,this.onChange())}get fontStyle(){return this._style.fontStyle}set fontStyle(t){const e=this._style;e.fontStyle!==t&&(e.fontStyle=t,this.onChange())}get fontVariant(){return this._style.fontVariant}set fontVariant(t){const e=this._style;e.fontVariant!==t&&(e.fontVariant=t,this.onChange())}get fontWeight(){return this._style.fontWeight}set fontWeight(t){const e=this._style;e.fontWeight!==t&&(e.fontWeight=t,this.onChange())}get clipping(){return this._style.clipping}set clipping(t){const e=this._style;e.clipping!==t&&(e.clipping=t,this.onChange())}get fitting(){return this._style.fitting}set fitting(t){const e=this._style;e.fitting!==t&&(e.fitting=t,this.onChange())}get wordWrap(){return this._style.wordWrap}set wordWrap(t){t=Qi(t,da);const e=this._style;e.wordWrap!==t&&(e.wordWrap=t,this.onChange())}get lineHeight(){return this._style.lineHeight}set lineHeight(t){const e=this._style;e.lineHeight!==t&&(e.lineHeight=t,this.onChange())}onChange(){ot.update(this._parent)}}class Ta extends t.utils.EventEmitter{constructor(t,e,i){var s,n;super(),this._parent=t,this._theme=e,this._value=null!==(s=null==i?void 0:i.value)&&void 0!==s?s:e.newTextValue(),this._computed=this.newComputed(),this._color=null==i?void 0:i.color,this._alpha=null==i?void 0:i.alpha;const o=new fa(t,e,null==i?void 0:i.style);this._dstyle=o,this._style=new va(t,o),this._align=new ma(t,e,null==i?void 0:i.align),this._formatter=null!==(n=null==i?void 0:i.formatter)&&void 0!==n?n:e.getTextFormatter(),this._isVisible=!0,this.onComputedChange(),this.updateObject()&&(t.toDirty(),ot.update(t))}get value(){return this._value}set value(t){this._value!==t&&(this._value=t,this.onValueChange())}getValue(){return this._value}setValue(t,e){(e||this._value!==t)&&(this._value=t,this.onValueChange(e))}onValueChange(t){const e=this.newComputed();if((t||this._computed!==e)&&(this._computed=e,this.onComputedChange(),this.updateObject())){const t=this._parent;t.toDirty(),ot.update(t)}}compute(t){this.onValueChange(t)}get computed(){return this._computed}get formatter(){return this._formatter}set formatter(t){this._formatter!==t&&(this._formatter=t,this.onValueChange(!0))}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onColorChange())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onColorChange())}onColorChange(){const t=this._object;if(null!=t){const e=this._parent,i=e.state,s=this.newColor(i),n=this.newAlpha(i),o=t.style;o.fill===s&&t.alpha===n||(o.fill=s,t.alpha=n,ot.update(e))}}get align(){return this._align}get style(){return this._style}get object(){return this._object}update(t){const e=this.newComputed();this._computed!==e&&(this._computed=e,this.onComputedChange(),this.updateObject());const i=this._object;if(null!=i){const e=this._parent.state;i.style.fill=this.newColor(e),i.alpha=this.newAlpha(e),t.set(i)}else t.set(null)}updateObject(){const t=this._computed;if(void 0!==t){const e=this._formatter(t,this._parent),i=this._object;if(null==i){if(0<e.length){const t=this.newObject();t.visible=this._isVisible,this._object=t;const i=this._parent;i.addChild(t);const s=i.getOverflowMask();return s&&(t.mask=s),t.text=e,!0}}else if(i.text!==e)return i.text=e,!0}else{const t=this._object;if(null!=t&&""!==t.text)return t.text="",!0}return!1}newComputed(){const t=this._value;if(void 0!==t){if(!Tt(t))return t;{const e=t(this._parent.state);if(void 0!==e)return e}}return this._theme.getTextValue(this._parent.state)}newColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getColor(t)}newAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getAlpha(t)}newObject(){return new ga(this._dstyle)}get visible(){const t=this._object;return null!=t?t.visible:this._isVisible}set visible(t){const e=this._object;null!=e&&(e.visible=t),this._isVisible=t}show(){return this.visible=!0,this}hide(){return this.visible=!1,this}isShown(){return this.visible}onComputedChange(){this.emit("change",this)}destroy(){const t=this._object;return t&&(this._object=void 0,t.destroy()),this}}class wa extends to{init(t){super.init(t),this.getText()}getOverflowMask(){let t=this._overflowMask;return void 0===t&&(t=this.newOverflowMask(),this._overflowMask=t),null}newOverflowMask(){var t,e;if(null!==(e=null===(t=this._options)||void 0===t?void 0:t.mask)&&void 0!==e?e:this.theme.isOverflowMaskEnabled()){const t=new ha(this);return this._reflowable.add(t),this.toDirty(),t}return null}get text(){var t;return null!==(t=this._text)&&void 0!==t?t:this._text=this.newText()}getText(){var t;return null!==(t=this._text)&&void 0!==t?t:this._text=this.newText()}newText(){var t;return new Ta(this,this.theme,null===(t=this._options)||void 0===t?void 0:t.text)}set text(t){this.text.value=t}onReflow(){super.onReflow(),this.onReflowTextAndImage()}getLayouter(){var t;return null!==(t=wa.LAYOUTER)&&void 0!==t?t:wa.LAYOUTER=new aa}onReflowTextAndImage(){const t=this.getLayouter(),e=this.getText();e.update(t);const i=this._auto;t.execute(this._padding,e.align,i.width.isOn?null:this.width,i.height.isOn?null:this.height),t.clear()}isRefitable(t){if(super.isRefitable(t))return!0;if(null!=t){const e=this._text;if(null!=e&&t===e.object)return!0}return!1}applyTitle(){const t=this.text.object;if(this._title.length<=0&&null!=t&&t.clipped){const e=ot.getLayer(this);e&&(e.view.title=t.text)}else super.applyTitle()}getType(){return"DTextBase"}destroy(){const t=this._text;t&&t.destroy();const e=this._overflowMask;e&&(this._overflowMask=null,e.destroy()),super.destroy()}}class Ea{constructor(t){this._theme=t}getImageAlignHorizontal(){return this._theme.getImageAlignHorizontal()}getImageAlignVertical(){return this._theme.getImageAlignVertical()}getImageAlignWith(){return this._theme.getImageAlignWith()}getImageMarginHorizontal(){return this._theme.getImageMarginHorizontal()}getImageMarginVertial(){return this._theme.getImageMarginVertial()}getImageTintColor(t){return this._theme.getImageTintColor(t)}getImageTintAlpha(t){return this._theme.getImageTintAlpha(t)}getImageRotation(t){return this._theme.getImageRotation(t)}getImageSource(t){return null}}class ya{constructor(t){this._theme=t}getImageAlignHorizontal(){return this._theme.getSecondaryImageAlignHorizontal()}getImageAlignVertical(){return this._theme.getSecondaryImageAlignVertical()}getImageAlignWith(){return this._theme.getSecondaryImageAlignWith()}getImageMarginHorizontal(){return this._theme.getSecondaryImageMarginHorizontal()}getImageMarginVertial(){return this._theme.getSecondaryImageMarginVertial()}getImageTintColor(t){return this._theme.getSecondaryImageTintColor(t)}getImageTintAlpha(t){return this._theme.getSecondaryImageTintAlpha(t)}getImageRotation(t){return this._theme.getSecondaryImageRotation(t)}getImageSource(t){var e,i,s;return null!==(s=null===(i=(e=this._theme).getSecondaryImageSource)||void 0===i?void 0:i.call(e,t))&&void 0!==s?s:null}}class xa{constructor(t){this._theme=t}getImageAlignHorizontal(){return this._theme.getTertiaryImageAlignHorizontal()}getImageAlignVertical(){return this._theme.getTertiaryImageAlignVertical()}getImageAlignWith(){return this._theme.getTertiaryImageAlignWith()}getImageMarginHorizontal(){return this._theme.getTertiaryImageMarginHorizontal()}getImageMarginVertial(){return this._theme.getTertiaryImageMarginVertial()}getImageTintColor(t){return this._theme.getTertiaryImageTintColor(t)}getImageTintAlpha(t){return this._theme.getTertiaryImageTintAlpha(t)}getImageRotation(t){return this._theme.getTertiaryImageRotation(t)}getImageSource(t){var e,i,s;return null!==(s=null===(i=(e=this._theme).getTertiaryImageSource)||void 0===i?void 0:i.call(e,t))&&void 0!==s?s:null}}class Ca{constructor(t,e,i){this._parent=t,null!=i&&(this._color=i.color,this._alpha=i.alpha),this._theme=e}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onChange())}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getImageTintColor(t)}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onChange())}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getImageTintAlpha(t)}set(t,e){let i=!1;return null!=t&&this._color!==t&&(this._color=t,i=!0),null!=e&&this._alpha!==e&&(this._alpha=e,i=!0),i&&this.onChange(),this}onChange(){this._parent.updateTint(),ot.update(this._parent)}}class Da{constructor(t,e,i){var s,n;this._parent=t,this._vertical=null!==(s=null==i?void 0:i.vertical)&&void 0!==s?s:e.getImageMarginVertial(),this._horizontal=null!==(n=null==i?void 0:i.horizontal)&&void 0!==n?n:e.getImageMarginHorizontal()}get vertical(){return this._vertical}set vertical(t){this._vertical!==t&&(this._vertical=t,this.onChange())}get horizontal(){return this._horizontal}set horizontal(t){this._horizontal!==t&&(this._horizontal=t,this.onChange())}set(t,e){let i=!1;return null!=t&&this._vertical!==t&&(this._vertical=t,i=!0),null!=e&&this._horizontal!==e&&(this._horizontal=e,i=!0),i&&this.onChange(),this}onChange(){this._parent.onUpdate()}}class Sa{constructor(t,e,i){var s,n,o;this._parent=t,this._with=Qi(null!==(s=null==i?void 0:i.with)&&void 0!==s?s:e.getImageAlignWith(),qr),this._vertical=Qi(null!==(n=null==i?void 0:i.vertical)&&void 0!==n?n:e.getImageAlignVertical(),Jr),this._horizontal=Qi(null!==(o=null==i?void 0:i.horizontal)&&void 0!==o?o:e.getImageAlignHorizontal(),Zr)}get with(){return this._with}set with(t){t=Qi(t,qr),this._with!==t&&(this._with=t,this.onChange())}get vertical(){return this._vertical}set vertical(t){t=Qi(t,Jr),this._vertical!==t&&(this._vertical=t,this.onChange())}get horizontal(){return this._horizontal}set horizontal(t){t=Qi(t,Zr),this._horizontal!==t&&(this._horizontal=t,this.onChange())}set(t,e,i){let s=!1;return null!=t&&(t=Qi(t,qr),this._with!==t&&(this._with=t,s=!0)),null!=e&&(e=Qi(e,Jr),this._vertical!==e&&(this._vertical=e,s=!0)),null!=i&&(i=Qi(i,Zr),this._horizontal!==i&&(this._horizontal=i,s=!0)),s&&this.onChange(),this}onChange(){this._parent.onUpdate()}}class ba{constructor(t,e,i){this._parent=t,this._theme=e,this._object=null,this._align=new Sa(this,e,null==i?void 0:i.align),this._margin=new Da(this,e,null==i?void 0:i.margin),this._tint=new Ca(this,e,null==i?void 0:i.tint),this._rotation=null==i?void 0:i.rotation,this._source=null==i?void 0:i.source,this._computed=null,this._onUpdateBound=()=>{this.onUpdate()}}get object(){return this._object}get align(){return this._align}get margin(){return this._margin}get tint(){return this._tint}get source(){return this._source}set source(t){this._source!==t&&(this._source=t,this.updateSource()&&this.onUpdate())}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateRotation()&&ot.update(this._parent))}computeSource(){const t=this._source;if(void 0!==t){if(!Tt(t))return t;{const e=t(this._parent.state);if(void 0!==e)return e}}return this._theme.getImageSource(this._parent.state)}onStateChange(t,e){this.updateTint(),this.updateRotation()}isTintAware(t){return null!=t&&"tint"in t}updateTint(){const t=this._object;if(t&&this.isTintAware(t)){const e=this._parent.state,i=this._tint.getColor(e);if(null!=i){let s=!1;t.tint!==i&&(t.tint=i,s=!0);const n=this._tint.getAlpha(e);return t.alpha!==n&&(t.alpha=n,s=!0),t.visible||(t.visible=!0,s=!0),s}if(t.visible)return t.visible=!1,!0}return!1}toRotation(t,e){const i=this._rotation;if(null!=i){if(!Tt(i))return i;{const t=i(e);if(void 0!==t)return t}}return t.getImageRotation(e)}updateRotation(){const t=this._object;if(t){const e=this._theme,i=this._parent.state,s=this.toRotation(e,i);if(null!=s){const e=t.transform;if(e.rotation!==s)return e.rotation=s,!0}}return!1}updateSource(){const e=this.computeSource(),i=this._computed;if(e!==i){this._computed=e;const s=this._parent,n=this._object,o=this._onUpdateBound;if(e instanceof t.Texture)if(i instanceof t.Texture)i.off("update",o),n instanceof t.Sprite&&(n.texture=e,e.on("update",o));else{null!=n&&s.removeChild(n);const i=new t.Sprite(e);i.anchor.set(.5,.5);const r=s.getOverflowMask();r&&(i.mask=r),e.on("update",o),s.addChild(i),this._object=i}else{if(i instanceof t.Texture?(i.off("update",o),null!=n&&(s.removeChild(n),n.destroy())):null!=n&&s.removeChild(n),null!=e){const t=s.getOverflowMask();t&&(e.mask=t),s.addChild(e)}this._object=e}return!0}return!1}isRefitable(t){return null!=t&&t===this._object}destroy(){this.source=null}onUpdate(){this._parent.toDirty(),ot.update(this._parent)}}class Ia{constructor(t,e,i){this._parent=t,this._theme=e;const s=[];if(this._pieces=s,null!=i){const t=i.images;if(null!=t){if(s.push(this.newImage(e,0<t.length?t[0]:void 0)),(null!=e.getSecondaryImageSource||1<t.length)&&s.push(this.newImage(new ya(e),t[1])),(null!=e.getTertiaryImageSource||2<t.length)&&s.push(this.newImage(new xa(e),t[2])),3<t.length){const i=new Ea(e);for(let e=3,n=t.length;e<n;++e)s.push(this.newImage(i,t[e]))}}else s.push(this.newImage(e,i.image)),null!=e.getSecondaryImageSource&&s.push(this.newImage(new ya(e))),null!=e.getTertiaryImageSource&&s.push(this.newImage(new xa(e)))}else s.push(this.newImage(e)),null!=e.getSecondaryImageSource&&s.push(this.newImage(new ya(e))),null!=e.getTertiaryImageSource&&s.push(this.newImage(new xa(e)))}newImage(t,e){return new ba(this._parent,t,e)}onStateChange(t,e){const i=this._pieces;for(let s=0,n=i.length;s<n;++s)i[s].onStateChange(t,e)}isRefitable(t){const e=this._pieces;for(let i=0,s=e.length;i<s;++i)if(e[i].isRefitable(t))return!0;return!1}update(t){const e=this._pieces;for(let i=0,s=e.length;i<s;++i){const s=e[i];s.updateSource(),s.updateTint(),s.updateRotation(),t.add(s)}}get object(){return this._pieces[0].object}get align(){return this._pieces[0].align}get margin(){return this._pieces[0].margin}get tint(){return this._pieces[0].tint}get source(){return this._pieces[0].source}set source(t){this._pieces[0].source=t}get rotation(){return this._pieces[0].rotation}set rotation(t){this._pieces[0].rotation=t}add(t){const e=this.newImage(this._theme,t);return this._pieces.push(e),e}get(t){const e=this._pieces;return 0<=t&&t<e.length?e[t]:null}remove(t){const e=this._pieces;return 0<=t&&t<e.length&&(e[t].destroy(),!0)}size(){return this._pieces.length}destroy(){const t=this._pieces;for(let e=0,i=t.length;e<i;++e)t[e].destroy()}}class Oa extends wa{init(t){this.getImage(),super.init(t)}get image(){var t;return null!==(t=this._image)&&void 0!==t?t:this._image=this.newImage()}getImage(){var t;return null!==(t=this._image)&&void 0!==t?t:this._image=this.newImage()}newImage(){return new Ia(this,this.theme,this.options)}set image(t){const e=this.image.get(0);null!=e&&(e.source=t)}onStateChange(t,e){super.onStateChange(t,e),this.getImage().onStateChange(t,e)}onReflowTextAndImage(){const t=this.getLayouter();this.getImage().update(t);const e=this.getText();e.update(t);const i=this._auto;t.execute(this._padding,e.align,i.width.isOn?null:this.width,i.height.isOn?null:this.height),t.clear()}isRefitable(t){return!!super.isRefitable(t)||!!this.getImage().isRefitable(t)}getType(){return"DImageBase"}destroy(){const t=this._image;null!=t&&t.destroy(),super.destroy()}}class Aa extends Oa{init(t){var e,i;super.init(t);const s=this.theme;this._isToggle=null!==(e=null==t?void 0:t.toggle)&&void 0!==e?e:s.isToggle(),this._when=Qi(null!==(i=null==t?void 0:t.when)&&void 0!==i?i:s.getWhen(),$r),this.on(nn.tap,t=>{this.onClick(t)}),this.initOnPress();const n=null==t?void 0:t.group;n&&n.add(this)}onShortcut(t){this.state.isActionable&&this.activate(t),super.onShortcut(t)}get isToggle(){return!!this._isToggle}get isGrouped(){return!!this._isGrouped}set isGrouped(t){this._isGrouped=t}initOnPress(){let t=null;const e=()=>{this.state.isPressed=!1,null!=t&&(t.off(nn.up,e),t.off(nn.upoutside,e),t.off(nn.cancel,e),t=null)};this.on(nn.down,()=>{if(this.state.isActionable){this.state.isPressed=!0;const i=ot.getLayer(this);i&&(t=i.renderer.plugins.interaction,null!=t&&(t.on(nn.up,e),t.on(nn.upoutside,e),t.on(nn.cancel,e)))}})}getType(){return"DButton"}onClick(t){this._when===$r.CLICKED&&this.state.isActionable&&this.activate(t)}onDblClick(t,e){return this._when===$r.DOUBLE_CLICKED&&this.state.isActionable&&this.activate(t),super.onDblClick(t,e)}activate(t){this._isToggle?this._isGrouped&&this.state.isActive||(this.onToggleStart(t),this.onToggleEnd(t)):this.onActivate(t)}onActivate(t){this.emit("active",this)}onInactivate(t){this.emit("inactive",this)}toggle(){this.state.isActionable&&this._isToggle&&(this.onToggleStart(),this.onToggleEnd())}onToggleStart(t){this.state.isActive=!this.state.isActive}onToggleEnd(t){this.state.isActive?this.onActivate(t):this.onInactivate(t)}onActivateKeyDown(t){this.state.isActionable&&(this._isToggle?this.onToggleStart(t):this.state.isPressed=!0)}onActivateKeyUp(t){this.state.isActionable&&(this._isToggle?this.onToggleEnd(t):(this.state.isPressed&&this.onActivate(t),this.state.isPressed=!1))}onKeyDown(t){return $n.isActivateKey(t)&&this.onActivateKeyDown(t),super.onKeyDown(t)}onKeyUp(t){return $n.isActivateKey(t)&&this.onActivateKeyUp(t),super.onKeyUp(t)}onStateChange(t,e){super.onStateChange(t,e),t.isPressed?e.isPressed||this.onPress():e.isPressed&&this.onUnpress()}onPress(){this.emit("press",this)}onUnpress(){this.emit("unpress",this)}destroy(){var t,e;null===(e=null===(t=this._options)||void 0===t?void 0:t.group)||void 0===e||e.remove(this),super.destroy()}}class Ra extends Aa{getType(){return"DButton"}}class Ma extends Ra{getType(){return"DButtonPrimary"}}class ka extends Xr{getType(){return"DLayoutHorizontal"}}class La extends ka{constructor(t,e){super(e),this._parent=t}init(t){super.init(t);const e=this.newChildren();if(0<e.length)for(let t=0,i=e.length;t<i;++t){const i=e[t];null!=i&&this.addChild(i)}}newChildren(){return[this.buttonSpaceLeft,this.buttonCancel,this.buttonOk,this.buttonSpaceRight]}get buttonSpaceLeft(){let t=this._buttonSpaceLeft;return void 0===t&&(t=this.newButtonSpaceLeft(),this._buttonSpaceLeft=t),t}newButtonSpaceLeft(){var t,e,i,s;return(null!==(s=null===(i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.space)||void 0===i?void 0:i.left)&&void 0!==s?s:this.theme.isButtonSpaceLeftEnabled())?new Wr({weight:1}):null}get buttonSpaceRight(){let t=this._buttonSpaceRight;return void 0===t&&(t=this.newButtonSpaceRight(),this._buttonSpaceRight=t),t}newButtonSpaceRight(){var t,e,i,s;return(null!==(s=null===(i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.space)||void 0===i?void 0:i.right)&&void 0!==s?s:this.theme.isButtonSpaceRightEnabled())?new Wr({weight:1}):null}get buttonCancel(){let t=this._buttonCancel;return void 0===t&&(t=this.newButtonCancel(),this._buttonCancel=t),t}newButtonCancel(){var t,e;let i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.cancel;return void 0===i&&(i=this.theme.getButtonCancel()),null!=i?new Ma({text:{value:i},on:{active:()=>{this._parent.cancel()}}}):null}get buttonOk(){let t=this._buttonOk;return void 0===t&&(t=this.newButtonOk(),this._buttonOk=t),t}newButtonOk(){var t,e;let i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.ok;return void 0===i&&(i=this.theme.getButtonOk()),null!=i?null!=this.buttonCancel?new Ra({text:{value:i},on:{active:()=>{this._parent.ok()}}}):new Ma({text:{value:i},on:{active:()=>{this._parent.ok()}}}):null}getType(){return"DDialogLayeredFooter"}}class Na extends Ra{getType(){return"DButtonAmbient"}}class Pa extends Na{getType(){return"DDialogLayeredHeaderButtonClose"}}class Ba extends Oa{getType(){return"DDialogLayeredHeaderSeparator"}}class za extends Oa{constructor(t,e){super(e),this._parent=t;const i=this.separator;i&&this.addChild(i);const s=this.buttonClose;s&&(this.addChild(s),s.on("active",()=>{this._parent.cancel()}))}get buttonClose(){let t=this._buttonClose;return void 0===t&&(t=this.newButtonClose(),this._buttonClose=t),t}newButtonClose(){var t,e;return!1!==(null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.close)?new Pa:null}get separator(){let t=this._separator;return void 0===t&&(t=this.newSeparator(),this._separator=t),t}newSeparator(){var t;return!1!==(null===(t=this._options)||void 0===t?void 0:t.separator)?new Ba:null}getType(){return"DDialogLayeredHeader"}}class Ua extends Gr{init(t){super.init(t),this.addChild(this.layout)}get layout(){let t=this._layout;return null==t&&(t=this.newLayout(),this._layout=t),t}newLayout(){return new Yr(this.toLayoutOptions(this.theme,this._options))}toLayoutOptions(t,e){var i,s;const n=null!==(s=null!==(i=null==e?void 0:e.layout)&&void 0!==i?i:t.getLayout())&&void 0!==s?s:this.newLayoutOptions(t,e);return void 0===n.children&&(n.children=this.newLayoutChildren(t,e)),n}newLayoutOptions(t,e){return{width:"padding",height:"auto",margin:0}}newLayoutChildren(t,e){return[this.header,this.content,this.footer]}get header(){let t=this._header;return void 0===t&&(t=this.newHeader(),this._header=t),t}newHeader(){const t=this.toHeaderOptions(this.theme,this._options);return null!==t?new za(this,t):null}toHeaderOptions(t,e){if(e){const t=e.header;if(void 0!==t)return t}return t.getHeader()}get content(){let t=this._content;return null==t&&(t=this.newContent(),this._content=t),t}newContent(){return new jr(this.toContentOptions(this.theme,this._options))}toContentOptions(t,e){var i,s;const n=null!==(s=null!==(i=null==e?void 0:e.content)&&void 0!==i?i:t.getContent())&&void 0!==s?s:{};return void 0===n.children&&(n.children=this.newContentChildren(t,e)),n}newContentChildren(t,e){return[]}get footer(){let t=this._footer;return void 0===t&&(t=this.newFooter(),this._footer=t),t}newFooter(){const t=this.toFooterOptions(this.theme,this._options);return null!==t?new La(this,t):null}toFooterOptions(t,e){if(e){const t=e.footer;if(void 0!==t)return t}return t.getFooter()}findFirstFocusable(t){return t.find(this.content,!1,!0,!0)}ok(){this.onOk(this.getResolvedValue())}onOk(t){this.doResolve(t),this.emit("ok",t,this)}cancel(){this.onCancel(this.getRejectReason())}onCancel(t){this.doReject(t),this.emit("cancel",t,this)}getRejectReason(){}getType(){return"DDialogLayered"}}class Fa extends Ua{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.inputLayout),i}toInputMargin(t,e){var i,s;return null!==(s=null===(i=null==e?void 0:e.input)||void 0===i?void 0:i.margin)&&void 0!==s?s:t.getInputMargin()}get inputLayout(){let t=this._inputLayout;return null==t&&(t=this.newInputLayout(),this._inputLayout=t),t}newInputLayout(){const t=this.toInputMargin(this.theme,this._options);return new ka({width:"padding",height:"auto",margin:0,children:[new Wr({width:t}),this.input,new Wr({width:t})]})}get input(){let t=this._input;if(null==t){const e=this._options;t=this.newInput(null==e?void 0:e.input),this._input=t}return t}get value(){return this.input.value}set value(t){this.input.value=t}getResolvedValue(){return this.input.value}getType(){return"DDialogInput"}}class Ha extends t.utils.EventEmitter{constructor(t){super(),this._buttons=[],this._active=null,this._onActiveBound=t=>{this.active=t};const e=null==t?void 0:t.on;if(null!=e)for(const t in e){const i=e[t];i&&this.on(t,i)}this.emit("init",this)}add(t){if(this._buttons.indexOf(t)<0){this._buttons.push(t),t.isGrouped=!0;const e=this._isEnabled;null!=e&&(t.state.isEnabled=e),t.on("active",this._onActiveBound),t.state.isActive&&(this.active=t)}}get active(){return this._active}set active(t){if((null==t||t.isToggle)&&this._active!==t){const e=this._active;this._active=t;const i=this._buttons;for(let e=0,s=i.length;e<s;++e){const s=i[e];s!==t&&s.isToggle&&s.state.isActive&&s.toggle()}this.emit("active",t,e,this)}}remove(t){const e=this._buttons,i=e.indexOf(t);0<=i&&(e.splice(i,1),t.isGrouped=!1,t.off("active",this._onActiveBound),this._active===t&&(this.active=null))}contains(t){return 0<=this._buttons.indexOf(t)}clear(){const t=this._buttons;for(let e=0,i=t.length;e<i;++e)t[e].isGrouped=!1;t.length=0,this.active=null}size(){return this._buttons.length}each(t){const e=this._buttons;for(let i=0,s=e.length;i<s&&!1!==t(e[i]);++i);}disable(){const t=this._buttons;for(let e=0,i=t.length;e<i;++e)t[e].state.isDisabled=!0;this._isEnabled=!1}enable(){const t=this._buttons;for(let e=0,i=t.length;e<i;++e)t[e].state.isDisabled=!1;this._isEnabled=!0}destroy(){this.clear()}}class Ga extends Ra{getType(){return"DInputBooleanButtonOff"}}class Va extends Ra{getType(){return"DInputBooleanButtonOn"}}class Wa extends ka{constructor(t){super(t),this._lockCount=0,this.addChild(this.getButtonOff()),this.addChild(this.getButtonOn());const e=null==t?void 0:t.value;null!=e&&(this.value=e),this.getButtonGroup().on("active",()=>{if(this._lockCount<=0){const t=this.value;this.emit("change",t,!t,this)}})}getButtonGroup(){let t=this._buttonGroup;return null==t&&(t=this.newButtonGroup(),this._buttonGroup=t),t}newButtonGroup(){return new Ha}getButtonOn(){let t=this._buttonOn;return null==t&&(t=this.newButtonOn(),this._buttonOn=t),t}newButtonOn(){return new Va({weight:1,group:this.getButtonGroup()})}getButtonOff(){let t=this._buttonOff;return null==t&&(t=this.newButtonOff(),this._buttonOff=t),t}newButtonOff(){return new Ga({weight:1,group:this.getButtonGroup(),state:lt.ACTIVE})}get value(){return this.getButtonOn().state.isActive}set value(t){if(this.value!==t){this._lockCount+=1;try{t?this.getButtonOn().activate():this.getButtonOff().activate()}catch(t){}this._lockCount-=1}}getType(){return"DInputBoolean"}}class Ka extends Fa{newInput(t){return new Wa(this.toInputOptions(t))}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputBoolean"}}class Xa extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target),this.onInputAction=t.onInputAction,this.isOpened=!1,this.step=fe.ofNumberOrNull(t.step),this.min=fe.ofNumberOrNull(t.min),this.max=fe.ofNumberOrNull(t.max)}execute(t,e,i){if(!this.isOpened&&this.condition(t,i,ge)){const e=this.target(t,i,ge);if(null!=e){const s=this.initial(t,i,ge),n=this.step(t,i,ge),o=this.min(t,i,ge),r=this.max(t,i,ge);this.isOpened=!0,setTimeout(()=>{this.open(t,e,s,n,o,r).then(s=>{this.isOpened=!1,dr.execute(t,this.onInputAction,e,s,i)},()=>{this.isOpened=!1})},0)}}}}class Ya extends Xa{constructor(t){super(t),this.initial=fe.ofBooleanOrFalse(t.initial)}open(t,e,i,s,n,o){let r=Ya.DIALOG;if(null==r)r=new Ka({header:{text:{value:e},button:{close:!1}}}),Ya.DIALOG=r;else{const t=r.header;t&&(t.text=e)}return r.value=i,r.open(t)}}class ja extends Oa{getUtil(){let t=this._util;return null==t&&(t=this.newUtil(),this._util=t),t}newUtil(){return new sr(this,this.newOperation(),this.theme,this._options)}newOperation(){return{getElementRect:(t,e,i)=>this.getElementRect(t,e,i),getElementMatrix:()=>null,getClipperRect:(t,e,i)=>this.getClipperRect(t,e,i),getPadding:()=>this.padding,containsPoint:t=>this.containsPoint(t),onStart:()=>{},onCancel:()=>{},onEnd:()=>{}}}get element(){return this.getUtil().element}onDownThis(t){const e=this.getUtil();e.onDowning(t),super.onDownThis(t),e.onDown(t)}onDblClick(t,e){return this.getUtil().onDblClick(t,e),super.onDblClick(t,e)}onFocus(){super.onFocus(),this.getUtil().onFocus()}onBlur(){super.onBlur(),this.getUtil().onBlur()}start(){this.getUtil().start()}render(t){this.getUtil().onRender(t),super.render(t)}getElementRect(t,e,i){return e.set(0,0),this.toGlobal(e,e,!1),i.x=e.x,i.y=e.y,e.set(this.width,this.height),this.toGlobal(e,e,!0),i.width=e.x-i.x,i.height=e.y-i.y,i}getClipperRect(t,e,i){return sr.getClipperRect(this.parent,this,t,e,i)}cancel(){this.getUtil().cancel()}end(){this.getUtil().end()}select(){return this.getUtil().select(),this}onActivateKeyDown(t){this.state.isActionable&&(this.state.isPressed=!0)}onActivateKeyUp(t){this.state.isActionable&&(this.state.isPressed&&this.start(),this.state.isPressed=!1)}onKeyDown(t){return $n.isActivateKey(t)&&this.onActivateKeyDown(t),super.onKeyDown(t)}onKeyUp(t){return $n.isActivateKey(t)&&this.onActivateKeyUp(t),super.onKeyUp(t)}getType(){return"DHtmlElement"}}class $a extends ja{newOperation(){return{getElementRect:(t,e,i)=>this.getElementRect(t,e,i),getElementMatrix:()=>null,getClipperRect:(t,e,i)=>this.getClipperRect(t,e,i),getPadding:()=>this.padding,containsPoint:t=>this.containsPoint(t),onStart:()=>{this.text.hide()},onCancel:()=>{this.text.show()},onEnd:()=>{},getValue:()=>this.text.computed,onValueInput:t=>{this.onValueInput(t)},onValueChange:(t,e)=>{this.text=t,this.onValueChange(t,e)},onEnter:()=>{this.onEnter()},applyTitle:()=>{this.applyTitle()}}}get value(){return this.text.computed}set value(t){this.text=t}newText(){const t=super.newText();return t.on("change",()=>{this.validate()}),t}onValueChange(t,e){this.emit("change",t,e,this)}onValueInput(t){this.emit("input",t,this)}onEnter(){this.emit("enter",this)}validate(){return this.getUtil().validate()}applyTitle(){this.getUtil().applyTitle()||super.applyTitle()}getType(){return"DInput"}}class qa extends $a{getType(){return"DInputInput"}}class Za extends qa{newUtil(){return new cr(this,this.newOperation(),this.theme,this._options)}get step(){return this.getUtil().step}set step(t){this.getUtil().step=t}get min(){return this.getUtil().min}set min(t){this.getUtil().min=t}get max(){return this.getUtil().max}set max(t){this.getUtil().max=t}}class Ja extends Za{getType(){return"DInputInteger"}}class Qa extends Fa{newInput(t){const e=new Ja(this.toInputOptions(t));return e.on("enter",()=>{this.ok()}),e}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputInteger"}}class th extends Xa{constructor(t){super(t),this.initial=fe.ofNumber(t.initial)}open(t,e,i,s,n,o){let r=th.DIALOG;if(null==r)r=new Qa({header:{text:{value:e},button:{close:!1}},input:{step:s,min:n,max:o,text:{value:i}}}),th.DIALOG=r;else{const t=r.header;t&&(t.text=e);const a=r.input;a.step=s,a.min=n,a.max=o,r.value=i}return r.open(t)}}class eh extends Za{getType(){return"DInputReal"}}class ih extends Fa{newInput(t){const e=new eh(this.toInputOptions(t));return e.on("enter",()=>{this.ok()}),e}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputReal"}}class sh extends Xa{constructor(t){super(t),this.initial=fe.ofNumber(t.initial)}open(t,e,i,s,n,o){let r=sh.DIALOG;if(null==r)r=new ih({header:{text:{value:e},button:{close:!1}},input:{step:s,min:n,max:o,text:{value:i}}}),sh.DIALOG=r;else{const t=r.header;t&&(t.text=e);const a=r.input;a.step=s,a.min=n,a.max=o,r.value=i}return r.open(t)}}class nh extends qa{newUtil(){return new vr(this,this.newOperation(),this.theme,this._options)}getType(){return"DInputText"}}class oh extends Fa{newInput(t){const e=new nh(this.toInputOptions(t));return e.on("enter",()=>{this.ok()}),e}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputText"}}class rh extends Xa{constructor(t){super(t),this.initial=fe.ofString(t.initial)}open(t,e,i,s,n,o){let r=rh.DIALOG;if(null==r)r=new oh({header:{text:{value:e},button:{close:!1}}}),rh.DIALOG=r;else{const t=r.header;t&&(t.text=e)}return r.value=i,r.open(t)}}class ah extends jr{getType(){return"DDialogFittedContent"}}class hh extends Ua{newLayoutOptions(t,e){return{width:"auto",height:"auto",margin:0}}newContent(){return new ah(this.toContentOptions(this.theme,this._options))}getType(){return"DDialogFitted"}}class lh extends Na{getType(){return"DPickerDatetimeButtonBack"}}class ch extends Na{getType(){return"DPickerDatetimeButtonDate"}}class uh extends Na{getType(){return"DPickerDatetimeButtonNext"}}class dh extends wa{getType(){return"DText"}}class ph extends dh{getType(){return"DPickerDatetimeLabel"}}class _h extends dh{getType(){return"DPickerDatetimeLabelDate"}}class gh extends to{constructor(t){super(t),this.renderable=!1}getType(){return"DPickerDatetimeSpace"}}const fh={NONE:0,DATE:1,HOURS:2,MINUTES:4,SECONDS:8,TIME:14,ALL:15};class mh{static from(t,e){const i=null==e?void 0:e.mask;if(null==i){if(Et(t)){const e=$.getInstance().get(t);if(null!=e)return e.getMask()}else if(null!=t)return t.getMask();return fh.NONE}if(Et(i))return fh[i];if(wt(i))return i;let s=fh.NONE;for(let t=0,e=i.length;t<e;++t)s|=fh[i[t]];return s}}class vh{constructor(t,e){var i,s;this._date=null!==(i=null==t?void 0:t.date)&&void 0!==i?i:null,this._inclusive=null!==(s=null==t?void 0:t.inclusive)&&void 0!==s&&s,this._onChange=e}get date(){return this._date}set date(t){this._date!==t&&(this._date=t,this._onChange())}get inclusive(){return this._inclusive}set inclusive(t){this._inclusive!==t&&(this._inclusive=t,this._onChange())}}class Th{constructor(t){this._parent=t}min(t){const e=this._parent,i=e.lower,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(s.getFullYear()<t.getFullYear())return n.hour.min;if(s.getMonth()<t.getMonth())return n.hour.min;if(s.getDate()<t.getDate())return n.hour.min}const r=s.getHours();return i.inclusive||o&fh.SECONDS&&s.getSeconds()<n.second.max||o&fh.MINUTES&&s.getMinutes()<n.minute.max?r:r+1}return n.hour.min}max(t){const e=this._parent,i=e.upper,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(t.getFullYear()<s.getFullYear())return n.hour.max;if(t.getMonth()<s.getMonth())return n.hour.max;if(t.getDate()<s.getDate())return n.hour.max}const r=s.getHours();return i.inclusive||o&fh.SECONDS&&n.second.min<s.getSeconds()||o&fh.MINUTES&&n.minute.min<s.getMinutes()?r:r-1}return n.hour.max}}class wh{constructor(t){this._parent=t}min(t){const e=this._parent,i=e.lower,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(s.getFullYear()<t.getFullYear())return n.minute.min;if(s.getMonth()<t.getMonth())return n.minute.min;if(s.getDate()<t.getDate())return n.minute.min}if(o&fh.HOURS&&s.getHours()<t.getHours())return n.minute.min;const r=s.getMinutes();return i.inclusive||o&fh.SECONDS&&s.getSeconds()<n.second.max?r:r+1}return n.minute.min}max(t){const e=this._parent,i=e.upper,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(t.getFullYear()<s.getFullYear())return n.minute.max;if(t.getMonth()<s.getMonth())return n.minute.max;if(t.getDate()<s.getDate())return n.minute.max}if(o&fh.HOURS&&t.getHours()<s.getHours())return n.minute.max;const r=s.getMinutes();return i.inclusive||o&fh.SECONDS&&n.second.min<s.getSeconds()?r:r-1}return n.minute.max}}class Eh{constructor(t){this._parent=t}min(t){const e=this._parent,i=e.lower,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(s.getFullYear()<t.getFullYear())return n.second.min;if(s.getMonth()<t.getMonth())return n.second.min;if(s.getDate()<t.getDate())return n.second.min}return o&fh.HOURS&&s.getHours()<t.getHours()||o&fh.MINUTES&&s.getMinutes()<t.getMinutes()?n.second.min:s.getSeconds()+(i.inclusive?0:1)}return n.second.min}max(t){const e=this._parent,i=e.upper,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(t.getFullYear()<s.getFullYear())return n.second.max;if(t.getMonth()<s.getMonth())return n.second.max;if(t.getDate()<s.getDate())return n.second.max}return o&fh.HOURS&&t.getHours()<s.getHours()||o&fh.MINUTES&&t.getMinutes()<s.getMinutes()?n.second.max:s.getSeconds()-(i.inclusive?0:1)}return n.second.max}}class yh{constructor(t,e){this.constant=this.newConstant(),this.lower=new vh(t&&t.lower,e),this.upper=new vh(t&&t.upper,e),this.mask=fh.ALL,this.hours=new Th(this),this.minutes=new wh(this),this.seconds=new Eh(this)}newConstant(){return{second:{min:0,max:59},minute:{min:0,max:59},hour:{min:0,max:23}}}adjust(t){const e=this.test(t);if(e<0){const e=this.lower,i=e.date;if(i){if(t.setTime(i.getTime()),!e.inclusive){const e=this.mask;e&fh.SECONDS?t.setSeconds(i.getSeconds()+1):e&fh.MINUTES?t.setMinutes(i.getMinutes()+1):e&fh.HOURS?t.setHours(i.getHours()+1):e&fh.DATE&&t.setDate(i.getDate()+1)}return!0}}else if(0<e){const e=this.upper,i=e.date;if(i){if(t.setTime(i.getTime()),!e.inclusive){const e=this.mask;e&fh.SECONDS?t.setSeconds(i.getSeconds()-1):e&fh.MINUTES?t.setMinutes(i.getMinutes()-1):e&fh.HOURS?t.setHours(i.getHours()-1):e&fh.DATE&&t.setDate(i.getDate()-1)}return!0}}return!1}compare(t,e){const i=this.mask;if(i&fh.DATE){const i=t.getFullYear(),s=e.getFullYear();if(i!==s)return i<s?-1:1;const n=t.getMonth(),o=e.getMonth();if(n!==o)return n<o?-1:1;const r=t.getDate(),a=e.getDate();if(r!==a)return r<a?-1:1}if(i&fh.HOURS){const i=t.getHours(),s=e.getHours();if(i!==s)return i<s?-1:1}if(i&fh.MINUTES){const i=t.getMinutes(),s=e.getMinutes();if(i!==s)return i<s?-1:1}if(i&fh.SECONDS){const i=t.getSeconds(),s=e.getSeconds();if(i!==s)return i<s?-1:1}return 0}test(t){const e=this.lower,i=e.date;if(null!=i){const s=this.compare(i,t);return e.inclusive?s<=0?0:-1:s<0?0:-1}const s=this.upper,n=s.date;if(null!=n){const e=this.compare(t,n);return s.inclusive?e<=0?0:1:e<0?0:1}return 0}contains(t){return 0===this.test(t)}}const xh=(t,e,i)=>{if(t){const s=t.date,n=t.inclusive;return{date:void 0!==s?s:e,inclusive:void 0!==n?n:i}}return{date:e,inclusive:i}};class Ch extends to{constructor(t){super(t),this.onNewChange()}init(t){var e;super.init(t);const i=this.theme;this._dateCurrent=new Date;const s=this._dateCurrent.getTime();this._dateNew=new Date(s),this._dateBounds=new yh(((t,e)=>e?{lower:xh(e.lower,t.getLowerBound(),t.isLowerBoundInclusive()),upper:xh(e.upper,t.getUpperBound(),t.isUpperBoundInclusive())}:{lower:{date:t.getLowerBound(),inclusive:t.isLowerBoundInclusive()},upper:{date:t.getUpperBound(),inclusive:t.isUpperBoundInclusive()}})(i,null==t?void 0:t.bounds),()=>{this.onNewChange()});const n=null!==(e=null==t?void 0:t.margin)&&void 0!==e?e:i.getMargin();new Yr({parent:this,x:"padding",y:"padding",width:"auto",height:"auto",margin:n,children:this.newChildren(i,t,n)})}get current(){return this._dateCurrent}set current(t){this._dateCurrent.getTime()!==t.getTime()&&(this._dateCurrent=t)}get new(){return this._dateNew}set new(t){this._dateNew.getTime()!==t.getTime()&&(this._dateNew=t,this.onNewChange())}get bounds(){return this._dateBounds}hasHours(){return null!=this._inputHours}hasMinutes(){return null!=this._inputMinutes}hasSeconds(){return null!=this._inputSeconds}reset(){const t=this._dateCurrent.getTime();this._dateNew.setTime(t),this.onReset()}onReset(){this.onNewChange()}onNewChange(){const t=this._dateNew,e=this._dateBounds;e.adjust(this._dateNew);const i=this._inputHours;if(i){const s=e.hours;i.value=t.getHours(),i.min=s.min(t),i.max=s.max(t)}const s=this._inputMinutes;if(s){const i=e.minutes;s.value=t.getMinutes(),s.min=i.min(t),s.max=i.max(t)}const n=this._inputSeconds;if(n){const i=e.seconds;n.value=t.getSeconds(),n.min=i.min(t),n.max=i.max(t)}}newChildren(t,e,i){const s=mh.from(t,e);return this._dateBounds.mask=s,this._inputHours=s&fh.HOURS?this.newInputHours(t,e):null,this._inputMinutes=s&fh.MINUTES?this.newInputMinutes(t,e):null,this._inputSeconds=s&fh.SECONDS?this.newInputSeconds(t,e):null,[this.newTimeLayout(this._inputHours,this._inputMinutes,this._inputSeconds,i)]}newTimeLayout(t,e,i,s){const n=this.newTimeLayoutChildren(t,e,i);return 0<n.length?new ka({width:this.getTimeLayoutWidth(),height:this.getTimeLayoutHeight(),margin:s,children:n}):null}getTimeLayoutWidth(){return"auto"}getTimeLayoutHeight(){return"auto"}newTimeLayoutChildren(t,e,i){const s=[];return null!=t&&s.push(t),null!=e&&(0<s.length&&s.push(this.newMinuteSeparator()),s.push(e)),null!=i&&(0<s.length&&s.push(this.newSecondSeparator()),s.push(i)),s}newMinuteSeparator(){return new dh({width:"auto",text:{value:this.getMinuteSeparator()}})}getMinuteSeparator(){return":"}newSecondSeparator(){return new dh({width:"auto",text:{value:this.getSecondSeparator()}})}getSecondSeparator(){return":"}adjustInputOptions(t,e,i){return null==e.step&&(e.step=1),null==e.min&&(e.min=0),null==e.max&&(e.max=i),e}newInputHours(t,e){var i;const s=null!==(i=null==e?void 0:e.hours)&&void 0!==i?i:t.getHoursOptions(),n=this._dateBounds.constant.hour.max,o=new Ja(this.adjustInputOptions(t,s,n));return o.on("change",t=>{this.onHoursChange(t)}),o}onHoursChange(t){this._dateNew.setHours(t),this.onNewChange()}newInputMinutes(t,e){const i=(null==e?void 0:e.minutes)||t.getMinutesOptions(),s=this._dateBounds.constant.minute.max,n=new Ja(this.adjustInputOptions(t,i,s));return n.on("change",t=>{this.onMinutesChange(t)}),n}onMinutesChange(t){this._dateNew.setMinutes(t),this.onNewChange()}newInputSeconds(t,e){const i=(null==e?void 0:e.seconds)||t.getSecondsOptions(),s=this._dateBounds.constant.second.max,n=new Ja(this.adjustInputOptions(t,i,s));return n.on("change",t=>{this.onSecondsChange(t)}),n}onSecondsChange(t){this._dateNew.setSeconds(t)}getType(){return"DPickerTime"}}class Dh extends Ch{init(t){super.init(t),this._datePage=new Date(this._dateCurrent.getTime())}newChildren(t,e,i){var s,n;this._dateButtons=this.newDateButtons(t,e),this._dateDecorator=null!==(n=null===(s=null==e?void 0:e.date)||void 0===s?void 0:s.decorator)&&void 0!==n?n:t.getDateDecorator(),this._label=this.newLabel(t,e);const o=super.newChildren(t,e,i);return o.unshift(new ka({width:"100%",height:"auto",children:[this.newBackButton(t,e),this._label,this.newNextButton(t,e)]}),new ka({width:"auto",height:"auto",margin:i,children:this.newDateLabels(t,e)}),new Yr({width:"auto",height:"auto",margin:i,column:7,children:this._dateButtons})),o}get page(){return this._datePage}set page(t){this._datePage.getTime()!==t.getTime()&&(this._datePage=t,this.onPageChange())}onReset(){this._datePage.setTime(this._dateCurrent.getTime()),super.onReset()}next(){const t=this._datePage;t.setFullYear(t.getFullYear(),t.getMonth()+1,1),t.setHours(0,0,0,0),this.onPageChange()}back(){const t=this._datePage;t.setFullYear(t.getFullYear(),t.getMonth()-1,1),t.setHours(0,0,0,0),this.onPageChange()}onNewChange(){this._dateBounds.adjust(this._datePage),super.onNewChange(),this.onPageChange()}onPageChange(){const t=this._dateButtons,e=this._dateBounds,i=this._datePage,s=this._dateNew,n=new Date(i.getTime());n.setDate(1),n.setHours(0,0,0,0);const o=this.theme,r=(n.getDay()-o.getDayStart()+7)%7;for(let e=0;e<r;++e)t[e].show();for(let e=r;e<7;++e)t[e].hide();const a=this._dateDecorator;n.setFullYear(n.getFullYear(),n.getMonth()+1,0);const h=n.getDate(),l=s.getFullYear()===n.getFullYear()&&s.getMonth()===n.getMonth()?s.getDate():0;for(let i=0;i<h;++i){n.setDate(i+1);const s=t[i+7];s.state.isActive=l===i+1,s.state.isDisabled=!e.contains(n),s.show(),a(n,s)}for(let e=h;e<31;++e){const i=t[e+7];i.state.isActive=!1,i.hide()}n.setTime(i.getTime()),this._label.text=n}adjustInputOptions(t,e,i){return null==e.weight&&(e.weight=1),super.adjustInputOptions(t,e,i)}getTimeLayoutWidth(){return"100%"}toLabelOptions(t,e){const i=e&&e.label||{};void 0===i.weight&&(i.weight=1),void 0===i.padding&&(i.padding=0);const s=i.text=i.text||{},n=s.align=s.align||{};return void 0===n.horizontal&&(n.horizontal="CENTER"),void 0===s.formatter&&(s.formatter=t.getLabelFormatter()),i}newLabel(t,e){return new ph(this.toLabelOptions(t,e))}newBackButton(t,e){let i=null==e?void 0:e.back;if(void 0===i&&(i=t.getBackButtonOptions()),null!=i){const t=new lh(i);return t.on("active",()=>{this.back()}),t}return null}newNextButton(t,e){let i=null==e?void 0:e.next;if(void 0===i&&(i=t.getNextButtonOptions()),null!=i){const t=new uh(i);return t.on("active",()=>{this.next()}),t}return null}newDateLabels(t,e){const i=t.getDayLabels(),s=t.getDayStart(),n=[];for(let o=0;o<7;++o){const r=i[(s+o)%7];n.push(this.newDateLabel(t,e,r))}return n}newDateLabel(t,e,i){return new _h({text:{value:i}})}newDateButtons(t,e){const i=[];for(let s=0;s<7;++s)i.push(this.newSpace(t,e));for(let s=1;s<=31;++s)i.push(this.newDateButton(t,e,s));return i}newSpace(t,e){return new gh}newDateButton(t,e,i){return new ch({text:{value:String(i)},on:{active:()=>{this.onDateButtonClicked(i)}}})}onDateButtonClicked(t){const e=this._dateNew;if(e.getDate()!==t){const i=this._datePage;e.setFullYear(i.getFullYear()),e.setMonth(i.getMonth()),e.setDate(t),this.onNewChange()}}getType(){return"DPickerDatetime"}}class Sh extends hh{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.picker),i}get current(){return this.picker.current}set current(t){this.picker.current=t}get new(){return this.picker.new}set new(t){this.picker.new=t}get page(){return this.picker.new}set page(t){this.picker.page=t}get picker(){var t;let e=this._picker;return null==e&&(e=new Dh(null===(t=this._options)||void 0===t?void 0:t.picker),this._picker=e),e}getResolvedValue(){return this.picker.new}getType(){return"DDialogDatetime"}}class bh extends Xa{constructor(t){super(t),this.initial=fe.ofUnknown(t.initial)}open(t,e,i,s,n,o){let r=bh.DIALOG;return null==r&&(r=new Sh,bh.DIALOG=r),r.new=r.current=this.toDate(i),r.open(t).then(t=>t.toISOString())}toDate(t){return Et(t)||wt(t)?new Date(t):t instanceof Date?t:new Date}}class Ih extends hh{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.picker),i}get current(){return this.picker.current}set current(t){this.picker.current=t}get new(){return this.picker.new}set new(t){this.picker.new=t}get picker(){var t;let e=this._picker;return null==e&&(e=new Ch(null===(t=this._options)||void 0===t?void 0:t.picker),this._picker=e),e}getResolvedValue(){return this.picker.new}getType(){return"DDialogTime"}}const Oh=t=>t!=t;class Ah extends Xa{constructor(t){super(t),this.initial=fe.ofUnknown(t.initial)}open(t,e,i,s,n,o){let r=Ah.DIALOG;return null==r&&(r=new Ih,Ah.DIALOG=r),r.new=r.current=this.toDate(i),r.open(t).then(t=>this.getFormatter().format(t.getTime(),0))}toDate(t){if(wt(t))return new Date(t);if(Et(t)){const e=new Date,i=this.getPattern().exec(t);if(null!=i){const t=this.toHours(i[1]);null!=t&&e.setHours(t);const s=this.toMinutes(i[2]);null!=s&&e.setMinutes(s);const n=this.toSeconds(i[3]);null!=n&&e.setSeconds(n);const o=this.toMilliseconds(i[4]);null!=o&&e.setMilliseconds(o)}return e}return t instanceof Date?t:new Date}toHours(t){return this.toNumber(t,0,23)}toMinutes(t){return this.toNumber(t,0,59)}toSeconds(t){return this.toNumber(t,0,59)}toMilliseconds(t){const e=this.toNumber(t,0,999);if(null!=e){const i=t.length;return 1===i?100*e:2===i?10*e:e}return e}toNumber(t,e,i){if(null!=t){const s=+t;if(!Oh(s))return Math.min(i,Math.max(e,s))}return null}getPattern(){let t=Ah.PATTERN;return null==t&&(t=this.newPattern(),Ah.PATTERN=t),t}newPattern(){return/^\s*(?:(\d+)(?::(\d+)(?::(\d+))?)?)?(?:\.(\d+))?\s*$/}getFormatter(){let t=Ah.FORMATTER;return null==t&&(t=this.newFormatter(),Ah.FORMATTER=t),t}newFormatter(){return Si.create("%Hm")}}class Rh extends Dh{getType(){return"DPickerDate"}}class Mh extends hh{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.picker),i}get current(){return this.picker.current}set current(t){this.picker.current=t}get new(){return this.picker.new}set new(t){this.picker.new=t}get page(){return this.picker.new}set page(t){this.picker.page=t}get picker(){var t;let e=this._picker;return null==e&&(e=new Rh(null===(t=this._options)||void 0===t?void 0:t.picker),this._picker=e),e}getResolvedValue(){return this.picker.new}getType(){return"DDialogDate"}}class kh extends Xa{constructor(t){super(t),this.initial=fe.ofUnknown(t.initial)}open(t,e,i,s,n,o){let r=kh.DIALOG;return null==r&&(r=new Mh,kh.DIALOG=r),r.new=r.current=this.toDate(i),r.open(t).then(t=>this.getFormatter().format(t.getTime(),0))}toDate(t){return Et(t)||wt(t)?new Date(t):t instanceof Date?t:new Date}getFormatter(){let t=kh.FORMATTER;return null==t&&(t=this.newFormatter(),kh.FORMATTER=t),t}newFormatter(){return Si.create("%Y-%M-%D")}}const Lh={TEXT:0,INTEGER:1,REAL:2,BOOLEAN:3,DATE:4,TIME:5,DATETIME:6,EXTENSION:1e3};class Nh extends Ie{constructor(t,e,i,s,n,o,r,a){super(Oe.OPEN,t,Rr.DIALOG),this.target=e,this.onInputAction=i,this.initial=s,this.step=n,this.min=o,this.max=r,this.dialogType=a}isEquals(t){return super.isEquals(t)&&t instanceof Nh&&this.target===t.target&&this.dialogType===t.dialogType&&this.onInputAction===t.onInputAction&&this.initial===t.initial&&this.step===t.step&&this.min===t.min&&this.max===t.max}toRuntime(){switch(this.dialogType){case Lh.TEXT:return new rh(this);case Lh.INTEGER:return new th(this);case Lh.REAL:return new sh(this);case Lh.BOOLEAN:return new Ya(this);case Lh.DATE:return new kh(this);case Lh.TIME:return new Ah(this);case Lh.DATETIME:return new bh(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=t.addResource(this.initial),n=t.addResource(this.step),o=t.addResource(this.min),r=t.addResource(this.max);return t.addResource(`[${this.type},${e},${this.subtype},${i},${this.onInputAction},${s},${this.dialogType},${n},${o},${r}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i),o=Ae.toResource(5,t,i),r=Ae.toResource(7,t,i),a=Ae.toResource(8,t,i),h=Ae.toResource(9,t,i);return new Nh(s,n,t[4],o,r,a,h,this.toDialogType(t))}static toDialogType(t){if(t[2]===Rr.DIALOG)return t[6];switch(t[2]){case Rr.DIALOG_TEXT:return Lh.TEXT;case Rr.DIALOG_INTEGER:return Lh.INTEGER;case Rr.DIALOG_REAL:return Lh.REAL;case Rr.DIALOG_BOOLEAN:return Lh.BOOLEAN;case Rr.DIALOG_DATE:return Lh.DATE;case Rr.DIALOG_TIME:return Lh.TIME;case Rr.DIALOG_DATETIME:return Lh.DATETIME}}}class Ph{static add(t){var e,i;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._data)&&void 0!==i?i:this._data=[]).push(t)}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Bh extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target),this.argument=fe.ofUnknown(t.argument);const e=Ph.get(t.dialogType);e&&(this.opener=e.opener)}execute(t,e,i){const s=this.opener;if(s&&this.condition(t,i,ge)){const e=this.target(t,i,ge);if(null!=e){const n=$o.toDiagram(t);if(null!=n){const o=this.argument(t,i,ge);setTimeout(()=>{s(e,o,t,n,ge)},0)}}}}}class zh extends Ie{constructor(t,e,i,s){super(Oe.OPEN,t,Rr.DIALOG),this.target=e,this.argument=i,this.dialogType=s}isEquals(t){return super.isEquals(t)&&t instanceof zh&&this.target===t.target&&this.argument===t.argument&&this.dialogType===t.dialogType}toRuntime(){return new Bh(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=t.addResource(this.argument);return t.addResource(`[${this.type},${e},${this.subtype},${i},0,-1,${this.dialogType},${s}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources),n=Ae.toResource(7,t,e.resources);return new zh(i,s,n,t[6])}}class Uh{static add(t){var e,i;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._data)&&void 0!==i?i:this._data=[]).push(t),yn[t.type]=t.opener}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Fh extends Ie{constructor(t,e,i,s){super(Oe.OPEN,e,t),this.target=i,this.inNewWindow=s}isEquals(t){return super.isEquals(t)&&t instanceof Fh&&this.target===t.target&&this.inNewWindow===t.inNewWindow}toRuntime(){return new Ar(this,this.subtype)}toLabel(){const t=this.getTheme().toTypeLabel(this.type),e=Uh.get(this.subtype);return`${t}: ${null!=e?e.label:"Unknown"}`}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=this.inNewWindow?1:0;return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources);return new Fh(t[2],i,s,!!t[4])}}const Hh={SHAPE_SHOW:0,SHAPE_HIDE:1,SHAPE:2,LAYER:3};class Gh extends ve{constructor(t){super(t,pe.VISIBILITY),this.visibility=t.subtype===Hh.SHAPE_SHOW}execute(t,e,i){this.condition(t,i,ge)&&(t.visible=this.visibility,e.written|=this.reset)}}class Vh extends Ie{constructor(t,e){super(Oe.SHOW_HIDE,e,t)}toRuntime(){return new Gh(this)}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources);return new Vh(t[2],i)}}class Wh extends ve{constructor(t){super(t,pe.NONE),this._data=new Map,this._layers=t.layers,this._bringToFront=t.bringToFront}initialize(t,e){super.initialize(t,e);let i=this._data.get(t);null==i&&(i=this.newData(t),null!=i&&this._data.set(t,i))}execute(t,e,i){const s=this._data.get(t);if(s){const e=this.condition(t,i,ge);if(s.condition!==e){s.condition=e;const t=s.layers;e?s.bringToFront?(tn.bringAllToFront(t),tn.showAll(t)):tn.showAll(t):tn.hideAll(t)}}}newData(t){const e=tn.toLayers(t,this._layers);if(0<e.length)return{layers:e,bringToFront:this._bringToFront,condition:null}}}class Kh extends Ie{constructor(t,e,i){super(Oe.SHOW_HIDE,t,Hh.LAYER),this.layers=e,this.bringToFront=i}toRuntime(){return new Wh(this)}serialize(t){const e=t.addResource(this.condition),i=this.serializeLayers(t),s=this.bringToFront?1:0;return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}serializeLayers(t){const e=this.layers;let i="[",s="";for(let t=0,n=e.length;t<n;++t)i+=s+e[t],s=",";return i+="]",t.addResource(i)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=this.deserializeLayers(t[3],e),n=!!t[4];return new Kh(i,s,n)}static deserializeLayers(t,e){const i=e.resources,s=i.length;return 0<=t&&t<s?JSON.parse(i[t]):[]}}class Xh extends ve{constructor(t){super(t,pe.VISIBILITY)}initialize(t,e){super.initialize(t,e)}execute(t,e,i){t.visible=this.condition(t,i,ge),e.written|=this.reset}}class Yh extends Ie{constructor(t){super(Oe.SHOW_HIDE,t,Hh.SHAPE)}toRuntime(){return new Xh(this)}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources);return new Yh(i)}}class jh extends ve{constructor(t,e){super(t,e),this.amount=fe.ofNumber(t.amount)}}class $h extends jh{constructor(t){super(t,pe.POSITION_X)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge);t.transform.position.x=s,e.written|=this.reset}}}class qh extends jh{constructor(t){super(t,pe.POSITION_Y)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge);t.transform.position.y=s,e.written|=this.reset}}}class Zh extends jh{constructor(t){super(t,pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=n.position,r=!!(e.written&pe.POSITION_X),a=!!(e.written&pe.POSITION_Y),h=r?o.x:e.x,l=a?o.y:e.y;t.updateTransform();const c=n.localTransform;o.set(h-c.c*s,l-c.d*s),e.written|=this.reset}}}class Jh extends jh{constructor(t){super(t,pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=n.position,r=!!(e.written&pe.POSITION_X),a=!!(e.written&pe.POSITION_Y),h=r?o.x:e.x,l=a?o.y:e.y;t.updateTransform();const c=n.localTransform;o.set(h+c.a*s,l+c.b*s),e.written|=this.reset}}}class Qh extends jh{constructor(t){super(t,pe.POSITION_X)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=!!(e.written&pe.POSITION_X),o=t.transform.position,r=n?o.x:e.x;o.x=r+s,e.written|=this.reset}}}class tl extends jh{constructor(t){super(t,pe.POSITION_Y)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=!!(e.written&pe.POSITION_Y),o=t.transform.position,r=n?o.y:e.y;o.y=r+s,e.written|=this.reset}}}class el extends Ie{constructor(t,e,i,s){super(t,e,i),this.opetype=s}isEquals(t){return super.isEquals(t)&&t instanceof el&&this.opetype===t.opetype}}const il={RELATIVE_X:0,RELATIVE_Y:1,ABSOLUTE_X:2,ABSOLUTE_Y:3,FORWARD_OR_BACKWARD:4,LEFT_OR_RIGHT:5},sl={RESIZE:0,MOVE:1,ROTATE:2};class nl extends el{constructor(t,e,i){super(Oe.TRANSFORM,e,sl.MOVE,t),this.amount=i}isEquals(t){return super.isEquals(t)&&t instanceof nl&&this.amount===t.amount}toRuntime(){switch(this.opetype){case il.ABSOLUTE_X:return new $h(this);case il.ABSOLUTE_Y:return new qh(this);case il.FORWARD_OR_BACKWARD:return new Zh(this);case il.LEFT_OR_RIGHT:return new Jh(this);case il.RELATIVE_X:return new Qh(this);case il.RELATIVE_Y:return new tl(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.amount);return t.addResource(`[${this.type},${e},${this.subtype},${this.opetype},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(4,t,e.resources);return new nl(t[3],i,s)}}const ol={RELATIVE_SIZE:0,RELATIVE_HEIGHT:1,RELATIVE_WIDTH:2,ABSOLUTE_SIZE:3,ABSOLUTE_HEIGHT:4,ABSOLUTE_WIDTH:5};class rl extends ve{constructor(t,e){switch(super(t,e),t.opetype){case ol.RELATIVE_SIZE:this.size=fe.ofNumberOrOne(t.amount);break;case ol.ABSOLUTE_SIZE:this.size=fe.ofNumberOrOneHundred(t.amount);break;case ol.RELATIVE_HEIGHT:this.size=fe.ofNumberOrOne(t.amount);break;case ol.ABSOLUTE_HEIGHT:this.size=fe.ofNumberOrOneHundred(t.amount);break;case ol.RELATIVE_WIDTH:this.size=fe.ofNumberOrOne(t.amount);break;case ol.ABSOLUTE_WIDTH:this.size=fe.ofNumberOrOneHundred(t.amount);break;default:this.size=fe.ONE}}adjustPosition(t,e,i,s,n,o){const r=(-.5+n)*i,a=(-.5+o)*s;t.updateTransform();const h=t.transform,l=h.position,c=h.localTransform,u=!!(e.written&pe.POSITION_X),d=!!(e.written&pe.POSITION_Y),p=u?l.x:e.x,_=d?l.y:e.y;e.written|=pe.POSITION,l.set(p+r*c.a+a*c.c,_+r*c.b+a*c.d)}}class al extends rl{constructor(t){super(t,pe.HEIGHT|pe.POSITION),this.origin=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.HEIGHT?n.y:e.sizeY;n.y=Fi(s),e.written|=pe.HEIGHT,this.adjustPosition(t,e,0,o-n.y,.5,this.origin)}}}class hl extends rl{constructor(t){super(t,pe.HEIGHT|pe.POSITION),this.origin=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.HEIGHT?n.y:e.sizeY;n.y=Fi(o*s),e.written|=pe.HEIGHT,this.adjustPosition(t,e,0,o-n.y,.5,this.origin)}}}class ll extends rl{constructor(t){super(t,pe.SIZE|pe.POSITION),this.originX=t.originX,this.originY=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=Fi(this.size(t,i,ge)),n=t.size,o=!!(e.written&pe.WIDTH),r=!!(e.written&pe.HEIGHT),a=o?n.x:e.sizeX,h=r?n.y:e.sizeY;n.set(s,s),e.written|=pe.SIZE,this.adjustPosition(t,e,a-n.x,h-n.y,this.originX,this.originY)}}}class cl extends rl{constructor(t){super(t,pe.SIZE|pe.POSITION),this.originX=t.originX,this.originY=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=!!(e.written&pe.WIDTH),r=!!(e.written&pe.HEIGHT),a=o?n.x:e.sizeX,h=r?n.y:e.sizeY;n.set(Fi(a*s),Fi(h*s)),e.written|=pe.SIZE,this.adjustPosition(t,e,a-n.x,h-n.y,this.originX,this.originY)}}}class ul extends rl{constructor(t){super(t,pe.WIDTH|pe.POSITION),this.origin=t.originX}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.WIDTH?n.x:e.sizeX;n.x=Fi(s),e.written|=pe.WIDTH,this.adjustPosition(t,e,o-n.x,0,this.origin,.5)}}}class dl extends rl{constructor(t){super(t,pe.WIDTH|pe.POSITION),this.origin=t.originX}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.WIDTH?n.x:e.sizeX;n.x=Fi(o*s),e.written|=pe.WIDTH,this.adjustPosition(t,e,o-n.x,0,this.origin,.5)}}}class pl extends el{constructor(t,e,i,s,n){super(Oe.TRANSFORM,e,sl.RESIZE,t),this.originX=i,this.originY=s,this.amount=n}isEquals(t){return super.isEquals(t)&&t instanceof pl&&this.originX===t.originX&&this.originY===t.originY&&this.amount===t.amount}toRuntime(){switch(this.opetype){case ol.ABSOLUTE_HEIGHT:return new al(this);case ol.ABSOLUTE_WIDTH:return new ul(this);case ol.ABSOLUTE_SIZE:return new ll(this);case ol.RELATIVE_HEIGHT:return new hl(this);case ol.RELATIVE_WIDTH:return new dl(this);case ol.RELATIVE_SIZE:return new cl(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.amount);return t.addResource(`[${this.type},${e},${this.subtype},${this.opetype},${this.originX},${this.originY},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(6,t,e.resources);return new pl(t[3],i,t[4],t[5],s)}}class _l extends ve{constructor(t,e){super(t,e),this.originX=t.originX,this.originY=t.originY,this.amount=fe.ofNumber(`(${t.amount}) * (Math.PI / 180)`)}adjustPosition(t,e,i,s,n,o){const r=!!(e.written&pe.WIDTH),a=!!(e.written&pe.HEIGHT),h=(-.5+n)*(r?t.size.x:e.sizeX),l=(-.5+o)*(a?t.size.y:e.sizeY),c=Math.sin(i)-Math.sin(s),u=Math.cos(i)-Math.cos(s),d=t.transform.position,p=!!(e.written&pe.POSITION_X),_=!!(e.written&pe.POSITION_Y),g=p?d.x:e.x,f=_?d.y:e.y;e.written|=pe.POSITION,d.set(g+h*u-l*c,f+h*c+l*u)}}class gl extends _l{constructor(t){super(t,pe.ROTATION|pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=e.written&pe.ROTATION?n.rotation:e.rotation;n.rotation=s,e.written|=pe.ROTATION,this.adjustPosition(t,e,o,s,this.originX,this.originY)}}}class fl extends _l{constructor(t){super(t,pe.ROTATION|pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=e.written&pe.ROTATION?n.rotation:e.rotation;n.rotation=o+s,e.written|=pe.ROTATION,this.adjustPosition(t,e,o,n.rotation,this.originX,this.originY)}}}const ml={RELATIVE:0,ABSOLUTE:1};class vl extends el{constructor(t,e,i,s,n){super(Oe.TRANSFORM,e,sl.ROTATE,t),this.originX=i,this.originY=s,this.amount=n}isEquals(t){return super.isEquals(t)&&t instanceof vl&&this.originX===t.originX&&this.originY===t.originY&&this.amount===t.amount}toRuntime(){switch(this.opetype){case ml.ABSOLUTE:return new gl(this);case ml.RELATIVE:return new fl(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.amount);return t.addResource(`[${this.type},${e},${this.subtype},${this.opetype},${this.originX},${this.originY},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(6,t,e.resources);return new vl(t[3],i,t[4],t[5],s)}}const Tl=(t,e)=>{switch(t[0]){case Oe.SHOW_HIDE:switch(t[2]){case Hh.SHAPE_SHOW:case Hh.SHAPE_HIDE:return Vh.deserialize(t,e);case Hh.SHAPE:return Yh.deserialize(t,e);case Hh.LAYER:return Kh.deserialize(t,e)}break;case Oe.BLINK:return Re.deserialize(t,e);case Oe.CHANGE_COLOR:case Oe.CHANGE_COLOR_LEGACY:switch(t[3]){case Le.COLOR_AND_ALPHA:case Le.COLOR:case Le.ALPHA:return Ue.deserialize(t,e);case Le.CODE:return Ve.deserialize(t,e);case Le.BRIGHTNESS:return He.deserialize(t,e)}break;case Oe.CHANGE_TEXT:return Ai.deserialize(t,e);case Oe.CHANGE_CURSOR:return Ke.deserialize(t,e);case Oe.EMIT_EVENT:return Zo.deserialize(t,e);case Oe.OPEN:switch(t[2]){case Rr.DIALOG_TEXT:case Rr.DIALOG_INTEGER:case Rr.DIALOG_REAL:case Rr.DIALOG_BOOLEAN:case Rr.DIALOG_DATE:case Rr.DIALOG_TIME:case Rr.DIALOG_DATETIME:case Rr.DIALOG:return Lh.EXTENSION<=t[6]?zh.deserialize(t,e):Nh.deserialize(t,e);case Rr.DIAGRAM_LEGACY:case Rr.PAGE_LEGACY:case Rr.PAGE_INPLACE_LEGACY:case Rr.DIAGRAM:case Rr.PAGE:return Mr.deserialize(t,e);default:if(Rr.EXTENSION<=t[2])return Fh.deserialize(t,e)}break;case Oe.TRANSFORM:switch(t[2]){case sl.MOVE:return nl.deserialize(t,e);case sl.RESIZE:return pl.deserialize(t,e);case sl.ROTATE:return vl.deserialize(t,e)}break;case Oe.GESTURE:return mn.deserialize(t,e);case Oe.MISC:switch(t[2]){case fn.GESTURE:return mn.deserialize(t,e);case fn.SHOW_HIDE_LAYER:return Kh.deserialize(t,e);case fn.GESTURE_LAYER:return mn.deserialize(t,e);case fn.EXECUTE:return Sr.deserialize(t,e);default:return fn.EXTENSION<=t[2]?Or.deserialize(t,e):Cr.deserialize(t,e)}}return null},wl={},El=t=>{try{const e=JSON.parse(t);return vt(e)&&2<=e.length?e:null}catch(t){return null}},yl=(t,e,i)=>{const s=e.resources;if(0<=t&&t<s.length){const e=s[t];Et(e)&&(i.gradient=(t=>{const e=(t=>{try{return JSON.parse(t)}catch(t){return null}})(t);if(!(null==e||e.length<7)){const t=e[0],i=[];for(let t=1,s=e.length;t<s;t+=3)i.push({color:e[t+0],alpha:e[t+1],position:e[t+2]});return{points:i,direction:t}}})(e))}},xl={},Cl=t=>{const e=xl[t];if(null!=e)return"url"in e?Promise.resolve(e):e;{const e=new Promise((e,i)=>{const s=document.createElement("img");s.onload=()=>{const i={url:t,width:s.width,height:s.height,source:s};xl[t]=i,e(i)},s.onabort=s.onerror=()=>{i()},s.src=t});return xl[t]=e,e}},Dl=(t,e,i)=>{const s=e.resources;i.id=s[t[1]]||"";const n=i.transform;n.position.set(t[2],t[3]),n.rotation=t[6],n.skew.set(t[7],t[7]),n.pivot.set(t[21],t[22]),i.size.set(Fi(t[4]),Fi(t[5])),i.fill.deserialize(t[8],e),i.stroke.deserialize(t[9],e);const o=t[10];i.cursor=0<=o?s[o]:void 0,i.text.deserialize(t[11],e),i.data.deserialize(t[12],e),i.radius=t[13],i.corner=t[14];const r=t[23];i.interactive=!!(1&r);const a=i.state;a.isFocusable=!(2&r),a.isActive=!!(4&r);const h=t[24];i.shortcut=0<=h?s[h]:void 0;const l=t[25];i.title=0<=l?s[l]:void 0;const c=t[26];i.uuid=null!=c?c:0;const u=t[27],d=t[28],p=t[29];(null!=u&&u!==Ot.NONE||null!=d&&d!==Ot.NONE||null!=p&&p!==Ot.NONE)&&i.capability.set(u,d,p);const _=((t,e,i)=>{if(0<t.length){const s=[];for(let i=0,n=t.length;i<n;++i)s.push($i(t[i],e));return Promise.all(s).then(t=>{i.children=t;for(let e=0,s=t.length;e<s;++e)t[e].parent=i;return i.onChildTransformChange(),i.toDirty(),i})}return null})(t[20],e,i);((t,e,i)=>{const s=i.action,n=e.resources;for(let i=0,o=t.length;i<o;++i){const o=t[i],r=e.getAction(o);if(null!=r)s.add(r);else{const t=n[o];if(null!=t){const i=El(t);if(null!=i&&0<i.length){const t=i[0],n=Oe.EXTENSION<=t?wl[t]:Tl;if(null!=n){const t=n(i,e);null!=t&&(e.setAction(o,t),s.add(t))}}}}}})(t[17],e,i),yl(t[19],e,i);const g=((t,e,i)=>{const s=e.resources;if(0<=t&&t<s.length){const e=s[t];if(Et(e))return Cl(e).then(t=>(i.image=t,i))}return null})(t[18],e,i);return null!=_?null!=g?Promise.all([_,g]).then(()=>i):_:null!=g?g:i},Sl=(t,e,i)=>{i=i||new ae;const s=Dl(t,e,i);i.points.deserialize(t[15],e);const n=i.points.style,o=F.NON_SCALING_MASK|F.DOTTED_MASK|F.DASHED_MASK,r=n&o;return r&&(i.points.style&=~o,i.stroke.style|=r),s},bl=()=>{n[s.BAR]=ce,e[s.BAR]=Sl},Il=44,Ol=24,Al=[0,0,0,0,0],Rl=new t.Point,Ml=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+2,t[++s]=e+2,t[++s]=e+1,t[++s]=e+3,t[++s]=e+4,t[++s]=e+5,t[++s]=e+6,t[++s]=e+6,t[++s]=e+5,t[++s]=e+7,t[++s]=e+8,t[++s]=e+9,t[++s]=e+10,t[++s]=e+10,t[++s]=e+9,t[++s]=e+11,t[++s]=e+12,t[++s]=e+13,t[++s]=e+14,t[++s]=e+14,t[++s]=e+13,t[++s]=e+15,t[++s]=e+16,t[++s]=e+17,t[++s]=e+19,t[++s]=e+19,t[++s]=e+17,t[++s]=e+20,t[++s]=e+18,t[++s]=e+20,t[++s]=e+21,t[++s]=e+21,t[++s]=e+20,t[++s]=e+22,t[++s]=e+23,t[++s]=e+24,t[++s]=e+25,t[++s]=e+25,t[++s]=e+24,t[++s]=e+26,t[++s]=e+25,t[++s]=e+27,t[++s]=e+28,t[++s]=e+28,t[++s]=e+27,t[++s]=e+29,t[++s]=e+30,t[++s]=e+31,t[++s]=e+32,t[++s]=e+32,t[++s]=e+31,t[++s]=e+34,t[++s]=e+33,t[++s]=e+34,t[++s]=e+35,t[++s]=e+35,t[++s]=e+34,t[++s]=e+36,t[++s]=e+37,t[++s]=e+38,t[++s]=e+39,t[++s]=e+39,t[++s]=e+38,t[++s]=e+41,t[++s]=e+39,t[++s]=e+40,t[++s]=e+42,t[++s]=e+42,t[++s]=e+40,t[++s]=e+43},kl=(t,e,i,s,n,o,r,a,h,l,c)=>{const u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u),_=Math.abs(d),g=Math.abs(p),f=h*Math.min(_,g),m=f/_,v=f/g,T=Rl;T.set(i-d,s-p),l.apply(T,T);const w=T.x,E=T.y;T.set(i,s-p),l.apply(T,T);const y=T.x,x=T.y;T.set(i-d,s),l.apply(T,T);const C=T.x,D=T.y,S=y-w,b=x-E,I=C-w,O=D-E,A=y+S,R=x+b,M=C+S,k=D+b,L=A+I,N=R+O,P=C+I,B=D+O,z=P+S,U=B+b,F=z+S,H=U+b,G=m*S,V=m*b,W=v*I,K=v*O,X=w,Y=E,j=X+G,$=Y+V,q=X+W,Z=Y+K,J=q+G,Q=Z+V;let tt=2*e-1;t[++tt]=X,t[++tt]=Y,t[++tt]=j,t[++tt]=$,t[++tt]=q,t[++tt]=Z,t[++tt]=J,t[++tt]=Q;const et=A,it=R,st=A-G,nt=R-V,ot=st+W,rt=nt+K,at=ot+G,ht=rt+V;t[++tt]=st,t[++tt]=nt,t[++tt]=et,t[++tt]=it,t[++tt]=ot,t[++tt]=rt,t[++tt]=at,t[++tt]=ht;const lt=P,ct=B,ut=lt-W,dt=ct-K,pt=lt+G,_t=ct+V,gt=ut+G,ft=dt+V;t[++tt]=ut,t[++tt]=dt,t[++tt]=gt,t[++tt]=ft,t[++tt]=lt,t[++tt]=ct,t[++tt]=pt,t[++tt]=_t;const mt=F,vt=H,Tt=mt-G,wt=vt-V,Et=mt-W,yt=vt-K,xt=Et-G,Ct=yt-V;t[++tt]=xt,t[++tt]=Ct,t[++tt]=Et,t[++tt]=yt,t[++tt]=Tt,t[++tt]=wt,t[++tt]=mt,t[++tt]=vt;const Dt=j,St=$,bt=y,It=x,Ot=q,At=Z,Rt=J,Mt=Q,kt=bt+W,Lt=It+K,Nt=C,Pt=D,Bt=M,zt=k;t[++tt]=Dt,t[++tt]=St,t[++tt]=bt,t[++tt]=It,t[++tt]=Ot,t[++tt]=At,t[++tt]=Rt,t[++tt]=Mt,t[++tt]=kt,t[++tt]=Lt,t[++tt]=Nt,t[++tt]=Pt,t[++tt]=Bt,t[++tt]=zt;const Ut=bt,Ft=It,Ht=st,Gt=nt,Vt=kt,Wt=Lt,Kt=ot,Xt=rt,Yt=at,jt=ht,$t=Bt,qt=zt,Zt=L,Jt=N;t[++tt]=Ut,t[++tt]=Ft,t[++tt]=Ht,t[++tt]=Gt,t[++tt]=Vt,t[++tt]=Wt,t[++tt]=Kt,t[++tt]=Xt,t[++tt]=Yt,t[++tt]=jt,t[++tt]=$t,t[++tt]=qt,t[++tt]=Zt,t[++tt]=Jt;const Qt=Nt,te=Pt,ee=Bt,ie=zt,se=ut,ne=dt,oe=gt,re=ft,ae=z-W,he=U-K,le=pt,ce=_t,ue=z,de=U;t[++tt]=Qt,t[++tt]=te,t[++tt]=ee,t[++tt]=ie,t[++tt]=se,t[++tt]=ne,t[++tt]=oe,t[++tt]=re,t[++tt]=ae,t[++tt]=he,t[++tt]=le,t[++tt]=ce,t[++tt]=ue,t[++tt]=de;const pe=ee,_e=ie,ge=Zt,fe=Jt,me=ae,ve=he,Te=xt,we=Ct,Ee=Et,ye=yt,xe=ue,Ce=de,De=Tt,Se=wt;t[++tt]=pe,t[++tt]=_e,t[++tt]=ge,t[++tt]=fe,t[++tt]=me,t[++tt]=ve,t[++tt]=Te,t[++tt]=we,t[++tt]=Ee,t[++tt]=ye,t[++tt]=xe,t[++tt]=Ce,t[++tt]=De,t[++tt]=Se,c[0]=_,c[1]=g,c[2]=f,c[3]=m,c[4]=v},Ll=(t,e,i,s,n,o,r)=>{const a=h(n),l=r[0],c=r[1],u=r[2],_=s&V.TOP?1:0,g=s&V.RIGHT?1:0,f=s&V.BOTTOM?1:0,m=s&V.LEFT?1:0,v=d(0,a,m,_),T=d(0,a,g,_),w=d(0,a,m,f),E=d(0,a,g,f),y=d(1,a,m,_),x=d(1,a,g,_),C=d(1,a,m,f),D=d(1,a,g,f),S=1-r[3],b=1-r[4],I=p(1,1),O=p(0,1),A=p(1,0),R=p(0,0),M=p(S,1),k=p(1,b),L=p(S,b),N=p(0,b);let P=6*e-1;o&nt.TOP_LEFT?(t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0):(t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0),o&nt.TOP_RIGHT?(t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0):(t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0),o&nt.BOTTOM_LEFT?(t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0):(t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0),o&nt.BOTTOM_RIGHT?(t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0):(t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0),t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0},Nl=(t,e,i,s)=>{const n=i.x0,o=i.y0,r=i.x1,a=i.y1,h=i.x2,l=i.y2,c=i.x3,u=i.y3,d=.5*(n+r),p=.5*(o+a),_=.5*(n+c),g=.5*(o+u),f=d-n,m=p-o,v=_-n,T=g-o,w=_+f,E=g+m,y=r+v,x=a+T,C=c+f,D=u+m,S=s[3],b=s[4],I=S*f,O=S*m,A=b*v,R=b*T,M=n,k=o,L=M+I,N=k+O,P=M+A,B=k+R,z=P+I,U=B+O;let F=2*e-1;t[++F]=M,t[++F]=k,t[++F]=L,t[++F]=N,t[++F]=P,t[++F]=B,t[++F]=z,t[++F]=U;const H=r,G=a,V=r-I,W=a-O,K=V+A,X=W+R,Y=K+I,j=X+O;t[++F]=V,t[++F]=W,t[++F]=H,t[++F]=G,t[++F]=K,t[++F]=X,t[++F]=Y,t[++F]=j;const $=c,q=u,Z=$-A,J=q-R,Q=$+I,tt=q+O,et=Z+I,it=J+O;t[++F]=Z,t[++F]=J,t[++F]=et,t[++F]=it,t[++F]=$,t[++F]=q,t[++F]=Q,t[++F]=tt;const st=h,nt=l,ot=st-I,rt=nt-O,at=st-A,ht=nt-R,lt=at-I,ct=ht-O;t[++F]=lt,t[++F]=ct,t[++F]=at,t[++F]=ht,t[++F]=ot,t[++F]=rt,t[++F]=st,t[++F]=nt;const ut=L,dt=N,pt=d,_t=p,gt=P,ft=B,mt=z,vt=U,Tt=pt+A,wt=_t+R,Et=_,yt=g,xt=w,Ct=E;t[++F]=ut,t[++F]=dt,t[++F]=pt,t[++F]=_t,t[++F]=gt,t[++F]=ft,t[++F]=mt,t[++F]=vt,t[++F]=Tt,t[++F]=wt,t[++F]=Et,t[++F]=yt,t[++F]=xt,t[++F]=Ct;const Dt=pt,St=_t,bt=V,It=W,Ot=Tt,At=wt,Rt=K,Mt=X,kt=Y,Lt=j,Nt=xt,Pt=Ct,Bt=y,zt=x;t[++F]=Dt,t[++F]=St,t[++F]=bt,t[++F]=It,t[++F]=Ot,t[++F]=At,t[++F]=Rt,t[++F]=Mt,t[++F]=kt,t[++F]=Lt,t[++F]=Nt,t[++F]=Pt,t[++F]=Bt,t[++F]=zt;const Ut=Et,Ft=yt,Ht=xt,Gt=Ct,Vt=Z,Wt=J,Kt=et,Xt=it,Yt=C-A,jt=D-R,$t=Q,qt=tt,Zt=C,Jt=D;t[++F]=Ut,t[++F]=Ft,t[++F]=Ht,t[++F]=Gt,t[++F]=Vt,t[++F]=Wt,t[++F]=Kt,t[++F]=Xt,t[++F]=Yt,t[++F]=jt,t[++F]=$t,t[++F]=qt,t[++F]=Zt,t[++F]=Jt;const Qt=Ht,te=Gt,ee=Bt,ie=zt,se=Yt,ne=jt,oe=lt,re=ct,ae=at,he=ht,le=Zt,ce=Jt,ue=ot,de=rt;t[++F]=Qt,t[++F]=te,t[++F]=ee,t[++F]=ie,t[++F]=se,t[++F]=ne,t[++F]=oe,t[++F]=re,t[++F]=ae,t[++F]=he,t[++F]=le,t[++F]=ce,t[++F]=ue,t[++F]=de};class Pl extends W{constructor(t,e,i){super(t,e,i,Il,Ol),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices(),Ml(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=e.radius,r=s!==this.sizeX||n!==this.sizeY||o!==this.radius,a=K(e),h=this.transformLocalId!==a,l=e.stroke,c=l.align,u=l.enable?l.width:0,d=l.side,p=l.style,_=this.strokeAlign!==c||this.strokeWidth!==u||this.strokeSide!==d||this.strokeStyle!==p,g=e.corner,f=g!==this.corner,m=X(e),v=Y(m),T=m!==this.texture||v!==this.textureTransformId,w=r||_,E=!(this.inited&H.VERTEX_STEP_AND_UV);if(E||w||h||f||T){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.radius=o,this.transformLocalId=a,this.strokeAlign=c,this.strokeWidth=u,this.strokeSide=d,this.strokeStyle=p,this.corner=g,this.texture=m,this.textureTransformId=v;const i=this.vertexOffset;t.updateVertices(),kl(t.vertices,i,0,0,s,n,c,u,o,e.transform.internalTransform,Al),(E||w||f||h)&&(t.updateSteps(),Ll(t.steps,i,u,d,p,g,Al)),(E||w||T)&&(t.updateUvs(),Nl(t.uvs,i,j(m),Al))}}}const Bl=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=Il+a,c=Ol+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new Pl(t,i,s),new le(t,i+Il,s+Ol,a,h)]).init(e):null},zl=(t,e,i,s,n)=>Bl(t,e,i,s),Ul=(t,e,i,s,n,o)=>{const r=-i+n;if(t<=r){const a=-s+n;if(e<=a&&o&nt.TOP_LEFT){const i=t-r,s=e-a;return i*i+s*s<=n*n}{const a=+s-n;if(a<=e&&o&nt.BOTTOM_LEFT){const i=t-r,s=e-a;return i*i+s*s<=n*n}return-i<=t}}{const r=+i-n;if(r<=t){const a=-s+n;if(e<=a&&o&nt.TOP_RIGHT){const i=t-r,s=e-a;return i*i+s*s<=n*n}{const a=+s-n;if(a<=e&&o&nt.BOTTOM_RIGHT){const i=t-r,s=e-a;return i*i+s*s<=n*n}return t<=+i}}return-s<=e&&e<=+s}},Fl=(t,e,i,s,n,o,r)=>{const a=t.fill;if(a.enable||0<o){const h=t.radius*Math.min(s,n),l=t.corner;if(Ul(e,i,s,n,h,l)){if(a.enable)return!0;{const a=o*r,c=Math.max(0,s-a),u=Math.max(0,n-a),d=Math.max(0,h-a);if(!Ul(e,i,c,u,d,l)){const s=t.stroke.side;if(s===V.ALL)return!0;if(e<=-c+d){const t=!!(s&V.LEFT);if(i<=-u+d){const n=!!(s&V.TOP);return!(!n||!t)||(n?-c<=i:!!t&&e<=-c)}if(+u-d<=i){const n=!!(s&V.BOTTOM);return!(!n||!t)||(n?+c<=i:!!t&&e<=-c)}return t}if(+c-d<=e){const t=!!(s&V.RIGHT);if(i<=-u+d){const n=!!(s&V.TOP);return!(!n||!t)||(n?-c<=i:!!t&&+c<=e)}if(+u-d<=i){const n=!!(s&V.BOTTOM);return!(!n||!t)||(n?+c<=i:!!t&&+c<=e)}return t}return i<=-u+d?!!(s&V.TOP):+u-d<=i&&!!(s&V.BOTTOM)}}}}return!1};class Hl extends te{constructor(t=s.RECTANGLE_ROUNDED){super(t)}clone(){return new Hl(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&Fl(this,t,e,i,s,n,o)}}class Gl extends Hl{constructor(t=s.BUTTON){super(t),this._isToggle=!1,this._isGrouped=!1}get isToggle(){return this._isToggle}set isToggle(t){this._isToggle=t}get isGrouped(){return this._isGrouped}set isGrouped(t){this._isGrouped=t}copy(t,e){return super.copy(t,e),t instanceof Gl&&(this._isToggle=t.isToggle,this._isGrouped=t.isGrouped),this}clone(){return new Gl(this.type).copy(this)}serialize(t){const e=super.serialize(t),i=this._isToggle?1:0,s=this._isGrouped?2:0;return e[15]=t.addResource(`[${i|s}]`),e}}const Vl=(t,e,i)=>{i=i||new Gl;const s=e.resources,n=t[15];if(0<=n&&n<s.length){let t=e.getExtension(n);null==t&&(t=JSON.parse(s[n]),e.setExtension(n,t)),i.isToggle=!!(1&t[0]),i.isGrouped=!!(2&t[0])}return Dl(t,e,i)};class Wl extends me{constructor(t){super(pe.COLOR_FILL_AND_STROKE|pe.COLOR_TEXT|pe.COLOR_TEXT_OUTLINE|pe.CURSOR);const e=t.fill,i=e.color,s=this.toOnHovered(i),n=2*s;this._fillColor=i,this._fillColorDisabled=de.toGrayscale(i),this._fillColorPressed=de.darken(i,n),this._fillColorHovered=de.darken(i,s);const o=e.alpha;this._fillAlpha=o,this._fillAlphaDisabled=.5*o;const r=t.stroke,a=r.color,h=this.toOnHovered(a),l=2*h;this._strokeColor=a,this._strokeColorDisabled=de.toGrayscale(a),this._strokeColorPressed=de.darken(a,l),this._strokeColorHovered=de.darken(a,h);const c=r.alpha;this._strokeAlpha=c,this._strokeAlphaDisabled=.5*c;const u=t.text,d=u.color;this._textColor=d,this._textColorDisabled=de.toGrayscale(d);const p=u.alpha;this._textAlpha=p,this._textAlphaDisabled=.5*p;const _=u.outline,g=_.color;this._textOutlineColor=g,this._textOutlineColorDisabled=de.toGrayscale(g);const f=_.alpha;this._textOutlineAlpha=f,this._textOutlineAlphaDisabled=.5*f}toOnHovered(t){const e=de.toLuma(t);if(128<=e){const t=(e-128)/127;return.15*(1-t)+.03*t}{const t=(127-e)/127;return-.15*(1-t)-.175*t}}execute(t,e,i){const s=t.state;t.fill.set(void 0,this.getFillColor(s),this.getFillAlpha(s)),t.stroke.set(void 0,this.getStrokeColor(s),this.getStrokeAlpha(s)),t.text.set(void 0,this.getTextColor(s),this.getTextAlpha(s)),t.text.outline.set(void 0,this.getTextOutlineColor(s),this.getTextOutlineAlpha(s)),t.cursor=this.getCursor(s),e.written|=this.reset}getFillColor(t){return t.inDisabled?this._fillColorDisabled:t.isPressed||t.isActive?this._fillColorPressed:t.isFocused||t.isHovered?this._fillColorHovered:this._fillColor}getFillAlpha(t){return t.inDisabled?this._fillAlphaDisabled:this._fillAlpha}getStrokeColor(t){return t.inDisabled?this._strokeColorDisabled:t.isPressed||t.isActive?this._strokeColorPressed:t.isFocused||t.isHovered?this._strokeColorHovered:this._strokeColor}getStrokeAlpha(t){return t.inDisabled?this._strokeAlphaDisabled:this._strokeAlpha}getTextColor(t){return t.inDisabled?this._textColorDisabled:this._textColor}getTextAlpha(t){return t.inDisabled?this._textAlphaDisabled:this._textAlpha}getTextOutlineColor(t){return t.inDisabled?this._textOutlineColorDisabled:this._textOutlineColor}getTextOutlineAlpha(t){return t.inDisabled?this._textOutlineAlphaDisabled:this._textOutlineAlpha}getCursor(t){return t.isActionable?"pointer":""}}class Kl extends me{constructor(t){super(pe.COLOR_FILL_AND_STROKE|pe.COLOR_TEXT|pe.COLOR_TEXT_OUTLINE|pe.CURSOR);const e=t.fill,i=e.color;this._fillColorActive=i;const s=this.toOnHovered(i),n=2*s;this._fillColorActivePressed=de.darken(i,n),this._fillColorActiveHovered=de.darken(i,s);const o=15197671;this._fillColor=o;const r=this.toOnHovered(o),a=2*r;this._fillColorPressed=de.darken(o,a),this._fillColorHovered=de.darken(o,r);const h=e.alpha;this._fillAlpha=h,this._fillAlphaDisabled=.5*h;const l=t.stroke,c=l.color;this._strokeColorActive=c;const u=this.toOnHovered(c),d=2*u;this._strokeColorActivePressed=de.darken(c,d),this._strokeColorActiveHovered=de.darken(c,u);const p=15197671;this._strokeColor=p;const _=this.toOnHovered(p),g=2*_;this._strokeColorPressed=de.darken(p,g),this._strokeColorGrayscaleHovered=de.darken(p,_);const f=l.alpha;this._strokeAlpha=f,this._strokeAlphaDisabled=.5*f;const m=t.text,v=m.color;this._textColorActive=v,this._textColorDisabled=de.toGrayscale(v),this._textColor=5197647;const T=m.alpha;this._textAlpha=T,this._textAlphaDisabled=.5*T;const w=m.outline,E=w.color;this._textOutlineColor=E,this._textOutlineColorDisabled=de.toGrayscale(E);const y=w.alpha;this._textOutlineAlpha=y,this._textOutlineAlphaDisabled=.5*y}toOnHovered(t){const e=de.toLuma(t);if(128<=e){const t=(e-128)/127;return.15*(1-t)+.03*t}{const t=(127-e)/127;return-.15*(1-t)-.175*t}}execute(t,e,i){const s=t.state;t.fill.set(void 0,this.getFillColor(s),this.getFillAlpha(s)),t.stroke.set(void 0,this.getStrokeColor(s),this.getStrokeAlpha(s)),t.text.set(void 0,this.getTextColor(s),this.getTextAlpha(s)),t.text.outline.set(void 0,this.getTextOutlineColor(s),this.getTextOutlineAlpha(s)),t.cursor=this.getCursor(s),e.written|=this.reset}getFillColor(t){return t.inDisabled?this._fillColor:t.isActive?t.isPressed?this._fillColorActivePressed:t.isFocused||t.isHovered?this._fillColorActiveHovered:this._fillColorActive:t.isPressed?this._fillColorPressed:t.isFocused||t.isHovered?this._fillColorHovered:this._fillColor}getFillAlpha(t){return t.inDisabled?this._fillAlphaDisabled:this._fillAlpha}getStrokeColor(t){return t.inDisabled?this._strokeColor:t.isActive?t.isPressed?this._strokeColorActivePressed:t.isFocused||t.isHovered?this._strokeColorActiveHovered:this._strokeColorActive:t.isPressed?this._strokeColorPressed:t.isFocused||t.isHovered?this._strokeColorGrayscaleHovered:this._strokeColor}getStrokeAlpha(t){return t.inDisabled?this._strokeAlphaDisabled:this._strokeAlpha}getTextColor(t){return t.inDisabled?this._textColorDisabled:t.isActive?this._textColorActive:this._textColor}getTextAlpha(t){return t.inDisabled?this._textAlphaDisabled:this._textAlpha}getTextOutlineColor(t){return t.inDisabled?this._textOutlineColorDisabled:this._textOutlineColor}getTextOutlineAlpha(t){return t.inDisabled?this._textOutlineAlphaDisabled:this._textOutlineAlpha}getCursor(t){return t.isActionable?"pointer":""}}class Xl extends Eo{constructor(t){super(t),t instanceof Gl&&(this._isToggle=t.isToggle,this._isGrouped=t.isGrouped)}isActionable(){return!0}initialize(t){this.actions.unshift(this._isToggle?new Kl(this):new Wl(this)),super.initialize(t)}onClick(t,e){const i=t.state,s=i.isClicked;i.lock(),super.onClick(t,e),!s&&i.isClicked&&(this._isToggle?i.isActive=!i.isActive:i.isActive||(i.isActivated=!0)),i.unlock()}onStateChange(t,e,i){super.onStateChange(t,e,i),this._isToggle&&this._isGrouped&&e.is(Ct.ACTIVATED)&&this.onActivated(t)}onActivated(t){const e=t.parent;if(null!=e){const i=e.children;for(let e=0,s=i.length;e<s;++e){const s=i[e];s!==t&&s instanceof Gl&&s.isToggle&&s.isGrouped&&(s.state.isActive=!1)}}}}const Yl=()=>{n[s.BUTTON]=zl,e[s.BUTTON]=Vl,bo[s.BUTTON]=Xl,Ui.set(s.BUTTON,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)},jl=[0,0],$l=new t.Point,ql=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+4,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+4,t[++s]=e+2,t[++s]=e+5,t[++s]=e+4,t[++s]=e+3,t[++s]=e+4,t[++s]=e+6,t[++s]=e+4,t[++s]=e+7,t[++s]=e+6,t[++s]=e+4,t[++s]=e+5,t[++s]=e+7,t[++s]=e+5,t[++s]=e+8,t[++s]=e+7},Zl=(t,e,i,s,n,o,r,a,h,l)=>{const c=$l,u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u);c.set(-d+i,-p+s),h.apply(c,c);const _=c.x,g=c.y;c.set(0+i,-p+s),h.apply(c,c);const f=c.x,m=c.y,v=f-_,T=m-g;c.set(i,s),h.apply(c,c);const w=c.x,E=c.y,y=w+(w-f),x=E+(E-m),D=w-v,S=E-T;let b=2*e-1;t[++b]=_,t[++b]=g,t[++b]=f,t[++b]=m,t[++b]=f+v,t[++b]=m+T,t[++b]=D,t[++b]=S,t[++b]=w,t[++b]=E,t[++b]=w+v,t[++b]=E+T,t[++b]=y-v,t[++b]=x-T,t[++b]=y,t[++b]=x,t[++b]=y+v,t[++b]=x+T,l[0]=C(_,g,f,m),l[1]=C(_,g,D,S)},Jl=(t,e,i,s,n)=>{const o=h(s),r=n[0],a=n[1],l=d(1,o,1,1),c=p(1,1),u=p(0,1),_=p(1,0),g=p(0,0);let f=6*e-1;t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=u,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=g,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=u,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0},Ql=(t,e,i)=>{const s=i.x0,n=i.x1,o=i.x2,r=i.x3,a=i.y0,h=i.y1,l=i.y2,c=i.y3;let u=2*e-1;t[++u]=s,t[++u]=a,t[++u]=.5*(s+n),t[++u]=.5*(a+h),t[++u]=n,t[++u]=h,t[++u]=.5*(s+r),t[++u]=.5*(a+c),t[++u]=.5*(s+o),t[++u]=.5*(a+l),t[++u]=.5*(n+o),t[++u]=.5*(h+l),t[++u]=r,t[++u]=c,t[++u]=.5*(r+o),t[++u]=.5*(c+l),t[++u]=o,t[++u]=l};class tc extends W{constructor(t,e,i){super(t,e,i,9,8)}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset;ql(t.indices,e,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u;(!(this.inited&H.VERTEX_AND_STEP)||o||a||d)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,t.updateVertices(),t.updateSteps(),Zl(t.vertices,this.vertexOffset,0,0,s,n,l,c,e.transform.internalTransform,jl),Jl(t.steps,this.vertexOffset,c,u,jl))}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=j(i);Ql(t.uvs,this.vertexOffset,e)}}}const ec=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=9+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new tc(t,i,s),new le(t,i+9,s+8,a,h)]).init(e):null},ic=(t,e,i)=>Dl(t,e,i||new Bi),sc=()=>{n[s.CIRCLE]=ec,e[s.CIRCLE]=ic},nc=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),oc=[0,1],rc=[0,1],ac=t=>t?t.formatted.plength:0,hc=t=>{const e=ac(t);return(e>>4)+(0<(15&e)?1:0)<<4},lc=(t,e)=>e?2+(t<<2):t<<2,cc=(t,e)=>lc(t,e)-2,uc=(t,e,i,s)=>{let n=3*i-1;const o=3*(i+s)-1;let r=e;for(;n<o;)t[++n]=r+0,t[++n]=r+2,t[++n]=r+1,t[++n]=r+1,t[++n]=r+2,t[++n]=r+3,r+=2},dc=(t,e,i,s,n,o)=>{const r=1/Math.max(1e-5,o),a=n.x0,h=n.x1,l=n.x2,c=n.x3,u=n.y0,d=n.y1,p=n.y2,_=n.y3,g=h-a,f=d-u,m=l-c,v=p-_;let T=(i<<1)-1;const w=(i+s<<1)-1;let E=6*i-9;for(;T<w;){const i=e[E+=12]*r;t[++T]=a+i*g,t[++T]=u+i*f,t[++T]=c+i*m,t[++T]=_+i*v}};let pc;const _c=(t,e,i,s,n,o,r,a,h,l,c)=>{let u=pc;null==u&&(u=[],pc=u);const d=c.a,p=c.b,_=c.c,g=c.d,f=c.tx,m=c.ty;for(let t=0;t<n;++t){const e=t<<1,i=r[e],s=r[e+1];u[e]=d*i+_*s+f,u[e+1]=p*i+g*s+m}return fc(t,e,i,s,n,o,u,a,h,l)},gc=(t,e,i,s,n,o,r,a,h,l,c,d,p,_)=>{const g=u(a,h),f=Math.min(l,c);e[++t]=n,e[++t]=o,s[++i]=r,s[++i]=p,s[++i]=g,s[++i]=d,s[++i]=d,s[++i]=f,e[++t]=n,e[++t]=o,s[++i]=r,s[++i]=_,s[++i]=g,s[++i]=d,s[++i]=d,s[++i]=f},fc=(t,e,i,s,n,o,r,a,h,l)=>{const c=a.length;if(0<c){if(o){let o=0,u=0,d=i,p=0,_=a[0];for(let i=1;i<c;++i)p=a[i],2<=p-_&&(u=vc(t,e,d,-1,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)),_=p;return p=a[0]+n,2<=p-_?(u=vc(t,e,d,i+s-d,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)):mc(t,e,d,i+s-d,r,_,p,n,h,l,u),o}{let o=0,u=0,d=i,p=a[0];2<=p&&(u=vc(t,e,d,-1,r,0,p,n,h,l,u),o=Math.max(o,u),d+=lc(p,!1));let _=p;for(let i=1;i<c;++i)p=a[i],2<=p-_&&(u=vc(t,e,d,-1,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)),_=p;return p=n,2<=p-_?(u=vc(t,e,d,i+s-d,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)):mc(t,e,d,i+s-d,r,_,p,n,h,l,u),o}}return o?Tc(t,e,i,s,r,0,n,n,h,l):vc(t,e,i,s,r,0,n,n,h,l,0)},mc=(t,e,i,s,n,o,r,l,c,u,p)=>{if(0<=s){const r=h(u),c=a(u),_=d(3,r,c,0),g=d(5,r,c,0);let f=(i<<1)-1,m=6*i-1;const v=(i+s<<1)-1,T=o%l<<1,w=n[T],E=n[T+1];for(;f<v;)t[++f]=w,t[++f]=E,e[++m]=0,e[++m]=_,e[++m]=0,e[++m]=p,e[++m]=p,e[++m]=0,t[++f]=w,t[++f]=E,e[++m]=0,e[++m]=g,e[++m]=0,e[++m]=p,e[++m]=p,e[++m]=0}return 0},vc=(t,e,i,s,n,o,r,p,_,g,f)=>{const m=h(g),v=a(g),T=d(3,m,v,0),w=d(4,m,v,0),E=d(5,m,v,0),y=d(6,m,v,0),x=o%p<<1;let C=n[x],D=n[x+1];const S=(o+1)%p<<1;let b=n[S],I=n[S+1],O=C-(b-C),A=D-(I-D);const R=oc,M=rc;l(O,A,C,D,R),l(C,D,b,I,M);let k=nc(R),L=k;c(R,k),c(M,L);let N=(i<<1)-1,P=6*i-1,B=0;gc(N,t,P,e,C,D,_,R,M,k,L,f,T,E),N+=4,P+=12,gc(N,t,P,e,C,D,_,R,M,k,L,B,w,y),N+=4,P+=12;for(let i=o+1,s=r-1;i<s;++i){O=C,A=D,C=b,D=I,R[0]=M[0],R[1]=M[1],k=L;const s=(i+1)%p<<1;b=n[s],I=n[s+1],l(C,D,b,I,M),L=nc(M),c(M,L),B+=k,gc(N,t,P,e,C,D,_,R,M,k,L,B,T,E),N+=4,P+=12,gc(N,t,P,e,C,D,_,R,M,k,L,B,w,y),N+=4,P+=12}O=C,A=D,C=b,D=I,R[0]=M[0],R[1]=M[1],k=L,b=C+(C-O),I=D+(D-A),l(C,D,b,I,M),c(M,L),B+=k,gc(N,t,P,e,C,D,_,R,M,k,L,B,T,E),N+=4,P+=12,gc(N,t,P,e,C,D,_,R,M,k,L,B,w,y),N+=4,P+=12;const z=6*i-1;for(let t=z,i=z+12;t<i;t+=6)e[t+5]=f;for(let t=z+12;t<P;t+=6)e[t+5]=B;if(0<=s){const n=u(R,M),o=(i+s<<1)-1;for(;N<o;)t[++N]=C,t[++N]=D,e[++P]=0,e[++P]=T,e[++P]=n,e[++P]=B,e[++P]=B,e[++P]=0,t[++N]=C,t[++N]=D,e[++P]=0,e[++P]=E,e[++P]=n,e[++P]=B,e[++P]=B,e[++P]=0}return B},Tc=(t,e,i,s,n,o,r,p,_,g)=>{const f=h(g),m=a(g),v=d(3,f,m,0),T=d(4,f,m,0),w=d(5,f,m,0),E=d(6,f,m,0),y=(r-1)%p<<1;let x=0,C=0,D=n[y],S=n[y+1];const b=o%p<<1;let I=n[b],O=n[b+1];const A=oc,R=rc;l(x,C,D,S,A),l(D,S,I,O,R);let M=nc(A),k=nc(R);c(A,M),c(R,k);let L=0,N=(i<<1)-1,P=6*i-1;for(let i=o;i<r;++i){x=D,C=S,D=I,S=O,A[0]=R[0],A[1]=R[1],M=k;const s=(i+1)%p<<1;I=n[s],O=n[s+1],l(D,S,I,O,R),k=nc(R),c(R,k),L+=M,gc(N,t,P,e,D,S,_,A,R,M,k,L,v,w),N+=4,P+=12,gc(N,t,P,e,D,S,_,A,R,M,k,L,T,E),N+=4,P+=12}x=D,C=S,D=I,S=O,A[0]=R[0],A[1]=R[1],M=k;const B=(o+1)%p<<1;I=n[B],O=n[B+1],l(D,S,I,O,R),k=nc(R),c(R,k),L+=M,gc(N,t,P,e,D,S,_,A,R,M,k,L,v,w),N+=4,P+=12;for(let t=6*i-1;t<P;t+=6)e[t+5]=-L;if(0<=s){const n=u(A,R),o=(i+s<<1)-1;for(;N<o;)t[++N]=D,t[++N]=S,e[++P]=_,e[++P]=v,e[++P]=n,e[++P]=L,e[++P]=-L,e[++P]=0,t[++N]=D,t[++N]=S,e[++P]=_,e[++P]=w,e[++P]=n,e[++P]=L,e[++P]=-L,e[++P]=0}return L};class wc extends W{constructor(t,e,i,s,n){super(t,e,i,s,n),this.pointId=-1,this.pointCount=0,this.pointsClosed=!1,this.length=1}init(){const t=this.buffer;t.updateIndices(),uc(t.indices,this.vertexOffset,this.indexOffset,this.indexCount),this.inited|=H.INDEX}reinit(t,e,i,s){const n=hc(e.points),o=lc(n,!0),r=cc(n,!0);return this.buffer===t&&this.vertexOffset===i&&this.indexOffset===s&&this.vertexCount===o&&this.indexCount===r||!!t.check(i,s,o,r)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.vertexCount=o,this.indexCount=r,this.init(),!0)}isCompatible(t){return lc(hc(t.points),!0)===this.vertexCount}update(t){const e=this.buffer;this.updateLineVertexStep(e,t),this.updateColor(e,t),this.updateLineUv(e,t)}updateLineVertexStep(t,e){const i=e.points;if(i){const s=i.id,n=i.formatted,o=n.length,r=!!(n.style&F.CLOSED),a=s!==this.pointId||o!==this.pointCount||r!==this.pointsClosed,h=e.stroke,l=h.enable?h.width:0,c=h.style,u=this.strokeWidth!==l||this.strokeStyle!==c,d=K(e),p=this.transformLocalId!==d;(!(this.inited&H.VERTEX_AND_STEP)||a||p||u)&&(this.inited|=H.VERTEX_AND_STEP,this.pointId=s,this.pointCount=o,this.pointsClosed=r,this.strokeWidth=l,this.strokeStyle=c,this.transformLocalId=d,a&&(this.inited&=~H.UV),t.updateVertices(),t.updateSteps(),this.length=_c(t.vertices,t.steps,this.vertexOffset,this.vertexCount,this.pointCount,this.pointsClosed,n.values,n.segments,l,c,e.transform.internalTransform))}}updateLineUv(t,e){const i=X(e),s=Y(i);(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId)&&(this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs(),dc(t.uvs,t.steps,this.vertexOffset,this.vertexCount,j(i),this.length))}}const Ec=[0,0,0],yc=new t.Point,xc=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+2,t[++s]=e+0,t[++s]=e+3,t[++s]=e+4,t[++s]=e+0,t[++s]=e+5,t[++s]=e+6},Cc=(t,e,i,s,n,o,r,a,h,l)=>{const c=r*a,u=.5*n+(0<=n?+c:-c),d=.5*o+(0<=o?+c:-c),p=2*u*d/(u+Math.sqrt(u*u+4*d*d)),_=yc;_.set(i,s-d),h.apply(_,_);const g=_.x,f=_.y;_.set(i,s),h.apply(_,_);const m=_.x,v=_.y;_.set(i+u,s),h.apply(_,_);const T=m-g,w=v-f,E=_.x+T,y=_.y+w,x=m+(m-_.x)+T,D=v+(v-_.y)+w;_.set(i,s+d-p),h.apply(_,_);const S=_.x,b=_.y,I=m+T,O=v+w;l[0]=C(I,O,S,b),l[1]=C(E,y,I,O),l[2]=C(g,f,m,v);let A=(e<<1)-1;t[++A]=S,t[++A]=b,t[++A]=g,t[++A]=f,t[++A]=E,t[++A]=y,t[++A]=E,t[++A]=y,t[++A]=x,t[++A]=D,t[++A]=x,t[++A]=D,t[++A]=g,t[++A]=f},Dc=(t,e,i,s,n)=>{const o=h(s),r=n[0],a=d(0,o,1,1),l=p(0,0),c=p(1,0),u=p(0,1);let _=6*e-1;t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=l,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=u,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=u,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0},Sc=(t,e,i,s)=>{const n=e.x0,o=e.x1,r=e.x2,a=e.x3,h=e.y0,l=e.y1,c=e.y2,u=e.y3,d=.5*(n+o),p=.5*(h+l),_=1-.5*s[0]/s[2],g=d+_*(a-n),f=p+_*(u-h);let m=(i<<1)-1;t[++m]=g,t[++m]=f,t[++m]=d,t[++m]=p,t[++m]=r,t[++m]=c,t[++m]=r,t[++m]=c,t[++m]=a,t[++m]=u,t[++m]=a,t[++m]=u,t[++m]=d,t[++m]=p};class bc extends W{updateColor(t,e){let i=16777215,s=1;const n=e.points;if(null!=n){const t=n.getMarker();if(null!=t){const n=this.toMarker(t).fill;i=n.color,s=e.visible&&n.enable?n.alpha:0}}const o=e.stroke,r=o.color,a=e.visible&&o.enable&&0<o.width?o.alpha:0;(!(this.inited&H.COLOR)||i!==this.colorFill||s!==this.alphaFill||r!==this.colorStroke||a!==this.alphaStroke)&&(this.inited|=H.COLOR,this.colorFill=i,this.alphaFill=s,this.colorStroke=r,this.alphaStroke=a,t.updateColors(),G(i,s,r,a,this.vertexOffset,this.vertexCount,t.colors))}}class Ic extends bc{constructor(t,e,i){super(t,e,i,7,3),this.pointId=-1}init(){const t=this.buffer;t.updateIndices(),xc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(e,i){var s;const n=i.points;if(null==n)return;const o=n.getMarker();if(null==o)return;const r=this.toMarker(o),a=r.size,h=a.x,l=a.y,c=h!==this.sizeX||l!==this.sizeY,u=K(i),d=this.transformLocalId!==u,p=i.stroke,_=p.align,g=p.enable?p.width:0,f=p.style,m=this.strokeAlign!==_||this.strokeWidth!==g||this.strokeStyle!==f,v=X(i),T=Y(v),w=v!==this.texture||T!==this.textureTransformId,E=c||m,y=n.id,x=y!==this.pointId,C=!(this.inited&H.VERTEX_STEP_AND_UV);if(C||E||d||w||x){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=h,this.sizeY=l,this.transformLocalId=u,this.strokeAlign=_,this.strokeWidth=g,this.strokeStyle=f,this.texture=v,this.textureTransformId=T,this.pointId=y;const n=this.vertexOffset,o=null!==(s=Ic.WORK)&&void 0!==s?s:Ic.WORK=new t.Matrix;o.copyFrom(r.transform).prepend(i.transform.internalTransform),e.updateVertices(),Cc(e.vertices,n,0,0,h,l,_,g,o,Ec),(C||E||d)&&(e.updateSteps(),Dc(e.steps,n,g,f,Ec)),(C||E||w)&&(e.updateUvs(),Sc(e.uvs,j(v),n,Ec))}}}class Oc extends Ic{toMarker(t){return t.head}}class Ac extends Ic{toMarker(t){return t.tail}}class Rc extends bc{constructor(t,e,i){super(t,e,i,9,8),this.pointId=-1}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset;ql(t.indices,e,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(e,i){var s;const n=i.points;if(null==n)return;const o=n.getMarker();if(null==o)return;const r=this.toMarker(o),a=r.size,h=a.x,l=a.y,c=h!==this.sizeX||l!==this.sizeY,u=K(i),d=this.transformLocalId!==u,p=i.stroke,_=p.align,g=p.enable?p.width:0,f=p.style,m=this.strokeAlign!==_||this.strokeWidth!==g||this.strokeStyle!==f,v=n.id,T=v!==this.pointId;if(!(this.inited&H.VERTEX_AND_STEP)||c||d||m||T){this.inited|=H.VERTEX_AND_STEP,this.sizeX=h,this.sizeY=l,this.transformLocalId=u,this.strokeAlign=_,this.strokeWidth=g,this.strokeStyle=f,this.pointId=v;const n=null!==(s=Rc.WORK)&&void 0!==s?s:Rc.WORK=new t.Matrix;n.copyFrom(r.transform).prepend(i.transform.internalTransform),e.updateVertices(),e.updateSteps(),Zl(e.vertices,this.vertexOffset,0,0,h,l,_,g,n,jl),Jl(e.steps,this.vertexOffset,g,f,jl)}}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=j(i);Ql(t.uvs,this.vertexOffset,e)}}}class Mc extends Rc{toMarker(t){return t.head}}class kc extends Rc{toMarker(t){return t.tail}}class Lc{constructor(t,e,i){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=0,this.indexCount=0,this.texture=null}init(){return this}reinit(t,e,i,s){return this.buffer=t,this.vertexOffset=i,this.indexOffset=s,!0}isCompatible(t){return!0}update(t){this.texture=X(t)}buildUnit(e){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;if(s!==e.baseTexture){e.baseTexture=s;const t=this.indexOffset;e.push(i,t)}}}const Nc=16,Pc=[0,0],Bc=new t.Point,zc=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+2,t[++s]=e+2,t[++s]=e+1,t[++s]=e+3,t[++s]=e+4,t[++s]=e+5,t[++s]=e+6,t[++s]=e+6,t[++s]=e+5,t[++s]=e+7,t[++s]=e+8,t[++s]=e+9,t[++s]=e+10,t[++s]=e+10,t[++s]=e+9,t[++s]=e+11,t[++s]=e+12,t[++s]=e+13,t[++s]=e+14,t[++s]=e+14,t[++s]=e+13,t[++s]=e+15},Uc=(t,e,i,s,n,o,r,a,h,l)=>{const c=r*a,u=.5*n+(0<=n?+c:-c),d=.5*o+(0<=o?+c:-c),p=Bc;p.set(i-u,s-d),h.apply(p,p);const _=p.x,g=p.y;p.set(i,s-d),h.apply(p,p);const f=p.x,m=p.y;p.set(i-u,s),h.apply(p,p);const v=p.x,T=p.y,w=f-_,E=m-g,y=v-_,x=T-g,D=f+w,S=m+E,b=v+w,I=T+E,O=D+y,A=S+x,R=v+y,M=T+x,k=R+w,L=M+E,N=k+w,P=L+E;let B=(e<<1)-1;t[++B]=_,t[++B]=g,t[++B]=f,t[++B]=m,t[++B]=v,t[++B]=T,t[++B]=b,t[++B]=I,t[++B]=f,t[++B]=m,t[++B]=D,t[++B]=S,t[++B]=b,t[++B]=I,t[++B]=O,t[++B]=A,t[++B]=v,t[++B]=T,t[++B]=b,t[++B]=I,t[++B]=R,t[++B]=M,t[++B]=k,t[++B]=L,t[++B]=b,t[++B]=I,t[++B]=O,t[++B]=A,t[++B]=k,t[++B]=L,t[++B]=N,t[++B]=P,l[0]=C(_,g,f,m),l[1]=C(_,g,v,T)},Fc=(t,e,i,s,n,o)=>{const r=h(n),a=o[0],l=o[1],c=s&V.TOP?1:0,u=s&V.RIGHT?1:0,_=s&V.BOTTOM?1:0,g=s&V.LEFT?1:0,f=d(0,r,g,c),m=d(0,r,u,c),v=d(0,r,g,_),T=d(0,r,u,_),w=p(1,1),E=p(0,1),y=p(0,0),x=p(1,0);let C=6*t-1;e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0,e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0},Hc=(t,e,i)=>{const s=i.x0,n=i.y0,o=i.x1,r=i.y1,a=i.x2,h=i.y2,l=i.x3,c=i.y3,u=.5*(s+o),d=.5*(n+r),p=.5*(s+l),_=.5*(n+c),g=u-s,f=d-n,m=p+g,v=_+f,T=o+(p-s),w=r+(_-n),E=l+g,y=c+f;let x=(e<<1)-1;t[++x]=s,t[++x]=n,t[++x]=u,t[++x]=d,t[++x]=p,t[++x]=_,t[++x]=m,t[++x]=v,t[++x]=u,t[++x]=d,t[++x]=o,t[++x]=r,t[++x]=m,t[++x]=v,t[++x]=T,t[++x]=w,t[++x]=p,t[++x]=_,t[++x]=m,t[++x]=v,t[++x]=l,t[++x]=c,t[++x]=E,t[++x]=y,t[++x]=m,t[++x]=v,t[++x]=T,t[++x]=w,t[++x]=E,t[++x]=y,t[++x]=a,t[++x]=h};class Gc extends bc{constructor(t,e,i){super(t,e,i,Nc,8),this.pointId=-1}init(){const t=this.buffer;t.updateIndices(),zc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(e,i){var s;const n=i.points;if(null==n)return;const o=n.getMarker();if(null==o)return;const r=this.toMarker(o),a=r.size,h=a.x,l=a.y,c=h!==this.sizeX||l!==this.sizeY,u=K(i),d=this.transformLocalId!==u,p=i.stroke,_=p.align,g=p.enable?p.width:0,f=p.side,m=p.style,v=this.strokeAlign!==_||this.strokeWidth!==g||this.strokeSide!==f||this.strokeStyle!==m,T=X(i),w=Y(T),E=T!==this.texture||w!==this.textureTransformId,y=c||v,x=n.id!==this.pointId,C=!(this.inited&H.VERTEX_STEP_AND_UV);if(C||y||d||E||x){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=h,this.sizeY=l,this.transformLocalId=u,this.strokeAlign=_,this.strokeWidth=g,this.strokeSide=f,this.strokeStyle=m,this.texture=T,this.textureTransformId=w;const n=this.vertexOffset,o=null!==(s=Gc.WORK)&&void 0!==s?s:Gc.WORK=new t.Matrix;o.copyFrom(r.transform).prepend(i.transform.internalTransform),e.updateVertices(),Uc(e.vertices,n,0,0,h,l,_,g,o,Pc),(C||y||d)&&(e.updateSteps(),Fc(n,e.steps,g,f,m,Pc)),(C||y||E)&&(e.updateUvs(),Hc(e.uvs,n,j(T)))}}}class Vc extends Gc{toMarker(t){return t.tail}}class Wc extends Gc{toMarker(t){return t.head}}const Kc=t=>{switch(t){case Z.NONE:return 0;case Z.CIRCLE:return 9;case Z.TRIANGLE:return 7;case Z.RECTANGLE:return Nc}return 0},Xc=t=>{switch(t){case Z.NONE:return 0;case Z.CIRCLE:return 8;case Z.TRIANGLE:return 3;case Z.RECTANGLE:return 8}return 0},Yc=(t,e,i,s)=>{switch(t){case Z.NONE:return new Lc(e,i,s);case Z.CIRCLE:return new Mc(e,i,s);case Z.TRIANGLE:return new Oc(e,i,s);case Z.RECTANGLE:return new Wc(e,i,s)}return new Lc(e,i,s)},jc=(t,e,i,s)=>{switch(t){case Z.NONE:return new Lc(e,i,s);case Z.CIRCLE:return new kc(e,i,s);case Z.TRIANGLE:return new Ac(e,i,s);case Z.RECTANGLE:return new Vc(e,i,s)}return new Lc(e,i,s)},$c=(t,e,i,s,n)=>{const r=e.points,a=hc(r),h=lc(a,!0),l=cc(a,!0);let c=Z.NONE,u=Z.NONE;if(r&&r instanceof bs){const t=r.getMarker();t&&(c=t.tail.type,u=t.head.type)}const d=Kc(c),p=Xc(c),_=i+h,g=s+l,f=Kc(u),m=Xc(u),v=_+d,T=g+p,w=I(e),E=w<<2,y=w<<1,x=v+f,C=T+m,D=h+f+d+E,S=l+m+p+y;return t.check(i,s,D,S)?new o(t,i,s,D,S,[new wc(t,i,s,h,l),jc(c,t,_,g),Yc(u,t,v,T),new le(t,x,C,E,y)]).init(e):null};class qc{constructor(t,e,i){this._threshold=1e-6,this._x=t,this._y=e,this._z=0,this._values=i,i[0]=t,i[1]=e,this.index=0}get x(){return this._x}set x(t){if(0===this._z||this._threshold<Math.abs(this._x-t)){this._x=t;const e=this.index,i=this._values;1===this._z?(i[e+0]=this._x,i[e+1]=this._y):(i[e+2]=this._x,i[e+3]=this._y,this.index+=2,this._z=1)}}get y(){return this._y}set y(t){if(0===this._z||this._threshold<Math.abs(this._y-t)){this._y=t;const e=this.index,i=this._values;2===this._z?(i[e+0]=this._x,i[e+1]=this._y):(i[e+2]=this._x,i[e+3]=this._y,this.index+=2,this._z=2)}}toSide(t,e){return 0<=t-e?0<=t+e?1:0:0<=t+e?2:3}toAxis(t,e,i,s,n){const o=Math.abs(i),r=Math.abs(s),a=this._threshold;if(o<a&&r<a)return Math.abs(t)<Math.abs(e)?0<=e?2:0:0<=t?1:3;let h=null,l=0;const c=t*t+e*e;if(this._threshold<c){const o=1/Math.sqrt(c),r=t*o,a=e*o,u=+i*r+s*a,d=-s*r+i*a,p=-u,_=-d;n&Ni.TOP&&(null==h||h<u)&&(h=u,l=this.toSide(i,s)),n&Ni.RIGHT&&(null==h||h<d)&&(h=d,l=this.toSide(-s,i)),n&Ni.BOTTOM&&(null==h||h<p)&&(h=p,l=this.toSide(-i,-s)),n&Ni.LEFT&&(null==h||h<_)&&(h=_,l=this.toSide(s,-i))}return l}toTailAxis(t,e,i,s,n){return this.toAxis(t-this.x,e-this.y,i,s,n)}tail(t,e,i,s,n,o,r,a){switch(this.toTailAxis(t,e,i,s,a)){case 0:this.y-r<=e?(this.y-=Math.max(r,o),this.x=t):this.y=e;break;case 1:t<=this.x+r?(this.x+=Math.max(r,n),this.y=e):this.x=t;break;case 2:e<=this.y+r?(this.y+=Math.max(r,n),this.x=t):this.y=e;break;case 3:this.x-r<=t?(this.x-=Math.max(r,n),this.y=e):this.x=t}}middle(t,e){const i=t-this._x,s=e-this._y;Math.abs(i)<Math.abs(s)?this.y=e:this.x=t}toHeadAxis(t,e,i,s,n){return this.toAxis(this.x-t,this.y-e,i,s,n)}head(t,e,i,s,n,o,r,a){switch(this.toHeadAxis(t,e,i,s,a)){case 0:e-r<=this.y&&(this.y=e-Math.max(r,o)),this.x=t,this.y=e;break;case 1:this.x<=t+r&&(this.x=t+Math.max(r,n)),this.y=e,this.x=t;break;case 2:this.y<=e+r&&(this.y=e+Math.max(r,o)),this.x=t,this.y=e;break;case 3:t-r<=this.x&&(this.x=t-Math.max(r,n)),this.y=e,this.x=t}}margin(t,e){const i=this._values;let s=this.index;if(0!==t&&2<=s){const e=i[0],s=i[1],n=i[2]-e,o=i[3]-s,r=n*n+o*o,a=this._threshold;if(a<r){const r=t/Math.sqrt(n*n+o*o);a<Math.abs(r-1)?(i[0]=e+n*r,i[1]=s+o*r):this.index-=2}}if(s=this.index,0!==e&&2<=s){const t=i[s+0],n=i[s+1],o=i[s-2]-t,r=i[s-1]-n,a=o*o+r*r,h=this._threshold;if(h<a){const a=e/Math.sqrt(o*o+r*r);h<Math.abs(a-1)?(i[s+0]=t+o*a,i[s+1]=n+r*a):this.index-=2}}i.length=this.index+2}}class Zc extends Os{constructor(t=s.CONNECTOR_ELBOW){super(t)}fillPoints(t,e,i,s,n,o,r,a){const h=t.local,l=h.x,c=h.y,u=t.normal,d=u.x,p=u.y,_=t.side,g=i.local,f=g.x,m=g.y,v=i.normal,T=v.x,w=v.y,E=i.side,y=n.values,x=y.length,C=l-o,D=c-r,S=f-o,b=m-r,I=.5*(S+C),O=.5*(b+D),A=S-C,R=b-D,M=.5*q.SIZE_X,k=.5*q.SIZE_Y,L=1e-6;if(Math.abs(A)<L&&Math.abs(R)<L)a[0]=C,a[1]=D,a[2]=S,a[3]=b,a.length=4;else{const t=new qc(C,D,a);if(0<x){const i=Math.atan2(R,A),n=Math.sqrt(A*A+R*R),o=Math.cos(i)*n,r=Math.sin(i)*n,a=y[0],h=y[1],l=I+o*a-r*h,c=O+o*h+r*a;t.tail(l,c,d,p,M,k,e,_);for(let e=2;e<x;e+=2){const i=y[e+0],s=y[e+1],n=I+o*i-r*s,a=O+o*s+r*i;t.middle(n,a)}t.head(S,b,T,w,M,k,s,E)}else t.tail(I,O,d,p,M,k,e,_),t.head(S,b,T,w,M,k,s,E);t.margin(e,s)}}}const Jc=(t,e,i)=>Dl(t,e,i||new Zc);class Qc{static from(t,e,i){const s=[],n=t.length;if(4<n){const o=1e-6;let r=t[0],a=t[1];if(0!==e){const i=r-t[2],s=a-t[3],n=i*i+s*s;if(o<n){const t=e/Math.sqrt(n);r+=i*t,a+=s*t}}let h=t[n-2],l=t[n-1];if(0!==i){const e=h-t[n-4],s=l-t[n-3],r=e*e+s*s;if(o<r){const t=i/Math.sqrt(r);h+=e*t,l+=s*t}}const c=.5*(h+r),u=.5*(l+a),d=h-r,p=l-a,_=Math.atan2(p,d),g=Math.cos(_),f=Math.sin(_),m=d*d+p*p,v=o<m?1/Math.sqrt(m):1;for(let e=2,i=n-2;e<i;e+=2){const i=t[e+0]-c,n=t[e+1]-u;s.push((g*i+f*n)*v,(g*n-f*i)*v)}}return s}}const tu=(t,e,i)=>Dl(t,e,i||new Os),eu=(t,e,i,s)=>{if(e instanceof Os){const n=s.resources,o=t[15];if(0<=o&&o<n.length){let t=s.getExtension(o);null==t&&(t=JSON.parse(n[o]),s.setExtension(o,t)),e.lock(Mt.CONNECTOR);const r=e.points;r.deserialize(t[1],s);const a=e.edge;a.deserialize(t[0],i,s);const h=e.body,l=t[2];null!=l?h.deserialize(l,i,s):h.set(Qc.from(r.values,a.tail.margin,a.head.margin)),e.unlock(Mt.CONNECTOR,!0)}}},iu=()=>{n[s.CONNECTOR_ELBOW]=$c,e[s.CONNECTOR_ELBOW]=Jc,i[s.CONNECTOR_ELBOW]=eu,Ui.set(s.CONNECTOR_ELBOW,Ot.CONNECTOR)},su=()=>{n[s.CONNECTOR_LINE]=$c,e[s.CONNECTOR_LINE]=tu,i[s.CONNECTOR_LINE]=eu,Ui.set(s.CONNECTOR_LINE,Ot.CONNECTOR)};class nu extends W{constructor(t,e,i){super(t,e,i,Nc,8)}init(){const t=this.buffer;t.updateIndices(),zc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.side,d=h.style,p=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeSide!==u||this.strokeStyle!==d,_=X(e),g=Y(_),f=_!==this.texture||g!==this.textureTransformId,m=o||p,v=!(this.inited&H.VERTEX_STEP_AND_UV);if(v||m||a||f){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeSide=u,this.strokeStyle=d,this.texture=_,this.textureTransformId=g;const i=this.vertexOffset;t.updateVertices(),Uc(t.vertices,i,.5*s,.5*n,s,n,l,c,e.transform.internalTransform,Pc),(v||m||a)&&(t.updateSteps(),Fc(i,t.steps,c,u,d,Pc)),(v||m||f)&&(t.updateUvs(),Hc(t.uvs,i,j(_)))}}}const ou=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=Nc+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new nu(t,i,s),new le(t,i+Nc,s+8,a,h)]).init(e):null},ru=(t,e,i,s)=>{const n=I(e),r=n<<2,a=n<<1,h=r,l=a;return t.check(i,s,h,l)?new o(t,i,s,h,l,[new le(t,i,s,r,a)]).init(e):null},au=(t,e)=>{const i=t.data.getMapping();if(null!=i){const s=i.values;for(let i=0,n=s.length;i<n;++i){const n=s[i],o=n[0],r=e.getDataMapper(o);if(null!=r){const i=t.children,s=e.getDataDestination(n[1]),o=n[2];hu(i,r,s,o)}}}},hu=(t,e,i,s)=>{for(let n=0,o=t.length;n<o;++n){const o=t[n],r=o.data;for(let t=0,n=r.size();t<n;++t){const n=r.get(t);n&&n.scope!==Ut.PRIVATE&&e.map(n,i,s)}const a=o.children;0<a.length&&hu(a,e,i,s)}},lu=(t,e,i)=>{const s=e.pieces,n=t[15];if(s&&0<=n&&n<s.length){const o=e.pieceData;if(o){const r=s[n],a=o.get(r),h=i&&i(r,e);return a?((t,e,i,s,n,o,r)=>{const a=n.mode,h=n.depth;r=r||new Yi(t,a,h);const l=Dl(o,n,r),c=r.size,u=c.x,d=c.y;return r.size.set(e,i),s.copyTo(r),r.size.init(),r.size.set(u,d),a===Li.EDITOR?0<h&&au(r,n):au(r,n),l})(r,a.width,a.height,a.layer,e,t,h):((t,e,i,s)=>{const n=e.mode,o=e.depth;s=s||new Yi(t,n,o);const r=Dl(i,e,s),a=s.size,h=a.x,l=a.y,c=s.children,u=new Qs("missing",n,o),d=.5*h,p=.5*h;u.transform.position.set(-d,-p),u.size.set(h,l),u.size.init(),u.parent=s;const _=new yo;return _.stroke.color=16711680,_.transform.position.set(d,p),_.size.copyFrom(s.size),_.attach(u),c.push(u),s.onChildTransformChange(),s.toDirty(),s.onAttach(),s.size.init(),n===Li.EDITOR?0<o&&au(s,e):au(s,e),r})(r,e,t,h)}}return null},cu=(t,e,i)=>{null!=i||(i=new zi);const s=t[15];i.subtype=(t=>{const e=Pi.ALL&t;return 0!==e?e:Pi.HEAD})(s),i.side=Ni.ALL&s>>2,i.vvisible=0<(1&s>>6);const n=Dl(t,e,i);return!1===i.vvisible&&e.mode===Li.VIEWER&&(i.visible=!1),n},uu=()=>{n[s.EMBEDDED]=ru,e[s.EMBEDDED]=lu,Ui.set(s.EMBEDDED,Ot.EMBEDDED),n[s.EMBEDDED_LAYER]=ou,n[s.EMBEDDED_ACCEPTOR_EDGE]=ec,e[s.EMBEDDED_ACCEPTOR_EDGE]=cu,Ui.set(s.EMBEDDED_ACCEPTOR_EDGE,Ot.EMBEDDED_ACCEPTOR_EDGE)};class du{constructor(t){this._parent=t}get enable(){const t=this._parent.children;return!(0<t.length)||t[t.length-1].fill.enable}set enable(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.enable=t}get color(){const t=this._parent.children;return 0<t.length?t[t.length-1].fill.color:16777215}set color(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.color=t}get alpha(){const t=this._parent.children;return 0<t.length?t[t.length-1].fill.alpha:1}set alpha(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.alpha=t}copy(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.copy(t)}set(t,e,i){const s=this._parent.children;for(let n=0,o=s.length;n<o;++n)s[n].fill.set(t,e,i)}clone(){return new du(this._parent)}toObject(){const t=this._parent.children;return 0<t.length?t[t.length-1].fill.toObject():{enable:!0,color:16777215,alpha:1}}serialize(t){return-1}deserialize(t,e){}}class pu{constructor(t){this._parent=t}get length(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.length}return 0}get plength(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.plength}return 0}get id(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.id}return 0}get values(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.values}return[]}set values(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.values=t)}}get segments(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.segments}return[]}set segments(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.segments=t)}}get style(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.style}return F.NONE}set style(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.style=t)}}get marker(){const t=this._parent.children;for(let e=0,i=t.length;e<i;++e){const i=t[e].points;if(null!=i)return i.marker}return tt.getInstance()}getMarker(){const t=this._parent.children;for(let e=0,i=t.length;e<i;++e){const i=t[e].points;if(null!=i)return i.getMarker()}}get formatter(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.formatter}return null}set formatter(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.formatter=t)}}get formatted(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.formatted}return this}onSizeChange(){}copy(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&s.copy(t)}return this}set(t,e,i){const s=this._parent.children;for(let n=0,o=s.length;n<o;++n){const o=s[n].points;null!=o&&o.set(t,e,i)}return this}clone(t){return new pu(t)}toPoints(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;if(null!=s)return s.toPoints(t)}return[]}serialize(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;if(null!=s)return s.serialize(t)}return-1}}class _u{constructor(t){this._parent=t}get enable(){const t=this._parent.children;return 0<t.length&&t[t.length-1].stroke.enable}set enable(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.enable=t}get color(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.color:16777215}set color(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.color=t}get alpha(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.alpha:1}set alpha(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.alpha=t}get width(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.width:1}set width(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.width=t}get align(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.align:1}set align(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.align=t}get side(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.side:1}set side(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.side=t}get style(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.style:r.NONE}set style(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.style=t}copy(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.copy(t)}set(t,e,i,s,n){const o=this._parent.children;for(let r=0,a=o.length;r<a;++r)o[r].stroke.set(t,e,i,s,n)}clone(){return new _u(this._parent)}toObject(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.toObject():{enable:!1,color:16777215,alpha:1,width:1,align:0,side:V.NONE,style:r.NONE}}serialize(t){return-1}deserialize(t,e){}}class gu extends kt{constructor(t,e=s.GROUP){super(e),this._mode=t;const i=new jt;this.data=i,this.tag=i,this.size=this.newGroupSize(t),this.fill=this.newGroupFill(),this.stroke=this.newGroupStroke(),this.text=this.newGroupText(),this._points=this.newGroupPoints()}get mode(){return this._mode}newGroupSize(t){const e=q.SIZE_X,i=q.SIZE_Y;return t!==Li.VIEWER?new Gi(this,e,i,this.isGroupSizeFittable()):new Vi(this,e,i,e,i)}isGroupSizeFittable(){return!0}newGroupFill(){return new du(this)}newGroupStroke(){return new _u(this)}newGroupText(){return new Jt(this,q.TEXT_VALUE,q.TEXT_COLOR,q.TEXT_ALPHA,q.TEXT_FAMILY,q.TEXT_SIZE)}newGroupPoints(){return new pu(this)}getBoundsSize(){const t=this.size;return t instanceof Vi?t.base:t}onChildTransformChange(){super.onChildTransformChange(),this.size.fit()}get corner(){const t=this.children;return 0<t.length?t[t.length-1].corner:nt.ALL}set corner(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].corner=t}get gradient(){const t=this.children;for(let e=t.length-1;0<=e;--e){const i=t[e].gradient;if(null!=i)return i}}set gradient(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].gradient=t}serializeGradient(t){return-1}get radius(){const t=this.children;return 0<t.length?t[t.length-1].radius:.5}set radius(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].radius=t}get image(){const t=this.children;for(let e=t.length-1;0<=e;--e){const i=t[e].image;if(null!=i)return i}}set image(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].image=t}serializeImage(t){return-1}get points(){const t=this.children;for(let e=t.length-1;0<=e;--e)if(null!=t[e].points)return this._points}set points(t){}clone(){const t=this.newClone().copy(this),e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].clone();s.parent=t,t.children.push(s)}return As.moveAll(e,t.children,e,t.children),t.onChildTransformChange(),t.toDirty(),t}newClone(){return new(0,this.constructor)(this._mode,this.type)}containsAbs(t,e,i,s,n,o,r){return!1}}const fu=(t,e,i)=>{i=i||new gu(e.mode);const s=Dl(t,e,i);return i.size.init(),s},mu=()=>{n[s.GROUP]=ru,e[s.GROUP]=fu,Ui.set(s.GROUP,Ot.GROUP)};class vu{constructor(e,i,s){this._parent=e,this._size=new t.Point(i,s)}init(){return this}get x(){return this._size.x}set x(t){const e=this._size;if(e.x!==t){const i=e.x;e.x=t,this.onChange(i,e.y)}}get y(){return this._size.y}set y(t){const e=this._size;if(e.y!==t){const i=e.y;e.y=t,this.onChange(e.x,i)}}set(t,e){let i=!1;const s=this._size,n=s.x,o=s.y;return null!=t&&n!==t&&(i=!0,s.x=t),null!=e&&o!==e&&(i=!0,s.y=e),i&&this.onChange(n,o),this}clone(){const t=this._size;return new vu(this._parent,t.x,t.y)}copy(){}copyFrom(t){const e=t.x,i=t.y,s=this._size,n=s.x,o=s.y;return n===e&&o===i||(s.x=e,s.y=i,this.onChange(n,o)),this}copyTo(t){return this._size.copyTo(t)}equals(t){return this._size.equals(t)}fit(){return this}onChange(t,e){this._parent.onSizeChange()}}class Tu extends gu{constructor(t,e=s.GROUP_SHADOWED){super(t,e)}newGroupSize(t){return t!==Li.VIEWER?new vu(this,q.SIZE_X,q.SIZE_Y):super.newGroupSize(t)}}const wu=(t,e,i)=>{i=i||new Tu(e.mode);const s=Dl(t,e,i);return i.size.init(),s},Eu=()=>{n[s.GROUP_SHADOWED]=ru,e[s.GROUP_SHADOWED]=wu,Ui.set(s.GROUP_SHADOWED,Ot.GROUP)};class yu extends W{constructor(t,e,i){super(t,e,i,Nc,8)}init(){const t=this.buffer;t.updateIndices(),zc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.side,d=h.style,p=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeSide!==u||this.strokeStyle!==d,_=X(e),g=Y(_),f=_!==this.texture||g!==this.textureTransformId,m=o||p,v=!(this.inited&H.VERTEX_STEP_AND_UV);if(v||m||a||f){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeSide=u,this.strokeStyle=d,this.texture=_,this.textureTransformId=g;const i=this.vertexOffset;t.updateVertices(),Uc(t.vertices,i,0,0,s,n,l,c,e.transform.internalTransform,Pc),(v||m||a)&&(t.updateSteps(),Fc(i,t.steps,c,u,d,Pc)),(v||m||f)&&(t.updateUvs(),Hc(t.uvs,i,j(_)))}}}const xu=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=Nc+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new yu(t,i,s),new le(t,i+Nc,s+8,a,h)]).init(e):null};class Cu extends yo{constructor(t,e=s.IMAGE){super(e),null!=t&&(this.image=t,this.size.set(t.width,t.height)),this.fill.alpha=1}clone(){return new Cu(this.image,this.type).copy(this)}}const Du=(t,e,i)=>Dl(t,e,i||new Cu),Su=()=>{n[s.IMAGE]=xu,e[s.IMAGE]=Du},bu=[0,0],Iu=new t.Point,Ou=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+4,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+4,t[++s]=e+2,t[++s]=e+5,t[++s]=e+4,t[++s]=e+3,t[++s]=e+4,t[++s]=e+6,t[++s]=e+4,t[++s]=e+7,t[++s]=e+6,t[++s]=e+4,t[++s]=e+5,t[++s]=e+7,t[++s]=e+5,t[++s]=e+8,t[++s]=e+7},Au=(t,e,i,s,n,o,r,a)=>{const l=h(n),c=d(2,l,1,1),u=o/a[0],p=r/a[1],_=.5*(u+p),g=s/12,f=-1+i;let m=6*e-1;t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=p,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=u,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=u,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=p,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=p,t[++m]=f,t[++m]=0,t[++m]=0},Ru=(t,e,i,s,n,o,r,a)=>{const h=Iu,l=.5*n,c=.5*o;h.set(i-l,s-c),r.apply(h,h);const u=h.x,d=h.y;h.set(i+l,s-c),r.apply(h,h);const p=h.x,_=h.y;h.set(i+l,s+c),r.apply(h,h);const g=h.x,f=h.y,m=u+(g-p),v=d+(f-_);let T=(e<<1)-1;t[++T]=u,t[++T]=d,t[++T]=.5*(u+p),t[++T]=.5*(d+_),t[++T]=p,t[++T]=_,t[++T]=.5*(u+m),t[++T]=.5*(d+v),t[++T]=.5*(u+g),t[++T]=.5*(d+f),t[++T]=.5*(p+g),t[++T]=.5*(_+f),t[++T]=m,t[++T]=v,t[++T]=.5*(m+g),t[++T]=.5*(v+f),t[++T]=g,t[++T]=f,a[0]=.5*C(u,d,p,_),a[1]=.5*C(u,d,m,v)},Mu=(t,e,i)=>{const s=i.x0,n=i.y0,o=i.x1,r=i.y1,a=i.x2,h=i.y2,l=i.x3,c=i.y3;let u=(e<<1)-1;t[++u]=s,t[++u]=n,t[++u]=.5*(o+s),t[++u]=.5*(r+n),t[++u]=o,t[++u]=r,t[++u]=.5*(s+l),t[++u]=.5*(n+c),t[++u]=.5*(s+a),t[++u]=.5*(n+h),t[++u]=.5*(o+a),t[++u]=.5*(r+h),t[++u]=l,t[++u]=c,t[++u]=.5*(l+a),t[++u]=.5*(c+h),t[++u]=a,t[++u]=h};class ku extends W{constructor(t,e,i){super(t,e,i,9,8),this.textureWidth=-1,this.textureHeight=-1}init(){const t=this.vertexOffset,e=this.buffer;e.updateIndices(),Ou(e.indices,t,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u,p=X(e),_=p.width*p.resolution,g=p.height*p.resolution,f=this.textureWidth!==_||this.textureHeight!==g;(!(this.inited&H.VERTEX_AND_STEP)||o||a||d||f)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,this.textureWidth=_,this.textureHeight=g,t.updateVertices(),Ru(t.vertices,this.vertexOffset,0,0,s,n,e.transform.internalTransform,bu),t.updateSteps(),Au(t.steps,this.vertexOffset,l,c,u,_,g,bu))}updateUv(t,e){const i=X(e),s=Y(i);(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId)&&(this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs(),Mu(t.uvs,this.vertexOffset,j(i)))}}const Lu=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=9+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new ku(t,i,s),new le(t,i+9,s+8,a,h)]).init(e):null};class Nu extends Cu{constructor(t,e=s.IMAGE_SDF){super(t,e)}clone(){return new Nu(this.image,this.type).copy(this)}}const Pu=(t,e,i)=>Dl(t,e,i||new Nu);class Bu{constructor(t,e,i){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=0,this.indexCount=0,this.texture=null}init(){return this}reinit(t,e,i,s){return this.buffer=t,this.vertexOffset=i,this.indexOffset=s,!0}isCompatible(t){return!0}update(t){this.texture=X(t)}buildUnit(e){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;if(s!==e.baseTexture){e.baseTexture=s;const t=this.indexOffset;e.push(i,t)}}}const zu=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=a,c=h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new Bu(t,i,s),new le(t,i,s,a,h)]).init(e):null};class Uu extends te{constructor(t=s.LABEL){super(t)}clone(){return new Uu(this.type).copy(this)}}const Fu=(t,e,i)=>Dl(t,e,i||new Uu),Hu=()=>{n[s.LABEL]=zu,e[s.LABEL]=Fu};class Gu extends re{constructor(t=s.LINE){super(t),this._points=new bs(this)}get points(){return this._points}clone(){return new Gu(this.type).copy(this)}serialize(t){const e=super.serialize(t);return e[15]=this._points.serialize(t),e}}const Vu=(t,e,i)=>{i=i||new Gu;const s=Dl(t,e,i);i.points.deserialize(t[15],e);const n=i.points.style,o=F.NON_SCALING_MASK|F.DOTTED_MASK|F.DASHED_MASK,r=n&o;return r&&(i.points.style&=~o,i.stroke.style|=r),s},Wu=()=>{n[s.LINE]=$c,e[s.LINE]=Vu},Ku=(t,e,i)=>{for(let s=2*e,n=2*(e+i);s<n;s+=2)t[s+0]=0,t[s+1]=0},Xu=(t,e,i)=>{for(let s=6*e,n=6*(e+i);s<n;s+=6)t[s+0]=0,t[s+1]=0,t[s+2]=0,t[s+3]=0,t[s+4]=0,t[s+5]=0},Yu=(t,e,i)=>{for(let s=2*e,n=2*(e+i);s<n;s+=2)t[s+0]=0,t[s+1]=0},ju=t=>(t>>4)+(0<(15&t)?1:0)<<4,$u=(t,e,i,s,n,o,r,a,h,l,c,u)=>{if(r)if(i.isStaticColor()){const r=i.getColor(0,h);if(i.isStaticAlpha()){const h=i.getAlpha(0,l);qu(t,e,i,s,n,o,a,c,u,r,h)}else Zu(t,e,i,s,n,o,a,c,u,r,l)}else if(i.isStaticAlpha()){const r=i.getAlpha(0,l);Ju(t,e,i,s,n,o,a,c,u,h,r)}else Qu(t,e,i,s,n,o,a,c,u,h,l);else if(i.isStaticColor()){const r=i.getColor(0,h);qu(t,e,i,s,n,o,a,c,u,r,0)}else Ju(t,e,i,s,n,o,a,c,u,h,0)},qu=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const i=s.getColor(0,a);if(s.isStaticAlpha()){const r=s.getAlpha(0,h);G(l,c,i,r,t,e*n,o)}else for(let r=0,a=t;r<n;r+=1,a+=e){const t=s.getAlpha(r,h);G(l,c,i,t,a,e,o)}}else if(s.isStaticAlpha()){const i=s.getAlpha(0,h);for(let r=0,h=t;r<n;r+=1,h+=e){const t=s.getColor(r,a);G(l,c,t,i,h,e,o)}}else for(let i=0,r=t;i<n;i+=1,r+=e){const t=s.getColor(i,a),n=s.getAlpha(i,h);G(l,c,t,n,r,e,o)}else if(s.isStaticColor()){const i=s.getColor(0,a);G(l,c,i,0,t,e*n,o)}else for(let i=0,r=t;i<n;i+=1,r+=e){const t=s.getColor(i,a);G(l,c,t,0,r,e,o)}},Zu=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const r=s.getColor(0,a);if(s.isStaticAlpha()){const a=s.getAlpha(0,h);for(let s=0,h=t;s<n;s+=1,h+=e){const t=i.getAlpha(s,c);G(l,t,r,a,h,e,o)}}else for(let a=0,u=t;a<n;a+=1,u+=e){const t=i.getAlpha(a,c),n=s.getAlpha(a,h);G(l,t,r,n,u,e,o)}}else if(s.isStaticAlpha()){const r=s.getAlpha(0,h);for(let h=0,u=t;h<n;h+=1,u+=e){const t=i.getAlpha(h,c),n=s.getColor(h,a);G(l,t,n,r,u,e,o)}}else for(let r=0,u=t;r<n;r+=1,u+=e){const t=i.getAlpha(r,c),n=s.getColor(r,a),d=s.getAlpha(r,h);G(l,t,n,d,u,e,o)}else if(s.isStaticColor()){const r=s.getColor(0,a);for(let s=0,a=t;s<n;s+=1,a+=e){const t=i.getAlpha(s,c);G(l,t,r,0,a,e,o)}}else for(let r=0,h=t;r<n;r+=1,h+=e){const t=i.getAlpha(r,c),n=s.getColor(r,a);G(l,t,n,0,h,e,o)}},Ju=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const r=s.getColor(0,a);if(s.isStaticAlpha()){const a=s.getAlpha(0,h);for(let s=0,h=t;s<n;s+=1,h+=e){const t=i.getColor(s,l);G(t,c,r,a,h,e,o)}}else for(let a=0,u=t;a<n;a+=1,u+=e){const t=i.getColor(a,l),n=s.getAlpha(a,h);G(t,c,r,n,u,e,o)}}else if(s.isStaticAlpha()){const r=s.getAlpha(0,h);for(let h=0,u=t;h<n;h+=1,u+=e){const t=i.getColor(h,l),n=s.getColor(h,a);G(t,c,n,r,u,e,o)}}else for(let r=0,u=t;r<n;r+=1,u+=e){const t=i.getColor(r,l),n=s.getColor(r,a),d=s.getAlpha(r,h);G(t,c,n,d,u,e,o)}else if(s.isStaticColor()){const r=s.getColor(0,a);for(let s=0,a=t;s<n;s+=1,a+=e){const t=i.getColor(s,l);G(t,c,r,0,a,e,o)}}else for(let r=0,h=t;r<n;r+=1,h+=e){const t=i.getColor(r,l),n=s.getColor(r,a);G(t,c,n,0,h,e,o)}},Qu=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const r=s.getColor(0,a);if(s.isStaticAlpha()){const a=s.getAlpha(0,h);for(let s=0,h=t;s<n;s+=1,h+=e){const t=i.getColor(s,l),n=i.getAlpha(s,c);G(t,n,r,a,h,e,o)}}else for(let a=0,u=t;a<n;a+=1,u+=e){const t=i.getColor(a,l),n=i.getAlpha(a,c),d=s.getAlpha(a,h);G(t,n,r,d,u,e,o)}}else if(s.isStaticAlpha()){const r=s.getAlpha(0,h);for(let h=0,u=t;h<n;h+=1,u+=e){const t=i.getColor(h,l),n=i.getAlpha(h,c),d=s.getColor(h,a);G(t,n,d,r,u,e,o)}}else for(let r=0,u=t;r<n;r+=1,u+=e){const t=i.getColor(r,l),n=i.getAlpha(r,c),d=s.getColor(r,a),p=s.getAlpha(r,h);G(t,n,d,p,u,e,o)}else if(s.isStaticColor()){const r=s.getColor(0,a);for(let s=0,a=t;s<n;s+=1,a+=e){const t=i.getColor(s,l),n=i.getAlpha(s,c);G(t,n,r,0,a,e,o)}}else for(let r=0,h=t;r<n;r+=1,h+=e){const t=i.getColor(r,l),n=i.getAlpha(r,c),u=s.getColor(r,a);G(t,n,u,0,h,e,o)}};class td extends W{constructor(t,e,i,s,n,o,r,a){super(t,e,i,s,n),this.pointId=-1,this.pointCount=0,this.pointCountReserved=o,this.pointSizeId=-1,this.pointOffsetId=-1,this.pointFillId=-1,this.pointStrokeId=-1,this.vcountPerPoint=r,this.icountPerPoint=a}reinit(t,e,i,s){const n=ju(ac(e.points));if(this.buffer!==t||this.vertexOffset!==i||this.indexOffset!==s||this.pointCountReserved!==n){const e=n*this.vcountPerPoint,o=n*this.icountPerPoint;return!!t.check(i,s,e,o)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.vertexCount=e,this.indexCount=o,this.pointCountReserved=n,this.init(),!0)}return!0}isCompatible(t){return ju(ac(t.points))===this.pointCountReserved}updateLineOfAnyColor(t,e,i,s){const n=i.fill,o=n.id,r=o!==this.pointFillId,a=e.fill,h=e.visible&&a.enable,l=a.color,c=h?a.alpha:0,u=l!==this.colorFill||c!==this.alphaFill,d=i.stroke,p=d.id,_=p!==this.pointStrokeId,g=e.stroke,f=e.visible&&g.enable,m=g.color,v=f?g.alpha:0,T=m!==this.colorStroke||v!==this.alphaStroke;(!(this.inited&H.COLOR)||r||u||_||T)&&(this.inited|=H.COLOR,this.colorFill=l,this.alphaFill=c,this.pointFillId=o,this.colorStroke=m,this.alphaStroke=v,this.pointStrokeId=p,t.updateColors(),$u(this.vertexOffset,s,n,d,this.pointCountReserved,t.colors,h,f,l,c,m,v))}}const ed=(t,e,i,s,n)=>{let o=e,r=i+s;for(let a=1;a<n;++a){let n=3*r,a=3*i;for(let e=0;e<s;++e)t[n+0]=t[a+0]+o,t[n+1]=t[a+1]+o,t[n+2]=t[a+2]+o,n+=3,a+=3;o+=e,r+=s}},id=(t,e,i,s)=>{const n=6*e;let o=6*(e+i);for(let e=1;e<s;++e){let e=n;for(let s=0;s<i;++s)t[o+0]=t[e+0],t[o+1]=t[e+1],t[o+2]=t[e+2],t[o+3]=t[e+3],t[o+4]=t[e+4],t[o+5]=t[e+5],o+=6,e+=6}},sd=(t,e,i,s)=>{let n=e+i;for(let o=1;o<s;++o){let s=n<<1,o=e<<1;for(let e=0;e<i;++e)t[s]=t[o],t[s+1]=t[o+1],s+=2,o+=2;n+=i}},nd=(t,e,i,s,n,o,r)=>{const a=e.a,h=e.b,l=e.c,c=e.d;let u=n-1,d=i+u*s;if(r.isStaticX()&&r.isStaticY()){const e=r.getX(0),n=r.getY(0);for(;0<=u;--u){const r=u<<1,p=o[r]+e,_=o[r+1]+n,g=a*p+l*_,f=h*p+c*_;let m=d<<1,v=i<<1;for(let e=0;e<s;++e)t[m]=t[v]+g,t[m+1]=t[v+1]+f,m+=2,v+=2;d-=s}}else for(;0<=u;--u){const e=u<<1,n=o[e]+r.getX(u),p=o[e+1]+r.getY(u),_=a*n+l*p,g=h*n+c*p;let f=d<<1,m=i<<1;for(let e=0;e<s;++e)t[f]=t[m]+_,t[f+1]=t[m+1]+g,f+=2,m+=2;d-=s}},od=t=>wt(t)||null==t,rd=(t,e,i)=>wt(e)?e:Tt(e)?e(t):e?e[t%e.length]:i;class ad{constructor(t){this._parent=t,this._id=0,this._color=null,this._alpha=null}get id(){return this._id}get color(){return this._color}set color(t){this.set(t,void 0)}get alpha(){return this._alpha}set alpha(t){this.set(void 0,t)}set(t,e){let i=!1;void 0!==t&&this._color!==t&&(i=!0,this._color=t),void 0!==e&&this._alpha!==e&&(i=!0,this._alpha=e),i&&(this._id+=1,this._parent.updateUploaded())}getColor(t,e){return rd(t,this._color,e)}getAlpha(t,e){return rd(t,this._alpha,e)}isStaticColor(){return od(this._color)}isStaticAlpha(){return od(this._alpha)}toDirty(){this._id+=1}}class hd{constructor(t,e,i){this._parent=t,this._id=0,this._x=null,this._y=null,this._defX=e,this._defY=i,this._limit=null,this._limitComputed=0,this._limitId=-1,this._limitParentLength=0}get id(){return this._id}get x(){return this._x}set x(t){this.set(t,void 0)}get y(){return this._y}set y(t){this.set(void 0,t)}get limit(){return this._limit}set limit(t){this._limit=t}set(t,e){let i=!1;void 0!==t&&this._x!==t&&(i=!0,this._x=t),void 0!==e&&this._y!==e&&(i=!0,this._y=e),i&&(this._id+=1,this._parent.updateUploaded())}getX(t){return rd(t,this._x,this._defX)}getY(t){return rd(t,this._y,this._defY)}getLimit(){const t=this._limit;return null!=t?t:(this.updateLimitComputed(),this._limitComputed)}updateLimitComputed(){const t=this._id,e=this._parent.length;this._limitId===t&&this._limitParentLength===e||(this._limitId=t,this._limitParentLength=e,this._limitComputed=Math.max(this.calcLimit(this._x,e,this._defX),this.calcLimit(this._y,e,this._defY)))}calcLimit(t,e,i){if(wt(t))return Math.abs(t);if(Tt(t)){if(0<e){let i=Math.abs(t(0));for(let s=1;s<e;++s)i=Math.max(i,Math.abs(t(s)));return i}return 0}if(null!=t){const e=t.length;if(0<e){let i=t[0];for(let s=1;s<e;++s)i=Math.max(i,Math.abs(t[s]));return i}return 0}return Math.abs(i)}isStaticX(){return od(this._x)}isStaticY(){return od(this._y)}toDirty(){this._id+=1}}class ld{constructor(t){this._parent=t,this._id=0,this._color=null,this._alpha=null}get id(){return this._id}get color(){return this._color}set color(t){this.set(t,void 0)}get alpha(){return this._alpha}set alpha(t){this.set(void 0,t)}set(t,e){let i=!1;void 0!==t&&this._color!==t&&(i=!0,this._color=t),void 0!==e&&this._alpha!==e&&(i=!0,this._alpha=e),i&&(this._id+=1,this._parent.updateUploaded())}getColor(t,e){return rd(t,this._color,e)}getAlpha(t,e){return rd(t,this._alpha,e)}isStaticColor(){return od(this._color)}isStaticAlpha(){return od(this._alpha)}toDirty(){this._id+=1}}class cd{constructor(t){this._parent=t,this._values=[],this._valuesLength=0,this._segments=[],this._length=0,this._plength=0,this._size=new hd(this,q.SIZE_X,q.SIZE_Y),this._offset=new hd(this,0,0),this._fill=new ad(t),this._stroke=new ld(t),this._id=0}get length(){return this._length}get plength(){return this._plength}get id(){return this._id}get values(){return this._values}set values(t){this.set(t,void 0,void 0)}get segments(){return this._segments}set segments(t){}get style(){return F.NONE}set style(t){this.set(void 0,void 0,t)}get marker(){let t=this._marker;return null==t&&(t=tt.getInstance(),this._marker=t),t}getMarker(){}get size(){return this._size}get offset(){return this._offset}get fill(){return this._fill}get stroke(){return this._stroke}get formatter(){return null}set formatter(t){}get formatted(){return this}onSizeChange(){}toFitted(t,e){}copy(t){return this.set(t.values,t.segments,t.style)}set(t,e,i){let s=!1,n=!1;if(null!=t){const e=this._values,i=this._valuesLength,o=t.length;if(e!==t){const r=Math.min(i,o);for(let i=0;i<r;++i)e[i]=t[i];for(let i=r;i<o;++i)e.push(t[i]);i!==o?(e.length=o,this._valuesLength=o,s=!0):n=!0}else i!==o?(this._valuesLength=o,s=!0):n=!0;const r=o>>1;this._length=r,this._plength<r&&(this._plength=r)}if(s){this._id+=1;const t=this._parent,e=t.uploaded;e?e.isCompatible(t)?t.updateUploaded():t.toDirty():t.updateUploaded()}else n&&(this._id+=1,this._parent.updateUploaded());return this}updateUploaded(){this._parent.updateUploaded()}clone(t){return new cd(t).copy(this)}toPoints(e){const i=[],s=this.values;for(let n=0,o=s.length;n<o;n+=2){const o=new t.Point(s[n+0],s[n+1]);i.push(e.apply(o,o))}return i}serialize(t){return t.addResource("[]")}calcHitPointAbs(t,e,i,s,n,o,r,a,h){const l=this.formatted,c=l.length,u=l.values,d=this._size,p=this._offset;let _=0,g=c;if(r){const i=.5*d.getLimit(),s=p.getLimit(),n=cd.WORK_RANGE;r(t,e,i,i,s,s,o,u,n),_=n[0],g=n[1]}for(let r=_,l=Math.min(g,c);r<l;++r){const l=r<<1,c=u[l],_=u[l+1];if(a(t,e,.5*d.getX(r),.5*d.getY(r),p.getX(r),p.getY(r),c,_,i,s,n,r,o,h))return!0}return!1}}cd.WORK_RANGE=[0,0];class ud extends td{init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(ql(e,i,s),ed(e,9,s,8,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexAndStep(i,t,e),this.updateLineOfAnyColor(i,t,e,9),this.updateUv(i,t)}}updateVertexAndStep(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=K(e),g=this.transformLocalId!==_,f=e.stroke,m=f.align,v=f.enable?f.width:0,T=f.style,w=this.strokeAlign!==m||this.strokeWidth!==v||this.strokeStyle!==T;if(!(this.inited&H.VERTEX_AND_STEP)||r||l||p||g||w){this.inited|=H.VERTEX_AND_STEP,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.transformLocalId=_,this.strokeWidth=v,this.strokeAlign=m,this.strokeStyle=T,t.updateVertices(),t.updateSteps();const l=this.pointCount,c=r.values,p=this.vertexOffset,g=t.vertices,f=t.steps,w=e.transform.internalTransform;if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Zl(g,p,0,0,t,e,m,v,w,jl),nd(g,w,p,9,l,c,n),Jl(f,p,v,T,jl),id(f,p,9,l)}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=p+9*t;Zl(g,h,i,s,o,r,m,v,w,jl),Jl(f,h,v,T,jl)}const E=p+9*l,y=9*(this.pointCountReserved-l);Ku(g,E,y),Xu(f,E,y)}}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=t.uvs,n=this.vertexOffset,o=j(i),r=this.pointCountReserved;0<r&&(Ql(e,n,o),sd(e,n,9,r))}}}const dd=(t,e,i,s,n,r,a,h)=>{const l=I(e),c=l<<2,u=l<<1,d=e.points,p=ju(ac(d)),_=p*s,g=p*r,f=_+c,m=g+u;return t.check(i,n,f,m)?new o(t,i,n,f,m,[new h(t,i,n,_,g,p,s,r),new le(t,i+_,n+g,c,u)]).init(e):null},pd=(t,e,i,s,n)=>dd(t,e,i,9,s,8,0,ud);class _d extends Bi{constructor(t=s.LINE_OF_CIRCLES){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new _d(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const gd=(t,e,i)=>Dl(t,e,i||new _d),fd=()=>{n[s.LINE_OF_CIRCLES]=pd,e[s.LINE_OF_CIRCLES]=gd};class md extends td{constructor(t,e,i,s,n,o,r,a){super(t,e,i,s,n,o,r,a),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(Ml(e,i,s),ed(e,Il,s,Ol,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUv(i,t,e),this.updateLineOfAnyColor(i,t,e,Il)}}updateVertexStepAndUv(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=e.radius,_=u!==this.sizeX||d!==this.sizeY||p!==this.radius,g=K(e),f=this.transformLocalId!==g,m=e.stroke,v=m.align,T=m.enable?m.width:0,w=m.side,E=m.style,y=this.strokeAlign!==v||this.strokeWidth!==T||this.strokeSide!==w||this.strokeStyle!==E,x=e.corner,C=x!==this.corner,D=X(e),S=Y(D),b=D!==this.texture||S!==this.textureTransformId,I=r||l||_||y,O=!(this.inited&H.VERTEX_STEP_AND_UV);if(O||I||f||C||b){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.radius=p,this.transformLocalId=g,this.strokeAlign=v,this.strokeWidth=T,this.strokeSide=w,this.strokeStyle=E,this.corner=x,this.texture=D,this.textureTransformId=S,t.updateVertices(),(O||I||f||C)&&t.updateSteps(),(O||I||b)&&t.updateUvs();const l=this.pointCount,c=r.values,_=this.vertexOffset,m=t.vertices,y=t.steps,A=t.uvs,R=e.transform.internalTransform,M=j(D);if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);kl(m,_,0,0,t,e,v,T,p,R,Al),nd(m,R,_,Il,l,c,n),(O||I||f||C)&&(Ll(y,_,T,w,E,x,Al),id(y,_,Il,l)),(O||I||b)&&(Nl(A,_,M,Al),sd(A,_,Il,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=_+t*Il;kl(m,h,i,s,o,r,v,T,p,R,Al),(O||I||f||C)&&Ll(y,h,T,w,E,x,Al),(O||I||b)&&Nl(A,h,M,Al)}const k=this.pointCountReserved,L=_+l*Il,N=Il*(k-l);Ku(m,L,N),Xu(y,L,N),Yu(A,L,N)}}}const vd=(t,e,i,s,n)=>dd(t,e,i,Il,s,Ol,0,md);class Td extends Hl{constructor(t=s.LINE_OF_RECTANGLE_ROUNDEDS){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Td(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,a,n,o,r,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const wd=(t,e,i)=>Dl(t,e,i||new Td),Ed=()=>{n[s.LINE_OF_RECTANGLE_ROUNDEDS]=vd,e[s.LINE_OF_RECTANGLE_ROUNDEDS]=wd,Ui.set(s.LINE_OF_RECTANGLE_ROUNDEDS,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)};class yd extends td{init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(zc(e,i,s),ed(e,Nc,s,8,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUv(i,t,e),this.updateLineOfAnyColor(i,t,e,Nc)}}updateVertexStepAndUv(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=K(e),g=this.transformLocalId!==_,f=e.stroke,m=f.align,v=f.enable?f.width:0,T=f.side,w=f.style,E=this.strokeAlign!==m||this.strokeWidth!==v||this.strokeSide!==T||this.strokeStyle!==w,y=X(e),x=Y(y),C=y!==this.texture||x!==this.textureTransformId,D=r||l||p||E,S=!(this.inited&H.VERTEX_STEP_AND_UV);if(S||D||g||C){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.transformLocalId=_,this.strokeWidth=v,this.strokeAlign=m,this.strokeSide=T,this.strokeStyle=w,this.texture=y,this.textureTransformId=x,t.updateVertices(),(S||D||g)&&t.updateSteps(),(S||D||C)&&t.updateUvs();const l=this.pointCount,c=r.values,u=this.vertexOffset,d=t.vertices,p=t.steps,f=t.uvs,E=e.transform.internalTransform,b=j(y);if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Uc(d,u,0,0,t,e,m,v,E,Pc),nd(d,E,u,Nc,l,c,n),(S||D||g)&&(Fc(u,p,v,T,w,Pc),id(p,u,Nc,l)),(S||D||C)&&(Hc(f,u,b),sd(f,u,Nc,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=u+t*Nc;Uc(d,h,i,s,o,r,m,v,E,Pc),(S||D||g)&&Fc(h,p,v,T,w,Pc),(S||D||C)&&Hc(f,h,b)}const I=this.pointCountReserved,O=u+l*Nc,A=Nc*(I-l);Ku(d,O,A),Xu(p,O,A),Yu(f,O,A)}}}const xd=(t,e,i,s,n)=>dd(t,e,i,Nc,s,8,0,yd);class Cd extends yo{constructor(t=s.LINE_OF_RECTANGLES){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Cd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const Dd=(t,e,i)=>Dl(t,e,i||new Cd),Sd=()=>{n[s.LINE_OF_RECTANGLES]=xd,e[s.LINE_OF_RECTANGLES]=Dd,Ui.set(s.LINE_OF_RECTANGLES,Ot.PRIMITIVE|Ot.STROKE_SIDE)},bd=22,Id=15,Od=[0,0,0,0,0],Ad=new t.Point,Rd=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+3,t[++s]=e+4,t[++s]=e+5,t[++s]=e+7,t[++s]=e+5,t[++s]=e+6,t[++s]=e+7,t[++s]=e+8,t[++s]=e+9,t[++s]=e+11,t[++s]=e+9,t[++s]=e+10,t[++s]=e+11,t[++s]=e+12,t[++s]=e+13,t[++s]=e+16,t[++s]=e+13,t[++s]=e+14,t[++s]=e+16,t[++s]=e+14,t[++s]=e+15,t[++s]=e+16,t[++s]=e+12,t[++s]=e+16,t[++s]=e+19,t[++s]=e+16,t[++s]=e+17,t[++s]=e+19,t[++s]=e+17,t[++s]=e+18,t[++s]=e+19,t[++s]=e+12,t[++s]=e+19,t[++s]=e+13,t[++s]=e+19,t[++s]=e+20,t[++s]=e+13,t[++s]=e+20,t[++s]=e+21,t[++s]=e+13},Md=(t,e,i,s,n,o,r,a,h,l,c)=>{const u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u),_=Math.sqrt(d*d+4*p*p),g=2*d*p/(d+_),f=g*h/(2*p),m=.5*(_-g)*h/_,v=f*_/(2*d),T=Ad;T.set(i,s-p),l.apply(T,T);const w=T.x,E=T.y;T.set(i,s),l.apply(T,T);const y=T.x,x=T.y;T.set(i+d,s),l.apply(T,T);const D=y-w,S=x-E,b=T.x+D,I=T.y+S,O=y+(y-T.x)+D,A=x+(x-T.y)+S,R=b-w,M=I-E,k=w+m*R,L=E+m*M,N=b-f*R,P=I-f*M,B=v*(O-b),z=v*(A-I),U=b+B,F=I+z,H=O-B,G=A-z,V=w-O,W=E-A,K=O+f*V,X=A+f*W,Y=w-m*V,j=E-m*W;T.set(i,s+p-g),l.apply(T,T);const $=T.x,q=T.y,Z=w+h*($-w),J=E+h*(q-E),Q=b+h*($-b),tt=I+h*(q-I),et=O+h*($-O),it=A+h*(q-A),st=y+D,nt=x+S;c[0]=C(st,nt,$,q),c[1]=v,c[2]=f,c[3]=m,c[4]=1-.5*g/p;let ot=2*e-1;t[++ot]=Z,t[++ot]=J,t[++ot]=Y,t[++ot]=j,t[++ot]=w,t[++ot]=E,t[++ot]=k,t[++ot]=L,t[++ot]=Q,t[++ot]=tt,t[++ot]=N,t[++ot]=P,t[++ot]=b,t[++ot]=I,t[++ot]=U,t[++ot]=F,t[++ot]=et,t[++ot]=it,t[++ot]=H,t[++ot]=G,t[++ot]=O,t[++ot]=A,t[++ot]=K,t[++ot]=X,t[++ot]=$,t[++ot]=q,t[++ot]=Z,t[++ot]=J,t[++ot]=k,t[++ot]=L,t[++ot]=N,t[++ot]=P,t[++ot]=Q,t[++ot]=tt,t[++ot]=U,t[++ot]=F,t[++ot]=H,t[++ot]=G,t[++ot]=et,t[++ot]=it,t[++ot]=K,t[++ot]=X,t[++ot]=Y,t[++ot]=j},kd=(t,e,i,s,n,o,r)=>{const a=h(s),l=r[0],c=o*l,u=1-o,_=d(0,a,1,1),g=d(1,a,1,1),f=p(0,0),m=p(1,0),v=p(1,1),T=p(0,1),w=p(u,u),E=p(1,u),y=p(u,1),x=p(u,0);let C=6*e-1;n&nt.TOP?(t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=T,t[++C]=0):(t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=w,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=E,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=y,t[++C]=0),n&nt.BOTTOM_RIGHT?(t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=T,t[++C]=0):(t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=w,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=E,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=y,t[++C]=0),n&nt.BOTTOM_LEFT?(t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=T,t[++C]=0):(t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=w,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=E,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=y,t[++C]=0),t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=x,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=x,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=x,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0},Ld=(t,e,i,s,n)=>{const o=i.x0,r=i.x1,a=i.x2,h=i.x3,l=i.y0,c=i.y1,u=i.y2,d=i.y3,p=.5*(o+r),_=.5*(l+c),g=n[4],f=p+g*(h-o),m=_+g*(d-l),v=n[1],T=n[2],w=n[3],E=p+w*(h-p),y=_+w*(d-_),x=p+s*(f-p),C=_+s*(m-_),D=p+w*(a-p),S=_+w*(u-_),b=a+T*(p-a),I=u+T*(_-u),O=a+s*(f-a),A=u+s*(m-u),R=a+v*(h-a),M=u+v*(d-u),k=h+v*(a-h),L=d+v*(u-d),N=h+s*(f-h),P=d+s*(m-d),B=h+T*(p-h),z=d+T*(_-d);let U=2*e-1;t[++U]=x,t[++U]=C,t[++U]=E,t[++U]=y,t[++U]=p,t[++U]=_,t[++U]=D,t[++U]=S,t[++U]=O,t[++U]=A,t[++U]=b,t[++U]=I,t[++U]=a,t[++U]=u,t[++U]=R,t[++U]=M,t[++U]=N,t[++U]=P,t[++U]=k,t[++U]=L,t[++U]=h,t[++U]=d,t[++U]=B,t[++U]=z,t[++U]=f,t[++U]=m,t[++U]=x,t[++U]=C,t[++U]=D,t[++U]=S,t[++U]=b,t[++U]=I,t[++U]=O,t[++U]=A,t[++U]=R,t[++U]=M,t[++U]=k,t[++U]=L,t[++U]=N,t[++U]=P,t[++U]=B,t[++U]=z,t[++U]=E,t[++U]=y};class Nd extends td{constructor(t,e,i,s,n,o,r,a){super(t,e,i,s,n,o,r,a),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset,i=this.indexOffset,s=this.pointCountReserved;0<s&&(Rd(t.indices,e,i),ed(t.indices,bd,i,Id,s)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUv(i,t,e),this.updateLineOfAnyColor(i,t,e,bd)}}updateVertexStepAndUv(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=e.radius,g=_!==this.radius,f=K(e),m=this.transformLocalId!==f,v=e.stroke,T=v.align,w=v.enable?v.width:0,E=v.style,y=this.strokeAlign!==T||this.strokeWidth!==w||this.strokeStyle!==E,x=e.corner,C=this.corner!==x,D=X(e),S=Y(D),b=D!==this.texture||S!==this.textureTransformId,I=r||l||p||g||y,O=!(this.inited&H.VERTEX_STEP_AND_UV);if(O||I||m||C||b){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.radius=_,this.transformLocalId=f,this.strokeAlign=T,this.strokeWidth=w,this.strokeStyle=E,this.corner=x,this.texture=D,this.textureTransformId=S,t.updateVertices(),(O||I||m||C)&&t.updateSteps(),(O||I||b)&&t.updateUvs();const l=this.pointCount,c=r.values,p=this.vertexOffset,g=t.vertices,v=t.steps,y=t.uvs,A=e.transform.internalTransform,R=j(D);if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Md(g,p,0,0,t,e,T,w,_,A,Od),nd(g,A,p,bd,l,c,n),(O||I||m||C)&&(kd(v,p,w,E,x,_,Od),id(v,p,bd,l)),(O||I||b)&&(Ld(y,p,R,_,Od),sd(y,p,bd,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=p+t*bd;Md(g,h,i,s,o,r,T,w,_,A,Od),(O||I||m||C)&&kd(v,h,w,E,x,_,Od),(O||I||b)&&Ld(y,h,R,_,Od)}const M=this.pointCountReserved,k=p+l*bd,L=bd*(M-l);Ku(g,k,L),Xu(v,k,L),Yu(y,k,L)}}}const Pd=(t,e,i,s,n)=>dd(t,e,i,bd,s,Id,0,Nd),Bd=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f)=>{const m=o+u*(a-o)-s,v=r+u*(h-r)-n,T=Math.sqrt(m*m+v*v),w=1e-5;if(w<T){const a=1/T,h=m*a,u=v*a,E=(o+d*(l-o)-s)*a,y=(r+d*(c-r)-n)*a,x=h*y-E*u;if(w<Math.abs(x)){const o=1/x,r=e-s,a=i-n;if(((t,e,i,s,n,o,r)=>{if(t.fill.enable){if(e*e+i*i<=s*s)return!0}else if(0<o){const t=e*e+i*i;if(t<=s*s){const e=Math.max(0,s*(1-o*r/n));if(e*e<=t)return!0}}return!1})(t,(+y*r-E*a)*o,(-u*r+h*a)*o,T,p*_,g,f))return!0}}return!1},zd=(t,e,i,s,n,o,r)=>{const a=2*n/s;if(se(e,i,a,-n,+n)){const h=Math.sqrt(s*s+4*n*n),l=2*s*n/(s+h),c=t.radius,u=0,d=n-l,p=0,_=-n,g=+s,f=+n,m=-g,v=+f,T=p+c*(u-p),w=_+c*(d-_),E=g+c*(u-g),y=f+c*(d-f),x=+y,C=-E,D=-a*e+w-i<=0,S=+a*e+w-i<=0,b=i<=y,I=t.corner;if(!D&&!S&&I&nt.TOP){const s=.5*(h-l)*c/h;if(Bd(t,e,i,T,w,p,_,m,v,g,f,s,s,l,c,o,r))return!0}else if(!D&&!b&&I&nt.BOTTOM_LEFT){const a=l*c/(2*n);if(Bd(t,e,i,C,x,m,v,g,f,p,_,a*h/(2*s),a,l,c,o,r))return!0}else if(!S&&!b&&I&nt.BOTTOM_RIGHT){const a=l*c/(2*n);if(Bd(t,e,i,E,y,g,f,p,_,m,v,a,a*h/(2*s),l,c,o,r))return!0}else{if(t.fill.enable)return!0;if(0<o){const t=o*r,s=n-l,h=s+(-n-s)*Math.max(0,l-t)/l;if(!se(e,i,a,h,n-t))return!0}}}return!1};class Ud extends te{constructor(t=s.TRIANGLE_ROUNDED){super(t)}clone(){return new Ud(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&zd(this,t,e,i,s,n,o)}}class Fd extends Ud{constructor(t=s.LINE_OF_TRIANGLE_ROUNDEDS){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Fd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const Hd=(t,e,i)=>Dl(t,e,i||new Fd),Gd=()=>{n[s.LINE_OF_TRIANGLE_ROUNDEDS]=Pd,e[s.LINE_OF_TRIANGLE_ROUNDEDS]=Hd,Ui.set(s.LINE_OF_TRIANGLE_ROUNDEDS,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)};class Vd extends td{init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(xc(e,i,s),ed(e,7,s,3,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUvs(i,t,e),this.updateLineOfAnyColor(i,t,e,7)}}updateVertexStepAndUvs(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=K(e),g=this.transformLocalId!==_,f=e.stroke,m=f.align,v=f.enable?f.width:0,T=f.style,w=this.strokeAlign!==m||this.strokeWidth!==v||this.strokeStyle!==T,E=X(e),y=Y(E),x=E!==this.texture||y!==this.textureTransformId,C=r||l||p||w,D=!(this.inited&H.VERTEX_STEP_AND_UV);if(D||C||g||x){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.transformLocalId=_,this.strokeAlign=m,this.strokeWidth=v,this.strokeStyle=T,this.texture=E,this.textureTransformId=y,t.updateVertices(),(D||C||g)&&t.updateSteps(),(D||C||x)&&t.updateUvs();const l=this.pointCount,c=r.values,p=this.vertexOffset,f=t.vertices,w=t.steps,S=t.uvs,b=j(E),I=e.transform.internalTransform;if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Cc(f,p,0,0,t,e,m,v,I,Ec),nd(f,I,p,7,l,c,n),(D||C||g)&&(Dc(w,p,v,T,Ec),id(w,p,7,l)),(D||C||x)&&(Sc(S,b,p,Ec),sd(S,p,7,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=p+7*t;Cc(f,h,i,s,o,r,m,v,I,Ec),(D||C||g)&&Dc(w,h,v,T,Ec),(D||C||x)&&Sc(S,b,h,Ec)}const O=p+7*l,A=7*(this.pointCountReserved-l);Ku(f,O,A),Xu(w,O,A),Yu(S,O,A)}}}const Wd=(t,e,i,s,n)=>dd(t,e,i,7,s,3,0,Vd);class Kd extends te{constructor(t=s.TRIANGLE){super(t)}clone(){return new Kd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&ne(this,t,e,i,s,n,o)}}class Xd extends Kd{constructor(t=s.LINE_OF_TRIANGLES){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Xd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const Yd=(t,e,i)=>Dl(t,e,i||new Xd),jd=()=>{n[s.LINE_OF_TRIANGLES]=Wd,e[s.LINE_OF_TRIANGLES]=Yd},$d=(t,e,i,s)=>new o(t,i,s,0,0,[new Lc(t,i,s)]).init(e);class qd extends te{constructor(t=s.NULL){super(t)}clone(){return new qd(this.type).copy(this)}}const Zd=(t,e,i)=>Dl(t,e,i||new qd),Jd=()=>{n[s.NULL]=$d,e[s.NULL]=Zd},Qd=(t,e,i)=>Dl(t,e,i||new yo),tp=()=>{n[s.RECTANGLE]=xu,e[s.RECTANGLE]=Qd,Ui.set(s.RECTANGLE,Ot.PRIMITIVE|Ot.STROKE_SIDE)},ep=(t,e,i)=>Dl(t,e,i||new xo),ip=(t,e,i)=>Dl(t,e,i||new Hl),sp=()=>{n[s.RECTANGLE_ROUNDED]=Bl,e[s.RECTANGLE_ROUNDED]=ip,Ui.set(s.RECTANGLE_ROUNDED,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)},np=[0,0],op=new t.Point,rp=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+4,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+4,t[++s]=e+2,t[++s]=e+5,t[++s]=e+4},ap=(t,e,i,s,n,o,r,a,h,l)=>{const c=op,u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u);c.set(-d+i,-p+s),h.apply(c,c);const _=c.x,g=c.y;c.set(0+i,-p+s),h.apply(c,c);const f=c.x,m=c.y,v=f-_,T=m-g;c.set(i,s),h.apply(c,c);const w=c.x,E=c.y,y=w-v,x=E-T;let D=2*e-1;t[++D]=_,t[++D]=g,t[++D]=f,t[++D]=m,t[++D]=f+v,t[++D]=m+T,t[++D]=y,t[++D]=x,t[++D]=w,t[++D]=E,t[++D]=w+v,t[++D]=E+T,l[0]=C(_,g,f,m),l[1]=C(_,g,y,x)},hp=(t,e,i,s,n)=>{const o=h(s),r=n[0],a=n[1],l=d(1,o,1,1),c=p(1,1),u=p(0,1),_=p(1,0),g=p(0,0);let f=6*e-1;t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=u,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=g,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0},lp=(t,e,i)=>{const s=i.x0,n=i.x1,o=i.x2,r=i.x3,a=i.y0,h=i.y1,l=i.y2,c=i.y3;let u=2*e-1;t[++u]=s,t[++u]=a,t[++u]=.5*(s+n),t[++u]=.5*(a+h),t[++u]=n,t[++u]=h,t[++u]=.5*(s+r),t[++u]=.5*(a+c),t[++u]=.5*(s+o),t[++u]=.5*(a+l),t[++u]=.5*(n+o),t[++u]=.5*(h+l)};class cp extends W{constructor(t,e,i){super(t,e,i,6,4)}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset;rp(t.indices,e,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u;(!(this.inited&H.VERTEX_AND_STEP)||o||a||d)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,t.updateVertices(),t.updateSteps(),ap(t.vertices,this.vertexOffset,0,0,s,n,l,c,e.transform.internalTransform,np),hp(t.steps,this.vertexOffset,c,u,np))}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=j(i);lp(t.uvs,this.vertexOffset,e)}}}const up=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=6+a,c=4+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new cp(t,i,s),new le(t,i+6,s+4,a,h)]).init(e):null},dp=(t,e,i,s,n,o,r)=>i<=0&&ee(t,e,i,s,n,o,r);class pp extends te{constructor(t=s.SEMICIRCLE){super(t),this.stroke.side=V.ALL&~V.BOTTOM}clone(){return new pp(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&dp(this,t,e,i,s,n,o)}}const _p=(t,e,i)=>Dl(t,e,i||new pp),gp=()=>{n[s.SEMICIRCLE]=up,e[s.SEMICIRCLE]=_p};class fp extends W{constructor(t,e,i){super(t,e,i,7,3)}init(){const t=this.buffer;t.updateIndices(),xc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u,p=X(e),_=Y(p),g=p!==this.texture||_!==this.textureTransformId,f=o||d,m=!(this.inited&H.VERTEX_STEP_AND_UV);if(m||f||a||g){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,this.texture=p,this.textureTransformId=_;const i=this.vertexOffset;t.updateVertices(),Cc(t.vertices,i,0,0,s,n,l,c,e.transform.internalTransform,Ec),(m||f||a)&&(t.updateSteps(),Dc(t.steps,i,c,u,Ec)),(m||f||g)&&(t.updateUvs(),Sc(t.uvs,j(p),i,Ec))}}}const mp=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=7+a,c=3+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new fp(t,i,s),new le(t,i+7,s+3,a,h)]).init(e):null},vp=(t,e,i)=>Dl(t,e,i||new Kd),Tp=()=>{n[s.TRIANGLE]=mp,e[s.TRIANGLE]=vp};class wp extends W{constructor(t,e,i){super(t,e,i,bd,Id),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices(),Rd(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=e.radius,a=r!==this.radius,h=K(e),l=this.transformLocalId!==h,c=e.stroke,u=c.align,d=c.enable?c.width:0,p=c.style,_=this.strokeAlign!==u||this.strokeWidth!==d||this.strokeStyle!==p,g=e.corner,f=g!==this.corner,m=X(e),v=Y(m),T=m!==this.texture||v!==this.textureTransformId,w=o||a||_,E=!(this.inited&H.VERTEX_STEP_AND_UV);if(E||w||l||f||T){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.radius=r,this.transformLocalId=h,this.strokeAlign=u,this.strokeWidth=d,this.strokeStyle=p,this.corner=g,this.texture=m,this.textureTransformId=v;const i=this.vertexOffset;t.updateVertices(),Md(t.vertices,i,0,0,s,n,u,d,r,e.transform.internalTransform,Od),(E||w||l||f)&&(t.updateSteps(),kd(t.steps,i,d,p,g,r,Od)),(E||w||T)&&(t.updateUvs(),Ld(t.uvs,i,j(m),r,Od))}}}const Ep=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=bd+a,c=Id+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new wp(t,i,s),new le(t,i+bd,s+Id,a,h)]).init(e):null},yp=(t,e,i)=>Dl(t,e,i||new Ud),xp=()=>{n[s.TRIANGLE_ROUNDED]=Ep,e[s.TRIANGLE_ROUNDED]=yp,Ui.set(s.TRIANGLE_ROUNDED,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)},Cp=()=>{bl(),Yl(),sc(),iu(),su(),uu(),Eu(),mu(),Su(),n[s.IMAGE_SDF]=Lu,e[s.IMAGE_SDF]=Pu,Hu(),Wu(),Jd(),n[s.RECTANGLE_PIVOTED]=ou,e[s.RECTANGLE_PIVOTED]=ep,Ui.set(s.RECTANGLE_PIVOTED,Ot.PRIMITIVE|Ot.STROKE_SIDE),sp(),tp(),gp(),xp(),Tp(),fd(),Ed(),Sd(),Gd(),jd()};class Dp extends Oa{getType(){return"DImage"}}class Sp extends Dp{constructor(t){var e;super(t),this._value=null!==(e=null==t?void 0:t.value)&&void 0!==e?e:null}init(t){super.init(t),this.on(nn.tap,t=>{this.onClick(t)})}onClick(t){this.state.isActionable&&this.activate(t)}activate(t){this.onSelect(t)}get value(){return this._value}set value(t){this._value=t}hasSelection(t){return t&&t.selection&&t.selection.add}getSelection(){let t=this.parent;for(;t;){if(this.hasSelection(t))return t.selection;t=t.parent}return null}onSelect(t){this.emit("select",this._value,this);const e=this.getSelection();e&&e.add(this)}onKeyDown(t){return $n.isActivateKey(t)&&this.onKeyDownActivate(t),super.onKeyDown(t)}onKeyDownActivate(t){return!(!this.state.isActionable||!this.state.isFocused||(this.activate(t),0))}getType(){return"DMenuItemBase"}}class bp extends Sp{getContext(){let t=this.parent;for(;t;){if(t.getContext)return t.getContext();t=t.parent}return null}getCloseable(){let t=this.parent;for(;t;){if(t.getCloseable)return t.getCloseable();t=t.parent}return null}getType(){return"DMenuItem"}}class Ip extends bp{init(t){super.init(t),this.initOnOver(t),this.initShortcuts(t)}initOnOver(t){this.on(nn.over,()=>{const t=this.getContext();null!=t&&this.parent instanceof to&&t.trim(this.getCloseable())})}initShortcuts(t){const e=this._shortcuts;if(null!=e&&0<e.length){const t=e[0],i=this.newShortcutText();this._shortcutText=i,this.snippet.add(i,!0),i.text=$n.toString(t)}else this._shortcutText=null;this._shortcutMargin=this.theme.getShortcutTextMargin()}newShortcutText(){var t,e;return new ga(new fa(this,this.theme,null===(e=null===(t=this._options)||void 0===t?void 0:t.text)||void 0===e?void 0:e.style))}updateShortcutText(){const t=this._shortcutText,e=this._shortcutMargin;if(null!=t&&null!=e){const i=this._auto;let s=0;s=i.width.isOn?e:this.width-t.width-e;let n=0;const o=this._padding,r=o.getTop();n=i.height.isOn?r:r+.5*(this.height-r-o.getBottom()-t.height),t.position.set(s,n)}}updateShortcutColor(){const t=this._shortcutText;if(null!=t){const e=this.theme,i=this.state;t.style.fill=e.getShortcutColor(i),t.alpha=e.getShortcutAlpha(i)}}onReflow(){super.onReflow(),this.updateShortcutColor(),this.updateShortcutText()}getType(){return"DMenuItemText"}onSelect(t){super.onSelect(t);const e=this.getCloseable();null!=e&&e.emit("select",this.value,this,e)}onShortcut(t){super.onShortcut(t),this.activate(t)}}class Op extends Ip{init(t){super.init(t),(null==t?void 0:t.check)&&(this.state.isActive=!0)}getType(){return"DMenuItemCheck"}onSelect(t){this.state.isActive=!this.state.isActive,super.onSelect(t)}}const Ap=t=>"check"in t,Rp={OPEN_LINK:0,OPEN_LINK_IN_NEW_WINDOW:1,COPY_LINK_ADDRESS:2};class Mp{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static setMenuCreator(t){this.MENU_CREATOR=t}static newItemOf(t,e,i,s){for(let e=0,n=t.length;e<n;++e){const n=t[e](i,s);if(null!=n)return n}return e?e(i,s):null}static newItem(t,e){return this.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)}static newItemsOf(e,i,s,n){for(let o=0,r=s.length;o<r;++o){const r=s[o];if(r instanceof t.DisplayObject)i.addChild(r);else if(null!=r){const t=e.newItem(r,n);if(null==t)throw new Error("No matching menu item creator found: "+JSON.stringify(r));i.addChild(t)}}}static newItems(t,e,i){this.newItemsOf(this,t,e,i)}static newMenu(t){if(null!=this.MENU_CREATOR)return this.MENU_CREATOR(t);throw new Error("Missing DMenu creator.")}}Mp.CREATORS=[],Mp.CREATOR_DEFAULT=null;class kp{constructor(t,e){this._parent=t,this._options=e,this._isEnabled=!0}get enable(){return this._isEnabled}set enable(t){this._isEnabled=t}open(t){this.get().open(t)}get(){let t=this._menu;return null==t&&(t=this.toMenu(this._options),this._menu=t,t.on("select",(t,e,i)=>{this.onSelect(t,e,i)})),t}toMenu(e){return e instanceof t.DisplayObject?e:this.newMenu(e)}newMenu(t){return Mp.newMenu(t)}onSelect(t,e,i){const s=this._parent;switch(t){case Rp.OPEN_LINK:s.open(!1);break;case Rp.OPEN_LINK_IN_NEW_WINDOW:s.open(!0);break;case Rp.COPY_LINK_ADDRESS:s.copy()}}}const Lp={AUTO:0,THIS_WINDOW:1,NEW_WINDOW:2},Np=t=>{const e=document.getSelection();if(e){const i=document.createRange();i.selectNodeContents(t),e.removeAllRanges(),e.addRange(i)}return e},Pp=t=>t.clipboardData||window.clipboardData;class Bp extends t.utils.EventEmitter{constructor(){super();const t=document.body;t.addEventListener("copy",e=>{e.target===t&&(e.preventDefault(),e.stopPropagation(),this.emit("copy",Pp(e)))}),t.addEventListener("cut",e=>{e.target===t&&(e.preventDefault(),e.stopPropagation(),this.emit("cut",Pp(e)))}),t.addEventListener("paste",e=>{e.target===t&&(e.preventDefault(),e.stopPropagation(),this.emit("paste",Pp(e)))})}static copy(t){const e=navigator.clipboard;e&&e.writeText?e.writeText(t):((t,e)=>{if("undefined"==typeof ClipboardEvent){const i=t.clipboardData;if(void 0!==i&&void 0!==i.setData)return i.setData("Text",e),!0}return!1})(window,t)||(t=>{const e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important"),e.textContent="Dummy",document.body.appendChild(e);const i=Np(e);let s=!1;if(i){const n=i=>{if(i.target===e){const e=Pp(i);e.setData("text/plain",t),s=e.getData("text/plain")===t,i.preventDefault()}};document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}i.removeAllRanges()}return document.body.removeChild(e),s})(t)||navigator.userAgent.indexOf("Edge")<0&&(t=>{const e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");const i=document.createElement("span");i.innerText=t,(e.attachShadow?e.attachShadow({mode:"open"}):e).appendChild(i),document.body.appendChild(e);const s=Np(e);s&&(document.execCommand("copy"),s.removeAllRanges()),document.body.removeChild(e)})(t)}}class zp{constructor(t){this._options=t,this._url=null==t?void 0:t.url,this._target=this.toNormalizedTarget(null==t?void 0:t.target),this._checker=null==t?void 0:t.checker,this._isEnabled=!0}get enable(){return this._isEnabled}set enable(t){this._isEnabled=t}get url(){return this._url}set url(t){this._url=t}get target(){return this._target}set target(t){this._target=this.toNormalizedTarget(t)}get checker(){return this._checker}set checker(t){this._checker=t}get menu(){let t=this._menu;return null==t&&(t=this.newMenu(),this._menu=t),t}newMenu(){const t=this._options;if(t){const e=t.menu;if(e)return new kp(this,e)}let e=zp.MENU;return null==e&&(e=new kp(this,$.getInstance().get("DLink").getMenuOptions()),zp.MENU=e),e}toStringifiedUrl(t,e){const i=Tt(t)?t():t;null!=i&&(Et(i)?e(i):i.then(t=>{null!=t&&e(t)}))}toNormalizedUrl(t){const e=zp.ANCHOR_ELEMENT||document.createElement("a");return zp.ANCHOR_ELEMENT=e,e.href=t,e.href}toNormalizedTarget(t){return Qi(null!=t?t:Lp.AUTO,Lp)}copy(){this.toStringifiedUrl(this._url,t=>{Bp.copy(this.toNormalizedUrl(t))})}open(t){this.toStringifiedUrl(this._url,e=>{const i=!0===t||!1===t?t:this.inNewWindow(t);this.check(e,i,()=>{this.exec(e,i)})})}check(t,e,i){const s=this._checker;if(s){const t=s();!0===t?i():!1===t||t.then(t=>{t&&i()})}else i()}exec(t,e){if(e){const e=document.createElement("a");e.href=t,e.target="_blank",e.style.display="none",e.rel="noopener noreferrer",document.body.appendChild(e),e.click(),setTimeout(()=>{document.body.removeChild(e)},100)}else window.location.href=t}inNewWindow(e){switch(this._target){case Lp.NEW_WINDOW:return!0;case Lp.THIS_WINDOW:return!1;case Lp.AUTO:if(null!=e){const i=e instanceof t.InteractionEvent?e.data.originalEvent:e;return i.ctrlKey||i.shiftKey||i.altKey||i.metaKey||"button"in i&&0!==i.button}return!1}}onClick(t,e){if(this._target===Lp.AUTO){const i=e.data.originalEvent;if("pointerType"in i&&"mouse"!==i.pointerType||"touches"in i){const e=this.menu;if(e.enable)return this._isEnabled&&t.state.isActionable&&e.open(t),!0}}return!this._isEnabled}}class Up{static toStateOptions(t,e){if(e&&(t===Lp.NEW_WINDOW||"NEW_WINDOW"===t)){const t=e.state;if(null==t)e.state=lt.NEW_WINDOW;else if(Et(t))t!==lt.NEW_WINDOW&&(e.state=[t,lt.NEW_WINDOW]);else if(vt(t))t.indexOf(lt.NEW_WINDOW)<0&&t.push(lt.NEW_WINDOW);else{const e=t.values;null==e?t.values=lt.NEW_WINDOW:Et(e)?e!==lt.NEW_WINDOW&&(t.values=[e,lt.NEW_WINDOW]):e.indexOf(lt.NEW_WINDOW)<0&&e.push(lt.NEW_WINDOW)}}return e}}class Fp extends Ip{toLinkOptions(t){if(t)return{url:this.toUrl(t.url),target:t.target,checker:this.toChecker(t.checker),menu:t.menu}}toUrl(t){return Et(t)||null==t?t:()=>t(this)}toChecker(t){if(null!=t)return()=>t(this)}init(t){super.init(Up.toStateOptions(null==t?void 0:t.target,t))}get link(){let t=this._link;return null==t&&(t=new zp(this.toLinkOptions(this._options)),this._link=t),t}onClick(t){this.link.onClick(this,t)||super.onClick(t)}getType(){return"DMenuItemLink"}onSelect(t){super.onSelect(t),this.link.open(t)}open(t){this.link.open(t)}onShortcut(t){super.onShortcut(t),this.activate(t)}}const Hp=t=>"url"in t;class Gp extends bp{init(t){super.init(t),this.initHover(t)}initHover(t){this.on(nn.over,()=>{this.state.isActionable&&this.open()})}toMenu(e){const i=null==e?void 0:e.menu;return i instanceof t.DisplayObject?i:this.newMenu(i)}newMenu(t){return Mp.newMenu(t)}get menu(){let t=this._menu;return null==t&&(t=this.toMenu(this._options),t.on("select",(t,e,i)=>{this.onMenuSelect(t,e,i)}),this._menu=t),t}getType(){return"DMenuItemMenu"}open(){const t=this.menu;t.isHidden()&&this.onOpen(t)}onOpen(t){const e=this.getContext();null!=e&&t.open(this,this.getCloseable(),e)}close(){this.menu.close()}toggle(){const t=this.menu;t.isHidden()?this.onOpen(t):t.close()}onSelect(t){this.open(),super.onSelect(t)}onMenuSelect(t,e,i){const s=this.getCloseable();null!=s&&s.emit("select",t,e,s)}onKeyDown(t){return $n.isArrowRightKey(t)&&this.onKeyDownArrowRight(t),super.onKeyDown(t)}onKeyDownArrowRight(t){return!(!this.state.isActionable||!this.state.isFocused||(this.onSelect(t),0))}}const Vp=t=>"menu"in t,Wp=(e,i)=>{const s=e.menu;return s instanceof t.DisplayObject||(null==s.sticky&&(s.sticky=i),null==s.align&&(s.align=kr.RIGHT)),e};class Kp extends t.Graphics{constructor(t){super(),t.snippet.add(this,!0),t.reflowable.add(this)}onReflow(t,e,i){const s=t.state,n=t.border,o=n.getWidth(s),r=n.getColor(s);if(null!=r){const a=n.getAlpha(s),h=n.getAlign(s),l=t.padding,c=.5*i;this.clear(),this.lineStyle(o,r,a,h),this.moveTo(l.getLeft(),c),this.lineTo(e-l.getRight(),c),this.visible=!0}else this.clear(),this.visible=!1}}const Xp=t=>"separator"in t;class Yp extends Sp{initReflowable(){new Kp(this)}getType(){return"DMenuItemSeparator"}}class jp extends Wr{getType(){return"DMenuItemSpace"}}const $p=t=>"space"in t,qp=()=>{Mp.addItemCreator(t=>Ap(t)?new Op(t):null),Mp.addItemCreator(t=>Hp(t)?new Fp(t):null),Mp.addItemCreator((t,e)=>Vp(t)?new Gp(Wp(t,e)):null),Mp.addItemCreator(t=>Xp(t)?new Yp(t):null),Mp.addItemCreator(t=>$p(t)?new jp(t):null),Mp.setItemCreatorDefault(t=>new Ip(t))};class Zp extends Yr{getType(){return"DMenuItemExpandableBody"}}class Jp extends Sp{getSelection(){return null}getType(){return"DMenuItemExpandableHeader"}}class Qp{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static newItem(t,e){return Mp.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)||Mp.newItem(t,e)}static newItems(t,e,i){Mp.newItemsOf(this,t,e,i)}}Qp.CREATORS=[],Qp.CREATOR_DEFAULT=null;class t_ extends Yr{init(t){var e;super.init(t);const i=this.theme,s=this.toHeader(i,t);this._header=s,s.on("select",()=>{this.toggle()}),this.addChild(s);const n=this.toBody(i,t);this._body=n;const o=null!==(e=null==t?void 0:t.sticky)&&void 0!==e&&e;this.newItems(n,o,i,t),this.addChild(n),this.state.isActive?this.onActivated():this.onDeactivated()}newItems(t,e,i,s){const n=null==s?void 0:s.items;null!=n&&Qp.newItems(t,n,e)}toHeader(e,i){return i?i.header instanceof t.DisplayObject?i.header:this.newHeader(e,i.header):this.newHeader(e)}newHeader(t,e){return new Jp(e)}toBody(e,i){const s=null==i?void 0:i.body;return s?s instanceof t.DisplayObject?s:this.newBody(e,s):this.newBody(e)}newBody(t,e){return new Zp(e)}open(){this.state.isActive=!0}close(){this.state.isActive=!1}toggle(){this.state.isActive=!this.state.isActive}onActivated(){const t=this._body;t instanceof to?t.show():t.visible=!0}onDeactivated(){const t=this._body;t instanceof to?t.hide():t.visible=!1}onStateChange(t,e){super.onStateChange(t,e),t.isActive?e.isActive||this.onActivated():e.isActive&&this.onDeactivated()}onKeyDown(t){if($n.isArrowRightKey(t)){if(this.state.isActionable&&!this.state.isActive){const t=this._header;t instanceof to&&t.state.isFocused&&(this.state.isActive=!0)}}else if($n.isArrowLeftKey(t)&&this.state.isActionable&&this.state.isActive){const e=this._header;return e instanceof to?e.focus():this.focus(),this.state.isActive=!1,super.onKeyDown(t),!0}return super.onKeyDown(t)}getType(){return"DMenuItemExpandable"}}const e_=t=>"header"in t;class i_ extends Op{getType(){return"DMenuItemExpandableItemCheck"}}class s_ extends Fp{getType(){return"DMenuItemExpandableItemLink"}}class n_ extends Yp{getType(){return"DMenuItemExpandableItemSeparator"}}class o_ extends jp{getType(){return"DMenuItemExpandableItemSpace"}}class r_ extends Ip{getType(){return"DMenuItemExpandableItemText"}}const a_=()=>{Mp.addItemCreator(t=>e_(t)?new t_(t):null),Qp.addItemCreator(t=>Ap(t)?new i_(t):null),Qp.addItemCreator(t=>Hp(t)?new s_(t):null),Qp.addItemCreator(t=>Xp(t)?new n_(t):null),Qp.addItemCreator(t=>$p(t)?new o_(t):null),Qp.setItemCreatorDefault(t=>new r_(t))};class h_ extends Op{getType(){return"DMenuSidedItemCheck"}}class l_ extends Fp{getSelection(){return null}getType(){return"DMenuSidedItemLink"}}class c_ extends Gp{initHover(t){}onMenuSelect(t,e,i){super.onMenuSelect(t,e,i);const s=super.getSelection();s&&s.add(e)}onOpen(t){t.open(this,this)}getSelection(){return null}getType(){return"DMenuSidedItemMenu"}}class u_ extends Yp{getType(){return"DMenuSidedItemSeparator"}}class d_ extends jp{getType(){return"DMenuSidedItemSpace"}}class p_ extends Ip{getType(){return"DMenuSidedItemText"}}class __{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static newItem(t,e){return Mp.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)||Mp.newItem(t,e)}static newItems(t,e,i){Mp.newItemsOf(this,t,e,i)}}__.CREATORS=[],__.CREATOR_DEFAULT=null;const g_=()=>{__.setItemCreatorDefault(t=>new p_(t)),__.addItemCreator(t=>$p(t)?new d_(t):null),__.addItemCreator(t=>Xp(t)?new u_(t):null),__.addItemCreator((t,e)=>Vp(t)?new c_(Wp(t,e)):null),__.addItemCreator(t=>Hp(t)?new l_(t):null),__.addItemCreator(t=>Ap(t)?new h_(t):null)};class f_{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static newItem(t,e){return Mp.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)||__.newItem(t,e)}static newItems(t,e,i){Mp.newItemsOf(this,t,e,i)}}f_.CREATORS=[],f_.CREATOR_DEFAULT=null;class m_ extends t_{newItems(t,e,i,s){null!=s&&null!=s.items&&f_.newItems(t,s.items,e)}getType(){return"DMenuSidedItemExpandable"}}class v_ extends i_{getType(){return"DMenuSidedItemExpandableItemCheck"}}class T_ extends Fp{getType(){return"DMenuSidedItemExpandableItemLink"}}class w_ extends Gp{getType(){return"DMenuItemExpandableItemMenu"}}class E_ extends w_{onOpen(t){t.open(this,this)}getType(){return"DMenuSidedItemExpandableItemMenu"}}class y_ extends n_{getType(){return"DMenuSidedItemSeparator"}}class x_ extends o_{getType(){return"DMenuSidedItemExpandableItemSpace"}}class C_ extends r_{getType(){return"DMenuSidedItemExpandableItemText"}}const D_=()=>{__.addItemCreator(t=>e_(t)?new m_(t):null),f_.addItemCreator(t=>Ap(t)?new v_(t):null),f_.addItemCreator(t=>Hp(t)?new T_(t):null),f_.addItemCreator((t,e)=>Vp(t)?new E_(Wp(t,e)):null),f_.addItemCreator(t=>Xp(t)?new y_(t):null),f_.addItemCreator(t=>$p(t)?new x_(t):null),f_.setItemCreatorDefault(t=>new C_(t))},S_=()=>{qp(),a_(),g_(),D_()},b_=()=>{S_(),Cp()},I_=(t,e)=>e?Cl(t).then(t=>{const e=Fs.getInstance().init();e.updateTexture(t.width,t.height,t.source),e.render();const i=document.createElement("canvas");return e.read(i),I_(i.toDataURL(),!1)}):Cl(t).then(t=>new Nu(t)),O_=t=>"data:image/svg+xml;base64,"+btoa(t),A_=t=>Math.round(100*t)/100,R_=Pi;class M_{static from(t){if(Et(t))return F[t];if(wt(t))return t;if(null!=t){let e=F.NONE;for(let i=0,s=t.length;i<s;++i)e|=F[t[i]];return e}return F.NONE}}class k_{constructor(){this.resources=[],this.resourceToIndex=new Map,this.data=[],this.dataToIndex=new Map,this.pieces=[],this.pieceToIndex=new Map,this.uuids=new Set,this.uuidNext=0}addResource(t){return this.add_(t,this.resources,this.resourceToIndex)}addData(t){return this.add_(t,this.data,this.dataToIndex)}addPiece(t){return this.add_(t,this.pieces,this.pieceToIndex)}addUuid(t){if(0!==t){const e=this.uuids;return e.has(t)?0:(e.add(t),t)}return 0}updateUuid(t){const e=this.uuids;if(0!==t)return t;{const t=this.newUuid();return e.add(t),t}}newUuid(){const t=this.uuids;let e=this.uuidNext;for(;;)if(e+=1,0!==e&&!t.has(e))return this.uuidNext=e,e}add_(t,e,i){const s=i.get(t);if(null!=s)return s;const n=e.length;return e.push(t),i.set(t,n),n}}class L_ extends t.utils.EventEmitter{constructor(t,e){var i,s,n;super(),this._isVisibleDefault=null!==(i=null==e?void 0:e.visible)&&void 0!==i?i:t.isSnapGridVisible(),this._isVisible=this._isVisibleDefault,this._isEnabledDefault=null!==(s=null==e?void 0:e.enable)&&void 0!==s?s:t.isSnapGridEnabled(),this._isEnabled=this._isEnabledDefault,this._sizeDefault=null!==(n=null==e?void 0:e.size)&&void 0!==n?n:t.getSnapGridSize(),this._size=this._sizeDefault}get visible(){return this._isVisible}set visible(t){this._isVisible!==t&&(this._isVisible=t,this.emit("change",this))}get enable(){return this._isEnabled}set enable(t){this._isEnabled!==t&&(this._isEnabled=t,this.emit("change",this))}get size(){return this._size}set size(t){this._size!==t&&(this._size=t,this.emit("change",t,this))}snap(t,e){if(this._isEnabled){const i=this._size;e.set(t,Math.round(t/i)*i)}}reset(){this._isVisible=this._isVisibleDefault,this._isEnabled=this._isEnabledDefault,this._size=this._sizeDefault,this.emit("change",this)}serialize(){return[this._isEnabled?1:0,this._isVisible?1:0,this._size]}deserialize(t){this.enable=!!t[0],2 in t?(this.visible=!!t[1],this.size=t[2]):(this.visible=this._isVisibleDefault,this.size=t[1])}}class N_{constructor(){this.distance=NaN,this.result=0,this.threshold=10}reset(t,e){this.distance=NaN,this.result=t,this.threshold=1e-4<e?10/e:10}set(t,e){const i=Math.abs(e-t);if(i<=this.threshold){const t=this.distance;(t!=t||i<t)&&(this.distance=i,this.result=e)}}}const P_={HORIZONTAL:0,VERTICAL:1};class B_{constructor(t,e){this.type=t,this.position=e}serialize(){return[this.type,this.position]}}class z_ extends t.utils.EventEmitter{constructor(t,e){var i,s;super(),this.values=[],this._isVisibleDefault=null!==(i=null==e?void 0:e.visible)&&void 0!==i?i:t.isSnapTargetVisible(),this._isVisible=this._isVisibleDefault,this._isEnabledDefault=null!==(s=null==e?void 0:e.enable)&&void 0!==s?s:t.isSnapTargetEnabled(),this._isEnabled=this._isEnabledDefault}get enable(){return this._isEnabled}set enable(t){this._isEnabled!==t&&(this._isEnabled=t,this.emit("change",this))}get visible(){return this._isVisible}set visible(t){this._isVisible!==t&&(this._isVisible=t,this.emit("change",this))}get size(){return this.values.length}add(t,e){null!=e?this.values.splice(e,0,t):this.values.push(t),this.emit("change",this)}remove(t){const e=this.values;0<=t&&t<e.length&&(e.splice(t,1),this.emit("change",this))}replace(t,e){const i=this.values;if(0<=t&&t<i.length){const s=i[t];return i[t]=e,this.emit("change",this),s}return null}swap(t,e){if(t!==e){const i=this.values,s=i[t];i[t]=i[e],i[e]=s,this.emit("change",this)}}snap(t,e,i,s){if(this._isEnabled){const n=this.values;for(let o=0,r=n.length;o<r;++o){const r=n[o];r.type===P_.VERTICAL?i.set(t,r.position):s.set(e,r.position)}}}reset(){this._isEnabled=this._isEnabledDefault,this._isVisible=this._isVisibleDefault,this.values.length=0,this.emit("change",this)}serialize(){const t=[],e=this.values;for(let i=0,s=e.length;i<s;++i)t.push(e[i].serialize());return[this._isEnabled?1:0,this._isVisible?1:0,t]}deserialize(t){this._isEnabled=!!t[0],this._isVisible=!!t[1];const e=t[2],i=this.values;i.length=0;for(let t=0,s=e.length;t<s;++t){const s=e[t];i.push(new B_(s[0],s[1]))}this.emit("change",this)}}const U_=1e-5,F_={NONE:0,TOP_LEFT:1,TOP_CENTER:2,TOP_RIGHT:3,MIDDLE_LEFT:4,MIDDLE_RIGHT:5,BOTTOM_LEFT:6,BOTTOM_CENTER:7,BOTTOM_RIGHT:8,ROTATION:9};class H_ extends t.utils.EventEmitter{constructor(e,i,s){var n;super(),this._points=[new t.Point,new t.Point,new t.Point,new t.Point,new t.Point],this._normals=[new t.Point,new t.Point],this._lengths=[1,1],this._workScale=new t.Point,this._workSnapResultX=new N_,this._workSnapResultY=new N_,this._workScaleResult={distance:0,scale:new t.Point},this._workTranslate=new t.Point,this._workSnapRectangle=new t.Rectangle,this._workSnap=new t.Point,this.grid=new L_(i,null==s?void 0:s.grid),this.target=new z_(i,null==s?void 0:s.target),this._parent=e,this._isEnabledDefault=null!==(n=null==s?void 0:s.enable)&&void 0!==n?n:i.isSnapEnabled(),this._isEnabled=this._isEnabledDefault}get enable(){return this._isEnabled}set enable(t){this._isEnabled!==t&&(this._isEnabled=t,this.emit("change",this))}prepare(t){t.updateTransform();const e=t.transform.localTransform,i=t.width,s=t.height,n=this._points;n[0].set(0,0),n[1].set(i,0),n[2].set(i,s),n[3].set(0,s),n[4].set(.5*i,.5*s),e.apply(n[0],n[0]),e.apply(n[1],n[1]),e.apply(n[2],n[2]),e.apply(n[3],n[3]),e.apply(n[4],n[4])}prepareForTranslate(t){this._isEnabled&&this.prepare(t)}snap(t,e){const i=t.x,s=t.y,n=this._parent.canvas,o=this._workSnapResultX,r=this._workSnapResultY;if(null!=n){const t=Math.max(n.scale.x,n.scale.y);o.reset(i,t),r.reset(s,t),o.set(i,0),o.set(i,n.width),r.set(s,0),r.set(s,n.height)}else o.reset(i,1),r.reset(s,1);return this.target.snap(i,s,o,r),this.grid.snap(i,o),this.grid.snap(s,r),e.x=Oh(o.distance)?NaN:o.result,e.y=Oh(r.distance)?NaN:r.result,e}toSnapped(t,e){const i=t.x,s=t.y;if(this._isEnabled){this.snap(t,e);const n=e.x,o=e.y;e.set(Oh(n)?i:n,Oh(o)?s:o)}else e.set(i,s);return e}toTranslationSnapped(t,e){const i=t.x,s=t.y;let n=NaN,o=NaN;if(this._isEnabled){const t=this._workTranslate,e=this._points;for(let r=0,a=e.length;r<a;++r){const a=e[r];if(t.set(a.x+i,a.y+s),this.snap(t,t),!Oh(t.x)){const e=t.x-a.x;(Oh(n)||Math.abs(e-i)<Math.abs(n-i))&&(n=e)}if(!Oh(t.y)){const e=t.y-a.y;(Oh(o)||Math.abs(e-s)<Math.abs(o-s))&&(o=e)}}}return e.x=Oh(n)?i:n,e.y=Oh(o)?s:o,e}prepareForRotate(t){}getGridSizeRotation(){return 5}toRadian(t){return t/180*Math.PI}toDegree(t){return t/Math.PI*180}toRotationSnapped(t,e){if(this._isEnabled){const i=this.getGridSizeRotation(),s=t+e,n=Math.round(this.toDegree(s)),o=n%90;return Math.abs(o)<=i?this.toRadian(n-o)-t:90-i<=o?this.toRadian(n+(90-o))-t:o<=-90+i?this.toRadian(n-(90+o))-t:e}return e}calcNormalizedVector(t,e,i){const s=e.x-t.x,n=e.y-t.y,o=Math.sqrt(s*s+n*n);if(U_<o){const t=1/o;i.x=s*t,i.y=n*t}else i.x=1,i.y=0;return o}prepareForScale(t,e){if(this._isEnabled){this.prepare(t);const i=this._points,s=this._normals,n=this._lengths;switch(e){case F_.TOP_LEFT:n[0]=this.calcNormalizedVector(i[1],i[0],s[0]),n[1]=this.calcNormalizedVector(i[3],i[0],s[1]);break;case F_.TOP_CENTER:n[0]=this.calcNormalizedVector(i[3],i[0],s[0]);break;case F_.TOP_RIGHT:n[0]=this.calcNormalizedVector(i[0],i[1],s[0]),n[1]=this.calcNormalizedVector(i[2],i[1],s[1]);break;case F_.MIDDLE_LEFT:n[0]=this.calcNormalizedVector(i[1],i[0],s[0]);break;case F_.NONE:break;case F_.MIDDLE_RIGHT:n[0]=this.calcNormalizedVector(i[0],i[1],s[0]);break;case F_.BOTTOM_LEFT:n[0]=this.calcNormalizedVector(i[2],i[3],s[0]),n[1]=this.calcNormalizedVector(i[0],i[3],s[1]);break;case F_.BOTTOM_CENTER:n[0]=this.calcNormalizedVector(i[0],i[3],s[0]);break;case F_.BOTTOM_RIGHT:n[0]=this.calcNormalizedVector(i[3],i[2],s[0]),n[1]=this.calcNormalizedVector(i[1],i[2],s[1])}}}setScaleSnappedResult(t,e,i,s,n){if(U_<e&&(Oh(n.distance)||t<n.distance)){n.distance=t;const o=1+i/e;s?n.scale.x=o:n.scale.y=o}}calcScaleSnapped1D(t,e,i,s,n,o){const r=this._workScale;t.apply(e,r);const a=r.x,h=r.y;this.snap(r,r);const l=r.x,c=r.y;if(!Oh(l)){const t=Math.abs(i.x);if(U_<t){const t=(l-a)/i.x,r=Math.abs(t),h=(l-e.x)/i.x;this.setScaleSnappedResult(r,s,h,n,o)}}if(!Oh(c)){const t=Math.abs(i.y);if(U_<t){const t=(c-h)/i.y,r=Math.abs(t),a=(c-e.y)/i.y;this.setScaleSnappedResult(r,s,a,n,o)}}}calcScaleSnappedX(t,e,i,s,n){this.calcScaleSnapped1D(t,e,i,s,!0,n)}calcScaleSnappedY(t,e,i,s,n){this.calcScaleSnapped1D(t,e,i,s,!1,n)}calcScaleSnapped2D(t,e,i,s,n){const o=this._workScale;t.apply(e,o);const r=o.x,a=o.y;this.snap(o,o);let h=o.x,l=o.y;if(Oh(h)){if(Oh(l))return;h=r}else Oh(l)&&(l=a);const c=i[0].x*i[1].y-i[1].x*i[0].y;if(U_<Math.abs(c)){const t=h-r,o=l-a,u=Math.abs(t*t+o*o);if(Oh(n.distance)||u<n.distance){n.distance=u;const t=h-e.x,o=l-e.y,r=(+i[1].y*t-i[1].x*o)/c,a=(-i[0].y*t+i[0].x*o)/c;n.scale.set(1+r/s[0],1+a/s[1])}}}calcScaleSnappedXY(t,e,i,s,n,o,r){this.calcScaleSnapped2D(t,e,n,o,r),this.calcScaleSnappedX(t,s,n[0],o[0],r),this.calcScaleSnappedY(t,i,n[1],o[1],r)}toScaleSnapped(t,e,i,s){if(this._isEnabled){const n=this._points,o=this._normals,r=this._lengths,a=this._workScaleResult;switch(a.distance=NaN,a.scale.set(s.x,s.y),e){case F_.TOP_LEFT:this.calcScaleSnappedXY(t,n[0],n[1],n[3],o,r,a);break;case F_.TOP_CENTER:this.calcScaleSnappedY(t,n[0],o[0],r[0],a),this.calcScaleSnappedY(t,n[1],o[0],r[0],a);break;case F_.TOP_RIGHT:this.calcScaleSnappedXY(t,n[1],n[0],n[2],o,r,a);break;case F_.MIDDLE_LEFT:this.calcScaleSnappedX(t,n[0],o[0],r[0],a),this.calcScaleSnappedX(t,n[3],o[0],r[0],a);break;case F_.NONE:break;case F_.MIDDLE_RIGHT:this.calcScaleSnappedX(t,n[1],o[0],r[0],a),this.calcScaleSnappedX(t,n[2],o[0],r[0],a);break;case F_.BOTTOM_LEFT:this.calcScaleSnappedXY(t,n[3],n[2],n[0],o,r,a);break;case F_.BOTTOM_CENTER:this.calcScaleSnappedY(t,n[2],o[0],r[0],a),this.calcScaleSnappedY(t,n[3],o[0],r[0],a);break;case F_.BOTTOM_RIGHT:this.calcScaleSnappedXY(t,n[2],n[3],n[1],o,r,a)}if(!Oh(a.distance)){if(s.copyFrom(a.scale),i)switch(e){case F_.TOP_LEFT:case F_.TOP_RIGHT:case F_.BOTTOM_LEFT:case F_.BOTTOM_RIGHT:s.x=s.y=Math.max(s.x,s.y);break;case F_.TOP_CENTER:case F_.BOTTOM_CENTER:s.x=s.y;break;case F_.MIDDLE_LEFT:case F_.MIDDLE_RIGHT:s.y=s.x}return!0}}return!1}reset(){this.enable=this._isEnabledDefault,this.target.reset(),this.grid.reset()}serialize(){return[this._isEnabled?1:0,this.target.serialize(),this.grid.serialize()]}deserialize(t){this.enable=!!t[0],this.target.deserialize(t[1]),this.grid.deserialize(t[2])}}class G_{constructor(e,i,s,n){this.id=e,this.size=i,this.color=t.utils.hex2string(s),this.height=i+2*n,this.measured=!1,this.ascent=0,this.descent=0}}class V_{constructor(e,i,s,n){this._id=e,this._canvas=document.createElement("canvas"),this._context=null;const o=this.toPadding(i);this._padding=o,this._font=new G_(e,i,s,o),this._unrefCount=0,this._width=1,this._height=1,this._revisionUpdated=0,this._texture=t.Texture.from(this._canvas,{mipmap:t.MIPMAP_MODES.OFF,resolution:n,scaleMode:t.SCALE_MODES.NEAREST});const r=new Map;r.set(D.SPACE,this.newChar(D.SPACE,zs.SPACE_R)),r.set(D.TAB,this.newChar(D.SOFT_TAB,zs.SPACE_R)),r.set(D.DOTS,this.newChar(D.DOTS,zs.LETTER_RNB));for(let t=0,e=D.ASCII.length;t<e;++t){const e=D.ASCII[t];r.set(e,this.newChar(e,zs.LETTER_RNB))}this._characters=r,this._createds=new Map,this._revision=1}toPadding(t){return Math.max(3,Math.ceil(.2*t))}get id(){return this._id}get font(){return this._font}get width(){return this._width}get height(){return this._height}get canvas(){return this._canvas}get characters(){return this._characters}get texture(){return this._texture}newChar(t,e){const i=this.getAdvance(t),s=this._padding,n=Math.ceil(s+i+s),o=this.font.height;return new Bs(e,t,-n,-o,n,o,i)}add(t,e){const i=this._characters,s=this._createds;for(let n=0,o=t.length;n<o;){if(t.charCodeAt(n)<=255){n+=1;continue}let r=n+1;for(;r<o;++r){const e=t.charCodeAt(r);if(!(56320<=e&&e<=57343||65024<=e&&e<=65039))break}const a=t.substring(n,r),h=i.get(a);if(null!=h)h.type&zs.RESERVED||(0===h.ref&&(this._unrefCount-=1),h.ref+=1);else{const t=s.get(a);if(null!=t)t.ref=1,i.set(a,t);else{const t=this.newChar(a,e);i.set(a,t),s.set(a,t)}this._revision+=1}n=r}}remove(t){const e=this._characters;for(let i=0,s=t.length;i<s;){if(t.charCodeAt(i)<=255){i+=1;continue}let n=i+1;for(;n<s;++n){const e=t.charCodeAt(n);if(!(56320<=e&&e<=57343||65024<=e&&e<=65039))break}const o=t.substring(i,n),r=e.get(o);null!=r&&0<r.ref&&!(r.type&zs.RESERVED)&&(r.ref-=1,0===r.ref&&(this._unrefCount+=1)),i=n}}cleanup(){const t=this._characters;t.size>>1<=this._unrefCount&&(t.forEach((e,i)=>{e.ref<=0&&t.delete(i)}),this._revision+=1,this._unrefCount=0)}get(t){return this._characters.get(t)}getAdvance(t){const e=this.getContext();return null!=e?e.measureText(t).width:0}getContext(){let t=this._context;if(null==t){const e=this._canvas;if(null==e)return null;if(t=this._context=e.getContext("2d",{alpha:!0}),null==t)return null}const e=this._font;return t.font!==e.id&&(t.font=e.id,e.id=t.font,t.textAlign="left",t.textBaseline="alphabetic",t.lineWidth=0,t.lineCap="round",t.lineJoin="miter",t.miterLimit=10,t.fillStyle=e.color,t.strokeStyle="#0000ff"),t}update(){if(this.cleanup(),this._revisionUpdated<this._revision){this._revisionUpdated=this._revision;const t=this._canvas;if(null!=t){const e=this._font,i=e.height,s=this._characters,n=this._width=this.toPowerOf2(Math.ceil(Math.sqrt(s.size))*i),o=this._padding;let r=0,a=0;s.forEach(t=>{n<=r+t.width&&(r=0,a+=i),t.x=r,t.y=a,t.origin.x=r+o,r+=t.width});const h=this._height=a+i,l=this._texture.baseTexture,c=l.resolution,u=Math.ceil(n*c),d=Math.ceil(h*c);t.width=u,t.height=d;const p=this.getContext();if(null!=p){Hs.measure(p,e);const t=Math.round(.5*(i-(e.ascent+e.descent))+e.ascent);p.save(),p.scale(c,c),p.clearRect(0,0,n,h),s.forEach(e=>{e.origin.y=e.y+t,p.fillText(e.character,e.origin.x,e.origin.y)}),p.restore()}return l.setRealSize(u,d),!0}}return!1}getRevision(){return this._revision}getRevisionUpdate(){return this._revisionUpdated}get length(){return this._characters.size}destroy(){null!=this._canvas&&(this._canvas=null),this._characters.clear(),this._createds.clear(),this._unrefCount=0}toPowerOf2(t){let e=32;for(;e<t;)e<<=1;return e}}const W_=t=>{t.update()},K_=t=>{t.forEach(W_)},X_=t=>{t.update()},Y_=t=>{t.forEach(X_)};class j_{constructor(t){this._atlases=new Map,this._resolution=t.renderer.resolution,t.renderer.on("prerender",()=>{this.update()})}add(t,e,i,s){const n=this._atlases;let o=n.get(t);null==o&&(o=new Map,n.set(t,o));let r=o.get(i);null==r&&(r=new V_(t,e,i,this._resolution),o.set(i,r)),r.add(s,zs.LETTER)}remove(t,e,i){const s=this._atlases.get(t);if(null!=s){const t=s.get(e);null!=t&&t.remove(i)}}get(t,e){const i=this._atlases.get(t);if(null==i)return null;const s=i.get(e);return null==s?null:s}update(){this._atlases.forEach(K_)}destroy(){const t=this._atlases;t.forEach(Y_),t.clear()}}const $_=t=>{if("object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)){const e=Object.getPrototypeOf(t);return null==e||e===Object.prototype}return!1},q_=(t,e,i,s)=>{let n=0,o=Math.floor(t.length/i)-1;for(;n<=o;){const r=n+(o-n>>1),a=t[r*i+s];if(e<a)o=r-1;else{if(!(a<e))return r;n=r+1}}return Math.max(n,o)},Z_=t=>vt(t)?(t=>{const e=[];for(let i=0,s=t.length;i<s;++i)e[i]=t[i];return e})(t):$_(t)?(t=>{const e={};for(const i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=Z_(t[i]));return e})(t):t,J_=t=>{if(null!=t){if(Et(t))return t;if(wt(t))return String(t);if("name"in t)return t.name;if("label"in t)return t.label;if("id"in t)return t.id}return""},Q_=(t,e)=>{if(null!=t){const i=Z_(t);if(null!=e)for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const s=e[t];if($_(s))if(Object.prototype.hasOwnProperty.call(i,t)){const e=i[t];$_(e)&&Q_(e,s)}else i[t]=Z_(s);else Object.prototype.hasOwnProperty.call(i,t)||(i[t]=s)}return i}return null!=e?Z_(e):{}},tg={TEXT:0,DATA_URL:1,BINARY_STRING:2,ARRAY_BUTTER:3,FILE:4};class eg{constructor(t,e){this._input=null,this._as=t,this._facade=e}open(){const t=this.getOrCreateInput();null!=t?t.click():this.onCancel()}getOrCreateInput(){if("FileReader"in window&&null==this._input){const t=document.createElement("input");this._input=t,t.setAttribute("type","file"),t.setAttribute("style","display:none"),t.addEventListener("change",e=>{this.onInputChange(t),t.value="",e.stopImmediatePropagation(),e.preventDefault()}),document.body.appendChild(t)}return this._input}onInputChange(t){const e=t.files;if(null!=e&&0<e.length){const t=e[0];if(this._as===tg.FILE)this.onOpen(t,t);else{const e=new FileReader;switch(e.onload=e=>{if(null!=e.target){const i=e.target;this.onOpen(i.result,t)}},e.onabort=t=>{this.onAboart(t)},this._as){case tg.TEXT:e.readAsText(t);break;case tg.DATA_URL:e.readAsDataURL(t);break;case tg.BINARY_STRING:e.readAsBinaryString(t);break;case tg.ARRAY_BUTTER:e.readAsArrayBuffer(t);break;default:e.readAsText(t)}}}else this.onCancel()}onOpen(t,e){const i=this._facade;i.emit("open",t,e,i)}onAboart(t){const e=this._facade;e.emit("abort",t,e)}onCancel(){const t=this._facade;t.emit("cancel",t)}}class ig{static fromRgb(t){const e=(16711680&t)>>16,i=(65280&t)>>8,s=255&t|0,n=Math.max(e,i,s),o=n-Math.min(e,i,s);let r=0;return 0<o&&(e===n?r=60*(i-s)/o:i===n?r=60*(s-e)/o+120:s===n&&(r=60*(e-i)/o+240),r<0&&(r+=360)),[r,o/n*255,n]}static toRgb(t,e,i){const s=i-e/255*i,n=i-s;let o=0,r=0,a=0;return t<=60?(o=i,r=t/60*n+s,a=s):t<=120?(o=(120-t)/60*n+s,r=i,a=s):t<=180?(o=s,r=i,a=(t-120)/60*n+s):t<=240?(o=s,r=(240-t)/60*n+s,a=i):t<=300?(o=(t-240)/60*n+s,r=s,a=i):(o=i,r=s,a=(360-t)/60*n+s),o=Math.max(0,Math.min(255,o)),r=Math.max(0,Math.min(255,r)),a=Math.max(0,Math.min(255,a)),o<<16|r<<8|a}}class sg extends hr{onElementAttached(t,e,i){t.addEventListener("keydown",this._onInputKeyDownBound),super.onElementAttached(t,e,i)}onElementDetached(t,e,i){t.removeEventListener("keydown",this._onInputKeyDownBound),super.onElementDetached(t,e,i)}onInputKeyDown(t){$n.isOkKey(t)&&this._operation.onEnter()}}class ng{static create(t){const e=this._mapping;return t in e?`${t} ${++e[t]}`:(e[t]=1,t+" 1")}}ng._mapping={};class og{constructor(t){var e;this._duration=null!==(e=null==t?void 0:t.duration)&&void 0!==e?e:300,this._current=null,this._lastUpdate=0,this._updateId=null}show(t,e){const i=this._updateId;null!=i&&clearTimeout(i);const s=this._current;if(t!==s){const i=this._duration,s=this._lastUpdate,n=Date.now(),o=s+i-n;!0===e||o<=0?this.update(n,t):this._updateId=window.setTimeout(()=>{this.update(Date.now(),t)},o)}}update(t,e){const i=this._current;i!==e&&(this._lastUpdate=t,null!=i&&i.hide(),this._current=e,null!=e&&e.show())}hide(){this.show(null)}}
|
|
9
|
+
!function(t){"use strict";const e={},i={},s={CIRCLE:0,RECTANGLE:1,RECTANGLE_ROUNDED:2,TRIANGLE:3,TRIANGLE_ROUNDED:4,LINE:5,IMAGE:6,IMAGE_SDF:7,GROUP:8,BAR:9,LABEL:10,NULL:11,GROUP_SHADOWED:12,LINE_OF_CIRCLES:13,LINE_OF_RECTANGLES:14,LINE_OF_RECTANGLE_ROUNDEDS:15,LINE_OF_TRIANGLES:16,LINE_OF_TRIANGLE_ROUNDEDS:17,EMBEDDED:18,EMBEDDED_LAYER:19,BUTTON:20,RECTANGLE_PIVOTED:21,CONNECTOR_LINE:22,CONNECTOR_ELBOW:23,SEMICIRCLE:24,EMBEDDED_ACCEPTOR_EDGE:25,EXTENSION:1e3},n={};class o{constructor(t,e,i,s,n,o){this._builders=o,this._vertexOffset=e,this._indexOffset=i,this._vertexCount=s,this._indexCount=n}init(t){t.uploaded=this;const e=this._builders;for(let t=0,i=e.length;t<i;++t)e[t].init();return this.update(t),this}reinit(t,e,i,s){const n=this._builders;let o=i,r=s;for(let i=0,s=n.length;i<s;++i){const s=n[i];if(!s.reinit(t,e,o,r))return!1;o+=s.vertexCount,r+=s.indexCount}return this._vertexCount=o-i,this._indexCount=r-s,this.update(e),!0}update(t){const e=this._builders;for(let i=0,s=e.length;i<s;++i)e[i].update(t);return this}isCompatible(t){const e=this._builders;for(let i=0,s=e.length;i<s;++i)if(!e[i].isCompatible(t))return!1;return!0}getVertexOffset(){return this._vertexOffset}getVertexCount(){return this._vertexCount}getIndexOffset(){return this._indexOffset}getIndexCount(){return this._indexCount}buildUnit(t){const e=this._builders;for(let i=0,s=e.length;i<s;++i)e[i].buildUnit(t)}}const r={NONE:0,NON_EXPANDING_WIDTH:2,NON_SHRINKING_WIDTH:4,NON_SCALING_DOT_AND_DASH:8,NON_SCALING:14,NON_SCALING_MASK:14,DOTTED:16,DOTTED_DENSELY:32,DOTTED_LOOSELY:64,DOTTED_MASK:112,DASHED:128,DASHED_DENSELY:256,DASHED_LOOSELY:512,DASHED_MASK:896},a=t=>t&r.DOTTED_MASK?t&r.DOTTED?1:t&r.DOTTED_DENSELY?2:3:t&r.DASHED_MASK?t&r.DASHED?4:t&r.DASHED_DENSELY?5:6:0,h=t=>{const e=t&r.NON_EXPANDING_WIDTH?1:0,i=t&r.NON_SHRINKING_WIDTH?2:0;return t&(r.DOTTED_MASK||r.DASHED_MASK)?e|i|(t&r.NON_SCALING_DOT_AND_DASH?4:0):e|i},l=(t,e,i,s,n)=>(n[0]=i-t,n[1]=s-e,n),c=(t,e)=>{if(1e-5<e){const i=1/e,s=t[0]*i,n=t[1]*i;t[0]=-n,t[1]=+s}else t[0]=0,t[1]=1;return t},u=(t,e)=>Math.round(511.5*(1+t[0]))+(Math.round(511.5*(1+e[0]))<<10)+((0<=t[1]?1:0)+(0<=e[1]?2:0)<<20),d=(t,e,i,s)=>t+(e<<6)+(i<<12)+(s<<18),p=(t,e)=>Math.round(1023*t)+(Math.round(1023*e)<<10),_=[0,1],g=[0,1],f=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+2,t[++s]=e+1,t[++s]=e+1,t[++s]=e+2,t[++s]=e+3},m=(t,e,i,s,n,o,r,p)=>{const f=p.a,m=p.b,v=p.c,T=p.d,w=p.tx,E=p.ty,y=s[0],x=s[1],C=f*y+v*x+w,D=m*y+T*x+E,S=s[2],b=s[3];let I=f*S+v*b+w,O=m*S+T*b+E,A=I-C,R=O-D;const M=Math.sqrt(A*A+R*R);let k=M;if(0<=n&&1e-5<M){const t=n/M;A*=t,R*=t,I=C+A,O=D+R,k=n}const L=_,N=g;l(C-A,D-R,C,D,L),l(C,D,I,O,N),c(L,k),c(N,k);const P=u(L,N),B=h(r),z=a(r),U=d(3,B,z,0),F=d(5,B,z,0);let H=(i<<1)-1,G=6*i-1;t[++H]=C,t[++H]=D,t[++H]=C,t[++H]=D,e[++G]=o,e[++G]=U,e[++G]=P,e[++G]=0,e[++G]=k,e[++G]=0,e[++G]=o,e[++G]=F,e[++G]=P,e[++G]=0,e[++G]=k,e[++G]=0,t[++H]=I,t[++H]=O,t[++H]=I,t[++H]=O,e[++G]=o,e[++G]=U,e[++G]=P,e[++G]=k,e[++G]=k,e[++G]=0,e[++G]=o,e[++G]=F,e[++G]=P,e[++G]=k,e[++G]=k,e[++G]=0},v=(t,e,i)=>{let s=(e<<1)-1;t[++s]=i.x0,t[++s]=i.y0,t[++s]=i.x3,t[++s]=i.y3,t[++s]=i.x1,t[++s]=i.y1,t[++s]=i.x2,t[++s]=i.y2},T={NORMAL:0,BOLD:1},w={NORMAL:0,ITALIC:1},E={LEFT:0,CENTER:1,RIGHT:2,OUTSIDE_LEFT:3,OUTSIDE_RIGHT:4},y={TOP:0,MIDDLE:1,BOTTOM:2,OUTSIDE_TOP:3,OUTSIDE_BOTTOM:4},x={LEFT_TO_RIGHT:0,TOP_TO_BOTTOM:1,BOTTOM_TO_TOP:2,RIGHT_TO_LEFT:3},C=(t,e,i,s)=>{const n=i-t,o=s-e;return Math.sqrt(n*n+o*o)},D={ASCII:"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",SPACE:" ",TAB:"\t",SOFT_TAB:" ",DOTS:"...",NEW_LINE:"\n"},S=1e-5,b=new t.Point,I=t=>{const e=t.text.plength;return(e>>3)+(0<(7&e)?1:0)<<3},O=(t,e,i,s)=>{let n=3*i-1;const o=3*(i+s)-1;let r=e;for(;n<o;)t[++n]=r,t[++n]=r+1,t[++n]=r+3,t[++n]=r+1,t[++n]=r+2,t[++n]=r+3,r+=4},A=(t,e,i,s,n,o,a,l,c)=>{let u=6*e-1;const p=6*(e+i)-1,_=h(r.NONE),g=d(2,_,1,1);if(null!=s){const e=s.font.size/(n*(l+c)*.5),i=a===T.NORMAL?0:.05;for(;u<p;)t[++u]=o,t[++u]=g,t[++u]=e,t[++u]=0,t[++u]=i,t[++u]=0}else for(;u<p;)t[++u]=0,t[++u]=g,t[++u]=0,t[++u]=0,t[++u]=0,t[++u]=0},R=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f,m,v,T,w)=>{switch(t){case E.LEFT:switch(e){case y.TOP:w.x=h+f*(i+n)+v*(s+o),w.y=l+m*(i+n)+T*(s+o);break;case y.MIDDLE:w.x=.5*(h+_)+f*(i+n)+v*(s-.5*a),w.y=.5*(l+g)+m*(i+n)+T*(s-.5*a);break;case y.BOTTOM:w.x=_+f*(i+n)+v*(s-o-a),w.y=g+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=h+f*(i+n)+v*(s-o-a),w.y=l+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=_+f*(i+n)+v*(s+o),w.y=g+m*(i+n)+T*(s+o)}break;case E.CENTER:switch(e){case y.TOP:w.x=.5*(h+c)+f*(i-.5*r)+v*(s+o),w.y=.5*(l+u)+m*(i-.5*r)+T*(s+o);break;case y.MIDDLE:w.x=.5*(h+d)+f*(i-.5*r)+v*(s-.5*a),w.y=.5*(l+p)+m*(i-.5*r)+T*(s-.5*a);break;case y.BOTTOM:w.x=.5*(_+d)+f*(i-.5*r)+v*(s-o-a),w.y=.5*(g+p)+m*(i-.5*r)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=.5*(h+c)+f*(i-.5*r)+v*(s-o-a),w.y=.5*(l+u)+m*(i-.5*r)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=.5*(_+d)+f*(i-.5*r)+v*(s+o),w.y=.5*(g+p)+m*(i-.5*r)+T*(s+o)}break;case E.RIGHT:switch(e){case y.TOP:w.x=c+f*(i-n-r)+v*(s+o),w.y=u+m*(i-n-r)+T*(s+o);break;case y.MIDDLE:w.x=.5*(c+d)+f*(i-n-r)+v*(s-.5*a),w.y=.5*(u+p)+m*(i-n-r)+T*(s-.5*a);break;case y.BOTTOM:w.x=d+f*(i-n-r)+v*(s-o-a),w.y=p+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=c+f*(i-n-r)+v*(s-o-a),w.y=u+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=d+f*(i-n-r)+v*(s+o),w.y=p+m*(i-n-r)+T*(s+o)}break;case E.OUTSIDE_LEFT:switch(e){case y.TOP:w.x=h+f*(i-n-r)+v*(s+o),w.y=l+m*(i-n-r)+T*(s+o);break;case y.MIDDLE:w.x=.5*(h+_)+f*(i-n-r)+v*(s-.5*a),w.y=.5*(l+g)+m*(i-n-r)+T*(s-.5*a);break;case y.BOTTOM:w.x=_+f*(i-n-r)+v*(s-o-a),w.y=g+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=h+f*(i-n-r)+v*(s-o-a),w.y=l+m*(i-n-r)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=_+f*(i-n-r)+v*(s+o),w.y=g+m*(i-n-r)+T*(s+o)}break;case E.OUTSIDE_RIGHT:switch(e){case y.TOP:w.x=c+f*(i+n)+v*(s+o),w.y=u+m*(i+n)+T*(s+o);break;case y.MIDDLE:w.x=.5*(c+d)+f*(i+n)+v*(s-.5*a),w.y=.5*(u+p)+m*(i+n)+T*(s-.5*a);break;case y.BOTTOM:w.x=d+f*(i+n)+v*(s-o-a),w.y=p+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_TOP:w.x=c+f*(i+n)+v*(s-o-a),w.y=u+m*(i+n)+T*(s-o-a);break;case y.OUTSIDE_BOTTOM:w.x=d+f*(i+n)+v*(s+o),w.y=p+m*(i+n)+T*(s+o)}}},M=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f,m,v,T,I,O,A,M,P,B)=>{const z=.5*r,F=.5*a,H=B.a,G=B.b,V=B.c,W=B.d,K=B.tx,X=B.ty,Y=n-z,j=o-F,$=n+z,q=o-F,Z=n+z,J=o+F,Q=H*Y+V*j+K,tt=G*Y+W*j+X,et=H*$+V*q+K,it=G*$+W*q+X,st=H*Z+V*J+K,nt=G*Z+W*J+X,ot=Q+(st-et),rt=tt+(nt-it),at=C(Q,tt,et,it);let ht=C(0,0,H,G),lt=1,ct=0;if(S<ht){const t=1/ht;lt=H*t,ct=G*t}const ut=C(Q,tt,ot,rt);let dt=C(0,0,V,W),pt=0,_t=1;if(S<ht){const t=1/dt;pt=V*t,_t=W*t}const gt=b;switch(v){case x.LEFT_TO_RIGHT:break;case x.TOP_TO_BOTTOM:gt.set(pt,_t),pt=-lt,_t=-ct,lt=gt.x,ct=gt.y,gt.x=dt,dt=ht,ht=gt.x;break;case x.BOTTOM_TO_TOP:gt.set(pt,_t),pt=lt,_t=ct,lt=-gt.x,ct=-gt.y,gt.x=dt,dt=ht,ht=gt.x;break;case x.RIGHT_TO_LEFT:lt=-lt,ct=-ct,pt=-pt,_t=-_t}let ft=0,mt=0,vt=0,Tt=l*dt,wt=Math.max(0,l+m)*dt,Et=0,yt=1;const xt=h.characters;let Ct=0;for(let t=0,e=c.length;t<e;++t){const e=c[t];if(e!==D.NEW_LINE){0<Ct&&(Et+=Math.max(0,Ct+f));const t=xt.get(e);t?(Ct=t.advance,vt=t.height):Ct=0}else Et+=Ct,Ct=0,ft=Math.max(ft,Et),Et=0,mt+=wt,yt+=1}if(Et+=Ct,ft=Math.max(ft,Et),mt+=Tt,Et=0,A&&k(d,p)){let t=0,e=0;switch(v){case x.LEFT_TO_RIGHT:case x.RIGHT_TO_LEFT:t=Math.max(0,at-2*T),e=Math.max(0,ut-2*I);break;case x.TOP_TO_BOTTOM:case x.BOTTOM_TO_TOP:t=Math.max(0,ut-2*I),e=Math.max(0,at-2*T)}const i=ft*ht*(l/h.font.size),s=mt,n=Math.min(1,Math.min(t/i,e/s));l*=n,Tt*=n,wt*=n,mt*=n}const Dt=l/h.font.size,St=ht*Dt;ft*=St,vt*=dt*Dt;let bt=0,It=0,Ot=ft;switch(v){case x.LEFT_TO_RIGHT:R(d,p,_,g,T,I,ft,mt,Q,tt,et,it,st,nt,ot,rt,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=at-2*T);break;case x.TOP_TO_BOTTOM:R((t=>{switch(t){case y.TOP:return E.LEFT;case y.MIDDLE:return E.CENTER;case y.BOTTOM:return E.RIGHT;case y.OUTSIDE_TOP:return E.OUTSIDE_LEFT;case y.OUTSIDE_BOTTOM:return E.OUTSIDE_RIGHT}})(p),(t=>{switch(t){case E.LEFT:return y.BOTTOM;case E.CENTER:return y.MIDDLE;case E.RIGHT:return y.TOP;case E.OUTSIDE_LEFT:return y.OUTSIDE_BOTTOM;case E.OUTSIDE_RIGHT:return y.OUTSIDE_TOP}})(d),g,_,I,T,ft,mt,et,it,st,nt,ot,rt,Q,tt,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=ut-2*I);break;case x.BOTTOM_TO_TOP:R((t=>{switch(t){case y.TOP:return E.RIGHT;case y.MIDDLE:return E.CENTER;case y.BOTTOM:return E.LEFT;case y.OUTSIDE_TOP:return E.OUTSIDE_RIGHT;case y.OUTSIDE_BOTTOM:return E.OUTSIDE_LEFT}})(p),(t=>{switch(t){case E.LEFT:return y.TOP;case E.CENTER:return y.MIDDLE;case E.RIGHT:return y.BOTTOM;case E.OUTSIDE_LEFT:return y.OUTSIDE_TOP;case E.OUTSIDE_RIGHT:return y.OUTSIDE_BOTTOM}})(d),g,_,I,T,ft,mt,ot,rt,Q,tt,et,it,st,nt,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=ut-2*I);break;case x.RIGHT_TO_LEFT:R((t=>{switch(t){case E.LEFT:return E.RIGHT;case E.CENTER:return E.CENTER;case E.RIGHT:return E.LEFT;case E.OUTSIDE_LEFT:return E.OUTSIDE_RIGHT;case E.OUTSIDE_RIGHT:return E.OUTSIDE_LEFT}})(d),(t=>{switch(t){case y.TOP:return y.BOTTOM;case y.MIDDLE:return y.MIDDLE;case y.BOTTOM:return y.TOP;case y.OUTSIDE_TOP:return y.OUTSIDE_BOTTOM;case y.OUTSIDE_BOTTOM:return y.OUTSIDE_TOP}})(p),_,g,T,I,ft,mt,st,nt,ot,rt,Q,tt,et,it,lt,ct,pt,_t,gt),bt=gt.x,It=gt.y,O&&k(d,p)&&(Ot=at-2*T)}if(Ot<ft){const t=.5*(ft-Ot);M[0]=bt+lt*t,M[1]=It+ct*t,M[2]=lt,M[3]=ct,M[4]=pt,M[5]=_t,M[6]=Ot,M[7]=mt,M[8]=ht,M[9]=dt}else M[0]=bt,M[1]=It,M[2]=lt,M[3]=ct,M[4]=pt,M[5]=_t,M[6]=ft,M[7]=mt,M[8]=ht,M[9]=dt;const At=P.x0,Rt=P.x1,Mt=P.x3,kt=P.y0,Lt=P.y1,Nt=P.y3,Pt=Rt-At,Bt=Lt-kt,zt=Mt-At,Ut=Nt-kt,Ft=wt*pt,Ht=wt*_t,Gt=St*lt,Vt=St*ct,Wt=.5*(vt-Tt),Kt=Wt*pt,Xt=Wt*_t,Yt=u===w.NORMAL?0:.25*l;let jt=bt-Kt+Yt*Gt,$t=It-Xt+Yt*Vt,qt=bt+Kt+Tt*pt,Zt=It+Xt+Tt*_t,Jt=jt,Qt=$t,te=qt,ee=Zt;Et=0,Ct=0,yt=0;let ie=2*i;for(let i=0,s=c.length;i<s;i+=1,ie+=8){const n=c[i];if(n!==D.NEW_LINE){const o=Et;0<Ct&&(Et+=Math.max(0,Ct+f));const r=Et*Gt,a=Et*Vt;Jt=jt+r,Qt=$t+a,te=qt+r,ee=Zt+a;const l=xt.get(n);if(yt+=1,l){const n=l.advance;if(Ot<(Et+n)*St){const r=xt.get(D.DOTS);if(r){if(1<yt&&Ot<(Et+r.advance)*St){Et=o,ie-=8,yt-=1;const t=Et*Gt,e=Et*Vt;Jt=jt+t,Qt=$t+e,te=qt+t,ee=Zt+e}for(Ct=r.advance,N(t,e,ie,r,h,Gt,Vt,Jt,Qt,te,ee,Pt,Bt,zt,Ut,At,kt),ie+=8;;ie+=8){if(!(i+1<s&&c[i+1]!==D.NEW_LINE)){ie-=8;break}L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt),yt+=1,i+=1}}else Ct=n,L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt)}else Ct=n,N(t,e,ie,l,h,Gt,Vt,Jt,Qt,te,ee,Pt,Bt,zt,Ut,At,kt)}else Ct=0,L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt)}else Et+=Ct,Ct=0,jt+=Ft,$t+=Ht,qt+=Ft,Zt+=Ht,Jt=jt,Qt=$t,te=qt,ee=Zt,L(t,e,ie,Jt,Qt,te,ee,At,kt,Mt,Nt),U(t,lt,ct,yt,ie,ft-Et*St,v,d,p),Et=0,yt=0}Et+=Ct,U(t,lt,ct,yt,ie,ft-Et*St,v,d,p);for(const n=2*(i+s);ie<n;ie+=2)t[ie+0]=bt,t[ie+1]=It,e[ie+0]=At,e[ie+1]=kt},k=(t,e)=>{switch(t){case E.LEFT:case E.CENTER:case E.RIGHT:switch(e){case y.TOP:case y.MIDDLE:case y.BOTTOM:return!0}}return!1},L=(t,e,i,s,n,o,r,a,h,l,c)=>{t[i+0]=s,t[i+1]=n,t[i+2]=s,t[i+3]=n,t[i+4]=o,t[i+5]=r,t[i+6]=o,t[i+7]=r,e[i+0]=a,e[i+1]=h,e[i+2]=a,e[i+3]=h,e[i+4]=l,e[i+5]=c,e[i+6]=l,e[i+7]=c},N=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f)=>{const m=s.x-s.origin.x,v=s.width,T=m*o,w=m*r,E=(m+v)*o,y=(m+v)*r;t[i+0]=a+T,t[i+1]=h+w,t[i+2]=a+E,t[i+3]=h+y,t[i+4]=l+E,t[i+5]=c+y,t[i+6]=l+T,t[i+7]=c+w;const x=s.x/n.width,C=s.y/n.height,D=(s.x+s.width)/n.width,S=(s.y+s.height)/n.height,b=u*x,I=d*x,O=u*D,A=d*D,R=p*C,M=_*C,k=p*S,L=_*S;e[i+0]=g+b+R,e[i+1]=f+I+M,e[i+2]=g+O+R,e[i+3]=f+A+M,e[i+4]=g+O+k,e[i+5]=f+A+L,e[i+6]=g+b+k,e[i+7]=f+I+L},P=(t,e,i,s,n)=>{let o=e-8*i-1;for(let e=0;e<i;++e)t[++o]+=s,t[++o]+=n,t[++o]+=s,t[++o]+=n,t[++o]+=s,t[++o]+=n,t[++o]+=s,t[++o]+=n},B=(t,e,i,s,n,o)=>{P(t,e,i,(s*=.5)*n,s*o)},z=(t,e,i,s,n,o)=>{P(t,e,i,s*n,s*o)},U=(t,e,i,s,n,o,r,a,h)=>{if(S<o)switch(r){case x.LEFT_TO_RIGHT:switch(a){case E.OUTSIDE_RIGHT:case E.LEFT:break;case E.CENTER:B(t,n,s,o,e,i);break;case E.OUTSIDE_LEFT:case E.RIGHT:z(t,n,s,o,e,i)}break;case x.TOP_TO_BOTTOM:switch(h){case y.OUTSIDE_BOTTOM:case y.TOP:break;case y.MIDDLE:B(t,n,s,o,e,i);break;case y.OUTSIDE_TOP:case y.BOTTOM:z(t,n,s,o,e,i)}break;case x.BOTTOM_TO_TOP:switch(h){case y.OUTSIDE_BOTTOM:case y.TOP:z(t,n,s,o,e,i);break;case y.MIDDLE:B(t,n,s,o,e,i)}break;case x.RIGHT_TO_LEFT:switch(a){case E.OUTSIDE_RIGHT:case E.LEFT:z(t,n,s,o,e,i);break;case E.CENTER:B(t,n,s,o,e,i)}}},F={NONE:0,CLOSED:1,NON_EXPANDING_WIDTH:2,NON_SHRINKING_WIDTH:4,NON_SCALING_DOT_AND_DASH:8,NON_SCALING_MASK:14,DOTTED:16,DOTTED_DENSELY:32,DOTTED_LOOSELY:64,DOTTED_MASK:112,DASHED:128,DASHED_DENSELY:256,DASHED_LOOSELY:512,DASHED_MASK:896,CURVE:1024,CURVE_SPLINE:1024,CURVE_BEZIER_QUADRATIC:2048,FORMATTER_SHIFT:10,FORMATTER_MASK:1047552,FORMATTER_EXTENSION_LOWEST:512,FORMATTER_EXTENSION_HIGHEST:1023,FORMATTER_CURVE:1,FORMATTER_CURVE_SPLINE:1,FORMATTER_CURVE_BEZIER_QUADRATIC:2},H={NONE:0,VERTEX:1,STEP:2,COLOR:4,UV:8,INDEX:16,VERTEX_AND_STEP:3,VERTEX_STEP_AND_UV:11,ALL:31},G=(t,e,i,s,n,o,r)=>{const a=p(Math.max(0,Math.min(1,e)),Math.max(0,Math.min(1,s)));let h=3*n-1;const l=3*(n+o)-1;for(;h<l;)r[++h]=t,r[++h]=i,r[++h]=a},V={NONE:0,TOP:1,RIGHT:2,BOTTOM:4,LEFT:8,TOP_OR_LEFT:9,TOP_OR_RIGHT:3,BOTTOM_OR_LEFT:12,BOTTOM_OR_RIGHT:6,ALL:15};class W{constructor(t,e,i,s,n){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=s,this.indexCount=n,this.inited=H.NONE,this.sizeX=0,this.sizeY=0,this.transformLocalId=-1,this.strokeAlign=0,this.strokeWidth=0,this.strokeSide=V.NONE,this.strokeStyle=r.NONE,this.colorFill=0,this.alphaFill=0,this.colorStroke=0,this.alphaStroke=0,this.texture=null,this.textureTransformId=-1}reinit(t,e,i,s){return this.buffer===t&&this.vertexOffset===i&&this.indexOffset===s||!!t.check(i,s,this.vertexCount,this.indexCount)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.init(),!0)}isCompatible(t){return!0}updateColor(t,e){const i=e.fill,s=i.color,n=e.visible&&i.enable?i.alpha:0,o=e.stroke,r=o.color,a=e.visible&&o.enable&&0<o.width?o.alpha:0;(!(this.inited&H.COLOR)||s!==this.colorFill||n!==this.alphaFill||r!==this.colorStroke||a!==this.alphaStroke)&&(this.inited|=H.COLOR,this.colorFill=s,this.alphaFill=n,this.colorStroke=r,this.alphaStroke=a,t.updateColors(),G(s,n,r,a,this.vertexOffset,this.vertexCount,t.colors))}buildUnit(e){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;if(s!==e.baseTexture){e.baseTexture=s;const t=this.indexOffset;e.push(i,t)}}}const K=t=>(t.updateTransform(),t.transform.getLocalId()),X=e=>e.texture||t.Texture.WHITE,Y=t=>{const e=t;return null==e._uvs&&t.updateUvs(),e._updateID},j=t=>t._uvs;class ${static setDefaultThemeClass(t){this.DEFAULT_THEME_CLASS=t}static getDefaultThemeClass(){return this.DEFAULT_THEME_CLASS}static getInstance(){if(null==this.INSTANCE){const t=this.getDefaultThemeClass();if(null==t)throw new Error("No default theme class found");this.INSTANCE=new t}return this.INSTANCE}static setInstance(t){const e=this.INSTANCE;return this.INSTANCE=t,e}static get(t){return this.getInstance().get(t)}static set(t,e){this.getInstance().set(t,e)}static getClass(t){return this.getInstance().getClass(t)}static setClass(t,e){this.getInstance().setClass(t,e)}static getAtlas(){return this.getInstance().getAtlas()}}$.DEFAULT_THEME_CLASS=null,$.INSTANCE=null;class q{static get THEME(){const t=this._THEME;if(null!=t)return t;const e=$.getInstance().get("EShape");return this._THEME=e,e}static get FILL_COLOR(){return this.THEME.getFillColor()}static get FILL_ALPHA(){return this.THEME.getFillAlpha()}static get STROKE_COLOR(){return this.THEME.getStrokeColor()}static get STROKE_ALPHA(){return this.THEME.getStrokeAlpha()}static get STROKE_WIDTH(){return this.THEME.getStrokeWidth()}static get STROKE_ALIGN(){return this.THEME.getStrokeAlign()}static get STROKE_SIDE(){return this.THEME.getStrokeSide()}static get STROKE_STYLE(){return this.THEME.getStrokeStyle()}static get TEXT_VALUE(){return this.THEME.getTextValue()}static get TEXT_COLOR(){return this.THEME.getTextColor()}static get TEXT_ALPHA(){return this.THEME.getTextAlpha()}static get TEXT_FAMILY(){return this.THEME.getTextFamily()}static get TEXT_SIZE(){return this.THEME.getTextSize()}static get RADIUS(){return this.THEME.getRadius()}static get SIZE_X(){return this.THEME.getSizeX()}static get SIZE_Y(){return this.THEME.getSizeY()}static get HIGHLIGHT_COLOR(){return this.THEME.getHighlightColor()}static get CURVE_SEGMENT_COUNT(){return this.THEME.getCurveSegmentCount()}}const Z={NONE:0,CIRCLE:1,TRIANGLE:2,RECTANGLE:3};class J{constructor(t,e,i,s){this._parent=t,this._enable=e,this._color=i,this._alpha=s}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.enable,t.color,t.alpha)}set(t,e,i){let s=!1;void 0!==t&&this._enable!==t&&(this._enable=t,s=!0),void 0!==e&&this._color!==e&&(this._color=e,s=!0),void 0!==i&&this._alpha!==i&&(this._alpha=i,s=!0),s&&this._parent.updateUploaded()}clone(){return new J(this._parent,this._enable,this._color,this._alpha)}toObject(){return{enable:this._enable,color:this._color,alpha:this._alpha}}serialize(t){const e=`[${this._enable?1:0},${this._color},${this._alpha}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getFill(t);if(null!=s)this.set(!!s[0],s[1],s[2]);else{const s=JSON.parse(i[t]);e.setFill(t,s),this.set(!!s[0],s[1],s[2])}}}}class Q{lock(){return this}unlock(){return this}get type(){return Z.NONE}set type(t){}get size(){let e=this._size;return null==e&&(e=new t.Point,this._size=e),e}get transform(){let e=this._transform;return null==e&&(e=new t.Matrix,this._transform=e),e}get fill(){let t=this._fill;return null==t&&(t=new J(this,!0,q.FILL_COLOR,1),this._fill=t),t}updateUploaded(){}copy(t){return this}set(t,e,i){return this}serialize(t){return-1}deserialize(t,e){}}class tt{constructor(){this._marker=new Q}lock(){return this}unlock(){return this}get head(){return this._marker}get tail(){return this._marker}copy(t){return this}serialize(t){return-1}deserialize(t,e){}static getInstance(){let t=this.INSTANCE;return null==t&&(t=new tt,this.INSTANCE=t),t}}const et={TOP:0,LEFT:1,RIGHT:2,BOTTOM:3};class it{constructor(t){this._parent=t,this._id=0,this._values=[0,0,0,0],this._segments=[],this._style=F.NONE,this._size=-1,this._position=et.TOP,this._updatedSize=NaN,this._updatedParentSizeX=NaN,this._updatedParentSizeY=NaN,this._updatedPosition=NaN}getComputedSize(t,e,i,s){if(0<=t)return t;switch(e){case et.TOP:case et.BOTTOM:return Math.abs(s);case et.RIGHT:case et.LEFT:return Math.abs(i)}return 0}onSizeChange(){this.update()}update(){const t=this._parent.size,e=t.x,i=t.y,s=this._position,n=this._size;if(this._updatedSize!==n||this._updatedParentSizeX!==e||this._updatedParentSizeY!==i||this._updatedPosition!==s){this._id+=1,this._updatedSize=n,this._updatedParentSizeX=e,this._updatedParentSizeY=i,this._updatedPosition=s;const t=.5*e,o=.5*i,r=this.getComputedSize(n,s,e,i),a=this._values;switch(s){case et.TOP:a[0]=0,a[1]=-o,a[2]=0,a[3]=-o+r;break;case et.RIGHT:a[0]=t,a[1]=0,a[2]=t-r,a[3]=0;break;case et.BOTTOM:a[0]=0,a[1]=o,a[2]=0,a[3]=o-r;break;case et.LEFT:a[0]=-t,a[1]=0,a[2]=-t+r,a[3]=0}}}get length(){return 2}get plength(){return 2}get id(){return this.update(),this._id}get values(){return this.update(),this._values}set values(t){}get segments(){return this._segments}set segments(t){}get size(){return this._size}set size(t){this.moveTo(void 0,t,void 0)}get position(){return this._position}set position(t){this.moveTo(t,void 0,void 0)}get style(){return this._style}set style(t){this.moveTo(void 0,void 0,t)}get marker(){let t=this._marker;return null==t&&(t=tt.getInstance(),this._marker=t),t}getMarker(){}get formatter(){return null}set formatter(t){}get formatted(){return this}copy(t){return t instanceof it?this.moveTo(t.position,t.size,t.style):this.moveTo(void 0,void 0,t.style)}set(t,e,i){let s,n;if(null!=t){const e=t[0];if(0===e){const e=t[1];s=e<=0?et.TOP:et.BOTTOM,n=Math.abs(t[3]-e)}else s=e<=0?et.LEFT:et.RIGHT,n=Math.abs(t[2]-e)}return this.moveTo(s,n,i)}moveTo(t,e,i){let s=!1;return null!=i&&this._style!==i&&(this._style=i,s=!0),null!=t&&this._position!==t&&(this._position=t,s=!0),null!=e&&this._size!==e&&(this._size=e,s=!0),s&&this._parent.updateUploaded(),this}clone(t){return new it(t).copy(this)}toPoints(e){const i=[],s=this.values;for(let n=0,o=s.length;n<o;n+=2){const o=new t.Point(s[n+0],s[n+1]);i.push(e.apply(o,o))}return i}serialize(t){return t.addResource(`[${this._position},${this._size},${this._style}]`)}deserialize(t,e){if(0<=t&&t<e.resources.length){const i=e.resources[t],s=JSON.parse(i);this.moveTo(s[0],s[1],s[2])}}calcHitPointAbs(t,e,i,s,n,o,r,a){if(2<=this.length){const i=this._values;if(r(t,e,i[0],i[1],i[2],i[3],0,n,a))return!0}return!1}}const st={NONE:0,LINE:1,MARKER_TAIL:2,MARKER_HEAD:3,TEXT:4,CHILDREN:5},nt={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_LEFT:4,BOTTOM_RIGHT:8,TOP:3,BOTTOM:12,LEFT:5,RIGHT:10,ALL:15};class ot{static add(t){ot.INSTANCES.push(t)}static first(){const t=ot.INSTANCES;if(0<t.length)return t[0];throw new Error("No application found.")}static last(){const t=ot.INSTANCES;if(0<t.length)return t[t.length-1];throw new Error("No application found.")}static get(t){const e=ot.INSTANCES;return 0<=t&&t<e.length?e[t]:null}static indexOf(t){return ot.INSTANCES.indexOf(t)}static size(){return ot.INSTANCES.length}static getStage(t){let e=t;for(;e.parent;)e=e.parent;return"application"in e&&"layer"in e?e:null}static find(t){const e=this.getStage(t);return e?e.layer.application:null}static getLayerBase(t){const e=this.getStage(t);return e?e.layer.application.getLayerBase():null}static getLayerOverlay(t){const e=this.getStage(t);return e?e.layer.application.getLayerOverlay():null}static getLayer(t){const e=this.getStage(t);return e?e.layer:null}static getResolution(t){var e;const i=this.getLayer(t);return i?i.renderer.resolution:null!==(e=window.devicePixelRatio)&&void 0!==e?e:1}static update(t){if(t){const e=this.getStage(t);e&&e.layer.update()}else{const t=ot.INSTANCES;for(let e=0,i=t.length;e<i;++e)t[e].update()}}static render(t){if(t){const e=this.getStage(t);e&&e.layer.render()}else{const t=ot.INSTANCES;for(let e=0,i=t.length;e<i;++e)t[e].render()}}}ot.INSTANCES=[];class rt{constructor(){this.values=[]}add(t,e){const i=this.values;return null!=e?i.splice(e,0,t):i.push(t),this}addAll(t){const e=this.values;for(let i=0,s=t.length;i<s;++i)e.push(t[i]);return this}clearAndAdd(t){return this.clear(),this.add(t),this}clearAndAddAll(t){return this.clear(),this.addAll(t),this}indexOf(t){const e=this.values;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return i;for(let i=0,s=e.length;i<s;++i)if(e[i].isEquals(t))return i;return-1}get(t){const e=this.values;return 0<=t||t<e.length?e[t]:null}set(t,e){const i=this.values;if(0<=t||t<i.length){const s=i[t];return i[t]=e,s}return null}remove(t){const e=this.values;return 0<=t||t<e.length?e.splice(t,1)[0]:null}clear(){return this.values.length=0,this}size(){return this.values.length}swap(t,e){const i=this.values,s=i[e];return i[e]=i[t],i[t]=s,this}serialize(t){const e=[],i=this.values;for(let s=0,n=i.length;s<n;++s)e.push(i[s].serialize(t));return e}}class at{constructor(t){this._parent=t,this._edges=new Set}add(t){const e=this._edges;return!e.has(t)&&(e.add(t),!0)}contains(t){return this._edges.has(t)}size(){return this._edges.size}remove(t){return this._edges.delete(t)}clear(){return 0<this._edges.size&&(this._edges.clear(),!0)}copy(t){const e=this._edges;return e.clear(),t.each(t=>{e.add(t)}),this}each(t){return this._edges.forEach(t),this}fit(t){this._edges.forEach(this.toOnFitBound(t))}toOnFitBound(t){if(t){let t=this._onFitBoundForcibly;return null==t&&(t=this.newOnFitBound(!0),this._onFitBoundForcibly=t),t}{let t=this._onFitBound;return null==t&&(t=this.newOnFitBound(!1),this._onFitBound=t),t}}newOnFitBound(t){return e=>{this.onFit(e,t)}}onFit(t,e){t.fit(e)}attach(){const t=this._parent;return this._edges.forEach(e=>{e.set(t)}),this}detach(t){return this._edges.forEach(e=>{null!=t&&t.has(e.parent)||e.set(null)}),this}}const ht={NONE:0,TRANSFORM:1,SIZE:2,STYLE:4,ACTION:8,POINTS:16,STATE:32,IMAGE:64,DATA:128,TAG:128,CONNECTOR:256,CAPABILITY:512,ALL:1023},lt={HOVERED:"HOVERED",ACTIVE:"ACTIVE",FOCUSED:"FOCUSED",UNFOCUSABLE:"UNFOCUSABLE",FOCUS_ROOT:"FOCUS_ROOT",FOCUS_REVERSE:"FOCUS_REVERSE",READ_ONLY:"READ_ONLY",DISABLED:"DISABLED",GESTURING:"GESTURING",PRESSED:"PRESSED",INVALID:"INVALID",PROCESSING:"PROCESSING",SUCCEEDED:"SUCCEEDED",FAILED:"FAILED",WARNED:"WARNED",CHANGED:"CHANGED",ALTERNATED:"ALTERNATED",NEW_WINDOW:"NEW_WINDOW"};class ct{constructor(t){this._stateToTargets=new Map,this._interval=t,this._onTimeBound=()=>this.onTime()}get interval(){return this._interval}add(t,e){const i=this._stateToTargets;let s=i.get(t);return null==s?(s=new Set,s.add(e),i.set(t,s),i.size<=1&&this.start()):s.add(e),this}remove(t,e){const i=this._stateToTargets,s=i.get(t);return null!=s&&s.has(e)&&(s.delete(e),e.remove(t),s.size<=0&&i.delete(t),i.size<=0&&this.stop()),this}start(){return null==this._timeoutId&&this.onTime(),this}stop(){const t=this._timeoutId;return null!=t&&(clearTimeout(t),this._timeoutId=void 0),this}onTime(){const t=Date.now(),e=this.interval,i=this.newValue(t,e),s=this.newOn(t,e);this._stateToTargets.forEach((t,e)=>{t.forEach(t=>{t.set(e,i,s)})}),this._timeoutId=window.setTimeout(this._onTimeBound,Math.max(0,e-t%e))}}class ut extends ct{newValue(t,e){return null}newOn(t,e){return Math.round(t/e)%2==0}}class dt{constructor(t,e){this._parent=t,this._stateToInterval=new Map,this._intervalToDatum=e}add(t,e){const i=this._stateToInterval,s=i.get(t);if(s===e)return this;if(null!=s){i.delete(t);const e=this._intervalToDatum.get(s);null!=e&&e.remove(t,this._parent)}i.set(t,e);let n=this._intervalToDatum.get(e);return null==n&&(n=this.newDatum(e),this._intervalToDatum.set(e,n)),n.add(t,this._parent),this}remove(t){const e=this._stateToInterval.get(t);if(null==e)return this;this._stateToInterval.delete(t);const i=this._intervalToDatum.get(e);return null==i||i.remove(t,this._parent),this}set(t,e,i){return i?this.add(t,e):this.remove(t)}has(t){return this._stateToInterval.has(t)}clear(){const t=this._parent,e=this._stateToInterval;return e.forEach((e,i)=>{const s=this._intervalToDatum.get(e);null!=s&&s.remove(i,t)}),e.clear(),this}}let pt,_t;class gt extends dt{constructor(t){super(t,null!=pt?pt:pt=new Map)}newDatum(t){return new ut(t)}}class ft extends ct{newValue(t,e){return Math.round(t/e)}newOn(t,e){return!0}}class mt extends dt{constructor(t){super(t,null!=_t?_t:_t=new Map)}newDatum(t){return new ft(t)}}const vt=Array.isArray||(t=>"[object Array]"===Object.prototype.toString.call(t)),Tt=t=>"function"==typeof t,wt=t=>"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t),Et=t=>"string"==typeof t||"[object String]"===Object.prototype.toString.call(t);class yt{constructor(){this._local=new Map,this._parent=null}get local(){return this._local}get parent(){return this._parent}set parent(t){this._parent!==t&&(this.begin(),this._parent=t,this.end())}onParentChange(t,e){this._parent=e,this.begin(),this._parent=t,this.end()}get blinker(){let t=this._blinker;return null==t&&(t=this.newBlinker(),this._blinker=t),t}newBlinker(){return new gt(this)}get ticker(){let t=this._ticker;return null==t&&(t=this.newTicker(),this._ticker=t),t}newTicker(){return new mt(this)}is(t,e){const i=this._local.get(t);return void 0!==i&&(void 0===e||e===i)}in(t,e){return this.is(t,e)||this.under(t,e)}on(t,e){const i=this._parent;return null!=i&&i.is(t,e)}under(t,e){const i=this._parent;return null!=i&&i.in(t,e)}lock(t){return this}unlock(){return this}begin(){return this}end(){return this}checkAdded(t,e){const i=this._local.get(t);return void 0===i||i!==e}add(t,e=null){return this.checkAdded(t,e)&&(this.begin(),this._local.set(t,e),this.end()),this}checkAddedsString(t){const e=this._local;for(let i=0,s=t.length;i<s;++i){const s=e.get(t[i]);if(void 0===s||null!==s)return!0}return!1}checkAddedsObject(t){const e=this._local;for(let i=0,s=t.length;i<s;++i){const s=t[i],n=e.get(s.state);if(void 0===n||n!==s.value)return!0}return!1}addAll(t){if(Et(t))return this.addAllString(arguments);if(vt(t)){if(0<t.length){const e=t[0];return Et(e)?this.addAllString(t):this.addAllObject(t)}return this}return this.addAllObject(arguments)}addAllString(t){if(this.checkAddedsString(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i)e.set(t[i],null);this.end()}return this}addAllObject(t){if(this.checkAddedsObject(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i){const s=t[i];e.set(s.state,s.value)}this.end()}return this}checkRemoved(t){return this._local.has(t)}remove(t){return this.checkRemoved(t)&&(this.begin(),this._local.delete(t),this.end()),this}checkRemovedsString(t){const e=this._local;for(let i=0,s=t.length;i<s;++i)if(e.has(t[i]))return!0;return!1}checkRemovedsObject(t){const e=this._local;for(let i=0,s=t.length;i<s;++i)if(e.has(t[i].state))return!0;return!1}removeAll(t){if(Tt(t))return this.removeAllMatcher(t);if(Et(t))return this.removeAllString(arguments);if(vt(t)){if(0<t.length){const e=t[0];return Et(e)?this.removeAllString(t):this.removeAllObject(t)}return this}return this.removeAllObject(arguments)}removeAllMatcher(t){let e=!1;const i=this._local;return i.forEach((s,n)=>{t(n)&&(e||(e=!0,this.begin()),i.delete(n))}),e&&this.end(),this}removeAllString(t){if(this.checkRemovedsString(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i)e.delete(t[i]);this.end()}return this}removeAllObject(t){if(this.checkRemovedsObject(t)){this.begin();const e=this._local;for(let i=0,s=t.length;i<s;++i)e.delete(t[i].state);this.end()}return this}set(t,e,i){if(!0===e)null!=t&&this.add(t);else if(!1===e)null!=t&&this.remove(t);else{if(null!=e&&!wt(e))return this.doSet(t,null,e);if(!0===i)null!=t&&this.add(t,e);else{if(!1!==i)return this.doSet(t,e,i);null!=t&&this.remove(t)}}return this}doSet(t,e,i){return null!=t?null!=i?(this.checkAdded(t,e)||this.checkRemoved(i))&&(this.begin(),this._local.set(t,e).delete(i),this.end()):this.add(t,e):null!=i&&this.remove(i),this}setAll(t,e){if(!0===e)null!=t&&this.addAll(t);else if(!1===e)null!=t&&this.removeAll(t);else if(null!=t&&0<t.length){if(null!=e&&0<e.length){const i=t[0];return Et(i)?this.setAllString(t,e):this.setAllObject(t,e)}this.addAll(t)}else null!=e&&this.removeAll(e);return this}setAllString(t,e){if(this.checkAddedsString(t)||this.checkRemovedsString(e)){this.begin();const i=this._local;for(let e=0,s=t.length;e<s;++e)i.set(t[e],null);for(let t=0,s=e.length;t<s;++t)i.delete(e[t]);this.end()}return this}setAllObject(t,e){if(this.checkAddedsObject(t)||this.checkRemovedsString(e)){this.begin();const i=this._local;for(let e=0,s=t.length;e<s;++e){const s=t[e];i.set(s.state,s.value)}for(let t=0,s=e.length;t<s;++t)i.delete(e[t]);this.end()}return this}clear(){const t=this._local;return 0<t.size&&(this.begin(),t.clear(),this.end()),this}valueOf(t,e){const i=this._local.get(t);if(void 0!==i)return null==i&&void 0!==e?e:i;const s=this._parent;return null!=s?void 0!==e?s.valueOf(t,e):s.valueOf(t):e}each(t){return this._local.forEach((e,i)=>{t(i,e)}),this}size(){return this._local.size}copy(t){if(t instanceof yt){this.begin();const e=this._local;e.clear(),t.local.forEach((t,i)=>{e.set(i,t)}),this._parent=t.parent,this.end()}return this}get isHovered(){return this.is(lt.HOVERED)}set isHovered(t){this.set(lt.HOVERED,t)}get inHovered(){return this.in(lt.HOVERED)}get onHovered(){return this.on(lt.HOVERED)}get underHovered(){return this.under(lt.HOVERED)}get isActive(){return this.is(lt.ACTIVE)}set isActive(t){this.set(lt.ACTIVE,t)}get inActive(){return this.in(lt.ACTIVE)}get onActive(){return this.on(lt.ACTIVE)}get underActive(){return this.under(lt.ACTIVE)}get isPressed(){return this.is(lt.PRESSED)}set isPressed(t){this.set(lt.PRESSED,t)}get inPressed(){return this.in(lt.PRESSED)}get onPressed(){return this.on(lt.PRESSED)}get underPressed(){return this.under(lt.PRESSED)}get isReadOnly(){return this.is(lt.READ_ONLY)}set isReadOnly(t){this.set(lt.READ_ONLY,t)}get inReadOnly(){return this.in(lt.READ_ONLY)}get onReadOnly(){return this.on(lt.READ_ONLY)}get underReadOnly(){return this.under(lt.READ_ONLY)}get isEnabled(){return!this.is(lt.DISABLED)}set isEnabled(t){this.set(lt.DISABLED,!t)}get inEnabled(){return!this.in(lt.DISABLED)}get onEnabled(){return!this.on(lt.DISABLED)}get underEnabled(){return!this.under(lt.DISABLED)}get isDisabled(){return this.is(lt.DISABLED)}set isDisabled(t){this.set(lt.DISABLED,t)}get inDisabled(){return this.in(lt.DISABLED)}get onDisabled(){return this.on(lt.DISABLED)}get underDisabled(){return this.under(lt.DISABLED)}get isActionable(){return!this.in(lt.DISABLED)&&!this.in(lt.READ_ONLY)}get isGesturing(){return this.is(lt.GESTURING)}set isGesturing(t){this.set(lt.GESTURING,t)}get inGesturing(){return this.in(lt.GESTURING)}get onGesturing(){return this.on(lt.GESTURING)}get underGesturing(){return this.under(lt.GESTURING)}get isFocused(){return this.is(lt.FOCUSED)}set isFocused(t){this.set(lt.FOCUSED,t)}get inFocused(){return this.in(lt.FOCUSED)}get onFocused(){return this.on(lt.FOCUSED)}get underFocused(){return this.under(lt.FOCUSED)}get isFocusRoot(){return this.is(lt.FOCUS_ROOT)}set isFocusRoot(t){this.set(lt.FOCUS_ROOT,t)}get inFocusRoot(){return this.in(lt.FOCUS_ROOT)}get onFocusRoot(){return this.on(lt.FOCUS_ROOT)}get underFocusRoot(){return this.under(lt.FOCUS_ROOT)}get isFocusReverse(){return this.is(lt.FOCUS_REVERSE)}set isFocusReverse(t){this.set(lt.FOCUS_REVERSE,t)}get inFocusReverse(){return this.in(lt.FOCUS_REVERSE)}get onFocusReverse(){return this.on(lt.FOCUS_REVERSE)}get underFocusReverse(){return this.under(lt.FOCUS_REVERSE)}get isFocusable(){return!this.is(lt.UNFOCUSABLE)}set isFocusable(t){this.set(lt.UNFOCUSABLE,!t)}get inFocusable(){return!this.in(lt.UNFOCUSABLE)}get onFocusable(){return!this.on(lt.UNFOCUSABLE)}get underFocusable(){return!this.under(lt.UNFOCUSABLE)}get isUnfocusable(){return this.is(lt.UNFOCUSABLE)}set isUnfocusable(t){this.set(lt.UNFOCUSABLE,t)}get inUnfocusable(){return this.in(lt.UNFOCUSABLE)}get onUnfocusable(){return this.on(lt.UNFOCUSABLE)}get underUnfocusable(){return this.under(lt.UNFOCUSABLE)}get isInvalid(){return this.is(lt.INVALID)}set isInvalid(t){this.set(lt.INVALID,t)}get inInvalid(){return this.in(lt.INVALID)}get onInvalid(){return this.on(lt.INVALID)}get underInvalid(){return this.on(lt.INVALID)}get isProcessing(){return this.is(lt.PROCESSING)}set isProcessing(t){this.set(lt.PROCESSING,t)}get inProcessing(){return this.in(lt.PROCESSING)}get onProcessing(){return this.on(lt.PROCESSING)}get underProcessing(){return this.under(lt.PROCESSING)}get isSucceeded(){return this.is(lt.SUCCEEDED)}set isSucceeded(t){this.set(lt.SUCCEEDED,t)}get inSucceeded(){return this.in(lt.SUCCEEDED)}get onSucceeded(){return this.on(lt.SUCCEEDED)}get underSucceeded(){return this.under(lt.SUCCEEDED)}get isFailed(){return this.is(lt.FAILED)}set isFailed(t){this.set(lt.FAILED,t)}get inFailed(){return this.in(lt.FAILED)}get onFailed(){return this.on(lt.FAILED)}get underFailed(){return this.under(lt.FAILED)}get isWarned(){return this.is(lt.WARNED)}set isWarned(t){this.set(lt.WARNED,t)}get inWarned(){return this.in(lt.WARNED)}get onWarned(){return this.on(lt.WARNED)}get underWarned(){return this.on(lt.WARNED)}get isChanged(){return this.is(lt.CHANGED)}set isChanged(t){this.set(lt.CHANGED,t)}get inChanged(){return this.in(lt.CHANGED)}get onChanged(){return this.on(lt.CHANGED)}get underChanged(){return this.on(lt.CHANGED)}get isAlternated(){return this.is(lt.ALTERNATED)}set isAlternated(t){this.set(lt.ALTERNATED,t)}get inAlternated(){return this.in(lt.ALTERNATED)}get onAlternated(){return this.on(lt.ALTERNATED)}get underAlternated(){return this.on(lt.ALTERNATED)}toObject(){const t=[];return this._local.forEach((e,i)=>{t.push(i)}),{local:t}}toString(){return JSON.stringify(this.toObject())}}class xt extends yt{constructor(t){super(),this._onChange=t,this._isLocked=0,this._isSaved=!1,this._doSave=!0}lock(t){return this._isLocked+=1,!1===t&&(this._doSave=!1),this}unlock(){return this._isLocked-=1,this.end()}get saved(){let t=this._saved;return null==t&&(t=new yt,this._saved=t),t}begin(){return this._doSave&&!this._isSaved&&(this._isSaved=!0,this.saved.copy(this)),this}end(){return this._isLocked<=0&&(this._doSave=!0,this._isSaved&&(this._isSaved=!1,this.onChange(this,this.saved))),this}onChange(t,e){this._onChange(t,e)}}const Ct={CLICKED:"CLICKED",DBL_CLICKED:"DBL_CLICKED",DOWN:"DOWN",UP:"UP",UP_OUTSIDE:"UP_OUTSIDE",RIGHT_CLICKED:"RIGHT_CLICKED",RIGHT_DOWN:"RIGHT_DOWN",RIGHT_UP:"RIGHT_UP",RIGHT_UP_OUTSIDE:"RIGHT_UP_OUTSIDE",RIGHT_PRESSED:"RIGHT_PRESSED",ACTIVATED:"ACTIVATED",DEACTIVATED:"DEACTIVATED"};class Dt extends xt{onChange(t,e){t.isActive?e.isActive||this._local.set(Ct.ACTIVATED,null).delete(Ct.DEACTIVATED):e.isActive&&this._local.set(Ct.DEACTIVATED,null).delete(Ct.ACTIVATED),super.onChange(t,e)}get isClicked(){return this.is(Ct.CLICKED)}set isClicked(t){this.set(Ct.CLICKED,t)}get inClicked(){return this.in(Ct.CLICKED)}get onClicked(){return this.on(Ct.CLICKED)}get underClicked(){return this.under(Ct.CLICKED)}get isDblClicked(){return this.is(Ct.DBL_CLICKED)}set isDblClicked(t){this.set(Ct.DBL_CLICKED,t)}get inDblClicked(){return this.in(Ct.DBL_CLICKED)}get onDblClicked(){return this.on(Ct.DBL_CLICKED)}get underDblClicked(){return this.under(Ct.DBL_CLICKED)}get isDown(){return this.is(Ct.DOWN)}set isDown(t){this.set(Ct.DOWN,t)}get inDown(){return this.in(Ct.DOWN)}get onDown(){return this.on(Ct.DOWN)}get underDown(){return this.under(Ct.DOWN)}get isUp(){return this.is(Ct.UP)}set isUp(t){this.set(Ct.UP,t)}get inUp(){return this.in(Ct.UP)}get onUp(){return this.on(Ct.UP)}get underUp(){return this.under(Ct.UP)}get isUpOutside(){return this.is(Ct.UP_OUTSIDE)}set isUpOutside(t){this.set(Ct.UP_OUTSIDE,t)}get inUpOutside(){return this.in(Ct.UP_OUTSIDE)}get onUpOutside(){return this.on(Ct.UP_OUTSIDE)}get underUpOutside(){return this.under(Ct.UP_OUTSIDE)}get isRightClicked(){return this.is(Ct.RIGHT_CLICKED)}set isRightClicked(t){this.set(Ct.RIGHT_CLICKED,t)}get inRightClicked(){return this.in(Ct.RIGHT_CLICKED)}get onRightClicked(){return this.on(Ct.RIGHT_CLICKED)}get underRightClicked(){return this.under(Ct.RIGHT_CLICKED)}get isRightDown(){return this.is(Ct.RIGHT_DOWN)}set isRightDown(t){this.set(Ct.RIGHT_DOWN,t)}get inRightDown(){return this.in(Ct.RIGHT_DOWN)}get onRightDown(){return this.on(Ct.RIGHT_DOWN)}get underRightDown(){return this.under(Ct.RIGHT_DOWN)}get isRightUp(){return this.is(Ct.RIGHT_UP)}set isRightUp(t){this.set(Ct.RIGHT_UP,t)}get inRightUp(){return this.in(Ct.RIGHT_UP)}get onRightUp(){return this.on(Ct.RIGHT_UP)}get underRightUp(){return this.under(Ct.RIGHT_UP)}get isRightUpOutside(){return this.is(Ct.RIGHT_UP_OUTSIDE)}set isRightUpOutside(t){this.set(Ct.RIGHT_UP_OUTSIDE,t)}get inRightUpOutside(){return this.in(Ct.RIGHT_UP_OUTSIDE)}get onRightUpOutside(){return this.on(Ct.RIGHT_UP_OUTSIDE)}get underRightUpOutside(){return this.under(Ct.RIGHT_UP_OUTSIDE)}get isRightPressed(){return this.is(Ct.RIGHT_PRESSED)}set isRightPressed(t){this.set(Ct.RIGHT_PRESSED,t)}get inRightPressed(){return this.in(Ct.RIGHT_PRESSED)}get onRightPressed(){return this.on(Ct.RIGHT_PRESSED)}get underRightPressed(){return this.under(Ct.RIGHT_PRESSED)}get isActivated(){return this.is(Ct.ACTIVATED)}set isActivated(t){this.set(Ct.ACTIVATED,t)}get inActivated(){return this.in(Ct.ACTIVATED)}get onActivated(){return this.on(Ct.ACTIVATED)}get underActivated(){return this.under(Ct.ACTIVATED)}get isDeactivated(){return this.is(Ct.DEACTIVATED)}set isDeactivated(t){this.set(Ct.DEACTIVATED,t)}get inDeactivated(){return this.in(Ct.DEACTIVATED)}get onDeactivated(){return this.on(Ct.DEACTIVATED)}get underDeactivated(){return this.under(Ct.DEACTIVATED)}}class St extends t.Transform{constructor(e){super(),this.internalTransform=new t.Matrix,this._parent=e}onChange(){super.onChange(),this._parent.onTransformChange()}updateSkew(){super.updateSkew(),this._parent.onTransformChange()}getLocalIdCurrent(){return this._currentLocalID}getLocalId(){return this._localID}getParentId(){return this._parentID}getWorldId(){return this._worldID}updateTransform(t){const e=this._currentLocalID,i=this._worldID;super.updateTransform(t);const s=this._currentLocalID,n=this._worldID;if(e!==s){const e=this.localTransform,i=this.internalTransform;e.copyTo(i),t instanceof St&&i.prepend(t.internalTransform)}else if(i!==n){const e=this.localTransform,i=this.internalTransform;t instanceof St&&(e.copyTo(i).prepend(t.internalTransform),this._currentLocalID+=1,this._localID=this._currentLocalID)}}}class bt{constructor(){this.x=0,this.y=0,this.width=0,this.height=0,this.strokeWidth=0,this.strokeScale=1,this.strokeAlign=0}set(t,e,i,s,n,o,r){return this.x=t,this.y=e,this.width=i,this.height=s,this.strokeWidth=n,this.strokeScale=o,this.strokeAlign=r,this}}const It=(t,e,i,s)=>-i<=t&&t<=+i&&-s<=e&&e<=+s,Ot={NONE:0,ID:1,POSITION:2,WIDTH:4,HEIGHT:8,ROTATION:16,SKEW:32,ALIGN:0,REPLACING:64,GROUPING:128,UNGROUPING:256,FILL:512,STROKE:1024,STROKE_SIDE:2048,BORDER_RADIUS:4096,TEXT:8192,TEXTURE:16384,TAG:32768,DATA:32768,DATA_MAPPING:1048576,ACTION:65536,CURSOR:131072,ORDER_IN_LAYER:262144,CHILDREN:524288,LINE:2097152,LINE_TAIL:4194304,LINE_HEAD:8388608,COORDINATE:62,SHAPE:14681792,LAYER:262144,PRIMITIVE:15722239,GROUP:15722495,EMBEDDED:1417471,EMBEDDED_ACCEPTOR_EDGE:517759,CONNECTOR:15722177,ALL:16777215};class At{constructor(){this.added=Ot.NONE,this.removed=Ot.NONE,this.locked=Ot.NONE}add(t){return this.removed&=~t,this.added|=t,this}remove(t){return this.added&=~t,this.removed|=t,this}lock(t){return this.locked|=t,this}unlock(t){return this.locked&=~t,this}clear(){return this.added=Ot.NONE,this.removed=Ot.NONE,this.locked=Ot.NONE,this}set(t,e,i){return null!=t&&(this.added=t),null!=e&&(this.removed=e),null!=i&&(this.locked=i),this}copy(t){return this.added=t.added,this.removed=t.removed,this.locked=t.locked,this}}class Rt{constructor(){this._count=0,this._flag=0}lock(){return this._count+=1,1===this._count&&(this._flag=0,!0)}unlock(){return this._count-=1,this._count<=0&&0!==this._flag}isLocked(t){return 0<this._count&&(this._flag|=t?3:1,!0)}isHigh(){return 1<this._flag}}const Mt={TRANSFORM_CHILD:1,TRANSFORM_THIS:2,TRANSFORM_PARENT:4,TRANSFORM:7,UPLOADED:8,TRANSFORM_AND_UPLOADED:15,CONNECTOR:16,ALL:31};class kt extends t.utils.EventEmitter{constructor(t){super(),this.id="",this.uuid=0,this.type=t,this.transform=this.newTransform(),this.action=new rt,this._visible=!0,this._lockTransformChild=new Rt,this._lockTransformThis=new Rt,this._lockTransformParent=new Rt,this._lockUploaded=new Rt,this._boundsTransformId=-1,this._boundsInternalTransformId=-1,this._boundsLocalTransformId=-1,this.interactive=!1,this.parent=null,this.children=[],this.selected=!1,this.index=0,this.reference=0}newTransform(){return new St(this)}onSizeChange(){this._boundsTransformId=-1,this._boundsInternalTransformId=-1,this._boundsLocalTransformId=-1,this._lockTransformChild.isLocked()||this.callChildTransformChange();const t=this._points;null!=t&&t.onSizeChange(),this.updateUploaded();const e=this._connector;null!=e&&e.fit(!0);const i=this.runtime;null!=i&&i.onResize(this)}onTransformChange(){this._lockTransformChild.isLocked()||this.callChildTransformChange(),this._lockTransformThis.isLocked()||this.onThisTransformChange(),this._lockTransformParent.isLocked()||this.callParentTransformChange()}callChildTransformChange(){const t=this.parent;null!=t&&t.onChildTransformChange()}onThisTransformChange(){this.updateUploaded();const t=this._connector;null!=t&&t.fit(!0)}callParentTransformChange(){const t=this.children;for(let e=0,i=t.length;e<i;++e)t[e].onParentTransformChange()}onParentTransformChange(){this._lockTransformThis.isLocked()||this.onThisTransformChange(),this._lockTransformParent.isLocked()||this.callParentTransformChange()}lock(t){return t&Mt.UPLOADED&&this._lockUploaded.lock(),t&Mt.TRANSFORM_PARENT&&this._lockTransformParent.lock(),t&Mt.TRANSFORM_THIS&&this._lockTransformThis.lock(),t&Mt.TRANSFORM_CHILD&&this._lockTransformChild.lock(),this}unlock(t,e){if(t&Mt.TRANSFORM_CHILD&&this._lockTransformChild.unlock()&&e){const t=this.parent;null!=t&&t.onChildTransformChange()}if(t&Mt.TRANSFORM_THIS&&this._lockTransformThis.unlock()&&e&&this.onThisTransformChange(),t&Mt.TRANSFORM_PARENT&&this._lockTransformParent.unlock()&&e){const t=this.children;for(let e=0,i=t.length;e<i;++e)t[e].onParentTransformChange()}if(t&Mt.UPLOADED){const t=this._lockUploaded;t.unlock()&&e&&this.updateUploaded(t.isHigh())}return this}onChildTransformChange(){}updateUploaded(t){if(this._lockUploaded.isLocked(t))return;const e=this.uploaded;if(null!=e&&e.update(this),!0===t){const t=this.children;for(let e=0,i=t.length;e<i;++e)t[e].updateUploaded(!0)}}get points(){return this._points}get root(){let t=this;for(;t.parent instanceof kt;)t=t.parent;return t}get connector(){let t=this._connector;return null==t&&(t=new at(this),this._connector=t),t}get visible(){if(this._visible){const t=this.parent;return!(t instanceof kt)||t.visible}return!1}set visible(t){this._visible!==t&&(this._visible=t,this.updateUploaded(!0))}get worldVisible(){if(this._visible){const t=this.parent;return!t||t.worldVisible}return!1}toDirty(){const t=this.parent;null!=t&&t.toDirty()}attach(t,e){this.detach(),this.parent=t;const i=t.children;return null!=e&&0<=e&&e<i.length?i.splice(e,0,this):i.push(this),t.onChildTransformChange(),t.toDirty(),this.onAttach(),this}onAttach(){this.uploaded=void 0;const t=this._connector;t&&(t.attach(),t.fit(!0));const e=this.children;for(let t=0,i=e.length;t<i;++t)e[t].onAttach()}detach(t){const e=this.parent;if(e){this.parent=null;const i=e.children,s=i.indexOf(this);0<=s&&(i.splice(s,1),e.onChildTransformChange(),e.toDirty(),this.onDetach(t))}return this}onDetach(t){this.uploaded=void 0;const e=this._connector;e&&e.detach(t);const i=this.children;for(let e=0,s=i.length;e<s;++e)i[e].onDetach(t)}updateTransform(){const e=this.parent;e?(e.parent&&e.updateTransform(),this.transform.updateTransform(e.transform)):this.transform.updateTransform(t.Transform.IDENTITY)}serializeChildren(t){const e=this.children,i=[];for(let s=0,n=e.length;s<n;++s){const n=e[s];i.push(n.serialize(t))}return i}serializeState(t){const e=this.state;return(this.interactive?1:0)|(e.isFocusable?0:2)|(e.isActive?4:0)}serialize(t){const e=this.transform,i=e.position,s=e.pivot,n=this.size,o=this.shortcut,r=null!=o?t.addResource(o):-1,a=this.cursor,h=null!=a?t.addResource(a):-1,l=this.title,c=null!=l?t.addResource(l):-1;let u=Ot.NONE,d=Ot.NONE,p=Ot.NONE;const _=this._capability;return null!=_&&(u=_.added,d=_.removed,p=_.locked),[this.type,t.addResource(this.id),i.x,i.y,n.x,n.y,e.rotation,e.skew.x,this.fill.serialize(t),this.stroke.serialize(t),h,this.text.serialize(t),this.data.serialize(t),this.radius,this.corner,-1,-1,this.action.serialize(t),this.serializeImage(t),this.serializeGradient(t),this.serializeChildren(t),s.x,s.y,this.serializeState(t),r,c,this.uuid,u,d,p]}addUuid(t){this.uuid=t.addUuid(this.uuid);const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].addUuid(t)}updateUuid(t){this.uuid=t.updateUuid(this.uuid);const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].updateUuid(t)}getShapeScale(){const t=this.root.parent;return null!=t&&null!=t.getShapeScale?t.getShapeScale():1}getStrokeWidthScale(t){return t&r.NON_EXPANDING_WIDTH?t&r.NON_SHRINKING_WIDTH?this.getShapeScale():Math.min(1,this.getShapeScale()):t&r.NON_SHRINKING_WIDTH?Math.max(1,this.getShapeScale()):1}getHitTestSize(t){const e=this.size;return t.width=.5*e.x,t.height=.5*e.y,t}toHitTestData(t,e){var i;const s=this.getHitTestSize(null!==(i=kt.WORK_HIT_TEST_DATA)&&void 0!==i?i:kt.WORK_HIT_TEST_DATA=new bt),n=s.width,o=s.height,r=this.transform.pivot,a=t-r.x,h=e-r.y,l=this.stroke,c=l.enable?l.width:0,u=this.getStrokeWidthScale(l.style),d=l.align,p=c*u*d;return s.set(0<=n?+a:-a,0<=o?+h:-h,Math.abs(n)+p,Math.abs(o)+p,c,u,d)}contains(t,e){const i=this.toHitTestData(t,e);return this.containsAbs(i.x,i.y,i.width,i.height,i.strokeWidth,i.strokeScale,i.strokeAlign)?this:this.containsText(t,e)||this.containsChildren(t,e)}containsText(t,e){const i=this.text;if(null!=i.atlas){const s=i.world;if(null!=s){const i=this.transform.internalTransform,n=i.a*t+i.c*e+i.tx-s[0],o=i.b*t+i.d*e+i.ty-s[1],r=s[2]*n+s[3]*o,a=s[4]*n+s[5]*o,h=s[6],l=s[7];if(0<=r&&r<=h&&0<=a&&a<=l)return this}}return null}containsChildren(t,e){const i=this.children;for(let s=i.length-1;0<=s;--s){const n=i[s];n.updateTransform();const o=n.transform.localTransform,r=o.a,a=o.b,h=o.c,l=o.d,c=o.tx,u=o.ty,d=1/(r*l-h*a),p=(l*t-h*e+u*h-c*l)*d,_=(r*e-a*t-u*r+c*a)*d,g=n.contains(p,_);if(null!=g)return g}return null}containsBBox(t,e){const i=this.toHitTestData(t,e);return this.containsAbsBBox(i.x,i.y,i.width,i.height)}containsAbs(t,e,i,s,n,o,r){return this.containsAbsBBox(t,e,i,s)}containsAbsBBox(t,e,i,s){return It(t,e,i,s)}select(t){return!1}toGlobal(t,e,i){return!0!==i&&this.updateTransform(),e.copyFrom(t),this.transform.worldTransform.apply(e,e),e}toLocal(e,i,s,n){return!0!==n&&this.updateTransform(),void 0===s&&(s=new t.Point),s.copyFrom(e),this.transform.worldTransform.applyInverse(s,s),s}getBounds(e,i){!0!==e&&this.updateTransform();const s=this._bounds||new t.Rectangle;this._bounds=s;const n=this.transform.getWorldId();return n!==this._boundsTransformId&&(this._boundsTransformId=n,this.getBounds_(this.transform.worldTransform,s)),null!=i||(i=new t.Rectangle),i.copyFrom(s),i}getBoundsInternal(e,i){!0!==e&&this.updateTransform();const s=this._boundsInternal||new t.Rectangle;this._boundsInternal=s;const n=this.transform.getLocalIdCurrent();return n!==this._boundsInternalTransformId&&(this._boundsInternalTransformId=n,this.getBounds_(this.transform.internalTransform,s)),null!=i||(i=new t.Rectangle),i.copyFrom(s),i}getBoundsLocal(e,i){!0!==e&&this.updateTransform();const s=this._boundsLocal||new t.Rectangle;this._boundsLocal=s;const n=this.transform.getLocalIdCurrent();return n!==this._boundsLocalTransformId&&(this._boundsLocalTransformId=n,this.getBounds_(this.transform.localTransform,s)),null!=i||(i=new t.Rectangle),i.copyFrom(s),i}getBoundsSize(){return this.size}getBounds_(t,e){const i=this.transform.pivot,s=i.x,n=i.y,o=this.getBoundsSize(),r=.5*o.x,a=.5*o.y,h=t.a,l=t.b,c=t.c,u=t.d;let d=-r+s,p=-a+n;const _=h*d+c*p,g=l*d+u*p;d=+r+s,p=-a+n;const f=h*d+c*p,m=l*d+u*p;d=-r+s,p=+a+n;const v=h*d+c*p,T=l*d+u*p;d=+r+s,p=+a+n;const w=h*d+c*p,E=l*d+u*p,y=Math.min(_,f,v,w),x=Math.min(g,m,T,E),C=Math.max(_,f,v,w),D=Math.max(g,m,T,E);return e.x=y+t.tx,e.y=x+t.ty,e.width=C-y,e.height=D-x,e}destroy(){const t=this.children;for(let e=t.length-1;0<=e;--e)t[e].destroy();t.length=0}onStateChange(t,e){const i=this.runtime;null!=i&&i.onStateChange(this,t,e);const s=this.children;for(let i=0,n=s.length;i<n;++i){const n=s[i];n instanceof kt&&n.state.onParentChange(t,e)}}get state(){let t=this._state;return null==t&&(t=new Dt((t,e)=>{this.onStateChange(t,e)}),this._state=t),t}get capability(){let t=this._capability;return null==t&&(t=new At,this._capability=t),t}getCapability(){return this._capability}focus(){return this.setFocused(!0),this}blur(){return this.setFocused(!1),this}setFocused(t){if(this.state.isFocused!==t){const e=ot.getLayer(this);e&&e.getFocusController().set(this,t)}}onKeyDown(t){const e=this.runtime;return!!e&&e.onKeyDown(this,t)}onKeyUp(t){const e=this.runtime;return!!e&&e.onKeyUp(this,t)}update(t){const e=this.runtime;e&&e.update(this,t)}onRender(t,e){const i=this.runtime;i&&i.onRender(this,t,e)}copy(t,e=ht.ALL){if(this.lock(Mt.ALL),this.id=t.id,this.uuid=t.uuid,this.visible=t.visible,e&ht.TRANSFORM){const e=this.transform,i=t.transform;e.position.copyFrom(i.position),e.rotation=i.rotation,e.skew.copyFrom(i.skew),e.pivot.copyFrom(i.pivot),e.scale.copyFrom(i.scale)}if(e&ht.SIZE&&this.size.copyFrom(t.size),e&ht.STYLE&&(this.fill.copy(t.fill),this.stroke.copy(t.stroke),this.text.copy(t.text),this.radius=t.radius,this.corner=t.corner),e&ht.DATA&&this.data.copy(t.data),e&ht.IMAGE&&(this.image=t.image),e&ht.ACTION&&(this.action.clearAndAddAll(t.action.values),this.interactive=t.interactive,this.title=t.title,this.cursor=t.cursor,this.shortcut=t.shortcut),e&ht.POINTS){const e=t.points;if(null!=e){const t=this.points;null!=t&&t.copy(e)}}if(e&ht.STATE&&this.state.lock(!1).copy(t.state).unlock(),e&ht.CONNECTOR)if(t instanceof kt){const e=t._connector;if(e)this.connector.copy(e);else{const t=this._connector;t&&t.clear()}}else{const t=this._connector;t&&t.clear()}if(e&ht.CAPABILITY){const e=t.getCapability();if(null!=e)this.capability.copy(e);else{const t=this._capability;null!=t&&t.clear()}}return this.unlock(Mt.ALL,!0),this}}class Lt{constructor(t,e,i,s,n,o,r,a){this._parent=t,this._enable=e,this._color=i,this._alpha=s,this._width=n,this._align=o,this._side=r,this._style=a}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this._parent.updateUploaded())}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this._parent.updateUploaded())}get side(){return this._side}set side(t){this._side!==t&&(this._side=t,this._parent.updateUploaded())}get style(){return this._style}set style(t){this._style!==t&&(this._style=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.enable,t.color,t.alpha,t.width,t.align,t.side,t.style)}set(t,e,i,s,n,o,r){let a=!1;void 0!==t&&this._enable!==t&&(this._enable=t,a=!0),void 0!==e&&this._color!==e&&(this._color=e,a=!0),void 0!==i&&this._alpha!==i&&(this._alpha=i,a=!0),void 0!==s&&this._width!==s&&(this._width=s,a=!0),void 0!==n&&this._align!==n&&(this._align=n,a=!0),void 0!==o&&this._side!==o&&(this._side=o,a=!0),void 0!==r&&this._style!==r&&(this._style=r,a=!0),a&&this._parent.updateUploaded()}clone(){return new Lt(this._parent,this._enable,this._color,this._alpha,this._width,this._align,this._side,this._style)}toObject(){return{enable:this._enable,color:this._color,alpha:this._alpha,width:this._width,align:this._align,side:this._side,style:this._style}}serialize(t){const e=`[${this._enable?1:0},${this._color},${this._alpha},${this._width},${this._align},${this._side},${this._style}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getStroke(t);if(null!=s)this.set(!!s[0],s[1],s[2],s[3],s[4],s[5],s[6]);else{const s=JSON.parse(i[t]);e.setStroke(t,s),this.set(!!s[0],s[1],s[2],s[3],s[4],s[5],s[6])}}}}const Nt={NONE:0,FROM:1,TO:2,FROM_TO:3};class Pt{constructor(){this._type=Nt.NONE,this._from=0,this._to=1}get type(){return this._type}set type(t){if(this._type!==t){this._type=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}get from(){return this._from}set from(t){if(this._from!==t){this._from=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}get to(){return this._to}set to(t){if(this._to!==t){this._to=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}set(t,e){let i=!1;if(void 0!==t&&void 0!==e)if(null!==t&&null!==e){const s=this._type|Nt.FROM|Nt.TO;this._type===s&&this._from===t&&this._to===e||(this._type=s,this._from=t,this._to=e,i=!0)}else if(null!==t){const e=(this._type|Nt.FROM)&~Nt.TO;this._type===e&&this._from===t||(this._type=e,this._from=t,i=!0)}else if(null!==e){const s=(this._type|Nt.TO)&~Nt.FROM;this._type===s&&this._from===t||(this._type=s,this._to=e,i=!0)}else{const t=this._type&~(Nt.TO|Nt.FROM);this._type!==t&&(this._type=t,i=!0)}else if(void 0!==t)if(null!==t){const e=this._type|Nt.FROM;this._type===e&&this._from===t||(this._type=e,this._from=t,i=!0)}else{const t=this._type&~Nt.FROM;this._type!==t&&(this._type=t,i=!0)}else if(void 0!==e)if(null!==e){const t=this._type|Nt.TO;this._type===t&&this._to===e||(this._type=t,this._to=e,i=!0)}else{const t=this._type&~Nt.TO;this._type!==t&&(this._type=t,i=!0)}if(i){const t=this.parent;null!=t&&(t.isChanged=!0)}return i}normalize(t){const e=this._type,i=this._from,s=this._to;switch(e){case Nt.FROM_TO:return(t-i)/(s-i);case Nt.FROM:return t-i;case Nt.TO:return s-t;case Nt.NONE:default:return t}}isEquals(t){return this._type===t.type&&this._from===t.from&&this._to===t.to}copy(t){return this.copy_(t.type,t.from,t.to)}copy_(t,e,i){let s=!1;if(this._type!==t&&(this._type=t,s=!0),this._from!==e&&(this._from=e,s=!0),this._to!==i&&(this._to=i,s=!0),s){const t=this.parent;null!=t&&(t.isChanged=!0)}return this}toObject(){return{type:this.type,from:this.from,to:this.to}}serialize(t){const e=`[${this._type},${this._from},${this._to}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getRange(t);if(null!=s)this.copy_(s[0],s[1],s[2]);else{const s=JSON.parse(i[t]);e.setRange(t,s),this.copy_(s[0],s[1],s[2])}}}}const Bt={ASCENDING:0,DESCENDING:1},zt={BOOLEAN:7,BOOLEAN_ARRAY:8,NUMBER:0,NUMBER_ARRAY:1,STRING:2,STRING_ARRAY:3,OBJECT:4,OBJECT_ARRAY:5,TICKER:6,EXTENSION:1e3},Ut={PRIVATE:0,PUBLIC:1,PROTECTED:2},Ft={UNKNOWN:-1,FOUND:0,NOT_FOUND:1,BAD_REQUEST:2,SERVER_ERROR:3,SERVICE_UNAVAILABLE:4,FORBIDDEN:5,NOT_DEFINED:6},Ht=(t,e)=>t-e;class Gt{constructor(){this.id="",this.as="",this.type=zt.NUMBER,this.scope=Ut.PUBLIC,this.initial="",this.format="",this.range=new Pt,this._value=0,this._time=0,this._state=Ft.UNKNOWN,this._capacity=0,this._order=Bt.ASCENDING}get parent(){return this._parent}set parent(t){this._parent!==t&&(this._parent=t,this.range.parent=t)}get value(){return this._value}set value(t){const e=this.formatter;null!=e&&(t=e(t));const i=this._capacity;if(i<=0){if(this._value!==t){this._value=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}else{let e=this._values;null==e&&(e=[],this._values=e),this._value=t;const s=this._order;s===Bt.ASCENDING?e.push(t):e.unshift(t);const n=e.length-i;if(0<n)if(s===Bt.ASCENDING)for(let t=0;t<n;++t)e.shift();else e.length=i;const o=this.parent;null!=o&&(o.isChanged=!0)}}get nvalue(){return this.range.normalize(this._value)}get values(){let t=this._values;return null==t&&(t=[],this._values=t),t}set values(t){const e=t.length;if(0<e){const i=this._capacity;if(i<=0){let i=t[e-1];const s=this.formatter;if(null!=s&&(i=s(i)),this._value!==i){this._value=i;const t=this.parent;null!=t&&(t.isChanged=!0)}}else{let s=this._values;null==s&&(s=[],this._values=s);const n=this._order,o=this.formatter;if(null!=o)if(this._value=o(t[e-1]),n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(o(t[i]));else for(let i=0;i<e;++i)s.unshift(o(t[i]));else if(this._value=t[e-1],n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(t[i]);else for(let i=0;i<e;++i)s.unshift(t[i]);const r=s.length-i;if(0<r)if(n===Bt.ASCENDING)for(let t=0;t<r;++t)s.shift();else s.length=i;const a=this.parent;null!=a&&(a.isChanged=!0)}}}get time(){return this._time}set time(t){const e=this._capacity;if(e<=0){if(this._time!==t){this._time=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}else{let i=this._times;null==i&&(i=[],this._times=i),this._time=t;const s=this._order;s===Bt.ASCENDING?i.push(t):i.unshift(t);const n=i.length-e;if(0<n)if(s===Bt.ASCENDING)for(let t=0;t<n;++t)i.shift();else i.length=e;const o=this.parent;null!=o&&(o.isChanged=!0)}}get times(){let t=this._times;return null==t&&(t=[],this._times=t),t}set times(t){const e=t.length;if(0<e){const i=this._capacity;if(i<=0){const i=t[e-1];if(this._time!==i){this._time=i;const t=this.parent;null!=t&&(t.isChanged=!0)}}else{let s=this._times;null==s&&(s=[],this._times=s),this._time=t[e-1];const n=this._order;if(n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(t[i]);else for(let i=0;i<e;++i)s.unshift(t[i]);const o=s.length-i;if(0<o)if(n===Bt.ASCENDING)for(let t=0;t<o;++t)s.shift();else s.length=i;const r=this.parent;null!=r&&(r.isChanged=!0)}}}get state(){return this._state}set state(t){const e=this._capacity;if(e<=0){if(this._state!==t){this._state=t;const e=this.parent;null!=e&&(e.isChanged=!0)}}else{let i=this._states;null==i&&(i=[],this._states=i),this._state=t;const s=this._order;s===Bt.ASCENDING?i.push(t):i.unshift(t);const n=i.length-e;if(0<n)if(s===Bt.ASCENDING)for(let t=0;t<n;++t)i.shift();else i.length=e;const o=this.parent;null!=o&&(o.isChanged=!0)}}get states(){let t=this._states;return null==t&&(t=[],this._states=t),t}set states(t){const e=t.length;if(0<e){const i=this._capacity;if(i<=0){const i=t[e-1];if(this._state!==i){this._state=i;const t=this.parent;null!=t&&(t.isChanged=!0)}}else{let s=this._states;null==s&&(s=[],this._states=s),this._state=t[e-1];const n=this._order;if(n===Bt.ASCENDING)for(let i=0;i<e;++i)s.push(t[i]);else for(let i=0;i<e;++i)s.unshift(t[i]);const o=s.length-i;if(0<o)if(n===Bt.ASCENDING)for(let t=0;t<o;++t)s.shift();else s.length=i;const r=this.parent;null!=r&&(r.isChanged=!0)}}}get capacity(){return this._capacity}set capacity(t){if(this._capacity<t)this._capacity=t;else if(t<this._capacity){this._capacity=t;let e=!1;const i=this._order,s=this._values;if(null!=s){const n=s.length-t;if(0<n){if(i===Bt.ASCENDING)for(let t=0;t<n;++t)s.shift();else s.length=t;e=!0}}const n=this._times;if(null!=n){const s=n.length-t;if(0<s){if(i===Bt.ASCENDING)for(let t=0;t<s;++t)n.shift();else n.length=t;e=!0}}const o=this._states;if(null!=o){const s=o.length-t;if(0<s){if(i===Bt.ASCENDING)for(let t=0;t<s;++t)o.shift();else o.length=t;e=!0}}if(e){const t=this.parent;null!=t&&(t.isChanged=!0)}}}get order(){return this._order}set order(t){this._order=t}remove(t){let e=!1;const i=this._values;null!=i&&0<=t&&t<i.length&&(i.splice(t,1),e=!0);const s=this._times;null!=s&&0<=t&&t<s.length&&(s.splice(t,1),e=!0);const n=this._states;if(null!=n&&0<=t&&t<n.length&&(n.splice(t,1),e=!0),e){const t=this.parent;null!=t&&(t.isChanged=!0)}}removeAll(t){let e=!1;const i=t.slice(0).sort(Ht),s=i.length,n=this._values;if(null!=n)for(let t=s-1;0<=t;--t){const s=i[t];0<=s&&s<n.length&&(n.splice(s,1),e=!0)}const o=this._times;if(null!=o)for(let t=s-1;0<=t;--t){const s=i[t];0<=s&&s<o.length&&(o.splice(s,1),e=!0)}const r=this._states;if(null!=r)for(let t=s-1;0<=t;--t){const s=i[t];0<=s&&s<r.length&&(r.splice(s,1),e=!0)}if(e){const t=this.parent;null!=t&&(t.isChanged=!0)}}clear(){let t=!1;const e=this._values;null!=e&&(e.length=0,t=!0);const i=this._times;null!=i&&(i.length=0,t=!0);const s=this._states;if(null!=s&&(s.length=0,t=!0),t){const t=this.parent;null!=t&&(t.isChanged=!0)}}toDirty(){const t=this.parent;null!=t&&(t.isChanged=!0)}copy(t){return this.id=t.id,this.as=t.as,this.type=t.type,this.scope=t.scope,this.initial=t.initial,this.format=t.format,this.formatter=t.formatter,this.range.copy(t.range),this._value=t.value,this._time=t.time,this._state=t.state,this._capacity=t.capacity,this}isEquals(t){return this.id===t.id&&this.as===t.as&&this.type===t.type&&this.scope===t.scope&&this.initial===t.initial&&this.formatter===t.formatter&&this.range.isEquals(t.range)}serialize(t){const e=t.addData(this.id),i=t.addResource(this.as),s=t.addResource(this.initial),n=t.addResource(this.format.trim()),o=this.range.serialize(t);return t.addResource(`[${e},${s},${n},${o},${this._capacity},${this._order},${this.type},${this.scope},${i}]`)}deserialize(t,e){var i,s;const n=e.resources;if(0<=t&&t<n.length){let o=e.getDataValue(t);null==o&&(o=JSON.parse(n[t]),e.setDataValue(t,o)),this.id=e.data[o[0]]||"";const r=o[8];this.as=null!=r&&n[r]||"",this.type=null!==(i=o[6])&&void 0!==i?i:zt.NUMBER,this.scope=null!==(s=o[7])&&void 0!==s?s:Ut.PUBLIC,this.initial=n[o[1]]||"",this.format=n[o[2]]||"",this.range.deserialize(o[3],e),this._capacity=o[4],this._order=o[5]}return this}}class Vt{constructor(){this.values=[]}add(t,e){const i=this.values;return null!=e?i.splice(e,0,t):i.push(t),this}addAll(t){const e=this.values;for(let i=0,s=t.length;i<s;++i)e.push(t[i]);return this}clearAndAdd(t){return this.clear(),this.add(t),this}clearAndAddAll(t){return this.clear(),this.addAll(t),this}indexOf(t){const e=this.values;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return i;for(let i=0,s=e.length;i<s;++i){const s=e[i];if(s[0]===t[0]&&s[1]===t[1]&&s[2]===t[2])return i}return-1}get(t){const e=this.values;return 0<=t||t<e.length?e[t]:null}set(t,e){const i=this.values;if(0<=t||t<i.length){const s=i[t];return i[t]=e,s}return null}remove(t){const e=this.values;return 0<=t||t<e.length?e.splice(t,1)[0]:null}clear(){return this.values.length=0,this}size(){return this.values.length}swap(t,e){const i=this.values,s=i[e];return i[e]=i[t],i[t]=s,this}copy(t){this.clearAndAddAll(t.values)}serialize(t){const e=this.values;if(e.length<=0)return-1;let i="[",s="";for(let n=0,o=e.length;n<o;++n){const o=e[n];i+=`${s}${t.addResource(o[0])},${t.addResource(o[1])},${t.addResource(o[2])}`,s=","}return i+="]",t.addResource(i)}deserialize(t,e){const i=this.values;i.length=0;const s=e.resources,n=s.length;if(0<=t&&t<n){let o=e.getDataMapping(t);null==o&&(o=JSON.parse(s[t]),e.setDataMapping(t,o));for(let t=0,e=o.length;t<e;t+=3){const e=o[t],r=o[t+1],a=o[t+2];i.push([0<=e&&e<n?s[e]:"",0<=r&&r<n?s[r]:"",0<=a&&a<n?s[a]:""])}}}}class Wt{get ids(){const t=this._data;if(null==t)return[];const e=[];return t.forEach((t,i)=>{e.push(i)}),e}add(t,e){var i;const s=null!==(i=this._data)&&void 0!==i?i:this._data=new Map,n=s.get(t);null==n?s.set(t,[e]):n.push(e)}set(t,e,i,s,n,o){const r=this._data;if(null==r)return!1;const a=r.get(t);if(null==a)return!1;const h=a.length;if(h<=0)return!1;for(let t=0;t<h;++t){const r=a[t];r.range.set(n,o),void 0!==i&&(r.time=i),void 0!==s&&(r.state=s),r.value=e}return!0}toDirty(t){const e=this._data;if(null==e)return!1;const i=e.get(t);if(null==i)return!1;const s=i.length;if(s<=0)return!1;for(let t=0;t<s;++t)i[t].toDirty();return!0}each(t){const e=this._data;if(null==e)return null;let i=null;return e.forEach((e,s)=>{null==i&&!1===t(s)&&(i=s)}),i}}class Kt{constructor(){this._data=new Map}set(t,e){return this._data.set(t,e),this}get(t){var e;return null!==(e=this._data.get(t))&&void 0!==e?e:null}contains(t){return this._data.has(t)}remove(t){const e=this._data,i=e.get(t);return e.delete(t),null!=i?i:null}clear(){return this._data.clear(),this}size(){return this._data.size}each(t){let e=!1;return this._data.forEach((i,s)=>{e||!1===t(i,s)&&(e=!0)}),this}copy(t){const e=this._data;return e.clear(),t.each((t,i)=>{e.set(i,t)}),this}serialize(t){const e=this._data;if(e.size<=0)return-1;const i=[];return e.forEach((e,s)=>{const n=t.addResource(e),o=t.addResource(s);i.push(o,n)}),t.addResource(JSON.stringify(i))}deserialize(t,e){const i=this._data;i.clear();const s=e.resources,n=s.length;if(0<=t&&t<n){let o=e.getDataSystem(t);null==o&&(o=JSON.parse(s[t]),e.setDataSystem(t,o));for(let t=0,e=o.length;t<e;t+=2){const e=o[t];if(0<=e&&e<n){const r=s[e],a=o[t+1];0<=a&&a<n&&i.set(r,s[a])}}}}}let Xt,Yt;class jt{constructor(){this._values=[],this._isChanged=!0}get values(){return this._values}get isChanged(){return this._isChanged}set isChanged(t){this._isChanged=t}get id(){const t=this._values;return 0<t.length?t[0].id:""}get as(){const t=this._values;return 0<t.length?t[0].as:""}get type(){const t=this._values;return 0<t.length?t[0].type:zt.NUMBER}get scope(){const t=this._values;return 0<t.length?t[0].scope:Ut.PRIVATE}get initial(){const t=this._values;return 0<t.length?t[0].initial:""}get format(){const t=this._values;return 0<t.length?t[0].format:""}get range(){const t=this._values;return 0<t.length?t[0].range:null!=Xt?Xt:Xt=new Pt}get value(){const t=this._values;return 0<t.length?t[0].value:0}set value(t){const e=this._values;0<e.length&&(e[0].value=t)}get nvalue(){const t=this._values;return 0<t.length?t[0].nvalue:0}get time(){const t=this._values;return 0<t.length?t[0].time:0}set time(t){const e=this._values;0<e.length&&(e[0].time=t)}get state(){const t=this._values;return 0<t.length?t[0].state:Ft.UNKNOWN}set state(t){const e=this._values;0<e.length&&(e[0].state=t)}get capacity(){const t=this._values;return 0<t.length?t[0].capacity:0}set capacity(t){const e=this._values;0<e.length&&(e[0].capacity=t)}get alias(){let t=this._alias;return null==t&&(t=this.newAlias(),this._alias=t),t}newAlias(){const t=this._values,e=t.length;if(0<e){const i={};for(let s=0;s<e;++s){const e=t[s];i[e.as||e.id]=e}return i}return null!=Yt?Yt:Yt={}}get mapping(){let t=this._mapping;return null==t&&(t=this.newMapping(),this._mapping=t),t}newMapping(){return new Vt}getMapping(){return this._mapping}get private(){let t=this._private;return null==t&&(t=this.newPrivate(),this._private=t),t}newPrivate(){return new Wt}getPrivate(){return this._private}get system(){let t=this._system;return null==t&&(t=this.newSystem(),this._system=t),t}newSystem(){return new Kt}getSystem(){return this._system}add(t,e){const i=this._values;t.parent=this,void 0===e?i.push(t):i.splice(e,0,t)}set(t,e){const i=this._values;if(0<=t&&t<i.length){const s=i[t];return e.parent=this,i[t]=e,s.parent=void 0,s}return null}remove(t){const e=this._values;0<=t&&t<e.length&&(e.splice(t,1)[0].parent=void 0)}indexOf(t){const e=this._values,i=e.length;for(let s=0;s<i;++s)if(e[s]===t)return s;for(let s=0;s<i;++s)if(e[s].isEquals(t))return s;for(let s=0;s<i;++s)if(e[s].id===t.id)return s;return-1}get(t){const e=this._values;return 0<=t&&t<e.length?e[t]:null}size(){return this._values.length}swap(t,e){const i=this._values,s=i[e];i[e]=i[t],i[t]=s}copy(t){const e=this._values;e.length=0;for(let i=0,s=t.size();i<s;++i){const s=t.get(i);if(null!=s){const t=(new Gt).copy(s);t.parent=this,e.push(t)}}const i=t.getMapping();i&&this.mapping.copy(i);const s=t.getSystem();return s&&this.system.copy(s),this}serialize(t){const e=this._values,i=[];for(let s=0,n=e.length;s<n;++s)i.push(e[s].serialize(t));const s=this._mapping;if(null!=s){i.push(s.serialize(t));const e=this._system;return null!=e?t.addResource(`[${JSON.stringify(i)},${e.serialize(t)}]`):t.addResource(`[${JSON.stringify(i)}]`)}{const e=this._system;return null!=e?(i.push(-1),t.addResource(`[${JSON.stringify(i)},${e.serialize(t)}]`)):t.addResource(JSON.stringify(i))}}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getData(t);null==s&&(s=JSON.parse(i[t]),e.setData(t,s));const n=this._values;if(n.length=0,this.isMapped(s)){const t=s[0],i=t.length;for(let s=0,o=i-1;s<o;++s){const i=t[s],o=new Gt;o.parent=this,o.deserialize(i,e),n.push(o)}const o=t[i-1];0<=o&&this.mapping.deserialize(o,e);const r=s[1];null!=r&&0<=r&&this.system.deserialize(r,e)}else for(let t=0,i=s.length;t<i;++t){const i=s[t],o=new Gt;o.parent=this,o.deserialize(i,e),n.push(o)}}}isMapped(t){return 0<t.length&&vt(t[0])}}class $t{constructor(t,e,i){this._parent=t,this._horizontal=e,this._vertical=i}get horizontal(){return this._horizontal}set horizontal(t){this._horizontal!==t&&(this._horizontal=t,this._parent.updateUploaded())}get vertical(){return this._vertical}set vertical(t){this._vertical!==t&&(this._vertical=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.horizontal,t.vertical)}set(t,e){let i=!1;null!=t&&this._horizontal!==t&&(this._horizontal=t,i=!0),null!=e&&this._vertical!==e&&(this._vertical=e,i=!0),i&&this._parent.updateUploaded()}toObject(){return{horizontal:this._horizontal,vertical:this._vertical}}serialize(t){return t.addResource(`[${this._horizontal},${this._vertical}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getAlign(t);if(null!=s)this.set(s[0],s[1]);else{const s=JSON.parse(i[t]);e.setAlign(t,s),this.set(s[0],s[1])}}}}class qt{constructor(t,e,i){this._parent=t,this._horizontal=e,this._vertical=i}get horizontal(){return this._horizontal}set horizontal(t){this._horizontal!==t&&(this._horizontal=t,this._parent.updateUploaded())}get vertical(){return this._vertical}set vertical(t){this._vertical!==t&&(this._vertical=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.horizontal,t.vertical)}set(t,e){let i=!1;null!=t&&this._horizontal!==t&&(this._horizontal=t,i=!0),null!=e&&this._vertical!==e&&(this._vertical=e,i=!0),i&&this._parent.updateUploaded()}toObject(){return{horizontal:this._horizontal,vertical:this._vertical}}serialize(t){return t.addResource(`[${this._horizontal},${this._vertical}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getMargin(t);if(null!=s)this.set(s[0],s[1]);else{const s=JSON.parse(i[t]);e.setMargin(t,s),this.set(s[0],s[1])}}}}class Zt{constructor(t,e,i,s,n){this._parent=t,this._enable=e,this._color=i,this._alpha=s,this._width=n}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this._parent.updateUploaded())}copy(t){t&&this.set(t.enable,t.color,t.alpha,t.width)}set(t,e,i,s){let n=!1;void 0!==t&&this._enable!==t&&(this._enable=t,n=!0),void 0!==e&&this._color!==e&&(this._color=e,n=!0),void 0!==i&&this._alpha!==i&&(this._alpha=i,n=!0),void 0!==s&&this._width!==s&&(this._width=s,n=!0),n&&this._parent.updateUploaded()}clone(){return new Zt(this._parent,this._enable,this._color,this._alpha,this._width)}toObject(){return{enable:this._enable,color:this._color,alpha:this._alpha,width:this._width}}serialize(t){const e=`[${this._enable?1:0},${this._color},${this._alpha},${this._width}]`;return t.addResource(e)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){const s=e.getTextOutline(t);if(null!=s)this.set(!!s[0],s[1],s[2],s[3]);else{const s=JSON.parse(i[t]);e.setTextOutline(t,s),this.set(!!s[0],s[1],s[2],s[3])}}}}class Jt{constructor(t,e,i,s,n,o){this._parent=t,this._enable=!0,this._value=e,this._plength=this._length=e.length,this._color=i,this._alpha=s,this._family=n,this._size=o,this._weight=T.NORMAL,this.align=new $t(t,E.CENTER,y.MIDDLE),this.offset=new qt(t,0,0),this._style=w.NORMAL,this.spacing=new qt(t,0,0),this.outline=new Zt(t,!1,16777215,1,.5),this._direction=x.LEFT_TO_RIGHT,this.padding=new qt(t,10,10),this._clipping=!1,this._fitting=!1,this._characters=[],this._nacharacters=[],this.updateCharacters(e)}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._parent.updateUploaded())}get value(){return this._value}set value(t){if(this._value!==t){this._value=t;const e=t.length;this._length=e,this._plength<e&&(this._plength=e),this.updateCharacters(t),this.isCompatible()?this._parent.updateUploaded():(this.atlas=void 0,this._parent.toDirty())}}get characters(){return this._characters}get nacharacters(){return this._nacharacters}updateCharacters(t){const e=this._characters,i=e.length;let s=0;const n=this._nacharacters,o=n.length;let r=0;for(let a=0,h=t.length;a<h;){if(t.charCodeAt(a)<=255){const n=t.substring(a,a+1);s<i?e[s]=n:e.push(n),s+=1,a+=1;continue}let l=a+1;for(;l<h;++l){const e=t.charCodeAt(l);if(!(56320<=e&&e<=57343||65024<=e&&e<=65039))break}const c=t.substring(a,l);s<i?e[s]=c:e.push(c),s+=1,r<o?n[r]=c:n.push(c),r+=1,a=l}s<i&&(e.length=s),r<o&&(n.length=r)}isCompatible(){const t=this._parent,e=t.uploaded;if(null==e||!e.isCompatible(t))return!1;const i=this.atlas;if(null==i)return!1;const s=i.characters,n=this._nacharacters;for(let t=0,e=n.length;t<e;++t)if(!s.has(n[t]))return!1;return!0}get length(){return this._length}get plength(){return this._plength}get family(){return this._family}set family(t){this._family!==t&&(this._family=t,this._parent.toDirty())}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this._parent.updateUploaded())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this._parent.updateUploaded())}get size(){return this._size}set size(t){this._size!==t&&(this._size=t,this._parent.updateUploaded())}get weight(){return this._weight}set weight(t){this._weight!==t&&(this._weight=t,this._parent.updateUploaded())}get style(){return this._style}set style(t){this._style!==t&&(this._style=t,this._parent.updateUploaded())}get direction(){return this._direction}set direction(t){this._direction!==t&&(this._direction=t,this._parent.updateUploaded())}get clipping(){return this._clipping}set clipping(t){this._clipping!==t&&(this._clipping=t,this._parent.updateUploaded())}get fitting(){return this._fitting}set fitting(t){this._fitting!==t&&(this._fitting=t,this._parent.updateUploaded())}copy(t){return t&&(this.set(t.value,t.color,t.alpha,t.family,t.size,t.weight,t.style,t.direction,t.clipping,t.fitting),this.align.copy(t.align),this.offset.copy(t.offset),this.outline.copy(t.outline),this.spacing.copy(t.spacing),this.padding.copy(t.padding)),this}set(t,e,i,s,n,o,r,a,h,l){let c=!1,u=!1;if(null!=t&&this._value!==t){this._value=t;const e=t.length;this._length=e,this._plength<e&&(this._plength=e),this.updateCharacters(t),this.isCompatible()?u=!0:(this.atlas=void 0,c=!0)}return null!=e&&this._color!==e&&(this._color=e,u=!0),null!=i&&this._alpha!==i&&(this._alpha=i,u=!0),null!=s&&this._family!==s&&(this._family=s,c=!0),null!=n&&this._size!==n&&(this._size=n,u=!0),null!=o&&this._weight!==o&&(this._weight=o,u=!0),null!=r&&this._style!==r&&(this._style=r,u=!0),null!=a&&this._direction!==a&&(this._direction=a,u=!0),null!=h&&this._clipping!==h&&(this._clipping=h,u=!0),null!=l&&this._fitting!==l&&(this._fitting=l,u=!0),c?this._parent.toDirty():u&&this._parent.updateUploaded(),this}toObject(){return{value:this._value,color:this._color,alpha:this._alpha,family:this._family,size:this._size,weight:this._weight,align:this.align.toObject(),offset:this.offset.toObject(),style:this._style,outline:this.outline.toObject(),direction:this._direction,spacing:this.spacing.toObject(),padding:this.padding.toObject(),clipping:this._clipping,fitting:this._fitting}}serialize(t){const e=t.addResource(this._value),i=t.addResource(this._family),s=this.align.serialize(t),n=this.offset.serialize(t),o=this.outline.serialize(t),r=this.spacing.serialize(t),a=this.padding.serialize(t),h=this._clipping?1:0,l=this._fitting?1:0,c=`[${e},${this._color},${this._alpha},${i},${this._size},${this._weight},${s},${n},${this._style},${o},${r},${this._direction},${a},${h},${l}]`;return t.addResource(c)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getText(t);null==s&&(s=JSON.parse(i[t]),e.setText(t,s)),this.set(i[s[0]]||"",s[1],s[2],i[s[3]]||"auto",s[4],s[5],s[8],s[11],!!s[13],!!s[14]),this.align.deserialize(s[6],e),this.offset.deserialize(s[7],e),this.outline.deserialize(s[9],e),this.spacing.deserialize(s[10],e),this.padding.deserialize(s[12],e)}}}const Qt=t=>{const e=t.points;let i="["+t.direction;for(let t=0,s=e.length,n=1;t<s;t+=1,n+=3){const s=e[t];i+=`,${s.color},${s.alpha},${s.position}`}return i+="]",i};class te extends kt{constructor(t){super(t),this.size=this.newSize(),this.fill=this.newFill(),this.stroke=this.newStroke(),this._radius=q.RADIUS,this._corner=nt.ALL;const e=new jt;this.data=e,this.tag=e,this.text=this.newText()}newSize(){return new t.ObservablePoint(()=>{this.onSizeChange()},void 0,q.SIZE_X,q.SIZE_Y)}newFill(){return new J(this,!0,q.FILL_COLOR,q.FILL_ALPHA)}newStroke(){return new Lt(this,!0,q.STROKE_COLOR,q.STROKE_ALPHA,q.STROKE_WIDTH,q.STROKE_ALIGN,q.STROKE_SIDE,q.STROKE_STYLE)}newText(){return new Jt(this,q.TEXT_VALUE,q.TEXT_COLOR,q.TEXT_ALPHA,q.TEXT_FAMILY,q.TEXT_SIZE)}get corner(){return this._corner}set corner(t){this._corner!==t&&(this._corner=t,this.updateUploaded())}get radius(){return this._radius}set radius(t){this._radius!==t&&(this._radius=t,this.updateUploaded())}get image(){return this._image}set image(t){if(this._image!==t){this._image=null!=t?t:void 0;const e=this.parent;null!=e&&e.toDirty()}}serializeImage(t){const e=this._image;return null!=e?t.addResource(e.url):-1}serializeGradient(t){const e=this.gradient;return null!=e?(null==e.serialized&&(e.serialized=Qt(e)),t.addResource(e.serialized)):-1}}const ee=(t,e,i,s,n,o,r)=>{if(t.fill.enable){const t=s*s,o=n*n;if(e*e*o+i*i*t<=t*o)return!0}else if(0<o){const t=o*r,a=e*e,h=i*i,l=Math.max(0,s-t),c=Math.max(0,n-t),u=l*l,d=c*c;if(u*d<=a*d+h*u){const t=s*s,e=n*n;if(a*e+h*t<=t*e)return!0}}return!1},ie=(t,e,i,s,n,o,r)=>{if(It(e,i,s,n)){if(t.fill.enable)return!0;{const a=t.stroke.side;if(0<o&&a!==V.NONE){const t=o*r,h=Math.max(0,s-t),l=Math.max(0,n-t);if(!It(e,i,h,l))return!(a!==V.ALL&&!(e<=-h?i<=-l?a&V.TOP_OR_LEFT:+l<=i?a&V.BOTTOM_OR_LEFT:a&V.LEFT:+h<=e?i<=-l?a&V.TOP_OR_RIGHT:+l<=i?a&V.BOTTOM_OR_RIGHT:a&V.RIGHT:i<=-l?a&V.TOP:+l<=i&&a&V.BOTTOM))}}}return!1},se=(t,e,i,s,n)=>+i*t+s-e<=0&&-i*t+s-e<=0&&e<=n,ne=(t,e,i,s,n,o,r)=>{const a=2*n/s;if(t.fill.enable){if(se(e,i,a,-n,+n))return!0}else if(0<o){const t=o*r;if(se(e,i,a,-n,+n)){const o=2*s*n/(s+Math.sqrt(s*s+4*n*n)),r=n-o,h=r+(-n-r)*Math.max(0,o-t)/o;if(!se(e,i,a,h,n-t))return!0}}return!1},oe=(t,e,i)=>.5*(i+t*e);class re extends te{getHitTestSize(t){const e=this._points.formatted;if("boundary"in e){const i=e.boundary;t.width=Math.max(Math.abs(i[0]),Math.abs(i[2])),t.height=Math.max(Math.abs(i[1]),Math.abs(i[3]))}else super.getHitTestSize(t);return t}toMarkerSize(t){let e=0;const i=t.getMarker();if(i){const t=i.head;if(t.type!==Z.NONE){const i=t.size;e=Math.max(e,2*Math.max(Math.abs(i.x),Math.abs(i.y)))}const s=i.tail;if(s.type!==Z.NONE){const t=s.size;e=Math.max(e,2*Math.max(Math.abs(t.x),Math.abs(t.y)))}}return e}containsAbsMarker(t,e,i,s,n,o){const r=t.type;if(r!==Z.NONE){const a=t.transform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,p=a.ty,_=1/(h*u-c*l),g=(u*e-c*i+p*c-d*u)*_,f=(h*i-l*e-p*h+d*l)*_,m=t.size;let v=.5*m.x,T=.5*m.y;v<0&&(v=-v,e=-e),T<0&&(T=-T,i=-i);const w=s*n*o;switch(v+=w,T+=w,r){case Z.CIRCLE:return ee(this,g,f,v,T,s,n);case Z.TRIANGLE:return ne(this,g,f,v,T,s,n);case Z.RECTANGLE:return ie(this,g,f,v,T,s,n)}}return!1}containsAbs(t,e,i,s,n,o,r){const a=this._points,h=oe(n,o,0),l=h+this.toMarkerSize(a);if(this.containsAbsBBox(t,e,i+l,s+l)){const l=a.getMarker();if(l){if(this.containsAbsMarker(l.head,t,e,n,o,r))return!0;if(this.containsAbsMarker(l.tail,t,e,n,o,r))return!0}const c=this.calcHitPointAbsHitTester;return a.calcHitPointAbs(t,e,i,s,h,null,c,null)}return!1}calcHitPart(t,e){const i=this.toHitTestData(t,e),s=i.strokeWidth,n=i.strokeScale,o=oe(s,n,0),r=this._points,a=o+this.toMarkerSize(r),h=i.x,l=i.y,c=i.width,u=i.height;if(this.containsAbsBBox(h,l,c+a,u+a)){const t=r.getMarker();if(t){const e=i.strokeAlign;if(this.containsAbsMarker(t.head,h,l,s,n,e))return st.MARKER_HEAD;if(this.containsAbsMarker(t.tail,h,l,s,n,e))return st.MARKER_TAIL}const e=this.calcHitPointAbsHitTester;if(r.calcHitPointAbs(h,l,c,u,o,null,e,null))return st.LINE}return this.containsText(t,e)?st.TEXT:this.containsChildren(t,e)?st.CHILDREN:st.NONE}calcHitPoint(t,e,i,s,n,o){const r=this._points,a=this.toHitTestData(t,e),h=(i||oe)(a.strokeWidth,a.strokeScale,0);return!!this.containsAbsBBox(a.x,a.y,a.width+h,a.height+h)&&r.calcHitPointAbs(a.x,a.y,a.width,a.height,h,s,n,o)}calcHitPointAbsHitTester(t,e,i,s,n,o,r,a,h){const l=n-i,c=o-s,u=t-i,d=e-s,p=l*l+c*c,_=l*u+c*d,g=u*u+d*d;if(1e-4<p){const t=Math.max(0,Math.min(1,_/p));if(p*t*t-2*_*t+g<a*a)return!0}return!1}}class ae extends re{constructor(t=s.BAR){super(t),this._points=new it(this)}get points(){return this._points}clone(){return new ae(this.type).copy(this)}containsAbsBBox(t,e,i,s){const n=Math.max(0,this._points.size);return super.containsAbsBBox(t,e,i+n,s+n)}serialize(t){const e=super.serialize(t);return e[15]=this._points.serialize(t),e}}class he extends W{constructor(t,e,i){super(t,e,i,4,2),this.pointsId=-1,this.pointsStyle=F.NONE}init(){const t=this.vertexOffset,e=this.indexOffset,i=this.buffer;i.updateIndices(),f(i.indices,t,e),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexStep(t,e){if(e instanceof ae){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=e.stroke,a=r.enable?r.width:0,h=r.style,l=a!==this.strokeWidth||h!==this.strokeStyle,c=K(e),u=this.transformLocalId!==c,d=e.points,p=d.id,_=p!==this.pointsId,g=d.style,f=g!==this.pointsStyle;(!(this.inited&H.VERTEX_AND_STEP)||o||u||l||_||f)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.strokeWidth=a,this.strokeStyle=h,this.transformLocalId=c,this.pointsId=p,this.pointsStyle=g,_&&(this.inited&=~H.UV),t.updateVertices(),t.updateSteps(),m(t.vertices,t.steps,this.vertexOffset,d.values,d.size,a,h,e.transform.internalTransform))}}updateUv(t,e){const i=X(e),s=Y(i);(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId)&&(this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs(),v(t.uvs,this.vertexOffset,j(i)))}}class le{constructor(t,e,i,s,n){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=s,this.indexCount=n,this.inited=H.NONE,this.sizeX=0,this.sizeY=0,this.transformLocalId=0,this.scaleX=1,this.scaleY=1,this.size=0,this.family="auto",this.value="",this.texture=null,this.textureTransformId=0,this.color=0,this.alpha=0,this.weight=0,this.style=0,this.alignHorizontal=0,this.alignVertical=0,this.offsetHorizontal=0,this.offsetVertical=0,this.outlineWidth=0,this.outlineColor=0,this.outlineAlpha=0,this.spacingHorizontal=0,this.spacingVertical=0,this.direction=0,this.paddingHorizontal=0,this.paddingVertical=0,this.clipping=!1,this.fitting=!1}init(){if(0<this.vertexCount){const t=this.buffer,e=this.vertexOffset;t.updateIndices(),O(t.indices,e,this.indexOffset,this.indexCount)}return this.inited|=H.INDEX,this}reinit(t,e,i,s){const n=I(e),o=n<<2,r=n<<1;return this.buffer===t&&this.vertexOffset===i&&this.indexOffset===s&&this.vertexCount===o&&this.indexCount===r||!!t.check(i,s,o,r)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.vertexCount=o,this.indexCount=r,this.init(),!0)}isCompatible(t){return I(t)<<2===this.vertexCount}update(t){if(0<this.vertexCount){const e=t.text.atlas;if(null!=e){const i=this.buffer;this.updateVertex(i,t,e),this.updateColor(i,t),this.updateStep(i,t)}}return this}updateVertex(e,i,s){const n=i.size,o=n.x,r=n.y,a=o!==this.sizeX||r!==this.sizeY,h=K(i),l=this.transformLocalId!==h,c=i.text,u=c.size,d=c.family,p=c.value,_=c.style,g=c.align.horizontal,f=c.align.vertical,m=c.offset.horizontal,v=c.offset.vertical,T=c.spacing.horizontal,w=c.spacing.vertical,E=c.direction,y=c.padding.horizontal,x=c.padding.vertical,C=c.clipping,D=c.fitting,S=c.texture||t.Texture.WHITE,b=Y(S),I=p!==this.value||d!==this.family,O=u!==this.size,A=_!==this.style,R=g!==this.alignHorizontal||f!==this.alignVertical,k=m!==this.offsetHorizontal||v!==this.offsetVertical,L=T!==this.spacingHorizontal||w!==this.spacingVertical||y!==this.paddingHorizontal||x!==this.paddingVertical,N=E!==this.direction,P=this.clipping!==C,B=this.fitting!==D,z=S!==this.texture||b!==this.textureTransformId;if(!(this.inited&H.VERTEX)||a||l||I||O||A||R||k||L||N||P||B||z){this.inited|=H.VERTEX,this.size=u,this.family=d,this.value=p,this.style=_,this.alignHorizontal=g,this.alignVertical=f,this.offsetHorizontal=m,this.offsetVertical=v,this.spacingHorizontal=T,this.spacingVertical=w,this.direction=E,this.paddingHorizontal=y,this.paddingVertical=x,this.clipping=C,this.fitting=D,this.texture=S,this.textureTransformId=b,(O||B||D&&a)&&(this.inited&=~H.STEP),e.updateVertices(),e.updateUvs();const t=i.size;let n=c.world;null==n&&(n=[0,0,0,0,0,0,0,0],c.world=n),M(e.vertices,e.uvs,this.vertexOffset,this.vertexCount,0,0,t.x,t.y,s,u,c.characters,_,g,f,m,v,T,w,E,y,x,C,D,n,j(S),i.transform.internalTransform)}}updateColor(t,e){const i=e.text,s=i.color,n=e.visible&&i.enable?i.alpha:0,o=i.outline,r=o.color,a=e.visible&&i.enable?o.alpha:0;(!(this.inited&H.COLOR)||s!==this.color||n!==this.alpha||s!==this.outlineColor||n!==this.outlineAlpha)&&(this.inited|=H.COLOR,this.color=s,this.alpha=n,this.outlineColor=r,this.outlineAlpha=a,t.updateColors(),G(s,n,r,a,this.vertexOffset,this.vertexCount,t.colors))}updateStep(t,e){const i=e.text,s=i.outline,n=s.enable?s.width:0,o=n!==this.outlineWidth,r=i.weight,a=r!==this.weight;let h=1,l=1;const c=i.world;null!=c&&(h=c[8],l=c[9]);const u=S<Math.abs(this.scaleX-h)||S<Math.abs(this.scaleY-l);(!(this.inited&H.STEP)||a||o||u)&&(this.inited|=H.STEP,this.weight=r,this.outlineWidth=n,this.scaleX=h,this.scaleY=l,t.updateSteps(),A(t.steps,this.vertexOffset,this.vertexCount,i.atlas,i.size,n,r,this.scaleX,this.scaleY))}buildUnit(e){if(0<this.vertexCount){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;s!==e.baseTexture&&(e.baseTexture=s,e.push(i,this.indexOffset))}}}const ce=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=4+a,c=2+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new he(t,i,s),new le(t,i+4,s+2,a,h)]).init(e):null},ue=(t,e,i)=>{const s=t.length;if(e<s)return t;let n="";for(let t=0,o=e-s;t<o;++t)n+=i;return n+t};class de{static toCode(t){return ue(t.toString(16).toUpperCase(),6,"0")}static fromCode(t){const e=t.trim().toLowerCase();if(6===e.length){const t=Number("0x"+e);if(t==t)return t}return null}static fromRgb(t,e,i){return 255*t<<16|255*e<<8|255*i|0}static blend(t,e,i){const s=t>>16&255,n=t>>8&255,o=255&(0|t),r=e>>16&255,a=e>>8&255,h=255&(0|e),l=Math.max(0,Math.min(1,i)),c=1-l;return Math.max(0,Math.min(255,s*c+r*l))<<16|Math.max(0,Math.min(255,n*c+a*l))<<8|0|Math.max(0,Math.min(255,o*c+h*l))}static brighten(t,e){return 0<=e?this.blend(t,16777215,e):this.blend(t,0,-e)}static darken(t,e){return 0<=e?this.blend(t,0,e):this.blend(t,16777215,-e)}static toGrayscale(t){const e=this.toLuma(t);return e<<16|e<<8|e}static toLuma(t){return.2126*(t>>16&255)+.7152*(t>>8&255)+.0722*(255&(0|t))&255}}const pe={NONE:0,POSITION_X:1,POSITION_Y:2,POSITION:3,ROTATION:4,COLOR_FILL:8,COLOR_STROKE:16,COLOR_FILL_AND_STROKE:24,COLOR_TEXT:32,COLOR_TEXT_OUTLINE:64,COLOR:120,VISIBILITY:128,HEIGHT:256,WIDTH:512,SIZE:768,TEXT:1024,CURSOR:2048};class _e{static toBaseFill(t,e){return(e.written&pe.COLOR_FILL?t:e).fill}static toBaseStroke(t,e){return(e.written&pe.COLOR_STROKE?t:e).stroke}static toBaseText(t,e){return(e.written&pe.COLOR_TEXT?t:e).text}static toBaseTextOutline(t,e){return(e.written&pe.COLOR_TEXT_OUTLINE?t:e).text.outline}}const ge={isInitializing:!1};class fe{static from(t,e,i,s,n,o){if(t.trim().length<=0)return i;try{const i="try {with (shape) {with (state) {with (data.alias) {with (environment) {"+(n?`var result = (${t});return (result != null ? ${e}(result) : null);`:`return ${e}(${t});`)+"}}}}} catch (e) {"+`return ${s};}`;return null==o?Function("shape","time","environment",i):Function("shape","time","environment",o,i)}catch(t){return i}}static ofNumberOrNull(t){return this.from(t,"Number",this.NULL,"null",!0)}static ofStringOrNull(t){return this.from(t,"String",this.NULL,"null",!0)}static ofUnknown(t){return this.from(t,"",this.NULL,"null",!1)}static ofNumber(t){return this.from(t,"Number",this.ZERO,"0",!1)}static ofNumberOrOne(t){return this.from(t,"Number",this.ONE,"1",!1)}static ofNumberOrOneHundred(t){return this.from(t,"Number",this.ONE_HUNDRED,"100",!1)}static ofString(t){return this.from(t,"String",this.EMPTY,'""',!1)}static ofBoolean(t){return this.from(t,"Boolean",this.TRUE,"true",!1)}static ofBooleanOrTrue(t){return this.from(t,"Boolean",this.TRUE,"true",!1)}static ofBooleanOrFalse(t){return this.from(t,"Boolean",this.FALSE,"false",!1)}static ofElementOrNull(t){return this.from(t,"",void 0,"null",!1,"container")}}fe.NULL=()=>null,fe.ZERO=()=>0,fe.ONE=()=>1,fe.ONE_HUNDRED=()=>100,fe.EMPTY=()=>"",fe.TRUE=()=>!0,fe.FALSE=()=>!1;class me{constructor(t){this.reset=t||pe.NONE}initialize(t,e){}execute(t,e,i){}onResize(t,e){}onFocus(t,e){}onBlur(t,e){}onClick(t,e,i){}onDblClick(t,e,i,s){}onDowning(t,e,i){}onDown(t,e,i){}onMove(t,e,i){}onOver(t,e,i){}onOut(t,e,i){}onUp(t,e,i){}onUpOutside(t,e,i){}onPressed(t,e,i){}onUnpressed(t,e,i){}onKeyDown(t,e,i){}onKeyUp(t,e,i){}onRightClick(t,e,i){}onRightDowning(t,e,i){}onRightDown(t,e,i){}onRightUp(t,e,i){}onRightUpOutside(t,e,i){}onRightPressed(t,e,i){}onRightUnpressed(t,e,i){}onRender(t,e,i,s){}}class ve extends me{constructor(t,e){super(e),this.condition=fe.ofBoolean(t.condition)}}class Te extends ve{constructor(t,e){super(t,e),this.interval=t.interval}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.interval,n=s<<1,o=i%n;o<s?(this.toOff(t,e),e.effect=i+(s-o)):(this.toOn(t,e),e.effect=i+(n-o))}}toOn(t,e){}toOff(t,e){}}class we extends Te{constructor(t){super(t,pe.COLOR)}toOn(t,e){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.brighten(i.color,.5),i.alpha);const s=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.brighten(s.color,.5),s.alpha);const n=_e.toBaseText(t,e);t.text.set(void 0,de.brighten(n.color,.5),n.alpha);const o=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.brighten(o.color,.5),o.alpha),e.written|=this.reset}}class Ee extends Te{constructor(t){super(t,pe.COLOR_FILL),this.color=t.color,this.alpha=t.alpha}toOn(t,e){t.fill.set(void 0,this.color,this.alpha),e.written|=this.reset}}class ye extends Te{constructor(t){super(t,pe.COLOR_STROKE),this.color=t.color,this.alpha=t.alpha}toOn(t,e){t.stroke.set(void 0,this.color,this.alpha),e.written|=this.reset}}class xe extends Te{constructor(t){super(t,pe.COLOR)}toOn(t,e){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.darken(i.color,.5),i.alpha);const s=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.darken(s.color,.5),s.alpha);const n=_e.toBaseText(t,e);t.text.set(void 0,de.darken(n.color,.5),n.alpha);const o=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.darken(o.color,.5),o.alpha),e.written|=this.reset}}class Ce extends Te{constructor(t){super(t,pe.COLOR_FILL_AND_STROKE)}toOn(t,e){const i=_e.toBaseFill(t,e);t.fill.set(void 0,i.color,.5*i.alpha);const s=_e.toBaseStroke(t,e);t.stroke.set(void 0,s.color,.5*s.alpha),e.written|=this.reset}}class De extends Te{constructor(t){super(t,pe.VISIBILITY)}toOn(t,e){t.visible=!0,e.written|=this.reset}toOff(t,e){t.visible=!1,e.written|=this.reset}}const Se={VISIBILITY:0,BRIGHTEN:1,DARKEN:2,OPACITY:3,COLOR_FILL:4,COLOR_STROKE:5};class be{constructor(t,e){this.type=t,this.condition=e}isEquals(t){return this.type===t.type&&this.condition===t.condition}toLabel(){return this.getTheme().toLabel(this)}getTheme(){var t;return null!==(t=be.THEME)&&void 0!==t?t:be.THEME=$.getInstance().get("EShapeActionValue")}}class Ie extends be{constructor(t,e,i){super(t,e),this.subtype=i}isEquals(t){return super.isEquals(t)&&t instanceof Ie&&this.subtype===t.subtype}}const Oe={SHOW_HIDE:0,BLINK:1,TRANSFORM:2,OPEN:3,EMIT_EVENT:4,CHANGE_COLOR_LEGACY:5,CHANGE_TEXT:6,CHANGE_CURSOR:7,MISC:8,CHANGE_COLOR:9,GESTURE:10,EXTENSION:1e3};class Ae{static toResource(t,e,i){if(0<=t&&t<e.length){const s=e[t];if(wt(s)&&0<=s&&s<i.length)return i[s]}return""}}class Re extends Ie{constructor(t,e,i,s,n){super(Oe.BLINK,e,t),this.interval=i,this.color=s,this.alpha=n}isEquals(t){return super.isEquals(t)&&t instanceof Re&&this.interval===t.interval&&this.color===t.color&&this.alpha===t.alpha}toRuntime(){switch(this.subtype){case Se.BRIGHTEN:return new we(this);case Se.COLOR_FILL:return new Ee(this);case Se.COLOR_STROKE:return new ye(this);case Se.DARKEN:return new xe(this);case Se.OPACITY:return new Ce(this);case Se.VISIBILITY:return new De(this)}}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype},${this.interval},${this.color},${this.alpha}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources);return new Re(t[2],i,t[3],t[4],t[5])}}class Me{static blend(t,e,i){const s=Math.max(0,Math.min(1,i));return Math.max(0,Math.min(1,t*(1-s)+e*s))}}class ke extends ve{constructor(t){super(t,t.subtype<<3)}set(t,e,i,s,n,o){const r=this.reset;if(null!=s){if(null!=n)if(null!=o){if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.blend(i.color,s,o),Me.blend(i.alpha,n,o))}}else r&pe.COLOR_FILL&&t.fill.set(void 0,s,n),r&pe.COLOR_STROKE&&t.stroke.set(void 0,s,n),r&pe.COLOR_TEXT&&t.text.set(void 0,s,n),r&pe.COLOR_TEXT_OUTLINE&&t.text.outline.set(void 0,s,n);else if(null!=o){if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,de.blend(i.color,s,o),i.alpha)}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,de.blend(i.color,s,o),i.alpha)}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,de.blend(i.color,s,o),i.alpha)}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,de.blend(i.color,s,o),i.alpha)}}else{if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,s,i.alpha)}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,s,i.alpha)}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,s,i.alpha)}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,s,i.alpha)}}e.written|=r}else if(null!=n){if(null!=o){if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,i.color,Me.blend(i.alpha,n,o))}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,i.color,Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,i.color,Me.blend(i.alpha,n,o))}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,i.color,Me.blend(i.alpha,n,o))}}else{if(r&pe.COLOR_FILL){const i=_e.toBaseFill(t,e);t.fill.set(void 0,i.color,n)}if(r&pe.COLOR_STROKE){const i=_e.toBaseStroke(t,e);t.stroke.set(void 0,i.color,n)}if(r&pe.COLOR_TEXT){const i=_e.toBaseText(t,e);t.text.set(void 0,i.color,n)}if(r&pe.COLOR_TEXT_OUTLINE){const i=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,i.color,n)}}e.written|=r}}}const Le={COLOR_AND_ALPHA:0,COLOR:1,ALPHA:2,CODE:3,BRIGHTNESS:4};class Ne extends ke{constructor(t){switch(super(t),t.target){case Le.COLOR:this.color=t.color,this.alpha=null;break;case Le.ALPHA:this.color=null,this.alpha=t.alpha;break;default:this.color=t.color,this.alpha=t.alpha}this.blend=fe.ofNumberOrNull(t.blend)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.color,n=this.alpha,o=this.blend(t,i,ge);this.set(t,e,i,s,n,o)}}}const Pe={NONE:0,FILL:1,STROKE:2,TEXT:4,TEXT_OUTLINE:8,FILL_AND_STROKE:3,ALL:15},Be={FILL:0,STROKE:1,FILL_AND_STROKE:2,TEXT:3,TEXT_OUTLINE:4,ALL:5};class ze{static from(t){if(t[0]===Oe.CHANGE_COLOR)return t[2];switch(t[2]){case Be.FILL:return Pe.FILL;case Be.STROKE:return Pe.STROKE;case Be.FILL_AND_STROKE:return Pe.FILL_AND_STROKE;case Be.TEXT:return Pe.TEXT;case Be.TEXT_OUTLINE:return Pe.TEXT_OUTLINE;case Be.ALL:return Pe.ALL}}static unpack(t){const e=[];return t&Pe.FILL&&e.push(Pe.FILL),t&Pe.STROKE&&e.push(Pe.STROKE),t&Pe.TEXT&&e.push(Pe.TEXT),t&Pe.TEXT_OUTLINE&&e.push(Pe.TEXT_OUTLINE),e}static pack(t){let e=Pe.NONE;for(let i=0,s=t.length;i<s;++i)e|=t[i];return e}}class Ue extends Ie{constructor(t,e,i,s,n,o){super(Oe.CHANGE_COLOR,e,t),this.target=i,this.color=s,this.alpha=n,this.blend=o}isEquals(t){return super.isEquals(t)&&t instanceof Ue&&this.target===t.target&&this.color===t.color&&this.alpha===t.alpha&&this.blend===t.blend}toRuntime(){return new Ne(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.blend);return t.addResource(`[${this.type},${e},${this.subtype},${this.target},${this.color},${this.alpha},${i}]`)}static deserialize(t,e){const i=ze.from(t),s=Ae.toResource(1,t,e.resources),n=Ae.toResource(6,t,e.resources);return new Ue(i,s,t[3],t[4],t[5],n)}}class Fe extends ke{constructor(t){super(t),this.brightness=fe.ofNumberOrNull(t.brightness)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.brightness(t,i,ge);this.set(t,e,i,s)}}set(t,e,i,s){const n=this.reset;if(null!=s){const i=this.toAdjusted;if(n&pe.COLOR_FILL){const n=_e.toBaseFill(t,e);t.fill.set(void 0,i(n.color,s),n.alpha)}if(n&pe.COLOR_STROKE){const n=_e.toBaseStroke(t,e);t.stroke.set(void 0,i(n.color,s),n.alpha)}if(n&pe.COLOR_TEXT){const n=_e.toBaseText(t,e);t.text.set(void 0,i(n.color,s),n.alpha)}if(n&pe.COLOR_TEXT_OUTLINE){const n=_e.toBaseTextOutline(t,e);t.text.outline.set(void 0,i(n.color,s),n.alpha)}e.written|=n}}toAdjusted(t,e){return 0<=e?de.brighten(t,+e):de.darken(t,-e)}}class He extends Ie{constructor(t,e,i){super(Oe.CHANGE_COLOR,e,t),this.brightness=i}isEquals(t){return super.isEquals(t)&&t instanceof He&&this.brightness===t.brightness}toRuntime(){return new Fe(this)}serialize(t){const e=t.addResource(this.condition),i=Le.BRIGHTNESS,s=t.addResource(this.brightness);return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}static deserialize(t,e){const i=ze.from(t),s=Ae.toResource(1,t,e.resources),n=Ae.toResource(4,t,e.resources);return new He(i,s,n)}}class Ge extends ke{constructor(t){super(t),this.color=fe.ofNumberOrNull(t.color),this.alpha=fe.ofNumberOrNull(t.alpha),this.blend=fe.ofNumberOrNull(t.blend)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.color(t,i,ge),n=this.alpha(t,i,ge),o=this.blend(t,i,ge);this.set(t,e,i,s,n,o)}}}class Ve extends Ie{constructor(t,e,i,s,n){super(Oe.CHANGE_COLOR,e,t),this.color=i,this.alpha=s,this.blend=n}isEquals(t){return super.isEquals(t)&&t instanceof Ve&&this.color===t.color&&this.alpha===t.alpha&&this.blend===t.blend}toRuntime(){return new Ge(this)}serialize(t){const e=t.addResource(this.condition),i=Le.CODE,s=t.addResource(this.color),n=t.addResource(this.alpha),o=t.addResource(this.blend);return t.addResource(`[${this.type},${e},${this.subtype},${i},${s},${n},${o}]`)}static deserialize(t,e){const i=ze.from(t),s=Ae.toResource(1,t,e.resources),n=Ae.toResource(4,t,e.resources),o=Ae.toResource(5,t,e.resources),r=Ae.toResource(6,t,e.resources);return new Ve(i,s,n,o,r)}}class We extends ve{constructor(t){super(t,pe.CURSOR),this.name=fe.ofStringOrNull(t.name)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.name(t,i,ge);null!=s&&(t.cursor=s,e.written|=this.reset)}}}class Ke extends be{constructor(t,e){super(Oe.CHANGE_CURSOR,t),this.name=e}isEquals(t){return super.isEquals(t)&&t instanceof Ke&&this.name===t.name}toRuntime(){return new We(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.name);return t.addResource(`[${this.type},${e},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(2,t,e.resources);return new Ke(i,s)}}class Xe{format(t,e,i){return i.getHours()<12?"AM":"PM"}}class Ye{format(t,e,i){return i.getHours()<12?"am":"pm"}}class je{format(t,e,i){return String(i.getDate())}}class $e{format(t,e,i){return""+(0|t)}}class qe{constructor(t){this.precision=null!=t?+t.substring(1,t.length):void 0}}class Ze extends qe{format(t,e,i){return t.toExponential(this.precision)}}class Je extends qe{format(t,e,i){return t.toFixed(this.precision)}}class Qe extends qe{format(t,e,i){const s=this.toAbs(t,e,i);return s<1e-24?this.format_(t,1,""):s<1e-21?this.format_(t,1e24,"y"):s<1e-18?this.format_(t,1e21,"z"):s<1e-15?this.format_(t,1e18,"a"):s<1e-12?this.format_(t,1e15,"f"):s<1e-9?this.format_(t,1e12,"p"):s<1e-6?this.format_(t,1e9,"n"):s<.001?this.format_(t,1e6,"μ"):s<1?this.format_(t,1e3,"m"):s<1e3?this.format_(t,1,""):s<1e6?this.format_(t,.001,"k"):s<1e9?this.format_(t,1e-6,"M"):s<1e12?this.format_(t,1e-9,"G"):s<1e15?this.format_(t,1e-12,"T"):s<1e18?this.format_(t,1e-15,"P"):s<1e21?this.format_(t,1e-18,"E"):s<1e24?this.format_(t,1e-21,"Z"):this.format_(t,1e-24,"Y")}toAbs(t,e,i){return Math.abs(t)}format_(t,e,i){return`${(t*e).toFixed(this.precision)}${i}`}}class ti extends qe{format(t,e,i){return t.toPrecision(this.precision)}}class ei{format(t,e,i){return String(i.getHours())}}class ii{format(t,e,i){return String(i.getHours()%12)}}class si{format(t,e,i){return String(i.getMonth()+1)}}class ni{format(t,e,i){return String(i.getMinutes())}}class oi{format(t,e,i){return String(i.getMilliseconds())}}class ri{format(t,e,i){return(100*t|0)+"%"}}class ai{format(t,e,i){return(0|t)+"%"}}class hi{constructor(t,e,i){this.length=t,this.character=e,this.node=i}format(t,e,i){return ue(this.node.format(t,e,i),this.length,this.character)}}class li{constructor(t){this.node=t}format(t,e,i){const s=this.node.format(t,e,i);return 0<s.length&&"-"===s[0]?`(${s.substring(1,s.length)})`:s}}class ci{constructor(t){this.node=t}format(t,e,i){const s=this.node.format(t,e,i);return 0<s.length&&"-"!==s[0]?"+"+s:s}}class ui{format(t,e,i){return Math.round(100*t)+"%"}}class di{format(t,e,i){return Math.round(t)+"%"}}class pi{constructor(t,e,i,s,n,o,r){this.Y=t,this.M=e,this.D=i,this.H=s,this.m=n,this.s=o,this.mi=r}format(t,e,i){return e<1e3?`${this.s.format(t,e,i)}.${this.mi.format(t,e,i)}`:e<6e4?`${this.m.format(t,e,i)}:${this.s.format(t,e,i)}`:e<36e5?`${this.H.format(t,e,i)}:${this.m.format(t,e,i)}`:e<864e5?`${this.M.format(t,e,i)}/${this.D.format(t,e,i)} ${this.H.format(t,e,i)}`:e<2592e6?`${this.M.format(t,e,i)}/${this.D.format(t,e,i)}`:`${this.Y.format(t,e,i)}/${this.M.format(t,e,i)}`}}class _i{constructor(t){this.node=t}format(t,e,i){const s=this.node.format(t,e,i);return 0<s.length&&"-"!==s[0]?" "+s:s}}class gi extends Qe{toAbs(t,e,i){return Math.abs(e)}}class fi{constructor(t){this.str=t}format(t,e,i){return this.str}}class mi{format(t,e,i){return String(i.getFullYear())}}class vi{format(t,e,i){return String(i.getFullYear()%100)}}class Ti{format(t,e,i){const s=i.getTimezoneOffset();return`${s<=0?"+":"-"}${ue(String(Math.floor(Math.abs(s)/60)),2,"0")}:${ue(String(Math.floor(Math.abs(s)%60)),2,"0")}`}}class wi{format(t,e,i){return""+Math.round(t)}}class Ei{format(t,e,i){return String(i.getSeconds())}}let yi=void 0;const xi=(t,e,i)=>{switch(t){case"_":return new hi(e," ",i);case"-":return i;default:return new hi(e,"0",i)}},Ci=(t,e)=>{switch(t){case"_":return new _i(e);case"+":return new ci(e);case"(":return new li(e);default:return e}};class Di{constructor(t){const e=(t=>{let e=0,i=!1;const s=[],n=(()=>{let t=yi;return t?t.lastIndex=0:(t=/%(0|_|-|\+|\()?(\.\d+)?(Y(?:MD?)?|y(?:MD?)?|MD?|D|H(?:ms?)?|h(?:ms?)?|m(?:i|s)?|a|A|s(?:s?i|dt)?|z|%|f(?:si)?|e|g|d|r(?:d|p)|p|P|RP)/g,yi=t),t})();for(;;){const o=n.exec(t);if(null==o){e<t.length&&s.push(new fi(t.substring(e,t.length)));break}{const n=o.index;e<n&&s.push(new fi(t.substring(e,n))),e=n+o[0].length;const r=o[0],a=o[1],h=o[2];switch(o[3]){case"Y":i=!0,s.push(new mi);break;case"YM":i=!0,s.push(new mi,new fi("/"),xi(a,2,new si));break;case"YMD":i=!0,s.push(new mi,new fi("/"),xi(a,2,new si),new fi("/"),xi(a,2,new je));break;case"y":i=!0,s.push(xi(a,2,new vi));break;case"yM":i=!0,s.push(xi(a,2,new vi),new fi("/"),xi(a,2,new si));break;case"yMD":s.push(xi(a,2,new vi),new fi("/"),xi(a,2,new si),new fi("/"),xi(a,2,new je));break;case"M":i=!0,s.push(xi(a,2,new si));break;case"MD":i=!0,s.push(xi(a,2,new si),new fi("/"),xi(a,2,new je));break;case"D":i=!0,s.push(xi(a,2,new je));break;case"H":i=!0,s.push(xi(a,2,new ei));break;case"Hm":i=!0,s.push(xi(a,2,new ei),new fi(":"),xi(a,2,new ni));break;case"Hms":i=!0,s.push(xi(a,2,new ei),new fi(":"),xi(a,2,new ni),new fi(":"),xi(a,2,new Ei));break;case"h":i=!0,s.push(xi(a,2,new ii));break;case"hm":i=!0,s.push(xi(a,2,new ii),new fi(":"),xi(a,2,new ni));break;case"hms":i=!0,s.push(xi(a,2,new ii),new fi(":"),xi(a,2,new ni),new fi(":"),xi(a,2,new Ei));break;case"m":i=!0,s.push(xi(a,2,new ni));break;case"ms":i=!0,s.push(xi(a,2,new ni),new fi(":"),xi(a,2,new Ei));break;case"mi":i=!0,s.push(xi(a,3,new oi));break;case"a":i=!0,s.push(new Ye);break;case"A":i=!0,s.push(new Xe);break;case"s":i=!0,s.push(xi(a,2,new Ei));break;case"sdt":i=!0,s.push(new pi(new mi,xi(a,2,new si),xi(a,2,new je),xi(a,2,new ei),xi(a,2,new ni),xi(a,2,new Ei),xi(a,3,new oi)));break;case"z":i=!0,s.push(new Ti);break;case"%":s.push(new fi("%"));break;case"f":s.push(Ci(a,new Je(h)));break;case"e":s.push(Ci(a,new Ze(h)));break;case"g":s.push(Ci(a,new ti(h)));break;case"rd":s.push(Ci(a,new wi));break;case"d":s.push(Ci(a,new $e));break;case"P":s.push(Ci(a,new ri));break;case"p":s.push(Ci(a,new ai));break;case"RP":s.push(Ci(a,new ui));break;case"rp":s.push(Ci(a,new di));break;case"fsi":s.push(Ci(a,new Qe(h)));break;case"ssi":s.push(Ci(a,new gi(h)));break;default:s.push(new fi(r))}}}return{nodes:s,date:i}})(t);this.date=e.date,this.nodes=e.nodes}format(t,e){const i=this.nodes;let s=Di.DATE;null==s&&(s=new Date,Di.DATE=s),this.date&&s.setTime(t);let n="";for(let o=0,r=i.length;o<r;++o)n+=i[o].format(t,e,s);return n}}class Si{static create(t){return new Di(t)}}class bi extends ve{constructor(t){super(t,pe.TEXT),this.number=fe.ofNumber(t.value),this.formatters=new Map}getFormatter(t,e){const i=this.formatters,s=e.text.value;let n=i.get(s);return void 0===n&&(n=this.newFormatter(s),i.set(s,n)),n}newFormatter(t){return 0<(t=t.trim()).length?Si.create(t):null}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.number(t,i,ge),n=this.getFormatter(t,e);t.text.value=null!=n?n.format(s,0):String(s),e.written|=this.reset}}}class Ii extends ve{constructor(t){super(t,pe.TEXT),this.text=fe.ofString(t.value)}execute(t,e,i){this.condition(t,i,ge)&&(t.text.value=this.text(t,i,ge),e.written|=this.reset)}}const Oi={TEXT:0,NUMBER:1};class Ai extends Ie{constructor(t,e,i){super(Oe.CHANGE_TEXT,e,t),this.value=i}isEquals(t){return super.isEquals(t)&&t instanceof Ai&&this.value===t.value}toRuntime(){switch(this.subtype){case Oi.TEXT:return new Ii(this);case Oi.NUMBER:return new bi(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.value);return t.addResource(`[${this.type},${e},${this.subtype},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources);return new Ai(t[2],i,s)}}const Ri={DIAGRAM:0,PAGE:1,EXTENSION:1e3};class Mi{constructor(t){this._sources=this.newSources(t)}map(t,e,i){const s=this._sources;if(null==s)return!1;const n=t.id,o=n.toLowerCase(),r=o.length;if(r!==n.length)return!1;const a=s[0],h=a.length;if(0!==h&&0!==o.indexOf(a))return!1;const l=Mi.SPANS;l[0]=0,l[1]=h;const c=s.length;for(let t=1;t<c;++t){const e=t<<1,i=s[t],n=i.length;if(0===n)l[e]=r,l[e+1]=r;else{const t=o.indexOf(i,l[e-1]);if(t<0)return!1;l[e]=t,l[e+1]=t+n}}if(null!=e){const i=e.length;let o="";for(let t=0,a=c;t<a;++t){const h=t<i?e[t]:s[t],c=t<<1,u=l[c+1],d=l[c+2];o+=h+n.substring(u,t+1<a?d:r)}t.id=o}return 0<i.length&&(t.initial=i),!0}newSources(t){if(null==t)return null;const e=t.trim();return e.length<=0?null:e.toLowerCase().split(Mi.WILDCARD)}static split(t){if(null==t)return null;const e=t.trim();return e.length<=0?null:e.split(this.WILDCARD)}}Mi.WILDCARD="*",Mi.SPANS=[];class ki{constructor(t,e,i,s,n){this.resources=t.resources,this.data=t.data||t.tags||t.resources,this.pieces=e,this.pieceData=i,this.mode=s,this.depth=n,this._actions=new Map,this._fills=new Map,this._strokes=new Map,this._data=new Map,this._dataValues=new Map,this._dataMapping=new Map,this._dataMappers=new Map,this._dataDestinations=new Map,this._dataSystem=new Map,this._ranges=new Map,this._aligns=new Map,this._margins=new Map,this._texts=new Map,this._textOutlines=new Map,this._capabilities=new Map,this._extensions=new Map}getAction(t){return this._actions.get(t)}setAction(t,e){this._actions.set(t,e)}getFill(t){return this._fills.get(t)}setFill(t,e){this._fills.set(t,e)}getStroke(t){return this._strokes.get(t)}setStroke(t,e){this._strokes.set(t,e)}getData(t){return this._data.get(t)}setData(t,e){this._data.set(t,e)}getDataValue(t){return this._dataValues.get(t)}setDataValue(t,e){this._dataValues.set(t,e)}getDataMapping(t){return this._dataMapping.get(t)}setDataMapping(t,e){this._dataMapping.set(t,e)}getDataMapper(t){const e=this._dataMappers;let i=e.get(t);return void 0===i&&(i=new Mi(t),e.set(t,i)),i}getDataDestination(t){const e=this._dataDestinations;let i=e.get(t);return void 0===i&&(i=Mi.split(t),e.set(t,i)),i}getDataSystem(t){return this._dataSystem.get(t)}setDataSystem(t,e){this._dataSystem.set(t,e)}getRange(t){return this._ranges.get(t)}setRange(t,e){this._ranges.set(t,e)}getAlign(t){return this._aligns.get(t)}setAlign(t,e){this._aligns.set(t,e)}getMargin(t){return this._margins.get(t)}setMargin(t,e){this._margins.set(t,e)}getText(t){return this._texts.get(t)}setText(t,e){this._texts.set(t,e)}getTextOutline(t){return this._textOutlines.get(t)}setTextOutline(t,e){this._textOutlines.set(t,e)}getCapability(t){return this._capabilities.get(t)}setCapability(t,e){this._capabilities.set(t,e)}getExtension(t){return this._extensions.get(t)}setExtension(t,e){this._extensions.set(t,e)}}const Li={VIEWER:0,EDITOR_DATA_MAPPED:1,EDITOR:2},Ni={NONE:0,TOP:1,RIGHT:2,BOTTOM:4,LEFT:8,ALL:15},Pi={TAIL:1,HEAD:2,ALL:3};class Bi extends te{constructor(t=s.CIRCLE){super(t)}clone(){return new Bi(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&ee(this,t,e,i,s,n,o)}}class zi extends Bi{constructor(t=s.EMBEDDED_ACCEPTOR_EDGE){super(t),this._subtype=Pi.HEAD,this._side=Ni.ALL,this._vvisible=!0}get subtype(){return this._subtype}set subtype(t){this._subtype=t}get side(){return this._side}set side(t){this._side=t}get vvisible(){return this._vvisible}set vvisible(t){this._vvisible=t}clone(){return new zi(this.type).copy(this)}copy(t,e=ht.ALL){return super.copy(t,e),t instanceof zi&&(this._subtype=t.subtype,this._side=t.side,this._vvisible=t.vvisible),this}serialize(t){const e=super.serialize(t);return e[15]=this._subtype|this._side<<2|(this._vvisible?64:0),e}}class Ui{static get(t){const e=this.mappings[t];return null!=e?e:Ot.PRIMITIVE}static contains(t,e){if(null!=t){let i=this.get(t.type);const s=t.getCapability();return null!=s&&(i&=~s.removed,i|=s.added,i&=~s.locked),(i&e)===e}return!1}static set(t,e){this.mappings[t]=e}}Ui.mappings={};const Fi=t=>Math.abs(t)<.001?t<0?-.001:.001:t;class Hi{constructor(e,i,s){this.shape=e,this.base=new t.Point(i,s);const n=e.size;this.shapeBase=new t.Point(n.x,n.y),this.transform=new t.Matrix,e.updateTransform(),e.transform.localTransform.copyTo(this.transform),this.capable=Ui.contains(e,Ot.POSITION)&&Ui.contains(e,Ot.WIDTH)&&Ui.contains(e,Ot.HEIGHT)&&Ui.contains(e,Ot.ROTATION)&&Ui.contains(e,Ot.SKEW)}isCompatible(t){return this.shape===t}reset(t,e,i){this.base.set(e,i);const s=t.size;this.shapeBase.copyFrom(s),t.updateTransform(),t.transform.localTransform.copyTo(this.transform)}update(t,e,i,s,n){if(!this.capable)return;const o=e/this.base.x,r=i/this.base.y,a=this.shapeBase,h=Hi.WORK_TRANSFORM;h.identity().append(this.transform).translate(-s,-n).scale(o,r).translate(+s,+n),t.lock(Mt.TRANSFORM_AND_UPLOADED),this.apply(t,h,Ot.ALL,a),t.unlock(Mt.TRANSFORM_CHILD,!1),t.unlock(Mt.TRANSFORM_THIS|Mt.TRANSFORM_PARENT|Mt.UPLOADED,!0)}apply(t,e,i,s){const n=e.a,o=e.b,r=e.c,a=e.d,h=e.tx,l=e.ty,c=t.transform,u=!!(i&Ot.POSITION),d=!!(i&Ot.ROTATION),p=!!(i&Ot.SKEW),_=!!(i&Ot.WIDTH),g=!!(i&Ot.HEIGHT);if(d||p){const t=Math.atan2(-r,a),e=Math.atan2(+o,n);if(d&&(c.rotation=.5*(t+e)),p){const i=.5*(e-t);c.skew.set(i,i)}}if(u){const t=c.pivot,e=t.x,i=t.y;c.position.set(h+(n*e+r*i),l+(o*e+a*i))}if(null!=s&&(_||g)){const e=Fi(s.x*Math.sqrt(n*n+o*o)),i=Fi(s.y*Math.sqrt(r*r+a*a)),h=t.size;_&&g?h.set(e,i):_?h.x=e:h.y=i}}}Hi.WORK_TRANSFORM=new t.Matrix;class Gi{constructor(e,i,s,n){this._workRectForCalcRect=new t.Rectangle,this._workRectForFit=new t.Rectangle,this._parent=e,this._layouts=[],this._size=new t.Point(i,s),this._isFittable=n}init(){return this}get x(){return this._size.x}set x(t){const e=this._size;if(e.x!==t){const i=e.x;e.x=t,this.onChange(i,e.y)}}get y(){return this._size.y}set y(t){const e=this._size;if(e.y!==t){const i=e.y;e.y=t,this.onChange(e.x,i)}}set(t,e){let i=!1;const s=this._size,n=s.x,o=s.y;return null!=t&&n!==t&&(i=!0,s.x=t),null!=e&&o!==e&&(i=!0,s.y=e),i&&this.onChange(n,o),this}clone(){const t=this._size;return new Gi(this._parent,t.x,t.y,this._isFittable)}copy(){}copyFrom(t){const e=t.x,i=t.y,s=this._size,n=s.x,o=s.y;return n===e&&o===i||(s.x=e,s.y=i,this.onChange(n,o)),this}copyTo(t){return this._size.copyTo(t)}equals(t){return this._size.equals(t)}fit(){return this._isFittable&&this.doFit(),this}doFit(){const t=this._parent;t.lock(Mt.TRANSFORM);const e=this.calcRect(this._workRectForFit),i=this._size;i.set(e.width,e.height),t.updateTransform();const s=t.transform,n=e.x+.5*e.width,o=e.y+.5*e.height,r=s.position,a=s.localTransform,h=a.a,l=a.b,c=a.c,u=a.d,d=s.pivot,p=n-d.x,_=o-d.y;r.set(r.x+(h*p+c*_),r.y+(l*p+u*_)),d.set(n,o),this.reset(t.children,this._layouts,i),t.unlock(Mt.TRANSFORM_CHILD|Mt.TRANSFORM_THIS,!0),t.unlock(Mt.TRANSFORM_PARENT,!1)}reset(t,e,i){for(let s=0,n=Math.min(e.length,t.length);s<n;++s){const n=t[s],o=e[s];if(!o.isCompatible(n)){e.length=s;break}o.reset(n,i.x,i.y)}t.length<e.length&&(e.length=t.length)}calcRect(t){const e=this._parent.children;if(e.length<=0)t.x=0,t.y=0,t.width=0,t.height=0;else{const i=this._workRectForCalcRect;e[0].getBoundsLocal(!1,t);for(let s=1,n=e.length;s<n;++s)e[s].getBoundsLocal(!1,i),t.enlarge(i)}return t}onChange(t,e){const i=this._parent,s=this._size,n=i.transform.pivot;this.onChange_(i.children,this._layouts,s.x,s.y,n.x,n.y,t,e),i.onSizeChange()}onChange_(t,e,i,s,n,o,r,a){for(let r=0,a=Math.min(e.length,t.length);r<a;++r){const a=t[r],h=e[r];if(!h.isCompatible(a)){e.length=r;break}h.update(a,i,s,n,o)}for(let h=e.length,l=t.length;h<l;++h){const l=t[h],c=this.newLayout(l,r,a);c.update(l,i,s,n,o),e.push(c)}e.length!==t.length&&(e.length=t.length)}newLayout(t,e,i){return t.layout||new Hi(t,e,i)}}class Vi{constructor(e,i,s,n,o){this._parent=e,this._x=i,this._y=s,this._base=new t.Point(n,o)}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.onChange())}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.onChange())}get base(){return this._base}init(){return this._base.copyFrom(this),this.onChange(),this}clone(){const t=this._base;return new Vi(this._parent,this._x,this._y,t.x,t.y)}set(t,e){let i=!1;return null!=t&&this._x!==t&&(this._x=t,i=!0),null!=e&&this._y!==e&&(this._y=e,i=!0),i&&this.onChange(),this}copyFrom(t){return t instanceof Vi&&this._base.copyFrom(t.base),this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this.onChange()),this}copyTo(t){return t instanceof Vi&&this._base.copyTo(t.base),t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}fit(){return this}onChange(){const t=this._base;this._parent.transform.scale.set(this._x/t.x,this._y/t.y)}}class Wi{constructor(){}get enable(){return!0}set enable(t){}get color(){return 16777215}set color(t){}get alpha(){return 1}set alpha(t){}copy(t){}set(t,e,i){}clone(){return new Wi}toObject(){return{enable:!0,color:16777215,alpha:1}}serialize(t){return-1}deserialize(t,e){}}class Ki{constructor(){}get enable(){return!1}set enable(t){}get color(){return 16777215}set color(t){}get alpha(){return 1}set alpha(t){}get width(){return 1}set width(t){}get align(){return 0}set align(t){}get side(){return V.NONE}set side(t){}get style(){return r.NONE}set style(t){}copy(t){}set(t,e,i,s,n,o,r){}clone(){return new Ki}toObject(){return{enable:!1,color:16777215,alpha:1,width:1,align:0,side:V.NONE,style:r.NONE}}serialize(t){return-1}deserialize(t,e){}}class Xi extends kt{constructor(t,e,i){super(i),this._mode=t,this._depth=e;const s=this.newData();this.data=s,this.tag=s,this.size=this.newGroupSize(t,e),this.fill=this.newGroupFill(),this.stroke=this.newGroupStroke(),this.text=this.newGroupText()}get mode(){return this._mode}get depth(){return this._depth}newGroupSize(t,e){const i=q.SIZE_X,s=q.SIZE_Y;return t!==Li.VIEWER?new Gi(this,i,s,this.isGroupSizeFittable()):new Vi(this,i,s,i,s)}isGroupSizeFittable(){return!0}newData(){return new jt}newGroupFill(){return new Wi}newGroupStroke(){return new Ki}newGroupText(){return new Jt(this,q.TEXT_VALUE,q.TEXT_COLOR,q.TEXT_ALPHA,q.TEXT_FAMILY,q.TEXT_SIZE)}getBoundsSize(){const t=this.size;return t instanceof Vi?t.base:t}onChildTransformChange(){super.onChildTransformChange(),this.size.fit()}get corner(){return nt.NONE}set corner(t){}get gradient(){}set gradient(t){}serializeGradient(t){return-1}get radius(){return 0}set radius(t){}get image(){}set image(t){}serializeImage(t){return-1}get points(){}set points(t){}containsAbs(t,e,i,s,n,o,r){return!1}}class Yi extends Xi{constructor(t,e,i,n=s.EMBEDDED){super(e,i,n),this._name=t,this._depth=i}get name(){return this._name}get edges(){var t;return null!==(t=this._edges)&&void 0!==t?t:this._edges=this.newEdges()}newEdges(){const t=new Map,e=this.children;if(null!=e){const i=this.size,s=i.x,n=i.y,o=.5*s,r=.5*n;for(let i=0,a=e.length;i<a;++i){const a=e[i],h=a.transform.position,l=h.x+o,c=h.y+r,u=a.children;for(let e=0,i=u.length;e<i;++e){const i=u[e];if(i instanceof zi){i.transform.updateLocalTransform();const e=i.transform.localTransform;t.set(i.id,{type:i.subtype,x:this.toEdgePosition(l,e.tx,o,s),y:this.toEdgePosition(c,e.ty,r,n),normal:this.toEdgeNormal(-e.c,-e.d),size:{x:0,y:0},side:i.side})}}}}return t}toEdgePosition(t,e,i,s){return 1e-5<Math.abs(s)?(t+e-i)/s:0}toEdgeNormal(t,e){const i=t*t+e*e;if(1e-5<i){const s=1/i;return{x:t*s,y:e*s}}return{x:0,y:-1}}isGroupSizeFittable(){return!1}newGroupSize(t,e){const i=q.SIZE_X,s=q.SIZE_Y;return t!==Li.VIEWER&&e<=0?new Gi(this,i,s,this.isGroupSizeFittable()):new Vi(this,i,s,i,s)}clone(){const t=this.newClone().copy(this),e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].clone();s.parent=t,t.children.push(s)}return t.onChildTransformChange(),t.toDirty(),t}newClone(){return new(0,this.constructor)(this._name,this._mode,this._depth,this.type)}serializeChildren(t){return[]}serializeImage(t){return-1}serializeGradient(t){return-1}serialize(t){const e=super.serialize(t);return e[15]=t.addPiece(this._name),e}addUuid(t){this.uuid=t.addUuid(this.uuid)}updateUuid(t){this.uuid=t.updateUuid(this.uuid)}}class ji{constructor(t){this._shapes=t}find(t){return this.getUuidToShape().get(t)}getUuidToShape(){let t=this._uuidToShape;return null==t&&(t=this.newUuidToShape(),this._uuidToShape=t),t}newUuidToShape(){const t=new Map;return this.fillUuidToShape(this._shapes,t),t}fillUuidToShape(t,e){for(let i=0,s=t.length;i<s;++i){const s=t[i];if(e.set(s.uuid,s),!(s instanceof Yi)){const t=s.children;0<t.length&&this.fillUuidToShape(t,e)}}}}const $i=(t,i)=>{const n=e[t[0]]||e[s.NULL];if(null!=n){const e=n(t,i);if(null!=e)return e}throw new Error("Missing shape deserializers")},qi=(t,e)=>{const i=[];for(let s=0,n=t.length;s<n;++s)i.push($i(t[s],e));return 0<i.length?Promise.all(i).then(i=>(Zi(t,i,new ji(i),e),i)):null},Zi=(t,e,s,n)=>{for(let o=0,r=t.length;o<r;++o){const r=t[o],a=e[o],h=i[r[0]];h&&h(r,a,s,n),Zi(r[20],a.children,s,n)}};class Ji{constructor(t,e,i,s){this.name=t,this.width=e,this.height=i,this.layer=s}}const Qi=(t,e)=>Et(t)?e[t]:t;class ts{constructor(){this._edges=new Map}add(t,e,i,s,n,o,r,a,h){return this._edges.set(t,{type:Qi(e,Pi),x:i,y:s,normal:this.toNormal(i,s,n,o),size:{x:null!=r?r:0,y:null!=a?a:0},side:this.toSide(h)}),!0}toNormal(t,e,i,s){if(null!=i&&null!=s)return{x:i,y:s};{const i=t*t+e*e;if(1e-5<i){const s=1/Math.sqrt(i);return{x:t*s,y:e*s}}return{x:0,y:0}}}toSide(t){if(null==t)return Ni.TOP;if(wt(t))return t;if(Et(t))return Qi(t,Ni);{let e=Ni.NONE;for(let i=0,s=t.length;i<s;++i)e|=Qi(t[i],Ni);return e}}remove(t){const e=this._edges,i=e.get(t);return null!=i?(e.delete(t),i):null}size(){return this._edges.size}get(t,e){return this._edges.get(e)||null}each(t,e){return this._edges.forEach(e),this}contains(t){return this._edges.has(t)}clear(){const t=this._edges;return 0<t.size&&(t.clear(),!0)}}class es extends ts{get(t,e){const i=this.getEdges(t);if(null!=i){const t=i.get(e);if(null!=t)return t}return super.get(t,e)}each(t,e){const i=this.getEdges(t);return null!=i&&i.forEach((t,i)=>{e(t,i)}),super.each(t,e)}getEdges(t){return t instanceof Yi?t.edges:null}}class is{static set(t,e){let i=this._acceptors;null==i&&(i=new Map,this._acceptors=i),i.set(t,e)}static get(t){var e;const i=this._acceptors;if(null!=i){const e=i.get(t);if(null!=e)return e}const n=null!==(e=this._defaults)&&void 0!==e?e:this._defaults=new Map;switch(t){case s.EMBEDDED:let e=n.get(t);return null==e&&(e=this.newDefaultEmbedded(),n.set(t,e)),e;case s.EMBEDDED_ACCEPTOR_EDGE:let i=n.get(t);return null==i&&(i=this.newDefaultEmbeddedAcceptorEdge(),n.set(t,i)),i;default:let o=n.get(null);return null==o&&(o=this.newDefaultOther(),n.set(null,o)),o}}static newDefaultEmbedded(){return this.initDefault(new es)}static newDefaultEmbeddedAcceptorEdge(){const t=new ts;return t.add("CENTER",Pi.ALL,0,0,0,0),t}static newDefaultOther(){return this.initDefault(new ts)}static initDefault(t){const e=1/Math.sqrt(2);return t.add("TOP",Pi.ALL,0,-.5,0,-1),t.add("LEFT",Pi.ALL,-.5,0,-1,0),t.add("RIGHT",Pi.ALL,.5,0,1,0),t.add("BOTTOM",Pi.ALL,0,.5,0,1),t.add("CENTER",Pi.ALL,0,0,0,0),t.add("TOP_LEFT",Pi.ALL,-.5,-.5,-e,-e),t.add("TOP_RIGHT",Pi.ALL,.5,-.5,e,-e),t.add("BOTTOM_LEFT",Pi.ALL,-.5,.5,-e,e),t.add("BOTTOM_RIGHT",Pi.ALL,.5,.5,e,e),t}}class ss{constructor(t){this._parent=t,this._shape=null,this._edge=null,this._x=null,this._y=null}get shape(){return this._shape}set shape(t){this.set(t)}get edge(){return this._edge}set edge(t){this.set(void 0,t)}get x(){return this._x}set x(t){this.set(void 0,void 0,t)}get y(){return this._y}set y(t){this.set(void 0,void 0,void 0,t)}copy(t){return this.set(t.shape,t.edge,t.x,t.y)}set(t,e,i,s){let n=!1;return void 0!==t&&this._shape!==t&&(this._shape=t,n=!0),void 0!==e&&this._edge!==e&&(this._edge=e,n=!0),void 0!==i&&this._x!==i&&(this._x=i,n=!0),void 0!==s&&this._y!==s&&(this._y=s,n=!0),n&&this._parent.onAcceptorChange(),this}}class ns{constructor(e,i){this._parent=e,this._onChange=i,this._acceptor=new ss(this),this._acceptorTransformNew=new t.Matrix,this._acceptorTransformOld=new t.Matrix,this._hasAcceptorTransformOld=!1,this._local=new t.ObservablePoint(()=>{this.onLocalChange()},void 0),this._localIdRequired=0,this._localId=0,this._normal=new t.ObservablePoint(()=>{this.onNormalChange()},void 0),this._normalIdRequired=0,this._normalId=0,this._side=Ni.TOP,this._margin=0,this._other=null,this._lockCount=0,this._isAcceptorChanged=!1,this._isLocalChanged=!1,this._isNormalChanged=!1,this._isOtherChanged=!1}lock(){this._lockCount+=1,1===this._lockCount&&(this._isAcceptorChanged=!1,this._isLocalChanged=!1,this._isNormalChanged=!1,this._isOtherChanged=!1)}unlock(){if(this._lockCount-=1,0===this._lockCount){let t=!1;this._isLocalChanged&&(this._localIdRequired+=1,this._localId=this._localIdRequired,t=!0),this._isNormalChanged&&(this._normalIdRequired+=1,this._normalId=this._normalIdRequired,t=!0),this._isOtherChanged&&(t=!0),this._isAcceptorChanged&&(this._hasAcceptorTransformOld=!1,this._isLocalChanged||(this._localIdRequired+=1),this._isNormalChanged||(this._normalIdRequired+=1),this.doFit()&&(t=!1)),t&&this._onChange()}}get parent(){return this._parent}get acceptor(){return this._acceptor}get local(){return this._local}get localId(){return this._localId}get normal(){return this._normal}get normalId(){return this._normalId}get side(){return this._side}set side(t){this._side!==t&&(this._side=t,this.onOtherChange())}get margin(){return this._margin}set margin(t){this._margin!==t&&(this._margin=t,this.onOtherChange())}get other(){return this._other}set other(t){this._other=t}set(t,e,i,s,n,o,r,a,h,l){this.lock(),this._acceptor.set(t,e,i,s);const c=this._local;null!=o&&null!=r?c.set(o,r):null!=o?c.x=o:null!=r&&(c.y=r);const u=this._normal;return null!=a&&null!=h?u.set(a,h):null!=a?u.x=a:null!=h&&(u.y=h),null!=l&&(this.side=l),null!=n&&(this.margin=n),this.unlock(),this}copy(t){return this.lock(),this._acceptor.copy(t.acceptor),this._local.copyFrom(t.local),this._normal.copyFrom(t.normal),this.side=t.side,this.margin=t.margin,this.unlock(),this}serialize(t){const e=this._acceptor,i=e.shape,s=i?i.uuid:null,n=e.edge,o=null!=n?t.addResource(n):-1,r=this._local,a=this._normal,h=this._side;return t.addResource(`[${s},${o},${r.x},${r.y},${this._margin},${a.x},${a.y},${e.x},${e.y},${h}]`)}deserialize(t,e,i){var s,n,o;const r=i.resources;if(0<=t&&t<r.length){let a=i.getExtension(t);null==a&&(a=JSON.parse(r[t]),i.setExtension(t,a));let h=null;const l=a[0];null!=l&&(h=e.find(l)||null),this.lock();const c=this._acceptor;c.shape=h;const u=a[1];c.edge=0<=u&&u<r.length?r[u]:null,c.x=null!==(s=a[7])&&void 0!==s?s:null,c.y=null!==(n=a[8])&&void 0!==n?n:null,this._local.set(a[2],a[3]);const d=a[5],p=a[6],_=this._normal;null!=d&&null!=p?_.set(d,p):_.set(1,0),this.side=null!==(o=a[9])&&void 0!==o?o:Ni.TOP,this.margin=a[4]||0,this.unlock(),h&&h.connector.add(this)}}fit(t){return t&&(this._localIdRequired+=1,this._normalIdRequired+=1),this.doFit(),this}doFit(){var e,i,s;const n=this._localIdRequired,o=this._localId!==n,r=this._normalIdRequired,a=this._normalId!==r;if(o||a){this._localId=n,this._normalId=r;const h=this._acceptor,l=h.shape,c=h.edge;if(null!=l&&null!=c){const n=is.get(l.type).get(l,c);if(n){const r=this._acceptorTransformOld,c=this._acceptorTransformNew;this.toAcceptorTransform(l,c);const u=this._other,d=this._hasAcceptorTransformOld&&null!=u&&null==u.acceptor.shape,p=null!==(e=ns.WORK_MATRIX)&&void 0!==e?e:ns.WORK_MATRIX=new t.Matrix;if(d&&r.copyTo(p).invert().prepend(c),this._acceptorTransformNew=r,this._acceptorTransformOld=c,this._hasAcceptorTransformOld=!0,this.lock(),o){const t=this._local,e=t.x,o=t.y,r=l.size,a=l.transform.pivot,_=a.x+r.x*(null!==(i=h.x)&&void 0!==i?i:n.x),g=a.y+r.y*(null!==(s=h.y)&&void 0!==s?s:n.y),f=c.a*_+c.c*g+c.tx,m=c.b*_+c.d*g+c.ty;if(t.set(f,m),d){const t=u.local,i=t.x,s=t.y,n=p.a*i+p.c*s+p.tx,r=p.b*i+p.d*s+p.ty,a=i-e,h=s-o,l=n-f,c=r-m,d=a*a+h*h,_=l*l+c*c;if(1e-6<_){const e=Math.sqrt(d/_);t.set(f+l*e,m+c*e)}else t.set(n,r)}}if(a){const t=n.normal,e=t.x,i=t.y,s=c.a*e+c.c*i,o=c.b*e+c.d*i,r=s*s+o*o,a=this._normal;if(1e-6<r){const t=1/Math.sqrt(r);a.set(s*t,o*t)}else a.set(e,i);if(d){const t=u.normal,e=t.x,i=t.y,s=p.a*e+p.c*i,n=p.b*e+p.d*i,o=s*s+n*n;if(1e-6<o){const e=1/Math.sqrt(o);t.set(s*e,n*e)}else t.set(e,i)}}const _=this._isLocalChanged||this._isNormalChanged;return this.unlock(),_}}}return!1}toAcceptorTransform(t,e){t.updateTransform();const i=this._parent,s=i.parent;return s instanceof kt?(i.updateTransform(),e.copyFrom(s.transform.internalTransform).invert().append(t.transform.internalTransform)):e.copyFrom(t.transform.internalTransform)}onAcceptorChange(){if(0<this._lockCount)return this._isLocalChanged=!1,this._isNormalChanged=!1,void(this._isAcceptorChanged=!0);this._hasAcceptorTransformOld=!1,this.fit(!0)}onLocalChange(){0<this._lockCount?this._isLocalChanged=!0:(this._localIdRequired+=1,this._localId=this._localIdRequired,this._onChange())}onNormalChange(){0<this._lockCount?this._isNormalChanged=!0:(this._normalIdRequired+=1,this._normalId=this._normalIdRequired,this._onChange())}onOtherChange(){0<this._lockCount?this._isOtherChanged=!0:this._onChange()}attach(){const t=this._acceptor.shape;return t&&t.connector.add(this)&&this.onAcceptorChange(),this}detach(t){const e=this._acceptor.shape;return null==e||null!=t&&t.has(e)||e.connector.remove(this)&&this.onAcceptorChange(),this}}class os{constructor(t,e){this._parent=t,this._lockCount=0,this._isChanged=!1,this._onChange=e;const i=()=>{this.onChange()},s=new ns(t,i),n=new ns(t,i);s.other=n,n.other=s,this._tail=s,this._head=n}lock(){return this._lockCount+=1,1===this._lockCount&&(this._isChanged=!1),this}unlock(){return this._lockCount-=1,0===this._lockCount&&this._isChanged&&this._onChange(),this}onChange(){0<this._lockCount?this._isChanged=!0:this._onChange()}get tail(){return this._tail}get head(){return this._head}copy(t){return this.lock(),this._tail.copy(t.tail),this._head.copy(t.head),this.unlock(),this}fit(t){return this.lock(),this._tail.fit(t),this._head.fit(t),this.unlock(),this}serialize(t){const e=this._tail.serialize(t),i=this._head.serialize(t);return t.addResource(`[${e},${i}]`)}deserialize(t,e,i){const s=i.resources;if(0<=t&&t<s.length){let n=i.getExtension(t);null==n&&(n=JSON.parse(s[t]),i.setExtension(t,n)),this.lock(),this._tail.deserialize(n[0],e,i),this._head.deserialize(n[1],e,i),this.unlock()}}attach(){this.lock();const t=this._tail,e=this._head;return t.attach(),e.attach(),t.fit(!0),e.fit(!0),this.unlock(),this}detach(t){return this.lock(),this._tail.detach(t),this._head.detach(t),this.unlock(),this}}const rs=(t,e)=>{let i=0,s=t.length-1;for(;i<=s;){const n=i+(s-i>>1),o=t[n];if(e<o)s=n-1;else{if(!(o<e))return n;i=n+1}}return-1},as=(t,e)=>{if(2<=t.length){let i=t[0],s=t[1],n=i,o=s;for(let e=2,r=t.length;e<r;e+=2){const r=t[e],a=t[e+1];i=Math.min(i,r),s=Math.min(s,a),n=Math.max(n,r),o=Math.max(o,a)}e[0]=i,e[1]=s,e[2]=n,e[3]=o}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e};class hs{constructor(e){this._parent=e,this._lockCount=0,this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1,this._type=Z.NONE,this._size=new t.ObservablePoint(()=>{this.onSizeChange()},void 0,.15*q.SIZE_X,.15*q.SIZE_Y),this._fill=this.newFill(),this._transformId=0}newFill(){return new J(this,!0,q.FILL_COLOR,1)}lock(){return this._lockCount+=1,1===this._lockCount&&(this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}unlock(){return this._lockCount-=1,0===this._lockCount&&(this._isTypeChanged?this.onTypeChange():this._isSizeChanged?this.onSizeChange():this._isFillChanged&&this.onFillChange(),this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}get type(){return this._type}set type(t){this._type!==t&&(this._type=t,this.onTypeChange())}onTypeChange(){0<this._lockCount?this._isTypeChanged=!0:this._parent.onTypeChange()}get size(){return this._size}onSizeChange(){0<this._lockCount?this._isSizeChanged=!0:this._parent.onSizeChange()}get transform(){return this.updateTransform()}updateTransform(){let e=this._transform;null==e&&(e=new t.Matrix,this._transform=e);const i=this._parent.parent,s=i.id;if(this._transformId!==s){this._transformId=s;const t=i.formatted;2<=t.length?this.toTransform(t.values,e):e.identity()}return e}toTransformMatrix(t,e,i,s,n){const o=t-i,r=e-s,a=o*o+r*r;if(1e-5<a){const i=1/Math.sqrt(a),s=o*i,h=r*i;n.set(h,-s,-s,-h,t,e)}else n.set(1,0,0,1,t,e);return n}get fill(){return this._fill}onFillChange(){0<this._lockCount?this._isFillChanged=!0:this._parent.onFillChange()}updateUploaded(){this.onFillChange()}copy(t){const e=t.size;return this.set(t.type,e.x,e.y),this}set(t,e,i){return this.lock(),null!=t&&(this.type=t),this.size.set(e,i),this.unlock(),this}serialize(t){const e=this._size,i=this._fill.serialize(t);return t.addResource(`[${this._type},${e.x},${e.y},${i}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getExtension(t);null==s&&(s=JSON.parse(i[t]),e.setExtension(t,s)),this.lock(),this.type=s[0],this._size.set(s[1],s[2]),this._fill.deserialize(s[3],e),this.unlock()}}}class ls extends hs{toTransform(t,e){const i=t.length;return 4<=i?this.toTransformMatrix(t[i-2],t[i-1],t[i-4],t[i-3],e):(e.identity(),e)}}class cs extends hs{toTransform(t,e){return 4<=t.length?this.toTransformMatrix(t[0],t[1],t[2],t[3],e):(e.identity(),e)}}class us{constructor(t){this._parent=t,this._lockCount=0,this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1,this._head=new ls(this),this._tail=new cs(this)}lock(){return this._lockCount+=1,1===this._lockCount&&(this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}unlock(){return this._lockCount-=1,0===this._lockCount&&(this._isTypeChanged?this.onTypeChange():this._isSizeChanged?this.onSizeChange():this._isFillChanged&&this.onFillChange(),this._isTypeChanged=!1,this._isSizeChanged=!1,this._isFillChanged=!1),this}get parent(){return this._parent}get head(){return this._head}get tail(){return this._tail}onTypeChange(){0<this._lockCount?this._isTypeChanged=!0:this._parent.onMarkerTypeChange()}onSizeChange(){0<this._lockCount?this._isSizeChanged=!0:this._parent.onMarkerSizeChange()}onFillChange(){0<this._lockCount?this._isFillChanged=!0:this._parent.onMarkerFillChange()}copy(t){return this.lock(),this._head.copy(t.head),this._tail.copy(t.tail),this.unlock(),this}serialize(t){const e=this._head.serialize(t),i=this._tail.serialize(t);return t.addResource(`[${e},${i}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getExtension(t);null==s&&(s=JSON.parse(i[t]),e.setExtension(t,s)),this.lock(),this._head.deserialize(s[0],e),this._tail.deserialize(s[1],e),this.unlock()}}}const ds=2*Math.PI,ps=.5*Math.PI,_s=(t,e,i,s)=>t*i+e*s,gs=(t,e)=>Math.sqrt(_s(t,e,t,e)),fs=(t,e,i,s)=>t*s-e*i,ms=(t,e,i,s,n,o,r,a,h,l)=>{const c=l.center;c[0]=t,c[1]=e;const u=l.axis1;u[0]=i,u[1]=s;const d=l.axis2;d[0]=n,d[1]=o;const p=l.angle;return p[0]=r,p[1]=a,p[2]=h,l},vs=(t,e)=>{const i=t.center,s=t.axis1,n=t.axis2,o=t.angle;return ms(i[0],i[1],s[0],s[1],n[0],n[1],o[0],o[1],o[2],e)},Ts=(t,e)=>{const i=t.length;for(let s=0;s<i;++s)e[s]=t[s];return e.length!==i&&(e.length=i),e};class ws{static set(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_){const g=Math.max(Math.abs(e-i),Math.abs(r-a)),f=u?Math.max(1,Math.round(c*(g/ps))):c,m=d?f+1:f;for(let c=0;c<m;++c){const u=c/f,d=1-u,g=u,m=d*e+g*i,v=Math.cos(m),T=Math.sin(m),w=t[0]+v*s[0]+T*n[0],E=t[1]+v*s[1]+T*n[1],y=d*r+g*a,x=Math.cos(y),C=Math.sin(y),D=o[0]+x*h[0]+C*l[0],S=o[1]+x*h[1]+C*l[1],b=ps*u,I=Math.cos(b),O=Math.sin(b),A=I*I,R=O*O,M=A*w+R*D,k=A*E+R*S;p[++_]=M,p[++_]=k}return _}static interpolate(t,e,i,s,n,o,r,a){const h=a.values,l=a.segments;if(t<=2)return Ts(e,h),Ts(i,l),a;const c=this.WORK_P0||{center:[0,0],axis1:[0,0],axis2:[0,0],angle:[0,0,0]};let u=this.WORK_P1||{center:[0,0],axis1:[0,0],axis2:[0,0],angle:[0,0,0]},d=this.WORK_P2||{center:[0,0],axis1:[0,0],axis2:[0,0],angle:[0,0,0]};this.WORK_P0=c,this.WORK_P1=u,this.WORK_P2=d;let p=-1,_=-1;if(n){s(0,t,e,c),vs(c,u);for(let n=1;n<t;++n){if(s(n,t,e,d),0<=rs(i,n)){const t=n-1<<1;h[++p]=e[t+0],h[++p]=e[t+1],l[++_]=p+1>>1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,d.center,d.angle[0],d.angle[1],d.axis1,d.axis2,o,r,!1,h,p);const a=u;u=d,d=a}if(0<=rs(i,0)){const i=t-1<<1;h[++p]=e[i+0],h[++p]=e[i+1],l.unshift(0),_+=1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,c.center,c.angle[0],c.angle[1],c.axis1,c.axis2,o,r,!1,h,p)}else{s(1,t,e,c),0<=rs(i,1)?(h[++p]=e[0],h[++p]=e[1],l[++_]=1):p=this.set(c.center,c.angle[0],c.angle[1],c.axis1,c.axis2,c.center,c.angle[0],c.angle[1],c.axis1,c.axis2,o,r,!1,h,p),vs(c,u);for(let n=2,a=t-1;n<a;++n){if(s(n,t,e,d),0<=rs(i,n)){const t=n-1<<1;h[++p]=e[t+0],h[++p]=e[t+1],l[++_]=p+1>>1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,d.center,d.angle[0],d.angle[1],d.axis1,d.axis2,o,r,!1,h,p);const a=u;u=d,d=a}if(0<=rs(i,t-1)){const i=t-2<<1;h[++p]=e[i+0],h[++p]=e[i+1],l[++_]=p+1>>1}else p=this.set(u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,u.center,u.angle[1],u.angle[2],u.axis1,u.axis2,o,r,!0,h,p)}return p+=1,h.length!==p&&(h.length=p),_+=1,l.length!==_&&(l.length=_),a}}ws.toCircle=(t,e,i,s)=>{const n=(0<t?t-1:e-1)<<1,o=t<<1,r=(t<e-1?t+1:0)<<1,a=i[n+0],h=i[n+1],l=i[o+0],c=i[o+1],u=i[r+0],d=i[r+1],p=l-a,_=c-h,g=u-l,f=d-c,m=a+.5*p,v=h+.5*_,T=l+.5*g,w=c+.5*f,E=-_,y=+p,x=-f,C=+g;let D=fs(E,y,x,C);if(Math.abs(D)<.001){if(0<=_s(p,_,g,f)||e<=2){const t=.01,e=Math.sin(t),i=gs(p,_),n=gs(g,f);return ms(l,c,0,0,g/e,f/e,-t*i/n,0,t,s)}D=.001}const S=(C*(T-m)+x*(v-w))/D,b=m+S*E,I=v+S*y,O=l-b,A=c-I,R=-A,M=+O,k=u-b,L=d-I;let N=Math.atan2(_s(R,M,k,L),_s(O,A,k,L));const P=a-b,B=h-I;let z=Math.atan2(_s(R,M,P,B),_s(O,A,P,B));return 0<z*N&&(Math.abs(z)<Math.abs(N)&&(0<N?N-=ds:N+=ds),Math.abs(N)<Math.abs(z)&&(0<z?z-=ds:z+=ds)),ms(b,I,O,A,R,M,z,0,N,s)},ws.toEllipse=(t,e,i,s)=>{const n=(0<t?t-1:e-1)<<1,o=t<<1,r=(t<e-1?t+1:0)<<1,a=i[n+0],h=i[n+1],l=i[o+0],c=i[o+1],u=i[r+0],d=i[r+1],p=a-l,_=h-c,g=u-l,f=d-c;if(e<=2){const t=.01,e=Math.sin(t);return ms(l,c,0,0,g/e,f/e,-t,0,t,s)}const m=gs(p,_),v=gs(g,f),T=_s(p,_,g,f)/(m*v),w=Math.acos(T);let E=.5*w,y=.25*w,x=0,C=0,D=0,S=0;const b=Math.max(m,v),I=Math.min(m,v);for(let t=0;t<16;++t){const t=.5*E,e=w-t;x=b*Math.sin(t),C=b*Math.cos(t),D=I*Math.sin(e),S=I*Math.cos(e),1<(1-S/C)*(1-S/C)+D*D/(x*x)?E+=y:E-=y,y*=.5}const O=Math.asin(Math.min(D/x,1));if(m<v){const t=g/v,e=f/v;let i,n;0<fs(p,_,g,f)?(i=+e,n=-t):(i=-e,n=+t);const o=-C*C/v,r=-C*x/v,a=o*t+r*i,h=o*e+r*n,m=l-a,T=c-h;return ms(m,T,a,h,u-m,d-T,-O,0,ps,s)}{const t=p/m,e=_/m;let i,n;fs(p,_,g,f)<0?(i=+e,n=-t):(i=-e,n=+t);const o=-C*C/m,r=-C*x/m,u=o*t+r*i,d=o*e+r*n,v=l-u,T=c-d;return ms(v,T,u,d,-(a-v),-(h-T),-ps,0,O,s)}},ws.toHybrid=(t,e,i,s)=>{const n=ws.toCircle(t,e,i,s),o=n.angle[0],r=n.angle[2],a=Math.min(o,r),h=Math.max(o,r);return a<-ps||ps<h?ws.toEllipse(t,e,i,s):n};const Es=(t,e,i,s,n)=>(ws.interpolate(t,e,i,ws.toHybrid,!!(s&F.CLOSED),q.CURVE_SEGMENT_COUNT,!0,n),n.length=n.values.length>>1,n.style=s,n),ys=(t,e)=>{const i=t.length;for(let s=0;s<i;++s)e[s]=t[s];return e.length!==i&&(e.length=i),e},xs=(t,e,i,s,n,o)=>{const r=1-n;return o[0]=t*r+i*n,o[1]=e*r+s*n,o},Cs=(t,e,i,s,n,o,r,a,h,l,c)=>{const u=[0,0],d=[0,0],p=[0,0];for(let _=r;_<a;++_){const r=_/h;xs(t,e,i,s,r,u),xs(i,s,n,o,r,d),xs(u[0],u[1],d[0],d[1],r,p),l[++c]=p[0],l[++c]=p[1]}return c},Ds=(t,e,i,s,n)=>(((t,e,i,s,n,o)=>{const r=o.values,a=o.segments;if(t<=2)return ys(e,r),ys(i,a),o;let h=-1,l=-1;const c=n>>1;if(s){let s=0;for(;s+2<t;s+=2){const t=s<<1,o=0<=rs(i,s+1),u=0<=rs(i,s+2);o&&u?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1)):o?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1),h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],c,n,n,r,h)):u?(h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,c,n,r,h),a[++l]=1+(h>>1)):h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,n,n,r,h)}if(s+1<t){const t=s<<1,o=0<=rs(i,s+1),u=0<=rs(i,0);o&&u?(r[++h]=e[0],r[++h]=e[1],a.unshift(0),l+=1):o?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1),h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[0],e[1],c,n,n,r,h)):u?(h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[0],e[1],0,c,n,r,h),a[++l]=1+(h>>1)):h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[0],e[1],0,n,n,r,h)}else if(s<t){const t=s<<1;r[++h]=e[t+0],r[++h]=e[t+1],0<=rs(i,0)&&(a.unshift(0),l+=1)}}else{let s=0;for(;s+2<t;s+=2){const t=s<<1,o=0<=rs(i,s+1),u=0<=rs(i,s+2);o&&u?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1)):o?(r[++h]=e[t+0],r[++h]=e[t+1],a[++l]=1+(h>>1),h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],c,n,n,r,h)):u?(h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,c,n,r,h),a[++l]=1+(h>>1)):h=Cs(e[t+0],e[t+1],e[t+2],e[t+3],e[t+4],e[t+5],0,n,n,r,h)}for(;s+1<t;++s){const t=s<<1;r[++h]=e[t+0],r[++h]=e[t+1],r[++h]=e[t+2],r[++h]=e[t+3],0<=rs(i,s+1)&&(a[++l]=1+(h>>1))}for(;s<t;++s){const t=s<<1;r[++h]=e[t+0],r[++h]=e[t+1]}}h+=1,r.length!==h&&(r.length=h),l+=1,a.length!==l&&(a.length=l)})(t,e,i,!!(s&F.CLOSED),q.CURVE_SEGMENT_COUNT,n),n.length=n.values.length>>1,n.style=s,n);class Ss{static set(t,e){null==this.data&&(this.data=this.newData()),this.data.set(t,e)}static get(t){return null==this.data&&(this.data=this.newData()),this.data.get(t)}static each(t){null==this.data&&(this.data=this.newData()),this.data.forEach((e,i)=>{t(i,e)})}static find(t){return this.get((t&F.FORMATTER_MASK)>>F.FORMATTER_SHIFT)}static newData(){const t=new Map,e=$.get("EShapePointsFormatter");return t.set(F.FORMATTER_CURVE_SPLINE,{label:e.getCurveSplineLabel(),formatter:Es}),t.set(F.FORMATTER_CURVE_BEZIER_QUADRATIC,{label:e.getCurveBezierQuadraticLabel(),formatter:Ds}),t}}class bs{constructor(e){this._parent=e,this._valuesBaseLength=0,this._values=[],this._segments=[],this._length=0,this._plength=0;const i=e.size,s=i.x,n=i.y;this._parentSizeBase=new t.Point(s,n),this._parentSizeFitted=new t.Point(s,n),this._id=0,this._style=F.NONE,this._formattedId=-1}get length(){return this._length}get plength(){return this._plength}toFitted(t,e){this._valuesBase=void 0,this._parentSizeFitted.set(t,e),this._parentSizeBase.set(t,e)}onSizeChange(){this.fit()}fit(){const t=this._parent,e=this._parentSizeFitted,i=t.size,s=i.x,n=i.y,o=1e-5;if(Math.abs(s-e.x)<=o&&Math.abs(n-e.y)<=o)return;e.set(s,n);const r=this._parentSizeBase,a=o<Math.abs(r.x),h=o<Math.abs(r.y);if(!a&&!h)return;const l=a?s/r.x:1,c=h?n/r.y:1,u=this._values;let d=this._valuesBase;if(null==d){d=[],this._valuesBase=d;for(let t=0,e=u.length;t<e;t+=2){const e=u[t],i=u[t+1];u[t]=e*l,u[t+1]=i*c,d.push(e,i)}}else for(let t=0,e=u.length;t<e;t+=2)u[t]=d[t]*l,u[t+1]=d[t+1]*c;if(this._id+=1,this._formatter||this._style&F.FORMATTER_MASK){const e=t.uploaded;e&&!e.isCompatible(t)&&t.toDirty()}}get id(){return this.fit(),this._id}get values(){return this.fit(),this._values}set values(t){this.set(t,void 0,void 0)}get segments(){return this._segments}set segments(t){this.set(void 0,t,void 0)}get style(){return this._style}set style(t){this.set(void 0,void 0,t)}get marker(){let t=this._marker;return null==t&&(t=this.newMarker(),this._marker=t),t}getMarker(){return this._marker}newMarker(){return new us(this)}onMarkerTypeChange(){const t=this._parent;t.uploaded=void 0,t.toDirty()}onMarkerSizeChange(){this._parent.updateUploaded()}onMarkerFillChange(){this._parent.updateUploaded()}get formatter(){return this._formatter||null}set formatter(t){this._formatter!==t&&(this._formattedId=-1,this._formatter=t,this.toDirty(!0))}get formatted(){var t,e;this.fit();const i=this._id;let s=this._formatted;if(this._formattedId!==i){this._formattedId=i;const n=this._style,o=null!==(t=this._formatter)&&void 0!==t?t:null===(e=Ss.find(n))||void 0===e?void 0:e.formatter;if(null!=o){null==s&&(s={length:0,plength:0,values:[],segments:[],boundary:[0,0,0,0],style:F.NONE});const t=this._values,e=this._segments;o(t.length>>1,t,e,n,s),s.plength<s.length&&(s.plength=s.length),as(s.values,s.boundary)}else s=void 0;this._formatted=s}return s||this}toScaled(t,e,i,s){const n=this._parentSizeFitted,o=this._parentSizeBase,r=1e-5,a=r<Math.abs(o.x),h=r<Math.abs(o.y);if(a||h){const r=a?n.x/o.x:1,l=h?n.y/o.y:1;for(let i=0,s=e.length;i<s;i+=2)t[i]=e[i]*r,t[i+1]=e[i+1]*l;for(let t=0,e=s.length;t<e;t+=2)i[t]=s[t]*r,i[t+1]=s[t+1]*l}}copy(t){this.set(t.values,t.segments,t.style);const e=t.getMarker();return e&&this.marker.copy(e),this}set(t,e,i){let s=!1,n=!1;const o=this._style,r=o&F.FORMATTER_MASK,a=this._formatter;if(null!=t){const e=this._values,i=this._valuesBaseLength,o=t.length,h=Math.min(o,i),l=this._parent.size;if(this.toFitted(l.x,l.y),e!==t){for(let i=0;i<h;++i)e[i]=t[i];for(let i=h;i<o;++i)e.push(t[i]);i!==o?(e.length=o,this._valuesBaseLength=o,s=!0):null!=a||r?s=!0:n=!0}else i!==o?(this._valuesBaseLength=o,s=!0):null!=a||r?s=!0:n=!0;const c=o>>1;this._length=c,this._plength<c&&(this._plength=c)}if(null!=e){const t=this._segments;if(t!==e){const i=e.length,s=Math.min(t.length,i);for(let i=0;i<s;++i)t[i]=e[i];for(let n=s;n<i;++n)t.push(e[n]);t.length!==i&&(t.length=i)}null!=a||r?s=!0:n=!0}return null!=i&&o!==i&&(r!==(i&F.FORMATTER_MASK)||(null!=a||r)&&(o&F.CLOSED)!=(i&F.CLOSED)?s=!0:n=!0,this._style=i),(n||s)&&this.toDirty(s),this}toDirty(t){if(t){this._id+=1;const t=this._parent,e=t.uploaded;e?e.isCompatible(t)?t.updateUploaded():t.toDirty():t.updateUploaded()}else this._id+=1,this._parent.updateUploaded()}clone(t){return new bs(t).copy(this)}toPoints(e){const i=[],s=this.values;for(let n=0,o=s.length;n<o;n+=2){const o=new t.Point(s[n+0],s[n+1]);i.push(e.apply(o,o))}return i}serialize(t){const e=JSON.stringify(this._values),i=JSON.stringify(this._segments),s=this._style;let n=-1;const o=this._marker;return o&&(n=o.serialize(t)),t.addResource(`[${e},${i},${s},${n}]`)}deserialize(t,e){const i=e.resources;if(0<=t&&t<i.length){let s=e.getExtension(t);null==s&&(s=JSON.parse(i[t]),e.setExtension(t,s)),this.set(s[0],s[1],s[2]);const n=s[3];null!=n&&0<=n&&this.marker.deserialize(n,e)}}calcHitPointAbs(t,e,i,s,n,o,r,a){const h=this.formatted,l=h.length;if(2<=l){const i=h.values,s=h.segments,c=h.style;let u=0,d=l;if(o){const s=bs.WORK_RANGE;o(t,e,n,i,s),u=s[0],d=s[1]}for(let o=u,h=Math.min(d,l-1);o<h;++o)if(rs(s,o+1)<0){const s=o<<1;if(r(t,e,i[s+0],i[s+1],i[s+2],i[s+3],o,n,a))return!0}if(2<l&&l<=d&&c&F.CLOSED&&rs(s,0)<0){const s=l-1,o=s<<1;if(r(t,e,i[o+0],i[o+1],i[0],i[1],s,n,a))return!0}}return!1}}bs.WORK_RANGE=[0,0];class Is{constructor(t,e){this._parent=t,this._id=0,this._values=[],this._lockCount=0,this._isChanged=!1,this._onChange=e}lock(){this._lockCount+=1,1===this._lockCount&&(this._isChanged=!1)}unlock(){this._lockCount-=1,0===this._lockCount&&(this._isChanged&&this.onChange(),this._isChanged=!1)}get id(){return this._id}get values(){return this._values}set values(t){this.set(t)}set(t){if(null!=t){if(this._id+=1,this._values!==t){const e=t.length,i=this._values;for(let s=0;s<e;++s)i[s]=t[s];i.length=e}this.onChange()}return this}copy(t){return this.set(t.values)}serialize(t){return t.addResource(JSON.stringify(this._values))}deserialize(t,e,i){const s=i.resources;if(0<=t&&t<s.length){let e=i.getExtension(t);null==e&&(e=JSON.parse(s[t]),i.setExtension(t,e)),this.set(e)}}onChange(){0<this._lockCount?this._isChanged=!0:this._onChange()}}class Os extends re{constructor(t=s.CONNECTOR_LINE){super(t),this._tailLocalId=0,this._tailNormalId=0,this._tailMargin=0,this._headLocalId=0,this._headNormalId=0,this._headMargin=0,this._bodyId=0,this._lockConnector=new Rt;const e=.5*q.SIZE_X,i=.5*q.SIZE_Y;this._points=new bs(this).set([-e,-i,+e,+i]);const n=()=>{this.onChange()};this._edge=new os(this,n),this._body=new Is(this,n)}lock(t){return t&Mt.CONNECTOR&&this._lockConnector.lock(),super.lock(t),this}unlock(t,e){return super.unlock(t,e),t&Mt.CONNECTOR&&this._lockConnector.unlock()&&e&&this.onChange(),this}get points(){return this._points}get edge(){return this._edge}get body(){return this._body}onAttach(){super.onAttach(),this._edge.attach()}onDetach(t){this._edge.detach(t),super.onDetach(t)}onChange(){var t;if(this._lockConnector.isLocked())return;const e=this._edge,i=e.tail,s=i.localId,n=i.normalId,o=i.margin,r=e.head,a=r.localId,h=r.normalId,l=r.margin,c=this._body,u=c.id;if(this._tailLocalId!==s||this._tailNormalId!==n||this._tailMargin!==o||this._headLocalId!==a||this._headNormalId!==h||this._headMargin!==l||this._bodyId!==u){this._tailLocalId=s,this._tailNormalId=n,this._tailMargin=o,this._headLocalId=a,this._headNormalId=h,this._headMargin=l,this._bodyId;const e=this.transform,u=e.position,d=u.x,p=u.y,_=this._points,g=_.values;this.fillPoints(i,o,r,l,c,d,p,g);const f=null!==(t=Os.WORK_BOUNDARY)&&void 0!==t?t:Os.WORK_BOUNDARY=[0,0,0,0];as(g,f);const m=.5*(f[2]+f[0]),v=.5*(f[3]+f[1]),T=f[2]-f[0],w=f[3]-f[1];for(let t=0,e=g.length;t<e;t+=2)g[t+0]-=m,g[t+1]-=v;this.lock(Mt.TRANSFORM_AND_UPLOADED),u.set(d+m,p+v),e.scale.set(1,1),e.rotation=0,e.skew.set(0,0),_.toFitted(T,w),this.size.set(T,w),_.set(g),this.unlock(Mt.TRANSFORM_AND_UPLOADED,!0)}}fillPoints(t,e,i,s,n,o,r,a){const h=1e-6,l=t.local,c=l.x-o,u=l.y-r,d=i.local,p=d.x-o,_=d.y-r,g=n.values,f=g.length;if(a[0]=c,a[1]=u,0<f){const t=.5*(p+c),e=.5*(_+u),i=p-c,s=_-u,n=Math.atan2(s,i),o=Math.cos(n),r=Math.sin(n),h=Math.sqrt(i*i+s*s);for(let i=0;i<f;i+=2){const s=g[i+0],n=g[i+1];a[i+2]=t+(o*s-r*n)*h,a[i+3]=e+(o*n+r*s)*h}}if(a[2+f]=p,a[3+f]=_,0!==e){const t=a[2]-c,i=a[3]-u;if(h<t*t+i*i){const s=e/Math.sqrt(t*t+i*i);a[0]=c+t*s,a[1]=u+i*s}}if(0!==s){const t=a[0+f]-p,e=a[1+f]-_;if(h<t*t+e*e){const i=s/Math.sqrt(t*t+e*e);a[2+f]=p+t*i,a[3+f]=_+e*i}}a.length=f+4}copy(t,e=ht.ALL){return this.lock(Mt.ALL),super.copy(t,e),t instanceof Os&&(this._edge.copy(t.edge),this._body.copy(t.body)),this.unlock(Mt.ALL,!0),this}clone(){return new(0,this.constructor)(this.type).copy(this)}serialize(t){const e=super.serialize(t),i=this._edge.serialize(t),s=this._body.serialize(t),n=this._points.serialize(t);return e[15]=t.addResource(`[${i},${n},${s}]`),e}}class As{static isConnector(t){return t instanceof Os}static newMapping(t,e,i){var s;null==i&&(i=null!==(s=As._MAPPING)&&void 0!==s?s:As._MAPPING=new Map).clear();for(let s=0,n=t.length;s<n;++s){const n=t[s],o=e[s];i.set(n,o),this.newMapping(n.children,o.children,i)}return i}static moveAll(t,e,i,s,n){for(let o=0,r=i.length;o<r;++o){const r=i[o],a=s[o];if(this.isConnector(r)&&this.isConnector(a)){const i=r.edge,s=a.edge,o=i.head,h=o.acceptor.shape;if(h){null==n&&(n=this.newMapping(t,e));const i=n.get(h);if(i){const t=s.head;t.detach(),t.set(i),t.attach(),i.connector.remove(o)}}const l=i.tail,c=l.acceptor.shape;if(c){null==n&&(n=this.newMapping(t,e));const i=n.get(c);if(i){const t=s.tail;t.detach(),t.set(i),t.attach(),i.connector.remove(l)}}}n=this.moveAll(t,e,r.children,a.children,n)}return n}static move(t,e){const i=t.children,s=e.children;this.moveAll(i,s,i,s)}}class Rs{constructor(e,i,s,n,o){this.id=e,this.ref=0;const r=o.resolution;this.frame=new t.Rectangle(0,0,i*r,s*r),this.texture=new t.Texture(o,new t.Rectangle(0,0,1,1)),this.width=i,this.height=s,this.strokeWidth=n}applyFrame(){const t=1/this.texture.baseTexture.resolution;this.texture.frame.x=this.frame.x*t,this.texture.frame.y=this.frame.y*t,this.texture.frame.width=this.width,this.texture.frame.height=this.height,this.texture.updateUvs(),this.texture.emit("update",this)}destroy(){this.texture.destroy()}}class Ms extends Rs{render(t){}}class ks extends Rs{render(t){const e=this.frame;t.save(),t.fillStyle="#ffffff",t.fillRect(e.x-1,e.y-1,e.width+2,e.height+2),t.restore()}}class Ls{constructor(e){const i=this._canvas=document.createElement("canvas");i.width=i.height=256;const s=t.BaseTexture.from(i,{mipmap:t.MIPMAP_MODES.OFF,resolution:e});this._baseTexture=s,this._idToDatum={},this._sortedData=[],this._predefined={empty:new Ms("empty",10,10,0,s),white:new ks("white",10,10,0,s)},this._isDirty=!0}updateFrames(t,e){let i=4,s=4,n=0;for(let o=0,r=e.length;o<r;++o){const r=e[o];t<i+r.frame.width+4&&(i=4,s+=n+4,n=0),r.frame.x=0|i,r.frame.y=0|s,i+=r.frame.width+4,n=Math.max(n,r.frame.height)}const o=s+n+4;let r=256;for(;r<o;)r<<=1;return Math.min(4096,r)}renderFrames(t,e,i){const s=this._canvas;s.width=t,s.height=e;const n=s.getContext("2d");if(null!=n)for(let t=0,e=i.length;t<e;++t)i[t].render(n)}applyFrames(t){for(let e=0,i=t.length;e<i;++e)t[e].applyFrame()}calcCanvasWidth(t){let e=512;for(let i=t.length-1;0<=i;--i){const s=t[i],n=Math.max(s.frame.width,s.frame.height);for(;e<n;)e<<=1}return Math.min(4096,e<<1)}cleanup(t){t.sort(Ls.ITEM_COMPARATOR);for(let e=t.length-1;0<=e;--e)if(0<t[e].ref)return void(t.length=e+1);t.length=0}begin(){const t=this._sortedData;for(let e=0,i=t.length;e<i;++e)t[e].ref=0;this._isDirty=!1}end(){const t=this._idToDatum,e=this._sortedData;for(let i=0,s=e.length;i<s;++i){const s=e[i];s.ref<=0&&(s.id in this._predefined||s.destroy(),delete t[s.id],this._isDirty=!0)}}repack(t){if(!0===t||this._isDirty){this._isDirty=!1;const t=this._sortedData;this.cleanup(t);const e=this.calcCanvasWidth(t),i=this.updateFrames(e,t);this.renderFrames(e,i,t),this._baseTexture.setRealSize(e,i),this.applyFrames(t)}}get(t){const e=this._idToDatum[t];if(null!=e)return e.ref+=1,e;{const e=this._predefined[t];if(null!=e)return this.set(t,e),e}return null}contains(t){return t in this._idToDatum}set(t,e){const i=this._idToDatum[t];return e.ref+=1,this._idToDatum[t]=e,this._sortedData.push(e),this._isDirty=!0,i}toDirty(){this._isDirty=!0}getDefaultTexture(){return this.get("white").texture}getBaseTexture(){return this._baseTexture}release(t){const e=this._idToDatum,i=e[t];null!=i&&(i.ref-=1,i.ref<=0&&(i.id in this._predefined||i.destroy(),delete e[t],this._isDirty=!0))}destroy(){const t=this._baseTexture;null!=t&&t.destroy()}}Ls.ITEM_COMPARATOR=(t,e)=>t.ref<=0?e.ref<=0?0:1:e.ref<=0||t.frame.height<e.frame.height?-1:e.frame.height<t.frame.height?1:t.frame.width-e.frame.width;class Ns extends Rs{constructor(t,e){super(t.id,t.width/e.resolution,t.height/e.resolution,0,e),this.canvas=t.canvas}render(t){const e=this.canvas;if(null!=e){const i=this.frame;t.drawImage(e,i.x,i.y,i.width,i.height)}}}class Ps{constructor(t,e){this.x=t,this.y=e}}class Bs{constructor(t,e,i,s,n,o,r){this.ref=1,this.life=Bs.LIFE,this.character=e,this.x=i,this.y=s,this.width=n,this.height=o,this.advance=r,this.origin=new Ps(0,0),this.type=t}}Bs.LIFE=10;const zs={RESERVED:1,NON_BREAKING:2,SPACE:4,SPACE_R:5,SPACE_NB:6,SPACE_RNB:7,LETTER:8,LETTER_R:9,LETTER_NB:10,LETTER_RNB:11};class Us{constructor(t){this.id=Us.toFontFamily(t),this.size=32,this.italic=!1,this.measured=!1,this.ascent=0,this.descent=0}static toFontFamily(t){return"auto"===t?Us.getAutoFontFamily():t}static getAutoFontFamily(){return null==Us.FONT_FAMILY_AUTO&&(Us.FONT_FAMILY_AUTO=$.getInstance().get("DBase").getFontFamilly()),Us.FONT_FAMILY_AUTO}}Us.FONT_FAMILY_AUTO=null;class Fs{constructor(){this._gl=null,this._texture=null,this._shaderProgram=null,this._vertexPositionAttribute=0,this._textureCoordAttribute=1,this._samplerUniform=null,this._sizeUniform=null,this._vb=null,this._uvb=null;const t=this._canvas=document.createElement("canvas");t.width=64,t.height=64,this._onLostBound=t=>{t.preventDefault()},this._onRestoreBound=()=>{this.restore()},this._onUnloadBound=()=>{this.destroy()},t.addEventListener("webglcontextlost",this._onLostBound,!1),t.addEventListener("webglcontextrestored",this._onRestoreBound,!1),window.addEventListener("unload",this._onUnloadBound,!1)}init(){const t=this._canvas;if(null!=t&&(null==this._gl||this._gl.isContextLost())){const e={alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1},i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);this._gl=i,null!=i&&(i.clearColor(1,1,1,0),this.makeVertexBuffer(),this.makeUvBuffer(),this.makeShaders(),this._texture=null)}return this}restore(){this.init()}getCanvas(){return this._canvas}getShader(t,e,i){const s=i?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);return null==s||(t.shaderSource(s,e),t.compileShader(s),t.getShaderParameter(s,t.COMPILE_STATUS))?s:(console&&console.error("Failed to compile the shader: "+t.getShaderInfoLog(s)),null)}makeShaders(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this.getShader(t,"\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nvarying mediump vec2 vTextureCoord;\nvoid main(void) {\n\tgl_Position = vec4(aVertexPosition, 0.0, 1.0);\n\tvTextureCoord = aTextureCoord;\n}\n",!1);if(null!=e){const i=this.getShader(t,"\nprecision mediump float;\n\nvarying mediump vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec2 uSize;\n\nfloat norm(vec2 v) {\n\treturn dot(v, v);\n}\n\nfloat norm(vec2 p, vec2 dp) {\n\tvec2 xy = p + dp;\n\tvec2 uvi = vec2(1.0) / uSize;\n\tvec2 uv = xy * uvi;\n\tvec4 t0 = vec4(texture2D(uSampler, uv).a);\n\tvec4 t1 = vec4(\n\t\ttexture2D(uSampler, uv + vec2(-uvi.x, 0.0 )).a,\n\t\ttexture2D(uSampler, uv + vec2(0.0 , -uvi.y)).a,\n\t\ttexture2D(uSampler, uv + vec2(+uvi.x, 0.0 )).a,\n\t\ttexture2D(uSampler, uv + vec2(0.0 , +uvi.y)).a\n\t);\n\tvec4 t2 = vec4(0.5);\n\tvec4 t3 = min(t1,t0);\n\tvec4 t4 = max(t1,t0);\n\n\tvec4 w0 = (t2 - t0) / (t1 - t0);\n\tvec4 s0 = vec4(\n\t\tt3.x < 0.5 && 0.5 <= t4.x,\n\t\tt3.y < 0.5 && 0.5 <= t4.y,\n\t\tt3.z < 0.5 && 0.5 <= t4.z,\n\t\tt3.w < 0.5 && 0.5 <= t4.w\n\t);\n\tvec4 l0 = vec4(\n\t\tnorm(dp + vec2(-w0.x, 0.0 )),\n\t\tnorm(dp + vec2(0.0 , -w0.y)),\n\t\tnorm(dp + vec2(+w0.z, 0.0 )),\n\t\tnorm(dp + vec2(0.0 , +w0.w))\n\t);\n\tvec4 c0 = vec4(100.0);\n\tvec4 r0 = mix(c0, l0, s0);\n\n\tvec4 w1 = w0 * vec4(0.5);\n\tvec4 s1 = vec4(\n\t\t0.5 < s0.x && 0.5 < s0.y,\n\t\t0.5 < s0.y && 0.5 < s0.z,\n\t\t0.5 < s0.z && 0.5 < s0.w,\n\t\t0.5 < s0.w && 0.5 < s0.x\n\t);\n\tvec4 l1 = vec4(\n\t\tnorm(dp + vec2(-w1.x, -w1.y)),\n\t\tnorm(dp + vec2(+w1.z, -w1.y)),\n\t\tnorm(dp + vec2(+w1.z, +w1.w)),\n\t\tnorm(dp + vec2(-w1.x, +w1.w))\n\t);\n\tvec4 r1 = mix(c0, l1, s1);\n\tvec4 r2 = min(r0, r1);\n\tvec2 r3 = min(r2.xy, r2.zw);\n\treturn min(r3.x, r3.y);\n}\n\nfloat normY(vec2 p, float dx) {\n\tfloat result = 100.0;\n\tfor (float dy=-6.0; dy < 6.5; dy += 1.0) {\n\t\tresult = min(result, norm(p, vec2(dx, dy)));\n\t}\n\treturn result;\n}\n\nfloat normX(vec2 p) {\n\tfloat result = 100.0;\n\tfor (float dx=-6.0; dx < 6.5; dx += 1.0) {\n\t\tresult = min(result, normY(p, dx));\n\t}\n\treturn result;\n}\n\nvoid main(void) {\n\tfloat t = texture2D(uSampler, vTextureCoord).a;\n\tfloat d = min( 6.0, sqrt(normX( vTextureCoord * uSize )) ) / 12.0;\n\td = clamp( mix( 0.5 - d, 0.5 + d, step( 0.5, t ) ), 0.0, 1.0 ) * 255.0;\n\tfloat r = floor(d);\n\td = (d - r) * 255.0;\n\tfloat g = floor(d);\n\tgl_FragColor = vec4(r * 0.00392156862745098, g * 0.00392156862745098, d - g, 1.0);\n}\n",!0);if(null!=i){const s=this._shaderProgram=t.createProgram();if(null!=s)return t.attachShader(s,e),t.attachShader(s,i),t.bindAttribLocation(s,0,"aVertexPosition"),t.bindAttribLocation(s,1,"aTextureCoord"),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)?(t.deleteShader(e),t.deleteShader(i),t.useProgram(s),this._samplerUniform=t.getUniformLocation(s,"uSampler"),this._sizeUniform=t.getUniformLocation(s,"uSize"),t.useProgram(null),s):(console&&console.error("Failed to link the program: "+t.getError()),t.deleteShader(e),t.deleteShader(i),null);t.deleteShader(e),t.deleteShader(i)}else t.deleteShader(e)}}return null}destroyShaders(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this._shaderProgram;null!=e&&(this._shaderProgram=null,t.useProgram(null),t.deleteProgram(e))}}updateTexture(t,e,i){const s=this._gl,n=this._canvas;if(null!=s&&!0!==s.isContextLost()&&null!=n){n.width===t&&n.height===e||(n.width=t,n.height=e,s.viewport(0,0,t,e));let o=this._texture;return null==o?(o=this._texture=s.createTexture(),s.bindTexture(s.TEXTURE_2D,o),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,i),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.bindTexture(s.TEXTURE_2D,null)):(s.bindTexture(s.TEXTURE_2D,o),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,i),s.bindTexture(s.TEXTURE_2D,null)),o}return null}destroyTexture(){const t=this._gl,e=this._texture;null!=t&&!0!==t.isContextLost()&&null!=e&&(this._texture=null,t.bindTexture(t.TEXTURE_2D,null),t.deleteTexture(e))}makeVertexBuffer(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this._vb=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e);const i=[-1,1,1,1,-1,-1,1,-1];return t.bufferData(t.ARRAY_BUFFER,new Float32Array(i),t.STATIC_DRAW),e}return null}destroyVertexBuffer(){const t=this._gl,e=this._vb;null!=t&&!0!==t.isContextLost()&&null!=e&&(this._vb=null,t.bindBuffer(t.ARRAY_BUFFER,null),t.deleteBuffer(e))}makeUvBuffer(){const t=this._gl;if(null!=t&&!0!==t.isContextLost()){const e=this._uvb=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e);const i=[0,0,1,0,0,1,1,1];return t.bufferData(t.ARRAY_BUFFER,new Float32Array(i),t.STATIC_DRAW),e}return null}destroyUvBuffer(){const t=this._gl,e=this._uvb;null!=t&&!0!==t.isContextLost()&&null!=e&&(this._uvb=null,t.bindBuffer(t.ARRAY_BUFFER,null),t.deleteBuffer(e))}render(){const t=this._gl,e=this._canvas,i=this._shaderProgram,s=this._vb,n=this._uvb,o=this._texture;if(null!=t&&!0!==t.isContextLost()&&null!=e&&null!=i&&null!=s&&null!=n&&null!=o){t.clear(t.COLOR_BUFFER_BIT),t.useProgram(i),t.bindBuffer(t.ARRAY_BUFFER,s);const r=this._vertexPositionAttribute;t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,n);const a=this._textureCoordAttribute;t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o),t.uniform1i(this._samplerUniform,0),t.uniform2f(this._sizeUniform,e.width,e.height),t.drawArrays(t.TRIANGLE_STRIP,0,4),t.bindTexture(t.TEXTURE_2D,null),t.bindBuffer(t.ARRAY_BUFFER,null),t.useProgram(null)}}read(t){const e=this._gl,i=this._canvas;if(null!=e&&!0!==e.isContextLost()&&null!=i){const e=i.width,s=i.height;t.width=e,t.height=s;const n=t.getContext("2d");null!=n&&n.drawImage(i,0,0)}}destroy(){this.destroyVertexBuffer(),this.destroyUvBuffer(),this.destroyShaders();const t=this._canvas;null!=t&&(this._canvas=null,t.removeEventListener("webglcontextlost",this._onLostBound,!1),t.removeEventListener("webglcontextrestored",this._onRestoreBound,!1),window.removeEventListener("unload",this._onUnloadBound,!1));const e=this._gl;if(null!=e){this._gl=null;const t=e.getExtension("WEBGL_lose_context");null!=t&&t.loseContext()}}static getInstance(){return null==Fs._INSTANCE&&(Fs._INSTANCE=new Fs),Fs._INSTANCE}}Fs._INSTANCE=null;class Hs{static measure(e,i){if(!i.measured){if("fontBoundingBoxAscent"in window.TextMetrics.prototype){const s=e.measureText(t.TextMetrics.METRICS_STRING);i.ascent=s.fontBoundingBoxAscent,i.descent=s.fontBoundingBoxDescent}else{const e=t.TextMetrics.measureFont(i.id);i.ascent=e.ascent,i.descent=e.descent}i.measured=!0}}static toSize(t){return this.setup(t),parseFloat(window.getComputedStyle(this._span).fontSize)}static setup(t){let e=this._span;null==e&&(e=document.createElement("span"),e.innerText="|ÉqÅ",e.style.border="none",e.style.margin="0px",this._span=e);let i=this._block;null==i&&(i=document.createElement("div"),i.style.display="inline-block",i.style.width="0px",i.style.height="0px",i.style.border="none",i.style.margin="0px",i.style.verticalAlign="baseline",this._block=i);let s=this._div;null==s&&(s=document.createElement("div"),s.style.position="absolute",s.style.padding="0px",s.style.margin="0px",s.style.visibility="hidden",s.appendChild(e),s.appendChild(i),document.body.appendChild(s),this._div=s),e.style.font=t}}class Gs{constructor(t){this._id="font-atlas:"+t,this._generator=Fs.getInstance().init(),this._canvas=document.createElement("canvas"),this._font=new Us(t),this._width=1,this._height=1;const e=new Map;e.set(D.SPACE,this.newChar(D.SPACE,zs.SPACE_R)),e.set(D.TAB,this.newChar(D.SOFT_TAB,zs.SPACE_R)),e.set(D.DOTS,this.newChar(D.DOTS,zs.LETTER_RNB));for(let t=0,i=D.ASCII.length;t<i;++t){const i=D.ASCII[t];e.set(i,this.newChar(i,zs.LETTER_RNB))}this._characters=e,this._isDirty=!0,this._isTouched=!1,this._life=Bs.LIFE}get id(){return this._id}get font(){return this._font}set font(t){this._font.id=t.id,this._font.size=t.size,this._font.italic=t.italic}get width(){return this._width}get height(){return this._height}get canvas(){return this._canvas}get generator(){return this._generator}get characters(){return this._characters}begin(){this._isTouched=!1,this._characters.forEach(t=>{t.type&zs.RESERVED||(t.ref=0)})}end(){const t=this._characters;this._isTouched?(this._life=Bs.LIFE,t.forEach((e,i)=>{e.ref<=0&&!(e.type&zs.RESERVED)&&(e.life-=1,e.life<=0&&(t.delete(i),this._isDirty=!0))})):(this._life-=1,this._life<=0&&0<t.size&&(t.clear(),this._isDirty=!0))}newChar(t,e){return new Bs(e,t,0,0,1,1,0)}add(t,e){const i=this._characters;for(let t=0,s=e.length;t<s;++t){const s=e[t],n=i.get(s);null!=n?(n.ref+=1,n.life=Bs.LIFE):(i.set(s,this.newChar(s,zs.LETTER)),this._isDirty=!0)}0<t.length&&(this._isTouched=!0)}get(t){return this._characters.get(t)}update(){if(this._isDirty){const t=this._canvas,e=this._generator;if(null!=t&&null!=e){const i=t.getContext("2d");if(null!=i){this._isDirty=!1;const s=this._font,n=s.size+14,o=this._characters,r=this.toPowerOf2(Math.ceil(Math.sqrt(o.size))*n);this._width=r;const a=(s.italic?"italic ":"")+s.size+"px "+s.id;i.font=a,i.textAlign="left",i.textBaseline="alphabetic",i.lineWidth=0,i.lineCap="round",i.lineJoin="miter",i.miterLimit=10,i.fillStyle="#FFFFFF",Hs.measure(i,s);const h=7,l=Math.round(.5*(n-(s.ascent+s.descent))+s.ascent);let c=0,u=0;o.forEach(t=>{const e=i.measureText(t.character).width,s=Math.ceil(h+e+h),o=n;r<=c+s&&(c=0,u+=n),t.x=c,t.y=u,t.width=s,t.height=o,t.advance=e,t.origin.x=c+h,t.origin.y=u+l,c+=s});const d=this._height=u+n;return t.width=r,t.height=d,i.font=a,i.textAlign="left",i.textBaseline="alphabetic",i.lineWidth=0,i.lineCap="round",i.lineJoin="miter",i.miterLimit=10,i.fillStyle="#FFFFFF",i.clearRect(0,0,r,d),o.forEach(t=>{i.fillText(t.character,t.origin.x,t.origin.y)}),e.updateTexture(r,d,t),e.render(),e.read(t),!0}}}return!1}get length(){return this._characters.size}toJson(){return{width:this._width,height:this._height,font:this._font,characters:this._characters}}toString(){return JSON.stringify(this.toJson())}destroy(){null!=this._generator&&(this._generator=null),null!=this._canvas&&(this._canvas=null),this._characters.clear()}toPowerOf2(t){let e=32;for(;e<t;)e<<=1;return e}}class Vs{constructor(){this._atlases=new Map}begin(){this._atlases.forEach(t=>{t.begin()})}end(){const t=this._atlases;t.forEach((e,i)=>{e.end(),e.length<=0&&(e.destroy(),t.delete(i))})}add(t,e,i){const s=this._atlases,n=s.get(t);if(null!=n)n.add(e,i);else{const n=new Gs(t);n.add(e,i),s.set(t,n)}}get(t){const e=this._atlases.get(t);return null!=e?e:null}update(t){const e=t.getBaseTexture();this._atlases.forEach(i=>{const s=i.id;if(i.update()){const n=t.get(s);if(null!=n){const s=i.width,o=i.height,r=e.resolution;n.frame.width=s,n.frame.height=o,n.width=s/r,n.height=o/r,t.toDirty()}else t.set(s,new Ns(i,e))}else t.contains(s)||t.set(s,new Ns(i,e))})}destroy(){const t=this._atlases;t.forEach(t=>{t.destroy()}),t.clear()}}class Ws extends Rs{constructor(t,e,i,s,n){super(t,e/n.resolution,i/n.resolution,0,n),this.source=s}render(t){const e=this.frame,i=e.x,s=e.y,n=e.width,o=e.height,r=this.source;r instanceof ImageData?(t.putImageData(r,i,s),t.putImageData(r,i-1,s,0,0,1,o),t.putImageData(r,i,s-1,0,0,n,1),t.putImageData(r,i+n,s,n-1,0,1,o),t.putImageData(r,i,s+o,0,o-1,n,1)):(t.drawImage(r,i,s,n,o),t.drawImage(r,0,0,1,o,i-1,s-1,1,o+2),t.drawImage(r,0,0,n,1,i,s-1,n,1),t.drawImage(r,n-1,0,1,o,i+n,s-1,1,o+2),t.drawImage(r,0,o-1,n,1,i,s+o,n,1))}}class Ks{constructor(t,e){this.texture=t,this.indexOffset=e}}class Xs{constructor(){this.index=0,this.baseTexture=null,this.units=[]}begin(){this.index=0,this.baseTexture=null}push(t,e){if(this.index<this.units.length){const i=this.units[this.index];i.texture=t,i.indexOffset=e}else this.units.push(new Ks(t,e));this.index+=1}end(){this.units.length!==this.index&&(this.units.length=this.index)}destroy(){this.units.length=0}}class Ys{constructor(t,e){const i=3*t,s=i;this.vertices=new Float32Array(2*s),this._vertexCapacity=s,this._vertexCount=0,this._vertexBuffer=null,this.steps=new Float32Array(6*s),this._stepBuffer=null,this.colors=new Float32Array(3*s),this._colorBuffer=null,this.uvs=new Float32Array(2*s),this._uvBuffer=null;const n=s<=65535;this.indices=n?new Uint16Array(i):new Uint32Array(i),this._indexCapacity=t,this._indexCount=0,this.indexCountRequested=0,this._indexBuffer=null,this._renderer=e,this._builder=new Xs,this._geometry=null}updateVertices(){const t=this._vertexBuffer;t&&t.update()}updateSteps(){const t=this._stepBuffer;t&&t.update()}updateColors(){const t=this._colorBuffer;t&&t.update()}updateUvs(){const t=this._uvBuffer;t&&t.update()}updateIndices(){const t=this._indexBuffer;t&&t.update()}getGeometry(){let e=this._geometry;return null==e&&(this._vertexBuffer=new t.Buffer(this.vertices,!1,!1),this._stepBuffer=new t.Buffer(this.steps,!1,!1),this._colorBuffer=new t.Buffer(this.colors,!1,!1),this._uvBuffer=new t.Buffer(this.uvs,!1,!1),this._indexBuffer=new t.Buffer(this.indices,!1,!0),this._geometry=e=(new t.Geometry).addIndex(this._indexBuffer).addAttribute("aPosition",this._vertexBuffer,2).addAttribute("aStepA",this._stepBuffer,2).addAttribute("aStepB",this._stepBuffer,4).addAttribute("aColor",this._colorBuffer,3).addAttribute("aUv",this._uvBuffer,2)),e}upload(){this._renderer.geometry.bind(this.getGeometry())}render(e){const i=this._renderer;i.geometry.bind(this.getGeometry());const s=this._builder.units,n=s.length;if(0<n){const o=t.DRAW_MODES.TRIANGLES;let r=null,a=s[0],h=0,l=3*a.indexOffset,c=0,u=t.Texture.WHITE;for(let d=0,p=n-1;d<p;++d)r=a,a=s[d+1],h=l,l=3*a.indexOffset,c=l-h,u=r.texture||t.Texture.WHITE,0<c&&u.valid&&(e.uniforms.sampler=i.texture.bind(u),i.geometry.draw(o,c,h));c=3*this._indexCount-l,u=a.texture||t.Texture.WHITE,0<c&&u.valid&&(e.uniforms.sampler=i.texture.bind(u),i.geometry.draw(o,c,l))}}update(t,e,i){const o=this._builder;o.begin();let r=0,a=0,h=t.get();for(;null!=h;h=t.next()){let l=h.uploaded;if(null==l){const t=n[h.type]||n[s.GROUP];if(null==t)break;const i=t(this,h,r,a,e);if(null==i)break;l=i}else if(!l.reinit(this,h,r,a))break;if(l.buildUnit(o),r+=l.getVertexCount(),a+=l.getIndexCount(),i){t.next();break}}return o.end(),this._vertexCount=r,this._indexCount=a,0<o.units.length}check(t,e,i,s){return this.indexCountRequested=s,t+i<=this._vertexCapacity&&e+s<=this._indexCapacity}destroy(){const t=this._geometry;t&&t.destroy(),this._builder.destroy()}}const js=[];class $s{constructor(){this.index=0,this.shapes=js,this.current=null}}class qs{constructor(){this._index=-1,this._datum=new $s,this._data=[this._datum],this._current=null}reset(t,e){this._index=0;const i=this._data[0];return i.index=-1,i.shapes=e,i.current=null,this._datum=i,null!=t?(this._current=t,t):this.next()}get(){return this._current}next(){for(;;){const t=this._datum,e=t.index+=1,i=t.shapes,s=e<i.length?t.current=i[e]:t.current=null;if(null==s){const t=this._index-=1,e=this._data;if(0<=t){const i=e[t];return this._datum=i,this._current=i.current}return this._current=null}{const t=s.children;if(!(0<t.length))return this._current=s,s;{const e=this._index+=1,i=this._data;if(e<i.length){const s=i[e];s.index=-1,s.shapes=t,s.current=null,this._datum=s}else{const e=new $s;i.push(e),e.index=-1,e.shapes=t,e.current=null,this._datum=e}}}}}}class Zs extends t.ObjectRenderer{constructor(e){super(e),Zs.SHADER=Zs.SHADER||t.Shader.from("\nattribute highp vec2 aPosition;\nattribute highp vec2 aStepA;\nattribute highp vec4 aStepB;\nattribute highp vec3 aColor;\nattribute highp vec2 aUv;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mediump float shapeScale;\nuniform mediump float antialiasWeight;\n\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nvec2 toInverse(in vec2 v) {\n\treturn vec2(-v.y, v.x);\n}\n\nvec4 toGeneral(in float v) {\n\tvec4 c = vec4(1.0, 1.0/64.0, 1.0/64.0/64.0, 1.0/64.0/64.0/64.0) * v;\n\tc -= fract(c);\n\tc -= c.yzwx * vec4(64.0, 64.0, 64.0, 0.0);\n\treturn c;\n}\n\nfloat toStrokeWidthScale(in float scale) {\n\treturn (\n\t\tscale == 3.0 || scale == 7.0 ?\n\t\tshapeScale : (\n\t\t\tscale == 1.0 || scale == 5.0 ?\n\t\t\tmin(1.0, shapeScale) : (\n\t\t\t\tscale == 2.0 || scale == 6.0 ?\n\t\t\t\tmax(1.0, shapeScale) : 1.0\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec2 toUnpackedF2x1024(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(1023.0, 1023.0);\n\treturn c;\n}\n\nvec3 toUnpackedF3x256(in float v) {\n\tvec3 c = vec3(1.0, 1.0/256.0, 1.0/256.0/256.0) * v;\n\tc -= fract(c);\n\tc -= c.yzx * vec3(256.0, 256.0, 0.0);\n\tc /= 255.0;\n\treturn c;\n}\n\nvec2 toPosition012(in vec2 v) {\n\treturn (projectionMatrix * translationMatrix * vec3(v, 1.0)).xy;\n}\n\nvec4 toStepB01(in vec4 sb) {\n\treturn vec4(sb.xy, toUnpackedF2x1024(sb.z));\n}\n\nvec4 toStepB2(in vec4 sb, in float strokeWidth) {\n\tfloat x = min(0.4, 0.4 / 12.0 * sb.x * antialiasWeight);\n\tfloat w = clamp(strokeWidth, 0.0, 1.0) * 0.4;\n\tfloat p = w * sb.y + sb.z;\n\tfloat y = 0.5 - p;\n\tfloat z = 0.5 - p - w;\n\treturn vec4(y, z, y - max(0.01, y - x), z - max(0.01, z - x));\n}\n\nvec2 toPosition3(in float type, in vec2 p, in float npacked, in float length, in float strokeWidth, out float shift) {\n\tvec3 t = vec3(1.0, 1.0/1024.0, 1.0/1024.0/1024.0) * npacked;\n\tt -= fract(t);\n\tt -= t.yzx * vec3(1024.0, 1024.0, 0.0);\n\tt *= vec3(1.0/511.5, 1.0/511.5, 1.0);\n\tt -= vec3(1.0, 1.0, 0.0);\n\tvec2 n0 = vec2(t.x, ((0.5 < t.z && t.z < 1.5) || 2.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.x * t.x)));\n\tvec2 n1 = vec2(t.y, (1.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.y * t.y)));\n\n\tvec2 n0i = toInverse(n0);\n\tvec2 n1i = toInverse(n1);\n\tfloat direction = sign(4.5 - type);\n\n\t// Offset\n\tfloat cross = dot(n0i, n1);\n\tbool bcross = 0.00001 < abs(cross);\n\tfloat crossi = (bcross ? 1.0 / cross : 0.0);\n\tfloat b = dot(n1 - n0, n0) * crossi;\n\tfloat offsetSize = direction * strokeWidth * 0.5;\n\tvec2 offset = n1 + n1i * b;\n\n\t// Miter\n\tvec2 pmiter = p + offsetSize * offset;\n\tfloat miterAngle0 = dot( n0i, offsetSize * offset - length * n0i );\n\tfloat miterAngle1 = dot( n1i, offsetSize * offset + length * n1i );\n\tfloat miterLength = dot( offset, offset );\n\tfloat miterSide = direction * cross;\n\n\t// Bevel\n\tvec2 n = (type == 4.0 || type == 6.0 ? n1 : n0);\n\tvec2 pbevel = p + offsetSize * n;\n\n\t//\n\tvec2 presult = (\n\t\t0.0 <= miterSide ?\n\t\t(miterAngle0 < 0.0 && 0.0 <= miterAngle1 && bcross ? pmiter : pbevel) :\n\t\t(miterLength < 6.0 && bcross ? pmiter : pbevel)\n\t);\n\tvec2 ni = (type == 4.0 || type == 6.0 ? n1i : n0i);\n\tshift = dot(ni, p - presult);\n\treturn toPosition012(presult);\n}\n\nvec2 toStepA3(in float type, in float strokeWidth) {\n\treturn vec2(type < 4.5 ? 1.0 : 0.0, strokeWidth);\n}\n\nvec4 toStepB3(in float shift, in float dash, in float strokeScaling, in float strokeWidthScale) {\n\tfloat l = aStepB.y + shift;\n\tfloat s = aStepA.x * (\n\t\tstrokeScaling == 4.0 || strokeScaling == 5.0 ||\n\t\tstrokeScaling == 6.0 || strokeScaling == 7.0 ?\n\t\tstrokeWidthScale : 1.0\n\t);\n\tfloat lt = aStepB.z;\n\treturn (dash < 0.5 ?\n\t\tvec4(l, 2.0 * abs(lt), 0.0, lt) :\n\t\t(dash < 3.5 ?\n\t\t\t(dash < 1.5 ?\n\t\t\t\tvec4(l, s, s, lt) :\n\t\t\t\t(2.5 < dash ?\n\t\t\t\t\tvec4(l, s, 2.0 * s, lt) :\n\t\t\t\t\tvec4(l, s, 0.5 * s, lt)\n\t\t\t\t)\n\t\t\t) :\n\t\t\t(dash < 4.5 ?\n\t\t\t\tvec4(l, 2.0 * s, s, lt) :\n\t\t\t\t(5.5 < dash ?\n\t\t\t\t\tvec4(l, 2.0 * s, 2.0 * s, lt) :\n\t\t\t\t\tvec4(l, 2.0 * s, 0.5 * s, lt)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t);\n}\n\nvoid toColors(in vec3 source, out vec4 fillColor, out vec4 strokeColor) {\n\tvec2 a = toUnpackedF2x1024(source.z);\n\tfillColor.xyz = toUnpackedF3x256(source.x).zyx * a.x;\n\tfillColor.w = a.x;\n\tstrokeColor.xyz = toUnpackedF3x256(source.y).zyx * a.y;\n\tstrokeColor.w = a.y;\n}\n\nvoid main(void) {\n\tvec4 general = toGeneral(aStepA.y);\n\tfloat type = general.x;\n\tfloat strokeScaling = general.y;\n\tfloat strokeWidthScale = toStrokeWidthScale(strokeScaling);\n\tfloat strokeWidth = strokeWidthScale * aStepA.x;\n\n\t// Type 0, 1\n\tvec2 p012 = toPosition012(aPosition);\n\tvec2 sa012 = strokeWidth * general.zw;\n\tvec4 sb01 = toStepB01(aStepB);\n\n\t// Type 2\n\tvec4 sb2 = toStepB2(aStepB, strokeWidth);\n\n\t// Type 3 ~ 6\n\tfloat shift3 = 0.0;\n\tvec2 p3 = toPosition3(type, aPosition, aStepB.x, aStepB.w, strokeWidth, shift3);\n\tvec2 sa3 = toStepA3(type, strokeWidth);\n\tvec4 sb3 = toStepB3(shift3, general.z, strokeScaling, strokeWidthScale);\n\n\t//\n\tgl_Position = vec4((2.5 < type ? p3 : p012), 0.0, 1.0);\n\tvType = type;\n\tvStepA = (2.5 < type ? sa3 : sa012);\n\tvStepB = (1.5 < type ? (2.5 < type ? sb3 : sb2) : sb01);\n\ttoColors(aColor, vColorFill, vColorStroke);\n\tvUv = aUv;\n}","\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nuniform sampler2D sampler;\nuniform mediump float antialiasWeight;\n\nvec4 toColor0(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tvec2 p0 = clamp(one - awd, zero, one);\n\tvec2 p1 = clamp(one - swd, zero, one);\n\tvec2 p2 = clamp(one - swd - awd, zero, one);\n\tvec2 s0 = smoothstep(p0, one, c);\n\tvec2 s1 = smoothstep(p2, p1, c);\n\tfloat s2 = max(s0.x, s0.y);\n\tfloat s3 = max(s1.x, s1.y);\n\treturn texture * (\n\t\tvColorStroke * (s3 - s2) +\n\t\tvColorFill * (1.0 - s3)\n\t);\n}\n\nvec4 toColor1(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tfloat s0 = smoothstep(length(c), length(c/clamp(one - awd, zero, one)), 1.0);\n\tfloat s1 = smoothstep(length(c/clamp(one - swd, zero, one)), length(c/clamp(one - swd - awd, zero, one)), 1.0);\n\treturn texture * (\n\t\tvColorStroke * (s0 - s1) +\n\t\tvColorFill * s1\n\t);\n}\n\nvec4 toColor2(in vec4 texture) {\n\tvec2 p0 = vStepB.xy;\n\tvec2 p1 = vStepB.zw;\n\tvec2 d = vec2(dot(texture, vec4(1.0, 1.0/255.0, 1.0/255.0/255.0, 0.0)));\n\tvec2 s = smoothstep(p0 - p1, p0 + p1, d);\n\treturn vColorStroke * (s.y - s.x) + vColorFill * s.x;\n}\n\nvec4 toColor3(in vec4 texture) {\n\tfloat l = vStepB.x;\n\tfloat lp0 = vStepB.y;\n\tfloat lp1 = vStepB.z;\n\tfloat lt = vStepB.w;\n\tfloat ld = antialiasWeight;\n\tfloat lm = mod(l, lp0 + lp1);\n\tfloat ls0 = (0.0 < lp1 ? smoothstep(0.0, ld, lm) - smoothstep(lp0, lp0 + ld, lm) : 1.0);\n\tfloat ls1 = (0.0 <= lt ? smoothstep(0.0, ld, l) - smoothstep(lt - ld, lt, l) : 1.0);\n\n\tfloat c = vStepA.x;\n\tfloat awd = antialiasWeight / vStepA.y;\n\tfloat p0 = clamp(awd, 0.0, 1.0);\n\tfloat p1 = clamp(1.0 - awd, 0.0, 1.0);\n\tfloat s0 = smoothstep(0.0, p0, c);\n\tfloat s1 = smoothstep(p1, 1.0, c);\n\treturn texture * vColorStroke * (s0 - s1) * ls0 * ls1;\n}\n\nvoid main(void) {\n\tvec4 texture = texture2D(sampler, vUv);\n\tgl_FragColor = (vType < 1.5 ?\n\t\t(vType < 0.5 ?\n\t\t\ttoColor0(texture) :\n\t\t\ttoColor1(texture)\n\t\t) :\n\t\t(vType < 2.5 ?\n\t\t\ttoColor2(texture) :\n\t\t\ttoColor3(texture)\n\t\t)\n\t);\n}"),this._shader=Zs.SHADER,this._iterator=new qs,this._bufferSizeMax=this.getBufferSizeMax(e)}getBufferSizeMax(t){const e=t.context,i=e.extensions;return 1<e.webGLVersion||i.uint32ElementIndex?1431655765:21845}updateAtlas(t,e,i,s,n){const o=t.image;if(null!=o){const i=e.get(o.url);if(null!=i)t.texture=i.texture;else{const i=new Ws(o.url,o.width,o.height,o.source,n);t.texture=i.texture,e.set(i.id,i)}}else t.texture=s;const r=t.text,a=r.characters;0<a.length&&i.add(r.family,a,r.nacharacters)}updateAtlases(t,e,i,s,n){for(let o=0,r=t.length;o<r;++o){const r=t[o];this.updateAtlas(r,e,i,s,n);const a=r.children;for(let t=0,o=a.length;t<o;++t){const o=a[t];this.updateAtlas(o,e,i,s,n),this.updateAtlases(o.children,e,i,s,n)}}}updateFontAtlas(t,e,i,s){const n=t.text,o=i.get(n.family);if(null!=o){const t=e.get(o.id);null!=t?(n.atlas=o,n.texture=t.texture):(n.atlas=void 0,n.texture=s)}else n.atlas=void 0,n.texture=s}updateFontAtlases(t,e,i,s){for(let n=0,o=t.length;n<o;++n){const o=t[n];this.updateFontAtlas(o,e,i,s);const r=o.children;for(let t=0,n=r.length;t<n;++t){const n=r[t];this.updateFontAtlas(n,e,i,s),this.updateFontAtlases(n.children,e,i,s)}}}render_(e,i,s,n){const o=this.renderer,r=this._shader;if(null!=r&&(null!=i||0<s.length)){const a=o.resolution,h=e.getBuffers(),l=e.toAntialiasWeight(a);if(n){const t=e.getAtlas(a),n=e.getFontAtlases();t.begin(),n.begin();const r=t.getDefaultTexture(),c=t.getBaseTexture();this.updateAtlases(s,t,n,r,c),n.end(),n.update(t),this.updateFontAtlases(s,t,n,r),t.end(),t.repack(),this.updateBuffers(i,s,h,o,l)}r.uniforms.shapeScale=e.toShapeScale(),r.uniforms.antialiasWeight=e.toPixelScale(a)*l,r.uniforms.translationMatrix=e.worldTransform.toArray(!0),o.shader.bind(r,!1),o.state.setBlendMode(t.utils.correctBlendMode(t.BLEND_MODES.NORMAL,!0));const c=h.length;if(1<c)for(let t=0;t<c;++t)h[t].upload();for(let t=0;t<c;++t)h[t].render(r)}}updateBuffers(t,e,i,s,n){const o=this._iterator;o.reset(t,e);let r=0,a=0;const h=5e3,l=this._bufferSizeMax;for(;null!=o.get();){let t=null,e=!1;if(0<a?(t=new Ys(a,s),i.splice(r,0,t),e=!0):r<i.length?(t=i[r],e=!1):(t=new Ys(h,s),i.push(t),e=!1),t.update(o,n,e))a=0,r+=1;else{if(a=t.indexCountRequested,!(a<=l))break;a=Math.ceil(a/h)*h,a=Math.min(a,l)}}if(r<i.length){for(let t=r,e=i.length;t<e;++t)i[t].destroy();i.length=r}}}Zs.SHADER=null;class Js extends t.DisplayObject{constructor(){super(),this._shapeRenderer=null,this.children=[],this._shape=null,this._childrenId=0,this._childrenIdRendered=-1,this._atlas=null,this._fontAtlases=new Vs,this._pixelScale=1,this._pixelScaleId=-2,this._shapeScale=1,this._shapeScaleId=-1,this._work=new t.Point,this._buffers=[]}calculateBounds(){this._bounds.clear()}onChildTransformChange(){}toDirty(){return this._childrenId+=1}isDirty(){return this._childrenIdRendered<this._childrenId}render(t){if(!this.visible||this.worldAlpha<=0||!this.renderable)return;const e=this._childrenId,i=this._childrenIdRendered;this._childrenIdRendered=e;const s=i<e;let n=this._shapeRenderer;null==n&&(n=this._shapeRenderer=new Zs(t)),t.batch.setObjectRenderer(n);const o=this.mask,r=this._shape,a=this.children;o?(t.mask.push(this,o),n.render_(this,r,a,s),t.mask.pop(this)):n.render_(this,r,a,s)}containsPoint(t){return!1}getFontAtlases(){return this._fontAtlases}getAtlas(t){let e=this._atlas;return null==e&&(e=new Ls(t),this._atlas=e),e}getBuffers(){return this._buffers}toShapeScale(){this.updateTransform();const t=this.transform,e=t._worldID;if(e!==this._shapeScaleId){this._shapeScaleId=e;const i=t.worldTransform,s=i.a,n=i.b;this._shapeScale=1/Math.sqrt(s*s+n*n)}return this._shapeScale}getShapeScale(){return this._shapeScale}toPixelScale(t){const e=this.toShapeScale(),i=this._shapeScaleId;return this._pixelScaleId!==i&&(this._pixelScaleId=i,this._pixelScale=1/t*e),this._pixelScale}getPixelScale(){return this._pixelScale}toAntialiasWeight(t){return 1.25/t}hitTest(t,e){const i=this._work,s=this.children;for(let n=s.length-1;0<=n;--n){const o=s[n];if(o.visible){o.toLocal(t,void 0,i);const s=o.contains(i.x,i.y);if(null!=s&&(null==e||e(s)))return s}}return null}hitTestBBox(t,e){const i=this._work,s=this.children;for(let n=s.length-1;0<=n;--n){const o=s[n];if(o.visible&&(o.toLocal(t,void 0,i),o.containsBBox(i.x,i.y)&&(null==e||e(o))))return o}return null}destroy(){const t=this._buffers;if(null!=t)for(let e=0,i=t.length;e<i;++e)t[e].destroy();this._buffers.length=0;const e=this.children;for(let t=e.length-1;0<=t;--t)e[t].destroy();e.length=0;const i=this._atlas;null!=i&&i.destroy(),this._fontAtlases.destroy(),super.destroy()}}class Qs extends Xi{constructor(t,e,i,n=s.EMBEDDED_LAYER){super(e,i,n),this._name=t}get name(){return this._name}newGroupFill(){return new J(this,!1,16777215,1)}isGroupSizeFittable(){return!1}newGroupSize(t,e){const i=q.SIZE_X,s=q.SIZE_Y;return new Vi(this,i,s,i,s)}clone(){const t=this.newClone().copy(this),e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].clone();s.parent=t,t.children.push(s)}t.onChildTransformChange(),t.toDirty();const i=this.size;if(i instanceof Vi){const e=i.base;t.size.set(e.x,e.y).init().set(i.x,i.y)}else t.size.init();return t}newClone(){return new(0,this.constructor)(this._name,this._mode,this._depth,this.type)}serializeChildren(t){return[]}serializeImage(t){return-1}serializeGradient(t){return-1}}class tn{static toLayers(t,e){const i=[],s=this.toLayer(t);if(s){const t=s.parent;if(t){const s=t.children,n=s.length;for(let t=0,o=e.length;t<o;++t){const o=e[t];0<=o&&o<n&&i.push(s[o])}}}return i}static toLayer(t){let e=t.parent;for(;null!=e;){if(e instanceof Js)return e;if(e instanceof Qs)return e;e=e.parent}return null}static show(t){return!t.visible&&(t.visible=!0,!0)}static showAll(t){let e=!1;for(let i=0,s=t.length;i<s;++i){const s=t[i];s.visible||(s.visible=!0,e=!0)}return e}static hide(t){return!!t.visible&&(t.visible=!1,!0)}static hideAll(t){let e=!1;for(let i=0,s=t.length;i<s;++i){const s=t[i];s.visible&&(s.visible=!1,e=!0)}return e}static bringToFront(t){const e=t.parent;return!!e&&this.doBringToFront(t,e.children,0)}static bringAllToFront(t){const e=t.length;if(0<e){const i=t[0].parent;if(i){let s=!1;const n=i.children;for(let i=0;i<e;++i){const o=t[e-1-i];this.doBringToFront(o,n,i)&&(s=!0)}return s}}return!1}static doBringToFront(t,e,i){const s=e.length-1-i;for(let i=s;0<=i;--i){const n=e[i];if(n===t){if(i!==s){for(let t=i+1;t<=s;++t)e[t-1]=e[t];return e[s]=n,!0}return!1}}return!1}}const en={NONE:0,CTRL:1,SHIFT:2,ALT:4,AND:8,OR:16,NOT_NONE:23};class sn{static from(t){const e="data"in t?t.data.originalEvent:t;return(e.ctrlKey?en.CTRL:en.NONE)|(e.altKey?en.ALT:en.NONE)|(e.shiftKey?en.SHIFT:en.NONE)}static match(t,e){return e&en.OR?!!(sn.from(t)&e):sn.from(t)===e}}class nn{static get touchable(){return"ontouchstart"in document}static get tap(){return"pointertap"}static get down(){return"pointerdown"}static get enter(){return"pointerenter"}static get leave(){return"pointerleave"}static get move(){return"pointermove"}static get out(){return"pointerout"}static get over(){return"pointerover"}static get up(){return"pointerup"}static get upoutside(){return"pointerupoutside"}static get cancel(){return"pointercancel"}static get righttap(){return"rightclick"}static get rightdown(){return"rightdown"}static get rightup(){return"rightup"}static get rightupoutside(){return"rightupoutside"}static toGlobal(t,e,i){if("touches"in t){const s=t.changedTouches,n=s[s.length-1];null!=n?e.mapPositionToPoint(i,n.clientX,n.clientY):e.mapPositionToPoint(i,0,0)}else e.mapPositionToPoint(i,t.clientX,t.clientY);return i}static onDblClick(t,e){if(t.addEventListener("dblclick",t=>e(t,!1)),this.touchable){let i=0,s=0,n=0,o=0;t.addEventListener("touchstart",t=>{if(0!==i&&2!==i)return void(i=0);const e=t.touches,o=e.length;if(o<=0)return void(i=0);const r=e.item(o-1);null!=r?(i+=1,s=r.clientX,n=r.clientY):i=0}),t.addEventListener("touchend",t=>{if(1!==i&&3!==i)return void(i=0);const r=t.changedTouches,a=r.length;if(a<=0)return void(i=0);const h=r[a-1];if(null==h)return void(i=0);const l=s-h.clientX,c=n-h.clientY;this.CLICK_DISTANCE_THRESHOLD<=Math.abs(l)+Math.abs(c)?i=0:1===i?(o=t.timeStamp,i=2):t.timeStamp-o<this.DBLCLICK_INTERVAL_THRESHOLD?(i=0,e(t,!0)):(o=t.timeStamp,i=2)}),t.addEventListener("touchcancel",()=>{i=0})}}static contains(t,e){let i=e;for(;null!=i&&i!==t;)i=i.parent;return i===t}}nn.CLICK_DISTANCE_THRESHOLD=10,nn.DBLCLICK_INTERVAL_THRESHOLD=333,nn.LONG_CLICK_THRESHOLD=750;class on{constructor(){this.pointers=new Map,this.center=new t.Point,this.scale=0,this.time=0,this.distance=0}start(t){const e=t.data.originalEvent;"pointerId"in e&&this.pointers.set(e.pointerId,e),this.doUpdate(t)}isUpdatable(t){const e=t.data.originalEvent;return!("pointerId"in e)||this.pointers.has(e.pointerId)}update(t){const e=t.data.originalEvent;"pointerId"in e&&this.pointers.set(e.pointerId,e),this.doUpdate(t)}end(t){let e=!0;const i=t.data.originalEvent;if("touches"in i)e=i.touches.length<=0;else if("pointerId"in i){const t=this.pointers;t.delete(i.pointerId),e=t.size<=0}return this.doUpdate(t),e}bind(t){const e=this.interactionManager;if(e){const t=this.onMove;t&&e.on(nn.move,t);const i=this.onEnd;i&&(e.on(nn.up,i),e.on(nn.upoutside,i),e.on(nn.cancel,i))}}unbind(){const t=this.interactionManager;if(t){const e=this.onMove;e&&t.off(nn.move,e);const i=this.onEnd;i&&(t.off(nn.up,i),t.off(nn.upoutside,i),t.off(nn.cancel,i))}}doUpdate(t){const e=this.interactionManager,i=this.center,s=t.data.originalEvent;if(this.scale=0,this.time=s.timeStamp,"touches"in s){const t=s.touches,n=t.length;if(0<n){let s=0,o=0;for(let e=0,i=t.length;e<i;++e){const i=t[e];s+=i.clientX,o+=i.clientY}if(s/=n,o/=n,e?e.mapPositionToPoint(i,s,o):i.set(s,o),1<n){let e=0;for(let i=1,n=t.length;i<n;++i){const n=t[i],r=n.clientX-s,a=n.clientY-o;e=Math.max(e,r*r+a*a)}this.scale=Math.sqrt(e)}}}else if("pointerId"in s){const t=this.pointers,s=t.size;if(0<s){let n=0,o=0;if(t.forEach(t=>{n+=t.clientX,o+=t.clientY}),n/=s,o/=s,e?e.mapPositionToPoint(i,n,o):i.set(n,o),1<s){let e=0;t.forEach(t=>{const i=t.clientX-n,s=t.clientY-o;e=Math.max(e,i*i+s*s)}),this.scale=Math.sqrt(e)}}}else i.copyFrom(t.data.global)}}class rn{static LINEAR(t){return t}static ELASTIC(t){return t*(3*(1-t)*(1-t)+t*(3*(1-t)+t))}static QUAD_IN_OUT(t){return t<.5?2*t*t:(4-2*t)*t-1}}class an extends t.utils.EventEmitter{constructor(t){var e,i,s;super(),this._id=null,this._target=null!==(e=null==t?void 0:t.target)&&void 0!==e?e:null,this._startTime=0,this._duration=null!==(i=null==t?void 0:t.duration)&&void 0!==i?i:200,this._durationInverse=1/Math.max(1,this._duration),this._reverse=!1,this._onTime=null==t?void 0:t.onTime,this._onTimeBaseBound=()=>{this.onTimeBase()},this._onStart=null==t?void 0:t.onStart,this._onEnd=null==t?void 0:t.onEnd,this._onStop=null==t?void 0:t.onStop,this._timing=null!==(s=null==t?void 0:t.timing)&&void 0!==s?s:rn.ELASTIC;const n=null==t?void 0:t.on;if(n)for(const t in n){const e=n[t];e&&this.on(t,e)}}get target(){return this._target}set target(t){this._target=t}get duration(){return this._duration}set duration(t){this._duration=t,this._durationInverse=1/Math.max(1,t)}start(t=!1){this.stop(),this._startTime=Date.now(),this._reverse=t,this._id=window.setTimeout(this._onTimeBaseBound,0),this.onStart(t);const e=this._duration,i=this.toTime(t?e:0);this.onTime(i,t,0)}onStart(t){const e=this._onStart;null!=e&&e(t,this),this.emit("start",t,this)}onTime(t,e,i){const s=this._onTime;null!=s&&s(t,e,i,this),this.emit("time",t,e,i,this)}onEnd(t){const e=this._onEnd;null!=e&&e(t,this),this.emit("end",t,this)}onStop(t){const e=this._onStop;null!=e&&e(t,this),this.emit("stop",t,this)}isStarted(){return null!=this._id}isReverse(){return this._reverse}onTimeBase(){if(null!=this._id){this._id=null;const t=Date.now()-this._startTime,e=this._duration,i=this._reverse;if(t<e){this._id=window.setTimeout(this._onTimeBaseBound,0);const s=this.toTime(i?e-t:t);this.onTime(s,i,t)}else{const s=this.toTime(i?0:e);this.onTime(s,i,t),this.onEnd(i)}}}toTime(t){return this._timing(t*this._durationInverse,this)}stop(){const t=this._id;null!=t&&(this._id=null,window.clearTimeout(t),this.onStop(this._reverse))}end(){const t=this._id;if(null!=t){this._id=null,window.clearTimeout(t);const e=this._reverse,i=Date.now()-this._startTime,s=this._duration,n=this.toTime(e?0:s);this.onTime(n,e,i),this.onEnd(e)}}}class hn{constructor(t,e,i,s){this.dx=t,this.dy=e,this.ds=i,this.dt=s}set(t,e,i,s){this.dx=t,this.dy=e,this.ds=i,this.dt=s}}class ln{constructor(t,e,i){var s;this._histories=[],this._historiesSorted=[],this._historyBegin=0,this._historyEnd=-1,this._dx=0,this._dy=0,this._ds=0,this._dt=0,this._dtw=0,this._t=0,this._duration=333*(null!==(s=null==i?void 0:i.duration)&&void 0!==s?s:1),this._animation=new an({onTime:t=>{this.onEase(t)},onEnd:()=>{this.onEaseEnd()},timing:rn.LINEAR,duration:this._duration}),this._onMove=t,this._onEnd=e}onStart(){const t=this._histories;for(let e=t.length,i=ln.HISTORY_CAPACITY;e<i;++e)t.push(new hn(0,0,1,0));this._historyBegin=0,this._historyEnd=-1,this._animation.stop()}onMove(t,e,i,s){const n=ln.HISTORY_CAPACITY,o=this._historyEnd,r=(o+1)%n;this._historyEnd=r;const a=this._historyBegin;(r<o||0<=o&&o<a)&&(this._historyBegin=(a+1)%n),this._histories[r].set(t,e,i,s)}updateHistoriesSorted(t){const e=this._histories,i=this._historiesSorted,s=this._historyBegin,n=this._historyEnd,o=e.length;if(n<0)return i.length=0,t;if(n<s){let r=t;i.length=0;for(let t=n;0<=t;--t){const s=e[t];if(!(r+s.dt<160))return r;r+=s.dt,i.push(s)}for(let t=o-1;s<=t;--t){const s=e[t];if(!(r+s.dt<160))return r;r+=s.dt,i.push(s)}return r}{let o=t;i.length=0;for(let t=n;s<=t;--t){const s=e[t];if(!(o+s.dt<160))return o;o+=s.dt,i.push(s)}return o}}onEnd(t){const e=this._duration,i=e-t;if(i<=0)return this.onEaseEnd();this.updateHistoriesSorted(t);const s=this._historiesSorted,n=s.length;if(n<=0)return this.onEaseEnd();let o=0,r=0,a=0,h=0;for(let t=0;t<n;++t){const e=s[t];o+=e.dx,r+=e.dy,a+=e.ds,h+=e.dt}if(h<=0)return this.onEaseEnd();const l=1/n;o*=l,r*=l,a*=l,h*=l*(e/i),this._dx=o,this._dy=r,this._ds=a,this._dt=h;const c=this._animation;c.duration=i,this._t=0,this._dtw=i/h,c.start()}onEase(t){const e=this._t;this._t=t;const i=(1-.5*(t+e))*(t-e)*this._dtw;this._onMove(this._dx*i,this._dy*i,1+(this._ds-1)*i,t)}onEaseEnd(){this._onEnd()}stop(){this._animation.stop()}}ln.HISTORY_CAPACITY=5;class cn{constructor(t,e){null!=t&&(this._onTap=t.tap,this._onLongPress=t.longpress),this._threshold=this.toThreshold(e),this._unused=[],this._used=new Map}toThreshold(t){var e,i;if(null!=t){const s=t.threshold;if(null!=s)return{distance:null!==(e=s.distance)&&void 0!==e?e:10,long:null!==(i=s.long)&&void 0!==i?i:500}}return{distance:10,long:500}}newData(t){const e=this._used,i=e.get(t);if(null!=i)return i;const s=this._unused.pop();if(null!=s)return e.set(t,s),s;const n=new on;return n.easing=void 0,n.onMove=this.newOnMove(n),n.onEnd=this.newOnEnd(n),e.set(t,n),n}deleteData(t){const e=t.target;if(e&&this._used.delete(e)){const e=t.timeoutId;null!=e&&(t.timeoutId=void 0,window.clearTimeout(e)),t.target=void 0,t.pointers.clear(),this._unused.push(t)}}newOnMove(t){return e=>{this.onMove(e,t)}}newOnEnd(t){return e=>{this.onEnd(e,t)}}onDown(t,e){var i;if(null==this._onTap&&null==this._onLongPress)return;const s=ot.getLayer(t);if(null!=s)if(e.stopPropagation(),t.state.isGesturing)null===(i=this._used.get(t))||void 0===i||i.start(e);else{const i=this.newData(t);i.target=t,i.distance=0,t.state.isGesturing=!0;const n=s.renderer.plugins.interaction;i.interactionManager=n,i.start(e),i.bind(e),this.start(t,i,e)}}onMove(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;if(!e.isUpdatable(t))return;const s=e.center,n=s.x,o=s.y;e.update(t);const r=s.x-n,a=s.y-o;e.distance+=Math.abs(r)+Math.abs(a)}onEnd(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;if(!e.end(t))return;i.state.isGesturing=!1;const s=e.interactionManager;if(e.interactionManager=void 0,s){const t=e.onMove;t&&s.off(nn.move,t);const i=e.onEnd;i&&(s.off(nn.up,i),s.off(nn.cancel,i))}this.end(i,e,t),this.deleteData(e)}onLongPress(t,e,i){if(e.timeoutId=void 0,e.distance<this._threshold.distance){e.distance=this._threshold.distance;const s=this._onLongPress;null!=s&&s(t,i)}}start(t,e,i){const s=this._threshold.long;0<=s&&(e.timeoutId=window.setTimeout(()=>{this.onLongPress(t,e,i)},s))}end(t,e,i){const s=e.timeoutId;if(null!=s&&(e.timeoutId=void 0,window.clearTimeout(s)),e.distance<this._threshold.distance){const e=this._onTap;e&&e(t,i)}}stop(t){const e=this._used.get(t);null!=e&&this.deleteData(e)}}class un{constructor(t){var e,i,s;const n=t.on;if(n){this._onStart=n.start,this._onMove=n.move,this._onEnd=n.end,this._onStop=n.stop;const t=n.easing;null!=t&&(this._onEasingStart=t.start,this._onEasingEnd=t.end)}this._modifier=null!==(e=null==t?void 0:t.modifier)&&void 0!==e?e:en.NONE;const o=t.checker,r=sn.match;this._checkerStart=null!==(i=null==o?void 0:o.start)&&void 0!==i?i:r,this._checkerMove=null!==(s=null==o?void 0:o.move)&&void 0!==s?s:r,this._easing=t.easing,this._touch=!!t.touch,this._unused=[],this._used=new Map,this._tap=new cn(t.on,t.tap);const a=t.bind;null!=a&&this.bind(a)}newData(t){const e=this._used,i=e.get(t);if(null!=i)return i;const s=this._unused.pop();if(null!=s)return e.set(t,s),s;const n=new on;return n.easing=this.newEasing(n),n.onMove=this.newOnMove(n),n.onEnd=this.newOnEnd(n),e.set(t,n),n}newEasing(t){const e=this._easing;if(null==e||!1!==e)return new ln((e,i,s,n)=>{this.onEasingMove(e,i,s,n,t)},()=>{this.onEasingEnd(t)},this.toEasingOptions(e))}toEasingOptions(t){return null==t||!0===t?void 0:t}deleteData(t){const e=t.target;e&&this._used.delete(e)&&(t.target=void 0,t.pointers.clear(),this._unused.push(t))}bind(t){return t.on(nn.down,e=>{this.onDown(t,e)}),this}isTouch(t){const e=t.data.originalEvent;return"touches"in e||"pointerId"in e&&"mouse"!==e.pointerType}onDown(t,e){var i;if(this._touch&&!this.isTouch(e))return;if(!this._checkerStart(e,this._modifier,t))return this._tap.onDown(t,e);const s=ot.getLayer(t);if(null!=s)if(e.stopPropagation(),t.state.isGesturing)null===(i=this._used.get(t))||void 0===i||i.start(e);else{const i=this._onStart;null!=i&&i(t);const n=this.newData(t);n.target=t,n.distance=0,t.state.isGesturing=!0;const o=s.renderer.plugins.interaction;n.interactionManager=o,n.start(e);const r=n.easing;r&&r.onStart(),n.bind(e),this._tap.start(t,n,e)}}newOnMove(t){return e=>{this.onMove(e,t)}}newOnEnd(t){return e=>{this.onEnd(e,t)}}onMove(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;if(!e.isUpdatable(t)||!this._checkerMove(t,this._modifier,i))return;const s=e.center,n=s.x,o=s.y,r=e.scale,a=e.time;e.update(t);const h=s.x,l=s.y,c=e.scale,u=h-n,d=l-o,p=e.time-a,_=1e-5,g=_<r&&_<c?c/r:1;e.distance+=Math.abs(u)+Math.abs(d);const f=e.easing;f&&f.onMove(u,d,g,p);const m=this._onMove;null!=m&&(0===u&&0===d&&1===g||m(i,u,d,h,l,g))}onEnd(t,e){const i=e.target;if(null==i||!i.state.isGesturing)return;const s=e.time;if(!e.end(t))return;i.state.isGesturing=!1;const n=e.interactionManager;if(e.interactionManager=void 0,n){const t=e.onMove;t&&n.off(nn.move,t);const i=e.onEnd;i&&(n.off(nn.up,i),n.off(nn.cancel,i))}const o=this._onEnd;null!=o&&o(i),this._tap.end(i,e,t);const r=this._onEasingStart;r&&r(e.target);const a=e.easing;if(a)a.onEnd(e.time-s);else{this.deleteData(e);const t=this._onEasingEnd;t&&t(e.target)}}onEasingMove(t,e,i,s,n){const o=n.target;if(null==o)return;const r=this._onMove;if(null==r)return;if(0===t&&0===e&&1===i)return;const a=n.center,h=a.x+t,l=a.y+e;a.set(h,l),r(o,t,e,h,l,i)}onEasingEnd(t){const e=t.target;if(this.deleteData(t),null!=e){const t=this._onEasingEnd;t&&t(e)}}stop(t){this._tap.stop(t);const e=this._used.get(t);if(null!=e){const i=e.easing;null!=i&&i.stop(),this.deleteData(e);const s=this._onStop;s&&s(t)}}}const dn={NONE:0,DRAG:1,PINCH:2,ALL:3};class pn extends ve{constructor(t){super(t,pe.NONE),this._layers=new Map,this._operationType=t.operationType,this._scaleMin=t.scaleMin,this._scaleMax=t.scaleMax}initialize(t,e){if(super.initialize(t,e),null==this._layers.get(t)){const e=tn.toLayer(t);null!=e&&this._layers.set(t,e)}}onDown(e,i,s){if(super.onDown(e,i,s),s instanceof t.InteractionEvent){const t=this._layers.get(e),i=s.data.originalEvent.timeStamp;t&&this.condition(e,i,ge)&&this.getGestureUtil().onDown(t,s)}}getGestureUtil(){var t;return null!==(t=pn.GESTURE_UTIL)&&void 0!==t?t:pn.GESTURE_UTIL=this.newGestureUtil()}newGestureUtil(){const e=new t.Point;return new un({on:{move:(t,i,s,n,o,r)=>{this.onGestureMove(t,i,s,n,o,r,e)}}})}onGestureMove(t,e,i,s,n,o,r){const a=t.parent;if(a){const h=t.transform,l=this._operationType;let c=!1,u=1;if(l&dn.PINCH){const t=h.scale,e=t.y,i=Math.min(this._scaleMax,Math.max(this._scaleMin,e*o));u=i/e,t.set(i,i),c=!0}if(l&dn.DRAG){a.toLocal(r.set(s,n),void 0,r);const t=r.x,o=r.y,l=s-e,d=n-i;a.toLocal(r.set(l,d),void 0,r);const p=r.x,_=r.y,g=h.position,f=(g.x-p)*u+t,m=(g.y-_)*u+o;g.set(f,m),c=!0}c&&ot.update(t)}}toSize(t,e){return"size"in t?e.copyFrom(t.size):e.set(t.width,t.height),e}}class _n extends ve{constructor(t){super(t,pe.NONE),this._operationType=t.operationType,this._scaleMin=t.scaleMin,this._scaleMax=t.scaleMax}onDown(e,i,s){super.onDown(e,i,s),s instanceof t.InteractionEvent&&this.condition(e,s.data.originalEvent.timeStamp,ge)&&this.getGestureUtil().onDown(e,s)}getGestureUtil(){var t;return null!==(t=_n.GESTURE_UTIL)&&void 0!==t?t:_n.GESTURE_UTIL=this.newGestureUtil()}newGestureUtil(){const e=new t.Point;return new un({on:{move:(t,i,s,n,o,r)=>{this.onGestureMove(t,i,s,n,o,r,e)}}})}onGestureMove(t,e,i,s,n,o,r){const a=t.parent;if(a){const h=t.transform,l=this._operationType;let c=!1,u=1;if(l&dn.PINCH){const t=h.scale,e=t.y,i=Math.min(this._scaleMax,Math.max(this._scaleMin,e*o));u=i/e,t.set(i,i),c=!0}if(l&dn.DRAG){a.toLocal(r.set(s,n),void 0,r);const t=r.x,o=r.y,l=s-e,d=n-i;a.toLocal(r.set(l,d),void 0,r);const p=r.x,_=r.y,g=h.position,f=(g.x-p)*u+t,m=(g.y-_)*u+o;g.set(f,m),c=!0}c&&ot.update(t)}}}const gn={SHAPE:0,LAYER:1},fn={INPUT_TEXT:0,INPUT_INTEGER:1,INPUT_REAL:2,EMIT_EVENT:3,WRITE_BOTH:4,WRITE_LOCAL:5,WRITE_REMOTE:6,HTML_ELEMENT:7,HTML_ELEMENT_WITHOUT_POINTER_EVENTS:8,SHOW_HIDE_LAYER:9,GESTURE_LAYER:10,GESTURE:11,EXECUTE:12,EXTENSION:1e3};class mn extends Ie{constructor(t="",e,i,s=.05,n=20){super(Oe.GESTURE,t,e),this.operationType=i,this.scaleMin=s,this.scaleMax=n}toRuntime(){switch(this.subtype){case gn.SHAPE:return new _n(this);case gn.LAYER:return new pn(this)}}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype},${this.operationType},${this.scaleMin},${this.scaleMax}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=this.toSubType(t),n=t[3],o=t[4],r=t[5];return new mn(i,s,n,o,r)}static toSubType(t){if(t[0]!==Oe.MISC)return t[2];switch(t[2]){case fn.GESTURE:return gn.SHAPE;case fn.GESTURE_LAYER:return gn.LAYER}}}const vn={INVISIBLE:"INVISIBLE",INTERACTIVE:"INTERACTIVE",DRAGGABLE:"DRAGGABLE",PINCHABLE:"PINCHABLE"},Tn=(t,e,i,s,n)=>{var o,r,a;const h=((t,e)=>{if(Et(t))return t;{const i=e.resources;return 0<=t&&t<=i.length?i[t]:""}})(t[0],e),l=n?n(h,e):new Qs(h,e.mode,e.depth),c=t[1];null==c||2&c||(l.visible=!1,l.state.add(vn.INVISIBLE));const u=-.5*i+(t[2]||0),d=-.5*s+(t[3]||0);l.transform.position.set(u,d);const p=null!==(o=t[4])&&void 0!==o?o:i,_=null!==(r=t[5])&&void 0!==r?r:s;l.size.set(p,_),l.size.init();const g=t[6];if(null!=g&&l.fill.deserialize(g,e),e.mode===Li.VIEWER){const e=null!==(a=t[7])&&void 0!==a?a:1,i=1&e,s=2&e,n=4&e;if(s||n){const t=(s?dn.DRAG:dn.NONE)|(n?dn.PINCH:dn.NONE);l.action.add(new mn("",gn.LAYER,t))}(i||s||n)&&(l.interactive=!0)}return l};class wn{constructor(t,e){this.children=[],this._width=t,this._height=e}hasConnectors(t){for(let e=0,i=t.length;e<i;++e){const i=t[e];if(i instanceof Os)return!0;const s=i.children;if(0<s.length&&this.hasConnectors(s))return!0}return!1}newHasConnectors(){const t=new Map,e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i];t.set(s,this.hasConnectors(s.children))}return t}copyTo(t){var e;const i=null!==(e=this._hasConnectors)&&void 0!==e?e:this._hasConnectors=this.newHasConnectors(),s=this.children,n=t.children;for(let e=0,o=s.length;e<o;++e){const o=s[e],r=o.clone();r.parent=t,n.push(r),i.get(o)&&As.move(o,r)}t.onChildTransformChange(),t.toDirty(),t.onAttach()}deserialize(t,e){const i=t.length;if(0<i){const s=this._width,n=this._height;for(let o=0;o<i;++o)this.children.push(Tn(t[o],e,s,n))}}}class En{static parse(t){if(null!=t&&Et(t))try{const e=JSON.parse(t);if(null!=e&&wt(e.version)&&Et(e.name)){if(wt(e.width)&&wt(e.height)&&vt(e.items)&&vt(e.resources))return e;if(Et(e.data))return this.toSerialized(e)}}catch(t){}return null}static toSimple(t){return{version:t.version,id:t.id,name:t.name,label:t.label,category:t.category,summary:t.summary,description:t.description,thumbnail:t.thumbnail,data:JSON.stringify({width:t.width,height:t.height,background:t.background,tile:t.tile,resources:t.resources,data:t.data||t.tags,pieces:t.pieces,layers:t.layers,items:t.items,snap:t.snap})}}static toSerialized(t){if(!("items"in t)){const e=JSON.parse(t.data),i={version:t.version,id:t.id,name:t.name,label:t.label,width:e.width,height:e.height,category:t.category,summary:t.summary,description:t.description,background:e.background,tile:e.tile,resources:e.resources,data:e.data||e.tags,pieces:e.pieces,layers:e.layers,items:e.items,snap:e.snap,thumbnail:t.thumbnail};if(null==i.data){const e=t.tags;null!=e&&(i.data=JSON.parse(e))}if(null==i.pieces){const e=t.pieces;null!=e&&(i.pieces=JSON.parse(e))}return i}return t}static newLayer(t,e,i){e.deserialize(t.layers,i);const s=t.items,n=qi(s,i);return null!=n?n.then(t=>{const i=e.children;for(let e=0,n=t.length;e<n;++e){const n=s[e],o=t[e],r=i[n[16]];null!=r&&(o.parent=r,o.uploaded=void 0,r.children.push(o))}for(let t=0,e=i.length;t<e;++t){const e=i[t];e.onChildTransformChange(),e.toDirty();const s=e.children;for(let t=0,e=s.length;t<e;++t)s[t].onAttach()}return t}):Promise.resolve([])}static toPieceData(t,e,i){const s=new Map,n=new Map,o=()=>s;return this.toPieceData_(t,e,s,n,i,0).then(o,o)}static toPieceData_(t,e,i,s,n,o){const r=[];if(e&&0<e.length&&t)for(let a=0,h=e.length;a<h;++a){const h=e[a],l=s.get(h);if(null!=l)r.push(l);else{const e=t.piece.getByName(h).then(e=>this.toPieceData__(t,h,e,n,o+1,i,s),()=>null);s.set(h,e),r.push(e)}}return Promise.all(r)}static toPieceData__(t,e,i,s,n,o,r){const a=this.toSerialized(i),h=a.width,l=a.height,c=new wn(h,l);o.set(e,new Ji(e,h,l,c));const u=a.pieces;return this.toPieceData_(t,u,o,r,s,n).then(()=>this.newLayer(a,c,new ki(a,u,o,s,n)))}}const yn={};class xn{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.background;s&&(this._color=s.color,this._alpha=s.alpha)}getTheme(){return this._theme}setTheme(t){this._theme=t}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBackgroundColor(t)}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onChange())}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBackgroundAlpha(t)}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onChange())}onChange(){const t=this._callback;null!=t&&t()}}const Cn={NONE:0,TOP:1,RIGHT:2,BOTTOM:4,LEFT:8,TOP_RIGHT:3,TOP_BOTTOM:5,TOP_LEFT:9,RIGHT_BOTTOM:6,RIGHT_LEFT:10,BOTTOM_LEFT:12,NOT_TOP:14,NOT_RIGHT:13,NOT_BOTTOM:11,NOT_LEFT:7,ALL:15};class Dn{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.border;s&&(this._color=s.color,this._alpha=s.alpha,this._width=s.width,this._align=s.align,this._mask=Qi(s.mask,Cn))}getTheme(){return this._theme}setTheme(t){this._theme=t}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderColor(t)}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onChange())}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderAlpha(t)}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onChange())}getWidth(t){const e=this._width;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderWidth(t)}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this.onChange())}getAlign(t){const e=this._align;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderAlign(t)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.onChange())}getMask(t){const e=this._mask;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getBorderMask(t)}get mask(){return this._mask}set mask(t){this._mask!==t&&(this._mask=t,this.onChange())}onChange(){const t=this._callback;null!=t&&t()}}const Sn={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_LEFT:4,BOTTOM_RIGHT:8,TOP:3,BOTTOM:12,LEFT:5,RIGHT:10,ALL:15};class bn{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.corner;s&&(wt(s)?(this._radius=s,this._mask=void 0):(this._radius=s.radius,this._mask=Qi(s.mask,Sn)))}getTheme(){return this._theme}setTheme(t){this._theme=t}getRadius(){var t;return null!==(t=this._radius)&&void 0!==t?t:this._theme.getCornerRadius()}get radius(){return this._radius}set radius(t){if(this._radius!==t){this._radius=t;const e=this._callback;null!=e&&e()}}getMask(){var t;return null!==(t=this._mask)&&void 0!==t?t:this._theme.getCornerMask()}get mask(){return this._mask}set mask(t){if(this._mask!==t){this._mask=t;const e=this._callback;null!=e&&e()}}set(t,e){let i=!1;this._radius!==t&&(this._radius=t,i=!0),this._mask!==e&&(this._mask=e,i=!0);const s=this._callback;i&&null!=s&&s()}}const In={NONE:0,SELF:1,CHILDREN:2,BOTH:3};class On{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.outline;s&&(this._color=s.color,this._alpha=s.alpha,this._width=s.width,this._offset=s.offset,this._align=s.align,this._mask=Qi(s.mask,Cn))}getTheme(){return this._theme}setTheme(t){this._theme=t}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineColor(t)}get color(){return this._color}set color(t){if(this._color!==t){this._color=t;const e=this._callback;null!=e&&e()}}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineAlpha(t)}get alpha(){return this._alpha}set alpha(t){if(this._alpha!==t){this._alpha=t;const e=this._callback;null!=e&&e()}}getWidth(t){const e=this._width;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineWidth(t)}get width(){return this._width}set width(t){if(this._width!==t){this._width=t;const e=this._callback;null!=e&&e()}}getOffset(t){const e=this._offset;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineOffset(t)}get offset(){return this._offset}set offset(t){if(this._offset!==t){this._offset=t;const e=this._callback;null!=e&&e()}}getAlign(t){const e=this._align;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineAlign(t)}get align(){return this._align}set align(t){if(this._align!==t){this._align=t;const e=this._callback;null!=e&&e()}}getMask(t){const e=this._mask;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getOutlineMask(t)}get mask(){return this._mask}set mask(t){if(this._mask!==t){this._mask=t;const e=this._callback;null!=e&&e()}}}class An{constructor(t,e,i){this._theme=t,this._callback=i;const s=null==e?void 0:e.padding;null!=s&&(wt(s)?(this._left=s,this._top=s,this._right=s,this._bottom=s):(this._left=s.left,this._top=s.top,this._right=s.right,this._bottom=s.bottom))}getTheme(){return this._theme}setTheme(t){this._theme=t}getCallback(){return this._callback}getLeft(){var t;return null!==(t=this._left)&&void 0!==t?t:this._theme.getPaddingLeft()}get left(){return this._left}set left(t){this._left!==t&&(this._left=t,null!=this._callback&&this._callback())}getTop(){var t;return null!==(t=this._top)&&void 0!==t?t:this._theme.getPaddingTop()}get top(){return this._top}set top(t){this._top!==t&&(this._top=t,null!=this._callback&&this._callback())}getRight(){var t;return null!==(t=this._right)&&void 0!==t?t:this._theme.getPaddingRight()}get right(){return this._right}set right(t){this._right!==t&&(this._right=t,null!=this._callback&&this._callback())}getBottom(){var t;return null!==(t=this._bottom)&&void 0!==t?t:this._theme.getPaddingBottom()}get bottom(){return this._bottom}set bottom(t){this._bottom!==t&&(this._bottom=t,null!=this._callback&&this._callback())}set(t,e,i,s){null==e?(this.top=t,this.right=t,this.bottom=t,this.left=t):null==i?(this.top=t,this.right=e,this.bottom=t,this.left=e):null==s?(this.top=t,this.right=e,this.bottom=i,this.left=e):(this.top=t,this.right=e,this.bottom=i,this.left=s),null!=this._callback&&this._callback()}}class Rn{constructor(t,e){this._point=t,this._onChange=e}get x(){return this._point.x}set x(t){const e=this._point,i=e.x;if(i!==t){e.x=t;const s=e.y;this._onChange(t,s,i,s)}}get y(){return this._point.y}set y(t){const e=this._point,i=e.y;if(i!==t){e.y=t;const s=e.x;this._onChange(s,t,s,i)}}set(t,e){const i=this._point,s=i.x,n=i.y;return s===t&&n===e||(i.set(t,e),this._onChange(t,e,s,n)),this}copyFrom(t){const e=t.x,i=t.y,s=this._point,n=s.x,o=s.y;return n===e&&o===i||(s.copyFrom(t),this._onChange(e,i,n,o)),this}copyTo(t){return t.copyFrom(this._point)}copy(){return this.copyFrom(arguments[0])}clone(t){return new Rn(this._point,t||this._onChange)}equals(t){return this._point.equals(t)}}class Mn extends t.MeshGeometry{constructor(t,e,i){super(t,e,i),this._width=100,this._height=100,this._cornerRadius=0,this._cornerMask=Sn.NONE,this._isDirty=!0,this._resolution=1,this._vertexBuffer=this.getBuffer("aVertexPosition"),this._vertices=this._vertexBuffer.data,this._uvBuffer=this.getBuffer("aTextureCoord"),this._uvs=this._uvBuffer.data,this._indexBuffer=this.getIndex(),this._indices=this._indexBuffer.data}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this._isDirty=!0)}get height(){return this._height}set height(t){this._height!==t&&(this._height=t,this._isDirty=!0)}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){this._cornerRadius!==t&&(this._cornerRadius=t,this._isDirty=!0)}get cornerMask(){return this._cornerMask}set cornerMask(t){this._cornerMask!==t&&(this._cornerMask=t,this._isDirty=!0)}getTables(){let t=Mn.TABLES;return null==t&&(t=this.newTables(Mn.N),Mn.TABLES=t),t}newTables(t){const e=1/(t-1)*.5;return[this.newTable(t,1,e),this.newTable(t,.5,e),this.newTable(t,0,e),this.newTable(t,1.5,e)]}newTable(t,e,i){const s=[],n=[],o=Math.PI;for(let r=0,a=e;r<t;r+=1,a-=i){const t=a*o,e=+Math.cos(t),i=-Math.sin(t);s.push(e),n.push(i)}return{cos:s,sin:n}}}Mn.N=5;class kn extends Mn{constructor(){super(new Float32Array(16*Mn.N),new Float32Array(16*Mn.N),new Uint16Array(3*(12*Mn.N-2)))}fillVertices(t,e,i,s,n,o,r,a,h,l){const c=l.cos,u=l.sin,d=a+h;for(let h=0;h<n;++h){const n=c[h],l=u[h];t[++i]=o+n*a,t[++i]=r+l*a,t[++i]=o+n*d,t[++i]=r+l*d,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+l)}}fillIndices(t,e,i,s){for(let n=0;n<s;++n)t[++i]=e+0,t[++i]=e+1,t[++i]=e+2,t[++i]=e+2,t[++i]=e+1,t[++i]=e+3,e+=2}fillIndicesEnd(t,e,i,s){for(let n=0,o=s-1;n<o;++n)t[++i]=e+0,t[++i]=e+1,t[++i]=e+2,t[++i]=e+2,t[++i]=e+1,t[++i]=e+3,e+=2;t[++i]=e+0,t[++i]=e+1,t[++i]=0,t[++i]=0,t[++i]=e+1,t[++i]=1,e+=2}update(t){const e=t.resolution;if(this._isDirty||this._resolution!==e){this._isDirty=!1,this._resolution=e;const t=this._vertices,i=this._uvs,s=this._indices,n=this._width,o=this._height,r=Math.min(.5*n,.5*o,this._cornerRadius),a=.5/e,h=0,l=r,c=n-r,u=n,d=0,p=r,_=o-r,g=o,f=this._cornerMask,m=!(f&Sn.TOP_LEFT),v=!(f&Sn.TOP_RIGHT),T=!(f&Sn.BOTTOM_LEFT),w=!(f&Sn.BOTTOM_RIGHT);let E=-1,y=-1,x=0,C=-1;const D=Mn.N,S=D<<2,b=D<<1,I=6*D,O=this.getTables(),A=O[0],R=O[1],M=O[2],k=O[3];m?this.fillVertices(t,i,E,y,D,l,p,r,a,A):this.fillVertices(t,i,E,y,D,h,d,0,a,A),this.fillIndices(s,x,C,D),E+=S,y+=S,x+=b,C+=I,v?this.fillVertices(t,i,E,y,D,c,p,r,a,R):this.fillVertices(t,i,E,y,D,u,d,0,a,R),this.fillIndices(s,x,C,D),E+=S,y+=S,x+=b,C+=I,w?this.fillVertices(t,i,E,y,D,c,_,r,a,M):this.fillVertices(t,i,E,y,D,u,g,0,a,M),this.fillIndices(s,x,C,D),E+=S,y+=S,x+=b,C+=I,T?this.fillVertices(t,i,E,y,D,l,_,r,a,k):this.fillVertices(t,i,E,y,D,h,g,0,a,k),this.fillIndicesEnd(s,x,C,D),E+=S,y+=S,x+=b,C+=I,x=2;for(let t=1,e=4*D-1;t<e;t+=1,x+=2)s[++C]=0,s[++C]=x,s[++C]=x+2;this._vertexBuffer.update(),this._uvBuffer.update(),this._indexBuffer.update()}}}class Ln extends t.Mesh{constructor(e){super(new kn,new t.MeshMaterial(e)),e.on("update",()=>{ot.update(this)})}get width(){return this.geometry.width}set width(t){this.geometry.width=t}get height(){return this.geometry.height}set height(t){this.geometry.height=t}get cornerRadius(){return this.geometry.cornerRadius}set cornerRadius(t){this.geometry.cornerRadius=t}get cornerMask(){return this.geometry.cornerMask}set cornerMask(t){this.geometry.cornerMask=t}_render(t){this.geometry.update(t),super._render(t)}}class Nn{get(t,e){let i=this._mesh;return null==i&&(i=new Ln(e.getBackgroundTexture()),i.parent=t,this._mesh=i),i}hide(){const t=this._mesh;null!=t&&(t.visible=!1)}onReflow(t,e,i,s,n,o,r){const a=t.background,h=a.getColor(n);if(null!=h){const l=a.getAlpha(n);if(0<l){const n=this.get(t,s);n.tint=h,n.alpha=l,n.width=e,n.height=i,n.cornerRadius=o,n.cornerMask=r,n.visible=!0}else this.hide()}else this.hide()}render(t){var e;null===(e=this._mesh)||void 0===e||e.render(t)}updateTransform(){var t;null===(t=this._mesh)||void 0===t||t.updateTransform()}}class Pn extends Mn{constructor(){super(new Float32Array(32*Mn.N),new Float32Array(32*Mn.N),new Uint16Array(72*Mn.N)),this._borderWidth=0,this._borderMask=Cn.NONE}get borderWidth(){return this._borderWidth}set borderWidth(t){this._borderWidth!==t&&(this._borderWidth=t,this._isDirty=!0)}get borderMask(){return this._borderMask}set borderMask(t){this._borderMask!==t&&(this._borderMask=t,this._isDirty=!0)}fillVertices(t,e,i,s,n,o,r,a,h,l,c){const u=.5*l,d=a-u,p=a+u,_=d-h,g=p+h,f=c.cos,m=c.sin;if(_<=0){const h=f[0]+f[n-1],l=m[0]+m[n-1];if(d<=0)if(a<=0)for(let a=0;a<n;++a){const n=f[a],c=m[a];t[++i]=o+h*_,t[++i]=r+l*_,t[++i]=o+h*d,t[++i]=r+l*d,t[++i]=o+h*p,t[++i]=r+l*p,t[++i]=o+h*g,t[++i]=r+l*g,e[++s]=.5*(1+n),e[++s]=.5*(1+c),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+c)}else for(let a=0;a<n;++a){const n=f[a],c=m[a];t[++i]=o+h*_,t[++i]=r+l*_,t[++i]=o+h*d,t[++i]=r+l*d,t[++i]=o+n*p,t[++i]=r+c*p,t[++i]=o+n*g,t[++i]=r+c*g,e[++s]=.5*(1+n),e[++s]=.5*(1+c),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+c)}else for(let a=0;a<n;++a){const n=f[a],c=m[a];t[++i]=o+h*_,t[++i]=r+l*_,t[++i]=o+n*d,t[++i]=r+c*d,t[++i]=o+n*p,t[++i]=r+c*p,t[++i]=o+n*g,t[++i]=r+c*g,e[++s]=.5*(1+n),e[++s]=.5*(1+c),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+c)}}else for(let a=0;a<n;++a){const n=f[a],h=m[a];t[++i]=o+n*_,t[++i]=r+h*_,t[++i]=o+n*d,t[++i]=r+h*d,t[++i]=o+n*p,t[++i]=r+h*p,t[++i]=o+n*g,t[++i]=r+h*g,e[++s]=.5*(1+n),e[++s]=.5*(1+h),e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5,e[++s]=.5*(1+n),e[++s]=.5*(1+h)}}fillIndices(t,e,i,s,n,o){for(let n=0,o=s-1;n<o;++n)t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=2;n?o?(t[++i]=e+0,t[++i]=e+1,t[++i]=0,t[++i]=0,t[++i]=e+1,t[++i]=1,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=1,t[++i]=1,t[++i]=e+1,t[++i]=2,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=2,t[++i]=2,t[++i]=e+1,t[++i]=3,e+=2):(t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=1,t[++i]=e+0,t[++i]=e+1,t[++i]=e+4,t[++i]=e+4,t[++i]=e+1,t[++i]=e+5,e+=2):(t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,e+=1,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,e+=1,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,t[++i]=e,e+=2)}update(t){const e=t.resolution;if(this._isDirty||this._resolution!==e){this._isDirty=!1,this._resolution=e;const t=this._vertices,i=this._uvs,s=this._indices,n=this._width,o=this._height,r=this._borderWidth,a=Math.min(.5*n,.5*o,this._cornerRadius),h=.5/e,l=0,c=a,u=n-a,d=n,p=0,_=a,g=o-a,f=o,m=this._borderMask,v=!(m&Cn.TOP),T=!(m&Cn.BOTTOM),w=!(m&Cn.LEFT),E=!(m&Cn.RIGHT),y=this._cornerMask,x=!(y&Sn.TOP_LEFT),C=!(y&Sn.TOP_RIGHT),D=!(y&Sn.BOTTOM_LEFT),S=!(y&Sn.BOTTOM_RIGHT);let b=-1,I=-1,O=0,A=-1;const R=Mn.N,M=R<<2,k=R<<3,L=18*R,N=this.getTables(),P=N[0],B=N[1],z=N[2],U=N[3];x?w||v?this.fillVertices(t,i,b,I,R,c,_,a,h,r,P):this.fillVertices(t,i,b,I,R,c,_,a,h,0,P):w||v?this.fillVertices(t,i,b,I,R,l,p,0,h,r,P):this.fillVertices(t,i,b,I,R,l,p,0,h,0,P),this.fillIndices(s,O,A,R,v,!1),b+=k,I+=k,O+=M,A+=L,C?v||E?this.fillVertices(t,i,b,I,R,u,_,a,h,r,B):this.fillVertices(t,i,b,I,R,u,_,a,h,0,B):v||E?this.fillVertices(t,i,b,I,R,d,p,0,h,r,B):this.fillVertices(t,i,b,I,R,d,p,0,h,0,B),this.fillIndices(s,O,A,R,E,!1),b+=k,I+=k,O+=M,A+=L,S?E||T?this.fillVertices(t,i,b,I,R,u,g,a,h,r,z):this.fillVertices(t,i,b,I,R,u,g,a,h,0,z):E||T?this.fillVertices(t,i,b,I,R,d,f,0,h,r,z):this.fillVertices(t,i,b,I,R,d,f,0,h,0,z),this.fillIndices(s,O,A,R,T,!1),b+=k,I+=k,O+=M,A+=L,D?T||w?this.fillVertices(t,i,b,I,R,c,g,a,h,r,U):this.fillVertices(t,i,b,I,R,c,g,a,h,0,U):T||w?this.fillVertices(t,i,b,I,R,l,f,0,h,r,U):this.fillVertices(t,i,b,I,R,l,f,0,h,0,U),this.fillIndices(s,O,A,R,w,!0),b+=k,I+=k,O+=M,A+=L,this._vertexBuffer.update(),this._uvBuffer.update(),this._indexBuffer.update()}}}class Bn extends t.Mesh{constructor(e){super(new Pn,new t.MeshMaterial(e)),e.on("update",()=>{ot.update(this)})}get width(){return this.geometry.width}set width(t){this.geometry.width=t}get height(){return this.geometry.height}set height(t){this.geometry.height=t}get cornerRadius(){return this.geometry.cornerRadius}set cornerRadius(t){this.geometry.cornerRadius=t}get cornerMask(){return this.geometry.cornerMask}set cornerMask(t){this.geometry.cornerMask=t}get borderWidth(){return this.geometry.borderWidth}set borderWidth(t){this.geometry.borderWidth=t}get borderMask(){return this.geometry.borderMask}set borderMask(t){this.geometry.borderMask=t}_render(t){this.geometry.update(t),super._render(t)}}class zn{get(t,e){let i=this._mesh;return null==i&&(i=new Bn(e.getBorderTexture()),i.parent=t,this._mesh=i),i}hide(){const t=this._mesh;null!=t&&(t.visible=!1)}onReflow(t,e,i,s,n,o,r){const a=t.border,h=a.getColor(n);if(null!=h){const l=a.getAlpha(n);if(0<l){const c=a.getWidth(n),u=a.getMask(n),d=this.get(t,s),p=(a.getAlign(n)-.5)*c;d.tint=h,d.alpha=l,d.x=-p,d.y=-p,d.width=e+2*p,d.height=i+2*p,d.cornerRadius=Math.max(0,o+p),d.cornerMask=r,d.borderWidth=c,d.borderMask=u,d.visible=!0}else this.hide()}else this.hide()}render(t){var e;null===(e=this._mesh)||void 0===e||e.render(t)}updateTransform(){var t;null===(t=this._mesh)||void 0===t||t.updateTransform()}}class Un{get(t,e){let i=this._mesh;return null==i&&(i=new Bn(e.getBorderTexture()),i.parent=t,this._mesh=i),i}hide(){const t=this._mesh;null!=t&&(t.visible=!1)}onReflow(t,e,i,s,n,o,r){const a=t.outline,h=a.getColor(n);if(null!=h){const l=a.getAlpha(n);if(0<l){const c=a.getWidth(n),u=a.getMask(n),d=this.get(t,s),p=a.getOffset(n)+(a.getAlign(n)-.5)*c;d.tint=h,d.alpha=l,d.x=-p,d.y=-p,d.width=e+2*p,d.height=i+2*p,d.cornerRadius=Math.max(0,o+p),d.cornerMask=r,d.borderWidth=c,d.borderMask=u,d.visible=!0}else this.hide()}else this.hide()}render(t){var e;null===(e=this._mesh)||void 0===e||e.render(t)}updateTransform(){var t;null===(t=this._mesh)||void 0===t||t.updateTransform()}}class Fn{constructor(t){const e=new Nn;this._background=e,t.snippet.add(e,!0);const i=new zn;this._border=i,t.snippet.add(i,!0);const s=new Un;this._outline=s,t.snippet.add(s,!1),t.reflowable.add(this)}onReflow(t,e,i){const s=t.theme,n=t.state,o=t.corner,r=o.getRadius(),a=o.getMask();this._background.onReflow(t,e,i,s,n,r,a),this._border.onReflow(t,e,i,s,n,r,a),this._outline.onReflow(t,e,i,s,n,r,a)}}const Hn={NONE:0,BEFORE:1,AFTER:2,BOTH:3},Gn={OPEN:0,CLOSE:1,PARENSESIS:2,ADD_OR_PLUS:3,SUB_OR_MINUS:4,PLUS:5,MINUS:6,ADD:7,SUB:8,MUL:9,DIV:10,MIN:11,MAX:12,COMMA:13,PARENT:14,SELF:15,PADDING:16,CURRENT:17,NUMBER:18};class Vn{constructor(t){const e=this.toToken(t);let i=0;do{i=this.toParensesis(e,i)}while(i<e.length);if(this.toUnary(e),this.toArithmetic(e,Gn.MUL,Gn.DIV),this.toArithmetic(e,Gn.ADD,Gn.SUB),1===e.length){const t=e[0];if(!wt(t))return void(this._node=t)}throw new Error(`Failed to parse '${t}'`)}toParensesis(t,e){let i=t.length;for(let s=e;s<i;++s)if(t[s]===Gn.OPEN){let e=s,n=Gn.PARENSESIS;if(0<s){const i=t[s-1];i!==Gn.MIN&&i!==Gn.MAX||(e-=1,n=i)}for(let o=s+1;o<i;++o){const r=t[o];if(r===Gn.CLOSE)return t[e]=[n,this.toComma(t,s+1,o)],t.splice(e+1,o-e),e+1;r===Gn.OPEN&&(o=this.toParensesis(t,o)-1,i=t.length)}throw new Error("Malformed parensesis")}return i}toCommaOf(t,e,i){const s=i-e;if(s<=0)return[Gn.NUMBER,0];if(s<=1)return t[e];{const s=[];for(let n=e;n<i;++n)s.push(t[n]);return[Gn.PARENSESIS,s]}}toComma(t,e,i){let s=null,n=e;for(let o=e;o<i;++o)t[o]===Gn.COMMA&&(s=s||[],s.push(this.toCommaOf(t,n,o)),n=o+1);if(n<i){if(null==s){const e=[];for(let s=n;s<i;++s)e.push(t[s]);return e}s.push(this.toCommaOf(t,n,i))}return s||[]}toUnaryNode(t){wt(t)||t[0]!==Gn.PARENSESIS&&t[0]!==Gn.MIN&&t[0]!==Gn.MAX||this.toUnary(t[1])}toUnary(t){for(let e=0,i=t.length;e<i;++e){const s=t[e];if(s===Gn.ADD_OR_PLUS||s===Gn.SUB_OR_MINUS)if(e<=0||wt(t[e-1])){if(!(e+1<i)||wt(t[e+1]))throw new Error("Malformed unary operator");{const n=t.splice(e+1,1)[0],o=s===Gn.ADD_OR_PLUS?Gn.PLUS:Gn.MINUS;t[e]=[o,n],i=t.length,this.toUnaryNode(n)}}else{const i=s===Gn.ADD_OR_PLUS?Gn.ADD:Gn.SUB;t[e]=i}else this.toUnaryNode(s),i=t.length}}toArithmeticNode(t,e,i){wt(t)||(t[0]===Gn.PARENSESIS||t[0]===Gn.MIN||t[0]===Gn.MAX?this.toArithmetic(t[1],e,i):t[0]===Gn.PLUS||t[0]===Gn.MINUS?this.toArithmeticNode(t[1],e,i):t[0]!==Gn.ADD&&t[0]!==Gn.SUB&&t[0]!==Gn.MUL&&t[0]!==Gn.DIV||(this.toArithmeticNode(t[1],e,i),this.toArithmeticNode(t[2],e,i)))}toArithmetic(t,e,i){for(let s=0,n=t.length;s<n;++s){const o=t[s];if(o===e||o===i){if(0<s&&s+1<n){const r=t[s-1],a=t[s+1];if(!wt(r)&&!wt(a)){t.splice(s,2),t[s-1]=[o,r,a],s-=1,n=t.length,this.toArithmeticNode(r,e,i),this.toArithmeticNode(a,e,i);continue}}throw new Error("Malformed operands for the operator "+o)}this.toArithmeticNode(o,e,i),n=t.length}}toToken(t){const e=[];for(;;){const i=Vn.TOKEN_REGEX.exec(t);if(null==i)break;{const s=i[0],n=this.toTokenOperator(s);if(null!=n)e.push(n);else{const n=parseFloat(s);if(n!=n)throw new Error(`Unexpected token '${s}' at ${i.index} in '${t}'`);const o=this.toTokenLiteral(s);null!=o?e.push([o,.01*n]):e.push([Gn.NUMBER,n])}}}return e}toTokenOperator(t){switch(t){case"+":return Gn.ADD_OR_PLUS;case"-":return Gn.SUB_OR_MINUS;case"*":return Gn.MUL;case"/":return Gn.DIV;case"(":return Gn.OPEN;case")":return Gn.CLOSE;case",":return Gn.COMMA;case"min":return Gn.MIN;case"max":return Gn.MAX}return null}toTokenLiteral(t){const e=t.length;if(0<e)switch(t[e-1]){case"%":return Gn.PARENT;case"s":return Gn.SELF;case"p":return Gn.PADDING;case"c":return Gn.CURRENT}return null}evaluate(t,e,i,s,n){switch(t[0]){case Gn.PARENSESIS:const o=t[1];return this.evaluate(o[o.length-1],e,i,s,n);case Gn.PLUS:return+this.evaluate(t[1],e,i,s,n);case Gn.MINUS:return-this.evaluate(t[1],e,i,s,n);case Gn.ADD:return this.evaluate(t[1],e,i,s,n)+this.evaluate(t[2],e,i,s,n);case Gn.SUB:return this.evaluate(t[1],e,i,s,n)-this.evaluate(t[2],e,i,s,n);case Gn.MUL:return this.evaluate(t[1],e,i,s,n)*this.evaluate(t[2],e,i,s,n);case Gn.DIV:return this.evaluate(t[1],e,i,s,n)/this.evaluate(t[2],e,i,s,n);case Gn.MIN:if(0<t[1].length){const o=t[1];let r=this.evaluate(o[0],e,i,s,n);for(let t=1,a=o.length;t<a;++t)r=Math.min(r,this.evaluate(o[t],e,i,s,n));return r}return 0;case Gn.MAX:if(0<t[1].length){const o=t[1];let r=this.evaluate(o[0],e,i,s,n);for(let t=1,a=o.length;t<a;++t)r=Math.max(r,this.evaluate(o[t],e,i,s,n));return r}return 0;case Gn.PARENT:return t[1]*e;case Gn.SELF:return t[1]*i;case Gn.PADDING:return t[1]*s;case Gn.CURRENT:return t[1]*n;case Gn.NUMBER:return t[1]}return 0}calculate(t,e,i,s){return this.evaluate(this._node,t,e,i,s)}}Vn.TOKEN_REGEX=/(?:\+|-|\*|\/|\(|\)|min|max|,|(?:\d+(?:\.\d*)?[%psc]?))/g;const Wn=(t,e)=>.5*(t-e),Kn=(t,e,i)=>i,Xn=t=>t,Yn=(t,e,i)=>t-i;class jn{static position(t){if(null==t||wt(t))return null;if(Et(t)){switch(t){case"center":case"CENTER":return Wn;case"padding":case"PADDING":return Kn}const e=new Vn(t);return(t,i,s,n)=>e.calculate(t,i,s,n)}if(Tt(t))return t;{const e=t;return(t,i,s,n)=>e.calculate(t,i,s,n)}}static size(t){if(null==t||wt(t))return null;if(Et(t)){switch(t){case"100%":case"maximized":case"MAXIMIZED":return Xn;case"padding":case"PADDING":return Yn}const e=new Vn(t);return(t,i,s,n)=>e.calculate(t,i,s,n)}if(Tt(t))return t;{const e=t;return(t,i,s,n)=>e.calculate(t,i,s,n)}}}class $n{static isActivateKey(t){return"Space"===t.key||"Enter"===t.key||32===t.which||13===t.which}static isArrowUpKey(t){return"ArrowUp"===t.key||38===t.which}static isArrowDownKey(t){return"ArrowDown"===t.key||40===t.which}static isArrowLeftKey(t){return"ArrowLeft"===t.key||37===t.which}static isArrowRightKey(t){return"ArrowRight"===t.key||39===t.which}static isCancelKey(t){return"Esc"===t.key||27===t.which}static isFocusKey(t){return"Tab"===t.key||9===t.which}static isUndoKey(t){return t.ctrlKey&&("z"===t.key||90===t.which)}static isRedoKey(t){return t.ctrlKey&&("y"===t.key||89===t.which)}static isSaveKey(t){return t.ctrlKey&&!t.shiftKey&&("s"===t.key||83===t.which)}static isSaveAsKey(t){return t.ctrlKey&&t.shiftKey&&("S"===t.key||83===t.which)}static isDeleteKey(t){return"Delete"===t.key||46===t.which}static isSelectAllKey(t){return t.ctrlKey&&!t.shiftKey&&("a"===t.key||65===t.which)}static isOkKey(t){return"Enter"===t.key||13===t.which}static getFocusDirection(t){return!0!==t.shiftKey}static toShortcut(t){if(Et(t)){const e=t,i=e.indexOf("->");let s,n;0<=i?(s=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+2).trim()):s=e.trim().toLowerCase();let o=!1,r=!1,a=!1,h="a";const l=s.length;let c=0,u=1;for(;u<l;++u)if("+"===s.charAt(u)){const t=s.substring(c,u);switch(t){case"alt":o=!0;break;case"ctrl":r=!0;break;case"shift":a=!0;break;default:h=t}u+=1,c=u}return c!==u&&(h=s.substring(c,u)),(t=>{const e=t.key;if(e.length<=1){t.shift&&(t.key=e.toUpperCase());const i=e.charCodeAt(0);t.which=97<=i&&i<=122?i-32:i}else switch(e){case"enter":t.key="Enter",t.which=13;break;case"space":t.key=" ",t.which=32;break;case"escape":t.key="Escape",t.which=27;break;case"f1":t.key="F1",t.which=112;break;case"f2":t.key="F2",t.which=113;break;case"f3":t.key="F3",t.which=114;break;case"f4":t.key="F4",t.which=115;break;case"f5":t.key="F5",t.which=116;break;case"f6":t.key="F6",t.which=117;break;case"f7":t.key="F7",t.which=118;break;case"f8":t.key="F8",t.which=119;break;case"f9":t.key="F9",t.which=120;break;case"f10":t.key="F10",t.which=121;break;case"f11":t.key="F11",t.which=122;break;case"f12":t.key="F12",t.which=123;break;case"capslock":t.key="CapsLock",t.shift?t.which=20:t.which=240;break;case"arrowup":t.key="ArrowUp",t.which=38;break;case"arrowdown":t.key="ArrowDown",t.which=40;break;case"arrowleft":t.key="ArrowLeft",t.which=37;break;case"arrowright":t.key="ArrowRight",t.which=39;break;case"insert":t.key="Insert",t.which=45;break;case"delete":t.key="Delete",t.which=46;break;case"pageup":t.key="PageUp",t.which=33;break;case"pagedown":t.key="PageDown",t.which=34;break;case"backspace":t.key="Backspace",t.which=8;break;case"colon":t.key=":",t.which=186;break;case"semicolon":t.key=";",t.which=187;break;case"pause":t.key="Pause",t.which=19;break;case"scrolllock":t.key="ScrollLock",t.which=145;break;case"tab":t.key="Tab",t.which=9;break;case"plus":t.key="+",t.which=187;break;case"minus":t.key="-",t.which=189}return t})({alt:o,ctrl:r,shift:a,key:h,which:0,event:n})}return t}static toString(t){const e=[];return t.ctrl&&e.push("Ctrl"),t.shift&&e.push("Shift"),t.alt&&e.push("Alt"),e.push(t.key.toUpperCase()),e.join("+")}static on(t,e,i){const s=this.toShortcut(e);document.body.addEventListener("keydown",e=>{e.altKey!==s.alt||e.ctrlKey!==s.ctrl||e.shiftKey!==s.shift||e.key!==s.key&&e.which!==s.which||(t.state.isActionable&&(null!=s.event?t.emit(s.event):null!=i&&i(e)),e.preventDefault())})}static moveFocusVertically(t,e,i){if(e.state.isActionable){const s=$n.isArrowUpKey(t),n=$n.isArrowDownKey(t);if(s||n)return this.moveFocus(n,e,i)}return!1}static moveFocusHorizontally(t,e,i){if(e.state.isActionable){const s=$n.isArrowLeftKey(t),n=$n.isArrowRightKey(t);if(s||n)return this.moveFocus(n,e,i)}return!1}static moveFocus(t,e,i){var s;const n=null!==(s=null==i?void 0:i.picked)&&void 0!==s?s:ot.getLayer(e);if(n){const i=n.getFocusController(),s=i.get();if(null!=s){const n=i.find(s,!1,s.state.isFocusRoot||t,t,e);if(null!=n)return i.focus(n),!0}}return!1}}class qn{constructor(){this._isOn=!1}get isOff(){return!this._isOn}get isOn(){return this._isOn}toCoordinate(t){return this._isOn?"auto":t}from(t){return"auto"===t||"AUTO"===t?(this._isOn=!0,!0):(this._isOn=!1,!1)}}class Zn{constructor(){this.width=new qn,this.height=new qn}}class Jn{constructor(t){this._parent=t,this._befores=[],this._afters=[],this._renderable=!0}get renderable(){return this._renderable}set renderable(t){this._renderable=t}add(t,e){(e?this._befores:this._afters).push(t),"parent"in t&&(t.parent=this._parent)}addAt(t,e,i){const s=e?this._befores:this._afters;0===i?s.unshift(t):0<i&&i<s.length?s.splice(i,0,t):s.push(t),"parent"in t&&(t.parent=this._parent)}remove(t,e){const i=e?this._befores:this._afters,s=i.indexOf(t);0<=s&&(i.splice(s,1),"parent"in t&&(t.parent=null))}render(t,e){if(this._renderable){const i=e?this._befores:this._afters;for(let e=0,s=i.length;e<s;++e)i[e].render(t)}}updateTransform(){const t=this._befores;for(let e=0,i=t.length;e<i;++e)t[e].updateTransform();const e=this._afters;for(let t=0,i=e.length;t<i;++t)e[t].updateTransform()}}class Qn{constructor(){this._list=[]}add(t){this._list.push(t)}remove(t){const e=this._list,i=e.indexOf(t);0<=i&&e.splice(i,1)}onReflow(t,e,i){const s=this._list;for(let n=0,o=s.length;n<o;++n)s[n].onReflow(t,e,i)}}class to extends t.Container{constructor(t){var e,i,s,n,o,r,a,h,l;super();const c=this.transform;this._position=new Rn(c.position,(t,e,i,s)=>{this.onMove(t,e,i,s)}),this._scale=new Rn(c.scale,(t,e,i,s)=>{this.onScale(t,e,i,s)}),this._skew=new Rn(c.skew,(t,e,i,s)=>{this.onSkew(t,e,i,s)}),this._options=t;const u=this._scalarSet={};this._auto=new Zn,this._isDirty=!0,this._hasDirty=!1,this._isHierarchyDirty=!1,this._shadow=null,this.name=null!==(e=null==t?void 0:t.name)&&void 0!==e?e:"";const d=(t=>{const e=null==t?void 0:t.theme;if(e)return Et(e)?$.getInstance().get(e):e})(t)||this.getThemeDefault();this._theme=d,this._snippet=new Jn(this),this._reflowable=new Qn,this._clearType=Qi(null!==(i=null==t?void 0:t.clear)&&void 0!==i?i:d.getClearType(),Hn),this._padding=this.newPadding(d,t,()=>{this.toDirty(),this.toParentResized(),this.toHierarchyDirty(),ot.update(this)});const p=()=>{this.toDirty(),ot.update(this)};this._background=new xn(d,t,p),this._border=new Dn(d,t,p),this._outline=new On(d,t,p),this._corner=new bn(d,t,p);const _=c.position,g=null!==(s=null==t?void 0:t.x)&&void 0!==s?s:d.getX();wt(g)?_.x=g:(_.x=0,u.x=jn.position(g));const f=null!==(n=null==t?void 0:t.y)&&void 0!==n?n:d.getY();wt(f)?_.y=f:(_.y=0,u.y=jn.position(f));const m=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:d.getWidth();this._auto.width.from(m)?this._width=100:wt(m)?this._width=m:(this._width=100,u.width=jn.size(m));const v=null!==(r=null==t?void 0:t.height)&&void 0!==r?r:d.getHeight();if(this._auto.height.from(v)?this._height=100:wt(v)?this._height=v:(this._height=100,u.height=jn.size(v)),null!=t){const e=t.visible;null!=e&&(this.visible=e)}if(null!=t){const e=t.renderable;null!=e&&(this.renderable=e)}this._state=new xt((t,e)=>{this.onStateChange(t,e)});const T=Qi(null!==(a=null==t?void 0:t.interactive)&&void 0!==a?a:d.getInteractive(),In);if(this.interactive=!!(T&In.SELF),this.interactiveChildren=!!(T&In.CHILDREN),null!=t){const e=t.on;if(null!=e)for(const t in e){const i=e[t];i&&this.on(t,i)}}let w;if(this._title=null!==(h=null==t?void 0:t.title)&&void 0!==h?h:d.getTitle(),this._weight=null!==(l=null==t?void 0:t.weight)&&void 0!==l?l:d.getWeight(),this.initReflowable(),this._onShadowUpdateBound=()=>{ot.update(this)},null!=t&&(w=t.shadow),void 0===w&&(w=d.getShadow()),w)if(Et(w))switch(w){case"WEAK":this.shadow=d.newShadowWeak();break;case"DEFAULT":this.shadow=d.newShadow()}else this.shadow=w;this.on(nn.over,t=>{this.onOver(t)}),this.on(nn.out,t=>{this.onOut(t)}),this.on(nn.down,t=>{this.onDown(t)}),this.on(nn.up,t=>{this.onUp(t)}),this.on("added",()=>{this.toParentResized(),(this.isDirty()||this.hasDirty())&&this.toParentHasDirty(),this._isHierarchyDirty&&this.toParentHierarchyDirty();const t=this.parent;t instanceof to&&(this.state.parent=t.state),ot.update(this)}),this.on("removed",()=>{this.blur(!0),this.state.parent=null,ot.update(this)});const E=(t=>{if(t){const e=t.shortcut,i=t.shortcuts;if(null!=i||null!=e){const t=[];if(null!=e&&t.push($n.toShortcut(e)),null!=i)for(let e=0,s=i.length;e<s;++e)t.push($n.toShortcut(i[e]));return t}}})(t);if(this._shortcuts=E,null!=E){const t=t=>{this.onShortcut(t)};for(let e=0,i=E.length;e<i;++e)$n.on(this,E[e],t)}if(this.init(t),d.newState(this._state),null!=t){const e=t.state;if(null!=e){const t=this._state;if(Et(e))t.add(e);else if(vt(e))t.addAll(e);else{const i=e.values;null!=i&&(Et(i)?t.add(i):t.addAll(i));const s=e.blinkers;if(null!=s){const e=t.blinker;for(let t=0,i=s.length;t<i;++t){const i=s[t];e.add(i.state,i.interval)}}const n=e.tickers;if(null!=n){const e=t.ticker;for(let t=0,i=n.length;t<i;++t){const i=n[t];e.add(i.state,i.interval)}}}}}if(null!=t){const e=t.parent;null!=e&&e.addChild(this)}if(null!=t){const e=t.children;if(null!=e)for(let t=0,i=e.length;t<i;++t){const i=e[t];null!=i&&this.addChild(i)}}let y;null!=t&&(y=t.cursor,this._cursor=y),this.cursor=this.toCursor(y,this._state),this.emit("init",this)}newPadding(t,e,i){return new An(t,e,i)}toCursor(t,e){if(t)if(Tt(t)){const i=t(e);if(void 0!==i)return i}else if(void 0!==t)return t;return this.theme.getCursor(e)}get snippet(){return this._snippet}get reflowable(){return this._reflowable}initReflowable(){new Fn(this)}onChildrenChange(){this.toHierarchyDirty(),super.onChildrenChange()}onShortcut(t){this.emit("shortcut",t,this)}init(t){}get weight(){return this._weight}set weight(t){this._weight!==t&&(this._weight=t,this.toHierarchyDirty(),ot.update(this))}onMove(t,e,i,s){const n=this.children;for(let o=0,r=n.length;o<r;++o){const r=n[o];r instanceof to&&r.onParentMove(t,e,i,s)}ot.update(this),this.emit("move",t,e,i,s,this)}resize(t,e){const i=this._width,s=this._height,n=null!=t?t:i,o=null!=e?e:s,r=i!==n,a=s!==o;r&&(this._width=n),a&&(this._height=o);const h=r||a;if(h&&this.onResize(n,o,i,s),r){const t=this._scalarSet;if(null!=t.x){const e=this._position,i=this.getParentOfSize();i&&(this._position.x=t.x(i.width,n,i.padding.getLeft(),e.x))}}if(a){const t=this._scalarSet;if(null!=t.y){const e=this._position,i=this.getParentOfSize();i&&(this._position.y=t.y(i.height,o,i.padding.getTop(),e.y))}}return h}getClearType(){return this._clearType}onResize(t,e,i,s){this.toDirty(),this.toHierarchyDirty();const n=this._padding,o=this.children;for(let i=0,s=o.length;i<s;++i){const s=o[i];s instanceof to&&s.onParentResize(t,e,n)}ot.update(this),this.emit("resize",t,e,i,s,this)}onScale(t,e,i,s){ot.update(this),this.emit("scale",t,e,i,s,this)}onSkew(t,e,i,s){ot.update(this),this.emit("skew",t,e,i,s,this)}get type(){return this.getType()}get x(){return this._position.x}set x(t){this.setX(t)}getX(){const t=this._scalarSet;return null!=t.x?t.x:this._position.x}setX(t){const e=this._scalarSet;if(wt(t)){const i=this._position;i.x!==t?(e.x=void 0,i.x=t):void 0!==e.x&&(e.x=void 0,this.toParentResized())}else{const i=jn.position(t);e.x!==i&&(e.x=i,this.toParentResized())}}get y(){return this._position.y}set y(t){this.setY(t)}getY(){const t=this._scalarSet;return null!=t.y?t.y:this._position.y}setY(t){const e=this._scalarSet;if(wt(t)){const i=this._position;i.y!==t?(e.y=void 0,i.y=t):void 0!==e.y&&(e.y=void 0,this.toParentResized())}else{const i=jn.position(t);e.y!==i&&(e.y=i,this.toParentResized())}}get width(){return this._width}set width(t){this.setWidth(t)}getWidth(){return this._auto.width.toCoordinate(this._scalarSet.width||this._width)}setWidth(t){const e=this._auto.width,i=e.isOn,s=e.from(t);if(e.isOn!==i&&(this.toHierarchyDirty(),ot.update(this)),!s){const e=this._scalarSet;if(wt(t)){const i=this._width;if(i!==t){e.width=void 0,this._width=t;const s=this._height;if(this.onResize(t,s,i,s),null!=e.x){const i=this._position,s=this.getParentOfSize();s&&(i.x=e.x(s.width,t,s.padding.getLeft(),i.x))}}else void 0!==e.width&&(e.width=void 0,this.toParentResized())}else{const i=jn.size(t);e.width!==i&&(e.width=i,this.toParentResized())}}}get height(){return this._height}set height(t){this.setHeight(t)}getHeight(){return this._auto.height.toCoordinate(this._scalarSet.height||this._height)}setHeight(t){const e=this._auto.height,i=e.isOn,s=e.from(t);if(e.isOn!==i&&(this.toHierarchyDirty(),ot.update(this)),!s){const e=this._scalarSet;if(wt(t)){const i=this._height;if(i!==t){e.height=void 0,this._height=t;const s=this._width;if(this.onResize(s,t,s,i),null!=e.y){const i=this._position,s=this.getParentOfSize();s&&(i.y=e.y(s.height,t,s.padding.getTop(),i.y))}}else void 0!==e.height&&(e.height=void 0,this.toParentResized())}else{const i=jn.size(t);e.height!==i&&(e.height=i,this.toParentResized())}}}get position(){return this._position}get scale(){return this._scale}get skew(){return this._skew}get padding(){return this._padding}get corner(){return this._corner}get background(){return this._background}get border(){return this._border}get outline(){return this._outline}get unsafe(){return this.transform}get title(){return this._title}set title(t){this._title!==t&&(this._title=t,this.state.isHovered&&this.applyTitle())}applyTitle(){const t=ot.getLayer(this);t&&(t.view.title=this._title)}show(){return this.visible||(this.visible=!0,this.toParentHierarchyDirty(),ot.update(this)),this}isShown(){return this.visible}hide(){return this.visible&&(this.visible=!1,this.toParentHierarchyDirty(),this.blur(!0),ot.update(this)),this}isHidden(){return!this.visible}toDirty(){return!this._isDirty&&(this._isDirty=!0,this.toParentHasDirty(),!0)}toHasDirty(){return!this._hasDirty&&(this._hasDirty=!0,this.toParentHasDirty(),!0)}toParentHasDirty(){const t=this.parent;t instanceof to&&t.toHasDirty()}toHierarchyDirty(){return!this._isHierarchyDirty&&(this._isHierarchyDirty=!0,this.onHierarchyDirty(),this.toParentHierarchyDirty(),!0)}toParentHierarchyDirty(){const t=this.parent;t instanceof to&&t.toHierarchyDirty()}isHierarchyDirty(){return this._isHierarchyDirty}onHierarchyDirty(){}isDirty(){return this._isDirty}hasDirty(){return this._hasDirty}setFocused(t){if(this.state.isFocused!==t){const e=ot.getLayer(this);e&&e.getFocusController().set(this,t)}return this}focus(){return this.setFocused(!0)}blur(t){if(t){const t=ot.getLayer(this);if(t){const e=t.getFocusController().get();if(e instanceof to){let t=e;for(;t;){if(t===this){e.setFocused(!1);break}t=t.parent}}}}else this.setFocused(!1);return this}onStateChange(t,e){this.toDirty(),ot.update(this),this.emit("statechange",t,e,this);const i=this.children;for(let s=0,n=i.length;s<n;++s){const n=i[s];n instanceof to&&n.state.onParentChange(t,e)}t.isFocused?(e.isFocused||this.onFocus(),t.inDisabled&&!e.inDisabled&&setTimeout(()=>{this.blur()},0)):e.isFocused&&this.onBlur(),this.cursor=this.toCursor(this._cursor,t)}onChildFocus(t){const e=this.parent;e instanceof to&&e.onChildFocus(t)}onFocus(){const t=this.parent;t instanceof to&&t.onChildFocus(this)}onChildBlur(t){const e=this.parent;e instanceof to&&e.onChildBlur(t)}onBlur(){const t=this.parent;t instanceof to&&t.onChildBlur(this)}get state(){return this._state}get options(){return this._options}get theme(){return this._theme}set theme(t){this._theme!==t&&(this._theme=t,this._padding.setTheme(t),this._background.setTheme(t),this._border.setTheme(t),this._outline.setTheme(t),this._corner.setTheme(t),this.toDirty(),ot.update(this))}reflow(){const t=this._isDirty;t&&(this.onReflow(),this._isDirty=!1);const e=this._hasDirty,i=this._isHierarchyDirty;if(e||i){this._hasDirty=!1,this._isHierarchyDirty=!1;const t=this.children;for(let e=0,i=t.length;e<i;++e){const i=t[e];i instanceof to&&i.reflow()}}(t||e||i)&&this.onRefit()}onRefit(){const e=this._auto,i=e.width.isOn,s=e.height.isOn;if(i&&s){let e=0,i=0;const s=this.children;for(let n=0,o=s.length;n<o;++n){const o=s[n];if(o.visible){const s=this.hasRefitableWidth(o),n=this.hasRefitableHeight(o);if(s||n)if(o instanceof to)s&&(e=Math.max(e,o.x+o.width)),n&&(i=Math.max(i,o.y+o.height));else if(o instanceof t.Container){const t=o.getLocalBounds(void 0,!0);s&&(e=Math.max(e,o.x+t.x+t.width)),n&&(i=Math.max(i,o.y+t.y+t.height))}else{const t=o.getLocalBounds();s&&(e=Math.max(e,o.x+t.x+t.width)),n&&(i=Math.max(i,o.y+t.y+t.height))}}}const n=this.padding;this.resize(e+n.getRight(),i+n.getBottom())}else if(i){let e=0;const i=this.children;for(let s=0,n=i.length;s<n;++s){const n=i[s];if(n.visible&&this.hasRefitableWidth(n))if(n instanceof to)e=Math.max(e,n.x+n.width);else if(n instanceof t.Container){const t=n.getLocalBounds(void 0,!0);e=Math.max(e,n.x+t.x+t.width)}else{const t=n.getLocalBounds();e=Math.max(e,n.x+t.x+t.width)}}this.resize(e+this.padding.getRight(),void 0)}else if(s){let e=0;const i=this.children;for(let s=0,n=i.length;s<n;++s){const n=i[s];if(n.visible&&this.hasRefitableHeight(n))if(n instanceof to)e=Math.max(e,n.y+n.height);else if(n instanceof t.Container){const t=n.getLocalBounds(void 0,!0);e=Math.max(e,n.y+t.y+t.height)}else{const t=n.getLocalBounds();e=Math.max(e,n.y+t.y+t.height)}}this.resize(void 0,e+this.padding.getBottom())}}isRefitable(t){return t instanceof to}hasRefitableHeight(t){return this.isRefitable(t)&&!(t instanceof to&&Tt(t.getHeight()))}hasRefitableWidth(t){return this.isRefitable(t)&&!(t instanceof to&&Tt(t.getWidth()))}onReflow(){this._reflowable.onReflow(this,this._width,this._height)}get shadow(){return this._shadow}set shadow(t){const e=this._shadow;if(e!==t){const i=this._reflowable,s=this._snippet,n=this._onShadowUpdateBound;null!=e&&(e.off("update",n),i.remove(e),s.remove(e,!0)),this._shadow=t,null!=t&&(t.on("update",n),i.add(t),s.addAt(t,!0,0)),ot.update(this)}}toParentResized(){const t=this.getParentOfSize();t&&this.onParentResize(t.width,t.height,t.padding)}getParentOfSize(){const t=this.parent;return t instanceof to?t:ot.getLayer(this)}onParentResize(t,e,i){const s=this._scalarSet,n=this.transform.position,o=n.x,r=n.y,a=this._width,h=this._height,l=i.getLeft()+i.getRight(),c=i.getTop()+i.getBottom(),u=null!=s.width?s.width(t,a,l,a):a,d=null!=s.height?s.height(e,h,c,h):h;this.resize(u,d);const p=null!=s.x?s.x(t,this._width,i.getLeft(),o):o,_=null!=s.y?s.y(e,this._height,i.getTop(),r):r;this.position.set(p,_)}onParentMove(t,e,i,s){}onWheel(t,e,i){return this.emit("wheel",t,e,i,this),!1}onKeyDown(t){return this.emit("keydown",t,this),!1}onKeyUp(t){return this.emit("keyup",t,this),!1}isEventTarget(t){const e=t.target;if(e===this)return!0;if(null!=e&&!(e instanceof to&&e.interactive)){let t=e.parent;for(;null!=t&&!(t instanceof to&&t.interactive);)t=t.parent;return t===this}return!1}onDown(t){this.isEventTarget(t)&&this.onDownThis(t),this.emit("down",t,this)}onDownThis(e){var i;"touches"in e.data.originalEvent?(null!==(i=this._lastDownPoint)&&void 0!==i?i:this._lastDownPoint=new t.Point).copyFrom(e.data.global):this.focusOnClosest()}onUp(t){this.isEventTarget(t)&&this.onUpThis(t),this.emit("up",t,this)}onUpThis(t){if("touches"in t.data.originalEvent){const e=this._lastDownPoint;if(e){const i=t.data.global,s=Math.abs(i.x-e.x),n=Math.abs(i.y-e.y),o=nn.CLICK_DISTANCE_THRESHOLD;s<o&&n<o&&this.focusOnClosest()}}}focusOnClosest(){const t=ot.getLayer(this);if(t){const e=t.getFocusController();e.focus(e.findParent(this))}}onOver(t){this.state.isHovered=!0,t.target===this&&this.applyTitle(),this.emit("over",t,this)}onOut(t){this.state.isHovered=!1,this.emit("out",t,this)}onDblClick(t,e){return this.emit("dblclick",t,e,this),!1}render(t){if(this.visible&&0<this.worldAlpha&&this.renderable){const e=this._snippet;e.render(t,!0),super.render(t),e.render(t,!1)}}updateTransform(){super.updateTransform(),this._snippet.updateTransform()}getThemeDefault(){return $.getInstance().get(this.getType())}getType(){return"DBase"}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this._width,this._height),super._calculateBounds()}containsPoint(t){return this.containsGlobalPoint(t)||this.containsLocalPoint(this.worldTransform.applyInverse(t,to.WORK_CONTAINS_POINT))}containsGlobalPoint(t){return!1}containsLocalPoint(t){const e=t.x,i=t.y,s=this._width,n=this._height;return 0<=e&&e<=s&&0<=i&&i<=n}getClippingRect(t,e){e.x=0,e.y=0,e.width=this._width,e.height=this._height}destroy(){const t=this._scalarSet;t.x=null,t.y=null,t.width=null,t.height=null;const e=this._shadow;e&&(this._shadow=null,e.destroy());const i=this.children;for(let t=i.length-1;0<=t;--t)i[t].destroy();i.length=0,super.destroy()}}to.WORK_CONTAINS_POINT=new t.Point;class eo extends t.Graphics{constructor(t){super(),this.parent=t,this._isInitialized=!1,this._width=0,this._height=0,this._cornderRadius=0,this._cornerMask=Sn.NONE}render(t){this.updateTransform(),super.render(t)}onReflow(t,e,i){const s=t.corner,n=Math.max(0,s.getRadius()-.5),o=s.getMask();if(this._isInitialized&&this._width===e&&this._height===i&&this._cornderRadius===n&&this._cornerMask===o)return;this._isInitialized=!0,this._width=e,this._height=i,this._cornderRadius=n,this._cornerMask=o;const r=o&Sn.TOP_LEFT?0:n,a=o&Sn.TOP_RIGHT?0:n,h=o&Sn.BOTTOM_LEFT?0:n,l=o&Sn.BOTTOM_RIGHT?0:n;this.clear(),this.beginFill(16777215,1),this.lineStyle(0,0,0,0,!1),r<=0&&a<=0&&h<=0&&l<=0?this.drawRect(0,0,e,i):(this.moveTo(0+r,0),0<a?this.arcTo(0+e,0,0+e,0+i,a):this.lineTo(0+e,0),0<l?this.arcTo(0+e,0+i,0,0+i,l):this.lineTo(0+e,0+i),0<h?this.arcTo(0,0+i,0,0,h):this.lineTo(0,0+i),0<r?this.arcTo(0,0,0+e,0,r):this.lineTo(0,0)),this.endFill()}}const io={OFF:0,ON:1,TOUCH:2};class so{constructor(e,i,s,n,o,r){var a,h;this._owner=e,this._parent=s,this._constraint=n;const l=Qi(null!==(a=null==r?void 0:r.mode)&&void 0!==a?a:o.getGestureMode(),io),c=Qi(null!==(h=null==r?void 0:r.modifier)&&void 0!==h?h:o.getGestureModifier(),en);if(l===io.ON||l===io.TOUCH){const s=new t.Point;this._gestureUtil=new un({touch:l===io.TOUCH,modifier:c,checker:r&&r.checker,easing:{duration:null==r?void 0:r.duration},on:{start:t=>{this.onStart(t)},move:(t,n,o,r,a,h)=>{this.onGestureMove(i(e),n,o,r,a,h,s)},easing:{end:t=>{this.onEnd(t)}},stop:t=>{this.onStop(t)},tap:(t,e)=>{this.onTap(t,e)},longpress:(t,e)=>{this.onLongPress(t,e)}}})}}onStart(t){const e=this._parent;e.stop(),e.emit("gesturestart",t,e)}onEnd(t){const e=this._parent;e.emit("gestureend",t,e)}onStop(t){const e=this._parent;e.emit("gesturestop",t,e)}onTap(t,e){const i=this._parent;i.emit("gesturetap",t,e,i)}onLongPress(t,e){const i=this._parent;i.emit("gesturelongpress",t,e,i)}onGestureMove(t,e,i,s,n,o,r){if(null!=t){const a=this._parent,h=t.scale,l=h.x,c=h.y;let u=a.toNormalizedScale(l*o),d=a.toNormalizedScale(c*o);const p=u/l,_=d/c,g=o<1?Math.max(p,_):Math.min(p,_);u=g*l,d=g*c;const f=t.parent;null!=f&&(f.toLocal(r.set(s,n),void 0,r),s=r.x,n=r.y);const m=s-e,v=n-i,T=t.position,w=(T.x-m)*g+s,E=(T.y-v)*g+n;this._constraint(t,w,E,u,d)}}stop(){var t;null===(t=this._gestureUtil)||void 0===t||t.stop(this._owner)}onDown(t){var e;null===(e=this._gestureUtil)||void 0===e||e.onDown(this._owner,t)}}class no{constructor(t,e,i,s,n){this._owner=t,this._toTarget=e,this._constraint=s,this._newScaleX=1,this._newScaleY=1,this._newX=0,this._newY=0,this._oldScaleX=1,this._oldScaleY=1,this._oldX=0,this._oldY=0,this._isStarted=!1,this._animation=new an({onStart:()=>{this.onStart()},onTime:t=>{this.onTime(t)},onEnd:()=>{this.onEnd()},onStop:()=>{this.onStop()},duration:n}),this._parent=i,this._duration=n}onStart(){const t=this._parent;t.emit("transformstart",this._owner,t)}onTime(t){const e=1-t,i=t,s=this._oldScaleX*e+this._newScaleX*i,n=this._oldScaleY*e+this._newScaleY*i,o=this._oldX*e+this._newX*i,r=this._oldY*e+this._newY*i,a=this._toTarget(this._owner);null!=a&&this._constraint(a,o,r,s,n)}onEnd(){const t=this._parent;t.emit("transformend",this._owner,t)}onStop(){const t=this._parent;t.emit("transformstop",this._owner,t)}start(t,e,i,s,n,o,r){const a=this._parent;if(!1!==r&&a.stop(),null==o&&(o=this._duration),o<=0)this.onStart(),this._constraint(t,e,i,s,n),this.onEnd();else{const r=t.position,a=t.scale;this._oldX=r.x,this._oldY=r.y,this._oldScaleX=a.x,this._oldScaleY=a.y,this._newX=e,this._newY=i,this._newScaleX=s,this._newScaleY=n,this._animation.duration=o,this._animation.start()}}stop(){this._animation.stop()}}class oo extends t.utils.EventEmitter{constructor(e,i,s){var n,o,r,a,h,l,c,u,d,p,_,g,f,m,v,T,w;super(),this._parent=e,this._toTarget=i,this._constraint=s&&s.constraint||oo.CONSTRAINT,this._workRect=new t.Rectangle;const E=this.toTheme(s)||this.getThemeDefault(),y=null==s?void 0:s.zoom;this._zoomPoint=new t.Point,this._zoomMin=null!==(n=null==y?void 0:y.min)&&void 0!==n?n:E.getZoomMin(),this._zoomMax=null!==(o=null==y?void 0:y.max)&&void 0!==o?o:E.getZoomMax(),this._zoomKeepRatio=null!==(r=null==y?void 0:y.keepRatio)&&void 0!==r?r:E.getZoomKeepRatio();const x=null==y?void 0:y.wheel;this._isWheelZoomEnabled=null!==(a=null==x?void 0:x.enable)&&void 0!==a?a:E.isWheelZoomEnabled(),this._wheelZoomSpeed=null!==(h=null==x?void 0:x.speed)&&void 0!==h?h:E.getWheelZoomSpeed(),this._wheelZoomModifier=Qi(null!==(l=null==x?void 0:x.modifier)&&void 0!==l?l:E.getWheelZoomModifier(),en),this._wheelZoomChecker=null!==(c=null==x?void 0:x.checker)&&void 0!==c?c:sn.match;const C=null==y?void 0:y.dblclick;this._isDblClickZoomEnabled=null!==(u=null==C?void 0:C.enable)&&void 0!==u?u:E.isDblClickZoomEnabled(),this._dblClickZoomSpeed=null!==(d=null==C?void 0:C.amount)&&void 0!==d?d:E.getDblClickZoomSpeed(),this._dblClickZoomModifier=Qi(null!==(p=null==C?void 0:C.modifier)&&void 0!==p?p:E.getDblClickZoomModifier(),en),this._dblClickZoomChecker=null!==(_=null==C?void 0:C.checker)&&void 0!==_?_:sn.match,this._dblclickZoomDuration=null!==(g=null==C?void 0:C.duration)&&void 0!==g?g:E.getDblClickZoomDuration();const D=null===(f=null==s?void 0:s.translation)||void 0===f?void 0:f.wheel;if(this._isWheelTranslationEnabled=null!==(m=null==D?void 0:D.enable)&&void 0!==m?m:E.isWheelTranslationEnabled(),this._wheelTranslationSpeed=null!==(v=null==D?void 0:D.speed)&&void 0!==v?v:E.getWheelTranslationSpeed(),this._wheelTranslationModifier=Qi(null!==(T=null==D?void 0:D.modifier)&&void 0!==T?T:E.getWheelTranslationModifier(),en),this._wheelTranslationChecker=null!==(w=null==D?void 0:D.checker)&&void 0!==w?w:sn.match,this._gesture=new so(e,i,this,this._constraint,E,null==s?void 0:s.gesture),this._transform=new no(e,i,this,this._constraint,this._dblclickZoomDuration),null!=s){const t=s.on;if(null!=t)for(const e in t){const i=t[e];i&&this.on(e,i)}}}get gesture(){return this._gesture}stop(){this._gesture.stop(),this._transform.stop()}reset(t,e){const i=this._parent,s=this._toTarget(i);if(s){const n=i.padding,o=n.getLeft(),r=n.getTop(),a=n.getRight(),h=n.getBottom(),l=i.width-o-a,c=i.height-r-h,u=s.getLocalBounds(this._workRect),d=u.x,p=u.y,_=o+.5*(l-u.width)-d,g=r+.5*(c-u.height)-p;this._transform.start(s,_,g,1,1,t,e)}}fit(t,e){const i=this._parent,s=this._toTarget(i);if(s){const n=i.padding,o=n.getLeft(),r=n.getTop(),a=n.getRight(),h=n.getBottom(),l=i.width-o-a,c=i.height-r-h,u=s.getLocalBounds(this._workRect),d=u.x,p=u.y,_=u.width,g=u.height;let f=l/_,m=c/g;if(this._zoomKeepRatio){const t=this.toNormalizedScale(Math.min(f,m));f=t,m=t}else f=this.toNormalizedScale(f),m=this.toNormalizedScale(m);const v=o+.5*(l-_*f)-d*f,T=r+.5*(c-g*m)-p*m;this._transform.start(s,v,T,f,m,t,e)}}zoomIn(t,e){const i=this._toTarget(this._parent);if(i){const s=this._dblClickZoomSpeed,n=i.scale;this.zoom(n.x*s,n.y*s,t,e)}}zoomOut(t,e){const i=this._toTarget(this._parent);if(i){const s=1/this._dblClickZoomSpeed,n=i.scale;this.zoom(n.x*s,n.y*s,t,e)}}zoomAt(t,e,i,s,n,o){const r=this._toTarget(this._parent);if(r){const a=r.scale.x,h=r.scale.y,l=this.toNormalizedScale(i),c=this.toNormalizedScale(s),u=l/a,d=c/h,p=(r.position.x-t)*u+t,_=(r.position.y-e)*d+e;this._transform.start(r,p,_,l,c,n,o)}}zoomAtGlobal(t,e,i,s,n,o){const r=this._zoomPoint;r.set(t,e),this.toLocal(r,r),this.zoomAt(r.x,r.y,i,s,n,o)}zoom(t,e,i,s){const n=this._parent;this.zoomAt(.5*n.width,.5*n.height,t,e,i,s)}get scale(){const e=this._toTarget(this._parent);return e?e.scale:new t.Point(1,1)}set scale(t){const e=this._toTarget(this._parent);if(e){const i=this.toNormalizedScale(t.x),s=this.toNormalizedScale(t.y),n=e.position;this._constraint(e,n.x,n.y,i,s)}}moveTo(t,e,i,s){const n=this._toTarget(this._parent);if(n){const o=n.scale;this._transform.start(n,t,e,o.x,o.y,i,s)}}get position(){const e=this._toTarget(this._parent);return e?e.position:new t.Point(0,0)}set position(t){const e=this._toTarget(this._parent);if(e){const i=e.scale;this._constraint(e,t.x,t.y,i.x,i.y)}}transform(t,e,i,s,n,o){const r=this._toTarget(this._parent);r&&this._transform.start(r,t,e,i,s,n,o)}toLocal(t,e,i){return this._parent.toLocal(t,void 0,e,i)}toGlobal(t,e,i){return this._parent.toGlobal(t,e,i)}toNormalizedScale(t){return Math.min(this._zoomMax,Math.max(this._zoomMin,t))}onWheel(t,e,i){if(this._isWheelZoomEnabled&&this._wheelZoomChecker(t,this._wheelZoomModifier,this._parent)&&0!==e.deltaY){const t=this._toTarget(this._parent);if(t){const s=e.lowest*this._wheelZoomSpeed,n=1+e.deltaY*s,o=t.scale;return this.zoomAtGlobal(i.x,i.y,o.x*n,o.y*n,0),!0}}if(this._isWheelTranslationEnabled&&this._wheelTranslationChecker(t,this._wheelTranslationModifier,this._parent)){const t=this._toTarget(this._parent);if(t){this.stop(),this.emit("wheeltranslationstart",this._parent,this);const i=e.lowest*this._wheelTranslationSpeed,s=t.position,n=s.x-e.deltaX*i,o=s.y+e.deltaY*i,r=t.scale;return this._constraint(t,n,o,r.x,r.y),this.emit("wheeltranslationend",this._parent,this),!0}}return!1}onDown(t){this._gesture.onDown(t)}onDblClick(t,e){if(this._isDblClickZoomEnabled&&this._dblClickZoomChecker(t,this._dblClickZoomModifier,this._parent)){const i=this._toTarget(this._parent);if(i){const s=this._zoomPoint;nn.toGlobal(t,e,s);const n=this._dblClickZoomSpeed,o=i.scale;return this.zoomAtGlobal(s.x,s.y,o.x*n,o.y*n,this._dblclickZoomDuration),!0}}return!1}toTheme(t){if(t&&t.theme){const e=t.theme;return Et(e)?$.getInstance().get(e):e}return null}getThemeDefault(){return $.getInstance().get(this.getType())}getType(){return"DView"}}oo.CONSTRAINT=(t,e,i,s,n)=>{t.scale.set(s,n),t.position.set(e,i)};class ro extends to{init(t){var e;super.init(t),this._canvas=null;const i=this.theme;this._view=new oo(this,()=>this._canvas,null==t?void 0:t.view);const s=null==t?void 0:t.canvas;s&&(this.canvas=s),(null!==(e=null==t?void 0:t.mask)&&void 0!==e?e:i.isOverflowMaskEnabled())&&(this.mask=this.getOverflowMask())}getType(){return"DCanvasContainer"}onResize(t,e,i,s){super.onResize(t,e,i,s),this.updateContentSize(t,e,i,s)}get canvas(){return this._canvas}set canvas(t){const e=this._canvas;null!=e&&(this._canvas=null,this.removeChild(e),this.emit("unset",e,this),e.destroy()),this._canvas=t,null!=t?(this.addChild(t),this._view.reset(0),this.emit("set",t,this)):ot.update(this)}getOverflowMask(){return null==this._overflowMask&&(this._overflowMask=new eo(this),this._reflowable.add(this._overflowMask),this.toDirty()),this._overflowMask}updateContentSize(t,e,i,s){const n=this._canvas;if(null!=n){const o=n.x+.5*(t-i),r=n.y+.5*(e-s);n.position.set(o,r)}}get view(){return this._view}onWheel(t,e,i){const s=this._view.onWheel(t,e,i),n=super.onWheel(t,e,i);return s||n}onDblClick(t,e,i){if(!0!==i){const i=this._view.onDblClick(t,e),s=super.onDblClick(t,e);return i||s}return super.onDblClick(t,e)}onDown(t,e){!0!==e&&this._view.onDown(t),super.onDown(t)}destroy(){const t=this._overflowMask;null!=t&&(this._overflowMask=null,t.destroy()),this.mask=null,super.destroy()}}class ao{constructor(t,e){const i=document.createElement("canvas");this._element=i;const s=this._element.getContext("2d",{willReadFrequently:!0});this._context=s,i.width=t,i.height=e}get element(){const t=this._element;if(null!=t)return t;throw new Error("No Element Available")}getElement(){return this._element}get canvas(){return this.element}get context(){const t=this._context;if(null!=t)return t;throw new Error("No Context Available")}getContext(){return this._context}get resolution(){return 1}get width(){const t=this._element;return null!=t?t.width:0}set width(t){const e=this._element;null!=e&&(e.width=t)}get height(){const t=this._element;return null!=t?t.height:0}set height(t){const e=this._element;null!=e&&(e.height=t)}clear(){const t=this._element,e=this._context;null!=t&&null!=e&&(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height))}resize(t,e){const i=this._element;null!=i&&(i.width=t,i.height=e)}destroy(){this._context=null,this._element=null}}class ho{static toTexture(e,i,s,n){const o=e.transform.scale,r=Math.max(1,Math.ceil(e.width*o.x)),a=Math.max(1,Math.ceil(e.height*o.y)),h=t.RenderTexture.create({width:r,height:a,scaleMode:t.SCALE_MODES.LINEAR,resolution:i}),l=new t.Matrix(void 0,void 0,void 0,void 0,-e.position.x,-e.position.y),c=ot.getLayer(e);return c&&c.renderer.render(e,h,s,l,n),h}static toPixels(t,e){const i=t.baseTexture,s=i.realWidth,n=i.realHeight,o=t.resolution,r=t.frame,a=Math.floor(r.x*o),h=Math.floor(r.y*o),l=Math.floor((r.x+r.width)*o),c=Math.floor((r.y+r.height)*o),u=Math.min(l-a,s),d=Math.min(c-h,n),p=new Uint8Array(4*u*d);if(0<u&&0<d){const i=e.renderTexture.current;e.renderTexture.bind(t);const s=e.gl;s.readPixels(a,h,u,d,s.RGBA,s.UNSIGNED_BYTE,p),e.renderTexture.bind(i)}return{width:u,height:d,array:p}}static toCanvas(e,i,s,n){const o=e.width,r=e.height,a=e.array;if(null==n?n=new ao(o,r):n.resize(o,r),o<=0||r<=0)return n;const h=n.getContext(),l=n.getElement();if(null==h||null==l)return n;const c=h.getImageData(0,0,o,r);if(s?c.data.set(a):t.Extract.arrayPostDivide(a,c.data),h.putImageData(c,0,0),null!=i&&1!==i){h.scale(i,i),h.drawImage(l,0,0);const t=Math.floor(o*i),e=Math.floor(r*i),s=h.getImageData(0,0,t,e);n.resize(t,e),h.putImageData(s,0,0)}return n}static toBase64(t,e,i){return t.toDataURL(e,i)}}class lo{static downloadUrl(t,e){const i=document.createElement("a");"download"in i?(i.href=e,i.setAttribute("download",t),i.style.display="none",document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i)},66)):window.open(e)||(location.href=e)}static download(t,e,i){const s=new Blob(!1!==i?["\ufeff",e]:[e],{type:"text/plain"}),n=window.navigator;"msSaveBlob"in n?n.msSaveBlob(s,t):this.downloadUrl(t,URL.createObjectURL(s))}}const co=t=>{var e;const i=t.target,s=t.resolution;if(null!=s){if(wt(s))return s;{const t=i.transform.scale,e=Math.max(i.width*t.x,i.height*t.y);return Math.min(1,s.size/e)}}return null!==(e=window.devicePixelRatio)&&void 0!==e?e:1},uo=(t,e)=>{const i=e.scale;if(null!=i){if(wt(i))return i;{const e=i.size;return Math.min(1,e/t.width,e/t.height)}}};class po{static texture(t){var e;const i=t.target,s=co(t),n=null===(e=t.transform)||void 0===e?void 0:e.update;return ho.toTexture(i,s,t.clear,n)}static pixels(e){var i;const s=(t=>{const e=t.renderer;if(e)return e;const i=t.application;if(i)return i.getLayerBase().renderer;const s=t.layer||ot.getLayer(t.target);if(s)return s.renderer;throw new Error("No renderer / application / layer found.")})(e),n=e.target,o=n.transform.scale,r=Math.ceil(n.width*o.x),a=Math.ceil(n.height*o.y);if(r<=0||a<=0)return{width:r,height:a,array:new Uint8Array(0)};const h=co(e);let l=po.WORK_RENDER_TEXTURE;if(null==l)l=t.RenderTexture.create({width:r,height:a,scaleMode:t.SCALE_MODES.LINEAR,resolution:h}),po.WORK_RENDER_TEXTURE=l;else{const t=l.baseTexture,e=t.width,i=t.height,s=e<r,n=i<a,o=l.resolution!==h;(o||s||n)&&(o&&(t.resolution=h),l.resize(Math.max(r,e),Math.max(a,i),!0))}const c=l.frame;0===c.x&&0===c.y&&c.width===r&&c.height===a||(c.x=0,c.y=0,c.width=r,c.height=a,l.frame=c);const u=n.position,d=new t.Matrix(1,0,0,1,-u.x,-u.y);return s.render(n,l,e.clear,d,null===(i=e.transform)||void 0===i?void 0:i.update),ho.toPixels(l,s)}static canvas(t){var e,i;const s=this.pixels(t),n=null===(i=null===(e=t.alpha)||void 0===e?void 0:e.premultiplied)||void 0===i?void 0:i.ignore,o=uo(s,t);return ho.toCanvas(s,o,n)}static base64(t){var e,i,s;const n=this.pixels(t),o=null===(i=null===(e=t.alpha)||void 0===e?void 0:e.premultiplied)||void 0===i?void 0:i.ignore,r=uo(n,t),a=null!==(s=this.WORK_CANVAS)&&void 0!==s?s:this.WORK_CANVAS=new ao(n.width,n.height);ho.toCanvas(n,r,o,a);const h=a.getElement();return null!=h?ho.toBase64(h,t.format,t.quality):"data:,"}static file(t){lo.downloadUrl(t.filename,this.base64(t))}static destroy(){const t=this.WORK_RENDER_TEXTURE;null!=t&&(this.WORK_RENDER_TEXTURE=void 0,t.destroy(!0));const e=this.WORK_CANVAS;null!=e&&(this.WORK_CANVAS=void 0,e.destroy())}}class _o extends t.utils.EventEmitter{constructor(t,e){super(),this._parent=t;const i=null==e?void 0:e.on;if(i)for(const t in i){const e=i[t];e&&this.on(t,e)}}createAsUrl(t){return null==t||wt(t)?this.create({size:t,extractor:t=>po.base64({target:t})}):this.create({size:t.size,cleanup:t.cleanup,extractor:t=>po.base64({target:t})})}createAsFile(t,e){Et(t)?this.create({extractor:e=>{po.file({target:e,filename:t})}}):null===t||wt(t)?this.create({size:t,extractor:t=>{po.file({target:t,filename:e})}}):this.create({size:t.size,cleanup:t.cleanup,extractor:e=>{po.file({target:e,filename:t.filename})}})}toScale(t,e){return null==t?1:t/ot.getResolution(e)/Math.max(e.width,e.height)}toCleanupSnap(t){if(null==t)return!0;const e=t.cleanup;return null==e||!0===e||!1!==e&&!1!==e.snap}toCleanupBackground(t){if(null==t)return!1;const e=t.cleanup;return null!=e&&!1!==e&&(!0===e||!0===e.background)}toCleanupReflow(t){if(null==t)return!0;const e=t.cleanup;return null==e||!0===e||!1!==e&&!1!==e.reflow}create(t){const e=this._parent,i=e.canvas;if(i){const s=e.view,n=s.position,o=s.scale,r=n.x,a=n.y,h=o.x,l=o.y,c=this.toScale(t.size,i);let u,d;if(s.transform(0,0,c,c,0),this.toCleanupSnap(t)&&"snap"in i){const t=i.snap;null!=t&&(u=t.container,u.renderable?u.renderable=!1:u=void 0)}if(this.toCleanupBackground(t)&&(d=i.snippet,d.renderable?d.renderable=!1:d=void 0),this.toCleanupReflow(t)){const t=ot.getLayer(i);t&&t.reflow()}this.emit("taking",i,this);const p=t.extractor(i);return this.emit("took",i,null,this),d&&(d.renderable=!0),null!=u&&(u.renderable=!0),s.transform(r,a,h,l,0),p}}}class go extends ro{constructor(t){var e;super(t),this._serialized=null,this._tileFactory=null==t?void 0:t.tile,this._controller=null==t?void 0:t.controller,this._isAmbient=null!==(e=null==t?void 0:t.ambient)&&void 0!==e?e:this.theme.isAmbient(),this._snapshot=new _o(this,null==t?void 0:t.snapshot),this._mode=this.toMode(t)}get snapshot(){return this._snapshot}get controller(){return this._controller||null}set(t){const e=this._serialized;if(e!==t){if(e&&(this._serialized=null,this.canvas&&(this.canvas=null),this.onUnset()),this._serialized=t,t){const e=this.newCanvas(t),i=t.pieces,s=this._mode,n=En.toPieceData(this._controller,i,s).then(n=>this.newLayer(t,e,s,i,n));return this.onSet(t,e),this.canvas=e,n}return Promise.resolve(null)}return Promise.resolve(this.canvas)}onSet(t,e){}newLayer(t,e,i,s,n){const o=new ki(t,s,n,i,0),r=En.newLayer(t,e.layer,o).then(t=>this.initLayer(e,t));if(this._isAmbient){const e=this.toCanvasBaseBackgroundOptions(t,this.theme,!1);this.background.color=e.color,this.background.alpha=e.alpha}return r}initLayer(t,e,i){return t.layer.init(),t.initialize(e,i),ot.update(this),this.emit("ready",this),t}toCanvasBaseOptions(t){var e;const i=this.theme,s=this._isAmbient;return{name:t.name,label:t.label,width:t.width,height:t.height,category:t.category,summary:t.summary,description:t.description,background:this.toCanvasBaseBackgroundOptions(t,i,s),border:s?{color:null}:void 0,outline:s?{color:null}:void 0,shadow:s?null:i.getCanvasShadow(),tile:{factory:this._tileFactory,mapping:null===(e=t.tile)||void 0===e?void 0:e.mapping},ambient:s}}toCanvasBaseBackgroundOptions(t,e,i){var s,n;if(i)return{color:null};const o=t.background;return{color:null!==(s=null==o?void 0:o.color)&&void 0!==s?s:e.getCanvasBackgroundColor(),alpha:null!==(n=null==o?void 0:o.alpha)&&void 0!==n?n:e.getCanvasBackgroundAlpha()}}onUnset(){}get(){return this._serialized}get layer(){const t=this.canvas;return t?t.layer.active:null}getType(){return"DDiagramBase"}}class fo extends to{getType(){return"DCanvas"}}class mo{constructor(t,e){this._target=t,this._base=e}getTheme(){return this._target.getTheme()}setTheme(t){this._target.setTheme(t)}getBaseColor(){return this._base}setBaseColor(t){this._base=t}getColor(t){const e=this._target,i=this._base,s=e.getColor(t);return null!=i?null!=s?de.blend(i,s,e.getAlpha(t)):i:s}get color(){return this._target.color}set color(t){this._target.color=t}getAlpha(t){return null!=this._base?1:this._target.getAlpha(t)}get alpha(){return this._target.alpha}set alpha(t){this._target.alpha=t}}class vo extends t.ObservablePoint{get lon(){return this.x}set lon(t){this.x=t}get lat(){return this.y}set lat(t){this.y=t}toObject(){return{lon:this.x,lat:this.y}}}class To{constructor(t,e,i,s,n,o){if(this._cb=t,!0===e||!1===e)this._enable=e,this._from=new vo(t,null,i,s),this._to=new vo(t,null,n,o);else if(null!=e){this._enable=e.enable;const i=e.from,s=e.to;this._from=new vo(t,null,i.lon,i.lat),this._to=new vo(t,null,s.lon,s.lat)}else this._enable=!1,this._from=new vo(t,null,-180,85.05112877980659),this._to=new vo(t,null,180,-85.05112877980659)}get enable(){return this._enable}set enable(t){this._enable!==t&&(this._enable=t,this._cb())}get from(){return this._from}get to(){return this._to}serialize(){return{enable:this._enable,from:this._from.toObject(),to:this._to.toObject()}}}class wo{constructor(t,e){this._canvas=t,this._factory=null==e?void 0:e.factory,this._mapping=new To(()=>{this.onMappingChange()},null==e?void 0:e.mapping)}init(){this.onMappingChange()}onMappingChange(){const t=this._factory;if(t){const e=this._mapping;if(e.enable){const i=this._pyramid;i?i.mapping=e:this._pyramid=t(this._canvas).fit()}else{const t=this._pyramid;t&&(this._pyramid=void 0,t.destroy())}}}get pyramid(){return this._pyramid}get factory(){return this._factory}get mapping(){return this._mapping}serialize(){return{mapping:this._mapping.serialize()}}destroy(){const t=this._pyramid;null!=t&&(this._pyramid=void 0,t.destroy())}}class Eo{constructor(t){const e=t.transform,i=e.position;this.x=i.x,this.y=i.y;const s=t.size;this.sizeX=s.x,this.sizeY=s.y,this.rotation=e.rotation,this.actions=[],this.fill=t.fill.toObject(),this.stroke=t.stroke.toObject(),this.text=t.text.toObject(),this.cursor=t.cursor,this.reset=pe.NONE,this.written=pe.NONE,this.effect=-1,this.isStateChanged=!1,this.interactive=!1}initialize(t){t.lock(Mt.UPLOADED);const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].initialize(t,this);t.unlock(Mt.UPLOADED,!0)}isActionable(){return 0<this.actions.length}onResize(t){const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].onResize(t,this)}onClick(t,e){const i=t.state;i.isActionable&&(i.isClicked=!0);const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onClick(t,this,e)}onDblClick(t,e,i){const s=t.state;s.isActionable&&(s.isDblClicked=!0);const n=this.actions;for(let s=0,o=n.length;s<o;++s)n[s].onDblClick(t,this,e,i);return!1}onOver(t,e){const i=t.state;if(!i.isHovered){i.isHovered=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onOver(t,this,e)}}onOut(t,e){if(t.state.isHovered){t.state.isHovered=!1;const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onOut(t,this,e)}}onDown(t,e){const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onDowning(t,this,e);const s=t.state;if(!s.isDown)if(s.isPressed){s.isDown=!0;const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s)i[s].onDown(t,this,e)}else{s.addAll(Ct.DOWN,lt.PRESSED);const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s){const n=i[s];n.onDown(t,this,e),n.onPressed(t,this,e)}}}onUp(t,e){const i=t.state;if(!i.isUp)if(i.isPressed){i.set(Ct.UP,lt.PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onUp(t,this,e),n.onUnpressed(t,this,e)}}else{i.isUp=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onUp(t,this,e)}}onUpOutside(t,e){const i=t.state;if(i.isPressed){i.set(Ct.UP_OUTSIDE,lt.PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onUpOutside(t,this,e),n.onUnpressed(t,this,e)}}else{i.isUpOutside=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onUpOutside(t,this,e)}}onMove(t,e){const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onMove(t,this,e)}onKeyDown(t,e){$n.isActivateKey(e)&&this.onDown(t,e);const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onKeyDown(t,this,e);return!1}onKeyUp(t,e){if($n.isActivateKey(e)){const i=t.state;if(i.isPressed){const s=i.isUp;this.onUp(t,e),!s&&i.isUp&&this.onClick(t,e)}}const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onKeyUp(t,this,e);return!1}onStateChange(t,e,i){this.isStateChanged=!0,ot.update(t),e.isFocused?i.isFocused||this.onFocus(t):i.isFocused&&this.onBlur(t)}onFocus(t){const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].onFocus(t,this)}onBlur(t){const e=this.actions;for(let i=0,s=e.length;i<s;++i)e[i].onBlur(t,this)}onRightClick(t,e){const i=t.state;i.isActionable&&(i.isRightClicked=!0);const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onRightClick(t,this,e)}onRightDown(t,e){const i=this.actions;for(let s=0,n=i.length;s<n;++s)i[s].onRightDowning(t,this,e);const s=t.state;if(!s.isRightDown)if(s.isRightPressed){s.addAll(Ct.RIGHT_DOWN,Ct.RIGHT_PRESSED);const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s){const n=i[s];n.onRightDown(t,this,e),n.onRightPressed(t,this,e)}}else{s.isRightDown=!1;const n=ot.getLayer(t);if(n){const e=n.getFocusController();e.focus(e.findParent(t))}for(let s=0,n=i.length;s<n;++s)i[s].onRightDown(t,this,e)}}onRightUp(t,e){const i=t.state;if(!i.isRightUp)if(i.isRightPressed){i.set(Ct.RIGHT_UP,Ct.RIGHT_PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onRightUp(t,this,e),n.onRightUnpressed(t,this,e)}}else{i.isRightUp=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onRightUp(t,this,e)}}onRightUpOutside(t,e){const i=t.state;if(i.isRightPressed){i.set(Ct.RIGHT_UP_OUTSIDE,Ct.RIGHT_PRESSED);const s=this.actions;for(let i=0,n=s.length;i<n;++i){const n=s[i];n.onRightUpOutside(t,this,e),n.onRightUnpressed(t,this,e)}}else{i.isRightUpOutside=!0;const s=this.actions;for(let i=0,n=s.length;i<n;++i)s[i].onRightUpOutside(t,this,e)}}update(t,e){const i=t.data,s=this.effect,n=0<=s&&s<=e;if(i.isChanged||this.isStateChanged||n){this.isStateChanged=!1,i.isChanged=!1,n&&(this.effect=-1),t.lock(Mt.UPLOADED),this.onUpdate(t,e),t.unlock(Mt.UPLOADED,!0);const s=this.isStateChanged;t.state.removeAll(Eo.TRANSIENT_STATES),this.isStateChanged=s}}onRender(t,e,i){const s=this.actions;for(let n=0,o=s.length;n<o;++n)s[n].onRender(t,this,e,i);this.update(t,e)}onUpdate(t,e){const i=this.actions;if(0<i.length){this.written=pe.NONE;for(let s=0,n=i.length;s<n;++s)i[s].execute(t,this,e);this.doReset(t)}}doReset(t){const e=~this.written&this.reset;if(e!==pe.NONE){if(e&pe.POSITION_X&&(t.transform.position.x=this.x),e&pe.POSITION_Y&&(t.transform.position.y=this.y),e&pe.VISIBILITY&&(t.visible=!0),e&pe.COLOR_FILL){const e=this.fill;t.fill.set(void 0,e.color,e.alpha)}if(e&pe.COLOR_STROKE){const e=this.stroke;t.stroke.set(void 0,e.color,e.alpha)}if(e&pe.COLOR_TEXT){const e=this.text;t.text.set(void 0,e.color,e.alpha)}if(e&pe.COLOR_TEXT_OUTLINE){const e=this.text.outline;t.text.outline.set(void 0,e.color,e.alpha)}e&pe.HEIGHT&&(t.size.y=this.sizeY),e&pe.WIDTH&&(t.size.x=this.sizeX),e&pe.ROTATION&&(t.transform.rotation=this.rotation),e&pe.TEXT&&(t.text.value=this.text.value),e&pe.CURSOR&&(t.cursor=this.cursor)}}}Eo.TRANSIENT_STATES=[Ct.CLICKED,Ct.DBL_CLICKED,Ct.DOWN,Ct.UP,Ct.UP_OUTSIDE,Ct.RIGHT_CLICKED,Ct.RIGHT_DOWN,Ct.RIGHT_UP,Ct.RIGHT_UP_OUTSIDE,Ct.ACTIVATED,Ct.DEACTIVATED];class yo extends te{constructor(t=s.RECTANGLE){super(t)}clone(){return new yo(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&ie(this,t,e,i,s,n,o)}}class xo extends yo{constructor(t=s.RECTANGLE_PIVOTED){super(t)}toHitTestData(t,e){const i=super.toHitTestData(t,e);return i.x-=i.width,i.y-=i.height,i}}class Co extends Js{constructor(t){super(),this.name=t,this.interactive=!1,this.reference=0;const e=this.newShape();e.parent=this,this._shape=e,this.interactives=[]}get width(){return this._shape.size.x}set width(t){this._shape.size.x=t}get height(){return this._shape.size.y}set height(t){this._shape.size.y=t}get background(){return this._shape.fill}get state(){return this._shape.state}newShape(){const t=new xo;return t.fill.set(!1,16777215,1),t.stroke.set(!1),t.state.add(vn.INTERACTIVE),t}initialize(t){const e=this.interactives,i=this._shape,s=i.state.is(vn.INTERACTIVE),n=i.state.is(vn.DRAGGABLE),o=i.state.is(vn.PINCHABLE);if(n||o){const e=new Eo(i);i.runtime=e;const s=(n?dn.DRAG:dn.NONE)|(o?dn.PINCH:dn.NONE);e.actions.push(new mn("",gn.LAYER,s).toRuntime()),t.push(i),e.initialize(i)}(s||n||o)&&(i.interactive=!0,e.push(i)),this.doInitialize(this.children,e)}doInitialize(t,e){for(let i=0,s=t.length;i<s;++i){const s=t[i],n=s.runtime;if(n)if(s.interactive||n.interactive)e.push(s);else{const t=s.cursor;null!=t&&0<t.length&&e.push(s)}const o=s.children;0<o.length&&this.doInitialize(o,e)}}update(t){this.doUpdate(this.children,t)}doUpdate(t,e){for(let i=0,s=t.length;i<s;++i){const s=t[i];s.update(e);const n=s.children;0<n.length&&this.doUpdate(n,e)}}hitTestInteractives(t){const e=this._work,i=this.interactives;for(let s=i.length-1;0<=s;--s){const n=i[s];if(n.visible&&(n.toLocal(t,void 0,e),null!=n.contains(e.x,e.y)))return n}return null}addUuid(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].addUuid(t)}updateUuid(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].updateUuid(t)}destroy(){if(!this._destroyed){const t=this.children;for(let e=t.length-1;0<=e;--e)t[e].destroy();t.length=0,super.destroy()}}serialize(t,e,i){const s=this.children;for(let n=0,o=s.length;n<o;++n){const o=s[n].serialize(e);o[16]=t,i.push(o)}const n=this._shape,o=e.addResource(this.name||""),r=(this.visible?1:0)|(n.state.is(vn.INVISIBLE)?0:2),a=this.position,h=n.size,l=n.fill.serialize(e),c=n.state.is(vn.INTERACTIVE)?1:0,u=n.state.is(vn.DRAGGABLE)?2:0,d=n.state.is(vn.PINCHABLE)?4:0;return[o,r,a.x,a.y,h.x,h.y,l,c|u|d]}static deserialize(t,e,i,s){var n,o,r;const a=new Co(this.deserializeName(t[0],e)),h=a._shape,l=t[1];if(null!=l){const t=e.mode!==Li.VIEWER;!t||1&l||(a.visible=!1),2&l||(h.state.add(vn.INVISIBLE),t||(a.visible=!1))}const c=t[2],u=t[3];a.position.set(c,u);const d=null!==(n=t[4])&&void 0!==n?n:i,p=null!==(o=t[5])&&void 0!==o?o:s;h.size.set(d,p);const _=t[6];null!=_&&h.fill.deserialize(_,e);const g=null!==(r=t[7])&&void 0!==r?r:1;return h.state.set(vn.INTERACTIVE,!!(1&g)),h.state.set(vn.DRAGGABLE,!!(2&g)),h.state.set(vn.PINCHABLE,!!(4&g)),a}static deserializeName(t,e){if(Et(t))return t;{const i=e.resources;return 0<=t&&t<=i.length?i[t]:""}}}class Do extends t.Container{constructor(t,e){super(),this._active=null,this._width=t,this._height=e,this.interactive=!1,this.interactiveChildren=!1}init(){if(null==this._active){const t=this.children,e=t.length;0<e&&(this._active=t[e-1])}}get active(){return this._active}set active(t){this._active!==t&&(null==t||0<=this.children.indexOf(t))&&(this._active=t,this.onLayerChange())}create(t,e){const i=new Co(t);return this.attach(i,e),i}attach(t,e){this.addChild(t),!0===e&&(this._active=t),this.onLayerChange(),ot.update(this)}attachAt(t,e,i){this.addChildAt(t,e),!0===i&&(this._active=t),this.onLayerChange(),ot.update(this)}detach(t,e){const i=this.children,s=i.indexOf(t);0<=s&&(this._active=e,i.splice(s,1),t.parent=void 0,this.onLayerChange(),ot.update(this))}delete(t,e){const i=this.children,s=i.indexOf(t);return 0<=s&&(i.splice(s,1),t.parent=void 0,this._active===t&&(!0===e?s<i.length?this._active=i[s]:0<i.length?this._active=i[s-1]:this._active=null:this._active=null),this.onLayerChange(),ot.update(this)),s}get(t){const e=this.children[t];return null!=e?e:null}clear(){const t=this.children;if(0<t.length){for(let e=t.length-1;0<=e;--e){const i=t[e];i.parent=null,i.destroy()}t.length=0,this.onLayerChange(),ot.update(this)}}destroy(){this._destroyed||(this.clear(),super.destroy())}size(){return this.children.length}onLayerChange(){this.emit("change",this)}serialize(t,e){const i=[],s=this.children;for(let e=0,i=s.length;e<i;++e)s[e].addUuid(t);for(let e=0,i=s.length;e<i;++e)s[e].updateUuid(t);for(let n=0,o=s.length;n<o;++n)i.push(s[n].serialize(n,t,e));return i}deserialize(t,e){const i=t.length;if(0<i){const s=this._width,n=this._height;for(let o=0;o<i;++o)this.addChild(Co.deserialize(t[o],e,s,n));this.onLayerChange(),ot.update(this)}}}class So extends fo{constructor(t){var e,i,s,n;super(t);const o=this.theme;this.isAmbient(o,t)||(this._background=new mo(this._background,this.toBackgroundBase(o,t)));const r=new Do(this.width,this.height);this._layer=r,this.addChild(r),null!=t?(this._label=null!==(e=t.label)&&void 0!==e?e:"",this._category=null!==(i=t.category)&&void 0!==i?i:null,this._summary=null!==(s=t.summary)&&void 0!==s?s:"",this._description=null!==(n=t.description)&&void 0!==n?n:""):(this._label="",this._category=null,this._summary="",this._description="");const a=new wo(this,null==t?void 0:t.tile);this._tile=a,a.init(),this._localBoundsLimit=o.getLocalBoundsLimit()}isAmbient(t,e){var i;return null!==(i=null==e?void 0:e.ambient)&&void 0!==i?i:t.isAmbient()}toBackgroundBase(t,e){var i,s;return null!==(s=null===(i=null==e?void 0:e.background)||void 0===i?void 0:i.base)&&void 0!==s?s:t.getBackgroundBase()}get label(){return this._label}set label(t){this._label=t}get category(){return this._category}set category(t){this._category=t}get summary(){return this._summary}set summary(t){this._summary=t}get description(){return this._description}set description(t){this._description=t}get tile(){return this._tile}get layer(){return this._layer}initialize(t,e){}destroy(){this._destroyed||(this.onDestroy(),super.destroy())}onDestroy(){this._tile.destroy(),this._layer.destroy()}hitTest(t,e){const i=this._layer.children;for(let s=i.length-1;0<=s;--s){const n=i[s];if(n.visible){const i=n.hitTest(t,e);if(null!=i)return i}}return null}getLocalBounds(e){var i,s;null==e&&(e=null!==(i=this._localBoundsRect)&&void 0!==i?i:this._localBoundsRect=new t.Rectangle),e.x=0,e.y=0,e.width=this.width,e.height=this.height;const n=this._localBoundsLimit;if(0===n)return e;const o=this.layer.children,r=o.length,a=null!==(s=So.WORK_LOCAL_BOUNDS)&&void 0!==s?s:So.WORK_LOCAL_BOUNDS=new t.Rectangle;if(0<n){let t=0;for(let i=0;i<r;++i){const s=o[i],n=s.transform.position;a.x=n.x,a.y=n.y,a.width=s.width,a.height=s.height,e.enlarge(a),t+=s.children.length}if(n<t)return e;for(let t=0;t<r;++t){const i=o[t],s=i.transform.position,n=s.x,r=s.y,h=i.children;for(let t=0,i=h.length;t<i;++t)h[t].getBoundsInternal(!0,a),a.x+=n,a.y+=r,e.enlarge(a)}}else for(let t=0;t<r;++t){const i=o[t],s=i.transform.position,n=s.x,r=s.y;a.x=n,a.y=r,a.width=i.width,a.height=i.height,e.enlarge(a);const h=i.children;for(let t=0,i=h.length;t<i;++t)h[t].getBoundsInternal(!0,a),a.x+=n,a.y+=r,e.enlarge(a)}return e}getType(){return"DDiagramCanvasBase"}}const bo={};class Io{get private(){let t=this._private;return null==t&&(t=this.newPrivate(),this._private=t),t}newPrivate(){return new Wt}get protected(){let t=this._protected;return null==t&&(t=this.newProtected(),this._protected=t),t}newProtected(){return new Wt}get extended(){let t=this._extended;return null==t&&(t=this.newExtended(),this._extended=t),t}newExtended(){return new Wt}get ids(){const t=this._data;if(null==t)return[];const e=[];return t.forEach((t,i)=>{e.push(i)}),e}each(t){const e=this._data;if(null==e)return null;let i=null;return e.forEach((e,s)=>{null==i&&!1===t(s)&&(i=s)}),i}add(t,e){var i;const s=null!==(i=this._data)&&void 0!==i?i:this._data=new Map,n=s.get(t);null==n?s.set(t,[e]):n.push(e)}set(t,e,i,s,n,o){const r=this._data;if(null==r)return!1;const a=r.get(t);if(null==a)return!1;const h=a.length;if(h<=0)return!1;for(let t=0;t<h;++t){const r=a[t];r.range.set(n,o),void 0!==i&&(r.time=i),void 0!==s&&(r.state=s),void 0!==e&&(r.value=e)}return!0}get(t){const e=this._data;if(null==e)return null;const i=e.get(t);return null==i?null:i}clear(t){const e=this._data;if(null==e)return!1;const i=e.get(t);if(null==i)return!1;const s=i.length;if(s<=0)return!1;for(let t=0;t<s;++t)i[t].clear();return!0}toDirty(t){const e=this._data;if(null==e)return!1;const i=e.get(t);if(null==i)return!1;const s=i.length;if(s<=0)return!1;for(let t=0;t<s;++t)i[t].toDirty();return!0}setAll(t,e,i,s,n,o){const r=this._data;if(null==r)return!1;const a=r.get(t);if(null==a)return!1;const h=a.length;if(h<=0)return!1;for(let t=0;t<h;++t){const r=a[t];r.range.set(n,o),void 0!==i&&(r.times=i),void 0!==s&&(r.states=s),void 0!==e&&(r.values=e)}return!0}setValue(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].value=e;return!0}setValues(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].values=e;return!0}setTime(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].time=e;return!0}setTimes(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].times=e;return!0}setState(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].state=e;return!0}setStates(t,e){const i=this._data;if(null==i)return!1;const s=i.get(t);if(null==s)return!1;const n=s.length;if(n<=0)return!1;for(let t=0;t<n;++t)s[t].states=e;return!0}setRange(t,e,i){const s=this._data;if(null==s)return!1;const n=s.get(t);if(null==n)return!1;const o=n.length;if(o<=0)return!1;for(let t=0;t<o;++t){const s=n[t].range;void 0!==e&&(null!==e?(s.type|=Nt.FROM,s.from=e):s.type&=~Nt.FROM),void 0!==i&&(null!==i?(s.type|=Nt.TO,s.to=i):s.type&=~Nt.TO)}return!0}}class Oo{constructor(t){this._canvas=t}each(t,e){const i=this._canvas.layer.children;for(let s=0,n=i.length;s<n&&!1!==this.each_(i[s].children,t,e);++s);return this}each_(t,e,i){for(let s=0,n=t.length;s<n;++s){const n=t[s];if(!1===e(n))return!1;if(i||Ui.contains(n,Ot.CHILDREN)){const t=n.children;if(0<t.length&&!1===this.each_(t,e,i))return!1}}}}class Ao extends Oo{constructor(t){super(t),this._data=new Map}add(t,e){const i=this._data,s=i.get(t);null==s?i.set(t,[e]):s.push(e)}get(t){const e=this._data.get(t);return e&&0<e.length?e[0]:null}getAll(t){return this._data.get(t)||[]}}class Ro{constructor(t,e){this._parent=t,this._values=[],this._interval=e,this._onTimeBound=()=>{this.onTime()}}add(t){this._values.push(t)}start(){null==this._timeoutId&&this.onTime()}getInterval(){const t=Date.now(),e=this._interval;return Math.max(0,e-t%e)}onTime(){const t=this._values;if(0<t.length){const e=Date.now()/this._interval;for(let i=0,s=t.length;i<s;++i)t[i].value=e;ot.update(this._parent)}this._timeoutId=window.setTimeout(this._onTimeBound,this.getInterval())}stop(){const t=this._timeoutId;null!=t&&(clearTimeout(t),this._timeoutId=void 0)}}class Mo{constructor(t){this._parent=t,this._data=new Map}add(t){const e=this._data,i=this.toNormalized(t),s=e.get(i);if(null!=s)return s;const n=new Ro(this._parent,i);return e.set(i,n),n}toNormalized(t){return wt(t)?Math.max(1,Math.round(t)):1e3}start(){this._data.forEach(t=>{t.start()})}stop(){this._data.forEach(t=>{t.stop()})}}class ko{static add(t){var e,i,s;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._idToDatum)&&void 0!==i?i:this._idToDatum=new Map).set(t.id,t),(null!==(s=this._data)&&void 0!==s?s:this._data=[]).push(t)}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static getById(t){const e=this._idToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Lo{static add(t,e){let i=this._typeToRuntimes;null==i&&(i=new Map,this._typeToRuntimes=i);let s=i.get(t);null==s?(s=[e],i.set(t,s)):s.push(e)}static get(t){const e=this._typeToRuntimes;if(null!=e)return e.get(t)}}const No="[]",Po=()=>0,Bo=()=>[],zo=()=>"",Uo=()=>({}),Fo=()=>!1;class Ho extends So{constructor(t){super(t),this._data=new Io,this._shape=new Ao(this),this._ticker=new Mo(this),this._actionables=[],this._downeds=new Set,this._updateBound=()=>{ot.update(this)}}get data(){return this._data}get shape(){return this._shape}get ticker(){return this._ticker}initialize(t,e){const i=this._actionables,s=this._data;this.initialize_(t,null,null,e,new Map,new Map,new Map,this._ticker,this._shape,s,i);const n=this._layer.children,o=n.length;for(let t=0;t<o;++t)n[t].initialize(i);ge.isInitializing=!0;const r=Date.now();for(let t=0;t<o;++t)n[t].update(r);ge.isInitializing=!1,s.extended.each(t=>{const e=ko.getById(t);if(e){const t=e.start;t&&t(this)}}),this._ticker.start()}initialize_(t,e,i,s,n,o,r,a,h,l,c){for(let u=0,d=t.length;u<d;++u){const d=t[u],p=d.id;0<p.length&&h.add(p,d),this.initData(d,e,i,s,n,o,a,l);const _=new(bo[d.type]||Eo)(d);d.runtime=_,this.initActions(d,_,r),_.initialize(d);const g=d.shortcut;null!=g&&$n.on(d,g,t=>{_.onClick(d,t)}),_.isActionable()&&c.push(d);const f=d.children;if(0<f.length){let t=e,u=i;d instanceof Yi&&(null==t&&(t=d),u=d),this.initialize_(f,t,u,s,n,o,r,a,h,l,c)}}}initData(t,e,i,s,n,o,r,a){const h=t.data;for(let l=0,c=h.size();l<c;++l){const c=h.get(l);if(null!=c)switch(c.type){case zt.BOOLEAN:case zt.BOOLEAN_ARRAY:case zt.NUMBER:case zt.NUMBER_ARRAY:case zt.STRING:case zt.STRING_ARRAY:case zt.OBJECT:case zt.OBJECT_ARRAY:this.initDataValue(c,t,e,i,s,n,o,a);break;case zt.TICKER:this.initDataTicker(c,o,r);break;default:this.initDataExtension(c,a)}}}initDataValue(t,e,i,s,n,o,r,a){if(t.scope===Ut.PRIVATE){const e=t.id;0<e.length&&(s?s.data.private.add(e,t):a.private.add(e,t))}else if(t.scope===Ut.PROTECTED){const e=t.id;0<e.length&&a.protected.add(e,t)}else{n&&n(t,i||e);const s=t.id;0<s.length&&a.add(s,t)}const h=t.format,l=t.initial;let c=o.get(t.type);null==c&&(c=new Map,o.set(t.type,c));const u=c.get(h);if(null!=u)t.formatter=u;else if(0<h.length){const e=this.calcFormatter(t,h,l);c.set(h,e),t.formatter=e}let d=r.get(t.type);null==d&&(d=new Map,r.set(t.type,d));const p=d.get(l);if(null!=p)t.value=p();else{const e=this.calcInitial(t,l);d.set(l,e),t.value=e()}}initDataTicker(t,e,i){const s=t.initial;let n=e.get(t.type);null==n&&(n=new Map,e.set(t.type,n));const o=n.get(s);if(void 0!==o)t.value=0,i.add(o()).add(t);else{const e=this.calcInitial(t,s);n.set(s,e),t.value=0,i.add(e()).add(t)}}initDataExtension(t,e){const i=ko.get(t.type);i&&(e.extended.add(i.id,t),t.value=i.initial)}initActions(t,e,i){const s=t.action.values,n=e.actions,o=Lo.get(t.type);if(null!=o)for(let t=0,i=o.length;t<i;++t){const i=o[t];n.push(i),e.reset|=i.reset}for(let t=0,o=s.length;t<o;++t){const o=s[t];let r=i.get(o);null==r?(r=o.toRuntime(),null!=r&&(i.set(o,r),n.push(r),e.reset|=r.reset)):(n.push(r),e.reset|=r.reset)}}calcFormatter(t,e,i){const s=this.toInitial(t);try{return Function("value",`try {return (${e});} catch( e1 ) {try {return (${0<i.length?i:s});} catch( e2 ) {return ${s};}}`)}catch(e){return this.toInitializer(t)}}calcInitial(t,e){if(e.length<=0)return this.toInitializer(t);try{return Function(`try {return (${e});} catch( e ) {return ${this.toInitial(t)};}`)}catch(e){return this.toInitializer(t)}}toInitial(t){switch(t.type){case zt.BOOLEAN:return"false";case zt.BOOLEAN_ARRAY:return No;case zt.NUMBER:return"0";case zt.NUMBER_ARRAY:return No;case zt.STRING:return'""';case zt.STRING_ARRAY:return No;case zt.OBJECT:return"{}";case zt.OBJECT_ARRAY:return No;case zt.TICKER:default:return"0"}}toInitializer(t){switch(t.type){case zt.BOOLEAN:return Fo;case zt.BOOLEAN_ARRAY:return Bo;case zt.NUMBER:return Po;case zt.NUMBER_ARRAY:return Bo;case zt.STRING:return zo;case zt.STRING_ARRAY:return Bo;case zt.OBJECT:return Uo;case zt.OBJECT_ARRAY:return Bo;case zt.TICKER:default:return Po}}onDestroy(){this._data.extended.each(t=>{const e=ko.getById(t);if(e){const t=e.stop;t&&t(this)}}),this._ticker.stop(),super.onDestroy()}hitTestInteractives(t){const e=this._layer.children;for(let i=e.length-1;0<=i;--i){const s=e[i];if(s.visible){const e=s.hitTestInteractives(t);if(null!=e)return e}}return null}onShapeMove(t){const e=this.hitTestInteractives(t.data.global);this.cursor=this._cursor=this.toShapeCursor(e);const i=ot.getLayer(this);if(i){const t=this.toShapeTitle(e),s=i.view;s.title!==t&&(s.title=t)}const s=this._overed;if(this._overed=e,e===s){if(null!=e){const i=e.runtime;i&&i.onMove(e,t)}}else this.onShapeOut(t,s,e),this.onShapeOver(t,e);return null!=e}toShapeCursor(t){if(null!=t){let e=t;for(;;){const t=e.cursor;if(null!=t&&0<t.length)return t;const i=e.parent;if(!(i instanceof kt))break;e=i}}return"auto"}toShapeTitle(t){if(null!=t){let e=t;for(;;){const t=e.title;if(null!=t&&0<t.length)return t;const i=e.parent;if(!(i instanceof kt))break;e=i}}return""}onShapeOut(t,e,i){for(;null!=e&&e!==i&&e instanceof kt;){const i=e.runtime;i&&i.onOut(e,t),e=e.parent}}onShapeOver(t,e,i){for(;null!=e&&e!==i&&e instanceof kt;){const i=e.runtime;i&&i.onOver(e,t),e=e.parent}}onShapeDown(t){const e=this.hitTestInteractives(t.data.global);if(this._downed=e,e){this._downeds.add(e);let i=e;for(;;){const e=i.runtime;e&&e.onDown(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeUp(t){const e=this._downeds,i=this.hitTestInteractives(t.data.global);if(i){e.delete(i);let s=i;for(;;){const e=s.runtime;e&&e.onUp(s,t);const i=s.parent;if(!(i instanceof kt))break;s=i}}return this.onShapeCancel(t),null!=i}onShapeCancel(t){const e=this._downeds;return 0<e.size&&(e.forEach(e=>{let i=e;for(;;){const e=i.runtime;e&&e.onUpOutside(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}}),e.clear(),!0)}onShapeClick(t){const e=this.hitTestInteractives(t.data.global);if(e&&this._downed===e){let i=e;for(;;){const e=i.runtime;e&&e.onClick(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeDblClick(e,i){var s;const n=null!==(s=Ho.WORK_DBLCLICK)&&void 0!==s?s:Ho.WORK_DBLCLICK=new t.Point;nn.toGlobal(e,i,n);const o=this.hitTestInteractives(n);if(o){let t=o;for(;;){const s=t.runtime;s&&s.onDblClick(t,e,i);const n=t.parent;if(!(n instanceof kt))break;t=n}return!0}return!1}onShapeRightClick(t){const e=this.hitTestInteractives(t.data.global);if(e&&this._downed===e){let i=e;for(;;){const e=i.runtime;e&&e.onRightClick(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeRightDown(t){const e=this.hitTestInteractives(t.data.global);if(this._downed=e,e){this._downeds.add(e);let i=e;for(;;){const e=i.runtime;e&&e.onRightDown(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}return!0}return!1}onShapeRightUp(t){const e=this._downeds,i=this.hitTestInteractives(t.data.global);if(i){e.delete(i);let s=i;for(;;){const e=s.runtime;e&&e.onRightUp(s,t);const i=s.parent;if(!(i instanceof kt))break;s=i}}return this.onShapeRightCancel(t),null!=i}onShapeRightCancel(t){const e=this._downeds;return 0<e.size&&(e.forEach(e=>{let i=e;for(;;){const e=i.runtime;e&&e.onRightUpOutside(i,t);const s=i.parent;if(!(s instanceof kt))break;i=s}}),e.clear(),!0)}update(){const t=this._actionables;if(0<t.length){let e=-1;const i=Date.now();for(let s=0,n=t.length;s<n;++s){const n=t[s];n.update(i);const o=n.runtime;if(o){const t=o.effect;0<=t&&i<t&&(e=e<0?t:Math.min(e,t))}}0<=e&&window.setTimeout(this._updateBound,e-Date.now())}}onRender(t){const e=this._actionables;if(0<e.length){let i=-1;const s=Date.now();for(let n=0,o=e.length;n<o;++n){const o=e[n];o.onRender(s,t);const r=o.runtime;if(r){const t=r.effect;0<=t&&s<t&&(i=i<0?t:Math.min(i,t))}}0<=i&&window.setTimeout(this._updateBound,i-Date.now())}}getType(){return"DDiagramCanvas"}}class Go extends t.utils.EventEmitter{constructor(t){super(),this._diagram=t,this._updateBound=()=>{ot.update(t)}}update(){const t=this._diagram.canvas;t&&t.update()}get(t){const e=this._diagram.canvas;return e?e.shape.get(t):null}getAll(t){const e=this._diagram.canvas;return e?e.shape.getAll(t):[]}each(t,e=!1){const i=this._diagram.canvas;if(null!=i){const s=i.layer.children;if(e)for(let e=s.length-1;0<=e;--e){const i=s[e].children;for(let e=i.length-1;0<=e;--e){const s=i[e];if(!1===t(s))return s}}else for(let e=0,i=s.length;e<i;++e){const i=s[e].children;for(let e=0,s=i.length;e<s;++e){const s=i[e];if(!1===t(s))return s}}}return null}}class Vo{constructor(t){this._diagram=t}get ids(){const t=this._diagram.canvas;return null!=t?t.data.private.ids:[]}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.private.set(t,e,i,s,n,o)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.private.toDirty(t)}each(t){const e=this._diagram.canvas;return null!=e?e.data.private.each(t):null}}class Wo{constructor(t){this._diagram=t}get ids(){const t=this._diagram.canvas;return null!=t?t.data.protected.ids:[]}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.protected.set(t,e,i,s,n,o)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.protected.toDirty(t)}each(t){const e=this._diagram.canvas;return null!=e?e.data.protected.each(t):null}}class Ko{constructor(t){this._controller=t&&t.controller}set(t,e){const i=this._controller;return!!i&&(i.write(t,e),!0)}}class Xo{constructor(t){this._diagram=t}get ids(){const t=this._diagram.canvas;return null!=t?t.data.extended.ids:[]}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.extended.set(t,e,i,s,n,o)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.extended.toDirty(t)}each(t){const e=this._diagram.canvas;return null!=e?e.data.extended.each(t):null}}class Yo{constructor(t,e){this._diagram=t,this._mapper=e&&e.mapper||null,this._remote=new Ko(e&&e.remote),this._private=new Vo(t),this._protected=new Wo(t),this._extended=new Xo(t)}update(){}get mapper(){return this._mapper}set mapper(t){this._mapper=t}get remote(){return this._remote}get private(){return this._private}get protected(){return this._protected}get extended(){return this._extended}get ids(){const t=this._diagram.canvas;return t?t.data.ids:[]}each(t){const e=this._diagram.canvas;return null!=e?e.data.each(t):null}set(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.set(t,e,i,s,n,o)}get(t){const e=this._diagram.canvas;return null!=e?e.data.get(t):null}clear(t){const e=this._diagram.canvas;return null!=e&&e.data.clear(t)}toDirty(t){const e=this._diagram.canvas;return null!=e&&e.data.toDirty(t)}setAll(t,e,i,s,n,o){const r=this._diagram.canvas;return null!=r&&r.data.setAll(t,e,i,s,n,o)}setValue(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setValue(t,e)}setValues(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setValues(t,e)}setTime(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setTime(t,e)}setTimes(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setTimes(t,e)}setState(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setState(t,e)}setStates(t,e){const i=this._diagram.canvas;return null!=i&&i.data.setStates(t,e)}setRange(t,e,i){const s=this._diagram.canvas;return null!=s&&s.data.setRange(t,e,i)}}class jo extends go{constructor(t){super(t),this.on(nn.move,t=>{this.onShapeMove(t)}),this.on(nn.up,t=>{this.onShapeUp(t)}),this.on(nn.upoutside,t=>{this.onShapeCancel(t)}),this.on(nn.cancel,t=>{this.onShapeCancel(t)}),this.on(nn.tap,t=>{this.onShapeClick(t)}),this.on(nn.righttap,t=>{this.onShapeRightClick(t)}),this.on(nn.rightdown,t=>{this.onShapeRightDown(t)}),this.on(nn.rightup,t=>{this.onShapeRightUp(t)}),this.on(nn.rightupoutside,t=>{this.onShapeRightCancel(t)});const e=new Yo(this,t&&(t.data||t.tag));this.data=e,this.tag=e,this.shape=new Go(this)}initLayer(t,e,i){return super.initLayer(t,e,i||this.data.mapper)}toMode(t){return Li.VIEWER}newCanvas(t){return new Ho(this.toCanvasOptions(t))}toCanvasOptions(t){return this.toCanvasBaseOptions(t)}onDown(t){const e=this.canvas;if(e){const i=t.target;i===this||i===e?super.onDown(t,e.onShapeDown(t)):super.onDown(t)}else super.onDown(t)}onShapeMove(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeMove(t)}}onShapeUp(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeUp(t)}}onShapeCancel(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeCancel(t)}}onShapeClick(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeClick(t)}}onShapeRightClick(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightClick(t)}}onShapeRightDown(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightDown(t)}}onShapeRightUp(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightUp(t)}}onShapeRightCancel(t){const e=this.canvas;if(e){const i=t.target;i!==this&&i!==e||e.onShapeRightCancel(t)}}onDblClick(t,e){const i=this.canvas;return i?super.onDblClick(t,e,i.onShapeDblClick(t,e)):super.onDblClick(t,e)}onPrerender(t){const e=this._canvas;e&&e.onRender(t)}render(t){var e;const i=this._rendererBound;if(i!==t){const s=null!==(e=this._onPrerenderBound)&&void 0!==e?e:this._onPrerenderBound=t=>{this.onPrerender(t)};null!=i&&i.off("prerender",s),this._rendererBound=t,null!=t&&(t.on("prerender",s),null!=this._canvas&&ot.update(this))}super.render(t)}destroy(){const t=this._rendererBound;if(null!=t){this._rendererBound=void 0;const e=this._onPrerenderBound;null!=e&&t.off("prerender",e)}super.destroy()}getType(){return"DDiagram"}}class $o{static isDiagram(t){return t instanceof jo}static isEmbedded(t){return t instanceof Yi}static toDiagram(t){let e=t;for(;null!=e;){if(this.isDiagram(e))return e;e=e.parent}return null}static open(t,e,i,s,n){const o=yn[e];if(null!=o){const e=this.toDiagram(t);e&&o(i,s,t,e,n)}else if(Et(i))switch(e){case Ri.DIAGRAM:const e=this.toDiagram(t);if(e){const t=e.controller;t&&t.getByName(i).then(t=>{e.set(En.toSerialized(t))})}break;case Ri.PAGE:s?window.open(i):window.location.href=i}}static writeLocal(t,e,i,s,n=Ft.FOUND){var o;let r=t;for(;null!=r;){if(this.isDiagram(r))return(r.data.private.set(e,i,s,n)||r.data.protected.set(e,i,s,n)||!!r.data.set(e,i,s,n))&&(ot.update(r),!0);if(this.isEmbedded(r)&&(null===(o=r.data.getPrivate())||void 0===o?void 0:o.set(e,i,s,n)))return ot.update(r),!0;r=r.parent}return!1}static writeRemote(t,e,i){const s=this.toDiagram(t);return!!s&&s.data.remote.set(e,i)}static emit(t,e,i,s){const n=$o.toDiagram(t);void 0===s?(t.emit(e,t),n&&n.shape.emit(e,t)):(t.emit(e,i,s,t),n&&n.shape.emit(e,i,s,t))}}class qo extends ve{constructor(t){super(t,pe.NONE),this.name=fe.ofStringOrNull(t.name)}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.name(t,i,ge);null!=e&&$o.emit(t,e)}}}class Zo extends be{constructor(t,e){super(Oe.EMIT_EVENT,t),this.name=e}isEquals(t){return super.isEquals(t)&&t instanceof Zo&&this.name===t.name}toRuntime(){return new qo(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.name);return t.addResource(`[${this.type},${e},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(2,t,e.resources);return new Zo(i,s)}}class Jo extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target)}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.target(t,i,ge);null!=e&&$o.emit(t,e)}}}const Qo={NO_POINTER_EVENTS:"NO_POINTER_EVENTS"};class tr{constructor(t){const e="http://www.w3.org/2000/svg",i=document.createElementNS(e,"svg");i.setAttribute("style","position: absolute;"),i.setAttribute("width","0px"),i.setAttribute("height","0px");const s=document.createElementNS(e,"defs"),n=document.createElementNS(e,"clipPath"),o="clipper_ex_"+Math.random().toString(32).substring(2);n.setAttribute("id",o),n.setAttribute("clipPathUnits","objectBoundingBox");const r=document.createElementNS(e,"path");this._path=r,this._pathD="",r.setAttribute("clip-rule","evenodd"),n.appendChild(r),s.appendChild(n),i.appendChild(s),this._id=o,t.appendChild(i)}get id(){return this._id}update(t,e,i){const s=this.toD(t,e,i);this._pathD!=s&&(this._path.setAttribute("d",s),this._pathD=s)}toD(e,i,s){var n,o;if(null==e)return"";const r=e.width,a=e.height,h=1e-4;if(r<h||a<h)return"";if(s.size<=0)return"M0,0 h1 v1 h-1z";const l=null!==(n=tr.WORK_MATRIX)&&void 0!==n?n:tr.WORK_MATRIX=new t.Matrix;null!=i?(l.copyFrom(i),l.invert()):l.identity(),l.translate(-e.x,-e.y),l.scale(1/r,1/a);let c=-1,u=2,d=-1,p=2,_="";const g=l.a,f=l.b,m=l.c,v=l.d,T=l.tx,w=l.ty,E=null!==(o=tr.WORK_RECTS)&&void 0!==o?o:tr.WORK_RECTS=[],y=this.toRects(s,E);for(let t=0;t<y;t+=4){const e=E[t+0],i=E[t+1],s=E[t+2],n=E[t+3],o=g*e+m*i+T,r=f*e+v*i+w,a=g*s+m*i+T,h=f*s+v*i+w,l=g*s+m*n+T,y=f*s+v*n+w,x=g*e+m*n+T,C=f*e+v*n+w;c=Math.min(c,o,a,l,x),u=Math.max(u,o,a,l,x),d=Math.min(d,r,h,y,C),p=Math.max(p,r,h,y,C),_+=` M${o.toFixed(5)},${r.toFixed(5)} L${a.toFixed(5)},${h.toFixed(5)} L${l.toFixed(5)},${y.toFixed(5)} L${x.toFixed(5)},${C.toFixed(5)}Z`}return`M${c},${d} L${u},${d} L${u},${p} L${c},${p}Z`+_}toRects(t,e){const i=t.data;let s=t.size<<2;for(let t=0;t<s;t+=4){const s=i[t+0],n=i[t+1],o=i[t+2],r=i[t+3];s<o?(e[t+0]=s,e[t+2]=o):(e[t+0]=o,e[t+2]=s),n<r?(e[t+1]=n,e[t+3]=r):(e[t+1]=r,e[t+3]=n)}for(let t=4;t<s;t+=4){let i=e[t+0],n=e[t+1],o=e[t+2],r=e[t+3];for(let a=0;a<t;a+=4){const h=e[a+0],l=e[a+1],c=e[a+2],u=e[a+3];let d=0,p=0;if(i<=h)if(o<=c){if(o<=h)continue;d=2,p=1}else p=3;else if(o<=c)d=3;else{if(c<=i)continue;d=1,p=2}let _=0,g=0;if(n<=l)if(r<=u){if(r<=l)continue;_=2,g=1}else g=3;else if(r<=u)_=3;else{if(u<=n)continue;_=1,g=2}let f=0;if(f=0===d||0===_?0:1===d||2===d?3===_?2:1:3===_?4:2,4===f){t+4<s&&(e[t+0]=e[s+0],e[t+1]=e[s+1],e[t+2]=e[s+2],e[t+3]=e[s+3]),t-=4,s-=4;break}let m=0;if(m=0===p||0===g?0:1===p||2===p?3===g?2:1:3===g?4:2,4!==m)if(0===f)if(0===m){for(let t=s-4;a<t;t-=4)e[t+4]=e[t+0],e[t+5]=e[t+1],e[t+6]=e[t+2],e[t+7]=e[t+3];0===p?(e[a+3]=n,e[a+4]=h,e[a+5]=r,e[a+6]=c,e[a+7]=u):(e[a+2]=i,e[a+4]=o,e[a+5]=l,e[a+6]=c,e[a+7]=u),t+=4,s+=4,a+=4}else 2===m&&(1===p?e[a+0]=o:2===p?e[a+2]=i:1===g?e[a+1]=r:2===g&&(e[a+3]=n));else if(1===f){for(let t=s-4;a<t;t-=4)e[t+4]=e[t+0],e[t+5]=e[t+1],e[t+6]=e[t+2],e[t+7]=e[t+3];1===p?1===g?(e[a+0]=o,e[a+4]=h,e[a+5]=r,e[a+6]=o,e[a+7]=u):(e[a+0]=o,e[a+4]=h,e[a+5]=l,e[a+6]=o,e[a+7]=n):1===g?(e[a+2]=i,e[a+4]=i,e[a+5]=r,e[a+6]=c,e[a+7]=u):(e[a+2]=i,e[a+4]=i,e[a+5]=l,e[a+6]=c,e[a+7]=n),t+=4,s+=4,a+=4}else 2===f&&(1===d?(e[t+0]=c,i=c):2===d?(e[t+2]=h,o=h):1===_?(e[t+1]=u,n=u):2===_&&(e[t+3]=l,r=l));else{for(let t=a+4;t<s;t+=4)e[t-4]=e[t+0],e[t-3]=e[t+1],e[t-2]=e[t+2],e[t-1]=e[t+3];t-=4,s-=4,a-=4}}}return s}}class er{constructor(){this._data=[],this._size=0,this._index=0,this._isDirty=!0}get data(){return this._data}get size(){return this._size}isDirty(){return this._isDirty}toClean(){this._isDirty=!1}begin(){return this._index=0,this}end(){const t=this._index;this._size=t;const e=this._data,i=t<<2;return e.length!==i&&(e.length=i,this._isDirty=!0),this}add(t,e,i,s){const n=this._index<<2;this._index+=1;const o=this._data;return n<o.length?o[n+0]===t&&o[n+1]===e&&o[n+2]===i&&o[n+3]===s||(o[n+0]=t,o[n+1]=e,o[n+2]=i,o[n+3]=s,this._isDirty=!0):(o.push(t,e,i,s),this._isDirty=!0),this}}const ir={CLICKED:0,DOUBLE_CLICKED:1,FOCUSED:2,ALWAYS:3};class sr{constructor(t,e,i,s){this._target=t,this._operation=e;const n=this.toData(i,s);this._data=n,this._isElementShown=!1,this._onElementFocusBound=t=>{this.onElementFocus(t)},this._onBeforeFocusBound=t=>{this.onBeforeFocus(t)},this._onAfterFocusBound=t=>{this.onAfterFocus(t)},this._isStarted=!1,this._wasStarted=!1,this._doSelectBound=()=>{this.doSelect()},this._isStartRequested=this._data.when===ir.ALWAYS,this._onPostRenderBound=()=>{this.updateElement(this._rendererBound)}}toData(t,e){var i,s;return{element:this.toElementData(t,null==e?void 0:e.element),clipper:this.toClipperData(t,null==e?void 0:e.clipper),before:this.toBeforeData(t,null==e?void 0:e.before),after:this.toAfterData(t,null==e?void 0:e.after),when:Qi(null!==(i=null==e?void 0:e.when)&&void 0!==i?i:t.getWhen(),ir),select:null!==(s=null==e?void 0:e.select)&&void 0!==s?s:t.getSelect()}}toElementData(t,e){var i,s;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getElementCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newElementStyler(t)}}newElementStyler(t){return(e,i,s,n,o,r,a)=>t.setElementStyle(e,i,s,n,o,r,a)}toClipperData(t,e){var i,s,n;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getClipperCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newClipperStyler(t),extended:null!==(n=null==e?void 0:e.extended)&&void 0!==n?n:t.isClipperExEnabled()}}newClipperStyler(t){return(e,i,s,n,o,r,a)=>t.setClipperStyle(e,i,s,n,o,r,a)}toBeforeData(t,e){var i,s;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getBeforeCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newBeforeStyler(t)}}newBeforeStyler(t){return e=>{t.setBeforeStyle(e)}}toAfterData(t,e){var i,s;return{creator:null!==(i=null==e?void 0:e.creator)&&void 0!==i?i:t.getAfterCreator(),styler:null!==(s=null==e?void 0:e.styler)&&void 0!==s?s:this.newAfterStyler(t)}}newAfterStyler(t){return e=>{t.setAfterStyle(e)}}get element(){var t;return null!==(t=this._element)&&void 0!==t?t:null}get when(){return this._data.when}onDowning(t){switch(this._wasStarted=this._isStarted,this.when){case ir.CLICKED:this.start();break;case ir.FOCUSED:this._target.state.isFocused&&this.start()}}onDown(t){!this._wasStarted&&this._isStarted&&("data"in t?t.data.originalEvent.preventDefault():t.preventDefault())}onDblClick(t,e){switch(this.when){case ir.DOUBLE_CLICKED:this.start()}}onFocus(){var t;switch(this.when){case ir.FOCUSED:this.start();break;default:null===(t=this._element)||void 0===t||t.focus()}}onBlur(){var t;switch(this.when){case ir.CLICKED:case ir.DOUBLE_CLICKED:case ir.FOCUSED:this.onEndByBlur(),this.cancel();break;default:null===(t=this._element)||void 0===t||t.blur()}}isStartable(){switch(this.when){case ir.CLICKED:case ir.DOUBLE_CLICKED:case ir.FOCUSED:return this._target.state.isActionable;default:return!0}}start(){!this._isStarted&&this.isStartable()&&(this._isStarted=!0,this._target.worldVisible?this.doStart():this._isStartRequested=!0,ot.update(this._target))}isShown(){return this._isElementShown}onRender(t){(this._isStartRequested||!this._isElementShown&&this.when===ir.ALWAYS)&&(this._isStartRequested=!1,this.doStart(t)),this._isStarted&&(this._isStarted=!1)}getElementRect(e){const i=this._point||new t.Point(0,0);this._point=i;const s=this._elementRectResult||new t.Rectangle;return this._elementRectResult=s,this._operation.getElementRect(e,i,s)}getElementMatrix(){return this._operation.getElementMatrix()}getClipperRect(e){const i=this._point||new t.Point(0,0);this._point=i;const s=this._clipperRectResult||new t.Rectangle;return this._clipperRectResult=s,this._operation.getClipperRect(e,i,s)}fillClipperExRects(t,e){const i=this._operation;return i.getClipperExRects&&i.getClipperExRects(e),e.isDirty()}doStart(t){var e,i;if(!this._isElementShown){this._isElementShown=!0;const s=this._rendererBound;null!=s&&(this._rendererBound=void 0,s.off("postrender",this._onPostRenderBound));const n=this._target;null==t&&(t=null===(e=ot.getLayer(n))||void 0===e?void 0:e.renderer),t&&(this._rendererBound=t,t.on("postrender",this._onPostRenderBound)),this.onStart();const o=this.getClipper();if(o){const e=this.getBefore(o),s=this.getElement(o),r=this.getAfter(o),a=this.getClipperEx(o);if(s){const h=null!==(i=null==t?void 0:t.resolution)&&void 0!==i?i:ot.getResolution(n),l=this.getElementRect(h),c=this.getElementMatrix(),u=this.toClipperRectAdjusted(l,c,this.getClipperRect(h)),d=n.state,p=this._operation.getPadding(),_=this._data;if(_.clipper.styler(o,d,p,l,c,u,a),_.element.styler(s,d,p,l,c,u,a),e&&_.before.styler(e),r&&_.after.styler(r),this.onElementAttached(s,e,r),a){const t=this.getClipperExRects();t&&this.fillClipperExRects(h,t)&&(a.update(l,c,t),t.toClean())}o.style.display="",d.isFocused&&this.toElementFocused(s),o.scrollTop=0,o.scrollLeft=0,this._data.select&&setTimeout(this._doSelectBound,0)}}}}toElementFocused(t){t.focus({preventScroll:!0})}onStart(){this._operation.onStart()}doSelect(){const t=this._element;t&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.select()}cancel(){var t;if(this._isElementShown){this._isElementShown=!1;const e=this._rendererBound;null!=e&&(this._rendererBound=void 0,e.off("postrender",this._onPostRenderBound)),this.onCancel();const i=this._target,s=ot.getLayer(i);if(s){const e=s.view;switch(this.when){case ir.CLICKED:case ir.DOUBLE_CLICKED:case ir.FOCUSED:document.activeElement===this._element&&e.focus()}const n=i.state,o=s.renderer.plugins.interaction;this._operation.containsPoint(o.mouse.global)&&!n.isHovered&&(n.isHovered=!0,e.style.cursor=null!==(t=i.cursor)&&void 0!==t?t:""),s.update()}const n=this._element;null!=n&&this.onElementDetached(n,this._before,this._after);const o=this._clipper;null!=o&&(o.style.display="none")}}onCancel(){this._operation.onCancel()}onElementAttached(t,e,i){null==e||e.addEventListener("focus",this._onBeforeFocusBound),null==i||i.addEventListener("focus",this._onAfterFocusBound),t.addEventListener("focus",this._onElementFocusBound,!0)}onElementDetached(t,e,i){null==e||e.removeEventListener("focus",this._onBeforeFocusBound),null==i||i.removeEventListener("focus",this._onAfterFocusBound),t.removeEventListener("focus",this._onElementFocusBound,!0)}getClipper(){let t=this._clipper;if(null==t){const e=ot.getLayer(this._target);t=e?this._data.clipper.creator(e.getElementContainer()):null,this._clipper=t}return t}getClipperEx(t){let e=this._clipperEx;return void 0===e&&(e=null!=this.getClipperExRects()?new tr(t):null,this._clipperEx=e),e}getClipperExRects(){let t=this._clipperExRects;return void 0===t&&(t=this._data.clipper.extended?new er:null,this._clipperExRects=t),t}getElement(t){let e=this._element;return null==e&&(e=this._data.element.creator(t),this._element=e),e}getBefore(t){let e=this._before;return null==e&&(e=this._data.before.creator(t),this._before=e),e}getAfter(t){let e=this._after;return null==e&&(e=this._data.after.creator(t),this._after=e),e}onBeforeFocus(t){const e=this._target,i=ot.getLayer(e);if(i){const s=i.getFocusController(),n=s.find(e,!1,!1,!1);i.view.focus(),s.focus(n),t.preventDefault(),t.stopImmediatePropagation()}}onAfterFocus(t){const e=this._target,i=ot.getLayer(e);if(i){const s=i.getFocusController(),n=s.find(e,!1,!1,!0);i.view.focus(),s.focus(n),t.preventDefault(),t.stopImmediatePropagation()}}onElementFocus(t){if(this.when===ir.ALWAYS){const t=this._target;t.state.isFocused||t.focus()}}onEndByBlur(){this.onEnd()}onEnd(){this._operation.onEnd()}end(){this.onEnd(),this.cancel()}select(){return this._isElementShown&&this._data.select&&this.doSelect(),this}toClipperRectAdjusted(t,e,i){if(i&&t&&null==e){const e=t.x,s=t.y,n=e+t.width,o=s+t.height,r=i.x,a=i.y,h=r+i.width,l=a+i.height,c=Math.min(Math.max(r,e),h),u=Math.min(Math.max(r,n),h),d=Math.min(Math.max(a,s),l),p=Math.min(Math.max(a,o),l);i.x=c,i.y=d,i.width=u-c,i.height=p-d}return i}updateElement(t){if(this._isElementShown){const e=this._target;if(e.worldVisible){const i=this._element,s=this._clipper,n=this._clipperEx;if(i&&s){const o=t.resolution,r=this.getElementRect(o),a=this.getElementMatrix(),h=this.toClipperRectAdjusted(r,a,this.getClipperRect(o)),l=e.state,c=this._operation.getPadding(),u=this._data;if(u.clipper.styler(s,l,c,r,a,h,n),u.element.styler(i,l,c,r,a,h,n),n){const t=this.getClipperExRects();t&&this.fillClipperExRects(o,t)&&(n.update(r,a,t),t.toClean())}}}else switch(this.when){case ir.ALWAYS:const t=this._clipper;t&&(t.style.display="none");break;default:this.cancel()}}}static getClipperRect(t,e,i,s,n){let o=!0,r=0,a=0,h=0,l=0,c=t;for(;c instanceof to;){c.getClippingRect(e,n),s.set(n.x,n.y),c.toGlobal(s,s,!1);const t=(s.x*i|0)/i,u=(s.y*i|0)/i;s.set(n.x+n.width,n.y+n.height),c.toGlobal(s,s,!0);const d=s.x,p=s.y,_=Math.min(t,d),g=Math.min(u,p),f=Math.max(t,d),m=Math.max(u,p);o?(o=!1,r=_,a=g,h=f,l=m):(r=Math.min(Math.max(r,_),f),a=Math.min(Math.max(a,g),m),h=Math.min(Math.max(h,_),f),l=Math.min(Math.max(l,g),m)),c=c.parent}return o?null:(n.x=r,n.y=a,n.width=h-r,n.height=l-a,n)}}let nr=!1;const or=()=>nr;class rr extends me{constructor(t){super(),this.condition=fe.ofString(t.condition),this.utils=new Map}getUtil(t,e){const i=this.utils;let s=i.get(t);return null==s&&(s=this.newUtil(t,e),i.set(t,s)),s}newUtil(t,e){return new sr(t,this.newOperation(t,e),$.getInstance().get("DHtmlElement"),this.newUtilOptions(t,e))}newOperation(t,e){return{getElementRect:(i,s,n)=>this.getElementRect(t,e,i,s,n),getElementMatrix:()=>this.getElementMatrix(t,e),getClipperRect:(i,s,n)=>this.getClipperToRect(t,e,i,s,n),getClipperExRects:e=>{this.getClipperExRects(t,e)},getPadding:()=>this.getPadding(t,e),containsPoint:i=>this.containsPoint(t,e,i),onStart:()=>{},onCancel:()=>{},onEnd:()=>{}}}newUtilOptions(t,e){return{element:{creator:this.newElementCreator(t,e)},when:this.toWhen(t,e),clipper:{extended:or()}}}toWhen(t,e){const i=this.condition(t,Date.now(),ge);if(null!=i&&i in ir)return ir[i]}containsPoint(e,i,s){var n;if(e.visible){const i=null!==(n=rr.WORK)&&void 0!==n?n:rr.WORK=new t.Point;return e.toLocal(s,void 0,i),null!=e.contains(i.x,i.y)}return!1}getPadding(t,e){return null}getElementRect(t,e,i,s,n){const o=t.transform.pivot,r=t.size,a=r.x,h=r.y;return n.x=-.5*a+o.x,n.y=-.5*h+o.y,n.width=a,n.height=h,n}getElementMatrix(t,e){return t.updateTransform(),t.transform.worldTransform}getClipperToRect(t,e,i,s,n){const o=$o.toDiagram(t);return sr.getClipperRect(o,t,i,s,n)}getClipperExRects(t,e){e.begin();const i=t.root.parent;if(i instanceof Co){const t=i.parent;if(null!=t){const s=t.children,n=s.indexOf(i);if(0<=n)for(let t=n+1,i=s.length;t<i;++t){const i=s[t];if(i.visible){const t=i.width,s=i.height,n=i.transform.worldTransform,o=n.a,r=n.b,a=n.c,h=n.d,l=n.tx,c=n.ty;e.add(l,c,o*t+a*s+l,r*t+h*s+c)}}}}e.end()}onRender(t,e,i,s){this.getUtil(t,e).onRender(s)}onFocus(t,e){this.getUtil(t,e).onFocus()}onBlur(t,e){this.getUtil(t,e).onBlur()}onDowning(t,e,i){this.getUtil(t,e).onDowning(i)}onDown(t,e,i){this.getUtil(t,e).onDown(i)}onDblClick(t,e,i,s){this.getUtil(t,e).onDblClick(i,s)}}class ar extends rr{constructor(t){super(t),this.elementCreator=fe.ofElementOrNull(t.value),this.noPointerEvent=t.subtype===fn.HTML_ELEMENT_WITHOUT_POINTER_EVENTS}newUtil(t,e){return this.noPointerEvent&&t.state.add(Qo.NO_POINTER_EVENTS),super.newUtil(t,e)}newElementCreator(t,e){const i=this.elementCreator;if(i)return e=>i(t,Date.now(),ge,e)}}class hr extends sr{constructor(t,e,i,s){var n,o,r,a,h,l;super(t,e,i,s),this._operation=e,this._onInputKeyDownBound=t=>{this.onInputKeyDown(t)},this._onInputChangeBound=()=>{this.onInputChange()},this._onInputInputBound=t=>{this.onInputInput(t)},this._description=null!==(n=null==s?void 0:s.description)&&void 0!==n?n:"";const c=null==s?void 0:s.editing;this._editingFormatter=null!==(a=null!==(o=null==c?void 0:c.formatter)&&void 0!==o?o:null===(r=null==s?void 0:s.text)||void 0===r?void 0:r.formatter)&&void 0!==a?a:i.getEditingFormatter(),this._editingUnformatter=null!==(h=null==c?void 0:c.unformatter)&&void 0!==h?h:i.getEditingUnformatter(),this._editingValidator=null!==(l=null==c?void 0:c.validator)&&void 0!==l?l:i.getEditingValidator()}onEnd(){super.onEnd(),this.onInputChange()}onElementAttached(t,e,i){t.value=this.fromValue(this._operation.getValue()),t.addEventListener("change",this._onInputChangeBound),t.addEventListener("input",this._onInputInputBound),super.onElementAttached(t,e,i)}onElementDetached(t,e,i){super.onElementDetached(t,e,i),t.removeEventListener("change",this._onInputChangeBound),t.removeEventListener("input",this._onInputInputBound)}onInputKeyDown(t){$n.isOkKey(t)?(this.end(),this._operation.onEnter()):$n.isCancelKey(t)&&this.cancel()}toElementFocused(t){super.toElementFocused(t),t.scrollTop=0,t.scrollLeft=0}onInputChange(){if(this.isShown()){const t=this.element;if(null!=t){const e=this._operation,i=this.toValue(t.value),s=e.getValue();s!==i&&e.onValueChange(i,s)}}}toValue(t){return this._editingUnformatter(t,this)}fromValue(t){return void 0!==t?this._editingFormatter(t,this):""}onInputInput(t){const e=t.target;(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&this._operation.onValueInput(this.toValue(e.value))}validate(){const t=this._operation.getValue();if(void 0!==t){const e=this._editingValidator(t,this);if(this._editingValidationResult!==e){this._editingValidationResult=e;const t=this._target.state;t.isInvalid=null!=e,t.isHovered&&this._operation.applyTitle()}return e}return null}applyTitle(){const t=this._editingValidationResult;if(Et(t)){const e=ot.getLayer(this._target);return e&&(e.view.title=t),!0}return!1}}class lr extends hr{onElementAttached(t,e,i){t.addEventListener("keydown",this._onInputKeyDownBound),super.onElementAttached(t,e,i)}onElementDetached(t,e,i){t.removeEventListener("keydown",this._onInputKeyDownBound),super.onElementDetached(t,e,i)}}class cr extends lr{constructor(t,e,i,s){var n,o,r;super(t,e,i,s),this._step=null!==(n=null==s?void 0:s.step)&&void 0!==n?n:i.getStep(),this._min=null!==(o=null==s?void 0:s.min)&&void 0!==o?o:i.getMin(),this._max=null!==(r=null==s?void 0:s.max)&&void 0!==r?r:i.getMax()}get step(){return this._step}set step(t){this._step!==t&&(this._step=t,this.onStepChange())}get min(){return this._min}set min(t){this._min!==t&&(this._min=t,this.onMinChange())}get max(){return this._max}set max(t){this._max!==t&&(this._max=t,this.onMaxChange())}toValue(t){const e=super.toValue(t);if(e==e){const t=this._min;if(null!=t&&e<t)return t;const i=this._max;return null!=i&&i<e?i:e}return 0}fromValue(t){return void 0!==t?this._editingFormatter(t,this):"0"}onStepChange(){if(this.isShown()){const t=this.element;t&&this.updateStep(t)}}onMinChange(){if(this.isShown()){const t=this.element;t&&this.updateMin(t)}}onMaxChange(){if(this.isShown()){const t=this.element;t&&this.updateMax(t)}}updateStep(t){const e=this.step;t.step=null!=e?""+e:"any"}updateMin(t){const e=this.min;null!=e?t.min=""+e:t.removeAttribute("min")}updateMax(t){const e=this.max;null!=e?t.max=""+e:t.removeAttribute("max")}onElementAttached(t,e,i){t.type="number",super.onElementAttached(t,e,i),this.updateStep(t),this.updateMin(t),this.updateMax(t)}}const ur={EMIT_EVENT:0,WRITE_BOTH:1,WRITE_LOCAL:2,WRITE_REMOTE:3};class dr{static execute(t,e,i,s,n){switch(e){case ur.EMIT_EVENT:t.emit(i,t,s),$o.emit(t,i,s,n);break;case ur.WRITE_LOCAL:$o.writeLocal(t,i,s,n);break;case ur.WRITE_REMOTE:$o.writeRemote(t,i,s);break;case ur.WRITE_BOTH:$o.writeLocal(t,i,s,n),$o.writeRemote(t,i,s)}}}class pr extends rr{constructor(t){super(t),this.target=fe.ofStringOrNull(t.target),this.onInputAction=t.onInputAction}newOperation(t,e){return{getElementRect:(i,s,n)=>this.getElementRect(t,e,i,s,n),getElementMatrix:()=>this.getElementMatrix(t,e),getClipperRect:(i,s,n)=>this.getClipperToRect(t,e,i,s,n),getClipperExRects:e=>{this.getClipperExRects(t,e)},getPadding:()=>this.getPadding(t,e),containsPoint:i=>this.containsPoint(t,e,i),onStart:()=>{t.text.enable=!1},onCancel:()=>{t.text.enable=!0},onEnd:()=>{},getValue:()=>this.getUtil(t,e).toValue(t.text.value),onValueInput:t=>{},onValueChange:(i,s)=>{this.onValueChange(t,e,i,s)},onEnter:()=>{},applyTitle:()=>{}}}newElementCreator(t,e){}getPadding(t,e){return t.text.padding}onValueChange(t,e,i,s){t.text.value=this.getUtil(t,e).fromValue(i);const n=Date.now(),o=this.target(t,n,ge);null!=o&&dr.execute(t,this.onInputAction,o,i,n)}}class _r extends pr{}class gr extends _r{}class fr extends gr{newUtil(t,e){return new cr(t,this.newOperation(t,e),$.getInstance().get("DInputInteger"),this.newUtilOptions(t,e))}}class mr extends gr{newUtil(t,e){return new cr(t,this.newOperation(t,e),$.getInstance().get("DInputReal"),this.newUtilOptions(t,e))}}class vr extends lr{onElementAttached(t,e,i){t.type="text",super.onElementAttached(t,e,i)}}class Tr extends _r{newUtil(t,e){return new vr(t,this.newOperation(t,e),$.getInstance().get("DInputText"),this.newUtilOptions(t,e))}}class wr extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target),this.value=fe.ofUnknown(t.value)}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.target(t,i,ge);null!=e&&this.write(t,e,this.value(t,i,ge),i)}}}class Er extends wr{write(t,e,i,s){$o.writeLocal(t,e,i,s),$o.writeRemote(t,e,i)}}class yr extends wr{write(t,e,i,s){$o.writeLocal(t,e,i,s)}}class xr extends wr{write(t,e,i,s){$o.writeRemote(t,e,i)}}class Cr extends Ie{constructor(t,e,i,s,n){super(Oe.MISC,e,t),this.target=i,this.onInputAction=s,this.value=n}toRuntime(){switch(this.subtype){case fn.INPUT_TEXT:return new Tr(this);case fn.INPUT_INTEGER:return new fr(this);case fn.INPUT_REAL:return new mr(this);case fn.EMIT_EVENT:return new Jo(this);case fn.WRITE_BOTH:return new Er(this);case fn.WRITE_LOCAL:return new yr(this);case fn.WRITE_REMOTE:return new xr(this);case fn.HTML_ELEMENT:case fn.HTML_ELEMENT_WITHOUT_POINTER_EVENTS:return new ar(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=t.addResource(this.value);return t.addResource(`[${this.type},${e},${this.subtype},${i},${this.onInputAction},${s}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i),o=Ae.toResource(5,t,i);return new Cr(t[2],s,n,t[4],o)}}class Dr extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofUnknown(t.target)}execute(t,e,i){this.condition(t,i,ge)&&this.target(t,i,ge)}}class Sr extends Ie{constructor(t,e){super(Oe.MISC,t,fn.EXECUTE),this.target=e}toRuntime(){return new Dr(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target);return t.addResource(`[${this.type},${e},${this.subtype},${i}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i);return new Sr(s,n)}}class br{static add(t){var e,i;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._data)&&void 0!==i?i:this._data=[]).push(t)}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Ir extends ve{constructor(t){super(t,pe.NONE),this.argument=fe.ofUnknown(t.argument),this.extension=br.get(t.subtype)}execute(t,e,i){const s=this.extension;if(null!=s&&this.condition(t,i,ge)){const e=$o.toDiagram(t);null!=e&&s.executor(this.argument(t,i,ge),t,e,ge)}}}class Or extends Ie{constructor(t,e,i){super(Oe.MISC,e,t),this.argument=i}toRuntime(){return new Ir(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.argument);return t.addResource(`[${this.type},${e},${this.subtype},${i}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i);return new Or(t[2],s,n)}}class Ar extends ve{constructor(t,e){super(t,pe.NONE),this.subtype=e,this.target=fe.ofUnknown(t.target),this.inNewWindow=t.inNewWindow}execute(t,e,i){if(this.condition(t,i,ge)){const e=this.target(t,i,ge);null!=e&&$o.open(t,this.subtype,e,this.inNewWindow,ge)}}}const Rr={DIAGRAM_LEGACY:0,PAGE_LEGACY:1,PAGE_INPLACE_LEGACY:2,DIALOG_TEXT:3,DIALOG_INTEGER:4,DIALOG_REAL:5,DIALOG_BOOLEAN:6,DIALOG_DATE:7,DIALOG_TIME:8,DIALOG_DATETIME:9,DIAGRAM:10,PAGE:11,DIALOG:12,EXTENSION:Ri.EXTENSION};class Mr extends Ie{constructor(t,e,i,s){super(Oe.OPEN,e,t),this.target=i,this.inNewWindow=s}isEquals(t){return super.isEquals(t)&&t instanceof Mr&&this.target===t.target&&this.inNewWindow===t.inNewWindow}toRuntime(){switch(this.subtype){case Rr.DIAGRAM:return new Ar(this,Ri.DIAGRAM);case Rr.PAGE:return new Ar(this,Ri.PAGE)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=this.inNewWindow?1:0;return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources);return new Mr(this.toSubType(t),i,s,this.inNewWindow(t))}static toSubType(t){switch(t[2]){case Rr.DIAGRAM_LEGACY:return Rr.DIAGRAM;case Rr.PAGE_LEGACY:case Rr.PAGE_INPLACE_LEGACY:return Rr.PAGE;case Rr.DIAGRAM:return Rr.DIAGRAM;case Rr.PAGE:return Rr.PAGE}return Rr.DIAGRAM}static inNewWindow(t){switch(t[2]){case Rr.DIAGRAM_LEGACY:return!1;case Rr.PAGE_LEGACY:return!0;case Rr.PAGE_INPLACE_LEGACY:return!1;case Rr.DIAGRAM:case Rr.PAGE:return!!t[4]}return!1}}const kr={TOP:0,TOP_LEFT:1,TOP_CENTER:2,TOP_RIGHT:3,LEFT:4,LEFT_TOP:5,LEFT_MIDDLE:6,LEFT_BOTTOM:7,RIGHT:8,RIGHT_TOP:9,RIGHT_MIDDLE:10,RIGHT_BOTTOM:11,BOTTOM:12,BOTTOM_LEFT:13,BOTTOM_CENTER:14,BOTTOM_RIGHT:15,OVER:16,NONE:17};class Lr{static attach(t,e,i,s,n,o,r){if(r===kr.NONE)return;const a=t.width,h=t.height;let l=0;switch(r){case kr.LEFT:case kr.LEFT_TOP:case kr.LEFT_MIDDLE:case kr.LEFT_BOTTOM:l=e.left-a-i,l<i&&(l=e.right+i,n-i<l+a&&(l=i));break;case kr.RIGHT:case kr.RIGHT_TOP:case kr.RIGHT_MIDDLE:case kr.RIGHT_BOTTOM:l=e.right+i,n-i<l+a&&(l=e.left-a-i,l<i&&(l=n-a-i));break;case kr.TOP:case kr.TOP_LEFT:case kr.BOTTOM:case kr.BOTTOM_LEFT:l=this.adjust(e.left,a,i,n);break;case kr.TOP_RIGHT:case kr.BOTTOM_RIGHT:l=this.adjust(e.right-a,a,i,n);break;case kr.TOP_CENTER:case kr.BOTTOM_CENTER:case kr.OVER:l=this.adjust(.5*(e.left+e.right-a),a,i,n)}let c=0;switch(r){case kr.LEFT:case kr.LEFT_TOP:case kr.RIGHT:case kr.RIGHT_TOP:c=this.adjust(e.top,h,s,o);break;case kr.LEFT_MIDDLE:case kr.RIGHT_MIDDLE:case kr.OVER:c=this.adjust(.5*(e.top+e.bottom-h),h,s,o);break;case kr.LEFT_BOTTOM:case kr.RIGHT_BOTTOM:c=this.adjust(e.bottom,h,s,o);break;case kr.TOP:case kr.TOP_LEFT:case kr.TOP_RIGHT:case kr.TOP_CENTER:c=e.top-h-s,c<s&&(c=e.bottom+s,o<c+h&&(c=s));break;case kr.BOTTOM:case kr.BOTTOM_LEFT:case kr.BOTTOM_RIGHT:case kr.BOTTOM_CENTER:c=e.bottom+s,o-s<c+h&&(c=e.top-h-s,c<s&&(c=o-h-s))}t.position.set(l,c)}static adjust(t,e,i,s){return t<i?s-i<t+e?.5*(s-e):i:s-i<t+e?s<e?.5*(s-e):s-e-i:t}}const Nr={NONE:0,ESC:1,CLICK_OUTSIDE:2},Pr={DIRTY:0,CLEAN:1};class Br{constructor(t,e){var i;this._parent=t,this._options=e,e.enable&&(this._util=this.newUtil()),this._mode=Qi(null!==(i=e.mode)&&void 0!==i?i:Pr.DIRTY,Pr),this._isEnabled=!0,this._isDirty=!1}get parent(){return this._parent}get mode(){return this._mode}set mode(t){this._mode=t}get constraint(){var t,e;let i=this._constraint;return null==i&&(i=null!==(e=null===(t=this._options)||void 0===t?void 0:t.constraint)&&void 0!==e?e:this.newConstraint(),this._constraint=i),i}set constraint(t){this._constraint=t}newConstraint(){return(t,e,i,s)=>{this.toConstrained(t,e,i,s)}}isDirty(){return this._isDirty}isClean(){return!this._isDirty}toClean(){this._isDirty&&(this._isDirty=!1)}newUtil(){const e=new t.Point,i=this._parent,s=i.position;return new un({bind:i,checker:{start:t=>{if(t.target!==i)return!1;e.copyFrom(t.data.global),i.toLocal(e,void 0,e,!0);const s=e.x,n=e.y;return!(s<0||n<0||i.width<s||i.height<n)}},on:{start:()=>{e.copyFrom(s)},move:(t,n,o)=>{e.set(e.x+n,e.y+o),this._isDirty||(this._isDirty=!0,i.setX(s.x),i.setY(s.y));const r=i.layer;null!=r&&this.constraint(i,r,e.x,e.y)}}})}toConstrained(e,i,s,n){var o;const r=e.position;if(i){const a=e.getBounds(!1,null!==(o=Br.WORK_BOUNDS)&&void 0!==o?o:Br.WORK_BOUNDS=new t.Rectangle),h=a.x+s-r.x,l=a.y+n-r.y,c=Math.min(Math.max(0,h),i.width-a.width),u=Math.min(Math.max(0,l),i.height-a.height);r.set(s+c-h,n+u-l)}else r.set(s,n)}}const zr={MODAL:0,MODELESS:1,MENU:2},Ur={MODAL:"MODAL",MODELESS:"MODELESS",MENU:"MENU"};class Fr{static apply(t,e){t.on(nn.down,i=>{if(i.target===t){const s=this.point;s.copyFrom(i.data.global),t.toLocal(s,void 0,s,!0);const n=s.x,o=s.y;(n<0||o<0||t.width<n||t.height<o)&&setTimeout(()=>{e(i)},0)}})}}Fr.point=new t.Point;class Hr{constructor(t){this._layer=null,this._application=null==(null==t?void 0:t.parent)?ot.last():null}get picked(){return this._layer}pick(t,e){let i=this._layer;if(null==i){if(i=ot.getLayerOverlay(t),null==i&&null!=e&&(i=ot.getLayerOverlay(e)),null==i){const t=this._application;i=t?t.getLayerOverlay():ot.last().getLayerOverlay()}this._layer=i}return i}}class Gr extends to{init(t){var e,i,s;super.init(t),this._onPrerenderBound=()=>{this.onPrerender()},this._layer=null;const n=this.theme,o=Qi(null!==(e=null==t?void 0:t.mode)&&void 0!==e?e:n.getMode(),zr);this._mode=o,this._alwaysOnTop=null!==(i=null==t?void 0:t.alwaysOnTop)&&void 0!==i?i:n.isAlwaysOnTop(),this._sticky=null!==(s=null==t?void 0:t.sticky)&&void 0!==s?s:n.isSticky(o);const r=this.toCloseOn(o,n,t);switch(this._closeOn=r,this._align=this.toAlign(o,n,t),this._overlay=new Hr,this._gesture=new Br(this,this.toGestureOptions(o,n,t)),this.visible=!1,o){case zr.MODAL:this.state.addAll(lt.FOCUS_ROOT,Ur.MODAL);break;case zr.MODELESS:this.state.add(Ur.MODELESS);break;case zr.MENU:this.state.addAll(lt.FOCUS_ROOT,Ur.MENU)}r&Nr.CLICK_OUTSIDE&&Fr.apply(this,()=>{this.onCloseOn()})}toCloseOn(t,e,i){const s=null==i?void 0:i.closeOn;if(null==s)return e.closeOn(t);if(vt(s)){let t=Nr.NONE;for(let e=0,i=s.length;e<i;++e)t|=Nr[s[e]];return t}return Et(s)?Nr[s]:s}toAlign(t,e,i){const s=null==i?void 0:i.align;return null===s?null:void 0===s?e.getAlign(t):Qi(s,kr)}get mode(){return this._mode}get align(){return this._align}set algin(t){this._align=t}get alwaysOnTop(){return this._alwaysOnTop}set alwaysOnTop(t){this._alwaysOnTop=t}get gesture(){return this._gesture}get layer(){return this._layer}toGestureOptions(t,e,i){const s=null==i?void 0:i.gesture;return!0===s?{enable:!0,mode:e.getGestureMode(t)}:!1===s?{enable:!1,mode:e.getGestureMode(t)}:null!=s?(void 0===s.enable&&(s.enable=e.isGestureEnabled(t)),void 0===s.mode&&(s.mode=e.getGestureMode(t)),s):{enable:e.isGestureEnabled(t),mode:e.getGestureMode(t)}}onParentResize(t,e,i){if(this.isOpened()){const t=this._layer;if(null!=t){const e=this._gesture;if(e.isDirty()){const i=this.position;e.constraint(this,t,i.x,i.y)}}}super.onParentResize(t,e,i)}getAnimation(){var t,e;let i=this._animation;return void 0===i&&(i=null!==(e=null===(t=this._options)||void 0===t?void 0:t.animation)&&void 0!==e?e:this.theme.newAnimation(this._mode),i&&(i.target=this,i.on("end",t=>{this.onAnimationEnd(t)})),this._animation=i),i}onAnimationEnd(t){if(t)if(this._mode===zr.MODELESS)this.hide();else{const t=this.parent;t&&t.removeChild(this)}else{const t=ot.getLayer(this);if(t){const e=t.getFocusController();this._focused=e.get(),e.focus(this.findFirstFocusable(e)||this)}}}findFirstFocusable(t){return t.find(this,!1,!0,!0)}open(t){let e=this._promise;if(null==e){e=new Promise((t,e)=>{this._resolve=t,this._reject=e}),this._promise=e,this._opener=t;let i=null;switch(this._mode){case zr.MODAL:case zr.MENU:i=this._overlay.pick(this,t),i.stage.addChild(this);break;case zr.MODELESS:i=ot.getLayer(this),this.show()}this._layer=i;const s=this._gesture;if(s.mode===Pr.CLEAN&&s.toClean(),null!=i)if(s.isClean()){const t=i.renderer,e=this._onPrerenderBound;this._sticky?t.on("prerender",e):t.once("prerender",e)}else{const t=this.position;s.constraint(this,i,t.x,t.y)}this.bringToFront(),this.onOpen()}return e}onChildFocus(t){super.onChildFocus(t),this.bringToFront()}onFocus(){super.onFocus(),this.bringToFront()}bringToFront(){const t=this.parent;if(null==t)return;const e=t.children,i=e.length;let s=i-1;for(;0<=s&&e[s]!==this;--s);if(!(s<0)){for(let t=s+1;t<i;++t)e[t-1]=e[t];e[i-1]=this,e.sort((t,e)=>(t instanceof Gr?t._alwaysOnTop?2:1:0)-(e instanceof Gr?e._alwaysOnTop?2:1:0))}}onPrerender(){var e;const i=this._layer;if(null==i)return;const s=this._align;if(s===kr.NONE)return;const n=this._opener;if(null!=s&&null!=n){const o=this._mode,r=n.getBounds(!1,null!==(e=Gr.WORK_BOUNDS)&&void 0!==e?e:Gr.WORK_BOUNDS=new t.Rectangle),a=this.theme;Lr.attach(this,r,a.getOffsetX(o),a.getOffsetY(o),i.width,i.height,s)}else this.position.set(.5*(i.width-this.width),.5*(i.height-this.height))}onOpen(){this.emit("open",this);const t=this.getAnimation();t?t.start():this._mode===zr.MENU&&(this.visible=!0,this.onAnimationEnd(!1))}isOpened(){return null!=this._promise}close(){this.doReject()}doResolve(t){const e=this._resolve;e&&(this._promise=void 0,this._resolve=void 0,this._reject=void 0,this.onClose(),e(t))}doReject(t){const e=this._reject;e&&(this._promise=void 0,this._resolve=void 0,this._reject=void 0,this.onClose(),e(t))}onClose(){const t=this._layer,e=this._focused;if(null!=e)if(this._focused=null,t){const i=ot.getLayer(e);null!=i&&t!==i&&i.view.focus(),t.getFocusController().focus(e)}else this.blur(!0);else this.blur(!0);t&&(t.renderer.off("prerender",this._onPrerenderBound),this._layer=null),this._opener=null;const i=this.getAnimation();if(i?i.start(!0):(this.visible=!1,this.onAnimationEnd(!0)),this._alwaysOnTop){const t=this.parent;null!=t&&t.off("childAdded",this._onParentChildAddedBound)}this.emit("close",this)}onKeyDown(t){return this._closeOn&Nr.ESC&&$n.isCancelKey(t)&&this.onCloseOn(),super.onKeyDown(t)}onCloseOn(){this.close()}containsGlobalPoint(t){switch(this._mode){case zr.MODAL:case zr.MENU:return!0;case zr.MODELESS:return super.containsGlobalPoint(t)}}getType(){return"DDialog"}}const Vr={VERTICAL:0,HORIZONTAL:1};class Wr extends to{constructor(t){super(t),this.visible=!1}getType(){return"DLayoutSpace"}}const Kr=t=>t instanceof to&&(t.visible||t instanceof Wr);class Xr extends to{init(t){super.init(t);const e=this.theme;this._margin=((t,e)=>{var i,s;const n=null==e?void 0:e.margin;if(null!=n){if(wt(n))return{horizontal:n,vertical:n};{const e=t.getMargin();return{horizontal:null!==(i=n.horizontal)&&void 0!==i?i:e,vertical:null!==(s=n.vertical)&&void 0!==s?s:e}}}{const e=t.getMargin();return{horizontal:e,vertical:e}}})(e,t),this._direction=((t,e)=>{const i=null==e?void 0:e.direction;return null!=i?Et(i)?Vr[i]:i:t.getDirection()})(e,t),this._cornerAdjust=((t,e)=>{const i=null==e?void 0:e.corner;if(null!=i&&!wt(i)){const t=i.adjust;if(null!=t)return t}return t.getCornerAdjust()})(e,t),this._multiplicity=((t,e)=>{if(e){const t=e.row;if(null!=t)return t;const i=e.column;if(null!=i)return i}return t.getMultiplicity()})(e,t),this._reverse=((t,e)=>{var i;return null!==(i=null==e?void 0:e.reverse)&&void 0!==i?i:t.getReverse()})(e,t)}get margin(){return this._margin}get multiplicity(){return this._multiplicity}getWeightTotal(){const t=this.children;let e=0;const i=this._multiplicity,s=this._reverse;for(let n=0,o=t.length;n<o;){let r=-1,a=0;for(;a<i&&n+a<o;++a){const e=t[s?o-1-(n+a):n+a];if(Kr(e)){const t=e.getClearType();if(0!==a&&t&Hn.BEFORE)break;if(r=Math.max(r,e.weight),t&&Hn.AFTER){a+=1;break}}else n+=1,a-=1}n+=a,0<=r&&(e+=r)}return e}getSpaceLeft(t,e){const i=this.children,s=this._multiplicity,n=this._reverse;if(this._direction===Vr.VERTICAL){let o=t,r=0;for(let t=0,a=i.length;t<a;){let h=0,l=-1,c=0;for(;c<s&&t+c<a;++c){const e=i[n?a-1-(t+c):t+c];if(Kr(e)){const t=e.getClearType();if(0!==c&&t&Hn.BEFORE)break;if(l=Math.max(l,e.weight),h=l<0?Math.max(h,e.height+r):r,t&Hn.AFTER){c+=1;break}}else t+=1,c-=1}t+=c,o-=h,r=e}return Math.max(0,o)}{let o=t,r=0;for(let t=0,a=i.length;t<a;){let h=0,l=-1,c=0;for(;c<s&&t+c<a;++c){const e=i[n?a-1-(t+c):t+c];if(Kr(e)){const t=e.getClearType();if(0!==c&&t&Hn.BEFORE)break;if(l=Math.max(l,e.weight),h=l<0?Math.max(h,e.width+r):r,t&Hn.AFTER){c+=1;break}}else t+=1,c-=1}t+=c,o-=h,r=e}return Math.max(0,o)}}calcSpaceLeft(t,e,i,s){return t?0:this.getSpaceLeft(e-i,s)}onRefit(){const t=this.children,e=this._padding,i=e.getTop(),s=e.getBottom(),n=e.getLeft(),o=e.getRight(),r=this._margin,a=r.vertical,h=r.horizontal,l=this.getWeightTotal(),c=this._multiplicity,u=this._reverse,d=this._auto;let p=null;if(this._cornerAdjust){const e=4+(t.length<<1);(null==Xr.CORNER_ADJUST_WORK||Xr.CORNER_ADJUST_WORK.length<e)&&(Xr.CORNER_ADJUST_WORK=new Float32Array(e)),p=Xr.CORNER_ADJUST_WORK,p[0]=-2,p[1]=-2,p[e-2]=-3,p[e-1]=-3}if(this._direction===Vr.VERTICAL){let e=0,o=i-a;if(0<l){const r=1/l,_=this.calcSpaceLeft(d.height.isOn,this.height,i+s,a);for(let i=0,s=t.length;i<s;){let l=n-h,d=0,g=0;for(;g<c&&i+g<s;++g){const n=t[u?s-1-(i+g):i+g];if(Kr(n)){const t=n.getClearType();if(0!==g&&t&Hn.BEFORE)break;{n.position.set(h+l,a+o);const s=n.weight;if(0<=s&&(n.height=_*(s*r)),l+=h+n.width,d=Math.max(d,n.height),t&Hn.AFTER){if(null!=p){const t=i+g+1<<1;p[t+0]=g,p[t+1]=e}g+=1;break}if(null!=p){const t=i+g+1<<1;p[t+0]=g,p[t+1]=e}}}else{if(null!=p){const t=i+g+1<<1;p[t+0]=g-1,p[t+1]=e}i+=1,g-=1}}o+=a+d,i+=g,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findRowIndexPrevious(i,o,p);this.hasClearTypeAfter(t,e)||(a=p[e])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findRowIndexNext(i,o,p);this.hasClearTypeBefore(t,e)||(h=p[e])}const l=this.countColumn(i,o,p);s.corner.mask=this.toCornerMaskColumn(a,n,h,l)}}}else{for(let i=0,s=t.length;i<s;){let r=n-h,l=0,d=0;for(;d<c&&i+d<s;++d){const n=t[u?s-1-(i+d):i+d];if(Kr(n)){const t=n.getClearType();if(0!==d&&t&Hn.BEFORE)break;if(n.position.set(h+r,a+o),0<=n.weight&&(n.height=0),r+=h+n.width,l=Math.max(l,n.height),t&Hn.AFTER){if(null!=p){const t=i+d+1<<1;p[t+0]=d,p[t+1]=e}d+=1;break}if(null!=p){const t=i+d+1<<1;p[t+0]=d,p[t+1]=e}}else{if(null!=p){const t=i+d+1<<1;p[t+0]=d-1,p[t+1]=e}i+=1,d-=1}}o+=a+l,i+=d,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findRowIndexPrevious(i,o,p);this.hasClearTypeAfter(t,e)||(a=p[e])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findRowIndexNext(i,o,p);this.hasClearTypeBefore(t,e)||(h=p[e])}const l=this.countColumn(i,o,p);s.corner.mask=this.toCornerMaskColumn(a,n,h,l)}}}}else{let e=0,s=n-h;if(0<l){const r=1/l,_=this.calcSpaceLeft(d.width.isOn,this.width,n+o,h);for(let n=0,o=t.length;n<o;){let l=i-a,d=0,g=0;for(;g<c&&n+g<o;++g){const i=t[u?o-1-(n+g):n+g];if(Kr(i)){const t=i.getClearType();if(0!==g&&t&Hn.BEFORE)break;{i.position.set(h+s,a+l);const o=i.weight;if(0<=o&&(i.width=_*(o*r)),d=Math.max(d,i.width),l+=a+i.height,t&Hn.AFTER){if(null!=p){const t=n+g+1<<1;p[t+0]=e,p[t+1]=g}g+=1;break}if(null!=p){const t=n+g+1<<1;p[t+0]=e,p[t+1]=g}}}else{if(null!=p){const t=n+g+1<<1;p[t+0]=e,p[t+1]=g-1}n+=1,g-=1}}s+=h+d,n+=g,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findColumnIndexPrevious(i,n,p);this.hasClearTypeAfter(t,e)||(a=p[e+1])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findColumnIndexNext(i,n,p);this.hasClearTypeBefore(t,e)||(h=p[e+1])}const l=this.countRow(i,n,p);s.corner.mask=this.toCornerMaskRow(a,o,h,l)}}}else{for(let n=0,o=t.length;n<o;){let r=i-a,l=0,d=0;for(;d<c&&n+d<o;++d){const i=t[u?o-1-(n+d):n+d];if(Kr(i)){const t=i.getClearType();if(0!==d&&t&Hn.BEFORE)break;if(i.position.set(h+s,a+r),0<=i.weight&&(i.width=0),l=Math.max(l,i.width),r+=a+i.height,t&Hn.AFTER){if(null!=p){const t=n+d+1<<1;p[t+0]=e,p[t+1]=d}d+=1;break}if(null!=p){const t=n+d+1<<1;p[t+0]=e,p[t+1]=d}}else{if(null!=p){const t=n+d+1<<1;p[t+0]=e,p[t+1]=d-1}n+=1,d-=1}}s+=h+l,n+=d,e+=1}if(null!=p)for(let e=0,i=t.length;e<i;++e){const s=t[u?i-1-e:e];if(Kr(s)){const i=2+(e<<1),n=p[i+0],o=p[i+1],r=s.getClearType();let a=-2;if(!(r&Hn.BEFORE)){const e=this.findColumnIndexPrevious(i,n,p);this.hasClearTypeAfter(t,e)||(a=p[e+1])}let h=-2;if(!(r&Hn.AFTER)){const e=this.findColumnIndexNext(i,n,p);this.hasClearTypeBefore(t,e)||(h=p[e+1])}const l=this.countRow(i,n,p);s.corner.mask=this.toCornerMaskRow(a,o,h,l)}}}}super.onRefit()}hasClearTypeBefore(t,e){return this.hasClearType(t,e,Hn.BEFORE)}hasClearTypeAfter(t,e){return this.hasClearType(t,e,Hn.AFTER)}hasClearType(t,e,i){if(2<=e){const s=e-2>>1;if(0<=s&&s<t.length){const e=t[s];if(e instanceof to)return!!(e.getClearType()&i)}}return!1}findColumnIndexPrevious(t,e,i){for(let s=t-2;0<=s;s-=2)if(i[s]!==e)return s;return 0}findColumnIndexNext(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2){const t=i[s];if(t!==e){for(let e=s+2;e<n;e+=2)if(i[e]!==t)return e-2;return s}}return i.length-2}countRow(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2)if(i[s]!==e)return i[s-2+1]+1;return 0}findRowIndexPrevious(t,e,i){for(let s=t-2;0<=s;s-=2)if(i[s+1]!==e)return s;return 0}findRowIndexNext(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2){const t=i[s+1];if(t!==e){for(let e=s+2;e<n;e+=2)if(i[e+1]!==t)return e-2;return s}}return i.length-2}countColumn(t,e,i){for(let s=t+2,n=i.length;s<n;s+=2)if(i[s+1]!==e)return i[s-2+0]+1;return 0}toCornerMaskColumn(t,e,i,s){let n=Sn.NONE;return t+1<e&&0===e&&(n|=Sn.TOP_LEFT),i+1<e&&0===e&&(n|=Sn.BOTTOM_LEFT),t<e&&e+1===s&&(n|=Sn.TOP_RIGHT),i<e&&e+1===s&&(n|=Sn.BOTTOM_RIGHT),Sn.ALL&~n}toCornerMaskRow(t,e,i,s){let n=Sn.NONE;return t+1<e&&0===e&&(n|=Sn.TOP_LEFT),i+1<e&&0===e&&(n|=Sn.TOP_RIGHT),t<e&&e+1===s&&(n|=Sn.BOTTOM_LEFT),i<e&&e+1===s&&(n|=Sn.BOTTOM_RIGHT),Sn.ALL&~n}addSpace(t){return this.addChild(new Wr(t))}getType(){return"DLayout"}}Xr.CORNER_ADJUST_WORK=null;class Yr extends Xr{getType(){return"DLayoutVertical"}}class jr extends Yr{getType(){return"DDialogLayeredContent"}}const $r={CLICKED:0,DOUBLE_CLICKED:1},qr={TEXT:0,PADDING:1,BORDER:2},Zr={LEFT:0,CENTER:1,RIGHT:2},Jr={TOP:0,MIDDLE:1,BOTTOM:2};class Qr{constructor(){this._pieces=[],this._bounds=[],this._size=0,this._margin=0}clear(){this._pieces.length=0,this._bounds.length=0,this._size=0,this._margin=0,this._text=void 0}set(t){this._text=t}get size(){return this._size-(null===this._text?this._margin:0)}}class ta extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.height,this._margin=i}execute(t,e){const i=this._pieces,s=this._bounds;let n=e-t;if(void 0!==this._text){let t=0;for(let e=0,o=i.length;e<o;++e){const o=i[e],r=s[e],a=o.object;n-=t+r.height,a.y=n-r.y,t=o.margin.horizontal}}else for(let t=0,e=i.length;t<e;++t){const e=i[t],o=s[t],r=e.object;n-=e.margin.horizontal+o.height,r.y=n-o.y}}}class ea extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size=Math.max(this.size,e.width)}execute(t,e,i){const s=t+.5*(i-t-e),n=this._pieces,o=this._bounds;for(let t=0,e=n.length;t<e;++t){const e=n[t],i=o[t];e.object.x=s-i.x-.5*i.width}}}class ia extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.width,this._margin=i}execute(t){const e=this._pieces,i=this._bounds;let s=t;if(void 0!==this._text)for(let t=0,n=e.length;t<n;++t){const n=e[t],o=i[t];n.object.x=s-o.x,s+=o.width+n.margin.horizontal}else for(let t=0,n=e.length;t<n;++t){const n=e[t],o=i[t],r=n.object;s+=n.margin.horizontal,r.x=s-o.x,s+=o.width}}}class sa extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size=Math.max(this.size,e.height)}execute(t,e,i){const s=t+.5*(i-t-e),n=this._pieces,o=this._bounds;for(let t=0,e=n.length;t<e;++t){const e=n[t],i=o[t];e.object.y=s-i.y-.5*i.height}}}class na extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.width,this._margin=i}execute(t,e){const i=this._pieces,s=this._bounds;let n=e-t;if(void 0!==this._text){let t=0;for(let e=0,o=i.length;e<o;++e){const o=i[e],r=s[e],a=o.object;n-=t+r.width,a.x=n-r.x,t=o.margin.horizontal}}else for(let t=0,e=i.length;t<e;++t){const e=i[t],o=s[t],r=e.object;n-=e.margin.horizontal+o.width,r.x=n-o.x}}}class oa extends Qr{add(t,e,i){this._pieces.push(t),this._bounds.push(e),this._size+=i+e.height,this._margin=i}execute(t){const e=this._pieces,i=this._bounds;let s=t;if(void 0!==this._text){let t=0;for(let n=0,o=e.length;n<o;++n){const o=e[n],r=i[n];o.object.y=t+s-r.y,s+=r.height,t=o.margin.vertical}}else for(let t=0,n=e.length;t<n;++t){const n=e[t],o=i[t],r=n.object;s+=n.margin.vertical,r.y=s-o.y,s+=o.height}}}class ra{constructor(){this.left=new ia,this.center=new ea,this.right=new na,this.top=new oa,this.middle=new sa,this.bottom=new ta}clear(){this.left.clear(),this.center.clear(),this.right.clear(),this.top.clear(),this.middle.clear(),this.bottom.clear(),this.text=void 0}add(t){const e=t.object;if(null!=e){const i=e.getLocalBounds(),s=t.margin,n=t.align;switch(n.horizontal){case Zr.LEFT:this.left.add(t,i,s.horizontal);break;case Zr.CENTER:this.center.add(t,i,s.horizontal);break;case Zr.RIGHT:this.right.add(t,i,s.horizontal)}switch(n.vertical){case Jr.TOP:this.top.add(t,i,s.vertical);break;case Jr.MIDDLE:this.middle.add(t,i,s.vertical);break;case Jr.BOTTOM:this.bottom.add(t,i,s.vertical)}}}set(t){this.left.set(t),this.center.set(t),this.right.set(t),this.top.set(t),this.middle.set(t),this.bottom.set(t),this.text=t}get width(){const t=this.text,e=this.left.size,i=this.center.size,s=this.right.size;return void 0!==t?null!==t?Math.max(e+t.width+s,i):Math.max(e+s,i):Math.max(e,s,i)}get height(){const t=this.text,e=this.top.size,i=this.middle.size,s=this.bottom.size;return void 0!==t?null!==t?Math.max(e+t.height+s,i):Math.max(e+s,i):Math.max(e,s,i)}execute(t,e,i,s,n,o,r){const a=this.left,h=this.center,l=this.right,c=this.top,u=this.middle,d=this.bottom,p=this.text;if(void 0!==p){const _=a.size,g=l.size,f=c.size,m=d.size;let v=0,T=0,w=0;switch(null!=p&&(p.setClippingDelta(_+g,f+m),T=p.width,w=p.height),n.horizontal){case Zr.LEFT:v=t+_;break;case Zr.CENTER:v=t+.5*(o-t-i-(_+T+g))+_;break;case Zr.RIGHT:v=o-i-g-T}let E=0;switch(n.vertical){case Jr.TOP:E=e+f;break;case Jr.MIDDLE:E=e+.5*(r-e-s-(f+w+m))+f;break;case Jr.BOTTOM:E=r-s-m-w}null!=p&&p.position.set(v,E),a.execute(v-_),h.execute(0,0,2*v+T),l.execute(0,v+T+g),c.execute(E-f),u.execute(0,0,2*E+w),d.execute(0,E+w+m)}else a.execute(t),h.execute(t,i,o),l.execute(i,o),c.execute(e),u.execute(e,s,r),d.execute(s,r)}}class aa{constructor(){this.text=new ra,this.padding=new ra,this.border=new ra}clear(){this.text.clear(),this.padding.clear(),this.border.clear()}add(t){if(t.object)switch(t.align.with){case qr.TEXT:this.text.add(t);break;case qr.PADDING:this.padding.add(t);break;case qr.BORDER:this.border.add(t)}}set(t){this.text.set(t)}execute(t,e,i,s){const n=t.getLeft(),o=t.getTop(),r=t.getRight(),a=t.getBottom();null==i&&(i=n+this.width+r),null==s&&(s=o+this.height+a),this.border.execute(0,0,0,0,e,i,s),this.padding.execute(n,o,r,a,e,i,s),this.text.execute(n,o,r,a,e,i,s)}get width(){return Math.max(this.border.width,this.padding.width,this.text.width)}get height(){return Math.max(this.border.height,this.padding.height,this.text.height)}}class ha extends t.Graphics{constructor(t){super(),this.parent=t,this._isInitialized=!1,this._width=this.width,this._height=this.height}render(t){this.updateTransform(),super.render(t)}onReflow(t,e,i){this._isInitialized&&this._width===e&&this._height===i||(this._isInitialized=!0,this._width=e,this._height=i,this.clear(),this.beginFill(16777215,1),this.drawRect(0,0,e,i),this.endFill())}}class la{constructor(t,e,i,s){this.x=t,this.y=e,this.character=i,this.wrappable=s}set(t,e,i,s){this.x=t,this.y=e,this.character=i,this.wrappable=s}}class ca{constructor(){this.count=0,this.countPerLine=0,this.width=0,this.height=0,this.characters=[],this.scale=1,this.scaled=!1,this.clipped=!1,this.x=0,this.y=0}start(t,e){this.count=0,this.countPerLine=0,this.width=0,this.height=0,this.scale=1,this.scaled=!1,this.clipped=!1,this.x=0,this.y=.5*(t-e)}isPushable(t,e){return!(t<this.x+e.advance&&!(e.type&zs.SPACE))}isPushableAtNewLine(t,e,i){return this.y+1.5*e+.5*i<=t}push(t,e){const i=this.x;this.x+=t.advance;const s=this.y,n=this.count,o=this.characters;n<o.length?o[n].set(i,s,t,e):o.push(new la(i,s,t,e)),this.count+=1,this.countPerLine+=1}newLine(t){this.width=Math.max(this.width,this.x),this.x=0,this.y+=t,this.countPerLine=0}wordWrap(t){const e=this.countPerLine,i=this.characters;if(0<e){const s=this.count;for(let n=s-1,o=s-e;o<n;--n){let e=i[n];if(e.wrappable){let o=e.character.advance;const r=e.y+t;e.x=0,e.y=r;for(let t=n+1;t<s;++t)e=i[t],e.x=o,e.y=r,o+=e.character.advance;return this.x=o,this.y=r,this.countPerLine=s-n,!0}}const n=i[s-1];return n.x=0,n.y=n.y+t,this.x=n.character.advance,this.y=n.y,this.countPerLine=1,!1}return!1}pop(){const t=this.countPerLine,e=this.characters;if(0<t){const t=e[this.count-1];return this.x-=t.character.advance,this.count-=1,this.countPerLine-=1,!0}return!1}fit(t,e){const i=this.width,s=this.height;1e-4<i&&t<i?1e-4<s&&e<s?(this.scale=Math.min(t/i,e/s),this.scaled=!0):(this.scale=t/i,this.scaled=!0):1e-4<s&&e<s&&(this.scale=e/s,this.scaled=!0)}end(t,e){this.newLine(t),this.y-=.5*(t-e),this.height=this.y}}class ua{constructor(){this.target="",this.position=0}init(t){this.target=t,this.position=0}hasNext(){return this.position<this.target.length}findNextBreak(t,e){const i=t.length;for(let s=e;s<i;++s){const e=t.charCodeAt(s);if(!this.isLowSurrogate(e)&&!this.isVariationSelector(e))return s}return i}isHighSurrogate(t){return 55296<=t&&t<=56319}isLowSurrogate(t){return 56320<=t&&t<=57343}isVariationSelector(t){return 65024<=t&&t<=65039}next(){const t=this.target,e=this.position,i=this.findNextBreak(t,e+1),s=t.substring(e,i);return this.position=i,s}close(){const t=this.target.length;return this.position<t&&(this.position=t,!0)}static from(t){null==ua._instance&&(ua._instance=new ua);const e=ua._instance;return e.init(t),e}}ua._instance=null;const da={NONE:0,NORMAL:1,BREAK_ALL:2};class pa{static measure(t,e,i){const s=pa.RESULT||new ca;if(pa.RESULT=s,null!=e){const n=ua.from(t),o=e.font.height,r=i.lineHeight,a=i.fitting,h=!a&&i.clipping,l=i.width,c=i.height,u=!a&&i.wordWrap;switch(s.start(r,o),u){case da.BREAK_ALL:h?this.measure1(n,l,c,o,r,e,s):this.measure2(n,l,r,e,s);break;case da.NORMAL:const i=this.newLineBreaker(t);i?h?this.measure1a(i,n,l,c,o,r,e,s):this.measure2a(i,n,l,r,e,s):h?this.measure1b(n,l,c,o,r,e,s):this.measure2b(n,l,r,e,s);break;default:h?this.measure3(n,l,c,o,r,e,s):this.measure4(n,r,e,s)}s.end(r,o),a&&s.fit(l,c)}else s.start(0,0),s.end(0,0);return s}static measure1a(t,e,i,s,n,o,r,a){let h=t.next();for(;e.hasNext();){const l=e.position,c=e.next();if(c===D.NEW_LINE)a.isPushableAtNewLine(s,o,n)?a.newLine(o):this.measure5(e,i,o,r,a,!0);else{const u=r.get(c);if(null==u)continue;h=this.advance(l,h,t);const d=this.isWrappable1(l,h);a.isPushable(i,u)?a.push(u,d):a.isPushableAtNewLine(s,o,n)?(a.push(u,d),a.wordWrap(o)):this.measure5(e,i,o,r,a,!0)}}}static measure1b(t,e,i,s,n,o,r){for(;t.hasNext();){const a=t.next();if(a===D.NEW_LINE)r.isPushableAtNewLine(i,n,s)?r.newLine(n):this.measure5(t,e,n,o,r,!0);else{const h=o.get(a);if(null==h)continue;const l=this.isWrappable2(r,h);r.isPushable(e,h)?r.push(h,l):r.isPushableAtNewLine(i,n,s)?(r.push(h,l),r.wordWrap(n)):this.measure5(t,e,n,o,r,!0)}}}static measure1(t,e,i,s,n,o,r){for(;t.hasNext();){const a=t.next();if(a===D.NEW_LINE)r.isPushableAtNewLine(i,n,s)?r.newLine(n):this.measure5(t,e,n,o,r,!0);else{const h=o.get(a);if(null==h)continue;r.isPushable(e,h)?r.push(h,!0):r.isPushableAtNewLine(i,n,s)?(r.newLine(n),r.push(h,!0)):this.measure5(t,e,n,o,r,!0)}}}static measure2a(t,e,i,s,n,o){let r=t.next();for(;e.hasNext();){const a=e.position,h=e.next();if(h===D.NEW_LINE)o.newLine(s);else{const e=n.get(h);if(null==e)continue;r=this.advance(a,r,t);const l=this.isWrappable1(a,r);o.isPushable(i,e)?o.push(e,l):(o.push(e,l),o.wordWrap(s))}}}static measure2b(t,e,i,s,n){for(;t.hasNext();){const o=t.next();if(o===D.NEW_LINE)n.newLine(i);else{const t=s.get(o);if(null==t)continue;const r=this.isWrappable2(n,t);n.isPushable(e,t)?n.push(t,r):(n.push(t,r),n.wordWrap(i))}}}static measure2(t,e,i,s,n){for(;t.hasNext();){const o=t.next();if(o===D.NEW_LINE)n.newLine(i);else{const t=s.get(o);if(null==t)continue;n.isPushable(e,t)||n.newLine(i),n.push(t,!1)}}}static measure3(t,e,i,s,n,o,r){for(;t.hasNext();){const a=t.next();if(a===D.NEW_LINE)r.isPushableAtNewLine(i,n,s)?r.newLine(n):this.measure5(t,e,n,o,r,!0);else{const i=o.get(a);if(null==i)continue;r.isPushable(e,i)?r.push(i,!1):this.measure5(t,e,n,o,r,!1)}}}static measure4(t,e,i,s){for(;t.hasNext();){const n=t.next();if(n===D.NEW_LINE)s.newLine(e);else{const t=i.get(n);if(null==t)continue;s.push(t,!1)}}}static measure5(t,e,i,s,n,o){n.clipped=!0;const r=s.get(D.DOTS);if(null!=r){for(;!n.isPushable(e,r)&&n.pop(););n.isPushable(e,r)&&n.push(r,!1)}if(o)t.close();else for(;t.hasNext();)if(t.next()===D.NEW_LINE){n.newLine(i);break}}static isWrappable2(t,e){if(t.countPerLine<=0)return!1;const i=t.characters[t.count-1].character.type,s=e.type;return i&zs.SPACE?!(s&zs.SPACE||i&zs.NON_BREAKING):!(s&zs.SPACE||i&zs.NON_BREAKING&&s&zs.NON_BREAKING)}static advance(t,e,i){return e.done||t<=e.value.end?e:e=i.next()}static isWrappable1(t,e){if(e.done)return!1;const i=e.value;return i.start===t||i.end===t}static newLineBreaker(t){return"css-line-break"in window?window["css-line-break"].LineBreaker(t,{lineBreak:"strict",wordBreak:"normal"}):null}}pa.RESULT=null;class _a extends t.MeshGeometry{constructor(){var t,e,i;super(null!==(t=_a.VERTICES)&&void 0!==t?t:_a.VERTICES=new Float32Array(0),null!==(e=_a.UVS)&&void 0!==e?e:_a.UVS=new Float32Array(0),null!==(i=_a.INDICES)&&void 0!==i?i:_a.INDICES=new Uint16Array(0)),this.width=0,this.height=0,this.scale=1,this.scaled=!1,this.clipped=!1,this.vertexBuffer=this.getBuffer("aVertexPosition"),this.vertices=_a.VERTICES,this.uvBuffer=this.getBuffer("aTextureCoord"),this.uvs=_a.UVS,this.indexBuffer=this.getIndex(),this.indices=_a.INDICES,this.nchars=0}update(t,e,i){const s=pa.measure(t,e,i),n=s.count;let o=(n>>3)+(7&n?1:0)<<3;if(this.nchars<o){this.nchars=o;const t=o<<3;this.vertices=new Float32Array(t),this.uvs=new Float32Array(t),this.vertexBuffer.data=this.vertices,this.uvBuffer.data=this.uvs;const e=(o<<2)+(o<<1);this.indices=new Uint16Array(e),this.indexBuffer.data=this.indices,this.initIndices(this.indices),this.indexBuffer.update()}else o=this.nchars;if(o<=0)return;const r=this.vertices,a=this.uvs;if(null!=e){const t=s.characters,i=s.scale,h=1/e.width,l=1/e.height;for(let e=0;e<n;++e){const s=t[e],n=s.x,o=s.y,c=s.character;this.fill(r,a,e,n,o,i,c,h,l)}for(let t=n;t<o;++t)this.fillBlank(r,a,t);this.width=s.width*i,this.height=s.height*i,this.scale=i,this.scaled=s.scaled,this.clipped=s.clipped}else{for(let t=0;t<o;++t)this.fillBlank(r,a,t);this.width=0,this.height=0,this.scale=1,this.scaled=!1,this.clipped=!1}this.vertexBuffer.update(),this.uvBuffer.update()}fill(t,e,i,s,n,o,r,a,h){const l=r.x,c=r.y,u=r.width,d=r.height,p=(s+(l-r.origin.x))*o,_=n*o,g=p+u*o,f=_+d*o,m=i<<3;t[m+0]=p,t[m+1]=_,t[m+2]=g,t[m+3]=_,t[m+4]=g,t[m+5]=f,t[m+6]=p,t[m+7]=f;const v=l*a,T=c*h,w=(l+u)*a,E=(c+d)*h;e[m+0]=v,e[m+1]=T,e[m+2]=w,e[m+3]=T,e[m+4]=w,e[m+5]=E,e[m+6]=v,e[m+7]=E}fillBlank(t,e,i){const s=i<<3;t[s+0]=0,t[s+1]=0,t[s+2]=0,t[s+3]=0,t[s+4]=0,t[s+5]=0,t[s+6]=0,t[s+7]=0,e[s+0]=0,e[s+1]=0,e[s+2]=0,e[s+3]=0,e[s+4]=0,e[s+5]=0,e[s+6]=0,e[s+7]=0}initIndices(t){for(let e=0,i=this.nchars<<2,s=0;e<i;e+=4,s+=6)t[s]=e,t[s+1]=e+1,t[s+2]=e+3,t[s+3]=e+1,t[s+4]=e+2,t[s+5]=e+3}}class ga extends t.Mesh{constructor(e){super(new _a,new t.MeshMaterial(t.Texture.EMPTY)),this._style=e,e.on("change",()=>{this.onStyleChange()}),this._text="",this._textApproved="",this._isDirty=!0,this._isGeometryDirty=!0,this._atlas=null,this._atlasRevisionUpdated=0,this._width=0,this._height=0,this._modifier={clipping:!1,fitting:!1,wordWrap:da.NONE,width:0,height:0,lineHeight:0,delta:{width:0,height:0}}}onStyleChange(){this._isDirty=!0,this._isGeometryDirty=!0,this._atlas=null,this.update_()}update_(){const t=ot.getLayer(this);if(t&&this._isDirty){this._isDirty=!1;const e=this._text,i=this._textApproved;this._textApproved=e;const s=this._style,n=s.fontId,o=s.fontIdApproved,r=s.fontIdFontSize,a=s.fill,h=s.fillApproved;s.approve();const l=t.getDynamicFontAtlases();e===i&&n===o&&a===h||(l.add(n,r,a,e),l.remove(o,h,i))}}get text(){return this._text}set text(t){this._text!==t&&(this._text=t,this._style.unfit()||(this._isDirty=!0,this._isGeometryDirty=!0,this.update_()))}get width(){return this.update(),Math.abs(this.scale.x)*this.geometry.width}set width(t){this.update();const e=this.geometry.width;if(1e-4<e){const i=t/e;this.scale.x=0<=this.scale.x?+i:-i}}get height(){return this.update(),Math.abs(this.scale.y)*this.geometry.height}set height(t){this.update();const e=this.geometry.height;if(1e-4<e){const i=t/e;this.scale.y=0<=this.scale.y?+i:-i}}get clipped(){return this.geometry.clipped}get style(){return this._style}update(){this.update_();const t=this._style;let e=this._atlas;if(null==e){const i=ot.getLayer(this);i&&(e=i.getDynamicFontAtlases().get(t.fontId,t.fill),null!=e&&(this._atlasRevisionUpdated=e.getRevisionUpdate(),this._atlas=e,this.texture=e.texture,this._isGeometryDirty=!0))}else{const t=e.getRevisionUpdate();t!==this._atlasRevisionUpdated&&(this._atlasRevisionUpdated=t,this._isGeometryDirty=!0)}const i=this._modifier;if(this.updateClipping(t,i)&&(this._isGeometryDirty=!0),this._isGeometryDirty){this._isGeometryDirty=!1;const s=this.geometry;if(s.update(this._text,e,i),i.fitting&&!t.isFontFitted&&s.scaled){const e=s.scale,i=t.fontSize,n=t.toFontId(Math.ceil(i*e*1e3)/1e3),o=Hs.toSize(n),r=o/i,a=t.lineHeight*r;t.fit(o,a)&&setTimeout(()=>{ot.update(this)},0)}}}updateClipping(t,e){let i=!1;const s=t.clipping;e.clipping!==s&&(e.clipping=s,i=!0);const n=t.fitting;e.fitting!==n&&(e.fitting=n,i=!0);const o=t.wordWrap;e.wordWrap!==o&&(e.wordWrap=o,i=!0);const r=n?t.lineHeightFitted:t.lineHeight;if(e.lineHeight!==r&&(e.lineHeight=r,i=!0),s||n||o){const t=this.parent;if(t instanceof to){const s=t.padding,n=t.width-s.getLeft()-s.getRight()-e.delta.width;e.width!==n&&(e.width=n,i=!0);const o=t.height-s.getTop()-s.getBottom()-e.delta.height;e.height!==o&&(e.height=o,i=!0)}}return i}setClippingDelta(t,e){const i=this._modifier.delta;i.width=t,i.height=e}_calculateBounds(){this.update();const t=this.geometry;this._bounds.addFrame(this.transform,0,0,t.width,t.height)}_render(t){this.update(),super._render(t)}}class fa extends t.utils.EventEmitter{constructor(t,e,i){var s,n,o,r,a,h,l,c,u;super(),this._id=0,this._idApproved=-1,i?(this._fontFamily=null!==(s=i.fontFamily)&&void 0!==s?s:e.getFontFamilly(),this._fontSize=null!==(n=i.fontSize)&&void 0!==n?n:e.getFontSize(),this._fontStyle=null!==(o=i.fontStyle)&&void 0!==o?o:e.getFontStyle(),this._fontVariant=null!==(r=i.fontVariant)&&void 0!==r?r:e.getFontVariant(),this._fontWeight=null!==(a=i.fontWeight)&&void 0!==a?a:e.getFontWeight(),this._clipping=null!==(h=i.clipping)&&void 0!==h?h:e.getTextStyleClipping(),this._fitting=null!==(l=i.fitting)&&void 0!==l?l:e.getTextStyleFitting(),this._wordWrap=Qi(null!==(c=i.wordWrap)&&void 0!==c?c:e.getTextStyleWordWrap(),da),this._lineHeight=null!==(u=i.lineHeight)&&void 0!==u?u:e.getLineHeight()):(this._fontFamily=e.getFontFamilly(),this._fontSize=e.getFontSize(),this._fontStyle=e.getFontStyle(),this._fontVariant=e.getFontVariant(),this._fontWeight=e.getFontWeight(),this._clipping=e.getTextStyleClipping(),this._fitting=e.getTextStyleFitting(),this._wordWrap=e.getTextStyleWordWrap(),this._lineHeight=e.getLineHeight()),this._fill=e.getColor(t.state),this._fontSizeFitted=this._fontSize,this._lineHeightFitted=this._lineHeight,this._isFontFitted=!1,this._fontIdFontSize=this._fontSize,this._fontIdId=-1,this._fontId="",this._fontIdApproved="",this._fillApproved=0}get id(){return this._id}get idApproved(){return this._idApproved}get fontId(){return this.update(),this._fontId}get fontIdFontSize(){return this.update(),this._fontSizeFitted}get fontIdApproved(){return this._fontIdApproved}get fill(){return this._fill}set fill(t){this._fill!==t&&(this._fill=t,this.onChange())}onChange(){this._id+=1,this.emit("change",this)}get fillApproved(){return this._fillApproved}approve(){this.update(),this._idApproved=this._id,this._fontIdApproved=this._fontId,this._fillApproved=this._fill}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.onChange())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this._fontSizeFitted=t,this._lineHeightFitted=this._lineHeight,this._isFontFitted=!1,this.onChange())}get fontSizeFitted(){return this._fontSizeFitted}get isFontFitted(){return this._isFontFitted}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.onChange())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.onChange())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.onChange())}update(){if(this._fontIdId!==this._id){this._fontIdId=this._id;const t=this._fitting?this._fontSizeFitted:this._fontSize;this._fontIdFontSize=t,this._fontId=this.toFontId(t)}}toFontId(t){return`${this._fontStyle} ${this._fontVariant} ${this._fontWeight} ${t}px ${this._fontFamily}`}get clipping(){return this._clipping}set clipping(t){this._clipping!==t&&(this._clipping=t,this.onChange())}get fitting(){return this._fitting}set fitting(t){this._fitting!==t&&(this._fitting=t,this.onChange())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.onChange())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this._fontSizeFitted=this._fontSize,this._lineHeightFitted=t,this._isFontFitted=!1,this.onChange())}get lineHeightFitted(){return this._lineHeightFitted}set lineHeightFitted(t){this._lineHeightFitted!==t&&(this._lineHeightFitted=t,this.onChange())}fit(t,e){let i=!1;return t<this._fontSizeFitted&&(this._fontSizeFitted=t,i=!0),this._lineHeightFitted!==e&&(this._lineHeightFitted=e,i=!0),!0!==this._isFontFitted&&(this._isFontFitted=!0,i=!0),i&&this.onChange(),i}unfit(){let t=!1;return!1!==this._isFontFitted&&(this._isFontFitted=!1,t=!0),this._fontSizeFitted!==this._fontSize&&(this._fontSizeFitted=this._fontSize,t=!0),this._lineHeightFitted!==this._lineHeight&&(this._lineHeightFitted=this._lineHeight,t=!0),t&&this.onChange(),t}}class ma{constructor(t,e,i){var s,n;this._parent=t,this._vertical=Qi(null!==(s=null==i?void 0:i.vertical)&&void 0!==s?s:e.getTextAlignVertical(),Jr),this._horizontal=Qi(null!==(n=null==i?void 0:i.horizontal)&&void 0!==n?n:e.getTextAlignHorizontal(),Zr)}get vertical(){return this._vertical}set vertical(t){t=Qi(t,Jr),this._vertical!==t&&(this._vertical=t,this.onChange())}get horizontal(){return this._horizontal}set horizontal(t){t=Qi(t,Zr),this._horizontal!==t&&(this._horizontal=t,this.onChange())}set(t,e){let i=!1;return null!=t&&(t=Qi(t,Jr),this._vertical!==t&&(this._vertical=t,i=!0)),null!=e&&(e=Qi(e,Zr),this._horizontal!==e&&(this._horizontal=e,i=!0)),i&&this.onChange(),this}onChange(){const t=this._parent;t.toDirty(),ot.update(t)}}class va{constructor(t,e){this._parent=t,this._style=e}get fontFamily(){return this._style.fontFamily}set fontFamily(t){const e=this._style;e.fontFamily!==t&&(e.fontFamily=t,this.onChange())}get fontSize(){return this._style.fontSize}set fontSize(t){const e=this._style;e.fontSize!==t&&(e.fontSize=t,this.onChange())}get fontStyle(){return this._style.fontStyle}set fontStyle(t){const e=this._style;e.fontStyle!==t&&(e.fontStyle=t,this.onChange())}get fontVariant(){return this._style.fontVariant}set fontVariant(t){const e=this._style;e.fontVariant!==t&&(e.fontVariant=t,this.onChange())}get fontWeight(){return this._style.fontWeight}set fontWeight(t){const e=this._style;e.fontWeight!==t&&(e.fontWeight=t,this.onChange())}get clipping(){return this._style.clipping}set clipping(t){const e=this._style;e.clipping!==t&&(e.clipping=t,this.onChange())}get fitting(){return this._style.fitting}set fitting(t){const e=this._style;e.fitting!==t&&(e.fitting=t,this.onChange())}get wordWrap(){return this._style.wordWrap}set wordWrap(t){t=Qi(t,da);const e=this._style;e.wordWrap!==t&&(e.wordWrap=t,this.onChange())}get lineHeight(){return this._style.lineHeight}set lineHeight(t){const e=this._style;e.lineHeight!==t&&(e.lineHeight=t,this.onChange())}onChange(){ot.update(this._parent)}}class Ta extends t.utils.EventEmitter{constructor(t,e,i){var s,n;super(),this._parent=t,this._theme=e,this._value=null!==(s=null==i?void 0:i.value)&&void 0!==s?s:e.newTextValue(),this._computed=this.newComputed(),this._color=null==i?void 0:i.color,this._alpha=null==i?void 0:i.alpha;const o=new fa(t,e,null==i?void 0:i.style);this._dstyle=o,this._style=new va(t,o),this._align=new ma(t,e,null==i?void 0:i.align),this._formatter=null!==(n=null==i?void 0:i.formatter)&&void 0!==n?n:e.getTextFormatter(),this._isVisible=!0,this.onComputedChange(),this.updateObject()&&(t.toDirty(),ot.update(t))}get value(){return this._value}set value(t){this._value!==t&&(this._value=t,this.onValueChange())}getValue(){return this._value}setValue(t,e){(e||this._value!==t)&&(this._value=t,this.onValueChange(e))}onValueChange(t){const e=this.newComputed();if((t||this._computed!==e)&&(this._computed=e,this.onComputedChange(),this.updateObject())){const t=this._parent;t.toDirty(),ot.update(t)}}compute(t){this.onValueChange(t)}get computed(){return this._computed}get formatter(){return this._formatter}set formatter(t){this._formatter!==t&&(this._formatter=t,this.onValueChange(!0))}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onColorChange())}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onColorChange())}onColorChange(){const t=this._object;if(null!=t){const e=this._parent,i=e.state,s=this.newColor(i),n=this.newAlpha(i),o=t.style;o.fill===s&&t.alpha===n||(o.fill=s,t.alpha=n,ot.update(e))}}get align(){return this._align}get style(){return this._style}get object(){return this._object}update(t){const e=this.newComputed();this._computed!==e&&(this._computed=e,this.onComputedChange(),this.updateObject());const i=this._object;if(null!=i){const e=this._parent.state;i.style.fill=this.newColor(e),i.alpha=this.newAlpha(e),t.set(i)}else t.set(null)}updateObject(){const t=this._computed;if(void 0!==t){const e=this._formatter(t,this._parent),i=this._object;if(null==i){if(0<e.length){const t=this.newObject();t.visible=this._isVisible,this._object=t;const i=this._parent;i.addChild(t);const s=i.getOverflowMask();return s&&(t.mask=s),t.text=e,!0}}else if(i.text!==e)return i.text=e,!0}else{const t=this._object;if(null!=t&&""!==t.text)return t.text="",!0}return!1}newComputed(){const t=this._value;if(void 0!==t){if(!Tt(t))return t;{const e=t(this._parent.state);if(void 0!==e)return e}}return this._theme.getTextValue(this._parent.state)}newColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getColor(t)}newAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getAlpha(t)}newObject(){return new ga(this._dstyle)}get visible(){const t=this._object;return null!=t?t.visible:this._isVisible}set visible(t){const e=this._object;null!=e&&(e.visible=t),this._isVisible=t}show(){return this.visible=!0,this}hide(){return this.visible=!1,this}isShown(){return this.visible}onComputedChange(){this.emit("change",this)}destroy(){const t=this._object;return t&&(this._object=void 0,t.destroy()),this}}class wa extends to{init(t){super.init(t),this.getText()}getOverflowMask(){let t=this._overflowMask;return void 0===t&&(t=this.newOverflowMask(),this._overflowMask=t),null}newOverflowMask(){var t,e;if(null!==(e=null===(t=this._options)||void 0===t?void 0:t.mask)&&void 0!==e?e:this.theme.isOverflowMaskEnabled()){const t=new ha(this);return this._reflowable.add(t),this.toDirty(),t}return null}get text(){var t;return null!==(t=this._text)&&void 0!==t?t:this._text=this.newText()}getText(){var t;return null!==(t=this._text)&&void 0!==t?t:this._text=this.newText()}newText(){var t;return new Ta(this,this.theme,null===(t=this._options)||void 0===t?void 0:t.text)}set text(t){this.text.value=t}onReflow(){super.onReflow(),this.onReflowTextAndImage()}getLayouter(){var t;return null!==(t=wa.LAYOUTER)&&void 0!==t?t:wa.LAYOUTER=new aa}onReflowTextAndImage(){const t=this.getLayouter(),e=this.getText();e.update(t);const i=this._auto;t.execute(this._padding,e.align,i.width.isOn?null:this.width,i.height.isOn?null:this.height),t.clear()}isRefitable(t){if(super.isRefitable(t))return!0;if(null!=t){const e=this._text;if(null!=e&&t===e.object)return!0}return!1}applyTitle(){const t=this.text.object;if(this._title.length<=0&&null!=t&&t.clipped){const e=ot.getLayer(this);e&&(e.view.title=t.text)}else super.applyTitle()}getType(){return"DTextBase"}destroy(){const t=this._text;t&&t.destroy();const e=this._overflowMask;e&&(this._overflowMask=null,e.destroy()),super.destroy()}}class Ea{constructor(t){this._theme=t}getImageAlignHorizontal(){return this._theme.getImageAlignHorizontal()}getImageAlignVertical(){return this._theme.getImageAlignVertical()}getImageAlignWith(){return this._theme.getImageAlignWith()}getImageMarginHorizontal(){return this._theme.getImageMarginHorizontal()}getImageMarginVertial(){return this._theme.getImageMarginVertial()}getImageTintColor(t){return this._theme.getImageTintColor(t)}getImageTintAlpha(t){return this._theme.getImageTintAlpha(t)}getImageRotation(t){return this._theme.getImageRotation(t)}getImageSource(t){return null}}class ya{constructor(t){this._theme=t}getImageAlignHorizontal(){return this._theme.getSecondaryImageAlignHorizontal()}getImageAlignVertical(){return this._theme.getSecondaryImageAlignVertical()}getImageAlignWith(){return this._theme.getSecondaryImageAlignWith()}getImageMarginHorizontal(){return this._theme.getSecondaryImageMarginHorizontal()}getImageMarginVertial(){return this._theme.getSecondaryImageMarginVertial()}getImageTintColor(t){return this._theme.getSecondaryImageTintColor(t)}getImageTintAlpha(t){return this._theme.getSecondaryImageTintAlpha(t)}getImageRotation(t){return this._theme.getSecondaryImageRotation(t)}getImageSource(t){var e,i,s;return null!==(s=null===(i=(e=this._theme).getSecondaryImageSource)||void 0===i?void 0:i.call(e,t))&&void 0!==s?s:null}}class xa{constructor(t){this._theme=t}getImageAlignHorizontal(){return this._theme.getTertiaryImageAlignHorizontal()}getImageAlignVertical(){return this._theme.getTertiaryImageAlignVertical()}getImageAlignWith(){return this._theme.getTertiaryImageAlignWith()}getImageMarginHorizontal(){return this._theme.getTertiaryImageMarginHorizontal()}getImageMarginVertial(){return this._theme.getTertiaryImageMarginVertial()}getImageTintColor(t){return this._theme.getTertiaryImageTintColor(t)}getImageTintAlpha(t){return this._theme.getTertiaryImageTintAlpha(t)}getImageRotation(t){return this._theme.getTertiaryImageRotation(t)}getImageSource(t){var e,i,s;return null!==(s=null===(i=(e=this._theme).getTertiaryImageSource)||void 0===i?void 0:i.call(e,t))&&void 0!==s?s:null}}class Ca{constructor(t,e,i){this._parent=t,null!=i&&(this._color=i.color,this._alpha=i.alpha),this._theme=e}get color(){return this._color}set color(t){this._color!==t&&(this._color=t,this.onChange())}getColor(t){const e=this._color;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getImageTintColor(t)}get alpha(){return this._alpha}set alpha(t){this._alpha!==t&&(this._alpha=t,this.onChange())}getAlpha(t){const e=this._alpha;if(void 0!==e){if(!Tt(e))return e;{const i=e(t);if(void 0!==i)return i}}return this._theme.getImageTintAlpha(t)}set(t,e){let i=!1;return null!=t&&this._color!==t&&(this._color=t,i=!0),null!=e&&this._alpha!==e&&(this._alpha=e,i=!0),i&&this.onChange(),this}onChange(){this._parent.updateTint(),ot.update(this._parent)}}class Da{constructor(t,e,i){var s,n;this._parent=t,this._vertical=null!==(s=null==i?void 0:i.vertical)&&void 0!==s?s:e.getImageMarginVertial(),this._horizontal=null!==(n=null==i?void 0:i.horizontal)&&void 0!==n?n:e.getImageMarginHorizontal()}get vertical(){return this._vertical}set vertical(t){this._vertical!==t&&(this._vertical=t,this.onChange())}get horizontal(){return this._horizontal}set horizontal(t){this._horizontal!==t&&(this._horizontal=t,this.onChange())}set(t,e){let i=!1;return null!=t&&this._vertical!==t&&(this._vertical=t,i=!0),null!=e&&this._horizontal!==e&&(this._horizontal=e,i=!0),i&&this.onChange(),this}onChange(){this._parent.onUpdate()}}class Sa{constructor(t,e,i){var s,n,o;this._parent=t,this._with=Qi(null!==(s=null==i?void 0:i.with)&&void 0!==s?s:e.getImageAlignWith(),qr),this._vertical=Qi(null!==(n=null==i?void 0:i.vertical)&&void 0!==n?n:e.getImageAlignVertical(),Jr),this._horizontal=Qi(null!==(o=null==i?void 0:i.horizontal)&&void 0!==o?o:e.getImageAlignHorizontal(),Zr)}get with(){return this._with}set with(t){t=Qi(t,qr),this._with!==t&&(this._with=t,this.onChange())}get vertical(){return this._vertical}set vertical(t){t=Qi(t,Jr),this._vertical!==t&&(this._vertical=t,this.onChange())}get horizontal(){return this._horizontal}set horizontal(t){t=Qi(t,Zr),this._horizontal!==t&&(this._horizontal=t,this.onChange())}set(t,e,i){let s=!1;return null!=t&&(t=Qi(t,qr),this._with!==t&&(this._with=t,s=!0)),null!=e&&(e=Qi(e,Jr),this._vertical!==e&&(this._vertical=e,s=!0)),null!=i&&(i=Qi(i,Zr),this._horizontal!==i&&(this._horizontal=i,s=!0)),s&&this.onChange(),this}onChange(){this._parent.onUpdate()}}class ba{constructor(t,e,i){this._parent=t,this._theme=e,this._object=null,this._align=new Sa(this,e,null==i?void 0:i.align),this._margin=new Da(this,e,null==i?void 0:i.margin),this._tint=new Ca(this,e,null==i?void 0:i.tint),this._rotation=null==i?void 0:i.rotation,this._source=null==i?void 0:i.source,this._computed=null,this._onUpdateBound=()=>{this.onUpdate()}}get object(){return this._object}get align(){return this._align}get margin(){return this._margin}get tint(){return this._tint}get source(){return this._source}set source(t){this._source!==t&&(this._source=t,this.updateSource()&&this.onUpdate())}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateRotation()&&ot.update(this._parent))}computeSource(){const t=this._source;if(void 0!==t){if(!Tt(t))return t;{const e=t(this._parent.state);if(void 0!==e)return e}}return this._theme.getImageSource(this._parent.state)}onStateChange(t,e){this.updateTint(),this.updateRotation()}isTintAware(t){return null!=t&&"tint"in t}updateTint(){const t=this._object;if(t&&this.isTintAware(t)){const e=this._parent.state,i=this._tint.getColor(e);if(null!=i){let s=!1;t.tint!==i&&(t.tint=i,s=!0);const n=this._tint.getAlpha(e);return t.alpha!==n&&(t.alpha=n,s=!0),t.visible||(t.visible=!0,s=!0),s}if(t.visible)return t.visible=!1,!0}return!1}toRotation(t,e){const i=this._rotation;if(null!=i){if(!Tt(i))return i;{const t=i(e);if(void 0!==t)return t}}return t.getImageRotation(e)}updateRotation(){const t=this._object;if(t){const e=this._theme,i=this._parent.state,s=this.toRotation(e,i);if(null!=s){const e=t.transform;if(e.rotation!==s)return e.rotation=s,!0}}return!1}updateSource(){const e=this.computeSource(),i=this._computed;if(e!==i){this._computed=e;const s=this._parent,n=this._object,o=this._onUpdateBound;if(e instanceof t.Texture)if(i instanceof t.Texture)i.off("update",o),n instanceof t.Sprite&&(n.texture=e,e.on("update",o));else{null!=n&&s.removeChild(n);const i=new t.Sprite(e);i.anchor.set(.5,.5);const r=s.getOverflowMask();r&&(i.mask=r),e.on("update",o),s.addChild(i),this._object=i}else{if(i instanceof t.Texture?(i.off("update",o),null!=n&&(s.removeChild(n),n.destroy())):null!=n&&s.removeChild(n),null!=e){const t=s.getOverflowMask();t&&(e.mask=t),s.addChild(e)}this._object=e}return!0}return!1}isRefitable(t){return null!=t&&t===this._object}destroy(){this.source=null}onUpdate(){this._parent.toDirty(),ot.update(this._parent)}}class Ia{constructor(t,e,i){this._parent=t,this._theme=e;const s=[];if(this._pieces=s,null!=i){const t=i.images;if(null!=t){if(s.push(this.newImage(e,0<t.length?t[0]:void 0)),(null!=e.getSecondaryImageSource||1<t.length)&&s.push(this.newImage(new ya(e),t[1])),(null!=e.getTertiaryImageSource||2<t.length)&&s.push(this.newImage(new xa(e),t[2])),3<t.length){const i=new Ea(e);for(let e=3,n=t.length;e<n;++e)s.push(this.newImage(i,t[e]))}}else s.push(this.newImage(e,i.image)),null!=e.getSecondaryImageSource&&s.push(this.newImage(new ya(e))),null!=e.getTertiaryImageSource&&s.push(this.newImage(new xa(e)))}else s.push(this.newImage(e)),null!=e.getSecondaryImageSource&&s.push(this.newImage(new ya(e))),null!=e.getTertiaryImageSource&&s.push(this.newImage(new xa(e)))}newImage(t,e){return new ba(this._parent,t,e)}onStateChange(t,e){const i=this._pieces;for(let s=0,n=i.length;s<n;++s)i[s].onStateChange(t,e)}isRefitable(t){const e=this._pieces;for(let i=0,s=e.length;i<s;++i)if(e[i].isRefitable(t))return!0;return!1}update(t){const e=this._pieces;for(let i=0,s=e.length;i<s;++i){const s=e[i];s.updateSource(),s.updateTint(),s.updateRotation(),t.add(s)}}get object(){return this._pieces[0].object}get align(){return this._pieces[0].align}get margin(){return this._pieces[0].margin}get tint(){return this._pieces[0].tint}get source(){return this._pieces[0].source}set source(t){this._pieces[0].source=t}get rotation(){return this._pieces[0].rotation}set rotation(t){this._pieces[0].rotation=t}add(t){const e=this.newImage(this._theme,t);return this._pieces.push(e),e}get(t){const e=this._pieces;return 0<=t&&t<e.length?e[t]:null}remove(t){const e=this._pieces;return 0<=t&&t<e.length&&(e[t].destroy(),!0)}size(){return this._pieces.length}destroy(){const t=this._pieces;for(let e=0,i=t.length;e<i;++e)t[e].destroy()}}class Oa extends wa{init(t){this.getImage(),super.init(t)}get image(){var t;return null!==(t=this._image)&&void 0!==t?t:this._image=this.newImage()}getImage(){var t;return null!==(t=this._image)&&void 0!==t?t:this._image=this.newImage()}newImage(){return new Ia(this,this.theme,this.options)}set image(t){const e=this.image.get(0);null!=e&&(e.source=t)}onStateChange(t,e){super.onStateChange(t,e),this.getImage().onStateChange(t,e)}onReflowTextAndImage(){const t=this.getLayouter();this.getImage().update(t);const e=this.getText();e.update(t);const i=this._auto;t.execute(this._padding,e.align,i.width.isOn?null:this.width,i.height.isOn?null:this.height),t.clear()}isRefitable(t){return!!super.isRefitable(t)||!!this.getImage().isRefitable(t)}getType(){return"DImageBase"}destroy(){const t=this._image;null!=t&&t.destroy(),super.destroy()}}class Aa extends Oa{init(t){var e,i;super.init(t);const s=this.theme;this._isToggle=null!==(e=null==t?void 0:t.toggle)&&void 0!==e?e:s.isToggle(),this._when=Qi(null!==(i=null==t?void 0:t.when)&&void 0!==i?i:s.getWhen(),$r),this.on(nn.tap,t=>{this.onClick(t)}),this.initOnPress();const n=null==t?void 0:t.group;n&&n.add(this)}onShortcut(t){this.state.isActionable&&this.activate(t),super.onShortcut(t)}get isToggle(){return!!this._isToggle}get isGrouped(){return!!this._isGrouped}set isGrouped(t){this._isGrouped=t}initOnPress(){let t=null;const e=()=>{this.state.isPressed=!1,null!=t&&(t.off(nn.up,e),t.off(nn.upoutside,e),t.off(nn.cancel,e),t=null)};this.on(nn.down,()=>{if(this.state.isActionable){this.state.isPressed=!0;const i=ot.getLayer(this);i&&(t=i.renderer.plugins.interaction,null!=t&&(t.on(nn.up,e),t.on(nn.upoutside,e),t.on(nn.cancel,e)))}})}getType(){return"DButton"}onClick(t){this._when===$r.CLICKED&&this.state.isActionable&&this.activate(t)}onDblClick(t,e){return this._when===$r.DOUBLE_CLICKED&&this.state.isActionable&&this.activate(t),super.onDblClick(t,e)}activate(t){this._isToggle?this._isGrouped&&this.state.isActive||(this.onToggleStart(t),this.onToggleEnd(t)):this.onActivate(t)}onActivate(t){this.emit("active",this)}onInactivate(t){this.emit("inactive",this)}toggle(){this.state.isActionable&&this._isToggle&&(this.onToggleStart(),this.onToggleEnd())}onToggleStart(t){this.state.isActive=!this.state.isActive}onToggleEnd(t){this.state.isActive?this.onActivate(t):this.onInactivate(t)}onActivateKeyDown(t){this.state.isActionable&&(this._isToggle?this.onToggleStart(t):this.state.isPressed=!0)}onActivateKeyUp(t){this.state.isActionable&&(this._isToggle?this.onToggleEnd(t):(this.state.isPressed&&this.onActivate(t),this.state.isPressed=!1))}onKeyDown(t){return $n.isActivateKey(t)&&this.onActivateKeyDown(t),super.onKeyDown(t)}onKeyUp(t){return $n.isActivateKey(t)&&this.onActivateKeyUp(t),super.onKeyUp(t)}onStateChange(t,e){super.onStateChange(t,e),t.isPressed?e.isPressed||this.onPress():e.isPressed&&this.onUnpress()}onPress(){this.emit("press",this)}onUnpress(){this.emit("unpress",this)}destroy(){var t,e;null===(e=null===(t=this._options)||void 0===t?void 0:t.group)||void 0===e||e.remove(this),super.destroy()}}class Ra extends Aa{getType(){return"DButton"}}class Ma extends Ra{getType(){return"DButtonPrimary"}}class ka extends Xr{getType(){return"DLayoutHorizontal"}}class La extends ka{constructor(t,e){super(e),this._parent=t}init(t){super.init(t);const e=this.newChildren();if(0<e.length)for(let t=0,i=e.length;t<i;++t){const i=e[t];null!=i&&this.addChild(i)}}newChildren(){return[this.buttonSpaceLeft,this.buttonCancel,this.buttonOk,this.buttonSpaceRight]}get buttonSpaceLeft(){let t=this._buttonSpaceLeft;return void 0===t&&(t=this.newButtonSpaceLeft(),this._buttonSpaceLeft=t),t}newButtonSpaceLeft(){var t,e,i,s;return(null!==(s=null===(i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.space)||void 0===i?void 0:i.left)&&void 0!==s?s:this.theme.isButtonSpaceLeftEnabled())?new Wr({weight:1}):null}get buttonSpaceRight(){let t=this._buttonSpaceRight;return void 0===t&&(t=this.newButtonSpaceRight(),this._buttonSpaceRight=t),t}newButtonSpaceRight(){var t,e,i,s;return(null!==(s=null===(i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.space)||void 0===i?void 0:i.right)&&void 0!==s?s:this.theme.isButtonSpaceRightEnabled())?new Wr({weight:1}):null}get buttonCancel(){let t=this._buttonCancel;return void 0===t&&(t=this.newButtonCancel(),this._buttonCancel=t),t}newButtonCancel(){var t,e;let i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.cancel;return void 0===i&&(i=this.theme.getButtonCancel()),null!=i?new Ma({text:{value:i},on:{active:()=>{this._parent.cancel()}}}):null}get buttonOk(){let t=this._buttonOk;return void 0===t&&(t=this.newButtonOk(),this._buttonOk=t),t}newButtonOk(){var t,e;let i=null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.ok;return void 0===i&&(i=this.theme.getButtonOk()),null!=i?null!=this.buttonCancel?new Ra({text:{value:i},on:{active:()=>{this._parent.ok()}}}):new Ma({text:{value:i},on:{active:()=>{this._parent.ok()}}}):null}getType(){return"DDialogLayeredFooter"}}class Na extends Ra{getType(){return"DButtonAmbient"}}class Pa extends Na{getType(){return"DDialogLayeredHeaderButtonClose"}}class Ba extends Oa{getType(){return"DDialogLayeredHeaderSeparator"}}class za extends Oa{constructor(t,e){super(e),this._parent=t;const i=this.separator;i&&this.addChild(i);const s=this.buttonClose;s&&(this.addChild(s),s.on("active",()=>{this._parent.cancel()}))}get buttonClose(){let t=this._buttonClose;return void 0===t&&(t=this.newButtonClose(),this._buttonClose=t),t}newButtonClose(){var t,e;return!1!==(null===(e=null===(t=this._options)||void 0===t?void 0:t.button)||void 0===e?void 0:e.close)?new Pa:null}get separator(){let t=this._separator;return void 0===t&&(t=this.newSeparator(),this._separator=t),t}newSeparator(){var t;return!1!==(null===(t=this._options)||void 0===t?void 0:t.separator)?new Ba:null}getType(){return"DDialogLayeredHeader"}}class Ua extends Gr{init(t){super.init(t),this.addChild(this.layout)}get layout(){let t=this._layout;return null==t&&(t=this.newLayout(),this._layout=t),t}newLayout(){return new Yr(this.toLayoutOptions(this.theme,this._options))}toLayoutOptions(t,e){var i,s;const n=null!==(s=null!==(i=null==e?void 0:e.layout)&&void 0!==i?i:t.getLayout())&&void 0!==s?s:this.newLayoutOptions(t,e);return void 0===n.children&&(n.children=this.newLayoutChildren(t,e)),n}newLayoutOptions(t,e){return{width:"padding",height:"auto",margin:0}}newLayoutChildren(t,e){return[this.header,this.content,this.footer]}get header(){let t=this._header;return void 0===t&&(t=this.newHeader(),this._header=t),t}newHeader(){const t=this.toHeaderOptions(this.theme,this._options);return null!==t?new za(this,t):null}toHeaderOptions(t,e){if(e){const t=e.header;if(void 0!==t)return t}return t.getHeader()}get content(){let t=this._content;return null==t&&(t=this.newContent(),this._content=t),t}newContent(){return new jr(this.toContentOptions(this.theme,this._options))}toContentOptions(t,e){var i,s;const n=null!==(s=null!==(i=null==e?void 0:e.content)&&void 0!==i?i:t.getContent())&&void 0!==s?s:{};return void 0===n.children&&(n.children=this.newContentChildren(t,e)),n}newContentChildren(t,e){return[]}get footer(){let t=this._footer;return void 0===t&&(t=this.newFooter(),this._footer=t),t}newFooter(){const t=this.toFooterOptions(this.theme,this._options);return null!==t?new La(this,t):null}toFooterOptions(t,e){if(e){const t=e.footer;if(void 0!==t)return t}return t.getFooter()}findFirstFocusable(t){return t.find(this.content,!1,!0,!0)}ok(){this.onOk(this.getResolvedValue())}onOk(t){this.doResolve(t),this.emit("ok",t,this)}cancel(){this.onCancel(this.getRejectReason())}onCancel(t){this.doReject(t),this.emit("cancel",t,this)}getRejectReason(){}getType(){return"DDialogLayered"}}class Fa extends Ua{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.inputLayout),i}toInputMargin(t,e){var i,s;return null!==(s=null===(i=null==e?void 0:e.input)||void 0===i?void 0:i.margin)&&void 0!==s?s:t.getInputMargin()}get inputLayout(){let t=this._inputLayout;return null==t&&(t=this.newInputLayout(),this._inputLayout=t),t}newInputLayout(){const t=this.toInputMargin(this.theme,this._options);return new ka({width:"padding",height:"auto",margin:0,children:[new Wr({width:t}),this.input,new Wr({width:t})]})}get input(){let t=this._input;if(null==t){const e=this._options;t=this.newInput(null==e?void 0:e.input),this._input=t}return t}get value(){return this.input.value}set value(t){this.input.value=t}getResolvedValue(){return this.input.value}getType(){return"DDialogInput"}}class Ha extends t.utils.EventEmitter{constructor(t){super(),this._buttons=[],this._active=null,this._onActiveBound=t=>{this.active=t};const e=null==t?void 0:t.on;if(null!=e)for(const t in e){const i=e[t];i&&this.on(t,i)}this.emit("init",this)}add(t){if(this._buttons.indexOf(t)<0){this._buttons.push(t),t.isGrouped=!0;const e=this._isEnabled;null!=e&&(t.state.isEnabled=e),t.on("active",this._onActiveBound),t.state.isActive&&(this.active=t)}}get active(){return this._active}set active(t){if((null==t||t.isToggle)&&this._active!==t){const e=this._active;this._active=t;const i=this._buttons;for(let e=0,s=i.length;e<s;++e){const s=i[e];s!==t&&s.isToggle&&s.state.isActive&&s.toggle()}this.emit("active",t,e,this)}}remove(t){const e=this._buttons,i=e.indexOf(t);0<=i&&(e.splice(i,1),t.isGrouped=!1,t.off("active",this._onActiveBound),this._active===t&&(this.active=null))}contains(t){return 0<=this._buttons.indexOf(t)}clear(){const t=this._buttons;for(let e=0,i=t.length;e<i;++e)t[e].isGrouped=!1;t.length=0,this.active=null}size(){return this._buttons.length}each(t){const e=this._buttons;for(let i=0,s=e.length;i<s&&!1!==t(e[i]);++i);}disable(){const t=this._buttons;for(let e=0,i=t.length;e<i;++e)t[e].state.isDisabled=!0;this._isEnabled=!1}enable(){const t=this._buttons;for(let e=0,i=t.length;e<i;++e)t[e].state.isDisabled=!1;this._isEnabled=!0}destroy(){this.clear()}}class Ga extends Ra{getType(){return"DInputBooleanButtonOff"}}class Va extends Ra{getType(){return"DInputBooleanButtonOn"}}class Wa extends ka{constructor(t){super(t),this._lockCount=0,this.addChild(this.getButtonOff()),this.addChild(this.getButtonOn());const e=null==t?void 0:t.value;null!=e&&(this.value=e),this.getButtonGroup().on("active",()=>{if(this._lockCount<=0){const t=this.value;this.emit("change",t,!t,this)}})}getButtonGroup(){let t=this._buttonGroup;return null==t&&(t=this.newButtonGroup(),this._buttonGroup=t),t}newButtonGroup(){return new Ha}getButtonOn(){let t=this._buttonOn;return null==t&&(t=this.newButtonOn(),this._buttonOn=t),t}newButtonOn(){return new Va({weight:1,group:this.getButtonGroup()})}getButtonOff(){let t=this._buttonOff;return null==t&&(t=this.newButtonOff(),this._buttonOff=t),t}newButtonOff(){return new Ga({weight:1,group:this.getButtonGroup(),state:lt.ACTIVE})}get value(){return this.getButtonOn().state.isActive}set value(t){if(this.value!==t){this._lockCount+=1;try{t?this.getButtonOn().activate():this.getButtonOff().activate()}catch(t){}this._lockCount-=1}}getType(){return"DInputBoolean"}}class Ka extends Fa{newInput(t){return new Wa(this.toInputOptions(t))}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputBoolean"}}class Xa extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target),this.onInputAction=t.onInputAction,this.isOpened=!1,this.step=fe.ofNumberOrNull(t.step),this.min=fe.ofNumberOrNull(t.min),this.max=fe.ofNumberOrNull(t.max)}execute(t,e,i){if(!this.isOpened&&this.condition(t,i,ge)){const e=this.target(t,i,ge);if(null!=e){const s=this.initial(t,i,ge),n=this.step(t,i,ge),o=this.min(t,i,ge),r=this.max(t,i,ge);this.isOpened=!0,setTimeout(()=>{this.open(t,e,s,n,o,r).then(s=>{this.isOpened=!1,dr.execute(t,this.onInputAction,e,s,i)},()=>{this.isOpened=!1})},0)}}}}class Ya extends Xa{constructor(t){super(t),this.initial=fe.ofBooleanOrFalse(t.initial)}open(t,e,i,s,n,o){let r=Ya.DIALOG;if(null==r)r=new Ka({header:{text:{value:e},button:{close:!1}}}),Ya.DIALOG=r;else{const t=r.header;t&&(t.text=e)}return r.value=i,r.open(t)}}class ja extends Oa{getUtil(){let t=this._util;return null==t&&(t=this.newUtil(),this._util=t),t}newUtil(){return new sr(this,this.newOperation(),this.theme,this._options)}newOperation(){return{getElementRect:(t,e,i)=>this.getElementRect(t,e,i),getElementMatrix:()=>null,getClipperRect:(t,e,i)=>this.getClipperRect(t,e,i),getPadding:()=>this.padding,containsPoint:t=>this.containsPoint(t),onStart:()=>{},onCancel:()=>{},onEnd:()=>{}}}get element(){return this.getUtil().element}onDownThis(t){const e=this.getUtil();e.onDowning(t),super.onDownThis(t),e.onDown(t)}onDblClick(t,e){return this.getUtil().onDblClick(t,e),super.onDblClick(t,e)}onFocus(){super.onFocus(),this.getUtil().onFocus()}onBlur(){super.onBlur(),this.getUtil().onBlur()}start(){this.getUtil().start()}render(t){this.getUtil().onRender(t),super.render(t)}getElementRect(t,e,i){return e.set(0,0),this.toGlobal(e,e,!1),i.x=e.x,i.y=e.y,e.set(this.width,this.height),this.toGlobal(e,e,!0),i.width=e.x-i.x,i.height=e.y-i.y,i}getClipperRect(t,e,i){return sr.getClipperRect(this.parent,this,t,e,i)}cancel(){this.getUtil().cancel()}end(){this.getUtil().end()}select(){return this.getUtil().select(),this}onActivateKeyDown(t){this.state.isActionable&&(this.state.isPressed=!0)}onActivateKeyUp(t){this.state.isActionable&&(this.state.isPressed&&this.start(),this.state.isPressed=!1)}onKeyDown(t){return $n.isActivateKey(t)&&this.onActivateKeyDown(t),super.onKeyDown(t)}onKeyUp(t){return $n.isActivateKey(t)&&this.onActivateKeyUp(t),super.onKeyUp(t)}getType(){return"DHtmlElement"}}class $a extends ja{newOperation(){return{getElementRect:(t,e,i)=>this.getElementRect(t,e,i),getElementMatrix:()=>null,getClipperRect:(t,e,i)=>this.getClipperRect(t,e,i),getPadding:()=>this.padding,containsPoint:t=>this.containsPoint(t),onStart:()=>{this.text.hide()},onCancel:()=>{this.text.show()},onEnd:()=>{},getValue:()=>this.text.computed,onValueInput:t=>{this.onValueInput(t)},onValueChange:(t,e)=>{this.text=t,this.onValueChange(t,e)},onEnter:()=>{this.onEnter()},applyTitle:()=>{this.applyTitle()}}}get value(){return this.text.computed}set value(t){this.text=t}newText(){const t=super.newText();return t.on("change",()=>{this.validate()}),t}onValueChange(t,e){this.emit("change",t,e,this)}onValueInput(t){this.emit("input",t,this)}onEnter(){this.emit("enter",this)}validate(){return this.getUtil().validate()}applyTitle(){this.getUtil().applyTitle()||super.applyTitle()}getType(){return"DInput"}}class qa extends $a{getType(){return"DInputInput"}}class Za extends qa{newUtil(){return new cr(this,this.newOperation(),this.theme,this._options)}get step(){return this.getUtil().step}set step(t){this.getUtil().step=t}get min(){return this.getUtil().min}set min(t){this.getUtil().min=t}get max(){return this.getUtil().max}set max(t){this.getUtil().max=t}}class Ja extends Za{getType(){return"DInputInteger"}}class Qa extends Fa{newInput(t){const e=new Ja(this.toInputOptions(t));return e.on("enter",()=>{this.ok()}),e}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputInteger"}}class th extends Xa{constructor(t){super(t),this.initial=fe.ofNumber(t.initial)}open(t,e,i,s,n,o){let r=th.DIALOG;if(null==r)r=new Qa({header:{text:{value:e},button:{close:!1}},input:{step:s,min:n,max:o,text:{value:i}}}),th.DIALOG=r;else{const t=r.header;t&&(t.text=e);const a=r.input;a.step=s,a.min=n,a.max=o,r.value=i}return r.open(t)}}class eh extends Za{getType(){return"DInputReal"}}class ih extends Fa{newInput(t){const e=new eh(this.toInputOptions(t));return e.on("enter",()=>{this.ok()}),e}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputReal"}}class sh extends Xa{constructor(t){super(t),this.initial=fe.ofNumber(t.initial)}open(t,e,i,s,n,o){let r=sh.DIALOG;if(null==r)r=new ih({header:{text:{value:e},button:{close:!1}},input:{step:s,min:n,max:o,text:{value:i}}}),sh.DIALOG=r;else{const t=r.header;t&&(t.text=e);const a=r.input;a.step=s,a.min=n,a.max=o,r.value=i}return r.open(t)}}class nh extends qa{newUtil(){return new vr(this,this.newOperation(),this.theme,this._options)}getType(){return"DInputText"}}class oh extends Fa{newInput(t){const e=new nh(this.toInputOptions(t));return e.on("enter",()=>{this.ok()}),e}toInputOptions(t){return t?(void 0===t.weight&&(t.weight=1),t):{weight:1}}getType(){return"DDialogInputText"}}class rh extends Xa{constructor(t){super(t),this.initial=fe.ofString(t.initial)}open(t,e,i,s,n,o){let r=rh.DIALOG;if(null==r)r=new oh({header:{text:{value:e},button:{close:!1}}}),rh.DIALOG=r;else{const t=r.header;t&&(t.text=e)}return r.value=i,r.open(t)}}class ah extends jr{getType(){return"DDialogFittedContent"}}class hh extends Ua{newLayoutOptions(t,e){return{width:"auto",height:"auto",margin:0}}newContent(){return new ah(this.toContentOptions(this.theme,this._options))}getType(){return"DDialogFitted"}}class lh extends Na{getType(){return"DPickerDatetimeButtonBack"}}class ch extends Na{getType(){return"DPickerDatetimeButtonDate"}}class uh extends Na{getType(){return"DPickerDatetimeButtonNext"}}class dh extends wa{getType(){return"DText"}}class ph extends dh{getType(){return"DPickerDatetimeLabel"}}class _h extends dh{getType(){return"DPickerDatetimeLabelDate"}}class gh extends to{constructor(t){super(t),this.renderable=!1}getType(){return"DPickerDatetimeSpace"}}const fh={NONE:0,DATE:1,HOURS:2,MINUTES:4,SECONDS:8,TIME:14,ALL:15};class mh{static from(t,e){const i=null==e?void 0:e.mask;if(null==i){if(Et(t)){const e=$.getInstance().get(t);if(null!=e)return e.getMask()}else if(null!=t)return t.getMask();return fh.NONE}if(Et(i))return fh[i];if(wt(i))return i;let s=fh.NONE;for(let t=0,e=i.length;t<e;++t)s|=fh[i[t]];return s}}class vh{constructor(t,e){var i,s;this._date=null!==(i=null==t?void 0:t.date)&&void 0!==i?i:null,this._inclusive=null!==(s=null==t?void 0:t.inclusive)&&void 0!==s&&s,this._onChange=e}get date(){return this._date}set date(t){this._date!==t&&(this._date=t,this._onChange())}get inclusive(){return this._inclusive}set inclusive(t){this._inclusive!==t&&(this._inclusive=t,this._onChange())}}class Th{constructor(t){this._parent=t}min(t){const e=this._parent,i=e.lower,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(s.getFullYear()<t.getFullYear())return n.hour.min;if(s.getMonth()<t.getMonth())return n.hour.min;if(s.getDate()<t.getDate())return n.hour.min}const r=s.getHours();return i.inclusive||o&fh.SECONDS&&s.getSeconds()<n.second.max||o&fh.MINUTES&&s.getMinutes()<n.minute.max?r:r+1}return n.hour.min}max(t){const e=this._parent,i=e.upper,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(t.getFullYear()<s.getFullYear())return n.hour.max;if(t.getMonth()<s.getMonth())return n.hour.max;if(t.getDate()<s.getDate())return n.hour.max}const r=s.getHours();return i.inclusive||o&fh.SECONDS&&n.second.min<s.getSeconds()||o&fh.MINUTES&&n.minute.min<s.getMinutes()?r:r-1}return n.hour.max}}class wh{constructor(t){this._parent=t}min(t){const e=this._parent,i=e.lower,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(s.getFullYear()<t.getFullYear())return n.minute.min;if(s.getMonth()<t.getMonth())return n.minute.min;if(s.getDate()<t.getDate())return n.minute.min}if(o&fh.HOURS&&s.getHours()<t.getHours())return n.minute.min;const r=s.getMinutes();return i.inclusive||o&fh.SECONDS&&s.getSeconds()<n.second.max?r:r+1}return n.minute.min}max(t){const e=this._parent,i=e.upper,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(t.getFullYear()<s.getFullYear())return n.minute.max;if(t.getMonth()<s.getMonth())return n.minute.max;if(t.getDate()<s.getDate())return n.minute.max}if(o&fh.HOURS&&t.getHours()<s.getHours())return n.minute.max;const r=s.getMinutes();return i.inclusive||o&fh.SECONDS&&n.second.min<s.getSeconds()?r:r-1}return n.minute.max}}class Eh{constructor(t){this._parent=t}min(t){const e=this._parent,i=e.lower,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(s.getFullYear()<t.getFullYear())return n.second.min;if(s.getMonth()<t.getMonth())return n.second.min;if(s.getDate()<t.getDate())return n.second.min}return o&fh.HOURS&&s.getHours()<t.getHours()||o&fh.MINUTES&&s.getMinutes()<t.getMinutes()?n.second.min:s.getSeconds()+(i.inclusive?0:1)}return n.second.min}max(t){const e=this._parent,i=e.upper,s=i.date,n=e.constant;if(null!=s){const o=e.mask;if(o&fh.DATE){if(t.getFullYear()<s.getFullYear())return n.second.max;if(t.getMonth()<s.getMonth())return n.second.max;if(t.getDate()<s.getDate())return n.second.max}return o&fh.HOURS&&t.getHours()<s.getHours()||o&fh.MINUTES&&t.getMinutes()<s.getMinutes()?n.second.max:s.getSeconds()-(i.inclusive?0:1)}return n.second.max}}class yh{constructor(t,e){this.constant=this.newConstant(),this.lower=new vh(t&&t.lower,e),this.upper=new vh(t&&t.upper,e),this.mask=fh.ALL,this.hours=new Th(this),this.minutes=new wh(this),this.seconds=new Eh(this)}newConstant(){return{second:{min:0,max:59},minute:{min:0,max:59},hour:{min:0,max:23}}}adjust(t){const e=this.test(t);if(e<0){const e=this.lower,i=e.date;if(i){if(t.setTime(i.getTime()),!e.inclusive){const e=this.mask;e&fh.SECONDS?t.setSeconds(i.getSeconds()+1):e&fh.MINUTES?t.setMinutes(i.getMinutes()+1):e&fh.HOURS?t.setHours(i.getHours()+1):e&fh.DATE&&t.setDate(i.getDate()+1)}return!0}}else if(0<e){const e=this.upper,i=e.date;if(i){if(t.setTime(i.getTime()),!e.inclusive){const e=this.mask;e&fh.SECONDS?t.setSeconds(i.getSeconds()-1):e&fh.MINUTES?t.setMinutes(i.getMinutes()-1):e&fh.HOURS?t.setHours(i.getHours()-1):e&fh.DATE&&t.setDate(i.getDate()-1)}return!0}}return!1}compare(t,e){const i=this.mask;if(i&fh.DATE){const i=t.getFullYear(),s=e.getFullYear();if(i!==s)return i<s?-1:1;const n=t.getMonth(),o=e.getMonth();if(n!==o)return n<o?-1:1;const r=t.getDate(),a=e.getDate();if(r!==a)return r<a?-1:1}if(i&fh.HOURS){const i=t.getHours(),s=e.getHours();if(i!==s)return i<s?-1:1}if(i&fh.MINUTES){const i=t.getMinutes(),s=e.getMinutes();if(i!==s)return i<s?-1:1}if(i&fh.SECONDS){const i=t.getSeconds(),s=e.getSeconds();if(i!==s)return i<s?-1:1}return 0}test(t){const e=this.lower,i=e.date;if(null!=i){const s=this.compare(i,t);return e.inclusive?s<=0?0:-1:s<0?0:-1}const s=this.upper,n=s.date;if(null!=n){const e=this.compare(t,n);return s.inclusive?e<=0?0:1:e<0?0:1}return 0}contains(t){return 0===this.test(t)}}const xh=(t,e,i)=>{if(t){const s=t.date,n=t.inclusive;return{date:void 0!==s?s:e,inclusive:void 0!==n?n:i}}return{date:e,inclusive:i}};class Ch extends to{constructor(t){super(t),this.onNewChange()}init(t){var e;super.init(t);const i=this.theme;this._dateCurrent=new Date;const s=this._dateCurrent.getTime();this._dateNew=new Date(s),this._dateBounds=new yh(((t,e)=>e?{lower:xh(e.lower,t.getLowerBound(),t.isLowerBoundInclusive()),upper:xh(e.upper,t.getUpperBound(),t.isUpperBoundInclusive())}:{lower:{date:t.getLowerBound(),inclusive:t.isLowerBoundInclusive()},upper:{date:t.getUpperBound(),inclusive:t.isUpperBoundInclusive()}})(i,null==t?void 0:t.bounds),()=>{this.onNewChange()});const n=null!==(e=null==t?void 0:t.margin)&&void 0!==e?e:i.getMargin();new Yr({parent:this,x:"padding",y:"padding",width:"auto",height:"auto",margin:n,children:this.newChildren(i,t,n)})}get current(){return this._dateCurrent}set current(t){this._dateCurrent.getTime()!==t.getTime()&&(this._dateCurrent=t)}get new(){return this._dateNew}set new(t){this._dateNew.getTime()!==t.getTime()&&(this._dateNew=t,this.onNewChange())}get bounds(){return this._dateBounds}hasHours(){return null!=this._inputHours}hasMinutes(){return null!=this._inputMinutes}hasSeconds(){return null!=this._inputSeconds}reset(){const t=this._dateCurrent.getTime();this._dateNew.setTime(t),this.onReset()}onReset(){this.onNewChange()}onNewChange(){const t=this._dateNew,e=this._dateBounds;e.adjust(this._dateNew);const i=this._inputHours;if(i){const s=e.hours;i.value=t.getHours(),i.min=s.min(t),i.max=s.max(t)}const s=this._inputMinutes;if(s){const i=e.minutes;s.value=t.getMinutes(),s.min=i.min(t),s.max=i.max(t)}const n=this._inputSeconds;if(n){const i=e.seconds;n.value=t.getSeconds(),n.min=i.min(t),n.max=i.max(t)}}newChildren(t,e,i){const s=mh.from(t,e);return this._dateBounds.mask=s,this._inputHours=s&fh.HOURS?this.newInputHours(t,e):null,this._inputMinutes=s&fh.MINUTES?this.newInputMinutes(t,e):null,this._inputSeconds=s&fh.SECONDS?this.newInputSeconds(t,e):null,[this.newTimeLayout(this._inputHours,this._inputMinutes,this._inputSeconds,i)]}newTimeLayout(t,e,i,s){const n=this.newTimeLayoutChildren(t,e,i);return 0<n.length?new ka({width:this.getTimeLayoutWidth(),height:this.getTimeLayoutHeight(),margin:s,children:n}):null}getTimeLayoutWidth(){return"auto"}getTimeLayoutHeight(){return"auto"}newTimeLayoutChildren(t,e,i){const s=[];return null!=t&&s.push(t),null!=e&&(0<s.length&&s.push(this.newMinuteSeparator()),s.push(e)),null!=i&&(0<s.length&&s.push(this.newSecondSeparator()),s.push(i)),s}newMinuteSeparator(){return new dh({width:"auto",text:{value:this.getMinuteSeparator()}})}getMinuteSeparator(){return":"}newSecondSeparator(){return new dh({width:"auto",text:{value:this.getSecondSeparator()}})}getSecondSeparator(){return":"}adjustInputOptions(t,e,i){return null==e.step&&(e.step=1),null==e.min&&(e.min=0),null==e.max&&(e.max=i),e}newInputHours(t,e){var i;const s=null!==(i=null==e?void 0:e.hours)&&void 0!==i?i:t.getHoursOptions(),n=this._dateBounds.constant.hour.max,o=new Ja(this.adjustInputOptions(t,s,n));return o.on("change",t=>{this.onHoursChange(t)}),o}onHoursChange(t){this._dateNew.setHours(t),this.onNewChange()}newInputMinutes(t,e){const i=(null==e?void 0:e.minutes)||t.getMinutesOptions(),s=this._dateBounds.constant.minute.max,n=new Ja(this.adjustInputOptions(t,i,s));return n.on("change",t=>{this.onMinutesChange(t)}),n}onMinutesChange(t){this._dateNew.setMinutes(t),this.onNewChange()}newInputSeconds(t,e){const i=(null==e?void 0:e.seconds)||t.getSecondsOptions(),s=this._dateBounds.constant.second.max,n=new Ja(this.adjustInputOptions(t,i,s));return n.on("change",t=>{this.onSecondsChange(t)}),n}onSecondsChange(t){this._dateNew.setSeconds(t)}getType(){return"DPickerTime"}}class Dh extends Ch{init(t){super.init(t),this._datePage=new Date(this._dateCurrent.getTime())}newChildren(t,e,i){var s,n;this._dateButtons=this.newDateButtons(t,e),this._dateDecorator=null!==(n=null===(s=null==e?void 0:e.date)||void 0===s?void 0:s.decorator)&&void 0!==n?n:t.getDateDecorator(),this._label=this.newLabel(t,e);const o=super.newChildren(t,e,i);return o.unshift(new ka({width:"100%",height:"auto",children:[this.newBackButton(t,e),this._label,this.newNextButton(t,e)]}),new ka({width:"auto",height:"auto",margin:i,children:this.newDateLabels(t,e)}),new Yr({width:"auto",height:"auto",margin:i,column:7,children:this._dateButtons})),o}get page(){return this._datePage}set page(t){this._datePage.getTime()!==t.getTime()&&(this._datePage=t,this.onPageChange())}onReset(){this._datePage.setTime(this._dateCurrent.getTime()),super.onReset()}next(){const t=this._datePage;t.setFullYear(t.getFullYear(),t.getMonth()+1,1),t.setHours(0,0,0,0),this.onPageChange()}back(){const t=this._datePage;t.setFullYear(t.getFullYear(),t.getMonth()-1,1),t.setHours(0,0,0,0),this.onPageChange()}onNewChange(){this._dateBounds.adjust(this._datePage),super.onNewChange(),this.onPageChange()}onPageChange(){const t=this._dateButtons,e=this._dateBounds,i=this._datePage,s=this._dateNew,n=new Date(i.getTime());n.setDate(1),n.setHours(0,0,0,0);const o=this.theme,r=(n.getDay()-o.getDayStart()+7)%7;for(let e=0;e<r;++e)t[e].show();for(let e=r;e<7;++e)t[e].hide();const a=this._dateDecorator;n.setFullYear(n.getFullYear(),n.getMonth()+1,0);const h=n.getDate(),l=s.getFullYear()===n.getFullYear()&&s.getMonth()===n.getMonth()?s.getDate():0;for(let i=0;i<h;++i){n.setDate(i+1);const s=t[i+7];s.state.isActive=l===i+1,s.state.isDisabled=!e.contains(n),s.show(),a(n,s)}for(let e=h;e<31;++e){const i=t[e+7];i.state.isActive=!1,i.hide()}n.setTime(i.getTime()),this._label.text=n}adjustInputOptions(t,e,i){return null==e.weight&&(e.weight=1),super.adjustInputOptions(t,e,i)}getTimeLayoutWidth(){return"100%"}toLabelOptions(t,e){const i=e&&e.label||{};void 0===i.weight&&(i.weight=1),void 0===i.padding&&(i.padding=0);const s=i.text=i.text||{},n=s.align=s.align||{};return void 0===n.horizontal&&(n.horizontal="CENTER"),void 0===s.formatter&&(s.formatter=t.getLabelFormatter()),i}newLabel(t,e){return new ph(this.toLabelOptions(t,e))}newBackButton(t,e){let i=null==e?void 0:e.back;if(void 0===i&&(i=t.getBackButtonOptions()),null!=i){const t=new lh(i);return t.on("active",()=>{this.back()}),t}return null}newNextButton(t,e){let i=null==e?void 0:e.next;if(void 0===i&&(i=t.getNextButtonOptions()),null!=i){const t=new uh(i);return t.on("active",()=>{this.next()}),t}return null}newDateLabels(t,e){const i=t.getDayLabels(),s=t.getDayStart(),n=[];for(let o=0;o<7;++o){const r=i[(s+o)%7];n.push(this.newDateLabel(t,e,r))}return n}newDateLabel(t,e,i){return new _h({text:{value:i}})}newDateButtons(t,e){const i=[];for(let s=0;s<7;++s)i.push(this.newSpace(t,e));for(let s=1;s<=31;++s)i.push(this.newDateButton(t,e,s));return i}newSpace(t,e){return new gh}newDateButton(t,e,i){return new ch({text:{value:String(i)},on:{active:()=>{this.onDateButtonClicked(i)}}})}onDateButtonClicked(t){const e=this._dateNew;if(e.getDate()!==t){const i=this._datePage;e.setFullYear(i.getFullYear()),e.setMonth(i.getMonth()),e.setDate(t),this.onNewChange()}}getType(){return"DPickerDatetime"}}class Sh extends hh{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.picker),i}get current(){return this.picker.current}set current(t){this.picker.current=t}get new(){return this.picker.new}set new(t){this.picker.new=t}get page(){return this.picker.new}set page(t){this.picker.page=t}get picker(){var t;let e=this._picker;return null==e&&(e=new Dh(null===(t=this._options)||void 0===t?void 0:t.picker),this._picker=e),e}getResolvedValue(){return this.picker.new}getType(){return"DDialogDatetime"}}class bh extends Xa{constructor(t){super(t),this.initial=fe.ofUnknown(t.initial)}open(t,e,i,s,n,o){let r=bh.DIALOG;return null==r&&(r=new Sh,bh.DIALOG=r),r.new=r.current=this.toDate(i),r.open(t).then(t=>t.toISOString())}toDate(t){return Et(t)||wt(t)?new Date(t):t instanceof Date?t:new Date}}class Ih extends hh{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.picker),i}get current(){return this.picker.current}set current(t){this.picker.current=t}get new(){return this.picker.new}set new(t){this.picker.new=t}get picker(){var t;let e=this._picker;return null==e&&(e=new Ch(null===(t=this._options)||void 0===t?void 0:t.picker),this._picker=e),e}getResolvedValue(){return this.picker.new}getType(){return"DDialogTime"}}const Oh=t=>t!=t;class Ah extends Xa{constructor(t){super(t),this.initial=fe.ofUnknown(t.initial)}open(t,e,i,s,n,o){let r=Ah.DIALOG;return null==r&&(r=new Ih,Ah.DIALOG=r),r.new=r.current=this.toDate(i),r.open(t).then(t=>this.getFormatter().format(t.getTime(),0))}toDate(t){if(wt(t))return new Date(t);if(Et(t)){const e=new Date,i=this.getPattern().exec(t);if(null!=i){const t=this.toHours(i[1]);null!=t&&e.setHours(t);const s=this.toMinutes(i[2]);null!=s&&e.setMinutes(s);const n=this.toSeconds(i[3]);null!=n&&e.setSeconds(n);const o=this.toMilliseconds(i[4]);null!=o&&e.setMilliseconds(o)}return e}return t instanceof Date?t:new Date}toHours(t){return this.toNumber(t,0,23)}toMinutes(t){return this.toNumber(t,0,59)}toSeconds(t){return this.toNumber(t,0,59)}toMilliseconds(t){const e=this.toNumber(t,0,999);if(null!=e){const i=t.length;return 1===i?100*e:2===i?10*e:e}return e}toNumber(t,e,i){if(null!=t){const s=+t;if(!Oh(s))return Math.min(i,Math.max(e,s))}return null}getPattern(){let t=Ah.PATTERN;return null==t&&(t=this.newPattern(),Ah.PATTERN=t),t}newPattern(){return/^\s*(?:(\d+)(?::(\d+)(?::(\d+))?)?)?(?:\.(\d+))?\s*$/}getFormatter(){let t=Ah.FORMATTER;return null==t&&(t=this.newFormatter(),Ah.FORMATTER=t),t}newFormatter(){return Si.create("%Hm")}}class Rh extends Dh{getType(){return"DPickerDate"}}class Mh extends hh{newContentChildren(t,e){const i=super.newContentChildren(t,e);return i.push(this.picker),i}get current(){return this.picker.current}set current(t){this.picker.current=t}get new(){return this.picker.new}set new(t){this.picker.new=t}get page(){return this.picker.new}set page(t){this.picker.page=t}get picker(){var t;let e=this._picker;return null==e&&(e=new Rh(null===(t=this._options)||void 0===t?void 0:t.picker),this._picker=e),e}getResolvedValue(){return this.picker.new}getType(){return"DDialogDate"}}class kh extends Xa{constructor(t){super(t),this.initial=fe.ofUnknown(t.initial)}open(t,e,i,s,n,o){let r=kh.DIALOG;return null==r&&(r=new Mh,kh.DIALOG=r),r.new=r.current=this.toDate(i),r.open(t).then(t=>this.getFormatter().format(t.getTime(),0))}toDate(t){return Et(t)||wt(t)?new Date(t):t instanceof Date?t:new Date}getFormatter(){let t=kh.FORMATTER;return null==t&&(t=this.newFormatter(),kh.FORMATTER=t),t}newFormatter(){return Si.create("%Y-%M-%D")}}const Lh={TEXT:0,INTEGER:1,REAL:2,BOOLEAN:3,DATE:4,TIME:5,DATETIME:6,EXTENSION:1e3};class Nh extends Ie{constructor(t,e,i,s,n,o,r,a){super(Oe.OPEN,t,Rr.DIALOG),this.target=e,this.onInputAction=i,this.initial=s,this.step=n,this.min=o,this.max=r,this.dialogType=a}isEquals(t){return super.isEquals(t)&&t instanceof Nh&&this.target===t.target&&this.dialogType===t.dialogType&&this.onInputAction===t.onInputAction&&this.initial===t.initial&&this.step===t.step&&this.min===t.min&&this.max===t.max}toRuntime(){switch(this.dialogType){case Lh.TEXT:return new rh(this);case Lh.INTEGER:return new th(this);case Lh.REAL:return new sh(this);case Lh.BOOLEAN:return new Ya(this);case Lh.DATE:return new kh(this);case Lh.TIME:return new Ah(this);case Lh.DATETIME:return new bh(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=t.addResource(this.initial),n=t.addResource(this.step),o=t.addResource(this.min),r=t.addResource(this.max);return t.addResource(`[${this.type},${e},${this.subtype},${i},${this.onInputAction},${s},${this.dialogType},${n},${o},${r}]`)}static deserialize(t,e){const i=e.resources,s=Ae.toResource(1,t,i),n=Ae.toResource(3,t,i),o=Ae.toResource(5,t,i),r=Ae.toResource(7,t,i),a=Ae.toResource(8,t,i),h=Ae.toResource(9,t,i);return new Nh(s,n,t[4],o,r,a,h,this.toDialogType(t))}static toDialogType(t){if(t[2]===Rr.DIALOG)return t[6];switch(t[2]){case Rr.DIALOG_TEXT:return Lh.TEXT;case Rr.DIALOG_INTEGER:return Lh.INTEGER;case Rr.DIALOG_REAL:return Lh.REAL;case Rr.DIALOG_BOOLEAN:return Lh.BOOLEAN;case Rr.DIALOG_DATE:return Lh.DATE;case Rr.DIALOG_TIME:return Lh.TIME;case Rr.DIALOG_DATETIME:return Lh.DATETIME}}}class Ph{static add(t){var e,i;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._data)&&void 0!==i?i:this._data=[]).push(t)}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Bh extends ve{constructor(t){super(t,pe.NONE),this.target=fe.ofStringOrNull(t.target),this.argument=fe.ofUnknown(t.argument);const e=Ph.get(t.dialogType);e&&(this.opener=e.opener)}execute(t,e,i){const s=this.opener;if(s&&this.condition(t,i,ge)){const e=this.target(t,i,ge);if(null!=e){const n=$o.toDiagram(t);if(null!=n){const o=this.argument(t,i,ge);setTimeout(()=>{s(e,o,t,n,ge)},0)}}}}}class zh extends Ie{constructor(t,e,i,s){super(Oe.OPEN,t,Rr.DIALOG),this.target=e,this.argument=i,this.dialogType=s}isEquals(t){return super.isEquals(t)&&t instanceof zh&&this.target===t.target&&this.argument===t.argument&&this.dialogType===t.dialogType}toRuntime(){return new Bh(this)}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=t.addResource(this.argument);return t.addResource(`[${this.type},${e},${this.subtype},${i},0,-1,${this.dialogType},${s}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources),n=Ae.toResource(7,t,e.resources);return new zh(i,s,n,t[6])}}class Uh{static add(t){var e,i;(null!==(e=this._typeToDatum)&&void 0!==e?e:this._typeToDatum=new Map).set(t.type,t),(null!==(i=this._data)&&void 0!==i?i:this._data=[]).push(t),yn[t.type]=t.opener}static get(t){const e=this._typeToDatum;if(null!=e)return e.get(t)}static each(t){const e=this._data;if(null!=e)for(let i=0,s=e.length;i<s;++i)t(e[i])}}class Fh extends Ie{constructor(t,e,i,s){super(Oe.OPEN,e,t),this.target=i,this.inNewWindow=s}isEquals(t){return super.isEquals(t)&&t instanceof Fh&&this.target===t.target&&this.inNewWindow===t.inNewWindow}toRuntime(){return new Ar(this,this.subtype)}toLabel(){const t=this.getTheme().toTypeLabel(this.type),e=Uh.get(this.subtype);return`${t}: ${null!=e?e.label:"Unknown"}`}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.target),s=this.inNewWindow?1:0;return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(3,t,e.resources);return new Fh(t[2],i,s,!!t[4])}}const Hh={SHAPE_SHOW:0,SHAPE_HIDE:1,SHAPE:2,LAYER:3};class Gh extends ve{constructor(t){super(t,pe.VISIBILITY),this.visibility=t.subtype===Hh.SHAPE_SHOW}execute(t,e,i){this.condition(t,i,ge)&&(t.visible=this.visibility,e.written|=this.reset)}}class Vh extends Ie{constructor(t,e){super(Oe.SHOW_HIDE,e,t)}toRuntime(){return new Gh(this)}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources);return new Vh(t[2],i)}}class Wh extends ve{constructor(t){super(t,pe.NONE),this._data=new Map,this._layers=t.layers,this._bringToFront=t.bringToFront}initialize(t,e){super.initialize(t,e);let i=this._data.get(t);null==i&&(i=this.newData(t),null!=i&&this._data.set(t,i))}execute(t,e,i){const s=this._data.get(t);if(s){const e=this.condition(t,i,ge);if(s.condition!==e){s.condition=e;const t=s.layers;e?s.bringToFront?(tn.bringAllToFront(t),tn.showAll(t)):tn.showAll(t):tn.hideAll(t)}}}newData(t){const e=tn.toLayers(t,this._layers);if(0<e.length)return{layers:e,bringToFront:this._bringToFront,condition:null}}}class Kh extends Ie{constructor(t,e,i){super(Oe.SHOW_HIDE,t,Hh.LAYER),this.layers=e,this.bringToFront=i}toRuntime(){return new Wh(this)}serialize(t){const e=t.addResource(this.condition),i=this.serializeLayers(t),s=this.bringToFront?1:0;return t.addResource(`[${this.type},${e},${this.subtype},${i},${s}]`)}serializeLayers(t){const e=this.layers;let i="[",s="";for(let t=0,n=e.length;t<n;++t)i+=s+e[t],s=",";return i+="]",t.addResource(i)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=this.deserializeLayers(t[3],e),n=!!t[4];return new Kh(i,s,n)}static deserializeLayers(t,e){const i=e.resources,s=i.length;return 0<=t&&t<s?JSON.parse(i[t]):[]}}class Xh extends ve{constructor(t){super(t,pe.VISIBILITY)}initialize(t,e){super.initialize(t,e)}execute(t,e,i){t.visible=this.condition(t,i,ge),e.written|=this.reset}}class Yh extends Ie{constructor(t){super(Oe.SHOW_HIDE,t,Hh.SHAPE)}toRuntime(){return new Xh(this)}serialize(t){const e=t.addResource(this.condition);return t.addResource(`[${this.type},${e},${this.subtype}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources);return new Yh(i)}}class jh extends ve{constructor(t,e){super(t,e),this.amount=fe.ofNumber(t.amount)}}class $h extends jh{constructor(t){super(t,pe.POSITION_X)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge);t.transform.position.x=s,e.written|=this.reset}}}class qh extends jh{constructor(t){super(t,pe.POSITION_Y)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge);t.transform.position.y=s,e.written|=this.reset}}}class Zh extends jh{constructor(t){super(t,pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=n.position,r=!!(e.written&pe.POSITION_X),a=!!(e.written&pe.POSITION_Y),h=r?o.x:e.x,l=a?o.y:e.y;t.updateTransform();const c=n.localTransform;o.set(h-c.c*s,l-c.d*s),e.written|=this.reset}}}class Jh extends jh{constructor(t){super(t,pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=n.position,r=!!(e.written&pe.POSITION_X),a=!!(e.written&pe.POSITION_Y),h=r?o.x:e.x,l=a?o.y:e.y;t.updateTransform();const c=n.localTransform;o.set(h+c.a*s,l+c.b*s),e.written|=this.reset}}}class Qh extends jh{constructor(t){super(t,pe.POSITION_X)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=!!(e.written&pe.POSITION_X),o=t.transform.position,r=n?o.x:e.x;o.x=r+s,e.written|=this.reset}}}class tl extends jh{constructor(t){super(t,pe.POSITION_Y)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=!!(e.written&pe.POSITION_Y),o=t.transform.position,r=n?o.y:e.y;o.y=r+s,e.written|=this.reset}}}class el extends Ie{constructor(t,e,i,s){super(t,e,i),this.opetype=s}isEquals(t){return super.isEquals(t)&&t instanceof el&&this.opetype===t.opetype}}const il={RELATIVE_X:0,RELATIVE_Y:1,ABSOLUTE_X:2,ABSOLUTE_Y:3,FORWARD_OR_BACKWARD:4,LEFT_OR_RIGHT:5},sl={RESIZE:0,MOVE:1,ROTATE:2};class nl extends el{constructor(t,e,i){super(Oe.TRANSFORM,e,sl.MOVE,t),this.amount=i}isEquals(t){return super.isEquals(t)&&t instanceof nl&&this.amount===t.amount}toRuntime(){switch(this.opetype){case il.ABSOLUTE_X:return new $h(this);case il.ABSOLUTE_Y:return new qh(this);case il.FORWARD_OR_BACKWARD:return new Zh(this);case il.LEFT_OR_RIGHT:return new Jh(this);case il.RELATIVE_X:return new Qh(this);case il.RELATIVE_Y:return new tl(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.amount);return t.addResource(`[${this.type},${e},${this.subtype},${this.opetype},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(4,t,e.resources);return new nl(t[3],i,s)}}const ol={RELATIVE_SIZE:0,RELATIVE_HEIGHT:1,RELATIVE_WIDTH:2,ABSOLUTE_SIZE:3,ABSOLUTE_HEIGHT:4,ABSOLUTE_WIDTH:5};class rl extends ve{constructor(t,e){switch(super(t,e),t.opetype){case ol.RELATIVE_SIZE:this.size=fe.ofNumberOrOne(t.amount);break;case ol.ABSOLUTE_SIZE:this.size=fe.ofNumberOrOneHundred(t.amount);break;case ol.RELATIVE_HEIGHT:this.size=fe.ofNumberOrOne(t.amount);break;case ol.ABSOLUTE_HEIGHT:this.size=fe.ofNumberOrOneHundred(t.amount);break;case ol.RELATIVE_WIDTH:this.size=fe.ofNumberOrOne(t.amount);break;case ol.ABSOLUTE_WIDTH:this.size=fe.ofNumberOrOneHundred(t.amount);break;default:this.size=fe.ONE}}adjustPosition(t,e,i,s,n,o){const r=(-.5+n)*i,a=(-.5+o)*s;t.updateTransform();const h=t.transform,l=h.position,c=h.localTransform,u=!!(e.written&pe.POSITION_X),d=!!(e.written&pe.POSITION_Y),p=u?l.x:e.x,_=d?l.y:e.y;e.written|=pe.POSITION,l.set(p+r*c.a+a*c.c,_+r*c.b+a*c.d)}}class al extends rl{constructor(t){super(t,pe.HEIGHT|pe.POSITION),this.origin=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.HEIGHT?n.y:e.sizeY;n.y=Fi(s),e.written|=pe.HEIGHT,this.adjustPosition(t,e,0,o-n.y,.5,this.origin)}}}class hl extends rl{constructor(t){super(t,pe.HEIGHT|pe.POSITION),this.origin=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.HEIGHT?n.y:e.sizeY;n.y=Fi(o*s),e.written|=pe.HEIGHT,this.adjustPosition(t,e,0,o-n.y,.5,this.origin)}}}class ll extends rl{constructor(t){super(t,pe.SIZE|pe.POSITION),this.originX=t.originX,this.originY=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=Fi(this.size(t,i,ge)),n=t.size,o=!!(e.written&pe.WIDTH),r=!!(e.written&pe.HEIGHT),a=o?n.x:e.sizeX,h=r?n.y:e.sizeY;n.set(s,s),e.written|=pe.SIZE,this.adjustPosition(t,e,a-n.x,h-n.y,this.originX,this.originY)}}}class cl extends rl{constructor(t){super(t,pe.SIZE|pe.POSITION),this.originX=t.originX,this.originY=t.originY}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=!!(e.written&pe.WIDTH),r=!!(e.written&pe.HEIGHT),a=o?n.x:e.sizeX,h=r?n.y:e.sizeY;n.set(Fi(a*s),Fi(h*s)),e.written|=pe.SIZE,this.adjustPosition(t,e,a-n.x,h-n.y,this.originX,this.originY)}}}class ul extends rl{constructor(t){super(t,pe.WIDTH|pe.POSITION),this.origin=t.originX}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.WIDTH?n.x:e.sizeX;n.x=Fi(s),e.written|=pe.WIDTH,this.adjustPosition(t,e,o-n.x,0,this.origin,.5)}}}class dl extends rl{constructor(t){super(t,pe.WIDTH|pe.POSITION),this.origin=t.originX}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.size(t,i,ge),n=t.size,o=e.written&pe.WIDTH?n.x:e.sizeX;n.x=Fi(o*s),e.written|=pe.WIDTH,this.adjustPosition(t,e,o-n.x,0,this.origin,.5)}}}class pl extends el{constructor(t,e,i,s,n){super(Oe.TRANSFORM,e,sl.RESIZE,t),this.originX=i,this.originY=s,this.amount=n}isEquals(t){return super.isEquals(t)&&t instanceof pl&&this.originX===t.originX&&this.originY===t.originY&&this.amount===t.amount}toRuntime(){switch(this.opetype){case ol.ABSOLUTE_HEIGHT:return new al(this);case ol.ABSOLUTE_WIDTH:return new ul(this);case ol.ABSOLUTE_SIZE:return new ll(this);case ol.RELATIVE_HEIGHT:return new hl(this);case ol.RELATIVE_WIDTH:return new dl(this);case ol.RELATIVE_SIZE:return new cl(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.amount);return t.addResource(`[${this.type},${e},${this.subtype},${this.opetype},${this.originX},${this.originY},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(6,t,e.resources);return new pl(t[3],i,t[4],t[5],s)}}class _l extends ve{constructor(t,e){super(t,e),this.originX=t.originX,this.originY=t.originY,this.amount=fe.ofNumber(`(${t.amount}) * (Math.PI / 180)`)}adjustPosition(t,e,i,s,n,o){const r=!!(e.written&pe.WIDTH),a=!!(e.written&pe.HEIGHT),h=(-.5+n)*(r?t.size.x:e.sizeX),l=(-.5+o)*(a?t.size.y:e.sizeY),c=Math.sin(i)-Math.sin(s),u=Math.cos(i)-Math.cos(s),d=t.transform.position,p=!!(e.written&pe.POSITION_X),_=!!(e.written&pe.POSITION_Y),g=p?d.x:e.x,f=_?d.y:e.y;e.written|=pe.POSITION,d.set(g+h*u-l*c,f+h*c+l*u)}}class gl extends _l{constructor(t){super(t,pe.ROTATION|pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=e.written&pe.ROTATION?n.rotation:e.rotation;n.rotation=s,e.written|=pe.ROTATION,this.adjustPosition(t,e,o,s,this.originX,this.originY)}}}class fl extends _l{constructor(t){super(t,pe.ROTATION|pe.POSITION)}execute(t,e,i){if(this.condition(t,i,ge)){const s=this.amount(t,i,ge),n=t.transform,o=e.written&pe.ROTATION?n.rotation:e.rotation;n.rotation=o+s,e.written|=pe.ROTATION,this.adjustPosition(t,e,o,n.rotation,this.originX,this.originY)}}}const ml={RELATIVE:0,ABSOLUTE:1};class vl extends el{constructor(t,e,i,s,n){super(Oe.TRANSFORM,e,sl.ROTATE,t),this.originX=i,this.originY=s,this.amount=n}isEquals(t){return super.isEquals(t)&&t instanceof vl&&this.originX===t.originX&&this.originY===t.originY&&this.amount===t.amount}toRuntime(){switch(this.opetype){case ml.ABSOLUTE:return new gl(this);case ml.RELATIVE:return new fl(this)}}serialize(t){const e=t.addResource(this.condition),i=t.addResource(this.amount);return t.addResource(`[${this.type},${e},${this.subtype},${this.opetype},${this.originX},${this.originY},${i}]`)}static deserialize(t,e){const i=Ae.toResource(1,t,e.resources),s=Ae.toResource(6,t,e.resources);return new vl(t[3],i,t[4],t[5],s)}}const Tl=(t,e)=>{switch(t[0]){case Oe.SHOW_HIDE:switch(t[2]){case Hh.SHAPE_SHOW:case Hh.SHAPE_HIDE:return Vh.deserialize(t,e);case Hh.SHAPE:return Yh.deserialize(t,e);case Hh.LAYER:return Kh.deserialize(t,e)}break;case Oe.BLINK:return Re.deserialize(t,e);case Oe.CHANGE_COLOR:case Oe.CHANGE_COLOR_LEGACY:switch(t[3]){case Le.COLOR_AND_ALPHA:case Le.COLOR:case Le.ALPHA:return Ue.deserialize(t,e);case Le.CODE:return Ve.deserialize(t,e);case Le.BRIGHTNESS:return He.deserialize(t,e)}break;case Oe.CHANGE_TEXT:return Ai.deserialize(t,e);case Oe.CHANGE_CURSOR:return Ke.deserialize(t,e);case Oe.EMIT_EVENT:return Zo.deserialize(t,e);case Oe.OPEN:switch(t[2]){case Rr.DIALOG_TEXT:case Rr.DIALOG_INTEGER:case Rr.DIALOG_REAL:case Rr.DIALOG_BOOLEAN:case Rr.DIALOG_DATE:case Rr.DIALOG_TIME:case Rr.DIALOG_DATETIME:case Rr.DIALOG:return Lh.EXTENSION<=t[6]?zh.deserialize(t,e):Nh.deserialize(t,e);case Rr.DIAGRAM_LEGACY:case Rr.PAGE_LEGACY:case Rr.PAGE_INPLACE_LEGACY:case Rr.DIAGRAM:case Rr.PAGE:return Mr.deserialize(t,e);default:if(Rr.EXTENSION<=t[2])return Fh.deserialize(t,e)}break;case Oe.TRANSFORM:switch(t[2]){case sl.MOVE:return nl.deserialize(t,e);case sl.RESIZE:return pl.deserialize(t,e);case sl.ROTATE:return vl.deserialize(t,e)}break;case Oe.GESTURE:return mn.deserialize(t,e);case Oe.MISC:switch(t[2]){case fn.GESTURE:return mn.deserialize(t,e);case fn.SHOW_HIDE_LAYER:return Kh.deserialize(t,e);case fn.GESTURE_LAYER:return mn.deserialize(t,e);case fn.EXECUTE:return Sr.deserialize(t,e);default:return fn.EXTENSION<=t[2]?Or.deserialize(t,e):Cr.deserialize(t,e)}}return null},wl={},El=t=>{try{const e=JSON.parse(t);return vt(e)&&2<=e.length?e:null}catch(t){return null}},yl=(t,e,i)=>{const s=e.resources;if(0<=t&&t<s.length){const e=s[t];Et(e)&&(i.gradient=(t=>{const e=(t=>{try{return JSON.parse(t)}catch(t){return null}})(t);if(!(null==e||e.length<7)){const t=e[0],i=[];for(let t=1,s=e.length;t<s;t+=3)i.push({color:e[t+0],alpha:e[t+1],position:e[t+2]});return{points:i,direction:t}}})(e))}},xl={},Cl=t=>{const e=xl[t];if(null!=e)return"url"in e?Promise.resolve(e):e;{const e=new Promise((e,i)=>{const s=document.createElement("img");s.onload=()=>{const i={url:t,width:s.width,height:s.height,source:s};xl[t]=i,e(i)},s.onabort=s.onerror=()=>{i()},s.src=t});return xl[t]=e,e}},Dl=(t,e,i)=>{const s=e.resources;i.id=s[t[1]]||"";const n=i.transform;n.position.set(t[2],t[3]),n.rotation=t[6],n.skew.set(t[7],t[7]),n.pivot.set(t[21],t[22]),i.size.set(Fi(t[4]),Fi(t[5])),i.fill.deserialize(t[8],e),i.stroke.deserialize(t[9],e);const o=t[10];i.cursor=0<=o?s[o]:void 0,i.text.deserialize(t[11],e),i.data.deserialize(t[12],e),i.radius=t[13],i.corner=t[14];const r=t[23];i.interactive=!!(1&r);const a=i.state;a.isFocusable=!(2&r),a.isActive=!!(4&r);const h=t[24];i.shortcut=0<=h?s[h]:void 0;const l=t[25];i.title=0<=l?s[l]:void 0;const c=t[26];i.uuid=null!=c?c:0;const u=t[27],d=t[28],p=t[29];(null!=u&&u!==Ot.NONE||null!=d&&d!==Ot.NONE||null!=p&&p!==Ot.NONE)&&i.capability.set(u,d,p);const _=((t,e,i)=>{if(0<t.length){const s=[];for(let i=0,n=t.length;i<n;++i)s.push($i(t[i],e));return Promise.all(s).then(t=>{i.children=t;for(let e=0,s=t.length;e<s;++e)t[e].parent=i;return i.onChildTransformChange(),i.toDirty(),i})}return null})(t[20],e,i);((t,e,i)=>{const s=i.action,n=e.resources;for(let i=0,o=t.length;i<o;++i){const o=t[i],r=e.getAction(o);if(null!=r)s.add(r);else{const t=n[o];if(null!=t){const i=El(t);if(null!=i&&0<i.length){const t=i[0],n=Oe.EXTENSION<=t?wl[t]:Tl;if(null!=n){const t=n(i,e);null!=t&&(e.setAction(o,t),s.add(t))}}}}}})(t[17],e,i),yl(t[19],e,i);const g=((t,e,i)=>{const s=e.resources;if(0<=t&&t<s.length){const e=s[t];if(Et(e))return Cl(e).then(t=>(i.image=t,i))}return null})(t[18],e,i);return null!=_?null!=g?Promise.all([_,g]).then(()=>i):_:null!=g?g:i},Sl=(t,e,i)=>{i=i||new ae;const s=Dl(t,e,i);i.points.deserialize(t[15],e);const n=i.points.style,o=F.NON_SCALING_MASK|F.DOTTED_MASK|F.DASHED_MASK,r=n&o;return r&&(i.points.style&=~o,i.stroke.style|=r),s},bl=()=>{n[s.BAR]=ce,e[s.BAR]=Sl},Il=44,Ol=24,Al=[0,0,0,0,0],Rl=new t.Point,Ml=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+2,t[++s]=e+2,t[++s]=e+1,t[++s]=e+3,t[++s]=e+4,t[++s]=e+5,t[++s]=e+6,t[++s]=e+6,t[++s]=e+5,t[++s]=e+7,t[++s]=e+8,t[++s]=e+9,t[++s]=e+10,t[++s]=e+10,t[++s]=e+9,t[++s]=e+11,t[++s]=e+12,t[++s]=e+13,t[++s]=e+14,t[++s]=e+14,t[++s]=e+13,t[++s]=e+15,t[++s]=e+16,t[++s]=e+17,t[++s]=e+19,t[++s]=e+19,t[++s]=e+17,t[++s]=e+20,t[++s]=e+18,t[++s]=e+20,t[++s]=e+21,t[++s]=e+21,t[++s]=e+20,t[++s]=e+22,t[++s]=e+23,t[++s]=e+24,t[++s]=e+25,t[++s]=e+25,t[++s]=e+24,t[++s]=e+26,t[++s]=e+25,t[++s]=e+27,t[++s]=e+28,t[++s]=e+28,t[++s]=e+27,t[++s]=e+29,t[++s]=e+30,t[++s]=e+31,t[++s]=e+32,t[++s]=e+32,t[++s]=e+31,t[++s]=e+34,t[++s]=e+33,t[++s]=e+34,t[++s]=e+35,t[++s]=e+35,t[++s]=e+34,t[++s]=e+36,t[++s]=e+37,t[++s]=e+38,t[++s]=e+39,t[++s]=e+39,t[++s]=e+38,t[++s]=e+41,t[++s]=e+39,t[++s]=e+40,t[++s]=e+42,t[++s]=e+42,t[++s]=e+40,t[++s]=e+43},kl=(t,e,i,s,n,o,r,a,h,l,c)=>{const u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u),_=Math.abs(d),g=Math.abs(p),f=h*Math.min(_,g),m=f/_,v=f/g,T=Rl;T.set(i-d,s-p),l.apply(T,T);const w=T.x,E=T.y;T.set(i,s-p),l.apply(T,T);const y=T.x,x=T.y;T.set(i-d,s),l.apply(T,T);const C=T.x,D=T.y,S=y-w,b=x-E,I=C-w,O=D-E,A=y+S,R=x+b,M=C+S,k=D+b,L=A+I,N=R+O,P=C+I,B=D+O,z=P+S,U=B+b,F=z+S,H=U+b,G=m*S,V=m*b,W=v*I,K=v*O,X=w,Y=E,j=X+G,$=Y+V,q=X+W,Z=Y+K,J=q+G,Q=Z+V;let tt=2*e-1;t[++tt]=X,t[++tt]=Y,t[++tt]=j,t[++tt]=$,t[++tt]=q,t[++tt]=Z,t[++tt]=J,t[++tt]=Q;const et=A,it=R,st=A-G,nt=R-V,ot=st+W,rt=nt+K,at=ot+G,ht=rt+V;t[++tt]=st,t[++tt]=nt,t[++tt]=et,t[++tt]=it,t[++tt]=ot,t[++tt]=rt,t[++tt]=at,t[++tt]=ht;const lt=P,ct=B,ut=lt-W,dt=ct-K,pt=lt+G,_t=ct+V,gt=ut+G,ft=dt+V;t[++tt]=ut,t[++tt]=dt,t[++tt]=gt,t[++tt]=ft,t[++tt]=lt,t[++tt]=ct,t[++tt]=pt,t[++tt]=_t;const mt=F,vt=H,Tt=mt-G,wt=vt-V,Et=mt-W,yt=vt-K,xt=Et-G,Ct=yt-V;t[++tt]=xt,t[++tt]=Ct,t[++tt]=Et,t[++tt]=yt,t[++tt]=Tt,t[++tt]=wt,t[++tt]=mt,t[++tt]=vt;const Dt=j,St=$,bt=y,It=x,Ot=q,At=Z,Rt=J,Mt=Q,kt=bt+W,Lt=It+K,Nt=C,Pt=D,Bt=M,zt=k;t[++tt]=Dt,t[++tt]=St,t[++tt]=bt,t[++tt]=It,t[++tt]=Ot,t[++tt]=At,t[++tt]=Rt,t[++tt]=Mt,t[++tt]=kt,t[++tt]=Lt,t[++tt]=Nt,t[++tt]=Pt,t[++tt]=Bt,t[++tt]=zt;const Ut=bt,Ft=It,Ht=st,Gt=nt,Vt=kt,Wt=Lt,Kt=ot,Xt=rt,Yt=at,jt=ht,$t=Bt,qt=zt,Zt=L,Jt=N;t[++tt]=Ut,t[++tt]=Ft,t[++tt]=Ht,t[++tt]=Gt,t[++tt]=Vt,t[++tt]=Wt,t[++tt]=Kt,t[++tt]=Xt,t[++tt]=Yt,t[++tt]=jt,t[++tt]=$t,t[++tt]=qt,t[++tt]=Zt,t[++tt]=Jt;const Qt=Nt,te=Pt,ee=Bt,ie=zt,se=ut,ne=dt,oe=gt,re=ft,ae=z-W,he=U-K,le=pt,ce=_t,ue=z,de=U;t[++tt]=Qt,t[++tt]=te,t[++tt]=ee,t[++tt]=ie,t[++tt]=se,t[++tt]=ne,t[++tt]=oe,t[++tt]=re,t[++tt]=ae,t[++tt]=he,t[++tt]=le,t[++tt]=ce,t[++tt]=ue,t[++tt]=de;const pe=ee,_e=ie,ge=Zt,fe=Jt,me=ae,ve=he,Te=xt,we=Ct,Ee=Et,ye=yt,xe=ue,Ce=de,De=Tt,Se=wt;t[++tt]=pe,t[++tt]=_e,t[++tt]=ge,t[++tt]=fe,t[++tt]=me,t[++tt]=ve,t[++tt]=Te,t[++tt]=we,t[++tt]=Ee,t[++tt]=ye,t[++tt]=xe,t[++tt]=Ce,t[++tt]=De,t[++tt]=Se,c[0]=_,c[1]=g,c[2]=f,c[3]=m,c[4]=v},Ll=(t,e,i,s,n,o,r)=>{const a=h(n),l=r[0],c=r[1],u=r[2],_=s&V.TOP?1:0,g=s&V.RIGHT?1:0,f=s&V.BOTTOM?1:0,m=s&V.LEFT?1:0,v=d(0,a,m,_),T=d(0,a,g,_),w=d(0,a,m,f),E=d(0,a,g,f),y=d(1,a,m,_),x=d(1,a,g,_),C=d(1,a,m,f),D=d(1,a,g,f),S=1-r[3],b=1-r[4],I=p(1,1),O=p(0,1),A=p(1,0),R=p(0,0),M=p(S,1),k=p(1,b),L=p(S,b),N=p(0,b);let P=6*e-1;o&nt.TOP_LEFT?(t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=y,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0):(t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0),o&nt.TOP_RIGHT?(t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=x,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0):(t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0),o&nt.BOTTOM_LEFT?(t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=C,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0):(t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0),o&nt.BOTTOM_RIGHT?(t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=D,t[++P]=u,t[++P]=u,t[++P]=I,t[++P]=0):(t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=I,t[++P]=0),t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=v,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=T,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0,t[++P]=i,t[++P]=w,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=R,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=A,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=N,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=L,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=k,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=O,t[++P]=0,t[++P]=i,t[++P]=E,t[++P]=l,t[++P]=c,t[++P]=M,t[++P]=0},Nl=(t,e,i,s)=>{const n=i.x0,o=i.y0,r=i.x1,a=i.y1,h=i.x2,l=i.y2,c=i.x3,u=i.y3,d=.5*(n+r),p=.5*(o+a),_=.5*(n+c),g=.5*(o+u),f=d-n,m=p-o,v=_-n,T=g-o,w=_+f,E=g+m,y=r+v,x=a+T,C=c+f,D=u+m,S=s[3],b=s[4],I=S*f,O=S*m,A=b*v,R=b*T,M=n,k=o,L=M+I,N=k+O,P=M+A,B=k+R,z=P+I,U=B+O;let F=2*e-1;t[++F]=M,t[++F]=k,t[++F]=L,t[++F]=N,t[++F]=P,t[++F]=B,t[++F]=z,t[++F]=U;const H=r,G=a,V=r-I,W=a-O,K=V+A,X=W+R,Y=K+I,j=X+O;t[++F]=V,t[++F]=W,t[++F]=H,t[++F]=G,t[++F]=K,t[++F]=X,t[++F]=Y,t[++F]=j;const $=c,q=u,Z=$-A,J=q-R,Q=$+I,tt=q+O,et=Z+I,it=J+O;t[++F]=Z,t[++F]=J,t[++F]=et,t[++F]=it,t[++F]=$,t[++F]=q,t[++F]=Q,t[++F]=tt;const st=h,nt=l,ot=st-I,rt=nt-O,at=st-A,ht=nt-R,lt=at-I,ct=ht-O;t[++F]=lt,t[++F]=ct,t[++F]=at,t[++F]=ht,t[++F]=ot,t[++F]=rt,t[++F]=st,t[++F]=nt;const ut=L,dt=N,pt=d,_t=p,gt=P,ft=B,mt=z,vt=U,Tt=pt+A,wt=_t+R,Et=_,yt=g,xt=w,Ct=E;t[++F]=ut,t[++F]=dt,t[++F]=pt,t[++F]=_t,t[++F]=gt,t[++F]=ft,t[++F]=mt,t[++F]=vt,t[++F]=Tt,t[++F]=wt,t[++F]=Et,t[++F]=yt,t[++F]=xt,t[++F]=Ct;const Dt=pt,St=_t,bt=V,It=W,Ot=Tt,At=wt,Rt=K,Mt=X,kt=Y,Lt=j,Nt=xt,Pt=Ct,Bt=y,zt=x;t[++F]=Dt,t[++F]=St,t[++F]=bt,t[++F]=It,t[++F]=Ot,t[++F]=At,t[++F]=Rt,t[++F]=Mt,t[++F]=kt,t[++F]=Lt,t[++F]=Nt,t[++F]=Pt,t[++F]=Bt,t[++F]=zt;const Ut=Et,Ft=yt,Ht=xt,Gt=Ct,Vt=Z,Wt=J,Kt=et,Xt=it,Yt=C-A,jt=D-R,$t=Q,qt=tt,Zt=C,Jt=D;t[++F]=Ut,t[++F]=Ft,t[++F]=Ht,t[++F]=Gt,t[++F]=Vt,t[++F]=Wt,t[++F]=Kt,t[++F]=Xt,t[++F]=Yt,t[++F]=jt,t[++F]=$t,t[++F]=qt,t[++F]=Zt,t[++F]=Jt;const Qt=Ht,te=Gt,ee=Bt,ie=zt,se=Yt,ne=jt,oe=lt,re=ct,ae=at,he=ht,le=Zt,ce=Jt,ue=ot,de=rt;t[++F]=Qt,t[++F]=te,t[++F]=ee,t[++F]=ie,t[++F]=se,t[++F]=ne,t[++F]=oe,t[++F]=re,t[++F]=ae,t[++F]=he,t[++F]=le,t[++F]=ce,t[++F]=ue,t[++F]=de};class Pl extends W{constructor(t,e,i){super(t,e,i,Il,Ol),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices(),Ml(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=e.radius,r=s!==this.sizeX||n!==this.sizeY||o!==this.radius,a=K(e),h=this.transformLocalId!==a,l=e.stroke,c=l.align,u=l.enable?l.width:0,d=l.side,p=l.style,_=this.strokeAlign!==c||this.strokeWidth!==u||this.strokeSide!==d||this.strokeStyle!==p,g=e.corner,f=g!==this.corner,m=X(e),v=Y(m),T=m!==this.texture||v!==this.textureTransformId,w=r||_,E=!(this.inited&H.VERTEX_STEP_AND_UV);if(E||w||h||f||T){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.radius=o,this.transformLocalId=a,this.strokeAlign=c,this.strokeWidth=u,this.strokeSide=d,this.strokeStyle=p,this.corner=g,this.texture=m,this.textureTransformId=v;const i=this.vertexOffset;t.updateVertices(),kl(t.vertices,i,0,0,s,n,c,u,o,e.transform.internalTransform,Al),(E||w||f||h)&&(t.updateSteps(),Ll(t.steps,i,u,d,p,g,Al)),(E||w||T)&&(t.updateUvs(),Nl(t.uvs,i,j(m),Al))}}}const Bl=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=Il+a,c=Ol+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new Pl(t,i,s),new le(t,i+Il,s+Ol,a,h)]).init(e):null},zl=(t,e,i,s,n)=>Bl(t,e,i,s),Ul=(t,e,i,s,n,o)=>{const r=-i+n;if(t<=r){const a=-s+n;if(e<=a&&o&nt.TOP_LEFT){const i=t-r,s=e-a;return i*i+s*s<=n*n}{const a=+s-n;if(a<=e&&o&nt.BOTTOM_LEFT){const i=t-r,s=e-a;return i*i+s*s<=n*n}return-i<=t}}{const r=+i-n;if(r<=t){const a=-s+n;if(e<=a&&o&nt.TOP_RIGHT){const i=t-r,s=e-a;return i*i+s*s<=n*n}{const a=+s-n;if(a<=e&&o&nt.BOTTOM_RIGHT){const i=t-r,s=e-a;return i*i+s*s<=n*n}return t<=+i}}return-s<=e&&e<=+s}},Fl=(t,e,i,s,n,o,r)=>{const a=t.fill;if(a.enable||0<o){const h=t.radius*Math.min(s,n),l=t.corner;if(Ul(e,i,s,n,h,l)){if(a.enable)return!0;{const a=o*r,c=Math.max(0,s-a),u=Math.max(0,n-a),d=Math.max(0,h-a);if(!Ul(e,i,c,u,d,l)){const s=t.stroke.side;if(s===V.ALL)return!0;if(e<=-c+d){const t=!!(s&V.LEFT);if(i<=-u+d){const n=!!(s&V.TOP);return!(!n||!t)||(n?-c<=i:!!t&&e<=-c)}if(+u-d<=i){const n=!!(s&V.BOTTOM);return!(!n||!t)||(n?+c<=i:!!t&&e<=-c)}return t}if(+c-d<=e){const t=!!(s&V.RIGHT);if(i<=-u+d){const n=!!(s&V.TOP);return!(!n||!t)||(n?-c<=i:!!t&&+c<=e)}if(+u-d<=i){const n=!!(s&V.BOTTOM);return!(!n||!t)||(n?+c<=i:!!t&&+c<=e)}return t}return i<=-u+d?!!(s&V.TOP):+u-d<=i&&!!(s&V.BOTTOM)}}}}return!1};class Hl extends te{constructor(t=s.RECTANGLE_ROUNDED){super(t)}clone(){return new Hl(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&Fl(this,t,e,i,s,n,o)}}class Gl extends Hl{constructor(t=s.BUTTON){super(t),this._isToggle=!1,this._isGrouped=!1}get isToggle(){return this._isToggle}set isToggle(t){this._isToggle=t}get isGrouped(){return this._isGrouped}set isGrouped(t){this._isGrouped=t}copy(t,e){return super.copy(t,e),t instanceof Gl&&(this._isToggle=t.isToggle,this._isGrouped=t.isGrouped),this}clone(){return new Gl(this.type).copy(this)}serialize(t){const e=super.serialize(t),i=this._isToggle?1:0,s=this._isGrouped?2:0;return e[15]=t.addResource(`[${i|s}]`),e}}const Vl=(t,e,i)=>{i=i||new Gl;const s=e.resources,n=t[15];if(0<=n&&n<s.length){let t=e.getExtension(n);null==t&&(t=JSON.parse(s[n]),e.setExtension(n,t)),i.isToggle=!!(1&t[0]),i.isGrouped=!!(2&t[0])}return Dl(t,e,i)};class Wl extends me{constructor(t){super(pe.COLOR_FILL_AND_STROKE|pe.COLOR_TEXT|pe.COLOR_TEXT_OUTLINE|pe.CURSOR);const e=t.fill,i=e.color,s=this.toOnHovered(i),n=2*s;this._fillColor=i,this._fillColorDisabled=de.toGrayscale(i),this._fillColorPressed=de.darken(i,n),this._fillColorHovered=de.darken(i,s);const o=e.alpha;this._fillAlpha=o,this._fillAlphaDisabled=.5*o;const r=t.stroke,a=r.color,h=this.toOnHovered(a),l=2*h;this._strokeColor=a,this._strokeColorDisabled=de.toGrayscale(a),this._strokeColorPressed=de.darken(a,l),this._strokeColorHovered=de.darken(a,h);const c=r.alpha;this._strokeAlpha=c,this._strokeAlphaDisabled=.5*c;const u=t.text,d=u.color;this._textColor=d,this._textColorDisabled=de.toGrayscale(d);const p=u.alpha;this._textAlpha=p,this._textAlphaDisabled=.5*p;const _=u.outline,g=_.color;this._textOutlineColor=g,this._textOutlineColorDisabled=de.toGrayscale(g);const f=_.alpha;this._textOutlineAlpha=f,this._textOutlineAlphaDisabled=.5*f}toOnHovered(t){const e=de.toLuma(t);if(128<=e){const t=(e-128)/127;return.15*(1-t)+.03*t}{const t=(127-e)/127;return-.15*(1-t)-.175*t}}execute(t,e,i){const s=t.state;t.fill.set(void 0,this.getFillColor(s),this.getFillAlpha(s)),t.stroke.set(void 0,this.getStrokeColor(s),this.getStrokeAlpha(s)),t.text.set(void 0,this.getTextColor(s),this.getTextAlpha(s)),t.text.outline.set(void 0,this.getTextOutlineColor(s),this.getTextOutlineAlpha(s)),t.cursor=this.getCursor(s),e.written|=this.reset}getFillColor(t){return t.inDisabled?this._fillColorDisabled:t.isPressed||t.isActive?this._fillColorPressed:t.isFocused||t.isHovered?this._fillColorHovered:this._fillColor}getFillAlpha(t){return t.inDisabled?this._fillAlphaDisabled:this._fillAlpha}getStrokeColor(t){return t.inDisabled?this._strokeColorDisabled:t.isPressed||t.isActive?this._strokeColorPressed:t.isFocused||t.isHovered?this._strokeColorHovered:this._strokeColor}getStrokeAlpha(t){return t.inDisabled?this._strokeAlphaDisabled:this._strokeAlpha}getTextColor(t){return t.inDisabled?this._textColorDisabled:this._textColor}getTextAlpha(t){return t.inDisabled?this._textAlphaDisabled:this._textAlpha}getTextOutlineColor(t){return t.inDisabled?this._textOutlineColorDisabled:this._textOutlineColor}getTextOutlineAlpha(t){return t.inDisabled?this._textOutlineAlphaDisabled:this._textOutlineAlpha}getCursor(t){return t.isActionable?"pointer":""}}class Kl extends me{constructor(t){super(pe.COLOR_FILL_AND_STROKE|pe.COLOR_TEXT|pe.COLOR_TEXT_OUTLINE|pe.CURSOR);const e=t.fill,i=e.color;this._fillColorActive=i;const s=this.toOnHovered(i),n=2*s;this._fillColorActivePressed=de.darken(i,n),this._fillColorActiveHovered=de.darken(i,s);const o=15197671;this._fillColor=o;const r=this.toOnHovered(o),a=2*r;this._fillColorPressed=de.darken(o,a),this._fillColorHovered=de.darken(o,r);const h=e.alpha;this._fillAlpha=h,this._fillAlphaDisabled=.5*h;const l=t.stroke,c=l.color;this._strokeColorActive=c;const u=this.toOnHovered(c),d=2*u;this._strokeColorActivePressed=de.darken(c,d),this._strokeColorActiveHovered=de.darken(c,u);const p=15197671;this._strokeColor=p;const _=this.toOnHovered(p),g=2*_;this._strokeColorPressed=de.darken(p,g),this._strokeColorGrayscaleHovered=de.darken(p,_);const f=l.alpha;this._strokeAlpha=f,this._strokeAlphaDisabled=.5*f;const m=t.text,v=m.color;this._textColorActive=v,this._textColorDisabled=de.toGrayscale(v),this._textColor=5197647;const T=m.alpha;this._textAlpha=T,this._textAlphaDisabled=.5*T;const w=m.outline,E=w.color;this._textOutlineColor=E,this._textOutlineColorDisabled=de.toGrayscale(E);const y=w.alpha;this._textOutlineAlpha=y,this._textOutlineAlphaDisabled=.5*y}toOnHovered(t){const e=de.toLuma(t);if(128<=e){const t=(e-128)/127;return.15*(1-t)+.03*t}{const t=(127-e)/127;return-.15*(1-t)-.175*t}}execute(t,e,i){const s=t.state;t.fill.set(void 0,this.getFillColor(s),this.getFillAlpha(s)),t.stroke.set(void 0,this.getStrokeColor(s),this.getStrokeAlpha(s)),t.text.set(void 0,this.getTextColor(s),this.getTextAlpha(s)),t.text.outline.set(void 0,this.getTextOutlineColor(s),this.getTextOutlineAlpha(s)),t.cursor=this.getCursor(s),e.written|=this.reset}getFillColor(t){return t.inDisabled?this._fillColor:t.isActive?t.isPressed?this._fillColorActivePressed:t.isFocused||t.isHovered?this._fillColorActiveHovered:this._fillColorActive:t.isPressed?this._fillColorPressed:t.isFocused||t.isHovered?this._fillColorHovered:this._fillColor}getFillAlpha(t){return t.inDisabled?this._fillAlphaDisabled:this._fillAlpha}getStrokeColor(t){return t.inDisabled?this._strokeColor:t.isActive?t.isPressed?this._strokeColorActivePressed:t.isFocused||t.isHovered?this._strokeColorActiveHovered:this._strokeColorActive:t.isPressed?this._strokeColorPressed:t.isFocused||t.isHovered?this._strokeColorGrayscaleHovered:this._strokeColor}getStrokeAlpha(t){return t.inDisabled?this._strokeAlphaDisabled:this._strokeAlpha}getTextColor(t){return t.inDisabled?this._textColorDisabled:t.isActive?this._textColorActive:this._textColor}getTextAlpha(t){return t.inDisabled?this._textAlphaDisabled:this._textAlpha}getTextOutlineColor(t){return t.inDisabled?this._textOutlineColorDisabled:this._textOutlineColor}getTextOutlineAlpha(t){return t.inDisabled?this._textOutlineAlphaDisabled:this._textOutlineAlpha}getCursor(t){return t.isActionable?"pointer":""}}class Xl extends Eo{constructor(t){super(t),t instanceof Gl&&(this._isToggle=t.isToggle,this._isGrouped=t.isGrouped)}isActionable(){return!0}initialize(t){this.actions.unshift(this._isToggle?new Kl(this):new Wl(this)),super.initialize(t)}onClick(t,e){const i=t.state,s=i.isClicked;i.lock(),super.onClick(t,e),!s&&i.isClicked&&(this._isToggle?i.isActive=!i.isActive:i.isActive||(i.isActivated=!0)),i.unlock()}onStateChange(t,e,i){super.onStateChange(t,e,i),this._isToggle&&this._isGrouped&&e.is(Ct.ACTIVATED)&&this.onActivated(t)}onActivated(t){const e=t.parent;if(null!=e){const i=e.children;for(let e=0,s=i.length;e<s;++e){const s=i[e];s!==t&&s instanceof Gl&&s.isToggle&&s.isGrouped&&(s.state.isActive=!1)}}}}const Yl=()=>{n[s.BUTTON]=zl,e[s.BUTTON]=Vl,bo[s.BUTTON]=Xl,Ui.set(s.BUTTON,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)},jl=[0,0],$l=new t.Point,ql=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+4,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+4,t[++s]=e+2,t[++s]=e+5,t[++s]=e+4,t[++s]=e+3,t[++s]=e+4,t[++s]=e+6,t[++s]=e+4,t[++s]=e+7,t[++s]=e+6,t[++s]=e+4,t[++s]=e+5,t[++s]=e+7,t[++s]=e+5,t[++s]=e+8,t[++s]=e+7},Zl=(t,e,i,s,n,o,r,a,h,l)=>{const c=$l,u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u);c.set(-d+i,-p+s),h.apply(c,c);const _=c.x,g=c.y;c.set(0+i,-p+s),h.apply(c,c);const f=c.x,m=c.y,v=f-_,T=m-g;c.set(i,s),h.apply(c,c);const w=c.x,E=c.y,y=w+(w-f),x=E+(E-m),D=w-v,S=E-T;let b=2*e-1;t[++b]=_,t[++b]=g,t[++b]=f,t[++b]=m,t[++b]=f+v,t[++b]=m+T,t[++b]=D,t[++b]=S,t[++b]=w,t[++b]=E,t[++b]=w+v,t[++b]=E+T,t[++b]=y-v,t[++b]=x-T,t[++b]=y,t[++b]=x,t[++b]=y+v,t[++b]=x+T,l[0]=C(_,g,f,m),l[1]=C(_,g,D,S)},Jl=(t,e,i,s,n)=>{const o=h(s),r=n[0],a=n[1],l=d(1,o,1,1),c=p(1,1),u=p(0,1),_=p(1,0),g=p(0,0);let f=6*e-1;t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=u,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=g,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=u,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0},Ql=(t,e,i)=>{const s=i.x0,n=i.x1,o=i.x2,r=i.x3,a=i.y0,h=i.y1,l=i.y2,c=i.y3;let u=2*e-1;t[++u]=s,t[++u]=a,t[++u]=.5*(s+n),t[++u]=.5*(a+h),t[++u]=n,t[++u]=h,t[++u]=.5*(s+r),t[++u]=.5*(a+c),t[++u]=.5*(s+o),t[++u]=.5*(a+l),t[++u]=.5*(n+o),t[++u]=.5*(h+l),t[++u]=r,t[++u]=c,t[++u]=.5*(r+o),t[++u]=.5*(c+l),t[++u]=o,t[++u]=l};class tc extends W{constructor(t,e,i){super(t,e,i,9,8)}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset;ql(t.indices,e,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u;(!(this.inited&H.VERTEX_AND_STEP)||o||a||d)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,t.updateVertices(),t.updateSteps(),Zl(t.vertices,this.vertexOffset,0,0,s,n,l,c,e.transform.internalTransform,jl),Jl(t.steps,this.vertexOffset,c,u,jl))}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=j(i);Ql(t.uvs,this.vertexOffset,e)}}}const ec=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=9+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new tc(t,i,s),new le(t,i+9,s+8,a,h)]).init(e):null},ic=(t,e,i)=>Dl(t,e,i||new Bi),sc=()=>{n[s.CIRCLE]=ec,e[s.CIRCLE]=ic},nc=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),oc=[0,1],rc=[0,1],ac=t=>t?t.formatted.plength:0,hc=t=>{const e=ac(t);return(e>>4)+(0<(15&e)?1:0)<<4},lc=(t,e)=>e?2+(t<<2):t<<2,cc=(t,e)=>lc(t,e)-2,uc=(t,e,i,s)=>{let n=3*i-1;const o=3*(i+s)-1;let r=e;for(;n<o;)t[++n]=r+0,t[++n]=r+2,t[++n]=r+1,t[++n]=r+1,t[++n]=r+2,t[++n]=r+3,r+=2},dc=(t,e,i,s,n,o)=>{const r=1/Math.max(1e-5,o),a=n.x0,h=n.x1,l=n.x2,c=n.x3,u=n.y0,d=n.y1,p=n.y2,_=n.y3,g=h-a,f=d-u,m=l-c,v=p-_;let T=(i<<1)-1;const w=(i+s<<1)-1;let E=6*i-9;for(;T<w;){const i=e[E+=12]*r;t[++T]=a+i*g,t[++T]=u+i*f,t[++T]=c+i*m,t[++T]=_+i*v}};let pc;const _c=(t,e,i,s,n,o,r,a,h,l,c)=>{let u=pc;null==u&&(u=[],pc=u);const d=c.a,p=c.b,_=c.c,g=c.d,f=c.tx,m=c.ty;for(let t=0;t<n;++t){const e=t<<1,i=r[e],s=r[e+1];u[e]=d*i+_*s+f,u[e+1]=p*i+g*s+m}return fc(t,e,i,s,n,o,u,a,h,l)},gc=(t,e,i,s,n,o,r,a,h,l,c,d,p,_)=>{const g=u(a,h),f=Math.min(l,c);e[++t]=n,e[++t]=o,s[++i]=r,s[++i]=p,s[++i]=g,s[++i]=d,s[++i]=d,s[++i]=f,e[++t]=n,e[++t]=o,s[++i]=r,s[++i]=_,s[++i]=g,s[++i]=d,s[++i]=d,s[++i]=f},fc=(t,e,i,s,n,o,r,a,h,l)=>{const c=a.length;if(0<c){if(o){let o=0,u=0,d=i,p=0,_=a[0];for(let i=1;i<c;++i)p=a[i],2<=p-_&&(u=vc(t,e,d,-1,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)),_=p;return p=a[0]+n,2<=p-_?(u=vc(t,e,d,i+s-d,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)):mc(t,e,d,i+s-d,r,_,p,n,h,l,u),o}{let o=0,u=0,d=i,p=a[0];2<=p&&(u=vc(t,e,d,-1,r,0,p,n,h,l,u),o=Math.max(o,u),d+=lc(p,!1));let _=p;for(let i=1;i<c;++i)p=a[i],2<=p-_&&(u=vc(t,e,d,-1,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)),_=p;return p=n,2<=p-_?(u=vc(t,e,d,i+s-d,r,_,p,n,h,l,u),o=Math.max(o,u),d+=lc(p-_,!1)):mc(t,e,d,i+s-d,r,_,p,n,h,l,u),o}}return o?Tc(t,e,i,s,r,0,n,n,h,l):vc(t,e,i,s,r,0,n,n,h,l,0)},mc=(t,e,i,s,n,o,r,l,c,u,p)=>{if(0<=s){const r=h(u),c=a(u),_=d(3,r,c,0),g=d(5,r,c,0);let f=(i<<1)-1,m=6*i-1;const v=(i+s<<1)-1,T=o%l<<1,w=n[T],E=n[T+1];for(;f<v;)t[++f]=w,t[++f]=E,e[++m]=0,e[++m]=_,e[++m]=0,e[++m]=p,e[++m]=p,e[++m]=0,t[++f]=w,t[++f]=E,e[++m]=0,e[++m]=g,e[++m]=0,e[++m]=p,e[++m]=p,e[++m]=0}return 0},vc=(t,e,i,s,n,o,r,p,_,g,f)=>{const m=h(g),v=a(g),T=d(3,m,v,0),w=d(4,m,v,0),E=d(5,m,v,0),y=d(6,m,v,0),x=o%p<<1;let C=n[x],D=n[x+1];const S=(o+1)%p<<1;let b=n[S],I=n[S+1],O=C-(b-C),A=D-(I-D);const R=oc,M=rc;l(O,A,C,D,R),l(C,D,b,I,M);let k=nc(R),L=k;c(R,k),c(M,L);let N=(i<<1)-1,P=6*i-1,B=0;gc(N,t,P,e,C,D,_,R,M,k,L,f,T,E),N+=4,P+=12,gc(N,t,P,e,C,D,_,R,M,k,L,B,w,y),N+=4,P+=12;for(let i=o+1,s=r-1;i<s;++i){O=C,A=D,C=b,D=I,R[0]=M[0],R[1]=M[1],k=L;const s=(i+1)%p<<1;b=n[s],I=n[s+1],l(C,D,b,I,M),L=nc(M),c(M,L),B+=k,gc(N,t,P,e,C,D,_,R,M,k,L,B,T,E),N+=4,P+=12,gc(N,t,P,e,C,D,_,R,M,k,L,B,w,y),N+=4,P+=12}O=C,A=D,C=b,D=I,R[0]=M[0],R[1]=M[1],k=L,b=C+(C-O),I=D+(D-A),l(C,D,b,I,M),c(M,L),B+=k,gc(N,t,P,e,C,D,_,R,M,k,L,B,T,E),N+=4,P+=12,gc(N,t,P,e,C,D,_,R,M,k,L,B,w,y),N+=4,P+=12;const z=6*i-1;for(let t=z,i=z+12;t<i;t+=6)e[t+5]=f;for(let t=z+12;t<P;t+=6)e[t+5]=B;if(0<=s){const n=u(R,M),o=(i+s<<1)-1;for(;N<o;)t[++N]=C,t[++N]=D,e[++P]=0,e[++P]=T,e[++P]=n,e[++P]=B,e[++P]=B,e[++P]=0,t[++N]=C,t[++N]=D,e[++P]=0,e[++P]=E,e[++P]=n,e[++P]=B,e[++P]=B,e[++P]=0}return B},Tc=(t,e,i,s,n,o,r,p,_,g)=>{const f=h(g),m=a(g),v=d(3,f,m,0),T=d(4,f,m,0),w=d(5,f,m,0),E=d(6,f,m,0),y=(r-1)%p<<1;let x=0,C=0,D=n[y],S=n[y+1];const b=o%p<<1;let I=n[b],O=n[b+1];const A=oc,R=rc;l(x,C,D,S,A),l(D,S,I,O,R);let M=nc(A),k=nc(R);c(A,M),c(R,k);let L=0,N=(i<<1)-1,P=6*i-1;for(let i=o;i<r;++i){x=D,C=S,D=I,S=O,A[0]=R[0],A[1]=R[1],M=k;const s=(i+1)%p<<1;I=n[s],O=n[s+1],l(D,S,I,O,R),k=nc(R),c(R,k),L+=M,gc(N,t,P,e,D,S,_,A,R,M,k,L,v,w),N+=4,P+=12,gc(N,t,P,e,D,S,_,A,R,M,k,L,T,E),N+=4,P+=12}x=D,C=S,D=I,S=O,A[0]=R[0],A[1]=R[1],M=k;const B=(o+1)%p<<1;I=n[B],O=n[B+1],l(D,S,I,O,R),k=nc(R),c(R,k),L+=M,gc(N,t,P,e,D,S,_,A,R,M,k,L,v,w),N+=4,P+=12;for(let t=6*i-1;t<P;t+=6)e[t+5]=-L;if(0<=s){const n=u(A,R),o=(i+s<<1)-1;for(;N<o;)t[++N]=D,t[++N]=S,e[++P]=_,e[++P]=v,e[++P]=n,e[++P]=L,e[++P]=-L,e[++P]=0,t[++N]=D,t[++N]=S,e[++P]=_,e[++P]=w,e[++P]=n,e[++P]=L,e[++P]=-L,e[++P]=0}return L};class wc extends W{constructor(t,e,i,s,n){super(t,e,i,s,n),this.pointId=-1,this.pointCount=0,this.pointsClosed=!1,this.length=1}init(){const t=this.buffer;t.updateIndices(),uc(t.indices,this.vertexOffset,this.indexOffset,this.indexCount),this.inited|=H.INDEX}reinit(t,e,i,s){const n=hc(e.points),o=lc(n,!0),r=cc(n,!0);return this.buffer===t&&this.vertexOffset===i&&this.indexOffset===s&&this.vertexCount===o&&this.indexCount===r||!!t.check(i,s,o,r)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.vertexCount=o,this.indexCount=r,this.init(),!0)}isCompatible(t){return lc(hc(t.points),!0)===this.vertexCount}update(t){const e=this.buffer;this.updateLineVertexStep(e,t),this.updateColor(e,t),this.updateLineUv(e,t)}updateLineVertexStep(t,e){const i=e.points;if(i){const s=i.id,n=i.formatted,o=n.length,r=!!(n.style&F.CLOSED),a=s!==this.pointId||o!==this.pointCount||r!==this.pointsClosed,h=e.stroke,l=h.enable?h.width:0,c=h.style,u=this.strokeWidth!==l||this.strokeStyle!==c,d=K(e),p=this.transformLocalId!==d;(!(this.inited&H.VERTEX_AND_STEP)||a||p||u)&&(this.inited|=H.VERTEX_AND_STEP,this.pointId=s,this.pointCount=o,this.pointsClosed=r,this.strokeWidth=l,this.strokeStyle=c,this.transformLocalId=d,a&&(this.inited&=~H.UV),t.updateVertices(),t.updateSteps(),this.length=_c(t.vertices,t.steps,this.vertexOffset,this.vertexCount,this.pointCount,this.pointsClosed,n.values,n.segments,l,c,e.transform.internalTransform))}}updateLineUv(t,e){const i=X(e),s=Y(i);(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId)&&(this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs(),dc(t.uvs,t.steps,this.vertexOffset,this.vertexCount,j(i),this.length))}}const Ec=[0,0,0],yc=new t.Point,xc=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+2,t[++s]=e+0,t[++s]=e+3,t[++s]=e+4,t[++s]=e+0,t[++s]=e+5,t[++s]=e+6},Cc=(t,e,i,s,n,o,r,a,h,l)=>{const c=r*a,u=.5*n+(0<=n?+c:-c),d=.5*o+(0<=o?+c:-c),p=2*u*d/(u+Math.sqrt(u*u+4*d*d)),_=yc;_.set(i,s-d),h.apply(_,_);const g=_.x,f=_.y;_.set(i,s),h.apply(_,_);const m=_.x,v=_.y;_.set(i+u,s),h.apply(_,_);const T=m-g,w=v-f,E=_.x+T,y=_.y+w,x=m+(m-_.x)+T,D=v+(v-_.y)+w;_.set(i,s+d-p),h.apply(_,_);const S=_.x,b=_.y,I=m+T,O=v+w;l[0]=C(I,O,S,b),l[1]=C(E,y,I,O),l[2]=C(g,f,m,v);let A=(e<<1)-1;t[++A]=S,t[++A]=b,t[++A]=g,t[++A]=f,t[++A]=E,t[++A]=y,t[++A]=E,t[++A]=y,t[++A]=x,t[++A]=D,t[++A]=x,t[++A]=D,t[++A]=g,t[++A]=f},Dc=(t,e,i,s,n)=>{const o=h(s),r=n[0],a=d(0,o,1,1),l=p(0,0),c=p(1,0),u=p(0,1);let _=6*e-1;t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=l,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=u,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=u,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0,t[++_]=i,t[++_]=a,t[++_]=r,t[++_]=r,t[++_]=c,t[++_]=0},Sc=(t,e,i,s)=>{const n=e.x0,o=e.x1,r=e.x2,a=e.x3,h=e.y0,l=e.y1,c=e.y2,u=e.y3,d=.5*(n+o),p=.5*(h+l),_=1-.5*s[0]/s[2],g=d+_*(a-n),f=p+_*(u-h);let m=(i<<1)-1;t[++m]=g,t[++m]=f,t[++m]=d,t[++m]=p,t[++m]=r,t[++m]=c,t[++m]=r,t[++m]=c,t[++m]=a,t[++m]=u,t[++m]=a,t[++m]=u,t[++m]=d,t[++m]=p};class bc extends W{updateColor(t,e){let i=16777215,s=1;const n=e.points;if(null!=n){const t=n.getMarker();if(null!=t){const n=this.toMarker(t).fill;i=n.color,s=e.visible&&n.enable?n.alpha:0}}const o=e.stroke,r=o.color,a=e.visible&&o.enable&&0<o.width?o.alpha:0;(!(this.inited&H.COLOR)||i!==this.colorFill||s!==this.alphaFill||r!==this.colorStroke||a!==this.alphaStroke)&&(this.inited|=H.COLOR,this.colorFill=i,this.alphaFill=s,this.colorStroke=r,this.alphaStroke=a,t.updateColors(),G(i,s,r,a,this.vertexOffset,this.vertexCount,t.colors))}}class Ic extends bc{constructor(t,e,i){super(t,e,i,7,3),this.pointId=-1}init(){const t=this.buffer;t.updateIndices(),xc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(e,i){var s;const n=i.points;if(null==n)return;const o=n.getMarker();if(null==o)return;const r=this.toMarker(o),a=r.size,h=a.x,l=a.y,c=h!==this.sizeX||l!==this.sizeY,u=K(i),d=this.transformLocalId!==u,p=i.stroke,_=p.align,g=p.enable?p.width:0,f=p.style,m=this.strokeAlign!==_||this.strokeWidth!==g||this.strokeStyle!==f,v=X(i),T=Y(v),w=v!==this.texture||T!==this.textureTransformId,E=c||m,y=n.id,x=y!==this.pointId,C=!(this.inited&H.VERTEX_STEP_AND_UV);if(C||E||d||w||x){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=h,this.sizeY=l,this.transformLocalId=u,this.strokeAlign=_,this.strokeWidth=g,this.strokeStyle=f,this.texture=v,this.textureTransformId=T,this.pointId=y;const n=this.vertexOffset,o=null!==(s=Ic.WORK)&&void 0!==s?s:Ic.WORK=new t.Matrix;o.copyFrom(r.transform).prepend(i.transform.internalTransform),e.updateVertices(),Cc(e.vertices,n,0,0,h,l,_,g,o,Ec),(C||E||d)&&(e.updateSteps(),Dc(e.steps,n,g,f,Ec)),(C||E||w)&&(e.updateUvs(),Sc(e.uvs,j(v),n,Ec))}}}class Oc extends Ic{toMarker(t){return t.head}}class Ac extends Ic{toMarker(t){return t.tail}}class Rc extends bc{constructor(t,e,i){super(t,e,i,9,8),this.pointId=-1}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset;ql(t.indices,e,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(e,i){var s;const n=i.points;if(null==n)return;const o=n.getMarker();if(null==o)return;const r=this.toMarker(o),a=r.size,h=a.x,l=a.y,c=h!==this.sizeX||l!==this.sizeY,u=K(i),d=this.transformLocalId!==u,p=i.stroke,_=p.align,g=p.enable?p.width:0,f=p.style,m=this.strokeAlign!==_||this.strokeWidth!==g||this.strokeStyle!==f,v=n.id,T=v!==this.pointId;if(!(this.inited&H.VERTEX_AND_STEP)||c||d||m||T){this.inited|=H.VERTEX_AND_STEP,this.sizeX=h,this.sizeY=l,this.transformLocalId=u,this.strokeAlign=_,this.strokeWidth=g,this.strokeStyle=f,this.pointId=v;const n=null!==(s=Rc.WORK)&&void 0!==s?s:Rc.WORK=new t.Matrix;n.copyFrom(r.transform).prepend(i.transform.internalTransform),e.updateVertices(),e.updateSteps(),Zl(e.vertices,this.vertexOffset,0,0,h,l,_,g,n,jl),Jl(e.steps,this.vertexOffset,g,f,jl)}}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=j(i);Ql(t.uvs,this.vertexOffset,e)}}}class Mc extends Rc{toMarker(t){return t.head}}class kc extends Rc{toMarker(t){return t.tail}}class Lc{constructor(t,e,i){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=0,this.indexCount=0,this.texture=null}init(){return this}reinit(t,e,i,s){return this.buffer=t,this.vertexOffset=i,this.indexOffset=s,!0}isCompatible(t){return!0}update(t){this.texture=X(t)}buildUnit(e){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;if(s!==e.baseTexture){e.baseTexture=s;const t=this.indexOffset;e.push(i,t)}}}const Nc=16,Pc=[0,0],Bc=new t.Point,zc=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+2,t[++s]=e+2,t[++s]=e+1,t[++s]=e+3,t[++s]=e+4,t[++s]=e+5,t[++s]=e+6,t[++s]=e+6,t[++s]=e+5,t[++s]=e+7,t[++s]=e+8,t[++s]=e+9,t[++s]=e+10,t[++s]=e+10,t[++s]=e+9,t[++s]=e+11,t[++s]=e+12,t[++s]=e+13,t[++s]=e+14,t[++s]=e+14,t[++s]=e+13,t[++s]=e+15},Uc=(t,e,i,s,n,o,r,a,h,l)=>{const c=r*a,u=.5*n+(0<=n?+c:-c),d=.5*o+(0<=o?+c:-c),p=Bc;p.set(i-u,s-d),h.apply(p,p);const _=p.x,g=p.y;p.set(i,s-d),h.apply(p,p);const f=p.x,m=p.y;p.set(i-u,s),h.apply(p,p);const v=p.x,T=p.y,w=f-_,E=m-g,y=v-_,x=T-g,D=f+w,S=m+E,b=v+w,I=T+E,O=D+y,A=S+x,R=v+y,M=T+x,k=R+w,L=M+E,N=k+w,P=L+E;let B=(e<<1)-1;t[++B]=_,t[++B]=g,t[++B]=f,t[++B]=m,t[++B]=v,t[++B]=T,t[++B]=b,t[++B]=I,t[++B]=f,t[++B]=m,t[++B]=D,t[++B]=S,t[++B]=b,t[++B]=I,t[++B]=O,t[++B]=A,t[++B]=v,t[++B]=T,t[++B]=b,t[++B]=I,t[++B]=R,t[++B]=M,t[++B]=k,t[++B]=L,t[++B]=b,t[++B]=I,t[++B]=O,t[++B]=A,t[++B]=k,t[++B]=L,t[++B]=N,t[++B]=P,l[0]=C(_,g,f,m),l[1]=C(_,g,v,T)},Fc=(t,e,i,s,n,o)=>{const r=h(n),a=o[0],l=o[1],c=s&V.TOP?1:0,u=s&V.RIGHT?1:0,_=s&V.BOTTOM?1:0,g=s&V.LEFT?1:0,f=d(0,r,g,c),m=d(0,r,u,c),v=d(0,r,g,_),T=d(0,r,u,_),w=p(1,1),E=p(0,1),y=p(0,0),x=p(1,0);let C=6*t-1;e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0,e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=f,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=m,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0,e[++C]=i,e[++C]=v,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=y,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=x,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=E,e[++C]=0,e[++C]=i,e[++C]=T,e[++C]=a,e[++C]=l,e[++C]=w,e[++C]=0},Hc=(t,e,i)=>{const s=i.x0,n=i.y0,o=i.x1,r=i.y1,a=i.x2,h=i.y2,l=i.x3,c=i.y3,u=.5*(s+o),d=.5*(n+r),p=.5*(s+l),_=.5*(n+c),g=u-s,f=d-n,m=p+g,v=_+f,T=o+(p-s),w=r+(_-n),E=l+g,y=c+f;let x=(e<<1)-1;t[++x]=s,t[++x]=n,t[++x]=u,t[++x]=d,t[++x]=p,t[++x]=_,t[++x]=m,t[++x]=v,t[++x]=u,t[++x]=d,t[++x]=o,t[++x]=r,t[++x]=m,t[++x]=v,t[++x]=T,t[++x]=w,t[++x]=p,t[++x]=_,t[++x]=m,t[++x]=v,t[++x]=l,t[++x]=c,t[++x]=E,t[++x]=y,t[++x]=m,t[++x]=v,t[++x]=T,t[++x]=w,t[++x]=E,t[++x]=y,t[++x]=a,t[++x]=h};class Gc extends bc{constructor(t,e,i){super(t,e,i,Nc,8),this.pointId=-1}init(){const t=this.buffer;t.updateIndices(),zc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(e,i){var s;const n=i.points;if(null==n)return;const o=n.getMarker();if(null==o)return;const r=this.toMarker(o),a=r.size,h=a.x,l=a.y,c=h!==this.sizeX||l!==this.sizeY,u=K(i),d=this.transformLocalId!==u,p=i.stroke,_=p.align,g=p.enable?p.width:0,f=p.side,m=p.style,v=this.strokeAlign!==_||this.strokeWidth!==g||this.strokeSide!==f||this.strokeStyle!==m,T=X(i),w=Y(T),E=T!==this.texture||w!==this.textureTransformId,y=c||v,x=n.id!==this.pointId,C=!(this.inited&H.VERTEX_STEP_AND_UV);if(C||y||d||E||x){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=h,this.sizeY=l,this.transformLocalId=u,this.strokeAlign=_,this.strokeWidth=g,this.strokeSide=f,this.strokeStyle=m,this.texture=T,this.textureTransformId=w;const n=this.vertexOffset,o=null!==(s=Gc.WORK)&&void 0!==s?s:Gc.WORK=new t.Matrix;o.copyFrom(r.transform).prepend(i.transform.internalTransform),e.updateVertices(),Uc(e.vertices,n,0,0,h,l,_,g,o,Pc),(C||y||d)&&(e.updateSteps(),Fc(n,e.steps,g,f,m,Pc)),(C||y||E)&&(e.updateUvs(),Hc(e.uvs,n,j(T)))}}}class Vc extends Gc{toMarker(t){return t.tail}}class Wc extends Gc{toMarker(t){return t.head}}const Kc=t=>{switch(t){case Z.NONE:return 0;case Z.CIRCLE:return 9;case Z.TRIANGLE:return 7;case Z.RECTANGLE:return Nc}return 0},Xc=t=>{switch(t){case Z.NONE:return 0;case Z.CIRCLE:return 8;case Z.TRIANGLE:return 3;case Z.RECTANGLE:return 8}return 0},Yc=(t,e,i,s)=>{switch(t){case Z.NONE:return new Lc(e,i,s);case Z.CIRCLE:return new Mc(e,i,s);case Z.TRIANGLE:return new Oc(e,i,s);case Z.RECTANGLE:return new Wc(e,i,s)}return new Lc(e,i,s)},jc=(t,e,i,s)=>{switch(t){case Z.NONE:return new Lc(e,i,s);case Z.CIRCLE:return new kc(e,i,s);case Z.TRIANGLE:return new Ac(e,i,s);case Z.RECTANGLE:return new Vc(e,i,s)}return new Lc(e,i,s)},$c=(t,e,i,s,n)=>{const r=e.points,a=hc(r),h=lc(a,!0),l=cc(a,!0);let c=Z.NONE,u=Z.NONE;if(r&&r instanceof bs){const t=r.getMarker();t&&(c=t.tail.type,u=t.head.type)}const d=Kc(c),p=Xc(c),_=i+h,g=s+l,f=Kc(u),m=Xc(u),v=_+d,T=g+p,w=I(e),E=w<<2,y=w<<1,x=v+f,C=T+m,D=h+f+d+E,S=l+m+p+y;return t.check(i,s,D,S)?new o(t,i,s,D,S,[new wc(t,i,s,h,l),jc(c,t,_,g),Yc(u,t,v,T),new le(t,x,C,E,y)]).init(e):null};class qc{constructor(t,e,i){this._threshold=1e-6,this._x=t,this._y=e,this._z=0,this._values=i,i[0]=t,i[1]=e,this.index=0}get x(){return this._x}set x(t){if(0===this._z||this._threshold<Math.abs(this._x-t)){this._x=t;const e=this.index,i=this._values;1===this._z?(i[e+0]=this._x,i[e+1]=this._y):(i[e+2]=this._x,i[e+3]=this._y,this.index+=2,this._z=1)}}get y(){return this._y}set y(t){if(0===this._z||this._threshold<Math.abs(this._y-t)){this._y=t;const e=this.index,i=this._values;2===this._z?(i[e+0]=this._x,i[e+1]=this._y):(i[e+2]=this._x,i[e+3]=this._y,this.index+=2,this._z=2)}}toSide(t,e){return 0<=t-e?0<=t+e?1:0:0<=t+e?2:3}toAxis(t,e,i,s,n){const o=Math.abs(i),r=Math.abs(s),a=this._threshold;if(o<a&&r<a)return Math.abs(t)<Math.abs(e)?0<=e?2:0:0<=t?1:3;let h=null,l=0;const c=t*t+e*e;if(this._threshold<c){const o=1/Math.sqrt(c),r=t*o,a=e*o,u=+i*r+s*a,d=-s*r+i*a,p=-u,_=-d;n&Ni.TOP&&(null==h||h<u)&&(h=u,l=this.toSide(i,s)),n&Ni.RIGHT&&(null==h||h<d)&&(h=d,l=this.toSide(-s,i)),n&Ni.BOTTOM&&(null==h||h<p)&&(h=p,l=this.toSide(-i,-s)),n&Ni.LEFT&&(null==h||h<_)&&(h=_,l=this.toSide(s,-i))}return l}toTailAxis(t,e,i,s,n){return this.toAxis(t-this.x,e-this.y,i,s,n)}tail(t,e,i,s,n,o,r,a){switch(this.toTailAxis(t,e,i,s,a)){case 0:this.y-r<=e?(this.y-=Math.max(r,o),this.x=t):this.y=e;break;case 1:t<=this.x+r?(this.x+=Math.max(r,n),this.y=e):this.x=t;break;case 2:e<=this.y+r?(this.y+=Math.max(r,n),this.x=t):this.y=e;break;case 3:this.x-r<=t?(this.x-=Math.max(r,n),this.y=e):this.x=t}}middle(t,e){const i=t-this._x,s=e-this._y;Math.abs(i)<Math.abs(s)?this.y=e:this.x=t}toHeadAxis(t,e,i,s,n){return this.toAxis(this.x-t,this.y-e,i,s,n)}head(t,e,i,s,n,o,r,a){switch(this.toHeadAxis(t,e,i,s,a)){case 0:e-r<=this.y&&(this.y=e-Math.max(r,o)),this.x=t,this.y=e;break;case 1:this.x<=t+r&&(this.x=t+Math.max(r,n)),this.y=e,this.x=t;break;case 2:this.y<=e+r&&(this.y=e+Math.max(r,o)),this.x=t,this.y=e;break;case 3:t-r<=this.x&&(this.x=t-Math.max(r,n)),this.y=e,this.x=t}}margin(t,e){const i=this._values;let s=this.index;if(0!==t&&2<=s){const e=i[0],s=i[1],n=i[2]-e,o=i[3]-s,r=n*n+o*o,a=this._threshold;if(a<r){const r=t/Math.sqrt(n*n+o*o);a<Math.abs(r-1)?(i[0]=e+n*r,i[1]=s+o*r):this.index-=2}}if(s=this.index,0!==e&&2<=s){const t=i[s+0],n=i[s+1],o=i[s-2]-t,r=i[s-1]-n,a=o*o+r*r,h=this._threshold;if(h<a){const a=e/Math.sqrt(o*o+r*r);h<Math.abs(a-1)?(i[s+0]=t+o*a,i[s+1]=n+r*a):this.index-=2}}i.length=this.index+2}}class Zc extends Os{constructor(t=s.CONNECTOR_ELBOW){super(t)}fillPoints(t,e,i,s,n,o,r,a){const h=t.local,l=h.x,c=h.y,u=t.normal,d=u.x,p=u.y,_=t.side,g=i.local,f=g.x,m=g.y,v=i.normal,T=v.x,w=v.y,E=i.side,y=n.values,x=y.length,C=l-o,D=c-r,S=f-o,b=m-r,I=.5*(S+C),O=.5*(b+D),A=S-C,R=b-D,M=.5*q.SIZE_X,k=.5*q.SIZE_Y,L=1e-6;if(Math.abs(A)<L&&Math.abs(R)<L)a[0]=C,a[1]=D,a[2]=S,a[3]=b,a.length=4;else{const t=new qc(C,D,a);if(0<x){const i=Math.atan2(R,A),n=Math.sqrt(A*A+R*R),o=Math.cos(i)*n,r=Math.sin(i)*n,a=y[0],h=y[1],l=I+o*a-r*h,c=O+o*h+r*a;t.tail(l,c,d,p,M,k,e,_);for(let e=2;e<x;e+=2){const i=y[e+0],s=y[e+1],n=I+o*i-r*s,a=O+o*s+r*i;t.middle(n,a)}t.head(S,b,T,w,M,k,s,E)}else t.tail(I,O,d,p,M,k,e,_),t.head(S,b,T,w,M,k,s,E);t.margin(e,s)}}}const Jc=(t,e,i)=>Dl(t,e,i||new Zc);class Qc{static from(t,e,i){const s=[],n=t.length;if(4<n){const o=1e-6;let r=t[0],a=t[1];if(0!==e){const i=r-t[2],s=a-t[3],n=i*i+s*s;if(o<n){const t=e/Math.sqrt(n);r+=i*t,a+=s*t}}let h=t[n-2],l=t[n-1];if(0!==i){const e=h-t[n-4],s=l-t[n-3],r=e*e+s*s;if(o<r){const t=i/Math.sqrt(r);h+=e*t,l+=s*t}}const c=.5*(h+r),u=.5*(l+a),d=h-r,p=l-a,_=Math.atan2(p,d),g=Math.cos(_),f=Math.sin(_),m=d*d+p*p,v=o<m?1/Math.sqrt(m):1;for(let e=2,i=n-2;e<i;e+=2){const i=t[e+0]-c,n=t[e+1]-u;s.push((g*i+f*n)*v,(g*n-f*i)*v)}}return s}}const tu=(t,e,i)=>Dl(t,e,i||new Os),eu=(t,e,i,s)=>{if(e instanceof Os){const n=s.resources,o=t[15];if(0<=o&&o<n.length){let t=s.getExtension(o);null==t&&(t=JSON.parse(n[o]),s.setExtension(o,t)),e.lock(Mt.CONNECTOR);const r=e.points;r.deserialize(t[1],s);const a=e.edge;a.deserialize(t[0],i,s);const h=e.body,l=t[2];null!=l?h.deserialize(l,i,s):h.set(Qc.from(r.values,a.tail.margin,a.head.margin)),e.unlock(Mt.CONNECTOR,!0)}}},iu=()=>{n[s.CONNECTOR_ELBOW]=$c,e[s.CONNECTOR_ELBOW]=Jc,i[s.CONNECTOR_ELBOW]=eu,Ui.set(s.CONNECTOR_ELBOW,Ot.CONNECTOR)},su=()=>{n[s.CONNECTOR_LINE]=$c,e[s.CONNECTOR_LINE]=tu,i[s.CONNECTOR_LINE]=eu,Ui.set(s.CONNECTOR_LINE,Ot.CONNECTOR)};class nu extends W{constructor(t,e,i){super(t,e,i,Nc,8)}init(){const t=this.buffer;t.updateIndices(),zc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.side,d=h.style,p=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeSide!==u||this.strokeStyle!==d,_=X(e),g=Y(_),f=_!==this.texture||g!==this.textureTransformId,m=o||p,v=!(this.inited&H.VERTEX_STEP_AND_UV);if(v||m||a||f){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeSide=u,this.strokeStyle=d,this.texture=_,this.textureTransformId=g;const i=this.vertexOffset;t.updateVertices(),Uc(t.vertices,i,.5*s,.5*n,s,n,l,c,e.transform.internalTransform,Pc),(v||m||a)&&(t.updateSteps(),Fc(i,t.steps,c,u,d,Pc)),(v||m||f)&&(t.updateUvs(),Hc(t.uvs,i,j(_)))}}}const ou=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=Nc+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new nu(t,i,s),new le(t,i+Nc,s+8,a,h)]).init(e):null},ru=(t,e,i,s)=>{const n=I(e),r=n<<2,a=n<<1,h=r,l=a;return t.check(i,s,h,l)?new o(t,i,s,h,l,[new le(t,i,s,r,a)]).init(e):null},au=(t,e)=>{const i=t.data.getMapping();if(null!=i){const s=i.values;for(let i=0,n=s.length;i<n;++i){const n=s[i],o=n[0],r=e.getDataMapper(o);if(null!=r){const i=t.children,s=e.getDataDestination(n[1]),o=n[2];hu(i,r,s,o)}}}},hu=(t,e,i,s)=>{for(let n=0,o=t.length;n<o;++n){const o=t[n],r=o.data;for(let t=0,n=r.size();t<n;++t){const n=r.get(t);n&&n.scope!==Ut.PRIVATE&&e.map(n,i,s)}const a=o.children;0<a.length&&hu(a,e,i,s)}},lu=(t,e,i)=>{const s=e.pieces,n=t[15];if(s&&0<=n&&n<s.length){const o=e.pieceData;if(o){const r=s[n],a=o.get(r),h=i&&i(r,e);return a?((t,e,i,s,n,o,r)=>{const a=n.mode,h=n.depth;r=r||new Yi(t,a,h);const l=Dl(o,n,r),c=r.size,u=c.x,d=c.y;return r.size.set(e,i),s.copyTo(r),r.size.init(),r.size.set(u,d),a===Li.EDITOR?0<h&&au(r,n):au(r,n),l})(r,a.width,a.height,a.layer,e,t,h):((t,e,i,s)=>{const n=e.mode,o=e.depth;s=s||new Yi(t,n,o);const r=Dl(i,e,s),a=s.size,h=a.x,l=a.y,c=s.children,u=new Qs("missing",n,o),d=.5*h,p=.5*h;u.transform.position.set(-d,-p),u.size.set(h,l),u.size.init(),u.parent=s;const _=new yo;return _.stroke.color=16711680,_.transform.position.set(d,p),_.size.copyFrom(s.size),_.attach(u),c.push(u),s.onChildTransformChange(),s.toDirty(),s.onAttach(),s.size.init(),n===Li.EDITOR?0<o&&au(s,e):au(s,e),r})(r,e,t,h)}}return null},cu=(t,e,i)=>{null!=i||(i=new zi);const s=t[15];i.subtype=(t=>{const e=Pi.ALL&t;return 0!==e?e:Pi.HEAD})(s),i.side=Ni.ALL&s>>2,i.vvisible=0<(1&s>>6);const n=Dl(t,e,i);return!1===i.vvisible&&e.mode===Li.VIEWER&&(i.visible=!1),n},uu=()=>{n[s.EMBEDDED]=ru,e[s.EMBEDDED]=lu,Ui.set(s.EMBEDDED,Ot.EMBEDDED),n[s.EMBEDDED_LAYER]=ou,n[s.EMBEDDED_ACCEPTOR_EDGE]=ec,e[s.EMBEDDED_ACCEPTOR_EDGE]=cu,Ui.set(s.EMBEDDED_ACCEPTOR_EDGE,Ot.EMBEDDED_ACCEPTOR_EDGE)};class du{constructor(t){this._parent=t}get enable(){const t=this._parent.children;return!(0<t.length)||t[t.length-1].fill.enable}set enable(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.enable=t}get color(){const t=this._parent.children;return 0<t.length?t[t.length-1].fill.color:16777215}set color(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.color=t}get alpha(){const t=this._parent.children;return 0<t.length?t[t.length-1].fill.alpha:1}set alpha(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.alpha=t}copy(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].fill.copy(t)}set(t,e,i){const s=this._parent.children;for(let n=0,o=s.length;n<o;++n)s[n].fill.set(t,e,i)}clone(){return new du(this._parent)}toObject(){const t=this._parent.children;return 0<t.length?t[t.length-1].fill.toObject():{enable:!0,color:16777215,alpha:1}}serialize(t){return-1}deserialize(t,e){}}class pu{constructor(t){this._parent=t}get length(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.length}return 0}get plength(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.plength}return 0}get id(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.id}return 0}get values(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.values}return[]}set values(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.values=t)}}get segments(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.segments}return[]}set segments(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.segments=t)}}get style(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.style}return F.NONE}set style(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.style=t)}}get marker(){const t=this._parent.children;for(let e=0,i=t.length;e<i;++e){const i=t[e].points;if(null!=i)return i.marker}return tt.getInstance()}getMarker(){const t=this._parent.children;for(let e=0,i=t.length;e<i;++e){const i=t[e].points;if(null!=i)return i.getMarker()}}get formatter(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.formatter}return null}set formatter(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&(s.formatter=t)}}get formatted(){const t=this._parent.children;if(0<t.length){const e=t[t.length-1].points;if(null!=e)return e.formatted}return this}onSizeChange(){}copy(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;null!=s&&s.copy(t)}return this}set(t,e,i){const s=this._parent.children;for(let n=0,o=s.length;n<o;++n){const o=s[n].points;null!=o&&o.set(t,e,i)}return this}clone(t){return new pu(t)}toPoints(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;if(null!=s)return s.toPoints(t)}return[]}serialize(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].points;if(null!=s)return s.serialize(t)}return-1}}class _u{constructor(t){this._parent=t}get enable(){const t=this._parent.children;return 0<t.length&&t[t.length-1].stroke.enable}set enable(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.enable=t}get color(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.color:16777215}set color(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.color=t}get alpha(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.alpha:1}set alpha(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.alpha=t}get width(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.width:1}set width(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.width=t}get align(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.align:1}set align(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.align=t}get side(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.side:1}set side(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.side=t}get style(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.style:r.NONE}set style(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.style=t}copy(t){const e=this._parent.children;for(let i=0,s=e.length;i<s;++i)e[i].stroke.copy(t)}set(t,e,i,s,n){const o=this._parent.children;for(let r=0,a=o.length;r<a;++r)o[r].stroke.set(t,e,i,s,n)}clone(){return new _u(this._parent)}toObject(){const t=this._parent.children;return 0<t.length?t[t.length-1].stroke.toObject():{enable:!1,color:16777215,alpha:1,width:1,align:0,side:V.NONE,style:r.NONE}}serialize(t){return-1}deserialize(t,e){}}class gu extends kt{constructor(t,e=s.GROUP){super(e),this._mode=t;const i=new jt;this.data=i,this.tag=i,this.size=this.newGroupSize(t),this.fill=this.newGroupFill(),this.stroke=this.newGroupStroke(),this.text=this.newGroupText(),this._points=this.newGroupPoints()}get mode(){return this._mode}newGroupSize(t){const e=q.SIZE_X,i=q.SIZE_Y;return t!==Li.VIEWER?new Gi(this,e,i,this.isGroupSizeFittable()):new Vi(this,e,i,e,i)}isGroupSizeFittable(){return!0}newGroupFill(){return new du(this)}newGroupStroke(){return new _u(this)}newGroupText(){return new Jt(this,q.TEXT_VALUE,q.TEXT_COLOR,q.TEXT_ALPHA,q.TEXT_FAMILY,q.TEXT_SIZE)}newGroupPoints(){return new pu(this)}getBoundsSize(){const t=this.size;return t instanceof Vi?t.base:t}onChildTransformChange(){super.onChildTransformChange(),this.size.fit()}get corner(){const t=this.children;return 0<t.length?t[t.length-1].corner:nt.ALL}set corner(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].corner=t}get gradient(){const t=this.children;for(let e=t.length-1;0<=e;--e){const i=t[e].gradient;if(null!=i)return i}}set gradient(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].gradient=t}serializeGradient(t){return-1}get radius(){const t=this.children;return 0<t.length?t[t.length-1].radius:.5}set radius(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].radius=t}get image(){const t=this.children;for(let e=t.length-1;0<=e;--e){const i=t[e].image;if(null!=i)return i}}set image(t){const e=this.children;for(let i=0,s=e.length;i<s;++i)e[i].image=t}serializeImage(t){return-1}get points(){const t=this.children;for(let e=t.length-1;0<=e;--e)if(null!=t[e].points)return this._points}set points(t){}clone(){const t=this.newClone().copy(this),e=this.children;for(let i=0,s=e.length;i<s;++i){const s=e[i].clone();s.parent=t,t.children.push(s)}return As.moveAll(e,t.children,e,t.children),t.onChildTransformChange(),t.toDirty(),t}newClone(){return new(0,this.constructor)(this._mode,this.type)}containsAbs(t,e,i,s,n,o,r){return!1}}const fu=(t,e,i)=>{i=i||new gu(e.mode);const s=Dl(t,e,i);return i.size.init(),s},mu=()=>{n[s.GROUP]=ru,e[s.GROUP]=fu,Ui.set(s.GROUP,Ot.GROUP)};class vu{constructor(e,i,s){this._parent=e,this._size=new t.Point(i,s)}init(){return this}get x(){return this._size.x}set x(t){const e=this._size;if(e.x!==t){const i=e.x;e.x=t,this.onChange(i,e.y)}}get y(){return this._size.y}set y(t){const e=this._size;if(e.y!==t){const i=e.y;e.y=t,this.onChange(e.x,i)}}set(t,e){let i=!1;const s=this._size,n=s.x,o=s.y;return null!=t&&n!==t&&(i=!0,s.x=t),null!=e&&o!==e&&(i=!0,s.y=e),i&&this.onChange(n,o),this}clone(){const t=this._size;return new vu(this._parent,t.x,t.y)}copy(){}copyFrom(t){const e=t.x,i=t.y,s=this._size,n=s.x,o=s.y;return n===e&&o===i||(s.x=e,s.y=i,this.onChange(n,o)),this}copyTo(t){return this._size.copyTo(t)}equals(t){return this._size.equals(t)}fit(){return this}onChange(t,e){this._parent.onSizeChange()}}class Tu extends gu{constructor(t,e=s.GROUP_SHADOWED){super(t,e)}newGroupSize(t){return t!==Li.VIEWER?new vu(this,q.SIZE_X,q.SIZE_Y):super.newGroupSize(t)}}const wu=(t,e,i)=>{i=i||new Tu(e.mode);const s=Dl(t,e,i);return i.size.init(),s},Eu=()=>{n[s.GROUP_SHADOWED]=ru,e[s.GROUP_SHADOWED]=wu,Ui.set(s.GROUP_SHADOWED,Ot.GROUP)};class yu extends W{constructor(t,e,i){super(t,e,i,Nc,8)}init(){const t=this.buffer;t.updateIndices(),zc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.side,d=h.style,p=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeSide!==u||this.strokeStyle!==d,_=X(e),g=Y(_),f=_!==this.texture||g!==this.textureTransformId,m=o||p,v=!(this.inited&H.VERTEX_STEP_AND_UV);if(v||m||a||f){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeSide=u,this.strokeStyle=d,this.texture=_,this.textureTransformId=g;const i=this.vertexOffset;t.updateVertices(),Uc(t.vertices,i,0,0,s,n,l,c,e.transform.internalTransform,Pc),(v||m||a)&&(t.updateSteps(),Fc(i,t.steps,c,u,d,Pc)),(v||m||f)&&(t.updateUvs(),Hc(t.uvs,i,j(_)))}}}const xu=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=Nc+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new yu(t,i,s),new le(t,i+Nc,s+8,a,h)]).init(e):null};class Cu extends yo{constructor(t,e=s.IMAGE){super(e),null!=t&&(this.image=t,this.size.set(t.width,t.height)),this.fill.alpha=1}clone(){return new Cu(this.image,this.type).copy(this)}}const Du=(t,e,i)=>Dl(t,e,i||new Cu),Su=()=>{n[s.IMAGE]=xu,e[s.IMAGE]=Du},bu=[0,0],Iu=new t.Point,Ou=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+4,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+4,t[++s]=e+2,t[++s]=e+5,t[++s]=e+4,t[++s]=e+3,t[++s]=e+4,t[++s]=e+6,t[++s]=e+4,t[++s]=e+7,t[++s]=e+6,t[++s]=e+4,t[++s]=e+5,t[++s]=e+7,t[++s]=e+5,t[++s]=e+8,t[++s]=e+7},Au=(t,e,i,s,n,o,r,a)=>{const l=h(n),c=d(2,l,1,1),u=o/a[0],p=r/a[1],_=.5*(u+p),g=s/12,f=-1+i;let m=6*e-1;t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=p,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=u,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=u,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=_,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=p,t[++m]=f,t[++m]=0,t[++m]=0,t[++m]=g,t[++m]=c,t[++m]=p,t[++m]=f,t[++m]=0,t[++m]=0},Ru=(t,e,i,s,n,o,r,a)=>{const h=Iu,l=.5*n,c=.5*o;h.set(i-l,s-c),r.apply(h,h);const u=h.x,d=h.y;h.set(i+l,s-c),r.apply(h,h);const p=h.x,_=h.y;h.set(i+l,s+c),r.apply(h,h);const g=h.x,f=h.y,m=u+(g-p),v=d+(f-_);let T=(e<<1)-1;t[++T]=u,t[++T]=d,t[++T]=.5*(u+p),t[++T]=.5*(d+_),t[++T]=p,t[++T]=_,t[++T]=.5*(u+m),t[++T]=.5*(d+v),t[++T]=.5*(u+g),t[++T]=.5*(d+f),t[++T]=.5*(p+g),t[++T]=.5*(_+f),t[++T]=m,t[++T]=v,t[++T]=.5*(m+g),t[++T]=.5*(v+f),t[++T]=g,t[++T]=f,a[0]=.5*C(u,d,p,_),a[1]=.5*C(u,d,m,v)},Mu=(t,e,i)=>{const s=i.x0,n=i.y0,o=i.x1,r=i.y1,a=i.x2,h=i.y2,l=i.x3,c=i.y3;let u=(e<<1)-1;t[++u]=s,t[++u]=n,t[++u]=.5*(o+s),t[++u]=.5*(r+n),t[++u]=o,t[++u]=r,t[++u]=.5*(s+l),t[++u]=.5*(n+c),t[++u]=.5*(s+a),t[++u]=.5*(n+h),t[++u]=.5*(o+a),t[++u]=.5*(r+h),t[++u]=l,t[++u]=c,t[++u]=.5*(l+a),t[++u]=.5*(c+h),t[++u]=a,t[++u]=h};class ku extends W{constructor(t,e,i){super(t,e,i,9,8),this.textureWidth=-1,this.textureHeight=-1}init(){const t=this.vertexOffset,e=this.buffer;e.updateIndices(),Ou(e.indices,t,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u,p=X(e),_=p.width*p.resolution,g=p.height*p.resolution,f=this.textureWidth!==_||this.textureHeight!==g;(!(this.inited&H.VERTEX_AND_STEP)||o||a||d||f)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,this.textureWidth=_,this.textureHeight=g,t.updateVertices(),Ru(t.vertices,this.vertexOffset,0,0,s,n,e.transform.internalTransform,bu),t.updateSteps(),Au(t.steps,this.vertexOffset,l,c,u,_,g,bu))}updateUv(t,e){const i=X(e),s=Y(i);(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId)&&(this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs(),Mu(t.uvs,this.vertexOffset,j(i)))}}const Lu=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=9+a,c=8+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new ku(t,i,s),new le(t,i+9,s+8,a,h)]).init(e):null};class Nu extends Cu{constructor(t,e=s.IMAGE_SDF){super(t,e)}clone(){return new Nu(this.image,this.type).copy(this)}}const Pu=(t,e,i)=>Dl(t,e,i||new Nu);class Bu{constructor(t,e,i){this.buffer=t,this.vertexOffset=e,this.indexOffset=i,this.vertexCount=0,this.indexCount=0,this.texture=null}init(){return this}reinit(t,e,i,s){return this.buffer=t,this.vertexOffset=i,this.indexOffset=s,!0}isCompatible(t){return!0}update(t){this.texture=X(t)}buildUnit(e){const i=this.texture||t.Texture.WHITE,s=i.baseTexture;if(s!==e.baseTexture){e.baseTexture=s;const t=this.indexOffset;e.push(i,t)}}}const zu=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=a,c=h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new Bu(t,i,s),new le(t,i,s,a,h)]).init(e):null};class Uu extends te{constructor(t=s.LABEL){super(t)}clone(){return new Uu(this.type).copy(this)}}const Fu=(t,e,i)=>Dl(t,e,i||new Uu),Hu=()=>{n[s.LABEL]=zu,e[s.LABEL]=Fu};class Gu extends re{constructor(t=s.LINE){super(t),this._points=new bs(this)}get points(){return this._points}clone(){return new Gu(this.type).copy(this)}serialize(t){const e=super.serialize(t);return e[15]=this._points.serialize(t),e}}const Vu=(t,e,i)=>{i=i||new Gu;const s=Dl(t,e,i);i.points.deserialize(t[15],e);const n=i.points.style,o=F.NON_SCALING_MASK|F.DOTTED_MASK|F.DASHED_MASK,r=n&o;return r&&(i.points.style&=~o,i.stroke.style|=r),s},Wu=()=>{n[s.LINE]=$c,e[s.LINE]=Vu},Ku=(t,e,i)=>{for(let s=2*e,n=2*(e+i);s<n;s+=2)t[s+0]=0,t[s+1]=0},Xu=(t,e,i)=>{for(let s=6*e,n=6*(e+i);s<n;s+=6)t[s+0]=0,t[s+1]=0,t[s+2]=0,t[s+3]=0,t[s+4]=0,t[s+5]=0},Yu=(t,e,i)=>{for(let s=2*e,n=2*(e+i);s<n;s+=2)t[s+0]=0,t[s+1]=0},ju=t=>(t>>4)+(0<(15&t)?1:0)<<4,$u=(t,e,i,s,n,o,r,a,h,l,c,u)=>{if(r)if(i.isStaticColor()){const r=i.getColor(0,h);if(i.isStaticAlpha()){const h=i.getAlpha(0,l);qu(t,e,i,s,n,o,a,c,u,r,h)}else Zu(t,e,i,s,n,o,a,c,u,r,l)}else if(i.isStaticAlpha()){const r=i.getAlpha(0,l);Ju(t,e,i,s,n,o,a,c,u,h,r)}else Qu(t,e,i,s,n,o,a,c,u,h,l);else if(i.isStaticColor()){const r=i.getColor(0,h);qu(t,e,i,s,n,o,a,c,u,r,0)}else Ju(t,e,i,s,n,o,a,c,u,h,0)},qu=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const i=s.getColor(0,a);if(s.isStaticAlpha()){const r=s.getAlpha(0,h);G(l,c,i,r,t,e*n,o)}else for(let r=0,a=t;r<n;r+=1,a+=e){const t=s.getAlpha(r,h);G(l,c,i,t,a,e,o)}}else if(s.isStaticAlpha()){const i=s.getAlpha(0,h);for(let r=0,h=t;r<n;r+=1,h+=e){const t=s.getColor(r,a);G(l,c,t,i,h,e,o)}}else for(let i=0,r=t;i<n;i+=1,r+=e){const t=s.getColor(i,a),n=s.getAlpha(i,h);G(l,c,t,n,r,e,o)}else if(s.isStaticColor()){const i=s.getColor(0,a);G(l,c,i,0,t,e*n,o)}else for(let i=0,r=t;i<n;i+=1,r+=e){const t=s.getColor(i,a);G(l,c,t,0,r,e,o)}},Zu=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const r=s.getColor(0,a);if(s.isStaticAlpha()){const a=s.getAlpha(0,h);for(let s=0,h=t;s<n;s+=1,h+=e){const t=i.getAlpha(s,c);G(l,t,r,a,h,e,o)}}else for(let a=0,u=t;a<n;a+=1,u+=e){const t=i.getAlpha(a,c),n=s.getAlpha(a,h);G(l,t,r,n,u,e,o)}}else if(s.isStaticAlpha()){const r=s.getAlpha(0,h);for(let h=0,u=t;h<n;h+=1,u+=e){const t=i.getAlpha(h,c),n=s.getColor(h,a);G(l,t,n,r,u,e,o)}}else for(let r=0,u=t;r<n;r+=1,u+=e){const t=i.getAlpha(r,c),n=s.getColor(r,a),d=s.getAlpha(r,h);G(l,t,n,d,u,e,o)}else if(s.isStaticColor()){const r=s.getColor(0,a);for(let s=0,a=t;s<n;s+=1,a+=e){const t=i.getAlpha(s,c);G(l,t,r,0,a,e,o)}}else for(let r=0,h=t;r<n;r+=1,h+=e){const t=i.getAlpha(r,c),n=s.getColor(r,a);G(l,t,n,0,h,e,o)}},Ju=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const r=s.getColor(0,a);if(s.isStaticAlpha()){const a=s.getAlpha(0,h);for(let s=0,h=t;s<n;s+=1,h+=e){const t=i.getColor(s,l);G(t,c,r,a,h,e,o)}}else for(let a=0,u=t;a<n;a+=1,u+=e){const t=i.getColor(a,l),n=s.getAlpha(a,h);G(t,c,r,n,u,e,o)}}else if(s.isStaticAlpha()){const r=s.getAlpha(0,h);for(let h=0,u=t;h<n;h+=1,u+=e){const t=i.getColor(h,l),n=s.getColor(h,a);G(t,c,n,r,u,e,o)}}else for(let r=0,u=t;r<n;r+=1,u+=e){const t=i.getColor(r,l),n=s.getColor(r,a),d=s.getAlpha(r,h);G(t,c,n,d,u,e,o)}else if(s.isStaticColor()){const r=s.getColor(0,a);for(let s=0,a=t;s<n;s+=1,a+=e){const t=i.getColor(s,l);G(t,c,r,0,a,e,o)}}else for(let r=0,h=t;r<n;r+=1,h+=e){const t=i.getColor(r,l),n=s.getColor(r,a);G(t,c,n,0,h,e,o)}},Qu=(t,e,i,s,n,o,r,a,h,l,c)=>{if(r)if(s.isStaticColor()){const r=s.getColor(0,a);if(s.isStaticAlpha()){const a=s.getAlpha(0,h);for(let s=0,h=t;s<n;s+=1,h+=e){const t=i.getColor(s,l),n=i.getAlpha(s,c);G(t,n,r,a,h,e,o)}}else for(let a=0,u=t;a<n;a+=1,u+=e){const t=i.getColor(a,l),n=i.getAlpha(a,c),d=s.getAlpha(a,h);G(t,n,r,d,u,e,o)}}else if(s.isStaticAlpha()){const r=s.getAlpha(0,h);for(let h=0,u=t;h<n;h+=1,u+=e){const t=i.getColor(h,l),n=i.getAlpha(h,c),d=s.getColor(h,a);G(t,n,d,r,u,e,o)}}else for(let r=0,u=t;r<n;r+=1,u+=e){const t=i.getColor(r,l),n=i.getAlpha(r,c),d=s.getColor(r,a),p=s.getAlpha(r,h);G(t,n,d,p,u,e,o)}else if(s.isStaticColor()){const r=s.getColor(0,a);for(let s=0,a=t;s<n;s+=1,a+=e){const t=i.getColor(s,l),n=i.getAlpha(s,c);G(t,n,r,0,a,e,o)}}else for(let r=0,h=t;r<n;r+=1,h+=e){const t=i.getColor(r,l),n=i.getAlpha(r,c),u=s.getColor(r,a);G(t,n,u,0,h,e,o)}};class td extends W{constructor(t,e,i,s,n,o,r,a){super(t,e,i,s,n),this.pointId=-1,this.pointCount=0,this.pointCountReserved=o,this.pointSizeId=-1,this.pointOffsetId=-1,this.pointFillId=-1,this.pointStrokeId=-1,this.vcountPerPoint=r,this.icountPerPoint=a}reinit(t,e,i,s){const n=ju(ac(e.points));if(this.buffer!==t||this.vertexOffset!==i||this.indexOffset!==s||this.pointCountReserved!==n){const e=n*this.vcountPerPoint,o=n*this.icountPerPoint;return!!t.check(i,s,e,o)&&(this.inited=H.NONE,this.buffer=t,this.vertexOffset=i,this.indexOffset=s,this.vertexCount=e,this.indexCount=o,this.pointCountReserved=n,this.init(),!0)}return!0}isCompatible(t){return ju(ac(t.points))===this.pointCountReserved}updateLineOfAnyColor(t,e,i,s){const n=i.fill,o=n.id,r=o!==this.pointFillId,a=e.fill,h=e.visible&&a.enable,l=a.color,c=h?a.alpha:0,u=l!==this.colorFill||c!==this.alphaFill,d=i.stroke,p=d.id,_=p!==this.pointStrokeId,g=e.stroke,f=e.visible&&g.enable,m=g.color,v=f?g.alpha:0,T=m!==this.colorStroke||v!==this.alphaStroke;(!(this.inited&H.COLOR)||r||u||_||T)&&(this.inited|=H.COLOR,this.colorFill=l,this.alphaFill=c,this.pointFillId=o,this.colorStroke=m,this.alphaStroke=v,this.pointStrokeId=p,t.updateColors(),$u(this.vertexOffset,s,n,d,this.pointCountReserved,t.colors,h,f,l,c,m,v))}}const ed=(t,e,i,s,n)=>{let o=e,r=i+s;for(let a=1;a<n;++a){let n=3*r,a=3*i;for(let e=0;e<s;++e)t[n+0]=t[a+0]+o,t[n+1]=t[a+1]+o,t[n+2]=t[a+2]+o,n+=3,a+=3;o+=e,r+=s}},id=(t,e,i,s)=>{const n=6*e;let o=6*(e+i);for(let e=1;e<s;++e){let e=n;for(let s=0;s<i;++s)t[o+0]=t[e+0],t[o+1]=t[e+1],t[o+2]=t[e+2],t[o+3]=t[e+3],t[o+4]=t[e+4],t[o+5]=t[e+5],o+=6,e+=6}},sd=(t,e,i,s)=>{let n=e+i;for(let o=1;o<s;++o){let s=n<<1,o=e<<1;for(let e=0;e<i;++e)t[s]=t[o],t[s+1]=t[o+1],s+=2,o+=2;n+=i}},nd=(t,e,i,s,n,o,r)=>{const a=e.a,h=e.b,l=e.c,c=e.d;let u=n-1,d=i+u*s;if(r.isStaticX()&&r.isStaticY()){const e=r.getX(0),n=r.getY(0);for(;0<=u;--u){const r=u<<1,p=o[r]+e,_=o[r+1]+n,g=a*p+l*_,f=h*p+c*_;let m=d<<1,v=i<<1;for(let e=0;e<s;++e)t[m]=t[v]+g,t[m+1]=t[v+1]+f,m+=2,v+=2;d-=s}}else for(;0<=u;--u){const e=u<<1,n=o[e]+r.getX(u),p=o[e+1]+r.getY(u),_=a*n+l*p,g=h*n+c*p;let f=d<<1,m=i<<1;for(let e=0;e<s;++e)t[f]=t[m]+_,t[f+1]=t[m+1]+g,f+=2,m+=2;d-=s}},od=t=>wt(t)||null==t,rd=(t,e,i)=>wt(e)?e:Tt(e)?e(t):e?e[t%e.length]:i;class ad{constructor(t){this._parent=t,this._id=0,this._color=null,this._alpha=null}get id(){return this._id}get color(){return this._color}set color(t){this.set(t,void 0)}get alpha(){return this._alpha}set alpha(t){this.set(void 0,t)}set(t,e){let i=!1;void 0!==t&&this._color!==t&&(i=!0,this._color=t),void 0!==e&&this._alpha!==e&&(i=!0,this._alpha=e),i&&(this._id+=1,this._parent.updateUploaded())}getColor(t,e){return rd(t,this._color,e)}getAlpha(t,e){return rd(t,this._alpha,e)}isStaticColor(){return od(this._color)}isStaticAlpha(){return od(this._alpha)}toDirty(){this._id+=1}}class hd{constructor(t,e,i){this._parent=t,this._id=0,this._x=null,this._y=null,this._defX=e,this._defY=i,this._limit=null,this._limitComputed=0,this._limitId=-1,this._limitParentLength=0}get id(){return this._id}get x(){return this._x}set x(t){this.set(t,void 0)}get y(){return this._y}set y(t){this.set(void 0,t)}get limit(){return this._limit}set limit(t){this._limit=t}set(t,e){let i=!1;void 0!==t&&this._x!==t&&(i=!0,this._x=t),void 0!==e&&this._y!==e&&(i=!0,this._y=e),i&&(this._id+=1,this._parent.updateUploaded())}getX(t){return rd(t,this._x,this._defX)}getY(t){return rd(t,this._y,this._defY)}getLimit(){const t=this._limit;return null!=t?t:(this.updateLimitComputed(),this._limitComputed)}updateLimitComputed(){const t=this._id,e=this._parent.length;this._limitId===t&&this._limitParentLength===e||(this._limitId=t,this._limitParentLength=e,this._limitComputed=Math.max(this.calcLimit(this._x,e,this._defX),this.calcLimit(this._y,e,this._defY)))}calcLimit(t,e,i){if(wt(t))return Math.abs(t);if(Tt(t)){if(0<e){let i=Math.abs(t(0));for(let s=1;s<e;++s)i=Math.max(i,Math.abs(t(s)));return i}return 0}if(null!=t){const e=t.length;if(0<e){let i=t[0];for(let s=1;s<e;++s)i=Math.max(i,Math.abs(t[s]));return i}return 0}return Math.abs(i)}isStaticX(){return od(this._x)}isStaticY(){return od(this._y)}toDirty(){this._id+=1}}class ld{constructor(t){this._parent=t,this._id=0,this._color=null,this._alpha=null}get id(){return this._id}get color(){return this._color}set color(t){this.set(t,void 0)}get alpha(){return this._alpha}set alpha(t){this.set(void 0,t)}set(t,e){let i=!1;void 0!==t&&this._color!==t&&(i=!0,this._color=t),void 0!==e&&this._alpha!==e&&(i=!0,this._alpha=e),i&&(this._id+=1,this._parent.updateUploaded())}getColor(t,e){return rd(t,this._color,e)}getAlpha(t,e){return rd(t,this._alpha,e)}isStaticColor(){return od(this._color)}isStaticAlpha(){return od(this._alpha)}toDirty(){this._id+=1}}class cd{constructor(t){this._parent=t,this._values=[],this._valuesLength=0,this._segments=[],this._length=0,this._plength=0,this._size=new hd(this,q.SIZE_X,q.SIZE_Y),this._offset=new hd(this,0,0),this._fill=new ad(t),this._stroke=new ld(t),this._id=0}get length(){return this._length}get plength(){return this._plength}get id(){return this._id}get values(){return this._values}set values(t){this.set(t,void 0,void 0)}get segments(){return this._segments}set segments(t){}get style(){return F.NONE}set style(t){this.set(void 0,void 0,t)}get marker(){let t=this._marker;return null==t&&(t=tt.getInstance(),this._marker=t),t}getMarker(){}get size(){return this._size}get offset(){return this._offset}get fill(){return this._fill}get stroke(){return this._stroke}get formatter(){return null}set formatter(t){}get formatted(){return this}onSizeChange(){}toFitted(t,e){}copy(t){return this.set(t.values,t.segments,t.style)}set(t,e,i){let s=!1,n=!1;if(null!=t){const e=this._values,i=this._valuesLength,o=t.length;if(e!==t){const r=Math.min(i,o);for(let i=0;i<r;++i)e[i]=t[i];for(let i=r;i<o;++i)e.push(t[i]);i!==o?(e.length=o,this._valuesLength=o,s=!0):n=!0}else i!==o?(this._valuesLength=o,s=!0):n=!0;const r=o>>1;this._length=r,this._plength<r&&(this._plength=r)}if(s){this._id+=1;const t=this._parent,e=t.uploaded;e?e.isCompatible(t)?t.updateUploaded():t.toDirty():t.updateUploaded()}else n&&(this._id+=1,this._parent.updateUploaded());return this}updateUploaded(){this._parent.updateUploaded()}clone(t){return new cd(t).copy(this)}toPoints(e){const i=[],s=this.values;for(let n=0,o=s.length;n<o;n+=2){const o=new t.Point(s[n+0],s[n+1]);i.push(e.apply(o,o))}return i}serialize(t){return t.addResource("[]")}calcHitPointAbs(t,e,i,s,n,o,r,a,h){const l=this.formatted,c=l.length,u=l.values,d=this._size,p=this._offset;let _=0,g=c;if(r){const i=.5*d.getLimit(),s=p.getLimit(),n=cd.WORK_RANGE;r(t,e,i,i,s,s,o,u,n),_=n[0],g=n[1]}for(let r=_,l=Math.min(g,c);r<l;++r){const l=r<<1,c=u[l],_=u[l+1];if(a(t,e,.5*d.getX(r),.5*d.getY(r),p.getX(r),p.getY(r),c,_,i,s,n,r,o,h))return!0}return!1}}cd.WORK_RANGE=[0,0];class ud extends td{init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(ql(e,i,s),ed(e,9,s,8,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexAndStep(i,t,e),this.updateLineOfAnyColor(i,t,e,9),this.updateUv(i,t)}}updateVertexAndStep(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=K(e),g=this.transformLocalId!==_,f=e.stroke,m=f.align,v=f.enable?f.width:0,T=f.style,w=this.strokeAlign!==m||this.strokeWidth!==v||this.strokeStyle!==T;if(!(this.inited&H.VERTEX_AND_STEP)||r||l||p||g||w){this.inited|=H.VERTEX_AND_STEP,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.transformLocalId=_,this.strokeWidth=v,this.strokeAlign=m,this.strokeStyle=T,t.updateVertices(),t.updateSteps();const l=this.pointCount,c=r.values,p=this.vertexOffset,g=t.vertices,f=t.steps,w=e.transform.internalTransform;if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Zl(g,p,0,0,t,e,m,v,w,jl),nd(g,w,p,9,l,c,n),Jl(f,p,v,T,jl),id(f,p,9,l)}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=p+9*t;Zl(g,h,i,s,o,r,m,v,w,jl),Jl(f,h,v,T,jl)}const E=p+9*l,y=9*(this.pointCountReserved-l);Ku(g,E,y),Xu(f,E,y)}}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=t.uvs,n=this.vertexOffset,o=j(i),r=this.pointCountReserved;0<r&&(Ql(e,n,o),sd(e,n,9,r))}}}const dd=(t,e,i,s,n,r,a,h)=>{const l=I(e),c=l<<2,u=l<<1,d=e.points,p=ju(ac(d)),_=p*s,g=p*r,f=_+c,m=g+u;return t.check(i,n,f,m)?new o(t,i,n,f,m,[new h(t,i,n,_,g,p,s,r),new le(t,i+_,n+g,c,u)]).init(e):null},pd=(t,e,i,s,n)=>dd(t,e,i,9,s,8,0,ud);class _d extends Bi{constructor(t=s.LINE_OF_CIRCLES){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new _d(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const gd=(t,e,i)=>Dl(t,e,i||new _d),fd=()=>{n[s.LINE_OF_CIRCLES]=pd,e[s.LINE_OF_CIRCLES]=gd};class md extends td{constructor(t,e,i,s,n,o,r,a){super(t,e,i,s,n,o,r,a),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(Ml(e,i,s),ed(e,Il,s,Ol,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUv(i,t,e),this.updateLineOfAnyColor(i,t,e,Il)}}updateVertexStepAndUv(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=e.radius,_=u!==this.sizeX||d!==this.sizeY||p!==this.radius,g=K(e),f=this.transformLocalId!==g,m=e.stroke,v=m.align,T=m.enable?m.width:0,w=m.side,E=m.style,y=this.strokeAlign!==v||this.strokeWidth!==T||this.strokeSide!==w||this.strokeStyle!==E,x=e.corner,C=x!==this.corner,D=X(e),S=Y(D),b=D!==this.texture||S!==this.textureTransformId,I=r||l||_||y,O=!(this.inited&H.VERTEX_STEP_AND_UV);if(O||I||f||C||b){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.radius=p,this.transformLocalId=g,this.strokeAlign=v,this.strokeWidth=T,this.strokeSide=w,this.strokeStyle=E,this.corner=x,this.texture=D,this.textureTransformId=S,t.updateVertices(),(O||I||f||C)&&t.updateSteps(),(O||I||b)&&t.updateUvs();const l=this.pointCount,c=r.values,_=this.vertexOffset,m=t.vertices,y=t.steps,A=t.uvs,R=e.transform.internalTransform,M=j(D);if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);kl(m,_,0,0,t,e,v,T,p,R,Al),nd(m,R,_,Il,l,c,n),(O||I||f||C)&&(Ll(y,_,T,w,E,x,Al),id(y,_,Il,l)),(O||I||b)&&(Nl(A,_,M,Al),sd(A,_,Il,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=_+t*Il;kl(m,h,i,s,o,r,v,T,p,R,Al),(O||I||f||C)&&Ll(y,h,T,w,E,x,Al),(O||I||b)&&Nl(A,h,M,Al)}const k=this.pointCountReserved,L=_+l*Il,N=Il*(k-l);Ku(m,L,N),Xu(y,L,N),Yu(A,L,N)}}}const vd=(t,e,i,s,n)=>dd(t,e,i,Il,s,Ol,0,md);class Td extends Hl{constructor(t=s.LINE_OF_RECTANGLE_ROUNDEDS){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Td(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,a,n,o,r,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const wd=(t,e,i)=>Dl(t,e,i||new Td),Ed=()=>{n[s.LINE_OF_RECTANGLE_ROUNDEDS]=vd,e[s.LINE_OF_RECTANGLE_ROUNDEDS]=wd,Ui.set(s.LINE_OF_RECTANGLE_ROUNDEDS,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)};class yd extends td{init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(zc(e,i,s),ed(e,Nc,s,8,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUv(i,t,e),this.updateLineOfAnyColor(i,t,e,Nc)}}updateVertexStepAndUv(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=K(e),g=this.transformLocalId!==_,f=e.stroke,m=f.align,v=f.enable?f.width:0,T=f.side,w=f.style,E=this.strokeAlign!==m||this.strokeWidth!==v||this.strokeSide!==T||this.strokeStyle!==w,y=X(e),x=Y(y),C=y!==this.texture||x!==this.textureTransformId,D=r||l||p||E,S=!(this.inited&H.VERTEX_STEP_AND_UV);if(S||D||g||C){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.transformLocalId=_,this.strokeWidth=v,this.strokeAlign=m,this.strokeSide=T,this.strokeStyle=w,this.texture=y,this.textureTransformId=x,t.updateVertices(),(S||D||g)&&t.updateSteps(),(S||D||C)&&t.updateUvs();const l=this.pointCount,c=r.values,u=this.vertexOffset,d=t.vertices,p=t.steps,f=t.uvs,E=e.transform.internalTransform,b=j(y);if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Uc(d,u,0,0,t,e,m,v,E,Pc),nd(d,E,u,Nc,l,c,n),(S||D||g)&&(Fc(u,p,v,T,w,Pc),id(p,u,Nc,l)),(S||D||C)&&(Hc(f,u,b),sd(f,u,Nc,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=u+t*Nc;Uc(d,h,i,s,o,r,m,v,E,Pc),(S||D||g)&&Fc(h,p,v,T,w,Pc),(S||D||C)&&Hc(f,h,b)}const I=this.pointCountReserved,O=u+l*Nc,A=Nc*(I-l);Ku(d,O,A),Xu(p,O,A),Yu(f,O,A)}}}const xd=(t,e,i,s,n)=>dd(t,e,i,Nc,s,8,0,yd);class Cd extends yo{constructor(t=s.LINE_OF_RECTANGLES){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Cd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const Dd=(t,e,i)=>Dl(t,e,i||new Cd),Sd=()=>{n[s.LINE_OF_RECTANGLES]=xd,e[s.LINE_OF_RECTANGLES]=Dd,Ui.set(s.LINE_OF_RECTANGLES,Ot.PRIMITIVE|Ot.STROKE_SIDE)},bd=22,Id=15,Od=[0,0,0,0,0],Ad=new t.Point,Rd=(t,e,i)=>{let s=3*i-1;t[++s]=e+0,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+3,t[++s]=e+4,t[++s]=e+5,t[++s]=e+7,t[++s]=e+5,t[++s]=e+6,t[++s]=e+7,t[++s]=e+8,t[++s]=e+9,t[++s]=e+11,t[++s]=e+9,t[++s]=e+10,t[++s]=e+11,t[++s]=e+12,t[++s]=e+13,t[++s]=e+16,t[++s]=e+13,t[++s]=e+14,t[++s]=e+16,t[++s]=e+14,t[++s]=e+15,t[++s]=e+16,t[++s]=e+12,t[++s]=e+16,t[++s]=e+19,t[++s]=e+16,t[++s]=e+17,t[++s]=e+19,t[++s]=e+17,t[++s]=e+18,t[++s]=e+19,t[++s]=e+12,t[++s]=e+19,t[++s]=e+13,t[++s]=e+19,t[++s]=e+20,t[++s]=e+13,t[++s]=e+20,t[++s]=e+21,t[++s]=e+13},Md=(t,e,i,s,n,o,r,a,h,l,c)=>{const u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u),_=Math.sqrt(d*d+4*p*p),g=2*d*p/(d+_),f=g*h/(2*p),m=.5*(_-g)*h/_,v=f*_/(2*d),T=Ad;T.set(i,s-p),l.apply(T,T);const w=T.x,E=T.y;T.set(i,s),l.apply(T,T);const y=T.x,x=T.y;T.set(i+d,s),l.apply(T,T);const D=y-w,S=x-E,b=T.x+D,I=T.y+S,O=y+(y-T.x)+D,A=x+(x-T.y)+S,R=b-w,M=I-E,k=w+m*R,L=E+m*M,N=b-f*R,P=I-f*M,B=v*(O-b),z=v*(A-I),U=b+B,F=I+z,H=O-B,G=A-z,V=w-O,W=E-A,K=O+f*V,X=A+f*W,Y=w-m*V,j=E-m*W;T.set(i,s+p-g),l.apply(T,T);const $=T.x,q=T.y,Z=w+h*($-w),J=E+h*(q-E),Q=b+h*($-b),tt=I+h*(q-I),et=O+h*($-O),it=A+h*(q-A),st=y+D,nt=x+S;c[0]=C(st,nt,$,q),c[1]=v,c[2]=f,c[3]=m,c[4]=1-.5*g/p;let ot=2*e-1;t[++ot]=Z,t[++ot]=J,t[++ot]=Y,t[++ot]=j,t[++ot]=w,t[++ot]=E,t[++ot]=k,t[++ot]=L,t[++ot]=Q,t[++ot]=tt,t[++ot]=N,t[++ot]=P,t[++ot]=b,t[++ot]=I,t[++ot]=U,t[++ot]=F,t[++ot]=et,t[++ot]=it,t[++ot]=H,t[++ot]=G,t[++ot]=O,t[++ot]=A,t[++ot]=K,t[++ot]=X,t[++ot]=$,t[++ot]=q,t[++ot]=Z,t[++ot]=J,t[++ot]=k,t[++ot]=L,t[++ot]=N,t[++ot]=P,t[++ot]=Q,t[++ot]=tt,t[++ot]=U,t[++ot]=F,t[++ot]=H,t[++ot]=G,t[++ot]=et,t[++ot]=it,t[++ot]=K,t[++ot]=X,t[++ot]=Y,t[++ot]=j},kd=(t,e,i,s,n,o,r)=>{const a=h(s),l=r[0],c=o*l,u=1-o,_=d(0,a,1,1),g=d(1,a,1,1),f=p(0,0),m=p(1,0),v=p(1,1),T=p(0,1),w=p(u,u),E=p(1,u),y=p(u,1),x=p(u,0);let C=6*e-1;n&nt.TOP?(t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=T,t[++C]=0):(t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=w,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=E,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=y,t[++C]=0),n&nt.BOTTOM_RIGHT?(t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=T,t[++C]=0):(t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=w,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=E,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=y,t[++C]=0),n&nt.BOTTOM_LEFT?(t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=g,t[++C]=c,t[++C]=c,t[++C]=T,t[++C]=0):(t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=w,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=E,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=v,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=y,t[++C]=0),t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=f,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=x,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=x,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=x,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0,t[++C]=i,t[++C]=_,t[++C]=l,t[++C]=l,t[++C]=m,t[++C]=0},Ld=(t,e,i,s,n)=>{const o=i.x0,r=i.x1,a=i.x2,h=i.x3,l=i.y0,c=i.y1,u=i.y2,d=i.y3,p=.5*(o+r),_=.5*(l+c),g=n[4],f=p+g*(h-o),m=_+g*(d-l),v=n[1],T=n[2],w=n[3],E=p+w*(h-p),y=_+w*(d-_),x=p+s*(f-p),C=_+s*(m-_),D=p+w*(a-p),S=_+w*(u-_),b=a+T*(p-a),I=u+T*(_-u),O=a+s*(f-a),A=u+s*(m-u),R=a+v*(h-a),M=u+v*(d-u),k=h+v*(a-h),L=d+v*(u-d),N=h+s*(f-h),P=d+s*(m-d),B=h+T*(p-h),z=d+T*(_-d);let U=2*e-1;t[++U]=x,t[++U]=C,t[++U]=E,t[++U]=y,t[++U]=p,t[++U]=_,t[++U]=D,t[++U]=S,t[++U]=O,t[++U]=A,t[++U]=b,t[++U]=I,t[++U]=a,t[++U]=u,t[++U]=R,t[++U]=M,t[++U]=N,t[++U]=P,t[++U]=k,t[++U]=L,t[++U]=h,t[++U]=d,t[++U]=B,t[++U]=z,t[++U]=f,t[++U]=m,t[++U]=x,t[++U]=C,t[++U]=D,t[++U]=S,t[++U]=b,t[++U]=I,t[++U]=O,t[++U]=A,t[++U]=R,t[++U]=M,t[++U]=k,t[++U]=L,t[++U]=N,t[++U]=P,t[++U]=B,t[++U]=z,t[++U]=E,t[++U]=y};class Nd extends td{constructor(t,e,i,s,n,o,r,a){super(t,e,i,s,n,o,r,a),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset,i=this.indexOffset,s=this.pointCountReserved;0<s&&(Rd(t.indices,e,i),ed(t.indices,bd,i,Id,s)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUv(i,t,e),this.updateLineOfAnyColor(i,t,e,bd)}}updateVertexStepAndUv(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=e.radius,g=_!==this.radius,f=K(e),m=this.transformLocalId!==f,v=e.stroke,T=v.align,w=v.enable?v.width:0,E=v.style,y=this.strokeAlign!==T||this.strokeWidth!==w||this.strokeStyle!==E,x=e.corner,C=this.corner!==x,D=X(e),S=Y(D),b=D!==this.texture||S!==this.textureTransformId,I=r||l||p||g||y,O=!(this.inited&H.VERTEX_STEP_AND_UV);if(O||I||m||C||b){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.radius=_,this.transformLocalId=f,this.strokeAlign=T,this.strokeWidth=w,this.strokeStyle=E,this.corner=x,this.texture=D,this.textureTransformId=S,t.updateVertices(),(O||I||m||C)&&t.updateSteps(),(O||I||b)&&t.updateUvs();const l=this.pointCount,c=r.values,p=this.vertexOffset,g=t.vertices,v=t.steps,y=t.uvs,A=e.transform.internalTransform,R=j(D);if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Md(g,p,0,0,t,e,T,w,_,A,Od),nd(g,A,p,bd,l,c,n),(O||I||m||C)&&(kd(v,p,w,E,x,_,Od),id(v,p,bd,l)),(O||I||b)&&(Ld(y,p,R,_,Od),sd(y,p,bd,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=p+t*bd;Md(g,h,i,s,o,r,T,w,_,A,Od),(O||I||m||C)&&kd(v,h,w,E,x,_,Od),(O||I||b)&&Ld(y,h,R,_,Od)}const M=this.pointCountReserved,k=p+l*bd,L=bd*(M-l);Ku(g,k,L),Xu(v,k,L),Yu(y,k,L)}}}const Pd=(t,e,i,s,n)=>dd(t,e,i,bd,s,Id,0,Nd),Bd=(t,e,i,s,n,o,r,a,h,l,c,u,d,p,_,g,f)=>{const m=o+u*(a-o)-s,v=r+u*(h-r)-n,T=Math.sqrt(m*m+v*v),w=1e-5;if(w<T){const a=1/T,h=m*a,u=v*a,E=(o+d*(l-o)-s)*a,y=(r+d*(c-r)-n)*a,x=h*y-E*u;if(w<Math.abs(x)){const o=1/x,r=e-s,a=i-n;if(((t,e,i,s,n,o,r)=>{if(t.fill.enable){if(e*e+i*i<=s*s)return!0}else if(0<o){const t=e*e+i*i;if(t<=s*s){const e=Math.max(0,s*(1-o*r/n));if(e*e<=t)return!0}}return!1})(t,(+y*r-E*a)*o,(-u*r+h*a)*o,T,p*_,g,f))return!0}}return!1},zd=(t,e,i,s,n,o,r)=>{const a=2*n/s;if(se(e,i,a,-n,+n)){const h=Math.sqrt(s*s+4*n*n),l=2*s*n/(s+h),c=t.radius,u=0,d=n-l,p=0,_=-n,g=+s,f=+n,m=-g,v=+f,T=p+c*(u-p),w=_+c*(d-_),E=g+c*(u-g),y=f+c*(d-f),x=+y,C=-E,D=-a*e+w-i<=0,S=+a*e+w-i<=0,b=i<=y,I=t.corner;if(!D&&!S&&I&nt.TOP){const s=.5*(h-l)*c/h;if(Bd(t,e,i,T,w,p,_,m,v,g,f,s,s,l,c,o,r))return!0}else if(!D&&!b&&I&nt.BOTTOM_LEFT){const a=l*c/(2*n);if(Bd(t,e,i,C,x,m,v,g,f,p,_,a*h/(2*s),a,l,c,o,r))return!0}else if(!S&&!b&&I&nt.BOTTOM_RIGHT){const a=l*c/(2*n);if(Bd(t,e,i,E,y,g,f,p,_,m,v,a,a*h/(2*s),l,c,o,r))return!0}else{if(t.fill.enable)return!0;if(0<o){const t=o*r,s=n-l,h=s+(-n-s)*Math.max(0,l-t)/l;if(!se(e,i,a,h,n-t))return!0}}}return!1};class Ud extends te{constructor(t=s.TRIANGLE_ROUNDED){super(t)}clone(){return new Ud(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&zd(this,t,e,i,s,n,o)}}class Fd extends Ud{constructor(t=s.LINE_OF_TRIANGLE_ROUNDEDS){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Fd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const Hd=(t,e,i)=>Dl(t,e,i||new Fd),Gd=()=>{n[s.LINE_OF_TRIANGLE_ROUNDEDS]=Pd,e[s.LINE_OF_TRIANGLE_ROUNDEDS]=Hd,Ui.set(s.LINE_OF_TRIANGLE_ROUNDEDS,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)};class Vd extends td{init(){const t=this.buffer;t.updateIndices();const e=t.indices,i=this.vertexOffset,s=this.indexOffset,n=this.pointCountReserved;0<n&&(xc(e,i,s),ed(e,7,s,3,n)),this.inited|=H.INDEX}update(t){const e=t.points;if(e instanceof cd){const i=this.buffer;this.updateVertexStepAndUvs(i,t,e),this.updateLineOfAnyColor(i,t,e,7)}}updateVertexStepAndUvs(t,e,i){const s=i.id,n=i.offset,o=n.id,r=s!==this.pointId||o!==this.pointOffsetId,a=i.size,h=a.id,l=h!==this.pointSizeId,c=e.size,u=c.x,d=c.y,p=u!==this.sizeX||d!==this.sizeY,_=K(e),g=this.transformLocalId!==_,f=e.stroke,m=f.align,v=f.enable?f.width:0,T=f.style,w=this.strokeAlign!==m||this.strokeWidth!==v||this.strokeStyle!==T,E=X(e),y=Y(E),x=E!==this.texture||y!==this.textureTransformId,C=r||l||p||w,D=!(this.inited&H.VERTEX_STEP_AND_UV);if(D||C||g||x){this.inited|=H.VERTEX_STEP_AND_UV,this.pointId=s;const r=i.formatted;this.pointCount=r.length,this.pointOffsetId=o,this.pointSizeId=h,this.sizeX=u,this.sizeY=d,this.transformLocalId=_,this.strokeAlign=m,this.strokeWidth=v,this.strokeStyle=T,this.texture=E,this.textureTransformId=y,t.updateVertices(),(D||C||g)&&t.updateSteps(),(D||C||x)&&t.updateUvs();const l=this.pointCount,c=r.values,p=this.vertexOffset,f=t.vertices,w=t.steps,S=t.uvs,b=j(E),I=e.transform.internalTransform;if(0<l&&a.isStaticX()&&a.isStaticY()){const t=a.getX(0),e=a.getY(0);Cc(f,p,0,0,t,e,m,v,I,Ec),nd(f,I,p,7,l,c,n),(D||C||g)&&(Dc(w,p,v,T,Ec),id(w,p,7,l)),(D||C||x)&&(Sc(S,b,p,Ec),sd(S,p,7,l))}else for(let t=0;t<l;++t){const e=t<<1,i=c[e]+n.getX(t),s=c[e+1]+n.getY(t),o=a.getX(t),r=a.getY(t),h=p+7*t;Cc(f,h,i,s,o,r,m,v,I,Ec),(D||C||g)&&Dc(w,h,v,T,Ec),(D||C||x)&&Sc(S,b,h,Ec)}const O=p+7*l,A=7*(this.pointCountReserved-l);Ku(f,O,A),Xu(w,O,A),Yu(S,O,A)}}}const Wd=(t,e,i,s,n)=>dd(t,e,i,7,s,3,0,Vd);class Kd extends te{constructor(t=s.TRIANGLE){super(t)}clone(){return new Kd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&ne(this,t,e,i,s,n,o)}}class Xd extends Kd{constructor(t=s.LINE_OF_TRIANGLES){super(t),this._points=new cd(this),this._tester=(t,e,i,s,n,o,r,a,h,l,c)=>this.containsPointAbs(t,e,i,s,n,o,r,a,h,l,c)}get points(){return this._points}clone(){return new Xd(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){const a=oe(n,o,this._points.size.getLimit());return!!this.containsAbsBBox(t,e,i+a,s+a)&&this._points.calcHitPointAbs(t,e,n,o,r,a,null,this._tester,null)}containsPointAbs(t,e,i,s,n,o,r,a,h,l,c){return super.containsAbs(t-r-n,e-a-o,i,s,h,l,c)}calcHitPoint(t,e,i,s,n,o){const r=this.toHitTestData(t,e),a=(i||oe)(r.strokeWidth,r.strokeScale,this._points.size.getLimit());return!!this.containsAbsBBox(r.x,r.y,r.width+a,r.height+a)&&this._points.calcHitPointAbs(r.x,r.y,r.strokeWidth,r.strokeScale,r.strokeAlign,a,s,n||this._tester,o)}}const Yd=(t,e,i)=>Dl(t,e,i||new Xd),jd=()=>{n[s.LINE_OF_TRIANGLES]=Wd,e[s.LINE_OF_TRIANGLES]=Yd},$d=(t,e,i,s)=>new o(t,i,s,0,0,[new Lc(t,i,s)]).init(e);class qd extends te{constructor(t=s.NULL){super(t)}clone(){return new qd(this.type).copy(this)}}const Zd=(t,e,i)=>Dl(t,e,i||new qd),Jd=()=>{n[s.NULL]=$d,e[s.NULL]=Zd},Qd=(t,e,i)=>Dl(t,e,i||new yo),tp=()=>{n[s.RECTANGLE]=xu,e[s.RECTANGLE]=Qd,Ui.set(s.RECTANGLE,Ot.PRIMITIVE|Ot.STROKE_SIDE)},ep=(t,e,i)=>Dl(t,e,i||new xo),ip=(t,e,i)=>Dl(t,e,i||new Hl),sp=()=>{n[s.RECTANGLE_ROUNDED]=Bl,e[s.RECTANGLE_ROUNDED]=ip,Ui.set(s.RECTANGLE_ROUNDED,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)},np=[0,0],op=new t.Point,rp=(t,e,i)=>{let s=3*i-1;t[++s]=e,t[++s]=e+1,t[++s]=e+3,t[++s]=e+1,t[++s]=e+4,t[++s]=e+3,t[++s]=e+1,t[++s]=e+2,t[++s]=e+4,t[++s]=e+2,t[++s]=e+5,t[++s]=e+4},ap=(t,e,i,s,n,o,r,a,h,l)=>{const c=op,u=r*a,d=.5*n+(0<=n?+u:-u),p=.5*o+(0<=o?+u:-u);c.set(-d+i,-p+s),h.apply(c,c);const _=c.x,g=c.y;c.set(0+i,-p+s),h.apply(c,c);const f=c.x,m=c.y,v=f-_,T=m-g;c.set(i,s),h.apply(c,c);const w=c.x,E=c.y,y=w-v,x=E-T;let D=2*e-1;t[++D]=_,t[++D]=g,t[++D]=f,t[++D]=m,t[++D]=f+v,t[++D]=m+T,t[++D]=y,t[++D]=x,t[++D]=w,t[++D]=E,t[++D]=w+v,t[++D]=E+T,l[0]=C(_,g,f,m),l[1]=C(_,g,y,x)},hp=(t,e,i,s,n)=>{const o=h(s),r=n[0],a=n[1],l=d(1,o,1,1),c=p(1,1),u=p(0,1),_=p(1,0),g=p(0,0);let f=6*e-1;t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=u,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=c,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=g,t[++f]=0,t[++f]=i,t[++f]=l,t[++f]=r,t[++f]=a,t[++f]=_,t[++f]=0},lp=(t,e,i)=>{const s=i.x0,n=i.x1,o=i.x2,r=i.x3,a=i.y0,h=i.y1,l=i.y2,c=i.y3;let u=2*e-1;t[++u]=s,t[++u]=a,t[++u]=.5*(s+n),t[++u]=.5*(a+h),t[++u]=n,t[++u]=h,t[++u]=.5*(s+r),t[++u]=.5*(a+c),t[++u]=.5*(s+o),t[++u]=.5*(a+l),t[++u]=.5*(n+o),t[++u]=.5*(h+l)};class cp extends W{constructor(t,e,i){super(t,e,i,6,4)}init(){const t=this.buffer;t.updateIndices();const e=this.vertexOffset;rp(t.indices,e,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexAndStep(e,t),this.updateColor(e,t),this.updateUv(e,t)}updateVertexAndStep(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u;(!(this.inited&H.VERTEX_AND_STEP)||o||a||d)&&(this.inited|=H.VERTEX_AND_STEP,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,t.updateVertices(),t.updateSteps(),ap(t.vertices,this.vertexOffset,0,0,s,n,l,c,e.transform.internalTransform,np),hp(t.steps,this.vertexOffset,c,u,np))}updateUv(t,e){const i=X(e),s=Y(i);if(!(this.inited&H.UV)||i!==this.texture||s!==this.textureTransformId){this.inited|=H.UV,this.texture=i,this.textureTransformId=s,t.updateUvs();const e=j(i);lp(t.uvs,this.vertexOffset,e)}}}const up=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=6+a,c=4+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new cp(t,i,s),new le(t,i+6,s+4,a,h)]).init(e):null},dp=(t,e,i,s,n,o,r)=>i<=0&&ee(t,e,i,s,n,o,r);class pp extends te{constructor(t=s.SEMICIRCLE){super(t),this.stroke.side=V.ALL&~V.BOTTOM}clone(){return new pp(this.type).copy(this)}containsAbs(t,e,i,s,n,o,r){return!!super.containsAbsBBox(t,e,i,s)&&dp(this,t,e,i,s,n,o)}}const _p=(t,e,i)=>Dl(t,e,i||new pp),gp=()=>{n[s.SEMICIRCLE]=up,e[s.SEMICIRCLE]=_p};class fp extends W{constructor(t,e,i){super(t,e,i,7,3)}init(){const t=this.buffer;t.updateIndices(),xc(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=K(e),a=this.transformLocalId!==r,h=e.stroke,l=h.align,c=h.enable?h.width:0,u=h.style,d=this.strokeAlign!==l||this.strokeWidth!==c||this.strokeStyle!==u,p=X(e),_=Y(p),g=p!==this.texture||_!==this.textureTransformId,f=o||d,m=!(this.inited&H.VERTEX_STEP_AND_UV);if(m||f||a||g){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.transformLocalId=r,this.strokeAlign=l,this.strokeWidth=c,this.strokeStyle=u,this.texture=p,this.textureTransformId=_;const i=this.vertexOffset;t.updateVertices(),Cc(t.vertices,i,0,0,s,n,l,c,e.transform.internalTransform,Ec),(m||f||a)&&(t.updateSteps(),Dc(t.steps,i,c,u,Ec)),(m||f||g)&&(t.updateUvs(),Sc(t.uvs,j(p),i,Ec))}}}const mp=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=7+a,c=3+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new fp(t,i,s),new le(t,i+7,s+3,a,h)]).init(e):null},vp=(t,e,i)=>Dl(t,e,i||new Kd),Tp=()=>{n[s.TRIANGLE]=mp,e[s.TRIANGLE]=vp};class wp extends W{constructor(t,e,i){super(t,e,i,bd,Id),this.radius=0,this.corner=0}init(){const t=this.buffer;t.updateIndices(),Rd(t.indices,this.vertexOffset,this.indexOffset),this.inited|=H.INDEX}update(t){const e=this.buffer;this.updateVertexStepAndUv(e,t),this.updateColor(e,t)}updateVertexStepAndUv(t,e){const i=e.size,s=i.x,n=i.y,o=s!==this.sizeX||n!==this.sizeY,r=e.radius,a=r!==this.radius,h=K(e),l=this.transformLocalId!==h,c=e.stroke,u=c.align,d=c.enable?c.width:0,p=c.style,_=this.strokeAlign!==u||this.strokeWidth!==d||this.strokeStyle!==p,g=e.corner,f=g!==this.corner,m=X(e),v=Y(m),T=m!==this.texture||v!==this.textureTransformId,w=o||a||_,E=!(this.inited&H.VERTEX_STEP_AND_UV);if(E||w||l||f||T){this.inited|=H.VERTEX_STEP_AND_UV,this.sizeX=s,this.sizeY=n,this.radius=r,this.transformLocalId=h,this.strokeAlign=u,this.strokeWidth=d,this.strokeStyle=p,this.corner=g,this.texture=m,this.textureTransformId=v;const i=this.vertexOffset;t.updateVertices(),Md(t.vertices,i,0,0,s,n,u,d,r,e.transform.internalTransform,Od),(E||w||l||f)&&(t.updateSteps(),kd(t.steps,i,d,p,g,r,Od)),(E||w||T)&&(t.updateUvs(),Ld(t.uvs,i,j(m),r,Od))}}}const Ep=(t,e,i,s,n)=>{const r=I(e),a=r<<2,h=r<<1,l=bd+a,c=Id+h;return t.check(i,s,l,c)?new o(t,i,s,l,c,[new wp(t,i,s),new le(t,i+bd,s+Id,a,h)]).init(e):null},yp=(t,e,i)=>Dl(t,e,i||new Ud),xp=()=>{n[s.TRIANGLE_ROUNDED]=Ep,e[s.TRIANGLE_ROUNDED]=yp,Ui.set(s.TRIANGLE_ROUNDED,Ot.PRIMITIVE|Ot.STROKE_SIDE|Ot.BORDER_RADIUS)},Cp=()=>{bl(),Yl(),sc(),iu(),su(),uu(),Eu(),mu(),Su(),n[s.IMAGE_SDF]=Lu,e[s.IMAGE_SDF]=Pu,Hu(),Wu(),Jd(),n[s.RECTANGLE_PIVOTED]=ou,e[s.RECTANGLE_PIVOTED]=ep,Ui.set(s.RECTANGLE_PIVOTED,Ot.PRIMITIVE|Ot.STROKE_SIDE),sp(),tp(),gp(),xp(),Tp(),fd(),Ed(),Sd(),Gd(),jd()};class Dp extends Oa{getType(){return"DImage"}}class Sp extends Dp{constructor(t){var e;super(t),this._value=null!==(e=null==t?void 0:t.value)&&void 0!==e?e:null}init(t){super.init(t),this.on(nn.tap,t=>{this.onClick(t)})}onClick(t){this.state.isActionable&&this.activate(t)}activate(t){this.onSelect(t)}get value(){return this._value}set value(t){this._value=t}hasSelection(t){return t&&t.selection&&t.selection.add}getSelection(){let t=this.parent;for(;t;){if(this.hasSelection(t))return t.selection;t=t.parent}return null}onSelect(t){this.emit("select",this._value,this);const e=this.getSelection();e&&e.add(this)}onKeyDown(t){return $n.isActivateKey(t)&&this.onKeyDownActivate(t),super.onKeyDown(t)}onKeyDownActivate(t){return!(!this.state.isActionable||!this.state.isFocused||(this.activate(t),0))}getType(){return"DMenuItemBase"}}class bp extends Sp{getContext(){let t=this.parent;for(;t;){if(t.getContext)return t.getContext();t=t.parent}return null}getCloseable(){let t=this.parent;for(;t;){if(t.getCloseable)return t.getCloseable();t=t.parent}return null}getType(){return"DMenuItem"}}class Ip extends bp{init(t){super.init(t),this.initOnOver(t),this.initShortcuts(t)}initOnOver(t){this.on(nn.over,()=>{const t=this.getContext();null!=t&&this.parent instanceof to&&t.trim(this.getCloseable())})}initShortcuts(t){const e=this._shortcuts;if(null!=e&&0<e.length){const t=e[0],i=this.newShortcutText();this._shortcutText=i,this.snippet.add(i,!0),i.text=$n.toString(t)}else this._shortcutText=null;this._shortcutMargin=this.theme.getShortcutTextMargin()}newShortcutText(){var t,e;return new ga(new fa(this,this.theme,null===(e=null===(t=this._options)||void 0===t?void 0:t.text)||void 0===e?void 0:e.style))}updateShortcutText(){const t=this._shortcutText,e=this._shortcutMargin;if(null!=t&&null!=e){const i=this._auto;let s=0;s=i.width.isOn?e:this.width-t.width-e;let n=0;const o=this._padding,r=o.getTop();n=i.height.isOn?r:r+.5*(this.height-r-o.getBottom()-t.height),t.position.set(s,n)}}updateShortcutColor(){const t=this._shortcutText;if(null!=t){const e=this.theme,i=this.state;t.style.fill=e.getShortcutColor(i),t.alpha=e.getShortcutAlpha(i)}}onReflow(){super.onReflow(),this.updateShortcutColor(),this.updateShortcutText()}getType(){return"DMenuItemText"}onSelect(t){super.onSelect(t);const e=this.getCloseable();null!=e&&e.emit("select",this.value,this,e)}onShortcut(t){super.onShortcut(t),this.activate(t)}}class Op extends Ip{init(t){super.init(t),(null==t?void 0:t.check)&&(this.state.isActive=!0)}getType(){return"DMenuItemCheck"}onSelect(t){this.state.isActive=!this.state.isActive,super.onSelect(t)}}const Ap=t=>"check"in t,Rp={OPEN_LINK:0,OPEN_LINK_IN_NEW_WINDOW:1,COPY_LINK_ADDRESS:2};class Mp{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static setMenuCreator(t){this.MENU_CREATOR=t}static newItemOf(t,e,i,s){for(let e=0,n=t.length;e<n;++e){const n=t[e](i,s);if(null!=n)return n}return e?e(i,s):null}static newItem(t,e){return this.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)}static newItemsOf(e,i,s,n){for(let o=0,r=s.length;o<r;++o){const r=s[o];if(r instanceof t.DisplayObject)i.addChild(r);else if(null!=r){const t=e.newItem(r,n);if(null==t)throw new Error("No matching menu item creator found: "+JSON.stringify(r));i.addChild(t)}}}static newItems(t,e,i){this.newItemsOf(this,t,e,i)}static newMenu(t){if(null!=this.MENU_CREATOR)return this.MENU_CREATOR(t);throw new Error("Missing DMenu creator.")}}Mp.CREATORS=[],Mp.CREATOR_DEFAULT=null;class kp{constructor(t,e){this._parent=t,this._options=e,this._isEnabled=!0}get enable(){return this._isEnabled}set enable(t){this._isEnabled=t}open(t){this.get().open(t)}get(){let t=this._menu;return null==t&&(t=this.toMenu(this._options),this._menu=t,t.on("select",(t,e,i)=>{this.onSelect(t,e,i)})),t}toMenu(e){return e instanceof t.DisplayObject?e:this.newMenu(e)}newMenu(t){return Mp.newMenu(t)}onSelect(t,e,i){const s=this._parent;switch(t){case Rp.OPEN_LINK:s.open(!1);break;case Rp.OPEN_LINK_IN_NEW_WINDOW:s.open(!0);break;case Rp.COPY_LINK_ADDRESS:s.copy()}}}const Lp={AUTO:0,THIS_WINDOW:1,NEW_WINDOW:2},Np=t=>{const e=document.getSelection();if(e){const i=document.createRange();i.selectNodeContents(t),e.removeAllRanges(),e.addRange(i)}return e},Pp=t=>t.clipboardData||window.clipboardData;class Bp extends t.utils.EventEmitter{constructor(t){super();const e=document.body;e.addEventListener("copy",i=>{i.target!==e&&i.target!==t||(i.preventDefault(),i.stopPropagation(),this.emit("copy",Pp(i)))}),e.addEventListener("cut",i=>{i.target!==e&&i.target!==t||(i.preventDefault(),i.stopPropagation(),this.emit("cut",Pp(i)))}),e.addEventListener("paste",i=>{i.target!==e&&i.target!==t||(i.preventDefault(),i.stopPropagation(),this.emit("paste",Pp(i)))})}static copy(t){const e=navigator.clipboard;e&&e.writeText?e.writeText(t):((t,e)=>{if("undefined"==typeof ClipboardEvent){const i=t.clipboardData;if(void 0!==i&&void 0!==i.setData)return i.setData("Text",e),!0}return!1})(window,t)||(t=>{const e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important"),e.textContent="Dummy",document.body.appendChild(e);const i=Np(e);let s=!1;if(i){const n=i=>{if(i.target===e){const e=Pp(i);e.setData("text/plain",t),s=e.getData("text/plain")===t,i.preventDefault()}};document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}i.removeAllRanges()}return document.body.removeChild(e),s})(t)||navigator.userAgent.indexOf("Edge")<0&&(t=>{const e=document.createElement("div");e.setAttribute("style","-webkit-user-select: text !important");const i=document.createElement("span");i.innerText=t,(e.attachShadow?e.attachShadow({mode:"open"}):e).appendChild(i),document.body.appendChild(e);const s=Np(e);s&&(document.execCommand("copy"),s.removeAllRanges()),document.body.removeChild(e)})(t)}}class zp{constructor(t){this._options=t,this._url=null==t?void 0:t.url,this._target=this.toNormalizedTarget(null==t?void 0:t.target),this._checker=null==t?void 0:t.checker,this._isEnabled=!0}get enable(){return this._isEnabled}set enable(t){this._isEnabled=t}get url(){return this._url}set url(t){this._url=t}get target(){return this._target}set target(t){this._target=this.toNormalizedTarget(t)}get checker(){return this._checker}set checker(t){this._checker=t}get menu(){let t=this._menu;return null==t&&(t=this.newMenu(),this._menu=t),t}newMenu(){const t=this._options;if(t){const e=t.menu;if(e)return new kp(this,e)}let e=zp.MENU;return null==e&&(e=new kp(this,$.getInstance().get("DLink").getMenuOptions()),zp.MENU=e),e}toStringifiedUrl(t,e){const i=Tt(t)?t():t;null!=i&&(Et(i)?e(i):i.then(t=>{null!=t&&e(t)}))}toNormalizedUrl(t){const e=zp.ANCHOR_ELEMENT||document.createElement("a");return zp.ANCHOR_ELEMENT=e,e.href=t,e.href}toNormalizedTarget(t){return Qi(null!=t?t:Lp.AUTO,Lp)}copy(){this.toStringifiedUrl(this._url,t=>{Bp.copy(this.toNormalizedUrl(t))})}open(t){this.toStringifiedUrl(this._url,e=>{const i=!0===t||!1===t?t:this.inNewWindow(t);this.check(e,i,()=>{this.exec(e,i)})})}check(t,e,i){const s=this._checker;if(s){const t=s();!0===t?i():!1===t||t.then(t=>{t&&i()})}else i()}exec(t,e){if(e){const e=document.createElement("a");e.href=t,e.target="_blank",e.style.display="none",e.rel="noopener noreferrer",document.body.appendChild(e),e.click(),setTimeout(()=>{document.body.removeChild(e)},100)}else window.location.href=t}inNewWindow(e){switch(this._target){case Lp.NEW_WINDOW:return!0;case Lp.THIS_WINDOW:return!1;case Lp.AUTO:if(null!=e){const i=e instanceof t.InteractionEvent?e.data.originalEvent:e;return i.ctrlKey||i.shiftKey||i.altKey||i.metaKey||"button"in i&&0!==i.button}return!1}}onClick(t,e){if(this._target===Lp.AUTO){const i=e.data.originalEvent;if("pointerType"in i&&"mouse"!==i.pointerType||"touches"in i){const e=this.menu;if(e.enable)return this._isEnabled&&t.state.isActionable&&e.open(t),!0}}return!this._isEnabled}}class Up{static toStateOptions(t,e){if(e&&(t===Lp.NEW_WINDOW||"NEW_WINDOW"===t)){const t=e.state;if(null==t)e.state=lt.NEW_WINDOW;else if(Et(t))t!==lt.NEW_WINDOW&&(e.state=[t,lt.NEW_WINDOW]);else if(vt(t))t.indexOf(lt.NEW_WINDOW)<0&&t.push(lt.NEW_WINDOW);else{const e=t.values;null==e?t.values=lt.NEW_WINDOW:Et(e)?e!==lt.NEW_WINDOW&&(t.values=[e,lt.NEW_WINDOW]):e.indexOf(lt.NEW_WINDOW)<0&&e.push(lt.NEW_WINDOW)}}return e}}class Fp extends Ip{toLinkOptions(t){if(t)return{url:this.toUrl(t.url),target:t.target,checker:this.toChecker(t.checker),menu:t.menu}}toUrl(t){return Et(t)||null==t?t:()=>t(this)}toChecker(t){if(null!=t)return()=>t(this)}init(t){super.init(Up.toStateOptions(null==t?void 0:t.target,t))}get link(){let t=this._link;return null==t&&(t=new zp(this.toLinkOptions(this._options)),this._link=t),t}onClick(t){this.link.onClick(this,t)||super.onClick(t)}getType(){return"DMenuItemLink"}onSelect(t){super.onSelect(t),this.link.open(t)}open(t){this.link.open(t)}onShortcut(t){super.onShortcut(t),this.activate(t)}}const Hp=t=>"url"in t;class Gp extends bp{init(t){super.init(t),this.initHover(t)}initHover(t){this.on(nn.over,()=>{this.state.isActionable&&this.open()})}toMenu(e){const i=null==e?void 0:e.menu;return i instanceof t.DisplayObject?i:this.newMenu(i)}newMenu(t){return Mp.newMenu(t)}get menu(){let t=this._menu;return null==t&&(t=this.toMenu(this._options),t.on("select",(t,e,i)=>{this.onMenuSelect(t,e,i)}),this._menu=t),t}getType(){return"DMenuItemMenu"}open(){const t=this.menu;t.isHidden()&&this.onOpen(t)}onOpen(t){const e=this.getContext();null!=e&&t.open(this,this.getCloseable(),e)}close(){this.menu.close()}toggle(){const t=this.menu;t.isHidden()?this.onOpen(t):t.close()}onSelect(t){this.open(),super.onSelect(t)}onMenuSelect(t,e,i){const s=this.getCloseable();null!=s&&s.emit("select",t,e,s)}onKeyDown(t){return $n.isArrowRightKey(t)&&this.onKeyDownArrowRight(t),super.onKeyDown(t)}onKeyDownArrowRight(t){return!(!this.state.isActionable||!this.state.isFocused||(this.onSelect(t),0))}}const Vp=t=>"menu"in t,Wp=(e,i)=>{const s=e.menu;return s instanceof t.DisplayObject||(null==s.sticky&&(s.sticky=i),null==s.align&&(s.align=kr.RIGHT)),e};class Kp extends t.Graphics{constructor(t){super(),t.snippet.add(this,!0),t.reflowable.add(this)}onReflow(t,e,i){const s=t.state,n=t.border,o=n.getWidth(s),r=n.getColor(s);if(null!=r){const a=n.getAlpha(s),h=n.getAlign(s),l=t.padding,c=.5*i;this.clear(),this.lineStyle(o,r,a,h),this.moveTo(l.getLeft(),c),this.lineTo(e-l.getRight(),c),this.visible=!0}else this.clear(),this.visible=!1}}const Xp=t=>"separator"in t;class Yp extends Sp{initReflowable(){new Kp(this)}getType(){return"DMenuItemSeparator"}}class jp extends Wr{getType(){return"DMenuItemSpace"}}const $p=t=>"space"in t,qp=()=>{Mp.addItemCreator(t=>Ap(t)?new Op(t):null),Mp.addItemCreator(t=>Hp(t)?new Fp(t):null),Mp.addItemCreator((t,e)=>Vp(t)?new Gp(Wp(t,e)):null),Mp.addItemCreator(t=>Xp(t)?new Yp(t):null),Mp.addItemCreator(t=>$p(t)?new jp(t):null),Mp.setItemCreatorDefault(t=>new Ip(t))};class Zp extends Yr{getType(){return"DMenuItemExpandableBody"}}class Jp extends Sp{getSelection(){return null}getType(){return"DMenuItemExpandableHeader"}}class Qp{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static newItem(t,e){return Mp.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)||Mp.newItem(t,e)}static newItems(t,e,i){Mp.newItemsOf(this,t,e,i)}}Qp.CREATORS=[],Qp.CREATOR_DEFAULT=null;class t_ extends Yr{init(t){var e;super.init(t);const i=this.theme,s=this.toHeader(i,t);this._header=s,s.on("select",()=>{this.toggle()}),this.addChild(s);const n=this.toBody(i,t);this._body=n;const o=null!==(e=null==t?void 0:t.sticky)&&void 0!==e&&e;this.newItems(n,o,i,t),this.addChild(n),this.state.isActive?this.onActivated():this.onDeactivated()}newItems(t,e,i,s){const n=null==s?void 0:s.items;null!=n&&Qp.newItems(t,n,e)}toHeader(e,i){return i?i.header instanceof t.DisplayObject?i.header:this.newHeader(e,i.header):this.newHeader(e)}newHeader(t,e){return new Jp(e)}toBody(e,i){const s=null==i?void 0:i.body;return s?s instanceof t.DisplayObject?s:this.newBody(e,s):this.newBody(e)}newBody(t,e){return new Zp(e)}open(){this.state.isActive=!0}close(){this.state.isActive=!1}toggle(){this.state.isActive=!this.state.isActive}onActivated(){const t=this._body;t instanceof to?t.show():t.visible=!0}onDeactivated(){const t=this._body;t instanceof to?t.hide():t.visible=!1}onStateChange(t,e){super.onStateChange(t,e),t.isActive?e.isActive||this.onActivated():e.isActive&&this.onDeactivated()}onKeyDown(t){if($n.isArrowRightKey(t)){if(this.state.isActionable&&!this.state.isActive){const t=this._header;t instanceof to&&t.state.isFocused&&(this.state.isActive=!0)}}else if($n.isArrowLeftKey(t)&&this.state.isActionable&&this.state.isActive){const e=this._header;return e instanceof to?e.focus():this.focus(),this.state.isActive=!1,super.onKeyDown(t),!0}return super.onKeyDown(t)}getType(){return"DMenuItemExpandable"}}const e_=t=>"header"in t;class i_ extends Op{getType(){return"DMenuItemExpandableItemCheck"}}class s_ extends Fp{getType(){return"DMenuItemExpandableItemLink"}}class n_ extends Yp{getType(){return"DMenuItemExpandableItemSeparator"}}class o_ extends jp{getType(){return"DMenuItemExpandableItemSpace"}}class r_ extends Ip{getType(){return"DMenuItemExpandableItemText"}}const a_=()=>{Mp.addItemCreator(t=>e_(t)?new t_(t):null),Qp.addItemCreator(t=>Ap(t)?new i_(t):null),Qp.addItemCreator(t=>Hp(t)?new s_(t):null),Qp.addItemCreator(t=>Xp(t)?new n_(t):null),Qp.addItemCreator(t=>$p(t)?new o_(t):null),Qp.setItemCreatorDefault(t=>new r_(t))};class h_ extends Op{getType(){return"DMenuSidedItemCheck"}}class l_ extends Fp{getSelection(){return null}getType(){return"DMenuSidedItemLink"}}class c_ extends Gp{initHover(t){}onMenuSelect(t,e,i){super.onMenuSelect(t,e,i);const s=super.getSelection();s&&s.add(e)}onOpen(t){t.open(this,this)}getSelection(){return null}getType(){return"DMenuSidedItemMenu"}}class u_ extends Yp{getType(){return"DMenuSidedItemSeparator"}}class d_ extends jp{getType(){return"DMenuSidedItemSpace"}}class p_ extends Ip{getType(){return"DMenuSidedItemText"}}class __{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static newItem(t,e){return Mp.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)||Mp.newItem(t,e)}static newItems(t,e,i){Mp.newItemsOf(this,t,e,i)}}__.CREATORS=[],__.CREATOR_DEFAULT=null;const g_=()=>{__.setItemCreatorDefault(t=>new p_(t)),__.addItemCreator(t=>$p(t)?new d_(t):null),__.addItemCreator(t=>Xp(t)?new u_(t):null),__.addItemCreator((t,e)=>Vp(t)?new c_(Wp(t,e)):null),__.addItemCreator(t=>Hp(t)?new l_(t):null),__.addItemCreator(t=>Ap(t)?new h_(t):null)};class f_{static addItemCreator(t){this.CREATORS.push(t)}static setItemCreatorDefault(t){this.CREATOR_DEFAULT=t}static newItem(t,e){return Mp.newItemOf(this.CREATORS,this.CREATOR_DEFAULT,t,e)||__.newItem(t,e)}static newItems(t,e,i){Mp.newItemsOf(this,t,e,i)}}f_.CREATORS=[],f_.CREATOR_DEFAULT=null;class m_ extends t_{newItems(t,e,i,s){null!=s&&null!=s.items&&f_.newItems(t,s.items,e)}getType(){return"DMenuSidedItemExpandable"}}class v_ extends i_{getType(){return"DMenuSidedItemExpandableItemCheck"}}class T_ extends Fp{getType(){return"DMenuSidedItemExpandableItemLink"}}class w_ extends Gp{getType(){return"DMenuItemExpandableItemMenu"}}class E_ extends w_{onOpen(t){t.open(this,this)}getType(){return"DMenuSidedItemExpandableItemMenu"}}class y_ extends n_{getType(){return"DMenuSidedItemSeparator"}}class x_ extends o_{getType(){return"DMenuSidedItemExpandableItemSpace"}}class C_ extends r_{getType(){return"DMenuSidedItemExpandableItemText"}}const D_=()=>{__.addItemCreator(t=>e_(t)?new m_(t):null),f_.addItemCreator(t=>Ap(t)?new v_(t):null),f_.addItemCreator(t=>Hp(t)?new T_(t):null),f_.addItemCreator((t,e)=>Vp(t)?new E_(Wp(t,e)):null),f_.addItemCreator(t=>Xp(t)?new y_(t):null),f_.addItemCreator(t=>$p(t)?new x_(t):null),f_.setItemCreatorDefault(t=>new C_(t))},S_=()=>{qp(),a_(),g_(),D_()},b_=()=>{S_(),Cp()},I_=(t,e)=>e?Cl(t).then(t=>{const e=Fs.getInstance().init();e.updateTexture(t.width,t.height,t.source),e.render();const i=document.createElement("canvas");return e.read(i),I_(i.toDataURL(),!1)}):Cl(t).then(t=>new Nu(t)),O_=t=>"data:image/svg+xml;base64,"+btoa(t),A_=t=>Math.round(100*t)/100,R_=Pi;class M_{static from(t){if(Et(t))return F[t];if(wt(t))return t;if(null!=t){let e=F.NONE;for(let i=0,s=t.length;i<s;++i)e|=F[t[i]];return e}return F.NONE}}class k_{constructor(){this.resources=[],this.resourceToIndex=new Map,this.data=[],this.dataToIndex=new Map,this.pieces=[],this.pieceToIndex=new Map,this.uuids=new Set,this.uuidNext=0}addResource(t){return this.add_(t,this.resources,this.resourceToIndex)}addData(t){return this.add_(t,this.data,this.dataToIndex)}addPiece(t){return this.add_(t,this.pieces,this.pieceToIndex)}addUuid(t){if(0!==t){const e=this.uuids;return e.has(t)?0:(e.add(t),t)}return 0}updateUuid(t){const e=this.uuids;if(0!==t)return t;{const t=this.newUuid();return e.add(t),t}}newUuid(){const t=this.uuids;let e=this.uuidNext;for(;;)if(e+=1,0!==e&&!t.has(e))return this.uuidNext=e,e}add_(t,e,i){const s=i.get(t);if(null!=s)return s;const n=e.length;return e.push(t),i.set(t,n),n}}class L_ extends t.utils.EventEmitter{constructor(t,e){var i,s,n;super(),this._isVisibleDefault=null!==(i=null==e?void 0:e.visible)&&void 0!==i?i:t.isSnapGridVisible(),this._isVisible=this._isVisibleDefault,this._isEnabledDefault=null!==(s=null==e?void 0:e.enable)&&void 0!==s?s:t.isSnapGridEnabled(),this._isEnabled=this._isEnabledDefault,this._sizeDefault=null!==(n=null==e?void 0:e.size)&&void 0!==n?n:t.getSnapGridSize(),this._size=this._sizeDefault}get visible(){return this._isVisible}set visible(t){this._isVisible!==t&&(this._isVisible=t,this.emit("change",this))}get enable(){return this._isEnabled}set enable(t){this._isEnabled!==t&&(this._isEnabled=t,this.emit("change",this))}get size(){return this._size}set size(t){this._size!==t&&(this._size=t,this.emit("change",t,this))}snap(t,e){if(this._isEnabled){const i=this._size;e.set(t,Math.round(t/i)*i)}}reset(){this._isVisible=this._isVisibleDefault,this._isEnabled=this._isEnabledDefault,this._size=this._sizeDefault,this.emit("change",this)}serialize(){return[this._isEnabled?1:0,this._isVisible?1:0,this._size]}deserialize(t){this.enable=!!t[0],2 in t?(this.visible=!!t[1],this.size=t[2]):(this.visible=this._isVisibleDefault,this.size=t[1])}}class N_{constructor(){this.distance=NaN,this.result=0,this.threshold=10}reset(t,e){this.distance=NaN,this.result=t,this.threshold=1e-4<e?10/e:10}set(t,e){const i=Math.abs(e-t);if(i<=this.threshold){const t=this.distance;(t!=t||i<t)&&(this.distance=i,this.result=e)}}}const P_={HORIZONTAL:0,VERTICAL:1};class B_{constructor(t,e){this.type=t,this.position=e}serialize(){return[this.type,this.position]}}class z_ extends t.utils.EventEmitter{constructor(t,e){var i,s;super(),this.values=[],this._isVisibleDefault=null!==(i=null==e?void 0:e.visible)&&void 0!==i?i:t.isSnapTargetVisible(),this._isVisible=this._isVisibleDefault,this._isEnabledDefault=null!==(s=null==e?void 0:e.enable)&&void 0!==s?s:t.isSnapTargetEnabled(),this._isEnabled=this._isEnabledDefault}get enable(){return this._isEnabled}set enable(t){this._isEnabled!==t&&(this._isEnabled=t,this.emit("change",this))}get visible(){return this._isVisible}set visible(t){this._isVisible!==t&&(this._isVisible=t,this.emit("change",this))}get size(){return this.values.length}add(t,e){null!=e?this.values.splice(e,0,t):this.values.push(t),this.emit("change",this)}remove(t){const e=this.values;0<=t&&t<e.length&&(e.splice(t,1),this.emit("change",this))}replace(t,e){const i=this.values;if(0<=t&&t<i.length){const s=i[t];return i[t]=e,this.emit("change",this),s}return null}swap(t,e){if(t!==e){const i=this.values,s=i[t];i[t]=i[e],i[e]=s,this.emit("change",this)}}snap(t,e,i,s){if(this._isEnabled){const n=this.values;for(let o=0,r=n.length;o<r;++o){const r=n[o];r.type===P_.VERTICAL?i.set(t,r.position):s.set(e,r.position)}}}reset(){this._isEnabled=this._isEnabledDefault,this._isVisible=this._isVisibleDefault,this.values.length=0,this.emit("change",this)}serialize(){const t=[],e=this.values;for(let i=0,s=e.length;i<s;++i)t.push(e[i].serialize());return[this._isEnabled?1:0,this._isVisible?1:0,t]}deserialize(t){this._isEnabled=!!t[0],this._isVisible=!!t[1];const e=t[2],i=this.values;i.length=0;for(let t=0,s=e.length;t<s;++t){const s=e[t];i.push(new B_(s[0],s[1]))}this.emit("change",this)}}const U_=1e-5,F_={NONE:0,TOP_LEFT:1,TOP_CENTER:2,TOP_RIGHT:3,MIDDLE_LEFT:4,MIDDLE_RIGHT:5,BOTTOM_LEFT:6,BOTTOM_CENTER:7,BOTTOM_RIGHT:8,ROTATION:9};class H_ extends t.utils.EventEmitter{constructor(e,i,s){var n;super(),this._points=[new t.Point,new t.Point,new t.Point,new t.Point,new t.Point],this._normals=[new t.Point,new t.Point],this._lengths=[1,1],this._workScale=new t.Point,this._workSnapResultX=new N_,this._workSnapResultY=new N_,this._workScaleResult={distance:0,scale:new t.Point},this._workTranslate=new t.Point,this._workSnapRectangle=new t.Rectangle,this._workSnap=new t.Point,this.grid=new L_(i,null==s?void 0:s.grid),this.target=new z_(i,null==s?void 0:s.target),this._parent=e,this._isEnabledDefault=null!==(n=null==s?void 0:s.enable)&&void 0!==n?n:i.isSnapEnabled(),this._isEnabled=this._isEnabledDefault}get enable(){return this._isEnabled}set enable(t){this._isEnabled!==t&&(this._isEnabled=t,this.emit("change",this))}prepare(t){t.updateTransform();const e=t.transform.localTransform,i=t.width,s=t.height,n=this._points;n[0].set(0,0),n[1].set(i,0),n[2].set(i,s),n[3].set(0,s),n[4].set(.5*i,.5*s),e.apply(n[0],n[0]),e.apply(n[1],n[1]),e.apply(n[2],n[2]),e.apply(n[3],n[3]),e.apply(n[4],n[4])}prepareForTranslate(t){this._isEnabled&&this.prepare(t)}snap(t,e){const i=t.x,s=t.y,n=this._parent.canvas,o=this._workSnapResultX,r=this._workSnapResultY;if(null!=n){const t=Math.max(n.scale.x,n.scale.y);o.reset(i,t),r.reset(s,t),o.set(i,0),o.set(i,n.width),r.set(s,0),r.set(s,n.height)}else o.reset(i,1),r.reset(s,1);return this.target.snap(i,s,o,r),this.grid.snap(i,o),this.grid.snap(s,r),e.x=Oh(o.distance)?NaN:o.result,e.y=Oh(r.distance)?NaN:r.result,e}toSnapped(t,e){const i=t.x,s=t.y;if(this._isEnabled){this.snap(t,e);const n=e.x,o=e.y;e.set(Oh(n)?i:n,Oh(o)?s:o)}else e.set(i,s);return e}toTranslationSnapped(t,e){const i=t.x,s=t.y;let n=NaN,o=NaN;if(this._isEnabled){const t=this._workTranslate,e=this._points;for(let r=0,a=e.length;r<a;++r){const a=e[r];if(t.set(a.x+i,a.y+s),this.snap(t,t),!Oh(t.x)){const e=t.x-a.x;(Oh(n)||Math.abs(e-i)<Math.abs(n-i))&&(n=e)}if(!Oh(t.y)){const e=t.y-a.y;(Oh(o)||Math.abs(e-s)<Math.abs(o-s))&&(o=e)}}}return e.x=Oh(n)?i:n,e.y=Oh(o)?s:o,e}prepareForRotate(t){}getGridSizeRotation(){return 5}toRadian(t){return t/180*Math.PI}toDegree(t){return t/Math.PI*180}toRotationSnapped(t,e){if(this._isEnabled){const i=this.getGridSizeRotation(),s=t+e,n=Math.round(this.toDegree(s)),o=n%90;return Math.abs(o)<=i?this.toRadian(n-o)-t:90-i<=o?this.toRadian(n+(90-o))-t:o<=-90+i?this.toRadian(n-(90+o))-t:e}return e}calcNormalizedVector(t,e,i){const s=e.x-t.x,n=e.y-t.y,o=Math.sqrt(s*s+n*n);if(U_<o){const t=1/o;i.x=s*t,i.y=n*t}else i.x=1,i.y=0;return o}prepareForScale(t,e){if(this._isEnabled){this.prepare(t);const i=this._points,s=this._normals,n=this._lengths;switch(e){case F_.TOP_LEFT:n[0]=this.calcNormalizedVector(i[1],i[0],s[0]),n[1]=this.calcNormalizedVector(i[3],i[0],s[1]);break;case F_.TOP_CENTER:n[0]=this.calcNormalizedVector(i[3],i[0],s[0]);break;case F_.TOP_RIGHT:n[0]=this.calcNormalizedVector(i[0],i[1],s[0]),n[1]=this.calcNormalizedVector(i[2],i[1],s[1]);break;case F_.MIDDLE_LEFT:n[0]=this.calcNormalizedVector(i[1],i[0],s[0]);break;case F_.NONE:break;case F_.MIDDLE_RIGHT:n[0]=this.calcNormalizedVector(i[0],i[1],s[0]);break;case F_.BOTTOM_LEFT:n[0]=this.calcNormalizedVector(i[2],i[3],s[0]),n[1]=this.calcNormalizedVector(i[0],i[3],s[1]);break;case F_.BOTTOM_CENTER:n[0]=this.calcNormalizedVector(i[0],i[3],s[0]);break;case F_.BOTTOM_RIGHT:n[0]=this.calcNormalizedVector(i[3],i[2],s[0]),n[1]=this.calcNormalizedVector(i[1],i[2],s[1])}}}setScaleSnappedResult(t,e,i,s,n){if(U_<e&&(Oh(n.distance)||t<n.distance)){n.distance=t;const o=1+i/e;s?n.scale.x=o:n.scale.y=o}}calcScaleSnapped1D(t,e,i,s,n,o){const r=this._workScale;t.apply(e,r);const a=r.x,h=r.y;this.snap(r,r);const l=r.x,c=r.y;if(!Oh(l)){const t=Math.abs(i.x);if(U_<t){const t=(l-a)/i.x,r=Math.abs(t),h=(l-e.x)/i.x;this.setScaleSnappedResult(r,s,h,n,o)}}if(!Oh(c)){const t=Math.abs(i.y);if(U_<t){const t=(c-h)/i.y,r=Math.abs(t),a=(c-e.y)/i.y;this.setScaleSnappedResult(r,s,a,n,o)}}}calcScaleSnappedX(t,e,i,s,n){this.calcScaleSnapped1D(t,e,i,s,!0,n)}calcScaleSnappedY(t,e,i,s,n){this.calcScaleSnapped1D(t,e,i,s,!1,n)}calcScaleSnapped2D(t,e,i,s,n){const o=this._workScale;t.apply(e,o);const r=o.x,a=o.y;this.snap(o,o);let h=o.x,l=o.y;if(Oh(h)){if(Oh(l))return;h=r}else Oh(l)&&(l=a);const c=i[0].x*i[1].y-i[1].x*i[0].y;if(U_<Math.abs(c)){const t=h-r,o=l-a,u=Math.abs(t*t+o*o);if(Oh(n.distance)||u<n.distance){n.distance=u;const t=h-e.x,o=l-e.y,r=(+i[1].y*t-i[1].x*o)/c,a=(-i[0].y*t+i[0].x*o)/c;n.scale.set(1+r/s[0],1+a/s[1])}}}calcScaleSnappedXY(t,e,i,s,n,o,r){this.calcScaleSnapped2D(t,e,n,o,r),this.calcScaleSnappedX(t,s,n[0],o[0],r),this.calcScaleSnappedY(t,i,n[1],o[1],r)}toScaleSnapped(t,e,i,s){if(this._isEnabled){const n=this._points,o=this._normals,r=this._lengths,a=this._workScaleResult;switch(a.distance=NaN,a.scale.set(s.x,s.y),e){case F_.TOP_LEFT:this.calcScaleSnappedXY(t,n[0],n[1],n[3],o,r,a);break;case F_.TOP_CENTER:this.calcScaleSnappedY(t,n[0],o[0],r[0],a),this.calcScaleSnappedY(t,n[1],o[0],r[0],a);break;case F_.TOP_RIGHT:this.calcScaleSnappedXY(t,n[1],n[0],n[2],o,r,a);break;case F_.MIDDLE_LEFT:this.calcScaleSnappedX(t,n[0],o[0],r[0],a),this.calcScaleSnappedX(t,n[3],o[0],r[0],a);break;case F_.NONE:break;case F_.MIDDLE_RIGHT:this.calcScaleSnappedX(t,n[1],o[0],r[0],a),this.calcScaleSnappedX(t,n[2],o[0],r[0],a);break;case F_.BOTTOM_LEFT:this.calcScaleSnappedXY(t,n[3],n[2],n[0],o,r,a);break;case F_.BOTTOM_CENTER:this.calcScaleSnappedY(t,n[2],o[0],r[0],a),this.calcScaleSnappedY(t,n[3],o[0],r[0],a);break;case F_.BOTTOM_RIGHT:this.calcScaleSnappedXY(t,n[2],n[3],n[1],o,r,a)}if(!Oh(a.distance)){if(s.copyFrom(a.scale),i)switch(e){case F_.TOP_LEFT:case F_.TOP_RIGHT:case F_.BOTTOM_LEFT:case F_.BOTTOM_RIGHT:s.x=s.y=Math.max(s.x,s.y);break;case F_.TOP_CENTER:case F_.BOTTOM_CENTER:s.x=s.y;break;case F_.MIDDLE_LEFT:case F_.MIDDLE_RIGHT:s.y=s.x}return!0}}return!1}reset(){this.enable=this._isEnabledDefault,this.target.reset(),this.grid.reset()}serialize(){return[this._isEnabled?1:0,this.target.serialize(),this.grid.serialize()]}deserialize(t){this.enable=!!t[0],this.target.deserialize(t[1]),this.grid.deserialize(t[2])}}class G_{constructor(e,i,s,n){this.id=e,this.size=i,this.color=t.utils.hex2string(s),this.height=i+2*n,this.measured=!1,this.ascent=0,this.descent=0}}class V_{constructor(e,i,s,n){this._id=e,this._canvas=document.createElement("canvas"),this._context=null;const o=this.toPadding(i);this._padding=o,this._font=new G_(e,i,s,o),this._unrefCount=0,this._width=1,this._height=1,this._revisionUpdated=0,this._texture=t.Texture.from(this._canvas,{mipmap:t.MIPMAP_MODES.OFF,resolution:n,scaleMode:t.SCALE_MODES.NEAREST});const r=new Map;r.set(D.SPACE,this.newChar(D.SPACE,zs.SPACE_R)),r.set(D.TAB,this.newChar(D.SOFT_TAB,zs.SPACE_R)),r.set(D.DOTS,this.newChar(D.DOTS,zs.LETTER_RNB));for(let t=0,e=D.ASCII.length;t<e;++t){const e=D.ASCII[t];r.set(e,this.newChar(e,zs.LETTER_RNB))}this._characters=r,this._createds=new Map,this._revision=1}toPadding(t){return Math.max(3,Math.ceil(.2*t))}get id(){return this._id}get font(){return this._font}get width(){return this._width}get height(){return this._height}get canvas(){return this._canvas}get characters(){return this._characters}get texture(){return this._texture}newChar(t,e){const i=this.getAdvance(t),s=this._padding,n=Math.ceil(s+i+s),o=this.font.height;return new Bs(e,t,-n,-o,n,o,i)}add(t,e){const i=this._characters,s=this._createds;for(let n=0,o=t.length;n<o;){if(t.charCodeAt(n)<=255){n+=1;continue}let r=n+1;for(;r<o;++r){const e=t.charCodeAt(r);if(!(56320<=e&&e<=57343||65024<=e&&e<=65039))break}const a=t.substring(n,r),h=i.get(a);if(null!=h)h.type&zs.RESERVED||(0===h.ref&&(this._unrefCount-=1),h.ref+=1);else{const t=s.get(a);if(null!=t)t.ref=1,i.set(a,t);else{const t=this.newChar(a,e);i.set(a,t),s.set(a,t)}this._revision+=1}n=r}}remove(t){const e=this._characters;for(let i=0,s=t.length;i<s;){if(t.charCodeAt(i)<=255){i+=1;continue}let n=i+1;for(;n<s;++n){const e=t.charCodeAt(n);if(!(56320<=e&&e<=57343||65024<=e&&e<=65039))break}const o=t.substring(i,n),r=e.get(o);null!=r&&0<r.ref&&!(r.type&zs.RESERVED)&&(r.ref-=1,0===r.ref&&(this._unrefCount+=1)),i=n}}cleanup(){const t=this._characters;t.size>>1<=this._unrefCount&&(t.forEach((e,i)=>{e.ref<=0&&t.delete(i)}),this._revision+=1,this._unrefCount=0)}get(t){return this._characters.get(t)}getAdvance(t){const e=this.getContext();return null!=e?e.measureText(t).width:0}getContext(){let t=this._context;if(null==t){const e=this._canvas;if(null==e)return null;if(t=this._context=e.getContext("2d",{alpha:!0}),null==t)return null}const e=this._font;return t.font!==e.id&&(t.font=e.id,e.id=t.font,t.textAlign="left",t.textBaseline="alphabetic",t.lineWidth=0,t.lineCap="round",t.lineJoin="miter",t.miterLimit=10,t.fillStyle=e.color,t.strokeStyle="#0000ff"),t}update(){if(this.cleanup(),this._revisionUpdated<this._revision){this._revisionUpdated=this._revision;const t=this._canvas;if(null!=t){const e=this._font,i=e.height,s=this._characters,n=this._width=this.toPowerOf2(Math.ceil(Math.sqrt(s.size))*i),o=this._padding;let r=0,a=0;s.forEach(t=>{n<=r+t.width&&(r=0,a+=i),t.x=r,t.y=a,t.origin.x=r+o,r+=t.width});const h=this._height=a+i,l=this._texture.baseTexture,c=l.resolution,u=Math.ceil(n*c),d=Math.ceil(h*c);t.width=u,t.height=d;const p=this.getContext();if(null!=p){Hs.measure(p,e);const t=Math.round(.5*(i-(e.ascent+e.descent))+e.ascent);p.save(),p.scale(c,c),p.clearRect(0,0,n,h),s.forEach(e=>{e.origin.y=e.y+t,p.fillText(e.character,e.origin.x,e.origin.y)}),p.restore()}return l.setRealSize(u,d),!0}}return!1}getRevision(){return this._revision}getRevisionUpdate(){return this._revisionUpdated}get length(){return this._characters.size}destroy(){null!=this._canvas&&(this._canvas=null),this._characters.clear(),this._createds.clear(),this._unrefCount=0}toPowerOf2(t){let e=32;for(;e<t;)e<<=1;return e}}const W_=t=>{t.update()},K_=t=>{t.forEach(W_)},X_=t=>{t.update()},Y_=t=>{t.forEach(X_)};class j_{constructor(t){this._atlases=new Map,this._resolution=t.renderer.resolution,t.renderer.on("prerender",()=>{this.update()})}add(t,e,i,s){const n=this._atlases;let o=n.get(t);null==o&&(o=new Map,n.set(t,o));let r=o.get(i);null==r&&(r=new V_(t,e,i,this._resolution),o.set(i,r)),r.add(s,zs.LETTER)}remove(t,e,i){const s=this._atlases.get(t);if(null!=s){const t=s.get(e);null!=t&&t.remove(i)}}get(t,e){const i=this._atlases.get(t);if(null==i)return null;const s=i.get(e);return null==s?null:s}update(){this._atlases.forEach(K_)}destroy(){const t=this._atlases;t.forEach(Y_),t.clear()}}const $_=t=>{if("object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)){const e=Object.getPrototypeOf(t);return null==e||e===Object.prototype}return!1},q_=(t,e,i,s)=>{let n=0,o=Math.floor(t.length/i)-1;for(;n<=o;){const r=n+(o-n>>1),a=t[r*i+s];if(e<a)o=r-1;else{if(!(a<e))return r;n=r+1}}return Math.max(n,o)},Z_=t=>vt(t)?(t=>{const e=[];for(let i=0,s=t.length;i<s;++i)e[i]=t[i];return e})(t):$_(t)?(t=>{const e={};for(const i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=Z_(t[i]));return e})(t):t,J_=t=>{if(null!=t){if(Et(t))return t;if(wt(t))return String(t);if("name"in t)return t.name;if("label"in t)return t.label;if("id"in t)return t.id}return""},Q_=(t,e)=>{if(null!=t){const i=Z_(t);if(null!=e)for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const s=e[t];if($_(s))if(Object.prototype.hasOwnProperty.call(i,t)){const e=i[t];$_(e)&&Q_(e,s)}else i[t]=Z_(s);else Object.prototype.hasOwnProperty.call(i,t)||(i[t]=s)}return i}return null!=e?Z_(e):{}},tg={TEXT:0,DATA_URL:1,BINARY_STRING:2,ARRAY_BUTTER:3,FILE:4};class eg{constructor(t,e){this._input=null,this._as=t,this._facade=e}open(){const t=this.getOrCreateInput();null!=t?t.click():this.onCancel()}getOrCreateInput(){if("FileReader"in window&&null==this._input){const t=document.createElement("input");this._input=t,t.setAttribute("type","file"),t.setAttribute("style","display:none"),t.addEventListener("change",e=>{this.onInputChange(t),t.value="",e.stopImmediatePropagation(),e.preventDefault()}),document.body.appendChild(t)}return this._input}onInputChange(t){const e=t.files;if(null!=e&&0<e.length){const t=e[0];if(this._as===tg.FILE)this.onOpen(t,t);else{const e=new FileReader;switch(e.onload=e=>{if(null!=e.target){const i=e.target;this.onOpen(i.result,t)}},e.onabort=t=>{this.onAboart(t)},this._as){case tg.TEXT:e.readAsText(t);break;case tg.DATA_URL:e.readAsDataURL(t);break;case tg.BINARY_STRING:e.readAsBinaryString(t);break;case tg.ARRAY_BUTTER:e.readAsArrayBuffer(t);break;default:e.readAsText(t)}}}else this.onCancel()}onOpen(t,e){const i=this._facade;i.emit("open",t,e,i)}onAboart(t){const e=this._facade;e.emit("abort",t,e)}onCancel(){const t=this._facade;t.emit("cancel",t)}}class ig{static fromRgb(t){const e=(16711680&t)>>16,i=(65280&t)>>8,s=255&t|0,n=Math.max(e,i,s),o=n-Math.min(e,i,s);let r=0;return 0<o&&(e===n?r=60*(i-s)/o:i===n?r=60*(s-e)/o+120:s===n&&(r=60*(e-i)/o+240),r<0&&(r+=360)),[r,o/n*255,n]}static toRgb(t,e,i){const s=i-e/255*i,n=i-s;let o=0,r=0,a=0;return t<=60?(o=i,r=t/60*n+s,a=s):t<=120?(o=(120-t)/60*n+s,r=i,a=s):t<=180?(o=s,r=i,a=(t-120)/60*n+s):t<=240?(o=s,r=(240-t)/60*n+s,a=i):t<=300?(o=(t-240)/60*n+s,r=s,a=i):(o=i,r=s,a=(360-t)/60*n+s),o=Math.max(0,Math.min(255,o)),r=Math.max(0,Math.min(255,r)),a=Math.max(0,Math.min(255,a)),o<<16|r<<8|a}}class sg extends hr{onElementAttached(t,e,i){t.addEventListener("keydown",this._onInputKeyDownBound),super.onElementAttached(t,e,i)}onElementDetached(t,e,i){t.removeEventListener("keydown",this._onInputKeyDownBound),super.onElementDetached(t,e,i)}onInputKeyDown(t){$n.isOkKey(t)&&this._operation.onEnter()}}class ng{static create(t){const e=this._mapping;return t in e?`${t} ${++e[t]}`:(e[t]=1,t+" 1")}}ng._mapping={};class og{constructor(t){var e;this._duration=null!==(e=null==t?void 0:t.duration)&&void 0!==e?e:300,this._current=null,this._lastUpdate=0,this._updateId=null}show(t,e){const i=this._updateId;null!=i&&clearTimeout(i);const s=this._current;if(t!==s){const i=this._duration,s=this._lastUpdate,n=Date.now(),o=s+i-n;!0===e||o<=0?this.update(n,t):this._updateId=window.setTimeout(()=>{this.update(Date.now(),t)},o)}}update(t,e){const i=this._current;i!==e&&(this._lastUpdate=t,null!=i&&i.hide(),this._current=e,null!=e&&e.show())}hide(){this.show(null)}}
|
|
10
10
|
/*!
|
|
11
11
|
* jQuery Mousewheel 3.1.13
|
|
12
12
|
*
|