@zzalai/leafer-multi-roi 1.0.3 → 1.0.4

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 +1 @@
1
- import{createCommentVNode as t,createElementBlock as e,createElementVNode as i,createTextVNode as s,defineComponent as r,nextTick as o,normalizeClass as n,onMounted as a,onUnmounted as h,openBlock as l,ref as d,toDisplayString as c}from"vue";var u;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(u||(u={}));var p={};function g(t){return void 0===t}function _(t){return null==t}function f(t){return"string"==typeof t}var{isFinite:m}=Number;function y(t){return"number"==typeof t}var{isArray:v}=Array;function w(t){return t&&"object"==typeof t}var x,b,k,E={default:(t,e)=>(S(e,t),S(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(r=>{var o,n;if(s=e[r],(null==s?void 0:s.constructor)===Object&&(null===(o=t[r])||void 0===o?void 0:o.constructor)===Object)return S(t[r],e[r],i&&i[r]);i&&r in i?(null===(n=i[r])||void 0===n?void 0:n.constructor)===Object&&S(t[r]={},e[r],i[r]):t[r]=e[r]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{g(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},stintSet(t,e,i){i||(i=void 0),t[e]!==i&&(t[e]=i)}},{assign:S}=E,B=class{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __usePathBox(){return this.__pathInputed}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(!g(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]=g(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(!g(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!g(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(v(t))for(let s of t)i[s]=this.__getInput(s);else for(let s in t)i[s]=this.__getInput(s);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let r in this)if("_"!==r[0]&&(t=this["_"+r],!g(t))){if("path"===r&&!this.__pathInputed)continue;e=s?s[r]:void 0,i[r]=g(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:r,e:o,f:n}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:r,e:o,f:n}}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,this.__complexData&&this.__complexData.destroy()}},T={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=C;return e[t]?e[t]++:(e[t]=1,0)}},C=T,{max:O}=Math,R=[0,0,0,0],P={zero:[...R],tempFour:R,set:(t,e,i,s,r)=>(void 0===i&&(i=s=r=e),t[0]=e,t[1]=i,t[2]=s,t[3]=r,t),setTemp:(t,e,i,s)=>L(R,t,e,i,s),toTempAB(t,e,i){k=i?y(t)?e:t:[],y(t)?(x=D(t),b=e):y(e)?(x=t,b=D(e)):(x=t,b=e),4!==x.length&&(x=M(x)),4!==b.length&&(b=M(b))},get(t,e){let i;if(!y(t))switch(t.length){case 4:i=g(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]),!g(e))for(let s=0;s<4;s++)i[s]>e&&(i[s]=e);return i},max:(t,e,i)=>y(t)&&y(e)?O(t,e):(A(t,e,i),L(k,O(x[0],b[0]),O(x[1],b[1]),O(x[2],b[2]),O(x[3],b[3]))),add:(t,e,i)=>y(t)&&y(e)?t+e:(A(t,e,i),L(k,x[0]+b[0],x[1]+b[1],x[2]+b[2],x[3]+b[3])),swapAndScale(t,e,i,s){if(y(t))return e===i?t*e:[t*i,t*e];const r=s?t:[],[o,n,a,h]=4===t.length?t:M(t);return L(r,a*i,h*e,o*i,n*e)}},{set:L,get:M,setTemp:D,toTempAB:A}=P,{round:I,pow:W,max:z,floor:F,PI:Y}=Math,N={},X={within:(t,e,i)=>(w(e)&&(i=e.max,e=e.min),!g(e)&&t<e&&(t=e),!g(i)&&t>i&&(t=i),t),fourNumber:P.get,formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),X.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=g(e)?1e12:W(10,e);return-0===(t=I(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(y(e)?e:e.width||0)/i.width,r=(y(e)?e:e.height||0)/i.height;s.scaleX=t||r||1,s.scaleY=r||t||1}else t&&X.assignScale(s,t);return s},getScaleFixedData(t,e,i,s,r){let{scaleX:o,scaleY:n}=t;if((s||e)&&(o<0&&(o=-o),n<0&&(n=-n)),e)if(!0===e)o=n=i?1:1/o;else{let t;y(e)?t=e:"zoom-in"===e&&(t=1),t&&(o=n=o>t||n>t?i?1:1/o:i?1:1/t)}return N.scaleX=o,N.scaleY=n,N},assignScale(t,e){y(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>z(F(t),e)/t,randInt:H,randColor:t=>`rgba(${H(255)},${H(255)},${H(255)},${t||1})`};function H(t){return Math.round(Math.random()*t)}var V=Y/180,U=2*Y,j=Y/2;function G(){return{a:1,b:0,c:0,d:1,e:0,f:0}}var{sin:K,cos:Z,acos:q,sqrt:$}=Math,{float:J}=X,Q={};function tt(){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})}var et,it,st={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:tt(),tempMatrix:{},set(t,e=1,i=0,s=0,r=1,o=0,n=0){t.a=e,t.b=i,t.c=s,t.d=r,t.e=o,t.f=n},get:G,getWorld:tt,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},pixelScale(t,e,i){i||(i=t),i.a=t.a*e,i.b=t.b*e,i.c=t.c*e,i.d=t.d*e,i.e=t.e*e,i.f=t.f*e},scaleOfOuter(t,e,i,s){rt.toInnerPoint(t,e,Q),rt.scaleOfInner(t,Q,i,s)},scaleOfInner(t,e,i,s=i){rt.translateInner(t,e.x,e.y),rt.scale(t,i,s),rt.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:r,d:o}=t,n=Z(e*=V),a=K(e);t.a=i*n-s*a,t.b=i*a+s*n,t.c=r*n-o*a,t.d=r*a+o*n},rotateOfOuter(t,e,i){rt.toInnerPoint(t,e,Q),rt.rotateOfInner(t,Q,i)},rotateOfInner(t,e,i){rt.translateInner(t,e.x,e.y),rt.rotate(t,i),rt.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:r,c:o,d:n}=t;i&&(i*=V,t.a=s+o*i,t.b=r+n*i),e&&(e*=V,t.c=o+s*e,t.d=n+r*e)},skewOfOuter(t,e,i,s){rt.toInnerPoint(t,e,Q),rt.skewOfInner(t,Q,i,s)},skewOfInner(t,e,i,s=0){rt.translateInner(t,e.x,e.y),rt.skew(t,i,s),rt.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:r,d:o,e:n,f:a}=t;t.a=e.a*i+e.b*r,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*r,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*r+n,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,r){const{e:o,f:n}=t;if(i||(i=t),g(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:n,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=n*e.a+a*e.c,i.d=n*e.b+a*e.d,r&&(i.scaleX=e.scaleX*r.scaleX,i.scaleY=e.scaleY*r.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,r&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=o*e.a+n*e.c+e.e,i.f=o*e.b+n*e.d+e.f},divide(t,e){rt.multiply(t,rt.tempInvert(e))},divideParent(t,e){rt.multiplyParent(t,rt.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=rt;return rt.copy(e,t),rt.invert(e),e},invert(t){const{a:e,b:i,c:s,d:r,e:o,f:n}=t;if(i||s){const a=1/(e*r-i*s);t.a=r*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*r-n*s)*a,t.f=-(n*e-o*i)*a}else if(1===e&&1===r)t.e=-o,t.f=-n;else{const i=1/(e*r);t.a=r*i,t.d=e*i,t.e=-o*r*i,t.f=-n*e*i}},toOuterPoint(t,e,i,s){const{x:r,y:o}=e;i||(i=e),i.x=r*t.a+o*t.c,i.y=r*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:r,b:o,c:n,d:a}=t,h=1/(r*a-o*n),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*n)*h,i.y=(d*r-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*n)*h,i.y-=(s*r-e*o)*h}},setLayout(t,e,i,s,r){const{x:o,y:n,scaleX:a,scaleY:h}=e;if(g(r)&&(r=e.rotation||e.skewX||e.skewY),r){const{rotation:i,skewX:s,skewY:r}=e,o=i*V,n=Z(o),l=K(o);if(s||r){const e=s*V,i=r*V;t.a=(n+i*-l)*a,t.b=(l+i*n)*a,t.c=(e*n-l)*h,t.d=(n+e*l)*h}else t.a=n*a,t.b=l*a,t.c=-l*h,t.d=n*h}else t.a=a,t.b=0,t.c=0,t.d=h;t.e=o,t.f=n,(i=i||s)&&rt.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:r,b:o,c:n,d:a,e:h,f:l}=t;let d,c,u,p,g,_=h,f=l;if(o||n){const t=r*a-o*n;if(n&&!s){d=$(r*r+o*o),c=t/d;const e=r/d;u=o>0?q(e):-q(e)}else{c=$(n*n+a*a),d=t/c;const e=n/c;u=j-(a>0?q(-e):-q(e))}const e=J(Z(u)),i=K(u);d=J(d),c=J(c),p=e?J((n/c+i)/e/V,9):0,g=e?J((o/d-i)/e/V,9):0,u=J(u/V)}else d=r,c=a,u=p=g=0;return(e=i||e)&&(_+=e.x*r+e.y*n,f+=e.x*o+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:p,skewY:g}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:r,c:o,d:n}=t;r||o?i=(s*n-r*o)/(e=$(s*s+r*r)):(e=s,i=n)}return s.scaleX=e,s.scaleY=i,s},reset(t){rt.set(t)}},rt=st,{float:ot}=X,{toInnerPoint:nt,toOuterPoint:at}=st,{sin:ht,cos:lt,abs:dt,sqrt:ct,atan2:ut,min:pt,round:gt}=Math,_t={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=g(i)?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},round(t,e){t.x=e?gt(t.x-.5)+.5:gt(t.x),t.y=e?gt(t.y-.5)+.5:gt(t.y)},move(t,e,i){w(e)?(t.x+=e.x,t.y+=e.y):(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=ft.defaultPoint);const s=lt(e*=V),r=ht(e),o=t.x-i.x,n=t.y-i.y;t.x=i.x+o*s-n*r,t.y=i.y+o*r+n*s},tempToInnerOf(t,e){const{tempPoint:i}=ft;return yt(i,t),nt(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=ft;return yt(i,t),at(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=ft;return yt(i,t),ft.toInnerRadiusPointOf(t,e,i),i},copyRadiusPoint:(t,e,i,s)=>(yt(t,e),vt(t,i,s),t),toInnerRadiusPointOf(t,e,i){i||(i=t),nt(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){nt(e,t,i)},toOuterOf(t,e,i){at(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)=>mt(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const r=dt(i-t),o=dt(s-e);return ct(r*r+o*o)},getMinDistanceFrom:(t,e,i,s,r,o)=>pt(mt(t,e,i,s),mt(i,s,r,o)),getAngle:(t,e)=>wt(t,e)/V,getRotation:(t,e,i,s)=>(s||(s=e),ft.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/V),getRadianFrom(t,e,i,s,r,o,n,a){g(n)&&(n=i,a=s);const h=t-i,l=e-s,d=r-n,c=o-a;return Math.atan2(h*c-l*d,h*d+l*c)},getAtan2:(t,e)=>ut(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s,r){const o=wt(t,e);return r&&(t=e),s||(e={}),e.x=t.x+lt(o)*i,e.y=t.y+ht(o)*i,e},toNumberPoints(t){let e=t;return w(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e,i)=>i?t.x===e.x&&t.y===e.y:ot(t.x)===ot(e.x)&&ot(t.y)===ot(e.y),reset(t){ft.reset(t)}},ft=_t,{getDistanceFrom:mt,copy:yt,setRadius:vt,getAtan2:wt}=ft,xt=class t{constructor(t,e){this.set(t,e)}set(t,e){return w(t)?_t.copy(this,t):_t.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new t(this)}move(t,e){return _t.move(this,t,e),this}scale(t,e){return _t.scale(this,t,e),this}scaleOf(t,e,i){return _t.scaleOf(this,t,e,i),this}rotate(t,e){return _t.rotate(this,t,e),this}rotateOf(t,e){return _t.rotate(this,e,t),this}getRotation(t,e,i){return _t.getRotation(this,t,e,i)}toInnerOf(t,e){return _t.toInnerOf(this,t,e),this}toOuterOf(t,e){return _t.toOuterOf(this,t,e),this}getCenter(e){return new t(_t.getCenter(this,e))}getDistance(t){return _t.getDistance(this,t)}getDistancePoint(e,i,s,r){return new t(_t.getDistancePoint(this,e,i,s,r))}getAngle(t){return _t.getAngle(this,t)}getAtan2(t){return _t.getAtan2(this,t)}isSame(t,e){return _t.isSame(this,t,e)}reset(){return _t.reset(this),this}},bt=(new xt,class t{constructor(t,e,i,s,r,o){this.set(t,e,i,s,r,o)}set(t,e,i,s,r,o){return w(t)?st.copy(this,t):st.set(this,t,e,i,s,r,o),this}setWith(t){return st.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:r,f:o}=this;return{a:t,b:e,c:i,d:s,e:r,f:o}}clone(){return new t(this)}translate(t,e){return st.translate(this,t,e),this}translateInner(t,e){return st.translateInner(this,t,e),this}scale(t,e){return st.scale(this,t,e),this}scaleWith(t,e){return st.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return st.pixelScale(this,t),this}scaleOfOuter(t,e,i){return st.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return st.scaleOfInner(this,t,e,i),this}rotate(t){return st.rotate(this,t),this}rotateOfOuter(t,e){return st.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return st.rotateOfInner(this,t,e),this}skew(t,e){return st.skew(this,t,e),this}skewOfOuter(t,e,i){return st.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return st.skewOfInner(this,t,e,i),this}multiply(t){return st.multiply(this,t),this}multiplyParent(t){return st.multiplyParent(this,t),this}divide(t){return st.divide(this,t),this}divideParent(t){return st.divideParent(this,t),this}invert(){return st.invert(this),this}invertWith(){return st.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){st.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){st.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return st.setLayout(this,t,e,i),this}getLayout(t,e,i){return st.getLayout(this,t,e,i)}withScale(t,e){return st.withScale(this,t,e)}reset(){st.reset(this)}}),kt=(new bt,{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,r){Et(t,e,i),Et(t,e+s,i+r)},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:Et}=kt;(function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"})(et||(et={})),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"}(it||(it={}));var St=[{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}];St.forEach(t=>t.type="percent");var Bt={directionData:St,tempPoint:{},get:Tt,toPoint(t,e,i,s,r,o){const n=Tt(t);i.x=n.x,i.y=n.y,"percent"===n.type&&(i.x*=e.width,i.y*=e.height,r&&(o||(i.x-=r.x,i.y-=r.y),n.x&&(i.x-=1===n.x?r.width:.5===n.x?n.x*r.width:0),n.y&&(i.y-=1===n.y?r.height:.5===n.y?n.y*r.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i,s=!0)=>(i||(i={}),Bt.toPoint(t,e,i,s),i)};function Tt(t){return f(t)?St[it[t]]:t}var Ct,Ot,Rt,Pt,{toPoint:Lt}=Bt,Mt={toPoint(t,e,i,s,r,o){Lt(t,i,s,r,e,o)}},{tempPointBounds:Dt,setPoint:At,addPoint:It,toBounds:Wt}=kt,{toOuterPoint:zt}=st,{float:Ft,fourNumber:Yt}=X,{floor:Nt,ceil:Xt}=Math,Ht={},Vt={},Ut={},jt={tempBounds:Ut,set(t,e=0,i=0,s=0,r=0){t.x=e,t.y=i,t.width=s,t.height=r},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,r){const{x:o,y:n,width:a,height:h}=e;if(v(i)){const e=Yt(i);s?Gt.set(t,o+e[3],n+e[0],a-e[1]-e[3],h-e[2]-e[0]):Gt.set(t,o-e[3],n-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Gt.set(t,o-i,n-i,a+2*i,h+2*i);r&&("width"===r?(t.y=n,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},scroll(t,e){t.x+=e.scrollX,t.y+=e.scrollY},getByMove:(t,e,i)=>(t=Object.assign({},t),Gt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Zt(e,t):e=t,i||(i=t),e.offsetX=Gt.maxX(i),e.offsetY=Gt.maxY(i),Gt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||_t.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){_t.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Gt.copy(Ut,t),Gt.toOuterOf(Ut,e),Ut),getOuterOf:(t,e)=>(t=Object.assign({},t),Gt.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:r,e:o,f:n}=e;s>0?(i.width=t.width*s,i.x=o+t.x*s):(i.width=t.width*-s,i.x=o+t.x*s-i.width),r>0?(i.height=t.height*r,i.y=n+t.y*r):(i.height=t.height*-r,i.y=n+t.y*r-i.height)}else Ht.x=t.x,Ht.y=t.y,zt(e,Ht,Vt),At(Dt,Vt.x,Vt.y),Ht.x=t.x+t.width,zt(e,Ht,Vt),It(Dt,Vt.x,Vt.y),Ht.y=t.y+t.height,zt(e,Ht,Vt),It(Dt,Vt.x,Vt.y),Ht.x=t.x,zt(e,Ht,Vt),It(Dt,Vt.x,Vt.y),Wt(Dt,i)},toInnerOf(t,e,i){i||(i=t),Gt.move(i,-e.e,-e.f),Gt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Gt.getFitScale(t,e));return new bt(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,r=t.height/e.height;return i?Math.max(s,r):Math.min(s,r)},put(t,e,i="center",s=1,r=!0,o){o||(o=e),f(s)&&(s=Gt.getFitScale(t,e,"cover"===s)),Ut.width=r?e.width*=s:e.width*s,Ut.height=r?e.height*=s:e.height*s,Mt.toPoint(i,Ut,t,o,!0,!0)},getSpread(t,e,i){const s={};return Gt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Gt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Gt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=Nt(t.x),t.y=Nt(t.y),t.width=e>t.x?Xt(t.width+e-t.x):Xt(t.width),t.height=i>t.y?Xt(t.height+i-t.y):Xt(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=Ft(t.x,e),t.y=Ft(t.y,e),t.width=Ft(t.width,e),t.height=Ft(t.height,e)},add(t,e,i){Ct=t.x+t.width,Ot=t.y+t.height,Rt=e.x,Pt=e.y,i||(Rt+=e.width,Pt+=e.height),Ct=Ct>Rt?Ct:Rt,Ot=Ot>Pt?Ot:Pt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=Ct-t.x,t.height=Ot-t.y},addList(t,e){Gt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Gt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Gt.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let r,o=!0;for(let n=0,a=e.length;n<a;n++)r=i?i(e[n],n):e[n],r&&(r.width||r.height)&&(o?(o=!1,s||Zt(t,r)):Kt(t,r));o&&Gt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?At(Dt,t.x,t.y):It(Dt,t.x,t.y)),Wt(Dt,t)},setPoint(t,e){Gt.set(t,e.x,e.y)},addPoint(t,e){Kt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:r}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+r},{x:e,y:i+r}]},getPoint:(t,e,i=!1,s)=>Bt.getPoint(e,t,s,i),hitRadiusPoint:(t,e,i)=>(i&&(e=_t.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=_t.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=Gt.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=Gt.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=Gt.tempToOuterOf(e,i)),!Gt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:r,width:o,height:n}=e;return Ct=s+o,Ot=r+n,Rt=t.x+t.width,Pt=t.y+t.height,s=s>t.x?s:t.x,r=r>t.y?r:t.y,o=(Ct=Ct<Rt?Ct:Rt)-s,n=(Ot=Ot<Pt?Ot:Pt)-r,{x:s,y:r,width:o,height:n}},intersect(t,e,i){Gt.copy(t,Gt.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,hasSize:t=>t.width&&t.height,reset(t){Gt.set(t)}},Gt=jt,{add:Kt,copy:Zt}=Gt,qt=class t{get minX(){return jt.minX(this)}get minY(){return jt.minY(this)}get maxX(){return jt.maxX(this)}get maxY(){return jt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return w(t)?jt.copy(this,t):jt.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 t(this)}move(t,e){return jt.move(this,t,e),this}scale(t,e,i){return jt.scale(this,t,e,i),this}scaleOf(t,e,i){return jt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return jt.toOuterOf(this,t,e),this}toInnerOf(t,e){return jt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return jt.getFitMatrix(this,t,e)}put(t,e,i){jt.put(this,t,e,i)}spread(t,e){return jt.spread(this,t,e),this}shrink(t,e){return jt.shrink(this,t,e),this}ceil(){return jt.ceil(this),this}unsign(){return jt.unsign(this),this}float(t){return jt.float(this,t),this}add(t){return jt.add(this,t),this}addList(t){return jt.setList(this,t,!0),this}setList(t){return jt.setList(this,t),this}addListWithFn(t,e){return jt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return jt.setListWithFn(this,t,e),this}setPoint(t){return jt.setPoint(this,t),this}setPoints(t){return jt.setPoints(this,t),this}addPoint(t){return jt.addPoint(this,t),this}getPoints(){return jt.getPoints(this)}getPoint(t,e,i){return jt.getPoint(this,t,e,i)}hitPoint(t,e){return jt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return jt.hitRadiusPoint(this,t,e)}hit(t,e){return jt.hit(this,t,e)}includes(t,e){return jt.includes(this,t,e)}intersect(t,e){return jt.intersect(this,t,e),this}getIntersect(e,i){return new t(jt.getIntersectData(this,e,i))}isSame(t){return jt.isSame(this,t)}isEmpty(){return jt.isEmpty(this)}reset(){jt.reset(this)}},$t=new qt,Jt=class{constructor(t,e,i,s,r,o){w(t)?this.copy(t):this.set(t,e,i,s,r,o)}set(t=0,e=0,i=0,s=0,r=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=r,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:r,width:o,height:n}=t;this.set(e,i,s,r,o,n)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:r,width:o,height:n}=this;return new qt(r,e,o||t.width-r-i,n||t.height-e-s)}},Qt={number:(t,e)=>w(t)?"percent"===t.type?t.value*e:t.value:t},te={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},{floor:ee,max:ie}=Math,se={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",isLarge:(t,e,i,s)=>t.width*t.height*(e?e*i:1)>(s||re.maxCacheSize),isSuperLarge:(t,e,i)=>re.isLarge(t,e,i,re.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=re;return!i||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+i),e&&"/"===t[0]&&(t=e+t),t},resize(t,e,i,s,r,o,n,a,h,l){const d=ie(ee(e+(s||0)),1),c=ie(ee(i+(r||0)),1);let u,p,g;l&&(g=Qt.number(l.offset,"x"===l.type?e:i))&&("x"===l.type?u=!0:p=!0);const _=se.origin.createCanvas(p?2*d:d,u?2*c:c),f=_.getContext("2d");if(a&&(f.globalAlpha=a),f.imageSmoothingEnabled=!1!==n,re.canUse(t)){if(o){const s=e/o.width,r=i/o.height;f.setTransform(s,0,0,r,-o.x*s,-o.y*r),f.drawImage(t,0,0,t.width,t.height)}else f.drawImage(t,0,0,e,i);g&&(f.drawImage(_,0,0,d,c,u?g-d:d,u?c:g-c,d,c),f.drawImage(_,0,0,d,c,u?g:d,u?c:g,d,c))}return _},canUse:t=>t&&t.width&&!t.__closed,setPatternTransform(t,e,i){try{e&&t.setTransform&&(t.setTransform(e),e=void 0)}catch(t){}i&&E.stintSet(i,"transform",e)}}},{image:re}=se,{randColor:oe}=X,ne=class t{constructor(t){this.repeatMap={},this.name=t}static get(e){return new t(e)}static set filter(t){this.filterList=ae(t)}static set exclude(t){this.excludeList=ae(t)}static drawRepaint(t,e){const i=oe();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(e,i,s){const r="hit"===t.showBounds,o=e.__nowWorld,n=oe();r&&(i.setWorld(o),e.__drawHitPath(i),i.fillStyle=n.replace("1)",".2)"),i.fill()),i.resetTransform(),i.setStroke(n,2),r?i.stroke():i.strokeWorld(o,n)}log(...t){if(he.enable){if(he.filterList.length&&he.filterList.every(t=>t!==this.name))return;if(he.excludeList.length&&he.excludeList.some(t=>t===this.name))return}}tip(...t){he.enable&&this.warn(...t)}warn(...t){he.showWarn}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(p){}}};function ae(t){return t?f(t)&&(t=[t]):t=[],t}ne.filterList=[],ne.excludeList=[],ne.showWarn=!0;var he=ne,le=ne.get("RunTime"),de={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=T.create(T.RUNTIME);return ce.currentId=ce.idMap[i]=e?performance.now():Date.now(),ce.currentName=ce.nameMap[i]=t,ce.nameToIdMap[t]=i,i},end(t,e){const i=ce.idMap[t],s=ce.nameMap[t],r=e?(performance.now()-i)/1e3:Date.now()-i;ce.idMap[t]=ce.nameMap[t]=ce.nameToIdMap[s]=void 0,le.log(s,r,"ms")},endOfName(t,e){const i=ce.nameToIdMap[t];g(i)||ce.end(i,e)}},ce=de,ue=[],pe={list:{},add(t,...e){this.list[t]=!0,ue.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){}};setTimeout(()=>ue.forEach(t=>pe.has(t,!0)));var ge={editor:t=>pe.need("editor")},_e=ne.get("UICreator"),fe={list:{},register(t){const{__tag:e}=t.prototype;me[e]&&_e.repeat(e),me[e]=t},get(t,e,i,s,r,o){if(!me[t])return void _e.warn("not register "+t);const n=new me[t](e);return g(i)||(n.x=i,s&&(n.y=s),r&&(n.width=r),o&&(n.height=o)),n}},{list:me}=fe,ye=ne.get("EventCreator"),ve={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],f(e)&&(we[e]&&ye.repeat(e),we[e]=t)})},changeName(t,e){const i=we[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,we[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new we[t](...e)},{nameList:we}=ve,xe=class{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let r=0,o=i.length;r<o;r++)if(e=i[r],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const s=ge.canvas(t);return this.add(s),s}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()}};function be(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}function ke(t,e,i,s){return new(i||(i=Promise))(function(r,o){function n(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?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,a)}h((s=s.apply(t,e||[])).next())})}function Ee(t){return(e,i)=>{t||(t=i);const s={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===i&&(s.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,i,s)}}var Se=[];function Be(){return(t,e)=>{Se.push(e)}}var Te=[],Ce=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||Te)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Se.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,r,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,r,o){w(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,r,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,r,o,n,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/r*h;r+=i,i=0,n+=t,h-=t}this.context.drawImage(t,e,i,s,r,o,n,a,h);break;case 5:this.context.drawImage(t,e,i,s,r);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,r,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,r,o){}arcTo(t,e,i,s,r){}ellipse(t,e,i,s,r,o,n,a){}rect(t,e,i,s){}roundRect(t,e,i,s,r){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,r,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}};be([Ee("imageSmoothingEnabled")],Ce.prototype,"smooth",void 0),be([Ee("imageSmoothingQuality")],Ce.prototype,"smoothLevel",void 0),be([Ee("globalAlpha")],Ce.prototype,"opacity",void 0),be([Ee()],Ce.prototype,"fillStyle",void 0),be([Ee()],Ce.prototype,"strokeStyle",void 0),be([Ee("lineWidth")],Ce.prototype,"strokeWidth",void 0),be([Ee("lineCap")],Ce.prototype,"strokeCap",void 0),be([Ee("lineJoin")],Ce.prototype,"strokeJoin",void 0),be([Ee("lineDashOffset")],Ce.prototype,"dashOffset",void 0),be([Ee()],Ce.prototype,"miterLimit",void 0),be([Ee()],Ce.prototype,"shadowBlur",void 0),be([Ee()],Ce.prototype,"shadowColor",void 0),be([Ee()],Ce.prototype,"shadowOffsetX",void 0),be([Ee()],Ce.prototype,"shadowOffsetY",void 0),be([Ee()],Ce.prototype,"filter",void 0),be([Ee()],Ce.prototype,"font",void 0),be([Ee()],Ce.prototype,"fontKerning",void 0),be([Ee()],Ce.prototype,"fontStretch",void 0),be([Ee()],Ce.prototype,"fontVariantCaps",void 0),be([Ee()],Ce.prototype,"textAlign",void 0),be([Ee()],Ce.prototype,"textBaseline",void 0),be([Ee()],Ce.prototype,"textRendering",void 0),be([Ee()],Ce.prototype,"wordSpacing",void 0),be([Ee()],Ce.prototype,"letterSpacing",void 0),be([Ee()],Ce.prototype,"direction",void 0),be([Be()],Ce.prototype,"setTransform",null),be([Be()],Ce.prototype,"resetTransform",null),be([Be()],Ce.prototype,"getTransform",null),be([Be()],Ce.prototype,"save",null),be([Be()],Ce.prototype,"restore",null),be([Be()],Ce.prototype,"translate",null),be([Be()],Ce.prototype,"scale",null),be([Be()],Ce.prototype,"rotate",null),be([Be()],Ce.prototype,"fill",null),be([Be()],Ce.prototype,"stroke",null),be([Be()],Ce.prototype,"clip",null),be([Be()],Ce.prototype,"fillRect",null),be([Be()],Ce.prototype,"strokeRect",null),be([Be()],Ce.prototype,"clearRect",null),be([Be()],Ce.prototype,"beginPath",null),be([Be()],Ce.prototype,"moveTo",null),be([Be()],Ce.prototype,"lineTo",null),be([Be()],Ce.prototype,"bezierCurveTo",null),be([Be()],Ce.prototype,"quadraticCurveTo",null),be([Be()],Ce.prototype,"closePath",null),be([Be()],Ce.prototype,"arc",null),be([Be()],Ce.prototype,"arcTo",null),be([Be()],Ce.prototype,"ellipse",null),be([Be()],Ce.prototype,"rect",null),be([Be()],Ce.prototype,"roundRect",null),be([Be()],Ce.prototype,"createConicGradient",null),be([Be()],Ce.prototype,"createLinearGradient",null),be([Be()],Ce.prototype,"createPattern",null),be([Be()],Ce.prototype,"createRadialGradient",null),be([Be()],Ce.prototype,"fillText",null),be([Be()],Ce.prototype,"measureText",null),be([Be()],Ce.prototype,"strokeText",null);var{copy:Oe,multiplyParent:Re,pixelScale:Pe}=st,{round:Le}=Math,Me=new qt,De=new qt,Ae={width:1,height:1,pixelRatio:1},Ie=["width","height","pixelRatio"],We=class extends Ce{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||0}get pixelHeight(){return this.height*this.pixelRatio||0}get pixelSnap(){return this.config.pixelSnap}set pixelSnap(t){this.config.pixelSnap=t}get allowBackgroundColor(){return this.view&&this.parentView}constructor(t,e){super(),this.size={},this.worldTransform={},t||(t=Ae),this.manager=e,this.innerId=T.create(T.CNAVAS);const{width:i,height:s,pixelRatio:r}=t;this.autoLayout=!i||!s,this.size.pixelRatio=r||se.devicePixelRatio,this.config=t,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;E.copyAttrs(s,t,Ie),Ie.forEach(t=>s[t]||(s[t]=1)),this.bounds=new qt(0,0,this.width,this.height),this.updateViewSize(),this.updateClientBounds(),this.context&&(this.smooth=this.config.smooth,!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,pixelSnap:s}=this,r=this.worldTransform;e&&Re(t,e,r),Pe(t,i,r),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(r.e=Le(r.e-.5)+.5,r.f=Le(r.f-.5)+.5):(r.e=Le(r.e),r.f=Le(r.f))),this.setTransform(r.a,r.b,r.c,r.d,r.e,r.f)}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,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i,s)}setStrokeOptions(t,e){let{strokeCap:i,strokeJoin:s,dashPattern:r,dashOffset:o,miterLimit:n}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),g(e.dashPattern)||(r=e.dashPattern),g(e.dashOffset)||(o=e.dashOffset),e.miterLimit&&(n=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=r,this.dashOffset=o,this.miterLimit=n}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:r}=this;this.shadowOffsetX=t*r,this.shadowOffsetY=e*r,this.shadowBlur=i*r,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,r){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,r),i?(this.setTempPixelBounds2(i,r),i=De):i=Me,this.drawImage(t.view,Me.x,Me.y,Me.width,Me.height,i.x,i.y,i.width,i.height)):this.drawImage(t.view,0,0),s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s,r){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,jt.tempToOuterOf(i,e),s,r),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,r),this.drawImage(t.view,Me.x,Me.y,Me.width,Me.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,r,o){this.resetTransform(),this.copyWorld(t,e,i,s,o),r||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,r=s.getImageData(Me.x,Me.y,Me.width,Me.height),{data:o}=r;for(let n=0,a=o.length;n<a;n+=4)i=.299*o[n]+.587*o[n+1]+.114*o[n+2],(e=o[n+3])&&(o[n+3]=255===e?i:e*(i/255));s.putImageData(r,Me.x,Me.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,s){i&&(this.blendMode=i),this.fillStyle=e,this.setTempPixelBounds(t,s),this.fillRect(Me.x,Me.y,Me.width,Me.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Me.x,Me.y,Me.width,Me.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Me.x,Me.y,Me.width,Me.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Me.x,Me.y,Me.width,Me.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Me,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(De,t,e,i)}copyToPixelBounds(t,e,i,s){t.set(e),s&&t.intersect(this.bounds),t.scale(this.pixelRatio),i&&t.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:i,pixelSnap:s}=this,r=this.manager?this.manager.get(i):ge.canvas(Object.assign({},i));return r.save(),t&&(Oe(r.worldTransform,this.worldTransform),r.useWorldTransform()),e&&(r.smooth=this.smooth),r.pixelSnap!==s&&(r.pixelSnap=s),r}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}},ze={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Fe={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Ye=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},Fe),Ne={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},Xe={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},He=Object.assign(Object.assign({},Xe),Fe),Ve=Ye,Ue={};for(let Qf in Ve)Ue[Ve[Qf]]=Qf;var je={};for(let Qf in Ve)je[Ve[Qf]]=Ne[Qf];var Ge,Ke,Ze,qe={drawRoundRect(t,e,i,s,r,o){const n=X.fourNumber(o,Math.min(s/2,r/2)),a=e+s,h=i+r;n[0]?t.moveTo(e+n[0],i):t.moveTo(e,i),n[1]?t.arcTo(a,i,a,h,n[1]):t.lineTo(a,i),n[2]?t.arcTo(a,h,e,h,n[2]):t.lineTo(a,h),n[3]?t.arcTo(e,h,e,i,n[3]):t.lineTo(e,h),n[0]?t.arcTo(e,i,a,i,n[0]):t.lineTo(e,i)}},{sin:$e,cos:Je,hypot:Qe,atan2:ti,ceil:ei,abs:ii,PI:si,sqrt:ri,pow:oi}=Math,{setPoint:ni,addPoint:ai}=kt,{set:hi,toNumberPoints:li}=_t,{M:di,L:ci,C:ui,Q:pi,Z:gi}=Ye,_i={},fi={points(t,e,i,s){let r=li(e);if(t.push(di,r[0],r[1]),i&&r.length>5){let e,o,n,a,h,l,d,c,u,p,g,_,f,m,y,v=r.length;const w=!0===i?.5:i;s&&(r=[r[v-2],r[v-1],...r,r[0],r[1],r[2],r[3]],v=r.length);for(let i=2;i<v-2;i+=2)e=r[i-2],o=r[i-1],n=r[i],a=r[i+1],h=r[i+2],l=r[i+3],g=n-e,_=a-o,f=ri(oi(g,2)+oi(_,2)),m=ri(oi(h-n,2)+oi(l-a,2)),(f||m)&&(y=f+m,f=w*f/y,m=w*m/y,h-=e,l-=o,d=n-f*h,c=a-f*l,2===i?s||t.push(pi,d,c,n,a):(g||_)&&t.push(ui,u,p,d,c,n,a),u=n+m*h,p=a+m*l);s||t.push(pi,u,p,r[v-2],r[v-1])}else for(let o=2,n=r.length;o<n;o+=2)t.push(ci,r[o],r[o+1]);s&&t.push(gi)},rect(t,e,i,s,r){ze.creator.path=t,ze.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+r).lineTo(e,i+r).lineTo(e,i)},roundRect(t,e,i,s,r,o){ze.creator.path=[],qe.drawRoundRect(ze.creator,e,i,s,r,o),t.push(...ze.convertToCanvasData(ze.creator.path,!0))},arcTo(t,e,i,s,r,o,n,a,h,l,d){const c=s-e,u=r-i,p=o-s,g=n-r;let _=ti(u,c),f=ti(g,p);const m=Qe(c,u),y=Qe(p,g);let v=f-_;if(v<0&&(v+=U),m<1e-12||y<1e-12||v<1e-12||ii(v-si)<1e-12)return t&&t.push(ci,s,r),h&&(ni(h,e,i),ai(h,s,r)),d&&hi(d,e,i),void(l&&hi(l,s,r));const w=c*g-p*u<0,x=w?-1:1,b=a/Je(v/2),k=s+b*Je(_+v/2+j*x),E=r+b*$e(_+v/2+j*x);return _-=j*x,f-=j*x,vi(t,k,E,a,a,0,_/V,f/V,w,h,l,d)},arc:(t,e,i,s,r,o,n,a,h,l)=>vi(t,e,i,s,s,0,r,o,n,a,h,l),ellipse(t,e,i,s,r,o,n,a,h,l,d,c){const u=o*V,p=$e(u),g=Je(u);let _=n*V,f=a*V;_>si&&(_-=U),f<0&&(f+=U);let m=f-_;m<0?m+=U:m>U&&(m-=U),h&&(m-=U);const y=ei(ii(m/j)),v=m/y,w=$e(v/4),x=8/3*w*w/$e(v/2);f=_+v;let b,k,E,S,B,T,C,O,R=Je(_),P=$e(_),L=E=g*s*R-p*r*P,M=S=p*s*R+g*r*P,D=e+E,A=i+S;t&&t.push(t.length?ci:di,D,A),l&&ni(l,D,A),c&&hi(c,D,A);for(let I=0;I<y;I++)b=Je(f),k=$e(f),E=g*s*b-p*r*k,S=p*s*b+g*r*k,B=e+L-x*(g*s*P+p*r*R),T=i+M-x*(p*s*P-g*r*R),C=e+E+x*(g*s*k+p*r*b),O=i+S+x*(p*s*k-g*r*b),t&&t.push(ui,B,T,C,O,e+E,i+S),l&&yi(e+L,i+M,B,T,C,O,e+E,i+S,l,!0),L=E,M=S,R=b,P=k,_=f,f+=v;d&&hi(d,e+E,i+S)},quadraticCurveTo(t,e,i,s,r,o,n){t.push(ui,(e+2*s)/3,(i+2*r)/3,(o+2*s)/3,(n+2*r)/3,o,n)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,r,o,n,a){yi(t,e,(t+2*i)/3,(e+2*s)/3,(r+2*i)/3,(o+2*s)/3,r,o,n,a)},toTwoPointBounds(t,e,i,s,r,o,n,a,h,l){const d=[];let c,u,p,g,_,f,m,y,v=t,w=i,x=r,b=n;for(let k=0;k<2;++k)if(1==k&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,p=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-p/u,0<g&&g<1&&d.push(g)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(_=(-u+y)/(2*c),0<_&&_<1&&d.push(_),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?ai(h,t,e):ni(h,t,e),ai(h,n,a);for(let k=0,E=d.length;k<E;k++)mi(d[k],t,e,i,s,r,o,n,a,_i),ai(h,_i.x,_i.y)},getPointAndSet(t,e,i,s,r,o,n,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,g=t*t*t;l.x=c*e+u*s+p*o+g*a,l.y=c*i+u*r+p*n+g*h},getPoint(t,e,i,s,r,o,n,a,h){const l={};return mi(t,e,i,s,r,o,n,a,h,l),l},getDerivative(t,e,i,s,r){const o=1-t;return 3*o*o*(i-e)+6*o*t*(s-i)+3*t*t*(r-s)},cut(t,e,i,s,r,o,n,a,h){if(t<=0)return{left:null,right:[s,r,o,n,a,h]};if(t>=1)return{left:[s,r,o,n,a,h],right:null};const l=1-t,d=e*l+s*t,c=i*l+r*t,u=s*l+o*t,p=r*l+n*t,g=o*l+a*t,_=n*l+h*t,f=d*l+u*t,m=c*l+p*t,y=u*l+g*t,v=p*l+_*t;return{left:[d,c,f,m,f*l+y*t,m*l+v*t],right:[y,v,g,_,a,h]}}},{getPointAndSet:mi,toTwoPointBounds:yi,ellipse:vi}=fi,{sin:wi,cos:xi,sqrt:bi,atan2:ki}=Math,{ellipse:Ei}=fi,Si={ellipticalArc(t,e,i,s,r,o,n,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,p=o*V,g=wi(p),_=xi(p),f=-_*c-g*u,m=-_*u+g*c,y=s*s,v=r*r,w=m*m,x=f*f,b=y*v-y*w-v*x;let k=0;if(b<0){const t=bi(1-b/(y*v));s*=t,r*=t}else k=(n===a?-1:1)*bi(b/(y*w+v*x));const E=k*s*m/r,S=-k*r*f/s,B=ki((m-S)/r,(f-E)/s),T=ki((-m-S)/r,(-f-E)/s);let C=T-B;0===a&&C>0?C-=U:1===a&&C<0&&(C+=U);const O=e+c+_*E-g*S,R=i+u+g*E+_*S,P=C<0?1:0;d||se.ellipseToCurve?Ei(t,O,R,s,r,o,B/V,T/V,P):s!==r||o?t.push(Ye.G,O,R,s,r,o,B/V,T/V,P):t.push(Ye.O,O,R,s,B/V,T/V,P)}},Bi=t=>[],{M:Ti,m:Ci,L:Oi,l:Ri,H:Pi,h:Li,V:Mi,v:Di,C:Ai,c:Ii,S:Wi,s:zi,Q:Fi,q:Yi,T:Ni,t:Xi,A:Hi,a:Vi,Z:Ui,z:ji,N:Gi,D:Ki,X:Zi,G:qi,F:$i,O:Ji,P:Qi,U:ts}=Ye,{rect:es,roundRect:is,arcTo:ss,arc:rs,ellipse:os,quadraticCurveTo:ns}=fi,{ellipticalArc:as}=Si,hs=ne.get("PathConvert"),ls={},ds={current:{dot:0},stringify(t,e){let i,s,r,o=0,n=t.length,a="";for(;o<n;){s=t[o],i=je[s],a+=s===r?" ":Ue[s];for(let s=1;s<i;s++)a+=X.float(t[o+s],e),s===i-1||(a+=" ");r=s,o+=i}return a},parse(t,e){let i,s,r,o="";const n=[],a=e?He:Xe;for(let h=0,l=t.length;h<l;h++)s=t[h],te[s]?("."===s&&(cs.dot&&(us(n,o),o=""),cs.dot++),"0"===o&&"."!==s&&(us(n,o),o=""),o+=s):Ye[s]?(o&&(us(n,o),o=""),cs.name=Ye[s],cs.length=Ne[s],cs.index=0,us(n,cs.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===r||"E"===r?o+=s:(o&&us(n,o),o=s):o&&(us(n,o),o=""),r=s;return o&&us(n,o),i?ds.toCanvasData(n,e):n},toCanvasData(t,e){let i,s,r,o,n,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(r=t[c],r){case Ci:t[c+1]+=a,t[c+2]+=h;case Ti:a=t[c+1],h=t[c+2],p.push(Ti,a,h),c+=3;break;case Li:t[c+1]+=a;case Pi:a=t[c+1],p.push(Oi,a,h),c+=2;break;case Di:t[c+1]+=h;case Mi:h=t[c+1],p.push(Oi,a,h),c+=2;break;case Ri:t[c+1]+=a,t[c+2]+=h;case Oi:a=t[c+1],h=t[c+2],p.push(Oi,a,h),c+=3;break;case zi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,r=Wi;case Wi:n=o===Ai||o===Wi,l=n?2*a-i:t[c+1],d=n?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],p.push(Ai,l,d,i,s,a,h),c+=5;break;case Ii:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,r=Ai;case Ai:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],p.push(Ai,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Xi:t[c+1]+=a,t[c+2]+=h,r=Ni;case Ni:n=o===Fi||o===Ni,i=n?2*a-i:t[c+1],s=n?2*h-s:t[c+2],e?ns(p,a,h,i,s,t[c+1],t[c+2]):p.push(Fi,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Yi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,r=Fi;case Fi:i=t[c+1],s=t[c+2],e?ns(p,a,h,i,s,t[c+3],t[c+4]):p.push(Fi,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Vi:t[c+6]+=a,t[c+7]+=h;case Hi:as(p,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 ji:case Ui:p.push(Ui),c++;break;case Gi:a=t[c+1],h=t[c+2],e?es(p,a,h,t[c+3],t[c+4]):ps(p,t,c,5),c+=5;break;case Ki:a=t[c+1],h=t[c+2],e?is(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):ps(p,t,c,9),c+=9;break;case Zi:a=t[c+1],h=t[c+2],e?is(p,a,h,t[c+3],t[c+4],t[c+5]):ps(p,t,c,6),c+=6;break;case qi:os(e?p:ps(p,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,ls),a=ls.x,h=ls.y,c+=9;break;case $i:e?os(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):ps(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Ji:rs(e?p:ps(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,ls),a=ls.x,h=ls.y,c+=7;break;case Qi:e?rs(p,t[c+1],t[c+2],t[c+3],0,360,!1):ps(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case ts:ss(e?p:ps(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,ls),a=ls.x,h=ls.y,c+=6;break;default:return hs.error(`command: ${r} [index:${c}]`,t),p}o=r}return p},objectToCanvasData(t){if(t[0].name.length>1)return Bi(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(Ti,t.x,t.y);break;case"L":e.push(Oi,t.x,t.y);break;case"C":e.push(Ai,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Fi,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Ui)}}),e}},copyData(t,e,i,s){for(let r=i,o=i+s;r<o;r++)t.push(e[r])},pushData(t,e){cs.index===cs.length&&(cs.index=1,t.push(cs.name)),t.push(Number(e)),cs.index++,cs.dot=0}},{current:cs,pushData:us,copyData:ps}=ds,{M:gs,L:_s,C:fs,Q:ms,Z:ys,N:vs,D:ws,X:xs,G:bs,F:ks,O:Es,P:Ss,U:Bs}=Ye,{getMinDistanceFrom:Ts,getRadianFrom:Cs}=_t,{tan:Os,min:Rs,abs:Ps}=Math,Ls={},Ms={beginPath(t){t.length=0},moveTo(t,e,i){t.push(gs,e,i)},lineTo(t,e,i){t.push(_s,e,i)},bezierCurveTo(t,e,i,s,r,o,n){t.push(fs,e,i,s,r,o,n)},quadraticCurveTo(t,e,i,s,r){t.push(ms,e,i,s,r)},closePath(t){t.push(ys)},rect(t,e,i,s,r){t.push(vs,e,i,s,r)},roundRect(t,e,i,s,r,o){if(y(o))t.push(xs,e,i,s,r,o);else{const n=X.fourNumber(o);n?t.push(ws,e,i,s,r,...n):t.push(vs,e,i,s,r)}},ellipse(t,e,i,s,r,o,n,a,h){if(s===r)return As(t,e,i,s,n,a,h);_(o)?t.push(ks,e,i,s,r):(_(n)&&(n=0),_(a)&&(a=360),t.push(bs,e,i,s,r,o,n,a,h?1:0))},arc(t,e,i,s,r,o,n){_(r)?t.push(Ss,e,i,s):(_(r)&&(r=0),_(o)&&(o=360),t.push(Es,e,i,s,r,o,n?1:0))},arcTo(t,e,i,s,r,o,n,a,h){if(!g(n)){const t=Ts(n,a,e,i,s,r)/(h?1:2);o=Rs(o,Rs(t,t*Ps(Os(Cs(n,a,e,i,s,r)/2))))}t.push(Bs,e,i,s,r,o)},drawEllipse(t,e,i,s,r,o,n,a,h){fi.ellipse(null,e,i,s,r,_(o)?0:o,_(n)?0:n,_(a)?360:a,h,null,null,Ls),t.push(gs,Ls.x,Ls.y),Ds(t,e,i,s,r,o,n,a,h)},drawArc(t,e,i,s,r,o,n){fi.arc(null,e,i,s,_(r)?0:r,_(o)?360:o,n,null,null,Ls),t.push(gs,Ls.x,Ls.y),As(t,e,i,s,r,o,n)},drawPoints(t,e,i,s){fi.points(t,e,i,s)}},{ellipse:Ds,arc:As}=Ms,{moveTo:Is,lineTo:Ws,quadraticCurveTo:zs,bezierCurveTo:Fs,closePath:Ys,beginPath:Ns,rect:Xs,roundRect:Hs,ellipse:Vs,arc:Us,arcTo:js,drawEllipse:Gs,drawArc:Ks,drawPoints:Zs}=Ms,qs=class{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?f(t)?ze.parse(t):t:[],this}beginPath(){return Ns(this.__path),this.paint(),this}moveTo(t,e){return Is(this.__path,t,e),this.paint(),this}lineTo(t,e){return Ws(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,r,o){return Fs(this.__path,t,e,i,s,r,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return zs(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ys(this.__path),this.paint(),this}rect(t,e,i,s){return Xs(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,r){return Hs(this.__path,t,e,i,s,r),this.paint(),this}ellipse(t,e,i,s,r,o,n,a){return Vs(this.__path,t,e,i,s,r,o,n,a),this.paint(),this}arc(t,e,i,s,r,o){return Us(this.__path,t,e,i,s,r,o),this.paint(),this}arcTo(t,e,i,s,r){return js(this.__path,t,e,i,s,r),this.paint(),this}drawEllipse(t,e,i,s,r,o,n,a){return Gs(this.__path,t,e,i,s,r,o,n,a),this.paint(),this}drawArc(t,e,i,s,r,o){return Ks(this.__path,t,e,i,s,r,o),this.paint(),this}drawPoints(t,e,i){return Zs(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}},{M:$s,L:Js,C:Qs,Q:tr,Z:er,N:ir,D:sr,X:rr,G:or,F:nr,O:ar,P:hr,U:lr}=Ye,dr=ne.get("PathDrawer"),cr={drawPathByData(t,e){if(!e)return;let i,s=0,r=e.length;for(;s<r;)switch(i=e[s],i){case $s:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Js:t.lineTo(e[s+1],e[s+2]),s+=3;break;case Qs:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case tr:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case er:t.closePath(),s+=1;break;case ir:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case sr: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 rr:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case or:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*V,e[s+6]*V,e[s+7]*V,e[s+8]),s+=9;break;case nr:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,U,!1),s+=5;break;case ar:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*V,e[s+5]*V,e[s+6]),s+=7;break;case hr:t.arc(e[s+1],e[s+2],e[s+3],0,U,!1),s+=4;break;case lr:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void dr.error(`command: ${i} [index:${s}]`,e)}}},{M:ur,L:pr,C:gr,Q:_r,Z:fr,N:mr,D:yr,X:vr,G:wr,F:xr,O:br,P:kr,U:Er}=Ye,{toTwoPointBounds:Sr,toTwoPointBoundsByQuadraticCurve:Br,arcTo:Tr,arc:Cr,ellipse:Or}=fi,{addPointBounds:Rr,copy:Pr,addPoint:Lr,setPoint:Mr,addBounds:Dr,toBounds:Ar}=kt,Ir=ne.get("PathBounds"),Wr={},zr={},Fr={},Yr={toBounds(t,e){Yr.toTwoPointBounds(t,zr),Ar(zr,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Mr(e,0,0);let i,s,r,o,n,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(n=t[a],0===a&&(n===fr||n===gr||n===_r?Mr(e,h,l):Mr(e,t[a+1],t[a+2])),n){case ur:case pr:h=t[a+1],l=t[a+2],Lr(e,h,l),a+=3;break;case gr:r=t[a+5],o=t[a+6],Sr(h,l,t[a+1],t[a+2],t[a+3],t[a+4],r,o,Wr),Rr(e,Wr),h=r,l=o,a+=7;break;case _r:i=t[a+1],s=t[a+2],r=t[a+3],o=t[a+4],Br(h,l,i,s,r,o,Wr),Rr(e,Wr),h=r,l=o,a+=5;break;case fr:a+=1;break;case mr:h=t[a+1],l=t[a+2],Dr(e,h,l,t[a+3],t[a+4]),a+=5;break;case yr:case vr:h=t[a+1],l=t[a+2],Dr(e,h,l,t[a+3],t[a+4]),a+=n===yr?9:6;break;case wr:Or(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],Wr,Fr),0===a?Pr(e,Wr):Rr(e,Wr),h=Fr.x,l=Fr.y,a+=9;break;case xr:h=t[a+1],l=t[a+2],Ke=t[a+3],Ze=t[a+4],Dr(e,h-Ke,l-Ze,2*Ke,2*Ze),h+=Ke,a+=5;break;case br:Cr(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Wr,Fr),0===a?Pr(e,Wr):Rr(e,Wr),h=Fr.x,l=Fr.y,a+=7;break;case kr:h=t[a+1],l=t[a+2],Ge=t[a+3],Dr(e,h-Ge,l-Ge,2*Ge,2*Ge),h+=Ge,a+=4;break;case Er:Tr(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Wr,Fr),0===a?Pr(e,Wr):Rr(e,Wr),h=Fr.x,l=Fr.y,a+=6;break;default:return void Ir.error(`command: ${n} [index:${a}]`,t)}}},{M:Nr,L:Xr,Z:Hr}=Ye,{getCenterX:Vr,getCenterY:Ur}=_t,{arcTo:jr}=Ms,Gr={smooth(t,e,i){let s,r,o,n=0,a=0,h=0,l=0,d=0,c=0,u=0,p=0,g=0;v(e)&&(e=e[0]||0);const _=t.length,f=9===_,m=[];for(;n<_;){switch(s=t[n],s){case Nr:l=p=t[n+1],d=g=t[n+2],n+=3,t[n]===Xr?(c=t[n+1],u=t[n+2],f?m.push(Nr,l,d):m.push(Nr,Vr(l,c),Ur(d,u))):m.push(Nr,l,d);break;case Xr:switch(a=t[n+1],h=t[n+2],n+=3,t[n]){case Xr:jr(m,a,h,t[n+1],t[n+2],e,p,g,f);break;case Hr:jr(m,a,h,l,d,e,p,g,f);break;default:m.push(Xr,a,h)}p=a,g=h;break;case Hr:r!==Hr&&(jr(m,l,d,c,u,e,p,g,f),m.push(Hr)),n+=1;break;default:o=je[s];for(let e=0;e<o;e++)m.push(t[n+e]);n+=o}r=s}return s!==Hr&&(m[1]=l,m[2]=d),m}};function Kr(t){return new qs(t)}var Zr=Kr();ze.creator=Kr(),ze.parse=ds.parse,ze.convertToCanvasData=ds.toCanvasData;var{drawRoundRect:qr}=qe;function $r(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,r){qr(this,t,e,i,s,r)})}(t)}var Jr={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mimeType:(t,e="image")=>!t||t.startsWith(e)?t:("jpg"===t&&(t="jpeg"),e+"/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=Qr.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{}}}},Qr=Jr;Qr.mineType=Qr.mimeType,Qr.alphaPixelTypes.forEach(t=>Qr.upperCaseTypeMap[t]=t.toUpperCase());var to=ne.get("TaskProcessor"),eo=class{constructor(t){this.parallel=!0,this.time=1,this.id=T.create(T.TASK),this.task=t}run(){return ke(this,void 0,void 0,function*(){try{if(this.isComplete||this.runing)return;if(this.runing=!0,this.canUse&&!this.canUse())return this.cancel();this.task&&(yield this.task())}catch(u){to.error(u)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}},io=class{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&&E.assign(this.config,t),this.empty()}add(t,e,i){let s,r,o,n;const a=new eo(t);return a.parent=this,y(e)?n=e:e&&(r=e.parallel,s=e.start,o=e.time,n=e.delay,i||(i=e.canUse)),o&&(a.time=o),!1===r&&(a.parallel=!1),i&&(a.canUse=i),g(n)?this.push(a,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(a,s))},n)),this.isComplete=!1,a}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.run()}),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++,t.isCancel?this.runTask():this.nextTask()}).catch(t=>{this.onError(t)}):this.timer=setTimeout(()=>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;const{config:e,list:i,index:s}=this;this.parallelList=[],this.parallelSuccessNumber=0;let r=s+e.parallel;if(r>i.length&&(r=i.length),e.parallel>1)for(let o=s;o<r&&(t=i[o],t.parallel);o++)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()}},so=ne.get("Resource"),ro={tasker:new io,queue:new io({parallel:1}),map:{},get isComplete(){return oo.tasker.isComplete},set(t,e){oo.map[t]&&so.repeat(t),oo.map[t]=e},get:t=>oo.map[t],remove(t){const e=oo.map[t];e&&(e.destroy&&e.destroy(),delete oo.map[t])},loadImage(t,e){return new Promise((i,s)=>{const r=this.setImage(t,t,e);r.load(()=>i(r),t=>s(t))})},setImage(t,e,i){let s;return f(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=ge.image(s)),oo.set(t,e),e},loadFilm(t,e){},loadVideo(t,e){},destroy(){oo.map={}}},oo=ro,no={maxRecycled:10,recycledList:[],patternTasker:ro.queue,get(t,e){let i=ro.get(t.url);return i||ro.set(t.url,i="film"===e?ge.film(t):ge.image(t)),i.use++,i},recycle(t){t.parent&&(t=t.parent),t.use--,setTimeout(()=>{t.use||(se.image.isLarge(t)?t.url&&ro.remove(t.url):(t.clearLevels(),ao.recycledList.push(t)))})},recyclePaint(t){ao.recycle(t.image)},clearRecycled(t){const e=ao.recycledList;(e.length>ao.maxRecycled||t)&&(e.forEach(e=>(!e.use||t)&&e.url&&ro.remove(e.url)),e.length=0)},clearLevels(){},hasAlphaPixel:t=>Jr.alphaPixelTypes.some(e=>ao.isFormat(e,t)),isFormat(t,e){if(e.format)return e.format===t;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+Jr.mimeType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Jr.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){this.clearRecycled(!0)}},ao=no,{IMAGE:ho,create:lo}=T,co=class{get tag(){return"Image"}get url(){return this.config.url}get crossOrigin(){const{crossOrigin:t}=this.config;return g(t)?se.image.crossOrigin:t}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=lo(ho),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}no.isFormat("svg",t)&&(this.isSVG=!0),no.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,e,i){return this.loading||(this.loading=!0,ro.tasker.add(()=>ke(this,void 0,void 0,function*(){return yield se.origin["load"+this.tag](this.getLoadUrl(i),this.crossOrigin,this).then(t=>{i&&this.setThumbView(t),this.setView(t)}).catch(t=>{this.error=t,this.onComplete(!1)})}))),this.waitComplete.push(t,e),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||(this.width=t.width,this.height=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(t,e,i,s,r,o,n,a){if(t||(t=this.width),e||(e=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 h=se.image.resize(this.view,t,e,r,o,void 0,n,i,s,a);return this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(t,e,i,s){const r=se.canvas.createPattern(t,e);return se.image.setPatternTransform(r,i,s),r}render(t,e,i,s,r,o,n,a,h){t.drawImage(this.view,e,i,s,r)}getLoadUrl(t){return this.url}setThumbView(t){}getThumbSize(t){}getMinLevel(){}getLevelData(t,e,i){}clearLevels(t){}destroyFilter(){}destroy(){this.clearLevels(),this.destroyFilter();const{view:t}=this;t&&t.close&&t.close(),this.config={url:""},this.cache=this.view=null,this.waitComplete.length=0}};function uo(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function po(t,e){return Object.getOwnPropertyDescriptor(t,e)}function go(t,e){return(i,s)=>function(t,e,i,s){uo(t,e,Object.assign({get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}},s||{})),Mo(t,e,i)}(i,s,t,e&&e(s))}function _o(t){return go(t)}function fo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function mo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function yo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),bo(this))}}))}function vo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function wo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function xo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&bo(this)}}))}function bo(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}var ko=xo;function Eo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i)&&(function(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&bo(t)}(this),e&&(this.__.__useStroke=!0))}}))}var So=Eo;function Bo(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function To(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Co(t){return go(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;E.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip)}}}))}function Oo(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Ro(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||bo(t))}function Po(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,this.leafer&&this.leafer.updateCursor())}}))}function Lo(t){return(e,i)=>{uo(e,"__DataProcessor",{get:()=>t})}}function Mo(t,e,i){const s=t.__DataProcessor.prototype,r="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),n=function(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}(e,i);if(g(i))n.get=function(){return this[r]};else if("function"==typeof i)n.get=function(){const t=this[r];return null==t?i(this.__leaf):t};else if(w(i)){const t=function(t){return"{}"===JSON.stringify(t)}(i);n.get=function(){const e=this[r];return null==e?this[r]=t?{}:E.clone(i):e}}const a=t.isBranchLeaf;"width"===e?n.get=function(){const t=this[r];if(null==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&&(n.get=function(){const t=this[r];if(null==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=po(l,e),l=l.__proto__;h&&h.set&&(n.set=h.set),s[o]&&(n.set=s[o],delete s[o]),uo(s,e,n)}var Do=new ne("rewrite"),Ao=[],Io=["destroy","constructor"];function Wo(t){return(e,i)=>{Ao.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function zo(){return t=>{Fo()}}function Fo(t){Ao.length&&(Ao.forEach(e=>{t&&Do.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Ao.length=0)}function Yo(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{Io.includes(s)||e&&e.includes(s)||(t.prototype?po(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s]):i.prototype[s]=t[s])})}}function No(){return t=>{fe.register(t)}}function Xo(){return t=>{ve.register(t)}}setTimeout(()=>Fo(!0));var{copy:Ho,toInnerPoint:Vo,toOuterPoint:Uo,scaleOfOuter:jo,rotateOfOuter:Go,skewOfOuter:Ko,multiplyParent:Zo,divideParent:qo,getLayout:$o}=st,Jo={},{round:Qo}=Math,tn={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),rn(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,r=s.length;t<r;t++)sn(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++)on(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&on(t),t.__updateChange(),e.surfaceChanged&&(t.__hasComplex&&en.updateComplex(t),e.surfaceChanged=!1)},updateAllChange(t){if(an(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)nn(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},draggable:t=>(t.draggable||t.editable)&&t.hitSelf&&!t.locked,copyCanvasByWorld(t,e,i,s,r,o){s||(s=t.__nowWorld),t.__worldFlipped||se.fullImageShadow?e.copyWorldByReset(i,s,t.__nowWorld,r,o):e.copyWorldToInner(i,s,t.__layout.renderBounds,r)},renderComplex(t,e,i){},updateComplex(t){},checkComplex(t){},moveWorld(t,e,i=0,s,r){const o=w(e)?Object.assign({},e):{x:e,y:i};s?Uo(t.localTransform,o,o,!0):t.parent&&Vo(t.parent.scrollWorldTransform,o,o,!0),en.moveLocal(t,o.x,o.y,r)},moveLocal(t,e,i=0,s){w(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=Qo(e),i=Qo(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,r,o){en.zoomOfLocal(t,hn(t,e),i,s,r,o)},zoomOfLocal(t,e,i,s=i,r,o){const n=t.__localMatrix;if(y(s)||(s&&(o=s),s=i),Ho(Jo,n),jo(Jo,e,i,s),en.hasHighPosition(t))en.setTransform(t,Jo,r,o);else{const e=t.x+Jo.e-n.e,a=t.y+Jo.f-n.f;o&&!r?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!==r))}},rotateOfWorld(t,e,i,s){en.rotateOfLocal(t,hn(t,e),i,s)},rotateOfLocal(t,e,i,s){const r=t.__localMatrix;Ho(Jo,r),Go(Jo,e,i),en.hasHighPosition(t)?en.setTransform(t,Jo,!1,s):t.set({x:t.x+Jo.e-r.e,y:t.y+Jo.f-r.f,rotation:X.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,r,o){en.skewOfLocal(t,hn(t,e),i,s,r,o)},skewOfLocal(t,e,i,s=0,r,o){Ho(Jo,t.__localMatrix),Ko(Jo,e,i,s),en.setTransform(t,Jo,r,o)},transformWorld(t,e,i,s){Ho(Jo,t.worldTransform),Zo(Jo,e),t.parent&&qo(Jo,t.parent.scrollWorldTransform),en.setTransform(t,Jo,i,s)},transform(t,e,i,s){Ho(Jo,t.localTransform),Zo(Jo,e),en.setTransform(t,Jo,i,s)},setTransform(t,e,i,s){const r=t.__,o=r.origin&&en.getInnerOrigin(t,r.origin),n=$o(e,o,r.around&&en.getInnerOrigin(t,r.around));if(en.hasOffset(t)&&(n.x-=r.offsetX,n.y-=r.offsetY),i){const e=n.scaleX/t.scaleX,i=n.scaleY/t.scaleY;if(delete n.scaleX,delete n.scaleY,o){jt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=en.getInnerOrigin(t,r.origin);_t.move(n,o.x-s.x,o.y-s.y)}t.set(n),t.scaleResize(e,i,!1)}else t.set(n,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return jo(i,en.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>_t.tempToOuterOf(en.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return Bt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Ho(Jo,t.worldTransform),qo(Jo,e.scrollWorldTransform),i?Jo:Object.assign({},Jo)),updateScaleFixedWorld(t){},updateOuterBounds(t){},cacheId(t){},drop(t,e,i,s){t.setTransform(en.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||en.hasOffset(t),hasOffset:t=>t.offsetX||t.offsetY,hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}},animateMove(t,e,i=.3){if(e.x||e.y)if(Math.abs(e.x)<1&&Math.abs(e.y)<1)t.move(e);else{const s=e.x*i,r=e.y*i;e.x-=s,e.y-=r,t.move(s,r),se.requestRender(()=>en.animateMove(t,e,i))}}},en=tn,{updateAllMatrix:sn,updateMatrix:rn,updateAllWorldOpacity:on,updateAllChange:nn,updateChange:an}=en;function hn(t,e){return t.updateLayout(),t.parent?_t.tempToInnerOf(e,t.parent.scrollWorldTransform):e}var ln,dn={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){const{__:e,__layout:i}=t;return e.eraser||0===e.visible?null:i.localOuterBounds||i.localRenderBounds},maskLocalBoxBounds:(t,e)=>cn(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>cn(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds(t,e){const{__layout:i}=t;return cn(t,e)&&(i.localOuterBounds||i.localRenderBounds)},excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};function cn(t,e){return e||(ln=0),t.__.mask&&(ln=1),ln<0?null:(ln&&(ln=-1),!0)}var{updateBounds:un}=tn,pn={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,r=i.length;s<r;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),gn(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&g(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 r=0,o=s.length;r<o;r++)s[r].isBranch&&e.push(s[r]);for(let r=i,o=e.length;r<o;r++)_n(e[r],e)},updateBounds(t,e){const i=[t];_n(t,i),fn(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let r=t.length-1;r>-1;r--){i=t[r],s=i.children;for(let t=0,e=s.length;t<e;t++)un(s[t]);e&&e===i||un(i)}},move(t,e,i){let s;const{children:r}=t;for(let o=0,n=r.length;o<n;o++)s=(t=r[o]).__world,s.e+=e,s.f+=i,s.x+=e,s.y+=i,t.isBranch&&mn(t,e,i)},scale(t,e,i,s,r,o,n){let a;const{children:h}=t,l=s-1,d=r-1;for(let c=0,u=h.length;c<u;c++)a=(t=h[c]).__world,a.a*=s,a.d*=r,(a.b||a.c)&&(a.b*=s,a.c*=r),a.e===a.x&&a.f===a.y?(a.x=a.e+=(a.e-o)*l+e,a.y=a.f+=(a.f-n)*d+i):(a.e+=(a.e-o)*l+e,a.f+=(a.f-n)*d+i,a.x+=(a.x-o)*l+e,a.y+=(a.y-n)*d+i),a.width*=s,a.height*=r,a.scaleX*=s,a.scaleY*=r,t.isBranch&&yn(t,e,i,s,r,o,n)}},{pushAllChildBranch:gn,pushAllBranchStack:_n,updateBoundsByBranchStack:fn,move:mn,scale:yn}=pn,vn={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:wn,updateBounds:xn}=tn,{toOuterOf:bn,getPoints:kn,copy:En}=jt,Sn="_localContentBounds",Bn="_worldContentBounds",Tn="_worldBoxBounds",Cn="_worldStrokeBounds",On=class{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}set renderBounds(t){this._renderBounds=t}get localContentBounds(){return bn(this.contentBounds,this.leaf.__localMatrix,this[Sn]||(this[Sn]={})),this[Sn]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return bn(this.contentBounds,this.leaf.__world,this[Bn]||(this[Bn]={})),this[Bn]}get worldBoxBounds(){return bn(this.boxBounds,this.leaf.__world,this[Tn]||(this[Tn]={})),this[Tn]}get worldStrokeBounds(){return bn(this.strokeBounds,this.leaf.__world,this[Cn]||(this[Cn]={})),this[Cn]}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.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),t.__world&&(this.boxBounds={x:0,y:0,width:0,height:0},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{leaf:t}=this,{leafer:e}=t;if(t.isApp)return xn(t);if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=t;for(;e.parent&&!e.parent.leafer;)e=e.parent;const i=e;if(i.__fullLayouting)return;i.__fullLayouting=!0,se.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 st.defaultMatrix;case"page":t=e.zoomLayer;default:return wn(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 qt(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 r,o,n,a=this.getInnerBounds(t);switch(e){case"world":r=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;n={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},r=s.getLocalPointByInner(a);break;case"inner":r=a,o=st.defaultMatrix;break;case"page":e=s.zoomLayer;default:r=s.getWorldPoint(a,e),o=wn(s,e,!0)}if(n||(n=st.getLayout(o)),En(n,a),_t.copy(n,r),i){const{scaleX:t,scaleY:e}=n,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(n.scaleX/=i,n.scaleY/=s,n.width*=i,n.height*=s)}return n}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=kn(this.getInnerBounds(t));let r;switch(e){case"world":r=null;break;case"local":r=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:r=e}return g(r)||s.forEach(t=>i.innerToWorld(t,null,!1,r)),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.boundsChanged||(this.boundsChanged=!0):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.boundsChanged||(this.boundsChanged=!0):this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}},Rn=class{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&se.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&se.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&se.event.stop(this.origin)}},Pn=class extends Rn{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}};Pn.ADD="child.add",Pn.REMOVE="child.remove",Pn.CREATED="created",Pn.MOUNTED="mounted",Pn.UNMOUNTED="unmounted",Pn.DESTROY="destroy";var Ln="property.scroll",Mn=class extends Rn{constructor(t,e,i,s,r){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=r}};Mn.CHANGE="property.change",Mn.LEAFER_CHANGE="property.leafer_change",Mn.SCROLL=Ln;var Dn={scrollX:Ln,scrollY:Ln},An=class extends Rn{constructor(t,e){super(t),Object.assign(this,e)}};An.LOAD="image.load",An.LOADED="image.loaded",An.ERROR="image.error";var In=class extends Rn{static checkHas(t,e,i){"on"===i?e===Yn?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Wn)||t.hasEvent(zn)||t.hasEvent(Fn),t.__hasWorldEvent=t.hasEvent(Yn))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Wn,t),"inner"===e&&t.emit(zn,t)),t.emit(Fn,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Yn,t)}};In.RESIZE="bounds.resize",In.INNER="bounds.inner",In.LOCAL="bounds.local",In.WORLD="bounds.world";var{RESIZE:Wn,INNER:zn,LOCAL:Fn,WORLD:Yn}=In,Nn={};[Wn,zn,Fn,Yn].forEach(t=>Nn[t]=1);var Xn=class t extends Rn{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(e,i){w(e)?(super(t.RESIZE),Object.assign(this,e)):super(e),this.old=i}static isResizing(t){return this.resizingKeys&&!g(this.resizingKeys[t.innerId])}};Xn.RESIZE="resize";var Hn=class extends Rn{constructor(t,e){super(t),this.data=e}};Hn.REQUEST="watch.request",Hn.DATA="watch.data";var Vn=class extends Rn{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}};Vn.REQUEST="layout.request",Vn.START="layout.start",Vn.BEFORE="layout.before",Vn.LAYOUT="layout",Vn.AFTER="layout.after",Vn.AGAIN="layout.again",Vn.END="layout.end";var Un=class extends Rn{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}};Un.REQUEST="render.request",Un.CHILD_START="render.child_start",Un.CHILD_END="render.child_end",Un.START="render.start",Un.BEFORE="render.before",Un.RENDER="render",Un.AFTER="render.after",Un.AGAIN="render.again",Un.END="render.end",Un.NEXT="render.next";var jn=class extends Rn{};jn.START="leafer.start",jn.BEFORE_READY="leafer.before_ready",jn.READY="leafer.ready",jn.AFTER_READY="leafer.after_ready",jn.VIEW_READY="leafer.view_ready",jn.VIEW_COMPLETED="leafer.view_completed",jn.STOP="leafer.stop",jn.RESTART="leafer.restart",jn.END="leafer.end",jn.UPDATE_MODE="leafer.update_mode",jn.TRANSFORM="leafer.transform",jn.MOVE="leafer.move",jn.SCALE="leafer.scale",jn.ROTATE="leafer.rotate",jn.SKEW="leafer.skew";var{MOVE:Gn,SCALE:Kn,ROTATE:Zn,SKEW:qn}=jn,$n={x:Gn,y:Gn,scaleX:Kn,scaleY:Kn,rotation:Zn,skewX:qn,skewY:qn},Jn={};function Qn(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Jn)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Jn)}}var{on:ta,on_:ea,off:ia,off_:sa,once:ra,emit:oa,emitEvent:na,hasEvent:aa,destroy:ha}=class{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(v(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)v(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,r,o;i&&("once"===i?r=!0:"boolean"==typeof i?s=i:(s=i.capture,r=i.once));const n=Qn(this,s,!0),a=f(t)?t.split(" "):t,h=r?{listener:e,once:r}:{listener:e};a.forEach(t=>{t&&(o=n[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(h):n[t]=[h],Nn[t]&&In.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=f(t)?t.split(" "):t;if(e){let t,r,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const n=Qn(this,t);s.forEach(t=>{t&&(r=n[t],r&&(o=r.findIndex(t=>t.listener===e),o>-1&&r.splice(o,1),r.length||delete n[t],Nn[t]&&In.checkHas(this,t,"off")))})}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 e?this.on(t,i?e=e.bind(i):e,s):v(t)&&t.forEach(t=>this.on(t[0],t[2]?t[1]=t[1].bind(t[2]):t[1],t[3])),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=v(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):v(t.type)&&t.type.forEach(e=>t.current.off(e[0],e[1],e[3])))}),e.length=0}once(t,e,i,s){if(!e)return v(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));w(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&ve.has(t)&&(e=ve.get(t,{type:t,target:this,current:this}));const s=Qn(this,i)[t];if(s){let r;for(let o=0,n=s.length;o<n&&!((r=s[o])&&(r.listener(e),r.once&&(this.off(t,r.listener,i),o--,n--),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,r=i&&i[t],o=s&&s[t];return!!(g(e)?r||o:e?o:r)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}.prototype,la={on:ta,on_:ea,off:ia,off_:sa,once:ra,emit:oa,emitEvent:na,hasEvent:aa,destroyEventer:ha},da=ne.get("setAttr"),ca={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||m(e)||g(e)||(da.warn(this.innerName,t,e),e=void 0),w(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Mn(Mn.LEAFER_CHANGE,this,t,s,e));const i=$n[t];i&&(this.emitEvent(new jn(i,this)),this.emitEvent(new jn(jn.TRANSFORM,this)))}this.emitPropertyEvent(Mn.CHANGE,t,s,e);const i=Dn[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const r=new Mn(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(r),this.leafer.emitEvent(r)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||g(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ua,multiplyParent:pa,translateInner:ga,defaultWorld:_a}=st,{toPoint:fa,tempPoint:ma}=Bt,ya={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:r}=this;pa(this.__local||e,t?t.__scrollWorld||t.__world:_a,i,!!e.affectScaleOrRotation,r),s&&ga(Object.assign(s,i),r.scrollX,r.scrollY),e.scaleFixed&&tn.updateScaleFixedWorld(this)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(ua(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(fa(i.around||i.origin,t.boxBounds,ma),ga(e,-ma.x,-ma.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:va,updateAllMatrix:wa}=tn,{updateBounds:xa}=pn,{toOuterOf:ba,copyAndSpread:ka,copy:Ea}=jt,{toBounds:Sa}=Yr,Ba={__updateWorldBounds(){const{__layout:t,__world:e}=this;ba(t.renderBounds,e,e),this.__hasComplex&&tn.checkComplex(this),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&In.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&In.emitWorld(this)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized="inner"),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=void 0,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=void 0,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=void 0,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized="inner"),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=void 0,this.parent&&this.parent.__layout.renderChange()),t.outerScale&&tn.updateOuterBounds(this),t.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),ba(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){ba(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){ba(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Sa(s.path,i):(i.x=0,i.y=0,i.width=s.width,i.height=s.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),wa(this),xa(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(wa(this),xa(this,this))):va(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;ka(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;y(i)&&i<=0?Ea(e.renderBounds,e.strokeBounds):ka(e.renderBounds,e.boxBounds,i)}},Ta={__render(t,e){if(e.shape)return this.__renderShape(t,e);if((!e.cellList||e.cellList.has(this))&&this.__worldOpacity){const i=this.__;if(i.bright&&!e.topRendering)return e.topList.add(this);if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.ignoreOpacity?1:e.dimOpacity&&!i.dimskip?i.opacity*e.dimOpacity:i.opacity,this.__.__single){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!0,!0);this.__draw(s,e,t),tn.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);ne.showBounds&&ne.drawBounds(this,t,e)}},__renderShape(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawShape(t,e))},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),t.clipUI(this))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:Ca}=dn,{hasSize:Oa}=jt,Ra={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){const i=this.__nowWorld=this.__getNowWorld(e);if(this.__worldOpacity&&Oa(i)){const s=this.__;if(s.__useDim)if(s.dim)e.dimOpacity=!0===s.dim?.2:s.dim;else{if(s.bright&&!e.topRendering)return e.topList.add(this);s.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(s.__single&&!this.isBranchLeaf){if("path"===s.eraser)return this.__renderEraser(t,e);const r=t.getSameCanvas(!1,!0);this.__renderBranch(r,e),t.opacity=e.ignoreOpacity?1:e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(r,i,i,s.__blendMode,!0),r.recycle(i)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{let i;const{children:s}=this;for(let r=0,o=s.length;r<o;r++)i=s[r],Ca(i,e)||(i.__hasComplex?tn.renderComplex(i,t,e):i.__render(t,e))}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,r=i.length;s<r;s++)Ca(i[s],e)||i[s].__clip(t,e)}}},{LEAF:Pa,create:La}=T,{stintSet:Ma}=E,{toInnerPoint:Da,toOuterPoint:Aa,multiplyParent:Ia}=st,{toOuterOf:Wa}=jt,{copy:za,move:Fa}=_t,{getScaleFixedData:Ya}=X,{moveLocal:Na,zoomOfLocal:Xa,rotateOfLocal:Ha,skewOfLocal:Va,moveWorld:Ua,zoomOfWorld:ja,rotateOfWorld:Ga,skewOfWorld:Ka,transform:Za,transformWorld:qa,setTransform:$a,getFlipTransform:Ja,getLocalOrigin:Qa,getRelativeWorld:th,drop:eh}=tn,ih=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 B}get __LayoutProcessor(){return On}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 scrollWorldTransform(){return this.updateLayout(),this.__scrollWorld||this.__world}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.updateLayout(),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=La(Pa),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Pn.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),0!==t&&(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(Pn.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Pn.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(Pn.MOUNTED),t.cacheId&&tn.cacheId(this)):this.__emitLifeEvent(Pn.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){g(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=g(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(t,e){}__updateContentBounds(){}__updateStrokeBounds(t){}__updateRenderBounds(t){}__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,i=this.__world;return Ia(i,t.matrix,e,void 0,i),Wa(this.__layout.renderBounds,e,e),Ma(e,"half",i.half),Ma(e,"ignorePixelSnap",i.ignorePixelSnap),e}return this.__world}getClampRenderScale(){let{scaleX:t}=this.__nowWorld||this.__world;return t<0&&(t=-t),t>1?t:1}getRenderScaleData(t,e,i=!0){return Ya(no.patternLocked?this.__world:this.__nowWorld||this.__world,e,i,t)}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?th(this,e):this.worldTransform,r=i?t:{};return Wa(t,s,r),r}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&za(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&za(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Da(this.worldTransform,t,e,i)}innerToWorld(t,e,i,s){Aa(this.worldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){const r=this.getInnerPoint(t,e,i,s);return i?r:this.getBoxPointByInner(r,null,null,!0)}getBoxPointByInner(t,e,i,s){const r=s?t:Object.assign({},t),{x:o,y:n}=this.boxBounds;return Fa(r,-o,-n),r}getInnerPoint(t,e,i,s){const r=s?t:{};return this.worldToInner(t,r,i,e),r}getInnerPointByBox(t,e,i,s){const r=s?t:Object.assign({},t),{x:o,y:n}=this.boxBounds;return Fa(r,o,n),r}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const r=s?t:{};return this.worldToLocal(t,r,i,e),r}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 r=s?t:{};return this.innerToWorld(t,r,i,e),r}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const r=s?t:{};return this.localToWorld(t,r,i,e),r}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){$a(this,t,e,i)}transform(t,e,i){Za(this,t,e,i)}move(t,e,i){Na(this,t,e,i)}moveInner(t,e,i){Ua(this,t,e,!0,i)}scaleOf(t,e,i,s,r){Xa(this,Qa(this,t),e,i,s,r)}rotateOf(t,e,i){Ha(this,Qa(this,t),e,i)}skewOf(t,e,i,s,r){Va(this,Qa(this,t),e,i,s,r)}transformWorld(t,e,i){qa(this,t,e,i)}moveWorld(t,e,i){Ua(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,r){ja(this,t,e,i,s,r)}rotateOfWorld(t,e){Ga(this,t,e)}skewOfWorld(t,e,i,s,r){Ka(this,t,e,i,s,r)}flip(t,e){Za(this,Ja(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}hit(t,e){return!0}__hitWorld(t,e){return!0}__hit(t,e){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,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(t){}getMotionPathData(){return pe.need("path")}getMotionPoint(t){return pe.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){eh(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i,s){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):Mo(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=xo),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Pn(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Pn.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};ih=be([Yo(ca),Yo(ya),Yo(Ba),Yo(la),Yo(Ta)],ih);var{setListWithFn:sh}=jt,{sort:rh}=pn,{localBoxBounds:oh,localStrokeBounds:nh,localRenderBounds:ah,maskLocalBoxBounds:hh,maskLocalStrokeBounds:lh,maskLocalRenderBounds:dh}=dn,ch=new ne("Branch"),uh=class extends ih{__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(){let t;const{children:e}=this;for(let i=0,s=e.length;i<s;i++)if(t=e[i].__layout,t.renderSpread||t.localOuterBounds)return 1;return 0}__updateBoxBounds(t,e){sh(e||this.__layout.boxBounds,this.children,this.__hasMask?hh:oh)}__updateStrokeBounds(t){sh(t||this.__layout.strokeBounds,this.children,this.__hasMask?lh:nh)}__updateRenderBounds(t){sh(t||this.__layout.renderBounds,this.children,this.__hasMask?dh:ah)}__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(rh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return ch.warn("add self or destroyed");const i=g(e);if(!t.__){if(v(t))return t.forEach(t=>{this.add(t,e),i||e++});if(!(t=fe.get(t.tag,t)))return}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(Pn.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Pn.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)):g(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(Pn.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Pn.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Pn(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};uh=be([Yo(Ra)],uh);var ph=class t{get length(){return this.list.length}constructor(t){this.reset(),t&&(v(t)?this.addList(t):this.add(t))}has(t){return t&&!g(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return g(e)?-1:e}add(t){const{list:e,keys:i}=this;g(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(g(i[t.innerId])){const{list:s}=this;for(let t=e,r=s.length;t<r;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,r=e.length;s<r;s++)g(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;g(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 e=new t;return e.list=[...this.list],e.keys=Object.assign({},this.keys),e}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()}},gh=class{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(v(t)?this.addList(t):this.add(t))}has(t){return!g(this.keys[t.innerId])}without(t){return g(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 s=0,r=e.length;s<r;s++)t(e[s])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}};function _h(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}function fh(t){return go(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0);const i=this.__layout;i.renderChanged||i.renderChange(),i.surfaceChange()}}))}function mh(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}var yh={},vh={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},wh=Qt,xh={},bh={},kh={},Eh={},Sh={},Bh={apply(){pe.need("filter")}},Th={},Ch={setStyleName:()=>pe.need("state"),set:()=>pe.need("state")},{parse:Oh,objectToCanvasData:Rh}=ds,{stintSet:Ph}=E,{hasTransparent:Lh}=vh,Mh={originPaint:{}},Dh=ne.get("UIData"),Ah=class extends B{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){return this.__getRealStrokeWidth()}get __maxStrokeWidth(){const t=this,e=t.__hasStrokeSides||t.strokeWidth;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,e):e}get __hasMultiPaint(){const t=this;return t.fill&&this.__useStroke||t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return null==this._width}get __autoHeight(){return null==this._height}get __autoSide(){return null==this._width||null==this._height}get __autoSize(){return null==this._width&&null==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,Dh.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Dh.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),f(t)||!t?(Ph(this,"__isTransparentFill",Lh(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):w(t)&&this.__setPaint("fill",t)}setStroke(t){f(t)||!t?(Ph(this,"__isTransparentStroke",Lh(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):w(t)&&this.__setPaint("stroke",t)}setPath(t){const e=f(t);e||t&&w(t[0])?(this.__setInput("path",t),this._path=e?Oh(t):Rh(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){Ih(this,"shadow",t)}setInnerShadow(t){Ih(this,"innerShadow",t)}setFilter(t){Ih(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&bh.compute("fill",this.__leaf),e&&bh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeScaleFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),g(t.strokeScaleFixed)||(i=t.strokeScaleFixed)),i){const{scaleX:t}=this.__leaf.getRenderScaleData(!0,i,!1);if(1!==t)return e*t}return e}__checkComplex(){const t=this;Ph(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),v(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=Mh)):(this.__isStrokes=!0,this._stroke||(this._stroke=Mh))}__removePaint(t,e){e&&this.__removeInput(t),kh.recycleImage(t,this),"fill"===t?(Ph(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(Ph(this,"__isAlphaPixelStroke",void 0),Ph(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}};function Ih(t,e,i){t.__setInput(e,i),v(i)?(i.some(t=>!1===t.visible)&&(i=i.filter(t=>!1!==t.visible)),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}var Wh=class extends Ah{},zh=class extends Wh{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return this.__single||this.__clipAfterFill}get __clipAfterFill(){const t=this;return"show"!==t.overflow&&t.__leaf.children.length&&(t.__leaf.isOverflow||super.__clipAfterFill)}},Fh=class extends Ah{get __usePathBox(){return this.points||this.__pathInputed}},Yh=class extends Ah{get __boxStroke(){return!this.__pathInputed}},Nh={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900},{max:Xh,add:Hh}=P,Vh={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:r}=i,o=this.__box;if((i.stroke||"all"===i.hitStroke)&&r&&"inside"!==s&&(e=t="center"===s?r/2:r,!i.__boxStroke||i.__useArrow)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:r;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*r),o&&(t=Xh(t,o.__layout.strokeSpread=o.__updateStrokeSpread()),e=Math.max(e,o.__layout.strokeBoxSpread)),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:r,filter:o,renderSpread:n}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=Sh.getShadowRenderSpread(this,e)),s&&(t=Xh(t,s)),o&&(t=Hh(t,Bh.getSpread(o))),n&&(t=Hh(t,n)),a&&(t=Hh(t,a));let l=t;return i&&(l=Xh(l,Sh.getInnerShadowSpread(this,i))),r&&(l=Xh(l,r)),this.__layout.renderShapeSpread=l,h?Xh(h.__updateRenderSpread(),t):t}},{stintSet:Uh}=E,jh={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Uh(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Uh(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,r=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Uh(t,"__isFastShadow",e&&!r&&e.length<2&&!e[0].spread&&!Sh.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(v(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!r)}t.__checkSingle(),t.__checkComplex()},__drawFast(t,e){Gh(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:o,__drawAfterFill:n,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=bh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&Sh.shadow(this,t,h),a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e)),r&&(s.__isFills?bh.fills(r,this,t,e):bh.fill(r,this,t,e)),n&&this.__drawAfterFill(t,e),d&&Sh.innerShadow(this,t,h),o&&!a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e)),c&&Bh.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e)),h){const e=s.shadow[0],{scaleX:i,scaleY:r}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*r,e.blur*i,vh.string(e.color))}r&&(s.__isFills?bh.fills(r,this,t,e):bh.fill(r,this,t,e)),h&&t.restore(),n&&this.__drawAfterFill(t,e),o&&!a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e))}}else s.__pathForRender?Gh(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:r}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?bh.fills(s,this,t,e):bh.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),r&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?bh.strokes(r,this,t,e):bh.stroke("#000000",this,t,e))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Gh(t,e,i){const{fill:s,stroke:r,__drawAfterFill:o,__fillAfterStroke:n}=t.__;t.__drawRenderPath(e),n&&bh.stroke(r,t,e,i),s&&bh.fill(s,t,e,i),o&&t.__drawAfterFill(e,i),r&&!n&&bh.stroke(r,t,e,i)}var Kh,Zh={__drawFast(t,e){let{x:i,y:s,width:r,height:o}=this.__layout.boxBounds;const{fill:n,stroke:a,__drawAfterFill:h}=this.__;if(n&&(t.fillStyle=n,t.fillRect(i,s,r,o)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:n,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(n){case"center":t.strokeRect(0,0,r,o);break;case"inside":r-=h,o-=h,r<0||o<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,r,o),t.restore()):t.strokeRect(i+l,s+l,r,o);break;case"outside":t.strokeRect(i-l,s-l,r+h,o+h)}}}},qh=Kh=class extends ih{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set strokeWidthFixed(t){this.strokeScaleFixed=t}get strokeWidthFixed(){return this.strokeScaleFixed}set scale(t){X.assignScale(this,t)}get scale(){return this.__.scale}get isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return Zr.set(this.path=t||[]),t||this.__drawPathByBox(Zr),Zr}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return f(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}clearProxyData(){}find(t,e){return pe.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return pe.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(Zr.set(i=[]),this.__drawPathByBox(Zr,!e)),t?ds.toCanvasData(i,!0):i}getPathString(t,e,i){return ds.stringify(this.getPath(t,e),i)}asPath(t,e){this.path=this.getPath(t,e)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Th.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(t){const e=this.__;e.path?(e.__pathForRender=e.cornerRadius||e.path.radius?Gr.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&xh.addArrows(this,t)):e.__pathForRender&&(e.__pathForRender=void 0)}__drawRenderPath(t){const e=this.__;t.beginPath(),e.__useArrow&&xh.updateArrow(this),this.__drawPathByData(t,e.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path,!0)}__drawPathByData(t,e,i){e?cr.drawPathByData(t,e):this.__drawPathByBox(t,i)}__drawPathByBox(t,e){const{x:i,y:s,width:r,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius&&!e){const{cornerRadius:e}=this.__;t.roundRect(i,s,r,o,y(e)?[e]:e)}else t.rect(i,s,r,o);t.closePath()}drawImagePlaceholder(t,e,i){bh.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),pe.need("animate")}killAnimate(t,e){}export(t,e){return pe.need("export")}syncExport(t,e){return pe.need("export")}clone(t){const e=E.clone(this.toJSON());return t&&Object.assign(e,t),Kh.one(e)}static one(t,e,i,s,r){return fe.get(t.tag||this.prototype.__tag,t,e,i,s,r)}static registerUI(){No()(this)}static registerData(t){Lo(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.__.__willDestroy=!0,this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};_h([Lo(Ah)],qh.prototype,"__",void 0),_h([(t,e)=>{const i="_"+e;uo(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}})}],qh.prototype,"zoomLayer",void 0),_h([_o("")],qh.prototype,"id",void 0),_h([_o("")],qh.prototype,"name",void 0),_h([_o("")],qh.prototype,"className",void 0),_h([To("pass-through")],qh.prototype,"blendMode",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Oo(this)}}))}(1)],qh.prototype,"opacity",void 0),_h([function(t){return go(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Ro(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Ro(this,t,e,i),this.mask&&Oo(this)}}))}(!0)],qh.prototype,"visible",void 0),_h([To(!1)],qh.prototype,"locked",void 0),_h([Co(!1)],qh.prototype,"dim",void 0),_h([Co(!1)],qh.prototype,"dimskip",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__layout.childrenSortChange()})}}))}(0)],qh.prototype,"zIndex",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}(!1)],qh.prototype,"mask",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}(!1)],qh.prototype,"eraser",void 0),_h([fo(0,!0)],qh.prototype,"x",void 0),_h([fo(0,!0)],qh.prototype,"y",void 0),_h([xo(100,!0)],qh.prototype,"width",void 0),_h([xo(100,!0)],qh.prototype,"height",void 0),_h([vo(1,!0)],qh.prototype,"scaleX",void 0),_h([vo(1,!0)],qh.prototype,"scaleY",void 0),_h([wo(0,!0)],qh.prototype,"rotation",void 0),_h([wo(0,!0)],qh.prototype,"skewX",void 0),_h([wo(0,!0)],qh.prototype,"skewY",void 0),_h([fo(0,!0)],qh.prototype,"offsetX",void 0),_h([fo(0,!0)],qh.prototype,"offsetY",void 0),_h([mo(0,!0)],qh.prototype,"scrollX",void 0),_h([mo(0,!0)],qh.prototype,"scrollY",void 0),_h([yo()],qh.prototype,"origin",void 0),_h([yo()],qh.prototype,"around",void 0),_h([_o(!1)],qh.prototype,"lazy",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(bo(this),this.__.__removeNaturalSize())}}))}(1)],qh.prototype,"pixelRatio",void 0),_h([Bo(0)],qh.prototype,"renderSpread",void 0),_h([function(t){return go(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),bo(this)}}))}()],qh.prototype,"path",void 0),_h([ko()],qh.prototype,"windingRule",void 0),_h([ko(!0)],qh.prototype,"closed",void 0),_h([xo(0)],qh.prototype,"padding",void 0),_h([xo(!1)],qh.prototype,"lockRatio",void 0),_h([xo()],qh.prototype,"widthRange",void 0),_h([xo()],qh.prototype,"heightRange",void 0),_h([_o(!1)],qh.prototype,"draggable",void 0),_h([_o()],qh.prototype,"dragBounds",void 0),_h([_o("auto")],qh.prototype,"dragBoundsType",void 0),_h([_o(!1)],qh.prototype,"editable",void 0),_h([Po(!0)],qh.prototype,"hittable",void 0),_h([Po("path")],qh.prototype,"hitFill",void 0),_h([So("path")],qh.prototype,"hitStroke",void 0),_h([Po(!1)],qh.prototype,"hitBox",void 0),_h([Po(!0)],qh.prototype,"hitChildren",void 0),_h([Po(!0)],qh.prototype,"hitSelf",void 0),_h([Po()],qh.prototype,"hitRadius",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}("")],qh.prototype,"cursor",void 0),_h([To()],qh.prototype,"fill",void 0),_h([So(void 0,!0)],qh.prototype,"stroke",void 0),_h([So("inside")],qh.prototype,"strokeAlign",void 0),_h([So(1,!0)],qh.prototype,"strokeWidth",void 0),_h([So(!1)],qh.prototype,"strokeScaleFixed",void 0),_h([So("none")],qh.prototype,"strokeCap",void 0),_h([So("miter")],qh.prototype,"strokeJoin",void 0),_h([So()],qh.prototype,"dashPattern",void 0),_h([So(0)],qh.prototype,"dashOffset",void 0),_h([So(10)],qh.prototype,"miterLimit",void 0),_h([ko(0)],qh.prototype,"cornerRadius",void 0),_h([ko()],qh.prototype,"cornerSmoothing",void 0),_h([fh()],qh.prototype,"shadow",void 0),_h([fh()],qh.prototype,"innerShadow",void 0),_h([fh()],qh.prototype,"blur",void 0),_h([fh()],qh.prototype,"backgroundBlur",void 0),_h([fh()],qh.prototype,"grayscale",void 0),_h([fh()],qh.prototype,"filter",void 0),_h([To()],qh.prototype,"placeholderColor",void 0),_h([_o(100)],qh.prototype,"placeholderDelay",void 0),_h([_o({})],qh.prototype,"data",void 0),_h([Wo(ih.prototype.reset)],qh.prototype,"reset",null),qh=Kh=_h([Yo(Vh),Yo(jh),zo()],qh);var $h,Jh=class extends qh{get __tag(){return"Group"}get isBranch(){return!0}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);if(!this.childlessJSON){const i=e.children=[];this.children.forEach(e=>e.skipJSON||i.push(e.toJSON(t)))}return 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(){}};_h([Lo(Wh)],Jh.prototype,"__",void 0),_h([xo(0)],Jh.prototype,"width",void 0),_h([xo(0)],Jh.prototype,"height",void 0),Jh=_h([Yo(uh),No()],Jh);var Qh=ne.get("Leafer"),tl=$h=class extends Jh{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&ro.isComplete}get layoutLocked(){return!this.layouter.running}get view(){return this.canvas&&this.canvas.view}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),$h.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,E.assign(s,t));const r=this.canvas=ge.canvas(s);this.__controllers.push(this.renderer=ge.renderer(this,r,s),this.watcher=ge.watcher(this,s),this.layouter=ge.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),e||(this.selector=ge.selector(this),this.interaction=ge.interaction(this,r,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ge.hitCanvasManager()),this.canvasManager=new xe,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(r),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),vn.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(jn.RESTART):this.emitLeafer(jn.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(jn.STOP))}unlockLayout(t=!0){this.layouter.start(),t&&this.updateLayout()}lockLayout(t=!0){t&&this.updateLayout(),this.layouter.stop()}resize(t){const e=E.copyAttrs({},t,Ie);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new qt(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=E.copyAttrs({},this.canvas,Ie);e.resize(t),this.updateLazyBounds(),this.__onResize(new Xn(t,i))}__onResize(t){this.emitEvent(t),E.copyAttrs(this.__,t,Ie),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(){const{config:t,parentApp:e}=this;e||(t.width&&t.height||(this.autoLayout=new Jt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Ie.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())):"mode"===t&&this.emit(jn.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Ie.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,r=E.copyAttrs({},s,Ie);r[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(r)}__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(jn.BEFORE_READY),this.emitLeafer(jn.READY),this.emitLeafer(jn.AFTER_READY),vn.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(jn.VIEW_READY),vn.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:r,pixelRatio:o}=this;const n="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,n.x+n.width)),i||(r=Math.max(1,n.y+n.height)),this.__doResize({width:s,height:r,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){vn.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(jn.VIEW_COMPLETED),vn.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 r=0;r<s.length;r++)if(s[r]===t){s.splice(r,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return pe.need("view")}getValidMove(t,e,i){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 jn(t,this))}__listenEvents(){const t=de.start("FirstCreate "+this.innerName);this.once([[jn.START,()=>de.end(t)],[Vn.START,this.updateLazyBounds,this],[Un.START,this.__onCreated,this],[Un.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Hn.DATA,this.__onWatchData,this],[Vn.END,this.__onLayoutEnd,this],[Un.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){$h.list.remove(this);try{this.stop(),this.emitLeafer(jn.END),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&&this.canvasManager.destroy()),this.canvas&&this.canvas.destroy(),this.config.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{no.clearRecycled()},100)}catch(t){Qh.error(t)}}};t?e():setTimeout(e)}};tl.list=new ph,_h([Lo(class extends Wh{__getInputData(t,e){const i=super.__getInputData(t,e);return Ie.forEach(t=>delete i[t]),i}})],tl.prototype,"__",void 0),_h([xo()],tl.prototype,"pixelRatio",void 0),_h([_o("normal")],tl.prototype,"mode",void 0),tl=$h=_h([No()],tl);var el=class extends qh{get __tag(){return"Rect"}};_h([Lo(Yh)],el.prototype,"__",void 0),el=_h([Yo(Zh),zo(),No()],el);var{add:il,includes:sl,scroll:rl}=jt,ol=el.prototype,nl=Jh.prototype,al=class extends Jh{get __tag(){return"Box"}get isBranchLeaf(){return!0}get __useSelfBox(){return this.pathInputed}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.__useSelfBox){const t=this.__;if(t.__autoSide){t.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:e}=this.__layout;t.__autoSize||(t.__autoWidth?(e.width+=e.x,e.x=0,e.height=t.height,e.y=0):(e.height+=e.y,e.y=0,e.width=t.width,e.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t,e;if(this.children.length){const i=this.__,s=this.__layout,{renderBounds:r,boxBounds:o}=s,{overflow:n}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=n&&n.includes("scroll"))&&(il(a,o),rl(a,i)),this.__updateRectRenderBounds(),t=!sl(o,a),t&&"show"===n&&il(r,a)}else this.__updateRectRenderBounds();E.stintSet(this,"isOverflow",t),this.__checkScroll(e)}__updateRectRenderBounds(){}__checkScroll(t){}__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)),this.hasScroller&&this.scroller.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};_h([Lo(zh)],al.prototype,"__",void 0),_h([xo(100)],al.prototype,"width",void 0),_h([xo(100)],al.prototype,"height",void 0),_h([_o(!1)],al.prototype,"resizeChildren",void 0),_h([Bo("show")],al.prototype,"overflow",void 0),_h([Wo(ol.__updateStrokeSpread)],al.prototype,"__updateStrokeSpread",null),_h([Wo(ol.__updateRenderSpread)],al.prototype,"__updateRectRenderSpread",null),_h([Wo(ol.__updateBoxBounds)],al.prototype,"__updateRectBoxBounds",null),_h([Wo(ol.__updateStrokeBounds)],al.prototype,"__updateStrokeBounds",null),_h([Wo(ol.__updateRenderBounds)],al.prototype,"__updateRectRenderBounds",null),_h([Wo(ol.__updateChange)],al.prototype,"__updateRectChange",null),_h([Wo(ol.__render)],al.prototype,"__renderRect",null),_h([Wo(nl.__render)],al.prototype,"__renderGroup",null),al=_h([zo(),No()],al);var hl=class extends al{get __tag(){return"Frame"}get isFrame(){return!0}};_h([Lo(class extends zh{})],hl.prototype,"__",void 0),_h([To("#FFFFFF")],hl.prototype,"fill",void 0),_h([Bo("hide")],hl.prototype,"overflow",void 0),hl=_h([No()],hl);var{moveTo:ll,closePath:dl,ellipse:cl}=Ms,ul=class extends qh{get __tag(){return"Ellipse"}__updatePath(){const t=this.__,{width:e,height:i,innerRadius:s,startAngle:r,endAngle:o}=t,n=e/2,a=i/2,h=t.path=[];let l;s?r||o?(s<1?cl(h,n,a,n*s,a*s,0,r,o,!1):l=!0,cl(h,n,a,n,a,0,o,r,!0)):(s<1&&(cl(h,n,a,n*s,a*s),ll(h,e,a)),cl(h,n,a,n,a,0,360,0,!0)):r||o?(ll(h,n,a),cl(h,n,a,n,a,0,r,o,!1)):cl(h,n,a,n,a),l||dl(h),(se.ellipseToCurve||t.__useArrow||t.cornerRadius)&&(t.path=this.getPath(!0))}};_h([Lo(class extends Ah{get __boxStroke(){return!this.__pathInputed}})],ul.prototype,"__",void 0),_h([ko(0)],ul.prototype,"innerRadius",void 0),_h([ko(0)],ul.prototype,"startAngle",void 0),_h([ko(0)],ul.prototype,"endAngle",void 0),ul=_h([No()],ul);var{sin:pl,cos:gl,PI:_l}=Math,{moveTo:fl,lineTo:ml,closePath:yl,drawPoints:vl}=Ms,wl=class extends qh{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)vl(e,t.points,t.curve,t.closed);else{const{width:i,height:s,sides:r,startAngle:o}=t,n=i/2,a=s/2;let h,l=0;o?(l=o*V,fl(e,n+n*pl(l),a-a*gl(l))):fl(e,n,0);for(let t=1;t<r;t++)h=2*t*_l/r+l,ml(e,n+n*pl(h),a-a*gl(h));yl(e)}}};_h([Lo(class extends Fh{})],wl.prototype,"__",void 0),_h([ko(3)],wl.prototype,"sides",void 0),_h([ko(0)],wl.prototype,"startAngle",void 0),_h([ko()],wl.prototype,"points",void 0),_h([ko(0)],wl.prototype,"curve",void 0),wl=_h([zo(),No()],wl);var{sin:xl,cos:bl,PI:kl}=Math,{moveTo:El,lineTo:Sl,closePath:Bl}=Ms,Tl=class extends qh{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s,startAngle:r}=this.__,o=t/2,n=e/2,a=this.__.path=[];let h,l=0;r?(l=r*V,El(a,o+o*xl(l),n-n*bl(l))):El(a,o,0);for(let d=1;d<2*i;d++)h=d*kl/i+l,Sl(a,o+(d%2==0?o:o*s)*xl(h),n-(d%2==0?n:n*s)*bl(h));Bl(a)}};_h([Lo(class extends Ah{get __boxStroke(){return!this.__pathInputed}})],Tl.prototype,"__",void 0),_h([ko(5)],Tl.prototype,"corners",void 0),_h([ko(.382)],Tl.prototype,"innerRadius",void 0),_h([ko(0)],Tl.prototype,"startAngle",void 0),Tl=_h([No()],Tl);var{moveTo:Cl,lineTo:Ol,drawPoints:Rl}=Ms,{rotate:Pl,getAngle:Ll,getDistance:Ml,defaultPoint:Dl}=_t,Al=class extends qh{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&Pl(i,e),i}set toPoint(t){this.width=Ml(Dl,t),this.rotation=Ll(Dl,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?Rl(e,t.points,t.curve,t.closed):(Cl(e,0,0),Ol(e,this.width,0))}};_h([Lo(Fh)],Al.prototype,"__",void 0),_h([Eo("center")],Al.prototype,"strokeAlign",void 0),_h([xo(0)],Al.prototype,"height",void 0),_h([ko()],Al.prototype,"points",void 0),_h([ko(0)],Al.prototype,"curve",void 0),_h([ko(!1)],Al.prototype,"closed",void 0),Al=_h([No()],Al);var Il=class extends el{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return v(t)&&t[0].image}};_h([Lo(class extends Yh{get __urlType(){return"image"}setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:this.__urlType,mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return t.url&&delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url&&delete i.fill,i}})],Il.prototype,"__",void 0),_h([xo("")],Il.prototype,"url",void 0),Il=_h([No()],Il);var Wl=class extends el{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=ge.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new co({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new An(An.LOADED,{image:t}))})}draw(t,e,i,s){const r=new bt(t.worldTransform).invert(),o=new bt;e&&o.translate(e.x,e.y),i&&(y(i)?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),r.multiplyParent(o),t.__render(this.canvas,{matrix:r.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:r}=this.canvas;t.drawImage(r,0,0,r.width,r.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=null),super.destroy()}};_h([Lo(class extends Yh{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}})],Wl.prototype,"__",void 0),_h([mh(100)],Wl.prototype,"width",void 0),_h([mh(100)],Wl.prototype,"height",void 0),_h([mh(1)],Wl.prototype,"pixelRatio",void 0),_h([mh(!0)],Wl.prototype,"smooth",void 0),_h([_o(!1)],Wl.prototype,"safeResize",void 0),_h([mh()],Wl.prototype,"contextSettings",void 0),Wl=_h([No()],Wl);var{copyAndSpread:zl,includes:Fl,spread:Yl,setList:Nl}=jt,{stintSet:Xl}=E,Hl=class extends qh{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:r,fontWeight:o,italic:n,textCase:a,textOverflow:h,padding:l,width:d,height:c}=t;t.__lineHeight=wh.number(e,r),t.__letterSpacing=wh.number(i,r),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==o?o+" ":""}${r||12}px ${s||"caption"}`,Xl(t,"__padding",l&&X.fourNumber(l)),Xl(t,"__clipText","show"!==h&&!t.__autoSize),Xl(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=yh.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:r,__autoWidth:o,__autoHeight:n}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&Yl(a,i/2),o||n){if(h.x=o?a.x:0,h.y=n?a.y:0,h.width=o?a.width:t.width,h.height=n?a.height:t.height,r){const[e,i,s,r]=t.__padding;o&&(h.x-=r,h.width+=i+r),n&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),E.stintSet(this,"isOverflow",!Fl(h,a)),this.isOverflow?(Nl(t.__textBoxBounds={},[h,a]),e.renderChanged=!0):t.__textBoxBounds=h}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;zl(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__updateChange(){super.__updateChange();const t=this.__box;t&&(t.__onUpdateSize(),t.__updateChange())}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}__drawShape(t,e){e.shape&&this.__box&&this.__box.__drawShape(t,e),super.__drawShape(t,e)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};_h([Lo(class extends Ah{get __useNaturalRatio(){return!1}setFontWeight(t){f(t)?(this.__setInput("fontWeight",t),t=Nh[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=fe.get("Rect",0);const r=e.__layout,o=i.__layout;s||(i.parent=e,i.__world=e.__world,o.boxBounds=r.boxBounds),i.set(t),o.strokeChanged&&r.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.textEditing&&delete i.textEditing,i}})],Hl.prototype,"__",void 0),_h([xo(0)],Hl.prototype,"width",void 0),_h([xo(0)],Hl.prototype,"height",void 0),_h([To()],Hl.prototype,"boxStyle",void 0),_h([_o(!1)],Hl.prototype,"resizeFontSize",void 0),_h([To("#000000")],Hl.prototype,"fill",void 0),_h([Eo("outside")],Hl.prototype,"strokeAlign",void 0),_h([Po("all")],Hl.prototype,"hitFill",void 0),_h([xo("")],Hl.prototype,"text",void 0),_h([xo("")],Hl.prototype,"placeholder",void 0),_h([xo("caption")],Hl.prototype,"fontFamily",void 0),_h([xo(12)],Hl.prototype,"fontSize",void 0),_h([xo("normal")],Hl.prototype,"fontWeight",void 0),_h([xo(!1)],Hl.prototype,"italic",void 0),_h([xo("none")],Hl.prototype,"textCase",void 0),_h([xo("none")],Hl.prototype,"textDecoration",void 0),_h([xo(0)],Hl.prototype,"letterSpacing",void 0),_h([xo({type:"percent",value:1.5})],Hl.prototype,"lineHeight",void 0),_h([xo(0)],Hl.prototype,"paraIndent",void 0),_h([xo(0)],Hl.prototype,"paraSpacing",void 0),_h([xo("x")],Hl.prototype,"writingMode",void 0),_h([xo("left")],Hl.prototype,"textAlign",void 0),_h([xo("top")],Hl.prototype,"verticalAlign",void 0),_h([xo(!0)],Hl.prototype,"autoSizeAlign",void 0),_h([xo("normal")],Hl.prototype,"textWrap",void 0),_h([xo("show")],Hl.prototype,"textOverflow",void 0),_h([To(!1)],Hl.prototype,"textEditing",void 0),Hl=_h([No()],Hl);var Vl=class extends qh{get __tag(){return"Path"}};_h([Lo(class extends Ah{get __pathInputed(){return 2}})],Vl.prototype,"__",void 0),_h([Eo("center")],Vl.prototype,"strokeAlign",void 0),Vl=_h([No()],Vl);var Ul=class extends Jh{get __tag(){return"Pen"}setStyle(t){const e=this.pathElement=new Vl(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,r,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,r){return this}ellipse(t,e,i,s,r,o,n,a){return this}arc(t,e,i,s,r,o){return this}arcTo(t,e,i,s,r){return this}drawEllipse(t,e,i,s,r,o,n,a){return this}drawArc(t,e,i,s,r,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){const{pathElement:t}=this;t.__layout.boxChanged||t.forceUpdate("path")}};function jl(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}_h([Lo(class extends Wh{})],Ul.prototype,"__",void 0),_h([(t,e)=>{uo(t,e,{get(){return this.__path}})}],Ul.prototype,"path",void 0),Ul=_h([Yo(qs,["set","path","paint"]),No()],Ul);var Gl=class extends tl{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,e){if(super.init(t,e),t){const{ground:e,tree:i,sky:s,editor:r}=t;e&&(this.ground=this.addLeafer(e)),(i||r)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||r)&&(this.sky=this.addLeafer(s)),r&&ge.editor(r,this)}}__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()}__updateLocalBounds(){this.forEach(t=>t.updateLayout()),super.__updateLocalBounds()}start(){super.start(),this.forEach(t=>t.start())}stop(){this.forEach(t=>t.stop()),super.stop()}unlockLayout(){super.unlockLayout(),this.forEach(t=>t.unlockLayout())}lockLayout(){super.lockLayout(),this.forEach(t=>t.lockLayout())}forceRender(t,e){this.forEach(i=>i.forceRender(t,e))}addLeafer(t){const e=new tl(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),g(e)||(t.canvas.childIndex=e),this.__listenChildEvents(t)}forEach(t){this.children.forEach(t)}__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){t.context&&this.forEach(i=>e.matrix?i.__render(t,e):t.copyWorld(i.canvas,e.bounds,void 0,void 0,!0))}__onResize(t){this.forEach(e=>e.resize(t)),super.__onResize(t)}updateLayout(){this.forEach(t=>t.updateLayout())}__getChildConfig(t){const e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&E.assign(e,t),this.autoLayout&&E.copyAttrs(e,this,Ie),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Vn.END,this.__onReady,this],[Un.START,this.__onCreated,this],[Un.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Un.END,this.__onChildRenderEnd,this))}};Gl=jl([No()],Gl);var Kl={},Zl={isHoldSpaceKey:()=>Zl.isHold("Space"),isHold:t=>Kl[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){Kl[t]||(Kl[t]=!0)},setUpCode(t){Kl[t]=!1}},ql={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},$l=class extends Rn{get spaceKey(){return Zl.isHoldSpaceKey()}get left(){return ql.left(this)}get right(){return ql.right(this)}get middle(){return ql.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return Zl.isHoldKeys(t,this)}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){ve.changeName(t,e)}},{min:Jl,max:Ql,abs:td}=Math,{float:ed,sign:id}=X,{minX:sd,maxX:rd,minY:od,maxY:nd}=jt,ad=new qt,hd=new qt,ld={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&dd.getValidMove(t.__localBoxBounds,dd.getDragBounds(t),s,e,!0),dd.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:r,dragBoundsType:o}=t;r&&dd.getValidScaleOf(t.__localBoxBounds,dd.getDragBounds(t),o,t.getLocalPointByInner(t.getInnerPointByBox(e)),i,s,!0)},axisMove(t,e){const{draggable:i}=t;"x"===i&&(e.y=0),"y"===i&&(e.x=0)},getDragBounds(t){const{dragBounds:e}=t;return"parent"===e?t.parent.boxBounds:e},isInnerMode:(t,e,i,s)=>"inner"===i||"auto"===i&&ed(t[s])>ed(e[s]),getValidMove(t,e,i,s,r){const o=t.x+s.x,n=t.y+s.y,a=o+t.width,h=n+t.height,l=e.x+e.width,d=e.y+e.height;return r||(s=Object.assign({},s)),dd.isInnerMode(t,e,i,"width")?o>e.x?s.x+=e.x-o:a<l&&(s.x+=l-a):o<e.x?s.x+=e.x-o:a>l&&(s.x+=l-a),dd.isInnerMode(t,e,i,"height")?n>e.y?s.y+=e.y-n:h<d&&(s.y+=d-h):n<e.y?s.y+=e.y-n:h>d&&(s.y+=d-h),s.x=ed(s.x),s.y=ed(s.y),s},getValidScaleOf(t,e,i,s,r,o,n){n||(r=Object.assign({},r)),hd.set(e),ad.set(t).scaleOf(s,r.x,r.y);const a=(s.x-t.x)/t.width,h=1-a,l=(s.y-t.y)/t.height,d=1-l;let c,u,p,g,_=1,f=1;return dd.isInnerMode(t,e,i,"width")?(r.x<0&&ad.scaleOf(s,_=1/r.x,1),p=ed(ad.minX-hd.minX),g=ed(hd.maxX-ad.maxX),c=a&&p>0?1+p/(a*ad.width):1,u=h&&g>0?1+g/(h*ad.width):1,_*=Ql(c,u)):(r.x<0&&((ed(sd(t)-sd(e))<=0||ed(rd(e)-rd(t))<=0)&&ad.scaleOf(s,_=1/r.x,1),ad.unsign()),p=ed(hd.minX-ad.minX),g=ed(ad.maxX-hd.maxX),c=a&&p>0?1-p/(a*ad.width):1,u=h&&g>0?1-g/(h*ad.width):1,_*=Jl(c,u)),dd.isInnerMode(t,e,i,"height")?(r.y<0&&ad.scaleOf(s,1,f=1/r.y),p=ed(ad.minY-hd.minY),g=ed(hd.maxY-ad.maxY),c=l&&p>0?1+p/(l*ad.height):1,u=d&&g>0?1+g/(d*ad.height):1,f*=Ql(c,u),o&&(c=Ql(td(_),td(f)),_=id(_)*c,f=id(f)*c)):(r.y<0&&((ed(od(t)-od(e))<=0||ed(nd(e)-nd(t))<=0)&&ad.scaleOf(s,1,f=1/r.y),ad.unsign()),p=ed(hd.minY-ad.minY),g=ed(ad.maxY-hd.maxY),c=l&&p>0?1-p/(l*ad.height):1,u=d&&g>0?1-g/(d*ad.height):1,f*=Jl(c,u)),r.x*=m(_)?_:1,r.y*=m(f)?f:1,r}},dd=ld,cd=class extends $l{};cd.POINTER="pointer",cd.BEFORE_DOWN="pointer.before_down",cd.BEFORE_MOVE="pointer.before_move",cd.BEFORE_UP="pointer.before_up",cd.DOWN="pointer.down",cd.MOVE="pointer.move",cd.UP="pointer.up",cd.OVER="pointer.over",cd.OUT="pointer.out",cd.ENTER="pointer.enter",cd.LEAVE="pointer.leave",cd.TAP="tap",cd.DOUBLE_TAP="double_tap",cd.CLICK="click",cd.DOUBLE_CLICK="double_click",cd.LONG_PRESS="long_press",cd.LONG_TAP="long_tap",cd.MENU="pointer.menu",cd.MENU_TAP="pointer.menu_tap";cd=jl([Xo()],cd);var ud={},pd=class extends cd{static setList(t){this.list=t instanceof ph?t:new ph(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const r=t.getLocalPoint(i,null,!0);return _t.move(r,e.x-t.x,e.y-t.y),s&&this.limitMove(t,r),ld.axisMove(t,r),r}static limitMove(t,e){ld.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(ud,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(ud,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(ud,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 jt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),jt.unsign(i),i}assignMove(t){ud.x=t?this.totalX:this.moveX,ud.y=t?this.totalY:this.moveY}};pd.BEFORE_DRAG="drag.before_drag",pd.START="drag.start",pd.DRAG="drag",pd.END="drag.end",pd.OVER="drag.over",pd.OUT="drag.out",pd.ENTER="drag.enter",pd.LEAVE="drag.leave",pd=jl([Xo()],pd);var gd=class extends cd{static setList(t){pd.setList(t)}static setData(t){pd.setData(t)}};gd.DROP="drop",gd=jl([Xo()],gd);var _d=class extends pd{};_d.BEFORE_MOVE="move.before_move",_d.START="move.start",_d.MOVE="move",_d.DRAG_ANIMATE="move.drag_animate",_d.END="move.end",_d.PULL_DOWN="move.pull_down",_d.REACH_BOTTOM="move.reach_bottom",_d=jl([Xo()],_d);var fd=class extends $l{};fd=jl([Xo()],fd);var md=class extends cd{};md.BEFORE_ROTATE="rotate.before_rotate",md.START="rotate.start",md.ROTATE="rotate",md.END="rotate.end",md=jl([Xo()],md);var yd=class extends pd{};yd.SWIPE="swipe",yd.LEFT="swipe.left",yd.RIGHT="swipe.right",yd.UP="swipe.up",yd.DOWN="swipe.down",yd=jl([Xo()],yd);var vd=class extends cd{};vd.BEFORE_ZOOM="zoom.before_zoom",vd.START="zoom.start",vd.ZOOM="zoom",vd.END="zoom.end",vd=jl([Xo()],vd);var wd=class extends $l{};wd.BEFORE_DOWN="key.before_down",wd.BEFORE_UP="key.before_up",wd.DOWN="key.down",wd.HOLD="key.hold",wd.UP="key.up",wd=jl([Xo()],wd);var xd={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?yd.UP:t>45&&t<135?yd.DOWN:t<=45&&t>=-45?yd.RIGHT:yd.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:bd.getSwipeDirection(_t.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,time:Date.now(),buttons:g(t.buttons)?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let s=0,r=i.length;s<r;s++)if(i[s].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new ph,{list:s}=t;for(let r=0,o=s.length;r<o;r++)s[r].hasEvent(e)&&i.add(s[r]);return i},pathCanDrag:t=>t&&t.list.some(t=>tn.draggable(t)||!t.isLeafer&&t.hasEvent(pd.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},bd=xd,kd=new ph,{getDragEventData:Ed,getDropEventData:Sd,getSwipeEventData:Bd}=xd,Td=class{constructor(t){this.dragDataList=[],this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Ed(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,r=pd.list||this.draggableList||kd;return this.dragging&&(s?t?kd:new ph(e?[...i.list,...i.dragHoverExclude]:i.list):r)}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(_d.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&ql.left(t),this.dragging&&(this.interaction.emit(pd.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],tn.draggable(e)){this.draggableList=new ph(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:r,throughPath:o}=s;this.dragData=Ed(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.dragDataList.push(this.dragData),this.moving?(t.moving=!0,this.dragData.moveType="drag",e.emit(_d.BEFORE_MOVE,this.dragData),e.emit(_d.MOVE,this.dragData)):this.dragging&&(t.dragging=!0,this.dragReal(),e.emit(pd.BEFORE_DRAG,this.dragData),e.emit(pd.DRAG,this.dragData))}dragReal(t){const{interaction:e}=this,{running:i}=e,s=this.realDraggableList;if(s.length&&i){const{totalX:i,totalY:r}=this.dragData,{dragLimitAnimate:o}=e.p,n=!o||!!t;s.forEach(e=>{if(e.draggable){const s=f(e.draggable),a=pd.getValidMove(e,this.dragStartPoints[e.innerId],{x:i,y:r},n||s);o&&!s&&t?tn.animateMove(e,a,y(o)?o:.3):e.move(a)}})}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(pd.OUT,t,i),e.emit(pd.OVER,t,s)):e.emit(pd.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(pd.LEAVE,t,i,s),e.emit(pd.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:r,throughPath:o}=i,n=Ed(i,t,t);if(o&&(n.throughPath=o),n.path=r,this.moving&&(this.moving=!1,n.moveType="drag",e.emit(_d.END,n)),this.dragging){const r=this.getList();this.dragging=!1,e.p.dragLimitAnimate&&this.dragReal(!0),e.emit(pd.END,n),this.swipe(t,i,s,n),this.drop(t,r,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:r}=this;if(_t.getDistance(e,t)>r.config.pointer.swipeDistance){const t=Bd(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=Sd(t,e,pd.data);s.path=i,this.interaction.emit(gd.DROP,s),this.interaction.emit(pd.LEAVE,t,i)}dragReset(){pd.list=pd.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null,this.dragDataList=[]}checkDragEndAnimate(t,e){return!1}animate(t,e){}stopAnimate(){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}},Cd=ne.get("emit"),Od=["move","zoom","rotate","key"];function Rd(t,e,i,s,r){if(Od.some(t=>e.startsWith(t))&&t.__.hitChildren&&!Ld(t,r)){let o;for(let n=0,a=t.children.length;n<a;n++)o=t.children[n],!i.path.has(o)&&o.__.hittable&&Pd(o,e,i,s,r)}}function Pd(t,e,i,s,r){if(t.destroyed)return!1;if(t.__.hitSelf&&!Ld(t,r)&&(Ch.updateEventStyle&&!s&&Ch.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const r=ve.get(e,i);if(t.emitEvent(r,s),r.isStop)return!0}return!1}function Ld(t,e){return e&&e.has(t)}var Md={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{type:"pointer",snap:!0,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:Dd,pathCanDrag:Ad,pathHasOutside:Id}=xd,Wd=class{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&&ql.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&ql.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&Zl.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=E.clone(Md),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new ph(t),this.createTransformer(),this.dragger=new Td(this),s&&(this.config=E.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(ql.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(cd.BEFORE_DOWN,t),t.path.needUpdate&&this.updateDownData(t),this.emit(cd.DOWN,t),ql.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=ql.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&&ql.defaultLeft(t),(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(cd.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=_t.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(cd.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;ql.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(cd.BEFORE_UP,t),this.emit(cd.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(cd.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(cd.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;this.emit(wd.BEFORE_DOWN,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Zl.setDownCode(e),this.emit(wd.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(wd.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;this.emit(wd.BEFORE_UP,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]=!1,Zl.setUpCode(e),this.emit(wd.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new ph),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(cd.OUT,t,i),this.emit(cd.OVER,t,e)):this.emit(cd.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(cd.LEAVE,t,i,e),this.emit(cd.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(cd.LEAVE,t),this.dragger.dragging&&this.emit(gd.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,r=[cd.DOUBLE_TAP,cd.DOUBLE_CLICK].some(e=>Dd(t.path,e));s<e.tapTime+50&&r?(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(t,e){const{hitRadius:i,through:s}=this.p,{bottomList:r,target:o}=this;se.backgrounder||t.origin||o&&o.updateLayout();const n=this.selector.getByPoint(t,i,Object.assign({bottomList:r,name:t.type},e||{through:s}));return n.throughPath&&(t.throughPath=n.throughPath),t.path=n.path,n.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&&!Ad(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))}stopDragAnimate(){this.dragger.stopAnimate()}replaceDownTarget(t){const{downData:e}=this;if(e&&t){const{path:i}=e;i.remove(i.list[0]),i.addAt(t,0)}}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:cd.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 r=0,o=s.length;r<o&&(e=s.list[r],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);r++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:r}=this.canvas;return s.x*=r.width/i.width,s.y*=r.height/i.height,this.p.snap&&_t.round(s),s}emitTap(t){this.emit(cd.TAP,t),this.emit(cd.CLICK,t)}emitDoubleTap(t){this.emit(cd.DOUBLE_TAP,t),this.emit(cd.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(cd.LONG_PRESS,t)},this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(cd.LONG_TAP,t),(Dd(t.path,cd.LONG_TAP)||Dd(t.path,cd.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new qt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(y(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Xn.RESIZE,this.__onResize,this)],t.once(jn.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 r;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(r=i.list[o],Pd(r,t,e,!0,s))return;r.isApp&&Rd(r,t,e,!0,s)}for(let o=0,n=i.length;o<n;o++)if(r=i.list[o],r.isApp&&Rd(r,t,e,!1,s),Pd(r,t,e,!1,s))return}catch(t){Cd.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)}},zd=class{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}};zd.custom={};var Fd=class extends xe{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new ph,this.pixelList=new ph}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),ge.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),ge.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()}};se.getSelector=function(t){return t.leafer?t.leafer.selector:se.selector||(se.selector=ge.selector())};var{toInnerRadiusPointOf:Yd,copyRadiusPoint:Nd}=_t,{hitRadiusPoint:Xd,hitPoint:Hd}=jt,Vd={},Ud={},jd=ih.prototype;jd.hit=function(t,e=0){this.updateLayout(),Nd(Ud,t,e);const i=this.__world;return!!(e?Xd(i,Ud):Hd(i,Ud))&&(this.isBranch?se.getSelector(this).hitPoint(Object.assign({},Ud),e,{target:this}):this.__hitWorld(Ud))},jd.__hitWorld=function(t,e){const i=this.__;if(!i.hitSelf)return!1;const s=this.__world,r=this.__layout,o=s.width<10&&s.height<10;if(i.hitRadius&&(Nd(Vd,t,i.hitRadius),t=Vd),Yd(t,s,Vd),i.hitBox||o){if(jt.hitRadiusPoint(r.boxBounds,Vd))return!0;if(o)return!1}return!r.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),r.boundsChanged||(r.hitCanvasChanged=!1)),this.__hit(Vd,e)},jd.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},jd.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},jd.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},jd.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};var Gd=new bt,Kd=qh.prototype;Kd.__updateHitCanvas=function(){this.__box&&this.__box.__updateHitCanvas();const{hitCanvasManager:t}=this.leafer||this.parent&&this.parent.leafer||{};if(!t)return;const e=this.__,i=(e.__isAlphaPixelFill||e.__isCanvas)&&"pixel"===e.hitFill,s=e.__isAlphaPixelStroke&&"pixel"===e.hitStroke,r=i||s;this.__hitCanvas||(this.__hitCanvas=r?t.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):t.getPathType(this));const o=this.__hitCanvas;if(r){const{renderBounds:t}=this.__layout,r=se.image.hitCanvasSize,n=o.hitScale=$t.set(0,0,r,r).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=$t.set(t).scale(n);o.resize({width:l,height:d,pixelRatio:1}),o.clear(),no.patternLocked=!0,this.__renderShape(o,{matrix:Gd.setWith(this.__world).scaleWith(1/n).invertWith().translate(-a,-h),snapshot:!0,ignoreFill:!i,ignoreStroke:!s}),no.patternLocked=!1,o.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(o),o.setStrokeOptions(e)},Kd.__hit=function(t,e){if(this.__box&&this.__box.__hit(t))return!0;const i=this.__;if(i.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:s}=i,r=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__isAlphaPixelFill||i.__isCanvas))||"all"===s||e;if(r&&this.__hitFill(t))return!0;const{hitStroke:o,__maxStrokeWidth:n}=i,a=i.stroke&&("path"===o||"pixel"===o&&!i.__isAlphaPixelStroke)||"all"===o;if(!r&&!a)return!1;const h=2*t.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*n,!r&&this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h;break;case"center":l+=n;break;case"outside":if(l+=2*n,!r){if(!this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h}}return!!l&&this.__hitStroke(t,l)};var Zd=qh.prototype,qd=el.prototype,$d=al.prototype;qd.__updateHitCanvas=$d.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?Zd.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},qd.__hitFill=$d.__hitFill=function(t){return this.__hitCanvas?Zd.__hitFill.call(this,t):jt.hitRadiusPoint(this.__layout.boxBounds,t)},Hl.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:r,__textDrawData:o}=this.__;t.beginPath(),r<0?this.__drawPathByBox(t):o.rows.forEach(r=>t.rect(r.x,r.y-s,r.width,e<i?i:e))},Jh.prototype.pick=function(t,e){return e||(e=p),this.updateLayout(),se.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};var Jd,Qd=We.prototype;function tc(t,e,i,s){return new(i||(i=Promise))(function(r,o){function n(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?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,a)}h((s=s.apply(t,e||[])).next())})}Qd.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},Qd.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},Qd.hitPixel=function(t,e,i=1){let{x:s,y:r,radiusX:o,radiusY:n}=t;e&&(s-=e.x,r-=e.y),$t.set(s-o,r-n,2*o,2*n).scale(i).ceil();const{data:a}=this.context.getImageData($t.x,$t.y,$t.width||1,$t.height||1);for(let h=0,l=a.length;h<l;h+=4)if(a[h+3]>0)return!0;return a[3]>0},function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(Jd||(Jd={}));var ec=ne.get("LeaferCanvas"),ic=class extends We{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none",this.view.classList.add("leafer-canvas-view")}se.syncDomFont&&!this.parentView&&(i.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=f(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else ec.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.unreal||(this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i))}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),ec.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),se.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=se.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:i,y:s,width:r,height:o}=this.autoBounds.getBoundsFrom(t),n={width:r,height:o,pixelRatio:this.config.pixelRatio?this.pixelRatio:se.devicePixelRatio};if(!this.isSameSize(n)){const{style:t}=e;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(n)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};E.copyAttrs(e,this,Ie),this.resize(t),this.resizeListener&&!g(this.width)&&this.resizeListener(new Xn(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){let t=this.view;t&&t.remove(),t=this.view=document.createElement("div"),this.parentView.appendChild(this.view),t.classList.add("leafer-app-view"),this.unreal=!0}}destroy(){const{view:t}=this;t&&(this.stopAutoLayout(),this.stopListenPixelRatio(),t.parentElement&&t.remove(),super.destroy())}};$r(CanvasRenderingContext2D.prototype),$r(Path2D.prototype),Object.assign(ge,{canvas:(t,e)=>new ic(t,e),image:t=>new co(t)}),se.name="web",se.isMobile="ontouchstart"in window,se.requestRender=function(t){window.requestAnimationFrame(t)},uo(se,"devicePixelRatio",{get:()=>devicePixelRatio});var{userAgent:sc}=navigator;sc.indexOf("Firefox")>-1?(se.intWheelDeltaY=!0,se.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(se.fullImageShadow=!0),sc.indexOf("Windows")>-1?(se.os="Windows",se.intWheelDeltaY=!0):sc.indexOf("Mac")>-1?se.os="Mac":sc.indexOf("Linux")>-1&&(se.os="Linux");var rc=class{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new ph;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 ph,this.target=t,e&&(this.config=E.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(Un.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===Pn.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 i=0,s=e.length;i<s;i++)this.__pushChild(e[i])}__onRquestData(){this.target.emitEvent(new Hn(Hn.DATA,{updatedList:this.updatedList})),this.__updatedList=new ph,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Mn.CHANGE,this.__onAttrChange,this],[[Pn.ADD,Pn.REMOVE],this.__onChildEvent,this],[Hn.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}},{updateAllMatrix:oc,updateBounds:nc,updateChange:ac}=tn,{pushAllChildBranch:hc,pushAllParent:lc}=pn,{worldBounds:dc}=dn,cc=class{constructor(t){this.updatedBounds=new qt,this.beforeBounds=new qt,this.afterBounds=new qt,v(t)&&(t=new ph(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,dc)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,dc),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}},{updateAllMatrix:uc,updateAllChange:pc}=tn,gc=ne.get("Layouter"),_c=class t{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new gh,this.target=t,e&&(this.config=E.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(Vn.START),this.layoutOnce(),t.emitEvent(new Vn(Vn.END,this.layoutedBlocks,this.times))}catch(t){gc.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gc.warn("layouting"):this.times>3?gc.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Hn.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=de.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:r,LAYOUT:o,AFTER:n}=Vn,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Vn(r,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?(oc(t,!0),e.add(t),t.isBranch&&hc(t,e),lc(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),lc(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(r=>{e=t.levelMap[r];for(let t=0,o=e.length;t<o;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||nc(s[t])}nc(i)}})}(this.__levelList),function(t){t.list.forEach(ac)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Vn(o,a,this.times)),i.emitEvent(new Vn(n,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,de.end(e)}fullLayout(){const e=de.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:r,AFTER:o}=Vn,n=this.getBlocks(new ph(i));i.emitEvent(new Vn(s,n,this.times)),t.fullLayout(i),n.forEach(t=>{t.setAfter()}),i.emitEvent(new Vn(r,n,this.times)),i.emitEvent(new Vn(o,n,this.times)),this.addBlocks(n),de.end(e)}static fullLayout(t){uc(t,!0),t.isBranch?pn.updateBounds(t):tn.updateBounds(t),pc(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new cc([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new cc(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(){this.__eventIds=[this.target.on_([[Vn.REQUEST,this.layout,this],[Vn.AGAIN,this.layoutAgain,this],[Hn.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}},fc=ne.get("Renderer"),mc=class t{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=E.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.requestTime||this.__requestRender()}requestLayout(){this.target.emit(Vn.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Un.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Un.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Un.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new qt,fc.log(e.innerName,"---\x3e");try{this.emitRender(Un.START),this.renderOnce(t),this.emitRender(Un.END,this.totalBounds),no.clearRecycled()}catch(t){this.rendering=!1,fc.error(t)}fc.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return fc.warn("rendering");if(this.times>3)return fc.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new qt,this.renderOptions={},t)this.emitRender(Un.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Un.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Un.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Un.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(e){const i=de.start("PartRender"),{canvas:s}=this,r=e.getIntersect(s.bounds),o=new qt(r);s.save(),r.spread(t.clipSpread).ceil();const{ceilPartPixel:n}=this.config;s.clipWorld(r,n),s.clearWorld(r,n),this.__render(r,o),s.restore(),de.end(i)}fullRender(){const t=de.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),de.end(t)}__render(t,e){const{canvas:i,target:s}=this,r=t.includes(s.__world),o=r?{includes:r}:{bounds:t,includes:r};this.needFill&&i.fillWorld(t,this.config.fill),ne.showRepaint&&ne.drawRepaint(i,t),this.config.useCellRender&&(o.cellList=this.getCellList()),se.render(s,i,o),this.renderBounds=e=e||t,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new qt;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return se.requestRender(e);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};se.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new qt(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 qt(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||fc.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new Un(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Un.REQUEST,this.update,this],[Vn.END,this.__onLayoutEnd,this],[Un.AGAIN,this.renderAgain,this],[Xn.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}};mc.clipSpread=10;var yc={},{copyRadiusPoint:vc}=_t,{hitRadiusPoint:wc}=jt,xc=class{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,r=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 ph(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:n}=this.findList,a=this.getBestMatchLeaf(n,i.bottomList,r,!!i.findList),h=r?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:n.length?this.getThroughPath(n):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const r=this.findList=new ph;if(t.length){let e;const{x:s,y:o}=this.point,n={x:s,y:o,radiusX:0,radiusY:0};for(let a=0,h=t.length;a<h;a++)if(e=t[a],(i||tn.worldHittable(e))&&(this.hitChild(e,n),r.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&tn.hasParent(t,e))){r.reset();break}return r.list[0]}}if(e)for(let o=0,n=e.length;o<n;o++)if(this.hitChild(e[o].target,this.point,e[o].proxy),r.length)return r.list[0];return s?null:i?t[0]:t.find(t=>tn.worldHittable(t))}getPath(t){const e=new ph,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new ph;for(let r=e.list.length-1;r>-1&&(i=e.list[r],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));r--);return s}getThroughPath(t){const e=new ph,i=[];for(let n=t.length-1;n>-1;n--)i.push(this.getPath(t[n]));let s,r,o;for(let n=0,a=i.length;n<a;n++){s=i[n],r=i[n+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!r||!r.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,r;const{point:o}=this;for(let n=t.length-1;n>-1;n--)if(i=t[n],r=i.__,r.visible&&(!e||r.mask))if(s=wc(i.__world,r.hitRadius?vc(yc,o,r.hitRadius):o),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&r.__clipAfterFill&&!i.__hitWorld(o,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,o)}}else s&&this.hitChild(i,o)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,r=[];const{children:o}=s;for(let s=0,n=o.length;s<n;s++)if(i=o[s],i.__.mask&&r.push(i),i===t){if(r&&!r.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}},bc=class{constructor(t,e){this.config={},e&&(this.config=E.default(e,this.config)),this.picker=new xc(this.target=t,this),this.finder=ge.finder&&ge.finder(t,this.config)}getByPoint(t,e,i){const{target:s,picker:r}=this;return se.backgrounder&&s&&s.updateLayout(),r.getByPoint(t,e,i)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):pe.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}};Object.assign(ge,{watcher:(t,e)=>new rc(t,e),layouter:(t,e)=>new _c(t,e),renderer:(t,e,i)=>new mc(t,e,i),selector:(t,e)=>new bc(t,e)}),se.layout=_c.fullLayout,se.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new ph,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};var kc={convert(t,e){const i=xd.getBase(t),{x:s,y:r}=e,o=Object.assign(Object.assign({},i),{x:s,y:r,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=xd.getBase(t),{x:s,y:r}=e;return Object.assign(Object.assign({},i),{x:s,y:r,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=kc.getTouch(t),s=xd.getBase(t),{x:r,y:o}=e;return Object.assign(Object.assign({},s),{x:r,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Ec={convert(t){const e=xd.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:Sc}=xd,Bc=class extends Wd{get windowTarget(){const{view:t}=this;return t&&t.ownerDocument||window}get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let s in e)e[s]=e[s].bind(this),t.addEventListener(s,e[s]);for(let s in i)i[s]=i[s].bind(this),this.windowTarget.addEventListener(s,i[s])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let i in t)this.view.removeEventListener(i,t[i]),this.viewEvents={};for(let i in e)this.windowTarget.removeEventListener(i,e[i]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!(this.downData||t.target===this.view||this.config.shadowDOM&&t.composedPath&&t.composedPath().includes(this.view))}onKeyDown(t){this.keyDown(Ec.convert(t))}onKeyUp(t){this.keyUp(Ec.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(kc.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(kc.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=kc.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(kc.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(kc.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(kc.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(kc.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=kc.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Sc(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(kc.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=kc.getTouch(t);this.pointerMove(kc.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=kc.getTouch(t);this.pointerUp(kc.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(xd.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},xd.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=xd.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(X.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),w(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>w(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,v(t))t.forEach(t=>this.eachCursor(t,e,i));else{const s=f(t)&&zd.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}};function Tc(t,e,i){t.__.__font?bh.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Cc(t,e,i,s,r){const o=i.__;w(t)?bh.drawStrokesStyle(t,e,!1,i,s,r):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&bh.strokeArrow(t,i,s,r)}function Oc(t,e,i,s,r){const o=i.__;w(t)?bh.drawStrokesStyle(t,e,!0,i,s,r):(s.setStroke(t,o.__strokeWidth*e,o),bh.drawTextStroke(i,s,r))}function Rc(t,e,i,s,r){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,Oc(t,2,i,o,r),o.blendMode="outside"===e?"destination-out":"destination-in",bh.fillText(i,o,r),o.blendMode="normal",tn.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}var Pc,{getSpread:Lc,copyAndSpread:Mc,toOuterOf:Dc,getOuterOf:Ac,getByMove:Ic,move:Wc,getIntersectData:zc}=jt,Fc={},{stintSet:Yc}=E,{hasTransparent:Nc}=vh;function Xc(t,e,i){if(!w(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:r}=i.__layout,{type:o}=e;switch(o){case"image":case"film":case"video":if(!e.url)return;s=kh.image(i,t,e,r,!Pc||!Pc[e.url]),"image"!==o&&kh[o](s);break;case"linear":s=Eh.linearGradient(e,r);break;case"radial":s=Eh.radialGradient(e,r);break;case"angular":s=Eh.conicGradient(e,r);break;case"solid":const{color:n,opacity:a}=e;s={type:o,style:vh.string(n,a)};break;default:g(e.r)||(s={type:"solid",style:vh.string(e)})}if(s&&(s.originPaint=e,f(s.style)&&Nc(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}var Hc,Vc={compute:function(t,e){const i=e.__,s=[];let r,o,n,a=i.__input[t];v(a)||(a=[a]),Pc=kh.recycleImage(t,i);for(let h,l=0,d=a.length;l<d;l++)(h=Xc(t,a[l],e))&&(s.push(h),h.strokeStyle&&(n||(n=1),h.strokeStyle.strokeWidth&&(n=Math.max(n,h.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===t?(Yc(i,"__isAlphaPixelFill",r),Yc(i,"__isTransparentFill",o)):(Yc(i,"__isAlphaPixelStroke",r),Yc(i,"__isTransparentStroke",o),Yc(i,"__hasMultiStrokeStyle",n))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Tc(e,i,s)},fills:function(t,e,i,s){let r,o,n;for(let a=0,h=t.length;a<h;a++){if(r=t[a],o=r.originPaint,r.image){if(n?n++:n=1,kh.checkImage(r,!e.__.__font,e,i,s))continue;if(!r.style){1===n&&r.image.isPlacehold&&e.drawImagePlaceholder(r,i,s);continue}}if(i.fillStyle=r.style,r.transform||o.scaleFixed){if(i.save(),r.transform&&i.transform(r.transform),o.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,o.scaleFixed,!1);1!==t&&i.scale(t,s)}o.blendMode&&(i.blendMode=o.blendMode),Tc(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),Tc(e,i,s),i.restoreBlendMode()):Tc(e,i,s)}},fillPathOrText:Tc,fillText:function(t,e,i){const s=t.__,{rows:r,decorationY:o}=s.__textDrawData;let n;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let a=0,h=r.length;a<h;a++)n=r[a],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.fillText(t.char,t.x,n.y)});if(o){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),r.forEach(t=>o.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const r=e.__;if(r.__strokeWidth)if(r.__font)bh.strokeText(t,e,i,s);else if(r.__pathForStroke)bh.fillStroke(t,e,i,s);else switch(r.strokeAlign){case"center":Cc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Cc(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const r=e.__;if(r.__fillAfterStroke)Cc(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,n=i.getSameCanvas(!0,!0);e.__drawRenderPath(n),Cc(t,2,e,n,s),n.clipUI(r),n.clearWorld(o),tn.copyCanvasByWorld(e,i,n),n.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){bh.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Oc(t,1,e,i,s);break;case"inside":Rc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Oc(t,2,e,i,s):Rc(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,r=t.__.__textDrawData;const{rows:o,decorationY:n}=r;for(let a=0,h=o.length;a<h;a++)s=o[a],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(n){const{decorationHeight:t}=r;o.forEach(i=>n.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,r,o){let n;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||r.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,d=t.length;l<d;l++)if(n=t[l],(!n.image||!kh.checkImage(n,!1,s,r,o))&&n.style){if(h){const{strokeStyle:t}=n;t?r.setStroke(n.style,a.__getRealStrokeWidth(t)*e,a,t):r.setStroke(n.style,a.__strokeWidth*e,a)}else r.strokeStyle=n.style;n.originPaint.blendMode?(r.saveBlendMode(n.originPaint.blendMode),i?bh.drawTextStroke(s,r,o):r.stroke(),r.restoreBlendMode()):i?bh.drawTextStroke(s,r,o):r.stroke()}},shape:function(t,e,i){const s=e.getSameCanvas(),r=e.bounds,o=t.__nowWorld,n=t.__layout,a=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let h,l,d,c,u,p;Dc(n.strokeSpread?(Mc(Fc,n.boxBounds,n.strokeSpread),Fc):n.boxBounds,o,a);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(r.includes(a))p=s,h=u=a,l=o;else{let s;s=se.fullImageShadow?a:zc(n.renderShapeSpread?Lc(r,P.swapAndScale(n.renderShapeSpread,g,_)):r,a),c=r.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,i),g*=f,_*=m),u=Ac(a,c),h=Ic(u,-c.e,-c.f),l=Ac(o,c),Wc(l,-c.e,-c.f);const y=i.matrix;y?(d=new bt(c),d.multiply(y),f*=y.scaleX,m*=y.scaleY):d=c,d.withScale(f,m),i=Object.assign(Object.assign({},i),{matrix:d})}return t.__renderShape(s,i),{canvas:s,matrix:d,fitMatrix:c,bounds:h,renderBounds:l,worldCanvas:p,shapeBounds:u,scaleX:g,scaleY:_}}},Uc=new qt,{isSame:jc}=jt;function Gc(t,e,i,s,r,o){let n=!0;const a=t.__;if("fill"!==e||a.__naturalWidth||(a.__naturalWidth=s.width/a.pixelRatio,a.__naturalHeight=s.height/a.pixelRatio,a.__autoSide&&(t.forceUpdate("width"),tn.updateBounds(t),t.__proxyData&&(t.setProxyAttr("width",a.width),t.setProxyAttr("height",a.height)),n=!1)),!r.data){kh.createData(r,s,i,o);const{transform:t}=r.data,{opacity:e,blendMode:n}=i,h=t&&!t.onlyScale||a.path||a.cornerRadius;(h||e&&e<1||n)&&(r.complex=!h||2)}return i.filter&&kh.applyFilter(r,s,i.filter,t),n}function Kc(t,e){$c(t,An.LOAD,e)}function Zc(t,e){$c(t,An.LOADED,e)}function qc(t,e,i){e.error=i,t.forceUpdate("surface"),$c(t,An.ERROR,e)}function $c(t,e,i){t.hasEvent(e)&&t.emitEvent(new An(e,i))}function Jc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}var{get:Qc,translate:tu}=st,eu=new qt,iu={},su={};function ru(t,e,i,s){const r=f(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&r<0?0:r}var ou={},nu={a:1,b:0,c:0,d:1,e:0,f:0},{get:au,set:hu,rotateOfOuter:lu,translate:du,scaleOfOuter:cu,multiplyParent:uu,scale:pu,rotate:gu,skew:_u}=st;function fu(t,e,i,s,r,o,n,a){n&&gu(t,n),a&&_u(t,a.x,a.y),r&&pu(t,r,o),du(t,e.x+i,e.y+s)}var{get:mu,scale:yu,copy:vu}=st,{getFloorScale:wu}=X,{abs:xu}=Math,bu={image:function(t,e,i,s,r){let o,n;const a=no.get(i,i.type);return Hc&&i===Hc.paint&&jc(s,Hc.boxBounds)?o=Hc.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Hc=a.use>1?{leafPaint:o,paint:i,boxBounds:Uc.set(s)}:null),(r||a.loading)&&(n={image:a,attrName:e,attrValue:i}),a.ready?(Gc(t,e,i,a,o,s),r&&(Kc(t,n),Zc(t,n))):a.error?r&&qc(t,n,a.error):(r&&(Jc(t,!0),Kc(t,n)),o.loadId=a.load(()=>{Jc(t,!1),t.destroyed||(Gc(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Zc(t,n)),o.loadId=void 0},e=>{Jc(t,!1),qc(t,n,e),o.loadId=void 0},i.lod&&a.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,i,s,r){const{scaleX:o,scaleY:n}=kh.getImageRenderScaleData(t,i,s,r),a=t.film?t.nowIndex:o+"-"+n,{image:h,data:l,originPaint:d}=t,{exporting:c,snapshot:u}=r;return!(!l||t.patternId===a&&!c||u||(e&&(l.repeat?e=!1:d.changeful||t.film||"miniapp"===se.name||c||(e=se.image.isLarge(h,o,n)||h.width*o>8096||h.height*n>8096)),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),kh.drawImage(t,o,n,i,s,r),0):(!t.style||d.sync||c?kh.createPattern(t,i,s,r):kh.createPatternTask(t,i,s,r),1)))},drawImage:function(t,e,i,s,r,o){const{data:n,image:a,complex:h}=t;let{width:l,height:d}=a;if(h){const{blendMode:o,opacity:c}=t.originPaint,{transform:u}=n;r.save(),2===h&&r.clipUI(s),o&&(r.blendMode=o),c&&(r.opacity*=c),u&&r.transform(u),a.render(r,0,0,l,d,s,t,e,i),r.restore()}else n.scaleX&&(l*=n.scaleX,d*=n.scaleY),a.render(r,0,0,l,d,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const r=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:o}=t;if(i){const{pixelRatio:t}=i;r.scaleX*=t,r.scaleY*=t}return o&&o.scaleX&&(r.scaleX*=Math.abs(o.scaleX),r.scaleY*=Math.abs(o.scaleY)),r},recycleImage:function(t,e){const i=e["_"+t];if(v(i)){let s,r,o,n,a;for(let h=0,l=i.length;h<l;h++)s=i[h],r=s.image,a=r&&r.url,a&&(o||(o={}),o[a]=!0,no.recyclePaint(s),e.__willDestroy&&r.parent&&kh.recycleFilter(r,e.__leaf),r.loading&&(n||(n=e.__input&&e.__input[t]||[],v(n)||(n=[n])),r.unload(i[h].loadId,!n.some(t=>t.url===a))));return o}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=no.patternTasker.add(()=>tc(this,void 0,void 0,function*(){kh.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,i,s){let{scaleX:r,scaleY:o}=kh.getImageRenderScaleData(t,e,i,s),n=t.film?t.nowIndex:r+"-"+o;if(t.patternId!==n&&!e.destroyed&&(!se.image.isLarge(t.image,r,o)||t.data.repeat)){const{image:i,data:s}=t,{opacity:a}=t.originPaint,{transform:h,gap:l}=s,d=kh.getPatternFixScale(t,r,o);let c,u,p,{width:g,height:_}=i;d&&(r*=d,o*=d),g*=r,_*=o,l&&(u=l.x*r/xu(s.scaleX||1),p=l.y*o/xu(s.scaleY||1)),(h||1!==r||1!==o)&&(r*=wu(g+(u||0)),o*=wu(_+(p||0)),c=mu(),h&&vu(c,h),yu(c,1/r,1/o));const f=i.getCanvas(g,_,a,void 0,u,p,e.leafer&&e.leafer.config.smooth,s.interlace);t.style=i.getPattern(f,s.repeat||se.origin.noRepeat||"no-repeat",c,t),t.patternId=n}},getPatternFixScale:function(t,e,i){const{image:s}=t;let r,o=se.image.maxPatternSize,n=s.width*s.height;return s.isSVG?e>1&&(r=Math.ceil(e)/e):o>n&&(o=n),(n*=e*i)>o&&(r=Math.sqrt(o/n)),r},createData:function(t,e,i,s){t.data=kh.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=eu.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:r}=i,{mode:o,align:n,offset:a,scale:h,size:l,rotation:d,skew:c,clipSize:u,repeat:p,gap:g,interlace:_}=t,m=e.width===s&&e.height===r,v={mode:o},x="center"!==n&&(d||0)%180==90;let b,k;switch(jt.set(su,0,0,x?r:s,x?s:r),o&&"cover"!==o&&"fit"!==o?((h||l)&&(X.getScaleData(h,l,i,iu),b=iu.scaleX,k=iu.scaleY),(n||g||p)&&(b&&jt.scale(su,b,k,!0),n&&Mt.toPoint(n,su,e,su,!0,!0))):m&&!d||(b=k=jt.getFitScale(e,su,"fit"!==o),jt.put(e,i,n,b,!1,su),jt.scale(su,b,k,!0)),a&&_t.move(su,a),o){case"stretch":m?b&&(b=k=void 0):(b=e.width/s,k=e.height/r,kh.stretchMode(v,e,b,k));break;case"normal":case"clip":if(su.x||su.y||b||u||d||c){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),kh.clipMode(v,e,su.x,su.y,b,k,d,c,t,i),t&&(b=b?b*t:t,k=k?k*i:i)}break;case"repeat":(!m||b||d||c)&&kh.repeatMode(v,e,s,r,su.x,su.y,b,k,d,c,n,t.freeTransform),p||(v.repeat="repeat");const i=w(p);(g||i)&&(v.gap=function(t,e,i,s,r){let o,n;return w(t)?(o=t.x,n=t.y):o=n=t,{x:ru(o,i,r.width,e&&e.x),y:ru(n,s,r.height,e&&e.y)}}(g,i&&p,su.width,su.height,e));break;default:b&&kh.fillOrFitMode(v,e,su.x,su.y,b,k,d)}return v.transform||(e.x||e.y)&&tu(v.transform=Qc(),e.x,e.y),b&&(v.scaleX=b,v.scaleY=k),p&&(v.repeat=f(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),_&&(v.interlace=y(_)||"percent"===_.type?{type:"x",offset:_}:_),v},stretchMode:function(t,e,i,s){const r=au(),{x:o,y:n}=e;o||n?du(r,o,n):i>0&&s>0&&(r.onlyScale=!0),pu(r,i,s),t.transform=r},fillOrFitMode:function(t,e,i,s,r,o,n){const a=au();du(a,e.x+i,e.y+s),pu(a,r,o),n&&lu(a,{x:e.x+e.width/2,y:e.y+e.height/2},n),t.transform=a},clipMode:function(t,e,i,s,r,o,n,a,h,l){const d=au();fu(d,e,i,s,r,o,n,a),h&&(n||a?(hu(nu),cu(nu,e,h,l),uu(d,nu)):cu(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,r,o,n,a,h,l,d,c){const u=au();if(c)fu(u,e,r,o,n,a,h,l);else{if(h)if("center"===d)lu(u,{x:i/2,y:s/2},h);else switch(gu(u,h),h){case 90:du(u,s,0);break;case 180:du(u,i,s);break;case 270:du(u,0,i)}ou.x=e.x+r,ou.y=e.y+o,du(u,ou.x,ou.y),n&&cu(u,ou,n,a)}t.transform=u}},{toPoint:ku}=Bt,{hasTransparent:Eu}=vh,Su={},Bu={};function Tu(t,e,i,s){if(i){let r,o,n,a;for(let t=0,h=i.length;t<h;t++)r=i[t],f(r)?(n=t/(h-1),o=vh.string(r,s)):(n=r.offset,o=vh.string(r.color,s)),e.addColorStop(n,o),!a&&Eu(o)&&(a=!0);a&&(t.isTransparent=!0)}}var{getAngle:Cu,getDistance:Ou}=_t,{get:Ru,rotateOfOuter:Pu,scaleOfOuter:Lu}=st,{toPoint:Mu}=Bt,Du={},Au={};function Iu(t,e,i,s,r){let o;const{width:n,height:a}=t;if(n!==a||s){const t=Cu(e,i);o=Ru(),r?(Lu(o,e,n/a*(s||1),1),Pu(o,e,t+90)):(Lu(o,e,1,n/a*(s||1)),Pu(o,e,t))}return o}var{getDistance:Wu}=_t,{toPoint:zu}=Bt,Fu={},Yu={},Nu={linearGradient:function(t,e){let{from:i,to:s,type:r,opacity:o}=t;ku(i||"top",e,Su),ku(s||"bottom",e,Bu);const n=se.canvas.createLinearGradient(Su.x,Su.y,Bu.x,Bu.y),a={type:r,style:n};return Tu(a,n,t.stops,o),a},radialGradient:function(t,e){let{from:i,to:s,type:r,opacity:o,stretch:n}=t;Mu(i||"center",e,Du),Mu(s||"bottom",e,Au);const a=se.canvas.createRadialGradient(Du.x,Du.y,0,Du.x,Du.y,Ou(Du,Au)),h={type:r,style:a};Tu(h,a,t.stops,o);const l=Iu(e,Du,Au,n,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:r,opacity:o,rotation:n,stretch:a}=t;zu(i||"center",e,Fu),zu(s||"bottom",e,Yu);const h=se.conicGradientSupport?se.canvas.createConicGradient(n?n*V:0,Fu.x,Fu.y):se.canvas.createRadialGradient(Fu.x,Fu.y,0,Fu.x,Fu.y,Wu(Fu,Yu)),l={type:r,style:h};Tu(l,h,t.stops,o);const d=Iu(e,Fu,Yu,a||1,se.conicGradientRotate90);return d&&(l.transform=d),l},getTransform:Iu},{copy:Xu,move:Hu,toOffsetOutBounds:Vu}=jt,{max:Uu,abs:ju}=Math,Gu={},Ku=new bt,Zu={};function qu(t,e){let i,s,r,o,n=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,o=1.5*(t.blur||0),r=ju(t.spread||0),n=Uu(n,r+o-s),a=Uu(a,r+o+i),h=Uu(h,r+o+s),l=Uu(l,r+o-i)}),n===a&&a===h&&h===l?n:[n,a,h,l]}function $u(t,e,i){const{shapeBounds:s}=i;let r,o;se.fullImageShadow?(Xu(Gu,t.bounds),Hu(Gu,e.x-s.x,e.y-s.y),r=t.bounds,o=Gu):(r=s,o=e),t.copyWorld(i.canvas,r,o)}var Ju,{toOffsetOutBounds:Qu}=jt,tp={},ep={shadow:function(t,e,i){let s,r;const{__nowWorld:o}=t,{shadow:n}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=n.length-1;Vu(h,Zu,l),n.forEach((n,_)=>{let f=1;if(n.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}p.setWorldShadow(Zu.offsetX+(n.x||0)*c*f,Zu.offsetY+(n.y||0)*u*f,(n.blur||0)*c*f,vh.string(n.color)),r=Sh.getShadowTransform(t,p,i,n,Zu,f),r&&p.setTransform(r),$u(p,Zu,i),r&&p.resetTransform(),s=l,n.box&&(p.restore(),p.save(),a&&(p.copyWorld(p,l,o,"copy"),s=o),a?p.copyWorld(a,o,o,"destination-out"):p.copyWorld(i.canvas,d,h,"destination-out")),tn.copyCanvasByWorld(t,e,p,s,n.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,r;const{__nowWorld:o}=t,{innerShadow:n}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=n.length-1;Qu(h,tp,l),n.forEach((n,_)=>{let f=1;if(n.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}p.save(),p.setWorldShadow(tp.offsetX+(n.x||0)*c*f,tp.offsetY+(n.y||0)*u*f,(n.blur||0)*c*f),r=Sh.getShadowTransform(t,p,i,n,tp,f,!0),r&&p.setTransform(r),$u(p,tp,i),p.restore(),a?(p.copyWorld(p,l,o,"copy"),p.copyWorld(a,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,d,h,"source-out"),s=l),p.fillWorld(s,vh.string(n.color),"source-in"),tn.copyCanvasByWorld(t,e,p,s,n.blendMode),g&&_<g&&p.clearWorld(s)}),p.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){},getShadowRenderSpread:qu,getShadowTransform:function(t,e,i,s,r,o,n){if(s.spread){const i=2*s.spread*o*(n?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return Ku.set().scaleOfOuter({x:(r.x+r.width/2)*e.pixelRatio,y:(r.y+r.height/2)*e.pixelRatio},1+i/a,1+i/h),Ku}},isTransformShadow(t){},getInnerShadowSpread:qu},{excludeRenderBounds:ip}=dn;function sp(t,e,i,s,r,o,n,a){switch(e){case"grayscale":Ju||(Ju=!0,r.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,r,o){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),o&&s.recycle(n),op(t,e,i,1,r,o)}(t,i,s,r,n,a);break;case"opacity-path":op(t,i,s,o,n,a);break;case"path":a&&i.restore()}}function rp(t){return t.getSameCanvas(!1,!0)}function op(t,e,i,s,r,o){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n,void 0,r),o?i.recycle(n):i.clearWorld(n)}Jh.prototype.__renderMask=function(t,e){let i,s,r,o,n,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){n&&(sp(this,n,t,r,s,o,void 0,!0),s=r=null),"clipping"!==a&&"clipping-path"!==a||ip(i,e)||i.__render(t,e),o=i.__.opacity,Ju=!1,"path"===a||"clipping-path"===a?(o<1?(n="opacity-path",r||(r=rp(t))):(n="path",t.save()),i.__clip(r||t,e)):(n="grayscale"===a?"grayscale":"alpha",s||(s=rp(t)),r||(r=rp(t)),i.__render(s,e));continue}const d=1===o&&i.__.__blendMode;d&&sp(this,n,t,r,s,o,void 0,!1),ip(i,e)||i.__render(r||t,e),d&&sp(this,n,t,r,s,o,d,!1)}sp(this,n,t,r,s,o,void 0,!0)};var np=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 ap(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}var hp,lp=ap("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),dp=ap("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),cp=ap(">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰"),up=ap(">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰_#~&*+\\=|≮≯≈≠=…"),pp=ap("- —/~|┆·");!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"}(hp||(hp={}));var{Letter:gp,Single:_p,Before:fp,After:mp,Symbol:yp,Break:vp}=hp;function wp(t){return lp[t]?gp:pp[t]?vp:dp[t]?fp:cp[t]?mp:up[t]?yp:np.test(t)?_p:gp}var xp={trimRight(t){const{words:e}=t;let i,s=0,r=e.length;for(let o=r-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(r-s,s)}};function bp(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}}var kp,Ep,Sp,Bp,Tp,Cp,Op,Rp,Pp,Lp,Mp,Dp,Ap,Ip,Wp,zp,Fp,{trimRight:Yp}=xp,{Letter:Np,Single:Xp,Before:Hp,After:Vp,Symbol:Up,Break:jp}=hp,Gp=[];function Kp(t,e){Pp&&!Rp&&(Rp=Pp),kp.data.push({char:t,width:e}),Sp+=e}function Zp(){Bp+=Sp,kp.width=Sp,Ep.words.push(kp),kp={data:[]},Sp=0}function qp(){Ip&&(Wp.paraNumber++,Ep.paraStart=!0,Ip=!1),Pp&&(Ep.startCharSize=Rp,Ep.endCharSize=Pp,Rp=0),Ep.width=Bp,zp.width?Yp(Ep):Fp&&$p(),Gp.push(Ep),Ep={words:[]},Bp=0}function $p(){Bp>(Wp.maxWidth||0)&&(Wp.maxWidth=Bp)}var{top:Jp,right:Qp,bottom:tg,left:eg}=et;function ig(t,e,i){const{bounds:s,rows:r}=t;s[e]+=i;for(let o=0;o<r.length;o++)r[o][e]+=i}Object.assign(yh,{getDrawData:function(t,e){f(t)||(t=String(t));let i=0,s=0,r=e.__getInput("width")||0,o=e.__getInput("height")||0;const{__padding:n}=e;n&&(r?(i=n[eg],r-=n[Qp]+n[eg],!r&&(r=.01)):e.autoSizeAlign||(i=n[eg]),o?(s=n[Jp],o-=n[Jp]+n[tg],!o&&(o=.01)):e.autoSizeAlign||(s=n[Jp]));const a={bounds:{x:i,y:s,width:r,height:o},rows:[],paraNumber:0,font:se.canvas.font=e.__font};return function(t,e,i){Wp=t,Gp=t.rows,Fp=!(zp=t.bounds).width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:r,textCase:o}=i,{canvas:n}=se,{width:a}=zp;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;Ip=!0,Mp=null,Rp=Op=Pp=Sp=Bp=0,kp={data:[]},Ep={words:[]};for(let i=0,l=(e=[...e]).length;i<l;i++)"\n"===(Cp=e[i])?(Sp&&Zp(),Ep.paraEnd=!0,qp(),Ip=!0):((Lp=wp(Cp))===Np&&"none"!==o&&(Cp=bp(Cp,o,!Sp)),Op=n.measureText(Cp).width,s&&(s<0&&(Pp=Op),Op+=s),Dp=Lp===Xp&&(Mp===Xp||Mp===Np)||Mp===Xp&&Lp!==Vp,Ap=!(Lp!==Hp&&Lp!==Xp||Mp!==Up&&Mp!==Vp),Tp=Ip&&r?a-r:a,t&&a&&Bp+Sp+Op>Tp&&(h?(Sp&&Zp(),Bp&&qp()):(Ap||(Ap=Lp===Np&&Mp==Vp),Dp||Ap||Lp===jp||Lp===Hp||Lp===Xp||Sp+Op>Tp?(Sp&&Zp(),Bp&&qp()):Bp&&qp()))," "===Cp&&!0!==Ip&&Bp+Sp===0||(Lp===jp?(" "===Cp&&Sp&&Zp(),Kp(Cp,Op),Zp()):Dp||Ap?(Sp&&Zp(),Kp(Cp,Op)):Kp(Cp,Op)),Mp=Lp);Sp&&Zp(),Bp&&qp(),Gp.length>0&&(Gp[Gp.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Wp.paraNumber++,Bp=n.measureText(t).width,Gp.push({x:r||0,text:t,width:Bp,paraStart:!0}),Fp&&$p()})}(a,t,e),n&&function(t,e,i,s,r){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ig(e,"x",t[eg]);break;case"right":ig(e,"x",-t[Qp])}if(!r&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ig(e,"y",t[Jp]);break;case"bottom":ig(e,"y",-t[tg])}}(n,a,e,r,o),function(t,e){const{rows:i,bounds:s}=t,r=i.length,{__lineHeight:o,__baseLine:n,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:p,y:g,width:_,height:f}=s,m=o*r+(c?c*(t.paraNumber-1):0),y=n;if(h&&m>f)m=Math.max(e.__autoHeight?m:f,o),r>1&&(t.overflow=r);else if(f||u)switch(d){case"middle":g+=(f-m)/2;break;case"bottom":g+=f-m}y+=g;let v,w,x,b=_||u?_:t.maxWidth;for(let k=0,E=r;k<E;k++){if(v=i[k],v.x=p,v.width<_||v.width>_&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&k>0&&(y+=c),v.y=y,y+=o,t.overflow>k&&y>m&&(v.isOverflow=!0,t.overflow=k+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&&_&&_<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(a,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:r,paraIndent:o,__letterSpacing:n}=e,a=i&&r.includes("both"),h=a||i&&r.includes("justify"),l=h&&r.includes("letter");let d,c,u,p,g,_,f,m,y,v;s.forEach(t=>{t.words&&(g=o&&t.paraStart?o:0,m=t.words.length,h&&(v=!t.paraEnd||a,c=i-t.width-g,l?p=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),_=n||t.isOverflow||l?0:u?1:2,t.isOverflow&&!n&&(t.textMode=!0),2===_?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===_?(f={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,f),(t.isOverflow||" "!==f.char)&&t.data.push(f)):d=function(t,e,i,s,r){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,r&&(e+=r)}),e}(e.data,d,t.data,t.isOverflow,v&&p),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):p&&(t.width+=p*(e.data.length-(y?1:0))))})),t.words=null)})}(a,e,r),a.overflow&&function(t,e,i,s){const{rows:r,overflow:o}=t;let{textOverflow:n}=e;if(o&&r.splice(o),s&&n&&"show"!==n){let t,a;"hide"===n?n="":"ellipsis"===n&&(n="...");const h=n?se.canvas.measureText(n).width:0,l=i+s-h;("none"===e.textWrap?r:[r[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<l));s--){if(a<l&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,e.data.push({char:n,x:a}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(a,e,i,r),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:r,textDecoration:o}=e;switch(t.decorationHeight=r/11,w(o)?(i=o.type,o.color&&(t.decorationColor=vh.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):i=o,i){case"under":t.decorationY=[.15*r+s];break;case"delete":t.decorationY=[.35*-r];break;case"under-delete":t.decorationY=[.15*r+s,.35*-r]}}(a,e),a}}),Object.assign(vh,{string:function(t,e){if(!t)return"#000";const i=y(e)&&e<1;if(f(t)){if(!i||!vh.object)return t;t=vh.object(t)}let s=g(t.a)?1:t.a;i&&(s*=e);const r=t.r+","+t.g+","+t.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}}),Object.assign(bh,Vc),Object.assign(kh,bu),Object.assign(Eh,Nu),Object.assign(Sh,ep),Object.assign(ge,{interaction:(t,e,i,s)=>new Bc(t,e,i,s),hitCanvas:(t,e)=>new ic(t,e),hitCanvasManager:()=>new Fd}),se.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=Jr.mimeType(e),r=t.toDataURL(s,i);return"image/bmp"===s?r.replace("image/png;","image/bmp;"):r},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,Jr.mimeType(e),i)),canvasSaveAs:(t,e,i)=>{const s=t.toDataURL(Jr.mimeType(Jr.fileType(e)),i);return se.origin.download(s,e)},download(t,e){return tc(this,void 0,void 0,function*(){let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i)})},loadImage:(t,e,i)=>new Promise((i,s)=>{const r=new se.origin.Image;e&&(r.setAttribute("crossOrigin",e),r.crossOrigin=e),r.onload=()=>{i(r)},r.onerror=t=>{s(t)},r.src=se.image.getRealURL(t)}),loadContent(t){return tc(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})},Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},se.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},se.canvas=ge.canvas(),se.conicGradientSupport=!!se.canvas.context.createConicGradient;var{M:sg,L:rg,C:og,Q:ng,Z:ag,N:hg,D:lg,X:dg,G:cg,F:ug,O:pg,P:gg,U:_g}=Ye,fg={scale(t,e,i){if(!t)return;let s,r=0,o=t.length;for(;r<o;)switch(s=t[r],s){case sg:case rg:mg(t,e,i,r,1),r+=3;break;case og:mg(t,e,i,r,3),r+=7;break;case ng:mg(t,e,i,r,2),r+=5;break;case ag:r+=1;break;case hg:mg(t,e,i,r,2),r+=5;break;case lg:mg(t,e,i,r,2),r+=9;break;case dg:mg(t,e,i,r,2),r+=6;break;case cg:mg(t,e,i,r,2),r+=9;break;case ug:mg(t,e,i,r,2),r+=5;break;case pg:t[r]=cg,t.splice(r+4,0,t[r+3],0),mg(t,e,i,r,2),r+=9,o+=2;break;case gg:t[r]=ug,t.splice(r+4,0,t[r+3]),mg(t,e,i,r,2),r+=5,o+=1;break;case _g:mg(t,e,i,r,2),r+=6}},scalePoints(t,e,i,s,r){for(let o=r?s+1:0,n=r?o+2*r:t.length;o<n;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:mg}=fg,yg=st.get(),{topLeft:vg,top:wg,topRight:xg,right:bg,bottom:kg,left:Eg}=it;function Sg(t,e,i){t.pathInputed?Tg(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function Bg(t,e,i,s){let r=e;if(!g(s)){const o=t.__layout;let{width:n,height:a}=o.boxBounds;switch(n*=i-e,a*=e-i,s){case wg:case kg:r=i,o.affectScaleOrRotation?t.moveInner(-n/2,0):t.x-=n/2;break;case Eg:case bg:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case vg:case xg:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=r;const o=t.__,{padding:n,lineHeight:a,letterSpacing:h}=o;n&&(t.padding=v(n)?n.map(t=>t*r):n*r),o.__autoWidth||(t.width*=r),o.__autoHeight||(t.height*=r),w(a)?"px"===a.type&&(o.lineHeight={type:"px",value:a.value*r}):a&&(o.lineHeight=a*r),w(h)?"px"===h.type&&(o.letterSpacing={type:"px",value:h.value*r}):h&&(o.letterSpacing=h*r)}function Tg(t,e,i){fg.scale(t.__.path,e,i),t.path=t.__.path}function Cg(t,e,i){const{points:s}=t;w(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):fg.scalePoints(s,e,i),t.points=s}function Og(t,e,i){const{children:s}=t;for(let r=0;r<s.length;r++)yg.a=e,yg.d=i,s[r].transform(yg,!0)}var Rg=ih.prototype;function Pg(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}function Lg(t){return t?v(t)?t:[t]:[]}Rg.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))},Rg.__scaleResize=function(t,e){Sg(this,t,e)},Rg.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},Rg.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},Hl.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,r=i&&i.editor,o=r&&r.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===r.mergedConfig.editSize)Bg(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:r,verticalAlign:o}=this.__,{boxBounds:n}=this.__layout;i&&"left"!==r&&1!==t&&(this.x+=n.x),s&&"top"!==o&&1!==e&&(this.y+=n.y),Sg(this,t,e)}},Vl.prototype.__scaleResize=function(t,e){Tg(this,t,e)},Al.prototype.__scaleResize=function(t,e){this.pathInputed?Tg(this,t,e):this.points?Cg(this,t,e):this.width*=t},wl.prototype.__scaleResize=function(t,e){this.pathInputed?Tg(this,t,e):this.points?Cg(this,t,e):Sg(this,t,e)},Jh.prototype.__scaleResize=function(t,e){Og(this,t,e)},al.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||Sg(this,t,e),i&&Og(this,t,e)},pe.add("resize");var Mg=class extends Rn{get list(){return Lg(this.value)}get oldList(){return Lg(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}};function Dg(t){return(e,i)=>{const s="_"+i;uo(e,i,{get(){return this[s]},set(e){const r=this[s];if(r!==e){const o=this;if(o.config){const t="target"===i;if(t){const{beforeSelect:t}=o.config;if(t){const i=t({target:e});if(w(i))e=i;else if(!1===i)return}o.hasDimOthers&&o.cancelDimOthers(),v(e)&&e.length>1&&e[0].locked&&e.splice(0,1),o.single&&(delete o.element.syncEventer,delete o.element.__world.ignorePixelSnap)}const s=t?Mg.BEFORE_SELECT:Mg.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new Mg(s,{editor:o,value:e,oldValue:r}))}this[s]=e,t(this,r)}}})}}Mg.BEFORE_SELECT="editor.before_select",Mg.SELECT="editor.select",Mg.AFTER_SELECT="editor.after_select",Mg.BEFORE_HOVER="editor.before_hover",Mg.HOVER="editor.hover";var{abs:Ag}=Math,{copy:Ig}=st,{setListWithFn:Wg}=jt,{worldBounds:zg}=dn,Fg={a:1,b:0,c:0,d:1,e:0,f:0},Yg={x:0,y:0,width:0,height:0},Ng=class extends qh{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(Wg(Yg,e,zg),t&&this.set(t),this.set(Yg),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const r=this.__,{stroke:o,strokeWidth:n,fill:a}=r,{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=Ag(d.scaleX),h=Ag(d.scaleY);if(Ig(Fg,d),Fg.half=n%2,t.setWorld(Fg,e.matrix),t.beginPath(),"path"===this.strokePathType||s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),r.strokeWidth=n/Math.max(i,h),r.shadow){const e=r.shadow[0],{scaleX:i,scaleY:s}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*s,e.blur*i,vh.string(e.color))}o&&(f(o)?bh.stroke(o,this,t,e):bh.strokes(o,this,t,e)),a&&(f(a)?bh.fill(a,this,t,e):bh.fills(a,this,t,e)),r.shadow&&t.restore()}}r.strokeWidth=n}}destroy(){this.target=null,super.destroy()}};Pg([Dg(function(t){const e=t.target;t.list=e?v(e)?e:[e]:[]})],Ng.prototype,"target",void 0),Pg([To("render-path")],Ng.prototype,"strokePathType",void 0);var Xg=class extends Jh{constructor(t){super(t),this.strokeArea=new el({strokeAlign:"center"}),this.fillArea=new el,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:r}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:r},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}},Hg={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return Vg([t],i,e),i}};function Vg(t,e,i){let s,r;for(let o=0,n=t.length;o<n;o++)if(s=t[o],r=s.__,r.hittable&&r.visible&&!r.locked&&i.hit(s.__world)){if(r.editable){if(s.isBranch&&!r.hitChildren){r.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)&&r.hitSelf&&e.push(s)}s.isBranch&&Vg(s.children,e,i)}}var{findOne:Ug,findByBounds:jg}=Hg,Gg=class extends Jh{get dragging(){return!!this.originList}get running(){const{editor:t,app:e}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&e&&"normal"===e.mode}get isMoveMode(){const{app:t}=this;return t&&t.interaction.moveMode}constructor(t){super(),this.hoverStroker=new Ng,this.targetStroker=new Ng,this.bounds=new qt,this.selectArea=new Xg,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{hoverTarget:e,mergeConfig:i}=t,s=Object.assign({},i);e&&e.editConfig&&Object.assign(s,e.editConfig);const{stroke:r,strokeWidth:o,hover:n,hoverStyle:a}=s;this.hoverStroker.setTarget(n?e:null,Object.assign({stroke:r,strokeWidth:o},a||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedPathType:i,selectedStyle:s}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2),strokePathType:i},s||{}))}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,selectKeep:s}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(s||(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,t.path.needUpdate=!0):this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||this.editor.mergedConfig.selectKeep||(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:r,y:o}=t.getInnerPoint(this);this.bounds.set(r,o),this.selectArea.setStyle({visible:!0,stroke:i,x:r,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(),r=new ph(jg(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),r.length){const t=[];this.originList.forEach(e=>{r.has(e)||t.push(e)}),r.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=0)}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)||this.isHoldMultipleSelectKey(t)&&!Ug(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new ph(this.editor.editBox.rect)};return Ug(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):Ug(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[Mg.HOVER,this.onHover,this],[Mg.SELECT,this.onSelect,this]]),e.on_([[cd.MOVE,this.onPointerMove,this],[cd.BEFORE_DOWN,this.onBeforeDown,this],[cd.TAP,this.onTap,this],[pd.START,this.onDragStart,this,!0],[pd.DRAG,this.onDrag,this],[pd.END,this.onDragEnd,this],[_d.MOVE,this.onAutoMove,this],[[vd.ZOOM,_d.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}},{topLeft:Kg,top:Zg,topRight:qg,right:$g,bottomRight:Jg,bottom:Qg,bottomLeft:t_,left:e_}=it,{toPoint:i_}=Bt,{within:s_,sign:r_}=X,{abs:o_}=Math,n_={getScaleData(t,e,i,s,r,o,n,a){let h,l,d={},c=1,u=1;const{boxBounds:p,widthRange:g,heightRange:_,dragBounds:f,worldBoxBounds:m}=t,{width:v,height:w}=e,x=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,k=r_(x),E=r_(b),S=a?x:k*p.width/v,B=a?b:E*p.height/w;if(y(s))c=u=Math.sqrt(s);else{o&&(s.x*=2,s.y*=2),s.x*=a?x:k,s.y*=a?b:E;const t=(-s.y+w)/w,e=(s.x+v)/v,n=(s.y+w)/w,d=(-s.x+v)/v;switch(i){case Zg:u=t,h="bottom";break;case $g:c=e,h="left";break;case Qg:u=n,h="top";break;case e_:c=d,h="right";break;case Kg:u=t,c=d,h="bottom-right";break;case qg:u=t,c=e,h="bottom-left";break;case Jg:u=n,c=e,h="top-left";break;case t_:u=n,c=d,h="top-right"}if(r)if("corner"===r&&i%2)r=!1;else switch(i){case Zg:case Qg:c=u;break;case e_:case $g:u=c;break;default:l=Math.sqrt(o_(c*u)),c=r_(c)*l,u=r_(u)*l}}const T=1!==c,C=1!==u;if(T&&(c/=S),C&&(u/=B),!n){const{worldTransform:e}=t;c<0&&(c=1/p.width/e.scaleX),u<0&&(u=1/p.height/e.scaleY)}if(i_(o||h,p,d,!0),f){const e={x:c,y:u};ld.limitScaleOf(t,d,e,r),c=e.x,u=e.y}if(T&&g){const e=p.width*t.scaleX;c=s_(e*c,g)/e}if(C&&_){const e=p.height*t.scaleY;u=s_(e*u,_)/e}return T&&o_(c*m.width)<1&&(c=r_(c)/m.width),C&&o_(u*m.height)<1&&(u=r_(u)/m.height),r&&c!==u&&(l=Math.min(o_(c),o_(u)),c=r_(c)*l,u=r_(u)*l),isFinite(c)||(c=1),isFinite(u)||(u=1),{origin:d,scaleX:c,scaleY:u,direction:i,lockRatio:r,around:o}},getRotateData(t,e,i,s,r){let o,n={};switch(e){case Kg:o="bottom-right";break;case qg:o="bottom-left";break;case Jg:o="top-left";break;case t_:o="top-right";break;default:o="center"}return i_(r||o,t.boxBounds,n,!0),{origin:n,rotation:_t.getRotation(s,t.getWorldPointByBox(n),i)}},getSkewData(t,e,i,s){let r,o,n={},a=0,h=0;switch(e){case Zg:case Kg:o={x:.5,y:0},r="bottom",a=1;break;case Qg:case Jg:o={x:.5,y:1},r="top",a=1;break;case e_:case t_:o={x:0,y:.5},r="right",h=1;break;case $g:case qg:o={x:1,y:.5},r="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,i_(s||r,t,n,!0);const c=_t.getRotation(o,n,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:n,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 e_:t=$g;break;case Kg:t=qg;break;case t_:t=Jg;break;case $g:t=e_;break;case qg:t=Kg;break;case Jg:t=t_}if(i)switch(t){case Zg:t=Qg;break;case Kg:t=t_;break;case qg:t=Jg;break;case Qg:t=Zg;break;case t_:t=Kg;break;case Jg:t=qg}return t}},a_={};function h_(t,e){const{enterPoint:i,dragging:s,skewing:r,resizing:o,flippedX:n,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return l_(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:p,moveable:g,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(g||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!_)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),w=s?r?p:o?c:u:v?p:y?c:u;h+=45*(n_.getFlipDirection(i.direction,n,a)+1),h=2*Math.round(X.formatRotation(h,!0)/2);const{url:x,x:b,y:k}=w,E=x+h;a_[E]?i.cursor=a_[E]:a_[E]=i.cursor={url:d_(x,h),x:b,y:k}}function l_(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function d_(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}var c_=class extends al{constructor(t){super(t),this.useFastShadow=!0}},u_=["top","right","bottom","left"],p_=void 0,g_=class extends Jh{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}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}get canUse(){return this.app&&this.editor.editing}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return f(t)||f(e)||f(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(t){super(),this.view=new Jh,this.rect=new c_({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new c_({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new Jh({around:"center",hitSelf:!1,visible:0}),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:r,rotatePoints:o,resizeLines:n,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let c=0;c<8;c++)t=new c_({name:"rotate-point",around:d[c],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",c),c%2&&(e=new c_({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),n.push(e),this.listenPointEvents(e,"resize",c)),i=new c_({name:"resize-point",hitRadius:5}),r.push(i),this.listenPointEvents(i,"resize",c);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...o,a,h,l,...n,...r),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:r,resizePoints:o,resizeLines:n}=this,{stroke:a,strokeWidth:h,ignorePixelSnap:l}=e,d=this.getPointsStyle(),c=this.getMiddlePointsStyle(),u=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let _=0;_<8;_++)p=o[_],p.set(this.getPointStyle(_%2?c[(_-1)/2%c.length]:d[_/2%d.length])),p.rotation=(_-(_%2?1:0))/2*90,_%2&&n[(_-1)/2].set(Object.assign({pointType:"resize",rotation:(_-1)/2*90},u[(_-1)/2%u.length]||{}));r.set(this.getPointStyle(e.circle||e.rotatePoint||d[0])),s.set(Object.assign({stroke:a,strokeWidth:h,opacity:1,editConfig:p_},e.rect||{}));const g=_(e.rectThrough)?i:e.rectThrough;s.hittable=!g,g&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&E.stintSet(t.__world,"ignorePixelSnap",l),l_(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:r,rotation:o,skewX:n,skewY:a,width:h,height:l}=this.target.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:e,y:i,scaleX:s,scaleY:r,rotation:o,skewX:n,skewY:a}),this.updateBounds({x:0,y:0,width:h,height:l})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,mergeConfig:i,single:s,rect:r,circle:o,buttons:n,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{editMask:d}=e,{middlePoint:c,resizeable:u,rotateable:p,hideOnSmall:_,editBox:f,mask:m,dimOthers:v,bright:w,spread:x,hideRotatePoints:b,hideResizeLines:k}=i;if(d.visible=!!m||0,g(v)&&g(w)?e.hasDimOthers&&e.cancelDimOthers():(e.setDimOthers(v),e.setBright(!!v||w),e.hasDimOthers=!0),x&&jt.spread(t,x),this.view.worldOpacity){const{width:e,height:d}=t,g=y(_)?_:10,m=f&&!(_&&e<g&&d<g);let v,w,x,E={};for(let i=0;i<8;i++)Bt.toPoint(Bt.directionData[i],t,E),w=a[i],v=h[i],w.set(E),v.set(E),w.visible=m&&!(!u&&!p),v.visible=m&&p&&u&&!b,i%2&&(x=l[(i-1)/2],x.set(E),x.visible=w.visible&&!k,w.visible&&(w.visible=!!c),v.visible&&(v.visible=!!c),(i+1)/2%2?(x.width=e+x.height,_&&2*w.width>e&&(w.visible=!1)):(x.width=d+x.height,_&&2*w.width>d&&(w.visible=!1)));o.visible=m&&p&&!(!i.circle&&!i.rotatePoint),o.visible&&this.layoutCircle(),r.path&&(r.path=null),r.set(Object.assign(Object.assign({},t),{visible:!s||f})),n.visible=m&&n.children.length>0||0,n.visible&&this.layoutButtons()}else r.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:r}=this.mergedConfig,o=u_.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,o,e||i,!!r)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:r}=this.mergedConfig,{flippedX:o,flippedY:n}=this;let a=u_.indexOf(e);(a%2&&o||(a+1)%2&&n)&&i&&(a=(a+2)%4);const h=i?n_.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!r),i&&(t.rotation=90*(h-a)),t.scaleX=o?-1:1,t.scaleY=n?-1:1}setButtonPosition(t,e,i,s){const r=this.resizePoints[2*e+1],o=e%2,n=e&&3!==e?1:-1,a=(i+(e%2?(s?r.width:0)+t.boxBounds.width:(s?r.height:0)+t.boxBounds.height)/2)*n;o?(t.x=r.x+a,t.y=r.y):(t.x=r.x,t.y=r.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:r,pointRadius:o}=this.mergedConfig,n={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:r,height:r,cornerRadius:o,offsetX:0,offsetY:0,editConfig:p_};return t?Object.assign(n,t):n}getPointsStyle(){const{point:t}=this.mergedConfig;return v(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return v(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return v(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:r,rotateable:o,skewable:n,onCopy:a}=this.mergeConfig;"move"===i?(t.altKey&&a&&a()&&this.editor.single&&this.app.interaction.replaceDownTarget(this.target),s&&(this.moving=!0)):(i.includes("rotate")||this.isHoldRotateKey(t)||!r?(o&&(this.rotating=!0),"resize-rotate"===i?r&&(this.resizing=!0):"resize-line"===e.name&&(n&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&r&&(this.resizing=!0),"skew"===i&&n&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:r,skewing:o}=this;if(i)e.onMove(t);else if(s||r||o){const i=t.current;i.pointType&&(this.enterPoint=i),r&&e.onRotate(t),s&&e.onScale(t),o&&e.onSkew(t)}h_(this,t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){(this.moving||this.gesturing)&&(this.editor.opacity=this.mergedConfig.hideOnMove?0:1),this.resizing&&(Xn.resizingKeys=this.editor.leafList.keys);const{dragStartData:e,target:i}=this;e.x=t.x,e.y=t.y,e.totalOffset={x:0,y:0},e.point={x:i.x,y:i.y},e.bounds=Object.assign({},i.getLayoutBounds("box","local")),e.rotation=i.rotation}onTransformEnd(t){this.canDragLimitAnimate&&(t instanceof pd||t instanceof _d)&&this.transformTool.onMove(t),this.resizing&&(Xn.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(t){if(this.canGesture&&"drag"!==t.moveType&&(t.stop(),f(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,t.type){case _d.START:this.onTransformStart(t);break;case _d.END:this.onTransformEnd(t);break;default:this.transformTool.onMove(t)}}onScale(t){if(this.canGesture&&(t.stop(),f(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,t.type){case vd.START:this.onTransformStart(t);break;case vd.END:this.onTransformEnd(t);break;default:this.transformTool.onScale(t)}}onRotate(t){if(this.canGesture&&(t.stop(),f(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,t.type){case vd.START:this.onTransformStart(t);break;case vd.END:this.onTransformEnd(t);break;default:this.transformTool.onRotate(t)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){h_(this,t)}onArrow(t){if(this.canUse){let e=0,i=0;switch(t.code){case"ArrowDown":i=1;break;case"ArrowUp":i=-1;break;case"ArrowLeft":e=-1;break;case"ArrowRight":e=1}if(e||i){const{keyEvent:s,arrowStep:r,arrowFastStep:o}=this.mergeConfig;if(s){const s=t.shiftKey?o:r;this.transformTool.move(e*s,i*s)}}}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof Hl)||t.find(t=>t instanceof Hl);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[pd.START,this.onDragStart,this],[pd.DRAG,this.onDrag,this],[pd.END,this.onDragEnd,this],[cd.ENTER,e=>{this.enterPoint=t,h_(this,e)}],[cd.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[cd.DOUBLE_TAP,this.onDoubleTap,this],[cd.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[wd.HOLD,wd.UP],this.onKey,this],[wd.DOWN,this.onArrow,this],[[_d.START,_d.BEFORE_MOVE,_d.END],this.onMove,this,!0],[[vd.START,vd.BEFORE_ZOOM,vd.END],this.onScale,this,!0],[[md.START,md.BEFORE_ROTATE,md.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}},__={x:0,y:0,width:1e5,height:1e5},f_=class extends qh{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,__),Object.assign(this.__world,__)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}},m_='\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"/>',y_={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,arrowStep:1,arrowFastStep:10,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${m_}\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${m_}\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${m_}\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},v_=new qt;function w_(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{v_.setListWithFn(i,t=>t.getBounds("box","page")),0===v_.width&&(v_.width=.1),0===v_.height&&(v_.height=.1),e.reset(v_.get())}),s.add(e)}var x_=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),b_=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),k_={group(t,e,i){t.sort(b_);const{app:s,parent:r}=t[0];let o;o=i&&i.add?i:new Jh(i),r.addAt(o,r.children.indexOf(t[0])),t.sort(x_);const n=new bt(e.worldTransform);return n.divideParent(r.scrollWorldTransform),o.setTransform(n),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(x_),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(b_),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},E_=ne.get("EditToolCreator");function S_(){return t=>{B_.register(t)}}var B_={list:{},register(t){const{tag:e}=t.prototype;T_[e]&&E_.repeat(e),T_[e]=t},get:(t,e)=>new T_[t](e)},{list:T_}=B_,C_=class extends Mg{constructor(t,e){super(t,e)}};C_.BEFORE_OPEN="innerEditor.before_open",C_.OPEN="innerEditor.open",C_.BEFORE_CLOSE="innerEditor.before_close",C_.CLOSE="innerEditor.close";var O_=class extends Mg{constructor(t,e){super(t,e)}};O_.BEFORE_GROUP="editor.before_group",O_.GROUP="editor.group",O_.BEFORE_UNGROUP="editor.before_ungroup",O_.UNGROUP="editor.ungroup",O_.BEFORE_OPEN="editor.before_open_group",O_.OPEN="editor.open_group",O_.BEFORE_CLOSE="editor.before_close_group",O_.CLOSE="editor.close_group";var{updateMatrix:R_}=tn,P_={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},L_="top-left",M_=class extends el{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.skipJSON=!0,this.on(Mn.CHANGE,e=>{if(this.checkChange&&P_[e.attrName]){const{attrName:i,newValue:s,oldValue:r}=e,o="s"===i[0]?(s||1)/(r||1):(s||0)-(r||0);this.canChange=!1;const n=this.__;n[i]=r,R_(this.parent),R_(this);const a=new bt(this.__world);switch(n[i]=s,this.__layout.rotationChange(),R_(this),this.changedTransform=new bt(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(L_,o);break;case"scaleX":t.scaleOf(L_,o,1);break;case"scaleY":t.scaleOf(L_,1,o);break;case"skewX":t.skewOf(L_,o,0);break;case"skewY":t.skewOf(L_,0,o)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}},D_=class extends Mg{constructor(t,e){super(t,e)}};D_.BEFORE_MOVE="editor.before_move",D_.MOVE="editor.move";var A_=class extends Mg{constructor(t,e){super(t,e)}};A_.BEFORE_SCALE="editor.before_scale",A_.SCALE="editor.scale";var I_=class extends Mg{constructor(t,e){super(t,e)}};I_.BEFORE_ROTATE="editor.before_rotate",I_.ROTATE="editor.rotate";var W_=class extends Mg{constructor(t,e){super(t,e)}};W_.BEFORE_SKEW="editor.before_skew",W_.SKEW="editor.skew";var z_=class extends Jh{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 dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new ph,this.openedGroupList=new ph,this.simulateTarget=new M_(this),this.editBox=new g_(this),this.editToolList={},this.selector=new Gg(this),this.editMask=new f_(this),this.targetEventIds=[];let i=E.clone(y_);t&&(i=E.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),pe.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}getItem(t){return this.list[t||0]}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)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?v(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>E.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}cancelDimOthers(){this.setDimOthers(!1),this.setBright(!1),this.hasDimOthers=void 0}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&&w_(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||B_.get(t,this)}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(f(s))e=s;else if(!1===s)return}if(B_.list[e]){const t=this.editTool=this.getEditTool(e);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(O_.BEFORE_GROUP),this.target=k_.group(this.list,this.element,t),this.emitGroupEvent(O_.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(O_.BEFORE_UNGROUP,t)),this.target=k_.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(O_.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(O_.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(O_.OPEN,t)}closeGroup(t){this.emitGroupEvent(O_.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(O_.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!tn.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 O_(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||B_.get(t,this)}openInnerEditor(t,e,i){let s;if(f(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(f(i))s=i;else if(!1===i)return}B_.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(C_.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(C_.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(C_.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(C_.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new C_(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&&(k_.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(k_.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(Un.START,this.onRenderStart,this),i&&i.on_(Mn.SCROLL,this.onChildScroll,this),t.on_(Un.CHILD_START,this.onAppRenderStart,this),t.on_(jn.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}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())}};Pg([(t,e)=>{uo(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,editTool:r,innerEditor:o,app:n}=this,a=Object.assign({},t);if(o?o.editConfig&&Object.assign(a,o.editConfig):r&&r.editConfig&&Object.assign(a,r.editConfig),e&&e.editConfig){let{editConfig:t}=e;(t.hover||t.hoverStyle)&&(t=Object.assign({},t),delete t.hover,delete t.hoverStyle),Object.assign(a,t)}return s.config&&Object.assign(a,s.config),i&&(i.editConfig&&Object.assign(a,i.editConfig),"font-size"===a.editSize&&(a.lockRatio=!0),"resize-rotate"===i.pointType&&(a.around||(a.around="center"),_(a.lockRatio)&&(a.lockRatio=!0))),g(a.dragLimitAnimate)&&(a.dragLimitAnimate=n&&n.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],z_.prototype,"mergeConfig",void 0),Pg([Dg(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof ph?i:new ph(i),t.multiple&&w_(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new Mg(Mg.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new Mg(Mg.AFTER_SELECT,s))})],z_.prototype,"target",void 0),Pg([Dg(function(t,e){t.emitEvent(new Mg(Mg.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],z_.prototype,"hoverTarget",void 0),z_=Pg([Yo(class{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let r,{dragLimitAnimate:o}=i;const n=t.type===_d.END||t.type===pd.END,a=f(e.draggable),h=!o||n||a,l={x:t.totalX,y:t.totalY};t instanceof _d&&_t.move(l,e.getWorldPointByLocal(s.totalOffset,null,!0)),t.shiftKey&&(Math.abs(l.x)>Math.abs(l.y)?l.y=0:l.x=0),r=pd.getValidMove(e,s.point,l,h),(r.x||r.y)&&(o&&!a&&n?tn.animateMove(this,r,y(o)?o:.3):this.move(r))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:r}=this.editBox;let o,{around:n,lockRatio:a,flipable:h,editSize:l}=i;t instanceof vd?(n||(n=e.getBoxPoint(t)),o=t.totalScale):o=t.getInnerTotal(e);const{direction:d}=t.current;(t.shiftKey||e.lockRatio)&&(a=!0);const c=n_.getScaleData(e,r.bounds,d,o,a,n_.getAround(n,t.altKey),h,!s||"scale"===l),u=e.x,p=e.y;t instanceof pd&&this.editTool&&this.editTool.onScaleWithDrag?(c.drag=t,this.scaleWithDrag(c)):this.scaleOf(c.origin,c.scaleX,c.scaleY),_t.move(r.totalOffset,e.x-u,e.y-p)}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:r,rotateAround:o,rotateGap:n,diagonalRotateKey:a}=i,{direction:h}=t.current;let l,d;if(t instanceof md)d=t.rotation,l=o?Bt.getPoint(o,e.boxBounds):e.getBoxPoint(t);else{const i=a?t.isHoldKeys(a):t.shiftKey,n=n_.getRotateData(e,h,t,s,i?null:o||e.around||e.origin||r||"center");d=s.rotation+n.rotation-e.rotation,l=n.origin}if(d=X.float(X.getGapRotation(d,n,e.rotation),2),!d)return;const c=e.x,u=e.y;this.rotateOf(l,d),_t.move(s.totalOffset,e.x-c,e.y-u)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:r,skewX:o,skewY:n}=n_.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),n_.getAround(s,t.altKey));(o||n)&&this.skewOf(r,o,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;w(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:r,editor:o}=this.editBox,{beforeMove:n}=s;if(n){const s=n({target:i,x:t,y:e});if(w(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);r||i.safeChange(()=>i.move(t,e));const h={target:i,editor:o,moveX:a.x,moveY:a.y};this.emitEvent(new D_(D_.BEFORE_MOVE,h));const l=new D_(D_.MOVE,h);this.doMove(l),this.emitEvent(l)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:r}=i;if(r){const{origin:i,scaleX:s,scaleY:o,drag:n}=t;if(!1===r({target:e,drag:n,origin:i,scaleX:s,scaleY:o}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new A_(A_.BEFORE_SCALE,t));const o=new A_(A_.SCALE,t);this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:r,mergeConfig:o,single:n,editor:a}=this.editBox,{beforeScale:h}=o;if(h){const s=h({target:r,origin:t,scaleX:e,scaleY:i});if(w(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!n&&this.getChangedTransform(()=>r.safeChange(()=>r.scaleOf(t,e,i))),c={target:r,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new A_(A_.BEFORE_SCALE,c));const u=new A_(A_.SCALE,c);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,r=this.getWorldOrigin("center"),o=i?new bt(tn.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),n={target:e,editor:s,worldOrigin:r,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:o};this.emitEvent(new A_(A_.BEFORE_SCALE,n));const a=new A_(A_.SCALE,n);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:r,editor:o}=this.editBox,{beforeRotate:n}=s;if(n){const s=n({target:i,origin:t,rotation:e});if(y(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!r&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),l={target:i,editor:o,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new I_(I_.BEFORE_ROTATE,l));const d=new I_(I_.ROTATE,l);this.doRotate(d),this.emitEvent(d)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:r,mergeConfig:o,single:n,editor:a}=this.editBox,{beforeSkew:h}=o;if(h){const s=h({target:r,origin:t,skewX:e,skewY:i});if(w(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!n&&this.getChangedTransform(()=>r.safeChange(()=>r.skewOf(t,e,i))),c={target:r,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new W_(W_.BEFORE_SKEW,c));const u=new W_(W_.SKEW,c);this.doSkew(u),this.emitEvent(u)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(tn.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new bt(e.worldTransform);return t(),new bt(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}},["editBox","editTool","emitEvent"])],z_);var F_=class{static registerInnerEditor(){B_.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this._editBox||this.editor.editBox}set editBox(t){this._editBox=t}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new Jh,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(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)}},Y_=class extends F_{static registerEditTool(){B_.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:r,list:o}=s;r.lockLayout(),o.forEach(t=>{t.moveWorld(e,i)}),r.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:r,editor:o}=t,{app:n,list:a}=o;n.lockLayout(),a.forEach(t=>{const n="scale"!==o.getEditSize(t);s?t.transformWorld(s,n):t.scaleOfWorld(r,e,i,n)}),n.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:r}=t,{app:o,list:n}=r;o.lockLayout(),n.forEach(t=>{const o="scale"!==r.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)}),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:r,editor:o}=t,{app:n,list:a}=o;n.lockLayout(),a.forEach(t=>{const n="scale"!==o.getEditSize(t);s?t.transformWorld(s,n):t.skewOfWorld(r,e,i,n)}),n.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};Y_=Pg([S_()],Y_);var{left:N_,right:X_}=it,{move:H_,copy:V_,toNumberPoints:U_}=_t,j_=class extends Y_{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:r}=t,o=t.target,n=i===N_;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,n,r,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,n,r,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,n,r,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=U_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,r){const{x:o,y:n}=r;i?(H_(t,o,n),s&&H_(e,-o,-n)):(s&&H_(t,-o,-n),H_(e,o,n))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:r}=t,o=t.target;let n,a;if(o.pathInputed?n=this.getFromToByPath(o.__.path):o.points&&(n=this.getFromToByPoints(o.__.points)),n){const{from:i,to:a}=n;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),r.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),V_(s[7],i),V_(e[7],i),V_(s[3],a),V_(e[3],a)}for(let h=0;h<8;h++)h<4&&(i[h].visible=!1),a=h===N_||h===X_,s[h].visible=a,e[h].visible=!n&&a}};function G_(t){const{scroll:e,disabled:i}=t.app.config.move;return!e||i?"":!0===e?"free":e}function K_(t,e,i){(function(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&E.assign(i,e),E.assign(t.config,i,t.userConfig)})(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(_d.BEFORE_MOVE,e=>{const i=t.getValidMove(e.moveX,e.moveY,!1);if(G_(t).includes("limit")){const s=t.getValidMove(0,0);if(s.x||s.y){const t=100,r=200,o="drag"===e.moveType?.3:.05;Math.abs(s.x)>t?i.x=0:i.x*=o,Math.abs(s.y)>r?i.y=0:i.y*=o}}t.zoomLayer.move(i)}),t.on_(_d.DRAG_ANIMATE,()=>{const e=t.getValidMove(0,0);(e.x||e.y)&&t.interaction.stopDragAnimate()}),t.on_(_d.END,e=>{tn.animateMove(t.zoomLayer,t.getValidMove(e.moveX,e.moveY))}),t.on_(vd.BEFORE_ZOOM,e=>{const{zoomLayer:i,layouter:s}=t,r=t.getValidScale(e.scale);1!==r&&(s.stop(),tn.updateMatrix(t),i.scaleOfWorld(e,r),s.start())}))}j_=Pg([S_()],j_),pe.add("editor","resize"),ge.editor=function(t,e){const i=new z_(t);return e&&e.sky.add(e.editor=i),i},al.addAttr("textBox",!1,_o),qh.addAttr("editConfig",void 0,_o),qh.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),_o),qh.addAttr("editInner","PathEditor",_o),Jh.addAttr("editInner","",_o),Hl.addAttr("editInner","TextEditor",_o),qh.setEditConfig=function(t){this.changeAttr("editConfig",t)},qh.setEditOuter=function(t){this.changeAttr("editOuter",t)},qh.setEditInner=function(t){this.changeAttr("editInner",t)};var Z_=ne.get("LeaferTypeCreator"),q_={list:{},register(t,e){$_[t]&&Z_.repeat(t),$_[t]=e},run(t,e){const i=$_[t];i&&i(e)}},{list:$_,register:J_}=q_;J_("viewport",K_),J_("custom",function(t){K_(t,null,!0)}),J_("design",function(t){K_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),J_("document",function(t){K_(t,{zoom:{min:1},move:{scroll:"limit"}})});var Q_,tf,ef,sf,rf={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=_t.getCenter(e.from,i.from),r=_t.getCenter(e.to,i.to),o={x:r.x-s.x,y:r.y-s.y},n=_t.getDistance(e.from,i.from);return{move:o,scale:_t.getDistance(e.to,i.to)/n,rotation:_t.getRotation(e.from,i.from,e.to,i.to),center:r}},getType(t,e){const i=Math.hypot(t.move.x,t.move.y)/(e.move||5),s=Math.abs(t.scale-1)/(e.scale||.03),r=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&r<1?"none":i>=s&&i>=r?"move":s>=r?"zoom":"rotate"},detect(t,e){const{state:i}=of,s=of.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),of.add(t,i.totalData),i.totalData=t,s===i.type){if(i.typeCount++,i.typeCount>=(e.count||3)&&"none"!==s)return s}else i.type=s,i.typeCount=1;return Date.now()-i.startTime>=(e.time||160)?of.getType(i.totalData,e):"none"},add(t,e){e&&(_t.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=of;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},of=rf,{abs:nf,max:af}=Math,{sign:hf,within:lf}=X,df={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:r}=t;t.shiftKey&&!s&&(s=r,r=0);const o=nf(s),n=nf(r);return o>50&&(s=af(50,o/3)*hf(s)),n>50&&(r=af(50,n/3)*hf(r)),{x:-s*i*2,y:-r*i*2}},getScale(t,e){let i,s=1,{zoomMode:r,zoomSpeed:o}=e;const n=t.deltaY||t.deltaX;if(r?(i="mouse"===r||!t.deltaX&&(se.intWheelDeltaY?Math.abs(n)>17:Math.ceil(n)!==n),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){o=lf(o,0,1);const i=t.deltaY?e.delta.y:e.delta.x,r=lf(1-nf(n)/(4*i)*o,.5,2);s=n>0?r:1/r}return s}},cf=class{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),Q_=0,tf=0,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0,totalX:Q_,totalY:tf}),e.emit(_d.START,this.moveData)),t.path=this.moveData.path,t.totalX=Q_+=t.moveX,t.totalY=tf+=t.moveY,e.emit(_d.BEFORE_MOVE,t),e.emit(_d.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),ef=1,this.zoomData=Object.assign(Object.assign({},t),{scale:1,totalScale:ef}),e.emit(vd.START,this.zoomData)),t.path=this.zoomData.path,t.totalScale=ef*=t.scale,e.emit(vd.BEFORE_ZOOM,t),e.emit(vd.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),sf=0,this.rotateData=Object.assign(Object.assign({},t),{rotation:0,totalRotation:sf}),e.emit(md.START,this.rotateData)),t.path=this.rotateData.path,t.totalRotation=sf+=t.rotation,e.emit(md.BEFORE_ROTATE,t),e.emit(md.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(_d.END,Object.assign(Object.assign({},e),{totalX:Q_,totalY:tf})),i&&t.emit(vd.END,Object.assign(Object.assign({},i),{totalScale:ef})),s&&t.emit(md.END,Object.assign(Object.assign({},s),{totalRotation:sf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}},uf=tl.prototype,pf=new qt,gf=new xt;function _f(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function ff(t,e){return Object.assign(Object.assign({},e),{scale:t})}uf.initType=function(t){q_.run(t,this)},uf.getValidMove=function(t,e,i=!0){const{disabled:s,scrollSpread:r}=this.app.config.move;gf.set(t,e);const o=G_(this);return o&&(o.includes("x")?gf.y=0:o.includes("y")?gf.x=0:Math.abs(gf.x)>Math.abs(gf.y)?gf.y=0:gf.x=0,i&&o.includes("limit")&&(pf.set(this.__world).addPoint(this.zoomLayer),r&&pf.spread(r),ld.getValidMove(pf,this.canvas.bounds,"auto",gf,!0),o.includes("x")?gf.y=0:o.includes("y")&&(gf.x=0))),{x:s?0:gf.x,y:s?0:gf.y}},uf.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:r}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),r?1:t};var mf=Wd.prototype;mf.createTransformer=function(){this.transformer=new cf(this)},mf.move=function(t){this.transformer.move(t)},mf.zoom=function(t){this.transformer.zoom(t)},mf.rotate=function(t){this.transformer.rotate(t)},mf.transformEnd=function(){this.transformer.transformEnd()},mf.wheel=function(t){const{wheel:e,pointer:i}=this.config,{posDeltaSpeed:s,negDeltaSpeed:r}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):r&&(t.deltaX*=r),t.deltaY>0?s&&(t.deltaY*=s):r&&(t.deltaY*=r);const o=e.getScale?e.getScale(t,e):df.getScale(t,e);if(1!==o)this.zoom(ff(o,t));else{const s=e.getMove?e.getMove(t,e):df.getMove(t,e);i.snap&&_t.round(s),this.move(_f(s,t))}},mf.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let r=rf.getData(e),{moving:o,zooming:n,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(rf.detect(r,w(s)?s:{})){case"move":o=!0;break;case"zoom":n=!0;break;case"rotate":a=!0;break;default:return}rf.reset()}o||(r.center=rf.state.center)}else o=n=a=!0;var h,l;Object.assign(t,r.center),t.multiTouch=!0,a&&this.rotate((h=r.rotation,l=t,Object.assign(Object.assign({},l),{rotation:h}))),n&&this.zoom(ff(r.scale,t)),o&&this.move(_f(r.move,t))};var yf=Td.prototype,{abs:vf,min:wf,max:xf,hypot:bf}=Math;function kf(t,e){let i=1;const s="out"===e,r=Math.abs(t);if(r>1){for(;s?i<r:i<=r;)i*=2;s&&(i/=2)}else{for(;s?i>=r:i>r;)i/=2;s||(i*=2)}return i/t}yf.checkDragEndAnimate=function(t){const{interaction:e}=this,i=this.canAnimate&&this.moving&&e.m.dragAnimate;if(i){const s=y(i)?i:.95,r=.15,o=150;let n,a,h,l=0,d=0,c=0,u=0,p=3;const{dragDataList:g}=this,_=g.length;for(let t=_-1;t>=xf(_-3,0)&&(h=g[t],!(h.time&&Date.now()-h.time>100));t--)n=p--,l+=h.moveX*n,d+=h.moveY*n,u+=n,a=bf(h.moveX,h.moveY),a>c&&(c=a);if(u&&(l/=u,d/=u),c>8){const t=1.15+.4500000000000002*wf((c-8)/17,1);l*=t,d*=t}const f=xf(vf(l),vf(d));f>o&&(a=o/f,l*=a,d*=a);const m=()=>{if(l*=s,d*=s,t=Object.assign({},t),vf(l)<r&&vf(d)<r)return this.dragEndReal(t);_t.move(t,l,d),this.drag(t),this.animate(m),e.emit(_d.DRAG_ANIMATE,t)};this.animate(m)}return i},yf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},yf.stopAnimate=function(){this.animate(null,"off"),this.interaction.target.nextRender(()=>{this.dragData&&this.dragEndReal(this.dragData)})},yf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},yf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:r,dragOut:o}=e.m;if(!o||!s||!r)return;const n=e.shrinkCanvasBounds,{x:a,y:h}=n,l=jt.maxX(n),d=jt.maxY(n),c=t.x<a?r:l<t.x?-r:0,u=t.y<h?r:d<t.y?-r:0;let p=0,g=0;this.autoMoveTimer=setInterval(()=>{p+=c,g+=u,_t.move(i,c,u),_t.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:p,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},yf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},pe.add("viewport"),pe.add("view"),tl.prototype.zoom=function(t,e,i,s){let r;!function(t){return w(t)&&!v(t)}(e)?r=e:(r=e.padding,i=e.scroll,s=e.transition);const{zoomLayer:o}=this,n=this.canvas.bounds.clone().shrink(_(r)?30:r),a=new qt,h={x:n.x+n.width/2,y:n.y+n.height/2};let l;o.killAnimate();const{x:d,y:c,scaleX:u,scaleY:p}=o.__,{boxBounds:g}=o;if(f(t))switch(t){case"in":l=kf(u,"in");break;case"out":l=kf(u,"out");break;case"fit":t=g;break;case"fit-width":(t=new qt(g)).height=0;break;case"fit-height":(t=new qt(g)).width=0}else y(t)&&(l=t/u);if(l)l=this.getValidScale(l),o.scaleOfWorld(h,l,l,!1,s);else if(w(t)){const e={x:d,y:c,scaleX:u,scaleY:p},r=v(t);if(r||t.tag){const e=r?t:[t];a.setListWithFn(e,dn.worldBounds)}else{const e=function(t,e){let i,{x:s,y:r,width:o,height:n}=t;return n||(n=o*(e.height/e.width),i=!0),o||(o=n*(e.width/e.height),i=!0),i?{x:s,y:r,width:o,height:n}:t}(t,n);a.set(o.getWorldBounds(e))}const{width:h,height:g}=a;let _=n.x-a.x,f=n.y-a.y;return i?(_+=Math.max((n.width-h)/2,0),f+=Math.max((n.height-g)/2,0)):(l=this.getValidScale(Math.min(n.width/h,n.height/g)),_+=(n.width-h*l)/2,f+=(n.height-g*l)/2,_t.scaleOf(e,a,l),a.scaleOf(a,l),e.scaleX*=l,e.scaleY*=l),"x"===i?f=0:"y"===i&&(_=0),_t.move(e,_,f),a.move(_,f),o.set(e,s),a}return o.worldBoxBounds};var Ef=class{constructor(t){this.undoStack=[],this.redoStack=[],this.limit=50,void 0!==t&&t>0&&(this.limit=t)}executeCommand(t){t.execute(),this.undoStack.push(t),this.redoStack=[],this.undoStack.length>this.limit&&this.undoStack.shift()}undo(){if(this.canUndo()){const t=this.undoStack.pop();t&&(t.undo(),this.redoStack.push(t))}}redo(){if(this.canRedo()){const t=this.redoStack.pop();t&&(t.execute(),this.undoStack.push(t))}}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[]}},Sf=class{constructor(t,e,i,s,r){this.target=t,this.fromX=e,this.fromY=i,this.toX=s,this.toY=r}execute(){this.target.x=this.toX,this.target.y=this.toY}undo(){this.target.x=this.fromX,this.target.y=this.fromY}},Bf=class{constructor(t,e,i,s,r){this.target=t,this.fromWidth=e,this.fromHeight=i,this.toWidth=s,this.toHeight=r}execute(){this.target.width=this.toWidth,this.target.height=this.toHeight}undo(){this.target.width=this.fromWidth,this.target.height=this.fromHeight}},Tf=class{constructor(t,e){this.parent=t,this.element=e}execute(){this.parent.add(this.element)}undo(){this.parent.remove(this.element)}},Cf=class{constructor(t,e,i){this.parent=t,this.element=e,this.index=i}execute(){this.parent.remove(this.element)}undo(){this.parent.add(this.element)}},Of=class{constructor(t){this.commands=t}execute(){this.commands.forEach(t=>t.execute())}undo(){for(let t=this.commands.length-1;t>=0;t--)this.commands[t].undo()}},Rf=["Shift","Meta","Alt","Control"],Pf="object"==typeof navigator?navigator.platform:"",Lf=/Mac|iPod|iPhone|iPad/.test(Pf)?"Meta":"Control",Mf="Win32"===Pf?["Control","Alt"]:["Alt"];function Df(t){let e=t.target;return t.repeat||t.isComposing||e!==t.currentTarget&&e.matches("[contenteditable],input,select,textarea")}function Af(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||Mf.includes(e)&&t.getModifierState("AltGraph"))}function If(t,[e,i,s]){const r=e.includes("AltGraph");return!((s instanceof RegExp?!s.test(t.key)&&!s.test(t.code):s.toUpperCase()!==t.key.toUpperCase()&&s!==t.code)||e.find(e=>!Af(t,e))||Rf.find(o=>!e.includes(o)&&!i.includes(o)&&s!==o&&Af(t,o)&&!(r&&Mf.includes(o))))}function Wf(t,e,i={}){let s=i.event??"keydown",r=function(t,e={}){let i=e.timeout??1e3,s=e.ignore??Df,r=Object.keys(t).map(e=>{return[e,(i=e,i.trim().split(" ").map(t=>{let e=t.split(/(?<=\w|\])\+/),i=e.pop(),s=i.match(/^\((.+)\)$/),r=s?new RegExp(`^(?:${s[1]})$`,"iv"):i,o=[],n=[];for(const a of e){let t=a.match(/^\[(.*)\]$/),e=t?.[1]??a;e="$mod"===e?Lf:e,t?n.push(e):o.push(e)}return[o,n,r]})),t[e]];var i}),o=/* @__PURE__ */new Map,n=null;return t=>{if(!function(t){return!!(t.key&&t.code&&t.getModifierState)}(t)||s(t))return;let e=[];for(let[i,s,n]of r){let r=o.get(i),[a,...h]=r||s;if(If(t,a)){if(h.length>0)o.set(i,h),e.push(i);else if(o.delete(i),!e.length){n(t);break}}else Af(t,t.key)||o.delete(i)}n&&clearTimeout(n),n=setTimeout(()=>o.clear(),i)}}(e,i);return t.addEventListener(s,r,i.capture),()=>{t.removeEventListener(s,r,i.capture)}}var zf={key:0,class:"loading-overlay",style:{}},Ff={key:1,class:"error-overlay"},Yf={class:"zoom-controller"},Nf={key:0,class:"hotkey-hint"},Xf={key:0,class:"hotkey-hint"},Hf={key:0,class:"hotkey-hint"},Vf={class:"toolbar"},Uf={key:0,class:"hotkey-hint"},jf={key:0,class:"hotkey-hint"},Gf={key:0,class:"hotkey-hint"},Kf={key:0,class:"hotkey-hint"},Zf={key:0,class:"hotkey-hint"},qf=/* @__PURE__ */r({__name:"RoiEditor",props:{imageSource:{type:Object,required:!0},options:{type:Object,default:()=>({})}},emits:["roiChange","loadStart","loadSuccess","loadError","undoStateChange","redoStateChange"],setup(r,{expose:u,emit:p}){const g=r,_=p,f=d(void 0),m=d("idle"),y=d(null),v=d(null);let w=null,x=null;const b=new Jh({name:"contentLayer"}),k=d({x:0,y:0}),E=d(!1),S=d(!1),B=d(!1),T=d("rectangle"),C=d(100),O=d(!1),R=d(0),P=d(0);let L,M=null,D=null,A=null;const I=t=>{L.executeCommand(t)},W=()=>{L=new Ef(g.options.maxUndoSteps??100),w=new Gl({view:f.value,width:f.value?.clientWidth||800,height:f.value?.clientHeight||600,fill:"#e3e3e3",zoom:{min:.2,max:4},editor:{rotateable:!1,middlePoint:{},selectedStyle:{...g.options.selectedRegionStyle}},tree:{type:"design"}}),w?.tree.add(b),w&&(w.on(cd.DOWN,H),w.on(cd.MOVE,V),w.on(cd.UP,U),w.on(pd.START,t=>{const e=t.target;e instanceof el&&e.parent===b&&(D={target:e,fromX:e.x||0,fromY:e.y||0,toX:e.x||0,toY:e.y||0})}),w.on(pd.DRAG,t=>{D&&(D.toX=t.target.x||0,D.toY=t.target.y||0)}),w.on(pd.END,()=>{if(D){const t=D.target;D.fromX===D.toX&&D.fromY===D.toY||(I(new Sf(t,D.fromX,D.fromY,D.toX,D.toY)),_("roiChange",F())),D=null}}),w.on(vd.ZOOM,t=>{it()}),w.editor?.on(A_.BEFORE_SCALE,t=>{const e=t.target;e instanceof el&&e.parent===b&&(A||(A={target:e,fromWidth:e.width||0,fromHeight:e.height||0,toWidth:e.width||0,toHeight:e.height||0}))}),w.editor?.on(A_.SCALE,t=>{A&&(A.toWidth=t.target.width||0,A.toHeight=t.target.height||0)}),w.on(cd.UP,()=>{A&&function(){if(A){const t=A.target;A.fromWidth===A.toWidth&&A.fromHeight===A.toHeight||(I(new Bf(t,A.fromWidth,A.fromHeight,A.toWidth,A.toHeight)),_("roiChange",F())),A=null}}()}))};const z=async t=>{const e=t||g.imageSource.url;if(w&&e){x&&(b.clear(),x.destroy()),m.value="loading",_("loadStart"),y.value=null,v.value=null;try{const t=await(i=e,new Promise((t,e)=>{const s=new window.Image;s.onload=()=>{t({width:s.width,height:s.height})},s.onerror=e,s.src=i}));y.value=t.width,v.value=t.height,x=new Il({url:e,draggable:!1,editable:!1,lazy:!0,zIndex:-1,placeholderColor:"transparent"}),x.on(An.LOADED,function(){m.value="success",_("loadSuccess"),X()}),x.on(An.ERROR,function(t){m.value="error",_("loadError",t)}),b.add(x)}catch(s){m.value="error",_("loadError",s)}var i}},F=()=>{if(!b||!y.value||!v.value)return[];const t=[],e=y.value,i=v.value;return Array.from(b.children).forEach(s=>{if(!s.url){const r=s,o=r.id||`roi-${t.length}`,n=r.x||0,a=r.y||0,h=r.width||0,l=r.height||0,d=[{x:n,y:a},{x:n+h,y:a},{x:n+h,y:a+l},{x:n,y:a+l}],c=d.map(t=>({x:e>0?t.x/e:0,y:i>0?t.y/i:0}));t.push({id:o,x:n,y:a,width:h,height:l,points:d,normalized:{x:e>0?n/e:0,y:i>0?a/i:0,width:e>0?h/e:0,height:i>0?l/i:0,points:c}})}}),t},Y=()=>({id:g.imageSource.id,url:g.imageSource.url,width:y.value,height:v.value});a(()=>{o(()=>{W(),z(),window.addEventListener("keydown",G),window.addEventListener("mousemove",N);const t=Wf(window,{v:t=>{(E.value||S.value)&&(t.preventDefault(),Z())},m:t=>{(E.value||S.value)&&(t.preventDefault(),q())},"$mod+KeyZ":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),$())},"$mod+KeyY":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),J())},Delete:t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),st())},"$mod+Equal":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),tt())},"$mod+Minus":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),Q())},"$mod+0":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),et())},Alt:t=>{(E.value||S.value)&&(t.preventDefault(),B.value=!B.value)}});window.__roiEditorHotkeysUnsubscribe=t})});const N=t=>{k.value={x:t.clientX,y:t.clientY}},X=()=>{if(!(w&&x&&y.value&&v.value))return;const t=w.width,e=w.height,i=y.value,s=v.value,r=t/i,o=e/s,n=Math.min(r,o,1),a=(t-i*Number(n.toFixed(2)))/2,h=(e-s*Number(n.toFixed(2)))/2;w.tree.scale=Number(n.toFixed(2)),w.tree.x=a,w.tree.y=h,it()},H=t=>{if("rectangle"!==T.value)return;if(t.ctrlKey||t.metaKey)return;if(t.target){if(t.target.parent===b&&!t.target.url)return;if(t.target.parent&&t.target.parent.parent===b&&!t.target.parent.url)return;if("resize"===t.target.pointType)return;if("rotate"===t.target.pointType)return}const e=b.getBoxPoint({x:t.x,y:t.y});j(e.x,e.y)&&(O.value=!0,R.value=e.x,P.value=e.y)},V=t=>{if(!O.value)return;const e=b.getBoxPoint({x:t.x,y:t.y}),i=e.x,s=e.y,r=Math.max(0,Math.min(i,y.value||0)),o=Math.max(0,Math.min(s,v.value||0)),n=Math.min(R.value,r),a=Math.min(P.value,o),h=Math.abs(r-R.value),l=Math.abs(o-P.value);M?(M.x=n,M.y=a,M.width=h,M.height=l):(M=new el({id:crypto.randomUUID(),x:n,y:a,width:h,height:l,stroke:"rgba(100, 149, 237, 0.8)",fill:"rgba(100, 149, 237, 0.3)",strokeWidth:2,draggable:!1,editable:!1,...g.options.regionStyle}),b.add(M))},U=()=>{if(O.value&&(O.value=!1,M)){const t=M.width||0,e=M.height||0;if(t<5||e<5)M.remove(),M=null;else{const t=g.options.maxRegions??20;if(F().length>=t)return alert(`已达到最大区域数量限制(${t}个)`),M.remove(),void(M=null);M.draggable=!0,M.editable=!0,M.dragBounds={x:0,y:0,width:y.value||0,height:v.value||0},I(new Tf(b,M)),_("roiChange",F()),M=null}}},j=(t,e)=>t>=0&&t<=(y.value||0)&&e>=0&&e<=(v.value||0),G=t=>{if("Space"===t.code&&K())return t.preventDefault(),!1},K=()=>{if(!f.value)return!1;const t=f.value.getBoundingClientRect();return k.value.x>=t.left&&k.value.x<=t.right&&k.value.y>=t.top&&k.value.y<=t.bottom};h(()=>{x&&(w?.tree.remove(x),x=null),w?.destroy(),w=null,window.removeEventListener("keydown",G),window.removeEventListener("mousemove",N),window.__roiEditorHotkeysUnsubscribe&&(window.__roiEditorHotkeysUnsubscribe(),delete window.__roiEditorHotkeysUnsubscribe)});const Z=()=>{T.value="select"},q=()=>{T.value="rectangle"},$=()=>{L.undo(),_("roiChange",F())},J=()=>{L.redo(),_("roiChange",F())},Q=()=>{w&&(w.tree.zoom("out"),it())},tt=()=>{w&&(w.tree.zoom("in"),it())},et=()=>{w&&(w.tree.zoom(1),it())},it=()=>{w&&w.tree&&void 0!==w.tree.scaleX&&(C.value=Math.round(100*w.tree.scaleX))},st=()=>{if(!w)return;const t=w.editor?.list||[];if(0===t.length)return;const e=t.filter(t=>t instanceof el&&t.parent===b);if(0===e.length)return;const i=[];e.forEach(t=>{const e=t.parent?.children.indexOf(t)??-1;t.remove();const s=new Cf(b,t,e);i.push(s)}),i.length>0&&I(new Of(i)),w&&w.editor&&w.editor.cancel(),_("roiChange",F())};return u({getROIAnnotations:F,getImageInfo:Y,exportCanvasJSON:()=>{const t={version:"1.0",canvas:{width:y.value,height:v.value,zoom:C.value/100},image:Y(),leaferJSON:w?.tree?.toJSON?.()||null,annotations:F(),exportedAt:/* @__PURE__ */(new Date).toISOString()};return JSON.stringify(t,null,2)},importCanvasJSON:async(t,e)=>{try{const s=JSON.parse(t);if(!s.leaferJSON)return!1;if(b){for(;b.children.length>0;)b.children[0].remove();if(s.leaferJSON&&s.leaferJSON.children){let t=null;const e=i=>{for(const s of i){if(s.url)return t=s,!0;if(s.children&&s.children.length>0&&e(s.children))return!0}return!1};if(e(s.leaferJSON.children),t)try{await z(t.url)}catch(i){y.value=t.width||s.canvas?.width||0,v.value=t.height||s.canvas?.height||0}const r=t=>{for(const e of t){if(e.url)continue;const t=JSON.parse(JSON.stringify(e));b.add(t),e.children&&e.children.length>0&&r(e.children)}};r(s.leaferJSON.children[0].children)}w?.tree.forceUpdate()}return e?.resetZoom&&s.canvas?.zoom&&(C.value=100*s.canvas.zoom,it()),_("roiChange",F()),!0}catch(i){return!1}},loadImage:z}),(r,o)=>(l(),e("div",{class:"roi-editor",onFocus:o[1]||(o[1]=t=>E.value=!0),onBlur:o[2]||(o[2]=t=>E.value=!1),onMouseenter:o[3]||(o[3]=t=>S.value=!0),onMouseleave:o[4]||(o[4]=t=>S.value=!1)},[i("div",{ref_key:"canvasContainer",ref:f,class:"canvas-container",tabindex:"0"},["loading"===m.value?(l(),e("div",zf,[...o[5]||(o[5]=[i("div",{class:"gradient-animation"},null,-1),i("div",{class:"loading-text"},"图片加载中",-1)])])):t("",!0),"error"===m.value?(l(),e("div",Ff,[o[6]||(o[6]=i("p",null,"加载失败",-1)),i("button",{onClick:o[0]||(o[0]=t=>z())},"重试")])):t("",!0),i("div",Yf,[i("button",{class:"zoom-button",title:"缩小 (Ctrl+-)",onClick:Q},[o[7]||(o[7]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)),B.value?(l(),e("span",Nf,"Ctrl+-")):t("",!0)]),i("div",{class:"zoom-value",onClick:et,title:"点击重置为100% (Ctrl+0)"},[s(c(C.value)+"% ",1),B.value?(l(),e("span",Xf,"Ctrl+0")):t("",!0)]),i("button",{class:"zoom-button",title:"放大 (Ctrl++)",onClick:tt},[o[8]||(o[8]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),i("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)),B.value?(l(),e("span",Hf,"Ctrl++")):t("",!0)])])],512),i("div",Vf,[i("button",{class:n(["tool-button",{active:"select"===T.value}]),title:"选择工具 (V)",onClick:Z},[o[9]||(o[9]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-mouse-pointer2-icon lucide-mouse-pointer-2"},[i("path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"})],-1)),B.value?(l(),e("span",Uf,"V")):t("",!0)],2),i("button",{class:n(["tool-button",{active:"rectangle"===T.value}]),title:"框选工具 (M)",onClick:q},[o[10]||(o[10]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"})],-1)),B.value?(l(),e("span",jf,"M")):t("",!0)],2),i("button",{class:"tool-button",title:"撤销 (Ctrl+Z)",onClick:$},[o[11]||(o[11]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M3 7v6h6"}),i("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)),B.value?(l(),e("span",Gf,"Ctrl+Z")):t("",!0)]),i("button",{class:"tool-button",title:"重做 (Ctrl+Y)",onClick:J},[o[12]||(o[12]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M21 7v6h-6"}),i("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)),B.value?(l(),e("span",Kf,"Ctrl+Y")):t("",!0)]),i("button",{class:"tool-button",title:"删除 (Delete)",onClick:st},[o[13]||(o[13]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M3 6h18"}),i("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),i("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})],-1)),B.value?(l(),e("span",Zf,"Del")):t("",!0)])])],32))}}),$f=/* @__PURE__ */((t,e)=>{const i=t.__vccOpts||t;for(const[s,r]of e)i[s]=r;return i})(qf,[["__scopeId","data-v-9c4af5f9"]]),Jf={install(t){t.component("RoiEditor",$f)}};export{$f as RoiEditor,Jf as default};
1
+ import{createCommentVNode as t,createElementBlock as e,createElementVNode as i,createTextVNode as s,defineComponent as r,nextTick as o,normalizeClass as n,onMounted as a,onUnmounted as h,openBlock as l,ref as d,toDisplayString as c}from"vue";var u;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(u||(u={}));var p={};function g(t){return void 0===t}function _(t){return null==t}function f(t){return"string"==typeof t}var{isFinite:m}=Number;function y(t){return"number"==typeof t}var{isArray:v}=Array;function w(t){return t&&"object"==typeof t}var x,b,k,E={default:(t,e)=>(S(e,t),S(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(r=>{var o,n;if(s=e[r],(null==s?void 0:s.constructor)===Object&&(null===(o=t[r])||void 0===o?void 0:o.constructor)===Object)return S(t[r],e[r],i&&i[r]);i&&r in i?(null===(n=i[r])||void 0===n?void 0:n.constructor)===Object&&S(t[r]={},e[r],i[r]):t[r]=e[r]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{g(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},stintSet(t,e,i){i||(i=void 0),t[e]!==i&&(t[e]=i)}},{assign:S}=E,B=class{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __usePathBox(){return this.__pathInputed}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(!g(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]=g(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(!g(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!g(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(v(t))for(let s of t)i[s]=this.__getInput(s);else for(let s in t)i[s]=this.__getInput(s);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let r in this)if("_"!==r[0]&&(t=this["_"+r],!g(t))){if("path"===r&&!this.__pathInputed)continue;e=s?s[r]:void 0,i[r]=g(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:r,e:o,f:n}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:r,e:o,f:n}}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,this.__complexData&&this.__complexData.destroy()}},T={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=C;return e[t]?e[t]++:(e[t]=1,0)}},C=T,{max:O}=Math,R=[0,0,0,0],P={zero:[...R],tempFour:R,set:(t,e,i,s,r)=>(void 0===i&&(i=s=r=e),t[0]=e,t[1]=i,t[2]=s,t[3]=r,t),setTemp:(t,e,i,s)=>L(R,t,e,i,s),toTempAB(t,e,i){k=i?y(t)?e:t:[],y(t)?(x=D(t),b=e):y(e)?(x=t,b=D(e)):(x=t,b=e),4!==x.length&&(x=M(x)),4!==b.length&&(b=M(b))},get(t,e){let i;if(!y(t))switch(t.length){case 4:i=g(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]),!g(e))for(let s=0;s<4;s++)i[s]>e&&(i[s]=e);return i},max:(t,e,i)=>y(t)&&y(e)?O(t,e):(A(t,e,i),L(k,O(x[0],b[0]),O(x[1],b[1]),O(x[2],b[2]),O(x[3],b[3]))),add:(t,e,i)=>y(t)&&y(e)?t+e:(A(t,e,i),L(k,x[0]+b[0],x[1]+b[1],x[2]+b[2],x[3]+b[3])),swapAndScale(t,e,i,s){if(y(t))return e===i?t*e:[t*i,t*e];const r=s?t:[],[o,n,a,h]=4===t.length?t:M(t);return L(r,a*i,h*e,o*i,n*e)}},{set:L,get:M,setTemp:D,toTempAB:A}=P,{round:I,pow:W,max:z,floor:F,PI:Y}=Math,N={},X={within:(t,e,i)=>(w(e)&&(i=e.max,e=e.min),!g(e)&&t<e&&(t=e),!g(i)&&t>i&&(t=i),t),fourNumber:P.get,formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),X.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=g(e)?1e12:W(10,e);return-0===(t=I(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(y(e)?e:e.width||0)/i.width,r=(y(e)?e:e.height||0)/i.height;s.scaleX=t||r||1,s.scaleY=r||t||1}else t&&X.assignScale(s,t);return s},getScaleFixedData(t,e,i,s,r){let{scaleX:o,scaleY:n}=t;if((s||e)&&(o<0&&(o=-o),n<0&&(n=-n)),e)if(!0===e)o=n=i?1:1/o;else{let t;y(e)?t=e:"zoom-in"===e&&(t=1),t&&(o=n=o>t||n>t?i?1:1/o:i?1:1/t)}return N.scaleX=o,N.scaleY=n,N},assignScale(t,e){y(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>z(F(t),e)/t,randInt:H,randColor:t=>`rgba(${H(255)},${H(255)},${H(255)},${t||1})`};function H(t){return Math.round(Math.random()*t)}var V=Y/180,U=2*Y,j=Y/2;function G(){return{a:1,b:0,c:0,d:1,e:0,f:0}}var{sin:K,cos:Z,acos:q,sqrt:$}=Math,{float:J}=X,Q={};function tt(){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})}var et,it,st={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:tt(),tempMatrix:{},set(t,e=1,i=0,s=0,r=1,o=0,n=0){t.a=e,t.b=i,t.c=s,t.d=r,t.e=o,t.f=n},get:G,getWorld:tt,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},pixelScale(t,e,i){i||(i=t),i.a=t.a*e,i.b=t.b*e,i.c=t.c*e,i.d=t.d*e,i.e=t.e*e,i.f=t.f*e},scaleOfOuter(t,e,i,s){rt.toInnerPoint(t,e,Q),rt.scaleOfInner(t,Q,i,s)},scaleOfInner(t,e,i,s=i){rt.translateInner(t,e.x,e.y),rt.scale(t,i,s),rt.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:r,d:o}=t,n=Z(e*=V),a=K(e);t.a=i*n-s*a,t.b=i*a+s*n,t.c=r*n-o*a,t.d=r*a+o*n},rotateOfOuter(t,e,i){rt.toInnerPoint(t,e,Q),rt.rotateOfInner(t,Q,i)},rotateOfInner(t,e,i){rt.translateInner(t,e.x,e.y),rt.rotate(t,i),rt.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:r,c:o,d:n}=t;i&&(i*=V,t.a=s+o*i,t.b=r+n*i),e&&(e*=V,t.c=o+s*e,t.d=n+r*e)},skewOfOuter(t,e,i,s){rt.toInnerPoint(t,e,Q),rt.skewOfInner(t,Q,i,s)},skewOfInner(t,e,i,s=0){rt.translateInner(t,e.x,e.y),rt.skew(t,i,s),rt.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:r,d:o,e:n,f:a}=t;t.a=e.a*i+e.b*r,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*r,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*r+n,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,r){const{e:o,f:n}=t;if(i||(i=t),g(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:n,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=n*e.a+a*e.c,i.d=n*e.b+a*e.d,r&&(i.scaleX=e.scaleX*r.scaleX,i.scaleY=e.scaleY*r.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,r&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=o*e.a+n*e.c+e.e,i.f=o*e.b+n*e.d+e.f},divide(t,e){rt.multiply(t,rt.tempInvert(e))},divideParent(t,e){rt.multiplyParent(t,rt.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=rt;return rt.copy(e,t),rt.invert(e),e},invert(t){const{a:e,b:i,c:s,d:r,e:o,f:n}=t;if(i||s){const a=1/(e*r-i*s);t.a=r*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*r-n*s)*a,t.f=-(n*e-o*i)*a}else if(1===e&&1===r)t.e=-o,t.f=-n;else{const i=1/(e*r);t.a=r*i,t.d=e*i,t.e=-o*r*i,t.f=-n*e*i}},toOuterPoint(t,e,i,s){const{x:r,y:o}=e;i||(i=e),i.x=r*t.a+o*t.c,i.y=r*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:r,b:o,c:n,d:a}=t,h=1/(r*a-o*n),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*n)*h,i.y=(d*r-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*n)*h,i.y-=(s*r-e*o)*h}},setLayout(t,e,i,s,r){const{x:o,y:n,scaleX:a,scaleY:h}=e;if(g(r)&&(r=e.rotation||e.skewX||e.skewY),r){const{rotation:i,skewX:s,skewY:r}=e,o=i*V,n=Z(o),l=K(o);if(s||r){const e=s*V,i=r*V;t.a=(n+i*-l)*a,t.b=(l+i*n)*a,t.c=(e*n-l)*h,t.d=(n+e*l)*h}else t.a=n*a,t.b=l*a,t.c=-l*h,t.d=n*h}else t.a=a,t.b=0,t.c=0,t.d=h;t.e=o,t.f=n,(i=i||s)&&rt.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:r,b:o,c:n,d:a,e:h,f:l}=t;let d,c,u,p,g,_=h,f=l;if(o||n){const t=r*a-o*n;if(n&&!s){d=$(r*r+o*o),c=t/d;const e=r/d;u=o>0?q(e):-q(e)}else{c=$(n*n+a*a),d=t/c;const e=n/c;u=j-(a>0?q(-e):-q(e))}const e=J(Z(u)),i=K(u);d=J(d),c=J(c),p=e?J((n/c+i)/e/V,9):0,g=e?J((o/d-i)/e/V,9):0,u=J(u/V)}else d=r,c=a,u=p=g=0;return(e=i||e)&&(_+=e.x*r+e.y*n,f+=e.x*o+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:p,skewY:g}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:r,c:o,d:n}=t;r||o?i=(s*n-r*o)/(e=$(s*s+r*r)):(e=s,i=n)}return s.scaleX=e,s.scaleY=i,s},reset(t){rt.set(t)}},rt=st,{float:ot}=X,{toInnerPoint:nt,toOuterPoint:at}=st,{sin:ht,cos:lt,abs:dt,sqrt:ct,atan2:ut,min:pt,round:gt}=Math,_t={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=g(i)?e:i},copy(t,e){t.x=e.x,t.y=e.y},copyFrom(t,e,i){t.x=e,t.y=i},round(t,e){t.x=e?gt(t.x-.5)+.5:gt(t.x),t.y=e?gt(t.y-.5)+.5:gt(t.y)},move(t,e,i){w(e)?(t.x+=e.x,t.y+=e.y):(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=ft.defaultPoint);const s=lt(e*=V),r=ht(e),o=t.x-i.x,n=t.y-i.y;t.x=i.x+o*s-n*r,t.y=i.y+o*r+n*s},tempToInnerOf(t,e){const{tempPoint:i}=ft;return yt(i,t),nt(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=ft;return yt(i,t),at(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=ft;return yt(i,t),ft.toInnerRadiusPointOf(t,e,i),i},copyRadiusPoint:(t,e,i,s)=>(yt(t,e),vt(t,i,s),t),toInnerRadiusPointOf(t,e,i){i||(i=t),nt(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){nt(e,t,i)},toOuterOf(t,e,i){at(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)=>mt(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const r=dt(i-t),o=dt(s-e);return ct(r*r+o*o)},getMinDistanceFrom:(t,e,i,s,r,o)=>pt(mt(t,e,i,s),mt(i,s,r,o)),getAngle:(t,e)=>wt(t,e)/V,getRotation:(t,e,i,s)=>(s||(s=e),ft.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/V),getRadianFrom(t,e,i,s,r,o,n,a){g(n)&&(n=i,a=s);const h=t-i,l=e-s,d=r-n,c=o-a;return Math.atan2(h*c-l*d,h*d+l*c)},getAtan2:(t,e)=>ut(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s,r){const o=wt(t,e);return r&&(t=e),s||(e={}),e.x=t.x+lt(o)*i,e.y=t.y+ht(o)*i,e},toNumberPoints(t){let e=t;return w(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e,i)=>i?t.x===e.x&&t.y===e.y:ot(t.x)===ot(e.x)&&ot(t.y)===ot(e.y),reset(t){ft.reset(t)}},ft=_t,{getDistanceFrom:mt,copy:yt,setRadius:vt,getAtan2:wt}=ft,xt=class t{constructor(t,e){this.set(t,e)}set(t,e){return w(t)?_t.copy(this,t):_t.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new t(this)}move(t,e){return _t.move(this,t,e),this}scale(t,e){return _t.scale(this,t,e),this}scaleOf(t,e,i){return _t.scaleOf(this,t,e,i),this}rotate(t,e){return _t.rotate(this,t,e),this}rotateOf(t,e){return _t.rotate(this,e,t),this}getRotation(t,e,i){return _t.getRotation(this,t,e,i)}toInnerOf(t,e){return _t.toInnerOf(this,t,e),this}toOuterOf(t,e){return _t.toOuterOf(this,t,e),this}getCenter(e){return new t(_t.getCenter(this,e))}getDistance(t){return _t.getDistance(this,t)}getDistancePoint(e,i,s,r){return new t(_t.getDistancePoint(this,e,i,s,r))}getAngle(t){return _t.getAngle(this,t)}getAtan2(t){return _t.getAtan2(this,t)}isSame(t,e){return _t.isSame(this,t,e)}reset(){return _t.reset(this),this}},bt=(new xt,class t{constructor(t,e,i,s,r,o){this.set(t,e,i,s,r,o)}set(t,e,i,s,r,o){return w(t)?st.copy(this,t):st.set(this,t,e,i,s,r,o),this}setWith(t){return st.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:r,f:o}=this;return{a:t,b:e,c:i,d:s,e:r,f:o}}clone(){return new t(this)}translate(t,e){return st.translate(this,t,e),this}translateInner(t,e){return st.translateInner(this,t,e),this}scale(t,e){return st.scale(this,t,e),this}scaleWith(t,e){return st.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return st.pixelScale(this,t),this}scaleOfOuter(t,e,i){return st.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return st.scaleOfInner(this,t,e,i),this}rotate(t){return st.rotate(this,t),this}rotateOfOuter(t,e){return st.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return st.rotateOfInner(this,t,e),this}skew(t,e){return st.skew(this,t,e),this}skewOfOuter(t,e,i){return st.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return st.skewOfInner(this,t,e,i),this}multiply(t){return st.multiply(this,t),this}multiplyParent(t){return st.multiplyParent(this,t),this}divide(t){return st.divide(this,t),this}divideParent(t){return st.divideParent(this,t),this}invert(){return st.invert(this),this}invertWith(){return st.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){st.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){st.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return st.setLayout(this,t,e,i),this}getLayout(t,e,i){return st.getLayout(this,t,e,i)}withScale(t,e){return st.withScale(this,t,e)}reset(){st.reset(this)}}),kt=(new bt,{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,r){Et(t,e,i),Et(t,e+s,i+r)},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:Et}=kt;(function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"})(et||(et={})),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"}(it||(it={}));var St=[{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}];St.forEach(t=>t.type="percent");var Bt={directionData:St,tempPoint:{},get:Tt,toPoint(t,e,i,s,r,o){const n=Tt(t);i.x=n.x,i.y=n.y,"percent"===n.type&&(i.x*=e.width,i.y*=e.height,r&&(o||(i.x-=r.x,i.y-=r.y),n.x&&(i.x-=1===n.x?r.width:.5===n.x?n.x*r.width:0),n.y&&(i.y-=1===n.y?r.height:.5===n.y?n.y*r.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i,s=!0)=>(i||(i={}),Bt.toPoint(t,e,i,s),i)};function Tt(t){return f(t)?St[it[t]]:t}var Ct,Ot,Rt,Pt,{toPoint:Lt}=Bt,Mt={toPoint(t,e,i,s,r,o){Lt(t,i,s,r,e,o)}},{tempPointBounds:Dt,setPoint:At,addPoint:It,toBounds:Wt}=kt,{toOuterPoint:zt}=st,{float:Ft,fourNumber:Yt}=X,{floor:Nt,ceil:Xt}=Math,Ht={},Vt={},Ut={},jt={tempBounds:Ut,set(t,e=0,i=0,s=0,r=0){t.x=e,t.y=i,t.width=s,t.height=r},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,r){const{x:o,y:n,width:a,height:h}=e;if(v(i)){const e=Yt(i);s?Gt.set(t,o+e[3],n+e[0],a-e[1]-e[3],h-e[2]-e[0]):Gt.set(t,o-e[3],n-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Gt.set(t,o-i,n-i,a+2*i,h+2*i);r&&("width"===r?(t.y=n,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},scroll(t,e){t.x+=e.scrollX,t.y+=e.scrollY},getByMove:(t,e,i)=>(t=Object.assign({},t),Gt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Zt(e,t):e=t,i||(i=t),e.offsetX=Gt.maxX(i),e.offsetY=Gt.maxY(i),Gt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||_t.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){_t.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Gt.copy(Ut,t),Gt.toOuterOf(Ut,e),Ut),getOuterOf:(t,e)=>(t=Object.assign({},t),Gt.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:r,e:o,f:n}=e;s>0?(i.width=t.width*s,i.x=o+t.x*s):(i.width=t.width*-s,i.x=o+t.x*s-i.width),r>0?(i.height=t.height*r,i.y=n+t.y*r):(i.height=t.height*-r,i.y=n+t.y*r-i.height)}else Ht.x=t.x,Ht.y=t.y,zt(e,Ht,Vt),At(Dt,Vt.x,Vt.y),Ht.x=t.x+t.width,zt(e,Ht,Vt),It(Dt,Vt.x,Vt.y),Ht.y=t.y+t.height,zt(e,Ht,Vt),It(Dt,Vt.x,Vt.y),Ht.x=t.x,zt(e,Ht,Vt),It(Dt,Vt.x,Vt.y),Wt(Dt,i)},toInnerOf(t,e,i){i||(i=t),Gt.move(i,-e.e,-e.f),Gt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Gt.getFitScale(t,e));return new bt(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,r=t.height/e.height;return i?Math.max(s,r):Math.min(s,r)},put(t,e,i="center",s=1,r=!0,o){o||(o=e),f(s)&&(s=Gt.getFitScale(t,e,"cover"===s)),Ut.width=r?e.width*=s:e.width*s,Ut.height=r?e.height*=s:e.height*s,Mt.toPoint(i,Ut,t,o,!0,!0)},getSpread(t,e,i){const s={};return Gt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Gt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Gt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=Nt(t.x),t.y=Nt(t.y),t.width=e>t.x?Xt(t.width+e-t.x):Xt(t.width),t.height=i>t.y?Xt(t.height+i-t.y):Xt(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=Ft(t.x,e),t.y=Ft(t.y,e),t.width=Ft(t.width,e),t.height=Ft(t.height,e)},add(t,e,i){Ct=t.x+t.width,Ot=t.y+t.height,Rt=e.x,Pt=e.y,i||(Rt+=e.width,Pt+=e.height),Ct=Ct>Rt?Ct:Rt,Ot=Ot>Pt?Ot:Pt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=Ct-t.x,t.height=Ot-t.y},addList(t,e){Gt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Gt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Gt.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let r,o=!0;for(let n=0,a=e.length;n<a;n++)r=i?i(e[n],n):e[n],r&&(r.width||r.height)&&(o?(o=!1,s||Zt(t,r)):Kt(t,r));o&&Gt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?At(Dt,t.x,t.y):It(Dt,t.x,t.y)),Wt(Dt,t)},setPoint(t,e){Gt.set(t,e.x,e.y)},addPoint(t,e){Kt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:r}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+r},{x:e,y:i+r}]},getPoint:(t,e,i=!1,s)=>Bt.getPoint(e,t,s,i),hitRadiusPoint:(t,e,i)=>(i&&(e=_t.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=_t.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=Gt.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=Gt.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=Gt.tempToOuterOf(e,i)),!Gt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:r,width:o,height:n}=e;return Ct=s+o,Ot=r+n,Rt=t.x+t.width,Pt=t.y+t.height,s=s>t.x?s:t.x,r=r>t.y?r:t.y,o=(Ct=Ct<Rt?Ct:Rt)-s,n=(Ot=Ot<Pt?Ot:Pt)-r,{x:s,y:r,width:o,height:n}},intersect(t,e,i){Gt.copy(t,Gt.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,hasSize:t=>t.width&&t.height,reset(t){Gt.set(t)}},Gt=jt,{add:Kt,copy:Zt}=Gt,qt=class t{get minX(){return jt.minX(this)}get minY(){return jt.minY(this)}get maxX(){return jt.maxX(this)}get maxY(){return jt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return w(t)?jt.copy(this,t):jt.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 t(this)}move(t,e){return jt.move(this,t,e),this}scale(t,e,i){return jt.scale(this,t,e,i),this}scaleOf(t,e,i){return jt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return jt.toOuterOf(this,t,e),this}toInnerOf(t,e){return jt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return jt.getFitMatrix(this,t,e)}put(t,e,i){jt.put(this,t,e,i)}spread(t,e){return jt.spread(this,t,e),this}shrink(t,e){return jt.shrink(this,t,e),this}ceil(){return jt.ceil(this),this}unsign(){return jt.unsign(this),this}float(t){return jt.float(this,t),this}add(t){return jt.add(this,t),this}addList(t){return jt.setList(this,t,!0),this}setList(t){return jt.setList(this,t),this}addListWithFn(t,e){return jt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return jt.setListWithFn(this,t,e),this}setPoint(t){return jt.setPoint(this,t),this}setPoints(t){return jt.setPoints(this,t),this}addPoint(t){return jt.addPoint(this,t),this}getPoints(){return jt.getPoints(this)}getPoint(t,e,i){return jt.getPoint(this,t,e,i)}hitPoint(t,e){return jt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return jt.hitRadiusPoint(this,t,e)}hit(t,e){return jt.hit(this,t,e)}includes(t,e){return jt.includes(this,t,e)}intersect(t,e){return jt.intersect(this,t,e),this}getIntersect(e,i){return new t(jt.getIntersectData(this,e,i))}isSame(t){return jt.isSame(this,t)}isEmpty(){return jt.isEmpty(this)}reset(){jt.reset(this)}},$t=new qt,Jt=class{constructor(t,e,i,s,r,o){w(t)?this.copy(t):this.set(t,e,i,s,r,o)}set(t=0,e=0,i=0,s=0,r=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=r,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:r,width:o,height:n}=t;this.set(e,i,s,r,o,n)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:r,width:o,height:n}=this;return new qt(r,e,o||t.width-r-i,n||t.height-e-s)}},Qt={number:(t,e)=>w(t)?"percent"===t.type?t.value*e:t.value:t},te={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},{floor:ee,max:ie}=Math,se={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",isLarge:(t,e,i,s)=>t.width*t.height*(e?e*i:1)>(s||re.maxCacheSize),isSuperLarge:(t,e,i)=>re.isLarge(t,e,i,re.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=re;return!i||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+i),e&&"/"===t[0]&&(t=e+t),t},resize(t,e,i,s,r,o,n,a,h,l){const d=ie(ee(e+(s||0)),1),c=ie(ee(i+(r||0)),1);let u,p,g;l&&(g=Qt.number(l.offset,"x"===l.type?e:i))&&("x"===l.type?u=!0:p=!0);const _=se.origin.createCanvas(p?2*d:d,u?2*c:c),f=_.getContext("2d");if(a&&(f.globalAlpha=a),f.imageSmoothingEnabled=!1!==n,re.canUse(t)){if(o){const s=e/o.width,r=i/o.height;f.setTransform(s,0,0,r,-o.x*s,-o.y*r),f.drawImage(t,0,0,t.width,t.height)}else f.drawImage(t,0,0,e,i);g&&(f.drawImage(_,0,0,d,c,u?g-d:d,u?c:g-c,d,c),f.drawImage(_,0,0,d,c,u?g:d,u?c:g,d,c))}return _},canUse:t=>t&&t.width&&!t.__closed,setPatternTransform(t,e,i){try{e&&t.setTransform&&(t.setTransform(e),e=void 0)}catch(t){}i&&E.stintSet(i,"transform",e)}}},{image:re}=se,{randColor:oe}=X,ne=class t{constructor(t){this.repeatMap={},this.name=t}static get(e){return new t(e)}static set filter(t){this.filterList=ae(t)}static set exclude(t){this.excludeList=ae(t)}static drawRepaint(t,e){const i=oe();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(e,i,s){const r="hit"===t.showBounds,o=e.__nowWorld,n=oe();r&&(i.setWorld(o),e.__drawHitPath(i),i.fillStyle=n.replace("1)",".2)"),i.fill()),i.resetTransform(),i.setStroke(n,2),r?i.stroke():i.strokeWorld(o,n)}log(...t){if(he.enable){if(he.filterList.length&&he.filterList.every(t=>t!==this.name))return;if(he.excludeList.length&&he.excludeList.some(t=>t===this.name))return}}tip(...t){he.enable&&this.warn(...t)}warn(...t){he.showWarn}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(p){}}};function ae(t){return t?f(t)&&(t=[t]):t=[],t}ne.filterList=[],ne.excludeList=[],ne.showWarn=!0;var he=ne,le=ne.get("RunTime"),de={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=T.create(T.RUNTIME);return ce.currentId=ce.idMap[i]=e?performance.now():Date.now(),ce.currentName=ce.nameMap[i]=t,ce.nameToIdMap[t]=i,i},end(t,e){const i=ce.idMap[t],s=ce.nameMap[t],r=e?(performance.now()-i)/1e3:Date.now()-i;ce.idMap[t]=ce.nameMap[t]=ce.nameToIdMap[s]=void 0,le.log(s,r,"ms")},endOfName(t,e){const i=ce.nameToIdMap[t];g(i)||ce.end(i,e)}},ce=de,ue=[],pe={list:{},add(t,...e){this.list[t]=!0,ue.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){}};setTimeout(()=>ue.forEach(t=>pe.has(t,!0)));var ge={editor:t=>pe.need("editor")},_e=ne.get("UICreator"),fe={list:{},register(t){const{__tag:e}=t.prototype;me[e]&&_e.repeat(e),me[e]=t},get(t,e,i,s,r,o){if(!me[t])return void _e.warn("not register "+t);const n=new me[t](e);return g(i)||(n.x=i,s&&(n.y=s),r&&(n.width=r),o&&(n.height=o)),n}},{list:me}=fe,ye=ne.get("EventCreator"),ve={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],f(e)&&(we[e]&&ye.repeat(e),we[e]=t)})},changeName(t,e){const i=we[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,we[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new we[t](...e)},{nameList:we}=ve,xe=class{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let r=0,o=i.length;r<o;r++)if(e=i[r],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const s=ge.canvas(t);return this.add(s),s}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()}};function be(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}function ke(t,e,i,s){return new(i||(i=Promise))(function(r,o){function n(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?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,a)}h((s=s.apply(t,e||[])).next())})}function Ee(t){return(e,i)=>{t||(t=i);const s={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===i&&(s.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,i,s)}}var Se=[];function Be(){return(t,e)=>{Se.push(e)}}var Te=[],Ce=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||Te)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Se.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,r,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,r,o){w(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,r,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,r,o,n,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/r*h;r+=i,i=0,n+=t,h-=t}this.context.drawImage(t,e,i,s,r,o,n,a,h);break;case 5:this.context.drawImage(t,e,i,s,r);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,r,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,r,o){}arcTo(t,e,i,s,r){}ellipse(t,e,i,s,r,o,n,a){}rect(t,e,i,s){}roundRect(t,e,i,s,r){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,r,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}};be([Ee("imageSmoothingEnabled")],Ce.prototype,"smooth",void 0),be([Ee("imageSmoothingQuality")],Ce.prototype,"smoothLevel",void 0),be([Ee("globalAlpha")],Ce.prototype,"opacity",void 0),be([Ee()],Ce.prototype,"fillStyle",void 0),be([Ee()],Ce.prototype,"strokeStyle",void 0),be([Ee("lineWidth")],Ce.prototype,"strokeWidth",void 0),be([Ee("lineCap")],Ce.prototype,"strokeCap",void 0),be([Ee("lineJoin")],Ce.prototype,"strokeJoin",void 0),be([Ee("lineDashOffset")],Ce.prototype,"dashOffset",void 0),be([Ee()],Ce.prototype,"miterLimit",void 0),be([Ee()],Ce.prototype,"shadowBlur",void 0),be([Ee()],Ce.prototype,"shadowColor",void 0),be([Ee()],Ce.prototype,"shadowOffsetX",void 0),be([Ee()],Ce.prototype,"shadowOffsetY",void 0),be([Ee()],Ce.prototype,"filter",void 0),be([Ee()],Ce.prototype,"font",void 0),be([Ee()],Ce.prototype,"fontKerning",void 0),be([Ee()],Ce.prototype,"fontStretch",void 0),be([Ee()],Ce.prototype,"fontVariantCaps",void 0),be([Ee()],Ce.prototype,"textAlign",void 0),be([Ee()],Ce.prototype,"textBaseline",void 0),be([Ee()],Ce.prototype,"textRendering",void 0),be([Ee()],Ce.prototype,"wordSpacing",void 0),be([Ee()],Ce.prototype,"letterSpacing",void 0),be([Ee()],Ce.prototype,"direction",void 0),be([Be()],Ce.prototype,"setTransform",null),be([Be()],Ce.prototype,"resetTransform",null),be([Be()],Ce.prototype,"getTransform",null),be([Be()],Ce.prototype,"save",null),be([Be()],Ce.prototype,"restore",null),be([Be()],Ce.prototype,"translate",null),be([Be()],Ce.prototype,"scale",null),be([Be()],Ce.prototype,"rotate",null),be([Be()],Ce.prototype,"fill",null),be([Be()],Ce.prototype,"stroke",null),be([Be()],Ce.prototype,"clip",null),be([Be()],Ce.prototype,"fillRect",null),be([Be()],Ce.prototype,"strokeRect",null),be([Be()],Ce.prototype,"clearRect",null),be([Be()],Ce.prototype,"beginPath",null),be([Be()],Ce.prototype,"moveTo",null),be([Be()],Ce.prototype,"lineTo",null),be([Be()],Ce.prototype,"bezierCurveTo",null),be([Be()],Ce.prototype,"quadraticCurveTo",null),be([Be()],Ce.prototype,"closePath",null),be([Be()],Ce.prototype,"arc",null),be([Be()],Ce.prototype,"arcTo",null),be([Be()],Ce.prototype,"ellipse",null),be([Be()],Ce.prototype,"rect",null),be([Be()],Ce.prototype,"roundRect",null),be([Be()],Ce.prototype,"createConicGradient",null),be([Be()],Ce.prototype,"createLinearGradient",null),be([Be()],Ce.prototype,"createPattern",null),be([Be()],Ce.prototype,"createRadialGradient",null),be([Be()],Ce.prototype,"fillText",null),be([Be()],Ce.prototype,"measureText",null),be([Be()],Ce.prototype,"strokeText",null);var{copy:Oe,multiplyParent:Re,pixelScale:Pe}=st,{round:Le}=Math,Me=new qt,De=new qt,Ae={width:1,height:1,pixelRatio:1},Ie=["width","height","pixelRatio"],We=class extends Ce{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||0}get pixelHeight(){return this.height*this.pixelRatio||0}get pixelSnap(){return this.config.pixelSnap}set pixelSnap(t){this.config.pixelSnap=t}get allowBackgroundColor(){return this.view&&this.parentView}constructor(t,e){super(),this.size={},this.worldTransform={},t||(t=Ae),this.manager=e,this.innerId=T.create(T.CNAVAS);const{width:i,height:s,pixelRatio:r}=t;this.autoLayout=!i||!s,this.size.pixelRatio=r||se.devicePixelRatio,this.config=t,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;E.copyAttrs(s,t,Ie),Ie.forEach(t=>s[t]||(s[t]=1)),this.bounds=new qt(0,0,this.width,this.height),this.updateViewSize(),this.updateClientBounds(),this.context&&(this.smooth=this.config.smooth,!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,pixelSnap:s}=this,r=this.worldTransform;e&&Re(t,e,r),Pe(t,i,r),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(r.e=Le(r.e-.5)+.5,r.f=Le(r.f-.5)+.5):(r.e=Le(r.e),r.f=Le(r.f))),this.setTransform(r.a,r.b,r.c,r.d,r.e,r.f)}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,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),i&&this.setStrokeOptions(i,s)}setStrokeOptions(t,e){let{strokeCap:i,strokeJoin:s,dashPattern:r,dashOffset:o,miterLimit:n}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),g(e.dashPattern)||(r=e.dashPattern),g(e.dashOffset)||(o=e.dashOffset),e.miterLimit&&(n=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=r,this.dashOffset=o,this.miterLimit=n}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:r}=this;this.shadowOffsetX=t*r,this.shadowOffsetY=e*r,this.shadowBlur=i*r,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,r){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,r),i?(this.setTempPixelBounds2(i,r),i=De):i=Me,this.drawImage(t.view,Me.x,Me.y,Me.width,Me.height,i.x,i.y,i.width,i.height)):this.drawImage(t.view,0,0),s&&(this.blendMode="source-over")}copyWorldToInner(t,e,i,s,r){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,jt.tempToOuterOf(i,e),s,r),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,r),this.drawImage(t.view,Me.x,Me.y,Me.width,Me.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,r,o){this.resetTransform(),this.copyWorld(t,e,i,s,o),r||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,r=s.getImageData(Me.x,Me.y,Me.width,Me.height),{data:o}=r;for(let n=0,a=o.length;n<a;n+=4)i=.299*o[n]+.587*o[n+1]+.114*o[n+2],(e=o[n+3])&&(o[n+3]=255===e?i:e*(i/255));s.putImageData(r,Me.x,Me.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,s){i&&(this.blendMode=i),this.fillStyle=e,this.setTempPixelBounds(t,s),this.fillRect(Me.x,Me.y,Me.width,Me.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Me.x,Me.y,Me.width,Me.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Me.x,Me.y,Me.width,Me.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Me.x,Me.y,Me.width,Me.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Me,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(De,t,e,i)}copyToPixelBounds(t,e,i,s){t.set(e),s&&t.intersect(this.bounds),t.scale(this.pixelRatio),i&&t.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:i,pixelSnap:s}=this,r=this.manager?this.manager.get(i):ge.canvas(Object.assign({},i));return r.save(),t&&(Oe(r.worldTransform,this.worldTransform),r.useWorldTransform()),e&&(r.smooth=this.smooth),r.pixelSnap!==s&&(r.pixelSnap=s),r}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}},ze={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Fe={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Ye=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},Fe),Ne={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},Xe={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},He=Object.assign(Object.assign({},Xe),Fe),Ve=Ye,Ue={};for(let tm in Ve)Ue[Ve[tm]]=tm;var je={};for(let tm in Ve)je[Ve[tm]]=Ne[tm];var Ge,Ke,Ze,qe={drawRoundRect(t,e,i,s,r,o){const n=X.fourNumber(o,Math.min(s/2,r/2)),a=e+s,h=i+r;n[0]?t.moveTo(e+n[0],i):t.moveTo(e,i),n[1]?t.arcTo(a,i,a,h,n[1]):t.lineTo(a,i),n[2]?t.arcTo(a,h,e,h,n[2]):t.lineTo(a,h),n[3]?t.arcTo(e,h,e,i,n[3]):t.lineTo(e,h),n[0]?t.arcTo(e,i,a,i,n[0]):t.lineTo(e,i)}},{sin:$e,cos:Je,hypot:Qe,atan2:ti,ceil:ei,abs:ii,PI:si,sqrt:ri,pow:oi}=Math,{setPoint:ni,addPoint:ai}=kt,{set:hi,toNumberPoints:li}=_t,{M:di,L:ci,C:ui,Q:pi,Z:gi}=Ye,_i={},fi={points(t,e,i,s){let r=li(e);if(t.push(di,r[0],r[1]),i&&r.length>5){let e,o,n,a,h,l,d,c,u,p,g,_,f,m,y,v=r.length;const w=!0===i?.5:i;s&&(r=[r[v-2],r[v-1],...r,r[0],r[1],r[2],r[3]],v=r.length);for(let i=2;i<v-2;i+=2)e=r[i-2],o=r[i-1],n=r[i],a=r[i+1],h=r[i+2],l=r[i+3],g=n-e,_=a-o,f=ri(oi(g,2)+oi(_,2)),m=ri(oi(h-n,2)+oi(l-a,2)),(f||m)&&(y=f+m,f=w*f/y,m=w*m/y,h-=e,l-=o,d=n-f*h,c=a-f*l,2===i?s||t.push(pi,d,c,n,a):(g||_)&&t.push(ui,u,p,d,c,n,a),u=n+m*h,p=a+m*l);s||t.push(pi,u,p,r[v-2],r[v-1])}else for(let o=2,n=r.length;o<n;o+=2)t.push(ci,r[o],r[o+1]);s&&t.push(gi)},rect(t,e,i,s,r){ze.creator.path=t,ze.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+r).lineTo(e,i+r).lineTo(e,i)},roundRect(t,e,i,s,r,o){ze.creator.path=[],qe.drawRoundRect(ze.creator,e,i,s,r,o),t.push(...ze.convertToCanvasData(ze.creator.path,!0))},arcTo(t,e,i,s,r,o,n,a,h,l,d){const c=s-e,u=r-i,p=o-s,g=n-r;let _=ti(u,c),f=ti(g,p);const m=Qe(c,u),y=Qe(p,g);let v=f-_;if(v<0&&(v+=U),m<1e-12||y<1e-12||v<1e-12||ii(v-si)<1e-12)return t&&t.push(ci,s,r),h&&(ni(h,e,i),ai(h,s,r)),d&&hi(d,e,i),void(l&&hi(l,s,r));const w=c*g-p*u<0,x=w?-1:1,b=a/Je(v/2),k=s+b*Je(_+v/2+j*x),E=r+b*$e(_+v/2+j*x);return _-=j*x,f-=j*x,vi(t,k,E,a,a,0,_/V,f/V,w,h,l,d)},arc:(t,e,i,s,r,o,n,a,h,l)=>vi(t,e,i,s,s,0,r,o,n,a,h,l),ellipse(t,e,i,s,r,o,n,a,h,l,d,c){const u=o*V,p=$e(u),g=Je(u);let _=n*V,f=a*V;_>si&&(_-=U),f<0&&(f+=U);let m=f-_;m<0?m+=U:m>U&&(m-=U),h&&(m-=U);const y=ei(ii(m/j)),v=m/y,w=$e(v/4),x=8/3*w*w/$e(v/2);f=_+v;let b,k,E,S,B,T,C,O,R=Je(_),P=$e(_),L=E=g*s*R-p*r*P,M=S=p*s*R+g*r*P,D=e+E,A=i+S;t&&t.push(t.length?ci:di,D,A),l&&ni(l,D,A),c&&hi(c,D,A);for(let I=0;I<y;I++)b=Je(f),k=$e(f),E=g*s*b-p*r*k,S=p*s*b+g*r*k,B=e+L-x*(g*s*P+p*r*R),T=i+M-x*(p*s*P-g*r*R),C=e+E+x*(g*s*k+p*r*b),O=i+S+x*(p*s*k-g*r*b),t&&t.push(ui,B,T,C,O,e+E,i+S),l&&yi(e+L,i+M,B,T,C,O,e+E,i+S,l,!0),L=E,M=S,R=b,P=k,_=f,f+=v;d&&hi(d,e+E,i+S)},quadraticCurveTo(t,e,i,s,r,o,n){t.push(ui,(e+2*s)/3,(i+2*r)/3,(o+2*s)/3,(n+2*r)/3,o,n)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,r,o,n,a){yi(t,e,(t+2*i)/3,(e+2*s)/3,(r+2*i)/3,(o+2*s)/3,r,o,n,a)},toTwoPointBounds(t,e,i,s,r,o,n,a,h,l){const d=[];let c,u,p,g,_,f,m,y,v=t,w=i,x=r,b=n;for(let k=0;k<2;++k)if(1==k&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,p=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-p/u,0<g&&g<1&&d.push(g)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(_=(-u+y)/(2*c),0<_&&_<1&&d.push(_),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?ai(h,t,e):ni(h,t,e),ai(h,n,a);for(let k=0,E=d.length;k<E;k++)mi(d[k],t,e,i,s,r,o,n,a,_i),ai(h,_i.x,_i.y)},getPointAndSet(t,e,i,s,r,o,n,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,g=t*t*t;l.x=c*e+u*s+p*o+g*a,l.y=c*i+u*r+p*n+g*h},getPoint(t,e,i,s,r,o,n,a,h){const l={};return mi(t,e,i,s,r,o,n,a,h,l),l},getDerivative(t,e,i,s,r){const o=1-t;return 3*o*o*(i-e)+6*o*t*(s-i)+3*t*t*(r-s)},cut(t,e,i,s,r,o,n,a,h){if(t<=0)return{left:null,right:[s,r,o,n,a,h]};if(t>=1)return{left:[s,r,o,n,a,h],right:null};const l=1-t,d=e*l+s*t,c=i*l+r*t,u=s*l+o*t,p=r*l+n*t,g=o*l+a*t,_=n*l+h*t,f=d*l+u*t,m=c*l+p*t,y=u*l+g*t,v=p*l+_*t;return{left:[d,c,f,m,f*l+y*t,m*l+v*t],right:[y,v,g,_,a,h]}}},{getPointAndSet:mi,toTwoPointBounds:yi,ellipse:vi}=fi,{sin:wi,cos:xi,sqrt:bi,atan2:ki}=Math,{ellipse:Ei}=fi,Si={ellipticalArc(t,e,i,s,r,o,n,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,p=o*V,g=wi(p),_=xi(p),f=-_*c-g*u,m=-_*u+g*c,y=s*s,v=r*r,w=m*m,x=f*f,b=y*v-y*w-v*x;let k=0;if(b<0){const t=bi(1-b/(y*v));s*=t,r*=t}else k=(n===a?-1:1)*bi(b/(y*w+v*x));const E=k*s*m/r,S=-k*r*f/s,B=ki((m-S)/r,(f-E)/s),T=ki((-m-S)/r,(-f-E)/s);let C=T-B;0===a&&C>0?C-=U:1===a&&C<0&&(C+=U);const O=e+c+_*E-g*S,R=i+u+g*E+_*S,P=C<0?1:0;d||se.ellipseToCurve?Ei(t,O,R,s,r,o,B/V,T/V,P):s!==r||o?t.push(Ye.G,O,R,s,r,o,B/V,T/V,P):t.push(Ye.O,O,R,s,B/V,T/V,P)}},Bi=t=>[],{M:Ti,m:Ci,L:Oi,l:Ri,H:Pi,h:Li,V:Mi,v:Di,C:Ai,c:Ii,S:Wi,s:zi,Q:Fi,q:Yi,T:Ni,t:Xi,A:Hi,a:Vi,Z:Ui,z:ji,N:Gi,D:Ki,X:Zi,G:qi,F:$i,O:Ji,P:Qi,U:ts}=Ye,{rect:es,roundRect:is,arcTo:ss,arc:rs,ellipse:os,quadraticCurveTo:ns}=fi,{ellipticalArc:as}=Si,hs=ne.get("PathConvert"),ls={},ds={current:{dot:0},stringify(t,e){let i,s,r,o=0,n=t.length,a="";for(;o<n;){s=t[o],i=je[s],a+=s===r?" ":Ue[s];for(let s=1;s<i;s++)a+=X.float(t[o+s],e),s===i-1||(a+=" ");r=s,o+=i}return a},parse(t,e){let i,s,r,o="";const n=[],a=e?He:Xe;for(let h=0,l=t.length;h<l;h++)s=t[h],te[s]?("."===s&&(cs.dot&&(us(n,o),o=""),cs.dot++),"0"===o&&"."!==s&&(us(n,o),o=""),o+=s):Ye[s]?(o&&(us(n,o),o=""),cs.name=Ye[s],cs.length=Ne[s],cs.index=0,us(n,cs.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===r||"E"===r?o+=s:(o&&us(n,o),o=s):o&&(us(n,o),o=""),r=s;return o&&us(n,o),i?ds.toCanvasData(n,e):n},toCanvasData(t,e){let i,s,r,o,n,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(r=t[c],r){case Ci:t[c+1]+=a,t[c+2]+=h;case Ti:a=t[c+1],h=t[c+2],p.push(Ti,a,h),c+=3;break;case Li:t[c+1]+=a;case Pi:a=t[c+1],p.push(Oi,a,h),c+=2;break;case Di:t[c+1]+=h;case Mi:h=t[c+1],p.push(Oi,a,h),c+=2;break;case Ri:t[c+1]+=a,t[c+2]+=h;case Oi:a=t[c+1],h=t[c+2],p.push(Oi,a,h),c+=3;break;case zi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,r=Wi;case Wi:n=o===Ai||o===Wi,l=n?2*a-i:t[c+1],d=n?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],p.push(Ai,l,d,i,s,a,h),c+=5;break;case Ii:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,r=Ai;case Ai:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],p.push(Ai,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Xi:t[c+1]+=a,t[c+2]+=h,r=Ni;case Ni:n=o===Fi||o===Ni,i=n?2*a-i:t[c+1],s=n?2*h-s:t[c+2],e?ns(p,a,h,i,s,t[c+1],t[c+2]):p.push(Fi,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Yi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,r=Fi;case Fi:i=t[c+1],s=t[c+2],e?ns(p,a,h,i,s,t[c+3],t[c+4]):p.push(Fi,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Vi:t[c+6]+=a,t[c+7]+=h;case Hi:as(p,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 ji:case Ui:p.push(Ui),c++;break;case Gi:a=t[c+1],h=t[c+2],e?es(p,a,h,t[c+3],t[c+4]):ps(p,t,c,5),c+=5;break;case Ki:a=t[c+1],h=t[c+2],e?is(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):ps(p,t,c,9),c+=9;break;case Zi:a=t[c+1],h=t[c+2],e?is(p,a,h,t[c+3],t[c+4],t[c+5]):ps(p,t,c,6),c+=6;break;case qi:os(e?p:ps(p,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,ls),a=ls.x,h=ls.y,c+=9;break;case $i:e?os(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):ps(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Ji:rs(e?p:ps(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,ls),a=ls.x,h=ls.y,c+=7;break;case Qi:e?rs(p,t[c+1],t[c+2],t[c+3],0,360,!1):ps(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case ts:ss(e?p:ps(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,ls),a=ls.x,h=ls.y,c+=6;break;default:return hs.error(`command: ${r} [index:${c}]`,t),p}o=r}return p},objectToCanvasData(t){if(t[0].name.length>1)return Bi(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(Ti,t.x,t.y);break;case"L":e.push(Oi,t.x,t.y);break;case"C":e.push(Ai,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Fi,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Ui)}}),e}},copyData(t,e,i,s){for(let r=i,o=i+s;r<o;r++)t.push(e[r])},pushData(t,e){cs.index===cs.length&&(cs.index=1,t.push(cs.name)),t.push(Number(e)),cs.index++,cs.dot=0}},{current:cs,pushData:us,copyData:ps}=ds,{M:gs,L:_s,C:fs,Q:ms,Z:ys,N:vs,D:ws,X:xs,G:bs,F:ks,O:Es,P:Ss,U:Bs}=Ye,{getMinDistanceFrom:Ts,getRadianFrom:Cs}=_t,{tan:Os,min:Rs,abs:Ps}=Math,Ls={},Ms={beginPath(t){t.length=0},moveTo(t,e,i){t.push(gs,e,i)},lineTo(t,e,i){t.push(_s,e,i)},bezierCurveTo(t,e,i,s,r,o,n){t.push(fs,e,i,s,r,o,n)},quadraticCurveTo(t,e,i,s,r){t.push(ms,e,i,s,r)},closePath(t){t.push(ys)},rect(t,e,i,s,r){t.push(vs,e,i,s,r)},roundRect(t,e,i,s,r,o){if(y(o))t.push(xs,e,i,s,r,o);else{const n=X.fourNumber(o);n?t.push(ws,e,i,s,r,...n):t.push(vs,e,i,s,r)}},ellipse(t,e,i,s,r,o,n,a,h){if(s===r)return As(t,e,i,s,n,a,h);_(o)?t.push(ks,e,i,s,r):(_(n)&&(n=0),_(a)&&(a=360),t.push(bs,e,i,s,r,o,n,a,h?1:0))},arc(t,e,i,s,r,o,n){_(r)?t.push(Ss,e,i,s):(_(r)&&(r=0),_(o)&&(o=360),t.push(Es,e,i,s,r,o,n?1:0))},arcTo(t,e,i,s,r,o,n,a,h){if(!g(n)){const t=Ts(n,a,e,i,s,r)/(h?1:2);o=Rs(o,Rs(t,t*Ps(Os(Cs(n,a,e,i,s,r)/2))))}t.push(Bs,e,i,s,r,o)},drawEllipse(t,e,i,s,r,o,n,a,h){fi.ellipse(null,e,i,s,r,_(o)?0:o,_(n)?0:n,_(a)?360:a,h,null,null,Ls),t.push(gs,Ls.x,Ls.y),Ds(t,e,i,s,r,o,n,a,h)},drawArc(t,e,i,s,r,o,n){fi.arc(null,e,i,s,_(r)?0:r,_(o)?360:o,n,null,null,Ls),t.push(gs,Ls.x,Ls.y),As(t,e,i,s,r,o,n)},drawPoints(t,e,i,s){fi.points(t,e,i,s)}},{ellipse:Ds,arc:As}=Ms,{moveTo:Is,lineTo:Ws,quadraticCurveTo:zs,bezierCurveTo:Fs,closePath:Ys,beginPath:Ns,rect:Xs,roundRect:Hs,ellipse:Vs,arc:Us,arcTo:js,drawEllipse:Gs,drawArc:Ks,drawPoints:Zs}=Ms,qs=class{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?f(t)?ze.parse(t):t:[],this}beginPath(){return Ns(this.__path),this.paint(),this}moveTo(t,e){return Is(this.__path,t,e),this.paint(),this}lineTo(t,e){return Ws(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,r,o){return Fs(this.__path,t,e,i,s,r,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return zs(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ys(this.__path),this.paint(),this}rect(t,e,i,s){return Xs(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,r){return Hs(this.__path,t,e,i,s,r),this.paint(),this}ellipse(t,e,i,s,r,o,n,a){return Vs(this.__path,t,e,i,s,r,o,n,a),this.paint(),this}arc(t,e,i,s,r,o){return Us(this.__path,t,e,i,s,r,o),this.paint(),this}arcTo(t,e,i,s,r){return js(this.__path,t,e,i,s,r),this.paint(),this}drawEllipse(t,e,i,s,r,o,n,a){return Gs(this.__path,t,e,i,s,r,o,n,a),this.paint(),this}drawArc(t,e,i,s,r,o){return Ks(this.__path,t,e,i,s,r,o),this.paint(),this}drawPoints(t,e,i){return Zs(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}},{M:$s,L:Js,C:Qs,Q:tr,Z:er,N:ir,D:sr,X:rr,G:or,F:nr,O:ar,P:hr,U:lr}=Ye,dr=ne.get("PathDrawer"),cr={drawPathByData(t,e){if(!e)return;let i,s=0,r=e.length;for(;s<r;)switch(i=e[s],i){case $s:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Js:t.lineTo(e[s+1],e[s+2]),s+=3;break;case Qs:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case tr:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case er:t.closePath(),s+=1;break;case ir:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case sr: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 rr:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case or:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*V,e[s+6]*V,e[s+7]*V,e[s+8]),s+=9;break;case nr:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,U,!1),s+=5;break;case ar:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*V,e[s+5]*V,e[s+6]),s+=7;break;case hr:t.arc(e[s+1],e[s+2],e[s+3],0,U,!1),s+=4;break;case lr:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void dr.error(`command: ${i} [index:${s}]`,e)}}},{M:ur,L:pr,C:gr,Q:_r,Z:fr,N:mr,D:yr,X:vr,G:wr,F:xr,O:br,P:kr,U:Er}=Ye,{toTwoPointBounds:Sr,toTwoPointBoundsByQuadraticCurve:Br,arcTo:Tr,arc:Cr,ellipse:Or}=fi,{addPointBounds:Rr,copy:Pr,addPoint:Lr,setPoint:Mr,addBounds:Dr,toBounds:Ar}=kt,Ir=ne.get("PathBounds"),Wr={},zr={},Fr={},Yr={toBounds(t,e){Yr.toTwoPointBounds(t,zr),Ar(zr,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Mr(e,0,0);let i,s,r,o,n,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(n=t[a],0===a&&(n===fr||n===gr||n===_r?Mr(e,h,l):Mr(e,t[a+1],t[a+2])),n){case ur:case pr:h=t[a+1],l=t[a+2],Lr(e,h,l),a+=3;break;case gr:r=t[a+5],o=t[a+6],Sr(h,l,t[a+1],t[a+2],t[a+3],t[a+4],r,o,Wr),Rr(e,Wr),h=r,l=o,a+=7;break;case _r:i=t[a+1],s=t[a+2],r=t[a+3],o=t[a+4],Br(h,l,i,s,r,o,Wr),Rr(e,Wr),h=r,l=o,a+=5;break;case fr:a+=1;break;case mr:h=t[a+1],l=t[a+2],Dr(e,h,l,t[a+3],t[a+4]),a+=5;break;case yr:case vr:h=t[a+1],l=t[a+2],Dr(e,h,l,t[a+3],t[a+4]),a+=n===yr?9:6;break;case wr:Or(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],Wr,Fr),0===a?Pr(e,Wr):Rr(e,Wr),h=Fr.x,l=Fr.y,a+=9;break;case xr:h=t[a+1],l=t[a+2],Ke=t[a+3],Ze=t[a+4],Dr(e,h-Ke,l-Ze,2*Ke,2*Ze),h+=Ke,a+=5;break;case br:Cr(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Wr,Fr),0===a?Pr(e,Wr):Rr(e,Wr),h=Fr.x,l=Fr.y,a+=7;break;case kr:h=t[a+1],l=t[a+2],Ge=t[a+3],Dr(e,h-Ge,l-Ge,2*Ge,2*Ge),h+=Ge,a+=4;break;case Er:Tr(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Wr,Fr),0===a?Pr(e,Wr):Rr(e,Wr),h=Fr.x,l=Fr.y,a+=6;break;default:return void Ir.error(`command: ${n} [index:${a}]`,t)}}},{M:Nr,L:Xr,Z:Hr}=Ye,{getCenterX:Vr,getCenterY:Ur}=_t,{arcTo:jr}=Ms,Gr={smooth(t,e,i){let s,r,o,n=0,a=0,h=0,l=0,d=0,c=0,u=0,p=0,g=0;v(e)&&(e=e[0]||0);const _=t.length,f=9===_,m=[];for(;n<_;){switch(s=t[n],s){case Nr:l=p=t[n+1],d=g=t[n+2],n+=3,t[n]===Xr?(c=t[n+1],u=t[n+2],f?m.push(Nr,l,d):m.push(Nr,Vr(l,c),Ur(d,u))):m.push(Nr,l,d);break;case Xr:switch(a=t[n+1],h=t[n+2],n+=3,t[n]){case Xr:jr(m,a,h,t[n+1],t[n+2],e,p,g,f);break;case Hr:jr(m,a,h,l,d,e,p,g,f);break;default:m.push(Xr,a,h)}p=a,g=h;break;case Hr:r!==Hr&&(jr(m,l,d,c,u,e,p,g,f),m.push(Hr)),n+=1;break;default:o=je[s];for(let e=0;e<o;e++)m.push(t[n+e]);n+=o}r=s}return s!==Hr&&(m[1]=l,m[2]=d),m}};function Kr(t){return new qs(t)}var Zr=Kr();ze.creator=Kr(),ze.parse=ds.parse,ze.convertToCanvasData=ds.toCanvasData;var{drawRoundRect:qr}=qe;function $r(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,r){qr(this,t,e,i,s,r)})}(t)}var Jr={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mimeType:(t,e="image")=>!t||t.startsWith(e)?t:("jpg"===t&&(t="jpeg"),e+"/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=Qr.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{}}}},Qr=Jr;Qr.mineType=Qr.mimeType,Qr.alphaPixelTypes.forEach(t=>Qr.upperCaseTypeMap[t]=t.toUpperCase());var to=ne.get("TaskProcessor"),eo=class{constructor(t){this.parallel=!0,this.time=1,this.id=T.create(T.TASK),this.task=t}run(){return ke(this,void 0,void 0,function*(){try{if(this.isComplete||this.runing)return;if(this.runing=!0,this.canUse&&!this.canUse())return this.cancel();this.task&&(yield this.task())}catch(u){to.error(u)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}},io=class{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&&E.assign(this.config,t),this.empty()}add(t,e,i){let s,r,o,n;const a=new eo(t);return a.parent=this,y(e)?n=e:e&&(r=e.parallel,s=e.start,o=e.time,n=e.delay,i||(i=e.canUse)),o&&(a.time=o),!1===r&&(a.parallel=!1),i&&(a.canUse=i),g(n)?this.push(a,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(a,s))},n)),this.isComplete=!1,a}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.run()}),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++,t.isCancel?this.runTask():this.nextTask()}).catch(t=>{this.onError(t)}):this.timer=setTimeout(()=>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;const{config:e,list:i,index:s}=this;this.parallelList=[],this.parallelSuccessNumber=0;let r=s+e.parallel;if(r>i.length&&(r=i.length),e.parallel>1)for(let o=s;o<r&&(t=i[o],t.parallel);o++)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()}},so=ne.get("Resource"),ro={tasker:new io,queue:new io({parallel:1}),map:{},get isComplete(){return oo.tasker.isComplete},set(t,e){oo.map[t]&&so.repeat(t),oo.map[t]=e},get:t=>oo.map[t],remove(t){const e=oo.map[t];e&&(e.destroy&&e.destroy(),delete oo.map[t])},loadImage(t,e){return new Promise((i,s)=>{const r=this.setImage(t,t,e);r.load(()=>i(r),t=>s(t))})},setImage(t,e,i){let s;return f(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=ge.image(s)),oo.set(t,e),e},loadFilm(t,e){},loadVideo(t,e){},destroy(){oo.map={}}},oo=ro,no={maxRecycled:10,recycledList:[],patternTasker:ro.queue,get(t,e){let i=ro.get(t.url);return i||ro.set(t.url,i="film"===e?ge.film(t):ge.image(t)),i.use++,i},recycle(t){t.parent&&(t=t.parent),t.use--,setTimeout(()=>{t.use||(se.image.isLarge(t)?t.url&&ro.remove(t.url):(t.clearLevels(),ao.recycledList.push(t)))})},recyclePaint(t){ao.recycle(t.image)},clearRecycled(t){const e=ao.recycledList;(e.length>ao.maxRecycled||t)&&(e.forEach(e=>(!e.use||t)&&e.url&&ro.remove(e.url)),e.length=0)},clearLevels(){},hasAlphaPixel:t=>Jr.alphaPixelTypes.some(e=>ao.isFormat(e,t)),isFormat(t,e){if(e.format)return e.format===t;const{url:i}=e;if(i.startsWith("data:")){if(i.startsWith("data:"+Jr.mimeType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Jr.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){this.clearRecycled(!0)}},ao=no,{IMAGE:ho,create:lo}=T,co=class{get tag(){return"Image"}get url(){return this.config.url}get crossOrigin(){const{crossOrigin:t}=this.config;return g(t)?se.image.crossOrigin:t}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=lo(ho),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}no.isFormat("svg",t)&&(this.isSVG=!0),no.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,e,i){return this.loading||(this.loading=!0,ro.tasker.add(()=>ke(this,void 0,void 0,function*(){return yield se.origin["load"+this.tag](this.getLoadUrl(i),this.crossOrigin,this).then(t=>{i&&this.setThumbView(t),this.setView(t)}).catch(t=>{this.error=t,this.onComplete(!1)})}))),this.waitComplete.push(t,e),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||(this.width=t.width,this.height=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(t,e,i,s,r,o,n,a){if(t||(t=this.width),e||(e=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 h=se.image.resize(this.view,t,e,r,o,void 0,n,i,s,a);return this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(t,e,i,s){const r=se.canvas.createPattern(t,e);return se.image.setPatternTransform(r,i,s),r}render(t,e,i,s,r,o,n,a,h){t.drawImage(this.view,e,i,s,r)}getLoadUrl(t){return this.url}setThumbView(t){}getThumbSize(t){}getMinLevel(){}getLevelData(t,e,i){}clearLevels(t){}destroyFilter(){}destroy(){this.clearLevels(),this.destroyFilter();const{view:t}=this;t&&t.close&&t.close(),this.config={url:""},this.cache=this.view=null,this.waitComplete.length=0}};function uo(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function po(t,e){return Object.getOwnPropertyDescriptor(t,e)}function go(t,e){return(i,s)=>function(t,e,i,s){uo(t,e,Object.assign({get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}},s||{})),Mo(t,e,i)}(i,s,t,e&&e(s))}function _o(t){return go(t)}function fo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function mo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function yo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),bo(this))}}))}function vo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function wo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function xo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&bo(this)}}))}function bo(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}var ko=xo;function Eo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i)&&(function(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&bo(t)}(this),e&&(this.__.__useStroke=!0))}}))}var So=Eo;function Bo(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function To(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Co(t){return go(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;E.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip)}}}))}function Oo(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Ro(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||bo(t))}function Po(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,this.leafer&&this.leafer.updateCursor())}}))}function Lo(t){return(e,i)=>{uo(e,"__DataProcessor",{get:()=>t})}}function Mo(t,e,i){const s=t.__DataProcessor.prototype,r="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),n=function(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}(e,i);if(g(i))n.get=function(){return this[r]};else if("function"==typeof i)n.get=function(){const t=this[r];return null==t?i(this.__leaf):t};else if(w(i)){const t=function(t){return"{}"===JSON.stringify(t)}(i);n.get=function(){const e=this[r];return null==e?this[r]=t?{}:E.clone(i):e}}const a=t.isBranchLeaf;"width"===e?n.get=function(){const t=this[r];if(null==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&&(n.get=function(){const t=this[r];if(null==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=po(l,e),l=l.__proto__;h&&h.set&&(n.set=h.set),s[o]&&(n.set=s[o],delete s[o]),uo(s,e,n)}var Do=new ne("rewrite"),Ao=[],Io=["destroy","constructor"];function Wo(t){return(e,i)=>{Ao.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function zo(){return t=>{Fo()}}function Fo(t){Ao.length&&(Ao.forEach(e=>{t&&Do.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Ao.length=0)}function Yo(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{Io.includes(s)||e&&e.includes(s)||(t.prototype?po(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s]):i.prototype[s]=t[s])})}}function No(){return t=>{fe.register(t)}}function Xo(){return t=>{ve.register(t)}}setTimeout(()=>Fo(!0));var{copy:Ho,toInnerPoint:Vo,toOuterPoint:Uo,scaleOfOuter:jo,rotateOfOuter:Go,skewOfOuter:Ko,multiplyParent:Zo,divideParent:qo,getLayout:$o}=st,Jo={},{round:Qo}=Math,tn={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),rn(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,r=s.length;t<r;t++)sn(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++)on(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&on(t),t.__updateChange(),e.surfaceChanged&&(t.__hasComplex&&en.updateComplex(t),e.surfaceChanged=!1)},updateAllChange(t){if(an(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)nn(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},draggable:t=>(t.draggable||t.editable)&&t.hitSelf&&!t.locked,copyCanvasByWorld(t,e,i,s,r,o){s||(s=t.__nowWorld),t.__worldFlipped||se.fullImageShadow?e.copyWorldByReset(i,s,t.__nowWorld,r,o):e.copyWorldToInner(i,s,t.__layout.renderBounds,r)},renderComplex(t,e,i){},updateComplex(t){},checkComplex(t){},moveWorld(t,e,i=0,s,r){const o=w(e)?Object.assign({},e):{x:e,y:i};s?Uo(t.localTransform,o,o,!0):t.parent&&Vo(t.parent.scrollWorldTransform,o,o,!0),en.moveLocal(t,o.x,o.y,r)},moveLocal(t,e,i=0,s){w(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=Qo(e),i=Qo(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,r,o){en.zoomOfLocal(t,hn(t,e),i,s,r,o)},zoomOfLocal(t,e,i,s=i,r,o){const n=t.__localMatrix;if(y(s)||(s&&(o=s),s=i),Ho(Jo,n),jo(Jo,e,i,s),en.hasHighPosition(t))en.setTransform(t,Jo,r,o);else{const e=t.x+Jo.e-n.e,a=t.y+Jo.f-n.f;o&&!r?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!==r))}},rotateOfWorld(t,e,i,s){en.rotateOfLocal(t,hn(t,e),i,s)},rotateOfLocal(t,e,i,s){const r=t.__localMatrix;Ho(Jo,r),Go(Jo,e,i),en.hasHighPosition(t)?en.setTransform(t,Jo,!1,s):t.set({x:t.x+Jo.e-r.e,y:t.y+Jo.f-r.f,rotation:X.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,r,o){en.skewOfLocal(t,hn(t,e),i,s,r,o)},skewOfLocal(t,e,i,s=0,r,o){Ho(Jo,t.__localMatrix),Ko(Jo,e,i,s),en.setTransform(t,Jo,r,o)},transformWorld(t,e,i,s){Ho(Jo,t.worldTransform),Zo(Jo,e),t.parent&&qo(Jo,t.parent.scrollWorldTransform),en.setTransform(t,Jo,i,s)},transform(t,e,i,s){Ho(Jo,t.localTransform),Zo(Jo,e),en.setTransform(t,Jo,i,s)},setTransform(t,e,i,s){const r=t.__,o=r.origin&&en.getInnerOrigin(t,r.origin),n=$o(e,o,r.around&&en.getInnerOrigin(t,r.around));if(en.hasOffset(t)&&(n.x-=r.offsetX,n.y-=r.offsetY),i){const e=n.scaleX/t.scaleX,i=n.scaleY/t.scaleY;if(delete n.scaleX,delete n.scaleY,o){jt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=en.getInnerOrigin(t,r.origin);_t.move(n,o.x-s.x,o.y-s.y)}t.set(n),t.scaleResize(e,i,!1)}else t.set(n,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return jo(i,en.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>_t.tempToOuterOf(en.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return Bt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Ho(Jo,t.worldTransform),qo(Jo,e.scrollWorldTransform),i?Jo:Object.assign({},Jo)),updateScaleFixedWorld(t){},updateOuterBounds(t){},cacheId(t){},drop(t,e,i,s){t.setTransform(en.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||en.hasOffset(t),hasOffset:t=>t.offsetX||t.offsetY,hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}},animateMove(t,e,i=.3){if(e.x||e.y)if(Math.abs(e.x)<1&&Math.abs(e.y)<1)t.move(e);else{const s=e.x*i,r=e.y*i;e.x-=s,e.y-=r,t.move(s,r),se.requestRender(()=>en.animateMove(t,e,i))}}},en=tn,{updateAllMatrix:sn,updateMatrix:rn,updateAllWorldOpacity:on,updateAllChange:nn,updateChange:an}=en;function hn(t,e){return t.updateLayout(),t.parent?_t.tempToInnerOf(e,t.parent.scrollWorldTransform):e}var ln,dn={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){const{__:e,__layout:i}=t;return e.eraser||0===e.visible?null:i.localOuterBounds||i.localRenderBounds},maskLocalBoxBounds:(t,e)=>cn(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>cn(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds(t,e){const{__layout:i}=t;return cn(t,e)&&(i.localOuterBounds||i.localRenderBounds)},excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};function cn(t,e){return e||(ln=0),t.__.mask&&(ln=1),ln<0?null:(ln&&(ln=-1),!0)}var{updateBounds:un}=tn,pn={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,r=i.length;s<r;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),gn(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&g(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 r=0,o=s.length;r<o;r++)s[r].isBranch&&e.push(s[r]);for(let r=i,o=e.length;r<o;r++)_n(e[r],e)},updateBounds(t,e){const i=[t];_n(t,i),fn(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let r=t.length-1;r>-1;r--){i=t[r],s=i.children;for(let t=0,e=s.length;t<e;t++)un(s[t]);e&&e===i||un(i)}},move(t,e,i){let s;const{children:r}=t;for(let o=0,n=r.length;o<n;o++)s=(t=r[o]).__world,s.e+=e,s.f+=i,s.x+=e,s.y+=i,t.isBranch&&mn(t,e,i)},scale(t,e,i,s,r,o,n){let a;const{children:h}=t,l=s-1,d=r-1;for(let c=0,u=h.length;c<u;c++)a=(t=h[c]).__world,a.a*=s,a.d*=r,(a.b||a.c)&&(a.b*=s,a.c*=r),a.e===a.x&&a.f===a.y?(a.x=a.e+=(a.e-o)*l+e,a.y=a.f+=(a.f-n)*d+i):(a.e+=(a.e-o)*l+e,a.f+=(a.f-n)*d+i,a.x+=(a.x-o)*l+e,a.y+=(a.y-n)*d+i),a.width*=s,a.height*=r,a.scaleX*=s,a.scaleY*=r,t.isBranch&&yn(t,e,i,s,r,o,n)}},{pushAllChildBranch:gn,pushAllBranchStack:_n,updateBoundsByBranchStack:fn,move:mn,scale:yn}=pn,vn={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:wn,updateBounds:xn}=tn,{toOuterOf:bn,getPoints:kn,copy:En}=jt,Sn="_localContentBounds",Bn="_worldContentBounds",Tn="_worldBoxBounds",Cn="_worldStrokeBounds",On=class{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}set renderBounds(t){this._renderBounds=t}get localContentBounds(){return bn(this.contentBounds,this.leaf.__localMatrix,this[Sn]||(this[Sn]={})),this[Sn]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return bn(this.contentBounds,this.leaf.__world,this[Bn]||(this[Bn]={})),this[Bn]}get worldBoxBounds(){return bn(this.boxBounds,this.leaf.__world,this[Tn]||(this[Tn]={})),this[Tn]}get worldStrokeBounds(){return bn(this.strokeBounds,this.leaf.__world,this[Cn]||(this[Cn]={})),this[Cn]}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.leaf.__local&&(this._localRenderBounds=this._localStrokeBounds=this.leaf.__local),t.__world&&(this.boxBounds={x:0,y:0,width:0,height:0},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{leaf:t}=this,{leafer:e}=t;if(t.isApp)return xn(t);if(e)e.ready?e.watcher.changed&&e.layouter.layout():e.start();else{let e=t;for(;e.parent&&!e.parent.leafer;)e=e.parent;const i=e;if(i.__fullLayouting)return;i.__fullLayouting=!0,se.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 st.defaultMatrix;case"page":t=e.zoomLayer;default:return wn(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 qt(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 r,o,n,a=this.getInnerBounds(t);switch(e){case"world":r=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;n={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},r=s.getLocalPointByInner(a);break;case"inner":r=a,o=st.defaultMatrix;break;case"page":e=s.zoomLayer;default:r=s.getWorldPoint(a,e),o=wn(s,e,!0)}if(n||(n=st.getLayout(o)),En(n,a),_t.copy(n,r),i){const{scaleX:t,scaleY:e}=n,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(n.scaleX/=i,n.scaleY/=s,n.width*=i,n.height*=s)}return n}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=kn(this.getInnerBounds(t));let r;switch(e){case"world":r=null;break;case"local":r=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:r=e}return g(r)||s.forEach(t=>i.innerToWorld(t,null,!1,r)),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.boundsChanged||(this.boundsChanged=!0):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.boundsChanged||(this.boundsChanged=!0):this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}},Rn=class{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&se.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&se.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&se.event.stop(this.origin)}},Pn=class extends Rn{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}};Pn.ADD="child.add",Pn.REMOVE="child.remove",Pn.CREATED="created",Pn.MOUNTED="mounted",Pn.UNMOUNTED="unmounted",Pn.DESTROY="destroy";var Ln="property.scroll",Mn=class extends Rn{constructor(t,e,i,s,r){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=r}};Mn.CHANGE="property.change",Mn.LEAFER_CHANGE="property.leafer_change",Mn.SCROLL=Ln;var Dn={scrollX:Ln,scrollY:Ln},An=class extends Rn{constructor(t,e){super(t),Object.assign(this,e)}};An.LOAD="image.load",An.LOADED="image.loaded",An.ERROR="image.error";var In=class extends Rn{static checkHas(t,e,i){"on"===i?e===Yn?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Wn)||t.hasEvent(zn)||t.hasEvent(Fn),t.__hasWorldEvent=t.hasEvent(Yn))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Wn,t),"inner"===e&&t.emit(zn,t)),t.emit(Fn,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Yn,t)}};In.RESIZE="bounds.resize",In.INNER="bounds.inner",In.LOCAL="bounds.local",In.WORLD="bounds.world";var{RESIZE:Wn,INNER:zn,LOCAL:Fn,WORLD:Yn}=In,Nn={};[Wn,zn,Fn,Yn].forEach(t=>Nn[t]=1);var Xn=class t extends Rn{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(e,i){w(e)?(super(t.RESIZE),Object.assign(this,e)):super(e),this.old=i}static isResizing(t){return this.resizingKeys&&!g(this.resizingKeys[t.innerId])}};Xn.RESIZE="resize";var Hn=class extends Rn{constructor(t,e){super(t),this.data=e}};Hn.REQUEST="watch.request",Hn.DATA="watch.data";var Vn=class extends Rn{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}};Vn.REQUEST="layout.request",Vn.START="layout.start",Vn.BEFORE="layout.before",Vn.LAYOUT="layout",Vn.AFTER="layout.after",Vn.AGAIN="layout.again",Vn.END="layout.end";var Un=class extends Rn{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}};Un.REQUEST="render.request",Un.CHILD_START="render.child_start",Un.CHILD_END="render.child_end",Un.START="render.start",Un.BEFORE="render.before",Un.RENDER="render",Un.AFTER="render.after",Un.AGAIN="render.again",Un.END="render.end",Un.NEXT="render.next";var jn=class extends Rn{};jn.START="leafer.start",jn.BEFORE_READY="leafer.before_ready",jn.READY="leafer.ready",jn.AFTER_READY="leafer.after_ready",jn.VIEW_READY="leafer.view_ready",jn.VIEW_COMPLETED="leafer.view_completed",jn.STOP="leafer.stop",jn.RESTART="leafer.restart",jn.END="leafer.end",jn.UPDATE_MODE="leafer.update_mode",jn.TRANSFORM="leafer.transform",jn.MOVE="leafer.move",jn.SCALE="leafer.scale",jn.ROTATE="leafer.rotate",jn.SKEW="leafer.skew";var{MOVE:Gn,SCALE:Kn,ROTATE:Zn,SKEW:qn}=jn,$n={x:Gn,y:Gn,scaleX:Kn,scaleY:Kn,rotation:Zn,skewX:qn,skewY:qn},Jn={};function Qn(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Jn)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Jn)}}var{on:ta,on_:ea,off:ia,off_:sa,once:ra,emit:oa,emitEvent:na,hasEvent:aa,destroy:ha}=class{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(v(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)v(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,r,o;i&&("once"===i?r=!0:"boolean"==typeof i?s=i:(s=i.capture,r=i.once));const n=Qn(this,s,!0),a=f(t)?t.split(" "):t,h=r?{listener:e,once:r}:{listener:e};a.forEach(t=>{t&&(o=n[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(h):n[t]=[h],Nn[t]&&In.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=f(t)?t.split(" "):t;if(e){let t,r,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const n=Qn(this,t);s.forEach(t=>{t&&(r=n[t],r&&(o=r.findIndex(t=>t.listener===e),o>-1&&r.splice(o,1),r.length||delete n[t],Nn[t]&&In.checkHas(this,t,"off")))})}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 e?this.on(t,i?e=e.bind(i):e,s):v(t)&&t.forEach(t=>this.on(t[0],t[2]?t[1]=t[1].bind(t[2]):t[1],t[3])),{type:t,current:this,listener:e,options:s}}off_(t){if(!t)return;const e=v(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):v(t.type)&&t.type.forEach(e=>t.current.off(e[0],e[1],e[3])))}),e.length=0}once(t,e,i,s){if(!e)return v(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));w(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&ve.has(t)&&(e=ve.get(t,{type:t,target:this,current:this}));const s=Qn(this,i)[t];if(s){let r;for(let o=0,n=s.length;o<n&&!((r=s[o])&&(r.listener(e),r.once&&(this.off(t,r.listener,i),o--,n--),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,r=i&&i[t],o=s&&s[t];return!!(g(e)?r||o:e?o:r)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}.prototype,la={on:ta,on_:ea,off:ia,off_:sa,once:ra,emit:oa,emitEvent:na,hasEvent:aa,destroyEventer:ha},da=ne.get("setAttr"),ca={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||m(e)||g(e)||(da.warn(this.innerName,t,e),e=void 0),w(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Mn(Mn.LEAFER_CHANGE,this,t,s,e));const i=$n[t];i&&(this.emitEvent(new jn(i,this)),this.emitEvent(new jn(jn.TRANSFORM,this)))}this.emitPropertyEvent(Mn.CHANGE,t,s,e);const i=Dn[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const r=new Mn(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(r),this.leafer.emitEvent(r)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||g(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ua,multiplyParent:pa,translateInner:ga,defaultWorld:_a}=st,{toPoint:fa,tempPoint:ma}=Bt,ya={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:r}=this;pa(this.__local||e,t?t.__scrollWorld||t.__world:_a,i,!!e.affectScaleOrRotation,r),s&&ga(Object.assign(s,i),r.scrollX,r.scrollY),e.scaleFixed&&tn.updateScaleFixedWorld(this)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(ua(e,i,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=i.x+i.offsetX,e.f=i.y+i.offsetY,(i.around||i.origin)&&(fa(i.around||i.origin,t.boxBounds,ma),ga(e,-ma.x,-ma.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:va,updateAllMatrix:wa}=tn,{updateBounds:xa}=pn,{toOuterOf:ba,copyAndSpread:ka,copy:Ea}=jt,{toBounds:Sa}=Yr,Ba={__updateWorldBounds(){const{__layout:t,__world:e}=this;ba(t.renderBounds,e,e),this.__hasComplex&&tn.checkComplex(this),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&In.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&In.emitWorld(this)},__updateLocalBounds(){const t=this.__layout;t.boxChanged&&(this.__.__pathInputed||this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),t.resized="inner"),t.localBoxChanged&&(this.__local&&this.__updateLocalBoxBounds(),t.localBoxChanged=void 0,t.strokeSpread&&(t.strokeChanged=!0),t.renderSpread&&(t.renderChanged=!0),this.parent&&this.parent.__layout.boxChange()),t.boxChanged=void 0,t.strokeChanged&&(t.strokeSpread=this.__updateStrokeSpread(),t.strokeSpread?(t.strokeBounds===t.boxBounds&&t.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):t.spreadStrokeCancel(),t.strokeChanged=void 0,(t.renderSpread||t.strokeSpread!==t.strokeBoxSpread)&&(t.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),t.resized="inner"),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=void 0,this.parent&&this.parent.__layout.renderChange()),t.outerScale&&tn.updateOuterBounds(this),t.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),ba(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){ba(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){ba(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Sa(s.path,i):(i.x=0,i.y=0,i.width=s.width,i.height=s.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),wa(this),xa(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(wa(this),xa(this,this))):va(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;ka(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;y(i)&&i<=0?Ea(e.renderBounds,e.strokeBounds):ka(e.renderBounds,e.boxBounds,i)}},Ta={__render(t,e){if(e.shape)return this.__renderShape(t,e);if((!e.cellList||e.cellList.has(this))&&this.__worldOpacity){const i=this.__;if(i.bright&&!e.topRendering)return e.topList.add(this);if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.ignoreOpacity?1:e.dimOpacity&&!i.dimskip?i.opacity*e.dimOpacity:i.opacity,this.__.__single){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!0,!0);this.__draw(s,e,t),tn.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);ne.showBounds&&ne.drawBounds(this,t,e)}},__renderShape(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawShape(t,e))},__clip(t,e){this.__worldOpacity&&(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),this.__drawRenderPath(t),t.clipUI(this))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{excludeRenderBounds:Ca}=dn,{hasSize:Oa}=jt,Ra={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){const i=this.__nowWorld=this.__getNowWorld(e);if(this.__worldOpacity&&Oa(i)){const s=this.__;if(s.__useDim)if(s.dim)e.dimOpacity=!0===s.dim?.2:s.dim;else{if(s.bright&&!e.topRendering)return e.topList.add(this);s.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(s.__single&&!this.isBranchLeaf){if("path"===s.eraser)return this.__renderEraser(t,e);const r=t.getSameCanvas(!1,!0);this.__renderBranch(r,e),t.opacity=e.ignoreOpacity?1:e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(r,i,i,s.__blendMode,!0),r.recycle(i)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{let i;const{children:s}=this;for(let r=0,o=s.length;r<o;r++)i=s[r],Ca(i,e)||(i.__hasComplex?tn.renderComplex(i,t,e):i.__render(t,e))}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,r=i.length;s<r;s++)Ca(i[s],e)||i[s].__clip(t,e)}}},{LEAF:Pa,create:La}=T,{stintSet:Ma}=E,{toInnerPoint:Da,toOuterPoint:Aa,multiplyParent:Ia}=st,{toOuterOf:Wa}=jt,{copy:za,move:Fa}=_t,{getScaleFixedData:Ya}=X,{moveLocal:Na,zoomOfLocal:Xa,rotateOfLocal:Ha,skewOfLocal:Va,moveWorld:Ua,zoomOfWorld:ja,rotateOfWorld:Ga,skewOfWorld:Ka,transform:Za,transformWorld:qa,setTransform:$a,getFlipTransform:Ja,getLocalOrigin:Qa,getRelativeWorld:th,drop:eh}=tn,ih=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 B}get __LayoutProcessor(){return On}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 scrollWorldTransform(){return this.updateLayout(),this.__scrollWorld||this.__world}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.updateLayout(),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=La(Pa),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Pn.CREATED)}reset(t){this.leafer&&this.leafer.forceRender(this.__world),0!==t&&(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(Pn.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Pn.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(Pn.MOUNTED),t.cacheId&&tn.cacheId(this)):this.__emitLifeEvent(Pn.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){g(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=g(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(t,e){}__updateContentBounds(){}__updateStrokeBounds(t){}__updateRenderBounds(t){}__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,i=this.__world;return Ia(i,t.matrix,e,void 0,i),Wa(this.__layout.renderBounds,e,e),Ma(e,"half",i.half),Ma(e,"ignorePixelSnap",i.ignorePixelSnap),e}return this.__world}getClampRenderScale(){let{scaleX:t}=this.__nowWorld||this.__world;return t<0&&(t=-t),t>1?t:1}getRenderScaleData(t,e,i=!0){return Ya(no.patternLocked?this.__world:this.__nowWorld||this.__world,e,i,t)}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?th(this,e):this.worldTransform,r=i?t:{};return Wa(t,s,r),r}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&za(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&za(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Da(this.worldTransform,t,e,i)}innerToWorld(t,e,i,s){Aa(this.worldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){const r=this.getInnerPoint(t,e,i,s);return i?r:this.getBoxPointByInner(r,null,null,!0)}getBoxPointByInner(t,e,i,s){const r=s?t:Object.assign({},t),{x:o,y:n}=this.boxBounds;return Fa(r,-o,-n),r}getInnerPoint(t,e,i,s){const r=s?t:{};return this.worldToInner(t,r,i,e),r}getInnerPointByBox(t,e,i,s){const r=s?t:Object.assign({},t),{x:o,y:n}=this.boxBounds;return Fa(r,o,n),r}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const r=s?t:{};return this.worldToLocal(t,r,i,e),r}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 r=s?t:{};return this.innerToWorld(t,r,i,e),r}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const r=s?t:{};return this.localToWorld(t,r,i,e),r}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){$a(this,t,e,i)}transform(t,e,i){Za(this,t,e,i)}move(t,e,i){Na(this,t,e,i)}moveInner(t,e,i){Ua(this,t,e,!0,i)}scaleOf(t,e,i,s,r){Xa(this,Qa(this,t),e,i,s,r)}rotateOf(t,e,i){Ha(this,Qa(this,t),e,i)}skewOf(t,e,i,s,r){Va(this,Qa(this,t),e,i,s,r)}transformWorld(t,e,i){qa(this,t,e,i)}moveWorld(t,e,i){Ua(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,r){ja(this,t,e,i,s,r)}rotateOfWorld(t,e){Ga(this,t,e)}skewOfWorld(t,e,i,s,r){Ka(this,t,e,i,s,r)}flip(t,e){Za(this,Ja(this,t),!1,e)}scaleResize(t,e=t,i){this.scaleX*=t,this.scaleY*=e}__scaleResize(t,e){}resizeWidth(t){}resizeHeight(t){}hit(t,e){return!0}__hitWorld(t,e){return!0}__hit(t,e){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,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(t){}getMotionPathData(){return pe.need("path")}getMotionPoint(t){return pe.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){eh(this,t,e,i)}on(t,e,i){}off(t,e,i){}on_(t,e,i,s){}off_(t){}once(t,e,i,s){}emit(t,e,i){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,i){i?this.addAttr(t,e,i):Mo(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=xo),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Pn(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Pn.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};ih=be([Yo(ca),Yo(ya),Yo(Ba),Yo(la),Yo(Ta)],ih);var{setListWithFn:sh}=jt,{sort:rh}=pn,{localBoxBounds:oh,localStrokeBounds:nh,localRenderBounds:ah,maskLocalBoxBounds:hh,maskLocalStrokeBounds:lh,maskLocalRenderBounds:dh}=dn,ch=new ne("Branch"),uh=class extends ih{__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(){let t;const{children:e}=this;for(let i=0,s=e.length;i<s;i++)if(t=e[i].__layout,t.renderSpread||t.localOuterBounds)return 1;return 0}__updateBoxBounds(t,e){sh(e||this.__layout.boxBounds,this.children,this.__hasMask?hh:oh)}__updateStrokeBounds(t){sh(t||this.__layout.strokeBounds,this.children,this.__hasMask?lh:nh)}__updateRenderBounds(t){sh(t||this.__layout.renderBounds,this.children,this.__hasMask?dh:ah)}__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(rh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return ch.warn("add self or destroyed");const i=g(e);if(!t.__){if(v(t))return t.forEach(t=>{this.add(t,e),i||e++});if(!(t=fe.get(t.tag,t)))return}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(Pn.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Pn.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)):g(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(Pn.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Pn.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Pn(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};uh=be([Yo(Ra)],uh);var ph=class t{get length(){return this.list.length}constructor(t){this.reset(),t&&(v(t)?this.addList(t):this.add(t))}has(t){return t&&!g(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return g(e)?-1:e}add(t){const{list:e,keys:i}=this;g(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(g(i[t.innerId])){const{list:s}=this;for(let t=e,r=s.length;t<r;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,r=e.length;s<r;s++)g(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;g(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 e=new t;return e.list=[...this.list],e.keys=Object.assign({},this.keys),e}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()}},gh=class{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(v(t)?this.addList(t):this.add(t))}has(t){return!g(this.keys[t.innerId])}without(t){return g(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 s=0,r=e.length;s<r;s++)t(e[s])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}};function _h(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}function fh(t){return go(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0);const i=this.__layout;i.renderChanged||i.renderChange(),i.surfaceChange()}}))}function mh(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}var yh={},vh={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},wh=Qt,xh={},bh={},kh={},Eh={},Sh={},Bh={apply(){pe.need("filter")}},Th={},Ch={setStyleName:()=>pe.need("state"),set:()=>pe.need("state")},{parse:Oh,objectToCanvasData:Rh}=ds,{stintSet:Ph}=E,{hasTransparent:Lh}=vh,Mh={originPaint:{}},Dh=ne.get("UIData"),Ah=class extends B{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){return this.__getRealStrokeWidth()}get __maxStrokeWidth(){const t=this,e=t.__hasStrokeSides||t.strokeWidth;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,e):e}get __hasMultiPaint(){const t=this;return t.fill&&this.__useStroke||t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return null==this._width}get __autoHeight(){return null==this._height}get __autoSide(){return null==this._width||null==this._height}get __autoSize(){return null==this._width&&null==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,Dh.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Dh.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),f(t)||!t?(Ph(this,"__isTransparentFill",Lh(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):w(t)&&this.__setPaint("fill",t)}setStroke(t){f(t)||!t?(Ph(this,"__isTransparentStroke",Lh(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):w(t)&&this.__setPaint("stroke",t)}setPath(t){const e=f(t);e||t&&w(t[0])?(this.__setInput("path",t),this._path=e?Oh(t):Rh(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){Ih(this,"shadow",t)}setInnerShadow(t){Ih(this,"innerShadow",t)}setFilter(t){Ih(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&bh.compute("fill",this.__leaf),e&&bh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeScaleFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),g(t.strokeScaleFixed)||(i=t.strokeScaleFixed)),i){const{scaleX:t}=this.__leaf.getRenderScaleData(!0,i,!1);if(1!==t)return e*t}return e}__checkComplex(){const t=this;Ph(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),v(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=Mh)):(this.__isStrokes=!0,this._stroke||(this._stroke=Mh))}__removePaint(t,e){e&&this.__removeInput(t),kh.recycleImage(t,this),"fill"===t?(Ph(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(Ph(this,"__isAlphaPixelStroke",void 0),Ph(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}};function Ih(t,e,i){t.__setInput(e,i),v(i)?(i.some(t=>!1===t.visible)&&(i=i.filter(t=>!1!==t.visible)),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}var Wh=class extends Ah{},zh=class extends Wh{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return this.__single||this.__clipAfterFill}get __clipAfterFill(){const t=this;return"show"!==t.overflow&&t.__leaf.children.length&&(t.__leaf.isOverflow||super.__clipAfterFill)}},Fh=class extends Ah{get __usePathBox(){return this.points||this.__pathInputed}},Yh=class extends Ah{get __boxStroke(){return!this.__pathInputed}},Nh={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900},{max:Xh,add:Hh}=P,Vh={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:r}=i,o=this.__box;if((i.stroke||"all"===i.hitStroke)&&r&&"inside"!==s&&(e=t="center"===s?r/2:r,!i.__boxStroke||i.__useArrow)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:r;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*r),o&&(t=Xh(t,o.__layout.strokeSpread=o.__updateStrokeSpread()),e=Math.max(e,o.__layout.strokeBoxSpread)),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:r,filter:o,renderSpread:n}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=Sh.getShadowRenderSpread(this,e)),s&&(t=Xh(t,s)),o&&(t=Hh(t,Bh.getSpread(o))),n&&(t=Hh(t,n)),a&&(t=Hh(t,a));let l=t;return i&&(l=Xh(l,Sh.getInnerShadowSpread(this,i))),r&&(l=Xh(l,r)),this.__layout.renderShapeSpread=l,h?Xh(h.__updateRenderSpread(),t):t}},{stintSet:Uh}=E,jh={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Uh(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Uh(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,r=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Uh(t,"__isFastShadow",e&&!r&&e.length<2&&!e[0].spread&&!Sh.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(v(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!r)}t.__checkSingle(),t.__checkComplex()},__drawFast(t,e){Gh(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:o,__drawAfterFill:n,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=bh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&Sh.shadow(this,t,h),a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e)),r&&(s.__isFills?bh.fills(r,this,t,e):bh.fill(r,this,t,e)),n&&this.__drawAfterFill(t,e),d&&Sh.innerShadow(this,t,h),o&&!a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e)),c&&Bh.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e)),h){const e=s.shadow[0],{scaleX:i,scaleY:r}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*r,e.blur*i,vh.string(e.color))}r&&(s.__isFills?bh.fills(r,this,t,e):bh.fill(r,this,t,e)),h&&t.restore(),n&&this.__drawAfterFill(t,e),o&&!a&&(s.__isStrokes?bh.strokes(o,this,t,e):bh.stroke(o,this,t,e))}}else s.__pathForRender?Gh(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:r}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?bh.fills(s,this,t,e):bh.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),r&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?bh.strokes(r,this,t,e):bh.stroke("#000000",this,t,e))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Gh(t,e,i){const{fill:s,stroke:r,__drawAfterFill:o,__fillAfterStroke:n}=t.__;t.__drawRenderPath(e),n&&bh.stroke(r,t,e,i),s&&bh.fill(s,t,e,i),o&&t.__drawAfterFill(e,i),r&&!n&&bh.stroke(r,t,e,i)}var Kh,Zh={__drawFast(t,e){let{x:i,y:s,width:r,height:o}=this.__layout.boxBounds;const{fill:n,stroke:a,__drawAfterFill:h}=this.__;if(n&&(t.fillStyle=n,t.fillRect(i,s,r,o)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:n,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(n){case"center":t.strokeRect(0,0,r,o);break;case"inside":r-=h,o-=h,r<0||o<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,r,o),t.restore()):t.strokeRect(i+l,s+l,r,o);break;case"outside":t.strokeRect(i-l,s-l,r+h,o+h)}}}},qh=Kh=class extends ih{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set strokeWidthFixed(t){this.strokeScaleFixed=t}get strokeWidthFixed(){return this.strokeScaleFixed}set scale(t){X.assignScale(this,t)}get scale(){return this.__.scale}get isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return Zr.set(this.path=t||[]),t||this.__drawPathByBox(Zr),Zr}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return f(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}clearProxyData(){}find(t,e){return pe.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return pe.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(Zr.set(i=[]),this.__drawPathByBox(Zr,!e)),t?ds.toCanvasData(i,!0):i}getPathString(t,e,i){return ds.stringify(this.getPath(t,e),i)}asPath(t,e){this.path=this.getPath(t,e)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Th.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(t){const e=this.__;e.path?(e.__pathForRender=e.cornerRadius||e.path.radius?Gr.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&xh.addArrows(this,t)):e.__pathForRender&&(e.__pathForRender=void 0)}__drawRenderPath(t){const e=this.__;t.beginPath(),e.__useArrow&&xh.updateArrow(this),this.__drawPathByData(t,e.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path,!0)}__drawPathByData(t,e,i){e?cr.drawPathByData(t,e):this.__drawPathByBox(t,i)}__drawPathByBox(t,e){const{x:i,y:s,width:r,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius&&!e){const{cornerRadius:e}=this.__;t.roundRect(i,s,r,o,y(e)?[e]:e)}else t.rect(i,s,r,o);t.closePath()}drawImagePlaceholder(t,e,i){bh.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),pe.need("animate")}killAnimate(t,e){}export(t,e){return pe.need("export")}syncExport(t,e){return pe.need("export")}clone(t){const e=E.clone(this.toJSON());return t&&Object.assign(e,t),Kh.one(e)}static one(t,e,i,s,r){return fe.get(t.tag||this.prototype.__tag,t,e,i,s,r)}static registerUI(){No()(this)}static registerData(t){Lo(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.__.__willDestroy=!0,this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};_h([Lo(Ah)],qh.prototype,"__",void 0),_h([(t,e)=>{const i="_"+e;uo(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}})}],qh.prototype,"zoomLayer",void 0),_h([_o("")],qh.prototype,"id",void 0),_h([_o("")],qh.prototype,"name",void 0),_h([_o("")],qh.prototype,"className",void 0),_h([To("pass-through")],qh.prototype,"blendMode",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Oo(this)}}))}(1)],qh.prototype,"opacity",void 0),_h([function(t){return go(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Ro(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Ro(this,t,e,i),this.mask&&Oo(this)}}))}(!0)],qh.prototype,"visible",void 0),_h([To(!1)],qh.prototype,"locked",void 0),_h([Co(!1)],qh.prototype,"dim",void 0),_h([Co(!1)],qh.prototype,"dimskip",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__layout.childrenSortChange()})}}))}(0)],qh.prototype,"zIndex",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}(!1)],qh.prototype,"mask",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}(!1)],qh.prototype,"eraser",void 0),_h([fo(0,!0)],qh.prototype,"x",void 0),_h([fo(0,!0)],qh.prototype,"y",void 0),_h([xo(100,!0)],qh.prototype,"width",void 0),_h([xo(100,!0)],qh.prototype,"height",void 0),_h([vo(1,!0)],qh.prototype,"scaleX",void 0),_h([vo(1,!0)],qh.prototype,"scaleY",void 0),_h([wo(0,!0)],qh.prototype,"rotation",void 0),_h([wo(0,!0)],qh.prototype,"skewX",void 0),_h([wo(0,!0)],qh.prototype,"skewY",void 0),_h([fo(0,!0)],qh.prototype,"offsetX",void 0),_h([fo(0,!0)],qh.prototype,"offsetY",void 0),_h([mo(0,!0)],qh.prototype,"scrollX",void 0),_h([mo(0,!0)],qh.prototype,"scrollY",void 0),_h([yo()],qh.prototype,"origin",void 0),_h([yo()],qh.prototype,"around",void 0),_h([_o(!1)],qh.prototype,"lazy",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(bo(this),this.__.__removeNaturalSize())}}))}(1)],qh.prototype,"pixelRatio",void 0),_h([Bo(0)],qh.prototype,"renderSpread",void 0),_h([function(t){return go(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),bo(this)}}))}()],qh.prototype,"path",void 0),_h([ko()],qh.prototype,"windingRule",void 0),_h([ko(!0)],qh.prototype,"closed",void 0),_h([xo(0)],qh.prototype,"padding",void 0),_h([xo(!1)],qh.prototype,"lockRatio",void 0),_h([xo()],qh.prototype,"widthRange",void 0),_h([xo()],qh.prototype,"heightRange",void 0),_h([_o(!1)],qh.prototype,"draggable",void 0),_h([_o()],qh.prototype,"dragBounds",void 0),_h([_o("auto")],qh.prototype,"dragBoundsType",void 0),_h([_o(!1)],qh.prototype,"editable",void 0),_h([Po(!0)],qh.prototype,"hittable",void 0),_h([Po("path")],qh.prototype,"hitFill",void 0),_h([So("path")],qh.prototype,"hitStroke",void 0),_h([Po(!1)],qh.prototype,"hitBox",void 0),_h([Po(!0)],qh.prototype,"hitChildren",void 0),_h([Po(!0)],qh.prototype,"hitSelf",void 0),_h([Po()],qh.prototype,"hitRadius",void 0),_h([function(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}("")],qh.prototype,"cursor",void 0),_h([To()],qh.prototype,"fill",void 0),_h([So(void 0,!0)],qh.prototype,"stroke",void 0),_h([So("inside")],qh.prototype,"strokeAlign",void 0),_h([So(1,!0)],qh.prototype,"strokeWidth",void 0),_h([So(!1)],qh.prototype,"strokeScaleFixed",void 0),_h([So("none")],qh.prototype,"strokeCap",void 0),_h([So("miter")],qh.prototype,"strokeJoin",void 0),_h([So()],qh.prototype,"dashPattern",void 0),_h([So(0)],qh.prototype,"dashOffset",void 0),_h([So(10)],qh.prototype,"miterLimit",void 0),_h([ko(0)],qh.prototype,"cornerRadius",void 0),_h([ko()],qh.prototype,"cornerSmoothing",void 0),_h([fh()],qh.prototype,"shadow",void 0),_h([fh()],qh.prototype,"innerShadow",void 0),_h([fh()],qh.prototype,"blur",void 0),_h([fh()],qh.prototype,"backgroundBlur",void 0),_h([fh()],qh.prototype,"grayscale",void 0),_h([fh()],qh.prototype,"filter",void 0),_h([To()],qh.prototype,"placeholderColor",void 0),_h([_o(100)],qh.prototype,"placeholderDelay",void 0),_h([_o({})],qh.prototype,"data",void 0),_h([Wo(ih.prototype.reset)],qh.prototype,"reset",null),qh=Kh=_h([Yo(Vh),Yo(jh),zo()],qh);var $h,Jh=class extends qh{get __tag(){return"Group"}get isBranch(){return!0}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);if(!this.childlessJSON){const i=e.children=[];this.children.forEach(e=>e.skipJSON||i.push(e.toJSON(t)))}return 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(){}};_h([Lo(Wh)],Jh.prototype,"__",void 0),_h([xo(0)],Jh.prototype,"width",void 0),_h([xo(0)],Jh.prototype,"height",void 0),Jh=_h([Yo(uh),No()],Jh);var Qh=ne.get("Leafer"),tl=$h=class extends Jh{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&ro.isComplete}get layoutLocked(){return!this.layouter.running}get view(){return this.canvas&&this.canvas.view}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),$h.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,E.assign(s,t));const r=this.canvas=ge.canvas(s);this.__controllers.push(this.renderer=ge.renderer(this,r,s),this.watcher=ge.watcher(this,s),this.layouter=ge.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),e||(this.selector=ge.selector(this),this.interaction=ge.interaction(this,r,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ge.hitCanvasManager()),this.canvasManager=new xe,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(r),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),vn.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(jn.RESTART):this.emitLeafer(jn.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(jn.STOP))}unlockLayout(t=!0){this.layouter.start(),t&&this.updateLayout()}lockLayout(t=!0){t&&this.updateLayout(),this.layouter.stop()}resize(t){const e=E.copyAttrs({},t,Ie);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new qt(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=E.copyAttrs({},this.canvas,Ie);e.resize(t),this.updateLazyBounds(),this.__onResize(new Xn(t,i))}__onResize(t){this.emitEvent(t),E.copyAttrs(this.__,t,Ie),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(){const{config:t,parentApp:e}=this;e||(t.width&&t.height||(this.autoLayout=new Jt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Ie.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())):"mode"===t&&this.emit(jn.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Ie.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,r=E.copyAttrs({},s,Ie);r[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(r)}__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(jn.BEFORE_READY),this.emitLeafer(jn.READY),this.emitLeafer(jn.AFTER_READY),vn.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(jn.VIEW_READY),vn.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:r,pixelRatio:o}=this;const n="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,n.x+n.width)),i||(r=Math.max(1,n.y+n.height)),this.__doResize({width:s,height:r,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){vn.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(jn.VIEW_COMPLETED),vn.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 r=0;r<s.length;r++)if(s[r]===t){s.splice(r,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return pe.need("view")}getValidMove(t,e,i){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 jn(t,this))}__listenEvents(){const t=de.start("FirstCreate "+this.innerName);this.once([[jn.START,()=>de.end(t)],[Vn.START,this.updateLazyBounds,this],[Un.START,this.__onCreated,this],[Un.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Hn.DATA,this.__onWatchData,this],[Vn.END,this.__onLayoutEnd,this],[Un.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){$h.list.remove(this);try{this.stop(),this.emitLeafer(jn.END),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&&this.canvasManager.destroy()),this.canvas&&this.canvas.destroy(),this.config.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{no.clearRecycled()},100)}catch(t){Qh.error(t)}}};t?e():setTimeout(e)}};tl.list=new ph,_h([Lo(class extends Wh{__getInputData(t,e){const i=super.__getInputData(t,e);return Ie.forEach(t=>delete i[t]),i}})],tl.prototype,"__",void 0),_h([xo()],tl.prototype,"pixelRatio",void 0),_h([_o("normal")],tl.prototype,"mode",void 0),tl=$h=_h([No()],tl);var el=class extends qh{get __tag(){return"Rect"}};_h([Lo(Yh)],el.prototype,"__",void 0),el=_h([Yo(Zh),zo(),No()],el);var{add:il,includes:sl,scroll:rl}=jt,ol=el.prototype,nl=Jh.prototype,al=class extends Jh{get __tag(){return"Box"}get isBranchLeaf(){return!0}get __useSelfBox(){return this.pathInputed}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.__useSelfBox){const t=this.__;if(t.__autoSide){t.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:e}=this.__layout;t.__autoSize||(t.__autoWidth?(e.width+=e.x,e.x=0,e.height=t.height,e.y=0):(e.height+=e.y,e.y=0,e.width=t.width,e.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t,e;if(this.children.length){const i=this.__,s=this.__layout,{renderBounds:r,boxBounds:o}=s,{overflow:n}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=n&&n.includes("scroll"))&&(il(a,o),rl(a,i)),this.__updateRectRenderBounds(),t=!sl(o,a),t&&"show"===n&&il(r,a)}else this.__updateRectRenderBounds();E.stintSet(this,"isOverflow",t),this.__checkScroll(e)}__updateRectRenderBounds(){}__checkScroll(t){}__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)),this.hasScroller&&this.scroller.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};_h([Lo(zh)],al.prototype,"__",void 0),_h([xo(100)],al.prototype,"width",void 0),_h([xo(100)],al.prototype,"height",void 0),_h([_o(!1)],al.prototype,"resizeChildren",void 0),_h([Bo("show")],al.prototype,"overflow",void 0),_h([Wo(ol.__updateStrokeSpread)],al.prototype,"__updateStrokeSpread",null),_h([Wo(ol.__updateRenderSpread)],al.prototype,"__updateRectRenderSpread",null),_h([Wo(ol.__updateBoxBounds)],al.prototype,"__updateRectBoxBounds",null),_h([Wo(ol.__updateStrokeBounds)],al.prototype,"__updateStrokeBounds",null),_h([Wo(ol.__updateRenderBounds)],al.prototype,"__updateRectRenderBounds",null),_h([Wo(ol.__updateChange)],al.prototype,"__updateRectChange",null),_h([Wo(ol.__render)],al.prototype,"__renderRect",null),_h([Wo(nl.__render)],al.prototype,"__renderGroup",null),al=_h([zo(),No()],al);var hl=class extends al{get __tag(){return"Frame"}get isFrame(){return!0}};_h([Lo(class extends zh{})],hl.prototype,"__",void 0),_h([To("#FFFFFF")],hl.prototype,"fill",void 0),_h([Bo("hide")],hl.prototype,"overflow",void 0),hl=_h([No()],hl);var{moveTo:ll,closePath:dl,ellipse:cl}=Ms,ul=class extends qh{get __tag(){return"Ellipse"}__updatePath(){const t=this.__,{width:e,height:i,innerRadius:s,startAngle:r,endAngle:o}=t,n=e/2,a=i/2,h=t.path=[];let l;s?r||o?(s<1?cl(h,n,a,n*s,a*s,0,r,o,!1):l=!0,cl(h,n,a,n,a,0,o,r,!0)):(s<1&&(cl(h,n,a,n*s,a*s),ll(h,e,a)),cl(h,n,a,n,a,0,360,0,!0)):r||o?(ll(h,n,a),cl(h,n,a,n,a,0,r,o,!1)):cl(h,n,a,n,a),l||dl(h),(se.ellipseToCurve||t.__useArrow||t.cornerRadius)&&(t.path=this.getPath(!0))}};_h([Lo(class extends Ah{get __boxStroke(){return!this.__pathInputed}})],ul.prototype,"__",void 0),_h([ko(0)],ul.prototype,"innerRadius",void 0),_h([ko(0)],ul.prototype,"startAngle",void 0),_h([ko(0)],ul.prototype,"endAngle",void 0),ul=_h([No()],ul);var{sin:pl,cos:gl,PI:_l}=Math,{moveTo:fl,lineTo:ml,closePath:yl,drawPoints:vl}=Ms,wl=class extends qh{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)vl(e,t.points,t.curve,t.closed);else{const{width:i,height:s,sides:r,startAngle:o}=t,n=i/2,a=s/2;let h,l=0;o?(l=o*V,fl(e,n+n*pl(l),a-a*gl(l))):fl(e,n,0);for(let t=1;t<r;t++)h=2*t*_l/r+l,ml(e,n+n*pl(h),a-a*gl(h));yl(e)}}};_h([Lo(class extends Fh{})],wl.prototype,"__",void 0),_h([ko(3)],wl.prototype,"sides",void 0),_h([ko(0)],wl.prototype,"startAngle",void 0),_h([ko()],wl.prototype,"points",void 0),_h([ko(0)],wl.prototype,"curve",void 0),wl=_h([zo(),No()],wl);var{sin:xl,cos:bl,PI:kl}=Math,{moveTo:El,lineTo:Sl,closePath:Bl}=Ms,Tl=class extends qh{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s,startAngle:r}=this.__,o=t/2,n=e/2,a=this.__.path=[];let h,l=0;r?(l=r*V,El(a,o+o*xl(l),n-n*bl(l))):El(a,o,0);for(let d=1;d<2*i;d++)h=d*kl/i+l,Sl(a,o+(d%2==0?o:o*s)*xl(h),n-(d%2==0?n:n*s)*bl(h));Bl(a)}};_h([Lo(class extends Ah{get __boxStroke(){return!this.__pathInputed}})],Tl.prototype,"__",void 0),_h([ko(5)],Tl.prototype,"corners",void 0),_h([ko(.382)],Tl.prototype,"innerRadius",void 0),_h([ko(0)],Tl.prototype,"startAngle",void 0),Tl=_h([No()],Tl);var{moveTo:Cl,lineTo:Ol,drawPoints:Rl}=Ms,{rotate:Pl,getAngle:Ll,getDistance:Ml,defaultPoint:Dl}=_t,Al=class extends qh{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&Pl(i,e),i}set toPoint(t){this.width=Ml(Dl,t),this.rotation=Ll(Dl,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?Rl(e,t.points,t.curve,t.closed):(Cl(e,0,0),Ol(e,this.width,0))}};_h([Lo(Fh)],Al.prototype,"__",void 0),_h([Eo("center")],Al.prototype,"strokeAlign",void 0),_h([xo(0)],Al.prototype,"height",void 0),_h([ko()],Al.prototype,"points",void 0),_h([ko(0)],Al.prototype,"curve",void 0),_h([ko(!1)],Al.prototype,"closed",void 0),Al=_h([No()],Al);var Il=class extends el{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return v(t)&&t[0].image}};_h([Lo(class extends Yh{get __urlType(){return"image"}setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:this.__urlType,mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return t.url&&delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url&&delete i.fill,i}})],Il.prototype,"__",void 0),_h([xo("")],Il.prototype,"url",void 0),Il=_h([No()],Il);var Wl=class extends el{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=ge.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new co({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new An(An.LOADED,{image:t}))})}draw(t,e,i,s){const r=new bt(t.worldTransform).invert(),o=new bt;e&&o.translate(e.x,e.y),i&&(y(i)?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),r.multiplyParent(o),t.__render(this.canvas,{matrix:r.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:r}=this.canvas;t.drawImage(r,0,0,r.width,r.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=null),super.destroy()}};_h([Lo(class extends Yh{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}})],Wl.prototype,"__",void 0),_h([mh(100)],Wl.prototype,"width",void 0),_h([mh(100)],Wl.prototype,"height",void 0),_h([mh(1)],Wl.prototype,"pixelRatio",void 0),_h([mh(!0)],Wl.prototype,"smooth",void 0),_h([_o(!1)],Wl.prototype,"safeResize",void 0),_h([mh()],Wl.prototype,"contextSettings",void 0),Wl=_h([No()],Wl);var{copyAndSpread:zl,includes:Fl,spread:Yl,setList:Nl}=jt,{stintSet:Xl}=E,Hl=class extends qh{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:r,fontWeight:o,italic:n,textCase:a,textOverflow:h,padding:l,width:d,height:c}=t;t.__lineHeight=wh.number(e,r),t.__letterSpacing=wh.number(i,r),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==o?o+" ":""}${r||12}px ${s||"caption"}`,Xl(t,"__padding",l&&X.fourNumber(l)),Xl(t,"__clipText","show"!==h&&!t.__autoSize),Xl(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=yh.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:r,__autoWidth:o,__autoHeight:n}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&Yl(a,i/2),o||n){if(h.x=o?a.x:0,h.y=n?a.y:0,h.width=o?a.width:t.width,h.height=n?a.height:t.height,r){const[e,i,s,r]=t.__padding;o&&(h.x-=r,h.width+=i+r),n&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),E.stintSet(this,"isOverflow",!Fl(h,a)),this.isOverflow?(Nl(t.__textBoxBounds={},[h,a]),e.renderChanged=!0):t.__textBoxBounds=h}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;zl(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__updateChange(){super.__updateChange();const t=this.__box;t&&(t.__onUpdateSize(),t.__updateChange())}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}__drawShape(t,e){e.shape&&this.__box&&this.__box.__drawShape(t,e),super.__drawShape(t,e)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};_h([Lo(class extends Ah{get __useNaturalRatio(){return!1}setFontWeight(t){f(t)?(this.__setInput("fontWeight",t),t=Nh[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=fe.get("Rect",0);const r=e.__layout,o=i.__layout;s||(i.parent=e,i.__world=e.__world,o.boxBounds=r.boxBounds),i.set(t),o.strokeChanged&&r.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}__getInputData(t,e){const i=super.__getInputData(t,e);return i.textEditing&&delete i.textEditing,i}})],Hl.prototype,"__",void 0),_h([xo(0)],Hl.prototype,"width",void 0),_h([xo(0)],Hl.prototype,"height",void 0),_h([To()],Hl.prototype,"boxStyle",void 0),_h([_o(!1)],Hl.prototype,"resizeFontSize",void 0),_h([To("#000000")],Hl.prototype,"fill",void 0),_h([Eo("outside")],Hl.prototype,"strokeAlign",void 0),_h([Po("all")],Hl.prototype,"hitFill",void 0),_h([xo("")],Hl.prototype,"text",void 0),_h([xo("")],Hl.prototype,"placeholder",void 0),_h([xo("caption")],Hl.prototype,"fontFamily",void 0),_h([xo(12)],Hl.prototype,"fontSize",void 0),_h([xo("normal")],Hl.prototype,"fontWeight",void 0),_h([xo(!1)],Hl.prototype,"italic",void 0),_h([xo("none")],Hl.prototype,"textCase",void 0),_h([xo("none")],Hl.prototype,"textDecoration",void 0),_h([xo(0)],Hl.prototype,"letterSpacing",void 0),_h([xo({type:"percent",value:1.5})],Hl.prototype,"lineHeight",void 0),_h([xo(0)],Hl.prototype,"paraIndent",void 0),_h([xo(0)],Hl.prototype,"paraSpacing",void 0),_h([xo("x")],Hl.prototype,"writingMode",void 0),_h([xo("left")],Hl.prototype,"textAlign",void 0),_h([xo("top")],Hl.prototype,"verticalAlign",void 0),_h([xo(!0)],Hl.prototype,"autoSizeAlign",void 0),_h([xo("normal")],Hl.prototype,"textWrap",void 0),_h([xo("show")],Hl.prototype,"textOverflow",void 0),_h([To(!1)],Hl.prototype,"textEditing",void 0),Hl=_h([No()],Hl);var Vl=class extends qh{get __tag(){return"Path"}};_h([Lo(class extends Ah{get __pathInputed(){return 2}})],Vl.prototype,"__",void 0),_h([Eo("center")],Vl.prototype,"strokeAlign",void 0),Vl=_h([No()],Vl);var Ul=class extends Jh{get __tag(){return"Pen"}setStyle(t){const e=this.pathElement=new Vl(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,r,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,r){return this}ellipse(t,e,i,s,r,o,n,a){return this}arc(t,e,i,s,r,o){return this}arcTo(t,e,i,s,r){return this}drawEllipse(t,e,i,s,r,o,n,a){return this}drawArc(t,e,i,s,r,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){const{pathElement:t}=this;t.__layout.boxChanged||t.forceUpdate("path")}};function jl(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}_h([Lo(class extends Wh{})],Ul.prototype,"__",void 0),_h([(t,e)=>{uo(t,e,{get(){return this.__path}})}],Ul.prototype,"path",void 0),Ul=_h([Yo(qs,["set","path","paint"]),No()],Ul);var Gl=class extends tl{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){super(t,e)}init(t,e){if(super.init(t,e),t){const{ground:e,tree:i,sky:s,editor:r}=t;e&&(this.ground=this.addLeafer(e)),(i||r)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||r)&&(this.sky=this.addLeafer(s)),r&&ge.editor(r,this)}}__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()}__updateLocalBounds(){this.forEach(t=>t.updateLayout()),super.__updateLocalBounds()}start(){super.start(),this.forEach(t=>t.start())}stop(){this.forEach(t=>t.stop()),super.stop()}unlockLayout(){super.unlockLayout(),this.forEach(t=>t.unlockLayout())}lockLayout(){super.lockLayout(),this.forEach(t=>t.lockLayout())}forceRender(t,e){this.forEach(i=>i.forceRender(t,e))}addLeafer(t){const e=new tl(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),g(e)||(t.canvas.childIndex=e),this.__listenChildEvents(t)}forEach(t){this.children.forEach(t)}__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){t.context&&this.forEach(i=>e.matrix?i.__render(t,e):t.copyWorld(i.canvas,e.bounds,void 0,void 0,!0))}__onResize(t){this.forEach(e=>e.resize(t)),super.__onResize(t)}updateLayout(){this.forEach(t=>t.updateLayout())}__getChildConfig(t){const e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&E.assign(e,t),this.autoLayout&&E.copyAttrs(e,this,Ie),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Vn.END,this.__onReady,this],[Un.START,this.__onCreated,this],[Un.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Un.END,this.__onChildRenderEnd,this))}};Gl=jl([No()],Gl);var Kl={},Zl={isHoldSpaceKey:()=>Zl.isHold("Space"),isHold:t=>Kl[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){Kl[t]||(Kl[t]=!0)},setUpCode(t){Kl[t]=!1}},ql={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},$l=class extends Rn{get spaceKey(){return Zl.isHoldSpaceKey()}get left(){return ql.left(this)}get right(){return ql.right(this)}get middle(){return ql.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return Zl.isHoldKeys(t,this)}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){ve.changeName(t,e)}},{min:Jl,max:Ql,abs:td}=Math,{float:ed,sign:id}=X,{minX:sd,maxX:rd,minY:od,maxY:nd}=jt,ad=new qt,hd=new qt,ld={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&dd.getValidMove(t.__localBoxBounds,dd.getDragBounds(t),s,e,!0),dd.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:r,dragBoundsType:o}=t;r&&dd.getValidScaleOf(t.__localBoxBounds,dd.getDragBounds(t),o,t.getLocalPointByInner(t.getInnerPointByBox(e)),i,s,!0)},axisMove(t,e){const{draggable:i}=t;"x"===i&&(e.y=0),"y"===i&&(e.x=0)},getDragBounds(t){const{dragBounds:e}=t;return"parent"===e?t.parent.boxBounds:e},isInnerMode:(t,e,i,s)=>"inner"===i||"auto"===i&&ed(t[s])>ed(e[s]),getValidMove(t,e,i,s,r){const o=t.x+s.x,n=t.y+s.y,a=o+t.width,h=n+t.height,l=e.x+e.width,d=e.y+e.height;return r||(s=Object.assign({},s)),dd.isInnerMode(t,e,i,"width")?o>e.x?s.x+=e.x-o:a<l&&(s.x+=l-a):o<e.x?s.x+=e.x-o:a>l&&(s.x+=l-a),dd.isInnerMode(t,e,i,"height")?n>e.y?s.y+=e.y-n:h<d&&(s.y+=d-h):n<e.y?s.y+=e.y-n:h>d&&(s.y+=d-h),s.x=ed(s.x),s.y=ed(s.y),s},getValidScaleOf(t,e,i,s,r,o,n){n||(r=Object.assign({},r)),hd.set(e),ad.set(t).scaleOf(s,r.x,r.y);const a=(s.x-t.x)/t.width,h=1-a,l=(s.y-t.y)/t.height,d=1-l;let c,u,p,g,_=1,f=1;return dd.isInnerMode(t,e,i,"width")?(r.x<0&&ad.scaleOf(s,_=1/r.x,1),p=ed(ad.minX-hd.minX),g=ed(hd.maxX-ad.maxX),c=a&&p>0?1+p/(a*ad.width):1,u=h&&g>0?1+g/(h*ad.width):1,_*=Ql(c,u)):(r.x<0&&((ed(sd(t)-sd(e))<=0||ed(rd(e)-rd(t))<=0)&&ad.scaleOf(s,_=1/r.x,1),ad.unsign()),p=ed(hd.minX-ad.minX),g=ed(ad.maxX-hd.maxX),c=a&&p>0?1-p/(a*ad.width):1,u=h&&g>0?1-g/(h*ad.width):1,_*=Jl(c,u)),dd.isInnerMode(t,e,i,"height")?(r.y<0&&ad.scaleOf(s,1,f=1/r.y),p=ed(ad.minY-hd.minY),g=ed(hd.maxY-ad.maxY),c=l&&p>0?1+p/(l*ad.height):1,u=d&&g>0?1+g/(d*ad.height):1,f*=Ql(c,u),o&&(c=Ql(td(_),td(f)),_=id(_)*c,f=id(f)*c)):(r.y<0&&((ed(od(t)-od(e))<=0||ed(nd(e)-nd(t))<=0)&&ad.scaleOf(s,1,f=1/r.y),ad.unsign()),p=ed(hd.minY-ad.minY),g=ed(ad.maxY-hd.maxY),c=l&&p>0?1-p/(l*ad.height):1,u=d&&g>0?1-g/(d*ad.height):1,f*=Jl(c,u)),r.x*=m(_)?_:1,r.y*=m(f)?f:1,r}},dd=ld,cd=class extends $l{};cd.POINTER="pointer",cd.BEFORE_DOWN="pointer.before_down",cd.BEFORE_MOVE="pointer.before_move",cd.BEFORE_UP="pointer.before_up",cd.DOWN="pointer.down",cd.MOVE="pointer.move",cd.UP="pointer.up",cd.OVER="pointer.over",cd.OUT="pointer.out",cd.ENTER="pointer.enter",cd.LEAVE="pointer.leave",cd.TAP="tap",cd.DOUBLE_TAP="double_tap",cd.CLICK="click",cd.DOUBLE_CLICK="double_click",cd.LONG_PRESS="long_press",cd.LONG_TAP="long_tap",cd.MENU="pointer.menu",cd.MENU_TAP="pointer.menu_tap";cd=jl([Xo()],cd);var ud={},pd=class extends cd{static setList(t){this.list=t instanceof ph?t:new ph(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const r=t.getLocalPoint(i,null,!0);return _t.move(r,e.x-t.x,e.y-t.y),s&&this.limitMove(t,r),ld.axisMove(t,r),r}static limitMove(t,e){ld.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(ud,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(ud,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(ud,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 jt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),jt.unsign(i),i}assignMove(t){ud.x=t?this.totalX:this.moveX,ud.y=t?this.totalY:this.moveY}};pd.BEFORE_DRAG="drag.before_drag",pd.START="drag.start",pd.DRAG="drag",pd.END="drag.end",pd.OVER="drag.over",pd.OUT="drag.out",pd.ENTER="drag.enter",pd.LEAVE="drag.leave",pd=jl([Xo()],pd);var gd=class extends cd{static setList(t){pd.setList(t)}static setData(t){pd.setData(t)}};gd.DROP="drop",gd=jl([Xo()],gd);var _d=class extends pd{};_d.BEFORE_MOVE="move.before_move",_d.START="move.start",_d.MOVE="move",_d.DRAG_ANIMATE="move.drag_animate",_d.END="move.end",_d.PULL_DOWN="move.pull_down",_d.REACH_BOTTOM="move.reach_bottom",_d=jl([Xo()],_d);var fd=class extends $l{};fd=jl([Xo()],fd);var md=class extends cd{};md.BEFORE_ROTATE="rotate.before_rotate",md.START="rotate.start",md.ROTATE="rotate",md.END="rotate.end",md=jl([Xo()],md);var yd=class extends pd{};yd.SWIPE="swipe",yd.LEFT="swipe.left",yd.RIGHT="swipe.right",yd.UP="swipe.up",yd.DOWN="swipe.down",yd=jl([Xo()],yd);var vd=class extends cd{};vd.BEFORE_ZOOM="zoom.before_zoom",vd.START="zoom.start",vd.ZOOM="zoom",vd.END="zoom.end",vd=jl([Xo()],vd);var wd=class extends $l{};wd.BEFORE_DOWN="key.before_down",wd.BEFORE_UP="key.before_up",wd.DOWN="key.down",wd.HOLD="key.hold",wd.UP="key.up",wd=jl([Xo()],wd);var xd={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?yd.UP:t>45&&t<135?yd.DOWN:t<=45&&t>=-45?yd.RIGHT:yd.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:bd.getSwipeDirection(_t.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,time:Date.now(),buttons:g(t.buttons)?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let s=0,r=i.length;s<r;s++)if(i[s].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new ph,{list:s}=t;for(let r=0,o=s.length;r<o;r++)s[r].hasEvent(e)&&i.add(s[r]);return i},pathCanDrag:t=>t&&t.list.some(t=>tn.draggable(t)||!t.isLeafer&&t.hasEvent(pd.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},bd=xd,kd=new ph,{getDragEventData:Ed,getDropEventData:Sd,getSwipeEventData:Bd}=xd,Td=class{constructor(t){this.dragDataList=[],this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Ed(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,r=pd.list||this.draggableList||kd;return this.dragging&&(s?t?kd:new ph(e?[...i.list,...i.dragHoverExclude]:i.list):r)}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(_d.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&ql.left(t),this.dragging&&(this.interaction.emit(pd.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],tn.draggable(e)){this.draggableList=new ph(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:r,throughPath:o}=s;this.dragData=Ed(s,i,t),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.dragDataList.push(this.dragData),this.moving?(t.moving=!0,this.dragData.moveType="drag",e.emit(_d.BEFORE_MOVE,this.dragData),e.emit(_d.MOVE,this.dragData)):this.dragging&&(t.dragging=!0,this.dragReal(),e.emit(pd.BEFORE_DRAG,this.dragData),e.emit(pd.DRAG,this.dragData))}dragReal(t){const{interaction:e}=this,{running:i}=e,s=this.realDraggableList;if(s.length&&i){const{totalX:i,totalY:r}=this.dragData,{dragLimitAnimate:o}=e.p,n=!o||!!t;s.forEach(e=>{if(e.draggable){const s=f(e.draggable),a=pd.getValidMove(e,this.dragStartPoints[e.innerId],{x:i,y:r},n||s);o&&!s&&t?tn.animateMove(e,a,y(o)?o:.3):e.move(a)}})}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(pd.OUT,t,i),e.emit(pd.OVER,t,s)):e.emit(pd.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(pd.LEAVE,t,i,s),e.emit(pd.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:r,throughPath:o}=i,n=Ed(i,t,t);if(o&&(n.throughPath=o),n.path=r,this.moving&&(this.moving=!1,n.moveType="drag",e.emit(_d.END,n)),this.dragging){const r=this.getList();this.dragging=!1,e.p.dragLimitAnimate&&this.dragReal(!0),e.emit(pd.END,n),this.swipe(t,i,s,n),this.drop(t,r,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:r}=this;if(_t.getDistance(e,t)>r.config.pointer.swipeDistance){const t=Bd(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=Sd(t,e,pd.data);s.path=i,this.interaction.emit(gd.DROP,s),this.interaction.emit(pd.LEAVE,t,i)}dragReset(){pd.list=pd.data=this.draggableList=this.dragData=this.downData=this.dragOverPath=this.dragEnterPath=null,this.dragDataList=[]}checkDragEndAnimate(t,e){return!1}animate(t,e){}stopAnimate(){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}},Cd=ne.get("emit"),Od=["move","zoom","rotate","key"];function Rd(t,e,i,s,r){if(Od.some(t=>e.startsWith(t))&&t.__.hitChildren&&!Ld(t,r)){let o;for(let n=0,a=t.children.length;n<a;n++)o=t.children[n],!i.path.has(o)&&o.__.hittable&&Pd(o,e,i,s,r)}}function Pd(t,e,i,s,r){if(t.destroyed)return!1;if(t.__.hitSelf&&!Ld(t,r)&&(Ch.updateEventStyle&&!s&&Ch.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const r=ve.get(e,i);if(t.emitEvent(r,s),r.isStop)return!0}return!1}function Ld(t,e){return e&&e.has(t)}var Md={wheel:{zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8}},pointer:{type:"pointer",snap:!0,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:Dd,pathCanDrag:Ad,pathHasOutside:Id}=xd,Wd=class{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&&ql.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&ql.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&Zl.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=E.clone(Md),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new ph(t),this.createTransformer(),this.dragger=new Td(this),s&&(this.config=E.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(ql.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(cd.BEFORE_DOWN,t),t.path.needUpdate&&this.updateDownData(t),this.emit(cd.DOWN,t),ql.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=ql.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&&ql.defaultLeft(t),(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(cd.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=_t.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(cd.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;ql.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(cd.BEFORE_UP,t),this.emit(cd.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(cd.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(cd.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;this.emit(wd.BEFORE_DOWN,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Zl.setDownCode(e),this.emit(wd.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(wd.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;this.emit(wd.BEFORE_UP,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]=!1,Zl.setUpCode(e),this.emit(wd.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new ph),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(cd.OUT,t,i),this.emit(cd.OVER,t,e)):this.emit(cd.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(cd.LEAVE,t,i,e),this.emit(cd.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(cd.LEAVE,t),this.dragger.dragging&&this.emit(gd.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,r=[cd.DOUBLE_TAP,cd.DOUBLE_CLICK].some(e=>Dd(t.path,e));s<e.tapTime+50&&r?(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(t,e){const{hitRadius:i,through:s}=this.p,{bottomList:r,target:o}=this;se.backgrounder||t.origin||o&&o.updateLayout();const n=this.selector.getByPoint(t,i,Object.assign({bottomList:r,name:t.type},e||{through:s}));return n.throughPath&&(t.throughPath=n.throughPath),t.path=n.path,n.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&&!Ad(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))}stopDragAnimate(){this.dragger.stopAnimate()}replaceDownTarget(t){const{downData:e}=this;if(e&&t){const{path:i}=e;i.remove(i.list[0]),i.addAt(t,0)}}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:cd.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 r=0,o=s.length;r<o&&(e=s.list[r],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);r++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:r}=this.canvas;return s.x*=r.width/i.width,s.y*=r.height/i.height,this.p.snap&&_t.round(s),s}emitTap(t){this.emit(cd.TAP,t),this.emit(cd.CLICK,t)}emitDoubleTap(t){this.emit(cd.DOUBLE_TAP,t),this.emit(cd.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(cd.LONG_PRESS,t)},this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(cd.LONG_TAP,t),(Dd(t.path,cd.LONG_TAP)||Dd(t.path,cd.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new qt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(y(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Xn.RESIZE,this.__onResize,this)],t.once(jn.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 r;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(r=i.list[o],Pd(r,t,e,!0,s))return;r.isApp&&Rd(r,t,e,!0,s)}for(let o=0,n=i.length;o<n;o++)if(r=i.list[o],r.isApp&&Rd(r,t,e,!1,s),Pd(r,t,e,!1,s))return}catch(t){Cd.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)}},zd=class{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}};zd.custom={};var Fd=class extends xe{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new ph,this.pixelList=new ph}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),ge.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),ge.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()}};se.getSelector=function(t){return t.leafer?t.leafer.selector:se.selector||(se.selector=ge.selector())};var{toInnerRadiusPointOf:Yd,copyRadiusPoint:Nd}=_t,{hitRadiusPoint:Xd,hitPoint:Hd}=jt,Vd={},Ud={},jd=ih.prototype;jd.hit=function(t,e=0){this.updateLayout(),Nd(Ud,t,e);const i=this.__world;return!!(e?Xd(i,Ud):Hd(i,Ud))&&(this.isBranch?se.getSelector(this).hitPoint(Object.assign({},Ud),e,{target:this}):this.__hitWorld(Ud))},jd.__hitWorld=function(t,e){const i=this.__;if(!i.hitSelf)return!1;const s=this.__world,r=this.__layout,o=s.width<10&&s.height<10;if(i.hitRadius&&(Nd(Vd,t,i.hitRadius),t=Vd),Yd(t,s,Vd),i.hitBox||o){if(jt.hitRadiusPoint(r.boxBounds,Vd))return!0;if(o)return!1}return!r.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),r.boundsChanged||(r.hitCanvasChanged=!1)),this.__hit(Vd,e)},jd.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},jd.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},jd.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},jd.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};var Gd=new bt,Kd=qh.prototype;Kd.__updateHitCanvas=function(){this.__box&&this.__box.__updateHitCanvas();const{hitCanvasManager:t}=this.leafer||this.parent&&this.parent.leafer||{};if(!t)return;const e=this.__,i=(e.__isAlphaPixelFill||e.__isCanvas)&&"pixel"===e.hitFill,s=e.__isAlphaPixelStroke&&"pixel"===e.hitStroke,r=i||s;this.__hitCanvas||(this.__hitCanvas=r?t.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):t.getPathType(this));const o=this.__hitCanvas;if(r){const{renderBounds:t}=this.__layout,r=se.image.hitCanvasSize,n=o.hitScale=$t.set(0,0,r,r).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=$t.set(t).scale(n);o.resize({width:l,height:d,pixelRatio:1}),o.clear(),no.patternLocked=!0,this.__renderShape(o,{matrix:Gd.setWith(this.__world).scaleWith(1/n).invertWith().translate(-a,-h),snapshot:!0,ignoreFill:!i,ignoreStroke:!s}),no.patternLocked=!1,o.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(o),o.setStrokeOptions(e)},Kd.__hit=function(t,e){if(this.__box&&this.__box.__hit(t))return!0;const i=this.__;if(i.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:s}=i,r=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__isAlphaPixelFill||i.__isCanvas))||"all"===s||e;if(r&&this.__hitFill(t))return!0;const{hitStroke:o,__maxStrokeWidth:n}=i,a=i.stroke&&("path"===o||"pixel"===o&&!i.__isAlphaPixelStroke)||"all"===o;if(!r&&!a)return!1;const h=2*t.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*n,!r&&this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h;break;case"center":l+=n;break;case"outside":if(l+=2*n,!r){if(!this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h}}return!!l&&this.__hitStroke(t,l)};var Zd=qh.prototype,qd=el.prototype,$d=al.prototype;qd.__updateHitCanvas=$d.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?Zd.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},qd.__hitFill=$d.__hitFill=function(t){return this.__hitCanvas?Zd.__hitFill.call(this,t):jt.hitRadiusPoint(this.__layout.boxBounds,t)},Hl.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:r,__textDrawData:o}=this.__;t.beginPath(),r<0?this.__drawPathByBox(t):o.rows.forEach(r=>t.rect(r.x,r.y-s,r.width,e<i?i:e))},Jh.prototype.pick=function(t,e){return e||(e=p),this.updateLayout(),se.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};var Jd,Qd=We.prototype;function tc(t,e,i,s){return new(i||(i=Promise))(function(r,o){function n(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?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,a)}h((s=s.apply(t,e||[])).next())})}Qd.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},Qd.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},Qd.hitPixel=function(t,e,i=1){let{x:s,y:r,radiusX:o,radiusY:n}=t;e&&(s-=e.x,r-=e.y),$t.set(s-o,r-n,2*o,2*n).scale(i).ceil();const{data:a}=this.context.getImageData($t.x,$t.y,$t.width||1,$t.height||1);for(let h=0,l=a.length;h<l;h+=4)if(a[h+3]>0)return!0;return a[3]>0},function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(Jd||(Jd={}));var ec=ne.get("LeaferCanvas"),ic=class extends We{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none",this.view.classList.add("leafer-canvas-view")}se.syncDomFont&&!this.parentView&&(i.display="none",document.body&&document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e=f(t)?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else ec.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.unreal||(this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i))}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),ec.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),se.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const t=se.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(t){const e=this.view,{x:i,y:s,width:r,height:o}=this.autoBounds.getBoundsFrom(t),n={width:r,height:o,pixelRatio:this.config.pixelRatio?this.pixelRatio:se.devicePixelRatio};if(!this.isSameSize(n)){const{style:t}=e;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(n)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(t){const e={};E.copyAttrs(e,this,Ie),this.resize(t),this.resizeListener&&!g(this.width)&&this.resizeListener(new Xn(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){let t=this.view;t&&t.remove(),t=this.view=document.createElement("div"),this.parentView.appendChild(this.view),t.classList.add("leafer-app-view"),this.unreal=!0}}destroy(){const{view:t}=this;t&&(this.stopAutoLayout(),this.stopListenPixelRatio(),t.parentElement&&t.remove(),super.destroy())}};$r(CanvasRenderingContext2D.prototype),$r(Path2D.prototype),Object.assign(ge,{canvas:(t,e)=>new ic(t,e),image:t=>new co(t)}),se.name="web",se.isMobile="ontouchstart"in window,se.requestRender=function(t){window.requestAnimationFrame(t)},uo(se,"devicePixelRatio",{get:()=>devicePixelRatio});var{userAgent:sc}=navigator;sc.indexOf("Firefox")>-1?(se.intWheelDeltaY=!0,se.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(se.fullImageShadow=!0),sc.indexOf("Windows")>-1?(se.os="Windows",se.intWheelDeltaY=!0):sc.indexOf("Mac")>-1?se.os="Mac":sc.indexOf("Linux")>-1&&(se.os="Linux");var rc=class{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new ph;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 ph,this.target=t,e&&(this.config=E.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(Un.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===Pn.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 i=0,s=e.length;i<s;i++)this.__pushChild(e[i])}__onRquestData(){this.target.emitEvent(new Hn(Hn.DATA,{updatedList:this.updatedList})),this.__updatedList=new ph,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Mn.CHANGE,this.__onAttrChange,this],[[Pn.ADD,Pn.REMOVE],this.__onChildEvent,this],[Hn.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}},{updateAllMatrix:oc,updateBounds:nc,updateChange:ac}=tn,{pushAllChildBranch:hc,pushAllParent:lc}=pn,{worldBounds:dc}=dn,cc=class{constructor(t){this.updatedBounds=new qt,this.beforeBounds=new qt,this.afterBounds=new qt,v(t)&&(t=new ph(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,dc)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,dc),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}},{updateAllMatrix:uc,updateAllChange:pc}=tn,gc=ne.get("Layouter"),_c=class t{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new gh,this.target=t,e&&(this.config=E.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(Vn.START),this.layoutOnce(),t.emitEvent(new Vn(Vn.END,this.layoutedBlocks,this.times))}catch(t){gc.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?gc.warn("layouting"):this.times>3?gc.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Hn.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=de.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:r,LAYOUT:o,AFTER:n}=Vn,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Vn(r,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?(oc(t,!0),e.add(t),t.isBranch&&hc(t,e),lc(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),lc(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(r=>{e=t.levelMap[r];for(let t=0,o=e.length;t<o;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||nc(s[t])}nc(i)}})}(this.__levelList),function(t){t.list.forEach(ac)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Vn(o,a,this.times)),i.emitEvent(new Vn(n,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,de.end(e)}fullLayout(){const e=de.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:r,AFTER:o}=Vn,n=this.getBlocks(new ph(i));i.emitEvent(new Vn(s,n,this.times)),t.fullLayout(i),n.forEach(t=>{t.setAfter()}),i.emitEvent(new Vn(r,n,this.times)),i.emitEvent(new Vn(o,n,this.times)),this.addBlocks(n),de.end(e)}static fullLayout(t){uc(t,!0),t.isBranch?pn.updateBounds(t):tn.updateBounds(t),pc(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new cc([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new cc(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(){this.__eventIds=[this.target.on_([[Vn.REQUEST,this.layout,this],[Vn.AGAIN,this.layoutAgain,this],[Hn.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}},fc=ne.get("Renderer"),mc=class t{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,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=E.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.requestTime||this.__requestRender()}requestLayout(){this.target.emit(Vn.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Un.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Un.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Un.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new qt,fc.log(e.innerName,"---\x3e");try{this.emitRender(Un.START),this.renderOnce(t),this.emitRender(Un.END,this.totalBounds),no.clearRecycled()}catch(t){this.rendering=!1,fc.error(t)}fc.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return fc.warn("rendering");if(this.times>3)return fc.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new qt,this.renderOptions={},t)this.emitRender(Un.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Un.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Un.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Un.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(e){const i=de.start("PartRender"),{canvas:s}=this,r=e.getIntersect(s.bounds),o=new qt(r);s.save(),r.spread(t.clipSpread).ceil();const{ceilPartPixel:n}=this.config;s.clipWorld(r,n),s.clearWorld(r,n),this.__render(r,o),s.restore(),de.end(i)}fullRender(){const t=de.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),de.end(t)}__render(t,e){const{canvas:i,target:s}=this,r=t.includes(s.__world),o=r?{includes:r}:{bounds:t,includes:r};this.needFill&&i.fillWorld(t,this.config.fill),ne.showRepaint&&ne.drawRepaint(i,t),this.config.useCellRender&&(o.cellList=this.getCellList()),se.render(s,i,o),this.renderBounds=e=e||t,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new qt;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return se.requestRender(e);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};se.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new qt(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 qt(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||fc.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new Un(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Un.REQUEST,this.update,this],[Vn.END,this.__onLayoutEnd,this],[Un.AGAIN,this.renderAgain,this],[Xn.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}};mc.clipSpread=10;var yc={},{copyRadiusPoint:vc}=_t,{hitRadiusPoint:wc}=jt,xc=class{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,r=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 ph(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:n}=this.findList,a=this.getBestMatchLeaf(n,i.bottomList,r,!!i.findList),h=r?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:n.length?this.getThroughPath(n):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const r=this.findList=new ph;if(t.length){let e;const{x:s,y:o}=this.point,n={x:s,y:o,radiusX:0,radiusY:0};for(let a=0,h=t.length;a<h;a++)if(e=t[a],(i||tn.worldHittable(e))&&(this.hitChild(e,n),r.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&tn.hasParent(t,e))){r.reset();break}return r.list[0]}}if(e)for(let o=0,n=e.length;o<n;o++)if(this.hitChild(e[o].target,this.point,e[o].proxy),r.length)return r.list[0];return s?null:i?t[0]:t.find(t=>tn.worldHittable(t))}getPath(t){const e=new ph,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new ph;for(let r=e.list.length-1;r>-1&&(i=e.list[r],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));r--);return s}getThroughPath(t){const e=new ph,i=[];for(let n=t.length-1;n>-1;n--)i.push(this.getPath(t[n]));let s,r,o;for(let n=0,a=i.length;n<a;n++){s=i[n],r=i[n+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!r||!r.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,r;const{point:o}=this;for(let n=t.length-1;n>-1;n--)if(i=t[n],r=i.__,r.visible&&(!e||r.mask))if(s=wc(i.__world,r.hitRadius?vc(yc,o,r.hitRadius):o),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&r.__clipAfterFill&&!i.__hitWorld(o,!0))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,o)}}else s&&this.hitChild(i,o)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,r=[];const{children:o}=s;for(let s=0,n=o.length;s<n;s++)if(i=o[s],i.__.mask&&r.push(i),i===t){if(r&&!r.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}},bc=class{constructor(t,e){this.config={},e&&(this.config=E.default(e,this.config)),this.picker=new xc(this.target=t,this),this.finder=ge.finder&&ge.finder(t,this.config)}getByPoint(t,e,i){const{target:s,picker:r}=this;return se.backgrounder&&s&&s.updateLayout(),r.getByPoint(t,e,i)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):pe.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}};Object.assign(ge,{watcher:(t,e)=>new rc(t,e),layouter:(t,e)=>new _c(t,e),renderer:(t,e,i)=>new mc(t,e,i),selector:(t,e)=>new bc(t,e)}),se.layout=_c.fullLayout,se.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new ph,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};var kc={convert(t,e){const i=xd.getBase(t),{x:s,y:r}=e,o=Object.assign(Object.assign({},i),{x:s,y:r,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===o.pointerType&&(o.tangentialPressure=t.tangentialPressure,o.tiltX=t.tiltX,o.tiltY=t.tiltY,o.twist=t.twist),o},convertMouse(t,e){const i=xd.getBase(t),{x:s,y:r}=e;return Object.assign(Object.assign({},i),{x:s,y:r,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=kc.getTouch(t),s=xd.getBase(t),{x:r,y:o}=e;return Object.assign(Object.assign({},s),{x:r,y:o,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Ec={convert(t){const e=xd.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:Sc}=xd,Bc=class extends Wd{get windowTarget(){const{view:t}=this;return t&&t.ownerDocument||window}get notPointer(){const{p:t}=this;return"pointer"!==t.type||t.touch||this.useMultiTouch}get notTouch(){const{p:t}=this;return"mouse"===t.type||this.usePointer}get notMouse(){return this.usePointer||this.useTouch}__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,pointerleave:this.onPointerLeave,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let s in e)e[s]=e[s].bind(this),t.addEventListener(s,e[s]);for(let s in i)i[s]=i[s].bind(this),this.windowTarget.addEventListener(s,i[s])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let i in t)this.view.removeEventListener(i,t[i]),this.viewEvents={};for(let i in e)this.windowTarget.removeEventListener(i,e[i]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!(this.downData||t.target===this.view||this.config.shadowDOM&&t.composedPath&&t.composedPath().includes(this.view))}onKeyDown(t){this.keyDown(Ec.convert(t))}onKeyUp(t){this.keyUp(Ec.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(kc.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.notPointer||(this.usePointer||(this.usePointer=!0),this.pointerDown(kc.convert(t,this.getLocal(t))))}onPointerMove(t,e){if(this.notPointer||this.preventWindowPointer(t))return;this.usePointer||(this.usePointer=!0);const i=kc.convert(t,this.getLocal(t,!0));e?this.pointerHover(i):this.pointerMove(i)}onPointerLeave(t){this.onPointerMove(t,!0)}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.notPointer||this.preventWindowPointer(t)||this.pointerUp(kc.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.notMouse||this.pointerDown(kc.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.notMouse||this.preventWindowPointer(t)||this.pointerMove(kc.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.notMouse||this.preventWindowPointer(t)||this.pointerUp(kc.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.notMouse||this.pointerCancel()}onTouchStart(t){const e=kc.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&Sc(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.notTouch||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(kc.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.notTouch||this.preventWindowPointer(t))return;const e=kc.getTouch(t);this.pointerMove(kc.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.notTouch||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout(()=>{this.useTouch=!1},500);const e=kc.getTouch(t);this.pointerUp(kc.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.notTouch||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(xd.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach(t=>{i=e.find(e=>e.identifier===t.identifier),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})}),s}getLocalTouchs(t){return t.map(t=>this.getLocal(t))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},xd.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=xd.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(X.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),w(e[e.length-1])&&e.push("default"),this.canvas.view.style.cursor=e.map(t=>w(t)?`url(${t.url}) ${t.x||0} ${t.y||0}`:t).join(",")}eachCursor(t,e,i=0){if(i++,v(t))t.forEach(t=>this.eachCursor(t,e,i));else{const s=f(t)&&zd.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}};function Tc(t,e,i){t.__.__font?bh.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Cc(t,e,i,s,r){const o=i.__;w(t)?bh.drawStrokesStyle(t,e,!1,i,s,r):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&bh.strokeArrow(t,i,s,r)}function Oc(t,e,i,s,r){const o=i.__;w(t)?bh.drawStrokesStyle(t,e,!0,i,s,r):(s.setStroke(t,o.__strokeWidth*e,o),bh.drawTextStroke(i,s,r))}function Rc(t,e,i,s,r){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,Oc(t,2,i,o,r),o.blendMode="outside"===e?"destination-out":"destination-in",bh.fillText(i,o,r),o.blendMode="normal",tn.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}var Pc,{getSpread:Lc,copyAndSpread:Mc,toOuterOf:Dc,getOuterOf:Ac,getByMove:Ic,move:Wc,getIntersectData:zc}=jt,Fc={},{stintSet:Yc}=E,{hasTransparent:Nc}=vh;function Xc(t,e,i){if(!w(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:r}=i.__layout,{type:o}=e;switch(o){case"image":case"film":case"video":if(!e.url)return;s=kh.image(i,t,e,r,!Pc||!Pc[e.url]),"image"!==o&&kh[o](s);break;case"linear":s=Eh.linearGradient(e,r);break;case"radial":s=Eh.radialGradient(e,r);break;case"angular":s=Eh.conicGradient(e,r);break;case"solid":const{color:n,opacity:a}=e;s={type:o,style:vh.string(n,a)};break;default:g(e.r)||(s={type:"solid",style:vh.string(e)})}if(s&&(s.originPaint=e,f(s.style)&&Nc(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}var Hc,Vc={compute:function(t,e){const i=e.__,s=[];let r,o,n,a=i.__input[t];v(a)||(a=[a]),Pc=kh.recycleImage(t,i);for(let h,l=0,d=a.length;l<d;l++)(h=Xc(t,a[l],e))&&(s.push(h),h.strokeStyle&&(n||(n=1),h.strokeStyle.strokeWidth&&(n=Math.max(n,h.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===t?(Yc(i,"__isAlphaPixelFill",r),Yc(i,"__isTransparentFill",o)):(Yc(i,"__isAlphaPixelStroke",r),Yc(i,"__isTransparentStroke",o),Yc(i,"__hasMultiStrokeStyle",n))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Tc(e,i,s)},fills:function(t,e,i,s){let r,o,n;for(let a=0,h=t.length;a<h;a++){if(r=t[a],o=r.originPaint,r.image){if(n?n++:n=1,kh.checkImage(r,!e.__.__font,e,i,s))continue;if(!r.style){1===n&&r.image.isPlacehold&&e.drawImagePlaceholder(r,i,s);continue}}if(i.fillStyle=r.style,r.transform||o.scaleFixed){if(i.save(),r.transform&&i.transform(r.transform),o.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,o.scaleFixed,!1);1!==t&&i.scale(t,s)}o.blendMode&&(i.blendMode=o.blendMode),Tc(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),Tc(e,i,s),i.restoreBlendMode()):Tc(e,i,s)}},fillPathOrText:Tc,fillText:function(t,e,i){const s=t.__,{rows:r,decorationY:o}=s.__textDrawData;let n;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let a=0,h=r.length;a<h;a++)n=r[a],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.fillText(t.char,t.x,n.y)});if(o){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),r.forEach(t=>o.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const r=e.__;if(r.__strokeWidth)if(r.__font)bh.strokeText(t,e,i,s);else if(r.__pathForStroke)bh.fillStroke(t,e,i,s);else switch(r.strokeAlign){case"center":Cc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Cc(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const r=e.__;if(r.__fillAfterStroke)Cc(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,n=i.getSameCanvas(!0,!0);e.__drawRenderPath(n),Cc(t,2,e,n,s),n.clipUI(r),n.clearWorld(o),tn.copyCanvasByWorld(e,i,n),n.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){bh.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Oc(t,1,e,i,s);break;case"inside":Rc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Oc(t,2,e,i,s):Rc(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,r=t.__.__textDrawData;const{rows:o,decorationY:n}=r;for(let a=0,h=o.length;a<h;a++)s=o[a],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(n){const{decorationHeight:t}=r;o.forEach(i=>n.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,r,o){let n;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||r.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,d=t.length;l<d;l++)if(n=t[l],(!n.image||!kh.checkImage(n,!1,s,r,o))&&n.style){if(h){const{strokeStyle:t}=n;t?r.setStroke(n.style,a.__getRealStrokeWidth(t)*e,a,t):r.setStroke(n.style,a.__strokeWidth*e,a)}else r.strokeStyle=n.style;n.originPaint.blendMode?(r.saveBlendMode(n.originPaint.blendMode),i?bh.drawTextStroke(s,r,o):r.stroke(),r.restoreBlendMode()):i?bh.drawTextStroke(s,r,o):r.stroke()}},shape:function(t,e,i){const s=e.getSameCanvas(),r=e.bounds,o=t.__nowWorld,n=t.__layout,a=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let h,l,d,c,u,p;Dc(n.strokeSpread?(Mc(Fc,n.boxBounds,n.strokeSpread),Fc):n.boxBounds,o,a);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(r.includes(a))p=s,h=u=a,l=o;else{let s;s=se.fullImageShadow?a:zc(n.renderShapeSpread?Lc(r,P.swapAndScale(n.renderShapeSpread,g,_)):r,a),c=r.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,i),g*=f,_*=m),u=Ac(a,c),h=Ic(u,-c.e,-c.f),l=Ac(o,c),Wc(l,-c.e,-c.f);const y=i.matrix;y?(d=new bt(c),d.multiply(y),f*=y.scaleX,m*=y.scaleY):d=c,d.withScale(f,m),i=Object.assign(Object.assign({},i),{matrix:d})}return t.__renderShape(s,i),{canvas:s,matrix:d,fitMatrix:c,bounds:h,renderBounds:l,worldCanvas:p,shapeBounds:u,scaleX:g,scaleY:_}}},Uc=new qt,{isSame:jc}=jt;function Gc(t,e,i,s,r,o){let n=!0;const a=t.__;if("fill"!==e||a.__naturalWidth||(a.__naturalWidth=s.width/a.pixelRatio,a.__naturalHeight=s.height/a.pixelRatio,a.__autoSide&&(t.forceUpdate("width"),tn.updateBounds(t),t.__proxyData&&(t.setProxyAttr("width",a.width),t.setProxyAttr("height",a.height)),n=!1)),!r.data){kh.createData(r,s,i,o);const{transform:t}=r.data,{opacity:e,blendMode:n}=i,h=t&&!t.onlyScale||a.path||a.cornerRadius;(h||e&&e<1||n)&&(r.complex=!h||2)}return i.filter&&kh.applyFilter(r,s,i.filter,t),n}function Kc(t,e){$c(t,An.LOAD,e)}function Zc(t,e){$c(t,An.LOADED,e)}function qc(t,e,i){e.error=i,t.forceUpdate("surface"),$c(t,An.ERROR,e)}function $c(t,e,i){t.hasEvent(e)&&t.emitEvent(new An(e,i))}function Jc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}var{get:Qc,translate:tu}=st,eu=new qt,iu={},su={};function ru(t,e,i,s){const r=f(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&r<0?0:r}var ou={},nu={a:1,b:0,c:0,d:1,e:0,f:0},{get:au,set:hu,rotateOfOuter:lu,translate:du,scaleOfOuter:cu,multiplyParent:uu,scale:pu,rotate:gu,skew:_u}=st;function fu(t,e,i,s,r,o,n,a){n&&gu(t,n),a&&_u(t,a.x,a.y),r&&pu(t,r,o),du(t,e.x+i,e.y+s)}var{get:mu,scale:yu,copy:vu}=st,{getFloorScale:wu}=X,{abs:xu}=Math,bu={image:function(t,e,i,s,r){let o,n;const a=no.get(i,i.type);return Hc&&i===Hc.paint&&jc(s,Hc.boxBounds)?o=Hc.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Hc=a.use>1?{leafPaint:o,paint:i,boxBounds:Uc.set(s)}:null),(r||a.loading)&&(n={image:a,attrName:e,attrValue:i}),a.ready?(Gc(t,e,i,a,o,s),r&&(Kc(t,n),Zc(t,n))):a.error?r&&qc(t,n,a.error):(r&&(Jc(t,!0),Kc(t,n)),o.loadId=a.load(()=>{Jc(t,!1),t.destroyed||(Gc(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Zc(t,n)),o.loadId=void 0},e=>{Jc(t,!1),qc(t,n,e),o.loadId=void 0},i.lod&&a.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),o},checkImage:function(t,e,i,s,r){const{scaleX:o,scaleY:n}=kh.getImageRenderScaleData(t,i,s,r),a=t.film?t.nowIndex:o+"-"+n,{image:h,data:l,originPaint:d}=t,{exporting:c,snapshot:u}=r;return!(!l||t.patternId===a&&!c||u||(e&&(l.repeat?e=!1:d.changeful||t.film||"miniapp"===se.name||c||(e=se.image.isLarge(h,o,n)||h.width*o>8096||h.height*n>8096)),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),kh.drawImage(t,o,n,i,s,r),0):(!t.style||d.sync||c?kh.createPattern(t,i,s,r):kh.createPatternTask(t,i,s,r),1)))},drawImage:function(t,e,i,s,r,o){const{data:n,image:a,complex:h}=t;let{width:l,height:d}=a;if(h){const{blendMode:o,opacity:c}=t.originPaint,{transform:u}=n;r.save(),2===h&&r.clipUI(s),o&&(r.blendMode=o),c&&(r.opacity*=c),u&&r.transform(u),a.render(r,0,0,l,d,s,t,e,i),r.restore()}else n.scaleX&&(l*=n.scaleX,d*=n.scaleY),a.render(r,0,0,l,d,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const r=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:o}=t;if(i){const{pixelRatio:t}=i;r.scaleX*=t,r.scaleY*=t}return o&&o.scaleX&&(r.scaleX*=Math.abs(o.scaleX),r.scaleY*=Math.abs(o.scaleY)),r},recycleImage:function(t,e){const i=e["_"+t];if(v(i)){let s,r,o,n,a;for(let h=0,l=i.length;h<l;h++)s=i[h],r=s.image,a=r&&r.url,a&&(o||(o={}),o[a]=!0,no.recyclePaint(s),e.__willDestroy&&r.parent&&kh.recycleFilter(r,e.__leaf),r.loading&&(n||(n=e.__input&&e.__input[t]||[],v(n)||(n=[n])),r.unload(i[h].loadId,!n.some(t=>t.url===a))));return o}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=no.patternTasker.add(()=>tc(this,void 0,void 0,function*(){kh.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,i,s){let{scaleX:r,scaleY:o}=kh.getImageRenderScaleData(t,e,i,s),n=t.film?t.nowIndex:r+"-"+o;if(t.patternId!==n&&!e.destroyed&&(!se.image.isLarge(t.image,r,o)||t.data.repeat)){const{image:i,data:s}=t,{opacity:a}=t.originPaint,{transform:h,gap:l}=s,d=kh.getPatternFixScale(t,r,o);let c,u,p,{width:g,height:_}=i;d&&(r*=d,o*=d),g*=r,_*=o,l&&(u=l.x*r/xu(s.scaleX||1),p=l.y*o/xu(s.scaleY||1)),(h||1!==r||1!==o)&&(r*=wu(g+(u||0)),o*=wu(_+(p||0)),c=mu(),h&&vu(c,h),yu(c,1/r,1/o));const f=i.getCanvas(g,_,a,void 0,u,p,e.leafer&&e.leafer.config.smooth,s.interlace);t.style=i.getPattern(f,s.repeat||se.origin.noRepeat||"no-repeat",c,t),t.patternId=n}},getPatternFixScale:function(t,e,i){const{image:s}=t;let r,o=se.image.maxPatternSize,n=s.width*s.height;return s.isSVG?e>1&&(r=Math.ceil(e)/e):o>n&&(o=n),(n*=e*i)>o&&(r=Math.sqrt(o/n)),r},createData:function(t,e,i,s){t.data=kh.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=eu.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:r}=i,{mode:o,align:n,offset:a,scale:h,size:l,rotation:d,skew:c,clipSize:u,repeat:p,gap:g,interlace:_}=t,m=e.width===s&&e.height===r,v={mode:o},x="center"!==n&&(d||0)%180==90;let b,k;switch(jt.set(su,0,0,x?r:s,x?s:r),o&&"cover"!==o&&"fit"!==o?((h||l)&&(X.getScaleData(h,l,i,iu),b=iu.scaleX,k=iu.scaleY),(n||g||p)&&(b&&jt.scale(su,b,k,!0),n&&Mt.toPoint(n,su,e,su,!0,!0))):m&&!d||(b=k=jt.getFitScale(e,su,"fit"!==o),jt.put(e,i,n,b,!1,su),jt.scale(su,b,k,!0)),a&&_t.move(su,a),o){case"stretch":m?b&&(b=k=void 0):(b=e.width/s,k=e.height/r,kh.stretchMode(v,e,b,k));break;case"normal":case"clip":if(su.x||su.y||b||u||d||c){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),kh.clipMode(v,e,su.x,su.y,b,k,d,c,t,i),t&&(b=b?b*t:t,k=k?k*i:i)}break;case"repeat":(!m||b||d||c)&&kh.repeatMode(v,e,s,r,su.x,su.y,b,k,d,c,n,t.freeTransform),p||(v.repeat="repeat");const i=w(p);(g||i)&&(v.gap=function(t,e,i,s,r){let o,n;return w(t)?(o=t.x,n=t.y):o=n=t,{x:ru(o,i,r.width,e&&e.x),y:ru(n,s,r.height,e&&e.y)}}(g,i&&p,su.width,su.height,e));break;default:b&&kh.fillOrFitMode(v,e,su.x,su.y,b,k,d)}return v.transform||(e.x||e.y)&&tu(v.transform=Qc(),e.x,e.y),b&&(v.scaleX=b,v.scaleY=k),p&&(v.repeat=f(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),_&&(v.interlace=y(_)||"percent"===_.type?{type:"x",offset:_}:_),v},stretchMode:function(t,e,i,s){const r=au(),{x:o,y:n}=e;o||n?du(r,o,n):i>0&&s>0&&(r.onlyScale=!0),pu(r,i,s),t.transform=r},fillOrFitMode:function(t,e,i,s,r,o,n){const a=au();du(a,e.x+i,e.y+s),pu(a,r,o),n&&lu(a,{x:e.x+e.width/2,y:e.y+e.height/2},n),t.transform=a},clipMode:function(t,e,i,s,r,o,n,a,h,l){const d=au();fu(d,e,i,s,r,o,n,a),h&&(n||a?(hu(nu),cu(nu,e,h,l),uu(d,nu)):cu(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,r,o,n,a,h,l,d,c){const u=au();if(c)fu(u,e,r,o,n,a,h,l);else{if(h)if("center"===d)lu(u,{x:i/2,y:s/2},h);else switch(gu(u,h),h){case 90:du(u,s,0);break;case 180:du(u,i,s);break;case 270:du(u,0,i)}ou.x=e.x+r,ou.y=e.y+o,du(u,ou.x,ou.y),n&&cu(u,ou,n,a)}t.transform=u}},{toPoint:ku}=Bt,{hasTransparent:Eu}=vh,Su={},Bu={};function Tu(t,e,i,s){if(i){let r,o,n,a;for(let t=0,h=i.length;t<h;t++)r=i[t],f(r)?(n=t/(h-1),o=vh.string(r,s)):(n=r.offset,o=vh.string(r.color,s)),e.addColorStop(n,o),!a&&Eu(o)&&(a=!0);a&&(t.isTransparent=!0)}}var{getAngle:Cu,getDistance:Ou}=_t,{get:Ru,rotateOfOuter:Pu,scaleOfOuter:Lu}=st,{toPoint:Mu}=Bt,Du={},Au={};function Iu(t,e,i,s,r){let o;const{width:n,height:a}=t;if(n!==a||s){const t=Cu(e,i);o=Ru(),r?(Lu(o,e,n/a*(s||1),1),Pu(o,e,t+90)):(Lu(o,e,1,n/a*(s||1)),Pu(o,e,t))}return o}var{getDistance:Wu}=_t,{toPoint:zu}=Bt,Fu={},Yu={},Nu={linearGradient:function(t,e){let{from:i,to:s,type:r,opacity:o}=t;ku(i||"top",e,Su),ku(s||"bottom",e,Bu);const n=se.canvas.createLinearGradient(Su.x,Su.y,Bu.x,Bu.y),a={type:r,style:n};return Tu(a,n,t.stops,o),a},radialGradient:function(t,e){let{from:i,to:s,type:r,opacity:o,stretch:n}=t;Mu(i||"center",e,Du),Mu(s||"bottom",e,Au);const a=se.canvas.createRadialGradient(Du.x,Du.y,0,Du.x,Du.y,Ou(Du,Au)),h={type:r,style:a};Tu(h,a,t.stops,o);const l=Iu(e,Du,Au,n,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:r,opacity:o,rotation:n,stretch:a}=t;zu(i||"center",e,Fu),zu(s||"bottom",e,Yu);const h=se.conicGradientSupport?se.canvas.createConicGradient(n?n*V:0,Fu.x,Fu.y):se.canvas.createRadialGradient(Fu.x,Fu.y,0,Fu.x,Fu.y,Wu(Fu,Yu)),l={type:r,style:h};Tu(l,h,t.stops,o);const d=Iu(e,Fu,Yu,a||1,se.conicGradientRotate90);return d&&(l.transform=d),l},getTransform:Iu},{copy:Xu,move:Hu,toOffsetOutBounds:Vu}=jt,{max:Uu,abs:ju}=Math,Gu={},Ku=new bt,Zu={};function qu(t,e){let i,s,r,o,n=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,o=1.5*(t.blur||0),r=ju(t.spread||0),n=Uu(n,r+o-s),a=Uu(a,r+o+i),h=Uu(h,r+o+s),l=Uu(l,r+o-i)}),n===a&&a===h&&h===l?n:[n,a,h,l]}function $u(t,e,i){const{shapeBounds:s}=i;let r,o;se.fullImageShadow?(Xu(Gu,t.bounds),Hu(Gu,e.x-s.x,e.y-s.y),r=t.bounds,o=Gu):(r=s,o=e),t.copyWorld(i.canvas,r,o)}var Ju,{toOffsetOutBounds:Qu}=jt,tp={},ep={shadow:function(t,e,i){let s,r;const{__nowWorld:o}=t,{shadow:n}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=n.length-1;Vu(h,Zu,l),n.forEach((n,_)=>{let f=1;if(n.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}p.setWorldShadow(Zu.offsetX+(n.x||0)*c*f,Zu.offsetY+(n.y||0)*u*f,(n.blur||0)*c*f,vh.string(n.color)),r=Sh.getShadowTransform(t,p,i,n,Zu,f),r&&p.setTransform(r),$u(p,Zu,i),r&&p.resetTransform(),s=l,n.box&&(p.restore(),p.save(),a&&(p.copyWorld(p,l,o,"copy"),s=o),a?p.copyWorld(a,o,o,"destination-out"):p.copyWorld(i.canvas,d,h,"destination-out")),tn.copyCanvasByWorld(t,e,p,s,n.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,r;const{__nowWorld:o}=t,{innerShadow:n}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=n.length-1;Qu(h,tp,l),n.forEach((n,_)=>{let f=1;if(n.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}p.save(),p.setWorldShadow(tp.offsetX+(n.x||0)*c*f,tp.offsetY+(n.y||0)*u*f,(n.blur||0)*c*f),r=Sh.getShadowTransform(t,p,i,n,tp,f,!0),r&&p.setTransform(r),$u(p,tp,i),p.restore(),a?(p.copyWorld(p,l,o,"copy"),p.copyWorld(a,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,d,h,"source-out"),s=l),p.fillWorld(s,vh.string(n.color),"source-in"),tn.copyCanvasByWorld(t,e,p,s,n.blendMode),g&&_<g&&p.clearWorld(s)}),p.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){},getShadowRenderSpread:qu,getShadowTransform:function(t,e,i,s,r,o,n){if(s.spread){const i=2*s.spread*o*(n?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return Ku.set().scaleOfOuter({x:(r.x+r.width/2)*e.pixelRatio,y:(r.y+r.height/2)*e.pixelRatio},1+i/a,1+i/h),Ku}},isTransformShadow(t){},getInnerShadowSpread:qu},{excludeRenderBounds:ip}=dn;function sp(t,e,i,s,r,o,n,a){switch(e){case"grayscale":Ju||(Ju=!0,r.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,r,o){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),o&&s.recycle(n),op(t,e,i,1,r,o)}(t,i,s,r,n,a);break;case"opacity-path":op(t,i,s,o,n,a);break;case"path":a&&i.restore()}}function rp(t){return t.getSameCanvas(!1,!0)}function op(t,e,i,s,r,o){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n,void 0,r),o?i.recycle(n):i.clearWorld(n)}Jh.prototype.__renderMask=function(t,e){let i,s,r,o,n,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){n&&(sp(this,n,t,r,s,o,void 0,!0),s=r=null),"clipping"!==a&&"clipping-path"!==a||ip(i,e)||i.__render(t,e),o=i.__.opacity,Ju=!1,"path"===a||"clipping-path"===a?(o<1?(n="opacity-path",r||(r=rp(t))):(n="path",t.save()),i.__clip(r||t,e)):(n="grayscale"===a?"grayscale":"alpha",s||(s=rp(t)),r||(r=rp(t)),i.__render(s,e));continue}const d=1===o&&i.__.__blendMode;d&&sp(this,n,t,r,s,o,void 0,!1),ip(i,e)||i.__render(r||t,e),d&&sp(this,n,t,r,s,o,d,!1)}sp(this,n,t,r,s,o,void 0,!0)};var np=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 ap(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}var hp,lp=ap("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),dp=ap("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),cp=ap(">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰"),up=ap(">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰_#~&*+\\=|≮≯≈≠=…"),pp=ap("- —/~|┆·");!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"}(hp||(hp={}));var{Letter:gp,Single:_p,Before:fp,After:mp,Symbol:yp,Break:vp}=hp;function wp(t){return lp[t]?gp:pp[t]?vp:dp[t]?fp:cp[t]?mp:up[t]?yp:np.test(t)?_p:gp}var xp={trimRight(t){const{words:e}=t;let i,s=0,r=e.length;for(let o=r-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(r-s,s)}};function bp(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}}var kp,Ep,Sp,Bp,Tp,Cp,Op,Rp,Pp,Lp,Mp,Dp,Ap,Ip,Wp,zp,Fp,{trimRight:Yp}=xp,{Letter:Np,Single:Xp,Before:Hp,After:Vp,Symbol:Up,Break:jp}=hp,Gp=[];function Kp(t,e){Pp&&!Rp&&(Rp=Pp),kp.data.push({char:t,width:e}),Sp+=e}function Zp(){Bp+=Sp,kp.width=Sp,Ep.words.push(kp),kp={data:[]},Sp=0}function qp(){Ip&&(Wp.paraNumber++,Ep.paraStart=!0,Ip=!1),Pp&&(Ep.startCharSize=Rp,Ep.endCharSize=Pp,Rp=0),Ep.width=Bp,zp.width?Yp(Ep):Fp&&$p(),Gp.push(Ep),Ep={words:[]},Bp=0}function $p(){Bp>(Wp.maxWidth||0)&&(Wp.maxWidth=Bp)}var{top:Jp,right:Qp,bottom:tg,left:eg}=et;function ig(t,e,i){const{bounds:s,rows:r}=t;s[e]+=i;for(let o=0;o<r.length;o++)r[o][e]+=i}Object.assign(yh,{getDrawData:function(t,e){f(t)||(t=String(t));let i=0,s=0,r=e.__getInput("width")||0,o=e.__getInput("height")||0;const{__padding:n}=e;n&&(r?(i=n[eg],r-=n[Qp]+n[eg],!r&&(r=.01)):e.autoSizeAlign||(i=n[eg]),o?(s=n[Jp],o-=n[Jp]+n[tg],!o&&(o=.01)):e.autoSizeAlign||(s=n[Jp]));const a={bounds:{x:i,y:s,width:r,height:o},rows:[],paraNumber:0,font:se.canvas.font=e.__font};return function(t,e,i){Wp=t,Gp=t.rows,Fp=!(zp=t.bounds).width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:r,textCase:o}=i,{canvas:n}=se,{width:a}=zp;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;Ip=!0,Mp=null,Rp=Op=Pp=Sp=Bp=0,kp={data:[]},Ep={words:[]};for(let i=0,l=(e=[...e]).length;i<l;i++)"\n"===(Cp=e[i])?(Sp&&Zp(),Ep.paraEnd=!0,qp(),Ip=!0):((Lp=wp(Cp))===Np&&"none"!==o&&(Cp=bp(Cp,o,!Sp)),Op=n.measureText(Cp).width,s&&(s<0&&(Pp=Op),Op+=s),Dp=Lp===Xp&&(Mp===Xp||Mp===Np)||Mp===Xp&&Lp!==Vp,Ap=!(Lp!==Hp&&Lp!==Xp||Mp!==Up&&Mp!==Vp),Tp=Ip&&r?a-r:a,t&&a&&Bp+Sp+Op>Tp&&(h?(Sp&&Zp(),Bp&&qp()):(Ap||(Ap=Lp===Np&&Mp==Vp),Dp||Ap||Lp===jp||Lp===Hp||Lp===Xp||Sp+Op>Tp?(Sp&&Zp(),Bp&&qp()):Bp&&qp()))," "===Cp&&!0!==Ip&&Bp+Sp===0||(Lp===jp?(" "===Cp&&Sp&&Zp(),Kp(Cp,Op),Zp()):Dp||Ap?(Sp&&Zp(),Kp(Cp,Op)):Kp(Cp,Op)),Mp=Lp);Sp&&Zp(),Bp&&qp(),Gp.length>0&&(Gp[Gp.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Wp.paraNumber++,Bp=n.measureText(t).width,Gp.push({x:r||0,text:t,width:Bp,paraStart:!0}),Fp&&$p()})}(a,t,e),n&&function(t,e,i,s,r){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ig(e,"x",t[eg]);break;case"right":ig(e,"x",-t[Qp])}if(!r&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ig(e,"y",t[Jp]);break;case"bottom":ig(e,"y",-t[tg])}}(n,a,e,r,o),function(t,e){const{rows:i,bounds:s}=t,r=i.length,{__lineHeight:o,__baseLine:n,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:p,y:g,width:_,height:f}=s,m=o*r+(c?c*(t.paraNumber-1):0),y=n;if(h&&m>f)m=Math.max(e.__autoHeight?m:f,o),r>1&&(t.overflow=r);else if(f||u)switch(d){case"middle":g+=(f-m)/2;break;case"bottom":g+=f-m}y+=g;let v,w,x,b=_||u?_:t.maxWidth;for(let k=0,E=r;k<E;k++){if(v=i[k],v.x=p,v.width<_||v.width>_&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&k>0&&(y+=c),v.y=y,y+=o,t.overflow>k&&y>m&&(v.isOverflow=!0,t.overflow=k+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&&_&&_<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(a,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:r,paraIndent:o,__letterSpacing:n}=e,a=i&&r.includes("both"),h=a||i&&r.includes("justify"),l=h&&r.includes("letter");let d,c,u,p,g,_,f,m,y,v;s.forEach(t=>{t.words&&(g=o&&t.paraStart?o:0,m=t.words.length,h&&(v=!t.paraEnd||a,c=i-t.width-g,l?p=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),_=n||t.isOverflow||l?0:u?1:2,t.isOverflow&&!n&&(t.textMode=!0),2===_?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===_?(f={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,f),(t.isOverflow||" "!==f.char)&&t.data.push(f)):d=function(t,e,i,s,r){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,r&&(e+=r)}),e}(e.data,d,t.data,t.isOverflow,v&&p),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):p&&(t.width+=p*(e.data.length-(y?1:0))))})),t.words=null)})}(a,e,r),a.overflow&&function(t,e,i,s){const{rows:r,overflow:o}=t;let{textOverflow:n}=e;if(o&&r.splice(o),s&&n&&"show"!==n){let t,a;"hide"===n?n="":"ellipsis"===n&&(n="...");const h=n?se.canvas.measureText(n).width:0,l=i+s-h;("none"===e.textWrap?r:[r[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<l));s--){if(a<l&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,e.data.push({char:n,x:a}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(a,e,i,r),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:r,textDecoration:o}=e;switch(t.decorationHeight=r/11,w(o)?(i=o.type,o.color&&(t.decorationColor=vh.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):i=o,i){case"under":t.decorationY=[.15*r+s];break;case"delete":t.decorationY=[.35*-r];break;case"under-delete":t.decorationY=[.15*r+s,.35*-r]}}(a,e),a}}),Object.assign(vh,{string:function(t,e){if(!t)return"#000";const i=y(e)&&e<1;if(f(t)){if(!i||!vh.object)return t;t=vh.object(t)}let s=g(t.a)?1:t.a;i&&(s*=e);const r=t.r+","+t.g+","+t.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}}),Object.assign(bh,Vc),Object.assign(kh,bu),Object.assign(Eh,Nu),Object.assign(Sh,ep),Object.assign(ge,{interaction:(t,e,i,s)=>new Bc(t,e,i,s),hitCanvas:(t,e)=>new ic(t,e),hitCanvasManager:()=>new Fd}),se.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const s=Jr.mimeType(e),r=t.toDataURL(s,i);return"image/bmp"===s?r.replace("image/png;","image/bmp;"):r},canvasToBolb:(t,e,i)=>new Promise(s=>t.toBlob(s,Jr.mimeType(e),i)),canvasSaveAs:(t,e,i)=>{const s=t.toDataURL(Jr.mimeType(Jr.fileType(e)),i);return se.origin.download(s,e)},download(t,e){return tc(this,void 0,void 0,function*(){let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i)})},loadImage:(t,e,i)=>new Promise((i,s)=>{const r=new se.origin.Image;e&&(r.setAttribute("crossOrigin",e),r.crossOrigin=e),r.onload=()=>{i(r)},r.onerror=t=>{s(t)},r.src=se.image.getRealURL(t)}),loadContent(t){return tc(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})},Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},se.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},se.canvas=ge.canvas(),se.conicGradientSupport=!!se.canvas.context.createConicGradient;var{M:sg,L:rg,C:og,Q:ng,Z:ag,N:hg,D:lg,X:dg,G:cg,F:ug,O:pg,P:gg,U:_g}=Ye,fg={scale(t,e,i){if(!t)return;let s,r=0,o=t.length;for(;r<o;)switch(s=t[r],s){case sg:case rg:mg(t,e,i,r,1),r+=3;break;case og:mg(t,e,i,r,3),r+=7;break;case ng:mg(t,e,i,r,2),r+=5;break;case ag:r+=1;break;case hg:mg(t,e,i,r,2),r+=5;break;case lg:mg(t,e,i,r,2),r+=9;break;case dg:mg(t,e,i,r,2),r+=6;break;case cg:mg(t,e,i,r,2),r+=9;break;case ug:mg(t,e,i,r,2),r+=5;break;case pg:t[r]=cg,t.splice(r+4,0,t[r+3],0),mg(t,e,i,r,2),r+=9,o+=2;break;case gg:t[r]=ug,t.splice(r+4,0,t[r+3]),mg(t,e,i,r,2),r+=5,o+=1;break;case _g:mg(t,e,i,r,2),r+=6}},scalePoints(t,e,i,s,r){for(let o=r?s+1:0,n=r?o+2*r:t.length;o<n;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:mg}=fg,yg=st.get(),{topLeft:vg,top:wg,topRight:xg,right:bg,bottom:kg,left:Eg}=it;function Sg(t,e,i){t.pathInputed?Tg(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function Bg(t,e,i,s){let r=e;if(!g(s)){const o=t.__layout;let{width:n,height:a}=o.boxBounds;switch(n*=i-e,a*=e-i,s){case wg:case kg:r=i,o.affectScaleOrRotation?t.moveInner(-n/2,0):t.x-=n/2;break;case Eg:case bg:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case vg:case xg:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=r;const o=t.__,{padding:n,lineHeight:a,letterSpacing:h}=o;n&&(t.padding=v(n)?n.map(t=>t*r):n*r),o.__autoWidth||(t.width*=r),o.__autoHeight||(t.height*=r),w(a)?"px"===a.type&&(o.lineHeight={type:"px",value:a.value*r}):a&&(o.lineHeight=a*r),w(h)?"px"===h.type&&(o.letterSpacing={type:"px",value:h.value*r}):h&&(o.letterSpacing=h*r)}function Tg(t,e,i){fg.scale(t.__.path,e,i),t.path=t.__.path}function Cg(t,e,i){const{points:s}=t;w(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):fg.scalePoints(s,e,i),t.points=s}function Og(t,e,i){const{children:s}=t;for(let r=0;r<s.length;r++)yg.a=e,yg.d=i,s[r].transform(yg,!0)}var Rg=ih.prototype;function Pg(t,e,i,s){var r,o=arguments.length,n=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(o<3?r(n):o>3?r(e,i,n):r(e,i))||n);return o>3&&n&&Object.defineProperty(e,i,n),n}function Lg(t){return t?v(t)?t:[t]:[]}Rg.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))},Rg.__scaleResize=function(t,e){Sg(this,t,e)},Rg.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},Rg.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},Hl.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,r=i&&i.editor,o=r&&r.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===r.mergedConfig.editSize)Bg(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:r,verticalAlign:o}=this.__,{boxBounds:n}=this.__layout;i&&"left"!==r&&1!==t&&(this.x+=n.x),s&&"top"!==o&&1!==e&&(this.y+=n.y),Sg(this,t,e)}},Vl.prototype.__scaleResize=function(t,e){Tg(this,t,e)},Al.prototype.__scaleResize=function(t,e){this.pathInputed?Tg(this,t,e):this.points?Cg(this,t,e):this.width*=t},wl.prototype.__scaleResize=function(t,e){this.pathInputed?Tg(this,t,e):this.points?Cg(this,t,e):Sg(this,t,e)},Jh.prototype.__scaleResize=function(t,e){Og(this,t,e)},al.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||Sg(this,t,e),i&&Og(this,t,e)},pe.add("resize");var Mg=class extends Rn{get list(){return Lg(this.value)}get oldList(){return Lg(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}};function Dg(t){return(e,i)=>{const s="_"+i;uo(e,i,{get(){return this[s]},set(e){const r=this[s];if(r!==e){const o=this;if(o.config){const t="target"===i;if(t){const{beforeSelect:t}=o.config;if(t){const i=t({target:e});if(w(i))e=i;else if(!1===i)return}o.hasDimOthers&&o.cancelDimOthers(),v(e)&&e.length>1&&e[0].locked&&e.splice(0,1),o.single&&(delete o.element.syncEventer,delete o.element.__world.ignorePixelSnap)}const s=t?Mg.BEFORE_SELECT:Mg.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new Mg(s,{editor:o,value:e,oldValue:r}))}this[s]=e,t(this,r)}}})}}Mg.BEFORE_SELECT="editor.before_select",Mg.SELECT="editor.select",Mg.AFTER_SELECT="editor.after_select",Mg.BEFORE_HOVER="editor.before_hover",Mg.HOVER="editor.hover";var{abs:Ag}=Math,{copy:Ig}=st,{setListWithFn:Wg}=jt,{worldBounds:zg}=dn,Fg={a:1,b:0,c:0,d:1,e:0,f:0},Yg={x:0,y:0,width:0,height:0},Ng=class extends qh{constructor(){super(),this.list=[],this.visible=0,this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){e&&this.set(e),this.target=t,this.update()}update(t){const{list:e}=this;e.length?(Wg(Yg,e,zg),t&&this.set(t),this.set(Yg),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const r=this.__,{stroke:o,strokeWidth:n,fill:a}=r,{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=Ag(d.scaleX),h=Ag(d.scaleY);if(Ig(Fg,d),Fg.half=n%2,t.setWorld(Fg,e.matrix),t.beginPath(),"path"===this.strokePathType||s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),r.strokeWidth=n/Math.max(i,h),r.shadow){const e=r.shadow[0],{scaleX:i,scaleY:s}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*s,e.blur*i,vh.string(e.color))}o&&(f(o)?bh.stroke(o,this,t,e):bh.strokes(o,this,t,e)),a&&(f(a)?bh.fill(a,this,t,e):bh.fills(a,this,t,e)),r.shadow&&t.restore()}}r.strokeWidth=n}}destroy(){this.target=null,super.destroy()}};Pg([Dg(function(t){const e=t.target;t.list=e?v(e)?e:[e]:[]})],Ng.prototype,"target",void 0),Pg([To("render-path")],Ng.prototype,"strokePathType",void 0);var Xg=class extends Jh{constructor(t){super(t),this.strokeArea=new el({strokeAlign:"center"}),this.fillArea=new el,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:r}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:r},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}},Hg={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return Vg([t],i,e),i}};function Vg(t,e,i){let s,r;for(let o=0,n=t.length;o<n;o++)if(s=t[o],r=s.__,r.hittable&&r.visible&&!r.locked&&i.hit(s.__world)){if(r.editable){if(s.isBranch&&!r.hitChildren){r.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)&&r.hitSelf&&e.push(s)}s.isBranch&&Vg(s.children,e,i)}}var{findOne:Ug,findByBounds:jg}=Hg,Gg=class extends Jh{get dragging(){return!!this.originList}get running(){const{editor:t,app:e}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector&&e&&"normal"===e.mode}get isMoveMode(){const{app:t}=this;return t&&t.interaction.moveMode}constructor(t){super(),this.hoverStroker=new Ng,this.targetStroker=new Ng,this.bounds=new qt,this.selectArea=new Xg,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{hoverTarget:e,mergeConfig:i}=t,s=Object.assign({},i);e&&e.editConfig&&Object.assign(s,e.editConfig);const{stroke:r,strokeWidth:o,hover:n,hoverStyle:a}=s;this.hoverStroker.setTarget(n?e:null,Object.assign({stroke:r,strokeWidth:o},a||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedPathType:i,selectedStyle:s}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2),strokePathType:i},s||{}))}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,selectKeep:s}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(s||(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,t.path.needUpdate=!0):this.allow(t.target)&&(this.isHoldMultipleSelectKey(t)||this.editor.mergedConfig.selectKeep||(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:r,y:o}=t.getInnerPoint(this);this.bounds.set(r,o),this.selectArea.setStyle({visible:!0,stroke:i,x:r,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(),r=new ph(jg(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),r.length){const t=[];this.originList.forEach(e=>{r.has(e)||t.push(e)}),r.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=0)}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)||this.isHoldMultipleSelectKey(t)&&!Ug(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new ph(this.editor.editBox.rect)};return Ug(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):Ug(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[Mg.HOVER,this.onHover,this],[Mg.SELECT,this.onSelect,this]]),e.on_([[cd.MOVE,this.onPointerMove,this],[cd.BEFORE_DOWN,this.onBeforeDown,this],[cd.TAP,this.onTap,this],[pd.START,this.onDragStart,this,!0],[pd.DRAG,this.onDrag,this],[pd.END,this.onDragEnd,this],[_d.MOVE,this.onAutoMove,this],[[vd.ZOOM,_d.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}},{topLeft:Kg,top:Zg,topRight:qg,right:$g,bottomRight:Jg,bottom:Qg,bottomLeft:t_,left:e_}=it,{toPoint:i_}=Bt,{within:s_,sign:r_}=X,{abs:o_}=Math,n_={getScaleData(t,e,i,s,r,o,n,a){let h,l,d={},c=1,u=1;const{boxBounds:p,widthRange:g,heightRange:_,dragBounds:f,worldBoxBounds:m}=t,{width:v,height:w}=e,x=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,k=r_(x),E=r_(b),S=a?x:k*p.width/v,B=a?b:E*p.height/w;if(y(s))c=u=Math.sqrt(s);else{o&&(s.x*=2,s.y*=2),s.x*=a?x:k,s.y*=a?b:E;const t=(-s.y+w)/w,e=(s.x+v)/v,n=(s.y+w)/w,d=(-s.x+v)/v;switch(i){case Zg:u=t,h="bottom";break;case $g:c=e,h="left";break;case Qg:u=n,h="top";break;case e_:c=d,h="right";break;case Kg:u=t,c=d,h="bottom-right";break;case qg:u=t,c=e,h="bottom-left";break;case Jg:u=n,c=e,h="top-left";break;case t_:u=n,c=d,h="top-right"}if(r)if("corner"===r&&i%2)r=!1;else switch(i){case Zg:case Qg:c=u;break;case e_:case $g:u=c;break;default:l=Math.sqrt(o_(c*u)),c=r_(c)*l,u=r_(u)*l}}const T=1!==c,C=1!==u;if(T&&(c/=S),C&&(u/=B),!n){const{worldTransform:e}=t;c<0&&(c=1/p.width/e.scaleX),u<0&&(u=1/p.height/e.scaleY)}if(i_(o||h,p,d,!0),f){const e={x:c,y:u};ld.limitScaleOf(t,d,e,r),c=e.x,u=e.y}if(T&&g){const e=p.width*t.scaleX;c=s_(e*c,g)/e}if(C&&_){const e=p.height*t.scaleY;u=s_(e*u,_)/e}return T&&o_(c*m.width)<1&&(c=r_(c)/m.width),C&&o_(u*m.height)<1&&(u=r_(u)/m.height),r&&c!==u&&(l=Math.min(o_(c),o_(u)),c=r_(c)*l,u=r_(u)*l),isFinite(c)||(c=1),isFinite(u)||(u=1),{origin:d,scaleX:c,scaleY:u,direction:i,lockRatio:r,around:o}},getRotateData(t,e,i,s,r){let o,n={};switch(e){case Kg:o="bottom-right";break;case qg:o="bottom-left";break;case Jg:o="top-left";break;case t_:o="top-right";break;default:o="center"}return i_(r||o,t.boxBounds,n,!0),{origin:n,rotation:_t.getRotation(s,t.getWorldPointByBox(n),i)}},getSkewData(t,e,i,s){let r,o,n={},a=0,h=0;switch(e){case Zg:case Kg:o={x:.5,y:0},r="bottom",a=1;break;case Qg:case Jg:o={x:.5,y:1},r="top",a=1;break;case e_:case t_:o={x:0,y:.5},r="right",h=1;break;case $g:case qg:o={x:1,y:.5},r="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,i_(s||r,t,n,!0);const c=_t.getRotation(o,n,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:n,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 e_:t=$g;break;case Kg:t=qg;break;case t_:t=Jg;break;case $g:t=e_;break;case qg:t=Kg;break;case Jg:t=t_}if(i)switch(t){case Zg:t=Qg;break;case Kg:t=t_;break;case qg:t=Jg;break;case Qg:t=Zg;break;case t_:t=Kg;break;case Jg:t=qg}return t}},a_={};function h_(t,e){const{enterPoint:i,dragging:s,skewing:r,resizing:o,flippedX:n,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return l_(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:p,moveable:g,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(g||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!_)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),w=s?r?p:o?c:u:v?p:y?c:u;h+=45*(n_.getFlipDirection(i.direction,n,a)+1),h=2*Math.round(X.formatRotation(h,!0)/2);const{url:x,x:b,y:k}=w,E=x+h;a_[E]?i.cursor=a_[E]:a_[E]=i.cursor={url:d_(x,h),x:b,y:k}}function l_(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function d_(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}var c_=class extends al{constructor(t){super(t),this.useFastShadow=!0}},u_=["top","right","bottom","left"],p_=void 0,g_=class extends Jh{get mergeConfig(){const{config:t}=this,{mergeConfig:e,editBox:i}=this.editor;return this.mergedConfig=t&&i!==this?Object.assign(Object.assign({},e),t):e}get target(){return this._target||this.editor.element}set target(t){this._target=t}get single(){return!!this._target||this.editor.single}get transformTool(){return this._transformTool||this.editor}set transformTool(t){this._transformTool=t}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}get canUse(){return this.app&&this.editor.editing}get canGesture(){if(!this.canUse)return!1;const{moveable:t,resizeable:e,rotateable:i}=this.mergeConfig;return f(t)||f(e)||f(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(t){super(),this.view=new Jh,this.rect=new c_({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new c_({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new Jh({around:"center",hitSelf:!1,visible:0}),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:r,rotatePoints:o,resizeLines:n,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let c=0;c<8;c++)t=new c_({name:"rotate-point",around:d[c],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",c),c%2&&(e=new c_({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),n.push(e),this.listenPointEvents(e,"resize",c)),i=new c_({name:"resize-point",hitRadius:5}),r.push(i),this.listenPointEvents(i,"resize",c);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...o,a,h,l,...n,...r),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:r,resizePoints:o,resizeLines:n}=this,{stroke:a,strokeWidth:h,ignorePixelSnap:l}=e,d=this.getPointsStyle(),c=this.getMiddlePointsStyle(),u=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let _=0;_<8;_++)p=o[_],p.set(this.getPointStyle(_%2?c[(_-1)/2%c.length]:d[_/2%d.length])),p.rotation=(_-(_%2?1:0))/2*90,_%2&&n[(_-1)/2].set(Object.assign({pointType:"resize",rotation:(_-1)/2*90},u[(_-1)/2%u.length]||{}));r.set(this.getPointStyle(e.circle||e.rotatePoint||d[0])),s.set(Object.assign({stroke:a,strokeWidth:h,opacity:1,editConfig:p_},e.rect||{}));const g=_(e.rectThrough)?i:e.rectThrough;s.hittable=!g,g&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&E.stintSet(t.__world,"ignorePixelSnap",l),l_(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:r,rotation:o,skewX:n,skewY:a,width:h,height:l}=this.target.getLayoutBounds("box",t,!0);this.visible=!this.target.locked,this.set({x:e,y:i,scaleX:s,scaleY:r,rotation:o,skewX:n,skewY:a}),this.updateBounds({x:0,y:0,width:h,height:l})}unload(){this.visible=!1,this.app&&(this.rect.syncEventer=this.app.interaction.bottomList=null)}updateBounds(t){const{editor:e,mergeConfig:i,single:s,rect:r,circle:o,buttons:n,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{editMask:d}=e,{middlePoint:c,resizeable:u,rotateable:p,hideOnSmall:_,editBox:f,mask:m,dimOthers:v,bright:w,spread:x,hideRotatePoints:b,hideResizeLines:k}=i;if(d.visible=!!m||0,g(v)&&g(w)?e.hasDimOthers&&e.cancelDimOthers():(e.setDimOthers(v),e.setBright(!!v||w),e.hasDimOthers=!0),x&&jt.spread(t,x),this.view.worldOpacity){const{width:e,height:d}=t,g=y(_)?_:10,m=f&&!(_&&e<g&&d<g);let v,w,x,E={};for(let i=0;i<8;i++)Bt.toPoint(Bt.directionData[i],t,E),w=a[i],v=h[i],w.set(E),v.set(E),w.visible=m&&!(!u&&!p),v.visible=m&&p&&u&&!b,i%2&&(x=l[(i-1)/2],x.set(E),x.visible=w.visible&&!k,w.visible&&(w.visible=!!c),v.visible&&(v.visible=!!c),(i+1)/2%2?(x.width=e+x.height,_&&2*w.width>e&&(w.visible=!1)):(x.width=d+x.height,_&&2*w.width>d&&(w.visible=!1)));o.visible=m&&p&&!(!i.circle&&!i.rotatePoint),o.visible&&this.layoutCircle(),r.path&&(r.path=null),r.set(Object.assign(Object.assign({},t),{visible:!s||f})),n.visible=m&&n.children.length>0||0,n.visible&&this.layoutButtons()}else r.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:r}=this.mergedConfig,o=u_.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,o,e||i,!!r)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:r}=this.mergedConfig,{flippedX:o,flippedY:n}=this;let a=u_.indexOf(e);(a%2&&o||(a+1)%2&&n)&&i&&(a=(a+2)%4);const h=i?n_.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!r),i&&(t.rotation=90*(h-a)),t.scaleX=o?-1:1,t.scaleY=n?-1:1}setButtonPosition(t,e,i,s){const r=this.resizePoints[2*e+1],o=e%2,n=e&&3!==e?1:-1,a=(i+(e%2?(s?r.width:0)+t.boxBounds.width:(s?r.height:0)+t.boxBounds.height)/2)*n;o?(t.x=r.x+a,t.y=r.y):(t.x=r.x,t.y=r.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:r,pointRadius:o}=this.mergedConfig,n={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:r,height:r,cornerRadius:o,offsetX:0,offsetY:0,editConfig:p_};return t?Object.assign(n,t):n}getPointsStyle(){const{point:t}=this.mergedConfig;return v(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return v(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return v(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:r,rotateable:o,skewable:n,onCopy:a}=this.mergeConfig;"move"===i?(t.altKey&&a&&a()&&this.editor.single&&this.app.interaction.replaceDownTarget(this.target),s&&(this.moving=!0)):(i.includes("rotate")||this.isHoldRotateKey(t)||!r?(o&&(this.rotating=!0),"resize-rotate"===i?r&&(this.resizing=!0):"resize-line"===e.name&&(n&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&r&&(this.resizing=!0),"skew"===i&&n&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:r,skewing:o}=this;if(i)e.onMove(t);else if(s||r||o){const i=t.current;i.pointType&&(this.enterPoint=i),r&&e.onRotate(t),s&&e.onScale(t),o&&e.onSkew(t)}h_(this,t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){(this.moving||this.gesturing)&&(this.editor.opacity=this.mergedConfig.hideOnMove?0:1),this.resizing&&(Xn.resizingKeys=this.editor.leafList.keys);const{dragStartData:e,target:i}=this;e.x=t.x,e.y=t.y,e.totalOffset={x:0,y:0},e.point={x:i.x,y:i.y},e.bounds=Object.assign({},i.getLayoutBounds("box","local")),e.rotation=i.rotation}onTransformEnd(t){this.canDragLimitAnimate&&(t instanceof pd||t instanceof _d)&&this.transformTool.onMove(t),this.resizing&&(Xn.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(t){if(this.canGesture&&"drag"!==t.moveType&&(t.stop(),f(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,t.type){case _d.START:this.onTransformStart(t);break;case _d.END:this.onTransformEnd(t);break;default:this.transformTool.onMove(t)}}onScale(t){if(this.canGesture&&(t.stop(),f(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,t.type){case vd.START:this.onTransformStart(t);break;case vd.END:this.onTransformEnd(t);break;default:this.transformTool.onScale(t)}}onRotate(t){if(this.canGesture&&(t.stop(),f(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,t.type){case vd.START:this.onTransformStart(t);break;case vd.END:this.onTransformEnd(t);break;default:this.transformTool.onRotate(t)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){h_(this,t)}onArrow(t){if(this.canUse){let e=0,i=0;switch(t.code){case"ArrowDown":i=1;break;case"ArrowUp":i=-1;break;case"ArrowLeft":e=-1;break;case"ArrowRight":e=1}if(e||i){const{keyEvent:s,arrowStep:r,arrowFastStep:o}=this.mergeConfig;if(s){const s=t.shiftKey?o:r;this.transformTool.move(e*s,i*s)}}}}onDoubleTap(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"double"!==e||i||this.openInner(t)}onLongPress(t){const{openInner:e,preventEditInner:i}=this.mergeConfig;"long"===e&&i&&this.openInner(t)}openInner(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof Hl)||t.find(t=>t instanceof Hl);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[pd.START,this.onDragStart,this],[pd.DRAG,this.onDrag,this],[pd.END,this.onDragEnd,this],[cd.ENTER,e=>{this.enterPoint=t,h_(this,e)}],[cd.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[cd.DOUBLE_TAP,this.onDoubleTap,this],[cd.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[wd.HOLD,wd.UP],this.onKey,this],[wd.DOWN,this.onArrow,this],[[_d.START,_d.BEFORE_MOVE,_d.END],this.onMove,this,!0],[[vd.START,vd.BEFORE_ZOOM,vd.END],this.onScale,this,!0],[[md.START,md.BEFORE_ROTATE,md.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}},__={x:0,y:0,width:1e5,height:1e5},f_=class extends qh{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,__),Object.assign(this.__world,__)}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergedConfig;if(s&&i.editing){if(t.fillWorld(t.bounds,!0===s?"rgba(0,0,0,0.8)":s),e.bounds&&!e.bounds.hit(i.editBox.rect.__world,e.matrix))return;t.saveBlendMode("destination-out"),e=Object.assign(Object.assign({},e),{shape:!0}),i.list.forEach(i=>{i.__render(t,e);const{parent:s}=i;s&&s.textBox&&s.__renderShape(t,e)}),t.restoreBlendMode()}}destroy(){this.editor=null,super.destroy()}},m_='\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"/>',y_={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,arrowStep:1,arrowFastStep:10,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${m_}\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${m_}\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${m_}\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},v_=new qt;function w_(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{v_.setListWithFn(i,t=>t.getBounds("box","page")),0===v_.width&&(v_.width=.1),0===v_.height&&(v_.height=.1),e.reset(v_.get())}),s.add(e)}var x_=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),b_=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),k_={group(t,e,i){t.sort(b_);const{app:s,parent:r}=t[0];let o;o=i&&i.add?i:new Jh(i),r.addAt(o,r.children.indexOf(t[0])),t.sort(x_);const n=new bt(e.worldTransform);return n.divideParent(r.scrollWorldTransform),o.setTransform(n),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(x_),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(b_),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},E_=ne.get("EditToolCreator");function S_(){return t=>{B_.register(t)}}var B_={list:{},register(t){const{tag:e}=t.prototype;T_[e]&&E_.repeat(e),T_[e]=t},get:(t,e)=>new T_[t](e)},{list:T_}=B_,C_=class extends Mg{constructor(t,e){super(t,e)}};C_.BEFORE_OPEN="innerEditor.before_open",C_.OPEN="innerEditor.open",C_.BEFORE_CLOSE="innerEditor.before_close",C_.CLOSE="innerEditor.close";var O_=class extends Mg{constructor(t,e){super(t,e)}};O_.BEFORE_GROUP="editor.before_group",O_.GROUP="editor.group",O_.BEFORE_UNGROUP="editor.before_ungroup",O_.UNGROUP="editor.ungroup",O_.BEFORE_OPEN="editor.before_open_group",O_.OPEN="editor.open_group",O_.BEFORE_CLOSE="editor.before_close_group",O_.CLOSE="editor.close_group";var{updateMatrix:R_}=tn,P_={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},L_="top-left",M_=class extends el{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.skipJSON=!0,this.on(Mn.CHANGE,e=>{if(this.checkChange&&P_[e.attrName]){const{attrName:i,newValue:s,oldValue:r}=e,o="s"===i[0]?(s||1)/(r||1):(s||0)-(r||0);this.canChange=!1;const n=this.__;n[i]=r,R_(this.parent),R_(this);const a=new bt(this.__world);switch(n[i]=s,this.__layout.rotationChange(),R_(this),this.changedTransform=new bt(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(L_,o);break;case"scaleX":t.scaleOf(L_,o,1);break;case"scaleY":t.scaleOf(L_,1,o);break;case"skewX":t.skewOf(L_,o,0);break;case"skewY":t.skewOf(L_,0,o)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}},D_=class extends Mg{constructor(t,e){super(t,e)}};D_.BEFORE_MOVE="editor.before_move",D_.MOVE="editor.move";var A_=class extends Mg{constructor(t,e){super(t,e)}};A_.BEFORE_SCALE="editor.before_scale",A_.SCALE="editor.scale";var I_=class extends Mg{constructor(t,e){super(t,e)}};I_.BEFORE_ROTATE="editor.before_rotate",I_.ROTATE="editor.rotate";var W_=class extends Mg{constructor(t,e){super(t,e)}};W_.BEFORE_SKEW="editor.before_skew",W_.SKEW="editor.skew";var z_=class extends Jh{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 dragPoint(){return this.editBox.dragPoint}get dragging(){return this.editBox.dragging}get gesturing(){return this.editBox.gesturing}get moving(){return this.editBox.moving}get resizing(){return this.editBox.resizing}get rotating(){return this.editBox.rotating}get skewing(){return this.editBox.skewing}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}get targetLeafer(){const t=this.list[0];return t&&t.leafer}constructor(t,e){super(e),this.leafList=new ph,this.openedGroupList=new ph,this.simulateTarget=new M_(this),this.editBox=new g_(this),this.editToolList={},this.selector=new Gg(this),this.editMask=new f_(this),this.targetEventIds=[];let i=E.clone(y_);t&&(i=E.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),pe.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}getItem(t){return this.list[t||0]}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)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?v(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>E.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}cancelDimOthers(){this.setDimOthers(!1),this.setBright(!1),this.hasDimOthers=void 0}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&&w_(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||B_.get(t,this)}updateEditTool(){if(this.unloadEditTool(),this.editing){const t=this.element;let e=t.editOuter||"EditTool";const{beforeEditOuter:i}=this.mergeConfig;if(i){const s=i({target:t,name:e});if(f(s))e=s;else if(!1===s)return}if(B_.list[e]){const t=this.editTool=this.getEditTool(e);this.editBox.load(),t.load(),this.update()}}}unloadEditTool(){let t=this.editTool;t&&(this.editBox.unload(),t.unload(),this.editTool=null)}getEditSize(t){return this.mergeConfig.editSize}onMove(t){}onScale(t){}onRotate(t){}onSkew(t){}move(t,e=0){}scaleWithDrag(t){}scaleOf(t,e,i=e,s){}flip(t){}rotateOf(t,e){}skewOf(t,e,i=0,s){}checkTransform(t){}getWorldOrigin(t){}getChangedTransform(t){}group(t){return this.multiple&&(this.emitGroupEvent(O_.BEFORE_GROUP),this.target=k_.group(this.list,this.element,t),this.emitGroupEvent(O_.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(O_.BEFORE_UNGROUP,t)),this.target=k_.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(O_.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(O_.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(O_.OPEN,t)}closeGroup(t){this.emitGroupEvent(O_.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(O_.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!tn.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 O_(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||B_.get(t,this)}openInnerEditor(t,e,i){let s;if(f(e)?s=e:i||(i=e),t&&i&&(this.target=t),this.single){t||(t=this.element),s||(s=t.editInner);const{beforeEditInner:e}=this.mergeConfig;if(e){const i=e({target:t,name:s});if(f(i))s=i;else if(!1===i)return}B_.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(C_.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(C_.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(C_.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(C_.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new C_(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&&(k_.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(k_.toBottom(this.list),this.leafList.update())}onAppRenderStart(t){(this.targetChanged=t.children.some(t=>t!==this.leafer&&t.renderer.changed))&&this.editBox.forceRender()}onRenderStart(){this.targetChanged&&this.update()}onChildScroll(){this.multiple&&this.updateEditBox()}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e,targetLeafer:i,editMask:s}=this;this.targetEventIds=[e.on_(Un.START,this.onRenderStart,this),i&&i.on_(Mn.SCROLL,this.onChildScroll,this),t.on_(Un.CHILD_START,this.onAppRenderStart,this),t.on_(jn.UPDATE_MODE,t=>{t.mode&&"normal"!==t.mode&&this.cancel()})],s.visible&&s.forceRender()}}removeTargetEvents(){const{targetEventIds:t,editMask:e}=this;t.length&&(this.off_(t),e.visible&&e.forceRender())}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())}};Pg([(t,e)=>{uo(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,editTool:r,innerEditor:o,app:n}=this,a=Object.assign({},t);if(o?o.editConfig&&Object.assign(a,o.editConfig):r&&r.editConfig&&Object.assign(a,r.editConfig),e&&e.editConfig){let{editConfig:t}=e;(t.hover||t.hoverStyle)&&(t=Object.assign({},t),delete t.hover,delete t.hoverStyle),Object.assign(a,t)}return s.config&&Object.assign(a,s.config),i&&(i.editConfig&&Object.assign(a,i.editConfig),"font-size"===a.editSize&&(a.lockRatio=!0),"resize-rotate"===i.pointType&&(a.around||(a.around="center"),_(a.lockRatio)&&(a.lockRatio=!0))),g(a.dragLimitAnimate)&&(a.dragLimitAnimate=n&&n.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],z_.prototype,"mergeConfig",void 0),Pg([Dg(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof ph?i:new ph(i),t.multiple&&w_(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new Mg(Mg.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new Mg(Mg.AFTER_SELECT,s))})],z_.prototype,"target",void 0),Pg([Dg(function(t,e){t.emitEvent(new Mg(Mg.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],z_.prototype,"hoverTarget",void 0),z_=Pg([Yo(class{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let r,{dragLimitAnimate:o}=i;const n=t.type===_d.END||t.type===pd.END,a=f(e.draggable),h=!o||n||a,l={x:t.totalX,y:t.totalY};t instanceof _d&&_t.move(l,e.getWorldPointByLocal(s.totalOffset,null,!0)),t.shiftKey&&(Math.abs(l.x)>Math.abs(l.y)?l.y=0:l.x=0),r=pd.getValidMove(e,s.point,l,h),(r.x||r.y)&&(o&&!a&&n?tn.animateMove(this,r,y(o)?o:.3):this.move(r))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:r}=this.editBox;let o,{around:n,lockRatio:a,flipable:h,editSize:l}=i;t instanceof vd?(n||(n=e.getBoxPoint(t)),o=t.totalScale):o=t.getInnerTotal(e);const{direction:d}=t.current;(t.shiftKey||e.lockRatio)&&(a=!0);const c=n_.getScaleData(e,r.bounds,d,o,a,n_.getAround(n,t.altKey),h,!s||"scale"===l),u=e.x,p=e.y;t instanceof pd&&this.editTool&&this.editTool.onScaleWithDrag?(c.drag=t,this.scaleWithDrag(c)):this.scaleOf(c.origin,c.scaleX,c.scaleY),_t.move(r.totalOffset,e.x-u,e.y-p)}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:r,rotateAround:o,rotateGap:n,diagonalRotateKey:a}=i,{direction:h}=t.current;let l,d;if(t instanceof md)d=t.rotation,l=o?Bt.getPoint(o,e.boxBounds):e.getBoxPoint(t);else{const i=a?t.isHoldKeys(a):t.shiftKey,n=n_.getRotateData(e,h,t,s,i?null:o||e.around||e.origin||r||"center");d=s.rotation+n.rotation-e.rotation,l=n.origin}if(d=X.float(X.getGapRotation(d,n,e.rotation),2),!d)return;const c=e.x,u=e.y;this.rotateOf(l,d),_t.move(s.totalOffset,e.x-c,e.y-u)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:r,skewX:o,skewY:n}=n_.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),n_.getAround(s,t.altKey));(o||n)&&this.skewOf(r,o,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;w(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:r,editor:o}=this.editBox,{beforeMove:n}=s;if(n){const s=n({target:i,x:t,y:e});if(w(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);r||i.safeChange(()=>i.move(t,e));const h={target:i,editor:o,moveX:a.x,moveY:a.y};this.emitEvent(new D_(D_.BEFORE_MOVE,h));const l=new D_(D_.MOVE,h);this.doMove(l),this.emitEvent(l)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{target:e,mergeConfig:i,editor:s}=this.editBox,{beforeScale:r}=i;if(r){const{origin:i,scaleX:s,scaleY:o,drag:n}=t;if(!1===r({target:e,drag:n,origin:i,scaleX:s,scaleY:o}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new A_(A_.BEFORE_SCALE,t));const o=new A_(A_.SCALE,t);this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:r,mergeConfig:o,single:n,editor:a}=this.editBox,{beforeScale:h}=o;if(h){const s=h({target:r,origin:t,scaleX:e,scaleY:i});if(w(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!n&&this.getChangedTransform(()=>r.safeChange(()=>r.scaleOf(t,e,i))),c={target:r,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new A_(A_.BEFORE_SCALE,c));const u=new A_(A_.SCALE,c);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,r=this.getWorldOrigin("center"),o=i?new bt(tn.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),n={target:e,editor:s,worldOrigin:r,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:o};this.emitEvent(new A_(A_.BEFORE_SCALE,n));const a=new A_(A_.SCALE,n);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:r,editor:o}=this.editBox,{beforeRotate:n}=s;if(n){const s=n({target:i,origin:t,rotation:e});if(y(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!r&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),l={target:i,editor:o,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new I_(I_.BEFORE_ROTATE,l));const d=new I_(I_.ROTATE,l);this.doRotate(d),this.emitEvent(d)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:r,mergeConfig:o,single:n,editor:a}=this.editBox,{beforeSkew:h}=o;if(h){const s=h({target:r,origin:t,skewX:e,skewY:i});if(w(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!n&&this.getChangedTransform(()=>r.safeChange(()=>r.skewOf(t,e,i))),c={target:r,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new W_(W_.BEFORE_SKEW,c));const u=new W_(W_.SKEW,c);this.doSkew(u),this.emitEvent(u)}doMove(t){this.editTool.onMove(t)}doScale(t){this.editTool.onScale(t)}doRotate(t){this.editTool.onRotate(t)}doSkew(t){this.editTool.onSkew(t)}checkTransform(t){const{target:e,mergeConfig:i}=this.editBox;return e&&!e.locked&&i[t]}getWorldOrigin(t){const{target:e}=this.editBox;return e.getWorldPoint(tn.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new bt(e.worldTransform);return t(),new bt(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}},["editBox","editTool","emitEvent"])],z_);var F_=class{static registerInnerEditor(){B_.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this._editBox||this.editor.editBox}set editBox(t){this._editBox=t}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new Jh,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&"focus"===this.mode&&(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)}},Y_=class extends F_{static registerEditTool(){B_.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:r,list:o}=s;r.lockLayout(),o.forEach(t=>{t.moveWorld(e,i)}),r.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:r,editor:o}=t,{app:n,list:a}=o;n.lockLayout(),a.forEach(t=>{const n="scale"!==o.getEditSize(t);s?t.transformWorld(s,n):t.scaleOfWorld(r,e,i,n)}),n.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:r}=t,{app:o,list:n}=r;o.lockLayout(),n.forEach(t=>{const o="scale"!==r.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)}),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:r,editor:o}=t,{app:n,list:a}=o;n.lockLayout(),a.forEach(t=>{const n="scale"!==o.getEditSize(t);s?t.transformWorld(s,n):t.skewOfWorld(r,e,i,n)}),n.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};Y_=Pg([S_()],Y_);var{left:N_,right:X_}=it,{move:H_,copy:V_,toNumberPoints:U_}=_t,j_=class extends Y_{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:r}=t,o=t.target,n=i===N_;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,n,r,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,n,r,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,n,r,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=U_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,r){const{x:o,y:n}=r;i?(H_(t,o,n),s&&H_(e,-o,-n)):(s&&H_(t,-o,-n),H_(e,o,n))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:r}=t,o=t.target;let n,a;if(o.pathInputed?n=this.getFromToByPath(o.__.path):o.points&&(n=this.getFromToByPoints(o.__.points)),n){const{from:i,to:a}=n;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),r.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),V_(s[7],i),V_(e[7],i),V_(s[3],a),V_(e[3],a)}for(let h=0;h<8;h++)h<4&&(i[h].visible=!1),a=h===N_||h===X_,s[h].visible=a,e[h].visible=!n&&a}};function G_(t){const{scroll:e,disabled:i}=t.app.config.move;return!e||i?"":!0===e?"free":e}function K_(t,e,i){(function(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&E.assign(i,e),E.assign(t.config,i,t.userConfig)})(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(_d.BEFORE_MOVE,e=>{const i=t.getValidMove(e.moveX,e.moveY,!1);if(G_(t).includes("limit")){const s=t.getValidMove(0,0);if(s.x||s.y){const t=100,r=200,o="drag"===e.moveType?.3:.05;Math.abs(s.x)>t?i.x=0:i.x*=o,Math.abs(s.y)>r?i.y=0:i.y*=o}}t.zoomLayer.move(i)}),t.on_(_d.DRAG_ANIMATE,()=>{const e=t.getValidMove(0,0);(e.x||e.y)&&t.interaction.stopDragAnimate()}),t.on_(_d.END,e=>{tn.animateMove(t.zoomLayer,t.getValidMove(e.moveX,e.moveY))}),t.on_(vd.BEFORE_ZOOM,e=>{const{zoomLayer:i,layouter:s}=t,r=t.getValidScale(e.scale);1!==r&&(s.stop(),tn.updateMatrix(t),i.scaleOfWorld(e,r),s.start())}))}j_=Pg([S_()],j_),pe.add("editor","resize"),ge.editor=function(t,e){const i=new z_(t);return e&&e.sky.add(e.editor=i),i},al.addAttr("textBox",!1,_o),qh.addAttr("editConfig",void 0,_o),qh.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),_o),qh.addAttr("editInner","PathEditor",_o),Jh.addAttr("editInner","",_o),Hl.addAttr("editInner","TextEditor",_o),qh.setEditConfig=function(t){this.changeAttr("editConfig",t)},qh.setEditOuter=function(t){this.changeAttr("editOuter",t)},qh.setEditInner=function(t){this.changeAttr("editInner",t)};var Z_=ne.get("LeaferTypeCreator"),q_={list:{},register(t,e){$_[t]&&Z_.repeat(t),$_[t]=e},run(t,e){const i=$_[t];i&&i(e)}},{list:$_,register:J_}=q_;J_("viewport",K_),J_("custom",function(t){K_(t,null,!0)}),J_("design",function(t){K_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),J_("document",function(t){K_(t,{zoom:{min:1},move:{scroll:"limit"}})});var Q_,tf,ef,sf,rf={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=_t.getCenter(e.from,i.from),r=_t.getCenter(e.to,i.to),o={x:r.x-s.x,y:r.y-s.y},n=_t.getDistance(e.from,i.from);return{move:o,scale:_t.getDistance(e.to,i.to)/n,rotation:_t.getRotation(e.from,i.from,e.to,i.to),center:r}},getType(t,e){const i=Math.hypot(t.move.x,t.move.y)/(e.move||5),s=Math.abs(t.scale-1)/(e.scale||.03),r=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&r<1?"none":i>=s&&i>=r?"move":s>=r?"zoom":"rotate"},detect(t,e){const{state:i}=of,s=of.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),of.add(t,i.totalData),i.totalData=t,s===i.type){if(i.typeCount++,i.typeCount>=(e.count||3)&&"none"!==s)return s}else i.type=s,i.typeCount=1;return Date.now()-i.startTime>=(e.time||160)?of.getType(i.totalData,e):"none"},add(t,e){e&&(_t.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=of;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},of=rf,{abs:nf,max:af}=Math,{sign:hf,within:lf}=X,df={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:r}=t;t.shiftKey&&!s&&(s=r,r=0);const o=nf(s),n=nf(r);return o>50&&(s=af(50,o/3)*hf(s)),n>50&&(r=af(50,n/3)*hf(r)),{x:-s*i*2,y:-r*i*2}},getScale(t,e){let i,s=1,{zoomMode:r,zoomSpeed:o}=e;const n=t.deltaY||t.deltaX;if(r?(i="mouse"===r||!t.deltaX&&(se.intWheelDeltaY?Math.abs(n)>17:Math.ceil(n)!==n),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){o=lf(o,0,1);const i=t.deltaY?e.delta.y:e.delta.x,r=lf(1-nf(n)/(4*i)*o,.5,2);s=n>0?r:1/r}return s}},cf=class{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),Q_=0,tf=0,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0,totalX:Q_,totalY:tf}),e.emit(_d.START,this.moveData)),t.path=this.moveData.path,t.totalX=Q_+=t.moveX,t.totalY=tf+=t.moveY,e.emit(_d.BEFORE_MOVE,t),e.emit(_d.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),ef=1,this.zoomData=Object.assign(Object.assign({},t),{scale:1,totalScale:ef}),e.emit(vd.START,this.zoomData)),t.path=this.zoomData.path,t.totalScale=ef*=t.scale,e.emit(vd.BEFORE_ZOOM,t),e.emit(vd.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),sf=0,this.rotateData=Object.assign(Object.assign({},t),{rotation:0,totalRotation:sf}),e.emit(md.START,this.rotateData)),t.path=this.rotateData.path,t.totalRotation=sf+=t.rotation,e.emit(md.BEFORE_ROTATE,t),e.emit(md.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(_d.END,Object.assign(Object.assign({},e),{totalX:Q_,totalY:tf})),i&&t.emit(vd.END,Object.assign(Object.assign({},i),{totalScale:ef})),s&&t.emit(md.END,Object.assign(Object.assign({},s),{totalRotation:sf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}},uf=tl.prototype,pf=new qt,gf=new xt;function _f(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function ff(t,e){return Object.assign(Object.assign({},e),{scale:t})}uf.initType=function(t){q_.run(t,this)},uf.getValidMove=function(t,e,i=!0){const{disabled:s,scrollSpread:r}=this.app.config.move;gf.set(t,e);const o=G_(this);return o&&(o.includes("x")?gf.y=0:o.includes("y")?gf.x=0:Math.abs(gf.x)>Math.abs(gf.y)?gf.y=0:gf.x=0,i&&o.includes("limit")&&(pf.set(this.__world).addPoint(this.zoomLayer),r&&pf.spread(r),ld.getValidMove(pf,this.canvas.bounds,"auto",gf,!0),o.includes("x")?gf.y=0:o.includes("y")&&(gf.x=0))),{x:s?0:gf.x,y:s?0:gf.y}},uf.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:r}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),r?1:t};var mf=Wd.prototype;mf.createTransformer=function(){this.transformer=new cf(this)},mf.move=function(t){this.transformer.move(t)},mf.zoom=function(t){this.transformer.zoom(t)},mf.rotate=function(t){this.transformer.rotate(t)},mf.transformEnd=function(){this.transformer.transformEnd()},mf.wheel=function(t){const{wheel:e,pointer:i}=this.config,{posDeltaSpeed:s,negDeltaSpeed:r}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):r&&(t.deltaX*=r),t.deltaY>0?s&&(t.deltaY*=s):r&&(t.deltaY*=r);const o=e.getScale?e.getScale(t,e):df.getScale(t,e);if(1!==o)this.zoom(ff(o,t));else{const s=e.getMove?e.getMove(t,e):df.getMove(t,e);i.snap&&_t.round(s),this.move(_f(s,t))}},mf.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let r=rf.getData(e),{moving:o,zooming:n,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(rf.detect(r,w(s)?s:{})){case"move":o=!0;break;case"zoom":n=!0;break;case"rotate":a=!0;break;default:return}rf.reset()}o||(r.center=rf.state.center)}else o=n=a=!0;var h,l;Object.assign(t,r.center),t.multiTouch=!0,a&&this.rotate((h=r.rotation,l=t,Object.assign(Object.assign({},l),{rotation:h}))),n&&this.zoom(ff(r.scale,t)),o&&this.move(_f(r.move,t))};var yf=Td.prototype,{abs:vf,min:wf,max:xf,hypot:bf}=Math;function kf(t,e){let i=1;const s="out"===e,r=Math.abs(t);if(r>1){for(;s?i<r:i<=r;)i*=2;s&&(i/=2)}else{for(;s?i>=r:i>r;)i/=2;s||(i*=2)}return i/t}yf.checkDragEndAnimate=function(t){const{interaction:e}=this,i=this.canAnimate&&this.moving&&e.m.dragAnimate;if(i){const s=y(i)?i:.95,r=.15,o=150;let n,a,h,l=0,d=0,c=0,u=0,p=3;const{dragDataList:g}=this,_=g.length;for(let t=_-1;t>=xf(_-3,0)&&(h=g[t],!(h.time&&Date.now()-h.time>100));t--)n=p--,l+=h.moveX*n,d+=h.moveY*n,u+=n,a=bf(h.moveX,h.moveY),a>c&&(c=a);if(u&&(l/=u,d/=u),c>8){const t=1.15+.4500000000000002*wf((c-8)/17,1);l*=t,d*=t}const f=xf(vf(l),vf(d));f>o&&(a=o/f,l*=a,d*=a);const m=()=>{if(l*=s,d*=s,t=Object.assign({},t),vf(l)<r&&vf(d)<r)return this.dragEndReal(t);_t.move(t,l,d),this.drag(t),this.animate(m),e.emit(_d.DRAG_ANIMATE,t)};this.animate(m)}return i},yf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},yf.stopAnimate=function(){this.animate(null,"off"),this.interaction.target.nextRender(()=>{this.dragData&&this.dragEndReal(this.dragData)})},yf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},yf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:r,dragOut:o}=e.m;if(!o||!s||!r)return;const n=e.shrinkCanvasBounds,{x:a,y:h}=n,l=jt.maxX(n),d=jt.maxY(n),c=t.x<a?r:l<t.x?-r:0,u=t.y<h?r:d<t.y?-r:0;let p=0,g=0;this.autoMoveTimer=setInterval(()=>{p+=c,g+=u,_t.move(i,c,u),_t.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:p,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},yf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},pe.add("viewport"),pe.add("view"),tl.prototype.zoom=function(t,e,i,s){let r;!function(t){return w(t)&&!v(t)}(e)?r=e:(r=e.padding,i=e.scroll,s=e.transition);const{zoomLayer:o}=this,n=this.canvas.bounds.clone().shrink(_(r)?30:r),a=new qt,h={x:n.x+n.width/2,y:n.y+n.height/2};let l;o.killAnimate();const{x:d,y:c,scaleX:u,scaleY:p}=o.__,{boxBounds:g}=o;if(f(t))switch(t){case"in":l=kf(u,"in");break;case"out":l=kf(u,"out");break;case"fit":t=g;break;case"fit-width":(t=new qt(g)).height=0;break;case"fit-height":(t=new qt(g)).width=0}else y(t)&&(l=t/u);if(l)l=this.getValidScale(l),o.scaleOfWorld(h,l,l,!1,s);else if(w(t)){const e={x:d,y:c,scaleX:u,scaleY:p},r=v(t);if(r||t.tag){const e=r?t:[t];a.setListWithFn(e,dn.worldBounds)}else{const e=function(t,e){let i,{x:s,y:r,width:o,height:n}=t;return n||(n=o*(e.height/e.width),i=!0),o||(o=n*(e.width/e.height),i=!0),i?{x:s,y:r,width:o,height:n}:t}(t,n);a.set(o.getWorldBounds(e))}const{width:h,height:g}=a;let _=n.x-a.x,f=n.y-a.y;return i?(_+=Math.max((n.width-h)/2,0),f+=Math.max((n.height-g)/2,0)):(l=this.getValidScale(Math.min(n.width/h,n.height/g)),_+=(n.width-h*l)/2,f+=(n.height-g*l)/2,_t.scaleOf(e,a,l),a.scaleOf(a,l),e.scaleX*=l,e.scaleY*=l),"x"===i?f=0:"y"===i&&(_=0),_t.move(e,_,f),a.move(_,f),o.set(e,s),a}return o.worldBoxBounds};var Ef=class{constructor(t){this.undoStack=[],this.redoStack=[],this.limit=50,void 0!==t&&t>0&&(this.limit=t)}executeCommand(t){t.execute(),this.undoStack.push(t),this.redoStack=[],this.undoStack.length>this.limit&&this.undoStack.shift()}undo(){if(this.canUndo()){const t=this.undoStack.pop();t&&(t.undo(),this.redoStack.push(t))}}redo(){if(this.canRedo()){const t=this.redoStack.pop();t&&(t.execute(),this.undoStack.push(t))}}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[]}},Sf=class{constructor(t,e,i,s,r){this.target=t,this.fromX=e,this.fromY=i,this.toX=s,this.toY=r}execute(){this.target.x=this.toX,this.target.y=this.toY}undo(){this.target.x=this.fromX,this.target.y=this.fromY}},Bf=class{constructor(t,e,i,s,r){this.target=t,this.fromWidth=e,this.fromHeight=i,this.toWidth=s,this.toHeight=r}execute(){this.target.width=this.toWidth,this.target.height=this.toHeight}undo(){this.target.width=this.fromWidth,this.target.height=this.fromHeight}},Tf=class{constructor(t,e){this.parent=t,this.element=e}execute(){this.parent.add(this.element)}undo(){this.parent.remove(this.element)}},Cf=class{constructor(t,e,i){this.parent=t,this.element=e,this.index=i}execute(){this.parent.remove(this.element)}undo(){this.parent.add(this.element)}},Of=class{constructor(t){this.commands=t}execute(){this.commands.forEach(t=>t.execute())}undo(){for(let t=this.commands.length-1;t>=0;t--)this.commands[t].undo()}},Rf=["Shift","Meta","Alt","Control"],Pf="object"==typeof navigator?navigator.platform:"",Lf=/Mac|iPod|iPhone|iPad/.test(Pf)?"Meta":"Control",Mf="Win32"===Pf?["Control","Alt"]:["Alt"];function Df(t){let e=t.target;return t.repeat||t.isComposing||e!==t.currentTarget&&e.matches("[contenteditable],input,select,textarea")}function Af(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||Mf.includes(e)&&t.getModifierState("AltGraph"))}function If(t,[e,i,s]){const r=e.includes("AltGraph");return!((s instanceof RegExp?!s.test(t.key)&&!s.test(t.code):s.toUpperCase()!==t.key.toUpperCase()&&s!==t.code)||e.find(e=>!Af(t,e))||Rf.find(o=>!e.includes(o)&&!i.includes(o)&&s!==o&&Af(t,o)&&!(r&&Mf.includes(o))))}function Wf(t,e,i={}){let s=i.event??"keydown",r=function(t,e={}){let i=e.timeout??1e3,s=e.ignore??Df,r=Object.keys(t).map(e=>{return[e,(i=e,i.trim().split(" ").map(t=>{let e=t.split(/(?<=\w|\])\+/),i=e.pop(),s=i.match(/^\((.+)\)$/),r=s?new RegExp(`^(?:${s[1]})$`,"iv"):i,o=[],n=[];for(const a of e){let t=a.match(/^\[(.*)\]$/),e=t?.[1]??a;e="$mod"===e?Lf:e,t?n.push(e):o.push(e)}return[o,n,r]})),t[e]];var i}),o=/* @__PURE__ */new Map,n=null;return t=>{if(!function(t){return!!(t.key&&t.code&&t.getModifierState)}(t)||s(t))return;let e=[];for(let[i,s,n]of r){let r=o.get(i),[a,...h]=r||s;if(If(t,a)){if(h.length>0)o.set(i,h),e.push(i);else if(o.delete(i),!e.length){n(t);break}}else Af(t,t.key)||o.delete(i)}n&&clearTimeout(n),n=setTimeout(()=>o.clear(),i)}}(e,i);return t.addEventListener(s,r,i.capture),()=>{t.removeEventListener(s,r,i.capture)}}var zf={key:0,class:"loading-overlay",style:{}},Ff={key:1,class:"error-overlay"},Yf={class:"zoom-controller"},Nf={key:0,class:"hotkey-hint"},Xf={key:0,class:"hotkey-hint"},Hf={key:0,class:"hotkey-hint"},Vf={class:"toolbar"},Uf={key:0,class:"hotkey-hint"},jf={key:0,class:"hotkey-hint"},Gf={key:0,class:"hotkey-hint"},Kf={key:0,class:"hotkey-hint"},Zf={key:0,class:"hotkey-hint"},qf=/* @__PURE__ */r({__name:"RoiEditor",props:{imageSource:{type:Object,required:!0},options:{type:Object,default:()=>({})}},emits:["roiChange","loadStart","loadSuccess","loadError","undoStateChange","redoStateChange"],setup(r,{expose:u,emit:p}){const g=r,_=p,f=d(void 0),m=d("idle"),y=d(null),v=d(null);let w=null,x=null;const b=new Jh({name:"contentLayer"}),k=d({x:0,y:0}),E=d(!1),S=d(!1),B=d(!1),T=d("rectangle"),C=d(100),O=d(!1),R=d(0),P=d(0);let L,M=null,D=null,A=null;const I=t=>{L.executeCommand(t)},W=()=>{L=new Ef(g.options.maxUndoSteps??100),w=new Gl({view:f.value,width:f.value?.clientWidth||800,height:f.value?.clientHeight||600,fill:"#e3e3e3",zoom:{min:.2,max:4},editor:{rotateable:!1,middlePoint:{},selectedStyle:{...g.options.selectedRegionStyle}},tree:{type:"design"}}),w?.tree.add(b),w&&(w.on(cd.DOWN,H),w.on(cd.MOVE,V),w.on(cd.UP,U),w.on(pd.START,t=>{const e=t.target;e instanceof el&&e.parent===b&&(D={target:e,fromX:e.x||0,fromY:e.y||0,toX:e.x||0,toY:e.y||0})}),w.on(pd.DRAG,t=>{D&&(D.toX=t.target.x||0,D.toY=t.target.y||0)}),w.on(pd.END,()=>{if(D){const t=D.target;D.fromX===D.toX&&D.fromY===D.toY||(I(new Sf(t,D.fromX,D.fromY,D.toX,D.toY)),_("roiChange",F())),D=null}}),w.on(vd.ZOOM,t=>{it()}),w.editor?.on(A_.BEFORE_SCALE,t=>{const e=t.target;e instanceof el&&e.parent===b&&(A||(A={target:e,fromWidth:e.width||0,fromHeight:e.height||0,toWidth:e.width||0,toHeight:e.height||0}))}),w.editor?.on(A_.SCALE,t=>{A&&(A.toWidth=t.target.width||0,A.toHeight=t.target.height||0)}),w.on(cd.UP,()=>{A&&function(){if(A){const t=A.target;A.fromWidth===A.toWidth&&A.fromHeight===A.toHeight||(I(new Bf(t,A.fromWidth,A.fromHeight,A.toWidth,A.toHeight)),_("roiChange",F())),A=null}}()}))};const z=async t=>{const e=t||g.imageSource.url;if(w&&e){x&&(b.clear(),x.destroy()),m.value="loading",_("loadStart"),y.value=null,v.value=null;try{const t=await(i=e,new Promise((t,e)=>{const s=new window.Image;s.onload=()=>{t({width:s.width,height:s.height})},s.onerror=e,s.src=i}));y.value=t.width,v.value=t.height,x=new Il({url:e,draggable:!1,editable:!1,lazy:!0,zIndex:-1,placeholderColor:"transparent"}),x.on(An.LOADED,function(){m.value="success",_("loadSuccess"),X()}),x.on(An.ERROR,function(t){m.value="error",_("loadError",t)}),b.add(x)}catch(s){m.value="error",_("loadError",s)}var i}},F=()=>{if(!b||!y.value||!v.value)return[];const t=[],e=y.value,i=v.value;return Array.from(b.children).forEach(s=>{if(!s.url){const r=s,o=r.id||`roi-${t.length}`,n=r.x||0,a=r.y||0,h=r.width||0,l=r.height||0,d=[{x:n,y:a},{x:n+h,y:a},{x:n+h,y:a+l},{x:n,y:a+l}],c=d.map(t=>({x:e>0?t.x/e:0,y:i>0?t.y/i:0}));t.push({id:o,x:n,y:a,width:h,height:l,points:d,normalized:{x:e>0?n/e:0,y:i>0?a/i:0,width:e>0?h/e:0,height:i>0?l/i:0,points:c}})}}),t},Y=()=>({id:g.imageSource.id,url:g.imageSource.url,width:y.value,height:v.value});a(()=>{o(()=>{W(),z(),window.addEventListener("keydown",G),window.addEventListener("mousemove",N);const t=Wf(window,{v:t=>{(E.value||S.value)&&(t.preventDefault(),Z())},m:t=>{(E.value||S.value)&&(t.preventDefault(),q())},"$mod+KeyZ":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),$())},"$mod+KeyY":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),J())},Delete:t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),st())},"$mod+Equal":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),tt())},"$mod+Minus":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),Q())},"$mod+0":t=>{(E.value||S.value)&&(t.preventDefault(),t.stopPropagation(),et())},Alt:t=>{(E.value||S.value)&&(t.preventDefault(),B.value=!B.value)}});window.__roiEditorHotkeysUnsubscribe=t})});const N=t=>{k.value={x:t.clientX,y:t.clientY}},X=()=>{if(!(w&&x&&y.value&&v.value))return;const t=w.width,e=w.height,i=y.value,s=v.value,r=t/i,o=e/s,n=Math.min(r,o,1),a=(t-i*Number(n.toFixed(2)))/2,h=(e-s*Number(n.toFixed(2)))/2;w.tree.scale=Number(n.toFixed(2)),w.tree.x=a,w.tree.y=h,it()},H=t=>{if("rectangle"!==T.value)return;if(t.ctrlKey||t.metaKey)return;if(t.target){if(t.target.parent===b&&!t.target.url)return;if(t.target.parent&&t.target.parent.parent===b&&!t.target.parent.url)return;if("resize"===t.target.pointType)return;if("rotate"===t.target.pointType)return}const e=b.getBoxPoint({x:t.x,y:t.y});j(e.x,e.y)&&(O.value=!0,R.value=e.x,P.value=e.y)},V=t=>{if(!O.value)return;const e=b.getBoxPoint({x:t.x,y:t.y}),i=e.x,s=e.y,r=Math.max(0,Math.min(i,y.value||0)),o=Math.max(0,Math.min(s,v.value||0)),n=Math.min(R.value,r),a=Math.min(P.value,o),h=Math.abs(r-R.value),l=Math.abs(o-P.value);M?(M.x=n,M.y=a,M.width=h,M.height=l):(M=new el({id:crypto.randomUUID(),x:n,y:a,width:h,height:l,stroke:"rgba(100, 149, 237, 0.8)",fill:"rgba(100, 149, 237, 0.3)",strokeWidth:2,draggable:!1,editable:!1,...g.options.regionStyle}),b.add(M))},U=()=>{if(O.value&&(O.value=!1,M)){const t=M.width||0,e=M.height||0;if(t<5||e<5)M.remove(),M=null;else{const t=g.options.maxRegions??20;if(F().length>=t)return alert(`已达到最大区域数量限制(${t}个)`),M.remove(),void(M=null);M.draggable=!0,M.editable=!0,M.dragBounds={x:0,y:0,width:y.value||0,height:v.value||0},I(new Tf(b,M)),_("roiChange",F()),M=null}}},j=(t,e)=>t>=0&&t<=(y.value||0)&&e>=0&&e<=(v.value||0),G=t=>{if("Space"===t.code&&K())return t.preventDefault(),!1},K=()=>{if(!f.value)return!1;const t=f.value.getBoundingClientRect();return k.value.x>=t.left&&k.value.x<=t.right&&k.value.y>=t.top&&k.value.y<=t.bottom};h(()=>{x&&(w?.tree.remove(x),x=null),w?.destroy(),w=null,window.removeEventListener("keydown",G),window.removeEventListener("mousemove",N),window.__roiEditorHotkeysUnsubscribe&&(window.__roiEditorHotkeysUnsubscribe(),delete window.__roiEditorHotkeysUnsubscribe)});const Z=()=>{T.value="select"},q=()=>{T.value="rectangle"},$=()=>{L.undo(),_("roiChange",F())},J=()=>{L.redo(),_("roiChange",F())},Q=()=>{w&&(w.tree.zoom("out"),it())},tt=()=>{w&&(w.tree.zoom("in"),it())},et=()=>{w&&(w.tree.zoom(1),it())},it=()=>{w&&w.tree&&void 0!==w.tree.scaleX&&(C.value=Math.round(100*w.tree.scaleX))},st=()=>{if(!w)return;const t=w.editor?.list||[];if(0===t.length)return;const e=t.filter(t=>t instanceof el&&t.parent===b);if(0===e.length)return;const i=[];e.forEach(t=>{const e=t.parent?.children.indexOf(t)??-1;t.remove();const s=new Cf(b,t,e);i.push(s)}),i.length>0&&I(new Of(i)),w&&w.editor&&w.editor.cancel(),_("roiChange",F())};return u({getROIAnnotations:F,getImageInfo:Y,exportCanvasJSON:()=>{const t={version:"1.0",canvas:{width:y.value,height:v.value,zoom:C.value/100},image:Y(),leaferJSON:w?.tree?.toJSON?.()||null,annotations:F(),exportedAt:/* @__PURE__ */(new Date).toISOString()};return JSON.stringify(t,null,2)},importCanvasJSON:async(t,e)=>{try{const s=JSON.parse(t);if(!s.leaferJSON)return!1;if(b){for(;b.children.length>0;)b.children[0].remove();if(s.leaferJSON&&s.leaferJSON.children){let t=null;const e=i=>{for(const s of i){if(s.url)return t=s,!0;if(s.children&&s.children.length>0&&e(s.children))return!0}return!1};if(e(s.leaferJSON.children),t)try{await z(t.url)}catch(i){y.value=t.width||s.canvas?.width||0,v.value=t.height||s.canvas?.height||0}const r=t=>{for(const e of t){if(e.url)continue;const t=JSON.parse(JSON.stringify(e));b.add(t),e.children&&e.children.length>0&&r(e.children)}};r(s.leaferJSON.children[0].children)}w?.tree.forceUpdate()}return e?.resetZoom&&s.canvas?.zoom&&(C.value=100*s.canvas.zoom,it()),_("roiChange",F()),!0}catch(i){return!1}},loadImage:z}),(r,o)=>(l(),e("div",{class:"roi-editor",onFocus:o[1]||(o[1]=t=>E.value=!0),onBlur:o[2]||(o[2]=t=>E.value=!1),onMouseenter:o[3]||(o[3]=t=>S.value=!0),onMouseleave:o[4]||(o[4]=t=>S.value=!1)},[i("div",{ref_key:"canvasContainer",ref:f,class:"canvas-container",tabindex:"0"},["loading"===m.value?(l(),e("div",zf,[...o[5]||(o[5]=[i("div",{class:"gradient-animation"},null,-1),i("div",{class:"loading-text"},"图片加载中",-1)])])):t("",!0),"error"===m.value?(l(),e("div",Ff,[o[6]||(o[6]=i("p",null,"加载失败",-1)),i("button",{onClick:o[0]||(o[0]=t=>z())},"重试")])):t("",!0),i("div",Yf,[i("button",{class:"zoom-button",title:"缩小 (Ctrl+-)",onClick:Q},[o[7]||(o[7]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)),B.value?(l(),e("span",Nf,"Ctrl+-")):t("",!0)]),i("div",{class:"zoom-value",onClick:et,title:"点击重置为100% (Ctrl+0)"},[s(c(C.value)+"% ",1),B.value?(l(),e("span",Xf,"Ctrl+0")):t("",!0)]),i("button",{class:"zoom-button",title:"放大 (Ctrl++)",onClick:tt},[o[8]||(o[8]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),i("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)),B.value?(l(),e("span",Hf,"Ctrl++")):t("",!0)])])],512),i("div",Vf,[i("button",{class:n(["tool-button",{active:"select"===T.value}]),title:"选择工具 (V)",onClick:Z},[o[9]||(o[9]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-mouse-pointer2-icon lucide-mouse-pointer-2"},[i("path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"})],-1)),B.value?(l(),e("span",Uf,"V")):t("",!0)],2),i("button",{class:n(["tool-button",{active:"rectangle"===T.value}]),title:"框选工具 (M)",onClick:q},[o[10]||(o[10]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"})],-1)),B.value?(l(),e("span",jf,"M")):t("",!0)],2),i("button",{class:"tool-button",title:"撤销 (Ctrl+Z)",onClick:$},[o[11]||(o[11]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M3 7v6h6"}),i("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)),B.value?(l(),e("span",Gf,"Ctrl+Z")):t("",!0)]),i("button",{class:"tool-button",title:"重做 (Ctrl+Y)",onClick:J},[o[12]||(o[12]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M21 7v6h-6"}),i("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)),B.value?(l(),e("span",Kf,"Ctrl+Y")):t("",!0)]),i("button",{class:"tool-button",title:"删除 (Delete)",onClick:st},[o[13]||(o[13]=i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[i("path",{d:"M3 6h18"}),i("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),i("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})],-1)),B.value?(l(),e("span",Zf,"Del")):t("",!0)])])],32))}}),$f=/* @__PURE__ */((t,e)=>{const i=t.__vccOpts||t;for(const[s,r]of e)i[s]=r;return i})(qf,[["__scopeId","data-v-9c4af5f9"]]);function Jf(t){t.component("RoiEditor",$f)}var Qf=$f;export{$f as RoiEditor,Qf as default,Jf as install};