@leafer-editor/worker 1.5.1 → 1.5.2

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.
@@ -1,2 +1,2 @@
1
- const t={toURL(t,e){let i=encodeURIComponent(t);return"text"===e?i="data:text/plain;charset=utf-8,"+i:"svg"===e&&(i="data:image/svg+xml,"+i),i},image:{hitCanvasSize:100,maxCacheSize:4096e3,maxPatternSize:8847360,crossOrigin:"anonymous",getRealURL(e){const{prefix:i,suffix:s}=t.image;return!s||e.startsWith("data:")||e.startsWith("blob:")||(e+=(e.includes("?")?"&":"?")+s),i&&"/"===e[0]&&(e=i+e),e}}},e={},i={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=s;return e[t]?e[t]++:(e[t]=1,0)}},s=i,{round:n,pow:o,PI:r}=Math,a={within:(t,e,i)=>("object"==typeof e&&(i=e.max,e=e.min),void 0!==e&&t<e&&(t=e),void 0!==i&&t>i&&(t=i),t),fourNumber(t,e){let i;if(t instanceof Array)switch(t.length){case 4:i=void 0===e?t:[...t];break;case 2:i=[t[0],t[1],t[0],t[1]];break;case 3:i=[t[0],t[1],t[2],t[1]];break;case 1:t=t[0];break;default:t=0}if(i||(i=[t,t,t,t]),e)for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),a.float(t)),getGapRotation(t,e,i=0){let s=t+i;if(e>1){const t=Math.abs(s%e);(t<1||t>e-1)&&(s=Math.round(s/e)*e)}return s-i},float(t,e){const i=void 0!==e?o(10,e):1e12;return-0===(t=n(t*i)/i)?0:t},getScaleData:(t,e,i,s)=>(s||(s={}),e?(s.scaleX=("number"==typeof e?e:e.width)/i.width,s.scaleY=("number"==typeof e?e:e.height)/i.height):t&&a.assignScale(s,t),s),assignScale(t,e){"number"==typeof e?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)}},h=r/180,l=2*r,d=r/2;function c(){return{x:0,y:0}}function u(){return{x:0,y:0,width:0,height:0}}function _(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:p,cos:g,acos:f,sqrt:y}=Math,{float:m}=a,v={};function w(){return Object.assign(Object.assign(Object.assign({},{a:1,b:0,c:0,d:1,e:0,f:0}),{x:0,y:0,width:0,height:0}),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0})}const x={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:w(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,o=0,r=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=o,t.f=r},get:_,getWorld:w,copy(t,e){t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f},translate(t,e,i){t.e+=e,t.f+=i},translateInner(t,e,i,s){t.e+=t.a*e+t.c*i,t.f+=t.b*e+t.d*i,s&&(t.e-=e,t.f-=i)},scale(t,e,i=e){t.a*=e,t.b*=e,t.c*=i,t.d*=i},scaleOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.scaleOfInner(t,v,i,s)},scaleOfInner(t,e,i,s=i){b.translateInner(t,e.x,e.y),b.scale(t,i,s),b.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:o}=t,r=g(e*=h),a=p(e);t.a=i*r-s*a,t.b=i*a+s*r,t.c=n*r-o*a,t.d=n*a+o*r},rotateOfOuter(t,e,i){b.toInnerPoint(t,e,v),b.rotateOfInner(t,v,i)},rotateOfInner(t,e,i){b.translateInner(t,e.x,e.y),b.rotate(t,i),b.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:o,d:r}=t;i&&(i*=h,t.a=s+o*i,t.b=n+r*i),e&&(e*=h,t.c=o+s*e,t.d=r+n*e)},skewOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.skewOfInner(t,v,i,s)},skewOfInner(t,e,i,s=0){b.translateInner(t,e.x,e.y),b.skew(t,i,s),b.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:o,e:r,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*n+r,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,n,o){let{e:r,f:a}=t;if(o&&(r+=o.scrollX,a+=o.scrollY),i||(i=t),void 0===s&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:r,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=r*e.a+a*e.c,i.d=r*e.b+a*e.d,n&&(i.scaleX=e.scaleX*n.scaleX,i.scaleY=e.scaleY*n.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,n&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=r*e.a+a*e.c+e.e,i.f=r*e.b+a*e.d+e.f},divide(t,e){b.multiply(t,b.tempInvert(e))},divideParent(t,e){b.multiplyParent(t,b.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=b;return b.copy(e,t),b.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:o,f:r}=t;if(i||s){const a=1/(e*n-i*s);t.a=n*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*n-r*s)*a,t.f=-(r*e-o*i)*a}else if(1===e&&1===n)t.e=-o,t.f=-r;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-o*n*i,t.f=-r*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:o}=e;i||(i=e),i.x=n*t.a+o*t.c,i.y=n*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:o,c:r,d:a}=t,h=1/(n*a-o*r),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*r)*h,i.y=(d*n-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*r)*h,i.y-=(s*n-e*o)*h}},setLayout(t,e,i,s,n){const{x:o,y:r,scaleX:a,scaleY:l}=e;if(void 0===n&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,o=i*h,r=g(o),d=p(o);if(s||n){const e=s*h,i=n*h;t.a=(r+i*-d)*a,t.b=(d+i*r)*a,t.c=(e*r-d)*l,t.d=(r+e*d)*l}else t.a=r*a,t.b=d*a,t.c=-d*l,t.d=r*l}else t.a=a,t.b=0,t.c=0,t.d=l;t.e=o,t.f=r,(i=i||s)&&b.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:o,c:r,d:a,e:l,f:c}=t;let u,_,v,w,x,b=l,k=c;if(o||r){const t=n*a-o*r;if(r&&!s){u=y(n*n+o*o),_=t/u;const e=n/u;v=o>0?f(e):-f(e)}else{_=y(r*r+a*a),u=t/_;const e=r/_;v=d-(a>0?f(-e):-f(e))}const e=m(g(v)),i=p(v);u=m(u),_=m(_),w=e?m((r/_+i)/e/h,9):0,x=e?m((o/u-i)/e/h,9):0,v=m(v/h)}else u=n,_=a,v=w=x=0;return(e=i||e)&&(b+=e.x*n+e.y*r,k+=e.x*o+e.y*a,i||(b-=e.x,k-=e.y)),{x:b,y:k,scaleX:u,scaleY:_,rotation:v,skewX:w,skewY:x}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:o,d:r}=t;n||o?i=(s*r-n*o)/(e=y(s*s+n*n)):(e=s,i=r)}return s.scaleX=e,s.scaleY=i,s},reset(t){b.set(t)}},b=x,{toInnerPoint:k,toOuterPoint:E}=x,{sin:B,cos:R,abs:O,sqrt:L,atan2:C,min:T,PI:S}=Math,P={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,i=0){t.x=e,t.y=i},setRadius(t,e,i){t.radiusX=e,t.radiusY=void 0===i?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},move(t,e,i){t.x+=e,t.y+=i},scale(t,e,i=e){t.x&&(t.x*=e),t.y&&(t.y*=i)},scaleOf(t,e,i,s=i){t.x+=(t.x-e.x)*(i-1),t.y+=(t.y-e.y)*(s-1)},rotate(t,e,i){i||(i=M.defaultPoint);const s=R(e*=h),n=B(e),o=t.x-i.x,r=t.y-i.y;t.x=i.x+o*s-r*n,t.y=i.y+o*n+r*s},tempToInnerOf(t,e){const{tempPoint:i}=M;return D(i,t),k(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=M;return D(i,t),E(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=M;return D(i,t),M.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),k(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){k(e,t,i)},toOuterOf(t,e,i){E(e,t,i)},getCenter:(t,e)=>({x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}),getCenterX:(t,e)=>t+(e-t)/2,getCenterY:(t,e)=>t+(e-t)/2,getDistance:(t,e)=>A(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=O(i-t),o=O(s-e);return L(n*n+o*o)},getMinDistanceFrom:(t,e,i,s,n,o)=>T(A(t,e,i,s),A(i,s,n,o)),getAngle:(t,e)=>I(t,e)/h,getRotation:(t,e,i,s)=>(s||(s=e),M.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/h),getRadianFrom(t,e,i,s,n,o,r,a){void 0===r&&(r=i,a=s);let h=C(e-s,t-i);const d=C(o-a,n-r)-h;return d<-S?d+l:d},getAtan2:(t,e)=>C(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s){const n=I(t,e);return(e=s?e:{}).x=t.x+R(n)*i,e.y=t.y+B(n)*i,e},toNumberPoints(t){let e=t;return"object"==typeof t[0]&&(e=[],t.forEach((t=>e.push(t.x,t.y)))),e},reset(t){M.reset(t)}},M=P,{getDistanceFrom:A,copy:D,getAtan2:I}=M;class W{constructor(t,e){this.set(t,e)}set(t,e){return"object"==typeof t?P.copy(this,t):P.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new W(this)}move(t,e){return P.move(this,t,e),this}scale(t,e){return P.scale(this,t,e),this}scaleOf(t,e,i){return P.scaleOf(this,t,e,i),this}rotate(t,e){return P.rotate(this,t,e),this}rotateOf(t,e){return P.rotate(this,e,t),this}getRotation(t,e,i){return P.getRotation(this,t,e,i)}toInnerOf(t,e){return P.toInnerOf(this,t,e),this}toOuterOf(t,e){return P.toOuterOf(this,t,e),this}getCenter(t){return new W(P.getCenter(this,t))}getDistance(t){return P.getDistance(this,t)}getDistancePoint(t,e,i){return new W(P.getDistancePoint(this,t,e,i))}getAngle(t){return P.getAngle(this,t)}getAtan2(t){return P.getAtan2(this,t)}reset(){return P.reset(this),this}}const F=new W;class z{constructor(t,e,i,s,n,o){this.set(t,e,i,s,n,o)}set(t,e,i,s,n,o){return"object"==typeof t?x.copy(this,t):x.set(this,t,e,i,s,n,o),this}setWith(t){return x.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:n,f:o}=this;return{a:t,b:e,c:i,d:s,e:n,f:o}}clone(){return new z(this)}translate(t,e){return x.translate(this,t,e),this}translateInner(t,e){return x.translateInner(this,t,e),this}scale(t,e){return x.scale(this,t,e),this}scaleWith(t,e){return x.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}scaleOfOuter(t,e,i){return x.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return x.scaleOfInner(this,t,e,i),this}rotate(t){return x.rotate(this,t),this}rotateOfOuter(t,e){return x.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return x.rotateOfInner(this,t,e),this}skew(t,e){return x.skew(this,t,e),this}skewOfOuter(t,e,i){return x.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return x.skewOfInner(this,t,e,i),this}multiply(t){return x.multiply(this,t),this}multiplyParent(t){return x.multiplyParent(this,t),this}divide(t){return x.divide(this,t),this}divideParent(t){return x.divideParent(this,t),this}invert(){return x.invert(this),this}invertWith(){return x.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){x.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){x.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return x.setLayout(this,t,e,i),this}getLayout(t,e,i){return x.getLayout(this,t,e,i)}withScale(t,e){return x.withScale(this,t,e)}reset(){x.reset(this)}}const N=new z,Y={tempPointBounds:{},setPoint(t,e,i){t.minX=t.maxX=e,t.minY=t.maxY=i},addPoint(t,e,i){t.minX=e<t.minX?e:t.minX,t.minY=i<t.minY?i:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=i>t.maxY?i:t.maxY},addBounds(t,e,i,s,n){H(t,e,i),H(t,e+s,i+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:H}=Y,{tempPointBounds:X,setPoint:V,addPoint:j,toBounds:U}=Y,{toOuterPoint:G}=x,{float:Z,fourNumber:K}=a,{floor:q,ceil:J}=Math;let $,Q,tt,et;const it={},st={},nt={tempBounds:{},set(t,e=0,i=0,s=0,n=0){t.x=e,t.y=i,t.width=s,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,n){const{x:o,y:r,width:a,height:h}=e;if(i instanceof Array){const e=K(i);s?ot.set(t,o+e[3],r+e[0],a-e[1]-e[3],h-e[2]-e[0]):ot.set(t,o-e[3],r-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),ot.set(t,o-i,r-i,a+2*i,h+2*i);n&&("width"===n?(t.y=r,t.height=h):(t.x=o,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},getByMove:(t,e,i)=>(t=Object.assign({},t),ot.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?at(e,t):e=t,i?(e.offsetX=-(ot.maxX(i)-t.x),e.offsetY=-(ot.maxY(i)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),ot.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e){P.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){P.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(ot.copy(ot.tempBounds,t),ot.toOuterOf(ot.tempBounds,e),ot.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),ot.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n}=e;s>0?(i.width=t.width*s,i.x=e.e+t.x*s):(i.width=t.width*-s,i.x=e.e+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=e.f+t.y*n):(i.height=t.height*-n,i.y=e.f+t.y*n-i.height)}else it.x=t.x,it.y=t.y,G(e,it,st),V(X,st.x,st.y),it.x=t.x+t.width,G(e,it,st),j(X,st.x,st.y),it.y=t.y+t.height,G(e,it,st),j(X,st.x,st.y),it.x=t.x,G(e,it,st),j(X,st.x,st.y),U(X,i)},toInnerOf(t,e,i){i||(i=t),ot.move(i,-e.e,-e.f),ot.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Math.min(t.width/e.width,t.height/e.height));return new z(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e,i){const s={};return ot.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){ot.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){ot.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=q(t.x),t.y=q(t.y),t.width=e>t.x?J(t.width+e-t.x):J(t.width),t.height=i>t.y?J(t.height+i-t.y):J(t.height)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},float(t,e){t.x=Z(t.x,e),t.y=Z(t.y,e),t.width=Z(t.width,e),t.height=Z(t.height,e)},add(t,e,i){$=t.x+t.width,Q=t.y+t.height,tt=e.x,et=e.y,i||(tt+=e.width,et+=e.height),$=$>tt?$:tt,Q=Q>et?Q:et,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=$-t.x,t.height=Q-t.y},addList(t,e){ot.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){ot.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){ot.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,o=!0;for(let r=0,a=e.length;r<a;r++)n=i?i(e[r]):e[r],n&&(n.width||n.height)&&(o?(o=!1,s||at(t,n)):rt(t,n));o&&ot.reset(t)},setPoints(t,e){e.forEach(((t,e)=>0===e?V(X,t.x,t.y):j(X,t.x,t.y))),U(X,t)},setPoint(t,e){ot.set(t,e.x,e.y)},addPoint(t,e){rt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]},hitRadiusPoint:(t,e,i)=>(i&&(e=P.tempToInnerRadiusPointOf(e,i)),e.x>=t.x-e.radiusX&&e.x<=t.x+t.width+e.radiusX&&e.y>=t.y-e.radiusY&&e.y<=t.y+t.height+e.radiusY),hitPoint:(t,e,i)=>(i&&(e=P.tempToInnerOf(e,i)),e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height),hit:(t,e,i)=>(i&&(e=ot.tempToOuterOf(e,i)),!(t.y+t.height<e.y||e.y+e.height<t.y||t.x+t.width<e.x||e.x+e.width<t.x)),includes:(t,e,i)=>(i&&(e=ot.tempToOuterOf(e,i)),t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height),getIntersectData(t,e,i){if(i&&(e=ot.tempToOuterOf(e,i)),!ot.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:o,height:r}=e;return $=s+o,Q=n+r,tt=t.x+t.width,et=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,$=$<tt?$:tt,Q=Q<et?Q:et,o=$-s,r=Q-n,{x:s,y:n,width:o,height:r}},intersect(t,e,i){ot.copy(t,ot.getIntersectData(t,e,i))},isSame:(t,e)=>t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height,isEmpty:t=>0===t.x&&0===t.y&&0===t.width&&0===t.height,reset(t){ot.set(t)}},ot=nt,{add:rt,copy:at}=ot;class ht{get minX(){return nt.minX(this)}get minY(){return nt.minY(this)}get maxX(){return nt.maxX(this)}get maxY(){return nt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return"object"==typeof t?nt.copy(this,t):nt.set(this,t,e,i,s),this}get(){const{x:t,y:e,width:i,height:s}=this;return{x:t,y:e,width:i,height:s}}clone(){return new ht(this)}move(t,e){return nt.move(this,t,e),this}scale(t,e){return nt.scale(this,t,e),this}scaleOf(t,e,i){return nt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return nt.toOuterOf(this,t,e),this}toInnerOf(t,e){return nt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return nt.getFitMatrix(this,t,e)}spread(t,e){return nt.spread(this,t,e),this}shrink(t,e){return nt.shrink(this,t,e),this}ceil(){return nt.ceil(this),this}unsign(){return nt.unsign(this),this}float(t){return nt.float(this,t),this}add(t){return nt.add(this,t),this}addList(t){return nt.setList(this,t,!0),this}setList(t){return nt.setList(this,t),this}addListWithFn(t,e){return nt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return nt.setListWithFn(this,t,e),this}setPoint(t){return nt.setPoint(this,t),this}setPoints(t){return nt.setPoints(this,t),this}addPoint(t){return nt.addPoint(this,t),this}getPoints(){return nt.getPoints(this)}hitPoint(t,e){return nt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return nt.hitRadiusPoint(this,t,e)}hit(t,e){return nt.hit(this,t,e)}includes(t,e){return nt.includes(this,t,e)}intersect(t,e){return nt.intersect(this,t,e),this}getIntersect(t,e){return new ht(nt.getIntersectData(this,t,e))}isSame(t){return nt.isSame(this,t)}isEmpty(){return nt.isEmpty(this)}reset(){nt.reset(this)}}const lt=new ht;class dt{constructor(t,e,i,s,n,o){"object"==typeof t?this.copy(t):this.set(t,e,i,s,n,o)}set(t=0,e=0,i=0,s=0,n=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=t;this.set(e,i,s,n,o,r)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=this;return new ht(n,e,o||t.width-n-i,r||t.height-e-s)}}var ct,ut;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(ct||(ct={})),function(t){t[t.topLeft=0]="topLeft",t[t.top=1]="top",t[t.topRight=2]="topRight",t[t.right=3]="right",t[t.bottomRight=4]="bottomRight",t[t.bottom=5]="bottom",t[t.bottomLeft=6]="bottomLeft",t[t.left=7]="left",t[t.center=8]="center",t[t["top-left"]=0]="top-left",t[t["top-right"]=2]="top-right",t[t["bottom-right"]=4]="bottom-right",t[t["bottom-left"]=6]="bottom-left"}(ut||(ut={}));const _t=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:1,y:.5},{x:1,y:1},{x:.5,y:1},{x:0,y:1},{x:0,y:.5},{x:.5,y:.5}];_t.forEach((t=>t.type="percent"));const pt={directionData:_t,tempPoint:{},get:gt,toPoint(t,e,i,s,n){const o=gt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,n&&(i.x-=n.x,i.y-=n.y,o.x&&(i.x-=1===o.x?n.width:.5===o.x?o.x*n.width:0),o.y&&(i.y-=1===o.y?n.height:.5===o.y?o.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)}};function gt(t){return"string"==typeof t?_t[ut[t]]:t}const{toPoint:ft}=pt,yt={toPoint(t,e,i,s,n){ft(t,i,s,n,e)}},mt={0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,".":1,e:1,E:1};class vt{constructor(t){this.repeatMap={},this.name=t}static get(t){return new vt(t)}static set filter(t){this.filterList=wt(t)}static set exclude(t){this.excludeList=wt(t)}log(...t){if(xt.enable){if(xt.filterList.length&&xt.filterList.every((t=>t!==this.name)))return;if(xt.excludeList.length&&xt.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){xt.enable&&this.warn(...t)}warn(...t){xt.showWarn&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}function wt(t){return t?"string"==typeof t&&(t=[t]):t=[],t}vt.filterList=[],vt.excludeList=[],vt.showWarn=!0;const xt=vt,bt=vt.get("RunTime"),kt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const s=i.create(i.RUNTIME);return Et.currentId=Et.idMap[s]=e?performance.now():Date.now(),Et.currentName=Et.nameMap[s]=t,Et.nameToIdMap[t]=s,s},end(t,e){const i=Et.idMap[t],s=Et.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;Et.idMap[t]=Et.nameMap[t]=Et.nameToIdMap[s]=void 0,bt.log(s,n,"ms")},endOfName(t,e){const i=Et.nameToIdMap[t];void 0!==i&&Et.end(i,e)}},Et=kt,Bt=[],Rt={list:{},add(t,...e){this.list[t]=!0,Bt.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("need plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout((()=>Bt.forEach((t=>Rt.has(t,!0)))));const Ot=vt.get("UICreator"),Lt={list:{},register(t){const{__tag:e}=t.prototype;Ct[e]&&Ot.repeat(e),Ct[e]=t},get(t,e,i,s,n,o){Ct[t]||Ot.error("not register "+t);const r=new Ct[t](e);return void 0!==i&&(r.x=i,s&&(r.y=s),n&&(r.width=n),o&&(r.height=o)),r}},{list:Ct}=Lt,Tt=vt.get("EventCreator"),St={nameList:{},register(t){let e;Object.keys(t).forEach((i=>{e=t[i],"string"==typeof e&&(Pt[e]&&Tt.repeat(e),Pt[e]=t)}))},changeName(t,e){const i=Pt[t];if(i){const s=Object.keys(i).find((e=>i[e]===t));s&&(i[s]=e,Pt[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new Pt[t](...e)},{nameList:Pt}=St;class Mt{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let i;const{list:s}=this;for(let e=0,n=s.length;e<n;e++)if(i=s[e],i.recycled&&i.isSameSize(t))return i.recycled=!1,i.manager||(i.manager=this),i;const n=e.canvas(t);return this.add(n),n}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let i=0,s=this.list.length;i<s;i++)t=this.list[i],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach((t=>{t.destroy()})),this.list.length=0}destroy(){this.clear()}}const At={default:(t,e)=>(Dt(e,t),Dt(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach((n=>{var o,r;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(o=t[n])||void 0===o?void 0:o.constructor)===Object)return Dt(t[n],e[n],i&&i[n]);i&&n in i?(null===(r=i[n])||void 0===r?void 0:r.constructor)===Object&&Dt(t[n]={},e[n],i[n]):t[n]=e[n]}))},copyAttrs:(t,e,i)=>(i.forEach((i=>{void 0!==e[i]&&(t[i]=e[i])})),t),clone:t=>JSON.parse(JSON.stringify(t)),toMap(t){const e={};for(let i=0,s=t.length;i<s;i++)e[t[i]]=!0;return e}},{assign:Dt}=At;class It{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(void 0!==e)return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let i;for(let s in this)"_"!==s[0]&&(i=e?e[s]:void 0,t[s]=void 0===i?this[s]:i);return t}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];if(void 0!==e)return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(t instanceof Array)for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let n in this)if("_"!==n[0]&&(t=this["_"+n],void 0!==t)){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=void 0===e?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:o,f:r}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:o,f:r}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}var Wt;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(Wt||(Wt={}));const Ft={};function zt(t){return null==t}function Nt(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,i,r):n(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}function Yt(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}function Ht(t){return(e,i)=>{t||(t=i),Object.defineProperty(e,i,{get(){return this.context[t]},set(e){this.context[t]=e}})}}"function"==typeof SuppressedError&&SuppressedError;const Xt=[];function Vt(){return(t,e)=>{Xt.push(e)}}const jt=[];let Ut=class{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||jt)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Xt.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))})),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,o){"object"==typeof t?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,i,s){}strokeRect(t,e,i,s){}clearRect(t,e,i,s){}drawImage(t,e,i,s,n,o,r,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,o+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,r+=t,h-=t}this.context.drawImage(t,e,i,s,n,o,r,a,h);break;case 5:this.context.drawImage(t,e,i,s,n);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,n,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,o){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,o,r,a){}rect(t,e,i,s){}roundRect(t,e,i,s,n){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,n,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}};Nt([Ht("imageSmoothingEnabled")],Ut.prototype,"smooth",void 0),Nt([Ht("imageSmoothingQuality")],Ut.prototype,"smoothLevel",void 0),Nt([Ht("globalAlpha")],Ut.prototype,"opacity",void 0),Nt([Ht()],Ut.prototype,"fillStyle",void 0),Nt([Ht()],Ut.prototype,"strokeStyle",void 0),Nt([Ht("lineWidth")],Ut.prototype,"strokeWidth",void 0),Nt([Ht("lineCap")],Ut.prototype,"strokeCap",void 0),Nt([Ht("lineJoin")],Ut.prototype,"strokeJoin",void 0),Nt([Ht("lineDashOffset")],Ut.prototype,"dashOffset",void 0),Nt([Ht()],Ut.prototype,"miterLimit",void 0),Nt([Ht()],Ut.prototype,"shadowBlur",void 0),Nt([Ht()],Ut.prototype,"shadowColor",void 0),Nt([Ht()],Ut.prototype,"shadowOffsetX",void 0),Nt([Ht()],Ut.prototype,"shadowOffsetY",void 0),Nt([Ht()],Ut.prototype,"filter",void 0),Nt([Ht()],Ut.prototype,"font",void 0),Nt([Ht()],Ut.prototype,"fontKerning",void 0),Nt([Ht()],Ut.prototype,"fontStretch",void 0),Nt([Ht()],Ut.prototype,"fontVariantCaps",void 0),Nt([Ht()],Ut.prototype,"textAlign",void 0),Nt([Ht()],Ut.prototype,"textBaseline",void 0),Nt([Ht()],Ut.prototype,"textRendering",void 0),Nt([Ht()],Ut.prototype,"wordSpacing",void 0),Nt([Ht()],Ut.prototype,"letterSpacing",void 0),Nt([Ht()],Ut.prototype,"direction",void 0),Nt([Vt()],Ut.prototype,"setTransform",null),Nt([Vt()],Ut.prototype,"resetTransform",null),Nt([Vt()],Ut.prototype,"getTransform",null),Nt([Vt()],Ut.prototype,"save",null),Nt([Vt()],Ut.prototype,"restore",null),Nt([Vt()],Ut.prototype,"translate",null),Nt([Vt()],Ut.prototype,"scale",null),Nt([Vt()],Ut.prototype,"rotate",null),Nt([Vt()],Ut.prototype,"fill",null),Nt([Vt()],Ut.prototype,"stroke",null),Nt([Vt()],Ut.prototype,"clip",null),Nt([Vt()],Ut.prototype,"fillRect",null),Nt([Vt()],Ut.prototype,"strokeRect",null),Nt([Vt()],Ut.prototype,"clearRect",null),Nt([Vt()],Ut.prototype,"beginPath",null),Nt([Vt()],Ut.prototype,"moveTo",null),Nt([Vt()],Ut.prototype,"lineTo",null),Nt([Vt()],Ut.prototype,"bezierCurveTo",null),Nt([Vt()],Ut.prototype,"quadraticCurveTo",null),Nt([Vt()],Ut.prototype,"closePath",null),Nt([Vt()],Ut.prototype,"arc",null),Nt([Vt()],Ut.prototype,"arcTo",null),Nt([Vt()],Ut.prototype,"ellipse",null),Nt([Vt()],Ut.prototype,"rect",null),Nt([Vt()],Ut.prototype,"roundRect",null),Nt([Vt()],Ut.prototype,"createConicGradient",null),Nt([Vt()],Ut.prototype,"createLinearGradient",null),Nt([Vt()],Ut.prototype,"createPattern",null),Nt([Vt()],Ut.prototype,"createRadialGradient",null),Nt([Vt()],Ut.prototype,"fillText",null),Nt([Vt()],Ut.prototype,"measureText",null),Nt([Vt()],Ut.prototype,"strokeText",null);const{copy:Gt}=x,Zt={width:1,height:1,pixelRatio:1},Kt=["width","height","pixelRatio"];class qt extends Ut{get width(){return this.size.width}get height(){return this.size.height}get pixelRatio(){return this.size.pixelRatio}get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,s){super(),this.size={},this.worldTransform={},e||(e=Zt),this.manager=s,this.innerId=i.create(i.CNAVAS);const{width:n,height:o,pixelRatio:r}=e;this.autoLayout=!n||!o,this.size.pixelRatio=r|t.devicePixelRatio,this.config=e,this.init()}init(){}__createContext(){const{view:t}=this,{contextSettings:e}=this.config;this.context=e?t.getContext("2d",e):t.getContext("2d"),this.__bindContext()}export(t,e){}toBlob(t,e){}toDataURL(t,e){}saveAs(t,e){}resize(t,e=!0){if(this.isSameSize(t))return;let i;this.context&&!this.unreal&&e&&this.width&&(i=this.getSameCanvas(),i.copyWorld(this));const s=this.size;At.copyAttrs(s,t,Kt),Kt.forEach((t=>s[t]||(s[t]=1))),this.bounds=new ht(0,0,this.width,this.height),this.context&&!this.unreal&&(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&i&&(this.clearWorld(i.bounds),this.copyWorld(i),i.recycle())}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:i}=this,s=this.worldTransform;if(e){const{a:n,b:o,c:r,d:a,e:h,f:l}=e;this.setTransform(s.a=(t.a*n+t.b*r)*i,s.b=(t.a*o+t.b*a)*i,s.c=(t.c*n+t.d*r)*i,s.d=(t.c*o+t.d*a)*i,s.e=(t.e*n+t.f*r+h)*i,s.f=(t.e*o+t.f*a+l)*i)}else this.setTransform(s.a=t.a*i,s.b=t.b*i,s.c=t.c*i,s.d=t.d*i,s.e=t.e*i,s.f=t.f*i)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,i){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i)}setStrokeOptions(t){this.strokeCap="none"===t.strokeCap?"butt":t.strokeCap,this.strokeJoin=t.strokeJoin,this.dashPattern=t.dashPattern,this.dashOffset=t.dashOffset,this.miterLimit=t.miterLimit}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s){if(s&&(this.blendMode=s),e){const{pixelRatio:s}=this;i||(i=e),this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x*s,i.y*s,i.width*s,i.height*s)}else this.drawImage(t.view,0,0);s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s){if(s&&(this.blendMode=s),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,nt.tempToOuterOf(i,e)),this.restore();else{const{pixelRatio:s}=this;this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x,i.y,i.width,i.height)}s&&(this.blendMode="source-over")}copyWorldByReset(t,e,i,s,n){this.resetTransform(),this.copyWorld(t,e,i,s),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(lt.x,lt.y,lt.width,lt.height),{data:o}=n;for(let t=0,s=o.length;t<s;t+=4)i=.299*o[t]+.587*o[t+1]+.114*o[t+2],(e=o[t+3])&&(o[t+3]=255===e?i:e*(i/255));s.putImageData(n,lt.x,lt.y)}useMask(t,e,i){this.copyWorld(t,e,i,"destination-in")}useEraser(t,e,i){this.copyWorld(t,e,i,"destination-out")}fillWorld(t,e,i){i&&(this.blendMode=i),this.fillStyle=e,this.setTempBounds(t),this.fillRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempBounds(t),this.strokeRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}clearWorld(t,e){this.setTempBounds(t,e),this.clearRect(lt.x,lt.y,lt.width,lt.height)}clipWorld(t,e){this.beginPath(),this.setTempBounds(t,e),this.rect(lt.x,lt.y,lt.width,lt.height),this.clip()}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempBounds(t,e,i){lt.set(t),i&&lt.intersect(this.bounds),lt.scale(this.pixelRatio),e&&lt.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,i){const s=this.manager?this.manager.get(this.size):e.canvas(Object.assign({},this.size));return s.save(),t&&(Gt(s.worldTransform,this.worldTransform),s.useWorldTransform()),i&&(s.smooth=this.smooth),s}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t,!0):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const Jt={creator:{},parse(t,e){},convertToCanvasData(t,e){}},$t={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Qt=Object.assign({M:1,m:10,L:2,l:20,H:3,h:30,V:4,v:40,C:5,c:50,S:6,s:60,Q:7,q:70,T:8,t:80,A:9,a:90,Z:11,z:11,R:12},$t),te={M:3,m:3,L:3,l:3,H:2,h:2,V:2,v:2,C:7,c:7,S:5,s:5,Q:5,q:5,T:3,t:3,A:8,a:8,Z:1,z:1,N:5,D:9,X:6,G:9,F:5,O:7,P:4,U:6},ee={m:10,l:20,H:3,h:30,V:4,v:40,c:50,S:6,s:60,q:70,T:8,t:80,A:9,a:90},ie=Object.assign(Object.assign({},ee),$t),se=Qt,ne={};for(let t in se)ne[se[t]]=t;const oe={};for(let t in se)oe[se[t]]=te[t];const re={drawRoundRect(t,e,i,s,n,o){const r=a.fourNumber(o,Math.min(s/2,n/2)),h=e+s,l=i+n;r[0]?t.moveTo(e+r[0],i):t.moveTo(e,i),r[1]?t.arcTo(h,i,h,l,r[1]):t.lineTo(h,i),r[2]?t.arcTo(h,l,e,l,r[2]):t.lineTo(h,l),r[3]?t.arcTo(e,l,e,i,r[3]):t.lineTo(e,l),r[0]?t.arcTo(e,i,h,i,r[0]):t.lineTo(e,i)}},{sin:ae,cos:he,atan2:le,ceil:de,abs:ce,PI:ue,sqrt:_e,pow:pe}=Math,{setPoint:ge,addPoint:fe}=Y,{set:ye,toNumberPoints:me}=P,{M:ve,L:we,C:xe,Q:be,Z:ke}=Qt,Ee={},Be={points(t,e,i,s){let n=me(e);if(t.push(ve,n[0],n[1]),i&&n.length>5){let e,o,r,a,h,l,d,c,u,_,p,g,f,y=n.length;const m=!0===i?.5:i;s&&(n=[n[y-2],n[y-1],...n,n[0],n[1],n[2],n[3]],y=n.length);for(let i=2;i<y-2;i+=2)e=n[i-2],o=n[i-1],r=n[i],a=n[i+1],h=n[i+2],l=n[i+3],p=_e(pe(r-e,2)+pe(a-o,2)),g=_e(pe(h-r,2)+pe(l-a,2)),f=p+g,p=m*p/f,g=m*g/f,h-=e,l-=o,d=r-p*h,c=a-p*l,2===i?s||t.push(be,d,c,r,a):t.push(xe,u,_,d,c,r,a),u=r+g*h,_=a+g*l;s||t.push(be,u,_,n[y-2],n[y-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(we,n[e],n[e+1]);s&&t.push(ke)},rect(t,e,i,s,n){Jt.creator.path=t,Jt.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+n).lineTo(e,i+n).lineTo(e,i)},roundRect(t,e,i,s,n,o){Jt.creator.path=[],re.drawRoundRect(Jt.creator,e,i,s,n,o),t.push(...Jt.convertToCanvasData(Jt.creator.path,!0))},arcTo(t,e,i,s,n,o,r,a,c,u,_){const p=s-e,g=n-i,f=o-s,y=r-n;let m=le(g,p),v=le(y,f),w=v-m;if(w<0&&(w+=l),w===ue||ce(p+g)<1e-12||ce(f+y)<1e-12)return t&&t.push(we,s,n),c&&(ge(c,e,i),fe(c,s,n)),_&&ye(_,e,i),void(u&&ye(u,s,n));const x=p*y-f*g<0,b=x?-1:1,k=a/he(w/2),E=s+k*he(m+w/2+d*b),B=n+k*ae(m+w/2+d*b);return m-=d*b,v-=d*b,Le(t,E,B,a,a,0,m/h,v/h,x,c,u,_)},arc:(t,e,i,s,n,o,r,a,h,l)=>Le(t,e,i,s,s,0,n,o,r,a,h,l),ellipse(t,e,i,s,n,o,r,a,c,u,_,p){const g=o*h,f=ae(g),y=he(g);let m=r*h,v=a*h;m>ue&&(m-=l),v<0&&(v+=l);let w=v-m;w<0?w+=l:w>l&&(w-=l),c&&(w-=l);const x=de(ce(w/d)),b=w/x,k=ae(b/4),E=8/3*k*k/ae(b/2);v=m+b;let B,R,O,L,C,T,S,P,M=he(m),A=ae(m),D=O=y*s*M-f*n*A,I=L=f*s*M+y*n*A,W=e+O,F=i+L;t&&t.push(t.length?we:ve,W,F),u&&ge(u,W,F),p&&ye(p,W,F);for(let o=0;o<x;o++)B=he(v),R=ae(v),O=y*s*B-f*n*R,L=f*s*B+y*n*R,C=e+D-E*(y*s*A+f*n*M),T=i+I-E*(f*s*A-y*n*M),S=e+O+E*(y*s*R+f*n*B),P=i+L+E*(f*s*R-y*n*B),t&&t.push(xe,C,T,S,P,e+O,i+L),u&&Oe(e+D,i+I,C,T,S,P,e+O,i+L,u,!0),D=O,I=L,M=B,A=R,m=v,v+=b;_&&ye(_,e+O,i+L)},quadraticCurveTo(t,e,i,s,n,o,r){t.push(xe,(e+2*s)/3,(i+2*n)/3,(o+2*s)/3,(r+2*n)/3,o,r)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,o,r,a){Oe(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(o+2*s)/3,n,o,r,a)},toTwoPointBounds(t,e,i,s,n,o,r,a,h,l){const d=[];let c,u,_,p,g,f,y,m,v=t,w=i,x=n,b=r;for(let t=0;t<2;++t)if(1==t&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,_=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;p=-_/u,0<p&&p<1&&d.push(p)}else y=u*u-4*_*c,m=Math.sqrt(y),y<0||(g=(-u+m)/(2*c),0<g&&g<1&&d.push(g),f=(-u-m)/(2*c),0<f&&f<1&&d.push(f));l?fe(h,t,e):ge(h,t,e),fe(h,r,a);for(let l=0,c=d.length;l<c;l++)Re(d[l],t,e,i,s,n,o,r,a,Ee),fe(h,Ee.x,Ee.y)},getPointAndSet(t,e,i,s,n,o,r,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,_=3*d*t*t,p=t*t*t;l.x=c*e+u*s+_*o+p*a,l.y=c*i+u*n+_*r+p*h},getPoint(t,e,i,s,n,o,r,a,h){const l={};return Re(t,e,i,s,n,o,r,a,h,l),l}},{getPointAndSet:Re,toTwoPointBounds:Oe,ellipse:Le}=Be,{sin:Ce,cos:Te,sqrt:Se,atan2:Pe}=Math,{ellipse:Me}=Be,Ae={ellipticalArc(e,i,s,n,o,r,a,d,c,u,_){const p=(c-i)/2,g=(u-s)/2,f=r*h,y=Ce(f),m=Te(f),v=-m*p-y*g,w=-m*g+y*p,x=n*n,b=o*o,k=w*w,E=v*v,B=x*b-x*k-b*E;let R=0;if(B<0){const t=Se(1-B/(x*b));n*=t,o*=t}else R=(a===d?-1:1)*Se(B/(x*k+b*E));const O=R*n*w/o,L=-R*o*v/n,C=Pe((w-L)/o,(v-O)/n),T=Pe((-w-L)/o,(-v-O)/n);let S=T-C;0===d&&S>0?S-=l:1===d&&S<0&&(S+=l);const P=i+p+m*O-y*L,M=s+g+y*O+m*L,A=S<0?1:0;_||t.ellipseToCurve?Me(e,P,M,n,o,r,C/h,T/h,A):n!==o||r?e.push(Qt.G,P,M,n,o,r,C/h,T/h,A):e.push(Qt.O,P,M,n,C/h,T/h,A)}},{M:De,m:Ie,L:We,l:Fe,H:ze,h:Ne,V:Ye,v:He,C:Xe,c:Ve,S:je,s:Ue,Q:Ge,q:Ze,T:Ke,t:qe,A:Je,a:$e,Z:Qe,z:ti,N:ei,D:ii,X:si,G:ni,F:oi,O:ri,P:ai,U:hi}=Qt,{rect:li,roundRect:di,arcTo:ci,arc:ui,ellipse:_i,quadraticCurveTo:pi}=Be,{ellipticalArc:gi}=Ae,fi=vt.get("PathConvert"),yi={},mi={current:{dot:0},stringify(t,e){let i,s,n,o=0,r=t.length,h="";for(;o<r;){s=t[o],i=oe[s],h+=s===n?" ":ne[s];for(let s=1;s<i;s++)h+=a.float(t[o+s],e),s===i-1||(h+=" ");n=s,o+=i}return h},parse(t,e){let i,s,n,o="";const r=[],a=e?ie:ee;for(let e=0,h=t.length;e<h;e++)s=t[e],mt[s]?("."===s&&(vi.dot&&(wi(r,o),o=""),vi.dot++),"0"===o&&"."!==s&&(wi(r,o),o=""),o+=s):Qt[s]?(o&&(wi(r,o),o=""),vi.name=Qt[s],vi.length=te[s],vi.index=0,wi(r,vi.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?o+=s:(o&&wi(r,o),o=s):o&&(wi(r,o),o=""),n=s;return o&&wi(r,o),i?mi.toCanvasData(r,e):r},toCanvasData(t,e){let i,s,n,o,r,a=0,h=0,l=0,d=0,c=0,u=t.length;const _=[];for(;c<u;){switch(n=t[c],n){case Ie:t[c+1]+=a,t[c+2]+=h;case De:a=t[c+1],h=t[c+2],_.push(De,a,h),c+=3;break;case Ne:t[c+1]+=a;case ze:a=t[c+1],_.push(We,a,h),c+=2;break;case He:t[c+1]+=h;case Ye:h=t[c+1],_.push(We,a,h),c+=2;break;case Fe:t[c+1]+=a,t[c+2]+=h;case We:a=t[c+1],h=t[c+2],_.push(We,a,h),c+=3;break;case Ue:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=je;case je:r=o===Xe||o===je,l=r?2*a-i:t[c+1],d=r?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],_.push(Xe,l,d,i,s,a,h),c+=5;break;case Ve:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=Xe;case Xe:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],_.push(Xe,t[c+1],t[c+2],i,s,a,h),c+=7;break;case qe:t[c+1]+=a,t[c+2]+=h,n=Ke;case Ke:r=o===Ge||o===Ke,i=r?2*a-i:t[c+1],s=r?2*h-s:t[c+2],e?pi(_,a,h,i,s,t[c+1],t[c+2]):_.push(Ge,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Ze:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ge;case Ge:i=t[c+1],s=t[c+2],e?pi(_,a,h,i,s,t[c+3],t[c+4]):_.push(Ge,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case $e:t[c+6]+=a,t[c+7]+=h;case Je:gi(_,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case ti:case Qe:_.push(Qe),c++;break;case ei:a=t[c+1],h=t[c+2],e?li(_,a,h,t[c+3],t[c+4]):xi(_,t,c,5),c+=5;break;case ii:a=t[c+1],h=t[c+2],e?di(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):xi(_,t,c,9),c+=9;break;case si:a=t[c+1],h=t[c+2],e?di(_,a,h,t[c+3],t[c+4],t[c+5]):xi(_,t,c,6),c+=6;break;case ni:_i(e?_:xi(_,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,yi),a=yi.x,h=yi.y,c+=9;break;case oi:e?_i(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):xi(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case ri:ui(e?_:xi(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,yi),a=yi.x,h=yi.y,c+=7;break;case ai:e?ui(_,t[c+1],t[c+2],t[c+3],0,360,!1):xi(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case hi:ci(e?_:xi(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,yi),a=yi.x,h=yi.y,c+=6;break;default:return fi.error(`command: ${n} [index:${c}]`,t),_}o=n}return _},objectToCanvasData(t){const e=[];return t.forEach((t=>{switch(t.name){case"M":e.push(De,t.x,t.y);break;case"L":e.push(We,t.x,t.y);break;case"C":e.push(Xe,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Ge,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Qe)}})),e},copyData(t,e,i,s){for(let n=i,o=i+s;n<o;n++)t.push(e[n])},pushData(t,e){vi.index===vi.length&&(vi.index=1,t.push(vi.name)),t.push(Number(e)),vi.index++,vi.dot=0}},{current:vi,pushData:wi,copyData:xi}=mi,{M:bi,L:ki,C:Ei,Q:Bi,Z:Ri,N:Oi,D:Li,X:Ci,G:Ti,F:Si,O:Pi,P:Mi,U:Ai}=Qt,{getMinDistanceFrom:Di,getRadianFrom:Ii}=P,{tan:Wi,min:Fi,abs:zi}=Math,Ni={},Yi={beginPath(t){t.length=0},moveTo(t,e,i){t.push(bi,e,i)},lineTo(t,e,i){t.push(ki,e,i)},bezierCurveTo(t,e,i,s,n,o,r){t.push(Ei,e,i,s,n,o,r)},quadraticCurveTo(t,e,i,s,n){t.push(Bi,e,i,s,n)},closePath(t){t.push(Ri)},rect(t,e,i,s,n){t.push(Oi,e,i,s,n)},roundRect(t,e,i,s,n,o){if("number"==typeof o)t.push(Ci,e,i,s,n,o);else{const r=a.fourNumber(o);r?t.push(Li,e,i,s,n,...r):t.push(Oi,e,i,s,n)}},ellipse(t,e,i,s,n,o,r,a,h){void 0===o?t.push(Si,e,i,s,n):(void 0===r&&(r=0),void 0===a&&(a=360),t.push(Ti,e,i,s,n,o,r,a,h?1:0))},arc(t,e,i,s,n,o,r){void 0===n?t.push(Mi,e,i,s):(void 0===o&&(o=360),t.push(Pi,e,i,s,n,o,r?1:0))},arcTo(t,e,i,s,n,o,r,a){if(void 0!==r){const t=Di(r,a,e,i,s,n);o=Fi(o,Fi(t/2,t/2*zi(Wi(Ii(r,a,e,i,s,n)/2))))}t.push(Ai,e,i,s,n,o)},drawEllipse(t,e,i,s,n,o,r,a,h){Be.ellipse(null,e,i,s,n,void 0===o?0:o,void 0===r?0:r,void 0===a?360:a,h,null,null,Ni),t.push(bi,Ni.x,Ni.y),Hi(t,e,i,s,n,o,r,a,h)},drawArc(t,e,i,s,n,o,r){Be.arc(null,e,i,s,void 0===n?0:n,void 0===o?360:o,r,null,null,Ni),t.push(bi,Ni.x,Ni.y),Xi(t,e,i,s,n,o,r)},drawPoints(t,e,i,s){Be.points(t,e,i,s)}},{ellipse:Hi,arc:Xi}=Yi,{moveTo:Vi,lineTo:ji,quadraticCurveTo:Ui,bezierCurveTo:Gi,closePath:Zi,beginPath:Ki,rect:qi,roundRect:Ji,ellipse:$i,arc:Qi,arcTo:ts,drawEllipse:es,drawArc:is,drawPoints:ss}=Yi;class ns{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?"string"==typeof t?Jt.parse(t):t:[],this}beginPath(){return Ki(this.__path),this.paint(),this}moveTo(t,e){return Vi(this.__path,t,e),this.paint(),this}lineTo(t,e){return ji(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,o){return Gi(this.__path,t,e,i,s,n,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return Ui(this.__path,t,e,i,s),this.paint(),this}closePath(){return Zi(this.__path),this.paint(),this}rect(t,e,i,s){return qi(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Ji(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,o,r,a){return $i(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}arc(t,e,i,s,n,o){return Qi(this.__path,t,e,i,s,n,o),this.paint(),this}arcTo(t,e,i,s,n){return ts(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,o,r,a){return es(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}drawArc(t,e,i,s,n,o){return is(this.__path,t,e,i,s,n,o),this.paint(),this}drawPoints(t,e,i){return ss(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:os,L:rs,C:as,Q:hs,Z:ls,N:ds,D:cs,X:us,G:_s,F:ps,O:gs,P:fs,U:ys}=Qt,ms=vt.get("PathDrawer"),vs={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case os:t.moveTo(e[s+1],e[s+2]),s+=3;break;case rs:t.lineTo(e[s+1],e[s+2]),s+=3;break;case as:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case hs:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case ls:t.closePath(),s+=1;break;case ds:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case cs:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case us:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case _s:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*h,e[s+6]*h,e[s+7]*h,e[s+8]),s+=9;break;case ps:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,l,!1),s+=5;break;case gs:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*h,e[s+5]*h,e[s+6]),s+=7;break;case fs:t.arc(e[s+1],e[s+2],e[s+3],0,l,!1),s+=4;break;case ys:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void ms.error(`command: ${i} [index:${s}]`,e)}}},{M:ws,L:xs,C:bs,Q:ks,Z:Es,N:Bs,D:Rs,X:Os,G:Ls,F:Cs,O:Ts,P:Ss,U:Ps}=Qt,{toTwoPointBounds:Ms,toTwoPointBoundsByQuadraticCurve:As,arcTo:Ds,arc:Is,ellipse:Ws}=Be,{addPointBounds:Fs,copy:zs,addPoint:Ns,setPoint:Ys,addBounds:Hs,toBounds:Xs}=Y,Vs=vt.get("PathBounds");let js,Us,Gs;const Zs={},Ks={},qs={},Js={toBounds(t,e){Js.toTwoPointBounds(t,Ks),Xs(Ks,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Ys(e,0,0);let i,s,n,o,r,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(r=t[a],0===a&&(r===Es||r===bs||r===ks?Ys(e,h,l):Ys(e,t[a+1],t[a+2])),r){case ws:case xs:h=t[a+1],l=t[a+2],Ns(e,h,l),a+=3;break;case bs:n=t[a+5],o=t[a+6],Ms(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,o,Zs),Fs(e,Zs),h=n,l=o,a+=7;break;case ks:i=t[a+1],s=t[a+2],n=t[a+3],o=t[a+4],As(h,l,i,s,n,o,Zs),Fs(e,Zs),h=n,l=o,a+=5;break;case Es:a+=1;break;case Bs:h=t[a+1],l=t[a+2],Hs(e,h,l,t[a+3],t[a+4]),a+=5;break;case Rs:case Os:h=t[a+1],l=t[a+2],Hs(e,h,l,t[a+3],t[a+4]),a+=r===Rs?9:6;break;case Ls:Ws(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],t[a+7],t[a+8],Zs,qs),0===a?zs(e,Zs):Fs(e,Zs),h=qs.x,l=qs.y,a+=9;break;case Cs:h=t[a+1],l=t[a+2],Us=t[a+3],Gs=t[a+4],Hs(e,h-Us,l-Gs,2*Us,2*Gs),h+=Us,a+=5;break;case Ts:Is(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Zs,qs),0===a?zs(e,Zs):Fs(e,Zs),h=qs.x,l=qs.y,a+=7;break;case Ss:h=t[a+1],l=t[a+2],js=t[a+3],Hs(e,h-js,l-js,2*js,2*js),h+=js,a+=4;break;case Ps:Ds(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Zs,qs),0===a?zs(e,Zs):Fs(e,Zs),h=qs.x,l=qs.y,a+=6;break;default:return void Vs.error(`command: ${r} [index:${a}]`,t)}}},{M:$s,L:Qs,C:tn,Z:en}=Qt,{getCenterX:sn,getCenterY:nn}=P,{arcTo:on}=Yi,rn={smooth(t,e,i){let s,n=0,o=0,r=0,a=0,h=0,l=0,d=0,c=0,u=0;const _=t.length,p=[];for(;n<_;)switch(s=t[n],s){case $s:a=c=t[n+1],h=u=t[n+2],n+=3,t[n]===Qs?(l=t[n+1],d=t[n+2],p.push($s,sn(a,l),nn(h,d))):p.push($s,a,h);break;case Qs:switch(o=t[n+1],r=t[n+2],n+=3,t[n]){case Qs:on(p,o,r,t[n+1],t[n+2],e,c,u);break;case en:on(p,o,r,a,h,e,c,u);break;default:p.push(Qs,o,r)}c=o,u=r;break;case tn:p.push(tn,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],t[n+6]),n+=7;break;case en:on(p,a,h,l,d,e,c,u),p.push(en),n+=1}return s!==en&&(p[1]=a,p[2]=h),p}};Jt.creator=new ns,Jt.parse=mi.parse,Jt.convertToCanvasData=mi.toCanvasData;const an=new ns,{drawRoundRect:hn}=re;function ln(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){hn(this,t,e,i,s,n)})}(t)}const dn={opacityTypes:["png","webp","svg"],upperCaseTypeMap:{},mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=cn.fileType(t);return["jpg","jpeg"].some((t=>t===e))},getExportOptions(t){switch(typeof t){case"object":return t;case"number":return{quality:t};case"boolean":return{blob:t};default:return{}}}},cn=dn;cn.opacityTypes.forEach((t=>cn.upperCaseTypeMap[t]=t.toUpperCase()));const un=vt.get("TaskProcessor");class _n{constructor(t){this.parallel=!0,this.time=1,this.id=i.create(i.TASK),this.task=t}run(){return Yt(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){un.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class pn{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,i=0;for(let s=0;s<t;s++)s<=this.finishedIndex?(i+=this.list[s].time,s===this.finishedIndex&&(e=i)):e+=this.list[s].time;return this.isComplete?1:i/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&At.assign(this.config,t),this.empty()}add(t,e){let i,s,n,o;const r=new _n(t);return r.parent=this,"number"==typeof e?o=e:e&&(s=e.parallel,i=e.start,n=e.time,o=e.delay),n&&(r.time=n),!1===s&&(r.parallel=!1),void 0===o?this.push(r,i):(this.delayNumber++,setTimeout((()=>{this.delayNumber&&(this.delayNumber--,this.push(r,i))}),o)),this.isComplete=!1,r}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout((()=>this.start())))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[],this.delayNumber=0}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach((t=>{t.isComplete||t.cancel()})),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)})):this.nextTask()}runParallelTasks(){this.parallelList.forEach((t=>this.runParallelTask(t)))}runParallelTask(t){t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout((()=>this.run()))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let i=this.index;i<e&&(t=this.list[i],t.parallel);i++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const i=e.length,s=this.finishedIndex+i;if(e.length){if(!this.running)return;s<this.total&&(t=this.list[s],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const gn=vt.get("Resource"),fn={tasker:new pn,map:{},get isComplete(){return yn.tasker.isComplete},set(t,e){yn.map[t]&&gn.repeat(t),yn.map[t]=e},get:t=>yn.map[t],remove(t){const e=yn.map[t];e&&(e.destroy&&e.destroy(),delete yn.map[t])},loadImage(t,e){return new Promise(((i,s)=>{const n=this.setImage(t,t,e);n.load((()=>i(n)),(t=>s(t)))}))},setImage(t,i,s){let n;return"string"==typeof i?n={url:i}:i.url||(n={url:t,view:i}),n&&(s&&(n.format=s),i=e.image(n)),yn.set(t,i),i},destroy(){yn.map={}}},yn=fn,mn={maxRecycled:100,recycledList:[],patternTasker:new pn,get(t){let i=fn.get(t.url);return i||fn.set(t.url,i=e.image(t)),i.use++,i},recycle(t){t.use--,setTimeout((()=>{t.use||vn.recycledList.push(t)}))},clearRecycled(){const t=vn.recycledList;t.length>vn.maxRecycled&&(t.forEach((t=>!t.use&&t.url&&fn.remove(t.url))),t.length=0)},hasOpacityPixel:t=>dn.opacityTypes.some((e=>vn.isFormat(e,t))),isFormat(t,e){if(e.format===t)return!0;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+dn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+dn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){vn.recycledList=[]}},vn=mn,{IMAGE:wn,create:xn}=i;class bn{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=xn(wn),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}mn.isFormat("svg",t)&&(this.isSVG=!0),mn.hasOpacityPixel(t)&&(this.hasOpacityPixel=!0)}load(e,i){return this.loading||(this.loading=!0,fn.tasker.add((()=>Yt(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>this.setView(t))).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),this.waitComplete.push(e,i),this.waitComplete.length-2}unload(t,e){const i=this.waitComplete;if(e){const e=i[t+1];e&&e({type:"stop"})}i[t]=i[t+1]=void 0}setView(t){this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onComplete(t){let e;this.waitComplete.forEach(((i,s)=>{e=s%2,i&&(t?e||i(this):e&&i(this.error))})),this.waitComplete.length=0,this.loading=!1}getFull(t){return this.view}getCanvas(e,i,s,n){if(e||(e=this.width),i||(i=this.height),this.cache){let{params:t,data:e}=this.cache;for(let i in t)if(t[i]!==arguments[i]){e=null;break}if(e)return e}const o=t.origin.createCanvas(e,i),r=o.getContext("2d");return s&&(r.globalAlpha=s),r.drawImage(this.view,0,0,e,i),this.cache=this.use>1?{data:o,params:arguments}:null,o}getPattern(e,i,s,n){const o=t.canvas.createPattern(e,i);try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function kn(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function En(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Bn(t,e){return(i,s)=>On(i,s,t,e&&e(s))}function Rn(t){return t}function On(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};kn(t,e,Object.assign(n,s||{})),to(t,e,i)}function Ln(t){return Bn(t)}function Cn(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}})))}function Tn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),Dn(this))}})))}function Sn(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}})))}function Pn(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}})))}function Mn(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&Dn(this)}})))}function An(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(Dn(this),this.__.__removeNaturalSize())}})))}function Dn(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function In(t){return Bn(t,(t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),Dn(this)}})))}const Wn=Mn;function Fn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&zn(this)}})))}function zn(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&Dn(t)}const Nn=Fn;function Yn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Hn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}})))}function Xn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&jn(this)}})))}function Vn(t){return Bn(t,(t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",(()=>Un(this,t,e,i)))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Un(this,t,e,i),this.mask&&jn(this)}})))}function jn(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Un(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||Dn(t))}function Gn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()})))}})))}function Zn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(e)})))}})))}function Kn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&this.waitParent((()=>{this.parent.__updateEraser(e)}))}})))}function qn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,vt.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor())}})))}function Jn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}})))}function $n(t){return(e,i)=>{kn(e,"__DataProcessor",{get:()=>t})}}function Qn(t){return(e,i)=>{kn(e,"__LayoutProcessor",{get:()=>t})}}function to(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),r={get(){const t=this[n];return void 0===t?i:t},set(t){this[n]=t}};void 0===i?r.get=function(){return this[n]}:"function"==typeof i&&(r.get=function(){let t=this[n];return void 0===t?i(this.__leaf):t}),"width"===e?r.get=function(){const t=this[n];if(void 0===t){const t=this;return t._height&&t.__naturalWidth&&t.__useNaturalRatio?t._height*t.__naturalWidth/t.__naturalHeight:t.__naturalWidth||i}return t}:"height"===e&&(r.get=function(){const t=this[n];if(void 0===t){const t=this;return t._width&&t.__naturalHeight&&t.__useNaturalRatio?t._width*t.__naturalHeight/t.__naturalWidth:t.__naturalHeight||i}return t});let a,h=s;for(;!a&&h;)a=En(h,e),h=h.__proto__;a&&a.set&&(r.set=a.set),s[o]&&(r.set=s[o],delete s[o]),kn(s,e,r)}const eo=new vt("rewrite"),io=[],so=["destroy","constructor"];function no(t){return(e,i)=>{io.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function oo(){return t=>{ro()}}function ro(t){io.length&&(io.forEach((e=>{t&&eo.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),io.length=0)}function ao(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach((s=>{if(!(so.includes(s)||e&&e.includes(s)))if(t.prototype){En(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]}))}}function ho(){return t=>{Lt.register(t)}}function lo(){return t=>{St.register(t)}}setTimeout((()=>ro(!0)));const{copy:co,toInnerPoint:uo,toOuterPoint:_o,scaleOfOuter:po,rotateOfOuter:go,skewOfOuter:fo,multiplyParent:yo,divideParent:mo,getLayout:vo}=x,wo={},xo={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),Eo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)ko(s[t],e,i)}},updateMatrix(t,e,i){const s=t.__layout;e?i&&(s.waitAutoLayout=!0,t.__hasAutoLayout&&(s.matrixChanged=!1)):s.waitAutoLayout&&(s.waitAutoLayout=!1),s.matrixChanged&&t.__updateLocalMatrix(),s.waitAutoLayout||t.__updateWorldMatrix()},updateBounds(t){const e=t.__layout;e.boundsChanged&&t.__updateLocalBounds(),e.waitAutoLayout||t.__updateWorldBounds()},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)Bo(e[t])}},updateAllChange(t){if(Bo(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)Ro(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},moveWorld(t,e,i=0,s,n){const o="object"==typeof e?Object.assign({},e):{x:e,y:i};s?_o(t.localTransform,o,o,!0):t.parent&&uo(t.parent.worldTransform,o,o,!0),bo.moveLocal(t,o.x,o.y,n)},moveLocal(t,e,i=0,s){"object"==typeof e&&(i=e.y,e=e.x),e+=t.x,i+=t.y,s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,o){bo.zoomOfLocal(t,Oo(t,e),i,s,n,o)},zoomOfLocal(t,e,i,s=i,n,o){const r=t.__localMatrix;if("number"!=typeof s&&(s&&(o=s),s=i),co(wo,r),po(wo,e,i,s),t.origin||t.around)bo.setTransform(t,wo,n,o);else{const e=t.x+wo.e-r.e,a=t.y+wo.f-r.f;o&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},o):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){bo.rotateOfLocal(t,Oo(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;co(wo,n),go(wo,e,i),t.origin||t.around?bo.setTransform(t,wo,!1,s):t.set({x:t.x+wo.e-n.e,y:t.y+wo.f-n.f,rotation:a.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,o){bo.skewOfLocal(t,Oo(t,e),i,s,n,o)},skewOfLocal(t,e,i,s=0,n,o){co(wo,t.__localMatrix),fo(wo,e,i,s),bo.setTransform(t,wo,n,o)},transformWorld(t,e,i,s){co(wo,t.worldTransform),yo(wo,e),t.parent&&mo(wo,t.parent.worldTransform),bo.setTransform(t,wo,i,s)},transform(t,e,i,s){co(wo,t.localTransform),yo(wo,e),bo.setTransform(t,wo,i,s)},setTransform(t,e,i,s){const n=t.__,o=n.origin&&bo.getInnerOrigin(t,n.origin),r=vo(e,o,n.around&&bo.getInnerOrigin(t,n.around));if(i){const e=r.scaleX/t.scaleX,i=r.scaleY/t.scaleY;if(delete r.scaleX,delete r.scaleY,o){nt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=bo.getInnerOrigin(t,n.origin);P.move(r,o.x-s.x,o.y-s.y)}t.set(r),t.scaleResize(e,i,!1)}else t.set(r,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return po(i,bo.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>P.tempToOuterOf(bo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return pt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(co(wo,t.worldTransform),mo(wo,e.worldTransform),i?wo:Object.assign({},wo)),drop(t,e,i,s){t.setTransform(bo.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}}},bo=xo,{updateAllMatrix:ko,updateMatrix:Eo,updateAllWorldOpacity:Bo,updateAllChange:Ro}=bo;function Oo(t,e){return t.__layout.update(),t.parent?P.tempToInnerOf(e,t.parent.__world):e}const Lo={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.eraser||0===t.__.visible?null:t.__local||t.__layout,localStrokeBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localRenderBounds,maskLocalBoxBounds:t=>t.__.mask?t.__localBoxBounds:null,maskLocalStrokeBounds:t=>t.__.mask?t.__layout.localStrokeBounds:null,maskLocalRenderBounds:t=>t.__.mask?t.__layout.localRenderBounds:null,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))},{updateBounds:Co}=xo,To={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:i}=t;for(let s=0,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),So(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&void 0===i[t.parent.innerId];)e.add(t.parent),t=t.parent;else for(;t.parent;)e.add(t.parent),t=t.parent},pushAllBranchStack(t,e){let i=e.length;const{children:s}=t;for(let t=0,i=s.length;t<i;t++)s[t].isBranch&&e.push(s[t]);for(let t=i,s=e.length;t<s;t++)Po(e[t],e)},updateBounds(t,e){const i=[t];Po(t,i),Mo(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let n=t.length-1;n>-1;n--){i=t[n],s=i.children;for(let t=0,e=s.length;t<e;t++)Co(s[t]);e&&e===i||Co(i)}}},{pushAllChildBranch:So,pushAllBranchStack:Po,updateBoundsByBranchStack:Mo}=To,Ao={run(t){if(t&&t.length){const e=t.length;for(let i=0;i<e;i++)t[i]();t.length===e?t.length=0:t.splice(0,e)}}},{getRelativeWorld:Do}=xo,{toOuterOf:Io,getPoints:Wo,copy:Fo}=nt,zo="_localContentBounds",No="_worldContentBounds",Yo="_worldBoxBounds",Ho="_worldStrokeBounds";class Xo{get contentBounds(){return this._contentBounds||this.boxBounds}set contentBounds(t){this._contentBounds=t}get strokeBounds(){return this._strokeBounds||this.boxBounds}get renderBounds(){return this._renderBounds||this.boxBounds}get localContentBounds(){return Io(this.contentBounds,this.leaf.__localMatrix,this[zo]||(this[zo]={})),this[zo]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return Io(this.contentBounds,this.leaf.__world,this[No]||(this[No]={})),this[No]}get worldBoxBounds(){return Io(this.boxBounds,this.leaf.__world,this[Yo]||(this[Yo]={})),this[Yo]}get worldStrokeBounds(){return Io(this.strokeBounds,this.leaf.__world,this[Ho]||(this[Ho]={})),this[Ho]}get a(){return 1}get b(){return 0}get c(){return 0}get d(){return 1}get e(){return this.leaf.__.x}get f(){return this.leaf.__.y}get x(){return this.e+this.boxBounds.x}get y(){return this.f+this.boxBounds.y}get width(){return this.boxBounds.width}get height(){return this.boxBounds.height}constructor(t){this.leaf=t,this.boxBounds={x:0,y:0,width:0,height:0},this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),this.boxChange(),this.matrixChange()}createLocal(){const t=this.leaf.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0};this._localStrokeBounds||(this._localStrokeBounds=t),this._localRenderBounds||(this._localRenderBounds=t)}update(){const{leafer:e}=this.leaf;if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=this.leaf;for(;e.parent&&!e.parent.leafer;)e=e.parent;t.layout(e)}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return x.defaultMatrix;case"page":t=e.zoomLayer;default:return Do(e,t)}}getBounds(t,e="world"){switch(this.update(),e){case"world":return this.getWorldBounds(t);case"local":return this.getLocalBounds(t);case"inner":return this.getInnerBounds(t);case"page":e=this.leaf.zoomLayer;default:return new ht(this.getInnerBounds(t)).toOuterOf(this.getTransform(e))}}getInnerBounds(t="box"){switch(t){case"render":return this.renderBounds;case"content":if(this.contentBounds)return this.contentBounds;case"box":return this.boxBounds;case"stroke":return this.strokeBounds}}getLocalBounds(t="box"){switch(t){case"render":return this.localRenderBounds;case"stroke":return this.localStrokeBounds;case"content":if(this.contentBounds)return this.localContentBounds;case"box":return this.leaf.__localBoxBounds}}getWorldBounds(t="box"){switch(t){case"render":return this.leaf.__world;case"stroke":return this.worldStrokeBounds;case"content":if(this.contentBounds)return this.worldContentBounds;case"box":return this.worldBoxBounds}}getLayoutBounds(t,e="world",i){const{leaf:s}=this;let n,o,r,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;r={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,o=x.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),o=Do(s,e,!0)}if(r||(r=x.getLayout(o)),Fo(r,a),P.copy(r,n),i){const{scaleX:t,scaleY:e}=r,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(r.scaleX/=i,r.scaleY/=s,r.width*=i,r.height*=s)}return r}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=Wo(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:n=e}return void 0!==n&&s.forEach((t=>i.innerToWorld(t,null,!1,n))),s}shrinkContent(){const{x:t,y:e,width:i,height:s}=this.boxBounds;this._contentBounds={x:t,y:e,width:i,height:s}}spreadStroke(){const{x:t,y:e,width:i,height:s}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:i,height:s},this._localStrokeBounds={x:t,y:e,width:i,height:s},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:i,height:s}=this.renderBounds;this._renderBounds={x:t,y:e,width:i,height:s},this._localRenderBounds={x:t,y:e,width:i,height:s}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class Vo{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&t.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&t.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&t.event.stop(this.origin)}}class jo extends Vo{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}jo.ADD="child.add",jo.REMOVE="child.remove",jo.CREATED="created",jo.MOUNTED="mounted",jo.UNMOUNTED="unmounted",jo.DESTROY="destroy";class Uo extends Vo{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Uo.CHANGE="property.change",Uo.LEAFER_CHANGE="property.leafer_change";class Go extends Vo{constructor(t,e){super(t),Object.assign(this,e)}}Go.LOAD="image.load",Go.LOADED="image.loaded",Go.ERROR="image.error";class Zo extends Vo{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){"object"==typeof t?(super(Zo.RESIZE),Object.assign(this,t)):super(t),this.old=e}}Zo.RESIZE="resize";class Ko extends Vo{constructor(t,e){super(t),this.data=e}}Ko.REQUEST="watch.request",Ko.DATA="watch.data";class qo extends Vo{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}qo.REQUEST="layout.request",qo.START="layout.start",qo.BEFORE="layout.before",qo.LAYOUT="layout",qo.AFTER="layout.after",qo.AGAIN="layout.again",qo.END="layout.end";class Jo extends Vo{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Jo.REQUEST="render.request",Jo.CHILD_START="render.child_start",Jo.START="render.start",Jo.BEFORE="render.before",Jo.RENDER="render",Jo.AFTER="render.after",Jo.AGAIN="render.again",Jo.END="render.end",Jo.NEXT="render.next";class $o extends Vo{}$o.START="leafer.start",$o.BEFORE_READY="leafer.before_ready",$o.READY="leafer.ready",$o.AFTER_READY="leafer.after_ready",$o.VIEW_READY="leafer.view_ready",$o.VIEW_COMPLETED="leafer.view_completed",$o.STOP="leafer.stop",$o.RESTART="leafer.restart",$o.END="leafer.end";const Qo={};class tr{set event(t){this.on(t)}on(t,e,i){if(!e){let e,i=t;for(let t in i)e=i[t],e instanceof Array?this.on(t,e[0],e[1]):this.on(t,e);return}let s,n,o;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const r=er(this,s,!0),a="string"==typeof t?t.split(" "):t,h=n?{listener:e,once:n}:{listener:e};a.forEach((t=>{t&&(o=r[t],o?-1===o.findIndex((t=>t.listener===e))&&o.push(h):r[t]=[h])}))}off(t,e,i){if(t){const s="string"==typeof t?t.split(" "):t;if(e){let t,n,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const r=er(this,t);s.forEach((t=>{t&&(n=r[t],n&&(o=n.findIndex((t=>t.listener===e)),o>-1&&n.splice(o,1),n.length||delete r[t]))}))}else{const{__bubbleMap:t,__captureMap:e}=this;s.forEach((i=>{t&&delete t[i],e&&delete e[i]}))}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,i,s){return i&&(e=e.bind(i)),this.on(t,e,s),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=t instanceof Array?t:[t];e.forEach((t=>t.current.off(t.type,t.listener,t.options))),e.length=0}once(t,e,i){this.on(t,e,{once:!0,capture:i})}emit(t,e,i){!e&&St.has(t)&&(e=St.get(t,{type:t,target:this,current:this}));const s=er(this,i)[t];if(s){let n;for(let o=0,r=s.length;o<r&&!((n=s[o])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),o--,r--),e&&e.isStopNow));o++);}this.syncEventer&&this.syncEventer.emitEvent(e,i)}emitEvent(t,e){t.current=this,this.emit(t.type,t,e)}hasEvent(t,e){if(this.syncEventer&&this.syncEventer.hasEvent(t,e))return!0;const{__bubbleMap:i,__captureMap:s}=this,n=i&&i[t],o=s&&s[t];return!!(void 0===e?n||o:e?o:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function er(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Qo)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Qo)}}const{on:ir,on_:sr,off:nr,off_:or,once:rr,emit:ar,emitEvent:hr,hasEvent:lr,destroy:dr}=tr.prototype,cr={on:ir,on_:sr,off:nr,off_:or,once:rr,emit:ar,emitEvent:hr,hasEvent:lr,destroyEventer:dr},{isFinite:ur}=Number,_r=vt.get("setAttr"),pr={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(i&&!ur(e)&&void 0!==e&&(_r.warn(this.innerName,t,e),e=void 0),"object"==typeof e||s!==e){this.__realSetAttr(t,e);const{CHANGE:i}=Uo,n=new Uo(i,this,t,s,e);return this.isLeafer?this.emitEvent(new Uo(Uo.LEAFER_CHANGE,this,t,s,e)):this.hasEvent(i)&&this.emitEvent(n),this.leafer.emitEvent(n),!0}return!1}return this.__realSetAttr(t,e),!0},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||void 0===i.normalStyle[t]||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:gr,multiplyParent:fr,translateInner:yr,defaultWorld:mr}=x,{toPoint:vr,tempPoint:wr}=pt,xr={__updateWorldMatrix(){fr(this.__local||this.__layout,this.parent?this.parent.__world:mr,this.__world,!!this.__layout.affectScaleOrRotation,this.__,this.parent&&this.parent.__)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged||t.rotationChanged)&&(gr(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=!1),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(vr(i.around||i.origin,t.boxBounds,wr),yr(e,-wr.x,-wr.y,!i.around))}this.__layout.matrixChanged=!1}},{updateMatrix:br,updateAllMatrix:kr}=xo,{updateBounds:Er}=To,{toOuterOf:Br,copyAndSpread:Rr,copy:Or}=nt,{toBounds:Lr}=Js,Cr={__updateWorldBounds(){Br(this.__layout.renderBounds,this.__world,this.__world),this.__layout.resized&&(this.__onUpdateSize(),this.__layout.resized=!1)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized=!0),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=!1,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=!1,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=!1,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized=!0),t.renderChanged&&(t.renderSpread=this.__updateRenderSpread(),t.renderSpread?(t.renderBounds!==t.boxBounds&&t.renderBounds!==t.strokeBounds||t.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):t.spreadRenderCancel(),t.renderChanged=!1,this.parent&&this.parent.__layout.renderChange()),t.boundsChanged=!1},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),Br(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Br(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Br(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,e=this.__;e.__pathInputed?Lr(e.path,t):(t.x=0,t.y=0,t.width=e.width,t.height=e.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),kr(this),Er(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(kr(this),Er(this,this))):br(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(){const t=this.__layout;Rr(t.strokeBounds,t.boxBounds,t.strokeBoxSpread)},__updateRenderBounds(){const t=this.__layout;t.renderSpread>0?Rr(t.renderBounds,t.boxBounds,t.renderSpread):Or(t.renderBounds,t.strokeBounds)}},Tr={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=this.__.opacity,this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!0,!0);this.__draw(i,e,t),this.__worldFlipped?t.copyWorldByReset(i,this.__nowWorld,null,this.__.__blendMode,!0):t.copyWorldToInner(i,this.__nowWorld,this.__layout.renderBounds,this.__.__blendMode),i.recycle(this.__nowWorld)}else this.__draw(t,e)},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),this.windingRule?t.clip(this.windingRule):t.clip())},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:Sr}=Lo,Pr={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__nowWorld=this.__getNowWorld(e),this.__worldOpacity)if(this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!1,!0);this.__renderBranch(i,e);const s=this.__nowWorld;t.opacity=this.__.opacity,t.copyWorldByReset(i,s,s,this.__.__blendMode,!0),i.recycle(s)}else this.__renderBranch(t,e)},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Sr(i[s],e)||i[s].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Sr(i[s],e)||i[s].__clip(t,e)}}},{LEAF:Mr,create:Ar}=i,{toInnerPoint:Dr,toOuterPoint:Ir,multiplyParent:Wr}=x,{toOuterOf:Fr}=nt,{copy:zr,move:Nr}=P,{moveLocal:Yr,zoomOfLocal:Hr,rotateOfLocal:Xr,skewOfLocal:Vr,moveWorld:jr,zoomOfWorld:Ur,rotateOfWorld:Gr,skewOfWorld:Zr,transform:Kr,transformWorld:qr,setTransform:Jr,getFlipTransform:$r,getLocalOrigin:Qr,getRelativeWorld:ta,drop:ea}=xo;let ia=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return It}get __LayoutProcessor(){return Xo}get leaferIsCreated(){return this.leafer&&this.leafer.created}get leaferIsReady(){return this.leafer&&this.leafer.ready}get isLeafer(){return!1}get isBranch(){return!1}get isBranchLeaf(){return!1}get __localMatrix(){return this.__local||this.__layout}get __localBoxBounds(){return this.__local||this.__layout}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get boxBounds(){return this.getBounds("box","inner")}get renderBounds(){return this.getBounds("render","inner")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.__layout.update(),this.__worldOpacity}get __worldFlipped(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}get __inLazyBounds(){return this.leaferIsCreated&&this.leafer.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=Ar(Mr),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(jo.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1},null!==t&&(this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0}),this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),this.__level&&this.resetCustom(),t&&(t.__&&(t=t.toJSON()),t.children?this.set(t):Object.assign(this,t))}resetCustom(){this.__hasMask=this.__hasEraser=null,this.forceUpdate()}waitParent(t,e){e&&(t=t.bind(e)),this.parent?t():this.on(jo.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(jo.MOUNTED,t,"once")}nextRender(t,e,i){this.leafer?this.leafer.nextRender(t,e,i):this.waitLeafer((()=>this.leafer.nextRender(t,e,i)))}removeNextRender(t){this.nextRender(t,null,"off")}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer&&!t&&this.leafer.leafs--,this.leafer=t,t?(t.leafs++,this.__level=this.parent?this.parent.__level+1:1,this.animation&&this.__runAnimation("in"),this.__bubbleMap&&this.__emitLifeEvent(jo.MOUNTED)):this.__emitLifeEvent(jo.UNMOUNTED),this.isBranch){const{children:e}=this;for(let i=0,s=e.length;i<s;i++)e[i].__bindLeafer(t)}}set(t,e){}get(t){}setAttr(t,e){this[t]=e}getAttr(t){return this[t]}getComputedAttr(t){return this.__[t]}toJSON(t){return t&&this.__layout.update(),this.__.__getInputData(null,t)}toString(t){return JSON.stringify(this.toJSON(t))}toSVG(){}__SVG(t){}toHTML(){}__setAttr(t,e){return!0}__getAttr(t){}setProxyAttr(t,e){}getProxyAttr(t){}find(t,e){}findTag(t){}findOne(t,e){}findId(t){}focus(t){}updateState(){}updateLayout(){this.__layout.update()}forceUpdate(t){void 0===t?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}forceRender(t,e){this.forceUpdate("surface")}__extraUpdate(){this.leaferIsReady&&this.leafer.layouter.addExtra(this)}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateContentBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some((t=>t.__.eraser))}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:i}=this.__layout;t.clearRect(i.x,i.y,i.width,i.height),t.restore()}__updateMask(t){this.__hasMask=this.children.some((t=>t.__.mask&&t.__.visible&&t.__.opacity))}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld;return Wr(this.__world,t.matrix,e,void 0,this.__world),Fr(this.__layout.renderBounds,e,e),e}return this.__world}getTransform(t){return this.__layout.getTransform(t||"local")}getBounds(t,e){return this.__layout.getBounds(t,e)}getLayoutBounds(t,e,i){return this.__layout.getLayoutBounds(t,e,i)}getLayoutPoints(t,e){return this.__layout.getLayoutPoints(t,e)}getWorldBounds(t,e,i){const s=e?ta(this,e):this.worldTransform,n=i?t:{};return Fr(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&zr(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&zr(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Dr(this.worldTransform,t,e,i)}innerToWorld(t,e,i,s){Ir(this.worldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Nr(n,-o,-r),n}getInnerPoint(t,e,i,s){const n=s?t:{};return this.worldToInner(t,n,i,e),n}getInnerPointByBox(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Nr(n,o,r),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){Jr(this,t,e,i)}transform(t,e,i){Kr(this,t,e,i)}move(t,e,i){Yr(this,t,e,i)}moveInner(t,e,i){jr(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Hr(this,Qr(this,t),e,i,s,n)}rotateOf(t,e,i){Xr(this,Qr(this,t),e,i)}skewOf(t,e,i,s,n){Vr(this,Qr(this,t),e,i,s,n)}transformWorld(t,e,i){qr(this,t,e,i)}moveWorld(t,e,i){jr(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){Ur(this,t,e,i,s,n)}rotateOfWorld(t,e){Gr(this,t,e)}skewOfWorld(t,e,i,s,n){Zr(this,t,e,i,s,n)}flip(t,e){Kr(this,$r(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}__hitWorld(t){return!0}__hit(t){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e){}__clip(t,e){}__renderShape(t,e,i,s){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return Rt.need("path")}getMotionPoint(t){return Rt.need("path")}getMotionTotal(){return 0}__updateMotionPath(){}__runAnimation(t,e){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}dropTo(t,e,i){ea(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):to(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=Mn),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new jo(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(jo.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};ia=Nt([ao(pr),ao(xr),ao(Cr),ao(cr),ao(Tr)],ia);const{setListWithFn:sa}=nt,{sort:na}=To,{localBoxBounds:oa,localStrokeBounds:ra,localRenderBounds:aa,maskLocalBoxBounds:ha,maskLocalStrokeBounds:la,maskLocalRenderBounds:da}=Lo,ca=new vt("Branch");let ua=class extends ia{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(){sa(this.__layout.boxBounds,this.children,this.__hasMask?ha:oa)}__updateStrokeBounds(){sa(this.__layout.strokeBounds,this.children,this.__hasMask?la:ra)}__updateRenderBounds(){sa(this.__layout.renderBounds,this.children,this.__hasMask?da:aa)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let i=0,s=e.length;i<s;i++)e[i].__tempNumber=i,e[i].__.zIndex&&(t=!0);e.sort(na),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return ca.warn("add self or destroyed");const i=void 0===e;if(!t.__){if(t instanceof Array)return t.forEach((t=>{this.add(t,e),i||e++}));t=Lt.get(t.tag,t)}t.parent&&t.parent.remove(t),t.parent=this,i?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1);const s=t.__layout;s.boxChanged||s.boxChange(),s.matrixChanged||s.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(jo.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(jo.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){this.add(t)}remove(t,e){t?t.__?t.animationOut?t.__runAnimation("out",(()=>this.__remove(t,e))):this.__remove(t,e):this.find(t).forEach((t=>this.remove(t,e))):void 0===t&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach((e=>{this.__realRemoveChild(e),t&&e.destroy()})))}clear(){this.removeAll(!0)}__remove(t,e){const i=this.children.indexOf(t);i>-1&&(this.children.splice(i,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.__emitLifeEvent(jo.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(jo.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new jo(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};ua=Nt([ao(Pr)],ua);class _a{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return t&&void 0!==this.keys[t.innerId]}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return void 0===e?-1:e}add(t){const{list:e,keys:i}=this;void 0===i[t.innerId]&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(void 0===i[t.innerId]){const{list:s}=this;for(let t=e,n=s.length;t<n;t++)i[s[t].innerId]++;0===e?s.unshift(t):(e>s.length&&(e=s.length),s.splice(e,0,t)),i[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let i;for(let s=0,n=e.length;s<n;s++)void 0!==i?this.keys[e[s].innerId]=s-1:e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]);void 0!==i&&e.splice(i,1)}sort(t){const{list:e}=this;t?e.sort(((t,e)=>e.__level-t.__level)):e.sort(((t,e)=>t.__level-e.__level))}forEach(t){this.list.forEach(t)}clone(){const t=new _a;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let i=0,s=t.length;i<s;i++)e[t[i].innerId]=i}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}class pa{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return void 0!==this.keys[t.innerId]}without(t){return void 0===this.keys[t.innerId]}sort(t){const{levels:e}=this;t?e.sort(((t,e)=>e-t)):e.sort(((t,e)=>t-e))}addList(t){t.forEach((t=>{this.add(t)}))}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach((i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])}))}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}const ga="1.5.1";class fa extends qt{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}ln(OffscreenCanvasRenderingContext2D.prototype),ln(Path2D.prototype);const{mineType:ya}=dn;function ma(i,s){t.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:ya(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:ya(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((i,s)=>{let n=new XMLHttpRequest;n.open("GET",t.image.getRealURL(e),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then((t=>{i(t)})).catch((t=>{s(t)}))},n.onerror=t=>s(t),n.send()}))},t.canvas=e.canvas(),t.conicGradientSupport=!!t.canvas.context.createConicGradient}Object.assign(e,{canvas:(t,e)=>new fa(t,e),image:t=>new bn(t)}),t.name="web",t.isWorker=!0,t.backgrounder=!0,t.requestRender=function(t){requestAnimationFrame(t)},kn(t,"devicePixelRatio",{get:()=>1});const{userAgent:va}=navigator;va.indexOf("Firefox")>-1?(t.conicGradientRotate90=!0,t.intWheelDeltaY=!0):va.indexOf("Safari")>-1&&-1===va.indexOf("Chrome")&&(t.fullImageShadow=!0),va.indexOf("Windows")>-1?(t.os="Windows",t.intWheelDeltaY=!0):va.indexOf("Mac")>-1?t.os="Mac":va.indexOf("Linux")>-1&&(t.os="Linux");class wa{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new _a;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new _a,this.target=t,e&&(this.config=At.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(Jo.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===jo.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new Ko(Ko.DATA,{updatedList:this.updatedList})),this.__updatedList=new _a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Uo.CHANGE,this.__onAttrChange,this),t.on_([jo.ADD,jo.REMOVE],this.__onChildEvent,this),t.on_(Ko.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:xa,updateBounds:ba,updateAllWorldOpacity:ka}=xo,{pushAllChildBranch:Ea,pushAllParent:Ba}=To;const{worldBounds:Ra}=Lo,Oa={x:0,y:0,width:1e5,height:1e5};class La{constructor(t){this.updatedBounds=new ht,this.beforeBounds=new ht,this.afterBounds=new ht,t instanceof Array&&(t=new _a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Ra)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Oa):this.afterBounds.setListWithFn(t,Ra),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:Ca,updateAllChange:Ta}=xo,Sa=vt.get("Layouter");class Pa{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new pa,this.target=t,e&&(this.config=At.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(qo.START),this.layoutOnce(),t.emitEvent(new qo(qo.END,this.layoutedBlocks,this.times))}catch(t){Sa.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Sa.warn("layouting"):this.times>3?Sa.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Ko.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=kt.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=qo,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new qo(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(xa(t,!0),e.add(t),t.isBranch&&Ea(t,e),Ba(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Ba(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||ba(s[t])}ba(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&ka(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new qo(o,a,this.times)),i.emitEvent(new qo(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,kt.end(e)}fullLayout(){const t=kt.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=qo,o=this.getBlocks(new _a(e));e.emitEvent(new qo(i,o,this.times)),Pa.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new qo(s,o,this.times)),e.emitEvent(new qo(n,o,this.times)),this.addBlocks(o),kt.end(t)}static fullLayout(t){Ca(t,!0),t.isBranch?To.updateBounds(t):xo.updateBounds(t),Ta(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new La([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new La(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(qo.REQUEST,this.layout,this),t.on_(qo.AGAIN,this.layoutAgain,this),t.on_(Ko.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Ma=vt.get("Renderer");class Aa{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=At.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(qo.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new ht,Ma.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(Jo.CHILD_START,e),this.emitRender(Jo.START),this.renderOnce(t),this.emitRender(Jo.END,this.totalBounds),mn.clearRecycled()}catch(t){this.rendering=!1,Ma.error(t)}Ma.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Ma.warn("rendering");if(this.times>3)return Ma.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new ht,this.renderOptions={},t)this.emitRender(Jo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Jo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Jo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Jo.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=kt.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new ht(s);i.save(),n&&!vt.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),kt.end(e)}fullRender(){const t=kt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),kt.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),vt.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),vt.showHitView&&this.renderHitView(s),vt.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new ht;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(Jo.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new ht(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new ht(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Ma.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new Jo(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Jo.REQUEST,this.update,this),t.on_(qo.END,this.__onLayoutEnd,this),t.on_(Jo.AGAIN,this.renderAgain,this),t.on_(Zo.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:Da}=nt;class Ia{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new _a(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new _a;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||xo.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new _a;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new _a;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new _a,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||Da(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Wa{constructor(t,i){this.config={},i&&(this.config=At.default(i,this.config)),this.picker=new Ia(this.target=t,this),this.finder=e.finder&&e.finder()}getByPoint(e,i,s){const{target:n,picker:o}=this;return t.backgrounder&&n&&n.updateLayout(),o.getByPoint(e,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):Rt.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Fa(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function za(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function Na(){return(t,e)=>{const i="_"+e;kn(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}Object.assign(e,{watcher:(t,e)=>new wa(t,e),layouter:(t,e)=>new Pa(t,e),renderer:(t,e,i)=>new Aa(t,e,i),selector:(t,e)=>new Wa(t,e)}),t.layout=Pa.fullLayout;const Ya={},Ha={},Xa={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},Va={},ja={},Ua={},Ga={},Za={},Ka={apply(){Rt.need("filter")}},qa={},Ja={setStyleName:()=>Rt.need("state"),set:()=>Rt.need("state")},$a={list:{},register(t,e){$a.list[t]=e},get:t=>$a.list[t]},{parse:Qa,objectToCanvasData:th}=mi,eh={},ih=vt.get("UIData");class sh extends It{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,ih.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,ih.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=eh)):(this.__isFills&&(this.__removeInput("fill"),Ua.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=eh)):(this.__isStrokes&&(this.__removeInput("stroke"),Ua.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Qa(t):th(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){nh(this,"shadow",t)}setInnerShadow(t){nh(this,"innerShadow",t)}setFilter(t){nh(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ja.compute("fill",this.__leaf),e&&ja.compute("stroke",this.__leaf),this.__needComputePaint=!1}}function nh(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=null)):i=i&&!1!==i.visible?[i]:null,t["_"+e]=i}class oh extends sh{}class rh extends oh{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class ah extends oh{__getInputData(t,e){const i=super.__getInputData(t,e);return Kt.forEach((t=>delete i[t])),i}}class hh extends rh{}class lh extends sh{}class dh extends sh{get __boxStroke(){return!this.__pathInputed}}class ch extends sh{get __boxStroke(){return!this.__pathInputed}}class uh extends sh{}class _h extends sh{}class ph extends sh{get __pathInputed(){return 2}}class gh extends oh{}const fh={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class yh extends sh{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=fh[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class mh extends dh{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class vh extends dh{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const wh={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:n}=i;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),o&&(t+=Ka.getSpread(o));let r=t=Math.ceil(t);return i&&i.forEach((t=>r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),n&&(r=Math.max(r,n)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},xh={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:o}=this.__;t.__useEffect=!!(e||i||s||n||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){bh(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:o,__drawAfterFill:r}=s;if(this.__drawRenderPath(t),s.__useEffect){const a=ja.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:l,filter:d}=s;h&&Za.shadow(this,t,a),n&&(s.__isFills?ja.fills(n,this,t):ja.fill(n,this,t)),r&&this.__drawAfterFill(t,e),l&&Za.innerShadow(this,t,a),o&&(s.__isStrokes?ja.strokes(o,this,t):ja.stroke(o,this,t)),d&&Ka.apply(d,this,this.__nowWorld,t,i,a),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else n&&(s.__isFills?ja.fills(n,this,t):ja.fill(n,this,t)),r&&this.__drawAfterFill(t,e),o&&(s.__isStrokes?ja.strokes(o,this,t):ja.stroke(o,this,t))}else s.__pathInputed?bh(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:n,stroke:o}=this.__;this.__drawRenderPath(t),n&&!i&&(this.__.__pixelFill?ja.fills(n,this,t):ja.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),o&&!s&&(this.__.__pixelStroke?ja.strokes(o,this,t):ja.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function bh(t,e,i){const{fill:s,stroke:n,__drawAfterFill:o}=t.__;t.__drawRenderPath(e),s&&ja.fill(s,t,e),o&&t.__drawAfterFill(e,i),n&&ja.stroke(n,t,e)}const kh={__drawFast(t,e){let{width:i,height:s,fill:n,stroke:o,__drawAfterFill:r}=this.__;if(n&&(t.fillStyle=n,t.fillRect(0,0,i,s)),r&&this.__drawAfterFill(t,e),o){const{strokeAlign:n,__strokeWidth:r}=this.__;if(!r)return;t.setStroke(o,r,this.__);const a=r/2;switch(n){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=r,s-=r,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(a,a,i,s),t.restore()):t.strokeRect(a,a,i,s);break;case"outside":t.strokeRect(-a,-a,i+r,s+r)}}}};var Eh;let Bh=Eh=class extends ia{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){a.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return an.set(this.path=t||[]),t||this.__drawPathByBox(an),an}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return Rt.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return Rt.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(an.set(i=[]),this.__drawPathByBox(an)),t?mi.toCanvasData(i,!0):i}getPathString(t,e,i){return mi.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||qa.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?rn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Va.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?vs.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:n}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:o}=this.__;t.roundRect(e,i,s,n,"number"==typeof o?[o]:o)}else t.rect(e,i,s,n)}animate(t,e,i,s){return Rt.need("animate")}killAnimate(t,e){}export(t,e){return Rt.need("export")}syncExport(t,e){return Rt.need("export")}clone(t){const e=At.clone(this.toJSON());return t&&Object.assign(e,t),Eh.one(e)}static one(t,e,i,s,n){return Lt.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){ho()(this)}static registerData(t){$n(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};Nt([$n(sh)],Bh.prototype,"__",void 0),Nt([Na()],Bh.prototype,"zoomLayer",void 0),Nt([Ln("")],Bh.prototype,"id",void 0),Nt([Ln("")],Bh.prototype,"name",void 0),Nt([Ln("")],Bh.prototype,"className",void 0),Nt([Hn("pass-through")],Bh.prototype,"blendMode",void 0),Nt([Xn(1)],Bh.prototype,"opacity",void 0),Nt([Vn(!0)],Bh.prototype,"visible",void 0),Nt([Hn(!1)],Bh.prototype,"locked",void 0),Nt([Gn(0)],Bh.prototype,"zIndex",void 0),Nt([Zn(!1)],Bh.prototype,"mask",void 0),Nt([Kn(!1)],Bh.prototype,"eraser",void 0),Nt([Cn(0,!0)],Bh.prototype,"x",void 0),Nt([Cn(0,!0)],Bh.prototype,"y",void 0),Nt([Mn(100,!0)],Bh.prototype,"width",void 0),Nt([Mn(100,!0)],Bh.prototype,"height",void 0),Nt([Sn(1,!0)],Bh.prototype,"scaleX",void 0),Nt([Sn(1,!0)],Bh.prototype,"scaleY",void 0),Nt([Pn(0,!0)],Bh.prototype,"rotation",void 0),Nt([Pn(0,!0)],Bh.prototype,"skewX",void 0),Nt([Pn(0,!0)],Bh.prototype,"skewY",void 0),Nt([Cn(0,!0)],Bh.prototype,"offsetX",void 0),Nt([Cn(0,!0)],Bh.prototype,"offsetY",void 0),Nt([Cn(0,!0)],Bh.prototype,"scrollX",void 0),Nt([Cn(0,!0)],Bh.prototype,"scrollY",void 0),Nt([Tn()],Bh.prototype,"origin",void 0),Nt([Tn()],Bh.prototype,"around",void 0),Nt([Ln(!1)],Bh.prototype,"lazy",void 0),Nt([An(1)],Bh.prototype,"pixelRatio",void 0),Nt([In()],Bh.prototype,"path",void 0),Nt([Wn()],Bh.prototype,"windingRule",void 0),Nt([Wn(!0)],Bh.prototype,"closed",void 0),Nt([Mn(0)],Bh.prototype,"padding",void 0),Nt([Mn(!1)],Bh.prototype,"lockRatio",void 0),Nt([Mn()],Bh.prototype,"widthRange",void 0),Nt([Mn()],Bh.prototype,"heightRange",void 0),Nt([Ln(!1)],Bh.prototype,"draggable",void 0),Nt([Ln()],Bh.prototype,"dragBounds",void 0),Nt([Ln(!1)],Bh.prototype,"editable",void 0),Nt([qn(!0)],Bh.prototype,"hittable",void 0),Nt([qn("path")],Bh.prototype,"hitFill",void 0),Nt([Nn("path")],Bh.prototype,"hitStroke",void 0),Nt([qn(!1)],Bh.prototype,"hitBox",void 0),Nt([qn(!0)],Bh.prototype,"hitChildren",void 0),Nt([qn(!0)],Bh.prototype,"hitSelf",void 0),Nt([qn()],Bh.prototype,"hitRadius",void 0),Nt([Jn("")],Bh.prototype,"cursor",void 0),Nt([Hn()],Bh.prototype,"fill",void 0),Nt([Nn()],Bh.prototype,"stroke",void 0),Nt([Nn("inside")],Bh.prototype,"strokeAlign",void 0),Nt([Nn(1)],Bh.prototype,"strokeWidth",void 0),Nt([Nn(!1)],Bh.prototype,"strokeWidthFixed",void 0),Nt([Nn("none")],Bh.prototype,"strokeCap",void 0),Nt([Nn("miter")],Bh.prototype,"strokeJoin",void 0),Nt([Nn()],Bh.prototype,"dashPattern",void 0),Nt([Nn()],Bh.prototype,"dashOffset",void 0),Nt([Nn(10)],Bh.prototype,"miterLimit",void 0),Nt([Wn(0)],Bh.prototype,"cornerRadius",void 0),Nt([Wn()],Bh.prototype,"cornerSmoothing",void 0),Nt([Fa()],Bh.prototype,"shadow",void 0),Nt([Fa()],Bh.prototype,"innerShadow",void 0),Nt([Fa()],Bh.prototype,"blur",void 0),Nt([Fa()],Bh.prototype,"backgroundBlur",void 0),Nt([Fa()],Bh.prototype,"grayscale",void 0),Nt([Fa()],Bh.prototype,"filter",void 0),Nt([Ln({})],Bh.prototype,"data",void 0),Nt([no(ia.prototype.reset)],Bh.prototype,"reset",null),Bh=Eh=Nt([ao(wh),ao(xh),oo()],Bh);let Rh=class extends Bh{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Oh;Nt([$n(oh)],Rh.prototype,"__",void 0),Rh=Nt([ao(ua),ho()],Rh);const Lh=vt.get("Leafer");let Ch=Oh=class extends Rh{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&fn.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Oh.list.add(this)}init(t,i){if(this.canvas)return;let s;const{config:n}=this;this.__setLeafer(this),i&&(this.parentApp=i,this.__bindApp(i),s=i.running),t&&(this.parent=i,this.initType(t.type),this.parent=void 0,At.assign(n,t));const o=this.canvas=e.canvas(n);this.__controllers.push(this.renderer=e.renderer(this,o,n),this.watcher=e.watcher(this,n),this.layouter=e.layouter(this,n)),this.isApp&&this.__setApp(),this.__checkAutoLayout(n,i),this.view=o.view,i||(this.selector=e.selector(this),this.interaction=e.interaction(this,o,this.selector,n),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=e.hitCanvasManager()),this.canvasManager=new Mt,s=n.start),this.hittable=n.hittable,this.fill=n.fill,this.canvasManager.add(o),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),Ao.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer($o.RESTART):this.emitLeafer($o.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer($o.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=At.copyAttrs({},t,Kt);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new ht(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=At.copyAttrs({},this.canvas,Kt);e.resize(t),this.updateLazyBounds(),this.__onResize(new Zo(t,i))}__onResize(t){this.emitEvent(t),At.copyAttrs(this.__,t,Kt),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new dt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Kt.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Kt.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=At.copyAttrs({},this.canvas,Kt);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer($o.BEFORE_READY),this.emitLeafer($o.READY),this.emitLeafer($o.AFTER_READY),Ao.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer($o.VIEW_READY),Ao.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:o}=this;const r="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,r.x+r.width)),i||(n=Math.max(1,r.y+r.height)),this.__doResize({width:s,height:n,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Ao.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer($o.VIEW_COMPLETED),Ao.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return Rt.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new $o(t,this))}__listenEvents(){const t=kt.start("FirstCreate "+this.innerName);this.once($o.START,(()=>kt.end(t))),this.once(qo.START,(()=>this.updateLazyBounds())),this.once(Jo.START,(()=>this.__onCreated())),this.once(Jo.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(Ko.DATA,this.__onWatchData,this),this.on_(qo.END,this.__onLayoutEnd,this),this.on_(Jo.NEXT,this.__onNextRender,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){Oh.list.remove(this);try{this.stop(),this.emitEvent(new $o($o.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{mn.clearRecycled()}),100)}catch(t){Lh.error(t)}}};t?e():setTimeout(e)}};Ch.list=new _a,Nt([$n(ah)],Ch.prototype,"__",void 0),Nt([Mn()],Ch.prototype,"pixelRatio",void 0),Ch=Oh=Nt([ho()],Ch);let Th=class extends Bh{get __tag(){return"Rect"}constructor(t){super(t)}};Nt([$n(dh)],Th.prototype,"__",void 0),Th=Nt([ao(kh),oo(),ho()],Th);const{copy:Sh,add:Ph,includes:Mh}=nt,Ah=Th.prototype,Dh=Rh.prototype,Ih={};let Wh=class extends Rh{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),Sh(Ih,e),this.__updateRectRenderBounds(),t=!Mh(e,Ih),t&&"hide"!==this.__.overflow&&Ph(e,Ih)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};Nt([$n(rh)],Wh.prototype,"__",void 0),Nt([Ln(!1)],Wh.prototype,"resizeChildren",void 0),Nt([Yn("show")],Wh.prototype,"overflow",void 0),Nt([no(Ah.__updateStrokeSpread)],Wh.prototype,"__updateStrokeSpread",null),Nt([no(Ah.__updateRenderSpread)],Wh.prototype,"__updateRectRenderSpread",null),Nt([no(Ah.__updateBoxBounds)],Wh.prototype,"__updateRectBoxBounds",null),Nt([no(Ah.__updateStrokeBounds)],Wh.prototype,"__updateStrokeBounds",null),Nt([no(Ah.__updateRenderBounds)],Wh.prototype,"__updateRectRenderBounds",null),Nt([no(Ah.__updateChange)],Wh.prototype,"__updateRectChange",null),Nt([no(Ah.__render)],Wh.prototype,"__renderRect",null),Nt([no(Dh.__render)],Wh.prototype,"__renderGroup",null),Wh=Nt([oo(),ho()],Wh);let Fh=class extends Wh{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};Nt([$n(hh)],Fh.prototype,"__",void 0),Nt([Hn("#FFFFFF")],Fh.prototype,"fill",void 0),Nt([Yn("hide")],Fh.prototype,"overflow",void 0),Fh=Nt([ho()],Fh);const{moveTo:zh,closePath:Nh,ellipse:Yh}=Yi;let Hh=class extends Bh{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:i,innerRadius:s,startAngle:n,endAngle:o}=this.__,r=e/2,a=i/2,h=this.__.path=[];s?(n||o?(s<1&&Yh(h,r,a,r*s,a*s,0,n,o,!1),Yh(h,r,a,r,a,0,o,n,!0),s<1&&Nh(h)):(s<1&&(Yh(h,r,a,r*s,a*s),zh(h,e,a)),Yh(h,r,a,r,a,0,360,0,!0)),t.ellipseToCurve&&(this.__.path=this.getPath(!0))):n||o?(zh(h,r,a),Yh(h,r,a,r,a,0,n,o,!1),Nh(h)):Yh(h,r,a,r,a)}};Nt([$n(ch)],Hh.prototype,"__",void 0),Nt([Wn(0)],Hh.prototype,"innerRadius",void 0),Nt([Wn(0)],Hh.prototype,"startAngle",void 0),Nt([Wn(0)],Hh.prototype,"endAngle",void 0),Hh=Nt([ho()],Hh);const{moveTo:Xh,lineTo:Vh,drawPoints:jh}=Yi,{rotate:Uh,getAngle:Gh,getDistance:Zh,defaultPoint:Kh}=P,{toBounds:qh}=Js;let Jh=class extends Bh{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&Uh(i,e),i}set toPoint(t){this.width=Zh(Kh,t),this.rotation=Gh(Kh,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?jh(e,t.points,!1,t.closed):(Xh(e,0,0),Vh(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(jh(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&Va.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?qh(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};Nt([$n(lh)],Jh.prototype,"__",void 0),Nt([Fn("center")],Jh.prototype,"strokeAlign",void 0),Nt([Mn(0)],Jh.prototype,"height",void 0),Nt([Wn()],Jh.prototype,"points",void 0),Nt([Wn(0)],Jh.prototype,"curve",void 0),Nt([Wn(!1)],Jh.prototype,"closed",void 0),Jh=Nt([ho()],Jh);const{sin:$h,cos:Qh,PI:tl}=Math,{moveTo:el,lineTo:il,closePath:sl,drawPoints:nl}=Yi,ol=Jh.prototype;let rl=class extends Bh{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)nl(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,n=e/2,o=i/2;el(t,n,0);for(let e=1;e<s;e++)il(t,n+n*$h(2*e*tl/s),o-o*Qh(2*e*tl/s))}sl(t)}__updateRenderPath(){}__updateBoxBounds(){}};Nt([$n(uh)],rl.prototype,"__",void 0),Nt([Wn(3)],rl.prototype,"sides",void 0),Nt([Wn()],rl.prototype,"points",void 0),Nt([Wn(0)],rl.prototype,"curve",void 0),Nt([no(ol.__updateRenderPath)],rl.prototype,"__updateRenderPath",null),Nt([no(ol.__updateBoxBounds)],rl.prototype,"__updateBoxBounds",null),rl=Nt([oo(),ho()],rl);const{sin:al,cos:hl,PI:ll}=Math,{moveTo:dl,lineTo:cl,closePath:ul}=Yi;let _l=class extends Bh{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,o=e/2,r=this.__.path=[];dl(r,n,0);for(let t=1;t<2*i;t++)cl(r,n+(t%2==0?n:n*s)*al(t*ll/i),o-(t%2==0?o:o*s)*hl(t*ll/i));ul(r)}};Nt([$n(_h)],_l.prototype,"__",void 0),Nt([Wn(5)],_l.prototype,"corners",void 0),Nt([Wn(.382)],_l.prototype,"innerRadius",void 0),_l=Nt([ho()],_l);let pl=class extends Th{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(Go.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};Nt([$n(mh)],pl.prototype,"__",void 0),Nt([Mn("")],pl.prototype,"url",void 0),pl=Nt([ho()],pl);const gl=pl;let fl=class extends Th{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=e.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new bn({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Go(Go.LOADED,{image:t}))}))}draw(t,e,i,s){const n=new z(t.worldTransform).invert(),o=new z;e&&o.translate(e.x,e.y),i&&("number"==typeof i?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),n.multiplyParent(o),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};Nt([$n(vh)],fl.prototype,"__",void 0),Nt([za(100)],fl.prototype,"width",void 0),Nt([za(100)],fl.prototype,"height",void 0),Nt([za(1)],fl.prototype,"pixelRatio",void 0),Nt([za(!0)],fl.prototype,"smooth",void 0),Nt([Ln(!1)],fl.prototype,"safeResize",void 0),Nt([za()],fl.prototype,"contextSettings",void 0),fl=Nt([ho()],fl);const{copyAndSpread:yl,includes:ml,isSame:vl,spread:wl,setList:xl}=nt;let bl=class extends Bh{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:n}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):n.rows.forEach((n=>t.rect(n.x,n.y-s,n.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;t.rect(i,s,n,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:o,italic:r,textCase:h,textOverflow:l,padding:d}=t;t.__lineHeight=Xa.number(e,n),t.__letterSpacing=Xa.number(i,n),t.__padding=d?a.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${r?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==o?o+" ":""}${n}px ${s}`,t.__clipText="show"!==l&&!t.__autoSize,t.__textDrawData=Ya.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:o,__autoHeight:r}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(t.__lineHeight<i&&wl(a,i/2),o||r){if(h.x=o?a.x:0,h.y=r?a.y:0,h.width=o?a.width:t.width,h.height=r?a.height:t.height,n){const[e,i,s,n]=t.__padding;o&&(h.x-=n,h.width+=i+n),r&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i);const l=ml(h,a)?h:a;vl(l,e.contentBounds)?t.__textBoxBounds=l:(e.contentBounds=l,e.renderChanged=!0,xl(t.__textBoxBounds={},[h,a]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){yl(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};Nt([$n(yh)],bl.prototype,"__",void 0),Nt([Mn(0)],bl.prototype,"width",void 0),Nt([Mn(0)],bl.prototype,"height",void 0),Nt([Ln(!1)],bl.prototype,"resizeFontSize",void 0),Nt([Hn("#000000")],bl.prototype,"fill",void 0),Nt([Fn("outside")],bl.prototype,"strokeAlign",void 0),Nt([qn("all")],bl.prototype,"hitFill",void 0),Nt([Mn("")],bl.prototype,"text",void 0),Nt([Mn("caption")],bl.prototype,"fontFamily",void 0),Nt([Mn(12)],bl.prototype,"fontSize",void 0),Nt([Mn("normal")],bl.prototype,"fontWeight",void 0),Nt([Mn(!1)],bl.prototype,"italic",void 0),Nt([Mn("none")],bl.prototype,"textCase",void 0),Nt([Mn("none")],bl.prototype,"textDecoration",void 0),Nt([Mn(0)],bl.prototype,"letterSpacing",void 0),Nt([Mn({type:"percent",value:1.5})],bl.prototype,"lineHeight",void 0),Nt([Mn(0)],bl.prototype,"paraIndent",void 0),Nt([Mn(0)],bl.prototype,"paraSpacing",void 0),Nt([Mn("x")],bl.prototype,"writingMode",void 0),Nt([Mn("left")],bl.prototype,"textAlign",void 0),Nt([Mn("top")],bl.prototype,"verticalAlign",void 0),Nt([Mn(!0)],bl.prototype,"autoSizeAlign",void 0),Nt([Mn("normal")],bl.prototype,"textWrap",void 0),Nt([Mn("show")],bl.prototype,"textOverflow",void 0),bl=Nt([ho()],bl);let kl=class extends Bh{get __tag(){return"Path"}constructor(t){super(t)}};Nt([$n(ph)],kl.prototype,"__",void 0),Nt([Fn("center")],kl.prototype,"strokeAlign",void 0),kl=Nt([ho()],kl);let El=class extends Rh{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new kl(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,o){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,n){return this}ellipse(t,e,i,s,n,o,r,a){return this}arc(t,e,i,s,n,o){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,o,r,a){return this}drawArc(t,e,i,s,n,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};Nt([$n(gh)],El.prototype,"__",void 0),Nt([(t,e)=>{kn(t,e,{get(){return this.__path}})}],El.prototype,"path",void 0),El=Nt([ao(ns,["set","path","paint"]),ho()],El);let Bl=class extends Ch{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,i){if(super.init(t,i),t){const{ground:i,tree:s,sky:n,editor:o}=t;i&&(this.ground=this.addLeafer(i)),(s||o)&&(this.tree=this.addLeafer(s||{type:t.type||"design"})),(n||o)&&(this.sky=this.addLeafer(n)),o&&this.sky.add(this.editor=e.editor(o))}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:i}=this.config;e||i===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(Uo.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}forceRender(t,e){this.children.forEach((i=>i.forceRender(t,e)))}addLeafer(t){const e=new Ch(t);return this.add(e),e}add(t,e){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t,e)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t,e),void 0!==e&&(t.canvas.childIndex=e),this.__listenChildEvents(t)}__onPropertyChange(){vt.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){if(t.context){const i=e.matrix;i&&t.setTransform(i.a,i.b,i.c,i.d,i.e,i.f),this.children.forEach((e=>t.copyWorld(e.canvas)))}}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}updateLayout(){this.children.forEach((t=>t.updateLayout()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&At.assign(e,t),this.autoLayout&&At.copyAttrs(e,this,Kt),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(qo.END,(()=>this.__onReady())),t.once(Jo.START,(()=>this.__onCreated())),t.once(Jo.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(t.on_(Jo.END,this.__onChildRenderEnd,this))}};Bl=Nt([ho()],Bl);const Rl={},Ol={isHoldSpaceKey:()=>Ol.isHold("Space"),isHold:t=>Rl[t],setDownCode(t){Rl[t]||(Rl[t]=!0)},setUpCode(t){Rl[t]=!1}},Ll={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Cl extends Vo{get spaceKey(){return Ol.isHoldSpaceKey()}get left(){return Ll.left(this)}get right(){return Ll.right(this)}get middle(){return Ll.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}getBoxPoint(t){return(t||this.current).getBoxPoint(this)}getInnerPoint(t){return(t||this.current).getInnerPoint(this)}getLocalPoint(t){return(t||this.current).getLocalPoint(this)}getPagePoint(){return this.current.getPagePoint(this)}getInner(t){return this.getInnerPoint(t)}getLocal(t){return this.getLocalPoint(t)}getPage(){return this.getPagePoint()}static changeName(t,e){St.changeName(t,e)}}let Tl=class extends Cl{};Tl.POINTER="pointer",Tl.BEFORE_DOWN="pointer.before_down",Tl.BEFORE_MOVE="pointer.before_move",Tl.BEFORE_UP="pointer.before_up",Tl.DOWN="pointer.down",Tl.MOVE="pointer.move",Tl.UP="pointer.up",Tl.OVER="pointer.over",Tl.OUT="pointer.out",Tl.ENTER="pointer.enter",Tl.LEAVE="pointer.leave",Tl.TAP="tap",Tl.DOUBLE_TAP="double_tap",Tl.CLICK="click",Tl.DOUBLE_CLICK="double_click",Tl.LONG_PRESS="long_press",Tl.LONG_TAP="long_tap",Tl.MENU="pointer.menu",Tl.MENU_TAP="pointer.menu_tap",Tl=Nt([lo()],Tl);const Sl=Tl,Pl={};let Ml=class extends Tl{static setList(t){this.list=t instanceof _a?t:new _a(t)}static setData(t){this.data=t}static getValidMove(t,e,i){const{draggable:s,dragBounds:n}=t,o=t.getLocalPoint(i,null,!0);return P.move(o,e.x-t.x,e.y-t.y),n&&this.getMoveInDragBounds(t.__localBoxBounds,"parent"===n?t.parent.boxBounds:n,o,!0),"x"===s&&(o.y=0),"y"===s&&(o.x=0),o}static getMoveInDragBounds(t,e,i,s){const n=t.x+i.x,o=t.y+i.y,r=n+t.width,a=o+t.height,h=e.x+e.width,l=e.y+e.height;return s||(i=Object.assign({},i)),nt.includes(t,e)?(n>e.x?i.x+=e.x-n:r<h&&(i.x+=h-r),o>e.y?i.y+=e.y-o:a<l&&(i.y+=l-a)):(n<e.x?i.x+=e.x-n:r>h&&(i.x+=h-r),o<e.y?i.y+=e.y-o:a>l&&(i.y+=l-a)),i}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Pl,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Pl,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Pl,null,!0)}getPageTotal(){return this.getPageMove(!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}getPageBounds(){const t=this.getPageTotal(),e=this.getPagePoint(),i={};return nt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),nt.unsign(i),i}assignMove(t){Pl.x=t?this.totalX:this.moveX,Pl.y=t?this.totalY:this.moveY}};Ml.BEFORE_DRAG="drag.before_drag",Ml.START="drag.start",Ml.DRAG="drag",Ml.END="drag.end",Ml.OVER="drag.over",Ml.OUT="drag.out",Ml.ENTER="drag.enter",Ml.LEAVE="drag.leave",Ml=Nt([lo()],Ml);const Al=Ml;let Dl=class extends Tl{static setList(t){Ml.setList(t)}static setData(t){Ml.setData(t)}};Dl.DROP="drop",Dl=Nt([lo()],Dl);let Il=class extends Ml{};Il.BEFORE_MOVE="move.before_move",Il.START="move.start",Il.MOVE="move",Il.END="move.end",Il=Nt([lo()],Il);let Wl=class extends Cl{};Wl.BEFORE_ROTATE="rotate.before_rotate",Wl.START="rotate.start",Wl.ROTATE="rotate",Wl.END="rotate.end",Wl=Nt([lo()],Wl);let Fl=class extends Ml{};Fl.SWIPE="swipe",Fl.LEFT="swipe.left",Fl.RIGHT="swipe.right",Fl.UP="swipe.up",Fl.DOWN="swipe.down",Fl=Nt([lo()],Fl);let zl=class extends Cl{};zl.BEFORE_ZOOM="zoom.before_zoom",zl.START="zoom.start",zl.ZOOM="zoom",zl.END="zoom.end",zl=Nt([lo()],zl);let Nl=class extends Cl{};Nl.DOWN="key.down",Nl.HOLD="key.hold",Nl.UP="key.up",Nl=Nt([lo()],Nl);const Yl={getDragEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:i.x,y:i.y,moveX:i.x-e.x,moveY:i.y-e.y,totalX:i.x-t.x,totalY:i.y-t.y}),getDropEventData:(t,e,i)=>Object.assign(Object.assign({},t),{list:e,data:i}),getSwipeDirection:t=>t<-45&&t>-135?Fl.UP:t>45&&t<135?Fl.DOWN:t<=45&&t>=-45?Fl.RIGHT:Fl.LEFT,getSwipeEventData:(t,e,i)=>Object.assign(Object.assign({},i),{moveX:e.moveX,moveY:e.moveY,totalX:i.x-t.x,totalY:i.y-t.y,type:Hl.getSwipeDirection(P.getAngle(t,i))}),getBase(t){const e=1===t.button?4:t.button;return{altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:void 0===t.buttons?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let t=0,s=i.length;t<s;t++)if(i[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new _a,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:t=>t&&t.list.some((t=>t.draggable||t.editable||!t.isLeafer&&t.hasEvent(Ml.DRAG))),pathHasOutside:t=>t&&t.list.some((t=>t.isOutside))},Hl=Yl,Xl=new _a,{getDragEventData:Vl,getDropEventData:jl,getSwipeEventData:Ul}=Yl;class Gl{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Vl(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,n=Ml.list||this.draggableList||Xl;return this.dragging&&(s?t?Xl:new _a(e?[...i.list,...i.dragHoverExclude]:i.list):n)}checkDrag(t,e){const{interaction:i}=this;if(this.moving&&t.buttons<1)return this.canAnimate=!1,void i.pointerCancel();!this.moving&&e&&(this.moving=i.canMove(this.downData)||i.isHoldRightKey||i.isMobileDragEmpty)&&(this.dragData.moveType="drag",i.emit(Il.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&Ll.left(t),this.dragging&&(this.interaction.emit(Ml.START,this.dragData),this.getDraggableList(this.dragData.path),this.setDragStartPoints(this.realDraggableList=this.getList(!0))))}setDragStartPoints(t){this.dragStartPoints={},t.forEach((t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y}))}getDraggableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],(e.draggable||e.editable)&&e.hitSelf&&!e.locked){this.draggableList=new _a(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:n,throughPath:o}=s;this.dragData=Vl(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=n,this.moving?(this.dragData.moveType="drag",e.emit(Il.BEFORE_MOVE,this.dragData),e.emit(Il.MOVE,this.dragData)):this.dragging&&(this.dragReal(),e.emit(Ml.BEFORE_DRAG,this.dragData),e.emit(Ml.DRAG,this.dragData))}dragReal(){const{running:t}=this.interaction,e=this.realDraggableList;if(e.length&&t){const{totalX:t,totalY:i}=this.dragData;e.forEach((e=>e.draggable&&e.move(Ml.getValidMove(e,this.dragStartPoints[e.innerId],{x:t,y:i}))))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(Ml.OUT,t,i),e.emit(Ml.OVER,t,s)):e.emit(Ml.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(Ml.LEAVE,t,i,s),e.emit(Ml.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:n,throughPath:o}=i,r=Vl(i,t,t);if(o&&(r.throughPath=o),r.path=n,this.moving&&(this.moving=!1,r.moveType="drag",e.emit(Il.END,r)),this.dragging){const n=this.getList();this.dragging=!1,e.emit(Ml.END,r),this.swipe(t,i,s,r),this.drop(t,n,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(P.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Ul(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=jl(t,e,Ml.data);s.path=i,this.interaction.emit(Dl.DROP,s),this.interaction.emit(Ml.LEAVE,t,i)}dragReset(){Ml.list=Ml.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null}checkDragEndAnimate(t,e){return!1}animate(t,e){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const Zl=vt.get("emit");const Kl=["move","zoom","rotate","key"];function ql(t,e,i,s,n){if(Kl.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!$l(t,n)){let o;for(let r=0,a=t.children.length;r<a;r++)o=t.children[r],!i.path.has(o)&&o.__.hittable&&Jl(o,e,i,s,n)}}function Jl(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!$l(t,n)&&(Ja.updateEventStyle&&!s&&Ja.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=St.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function $l(t,e){return e&&e.has(t)}const Ql={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20},touch:{preventDefault:"auto"},multiTouch:{},move:{autoDistance:2},zoom:{},cursor:!0,keyEvent:!0},{pathHasEventType:td,pathCanDrag:ed,pathHasOutside:id}=Yl;class sd{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return!0===this.m.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.p.hover&&!this.config.mobile}get isDragEmpty(){return this.m.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.m.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.m.holdMiddleKey&&this.downData&&Ll.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&Ll.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&Ol.isHoldSpaceKey()}get m(){return this.config.move}get p(){return this.config.pointer}get hitRadius(){return this.p.hitRadius}constructor(t,e,i,s){this.config=At.clone(Ql),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new _a(t),this.createTransformer(),this.dragger=new Gl(this),s&&(this.config=At.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Ll.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(Tl.BEFORE_DOWN,t),this.emit(Tl.DOWN,t),Ll.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=Ll.right(t),this.dragger.setDragData(t),this.isHoldRightKey||this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&Ll.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(Tl.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=P.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.waitTap&&this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(Tl.MOVE,t),this.pointerHover(t),this.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t))),this.updateCursor(this.downData||t)}pointerUp(t){const{downData:e}=this;if(t||(t=e),!e)return;Ll.defaultLeft(t),t.multiTouch=e.multiTouch,this.findPath(t);const i=Object.assign(Object.assign({},t),{path:t.path.clone()});t.path.addList(e.path.list),this.checkPath(t),this.downData=null,this.emit(Tl.BEFORE_UP,t),this.emit(Tl.UP,t),this.touchLeave(t),t.isCancel||(this.tap(t),this.menuTap(t)),this.dragger.dragEnd(t),this.updateCursor(i)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(t){this.findPath(t),this.emit(Tl.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(Tl.MENU_TAP,t),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Ol.setDownCode(e),this.emit(Nl.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(Nl.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]=!1,Ol.setUpCode(e),this.emit(Nl.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new _a),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(t){const{path:e}=t,{overPath:i}=this;this.overPath=e,i?e.indexAt(0)!==i.indexAt(0)&&(this.emit(Tl.OUT,t,i),this.emit(Tl.OVER,t,e)):this.emit(Tl.OVER,t,e)}pointerEnterOrLeave(t){let{path:e}=t;this.downData&&!this.moveMode&&(e=e.clone(),this.downData.path.forEach((t=>e.add(t))));const{enterPath:i}=this;this.enterPath=e,this.emit(Tl.LEAVE,t,i,e),this.emit(Tl.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(Tl.LEAVE,t),this.dragger.dragging&&this.emit(Dl.LEAVE,t))}tap(t){const{pointer:e}=this.config,i=this.longTap(t);if(!e.tapMore&&i)return;if(!this.waitTap)return;e.tapMore&&this.emitTap(t);const s=Date.now()-this.downTime,n=[Tl.DOUBLE_TAP,Tl.DOUBLE_CLICK].some((e=>td(t.path,e)));s<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout((()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(e,i){const{hitRadius:s,through:n}=this.p,{bottomList:o,target:r}=this;t.backgrounder||e.origin||r&&r.updateLayout();const a=this.selector.getByPoint(e,s,Object.assign({bottomList:o,name:e.type},i||{through:n}));return a.throughPath&&(e.throughPath=a.throughPath),e.path=a.path,a.path}isRootPath(t){return t&&t.path.list[0].isLeafer}isTreePath(t){const e=this.target.app;return!(!e||!e.isApp)&&(e.editor&&!t.path.has(e.editor)&&t.path.has(e.tree)&&!t.target.syncEventer)}checkPath(t,e){(e||this.moveMode&&!id(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!ed(t.path))&&!id(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getList(!1,!0),name:Tl.MOVE}),this.hoverData=t)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e);return{x:t.clientX-i.x,y:t.clientY-i.y}}emitTap(t){this.emit(Tl.TAP,t),this.emit(Tl.CLICK,t)}emitDoubleTap(t){this.emit(Tl.DOUBLE_TAP,t),this.emit(Tl.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout((()=>{this.longPressed=!0,this.emit(Tl.LONG_PRESS,t)}),this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(Tl.LONG_TAP,t),(td(t.path,Tl.LONG_TAP)||td(t.path,Tl.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new ht(this.canvas.bounds),this.shrinkCanvasBounds.spread(-("number"==typeof t?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Zo.RESIZE,this.__onResize,this)],t.once($o.READY,(()=>this.__onResize()))}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,i,s){this.running&&function(t,e,i,s){if(!i&&!e.path)return;let n;e.type=t,i?e=Object.assign(Object.assign({},e),{path:i}):i=e.path,e.target=i.indexAt(0);try{for(let o=i.length-1;o>-1;o--){if(n=i.list[o],Jl(n,t,e,!0,s))return;n.isApp&&ql(n,t,e,!0,s)}for(let o=0,r=i.length;o<r;o++)if(n=i.list[o],n.isApp&&ql(n,t,e,!1,s),Jl(n,t,e,!1,s))return}catch(t){Zl.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class nd{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}nd.custom={};class od extends Mt{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new _a,this.pixelList=new _a}getPixelType(t,i){return this.__autoClear(),this.pixelList.add(t),e.hitCanvas(i)}getPathType(t){return this.__autoClear(),this.pathList.add(t),e.hitCanvas()}clearImageType(){this.__clearLeafList(this.pixelList)}clearPathType(){this.__clearLeafList(this.pathList)}__clearLeafList(t){t.length&&(t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset())}__autoClear(){this.pathList.length+this.pixelList.length>this.maxTotal&&this.clear()}clear(){this.clearPathType(),this.clearImageType()}}const{toInnerRadiusPointOf:rd,copy:ad,setRadius:hd}=P,ld={},dd=ia.prototype;dd.__hitWorld=function(t){if(!this.__.hitSelf)return!1;this.__.hitRadius&&(ad(ld,t),hd(t=ld,this.__.hitRadius)),rd(t,this.__world,ld);const{width:e,height:i}=this.__world,s=e<10&&i<10;if(this.__.hitBox||s){if(nt.hitRadiusPoint(this.__layout.boxBounds,ld))return!0;if(s)return!1}return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.boundsChanged||(this.__layout.hitCanvasChanged=!1)),this.__hit(ld)},dd.__hitFill=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitFill(t,this.__.windingRule)},dd.__hitStroke=function(t,e){var i;return null===(i=this.__hitCanvas)||void 0===i?void 0:i.hitStroke(t,e)},dd.__hitPixel=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitPixel(t,this.__layout.renderBounds,this.__hitCanvas.hitScale)},dd.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const cd=new z,ud=Bh.prototype;ud.__updateHitCanvas=function(){const e=this.__,{hitCanvasManager:i}=this.leafer,s=(e.__pixelFill||e.__isCanvas)&&"pixel"===e.hitFill,n=e.__pixelStroke&&"pixel"===e.hitStroke,o=s||n;this.__hitCanvas||(this.__hitCanvas=o?i.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):i.getPathType(this));const r=this.__hitCanvas;if(o){const{renderBounds:i}=this.__layout,o=t.image.hitCanvasSize,a=r.hitScale=lt.set(0,0,o,o).getFitMatrix(i).a,{x:h,y:l,width:d,height:c}=lt.set(i).scale(a);r.resize({width:d,height:c,pixelRatio:1}),r.clear(),mn.patternLocked=!0,this.__renderShape(r,{matrix:cd.setWith(this.__world).scaleWith(1/a).invertWith().translate(-h,-l)},!s,!n),mn.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},ud.__hit=function(t){const e=this.__;if(e.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:i}=e,s=(e.fill||e.__isCanvas)&&("path"===i||"pixel"===i&&!(e.__pixelFill||e.__isCanvas))||"all"===i;if(s&&this.__hitFill(t))return!0;const{hitStroke:n,__strokeWidth:o}=e,r=e.stroke&&("path"===n||"pixel"===n&&!e.__pixelStroke)||"all"===n;if(!s&&!r)return!1;const a=2*t.radiusX;let h=a;if(r)switch(e.strokeAlign){case"inside":if(h+=2*o,!s&&this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a;break;case"center":h+=o;break;case"outside":if(h+=2*o,!s){if(!this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a}}return!!h&&this.__hitStroke(t,h)};const _d=Bh.prototype,pd=Th.prototype,gd=Wh.prototype;pd.__updateHitCanvas=gd.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?_d.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},pd.__hitFill=gd.__hitFill=function(t){return this.__hitCanvas?_d.__hitFill.call(this,t):nt.hitRadiusPoint(this.__layout.boxBounds,t)},Rh.prototype.pick=function(i,s){return s||(s=Ft),this.updateLayout(),function(i){return i.leafer?i.leafer.selector:t.selector||(t.selector=e.selector())}(this).getByPoint(i,s.hitRadius||0,Object.assign(Object.assign({},s),{target:this}))};const fd=qt.prototype;function yd(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function md(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?xd(t,!0,e,i):wd(e,i);break;case"inside":vd("inside",t,n,e,i);break;case"outside":vd("outside",t,n,e,i)}}function vd(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?xd(e,!0,s,a):wd(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",yd(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function wd(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function xd(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&Ua.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?wd(i,s):s.stroke(),s.restoreBlendMode()):e?wd(i,s):s.stroke())}function bd(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}fd.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},fd.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},fd.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:o,radiusY:r}=t;e&&(s-=e.x,n-=e.y),lt.set(s-o,n-r,2*o,2*r).scale(i).ceil();const{data:a}=this.context.getImageData(lt.x,lt.y,lt.width||1,lt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:kd,getOuterOf:Ed,getByMove:Bd,getIntersectData:Rd}=nt;let Od;function Ld(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:Ha.string(r,a)};case"image":return Ua.image(i,t,e,s,!Od||!Od[e.url]);case"linear":return Ga.linearGradient(e,s);case"radial":return Ga.radialGradient(e,s);case"angular":return Ga.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:Ha.string(e)}:void 0}}const Cd={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Od=Ua.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Ld(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?yd(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&Ua.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?yd(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?yd(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?yd(e,i):n?i.fill(n):i.fill())},fillText:yd,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)md(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&bd(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)md(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),xd(t,!1,e,i),s.__useArrow&&bd(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),xd(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),xd(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:md,drawTextStroke:wd,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:d}=n;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,c=Rd(s?kd(e.bounds,l===d?s*l:[s*d,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:_}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=_),a=Ed(n,r),o=Bd(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,_*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,_)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:d}}};let Td={};const{get:Sd,rotateOfOuter:Pd,translate:Md,scaleOfOuter:Ad,scale:Dd,rotate:Id}=x;function Wd(t,e,i,s,n,o,r){const a=Sd();Md(a,e.x+i,e.y+s),Dd(a,n,o),r&&Pd(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Fd(t,e,i,s,n,o,r){const a=Sd();Md(a,e.x+i,e.y+s),n&&Dd(a,n,o),r&&Id(a,r),t.transform=a}function zd(t,e,i,s,n,o,r,a,h,l){const d=Sd();if(h)if("center"===l)Pd(d,{x:i/2,y:s/2},h);else switch(Id(d,h),h){case 90:Md(d,s,0);break;case 180:Md(d,i,s);break;case 270:Md(d,0,i)}Td.x=e.x+n,Td.y=e.y+o,Md(d,Td.x,Td.y),r&&Ad(d,Td,r,a),t.transform=d}const{get:Nd,translate:Yd}=x,Hd=new ht,Xd={},Vd={};function jd(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=Ud(i,s,e)}function Ud(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Hd.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,repeat:_,filters:p}=t,g=e.width===s&&e.height===n,f={mode:r},y="center"!==h&&(u||0)%180==90,m=y?n:s,v=y?s:n;let w,x,b=0,k=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(a.getScaleData(d,c,i,Vd),w=Vd.scaleX,x=Vd.scaleY);else if(!g||u){const t=e.width/m,i=e.height/v;w=x="fit"===r?Math.min(t,i):Math.max(t,i),b+=(e.width-s*w)/2,k+=(e.height-n*x)/2}if(h){const t={x:b,y:k,width:m,height:v};w&&(t.width*=w,t.height*=x),yt.toPoint(h,t,e,Xd,!0),b+=Xd.x,k+=Xd.y}switch(l&&(b+=l.x,k+=l.y),r){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(b||k||w||u)&&Fd(f,e,b,k,w,x,u);break;case"repeat":(!g||w||u)&&zd(f,e,s,n,b,k,w,x,u,h),_||(f.repeat="repeat");break;default:w&&Wd(f,e,b,k,w,x,u)}return f.transform||(e.x||e.y)&&(f.transform=Nd(),Yd(f.transform,e.x,e.y)),w&&"stretch"!==r&&(f.scaleX=w,f.scaleY=x),f.width=s,f.height=n,o&&(f.opacity=o),p&&(f.filters=p),_&&(f.repeat="string"==typeof _?"x"===_?"repeat-x":"repeat-y":"repeat"),f}let Gd,Zd=new ht;const{isSame:Kd}=nt;function qd(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||jd(n,s,i,o),!0}function Jd(t,e){tc(t,Go.LOAD,e)}function $d(t,e){tc(t,Go.LOADED,e)}function Qd(t,e,i){e.error=i,t.forceUpdate("surface"),tc(t,Go.ERROR,e)}function tc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Go(e,i))}function ec(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ic,scale:sc,copy:nc}=x,{ceil:oc,abs:rc}=Math;function ac(e,i,s){let{scaleX:n,scaleY:o}=mn.patternLocked?e.__world:e.__nowWorld;const r=n+"-"+o+"-"+s;if(i.patternId===r||e.destroyed)return!1;{n=rc(n),o=rc(o);const{image:e,data:a}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:_,transform:p,repeat:g}=a;u&&(l=ic(),nc(l,p),sc(l,1/u,1/_),n*=u,o*=_),n*=s,o*=s,d*=n,c*=o;const f=d*c;if(!g&&f>t.image.maxCacheSize)return!1;let y=t.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}f>y&&(h=Math.sqrt(f/y)),h&&(n/=h,o/=h,d/=h,c/=h),u&&(n/=u,o/=_),(p||1!==n||1!==o)&&(l||(l=ic(),p&&nc(l,p)),sc(l,1/n,1/o));const m=e.getCanvas(oc(d)||1,oc(c)||1,a.opacity,a.filters),v=e.getPattern(m,g||t.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=r,!0}}const{abs:hc}=Math;const lc={image:function(t,e,i,s,n){let o,r;const a=mn.get(i);return Gd&&i===Gd.paint&&Kd(s,Gd.boxBounds)?o=Gd.leafPaint:(o={type:i.type,image:a},Gd=a.use>1?{leafPaint:o,paint:i,boxBounds:Zd.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(qd(t,e,i,a,o,s),n&&(Jd(t,r),$d(t,r))):a.error?n&&Qd(t,r,a.error):(n&&(ec(t,!0),Jd(t,r)),o.loadId=a.load((()=>{ec(t,!1),t.destroyed||(qd(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$d(t,r)),o.loadId=null}),(e=>{ec(t,!1),Qd(t,r,e),o.loadId=null}))),o},checkImage:function(e,i,s,n){const{scaleX:o,scaleY:r}=mn.patternLocked?e.__world:e.__nowWorld,{pixelRatio:a}=i;if(!s.data||s.patternId===o+"-"+r+"-"+a&&!qa.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:e,height:i}=h;e*=hc(o)*a,i*=hc(r)*a,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),n=e*i>t.image.maxCacheSize||qa.running}return n?(i.save(),e.windingRule?i.clip(e.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.getFull(h.filters),0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||qa.running?ac(e,s,a):s.patternTask||(s.patternTask=mn.patternTasker.add((()=>Yt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&ac(e,s,a),e.forceUpdate("surface")}))),300)),!1)}},createPattern:ac,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,mn.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null},createData:jd,getPatternData:Ud,fillOrFitMode:Wd,clipMode:Fd,repeatMode:zd},{toPoint:dc}=pt,cc={},uc={};function _c(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),Ha.string(s,i)):t.addColorStop(s.offset,Ha.string(s.color,i))}}const{getAngle:pc,getDistance:gc}=P,{get:fc,rotateOfOuter:yc,scaleOfOuter:mc}=x,{toPoint:vc}=pt,wc={},xc={};function bc(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=pc(e,i);o=fc(),n?(mc(o,e,r/a*(s||1),1),yc(o,e,t+90)):(mc(o,e,1,r/a*(s||1)),yc(o,e,t))}return o}const{getDistance:kc}=P,{toPoint:Ec}=pt,Bc={},Rc={};const Oc={linearGradient:function(e,i){let{from:s,to:n,type:o,blendMode:r,opacity:a}=e;dc(s||"top",i,cc),dc(n||"bottom",i,uc);const h=t.canvas.createLinearGradient(cc.x,cc.y,uc.x,uc.y);_c(h,e.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=e;vc(s||"center",i,wc),vc(n||"bottom",i,xc);const l=t.canvas.createRadialGradient(wc.x,wc.y,0,wc.x,wc.y,gc(wc,xc));_c(l,e.stops,r);const d={type:o,style:l},c=bc(i,wc,xc,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=e;Ec(s||"center",i,Bc),Ec(n||"bottom",i,Rc);const l=t.conicGradientSupport?t.canvas.createConicGradient(0,Bc.x,Bc.y):t.canvas.createRadialGradient(Bc.x,Bc.y,0,Bc.x,Bc.y,kc(Bc,Rc));_c(l,e.stops,r);const d={type:o,style:l},c=bc(i,Bc,Rc,h||1,t.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:bc},{copy:Lc,toOffsetOutBounds:Cc}=nt,Tc={},Sc={};function Pc(e,i,s,n){const{bounds:o,shapeBounds:r}=n;if(t.fullImageShadow){if(Lc(Tc,e.bounds),Tc.x+=i.x-r.x,Tc.y+=i.y-r.y,s){const{matrix:t}=n;Tc.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Tc.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Tc.width*=s,Tc.height*=s}e.copyWorld(n.canvas,e.bounds,Tc)}else s&&(Lc(Tc,i),Tc.x-=i.width/2*(s-1),Tc.y-=i.height/2*(s-1),Tc.width*=s,Tc.height*=s),e.copyWorld(n.canvas,r,s?Tc:i)}const{toOffsetOutBounds:Mc}=nt,Ac={};const Dc={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Cc(l,Sc),a.forEach(((a,g)=>{_.setWorldShadow(Sc.offsetX+a.x*c,Sc.offsetY+a.y*u,a.blur*c,Ha.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Pc(_,Sc,n,i),s=l,a.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,o,"copy"),s=o),h?_.copyWorld(h,o,o,"destination-out"):_.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,r.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Mc(l,Ac),a.forEach(((a,g)=>{_.save(),_.setWorldShadow(Ac.offsetX+a.x*c,Ac.offsetY+a.y*u,a.blur*c),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Pc(_,Ac,n,i),_.restore(),h?(_.copyWorld(_,l,o,"copy"),_.copyWorld(h,o,o,"source-out"),s=o):(_.copyWorld(i.canvas,d,l,"source-out"),s=l),_.fillWorld(s,Ha.string(a.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,r.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ic}=Lo;function Wc(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),zc(t,e,i,1)}(t,i,s,n);break;case"opacity-path":zc(t,i,s,o);break;case"path":i.restore()}}function Fc(t){return t.getSameCanvas(!1,!0)}function zc(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Rh.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],a=i.__.mask,a&&(r&&(Wc(this,r,t,n,s,o),s=n=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=Fc(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Fc(t)),n||(n=Fc(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||Ic(i,e)||i.__render(n||t,e);Wc(this,r,t,n,s,o)};const Nc=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Yc=Nc+"_#~&*+\\=|≮≯≈≠=…",Hc=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Xc(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Vc=Xc("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),jc=Xc("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Uc=Xc(Nc),Gc=Xc(Yc),Zc=Xc("- —/~|┆·");var Kc;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Kc||(Kc={}));const{Letter:qc,Single:Jc,Before:$c,After:Qc,Symbol:tu,Break:eu}=Kc;function iu(t){return Vc[t]?qc:Zc[t]?eu:jc[t]?$c:Uc[t]?Qc:Gc[t]?tu:Hc.test(t)?Jc:qc}const su={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function nu(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ou}=su,{Letter:ru,Single:au,Before:hu,After:lu,Symbol:du,Break:cu}=Kc;let uu,_u,pu,gu,fu,yu,mu,vu,wu,xu,bu,ku,Eu,Bu,Ru,Ou,Lu,Cu=[];function Tu(t,e){wu&&!vu&&(vu=wu),uu.data.push({char:t,width:e}),pu+=e}function Su(){gu+=pu,uu.width=pu,_u.words.push(uu),uu={data:[]},pu=0}function Pu(){Bu&&(Ru.paraNumber++,_u.paraStart=!0,Bu=!1),wu&&(_u.startCharSize=vu,_u.endCharSize=wu,vu=0),_u.width=gu,Ou.width?ou(_u):Lu&&Mu(),Cu.push(_u),_u={words:[]},gu=0}function Mu(){gu>(Ru.maxWidth||0)&&(Ru.maxWidth=gu)}const{top:Au,right:Du,bottom:Iu,left:Wu}=ct;function Fu(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const zu={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let s=0,n=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=i;l&&(o?(s=l[Wu],o-=l[Du]+l[Wu]):i.autoSizeAlign||(s=l[Wu]),r?(n=l[Au],r-=l[Au]+l[Iu]):i.autoSizeAlign||(n=l[Au]));const d={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:t.canvas.font=h};return function(e,i,s){Ru=e,Cu=e.rows,Ou=e.bounds,Lu=!Ou.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t,{width:h,height:l}=Ou;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Bu=!0,bu=null,vu=mu=wu=pu=gu=0,uu={data:[]},_u={words:[]};for(let s=0,l=i.length;s<l;s++)yu=i[s],"\n"===yu?(pu&&Su(),_u.paraEnd=!0,Pu(),Bu=!0):(xu=iu(yu),xu===ru&&"none"!==r&&(yu=nu(yu,r,!pu)),mu=a.measureText(yu).width,n&&(n<0&&(wu=mu),mu+=n),ku=xu===au&&(bu===au||bu===ru)||bu===au&&xu!==lu,Eu=!(xu!==hu&&xu!==au||bu!==du&&bu!==lu),fu=Bu&&o?h-o:h,t&&h&&gu+pu+mu>fu&&(e?(pu&&Su(),gu&&Pu()):(Eu||(Eu=xu===ru&&bu==lu),ku||Eu||xu===cu||xu===hu||xu===au||pu+mu>fu?(pu&&Su(),gu&&Pu()):gu&&Pu()))," "===yu&&!0!==Bu&&gu+pu===0||(xu===cu?(" "===yu&&pu&&Su(),Tu(yu,mu),Su()):ku||Eu?(pu&&Su(),Tu(yu,mu)):Tu(yu,mu)),bu=xu);pu&&Su(),gu&&Pu(),Cu.length>0&&(Cu[Cu.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ru.paraNumber++,gu=a.measureText(t).width,Cu.push({x:o||0,text:t,width:gu,paraStart:!0}),Lu&&Mu()}))}(d,e,i),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Fu(e,"x",t[Wu]);break;case"right":Fu(e,"x",-t[Du])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Fu(e,"y",t[Au]);break;case"bottom":Fu(e,"y",-t[Iu])}}(l,d,i,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:_,y:p,width:g,height:f}=s,y=o*n+(c?c*(t.paraNumber-1):0),m=r;if(h&&y>f)y=Math.max(f,o),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":p+=(f-y)/2;break;case"bottom":p+=f-y}m+=p;let v,w,x,b=g||u?g:t.maxWidth;for(let r=0,d=n;r<d;r++){if(v=i[r],v.x=_,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&r>0&&(m+=c),v.y=m,m+=o,t.overflow>r&&m>y&&(v.isOverflow=!0,t.overflow=r+1),w=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,w-=x,x+=e.fontSize):x-=a),w<s.x&&(s.x=w),x>s.width&&(s.width=x),h&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=y}(d,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,d,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,d=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===d?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach(((e,i)=>{1===d?(c={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):a=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)}))),t.words=null)}))}(d,i,o),d.overflow&&function(e,i,s,n){if(!n)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.canvas.measureText(a).width:0,d=s+n-l;("none"===i.textWrap?o:[o[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let s=i;s>-1&&(e=t.data[s],h=e.x+e.width,!(s===i&&h<d));s--){if(h<d&&" "!==e.char||!s){t.data.splice(s+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,i,s,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,i),d}};const Nu={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!Ha.object)return t;t=Ha.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};function Yu(t){return t?t instanceof Array?t:[t]:[]}Object.assign(Ya,zu),Object.assign(Ha,Nu),Object.assign(ja,Cd),Object.assign(Ua,lc),Object.assign(Ga,Oc),Object.assign(Za,Dc),Object.assign(e,{interaction:(t,e,i,s)=>new sd(t,e,i,s),hitCanvas:(t,e)=>new fa(t,e),hitCanvasManager:()=>new od}),ma();class Hu extends Vo{get list(){return Yu(this.value)}get oldList(){return Yu(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}Hu.BEFORE_SELECT="editor.before_select",Hu.SELECT="editor.select",Hu.BEFORE_HOVER="editor.before_hover",Hu.HOVER="editor.hover";class Xu extends Hu{constructor(t,e){super(t,e)}}Xu.BEFORE_MOVE="editor.before_move",Xu.MOVE="editor.move";class Vu extends Hu{constructor(t,e){super(t,e)}}Vu.BEFORE_SCALE="editor.before_scale",Vu.SCALE="editor.scale";class ju extends Hu{constructor(t,e){super(t,e)}}ju.BEFORE_ROTATE="editor.before_rotate",ju.ROTATE="editor.rotate";class Uu extends Hu{constructor(t,e){super(t,e)}}function Gu(t){return(e,i)=>{const s="_"+i;kn(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const o="target"===i?Hu.BEFORE_SELECT:Hu.BEFORE_HOVER;this.hasEvent(o)&&this.emitEvent(new Hu(o,{editor:this,value:e,oldValue:n})),this[s]=e,t(this,n)}}})}}Uu.BEFORE_SKEW="editor.before_skew",Uu.SKEW="editor.skew";const{abs:Zu}=Math,{copy:Ku,scale:qu}=x,{setListWithFn:Ju}=nt,{worldBounds:$u}=Lo,Qu={a:1,b:0,c:0,d:1,e:0,f:0},t_={x:0,y:0,width:0,height:0};class e_ extends Bh{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(Ju(t_,t,$u),this.set(t_)):this.width=this.height=1}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:o,strokeWidth:r,fill:a}=n,{bounds:h}=e;for(let l=0;l<i.length;l++){s=i[l];const{worldTransform:d,worldRenderBounds:c}=s;if(c.width&&c.height&&(!h||h.hit(c,e.matrix))){const i=Zu(d.scaleX),h=Zu(d.scaleY);if(i!==h){Ku(Qu,d),qu(Qu,1/i,1/h),t.setWorld(Qu,e.matrix),t.beginPath(),n.strokeWidth=r;const{x:o,y:a,width:l,height:c}=s.__layout.boxBounds;t.rect(o*i,a*h,l*i,c*h)}else t.setWorld(d,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=r/Zu(d.scaleX);o&&("string"==typeof o?ja.stroke(o,this,t):ja.strokes(o,this,t)),a&&("string"==typeof a?ja.fill(a,this,t):ja.fills(a,this,t))}}n.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}Nt([Gu((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],e_.prototype,"target",void 0);class i_ extends Rh{constructor(t){super(t),this.strokeArea=new Th({strokeAlign:"center"}),this.fillArea=new Th,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const s_={findOne:t=>t.list.find((t=>t.editable)),findByBounds(t,e){const i=[];return n_([t],i,e),i}};function n_(t,e,i){let s,n;for(let o=0,r=t.length;o<r;o++)if(s=t[o],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&n_(s.children,e,i)}}const{findOne:o_,findByBounds:r_}=s_;class a_ extends Rh{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new e_,this.targetStroker=new e_,this.bounds=new ht,this.selectArea=new i_,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:n}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},n||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s,selectedStyle:n}=t;this.targetStroker.setTarget(e,Object.assign({stroke:i,strokeWidth:Math.max(1,s/2)},n||{})),this.hoverStroker.target=null}}update(){this.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:n,y:o}=t.getInnerPoint(this);this.bounds.set(n,o),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:o},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new _a(r_(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!o_(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new _a(this.editor.editBox.rect)};return o_(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):o_(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(Hu.HOVER,this.onHover,this),t.on_(Hu.SELECT,this.onSelect,this),e.on_(Tl.MOVE,this.onPointerMove,this),e.on_(Tl.BEFORE_DOWN,this.onBeforeDown,this),e.on_(Tl.TAP,this.onTap,this),e.on_(Ml.START,this.onDragStart,this,!0),e.on_(Ml.DRAG,this.onDrag,this),e.on_(Ml.END,this.onDragEnd,this),e.on_(Il.MOVE,this.onAutoMove,this),e.on_([zl.ZOOM,Il.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:h_,top:l_,topRight:d_,right:c_,bottomRight:u_,bottom:__,bottomLeft:p_,left:g_}=ut,{toPoint:f_}=pt,{within:y_}=a,m_={getScaleData(t,e,i,s,n,o,r,a){let h,l={},d=1,c=1;const{boxBounds:u,widthRange:_,heightRange:p,dragBounds:g,worldBoxBounds:f}=t,{width:y,height:m}=e;o&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,w=t.scaleY/e.scaleY,x=v<0?-1:1,b=w<0?-1:1,k=a?v:x*u.width/y,E=a?w:b*u.height/m;s.x*=a?v:x,s.y*=a?w:b;const B=(-s.y+m)/m,R=(s.x+y)/y,O=(s.y+m)/m,L=(-s.x+y)/y;switch(i){case l_:c=B,h="bottom";break;case c_:d=R,h="left";break;case __:c=O,h="top";break;case g_:d=L,h="right";break;case h_:c=B,d=L,h="bottom-right";break;case d_:c=B,d=R,h="bottom-left";break;case u_:c=O,d=R,h="top-left";break;case p_:c=O,d=L,h="top-right"}if(n){if(!("corner"===n&&i%2)){let t;switch(i){case l_:case __:t=c;break;case g_:case c_:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=k,c/=E,!r){const{worldTransform:e}=t;d<0&&(d=1/u.width/e.scaleX),c<0&&(c=1/u.height/e.scaleY)}if(f_(o||h,u,l,!0),g){const e="parent"===g?t.parent.boxBounds:g,i=new ht(t.__localBoxBounds);if(i.scaleOf(t.getLocalPointByInner(l),d,c),!nt.includes(e,i)){const t=i.getIntersect(e);d*=t.width/i.width,c*=t.height/i.height}}if(_){const e=u.width*t.scaleX;d=y_(e*d,_)/e}if(p){const e=u.height*t.scaleY;c=y_(e*c,p)/e}return Math.abs(d*f.width)<1&&(d=(d<0?-1:1)/f.width),Math.abs(c*f.height)<1&&(c=(c<0?-1:1)/f.height),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:n,around:o}},getRotateData(t,e,i,s,n){let o,r={};switch(e){case h_:o="bottom-right";break;case d_:o="bottom-left";break;case u_:o="top-left";break;case p_:o="top-right";break;default:o="center"}return f_(n||o,t,r,!0),{origin:r,rotation:P.getRotation(s,r,i)}},getSkewData(t,e,i,s){let n,o,r={},a=0,h=0;switch(e){case l_:o={x:.5,y:0},n="bottom",a=1;break;case __:o={x:.5,y:1},n="top",a=1;break;case g_:o={x:0,y:.5},n="right",h=1;break;case c_:o={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,f_(s||n,t,r,!0);const c=P.getRotation(o,r,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case g_:t=c_;break;case h_:t=d_;break;case p_:t=u_;break;case c_:t=g_;break;case d_:t=h_;break;case u_:t=p_}if(i)switch(t){case l_:t=__;break;case h_:t=p_;break;case d_:t=u_;break;case __:t=l_;break;case p_:t=h_;break;case u_:t=d_}return t}},v_={};function w_(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=i;const{resizeCursor:o,rotateCursor:r,skewCursor:h,resizeable:l,rotateable:d,skewable:c}=t.mergeConfig,{pointType:u}=s,{flippedX:_,flippedY:p}=i;let g=u.includes("resize");g&&d&&(e.metaKey||e.ctrlKey||!l)&&(g=!1);const f=c&&!g&&"resize-line"===s.name?h:g?o:r;n+=45*(m_.getFlipDirection(s.direction,_,p)+1),n=2*Math.round(a.formatRotation(n,!0)/2);const{url:y,x:m,y:v}=f,w=y+n;v_[w]?s.cursor=v_[w]:v_[w]=s.cursor={url:b_(y,n),x:m,y:v}}function x_(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function b_(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class k_ extends Wh{}const E_=["top","right","bottom","left"],B_=void 0;class R_ extends Rh{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new Rh,this.rect=new Wh({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new k_({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new Rh({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:o,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new k_({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new k_({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new k_({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...o,a,h,l,...r,...n),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:n,resizePoints:o}=this,{stroke:r,strokeWidth:a}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=o[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);n.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),s.set(Object.assign({stroke:r,strokeWidth:a,editConfig:B_},t.rect||{})),s.hittable=!i,s.syncEventer=i&&this.editor,i&&(e.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:e}])}update(t){const{mergeConfig:e,element:i,multiple:s}=this.editor,{middlePoint:n,resizeable:o,rotateable:r,hideOnSmall:a,editBox:h}=e;if(this.visible=!i.locked,this.view.worldOpacity){const{width:i,height:l}=t,{rect:d,circle:c,buttons:u,resizePoints:_,rotatePoints:p,resizeLines:g}=this,f="number"==typeof a?a:10,y=h&&!(a&&i<f&&l<f);let m,v,w,x={};for(let s=0;s<8;s++)pt.toPoint(pt.directionData[s],t,x),v=_[s],m=p[s],w=g[Math.floor(s/2)],v.set(x),m.set(x),w.set(x),v.visible=w.visible=y&&!(!o&&!r),m.visible=y&&r&&o&&!e.rotatePoint,s%2&&(v.visible=m.visible=y&&!!n,(s+1)/2%2?(w.width=i,a&&2*v.width>i&&(v.visible=!1)):(w.height=l,v.rotation=90,a&&2*v.width>l&&(v.visible=!1)));c.visible=y&&r&&!(!e.circle&&!e.rotatePoint),c.visible&&this.layoutCircle(e),d.path&&(d.path=null),d.set(Object.assign(Object.assign({},t),{visible:!!s||h})),u.visible=y&&u.children.length>0,u.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:n,middlePoint:o}=t,r=E_.indexOf(e||(this.buttons.children.length&&"bottom"===n?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!o)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:n,middlePoint:o}=t,{flippedX:r,flippedY:a}=this;let h=E_.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?m_.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,n,!!o),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],o=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*r;o?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:o}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:n,height:n,cornerRadius:o,offsetX:0,offsetY:0,editConfig:B_};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{editor:i,dragStartData:s}=this,{element:n}=i;"rect"===e.name&&(this.moving=!0,i.opacity=i.mergeConfig.hideOnMove?0:1),s.x=t.x,s.y=t.y,s.point={x:n.x,y:n.y},s.bounds=Object.assign({},n.getLayoutBounds("box","local")),s.rotation=n.rotation}onDragEnd(t){this.dragging=!1,this.dragPoint=null,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this,{pointType:i}=this.enterPoint=t.current;(i.includes("rotate")||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable)&&e.onRotate(t),i.includes("resize")&&e.onScale(t),w_(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find((t=>t.editable&&t instanceof bl))||t.find((t=>t instanceof bl));if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(Ml.START,this.onDragStart,this),t.on_(Ml.DRAG,this.onDrag,this),t.on_(Ml.END,this.onDragEnd,this),t.on_(Tl.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(Tl.ENTER,(e=>{this.enterPoint=t,w_(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(Hu.SELECT,this.onSelect,this),t.on_(Ml.START,this.onDragStart,this),t.on_(Ml.DRAG,e.onMove,e),t.on_(Ml.END,this.onDragEnd,this),t.on_(Tl.ENTER,(()=>x_(e))),t.on_(Tl.DOUBLE_TAP,this.onDoubleTap,this),t.on_(Tl.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class O_ extends Bh{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergeConfig;if(s&&i.list.length){const{rect:n}=i.editBox,{width:o,height:r}=n.__;t.resetTransform(),t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(n.__world,e.matrix),t.clearRect(0,0,o,r)}}destroy(){this.editor=null,super.destroy()}}const L_='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',C_={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${L_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${L_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${L_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},T_=new ht;function S_(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer.zoomLayer;e.safeChange((()=>{T_.setListWithFn(i,(t=>t.getBounds("box","page"))),0===T_.width&&(T_.width=.1),0===T_.height&&(T_.height=.1),e.reset(T_.get())})),s.add(e)}function P_(t){return t.editable&&!t.locked}const M_=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),A_=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),D_={group(t,e,i){t.sort(A_);const{app:s,parent:n}=t[0];let o;o=i&&i.add?i:new Rh(i),n.addAt(o,n.children.indexOf(t[0])),t.sort(M_);const r=new z(e.worldTransform);return r.divideParent(n.worldTransform),o.setTransform(r),o.editable=!0,o.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(o))),s.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch&&!t.isBranchLeaf){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(M_),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(A_),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},I_=vt.get("EditToolCreator");function W_(){return t=>{z_.register(t)}}const F_=W_,z_={list:{},register(t){const{tag:e}=t.prototype;N_[e]&&I_.repeat(e),N_[e]=t},get:(t,e)=>new N_[t](e)},{list:N_}=z_;class Y_ extends Hu{constructor(t,e){super(t,e)}}Y_.BEFORE_OPEN="innerEditor.before_open",Y_.OPEN="innerEditor.open",Y_.BEFORE_CLOSE="innerEditor.before_close",Y_.CLOSE="innerEditor.close";class H_ extends Hu{constructor(t,e){super(t,e)}}H_.BEFORE_GROUP="editor.before_group",H_.GROUP="editor.group",H_.BEFORE_UNGROUP="editor.before_ungroup",H_.UNGROUP="editor.ungroup",H_.BEFORE_OPEN="editor.before_open_group",H_.OPEN="editor.open_group",H_.BEFORE_CLOSE="editor.before_close_group",H_.CLOSE="editor.close_group";const{updateMatrix:X_}=xo,V_={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},j_="top-left";class U_ extends Th{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Uo.CHANGE,(e=>{if(this.checkChange&&V_[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,o="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const r=this.__;r[i]=n,X_(this.parent),X_(this);const a=new z(this.__world);switch(r[i]=s,this.__layout.rotationChange(),X_(this),this.changedTransform=new z(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(j_,o);break;case"scaleX":t.scaleOf(j_,o,1);break;case"scaleY":t.scaleOf(j_,1,o);break;case"skewX":t.skewOf(j_,o,0);break;case"skewY":t.skewOf(j_,0,o)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class G_ extends Rh{get mergeConfig(){const{config:t,element:e,dragPoint:i}=this,s=Object.assign({},t);return e&&e.editConfig&&Object.assign(s,e.editConfig),i&&(i.editConfig&&Object.assign(s,i.editConfig),"font-size"===s.editSize&&(s.lockRatio=!0),"resize-rotate"===i.pointType&&(s.around||(s.around="center"),zt(s.lockRatio)&&(s.lockRatio=!0))),s}get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get moving(){return this.editBox.moving}get dragPoint(){return this.editBox.dragPoint}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=At.clone(C_),this.leafList=new _a,this.openedGroupList=new _a,this.simulateTarget=new U_(this),this.editBox=new R_(this),this.editToolList={},this.selector=new a_(this),this.editMask=new O_(this),this.targetEventIds=[],t&&(this.config=At.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox),Rt.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&S_(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||z_.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof Il){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(Ml.getValidMove(this.element,this.editBox.dragStartData.point,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:n,flipable:o,editSize:r}=this.mergeConfig;if(t instanceof zl)"zoom"===n&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:n}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=m_.getScaleData(e,this.editBox.dragStartData.bounds,n,t.getInnerTotal(e),s,m_.getAround(i,t.altKey),o,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:n}=this.mergeConfig,{direction:o,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:h}=this,{dragStartData:l}=this.editBox;let d,c;if(t instanceof Wl){if("rotate"!==i)return;t.stop(),c=t.rotation,d=h.getBoxPoint(t),h.scaleX*h.scaleY<0&&(c=-c)}else{const e=m_.getRotateData(h.boxBounds,o,t.getBoxPoint(h),h.getBoxPoint(l),t.shiftKey?null:h.around||h.origin||s||"center");c=e.rotation,d=e.origin}h.scaleX*h.scaleY<0&&(c=-c),t instanceof Ml&&(c=l.rotation+c-h.rotation),c=a.float(a.getGapRotation(c,n,h.rotation),2),c&&this.rotateOf(d,c)}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:n,skewY:o}=m_.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),m_.getAround(i,t.altKey));(n||o)&&this.skewOf(s,n,o)}move(t,e=0){const{element:i}=this;if(!this.checkTransform("moveable"))return;const s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const n={target:i,editor:this,moveX:s.x,moveY:s.y};this.emitEvent(new Xu(Xu.BEFORE_MOVE,n));const o=new Xu(Xu.MOVE,n);this.editTool.onMove(o),this.emitEvent(o)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this;t=Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new Vu(Vu.BEFORE_SCALE,t));const i=new Vu(Vu.SCALE,t);this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{element:n}=this,o=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>n.safeChange((()=>n.scaleOf(t,e,i))))),a={target:n,editor:this,worldOrigin:o,scaleX:e,scaleY:i,transform:r};this.emitEvent(new Vu(Vu.BEFORE_SCALE,a));const h=new Vu(Vu.SCALE,a);this.editTool.onScale(h),this.emitEvent(h)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.safeChange((()=>e.flip(t))))):new z(xo.getFlipTransform(e,t)),n={target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s};this.emitEvent(new Vu(Vu.BEFORE_SCALE,n));const o=new Vu(Vu.SCALE,n);this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,s=this.getWorldOrigin(t),n=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),o={target:i,editor:this,worldOrigin:s,rotation:e,transform:n};this.emitEvent(new ju(ju.BEFORE_ROTATE,o));const r=new ju(ju.ROTATE,o);this.editTool.onRotate(r),this.emitEvent(r)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{element:n}=this,o=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>n.safeChange((()=>n.skewOf(t,e,i))))),a={target:n,editor:this,worldOrigin:o,skewX:e,skewY:i,transform:r};this.emitEvent(new Uu(Uu.BEFORE_SKEW,a));const h=new Uu(Uu.SKEW,a);this.editTool.onSkew(h),this.emitEvent(h)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(xo.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this;if(this.multiple&&!e.canChange)return e.changedTransform;const i=new z(e.worldTransform);return t(),new z(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.emitGroupEvent(H_.BEFORE_GROUP),this.target=D_.group(this.list,this.element,t),this.emitGroupEvent(H_.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(H_.BEFORE_UNGROUP,t))),this.target=D_.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(H_.UNGROUP,t)))),this.list}openGroup(t){this.emitGroupEvent(H_.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(H_.OPEN,t)}closeGroup(t){this.emitGroupEvent(H_.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(H_.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!xo.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new H_(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&z_.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||z_.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(Y_.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Y_.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Y_.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Y_.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Y_(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(D_.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(D_.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e}=this;this.targetEventIds=[e.on_(Jo.START,this.update,this),t.on_(Jo.CHILD_START,this.forceRender,this),t.on_(Il.BEFORE_MOVE,this.onMove,this,!0),t.on_(zl.BEFORE_ZOOM,this.onScale,this,!0),t.on_(Wl.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([Nl.HOLD,Nl.UP],(t=>{w_(this,t)})),t.on_(Nl.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}Nt([Gu((function(t,e){t.emitEvent(new Hu(Hu.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],G_.prototype,"hoverTarget",void 0),Nt([Gu((function(t,e){const{target:i}=t;if(i){const{list:e}=t.leafList=i instanceof _a?i:new _a(i);if(!e.every(P_))return void(t.target=e.filter(P_));t.multiple&&S_(t)}else t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor();t.emitEvent(new Hu(Hu.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{x_(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],G_.prototype,"target",void 0);class Z_{static registerInnerEditor(){z_.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new Rh,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let K_=class extends Z_{static registerEditTool(){z_.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:o}=s;n.lockLayout(),o.forEach((t=>{t.moveWorld(e,i)})),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach((t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(n,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:o,list:r}=n;o.lockLayout(),r.forEach((t=>{const o="scale"!==n.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)})),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach((t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(n,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{x:i,y:s,scaleX:n,scaleY:o,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:s,scaleX:n,scaleY:o,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};K_=Nt([W_()],K_);const{left:q_,right:J_}=ut,{move:$_,copy:Q_,toNumberPoints:tp}=P;let ep=class extends K_{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,o=t.target,r=i===q_;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,o.path=t}else if(o.points){const{points:t}=o,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,o.points=t}else{const t={x:0,y:0},{toPoint:i}=o;o.rotation=0,this.dragPoint(t,i,r,n,this.getInnerMove(o,e,s)),o.getLocalPointByInner(t,null,null,!0),o.getLocalPointByInner(i,null,null,!0),o.x=t.x,o.y=t.y,o.getInnerPointByLocal(i,null,null,!0),o.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=tp(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:o,y:r}=n;i?($_(t,o,r),s&&$_(e,-o,-r)):(s&&$_(t,-o,-r),$_(e,o,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,o=this.editor.element;let r,a;if(o.pathInputed?r=this.getFromToByPath(o.__.path):o.points&&(r=this.getFromToByPoints(o.__.points)),r){const{from:i,to:a}=r;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Q_(s[7],i),Q_(e[7],i),Q_(s[3],a),Q_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===q_||t===J_,s[t].visible=a,e[t].visible=!r&&a}};ep=Nt([W_()],ep);const{M:ip,L:sp,C:np,Q:op,Z:rp,N:ap,D:hp,X:lp,G:dp,F:cp,O:up,P:_p,U:pp}=Qt,gp={scale(t,e,i){if(!t)return;let s,n=0,o=t.length;for(;n<o;)switch(s=t[n],s){case ip:case sp:fp(t,e,i,n,1),n+=3;break;case np:fp(t,e,i,n,3),n+=7;break;case op:fp(t,e,i,n,2),n+=5;break;case rp:n+=1;break;case ap:fp(t,e,i,n,2),n+=5;break;case hp:fp(t,e,i,n,2),n+=9;break;case lp:fp(t,e,i,n,2),n+=6;break;case dp:fp(t,e,i,n,2),n+=9;break;case cp:fp(t,e,i,n,2),n+=5;break;case up:t[n]=dp,t.splice(n+4,0,t[n+3],0),fp(t,e,i,n,2),n+=9,o+=2;break;case _p:t[n]=cp,t.splice(n+4,0,t[n+3]),fp(t,e,i,n,2),n+=5,o+=1;break;case pp:fp(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let o=n?s+1:0,r=n?o+2*n:t.length;o<r;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:fp}=gp,yp=x.get(),{topLeft:mp,top:vp,topRight:wp,right:xp,bottom:bp,left:kp}=ut;function Ep(t,e,i){t.pathInputed?Bp(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function Bp(t,e,i){gp.scale(t.__.path,e,i),t.path=t.__.path}function Rp(t,e,i){const{points:s}=t;"object"==typeof s[0]?s.forEach((t=>{t.x*=e,t.y*=i})):gp.scalePoints(s,e,i),t.points=s}function Op(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)yp.a=e,yp.d=i,s[t].transform(yp,!0)}const Lp=ia.prototype;function Cp(t,e,i){Tp(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(Il.BEFORE_MOVE,(e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY))})),t.on_(zl.BEFORE_ZOOM,(e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&i.scaleOfWorld(e,s)})))}function Tp(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&At.assign(i,e),At.assign(t.config,i,t.userConfig)}Lp.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},Lp.__scaleResize=function(t,e){Ep(this,t,e)},Lp.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},Lp.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},bl.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,n=i&&i.editor,o=n&&n.dragPoint;this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===n.mergeConfig.editSize?function(t,e,i,s){let n=e;if(void 0!==s){const o=t.__layout;let{width:r,height:a}=o.boxBounds;switch(r*=i-e,a*=e-i,s){case vp:case bp:n=i,o.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case kp:case xp:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case mp:case wp:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const o=t.__;o.__autoWidth||(t.width*=n),o.__autoHeight||(t.height*=n)}(this,t,e,o&&o.direction):Ep(this,t,e)},kl.prototype.__scaleResize=function(t,e){Bp(this,t,e)},Jh.prototype.__scaleResize=function(t,e){this.pathInputed?Bp(this,t,e):this.points?Rp(this,t,e):this.width*=t},rl.prototype.__scaleResize=function(t,e){this.pathInputed?Bp(this,t,e):this.points?Rp(this,t,e):Ep(this,t,e)},Rh.prototype.__scaleResize=function(t,e){Op(this,t,e)},Wh.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?Op(this,t,e):(Ep(this,t,e),this.__.resizeChildren&&Op(this,t,e))},Rt.add("resize"),Rt.add("editor","resize"),e.editor=function(t){return new G_(t)},Wh.addAttr("textBox",!1,Ln),Bh.addAttr("editConfig",void 0,Ln),Bh.addAttr("editOuter",(t=>t.__.__isLinePath?"LineEditTool":"EditTool"),Ln),Bh.addAttr("editInner","PathEditor",Ln),Rh.addAttr("editInner","",Ln),bl.addAttr("editInner","TextEditor",Ln),Bh.setEditConfig=function(t){this.changeAttr("editConfig",t)},Bh.setEditOuter=function(t){this.changeAttr("editOuter",t)},Bh.setEditInner=function(t){this.changeAttr("editInner",t)};const Sp=vt.get("LeaferTypeCreator"),Pp={list:{},register(t,e){Mp[t]&&Sp.repeat(t),Mp[t]=e},run(t,e){const i=Mp[t];i&&i(e)}},{list:Mp,register:Ap}=Pp;Ap("viewport",Cp),Ap("custom",(function(t){Cp(t,null,!0)})),Ap("design",(function(t){Cp(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),Ap("document",(function(t){Cp(t,{zoom:{min:1},move:{scroll:"limit"}})}));const Dp={getData(t){const e=t[0],i=t[1],s=P.getCenter(e.from,i.from),n=P.getCenter(e.to,i.to),o={x:n.x-s.x,y:n.y-s.y},r=P.getDistance(e.from,i.from);return{move:o,scale:P.getDistance(e.to,i.to)/r,rotation:P.getRotation(e.from,i.from,e.to,i.to),center:n}}},Ip={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(e,i){let s,n=1,{zoomMode:o,zoomSpeed:r}=i;const h=e.deltaY||e.deltaX;if(o?(s="mouse"===o||!e.deltaX&&(t.intWheelDeltaY?Math.abs(h)>17:Math.ceil(h)!==h),(e.shiftKey||e.metaKey||e.ctrlKey)&&(s=!0)):s=!e.shiftKey&&(e.metaKey||e.ctrlKey),s){r=a.within(r,0,1);n=1-h/(4*(e.deltaY?i.delta.y:i.delta.x))*r,n<.5&&(n=.5),n>=1.5&&(n=1.5)}return n}};class Wp{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),e.emit(Il.START,this.moveData)),t.path=this.moveData.path,e.emit(Il.BEFORE_MOVE,t),e.emit(Il.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.emit(zl.START,this.zoomData)),t.path=this.zoomData.path,e.emit(zl.BEFORE_ZOOM,t),e.emit(zl.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.emit(Wl.START,this.rotateData)),t.path=this.rotateData.path,e.emit(Wl.BEFORE_ROTATE,t),e.emit(Wl.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout((()=>{this.transformEnd()}),this.interaction.p.transformTime)}transformEnd(){const{interaction:t,moveData:e,zoomData:i,rotateData:s}=this;e&&t.emit(Il.END,e),i&&t.emit(zl.END,i),s&&t.emit(Wl.END,s),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const Fp=Ch.prototype,zp=new ht;function Np(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function Yp(t,e){return Object.assign(Object.assign({},e),{scale:t})}Fp.initType=function(t){Pp.run(t,this)},Fp.getValidMove=function(t,e){const{scroll:i,disabled:s}=this.app.config.move;if(i){const s=!0===i?"":i;if(s.includes("x")?(t=t||e,e=0):s.includes("y")?(e=e||t,t=0):Math.abs(t)>Math.abs(e)?e=0:t=0,s.includes("limit")){const{x:i,y:s,width:n,height:o}=zp.set(this.__world).addPoint(this.zoomLayer),r=i+n-this.width,a=s+o-this.height;i>=0&&r<=0?t=0:t>0?i+t>0&&(t=-i):t<0&&r+t<0&&(t=-r),s>=0&&a<=0?e=0:e>0?s+e>0&&(e=-s):e<0&&a+e<0&&(e=-a)}}return{x:s?0:t,y:s?0:e}},Fp.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),n?1:t};const Hp=sd.prototype;Hp.createTransformer=function(){this.transformer=new Wp(this)},Hp.move=function(t){this.transformer.move(t)},Hp.zoom=function(t){this.transformer.zoom(t)},Hp.rotate=function(t){this.transformer.rotate(t)},Hp.transformEnd=function(){this.transformer.transformEnd()},Hp.wheel=function(t){const{wheel:e}=this.config;if(e.disabled)return;const i=e.getScale?e.getScale(t,e):Ip.getScale(t,e);1!==i?this.zoom(Yp(i,t)):this.move(Np(e.getMove?e.getMove(t,e):Ip.getMove(t,e),t))},Hp.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:i,rotation:s,scale:n,center:o}=Dp.getData(e);Object.assign(t,o),this.rotate(function(t,e){return Object.assign(Object.assign({},e),{rotation:t})}(s,t)),this.zoom(Yp(n,t)),this.move(Np(i,t))};const Xp=Gl.prototype,{abs:Vp}=Math;function jp(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}Xp.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=Vp(i),o=Vp(s),r=e?1:.1,a=this.interaction.m.dragAnimate&&this.canAnimate&&this.moving&&(n>r||o>r);if(a){const r="touch"===t.pointerType?3:1,a=70;n*(e=e?.95:r)>a?e=a/n:o*e>a&&(e=a/o),t=Object.assign({},t),P.move(t,i*e,s*e),this.drag(t),this.animate((()=>{this.dragEnd(t,1)}))}return a},Xp.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},Xp.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},Xp.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:o}=e.m;if(!o||!s||!n)return;const r=e.shrinkCanvasBounds,{x:a,y:h}=r,l=nt.maxX(r),d=nt.maxY(r),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let _=0,p=0;this.autoMoveTimer=setInterval((()=>{_+=c,p+=u,P.move(i,c,u),P.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:_,totalY:p,moveType:"drag"})),e.pointerMoveReal(t)}),10)},Xp.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},Rt.add("viewport"),Rt.add("view"),Ch.prototype.zoom=function(t,e,i,s){this.killAnimate();const{zoomLayer:n}=this,o=this.canvas.bounds.clone().shrink(void 0!==e?e:30),r=new ht,a={x:o.x+o.width/2,y:o.y+o.height/2};let h;const{x:l,y:d,scaleX:c,scaleY:u}=n.__;if("string"==typeof t)switch(t){case"in":h=jp(c,"in");break;case"out":h=jp(c,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new ht(this.boxBounds)).height=0;break;case"fit-height":(t=new ht(this.boxBounds)).width=0}else"number"==typeof t&&(h=t/c);if(h)h=this.getValidScale(h),n.scaleOfWorld(a,h,h,!1,s);else if("object"==typeof t){const e={x:l,y:d,scaleX:c,scaleY:u},a=t instanceof Array;if(a||t.tag){const e=a?t:[t];r.setListWithFn(e,Lo.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:o,height:r}=t;return r||(r=o*(e.height/e.width),i=!0),o||(o=r*(e.width/e.height),i=!0),i?{x:s,y:n,width:o,height:r}:t}(t,o);r.set(n.getWorldBounds(e))}const{width:_,height:p}=r;let g=o.x-r.x,f=o.y-r.y;return i?(g+=Math.max((o.width-_)/2,0),f+=Math.max((o.height-p)/2,0)):(h=this.getValidScale(Math.min(o.width/_,o.height/p)),g+=(o.width-_*h)/2,f+=(o.height-p*h)/2,P.scaleOf(e,r,h),r.scaleOf(r,h),e.scaleX*=h,e.scaleY*=h),P.move(e,g,f),r.move(g,f),n.set(e,s),r}return n.worldBoxBounds};class Up extends Rh{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&At.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let e;"string"==typeof t?(e={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(e.fill="white",e.stroke="rgba(0,0,0,0.2)")):e=t,this.scrollXBar||this.addMany(this.scrollXBar=new Wh,this.scrollYBar=new Wh),e=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},e),e.height||(e.height=e.width),this.scrollXBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:o}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(o))return;this.scrollBounds=new ht(o);const r=n.bounds.clone().shrink(i),a=r.clone().add(o),h=this.ratioX=r.width/a.width,l=this.ratioY=r.height/a.height,d=(r.x-a.x)/a.width,c=(r.y-a.y)/a.height,u=h<1,_=l<1,{scrollXBar:p,scrollYBar:g}=this,{x:f,y:y,width:m,height:v}=r.shrink([2,_?g.width+6:2,u?p.height+6:2,2]);p.set({x:f+m*d,y:y+v+2,width:Math.max(m*h,e),visible:u}),g.set({x:f+m+2,y:y+v*c,height:Math.max(v*l,e),visible:_})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:e}=this;this.__eventIds=[t.on_(Ml.DRAG,this.onDrag,this),e.on_(Ml.DRAG,this.onDrag,this),t.on_(Ml.END,this.onDragEnd,this),e.on_(Ml.END,this.onDragEnd,this),this.target.on_(Jo.BEFORE,(()=>this.update(!0))),this.target.leafer.on_(Zo.RESIZE,(()=>this.update()))]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}Rt.add("scroll");class Gp extends lh{}function Zp(t){return Bn(t,(t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,zn(this)}}})))}let Kp=class extends Jh{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}};Nt([$n(Gp)],Kp.prototype,"__",void 0),Nt([Zp("angle")],Kp.prototype,"endArrow",void 0),Kp=Nt([ho()],Kp);const{M:qp,L:Jp,C:$p,Q:Qp,O:tg}=Qt,{rotate:eg,copyFrom:ig,scale:sg}=P,ng={},og={layout(t,e,i,s,n,o,r){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case qp:case Jp:rg(t,l+1,e,i,s,n,o,r),l+=3;break;case $p:for(h=1;h<6;h+=2)rg(t,l+h,e,i,s,n,o,r);l+=7;break;case Qp:for(h=1;h<4;h+=2)rg(t,l+h,e,i,s,n,o,r);l+=5;break;case tg:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),o&&(t[l+4]+=o,t[l+5]+=o),l+=7}},rotate(t,e,i){og.layout(t,0,0,1,1,e,i)}};function rg(t,e,i,s,n,o,r,a){ig(ng,t[e],t[e+1]),r&&eg(ng,r,a),n&&sg(ng,n,o),t[e]=i+ng.x,t[e+1]=s+ng.y}const{layout:ag,rotate:hg}=og,{getAngle:lg}=P,dg={x:-.5},cg={connect:dg,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},ug={connect:dg,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},_g={connect:dg,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},pg={connect:dg,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},gg={offset:dg,path:[..._g.path],dashPath:[1,-2.5,0,2,-1,0]};hg(gg.path,180,{x:-1.5,y:0});const fg={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},yg={connect:{x:.5},path:[...fg.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},mg={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},vg={path:[...mg.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},wg=At.clone(mg),xg=At.clone(vg);hg(wg.path,45),hg(xg.path,45);const bg={angle:cg,"angle-side":ug,arrow:pg,triangle:_g,"triangle-flip":gg,circle:yg,"circle-line":fg,square:vg,"square-line":mg,diamond:xg,"diamond-line":wg,mark:{offset:dg,path:[1,0,-2,2,0,2]}};function kg(t,e,i,s,n,o,r){const{strokeCap:a,strokeJoin:h}=t.__,{offset:l,connect:d,path:c,dashPath:u}="object"==typeof e?e:bg[e];let _=d?d.x:0,p=l?l.x:0;const g=[...c];return r&&u&&g.push(...u),"none"!==a&&(_-=.5),l&&("round"===h&&l.roundJoin?p+=l.roundJoin:"bevel"===h&&l.bevelJoin&&(p+=l.bevelJoin)),p&&ag(g,p,0),ag(g,s.x,s.y,n,n,lg(i,s)),o.x=(_+p)*n,g}const{M:Eg,L:Bg,C:Rg,Q:Og,Z:Lg,N:Cg,D:Tg,X:Sg,G:Pg,F:Mg,O:Ag,P:Dg,U:Ig}=Qt,{copy:Wg,copyFrom:Fg,getDistancePoint:zg}=P,Ng={},Yg={},Hg={},Xg={},Vg={},jg={list:bg,addArrows(t,e){const{startArrow:i,endArrow:s,strokeWidth:n,dashPattern:o,__pathForRender:r}=t.__;let a,h=0,l=r.length,d=0,c=i&&"none"!==i;for(;h<l;){switch(a=r[h],a){case Eg:case Bg:(d<2||h+6>=l)&&(Fg(Vg,r[h+1],r[h+2]),!d&&c&&Wg(Yg,Vg)),h+=3;break;case Rg:1!==d&&h+7!==l||Ug(r,Xg,Vg,h+3),h+=7;break;case Og:1!==d&&h+5!==l||Ug(r,Xg,Vg,h+1),h+=5;break;case Lg:return;case Cg:h+=5;break;case Tg:h+=9;break;case Sg:h+=6;break;case Pg:h+=9;break;case Mg:h+=5;break;case Ag:h+=7;break;case Dg:h+=4;break;case Ig:1!==d&&h+6!==l||Ug(r,Xg,Vg,h+1),h+=6}if(d++,1===d&&a!==Eg)return;if(2===d&&c&&Wg(Hg,a===Bg?Vg:Xg),h===l){const l=t.__.__pathForRender=e?[...r]:r,d=t.__.__pathForArrow=[];if(c){const e=kg(t,i,Hg,Yg,n,Ng,!!o);o?d.push(...e):l.push(...e),Ng.x&&(zg(Yg,Hg,-Ng.x,!0),l[1]=Hg.x,l[2]=Hg.y)}if(s&&"none"!==s){const e=kg(t,s,Xg,Vg,n,Ng,!!o);if(o?d.push(...e):l.push(...e),Ng.x){let t;switch(zg(Vg,Xg,-Ng.x,!0),a){case Bg:t=h-3+1;break;case Rg:t=h-7+5;break;case Og:t=h-5+3;break;case Ig:t=h-6+3}t&&Gg(l,Xg,t)}}}else Wg(Xg,Vg)}}};function Ug(t,e,i,s){Fg(e,t[s],t[s+1]),Fg(i,t[s+2],t[s+3])}function Gg(t,e,i){t[i]=e.x,t[i+1]=e.y}Rt.add("arrow"),Bh.addAttr("startArrow","none",Zp),Bh.addAttr("endArrow","none",Zp),Object.assign(Va,jg);const{Yes:Zg,NoAndSkip:Kg,YesAndSkip:qg}=Wt,Jg={},$g={},Qg={};class tf{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":Jg.id=t.substring(1),t=Jg;break;case".":$g.className=t.substring(1),t=$g;break;default:Qg.tag=t,t=Qg}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:s}=t,n=s instanceof Array;return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?At.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&xo.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===Zg||o===qg){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<Kg&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(jo.REMOVE,this.__onRemoveChild,this),this.target.on_(Uo.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const ef=Bh.prototype;function sf(i){return i.leafer?i.leafer.selector:t.selector||(t.selector=e.selector())}ef.find=function(t,e){return sf(this).getBy(t,this,!1,e)},ef.findOne=function(t,e){return sf(this).getBy(t,this,!0,e)},Rt.add("find"),e.finder=function(t){return new tf(t)};const{setPoint:nf,addPoint:of,toBounds:rf}=Y;const af={syncExport(i,s,n){let o;this.running=!0;const r=dn.fileType(s),h=s.includes(".");n=dn.getExportOptions(n);const{toURL:l}=t,{download:d}=t.origin;if("json"===r)h&&d(l(JSON.stringify(i.toJSON(n.json)),"text"),s),o={data:!!h||i.toJSON(n.json)};else if("svg"===r)h&&d(l(i.toSVG(),"svg"),s),o={data:!!h||i.toSVG()};else{let t,r,h=1,l=1;const{worldTransform:d,isLeafer:c,leafer:u,isFrame:_}=i,{slice:p,trim:g,padding:f,onCanvas:y}=n,m=void 0===n.smooth?!u||u.config.smooth:n.smooth,v=n.contextSettings||(u?u.config.contextSettings:void 0),w=n.screenshot||i.isApp,x=c&&w&&void 0===n.fill?i.fill:n.fill,b=dn.isOpaqueImage(s)||x,k=new z;if(w)t=!0===w?c?u.canvas.bounds:i.worldRenderBounds:w;else{let e=n.relative||(c?"inner":"local");switch(h=d.scaleX,l=d.scaleY,e){case"inner":k.set(d);break;case"local":k.set(d).divide(i.localTransform),h/=i.scaleX,l/=i.scaleY;break;case"world":h=1,l=1;break;case"page":e=u||i;default:k.set(d).divide(i.getTransform(e));const t=e.worldTransform;h/=h/t.scaleX,l/=l/t.scaleY}t=i.getBounds("render",e)}const E={scaleX:1,scaleY:1};a.getScaleData(n.scale,n.size,t,E);let B=n.pixelRatio||1;i.isApp&&(E.scaleX*=B,E.scaleY*=B,B=i.app.pixelRatio);const{x:R,y:O,width:L,height:C}=new ht(t).scale(E.scaleX,E.scaleY),T={matrix:k.scale(1/E.scaleX,1/E.scaleY).invert().translate(-R,-O).withScale(1/h*E.scaleX,1/l*E.scaleY)};let S,P=e.canvas({width:Math.floor(L),height:Math.floor(C),pixelRatio:B,smooth:m,contextSettings:v});if(p&&(S=i,S.__worldOpacity=0,i=u||i,T.bounds=P.bounds),P.save(),_&&void 0!==x){const t=i.get("fill");i.fill="",i.__render(P,T),i.fill=t}else i.__render(P,T);if(P.restore(),S&&S.__updateWorldOpacity(),g){r=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?of(r,n,o):nf(r={},n,o)),a++;const h=new ht;return rf(r,h),h.scale(1/t.pixelRatio).ceil()}(P);const t=P,{width:i,height:s}=r,n={x:0,y:0,width:i,height:s,pixelRatio:B};P=e.canvas(n),P.copyWorld(t,r,n)}if(f){const[t,i,s,n]=a.fourNumber(f),o=P,{width:r,height:h}=o;P=e.canvas({width:r+n+i,height:h+t+s,pixelRatio:B}),P.copyWorld(o,o.bounds,{x:n,y:t,width:r,height:h})}b&&P.fillWorld(P.bounds,x||"#FFFFFF","destination-over"),y&&y(P);o={data:"canvas"===s?P:P.export(s,n),width:P.pixelWidth,height:P.pixelHeight,renderBounds:t,trimBounds:r}}return this.running=!1,o},export(e,i,s){return this.running=!0,function(t){hf||(hf=new pn);return new Promise((e=>{hf.add((()=>Yt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=()=>Yt(this,void 0,void 0,(function*(){if(!fn.isComplete)return t.requestRender(r);const a=af.syncExport(e,i,s);a.data instanceof Promise&&(a.data=yield a.data),n(a),o()}));e.updateLayout(),lf(e);const{leafer:a}=e;a?a.waitViewCompleted(r):r()}))))}};let hf;function lf(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>lf(t)))}const df=qt.prototype,cf=vt.get("@leafer-in/export");df.export=function(t,e){const{quality:i,blob:s}=dn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},df.toBlob=function(e,i){return new Promise((s=>{t.origin.canvasToBolb(this.view,e,i).then((t=>{s(t)})).catch((t=>{cf.error(t),s(null)}))}))},df.toDataURL=function(e,i){return t.origin.canvasToDataURL(this.view,e,i)},df.saveAs=function(e,i){return new Promise((s=>{t.origin.canvasSaveAs(this.view,e,i).then((()=>{s(!0)})).catch((t=>{cf.error(t),s(!1)}))}))},Rt.add("export"),Object.assign(qa,af),Bh.prototype.export=function(t,e){return qa.export(this,t,e)},Bh.prototype.syncExport=function(t,e){return qa.syncExport(this,t,e)};const uf={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},_f={top:"flex-start",middle:"center",bottom:"flex-end"};function pf(t,e,i){const{style:s}=t,{fill:n,padding:o,textWrap:r,textOverflow:a,textDecoration:h}=e;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";e instanceof Array&&(e=e[0]);if("object"==typeof e)switch(e.type){case"solid":i=Ha.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Ha.string("string"==typeof t?t:t.color);break;default:void 0!==e.r&&(i=Ha.string(e))}else i=e;t.color=i}(s,n),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,s.textDecoration="delete"===h?"line-through":h,s.textTransform=uf[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=_f[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px","none"===r?s.whiteSpace="nowrap":"break"===r&&(s.wordBreak="break-all"),s.textIndent=(e.paraIndent||0)*i+"px",s.padding=o instanceof Array?o.map((t=>t*i+"px")).join(" "):(o||0)*i+"px",s.textOverflow="show"===a?"":"hide"===a?"clip":a}let gf=class extends Z_{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:t}=this,{config:e}=t.app,i=this.editTarget;i.visible=!1,this.isHTMLText=!(i instanceof bl),this._keyEvent=e.keyEvent,e.keyEvent=!1;const s=this.editDom=document.createElement("div"),{style:n}=s;s.contentEditable="true",n.position="fixed",n.transformOrigin="left top",n.boxSizing="border-box",this.isHTMLText?s.innerHTML=String(i.text):s.innerText=String(i.text);const{view:o}=t.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(s):o.appendChild(s),this.eventIds=[t.app.on_(Tl.DOWN,(e=>{let i,{target:n}=e.origin;for(;n;)n===s&&(i=!0),n=n.parentElement;i||t.closeInnerEditor()}))],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),s.addEventListener("focus",this.onFocus),s.addEventListener("input",this.onInput),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const r=window.getSelection(),a=document.createRange();if(this.config.selectAll)a.selectNodeContents(s);else{const t=s.childNodes[0];a.setStartAfter(t),a.setEndAfter(t),a.collapse(!0)}r.removeAllRanges(),r.addRange(a)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=window.getSelection().getRangeAt(0);i.deleteContents(),i.insertNode(e),i.setStartAfter(e),i.setEndAfter(e),this.onInput()}}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;const{a:i,b:s,c:n,d:o,e:r,f:a}=new z(t.worldTransform).scale(1/e);let{x:h,y:l}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds;this.inBody||(h-=window.scrollX,l-=window.scrollY);let{width:d,height:c}=t;d*=e,c*=e;const u=t.__;if(u.__autoWidth&&u.autoSizeAlign)switch(d+=20,u.textAlign){case"center":h-=d/2;break;case"right":h-=d}if(u.__autoHeight&&u.autoSizeAlign)switch(c+=20,u.verticalAlign){case"middle":l-=c/2;break;case"bottom":l-=c}const{style:_}=this.editDom;_.transform=`matrix(${i},${s},${n},${o},${r},${a})`,_.left=h+"px",_.top=l+"px",_.width=d+"px",_.height=c+"px",this.isHTMLText||pf(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),t.visible=!0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}};gf=Nt([F_()],gf),Rt.add("text-editor","editor");class ff extends mh{setText(t){this._text=t,this.__htmlChanged=!0}}let yf=class extends pl{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),o=s+10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${n}">\n <foreignObject width="${o}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),t.__naturalWidth=o/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}};Nt([$n(ff)],yf.prototype,"__",void 0),Nt([Mn("")],yf.prototype,"text",void 0),Nt([Ln("TextEditor")],yf.prototype,"editInner",void 0),yf=Nt([ho()],yf),Rt.add("html");export{yt as AlignHelper,Wt as Answer,Bl as App,pt as AroundHelper,Kp as Arrow,Gp as ArrowData,dt as AutoBounds,Be as BezierHelper,ht as Bounds,nt as BoundsHelper,Wh as Box,rh as BoxData,ua as Branch,To as BranchHelper,Pr as BranchRender,fl as Canvas,vh as CanvasData,Mt as CanvasManager,jo as ChildEvent,Ha as ColorConvert,e as Creator,nd as Cursor,At as DataHelper,vt as Debug,ct as Direction4,ut as Direction9,Ml as DragEvent,Gl as Dragger,Dl as DropEvent,R_ as EditBox,m_ as EditDataHelper,k_ as EditPoint,a_ as EditSelect,s_ as EditSelectHelper,K_ as EditTool,z_ as EditToolCreator,G_ as Editor,Hu as EditorEvent,H_ as EditorGroupEvent,D_ as EditorHelper,Xu as EditorMoveEvent,ju as EditorRotateEvent,Vu as EditorScaleEvent,Uu as EditorSkewEvent,Za as Effect,Hh as Ellipse,ch as EllipseData,Ae as EllipseHelper,Vo as Event,St as EventCreator,tr as Eventer,qa as Export,dn as FileHelper,Ka as Filter,tf as Finder,Fh as Frame,hh as FrameData,Rh as Group,oh as GroupData,yf as HTMLText,ff as HTMLTextData,od as HitCanvasManager,pl as Image,mh as ImageData,Go as ImageEvent,mn as ImageManager,i as IncrementId,Z_ as InnerEditor,Y_ as InnerEditorEvent,sd as InteractionBase,Yl as InteractionHelper,Nl as KeyEvent,Ol as Keyboard,qo as LayoutEvent,Pa as Layouter,ia as Leaf,Cr as LeafBounds,Lo as LeafBoundsHelper,It as LeafData,pr as LeafDataProxy,cr as LeafEventer,xo as LeafHelper,Xo as LeafLayout,pa as LeafLevelList,_a as LeafList,xr as LeafMatrix,Tr as LeafRender,Ch as Leafer,fa as LeaferCanvas,qt as LeaferCanvasBase,ah as LeaferData,$o as LeaferEvent,bn as LeaferImage,Pp as LeaferTypeCreator,Jh as Line,lh as LineData,ep as LineEditTool,a as MathHelper,z as Matrix,x as MatrixHelper,Il as MoveEvent,Dp as MultiTouchHelper,Al as MyDragEvent,gl as MyImage,Sl as MyPointerEvent,ee as NeedConvertToCanvasCommandMap,h as OneRadian,l as PI2,d as PI_2,ja as Paint,Ga as PaintGradient,Ua as PaintImage,kl as Path,Va as PathArrow,jg as PathArrowModule,Js as PathBounds,Yi as PathCommandDataHelper,Qt as PathCommandMap,mi as PathConvert,rn as PathCorner,ns as PathCreator,ph as PathData,vs as PathDrawer,Jt as PathHelper,og as PathMatrixHelper,oe as PathNumberCommandLengthMap,ne as PathNumberCommandMap,El as Pen,gh as PenData,Ia as Picker,t as Platform,Rt as Plugin,W as Point,P as PointHelper,Ll as PointerButton,Tl as PointerEvent,rl as Polygon,uh as PolygonData,Uo as PropertyEvent,Th as Rect,dh as RectData,re as RectHelper,kh as RectRender,Jo as RenderEvent,Aa as Renderer,Zo as ResizeEvent,fn as Resource,Wl as RotateEvent,kt as Run,Up as ScrollBar,i_ as SelectArea,Wa as Selector,_l as Star,_h as StarData,Ja as State,mt as StringNumberMap,e_ as Stroker,Fl as SwipeEvent,_n as TaskItem,pn as TaskProcessor,bl as Text,Ya as TextConvert,yh as TextData,gf as TextEditor,Wp as Transformer,$a as Transition,Y as TwoPointBoundsHelper,Bh as UI,wh as UIBounds,Lt as UICreator,sh as UIData,Cl as UIEvent,xh as UIRender,Xa as UnitConvert,Ao as WaitHelper,Ko as WatchEvent,wa as Watcher,Ip as WheelEventHelper,zl as ZoomEvent,Cp as addViewport,Tp as addViewportConfig,Yn as affectRenderBoundsType,Fn as affectStrokeBoundsType,Zp as arrowType,Rn as attr,Tn as autoLayoutType,Mn as boundsType,ln as canvasPatch,Kt as canvasSizeAttrs,Jn as cursorType,$n as dataProcessor,Ln as dataType,Bn as decorateLeafAttr,to as defineDataProcessor,kn as defineKey,On as defineLeafAttr,Dn as doBoundsType,zn as doStrokeType,Fa as effectType,Ft as emptyData,Kn as eraserType,u as getBoundsData,En as getDescriptor,_ as getMatrixData,c as getPointData,qn as hitType,zt as isNull,Qn as layoutProcessor,Zn as maskType,An as naturalBoundsType,Xn as opacityType,In as pathInputType,Wn as pathType,an as pen,Cn as positionType,W_ as registerEditTool,F_ as registerInnerEditor,ho as registerUI,lo as registerUIEvent,za as resizeType,no as rewrite,oo as rewriteAble,Pn as rotationType,Sn as scaleType,Gn as sortType,Nn as strokeType,Hn as surfaceType,lt as tempBounds,N as tempMatrix,F as tempPoint,ma as useCanvas,ao as useModule,ga as version,Vn as visibleType,Na as zoomLayerType};
1
+ const t={toURL(t,e){let i=encodeURIComponent(t);return"text"===e?i="data:text/plain;charset=utf-8,"+i:"svg"===e&&(i="data:image/svg+xml,"+i),i},image:{hitCanvasSize:100,maxCacheSize:4096e3,maxPatternSize:8847360,crossOrigin:"anonymous",getRealURL(e){const{prefix:i,suffix:s}=t.image;return!s||e.startsWith("data:")||e.startsWith("blob:")||(e+=(e.includes("?")?"&":"?")+s),i&&"/"===e[0]&&(e=i+e),e}}},e={},i={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=s;return e[t]?e[t]++:(e[t]=1,0)}},s=i,{round:n,pow:o,PI:r}=Math,a={within:(t,e,i)=>("object"==typeof e&&(i=e.max,e=e.min),void 0!==e&&t<e&&(t=e),void 0!==i&&t>i&&(t=i),t),fourNumber(t,e){let i;if(t instanceof Array)switch(t.length){case 4:i=void 0===e?t:[...t];break;case 2:i=[t[0],t[1],t[0],t[1]];break;case 3:i=[t[0],t[1],t[2],t[1]];break;case 1:t=t[0];break;default:t=0}if(i||(i=[t,t,t,t]),e)for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),a.float(t)),getGapRotation(t,e,i=0){let s=t+i;if(e>1){const t=Math.abs(s%e);(t<1||t>e-1)&&(s=Math.round(s/e)*e)}return s-i},float(t,e){const i=void 0!==e?o(10,e):1e12;return-0===(t=n(t*i)/i)?0:t},getScaleData(t,e,i,s){if(s||(s={}),e){const t=("number"==typeof e?e:e.width||0)/i.width,n=("number"==typeof e?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&a.assignScale(s,t);return s},assignScale(t,e){"number"==typeof e?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)}},h=r/180,l=2*r,d=r/2;function c(){return{x:0,y:0}}function u(){return{x:0,y:0,width:0,height:0}}function _(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:p,cos:g,acos:f,sqrt:y}=Math,{float:m}=a,v={};function w(){return Object.assign(Object.assign(Object.assign({},{a:1,b:0,c:0,d:1,e:0,f:0}),{x:0,y:0,width:0,height:0}),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0})}const x={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:w(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,o=0,r=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=o,t.f=r},get:_,getWorld:w,copy(t,e){t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f},translate(t,e,i){t.e+=e,t.f+=i},translateInner(t,e,i,s){t.e+=t.a*e+t.c*i,t.f+=t.b*e+t.d*i,s&&(t.e-=e,t.f-=i)},scale(t,e,i=e){t.a*=e,t.b*=e,t.c*=i,t.d*=i},scaleOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.scaleOfInner(t,v,i,s)},scaleOfInner(t,e,i,s=i){b.translateInner(t,e.x,e.y),b.scale(t,i,s),b.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:o}=t,r=g(e*=h),a=p(e);t.a=i*r-s*a,t.b=i*a+s*r,t.c=n*r-o*a,t.d=n*a+o*r},rotateOfOuter(t,e,i){b.toInnerPoint(t,e,v),b.rotateOfInner(t,v,i)},rotateOfInner(t,e,i){b.translateInner(t,e.x,e.y),b.rotate(t,i),b.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:o,d:r}=t;i&&(i*=h,t.a=s+o*i,t.b=n+r*i),e&&(e*=h,t.c=o+s*e,t.d=r+n*e)},skewOfOuter(t,e,i,s){b.toInnerPoint(t,e,v),b.skewOfInner(t,v,i,s)},skewOfInner(t,e,i,s=0){b.translateInner(t,e.x,e.y),b.skew(t,i,s),b.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:o,e:r,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*n+r,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,n,o){let{e:r,f:a}=t;if(o&&(r+=o.scrollX,a+=o.scrollY),i||(i=t),void 0===s&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:r,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=r*e.a+a*e.c,i.d=r*e.b+a*e.d,n&&(i.scaleX=e.scaleX*n.scaleX,i.scaleY=e.scaleY*n.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,n&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=r*e.a+a*e.c+e.e,i.f=r*e.b+a*e.d+e.f},divide(t,e){b.multiply(t,b.tempInvert(e))},divideParent(t,e){b.multiplyParent(t,b.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=b;return b.copy(e,t),b.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:o,f:r}=t;if(i||s){const a=1/(e*n-i*s);t.a=n*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*n-r*s)*a,t.f=-(r*e-o*i)*a}else if(1===e&&1===n)t.e=-o,t.f=-r;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-o*n*i,t.f=-r*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:o}=e;i||(i=e),i.x=n*t.a+o*t.c,i.y=n*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:o,c:r,d:a}=t,h=1/(n*a-o*r),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*r)*h,i.y=(d*n-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*r)*h,i.y-=(s*n-e*o)*h}},setLayout(t,e,i,s,n){const{x:o,y:r,scaleX:a,scaleY:l}=e;if(void 0===n&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,o=i*h,r=g(o),d=p(o);if(s||n){const e=s*h,i=n*h;t.a=(r+i*-d)*a,t.b=(d+i*r)*a,t.c=(e*r-d)*l,t.d=(r+e*d)*l}else t.a=r*a,t.b=d*a,t.c=-d*l,t.d=r*l}else t.a=a,t.b=0,t.c=0,t.d=l;t.e=o,t.f=r,(i=i||s)&&b.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:o,c:r,d:a,e:l,f:c}=t;let u,_,v,w,x,b=l,k=c;if(o||r){const t=n*a-o*r;if(r&&!s){u=y(n*n+o*o),_=t/u;const e=n/u;v=o>0?f(e):-f(e)}else{_=y(r*r+a*a),u=t/_;const e=r/_;v=d-(a>0?f(-e):-f(e))}const e=m(g(v)),i=p(v);u=m(u),_=m(_),w=e?m((r/_+i)/e/h,9):0,x=e?m((o/u-i)/e/h,9):0,v=m(v/h)}else u=n,_=a,v=w=x=0;return(e=i||e)&&(b+=e.x*n+e.y*r,k+=e.x*o+e.y*a,i||(b-=e.x,k-=e.y)),{x:b,y:k,scaleX:u,scaleY:_,rotation:v,skewX:w,skewY:x}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:o,d:r}=t;n||o?i=(s*r-n*o)/(e=y(s*s+n*n)):(e=s,i=r)}return s.scaleX=e,s.scaleY=i,s},reset(t){b.set(t)}},b=x,{toInnerPoint:k,toOuterPoint:E}=x,{sin:B,cos:R,abs:C,sqrt:L,atan2:O,min:T,PI:S}=Math,P={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,i=0){t.x=e,t.y=i},setRadius(t,e,i){t.radiusX=e,t.radiusY=void 0===i?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},move(t,e,i){t.x+=e,t.y+=i},scale(t,e,i=e){t.x&&(t.x*=e),t.y&&(t.y*=i)},scaleOf(t,e,i,s=i){t.x+=(t.x-e.x)*(i-1),t.y+=(t.y-e.y)*(s-1)},rotate(t,e,i){i||(i=M.defaultPoint);const s=R(e*=h),n=B(e),o=t.x-i.x,r=t.y-i.y;t.x=i.x+o*s-r*n,t.y=i.y+o*n+r*s},tempToInnerOf(t,e){const{tempPoint:i}=M;return D(i,t),k(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=M;return D(i,t),E(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=M;return D(i,t),M.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),k(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){k(e,t,i)},toOuterOf(t,e,i){E(e,t,i)},getCenter:(t,e)=>({x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}),getCenterX:(t,e)=>t+(e-t)/2,getCenterY:(t,e)=>t+(e-t)/2,getDistance:(t,e)=>A(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=C(i-t),o=C(s-e);return L(n*n+o*o)},getMinDistanceFrom:(t,e,i,s,n,o)=>T(A(t,e,i,s),A(i,s,n,o)),getAngle:(t,e)=>I(t,e)/h,getRotation:(t,e,i,s)=>(s||(s=e),M.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/h),getRadianFrom(t,e,i,s,n,o,r,a){void 0===r&&(r=i,a=s);let h=O(e-s,t-i);const d=O(o-a,n-r)-h;return d<-S?d+l:d},getAtan2:(t,e)=>O(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s){const n=I(t,e);return(e=s?e:{}).x=t.x+R(n)*i,e.y=t.y+B(n)*i,e},toNumberPoints(t){let e=t;return"object"==typeof t[0]&&(e=[],t.forEach((t=>e.push(t.x,t.y)))),e},reset(t){M.reset(t)}},M=P,{getDistanceFrom:A,copy:D,getAtan2:I}=M;class W{constructor(t,e){this.set(t,e)}set(t,e){return"object"==typeof t?P.copy(this,t):P.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new W(this)}move(t,e){return P.move(this,t,e),this}scale(t,e){return P.scale(this,t,e),this}scaleOf(t,e,i){return P.scaleOf(this,t,e,i),this}rotate(t,e){return P.rotate(this,t,e),this}rotateOf(t,e){return P.rotate(this,e,t),this}getRotation(t,e,i){return P.getRotation(this,t,e,i)}toInnerOf(t,e){return P.toInnerOf(this,t,e),this}toOuterOf(t,e){return P.toOuterOf(this,t,e),this}getCenter(t){return new W(P.getCenter(this,t))}getDistance(t){return P.getDistance(this,t)}getDistancePoint(t,e,i){return new W(P.getDistancePoint(this,t,e,i))}getAngle(t){return P.getAngle(this,t)}getAtan2(t){return P.getAtan2(this,t)}reset(){return P.reset(this),this}}const F=new W;class z{constructor(t,e,i,s,n,o){this.set(t,e,i,s,n,o)}set(t,e,i,s,n,o){return"object"==typeof t?x.copy(this,t):x.set(this,t,e,i,s,n,o),this}setWith(t){return x.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:n,f:o}=this;return{a:t,b:e,c:i,d:s,e:n,f:o}}clone(){return new z(this)}translate(t,e){return x.translate(this,t,e),this}translateInner(t,e){return x.translateInner(this,t,e),this}scale(t,e){return x.scale(this,t,e),this}scaleWith(t,e){return x.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}scaleOfOuter(t,e,i){return x.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return x.scaleOfInner(this,t,e,i),this}rotate(t){return x.rotate(this,t),this}rotateOfOuter(t,e){return x.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return x.rotateOfInner(this,t,e),this}skew(t,e){return x.skew(this,t,e),this}skewOfOuter(t,e,i){return x.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return x.skewOfInner(this,t,e,i),this}multiply(t){return x.multiply(this,t),this}multiplyParent(t){return x.multiplyParent(this,t),this}divide(t){return x.divide(this,t),this}divideParent(t){return x.divideParent(this,t),this}invert(){return x.invert(this),this}invertWith(){return x.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){x.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){x.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return x.setLayout(this,t,e,i),this}getLayout(t,e,i){return x.getLayout(this,t,e,i)}withScale(t,e){return x.withScale(this,t,e)}reset(){x.reset(this)}}const N=new z,Y={tempPointBounds:{},setPoint(t,e,i){t.minX=t.maxX=e,t.minY=t.maxY=i},addPoint(t,e,i){t.minX=e<t.minX?e:t.minX,t.minY=i<t.minY?i:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=i>t.maxY?i:t.maxY},addBounds(t,e,i,s,n){X(t,e,i),X(t,e+s,i+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:X}=Y,{tempPointBounds:H,setPoint:V,addPoint:j,toBounds:U}=Y,{toOuterPoint:G}=x,{float:Z,fourNumber:K}=a,{floor:q,ceil:J}=Math;let $,Q,tt,et;const it={},st={},nt={tempBounds:{},set(t,e=0,i=0,s=0,n=0){t.x=e,t.y=i,t.width=s,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,n){const{x:o,y:r,width:a,height:h}=e;if(i instanceof Array){const e=K(i);s?ot.set(t,o+e[3],r+e[0],a-e[1]-e[3],h-e[2]-e[0]):ot.set(t,o-e[3],r-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),ot.set(t,o-i,r-i,a+2*i,h+2*i);n&&("width"===n?(t.y=r,t.height=h):(t.x=o,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},getByMove:(t,e,i)=>(t=Object.assign({},t),ot.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?at(e,t):e=t,i?(e.offsetX=-(ot.maxX(i)-t.x),e.offsetY=-(ot.maxY(i)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),ot.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e){P.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){P.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(ot.copy(ot.tempBounds,t),ot.toOuterOf(ot.tempBounds,e),ot.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),ot.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n}=e;s>0?(i.width=t.width*s,i.x=e.e+t.x*s):(i.width=t.width*-s,i.x=e.e+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=e.f+t.y*n):(i.height=t.height*-n,i.y=e.f+t.y*n-i.height)}else it.x=t.x,it.y=t.y,G(e,it,st),V(H,st.x,st.y),it.x=t.x+t.width,G(e,it,st),j(H,st.x,st.y),it.y=t.y+t.height,G(e,it,st),j(H,st.x,st.y),it.x=t.x,G(e,it,st),j(H,st.x,st.y),U(H,i)},toInnerOf(t,e,i){i||(i=t),ot.move(i,-e.e,-e.f),ot.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Math.min(t.width/e.width,t.height/e.height));return new z(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e,i){const s={};return ot.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){ot.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){ot.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=q(t.x),t.y=q(t.y),t.width=e>t.x?J(t.width+e-t.x):J(t.width),t.height=i>t.y?J(t.height+i-t.y):J(t.height)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},float(t,e){t.x=Z(t.x,e),t.y=Z(t.y,e),t.width=Z(t.width,e),t.height=Z(t.height,e)},add(t,e,i){$=t.x+t.width,Q=t.y+t.height,tt=e.x,et=e.y,i||(tt+=e.width,et+=e.height),$=$>tt?$:tt,Q=Q>et?Q:et,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=$-t.x,t.height=Q-t.y},addList(t,e){ot.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){ot.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){ot.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,o=!0;for(let r=0,a=e.length;r<a;r++)n=i?i(e[r]):e[r],n&&(n.width||n.height)&&(o?(o=!1,s||at(t,n)):rt(t,n));o&&ot.reset(t)},setPoints(t,e){e.forEach(((t,e)=>0===e?V(H,t.x,t.y):j(H,t.x,t.y))),U(H,t)},setPoint(t,e){ot.set(t,e.x,e.y)},addPoint(t,e){rt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]},hitRadiusPoint:(t,e,i)=>(i&&(e=P.tempToInnerRadiusPointOf(e,i)),e.x>=t.x-e.radiusX&&e.x<=t.x+t.width+e.radiusX&&e.y>=t.y-e.radiusY&&e.y<=t.y+t.height+e.radiusY),hitPoint:(t,e,i)=>(i&&(e=P.tempToInnerOf(e,i)),e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height),hit:(t,e,i)=>(i&&(e=ot.tempToOuterOf(e,i)),!(t.y+t.height<e.y||e.y+e.height<t.y||t.x+t.width<e.x||e.x+e.width<t.x)),includes:(t,e,i)=>(i&&(e=ot.tempToOuterOf(e,i)),t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height),getIntersectData(t,e,i){if(i&&(e=ot.tempToOuterOf(e,i)),!ot.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:o,height:r}=e;return $=s+o,Q=n+r,tt=t.x+t.width,et=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,$=$<tt?$:tt,Q=Q<et?Q:et,o=$-s,r=Q-n,{x:s,y:n,width:o,height:r}},intersect(t,e,i){ot.copy(t,ot.getIntersectData(t,e,i))},isSame:(t,e)=>t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height,isEmpty:t=>0===t.x&&0===t.y&&0===t.width&&0===t.height,reset(t){ot.set(t)}},ot=nt,{add:rt,copy:at}=ot;class ht{get minX(){return nt.minX(this)}get minY(){return nt.minY(this)}get maxX(){return nt.maxX(this)}get maxY(){return nt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return"object"==typeof t?nt.copy(this,t):nt.set(this,t,e,i,s),this}get(){const{x:t,y:e,width:i,height:s}=this;return{x:t,y:e,width:i,height:s}}clone(){return new ht(this)}move(t,e){return nt.move(this,t,e),this}scale(t,e){return nt.scale(this,t,e),this}scaleOf(t,e,i){return nt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return nt.toOuterOf(this,t,e),this}toInnerOf(t,e){return nt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return nt.getFitMatrix(this,t,e)}spread(t,e){return nt.spread(this,t,e),this}shrink(t,e){return nt.shrink(this,t,e),this}ceil(){return nt.ceil(this),this}unsign(){return nt.unsign(this),this}float(t){return nt.float(this,t),this}add(t){return nt.add(this,t),this}addList(t){return nt.setList(this,t,!0),this}setList(t){return nt.setList(this,t),this}addListWithFn(t,e){return nt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return nt.setListWithFn(this,t,e),this}setPoint(t){return nt.setPoint(this,t),this}setPoints(t){return nt.setPoints(this,t),this}addPoint(t){return nt.addPoint(this,t),this}getPoints(){return nt.getPoints(this)}hitPoint(t,e){return nt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return nt.hitRadiusPoint(this,t,e)}hit(t,e){return nt.hit(this,t,e)}includes(t,e){return nt.includes(this,t,e)}intersect(t,e){return nt.intersect(this,t,e),this}getIntersect(t,e){return new ht(nt.getIntersectData(this,t,e))}isSame(t){return nt.isSame(this,t)}isEmpty(){return nt.isEmpty(this)}reset(){nt.reset(this)}}const lt=new ht;class dt{constructor(t,e,i,s,n,o){"object"==typeof t?this.copy(t):this.set(t,e,i,s,n,o)}set(t=0,e=0,i=0,s=0,n=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=t;this.set(e,i,s,n,o,r)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=this;return new ht(n,e,o||t.width-n-i,r||t.height-e-s)}}var ct,ut;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(ct||(ct={})),function(t){t[t.topLeft=0]="topLeft",t[t.top=1]="top",t[t.topRight=2]="topRight",t[t.right=3]="right",t[t.bottomRight=4]="bottomRight",t[t.bottom=5]="bottom",t[t.bottomLeft=6]="bottomLeft",t[t.left=7]="left",t[t.center=8]="center",t[t["top-left"]=0]="top-left",t[t["top-right"]=2]="top-right",t[t["bottom-right"]=4]="bottom-right",t[t["bottom-left"]=6]="bottom-left"}(ut||(ut={}));const _t=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:1,y:.5},{x:1,y:1},{x:.5,y:1},{x:0,y:1},{x:0,y:.5},{x:.5,y:.5}];_t.forEach((t=>t.type="percent"));const pt={directionData:_t,tempPoint:{},get:gt,toPoint(t,e,i,s,n){const o=gt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,n&&(i.x-=n.x,i.y-=n.y,o.x&&(i.x-=1===o.x?n.width:.5===o.x?o.x*n.width:0),o.y&&(i.y-=1===o.y?n.height:.5===o.y?o.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)}};function gt(t){return"string"==typeof t?_t[ut[t]]:t}const{toPoint:ft}=pt,yt={toPoint(t,e,i,s,n){ft(t,i,s,n,e)}},mt={0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,".":1,e:1,E:1};class vt{constructor(t){this.repeatMap={},this.name=t}static get(t){return new vt(t)}static set filter(t){this.filterList=wt(t)}static set exclude(t){this.excludeList=wt(t)}log(...t){if(xt.enable){if(xt.filterList.length&&xt.filterList.every((t=>t!==this.name)))return;if(xt.excludeList.length&&xt.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){xt.enable&&this.warn(...t)}warn(...t){xt.showWarn&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}function wt(t){return t?"string"==typeof t&&(t=[t]):t=[],t}vt.filterList=[],vt.excludeList=[],vt.showWarn=!0;const xt=vt,bt=vt.get("RunTime"),kt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const s=i.create(i.RUNTIME);return Et.currentId=Et.idMap[s]=e?performance.now():Date.now(),Et.currentName=Et.nameMap[s]=t,Et.nameToIdMap[t]=s,s},end(t,e){const i=Et.idMap[t],s=Et.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;Et.idMap[t]=Et.nameMap[t]=Et.nameToIdMap[s]=void 0,bt.log(s,n,"ms")},endOfName(t,e){const i=Et.nameToIdMap[t];void 0!==i&&Et.end(i,e)}},Et=kt,Bt=[],Rt={list:{},add(t,...e){this.list[t]=!0,Bt.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("need plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout((()=>Bt.forEach((t=>Rt.has(t,!0)))));const Ct=vt.get("UICreator"),Lt={list:{},register(t){const{__tag:e}=t.prototype;Ot[e]&&Ct.repeat(e),Ot[e]=t},get(t,e,i,s,n,o){Ot[t]||Ct.error("not register "+t);const r=new Ot[t](e);return void 0!==i&&(r.x=i,s&&(r.y=s),n&&(r.width=n),o&&(r.height=o)),r}},{list:Ot}=Lt,Tt=vt.get("EventCreator"),St={nameList:{},register(t){let e;Object.keys(t).forEach((i=>{e=t[i],"string"==typeof e&&(Pt[e]&&Tt.repeat(e),Pt[e]=t)}))},changeName(t,e){const i=Pt[t];if(i){const s=Object.keys(i).find((e=>i[e]===t));s&&(i[s]=e,Pt[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new Pt[t](...e)},{nameList:Pt}=St;class Mt{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let i;const{list:s}=this;for(let e=0,n=s.length;e<n;e++)if(i=s[e],i.recycled&&i.isSameSize(t))return i.recycled=!1,i.manager||(i.manager=this),i;const n=e.canvas(t);return this.add(n),n}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let i=0,s=this.list.length;i<s;i++)t=this.list[i],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach((t=>{t.destroy()})),this.list.length=0}destroy(){this.clear()}}const At={default:(t,e)=>(Dt(e,t),Dt(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach((n=>{var o,r;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(o=t[n])||void 0===o?void 0:o.constructor)===Object)return Dt(t[n],e[n],i&&i[n]);i&&n in i?(null===(r=i[n])||void 0===r?void 0:r.constructor)===Object&&Dt(t[n]={},e[n],i[n]):t[n]=e[n]}))},copyAttrs:(t,e,i)=>(i.forEach((i=>{void 0!==e[i]&&(t[i]=e[i])})),t),clone:t=>JSON.parse(JSON.stringify(t)),toMap(t){const e={};for(let i=0,s=t.length;i<s;i++)e[t[i]]=!0;return e}},{assign:Dt}=At;class It{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(void 0!==e)return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let i;for(let s in this)"_"!==s[0]&&(i=e?e[s]:void 0,t[s]=void 0===i?this[s]:i);return t}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];if(void 0!==e)return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(t instanceof Array)for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let n in this)if("_"!==n[0]&&(t=this["_"+n],void 0!==t)){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=void 0===e?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:o,f:r}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:o,f:r}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}var Wt;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(Wt||(Wt={}));const Ft={};function zt(t){return null==t}function Nt(t){return"{}"===JSON.stringify(t)}function Yt(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,i,r):n(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}function Xt(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}function Ht(t){return(e,i)=>{t||(t=i),Object.defineProperty(e,i,{get(){return this.context[t]},set(e){this.context[t]=e}})}}"function"==typeof SuppressedError&&SuppressedError;const Vt=[];function jt(){return(t,e)=>{Vt.push(e)}}const Ut=[];let Gt=class{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||Ut)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Vt.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))})),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,o){"object"==typeof t?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,i,s){}strokeRect(t,e,i,s){}clearRect(t,e,i,s){}drawImage(t,e,i,s,n,o,r,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,o+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,r+=t,h-=t}this.context.drawImage(t,e,i,s,n,o,r,a,h);break;case 5:this.context.drawImage(t,e,i,s,n);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,n,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,o){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,o,r,a){}rect(t,e,i,s){}roundRect(t,e,i,s,n){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,n,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}};Yt([Ht("imageSmoothingEnabled")],Gt.prototype,"smooth",void 0),Yt([Ht("imageSmoothingQuality")],Gt.prototype,"smoothLevel",void 0),Yt([Ht("globalAlpha")],Gt.prototype,"opacity",void 0),Yt([Ht()],Gt.prototype,"fillStyle",void 0),Yt([Ht()],Gt.prototype,"strokeStyle",void 0),Yt([Ht("lineWidth")],Gt.prototype,"strokeWidth",void 0),Yt([Ht("lineCap")],Gt.prototype,"strokeCap",void 0),Yt([Ht("lineJoin")],Gt.prototype,"strokeJoin",void 0),Yt([Ht("lineDashOffset")],Gt.prototype,"dashOffset",void 0),Yt([Ht()],Gt.prototype,"miterLimit",void 0),Yt([Ht()],Gt.prototype,"shadowBlur",void 0),Yt([Ht()],Gt.prototype,"shadowColor",void 0),Yt([Ht()],Gt.prototype,"shadowOffsetX",void 0),Yt([Ht()],Gt.prototype,"shadowOffsetY",void 0),Yt([Ht()],Gt.prototype,"filter",void 0),Yt([Ht()],Gt.prototype,"font",void 0),Yt([Ht()],Gt.prototype,"fontKerning",void 0),Yt([Ht()],Gt.prototype,"fontStretch",void 0),Yt([Ht()],Gt.prototype,"fontVariantCaps",void 0),Yt([Ht()],Gt.prototype,"textAlign",void 0),Yt([Ht()],Gt.prototype,"textBaseline",void 0),Yt([Ht()],Gt.prototype,"textRendering",void 0),Yt([Ht()],Gt.prototype,"wordSpacing",void 0),Yt([Ht()],Gt.prototype,"letterSpacing",void 0),Yt([Ht()],Gt.prototype,"direction",void 0),Yt([jt()],Gt.prototype,"setTransform",null),Yt([jt()],Gt.prototype,"resetTransform",null),Yt([jt()],Gt.prototype,"getTransform",null),Yt([jt()],Gt.prototype,"save",null),Yt([jt()],Gt.prototype,"restore",null),Yt([jt()],Gt.prototype,"translate",null),Yt([jt()],Gt.prototype,"scale",null),Yt([jt()],Gt.prototype,"rotate",null),Yt([jt()],Gt.prototype,"fill",null),Yt([jt()],Gt.prototype,"stroke",null),Yt([jt()],Gt.prototype,"clip",null),Yt([jt()],Gt.prototype,"fillRect",null),Yt([jt()],Gt.prototype,"strokeRect",null),Yt([jt()],Gt.prototype,"clearRect",null),Yt([jt()],Gt.prototype,"beginPath",null),Yt([jt()],Gt.prototype,"moveTo",null),Yt([jt()],Gt.prototype,"lineTo",null),Yt([jt()],Gt.prototype,"bezierCurveTo",null),Yt([jt()],Gt.prototype,"quadraticCurveTo",null),Yt([jt()],Gt.prototype,"closePath",null),Yt([jt()],Gt.prototype,"arc",null),Yt([jt()],Gt.prototype,"arcTo",null),Yt([jt()],Gt.prototype,"ellipse",null),Yt([jt()],Gt.prototype,"rect",null),Yt([jt()],Gt.prototype,"roundRect",null),Yt([jt()],Gt.prototype,"createConicGradient",null),Yt([jt()],Gt.prototype,"createLinearGradient",null),Yt([jt()],Gt.prototype,"createPattern",null),Yt([jt()],Gt.prototype,"createRadialGradient",null),Yt([jt()],Gt.prototype,"fillText",null),Yt([jt()],Gt.prototype,"measureText",null),Yt([jt()],Gt.prototype,"strokeText",null);const{copy:Zt}=x,Kt={width:1,height:1,pixelRatio:1},qt=["width","height","pixelRatio"];class Jt extends Gt{get width(){return this.size.width}get height(){return this.size.height}get pixelRatio(){return this.size.pixelRatio}get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,s){super(),this.size={},this.worldTransform={},e||(e=Kt),this.manager=s,this.innerId=i.create(i.CNAVAS);const{width:n,height:o,pixelRatio:r}=e;this.autoLayout=!n||!o,this.size.pixelRatio=r|t.devicePixelRatio,this.config=e,this.init()}init(){}__createContext(){const{view:t}=this,{contextSettings:e}=this.config;this.context=e?t.getContext("2d",e):t.getContext("2d"),this.__bindContext()}export(t,e){}toBlob(t,e){}toDataURL(t,e){}saveAs(t,e){}resize(t,e=!0){if(this.isSameSize(t))return;let i;this.context&&!this.unreal&&e&&this.width&&(i=this.getSameCanvas(),i.copyWorld(this));const s=this.size;At.copyAttrs(s,t,qt),qt.forEach((t=>s[t]||(s[t]=1))),this.bounds=new ht(0,0,this.width,this.height),this.context&&!this.unreal&&(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&i&&(this.clearWorld(i.bounds),this.copyWorld(i),i.recycle())}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:i}=this,s=this.worldTransform;if(e){const{a:n,b:o,c:r,d:a,e:h,f:l}=e;this.setTransform(s.a=(t.a*n+t.b*r)*i,s.b=(t.a*o+t.b*a)*i,s.c=(t.c*n+t.d*r)*i,s.d=(t.c*o+t.d*a)*i,s.e=(t.e*n+t.f*r+h)*i,s.f=(t.e*o+t.f*a+l)*i)}else this.setTransform(s.a=t.a*i,s.b=t.b*i,s.c=t.c*i,s.d=t.d*i,s.e=t.e*i,s.f=t.f*i)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,i){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i)}setStrokeOptions(t){this.strokeCap="none"===t.strokeCap?"butt":t.strokeCap,this.strokeJoin=t.strokeJoin,this.dashPattern=t.dashPattern,this.dashOffset=t.dashOffset,this.miterLimit=t.miterLimit}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s){if(s&&(this.blendMode=s),e){const{pixelRatio:s}=this;i||(i=e),this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x*s,i.y*s,i.width*s,i.height*s)}else this.drawImage(t.view,0,0);s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s){if(s&&(this.blendMode=s),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,nt.tempToOuterOf(i,e)),this.restore();else{const{pixelRatio:s}=this;this.drawImage(t.view,e.x*s,e.y*s,e.width*s,e.height*s,i.x,i.y,i.width,i.height)}s&&(this.blendMode="source-over")}copyWorldByReset(t,e,i,s,n){this.resetTransform(),this.copyWorld(t,e,i,s),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(lt.x,lt.y,lt.width,lt.height),{data:o}=n;for(let t=0,s=o.length;t<s;t+=4)i=.299*o[t]+.587*o[t+1]+.114*o[t+2],(e=o[t+3])&&(o[t+3]=255===e?i:e*(i/255));s.putImageData(n,lt.x,lt.y)}useMask(t,e,i){this.copyWorld(t,e,i,"destination-in")}useEraser(t,e,i){this.copyWorld(t,e,i,"destination-out")}fillWorld(t,e,i){i&&(this.blendMode=i),this.fillStyle=e,this.setTempBounds(t),this.fillRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempBounds(t),this.strokeRect(lt.x,lt.y,lt.width,lt.height),i&&(this.blendMode="source-over")}clearWorld(t,e){this.setTempBounds(t,e),this.clearRect(lt.x,lt.y,lt.width,lt.height)}clipWorld(t,e){this.beginPath(),this.setTempBounds(t,e),this.rect(lt.x,lt.y,lt.width,lt.height),this.clip()}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempBounds(t,e,i){lt.set(t),i&&lt.intersect(this.bounds),lt.scale(this.pixelRatio),e&&lt.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,i){const s=this.manager?this.manager.get(this.size):e.canvas(Object.assign({},this.size));return s.save(),t&&(Zt(s.worldTransform,this.worldTransform),s.useWorldTransform()),i&&(s.smooth=this.smooth),s}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t,!0):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const $t={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Qt={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},te=Object.assign({M:1,m:10,L:2,l:20,H:3,h:30,V:4,v:40,C:5,c:50,S:6,s:60,Q:7,q:70,T:8,t:80,A:9,a:90,Z:11,z:11,R:12},Qt),ee={M:3,m:3,L:3,l:3,H:2,h:2,V:2,v:2,C:7,c:7,S:5,s:5,Q:5,q:5,T:3,t:3,A:8,a:8,Z:1,z:1,N:5,D:9,X:6,G:9,F:5,O:7,P:4,U:6},ie={m:10,l:20,H:3,h:30,V:4,v:40,c:50,S:6,s:60,q:70,T:8,t:80,A:9,a:90},se=Object.assign(Object.assign({},ie),Qt),ne=te,oe={};for(let t in ne)oe[ne[t]]=t;const re={};for(let t in ne)re[ne[t]]=ee[t];const ae={drawRoundRect(t,e,i,s,n,o){const r=a.fourNumber(o,Math.min(s/2,n/2)),h=e+s,l=i+n;r[0]?t.moveTo(e+r[0],i):t.moveTo(e,i),r[1]?t.arcTo(h,i,h,l,r[1]):t.lineTo(h,i),r[2]?t.arcTo(h,l,e,l,r[2]):t.lineTo(h,l),r[3]?t.arcTo(e,l,e,i,r[3]):t.lineTo(e,l),r[0]?t.arcTo(e,i,h,i,r[0]):t.lineTo(e,i)}},{sin:he,cos:le,atan2:de,ceil:ce,abs:ue,PI:_e,sqrt:pe,pow:ge}=Math,{setPoint:fe,addPoint:ye}=Y,{set:me,toNumberPoints:ve}=P,{M:we,L:xe,C:be,Q:ke,Z:Ee}=te,Be={},Re={points(t,e,i,s){let n=ve(e);if(t.push(we,n[0],n[1]),i&&n.length>5){let e,o,r,a,h,l,d,c,u,_,p,g,f,y=n.length;const m=!0===i?.5:i;s&&(n=[n[y-2],n[y-1],...n,n[0],n[1],n[2],n[3]],y=n.length);for(let i=2;i<y-2;i+=2)e=n[i-2],o=n[i-1],r=n[i],a=n[i+1],h=n[i+2],l=n[i+3],p=pe(ge(r-e,2)+ge(a-o,2)),g=pe(ge(h-r,2)+ge(l-a,2)),f=p+g,p=m*p/f,g=m*g/f,h-=e,l-=o,d=r-p*h,c=a-p*l,2===i?s||t.push(ke,d,c,r,a):t.push(be,u,_,d,c,r,a),u=r+g*h,_=a+g*l;s||t.push(ke,u,_,n[y-2],n[y-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(xe,n[e],n[e+1]);s&&t.push(Ee)},rect(t,e,i,s,n){$t.creator.path=t,$t.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+n).lineTo(e,i+n).lineTo(e,i)},roundRect(t,e,i,s,n,o){$t.creator.path=[],ae.drawRoundRect($t.creator,e,i,s,n,o),t.push(...$t.convertToCanvasData($t.creator.path,!0))},arcTo(t,e,i,s,n,o,r,a,c,u,_){const p=s-e,g=n-i,f=o-s,y=r-n;let m=de(g,p),v=de(y,f),w=v-m;if(w<0&&(w+=l),w===_e||ue(p+g)<1e-12||ue(f+y)<1e-12)return t&&t.push(xe,s,n),c&&(fe(c,e,i),ye(c,s,n)),_&&me(_,e,i),void(u&&me(u,s,n));const x=p*y-f*g<0,b=x?-1:1,k=a/le(w/2),E=s+k*le(m+w/2+d*b),B=n+k*he(m+w/2+d*b);return m-=d*b,v-=d*b,Oe(t,E,B,a,a,0,m/h,v/h,x,c,u,_)},arc:(t,e,i,s,n,o,r,a,h,l)=>Oe(t,e,i,s,s,0,n,o,r,a,h,l),ellipse(t,e,i,s,n,o,r,a,c,u,_,p){const g=o*h,f=he(g),y=le(g);let m=r*h,v=a*h;m>_e&&(m-=l),v<0&&(v+=l);let w=v-m;w<0?w+=l:w>l&&(w-=l),c&&(w-=l);const x=ce(ue(w/d)),b=w/x,k=he(b/4),E=8/3*k*k/he(b/2);v=m+b;let B,R,C,L,O,T,S,P,M=le(m),A=he(m),D=C=y*s*M-f*n*A,I=L=f*s*M+y*n*A,W=e+C,F=i+L;t&&t.push(t.length?xe:we,W,F),u&&fe(u,W,F),p&&me(p,W,F);for(let o=0;o<x;o++)B=le(v),R=he(v),C=y*s*B-f*n*R,L=f*s*B+y*n*R,O=e+D-E*(y*s*A+f*n*M),T=i+I-E*(f*s*A-y*n*M),S=e+C+E*(y*s*R+f*n*B),P=i+L+E*(f*s*R-y*n*B),t&&t.push(be,O,T,S,P,e+C,i+L),u&&Le(e+D,i+I,O,T,S,P,e+C,i+L,u,!0),D=C,I=L,M=B,A=R,m=v,v+=b;_&&me(_,e+C,i+L)},quadraticCurveTo(t,e,i,s,n,o,r){t.push(be,(e+2*s)/3,(i+2*n)/3,(o+2*s)/3,(r+2*n)/3,o,r)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,o,r,a){Le(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(o+2*s)/3,n,o,r,a)},toTwoPointBounds(t,e,i,s,n,o,r,a,h,l){const d=[];let c,u,_,p,g,f,y,m,v=t,w=i,x=n,b=r;for(let t=0;t<2;++t)if(1==t&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,_=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;p=-_/u,0<p&&p<1&&d.push(p)}else y=u*u-4*_*c,m=Math.sqrt(y),y<0||(g=(-u+m)/(2*c),0<g&&g<1&&d.push(g),f=(-u-m)/(2*c),0<f&&f<1&&d.push(f));l?ye(h,t,e):fe(h,t,e),ye(h,r,a);for(let l=0,c=d.length;l<c;l++)Ce(d[l],t,e,i,s,n,o,r,a,Be),ye(h,Be.x,Be.y)},getPointAndSet(t,e,i,s,n,o,r,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,_=3*d*t*t,p=t*t*t;l.x=c*e+u*s+_*o+p*a,l.y=c*i+u*n+_*r+p*h},getPoint(t,e,i,s,n,o,r,a,h){const l={};return Ce(t,e,i,s,n,o,r,a,h,l),l}},{getPointAndSet:Ce,toTwoPointBounds:Le,ellipse:Oe}=Re,{sin:Te,cos:Se,sqrt:Pe,atan2:Me}=Math,{ellipse:Ae}=Re,De={ellipticalArc(e,i,s,n,o,r,a,d,c,u,_){const p=(c-i)/2,g=(u-s)/2,f=r*h,y=Te(f),m=Se(f),v=-m*p-y*g,w=-m*g+y*p,x=n*n,b=o*o,k=w*w,E=v*v,B=x*b-x*k-b*E;let R=0;if(B<0){const t=Pe(1-B/(x*b));n*=t,o*=t}else R=(a===d?-1:1)*Pe(B/(x*k+b*E));const C=R*n*w/o,L=-R*o*v/n,O=Me((w-L)/o,(v-C)/n),T=Me((-w-L)/o,(-v-C)/n);let S=T-O;0===d&&S>0?S-=l:1===d&&S<0&&(S+=l);const P=i+p+m*C-y*L,M=s+g+y*C+m*L,A=S<0?1:0;_||t.ellipseToCurve?Ae(e,P,M,n,o,r,O/h,T/h,A):n!==o||r?e.push(te.G,P,M,n,o,r,O/h,T/h,A):e.push(te.O,P,M,n,O/h,T/h,A)}},{M:Ie,m:We,L:Fe,l:ze,H:Ne,h:Ye,V:Xe,v:He,C:Ve,c:je,S:Ue,s:Ge,Q:Ze,q:Ke,T:qe,t:Je,A:$e,a:Qe,Z:ti,z:ei,N:ii,D:si,X:ni,G:oi,F:ri,O:ai,P:hi,U:li}=te,{rect:di,roundRect:ci,arcTo:ui,arc:_i,ellipse:pi,quadraticCurveTo:gi}=Re,{ellipticalArc:fi}=De,yi=vt.get("PathConvert"),mi={},vi={current:{dot:0},stringify(t,e){let i,s,n,o=0,r=t.length,h="";for(;o<r;){s=t[o],i=re[s],h+=s===n?" ":oe[s];for(let s=1;s<i;s++)h+=a.float(t[o+s],e),s===i-1||(h+=" ");n=s,o+=i}return h},parse(t,e){let i,s,n,o="";const r=[],a=e?se:ie;for(let e=0,h=t.length;e<h;e++)s=t[e],mt[s]?("."===s&&(wi.dot&&(xi(r,o),o=""),wi.dot++),"0"===o&&"."!==s&&(xi(r,o),o=""),o+=s):te[s]?(o&&(xi(r,o),o=""),wi.name=te[s],wi.length=ee[s],wi.index=0,xi(r,wi.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?o+=s:(o&&xi(r,o),o=s):o&&(xi(r,o),o=""),n=s;return o&&xi(r,o),i?vi.toCanvasData(r,e):r},toCanvasData(t,e){let i,s,n,o,r,a=0,h=0,l=0,d=0,c=0,u=t.length;const _=[];for(;c<u;){switch(n=t[c],n){case We:t[c+1]+=a,t[c+2]+=h;case Ie:a=t[c+1],h=t[c+2],_.push(Ie,a,h),c+=3;break;case Ye:t[c+1]+=a;case Ne:a=t[c+1],_.push(Fe,a,h),c+=2;break;case He:t[c+1]+=h;case Xe:h=t[c+1],_.push(Fe,a,h),c+=2;break;case ze:t[c+1]+=a,t[c+2]+=h;case Fe:a=t[c+1],h=t[c+2],_.push(Fe,a,h),c+=3;break;case Ge:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ue;case Ue:r=o===Ve||o===Ue,l=r?2*a-i:t[c+1],d=r?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],_.push(Ve,l,d,i,s,a,h),c+=5;break;case je:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=Ve;case Ve:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],_.push(Ve,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Je:t[c+1]+=a,t[c+2]+=h,n=qe;case qe:r=o===Ze||o===qe,i=r?2*a-i:t[c+1],s=r?2*h-s:t[c+2],e?gi(_,a,h,i,s,t[c+1],t[c+2]):_.push(Ze,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Ke:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ze;case Ze:i=t[c+1],s=t[c+2],e?gi(_,a,h,i,s,t[c+3],t[c+4]):_.push(Ze,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Qe:t[c+6]+=a,t[c+7]+=h;case $e:fi(_,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case ei:case ti:_.push(ti),c++;break;case ii:a=t[c+1],h=t[c+2],e?di(_,a,h,t[c+3],t[c+4]):bi(_,t,c,5),c+=5;break;case si:a=t[c+1],h=t[c+2],e?ci(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):bi(_,t,c,9),c+=9;break;case ni:a=t[c+1],h=t[c+2],e?ci(_,a,h,t[c+3],t[c+4],t[c+5]):bi(_,t,c,6),c+=6;break;case oi:pi(e?_:bi(_,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,mi),a=mi.x,h=mi.y,c+=9;break;case ri:e?pi(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):bi(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case ai:_i(e?_:bi(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,mi),a=mi.x,h=mi.y,c+=7;break;case hi:e?_i(_,t[c+1],t[c+2],t[c+3],0,360,!1):bi(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case li:ui(e?_:bi(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,mi),a=mi.x,h=mi.y,c+=6;break;default:return yi.error(`command: ${n} [index:${c}]`,t),_}o=n}return _},objectToCanvasData(t){const e=[];return t.forEach((t=>{switch(t.name){case"M":e.push(Ie,t.x,t.y);break;case"L":e.push(Fe,t.x,t.y);break;case"C":e.push(Ve,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Ze,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(ti)}})),e},copyData(t,e,i,s){for(let n=i,o=i+s;n<o;n++)t.push(e[n])},pushData(t,e){wi.index===wi.length&&(wi.index=1,t.push(wi.name)),t.push(Number(e)),wi.index++,wi.dot=0}},{current:wi,pushData:xi,copyData:bi}=vi,{M:ki,L:Ei,C:Bi,Q:Ri,Z:Ci,N:Li,D:Oi,X:Ti,G:Si,F:Pi,O:Mi,P:Ai,U:Di}=te,{getMinDistanceFrom:Ii,getRadianFrom:Wi}=P,{tan:Fi,min:zi,abs:Ni}=Math,Yi={},Xi={beginPath(t){t.length=0},moveTo(t,e,i){t.push(ki,e,i)},lineTo(t,e,i){t.push(Ei,e,i)},bezierCurveTo(t,e,i,s,n,o,r){t.push(Bi,e,i,s,n,o,r)},quadraticCurveTo(t,e,i,s,n){t.push(Ri,e,i,s,n)},closePath(t){t.push(Ci)},rect(t,e,i,s,n){t.push(Li,e,i,s,n)},roundRect(t,e,i,s,n,o){if("number"==typeof o)t.push(Ti,e,i,s,n,o);else{const r=a.fourNumber(o);r?t.push(Oi,e,i,s,n,...r):t.push(Li,e,i,s,n)}},ellipse(t,e,i,s,n,o,r,a,h){void 0===o?t.push(Pi,e,i,s,n):(void 0===r&&(r=0),void 0===a&&(a=360),t.push(Si,e,i,s,n,o,r,a,h?1:0))},arc(t,e,i,s,n,o,r){void 0===n?t.push(Ai,e,i,s):(void 0===o&&(o=360),t.push(Mi,e,i,s,n,o,r?1:0))},arcTo(t,e,i,s,n,o,r,a){if(void 0!==r){const t=Ii(r,a,e,i,s,n);o=zi(o,zi(t/2,t/2*Ni(Fi(Wi(r,a,e,i,s,n)/2))))}t.push(Di,e,i,s,n,o)},drawEllipse(t,e,i,s,n,o,r,a,h){Re.ellipse(null,e,i,s,n,void 0===o?0:o,void 0===r?0:r,void 0===a?360:a,h,null,null,Yi),t.push(ki,Yi.x,Yi.y),Hi(t,e,i,s,n,o,r,a,h)},drawArc(t,e,i,s,n,o,r){Re.arc(null,e,i,s,void 0===n?0:n,void 0===o?360:o,r,null,null,Yi),t.push(ki,Yi.x,Yi.y),Vi(t,e,i,s,n,o,r)},drawPoints(t,e,i,s){Re.points(t,e,i,s)}},{ellipse:Hi,arc:Vi}=Xi,{moveTo:ji,lineTo:Ui,quadraticCurveTo:Gi,bezierCurveTo:Zi,closePath:Ki,beginPath:qi,rect:Ji,roundRect:$i,ellipse:Qi,arc:ts,arcTo:es,drawEllipse:is,drawArc:ss,drawPoints:ns}=Xi;class os{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?"string"==typeof t?$t.parse(t):t:[],this}beginPath(){return qi(this.__path),this.paint(),this}moveTo(t,e){return ji(this.__path,t,e),this.paint(),this}lineTo(t,e){return Ui(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,o){return Zi(this.__path,t,e,i,s,n,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return Gi(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ki(this.__path),this.paint(),this}rect(t,e,i,s){return Ji(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return $i(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,o,r,a){return Qi(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}arc(t,e,i,s,n,o){return ts(this.__path,t,e,i,s,n,o),this.paint(),this}arcTo(t,e,i,s,n){return es(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,o,r,a){return is(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}drawArc(t,e,i,s,n,o){return ss(this.__path,t,e,i,s,n,o),this.paint(),this}drawPoints(t,e,i){return ns(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:rs,L:as,C:hs,Q:ls,Z:ds,N:cs,D:us,X:_s,G:ps,F:gs,O:fs,P:ys,U:ms}=te,vs=vt.get("PathDrawer"),ws={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case rs:t.moveTo(e[s+1],e[s+2]),s+=3;break;case as:t.lineTo(e[s+1],e[s+2]),s+=3;break;case hs:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case ls:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case ds:t.closePath(),s+=1;break;case cs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case us:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case _s:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case ps:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*h,e[s+6]*h,e[s+7]*h,e[s+8]),s+=9;break;case gs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,l,!1),s+=5;break;case fs:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*h,e[s+5]*h,e[s+6]),s+=7;break;case ys:t.arc(e[s+1],e[s+2],e[s+3],0,l,!1),s+=4;break;case ms:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void vs.error(`command: ${i} [index:${s}]`,e)}}},{M:xs,L:bs,C:ks,Q:Es,Z:Bs,N:Rs,D:Cs,X:Ls,G:Os,F:Ts,O:Ss,P:Ps,U:Ms}=te,{toTwoPointBounds:As,toTwoPointBoundsByQuadraticCurve:Ds,arcTo:Is,arc:Ws,ellipse:Fs}=Re,{addPointBounds:zs,copy:Ns,addPoint:Ys,setPoint:Xs,addBounds:Hs,toBounds:Vs}=Y,js=vt.get("PathBounds");let Us,Gs,Zs;const Ks={},qs={},Js={},$s={toBounds(t,e){$s.toTwoPointBounds(t,qs),Vs(qs,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Xs(e,0,0);let i,s,n,o,r,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(r=t[a],0===a&&(r===Bs||r===ks||r===Es?Xs(e,h,l):Xs(e,t[a+1],t[a+2])),r){case xs:case bs:h=t[a+1],l=t[a+2],Ys(e,h,l),a+=3;break;case ks:n=t[a+5],o=t[a+6],As(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,o,Ks),zs(e,Ks),h=n,l=o,a+=7;break;case Es:i=t[a+1],s=t[a+2],n=t[a+3],o=t[a+4],Ds(h,l,i,s,n,o,Ks),zs(e,Ks),h=n,l=o,a+=5;break;case Bs:a+=1;break;case Rs:h=t[a+1],l=t[a+2],Hs(e,h,l,t[a+3],t[a+4]),a+=5;break;case Cs:case Ls:h=t[a+1],l=t[a+2],Hs(e,h,l,t[a+3],t[a+4]),a+=r===Cs?9:6;break;case Os:Fs(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],t[a+7],t[a+8],Ks,Js),0===a?Ns(e,Ks):zs(e,Ks),h=Js.x,l=Js.y,a+=9;break;case Ts:h=t[a+1],l=t[a+2],Gs=t[a+3],Zs=t[a+4],Hs(e,h-Gs,l-Zs,2*Gs,2*Zs),h+=Gs,a+=5;break;case Ss:Ws(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Ks,Js),0===a?Ns(e,Ks):zs(e,Ks),h=Js.x,l=Js.y,a+=7;break;case Ps:h=t[a+1],l=t[a+2],Us=t[a+3],Hs(e,h-Us,l-Us,2*Us,2*Us),h+=Us,a+=4;break;case Ms:Is(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Ks,Js),0===a?Ns(e,Ks):zs(e,Ks),h=Js.x,l=Js.y,a+=6;break;default:return void js.error(`command: ${r} [index:${a}]`,t)}}},{M:Qs,L:tn,Z:en}=te,{getCenterX:sn,getCenterY:nn}=P,{arcTo:on}=Xi,rn={smooth(t,e,i){let s,n,o=0,r=0,a=0,h=0,l=0,d=0,c=0,u=0,_=0;const p=t.length,g=[];for(;o<p;)switch(s=t[o],s){case Qs:h=u=t[o+1],l=_=t[o+2],o+=3,t[o]===tn?(d=t[o+1],c=t[o+2],g.push(Qs,sn(h,d),nn(l,c))):g.push(Qs,h,l);break;case tn:switch(r=t[o+1],a=t[o+2],o+=3,t[o]){case tn:on(g,r,a,t[o+1],t[o+2],e,u,_);break;case en:on(g,r,a,h,l,e,u,_);break;default:g.push(tn,r,a)}u=r,_=a;break;case en:on(g,h,l,d,c,e,u,_),g.push(en),o+=1;break;default:n=re[s];for(let e=0;e<n;e++)g.push(t[o+e]);o+=n}return s!==en&&(g[1]=h,g[2]=l),g}};$t.creator=new os,$t.parse=vi.parse,$t.convertToCanvasData=vi.toCanvasData;const an=new os,{drawRoundRect:hn}=ae;function ln(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){hn(this,t,e,i,s,n)})}(t)}const dn={opacityTypes:["png","webp","svg"],upperCaseTypeMap:{},mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=cn.fileType(t);return["jpg","jpeg"].some((t=>t===e))},getExportOptions(t){switch(typeof t){case"object":return t;case"number":return{quality:t};case"boolean":return{blob:t};default:return{}}}},cn=dn;cn.opacityTypes.forEach((t=>cn.upperCaseTypeMap[t]=t.toUpperCase()));const un=vt.get("TaskProcessor");class _n{constructor(t){this.parallel=!0,this.time=1,this.id=i.create(i.TASK),this.task=t}run(){return Xt(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){un.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class pn{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,i=0;for(let s=0;s<t;s++)s<=this.finishedIndex?(i+=this.list[s].time,s===this.finishedIndex&&(e=i)):e+=this.list[s].time;return this.isComplete?1:i/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&At.assign(this.config,t),this.empty()}add(t,e){let i,s,n,o;const r=new _n(t);return r.parent=this,"number"==typeof e?o=e:e&&(s=e.parallel,i=e.start,n=e.time,o=e.delay),n&&(r.time=n),!1===s&&(r.parallel=!1),void 0===o?this.push(r,i):(this.delayNumber++,setTimeout((()=>{this.delayNumber&&(this.delayNumber--,this.push(r,i))}),o)),this.isComplete=!1,r}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout((()=>this.start())))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[],this.delayNumber=0}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach((t=>{t.isComplete||t.cancel()})),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)})):this.nextTask()}runParallelTasks(){this.parallelList.forEach((t=>this.runParallelTask(t)))}runParallelTask(t){t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout((()=>this.run()))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let i=this.index;i<e&&(t=this.list[i],t.parallel);i++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const i=e.length,s=this.finishedIndex+i;if(e.length){if(!this.running)return;s<this.total&&(t=this.list[s],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const gn=vt.get("Resource"),fn={tasker:new pn,map:{},get isComplete(){return yn.tasker.isComplete},set(t,e){yn.map[t]&&gn.repeat(t),yn.map[t]=e},get:t=>yn.map[t],remove(t){const e=yn.map[t];e&&(e.destroy&&e.destroy(),delete yn.map[t])},loadImage(t,e){return new Promise(((i,s)=>{const n=this.setImage(t,t,e);n.load((()=>i(n)),(t=>s(t)))}))},setImage(t,i,s){let n;return"string"==typeof i?n={url:i}:i.url||(n={url:t,view:i}),n&&(s&&(n.format=s),i=e.image(n)),yn.set(t,i),i},destroy(){yn.map={}}},yn=fn,mn={maxRecycled:100,recycledList:[],patternTasker:new pn,get(t){let i=fn.get(t.url);return i||fn.set(t.url,i=e.image(t)),i.use++,i},recycle(t){t.use--,setTimeout((()=>{t.use||vn.recycledList.push(t)}))},clearRecycled(){const t=vn.recycledList;t.length>vn.maxRecycled&&(t.forEach((t=>!t.use&&t.url&&fn.remove(t.url))),t.length=0)},hasOpacityPixel:t=>dn.opacityTypes.some((e=>vn.isFormat(e,t))),isFormat(t,e){if(e.format===t)return!0;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+dn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+dn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){vn.recycledList=[]}},vn=mn,{IMAGE:wn,create:xn}=i;class bn{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=xn(wn),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}mn.isFormat("svg",t)&&(this.isSVG=!0),mn.hasOpacityPixel(t)&&(this.hasOpacityPixel=!0)}load(e,i){return this.loading||(this.loading=!0,fn.tasker.add((()=>Xt(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>this.setView(t))).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),this.waitComplete.push(e,i),this.waitComplete.length-2}unload(t,e){const i=this.waitComplete;if(e){const e=i[t+1];e&&e({type:"stop"})}i[t]=i[t+1]=void 0}setView(t){this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onComplete(t){let e;this.waitComplete.forEach(((i,s)=>{e=s%2,i&&(t?e||i(this):e&&i(this.error))})),this.waitComplete.length=0,this.loading=!1}getFull(t){return this.view}getCanvas(e,i,s,n){if(e||(e=this.width),i||(i=this.height),this.cache){let{params:t,data:e}=this.cache;for(let i in t)if(t[i]!==arguments[i]){e=null;break}if(e)return e}const o=t.origin.createCanvas(e,i),r=o.getContext("2d");return s&&(r.globalAlpha=s),r.drawImage(this.view,0,0,e,i),this.cache=this.use>1?{data:o,params:arguments}:null,o}getPattern(e,i,s,n){const o=t.canvas.createPattern(e,i);try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function kn(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function En(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Bn(t,e){return(i,s)=>Cn(i,s,t,e&&e(s))}function Rn(t){return t}function Cn(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};kn(t,e,Object.assign(n,s||{})),to(t,e,i)}function Ln(t){return Bn(t)}function On(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}})))}function Tn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),Dn(this))}})))}function Sn(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}})))}function Pn(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}})))}function Mn(t,e){return Bn(t,(t=>({set(i){this.__setAttr(t,i,e)&&Dn(this)}})))}function An(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(Dn(this),this.__.__removeNaturalSize())}})))}function Dn(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function In(t){return Bn(t,(t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),Dn(this)}})))}const Wn=Mn;function Fn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&zn(this)}})))}function zn(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&Dn(t)}const Nn=Fn;function Yn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}})))}function Xn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}})))}function Hn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&jn(this)}})))}function Vn(t){return Bn(t,(t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",(()=>Un(this,t,e,i)))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Un(this,t,e,i),this.mask&&jn(this)}})))}function jn(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Un(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||Dn(t))}function Gn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()})))}})))}function Zn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(e)})))}})))}function Kn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&this.waitParent((()=>{this.parent.__updateEraser(e)}))}})))}function qn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,vt.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor())}})))}function Jn(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}})))}function $n(t){return(e,i)=>{kn(e,"__DataProcessor",{get:()=>t})}}function Qn(t){return(e,i)=>{kn(e,"__LayoutProcessor",{get:()=>t})}}function to(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),r={get(){const t=this[n];return void 0===t?i:t},set(t){this[n]=t}};if(void 0===i)r.get=function(){return this[n]};else if("function"==typeof i)r.get=function(){let t=this[n];return void 0===t?i(this.__leaf):t};else if("object"==typeof i){const t=Nt(i);r.get=function(){let e=this[n];return void 0===e?this[n]=t?{}:At.clone(i):e}}const a=t.isBranchLeaf;"width"===e?r.get=function(){const t=this[n];if(void 0===t){const t=this,e=t.__naturalWidth,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:a&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(r.get=function(){const t=this[n];if(void 0===t){const t=this,e=t.__naturalHeight,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:a&&s.children.length?s.boxBounds.height:i}return t});let h,l=s;for(;!h&&l;)h=En(l,e),l=l.__proto__;h&&h.set&&(r.set=h.set),s[o]&&(r.set=s[o],delete s[o]),kn(s,e,r)}const eo=new vt("rewrite"),io=[],so=["destroy","constructor"];function no(t){return(e,i)=>{io.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function oo(){return t=>{ro()}}function ro(t){io.length&&(io.forEach((e=>{t&&eo.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),io.length=0)}function ao(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach((s=>{if(!(so.includes(s)||e&&e.includes(s)))if(t.prototype){En(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]}))}}function ho(){return t=>{Lt.register(t)}}function lo(){return t=>{St.register(t)}}setTimeout((()=>ro(!0)));const{copy:co,toInnerPoint:uo,toOuterPoint:_o,scaleOfOuter:po,rotateOfOuter:go,skewOfOuter:fo,multiplyParent:yo,divideParent:mo,getLayout:vo}=x,wo={},xo={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),Eo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)ko(s[t],e,i)}},updateMatrix(t,e,i){const s=t.__layout;e?i&&(s.waitAutoLayout=!0,t.__hasAutoLayout&&(s.matrixChanged=!1)):s.waitAutoLayout&&(s.waitAutoLayout=!1),s.matrixChanged&&t.__updateLocalMatrix(),s.waitAutoLayout||t.__updateWorldMatrix()},updateBounds(t){const e=t.__layout;e.boundsChanged&&t.__updateLocalBounds(),e.waitAutoLayout||t.__updateWorldBounds()},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)Bo(e[t])}},updateAllChange(t){if(Bo(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)Ro(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},moveWorld(t,e,i=0,s,n){const o="object"==typeof e?Object.assign({},e):{x:e,y:i};s?_o(t.localTransform,o,o,!0):t.parent&&uo(t.parent.worldTransform,o,o,!0),bo.moveLocal(t,o.x,o.y,n)},moveLocal(t,e,i=0,s){"object"==typeof e&&(i=e.y,e=e.x),e+=t.x,i+=t.y,s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,o){bo.zoomOfLocal(t,Co(t,e),i,s,n,o)},zoomOfLocal(t,e,i,s=i,n,o){const r=t.__localMatrix;if("number"!=typeof s&&(s&&(o=s),s=i),co(wo,r),po(wo,e,i,s),t.origin||t.around)bo.setTransform(t,wo,n,o);else{const e=t.x+wo.e-r.e,a=t.y+wo.f-r.f;o&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},o):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){bo.rotateOfLocal(t,Co(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;co(wo,n),go(wo,e,i),t.origin||t.around?bo.setTransform(t,wo,!1,s):t.set({x:t.x+wo.e-n.e,y:t.y+wo.f-n.f,rotation:a.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,o){bo.skewOfLocal(t,Co(t,e),i,s,n,o)},skewOfLocal(t,e,i,s=0,n,o){co(wo,t.__localMatrix),fo(wo,e,i,s),bo.setTransform(t,wo,n,o)},transformWorld(t,e,i,s){co(wo,t.worldTransform),yo(wo,e),t.parent&&mo(wo,t.parent.worldTransform),bo.setTransform(t,wo,i,s)},transform(t,e,i,s){co(wo,t.localTransform),yo(wo,e),bo.setTransform(t,wo,i,s)},setTransform(t,e,i,s){const n=t.__,o=n.origin&&bo.getInnerOrigin(t,n.origin),r=vo(e,o,n.around&&bo.getInnerOrigin(t,n.around));if(i){const e=r.scaleX/t.scaleX,i=r.scaleY/t.scaleY;if(delete r.scaleX,delete r.scaleY,o){nt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=bo.getInnerOrigin(t,n.origin);P.move(r,o.x-s.x,o.y-s.y)}t.set(r),t.scaleResize(e,i,!1)}else t.set(r,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return po(i,bo.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>P.tempToOuterOf(bo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return pt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(co(wo,t.worldTransform),mo(wo,e.worldTransform),i?wo:Object.assign({},wo)),drop(t,e,i,s){t.setTransform(bo.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}}},bo=xo,{updateAllMatrix:ko,updateMatrix:Eo,updateAllWorldOpacity:Bo,updateAllChange:Ro}=bo;function Co(t,e){return t.__layout.update(),t.parent?P.tempToInnerOf(e,t.parent.__world):e}const Lo={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.eraser||0===t.__.visible?null:t.__local||t.__layout,localStrokeBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localRenderBounds,maskLocalBoxBounds:t=>t.__.mask?t.__localBoxBounds:null,maskLocalStrokeBounds:t=>t.__.mask?t.__layout.localStrokeBounds:null,maskLocalRenderBounds:t=>t.__.mask?t.__layout.localRenderBounds:null,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))},{updateBounds:Oo}=xo,To={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:i}=t;for(let s=0,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),So(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&void 0===i[t.parent.innerId];)e.add(t.parent),t=t.parent;else for(;t.parent;)e.add(t.parent),t=t.parent},pushAllBranchStack(t,e){let i=e.length;const{children:s}=t;for(let t=0,i=s.length;t<i;t++)s[t].isBranch&&e.push(s[t]);for(let t=i,s=e.length;t<s;t++)Po(e[t],e)},updateBounds(t,e){const i=[t];Po(t,i),Mo(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let n=t.length-1;n>-1;n--){i=t[n],s=i.children;for(let t=0,e=s.length;t<e;t++)Oo(s[t]);e&&e===i||Oo(i)}}},{pushAllChildBranch:So,pushAllBranchStack:Po,updateBoundsByBranchStack:Mo}=To,Ao={run(t){if(t&&t.length){const e=t.length;for(let i=0;i<e;i++)t[i]();t.length===e?t.length=0:t.splice(0,e)}}},{getRelativeWorld:Do}=xo,{toOuterOf:Io,getPoints:Wo,copy:Fo}=nt,zo="_localContentBounds",No="_worldContentBounds",Yo="_worldBoxBounds",Xo="_worldStrokeBounds";class Ho{get contentBounds(){return this._contentBounds||this.boxBounds}set contentBounds(t){this._contentBounds=t}get strokeBounds(){return this._strokeBounds||this.boxBounds}get renderBounds(){return this._renderBounds||this.boxBounds}get localContentBounds(){return Io(this.contentBounds,this.leaf.__localMatrix,this[zo]||(this[zo]={})),this[zo]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return Io(this.contentBounds,this.leaf.__world,this[No]||(this[No]={})),this[No]}get worldBoxBounds(){return Io(this.boxBounds,this.leaf.__world,this[Yo]||(this[Yo]={})),this[Yo]}get worldStrokeBounds(){return Io(this.strokeBounds,this.leaf.__world,this[Xo]||(this[Xo]={})),this[Xo]}get a(){return 1}get b(){return 0}get c(){return 0}get d(){return 1}get e(){return this.leaf.__.x}get f(){return this.leaf.__.y}get x(){return this.e+this.boxBounds.x}get y(){return this.f+this.boxBounds.y}get width(){return this.boxBounds.width}get height(){return this.boxBounds.height}constructor(t){this.leaf=t,this.boxBounds={x:0,y:0,width:0,height:0},this.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),this.boxChange(),this.matrixChange()}createLocal(){const t=this.leaf.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0};this._localStrokeBounds||(this._localStrokeBounds=t),this._localRenderBounds||(this._localRenderBounds=t)}update(){const{leafer:e}=this.leaf;if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=this.leaf;for(;e.parent&&!e.parent.leafer;)e=e.parent;const i=e;if(i.__fullLayouting)return;i.__fullLayouting=!0,t.layout(i),delete i.__fullLayouting}}getTransform(t="world"){this.update();const{leaf:e}=this;switch(t){case"world":return e.__world;case"local":return e.__localMatrix;case"inner":return x.defaultMatrix;case"page":t=e.zoomLayer;default:return Do(e,t)}}getBounds(t,e="world"){switch(this.update(),e){case"world":return this.getWorldBounds(t);case"local":return this.getLocalBounds(t);case"inner":return this.getInnerBounds(t);case"page":e=this.leaf.zoomLayer;default:return new ht(this.getInnerBounds(t)).toOuterOf(this.getTransform(e))}}getInnerBounds(t="box"){switch(t){case"render":return this.renderBounds;case"content":if(this.contentBounds)return this.contentBounds;case"box":return this.boxBounds;case"stroke":return this.strokeBounds}}getLocalBounds(t="box"){switch(t){case"render":return this.localRenderBounds;case"stroke":return this.localStrokeBounds;case"content":if(this.contentBounds)return this.localContentBounds;case"box":return this.leaf.__localBoxBounds}}getWorldBounds(t="box"){switch(t){case"render":return this.leaf.__world;case"stroke":return this.worldStrokeBounds;case"content":if(this.contentBounds)return this.worldContentBounds;case"box":return this.worldBoxBounds}}getLayoutBounds(t,e="world",i){const{leaf:s}=this;let n,o,r,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;r={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,o=x.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),o=Do(s,e,!0)}if(r||(r=x.getLayout(o)),Fo(r,a),P.copy(r,n),i){const{scaleX:t,scaleY:e}=r,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(r.scaleX/=i,r.scaleY/=s,r.width*=i,r.height*=s)}return r}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=Wo(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:n=e}return void 0!==n&&s.forEach((t=>i.innerToWorld(t,null,!1,n))),s}shrinkContent(){const{x:t,y:e,width:i,height:s}=this.boxBounds;this._contentBounds={x:t,y:e,width:i,height:s}}spreadStroke(){const{x:t,y:e,width:i,height:s}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:i,height:s},this._localStrokeBounds={x:t,y:e,width:i,height:s},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:i,height:s}=this.renderBounds;this._renderBounds={x:t,y:e,width:i,height:s},this._localRenderBounds={x:t,y:e,width:i,height:s}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class Vo{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&t.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&t.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&t.event.stop(this.origin)}}class jo extends Vo{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}jo.ADD="child.add",jo.REMOVE="child.remove",jo.CREATED="created",jo.MOUNTED="mounted",jo.UNMOUNTED="unmounted",jo.DESTROY="destroy";class Uo extends Vo{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Uo.CHANGE="property.change",Uo.LEAFER_CHANGE="property.leafer_change";class Go extends Vo{constructor(t,e){super(t),Object.assign(this,e)}}Go.LOAD="image.load",Go.LOADED="image.loaded",Go.ERROR="image.error";class Zo extends Vo{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){"object"==typeof t?(super(Zo.RESIZE),Object.assign(this,t)):super(t),this.old=e}}Zo.RESIZE="resize";class Ko extends Vo{constructor(t,e){super(t),this.data=e}}Ko.REQUEST="watch.request",Ko.DATA="watch.data";class qo extends Vo{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}qo.REQUEST="layout.request",qo.START="layout.start",qo.BEFORE="layout.before",qo.LAYOUT="layout",qo.AFTER="layout.after",qo.AGAIN="layout.again",qo.END="layout.end";class Jo extends Vo{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Jo.REQUEST="render.request",Jo.CHILD_START="render.child_start",Jo.START="render.start",Jo.BEFORE="render.before",Jo.RENDER="render",Jo.AFTER="render.after",Jo.AGAIN="render.again",Jo.END="render.end",Jo.NEXT="render.next";class $o extends Vo{}$o.START="leafer.start",$o.BEFORE_READY="leafer.before_ready",$o.READY="leafer.ready",$o.AFTER_READY="leafer.after_ready",$o.VIEW_READY="leafer.view_ready",$o.VIEW_COMPLETED="leafer.view_completed",$o.STOP="leafer.stop",$o.RESTART="leafer.restart",$o.END="leafer.end";const Qo={};class tr{set event(t){this.on(t)}on(t,e,i){if(!e){let e,i=t;for(let t in i)e=i[t],e instanceof Array?this.on(t,e[0],e[1]):this.on(t,e);return}let s,n,o;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const r=er(this,s,!0),a="string"==typeof t?t.split(" "):t,h=n?{listener:e,once:n}:{listener:e};a.forEach((t=>{t&&(o=r[t],o?-1===o.findIndex((t=>t.listener===e))&&o.push(h):r[t]=[h])}))}off(t,e,i){if(t){const s="string"==typeof t?t.split(" "):t;if(e){let t,n,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const r=er(this,t);s.forEach((t=>{t&&(n=r[t],n&&(o=n.findIndex((t=>t.listener===e)),o>-1&&n.splice(o,1),n.length||delete r[t]))}))}else{const{__bubbleMap:t,__captureMap:e}=this;s.forEach((i=>{t&&delete t[i],e&&delete e[i]}))}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,i,s){return i&&(e=e.bind(i)),this.on(t,e,s),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=t instanceof Array?t:[t];e.forEach((t=>t.current.off(t.type,t.listener,t.options))),e.length=0}once(t,e,i){this.on(t,e,{once:!0,capture:i})}emit(t,e,i){!e&&St.has(t)&&(e=St.get(t,{type:t,target:this,current:this}));const s=er(this,i)[t];if(s){let n;for(let o=0,r=s.length;o<r&&!((n=s[o])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),o--,r--),e&&e.isStopNow));o++);}this.syncEventer&&this.syncEventer.emitEvent(e,i)}emitEvent(t,e){t.current=this,this.emit(t.type,t,e)}hasEvent(t,e){if(this.syncEventer&&this.syncEventer.hasEvent(t,e))return!0;const{__bubbleMap:i,__captureMap:s}=this,n=i&&i[t],o=s&&s[t];return!!(void 0===e?n||o:e?o:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function er(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Qo)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Qo)}}const{on:ir,on_:sr,off:nr,off_:or,once:rr,emit:ar,emitEvent:hr,hasEvent:lr,destroy:dr}=tr.prototype,cr={on:ir,on_:sr,off:nr,off_:or,once:rr,emit:ar,emitEvent:hr,hasEvent:lr,destroyEventer:dr},{isFinite:ur}=Number,_r=vt.get("setAttr"),pr={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(i&&!ur(e)&&void 0!==e&&(_r.warn(this.innerName,t,e),e=void 0),"object"==typeof e||s!==e){this.__realSetAttr(t,e);const{CHANGE:i}=Uo,n=new Uo(i,this,t,s,e);return this.isLeafer?this.emitEvent(new Uo(Uo.LEAFER_CHANGE,this,t,s,e)):this.hasEvent(i)&&this.emitEvent(n),this.leafer.emitEvent(n),!0}return!1}return this.__realSetAttr(t,e),!0},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||void 0===i.normalStyle[t]||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:gr,multiplyParent:fr,translateInner:yr,defaultWorld:mr}=x,{toPoint:vr,tempPoint:wr}=pt,xr={__updateWorldMatrix(){fr(this.__local||this.__layout,this.parent?this.parent.__world:mr,this.__world,!!this.__layout.affectScaleOrRotation,this.__,this.parent&&this.parent.__)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged||t.rotationChanged)&&(gr(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=!1),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(vr(i.around||i.origin,t.boxBounds,wr),yr(e,-wr.x,-wr.y,!i.around))}this.__layout.matrixChanged=!1}},{updateMatrix:br,updateAllMatrix:kr}=xo,{updateBounds:Er}=To,{toOuterOf:Br,copyAndSpread:Rr,copy:Cr}=nt,{toBounds:Lr}=$s,Or={__updateWorldBounds(){Br(this.__layout.renderBounds,this.__world,this.__world),this.__layout.resized&&(this.__onUpdateSize(),this.__layout.resized=!1)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized=!0),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=!1,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=!1,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=!1,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized=!0),t.renderChanged&&(t.renderSpread=this.__updateRenderSpread(),t.renderSpread?(t.renderBounds!==t.boxBounds&&t.renderBounds!==t.strokeBounds||t.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):t.spreadRenderCancel(),t.renderChanged=!1,this.parent&&this.parent.__layout.renderChange()),t.boundsChanged=!1},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),Br(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Br(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Br(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,e=this.__;e.__pathInputed?Lr(e.path,t):(t.x=0,t.y=0,t.width=e.width,t.height=e.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),kr(this),Er(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(kr(this),Er(this,this))):br(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(){const t=this.__layout;Rr(t.strokeBounds,t.boxBounds,t.strokeBoxSpread)},__updateRenderBounds(){const t=this.__layout;t.renderSpread>0?Rr(t.renderBounds,t.boxBounds,t.renderSpread):Cr(t.renderBounds,t.strokeBounds)}},Tr={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=this.__.opacity,this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!0,!0);this.__draw(i,e,t),this.__worldFlipped?t.copyWorldByReset(i,this.__nowWorld,null,this.__.__blendMode,!0):t.copyWorldToInner(i,this.__nowWorld,this.__layout.renderBounds,this.__.__blendMode),i.recycle(this.__nowWorld)}else this.__draw(t,e)},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),this.windingRule?t.clip(this.windingRule):t.clip())},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:Sr}=Lo,Pr={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__nowWorld=this.__getNowWorld(e),this.__worldOpacity)if(this.__.__single){if("path"===this.__.eraser)return this.__renderEraser(t,e);const i=t.getSameCanvas(!1,!0);this.__renderBranch(i,e);const s=this.__nowWorld;t.opacity=this.__.opacity,t.copyWorldByReset(i,s,s,this.__.__blendMode,!0),i.recycle(s)}else this.__renderBranch(t,e)},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Sr(i[s],e)||i[s].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Sr(i[s],e)||i[s].__clip(t,e)}}},{LEAF:Mr,create:Ar}=i,{toInnerPoint:Dr,toOuterPoint:Ir,multiplyParent:Wr}=x,{toOuterOf:Fr}=nt,{copy:zr,move:Nr}=P,{moveLocal:Yr,zoomOfLocal:Xr,rotateOfLocal:Hr,skewOfLocal:Vr,moveWorld:jr,zoomOfWorld:Ur,rotateOfWorld:Gr,skewOfWorld:Zr,transform:Kr,transformWorld:qr,setTransform:Jr,getFlipTransform:$r,getLocalOrigin:Qr,getRelativeWorld:ta,drop:ea}=xo;let ia=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return It}get __LayoutProcessor(){return Ho}get leaferIsCreated(){return this.leafer&&this.leafer.created}get leaferIsReady(){return this.leafer&&this.leafer.ready}get isLeafer(){return!1}get isBranch(){return!1}get isBranchLeaf(){return!1}get __localMatrix(){return this.__local||this.__layout}get __localBoxBounds(){return this.__local||this.__layout}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get boxBounds(){return this.getBounds("box","inner")}get renderBounds(){return this.getBounds("render","inner")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.__layout.update(),this.__worldOpacity}get __worldFlipped(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}get __inLazyBounds(){return this.leaferIsCreated&&this.leafer.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=Ar(Mr),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(jo.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1},null!==t&&(this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0}),this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),this.__level&&this.resetCustom(),t&&(t.__&&(t=t.toJSON()),t.children?this.set(t):Object.assign(this,t))}resetCustom(){this.__hasMask=this.__hasEraser=null,this.forceUpdate()}waitParent(t,e){e&&(t=t.bind(e)),this.parent?t():this.on(jo.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(jo.MOUNTED,t,"once")}nextRender(t,e,i){this.leafer?this.leafer.nextRender(t,e,i):this.waitLeafer((()=>this.leafer.nextRender(t,e,i)))}removeNextRender(t){this.nextRender(t,null,"off")}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer&&!t&&this.leafer.leafs--,this.leafer=t,t?(t.leafs++,this.__level=this.parent?this.parent.__level+1:1,this.animation&&this.__runAnimation("in"),this.__bubbleMap&&this.__emitLifeEvent(jo.MOUNTED)):this.__emitLifeEvent(jo.UNMOUNTED),this.isBranch){const{children:e}=this;for(let i=0,s=e.length;i<s;i++)e[i].__bindLeafer(t)}}set(t,e){}get(t){}setAttr(t,e){this[t]=e}getAttr(t){return this[t]}getComputedAttr(t){return this.__[t]}toJSON(t){return t&&this.__layout.update(),this.__.__getInputData(null,t)}toString(t){return JSON.stringify(this.toJSON(t))}toSVG(){}__SVG(t){}toHTML(){}__setAttr(t,e){return!0}__getAttr(t){}setProxyAttr(t,e){}getProxyAttr(t){}find(t,e){}findTag(t){}findOne(t,e){}findId(t){}focus(t){}updateState(){}updateLayout(){this.__layout.update()}forceUpdate(t){void 0===t?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}forceRender(t,e){this.forceUpdate("surface")}__extraUpdate(){this.leaferIsReady&&this.leafer.layouter.addExtra(this)}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateContentBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some((t=>t.__.eraser))}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:i}=this.__layout;t.clearRect(i.x,i.y,i.width,i.height),t.restore()}__updateMask(t){this.__hasMask=this.children.some((t=>t.__.mask&&t.__.visible&&t.__.opacity))}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld;return Wr(this.__world,t.matrix,e,void 0,this.__world),Fr(this.__layout.renderBounds,e,e),e}return this.__world}getTransform(t){return this.__layout.getTransform(t||"local")}getBounds(t,e){return this.__layout.getBounds(t,e)}getLayoutBounds(t,e,i){return this.__layout.getLayoutBounds(t,e,i)}getLayoutPoints(t,e){return this.__layout.getLayoutPoints(t,e)}getWorldBounds(t,e,i){const s=e?ta(this,e):this.worldTransform,n=i?t:{};return Fr(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&zr(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&zr(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Dr(this.worldTransform,t,e,i)}innerToWorld(t,e,i,s){Ir(this.worldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Nr(n,-o,-r),n}getInnerPoint(t,e,i,s){const n=s?t:{};return this.worldToInner(t,n,i,e),n}getInnerPointByBox(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Nr(n,o,r),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){Jr(this,t,e,i)}transform(t,e,i){Kr(this,t,e,i)}move(t,e,i){Yr(this,t,e,i)}moveInner(t,e,i){jr(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Xr(this,Qr(this,t),e,i,s,n)}rotateOf(t,e,i){Hr(this,Qr(this,t),e,i)}skewOf(t,e,i,s,n){Vr(this,Qr(this,t),e,i,s,n)}transformWorld(t,e,i){qr(this,t,e,i)}moveWorld(t,e,i){jr(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){Ur(this,t,e,i,s,n)}rotateOfWorld(t,e){Gr(this,t,e)}skewOfWorld(t,e,i,s,n){Zr(this,t,e,i,s,n)}flip(t,e){Kr(this,$r(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}__hitWorld(t){return!0}__hit(t){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e){}__clip(t,e){}__renderShape(t,e,i,s){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return Rt.need("path")}getMotionPoint(t){return Rt.need("path")}getMotionTotal(){return 0}__updateMotionPath(){}__runAnimation(t,e){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}dropTo(t,e,i){ea(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):to(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=Mn),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new jo(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(jo.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};ia=Yt([ao(pr),ao(xr),ao(Or),ao(cr),ao(Tr)],ia);const{setListWithFn:sa}=nt,{sort:na}=To,{localBoxBounds:oa,localStrokeBounds:ra,localRenderBounds:aa,maskLocalBoxBounds:ha,maskLocalStrokeBounds:la,maskLocalRenderBounds:da}=Lo,ca=new vt("Branch");let ua=class extends ia{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(){sa(this.__layout.boxBounds,this.children,this.__hasMask?ha:oa)}__updateStrokeBounds(){sa(this.__layout.strokeBounds,this.children,this.__hasMask?la:ra)}__updateRenderBounds(){sa(this.__layout.renderBounds,this.children,this.__hasMask?da:aa)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let i=0,s=e.length;i<s;i++)e[i].__tempNumber=i,e[i].__.zIndex&&(t=!0);e.sort(na),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return ca.warn("add self or destroyed");const i=void 0===e;if(!t.__){if(t instanceof Array)return t.forEach((t=>{this.add(t,e),i||e++}));t=Lt.get(t.tag,t)}t.parent&&t.parent.remove(t),t.parent=this,i?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1);const s=t.__layout;s.boxChanged||s.boxChange(),s.matrixChanged||s.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(jo.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(jo.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){this.add(t)}remove(t,e){t?t.__?t.animationOut?t.__runAnimation("out",(()=>this.__remove(t,e))):this.__remove(t,e):this.find(t).forEach((t=>this.remove(t,e))):void 0===t&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach((e=>{this.__realRemoveChild(e),t&&e.destroy()})))}clear(){this.removeAll(!0)}__remove(t,e){const i=this.children.indexOf(t);i>-1&&(this.children.splice(i,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.__emitLifeEvent(jo.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(jo.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new jo(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};ua=Yt([ao(Pr)],ua);class _a{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return t&&void 0!==this.keys[t.innerId]}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return void 0===e?-1:e}add(t){const{list:e,keys:i}=this;void 0===i[t.innerId]&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(void 0===i[t.innerId]){const{list:s}=this;for(let t=e,n=s.length;t<n;t++)i[s[t].innerId]++;0===e?s.unshift(t):(e>s.length&&(e=s.length),s.splice(e,0,t)),i[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let i;for(let s=0,n=e.length;s<n;s++)void 0!==i?this.keys[e[s].innerId]=s-1:e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]);void 0!==i&&e.splice(i,1)}sort(t){const{list:e}=this;t?e.sort(((t,e)=>e.__level-t.__level)):e.sort(((t,e)=>t.__level-e.__level))}forEach(t){this.list.forEach(t)}clone(){const t=new _a;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let i=0,s=t.length;i<s;i++)e[t[i].innerId]=i}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}class pa{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(t instanceof Array?this.addList(t):this.add(t))}has(t){return void 0!==this.keys[t.innerId]}without(t){return void 0===this.keys[t.innerId]}sort(t){const{levels:e}=this;t?e.sort(((t,e)=>e-t)):e.sort(((t,e)=>t-e))}addList(t){t.forEach((t=>{this.add(t)}))}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach((i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])}))}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}const ga="1.5.2";class fa extends Jt{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}ln(OffscreenCanvasRenderingContext2D.prototype),ln(Path2D.prototype);const{mineType:ya}=dn;function ma(i,s){t.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:ya(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:ya(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((i,s)=>{let n=new XMLHttpRequest;n.open("GET",t.image.getRealURL(e),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then((t=>{i(t)})).catch((t=>{s(t)}))},n.onerror=t=>s(t),n.send()}))},t.canvas=e.canvas(),t.conicGradientSupport=!!t.canvas.context.createConicGradient}Object.assign(e,{canvas:(t,e)=>new fa(t,e),image:t=>new bn(t)}),t.name="web",t.isWorker=!0,t.backgrounder=!0,t.requestRender=function(t){requestAnimationFrame(t)},kn(t,"devicePixelRatio",{get:()=>1});const{userAgent:va}=navigator;va.indexOf("Firefox")>-1?(t.conicGradientRotate90=!0,t.intWheelDeltaY=!0):va.indexOf("Safari")>-1&&-1===va.indexOf("Chrome")&&(t.fullImageShadow=!0),va.indexOf("Windows")>-1?(t.os="Windows",t.intWheelDeltaY=!0):va.indexOf("Mac")>-1?t.os="Mac":va.indexOf("Linux")>-1&&(t.os="Linux");class wa{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new _a;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new _a,this.target=t,e&&(this.config=At.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(Jo.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===jo.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new Ko(Ko.DATA,{updatedList:this.updatedList})),this.__updatedList=new _a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Uo.CHANGE,this.__onAttrChange,this),t.on_([jo.ADD,jo.REMOVE],this.__onChildEvent,this),t.on_(Ko.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:xa,updateBounds:ba,updateAllWorldOpacity:ka}=xo,{pushAllChildBranch:Ea,pushAllParent:Ba}=To;const{worldBounds:Ra}=Lo,Ca={x:0,y:0,width:1e5,height:1e5};class La{constructor(t){this.updatedBounds=new ht,this.beforeBounds=new ht,this.afterBounds=new ht,t instanceof Array&&(t=new _a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Ra)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Ca):this.afterBounds.setListWithFn(t,Ra),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:Oa,updateAllChange:Ta}=xo,Sa=vt.get("Layouter");class Pa{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new pa,this.target=t,e&&(this.config=At.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(qo.START),this.layoutOnce(),t.emitEvent(new qo(qo.END,this.layoutedBlocks,this.times))}catch(t){Sa.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Sa.warn("layouting"):this.times>3?Sa.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Ko.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=kt.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=qo,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new qo(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(xa(t,!0),e.add(t),t.isBranch&&Ea(t,e),Ba(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Ba(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||ba(s[t])}ba(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&ka(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new qo(o,a,this.times)),i.emitEvent(new qo(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,kt.end(e)}fullLayout(){const t=kt.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=qo,o=this.getBlocks(new _a(e));e.emitEvent(new qo(i,o,this.times)),Pa.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new qo(s,o,this.times)),e.emitEvent(new qo(n,o,this.times)),this.addBlocks(o),kt.end(t)}static fullLayout(t){Oa(t,!0),t.isBranch?To.updateBounds(t):xo.updateBounds(t),Ta(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new La([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new La(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(qo.REQUEST,this.layout,this),t.on_(qo.AGAIN,this.layoutAgain,this),t.on_(Ko.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Ma=vt.get("Renderer");class Aa{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=At.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(qo.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new ht,Ma.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(Jo.CHILD_START,e),this.emitRender(Jo.START),this.renderOnce(t),this.emitRender(Jo.END,this.totalBounds),mn.clearRecycled()}catch(t){this.rendering=!1,Ma.error(t)}Ma.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Ma.warn("rendering");if(this.times>3)return Ma.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new ht,this.renderOptions={},t)this.emitRender(Jo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Jo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Jo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Jo.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=kt.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new ht(s);i.save(),n&&!vt.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),kt.end(e)}fullRender(){const t=kt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),kt.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),vt.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),vt.showHitView&&this.renderHitView(s),vt.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new ht;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(Jo.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new ht(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new ht(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Ma.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new Jo(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Jo.REQUEST,this.update,this),t.on_(qo.END,this.__onLayoutEnd,this),t.on_(Jo.AGAIN,this.renderAgain,this),t.on_(Zo.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:Da}=nt;class Ia{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new _a(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new _a;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||xo.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new _a;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new _a;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new _a,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||Da(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Wa{constructor(t,i){this.config={},i&&(this.config=At.default(i,this.config)),this.picker=new Ia(this.target=t,this),this.finder=e.finder&&e.finder()}getByPoint(e,i,s){const{target:n,picker:o}=this;return t.backgrounder&&n&&n.updateLayout(),o.getByPoint(e,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):Rt.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Fa(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function za(t){return Bn(t,(t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function Na(){return(t,e)=>{const i="_"+e;kn(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}Object.assign(e,{watcher:(t,e)=>new wa(t,e),layouter:(t,e)=>new Pa(t,e),renderer:(t,e,i)=>new Aa(t,e,i),selector:(t,e)=>new Wa(t,e)}),t.layout=Pa.fullLayout;const Ya={},Xa={},Ha={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},Va={},ja={},Ua={},Ga={},Za={},Ka={apply(){Rt.need("filter")}},qa={},Ja={setStyleName:()=>Rt.need("state"),set:()=>Rt.need("state")},$a={list:{},register(t,e){$a.list[t]=e},get:t=>$a.list[t]},{parse:Qa,objectToCanvasData:th}=vi,eh={},ih=vt.get("UIData");class sh extends It{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,ih.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,ih.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=eh)):(this.__isFills&&(this.__removeInput("fill"),Ua.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=eh)):(this.__isStrokes&&(this.__removeInput("stroke"),Ua.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Qa(t):th(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){nh(this,"shadow",t)}setInnerShadow(t){nh(this,"innerShadow",t)}setFilter(t){nh(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ja.compute("fill",this.__leaf),e&&ja.compute("stroke",this.__leaf),this.__needComputePaint=!1}}function nh(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=null)):i=i&&!1!==i.visible?[i]:null,t["_"+e]=i}class oh extends sh{}class rh extends oh{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class ah extends oh{__getInputData(t,e){const i=super.__getInputData(t,e);return qt.forEach((t=>delete i[t])),i}}class hh extends rh{}class lh extends sh{}class dh extends sh{get __boxStroke(){return!this.__pathInputed}}class ch extends sh{get __boxStroke(){return!this.__pathInputed}}class uh extends sh{}class _h extends sh{}class ph extends sh{get __pathInputed(){return 2}}class gh extends oh{}const fh={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class yh extends sh{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=fh[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class mh extends dh{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class vh extends dh{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const wh={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:n}=i;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),o&&(t+=Ka.getSpread(o));let r=t=Math.ceil(t);return i&&i.forEach((t=>r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),n&&(r=Math.max(r,n)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},xh={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:o}=this.__;t.__useEffect=!!(e||i||s||n||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){bh(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:o,__drawAfterFill:r}=s;if(this.__drawRenderPath(t),s.__useEffect){const a=ja.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:l,filter:d}=s;h&&Za.shadow(this,t,a),n&&(s.__isFills?ja.fills(n,this,t):ja.fill(n,this,t)),r&&this.__drawAfterFill(t,e),l&&Za.innerShadow(this,t,a),o&&(s.__isStrokes?ja.strokes(o,this,t):ja.stroke(o,this,t)),d&&Ka.apply(d,this,this.__nowWorld,t,i,a),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else n&&(s.__isFills?ja.fills(n,this,t):ja.fill(n,this,t)),r&&this.__drawAfterFill(t,e),o&&(s.__isStrokes?ja.strokes(o,this,t):ja.stroke(o,this,t))}else s.__pathInputed?bh(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:n,stroke:o}=this.__;this.__drawRenderPath(t),n&&!i&&(this.__.__pixelFill?ja.fills(n,this,t):ja.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),o&&!s&&(this.__.__pixelStroke?ja.strokes(o,this,t):ja.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function bh(t,e,i){const{fill:s,stroke:n,__drawAfterFill:o}=t.__;t.__drawRenderPath(e),s&&ja.fill(s,t,e),o&&t.__drawAfterFill(e,i),n&&ja.stroke(n,t,e)}const kh={__drawFast(t,e){let{width:i,height:s,fill:n,stroke:o,__drawAfterFill:r}=this.__;if(n&&(t.fillStyle=n,t.fillRect(0,0,i,s)),r&&this.__drawAfterFill(t,e),o){const{strokeAlign:n,__strokeWidth:r}=this.__;if(!r)return;t.setStroke(o,r,this.__);const a=r/2;switch(n){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=r,s-=r,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(a,a,i,s),t.restore()):t.strokeRect(a,a,i,s);break;case"outside":t.strokeRect(-a,-a,i+r,s+r)}}}};var Eh;let Bh=Eh=class extends ia{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){a.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return an.set(this.path=t||[]),t||this.__drawPathByBox(an),an}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return Rt.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return Rt.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(an.set(i=[]),this.__drawPathByBox(an)),t?vi.toCanvasData(i,!0):i}getPathString(t,e,i){return vi.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||qa.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?rn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Va.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?ws.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:n}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:o}=this.__;t.roundRect(e,i,s,n,"number"==typeof o?[o]:o)}else t.rect(e,i,s,n)}animate(t,e,i,s){return Rt.need("animate")}killAnimate(t,e){}export(t,e){return Rt.need("export")}syncExport(t,e){return Rt.need("export")}clone(t){const e=At.clone(this.toJSON());return t&&Object.assign(e,t),Eh.one(e)}static one(t,e,i,s,n){return Lt.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){ho()(this)}static registerData(t){$n(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};Yt([$n(sh)],Bh.prototype,"__",void 0),Yt([Na()],Bh.prototype,"zoomLayer",void 0),Yt([Ln("")],Bh.prototype,"id",void 0),Yt([Ln("")],Bh.prototype,"name",void 0),Yt([Ln("")],Bh.prototype,"className",void 0),Yt([Xn("pass-through")],Bh.prototype,"blendMode",void 0),Yt([Hn(1)],Bh.prototype,"opacity",void 0),Yt([Vn(!0)],Bh.prototype,"visible",void 0),Yt([Xn(!1)],Bh.prototype,"locked",void 0),Yt([Gn(0)],Bh.prototype,"zIndex",void 0),Yt([Zn(!1)],Bh.prototype,"mask",void 0),Yt([Kn(!1)],Bh.prototype,"eraser",void 0),Yt([On(0,!0)],Bh.prototype,"x",void 0),Yt([On(0,!0)],Bh.prototype,"y",void 0),Yt([Mn(100,!0)],Bh.prototype,"width",void 0),Yt([Mn(100,!0)],Bh.prototype,"height",void 0),Yt([Sn(1,!0)],Bh.prototype,"scaleX",void 0),Yt([Sn(1,!0)],Bh.prototype,"scaleY",void 0),Yt([Pn(0,!0)],Bh.prototype,"rotation",void 0),Yt([Pn(0,!0)],Bh.prototype,"skewX",void 0),Yt([Pn(0,!0)],Bh.prototype,"skewY",void 0),Yt([On(0,!0)],Bh.prototype,"offsetX",void 0),Yt([On(0,!0)],Bh.prototype,"offsetY",void 0),Yt([On(0,!0)],Bh.prototype,"scrollX",void 0),Yt([On(0,!0)],Bh.prototype,"scrollY",void 0),Yt([Tn()],Bh.prototype,"origin",void 0),Yt([Tn()],Bh.prototype,"around",void 0),Yt([Ln(!1)],Bh.prototype,"lazy",void 0),Yt([An(1)],Bh.prototype,"pixelRatio",void 0),Yt([In()],Bh.prototype,"path",void 0),Yt([Wn()],Bh.prototype,"windingRule",void 0),Yt([Wn(!0)],Bh.prototype,"closed",void 0),Yt([Mn(0)],Bh.prototype,"padding",void 0),Yt([Mn(!1)],Bh.prototype,"lockRatio",void 0),Yt([Mn()],Bh.prototype,"widthRange",void 0),Yt([Mn()],Bh.prototype,"heightRange",void 0),Yt([Ln(!1)],Bh.prototype,"draggable",void 0),Yt([Ln()],Bh.prototype,"dragBounds",void 0),Yt([Ln(!1)],Bh.prototype,"editable",void 0),Yt([qn(!0)],Bh.prototype,"hittable",void 0),Yt([qn("path")],Bh.prototype,"hitFill",void 0),Yt([Nn("path")],Bh.prototype,"hitStroke",void 0),Yt([qn(!1)],Bh.prototype,"hitBox",void 0),Yt([qn(!0)],Bh.prototype,"hitChildren",void 0),Yt([qn(!0)],Bh.prototype,"hitSelf",void 0),Yt([qn()],Bh.prototype,"hitRadius",void 0),Yt([Jn("")],Bh.prototype,"cursor",void 0),Yt([Xn()],Bh.prototype,"fill",void 0),Yt([Nn()],Bh.prototype,"stroke",void 0),Yt([Nn("inside")],Bh.prototype,"strokeAlign",void 0),Yt([Nn(1)],Bh.prototype,"strokeWidth",void 0),Yt([Nn(!1)],Bh.prototype,"strokeWidthFixed",void 0),Yt([Nn("none")],Bh.prototype,"strokeCap",void 0),Yt([Nn("miter")],Bh.prototype,"strokeJoin",void 0),Yt([Nn()],Bh.prototype,"dashPattern",void 0),Yt([Nn(0)],Bh.prototype,"dashOffset",void 0),Yt([Nn(10)],Bh.prototype,"miterLimit",void 0),Yt([Wn(0)],Bh.prototype,"cornerRadius",void 0),Yt([Wn()],Bh.prototype,"cornerSmoothing",void 0),Yt([Fa()],Bh.prototype,"shadow",void 0),Yt([Fa()],Bh.prototype,"innerShadow",void 0),Yt([Fa()],Bh.prototype,"blur",void 0),Yt([Fa()],Bh.prototype,"backgroundBlur",void 0),Yt([Fa()],Bh.prototype,"grayscale",void 0),Yt([Fa()],Bh.prototype,"filter",void 0),Yt([Ln({})],Bh.prototype,"data",void 0),Yt([no(ia.prototype.reset)],Bh.prototype,"reset",null),Bh=Eh=Yt([ao(wh),ao(xh),oo()],Bh);let Rh=class extends Bh{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Ch;Yt([$n(oh)],Rh.prototype,"__",void 0),Yt([Mn(0)],Rh.prototype,"width",void 0),Yt([Mn(0)],Rh.prototype,"height",void 0),Rh=Yt([ao(ua),ho()],Rh);const Lh=vt.get("Leafer");let Oh=Ch=class extends Rh{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&fn.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Ch.list.add(this)}init(t,i){if(this.canvas)return;let s;const{config:n}=this;this.__setLeafer(this),i&&(this.parentApp=i,this.__bindApp(i),s=i.running),t&&(this.parent=i,this.initType(t.type),this.parent=void 0,At.assign(n,t));const o=this.canvas=e.canvas(n);this.__controllers.push(this.renderer=e.renderer(this,o,n),this.watcher=e.watcher(this,n),this.layouter=e.layouter(this,n)),this.isApp&&this.__setApp(),this.__checkAutoLayout(n,i),this.view=o.view,i||(this.selector=e.selector(this),this.interaction=e.interaction(this,o,this.selector,n),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=e.hitCanvasManager()),this.canvasManager=new Mt,s=n.start),this.hittable=n.hittable,this.fill=n.fill,this.canvasManager.add(o),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),Ao.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer($o.RESTART):this.emitLeafer($o.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer($o.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=At.copyAttrs({},t,qt);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new ht(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=At.copyAttrs({},this.canvas,qt);e.resize(t),this.updateLazyBounds(),this.__onResize(new Zo(t,i))}__onResize(t){this.emitEvent(t),At.copyAttrs(this.__,t,qt),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new dt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(qt.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&qt.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=At.copyAttrs({},this.canvas,qt);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer($o.BEFORE_READY),this.emitLeafer($o.READY),this.emitLeafer($o.AFTER_READY),Ao.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer($o.VIEW_READY),Ao.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:o}=this;const r="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,r.x+r.width)),i||(n=Math.max(1,r.y+r.height)),this.__doResize({width:s,height:n,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Ao.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer($o.VIEW_COMPLETED),Ao.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return Rt.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new $o(t,this))}__listenEvents(){const t=kt.start("FirstCreate "+this.innerName);this.once($o.START,(()=>kt.end(t))),this.once(qo.START,(()=>this.updateLazyBounds())),this.once(Jo.START,(()=>this.__onCreated())),this.once(Jo.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(Ko.DATA,this.__onWatchData,this),this.on_(qo.END,this.__onLayoutEnd,this),this.on_(Jo.NEXT,this.__onNextRender,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){Ch.list.remove(this);try{this.stop(),this.emitEvent(new $o($o.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{mn.clearRecycled()}),100)}catch(t){Lh.error(t)}}};t?e():setTimeout(e)}};Oh.list=new _a,Yt([$n(ah)],Oh.prototype,"__",void 0),Yt([Mn()],Oh.prototype,"pixelRatio",void 0),Oh=Ch=Yt([ho()],Oh);let Th=class extends Bh{get __tag(){return"Rect"}constructor(t){super(t)}};Yt([$n(dh)],Th.prototype,"__",void 0),Th=Yt([ao(kh),oo(),ho()],Th);const{copy:Sh,add:Ph,includes:Mh}=nt,Ah=Th.prototype,Dh=Rh.prototype,Ih={};let Wh=class extends Rh{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length&&!this.pathInputed)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),Sh(Ih,e),this.__updateRectRenderBounds(),t=!Mh(e,Ih),t&&"hide"!==this.__.overflow&&Ph(e,Ih)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};Yt([$n(rh)],Wh.prototype,"__",void 0),Yt([Mn(100)],Wh.prototype,"width",void 0),Yt([Mn(100)],Wh.prototype,"height",void 0),Yt([Ln(!1)],Wh.prototype,"resizeChildren",void 0),Yt([Yn("show")],Wh.prototype,"overflow",void 0),Yt([no(Ah.__updateStrokeSpread)],Wh.prototype,"__updateStrokeSpread",null),Yt([no(Ah.__updateRenderSpread)],Wh.prototype,"__updateRectRenderSpread",null),Yt([no(Ah.__updateBoxBounds)],Wh.prototype,"__updateRectBoxBounds",null),Yt([no(Ah.__updateStrokeBounds)],Wh.prototype,"__updateStrokeBounds",null),Yt([no(Ah.__updateRenderBounds)],Wh.prototype,"__updateRectRenderBounds",null),Yt([no(Ah.__updateChange)],Wh.prototype,"__updateRectChange",null),Yt([no(Ah.__render)],Wh.prototype,"__renderRect",null),Yt([no(Dh.__render)],Wh.prototype,"__renderGroup",null),Wh=Yt([oo(),ho()],Wh);let Fh=class extends Wh{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};Yt([$n(hh)],Fh.prototype,"__",void 0),Yt([Xn("#FFFFFF")],Fh.prototype,"fill",void 0),Yt([Yn("hide")],Fh.prototype,"overflow",void 0),Fh=Yt([ho()],Fh);const{moveTo:zh,closePath:Nh,ellipse:Yh}=Xi;let Xh=class extends Bh{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:i,innerRadius:s,startAngle:n,endAngle:o}=this.__,r=e/2,a=i/2,h=this.__.path=[];s?(n||o?(s<1&&Yh(h,r,a,r*s,a*s,0,n,o,!1),Yh(h,r,a,r,a,0,o,n,!0),s<1&&Nh(h)):(s<1&&(Yh(h,r,a,r*s,a*s),zh(h,e,a)),Yh(h,r,a,r,a,0,360,0,!0)),t.ellipseToCurve&&(this.__.path=this.getPath(!0))):n||o?(zh(h,r,a),Yh(h,r,a,r,a,0,n,o,!1),Nh(h)):Yh(h,r,a,r,a)}};Yt([$n(ch)],Xh.prototype,"__",void 0),Yt([Wn(0)],Xh.prototype,"innerRadius",void 0),Yt([Wn(0)],Xh.prototype,"startAngle",void 0),Yt([Wn(0)],Xh.prototype,"endAngle",void 0),Xh=Yt([ho()],Xh);const{moveTo:Hh,lineTo:Vh,drawPoints:jh}=Xi,{rotate:Uh,getAngle:Gh,getDistance:Zh,defaultPoint:Kh}=P,{toBounds:qh}=$s;let Jh=class extends Bh{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&Uh(i,e),i}set toPoint(t){this.width=Zh(Kh,t),this.rotation=Gh(Kh,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?jh(e,t.points,!1,t.closed):(Hh(e,0,0),Vh(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(jh(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&Va.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?qh(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};Yt([$n(lh)],Jh.prototype,"__",void 0),Yt([Fn("center")],Jh.prototype,"strokeAlign",void 0),Yt([Mn(0)],Jh.prototype,"height",void 0),Yt([Wn()],Jh.prototype,"points",void 0),Yt([Wn(0)],Jh.prototype,"curve",void 0),Yt([Wn(!1)],Jh.prototype,"closed",void 0),Jh=Yt([ho()],Jh);const{sin:$h,cos:Qh,PI:tl}=Math,{moveTo:el,lineTo:il,closePath:sl,drawPoints:nl}=Xi,ol=Jh.prototype;let rl=class extends Bh{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)nl(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,n=e/2,o=i/2;el(t,n,0);for(let e=1;e<s;e++)il(t,n+n*$h(2*e*tl/s),o-o*Qh(2*e*tl/s))}sl(t)}__updateRenderPath(){}__updateBoxBounds(){}};Yt([$n(uh)],rl.prototype,"__",void 0),Yt([Wn(3)],rl.prototype,"sides",void 0),Yt([Wn()],rl.prototype,"points",void 0),Yt([Wn(0)],rl.prototype,"curve",void 0),Yt([no(ol.__updateRenderPath)],rl.prototype,"__updateRenderPath",null),Yt([no(ol.__updateBoxBounds)],rl.prototype,"__updateBoxBounds",null),rl=Yt([oo(),ho()],rl);const{sin:al,cos:hl,PI:ll}=Math,{moveTo:dl,lineTo:cl,closePath:ul}=Xi;let _l=class extends Bh{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,o=e/2,r=this.__.path=[];dl(r,n,0);for(let t=1;t<2*i;t++)cl(r,n+(t%2==0?n:n*s)*al(t*ll/i),o-(t%2==0?o:o*s)*hl(t*ll/i));ul(r)}};Yt([$n(_h)],_l.prototype,"__",void 0),Yt([Wn(5)],_l.prototype,"corners",void 0),Yt([Wn(.382)],_l.prototype,"innerRadius",void 0),_l=Yt([ho()],_l);let pl=class extends Th{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(Go.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};Yt([$n(mh)],pl.prototype,"__",void 0),Yt([Mn("")],pl.prototype,"url",void 0),pl=Yt([ho()],pl);const gl=pl;let fl=class extends Th{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=e.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new bn({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Go(Go.LOADED,{image:t}))}))}draw(t,e,i,s){const n=new z(t.worldTransform).invert(),o=new z;e&&o.translate(e.x,e.y),i&&("number"==typeof i?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),n.multiplyParent(o),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};Yt([$n(vh)],fl.prototype,"__",void 0),Yt([za(100)],fl.prototype,"width",void 0),Yt([za(100)],fl.prototype,"height",void 0),Yt([za(1)],fl.prototype,"pixelRatio",void 0),Yt([za(!0)],fl.prototype,"smooth",void 0),Yt([Ln(!1)],fl.prototype,"safeResize",void 0),Yt([za()],fl.prototype,"contextSettings",void 0),fl=Yt([ho()],fl);const{copyAndSpread:yl,includes:ml,isSame:vl,spread:wl,setList:xl}=nt;let bl=class extends Bh{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:n}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):n.rows.forEach((n=>t.rect(n.x,n.y-s,n.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;t.rect(i,s,n,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:o,italic:r,textCase:h,textOverflow:l,padding:d}=t;t.__lineHeight=Ha.number(e,n),t.__letterSpacing=Ha.number(i,n),t.__padding=d?a.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${r?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==o?o+" ":""}${n}px ${s}`,t.__clipText="show"!==l&&!t.__autoSize,t.__textDrawData=Ya.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:o,__autoHeight:r}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(t.__lineHeight<i&&wl(a,i/2),o||r){if(h.x=o?a.x:0,h.y=r?a.y:0,h.width=o?a.width:t.width,h.height=r?a.height:t.height,n){const[e,i,s,n]=t.__padding;o&&(h.x-=n,h.width+=i+n),r&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i);const l=ml(h,a)?h:a;vl(l,e.contentBounds)?t.__textBoxBounds=l:(e.contentBounds=l,e.renderChanged=!0,xl(t.__textBoxBounds={},[h,a]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){yl(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};Yt([$n(yh)],bl.prototype,"__",void 0),Yt([Mn(0)],bl.prototype,"width",void 0),Yt([Mn(0)],bl.prototype,"height",void 0),Yt([Ln(!1)],bl.prototype,"resizeFontSize",void 0),Yt([Xn("#000000")],bl.prototype,"fill",void 0),Yt([Fn("outside")],bl.prototype,"strokeAlign",void 0),Yt([qn("all")],bl.prototype,"hitFill",void 0),Yt([Mn("")],bl.prototype,"text",void 0),Yt([Mn("caption")],bl.prototype,"fontFamily",void 0),Yt([Mn(12)],bl.prototype,"fontSize",void 0),Yt([Mn("normal")],bl.prototype,"fontWeight",void 0),Yt([Mn(!1)],bl.prototype,"italic",void 0),Yt([Mn("none")],bl.prototype,"textCase",void 0),Yt([Mn("none")],bl.prototype,"textDecoration",void 0),Yt([Mn(0)],bl.prototype,"letterSpacing",void 0),Yt([Mn({type:"percent",value:1.5})],bl.prototype,"lineHeight",void 0),Yt([Mn(0)],bl.prototype,"paraIndent",void 0),Yt([Mn(0)],bl.prototype,"paraSpacing",void 0),Yt([Mn("x")],bl.prototype,"writingMode",void 0),Yt([Mn("left")],bl.prototype,"textAlign",void 0),Yt([Mn("top")],bl.prototype,"verticalAlign",void 0),Yt([Mn(!0)],bl.prototype,"autoSizeAlign",void 0),Yt([Mn("normal")],bl.prototype,"textWrap",void 0),Yt([Mn("show")],bl.prototype,"textOverflow",void 0),bl=Yt([ho()],bl);let kl=class extends Bh{get __tag(){return"Path"}constructor(t){super(t)}};Yt([$n(ph)],kl.prototype,"__",void 0),Yt([Fn("center")],kl.prototype,"strokeAlign",void 0),kl=Yt([ho()],kl);let El=class extends Rh{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new kl(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,o){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,n){return this}ellipse(t,e,i,s,n,o,r,a){return this}arc(t,e,i,s,n,o){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,o,r,a){return this}drawArc(t,e,i,s,n,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};Yt([$n(gh)],El.prototype,"__",void 0),Yt([(t,e)=>{kn(t,e,{get(){return this.__path}})}],El.prototype,"path",void 0),El=Yt([ao(os,["set","path","paint"]),ho()],El);let Bl=class extends Oh{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,i){if(super.init(t,i),t){const{ground:i,tree:s,sky:n,editor:o}=t;i&&(this.ground=this.addLeafer(i)),(s||o)&&(this.tree=this.addLeafer(s||{type:t.type||"design"})),(n||o)&&(this.sky=this.addLeafer(n)),o&&this.sky.add(this.editor=e.editor(o))}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:i}=this.config;e||i===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(Uo.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}forceRender(t,e){this.children.forEach((i=>i.forceRender(t,e)))}addLeafer(t){const e=new Oh(t);return this.add(e),e}add(t,e){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t,e)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t,e),void 0!==e&&(t.canvas.childIndex=e),this.__listenChildEvents(t)}__onPropertyChange(){vt.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){if(t.context){const i=e.matrix;i&&t.setTransform(i.a,i.b,i.c,i.d,i.e,i.f),this.children.forEach((e=>t.copyWorld(e.canvas)))}}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}updateLayout(){this.children.forEach((t=>t.updateLayout()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&At.assign(e,t),this.autoLayout&&At.copyAttrs(e,this,qt),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(qo.END,(()=>this.__onReady())),t.once(Jo.START,(()=>this.__onCreated())),t.once(Jo.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(t.on_(Jo.END,this.__onChildRenderEnd,this))}};Bl=Yt([ho()],Bl);const Rl={},Cl={isHoldSpaceKey:()=>Cl.isHold("Space"),isHold:t=>Rl[t],setDownCode(t){Rl[t]||(Rl[t]=!0)},setUpCode(t){Rl[t]=!1}},Ll={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Ol extends Vo{get spaceKey(){return Cl.isHoldSpaceKey()}get left(){return Ll.left(this)}get right(){return Ll.right(this)}get middle(){return Ll.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}getBoxPoint(t){return(t||this.current).getBoxPoint(this)}getInnerPoint(t){return(t||this.current).getInnerPoint(this)}getLocalPoint(t){return(t||this.current).getLocalPoint(this)}getPagePoint(){return this.current.getPagePoint(this)}getInner(t){return this.getInnerPoint(t)}getLocal(t){return this.getLocalPoint(t)}getPage(){return this.getPagePoint()}static changeName(t,e){St.changeName(t,e)}}let Tl=class extends Ol{};Tl.POINTER="pointer",Tl.BEFORE_DOWN="pointer.before_down",Tl.BEFORE_MOVE="pointer.before_move",Tl.BEFORE_UP="pointer.before_up",Tl.DOWN="pointer.down",Tl.MOVE="pointer.move",Tl.UP="pointer.up",Tl.OVER="pointer.over",Tl.OUT="pointer.out",Tl.ENTER="pointer.enter",Tl.LEAVE="pointer.leave",Tl.TAP="tap",Tl.DOUBLE_TAP="double_tap",Tl.CLICK="click",Tl.DOUBLE_CLICK="double_click",Tl.LONG_PRESS="long_press",Tl.LONG_TAP="long_tap",Tl.MENU="pointer.menu",Tl.MENU_TAP="pointer.menu_tap",Tl=Yt([lo()],Tl);const Sl=Tl,Pl={};let Ml=class extends Tl{static setList(t){this.list=t instanceof _a?t:new _a(t)}static setData(t){this.data=t}static getValidMove(t,e,i){const{draggable:s,dragBounds:n}=t,o=t.getLocalPoint(i,null,!0);return P.move(o,e.x-t.x,e.y-t.y),n&&this.getMoveInDragBounds(t.__localBoxBounds,"parent"===n?t.parent.boxBounds:n,o,!0),"x"===s&&(o.y=0),"y"===s&&(o.x=0),o}static getMoveInDragBounds(t,e,i,s){const n=t.x+i.x,o=t.y+i.y,r=n+t.width,a=o+t.height,h=e.x+e.width,l=e.y+e.height;return s||(i=Object.assign({},i)),nt.includes(t,e)?(n>e.x?i.x+=e.x-n:r<h&&(i.x+=h-r),o>e.y?i.y+=e.y-o:a<l&&(i.y+=l-a)):(n<e.x?i.x+=e.x-n:r>h&&(i.x+=h-r),o<e.y?i.y+=e.y-o:a>l&&(i.y+=l-a)),i}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Pl,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Pl,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Pl,null,!0)}getPageTotal(){return this.getPageMove(!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}getPageBounds(){const t=this.getPageTotal(),e=this.getPagePoint(),i={};return nt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),nt.unsign(i),i}assignMove(t){Pl.x=t?this.totalX:this.moveX,Pl.y=t?this.totalY:this.moveY}};Ml.BEFORE_DRAG="drag.before_drag",Ml.START="drag.start",Ml.DRAG="drag",Ml.END="drag.end",Ml.OVER="drag.over",Ml.OUT="drag.out",Ml.ENTER="drag.enter",Ml.LEAVE="drag.leave",Ml=Yt([lo()],Ml);const Al=Ml;let Dl=class extends Tl{static setList(t){Ml.setList(t)}static setData(t){Ml.setData(t)}};Dl.DROP="drop",Dl=Yt([lo()],Dl);let Il=class extends Ml{};Il.BEFORE_MOVE="move.before_move",Il.START="move.start",Il.MOVE="move",Il.END="move.end",Il=Yt([lo()],Il);let Wl=class extends Ol{};Wl.BEFORE_ROTATE="rotate.before_rotate",Wl.START="rotate.start",Wl.ROTATE="rotate",Wl.END="rotate.end",Wl=Yt([lo()],Wl);let Fl=class extends Ml{};Fl.SWIPE="swipe",Fl.LEFT="swipe.left",Fl.RIGHT="swipe.right",Fl.UP="swipe.up",Fl.DOWN="swipe.down",Fl=Yt([lo()],Fl);let zl=class extends Ol{};zl.BEFORE_ZOOM="zoom.before_zoom",zl.START="zoom.start",zl.ZOOM="zoom",zl.END="zoom.end",zl=Yt([lo()],zl);let Nl=class extends Ol{};Nl.DOWN="key.down",Nl.HOLD="key.hold",Nl.UP="key.up",Nl=Yt([lo()],Nl);const Yl={getDragEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:i.x,y:i.y,moveX:i.x-e.x,moveY:i.y-e.y,totalX:i.x-t.x,totalY:i.y-t.y}),getDropEventData:(t,e,i)=>Object.assign(Object.assign({},t),{list:e,data:i}),getSwipeDirection:t=>t<-45&&t>-135?Fl.UP:t>45&&t<135?Fl.DOWN:t<=45&&t>=-45?Fl.RIGHT:Fl.LEFT,getSwipeEventData:(t,e,i)=>Object.assign(Object.assign({},i),{moveX:e.moveX,moveY:e.moveY,totalX:i.x-t.x,totalY:i.y-t.y,type:Xl.getSwipeDirection(P.getAngle(t,i))}),getBase(t){const e=1===t.button?4:t.button;return{altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:void 0===t.buttons?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let t=0,s=i.length;t<s;t++)if(i[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new _a,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:t=>t&&t.list.some((t=>t.draggable||t.editable||!t.isLeafer&&t.hasEvent(Ml.DRAG))),pathHasOutside:t=>t&&t.list.some((t=>t.isOutside))},Xl=Yl,Hl=new _a,{getDragEventData:Vl,getDropEventData:jl,getSwipeEventData:Ul}=Yl;class Gl{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Vl(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,n=Ml.list||this.draggableList||Hl;return this.dragging&&(s?t?Hl:new _a(e?[...i.list,...i.dragHoverExclude]:i.list):n)}checkDrag(t,e){const{interaction:i}=this;if(this.moving&&t.buttons<1)return this.canAnimate=!1,void i.pointerCancel();!this.moving&&e&&(this.moving=i.canMove(this.downData)||i.isHoldRightKey||i.isMobileDragEmpty)&&(this.dragData.moveType="drag",i.emit(Il.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&Ll.left(t),this.dragging&&(this.interaction.emit(Ml.START,this.dragData),this.getDraggableList(this.dragData.path),this.setDragStartPoints(this.realDraggableList=this.getList(!0))))}setDragStartPoints(t){this.dragStartPoints={},t.forEach((t=>this.dragStartPoints[t.innerId]={x:t.x,y:t.y}))}getDraggableList(t){let e;for(let i=0,s=t.length;i<s;i++)if(e=t.list[i],(e.draggable||e.editable)&&e.hitSelf&&!e.locked){this.draggableList=new _a(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:n,throughPath:o}=s;this.dragData=Vl(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=n,this.moving?(this.dragData.moveType="drag",e.emit(Il.BEFORE_MOVE,this.dragData),e.emit(Il.MOVE,this.dragData)):this.dragging&&(this.dragReal(),e.emit(Ml.BEFORE_DRAG,this.dragData),e.emit(Ml.DRAG,this.dragData))}dragReal(){const{running:t}=this.interaction,e=this.realDraggableList;if(e.length&&t){const{totalX:t,totalY:i}=this.dragData;e.forEach((e=>e.draggable&&e.move(Ml.getValidMove(e,this.dragStartPoints[e.innerId],{x:t,y:i}))))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(Ml.OUT,t,i),e.emit(Ml.OVER,t,s)):e.emit(Ml.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(Ml.LEAVE,t,i,s),e.emit(Ml.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:n,throughPath:o}=i,r=Vl(i,t,t);if(o&&(r.throughPath=o),r.path=n,this.moving&&(this.moving=!1,r.moveType="drag",e.emit(Il.END,r)),this.dragging){const n=this.getList();this.dragging=!1,e.emit(Ml.END,r),this.swipe(t,i,s,r),this.drop(t,n,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(P.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Ul(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=jl(t,e,Ml.data);s.path=i,this.interaction.emit(Dl.DROP,s),this.interaction.emit(Ml.LEAVE,t,i)}dragReset(){Ml.list=Ml.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null}checkDragEndAnimate(t,e){return!1}animate(t,e){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const Zl=vt.get("emit");const Kl=["move","zoom","rotate","key"];function ql(t,e,i,s,n){if(Kl.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!$l(t,n)){let o;for(let r=0,a=t.children.length;r<a;r++)o=t.children[r],!i.path.has(o)&&o.__.hittable&&Jl(o,e,i,s,n)}}function Jl(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!$l(t,n)&&(Ja.updateEventStyle&&!s&&Ja.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=St.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function $l(t,e){return e&&e.has(t)}const Ql={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{hitRadius:5,tapTime:120,longPressTime:800,transformTime:500,hover:!0,dragHover:!0,dragDistance:2,swipeDistance:20},touch:{preventDefault:"auto"},multiTouch:{},move:{autoDistance:2},zoom:{},cursor:!0,keyEvent:!0},{pathHasEventType:td,pathCanDrag:ed,pathHasOutside:id}=Yl;class sd{get dragging(){return this.dragger.dragging}get transforming(){return this.transformer.transforming}get moveMode(){return!0===this.m.drag||this.isHoldSpaceKey||this.isHoldMiddleKey||this.isHoldRightKey&&this.dragger.moving||this.isDragEmpty}get canHover(){return this.p.hover&&!this.config.mobile}get isDragEmpty(){return this.m.dragEmpty&&this.isRootPath(this.hoverData)&&(!this.downData||this.isRootPath(this.downData))}get isMobileDragEmpty(){return this.m.dragEmpty&&!this.canHover&&this.downData&&this.isTreePath(this.downData)}get isHoldMiddleKey(){return this.m.holdMiddleKey&&this.downData&&Ll.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&Ll.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&Cl.isHoldSpaceKey()}get m(){return this.config.move}get p(){return this.config.pointer}get hitRadius(){return this.p.hitRadius}constructor(t,e,i,s){this.config=At.clone(Ql),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new _a(t),this.createTransformer(),this.dragger=new Gl(this),s&&(this.config=At.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Ll.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(Tl.BEFORE_DOWN,t),this.emit(Tl.DOWN,t),Ll.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=Ll.right(t),this.dragger.setDragData(t),this.isHoldRightKey||this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&Ll.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(Tl.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=P.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.waitTap&&this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(Tl.MOVE,t),this.pointerHover(t),this.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t))),this.updateCursor(this.downData||t)}pointerUp(t){const{downData:e}=this;if(t||(t=e),!e)return;Ll.defaultLeft(t),t.multiTouch=e.multiTouch,this.findPath(t);const i=Object.assign(Object.assign({},t),{path:t.path.clone()});t.path.addList(e.path.list),this.checkPath(t),this.downData=null,this.emit(Tl.BEFORE_UP,t),this.emit(Tl.UP,t),this.touchLeave(t),t.isCancel||(this.tap(t),this.menuTap(t)),this.dragger.dragEnd(t),this.updateCursor(i)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(t){this.findPath(t),this.emit(Tl.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(Tl.MENU_TAP,t),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Cl.setDownCode(e),this.emit(Nl.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(Nl.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;const{code:e}=t;this.downKeyMap[e]=!1,Cl.setUpCode(e),this.emit(Nl.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new _a),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(t){const{path:e}=t,{overPath:i}=this;this.overPath=e,i?e.indexAt(0)!==i.indexAt(0)&&(this.emit(Tl.OUT,t,i),this.emit(Tl.OVER,t,e)):this.emit(Tl.OVER,t,e)}pointerEnterOrLeave(t){let{path:e}=t;this.downData&&!this.moveMode&&(e=e.clone(),this.downData.path.forEach((t=>e.add(t))));const{enterPath:i}=this;this.enterPath=e,this.emit(Tl.LEAVE,t,i,e),this.emit(Tl.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(Tl.LEAVE,t),this.dragger.dragging&&this.emit(Dl.LEAVE,t))}tap(t){const{pointer:e}=this.config,i=this.longTap(t);if(!e.tapMore&&i)return;if(!this.waitTap)return;e.tapMore&&this.emitTap(t);const s=Date.now()-this.downTime,n=[Tl.DOUBLE_TAP,Tl.DOUBLE_CLICK].some((e=>td(t.path,e)));s<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout((()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(e,i){const{hitRadius:s,through:n}=this.p,{bottomList:o,target:r}=this;t.backgrounder||e.origin||r&&r.updateLayout();const a=this.selector.getByPoint(e,s,Object.assign({bottomList:o,name:e.type},i||{through:n}));return a.throughPath&&(e.throughPath=a.throughPath),e.path=a.path,a.path}isRootPath(t){return t&&t.path.list[0].isLeafer}isTreePath(t){const e=this.target.app;return!(!e||!e.isApp)&&(e.editor&&!t.path.has(e.editor)&&t.path.has(e.tree)&&!t.target.syncEventer)}checkPath(t,e){(e||this.moveMode&&!id(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!ed(t.path))&&!id(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getList(!1,!0),name:Tl.MOVE}),this.hoverData=t)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e);return{x:t.clientX-i.x,y:t.clientY-i.y}}emitTap(t){this.emit(Tl.TAP,t),this.emit(Tl.CLICK,t)}emitDoubleTap(t){this.emit(Tl.DOUBLE_TAP,t),this.emit(Tl.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout((()=>{this.longPressed=!0,this.emit(Tl.LONG_PRESS,t)}),this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(Tl.LONG_TAP,t),(td(t.path,Tl.LONG_TAP)||td(t.path,Tl.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new ht(this.canvas.bounds),this.shrinkCanvasBounds.spread(-("number"==typeof t?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Zo.RESIZE,this.__onResize,this)],t.once($o.READY,(()=>this.__onResize()))}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,i,s){this.running&&function(t,e,i,s){if(!i&&!e.path)return;let n;e.type=t,i?e=Object.assign(Object.assign({},e),{path:i}):i=e.path,e.target=i.indexAt(0);try{for(let o=i.length-1;o>-1;o--){if(n=i.list[o],Jl(n,t,e,!0,s))return;n.isApp&&ql(n,t,e,!0,s)}for(let o=0,r=i.length;o<r;o++)if(n=i.list[o],n.isApp&&ql(n,t,e,!1,s),Jl(n,t,e,!1,s))return}catch(t){Zl.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class nd{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}nd.custom={};class od extends Mt{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new _a,this.pixelList=new _a}getPixelType(t,i){return this.__autoClear(),this.pixelList.add(t),e.hitCanvas(i)}getPathType(t){return this.__autoClear(),this.pathList.add(t),e.hitCanvas()}clearImageType(){this.__clearLeafList(this.pixelList)}clearPathType(){this.__clearLeafList(this.pathList)}__clearLeafList(t){t.length&&(t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset())}__autoClear(){this.pathList.length+this.pixelList.length>this.maxTotal&&this.clear()}clear(){this.clearPathType(),this.clearImageType()}}const{toInnerRadiusPointOf:rd,copy:ad,setRadius:hd}=P,ld={},dd=ia.prototype;dd.__hitWorld=function(t){if(!this.__.hitSelf)return!1;this.__.hitRadius&&(ad(ld,t),hd(t=ld,this.__.hitRadius)),rd(t,this.__world,ld);const{width:e,height:i}=this.__world,s=e<10&&i<10;if(this.__.hitBox||s){if(nt.hitRadiusPoint(this.__layout.boxBounds,ld))return!0;if(s)return!1}return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.boundsChanged||(this.__layout.hitCanvasChanged=!1)),this.__hit(ld)},dd.__hitFill=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitFill(t,this.__.windingRule)},dd.__hitStroke=function(t,e){var i;return null===(i=this.__hitCanvas)||void 0===i?void 0:i.hitStroke(t,e)},dd.__hitPixel=function(t){var e;return null===(e=this.__hitCanvas)||void 0===e?void 0:e.hitPixel(t,this.__layout.renderBounds,this.__hitCanvas.hitScale)},dd.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const cd=new z,ud=Bh.prototype;ud.__updateHitCanvas=function(){const e=this.__,{hitCanvasManager:i}=this.leafer,s=(e.__pixelFill||e.__isCanvas)&&"pixel"===e.hitFill,n=e.__pixelStroke&&"pixel"===e.hitStroke,o=s||n;this.__hitCanvas||(this.__hitCanvas=o?i.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):i.getPathType(this));const r=this.__hitCanvas;if(o){const{renderBounds:i}=this.__layout,o=t.image.hitCanvasSize,a=r.hitScale=lt.set(0,0,o,o).getFitMatrix(i).a,{x:h,y:l,width:d,height:c}=lt.set(i).scale(a);r.resize({width:d,height:c,pixelRatio:1}),r.clear(),mn.patternLocked=!0,this.__renderShape(r,{matrix:cd.setWith(this.__world).scaleWith(1/a).invertWith().translate(-h,-l)},!s,!n),mn.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},ud.__hit=function(t){const e=this.__;if(e.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:i}=e,s=(e.fill||e.__isCanvas)&&("path"===i||"pixel"===i&&!(e.__pixelFill||e.__isCanvas))||"all"===i;if(s&&this.__hitFill(t))return!0;const{hitStroke:n,__strokeWidth:o}=e,r=e.stroke&&("path"===n||"pixel"===n&&!e.__pixelStroke)||"all"===n;if(!s&&!r)return!1;const a=2*t.radiusX;let h=a;if(r)switch(e.strokeAlign){case"inside":if(h+=2*o,!s&&this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a;break;case"center":h+=o;break;case"outside":if(h+=2*o,!s){if(!this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a}}return!!h&&this.__hitStroke(t,h)};const _d=Bh.prototype,pd=Th.prototype,gd=Wh.prototype;pd.__updateHitCanvas=gd.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?_d.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},pd.__hitFill=gd.__hitFill=function(t){return this.__hitCanvas?_d.__hitFill.call(this,t):nt.hitRadiusPoint(this.__layout.boxBounds,t)},Rh.prototype.pick=function(i,s){return s||(s=Ft),this.updateLayout(),function(i){return i.leafer?i.leafer.selector:t.selector||(t.selector=e.selector())}(this).getByPoint(i,s.hitRadius||0,Object.assign(Object.assign({},s),{target:this}))};const fd=Jt.prototype;function yd(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=s;t&&(e.fillStyle=t),n.forEach((t=>o.forEach((s=>e.fillRect(t.x,t.y+s,t.width,i)))))}}function md(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?xd(t,!0,e,i):wd(e,i);break;case"inside":vd("inside",t,n,e,i);break;case"outside":vd("outside",t,n,e,i)}}function vd(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?xd(e,!0,s,a):wd(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",yd(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function wd(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(o){const{decorationHeight:t}=s;n.forEach((i=>o.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function xd(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&Ua.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?wd(i,s):s.stroke(),s.restoreBlendMode()):e?wd(i,s):s.stroke())}function bd(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}fd.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},fd.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},fd.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:o,radiusY:r}=t;e&&(s-=e.x,n-=e.y),lt.set(s-o,n-r,2*o,2*r).scale(i).ceil();const{data:a}=this.context.getImageData(lt.x,lt.y,lt.width||1,lt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:kd,getOuterOf:Ed,getByMove:Bd,getIntersectData:Rd}=nt;let Cd;function Ld(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:Xa.string(r,a)};case"image":return Ua.image(i,t,e,s,!Cd||!Cd[e.url]);case"linear":return Ga.linearGradient(e,s);case"radial":return Ga.radialGradient(e,s);case"angular":return Ga.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:Xa.string(e)}:void 0}}const Od={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Cd=Ua.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Ld(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?yd(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&Ua.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?yd(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?yd(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?yd(e,i):n?i.fill(n):i.fill())},fillText:yd,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)md(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&bd(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)md(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),xd(t,!1,e,i),s.__useArrow&&bd(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),xd(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),xd(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:md,drawTextStroke:wd,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:d}=n;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,c=Rd(s?kd(e.bounds,l===d?s*l:[s*d,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(c);let{a:u,d:_}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=_),a=Ed(n,r),o=Bd(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,_*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,_)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:d}}};let Td={};const{get:Sd,rotateOfOuter:Pd,translate:Md,scaleOfOuter:Ad,scale:Dd,rotate:Id}=x;function Wd(t,e,i,s,n,o,r){const a=Sd();Md(a,e.x+i,e.y+s),Dd(a,n,o),r&&Pd(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function Fd(t,e,i,s,n,o,r){const a=Sd();Md(a,e.x+i,e.y+s),n&&Dd(a,n,o),r&&Id(a,r),t.transform=a}function zd(t,e,i,s,n,o,r,a,h,l){const d=Sd();if(h)if("center"===l)Pd(d,{x:i/2,y:s/2},h);else switch(Id(d,h),h){case 90:Md(d,s,0);break;case 180:Md(d,i,s);break;case 270:Md(d,0,i)}Td.x=e.x+n,Td.y=e.y+o,Md(d,Td.x,Td.y),r&&Ad(d,Td,r,a),t.transform=d}const{get:Nd,translate:Yd}=x,Xd=new ht,Hd={},Vd={};function jd(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=Ud(i,s,e)}function Ud(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Xd.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,repeat:_,filters:p}=t,g=e.width===s&&e.height===n,f={mode:r},y="center"!==h&&(u||0)%180==90,m=y?n:s,v=y?s:n;let w,x,b=0,k=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(a.getScaleData(d,c,i,Vd),w=Vd.scaleX,x=Vd.scaleY);else if(!g||u){const t=e.width/m,i=e.height/v;w=x="fit"===r?Math.min(t,i):Math.max(t,i),b+=(e.width-s*w)/2,k+=(e.height-n*x)/2}if(h){const t={x:b,y:k,width:m,height:v};w&&(t.width*=w,t.height*=x),yt.toPoint(h,t,e,Hd,!0),b+=Hd.x,k+=Hd.y}switch(l&&(b+=l.x,k+=l.y),r){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(b||k||w||u)&&Fd(f,e,b,k,w,x,u);break;case"repeat":(!g||w||u)&&zd(f,e,s,n,b,k,w,x,u,h),_||(f.repeat="repeat");break;default:w&&Wd(f,e,b,k,w,x,u)}return f.transform||(e.x||e.y)&&(f.transform=Nd(),Yd(f.transform,e.x,e.y)),w&&"stretch"!==r&&(f.scaleX=w,f.scaleY=x),f.width=s,f.height=n,o&&(f.opacity=o),p&&(f.filters=p),_&&(f.repeat="string"==typeof _?"x"===_?"repeat-x":"repeat-y":"repeat"),f}let Gd,Zd=new ht;const{isSame:Kd}=nt;function qd(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||jd(n,s,i,o),!0}function Jd(t,e){tc(t,Go.LOAD,e)}function $d(t,e){tc(t,Go.LOADED,e)}function Qd(t,e,i){e.error=i,t.forceUpdate("surface"),tc(t,Go.ERROR,e)}function tc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Go(e,i))}function ec(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ic,scale:sc,copy:nc}=x,{ceil:oc,abs:rc}=Math;function ac(e,i,s){let{scaleX:n,scaleY:o}=mn.patternLocked?e.__world:e.__nowWorld;const r=n+"-"+o+"-"+s;if(i.patternId===r||e.destroyed)return!1;{n=rc(n),o=rc(o);const{image:e,data:a}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:_,transform:p,repeat:g}=a;u&&(l=ic(),nc(l,p),sc(l,1/u,1/_),n*=u,o*=_),n*=s,o*=s,d*=n,c*=o;const f=d*c;if(!g&&f>t.image.maxCacheSize)return!1;let y=t.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}f>y&&(h=Math.sqrt(f/y)),h&&(n/=h,o/=h,d/=h,c/=h),u&&(n/=u,o/=_),(p||1!==n||1!==o)&&(l||(l=ic(),p&&nc(l,p)),sc(l,1/n,1/o));const m=e.getCanvas(oc(d)||1,oc(c)||1,a.opacity,a.filters),v=e.getPattern(m,g||t.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=r,!0}}const{abs:hc}=Math;const lc={image:function(t,e,i,s,n){let o,r;const a=mn.get(i);return Gd&&i===Gd.paint&&Kd(s,Gd.boxBounds)?o=Gd.leafPaint:(o={type:i.type,image:a},Gd=a.use>1?{leafPaint:o,paint:i,boxBounds:Zd.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(qd(t,e,i,a,o,s),n&&(Jd(t,r),$d(t,r))):a.error?n&&Qd(t,r,a.error):(n&&(ec(t,!0),Jd(t,r)),o.loadId=a.load((()=>{ec(t,!1),t.destroyed||(qd(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$d(t,r)),o.loadId=null}),(e=>{ec(t,!1),Qd(t,r,e),o.loadId=null}))),o},checkImage:function(e,i,s,n){const{scaleX:o,scaleY:r}=mn.patternLocked?e.__world:e.__nowWorld,{pixelRatio:a}=i;if(!s.data||s.patternId===o+"-"+r+"-"+a&&!qa.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:e,height:i}=h;e*=hc(o)*a,i*=hc(r)*a,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),n=e*i>t.image.maxCacheSize||qa.running}return n?(i.save(),e.windingRule?i.clip(e.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.getFull(h.filters),0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||qa.running?ac(e,s,a):s.patternTask||(s.patternTask=mn.patternTasker.add((()=>Xt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&ac(e,s,a),e.forceUpdate("surface")}))),300)),!1)}},createPattern:ac,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,mn.recycle(s),s.loading?(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))):i[a].style=null);return n}return null},createData:jd,getPatternData:Ud,fillOrFitMode:Wd,clipMode:Fd,repeatMode:zd},{toPoint:dc}=pt,cc={},uc={};function _c(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),Xa.string(s,i)):t.addColorStop(s.offset,Xa.string(s.color,i))}}const{getAngle:pc,getDistance:gc}=P,{get:fc,rotateOfOuter:yc,scaleOfOuter:mc}=x,{toPoint:vc}=pt,wc={},xc={};function bc(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=pc(e,i);o=fc(),n?(mc(o,e,r/a*(s||1),1),yc(o,e,t+90)):(mc(o,e,1,r/a*(s||1)),yc(o,e,t))}return o}const{getDistance:kc}=P,{toPoint:Ec}=pt,Bc={},Rc={};const Cc={linearGradient:function(e,i){let{from:s,to:n,type:o,blendMode:r,opacity:a}=e;dc(s||"top",i,cc),dc(n||"bottom",i,uc);const h=t.canvas.createLinearGradient(cc.x,cc.y,uc.x,uc.y);_c(h,e.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=e;vc(s||"center",i,wc),vc(n||"bottom",i,xc);const l=t.canvas.createRadialGradient(wc.x,wc.y,0,wc.x,wc.y,gc(wc,xc));_c(l,e.stops,r);const d={type:o,style:l},c=bc(i,wc,xc,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(e,i){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=e;Ec(s||"center",i,Bc),Ec(n||"bottom",i,Rc);const l=t.conicGradientSupport?t.canvas.createConicGradient(0,Bc.x,Bc.y):t.canvas.createRadialGradient(Bc.x,Bc.y,0,Bc.x,Bc.y,kc(Bc,Rc));_c(l,e.stops,r);const d={type:o,style:l},c=bc(i,Bc,Rc,h||1,t.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:bc},{copy:Lc,toOffsetOutBounds:Oc}=nt,Tc={},Sc={};function Pc(e,i,s,n){const{bounds:o,shapeBounds:r}=n;if(t.fullImageShadow){if(Lc(Tc,e.bounds),Tc.x+=i.x-r.x,Tc.y+=i.y-r.y,s){const{matrix:t}=n;Tc.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Tc.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Tc.width*=s,Tc.height*=s}e.copyWorld(n.canvas,e.bounds,Tc)}else s&&(Lc(Tc,i),Tc.x-=i.width/2*(s-1),Tc.y-=i.height/2*(s-1),Tc.width*=s,Tc.height*=s),e.copyWorld(n.canvas,r,s?Tc:i)}const{toOffsetOutBounds:Mc}=nt,Ac={};const Dc={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Oc(l,Sc),a.forEach(((a,g)=>{_.setWorldShadow(Sc.offsetX+a.x*c,Sc.offsetY+a.y*u,a.blur*c,Xa.string(a.color)),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Pc(_,Sc,n,i),s=l,a.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,o,"copy"),s=o),h?_.copyWorld(h,o,o,"destination-out"):_.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,r.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,_=e.getSameCanvas(),p=a.length-1;Mc(l,Ac),a.forEach(((a,g)=>{_.save(),_.setWorldShadow(Ac.offsetX+a.x*c,Ac.offsetY+a.y*u,a.blur*c),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Pc(_,Ac,n,i),_.restore(),h?(_.copyWorld(_,l,o,"copy"),_.copyWorld(h,o,o,"source-out"),s=o):(_.copyWorld(i.canvas,d,l,"source-out"),s=l),_.fillWorld(s,Xa.string(a.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(_,s,o,a.blendMode):e.copyWorldToInner(_,s,r.renderBounds,a.blendMode),p&&g<p&&_.clearWorld(s,!0)})),_.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ic}=Lo;function Wc(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),zc(t,e,i,1)}(t,i,s,n);break;case"opacity-path":zc(t,i,s,o);break;case"path":i.restore()}}function Fc(t){return t.getSameCanvas(!1,!0)}function zc(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Rh.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],a=i.__.mask,a&&(r&&(Wc(this,r,t,n,s,o),s=n=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=Fc(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Fc(t)),n||(n=Fc(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||Ic(i,e)||i.__render(n||t,e);Wc(this,r,t,n,s,o)};const Nc=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Yc=Nc+"_#~&*+\\=|≮≯≈≠=…",Xc=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Hc(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Vc=Hc("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),jc=Hc("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Uc=Hc(Nc),Gc=Hc(Yc),Zc=Hc("- —/~|┆·");var Kc;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Kc||(Kc={}));const{Letter:qc,Single:Jc,Before:$c,After:Qc,Symbol:tu,Break:eu}=Kc;function iu(t){return Vc[t]?qc:Zc[t]?eu:jc[t]?$c:Uc[t]?Qc:Gc[t]?tu:Xc.test(t)?Jc:qc}const su={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function nu(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ou}=su,{Letter:ru,Single:au,Before:hu,After:lu,Symbol:du,Break:cu}=Kc;let uu,_u,pu,gu,fu,yu,mu,vu,wu,xu,bu,ku,Eu,Bu,Ru,Cu,Lu,Ou=[];function Tu(t,e){wu&&!vu&&(vu=wu),uu.data.push({char:t,width:e}),pu+=e}function Su(){gu+=pu,uu.width=pu,_u.words.push(uu),uu={data:[]},pu=0}function Pu(){Bu&&(Ru.paraNumber++,_u.paraStart=!0,Bu=!1),wu&&(_u.startCharSize=vu,_u.endCharSize=wu,vu=0),_u.width=gu,Cu.width?ou(_u):Lu&&Mu(),Ou.push(_u),_u={words:[]},gu=0}function Mu(){gu>(Ru.maxWidth||0)&&(Ru.maxWidth=gu)}const{top:Au,right:Du,bottom:Iu,left:Wu}=ct;function Fu(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const zu={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let s=0,n=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=i;l&&(o?(s=l[Wu],o-=l[Du]+l[Wu]):i.autoSizeAlign||(s=l[Wu]),r?(n=l[Au],r-=l[Au]+l[Iu]):i.autoSizeAlign||(n=l[Au]));const d={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:t.canvas.font=h};return function(e,i,s){Ru=e,Ou=e.rows,Cu=e.bounds,Lu=!Cu.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=t,{width:h,height:l}=Cu;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Bu=!0,bu=null,vu=mu=wu=pu=gu=0,uu={data:[]},_u={words:[]};for(let s=0,l=i.length;s<l;s++)yu=i[s],"\n"===yu?(pu&&Su(),_u.paraEnd=!0,Pu(),Bu=!0):(xu=iu(yu),xu===ru&&"none"!==r&&(yu=nu(yu,r,!pu)),mu=a.measureText(yu).width,n&&(n<0&&(wu=mu),mu+=n),ku=xu===au&&(bu===au||bu===ru)||bu===au&&xu!==lu,Eu=!(xu!==hu&&xu!==au||bu!==du&&bu!==lu),fu=Bu&&o?h-o:h,t&&h&&gu+pu+mu>fu&&(e?(pu&&Su(),gu&&Pu()):(Eu||(Eu=xu===ru&&bu==lu),ku||Eu||xu===cu||xu===hu||xu===au||pu+mu>fu?(pu&&Su(),gu&&Pu()):gu&&Pu()))," "===yu&&!0!==Bu&&gu+pu===0||(xu===cu?(" "===yu&&pu&&Su(),Tu(yu,mu),Su()):ku||Eu?(pu&&Su(),Tu(yu,mu)):Tu(yu,mu)),bu=xu);pu&&Su(),gu&&Pu(),Ou.length>0&&(Ou[Ou.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ru.paraNumber++,gu=a.measureText(t).width,Ou.push({x:o||0,text:t,width:gu,paraStart:!0}),Lu&&Mu()}))}(d,e,i),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Fu(e,"x",t[Wu]);break;case"right":Fu(e,"x",-t[Du])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Fu(e,"y",t[Au]);break;case"bottom":Fu(e,"y",-t[Iu])}}(l,d,i,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:_,y:p,width:g,height:f}=s,y=o*n+(c?c*(t.paraNumber-1):0),m=r;if(h&&y>f)y=Math.max(f,o),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":p+=(f-y)/2;break;case"bottom":p+=f-y}m+=p;let v,w,x,b=g||u?g:t.maxWidth;for(let r=0,d=n;r<d;r++){if(v=i[r],v.x=_,v.width<g||v.width>g&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&r>0&&(m+=c),v.y=m,m+=o,t.overflow>r&&m>y&&(v.isOverflow=!0,t.overflow=r+1),w=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,w-=x,x+=e.fontSize):x-=a),w<s.x&&(s.x=w),x>s.width&&(s.width=x),h&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=y}(d,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,letterSpacing:r}=e;let a,h,l,d,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,d=r||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===d?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach(((e,i)=>{1===d?(c={char:"",x:a},a=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,a,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):a=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)}))),t.words=null)}))}(d,i,o),d.overflow&&function(e,i,s,n){if(!n)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.canvas.measureText(a).width:0,d=s+n-l;("none"===i.textWrap?o:[o[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let s=i;s>-1&&(e=t.data[s],h=e.x+e.width,!(s===i&&h<d));s--){if(h<d&&" "!==e.char||!s){t.data.splice(s+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,i,s,o),"none"!==a&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=Xa.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,i),d}};const Nu={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!Xa.object)return t;t=Xa.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};function Yu(t){return t?t instanceof Array?t:[t]:[]}Object.assign(Ya,zu),Object.assign(Xa,Nu),Object.assign(ja,Od),Object.assign(Ua,lc),Object.assign(Ga,Cc),Object.assign(Za,Dc),Object.assign(e,{interaction:(t,e,i,s)=>new sd(t,e,i,s),hitCanvas:(t,e)=>new fa(t,e),hitCanvasManager:()=>new od}),ma();class Xu extends Vo{get list(){return Yu(this.value)}get oldList(){return Yu(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}Xu.BEFORE_SELECT="editor.before_select",Xu.SELECT="editor.select",Xu.BEFORE_HOVER="editor.before_hover",Xu.HOVER="editor.hover";class Hu extends Xu{constructor(t,e){super(t,e)}}Hu.BEFORE_MOVE="editor.before_move",Hu.MOVE="editor.move";class Vu extends Xu{constructor(t,e){super(t,e)}}Vu.BEFORE_SCALE="editor.before_scale",Vu.SCALE="editor.scale";class ju extends Xu{constructor(t,e){super(t,e)}}ju.BEFORE_ROTATE="editor.before_rotate",ju.ROTATE="editor.rotate";class Uu extends Xu{constructor(t,e){super(t,e)}}function Gu(t){return(e,i)=>{const s="_"+i;kn(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const o="target"===i?Xu.BEFORE_SELECT:Xu.BEFORE_HOVER;this.hasEvent(o)&&this.emitEvent(new Xu(o,{editor:this,value:e,oldValue:n})),this[s]=e,t(this,n)}}})}}Uu.BEFORE_SKEW="editor.before_skew",Uu.SKEW="editor.skew";const{abs:Zu}=Math,{copy:Ku,scale:qu}=x,{setListWithFn:Ju}=nt,{worldBounds:$u}=Lo,Qu={a:1,b:0,c:0,d:1,e:0,f:0},t_={x:0,y:0,width:0,height:0};class e_ extends Bh{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(Ju(t_,t,$u),this.set(t_)):this.width=this.height=1}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:o,strokeWidth:r,fill:a}=n,{bounds:h}=e;for(let l=0;l<i.length;l++){s=i[l];const{worldTransform:d,worldRenderBounds:c}=s;if(c.width&&c.height&&(!h||h.hit(c,e.matrix))){const i=Zu(d.scaleX),h=Zu(d.scaleY);if(i!==h){Ku(Qu,d),qu(Qu,1/i,1/h),t.setWorld(Qu,e.matrix),t.beginPath(),n.strokeWidth=r;const{x:o,y:a,width:l,height:c}=s.__layout.boxBounds;t.rect(o*i,a*h,l*i,c*h)}else t.setWorld(d,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=r/Zu(d.scaleX);o&&("string"==typeof o?ja.stroke(o,this,t):ja.strokes(o,this,t)),a&&("string"==typeof a?ja.fill(a,this,t):ja.fills(a,this,t))}}n.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}Yt([Gu((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],e_.prototype,"target",void 0);class i_ extends Rh{constructor(t){super(t),this.strokeArea=new Th({strokeAlign:"center"}),this.fillArea=new Th,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const s_={findOne:t=>t.list.find((t=>t.editable)),findByBounds(t,e){const i=[];return n_([t],i,e),i}};function n_(t,e,i){let s,n;for(let o=0,r=t.length;o<r;o++)if(s=t[o],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&n_(s.children,e,i)}}const{findOne:o_,findByBounds:r_}=s_;class a_ extends Rh{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new e_,this.targetStroker=new e_,this.bounds=new ht,this.selectArea=new i_,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:n}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},n||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s,selectedStyle:n}=t;this.targetStroker.setTarget(e,Object.assign({stroke:i,strokeWidth:Math.max(1,s/2)},n||{})),this.hoverStroker.target=null}}update(){this.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:n,y:o}=t.getInnerPoint(this);this.bounds.set(n,o),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:o},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new _a(r_(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){const{boxSelect:e,multipleSelect:i}=this.editor.mergeConfig;return!(!(this.running&&i&&e)||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!o_(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new _a(this.editor.editBox.rect)};return o_(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):o_(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(t.shiftKey||i)}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(Xu.HOVER,this.onHover,this),t.on_(Xu.SELECT,this.onSelect,this),e.on_(Tl.MOVE,this.onPointerMove,this),e.on_(Tl.BEFORE_DOWN,this.onBeforeDown,this),e.on_(Tl.TAP,this.onTap,this),e.on_(Ml.START,this.onDragStart,this,!0),e.on_(Ml.DRAG,this.onDrag,this),e.on_(Ml.END,this.onDragEnd,this),e.on_(Il.MOVE,this.onAutoMove,this),e.on_([zl.ZOOM,Il.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:h_,top:l_,topRight:d_,right:c_,bottomRight:u_,bottom:__,bottomLeft:p_,left:g_}=ut,{toPoint:f_}=pt,{within:y_}=a,m_={getScaleData(t,e,i,s,n,o,r,a){let h,l={},d=1,c=1;const{boxBounds:u,widthRange:_,heightRange:p,dragBounds:g,worldBoxBounds:f}=t,{width:y,height:m}=e;o&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,w=t.scaleY/e.scaleY,x=v<0?-1:1,b=w<0?-1:1,k=a?v:x*u.width/y,E=a?w:b*u.height/m;s.x*=a?v:x,s.y*=a?w:b;const B=(-s.y+m)/m,R=(s.x+y)/y,C=(s.y+m)/m,L=(-s.x+y)/y;switch(i){case l_:c=B,h="bottom";break;case c_:d=R,h="left";break;case __:c=C,h="top";break;case g_:d=L,h="right";break;case h_:c=B,d=L,h="bottom-right";break;case d_:c=B,d=R,h="bottom-left";break;case u_:c=C,d=R,h="top-left";break;case p_:c=C,d=L,h="top-right"}if(n){if(!("corner"===n&&i%2)){let t;switch(i){case l_:case __:t=c;break;case g_:case c_:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=k,c/=E,!r){const{worldTransform:e}=t;d<0&&(d=1/u.width/e.scaleX),c<0&&(c=1/u.height/e.scaleY)}if(f_(o||h,u,l,!0),g){const e="parent"===g?t.parent.boxBounds:g,i=new ht(t.__localBoxBounds);if(i.scaleOf(t.getLocalPointByInner(l),d,c),!nt.includes(e,i)){const t=i.getIntersect(e);d*=t.width/i.width,c*=t.height/i.height}}if(_){const e=u.width*t.scaleX;d=y_(e*d,_)/e}if(p){const e=u.height*t.scaleY;c=y_(e*c,p)/e}return Math.abs(d*f.width)<1&&(d=(d<0?-1:1)/f.width),Math.abs(c*f.height)<1&&(c=(c<0?-1:1)/f.height),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:n,around:o}},getRotateData(t,e,i,s,n){let o,r={};switch(e){case h_:o="bottom-right";break;case d_:o="bottom-left";break;case u_:o="top-left";break;case p_:o="top-right";break;default:o="center"}return f_(n||o,t,r,!0),{origin:r,rotation:P.getRotation(s,r,i)}},getSkewData(t,e,i,s){let n,o,r={},a=0,h=0;switch(e){case l_:case h_:o={x:.5,y:0},n="bottom",a=1;break;case __:case u_:o={x:.5,y:1},n="top",a=1;break;case g_:case p_:o={x:0,y:.5},n="right",h=1;break;case c_:case d_:o={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,f_(s||n,t,r,!0);const c=P.getRotation(o,r,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case g_:t=c_;break;case h_:t=d_;break;case p_:t=u_;break;case c_:t=g_;break;case d_:t=h_;break;case u_:t=p_}if(i)switch(t){case l_:t=__;break;case h_:t=p_;break;case d_:t=u_;break;case __:t=l_;break;case p_:t=h_;break;case u_:t=d_}return t}},v_={};function w_(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=i;const{resizeCursor:o,rotateCursor:r,skewCursor:h,resizeable:l,rotateable:d,skewable:c}=t.mergeConfig,{pointType:u}=s,{flippedX:_,flippedY:p}=i;let g=u.includes("resize");g&&d&&(e.metaKey||e.ctrlKey||!l)&&(g=!1);const f=c&&!g&&("resize-line"===s.name||"skew"===u)?h:g?o:r;n+=45*(m_.getFlipDirection(s.direction,_,p)+1),n=2*Math.round(a.formatRotation(n,!0)/2);const{url:y,x:m,y:v}=f,w=y+n;v_[w]?s.cursor=v_[w]:v_[w]=s.cursor={url:b_(y,n),x:m,y:v}}function x_(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function b_(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class k_ extends Wh{}const E_=["top","right","bottom","left"],B_=void 0;class R_ extends Rh{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new Rh,this.rect=new Wh({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new k_({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new Rh({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:o,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new k_({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new k_({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new k_({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...o,a,h,l,...r,...n),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:n,resizePoints:o}=this,{stroke:r,strokeWidth:a}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=o[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);n.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),s.set(Object.assign({stroke:r,strokeWidth:a,editConfig:B_},t.rect||{})),s.hittable=!i,s.syncEventer=i&&this.editor,i&&(e.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:e}])}update(t){const{mergeConfig:e,element:i,multiple:s}=this.editor,{middlePoint:n,resizeable:o,rotateable:r,hideOnSmall:a,editBox:h}=e;if(this.visible=!i.locked,this.view.worldOpacity){const{width:i,height:l}=t,{rect:d,circle:c,buttons:u,resizePoints:_,rotatePoints:p,resizeLines:g}=this,f="number"==typeof a?a:10,y=h&&!(a&&i<f&&l<f);let m,v,w,x={};for(let s=0;s<8;s++)pt.toPoint(pt.directionData[s],t,x),v=_[s],m=p[s],w=g[Math.floor(s/2)],v.set(x),m.set(x),w.set(x),v.visible=w.visible=y&&!(!o&&!r),m.visible=y&&r&&o&&!e.rotatePoint,s%2&&(v.visible=m.visible=y&&!!n,(s+1)/2%2?(w.width=i,a&&2*v.width>i&&(v.visible=!1)):(w.height=l,v.rotation=90,a&&2*v.width>l&&(v.visible=!1)));c.visible=y&&r&&!(!e.circle&&!e.rotatePoint),c.visible&&this.layoutCircle(e),d.path&&(d.path=null),d.set(Object.assign(Object.assign({},t),{visible:!!s||h})),u.visible=y&&u.children.length>0,u.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:n,middlePoint:o}=t,r=E_.indexOf(e||(this.buttons.children.length&&"bottom"===n?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!o)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:n,middlePoint:o}=t,{flippedX:r,flippedY:a}=this;let h=E_.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?m_.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,n,!!o),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],o=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*r;o?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:o}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:n,height:n,cornerRadius:o,offsetX:0,offsetY:0,editConfig:B_};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{editor:i,dragStartData:s}=this,{element:n}=i;"rect"===e.name&&(this.moving=!0,i.opacity=i.mergeConfig.hideOnMove?0:1),s.x=t.x,s.y=t.y,s.point={x:n.x,y:n.y},s.bounds=Object.assign({},n.getLayoutBounds("box","local")),s.rotation=n.rotation}onDragEnd(t){this.dragging=!1,this.dragPoint=null,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this,{pointType:i}=this.enterPoint=t.current;(i.includes("rotate")||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable)&&e.onRotate(t),i.includes("resize")&&e.onScale(t),"skew"===i&&e.onSkew(t),w_(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find((t=>t.editable&&t instanceof bl))||t.find((t=>t instanceof bl));if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(Ml.START,this.onDragStart,this),t.on_(Ml.DRAG,this.onDrag,this),t.on_(Ml.END,this.onDragEnd,this),t.on_(Tl.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(Tl.ENTER,(e=>{this.enterPoint=t,w_(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(Xu.SELECT,this.onSelect,this),t.on_(Ml.START,this.onDragStart,this),t.on_(Ml.DRAG,e.onMove,e),t.on_(Ml.END,this.onDragEnd,this),t.on_(Tl.ENTER,(()=>x_(e))),t.on_(Tl.DOUBLE_TAP,this.onDoubleTap,this),t.on_(Tl.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class C_ extends Bh{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergeConfig;if(s&&i.list.length){const{rect:n}=i.editBox,{width:o,height:r}=n.__;t.resetTransform(),t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(n.__world,e.matrix),t.clearRect(0,0,o,r)}}destroy(){this.editor=null,super.destroy()}}const L_='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',O_={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${L_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${L_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${L_}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,editBox:!0,hover:!0,select:"press",openInner:"double",multipleSelect:!0,boxSelect:!0,moveable:!0,resizeable:!0,flipable:!0,rotateable:!0,skewable:!0},T_=new ht;function S_(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer.zoomLayer;e.safeChange((()=>{T_.setListWithFn(i,(t=>t.getBounds("box","page"))),0===T_.width&&(T_.width=.1),0===T_.height&&(T_.height=.1),e.reset(T_.get())})),s.add(e)}function P_(t){return t.editable&&!t.locked}const M_=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),A_=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),D_={group(t,e,i){t.sort(A_);const{app:s,parent:n}=t[0];let o;o=i&&i.add?i:new Rh(i),n.addAt(o,n.children.indexOf(t[0])),t.sort(M_);const r=new z(e.worldTransform);return r.divideParent(n.worldTransform),o.setTransform(r),o.editable=!0,o.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(o))),s.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(M_),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(A_),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},I_=vt.get("EditToolCreator");function W_(){return t=>{z_.register(t)}}const F_=W_,z_={list:{},register(t){const{tag:e}=t.prototype;N_[e]&&I_.repeat(e),N_[e]=t},get:(t,e)=>new N_[t](e)},{list:N_}=z_;class Y_ extends Xu{constructor(t,e){super(t,e)}}Y_.BEFORE_OPEN="innerEditor.before_open",Y_.OPEN="innerEditor.open",Y_.BEFORE_CLOSE="innerEditor.before_close",Y_.CLOSE="innerEditor.close";class X_ extends Xu{constructor(t,e){super(t,e)}}X_.BEFORE_GROUP="editor.before_group",X_.GROUP="editor.group",X_.BEFORE_UNGROUP="editor.before_ungroup",X_.UNGROUP="editor.ungroup",X_.BEFORE_OPEN="editor.before_open_group",X_.OPEN="editor.open_group",X_.BEFORE_CLOSE="editor.before_close_group",X_.CLOSE="editor.close_group";const{updateMatrix:H_}=xo,V_={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},j_="top-left";class U_ extends Th{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Uo.CHANGE,(e=>{if(this.checkChange&&V_[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,o="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const r=this.__;r[i]=n,H_(this.parent),H_(this);const a=new z(this.__world);switch(r[i]=s,this.__layout.rotationChange(),H_(this),this.changedTransform=new z(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(j_,o);break;case"scaleX":t.scaleOf(j_,o,1);break;case"scaleY":t.scaleOf(j_,1,o);break;case"skewX":t.skewOf(j_,o,0);break;case"skewY":t.skewOf(j_,0,o)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class G_ extends Rh{get mergeConfig(){const{config:t,element:e,dragPoint:i}=this,s=Object.assign({},t);return e&&e.editConfig&&Object.assign(s,e.editConfig),i&&(i.editConfig&&Object.assign(s,i.editConfig),"font-size"===s.editSize&&(s.lockRatio=!0),"resize-rotate"===i.pointType&&(s.around||(s.around="center"),zt(s.lockRatio)&&(s.lockRatio=!0))),s}get list(){return this.leafList.list}get dragHoverExclude(){return[this.editBox.rect]}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get moving(){return this.editBox.moving}get dragPoint(){return this.editBox.dragPoint}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=At.clone(O_),this.leafList=new _a,this.openedGroupList=new _a,this.simulateTarget=new U_(this),this.editBox=new R_(this),this.editToolList={},this.selector=new a_(this),this.editMask=new C_(this),this.targetEventIds=[],t&&(this.config=At.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox),Rt.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&S_(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||z_.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof Il){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(Ml.getValidMove(this.element,this.editBox.dragStartData.point,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:n,flipable:o,editSize:r}=this.mergeConfig;if(t instanceof zl)"zoom"===n&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:n}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=m_.getScaleData(e,this.editBox.dragStartData.bounds,n,t.getInnerTotal(e),s,m_.getAround(i,t.altKey),o,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:n}=this.mergeConfig,{direction:o,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:h}=this,{dragStartData:l}=this.editBox;let d,c;if(t instanceof Wl){if("rotate"!==i)return;t.stop(),c=t.rotation,d=h.getBoxPoint(t),h.scaleX*h.scaleY<0&&(c=-c)}else{const e=m_.getRotateData(h.boxBounds,o,t.getBoxPoint(h),h.getBoxPoint(l),t.shiftKey?null:h.around||h.origin||s||"center");c=e.rotation,d=e.origin}h.scaleX*h.scaleY<0&&(c=-c),t instanceof Ml&&(c=l.rotation+c-h.rotation),c=a.float(a.getGapRotation(c,n,h.rotation),2),c&&this.rotateOf(d,c)}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:n,skewY:o}=m_.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),m_.getAround(i,t.altKey));(n||o)&&this.skewOf(s,n,o)}move(t,e=0){if(!this.checkTransform("moveable"))return;"object"==typeof t&&(e=t.y,t=t.x);const{element:i}=this,{beforeMove:s}=this.mergeConfig;if(s){const n=s({target:i,x:t,y:e});if("object"==typeof n)t=n.x,e=n.y;else if(!1===n)return}const n=i.getWorldPointByLocal({x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const o={target:i,editor:this,moveX:n.x,moveY:n.y};this.emitEvent(new Hu(Hu.BEFORE_MOVE,o));const r=new Hu(Hu.MOVE,o);this.editTool.onMove(r),this.emitEvent(r)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,{beforeScale:i}=this.mergeConfig;if(i){const{origin:s,scaleX:n,scaleY:o,drag:r}=t;if(!1===i({target:e,drag:r,origin:s,scaleX:n,scaleY:o}))return}t=Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new Vu(Vu.BEFORE_SCALE,t));const s=new Vu(Vu.SCALE,t);this.editTool.onScaleWithDrag(s),this.emitEvent(s)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{element:n}=this,{beforeScale:o}=this.mergeConfig;if(o){const s=o({target:n,origin:t,scaleX:e,scaleY:i});if("object"==typeof s)e=s.scaleX,i=s.scaleY;else if(!1===s)return}const r=this.getWorldOrigin(t),a=this.multiple&&this.getChangedTransform((()=>n.safeChange((()=>n.scaleOf(t,e,i))))),h={target:n,editor:this,worldOrigin:r,scaleX:e,scaleY:i,transform:a};this.emitEvent(new Vu(Vu.BEFORE_SCALE,h));const l=new Vu(Vu.SCALE,h);this.editTool.onScale(l),this.emitEvent(l)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.safeChange((()=>e.flip(t))))):new z(xo.getFlipTransform(e,t)),n={target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s};this.emitEvent(new Vu(Vu.BEFORE_SCALE,n));const o=new Vu(Vu.SCALE,n);this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,{beforeRotate:s}=this.mergeConfig;if(s){const n=s({target:i,origin:t,rotation:e});if("number"==typeof n)e=n;else if(!1===n)return}const n=this.getWorldOrigin(t),o=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),r={target:i,editor:this,worldOrigin:n,rotation:e,transform:o};this.emitEvent(new ju(ju.BEFORE_ROTATE,r));const a=new ju(ju.ROTATE,r);this.editTool.onRotate(a),this.emitEvent(a)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{element:n}=this,{beforeSkew:o}=this.mergeConfig;if(o){const s=o({target:n,origin:t,skewX:e,skewY:i});if("object"==typeof s)e=s.skewX,i=s.skewY;else if(!1===s)return}const r=this.getWorldOrigin(t),a=this.multiple&&this.getChangedTransform((()=>n.safeChange((()=>n.skewOf(t,e,i))))),h={target:n,editor:this,worldOrigin:r,skewX:e,skewY:i,transform:a};this.emitEvent(new Uu(Uu.BEFORE_SKEW,h));const l=new Uu(Uu.SKEW,h);this.editTool.onSkew(l),this.emitEvent(l)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(xo.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this;if(this.multiple&&!e.canChange)return e.changedTransform;const i=new z(e.worldTransform);return t(),new z(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.emitGroupEvent(X_.BEFORE_GROUP),this.target=D_.group(this.list,this.element,t),this.emitGroupEvent(X_.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(X_.BEFORE_UNGROUP,t))),this.target=D_.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(X_.UNGROUP,t)))),this.list}openGroup(t){this.emitGroupEvent(X_.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(X_.OPEN,t)}closeGroup(t){this.emitGroupEvent(X_.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(X_.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!xo.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new X_(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&z_.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||z_.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(Y_.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Y_.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Y_.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Y_.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Y_(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(D_.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(D_.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e}=this;this.targetEventIds=[e.on_(Jo.START,this.update,this),t.on_(Jo.CHILD_START,this.forceRender,this),t.on_(Il.BEFORE_MOVE,this.onMove,this,!0),t.on_(zl.BEFORE_ZOOM,this.onScale,this,!0),t.on_(Wl.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([Nl.HOLD,Nl.UP],(t=>{w_(this,t)})),t.on_(Nl.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}Yt([Gu((function(t,e){t.emitEvent(new Xu(Xu.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],G_.prototype,"hoverTarget",void 0),Yt([Gu((function(t,e){const{target:i}=t;if(i){const{list:e}=t.leafList=i instanceof _a?i:new _a(i);if(!e.every(P_))return void(t.target=e.filter(P_));t.multiple&&S_(t)}else t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor();t.emitEvent(new Xu(Xu.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{x_(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],G_.prototype,"target",void 0);class Z_{static registerInnerEditor(){z_.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new Rh,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!0),this.onUnload())}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let K_=class extends Z_{static registerEditTool(){z_.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:o}=s;n.lockLayout(),o.forEach((t=>{t.moveWorld(e,i)})),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach((t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(n,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:o,list:r}=n;o.lockLayout(),r.forEach((t=>{const o="scale"!==n.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)})),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach((t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(n,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{x:i,y:s,scaleX:n,scaleY:o,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:s,scaleX:n,scaleY:o,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};K_=Yt([W_()],K_);const{left:q_,right:J_}=ut,{move:$_,copy:Q_,toNumberPoints:tp}=P;let ep=class extends K_{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,o=t.target,r=i===q_;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,o.path=t}else if(o.points){const{points:t}=o,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,o.points=t}else{const t={x:0,y:0},{toPoint:i}=o;o.rotation=0,this.dragPoint(t,i,r,n,this.getInnerMove(o,e,s)),o.getLocalPointByInner(t,null,null,!0),o.getLocalPointByInner(i,null,null,!0),o.x=t.x,o.y=t.y,o.getInnerPointByLocal(i,null,null,!0),o.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=tp(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:o,y:r}=n;i?($_(t,o,r),s&&$_(e,-o,-r)):(s&&$_(t,-o,-r),$_(e,o,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,o=this.editor.element;let r,a;if(o.pathInputed?r=this.getFromToByPath(o.__.path):o.points&&(r=this.getFromToByPoints(o.__.points)),r){const{from:i,to:a}=r;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Q_(s[7],i),Q_(e[7],i),Q_(s[3],a),Q_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===q_||t===J_,s[t].visible=a,e[t].visible=!r&&a}};ep=Yt([W_()],ep);const{M:ip,L:sp,C:np,Q:op,Z:rp,N:ap,D:hp,X:lp,G:dp,F:cp,O:up,P:_p,U:pp}=te,gp={scale(t,e,i){if(!t)return;let s,n=0,o=t.length;for(;n<o;)switch(s=t[n],s){case ip:case sp:fp(t,e,i,n,1),n+=3;break;case np:fp(t,e,i,n,3),n+=7;break;case op:fp(t,e,i,n,2),n+=5;break;case rp:n+=1;break;case ap:fp(t,e,i,n,2),n+=5;break;case hp:fp(t,e,i,n,2),n+=9;break;case lp:fp(t,e,i,n,2),n+=6;break;case dp:fp(t,e,i,n,2),n+=9;break;case cp:fp(t,e,i,n,2),n+=5;break;case up:t[n]=dp,t.splice(n+4,0,t[n+3],0),fp(t,e,i,n,2),n+=9,o+=2;break;case _p:t[n]=cp,t.splice(n+4,0,t[n+3]),fp(t,e,i,n,2),n+=5,o+=1;break;case pp:fp(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let o=n?s+1:0,r=n?o+2*n:t.length;o<r;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:fp}=gp,yp=x.get(),{topLeft:mp,top:vp,topRight:wp,right:xp,bottom:bp,left:kp}=ut;function Ep(t,e,i){t.pathInputed?Bp(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function Bp(t,e,i){gp.scale(t.__.path,e,i),t.path=t.__.path}function Rp(t,e,i){const{points:s}=t;"object"==typeof s[0]?s.forEach((t=>{t.x*=e,t.y*=i})):gp.scalePoints(s,e,i),t.points=s}function Cp(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)yp.a=e,yp.d=i,s[t].transform(yp,!0)}const Lp=ia.prototype;function Op(t,e,i){Tp(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(Il.BEFORE_MOVE,(e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY))})),t.on_(zl.BEFORE_ZOOM,(e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&i.scaleOfWorld(e,s)})))}function Tp(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&At.assign(i,e),At.assign(t.config,i,t.userConfig)}Lp.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},Lp.__scaleResize=function(t,e){Ep(this,t,e)},Lp.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},Lp.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},bl.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,n=i&&i.editor,o=n&&n.dragPoint;this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===n.mergeConfig.editSize?function(t,e,i,s){let n=e;if(void 0!==s){const o=t.__layout;let{width:r,height:a}=o.boxBounds;switch(r*=i-e,a*=e-i,s){case vp:case bp:n=i,o.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case kp:case xp:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case mp:case wp:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const o=t.__,{padding:r}=o;r&&(t.padding=r instanceof Array?r.map((t=>t*n)):r*n),o.__autoWidth||(t.width*=n),o.__autoHeight||(t.height*=n)}(this,t,e,o&&o.direction):Ep(this,t,e)},kl.prototype.__scaleResize=function(t,e){Bp(this,t,e)},Jh.prototype.__scaleResize=function(t,e){this.pathInputed?Bp(this,t,e):this.points?Rp(this,t,e):this.width*=t},rl.prototype.__scaleResize=function(t,e){this.pathInputed?Bp(this,t,e):this.points?Rp(this,t,e):Ep(this,t,e)},Rh.prototype.__scaleResize=function(t,e){Cp(this,t,e)},Wh.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||Ep(this,t,e),i&&Cp(this,t,e)},Rt.add("resize"),Rt.add("editor","resize"),e.editor=function(t){return new G_(t)},Wh.addAttr("textBox",!1,Ln),Bh.addAttr("editConfig",void 0,Ln),Bh.addAttr("editOuter",(t=>t.__.__isLinePath?"LineEditTool":"EditTool"),Ln),Bh.addAttr("editInner","PathEditor",Ln),Rh.addAttr("editInner","",Ln),bl.addAttr("editInner","TextEditor",Ln),Bh.setEditConfig=function(t){this.changeAttr("editConfig",t)},Bh.setEditOuter=function(t){this.changeAttr("editOuter",t)},Bh.setEditInner=function(t){this.changeAttr("editInner",t)};const Sp=vt.get("LeaferTypeCreator"),Pp={list:{},register(t,e){Mp[t]&&Sp.repeat(t),Mp[t]=e},run(t,e){const i=Mp[t];i&&i(e)}},{list:Mp,register:Ap}=Pp;Ap("viewport",Op),Ap("custom",(function(t){Op(t,null,!0)})),Ap("design",(function(t){Op(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})})),Ap("document",(function(t){Op(t,{zoom:{min:1},move:{scroll:"limit"}})}));const Dp={getData(t){const e=t[0],i=t[1],s=P.getCenter(e.from,i.from),n=P.getCenter(e.to,i.to),o={x:n.x-s.x,y:n.y-s.y},r=P.getDistance(e.from,i.from);return{move:o,scale:P.getDistance(e.to,i.to)/r,rotation:P.getRotation(e.from,i.from,e.to,i.to),center:n}}},Ip={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(e,i){let s,n=1,{zoomMode:o,zoomSpeed:r}=i;const h=e.deltaY||e.deltaX;if(o?(s="mouse"===o||!e.deltaX&&(t.intWheelDeltaY?Math.abs(h)>17:Math.ceil(h)!==h),(e.shiftKey||e.metaKey||e.ctrlKey)&&(s=!0)):s=!e.shiftKey&&(e.metaKey||e.ctrlKey),s){r=a.within(r,0,1);n=1-h/(4*(e.deltaY?i.delta.y:i.delta.x))*r,n<.5&&(n=.5),n>=1.5&&(n=1.5)}return n}};class Wp{get transforming(){return!!(this.moveData||this.zoomData||this.rotateData)}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),e.emit(Il.START,this.moveData)),t.path=this.moveData.path,e.emit(Il.BEFORE_MOVE,t),e.emit(Il.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.emit(zl.START,this.zoomData)),t.path=this.zoomData.path,e.emit(zl.BEFORE_ZOOM,t),e.emit(zl.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.emit(Wl.START,this.rotateData)),t.path=this.rotateData.path,e.emit(Wl.BEFORE_ROTATE,t),e.emit(Wl.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout((()=>{this.transformEnd()}),this.interaction.p.transformTime)}transformEnd(){const{interaction:t,moveData:e,zoomData:i,rotateData:s}=this;e&&t.emit(Il.END,e),i&&t.emit(zl.END,i),s&&t.emit(Wl.END,s),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const Fp=Oh.prototype,zp=new ht;function Np(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function Yp(t,e){return Object.assign(Object.assign({},e),{scale:t})}Fp.initType=function(t){Pp.run(t,this)},Fp.getValidMove=function(t,e){const{scroll:i,disabled:s}=this.app.config.move;if(i){const s=!0===i?"":i;if(s.includes("x")?(t=t||e,e=0):s.includes("y")?(e=e||t,t=0):Math.abs(t)>Math.abs(e)?e=0:t=0,s.includes("limit")){const{x:i,y:s,width:n,height:o}=zp.set(this.__world).addPoint(this.zoomLayer),r=i+n-this.width,a=s+o-this.height;i>=0&&r<=0?t=0:t>0?i+t>0&&(t=-i):t<0&&r+t<0&&(t=-r),s>=0&&a<=0?e=0:e>0?s+e>0&&(e=-s):e<0&&a+e<0&&(e=-a)}}return{x:s?0:t,y:s?0:e}},Fp.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),n?1:t};const Xp=sd.prototype;Xp.createTransformer=function(){this.transformer=new Wp(this)},Xp.move=function(t){this.transformer.move(t)},Xp.zoom=function(t){this.transformer.zoom(t)},Xp.rotate=function(t){this.transformer.rotate(t)},Xp.transformEnd=function(){this.transformer.transformEnd()},Xp.wheel=function(t){const{wheel:e}=this.config;if(e.disabled)return;const i=e.getScale?e.getScale(t,e):Ip.getScale(t,e);1!==i?this.zoom(Yp(i,t)):this.move(Np(e.getMove?e.getMove(t,e):Ip.getMove(t,e),t))},Xp.multiTouch=function(t,e){if(this.config.multiTouch.disabled)return;const{move:i,rotation:s,scale:n,center:o}=Dp.getData(e);Object.assign(t,o),this.rotate(function(t,e){return Object.assign(Object.assign({},e),{rotation:t})}(s,t)),this.zoom(Yp(n,t)),this.move(Np(i,t))};const Hp=Gl.prototype,{abs:Vp}=Math;function jp(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}Hp.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=Vp(i),o=Vp(s),r=e?1:.1,a=this.interaction.m.dragAnimate&&this.canAnimate&&this.moving&&(n>r||o>r);if(a){const r="touch"===t.pointerType?3:1,a=70;n*(e=e?.95:r)>a?e=a/n:o*e>a&&(e=a/o),t=Object.assign({},t),P.move(t,i*e,s*e),this.drag(t),this.animate((()=>{this.dragEnd(t,1)}))}return a},Hp.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},Hp.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},Hp.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:o}=e.m;if(!o||!s||!n)return;const r=e.shrinkCanvasBounds,{x:a,y:h}=r,l=nt.maxX(r),d=nt.maxY(r),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let _=0,p=0;this.autoMoveTimer=setInterval((()=>{_+=c,p+=u,P.move(i,c,u),P.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:_,totalY:p,moveType:"drag"})),e.pointerMoveReal(t)}),10)},Hp.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},Rt.add("viewport"),Rt.add("view"),Oh.prototype.zoom=function(t,e,i,s){this.killAnimate();const{zoomLayer:n}=this,o=this.canvas.bounds.clone().shrink(void 0!==e?e:30),r=new ht,a={x:o.x+o.width/2,y:o.y+o.height/2};let h;const{x:l,y:d,scaleX:c,scaleY:u}=n.__;if("string"==typeof t)switch(t){case"in":h=jp(c,"in");break;case"out":h=jp(c,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new ht(this.boxBounds)).height=0;break;case"fit-height":(t=new ht(this.boxBounds)).width=0}else"number"==typeof t&&(h=t/c);if(h)h=this.getValidScale(h),n.scaleOfWorld(a,h,h,!1,s);else if("object"==typeof t){const e={x:l,y:d,scaleX:c,scaleY:u},a=t instanceof Array;if(a||t.tag){const e=a?t:[t];r.setListWithFn(e,Lo.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:o,height:r}=t;return r||(r=o*(e.height/e.width),i=!0),o||(o=r*(e.width/e.height),i=!0),i?{x:s,y:n,width:o,height:r}:t}(t,o);r.set(n.getWorldBounds(e))}const{width:_,height:p}=r;let g=o.x-r.x,f=o.y-r.y;return i?(g+=Math.max((o.width-_)/2,0),f+=Math.max((o.height-p)/2,0)):(h=this.getValidScale(Math.min(o.width/_,o.height/p)),g+=(o.width-_*h)/2,f+=(o.height-p*h)/2,P.scaleOf(e,r,h),r.scaleOf(r,h),e.scaleX*=h,e.scaleY*=h),P.move(e,g,f),r.move(g,f),n.set(e,s),r}return n.worldBoxBounds};class Up extends Rh{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&At.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let e;"string"==typeof t?(e={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(e.fill="white",e.stroke="rgba(0,0,0,0.2)")):e=t,this.scrollXBar||this.addMany(this.scrollXBar=new Wh,this.scrollYBar=new Wh),e=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},e),e.height||(e.height=e.width),this.scrollXBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:o}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(o))return;this.scrollBounds=new ht(o);const r=n.bounds.clone().shrink(i),a=r.clone().add(o),h=this.ratioX=r.width/a.width,l=this.ratioY=r.height/a.height,d=(r.x-a.x)/a.width,c=(r.y-a.y)/a.height,u=h<1,_=l<1,{scrollXBar:p,scrollYBar:g}=this,{x:f,y:y,width:m,height:v}=r.shrink([2,_?g.width+6:2,u?p.height+6:2,2]);p.set({x:f+m*d,y:y+v+2,width:Math.max(m*h,e),visible:u}),g.set({x:f+m+2,y:y+v*c,height:Math.max(v*l,e),visible:_})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:e}=this;this.__eventIds=[t.on_(Ml.DRAG,this.onDrag,this),e.on_(Ml.DRAG,this.onDrag,this),t.on_(Ml.END,this.onDragEnd,this),e.on_(Ml.END,this.onDragEnd,this),this.target.on_(Jo.BEFORE,(()=>this.update(!0))),this.target.leafer.on_(Zo.RESIZE,(()=>this.update()))]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}Rt.add("scroll");class Gp extends lh{}function Zp(t){return Bn(t,(t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,zn(this)}}})))}let Kp=class extends Jh{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}};Yt([$n(Gp)],Kp.prototype,"__",void 0),Yt([Zp("angle")],Kp.prototype,"endArrow",void 0),Kp=Yt([ho()],Kp);const{M:qp,L:Jp,C:$p,Q:Qp,O:tg}=te,{rotate:eg,copyFrom:ig,scale:sg}=P,ng={},og={layout(t,e,i,s,n,o,r){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case qp:case Jp:rg(t,l+1,e,i,s,n,o,r),l+=3;break;case $p:for(h=1;h<6;h+=2)rg(t,l+h,e,i,s,n,o,r);l+=7;break;case Qp:for(h=1;h<4;h+=2)rg(t,l+h,e,i,s,n,o,r);l+=5;break;case tg:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),o&&(t[l+4]+=o,t[l+5]+=o),l+=7}},rotate(t,e,i){og.layout(t,0,0,1,1,e,i)}};function rg(t,e,i,s,n,o,r,a){ig(ng,t[e],t[e+1]),r&&eg(ng,r,a),n&&sg(ng,n,o),t[e]=i+ng.x,t[e+1]=s+ng.y}const{layout:ag,rotate:hg}=og,{getAngle:lg}=P,dg={x:-.5},cg={connect:dg,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},ug={connect:dg,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},_g={connect:dg,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},pg={connect:dg,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},gg={offset:dg,path:[..._g.path],dashPath:[1,-2.5,0,2,-1,0]};hg(gg.path,180,{x:-1.5,y:0});const fg={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},yg={connect:{x:.5},path:[...fg.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},mg={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},vg={path:[...mg.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},wg=At.clone(mg),xg=At.clone(vg);hg(wg.path,45),hg(xg.path,45);const bg={angle:cg,"angle-side":ug,arrow:pg,triangle:_g,"triangle-flip":gg,circle:yg,"circle-line":fg,square:vg,"square-line":mg,diamond:xg,"diamond-line":wg,mark:{offset:dg,path:[1,0,-2,2,0,2]}};function kg(t,e,i,s,n,o,r){const{strokeCap:a,strokeJoin:h}=t.__,{offset:l,connect:d,path:c,dashPath:u}="object"==typeof e?e:bg[e];let _=d?d.x:0,p=l?l.x:0;const g=[...c];return r&&u&&g.push(...u),"none"!==a&&(_-=.5),l&&("round"===h&&l.roundJoin?p+=l.roundJoin:"bevel"===h&&l.bevelJoin&&(p+=l.bevelJoin)),p&&ag(g,p,0),ag(g,s.x,s.y,n,n,lg(i,s)),o.x=(_+p)*n,g}const{M:Eg,L:Bg,C:Rg,Q:Cg,Z:Lg,N:Og,D:Tg,X:Sg,G:Pg,F:Mg,O:Ag,P:Dg,U:Ig}=te,{copy:Wg,copyFrom:Fg,getDistancePoint:zg}=P,Ng={},Yg={},Xg={},Hg={},Vg={},jg={list:bg,addArrows(t,e){const{startArrow:i,endArrow:s,strokeWidth:n,dashPattern:o,__pathForRender:r}=t.__;let a,h=0,l=r.length,d=0,c=i&&"none"!==i;for(;h<l;){switch(a=r[h],a){case Eg:case Bg:(d<2||h+6>=l)&&(Fg(Vg,r[h+1],r[h+2]),!d&&c&&Wg(Yg,Vg)),h+=3;break;case Rg:1!==d&&h+7!==l||Ug(r,Hg,Vg,h+3),h+=7;break;case Cg:1!==d&&h+5!==l||Ug(r,Hg,Vg,h+1),h+=5;break;case Lg:return;case Og:h+=5;break;case Tg:h+=9;break;case Sg:h+=6;break;case Pg:h+=9;break;case Mg:h+=5;break;case Ag:h+=7;break;case Dg:h+=4;break;case Ig:1!==d&&h+6!==l||Ug(r,Hg,Vg,h+1),h+=6}if(d++,1===d&&a!==Eg)return;if(2===d&&c&&Wg(Xg,a===Bg?Vg:Hg),h===l){const l=t.__.__pathForRender=e?[...r]:r,d=t.__.__pathForArrow=[];if(c){const e=kg(t,i,Xg,Yg,n,Ng,!!o);o?d.push(...e):l.push(...e),Ng.x&&(zg(Yg,Xg,-Ng.x,!0),l[1]=Xg.x,l[2]=Xg.y)}if(s&&"none"!==s){const e=kg(t,s,Hg,Vg,n,Ng,!!o);if(o?d.push(...e):l.push(...e),Ng.x){let t;switch(zg(Vg,Hg,-Ng.x,!0),a){case Bg:t=h-3+1;break;case Rg:t=h-7+5;break;case Cg:t=h-5+3;break;case Ig:t=h-6+3}t&&Gg(l,Hg,t)}}}else Wg(Hg,Vg)}}};function Ug(t,e,i,s){Fg(e,t[s],t[s+1]),Fg(i,t[s+2],t[s+3])}function Gg(t,e,i){t[i]=e.x,t[i+1]=e.y}Rt.add("arrow"),Bh.addAttr("startArrow","none",Zp),Bh.addAttr("endArrow","none",Zp),Object.assign(Va,jg);const{Yes:Zg,NoAndSkip:Kg,YesAndSkip:qg}=Wt,Jg={},$g={},Qg={};class tf{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":Jg.id=t.substring(1),t=Jg;break;case".":$g.className=t.substring(1),t=$g;break;default:Qg.tag=t,t=Qg}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:s}=t,n=s instanceof Array;return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?At.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&xo.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),o===Zg||o===qg){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<Kg&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(jo.REMOVE,this.__onRemoveChild,this),this.target.on_(Uo.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const ef=Bh.prototype;function sf(i){return i.leafer?i.leafer.selector:t.selector||(t.selector=e.selector())}ef.find=function(t,e){return sf(this).getBy(t,this,!1,e)},ef.findOne=function(t,e){return sf(this).getBy(t,this,!0,e)},Rt.add("find"),e.finder=function(t){return new tf(t)};const{setPoint:nf,addPoint:of,toBounds:rf}=Y;const af={syncExport(i,s,n){let o;this.running=!0;const r=dn.fileType(s),h=s.includes(".");n=dn.getExportOptions(n);const{toURL:l}=t,{download:d}=t.origin;if("json"===r)h&&d(l(JSON.stringify(i.toJSON(n.json)),"text"),s),o={data:!!h||i.toJSON(n.json)};else if("svg"===r)h&&d(l(i.toSVG(),"svg"),s),o={data:!!h||i.toSVG()};else{let t,r,h=1,l=1;const{worldTransform:d,isLeafer:c,leafer:u,isFrame:_}=i,{slice:p,trim:g,padding:f,onCanvas:y}=n,m=void 0===n.smooth?!u||u.config.smooth:n.smooth,v=n.contextSettings||(u?u.config.contextSettings:void 0),w=n.screenshot||i.isApp,x=c&&w&&void 0===n.fill?i.fill:n.fill,b=dn.isOpaqueImage(s)||x,k=new z;if(w)t=!0===w?c?u.canvas.bounds:i.worldRenderBounds:w;else{let e=n.relative||(c?"inner":"local");switch(h=d.scaleX,l=d.scaleY,e){case"inner":k.set(d);break;case"local":k.set(d).divide(i.localTransform),h/=i.scaleX,l/=i.scaleY;break;case"world":h=1,l=1;break;case"page":e=u||i;default:k.set(d).divide(i.getTransform(e));const t=e.worldTransform;h/=h/t.scaleX,l/=l/t.scaleY}t=i.getBounds("render",e)}const E={scaleX:1,scaleY:1};a.getScaleData(n.scale,n.size,t,E);let B=n.pixelRatio||1;i.isApp&&(E.scaleX*=B,E.scaleY*=B,B=i.app.pixelRatio);const{x:R,y:C,width:L,height:O}=new ht(t).scale(E.scaleX,E.scaleY),T={matrix:k.scale(1/E.scaleX,1/E.scaleY).invert().translate(-R,-C).withScale(1/h*E.scaleX,1/l*E.scaleY)};let S,P=e.canvas({width:Math.floor(L),height:Math.floor(O),pixelRatio:B,smooth:m,contextSettings:v});if(p&&(S=i,S.__worldOpacity=0,i=u||i,T.bounds=P.bounds),P.save(),_&&void 0!==x){const t=i.get("fill");i.fill="",i.__render(P,T),i.fill=t}else i.__render(P,T);if(P.restore(),S&&S.__updateWorldOpacity(),g){r=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?of(r,n,o):nf(r={},n,o)),a++;const h=new ht;return rf(r,h),h.scale(1/t.pixelRatio).ceil()}(P);const t=P,{width:i,height:s}=r,n={x:0,y:0,width:i,height:s,pixelRatio:B};P=e.canvas(n),P.copyWorld(t,r,n)}if(f){const[t,i,s,n]=a.fourNumber(f),o=P,{width:r,height:h}=o;P=e.canvas({width:r+n+i,height:h+t+s,pixelRatio:B}),P.copyWorld(o,o.bounds,{x:n,y:t,width:r,height:h})}b&&P.fillWorld(P.bounds,x||"#FFFFFF","destination-over"),y&&y(P);o={data:"canvas"===s?P:P.export(s,n),width:P.pixelWidth,height:P.pixelHeight,renderBounds:t,trimBounds:r}}return this.running=!1,o},export(e,i,s){return this.running=!0,function(t){hf||(hf=new pn);return new Promise((e=>{hf.add((()=>Xt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=()=>Xt(this,void 0,void 0,(function*(){if(!fn.isComplete)return t.requestRender(r);const a=af.syncExport(e,i,s);a.data instanceof Promise&&(a.data=yield a.data),n(a),o()}));e.updateLayout(),lf(e);const{leafer:a}=e;a?a.waitViewCompleted(r):r()}))))}};let hf;function lf(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>lf(t)))}const df=Jt.prototype,cf=vt.get("@leafer-in/export");df.export=function(t,e){const{quality:i,blob:s}=dn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},df.toBlob=function(e,i){return new Promise((s=>{t.origin.canvasToBolb(this.view,e,i).then((t=>{s(t)})).catch((t=>{cf.error(t),s(null)}))}))},df.toDataURL=function(e,i){return t.origin.canvasToDataURL(this.view,e,i)},df.saveAs=function(e,i){return new Promise((s=>{t.origin.canvasSaveAs(this.view,e,i).then((()=>{s(!0)})).catch((t=>{cf.error(t),s(!1)}))}))},Rt.add("export"),Object.assign(qa,af),Bh.prototype.export=function(t,e){return qa.export(this,t,e)},Bh.prototype.syncExport=function(t,e){return qa.syncExport(this,t,e)};const uf={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},_f={top:"flex-start",middle:"center",bottom:"flex-end"},pf={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function gf(t,e,i){const{style:s}=t,{fill:n,padding:o,textWrap:r,textOverflow:a,textDecoration:h}=e;let l;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";e instanceof Array&&(e=e[0]);if("object"==typeof e)switch(e.type){case"solid":i=Xa.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Xa.string("string"==typeof t?t:t.color);break;default:void 0!==e.r&&(i=Xa.string(e))}else i=e;t.color=i}(s,n),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,"object"==typeof h?(l=h.type,h.color&&(s.textDecorationColor=Xa.string(h.color))):l=h,s.textDecoration=pf[l],s.textTransform=uf[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=_f[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px","none"===r?s.whiteSpace="nowrap":"break"===r&&(s.wordBreak="break-all"),s.textIndent=(e.paraIndent||0)*i+"px",s.padding=o instanceof Array?o.map((t=>t*i+"px")).join(" "):(o||0)*i+"px",s.textOverflow="show"===a?"":"hide"===a?"clip":a}let ff=class extends Z_{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:t}=this,{config:e}=t.app,i=this.editTarget;i.visible=!1,this.isHTMLText=!(i instanceof bl),this._keyEvent=e.keyEvent,e.keyEvent=!1;const s=this.editDom=document.createElement("div"),{style:n}=s;s.contentEditable="true",n.position="fixed",n.transformOrigin="left top",n.boxSizing="border-box",this.isHTMLText?s.innerHTML=String(i.text):s.innerText=String(i.text);const{view:o}=t.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(s):o.appendChild(s),this.eventIds=[t.app.on_(Tl.DOWN,(e=>{let i,{target:n}=e.origin;for(;n;)n===s&&(i=!0),n=n.parentElement;i||t.closeInnerEditor()}))],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),s.addEventListener("focus",this.onFocus),s.addEventListener("input",this.onInput),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const r=window.getSelection(),a=document.createRange();if(this.config.selectAll)a.selectNodeContents(s);else{const t=s.childNodes[0];a.setStartAfter(t),a.setEndAfter(t),a.collapse(!0)}r.removeAllRanges(),r.addRange(a)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=window.getSelection().getRangeAt(0);i.deleteContents(),i.insertNode(e),i.setStartAfter(e),i.setEndAfter(e),this.onInput()}}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;const{a:i,b:s,c:n,d:o,e:r,f:a}=new z(t.worldTransform).scale(1/e);let{x:h,y:l}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds;this.inBody||(h-=window.scrollX,l-=window.scrollY);let{width:d,height:c}=t;d*=e,c*=e;const u=t.__;if(u.__autoWidth&&u.autoSizeAlign)switch(d+=20,u.textAlign){case"center":h-=d/2;break;case"right":h-=d}if(u.__autoHeight&&u.autoSizeAlign)switch(c+=20,u.verticalAlign){case"middle":l-=c/2;break;case"bottom":l-=c}const{style:_}=this.editDom;_.transform=`matrix(${i},${s},${n},${o},${r},${a})`,_.left=h+"px",_.top=l+"px",_.width=d+"px",_.height=c+"px",this.isHTMLText||gf(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),t.visible=!0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}};ff=Yt([F_()],ff),Rt.add("text-editor","editor");class yf extends mh{setText(t){this._text=t,this.__htmlChanged=!0}}let mf=class extends pl{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),o=s+10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${n}">\n <foreignObject width="${o}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.text}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),t.__naturalWidth=o/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}};Yt([$n(yf)],mf.prototype,"__",void 0),Yt([Mn("")],mf.prototype,"text",void 0),Yt([Ln("TextEditor")],mf.prototype,"editInner",void 0),mf=Yt([ho()],mf),Rt.add("html");export{yt as AlignHelper,Wt as Answer,Bl as App,pt as AroundHelper,Kp as Arrow,Gp as ArrowData,dt as AutoBounds,Re as BezierHelper,ht as Bounds,nt as BoundsHelper,Wh as Box,rh as BoxData,ua as Branch,To as BranchHelper,Pr as BranchRender,fl as Canvas,vh as CanvasData,Mt as CanvasManager,jo as ChildEvent,Xa as ColorConvert,e as Creator,nd as Cursor,At as DataHelper,vt as Debug,ct as Direction4,ut as Direction9,Ml as DragEvent,Gl as Dragger,Dl as DropEvent,R_ as EditBox,m_ as EditDataHelper,k_ as EditPoint,a_ as EditSelect,s_ as EditSelectHelper,K_ as EditTool,z_ as EditToolCreator,G_ as Editor,Xu as EditorEvent,X_ as EditorGroupEvent,D_ as EditorHelper,Hu as EditorMoveEvent,ju as EditorRotateEvent,Vu as EditorScaleEvent,Uu as EditorSkewEvent,Za as Effect,Xh as Ellipse,ch as EllipseData,De as EllipseHelper,Vo as Event,St as EventCreator,tr as Eventer,qa as Export,dn as FileHelper,Ka as Filter,tf as Finder,Fh as Frame,hh as FrameData,Rh as Group,oh as GroupData,mf as HTMLText,yf as HTMLTextData,od as HitCanvasManager,pl as Image,mh as ImageData,Go as ImageEvent,mn as ImageManager,i as IncrementId,Z_ as InnerEditor,Y_ as InnerEditorEvent,sd as InteractionBase,Yl as InteractionHelper,Nl as KeyEvent,Cl as Keyboard,qo as LayoutEvent,Pa as Layouter,ia as Leaf,Or as LeafBounds,Lo as LeafBoundsHelper,It as LeafData,pr as LeafDataProxy,cr as LeafEventer,xo as LeafHelper,Ho as LeafLayout,pa as LeafLevelList,_a as LeafList,xr as LeafMatrix,Tr as LeafRender,Oh as Leafer,fa as LeaferCanvas,Jt as LeaferCanvasBase,ah as LeaferData,$o as LeaferEvent,bn as LeaferImage,Pp as LeaferTypeCreator,Jh as Line,lh as LineData,ep as LineEditTool,a as MathHelper,z as Matrix,x as MatrixHelper,Il as MoveEvent,Dp as MultiTouchHelper,Al as MyDragEvent,gl as MyImage,Sl as MyPointerEvent,ie as NeedConvertToCanvasCommandMap,h as OneRadian,l as PI2,d as PI_2,ja as Paint,Ga as PaintGradient,Ua as PaintImage,kl as Path,Va as PathArrow,jg as PathArrowModule,$s as PathBounds,Xi as PathCommandDataHelper,te as PathCommandMap,vi as PathConvert,rn as PathCorner,os as PathCreator,ph as PathData,ws as PathDrawer,$t as PathHelper,og as PathMatrixHelper,re as PathNumberCommandLengthMap,oe as PathNumberCommandMap,El as Pen,gh as PenData,Ia as Picker,t as Platform,Rt as Plugin,W as Point,P as PointHelper,Ll as PointerButton,Tl as PointerEvent,rl as Polygon,uh as PolygonData,Uo as PropertyEvent,Th as Rect,dh as RectData,ae as RectHelper,kh as RectRender,Jo as RenderEvent,Aa as Renderer,Zo as ResizeEvent,fn as Resource,Wl as RotateEvent,kt as Run,Up as ScrollBar,i_ as SelectArea,Wa as Selector,_l as Star,_h as StarData,Ja as State,mt as StringNumberMap,e_ as Stroker,Fl as SwipeEvent,_n as TaskItem,pn as TaskProcessor,bl as Text,Ya as TextConvert,yh as TextData,ff as TextEditor,Wp as Transformer,$a as Transition,Y as TwoPointBoundsHelper,Bh as UI,wh as UIBounds,Lt as UICreator,sh as UIData,Ol as UIEvent,xh as UIRender,Ha as UnitConvert,Ao as WaitHelper,Ko as WatchEvent,wa as Watcher,Ip as WheelEventHelper,zl as ZoomEvent,Op as addViewport,Tp as addViewportConfig,Yn as affectRenderBoundsType,Fn as affectStrokeBoundsType,Zp as arrowType,Rn as attr,Tn as autoLayoutType,Mn as boundsType,ln as canvasPatch,qt as canvasSizeAttrs,Jn as cursorType,$n as dataProcessor,Ln as dataType,Bn as decorateLeafAttr,to as defineDataProcessor,kn as defineKey,Cn as defineLeafAttr,Dn as doBoundsType,zn as doStrokeType,Fa as effectType,Ft as emptyData,Kn as eraserType,u as getBoundsData,En as getDescriptor,_ as getMatrixData,c as getPointData,qn as hitType,Nt as isEmptyData,zt as isNull,Qn as layoutProcessor,Zn as maskType,An as naturalBoundsType,Hn as opacityType,In as pathInputType,Wn as pathType,an as pen,On as positionType,W_ as registerEditTool,F_ as registerInnerEditor,ho as registerUI,lo as registerUIEvent,za as resizeType,no as rewrite,oo as rewriteAble,Pn as rotationType,Sn as scaleType,Gn as sortType,Nn as strokeType,Xn as surfaceType,lt as tempBounds,N as tempMatrix,F as tempPoint,ma as useCanvas,ao as useModule,ga as version,Vn as visibleType,Na as zoomLayerType};
2
2
  //# sourceMappingURL=worker.module.min.js.map