@leafer/worker 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var LeaferUI=function(t){"use strict";var e,i;t.PathNodeHandleType=void 0,(e=t.PathNodeHandleType||(t.PathNodeHandleType={}))[e.none=1]="none",e[e.free=2]="free",e[e.mirrorAngle=3]="mirrorAngle",e[e.mirror=4]="mirror",t.Answer=void 0,(i=t.Answer||(t.Answer={}))[i.No=0]="No",i[i.Yes=1]="Yes",i[i.NoAndSkip=2]="NoAndSkip",i[i.YesAndSkip=3]="YesAndSkip";const s={};function n(t){return void 0===t}function o(t){return null==t}function r(t){return"string"==typeof t}const{isFinite:a}=Number;function h(t){return"number"==typeof t}const l=/^-?\d+(?:\.\d+)?$/;function d(t){return"string"==typeof t&&l.test(t)?+t:t}const{isArray:c}=Array;function u(t){return t&&"object"==typeof t}function g(t){return u(t)&&!c(t)}function p(t){return"{}"===JSON.stringify(t)}const _={default:(t,e)=>(f(e,t),f(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var o,r;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(o=t[n])||void 0===o?void 0:o.constructor)===Object)return f(t[n],e[n],i&&i[n]);i&&n in i?(null===(r=i[n])||void 0===r?void 0:r.constructor)===Object&&f(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{n(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:f}=_;class m{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(!n(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]=n(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(!n(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!n(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(c(t))for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let o in this)if("_"!==o[0]&&(t=this["_"+o],!n(t))){if("path"===o&&!this.__pathInputed)continue;e=s?s[o]:void 0,i[o]=n(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:o,f:r}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:o,f:r}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}const y={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=v;return e[t]?e[t]++:(e[t]=1,0)}},v=y;let w,x,b;const{max:E}=Math,S=[0,0,0,0],k={zero:[...S],tempFour:S,set:(t,e,i,s,n)=>(void 0===i&&(i=s=n=e),t[0]=e,t[1]=i,t[2]=s,t[3]=n,t),setTemp:(t,e,i,s)=>T(S,t,e,i,s),toTempAB(t,e,i){b=i?h(t)?e:t:[],h(t)?(w=P(t),x=e):h(e)?(w=t,x=P(e)):(w=t,x=e),4!==w.length&&(w=B(w)),4!==x.length&&(x=B(x))},get(t,e){let i;if(!h(t))switch(t.length){case 4:i=n(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]),!n(e))for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},max:(t,e,i)=>h(t)&&h(e)?E(t,e):(R(t,e,i),T(b,E(w[0],x[0]),E(w[1],x[1]),E(w[2],x[2]),E(w[3],x[3]))),add:(t,e,i)=>h(t)&&h(e)?t+e:(R(t,e,i),T(b,w[0]+x[0],w[1]+x[1],w[2]+x[2],w[3]+x[3])),swapAndScale(t,e,i,s){if(h(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[o,r,a,l]=4===t.length?t:B(t);return T(n,a*i,l*e,o*i,r*e)}},{set:T,get:B,setTemp:P,toTempAB:R}=k,{round:L,pow:C,max:O,floor:A,PI:D}=Math,M={within:(t,e,i)=>(u(e)&&(i=e.max,e=e.min),!n(e)&&t<e&&(t=e),!n(i)&&t>i&&(t=i),t),fourNumber:k.get,formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),M.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=n(e)?1e12:C(10,e);return-0===(t=L(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(h(e)?e:e.width||0)/i.width,n=(h(e)?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&M.assignScale(s,t);return s},assignScale(t,e){h(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>O(A(t),e)/t,randInt:I,randColor:t=>`rgba(${I(255)},${I(255)},${I(255)},${t||1})`};function I(t){return Math.round(Math.random()*t)}const F=D/180,W=2*D,z=D/2;function U(){return{x:0,y:0}}function H(){return{x:0,y:0,width:0,height:0}}function N(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:Y,cos:X,acos:V,sqrt:G}=Math,{float:j}=M,K={};function q(){return Object.assign(Object.assign(Object.assign({},{a:1,b:0,c:0,d:1,e:0,f:0}),{x:0,y:0,width:0,height:0}),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0})}const Z={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:q(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,o=0,r=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=o,t.f=r},get:N,getWorld:q,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){J.toInnerPoint(t,e,K),J.scaleOfInner(t,K,i,s)},scaleOfInner(t,e,i,s=i){J.translateInner(t,e.x,e.y),J.scale(t,i,s),J.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:o}=t,r=X(e*=F),a=Y(e);t.a=i*r-s*a,t.b=i*a+s*r,t.c=n*r-o*a,t.d=n*a+o*r},rotateOfOuter(t,e,i){J.toInnerPoint(t,e,K),J.rotateOfInner(t,K,i)},rotateOfInner(t,e,i){J.translateInner(t,e.x,e.y),J.rotate(t,i),J.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:o,d:r}=t;i&&(i*=F,t.a=s+o*i,t.b=n+r*i),e&&(e*=F,t.c=o+s*e,t.d=r+n*e)},skewOfOuter(t,e,i,s){J.toInnerPoint(t,e,K),J.skewOfInner(t,K,i,s)},skewOfInner(t,e,i,s=0){J.translateInner(t,e.x,e.y),J.skew(t,i,s),J.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:o,e:r,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*n+r,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,o){const{e:r,f:a}=t;if(i||(i=t),n(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:n,c:r,d:a}=t;i.a=s*e.a+n*e.c,i.b=s*e.b+n*e.d,i.c=r*e.a+a*e.c,i.d=r*e.b+a*e.d,o&&(i.scaleX=e.scaleX*o.scaleX,i.scaleY=e.scaleY*o.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,o&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=r*e.a+a*e.c+e.e,i.f=r*e.b+a*e.d+e.f},divide(t,e){J.multiply(t,J.tempInvert(e))},divideParent(t,e){J.multiplyParent(t,J.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=J;return J.copy(e,t),J.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:o,f:r}=t;if(i||s){const a=1/(e*n-i*s);t.a=n*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*n-r*s)*a,t.f=-(r*e-o*i)*a}else if(1===e&&1===n)t.e=-o,t.f=-r;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-o*n*i,t.f=-r*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:o}=e;i||(i=e),i.x=n*t.a+o*t.c,i.y=n*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:o,c:r,d:a}=t,h=1/(n*a-o*r),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*r)*h,i.y=(d*n-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*r)*h,i.y-=(s*n-e*o)*h}},setLayout(t,e,i,s,o){const{x:r,y:a,scaleX:h,scaleY:l}=e;if(n(o)&&(o=e.rotation||e.skewX||e.skewY),o){const{rotation:i,skewX:s,skewY:n}=e,o=i*F,r=X(o),a=Y(o);if(s||n){const e=s*F,i=n*F;t.a=(r+i*-a)*h,t.b=(a+i*r)*h,t.c=(e*r-a)*l,t.d=(r+e*a)*l}else t.a=r*h,t.b=a*h,t.c=-a*l,t.d=r*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=r,t.f=a,(i=i||s)&&J.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:o,c:r,d:a,e:h,f:l}=t;let d,c,u,g,p,_=h,f=l;if(o||r){const t=n*a-o*r;if(r&&!s){d=G(n*n+o*o),c=t/d;const e=n/d;u=o>0?V(e):-V(e)}else{c=G(r*r+a*a),d=t/c;const e=r/c;u=z-(a>0?V(-e):-V(e))}const e=j(X(u)),i=Y(u);d=j(d),c=j(c),g=e?j((r/c+i)/e/F,9):0,p=e?j((o/d-i)/e/F,9):0,u=j(u/F)}else d=n,c=a,u=g=p=0;return(e=i||e)&&(_+=e.x*n+e.y*r,f+=e.x*o+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:g,skewY:p}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:o,d:r}=t;n||o?i=(s*r-n*o)/(e=G(s*s+n*n)):(e=s,i=r)}return s.scaleX=e,s.scaleY=i,s},reset(t){J.set(t)}},J=Z,{float:$}=M,{toInnerPoint:Q,toOuterPoint:tt}=Z,{sin:et,cos:it,abs:st,sqrt:nt,atan2:ot,min:rt,round:at}=Math,ht={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=n(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?at(t.x-.5)+.5:at(t.x),t.y=e?at(t.y-.5)+.5:at(t.y)},move(t,e,i){u(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=lt.defaultPoint);const s=it(e*=F),n=et(e),o=t.x-i.x,r=t.y-i.y;t.x=i.x+o*s-r*n,t.y=i.y+o*n+r*s},tempToInnerOf(t,e){const{tempPoint:i}=lt;return ct(i,t),Q(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=lt;return ct(i,t),tt(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=lt;return ct(i,t),lt.toInnerRadiusPointOf(t,e,i),i},copyRadiusPoint:(t,e,i,s)=>(ct(t,e),ut(t,i,s),t),toInnerRadiusPointOf(t,e,i){i||(i=t),Q(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){Q(e,t,i)},toOuterOf(t,e,i){tt(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)=>dt(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=st(i-t),o=st(s-e);return nt(n*n+o*o)},getMinDistanceFrom:(t,e,i,s,n,o)=>rt(dt(t,e,i,s),dt(i,s,n,o)),getAngle:(t,e)=>gt(t,e)/F,getRotation:(t,e,i,s)=>(s||(s=e),lt.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/F),getRadianFrom(t,e,i,s,o,r,a,h){n(a)&&(a=i,h=s);const l=t-i,d=e-s,c=o-a,u=r-h;return Math.atan2(l*u-d*c,l*c+d*u)},getAtan2:(t,e)=>ot(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s,n){const o=gt(t,e);return n&&(t=e),s||(e={}),e.x=t.x+it(o)*i,e.y=t.y+et(o)*i,e},toNumberPoints(t){let e=t;return u(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e)=>$(t.x)===$(e.x)&&$(t.y)===$(e.y),reset(t){lt.reset(t)}},lt=ht,{getDistanceFrom:dt,copy:ct,setRadius:ut,getAtan2:gt}=lt;class pt{constructor(t,e){this.set(t,e)}set(t,e){return u(t)?ht.copy(this,t):ht.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new pt(this)}move(t,e){return ht.move(this,t,e),this}scale(t,e){return ht.scale(this,t,e),this}scaleOf(t,e,i){return ht.scaleOf(this,t,e,i),this}rotate(t,e){return ht.rotate(this,t,e),this}rotateOf(t,e){return ht.rotate(this,e,t),this}getRotation(t,e,i){return ht.getRotation(this,t,e,i)}toInnerOf(t,e){return ht.toInnerOf(this,t,e),this}toOuterOf(t,e){return ht.toOuterOf(this,t,e),this}getCenter(t){return new pt(ht.getCenter(this,t))}getDistance(t){return ht.getDistance(this,t)}getDistancePoint(t,e,i,s){return new pt(ht.getDistancePoint(this,t,e,i,s))}getAngle(t){return ht.getAngle(this,t)}getAtan2(t){return ht.getAtan2(this,t)}isSame(t){return ht.isSame(this,t)}reset(){return ht.reset(this),this}}const _t=new pt;class ft{constructor(t,e,i,s,n,o){this.set(t,e,i,s,n,o)}set(t,e,i,s,n,o){return u(t)?Z.copy(this,t):Z.set(this,t,e,i,s,n,o),this}setWith(t){return Z.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:n,f:o}=this;return{a:t,b:e,c:i,d:s,e:n,f:o}}clone(){return new ft(this)}translate(t,e){return Z.translate(this,t,e),this}translateInner(t,e){return Z.translateInner(this,t,e),this}scale(t,e){return Z.scale(this,t,e),this}scaleWith(t,e){return Z.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return Z.pixelScale(this,t),this}scaleOfOuter(t,e,i){return Z.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return Z.scaleOfInner(this,t,e,i),this}rotate(t){return Z.rotate(this,t),this}rotateOfOuter(t,e){return Z.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return Z.rotateOfInner(this,t,e),this}skew(t,e){return Z.skew(this,t,e),this}skewOfOuter(t,e,i){return Z.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return Z.skewOfInner(this,t,e,i),this}multiply(t){return Z.multiply(this,t),this}multiplyParent(t){return Z.multiplyParent(this,t),this}divide(t){return Z.divide(this,t),this}divideParent(t){return Z.divideParent(this,t),this}invert(){return Z.invert(this),this}invertWith(){return Z.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){Z.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){Z.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return Z.setLayout(this,t,e,i),this}getLayout(t,e,i){return Z.getLayout(this,t,e,i)}withScale(t,e){return Z.withScale(this,t,e)}reset(){Z.reset(this)}}const mt=new ft,yt={tempPointBounds:{},setPoint(t,e,i){t.minX=t.maxX=e,t.minY=t.maxY=i},addPoint(t,e,i){t.minX=e<t.minX?e:t.minX,t.minY=i<t.minY?i:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=i>t.maxY?i:t.maxY},addBounds(t,e,i,s,n){vt(t,e,i),vt(t,e+s,i+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:vt}=yt;var wt,xt;t.Direction4=void 0,(wt=t.Direction4||(t.Direction4={}))[wt.top=0]="top",wt[wt.right=1]="right",wt[wt.bottom=2]="bottom",wt[wt.left=3]="left",t.Direction9=void 0,(xt=t.Direction9||(t.Direction9={}))[xt.topLeft=0]="topLeft",xt[xt.top=1]="top",xt[xt.topRight=2]="topRight",xt[xt.right=3]="right",xt[xt.bottomRight=4]="bottomRight",xt[xt.bottom=5]="bottom",xt[xt.bottomLeft=6]="bottomLeft",xt[xt.left=7]="left",xt[xt.center=8]="center",xt[xt["top-left"]=0]="top-left",xt[xt["top-right"]=2]="top-right",xt[xt["bottom-right"]=4]="bottom-right",xt[xt["bottom-left"]=6]="bottom-left";const bt=[{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}];bt.forEach(t=>t.type="percent");const Et={directionData:bt,tempPoint:{},get:St,toPoint(t,e,i,s,n,o){const r=St(t);i.x=r.x,i.y=r.y,"percent"===r.type&&(i.x*=e.width,i.y*=e.height,n&&(o||(i.x-=n.x,i.y-=n.y),r.x&&(i.x-=1===r.x?n.width:.5===r.x?r.x*n.width:0),r.y&&(i.y-=1===r.y?n.height:.5===r.y?r.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i)=>(i||(i={}),Et.toPoint(t,e,i,!0),i)};function St(e){return r(e)?bt[t.Direction9[e]]:e}const{toPoint:kt}=Et,Tt={toPoint(t,e,i,s,n,o){kt(t,i,s,n,e,o)}},{tempPointBounds:Bt,setPoint:Pt,addPoint:Rt,toBounds:Lt}=yt,{toOuterPoint:Ct}=Z,{float:Ot,fourNumber:At}=M,{floor:Dt,ceil:Mt}=Math;let It,Ft,Wt,zt;const Ut={},Ht={},Nt={},Yt={tempBounds:Nt,set(t,e=0,i=0,s=0,n=0){t.x=e,t.y=i,t.width=s,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,n){const{x:o,y:r,width:a,height:h}=e;if(c(i)){const e=At(i);s?Xt.set(t,o+e[3],r+e[0],a-e[1]-e[3],h-e[2]-e[0]):Xt.set(t,o-e[3],r-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Xt.set(t,o-i,r-i,a+2*i,h+2*i);n&&("width"===n?(t.y=r,t.height=h):(t.x=o,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},scroll(t,e){t.x+=e.scrollX,t.y+=e.scrollY},getByMove:(t,e,i)=>(t=Object.assign({},t),Xt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Gt(e,t):e=t,i||(i=t),e.offsetX=Xt.maxX(i),e.offsetY=Xt.maxY(i),Xt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||ht.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){ht.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Xt.copy(Nt,t),Xt.toOuterOf(Nt,e),Nt),getOuterOf:(t,e)=>(t=Object.assign({},t),Xt.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n,e:o,f:r}=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),n>0?(i.height=t.height*n,i.y=r+t.y*n):(i.height=t.height*-n,i.y=r+t.y*n-i.height)}else Ut.x=t.x,Ut.y=t.y,Ct(e,Ut,Ht),Pt(Bt,Ht.x,Ht.y),Ut.x=t.x+t.width,Ct(e,Ut,Ht),Rt(Bt,Ht.x,Ht.y),Ut.y=t.y+t.height,Ct(e,Ut,Ht),Rt(Bt,Ht.x,Ht.y),Ut.x=t.x,Ct(e,Ut,Ht),Rt(Bt,Ht.x,Ht.y),Lt(Bt,i)},toInnerOf(t,e,i){i||(i=t),Xt.move(i,-e.e,-e.f),Xt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Xt.getFitScale(t,e));return new ft(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,n=t.height/e.height;return i?Math.max(s,n):Math.min(s,n)},put(t,e,i="center",s=1,n=!0,o){o||(o=e),r(s)&&(s=Xt.getFitScale(t,e,"cover"===s)),Nt.width=n?e.width*=s:e.width*s,Nt.height=n?e.height*=s:e.height*s,Tt.toPoint(i,Nt,t,o,!0,!0)},getSpread(t,e,i){const s={};return Xt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Xt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Xt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=Dt(t.x),t.y=Dt(t.y),t.width=e>t.x?Mt(t.width+e-t.x):Mt(t.width),t.height=i>t.y?Mt(t.height+i-t.y):Mt(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=Ot(t.x,e),t.y=Ot(t.y,e),t.width=Ot(t.width,e),t.height=Ot(t.height,e)},add(t,e,i){It=t.x+t.width,Ft=t.y+t.height,Wt=e.x,zt=e.y,i||(Wt+=e.width,zt+=e.height),It=It>Wt?It:Wt,Ft=Ft>zt?Ft:zt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=It-t.x,t.height=Ft-t.y},addList(t,e){Xt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Xt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Xt.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,o=!0;for(let r=0,a=e.length;r<a;r++)n=i?i(e[r],r):e[r],n&&(n.width||n.height)&&(o?(o=!1,s||Gt(t,n)):Vt(t,n));o&&Xt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?Pt(Bt,t.x,t.y):Rt(Bt,t.x,t.y)),Lt(Bt,t)},setPoint(t,e){Xt.set(t,e.x,e.y)},addPoint(t,e){Vt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]},hitRadiusPoint:(t,e,i)=>(i&&(e=ht.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=ht.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=Xt.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=Xt.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=Xt.tempToOuterOf(e,i)),!Xt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:o,height:r}=e;return It=s+o,Ft=n+r,Wt=t.x+t.width,zt=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,It=It<Wt?It:Wt,Ft=Ft<zt?Ft:zt,o=It-s,r=Ft-n,{x:s,y:n,width:o,height:r}},intersect(t,e,i){Xt.copy(t,Xt.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){Xt.set(t)}},Xt=Yt,{add:Vt,copy:Gt}=Xt;class jt{get minX(){return Yt.minX(this)}get minY(){return Yt.minY(this)}get maxX(){return Yt.maxX(this)}get maxY(){return Yt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return u(t)?Yt.copy(this,t):Yt.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 jt(this)}move(t,e){return Yt.move(this,t,e),this}scale(t,e,i){return Yt.scale(this,t,e,i),this}scaleOf(t,e,i){return Yt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Yt.toOuterOf(this,t,e),this}toInnerOf(t,e){return Yt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Yt.getFitMatrix(this,t,e)}put(t,e,i){Yt.put(this,t,e,i)}spread(t,e){return Yt.spread(this,t,e),this}shrink(t,e){return Yt.shrink(this,t,e),this}ceil(){return Yt.ceil(this),this}unsign(){return Yt.unsign(this),this}float(t){return Yt.float(this,t),this}add(t){return Yt.add(this,t),this}addList(t){return Yt.setList(this,t,!0),this}setList(t){return Yt.setList(this,t),this}addListWithFn(t,e){return Yt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Yt.setListWithFn(this,t,e),this}setPoint(t){return Yt.setPoint(this,t),this}setPoints(t){return Yt.setPoints(this,t),this}addPoint(t){return Yt.addPoint(this,t),this}getPoints(){return Yt.getPoints(this)}hitPoint(t,e){return Yt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Yt.hitRadiusPoint(this,t,e)}hit(t,e){return Yt.hit(this,t,e)}includes(t,e){return Yt.includes(this,t,e)}intersect(t,e){return Yt.intersect(this,t,e),this}getIntersect(t,e){return new jt(Yt.getIntersectData(this,t,e))}isSame(t){return Yt.isSame(this,t)}isEmpty(){return Yt.isEmpty(this)}reset(){Yt.reset(this)}}const Kt=new jt;class qt{constructor(t,e,i,s,n,o){u(t)?this.copy(t):this.set(t,e,i,s,n,o)}set(t=0,e=0,i=0,s=0,n=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=t;this.set(e,i,s,n,o,r)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=this;return new jt(n,e,o||t.width-n-i,r||t.height-e-s)}}const Zt={number:(t,e)=>u(t)?"percent"===t.type?t.value*e:t.value:t},Jt={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:$t,max:Qt}=Math,te={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||ee.maxCacheSize),isSuperLarge:(t,e,i)=>ee.isLarge(t,e,i,ee.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=ee;return!i||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+i),e&&"/"===t[0]&&(t=e+t),t},resize(t,e,i,s,n,o,r,a,h,l){const d=Qt($t(e+(s||0)),1),c=Qt($t(i+(n||0)),1);let u,g,p;l&&(p=Zt.number(l.offset,(u="x"===l.type)?e:i))&&(u||(g=!0));const _=te.origin.createCanvas(g?2*d:d,u?2*c:c),f=_.getContext("2d");if(a&&(f.globalAlpha=a),f.imageSmoothingEnabled=!1!==r,ee.canUse(t)){if(o){const s=e/o.width,n=i/o.height;f.setTransform(s,0,0,n,-o.x*s,-o.y*n),f.drawImage(t,0,0,t.width,t.height)}else f.drawImage(t,0,0,e,i);p&&(f.drawImage(_,0,0,d,c,u?p-d:d,u?c:p-c,d,c),f.drawImage(_,0,0,d,c,u?p:d,u?c:p,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&&_.stintSet(i,"transform",e)}}},{image:ee}=te,{randColor:ie}=M;class se{constructor(t){this.repeatMap={},this.name=t}static get(t){return new se(t)}static set filter(t){this.filterList=ne(t)}static set exclude(t){this.excludeList=ne(t)}static drawRepaint(t,e){const i=ie();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===se.showBounds,n=t.__nowWorld,o=ie();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=o.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(o,2),s?e.stroke():e.strokeWorld(n,o)}log(...t){if(oe.enable){if(oe.filterList.length&&oe.filterList.every(t=>t!==this.name))return;if(oe.excludeList.length&&oe.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){oe.enable&&this.warn(...t)}warn(...t){oe.showWarn&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}function ne(t){return t?r(t)&&(t=[t]):t=[],t}se.filterList=[],se.excludeList=[],se.showWarn=!0;const oe=se,re=se.get("RunTime"),ae={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=y.create(y.RUNTIME);return he.currentId=he.idMap[i]=e?performance.now():Date.now(),he.currentName=he.nameMap[i]=t,he.nameToIdMap[t]=i,i},end(t,e){const i=he.idMap[t],s=he.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;he.idMap[t]=he.nameMap[t]=he.nameToIdMap[s]=void 0,re.log(s,n,"ms")},endOfName(t,e){const i=he.nameToIdMap[t];n(i)||he.end(i,e)}},he=ae,le=[],de={list:{},add(t,...e){this.list[t]=!0,le.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>le.forEach(t=>de.has(t,!0)));const ce={editor:t=>de.need("editor")},ue=se.get("UICreator"),ge={list:{},register(t){const{__tag:e}=t.prototype;pe[e]&&ue.repeat(e),pe[e]=t},get(t,e,i,s,o,r){pe[t]||ue.error("not register "+t);const a=new pe[t](e);return n(i)||(a.x=i,s&&(a.y=s),o&&(a.width=o),r&&(a.height=r)),a}},{list:pe}=ge,_e=se.get("EventCreator"),fe={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],r(e)&&(me[e]&&_e.repeat(e),me[e]=t)})},changeName(t,e){const i=me[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,me[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new me[t](...e)},{nameList:me}=fe;class ye{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let s=0,n=i.length;s<n;s++)if(e=i[s],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const s=ce.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 ve(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,i,r):n(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}function we(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){t.done?n(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(r,a)}h((s=s.apply(t,e||[])).next())})}function xe(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)}}"function"==typeof SuppressedError&&SuppressedError;const be=[];function Ee(){return(t,e)=>{be.push(e)}}const Se=[];class ke{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||Se)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;be.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,o){u(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,i,s){}strokeRect(t,e,i,s){}clearRect(t,e,i,s){}drawImage(t,e,i,s,n,o,r,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,o+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,r+=t,h-=t}this.context.drawImage(t,e,i,s,n,o,r,a,h);break;case 5:this.context.drawImage(t,e,i,s,n);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,n,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,o){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,o,r,a){}rect(t,e,i,s){}roundRect(t,e,i,s,n){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,n,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}}ve([xe("imageSmoothingEnabled")],ke.prototype,"smooth",void 0),ve([xe("imageSmoothingQuality")],ke.prototype,"smoothLevel",void 0),ve([xe("globalAlpha")],ke.prototype,"opacity",void 0),ve([xe()],ke.prototype,"fillStyle",void 0),ve([xe()],ke.prototype,"strokeStyle",void 0),ve([xe("lineWidth")],ke.prototype,"strokeWidth",void 0),ve([xe("lineCap")],ke.prototype,"strokeCap",void 0),ve([xe("lineJoin")],ke.prototype,"strokeJoin",void 0),ve([xe("lineDashOffset")],ke.prototype,"dashOffset",void 0),ve([xe()],ke.prototype,"miterLimit",void 0),ve([xe()],ke.prototype,"shadowBlur",void 0),ve([xe()],ke.prototype,"shadowColor",void 0),ve([xe()],ke.prototype,"shadowOffsetX",void 0),ve([xe()],ke.prototype,"shadowOffsetY",void 0),ve([xe()],ke.prototype,"filter",void 0),ve([xe()],ke.prototype,"font",void 0),ve([xe()],ke.prototype,"fontKerning",void 0),ve([xe()],ke.prototype,"fontStretch",void 0),ve([xe()],ke.prototype,"fontVariantCaps",void 0),ve([xe()],ke.prototype,"textAlign",void 0),ve([xe()],ke.prototype,"textBaseline",void 0),ve([xe()],ke.prototype,"textRendering",void 0),ve([xe()],ke.prototype,"wordSpacing",void 0),ve([xe()],ke.prototype,"letterSpacing",void 0),ve([xe()],ke.prototype,"direction",void 0),ve([Ee()],ke.prototype,"setTransform",null),ve([Ee()],ke.prototype,"resetTransform",null),ve([Ee()],ke.prototype,"getTransform",null),ve([Ee()],ke.prototype,"save",null),ve([Ee()],ke.prototype,"restore",null),ve([Ee()],ke.prototype,"translate",null),ve([Ee()],ke.prototype,"scale",null),ve([Ee()],ke.prototype,"rotate",null),ve([Ee()],ke.prototype,"fill",null),ve([Ee()],ke.prototype,"stroke",null),ve([Ee()],ke.prototype,"clip",null),ve([Ee()],ke.prototype,"fillRect",null),ve([Ee()],ke.prototype,"strokeRect",null),ve([Ee()],ke.prototype,"clearRect",null),ve([Ee()],ke.prototype,"beginPath",null),ve([Ee()],ke.prototype,"moveTo",null),ve([Ee()],ke.prototype,"lineTo",null),ve([Ee()],ke.prototype,"bezierCurveTo",null),ve([Ee()],ke.prototype,"quadraticCurveTo",null),ve([Ee()],ke.prototype,"closePath",null),ve([Ee()],ke.prototype,"arc",null),ve([Ee()],ke.prototype,"arcTo",null),ve([Ee()],ke.prototype,"ellipse",null),ve([Ee()],ke.prototype,"rect",null),ve([Ee()],ke.prototype,"roundRect",null),ve([Ee()],ke.prototype,"createConicGradient",null),ve([Ee()],ke.prototype,"createLinearGradient",null),ve([Ee()],ke.prototype,"createPattern",null),ve([Ee()],ke.prototype,"createRadialGradient",null),ve([Ee()],ke.prototype,"fillText",null),ve([Ee()],ke.prototype,"measureText",null),ve([Ee()],ke.prototype,"strokeText",null);const{copy:Te,multiplyParent:Be,pixelScale:Pe}=Z,{round:Re}=Math,Le=new jt,Ce=new jt,Oe={width:1,height:1,pixelRatio:1},Ae=["width","height","pixelRatio"];class De extends ke{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=Oe),this.manager=e,this.innerId=y.create(y.CNAVAS);const{width:i,height:s,pixelRatio:n}=t;this.autoLayout=!i||!s,this.size.pixelRatio=n||te.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;_.copyAttrs(s,t,Ae),Ae.forEach(t=>s[t]||(s[t]=1)),this.bounds=new jt(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,n=this.worldTransform;e&&Be(t,e,n),Pe(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=Re(n.e-.5)+.5,n.f=Re(n.f-.5)+.5):(n.e=Re(n.e),n.f=Re(n.f))),this.setTransform(n.a,n.b,n.c,n.d,n.e,n.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:o,dashOffset:r,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),n(e.dashPattern)||(o=e.dashPattern),n(e.dashOffset)||(r=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=o,this.dashOffset=r,this.miterLimit=a}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,n){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=Ce):i=Le,this.drawImage(t.view,Le.x,Le.y,Le.width,Le.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,n){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Yt.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,Le.x,Le.y,Le.width,Le.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,o){this.resetTransform(),this.copyWorld(t,e,i,s,o),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(Le.x,Le.y,Le.width,Le.height),{data:o}=n;for(let t=0,s=o.length;t<s;t+=4)i=.299*o[t]+.587*o[t+1]+.114*o[t+2],(e=o[t+3])&&(o[t+3]=255===e?i:e*(i/255));s.putImageData(n,Le.x,Le.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(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Le.x,Le.y,Le.width,Le.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Le.x,Le.y,Le.width,Le.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Le,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(Ce,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,n=this.manager?this.manager.get(i):ce.canvas(Object.assign({},i));return n.save(),t&&(Te(n.worldTransform,this.worldTransform),n.useWorldTransform()),e&&(n.smooth=this.smooth),n.pixelSnap!==s&&(n.pixelSnap=s),n}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}}const Me={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Ie={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Fe=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},Ie),We={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},ze={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},Ue=Object.assign(Object.assign({},ze),Ie),He=Fe,Ne={};for(let t in He)Ne[He[t]]=t;const Ye={};for(let t in He)Ye[He[t]]=We[t];const Xe={drawRoundRect(t,e,i,s,n,o){const r=M.fourNumber(o,Math.min(s/2,n/2)),a=e+s,h=i+n;r[0]?t.moveTo(e+r[0],i):t.moveTo(e,i),r[1]?t.arcTo(a,i,a,h,r[1]):t.lineTo(a,i),r[2]?t.arcTo(a,h,e,h,r[2]):t.lineTo(a,h),r[3]?t.arcTo(e,h,e,i,r[3]):t.lineTo(e,h),r[0]?t.arcTo(e,i,a,i,r[0]):t.lineTo(e,i)}},{sin:Ve,cos:Ge,hypot:je,atan2:Ke,ceil:qe,abs:Ze,PI:Je,sqrt:$e,pow:Qe}=Math,{setPoint:ti,addPoint:ei}=yt,{set:ii,toNumberPoints:si}=ht,{M:ni,L:oi,C:ri,Q:ai,Z:hi}=Fe,li={},di={points(t,e,i,s){let n=si(e);if(t.push(ni,n[0],n[1]),i&&n.length>5){let e,o,r,a,h,l,d,c,u,g,p,_,f,m,y,v=n.length;const w=!0===i?.5:i;s&&(n=[n[v-2],n[v-1],...n,n[0],n[1],n[2],n[3]],v=n.length);for(let i=2;i<v-2;i+=2)e=n[i-2],o=n[i-1],r=n[i],a=n[i+1],h=n[i+2],l=n[i+3],p=r-e,_=a-o,f=$e(Qe(p,2)+Qe(_,2)),m=$e(Qe(h-r,2)+Qe(l-a,2)),(f||m)&&(y=f+m,f=w*f/y,m=w*m/y,h-=e,l-=o,d=r-f*h,c=a-f*l,2===i?s||t.push(ai,d,c,r,a):(p||_)&&t.push(ri,u,g,d,c,r,a),u=r+m*h,g=a+m*l);s||t.push(ai,u,g,n[v-2],n[v-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(oi,n[e],n[e+1]);s&&t.push(hi)},rect(t,e,i,s,n){Me.creator.path=t,Me.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+n).lineTo(e,i+n).lineTo(e,i)},roundRect(t,e,i,s,n,o){Me.creator.path=[],Xe.drawRoundRect(Me.creator,e,i,s,n,o),t.push(...Me.convertToCanvasData(Me.creator.path,!0))},arcTo(t,e,i,s,n,o,r,a,h,l,d){const c=s-e,u=n-i,g=o-s,p=r-n;let _=Ke(u,c),f=Ke(p,g);const m=je(c,u),y=je(g,p);let v=f-_;if(v<0&&(v+=W),m<1e-12||y<1e-12||v<1e-12||Ze(v-Je)<1e-12)return t&&t.push(oi,s,n),h&&(ti(h,e,i),ei(h,s,n)),d&&ii(d,e,i),void(l&&ii(l,s,n));const w=c*p-g*u<0,x=w?-1:1,b=a/Ge(v/2),E=s+b*Ge(_+v/2+z*x),S=n+b*Ve(_+v/2+z*x);return _-=z*x,f-=z*x,gi(t,E,S,a,a,0,_/F,f/F,w,h,l,d)},arc:(t,e,i,s,n,o,r,a,h,l)=>gi(t,e,i,s,s,0,n,o,r,a,h,l),ellipse(t,e,i,s,n,o,r,a,h,l,d,c){const u=o*F,g=Ve(u),p=Ge(u);let _=r*F,f=a*F;_>Je&&(_-=W),f<0&&(f+=W);let m=f-_;m<0?m+=W:m>W&&(m-=W),h&&(m-=W);const y=qe(Ze(m/z)),v=m/y,w=Ve(v/4),x=8/3*w*w/Ve(v/2);f=_+v;let b,E,S,k,T,B,P,R,L=Ge(_),C=Ve(_),O=S=p*s*L-g*n*C,A=k=g*s*L+p*n*C,D=e+S,M=i+k;t&&t.push(t.length?oi:ni,D,M),l&&ti(l,D,M),c&&ii(c,D,M);for(let o=0;o<y;o++)b=Ge(f),E=Ve(f),S=p*s*b-g*n*E,k=g*s*b+p*n*E,T=e+O-x*(p*s*C+g*n*L),B=i+A-x*(g*s*C-p*n*L),P=e+S+x*(p*s*E+g*n*b),R=i+k+x*(g*s*E-p*n*b),t&&t.push(ri,T,B,P,R,e+S,i+k),l&&ui(e+O,i+A,T,B,P,R,e+S,i+k,l,!0),O=S,A=k,L=b,C=E,_=f,f+=v;d&&ii(d,e+S,i+k)},quadraticCurveTo(t,e,i,s,n,o,r){t.push(ri,(e+2*s)/3,(i+2*n)/3,(o+2*s)/3,(r+2*n)/3,o,r)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,o,r,a){ui(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(o+2*s)/3,n,o,r,a)},toTwoPointBounds(t,e,i,s,n,o,r,a,h,l){const d=[];let c,u,g,p,_,f,m,y,v=t,w=i,x=n,b=r;for(let t=0;t<2;++t)if(1==t&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,g=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;p=-g/u,0<p&&p<1&&d.push(p)}else m=u*u-4*g*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?ei(h,t,e):ti(h,t,e),ei(h,r,a);for(let l=0,c=d.length;l<c;l++)ci(d[l],t,e,i,s,n,o,r,a,li),ei(h,li.x,li.y)},getPointAndSet(t,e,i,s,n,o,r,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,g=3*d*t*t,p=t*t*t;l.x=c*e+u*s+g*o+p*a,l.y=c*i+u*n+g*r+p*h},getPoint(t,e,i,s,n,o,r,a,h){const l={};return ci(t,e,i,s,n,o,r,a,h,l),l},getDerivative(t,e,i,s,n){const o=1-t;return 3*o*o*(i-e)+6*o*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:ci,toTwoPointBounds:ui,ellipse:gi}=di,{sin:pi,cos:_i,sqrt:fi,atan2:mi}=Math,{ellipse:yi}=di,vi={ellipticalArc(t,e,i,s,n,o,r,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,g=o*F,p=pi(g),_=_i(g),f=-_*c-p*u,m=-_*u+p*c,y=s*s,v=n*n,w=m*m,x=f*f,b=y*v-y*w-v*x;let E=0;if(b<0){const t=fi(1-b/(y*v));s*=t,n*=t}else E=(r===a?-1:1)*fi(b/(y*w+v*x));const S=E*s*m/n,k=-E*n*f/s,T=mi((m-k)/n,(f-S)/s),B=mi((-m-k)/n,(-f-S)/s);let P=B-T;0===a&&P>0?P-=W:1===a&&P<0&&(P+=W);const R=e+c+_*S-p*k,L=i+u+p*S+_*k,C=P<0?1:0;d||te.ellipseToCurve?yi(t,R,L,s,n,o,T/F,B/F,C):s!==n||o?t.push(Fe.G,R,L,s,n,o,T/F,B/F,C):t.push(Fe.O,R,L,s,T/F,B/F,C)}},wi={toCommand:t=>[],toNode:t=>[]},{M:xi,m:bi,L:Ei,l:Si,H:ki,h:Ti,V:Bi,v:Pi,C:Ri,c:Li,S:Ci,s:Oi,Q:Ai,q:Di,T:Mi,t:Ii,A:Fi,a:Wi,Z:zi,z:Ui,N:Hi,D:Ni,X:Yi,G:Xi,F:Vi,O:Gi,P:ji,U:Ki}=Fe,{rect:qi,roundRect:Zi,arcTo:Ji,arc:$i,ellipse:Qi,quadraticCurveTo:ts}=di,{ellipticalArc:es}=vi,is=se.get("PathConvert"),ss={},ns={current:{dot:0},stringify(t,e){let i,s,n,o=0,r=t.length,a="";for(;o<r;){s=t[o],i=Ye[s],a+=s===n?" ":Ne[s];for(let s=1;s<i;s++)a+=M.float(t[o+s],e),s===i-1||(a+=" ");n=s,o+=i}return a},parse(t,e){let i,s,n,o="";const r=[],a=e?Ue:ze;for(let e=0,h=t.length;e<h;e++)s=t[e],Jt[s]?("."===s&&(os.dot&&(rs(r,o),o=""),os.dot++),"0"===o&&"."!==s&&(rs(r,o),o=""),o+=s):Fe[s]?(o&&(rs(r,o),o=""),os.name=Fe[s],os.length=We[s],os.index=0,rs(r,os.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?o+=s:(o&&rs(r,o),o=s):o&&(rs(r,o),o=""),n=s;return o&&rs(r,o),i?ns.toCanvasData(r,e):r},toCanvasData(t,e){let i,s,n,o,r,a=0,h=0,l=0,d=0,c=0,u=t.length;const g=[];for(;c<u;){switch(n=t[c],n){case bi:t[c+1]+=a,t[c+2]+=h;case xi:a=t[c+1],h=t[c+2],g.push(xi,a,h),c+=3;break;case Ti:t[c+1]+=a;case ki:a=t[c+1],g.push(Ei,a,h),c+=2;break;case Pi:t[c+1]+=h;case Bi:h=t[c+1],g.push(Ei,a,h),c+=2;break;case Si:t[c+1]+=a,t[c+2]+=h;case Ei:a=t[c+1],h=t[c+2],g.push(Ei,a,h),c+=3;break;case Oi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ci;case Ci:r=o===Ri||o===Ci,l=r?2*a-i:t[c+1],d=r?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],g.push(Ri,l,d,i,s,a,h),c+=5;break;case Li:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=Ri;case Ri:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],g.push(Ri,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Ii:t[c+1]+=a,t[c+2]+=h,n=Mi;case Mi:r=o===Ai||o===Mi,i=r?2*a-i:t[c+1],s=r?2*h-s:t[c+2],e?ts(g,a,h,i,s,t[c+1],t[c+2]):g.push(Ai,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Di:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ai;case Ai:i=t[c+1],s=t[c+2],e?ts(g,a,h,i,s,t[c+3],t[c+4]):g.push(Ai,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Wi:t[c+6]+=a,t[c+7]+=h;case Fi:es(g,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 Ui:case zi:g.push(zi),c++;break;case Hi:a=t[c+1],h=t[c+2],e?qi(g,a,h,t[c+3],t[c+4]):as(g,t,c,5),c+=5;break;case Ni:a=t[c+1],h=t[c+2],e?Zi(g,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):as(g,t,c,9),c+=9;break;case Yi:a=t[c+1],h=t[c+2],e?Zi(g,a,h,t[c+3],t[c+4],t[c+5]):as(g,t,c,6),c+=6;break;case Xi:Qi(e?g:as(g,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,ss),a=ss.x,h=ss.y,c+=9;break;case Vi:e?Qi(g,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):as(g,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Gi:$i(e?g:as(g,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,ss),a=ss.x,h=ss.y,c+=7;break;case ji:e?$i(g,t[c+1],t[c+2],t[c+3],0,360,!1):as(g,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Ki:Ji(e?g:as(g,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,ss),a=ss.x,h=ss.y,c+=6;break;default:return is.error(`command: ${n} [index:${c}]`,t),g}o=n}return g},objectToCanvasData(t){if(t[0].name.length>1)return wi.toCommand(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(xi,t.x,t.y);break;case"L":e.push(Ei,t.x,t.y);break;case"C":e.push(Ri,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Ai,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(zi)}}),e}},copyData(t,e,i,s){for(let n=i,o=i+s;n<o;n++)t.push(e[n])},pushData(t,e){os.index===os.length&&(os.index=1,t.push(os.name)),t.push(Number(e)),os.index++,os.dot=0}},{current:os,pushData:rs,copyData:as}=ns,{M:hs,L:ls,C:ds,Q:cs,Z:us,N:gs,D:ps,X:_s,G:fs,F:ms,O:ys,P:vs,U:ws}=Fe,{getMinDistanceFrom:xs,getRadianFrom:bs}=ht,{tan:Es,min:Ss,abs:ks}=Math,Ts={},Bs={beginPath(t){t.length=0},moveTo(t,e,i){t.push(hs,e,i)},lineTo(t,e,i){t.push(ls,e,i)},bezierCurveTo(t,e,i,s,n,o,r){t.push(ds,e,i,s,n,o,r)},quadraticCurveTo(t,e,i,s,n){t.push(cs,e,i,s,n)},closePath(t){t.push(us)},rect(t,e,i,s,n){t.push(gs,e,i,s,n)},roundRect(t,e,i,s,n,o){if(h(o))t.push(_s,e,i,s,n,o);else{const r=M.fourNumber(o);r?t.push(ps,e,i,s,n,...r):t.push(gs,e,i,s,n)}},ellipse(t,e,i,s,n,r,a,h,l){if(s===n)return Rs(t,e,i,s,a,h,l);o(r)?t.push(ms,e,i,s,n):(o(a)&&(a=0),o(h)&&(h=360),t.push(fs,e,i,s,n,r,a,h,l?1:0))},arc(t,e,i,s,n,r,a){o(n)?t.push(vs,e,i,s):(o(n)&&(n=0),o(r)&&(r=360),t.push(ys,e,i,s,n,r,a?1:0))},arcTo(t,e,i,s,o,r,a,h){if(!n(a)){const t=xs(a,h,e,i,s,o);r=Ss(r,Ss(t/2,t/2*ks(Es(bs(a,h,e,i,s,o)/2))))}t.push(ws,e,i,s,o,r)},drawEllipse(t,e,i,s,n,r,a,h,l){di.ellipse(null,e,i,s,n,o(r)?0:r,o(a)?0:a,o(h)?360:h,l,null,null,Ts),t.push(hs,Ts.x,Ts.y),Ps(t,e,i,s,n,r,a,h,l)},drawArc(t,e,i,s,n,r,a){di.arc(null,e,i,s,o(n)?0:n,o(r)?360:r,a,null,null,Ts),t.push(hs,Ts.x,Ts.y),Rs(t,e,i,s,n,r,a)},drawPoints(t,e,i,s){di.points(t,e,i,s)}},{ellipse:Ps,arc:Rs}=Bs,{moveTo:Ls,lineTo:Cs,quadraticCurveTo:Os,bezierCurveTo:As,closePath:Ds,beginPath:Ms,rect:Is,roundRect:Fs,ellipse:Ws,arc:zs,arcTo:Us,drawEllipse:Hs,drawArc:Ns,drawPoints:Ys}=Bs;class Xs{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?r(t)?Me.parse(t):t:[],this}beginPath(){return Ms(this.__path),this.paint(),this}moveTo(t,e){return Ls(this.__path,t,e),this.paint(),this}lineTo(t,e){return Cs(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,o){return As(this.__path,t,e,i,s,n,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return Os(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ds(this.__path),this.paint(),this}rect(t,e,i,s){return Is(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Fs(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,o,r,a){return Ws(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}arc(t,e,i,s,n,o){return zs(this.__path,t,e,i,s,n,o),this.paint(),this}arcTo(t,e,i,s,n){return Us(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,o,r,a){return Hs(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}drawArc(t,e,i,s,n,o){return Ns(this.__path,t,e,i,s,n,o),this.paint(),this}drawPoints(t,e,i){return Ys(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Vs,L:Gs,C:js,Q:Ks,Z:qs,N:Zs,D:Js,X:$s,G:Qs,F:tn,O:en,P:sn,U:nn}=Fe,on=se.get("PathDrawer"),rn={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Vs:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Gs:t.lineTo(e[s+1],e[s+2]),s+=3;break;case js:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Ks:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case qs:t.closePath(),s+=1;break;case Zs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Js:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case $s:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Qs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*F,e[s+6]*F,e[s+7]*F,e[s+8]),s+=9;break;case tn:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,W,!1),s+=5;break;case en:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*F,e[s+5]*F,e[s+6]),s+=7;break;case sn:t.arc(e[s+1],e[s+2],e[s+3],0,W,!1),s+=4;break;case nn:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void on.error(`command: ${i} [index:${s}]`,e)}}},{M:an,L:hn,C:ln,Q:dn,Z:cn,N:un,D:gn,X:pn,G:_n,F:fn,O:mn,P:yn,U:vn}=Fe,{toTwoPointBounds:wn,toTwoPointBoundsByQuadraticCurve:xn,arcTo:bn,arc:En,ellipse:Sn}=di,{addPointBounds:kn,copy:Tn,addPoint:Bn,setPoint:Pn,addBounds:Rn,toBounds:Ln}=yt,Cn=se.get("PathBounds");let On,An,Dn;const Mn={},In={},Fn={},Wn={toBounds(t,e){Wn.toTwoPointBounds(t,In),Ln(In,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Pn(e,0,0);let i,s,n,o,r,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(r=t[a],0===a&&(r===cn||r===ln||r===dn?Pn(e,h,l):Pn(e,t[a+1],t[a+2])),r){case an:case hn:h=t[a+1],l=t[a+2],Bn(e,h,l),a+=3;break;case ln:n=t[a+5],o=t[a+6],wn(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,o,Mn),kn(e,Mn),h=n,l=o,a+=7;break;case dn:i=t[a+1],s=t[a+2],n=t[a+3],o=t[a+4],xn(h,l,i,s,n,o,Mn),kn(e,Mn),h=n,l=o,a+=5;break;case cn:a+=1;break;case un:h=t[a+1],l=t[a+2],Rn(e,h,l,t[a+3],t[a+4]),a+=5;break;case gn:case pn:h=t[a+1],l=t[a+2],Rn(e,h,l,t[a+3],t[a+4]),a+=r===gn?9:6;break;case _n:Sn(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],Mn,Fn),0===a?Tn(e,Mn):kn(e,Mn),h=Fn.x,l=Fn.y,a+=9;break;case fn:h=t[a+1],l=t[a+2],An=t[a+3],Dn=t[a+4],Rn(e,h-An,l-Dn,2*An,2*Dn),h+=An,a+=5;break;case mn:En(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Mn,Fn),0===a?Tn(e,Mn):kn(e,Mn),h=Fn.x,l=Fn.y,a+=7;break;case yn:h=t[a+1],l=t[a+2],On=t[a+3],Rn(e,h-On,l-On,2*On,2*On),h+=On,a+=4;break;case vn:bn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Mn,Fn),0===a?Tn(e,Mn):kn(e,Mn),h=Fn.x,l=Fn.y,a+=6;break;default:return void Cn.error(`command: ${r} [index:${a}]`,t)}}},{M:zn,L:Un,Z:Hn}=Fe,{getCenterX:Nn,getCenterY:Yn}=ht,{arcTo:Xn}=Bs,Vn={smooth(t,e,i){let s,n,o,r=0,a=0,h=0,l=0,d=0,u=0,g=0,p=0,_=0;c(e)&&(e=e[0]||0);const f=t.length,m=[];for(;r<f;){switch(s=t[r],s){case zn:l=p=t[r+1],d=_=t[r+2],r+=3,t[r]===Un?(u=t[r+1],g=t[r+2],m.push(zn,Nn(l,u),Yn(d,g))):m.push(zn,l,d);break;case Un:switch(a=t[r+1],h=t[r+2],r+=3,t[r]){case Un:Xn(m,a,h,t[r+1],t[r+2],e,p,_);break;case Hn:Xn(m,a,h,l,d,e,p,_);break;default:m.push(Un,a,h)}p=a,_=h;break;case Hn:n!==Hn&&(Xn(m,l,d,u,g,e,p,_),m.push(Hn)),r+=1;break;default:o=Ye[s];for(let e=0;e<o;e++)m.push(t[r+e]);r+=o}n=s}return s!==Hn&&(m[1]=l,m[2]=d),m}};function Gn(t){return new Xs(t)}const jn=Gn();Me.creator=Gn(),Me.parse=ns.parse,Me.convertToCanvasData=ns.toCanvasData;const{drawRoundRect:Kn}=Xe;function qn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Kn(this,t,e,i,s,n)})}(t)}const Zn={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=Jn.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{}}}},Jn=Zn;Jn.alphaPixelTypes.forEach(t=>Jn.upperCaseTypeMap[t]=t.toUpperCase());const $n=se.get("TaskProcessor");class Qn{constructor(t){this.parallel=!0,this.time=1,this.id=y.create(y.TASK),this.task=t}run(){return we(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(t){$n.error(t)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}}class to{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&&_.assign(this.config,t),this.empty()}add(t,e,i){let s,o,r,a;const l=new Qn(t);return l.parent=this,h(e)?a=e:e&&(o=e.parallel,s=e.start,r=e.time,a=e.delay,i||(i=e.canUse)),r&&(l.time=r),!1===o&&(l.parallel=!1),i&&(l.canUse=i),n(a)?this.push(l,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(l,s))},a)),this.isComplete=!1,l}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 n=s+e.parallel;if(n>i.length&&(n=i.length),e.parallel>1)for(let e=s;e<n&&(t=i[e],t.parallel);e++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const i=e.length,s=this.finishedIndex+i;if(e.length){if(!this.running)return;s<this.total&&(t=this.list[s],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach(t=>{t.parallel=!1}),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const eo=se.get("Resource"),io={tasker:new to,map:{},get isComplete(){return so.tasker.isComplete},set(t,e){so.map[t]&&eo.repeat(t),so.map[t]=e},get:t=>so.map[t],remove(t){const e=so.map[t];e&&(e.destroy&&e.destroy(),delete so.map[t])},loadImage(t,e){return new Promise((i,s)=>{const n=this.setImage(t,t,e);n.load(()=>i(n),t=>s(t))})},setImage(t,e,i){let s;return r(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=ce.image(s)),so.set(t,e),e},destroy(){so.map={}}},so=io,no={maxRecycled:10,recycledList:[],patternTasker:new to({parallel:1}),get(t){let e=io.get(t.url);return e||io.set(t.url,e=ce.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||(te.image.isLarge(t)?t.url&&io.remove(t.url):(t.clearLevels(),oo.recycledList.push(t)))})},recyclePaint(t){oo.recycle(t.image)},clearRecycled(t){const e=oo.recycledList;(e.length>oo.maxRecycled||t)&&(e.forEach(e=>(!e.use||t)&&e.url&&io.remove(e.url)),e.length=0)},clearLevels(){},hasAlphaPixel:t=>Zn.alphaPixelTypes.some(e=>oo.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:"+Zn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Zn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){this.clearRecycled(!0)}},oo=no,{IMAGE:ro,create:ao}=y;class ho{get url(){return this.config.url}get crossOrigin(){const{crossOrigin:t}=this.config;return n(t)?te.image.crossOrigin:t}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=ao(ro),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,io.tasker.add(()=>we(this,void 0,void 0,function*(){return yield te.origin.loadImage(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,n,o,r,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=te.image.resize(this.view,t,e,n,o,void 0,r,i,s,a);return this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(t,e,i,s){const n=te.canvas.createPattern(t,e);return te.image.setPatternTransform(n,i,s),n}getLoadUrl(t){return this.url}setThumbView(t){}getThumbSize(t){}getMinLevel(){}getLevelData(t,e,i){}clearLevels(t){}destroy(){this.clearLevels();const{view:t}=this;t&&t.close&&t.close(),this.config={url:""},this.cache=this.view=null,this.waitComplete.length=0}}function lo(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function co(t,e){return Object.getOwnPropertyDescriptor(t,e)}function uo(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function go(t,e){return(i,s)=>_o(i,s,t,e&&e(s))}function po(t){return t}function _o(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};lo(t,e,Object.assign(n,s||{})),Yo(t,e,i)}function fo(t){return go(t)}function mo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function yo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function vo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),So(this))}}))}function wo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function xo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function bo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&So(this)}}))}function Eo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(So(this),this.__.__removeNaturalSize())}}))}function So(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function ko(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),So(this)}}))}const To=bo;function Bo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i)&&(Po(this),e&&(this.__.__useStroke=!0))}}))}function Po(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&So(t)}const Ro=Bo;function Lo(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Co(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Oo(t){return go(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;_.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Ao(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Mo(this)}}))}function Do(t){return go(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Io(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Io(this,t,e,i),this.mask&&Mo(this)}}))}function Mo(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Io(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||So(t))}function Fo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Wo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function zo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Uo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===se.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function Ho(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function No(t){return(e,i)=>{lo(e,"__DataProcessor",{get:()=>t})}}function Yo(t,e,i){const s=t.__DataProcessor.prototype,o="_"+e,r=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=uo(e,i);if(n(i))a.get=function(){return this[o]};else if("function"==typeof i)a.get=function(){const t=this[o];return null==t?i(this.__leaf):t};else if(u(i)){const t=p(i);a.get=function(){const e=this[o];return null==e?this[o]=t?{}:_.clone(i):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[o];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:h&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(a.get=function(){const t=this[o];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:h&&s.children.length?s.boxBounds.height:i}return t});let l,d=s;for(;!l&&d;)l=co(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),s[r]&&(a.set=s[r],delete s[r]),lo(s,e,a)}const Xo=new se("rewrite"),Vo=[],Go=["destroy","constructor"];function jo(t){return(e,i)=>{Vo.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function Ko(){return t=>{qo()}}function qo(t){Vo.length&&(Vo.forEach(e=>{t&&Xo.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Vo.length=0)}function Zo(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Go.includes(s)||e&&e.includes(s)))if(t.prototype){co(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Jo(){return t=>{ge.register(t)}}function $o(){return t=>{fe.register(t)}}setTimeout(()=>qo(!0));const{copy:Qo,toInnerPoint:tr,toOuterPoint:er,scaleOfOuter:ir,rotateOfOuter:sr,skewOfOuter:nr,multiplyParent:or,divideParent:rr,getLayout:ar}=Z,hr={},{round:lr}=Math,dr={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),gr(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)ur(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++)pr(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&pr(t),t.__updateChange()},updateAllChange(t){if(fr(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)_r(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,n,o){s||(s=t.__nowWorld),t.__worldFlipped||te.fullImageShadow?e.copyWorldByReset(i,s,t.__nowWorld,n,o):e.copyWorldToInner(i,s,t.__layout.renderBounds,n)},moveWorld(t,e,i=0,s,n){const o=u(e)?Object.assign({},e):{x:e,y:i};s?er(t.localTransform,o,o,!0):t.parent&&tr(t.parent.scrollWorldTransform,o,o,!0),cr.moveLocal(t,o.x,o.y,n)},moveLocal(t,e,i=0,s){u(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=lr(e),i=lr(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,o){cr.zoomOfLocal(t,mr(t,e),i,s,n,o)},zoomOfLocal(t,e,i,s=i,n,o){const r=t.__localMatrix;if(h(s)||(s&&(o=s),s=i),Qo(hr,r),ir(hr,e,i,s),cr.hasHighPosition(t))cr.setTransform(t,hr,n,o);else{const e=t.x+hr.e-r.e,a=t.y+hr.f-r.f;o&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},o):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){cr.rotateOfLocal(t,mr(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Qo(hr,n),sr(hr,e,i),cr.hasHighPosition(t)?cr.setTransform(t,hr,!1,s):t.set({x:t.x+hr.e-n.e,y:t.y+hr.f-n.f,rotation:M.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,o){cr.skewOfLocal(t,mr(t,e),i,s,n,o)},skewOfLocal(t,e,i,s=0,n,o){Qo(hr,t.__localMatrix),nr(hr,e,i,s),cr.setTransform(t,hr,n,o)},transformWorld(t,e,i,s){Qo(hr,t.worldTransform),or(hr,e),t.parent&&rr(hr,t.parent.scrollWorldTransform),cr.setTransform(t,hr,i,s)},transform(t,e,i,s){Qo(hr,t.localTransform),or(hr,e),cr.setTransform(t,hr,i,s)},setTransform(t,e,i,s){const n=t.__,o=n.origin&&cr.getInnerOrigin(t,n.origin),r=ar(e,o,n.around&&cr.getInnerOrigin(t,n.around));if(cr.hasOffset(t)&&(r.x-=n.offsetX,r.y-=n.offsetY),i){const e=r.scaleX/t.scaleX,i=r.scaleY/t.scaleY;if(delete r.scaleX,delete r.scaleY,o){Yt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=cr.getInnerOrigin(t,n.origin);ht.move(r,o.x-s.x,o.y-s.y)}t.set(r),t.scaleResize(e,i,!1)}else t.set(r,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return ir(i,cr.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>ht.tempToOuterOf(cr.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return Et.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Qo(hr,t.worldTransform),rr(hr,e.scrollWorldTransform),i?hr:Object.assign({},hr)),drop(t,e,i,s){t.setTransform(cr.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||cr.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,n=e.y*i;e.x-=s,e.y-=n,t.move(s,n),te.requestRender(()=>cr.animateMove(t,e,i))}}},cr=dr,{updateAllMatrix:ur,updateMatrix:gr,updateAllWorldOpacity:pr,updateAllChange:_r,updateChange:fr}=cr;function mr(t,e){return t.updateLayout(),t.parent?ht.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const yr={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.eraser||0===t.__.visible?null:t.__local||t.__layout,localStrokeBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localRenderBounds,maskLocalBoxBounds:(t,e)=>wr(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>wr(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>wr(t,e)&&t.__layout.localRenderBounds,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};let vr;function wr(t,e){return e||(vr=0),t.__.mask&&(vr=1),vr<0?null:(vr&&(vr=-1),!0)}const{updateBounds:xr}=dr,br={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:i}=t;for(let s=0,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),Er(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&n(i[t.parent.innerId]);)e.add(t.parent),t=t.parent;else for(;t.parent;)e.add(t.parent),t=t.parent},pushAllBranchStack(t,e){let i=e.length;const{children:s}=t;for(let t=0,i=s.length;t<i;t++)s[t].isBranch&&e.push(s[t]);for(let t=i,s=e.length;t<s;t++)Sr(e[t],e)},updateBounds(t,e){const i=[t];Sr(t,i),kr(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let n=t.length-1;n>-1;n--){i=t[n],s=i.children;for(let t=0,e=s.length;t<e;t++)xr(s[t]);e&&e===i||xr(i)}},move(t,e,i){let s;const{children:n}=t;for(let o=0,r=n.length;o<r;o++)s=(t=n[o]).__world,s.e+=e,s.f+=i,s.x+=e,s.y+=i,t.isBranch&&Tr(t,e,i)},scale(t,e,i,s,n,o,r){let a;const{children:h}=t,l=s-1,d=n-1;for(let c=0,u=h.length;c<u;c++)a=(t=h[c]).__world,a.a*=s,a.d*=n,(a.b||a.c)&&(a.b*=s,a.c*=n),a.e===a.x&&a.f===a.y?(a.x=a.e+=(a.e-o)*l+e,a.y=a.f+=(a.f-r)*d+i):(a.e+=(a.e-o)*l+e,a.f+=(a.f-r)*d+i,a.x+=(a.x-o)*l+e,a.y+=(a.y-r)*d+i),a.width*=s,a.height*=n,a.scaleX*=s,a.scaleY*=n,t.isBranch&&Br(t,e,i,s,n,o,r)}},{pushAllChildBranch:Er,pushAllBranchStack:Sr,updateBoundsByBranchStack:kr,move:Tr,scale:Br}=br,Pr={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:Rr,updateBounds:Lr}=dr,{toOuterOf:Cr,getPoints:Or,copy:Ar}=Yt,Dr="_localContentBounds",Mr="_worldContentBounds",Ir="_worldBoxBounds",Fr="_worldStrokeBounds";class Wr{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 Cr(this.contentBounds,this.leaf.__localMatrix,this[Dr]||(this[Dr]={})),this[Dr]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return Cr(this.contentBounds,this.leaf.__world,this[Mr]||(this[Mr]={})),this[Mr]}get worldBoxBounds(){return Cr(this.boxBounds,this.leaf.__world,this[Ir]||(this[Ir]={})),this[Ir]}get worldStrokeBounds(){return Cr(this.strokeBounds,this.leaf.__world,this[Fr]||(this[Fr]={})),this[Fr]}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 Lr(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,te.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 Z.defaultMatrix;case"page":t=e.zoomLayer;default:return Rr(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 jt(this.getInnerBounds(t)).toOuterOf(this.getTransform(e))}}getInnerBounds(t="box"){switch(t){case"render":return this.renderBounds;case"content":if(this.contentBounds)return this.contentBounds;case"box":return this.boxBounds;case"stroke":return this.strokeBounds}}getLocalBounds(t="box"){switch(t){case"render":return this.localRenderBounds;case"stroke":return this.localStrokeBounds;case"content":if(this.contentBounds)return this.localContentBounds;case"box":return this.leaf.__localBoxBounds}}getWorldBounds(t="box"){switch(t){case"render":return this.leaf.__world;case"stroke":return this.worldStrokeBounds;case"content":if(this.contentBounds)return this.worldContentBounds;case"box":return this.worldBoxBounds}}getLayoutBounds(t,e="world",i){const{leaf:s}=this;let n,o,r,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;r={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,o=Z.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),o=Rr(s,e,!0)}if(r||(r=Z.getLayout(o)),Ar(r,a),ht.copy(r,n),i){const{scaleX:t,scaleY:e}=r,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(r.scaleX/=i,r.scaleY/=s,r.width*=i,r.height*=s)}return r}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=Or(this.getInnerBounds(t));let o;switch(e){case"world":o=null;break;case"local":o=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:o=e}return n(o)||s.forEach(t=>i.innerToWorld(t,null,!1,o)),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,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class zr{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&te.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&te.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&te.event.stop(this.origin)}}class Ur extends zr{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Ur.ADD="child.add",Ur.REMOVE="child.remove",Ur.CREATED="created",Ur.MOUNTED="mounted",Ur.UNMOUNTED="unmounted",Ur.DESTROY="destroy";const Hr="property.scroll";class Nr extends zr{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Nr.CHANGE="property.change",Nr.LEAFER_CHANGE="property.leafer_change",Nr.SCROLL=Hr;const Yr={scrollX:Hr,scrollY:Hr};class Xr extends zr{constructor(t,e){super(t),Object.assign(this,e)}}Xr.LOAD="image.load",Xr.LOADED="image.loaded",Xr.ERROR="image.error";class Vr extends zr{static checkHas(t,e,i){"on"===i?e===qr?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Gr)||t.hasEvent(jr)||t.hasEvent(Kr),t.__hasWorldEvent=t.hasEvent(qr))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Gr,t),"inner"===e&&t.emit(jr,t)),t.emit(Kr,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(qr,this)}}Vr.RESIZE="bounds.resize",Vr.INNER="bounds.inner",Vr.LOCAL="bounds.local",Vr.WORLD="bounds.world";const{RESIZE:Gr,INNER:jr,LOCAL:Kr,WORLD:qr}=Vr,Zr={};[Gr,jr,Kr,qr].forEach(t=>Zr[t]=1);class Jr extends zr{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){u(t)?(super(Jr.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!n(this.resizingKeys[t.innerId])}}Jr.RESIZE="resize";class $r extends zr{constructor(t,e){super(t),this.data=e}}$r.REQUEST="watch.request",$r.DATA="watch.data";class Qr extends zr{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Qr.REQUEST="layout.request",Qr.START="layout.start",Qr.BEFORE="layout.before",Qr.LAYOUT="layout",Qr.AFTER="layout.after",Qr.AGAIN="layout.again",Qr.END="layout.end";class ta extends zr{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}ta.REQUEST="render.request",ta.CHILD_START="render.child_start",ta.CHILD_END="render.child_end",ta.START="render.start",ta.BEFORE="render.before",ta.RENDER="render",ta.AFTER="render.after",ta.AGAIN="render.again",ta.END="render.end",ta.NEXT="render.next";class ea extends zr{}ea.START="leafer.start",ea.BEFORE_READY="leafer.before_ready",ea.READY="leafer.ready",ea.AFTER_READY="leafer.after_ready",ea.VIEW_READY="leafer.view_ready",ea.VIEW_COMPLETED="leafer.view_completed",ea.STOP="leafer.stop",ea.RESTART="leafer.restart",ea.END="leafer.end",ea.UPDATE_MODE="leafer.update_mode",ea.TRANSFORM="leafer.transform",ea.MOVE="leafer.move",ea.SCALE="leafer.scale",ea.ROTATE="leafer.rotate",ea.SKEW="leafer.skew";const{MOVE:ia,SCALE:sa,ROTATE:na,SKEW:oa}=ea,ra={x:ia,y:ia,scaleX:sa,scaleY:sa,rotation:na,skewX:oa,skewY:oa},aa={};class ha{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(c(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)c(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,n,o;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const a=la(this,s,!0),h=r(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};h.forEach(t=>{t&&(o=a[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(l):a[t]=[l],Zr[t]&&Vr.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=r(t)?t.split(" "):t;if(e){let t,n,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const r=la(this,t);s.forEach(t=>{t&&(n=r[t],n&&(o=n.findIndex(t=>t.listener===e),o>-1&&n.splice(o,1),n.length||delete r[t],Zr[t]&&Vr.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):c(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=c(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):c(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 c(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));u(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&fe.has(t)&&(e=fe.get(t,{type:t,target:this,current:this}));const s=la(this,i)[t];if(s){let n;for(let o=0,r=s.length;o<r&&!((n=s[o])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),o--,r--),e&&e.isStopNow));o++);}this.syncEventer&&this.syncEventer.emitEvent(e,i)}emitEvent(t,e){t.current=this,this.emit(t.type,t,e)}hasEvent(t,e){if(this.syncEventer&&this.syncEventer.hasEvent(t,e))return!0;const{__bubbleMap:i,__captureMap:s}=this,o=i&&i[t],r=s&&s[t];return!!(n(e)?o||r:e?r:o)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function la(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:aa)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:aa)}}const{on:da,on_:ca,off:ua,off_:ga,once:pa,emit:_a,emitEvent:fa,hasEvent:ma,destroy:ya}=ha.prototype,va={on:da,on_:ca,off:ua,off_:ga,once:pa,emit:_a,emitEvent:fa,hasEvent:ma,destroyEventer:ya},wa=se.get("setAttr"),xa={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||a(e)||n(e)||(wa.warn(this.innerName,t,e),e=void 0),u(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Nr(Nr.LEAFER_CHANGE,this,t,s,e));const i=ra[t];i&&(this.emitEvent(new ea(i,this)),this.emitEvent(new ea(ea.TRANSFORM,this)))}this.emitPropertyEvent(Nr.CHANGE,t,s,e);const i=Yr[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const n=new Nr(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(n),this.leafer.emitEvent(n)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||n(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ba,multiplyParent:Ea,translateInner:Sa,defaultWorld:ka}=Z,{toPoint:Ta,tempPoint:Ba}=Et,Pa={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;Ea(this.__local||e,t?t.__scrollWorld||t.__world:ka,i,!!e.affectScaleOrRotation,n),s&&Sa(Object.assign(s,i),n.scrollX,n.scrollY)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(ba(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)&&(Ta(i.around||i.origin,t.boxBounds,Ba),Sa(e,-Ba.x,-Ba.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:Ra,updateAllMatrix:La}=dr,{updateBounds:Ca}=br,{toOuterOf:Oa,copyAndSpread:Aa,copy:Da}=Yt,{toBounds:Ma}=Wn,Ia={__updateWorldBounds(){const{__layout:t,__world:e}=this;Oa(t.renderBounds,e,e),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Vr.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Vr.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.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),Oa(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Oa(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Oa(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Ma(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(),La(this),Ca(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(La(this),Ca(this,this))):Ra(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Aa(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;h(i)&&i<=0?Da(e.renderBounds,e.strokeBounds):Aa(e.renderBounds,e.boxBounds,i)}},Fa={__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.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),dr.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);se.showBounds&&se.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:Wa}=yr,{hasSize:za}=Yt,Ua={__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&&za(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 n=t.getSameCanvas(!1,!0);this.__renderBranch(n,e),t.opacity=e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(n,i,i,s.__blendMode,!0),n.recycle(i)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Wa(i[s],e)||i[s].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Wa(i[s],e)||i[s].__clip(t,e)}}},Ha={},{LEAF:Na,create:Ya}=y,{stintSet:Xa}=_,{toInnerPoint:Va,toOuterPoint:Ga,multiplyParent:ja}=Z,{toOuterOf:Ka}=Yt,{copy:qa,move:Za}=ht,{moveLocal:Ja,zoomOfLocal:$a,rotateOfLocal:Qa,skewOfLocal:th,moveWorld:eh,zoomOfWorld:ih,rotateOfWorld:sh,skewOfWorld:nh,transform:oh,transformWorld:rh,setTransform:ah,getFlipTransform:hh,getLocalOrigin:lh,getRelativeWorld:dh,drop:ch}=dr;t.Leaf=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 m}get __LayoutProcessor(){return Wr}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=Ya(Na),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Ur.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(Ur.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Ur.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(Ur.MOUNTED)):this.__emitLifeEvent(Ur.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){n(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=n(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 ja(i,t.matrix,e,void 0,i),Ka(this.__layout.renderBounds,e,e),Xa(e,"half",i.half),Xa(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){let{scaleX:i,scaleY:s}=no.patternLocked?this.__world:this.__nowWorld;return t&&(i<0&&(i=-i),s<0&&(s=-s)),(!0===e||"zoom-in"===e&&i>1&&s>1)&&(i=s=1),Ha.scaleX=i,Ha.scaleY=s,Ha}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?dh(this,e):this.worldTransform,n=i?t:{};return Ka(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&qa(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&qa(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Va(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Ga(this.scrollWorldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Za(n,-o,-r),n}getInnerPoint(t,e,i,s){const n=s?t:{};return this.worldToInner(t,n,i,e),n}getInnerPointByBox(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Za(n,o,r),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){ah(this,t,e,i)}transform(t,e,i){oh(this,t,e,i)}move(t,e,i){Ja(this,t,e,i)}moveInner(t,e,i){eh(this,t,e,!0,i)}scaleOf(t,e,i,s,n){$a(this,lh(this,t),e,i,s,n)}rotateOf(t,e,i){Qa(this,lh(this,t),e,i)}skewOf(t,e,i,s,n){th(this,lh(this,t),e,i,s,n)}transformWorld(t,e,i){rh(this,t,e,i)}moveWorld(t,e,i){eh(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){ih(this,t,e,i,s,n)}rotateOfWorld(t,e){sh(this,t,e)}skewOfWorld(t,e,i,s,n){nh(this,t,e,i,s,n)}flip(t,e){oh(this,hh(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(){}getMotionPathData(){return de.need("path")}getMotionPoint(t){return de.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){ch(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):Yo(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=bo),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Ur(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Ur.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},t.Leaf=ve([Zo(xa),Zo(Pa),Zo(Ia),Zo(va),Zo(Fa)],t.Leaf);const{setListWithFn:uh}=Yt,{sort:gh}=br,{localBoxBounds:ph,localStrokeBounds:_h,localRenderBounds:fh,maskLocalBoxBounds:mh,maskLocalStrokeBounds:yh,maskLocalRenderBounds:vh}=yr,wh=new se("Branch");t.Branch=class extends t.Leaf{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(t,e){uh(e||this.__layout.boxBounds,this.children,this.__hasMask?mh:ph)}__updateStrokeBounds(t){uh(t||this.__layout.strokeBounds,this.children,this.__hasMask?yh:_h)}__updateRenderBounds(t){uh(t||this.__layout.renderBounds,this.children,this.__hasMask?vh:fh)}__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(gh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return wh.warn("add self or destroyed");const i=n(e);if(!t.__){if(c(t))return t.forEach(t=>{this.add(t,e),i||e++});t=ge.get(t.tag,t)}t.parent&&t.parent.remove(t),t.parent=this,i?this.children.push(t):this.children.splice(e,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1);const s=t.__layout;s.boxChanged||s.boxChange(),s.matrixChanged||s.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(Ur.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Ur.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)):n(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(Ur.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Ur.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Ur(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}},t.Branch=ve([Zo(Ua)],t.Branch);class xh{get length(){return this.list.length}constructor(t){this.reset(),t&&(c(t)?this.addList(t):this.add(t))}has(t){return t&&!n(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return n(e)?-1:e}add(t){const{list:e,keys:i}=this;n(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(n(i[t.innerId])){const{list:s}=this;for(let t=e,n=s.length;t<n;t++)i[s[t].innerId]++;0===e?s.unshift(t):(e>s.length&&(e=s.length),s.splice(e,0,t)),i[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let i;for(let s=0,o=e.length;s<o;s++)n(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;n(i)||e.splice(i,1)}sort(t){const{list:e}=this;t?e.sort((t,e)=>e.__level-t.__level):e.sort((t,e)=>t.__level-e.__level)}forEach(t){this.list.forEach(t)}clone(){const t=new xh;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let i=0,s=t.length;i<s;i++)e[t[i].innerId]=i}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}class bh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(c(t)?this.addList(t):this.add(t))}has(t){return!n(this.keys[t.innerId])}without(t){return n(this.keys[t.innerId])}sort(t){const{levels:e}=this;t?e.sort((t,e)=>e-t):e.sort((t,e)=>t-e)}addList(t){t.forEach(t=>{this.add(t)})}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}class Eh extends De{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=te.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}qn(OffscreenCanvasRenderingContext2D.prototype),qn(Path2D.prototype);const{mineType:Sh}=Zn;function kh(t,e){te.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Sh(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:Sh(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",te.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then(t=>{e(t)}).catch(t=>{i(t)})},s.onerror=t=>i(t),s.send()})},te.canvas=ce.canvas(),te.conicGradientSupport=!!te.canvas.context.createConicGradient}Object.assign(ce,{canvas:(t,e)=>new Eh(t,e),image:t=>new ho(t)}),te.name="web",te.isWorker=!0,te.backgrounder=!0,te.requestRender=function(t){requestAnimationFrame(t)},lo(te,"devicePixelRatio",{get:()=>1});const{userAgent:Th}=navigator;Th.indexOf("Firefox")>-1?(te.conicGradientRotate90=!0,te.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(te.fullImageShadow=!0),Th.indexOf("Windows")>-1?(te.os="Windows",te.intWheelDeltaY=!0):Th.indexOf("Mac")>-1?te.os="Mac":Th.indexOf("Linux")>-1&&(te.os="Linux");class Bh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new xh;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 xh,this.target=t,e&&(this.config=_.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(ta.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===Ur.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new $r($r.DATA,{updatedList:this.updatedList})),this.__updatedList=new xh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Nr.CHANGE,this.__onAttrChange,this],[[Ur.ADD,Ur.REMOVE],this.__onChildEvent,this],[$r.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:Ph,updateBounds:Rh,updateChange:Lh}=dr,{pushAllChildBranch:Ch,pushAllParent:Oh}=br;const{worldBounds:Ah}=yr;class Dh{constructor(t){this.updatedBounds=new jt,this.beforeBounds=new jt,this.afterBounds=new jt,c(t)&&(t=new xh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Ah)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Ah),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:Mh,updateAllChange:Ih}=dr,Fh=se.get("Layouter");class Wh{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new bh,this.target=t,e&&(this.config=_.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(Qr.START),this.layoutOnce(),t.emitEvent(new Qr(Qr.END,this.layoutedBlocks,this.times))}catch(t){Fh.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Fh.warn("layouting"):this.times>3?Fh.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit($r.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=ae.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=Qr,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Qr(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Ph(t,!0),e.add(t),t.isBranch&&Ch(t,e),Oh(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Oh(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Rh(s[t])}Rh(i)}})}(this.__levelList),function(t){t.list.forEach(Lh)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Qr(o,a,this.times)),i.emitEvent(new Qr(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,ae.end(e)}fullLayout(){const t=ae.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=Qr,o=this.getBlocks(new xh(e));e.emitEvent(new Qr(i,o,this.times)),Wh.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new Qr(s,o,this.times)),e.emitEvent(new Qr(n,o,this.times)),this.addBlocks(o),ae.end(t)}static fullLayout(t){Mh(t,!0),t.isBranch?br.updateBounds(t):dr.updateBounds(t),Ih(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Dh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Dh(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_([[Qr.REQUEST,this.layout,this],[Qr.AGAIN,this.layoutAgain,this],[$r.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const zh=se.get("Renderer");class Uh{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=_.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(Qr.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(ta.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(ta.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(ta.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new jt,zh.log(e.innerName,"---\x3e");try{this.emitRender(ta.START),this.renderOnce(t),this.emitRender(ta.END,this.totalBounds),no.clearRecycled()}catch(t){this.rendering=!1,zh.error(t)}zh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return zh.warn("rendering");if(this.times>3)return zh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new jt,this.renderOptions={},t)this.emitRender(ta.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(ta.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(ta.RENDER,this.renderBounds,this.renderOptions),this.emitRender(ta.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=ae.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new jt(s);i.save(),s.spread(Uh.clipSpread).ceil();const{ceilPartPixel:o}=this.config;i.clipWorld(s,o),i.clearWorld(s,o),this.__render(s,n),i.restore(),ae.end(e)}fullRender(){const t=ae.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),ae.end(t)}__render(t,e){const{canvas:i,target:s}=this,n=t.includes(s.__world),o=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),se.showRepaint&&se.drawRepaint(i,t),this.config.useCellRender&&(o.cellList=this.getCellList()),te.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){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new jt;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 te.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()};te.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new jt(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 jt(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||zh.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new ta(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[ta.REQUEST,this.update,this],[Qr.END,this.__onLayoutEnd,this],[ta.AGAIN,this.renderAgain,this],[Jr.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Uh.clipSpread=10;const Hh={},{copyRadiusPoint:Nh}=ht,{hitRadiusPoint:Yh}=Yt;class Xh{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new xh(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new xh;if(t.length){let e;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=t.length;s<o;s++)if(e=t[s],(i||dr.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&dr.hasParent(t,e))){n.reset();break}return n.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>dr.worldHittable(t))}getPath(t){const e=new xh,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 xh;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new xh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,n;const{point:o}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],n=i.__,n.visible&&(!e||n.mask))if(s=Yh(i.__world,n.hitRadius?Nh(Hh,o,n.hitRadius):o),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__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,n=[];const{children:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[s],i.__.mask&&n.push(i),i===t){if(n&&!n.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()}}class Vh{constructor(t,e){this.config={},e&&(this.config=_.default(e,this.config)),this.picker=new Xh(this.target=t,this),this.finder=ce.finder&&ce.finder()}getByPoint(t,e,i){const{target:s,picker:n}=this;return te.backgrounder&&s&&s.updateLayout(),n.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):de.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Gh(t){return go(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function jh(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Kh(){return(t,e)=>{const i="_"+e;lo(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}Object.assign(ce,{watcher:(t,e)=>new Bh(t,e),layouter:(t,e)=>new Wh(t,e),renderer:(t,e,i)=>new Uh(t,e,i),selector:(t,e)=>new Vh(t,e)}),te.layout=Wh.fullLayout,te.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new xh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const qh={},Zh={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}},Jh=Zt,$h={},Qh={},tl={},el={},il={},sl={apply(){de.need("filter")}},nl={},ol={setStyleName:()=>de.need("state"),set:()=>de.need("state")},rl={list:{},register(t,e){rl.list[t]=e},get:t=>rl.list[t]},{parse:al,objectToCanvasData:hl}=ns,{stintSet:ll}=_,{hasTransparent:dl}=Zh,cl={originPaint:{}},ul=se.get("UIData");class gl extends m{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;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,t.strokeWidth):t.strokeWidth}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!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,ul.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,ul.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),r(t)||!t?(ll(this,"__isTransparentFill",dl(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):u(t)&&this.__setPaint("fill",t)}setStroke(t){r(t)||!t?(ll(this,"__isTransparentStroke",dl(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):u(t)&&this.__setPaint("stroke",t)}setPath(t){const e=r(t);e||t&&u(t[0])?(this.__setInput("path",t),this._path=e?al(t):hl(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){pl(this,"shadow",t)}setInnerShadow(t){pl(this,"innerShadow",t)}setFilter(t){pl(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Qh.compute("fill",this.__leaf),e&&Qh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),n(t.strokeWidthFixed)||(i=t.strokeWidthFixed)),i){const t=this.__leaf.getClampRenderScale();return t>1?e/t:e}return e}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),c(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=cl)):(this.__isStrokes=!0,this._stroke||(this._stroke=cl))}__removePaint(t,e){e&&this.__removeInput(t),tl.recycleImage(t,this),"fill"===t?(ll(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(ll(this,"__isAlphaPixelStroke",void 0),ll(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function pl(t,e,i){t.__setInput(e,i),c(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}class _l extends gl{}class fl extends _l{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)}}class ml extends _l{__getInputData(t,e){const i=super.__getInputData(t,e);return Ae.forEach(t=>delete i[t]),i}}class yl extends fl{}class vl extends gl{get __usePathBox(){return this.points||this.__pathInputed}}class wl extends gl{get __boxStroke(){return!this.__pathInputed}}class xl extends gl{get __boxStroke(){return!this.__pathInputed}}class bl extends vl{}class El extends gl{}class Sl extends gl{get __pathInputed(){return 2}}class kl extends _l{}const Tl={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Bl extends gl{get __useNaturalRatio(){return!1}setFontWeight(t){r(t)?(this.__setInput("fontWeight",t),t=Tl[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=ge.get("Rect",0);const n=e.__layout,o=i.__layout;s||(i.parent=e,i.__world=e.__world,o.boxBounds=n.boxBounds),i.set(t),o.strokeChanged&&n.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}}class Pl extends wl{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:"image",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}}class Rl extends wl{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const{max:Ll,add:Cl}=k,Ol={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,o=this.__box;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),o&&(t=Ll(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:n,filter:o,renderSpread:r}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=il.getShadowRenderSpread(this,e)),s&&(t=Ll(t,s)),o&&(t=Cl(t,sl.getSpread(o))),r&&(t=Cl(t,r)),a&&(t=Cl(t,a));let l=t;return i&&(l=Ll(l,il.getInnerShadowSpread(this,i))),n&&(l=Ll(l,n)),this.__layout.renderShapeSpread=l,h?Ll(h.__updateRenderSpread(),t):t}},{stintSet:Al}=_,Dl={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Al(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Al(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,n=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Al(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!il.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(c(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),Al(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){Ml(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:o,__drawAfterFill:r,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=Qh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&il.shadow(this,t,h),a&&(s.__isStrokes?Qh.strokes(o,this,t,e):Qh.stroke(o,this,t,e)),n&&(s.__isFills?Qh.fills(n,this,t,e):Qh.fill(n,this,t,e)),r&&this.__drawAfterFill(t,e),d&&il.innerShadow(this,t,h),o&&!a&&(s.__isStrokes?Qh.strokes(o,this,t,e):Qh.stroke(o,this,t,e)),c&&sl.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?Qh.strokes(o,this,t,e):Qh.stroke(o,this,t,e)),h){const e=s.shadow[0],{scaleX:i,scaleY:n}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*n,e.blur*i,Zh.string(e.color))}n&&(s.__isFills?Qh.fills(n,this,t,e):Qh.fill(n,this,t,e)),h&&t.restore(),r&&this.__drawAfterFill(t,e),o&&!a&&(s.__isStrokes?Qh.strokes(o,this,t,e):Qh.stroke(o,this,t,e))}}else s.__pathForRender?Ml(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:n}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?Qh.fills(s,this,t,e):Qh.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?Qh.strokes(n,this,t,e):Qh.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 Ml(t,e,i){const{fill:s,stroke:n,__drawAfterFill:o,__fillAfterStroke:r}=t.__;t.__drawRenderPath(e),r&&Qh.stroke(n,t,e,i),s&&Qh.fill(s,t,e,i),o&&t.__drawAfterFill(e,i),n&&!r&&Qh.stroke(n,t,e,i)}const Il={__drawFast(t,e){let{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;const{fill:r,stroke:a,__drawAfterFill:h}=this.__;if(r&&(t.fillStyle=r,t.fillRect(i,s,n,o)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:r,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(r){case"center":t.strokeRect(0,0,n,o);break;case"inside":n-=h,o-=h,n<0||o<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,o),t.restore()):t.strokeRect(i+l,s+l,n,o);break;case"outside":t.strokeRect(i-l,s-l,n+h,o+h)}}}};var Fl,Wl;t.UI=Fl=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){M.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 jn.set(this.path=t||[]),t||this.__drawPathByBox(jn),jn}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return r(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return de.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return de.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(jn.set(i=[]),this.__drawPathByBox(jn,!e)),t?ns.toCanvasData(i,!0):i}getPathString(t,e,i){return ns.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||nl.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Vn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&$h.addArrows(this)):t.__pathForRender&&(t.__pathForRender=void 0)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path,!0)}__drawPathByData(t,e,i){e?rn.drawPathByData(t,e):this.__drawPathByBox(t,i)}__drawPathByBox(t,e){const{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius&&!e){const{cornerRadius:e}=this.__;t.roundRect(i,s,n,o,h(e)?[e]:e)}else t.rect(i,s,n,o);t.closePath()}drawImagePlaceholder(t,e,i){Qh.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),de.need("animate")}killAnimate(t,e){}export(t,e){return de.need("export")}syncExport(t,e){return de.need("export")}clone(t){const e=_.clone(this.toJSON());return t&&Object.assign(e,t),Fl.one(e)}static one(t,e,i,s,n){return ge.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Jo()(this)}static registerData(t){No(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},ve([No(gl)],t.UI.prototype,"__",void 0),ve([Kh()],t.UI.prototype,"zoomLayer",void 0),ve([fo("")],t.UI.prototype,"id",void 0),ve([fo("")],t.UI.prototype,"name",void 0),ve([fo("")],t.UI.prototype,"className",void 0),ve([Co("pass-through")],t.UI.prototype,"blendMode",void 0),ve([Ao(1)],t.UI.prototype,"opacity",void 0),ve([Do(!0)],t.UI.prototype,"visible",void 0),ve([Co(!1)],t.UI.prototype,"locked",void 0),ve([Oo(!1)],t.UI.prototype,"dim",void 0),ve([Oo(!1)],t.UI.prototype,"dimskip",void 0),ve([Fo(0)],t.UI.prototype,"zIndex",void 0),ve([Wo(!1)],t.UI.prototype,"mask",void 0),ve([zo(!1)],t.UI.prototype,"eraser",void 0),ve([mo(0,!0)],t.UI.prototype,"x",void 0),ve([mo(0,!0)],t.UI.prototype,"y",void 0),ve([bo(100,!0)],t.UI.prototype,"width",void 0),ve([bo(100,!0)],t.UI.prototype,"height",void 0),ve([wo(1,!0)],t.UI.prototype,"scaleX",void 0),ve([wo(1,!0)],t.UI.prototype,"scaleY",void 0),ve([xo(0,!0)],t.UI.prototype,"rotation",void 0),ve([xo(0,!0)],t.UI.prototype,"skewX",void 0),ve([xo(0,!0)],t.UI.prototype,"skewY",void 0),ve([mo(0,!0)],t.UI.prototype,"offsetX",void 0),ve([mo(0,!0)],t.UI.prototype,"offsetY",void 0),ve([yo(0,!0)],t.UI.prototype,"scrollX",void 0),ve([yo(0,!0)],t.UI.prototype,"scrollY",void 0),ve([vo()],t.UI.prototype,"origin",void 0),ve([vo()],t.UI.prototype,"around",void 0),ve([fo(!1)],t.UI.prototype,"lazy",void 0),ve([Eo(1)],t.UI.prototype,"pixelRatio",void 0),ve([Lo(0)],t.UI.prototype,"renderSpread",void 0),ve([ko()],t.UI.prototype,"path",void 0),ve([To()],t.UI.prototype,"windingRule",void 0),ve([To(!0)],t.UI.prototype,"closed",void 0),ve([bo(0)],t.UI.prototype,"padding",void 0),ve([bo(!1)],t.UI.prototype,"lockRatio",void 0),ve([bo()],t.UI.prototype,"widthRange",void 0),ve([bo()],t.UI.prototype,"heightRange",void 0),ve([fo(!1)],t.UI.prototype,"draggable",void 0),ve([fo()],t.UI.prototype,"dragBounds",void 0),ve([fo("auto")],t.UI.prototype,"dragBoundsType",void 0),ve([fo(!1)],t.UI.prototype,"editable",void 0),ve([Uo(!0)],t.UI.prototype,"hittable",void 0),ve([Uo("path")],t.UI.prototype,"hitFill",void 0),ve([Ro("path")],t.UI.prototype,"hitStroke",void 0),ve([Uo(!1)],t.UI.prototype,"hitBox",void 0),ve([Uo(!0)],t.UI.prototype,"hitChildren",void 0),ve([Uo(!0)],t.UI.prototype,"hitSelf",void 0),ve([Uo()],t.UI.prototype,"hitRadius",void 0),ve([Ho("")],t.UI.prototype,"cursor",void 0),ve([Co()],t.UI.prototype,"fill",void 0),ve([Ro(void 0,!0)],t.UI.prototype,"stroke",void 0),ve([Ro("inside")],t.UI.prototype,"strokeAlign",void 0),ve([Ro(1,!0)],t.UI.prototype,"strokeWidth",void 0),ve([Ro(!1)],t.UI.prototype,"strokeWidthFixed",void 0),ve([Ro("none")],t.UI.prototype,"strokeCap",void 0),ve([Ro("miter")],t.UI.prototype,"strokeJoin",void 0),ve([Ro()],t.UI.prototype,"dashPattern",void 0),ve([Ro(0)],t.UI.prototype,"dashOffset",void 0),ve([Ro(10)],t.UI.prototype,"miterLimit",void 0),ve([To(0)],t.UI.prototype,"cornerRadius",void 0),ve([To()],t.UI.prototype,"cornerSmoothing",void 0),ve([Gh()],t.UI.prototype,"shadow",void 0),ve([Gh()],t.UI.prototype,"innerShadow",void 0),ve([Gh()],t.UI.prototype,"blur",void 0),ve([Gh()],t.UI.prototype,"backgroundBlur",void 0),ve([Gh()],t.UI.prototype,"grayscale",void 0),ve([Gh()],t.UI.prototype,"filter",void 0),ve([Co()],t.UI.prototype,"placeholderColor",void 0),ve([fo(100)],t.UI.prototype,"placeholderDelay",void 0),ve([fo({})],t.UI.prototype,"data",void 0),ve([jo(t.Leaf.prototype.reset)],t.UI.prototype,"reset",null),t.UI=Fl=ve([Zo(Ol),Zo(Dl),Ko()],t.UI),t.Group=class extends t.UI{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);return this.childlessJSON||(e.children=this.children.map(e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},ve([No(_l)],t.Group.prototype,"__",void 0),ve([bo(0)],t.Group.prototype,"width",void 0),ve([bo(0)],t.Group.prototype,"height",void 0),t.Group=ve([Zo(t.Branch),Jo()],t.Group);const zl=se.get("Leafer");t.Leafer=Wl=class extends t.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&io.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),Wl.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,_.assign(s,t));const n=this.canvas=ce.canvas(s);this.__controllers.push(this.renderer=ce.renderer(this,n,s),this.watcher=ce.watcher(this,s),this.layouter=ce.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),e||(this.selector=ce.selector(this),this.interaction=ce.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ce.hitCanvasManager()),this.canvasManager=new ye,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(n),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Pr.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(ea.RESTART):this.emitLeafer(ea.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(ea.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=_.copyAttrs({},t,Ae);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new jt(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=_.copyAttrs({},this.canvas,Ae);e.resize(t),this.updateLazyBounds(),this.__onResize(new Jr(t,i))}__onResize(t){this.emitEvent(t),_.copyAttrs(this.__,t,Ae),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 qt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Ae.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(ea.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Ae.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=_.copyAttrs({},s,Ae);n[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(n)}__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(ea.BEFORE_READY),this.emitLeafer(ea.READY),this.emitLeafer(ea.AFTER_READY),Pr.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(ea.VIEW_READY),Pr.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:o}=this;const r="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,r.x+r.width)),i||(n=Math.max(1,r.y+r.height)),this.__doResize({width:s,height:n,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Pr.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(ea.VIEW_COMPLETED),Pr.run(this.__viewCompletedWait),this.viewCompleted=!0)})}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender(()=>this.interaction.updateCursor())}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return de.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 ea(t,this))}__listenEvents(){const t=ae.start("FirstCreate "+this.innerName);this.once([[ea.START,()=>ae.end(t)],[Qr.START,this.updateLazyBounds,this],[ta.START,this.__onCreated,this],[ta.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[$r.DATA,this.__onWatchData,this],[Qr.END,this.__onLayoutEnd,this],[ta.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Wl.list.remove(this);try{this.stop(),this.emitLeafer(ea.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){zl.error(t)}}};t?e():setTimeout(e)}},t.Leafer.list=new xh,ve([No(ml)],t.Leafer.prototype,"__",void 0),ve([bo()],t.Leafer.prototype,"pixelRatio",void 0),ve([fo("normal")],t.Leafer.prototype,"mode",void 0),t.Leafer=Wl=ve([Jo()],t.Leafer),t.Rect=class extends t.UI{get __tag(){return"Rect"}},ve([No(wl)],t.Rect.prototype,"__",void 0),t.Rect=ve([Zo(Il),Ko(),Jo()],t.Rect);const{add:Ul,includes:Hl,scroll:Nl}=Yt,Yl=t.Rect.prototype,Xl=t.Group.prototype;t.Box=class extends t.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.pathInputed){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:n,boxBounds:o}=s,{overflow:r}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=r&&r.includes("scroll"))&&(Ul(a,o),Nl(a,i)),this.__updateRectRenderBounds(),t=!Hl(o,a),t&&"show"===r&&Ul(n,a)}else this.__updateRectRenderBounds();_.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))}},ve([No(fl)],t.Box.prototype,"__",void 0),ve([bo(100)],t.Box.prototype,"width",void 0),ve([bo(100)],t.Box.prototype,"height",void 0),ve([fo(!1)],t.Box.prototype,"resizeChildren",void 0),ve([Lo("show")],t.Box.prototype,"overflow",void 0),ve([jo(Yl.__updateStrokeSpread)],t.Box.prototype,"__updateStrokeSpread",null),ve([jo(Yl.__updateRenderSpread)],t.Box.prototype,"__updateRectRenderSpread",null),ve([jo(Yl.__updateBoxBounds)],t.Box.prototype,"__updateRectBoxBounds",null),ve([jo(Yl.__updateStrokeBounds)],t.Box.prototype,"__updateStrokeBounds",null),ve([jo(Yl.__updateRenderBounds)],t.Box.prototype,"__updateRectRenderBounds",null),ve([jo(Yl.__updateChange)],t.Box.prototype,"__updateRectChange",null),ve([jo(Yl.__render)],t.Box.prototype,"__renderRect",null),ve([jo(Xl.__render)],t.Box.prototype,"__renderGroup",null),t.Box=ve([Ko(),Jo()],t.Box),t.Frame=class extends t.Box{get __tag(){return"Frame"}get isFrame(){return!0}},ve([No(yl)],t.Frame.prototype,"__",void 0),ve([Co("#FFFFFF")],t.Frame.prototype,"fill",void 0),ve([Lo("hide")],t.Frame.prototype,"overflow",void 0),t.Frame=ve([Jo()],t.Frame);const{moveTo:Vl,closePath:Gl,ellipse:jl}=Bs;t.Ellipse=class extends t.UI{get __tag(){return"Ellipse"}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:n}=this.__,o=t/2,r=e/2,a=this.__.path=[];let h;i?s||n?(i<1?jl(a,o,r,o*i,r*i,0,s,n,!1):h=!0,jl(a,o,r,o,r,0,n,s,!0)):(i<1&&(jl(a,o,r,o*i,r*i),Vl(a,t,r)),jl(a,o,r,o,r,0,360,0,!0)):s||n?(Vl(a,o,r),jl(a,o,r,o,r,0,s,n,!1)):jl(a,o,r,o,r),h||Gl(a),te.ellipseToCurve&&(this.__.path=this.getPath(!0))}},ve([No(xl)],t.Ellipse.prototype,"__",void 0),ve([To(0)],t.Ellipse.prototype,"innerRadius",void 0),ve([To(0)],t.Ellipse.prototype,"startAngle",void 0),ve([To(0)],t.Ellipse.prototype,"endAngle",void 0),t.Ellipse=ve([Jo()],t.Ellipse);const{sin:Kl,cos:ql,PI:Zl}=Math,{moveTo:Jl,lineTo:$l,closePath:Ql,drawPoints:td}=Bs;t.Polygon=class extends t.UI{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)td(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,o=i/2,r=s/2;Jl(e,o,0);for(let t=1;t<n;t++)$l(e,o+o*Kl(2*t*Zl/n),r-r*ql(2*t*Zl/n));Ql(e)}}},ve([No(bl)],t.Polygon.prototype,"__",void 0),ve([To(3)],t.Polygon.prototype,"sides",void 0),ve([To()],t.Polygon.prototype,"points",void 0),ve([To(0)],t.Polygon.prototype,"curve",void 0),t.Polygon=ve([Ko(),Jo()],t.Polygon);const{sin:ed,cos:id,PI:sd}=Math,{moveTo:nd,lineTo:od,closePath:rd}=Bs;t.Star=class extends t.UI{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,o=e/2,r=this.__.path=[];nd(r,n,0);for(let t=1;t<2*i;t++)od(r,n+(t%2==0?n:n*s)*ed(t*sd/i),o-(t%2==0?o:o*s)*id(t*sd/i));rd(r)}},ve([No(El)],t.Star.prototype,"__",void 0),ve([To(5)],t.Star.prototype,"corners",void 0),ve([To(.382)],t.Star.prototype,"innerRadius",void 0),t.Star=ve([Jo()],t.Star);const{moveTo:ad,lineTo:hd,drawPoints:ld}=Bs,{rotate:dd,getAngle:cd,getDistance:ud,defaultPoint:gd}=ht;t.Line=class extends t.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&dd(i,e),i}set toPoint(t){this.width=ud(gd,t),this.rotation=cd(gd,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?ld(e,t.points,t.curve,t.closed):(ad(e,0,0),hd(e,this.width,0))}},ve([No(vl)],t.Line.prototype,"__",void 0),ve([Bo("center")],t.Line.prototype,"strokeAlign",void 0),ve([bo(0)],t.Line.prototype,"height",void 0),ve([To()],t.Line.prototype,"points",void 0),ve([To(0)],t.Line.prototype,"curve",void 0),ve([To(!1)],t.Line.prototype,"closed",void 0),t.Line=ve([Jo()],t.Line),t.Image=class extends t.Rect{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return c(t)&&t[0].image}},ve([No(Pl)],t.Image.prototype,"__",void 0),ve([bo("")],t.Image.prototype,"url",void 0),t.Image=ve([Jo()],t.Image);const pd=t.Image;t.Canvas=class extends t.Rect{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=ce.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new ho({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Xr(Xr.LOADED,{image:t}))})}draw(t,e,i,s){const n=new ft(t.worldTransform).invert(),o=new ft;e&&o.translate(e.x,e.y),i&&(h(i)?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),n.multiplyParent(o),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}},ve([No(Rl)],t.Canvas.prototype,"__",void 0),ve([jh(100)],t.Canvas.prototype,"width",void 0),ve([jh(100)],t.Canvas.prototype,"height",void 0),ve([jh(1)],t.Canvas.prototype,"pixelRatio",void 0),ve([jh(!0)],t.Canvas.prototype,"smooth",void 0),ve([fo(!1)],t.Canvas.prototype,"safeResize",void 0),ve([jh()],t.Canvas.prototype,"contextSettings",void 0),t.Canvas=ve([Jo()],t.Canvas);const{copyAndSpread:_d,includes:fd,spread:md,setList:yd}=Yt,{stintSet:vd}=_;t.Text=class extends t.UI{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:o,italic:r,textCase:a,textOverflow:h,padding:l,width:d,height:c}=t;t.__lineHeight=Jh.number(e,n),t.__letterSpacing=Jh.number(i,n),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${r?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==o?o+" ":""}${n||12}px ${s||"caption"}`,vd(t,"__padding",l&&M.fourNumber(l)),vd(t,"__clipText","show"!==h&&!t.__autoSize),vd(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=qh.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:o,__autoHeight:r}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&md(a,i/2),o||r){if(h.x=o?a.x:0,h.y=r?a.y:0,h.width=o?a.width:t.width,h.height=r?a.height:t.height,n){const[e,i,s,n]=t.__padding;o&&(h.x-=n,h.width+=i+n),r&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),_.stintSet(this,"isOverflow",!fd(h,a)),this.isOverflow?(yd(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;_d(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()}},ve([No(Bl)],t.Text.prototype,"__",void 0),ve([bo(0)],t.Text.prototype,"width",void 0),ve([bo(0)],t.Text.prototype,"height",void 0),ve([Co()],t.Text.prototype,"boxStyle",void 0),ve([fo(!1)],t.Text.prototype,"resizeFontSize",void 0),ve([Co("#000000")],t.Text.prototype,"fill",void 0),ve([Bo("outside")],t.Text.prototype,"strokeAlign",void 0),ve([Uo("all")],t.Text.prototype,"hitFill",void 0),ve([bo("")],t.Text.prototype,"text",void 0),ve([bo("")],t.Text.prototype,"placeholder",void 0),ve([bo("caption")],t.Text.prototype,"fontFamily",void 0),ve([bo(12)],t.Text.prototype,"fontSize",void 0),ve([bo("normal")],t.Text.prototype,"fontWeight",void 0),ve([bo(!1)],t.Text.prototype,"italic",void 0),ve([bo("none")],t.Text.prototype,"textCase",void 0),ve([bo("none")],t.Text.prototype,"textDecoration",void 0),ve([bo(0)],t.Text.prototype,"letterSpacing",void 0),ve([bo({type:"percent",value:1.5})],t.Text.prototype,"lineHeight",void 0),ve([bo(0)],t.Text.prototype,"paraIndent",void 0),ve([bo(0)],t.Text.prototype,"paraSpacing",void 0),ve([bo("x")],t.Text.prototype,"writingMode",void 0),ve([bo("left")],t.Text.prototype,"textAlign",void 0),ve([bo("top")],t.Text.prototype,"verticalAlign",void 0),ve([bo(!0)],t.Text.prototype,"autoSizeAlign",void 0),ve([bo("normal")],t.Text.prototype,"textWrap",void 0),ve([bo("show")],t.Text.prototype,"textOverflow",void 0),ve([Co(!1)],t.Text.prototype,"textEditing",void 0),t.Text=ve([Jo()],t.Text),t.Path=class extends t.UI{get __tag(){return"Path"}},ve([No(Sl)],t.Path.prototype,"__",void 0),ve([Bo("center")],t.Path.prototype,"strokeAlign",void 0),t.Path=ve([Jo()],t.Path),t.Pen=class extends t.Group{get __tag(){return"Pen"}setStyle(e){const i=this.pathElement=new t.Path(e);return this.pathStyle=e,this.__path=i.path||(i.path=[]),this.add(i),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,o){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,n){return this}ellipse(t,e,i,s,n,o,r,a){return this}arc(t,e,i,s,n,o){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,o,r,a){return this}drawArc(t,e,i,s,n,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},ve([No(kl)],t.Pen.prototype,"__",void 0),ve([(t,e)=>{lo(t,e,{get(){return this.__path}})}],t.Pen.prototype,"path",void 0),t.Pen=ve([Zo(Xs,["set","path","paint"]),Jo()],t.Pen),t.App=class extends t.Leafer{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:n}=t;e&&(this.ground=this.addLeafer(e)),(i||n)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||n)&&(this.sky=this.addLeafer(s)),n&&ce.editor(n,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(e){const i=new t.Leafer(e);return this.add(i),i}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),n(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))}__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&&_.assign(e,t),this.autoLayout&&_.copyAttrs(e,this,Ae),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Qr.END,this.__onReady,this],[ta.START,this.__onCreated,this],[ta.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(ta.END,this.__onChildRenderEnd,this))}},t.App=ve([Jo()],t.App);const wd={},xd={isHoldSpaceKey:()=>xd.isHold("Space"),isHold:t=>wd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){wd[t]||(wd[t]=!0)},setUpCode(t){wd[t]=!1}},bd={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Ed extends zr{get spaceKey(){return xd.isHoldSpaceKey()}get left(){return bd.left(this)}get right(){return bd.right(this)}get middle(){return bd.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return xd.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){fe.changeName(t,e)}}const{min:Sd,max:kd,abs:Td}=Math,{float:Bd,sign:Pd}=M,{minX:Rd,maxX:Ld,minY:Cd,maxY:Od}=Yt,Ad=new jt,Dd=new jt,Md={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Id.getValidMove(t.__localBoxBounds,Id.getDragBounds(t),s,e,!0),Id.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:o}=t;n&&Id.getValidScaleOf(t.__localBoxBounds,Id.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&&t[s]>e[s],getValidMove(t,e,i,s,n){const o=t.x+s.x,r=t.y+s.y,a=o+t.width,h=r+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),Id.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),Id.isInnerMode(t,e,i,"height")?r>e.y?s.y+=e.y-r:h<d&&(s.y+=d-h):r<e.y?s.y+=e.y-r:h>d&&(s.y+=d-h),s.x=Bd(s.x),s.y=Bd(s.y),s},getValidScaleOf(t,e,i,s,n,o,r){r||(n=Object.assign({},n)),Dd.set(e),Ad.set(t).scaleOf(s,n.x,n.y);const h=(s.x-t.x)/t.width,l=1-h,d=(s.y-t.y)/t.height,c=1-d;let u,g,p,_,f=1,m=1;return Id.isInnerMode(t,e,i,"width")?(n.x<0&&Ad.scaleOf(s,f=1/n.x,1),p=Bd(Ad.minX-Dd.minX),_=Bd(Dd.maxX-Ad.maxX),u=h&&p>0?1+p/(h*Ad.width):1,g=l&&_>0?1+_/(l*Ad.width):1,f*=kd(u,g)):(n.x<0&&((Bd(Rd(t)-Rd(e))<=0||Bd(Ld(e)-Ld(t))<=0)&&Ad.scaleOf(s,f=1/n.x,1),Ad.unsign()),p=Bd(Dd.minX-Ad.minX),_=Bd(Ad.maxX-Dd.maxX),u=h&&p>0?1-p/(h*Ad.width):1,g=l&&_>0?1-_/(l*Ad.width):1,f*=Sd(u,g)),Id.isInnerMode(t,e,i,"height")?(n.y<0&&Ad.scaleOf(s,1,m=1/n.y),p=Bd(Ad.minY-Dd.minY),_=Bd(Dd.maxY-Ad.maxY),u=d&&p>0?1+p/(d*Ad.height):1,g=c&&_>0?1+_/(c*Ad.height):1,m*=kd(u,g),o&&(u=kd(Td(f),Td(m)),f=Pd(f)*u,m=Pd(m)*u)):(n.y<0&&((Bd(Cd(t)-Cd(e))<=0||Bd(Od(e)-Od(t))<=0)&&Ad.scaleOf(s,1,m=1/n.y),Ad.unsign()),p=Bd(Dd.minY-Ad.minY),_=Bd(Ad.maxY-Dd.maxY),u=d&&p>0?1-p/(d*Ad.height):1,g=c&&_>0?1-_/(c*Ad.height):1,m*=Sd(u,g)),n.x*=a(f)?f:1,n.y*=a(m)?m:1,n}},Id=Md;t.PointerEvent=class extends Ed{},t.PointerEvent.POINTER="pointer",t.PointerEvent.BEFORE_DOWN="pointer.before_down",t.PointerEvent.BEFORE_MOVE="pointer.before_move",t.PointerEvent.BEFORE_UP="pointer.before_up",t.PointerEvent.DOWN="pointer.down",t.PointerEvent.MOVE="pointer.move",t.PointerEvent.UP="pointer.up",t.PointerEvent.OVER="pointer.over",t.PointerEvent.OUT="pointer.out",t.PointerEvent.ENTER="pointer.enter",t.PointerEvent.LEAVE="pointer.leave",t.PointerEvent.TAP="tap",t.PointerEvent.DOUBLE_TAP="double_tap",t.PointerEvent.CLICK="click",t.PointerEvent.DOUBLE_CLICK="double_click",t.PointerEvent.LONG_PRESS="long_press",t.PointerEvent.LONG_TAP="long_tap",t.PointerEvent.MENU="pointer.menu",t.PointerEvent.MENU_TAP="pointer.menu_tap",t.PointerEvent=ve([$o()],t.PointerEvent);const Fd=t.PointerEvent,Wd={};t.DragEvent=class extends t.PointerEvent{static setList(t){this.list=t instanceof xh?t:new xh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return ht.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),Md.axisMove(t,n),n}static limitMove(t,e){Md.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Wd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Wd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Wd,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 Yt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Yt.unsign(i),i}assignMove(t){Wd.x=t?this.totalX:this.moveX,Wd.y=t?this.totalY:this.moveY}},t.DragEvent.BEFORE_DRAG="drag.before_drag",t.DragEvent.START="drag.start",t.DragEvent.DRAG="drag",t.DragEvent.END="drag.end",t.DragEvent.OVER="drag.over",t.DragEvent.OUT="drag.out",t.DragEvent.ENTER="drag.enter",t.DragEvent.LEAVE="drag.leave",t.DragEvent=ve([$o()],t.DragEvent);const zd=t.DragEvent;t.DropEvent=class extends t.PointerEvent{static setList(e){t.DragEvent.setList(e)}static setData(e){t.DragEvent.setData(e)}},t.DropEvent.DROP="drop",t.DropEvent=ve([$o()],t.DropEvent),t.MoveEvent=class extends t.DragEvent{},t.MoveEvent.BEFORE_MOVE="move.before_move",t.MoveEvent.START="move.start",t.MoveEvent.MOVE="move",t.MoveEvent.DRAG_ANIMATE="move.drag_animate",t.MoveEvent.END="move.end",t.MoveEvent.PULL_DOWN="move.pull_down",t.MoveEvent.REACH_BOTTOM="move.reach_bottom",t.MoveEvent=ve([$o()],t.MoveEvent),t.TouchEvent=class extends Ed{},t.TouchEvent=ve([$o()],t.TouchEvent);const Ud=t.TouchEvent;t.RotateEvent=class extends t.PointerEvent{},t.RotateEvent.BEFORE_ROTATE="rotate.before_rotate",t.RotateEvent.START="rotate.start",t.RotateEvent.ROTATE="rotate",t.RotateEvent.END="rotate.end",t.RotateEvent=ve([$o()],t.RotateEvent),t.SwipeEvent=class extends t.DragEvent{},t.SwipeEvent.SWIPE="swipe",t.SwipeEvent.LEFT="swipe.left",t.SwipeEvent.RIGHT="swipe.right",t.SwipeEvent.UP="swipe.up",t.SwipeEvent.DOWN="swipe.down",t.SwipeEvent=ve([$o()],t.SwipeEvent),t.ZoomEvent=class extends t.PointerEvent{},t.ZoomEvent.BEFORE_ZOOM="zoom.before_zoom",t.ZoomEvent.START="zoom.start",t.ZoomEvent.ZOOM="zoom",t.ZoomEvent.END="zoom.end",t.ZoomEvent=ve([$o()],t.ZoomEvent),t.KeyEvent=class extends Ed{},t.KeyEvent.BEFORE_DOWN="key.before_down",t.KeyEvent.BEFORE_UP="key.before_up",t.KeyEvent.DOWN="key.down",t.KeyEvent.HOLD="key.hold",t.KeyEvent.UP="key.up",t.KeyEvent=ve([$o()],t.KeyEvent);const Hd={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:e=>e<-45&&e>-135?t.SwipeEvent.UP:e>45&&e<135?t.SwipeEvent.DOWN:e<=45&&e>=-45?t.SwipeEvent.RIGHT:t.SwipeEvent.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:Nd.getSwipeDirection(ht.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:n(t.buttons)?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let t=0,s=i.length;t<s;t++)if(i[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new xh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:e=>e&&e.list.some(e=>dr.draggable(e)||!e.isLeafer&&e.hasEvent(t.DragEvent.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Nd=Hd,Yd=new xh,{getDragEventData:Xd,getDropEventData:Vd,getSwipeEventData:Gd}=Hd;class jd{constructor(t){this.dragDataList=[],this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Xd(t,t,t),this.canAnimate=this.canDragOut=!0}getList(e,i){const{proxy:s}=this.interaction.selector,n=s&&s.list.length,o=t.DragEvent.list||this.draggableList||Yd;return this.dragging&&(n?e?Yd:new xh(i?[...s.list,...s.dragHoverExclude]:s.list):o)}checkDrag(e,i){const{interaction:s}=this;if(this.moving&&e.buttons<1)return this.canAnimate=!1,void s.pointerCancel();!this.moving&&i&&(this.moving=s.canMove(this.downData)||s.isHoldRightKey||s.isMobileDragEmpty)&&(this.dragData.moveType="drag",s.emit(t.MoveEvent.START,this.dragData)),this.moving||this.dragStart(e,i),this.drag(e)}dragStart(e,i){this.dragging||(this.dragging=i&&bd.left(e),this.dragging&&(this.interaction.emit(t.DragEvent.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],dr.draggable(e)){this.draggableList=new xh(e);break}}drag(e){const{interaction:i,dragData:s,downData:n}=this,{path:o,throughPath:r}=n;this.dragData=Xd(n,s,e),r&&(this.dragData.throughPath=r),this.dragData.path=o,this.dragDataList.push(this.dragData),this.moving?(e.moving=!0,this.dragData.moveType="drag",i.emit(t.MoveEvent.BEFORE_MOVE,this.dragData),i.emit(t.MoveEvent.MOVE,this.dragData)):this.dragging&&(e.dragging=!0,this.dragReal(),i.emit(t.DragEvent.BEFORE_DRAG,this.dragData),i.emit(t.DragEvent.DRAG,this.dragData))}dragReal(e){const{interaction:i}=this,{running:s}=i,n=this.realDraggableList;if(n.length&&s){const{totalX:s,totalY:o}=this.dragData,{dragLimitAnimate:a}=i.p,l=!a||!!e;n.forEach(i=>{if(i.draggable){const n=r(i.draggable),d=t.DragEvent.getValidMove(i,this.dragStartPoints[i.innerId],{x:s,y:o},l||n);a&&!n&&e?dr.animateMove(i,d,h(a)?a:.3):i.move(d)}})}}dragOverOrOut(e){const{interaction:i}=this,{dragOverPath:s}=this,{path:n}=e;this.dragOverPath=n,s?n.indexAt(0)!==s.indexAt(0)&&(i.emit(t.DragEvent.OUT,e,s),i.emit(t.DragEvent.OVER,e,n)):i.emit(t.DragEvent.OVER,e,n)}dragEnterOrLeave(e){const{interaction:i}=this,{dragEnterPath:s}=this,{path:n}=e;i.emit(t.DragEvent.LEAVE,e,s,n),i.emit(t.DragEvent.ENTER,e,n,s),this.dragEnterPath=n}dragEnd(t){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t)||this.dragEndReal(t))}dragEndReal(e){const{interaction:i,downData:s,dragData:n}=this;e||(e=n);const{path:o,throughPath:r}=s,a=Xd(s,e,e);if(r&&(a.throughPath=r),a.path=o,this.moving&&(this.moving=!1,a.moveType="drag",i.emit(t.MoveEvent.END,a)),this.dragging){const o=this.getList();this.dragging=!1,i.p.dragLimitAnimate&&this.dragReal(!0),i.emit(t.DragEvent.END,a),this.swipe(e,s,n,a),this.drop(e,o,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(ht.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Gd(e,i,s);this.interaction.emit(t.type,t)}}drop(e,i,s){const n=Vd(e,i,t.DragEvent.data);n.path=s,this.interaction.emit(t.DropEvent.DROP,n),this.interaction.emit(t.DragEvent.LEAVE,e,s)}dragReset(){t.DragEvent.list=t.DragEvent.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()}}const Kd=se.get("emit");const qd=["move","zoom","rotate","key"];function Zd(t,e,i,s,n){if(qd.some(t=>e.startsWith(t))&&t.__.hitChildren&&!$d(t,n)){let o;for(let r=0,a=t.children.length;r<a;r++)o=t.children[r],!i.path.has(o)&&o.__.hittable&&Jd(o,e,i,s,n)}}function Jd(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!$d(t,n)&&(ol.updateEventStyle&&!s&&ol.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=fe.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function $d(t,e){return e&&e.has(t)}const Qd={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:tc,pathCanDrag:ec,pathHasOutside:ic}=Hd;class sc{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&&bd.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&bd.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&xd.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=_.clone(Qd),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new xh(t),this.createTransformer(),this.dragger=new jd(this),s&&(this.config=_.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(e,i){e||(e=this.hoverData),e&&(bd.defaultLeft(e),this.updateDownData(e),this.checkPath(e,i),this.downTime=Date.now(),this.emit(t.PointerEvent.BEFORE_DOWN,e),this.emit(t.PointerEvent.DOWN,e),bd.left(e)&&(this.tapWait(),this.longPressWait(e)),this.waitRightTap=bd.right(e),this.dragger.setDragData(e),this.isHoldRightKey||this.updateCursor(e))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&bd.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(e){if(this.emit(t.PointerEvent.BEFORE_MOVE,e,this.defaultPath),this.downData){const t=ht.getDistance(this.downData,e)>this.p.dragDistance;t&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(e,t)}this.dragger.moving||(this.updateHoverData(e),this.checkPath(e),this.emit(t.PointerEvent.MOVE,e),this.pointerHover(e),this.dragging&&(this.dragger.dragOverOrOut(e),this.dragger.dragEnterOrLeave(e))),this.updateCursor(this.downData||e)}pointerUp(e){const{downData:i}=this;if(e||(e=i),!i)return;bd.defaultLeft(e),e.multiTouch=i.multiTouch,this.findPath(e);const s=Object.assign(Object.assign({},e),{path:e.path.clone()});e.path.addList(i.path.list),this.checkPath(e),this.downData=null,this.emit(t.PointerEvent.BEFORE_UP,e),this.emit(t.PointerEvent.UP,e),this.touchLeave(e),e.isCancel||(this.tap(e),this.menuTap(e)),this.dragger.dragEnd(e),this.updateCursor(s)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(e){this.findPath(e),this.emit(t.PointerEvent.MENU,e),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(e)}menuTap(e){this.waitRightTap&&this.waitMenuTap&&(this.emit(t.PointerEvent.MENU_TAP,e),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_DOWN,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]||(this.downKeyMap[i]=!0,xd.setDownCode(i),this.emit(t.KeyEvent.HOLD,e,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(t.KeyEvent.DOWN,e,this.defaultPath)}keyUp(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_UP,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]=!1,xd.setUpCode(i),this.emit(t.KeyEvent.UP,e,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new xh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(e){const{path:i}=e,{overPath:s}=this;this.overPath=i,s?i.indexAt(0)!==s.indexAt(0)&&(this.emit(t.PointerEvent.OUT,e,s),this.emit(t.PointerEvent.OVER,e,i)):this.emit(t.PointerEvent.OVER,e,i)}pointerEnterOrLeave(e){let{path:i}=e;this.downData&&!this.moveMode&&(i=i.clone(),this.downData.path.forEach(t=>i.add(t)));const{enterPath:s}=this;this.enterPath=i,this.emit(t.PointerEvent.LEAVE,e,s,i),this.emit(t.PointerEvent.ENTER,e,i,s)}touchLeave(e){"touch"===e.pointerType&&this.enterPath&&(this.emit(t.PointerEvent.LEAVE,e),this.dragger.dragging&&this.emit(t.DropEvent.LEAVE,e))}tap(e){const{pointer:i}=this.config,s=this.longTap(e);if(!i.tapMore&&s)return;if(!this.waitTap)return;i.tapMore&&this.emitTap(e);const n=Date.now()-this.downTime,o=[t.PointerEvent.DOUBLE_TAP,t.PointerEvent.DOUBLE_CLICK].some(t=>tc(e.path,t));n<i.tapTime+50&&o?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(e)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{i.tapMore||(this.tapWaitCancel(),this.emitTap(e))},i.tapTime))):i.tapMore||(this.tapWaitCancel(),this.emitTap(e))}findPath(t,e){const{hitRadius:i,through:s}=this.p,{bottomList:n,target:o}=this;te.backgrounder||t.origin||o&&o.updateLayout();const r=this.selector.getByPoint(t,i,Object.assign({bottomList:n,name:t.type},e||{through:s}));return r.throughPath&&(t.throughPath=r.throughPath),t.path=r.path,r.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&&!ic(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!ec(t.path))&&!ic(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()}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(e){e||(e=this.hoverData),e&&(this.findPath(e,{exclude:this.dragger.getList(!1,!0),name:t.PointerEvent.MOVE}),this.hoverData=e)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:n}=this.canvas;return s.x*=n.width/i.width,s.y*=n.height/i.height,this.p.snap&&ht.round(s),s}emitTap(e){this.emit(t.PointerEvent.TAP,e),this.emit(t.PointerEvent.CLICK,e)}emitDoubleTap(e){this.emit(t.PointerEvent.DOUBLE_TAP,e),this.emit(t.PointerEvent.DOUBLE_CLICK,e)}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(e){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(t.PointerEvent.LONG_PRESS,e)},this.p.longPressTime)}longTap(e){let i;return this.longPressed&&(this.emit(t.PointerEvent.LONG_TAP,e),(tc(e.path,t.PointerEvent.LONG_TAP)||tc(e.path,t.PointerEvent.LONG_PRESS))&&(i=!0)),this.longPressWaitCancel(),i}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new jt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(h(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Jr.RESIZE,this.__onResize,this)],t.once(ea.READY,()=>this.__onResize())}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,i,s){this.running&&function(t,e,i,s){if(!i&&!e.path)return;let n;e.type=t,i?e=Object.assign(Object.assign({},e),{path:i}):i=e.path,e.target=i.indexAt(0);try{for(let o=i.length-1;o>-1;o--){if(n=i.list[o],Jd(n,t,e,!0,s))return;n.isApp&&Zd(n,t,e,!0,s)}for(let o=0,r=i.length;o<r;o++)if(n=i.list[o],n.isApp&&Zd(n,t,e,!1,s),Jd(n,t,e,!1,s))return}catch(t){Kd.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class nc{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}nc.custom={};class oc extends ye{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new xh,this.pixelList=new xh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),ce.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),ce.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()}}te.getSelector=function(t){return t.leafer?t.leafer.selector:te.selector||(te.selector=ce.selector())};const{toInnerRadiusPointOf:rc,copyRadiusPoint:ac}=ht,{hitRadiusPoint:hc,hitPoint:lc}=Yt,dc={},cc={},uc=t.Leaf.prototype;uc.hit=function(t,e=0){this.updateLayout(),ac(cc,t,e);const i=this.__world;return!!(e?hc(i,cc):lc(i,cc))&&(this.isBranch?te.getSelector(this).hitPoint(Object.assign({},cc),e,{target:this}):this.__hitWorld(cc))},uc.__hitWorld=function(t,e){const i=this.__;if(!i.hitSelf)return!1;const s=this.__world,n=this.__layout,o=s.width<10&&s.height<10;if(i.hitRadius&&(ac(dc,t,i.hitRadius),t=dc),rc(t,s,dc),i.hitBox||o){if(Yt.hitRadiusPoint(n.boxBounds,dc))return!0;if(o)return!1}return!n.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),n.boundsChanged||(n.hitCanvasChanged=!1)),this.__hit(dc,e)},uc.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},uc.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},uc.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},uc.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const gc=new ft,pc=t.UI.prototype;pc.__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,n=i||s;this.__hitCanvas||(this.__hitCanvas=n?t.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):t.getPathType(this));const o=this.__hitCanvas;if(n){const{renderBounds:t}=this.__layout,n=te.image.hitCanvasSize,r=o.hitScale=Kt.set(0,0,n,n).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=Kt.set(t).scale(r);o.resize({width:l,height:d,pixelRatio:1}),o.clear(),no.patternLocked=!0,this.__renderShape(o,{matrix:gc.setWith(this.__world).scaleWith(1/r).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)},pc.__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,n=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__isAlphaPixelFill||i.__isCanvas))||"all"===s||e;if(n&&this.__hitFill(t))return!0;const{hitStroke:o,__maxStrokeWidth:r}=i,a=i.stroke&&("path"===o||"pixel"===o&&!i.__isAlphaPixelStroke)||"all"===o;if(!n&&!a)return!1;const h=2*t.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*r,!n&&this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h;break;case"center":l+=r;break;case"outside":if(l+=2*r,!n){if(!this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h}}return!!l&&this.__hitStroke(t,l)};const _c=t.UI.prototype,fc=t.Rect.prototype,mc=t.Box.prototype;fc.__updateHitCanvas=mc.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?_c.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},fc.__hitFill=mc.__hitFill=function(t){return this.__hitCanvas?_c.__hitFill.call(this,t):Yt.hitRadiusPoint(this.__layout.boxBounds,t)},t.Text.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:n,__textDrawData:o}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):o.rows.forEach(n=>t.rect(n.x,n.y-s,n.width,e<i?i:e))},t.Group.prototype.pick=function(t,e){return e||(e=s),this.updateLayout(),te.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};const yc=De.prototype;function vc(t,e,i){t.__.__font?Qh.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function wc(t,e,i,s,n){const o=i.__;u(t)?Qh.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&Qh.strokeArrow(t,i,s,n)}function xc(t,e,i,s,n){const o=i.__;u(t)?Qh.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),Qh.drawTextStroke(i,s,n))}function bc(t,e,i,s,n){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,xc(t,2,i,o,n),o.blendMode="outside"===e?"destination-out":"destination-in",Qh.fillText(i,o,n),o.blendMode="normal",dr.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}yc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},yc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},yc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:o,radiusY:r}=t;e&&(s-=e.x,n-=e.y),Kt.set(s-o,n-r,2*o,2*r).scale(i).ceil();const{data:a}=this.context.getImageData(Kt.x,Kt.y,Kt.width||1,Kt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:Ec,copyAndSpread:Sc,toOuterOf:kc,getOuterOf:Tc,getByMove:Bc,move:Pc,getIntersectData:Rc}=Yt,Lc={};let Cc;const{stintSet:Oc}=_,{hasTransparent:Ac}=Zh;function Dc(t,e,i){if(!u(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:o}=i.__layout;switch(e.type){case"image":if(!e.url)return;s=tl.image(i,t,e,o,!Cc||!Cc[e.url]);break;case"linear":s=el.linearGradient(e,o);break;case"radial":s=el.radialGradient(e,o);break;case"angular":s=el.conicGradient(e,o);break;case"solid":const{type:r,color:a,opacity:h}=e;s={type:r,style:Zh.string(a,h)};break;default:n(e.r)||(s={type:"solid",style:Zh.string(e)})}if(s&&(s.originPaint=e,r(s.style)&&Ac(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const Mc={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];c(a)||(a=[a]),Cc=tl.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Dc(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Oc(i,"__isAlphaPixelFill",n),Oc(i,"__isTransparentFill",o)):(Oc(i,"__isAlphaPixelStroke",n),Oc(i,"__isTransparentStroke",o),Oc(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,vc(e,i,s)},fills:function(t,e,i,s){let n,o,r;for(let a=0,h=t.length;a<h;a++){if(n=t[a],o=n.originPaint,n.image){if(r?r++:r=1,tl.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||o.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),o.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===o.scaleFixed||"zoom-in"===o.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}o.blendMode&&(i.blendMode=o.blendMode),vc(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),vc(e,i,s),i.restoreBlendMode()):vc(e,i,s)}},fillPathOrText:vc,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:o}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(o){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>o.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)Qh.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":wc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),wc(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)wc(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),wc(t,2,e,r,s),r.clipUI(n),r.clearWorld(o),dr.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Qh.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":xc(t,1,e,i,s);break;case"inside":bc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?xc(t,2,e,i,s):bc(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:o,decorationY:r}=n;for(let t=0,i=o.length;t<i;t++)s=o[t],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(r){const{decorationHeight:t}=n;o.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,o){let r;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||n.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,d=t.length;l<d;l++)if(r=t[l],(!r.image||!tl.checkImage(r,!1,s,n,o))&&r.style){if(h){const{strokeStyle:t}=r;t?n.setStroke(r.style,a.__getRealStrokeWidth(t)*e,a,t):n.setStroke(r.style,a.__strokeWidth*e,a)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?Qh.drawTextStroke(s,n,o):n.stroke(),n.restoreBlendMode()):i?Qh.drawTextStroke(s,n,o):n.stroke()}},shape:function(t,e,i){const s=e.getSameCanvas(),n=e.bounds,o=t.__nowWorld,r=t.__layout,a=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let h,l,d,c,u,g;kc(r.strokeSpread?(Sc(Lc,r.boxBounds,r.strokeSpread),Lc):r.boxBounds,o,a);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(a))g=s,h=u=a,l=o;else{let s;if(te.fullImageShadow)s=a;else{const t=r.renderShapeSpread?Ec(n,k.swapAndScale(r.renderShapeSpread,p,_)):n;s=Rc(t,a)}c=n.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(g=e.getSameCanvas(),t.__renderShape(g,i),p*=f,_*=m),u=Tc(a,c),h=Bc(u,-c.e,-c.f),l=Tc(o,c),Pc(l,-c.e,-c.f);const y=i.matrix;y?(d=new ft(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:g,shapeBounds:u,scaleX:p,scaleY:_}}};let Ic,Fc=new jt;const{isSame:Wc}=Yt;function zc(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||tl.createData(n,s,i,o),!0}function Uc(t,e){Yc(t,Xr.LOAD,e)}function Hc(t,e){Yc(t,Xr.LOADED,e)}function Nc(t,e,i){e.error=i,t.forceUpdate("surface"),Yc(t,Xr.ERROR,e)}function Yc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Xr(e,i))}function Xc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Vc,translate:Gc}=Z,jc=new jt,Kc={},qc={};function Zc(t,e,i,s){const n=r(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Jc={},$c={a:1,b:0,c:0,d:1,e:0,f:0};const{get:Qc,set:tu,rotateOfOuter:eu,translate:iu,scaleOfOuter:su,multiplyParent:nu,scale:ou,rotate:ru,skew:au}=Z;function hu(t,e,i,s,n,o,r,a){r&&ru(t,r),a&&au(t,a.x,a.y),n&&ou(t,n,o),iu(t,e.x+i,e.y+s)}const{get:lu,scale:du,copy:cu}=Z,{getFloorScale:uu}=M,{abs:gu}=Math;const pu={image:function(t,e,i,s,n){let o,r;const a=no.get(i);return Ic&&i===Ic.paint&&Wc(s,Ic.boxBounds)?o=Ic.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Ic=a.use>1?{leafPaint:o,paint:i,boxBounds:Fc.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(zc(t,e,i,a,o,s),n&&(Uc(t,r),Hc(t,r))):a.error?n&&Nc(t,r,a.error):(n&&(Xc(t,!0),Uc(t,r)),o.loadId=a.load(()=>{Xc(t,!1),t.destroyed||(zc(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Hc(t,r)),o.loadId=void 0},e=>{Xc(t,!1),Nc(t,r,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,n){const{scaleX:o,scaleY:r}=tl.getImageRenderScaleData(t,i,s,n),{image:a,data:h,originPaint:l}=t,{exporting:d,snapshot:c}=n;return!(!h||t.patternId===o+"-"+r&&!d||c)&&(e&&(h.repeat?e=!1:l.changeful||"miniapp"===te.name&&Jr.isResizing(i)||d||(e=te.image.isLarge(a,o,r)||a.width*o>8096||a.height*r>8096)),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),tl.drawImage(t,o,r,i,s,n),!0):(!t.style||l.sync||d?tl.createPattern(t,i,s,n):tl.createPatternTask(t,i,s,n),!1))},drawImage:function(t,e,i,s,n,o){const{data:r,image:a}=t,{blendMode:h}=t.originPaint,{opacity:l,transform:d}=r,c=a.getFull(r.filters),u=s.__;let g,{width:p,height:_}=a;(g=d&&!d.onlyScale||u.path||u.cornerRadius)||l||h?(n.save(),g&&n.clipUI(s),h&&(n.blendMode=h),l&&(n.opacity*=l),d&&n.transform(d),n.drawImage(c,0,0,p,_),n.restore()):(r.scaleX&&(p*=r.scaleX,_*=r.scaleY),n.drawImage(c,0,0,p,_))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:o}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return o&&o.scaleX&&(n.scaleX*=Math.abs(o.scaleX),n.scaleY*=Math.abs(o.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(c(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,no.recyclePaint(s),n.loading&&(r||(r=e.__input&&e.__input[t]||[],c(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=no.patternTasker.add(()=>we(this,void 0,void 0,function*(){tl.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:n,scaleY:o}=tl.getImageRenderScaleData(t,e,i,s),r=n+"-"+o;if(t.patternId!==r&&!e.destroyed&&(!te.image.isLarge(t.image,n,o)||t.data.repeat)){const{image:i,data:s}=t,{transform:a,gap:h}=s,l=tl.getPatternFixScale(t,n,o);let d,c,u,{width:g,height:p}=i;l&&(n*=l,o*=l),g*=n,p*=o,h&&(c=h.x*n/gu(s.scaleX||1),u=h.y*o/gu(s.scaleY||1)),(a||1!==n||1!==o)&&(n*=uu(g+(c||0)),o*=uu(p+(u||0)),d=lu(),a&&cu(d,a),du(d,1/n,1/o));const _=i.getCanvas(g,p,s.opacity,s.filters,c,u,e.leafer&&e.leafer.config.smooth,s.interlace),f=i.getPattern(_,s.repeat||te.origin.noRepeat||"no-repeat",d,t);t.style=f,t.patternId=r}},getPatternFixScale:function(t,e,i){const{image:s}=t;let n,o=te.image.maxPatternSize,r=s.width*s.height;return s.isSVG?e>1&&(n=Math.ceil(e)/e):o>r&&(o=r),(r*=e*i)>o&&(n=Math.sqrt(o/r)),n},createData:function(t,e,i,s){t.data=tl.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=jc.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:n}=i,{opacity:o,mode:a,align:l,offset:d,scale:c,size:g,rotation:p,skew:_,clipSize:f,repeat:m,gap:y,filters:v,interlace:w}=t,x=e.width===s&&e.height===n,b={mode:a},E="center"!==l&&(p||0)%180==90;let S,k;switch(Yt.set(qc,0,0,E?n:s,E?s:n),a&&"cover"!==a&&"fit"!==a?((c||g)&&(M.getScaleData(c,g,i,Kc),S=Kc.scaleX,k=Kc.scaleY),(l||y||m)&&(S&&Yt.scale(qc,S,k,!0),l&&Tt.toPoint(l,qc,e,qc,!0,!0))):x&&!p||(S=k=Yt.getFitScale(e,qc,"fit"!==a),Yt.put(e,i,l,S,!1,qc),Yt.scale(qc,S,k,!0)),d&&ht.move(qc,d),a){case"stretch":x?S&&(S=k=void 0):(S=e.width/s,k=e.height/n,tl.stretchMode(b,e,S,k));break;case"normal":case"clip":if(qc.x||qc.y||S||f||p||_){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),tl.clipMode(b,e,qc.x,qc.y,S,k,p,_,t,i),t&&(S=S?S*t:t,k=k?k*i:i)}break;case"repeat":(!x||S||p||_)&&tl.repeatMode(b,e,s,n,qc.x,qc.y,S,k,p,_,l,t.freeTransform),m||(b.repeat="repeat");const i=u(m);(y||i)&&(b.gap=function(t,e,i,s,n){let o,r;u(t)?(o=t.x,r=t.y):o=r=t;return{x:Zc(o,i,n.width,e&&e.x),y:Zc(r,s,n.height,e&&e.y)}}(y,i&&m,qc.width,qc.height,e));break;default:S&&tl.fillOrFitMode(b,e,qc.x,qc.y,S,k,p)}return b.transform||(e.x||e.y)&&Gc(b.transform=Vc(),e.x,e.y),S&&(b.scaleX=S,b.scaleY=k),o&&o<1&&(b.opacity=o),v&&(b.filters=v),m&&(b.repeat=r(m)?"x"===m?"repeat-x":"repeat-y":"repeat"),w&&(b.interlace=h(w)||"percent"===w.type?{type:"x",offset:w}:w),b},stretchMode:function(t,e,i,s){const n=Qc(),{x:o,y:r}=e;o||r?iu(n,o,r):n.onlyScale=!0,ou(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,o,r){const a=Qc();iu(a,e.x+i,e.y+s),ou(a,n,o),r&&eu(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a},clipMode:function(t,e,i,s,n,o,r,a,h,l){const d=Qc();hu(d,e,i,s,n,o,r,a),h&&(r||a?(tu($c),su($c,e,h,l),nu(d,$c)):su(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,n,o,r,a,h,l,d,c){const u=Qc();if(c)hu(u,e,n,o,r,a,h,l);else{if(h)if("center"===d)eu(u,{x:i/2,y:s/2},h);else switch(ru(u,h),h){case 90:iu(u,s,0);break;case 180:iu(u,i,s);break;case 270:iu(u,0,i)}Jc.x=e.x+n,Jc.y=e.y+o,iu(u,Jc.x,Jc.y),r&&su(u,Jc,r,a)}t.transform=u}},{toPoint:_u}=Et,{hasTransparent:fu}=Zh,mu={},yu={};function vu(t,e,i,s){if(i){let n,o,a,h;for(let t=0,l=i.length;t<l;t++)n=i[t],r(n)?(a=t/(l-1),o=Zh.string(n,s)):(a=n.offset,o=Zh.string(n.color,s)),e.addColorStop(a,o),!h&&fu(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:wu,getDistance:xu}=ht,{get:bu,rotateOfOuter:Eu,scaleOfOuter:Su}=Z,{toPoint:ku}=Et,Tu={},Bu={};function Pu(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=wu(e,i);o=bu(),n?(Su(o,e,r/a*(s||1),1),Eu(o,e,t+90)):(Su(o,e,1,r/a*(s||1)),Eu(o,e,t))}return o}const{getDistance:Ru}=ht,{toPoint:Lu}=Et,Cu={},Ou={};const Au={linearGradient:function(t,e){let{from:i,to:s,type:n,opacity:o}=t;_u(i||"top",e,mu),_u(s||"bottom",e,yu);const r=te.canvas.createLinearGradient(mu.x,mu.y,yu.x,yu.y),a={type:n,style:r};return vu(a,r,t.stops,o),a},radialGradient:function(t,e){let{from:i,to:s,type:n,opacity:o,stretch:r}=t;ku(i||"center",e,Tu),ku(s||"bottom",e,Bu);const a=te.canvas.createRadialGradient(Tu.x,Tu.y,0,Tu.x,Tu.y,xu(Tu,Bu)),h={type:n,style:a};vu(h,a,t.stops,o);const l=Pu(e,Tu,Bu,r,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:n,opacity:o,stretch:r}=t;Lu(i||"center",e,Cu),Lu(s||"bottom",e,Ou);const a=te.conicGradientSupport?te.canvas.createConicGradient(0,Cu.x,Cu.y):te.canvas.createRadialGradient(Cu.x,Cu.y,0,Cu.x,Cu.y,Ru(Cu,Ou)),h={type:n,style:a};vu(h,a,t.stops,o);const l=Pu(e,Cu,Ou,r||1,te.conicGradientRotate90);return l&&(h.transform=l),h},getTransform:Pu},{copy:Du,move:Mu,toOffsetOutBounds:Iu}=Yt,{max:Fu,abs:Wu}=Math,zu={},Uu=new ft,Hu={};function Nu(t,e){let i,s,n,o,r=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),n=Wu(t.spread||0),r=Fu(r,n+o-s),a=Fu(a,n+o+i),h=Fu(h,n+o+s),l=Fu(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function Yu(t,e,i){const{shapeBounds:s}=i;let n,o;te.fullImageShadow?(Du(zu,t.bounds),Mu(zu,e.x-s.x,e.y-s.y),n=t.bounds,o=zu):(n=s,o=e),t.copyWorld(i.canvas,n,o)}const{toOffsetOutBounds:Xu}=Yt,Vu={};const Gu=Nu;const ju={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Iu(h,Hu,l),r.forEach((r,_)=>{let f=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}g.setWorldShadow(Hu.offsetX+(r.x||0)*c*f,Hu.offsetY+(r.y||0)*u*f,(r.blur||0)*c*f,Zh.string(r.color)),n=il.getShadowTransform(t,g,i,r,Hu,f),n&&g.setTransform(n),Yu(g,Hu,i),n&&g.resetTransform(),s=l,r.box&&(g.restore(),g.save(),a&&(g.copyWorld(g,l,o,"copy"),s=o),a?g.copyWorld(a,o,o,"destination-out"):g.copyWorld(i.canvas,d,h,"destination-out")),dr.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Xu(h,Vu,l),r.forEach((r,_)=>{let f=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}g.save(),g.setWorldShadow(Vu.offsetX+(r.x||0)*c*f,Vu.offsetY+(r.y||0)*u*f,(r.blur||0)*c*f),n=il.getShadowTransform(t,g,i,r,Vu,f,!0),n&&g.setTransform(n),Yu(g,Vu,i),g.restore(),a?(g.copyWorld(g,l,o,"copy"),g.copyWorld(a,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,d,h,"source-out"),s=l),g.fillWorld(s,Zh.string(r.color),"source-in"),dr.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.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:Nu,getShadowTransform:function(t,e,i,s,n,o,r){if(s.spread){const i=2*s.spread*o*(r?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return Uu.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),Uu}},isTransformShadow(t){},getInnerShadowSpread:Gu},{excludeRenderBounds:Ku}=yr;let qu;function Zu(t,e,i,s,n,o,r,a){switch(e){case"grayscale":qu||(qu=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);$u(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":$u(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function Ju(t){return t.getSameCanvas(!1,!0)}function $u(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}t.Group.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){r&&(Zu(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||Ku(i,e)||i.__render(t,e),o=i.__.opacity,qu=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=Ju(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Ju(t)),n||(n=Ju(t)),i.__render(s,e));continue}const d=1===o&&i.__.__blendMode;d&&Zu(this,r,t,n,s,o,void 0,!1),Ku(i,e)||i.__render(n||t,e),d&&Zu(this,r,t,n,s,o,d,!1)}Zu(this,r,t,n,s,o,void 0,!0)};const Qu=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",tg=Qu+"_#~&*+\\=|≮≯≈≠=…",eg=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 ig(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const sg=ig("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ng=ig("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),og=ig(Qu),rg=ig(tg),ag=ig("- —/~|┆·");var hg;!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"}(hg||(hg={}));const{Letter:lg,Single:dg,Before:cg,After:ug,Symbol:gg,Break:pg}=hg;function _g(t){return sg[t]?lg:ag[t]?pg:ng[t]?cg:og[t]?ug:rg[t]?gg:eg.test(t)?dg:lg}const fg={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function mg(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:yg}=fg,{Letter:vg,Single:wg,Before:xg,After:bg,Symbol:Eg,Break:Sg}=hg;let kg,Tg,Bg,Pg,Rg,Lg,Cg,Og,Ag,Dg,Mg,Ig,Fg,Wg,zg,Ug,Hg,Ng=[];function Yg(t,e){Ag&&!Og&&(Og=Ag),kg.data.push({char:t,width:e}),Bg+=e}function Xg(){Pg+=Bg,kg.width=Bg,Tg.words.push(kg),kg={data:[]},Bg=0}function Vg(){Wg&&(zg.paraNumber++,Tg.paraStart=!0,Wg=!1),Ag&&(Tg.startCharSize=Og,Tg.endCharSize=Ag,Og=0),Tg.width=Pg,Ug.width?yg(Tg):Hg&&Gg(),Ng.push(Tg),Tg={words:[]},Pg=0}function Gg(){Pg>(zg.maxWidth||0)&&(zg.maxWidth=Pg)}const{top:jg,right:Kg,bottom:qg,left:Zg}=t.Direction4;function Jg(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const $g={getDrawData:function(t,e){r(t)||(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,o=e.__getInput("height")||0;const{__padding:a}=e;a&&(n?(i=a[Zg],n-=a[Kg]+a[Zg],!n&&(n=.01)):e.autoSizeAlign||(i=a[Zg]),o?(s=a[jg],o-=a[jg]+a[qg],!o&&(o=.01)):e.autoSizeAlign||(s=a[jg]));const h={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:te.canvas.font=e.__font};return function(t,e,i){zg=t,Ng=t.rows,Ug=t.bounds,Hg=!Ug.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=te,{width:a}=Ug;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;Wg=!0,Mg=null,Og=Cg=Ag=Bg=Pg=0,kg={data:[]},Tg={words:[]},s&&(e=[...e]);for(let i=0,l=e.length;i<l;i++)Lg=e[i],"\n"===Lg?(Bg&&Xg(),Tg.paraEnd=!0,Vg(),Wg=!0):(Dg=_g(Lg),Dg===vg&&"none"!==o&&(Lg=mg(Lg,o,!Bg)),Cg=r.measureText(Lg).width,s&&(s<0&&(Ag=Cg),Cg+=s),Ig=Dg===wg&&(Mg===wg||Mg===vg)||Mg===wg&&Dg!==bg,Fg=!(Dg!==xg&&Dg!==wg||Mg!==Eg&&Mg!==bg),Rg=Wg&&n?a-n:a,t&&a&&Pg+Bg+Cg>Rg&&(h?(Bg&&Xg(),Pg&&Vg()):(Fg||(Fg=Dg===vg&&Mg==bg),Ig||Fg||Dg===Sg||Dg===xg||Dg===wg||Bg+Cg>Rg?(Bg&&Xg(),Pg&&Vg()):Pg&&Vg()))," "===Lg&&!0!==Wg&&Pg+Bg===0||(Dg===Sg?(" "===Lg&&Bg&&Xg(),Yg(Lg,Cg),Xg()):Ig||Fg?(Bg&&Xg(),Yg(Lg,Cg)):Yg(Lg,Cg)),Mg=Dg);Bg&&Xg(),Pg&&Vg(),Ng.length>0&&(Ng[Ng.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{zg.paraNumber++,Pg=r.measureText(t).width,Ng.push({x:n||0,text:t,width:Pg,paraStart:!0}),Hg&&Gg()})}(h,t,e),a&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Jg(e,"x",t[Zg]);break;case"right":Jg(e,"x",-t[Kg])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Jg(e,"y",t[jg]);break;case"bottom":Jg(e,"y",-t[qg])}}(a,h,e,n,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:g,y:p,width:_,height:f}=s,m=o*n+(c?c*(t.paraNumber-1):0),y=r;if(h&&m>f)m=Math.max(f,o),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":p+=(f-m)/2;break;case"bottom":p+=f-m}y+=p;let v,w,x,b=_||u?_:t.maxWidth;for(let r=0,d=n;r<d;r++){if(v=i[r],v.x=g,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&&r>0&&(y+=c),v.y=y,y+=o,t.overflow>r&&y>m&&(v.isOverflow=!0,t.overflow=r+1),w=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,w-=x,x+=e.fontSize):x-=a),w<s.x&&(s.x=w),x>s.width&&(s.width=x),h&&_&&_<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=m}(h,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,__letterSpacing:r}=e,a=i&&n.includes("both"),h=a||i&&n.includes("justify"),l=h&&n.includes("letter");let d,c,u,g,p,_,f,m,y,v;s.forEach(t=>{t.words&&(p=o&&t.paraStart?o:0,m=t.words.length,h&&(v=!t.paraEnd||a,c=i-t.width-p,l?g=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),_=r||t.isOverflow||l?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===_?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,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,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,d,t.data,t.isOverflow,v&&g),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):g&&(t.width+=g*(e.data.length-(y?1:0))))})),t.words=null)})}(h,e,n),h.overflow&&function(t,e,i,s){if(!s)return;const{rows:n,overflow:o}=t;let{textOverflow:r}=e;if(n.splice(o),r&&"show"!==r){let t,a;"hide"===r?r="":"ellipsis"===r&&(r="...");const h=r?te.canvas.measureText(r).width:0,l=i+s-h;("none"===e.textWrap?n:[n[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:r,x:a}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(h,e,i,n),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,u(o)?(i=o.type,o.color&&(t.decorationColor=Zh.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,e),h}};const Qg={string:function(t,e){if(!t)return"#000";const i=h(e)&&e<1;if(r(t)){if(!i||!Zh.object)return t;t=Zh.object(t)}let s=n(t.a)?1:t.a;i&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};function tp(t){return t?c(t)?t:[t]:[]}Object.assign(qh,$g),Object.assign(Zh,Qg),Object.assign(Qh,Mc),Object.assign(tl,pu),Object.assign(el,Au),Object.assign(il,ju),Object.assign(ce,{interaction:(t,e,i,s)=>new sc(t,e,i,s),hitCanvas:(t,e)=>new Eh(t,e),hitCanvasManager:()=>new oc}),kh();class ep extends zr{get list(){return tp(this.value)}get oldList(){return tp(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function ip(t){return(e,i)=>{const s="_"+i;lo(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==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(u(i))e=i;else if(!1===i)return}o.setDimOthers(!1),o.setBright(!1),c(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?ep.BEFORE_SELECT:ep.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new ep(s,{editor:o,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}ep.BEFORE_SELECT="editor.before_select",ep.SELECT="editor.select",ep.AFTER_SELECT="editor.after_select",ep.BEFORE_HOVER="editor.before_hover",ep.HOVER="editor.hover";const{abs:sp}=Math,{copy:np}=Z,{setListWithFn:op}=Yt,{worldBounds:rp}=yr,ap={a:1,b:0,c:0,d:1,e:0,f:0},hp={x:0,y:0,width:0,height:0};class lp extends t.UI{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?(op(hp,e,rp),t&&this.set(t),this.set(hp),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:o,strokeWidth:a,fill:h}=n,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:u}=s;if(u.width&&u.height&&(!l||l.hit(u,e.matrix))){const i=sp(c.scaleX),l=sp(c.scaleY);np(ap,c),ap.half=a%2,t.setWorld(ap,e.matrix),t.beginPath(),"path"===this.strokePathType||s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=a/Math.max(i,l),o&&(r(o)?Qh.stroke(o,this,t,e):Qh.strokes(o,this,t,e)),h&&(r(h)?Qh.fill(h,this,t,e):Qh.fills(h,this,t,e))}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}ve([ip(function(t){const e=t.target;t.list=e?c(e)?e:[e]:[]})],lp.prototype,"target",void 0),ve([Co("render-path")],lp.prototype,"strokePathType",void 0);class dp extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const cp={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return up([t],i,e),i}};function up(t,e,i){let s,n;for(let o=0,r=t.length;o<r;o++)if(s=t[o],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&up(s.children,e,i)}}const{findOne:gp,findByBounds:pp}=cp;class _p extends t.Group{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 lp,this.targetStroker=new lp,this.bounds=new jt,this.selectArea=new dp,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:n,strokeWidth:o,hover:r,hoverStyle:a}=s;this.hoverStroker.setTarget(r?e:null,Object.assign({stroke:n,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: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:n,y:o}=t.getInnerPoint(this);this.bounds.set(n,o),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:o},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new xh(pp(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach(e=>{n.has(e)||t.push(e)}),n.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==e.list.length||e.list.some((e,i)=>e!==t[i]))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=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)&&!gp(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new xh(this.editor.editBox.rect)};return gp(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):gp(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:e}=this;e.waitLeafer(()=>{const{app:i}=e;i.selector.proxy=e,this.__eventIds=[e.on_([[ep.HOVER,this.onHover,this],[ep.SELECT,this.onSelect,this]]),i.on_([[t.PointerEvent.MOVE,this.onPointerMove,this],[t.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this],[t.PointerEvent.TAP,this.onTap,this],[t.DragEvent.START,this.onDragStart,this,!0],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.MoveEvent.MOVE,this.onAutoMove,this],[[t.ZoomEvent.ZOOM,t.MoveEvent.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:fp,top:mp,topRight:yp,right:vp,bottomRight:wp,bottom:xp,bottomLeft:bp,left:Ep}=t.Direction9,{toPoint:Sp}=Et,{within:kp,sign:Tp}=M,{abs:Bp}=Math,Pp={getScaleData(t,e,i,s,n,o,r,a){let l,d,c={},u=1,g=1;const{boxBounds:p,widthRange:_,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:w}=e,x=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,E=Tp(x),S=Tp(b),k=a?x:E*p.width/v,T=a?b:S*p.height/w;if(h(s))u=g=Math.sqrt(s);else{o&&(s.x*=2,s.y*=2),s.x*=a?x:E,s.y*=a?b:S;const t=(-s.y+w)/w,e=(s.x+v)/v,r=(s.y+w)/w,h=(-s.x+v)/v;switch(i){case mp:g=t,l="bottom";break;case vp:u=e,l="left";break;case xp:g=r,l="top";break;case Ep:u=h,l="right";break;case fp:g=t,u=h,l="bottom-right";break;case yp:g=t,u=e,l="bottom-left";break;case wp:g=r,u=e,l="top-left";break;case bp:g=r,u=h,l="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case mp:case xp:u=g;break;case Ep:case vp:g=u;break;default:d=Math.sqrt(Bp(u*g)),u=Tp(u)*d,g=Tp(g)*d}}const B=1!==u,P=1!==g;if(B&&(u/=k),P&&(g/=T),!r){const{worldTransform:e}=t;u<0&&(u=1/p.width/e.scaleX),g<0&&(g=1/p.height/e.scaleY)}if(Sp(o||l,p,c,!0),m){const e={x:u,y:g};Md.limitScaleOf(t,c,e,n),u=e.x,g=e.y}if(B&&_){const e=p.width*t.scaleX;u=kp(e*u,_)/e}if(P&&f){const e=p.height*t.scaleY;g=kp(e*g,f)/e}return B&&Bp(u*y.width)<1&&(u=Tp(u)/y.width),P&&Bp(g*y.height)<1&&(g=Tp(g)/y.height),n&&u!==g&&(d=Math.min(Bp(u),Bp(g)),u=Tp(u)*d,g=Tp(g)*d),isFinite(u)||(u=1),isFinite(g)||(g=1),{origin:c,scaleX:u,scaleY:g,direction:i,lockRatio:n,around:o}},getRotateData(t,e,i,s,n){let o,r={};switch(e){case fp:o="bottom-right";break;case yp:o="bottom-left";break;case wp:o="top-left";break;case bp:o="top-right";break;default:o="center"}return Sp(n||o,t.boxBounds,r,!0),{origin:r,rotation:ht.getRotation(s,t.getWorldPointByBox(r),i)}},getSkewData(t,e,i,s){let n,o,r={},a=0,h=0;switch(e){case mp:case fp:o={x:.5,y:0},n="bottom",a=1;break;case xp:case wp:o={x:.5,y:1},n="top",a=1;break;case Ep:case bp:o={x:0,y:.5},n="right",h=1;break;case vp:case yp:o={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,Sp(s||n,t,r,!0);const c=ht.getRotation(o,r,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Ep:t=vp;break;case fp:t=yp;break;case bp:t=wp;break;case vp:t=Ep;break;case yp:t=fp;break;case wp:t=bp}if(i)switch(t){case mp:t=xp;break;case fp:t=bp;break;case yp:t=wp;break;case xp:t=mp;break;case bp:t=fp;break;case wp:t=yp}return t}},Rp={};function Lp(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:o,flippedX:r,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Cp(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:g,moveable:p,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(p||(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?n?g:o?c:u:v?g:y?c:u;h+=45*(Pp.getFlipDirection(i.direction,r,a)+1),h=2*Math.round(M.formatRotation(h,!0)/2);const{url:x,x:b,y:E}=w,S=x+h;Rp[S]?i.cursor=Rp[S]:Rp[S]=i.cursor={url:Op(x,h),x:b,y:E}}function Cp(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Op(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Ap extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const Dp=["top","right","bottom","left"],Mp=void 0;class Ip extends t.Group{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 r(t)||r(e)||r(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(e){super(),this.view=new t.Group,this.rect=new Ap({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Ap({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:o,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Ap({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Ap({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Ap({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...o,a,h,l,...r,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:n,resizePoints:r,resizeLines:a}=this,{stroke:h,strokeWidth:l,ignorePixelSnap:d}=e,c=this.getPointsStyle(),u=this.getMiddlePointsStyle(),g=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let t=0;t<8;t++)p=r[t],p.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:c[t/2%c.length])),p.rotation=(t-(t%2?1:0))/2*90,t%2&&a[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},g[(t-1)/2%g.length]||{}));n.set(this.getPointStyle(e.circle||e.rotatePoint||c[0])),s.set(Object.assign({stroke:h,strokeWidth:l,opacity:1,editConfig:Mp},e.rect||{}));const f=o(e.rectThrough)?i:e.rectThrough;s.hittable=!f,f&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&_.stintSet(t.__world,"ignorePixelSnap",d),Cp(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:o,skewX:r,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:n,rotation:o,skewX:r,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:n,circle:o,buttons:r,resizePoints:a,rotatePoints:l,resizeLines:d}=this,{editMask:c}=e,{middlePoint:u,resizeable:g,rotateable:p,hideOnSmall:_,editBox:f,mask:m,dimOthers:y,bright:v,spread:w,hideRotatePoints:x,hideResizeLines:b}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),w&&Yt.spread(t,w),this.view.worldOpacity){const{width:e,height:c}=t,m=h(_)?_:10,y=f&&!(_&&e<m&&c<m);let v,w,E,S={};for(let i=0;i<8;i++)Et.toPoint(Et.directionData[i],t,S),w=a[i],v=l[i],w.set(S),v.set(S),w.visible=y&&!(!g&&!p),v.visible=y&&p&&g&&!x,i%2&&(E=d[(i-1)/2],E.set(S),E.visible=w.visible&&!b,w.visible=v.visible=y&&!!u,(i+1)/2%2?(E.width=e+E.height,_&&2*w.width>e&&(w.visible=!1)):(E.width=c+E.height,_&&2*w.width>c&&(w.visible=!1)));o.visible=y&&p&&!(!i.circle&&!i.rotatePoint),o.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),r.visible=y&&r.children.length>0||0,r.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,o=Dp.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,o,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:o,flippedY:r}=this;let a=Dp.indexOf(e);(a%2&&o||(a+1)%2&&r)&&i&&(a=(a+2)%4);const h=i?Pp.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=o?-1:1,t.scaleY=r?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],o=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*r;o?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:o}=this.mergedConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:n,height:n,cornerRadius:o,offsetX:0,offsetY:0,editConfig:Mp};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.mergedConfig;return c(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return c(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return c(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:n,rotateable:o,skewable:r}=this.mergeConfig;"move"===i?s&&(this.moving=!0):(i.includes("rotate")||this.isHoldRotateKey(t)||!n?(o&&(this.rotating=!0),"resize-rotate"===i?n&&(this.resizing=!0):"resize-line"===e.name&&(r&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&n&&(this.resizing=!0),"skew"===i&&r&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:o}=this;if(i)e.onMove(t);else if(s||n||o){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),o&&e.onSkew(t)}Lp(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&&(Jr.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(e){this.canDragLimitAnimate&&(e instanceof t.DragEvent||e instanceof t.MoveEvent)&&this.transformTool.onMove(e),this.resizing&&(Jr.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(e){if(this.canGesture&&"drag"!==e.moveType&&(e.stop(),r(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,e.type){case t.MoveEvent.START:this.onTransformStart(e);break;case t.MoveEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onMove(e)}}onScale(e){if(this.canGesture&&(e.stop(),r(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onScale(e)}}onRotate(e){if(this.canGesture&&(e.stop(),r(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onRotate(e)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Lp(this,t)}onArrow(t){if(this.canUse&&this.mergeConfig.keyEvent){let e=0,i=0;const s=t.shiftKey?10:1;switch(t.code){case"ArrowDown":i=s;break;case"ArrowUp":i=-s;break;case"ArrowLeft":e=-s;break;case"ArrowRight":e=s}(e||i)&&this.transformTool.move(e,i)}}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(e){const{editor:i,target:s}=this;if(this.single){if(s.locked)return;if(s.isBranch&&!s.editInner){if(s.textBox){const{children:e}=s,n=e.find(e=>e.editable&&e instanceof t.Text)||e.find(e=>e instanceof t.Text);if(n)return i.openInnerEditor(n)}i.openGroup(s),i.target=i.selector.findDeepOne(e)}else i.openInnerEditor()}}listenPointEvents(e,i,s){e.direction=s,e.pointType=i,this.__eventIds.push(e.on_([[t.DragEvent.START,this.onDragStart,this],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.PointerEvent.ENTER,t=>{this.enterPoint=e,Lp(this,t)}],[t.PointerEvent.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:e,editor:i,__eventIds:s}=this;s.push(e.on_([[t.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this],[t.PointerEvent.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{s.push(i.app.on_([[[t.KeyEvent.HOLD,t.KeyEvent.UP],this.onKey,this],[t.KeyEvent.DOWN,this.onArrow,this],[[t.MoveEvent.START,t.MoveEvent.BEFORE_MOVE,t.MoveEvent.END],this.onMove,this,!0],[[t.ZoomEvent.START,t.ZoomEvent.BEFORE_ZOOM,t.ZoomEvent.END],this.onScale,this,!0],[[t.RotateEvent.START,t.RotateEvent.BEFORE_ROTATE,t.RotateEvent.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const Fp={x:0,y:0,width:1e5,height:1e5};class Wp extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Fp),Object.assign(this.__world,Fp)}__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()}}const zp='\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"/>',Up={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${zp}\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${zp}\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${zp}\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},Hp=new jt;function Np(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{Hp.setListWithFn(i,t=>t.getBounds("box","page")),0===Hp.width&&(Hp.width=.1),0===Hp.height&&(Hp.height=.1),e.reset(Hp.get())}),s.add(e)}const Yp=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Xp=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Vp={group(e,i,s){e.sort(Xp);const{app:n,parent:o}=e[0];let r;r=s&&s.add?s:new t.Group(s),o.addAt(r,o.children.indexOf(e[0])),e.sort(Yp);const a=new ft(i.worldTransform);return a.divideParent(o.scrollWorldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,n.lockLayout(),e.forEach(t=>t.dropTo(r)),n.unlockLayout(),r},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(Yp),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(Xp),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},Gp=se.get("EditToolCreator");function jp(){return t=>{qp.register(t)}}const Kp=jp,qp={list:{},register(t){const{tag:e}=t.prototype;Zp[e]&&Gp.repeat(e),Zp[e]=t},get:(t,e)=>new Zp[t](e)},{list:Zp}=qp;class Jp extends ep{constructor(t,e){super(t,e)}}Jp.BEFORE_OPEN="innerEditor.before_open",Jp.OPEN="innerEditor.open",Jp.BEFORE_CLOSE="innerEditor.before_close",Jp.CLOSE="innerEditor.close";class $p extends ep{constructor(t,e){super(t,e)}}$p.BEFORE_GROUP="editor.before_group",$p.GROUP="editor.group",$p.BEFORE_UNGROUP="editor.before_ungroup",$p.UNGROUP="editor.ungroup",$p.BEFORE_OPEN="editor.before_open_group",$p.OPEN="editor.open_group",$p.BEFORE_CLOSE="editor.before_close_group",$p.CLOSE="editor.close_group";const{updateMatrix:Qp}=dr,t_={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},e_="top-left";class i_ extends t.Rect{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Nr.CHANGE,e=>{if(this.checkChange&&t_[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,o="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const r=this.__;r[i]=n,Qp(this.parent),Qp(this);const a=new ft(this.__world);switch(r[i]=s,this.__layout.rotationChange(),Qp(this),this.changedTransform=new ft(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(e_,o);break;case"scaleX":t.scaleOf(e_,o,1);break;case"scaleY":t.scaleOf(e_,1,o);break;case"skewX":t.skewOf(e_,o,0);break;case"skewY":t.skewOf(e_,0,o)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class s_ extends ep{constructor(t,e){super(t,e)}}s_.BEFORE_MOVE="editor.before_move",s_.MOVE="editor.move";class n_ extends ep{constructor(t,e){super(t,e)}}n_.BEFORE_SCALE="editor.before_scale",n_.SCALE="editor.scale";class o_ extends ep{constructor(t,e){super(t,e)}}o_.BEFORE_ROTATE="editor.before_rotate",o_.ROTATE="editor.rotate";class r_ extends ep{constructor(t,e){super(t,e)}}r_.BEFORE_SKEW="editor.before_skew",r_.SKEW="editor.skew";class a_{onMove(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox;let o,{dragLimitAnimate:a}=s;const l=e.type===t.MoveEvent.END||e.type===t.DragEvent.END,d=r(i.draggable),c=!a||l||d,u={x:e.totalX,y:e.totalY};e instanceof t.MoveEvent&&ht.move(u,i.getWorldPointByLocal(n.totalOffset,null,!0)),e.shiftKey&&(Math.abs(u.x)>Math.abs(u.y)?u.y=0:u.x=0),o=t.DragEvent.getValidMove(i,n.point,u,c),(o.x||o.y)&&(a&&!d&&l?dr.animateMove(this,o,h(a)?a:.3):this.move(o))}onScale(e){const{target:i,mergeConfig:s,single:n,dragStartData:o}=this.editBox;let r,{around:a,lockRatio:h,flipable:l,editSize:d}=s;e instanceof t.ZoomEvent?(a||(a=i.getBoxPoint(e)),r=e.totalScale):r=e.getInnerTotal(i);const{direction:c}=e.current;(e.shiftKey||i.lockRatio)&&(h=!0);const u=Pp.getScaleData(i,o.bounds,c,r,h,Pp.getAround(a,e.altKey),l,!n||"scale"===d),g=i.x,p=i.y;e instanceof t.DragEvent&&this.editTool&&this.editTool.onScaleWithDrag?(u.drag=e,this.scaleWithDrag(u)):this.scaleOf(u.origin,u.scaleX,u.scaleY),ht.move(o.totalOffset,i.x-g,i.y-p)}onRotate(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox,{around:o,rotateAround:r,rotateGap:a,diagonalRotateKey:h}=s,{direction:l}=e.current;let d,c;if(e instanceof t.RotateEvent)c=e.rotation,d=r?Et.getPoint(r,i.boxBounds):i.getBoxPoint(e);else{const t=h?e.isHoldKeys(h):e.shiftKey,s=Pp.getRotateData(i,l,e,n,t?null:r||i.around||i.origin||o||"center");c=n.rotation+s.rotation-i.rotation,d=s.origin}if(c=M.float(M.getGapRotation(c,a,i.rotation),2),!c)return;const u=i.x,g=i.y;this.rotateOf(d,c),ht.move(n.totalOffset,i.x-u,i.y-g)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:o,skewY:r}=Pp.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Pp.getAround(s,t.altKey));(o||r)&&this.skewOf(n,o,r)}move(t,e=0){if(!this.checkTransform("moveable"))return;u(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeMove:r}=s;if(r){const s=r({target:i,x:t,y:e});if(u(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);n||i.safeChange(()=>i.move(t,e));const h={target:i,editor:o,moveX:a.x,moveY:a.y};this.emitEvent(new s_(s_.BEFORE_MOVE,h));const l=new s_(s_.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:n}=i;if(n){const{origin:i,scaleX:s,scaleY:o,drag:r}=t;if(!1===n({target:e,drag:r,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 n_(n_.BEFORE_SCALE,t));const o=new n_(n_.SCALE,t);this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeScale:h}=o;if(h){const s=h({target:n,origin:t,scaleX:e,scaleY:i});if(u(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.scaleOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new n_(n_.BEFORE_SCALE,c));const g=new n_(n_.SCALE,c);this.doScale(g),this.emitEvent(g)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),o=i?new ft(dr.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),r={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:o};this.emitEvent(new n_(n_.BEFORE_SCALE,r));const a=new n_(n_.SCALE,r);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeRotate:r}=s;if(r){const s=r({target:i,origin:t,rotation:e});if(h(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),l=!n&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),d={target:i,editor:o,worldOrigin:a,rotation:e,transform:l};this.emitEvent(new o_(o_.BEFORE_ROTATE,d));const c=new o_(o_.ROTATE,d);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeSkew:h}=o;if(h){const s=h({target:n,origin:t,skewX:e,skewY:i});if(u(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.skewOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new r_(r_.BEFORE_SKEW,c));const g=new r_(r_.SKEW,c);this.doSkew(g),this.emitEvent(g)}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(dr.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new ft(e.worldTransform);return t(),new ft(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}t.Editor=class extends t.Group{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 xh,this.openedGroupList=new xh,this.simulateTarget=new i_(this),this.editBox=new Ip(this),this.editToolList={},this.selector=new _p(this),this.editMask=new Wp(this),this.targetEventIds=[];let i=_.clone(Up);t&&(i=_.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),de.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?c(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>_.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}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&&Np(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||qp.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(r(s))e=s;else if(!1===s)return}if(qp.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($p.BEFORE_GROUP),this.target=Vp.group(this.list,this.element,t),this.emitGroupEvent($p.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent($p.BEFORE_UNGROUP,t)),this.target=Vp.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent($p.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent($p.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent($p.OPEN,t)}closeGroup(t){this.emitGroupEvent($p.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent($p.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!dr.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 $p(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||qp.get(t,this)}openInnerEditor(t,e,i){let s;if(r(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(r(i))s=i;else if(!1===i)return}qp.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(Jp.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Jp.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Jp.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Jp.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Jp(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&&(Vp.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Vp.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_(ta.START,this.onRenderStart,this),i&&i.on_(Nr.SCROLL,this.onChildScroll,this),t.on_(ta.CHILD_START,this.onAppRenderStart,this),t.on_(ea.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())}},ve([(t,e)=>{lo(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,app:r}=this,a=Object.assign({},t);if(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"),o(a.lockRatio)&&(a.lockRatio=!0))),n(a.dragLimitAnimate)&&(a.dragLimitAnimate=r&&r.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],t.Editor.prototype,"mergeConfig",void 0),ve([ip(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof xh?i:new xh(i),t.multiple&&Np(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new ep(ep.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new ep(ep.AFTER_SELECT,s))})],t.Editor.prototype,"target",void 0),ve([ip(function(t,e){t.emitEvent(new ep(ep.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],t.Editor.prototype,"hoverTarget",void 0),t.Editor=ve([Zo(a_,["editBox","editTool","emitEvent"])],t.Editor);class h_{static registerInnerEditor(){qp.register(this)}get tag(){return"InnerEditor"}get mode(){return"focus"}get editBox(){return this.editor.editBox}constructor(t){this.eventIds=[],this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,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)}}t.EditTool=class extends h_{static registerEditTool(){qp.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:o}=s;n.lockLayout(),o.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(n,e,i,r)}),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:o,list:r}=n;o.lockLayout(),r.forEach(t=>{const o="scale"!==n.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)}),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(n,e,i,r)}),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=ve([jp()],t.EditTool);const{left:l_,right:d_}=t.Direction9,{move:c_,copy:u_,toNumberPoints:g_}=ht;t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,o=t.target,r=i===l_;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,o.path=t}else if(o.points){const{points:t}=o,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,o.points=t}else{const t={x:0,y:0},{toPoint:i}=o;o.rotation=0,this.dragPoint(t,i,r,n,this.getInnerMove(o,e,s)),o.getLocalPointByInner(t,null,null,!0),o.getLocalPointByInner(i,null,null,!0),o.x=t.x,o.y=t.y,o.getInnerPointByLocal(i,null,null,!0),o.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=g_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:o,y:r}=n;i?(c_(t,o,r),s&&c_(e,-o,-r)):(s&&c_(t,-o,-r),c_(e,o,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,o=this.editor.element;let r,a;if(o.pathInputed?r=this.getFromToByPath(o.__.path):o.points&&(r=this.getFromToByPoints(o.__.points)),r){const{from:i,to:a}=r;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),u_(s[7],i),u_(e[7],i),u_(s[3],a),u_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===l_||t===d_,s[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=ve([jp()],t.LineEditTool);const{M:p_,L:__,C:f_,Q:m_,Z:y_,N:v_,D:w_,X:x_,G:b_,F:E_,O:S_,P:k_,U:T_}=Fe,B_={scale(t,e,i){if(!t)return;let s,n=0,o=t.length;for(;n<o;)switch(s=t[n],s){case p_:case __:P_(t,e,i,n,1),n+=3;break;case f_:P_(t,e,i,n,3),n+=7;break;case m_:P_(t,e,i,n,2),n+=5;break;case y_:n+=1;break;case v_:P_(t,e,i,n,2),n+=5;break;case w_:P_(t,e,i,n,2),n+=9;break;case x_:P_(t,e,i,n,2),n+=6;break;case b_:P_(t,e,i,n,2),n+=9;break;case E_:P_(t,e,i,n,2),n+=5;break;case S_:t[n]=b_,t.splice(n+4,0,t[n+3],0),P_(t,e,i,n,2),n+=9,o+=2;break;case k_:t[n]=E_,t.splice(n+4,0,t[n+3]),P_(t,e,i,n,2),n+=5,o+=1;break;case T_:P_(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let o=n?s+1:0,r=n?o+2*n:t.length;o<r;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:P_}=B_,R_=Z.get(),{topLeft:L_,top:C_,topRight:O_,right:A_,bottom:D_,left:M_}=t.Direction9;function I_(t,e,i){t.pathInputed?W_(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function F_(t,e,i,s){let o=e;if(!n(s)){const n=t.__layout;let{width:r,height:a}=n.boxBounds;switch(r*=i-e,a*=e-i,s){case C_:case D_:o=i,n.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case M_:case A_:n.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case L_:case O_:n.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=o;const r=t.__,{padding:a}=r;a&&(t.padding=c(a)?a.map(t=>t*o):a*o),r.__autoWidth||(t.width*=o),r.__autoHeight||(t.height*=o)}function W_(t,e,i){B_.scale(t.__.path,e,i),t.path=t.__.path}function z_(t,e,i){const{points:s}=t;u(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):B_.scalePoints(s,e,i),t.points=s}function U_(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)R_.a=e,R_.d=i,s[t].transform(R_,!0)}const H_=t.Leaf.prototype;H_.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))},H_.__scaleResize=function(t,e){I_(this,t,e)},H_.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},H_.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,n=i&&i.editor,o=n&&n.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===n.mergedConfig.editSize)F_(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:o}=this.__,{boxBounds:r}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=r.x),s&&"top"!==o&&1!==e&&(this.y+=r.y),I_(this,t,e)}},t.Path.prototype.__scaleResize=function(t,e){W_(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?W_(this,t,e):this.points?z_(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?W_(this,t,e):this.points?z_(this,t,e):I_(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){U_(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||I_(this,t,e),i&&U_(this,t,e)},de.add("resize"),de.add("editor","resize"),ce.editor=function(e,i){const s=new t.Editor(e);return i&&i.sky.add(i.editor=s),s},t.Box.addAttr("textBox",!1,fo),t.UI.addAttr("editConfig",void 0,fo),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),fo),t.UI.addAttr("editInner","PathEditor",fo),t.Group.addAttr("editInner","",fo),t.Text.addAttr("editInner","TextEditor",fo),t.UI.setEditConfig=function(t){this.changeAttr("editConfig",t)},t.UI.setEditOuter=function(t){this.changeAttr("editOuter",t)},t.UI.setEditInner=function(t){this.changeAttr("editInner",t)};const N_={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},Y_={top:"flex-start",middle:"center",bottom:"flex-end"},X_={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function V_(t,e,i){const{style:s}=t,{fill:o,padding:a,textWrap:h,textOverflow:l,textDecoration:d}=e;let g;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";c(e)&&(e=e[0]);if(u(e))switch(e.type){case"solid":i=Zh.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Zh.string(r(t)?t:t.color);break;default:n(e.r)||(i=Zh.string(e))}else i=e;t.color=i}(s,o),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,u(d)?(g=d.type,d.color&&(s.textDecorationColor=Zh.string(d.color))):g=d,s.textDecoration=X_[g],s.textTransform=N_[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=Y_[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px",s.whiteSpace="none"===h||e.__.__autoWidth?"nowrap":"normal",s.wordBreak="break"===h?"break-all":"normal",s.textIndent=(e.paraIndent||0)*i+"px",s.padding=c(a)?a.map(t=>t*i+"px").join(" "):(a||0)*i+"px",s.textOverflow="show"===l?"":"hide"===l?"clip":l}function G_(t){const{scroll:e,disabled:i}=t.app.config.move;return!e||i?"":!0===e?"free":e}function j_(e,i,s){K_(e.parentApp?e.parentApp:e,i),e.isApp||s||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,t=>{const i=e.getValidMove(t.moveX,t.moveY,!1);if(G_(e).includes("limit")){const s=e.getValidMove(0,0);if(s.x||s.y){const e=100,n=200,o="drag"===t.moveType?.3:.05;Math.abs(s.x)>e?i.x=0:i.x*=o,Math.abs(s.y)>n?i.y=0:i.y*=o}}e.zoomLayer.move(i)}),e.on_(t.MoveEvent.DRAG_ANIMATE,()=>{const t=e.getValidMove(0,0);(t.x||t.y)&&e.interaction.stopDragAnimate()}),e.on_(t.MoveEvent.END,t=>{dr.animateMove(e.zoomLayer,e.getValidMove(t.moveX,t.moveY))}),e.on_(t.ZoomEvent.BEFORE_ZOOM,t=>{const{zoomLayer:i}=e,s=e.getValidScale(t.scale);1!==s&&i.scaleOfWorld(t,s)}))}function K_(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&_.assign(i,e),_.assign(t.config,i,t.userConfig)}t.TextEditor=class extends h_{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:e}=this,{config:i}=e.app,s=this.editTarget;s.textEditing=!0,this.isHTMLText=!(s instanceof t.Text),this._keyEvent=i.keyEvent,i.keyEvent=!1;const n=this.editDom=document.createElement("div");n.classList.add("leafer-text-editor");const{style:o}=n;n.contentEditable="true",o.position="fixed",o.transformOrigin="left top",o.boxSizing="border-box",this.isHTMLText?n.innerHTML=String(s.text):n.innerText=String(s.text);const{view:r}=e.app;(this.inBody=r instanceof HTMLCanvasElement)?document.body.appendChild(n):r.appendChild(n),this.eventIds=[e.app.on_(t.PointerEvent.DOWN,t=>{let i,{target:s}=t.origin;for(;s;)s===n&&(i=!0),s=s.parentElement;i||e.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),n.addEventListener("focus",this.onFocus),n.addEventListener("input",this.onInput),n.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const a=window.getSelection(),h=document.createRange();if(this.config.selectAll)h.selectNodeContents(n);else{const t=n.childNodes[0];t&&(h.setStartAfter(t),h.setEndAfter(t)),h.collapse(!0)}a.removeAllRanges(),a.addRange(h)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=document.createTextNode("​"),s=window.getSelection().getRangeAt(0);s.deleteContents(),s.insertNode(i),s.insertNode(e),s.setStartAfter(e),s.setEndAfter(e),this.onInput()}}onPaste(t){if(this.isHTMLText)return;t.preventDefault();const e=t.clipboardData;if(!e)return;let i=e.getData("text/plain").replace(/\r\n?/g,"\n");const s=window.getSelection();if(!s||!s.rangeCount)return;const n=s.getRangeAt(0);n.deleteContents();const o=i.split("\n"),r=document.createDocumentFragment();o.forEach((t,e)=>{e>0&&r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(t))}),n.insertNode(r),n.collapse(!1),s.removeAllRanges(),s.addRange(n),this.onInput()}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;let{width:i,height:s}=t,n=0,o=0;i*=e,s*=e;const r=t.__;if(r.__autoWidth)switch(i+=20,r.textAlign){case"center":n=r.autoSizeAlign?-i/2:-10;break;case"right":n=r.autoSizeAlign?-i:-20}if(r.__autoHeight)switch(s+=20,r.verticalAlign){case"middle":o=r.autoSizeAlign?-s/2:-10;break;case"bottom":o=r.autoSizeAlign?-s:-20}const{x:a,y:h}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:l,b:d,c:c,d:u,e:g,f:p}=new ft(t.worldTransform).scale(1/e).translateInner(n,o),{style:_}=this.editDom;_.transform=`matrix(${l},${d},${c},${u},${g},${p})`,_.left=a+"px",_.top=h+"px",_.width=i+"px",_.height=s+"px",this.isHTMLText||V_(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),"\n"===t.text&&(t.text=""),t.textEditing=void 0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),i.removeEventListener("paste",this.onPaste),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}},t.TextEditor=ve([Kp()],t.TextEditor),de.add("text-editor","editor");const q_=se.get("LeaferTypeCreator"),Z_={list:{},register(t,e){J_[t]&&q_.repeat(t),J_[t]=e},run(t,e){const i=J_[t];i&&i(e)}},{list:J_,register:$_}=Z_;$_("viewport",j_),$_("custom",function(t){j_(t,null,!0)}),$_("design",function(t){j_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),$_("document",function(t){j_(t,{zoom:{min:1},move:{scroll:"limit"}})});const Q_={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=ht.getCenter(e.from,i.from),n=ht.getCenter(e.to,i.to),o={x:n.x-s.x,y:n.y-s.y},r=ht.getDistance(e.from,i.from);return{move:o,scale:ht.getDistance(e.to,i.to)/r,rotation:ht.getRotation(e.from,i.from,e.to,i.to),center:n}},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),n=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&n<1?"none":i>=s&&i>=n?"move":s>=n?"zoom":"rotate"},detect(t,e){const{state:i}=tf,s=tf.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),tf.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)?tf.getType(i.totalData,e):"none"},add(t,e){e&&(ht.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=tf;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},tf=Q_,{abs:ef,max:sf}=Math,{sign:nf,within:of}=M,rf={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const o=ef(s),r=ef(n);return o>50&&(s=sf(50,o/3)*nf(s)),r>50&&(n=sf(50,r/3)*nf(n)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:o}=e;const r=t.deltaY||t.deltaX;if(n?(i="mouse"===n||!t.deltaX&&(te.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){o=of(o,0,1);const i=t.deltaY?e.delta.y:e.delta.x,n=of(1-ef(r)/(4*i)*o,.5,2);s=r>0?n:1/n}return s}};let af,hf,lf,df;class cf{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(e){const{interaction:i}=this;e.moveType||(e.moveType="move"),this.moveData||(this.setPath(e),af=0,hf=0,this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0,totalX:af,totalY:hf}),i.emit(t.MoveEvent.START,this.moveData)),e.path=this.moveData.path,e.totalX=af+=e.moveX,e.totalY=hf+=e.moveY,i.emit(t.MoveEvent.BEFORE_MOVE,e),i.emit(t.MoveEvent.MOVE,e),this.transformEndWait()}zoom(e){const{interaction:i}=this;this.zoomData||(this.setPath(e),lf=1,this.zoomData=Object.assign(Object.assign({},e),{scale:1,totalScale:lf}),i.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,e.totalScale=lf*=e.scale,i.emit(t.ZoomEvent.BEFORE_ZOOM,e),i.emit(t.ZoomEvent.ZOOM,e),this.transformEndWait()}rotate(e){const{interaction:i}=this;this.rotateData||(this.setPath(e),df=0,this.rotateData=Object.assign(Object.assign({},e),{rotation:0,totalRotation:df}),i.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,e.totalRotation=df+=e.rotation,i.emit(t.RotateEvent.BEFORE_ROTATE,e),i.emit(t.RotateEvent.ROTATE,e),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:e,moveData:i,zoomData:s,rotateData:n}=this;i&&e.emit(t.MoveEvent.END,Object.assign(Object.assign({},i),{totalX:af,totalY:hf})),s&&e.emit(t.ZoomEvent.END,Object.assign(Object.assign({},s),{totalScale:lf})),n&&e.emit(t.RotateEvent.END,Object.assign(Object.assign({},n),{totalRotation:df})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const uf=t.Leafer.prototype,gf=new jt,pf=new pt;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){Z_.run(t,this)},uf.getValidMove=function(t,e,i=!0){const{disabled:s,scrollSpread:n}=this.app.config.move;pf.set(t,e);const o=G_(this);return o&&(o.includes("x")?pf.y=0:o.includes("y")?pf.x=0:Math.abs(pf.x)>Math.abs(pf.y)?pf.y=0:pf.x=0,i&&o.includes("limit")&&(gf.set(this.__world).addPoint(this.zoomLayer),n&&gf.spread(n),Md.getValidMove(gf,this.canvas.bounds,"auto",pf,!0),o.includes("x")?pf.y=0:o.includes("y")&&(pf.x=0))),{x:s?0:pf.x,y:s?0:pf.y}},uf.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),n?1:t};const mf=sc.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:n}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):n&&(t.deltaX*=n),t.deltaY>0?s&&(t.deltaY*=s):n&&(t.deltaY*=n);const o=e.getScale?e.getScale(t,e):rf.getScale(t,e);if(1!==o)this.zoom(ff(o,t));else{const s=e.getMove?e.getMove(t,e):rf.getMove(t,e);i.snap&&ht.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 n=Q_.getData(e),{moving:o,zooming:r,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(Q_.detect(n,u(s)?s:{})){case"move":o=!0;break;case"zoom":r=!0;break;case"rotate":a=!0;break;default:return}Q_.reset()}o||(n.center=Q_.state.center)}else o=r=a=!0;var h,l;Object.assign(t,n.center),t.multiTouch=!0,a&&this.rotate((h=n.rotation,l=t,Object.assign(Object.assign({},l),{rotation:h}))),r&&this.zoom(ff(n.scale,t)),o&&this.move(_f(n.move,t))};const yf=jd.prototype,{abs:vf,min:wf,max:xf,hypot:bf}=Math;function Ef(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}yf.checkDragEndAnimate=function(e){const{interaction:i}=this,s=this.canAnimate&&this.moving&&i.m.dragAnimate;if(s){const n=h(s)?s:.95,o=.15,r=150;let a,l,d,c=0,u=0,g=0,p=0,_=3;const{dragDataList:f}=this,m=f.length;for(let t=m-1;t>=xf(m-3,0)&&(d=f[t],!(d.time&&Date.now()-d.time>100));t--)a=_--,c+=d.moveX*a,u+=d.moveY*a,p+=a,l=bf(d.moveX,d.moveY),l>g&&(g=l);if(p&&(c/=p,u/=p),g>8){const t=1.15+wf((g-8)/17,1)*(1.6-1.15);c*=t,u*=t}const y=xf(vf(c),vf(u));y>r&&(l=r/y,c*=l,u*=l);const v=()=>{if(c*=n,u*=n,e=Object.assign({},e),vf(c)<o&&vf(u)<o)return this.dragEndReal(e);ht.move(e,c,u),this.drag(e),this.animate(v),i.emit(t.MoveEvent.DRAG_ANIMATE,e)};this.animate(v)}return s},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:n,dragOut:o}=e.m;if(!o||!s||!n)return;const r=e.shrinkCanvasBounds,{x:a,y:h}=r,l=Yt.maxX(r),d=Yt.maxY(r),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let g=0,p=0;this.autoMoveTimer=setInterval(()=>{g+=c,p+=u,ht.move(i,c,u),ht.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:g,totalY:p,moveType:"drag"})),e.pointerMoveReal(t)},10)},yf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},de.add("viewport"),de.add("view"),t.Leafer.prototype.zoom=function(t,e,i,s){let n;g(e)?(n=e.padding,i=e.scroll,s=e.transition):n=e;const{zoomLayer:a}=this,l=this.canvas.bounds.clone().shrink(o(n)?30:n),d=new jt,p={x:l.x+l.width/2,y:l.y+l.height/2};let _;a.killAnimate();const{x:f,y:m,scaleX:y,scaleY:v}=a.__,{boxBounds:w}=a;if(r(t))switch(t){case"in":_=Ef(y,"in");break;case"out":_=Ef(y,"out");break;case"fit":t=w;break;case"fit-width":(t=new jt(w)).height=0;break;case"fit-height":(t=new jt(w)).width=0}else h(t)&&(_=t/y);if(_)_=this.getValidScale(_),a.scaleOfWorld(p,_,_,!1,s);else if(u(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=c(t);if(n||t.tag){const e=n?t:[t];d.setListWithFn(e,yr.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:o,height:r}=t;return r||(r=o*(e.height/e.width),i=!0),o||(o=r*(e.width/e.height),i=!0),i?{x:s,y:n,width:o,height:r}:t}(t,l);d.set(a.getWorldBounds(e))}const{width:o,height:r}=d;let h=l.x-d.x,u=l.y-d.y;return i?(h+=Math.max((l.width-o)/2,0),u+=Math.max((l.height-r)/2,0)):(_=this.getValidScale(Math.min(l.width/o,l.height/r)),h+=(l.width-o*_)/2,u+=(l.height-r*_)/2,ht.scaleOf(e,d,_),d.scaleOf(d,_),e.scaleX*=_,e.scaleY*=_),"x"===i?u=0:"y"===i&&(h=0),ht.move(e,h,u),d.move(h,u),a.set(e,s),d}return a.worldBoxBounds};class Sf extends t.Group{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&_.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(e){let i;r(e)?(i={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===e&&(i.fill="white",i.stroke="rgba(0,0,0,0.2)")):i=e,this.scrollXBar||this.addMany(this.scrollXBar=new t.Box,this.scrollYBar=new t.Box),i=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},i),i.height||(i.height=i.width),this.scrollXBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:o}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(o))return;this.scrollBounds=new jt(o);const r=n.bounds.clone().shrink(i),a=r.clone().add(o),h=this.ratioX=r.width/a.width,l=this.ratioY=r.height/a.height,d=(r.x-a.x)/a.width,c=(r.y-a.y)/a.height,u=h<1,g=l<1,{scrollXBar:p,scrollYBar:_}=this,{x:f,y:m,width:y,height:v}=r.shrink([2,g?_.width+6:2,u?p.height+6:2,2]);p.set({x:f+y*d,y:m+v+2,width:Math.max(y*h,e),visible:u}),_.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:g})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:e,scrollYBar:i}=this;this.__eventIds=[e.on_(t.DragEvent.DRAG,this.onDrag,this),i.on_(t.DragEvent.DRAG,this.onDrag,this),e.on_(t.DragEvent.END,this.onDragEnd,this),i.on_(t.DragEvent.END,this.onDragEnd,this),this.target.on_(ta.BEFORE,()=>this.update(!0)),this.target.leafer.on_(Jr.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}de.add("scroll");class kf extends Pl{setText(t){this._text=t,this.__htmlChanged=!0}}const Tf={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",hellip:"…",middot:"·",bull:"•",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",cent:"¢",pound:"£",yen:"¥",euro:"€",times:"×",divide:"÷",plusmn:"±",minus:"−",frac12:"½",frac14:"¼",frac34:"¾",sup2:"²",sup3:"³",deg:"°",reg:"®",copy:"©",trade:"™",section:"§",para:"¶",dagger:"†",Dagger:"‡",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",alpha:"α",beta:"β",gamma:"γ",delta:"δ",pi:"π",sigma:"σ",omega:"ω",Omega:"Ω",micro:"µ",infinity:"∞",not:"¬",equiv:"≡",le:"≤",ge:"≥"};t.HTMLText=class extends t.Image{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),o=s+10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${n}">\n <foreignObject width="${o}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.decodeText(this.text)}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),t.__naturalWidth=o/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}__draw(t,e,i){this.textEditing&&!e.exporting||super.__draw(t,e,i)}decodeText(t){if(!t.includes("&"))return t;let e,i,s="",n=0;for(;n<t.length;){if("&"===t[n]){const o=t.indexOf(";",n+1);if(o>n+1&&(e=t.slice(n+1,o),i=Tf[e],void 0!==i)){s+=i,n=o+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){r(t)?Tf[t]=e:Object.assign(Tf,t)}},ve([No(kf)],t.HTMLText.prototype,"__",void 0),ve([bo("")],t.HTMLText.prototype,"text",void 0),ve([fo("TextEditor")],t.HTMLText.prototype,"editInner",void 0),ve([Co(!1)],t.HTMLText.prototype,"textEditing",void 0),t.HTMLText=ve([Jo()],t.HTMLText),de.add("html");class Bf extends vl{}function Pf(t){return go(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__,e="none"!==t.startArrow||"none"!==t.endArrow;t.__useArrow!==e&&So(this),t.__useArrow=e,Po(this)}}}))}t.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){$h.register(t,e)}},ve([No(Bf)],t.Arrow.prototype,"__",void 0),ve([Pf("angle")],t.Arrow.prototype,"endArrow",void 0),t.Arrow=ve([Jo()],t.Arrow);const{M:Rf,L:Lf,C:Cf,Q:Of,O:Af}=Fe,{rotate:Df,copyFrom:Mf,scale:If}=ht,Ff={},Wf={layout(t,e,i,s,n,o,r){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case Rf:case Lf:zf(t,l+1,e,i,s,n,o,r),l+=3;break;case Cf:for(h=1;h<6;h+=2)zf(t,l+h,e,i,s,n,o,r);l+=7;break;case Of:for(h=1;h<4;h+=2)zf(t,l+h,e,i,s,n,o,r);l+=5;break;case Af:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),o&&(t[l+4]+=o,t[l+5]+=o),l+=7}},rotate(t,e,i){Wf.layout(t,0,0,1,1,e,i)}};function zf(t,e,i,s,n,o,r,a){Mf(Ff,t[e],t[e+1]),r&&Df(Ff,r,a),n&&If(Ff,n,o),t[e]=i+Ff.x,t[e+1]=s+Ff.y}const{layout:Uf,rotate:Hf}=Wf,{getAngle:Nf}=ht,Yf={x:-.5},Xf={connect:Yf,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},Vf={connect:Yf,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},Gf={connect:Yf,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},jf={connect:Yf,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},Kf={offset:Yf,path:[...Gf.path],dashPath:[1,-2.5,0,2,-1,0]};Hf(Kf.path,180,{x:-1.5,y:0});const qf={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},Zf={connect:{x:.5},path:[...qf.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},Jf={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},$f={path:[...Jf.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},Qf=_.clone(Jf),tm=_.clone($f);Hf(Qf.path,45),Hf(tm.path,45);const em={angle:Xf,"angle-side":Vf,arrow:jf,triangle:Gf,"triangle-flip":Kf,circle:Zf,"circle-line":qf,square:$f,"square-line":Jf,diamond:tm,"diamond-line":Qf,mark:{offset:Yf,path:[1,0,-2,2,0,2]}};function im(t,e,i,s,n,o,r){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;u(e)?e.type?(h=e.scale,a=em[e.type]):a=e:a=em[e];const{offset:c,connect:g,path:p,dashPath:_}=a;let f=g?g.x:0,m=c?c.x:0;const y=[...p];return r&&_&&y.push(..._),"none"!==l&&(f-=.5),c&&("round"===d&&c.roundJoin?m+=c.roundJoin:"bevel"===d&&c.bevelJoin&&(m+=c.bevelJoin)),h&&Uf(y,0,0,h,h),m&&Uf(y,m,0),Uf(y,s.x,s.y,n,n,Nf(i,s)),o.x=(f+m)*n,y}const{M:sm,L:nm,C:om,Q:rm,Z:am,N:hm,D:lm,X:dm,G:cm,F:um,O:gm,P:pm,U:_m}=Fe,{copy:fm,copyFrom:mm,getDistancePoint:ym}=ht,vm={},wm={},xm={},bm={},Em={},Sm={list:em,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:o,cornerRadius:r}=t.__,a=!r;let h,l=0,d=o.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=o[l],h){case sm:case nm:(c<2||l+6>=d)&&(mm(Em,o[l+1],o[l+2]),!c&&u&&fm(wm,Em)),l+=3;break;case om:(1===c||l+7>=d-3)&&km(o,bm,Em,l+3),l+=7;break;case rm:(1===c||l+5>=d-3)&&km(o,bm,Em,l+1),l+=5;break;case am:return;case hm:l+=5;break;case lm:l+=9;break;case dm:l+=6;break;case cm:l+=9;break;case um:l+=5;break;case gm:l+=7;break;case pm:l+=4;break;case _m:(1===c||l+6>=d-3)&&(km(o,bm,Em,l+1),l+6!==d&&(Em.x-=(Em.x-bm.x)/10,Em.y-=(Em.y-bm.y)/10)),l+=6}if(c++,1===c&&h!==sm)return;if(2===c&&u&&fm(xm,h===nm?Em:bm),l===d){const r=t.__.__pathForRender=a?[...o]:o,d=t.__.__pathForArrow=[];if(u){const i=im(t,e,xm,wm,s,vm,!!n);n?d.push(...i):r.push(...i),vm.x&&(ym(wm,xm,-vm.x,!0),r[1]=xm.x,r[2]=xm.y)}if(i&&"none"!==i){const e=im(t,i,bm,Em,s,vm,!!n);if(n?d.push(...e):r.push(...e),vm.x){let t;switch(ym(Em,bm,-vm.x,!0),h){case nm:t=l-3+1;break;case om:t=l-7+5;break;case rm:t=l-5+3;break;case _m:t=l-6+3}t&&Tm(r,bm,t)}}}else fm(bm,Em)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function km(t,e,i,s){mm(e,t[s],t[s+1]),mm(i,t[s+2],t[s+3])}function Tm(t,e,i){t[i]=e.x,t[i+1]=e.y}de.add("arrow"),t.UI.addAttr("startArrow","none",Pf),t.UI.addAttr("endArrow","none",Pf),Object.assign($h,Sm),Object.assign(Qh,{strokeArrow(t,e,i,s){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});t.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},ve([No(class extends fl{})],t.Flow.prototype,"__",void 0),ve([vo("x")],t.Flow.prototype,"flow",void 0),t.Flow=ve([Jo()],t.Flow);const Bm={},Pm={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},Rm={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function Lm(t,e,i){const s=t.__,{contentBounds:n}=t.__layout;Tt.toPoint(i,e,n,Bm),e.x=s.__autoWidth?n.x:Bm.x,e.y=s.__autoHeight?n.y:Bm.y}const{move:Cm}=ht;function Om(t,e,i,s,n,o){const{children:r}=t;let a,h,{x:l,start:d}=e,c=s;l+=i;for(let t=0,i=e.count;t<i;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=s+(e.height-h.height)/("center"===n?2:1)),Cm(a,l-h.x,c-h.y),l+=h.width+e.gap):i++}function Am(t,e,i){const s="width"===i?"height":"width";t[i]=Math.max(t[i],e[i]),t[s]+=t.count?e[s]+t.gap:e[s],t.list.push(e),t.count++}const Dm={};function Mm(t,e){const{gap:i,flowAlign:s,flowWrap:n,__autoWidth:o,__autoHeight:a}=t.__,h=n&&(e?!o:!a);return u(i)?(Dm.xGap=i.x||0,Dm.yGap=i.y||0):Dm.xGap=Dm.yGap=d(i),Dm.isAutoXGap=r(Dm.xGap)&&!o,Dm.isAutoYGap=r(Dm.yGap)&&!a,Dm.complex=h||"top-left"!==s||t.__hasGrow||Dm.isAutoXGap||Dm.isAutoYGap,Dm.wrap=h,Dm.complex&&(Dm.isFitXGap="fit"===Dm.xGap&&!o,Dm.isFitYGap="fit"===Dm.yGap&&!a,u(s)?(Dm.contentAlign=s.content||"top-left",Dm.rowXAlign=s.x||"from",Dm.rowYAlign=s.y||"from"):(Dm.contentAlign=s,Dm.rowXAlign=Pm[s],Dm.rowYAlign=Rm[s])),Dm}function Im(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function Fm(t,e,i,s){const{count:n}=t;n>1&&(i>t[e]||s)&&(t.gap=(i-t[e])/(n-1),t[e]=i)}function Wm(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:zm}=M;function Um(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.width)/l,{children:u}=t;if(!(c<=0)){e.width=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__widthGrow)&&(r=Hm(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.widthRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__widthGrow,n=e/i*s,r=Hm(t,o=t.__flowBounds,o.width+n),e-=n-r,i-=s})}(h,a,l)}}function Hm(t,e,i){const{widthRange:s,lockRatio:n}=t.__,o=s?zm(i,s):i,r=o/e.width;return t.scaleResize(r,n?r:1),e.width=o,i-o}const{within:Nm}=M;function Ym(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.height)/l,{children:u}=t;if(!(c<=0)){e.height=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__heightGrow)&&(r=Xm(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.heightRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__heightGrow,n=e/i*s,r=Xm(t,o=t.__flowBounds,o.height+n),e-=n-r,i-=s})}(h,a,l)}}function Xm(t,e,i){const{heightRange:s,lockRatio:n}=t.__,o=s?Nm(i,s):i,r=o/e.height;return t.scaleResize(n?r:1,r),e.height=o,i-o}const{move:Vm}=ht;function Gm(t,e){const i="width",{children:s,itemBox:n}=t,o=Mm(t,!0),{complex:r,wrap:a,xGap:h,yGap:l,isAutoXGap:d,isFitXGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=d?0:h;let p,_,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(_=Wm(p,n),r?(p.__flowBounds=_,y||(y=Im(m,g)),a&&y.count&&y.width+_.width>x&&(y.grow?Um(t,y,x,e):d&&Fm(y,i,x,c),Am(u,y,i),y=Im(m,g)),f=_.width,p.__widthGrow&&(y.grow+=p.__widthGrow,f=0,p.__.widthRange&&(y.hasRangeSize=!0)),p.__heightGrow&&Xm(p,_,b),y.width+=y.count?f+g:f,y.height=Math.max(y.height,_.height),y.count++):(Vm(p,v-_.x,w-_.y),v+=_.width+g));if(r&&y){const{isAutoYGap:s,isFitYGap:n,contentAlign:r,rowXAlign:h,rowYAlign:g}=o;y.count&&(y.grow?Um(t,y,x,e):d&&Fm(y,i,x,c),a&&Am(u,y,i)),a?(s?Fm(u,"height",b,n):u.height+=(u.gap=l)*(u.list.length-1),function(t,e,i,s){Lm(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=Pm[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.x=e.width-t.width,"center"===s&&(t.x/=2)}}(t,u,r,h),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],Om(t,r,a,h,i,s),h+=r.height+e.gap}(t,u,g,e)):(Lm(t,y,r),Om(t,y,0,y.y,g,e))}}const{move:jm}=ht;function Km(t,e,i,s,n,o){const{children:r}=t;let a,h,{y:l,start:d}=e,c=i;l+=s;for(let t=0,s=e.count;t<s;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=i+(e.width-h.width)/("center"===n?2:1)),jm(a,c-h.x,l-h.y),l+=h.height+e.gap):s++}const{move:qm}=ht;function Zm(t,e){const i="height",{children:s,itemBox:n}=t,o=Mm(t,!1),{complex:r,wrap:a,xGap:h,yGap:l,isAutoYGap:d,isFitYGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=d?0:l;let p,_,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(_=Wm(p,n),r?(p.__flowBounds=_,y||(y=Im(m,g)),a&&y.count&&y.height+_.height>b&&(y.grow&&Ym(t,y,b,e),d&&Fm(y,i,b,c),Am(u,y,i),y=Im(m,g)),f=_.height,p.__heightGrow&&(y.grow+=p.__heightGrow,f=0,p.__.heightRange&&(y.hasRangeSize=!0)),p.__widthGrow&&Hm(p,_,x),y.height+=y.count?f+g:f,y.width=Math.max(y.width,_.width),y.count++):(qm(p,v-_.x,w-_.y),w+=_.height+g));if(r&&y){const{isAutoXGap:s,isFitXGap:n,contentAlign:r,rowXAlign:l,rowYAlign:g}=o;y.count&&(y.grow&&Ym(t,y,b,e),d&&Fm(y,i,b,c),a&&Am(u,y,i)),a?(s?Fm(u,"width",x,n):u.width+=(u.gap=h)*(u.list.length-1),function(t,e,i,s){Lm(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=Rm[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.y=e.height-t.height,"center"===s&&(t.y/=2)}}(t,u,r,g),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],Km(t,r,a,h,i,s),a+=r.width+e.gap}(t,u,l,e)):(Lm(t,y,r),Km(t,y,y.x,0,l,e))}}function Jm(t){return go(t,t=>({set(e){const i=h(e)?e:0;"autoWidth"===t?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent(()=>{this.parent.__hasGrow=!0}),this.__setAttr(t,e)&&So(this)}}))}de.add("flow","resize");const $m=t.Box.prototype,{__updateBoxBounds:Qm}=t.Group.prototype;t.UI.addAttr("flow",!1,vo),t.UI.addAttr("gap",0,bo),t.UI.addAttr("flowAlign","top-left",bo),t.UI.addAttr("flowWrap",!1,bo),t.UI.addAttr("itemBox","box",bo),t.UI.addAttr("inFlow",!0,bo),t.UI.addAttr("autoWidth",void 0,Jm),t.UI.addAttr("autoHeight",void 0,Jm),t.UI.addAttr("autoBox",void 0,bo);const{copyAndSpread:ty}=Yt;$m.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:Gm(this);break;case"y":Zm(this);break;case"x-reverse":Gm(this,!0);break;case"y-reverse":Zm(this,!0)}t&&(this.leafer.created=!0)},$m.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,i=e.contentBounds===e.boxBounds;t?(i&&e.shrinkContent(),ty(e.contentBounds,e.boxBounds,t,!0)):i||e.shrinkContentCancel()},$m.__updateBoxBounds=function(t){if(this.children.length&&!this.pathInputed){const e=this.__,{flow:i}=e;if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),i&&!t?this.__updateRectBoxBounds():Qm.call(this);const{boxBounds:s}=this.__layout;e.__autoSize||(e.__autoWidth?(i||(s.width+=s.x,s.x=0),s.height=e.height,s.y=0):(i||(s.height+=s.y,s.y=0),s.width=e.width,s.x=0)),i&&t&&e.padding&&ty(s,s,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();i&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};const{cos:ey,sin:iy,pow:sy,sqrt:ny,abs:oy,ceil:ry,floor:ay,round:hy,PI:ly}=Math,dy=5*ly,cy=1.70158,uy=2.5949095,gy=7.5625,py=2.75;function _y(t){return e=>sy(e,t)}function fy(t){return e=>1-sy(1-e,t)}function my(t){return e=>e<.5?.5*sy(2*e,t):1-.5*sy(2-2*e,t)}function yy(t){return t<1/py?gy*t*t:t<2/py?gy*(t-=1.5/py)*t+.75:t<2.5/py?gy*(t-=2.25/py)*t+.9375:gy*(t-=2.625/py)*t+.984375}function vy(t,e,i,s){const n={};return o=>{const r=~~(1e4*o),a=n[r];if(a)return a;let h,l,d,c=o;for(let e=0;e<8&&(h=1-c,d=wy(c,t,i)-o,l=3*h*h*t+6*h*c*(i-t)+3*c*c*(1-i),!(oy(l)<1e-6));e++)c-=d/l;return n[r]=wy(c,e,s)}}function wy(t,e,i){const s=1-t;return 3*s*s*t*e+3*s*t*t*i+t*t*t}const xy={get(t){const{list:e}=xy;return r(t)?e[t||"ease"]:u(t)?e[t.name].apply(e,c(t.value)?t.value:[t.value]):e.ease},register(t,e){xy.list[t]=e},list:{linear:t=>t,ease:vy(.25,.1,.25,1),"ease-in":vy(.42,0,1,1),"ease-out":vy(0,0,.58,1),"ease-in-out":vy(.42,0,.58,1),"sine-in":t=>1-ey(t*ly*.5),"sine-out":t=>iy(t*ly*.5),"sine-in-out":t=>.5*(1-ey(t*ly)),"quad-in":_y(2),"quad-out":fy(2),"quad-in-out":my(2),"cubic-in":_y(3),"cubic-out":fy(3),"cubic-in-out":my(3),"quart-in":_y(4),"quart-out":fy(4),"quart-in-out":my(4),"quint-in":_y(5),"quint-out":fy(5),"quint-in-out":my(5),"expo-in":t=>t?sy(2,10*t-10):0,"expo-out":t=>1===t?1:1-sy(2,10*-t),"expo-in-out":t=>0===t||1===t?t:t<.5?.5*sy(2,2*t*10-10):.5*(2-sy(2,10-2*t*10)),"circ-in":t=>1-ny(1-sy(t,2)),"circ-out":t=>ny(1-sy(t-1,2)),"circ-in-out":t=>t<.5?.5*(1-ny(1-sy(2*t,2))):.5*(ny(1-sy(2-2*t,2))+1),"back-in":t=>((cy+1)*t-cy)*t*t,"back-out":t=>(t-=1)*t*((cy+1)*t+cy)+1,"back-in-out":t=>t<.5?(t*=2)*t*((uy+1)*t-uy)*.5:.5*((t=2*t-2)*t*((uy+1)*t+uy)+2),"elastic-in":t=>0===t||1===t?t:-sy(2,10*(t-1))*iy((t-1.1)*dy),"elastic-out":t=>0===t||1===t?t:sy(2,-10*t)*iy((t-.1)*dy)+1,"elastic-in-out":t=>0===t||1===t?t:t<.5?-sy(2,10*((t*=2)-1))*iy((t-1.1)*dy)*.5:sy(2,10*(1-(t*=2)))*iy((t-1.1)*dy)*.5+1,"bounce-in":t=>1-yy(1-t),"bounce-out":yy,"bounce-in-out":t=>t<.5?.5*(1-yy(1-2*t)):.5*(1+yy(2*t-1)),"cubic-bezier":vy,steps:function(t,e="floor"){return i=>("floor"===e?ay(i*t):"ceil"===e?ry(i*t):hy(i*t))/t}}};function by(t){return(e,i)=>{Object.defineProperty(e,i,{get(){const e=this.config&&this.config[i];return void 0===e?t:e},set(t){this.config||(this.config={}),this.config[i]=t}})}}class Ey{}Ey.CREATED="created",Ey.PLAY="play",Ey.PAUSE="pause",Ey.STOP="stop",Ey.SEEK="seek",Ey.UPDATE="update",Ey.COMPLETED="completed";t.Animate=class extends ha{get endingStyle(){return"from"===this.realEnding?this.fromStyle:this.toStyle}get started(){return!!this.requestAnimateTime}get completed(){return this.time>=this.duration&&!this.started}get frame(){return this.frames[this.nowIndex]}get frameTotalTime(){return this.frame.totalTime||this.frame.duration||0}get nowReverse(){return(this.mainReverse?1:0)+(this.frameReverse?1:0)==1}get realEnding(){let t;const{ending:e,reverse:i,swing:s,loop:n}=this;return"from"===e?t=0:"to"===e?t=1:(t=i?0:1,s&&n&&h(n)&&(t+=n-1)),t%2?"to":"from"}constructor(t,e,i,s){super(),this.nowIndex=0,this.playedTotalTime=0,e&&(e.keyframes?(i=e,e=e.keyframes):e.style&&(i=e,e=e.style)),this.init(t,e,i,s)}init(t,e,i,s){switch(this.target=t,(s||this.isTemp)&&(this.isTemp=s),typeof i){case"number":this.config={duration:i};break;case"string":this.config={easing:i};break;case"object":this.config=i,i.event&&(this.event=i.event)}this.keyframes=c(e)?e:e?[e]:[];const{easing:n,attrs:o}=this;this.easingFn=xy.get(n),(o||this.attrsMap)&&(this.attrsMap=o?o.reduce((t,e)=>(t[e]=!0,t),{}):void 0),this.frames=[],this.create(),this.autoplay&&this.frames.length&&(this.timer=setTimeout(()=>{this.timer=0,this.play()},0))}emitType(t){this.emit(t,this),this.parent&&this.parent.onChildEvent(t,this)}play(){this.destroyed||(this.running=!0,this.started?this.timer||this.startRequestAnimate():(this.clearTimer(),this.start()),this.emitType(Ey.PLAY))}pause(){this.destroyed||(this.running=!1,this.clearTimer(),this.emitType(Ey.PAUSE))}stop(){this.destroyed||(this.complete(),this.emitType(Ey.STOP))}seek(t,e){if(this.destroyed)return;const{delay:i}=this;let s;u(t)&&(t=Jh.number(t,this.duration+(e?i:0))),e&&(t-=i),t&&(t/=this.speed),t<0&&(s=-t,t=0),(!this.started||t<this.time||!t)&&this.start(!0),this.time=t,s||this.animate(0,!0),this.clearTimer(()=>{s?this.timer=setTimeout(()=>{this.timer=0,this.begin()},1e3*s):this.startRequestAnimate()}),this.emitType(Ey.SEEK)}kill(t=!0,e){this.killStyle=e,this.destroy(t)}create(){const{target:t,frames:e,keyframes:i,config:s}=this,{length:o}=i,r=!(o>1)||this.join;let a,l,d,c,u,g=0,p=0;o>1&&(this.fromStyle={},this.toStyle={});for(let s=0;s<o;s++){if(l=i[s],c=l.style||l,a||(a=r?t:c),d={style:c,beforeStyle:{}},u=1,l.style){const{duration:t,autoDuration:e,delay:i,autoDelay:s,easing:n,swing:o,loop:r}=l;o&&(d.swing=h(o)?o:2,u=2*d.swing-1),r&&(d.loop=u=h(r)?r:2),t?(d.duration=t,g+=t*u,i&&(d.totalTime=t+i)):e&&(d.autoDuration=e,p+=e*u),i?(d.delay=i,g+=i*u):s&&(d.autoDelay=s,p+=s*u),n&&(d.easingFn=xy.get(n))}if(!d.autoDuration&&n(d.duration)&&(o>1?s>0||r?p+=u:d.duration=0:d.duration=this.duration),o>1)this.setBefore(d,c,a);else{for(let e in c)d.beforeStyle[e]=t[e];this.fromStyle=d.beforeStyle,this.toStyle=d.style}a=c,e.push(d)}p?((this.duration<=g||!s||!s.duration)&&this.changeDuration(g+.2*p),this.allocateTime((this.duration-g)/p)):g&&this.changeDuration(g),this.emitType(Ey.CREATED)}changeDuration(t){const{config:e}=this;this.config=e?Object.assign(Object.assign({},e),{duration:t}):{duration:t}}setBefore(t,e,i){const{fromStyle:s,toStyle:o,target:r}=this;for(let a in e)n(s[a])&&(s[a]=o[a]=e===i?i[a]:r[a]),t.beforeStyle[a]=n(i[a])?o[a]:i[a],o[a]=e[a]}allocateTime(t){let e,{frames:i}=this,{length:s}=i;for(let o=0;o<s;o++)e=i[o],n(e.duration)&&(e.duration=e.autoDuration?t*e.autoDuration:t),e.totalTime||(e.autoDelay&&(e.delay=e.autoDelay*t),e.delay&&(e.totalTime=e.duration+e.delay))}startRequestAnimate(){this.requestAnimateTime=Date.now(),this.requestAnimatePageTime=0,this.waitRequestRender||this.requestAnimate()}requestAnimate(){this.waitRequestRender=!0,te.requestRender(this.animate.bind(this))}animate(t,e){if(!e){if(this.waitRequestRender=!1,!this.running)return;let e;e=t&&this.requestAnimatePageTime?t-this.requestAnimatePageTime:Date.now()-this.requestAnimateTime,this.time+=e/1e3,this.requestAnimatePageTime=t,this.requestAnimateTime=Date.now()}const{duration:i}=this,s=this.time*this.speed;if(s<i){for(;s-this.playedTotalTime>this.frameTotalTime;)this.transition(1),this.mainReverse?this.reverseNextFrame():this.nextFrame();const t=this.nowReverse?0:this.frame.delay||0,e=s-this.playedTotalTime-t,i=this.frame.duration;if(e>i)this.transition(1);else if(e>=0){const t=i?e/i:1;this.transition(this.frame.easingFn?this.frame.easingFn(t):this.easingFn(t))}}else this.end();if(!e)if(s<i)this.requestAnimate();else{const{loop:t,loopDelay:e,swing:i}=this;if((!1!==t||i)&&(this.looped?this.looped++:this.looped=1,this.needLoop(this.looped,t,i)))return i&&(this.mainReverse=!this.mainReverse),void(e?this.timer=setTimeout(()=>{this.timer=0,this.begin()},e/this.speed*1e3):this.begin());this.complete()}}start(t){this.requestAnimateTime=1;const{reverse:e,jump:i}=this;if((e||this.mainReverse)&&(this.mainReverse=e),this.looped&&(this.looped=0),t)this.begin(!0);else{const{delay:t}=this;t?(i&&this.begin(!0),this.timer=setTimeout(()=>{this.timer=0,this.begin()},t/this.speed*1e3)):this.begin()}}begin(t){this.playedTotalTime=this.time=0,this.mainReverse?this.setTo():this.setFrom(),t||this.startRequestAnimate()}end(){this.mainReverse?this.setFrom():this.setTo()}complete(){this.requestAnimateTime=0,this.running=!1;const{endingStyle:t,killStyle:e}=this,i=e?{}:t;if(e)for(let s in t)s in e||(i[s]=t[s]);this.setStyle(i),this.clearTimer(),this.emitType(Ey.COMPLETED)}setFrom(){this.nowIndex=0,this.setStyle(this.fromStyle)}setTo(){this.nowIndex=this.frames.length-1,this.setStyle(this.toStyle)}nextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex+1>=this.frames.length||(this.increaseTime(),this.nowIndex++)}reverseNextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex-1<0||(this.increaseTime(),this.nowIndex--)}transition(t){const{style:e,beforeStyle:i}=this.frame,s=this.nowReverse?e:i,n=this.nowReverse?i:e;if(0===t)this.setStyle(s);else if(1===t)this.setStyle(n);else{const{attrsMap:i,target:o}=this;let{betweenStyle:r}=this.frame;r||(r=this.frame.betweenStyle={}),rl.setBetweenStyle(r,s,n,e,t,o,i),this.setStyle(r)}this.emitType(Ey.UPDATE)}setStyle(t){const{target:e}=this;e&&t&&(this.style=t,e.__?e.set(t,!!this.isTemp&&"temp"):Object.assign(e,t))}increaseTime(){this.playedTotalTime+=this.frameTotalTime}needLoop(t,e,i){return!(this.needStopLoop(t,e)||this.needStopLoop(t,i,!0))}needStopLoop(t,e,i){return h(e)&&(!e||t>=(i?2*e-1:e))}needLoopFrame(){const{loop:t,swing:e}=this.frame;if(t||e){if(this.frameLooped?this.frameLooped++:this.frameLooped=1,e&&(this.frameReverse=!this.frameReverse),this.needLoop(this.frameLooped,t,e))return!0;this.frameLooped=this.frameReverse=void 0}return!1}clearTimer(t){this.timer&&(clearTimeout(this.timer),this.timer=0,t&&t())}destroy(t){this.destroyed||(super.destroy(),t&&!this.completed?this.stop():this.pause(),this.target=this.parent=this.config=this.frames=this.fromStyle=this.toStyle=this.style=this.killStyle=null,this.destroyed=!0)}},ve([by("ease")],t.Animate.prototype,"easing",void 0),ve([by(0)],t.Animate.prototype,"delay",void 0),ve([by(.2)],t.Animate.prototype,"duration",void 0),ve([by("auto")],t.Animate.prototype,"ending",void 0),ve([by(!1)],t.Animate.prototype,"reverse",void 0),ve([by(!1)],t.Animate.prototype,"swing",void 0),ve([by(!1)],t.Animate.prototype,"loop",void 0),ve([by(0)],t.Animate.prototype,"loopDelay",void 0),ve([by(1)],t.Animate.prototype,"speed",void 0),ve([by(!0)],t.Animate.prototype,"autoplay",void 0),ve([by()],t.Animate.prototype,"join",void 0),ve([by()],t.Animate.prototype,"jump",void 0),ve([by()],t.Animate.prototype,"attrs",void 0),t.Animate=ve([Zo(va)],t.Animate),t.AnimateList=class extends t.Animate{get completed(){return this.list.every(t=>t.completed)}get endingStyle(){return this._endingStyle}constructor(t,e,i){super(t,null),this.list=[],this.updateList(e,i)}updateList(e,i){this.fromStyle={},this.toStyle={},this._endingStyle={},e||(e=this.list.filter(t=>{const{completed:e}=t;return e&&t.destroy(),!e})),this.list=e.map(e=>{const s=e.target?e:new t.Animate(this.target,e,i);return s.parent=this,Object.assign(this.fromStyle,s.fromStyle),Object.assign(this.toStyle,s.toStyle),Object.assign(this._endingStyle,s.endingStyle),s})}play(){this.each(t=>t.play()),this.emitType(Ey.PLAY)}pause(){this.each(t=>t.pause()),this.emitType(Ey.PAUSE)}stop(){this.each(t=>t.stop()),this.emitType(Ey.STOP)}seek(t,e){this.each(i=>i.seek(t,e)),this.emitType(Ey.SEEK)}kill(t,e){this.each(i=>i.kill(t,e)),this.destroy()}onChildEvent(t,e){switch(t){case Ey.COMPLETED:this.completed&&this.emitType(t);break;case Ey.UPDATE:this.emitType(t)}}each(t){this.list.forEach(t)}destroy(t){const{list:e}=this;e.length&&(this.each(e=>e.destroy(t)),e.length=0)}},t.AnimateList=ve([Zo(va)],t.AnimateList);const Sy={transparent:"FFF0",aliceblue:"F0F8FF",antiquewhite:"FAEBD7",aqua:"0FF",aquamarine:"7FFFD4",azure:"F0FFFF",beige:"F5F5DC",bisque:"FFE4C4",black:"0",blanchedalmond:"FFEBCD",blue:"00F",blueviolet:"8A2BE2",brown:"A52A2A",burlywood:"DEB887",cadetblue:"5F9EA0",chartreuse:"7FFF00",chocolate:"D2691E",coral:"FF7F50",cornflowerblue:"6495ED",cornsilk:"FFF8DC",crimson:"DC143C",cyan:"0FF",darkblue:"00008B",darkcyan:"008B8B",darkgoldenrod:"B8860B",darkgray:"A9",darkgreen:"006400",darkgrey:"A9",darkkhaki:"BDB76B",darkmagenta:"8B008B",darkolivegreen:"556B2F",darkorange:"FF8C00",darkorchid:"9932CC",darkred:"8B0000",darksalmon:"E9967A",darkseagreen:"8FBC8F",darkslateblue:"483D8B",darkslategray:"2F4F4F",darkslategrey:"2F4F4F",darkturquoise:"00CED1",darkviolet:"9400D3",deeppink:"FF1493",deepskyblue:"00BFFF",dimgray:"69",dimgrey:"69",dodgerblue:"1E90FF",firebrick:"B22222",floralwhite:"FFFAF0",forestgreen:"228B22",fuchsia:"F0F",gainsboro:"DC",ghostwhite:"F8F8FF",gold:"FFD700",goldenrod:"DAA520",gray:"80",green:"008000",greenyellow:"ADFF2F",grey:"80",honeydew:"F0FFF0",hotpink:"FF69B4",indianred:"CD5C5C",indigo:"4B0082",ivory:"FFFFF0",khaki:"F0E68C",lavender:"E6E6FA",lavenderblush:"FFF0F5",lawngreen:"7CFC00",lemonchiffon:"FFFACD",lightblue:"ADD8E6",lightcoral:"F08080",lightcyan:"E0FFFF",lightgoldenrodyellow:"FAFAD2",lightgray:"D3",lightgreen:"90EE90",lightgrey:"D3",lightpink:"FFB6C1",lightsalmon:"FFA07A",lightseagreen:"20B2AA",lightskyblue:"87CEFA",lightslategray:"789",lightslategrey:"789",lightsteelblue:"B0C4DE",lightyellow:"FFFFE0",lime:"00FF00",limegreen:"32CD32",linen:"FAF0E6",magenta:"FF00FF",maroon:"800000",mediumaquamarine:"66CDAA",mediumblue:"0000CD",mediumorchid:"BA55D3",mediumpurple:"9370DB",mediumseagreen:"3CB371",mediumslateblue:"7B68EE",mediumspringgreen:"00FA9A",mediumturquoise:"48D1CC",mediumvioletred:"C71585",midnightblue:"191970",mintcream:"F5FFFA",mistyrose:"FFE4E1",moccasin:"FFE4B5",navajowhite:"FFDEAD",navy:"000080",oldlace:"FDF5E6",olive:"808000",olivedrab:"6B8E23",orange:"FFA500",orangered:"FF4500",orchid:"DA70D6",palegoldenrod:"EEE8AA",palegreen:"98FB98",paleturquoise:"AFEEEE",palevioletred:"D87093",papayawhip:"FFEFD5",peachpuff:"FFDAB9",peru:"CD853F",pink:"FFC0CB",plum:"DDA0DD",powderblue:"B0E0E6",purple:"800080",rebeccapurple:"639",red:"F00",rosybrown:"BC8F8F",royalblue:"4169E1",saddlebrown:"8B4513",salmon:"FA8072",sandybrown:"F4A460",seagreen:"2E8B57",seashell:"FFF5EE",sienna:"A0522D",silver:"C0",skyblue:"87CEEB",slateblue:"6A5ACD",slategray:"708090",slategrey:"708090",snow:"FFFAFA",springgreen:"00FF7F",steelblue:"4682B4",tan:"D2B48C",teal:"008080",thistle:"D8BFD8",tomato:"FF6347",turquoise:"40E0D0",violet:"EE82EE",wheat:"F5DEB3",white:"F",whitesmoke:"F5",yellow:"FF0",yellowgreen:"9ACD32"},ky=/^rgb\((\d+),\s*(\d+),\s*(\d+)/i,Ty=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)/i,By=/^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i,Py=/^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i,Ry=parseInt,Ly=parseFloat,{round:Cy}=Math;let Oy={},Ay=0;function Dy(t){let e,i,s,n=1;switch(t.length){case 9:e=Ry(t.slice(1,3),16),i=Ry(t.slice(3,5),16),s=Ry(t.slice(5,7),16),n=Ry(t.slice(7,9),16)/255;break;case 7:e=Ry(t.slice(1,3),16),i=Ry(t.slice(3,5),16),s=Ry(t.slice(5,7),16);break;case 5:e=Ry(t[1]+t[1],16),i=Ry(t[2]+t[2],16),s=Ry(t[3]+t[3],16),n=Ry(t[4]+t[4],16)/255;break;case 4:e=Ry(t[1]+t[1],16),i=Ry(t[2]+t[2],16),s=Ry(t[3]+t[3],16);break;case 3:e=i=s=Ry(t[1]+t[2],16);break;case 2:e=i=s=Ry(t[1]+t[1],16)}return{r:e,g:i,b:s,a:n}}const My=1/6,Iy=.5,Fy=2/3,Wy=1/3;function zy(t,e,i){return i<0?i++:i>1&&i--,i<My?t+6*(e-t)*i:i<Iy?e:i<Fy?t+(e-t)*(Fy-i)*6:t}function Uy(t,e,i,s=1){let n,o,r;if(t/=360,i/=100,0===(e/=100))n=o=r=i;else{let s=i<.5?i*(1+e):i+e-i*e,a=2*i-s;n=zy(a,s,t+Wy),o=zy(a,s,t),r=zy(a,s,t-Wy)}return{r:Cy(255*n),g:Cy(255*o),b:Cy(255*r),a:s}}de.add("color"),Zh.object=function(t,e){let i,s=!n(e)&&e<1;if(r(t)){const e=Oy[t];if(e)i=Object.assign({},e);else{switch(t[0]){case"#":i=Dy(t);break;case"R":case"r":"("===t[4]&&Ty.test(t)?i=function(t){const e=Ty.exec(t);return{r:Ry(e[1]),g:Ry(e[2]),b:Ry(e[3]),a:Ly(e[4])}}(t):"("===t[3]&&ky.test(t)&&(i=function(t){const e=ky.exec(t);return{r:Ry(e[1]),g:Ry(e[2]),b:Ry(e[3]),a:1}}(t));break;case"H":case"h":"("===t[4]&&Py.test(t)?i=function(t){const e=Py.exec(t);return Uy(Ly(e[1]),Ly(e[2]),Ly(e[3]),Ly(e[4]))}(t):"("===t[3]&&By.test(t)&&(i=function(t){const e=By.exec(t);return Uy(Ly(e[1]),Ly(e[2]),Ly(e[3]),1)}(t))}if(!i){const e=Sy[t.toLowerCase()];e&&(i=Dy("#"+e))}i&&(Ay++,Ay>1e4&&(Oy={},Ay=0),Oy[t]=Object.assign({},i))}}else u(t)&&(n(t.a)&&(t.a=1),s&&(t=Object.assign({},t)),i=t);return i||(i={r:255,g:255,b:255,a:1}),s&&(i.a*=e),i};const{round:Hy}=Math,{fourNumber:Ny}=M,Yy={fill:Ky,stroke:Ky,cornerRadius:(t,e,i)=>h(t)&&h(e)?Gy(t,e,i):(t=Ny(t),e=Ny(e),t.map((t,s)=>Gy(t,e[s],i))),text(t,e,i){if(r(t)&&r(e)){const s=t.length,n=e.length,o=Gy(s,n,i,1);return s<n?e.substring(0,o):t.substring(0,o)}return h(t)||h(e)?M.float(Gy(t,e,i),Math.max(Vy(t),Vy(e))):e},boxStyle(t,e,i,s){t||(t={}),e||(e={});const n=Object.assign(Object.assign({},t),e);return rl.setBetweenStyle(n,t,e,n,i,s),n},shadow:qy,innerShadow:qy},Xy={value:function(t,e,i){const s=h(t),n=h(e);return s&&n?t+(e-t)*i:n||s?Gy(t,e,i):t},number:Gy,color:jy,setBetweenStyle:function(t,e,i,s,n,o,r){let a,h,l;const{list:d,value:c}=rl;for(let u in s)r&&!r[u]||(a=e[u],h=i[u],l=d[u]||c,a!==h&&(t[u]=l(a,h,n,o)))}};function Vy(t){const e=String(t).split(".")[1];return e?e.length:0}function Gy(t,e,i,s){t||(t=0),e||(e=0);const n=t+(e-t)*i;return s?Hy(n):n}function jy(t,e,i){t=Zh.object(t),e=Zh.object(e);const s=Gy(t.r,e.r,i,1)+","+Gy(t.g,e.g,i,1)+","+Gy(t.b,e.b,i,1),n=Gy(t.a,e.a,i);return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}function Ky(t,e,i){return r(t)&&r(e)?jy(t,e,i):e}function qy(t,e,i){return c(t)||c(e)?e:(e=e||{},{x:Gy((t=t||{}).x,e.x,i),y:Gy(t.y,e.y,i),blur:Gy(t.blur,e.blur,i),spread:Gy(t.spread,e.spread,i),color:jy(t.color||"#FFFFFF00",e.color||"#FFFFFF00",i),visible:e.visible,blendMode:e.blendMode,box:e.box||t.box})}de.add("animate","color"),ol.canAnimate=!0,Object.assign(rl.list,Yy),Object.assign(rl,Xy);const Zy=t.UI.prototype;t.UI.addAttr("animation",void 0,function(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&(this.killAnimate("animation"),e&&this.animate(e,void 0,"animation"))}}))}),t.UI.addAttr("animationOut",void 0,fo),t.UI.addAttr("transition",!0,fo),t.UI.addAttr("transitionOut",void 0,fo),Zy.set=function(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))},Zy.animate=function(e,i,s,o){if(n(e))return this.__animate;let r=c(e)&&!i&&s?new t.AnimateList(this,e,o):new t.Animate(this,e,i,o);this.killAnimate(s,r.toStyle);const a=this.__animate;return a&&(r instanceof t.AnimateList?r.list.unshift(a):r=new t.AnimateList(this,[a,r])),this.__animate=r},Zy.killAnimate=function(e,i){const s=this.__animate;if(s){let e=!1;if(i&&!s.completed){s instanceof t.AnimateList&&s.updateList();const{toStyle:n}=s;for(let t in i)if(t in n){e=!0;break}}else e=!0;e&&(s.kill(!0,i),this.__animate=null)}},Zy.__runAnimation=function(t,e){this.animate("in"===t?this.animation:this.animationOut,void 0,"animation"),e&&this.__animate.on(Ey.COMPLETED,e)};const Jy=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],$y=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:Qy}=Math,{getDerivative:tv}=di,ev={getDistance(t,e,i,s,n,o,r,a,h=1){let l,d,c,u,g,p,_=0,f=h/2;for(let h=0;h<Jy.length;h++)l=f*(1+Jy[h]),d=f*(1-Jy[h]),c=tv(l,t,i,n,r),u=tv(l,e,s,o,a),g=tv(d,t,i,n,r),p=tv(d,e,s,o,a),_+=$y[h]*(Qy(c*c+u*u)+Qy(g*g+p*p));return _*f},getRotation(t,e,i,s,n,o,r,a,h){const l=tv(t,e,s,o,a),d=tv(t,i,n,r,h);return Math.atan2(d,l)/F},getT(t,e,i,s,n,o,r,a,h,l,d=1){let c=0,u=1,g=t/e,p=d/e/3;if(g>=1)return 1;if(g<=0)return 0;for(;u-c>p;)iv(i,s,n,o,r,a,h,l,g)<t?c=g:u=g,g=(c+u)/2;return g},cut(t,e,i,s,n,o,r,a,h,l){const d=1-e,c=d*i+e*n,u=d*s+e*o,g=d*n+e*r,p=d*o+e*a,_=d*c+e*g,f=d*u+e*p,m=d*_+e*(d*g+e*(d*r+e*h)),y=d*f+e*(d*p+e*(d*a+e*l));t.push(Fe.C,c,u,_,f,m,y)}},{getDistance:iv}=ev,{M:sv,L:nv,C:ov,Z:rv}=Fe,{float:av}=M,hv={},lv={},dv={transform(t,e){let i,s=0;const n=t.length;for(;s<n;)switch(i=t[s],i){case sv:case nv:dv.transformPoints(t,e,s,1),s+=3;break;case ov:dv.transformPoints(t,e,s,3),s+=7;break;case rv:s+=1}},transformPoints(t,e,i,s){for(let n=i+1,o=n+2*s;n<o;n+=2)hv.x=t[n],hv.y=t[n+1],Z.toOuterPoint(e,hv),t[n]=hv.x,t[n+1]=hv.y},getMotionPathData(t){let e,i,s,n,o=0,r=[],a=0,h=0,l=0;const d=t.length;for(;a<d;){switch(n=t[a],n){case sv:case nv:i=t[a+1],s=t[a+2],e=n===nv&&a>0?ht.getDistanceFrom(h,l,i,s):0,h=i,l=s,a+=3;break;case ov:i=t[a+5],s=t[a+6],e=ev.getDistance(h,l,t[a+1],t[a+2],t[a+3],t[a+4],i,s),h=i,l=s,a+=7;break;case rv:a+=1;default:e=0}r.push(e),o+=e}return{total:o,segments:r,data:t}},getDistancePoint(t,e,i){const{segments:s,data:n}=t;e=Jh.number(e,t.total);let o,r,a,h,l,d,c,u,g,p=0,_={},f=0,m=0,y=0,v=0;const w=n.length;for(;f<w;){switch(h=n[f],h){case sv:case nv:if(r=n[f+1],a=n[f+2],o=s[m],p+o>=e||!t.total)return f||(y=r,v=a),lv.x=y,lv.y=v,_.x=r,_.y=a,ht.getDistancePoint(lv,_,e-p,!0),_.rotation=ht.getAngle(lv,_),_;y=r,v=a,f+=3;break;case ov:if(r=n[f+5],a=n[f+6],o=s[m],p+o>=e)return l=n[f+1],d=n[f+2],c=n[f+3],u=n[f+4],g=ev.getT(e-p,o,y,v,l,d,c,u,r,a,i),di.getPointAndSet(g,y,v,l,d,c,u,r,a,_),_.rotation=ev.getRotation(g,y,v,l,d,c,u,r,a),_;y=r,v=a,f+=7;break;case rv:f+=1;default:o=0}m++,p+=o}return _},getDistancePath(t,e,i){const{segments:s,data:n}=t,o=[];e=Jh.number(e,t.total);let r,a,h,l,d,c,u,g,p,_,f=0,m={},y=0,v=0,w=0,x=0;const b=n.length;for(;y<b;){switch(d=n[y],d){case sv:case nv:if(h=n[y+1],l=n[y+2],r=s[v],f+r>e||!t.total)return y||(w=h,x=l),lv.x=w,lv.y=x,m.x=h,m.y=l,a=av(e-f),a&&(ht.getDistancePoint(lv,m,a,!0),o.push(d,m.x,m.y)),o;w=h,x=l,y+=3,o.push(d,w,x);break;case ov:if(c=n[y+1],u=n[y+2],g=n[y+3],p=n[y+4],h=n[y+5],l=n[y+6],r=s[v],f+r>e)return a=av(e-f),a&&(_=ev.getT(a,r,w,x,c,u,g,p,h,l,i),ev.cut(o,_,w,x,c,u,g,p,h,l)),o;w=h,x=l,y+=7,o.push(d,c,u,g,p,h,l);break;case rv:y+=1,o.push(d);default:r=0}v++,f+=r}return o}};function cv(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!o(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}}))}de.add("motion-path"),rl.register("motion",function(t,e,i,s){return u(t)&&(t=Jh.number(t,s.getMotionTotal())),u(e)&&(e=Jh.number(e,s.getMotionTotal())),rl.number(t||0,e||0,i)}),rl.register("motionRotation",function(t,e,i){return rl.number(t,e,i)});const uv=t.UI.prototype,{updateMatrix:gv,updateAllMatrix:pv}=dr,{updateBounds:_v}=br;function fv(t){const{motion:e,leaferIsCreated:i}=t;if(!o(e)){if(i&&(t.leafer.created=!1),t.motionPath){const i=yv(t);i.total&&(t.__.__pathForRender=dv.getDistancePath(i,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(pv(t),_v(t,t)):gv(t));i&&(t.leafer.created=!0)}}function mv(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function yv(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=dv.getMotionPathData(t.getPath(!0,!0))}function vv(t,e){return go(t,t=>({set(i){this.__setAttr(t,i),this.leaferIsReady?e?ol.setStyleName(this,e,i):ol.set(this,i):this.__layout.stateStyleChanged=!0}}))}function wv(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}}))}function xv(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function bv(t,e){u(e)||(e=void 0),kv(t,e,"in")}function Ev(t,e){const{normalStyle:i}=t;u(e)||(e=void 0),i&&(e||(e=i),kv(t,e,"out"))}t.UI.addAttr("motionPath",void 0,cv),t.UI.addAttr("motionPrecision",1,cv),t.UI.addAttr("motion",void 0,cv),t.UI.addAttr("motionRotation",!0,cv),uv.getMotionPathData=function(){return yv(mv(this))},uv.getMotionPoint=function(t){const e=mv(this),i=yv(e);if(!i.total)return{};const s=dv.getDistancePoint(i,t,e.motionPrecision);Z.toOuterPoint(e.localTransform,s);const{motionRotation:n}=this;return!1===n?delete s.rotation:h(n)&&(s.rotation+=n),s},uv.getMotionTotal=function(){return this.getMotionPathData().total},uv.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent;for(let i=0;i<e.length;i++)t=e[i],o(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),fv(t))}else fv(this)};const Sv={};function kv(t,e,i){const{normalStyle:s}=t;e||(e=Sv),e.scale&&(M.assignScale(e,e.scale),delete e.scale),e!==Sv&&ol.canAnimate||(i=null);let n=!!i&&function(t,e,i){let s="in"===t?"transition":"transitionOut";"out"===t&&o(i[s])&&o(e[s])&&(s="transition");return o(e[s])?i[s]:e[s]}(i,e,t);const r=n?function(t,e){const i=Pv(e,t),s=t.animate();s&&Pv(i,t,s.fromStyle);return i}(t,e):void 0;ol.canAnimate&&Tv(t)&&t.killAnimate("transition"),s&&t.set(s,"temp");const a=Tv(t);if(a){const{animation:s}=a;if(s){const o=t.animate(s,void 0,"animation",!0);Object.assign(a,o.endingStyle),"in"!==i||e.animation!==s?o.kill():n=!1,delete a.animation}t.normalStyle=Bv(a,t),t.set(a,"temp")}else t.normalStyle=void 0;if(n){const e=Bv(r,t);t.set(r,"temp"),t.animate([r,e],n,"transition",!0)}t.__layout.stateStyleChanged=!1}function Tv(t){let e;const i={},s=xv(t),n=s?t.state||s.state:t.state,o=n&&t.states[n];o&&ol.isState(n,t,s)&&(e=Rv(i,o));const r=i.selectedStyle||t.selectedStyle;r&&ol.isSelected(t,s)&&(e=Rv(i,r));const a=i.placeholderStyle||t.placeholderStyle;if(a&&ol.isPlacehold(t,s)&&(e=Rv(i,a)),ol.isDisabled(t,s)){const s=i.disabledStyle||t.disabledStyle;s&&(e=Rv(i,s))}else{const n=i.focusStyle||t.focusStyle;n&&ol.isFocus(t,s)&&(e=Rv(i,n));const o=i.hoverStyle||t.hoverStyle;o&&ol.isHover(t,s)&&(e=Rv(i,o));const r=i.pressStyle||t.pressStyle;r&&ol.isPress(t,s)&&(e=Rv(i,r))}return e?i:void 0}function Bv(t,e,i,s){const n=i?t:{},o=i||t;for(let t in o)s&&ol.animateExcludes[t]||(n[t]=e[t]);return n}function Pv(t,e,i){return Bv(t,e,i,!0)}function Rv(t,e){return Object.assign(t,e),!0}function Lv(t,e){const i=t[e];i&&bv(t,i),t.button&&Ov(t.children,e)}function Cv(t,e,i){i||(i=t.states[e]),bv(t,i),t.button&&Ov(t.children,null,e)}function Ov(t,e,i){if(!t)return;let s,o;for(let r=0,a=t.length;r<a;r++){if(s=t[r],e){switch(o=!0,e){case"hoverStyle":ol.isHover(s)&&(o=!1);break;case"pressStyle":ol.isPress(s)&&(o=!1);break;case"focusStyle":ol.isFocus(s)&&(o=!1)}o&&Lv(s,e)}else n(i)||Cv(s,i);s.isBranch&&Ov(s.children,e,i)}}function Av(t,e){const i=t[e];i&&Ev(t,i),t.button&&Mv(t.children,e)}function Dv(t,e,i){Ev(t,i),t.button&&Mv(t.children,null,e)}function Mv(t,e,i){if(!t)return;let s;for(let o=0,r=t.length;o<r;o++)s=t[o],e?Av(s,e):n(i)||Dv(s,i),s.isBranch&&Mv(s.children,e,i)}function Iv(t,e,i){let s;const n=e.leafer?e.leafer.interaction:null;if(n&&(s=n[t](e),!s&&i)){const o=xv(e,i);o&&(s=n[t](o))}return s}function Fv(t,e,i){let s=e[t];if(!s&&i){const n=xv(e,i);n&&(s=n[t])}return s}de.add("state"),ol.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,placeholder:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1,placeholderStyle:1},ol.isState=function(t,e,i){return function(t,e,i){let s=e.states[t];if(!s&&i){const n=xv(e,i);n&&(s=n.states[t])}return!!s}(t,e,i)},ol.isSelected=function(t,e){return Fv("selected",t,e)},ol.isDisabled=function(t,e){return Fv("disabled",t,e)},ol.isFocus=function(t,e){return Iv("isFocus",t,e)},ol.isHover=function(t,e){return Iv("isHover",t,e)},ol.isPress=function(t,e){return Iv("isPress",t,e)},ol.isPlacehold=function(t,e){return t.__.__isPlacehold},ol.isDrag=function(t,e){return Iv("isDrag",t,e)},ol.setStyleName=function(t,e,i){i?Cv(t,e,t[e]):Dv(t,e,t[e])},ol.set=function(t,e){const i=t.states[e];i?Cv(t,e,i):Dv(t,e,i)},ol.getStyle=Tv,ol.updateStyle=kv,ol.updateEventStyle=function(e,i){switch(i){case t.PointerEvent.ENTER:Lv(e,"hoverStyle");break;case t.PointerEvent.LEAVE:Av(e,"hoverStyle");break;case t.PointerEvent.DOWN:Lv(e,"pressStyle");break;case t.PointerEvent.UP:Av(e,"pressStyle")}};const Wv=t.UI.prototype;t.UI.addAttr("selected",!1,vv,"selectedStyle"),t.UI.addAttr("disabled",!1,vv,"disabledStyle"),t.UI.addAttr("states",{},wv),t.UI.addAttr("state","",vv),t.UI.addAttr("normalStyle",void 0,fo),t.UI.addAttr("hoverStyle",void 0,wv),t.UI.addAttr("pressStyle",void 0,wv),t.UI.addAttr("focusStyle",void 0,wv),t.UI.addAttr("selectedStyle",void 0,wv),t.UI.addAttr("disabledStyle",void 0,wv),t.UI.addAttr("placeholderStyle",void 0,wv),t.UI.addAttr("button",!1,fo),Wv.set=function(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))},Wv.focus=function(t=!0){this.waitLeafer(()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?Lv(this,"focusStyle"):Av(this,"focusStyle")})},Wv.updateState=function(){ol.updateStyle(this,void 0,"in")};const zv=t.Text.prototype,Uv="text";lo(zv,Uv,Object.assign(Object.assign({},co(zv,Uv)),{set(t){const e=this,i=e.text;e.__setAttr(Uv,t)&&(So(e),e.placeholderStyle&&e.placeholder&&(""===i||""===t)&&(e.__layout.stateStyleChanged=!0))}}));class Hv extends gl{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}t.Robot=class extends t.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let e=0;c(t)?t.forEach(t=>this.__loadRobot(t,e,e+=t.total||1)):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),!n(t))if(h(t))this.now=t;else if(u(t)){const e=c(t),i=e?t:t.keyframes;this.__action=e?void 0:t;const{length:s}=i;if(s>1){const t=this.now=i[0],e=i[i.length-1];this.play(),this.__runAction(t,e)}else s&&(this.now=i[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=no.get(t);s.ready?this.__createFrames(s,t,e,i):s.load(()=>this.__createFrames(s,t,e,i))}__createFrames(t,e,i,s){const{offset:n,size:o,total:r}=e,{width:a,height:l}=o&&(h(o)?{width:o,height:o}:o)||(r>1?this:t);let d=n?n.x:0,c=n?n.y:0;for(let e=i;e<s;e++)this.robotFrames[e]={view:t.view,x:d,y:c,width:a,height:l},d+a>=t.width?(d=0,c+=l):d+=a;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new Xr(Xr.LOADED,{image:t}))}__runAction(t,e){let{FPS:i,loop:s,__action:o}=this;o&&(o.FPS&&(i=o.FPS),n(o.loop)||(s=o.loop)),this.__timer=setTimeout(()=>{if(this.running){if(this.now===e){if(!s)return this.stop();this.now=t}else this.now++;this.__updateRobotBounds()}this.__runAction(t,e)},1e3/i)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const e=this.__,i=t.width/e.pixelRatio,s=t.height/e.pixelRatio;e.width===i&&e.height===s||this.forceUpdate("width"),e.__naturalWidth=i,e.__naturalHeight=s}}__drawContent(t,e){const{nowFrame:i}=this,{width:s,height:n}=this.__;i&&t.drawImage(i.view,i.x,i.y,i.width,i.height,0,0,s,n)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},ve([No(Hv)],t.Robot.prototype,"__",void 0),ve([bo()],t.Robot.prototype,"robot",void 0),ve([fo()],t.Robot.prototype,"actions",void 0),ve([fo("")],t.Robot.prototype,"action",void 0),ve([Co(0)],t.Robot.prototype,"now",void 0),ve([fo(12)],t.Robot.prototype,"FPS",void 0),ve([fo(!0)],t.Robot.prototype,"loop",void 0),t.Robot=ve([Jo()],t.Robot),de.add("robot");const{Yes:Nv,NoAndSkip:Yv,YesAndSkip:Xv}=t.Answer,Vv={},Gv={},jv={};class Kv{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":Vv.id=t.substring(1),t=Vv;break;case".":Gv.className=t.substring(1),t=Gv;break;default:jv.tag=t,t=jv}case"object":if(n(t.id)){if(t.tag){const{tag:s}=t,n=c(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?_.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className)}{const s=this.getById(t.id,e);return i?s:s?[s]:[]}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&dr.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),"boolean"==typeof o&&(o=o?1:0),o===Nv||o===Xv){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<Yv&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(Ur.REMOVE,this.__onRemoveChild,this),this.target.on_(Nr.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const qv=t.UI.prototype;function Zv(t){return t.leafer?t.leafer.selector:te.selector||(te.selector=ce.selector())}qv.find=function(t,e){return Zv(this).getBy(t,this,!1,e)},qv.findOne=function(t,e){return Zv(this).getBy(t,this,!0,e)},de.add("find"),ce.finder=function(t){return new Kv(t)};const{setPoint:Jv,addPoint:$v,toBounds:Qv}=yt;const tw={syncExport(t,e,i){let s;nl.running=!0;try{const o=Zn.fileType(e),r=e.includes(".");i=Zn.getExportOptions(i);const{toURL:a}=te,{download:h}=te.origin;if("json"===o)r&&h(a(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!r||t.toJSON(i.json)};else if("svg"===o)r&&h(a(t.toSVG(),"svg"),e),s={data:!!r||t.toSVG()};else{let o,r,a=1,h=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:u}=t,{slice:g,clip:p,trim:_,screenshot:f,padding:m,onCanvas:y}=i,v=n(i.smooth)?!c||c.config.smooth:i.smooth,w=i.contextSettings||(c?c.config.contextSettings:void 0),x=d&&f&&n(i.fill)?t.fill:i.fill,b=Zn.isOpaqueImage(e)||x,E=new ft;if(f)o=!0===f?d?c.canvas.bounds:t.worldRenderBounds:f;else{let e=i.relative||(d?"inner":"local");switch(a=l.scaleX,h=l.scaleY,e){case"inner":E.set(l);break;case"local":E.set(l).divide(t.localTransform),a/=t.scaleX,h/=t.scaleY;break;case"world":a=1,h=1;break;case"page":e=c||t;default:E.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,h/=h/i.scaleY}o=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};M.getScaleData(i.scale,i.size,o,S);let k=i.pixelRatio||1,{x:T,y:B,width:P,height:R}=new jt(o).scale(S.scaleX,S.scaleY);p&&(T+=p.x,B+=p.y,P=p.width,R=p.height,p.rotation&&E.rotateOfInner({x:T,y:B},-p.rotation));const L={exporting:!0,matrix:E.scale(1/S.scaleX,1/S.scaleY).invert().translate(-T,-B).withScale(1/a*S.scaleX,1/h*S.scaleY)};let C,O=ce.canvas({width:Math.floor(P),height:Math.floor(R),pixelRatio:k,smooth:v,contextSettings:w});g&&(C=t,C.__worldOpacity=0,t=c||t,L.bounds=O.bounds),O.save();const A=u&&!n(x),D=t.get("fill");if(A&&(t.fill=""),te.render(t,O,L),A&&(t.fill=D),O.restore(),C&&C.__updateWorldOpacity(),_){r=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?$v(r,n,o):Jv(r={},n,o)),a++;const h=new jt;return r&&(Qv(r,h),h.scale(1/t.pixelRatio).ceil()),h}(O);const t=O,{width:e,height:i}=r,s={x:0,y:0,width:e,height:i,pixelRatio:k};O=ce.canvas(s),O.copyWorld(t,r,s),t.destroy()}if(m){const[t,e,i,s]=M.fourNumber(m),n=O,{width:o,height:r}=n;O=ce.canvas({width:o+s+e,height:r+t+i,pixelRatio:k}),O.copyWorld(n,n.bounds,{x:s,y:t,width:o,height:r}),n.destroy()}b&&O.fillWorld(O.bounds,x||"#FFFFFF","destination-over"),y&&y(O);s={data:"canvas"===e?O:O.export(e,i),width:O.pixelWidth,height:O.pixelHeight,renderBounds:o,trimBounds:r};const I=c&&c.app;I&&I.canvasManager&&I.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return nl.running=!1,s},export(t,e,i){return nl.running=!0,function(t){ew||(ew=new to);return new Promise(e=>{ew.add(()=>we(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const o=()=>we(this,void 0,void 0,function*(){if(!io.isComplete)return te.requestRender(o);const r=nl.syncExport(t,e,i);r.data instanceof Promise&&(r.data=yield r.data),s(r),n()});t.updateLayout(),iw(t);const{leafer:r}=t;r?r.waitViewCompleted(o):o()}))}};let ew;function iw(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>iw(t))}const sw=De.prototype,nw=se.get("@leafer-in/export");return sw.export=function(t,e){const{quality:i,blob:s}=Zn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},sw.toBlob=function(t,e){return new Promise(i=>{te.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{nw.error(t),i(null)})})},sw.toDataURL=function(t,e){return te.origin.canvasToDataURL(this.view,t,e)},sw.saveAs=function(t,e){return new Promise(i=>{te.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{nw.error(t),i(!1)})})},de.add("export"),Object.assign(nl,tw),t.UI.prototype.export=function(t,e){return nl.export(this,t,e)},t.UI.prototype.syncExport=function(t,e){return nl.syncExport(this,t,e)},de.add("filter"),Object.assign(sl,{list:{},register(t,e){sl.list[t]=e},apply(t,e,i,s,n,o){let r;t.forEach(t=>{r=sl.list[t.type],r&&r.apply(t,e,i,s,n,o)})},getSpread(t){let e,i=0;return t.forEach(t=>{e=sl.list[t.type],e&&(i+=e.getSpread(t))}),i}}),de.add("bright"),t.UI.addAttr("bright",!1,Oo),t.AlignHelper=Tt,t.AnimateEasing=xy,t.AnimateEvent=Ey,t.AroundHelper=Et,t.ArrowData=Bf,t.AutoBounds=qt,t.BezierHelper=di,t.Bounds=jt,t.BoundsEvent=Vr,t.BoundsHelper=Yt,t.BoxData=fl,t.BranchHelper=br,t.BranchRender=Ua,t.CanvasData=Rl,t.CanvasManager=ye,t.ChildEvent=Ur,t.ColorConvert=Zh,t.Creator=ce,t.Cursor=nc,t.DataHelper=_,t.Debug=se,t.DragBoundsHelper=Md,t.Dragger=jd,t.EditBox=Ip,t.EditDataHelper=Pp,t.EditPoint=Ap,t.EditSelect=_p,t.EditSelectHelper=cp,t.EditToolCreator=qp,t.EditorEvent=ep,t.EditorGroupEvent=$p,t.EditorHelper=Vp,t.EditorMoveEvent=s_,t.EditorRotateEvent=o_,t.EditorScaleEvent=n_,t.EditorSkewEvent=r_,t.Effect=il,t.EllipseData=xl,t.EllipseHelper=vi,t.Event=zr,t.EventCreator=fe,t.Eventer=ha,t.Export=nl,t.FileHelper=Zn,t.Filter=sl,t.Finder=Kv,t.FourNumberHelper=k,t.FrameData=yl,t.GroupData=_l,t.HTMLTextData=kf,t.HighBezierHelper=ev,t.HighCurveHelper=dv,t.HitCanvasManager=oc,t.ImageData=Pl,t.ImageEvent=Xr,t.ImageManager=no,t.IncrementId=y,t.InnerEditor=h_,t.InnerEditorEvent=Jp,t.InteractionBase=sc,t.InteractionHelper=Hd,t.Keyboard=xd,t.LayoutEvent=Qr,t.Layouter=Wh,t.LeafBounds=Ia,t.LeafBoundsHelper=yr,t.LeafData=m,t.LeafDataProxy=xa,t.LeafEventer=va,t.LeafHelper=dr,t.LeafLayout=Wr,t.LeafLevelList=bh,t.LeafList=xh,t.LeafMatrix=Pa,t.LeafRender=Fa,t.LeaferCanvas=Eh,t.LeaferCanvasBase=De,t.LeaferData=ml,t.LeaferEvent=ea,t.LeaferImage=ho,t.LeaferTypeCreator=Z_,t.LineData=vl,t.MathHelper=M,t.Matrix=ft,t.MatrixHelper=Z,t.MultiTouchHelper=Q_,t.MyDragEvent=zd,t.MyImage=pd,t.MyPointerEvent=Fd,t.MyTouchEvent=Ud,t.NeedConvertToCanvasCommandMap=ze,t.OneRadian=F,t.PI2=W,t.PI_2=z,t.Paint=Qh,t.PaintGradient=el,t.PaintImage=tl,t.PathArrow=$h,t.PathArrowModule=Sm,t.PathBounds=Wn,t.PathCommandDataHelper=Bs,t.PathCommandMap=Fe,t.PathCommandNodeHelper=wi,t.PathConvert=ns,t.PathCorner=Vn,t.PathCreator=Xs,t.PathData=Sl,t.PathDrawer=rn,t.PathHelper=Me,t.PathMatrixHelper=Wf,t.PathNumberCommandLengthMap=Ye,t.PathNumberCommandMap=Ne,t.PathScaler=B_,t.PenData=kl,t.Picker=Xh,t.Platform=te,t.Plugin=de,t.Point=pt,t.PointHelper=ht,t.PointerButton=bd,t.PolygonData=bl,t.PropertyEvent=Nr,t.RectData=wl,t.RectHelper=Xe,t.RectRender=Il,t.RenderEvent=ta,t.Renderer=Uh,t.ResizeEvent=Jr,t.Resource=io,t.RobotData=Hv,t.Run=ae,t.ScrollBar=Sf,t.SelectArea=dp,t.Selector=Vh,t.StarData=El,t.State=ol,t.StringNumberMap=Jt,t.Stroker=lp,t.TaskItem=Qn,t.TaskProcessor=to,t.TextConvert=qh,t.TextData=Bl,t.TransformTool=a_,t.Transformer=cf,t.Transition=rl,t.TwoPointBoundsHelper=yt,t.UIBounds=Ol,t.UICreator=ge,t.UIData=gl,t.UIEvent=Ed,t.UIRender=Dl,t.UnitConvert=Jh,t.UnitConvertHelper=Zt,t.WaitHelper=Pr,t.WatchEvent=$r,t.Watcher=Bh,t.WheelEventHelper=rf,t.addViewport=j_,t.addViewportConfig=K_,t.affectRenderBoundsType=Lo,t.affectStrokeBoundsType=Bo,t.arrowType=Pf,t.attr=po,t.autoLayoutType=vo,t.boundsType=bo,t.canvasPatch=qn,t.canvasSizeAttrs=Ae,t.createAttr=function(t){return(e,i)=>{lo(e,i,uo(i,t))}},t.createDescriptor=uo,t.cursorType=Ho,t.dataProcessor=No,t.dataType=fo,t.decorateLeafAttr=go,t.defineDataProcessor=Yo,t.defineKey=lo,t.defineLeafAttr=_o,t.dimType=Oo,t.doBoundsType=So,t.doStrokeType=Po,t.effectType=Gh,t.emptyData=s,t.eraserType=zo,t.extraPropertyEventMap=Yr,t.getBoundsData=H,t.getDescriptor=co,t.getMatrixData=N,t.getPointData=U,t.hitType=Uo,t.isArray=c,t.isData=g,t.isEmptyData=p,t.isFinite=a,t.isNull=o,t.isNumber=h,t.isObject=u,t.isString=r,t.isUndefined=n,t.layoutProcessor=function(t){return(e,i)=>{lo(e,"__LayoutProcessor",{get:()=>t})}},t.leaferTransformAttrMap=ra,t.maskType=Wo,t.motionPathType=cv,t.naturalBoundsType=Eo,t.opacityType=Ao,t.path=Gn,t.pathInputType=ko,t.pathType=To,t.pen=jn,t.positionType=mo,t.registerEditTool=jp,t.registerInnerEditor=Kp,t.registerUI=Jo,t.registerUIEvent=$o,t.resizeType=jh,t.rewrite=jo,t.rewriteAble=Ko,t.rotationType=xo,t.scaleResize=I_,t.scaleResizeFontSize=F_,t.scaleResizeGroup=U_,t.scaleResizePath=W_,t.scaleResizePoints=z_,t.scaleType=wo,t.scrollType=yo,t.sortType=Fo,t.stateStyleType=wv,t.stateType=vv,t.strokeType=Ro,t.surfaceType=Co,t.tempBounds=Kt,t.tempMatrix=mt,t.tempPoint=_t,t.tryToNumber=d,t.useCanvas=kh,t.useModule=Zo,t.version="2.0.0",t.visibleType=Do,t.zoomLayerType=Kh,t}({});function Leafer(t){return new LeaferUI.Leafer(t)}Object.setPrototypeOf(Leafer,LeaferUI),Leafer.prototype=LeaferUI.Leafer.prototype;
1
+ var LeaferUI=function(t){"use strict";var e,i;function s(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,i,r):n(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}function n(t,e,i,s){return new(i||(i=Promise))(function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){t.done?n(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(r,a)}h((s=s.apply(t,e||[])).next())})}t.PathNodeHandleType=void 0,(e=t.PathNodeHandleType||(t.PathNodeHandleType={}))[e.none=1]="none",e[e.free=2]="free",e[e.mirrorAngle=3]="mirrorAngle",e[e.mirror=4]="mirror","function"==typeof SuppressedError&&SuppressedError,t.Answer=void 0,(i=t.Answer||(t.Answer={}))[i.No=0]="No",i[i.Yes=1]="Yes",i[i.NoAndSkip=2]="NoAndSkip",i[i.YesAndSkip=3]="YesAndSkip";const o={};function r(t){return void 0===t}function a(t){return null==t}function h(t){return"string"==typeof t}const{isFinite:l}=Number;function d(t){return"number"==typeof t}const c=/^-?\d+(?:\.\d+)?$/;function u(t){return"string"==typeof t&&c.test(t)?+t:t}const{isArray:g}=Array;function p(t){return t&&"object"==typeof t}function _(t){return p(t)&&!g(t)}function f(t){return"{}"===JSON.stringify(t)}const m={default:(t,e)=>(y(e,t),y(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var o,r;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(o=t[n])||void 0===o?void 0:o.constructor)===Object)return y(t[n],e[n],i&&i[n]);i&&n in i?(null===(r=i[n])||void 0===r?void 0:r.constructor)===Object&&y(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{r(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:y}=m;class v{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(!r(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]=r(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(!r(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!r(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(g(t))for(let e of t)i[e]=this.__getInput(e);else for(let e in t)i[e]=this.__getInput(e);else{let t,e,{__input:s}=this;i.tag=this.__leaf.tag;for(let n in this)if("_"!==n[0]&&(t=this["_"+n],!r(t))){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=r(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:o,f:r}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:o,f:r}}return i}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){const t=this;if("pass-through"===t.blendMode){const e=this.__leaf;t.opacity<1&&(e.isBranch||t.__hasMultiPaint)||e.__hasEraser||t.eraser||t.filter?t.__single=!0:t.__single&&(t.__single=!1)}else t.__single=!0}__removeNaturalSize(){this.__naturalWidth=this.__naturalHeight=void 0}destroy(){this.__input=this.__middle=null}}const w={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=x;return e[t]?e[t]++:(e[t]=1,0)}},x=w;let b,E,S;const{max:k}=Math,B=[0,0,0,0],T={zero:[...B],tempFour:B,set:(t,e,i,s,n)=>(void 0===i&&(i=s=n=e),t[0]=e,t[1]=i,t[2]=s,t[3]=n,t),setTemp:(t,e,i,s)=>P(B,t,e,i,s),toTempAB(t,e,i){S=i?d(t)?e:t:[],d(t)?(b=L(t),E=e):d(e)?(b=t,E=L(e)):(b=t,E=e),4!==b.length&&(b=R(b)),4!==E.length&&(E=R(E))},get(t,e){let i;if(!d(t))switch(t.length){case 4:i=r(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]),!r(e))for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},max:(t,e,i)=>d(t)&&d(e)?k(t,e):(C(t,e,i),P(S,k(b[0],E[0]),k(b[1],E[1]),k(b[2],E[2]),k(b[3],E[3]))),add:(t,e,i)=>d(t)&&d(e)?t+e:(C(t,e,i),P(S,b[0]+E[0],b[1]+E[1],b[2]+E[2],b[3]+E[3])),swapAndScale(t,e,i,s){if(d(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[o,r,a,h]=4===t.length?t:R(t);return P(n,a*i,h*e,o*i,r*e)}},{set:P,get:R,setTemp:L,toTempAB:C}=T,{round:O,pow:A,max:D,floor:M,PI:I}=Math,F={within:(t,e,i)=>(p(e)&&(i=e.max,e=e.min),!r(e)&&t<e&&(t=e),!r(i)&&t>i&&(t=i),t),fourNumber:T.get,formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),F.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=r(e)?1e12:A(10,e);return-0===(t=O(t*i)/i)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(d(e)?e:e.width||0)/i.width,n=(d(e)?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&F.assignScale(s,t);return s},assignScale(t,e){d(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>D(M(t),e)/t,randInt:W,randColor:t=>`rgba(${W(255)},${W(255)},${W(255)},${t||1})`};function W(t){return Math.round(Math.random()*t)}const z=I/180,U=2*I,H=I/2;function Y(){return{x:0,y:0}}function N(){return{x:0,y:0,width:0,height:0}}function X(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:V,cos:G,acos:j,sqrt:K}=Math,{float:q}=F,Z={};function J(){return Object.assign(Object.assign(Object.assign({},{a:1,b:0,c:0,d:1,e:0,f:0}),{x:0,y:0,width:0,height:0}),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0})}const $={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:J(),tempMatrix:{},set(t,e=1,i=0,s=0,n=1,o=0,r=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=o,t.f=r},get:X,getWorld:J,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){Q.toInnerPoint(t,e,Z),Q.scaleOfInner(t,Z,i,s)},scaleOfInner(t,e,i,s=i){Q.translateInner(t,e.x,e.y),Q.scale(t,i,s),Q.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:o}=t,r=G(e*=z),a=V(e);t.a=i*r-s*a,t.b=i*a+s*r,t.c=n*r-o*a,t.d=n*a+o*r},rotateOfOuter(t,e,i){Q.toInnerPoint(t,e,Z),Q.rotateOfInner(t,Z,i)},rotateOfInner(t,e,i){Q.translateInner(t,e.x,e.y),Q.rotate(t,i),Q.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:o,d:r}=t;i&&(i*=z,t.a=s+o*i,t.b=n+r*i),e&&(e*=z,t.c=o+s*e,t.d=r+n*e)},skewOfOuter(t,e,i,s){Q.toInnerPoint(t,e,Z),Q.skewOfInner(t,Z,i,s)},skewOfInner(t,e,i,s=0){Q.translateInner(t,e.x,e.y),Q.skew(t,i,s),Q.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:o,e:r,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*o,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*o,t.e=e.e*i+e.f*n+r,t.f=e.e*s+e.f*o+a},multiplyParent(t,e,i,s,n){const{e:o,f:a}=t;if(i||(i=t),r(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:o,c:r,d:a}=t;i.a=s*e.a+o*e.c,i.b=s*e.b+o*e.d,i.c=r*e.a+a*e.c,i.d=r*e.b+a*e.d,n&&(i.scaleX=e.scaleX*n.scaleX,i.scaleY=e.scaleY*n.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,n&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=o*e.a+a*e.c+e.e,i.f=o*e.b+a*e.d+e.f},divide(t,e){Q.multiply(t,Q.tempInvert(e))},divideParent(t,e){Q.multiplyParent(t,Q.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=Q;return Q.copy(e,t),Q.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:o,f:r}=t;if(i||s){const a=1/(e*n-i*s);t.a=n*a,t.b=-i*a,t.c=-s*a,t.d=e*a,t.e=-(o*n-r*s)*a,t.f=-(r*e-o*i)*a}else if(1===e&&1===n)t.e=-o,t.f=-r;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-o*n*i,t.f=-r*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:o}=e;i||(i=e),i.x=n*t.a+o*t.c,i.y=n*t.b+o*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:o,c:r,d:a}=t,h=1/(n*a-o*r),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*r)*h,i.y=(d*n-l*o)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*r)*h,i.y-=(s*n-e*o)*h}},setLayout(t,e,i,s,n){const{x:o,y:a,scaleX:h,scaleY:l}=e;if(r(n)&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,o=i*z,r=G(o),a=V(o);if(s||n){const e=s*z,i=n*z;t.a=(r+i*-a)*h,t.b=(a+i*r)*h,t.c=(e*r-a)*l,t.d=(r+e*a)*l}else t.a=r*h,t.b=a*h,t.c=-a*l,t.d=r*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=o,t.f=a,(i=i||s)&&Q.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:o,c:r,d:a,e:h,f:l}=t;let d,c,u,g,p,_=h,f=l;if(o||r){const t=n*a-o*r;if(r&&!s){d=K(n*n+o*o),c=t/d;const e=n/d;u=o>0?j(e):-j(e)}else{c=K(r*r+a*a),d=t/c;const e=r/c;u=H-(a>0?j(-e):-j(e))}const e=q(G(u)),i=V(u);d=q(d),c=q(c),g=e?q((r/c+i)/e/z,9):0,p=e?q((o/d-i)/e/z,9):0,u=q(u/z)}else d=n,c=a,u=g=p=0;return(e=i||e)&&(_+=e.x*n+e.y*r,f+=e.x*o+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:g,skewY:p}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:o,d:r}=t;n||o?i=(s*r-n*o)/(e=K(s*s+n*n)):(e=s,i=r)}return s.scaleX=e,s.scaleY=i,s},reset(t){Q.set(t)}},Q=$,{float:tt}=F,{toInnerPoint:et,toOuterPoint:it}=$,{sin:st,cos:nt,abs:ot,sqrt:rt,atan2:at,min:ht,round:lt}=Math,dt={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=r(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?lt(t.x-.5)+.5:lt(t.x),t.y=e?lt(t.y-.5)+.5:lt(t.y)},move(t,e,i){p(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=ct.defaultPoint);const s=nt(e*=z),n=st(e),o=t.x-i.x,r=t.y-i.y;t.x=i.x+o*s-r*n,t.y=i.y+o*n+r*s},tempToInnerOf(t,e){const{tempPoint:i}=ct;return gt(i,t),et(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=ct;return gt(i,t),it(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=ct;return gt(i,t),ct.toInnerRadiusPointOf(t,e,i),i},copyRadiusPoint:(t,e,i,s)=>(gt(t,e),pt(t,i,s),t),toInnerRadiusPointOf(t,e,i){i||(i=t),et(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){et(e,t,i)},toOuterOf(t,e,i){it(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)=>ut(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=ot(i-t),o=ot(s-e);return rt(n*n+o*o)},getMinDistanceFrom:(t,e,i,s,n,o)=>ht(ut(t,e,i,s),ut(i,s,n,o)),getAngle:(t,e)=>_t(t,e)/z,getRotation:(t,e,i,s)=>(s||(s=e),ct.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/z),getRadianFrom(t,e,i,s,n,o,a,h){r(a)&&(a=i,h=s);const l=t-i,d=e-s,c=n-a,u=o-h;return Math.atan2(l*u-d*c,l*c+d*u)},getAtan2:(t,e)=>at(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s,n){const o=_t(t,e);return n&&(t=e),s||(e={}),e.x=t.x+nt(o)*i,e.y=t.y+st(o)*i,e},toNumberPoints(t){let e=t;return p(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e)=>tt(t.x)===tt(e.x)&&tt(t.y)===tt(e.y),reset(t){ct.reset(t)}},ct=dt,{getDistanceFrom:ut,copy:gt,setRadius:pt,getAtan2:_t}=ct;class ft{constructor(t,e){this.set(t,e)}set(t,e){return p(t)?dt.copy(this,t):dt.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new ft(this)}move(t,e){return dt.move(this,t,e),this}scale(t,e){return dt.scale(this,t,e),this}scaleOf(t,e,i){return dt.scaleOf(this,t,e,i),this}rotate(t,e){return dt.rotate(this,t,e),this}rotateOf(t,e){return dt.rotate(this,e,t),this}getRotation(t,e,i){return dt.getRotation(this,t,e,i)}toInnerOf(t,e){return dt.toInnerOf(this,t,e),this}toOuterOf(t,e){return dt.toOuterOf(this,t,e),this}getCenter(t){return new ft(dt.getCenter(this,t))}getDistance(t){return dt.getDistance(this,t)}getDistancePoint(t,e,i,s){return new ft(dt.getDistancePoint(this,t,e,i,s))}getAngle(t){return dt.getAngle(this,t)}getAtan2(t){return dt.getAtan2(this,t)}isSame(t){return dt.isSame(this,t)}reset(){return dt.reset(this),this}}const mt=new ft;class yt{constructor(t,e,i,s,n,o){this.set(t,e,i,s,n,o)}set(t,e,i,s,n,o){return p(t)?$.copy(this,t):$.set(this,t,e,i,s,n,o),this}setWith(t){return $.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:i,d:s,e:n,f:o}=this;return{a:t,b:e,c:i,d:s,e:n,f:o}}clone(){return new yt(this)}translate(t,e){return $.translate(this,t,e),this}translateInner(t,e){return $.translateInner(this,t,e),this}scale(t,e){return $.scale(this,t,e),this}scaleWith(t,e){return $.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return $.pixelScale(this,t),this}scaleOfOuter(t,e,i){return $.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return $.scaleOfInner(this,t,e,i),this}rotate(t){return $.rotate(this,t),this}rotateOfOuter(t,e){return $.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return $.rotateOfInner(this,t,e),this}skew(t,e){return $.skew(this,t,e),this}skewOfOuter(t,e,i){return $.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return $.skewOfInner(this,t,e,i),this}multiply(t){return $.multiply(this,t),this}multiplyParent(t){return $.multiplyParent(this,t),this}divide(t){return $.divide(this,t),this}divideParent(t){return $.divideParent(this,t),this}invert(){return $.invert(this),this}invertWith(){return $.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){$.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){$.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return $.setLayout(this,t,e,i),this}getLayout(t,e,i){return $.getLayout(this,t,e,i)}withScale(t,e){return $.withScale(this,t,e)}reset(){$.reset(this)}}const vt=new yt,wt={tempPointBounds:{},setPoint(t,e,i){t.minX=t.maxX=e,t.minY=t.maxY=i},addPoint(t,e,i){t.minX=e<t.minX?e:t.minX,t.minY=i<t.minY?i:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=i>t.maxY?i:t.maxY},addBounds(t,e,i,s,n){xt(t,e,i),xt(t,e+s,i+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:xt}=wt;var bt,Et;t.Direction4=void 0,(bt=t.Direction4||(t.Direction4={}))[bt.top=0]="top",bt[bt.right=1]="right",bt[bt.bottom=2]="bottom",bt[bt.left=3]="left",t.Direction9=void 0,(Et=t.Direction9||(t.Direction9={}))[Et.topLeft=0]="topLeft",Et[Et.top=1]="top",Et[Et.topRight=2]="topRight",Et[Et.right=3]="right",Et[Et.bottomRight=4]="bottomRight",Et[Et.bottom=5]="bottom",Et[Et.bottomLeft=6]="bottomLeft",Et[Et.left=7]="left",Et[Et.center=8]="center",Et[Et["top-left"]=0]="top-left",Et[Et["top-right"]=2]="top-right",Et[Et["bottom-right"]=4]="bottom-right",Et[Et["bottom-left"]=6]="bottom-left";const 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");const kt={directionData:St,tempPoint:{},get:Bt,toPoint(t,e,i,s,n,o){const r=Bt(t);i.x=r.x,i.y=r.y,"percent"===r.type&&(i.x*=e.width,i.y*=e.height,n&&(o||(i.x-=n.x,i.y-=n.y),r.x&&(i.x-=1===r.x?n.width:.5===r.x?r.x*n.width:0),r.y&&(i.y-=1===r.y?n.height:.5===r.y?r.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i)=>(i||(i={}),kt.toPoint(t,e,i,!0),i)};function Bt(e){return h(e)?St[t.Direction9[e]]:e}const{toPoint:Tt}=kt,Pt={toPoint(t,e,i,s,n,o){Tt(t,i,s,n,e,o)}},{tempPointBounds:Rt,setPoint:Lt,addPoint:Ct,toBounds:Ot}=wt,{toOuterPoint:At}=$,{float:Dt,fourNumber:Mt}=F,{floor:It,ceil:Ft}=Math;let Wt,zt,Ut,Ht;const Yt={},Nt={},Xt={},Vt={tempBounds:Xt,set(t,e=0,i=0,s=0,n=0){t.x=e,t.y=i,t.width=s,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,n){const{x:o,y:r,width:a,height:h}=e;if(g(i)){const e=Mt(i);s?Gt.set(t,o+e[3],r+e[0],a-e[1]-e[3],h-e[2]-e[0]):Gt.set(t,o-e[3],r-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Gt.set(t,o-i,r-i,a+2*i,h+2*i);n&&("width"===n?(t.y=r,t.height=h):(t.x=o,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,i){t.x+=e,t.y+=i},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?Kt(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||dt.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){dt.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Gt.copy(Xt,t),Gt.toOuterOf(Xt,e),Xt),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:n,e:o,f:r}=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),n>0?(i.height=t.height*n,i.y=r+t.y*n):(i.height=t.height*-n,i.y=r+t.y*n-i.height)}else Yt.x=t.x,Yt.y=t.y,At(e,Yt,Nt),Lt(Rt,Nt.x,Nt.y),Yt.x=t.x+t.width,At(e,Yt,Nt),Ct(Rt,Nt.x,Nt.y),Yt.y=t.y+t.height,At(e,Yt,Nt),Ct(Rt,Nt.x,Nt.y),Yt.x=t.x,At(e,Yt,Nt),Ct(Rt,Nt.x,Nt.y),Ot(Rt,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 yt(s,0,0,s,-e.x*s,-e.y*s)},getFitScale(t,e,i){const s=t.width/e.width,n=t.height/e.height;return i?Math.max(s,n):Math.min(s,n)},put(t,e,i="center",s=1,n=!0,o){o||(o=e),h(s)&&(s=Gt.getFitScale(t,e,"cover"===s)),Xt.width=n?e.width*=s:e.width*s,Xt.height=n?e.height*=s:e.height*s,Pt.toPoint(i,Xt,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=It(t.x),t.y=It(t.y),t.width=e>t.x?Ft(t.width+e-t.x):Ft(t.width),t.height=i>t.y?Ft(t.height+i-t.y):Ft(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=Dt(t.x,e),t.y=Dt(t.y,e),t.width=Dt(t.width,e),t.height=Dt(t.height,e)},add(t,e,i){Wt=t.x+t.width,zt=t.y+t.height,Ut=e.x,Ht=e.y,i||(Ut+=e.width,Ht+=e.height),Wt=Wt>Ut?Wt:Ut,zt=zt>Ht?zt:Ht,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=Wt-t.x,t.height=zt-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 n,o=!0;for(let r=0,a=e.length;r<a;r++)n=i?i(e[r],r):e[r],n&&(n.width||n.height)&&(o?(o=!1,s||Kt(t,n)):jt(t,n));o&&Gt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?Lt(Rt,t.x,t.y):Ct(Rt,t.x,t.y)),Ot(Rt,t)},setPoint(t,e){Gt.set(t,e.x,e.y)},addPoint(t,e){jt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]},hitRadiusPoint:(t,e,i)=>(i&&(e=dt.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=dt.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:n,width:o,height:r}=e;return Wt=s+o,zt=n+r,Ut=t.x+t.width,Ht=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,Wt=Wt<Ut?Wt:Ut,zt=zt<Ht?zt:Ht,o=Wt-s,r=zt-n,{x:s,y:n,width:o,height:r}},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=Vt,{add:jt,copy:Kt}=Gt;class qt{get minX(){return Vt.minX(this)}get minY(){return Vt.minY(this)}get maxX(){return Vt.maxX(this)}get maxY(){return Vt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return p(t)?Vt.copy(this,t):Vt.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 qt(this)}move(t,e){return Vt.move(this,t,e),this}scale(t,e,i){return Vt.scale(this,t,e,i),this}scaleOf(t,e,i){return Vt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Vt.toOuterOf(this,t,e),this}toInnerOf(t,e){return Vt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Vt.getFitMatrix(this,t,e)}put(t,e,i){Vt.put(this,t,e,i)}spread(t,e){return Vt.spread(this,t,e),this}shrink(t,e){return Vt.shrink(this,t,e),this}ceil(){return Vt.ceil(this),this}unsign(){return Vt.unsign(this),this}float(t){return Vt.float(this,t),this}add(t){return Vt.add(this,t),this}addList(t){return Vt.setList(this,t,!0),this}setList(t){return Vt.setList(this,t),this}addListWithFn(t,e){return Vt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Vt.setListWithFn(this,t,e),this}setPoint(t){return Vt.setPoint(this,t),this}setPoints(t){return Vt.setPoints(this,t),this}addPoint(t){return Vt.addPoint(this,t),this}getPoints(){return Vt.getPoints(this)}hitPoint(t,e){return Vt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Vt.hitRadiusPoint(this,t,e)}hit(t,e){return Vt.hit(this,t,e)}includes(t,e){return Vt.includes(this,t,e)}intersect(t,e){return Vt.intersect(this,t,e),this}getIntersect(t,e){return new qt(Vt.getIntersectData(this,t,e))}isSame(t){return Vt.isSame(this,t)}isEmpty(){return Vt.isEmpty(this)}reset(){Vt.reset(this)}}const Zt=new qt;class Jt{constructor(t,e,i,s,n,o){p(t)?this.copy(t):this.set(t,e,i,s,n,o)}set(t=0,e=0,i=0,s=0,n=0,o=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=o}copy(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=t;this.set(e,i,s,n,o,r)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:o,height:r}=this;return new qt(n,e,o||t.width-n-i,r||t.height-e-s)}}const $t={number:(t,e)=>p(t)?"percent"===t.type?t.value*e:t.value:t},Qt={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:te,max:ee}=Math,ie={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||se.maxCacheSize),isSuperLarge:(t,e,i)=>se.isLarge(t,e,i,se.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=se;return!i||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+i),e&&"/"===t[0]&&(t=e+t),t},resize(t,e,i,s,n,o,r,a,h,l){const d=ee(te(e+(s||0)),1),c=ee(te(i+(n||0)),1);let u,g,p;l&&(p=$t.number(l.offset,"x"===l.type?e:i))&&("x"===l.type?u=!0:g=!0);const _=ie.origin.createCanvas(g?2*d:d,u?2*c:c),f=_.getContext("2d");if(a&&(f.globalAlpha=a),f.imageSmoothingEnabled=!1!==r,se.canUse(t)){if(o){const s=e/o.width,n=i/o.height;f.setTransform(s,0,0,n,-o.x*s,-o.y*n),f.drawImage(t,0,0,t.width,t.height)}else f.drawImage(t,0,0,e,i);p&&(f.drawImage(_,0,0,d,c,u?p-d:d,u?c:p-c,d,c),f.drawImage(_,0,0,d,c,u?p:d,u?c:p,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&&m.stintSet(i,"transform",e)}}},{image:se}=ie,{randColor:ne}=F;class oe{constructor(t){this.repeatMap={},this.name=t}static get(t){return new oe(t)}static set filter(t){this.filterList=re(t)}static set exclude(t){this.excludeList=re(t)}static drawRepaint(t,e){const i=ne();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===oe.showBounds,n=t.__nowWorld,o=ne();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=o.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(o,2),s?e.stroke():e.strokeWorld(n,o)}log(...t){if(ae.enable){if(ae.filterList.length&&ae.filterList.every(t=>t!==this.name))return;if(ae.excludeList.length&&ae.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){ae.enable&&this.warn(...t)}warn(...t){ae.showWarn&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}function re(t){return t?h(t)&&(t=[t]):t=[],t}oe.filterList=[],oe.excludeList=[],oe.showWarn=!0;const ae=oe,he=oe.get("RunTime"),le={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=w.create(w.RUNTIME);return de.currentId=de.idMap[i]=e?performance.now():Date.now(),de.currentName=de.nameMap[i]=t,de.nameToIdMap[t]=i,i},end(t,e){const i=de.idMap[t],s=de.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;de.idMap[t]=de.nameMap[t]=de.nameToIdMap[s]=void 0,he.log(s,n,"ms")},endOfName(t,e){const i=de.nameToIdMap[t];r(i)||de.end(i,e)}},de=le,ce=[],ue={list:{},add(t,...e){this.list[t]=!0,ce.push(...e)},has(t,e){const i=this.list[t];return!i&&e&&this.need(t),i},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>ce.forEach(t=>ue.has(t,!0)));const ge={editor:t=>ue.need("editor")},pe=oe.get("UICreator"),_e={list:{},register(t){const{__tag:e}=t.prototype;fe[e]&&pe.repeat(e),fe[e]=t},get(t,e,i,s,n,o){if(!fe[t])return void pe.warn("not register "+t);const a=new fe[t](e);return r(i)||(a.x=i,s&&(a.y=s),n&&(a.width=n),o&&(a.height=o)),a}},{list:fe}=_e,me=oe.get("EventCreator"),ye={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],h(e)&&(ve[e]&&me.repeat(e),ve[e]=t)})},changeName(t,e){const i=ve[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,ve[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new ve[t](...e)},{nameList:ve}=ye;class we{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:i}=this;for(let s=0,n=i.length;s<n;s++)if(e=i[s],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 xe(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)}}const be=[];function Ee(){return(t,e)=>{be.push(e)}}const Se=[];class ke{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||Se)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;be.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,o){p(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,i,s){}strokeRect(t,e,i,s){}clearRect(t,e,i,s){}drawImage(t,e,i,s,n,o,r,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,o+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,r+=t,h-=t}this.context.drawImage(t,e,i,s,n,o,r,a,h);break;case 5:this.context.drawImage(t,e,i,s,n);break;case 3:this.context.drawImage(t,e,i)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,i,s,n,o){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,o){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,o,r,a){}rect(t,e,i,s){}roundRect(t,e,i,s,n){}createConicGradient(t,e,i){}createLinearGradient(t,e,i,s){}createPattern(t,e){}createRadialGradient(t,e,i,s,n,o){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}}s([xe("imageSmoothingEnabled")],ke.prototype,"smooth",void 0),s([xe("imageSmoothingQuality")],ke.prototype,"smoothLevel",void 0),s([xe("globalAlpha")],ke.prototype,"opacity",void 0),s([xe()],ke.prototype,"fillStyle",void 0),s([xe()],ke.prototype,"strokeStyle",void 0),s([xe("lineWidth")],ke.prototype,"strokeWidth",void 0),s([xe("lineCap")],ke.prototype,"strokeCap",void 0),s([xe("lineJoin")],ke.prototype,"strokeJoin",void 0),s([xe("lineDashOffset")],ke.prototype,"dashOffset",void 0),s([xe()],ke.prototype,"miterLimit",void 0),s([xe()],ke.prototype,"shadowBlur",void 0),s([xe()],ke.prototype,"shadowColor",void 0),s([xe()],ke.prototype,"shadowOffsetX",void 0),s([xe()],ke.prototype,"shadowOffsetY",void 0),s([xe()],ke.prototype,"filter",void 0),s([xe()],ke.prototype,"font",void 0),s([xe()],ke.prototype,"fontKerning",void 0),s([xe()],ke.prototype,"fontStretch",void 0),s([xe()],ke.prototype,"fontVariantCaps",void 0),s([xe()],ke.prototype,"textAlign",void 0),s([xe()],ke.prototype,"textBaseline",void 0),s([xe()],ke.prototype,"textRendering",void 0),s([xe()],ke.prototype,"wordSpacing",void 0),s([xe()],ke.prototype,"letterSpacing",void 0),s([xe()],ke.prototype,"direction",void 0),s([Ee()],ke.prototype,"setTransform",null),s([Ee()],ke.prototype,"resetTransform",null),s([Ee()],ke.prototype,"getTransform",null),s([Ee()],ke.prototype,"save",null),s([Ee()],ke.prototype,"restore",null),s([Ee()],ke.prototype,"translate",null),s([Ee()],ke.prototype,"scale",null),s([Ee()],ke.prototype,"rotate",null),s([Ee()],ke.prototype,"fill",null),s([Ee()],ke.prototype,"stroke",null),s([Ee()],ke.prototype,"clip",null),s([Ee()],ke.prototype,"fillRect",null),s([Ee()],ke.prototype,"strokeRect",null),s([Ee()],ke.prototype,"clearRect",null),s([Ee()],ke.prototype,"beginPath",null),s([Ee()],ke.prototype,"moveTo",null),s([Ee()],ke.prototype,"lineTo",null),s([Ee()],ke.prototype,"bezierCurveTo",null),s([Ee()],ke.prototype,"quadraticCurveTo",null),s([Ee()],ke.prototype,"closePath",null),s([Ee()],ke.prototype,"arc",null),s([Ee()],ke.prototype,"arcTo",null),s([Ee()],ke.prototype,"ellipse",null),s([Ee()],ke.prototype,"rect",null),s([Ee()],ke.prototype,"roundRect",null),s([Ee()],ke.prototype,"createConicGradient",null),s([Ee()],ke.prototype,"createLinearGradient",null),s([Ee()],ke.prototype,"createPattern",null),s([Ee()],ke.prototype,"createRadialGradient",null),s([Ee()],ke.prototype,"fillText",null),s([Ee()],ke.prototype,"measureText",null),s([Ee()],ke.prototype,"strokeText",null);const{copy:Be,multiplyParent:Te,pixelScale:Pe}=$,{round:Re}=Math,Le=new qt,Ce=new qt,Oe={width:1,height:1,pixelRatio:1},Ae=["width","height","pixelRatio"];class De extends ke{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=Oe),this.manager=e,this.innerId=w.create(w.CNAVAS);const{width:i,height:s,pixelRatio:n}=t;this.autoLayout=!i||!s,this.size.pixelRatio=n||ie.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;m.copyAttrs(s,t,Ae),Ae.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,n=this.worldTransform;e&&Te(t,e,n),Pe(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=Re(n.e-.5)+.5,n.f=Re(n.f-.5)+.5):(n.e=Re(n.e),n.f=Re(n.f))),this.setTransform(n.a,n.b,n.c,n.d,n.e,n.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:n,dashOffset:o,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),r(e.dashPattern)||(n=e.dashPattern),r(e.dashOffset)||(o=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=n,this.dashOffset=o,this.miterLimit=a}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,i=1){return!0}setWorldShadow(t,e,i,s){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=i*n,this.shadowColor=s||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,i,s,n){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=Ce):i=Le,this.drawImage(t.view,Le.x,Le.y,Le.width,Le.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,n){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Vt.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,Le.x,Le.y,Le.width,Le.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,o){this.resetTransform(),this.copyWorld(t,e,i,s,o),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(Le.x,Le.y,Le.width,Le.height),{data:o}=n;for(let t=0,s=o.length;t<s;t+=4)i=.299*o[t]+.587*o[t+1]+.114*o[t+2],(e=o[t+3])&&(o[t+3]=255===e?i:e*(i/255));s.putImageData(n,Le.x,Le.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(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Le.x,Le.y,Le.width,Le.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Le.x,Le.y,Le.width,Le.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Le.x,Le.y,Le.width,Le.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Le,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(Ce,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,n=this.manager?this.manager.get(i):ge.canvas(Object.assign({},i));return n.save(),t&&(Be(n.worldTransform,this.worldTransform),n.useWorldTransform()),e&&(n.smooth=this.smooth),n.pixelSnap!==s&&(n.pixelSnap=s),n}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}}const Me={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Ie={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Fe=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},Ie),We={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},ze={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},Ue=Object.assign(Object.assign({},ze),Ie),He=Fe,Ye={};for(let t in He)Ye[He[t]]=t;const Ne={};for(let t in He)Ne[He[t]]=We[t];const Xe={drawRoundRect(t,e,i,s,n,o){const r=F.fourNumber(o,Math.min(s/2,n/2)),a=e+s,h=i+n;r[0]?t.moveTo(e+r[0],i):t.moveTo(e,i),r[1]?t.arcTo(a,i,a,h,r[1]):t.lineTo(a,i),r[2]?t.arcTo(a,h,e,h,r[2]):t.lineTo(a,h),r[3]?t.arcTo(e,h,e,i,r[3]):t.lineTo(e,h),r[0]?t.arcTo(e,i,a,i,r[0]):t.lineTo(e,i)}},{sin:Ve,cos:Ge,hypot:je,atan2:Ke,ceil:qe,abs:Ze,PI:Je,sqrt:$e,pow:Qe}=Math,{setPoint:ti,addPoint:ei}=wt,{set:ii,toNumberPoints:si}=dt,{M:ni,L:oi,C:ri,Q:ai,Z:hi}=Fe,li={},di={points(t,e,i,s){let n=si(e);if(t.push(ni,n[0],n[1]),i&&n.length>5){let e,o,r,a,h,l,d,c,u,g,p,_,f,m,y,v=n.length;const w=!0===i?.5:i;s&&(n=[n[v-2],n[v-1],...n,n[0],n[1],n[2],n[3]],v=n.length);for(let i=2;i<v-2;i+=2)e=n[i-2],o=n[i-1],r=n[i],a=n[i+1],h=n[i+2],l=n[i+3],p=r-e,_=a-o,f=$e(Qe(p,2)+Qe(_,2)),m=$e(Qe(h-r,2)+Qe(l-a,2)),(f||m)&&(y=f+m,f=w*f/y,m=w*m/y,h-=e,l-=o,d=r-f*h,c=a-f*l,2===i?s||t.push(ai,d,c,r,a):(p||_)&&t.push(ri,u,g,d,c,r,a),u=r+m*h,g=a+m*l);s||t.push(ai,u,g,n[v-2],n[v-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(oi,n[e],n[e+1]);s&&t.push(hi)},rect(t,e,i,s,n){Me.creator.path=t,Me.creator.moveTo(e,i).lineTo(e+s,i).lineTo(e+s,i+n).lineTo(e,i+n).lineTo(e,i)},roundRect(t,e,i,s,n,o){Me.creator.path=[],Xe.drawRoundRect(Me.creator,e,i,s,n,o),t.push(...Me.convertToCanvasData(Me.creator.path,!0))},arcTo(t,e,i,s,n,o,r,a,h,l,d){const c=s-e,u=n-i,g=o-s,p=r-n;let _=Ke(u,c),f=Ke(p,g);const m=je(c,u),y=je(g,p);let v=f-_;if(v<0&&(v+=U),m<1e-12||y<1e-12||v<1e-12||Ze(v-Je)<1e-12)return t&&t.push(oi,s,n),h&&(ti(h,e,i),ei(h,s,n)),d&&ii(d,e,i),void(l&&ii(l,s,n));const w=c*p-g*u<0,x=w?-1:1,b=a/Ge(v/2),E=s+b*Ge(_+v/2+H*x),S=n+b*Ve(_+v/2+H*x);return _-=H*x,f-=H*x,gi(t,E,S,a,a,0,_/z,f/z,w,h,l,d)},arc:(t,e,i,s,n,o,r,a,h,l)=>gi(t,e,i,s,s,0,n,o,r,a,h,l),ellipse(t,e,i,s,n,o,r,a,h,l,d,c){const u=o*z,g=Ve(u),p=Ge(u);let _=r*z,f=a*z;_>Je&&(_-=U),f<0&&(f+=U);let m=f-_;m<0?m+=U:m>U&&(m-=U),h&&(m-=U);const y=qe(Ze(m/H)),v=m/y,w=Ve(v/4),x=8/3*w*w/Ve(v/2);f=_+v;let b,E,S,k,B,T,P,R,L=Ge(_),C=Ve(_),O=S=p*s*L-g*n*C,A=k=g*s*L+p*n*C,D=e+S,M=i+k;t&&t.push(t.length?oi:ni,D,M),l&&ti(l,D,M),c&&ii(c,D,M);for(let o=0;o<y;o++)b=Ge(f),E=Ve(f),S=p*s*b-g*n*E,k=g*s*b+p*n*E,B=e+O-x*(p*s*C+g*n*L),T=i+A-x*(g*s*C-p*n*L),P=e+S+x*(p*s*E+g*n*b),R=i+k+x*(g*s*E-p*n*b),t&&t.push(ri,B,T,P,R,e+S,i+k),l&&ui(e+O,i+A,B,T,P,R,e+S,i+k,l,!0),O=S,A=k,L=b,C=E,_=f,f+=v;d&&ii(d,e+S,i+k)},quadraticCurveTo(t,e,i,s,n,o,r){t.push(ri,(e+2*s)/3,(i+2*n)/3,(o+2*s)/3,(r+2*n)/3,o,r)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,o,r,a){ui(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(o+2*s)/3,n,o,r,a)},toTwoPointBounds(t,e,i,s,n,o,r,a,h,l){const d=[];let c,u,g,p,_,f,m,y,v=t,w=i,x=n,b=r;for(let t=0;t<2;++t)if(1==t&&(v=e,w=s,x=o,b=a),c=-3*v+9*w-9*x+3*b,u=6*v-12*w+6*x,g=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;p=-g/u,0<p&&p<1&&d.push(p)}else m=u*u-4*g*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?ei(h,t,e):ti(h,t,e),ei(h,r,a);for(let l=0,c=d.length;l<c;l++)ci(d[l],t,e,i,s,n,o,r,a,li),ei(h,li.x,li.y)},getPointAndSet(t,e,i,s,n,o,r,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,g=3*d*t*t,p=t*t*t;l.x=c*e+u*s+g*o+p*a,l.y=c*i+u*n+g*r+p*h},getPoint(t,e,i,s,n,o,r,a,h){const l={};return ci(t,e,i,s,n,o,r,a,h,l),l},getDerivative(t,e,i,s,n){const o=1-t;return 3*o*o*(i-e)+6*o*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:ci,toTwoPointBounds:ui,ellipse:gi}=di,{sin:pi,cos:_i,sqrt:fi,atan2:mi}=Math,{ellipse:yi}=di,vi={ellipticalArc(t,e,i,s,n,o,r,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,g=o*z,p=pi(g),_=_i(g),f=-_*c-p*u,m=-_*u+p*c,y=s*s,v=n*n,w=m*m,x=f*f,b=y*v-y*w-v*x;let E=0;if(b<0){const t=fi(1-b/(y*v));s*=t,n*=t}else E=(r===a?-1:1)*fi(b/(y*w+v*x));const S=E*s*m/n,k=-E*n*f/s,B=mi((m-k)/n,(f-S)/s),T=mi((-m-k)/n,(-f-S)/s);let P=T-B;0===a&&P>0?P-=U:1===a&&P<0&&(P+=U);const R=e+c+_*S-p*k,L=i+u+p*S+_*k,C=P<0?1:0;d||ie.ellipseToCurve?yi(t,R,L,s,n,o,B/z,T/z,C):s!==n||o?t.push(Fe.G,R,L,s,n,o,B/z,T/z,C):t.push(Fe.O,R,L,s,B/z,T/z,C)}},wi={toCommand:t=>[],toNode:t=>[]},{M:xi,m:bi,L:Ei,l:Si,H:ki,h:Bi,V:Ti,v:Pi,C:Ri,c:Li,S:Ci,s:Oi,Q:Ai,q:Di,T:Mi,t:Ii,A:Fi,a:Wi,Z:zi,z:Ui,N:Hi,D:Yi,X:Ni,G:Xi,F:Vi,O:Gi,P:ji,U:Ki}=Fe,{rect:qi,roundRect:Zi,arcTo:Ji,arc:$i,ellipse:Qi,quadraticCurveTo:ts}=di,{ellipticalArc:es}=vi,is=oe.get("PathConvert"),ss={},ns={current:{dot:0},stringify(t,e){let i,s,n,o=0,r=t.length,a="";for(;o<r;){s=t[o],i=Ne[s],a+=s===n?" ":Ye[s];for(let s=1;s<i;s++)a+=F.float(t[o+s],e),s===i-1||(a+=" ");n=s,o+=i}return a},parse(t,e){let i,s,n,o="";const r=[],a=e?Ue:ze;for(let e=0,h=t.length;e<h;e++)s=t[e],Qt[s]?("."===s&&(os.dot&&(rs(r,o),o=""),os.dot++),"0"===o&&"."!==s&&(rs(r,o),o=""),o+=s):Fe[s]?(o&&(rs(r,o),o=""),os.name=Fe[s],os.length=We[s],os.index=0,rs(r,os.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?o+=s:(o&&rs(r,o),o=s):o&&(rs(r,o),o=""),n=s;return o&&rs(r,o),i?ns.toCanvasData(r,e):r},toCanvasData(t,e){let i,s,n,o,r,a=0,h=0,l=0,d=0,c=0,u=t.length;const g=[];for(;c<u;){switch(n=t[c],n){case bi:t[c+1]+=a,t[c+2]+=h;case xi:a=t[c+1],h=t[c+2],g.push(xi,a,h),c+=3;break;case Bi:t[c+1]+=a;case ki:a=t[c+1],g.push(Ei,a,h),c+=2;break;case Pi:t[c+1]+=h;case Ti:h=t[c+1],g.push(Ei,a,h),c+=2;break;case Si:t[c+1]+=a,t[c+2]+=h;case Ei:a=t[c+1],h=t[c+2],g.push(Ei,a,h),c+=3;break;case Oi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ci;case Ci:r=o===Ri||o===Ci,l=r?2*a-i:t[c+1],d=r?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],g.push(Ri,l,d,i,s,a,h),c+=5;break;case Li:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=Ri;case Ri:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],g.push(Ri,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Ii:t[c+1]+=a,t[c+2]+=h,n=Mi;case Mi:r=o===Ai||o===Mi,i=r?2*a-i:t[c+1],s=r?2*h-s:t[c+2],e?ts(g,a,h,i,s,t[c+1],t[c+2]):g.push(Ai,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Di:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ai;case Ai:i=t[c+1],s=t[c+2],e?ts(g,a,h,i,s,t[c+3],t[c+4]):g.push(Ai,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Wi:t[c+6]+=a,t[c+7]+=h;case Fi:es(g,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 Ui:case zi:g.push(zi),c++;break;case Hi:a=t[c+1],h=t[c+2],e?qi(g,a,h,t[c+3],t[c+4]):as(g,t,c,5),c+=5;break;case Yi:a=t[c+1],h=t[c+2],e?Zi(g,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):as(g,t,c,9),c+=9;break;case Ni:a=t[c+1],h=t[c+2],e?Zi(g,a,h,t[c+3],t[c+4],t[c+5]):as(g,t,c,6),c+=6;break;case Xi:Qi(e?g:as(g,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,ss),a=ss.x,h=ss.y,c+=9;break;case Vi:e?Qi(g,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):as(g,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Gi:$i(e?g:as(g,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,ss),a=ss.x,h=ss.y,c+=7;break;case ji:e?$i(g,t[c+1],t[c+2],t[c+3],0,360,!1):as(g,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Ki:Ji(e?g:as(g,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,ss),a=ss.x,h=ss.y,c+=6;break;default:return is.error(`command: ${n} [index:${c}]`,t),g}o=n}return g},objectToCanvasData(t){if(t[0].name.length>1)return wi.toCommand(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(xi,t.x,t.y);break;case"L":e.push(Ei,t.x,t.y);break;case"C":e.push(Ri,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Ai,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(zi)}}),e}},copyData(t,e,i,s){for(let n=i,o=i+s;n<o;n++)t.push(e[n])},pushData(t,e){os.index===os.length&&(os.index=1,t.push(os.name)),t.push(Number(e)),os.index++,os.dot=0}},{current:os,pushData:rs,copyData:as}=ns,{M:hs,L:ls,C:ds,Q:cs,Z:us,N:gs,D:ps,X:_s,G:fs,F:ms,O:ys,P:vs,U:ws}=Fe,{getMinDistanceFrom:xs,getRadianFrom:bs}=dt,{tan:Es,min:Ss,abs:ks}=Math,Bs={},Ts={beginPath(t){t.length=0},moveTo(t,e,i){t.push(hs,e,i)},lineTo(t,e,i){t.push(ls,e,i)},bezierCurveTo(t,e,i,s,n,o,r){t.push(ds,e,i,s,n,o,r)},quadraticCurveTo(t,e,i,s,n){t.push(cs,e,i,s,n)},closePath(t){t.push(us)},rect(t,e,i,s,n){t.push(gs,e,i,s,n)},roundRect(t,e,i,s,n,o){if(d(o))t.push(_s,e,i,s,n,o);else{const r=F.fourNumber(o);r?t.push(ps,e,i,s,n,...r):t.push(gs,e,i,s,n)}},ellipse(t,e,i,s,n,o,r,h,l){if(s===n)return Rs(t,e,i,s,r,h,l);a(o)?t.push(ms,e,i,s,n):(a(r)&&(r=0),a(h)&&(h=360),t.push(fs,e,i,s,n,o,r,h,l?1:0))},arc(t,e,i,s,n,o,r){a(n)?t.push(vs,e,i,s):(a(n)&&(n=0),a(o)&&(o=360),t.push(ys,e,i,s,n,o,r?1:0))},arcTo(t,e,i,s,n,o,a,h,l){if(!r(a)){const t=xs(a,h,e,i,s,n)/(l?1:2);o=Ss(o,Ss(t,t*ks(Es(bs(a,h,e,i,s,n)/2))))}t.push(ws,e,i,s,n,o)},drawEllipse(t,e,i,s,n,o,r,h,l){di.ellipse(null,e,i,s,n,a(o)?0:o,a(r)?0:r,a(h)?360:h,l,null,null,Bs),t.push(hs,Bs.x,Bs.y),Ps(t,e,i,s,n,o,r,h,l)},drawArc(t,e,i,s,n,o,r){di.arc(null,e,i,s,a(n)?0:n,a(o)?360:o,r,null,null,Bs),t.push(hs,Bs.x,Bs.y),Rs(t,e,i,s,n,o,r)},drawPoints(t,e,i,s){di.points(t,e,i,s)}},{ellipse:Ps,arc:Rs}=Ts,{moveTo:Ls,lineTo:Cs,quadraticCurveTo:Os,bezierCurveTo:As,closePath:Ds,beginPath:Ms,rect:Is,roundRect:Fs,ellipse:Ws,arc:zs,arcTo:Us,drawEllipse:Hs,drawArc:Ys,drawPoints:Ns}=Ts;class Xs{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?h(t)?Me.parse(t):t:[],this}beginPath(){return Ms(this.__path),this.paint(),this}moveTo(t,e){return Ls(this.__path,t,e),this.paint(),this}lineTo(t,e){return Cs(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,o){return As(this.__path,t,e,i,s,n,o),this.paint(),this}quadraticCurveTo(t,e,i,s){return Os(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ds(this.__path),this.paint(),this}rect(t,e,i,s){return Is(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Fs(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,o,r,a){return Ws(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}arc(t,e,i,s,n,o){return zs(this.__path,t,e,i,s,n,o),this.paint(),this}arcTo(t,e,i,s,n){return Us(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,o,r,a){return Hs(this.__path,t,e,i,s,n,o,r,a),this.paint(),this}drawArc(t,e,i,s,n,o){return Ys(this.__path,t,e,i,s,n,o),this.paint(),this}drawPoints(t,e,i){return Ns(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Vs,L:Gs,C:js,Q:Ks,Z:qs,N:Zs,D:Js,X:$s,G:Qs,F:tn,O:en,P:sn,U:nn}=Fe,on=oe.get("PathDrawer"),rn={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Vs:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Gs:t.lineTo(e[s+1],e[s+2]),s+=3;break;case js:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Ks:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case qs:t.closePath(),s+=1;break;case Zs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Js:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case $s:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Qs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*z,e[s+6]*z,e[s+7]*z,e[s+8]),s+=9;break;case tn:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,U,!1),s+=5;break;case en:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*z,e[s+5]*z,e[s+6]),s+=7;break;case sn:t.arc(e[s+1],e[s+2],e[s+3],0,U,!1),s+=4;break;case nn:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void on.error(`command: ${i} [index:${s}]`,e)}}},{M:an,L:hn,C:ln,Q:dn,Z:cn,N:un,D:gn,X:pn,G:_n,F:fn,O:mn,P:yn,U:vn}=Fe,{toTwoPointBounds:wn,toTwoPointBoundsByQuadraticCurve:xn,arcTo:bn,arc:En,ellipse:Sn}=di,{addPointBounds:kn,copy:Bn,addPoint:Tn,setPoint:Pn,addBounds:Rn,toBounds:Ln}=wt,Cn=oe.get("PathBounds");let On,An,Dn;const Mn={},In={},Fn={},Wn={toBounds(t,e){Wn.toTwoPointBounds(t,In),Ln(In,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Pn(e,0,0);let i,s,n,o,r,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(r=t[a],0===a&&(r===cn||r===ln||r===dn?Pn(e,h,l):Pn(e,t[a+1],t[a+2])),r){case an:case hn:h=t[a+1],l=t[a+2],Tn(e,h,l),a+=3;break;case ln:n=t[a+5],o=t[a+6],wn(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,o,Mn),kn(e,Mn),h=n,l=o,a+=7;break;case dn:i=t[a+1],s=t[a+2],n=t[a+3],o=t[a+4],xn(h,l,i,s,n,o,Mn),kn(e,Mn),h=n,l=o,a+=5;break;case cn:a+=1;break;case un:h=t[a+1],l=t[a+2],Rn(e,h,l,t[a+3],t[a+4]),a+=5;break;case gn:case pn:h=t[a+1],l=t[a+2],Rn(e,h,l,t[a+3],t[a+4]),a+=r===gn?9:6;break;case _n:Sn(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],Mn,Fn),0===a?Bn(e,Mn):kn(e,Mn),h=Fn.x,l=Fn.y,a+=9;break;case fn:h=t[a+1],l=t[a+2],An=t[a+3],Dn=t[a+4],Rn(e,h-An,l-Dn,2*An,2*Dn),h+=An,a+=5;break;case mn:En(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Mn,Fn),0===a?Bn(e,Mn):kn(e,Mn),h=Fn.x,l=Fn.y,a+=7;break;case yn:h=t[a+1],l=t[a+2],On=t[a+3],Rn(e,h-On,l-On,2*On,2*On),h+=On,a+=4;break;case vn:bn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Mn,Fn),0===a?Bn(e,Mn):kn(e,Mn),h=Fn.x,l=Fn.y,a+=6;break;default:return void Cn.error(`command: ${r} [index:${a}]`,t)}}},{M:zn,L:Un,Z:Hn}=Fe,{getCenterX:Yn,getCenterY:Nn}=dt,{arcTo:Xn}=Ts,Vn={smooth(t,e,i){let s,n,o,r=0,a=0,h=0,l=0,d=0,c=0,u=0,p=0,_=0;g(e)&&(e=e[0]||0);const f=t.length,m=9===f,y=[];for(;r<f;){switch(s=t[r],s){case zn:l=p=t[r+1],d=_=t[r+2],r+=3,t[r]===Un?(c=t[r+1],u=t[r+2],m?y.push(zn,l,d):y.push(zn,Yn(l,c),Nn(d,u))):y.push(zn,l,d);break;case Un:switch(a=t[r+1],h=t[r+2],r+=3,t[r]){case Un:Xn(y,a,h,t[r+1],t[r+2],e,p,_,m);break;case Hn:Xn(y,a,h,l,d,e,p,_,m);break;default:y.push(Un,a,h)}p=a,_=h;break;case Hn:n!==Hn&&(Xn(y,l,d,c,u,e,p,_,m),y.push(Hn)),r+=1;break;default:o=Ne[s];for(let e=0;e<o;e++)y.push(t[r+e]);r+=o}n=s}return s!==Hn&&(y[1]=l,y[2]=d),y}};function Gn(t){return new Xs(t)}const jn=Gn();Me.creator=Gn(),Me.parse=ns.parse,Me.convertToCanvasData=ns.toCanvasData;const{drawRoundRect:Kn}=Xe;function qn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Kn(this,t,e,i,s,n)})}(t)}const Zn={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=Jn.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{}}}},Jn=Zn;Jn.mineType=Jn.mimeType,Jn.alphaPixelTypes.forEach(t=>Jn.upperCaseTypeMap[t]=t.toUpperCase());const $n=oe.get("TaskProcessor");class Qn{constructor(t){this.parallel=!0,this.time=1,this.id=w.create(w.TASK),this.task=t}run(){return n(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(t){$n.error(t)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}}class to{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&&m.assign(this.config,t),this.empty()}add(t,e,i){let s,n,o,a;const h=new Qn(t);return h.parent=this,d(e)?a=e:e&&(n=e.parallel,s=e.start,o=e.time,a=e.delay,i||(i=e.canUse)),o&&(h.time=o),!1===n&&(h.parallel=!1),i&&(h.canUse=i),r(a)?this.push(h,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(h,s))},a)),this.isComplete=!1,h}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 n=s+e.parallel;if(n>i.length&&(n=i.length),e.parallel>1)for(let e=s;e<n&&(t=i[e],t.parallel);e++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const i=e.length,s=this.finishedIndex+i;if(e.length){if(!this.running)return;s<this.total&&(t=this.list[s],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach(t=>{t.parallel=!1}),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const eo=oe.get("Resource"),io={tasker:new to,queue:new to({parallel:1}),map:{},get isComplete(){return so.tasker.isComplete},set(t,e){so.map[t]&&eo.repeat(t),so.map[t]=e},get:t=>so.map[t],remove(t){const e=so.map[t];e&&(e.destroy&&e.destroy(),delete so.map[t])},loadImage(t,e){return new Promise((i,s)=>{const n=this.setImage(t,t,e);n.load(()=>i(n),t=>s(t))})},setImage(t,e,i){let s;return h(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=ge.image(s)),so.set(t,e),e},loadFilm(t,e){},loadVideo(t,e){},destroy(){so.map={}}},so=io,no={maxRecycled:10,recycledList:[],patternTasker:io.queue,get(t,e){let i=io.get(t.url);return i||io.set(t.url,i="film"===e?ge.film(t):ge.image(t)),i.use++,i},recycle(t){t.use--,setTimeout(()=>{t.use||(ie.image.isLarge(t)?t.url&&io.remove(t.url):(t.clearLevels(),oo.recycledList.push(t)))})},recyclePaint(t){oo.recycle(t.image)},clearRecycled(t){const e=oo.recycledList;(e.length>oo.maxRecycled||t)&&(e.forEach(e=>(!e.use||t)&&e.url&&io.remove(e.url)),e.length=0)},clearLevels(){},hasAlphaPixel:t=>Zn.alphaPixelTypes.some(e=>oo.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:"+Zn.mimeType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Zn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){this.clearRecycled(!0)}},oo=no,{IMAGE:ro,create:ao}=w;class ho{get tag(){return"Image"}get url(){return this.config.url}get crossOrigin(){const{crossOrigin:t}=this.config;return r(t)?ie.image.crossOrigin:t}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=ao(ro),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,io.tasker.add(()=>n(this,void 0,void 0,function*(){return yield ie.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,n,o,r,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=ie.image.resize(this.view,t,e,n,o,void 0,r,i,s,a);return this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(t,e,i,s){const n=ie.canvas.createPattern(t,e);return ie.image.setPatternTransform(n,i,s),n}render(t,e,i,s,n,o,r,a,h){t.drawImage(this.view,e,i,s,n)}getLoadUrl(t){return this.url}setThumbView(t){}getThumbSize(t){}getMinLevel(){}getLevelData(t,e,i){}clearLevels(t){}destroy(){this.clearLevels();const{view:t}=this;t&&t.close&&t.close(),this.config={url:""},this.cache=this.view=null,this.waitComplete.length=0}}function lo(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function co(t,e){return Object.getOwnPropertyDescriptor(t,e)}function uo(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function go(t,e){return(i,s)=>_o(i,s,t,e&&e(s))}function po(t){return t}function _o(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};lo(t,e,Object.assign(n,s||{})),No(t,e,i)}function fo(t){return go(t)}function mo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function yo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function vo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),So(this))}}))}function wo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function xo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function bo(t,e){return go(t,t=>({set(i){this.__setAttr(t,i,e)&&So(this)}}))}function Eo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(So(this),this.__.__removeNaturalSize())}}))}function So(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function ko(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),So(this)}}))}const Bo=bo;function To(t,e){return go(t,t=>({set(i){this.__setAttr(t,i)&&(Po(this),e&&(this.__.__useStroke=!0))}}))}function Po(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&So(t)}const Ro=To;function Lo(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Co(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Oo(t){return go(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;m.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Ao(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Mo(this)}}))}function Do(t){return go(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Io(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Io(this,t,e,i),this.mask&&Mo(this)}}))}function Mo(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Io(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||So(t))}function Fo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Wo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function zo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Uo(t){return go(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===oe.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function Ho(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Yo(t){return(e,i)=>{lo(e,"__DataProcessor",{get:()=>t})}}function No(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=uo(e,i);if(r(i))a.get=function(){return this[n]};else if("function"==typeof i)a.get=function(){const t=this[n];return null==t?i(this.__leaf):t};else if(p(i)){const t=f(i);a.get=function(){const e=this[n];return null==e?this[n]=t?{}:m.clone(i):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[n];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:h&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(a.get=function(){const t=this[n];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:h&&s.children.length?s.boxBounds.height:i}return t});let l,d=s;for(;!l&&d;)l=co(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),s[o]&&(a.set=s[o],delete s[o]),lo(s,e,a)}const Xo=new oe("rewrite"),Vo=[],Go=["destroy","constructor"];function jo(t){return(e,i)=>{Vo.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function Ko(){return t=>{qo()}}function qo(t){Vo.length&&(Vo.forEach(e=>{t&&Xo.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Vo.length=0)}function Zo(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Go.includes(s)||e&&e.includes(s)))if(t.prototype){co(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Jo(){return t=>{_e.register(t)}}function $o(){return t=>{ye.register(t)}}setTimeout(()=>qo(!0));const{copy:Qo,toInnerPoint:tr,toOuterPoint:er,scaleOfOuter:ir,rotateOfOuter:sr,skewOfOuter:nr,multiplyParent:or,divideParent:rr,getLayout:ar}=$,hr={},{round:lr}=Math,dr={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),gr(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)ur(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++)pr(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&pr(t),t.__updateChange()},updateAllChange(t){if(fr(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)_r(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,n,o){s||(s=t.__nowWorld),t.__worldFlipped||ie.fullImageShadow?e.copyWorldByReset(i,s,t.__nowWorld,n,o):e.copyWorldToInner(i,s,t.__layout.renderBounds,n)},moveWorld(t,e,i=0,s,n){const o=p(e)?Object.assign({},e):{x:e,y:i};s?er(t.localTransform,o,o,!0):t.parent&&tr(t.parent.scrollWorldTransform,o,o,!0),cr.moveLocal(t,o.x,o.y,n)},moveLocal(t,e,i=0,s){p(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=lr(e),i=lr(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,o){cr.zoomOfLocal(t,mr(t,e),i,s,n,o)},zoomOfLocal(t,e,i,s=i,n,o){const r=t.__localMatrix;if(d(s)||(s&&(o=s),s=i),Qo(hr,r),ir(hr,e,i,s),cr.hasHighPosition(t))cr.setTransform(t,hr,n,o);else{const e=t.x+hr.e-r.e,a=t.y+hr.f-r.f;o&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},o):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){cr.rotateOfLocal(t,mr(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Qo(hr,n),sr(hr,e,i),cr.hasHighPosition(t)?cr.setTransform(t,hr,!1,s):t.set({x:t.x+hr.e-n.e,y:t.y+hr.f-n.f,rotation:F.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,o){cr.skewOfLocal(t,mr(t,e),i,s,n,o)},skewOfLocal(t,e,i,s=0,n,o){Qo(hr,t.__localMatrix),nr(hr,e,i,s),cr.setTransform(t,hr,n,o)},transformWorld(t,e,i,s){Qo(hr,t.worldTransform),or(hr,e),t.parent&&rr(hr,t.parent.scrollWorldTransform),cr.setTransform(t,hr,i,s)},transform(t,e,i,s){Qo(hr,t.localTransform),or(hr,e),cr.setTransform(t,hr,i,s)},setTransform(t,e,i,s){const n=t.__,o=n.origin&&cr.getInnerOrigin(t,n.origin),r=ar(e,o,n.around&&cr.getInnerOrigin(t,n.around));if(cr.hasOffset(t)&&(r.x-=n.offsetX,r.y-=n.offsetY),i){const e=r.scaleX/t.scaleX,i=r.scaleY/t.scaleY;if(delete r.scaleX,delete r.scaleY,o){Vt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=cr.getInnerOrigin(t,n.origin);dt.move(r,o.x-s.x,o.y-s.y)}t.set(r),t.scaleResize(e,i,!1)}else t.set(r,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return ir(i,cr.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>dt.tempToOuterOf(cr.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return kt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Qo(hr,t.worldTransform),rr(hr,e.scrollWorldTransform),i?hr:Object.assign({},hr)),drop(t,e,i,s){t.setTransform(cr.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||cr.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,n=e.y*i;e.x-=s,e.y-=n,t.move(s,n),ie.requestRender(()=>cr.animateMove(t,e,i))}}},cr=dr,{updateAllMatrix:ur,updateMatrix:gr,updateAllWorldOpacity:pr,updateAllChange:_r,updateChange:fr}=cr;function mr(t,e){return t.updateLayout(),t.parent?dt.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const yr={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.eraser||0===t.__.visible?null:t.__local||t.__layout,localStrokeBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.eraser||0===t.__.visible?null:t.__layout.localRenderBounds,maskLocalBoxBounds:(t,e)=>wr(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>wr(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>wr(t,e)&&t.__layout.localRenderBounds,excludeRenderBounds:(t,e)=>!(!e.bounds||e.bounds.hit(t.__world,e.matrix))||!(!e.hideBounds||!e.hideBounds.includes(t.__world,e.matrix))};let vr;function wr(t,e){return e||(vr=0),t.__.mask&&(vr=1),vr<0?null:(vr&&(vr=-1),!0)}const{updateBounds:xr}=dr,br={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:i}=t;for(let s=0,n=i.length;s<n;s++)(t=i[s]).isBranch&&(t.__tempNumber=1,e.add(t),Er(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&r(i[t.parent.innerId]);)e.add(t.parent),t=t.parent;else for(;t.parent;)e.add(t.parent),t=t.parent},pushAllBranchStack(t,e){let i=e.length;const{children:s}=t;for(let t=0,i=s.length;t<i;t++)s[t].isBranch&&e.push(s[t]);for(let t=i,s=e.length;t<s;t++)Sr(e[t],e)},updateBounds(t,e){const i=[t];Sr(t,i),kr(i,e)},updateBoundsByBranchStack(t,e){let i,s;for(let n=t.length-1;n>-1;n--){i=t[n],s=i.children;for(let t=0,e=s.length;t<e;t++)xr(s[t]);e&&e===i||xr(i)}},move(t,e,i){let s;const{children:n}=t;for(let o=0,r=n.length;o<r;o++)s=(t=n[o]).__world,s.e+=e,s.f+=i,s.x+=e,s.y+=i,t.isBranch&&Br(t,e,i)},scale(t,e,i,s,n,o,r){let a;const{children:h}=t,l=s-1,d=n-1;for(let c=0,u=h.length;c<u;c++)a=(t=h[c]).__world,a.a*=s,a.d*=n,(a.b||a.c)&&(a.b*=s,a.c*=n),a.e===a.x&&a.f===a.y?(a.x=a.e+=(a.e-o)*l+e,a.y=a.f+=(a.f-r)*d+i):(a.e+=(a.e-o)*l+e,a.f+=(a.f-r)*d+i,a.x+=(a.x-o)*l+e,a.y+=(a.y-r)*d+i),a.width*=s,a.height*=n,a.scaleX*=s,a.scaleY*=n,t.isBranch&&Tr(t,e,i,s,n,o,r)}},{pushAllChildBranch:Er,pushAllBranchStack:Sr,updateBoundsByBranchStack:kr,move:Br,scale:Tr}=br,Pr={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:Rr,updateBounds:Lr}=dr,{toOuterOf:Cr,getPoints:Or,copy:Ar}=Vt,Dr="_localContentBounds",Mr="_worldContentBounds",Ir="_worldBoxBounds",Fr="_worldStrokeBounds";class Wr{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 Cr(this.contentBounds,this.leaf.__localMatrix,this[Dr]||(this[Dr]={})),this[Dr]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return Cr(this.contentBounds,this.leaf.__world,this[Mr]||(this[Mr]={})),this[Mr]}get worldBoxBounds(){return Cr(this.boxBounds,this.leaf.__world,this[Ir]||(this[Ir]={})),this[Ir]}get worldStrokeBounds(){return Cr(this.strokeBounds,this.leaf.__world,this[Fr]||(this[Fr]={})),this[Fr]}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 Lr(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,ie.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 $.defaultMatrix;case"page":t=e.zoomLayer;default:return Rr(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 n,o,r,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),o=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;r={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,o=$.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),o=Rr(s,e,!0)}if(r||(r=$.getLayout(o)),Ar(r,a),dt.copy(r,n),i){const{scaleX:t,scaleY:e}=r,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(r.scaleX/=i,r.scaleY/=s,r.width*=i,r.height*=s)}return r}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=Or(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:n=e}return r(n)||s.forEach(t=>i.innerToWorld(t,null,!1,n)),s}shrinkContent(){const{x:t,y:e,width:i,height:s}=this.boxBounds;this._contentBounds={x:t,y:e,width:i,height:s}}spreadStroke(){const{x:t,y:e,width:i,height:s}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:i,height:s},this._localStrokeBounds={x:t,y:e,width:i,height:s},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:i,height:s}=this.renderBounds;this._renderBounds={x:t,y:e,width:i,height:s},this._localRenderBounds={x:t,y:e,width:i,height:s}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged?this.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,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class zr{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&ie.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&ie.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&ie.event.stop(this.origin)}}class Ur extends zr{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Ur.ADD="child.add",Ur.REMOVE="child.remove",Ur.CREATED="created",Ur.MOUNTED="mounted",Ur.UNMOUNTED="unmounted",Ur.DESTROY="destroy";const Hr="property.scroll";class Yr extends zr{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Yr.CHANGE="property.change",Yr.LEAFER_CHANGE="property.leafer_change",Yr.SCROLL=Hr;const Nr={scrollX:Hr,scrollY:Hr};class Xr extends zr{constructor(t,e){super(t),Object.assign(this,e)}}Xr.LOAD="image.load",Xr.LOADED="image.loaded",Xr.ERROR="image.error";class Vr extends zr{static checkHas(t,e,i){"on"===i?e===qr?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Gr)||t.hasEvent(jr)||t.hasEvent(Kr),t.__hasWorldEvent=t.hasEvent(qr))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Gr,t),"inner"===e&&t.emit(jr,t)),t.emit(Kr,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(qr,this)}}Vr.RESIZE="bounds.resize",Vr.INNER="bounds.inner",Vr.LOCAL="bounds.local",Vr.WORLD="bounds.world";const{RESIZE:Gr,INNER:jr,LOCAL:Kr,WORLD:qr}=Vr,Zr={};[Gr,jr,Kr,qr].forEach(t=>Zr[t]=1);class Jr extends zr{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){p(t)?(super(Jr.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!r(this.resizingKeys[t.innerId])}}Jr.RESIZE="resize";class $r extends zr{constructor(t,e){super(t),this.data=e}}$r.REQUEST="watch.request",$r.DATA="watch.data";class Qr extends zr{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Qr.REQUEST="layout.request",Qr.START="layout.start",Qr.BEFORE="layout.before",Qr.LAYOUT="layout",Qr.AFTER="layout.after",Qr.AGAIN="layout.again",Qr.END="layout.end";class ta extends zr{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}ta.REQUEST="render.request",ta.CHILD_START="render.child_start",ta.CHILD_END="render.child_end",ta.START="render.start",ta.BEFORE="render.before",ta.RENDER="render",ta.AFTER="render.after",ta.AGAIN="render.again",ta.END="render.end",ta.NEXT="render.next";class ea extends zr{}ea.START="leafer.start",ea.BEFORE_READY="leafer.before_ready",ea.READY="leafer.ready",ea.AFTER_READY="leafer.after_ready",ea.VIEW_READY="leafer.view_ready",ea.VIEW_COMPLETED="leafer.view_completed",ea.STOP="leafer.stop",ea.RESTART="leafer.restart",ea.END="leafer.end",ea.UPDATE_MODE="leafer.update_mode",ea.TRANSFORM="leafer.transform",ea.MOVE="leafer.move",ea.SCALE="leafer.scale",ea.ROTATE="leafer.rotate",ea.SKEW="leafer.skew";const{MOVE:ia,SCALE:sa,ROTATE:na,SKEW:oa}=ea,ra={x:ia,y:ia,scaleX:sa,scaleY:sa,rotation:na,skewX:oa,skewY:oa},aa={};class ha{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(g(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)g(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,n,o;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const r=la(this,s,!0),a=h(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};a.forEach(t=>{t&&(o=r[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(l):r[t]=[l],Zr[t]&&Vr.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=h(t)?t.split(" "):t;if(e){let t,n,o;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const r=la(this,t);s.forEach(t=>{t&&(n=r[t],n&&(o=n.findIndex(t=>t.listener===e),o>-1&&n.splice(o,1),n.length||delete r[t],Zr[t]&&Vr.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):g(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=g(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):g(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 g(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));p(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&ye.has(t)&&(e=ye.get(t,{type:t,target:this,current:this}));const s=la(this,i)[t];if(s){let n;for(let o=0,r=s.length;o<r&&!((n=s[o])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),o--,r--),e&&e.isStopNow));o++);}this.syncEventer&&this.syncEventer.emitEvent(e,i)}emitEvent(t,e){t.current=this,this.emit(t.type,t,e)}hasEvent(t,e){if(this.syncEventer&&this.syncEventer.hasEvent(t,e))return!0;const{__bubbleMap:i,__captureMap:s}=this,n=i&&i[t],o=s&&s[t];return!!(r(e)?n||o:e?o:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function la(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:aa)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:aa)}}const{on:da,on_:ca,off:ua,off_:ga,once:pa,emit:_a,emitEvent:fa,hasEvent:ma,destroy:ya}=ha.prototype,va={on:da,on_:ca,off:ua,off_:ga,once:pa,emit:_a,emitEvent:fa,hasEvent:ma,destroyEventer:ya},wa=oe.get("setAttr"),xa={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||l(e)||r(e)||(wa.warn(this.innerName,t,e),e=void 0),p(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Yr(Yr.LEAFER_CHANGE,this,t,s,e));const i=ra[t];i&&(this.emitEvent(new ea(i,this)),this.emitEvent(new ea(ea.TRANSFORM,this)))}this.emitPropertyEvent(Yr.CHANGE,t,s,e);const i=Nr[t];return i&&this.emitPropertyEvent(i,t,s,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const n=new Yr(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(n),this.leafer.emitEvent(n)},__realSetAttr(t,e){const i=this.__;i[t]=e,this.__proxyData&&this.setProxyAttr(t,e),i.normalStyle&&(this.lockNormalStyle||r(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ba,multiplyParent:Ea,translateInner:Sa,defaultWorld:ka}=$,{toPoint:Ba,tempPoint:Ta}=kt,Pa={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;Ea(this.__local||e,t?t.__scrollWorld||t.__world:ka,i,!!e.affectScaleOrRotation,n),s&&Sa(Object.assign(s,i),n.scrollX,n.scrollY)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,i=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(ba(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)&&(Ba(i.around||i.origin,t.boxBounds,Ta),Sa(e,-Ta.x,-Ta.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:Ra,updateAllMatrix:La}=dr,{updateBounds:Ca}=br,{toOuterOf:Oa,copyAndSpread:Aa,copy:Da}=Vt,{toBounds:Ma}=Wn,Ia={__updateWorldBounds(){const{__layout:t,__world:e}=this;Oa(t.renderBounds,e,e),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Vr.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Vr.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.resized||(t.resized="local"),t.boundsChanged=void 0},__updateLocalBoxBounds(){this.__hasMotionPath&&this.__updateMotionPath(),this.__hasAutoLayout&&this.__updateAutoLayout(),Oa(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Oa(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Oa(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Ma(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(),La(this),Ca(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(La(this),Ca(this,this))):Ra(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Aa(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;d(i)&&i<=0?Da(e.renderBounds,e.strokeBounds):Aa(e.renderBounds,e.boxBounds,i)}},Fa={__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.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),dr.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);oe.showBounds&&oe.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:Wa}=yr,{hasSize:za}=Vt,Ua={__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&&za(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 n=t.getSameCanvas(!1,!0);this.__renderBranch(n,e),t.opacity=e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(n,i,i,s.__blendMode,!0),n.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 n=0,o=s.length;n<o;n++)i=s[n],Wa(i,e)||(i.__.complex?i.__renderComplex(t,e):i.__render(t,e))}},__clip(t,e){if(this.__worldOpacity){const{children:i}=this;for(let s=0,n=i.length;s<n;s++)Wa(i[s],e)||i[s].__clip(t,e)}}},Ha={},{LEAF:Ya,create:Na}=w,{stintSet:Xa}=m,{toInnerPoint:Va,toOuterPoint:Ga,multiplyParent:ja}=$,{toOuterOf:Ka}=Vt,{copy:qa,move:Za}=dt,{moveLocal:Ja,zoomOfLocal:$a,rotateOfLocal:Qa,skewOfLocal:th,moveWorld:eh,zoomOfWorld:ih,rotateOfWorld:sh,skewOfWorld:nh,transform:oh,transformWorld:rh,setTransform:ah,getFlipTransform:hh,getLocalOrigin:lh,getRelativeWorld:dh,drop:ch}=dr;t.Leaf=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 v}get __LayoutProcessor(){return Wr}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=Na(Ya),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Ur.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(Ur.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Ur.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(Ur.MOUNTED)):this.__emitLifeEvent(Ur.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){r(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=r(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 ja(i,t.matrix,e,void 0,i),Ka(this.__layout.renderBounds,e,e),Xa(e,"half",i.half),Xa(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){let{scaleX:i,scaleY:s}=no.patternLocked?this.__world:this.__nowWorld;return t&&(i<0&&(i=-i),s<0&&(s=-s)),(!0===e||"zoom-in"===e&&i>1&&s>1)&&(i=s=1),Ha.scaleX=i,Ha.scaleY=s,Ha}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?dh(this,e):this.worldTransform,n=i?t:{};return Ka(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&qa(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&qa(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Va(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Ga(this.scrollWorldTransform,t,e,i),s&&s.worldToInner(e||t,null,i)}getBoxPoint(t,e,i,s){return this.getBoxPointByInner(this.getInnerPoint(t,e,i,s),null,null,!0)}getBoxPointByInner(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Za(n,-o,-r),n}getInnerPoint(t,e,i,s){const n=s?t:{};return this.worldToInner(t,n,i,e),n}getInnerPointByBox(t,e,i,s){const n=s?t:Object.assign({},t),{x:o,y:r}=this.boxBounds;return Za(n,o,r),n}getInnerPointByLocal(t,e,i,s){return this.getInnerPoint(t,this.parent,i,s)}getLocalPoint(t,e,i,s){const n=s?t:{};return this.worldToLocal(t,n,i,e),n}getLocalPointByInner(t,e,i,s){return this.getWorldPoint(t,this.parent,i,s)}getPagePoint(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,i,s)}getWorldPoint(t,e,i,s){const n=s?t:{};return this.innerToWorld(t,n,i,e),n}getWorldPointByBox(t,e,i,s){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,s),e,i,!0)}getWorldPointByLocal(t,e,i,s){const n=s?t:{};return this.localToWorld(t,n,i,e),n}getWorldPointByPage(t,e,i,s){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,i,s)}setTransform(t,e,i){ah(this,t,e,i)}transform(t,e,i){oh(this,t,e,i)}move(t,e,i){Ja(this,t,e,i)}moveInner(t,e,i){eh(this,t,e,!0,i)}scaleOf(t,e,i,s,n){$a(this,lh(this,t),e,i,s,n)}rotateOf(t,e,i){Qa(this,lh(this,t),e,i)}skewOf(t,e,i,s,n){th(this,lh(this,t),e,i,s,n)}transformWorld(t,e,i){rh(this,t,e,i)}moveWorld(t,e,i){eh(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){ih(this,t,e,i,s,n)}rotateOfWorld(t,e){sh(this,t,e)}skewOfWorld(t,e,i,s,n){nh(this,t,e,i,s,n)}flip(t,e){oh(this,hh(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){}__renderComplex(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(){}getMotionPathData(){return ue.need("path")}getMotionPoint(t){return ue.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){ch(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):No(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=bo),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Ur(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Ur.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},t.Leaf=s([Zo(xa),Zo(Pa),Zo(Ia),Zo(va),Zo(Fa)],t.Leaf);const{setListWithFn:uh}=Vt,{sort:gh}=br,{localBoxBounds:ph,localStrokeBounds:_h,localRenderBounds:fh,maskLocalBoxBounds:mh,maskLocalStrokeBounds:yh,maskLocalRenderBounds:vh}=yr,wh=new oe("Branch");t.Branch=class extends t.Leaf{__updateStrokeSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,i=t.length;e<i;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(t,e){uh(e||this.__layout.boxBounds,this.children,this.__hasMask?mh:ph)}__updateStrokeBounds(t){uh(t||this.__layout.strokeBounds,this.children,this.__hasMask?yh:_h)}__updateRenderBounds(t){uh(t||this.__layout.renderBounds,this.children,this.__hasMask?vh:fh)}__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(gh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return wh.warn("add self or destroyed");const i=r(e);if(!t.__){if(g(t))return t.forEach(t=>{this.add(t,e),i||e++});if(!(t=_e.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(Ur.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Ur.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)):r(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(Ur.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Ur.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Ur(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}},t.Branch=s([Zo(Ua)],t.Branch);class xh{get length(){return this.list.length}constructor(t){this.reset(),t&&(g(t)?this.addList(t):this.add(t))}has(t){return t&&!r(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return r(e)?-1:e}add(t){const{list:e,keys:i}=this;r(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(r(i[t.innerId])){const{list:s}=this;for(let t=e,n=s.length;t<n;t++)i[s[t].innerId]++;0===e?s.unshift(t):(e>s.length&&(e=s.length),s.splice(e,0,t)),i[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let i;for(let s=0,n=e.length;s<n;s++)r(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;r(i)||e.splice(i,1)}sort(t){const{list:e}=this;t?e.sort((t,e)=>e.__level-t.__level):e.sort((t,e)=>t.__level-e.__level)}forEach(t){this.list.forEach(t)}clone(){const t=new xh;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let i=0,s=t.length;i<s;i++)e[t[i].innerId]=i}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}class bh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(g(t)?this.addList(t):this.add(t))}has(t){return!r(this.keys[t.innerId])}without(t){return r(this.keys[t.innerId])}sort(t){const{levels:e}=this;t?e.sort((t,e)=>e-t):e.sort((t,e)=>t-e)}addList(t){t.forEach(t=>{this.add(t)})}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}class Eh extends De{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=ie.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function Sh(t,e){ie.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Zn.mimeType(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:Zn.mimeType(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:(t,e,i)=>new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",ie.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then(t=>{e(t)}).catch(t=>{i(t)})},s.onerror=t=>i(t),s.send()}),loadContent(t){return n(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]()})}},ie.canvas=ge.canvas(),ie.conicGradientSupport=!!ie.canvas.context.createConicGradient}qn(OffscreenCanvasRenderingContext2D.prototype),qn(Path2D.prototype),Object.assign(ge,{canvas:(t,e)=>new Eh(t,e),image:t=>new ho(t)}),ie.name="web",ie.isWorker=!0,ie.backgrounder=!0,ie.requestRender=function(t){requestAnimationFrame(t)},lo(ie,"devicePixelRatio",{get:()=>1});const{userAgent:kh}=navigator;kh.indexOf("Firefox")>-1?(ie.conicGradientRotate90=!0,ie.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(ie.fullImageShadow=!0),kh.indexOf("Windows")>-1?(ie.os="Windows",ie.intWheelDeltaY=!0):kh.indexOf("Mac")>-1?ie.os="Mac":kh.indexOf("Linux")>-1&&(ie.os="Linux");class Bh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new xh;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 xh,this.target=t,e&&(this.config=m.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(ta.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===Ur.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new $r($r.DATA,{updatedList:this.updatedList})),this.__updatedList=new xh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Yr.CHANGE,this.__onAttrChange,this],[[Ur.ADD,Ur.REMOVE],this.__onChildEvent,this],[$r.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:Th,updateBounds:Ph,updateChange:Rh}=dr,{pushAllChildBranch:Lh,pushAllParent:Ch}=br;const{worldBounds:Oh}=yr;class Ah{constructor(t){this.updatedBounds=new qt,this.beforeBounds=new qt,this.afterBounds=new qt,g(t)&&(t=new xh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Oh)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Oh),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:Dh,updateAllChange:Mh}=dr,Ih=oe.get("Layouter");class Fh{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new bh,this.target=t,e&&(this.config=m.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(Qr.START),this.layoutOnce(),t.emitEvent(new Qr(Qr.END,this.layoutedBlocks,this.times))}catch(t){Ih.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Ih.warn("layouting"):this.times>3?Ih.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit($r.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=le.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=Qr,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Qr(n,a,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Th(t,!0),e.add(t),t.isBranch&&Lh(t,e),Ch(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Ch(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Ph(s[t])}Ph(i)}})}(this.__levelList),function(t){t.list.forEach(Rh)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Qr(o,a,this.times)),i.emitEvent(new Qr(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,le.end(e)}fullLayout(){const t=le.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=Qr,o=this.getBlocks(new xh(e));e.emitEvent(new Qr(i,o,this.times)),Fh.fullLayout(e),o.forEach(t=>{t.setAfter()}),e.emitEvent(new Qr(s,o,this.times)),e.emitEvent(new Qr(n,o,this.times)),this.addBlocks(o),le.end(t)}static fullLayout(t){Dh(t,!0),t.isBranch?br.updateBounds(t):dr.updateBounds(t),Mh(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Ah([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Ah(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_([[Qr.REQUEST,this.layout,this],[Qr.AGAIN,this.layoutAgain,this],[$r.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Wh=oe.get("Renderer");class zh{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=m.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(Qr.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(ta.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(ta.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(ta.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new qt,Wh.log(e.innerName,"---\x3e");try{this.emitRender(ta.START),this.renderOnce(t),this.emitRender(ta.END,this.totalBounds),no.clearRecycled()}catch(t){this.rendering=!1,Wh.error(t)}Wh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Wh.warn("rendering");if(this.times>3)return Wh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new qt,this.renderOptions={},t)this.emitRender(ta.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(ta.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(ta.RENDER,this.renderBounds,this.renderOptions),this.emitRender(ta.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=le.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new qt(s);i.save(),s.spread(zh.clipSpread).ceil();const{ceilPartPixel:o}=this.config;i.clipWorld(s,o),i.clearWorld(s,o),this.__render(s,n),i.restore(),le.end(e)}fullRender(){const t=le.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),le.end(t)}__render(t,e){const{canvas:i,target:s}=this,n=t.includes(s.__world),o=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),oe.showRepaint&&oe.drawRepaint(i,t),this.config.useCellRender&&(o.cellList=this.getCellList()),ie.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 ie.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()};ie.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||Wh.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 ta(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[ta.REQUEST,this.update,this],[Qr.END,this.__onLayoutEnd,this],[ta.AGAIN,this.renderAgain,this],[Jr.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}zh.clipSpread=10;const Uh={},{copyRadiusPoint:Hh}=dt,{hitRadiusPoint:Yh}=Vt;class Nh{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new xh(i.findList),i.findList||this.hitBranch(o.isBranchLeaf?{children:[o]}:o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new xh;if(t.length){let e;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=t.length;s<o;s++)if(e=t[s],(i||dr.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&dr.hasParent(t,e))){n.reset();break}return n.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>dr.worldHittable(t))}getPath(t){const e=new xh,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 xh;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new xh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s,n;const{point:o}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],n=i.__,n.visible&&(!e||n.mask))if(s=Yh(i.__world,n.hitRadius?Hh(Uh,o,n.hitRadius):o),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&n.__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,n=[];const{children:o}=s;for(let s=0,r=o.length;s<r;s++)if(i=o[s],i.__.mask&&n.push(i),i===t){if(n&&!n.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()}}class Xh{constructor(t,e){this.config={},e&&(this.config=m.default(e,this.config)),this.picker=new Nh(this.target=t,this),this.finder=ge.finder&&ge.finder()}getByPoint(t,e,i){const{target:s,picker:n}=this;return ie.backgrounder&&s&&s.updateLayout(),n.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):ue.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Vh(t){return go(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Gh(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function jh(){return(t,e)=>{const i="_"+e;lo(t,e,{set(t){this.isLeafer&&(this[i]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[i]||this:this.leafer&&this.leafer.zoomLayer}})}}Object.assign(ge,{watcher:(t,e)=>new Bh(t,e),layouter:(t,e)=>new Fh(t,e),renderer:(t,e,i)=>new zh(t,e,i),selector:(t,e)=>new Xh(t,e)}),ie.layout=Fh.fullLayout,ie.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new xh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Kh={},qh={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}},Zh=$t,Jh={},$h={},Qh={},tl={},el={},il={apply(){ue.need("filter")}},sl={},nl={setStyleName:()=>ue.need("state"),set:()=>ue.need("state")},ol={list:{},register(t,e){ol.list[t]=e},get:t=>ol.list[t]},{parse:rl,objectToCanvasData:al}=ns,{stintSet:hl}=m,{hasTransparent:ll}=qh,dl={originPaint:{}},cl=oe.get("UIData");class ul extends v{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;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,t.strokeWidth):t.strokeWidth}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,cl.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,cl.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),h(t)||!t?(hl(this,"__isTransparentFill",ll(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):p(t)&&this.__setPaint("fill",t)}setStroke(t){h(t)||!t?(hl(this,"__isTransparentStroke",ll(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):p(t)&&this.__setPaint("stroke",t)}setPath(t){const e=h(t);e||t&&p(t[0])?(this.__setInput("path",t),this._path=e?rl(t):al(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){gl(this,"shadow",t)}setInnerShadow(t){gl(this,"innerShadow",t)}setFilter(t){gl(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&$h.compute("fill",this.__leaf),e&&$h.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),r(t.strokeWidthFixed)||(i=t.strokeWidthFixed)),i){const t=this.__leaf.getClampRenderScale();return t>1?e/t:e}return e}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),g(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=dl)):(this.__isStrokes=!0,this._stroke||(this._stroke=dl))}__removePaint(t,e){e&&this.__removeInput(t),Qh.recycleImage(t,this),"fill"===t?(hl(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(hl(this,"__isAlphaPixelStroke",void 0),hl(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function gl(t,e,i){t.__setInput(e,i),g(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}class pl extends ul{}class _l extends pl{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)}}class fl extends pl{__getInputData(t,e){const i=super.__getInputData(t,e);return Ae.forEach(t=>delete i[t]),i}}class ml extends _l{}class yl extends ul{get __usePathBox(){return this.points||this.__pathInputed}}class vl extends ul{get __boxStroke(){return!this.__pathInputed}}class wl extends ul{get __boxStroke(){return!this.__pathInputed}}class xl extends yl{}class bl extends ul{}class El extends ul{get __pathInputed(){return 2}}class Sl extends pl{}const kl={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Bl extends ul{get __useNaturalRatio(){return!1}setFontWeight(t){h(t)?(this.__setInput("fontWeight",t),t=kl[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=_e.get("Rect",0);const n=e.__layout,o=i.__layout;s||(i.parent=e,i.__world=e.__world,o.boxBounds=n.boxBounds),i.set(t),o.strokeChanged&&n.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}}class Tl extends vl{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}}class Pl extends vl{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const{max:Rl,add:Ll}=T,Cl={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,o=this.__box;if((i.stroke||"all"===i.hitStroke)&&n&&"inside"!==s&&(e=t="center"===s?n/2:n,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:n;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*n),o&&(t=Rl(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:n,filter:o,renderSpread:r}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=el.getShadowRenderSpread(this,e)),s&&(t=Rl(t,s)),o&&(t=Ll(t,il.getSpread(o))),r&&(t=Ll(t,r)),a&&(t=Ll(t,a));let l=t;return i&&(l=Rl(l,el.getInnerShadowSpread(this,i))),n&&(l=Rl(l,n)),this.__layout.renderShapeSpread=l,h?Rl(h.__updateRenderSpread(),t):t}},{stintSet:Ol}=m,Al={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Ol(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Ol(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,n=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Ol(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!el.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(g(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),Ol(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){Dl(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:o,__drawAfterFill:r,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=$h.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&el.shadow(this,t,h),a&&(s.__isStrokes?$h.strokes(o,this,t,e):$h.stroke(o,this,t,e)),n&&(s.__isFills?$h.fills(n,this,t,e):$h.fill(n,this,t,e)),r&&this.__drawAfterFill(t,e),d&&el.innerShadow(this,t,h),o&&!a&&(s.__isStrokes?$h.strokes(o,this,t,e):$h.stroke(o,this,t,e)),c&&il.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?$h.strokes(o,this,t,e):$h.stroke(o,this,t,e)),h){const e=s.shadow[0],{scaleX:i,scaleY:n}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*n,e.blur*i,qh.string(e.color))}n&&(s.__isFills?$h.fills(n,this,t,e):$h.fill(n,this,t,e)),h&&t.restore(),r&&this.__drawAfterFill(t,e),o&&!a&&(s.__isStrokes?$h.strokes(o,this,t,e):$h.stroke(o,this,t,e))}}else s.__pathForRender?Dl(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:n}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?$h.fills(s,this,t,e):$h.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?$h.strokes(n,this,t,e):$h.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 Dl(t,e,i){const{fill:s,stroke:n,__drawAfterFill:o,__fillAfterStroke:r}=t.__;t.__drawRenderPath(e),r&&$h.stroke(n,t,e,i),s&&$h.fill(s,t,e,i),o&&t.__drawAfterFill(e,i),n&&!r&&$h.stroke(n,t,e,i)}const Ml={__drawFast(t,e){let{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;const{fill:r,stroke:a,__drawAfterFill:h}=this.__;if(r&&(t.fillStyle=r,t.fillRect(i,s,n,o)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:r,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(r){case"center":t.strokeRect(0,0,n,o);break;case"inside":n-=h,o-=h,n<0||o<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,o),t.restore()):t.strokeRect(i+l,s+l,n,o);break;case"outside":t.strokeRect(i-l,s-l,n+h,o+h)}}}};var Il,Fl;t.UI=Il=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){F.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 jn.set(this.path=t||[]),t||this.__drawPathByBox(jn),jn}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return h(t)?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return ue.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return ue.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(jn.set(i=[]),this.__drawPathByBox(jn,!e)),t?ns.toCanvasData(i,!0):i}getPathString(t,e,i){return ns.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||sl.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Vn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Jh.addArrows(this)):t.__pathForRender&&(t.__pathForRender=void 0)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path,!0)}__drawPathByData(t,e,i){e?rn.drawPathByData(t,e):this.__drawPathByBox(t,i)}__drawPathByBox(t,e){const{x:i,y:s,width:n,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius&&!e){const{cornerRadius:e}=this.__;t.roundRect(i,s,n,o,d(e)?[e]:e)}else t.rect(i,s,n,o);t.closePath()}drawImagePlaceholder(t,e,i){$h.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),ue.need("animate")}killAnimate(t,e){}export(t,e){return ue.need("export")}syncExport(t,e){return ue.need("export")}clone(t){const e=m.clone(this.toJSON());return t&&Object.assign(e,t),Il.one(e)}static one(t,e,i,s,n){return _e.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Jo()(this)}static registerData(t){Yo(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},s([Yo(ul)],t.UI.prototype,"__",void 0),s([jh()],t.UI.prototype,"zoomLayer",void 0),s([fo("")],t.UI.prototype,"id",void 0),s([fo("")],t.UI.prototype,"name",void 0),s([fo("")],t.UI.prototype,"className",void 0),s([Co("pass-through")],t.UI.prototype,"blendMode",void 0),s([Ao(1)],t.UI.prototype,"opacity",void 0),s([Do(!0)],t.UI.prototype,"visible",void 0),s([Co(!1)],t.UI.prototype,"locked",void 0),s([Oo(!1)],t.UI.prototype,"dim",void 0),s([Oo(!1)],t.UI.prototype,"dimskip",void 0),s([Fo(0)],t.UI.prototype,"zIndex",void 0),s([Wo(!1)],t.UI.prototype,"mask",void 0),s([zo(!1)],t.UI.prototype,"eraser",void 0),s([mo(0,!0)],t.UI.prototype,"x",void 0),s([mo(0,!0)],t.UI.prototype,"y",void 0),s([bo(100,!0)],t.UI.prototype,"width",void 0),s([bo(100,!0)],t.UI.prototype,"height",void 0),s([wo(1,!0)],t.UI.prototype,"scaleX",void 0),s([wo(1,!0)],t.UI.prototype,"scaleY",void 0),s([xo(0,!0)],t.UI.prototype,"rotation",void 0),s([xo(0,!0)],t.UI.prototype,"skewX",void 0),s([xo(0,!0)],t.UI.prototype,"skewY",void 0),s([mo(0,!0)],t.UI.prototype,"offsetX",void 0),s([mo(0,!0)],t.UI.prototype,"offsetY",void 0),s([yo(0,!0)],t.UI.prototype,"scrollX",void 0),s([yo(0,!0)],t.UI.prototype,"scrollY",void 0),s([vo()],t.UI.prototype,"origin",void 0),s([vo()],t.UI.prototype,"around",void 0),s([fo(!1)],t.UI.prototype,"lazy",void 0),s([Eo(1)],t.UI.prototype,"pixelRatio",void 0),s([Lo(0)],t.UI.prototype,"renderSpread",void 0),s([ko()],t.UI.prototype,"path",void 0),s([Bo()],t.UI.prototype,"windingRule",void 0),s([Bo(!0)],t.UI.prototype,"closed",void 0),s([bo(0)],t.UI.prototype,"padding",void 0),s([bo(!1)],t.UI.prototype,"lockRatio",void 0),s([bo()],t.UI.prototype,"widthRange",void 0),s([bo()],t.UI.prototype,"heightRange",void 0),s([fo(!1)],t.UI.prototype,"draggable",void 0),s([fo()],t.UI.prototype,"dragBounds",void 0),s([fo("auto")],t.UI.prototype,"dragBoundsType",void 0),s([fo(!1)],t.UI.prototype,"editable",void 0),s([Uo(!0)],t.UI.prototype,"hittable",void 0),s([Uo("path")],t.UI.prototype,"hitFill",void 0),s([Ro("path")],t.UI.prototype,"hitStroke",void 0),s([Uo(!1)],t.UI.prototype,"hitBox",void 0),s([Uo(!0)],t.UI.prototype,"hitChildren",void 0),s([Uo(!0)],t.UI.prototype,"hitSelf",void 0),s([Uo()],t.UI.prototype,"hitRadius",void 0),s([Ho("")],t.UI.prototype,"cursor",void 0),s([Co()],t.UI.prototype,"fill",void 0),s([Ro(void 0,!0)],t.UI.prototype,"stroke",void 0),s([Ro("inside")],t.UI.prototype,"strokeAlign",void 0),s([Ro(1,!0)],t.UI.prototype,"strokeWidth",void 0),s([Ro(!1)],t.UI.prototype,"strokeWidthFixed",void 0),s([Ro("none")],t.UI.prototype,"strokeCap",void 0),s([Ro("miter")],t.UI.prototype,"strokeJoin",void 0),s([Ro()],t.UI.prototype,"dashPattern",void 0),s([Ro(0)],t.UI.prototype,"dashOffset",void 0),s([Ro(10)],t.UI.prototype,"miterLimit",void 0),s([Bo(0)],t.UI.prototype,"cornerRadius",void 0),s([Bo()],t.UI.prototype,"cornerSmoothing",void 0),s([Vh()],t.UI.prototype,"shadow",void 0),s([Vh()],t.UI.prototype,"innerShadow",void 0),s([Vh()],t.UI.prototype,"blur",void 0),s([Vh()],t.UI.prototype,"backgroundBlur",void 0),s([Vh()],t.UI.prototype,"grayscale",void 0),s([Vh()],t.UI.prototype,"filter",void 0),s([Co()],t.UI.prototype,"placeholderColor",void 0),s([fo(100)],t.UI.prototype,"placeholderDelay",void 0),s([fo({})],t.UI.prototype,"data",void 0),s([jo(t.Leaf.prototype.reset)],t.UI.prototype,"reset",null),t.UI=Il=s([Zo(Cl),Zo(Al),Ko()],t.UI),t.Group=class extends t.UI{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(){}},s([Yo(pl)],t.Group.prototype,"__",void 0),s([bo(0)],t.Group.prototype,"width",void 0),s([bo(0)],t.Group.prototype,"height",void 0),t.Group=s([Zo(t.Branch),Jo()],t.Group);const Wl=oe.get("Leafer");t.Leafer=Fl=class extends t.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&io.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),Fl.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,m.assign(s,t));const n=this.canvas=ge.canvas(s);this.__controllers.push(this.renderer=ge.renderer(this,n,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,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ge.hitCanvasManager()),this.canvasManager=new we,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(n),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Pr.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(ea.RESTART):this.emitLeafer(ea.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(ea.STOP))}unlockLayout(t=!0){this.layouter.start(),t&&this.updateLayout()}lockLayout(t=!0){t&&this.updateLayout(),this.layouter.stop()}resize(t){const e=m.copyAttrs({},t,Ae);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=m.copyAttrs({},this.canvas,Ae);e.resize(t),this.updateLazyBounds(),this.__onResize(new Jr(t,i))}__onResize(t){this.emitEvent(t),m.copyAttrs(this.__,t,Ae),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&&(Ae.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(ea.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Ae.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=m.copyAttrs({},s,Ae);n[t]=i[t]=e,i.width&&i.height?s.stopAutoLayout():this.__checkAutoLayout(),this.__doResize(n)}__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(ea.BEFORE_READY),this.emitLeafer(ea.READY),this.emitLeafer(ea.AFTER_READY),Pr.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(ea.VIEW_READY),Pr.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:o}=this;const r="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,r.x+r.width)),i||(n=Math.max(1,r.y+r.height)),this.__doResize({width:s,height:n,pixelRatio:o})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Pr.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(ea.VIEW_COMPLETED),Pr.run(this.__viewCompletedWait),this.viewCompleted=!0)})}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender(()=>this.interaction.updateCursor())}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return ue.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 ea(t,this))}__listenEvents(){const t=le.start("FirstCreate "+this.innerName);this.once([[ea.START,()=>le.end(t)],[Qr.START,this.updateLazyBounds,this],[ta.START,this.__onCreated,this],[ta.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[$r.DATA,this.__onWatchData,this],[Qr.END,this.__onLayoutEnd,this],[ta.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Fl.list.remove(this);try{this.stop(),this.emitLeafer(ea.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){Wl.error(t)}}};t?e():setTimeout(e)}},t.Leafer.list=new xh,s([Yo(fl)],t.Leafer.prototype,"__",void 0),s([bo()],t.Leafer.prototype,"pixelRatio",void 0),s([fo("normal")],t.Leafer.prototype,"mode",void 0),t.Leafer=Fl=s([Jo()],t.Leafer),t.Rect=class extends t.UI{get __tag(){return"Rect"}},s([Yo(vl)],t.Rect.prototype,"__",void 0),t.Rect=s([Zo(Ml),Ko(),Jo()],t.Rect);const{add:zl,includes:Ul,scroll:Hl}=Vt,Yl=t.Rect.prototype,Nl=t.Group.prototype;t.Box=class extends t.Group{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.pathInputed){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:n,boxBounds:o}=s,{overflow:r}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=r&&r.includes("scroll"))&&(zl(a,o),Hl(a,i)),this.__updateRectRenderBounds(),t=!Ul(o,a),t&&"show"===r&&zl(n,a)}else this.__updateRectRenderBounds();m.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))}},s([Yo(_l)],t.Box.prototype,"__",void 0),s([bo(100)],t.Box.prototype,"width",void 0),s([bo(100)],t.Box.prototype,"height",void 0),s([fo(!1)],t.Box.prototype,"resizeChildren",void 0),s([Lo("show")],t.Box.prototype,"overflow",void 0),s([jo(Yl.__updateStrokeSpread)],t.Box.prototype,"__updateStrokeSpread",null),s([jo(Yl.__updateRenderSpread)],t.Box.prototype,"__updateRectRenderSpread",null),s([jo(Yl.__updateBoxBounds)],t.Box.prototype,"__updateRectBoxBounds",null),s([jo(Yl.__updateStrokeBounds)],t.Box.prototype,"__updateStrokeBounds",null),s([jo(Yl.__updateRenderBounds)],t.Box.prototype,"__updateRectRenderBounds",null),s([jo(Yl.__updateChange)],t.Box.prototype,"__updateRectChange",null),s([jo(Yl.__render)],t.Box.prototype,"__renderRect",null),s([jo(Nl.__render)],t.Box.prototype,"__renderGroup",null),t.Box=s([Ko(),Jo()],t.Box),t.Frame=class extends t.Box{get __tag(){return"Frame"}get isFrame(){return!0}},s([Yo(ml)],t.Frame.prototype,"__",void 0),s([Co("#FFFFFF")],t.Frame.prototype,"fill",void 0),s([Lo("hide")],t.Frame.prototype,"overflow",void 0),t.Frame=s([Jo()],t.Frame);const{moveTo:Xl,closePath:Vl,ellipse:Gl}=Ts;t.Ellipse=class extends t.UI{get __tag(){return"Ellipse"}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:n}=this.__,o=t/2,r=e/2,a=this.__.path=[];let h;i?s||n?(i<1?Gl(a,o,r,o*i,r*i,0,s,n,!1):h=!0,Gl(a,o,r,o,r,0,n,s,!0)):(i<1&&(Gl(a,o,r,o*i,r*i),Xl(a,t,r)),Gl(a,o,r,o,r,0,360,0,!0)):s||n?(Xl(a,o,r),Gl(a,o,r,o,r,0,s,n,!1)):Gl(a,o,r,o,r),h||Vl(a),ie.ellipseToCurve&&(this.__.path=this.getPath(!0))}},s([Yo(wl)],t.Ellipse.prototype,"__",void 0),s([Bo(0)],t.Ellipse.prototype,"innerRadius",void 0),s([Bo(0)],t.Ellipse.prototype,"startAngle",void 0),s([Bo(0)],t.Ellipse.prototype,"endAngle",void 0),t.Ellipse=s([Jo()],t.Ellipse);const{sin:jl,cos:Kl,PI:ql}=Math,{moveTo:Zl,lineTo:Jl,closePath:$l,drawPoints:Ql}=Ts;t.Polygon=class extends t.UI{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)Ql(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,o=i/2,r=s/2;Zl(e,o,0);for(let t=1;t<n;t++)Jl(e,o+o*jl(2*t*ql/n),r-r*Kl(2*t*ql/n));$l(e)}}},s([Yo(xl)],t.Polygon.prototype,"__",void 0),s([Bo(3)],t.Polygon.prototype,"sides",void 0),s([Bo()],t.Polygon.prototype,"points",void 0),s([Bo(0)],t.Polygon.prototype,"curve",void 0),t.Polygon=s([Ko(),Jo()],t.Polygon);const{sin:td,cos:ed,PI:id}=Math,{moveTo:sd,lineTo:nd,closePath:od}=Ts;t.Star=class extends t.UI{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,o=e/2,r=this.__.path=[];sd(r,n,0);for(let t=1;t<2*i;t++)nd(r,n+(t%2==0?n:n*s)*td(t*id/i),o-(t%2==0?o:o*s)*ed(t*id/i));od(r)}},s([Yo(bl)],t.Star.prototype,"__",void 0),s([Bo(5)],t.Star.prototype,"corners",void 0),s([Bo(.382)],t.Star.prototype,"innerRadius",void 0),t.Star=s([Jo()],t.Star);const{moveTo:rd,lineTo:ad,drawPoints:hd}=Ts,{rotate:ld,getAngle:dd,getDistance:cd,defaultPoint:ud}=dt;t.Line=class extends t.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&ld(i,e),i}set toPoint(t){this.width=cd(ud,t),this.rotation=dd(ud,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?hd(e,t.points,t.curve,t.closed):(rd(e,0,0),ad(e,this.width,0))}},s([Yo(yl)],t.Line.prototype,"__",void 0),s([To("center")],t.Line.prototype,"strokeAlign",void 0),s([bo(0)],t.Line.prototype,"height",void 0),s([Bo()],t.Line.prototype,"points",void 0),s([Bo(0)],t.Line.prototype,"curve",void 0),s([Bo(!1)],t.Line.prototype,"closed",void 0),t.Line=s([Jo()],t.Line),t.Image=class extends t.Rect{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return g(t)&&t[0].image}},s([Yo(Tl)],t.Image.prototype,"__",void 0),s([bo("")],t.Image.prototype,"url",void 0),t.Image=s([Jo()],t.Image);const gd=t.Image;t.Canvas=class extends t.Rect{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 ho({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Xr(Xr.LOADED,{image:t}))})}draw(t,e,i,s){const n=new yt(t.worldTransform).invert(),o=new yt;e&&o.translate(e.x,e.y),i&&(d(i)?o.scale(i):o.scale(i.x,i.y)),s&&o.rotate(s),n.multiplyParent(o),t.__render(this.canvas,{matrix:n.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:n}=this.canvas;t.drawImage(n,0,0,n.width,n.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}},s([Yo(Pl)],t.Canvas.prototype,"__",void 0),s([Gh(100)],t.Canvas.prototype,"width",void 0),s([Gh(100)],t.Canvas.prototype,"height",void 0),s([Gh(1)],t.Canvas.prototype,"pixelRatio",void 0),s([Gh(!0)],t.Canvas.prototype,"smooth",void 0),s([fo(!1)],t.Canvas.prototype,"safeResize",void 0),s([Gh()],t.Canvas.prototype,"contextSettings",void 0),t.Canvas=s([Jo()],t.Canvas);const{copyAndSpread:pd,includes:_d,spread:fd,setList:md}=Vt,{stintSet:yd}=m;t.Text=class extends t.UI{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:n,fontWeight:o,italic:r,textCase:a,textOverflow:h,padding:l,width:d,height:c}=t;t.__lineHeight=Zh.number(e,n),t.__letterSpacing=Zh.number(i,n),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${r?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==o?o+" ":""}${n||12}px ${s||"caption"}`,yd(t,"__padding",l&&F.fourNumber(l)),yd(t,"__clipText","show"!==h&&!t.__autoSize),yd(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=Kh.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:n,__autoWidth:o,__autoHeight:r}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&fd(a,i/2),o||r){if(h.x=o?a.x:0,h.y=r?a.y:0,h.width=o?a.width:t.width,h.height=r?a.height:t.height,n){const[e,i,s,n]=t.__padding;o&&(h.x-=n,h.width+=i+n),r&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),m.stintSet(this,"isOverflow",!_d(h,a)),this.isOverflow?(md(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;pd(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()}},s([Yo(Bl)],t.Text.prototype,"__",void 0),s([bo(0)],t.Text.prototype,"width",void 0),s([bo(0)],t.Text.prototype,"height",void 0),s([Co()],t.Text.prototype,"boxStyle",void 0),s([fo(!1)],t.Text.prototype,"resizeFontSize",void 0),s([Co("#000000")],t.Text.prototype,"fill",void 0),s([To("outside")],t.Text.prototype,"strokeAlign",void 0),s([Uo("all")],t.Text.prototype,"hitFill",void 0),s([bo("")],t.Text.prototype,"text",void 0),s([bo("")],t.Text.prototype,"placeholder",void 0),s([bo("caption")],t.Text.prototype,"fontFamily",void 0),s([bo(12)],t.Text.prototype,"fontSize",void 0),s([bo("normal")],t.Text.prototype,"fontWeight",void 0),s([bo(!1)],t.Text.prototype,"italic",void 0),s([bo("none")],t.Text.prototype,"textCase",void 0),s([bo("none")],t.Text.prototype,"textDecoration",void 0),s([bo(0)],t.Text.prototype,"letterSpacing",void 0),s([bo({type:"percent",value:1.5})],t.Text.prototype,"lineHeight",void 0),s([bo(0)],t.Text.prototype,"paraIndent",void 0),s([bo(0)],t.Text.prototype,"paraSpacing",void 0),s([bo("x")],t.Text.prototype,"writingMode",void 0),s([bo("left")],t.Text.prototype,"textAlign",void 0),s([bo("top")],t.Text.prototype,"verticalAlign",void 0),s([bo(!0)],t.Text.prototype,"autoSizeAlign",void 0),s([bo("normal")],t.Text.prototype,"textWrap",void 0),s([bo("show")],t.Text.prototype,"textOverflow",void 0),s([Co(!1)],t.Text.prototype,"textEditing",void 0),t.Text=s([Jo()],t.Text),t.Path=class extends t.UI{get __tag(){return"Path"}},s([Yo(El)],t.Path.prototype,"__",void 0),s([To("center")],t.Path.prototype,"strokeAlign",void 0),t.Path=s([Jo()],t.Path),t.Pen=class extends t.Group{get __tag(){return"Pen"}setStyle(e){const i=this.pathElement=new t.Path(e);return this.pathStyle=e,this.__path=i.path||(i.path=[]),this.add(i),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,o){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,n){return this}ellipse(t,e,i,s,n,o,r,a){return this}arc(t,e,i,s,n,o){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,o,r,a){return this}drawArc(t,e,i,s,n,o){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},s([Yo(Sl)],t.Pen.prototype,"__",void 0),s([(t,e)=>{lo(t,e,{get(){return this.__path}})}],t.Pen.prototype,"path",void 0),t.Pen=s([Zo(Xs,["set","path","paint"]),Jo()],t.Pen),t.App=class extends t.Leafer{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:n}=t;e&&(this.ground=this.addLeafer(e)),(i||n)&&(this.tree=this.addLeafer(i||{type:t.type||"design"})),(s||n)&&(this.sky=this.addLeafer(s)),n&&ge.editor(n,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(e){const i=new t.Leafer(e);return this.add(i),i}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),r(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))}__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&&m.assign(e,t),this.autoLayout&&m.copyAttrs(e,this,Ae),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Qr.END,this.__onReady,this],[ta.START,this.__onCreated,this],[ta.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(ta.END,this.__onChildRenderEnd,this))}},t.App=s([Jo()],t.App);const vd={},wd={isHoldSpaceKey:()=>wd.isHold("Space"),isHold:t=>vd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){vd[t]||(vd[t]=!0)},setUpCode(t){vd[t]=!1}},xd={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class bd extends zr{get spaceKey(){return wd.isHoldSpaceKey()}get left(){return xd.left(this)}get right(){return xd.right(this)}get middle(){return xd.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return wd.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){ye.changeName(t,e)}}const{min:Ed,max:Sd,abs:kd}=Math,{float:Bd,sign:Td}=F,{minX:Pd,maxX:Rd,minY:Ld,maxY:Cd}=Vt,Od=new qt,Ad=new qt,Dd={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Md.getValidMove(t.__localBoxBounds,Md.getDragBounds(t),s,e,!0),Md.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:o}=t;n&&Md.getValidScaleOf(t.__localBoxBounds,Md.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&&t[s]>e[s],getValidMove(t,e,i,s,n){const o=t.x+s.x,r=t.y+s.y,a=o+t.width,h=r+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),Md.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),Md.isInnerMode(t,e,i,"height")?r>e.y?s.y+=e.y-r:h<d&&(s.y+=d-h):r<e.y?s.y+=e.y-r:h>d&&(s.y+=d-h),s.x=Bd(s.x),s.y=Bd(s.y),s},getValidScaleOf(t,e,i,s,n,o,r){r||(n=Object.assign({},n)),Ad.set(e),Od.set(t).scaleOf(s,n.x,n.y);const a=(s.x-t.x)/t.width,h=1-a,d=(s.y-t.y)/t.height,c=1-d;let u,g,p,_,f=1,m=1;return Md.isInnerMode(t,e,i,"width")?(n.x<0&&Od.scaleOf(s,f=1/n.x,1),p=Bd(Od.minX-Ad.minX),_=Bd(Ad.maxX-Od.maxX),u=a&&p>0?1+p/(a*Od.width):1,g=h&&_>0?1+_/(h*Od.width):1,f*=Sd(u,g)):(n.x<0&&((Bd(Pd(t)-Pd(e))<=0||Bd(Rd(e)-Rd(t))<=0)&&Od.scaleOf(s,f=1/n.x,1),Od.unsign()),p=Bd(Ad.minX-Od.minX),_=Bd(Od.maxX-Ad.maxX),u=a&&p>0?1-p/(a*Od.width):1,g=h&&_>0?1-_/(h*Od.width):1,f*=Ed(u,g)),Md.isInnerMode(t,e,i,"height")?(n.y<0&&Od.scaleOf(s,1,m=1/n.y),p=Bd(Od.minY-Ad.minY),_=Bd(Ad.maxY-Od.maxY),u=d&&p>0?1+p/(d*Od.height):1,g=c&&_>0?1+_/(c*Od.height):1,m*=Sd(u,g),o&&(u=Sd(kd(f),kd(m)),f=Td(f)*u,m=Td(m)*u)):(n.y<0&&((Bd(Ld(t)-Ld(e))<=0||Bd(Cd(e)-Cd(t))<=0)&&Od.scaleOf(s,1,m=1/n.y),Od.unsign()),p=Bd(Ad.minY-Od.minY),_=Bd(Od.maxY-Ad.maxY),u=d&&p>0?1-p/(d*Od.height):1,g=c&&_>0?1-_/(c*Od.height):1,m*=Ed(u,g)),n.x*=l(f)?f:1,n.y*=l(m)?m:1,n}},Md=Dd;t.PointerEvent=class extends bd{},t.PointerEvent.POINTER="pointer",t.PointerEvent.BEFORE_DOWN="pointer.before_down",t.PointerEvent.BEFORE_MOVE="pointer.before_move",t.PointerEvent.BEFORE_UP="pointer.before_up",t.PointerEvent.DOWN="pointer.down",t.PointerEvent.MOVE="pointer.move",t.PointerEvent.UP="pointer.up",t.PointerEvent.OVER="pointer.over",t.PointerEvent.OUT="pointer.out",t.PointerEvent.ENTER="pointer.enter",t.PointerEvent.LEAVE="pointer.leave",t.PointerEvent.TAP="tap",t.PointerEvent.DOUBLE_TAP="double_tap",t.PointerEvent.CLICK="click",t.PointerEvent.DOUBLE_CLICK="double_click",t.PointerEvent.LONG_PRESS="long_press",t.PointerEvent.LONG_TAP="long_tap",t.PointerEvent.MENU="pointer.menu",t.PointerEvent.MENU_TAP="pointer.menu_tap",t.PointerEvent=s([$o()],t.PointerEvent);const Id=t.PointerEvent,Fd={};t.DragEvent=class extends t.PointerEvent{static setList(t){this.list=t instanceof xh?t:new xh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return dt.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),Dd.axisMove(t,n),n}static limitMove(t,e){Dd.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Fd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Fd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Fd,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 Vt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Vt.unsign(i),i}assignMove(t){Fd.x=t?this.totalX:this.moveX,Fd.y=t?this.totalY:this.moveY}},t.DragEvent.BEFORE_DRAG="drag.before_drag",t.DragEvent.START="drag.start",t.DragEvent.DRAG="drag",t.DragEvent.END="drag.end",t.DragEvent.OVER="drag.over",t.DragEvent.OUT="drag.out",t.DragEvent.ENTER="drag.enter",t.DragEvent.LEAVE="drag.leave",t.DragEvent=s([$o()],t.DragEvent);const Wd=t.DragEvent;t.DropEvent=class extends t.PointerEvent{static setList(e){t.DragEvent.setList(e)}static setData(e){t.DragEvent.setData(e)}},t.DropEvent.DROP="drop",t.DropEvent=s([$o()],t.DropEvent),t.MoveEvent=class extends t.DragEvent{},t.MoveEvent.BEFORE_MOVE="move.before_move",t.MoveEvent.START="move.start",t.MoveEvent.MOVE="move",t.MoveEvent.DRAG_ANIMATE="move.drag_animate",t.MoveEvent.END="move.end",t.MoveEvent.PULL_DOWN="move.pull_down",t.MoveEvent.REACH_BOTTOM="move.reach_bottom",t.MoveEvent=s([$o()],t.MoveEvent),t.TouchEvent=class extends bd{},t.TouchEvent=s([$o()],t.TouchEvent);const zd=t.TouchEvent;t.RotateEvent=class extends t.PointerEvent{},t.RotateEvent.BEFORE_ROTATE="rotate.before_rotate",t.RotateEvent.START="rotate.start",t.RotateEvent.ROTATE="rotate",t.RotateEvent.END="rotate.end",t.RotateEvent=s([$o()],t.RotateEvent),t.SwipeEvent=class extends t.DragEvent{},t.SwipeEvent.SWIPE="swipe",t.SwipeEvent.LEFT="swipe.left",t.SwipeEvent.RIGHT="swipe.right",t.SwipeEvent.UP="swipe.up",t.SwipeEvent.DOWN="swipe.down",t.SwipeEvent=s([$o()],t.SwipeEvent),t.ZoomEvent=class extends t.PointerEvent{},t.ZoomEvent.BEFORE_ZOOM="zoom.before_zoom",t.ZoomEvent.START="zoom.start",t.ZoomEvent.ZOOM="zoom",t.ZoomEvent.END="zoom.end",t.ZoomEvent=s([$o()],t.ZoomEvent),t.KeyEvent=class extends bd{},t.KeyEvent.BEFORE_DOWN="key.before_down",t.KeyEvent.BEFORE_UP="key.before_up",t.KeyEvent.DOWN="key.down",t.KeyEvent.HOLD="key.hold",t.KeyEvent.UP="key.up",t.KeyEvent=s([$o()],t.KeyEvent);const Ud={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:e=>e<-45&&e>-135?t.SwipeEvent.UP:e>45&&e<135?t.SwipeEvent.DOWN:e<=45&&e>=-45?t.SwipeEvent.RIGHT:t.SwipeEvent.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:Hd.getSwipeDirection(dt.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:r(t.buttons)?1:0===t.buttons?e:t.buttons,origin:t}},pathHasEventType(t,e){const{list:i}=t;for(let t=0,s=i.length;t<s;t++)if(i[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const i=new xh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:e=>e&&e.list.some(e=>dr.draggable(e)||!e.isLeafer&&e.hasEvent(t.DragEvent.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Hd=Ud,Yd=new xh,{getDragEventData:Nd,getDropEventData:Xd,getSwipeEventData:Vd}=Ud;class Gd{constructor(t){this.dragDataList=[],this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Nd(t,t,t),this.canAnimate=this.canDragOut=!0}getList(e,i){const{proxy:s}=this.interaction.selector,n=s&&s.list.length,o=t.DragEvent.list||this.draggableList||Yd;return this.dragging&&(n?e?Yd:new xh(i?[...s.list,...s.dragHoverExclude]:s.list):o)}checkDrag(e,i){const{interaction:s}=this;if(this.moving&&e.buttons<1)return this.canAnimate=!1,void s.pointerCancel();!this.moving&&i&&(this.moving=s.canMove(this.downData)||s.isHoldRightKey||s.isMobileDragEmpty)&&(this.dragData.moveType="drag",s.emit(t.MoveEvent.START,this.dragData)),this.moving||this.dragStart(e,i),this.drag(e)}dragStart(e,i){this.dragging||(this.dragging=i&&xd.left(e),this.dragging&&(this.interaction.emit(t.DragEvent.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],dr.draggable(e)){this.draggableList=new xh(e);break}}drag(e){const{interaction:i,dragData:s,downData:n}=this,{path:o,throughPath:r}=n;this.dragData=Nd(n,s,e),r&&(this.dragData.throughPath=r),this.dragData.path=o,this.dragDataList.push(this.dragData),this.moving?(e.moving=!0,this.dragData.moveType="drag",i.emit(t.MoveEvent.BEFORE_MOVE,this.dragData),i.emit(t.MoveEvent.MOVE,this.dragData)):this.dragging&&(e.dragging=!0,this.dragReal(),i.emit(t.DragEvent.BEFORE_DRAG,this.dragData),i.emit(t.DragEvent.DRAG,this.dragData))}dragReal(e){const{interaction:i}=this,{running:s}=i,n=this.realDraggableList;if(n.length&&s){const{totalX:s,totalY:o}=this.dragData,{dragLimitAnimate:r}=i.p,a=!r||!!e;n.forEach(i=>{if(i.draggable){const n=h(i.draggable),l=t.DragEvent.getValidMove(i,this.dragStartPoints[i.innerId],{x:s,y:o},a||n);r&&!n&&e?dr.animateMove(i,l,d(r)?r:.3):i.move(l)}})}}dragOverOrOut(e){const{interaction:i}=this,{dragOverPath:s}=this,{path:n}=e;this.dragOverPath=n,s?n.indexAt(0)!==s.indexAt(0)&&(i.emit(t.DragEvent.OUT,e,s),i.emit(t.DragEvent.OVER,e,n)):i.emit(t.DragEvent.OVER,e,n)}dragEnterOrLeave(e){const{interaction:i}=this,{dragEnterPath:s}=this,{path:n}=e;i.emit(t.DragEvent.LEAVE,e,s,n),i.emit(t.DragEvent.ENTER,e,n,s),this.dragEnterPath=n}dragEnd(t){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t)||this.dragEndReal(t))}dragEndReal(e){const{interaction:i,downData:s,dragData:n}=this;e||(e=n);const{path:o,throughPath:r}=s,a=Nd(s,e,e);if(r&&(a.throughPath=r),a.path=o,this.moving&&(this.moving=!1,a.moveType="drag",i.emit(t.MoveEvent.END,a)),this.dragging){const o=this.getList();this.dragging=!1,i.p.dragLimitAnimate&&this.dragReal(!0),i.emit(t.DragEvent.END,a),this.swipe(e,s,n,a),this.drop(e,o,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(dt.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Vd(e,i,s);this.interaction.emit(t.type,t)}}drop(e,i,s){const n=Xd(e,i,t.DragEvent.data);n.path=s,this.interaction.emit(t.DropEvent.DROP,n),this.interaction.emit(t.DragEvent.LEAVE,e,s)}dragReset(){t.DragEvent.list=t.DragEvent.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()}}const jd=oe.get("emit");const Kd=["move","zoom","rotate","key"];function qd(t,e,i,s,n){if(Kd.some(t=>e.startsWith(t))&&t.__.hitChildren&&!Jd(t,n)){let o;for(let r=0,a=t.children.length;r<a;r++)o=t.children[r],!i.path.has(o)&&o.__.hittable&&Zd(o,e,i,s,n)}}function Zd(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!Jd(t,n)&&(nl.updateEventStyle&&!s&&nl.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=ye.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function Jd(t,e){return e&&e.has(t)}const $d={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:Qd,pathCanDrag:tc,pathHasOutside:ec}=Ud;class ic{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&&xd.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&xd.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&wd.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=m.clone($d),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new xh(t),this.createTransformer(),this.dragger=new Gd(this),s&&(this.config=m.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(e,i){e||(e=this.hoverData),e&&(xd.defaultLeft(e),this.updateDownData(e),this.checkPath(e,i),this.downTime=Date.now(),this.emit(t.PointerEvent.BEFORE_DOWN,e),e.path.needUpdate&&this.updateDownData(e),this.emit(t.PointerEvent.DOWN,e),xd.left(e)&&(this.tapWait(),this.longPressWait(e)),this.waitRightTap=xd.right(e),this.dragger.setDragData(e),this.isHoldRightKey||this.updateCursor(e))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&xd.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(e){if(this.emit(t.PointerEvent.BEFORE_MOVE,e,this.defaultPath),this.downData){const t=dt.getDistance(this.downData,e)>this.p.dragDistance;t&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(e,t)}this.dragger.moving||(this.updateHoverData(e),this.checkPath(e),this.emit(t.PointerEvent.MOVE,e),this.pointerHover(e),this.dragging&&(this.dragger.dragOverOrOut(e),this.dragger.dragEnterOrLeave(e))),this.updateCursor(this.downData||e)}pointerUp(e){const{downData:i}=this;if(e||(e=i),!i)return;xd.defaultLeft(e),e.multiTouch=i.multiTouch,this.findPath(e);const s=Object.assign(Object.assign({},e),{path:e.path.clone()});e.path.addList(i.path.list),this.checkPath(e),this.downData=null,this.emit(t.PointerEvent.BEFORE_UP,e),this.emit(t.PointerEvent.UP,e),this.touchLeave(e),e.isCancel||(this.tap(e),this.menuTap(e)),this.dragger.dragEnd(e),this.updateCursor(s)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(e){this.findPath(e),this.emit(t.PointerEvent.MENU,e),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(e)}menuTap(e){this.waitRightTap&&this.waitMenuTap&&(this.emit(t.PointerEvent.MENU_TAP,e),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_DOWN,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]||(this.downKeyMap[i]=!0,wd.setDownCode(i),this.emit(t.KeyEvent.HOLD,e,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(t.KeyEvent.DOWN,e,this.defaultPath)}keyUp(e){if(!this.config.keyEvent)return;this.emit(t.KeyEvent.BEFORE_UP,e,this.defaultPath);const{code:i}=e;this.downKeyMap[i]=!1,wd.setUpCode(i),this.emit(t.KeyEvent.UP,e,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new xh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(e){const{path:i}=e,{overPath:s}=this;this.overPath=i,s?i.indexAt(0)!==s.indexAt(0)&&(this.emit(t.PointerEvent.OUT,e,s),this.emit(t.PointerEvent.OVER,e,i)):this.emit(t.PointerEvent.OVER,e,i)}pointerEnterOrLeave(e){let{path:i}=e;this.downData&&!this.moveMode&&(i=i.clone(),this.downData.path.forEach(t=>i.add(t)));const{enterPath:s}=this;this.enterPath=i,this.emit(t.PointerEvent.LEAVE,e,s,i),this.emit(t.PointerEvent.ENTER,e,i,s)}touchLeave(e){"touch"===e.pointerType&&this.enterPath&&(this.emit(t.PointerEvent.LEAVE,e),this.dragger.dragging&&this.emit(t.DropEvent.LEAVE,e))}tap(e){const{pointer:i}=this.config,s=this.longTap(e);if(!i.tapMore&&s)return;if(!this.waitTap)return;i.tapMore&&this.emitTap(e);const n=Date.now()-this.downTime,o=[t.PointerEvent.DOUBLE_TAP,t.PointerEvent.DOUBLE_CLICK].some(t=>Qd(e.path,t));n<i.tapTime+50&&o?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(e)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{i.tapMore||(this.tapWaitCancel(),this.emitTap(e))},i.tapTime))):i.tapMore||(this.tapWaitCancel(),this.emitTap(e))}findPath(t,e){const{hitRadius:i,through:s}=this.p,{bottomList:n,target:o}=this;ie.backgrounder||t.origin||o&&o.updateLayout();const r=this.selector.getByPoint(t,i,Object.assign({bottomList:n,name:t.type},e||{through:s}));return r.throughPath&&(t.throughPath=r.throughPath),t.path=r.path,r.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&&!ec(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!tc(t.path))&&!ec(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()}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(e){e||(e=this.hoverData),e&&(this.findPath(e,{exclude:this.dragger.getList(!1,!0),name:t.PointerEvent.MOVE}),this.hoverData=e)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:n}=this.canvas;return s.x*=n.width/i.width,s.y*=n.height/i.height,this.p.snap&&dt.round(s),s}emitTap(e){this.emit(t.PointerEvent.TAP,e),this.emit(t.PointerEvent.CLICK,e)}emitDoubleTap(e){this.emit(t.PointerEvent.DOUBLE_TAP,e),this.emit(t.PointerEvent.DOUBLE_CLICK,e)}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(e){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(t.PointerEvent.LONG_PRESS,e)},this.p.longPressTime)}longTap(e){let i;return this.longPressed&&(this.emit(t.PointerEvent.LONG_TAP,e),(Qd(e.path,t.PointerEvent.LONG_TAP)||Qd(e.path,t.PointerEvent.LONG_PRESS))&&(i=!0)),this.longPressWaitCancel(),i}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(-(d(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Jr.RESIZE,this.__onResize,this)],t.once(ea.READY,()=>this.__onResize())}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,i,s){this.running&&function(t,e,i,s){if(!i&&!e.path)return;let n;e.type=t,i?e=Object.assign(Object.assign({},e),{path:i}):i=e.path,e.target=i.indexAt(0);try{for(let o=i.length-1;o>-1;o--){if(n=i.list[o],Zd(n,t,e,!0,s))return;n.isApp&&qd(n,t,e,!0,s)}for(let o=0,r=i.length;o<r;o++)if(n=i.list[o],n.isApp&&qd(n,t,e,!1,s),Zd(n,t,e,!1,s))return}catch(t){jd.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class sc{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}sc.custom={};class nc extends we{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new xh,this.pixelList=new xh}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()}}ie.getSelector=function(t){return t.leafer?t.leafer.selector:ie.selector||(ie.selector=ge.selector())};const{toInnerRadiusPointOf:oc,copyRadiusPoint:rc}=dt,{hitRadiusPoint:ac,hitPoint:hc}=Vt,lc={},dc={},cc=t.Leaf.prototype;cc.hit=function(t,e=0){this.updateLayout(),rc(dc,t,e);const i=this.__world;return!!(e?ac(i,dc):hc(i,dc))&&(this.isBranch?ie.getSelector(this).hitPoint(Object.assign({},dc),e,{target:this}):this.__hitWorld(dc))},cc.__hitWorld=function(t,e){const i=this.__;if(!i.hitSelf)return!1;const s=this.__world,n=this.__layout,o=s.width<10&&s.height<10;if(i.hitRadius&&(rc(lc,t,i.hitRadius),t=lc),oc(t,s,lc),i.hitBox||o){if(Vt.hitRadiusPoint(n.boxBounds,lc))return!0;if(o)return!1}return!n.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),n.boundsChanged||(n.hitCanvasChanged=!1)),this.__hit(lc,e)},cc.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},cc.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},cc.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},cc.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const uc=new yt,gc=t.UI.prototype;gc.__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,n=i||s;this.__hitCanvas||(this.__hitCanvas=n?t.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):t.getPathType(this));const o=this.__hitCanvas;if(n){const{renderBounds:t}=this.__layout,n=ie.image.hitCanvasSize,r=o.hitScale=Zt.set(0,0,n,n).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=Zt.set(t).scale(r);o.resize({width:l,height:d,pixelRatio:1}),o.clear(),no.patternLocked=!0,this.__renderShape(o,{matrix:uc.setWith(this.__world).scaleWith(1/r).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)},gc.__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,n=(i.fill||i.__isCanvas)&&("path"===s||"pixel"===s&&!(i.__isAlphaPixelFill||i.__isCanvas))||"all"===s||e;if(n&&this.__hitFill(t))return!0;const{hitStroke:o,__maxStrokeWidth:r}=i,a=i.stroke&&("path"===o||"pixel"===o&&!i.__isAlphaPixelStroke)||"all"===o;if(!n&&!a)return!1;const h=2*t.radiusX;let l=h;if(a)switch(i.strokeAlign){case"inside":if(l+=2*r,!n&&this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h;break;case"center":l+=r;break;case"outside":if(l+=2*r,!n){if(!this.__hitFill(t)&&this.__hitStroke(t,l))return!0;l=h}}return!!l&&this.__hitStroke(t,l)};const pc=t.UI.prototype,_c=t.Rect.prototype,fc=t.Box.prototype;_c.__updateHitCanvas=fc.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?pc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},_c.__hitFill=fc.__hitFill=function(t){return this.__hitCanvas?pc.__hitFill.call(this,t):Vt.hitRadiusPoint(this.__layout.boxBounds,t)},t.Text.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:n,__textDrawData:o}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):o.rows.forEach(n=>t.rect(n.x,n.y-s,n.width,e<i?i:e))},t.Group.prototype.pick=function(t,e){return e||(e=o),this.updateLayout(),ie.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};const mc=De.prototype;function yc(t,e,i){t.__.__font?$h.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function vc(t,e,i,s,n){const o=i.__;p(t)?$h.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),s.stroke()),o.__useArrow&&$h.strokeArrow(t,i,s,n)}function wc(t,e,i,s,n){const o=i.__;p(t)?$h.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,o.__strokeWidth*e,o),$h.drawTextStroke(i,s,n))}function xc(t,e,i,s,n){const o=s.getSameCanvas(!0,!0);o.font=i.__.__font,wc(t,2,i,o,n),o.blendMode="outside"===e?"destination-out":"destination-in",$h.fillText(i,o,n),o.blendMode="normal",dr.copyCanvasByWorld(i,s,o),o.recycle(i.__nowWorld)}mc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},mc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},mc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:o,radiusY:r}=t;e&&(s-=e.x,n-=e.y),Zt.set(s-o,n-r,2*o,2*r).scale(i).ceil();const{data:a}=this.context.getImageData(Zt.x,Zt.y,Zt.width||1,Zt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:bc,copyAndSpread:Ec,toOuterOf:Sc,getOuterOf:kc,getByMove:Bc,move:Tc,getIntersectData:Pc}=Vt,Rc={};let Lc;const{stintSet:Cc}=m,{hasTransparent:Oc}=qh;function Ac(t,e,i){if(!p(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout,{type:o}=e;switch(o){case"image":case"film":case"video":if(!e.url)return;s=Qh.image(i,t,e,n,!Lc||!Lc[e.url]),"image"!==o&&Qh[o](s);break;case"linear":s=tl.linearGradient(e,n);break;case"radial":s=tl.radialGradient(e,n);break;case"angular":s=tl.conicGradient(e,n);break;case"solid":const{color:a,opacity:h}=e;s={type:o,style:qh.string(a,h)};break;default:r(e.r)||(s={type:"solid",style:qh.string(e)})}if(s&&(s.originPaint=e,h(s.style)&&Oc(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const Dc={compute:function(t,e){const i=e.__,s=[];let n,o,r,a=i.__input[t];g(a)||(a=[a]),Lc=Qh.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)(i=Ac(t,a[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),o=!0),"fill"===t?(Cc(i,"__isAlphaPixelFill",n),Cc(i,"__isTransparentFill",o)):(Cc(i,"__isAlphaPixelStroke",n),Cc(i,"__isTransparentStroke",o),Cc(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,yc(e,i,s)},fills:function(t,e,i,s){let n,o,r;for(let a=0,h=t.length;a<h;a++){if(n=t[a],o=n.originPaint,n.image){if(r?r++:r=1,Qh.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||o.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),o.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===o.scaleFixed||"zoom-in"===o.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}o.blendMode&&(i.blendMode=o.blendMode),yc(e,i,s),i.restore()}else o.blendMode?(i.saveBlendMode(o.blendMode),yc(e,i,s),i.restoreBlendMode()):yc(e,i,s)}},fillPathOrText:yc,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:o}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(o){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>o.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)$h.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":vc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),vc(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)vc(t,2,e,i,s);else{const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),vc(t,2,e,r,s),r.clipUI(n),r.clearWorld(o),dr.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){$h.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":wc(t,1,e,i,s);break;case"inside":xc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?wc(t,2,e,i,s):xc(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:o,decorationY:r}=n;for(let t=0,i=o.length;t<i;t++)s=o[t],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(r){const{decorationHeight:t}=n;o.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,o){let r;const a=s.__,{__hasMultiStrokeStyle:h}=a;h||n.setStroke(void 0,a.__strokeWidth*e,a);for(let l=0,d=t.length;l<d;l++)if(r=t[l],(!r.image||!Qh.checkImage(r,!1,s,n,o))&&r.style){if(h){const{strokeStyle:t}=r;t?n.setStroke(r.style,a.__getRealStrokeWidth(t)*e,a,t):n.setStroke(r.style,a.__strokeWidth*e,a)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?$h.drawTextStroke(s,n,o):n.stroke(),n.restoreBlendMode()):i?$h.drawTextStroke(s,n,o):n.stroke()}},shape:function(t,e,i){const s=e.getSameCanvas(),n=e.bounds,o=t.__nowWorld,r=t.__layout,a=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let h,l,d,c,u,g;Sc(r.strokeSpread?(Ec(Rc,r.boxBounds,r.strokeSpread),Rc):r.boxBounds,o,a);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(a))g=s,h=u=a,l=o;else{let s;if(ie.fullImageShadow)s=a;else{const t=r.renderShapeSpread?bc(n,T.swapAndScale(r.renderShapeSpread,p,_)):n;s=Pc(t,a)}c=n.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(g=e.getSameCanvas(),t.__renderShape(g,i),p*=f,_*=m),u=kc(a,c),h=Bc(u,-c.e,-c.f),l=kc(o,c),Tc(l,-c.e,-c.f);const y=i.matrix;y?(d=new yt(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:g,shapeBounds:u,scaleX:p,scaleY:_}}};let Mc,Ic=new qt;const{isSame:Fc}=Vt;function Wc(t,e,i,s,n,o){const r=t.__;if("fill"===e&&!r.__naturalWidth&&(r.__naturalWidth=s.width/r.pixelRatio,r.__naturalHeight=s.height/r.pixelRatio,r.__autoSide))return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",r.width),t.setProxyAttr("height",r.height)),!1;if(!n.data){Qh.createData(n,s,i,o);const{transform:t}=n.data,{opacity:e,blendMode:a}=i,h=t&&!t.onlyScale||r.path||r.cornerRadius;(h||e&&e<1||a)&&(n.complex=!h||2)}return!0}function zc(t,e){Yc(t,Xr.LOAD,e)}function Uc(t,e){Yc(t,Xr.LOADED,e)}function Hc(t,e,i){e.error=i,t.forceUpdate("surface"),Yc(t,Xr.ERROR,e)}function Yc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Xr(e,i))}function Nc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Xc,translate:Vc}=$,Gc=new qt,jc={},Kc={};function qc(t,e,i,s){const n=h(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Zc={},Jc={a:1,b:0,c:0,d:1,e:0,f:0};const{get:$c,set:Qc,rotateOfOuter:tu,translate:eu,scaleOfOuter:iu,multiplyParent:su,scale:nu,rotate:ou,skew:ru}=$;function au(t,e,i,s,n,o,r,a){r&&ou(t,r),a&&ru(t,a.x,a.y),n&&nu(t,n,o),eu(t,e.x+i,e.y+s)}const{get:hu,scale:lu,copy:du}=$,{getFloorScale:cu}=F,{abs:uu}=Math;const gu={image:function(t,e,i,s,n){let o,r;const a=no.get(i,i.type);return Mc&&i===Mc.paint&&Fc(s,Mc.boxBounds)?o=Mc.leafPaint:(o={type:i.type,image:a},a.hasAlphaPixel&&(o.isTransparent=!0),Mc=a.use>1?{leafPaint:o,paint:i,boxBounds:Ic.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Wc(t,e,i,a,o,s),n&&(zc(t,r),Uc(t,r))):a.error?n&&Hc(t,r,a.error):(n&&(Nc(t,!0),zc(t,r)),o.loadId=a.load(()=>{Nc(t,!1),t.destroyed||(Wc(t,e,i,a,o,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Uc(t,r)),o.loadId=void 0},e=>{Nc(t,!1),Hc(t,r,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,n){const{scaleX:o,scaleY:r}=Qh.getImageRenderScaleData(t,i,s,n),a=t.film?t.nowIndex:o+"-"+r,{image:h,data:l,originPaint:d}=t,{exporting:c,snapshot:u}=n;return!(!l||t.patternId===a&&!c||u)&&(e&&(l.repeat?e=!1:d.changeful||t.film||"miniapp"===ie.name&&Jr.isResizing(i)||c||(e=ie.image.isLarge(h,o,r)||h.width*o>8096||h.height*r>8096)),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),Qh.drawImage(t,o,r,i,s,n),!0):(!t.style||d.sync||c?Qh.createPattern(t,i,s,n):Qh.createPatternTask(t,i,s,n),!1))},drawImage:function(t,e,i,s,n,o){const{data:r,image:a,complex:h}=t;let{width:l,height:d}=a;if(h){const{blendMode:o,opacity:c}=t.originPaint,{transform:u}=r;n.save(),2===h&&n.clipUI(s),o&&(n.blendMode=o),c&&(n.opacity*=c),u&&n.transform(u),a.render(n,0,0,l,d,s,t,e,i),n.restore()}else r.scaleX&&(l*=r.scaleX,d*=r.scaleY),a.render(n,0,0,l,d,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:o}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return o&&o.scaleX&&(n.scaleX*=Math.abs(o.scaleX),n.scaleY*=Math.abs(o.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(g(i)){let s,n,o,r,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(o||(o={}),o[a]=!0,no.recyclePaint(s),n.loading&&(r||(r=e.__input&&e.__input[t]||[],g(r)||(r=[r])),n.unload(i[h].loadId,!r.some(t=>t.url===a))));return o}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=no.patternTasker.add(()=>n(this,void 0,void 0,function*(){Qh.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:n,scaleY:o}=Qh.getImageRenderScaleData(t,e,i,s),r=t.film?t.nowIndex:n+"-"+o;if(t.patternId!==r&&!e.destroyed&&(!ie.image.isLarge(t.image,n,o)||t.data.repeat)){const{image:i,data:s}=t,{opacity:a,filters:h}=t.originPaint,{transform:l,gap:d}=s,c=Qh.getPatternFixScale(t,n,o);let u,g,p,{width:_,height:f}=i;c&&(n*=c,o*=c),_*=n,f*=o,d&&(g=d.x*n/uu(s.scaleX||1),p=d.y*o/uu(s.scaleY||1)),(l||1!==n||1!==o)&&(n*=cu(_+(g||0)),o*=cu(f+(p||0)),u=hu(),l&&du(u,l),lu(u,1/n,1/o));const m=i.getCanvas(_,f,a,h,g,p,e.leafer&&e.leafer.config.smooth,s.interlace),y=i.getPattern(m,s.repeat||ie.origin.noRepeat||"no-repeat",u,t);t.style=y,t.patternId=r}},getPatternFixScale:function(t,e,i){const{image:s}=t;let n,o=ie.image.maxPatternSize,r=s.width*s.height;return s.isSVG?e>1&&(n=Math.ceil(e)/e):o>r&&(o=r),(r*=e*i)>o&&(n=Math.sqrt(o/r)),n},createData:function(t,e,i,s){t.data=Qh.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=Gc.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:n}=i,{mode:o,align:r,offset:a,scale:l,size:c,rotation:u,skew:g,clipSize:_,repeat:f,gap:m,interlace:y}=t,v=e.width===s&&e.height===n,w={mode:o},x="center"!==r&&(u||0)%180==90;let b,E;switch(Vt.set(Kc,0,0,x?n:s,x?s:n),o&&"cover"!==o&&"fit"!==o?((l||c)&&(F.getScaleData(l,c,i,jc),b=jc.scaleX,E=jc.scaleY),(r||m||f)&&(b&&Vt.scale(Kc,b,E,!0),r&&Pt.toPoint(r,Kc,e,Kc,!0,!0))):v&&!u||(b=E=Vt.getFitScale(e,Kc,"fit"!==o),Vt.put(e,i,r,b,!1,Kc),Vt.scale(Kc,b,E,!0)),a&&dt.move(Kc,a),o){case"stretch":v?b&&(b=E=void 0):(b=e.width/s,E=e.height/n,Qh.stretchMode(w,e,b,E));break;case"normal":case"clip":if(Kc.x||Kc.y||b||_||u||g){let t,i;_&&(t=e.width/_.width,i=e.height/_.height),Qh.clipMode(w,e,Kc.x,Kc.y,b,E,u,g,t,i),t&&(b=b?b*t:t,E=E?E*i:i)}break;case"repeat":(!v||b||u||g)&&Qh.repeatMode(w,e,s,n,Kc.x,Kc.y,b,E,u,g,r,t.freeTransform),f||(w.repeat="repeat");const i=p(f);(m||i)&&(w.gap=function(t,e,i,s,n){let o,r;p(t)?(o=t.x,r=t.y):o=r=t;return{x:qc(o,i,n.width,e&&e.x),y:qc(r,s,n.height,e&&e.y)}}(m,i&&f,Kc.width,Kc.height,e));break;default:b&&Qh.fillOrFitMode(w,e,Kc.x,Kc.y,b,E,u)}return w.transform||(e.x||e.y)&&Vc(w.transform=Xc(),e.x,e.y),b&&(w.scaleX=b,w.scaleY=E),f&&(w.repeat=h(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),y&&(w.interlace=d(y)||"percent"===y.type?{type:"x",offset:y}:y),w},stretchMode:function(t,e,i,s){const n=$c(),{x:o,y:r}=e;o||r?eu(n,o,r):i>0&&s>0&&(n.onlyScale=!0),nu(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,o,r){const a=$c();eu(a,e.x+i,e.y+s),nu(a,n,o),r&&tu(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a},clipMode:function(t,e,i,s,n,o,r,a,h,l){const d=$c();au(d,e,i,s,n,o,r,a),h&&(r||a?(Qc(Jc),iu(Jc,e,h,l),su(d,Jc)):iu(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,n,o,r,a,h,l,d,c){const u=$c();if(c)au(u,e,n,o,r,a,h,l);else{if(h)if("center"===d)tu(u,{x:i/2,y:s/2},h);else switch(ou(u,h),h){case 90:eu(u,s,0);break;case 180:eu(u,i,s);break;case 270:eu(u,0,i)}Zc.x=e.x+n,Zc.y=e.y+o,eu(u,Zc.x,Zc.y),r&&iu(u,Zc,r,a)}t.transform=u}},{toPoint:pu}=kt,{hasTransparent:_u}=qh,fu={},mu={};function yu(t,e,i,s){if(i){let n,o,r,a;for(let t=0,l=i.length;t<l;t++)n=i[t],h(n)?(r=t/(l-1),o=qh.string(n,s)):(r=n.offset,o=qh.string(n.color,s)),e.addColorStop(r,o),!a&&_u(o)&&(a=!0);a&&(t.isTransparent=!0)}}const{getAngle:vu,getDistance:wu}=dt,{get:xu,rotateOfOuter:bu,scaleOfOuter:Eu}=$,{toPoint:Su}=kt,ku={},Bu={};function Tu(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=vu(e,i);o=xu(),n?(Eu(o,e,r/a*(s||1),1),bu(o,e,t+90)):(Eu(o,e,1,r/a*(s||1)),bu(o,e,t))}return o}const{getDistance:Pu}=dt,{toPoint:Ru}=kt,Lu={},Cu={};const Ou={linearGradient:function(t,e){let{from:i,to:s,type:n,opacity:o}=t;pu(i||"top",e,fu),pu(s||"bottom",e,mu);const r=ie.canvas.createLinearGradient(fu.x,fu.y,mu.x,mu.y),a={type:n,style:r};return yu(a,r,t.stops,o),a},radialGradient:function(t,e){let{from:i,to:s,type:n,opacity:o,stretch:r}=t;Su(i||"center",e,ku),Su(s||"bottom",e,Bu);const a=ie.canvas.createRadialGradient(ku.x,ku.y,0,ku.x,ku.y,wu(ku,Bu)),h={type:n,style:a};yu(h,a,t.stops,o);const l=Tu(e,ku,Bu,r,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:n,opacity:o,stretch:r}=t;Ru(i||"center",e,Lu),Ru(s||"bottom",e,Cu);const a=ie.conicGradientSupport?ie.canvas.createConicGradient(0,Lu.x,Lu.y):ie.canvas.createRadialGradient(Lu.x,Lu.y,0,Lu.x,Lu.y,Pu(Lu,Cu)),h={type:n,style:a};yu(h,a,t.stops,o);const l=Tu(e,Lu,Cu,r||1,ie.conicGradientRotate90);return l&&(h.transform=l),h},getTransform:Tu},{copy:Au,move:Du,toOffsetOutBounds:Mu}=Vt,{max:Iu,abs:Fu}=Math,Wu={},zu=new yt,Uu={};function Hu(t,e){let i,s,n,o,r=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),n=Fu(t.spread||0),r=Iu(r,n+o-s),a=Iu(a,n+o+i),h=Iu(h,n+o+s),l=Iu(l,n+o-i)}),r===a&&a===h&&h===l?r:[r,a,h,l]}function Yu(t,e,i){const{shapeBounds:s}=i;let n,o;ie.fullImageShadow?(Au(Wu,t.bounds),Du(Wu,e.x-s.x,e.y-s.y),n=t.bounds,o=Wu):(n=s,o=e),t.copyWorld(i.canvas,n,o)}const{toOffsetOutBounds:Nu}=Vt,Xu={};const Vu=Hu;const Gu={shadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Mu(h,Uu,l),r.forEach((r,_)=>{let f=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}g.setWorldShadow(Uu.offsetX+(r.x||0)*c*f,Uu.offsetY+(r.y||0)*u*f,(r.blur||0)*c*f,qh.string(r.color)),n=el.getShadowTransform(t,g,i,r,Uu,f),n&&g.setTransform(n),Yu(g,Uu,i),n&&g.resetTransform(),s=l,r.box&&(g.restore(),g.save(),a&&(g.copyWorld(g,l,o,"copy"),s=o),a?g.copyWorld(a,o,o,"destination-out"):g.copyWorld(i.canvas,d,h,"destination-out")),dr.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Nu(h,Xu,l),r.forEach((r,_)=>{let f=1;if(r.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(f=1/t)}g.save(),g.setWorldShadow(Xu.offsetX+(r.x||0)*c*f,Xu.offsetY+(r.y||0)*u*f,(r.blur||0)*c*f),n=el.getShadowTransform(t,g,i,r,Xu,f,!0),n&&g.setTransform(n),Yu(g,Xu,i),g.restore(),a?(g.copyWorld(g,l,o,"copy"),g.copyWorld(a,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,d,h,"source-out"),s=l),g.fillWorld(s,qh.string(r.color),"source-in"),dr.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.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:Hu,getShadowTransform:function(t,e,i,s,n,o,r){if(s.spread){const i=2*s.spread*o*(r?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return zu.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),zu}},isTransformShadow(t){},getInnerShadowSpread:Vu},{excludeRenderBounds:ju}=yr;let Ku;function qu(t,e,i,s,n,o,r,a){switch(e){case"grayscale":Ku||(Ku=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,o){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),o&&s.recycle(r);Ju(t,e,i,1,n,o)}(t,i,s,n,r,a);break;case"opacity-path":Ju(t,i,s,o,r,a);break;case"path":a&&i.restore()}}function Zu(t){return t.getSameCanvas(!1,!0)}function Ju(t,e,i,s,n,o){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),o?i.recycle(r):i.clearWorld(r)}t.Group.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){r&&(qu(this,r,t,n,s,o,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||ju(i,e)||i.__render(t,e),o=i.__.opacity,Ku=!1,"path"===a||"clipping-path"===a?(o<1?(r="opacity-path",n||(n=Zu(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Zu(t)),n||(n=Zu(t)),i.__render(s,e));continue}const d=1===o&&i.__.__blendMode;d&&qu(this,r,t,n,s,o,void 0,!1),ju(i,e)||i.__render(n||t,e),d&&qu(this,r,t,n,s,o,d,!1)}qu(this,r,t,n,s,o,void 0,!0)};const $u=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qu=$u+"_#~&*+\\=|≮≯≈≠=…",tg=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 eg(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ig=eg("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),sg=eg("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ng=eg($u),og=eg(Qu),rg=eg("- —/~|┆·");var ag;!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"}(ag||(ag={}));const{Letter:hg,Single:lg,Before:dg,After:cg,Symbol:ug,Break:gg}=ag;function pg(t){return ig[t]?hg:rg[t]?gg:sg[t]?dg:ng[t]?cg:og[t]?ug:tg.test(t)?lg:hg}const _g={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function fg(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:mg}=_g,{Letter:yg,Single:vg,Before:wg,After:xg,Symbol:bg,Break:Eg}=ag;let Sg,kg,Bg,Tg,Pg,Rg,Lg,Cg,Og,Ag,Dg,Mg,Ig,Fg,Wg,zg,Ug,Hg=[];function Yg(t,e){Og&&!Cg&&(Cg=Og),Sg.data.push({char:t,width:e}),Bg+=e}function Ng(){Tg+=Bg,Sg.width=Bg,kg.words.push(Sg),Sg={data:[]},Bg=0}function Xg(){Fg&&(Wg.paraNumber++,kg.paraStart=!0,Fg=!1),Og&&(kg.startCharSize=Cg,kg.endCharSize=Og,Cg=0),kg.width=Tg,zg.width?mg(kg):Ug&&Vg(),Hg.push(kg),kg={words:[]},Tg=0}function Vg(){Tg>(Wg.maxWidth||0)&&(Wg.maxWidth=Tg)}const{top:Gg,right:jg,bottom:Kg,left:qg}=t.Direction4;function Zg(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Jg={getDrawData:function(t,e){h(t)||(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,o=e.__getInput("height")||0;const{__padding:r}=e;r&&(n?(i=r[qg],n-=r[jg]+r[qg],!n&&(n=.01)):e.autoSizeAlign||(i=r[qg]),o?(s=r[Gg],o-=r[Gg]+r[Kg],!o&&(o=.01)):e.autoSizeAlign||(s=r[Gg]));const a={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:ie.canvas.font=e.__font};return function(t,e,i){Wg=t,Hg=t.rows,zg=t.bounds,Ug=!zg.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=ie,{width:a}=zg;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;Fg=!0,Dg=null,Cg=Lg=Og=Bg=Tg=0,Sg={data:[]},kg={words:[]},s&&(e=[...e]);for(let i=0,l=e.length;i<l;i++)Rg=e[i],"\n"===Rg?(Bg&&Ng(),kg.paraEnd=!0,Xg(),Fg=!0):(Ag=pg(Rg),Ag===yg&&"none"!==o&&(Rg=fg(Rg,o,!Bg)),Lg=r.measureText(Rg).width,s&&(s<0&&(Og=Lg),Lg+=s),Mg=Ag===vg&&(Dg===vg||Dg===yg)||Dg===vg&&Ag!==xg,Ig=!(Ag!==wg&&Ag!==vg||Dg!==bg&&Dg!==xg),Pg=Fg&&n?a-n:a,t&&a&&Tg+Bg+Lg>Pg&&(h?(Bg&&Ng(),Tg&&Xg()):(Ig||(Ig=Ag===yg&&Dg==xg),Mg||Ig||Ag===Eg||Ag===wg||Ag===vg||Bg+Lg>Pg?(Bg&&Ng(),Tg&&Xg()):Tg&&Xg()))," "===Rg&&!0!==Fg&&Tg+Bg===0||(Ag===Eg?(" "===Rg&&Bg&&Ng(),Yg(Rg,Lg),Ng()):Mg||Ig?(Bg&&Ng(),Yg(Rg,Lg)):Yg(Rg,Lg)),Dg=Ag);Bg&&Ng(),Tg&&Xg(),Hg.length>0&&(Hg[Hg.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Wg.paraNumber++,Tg=r.measureText(t).width,Hg.push({x:n||0,text:t,width:Tg,paraStart:!0}),Ug&&Vg()})}(a,t,e),r&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Zg(e,"x",t[qg]);break;case"right":Zg(e,"x",-t[jg])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Zg(e,"y",t[Gg]);break;case"bottom":Zg(e,"y",-t[Kg])}}(r,a,e,n,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:o,__baseLine:r,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:g,y:p,width:_,height:f}=s,m=o*n+(c?c*(t.paraNumber-1):0),y=r;if(h&&m>f)m=Math.max(e.__autoHeight?m:f,o),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":p+=(f-m)/2;break;case"bottom":p+=f-m}y+=p;let v,w,x,b=_||u?_:t.maxWidth;for(let r=0,d=n;r<d;r++){if(v=i[r],v.x=g,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&&r>0&&(y+=c),v.y=y,y+=o,t.overflow>r&&y>m&&(v.isOverflow=!0,t.overflow=r+1),w=v.x,x=v.width,a<0&&(v.width<0?(x=-v.width+e.fontSize+a,w-=x,x+=e.fontSize):x-=a),w<s.x&&(s.x=w),x>s.width&&(s.width=x),h&&_&&_<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=m}(a,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:o,__letterSpacing:r}=e,a=i&&n.includes("both"),h=a||i&&n.includes("justify"),l=h&&n.includes("letter");let d,c,u,g,p,_,f,m,y,v;s.forEach(t=>{t.words&&(p=o&&t.paraStart?o:0,m=t.words.length,h&&(v=!t.paraEnd||a,c=i-t.width-p,l?g=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),_=r||t.isOverflow||l?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===_?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,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,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,d,t.data,t.isOverflow,v&&g),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):g&&(t.width+=g*(e.data.length-(y?1:0))))})),t.words=null)})}(a,e,n),a.overflow&&function(t,e,i,s){const{rows:n,overflow:o}=t;let{textOverflow:r}=e;if(o&&n.splice(o),s&&r&&"show"!==r){let t,a;"hide"===r?r="":"ellipsis"===r&&(r="...");const h=r?ie.canvas.measureText(r).width:0,l=i+s-h;("none"===e.textWrap?n:[n[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:r,x:a}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(a,e,i,n),"none"!==e.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:o}=e;switch(t.decorationHeight=n/11,p(o)?(i=o.type,o.color&&(t.decorationColor=qh.string(o.color)),o.offset&&(s=Math.min(.3*n,Math.max(o.offset,.15*-n)))):i=o,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(a,e),a}};const $g={string:function(t,e){if(!t)return"#000";const i=d(e)&&e<1;if(h(t)){if(!i||!qh.object)return t;t=qh.object(t)}let s=r(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};function Qg(t){return t?g(t)?t:[t]:[]}Object.assign(Kh,Jg),Object.assign(qh,$g),Object.assign($h,Dc),Object.assign(Qh,gu),Object.assign(tl,Ou),Object.assign(el,Gu),Object.assign(ge,{interaction:(t,e,i,s)=>new ic(t,e,i,s),hitCanvas:(t,e)=>new Eh(t,e),hitCanvasManager:()=>new nc}),Sh();class tp extends zr{get list(){return Qg(this.value)}get oldList(){return Qg(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function ep(t){return(e,i)=>{const s="_"+i;lo(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==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(p(i))e=i;else if(!1===i)return}o.setDimOthers(!1),o.setBright(!1),g(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?tp.BEFORE_SELECT:tp.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new tp(s,{editor:o,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}tp.BEFORE_SELECT="editor.before_select",tp.SELECT="editor.select",tp.AFTER_SELECT="editor.after_select",tp.BEFORE_HOVER="editor.before_hover",tp.HOVER="editor.hover";const{abs:ip}=Math,{copy:sp}=$,{setListWithFn:np}=Vt,{worldBounds:op}=yr,rp={a:1,b:0,c:0,d:1,e:0,f:0},ap={x:0,y:0,width:0,height:0};class hp extends t.UI{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?(np(ap,e,op),t&&this.set(t),this.set(ap),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:o,strokeWidth:r,fill:a}=n,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:u}=s;if(u.width&&u.height&&(!l||l.hit(u,e.matrix))){const i=ip(c.scaleX),l=ip(c.scaleY);if(sp(rp,c),rp.half=r%2,t.setWorld(rp,e.matrix),t.beginPath(),"path"===this.strokePathType||s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=r/Math.max(i,l),n.shadow){const e=n.shadow[0],{scaleX:i,scaleY:s}=this.getRenderScaleData(!0,e.scaleFixed);t.save(),t.setWorldShadow(e.x*i,e.y*s,e.blur*i,qh.string(e.color))}o&&(h(o)?$h.stroke(o,this,t,e):$h.strokes(o,this,t,e)),a&&(h(a)?$h.fill(a,this,t,e):$h.fills(a,this,t,e)),n.shadow&&t.restore()}}n.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}s([ep(function(t){const e=t.target;t.list=e?g(e)?e:[e]:[]})],hp.prototype,"target",void 0),s([Co("render-path")],hp.prototype,"strokePathType",void 0);class lp extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=0,this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:n}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:n},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const dp={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return cp([t],i,e),i}};function cp(t,e,i){let s,n;for(let o=0,r=t.length;o<r;o++)if(s=t[o],n=s.__,n.hittable&&n.visible&&!n.locked&&i.hit(s.__world)){if(n.editable){if(s.isBranch&&!n.hitChildren){n.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&n.hitSelf&&e.push(s)}s.isBranch&&cp(s.children,e,i)}}const{findOne:up,findByBounds:gp}=dp;class pp extends t.Group{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 hp,this.targetStroker=new hp,this.bounds=new qt,this.selectArea=new lp,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:n,strokeWidth:o,hover:r,hoverStyle:a}=s;this.hoverStroker.setTarget(r?e:null,Object.assign({stroke:n,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:n,y:o}=t.getInnerPoint(this);this.bounds.set(n,o),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:o},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new xh(gp(e.app,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach(e=>{n.has(e)||t.push(e)}),n.forEach(e=>{this.originList.has(e)||t.push(e)}),(t.length!==e.list.length||e.list.some((e,i)=>e!==t[i]))&&(e.target=t)}else e.target=this.originList.list}}}onDragEnd(t){t.multiTouch||this.dragging&&(this.originList=null,this.selectArea.visible=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)&&!up(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new xh(this.editor.editBox.rect)};return up(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):up(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:e}=this;e.waitLeafer(()=>{const{app:i}=e;i.selector.proxy=e,this.__eventIds=[e.on_([[tp.HOVER,this.onHover,this],[tp.SELECT,this.onSelect,this]]),i.on_([[t.PointerEvent.MOVE,this.onPointerMove,this],[t.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this],[t.PointerEvent.TAP,this.onTap,this],[t.DragEvent.START,this.onDragStart,this,!0],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.MoveEvent.MOVE,this.onAutoMove,this],[[t.ZoomEvent.ZOOM,t.MoveEvent.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:_p,top:fp,topRight:mp,right:yp,bottomRight:vp,bottom:wp,bottomLeft:xp,left:bp}=t.Direction9,{toPoint:Ep}=kt,{within:Sp,sign:kp}=F,{abs:Bp}=Math,Tp={getScaleData(t,e,i,s,n,o,r,a){let h,l,c={},u=1,g=1;const{boxBounds:p,widthRange:_,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:w}=e,x=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,E=kp(x),S=kp(b),k=a?x:E*p.width/v,B=a?b:S*p.height/w;if(d(s))u=g=Math.sqrt(s);else{o&&(s.x*=2,s.y*=2),s.x*=a?x:E,s.y*=a?b:S;const t=(-s.y+w)/w,e=(s.x+v)/v,r=(s.y+w)/w,d=(-s.x+v)/v;switch(i){case fp:g=t,h="bottom";break;case yp:u=e,h="left";break;case wp:g=r,h="top";break;case bp:u=d,h="right";break;case _p:g=t,u=d,h="bottom-right";break;case mp:g=t,u=e,h="bottom-left";break;case vp:g=r,u=e,h="top-left";break;case xp:g=r,u=d,h="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case fp:case wp:u=g;break;case bp:case yp:g=u;break;default:l=Math.sqrt(Bp(u*g)),u=kp(u)*l,g=kp(g)*l}}const T=1!==u,P=1!==g;if(T&&(u/=k),P&&(g/=B),!r){const{worldTransform:e}=t;u<0&&(u=1/p.width/e.scaleX),g<0&&(g=1/p.height/e.scaleY)}if(Ep(o||h,p,c,!0),m){const e={x:u,y:g};Dd.limitScaleOf(t,c,e,n),u=e.x,g=e.y}if(T&&_){const e=p.width*t.scaleX;u=Sp(e*u,_)/e}if(P&&f){const e=p.height*t.scaleY;g=Sp(e*g,f)/e}return T&&Bp(u*y.width)<1&&(u=kp(u)/y.width),P&&Bp(g*y.height)<1&&(g=kp(g)/y.height),n&&u!==g&&(l=Math.min(Bp(u),Bp(g)),u=kp(u)*l,g=kp(g)*l),isFinite(u)||(u=1),isFinite(g)||(g=1),{origin:c,scaleX:u,scaleY:g,direction:i,lockRatio:n,around:o}},getRotateData(t,e,i,s,n){let o,r={};switch(e){case _p:o="bottom-right";break;case mp:o="bottom-left";break;case vp:o="top-left";break;case xp:o="top-right";break;default:o="center"}return Ep(n||o,t.boxBounds,r,!0),{origin:r,rotation:dt.getRotation(s,t.getWorldPointByBox(r),i)}},getSkewData(t,e,i,s){let n,o,r={},a=0,h=0;switch(e){case fp:case _p:o={x:.5,y:0},n="bottom",a=1;break;case wp:case vp:o={x:.5,y:1},n="top",a=1;break;case bp:case xp:o={x:0,y:.5},n="right",h=1;break;case yp:case mp:o={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;o.x=o.x*l,o.y=o.y*d,Ep(s||n,t,r,!0);const c=dt.getRotation(o,r,{x:o.x+(a?i.x:0),y:o.y+(h?i.y:0)});return a?a=-c:h=c,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case bp:t=yp;break;case _p:t=mp;break;case xp:t=vp;break;case yp:t=bp;break;case mp:t=_p;break;case vp:t=xp}if(i)switch(t){case fp:t=wp;break;case _p:t=xp;break;case mp:t=vp;break;case wp:t=fp;break;case xp:t=_p;break;case vp:t=mp}return t}},Pp={};function Rp(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:o,flippedX:r,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Lp(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:g,moveable:p,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(p||(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?n?g:o?c:u:v?g:y?c:u;h+=45*(Tp.getFlipDirection(i.direction,r,a)+1),h=2*Math.round(F.formatRotation(h,!0)/2);const{url:x,x:b,y:E}=w,S=x+h;Pp[S]?i.cursor=Pp[S]:Pp[S]=i.cursor={url:Cp(x,h),x:b,y:E}}function Lp(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Cp(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Op extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const Ap=["top","right","bottom","left"],Dp=void 0;class Mp extends t.Group{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 h(t)||h(e)||h(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(e){super(),this.view=new t.Group,this.rect=new Op({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Op({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:n,rotatePoints:o,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Op({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),o.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Op({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Op({name:"resize-point",hitRadius:5}),n.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),this.listenPointEvents(a,"move",8),s.addMany(...o,a,h,l,...r,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:n,resizePoints:o,resizeLines:r}=this,{stroke:h,strokeWidth:l,ignorePixelSnap:d}=e,c=this.getPointsStyle(),u=this.getMiddlePointsStyle(),g=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let t=0;t<8;t++)p=o[t],p.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:c[t/2%c.length])),p.rotation=(t-(t%2?1:0))/2*90,t%2&&r[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},g[(t-1)/2%g.length]||{}));n.set(this.getPointStyle(e.circle||e.rotatePoint||c[0])),s.set(Object.assign({stroke:h,strokeWidth:l,opacity:1,editConfig:Dp},e.rect||{}));const _=a(e.rectThrough)?i:e.rectThrough;s.hittable=!_,_&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&m.stintSet(t.__world,"ignorePixelSnap",d),Lp(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:o,skewX:r,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:n,rotation:o,skewX:r,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:n,circle:o,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{editMask:c}=e,{middlePoint:u,resizeable:g,rotateable:p,hideOnSmall:_,editBox:f,mask:m,dimOthers:y,bright:v,spread:w,hideRotatePoints:x,hideResizeLines:b}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),w&&Vt.spread(t,w),this.view.worldOpacity){const{width:e,height:c}=t,m=d(_)?_:10,y=f&&!(_&&e<m&&c<m);let v,w,E,S={};for(let i=0;i<8;i++)kt.toPoint(kt.directionData[i],t,S),w=a[i],v=h[i],w.set(S),v.set(S),w.visible=y&&!(!g&&!p),v.visible=y&&p&&g&&!x,i%2&&(E=l[(i-1)/2],E.set(S),E.visible=w.visible&&!b,w.visible=v.visible=y&&!!u,(i+1)/2%2?(E.width=e+E.height,_&&2*w.width>e&&(w.visible=!1)):(E.width=c+E.height,_&&2*w.width>c&&(w.visible=!1)));o.visible=y&&p&&!(!i.circle&&!i.rotatePoint),o.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),r.visible=y&&r.children.length>0||0,r.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,o=Ap.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,o,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:o,flippedY:r}=this;let a=Ap.indexOf(e);(a%2&&o||(a+1)%2&&r)&&i&&(a=(a+2)%4);const h=i?Tp.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=o?-1:1,t.scaleY=r?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],o=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*r;o?(t.x=n.x+a,t.y=n.y):(t.x=n.x,t.y=n.y+a)}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:n,pointRadius:o}=this.mergedConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:n,height:n,cornerRadius:o,offsetX:0,offsetY:0,editConfig:Dp};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.mergedConfig;return g(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return g(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return g(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:n,rotateable:o,skewable:r}=this.mergeConfig;"move"===i?s&&(this.moving=!0):(i.includes("rotate")||this.isHoldRotateKey(t)||!n?(o&&(this.rotating=!0),"resize-rotate"===i?n&&(this.resizing=!0):"resize-line"===e.name&&(r&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&n&&(this.resizing=!0),"skew"===i&&r&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:o}=this;if(i)e.onMove(t);else if(s||n||o){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),o&&e.onSkew(t)}Rp(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&&(Jr.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(e){this.canDragLimitAnimate&&(e instanceof t.DragEvent||e instanceof t.MoveEvent)&&this.transformTool.onMove(e),this.resizing&&(Jr.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(e){if(this.canGesture&&"drag"!==e.moveType&&(e.stop(),h(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,e.type){case t.MoveEvent.START:this.onTransformStart(e);break;case t.MoveEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onMove(e)}}onScale(e){if(this.canGesture&&(e.stop(),h(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onScale(e)}}onRotate(e){if(this.canGesture&&(e.stop(),h(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,e.type){case t.ZoomEvent.START:this.onTransformStart(e);break;case t.ZoomEvent.END:this.onTransformEnd(e);break;default:this.transformTool.onRotate(e)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Rp(this,t)}onArrow(t){if(this.canUse&&this.mergeConfig.keyEvent){let e=0,i=0;const s=t.shiftKey?10:1;switch(t.code){case"ArrowDown":i=s;break;case"ArrowUp":i=-s;break;case"ArrowLeft":e=-s;break;case"ArrowRight":e=s}(e||i)&&this.transformTool.move(e,i)}}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(e){const{editor:i,target:s}=this;if(this.single){if(s.locked)return;if(s.isBranch&&!s.editInner){if(s.textBox){const{children:e}=s,n=e.find(e=>e.editable&&e instanceof t.Text)||e.find(e=>e instanceof t.Text);if(n)return i.openInnerEditor(n)}i.openGroup(s),i.target=i.selector.findDeepOne(e)}else i.openInnerEditor()}}listenPointEvents(e,i,s){e.direction=s,e.pointType=i,this.__eventIds.push(e.on_([[t.DragEvent.START,this.onDragStart,this],[t.DragEvent.DRAG,this.onDrag,this],[t.DragEvent.END,this.onDragEnd,this],[t.PointerEvent.ENTER,t=>{this.enterPoint=e,Rp(this,t)}],[t.PointerEvent.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:e,editor:i,__eventIds:s}=this;s.push(e.on_([[t.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this],[t.PointerEvent.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{s.push(i.app.on_([[[t.KeyEvent.HOLD,t.KeyEvent.UP],this.onKey,this],[t.KeyEvent.DOWN,this.onArrow,this],[[t.MoveEvent.START,t.MoveEvent.BEFORE_MOVE,t.MoveEvent.END],this.onMove,this,!0],[[t.ZoomEvent.START,t.ZoomEvent.BEFORE_ZOOM,t.ZoomEvent.END],this.onScale,this,!0],[[t.RotateEvent.START,t.RotateEvent.BEFORE_ROTATE,t.RotateEvent.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const Ip={x:0,y:0,width:1e5,height:1e5};class Fp extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Ip),Object.assign(this.__world,Ip)}__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()}}const Wp='\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"/>',zp={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${Wp}\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${Wp}\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${Wp}\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},Up=new qt;function Hp(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{Up.setListWithFn(i,t=>t.getBounds("box","page")),0===Up.width&&(Up.width=.1),0===Up.height&&(Up.height=.1),e.reset(Up.get())}),s.add(e)}const Yp=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Np=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Xp={group(e,i,s){e.sort(Np);const{app:n,parent:o}=e[0];let r;r=s&&s.add?s:new t.Group(s),o.addAt(r,o.children.indexOf(e[0])),e.sort(Yp);const a=new yt(i.worldTransform);return a.divideParent(o.scrollWorldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,n.lockLayout(),e.forEach(t=>t.dropTo(r)),n.unlockLayout(),r},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(Yp),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(Np),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},Vp=oe.get("EditToolCreator");function Gp(){return t=>{Kp.register(t)}}const jp=Gp,Kp={list:{},register(t){const{tag:e}=t.prototype;qp[e]&&Vp.repeat(e),qp[e]=t},get:(t,e)=>new qp[t](e)},{list:qp}=Kp;class Zp extends tp{constructor(t,e){super(t,e)}}Zp.BEFORE_OPEN="innerEditor.before_open",Zp.OPEN="innerEditor.open",Zp.BEFORE_CLOSE="innerEditor.before_close",Zp.CLOSE="innerEditor.close";class Jp extends tp{constructor(t,e){super(t,e)}}Jp.BEFORE_GROUP="editor.before_group",Jp.GROUP="editor.group",Jp.BEFORE_UNGROUP="editor.before_ungroup",Jp.UNGROUP="editor.ungroup",Jp.BEFORE_OPEN="editor.before_open_group",Jp.OPEN="editor.open_group",Jp.BEFORE_CLOSE="editor.before_close_group",Jp.CLOSE="editor.close_group";const{updateMatrix:$p}=dr,Qp={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},t_="top-left";class e_ extends t.Rect{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.skipJSON=!0,this.on(Yr.CHANGE,e=>{if(this.checkChange&&Qp[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,o="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const r=this.__;r[i]=n,$p(this.parent),$p(this);const a=new yt(this.__world);switch(r[i]=s,this.__layout.rotationChange(),$p(this),this.changedTransform=new yt(this.__world).divide(a),i){case"x":t.move(o,0);break;case"y":t.move(0,o);break;case"rotation":t.rotateOf(t_,o);break;case"scaleX":t.scaleOf(t_,o,1);break;case"scaleY":t.scaleOf(t_,1,o);break;case"skewX":t.skewOf(t_,o,0);break;case"skewY":t.skewOf(t_,0,o)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class i_ extends tp{constructor(t,e){super(t,e)}}i_.BEFORE_MOVE="editor.before_move",i_.MOVE="editor.move";class s_ extends tp{constructor(t,e){super(t,e)}}s_.BEFORE_SCALE="editor.before_scale",s_.SCALE="editor.scale";class n_ extends tp{constructor(t,e){super(t,e)}}n_.BEFORE_ROTATE="editor.before_rotate",n_.ROTATE="editor.rotate";class o_ extends tp{constructor(t,e){super(t,e)}}o_.BEFORE_SKEW="editor.before_skew",o_.SKEW="editor.skew";class r_{onMove(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox;let o,{dragLimitAnimate:r}=s;const a=e.type===t.MoveEvent.END||e.type===t.DragEvent.END,l=h(i.draggable),c=!r||a||l,u={x:e.totalX,y:e.totalY};e instanceof t.MoveEvent&&dt.move(u,i.getWorldPointByLocal(n.totalOffset,null,!0)),e.shiftKey&&(Math.abs(u.x)>Math.abs(u.y)?u.y=0:u.x=0),o=t.DragEvent.getValidMove(i,n.point,u,c),(o.x||o.y)&&(r&&!l&&a?dr.animateMove(this,o,d(r)?r:.3):this.move(o))}onScale(e){const{target:i,mergeConfig:s,single:n,dragStartData:o}=this.editBox;let r,{around:a,lockRatio:h,flipable:l,editSize:d}=s;e instanceof t.ZoomEvent?(a||(a=i.getBoxPoint(e)),r=e.totalScale):r=e.getInnerTotal(i);const{direction:c}=e.current;(e.shiftKey||i.lockRatio)&&(h=!0);const u=Tp.getScaleData(i,o.bounds,c,r,h,Tp.getAround(a,e.altKey),l,!n||"scale"===d),g=i.x,p=i.y;e instanceof t.DragEvent&&this.editTool&&this.editTool.onScaleWithDrag?(u.drag=e,this.scaleWithDrag(u)):this.scaleOf(u.origin,u.scaleX,u.scaleY),dt.move(o.totalOffset,i.x-g,i.y-p)}onRotate(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox,{around:o,rotateAround:r,rotateGap:a,diagonalRotateKey:h}=s,{direction:l}=e.current;let d,c;if(e instanceof t.RotateEvent)c=e.rotation,d=r?kt.getPoint(r,i.boxBounds):i.getBoxPoint(e);else{const t=h?e.isHoldKeys(h):e.shiftKey,s=Tp.getRotateData(i,l,e,n,t?null:r||i.around||i.origin||o||"center");c=n.rotation+s.rotation-i.rotation,d=s.origin}if(c=F.float(F.getGapRotation(c,a,i.rotation),2),!c)return;const u=i.x,g=i.y;this.rotateOf(d,c),dt.move(n.totalOffset,i.x-u,i.y-g)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:o,skewY:r}=Tp.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Tp.getAround(s,t.altKey));(o||r)&&this.skewOf(n,o,r)}move(t,e=0){if(!this.checkTransform("moveable"))return;p(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeMove:r}=s;if(r){const s=r({target:i,x:t,y:e});if(p(s))t=s.x,e=s.y;else if(!1===s)return}const a=i.getWorldPointByLocal({x:t,y:e},null,!0);n||i.safeChange(()=>i.move(t,e));const h={target:i,editor:o,moveX:a.x,moveY:a.y};this.emitEvent(new i_(i_.BEFORE_MOVE,h));const l=new i_(i_.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:n}=i;if(n){const{origin:i,scaleX:s,scaleY:o,drag:r}=t;if(!1===n({target:e,drag:r,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 s_(s_.BEFORE_SCALE,t));const o=new s_(s_.SCALE,t);this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeScale:h}=o;if(h){const s=h({target:n,origin:t,scaleX:e,scaleY:i});if(p(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.scaleOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new s_(s_.BEFORE_SCALE,c));const u=new s_(s_.SCALE,c);this.doScale(u),this.emitEvent(u)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),o=i?new yt(dr.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),r={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:o};this.emitEvent(new s_(s_.BEFORE_SCALE,r));const a=new s_(s_.SCALE,r);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:o}=this.editBox,{beforeRotate:r}=s;if(r){const s=r({target:i,origin:t,rotation:e});if(d(s))e=s;else if(!1===s)return}const a=this.getWorldOrigin(t),h=!n&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),l={target:i,editor:o,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new n_(n_.BEFORE_ROTATE,l));const c=new n_(n_.ROTATE,l);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:o,single:r,editor:a}=this.editBox,{beforeSkew:h}=o;if(h){const s=h({target:n,origin:t,skewX:e,skewY:i});if(p(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),d=!r&&this.getChangedTransform(()=>n.safeChange(()=>n.skewOf(t,e,i))),c={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new o_(o_.BEFORE_SKEW,c));const u=new o_(o_.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(dr.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new yt(e.worldTransform);return t(),new yt(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}t.Editor=class extends t.Group{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 xh,this.openedGroupList=new xh,this.simulateTarget=new e_(this),this.editBox=new Mp(this),this.editToolList={},this.selector=new pp(this),this.editMask=new Fp(this),this.targetEventIds=[];let i=m.clone(zp);t&&(i=m.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),ue.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?g(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>m.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}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&&Hp(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||Kp.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(h(s))e=s;else if(!1===s)return}if(Kp.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(Jp.BEFORE_GROUP),this.target=Xp.group(this.list,this.element,t),this.emitGroupEvent(Jp.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(Jp.BEFORE_UNGROUP,t)),this.target=Xp.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(Jp.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(Jp.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Jp.OPEN,t)}closeGroup(t){this.emitGroupEvent(Jp.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Jp.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!dr.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 Jp(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||Kp.get(t,this)}openInnerEditor(t,e,i){let s;if(h(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(h(i))s=i;else if(!1===i)return}Kp.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(Zp.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Zp.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Zp.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Zp.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Zp(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&&(Xp.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Xp.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_(ta.START,this.onRenderStart,this),i&&i.on_(Yr.SCROLL,this.onChildScroll,this),t.on_(ta.CHILD_START,this.onAppRenderStart,this),t.on_(ea.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())}},s([(t,e)=>{lo(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,app:n}=this,o=Object.assign({},t);if(e&&e.editConfig){let{editConfig:t}=e;(t.hover||t.hoverStyle)&&(t=Object.assign({},t),delete t.hover,delete t.hoverStyle),Object.assign(o,t)}return s.config&&Object.assign(o,s.config),i&&(i.editConfig&&Object.assign(o,i.editConfig),"font-size"===o.editSize&&(o.lockRatio=!0),"resize-rotate"===i.pointType&&(o.around||(o.around="center"),a(o.lockRatio)&&(o.lockRatio=!0))),r(o.dragLimitAnimate)&&(o.dragLimitAnimate=n&&n.config.pointer.dragLimitAnimate),this.mergedConfig=o}})}],t.Editor.prototype,"mergeConfig",void 0),s([ep(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof xh?i:new xh(i),t.multiple&&Hp(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new tp(tp.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new tp(tp.AFTER_SELECT,s))})],t.Editor.prototype,"target",void 0),s([ep(function(t,e){t.emitEvent(new tp(tp.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],t.Editor.prototype,"hoverTarget",void 0),t.Editor=s([Zo(r_,["editBox","editTool","emitEvent"])],t.Editor);class a_{static registerInnerEditor(){Kp.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 t.Group,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)}}t.EditTool=class extends a_{static registerEditTool(){Kp.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:o}=s;n.lockLayout(),o.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(n,e,i,r)}),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:o,list:r}=n;o.lockLayout(),r.forEach(t=>{const o="scale"!==n.getEditSize(t);i?t.transformWorld(i,o):t.rotateOfWorld(s,e)}),o.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:o}=t,{app:r,list:a}=o;r.lockLayout(),a.forEach(t=>{const r="scale"!==o.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(n,e,i,r)}),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){this.editBox.update(),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=s([Gp()],t.EditTool);const{left:h_,right:l_}=t.Direction9,{move:d_,copy:c_,toNumberPoints:u_}=dt;t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:n}=t,o=t.target,r=i===h_;if(o.pathInputed){const{path:t}=o.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,o.path=t}else if(o.points){const{points:t}=o,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,n,this.getInnerMove(o,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,o.points=t}else{const t={x:0,y:0},{toPoint:i}=o;o.rotation=0,this.dragPoint(t,i,r,n,this.getInnerMove(o,e,s)),o.getLocalPointByInner(t,null,null,!0),o.getLocalPointByInner(i,null,null,!0),o.x=t.x,o.y=t.y,o.getInnerPointByLocal(i,null,null,!0),o.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){const e=u_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:o,y:r}=n;i?(d_(t,o,r),s&&d_(e,-o,-r)):(s&&d_(t,-o,-r),d_(e,o,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,o=t.target;let r,a;if(o.pathInputed?r=this.getFromToByPath(o.__.path):o.points&&(r=this.getFromToByPoints(o.__.points)),r){const{from:i,to:a}=r;o.innerToWorld(i,i,!1,t),o.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),c_(s[7],i),c_(e[7],i),c_(s[3],a),c_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===h_||t===l_,s[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=s([Gp()],t.LineEditTool);const{M:g_,L:p_,C:__,Q:f_,Z:m_,N:y_,D:v_,X:w_,G:x_,F:b_,O:E_,P:S_,U:k_}=Fe,B_={scale(t,e,i){if(!t)return;let s,n=0,o=t.length;for(;n<o;)switch(s=t[n],s){case g_:case p_:T_(t,e,i,n,1),n+=3;break;case __:T_(t,e,i,n,3),n+=7;break;case f_:T_(t,e,i,n,2),n+=5;break;case m_:n+=1;break;case y_:T_(t,e,i,n,2),n+=5;break;case v_:T_(t,e,i,n,2),n+=9;break;case w_:T_(t,e,i,n,2),n+=6;break;case x_:T_(t,e,i,n,2),n+=9;break;case b_:T_(t,e,i,n,2),n+=5;break;case E_:t[n]=x_,t.splice(n+4,0,t[n+3],0),T_(t,e,i,n,2),n+=9,o+=2;break;case S_:t[n]=b_,t.splice(n+4,0,t[n+3]),T_(t,e,i,n,2),n+=5,o+=1;break;case k_:T_(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let o=n?s+1:0,r=n?o+2*n:t.length;o<r;o+=2)t[o]*=e,t[o+1]*=i}},{scalePoints:T_}=B_,P_=$.get(),{topLeft:R_,top:L_,topRight:C_,right:O_,bottom:A_,left:D_}=t.Direction9;function M_(t,e,i){t.pathInputed?F_(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function I_(t,e,i,s){let n=e;if(!r(s)){const o=t.__layout;let{width:r,height:a}=o.boxBounds;switch(r*=i-e,a*=e-i,s){case L_:case A_:n=i,o.affectScaleOrRotation?t.moveInner(-r/2,0):t.x-=r/2;break;case D_:case O_:o.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case R_:case C_:o.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const o=t.__,{padding:a}=o;a&&(t.padding=g(a)?a.map(t=>t*n):a*n),o.__autoWidth||(t.width*=n),o.__autoHeight||(t.height*=n)}function F_(t,e,i){B_.scale(t.__.path,e,i),t.path=t.__.path}function W_(t,e,i){const{points:s}=t;p(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):B_.scalePoints(s,e,i),t.points=s}function z_(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)P_.a=e,P_.d=i,s[t].transform(P_,!0)}const U_=t.Leaf.prototype;U_.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))},U_.__scaleResize=function(t,e){M_(this,t,e)},U_.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},U_.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){const{app:i,editConfig:s}=this,n=i&&i.editor,o=n&&n.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||o&&"font-size"===n.mergedConfig.editSize)I_(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:o}=this.__,{boxBounds:r}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=r.x),s&&"top"!==o&&1!==e&&(this.y+=r.y),M_(this,t,e)}},t.Path.prototype.__scaleResize=function(t,e){F_(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?F_(this,t,e):this.points?W_(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?F_(this,t,e):this.points?W_(this,t,e):M_(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){z_(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||M_(this,t,e),i&&z_(this,t,e)},ue.add("resize"),ue.add("editor","resize"),ge.editor=function(e,i){const s=new t.Editor(e);return i&&i.sky.add(i.editor=s),s},t.Box.addAttr("textBox",!1,fo),t.UI.addAttr("editConfig",void 0,fo),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),fo),t.UI.addAttr("editInner","PathEditor",fo),t.Group.addAttr("editInner","",fo),t.Text.addAttr("editInner","TextEditor",fo),t.UI.setEditConfig=function(t){this.changeAttr("editConfig",t)},t.UI.setEditOuter=function(t){this.changeAttr("editOuter",t)},t.UI.setEditInner=function(t){this.changeAttr("editInner",t)};const H_={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},Y_={top:"flex-start",middle:"center",bottom:"flex-end"},N_={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function X_(t,e,i){const{style:s}=t,{fill:n,padding:o,textWrap:a,textOverflow:l,textDecoration:d}=e;let c;s.fontFamily=e.fontFamily,s.fontSize=e.fontSize*i+"px",function(t,e){let i="black";g(e)&&(e=e[0]);if(p(e))switch(e.type){case"solid":i=qh.string(e.color);break;case"image":case"film":case"video":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=qh.string(h(t)?t:t.color);break;default:r(e.r)||(i=qh.string(e))}else i=e;t.color=i}(s,n),s.fontStyle=e.italic?"italic":"normal",s.fontWeight=e.fontWeight,p(d)?(c=d.type,d.color&&(s.textDecorationColor=qh.string(d.color))):c=d,s.textDecoration=N_[c],s.textTransform=H_[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=Y_[e.verticalAlign],s.lineHeight=(e.__.__lineHeight||0)*i+"px",s.letterSpacing=(e.__.__letterSpacing||0)*i+"px",s.whiteSpace="none"===a||e.__.__autoWidth?"nowrap":"normal",s.wordBreak="break"===a?"break-all":"normal",s.textIndent=(e.paraIndent||0)*i+"px",s.padding=g(o)?o.map(t=>t*i+"px").join(" "):(o||0)*i+"px",s.textOverflow="show"===l?"":"hide"===l?"clip":l}function V_(t){const{scroll:e,disabled:i}=t.app.config.move;return!e||i?"":!0===e?"free":e}function G_(e,i,s){j_(e.parentApp?e.parentApp:e,i),e.isApp||s||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,t=>{const i=e.getValidMove(t.moveX,t.moveY,!1);if(V_(e).includes("limit")){const s=e.getValidMove(0,0);if(s.x||s.y){const e=100,n=200,o="drag"===t.moveType?.3:.05;Math.abs(s.x)>e?i.x=0:i.x*=o,Math.abs(s.y)>n?i.y=0:i.y*=o}}e.zoomLayer.move(i)}),e.on_(t.MoveEvent.DRAG_ANIMATE,()=>{const t=e.getValidMove(0,0);(t.x||t.y)&&e.interaction.stopDragAnimate()}),e.on_(t.MoveEvent.END,t=>{dr.animateMove(e.zoomLayer,e.getValidMove(t.moveX,t.moveY))}),e.on_(t.ZoomEvent.BEFORE_ZOOM,t=>{const{zoomLayer:i,layouter:s}=e,n=e.getValidScale(t.scale);1!==n&&(s.stop(),dr.updateMatrix(e),i.scaleOfWorld(t,n),s.start())}))}function j_(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&m.assign(i,e),m.assign(t.config,i,t.userConfig)}t.TextEditor=class extends a_{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:e}=this,{config:i}=e.app,s=this.editTarget;s.textEditing=!0,this.isHTMLText=!(s instanceof t.Text),this._keyEvent=i.keyEvent,i.keyEvent=!1;const n=this.editDom=document.createElement("div");n.classList.add("leafer-text-editor");const{style:o}=n;n.contentEditable="true",o.position="fixed",o.transformOrigin="left top",o.boxSizing="border-box",this.isHTMLText?n.innerHTML=String(s.text):n.innerText=String(s.text);const{view:r}=e.app;(this.inBody=r instanceof HTMLCanvasElement)?document.body.appendChild(n):r.appendChild(n),this.eventIds=[e.app.on_(t.PointerEvent.DOWN,t=>{let i,{target:s}=t.origin;for(;s;)s===n&&(i=!0),s=s.parentElement;i||e.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),n.addEventListener("focus",this.onFocus),n.addEventListener("input",this.onInput),n.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const a=window.getSelection(),h=document.createRange();if(this.config.selectAll)h.selectNodeContents(n);else{const t=n.childNodes[0];t&&(h.setStartAfter(t),h.setEndAfter(t)),h.collapse(!0)}a.removeAllRanges(),a.addRange(h)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=document.createTextNode("​"),s=window.getSelection().getRangeAt(0);s.deleteContents(),s.insertNode(i),s.insertNode(e),s.setStartAfter(e),s.setEndAfter(e),this.onInput()}}onPaste(t){if(this.isHTMLText)return;t.preventDefault();const e=t.clipboardData;if(!e)return;let i=e.getData("text/plain").replace(/\r\n?/g,"\n");const s=window.getSelection();if(!s||!s.rangeCount)return;const n=s.getRangeAt(0);n.deleteContents();const o=i.split("\n"),r=document.createDocumentFragment();o.forEach((t,e)=>{e>0&&r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(t))}),n.insertNode(r),n.collapse(!1),s.removeAllRanges(),s.addRange(n),this.onInput()}onUpdate(){const{editTarget:t}=this;let e=1;if(!this.isHTMLText){const{scaleX:i,scaleY:s}=t.worldTransform;e=Math.max(Math.abs(i),Math.abs(s));t.fontSize*e<12&&(e*=12/t.fontSize)}this.textScale=e;let{width:i,height:s}=t,n=0,o=0;i*=e,s*=e;const r=t.__;if(r.__autoWidth)switch(i+=20,r.textAlign){case"center":n=r.autoSizeAlign?-i/2:-10;break;case"right":n=r.autoSizeAlign?-i:-20}if(r.__autoHeight)switch(s+=20,r.verticalAlign){case"middle":o=r.autoSizeAlign?-s/2:-10;break;case"bottom":o=r.autoSizeAlign?-s:-20}const{x:a,y:h}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:l,b:d,c:c,d:u,e:g,f:p}=new yt(t.worldTransform).scale(1/e).translateInner(n,o),{style:_}=this.editDom;_.transform=`matrix(${l},${d},${c},${u},${g},${p})`,_.left=a+"px",_.top=h+"px",_.width=i+"px",_.height=s+"px",this.isHTMLText||X_(this.editDom,t,e)}onUnload(){const{editTarget:t,editor:e,editDom:i}=this;t&&(this.onInput(),"\n"===t.text&&(t.text=""),t.textEditing=void 0,e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),i.removeEventListener("focus",this.onFocus),i.removeEventListener("input",this.onInput),i.removeEventListener("paste",this.onPaste),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("scroll",this.onUpdate),i.remove(),this.editDom=this.eventIds=void 0)}},t.TextEditor=s([jp()],t.TextEditor),ue.add("text-editor","editor");const K_=oe.get("LeaferTypeCreator"),q_={list:{},register(t,e){Z_[t]&&K_.repeat(t),Z_[t]=e},run(t,e){const i=Z_[t];i&&i(e)}},{list:Z_,register:J_}=q_;J_("viewport",G_),J_("custom",function(t){G_(t,null,!0)}),J_("design",function(t){G_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),J_("document",function(t){G_(t,{zoom:{min:1},move:{scroll:"limit"}})});const $_={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=dt.getCenter(e.from,i.from),n=dt.getCenter(e.to,i.to),o={x:n.x-s.x,y:n.y-s.y},r=dt.getDistance(e.from,i.from);return{move:o,scale:dt.getDistance(e.to,i.to)/r,rotation:dt.getRotation(e.from,i.from,e.to,i.to),center:n}},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),n=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&n<1?"none":i>=s&&i>=n?"move":s>=n?"zoom":"rotate"},detect(t,e){const{state:i}=Q_,s=Q_.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),Q_.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)?Q_.getType(i.totalData,e):"none"},add(t,e){e&&(dt.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=Q_;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},Q_=$_,{abs:tf,max:ef}=Math,{sign:sf,within:nf}=F,of={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const o=tf(s),r=tf(n);return o>50&&(s=ef(50,o/3)*sf(s)),r>50&&(n=ef(50,r/3)*sf(n)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:o}=e;const r=t.deltaY||t.deltaX;if(n?(i="mouse"===n||!t.deltaX&&(ie.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){o=nf(o,0,1);const i=t.deltaY?e.delta.y:e.delta.x,n=nf(1-tf(r)/(4*i)*o,.5,2);s=r>0?n:1/n}return s}};let rf,af,hf,lf;class df{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(e){const{interaction:i}=this;e.moveType||(e.moveType="move"),this.moveData||(this.setPath(e),rf=0,af=0,this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0,totalX:rf,totalY:af}),i.emit(t.MoveEvent.START,this.moveData)),e.path=this.moveData.path,e.totalX=rf+=e.moveX,e.totalY=af+=e.moveY,i.emit(t.MoveEvent.BEFORE_MOVE,e),i.emit(t.MoveEvent.MOVE,e),this.transformEndWait()}zoom(e){const{interaction:i}=this;this.zoomData||(this.setPath(e),hf=1,this.zoomData=Object.assign(Object.assign({},e),{scale:1,totalScale:hf}),i.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,e.totalScale=hf*=e.scale,i.emit(t.ZoomEvent.BEFORE_ZOOM,e),i.emit(t.ZoomEvent.ZOOM,e),this.transformEndWait()}rotate(e){const{interaction:i}=this;this.rotateData||(this.setPath(e),lf=0,this.rotateData=Object.assign(Object.assign({},e),{rotation:0,totalRotation:lf}),i.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,e.totalRotation=lf+=e.rotation,i.emit(t.RotateEvent.BEFORE_ROTATE,e),i.emit(t.RotateEvent.ROTATE,e),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:e,moveData:i,zoomData:s,rotateData:n}=this;i&&e.emit(t.MoveEvent.END,Object.assign(Object.assign({},i),{totalX:rf,totalY:af})),s&&e.emit(t.ZoomEvent.END,Object.assign(Object.assign({},s),{totalScale:hf})),n&&e.emit(t.RotateEvent.END,Object.assign(Object.assign({},n),{totalRotation:lf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const cf=t.Leafer.prototype,uf=new qt,gf=new ft;function pf(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function _f(t,e){return Object.assign(Object.assign({},e),{scale:t})}cf.initType=function(t){q_.run(t,this)},cf.getValidMove=function(t,e,i=!0){const{disabled:s,scrollSpread:n}=this.app.config.move;gf.set(t,e);const o=V_(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")&&(uf.set(this.__world).addPoint(this.zoomLayer),n&&uf.spread(n),Dd.getValidMove(uf,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}},cf.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,o=Math.abs(e*t);return i&&o<i?t=i/e:s&&o>s&&(t=s/e),n?1:t};const ff=ic.prototype;ff.createTransformer=function(){this.transformer=new df(this)},ff.move=function(t){this.transformer.move(t)},ff.zoom=function(t){this.transformer.zoom(t)},ff.rotate=function(t){this.transformer.rotate(t)},ff.transformEnd=function(){this.transformer.transformEnd()},ff.wheel=function(t){const{wheel:e,pointer:i}=this.config,{posDeltaSpeed:s,negDeltaSpeed:n}=e;if(e.disabled)return;t.deltaX>0?s&&(t.deltaX*=s):n&&(t.deltaX*=n),t.deltaY>0?s&&(t.deltaY*=s):n&&(t.deltaY*=n);const o=e.getScale?e.getScale(t,e):of.getScale(t,e);if(1!==o)this.zoom(_f(o,t));else{const s=e.getMove?e.getMove(t,e):of.getMove(t,e);i.snap&&dt.round(s),this.move(pf(s,t))}},ff.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=$_.getData(e),{moving:o,zooming:r,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch($_.detect(n,p(s)?s:{})){case"move":o=!0;break;case"zoom":r=!0;break;case"rotate":a=!0;break;default:return}$_.reset()}o||(n.center=$_.state.center)}else o=r=a=!0;var h,l;Object.assign(t,n.center),t.multiTouch=!0,a&&this.rotate((h=n.rotation,l=t,Object.assign(Object.assign({},l),{rotation:h}))),r&&this.zoom(_f(n.scale,t)),o&&this.move(pf(n.move,t))};const mf=Gd.prototype,{abs:yf,min:vf,max:wf,hypot:xf}=Math;function bf(t,e){let i=1;const s="out"===e,n=Math.abs(t);if(n>1){for(;s?i<n:i<=n;)i*=2;s&&(i/=2)}else{for(;s?i>=n:i>n;)i/=2;s||(i*=2)}return i/t}mf.checkDragEndAnimate=function(e){const{interaction:i}=this,s=this.canAnimate&&this.moving&&i.m.dragAnimate;if(s){const n=d(s)?s:.95,o=.15,r=150;let a,h,l,c=0,u=0,g=0,p=0,_=3;const{dragDataList:f}=this,m=f.length;for(let t=m-1;t>=wf(m-3,0)&&(l=f[t],!(l.time&&Date.now()-l.time>100));t--)a=_--,c+=l.moveX*a,u+=l.moveY*a,p+=a,h=xf(l.moveX,l.moveY),h>g&&(g=h);if(p&&(c/=p,u/=p),g>8){const t=1.15+vf((g-8)/17,1)*(1.6-1.15);c*=t,u*=t}const y=wf(yf(c),yf(u));y>r&&(h=r/y,c*=h,u*=h);const v=()=>{if(c*=n,u*=n,e=Object.assign({},e),yf(c)<o&&yf(u)<o)return this.dragEndReal(e);dt.move(e,c,u),this.drag(e),this.animate(v),i.emit(t.MoveEvent.DRAG_ANIMATE,e)};this.animate(v)}return s},mf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},mf.stopAnimate=function(){this.animate(null,"off"),this.interaction.target.nextRender(()=>{this.dragData&&this.dragEndReal(this.dragData)})},mf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},mf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:o}=e.m;if(!o||!s||!n)return;const r=e.shrinkCanvasBounds,{x:a,y:h}=r,l=Vt.maxX(r),d=Vt.maxY(r),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let g=0,p=0;this.autoMoveTimer=setInterval(()=>{g+=c,p+=u,dt.move(i,c,u),dt.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:g,totalY:p,moveType:"drag"})),e.pointerMoveReal(t)},10)},mf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},ue.add("viewport"),ue.add("view"),t.Leafer.prototype.zoom=function(t,e,i,s){let n;_(e)?(n=e.padding,i=e.scroll,s=e.transition):n=e;const{zoomLayer:o}=this,r=this.canvas.bounds.clone().shrink(a(n)?30:n),l=new qt,c={x:r.x+r.width/2,y:r.y+r.height/2};let u;o.killAnimate();const{x:f,y:m,scaleX:y,scaleY:v}=o.__,{boxBounds:w}=o;if(h(t))switch(t){case"in":u=bf(y,"in");break;case"out":u=bf(y,"out");break;case"fit":t=w;break;case"fit-width":(t=new qt(w)).height=0;break;case"fit-height":(t=new qt(w)).width=0}else d(t)&&(u=t/y);if(u)u=this.getValidScale(u),o.scaleOfWorld(c,u,u,!1,s);else if(p(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=g(t);if(n||t.tag){const e=n?t:[t];l.setListWithFn(e,yr.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:o,height:r}=t;return r||(r=o*(e.height/e.width),i=!0),o||(o=r*(e.width/e.height),i=!0),i?{x:s,y:n,width:o,height:r}:t}(t,r);l.set(o.getWorldBounds(e))}const{width:a,height:h}=l;let d=r.x-l.x,c=r.y-l.y;return i?(d+=Math.max((r.width-a)/2,0),c+=Math.max((r.height-h)/2,0)):(u=this.getValidScale(Math.min(r.width/a,r.height/h)),d+=(r.width-a*u)/2,c+=(r.height-h*u)/2,dt.scaleOf(e,l,u),l.scaleOf(l,u),e.scaleX*=u,e.scaleY*=u),"x"===i?c=0:"y"===i&&(d=0),dt.move(e,d,c),l.move(d,c),o.set(e,s),l}return o.worldBoxBounds};class Ef extends t.Group{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&m.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(e){let i;h(e)?(i={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===e&&(i.fill="white",i.stroke="rgba(0,0,0,0.2)")):i=e,this.scrollXBar||this.addMany(this.scrollXBar=new t.Box,this.scrollYBar=new t.Box),i=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},i),i.height||(i.height=i.width),this.scrollXBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},i),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:o}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(o))return;this.scrollBounds=new qt(o);const r=n.bounds.clone().shrink(i),a=r.clone().add(o),h=this.ratioX=r.width/a.width,l=this.ratioY=r.height/a.height,d=(r.x-a.x)/a.width,c=(r.y-a.y)/a.height,u=h<1,g=l<1,{scrollXBar:p,scrollYBar:_}=this,{x:f,y:m,width:y,height:v}=r.shrink([2,g?_.width+6:2,u?p.height+6:2,2]);p.set({x:f+y*d,y:m+v+2,width:Math.max(y*h,e),visible:u}),_.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:g})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:e,scrollYBar:i}=this;this.__eventIds=[e.on_(t.DragEvent.DRAG,this.onDrag,this),i.on_(t.DragEvent.DRAG,this.onDrag,this),e.on_(t.DragEvent.END,this.onDragEnd,this),i.on_(t.DragEvent.END,this.onDragEnd,this),this.target.on_(ta.BEFORE,()=>this.update(!0)),this.target.leafer.on_(Jr.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}ue.add("scroll");class Sf extends Tl{setText(t){this._text=t,this.__htmlChanged=!0}}const kf={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",hellip:"…",middot:"·",bull:"•",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",cent:"¢",pound:"£",yen:"¥",euro:"€",times:"×",divide:"÷",plusmn:"±",minus:"−",frac12:"½",frac14:"¼",frac34:"¾",sup2:"²",sup3:"³",deg:"°",reg:"®",copy:"©",trade:"™",section:"§",para:"¶",dagger:"†",Dagger:"‡",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",alpha:"α",beta:"β",gamma:"γ",delta:"δ",pi:"π",sigma:"σ",omega:"ω",Omega:"Ω",micro:"µ",infinity:"∞",not:"¬",equiv:"≡",le:"≤",ge:"≥"};t.HTMLText=class extends t.Image{get __tag(){return"HTMLText"}constructor(t){super(t)}__updateBoxBounds(){const t=this.__;if(t.__htmlChanged){const e=document.createElement("div"),{style:i}=e;i.all="initial",i.position="absolute",i.visibility="hidden",e.innerHTML=this.text,document.body.appendChild(e);const{width:s,height:n}=e.getBoundingClientRect(),o=s+10,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${n}">\n <foreignObject width="${o}" height="${n}">\n <style>\n * {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n </style>\n <body xmlns="http://www.w3.org/1999/xhtml">\n ${this.decodeText(this.text)}\n </body>\n </foreignObject>\n </svg>`;t.__setImageFill("data:image/svg+xml,"+encodeURIComponent(r)),t.__naturalWidth=o/t.pixelRatio,t.__naturalHeight=n/t.pixelRatio,t.__htmlChanged=!1,e.remove()}super.__updateBoxBounds()}__draw(t,e,i){this.textEditing&&!e.exporting||super.__draw(t,e,i)}decodeText(t){if(!t.includes("&"))return t;let e,i,s="",n=0;for(;n<t.length;){if("&"===t[n]){const o=t.indexOf(";",n+1);if(o>n+1&&(e=t.slice(n+1,o),i=kf[e],void 0!==i)){s+=i,n=o+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){h(t)?kf[t]=e:Object.assign(kf,t)}},s([Yo(Sf)],t.HTMLText.prototype,"__",void 0),s([bo("")],t.HTMLText.prototype,"text",void 0),s([fo("TextEditor")],t.HTMLText.prototype,"editInner",void 0),s([Co(!1)],t.HTMLText.prototype,"textEditing",void 0),t.HTMLText=s([Jo()],t.HTMLText),ue.add("html");class Bf extends yl{}function Tf(t){return go(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__,e="none"!==t.startArrow||"none"!==t.endArrow;t.__useArrow!==e&&So(this),t.__useArrow=e,Po(this)}}}))}t.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Jh.register(t,e)}},s([Yo(Bf)],t.Arrow.prototype,"__",void 0),s([Tf("angle")],t.Arrow.prototype,"endArrow",void 0),t.Arrow=s([Jo()],t.Arrow);const{M:Pf,L:Rf,C:Lf,Q:Cf,O:Of}=Fe,{rotate:Af,copyFrom:Df,scale:Mf}=dt,If={},Ff={layout(t,e,i,s,n,o,r){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case Pf:case Rf:Wf(t,l+1,e,i,s,n,o,r),l+=3;break;case Lf:for(h=1;h<6;h+=2)Wf(t,l+h,e,i,s,n,o,r);l+=7;break;case Cf:for(h=1;h<4;h+=2)Wf(t,l+h,e,i,s,n,o,r);l+=5;break;case Of:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),o&&(t[l+4]+=o,t[l+5]+=o),l+=7}},rotate(t,e,i){Ff.layout(t,0,0,1,1,e,i)}};function Wf(t,e,i,s,n,o,r,a){Df(If,t[e],t[e+1]),r&&Af(If,r,a),n&&Mf(If,n,o),t[e]=i+If.x,t[e+1]=s+If.y}const{layout:zf,rotate:Uf}=Ff,{getAngle:Hf}=dt,Yf={x:-.5},Nf={connect:Yf,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},Xf={connect:Yf,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},Vf={connect:Yf,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},Gf={connect:Yf,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},jf={offset:Yf,path:[...Vf.path],dashPath:[1,-2.5,0,2,-1,0]};Uf(jf.path,180,{x:-1.5,y:0});const Kf={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},qf={connect:{x:.5},path:[...Kf.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},Zf={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},Jf={path:[...Zf.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},$f=m.clone(Zf),Qf=m.clone(Jf);Uf($f.path,45),Uf(Qf.path,45);const tm={angle:Nf,"angle-side":Xf,arrow:Gf,triangle:Vf,"triangle-flip":jf,circle:qf,"circle-line":Kf,square:Jf,"square-line":Zf,diamond:Qf,"diamond-line":$f,mark:{offset:Yf,path:[1,0,-2,2,0,2]}};function em(t,e,i,s,n,o,r){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;p(e)?e.type?(h=e.scale,a=tm[e.type]):a=e:a=tm[e];const{offset:c,connect:u,path:g,dashPath:_}=a;let f=u?u.x:0,m=c?c.x:0;const y=[...g];return r&&_&&y.push(..._),"none"!==l&&(f-=.5),c&&("round"===d&&c.roundJoin?m+=c.roundJoin:"bevel"===d&&c.bevelJoin&&(m+=c.bevelJoin)),h&&zf(y,0,0,h,h),m&&zf(y,m,0),zf(y,s.x,s.y,n,n,Hf(i,s)),o.x=(f+m)*n,y}const{M:im,L:sm,C:nm,Q:om,Z:rm,N:am,D:hm,X:lm,G:dm,F:cm,O:um,P:gm,U:pm}=Fe,{copy:_m,copyFrom:fm,getDistancePoint:mm}=dt,ym={},vm={},wm={},xm={},bm={},Em={list:tm,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:o,cornerRadius:r}=t.__,a=!r;let h,l=0,d=o.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=o[l],h){case im:case sm:(c<2||l+6>=d)&&(fm(bm,o[l+1],o[l+2]),!c&&u&&_m(vm,bm)),l+=3;break;case nm:(1===c||l+7>=d-3)&&Sm(o,xm,bm,l+3),l+=7;break;case om:(1===c||l+5>=d-3)&&Sm(o,xm,bm,l+1),l+=5;break;case rm:return;case am:l+=5;break;case hm:l+=9;break;case lm:l+=6;break;case dm:l+=9;break;case cm:l+=5;break;case um:l+=7;break;case gm:l+=4;break;case pm:(1===c||l+6>=d-3)&&(Sm(o,xm,bm,l+1),l+6!==d&&(bm.x-=(bm.x-xm.x)/10,bm.y-=(bm.y-xm.y)/10)),l+=6}if(c++,1===c&&h!==im)return;if(2===c&&u&&_m(wm,h===sm?bm:xm),l===d){const r=t.__.__pathForRender=a?[...o]:o,d=t.__.__pathForArrow=[];if(u){const i=em(t,e,wm,vm,s,ym,!!n);n?d.push(...i):r.push(...i),ym.x&&(mm(vm,wm,-ym.x,!0),r[1]=wm.x,r[2]=wm.y)}if(i&&"none"!==i){const e=em(t,i,xm,bm,s,ym,!!n);if(n?d.push(...e):r.push(...e),ym.x){let t;switch(mm(bm,xm,-ym.x,!0),h){case sm:t=l-3+1;break;case nm:t=l-7+5;break;case om:t=l-5+3;break;case pm:t=l-6+3}t&&km(r,xm,t)}}}else _m(xm,bm)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function Sm(t,e,i,s){fm(e,t[s],t[s+1]),fm(i,t[s+2],t[s+3])}function km(t,e,i){t[i]=e.x,t[i+1]=e.y}ue.add("arrow"),t.UI.addAttr("startArrow","none",Tf),t.UI.addAttr("endArrow","none",Tf),Object.assign(Jh,Em),Object.assign($h,{strokeArrow(t,e,i,s){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});t.Flow=class extends t.Box{get __tag(){return"Flow"}constructor(t){super(t),this.__hasAutoLayout=!0}},s([Yo(class extends _l{})],t.Flow.prototype,"__",void 0),s([vo("x")],t.Flow.prototype,"flow",void 0),t.Flow=s([Jo()],t.Flow);const Bm={},Tm={"top-left":"from",top:"center","top-right":"to",right:"to","bottom-right":"to",bottom:"center","bottom-left":"from",left:"from",center:"center","baseline-left":"from","baseline-center":"center","baseline-right":"to"},Pm={"top-left":"from",top:"from","top-right":"from",right:"center","bottom-right":"to",bottom:"to","bottom-left":"to",left:"center",center:"center","baseline-left":"to","baseline-center":"to","baseline-right":"to"};function Rm(t,e,i){const s=t.__,{contentBounds:n}=t.__layout;Pt.toPoint(i,e,n,Bm),e.x=s.__autoWidth?n.x:Bm.x,e.y=s.__autoHeight?n.y:Bm.y}const{move:Lm}=dt;function Cm(t,e,i,s,n,o){const{children:r}=t;let a,h,{x:l,start:d}=e,c=s;l+=i;for(let t=0,i=e.count;t<i;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=s+(e.height-h.height)/("center"===n?2:1)),Lm(a,l-h.x,c-h.y),l+=h.width+e.gap):i++}function Om(t,e,i){const s="width"===i?"height":"width";t[i]=Math.max(t[i],e[i]),t[s]+=t.count?e[s]+t.gap:e[s],t.list.push(e),t.count++}const Am={};function Dm(t,e){const{gap:i,flowAlign:s,flowWrap:n,__autoWidth:o,__autoHeight:r}=t.__,a=n&&(e?!o:!r);return p(i)?(Am.xGap=i.x||0,Am.yGap=i.y||0):Am.xGap=Am.yGap=u(i),Am.isAutoXGap=h(Am.xGap)&&!o,Am.isAutoYGap=h(Am.yGap)&&!r,Am.complex=a||"top-left"!==s||t.__hasGrow||Am.isAutoXGap||Am.isAutoYGap,Am.wrap=a,Am.complex&&(Am.isFitXGap="fit"===Am.xGap&&!o,Am.isFitYGap="fit"===Am.yGap&&!r,p(s)?(Am.contentAlign=s.content||"top-left",Am.rowXAlign=s.x||"from",Am.rowYAlign=s.y||"from"):(Am.contentAlign=s,Am.rowXAlign=Tm[s],Am.rowYAlign=Pm[s])),Am}function Mm(t,e){return{x:0,y:0,width:0,height:0,gap:e,start:t,count:0,grow:0}}function Im(t,e,i,s){const{count:n}=t;n>1&&(i>t[e]||s)&&(t.gap=(i-t[e])/(n-1),t[e]=i)}function Fm(t,e){return"box"===e?t.__local:t.__layout.localStrokeBounds}const{within:Wm}=F;function zm(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.width)/l,{children:u}=t;if(!(c<=0)){e.width=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__widthGrow)&&(r=Um(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.widthRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__widthGrow,n=e/i*s,r=Um(t,o=t.__flowBounds,o.width+n),e-=n-r,i-=s})}(h,a,l)}}function Um(t,e,i){const{widthRange:s,lockRatio:n}=t.__,o=s?Wm(i,s):i,r=o/e.width;return t.scaleResize(r,n?r:1),e.width=o,i-o}const{within:Hm}=F;function Ym(t,e,i,s){let n,o,r,a=0,h=e.hasRangeSize&&[],{grow:l,start:d}=e;const c=(i-e.height)/l,{children:u}=t;if(!(c<=0)){e.height=i;for(let t=0,i=e.count;t<i;t++)n=u[s?d-t:d+t],n.__.inFlow&&0!==n.__.visible?(o=n.__heightGrow)&&(r=Nm(n,n.__flowBounds,c*o),r?(a+=r,l-=o):h&&(n.__.heightRange?h.unshift(n):h.push(n))):i++;a&&function(t,e,i){let s,n,o,r;t.forEach(t=>{s=t.__heightGrow,n=e/i*s,r=Nm(t,o=t.__flowBounds,o.height+n),e-=n-r,i-=s})}(h,a,l)}}function Nm(t,e,i){const{heightRange:s,lockRatio:n}=t.__,o=s?Hm(i,s):i,r=o/e.height;return t.scaleResize(n?r:1,r),e.height=o,i-o}const{move:Xm}=dt;function Vm(t,e){const i="width",{children:s,itemBox:n}=t,o=Dm(t,!0),{complex:r,wrap:a,xGap:h,yGap:l,isAutoXGap:d,isFitXGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=d?0:h;let p,_,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(_=Fm(p,n),r?(p.__flowBounds=_,y||(y=Mm(m,g)),a&&y.count&&y.width+_.width>x&&(y.grow?zm(t,y,x,e):d&&Im(y,i,x,c),Om(u,y,i),y=Mm(m,g)),f=_.width,p.__widthGrow&&(y.grow+=p.__widthGrow,f=0,p.__.widthRange&&(y.hasRangeSize=!0)),p.__heightGrow&&Nm(p,_,b),y.width+=y.count?f+g:f,y.height=Math.max(y.height,_.height),y.count++):(Xm(p,v-_.x,w-_.y),v+=_.width+g));if(r&&y){const{isAutoYGap:s,isFitYGap:n,contentAlign:r,rowXAlign:h,rowYAlign:g}=o;y.count&&(y.grow?zm(t,y,x,e):d&&Im(y,i,x,c),a&&Om(u,y,i)),a?(s?Im(u,"height",b,n):u.height+=(u.gap=l)*(u.list.length-1),function(t,e,i,s){Rm(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=Tm[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.x=e.width-t.width,"center"===s&&(t.x/=2)}}(t,u,r,h),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],Cm(t,r,a,h,i,s),h+=r.height+e.gap}(t,u,g,e)):(Rm(t,y,r),Cm(t,y,0,y.y,g,e))}}const{move:Gm}=dt;function jm(t,e,i,s,n,o){const{children:r}=t;let a,h,{y:l,start:d}=e,c=i;l+=s;for(let t=0,s=e.count;t<s;t++)a=r[o?d-t:d+t],a.__.inFlow&&0!==a.__.visible?(h=a.__flowBounds,"from"!==n&&(c=i+(e.width-h.width)/("center"===n?2:1)),Gm(a,c-h.x,l-h.y),l+=h.height+e.gap):s++}const{move:Km}=dt;function qm(t,e){const i="height",{children:s,itemBox:n}=t,o=Dm(t,!1),{complex:r,wrap:a,xGap:h,yGap:l,isAutoYGap:d,isFitYGap:c}=o;if(!s.length)return;const u=a&&{x:0,y:0,width:0,height:0,gap:0,count:0,list:[]},g=d?0:l;let p,_,f,m,y,{x:v,y:w,width:x,height:b}=t.__layout.contentBounds;for(let o=0,h=s.length;o<h;o++)p=s[m=e?h-1-o:o],p.__.inFlow&&0!==p.__.visible&&(_=Fm(p,n),r?(p.__flowBounds=_,y||(y=Mm(m,g)),a&&y.count&&y.height+_.height>b&&(y.grow&&Ym(t,y,b,e),d&&Im(y,i,b,c),Om(u,y,i),y=Mm(m,g)),f=_.height,p.__heightGrow&&(y.grow+=p.__heightGrow,f=0,p.__.heightRange&&(y.hasRangeSize=!0)),p.__widthGrow&&Um(p,_,x),y.height+=y.count?f+g:f,y.width=Math.max(y.width,_.width),y.count++):(Km(p,v-_.x,w-_.y),w+=_.height+g));if(r&&y){const{isAutoXGap:s,isFitXGap:n,contentAlign:r,rowXAlign:l,rowYAlign:g}=o;y.count&&(y.grow&&Ym(t,y,b,e),d&&Im(y,i,b,c),a&&Om(u,y,i)),a?(s?Im(u,"width",x,n):u.width+=(u.gap=h)*(u.list.length-1),function(t,e,i,s){Rm(t,e,i);const{list:n}=e;if(n.length>1&&(s||(s=Pm[i]),"from"!==s)){let t;for(let i=0,o=n.length;i<o;i++)t=n[i],t.y=e.height-t.height,"center"===s&&(t.y/=2)}}(t,u,r,g),function(t,e,i,s){const{list:n}=e,o="reverse"===t.__.flowWrap;let r,{x:a,y:h}=e;for(let l=0,d=n.length;l<d;l++)r=n[o?d-1-l:l],jm(t,r,a,h,i,s),a+=r.width+e.gap}(t,u,l,e)):(Rm(t,y,r),jm(t,y,y.x,0,l,e))}}function Zm(t){return go(t,t=>({set(e){const i=d(e)?e:0;"autoWidth"===t?this.__widthGrow=i:this.__heightGrow=i,!i||this.parent&&this.parent.__hasGrow||this.waitParent(()=>{this.parent.__hasGrow=!0}),this.__setAttr(t,e)&&So(this)}}))}ue.add("flow","resize");const Jm=t.Box.prototype,{__updateBoxBounds:$m}=t.Group.prototype;t.UI.addAttr("flow",!1,vo),t.UI.addAttr("gap",0,bo),t.UI.addAttr("flowAlign","top-left",bo),t.UI.addAttr("flowWrap",!1,bo),t.UI.addAttr("itemBox","box",bo),t.UI.addAttr("inFlow",!0,bo),t.UI.addAttr("autoWidth",void 0,Zm),t.UI.addAttr("autoHeight",void 0,Zm),t.UI.addAttr("autoBox",void 0,bo);const{copyAndSpread:Qm}=Vt;Jm.__updateFlowLayout=function(){const{leaferIsCreated:t,flow:e}=this;switch(t&&(this.leafer.created=!1),e){case"x":case!0:Vm(this);break;case"y":qm(this);break;case"x-reverse":Vm(this,!0);break;case"y-reverse":qm(this,!0)}t&&(this.leafer.created=!0)},Jm.__updateContentBounds=function(){const{padding:t}=this.__,e=this.__layout,i=e.contentBounds===e.boxBounds;t?(i&&e.shrinkContent(),Qm(e.contentBounds,e.boxBounds,t,!0)):i||e.shrinkContentCancel()},Jm.__updateBoxBounds=function(t){if(this.children.length&&!this.pathInputed){const e=this.__,{flow:i}=e;if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),i&&!t?this.__updateRectBoxBounds():$m.call(this);const{boxBounds:s}=this.__layout;e.__autoSize||(e.__autoWidth?(i||(s.width+=s.x,s.x=0),s.height=e.height,s.y=0):(i||(s.height+=s.y,s.y=0),s.width=e.width,s.x=0)),i&&t&&e.padding&&Qm(s,s,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();i&&this.__updateContentBounds()}else this.__updateRectBoxBounds()};const{cos:ty,sin:ey,pow:iy,sqrt:sy,abs:ny,ceil:oy,floor:ry,round:ay,PI:hy}=Math,ly=5*hy,dy=1.70158,cy=2.5949095,uy=7.5625,gy=2.75;function py(t){return e=>iy(e,t)}function _y(t){return e=>1-iy(1-e,t)}function fy(t){return e=>e<.5?.5*iy(2*e,t):1-.5*iy(2-2*e,t)}function my(t){return t<1/gy?uy*t*t:t<2/gy?uy*(t-=1.5/gy)*t+.75:t<2.5/gy?uy*(t-=2.25/gy)*t+.9375:uy*(t-=2.625/gy)*t+.984375}function yy(t,e,i,s){const n={};return o=>{const r=~~(1e4*o),a=n[r];if(a)return a;let h,l,d,c=o;for(let e=0;e<8&&(h=1-c,d=vy(c,t,i)-o,l=3*h*h*t+6*h*c*(i-t)+3*c*c*(1-i),!(ny(l)<1e-6));e++)c-=d/l;return n[r]=vy(c,e,s)}}function vy(t,e,i){const s=1-t;return 3*s*s*t*e+3*s*t*t*i+t*t*t}const wy={get(t){const{list:e}=wy;return h(t)?e[t||"ease"]:p(t)?e[t.name].apply(e,g(t.value)?t.value:[t.value]):e.ease},register(t,e){wy.list[t]=e},list:{linear:t=>t,ease:yy(.25,.1,.25,1),"ease-in":yy(.42,0,1,1),"ease-out":yy(0,0,.58,1),"ease-in-out":yy(.42,0,.58,1),"sine-in":t=>1-ty(t*hy*.5),"sine-out":t=>ey(t*hy*.5),"sine-in-out":t=>.5*(1-ty(t*hy)),"quad-in":py(2),"quad-out":_y(2),"quad-in-out":fy(2),"cubic-in":py(3),"cubic-out":_y(3),"cubic-in-out":fy(3),"quart-in":py(4),"quart-out":_y(4),"quart-in-out":fy(4),"quint-in":py(5),"quint-out":_y(5),"quint-in-out":fy(5),"expo-in":t=>t?iy(2,10*t-10):0,"expo-out":t=>1===t?1:1-iy(2,10*-t),"expo-in-out":t=>0===t||1===t?t:t<.5?.5*iy(2,2*t*10-10):.5*(2-iy(2,10-2*t*10)),"circ-in":t=>1-sy(1-iy(t,2)),"circ-out":t=>sy(1-iy(t-1,2)),"circ-in-out":t=>t<.5?.5*(1-sy(1-iy(2*t,2))):.5*(sy(1-iy(2-2*t,2))+1),"back-in":t=>((dy+1)*t-dy)*t*t,"back-out":t=>(t-=1)*t*((dy+1)*t+dy)+1,"back-in-out":t=>t<.5?(t*=2)*t*((cy+1)*t-cy)*.5:.5*((t=2*t-2)*t*((cy+1)*t+cy)+2),"elastic-in":t=>0===t||1===t?t:-iy(2,10*(t-1))*ey((t-1.1)*ly),"elastic-out":t=>0===t||1===t?t:iy(2,-10*t)*ey((t-.1)*ly)+1,"elastic-in-out":t=>0===t||1===t?t:t<.5?-iy(2,10*((t*=2)-1))*ey((t-1.1)*ly)*.5:iy(2,10*(1-(t*=2)))*ey((t-1.1)*ly)*.5+1,"bounce-in":t=>1-my(1-t),"bounce-out":my,"bounce-in-out":t=>t<.5?.5*(1-my(1-2*t)):.5*(1+my(2*t-1)),"cubic-bezier":yy,steps:function(t,e="floor"){return i=>("floor"===e?ry(i*t):"ceil"===e?oy(i*t):ay(i*t))/t}}};function xy(t){return(e,i)=>{Object.defineProperty(e,i,{get(){const e=this.config&&this.config[i];return void 0===e?t:e},set(t){this.config||(this.config={}),this.config[i]=t}})}}class by{}by.CREATED="created",by.PLAY="play",by.PAUSE="pause",by.STOP="stop",by.SEEK="seek",by.UPDATE="update",by.COMPLETED="completed";t.Animate=class extends ha{get endingStyle(){return"from"===this.realEnding?this.fromStyle:this.toStyle}get started(){return!!this.requestAnimateTime}get completed(){return this.time>=this.duration&&!this.started}get frame(){return this.frames[this.nowIndex]}get frameTotalTime(){return this.frame.totalTime||this.frame.duration||0}get nowReverse(){return(this.mainReverse?1:0)+(this.frameReverse?1:0)==1}get realEnding(){let t;const{ending:e,reverse:i,swing:s,loop:n}=this;return"from"===e?t=0:"to"===e?t=1:(t=i?0:1,s&&n&&d(n)&&(t+=n-1)),t%2?"to":"from"}constructor(t,e,i,s){super(),this.nowIndex=0,this.playedTotalTime=0,e&&(e.keyframes?(i=e,e=e.keyframes):e.style&&(i=e,e=e.style)),this.init(t,e,i,s)}init(t,e,i,s){switch(this.target=t,(s||this.isTemp)&&(this.isTemp=s),typeof i){case"number":this.config={duration:i};break;case"string":this.config={easing:i};break;case"object":this.config=i,i.event&&(this.event=i.event)}this.keyframes=g(e)?e:e?[e]:[];const{easing:n,attrs:o}=this;this.easingFn=wy.get(n),(o||this.attrsMap)&&(this.attrsMap=o?o.reduce((t,e)=>(t[e]=!0,t),{}):void 0),this.frames=[],this.create(),this.autoplay&&this.frames.length&&(this.timer=setTimeout(()=>{this.timer=0,this.play()},0))}emitType(t){this.emit(t,this),this.parent&&this.parent.onChildEvent(t,this)}play(){this.destroyed||(this.running=!0,this.started?this.timer||this.startRequestAnimate():(this.clearTimer(),this.start()),this.emitType(by.PLAY))}pause(){this.destroyed||(this.running=!1,this.clearTimer(),this.emitType(by.PAUSE))}stop(){this.destroyed||(this.complete(),this.emitType(by.STOP))}seek(t,e){if(this.destroyed)return;const{delay:i}=this;let s;p(t)&&(t=Zh.number(t,this.duration+(e?i:0))),e&&(t-=i),t&&(t/=this.speed),t<0&&(s=-t,t=0),(!this.started||t<this.time||!t)&&this.start(!0),this.time=t,s||this.animate(0,!0),this.clearTimer(()=>{s?this.timer=setTimeout(()=>{this.timer=0,this.begin()},1e3*s):this.startRequestAnimate()}),this.emitType(by.SEEK)}kill(t=!0,e){this.killStyle=e,this.destroy(t)}create(){const{target:t,frames:e,keyframes:i,config:s}=this,{length:n}=i,o=!(n>1)||this.join;let a,h,l,c,u,g=0,p=0;n>1&&(this.fromStyle={},this.toStyle={});for(let s=0;s<n;s++){if(h=i[s],c=h.style||h,a||(a=o?t:c),l={style:c,beforeStyle:{}},u=1,h.style){const{duration:t,autoDuration:e,delay:i,autoDelay:s,easing:n,swing:o,loop:r}=h;o&&(l.swing=d(o)?o:2,u=2*l.swing-1),r&&(l.loop=u=d(r)?r:2),t?(l.duration=t,g+=t*u,i&&(l.totalTime=t+i)):e&&(l.autoDuration=e,p+=e*u),i?(l.delay=i,g+=i*u):s&&(l.autoDelay=s,p+=s*u),n&&(l.easingFn=wy.get(n))}if(!l.autoDuration&&r(l.duration)&&(n>1?s>0||o?p+=u:l.duration=0:l.duration=this.duration),n>1)this.setBefore(l,c,a);else{for(let e in c)l.beforeStyle[e]=t[e];this.fromStyle=l.beforeStyle,this.toStyle=l.style}a=c,e.push(l)}p?((this.duration<=g||!s||!s.duration)&&this.changeDuration(g+.2*p),this.allocateTime((this.duration-g)/p)):g&&this.changeDuration(g),this.emitType(by.CREATED)}changeDuration(t){const{config:e}=this;this.config=e?Object.assign(Object.assign({},e),{duration:t}):{duration:t}}setBefore(t,e,i){const{fromStyle:s,toStyle:n,target:o}=this;for(let a in e)r(s[a])&&(s[a]=n[a]=e===i?i[a]:o[a]),t.beforeStyle[a]=r(i[a])?n[a]:i[a],n[a]=e[a]}allocateTime(t){let e,{frames:i}=this,{length:s}=i;for(let n=0;n<s;n++)e=i[n],r(e.duration)&&(e.duration=e.autoDuration?t*e.autoDuration:t),e.totalTime||(e.autoDelay&&(e.delay=e.autoDelay*t),e.delay&&(e.totalTime=e.duration+e.delay))}startRequestAnimate(){this.requestAnimateTime=Date.now(),this.requestAnimatePageTime=0,this.waitRequestRender||this.requestAnimate()}requestAnimate(){this.waitRequestRender=!0,ie.requestRender(this.animate.bind(this))}animate(t,e){if(!e){if(this.waitRequestRender=!1,!this.running)return;let e;e=t&&this.requestAnimatePageTime?t-this.requestAnimatePageTime:Date.now()-this.requestAnimateTime,this.time+=e/1e3,this.requestAnimatePageTime=t,this.requestAnimateTime=Date.now()}const{duration:i}=this,s=this.time*this.speed;if(s<i){for(;s-this.playedTotalTime>this.frameTotalTime;)this.transition(1),this.mainReverse?this.reverseNextFrame():this.nextFrame();const t=this.nowReverse?0:this.frame.delay||0,e=s-this.playedTotalTime-t,i=this.frame.duration;if(e>i)this.transition(1);else if(e>=0){const t=i?e/i:1;this.transition(this.frame.easingFn?this.frame.easingFn(t):this.easingFn(t))}}else this.end();if(!e)if(s<i)this.requestAnimate();else{const{loop:t,loopDelay:e,swing:i}=this;if((!1!==t||i)&&(this.looped?this.looped++:this.looped=1,this.needLoop(this.looped,t,i)))return i&&(this.mainReverse=!this.mainReverse),void(e?this.timer=setTimeout(()=>{this.timer=0,this.begin()},e/this.speed*1e3):this.begin());this.complete()}}start(t){this.requestAnimateTime=1;const{reverse:e,jump:i}=this;if((e||this.mainReverse)&&(this.mainReverse=e),this.looped&&(this.looped=0),t)this.begin(!0);else{const{delay:t}=this;t?(i&&this.begin(!0),this.timer=setTimeout(()=>{this.timer=0,this.begin()},t/this.speed*1e3)):this.begin()}}begin(t){this.playedTotalTime=this.time=0,this.mainReverse?this.setTo():this.setFrom(),t||this.startRequestAnimate()}end(){this.mainReverse?this.setFrom():this.setTo()}complete(){this.requestAnimateTime=0,this.running=!1;const{endingStyle:t,killStyle:e}=this,i=e?{}:t;if(e)for(let s in t)s in e||(i[s]=t[s]);this.setStyle(i),this.clearTimer(),this.emitType(by.COMPLETED)}setFrom(){this.nowIndex=0,this.setStyle(this.fromStyle)}setTo(){this.nowIndex=this.frames.length-1,this.setStyle(this.toStyle)}nextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex+1>=this.frames.length||(this.increaseTime(),this.nowIndex++)}reverseNextFrame(){if(this.needLoopFrame())return this.increaseTime();this.nowIndex-1<0||(this.increaseTime(),this.nowIndex--)}transition(t){const{style:e,beforeStyle:i}=this.frame,s=this.nowReverse?e:i,n=this.nowReverse?i:e;if(0===t)this.setStyle(s);else if(1===t)this.setStyle(n);else{const{attrsMap:i,target:o}=this;let{betweenStyle:r}=this.frame;r||(r=this.frame.betweenStyle={}),ol.setBetweenStyle(r,s,n,e,t,o,i),this.setStyle(r)}this.emitType(by.UPDATE)}setStyle(t){const{target:e}=this;e&&t&&(this.style=t,e.__?e.set(t,!!this.isTemp&&"temp"):Object.assign(e,t))}increaseTime(){this.playedTotalTime+=this.frameTotalTime}needLoop(t,e,i){return!(this.needStopLoop(t,e)||this.needStopLoop(t,i,!0))}needStopLoop(t,e,i){return d(e)&&(!e||t>=(i?2*e-1:e))}needLoopFrame(){const{loop:t,swing:e}=this.frame;if(t||e){if(this.frameLooped?this.frameLooped++:this.frameLooped=1,e&&(this.frameReverse=!this.frameReverse),this.needLoop(this.frameLooped,t,e))return!0;this.frameLooped=this.frameReverse=void 0}return!1}clearTimer(t){this.timer&&(clearTimeout(this.timer),this.timer=0,t&&t())}destroy(t){this.destroyed||(super.destroy(),t&&!this.completed?this.stop():this.pause(),this.target=this.parent=this.config=this.frames=this.fromStyle=this.toStyle=this.style=this.killStyle=null,this.destroyed=!0)}},s([xy("ease")],t.Animate.prototype,"easing",void 0),s([xy(0)],t.Animate.prototype,"delay",void 0),s([xy(.2)],t.Animate.prototype,"duration",void 0),s([xy("auto")],t.Animate.prototype,"ending",void 0),s([xy(!1)],t.Animate.prototype,"reverse",void 0),s([xy(!1)],t.Animate.prototype,"swing",void 0),s([xy(!1)],t.Animate.prototype,"loop",void 0),s([xy(0)],t.Animate.prototype,"loopDelay",void 0),s([xy(1)],t.Animate.prototype,"speed",void 0),s([xy(!0)],t.Animate.prototype,"autoplay",void 0),s([xy()],t.Animate.prototype,"join",void 0),s([xy()],t.Animate.prototype,"jump",void 0),s([xy()],t.Animate.prototype,"attrs",void 0),t.Animate=s([Zo(va)],t.Animate),t.AnimateList=class extends t.Animate{get completed(){return this.list.every(t=>t.completed)}get endingStyle(){return this._endingStyle}constructor(t,e,i){super(t,null),this.list=[],this.updateList(e,i)}updateList(e,i){this.fromStyle={},this.toStyle={},this._endingStyle={},e||(e=this.list.filter(t=>{const{completed:e}=t;return e&&t.destroy(),!e})),this.list=e.map(e=>{const s=e.target?e:new t.Animate(this.target,e,i);return s.parent=this,Object.assign(this.fromStyle,s.fromStyle),Object.assign(this.toStyle,s.toStyle),Object.assign(this._endingStyle,s.endingStyle),s})}play(){this.each(t=>t.play()),this.emitType(by.PLAY)}pause(){this.each(t=>t.pause()),this.emitType(by.PAUSE)}stop(){this.each(t=>t.stop()),this.emitType(by.STOP)}seek(t,e){this.each(i=>i.seek(t,e)),this.emitType(by.SEEK)}kill(t,e){this.each(i=>i.kill(t,e)),this.destroy()}onChildEvent(t,e){switch(t){case by.COMPLETED:this.completed&&this.emitType(t);break;case by.UPDATE:this.emitType(t)}}each(t){this.list.forEach(t)}destroy(t){const{list:e}=this;e.length&&(this.each(e=>e.destroy(t)),e.length=0)}},t.AnimateList=s([Zo(va)],t.AnimateList);const Ey={transparent:"FFF0",aliceblue:"F0F8FF",antiquewhite:"FAEBD7",aqua:"0FF",aquamarine:"7FFFD4",azure:"F0FFFF",beige:"F5F5DC",bisque:"FFE4C4",black:"0",blanchedalmond:"FFEBCD",blue:"00F",blueviolet:"8A2BE2",brown:"A52A2A",burlywood:"DEB887",cadetblue:"5F9EA0",chartreuse:"7FFF00",chocolate:"D2691E",coral:"FF7F50",cornflowerblue:"6495ED",cornsilk:"FFF8DC",crimson:"DC143C",cyan:"0FF",darkblue:"00008B",darkcyan:"008B8B",darkgoldenrod:"B8860B",darkgray:"A9",darkgreen:"006400",darkgrey:"A9",darkkhaki:"BDB76B",darkmagenta:"8B008B",darkolivegreen:"556B2F",darkorange:"FF8C00",darkorchid:"9932CC",darkred:"8B0000",darksalmon:"E9967A",darkseagreen:"8FBC8F",darkslateblue:"483D8B",darkslategray:"2F4F4F",darkslategrey:"2F4F4F",darkturquoise:"00CED1",darkviolet:"9400D3",deeppink:"FF1493",deepskyblue:"00BFFF",dimgray:"69",dimgrey:"69",dodgerblue:"1E90FF",firebrick:"B22222",floralwhite:"FFFAF0",forestgreen:"228B22",fuchsia:"F0F",gainsboro:"DC",ghostwhite:"F8F8FF",gold:"FFD700",goldenrod:"DAA520",gray:"80",green:"008000",greenyellow:"ADFF2F",grey:"80",honeydew:"F0FFF0",hotpink:"FF69B4",indianred:"CD5C5C",indigo:"4B0082",ivory:"FFFFF0",khaki:"F0E68C",lavender:"E6E6FA",lavenderblush:"FFF0F5",lawngreen:"7CFC00",lemonchiffon:"FFFACD",lightblue:"ADD8E6",lightcoral:"F08080",lightcyan:"E0FFFF",lightgoldenrodyellow:"FAFAD2",lightgray:"D3",lightgreen:"90EE90",lightgrey:"D3",lightpink:"FFB6C1",lightsalmon:"FFA07A",lightseagreen:"20B2AA",lightskyblue:"87CEFA",lightslategray:"789",lightslategrey:"789",lightsteelblue:"B0C4DE",lightyellow:"FFFFE0",lime:"00FF00",limegreen:"32CD32",linen:"FAF0E6",magenta:"FF00FF",maroon:"800000",mediumaquamarine:"66CDAA",mediumblue:"0000CD",mediumorchid:"BA55D3",mediumpurple:"9370DB",mediumseagreen:"3CB371",mediumslateblue:"7B68EE",mediumspringgreen:"00FA9A",mediumturquoise:"48D1CC",mediumvioletred:"C71585",midnightblue:"191970",mintcream:"F5FFFA",mistyrose:"FFE4E1",moccasin:"FFE4B5",navajowhite:"FFDEAD",navy:"000080",oldlace:"FDF5E6",olive:"808000",olivedrab:"6B8E23",orange:"FFA500",orangered:"FF4500",orchid:"DA70D6",palegoldenrod:"EEE8AA",palegreen:"98FB98",paleturquoise:"AFEEEE",palevioletred:"D87093",papayawhip:"FFEFD5",peachpuff:"FFDAB9",peru:"CD853F",pink:"FFC0CB",plum:"DDA0DD",powderblue:"B0E0E6",purple:"800080",rebeccapurple:"639",red:"F00",rosybrown:"BC8F8F",royalblue:"4169E1",saddlebrown:"8B4513",salmon:"FA8072",sandybrown:"F4A460",seagreen:"2E8B57",seashell:"FFF5EE",sienna:"A0522D",silver:"C0",skyblue:"87CEEB",slateblue:"6A5ACD",slategray:"708090",slategrey:"708090",snow:"FFFAFA",springgreen:"00FF7F",steelblue:"4682B4",tan:"D2B48C",teal:"008080",thistle:"D8BFD8",tomato:"FF6347",turquoise:"40E0D0",violet:"EE82EE",wheat:"F5DEB3",white:"F",whitesmoke:"F5",yellow:"FF0",yellowgreen:"9ACD32"},Sy=/^rgb\((\d+),\s*(\d+),\s*(\d+)/i,ky=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d*\.?\d+)/i,By=/^hsl\((\d+),\s*(\d+)%\s*,\s*(\d+)%/i,Ty=/^hsla\((\d+),\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d*\.?\d+)/i,Py=parseInt,Ry=parseFloat,{round:Ly}=Math;let Cy={},Oy=0;function Ay(t){let e,i,s,n=1;switch(t.length){case 9:e=Py(t.slice(1,3),16),i=Py(t.slice(3,5),16),s=Py(t.slice(5,7),16),n=Py(t.slice(7,9),16)/255;break;case 7:e=Py(t.slice(1,3),16),i=Py(t.slice(3,5),16),s=Py(t.slice(5,7),16);break;case 5:e=Py(t[1]+t[1],16),i=Py(t[2]+t[2],16),s=Py(t[3]+t[3],16),n=Py(t[4]+t[4],16)/255;break;case 4:e=Py(t[1]+t[1],16),i=Py(t[2]+t[2],16),s=Py(t[3]+t[3],16);break;case 3:e=i=s=Py(t[1]+t[2],16);break;case 2:e=i=s=Py(t[1]+t[1],16)}return{r:e,g:i,b:s,a:n}}const Dy=1/6,My=.5,Iy=2/3,Fy=1/3;function Wy(t,e,i){return i<0?i++:i>1&&i--,i<Dy?t+6*(e-t)*i:i<My?e:i<Iy?t+(e-t)*(Iy-i)*6:t}function zy(t,e,i,s=1){let n,o,r;if(t/=360,i/=100,0===(e/=100))n=o=r=i;else{let s=i<.5?i*(1+e):i+e-i*e,a=2*i-s;n=Wy(a,s,t+Fy),o=Wy(a,s,t),r=Wy(a,s,t-Fy)}return{r:Ly(255*n),g:Ly(255*o),b:Ly(255*r),a:s}}ue.add("color"),qh.object=function(t,e){let i,s=!r(e)&&e<1;if(h(t)){const e=Cy[t];if(e)i=Object.assign({},e);else{switch(t[0]){case"#":i=Ay(t);break;case"R":case"r":"("===t[4]&&ky.test(t)?i=function(t){const e=ky.exec(t);return{r:Py(e[1]),g:Py(e[2]),b:Py(e[3]),a:Ry(e[4])}}(t):"("===t[3]&&Sy.test(t)&&(i=function(t){const e=Sy.exec(t);return{r:Py(e[1]),g:Py(e[2]),b:Py(e[3]),a:1}}(t));break;case"H":case"h":"("===t[4]&&Ty.test(t)?i=function(t){const e=Ty.exec(t);return zy(Ry(e[1]),Ry(e[2]),Ry(e[3]),Ry(e[4]))}(t):"("===t[3]&&By.test(t)&&(i=function(t){const e=By.exec(t);return zy(Ry(e[1]),Ry(e[2]),Ry(e[3]),1)}(t))}if(!i){const e=Ey[t.toLowerCase()];e&&(i=Ay("#"+e))}i&&(Oy++,Oy>1e4&&(Cy={},Oy=0),Cy[t]=Object.assign({},i))}}else p(t)&&(r(t.a)&&(t.a=1),s&&(t=Object.assign({},t)),i=t);return i||(i={r:255,g:255,b:255,a:1}),s&&(i.a*=e),i};const{round:Uy}=Math,{fourNumber:Hy}=F,Yy={fill:jy,stroke:jy,cornerRadius:(t,e,i)=>d(t)&&d(e)?Vy(t,e,i):(t=Hy(t),e=Hy(e),t.map((t,s)=>Vy(t,e[s],i))),text(t,e,i){if(h(t)&&h(e)){const s=t.length,n=e.length,o=Vy(s,n,i,1);return s<n?e.substring(0,o):t.substring(0,o)}return d(t)||d(e)?F.float(Vy(t,e,i),Math.max(Xy(t),Xy(e))):e},boxStyle(t,e,i,s){t||(t={}),e||(e={});const n=Object.assign(Object.assign({},t),e);return ol.setBetweenStyle(n,t,e,n,i,s),n},shadow:Ky,innerShadow:Ky},Ny={value:function(t,e,i){const s=d(t),n=d(e);return s&&n?t+(e-t)*i:n||s?Vy(t,e,i):t},number:Vy,color:Gy,setBetweenStyle:function(t,e,i,s,n,o,r){let a,h,l;const{list:d,value:c}=ol;for(let u in s)r&&!r[u]||(a=e[u],h=i[u],l=d[u]||c,a!==h&&(t[u]=l(a,h,n,o)))}};function Xy(t){const e=String(t).split(".")[1];return e?e.length:0}function Vy(t,e,i,s){t||(t=0),e||(e=0);const n=t+(e-t)*i;return s?Uy(n):n}function Gy(t,e,i){t=qh.object(t),e=qh.object(e);const s=Vy(t.r,e.r,i,1)+","+Vy(t.g,e.g,i,1)+","+Vy(t.b,e.b,i,1),n=Vy(t.a,e.a,i);return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}function jy(t,e,i){return h(t)&&h(e)?Gy(t,e,i):e}function Ky(t,e,i){return g(t)||g(e)?e:(e=e||{},{x:Vy((t=t||{}).x,e.x,i),y:Vy(t.y,e.y,i),blur:Vy(t.blur,e.blur,i),spread:Vy(t.spread,e.spread,i),color:Gy(t.color||"#FFFFFF00",e.color||"#FFFFFF00",i),visible:e.visible,blendMode:e.blendMode,box:e.box||t.box})}ue.add("animate","color"),nl.canAnimate=!0,Object.assign(ol.list,Yy),Object.assign(ol,Ny);const qy=t.UI.prototype;t.UI.addAttr("animation",void 0,function(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&(this.killAnimate("animation"),e&&this.animate(e,void 0,"animation"))}}))}),t.UI.addAttr("animationOut",void 0,fo),t.UI.addAttr("transition",!0,fo),t.UI.addAttr("transitionOut",void 0,fo),qy.set=function(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))},qy.animate=function(e,i,s,n){if(r(e))return this.__animate;let o=g(e)&&!i&&s?new t.AnimateList(this,e,n):new t.Animate(this,e,i,n);this.killAnimate(s,o.toStyle);const a=this.__animate;return a&&(o instanceof t.AnimateList?o.list.unshift(a):o=new t.AnimateList(this,[a,o])),this.__animate=o},qy.killAnimate=function(e,i){const s=this.__animate;if(s){let e=!1;if(i&&!s.completed){s instanceof t.AnimateList&&s.updateList();const{toStyle:n}=s;for(let t in i)if(t in n){e=!0;break}}else e=!0;e&&(s.kill(!0,i),this.__animate=null)}},qy.__runAnimation=function(t,e){this.animate("in"===t?this.animation:this.animationOut,void 0,"animation"),e&&this.__animate.on(by.COMPLETED,e)};const Zy=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],Jy=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:$y}=Math,{getDerivative:Qy}=di,tv={getDistance(t,e,i,s,n,o,r,a,h=1){let l,d,c,u,g,p,_=0,f=h/2;for(let h=0;h<Zy.length;h++)l=f*(1+Zy[h]),d=f*(1-Zy[h]),c=Qy(l,t,i,n,r),u=Qy(l,e,s,o,a),g=Qy(d,t,i,n,r),p=Qy(d,e,s,o,a),_+=Jy[h]*($y(c*c+u*u)+$y(g*g+p*p));return _*f},getRotation(t,e,i,s,n,o,r,a,h){const l=Qy(t,e,s,o,a),d=Qy(t,i,n,r,h);return Math.atan2(d,l)/z},getT(t,e,i,s,n,o,r,a,h,l,d=1){let c=0,u=1,g=t/e,p=d/e/3;if(g>=1)return 1;if(g<=0)return 0;for(;u-c>p;)ev(i,s,n,o,r,a,h,l,g)<t?c=g:u=g,g=(c+u)/2;return g},cut(t,e,i,s,n,o,r,a,h,l){const d=1-e,c=d*i+e*n,u=d*s+e*o,g=d*n+e*r,p=d*o+e*a,_=d*c+e*g,f=d*u+e*p,m=d*_+e*(d*g+e*(d*r+e*h)),y=d*f+e*(d*p+e*(d*a+e*l));t.push(Fe.C,c,u,_,f,m,y)}},{getDistance:ev}=tv,{M:iv,L:sv,C:nv,Z:ov}=Fe,{float:rv}=F,av={},hv={},lv={transform(t,e){let i,s=0;const n=t.length;for(;s<n;)switch(i=t[s],i){case iv:case sv:lv.transformPoints(t,e,s,1),s+=3;break;case nv:lv.transformPoints(t,e,s,3),s+=7;break;case ov:s+=1}},transformPoints(t,e,i,s){for(let n=i+1,o=n+2*s;n<o;n+=2)av.x=t[n],av.y=t[n+1],$.toOuterPoint(e,av),t[n]=av.x,t[n+1]=av.y},getMotionPathData(t){let e,i,s,n,o=0,r=[],a=0,h=0,l=0;const d=t.length;for(;a<d;){switch(n=t[a],n){case iv:case sv:i=t[a+1],s=t[a+2],e=n===sv&&a>0?dt.getDistanceFrom(h,l,i,s):0,h=i,l=s,a+=3;break;case nv:i=t[a+5],s=t[a+6],e=tv.getDistance(h,l,t[a+1],t[a+2],t[a+3],t[a+4],i,s),h=i,l=s,a+=7;break;case ov:a+=1;default:e=0}r.push(e),o+=e}return{total:o,segments:r,data:t}},getDistancePoint(t,e,i){const{segments:s,data:n}=t;e=Zh.number(e,t.total);let o,r,a,h,l,d,c,u,g,p=0,_={},f=0,m=0,y=0,v=0;const w=n.length;for(;f<w;){switch(h=n[f],h){case iv:case sv:if(r=n[f+1],a=n[f+2],o=s[m],p+o>=e||!t.total)return f||(y=r,v=a),hv.x=y,hv.y=v,_.x=r,_.y=a,dt.getDistancePoint(hv,_,e-p,!0),_.rotation=dt.getAngle(hv,_),_;y=r,v=a,f+=3;break;case nv:if(r=n[f+5],a=n[f+6],o=s[m],p+o>=e)return l=n[f+1],d=n[f+2],c=n[f+3],u=n[f+4],g=tv.getT(e-p,o,y,v,l,d,c,u,r,a,i),di.getPointAndSet(g,y,v,l,d,c,u,r,a,_),_.rotation=tv.getRotation(g,y,v,l,d,c,u,r,a),_;y=r,v=a,f+=7;break;case ov:f+=1;default:o=0}m++,p+=o}return _},getDistancePath(t,e,i){const{segments:s,data:n}=t,o=[];e=Zh.number(e,t.total);let r,a,h,l,d,c,u,g,p,_,f=0,m={},y=0,v=0,w=0,x=0;const b=n.length;for(;y<b;){switch(d=n[y],d){case iv:case sv:if(h=n[y+1],l=n[y+2],r=s[v],f+r>e||!t.total)return y||(w=h,x=l),hv.x=w,hv.y=x,m.x=h,m.y=l,a=rv(e-f),a&&(dt.getDistancePoint(hv,m,a,!0),o.push(d,m.x,m.y)),o;w=h,x=l,y+=3,o.push(d,w,x);break;case nv:if(c=n[y+1],u=n[y+2],g=n[y+3],p=n[y+4],h=n[y+5],l=n[y+6],r=s[v],f+r>e)return a=rv(e-f),a&&(_=tv.getT(a,r,w,x,c,u,g,p,h,l,i),tv.cut(o,_,w,x,c,u,g,p,h,l)),o;w=h,x=l,y+=7,o.push(d,c,u,g,p,h,l);break;case ov:y+=1,o.push(d);default:r=0}v++,f+=r}return o}};function dv(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!a(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}}))}ue.add("motion-path"),ol.register("motion",function(t,e,i,s){return p(t)&&(t=Zh.number(t,s.getMotionTotal())),p(e)&&(e=Zh.number(e,s.getMotionTotal())),ol.number(t||0,e||0,i)}),ol.register("motionRotation",function(t,e,i){return ol.number(t,e,i)});const cv=t.UI.prototype,{updateMatrix:uv,updateAllMatrix:gv}=dr,{updateBounds:pv}=br;function _v(t){const{motion:e,leaferIsCreated:i}=t;if(!a(e)){if(i&&(t.leafer.created=!1),t.motionPath){const i=mv(t);i.total&&(t.__.__pathForRender=lv.getDistancePath(i,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(gv(t),pv(t,t)):uv(t));i&&(t.leafer.created=!0)}}function fv(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function mv(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=lv.getMotionPathData(t.getPath(!0,!0))}function yv(t,e){return go(t,t=>({set(i){this.__setAttr(t,i),this.leaferIsReady?e?nl.setStyleName(this,e,i):nl.set(this,i):this.__layout.stateStyleChanged=!0}}))}function vv(t){return go(t,t=>({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}}))}function wv(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function xv(t,e){p(e)||(e=void 0),Sv(t,e,"in")}function bv(t,e){const{normalStyle:i}=t;p(e)||(e=void 0),i&&(e||(e=i),Sv(t,e,"out"))}t.UI.addAttr("motionPath",void 0,dv),t.UI.addAttr("motionPrecision",1,dv),t.UI.addAttr("motion",void 0,dv),t.UI.addAttr("motionRotation",!0,dv),cv.getMotionPathData=function(){return mv(fv(this))},cv.getMotionPoint=function(t){const e=fv(this),i=mv(e);if(!i.total)return{};const s=lv.getDistancePoint(i,t,e.motionPrecision);$.toOuterPoint(e.localTransform,s);const{motionRotation:n}=this;return!1===n?delete s.rotation:d(n)&&(s.rotation+=n),s},cv.getMotionTotal=function(){return this.getMotionPathData().total},cv.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent;for(let i=0;i<e.length;i++)t=e[i],a(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),_v(t))}else _v(this)};const Ev={};function Sv(t,e,i){const{normalStyle:s}=t;e||(e=Ev),e.scale&&(F.assignScale(e,e.scale),delete e.scale),e!==Ev&&nl.canAnimate||(i=null);let n=!!i&&function(t,e,i){let s="in"===t?"transition":"transitionOut";"out"===t&&a(i[s])&&a(e[s])&&(s="transition");return a(e[s])?i[s]:e[s]}(i,e,t);const o=n?function(t,e){const i=Tv(e,t),s=t.animate();s&&Tv(i,t,s.fromStyle);return i}(t,e):void 0;nl.canAnimate&&kv(t)&&t.killAnimate("transition"),s&&t.set(s,"temp");const r=kv(t);if(r){const{animation:s}=r;if(s){const o=t.animate(s,void 0,"animation",!0);Object.assign(r,o.endingStyle),"in"!==i||e.animation!==s?o.kill():n=!1,delete r.animation}t.normalStyle=Bv(r,t),t.set(r,"temp")}else t.normalStyle=void 0;if(n){const e=Bv(o,t);t.set(o,"temp"),t.animate([o,e],n,"transition",!0)}t.__layout.stateStyleChanged=!1}function kv(t){let e;const i={},s=wv(t),n=s?t.state||s.state:t.state,o=n&&t.states[n];o&&nl.isState(n,t,s)&&(e=Pv(i,o));const r=i.selectedStyle||t.selectedStyle;r&&nl.isSelected(t,s)&&(e=Pv(i,r));const a=i.placeholderStyle||t.placeholderStyle;if(a&&nl.isPlacehold(t,s)&&(e=Pv(i,a)),nl.isDisabled(t,s)){const s=i.disabledStyle||t.disabledStyle;s&&(e=Pv(i,s))}else{const n=i.focusStyle||t.focusStyle;n&&nl.isFocus(t,s)&&(e=Pv(i,n));const o=i.hoverStyle||t.hoverStyle;o&&nl.isHover(t,s)&&(e=Pv(i,o));const r=i.pressStyle||t.pressStyle;r&&nl.isPress(t,s)&&(e=Pv(i,r))}return e?i:void 0}function Bv(t,e,i,s){const n=i?t:{},o=i||t;for(let t in o)s&&nl.animateExcludes[t]||(n[t]=e[t]);return n}function Tv(t,e,i){return Bv(t,e,i,!0)}function Pv(t,e){return Object.assign(t,e),!0}function Rv(t,e){const i=t[e];i&&xv(t,i),t.button&&Cv(t.children,e)}function Lv(t,e,i){i||(i=t.states[e]),xv(t,i),t.button&&Cv(t.children,null,e)}function Cv(t,e,i){if(!t)return;let s,n;for(let o=0,a=t.length;o<a;o++){if(s=t[o],e){switch(n=!0,e){case"hoverStyle":nl.isHover(s)&&(n=!1);break;case"pressStyle":nl.isPress(s)&&(n=!1);break;case"focusStyle":nl.isFocus(s)&&(n=!1)}n&&Rv(s,e)}else r(i)||Lv(s,i);s.isBranch&&Cv(s.children,e,i)}}function Ov(t,e){const i=t[e];i&&bv(t,i),t.button&&Dv(t.children,e)}function Av(t,e,i){bv(t,i),t.button&&Dv(t.children,null,e)}function Dv(t,e,i){if(!t)return;let s;for(let n=0,o=t.length;n<o;n++)s=t[n],e?Ov(s,e):r(i)||Av(s,i),s.isBranch&&Dv(s.children,e,i)}function Mv(t,e,i){let s;const n=e.leafer?e.leafer.interaction:null;if(n&&(s=n[t](e),!s&&i)){const o=wv(e,i);o&&(s=n[t](o))}return s}function Iv(t,e,i){let s=e[t];if(!s&&i){const n=wv(e,i);n&&(s=n[t])}return s}ue.add("state"),nl.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,placeholder:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1,placeholderStyle:1},nl.isState=function(t,e,i){return function(t,e,i){let s=e.states[t];if(!s&&i){const n=wv(e,i);n&&(s=n.states[t])}return!!s}(t,e,i)},nl.isSelected=function(t,e){return Iv("selected",t,e)},nl.isDisabled=function(t,e){return Iv("disabled",t,e)},nl.isFocus=function(t,e){return Mv("isFocus",t,e)},nl.isHover=function(t,e){return Mv("isHover",t,e)},nl.isPress=function(t,e){return Mv("isPress",t,e)},nl.isPlacehold=function(t,e){return t.__.__isPlacehold},nl.isDrag=function(t,e){return Mv("isDrag",t,e)},nl.setStyleName=function(t,e,i){i?Lv(t,e,t[e]):Av(t,e,t[e])},nl.set=function(t,e){const i=t.states[e];i?Lv(t,e,i):Av(t,e,i)},nl.getStyle=kv,nl.updateStyle=Sv,nl.updateEventStyle=function(e,i){switch(i){case t.PointerEvent.ENTER:Rv(e,"hoverStyle");break;case t.PointerEvent.LEAVE:Ov(e,"hoverStyle");break;case t.PointerEvent.DOWN:Rv(e,"pressStyle");break;case t.PointerEvent.UP:Ov(e,"pressStyle")}};const Fv=t.UI.prototype;t.UI.addAttr("selected",!1,yv,"selectedStyle"),t.UI.addAttr("disabled",!1,yv,"disabledStyle"),t.UI.addAttr("states",{},vv),t.UI.addAttr("state","",yv),t.UI.addAttr("normalStyle",void 0,fo),t.UI.addAttr("hoverStyle",void 0,vv),t.UI.addAttr("pressStyle",void 0,vv),t.UI.addAttr("focusStyle",void 0,vv),t.UI.addAttr("selectedStyle",void 0,vv),t.UI.addAttr("disabledStyle",void 0,vv),t.UI.addAttr("placeholderStyle",void 0,vv),t.UI.addAttr("button",!1,fo),Fv.set=function(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))},Fv.focus=function(t=!0){this.waitLeafer(()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?Rv(this,"focusStyle"):Ov(this,"focusStyle")})},Fv.updateState=function(){nl.updateStyle(this,void 0,"in")};const Wv=t.Text.prototype,zv="text";lo(Wv,zv,Object.assign(Object.assign({},co(Wv,zv)),{set(t){const e=this,i=e.text;e.__setAttr(zv,t)&&(So(e),e.placeholderStyle&&e.placeholder&&(""===i||""===t)&&(e.__layout.stateStyleChanged=!0))}}));class Uv extends ul{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}t.Robot=class extends t.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}togglePlay(){this.running?this.pause():this.play()}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let e=0;g(t)?t.forEach(t=>this.__loadRobot(t,e,e+=t.total||1)):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),!r(t))if(d(t))this.now=t;else if(p(t)){const e=g(t),i=e?t:t.keyframes;this.__action=e?void 0:t;const{length:s}=i;if(s>1){const t=this.now=i[0],e=i[i.length-1];this.play(),this.__runAction(t,e)}else s&&(this.now=i[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=no.get(t);s.ready?this.__createFrames(s,t,e,i):s.load(()=>this.__createFrames(s,t,e,i))}__createFrames(t,e,i,s){const{offset:n,size:o,total:r}=e,{width:a,height:h}=o&&(d(o)?{width:o,height:o}:o)||(r>1?this:t);let l=n?n.x:0,c=n?n.y:0;for(let e=i;e<s;e++)this.robotFrames[e]={view:t.view,x:l,y:c,width:a,height:h},l+a>=t.width?(l=0,c+=h):l+=a;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new Xr(Xr.LOADED,{image:t}))}__runAction(t,e){let{FPS:i,loop:s,__action:n}=this;n&&(n.FPS&&(i=n.FPS),r(n.loop)||(s=n.loop)),this.__timer=setTimeout(()=>{if(this.running){if(this.now===e){if(!s)return this.stop();this.now=t}else this.now++;this.__updateRobotBounds()}this.__runAction(t,e)},1e3/i)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const e=this.__,i=t.width/e.pixelRatio,s=t.height/e.pixelRatio;e.width===i&&e.height===s||this.forceUpdate("width"),e.__naturalWidth=i,e.__naturalHeight=s}}__drawContent(t,e){const{nowFrame:i}=this,{width:s,height:n}=this.__;i&&t.drawImage(i.view,i.x,i.y,i.width,i.height,0,0,s,n)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},s([Yo(Uv)],t.Robot.prototype,"__",void 0),s([bo()],t.Robot.prototype,"robot",void 0),s([fo()],t.Robot.prototype,"actions",void 0),s([fo("")],t.Robot.prototype,"action",void 0),s([Co(0)],t.Robot.prototype,"now",void 0),s([fo(12)],t.Robot.prototype,"FPS",void 0),s([fo(!0)],t.Robot.prototype,"loop",void 0),t.Robot=s([Jo()],t.Robot),ue.add("robot");const{Yes:Hv,NoAndSkip:Yv,YesAndSkip:Nv}=t.Answer,Xv={},Vv={},Gv={};class jv{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":Xv.id=t.substring(1),t=Xv;break;case".":Vv.className=t.substring(1),t=Vv;break;default:Gv.tag=t,t=Gv}case"object":if(r(t.id)){if(t.tag){const{tag:s}=t,n=g(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?m.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className)}{const s=this.getById(t.id,e);return i?s:s?[s]:[]}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&dr.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let r=0,a=t.length;r<a;r++){if(n=t[r],o=e(n,s),"boolean"==typeof o&&(o=o?1:0),o===Hv||o===Nv){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<Yv&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(Ur.REMOVE,this.__onRemoveChild,this),this.target.on_(Yr.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const Kv=t.UI.prototype;function qv(t){return t.leafer?t.leafer.selector:ie.selector||(ie.selector=ge.selector())}Kv.find=function(t,e){return qv(this).getBy(t,this,!1,e)},Kv.findOne=function(t,e){return qv(this).getBy(t,this,!0,e)},ue.add("find"),ge.finder=function(t){return new jv(t)};const{setPoint:Zv,addPoint:Jv,toBounds:$v}=wt;const Qv={syncExport(t,e,i){let s;sl.running=!0;try{const n=Zn.fileType(e),o=e.includes(".");i=Zn.getExportOptions(i);const{toURL:a}=ie,{download:h}=ie.origin;if("json"===n)o&&h(a(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!o||t.toJSON(i.json)};else if("svg"===n)o&&h(a(t.toSVG(),"svg"),e),s={data:!!o||t.toSVG()};else{let n,o,a=1,h=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:u}=t,{slice:g,clip:p,trim:_,screenshot:f,padding:m,onCanvas:y}=i,v=r(i.smooth)?!c||c.config.smooth:i.smooth,w=i.contextSettings||(c?c.config.contextSettings:void 0),x=d&&f&&r(i.fill)?t.fill:i.fill,b=Zn.isOpaqueImage(e)||x,E=new yt;if(f)n=!0===f?d?c.canvas.bounds:t.worldRenderBounds:f;else{let e=i.relative||(d?"inner":"local");switch(a=l.scaleX,h=l.scaleY,e){case"inner":E.set(l);break;case"local":E.set(l).divide(t.localTransform),a/=t.scaleX,h/=t.scaleY;break;case"world":a=1,h=1;break;case"page":e=c||t;default:E.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,h/=h/i.scaleY}n=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};F.getScaleData(i.scale,i.size,n,S);let k=i.pixelRatio||1,{x:B,y:T,width:P,height:R}=new qt(n).scale(S.scaleX,S.scaleY);p&&(B+=p.x,T+=p.y,P=p.width,R=p.height,p.rotation&&E.rotateOfInner({x:B,y:T},-p.rotation));const L={exporting:!0,matrix:E.scale(1/S.scaleX,1/S.scaleY).invert().translate(-B,-T).withScale(1/a*S.scaleX,1/h*S.scaleY)};let C,O=ge.canvas({width:Math.floor(P),height:Math.floor(R),pixelRatio:k,smooth:v,contextSettings:w});g&&(C=t,C.__worldOpacity=0,t=c||t,L.bounds=O.bounds),O.save();const A=u&&!r(x),D=t.get("fill");if(A&&(t.fill=""),ie.render(t,O,L),A&&(t.fill=D),O.restore(),C&&C.__updateWorldOpacity(),_){o=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,r,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,o=(a-n)/e,r?Jv(r,n,o):Zv(r={},n,o)),a++;const h=new qt;return r&&($v(r,h),h.scale(1/t.pixelRatio).ceil()),h}(O);const t=O,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:k};O=ge.canvas(s),O.copyWorld(t,o,s),t.destroy()}if(m){const[t,e,i,s]=F.fourNumber(m),n=O,{width:o,height:r}=n;O=ge.canvas({width:o+s+e,height:r+t+i,pixelRatio:k}),O.copyWorld(n,n.bounds,{x:s,y:t,width:o,height:r}),n.destroy()}b&&O.fillWorld(O.bounds,x||"#FFFFFF","destination-over"),y&&y(O);s={data:"canvas"===e?O:O.export(e,i),width:O.pixelWidth,height:O.pixelHeight,renderBounds:n,trimBounds:o};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return sl.running=!1,s},export(t,e,i){return sl.running=!0,function(t){tw||(tw=new to);return new Promise(e=>{tw.add(()=>n(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(o=>{const r=()=>n(this,void 0,void 0,function*(){if(!io.isComplete)return ie.requestRender(r);const n=sl.syncExport(t,e,i);n.data instanceof Promise&&(n.data=yield n.data),s(n),o()});t.updateLayout(),ew(t);const{leafer:a}=t;a?a.waitViewCompleted(r):r()}))}};let tw;function ew(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>ew(t))}const iw=De.prototype,sw=oe.get("@leafer-in/export");iw.export=function(t,e){const{quality:i,blob:s}=Zn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},iw.toBlob=function(t,e){return new Promise(i=>{ie.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{sw.error(t),i(null)})})},iw.toDataURL=function(t,e){return ie.origin.canvasToDataURL(this.view,t,e)},iw.saveAs=function(t,e){return new Promise(i=>{ie.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{sw.error(t),i(!1)})})},ue.add("export"),Object.assign(sl,Qv),t.UI.prototype.export=function(t,e){return sl.export(this,t,e)},t.UI.prototype.syncExport=function(t,e){return sl.syncExport(this,t,e)},ue.add("filter"),Object.assign(il,{list:{},register(t,e){il.list[t]=e},apply(t,e,i,s,n,o){let r;t.forEach(t=>{r=il.list[t.type],r&&r.apply(t,e,i,s,n,o)})},getSpread(t){let e,i=0;return t.forEach(t=>{e=il.list[t.type],e&&(i+=e.getSpread(t))}),i}}),ue.add("bright"),t.UI.addAttr("bright",!1,Oo);const nw={theme:"light",style:{dragBoundsType:"outer",strokeAlign:"center",strokeWidthFixed:"zoom-in",width:6,height:6,opacity:.5,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.66}},size:6,endsMargin:2,sideMargin:2,minSize:10,scaleFixed:"zoom-in",scrollType:"both",hideOnActionEnd:"hover"},ow=new qt,{float:rw}=F,{clone:aw,assign:hw}=m;class lw extends t.Group{get canUse(){return this.target.hasScroller}constructor(t){super(),this.targetWorldBounds=new qt,this.viewportBounds=new qt,this.contentBounds=new qt,this.scrollXBounds=new qt,this.scrollYBounds=new qt,this.target=t,this.config=aw(nw),this.updateConfig(),this.__listenEvents(),t.waitLeafer(()=>{this.parent=t,this.__bindLeafer(t.leafer)}),this.mergedConfig.hideOnActionEnd&&(this.opacity=0)}static registerTheme(t,e){dw.themeMap[t]=e}static getTheme(t){return t&&dw.themeMap[t]}static hasTheme(t){return t&&!!dw.themeMap[t]}updateConfig(){const{scrollConfig:t}=this.target,e=dw.getTheme(t&&dw.hasTheme(t.theme)&&t.theme||this.config.theme),i=this.mergedConfig=aw(this.config);hw(i,e),t&&hw(i,t),this.updateStyle(i.style)}updateStyle(e){this.scrollXBar||this.addMany(this.scrollXBar=new t.Box,this.scrollYBar=new t.Box);const{scrollXBar:i,scrollYBar:s}=this;i.set(e),s.set(e),i.draggable="x",s.draggable="y"}update(t=!0){if(this.dragScrolling)return;const{target:e,targetOverflow:i,targetWorldBounds:s,viewportBounds:n,contentBounds:o}=this,r=e.__layout,{overflow:a}=e.__,{childrenRenderBounds:h}=r,{boxBounds:l,worldBoxBounds:d}=r,c=t&&i===a&&s.isSame(d),u=!r.scrollConfigChanged||(this.updateConfig(),r.scrollConfigChanged=!1),g=ow.set(n).add(h);if(c&&u&&o.isSame(g))return;this.targetOverflow=a,n.set(l),s.set(d),o.set(g);const{scrollXBar:p,scrollYBar:_}=this,{size:f,endsMargin:m,minSize:y}=this.mergedConfig,{width:v,height:w}=n;this.contentRealX=o.x-e.scrollX,this.contentRealY=o.y-e.scrollY,this.ratioX=n.width/o.width,this.ratioY=n.height/o.height;const x=f+2*m+y;p.visible=rw(o.width)>rw(v)&&"y-scroll"!==a&&v>x,_.visible=rw(o.height)>rw(w)&&"x-scroll"!==a&&w>x,this.updateScrollBar()}updateScrollBar(){const{target:t,viewportBounds:e,contentBounds:i,ratioX:s,ratioY:n,scrollXBar:o,scrollYBar:a,scrollXBounds:h,scrollYBounds:l}=this;let{size:d,cornerRadius:c,endsMargin:u,sideMargin:g,minSize:p,scaleFixed:_,scrollType:f}=this.mergedConfig;const m=_?t.getClampRenderScale():1;if(u/=m,g/=m,d/=m,r(c)&&(c=d/2),o.visible){h.set(e).shrink([u,a.visible?d+g:u,g,u]);const t=this.scrollRatioX=h.width/i.width;o.set({x:h.x-i.x*t,y:h.maxY-d,width:Math.max(h.width*s,p),height:d,cornerRadius:c,dragBounds:h,hittable:"move"!==f})}if(a.visible){l.set(e).shrink([u,g,o.visible?d+g:u,u]);const t=this.scrollRatioY=l.height/i.height;a.set({x:l.maxX-d,y:l.y-i.y*t,width:d,height:Math.max(l.height*n,p),cornerRadius:c,dragBounds:l,hittable:"move"!==f})}this.x=-this.target.scrollX,this.y=-this.target.scrollY,dr.updateAllMatrix(this),br.updateBounds(this),dr.updateAllChange(this)}onDrag(t){if("move"===this.mergedConfig.scrollType)return;this.dragScrolling=!0;const{scrollXBar:e,scrollYBar:i,target:s,scrollXBounds:n,scrollYBounds:o}=this;t.current===e?s.scrollX=-((e.x-n.x)/this.scrollRatioX+this.contentRealX):s.scrollY=-((i.y-o.y)/this.scrollRatioY+this.contentRealY)}onDragEnd(){"move"!==this.mergedConfig.scrollType&&(this.dragScrolling=!1)}onMove(t){if(!this.canUse)return;this.onEnter();const{scrollType:e,stopDefault:i}=this.mergedConfig;if("drag"===e)return;const{viewportBounds:s,contentBounds:n,scrollXBar:o,scrollYBar:r}=this;if(o.visible||r.visible){const e=t.getInnerMove(this.target);let a;Dd.getValidMove(n,s,"inner",e,!0),e.x&&o.visible&&(this.target.scrollX+=e.x,a=!0),e.y&&r.visible&&(this.target.scrollY+=e.y,a=!0),(a||i)&&t.stop(),i&&t.stopDefault()}}onMoveEnd(t){this.canUse&&(this.target.hit(t)||this.onLeave())}onEnter(){this.canUse&&(clearTimeout(this.hideTimer),this.killAnimate(),this.opacity=1)}onLeave(){this.canUse&&(clearTimeout(this.hideTimer),this.mergedConfig.hideOnActionEnd&&(this.hideTimer=setTimeout(()=>{this.set({opacity:0},ue.has("animate"))},600)))}onResize(){this.canUse&&this.update()}__listenEvents(){const{scrollXBar:e,scrollYBar:i,target:s}=this;this.__eventIds=[e.on_(t.DragEvent.DRAG,this.onDrag,this),e.on_(t.DragEvent.END,this.onDragEnd,this),i.on_(t.DragEvent.DRAG,this.onDrag,this),i.on_(t.DragEvent.END,this.onDragEnd,this),s.on_(t.PointerEvent.ENTER,this.onEnter,this),s.on_(t.PointerEvent.LEAVE,this.onLeave,this),s.on_(t.MoveEvent.BEFORE_MOVE,this.onMove,this),s.on_(t.MoveEvent.END,this.onMoveEnd,this),s.on_(Vr.WORLD,this.onResize,this),s.on_(Ur.DESTROY,this.destroy,this)]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){if(!this.destroyed){this.__removeListenEvents();const{target:t}=this;t.scroller=t.topChildren=t.hasScroller=void 0,this.target=this.config=null,super.destroy()}}}lw.themeMap={};const dw=lw;ue.add("scroller");const cw=t.Box.prototype;return t.Box.addAttr("scrollConfig",void 0,function(t){return go(t,t=>({set(e){if(this.__setAttr(t,e)){this.__layout.scrollConfigChanged=!0,So(this)}}}))}),cw.__checkScroll=function(t){t&&this.isOverflow?(this.scroller||(this.scroller=new lw(this),this.topChildren||(this.topChildren=[]),this.topChildren.push(this.scroller)),this.hasScroller=!0):this.hasScroller&&!this.scroller.dragScrolling&&(this.hasScroller=void 0,this.scroller.update())},lw.registerTheme("light",{style:{fill:"black"}}),lw.registerTheme("dark",{style:{fill:"white"}}),t.AlignHelper=Pt,t.AnimateEasing=wy,t.AnimateEvent=by,t.AroundHelper=kt,t.ArrowData=Bf,t.AutoBounds=Jt,t.BezierHelper=di,t.Bounds=qt,t.BoundsEvent=Vr,t.BoundsHelper=Vt,t.BoxData=_l,t.BranchHelper=br,t.BranchRender=Ua,t.CanvasData=Pl,t.CanvasManager=we,t.ChildEvent=Ur,t.ColorConvert=qh,t.Creator=ge,t.Cursor=sc,t.DataHelper=m,t.Debug=oe,t.DragBoundsHelper=Dd,t.Dragger=Gd,t.EditBox=Mp,t.EditDataHelper=Tp,t.EditPoint=Op,t.EditSelect=pp,t.EditSelectHelper=dp,t.EditToolCreator=Kp,t.EditorEvent=tp,t.EditorGroupEvent=Jp,t.EditorHelper=Xp,t.EditorMoveEvent=i_,t.EditorRotateEvent=n_,t.EditorScaleEvent=s_,t.EditorSkewEvent=o_,t.Effect=el,t.EllipseData=wl,t.EllipseHelper=vi,t.Event=zr,t.EventCreator=ye,t.Eventer=ha,t.Export=sl,t.FileHelper=Zn,t.Filter=il,t.Finder=jv,t.FourNumberHelper=T,t.FrameData=ml,t.GroupData=pl,t.HTMLTextData=Sf,t.HighBezierHelper=tv,t.HighCurveHelper=lv,t.HitCanvasManager=nc,t.ImageData=Tl,t.ImageEvent=Xr,t.ImageManager=no,t.IncrementId=w,t.InnerEditor=a_,t.InnerEditorEvent=Zp,t.InteractionBase=ic,t.InteractionHelper=Ud,t.Keyboard=wd,t.LayoutEvent=Qr,t.Layouter=Fh,t.LeafBounds=Ia,t.LeafBoundsHelper=yr,t.LeafData=v,t.LeafDataProxy=xa,t.LeafEventer=va,t.LeafHelper=dr,t.LeafLayout=Wr,t.LeafLevelList=bh,t.LeafList=xh,t.LeafMatrix=Pa,t.LeafRender=Fa,t.LeaferCanvas=Eh,t.LeaferCanvasBase=De,t.LeaferData=fl,t.LeaferEvent=ea,t.LeaferFilm=class extends ho{get tag(){return"Film"}},t.LeaferImage=ho,t.LeaferTypeCreator=q_,t.LeaferVideo=class extends ho{get tag(){return"Video"}},t.LineData=yl,t.MathHelper=F,t.Matrix=yt,t.MatrixHelper=$,t.MultiTouchHelper=$_,t.MyDragEvent=Wd,t.MyImage=gd,t.MyPointerEvent=Id,t.MyTouchEvent=zd,t.NeedConvertToCanvasCommandMap=ze,t.OneRadian=z,t.PI2=U,t.PI_2=H,t.Paint=$h,t.PaintGradient=tl,t.PaintImage=Qh,t.PathArrow=Jh,t.PathArrowModule=Em,t.PathBounds=Wn,t.PathCommandDataHelper=Ts,t.PathCommandMap=Fe,t.PathCommandNodeHelper=wi,t.PathConvert=ns,t.PathCorner=Vn,t.PathCreator=Xs,t.PathData=El,t.PathDrawer=rn,t.PathHelper=Me,t.PathMatrixHelper=Ff,t.PathNumberCommandLengthMap=Ne,t.PathNumberCommandMap=Ye,t.PathScaler=B_,t.PenData=Sl,t.Picker=Nh,t.Platform=ie,t.Plugin=ue,t.Point=ft,t.PointHelper=dt,t.PointerButton=xd,t.PolygonData=xl,t.PropertyEvent=Yr,t.RectData=vl,t.RectHelper=Xe,t.RectRender=Ml,t.RenderEvent=ta,t.Renderer=zh,t.ResizeEvent=Jr,t.Resource=io,t.RobotData=Uv,t.Run=le,t.ScrollBar=Ef,t.Scroller=lw,t.SelectArea=lp,t.Selector=Xh,t.StarData=bl,t.State=nl,t.StringNumberMap=Qt,t.Stroker=hp,t.TaskItem=Qn,t.TaskProcessor=to,t.TextConvert=Kh,t.TextData=Bl,t.TransformTool=r_,t.Transformer=df,t.Transition=ol,t.TwoPointBoundsHelper=wt,t.UIBounds=Cl,t.UICreator=_e,t.UIData=ul,t.UIEvent=bd,t.UIRender=Al,t.UnitConvert=Zh,t.UnitConvertHelper=$t,t.WaitHelper=Pr,t.WatchEvent=$r,t.Watcher=Bh,t.WheelEventHelper=of,t.addViewport=G_,t.addViewportConfig=j_,t.affectRenderBoundsType=Lo,t.affectStrokeBoundsType=To,t.arrowType=Tf,t.attr=po,t.autoLayoutType=vo,t.boundsType=bo,t.canvasPatch=qn,t.canvasSizeAttrs=Ae,t.createAttr=function(t){return(e,i)=>{lo(e,i,uo(i,t))}},t.createDescriptor=uo,t.cursorType=Ho,t.dataProcessor=Yo,t.dataType=fo,t.decorateLeafAttr=go,t.defineDataProcessor=No,t.defineKey=lo,t.defineLeafAttr=_o,t.dimType=Oo,t.doBoundsType=So,t.doStrokeType=Po,t.effectType=Vh,t.emptyData=o,t.eraserType=zo,t.extraPropertyEventMap=Nr,t.getBoundsData=N,t.getDescriptor=co,t.getMatrixData=X,t.getPointData=Y,t.hitType=Uo,t.isArray=g,t.isData=_,t.isEmptyData=f,t.isFinite=l,t.isNull=a,t.isNumber=d,t.isObject=p,t.isString=h,t.isUndefined=r,t.layoutProcessor=function(t){return(e,i)=>{lo(e,"__LayoutProcessor",{get:()=>t})}},t.leaferTransformAttrMap=ra,t.maskType=Wo,t.motionPathType=dv,t.naturalBoundsType=Eo,t.opacityType=Ao,t.path=Gn,t.pathInputType=ko,t.pathType=Bo,t.pen=jn,t.positionType=mo,t.registerEditTool=Gp,t.registerInnerEditor=jp,t.registerUI=Jo,t.registerUIEvent=$o,t.resizeType=Gh,t.rewrite=jo,t.rewriteAble=Ko,t.rotationType=xo,t.scaleResize=M_,t.scaleResizeFontSize=I_,t.scaleResizeGroup=z_,t.scaleResizePath=F_,t.scaleResizePoints=W_,t.scaleType=wo,t.scrollType=yo,t.sortType=Fo,t.stateStyleType=vv,t.stateType=yv,t.strokeType=Ro,t.surfaceType=Co,t.tempBounds=Zt,t.tempMatrix=vt,t.tempPoint=mt,t.tryToNumber=u,t.useCanvas=Sh,t.useModule=Zo,t.version="2.0.2",t.visibleType=Do,t.zoomLayerType=jh,t}({});function Leafer(t){return new LeaferUI.Leafer(t)}Object.setPrototypeOf(Leafer,LeaferUI),Leafer.prototype=LeaferUI.Leafer.prototype;
2
2
  //# sourceMappingURL=worker.min.js.map