@leafer-editor/worker 1.9.12 → 1.10.1

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";const e={toURL(t,e){let i=encodeURIComponent(t);return"text"===e?i="data:text/plain;charset=utf-8,"+i:"svg"===e&&(i="data:image/svg+xml,"+i),i},image:{hitCanvasSize:100,maxCacheSize:4096e3,maxPatternSize:8847360,crossOrigin:"anonymous",getRealURL(t){const{prefix:i,suffix:s}=e.image;return!s||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+s),i&&"/"===t[0]&&(t=i+t),t}}},i={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=s;return e[t]?e[t]++:(e[t]=1,0)}},s=i;var n;t.Answer=void 0,(n=t.Answer||(t.Answer={}))[n.No=0]="No",n[n.Yes=1]="Yes",n[n.NoAndSkip=2]="NoAndSkip",n[n.YesAndSkip=3]="YesAndSkip";const r={};function o(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+)?$/;const{isArray:u}=Array;function p(t){return t&&"object"==typeof t}function g(t){return p(t)&&!u(t)}function _(t){return"{}"===JSON.stringify(t)}const f={default:(t,e)=>(m(e,t),m(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var r,o;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(r=t[n])||void 0===r?void 0:r.constructor)===Object)return m(t[n],e[n],i&&i[n]);i&&n in i?(null===(o=i[n])||void 0===o?void 0:o.constructor)===Object&&m(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{o(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:m}=f;class y{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(!o(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]=o(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(!o(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!o(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(u(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],!o(t))){if("path"===n&&!this.__pathInputed)continue;e=s?s[n]:void 0,i[n]=o(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:r,f:o}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:r,f:o}}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}}let v,x,w;const{max:E}=Math,b=[0,0,0,0],k={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)=>B(b,t,e,i,s),toTempAB(t,e,i){w=i?d(t)?e:t:[],d(t)?(v=T(t),x=e):d(e)?(v=t,x=T(e)):(v=t,x=e),4!==v.length&&(v=S(v)),4!==x.length&&(x=S(x))},get(t,e){let i;if(!d(t))switch(t.length){case 4:i=o(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]),!o(e))for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},max:(t,e,i)=>d(t)&&d(e)?E(t,e):(P(t,e,i),B(w,E(v[0],x[0]),E(v[1],x[1]),E(v[2],x[2]),E(v[3],x[3]))),add:(t,e,i)=>d(t)&&d(e)?t+e:(P(t,e,i),B(w,v[0]+x[0],v[1]+x[1],v[2]+x[2],v[3]+x[3])),swapAndScale(t,e,i,s){if(d(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[r,o,a,h]=4===t.length?t:S(t);return B(n,a*i,h*e,r*i,o*e)}},{set:B,get:S,setTemp:T,toTempAB:P}=k,{round:L,pow:R,PI:C}=Math,O={within:(t,e,i)=>(p(e)&&(i=e.max,e=e.min),!o(e)&&t<e&&(t=e),!o(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)),O.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=o(e)?1e12:R(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=(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&&O.assignScale(s,t);return s},assignScale(t,e){d(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},randInt:M,randColor:t=>`rgba(${M(255)},${M(255)},${M(255)},${t||1})`};function M(t){return Math.round(Math.random()*t)}const D=C/180,I=2*C,A=C/2;function W(){return{x:0,y:0}}function F(){return{x:0,y:0,width:0,height:0}}function z(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:H,cos:U,acos:N,sqrt:Y}=Math,{float:X}=O,V={};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 G={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,r=0,o=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=r,t.f=o},get:z,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){K.toInnerPoint(t,e,V),K.scaleOfInner(t,V,i,s)},scaleOfInner(t,e,i,s=i){K.translateInner(t,e.x,e.y),K.scale(t,i,s),K.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:r}=t,o=U(e*=D),a=H(e);t.a=i*o-s*a,t.b=i*a+s*o,t.c=n*o-r*a,t.d=n*a+r*o},rotateOfOuter(t,e,i){K.toInnerPoint(t,e,V),K.rotateOfInner(t,V,i)},rotateOfInner(t,e,i){K.translateInner(t,e.x,e.y),K.rotate(t,i),K.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:r,d:o}=t;i&&(i*=D,t.a=s+r*i,t.b=n+o*i),e&&(e*=D,t.c=r+s*e,t.d=o+n*e)},skewOfOuter(t,e,i,s){K.toInnerPoint(t,e,V),K.skewOfInner(t,V,i,s)},skewOfInner(t,e,i,s=0){K.translateInner(t,e.x,e.y),K.skew(t,i,s),K.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:i,b:s,c:n,d:r,e:o,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*r,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*r,t.e=e.e*i+e.f*n+o,t.f=e.e*s+e.f*r+a},multiplyParent(t,e,i,s,n){const{e:r,f:a}=t;if(i||(i=t),o(s)&&(s=1!==t.a||t.b||t.c||1!==t.d),s){const{a:s,b:r,c:o,d:a}=t;i.a=s*e.a+r*e.c,i.b=s*e.b+r*e.d,i.c=o*e.a+a*e.c,i.d=o*e.b+a*e.d,n&&(i.scaleX=e.scaleX*n.scaleX,i.scaleY=e.scaleY*n.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,n&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=r*e.a+a*e.c+e.e,i.f=r*e.b+a*e.d+e.f},divide(t,e){K.multiply(t,K.tempInvert(e))},divideParent(t,e){K.multiplyParent(t,K.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=K;return K.copy(e,t),K.invert(e),e},invert(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=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=-(r*n-o*s)*a,t.f=-(o*e-r*i)*a}else if(1===e&&1===n)t.e=-r,t.f=-o;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-r*n*i,t.f=-o*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:r}=e;i||(i=e),i.x=n*t.a+r*t.c,i.y=n*t.b+r*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:r,c:o,d:a}=t,h=1/(n*a-r*o),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*o)*h,i.y=(d*n-l*r)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*o)*h,i.y-=(s*n-e*r)*h}},setLayout(t,e,i,s,n){const{x:r,y:a,scaleX:h,scaleY:l}=e;if(o(n)&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:i,skewX:s,skewY:n}=e,r=i*D,o=U(r),a=H(r);if(s||n){const e=s*D,i=n*D;t.a=(o+i*-a)*h,t.b=(a+i*o)*h,t.c=(e*o-a)*l,t.d=(o+e*a)*l}else t.a=o*h,t.b=a*h,t.c=-a*l,t.d=o*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=r,t.f=a,(i=i||s)&&K.translateInner(t,-i.x,-i.y,!s)},getLayout(t,e,i,s){const{a:n,b:r,c:o,d:a,e:h,f:l}=t;let d,c,u,p,g,_=h,f=l;if(r||o){const t=n*a-r*o;if(o&&!s){d=Y(n*n+r*r),c=t/d;const e=n/d;u=r>0?N(e):-N(e)}else{c=Y(o*o+a*a),d=t/c;const e=o/c;u=A-(a>0?N(-e):-N(e))}const e=X(U(u)),i=H(u);d=X(d),c=X(c),p=e?X((o/c+i)/e/D,9):0,g=e?X((r/d-i)/e/D,9):0,u=X(u/D)}else d=n,c=a,u=p=g=0;return(e=i||e)&&(_+=e.x*n+e.y*o,f+=e.x*r+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:p,skewY:g}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:r,d:o}=t;n||r?i=(s*o-n*r)/(e=Y(s*s+n*n)):(e=s,i=o)}return s.scaleX=e,s.scaleY=i,s},reset(t){K.set(t)}},K=G,{toInnerPoint:Z,toOuterPoint:q}=G,{sin:J,cos:$,abs:Q,sqrt:tt,atan2:et,min:it,round:st}=Math,nt={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=o(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?st(t.x-.5)+.5:st(t.x),t.y=e?st(t.y-.5)+.5:st(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=rt.defaultPoint);const s=$(e*=D),n=J(e),r=t.x-i.x,o=t.y-i.y;t.x=i.x+r*s-o*n,t.y=i.y+r*n+o*s},tempToInnerOf(t,e){const{tempPoint:i}=rt;return at(i,t),Z(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=rt;return at(i,t),q(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=rt;return at(i,t),rt.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),Z(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){Z(e,t,i)},toOuterOf(t,e,i){q(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)=>ot(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=Q(i-t),r=Q(s-e);return tt(n*n+r*r)},getMinDistanceFrom:(t,e,i,s,n,r)=>it(ot(t,e,i,s),ot(i,s,n,r)),getAngle:(t,e)=>ht(t,e)/D,getRotation:(t,e,i,s)=>(s||(s=e),rt.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/D),getRadianFrom(t,e,i,s,n,r,a,h){o(a)&&(a=i,h=s);const l=t-i,d=e-s,c=n-a,u=r-h;return Math.atan2(l*u-d*c,l*c+d*u)},getAtan2:(t,e)=>et(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s){const n=ht(t,e);return(e=s?e:{}).x=t.x+$(n)*i,e.y=t.y+J(n)*i,e},toNumberPoints(t){let e=t;return p(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},reset(t){rt.reset(t)}},rt=nt,{getDistanceFrom:ot,copy:at,getAtan2:ht}=rt;class lt{constructor(t,e){this.set(t,e)}set(t,e){return p(t)?nt.copy(this,t):nt.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new lt(this)}move(t,e){return nt.move(this,t,e),this}scale(t,e){return nt.scale(this,t,e),this}scaleOf(t,e,i){return nt.scaleOf(this,t,e,i),this}rotate(t,e){return nt.rotate(this,t,e),this}rotateOf(t,e){return nt.rotate(this,e,t),this}getRotation(t,e,i){return nt.getRotation(this,t,e,i)}toInnerOf(t,e){return nt.toInnerOf(this,t,e),this}toOuterOf(t,e){return nt.toOuterOf(this,t,e),this}getCenter(t){return new lt(nt.getCenter(this,t))}getDistance(t){return nt.getDistance(this,t)}getDistancePoint(t,e,i){return new lt(nt.getDistancePoint(this,t,e,i))}getAngle(t){return nt.getAngle(this,t)}getAtan2(t){return nt.getAtan2(this,t)}reset(){return nt.reset(this),this}}const dt=new lt;class ct{constructor(t,e,i,s,n,r){this.set(t,e,i,s,n,r)}set(t,e,i,s,n,r){return p(t)?G.copy(this,t):G.set(this,t,e,i,s,n,r),this}setWith(t){return G.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:r}=this;return{a:t,b:e,c:i,d:s,e:n,f:r}}clone(){return new ct(this)}translate(t,e){return G.translate(this,t,e),this}translateInner(t,e){return G.translateInner(this,t,e),this}scale(t,e){return G.scale(this,t,e),this}scaleWith(t,e){return G.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return G.pixelScale(this,t),this}scaleOfOuter(t,e,i){return G.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return G.scaleOfInner(this,t,e,i),this}rotate(t){return G.rotate(this,t),this}rotateOfOuter(t,e){return G.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return G.rotateOfInner(this,t,e),this}skew(t,e){return G.skew(this,t,e),this}skewOfOuter(t,e,i){return G.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return G.skewOfInner(this,t,e,i),this}multiply(t){return G.multiply(this,t),this}multiplyParent(t){return G.multiplyParent(this,t),this}divide(t){return G.divide(this,t),this}divideParent(t){return G.divideParent(this,t),this}invert(){return G.invert(this),this}invertWith(){return G.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){G.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){G.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return G.setLayout(this,t,e,i),this}getLayout(t,e,i){return G.getLayout(this,t,e,i)}withScale(t,e){return G.withScale(this,t,e)}reset(){G.reset(this)}}const ut=new ct,pt={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){gt(t,e,i),gt(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:gt}=pt;var _t,ft;t.Direction4=void 0,(_t=t.Direction4||(t.Direction4={}))[_t.top=0]="top",_t[_t.right=1]="right",_t[_t.bottom=2]="bottom",_t[_t.left=3]="left",t.Direction9=void 0,(ft=t.Direction9||(t.Direction9={}))[ft.topLeft=0]="topLeft",ft[ft.top=1]="top",ft[ft.topRight=2]="topRight",ft[ft.right=3]="right",ft[ft.bottomRight=4]="bottomRight",ft[ft.bottom=5]="bottom",ft[ft.bottomLeft=6]="bottomLeft",ft[ft.left=7]="left",ft[ft.center=8]="center",ft[ft["top-left"]=0]="top-left",ft[ft["top-right"]=2]="top-right",ft[ft["bottom-right"]=4]="bottom-right",ft[ft["bottom-left"]=6]="bottom-left";const mt=[{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}];mt.forEach(t=>t.type="percent");const yt={directionData:mt,tempPoint:{},get:vt,toPoint(t,e,i,s,n,r){const o=vt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,n&&(r||(i.x-=n.x,i.y-=n.y),o.x&&(i.x-=1===o.x?n.width:.5===o.x?o.x*n.width:0),o.y&&(i.y-=1===o.y?n.height:.5===o.y?o.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i)=>(i||(i={}),yt.toPoint(t,e,i,!0),i)};function vt(e){return h(e)?mt[t.Direction9[e]]:e}const{toPoint:xt}=yt,wt={toPoint(t,e,i,s,n,r){xt(t,i,s,n,e,r)}},{tempPointBounds:Et,setPoint:bt,addPoint:kt,toBounds:Bt}=pt,{toOuterPoint:St}=G,{float:Tt,fourNumber:Pt}=O,{floor:Lt,ceil:Rt}=Math;let Ct,Ot,Mt,Dt;const It={},At={},Wt={},Ft={tempBounds:Wt,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:r,y:o,width:a,height:h}=e;if(u(i)){const e=Pt(i);s?zt.set(t,r+e[3],o+e[0],a-e[1]-e[3],h-e[2]-e[0]):zt.set(t,r-e[3],o-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),zt.set(t,r-i,o-i,a+2*i,h+2*i);n&&("width"===n?(t.y=o,t.height=h):(t.x=r,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),zt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Ut(e,t):e=t,i||(i=t),e.offsetX=zt.maxX(i),e.offsetY=zt.maxY(i),zt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||nt.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){nt.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(zt.copy(Wt,t),zt.toOuterOf(Wt,e),Wt),getOuterOf:(t,e)=>(t=Object.assign({},t),zt.toOuterOf(t,e),t),toOuterOf(t,e,i){if(i||(i=t),0===e.b&&0===e.c){const{a:s,d:n}=e;s>0?(i.width=t.width*s,i.x=e.e+t.x*s):(i.width=t.width*-s,i.x=e.e+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=e.f+t.y*n):(i.height=t.height*-n,i.y=e.f+t.y*n-i.height)}else It.x=t.x,It.y=t.y,St(e,It,At),bt(Et,At.x,At.y),It.x=t.x+t.width,St(e,It,At),kt(Et,At.x,At.y),It.y=t.y+t.height,St(e,It,At),kt(Et,At.x,At.y),It.x=t.x,St(e,It,At),kt(Et,At.x,At.y),Bt(Et,i)},toInnerOf(t,e,i){i||(i=t),zt.move(i,-e.e,-e.f),zt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,zt.getFitScale(t,e));return new ct(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,r){r||(r=e),h(s)&&(s=zt.getFitScale(t,e,"cover"===s)),Wt.width=n?e.width*=s:e.width*s,Wt.height=n?e.height*=s:e.height*s,wt.toPoint(i,Wt,t,r,!0,!0)},getSpread(t,e,i){const s={};return zt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){zt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){zt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=Lt(t.x),t.y=Lt(t.y),t.width=e>t.x?Rt(t.width+e-t.x):Rt(t.width),t.height=i>t.y?Rt(t.height+i-t.y):Rt(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=Tt(t.x,e),t.y=Tt(t.y,e),t.width=Tt(t.width,e),t.height=Tt(t.height,e)},add(t,e,i){Ct=t.x+t.width,Ot=t.y+t.height,Mt=e.x,Dt=e.y,i||(Mt+=e.width,Dt+=e.height),Ct=Ct>Mt?Ct:Mt,Ot=Ot>Dt?Ot:Dt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=Ct-t.x,t.height=Ot-t.y},addList(t,e){zt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){zt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){zt.setListWithFn(t,e,i,!0)},setListWithFn(t,e,i,s=!1){let n,r=!0;for(let o=0,a=e.length;o<a;o++)n=i?i(e[o],o):e[o],n&&(n.width||n.height)&&(r?(r=!1,s||Ut(t,n)):Ht(t,n));r&&zt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?bt(Et,t.x,t.y):kt(Et,t.x,t.y)),Bt(Et,t)},setPoint(t,e){zt.set(t,e.x,e.y)},addPoint(t,e){Ht(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=nt.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=nt.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=zt.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=zt.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=zt.tempToOuterOf(e,i)),!zt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:r,height:o}=e;return Ct=s+r,Ot=n+o,Mt=t.x+t.width,Dt=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,Ct=Ct<Mt?Ct:Mt,Ot=Ot<Dt?Ot:Dt,r=Ct-s,o=Ot-n,{x:s,y:n,width:r,height:o}},intersect(t,e,i){zt.copy(t,zt.getIntersectData(t,e,i))},isSame:(t,e)=>t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height,isEmpty:t=>0===t.x&&0===t.y&&0===t.width&&0===t.height,reset(t){zt.set(t)}},zt=Ft,{add:Ht,copy:Ut}=zt;class Nt{get minX(){return Ft.minX(this)}get minY(){return Ft.minY(this)}get maxX(){return Ft.maxX(this)}get maxY(){return Ft.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return p(t)?Ft.copy(this,t):Ft.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 Nt(this)}move(t,e){return Ft.move(this,t,e),this}scale(t,e,i){return Ft.scale(this,t,e,i),this}scaleOf(t,e,i){return Ft.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Ft.toOuterOf(this,t,e),this}toInnerOf(t,e){return Ft.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Ft.getFitMatrix(this,t,e)}put(t,e,i){Ft.put(this,t,e,i)}spread(t,e){return Ft.spread(this,t,e),this}shrink(t,e){return Ft.shrink(this,t,e),this}ceil(){return Ft.ceil(this),this}unsign(){return Ft.unsign(this),this}float(t){return Ft.float(this,t),this}add(t){return Ft.add(this,t),this}addList(t){return Ft.setList(this,t,!0),this}setList(t){return Ft.setList(this,t),this}addListWithFn(t,e){return Ft.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Ft.setListWithFn(this,t,e),this}setPoint(t){return Ft.setPoint(this,t),this}setPoints(t){return Ft.setPoints(this,t),this}addPoint(t){return Ft.addPoint(this,t),this}getPoints(){return Ft.getPoints(this)}hitPoint(t,e){return Ft.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Ft.hitRadiusPoint(this,t,e)}hit(t,e){return Ft.hit(this,t,e)}includes(t,e){return Ft.includes(this,t,e)}intersect(t,e){return Ft.intersect(this,t,e),this}getIntersect(t,e){return new Nt(Ft.getIntersectData(this,t,e))}isSame(t){return Ft.isSame(this,t)}isEmpty(){return Ft.isEmpty(this)}reset(){Ft.reset(this)}}const Yt=new Nt;class Xt{constructor(t,e,i,s,n,r){p(t)?this.copy(t):this.set(t,e,i,s,n,r)}set(t=0,e=0,i=0,s=0,n=0,r=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=r}copy(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=t;this.set(e,i,s,n,r,o)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=this;return new Nt(n,e,r||t.width-n-i,o||t.height-e-s)}}const Vt={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},{randColor:jt}=O;class Gt{constructor(t){this.repeatMap={},this.name=t}static get(t){return new Gt(t)}static set filter(t){this.filterList=Kt(t)}static set exclude(t){this.excludeList=Kt(t)}static drawRepaint(t,e){const i=jt();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===Gt.showBounds,n=t.__nowWorld,r=jt();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=r.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(r,2),s?e.stroke():e.strokeWorld(n,r)}log(...t){if(Zt.enable){if(Zt.filterList.length&&Zt.filterList.every(t=>t!==this.name))return;if(Zt.excludeList.length&&Zt.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){Zt.enable&&this.warn(...t)}warn(...t){Zt.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 Kt(t){return t?h(t)&&(t=[t]):t=[],t}Gt.filterList=[],Gt.excludeList=[],Gt.showWarn=!0;const Zt=Gt,qt=Gt.get("RunTime"),Jt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const s=i.create(i.RUNTIME);return $t.currentId=$t.idMap[s]=e?performance.now():Date.now(),$t.currentName=$t.nameMap[s]=t,$t.nameToIdMap[t]=s,s},end(t,e){const i=$t.idMap[t],s=$t.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;$t.idMap[t]=$t.nameMap[t]=$t.nameToIdMap[s]=void 0,qt.log(s,n,"ms")},endOfName(t,e){const i=$t.nameToIdMap[t];o(i)||$t.end(i,e)}},$t=Jt,Qt=[],te={list:{},add(t,...e){this.list[t]=!0,Qt.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(()=>Qt.forEach(t=>te.has(t,!0)));const ee={editor:t=>te.need("editor")},ie=Gt.get("UICreator"),se={list:{},register(t){const{__tag:e}=t.prototype;ne[e]&&ie.repeat(e),ne[e]=t},get(t,e,i,s,n,r){ne[t]||ie.error("not register "+t);const a=new ne[t](e);return o(i)||(a.x=i,s&&(a.y=s),n&&(a.width=n),r&&(a.height=r)),a}},{list:ne}=se,re=Gt.get("EventCreator"),oe={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],h(e)&&(ae[e]&&re.repeat(e),ae[e]=t)})},changeName(t,e){const i=ae[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,ae[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new ae[t](...e)},{nameList:ae}=oe;class he{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=ee.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 le(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o}function de(t,e,i,s){return new(i||(i=Promise))(function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,a)}h((s=s.apply(t,e||[])).next())})}function ce(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 ue=[];function pe(){return(t,e)=>{ue.push(e)}}const ge=[];class _e{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||ge)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;ue.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,r){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,r){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,r)}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,r,o,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,r+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,o+=t,h-=t}this.context.drawImage(t,e,i,s,n,r,o,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,r){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,r){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,r,o,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,r){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}}le([ce("imageSmoothingEnabled")],_e.prototype,"smooth",void 0),le([ce("imageSmoothingQuality")],_e.prototype,"smoothLevel",void 0),le([ce("globalAlpha")],_e.prototype,"opacity",void 0),le([ce()],_e.prototype,"fillStyle",void 0),le([ce()],_e.prototype,"strokeStyle",void 0),le([ce("lineWidth")],_e.prototype,"strokeWidth",void 0),le([ce("lineCap")],_e.prototype,"strokeCap",void 0),le([ce("lineJoin")],_e.prototype,"strokeJoin",void 0),le([ce("lineDashOffset")],_e.prototype,"dashOffset",void 0),le([ce()],_e.prototype,"miterLimit",void 0),le([ce()],_e.prototype,"shadowBlur",void 0),le([ce()],_e.prototype,"shadowColor",void 0),le([ce()],_e.prototype,"shadowOffsetX",void 0),le([ce()],_e.prototype,"shadowOffsetY",void 0),le([ce()],_e.prototype,"filter",void 0),le([ce()],_e.prototype,"font",void 0),le([ce()],_e.prototype,"fontKerning",void 0),le([ce()],_e.prototype,"fontStretch",void 0),le([ce()],_e.prototype,"fontVariantCaps",void 0),le([ce()],_e.prototype,"textAlign",void 0),le([ce()],_e.prototype,"textBaseline",void 0),le([ce()],_e.prototype,"textRendering",void 0),le([ce()],_e.prototype,"wordSpacing",void 0),le([ce()],_e.prototype,"letterSpacing",void 0),le([ce()],_e.prototype,"direction",void 0),le([pe()],_e.prototype,"setTransform",null),le([pe()],_e.prototype,"resetTransform",null),le([pe()],_e.prototype,"getTransform",null),le([pe()],_e.prototype,"save",null),le([pe()],_e.prototype,"restore",null),le([pe()],_e.prototype,"translate",null),le([pe()],_e.prototype,"scale",null),le([pe()],_e.prototype,"rotate",null),le([pe()],_e.prototype,"fill",null),le([pe()],_e.prototype,"stroke",null),le([pe()],_e.prototype,"clip",null),le([pe()],_e.prototype,"fillRect",null),le([pe()],_e.prototype,"strokeRect",null),le([pe()],_e.prototype,"clearRect",null),le([pe()],_e.prototype,"beginPath",null),le([pe()],_e.prototype,"moveTo",null),le([pe()],_e.prototype,"lineTo",null),le([pe()],_e.prototype,"bezierCurveTo",null),le([pe()],_e.prototype,"quadraticCurveTo",null),le([pe()],_e.prototype,"closePath",null),le([pe()],_e.prototype,"arc",null),le([pe()],_e.prototype,"arcTo",null),le([pe()],_e.prototype,"ellipse",null),le([pe()],_e.prototype,"rect",null),le([pe()],_e.prototype,"roundRect",null),le([pe()],_e.prototype,"createConicGradient",null),le([pe()],_e.prototype,"createLinearGradient",null),le([pe()],_e.prototype,"createPattern",null),le([pe()],_e.prototype,"createRadialGradient",null),le([pe()],_e.prototype,"fillText",null),le([pe()],_e.prototype,"measureText",null),le([pe()],_e.prototype,"strokeText",null);const{copy:fe,multiplyParent:me,pixelScale:ye}=G,{round:ve}=Math,xe=new Nt,we=new Nt,Ee={width:1,height:1,pixelRatio:1},be=["width","height","pixelRatio"];class ke extends _e{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,s){super(),this.size={},this.worldTransform={},t||(t=Ee),this.manager=s,this.innerId=i.create(i.CNAVAS);const{width:n,height:r,pixelRatio:o}=t;this.autoLayout=!n||!r,this.size.pixelRatio=o||e.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;f.copyAttrs(s,t,be),be.forEach(t=>s[t]||(s[t]=1)),this.bounds=new Nt(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&&me(t,e,n),ye(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=ve(n.e-.5)+.5,n.f=ve(n.f-.5)+.5):(n.e=ve(n.e),n.f=ve(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:r,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(s=e.strokeJoin),o(e.dashPattern)||(n=e.dashPattern),o(e.dashOffset)||(r=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=s,this.dashPattern=n,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=!0){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=we):i=xe,this.drawImage(t.view,xe.x,xe.y,xe.width,xe.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=!0){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Ft.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,xe.x,xe.y,xe.width,xe.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,r=!0){this.resetTransform(),this.copyWorld(t,e,i,s,r),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(xe.x,xe.y,xe.width,xe.height),{data:r}=n;for(let t=0,s=r.length;t<s;t+=4)i=.299*r[t]+.587*r[t+1]+.114*r[t+2],(e=r[t+3])&&(r[t+3]=255===e?i:e*(i/255));s.putImageData(n,xe.x,xe.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(xe.x,xe.y,xe.width,xe.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(xe.x,xe.y,xe.width,xe.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(xe.x,xe.y,xe.width,xe.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(xe.x,xe.y,xe.width,xe.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(xe,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(we,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):ee.canvas(Object.assign({},i));return n.save(),t&&(fe(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 Be={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Se={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Te=Object.assign({M:1,m:10,L:2,l:20,H:3,h:30,V:4,v:40,C:5,c:50,S:6,s:60,Q:7,q:70,T:8,t:80,A:9,a:90,Z:11,z:11,R:12},Se),Pe={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},Le={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},Re=Object.assign(Object.assign({},Le),Se),Ce=Te,Oe={};for(let t in Ce)Oe[Ce[t]]=t;const Me={};for(let t in Ce)Me[Ce[t]]=Pe[t];const De={drawRoundRect(t,e,i,s,n,r){const o=O.fourNumber(r,Math.min(s/2,n/2)),a=e+s,h=i+n;o[0]?t.moveTo(e+o[0],i):t.moveTo(e,i),o[1]?t.arcTo(a,i,a,h,o[1]):t.lineTo(a,i),o[2]?t.arcTo(a,h,e,h,o[2]):t.lineTo(a,h),o[3]?t.arcTo(e,h,e,i,o[3]):t.lineTo(e,h),o[0]?t.arcTo(e,i,a,i,o[0]):t.lineTo(e,i)}},{sin:Ie,cos:Ae,hypot:We,atan2:Fe,ceil:ze,abs:He,PI:Ue,sqrt:Ne,pow:Ye}=Math,{setPoint:Xe,addPoint:Ve}=pt,{set:je,toNumberPoints:Ge}=nt,{M:Ke,L:Ze,C:qe,Q:Je,Z:$e}=Te,Qe={},ti={points(t,e,i,s){let n=Ge(e);if(t.push(Ke,n[0],n[1]),i&&n.length>5){let e,r,o,a,h,l,d,c,u,p,g,_,f,m=n.length;const y=!0===i?.5:i;s&&(n=[n[m-2],n[m-1],...n,n[0],n[1],n[2],n[3]],m=n.length);for(let i=2;i<m-2;i+=2)e=n[i-2],r=n[i-1],o=n[i],a=n[i+1],h=n[i+2],l=n[i+3],g=Ne(Ye(o-e,2)+Ye(a-r,2)),_=Ne(Ye(h-o,2)+Ye(l-a,2)),(g||_)&&(f=g+_,g=y*g/f,_=y*_/f,h-=e,l-=r,d=o-g*h,c=a-g*l,2===i?s||t.push(Je,d,c,o,a):t.push(qe,u,p,d,c,o,a),u=o+_*h,p=a+_*l);s||t.push(Je,u,p,n[m-2],n[m-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(Ze,n[e],n[e+1]);s&&t.push($e)},rect(t,e,i,s,n){Be.creator.path=t,Be.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,r){Be.creator.path=[],De.drawRoundRect(Be.creator,e,i,s,n,r),t.push(...Be.convertToCanvasData(Be.creator.path,!0))},arcTo(t,e,i,s,n,r,o,a,h,l,d){const c=s-e,u=n-i,p=r-s,g=o-n;let _=Fe(u,c),f=Fe(g,p);const m=We(c,u),y=We(p,g);let v=f-_;if(v<0&&(v+=I),m<1e-12||y<1e-12||v<1e-12||He(v-Ue)<1e-12)return t&&t.push(Ze,s,n),h&&(Xe(h,e,i),Ve(h,s,n)),d&&je(d,e,i),void(l&&je(l,s,n));const x=c*g-p*u<0,w=x?-1:1,E=a/Ae(v/2),b=s+E*Ae(_+v/2+A*w),k=n+E*Ie(_+v/2+A*w);return _-=A*w,f-=A*w,si(t,b,k,a,a,0,_/D,f/D,x,h,l,d)},arc:(t,e,i,s,n,r,o,a,h,l)=>si(t,e,i,s,s,0,n,r,o,a,h,l),ellipse(t,e,i,s,n,r,o,a,h,l,d,c){const u=r*D,p=Ie(u),g=Ae(u);let _=o*D,f=a*D;_>Ue&&(_-=I),f<0&&(f+=I);let m=f-_;m<0?m+=I:m>I&&(m-=I),h&&(m-=I);const y=ze(He(m/A)),v=m/y,x=Ie(v/4),w=8/3*x*x/Ie(v/2);f=_+v;let E,b,k,B,S,T,P,L,R=Ae(_),C=Ie(_),O=k=g*s*R-p*n*C,M=B=p*s*R+g*n*C,W=e+k,F=i+B;t&&t.push(t.length?Ze:Ke,W,F),l&&Xe(l,W,F),c&&je(c,W,F);for(let r=0;r<y;r++)E=Ae(f),b=Ie(f),k=g*s*E-p*n*b,B=p*s*E+g*n*b,S=e+O-w*(g*s*C+p*n*R),T=i+M-w*(p*s*C-g*n*R),P=e+k+w*(g*s*b+p*n*E),L=i+B+w*(p*s*b-g*n*E),t&&t.push(qe,S,T,P,L,e+k,i+B),l&&ii(e+O,i+M,S,T,P,L,e+k,i+B,l,!0),O=k,M=B,R=E,C=b,_=f,f+=v;d&&je(d,e+k,i+B)},quadraticCurveTo(t,e,i,s,n,r,o){t.push(qe,(e+2*s)/3,(i+2*n)/3,(r+2*s)/3,(o+2*n)/3,r,o)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,r,o,a){ii(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(r+2*s)/3,n,r,o,a)},toTwoPointBounds(t,e,i,s,n,r,o,a,h,l){const d=[];let c,u,p,g,_,f,m,y,v=t,x=i,w=n,E=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=s,w=r,E=a),c=-3*v+9*x-9*w+3*E,u=6*v-12*x+6*w,p=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-p/u,0<g&&g<1&&d.push(g)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(_=(-u+y)/(2*c),0<_&&_<1&&d.push(_),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?Ve(h,t,e):Xe(h,t,e),Ve(h,o,a);for(let l=0,c=d.length;l<c;l++)ei(d[l],t,e,i,s,n,r,o,a,Qe),Ve(h,Qe.x,Qe.y)},getPointAndSet(t,e,i,s,n,r,o,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,g=t*t*t;l.x=c*e+u*s+p*r+g*a,l.y=c*i+u*n+p*o+g*h},getPoint(t,e,i,s,n,r,o,a,h){const l={};return ei(t,e,i,s,n,r,o,a,h,l),l},getDerivative(t,e,i,s,n){const r=1-t;return 3*r*r*(i-e)+6*r*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:ei,toTwoPointBounds:ii,ellipse:si}=ti,{sin:ni,cos:ri,sqrt:oi,atan2:ai}=Math,{ellipse:hi}=ti,li={ellipticalArc(t,i,s,n,r,o,a,h,l,d,c){const u=(l-i)/2,p=(d-s)/2,g=o*D,_=ni(g),f=ri(g),m=-f*u-_*p,y=-f*p+_*u,v=n*n,x=r*r,w=y*y,E=m*m,b=v*x-v*w-x*E;let k=0;if(b<0){const t=oi(1-b/(v*x));n*=t,r*=t}else k=(a===h?-1:1)*oi(b/(v*w+x*E));const B=k*n*y/r,S=-k*r*m/n,T=ai((y-S)/r,(m-B)/n),P=ai((-y-S)/r,(-m-B)/n);let L=P-T;0===h&&L>0?L-=I:1===h&&L<0&&(L+=I);const R=i+u+f*B-_*S,C=s+p+_*B+f*S,O=L<0?1:0;c||e.ellipseToCurve?hi(t,R,C,n,r,o,T/D,P/D,O):n!==r||o?t.push(Te.G,R,C,n,r,o,T/D,P/D,O):t.push(Te.O,R,C,n,T/D,P/D,O)}},{M:di,m:ci,L:ui,l:pi,H:gi,h:_i,V:fi,v:mi,C:yi,c:vi,S:xi,s:wi,Q:Ei,q:bi,T:ki,t:Bi,A:Si,a:Ti,Z:Pi,z:Li,N:Ri,D:Ci,X:Oi,G:Mi,F:Di,O:Ii,P:Ai,U:Wi}=Te,{rect:Fi,roundRect:zi,arcTo:Hi,arc:Ui,ellipse:Ni,quadraticCurveTo:Yi}=ti,{ellipticalArc:Xi}=li,Vi=Gt.get("PathConvert"),ji={},Gi={current:{dot:0},stringify(t,e){let i,s,n,r=0,o=t.length,a="";for(;r<o;){s=t[r],i=Me[s],a+=s===n?" ":Oe[s];for(let s=1;s<i;s++)a+=O.float(t[r+s],e),s===i-1||(a+=" ");n=s,r+=i}return a},parse(t,e){let i,s,n,r="";const o=[],a=e?Re:Le;for(let e=0,h=t.length;e<h;e++)s=t[e],Vt[s]?("."===s&&(Ki.dot&&(Zi(o,r),r=""),Ki.dot++),"0"===r&&"."!==s&&(Zi(o,r),r=""),r+=s):Te[s]?(r&&(Zi(o,r),r=""),Ki.name=Te[s],Ki.length=Pe[s],Ki.index=0,Zi(o,Ki.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?r+=s:(r&&Zi(o,r),r=s):r&&(Zi(o,r),r=""),n=s;return r&&Zi(o,r),i?Gi.toCanvasData(o,e):o},toCanvasData(t,e){let i,s,n,r,o,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(n=t[c],n){case ci:t[c+1]+=a,t[c+2]+=h;case di:a=t[c+1],h=t[c+2],p.push(di,a,h),c+=3;break;case _i:t[c+1]+=a;case gi:a=t[c+1],p.push(ui,a,h),c+=2;break;case mi:t[c+1]+=h;case fi:h=t[c+1],p.push(ui,a,h),c+=2;break;case pi:t[c+1]+=a,t[c+2]+=h;case ui:a=t[c+1],h=t[c+2],p.push(ui,a,h),c+=3;break;case wi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=xi;case xi:o=r===yi||r===xi,l=o?2*a-i:t[c+1],d=o?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],p.push(yi,l,d,i,s,a,h),c+=5;break;case vi: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=yi;case yi:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],p.push(yi,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Bi:t[c+1]+=a,t[c+2]+=h,n=ki;case ki:o=r===Ei||r===ki,i=o?2*a-i:t[c+1],s=o?2*h-s:t[c+2],e?Yi(p,a,h,i,s,t[c+1],t[c+2]):p.push(Ei,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case bi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ei;case Ei:i=t[c+1],s=t[c+2],e?Yi(p,a,h,i,s,t[c+3],t[c+4]):p.push(Ei,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Ti:t[c+6]+=a,t[c+7]+=h;case Si:Xi(p,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case Li:case Pi:p.push(Pi),c++;break;case Ri:a=t[c+1],h=t[c+2],e?Fi(p,a,h,t[c+3],t[c+4]):qi(p,t,c,5),c+=5;break;case Ci:a=t[c+1],h=t[c+2],e?zi(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):qi(p,t,c,9),c+=9;break;case Oi:a=t[c+1],h=t[c+2],e?zi(p,a,h,t[c+3],t[c+4],t[c+5]):qi(p,t,c,6),c+=6;break;case Mi:Ni(e?p:qi(p,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,ji),a=ji.x,h=ji.y,c+=9;break;case Di:e?Ni(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):qi(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Ii:Ui(e?p:qi(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,ji),a=ji.x,h=ji.y,c+=7;break;case Ai:e?Ui(p,t[c+1],t[c+2],t[c+3],0,360,!1):qi(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Wi:Hi(e?p:qi(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,ji),a=ji.x,h=ji.y,c+=6;break;default:return Vi.error(`command: ${n} [index:${c}]`,t),p}r=n}return p},objectToCanvasData(t){const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(di,t.x,t.y);break;case"L":e.push(ui,t.x,t.y);break;case"C":e.push(yi,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Ei,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Pi)}}),e},copyData(t,e,i,s){for(let n=i,r=i+s;n<r;n++)t.push(e[n])},pushData(t,e){Ki.index===Ki.length&&(Ki.index=1,t.push(Ki.name)),t.push(Number(e)),Ki.index++,Ki.dot=0}},{current:Ki,pushData:Zi,copyData:qi}=Gi,{M:Ji,L:$i,C:Qi,Q:ts,Z:es,N:is,D:ss,X:ns,G:rs,F:os,O:as,P:hs,U:ls}=Te,{getMinDistanceFrom:ds,getRadianFrom:cs}=nt,{tan:us,min:ps,abs:gs}=Math,_s={},fs={beginPath(t){t.length=0},moveTo(t,e,i){t.push(Ji,e,i)},lineTo(t,e,i){t.push($i,e,i)},bezierCurveTo(t,e,i,s,n,r,o){t.push(Qi,e,i,s,n,r,o)},quadraticCurveTo(t,e,i,s,n){t.push(ts,e,i,s,n)},closePath(t){t.push(es)},rect(t,e,i,s,n){t.push(is,e,i,s,n)},roundRect(t,e,i,s,n,r){if(d(r))t.push(ns,e,i,s,n,r);else{const o=O.fourNumber(r);o?t.push(ss,e,i,s,n,...o):t.push(is,e,i,s,n)}},ellipse(t,e,i,s,n,r,o,h,l){a(r)?t.push(os,e,i,s,n):(a(o)&&(o=0),a(h)&&(h=360),t.push(rs,e,i,s,n,r,o,h,l?1:0))},arc(t,e,i,s,n,r,o){a(n)?t.push(hs,e,i,s):(a(r)&&(r=360),t.push(as,e,i,s,n,r,o?1:0))},arcTo(t,e,i,s,n,r,a,h){if(!o(a)){const t=ds(a,h,e,i,s,n);r=ps(r,ps(t/2,t/2*gs(us(cs(a,h,e,i,s,n)/2))))}t.push(ls,e,i,s,n,r)},drawEllipse(t,e,i,s,n,r,o,h,l){ti.ellipse(null,e,i,s,n,a(r)?0:r,a(o)?0:o,a(h)?360:h,l,null,null,_s),t.push(Ji,_s.x,_s.y),ms(t,e,i,s,n,r,o,h,l)},drawArc(t,e,i,s,n,r,o){ti.arc(null,e,i,s,a(n)?0:n,a(r)?360:r,o,null,null,_s),t.push(Ji,_s.x,_s.y),ys(t,e,i,s,n,r,o)},drawPoints(t,e,i,s){ti.points(t,e,i,s)}},{ellipse:ms,arc:ys}=fs,{moveTo:vs,lineTo:xs,quadraticCurveTo:ws,bezierCurveTo:Es,closePath:bs,beginPath:ks,rect:Bs,roundRect:Ss,ellipse:Ts,arc:Ps,arcTo:Ls,drawEllipse:Rs,drawArc:Cs,drawPoints:Os}=fs;class Ms{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?h(t)?Be.parse(t):t:[],this}beginPath(){return ks(this.__path),this.paint(),this}moveTo(t,e){return vs(this.__path,t,e),this.paint(),this}lineTo(t,e){return xs(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,r){return Es(this.__path,t,e,i,s,n,r),this.paint(),this}quadraticCurveTo(t,e,i,s){return ws(this.__path,t,e,i,s),this.paint(),this}closePath(){return bs(this.__path),this.paint(),this}rect(t,e,i,s){return Bs(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Ss(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,r,o,a){return Ts(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}arc(t,e,i,s,n,r){return Ps(this.__path,t,e,i,s,n,r),this.paint(),this}arcTo(t,e,i,s,n){return Ls(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,r,o,a){return Rs(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}drawArc(t,e,i,s,n,r){return Cs(this.__path,t,e,i,s,n,r),this.paint(),this}drawPoints(t,e,i){return Os(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Ds,L:Is,C:As,Q:Ws,Z:Fs,N:zs,D:Hs,X:Us,G:Ns,F:Ys,O:Xs,P:Vs,U:js}=Te,Gs=Gt.get("PathDrawer"),Ks={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Ds:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Is:t.lineTo(e[s+1],e[s+2]),s+=3;break;case As:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Ws:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Fs: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 Hs:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case Us:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Ns:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*D,e[s+6]*D,e[s+7]*D,e[s+8]),s+=9;break;case Ys:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,I,!1),s+=5;break;case Xs:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*D,e[s+5]*D,e[s+6]),s+=7;break;case Vs:t.arc(e[s+1],e[s+2],e[s+3],0,I,!1),s+=4;break;case js:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void Gs.error(`command: ${i} [index:${s}]`,e)}}},{M:Zs,L:qs,C:Js,Q:$s,Z:Qs,N:tn,D:en,X:sn,G:nn,F:rn,O:on,P:an,U:hn}=Te,{toTwoPointBounds:ln,toTwoPointBoundsByQuadraticCurve:dn,arcTo:cn,arc:un,ellipse:pn}=ti,{addPointBounds:gn,copy:_n,addPoint:fn,setPoint:mn,addBounds:yn,toBounds:vn}=pt,xn=Gt.get("PathBounds");let wn,En,bn;const kn={},Bn={},Sn={},Tn={toBounds(t,e){Tn.toTwoPointBounds(t,Bn),vn(Bn,e)},toTwoPointBounds(t,e){if(!t||!t.length)return mn(e,0,0);let i,s,n,r,o,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(o=t[a],0===a&&(o===Qs||o===Js||o===$s?mn(e,h,l):mn(e,t[a+1],t[a+2])),o){case Zs:case qs:h=t[a+1],l=t[a+2],fn(e,h,l),a+=3;break;case Js:n=t[a+5],r=t[a+6],ln(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,r,kn),gn(e,kn),h=n,l=r,a+=7;break;case $s:i=t[a+1],s=t[a+2],n=t[a+3],r=t[a+4],dn(h,l,i,s,n,r,kn),gn(e,kn),h=n,l=r,a+=5;break;case Qs:a+=1;break;case tn:h=t[a+1],l=t[a+2],yn(e,h,l,t[a+3],t[a+4]),a+=5;break;case en:case sn:h=t[a+1],l=t[a+2],yn(e,h,l,t[a+3],t[a+4]),a+=o===en?9:6;break;case nn:pn(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],kn,Sn),0===a?_n(e,kn):gn(e,kn),h=Sn.x,l=Sn.y,a+=9;break;case rn:h=t[a+1],l=t[a+2],En=t[a+3],bn=t[a+4],yn(e,h-En,l-bn,2*En,2*bn),h+=En,a+=5;break;case on:un(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],kn,Sn),0===a?_n(e,kn):gn(e,kn),h=Sn.x,l=Sn.y,a+=7;break;case an:h=t[a+1],l=t[a+2],wn=t[a+3],yn(e,h-wn,l-wn,2*wn,2*wn),h+=wn,a+=4;break;case hn:cn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],kn,Sn),0===a?_n(e,kn):gn(e,kn),h=Sn.x,l=Sn.y,a+=6;break;default:return void xn.error(`command: ${o} [index:${a}]`,t)}}},{M:Pn,L:Ln,Z:Rn}=Te,{getCenterX:Cn,getCenterY:On}=nt,{arcTo:Mn}=fs,Dn={smooth(t,e,i){let s,n,r,o=0,a=0,h=0,l=0,d=0,c=0,u=0,p=0,g=0;const _=t.length,f=[];for(;o<_;){switch(s=t[o],s){case Pn:l=p=t[o+1],d=g=t[o+2],o+=3,t[o]===Ln?(c=t[o+1],u=t[o+2],f.push(Pn,Cn(l,c),On(d,u))):f.push(Pn,l,d);break;case Ln:switch(a=t[o+1],h=t[o+2],o+=3,t[o]){case Ln:Mn(f,a,h,t[o+1],t[o+2],e,p,g);break;case Rn:Mn(f,a,h,l,d,e,p,g);break;default:f.push(Ln,a,h)}p=a,g=h;break;case Rn:n!==Rn&&(Mn(f,l,d,c,u,e,p,g),f.push(Rn)),o+=1;break;default:r=Me[s];for(let e=0;e<r;e++)f.push(t[o+e]);o+=r}n=s}return s!==Rn&&(f[1]=l,f[2]=d),f}};function In(t){return new Ms(t)}const An=In();Be.creator=In(),Be.parse=Gi.parse,Be.convertToCanvasData=Gi.toCanvasData;const{drawRoundRect:Wn}=De;function Fn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Wn(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=Hn.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{}}}},Hn=zn;Hn.alphaPixelTypes.forEach(t=>Hn.upperCaseTypeMap[t]=t.toUpperCase());const Un=Gt.get("TaskProcessor");class Nn{constructor(t){this.parallel=!0,this.time=1,this.id=i.create(i.TASK),this.task=t}run(){return de(this,void 0,void 0,function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){Un.error(t)}})}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class Yn{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&&f.assign(this.config,t),this.empty()}add(t,e){let i,s,n,r;const a=new Nn(t);return a.parent=this,d(e)?r=e:e&&(s=e.parallel,i=e.start,n=e.time,r=e.delay),n&&(a.time=n),!1===s&&(a.parallel=!1),o(r)?this.push(a,i):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(a,i))},r)),this.isComplete=!1,a}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout(()=>this.start()))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[],this.delayNumber=0}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach(t=>{t.isComplete||t.cancel()}),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];if(t)return t.isCancel?(this.index++,void this.runTask()):void t.run().then(()=>{this.onTask(t),this.index++,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 Xn=Gt.get("Resource"),Vn={tasker:new Yn,map:{},get isComplete(){return jn.tasker.isComplete},set(t,e){jn.map[t]&&Xn.repeat(t),jn.map[t]=e},get:t=>jn.map[t],remove(t){const e=jn.map[t];e&&(e.destroy&&e.destroy(),delete jn.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=ee.image(s)),jn.set(t,e),e},destroy(){jn.map={}}},jn=Vn,Gn={maxRecycled:10,recycledList:[],patternTasker:new Yn,get(t){let e=Vn.get(t.url);return e||Vn.set(t.url,e=ee.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||Kn.recycledList.push(t)})},clearRecycled(){const t=Kn.recycledList;t.length>Kn.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&Vn.remove(t.url)),t.length=0)},hasAlphaPixel:t=>zn.alphaPixelTypes.some(e=>Kn.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(){Kn.recycledList=[]}},Kn=Gn,{IMAGE:Zn,create:qn}=i,{floor:Jn,max:$n}=Math;class Qn{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=qn(Zn),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}Gn.isFormat("svg",t)&&(this.isSVG=!0),Gn.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,i){if(!this.loading){this.loading=!0;let{loadImage:t,loadImageWithProgress:i}=e.origin,s=this.config.showProgress&&i&&this.onProgress.bind(this);s&&(t=i),Vn.tasker.add(()=>de(this,void 0,void 0,function*(){return yield t(this.url,s).then(t=>this.setView(t)).catch(t=>{this.error=t,this.onComplete(!1)})}))}return this.waitComplete.push(t,i),this.waitComplete.length-2}unload(t,e){const i=this.waitComplete;if(e){const e=i[t+1];e&&e({type:"stop"})}i[t]=i[t+1]=void 0}setView(t){this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onProgress(t){this.progress=t}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,i,s,n,r,o,a){if(t||(t=this.width),i||(i=this.height),this.cache){let{params:t,data:e}=this.cache;for(let i in t)if(t[i]!==arguments[i]){e=null;break}if(e)return e}const h=e.origin.createCanvas($n(Jn(t+(r||0)),1),$n(Jn(i+(o||0)),1)),l=h.getContext("2d");return s&&(l.globalAlpha=s),l.imageSmoothingEnabled=!1!==a,l.drawImage(this.view,0,0,t,i),this.cache=this.use>1?{data:h,params:arguments}:null,h}getPattern(t,i,s,n){const r=e.canvas.createPattern(t,i);try{s&&r.setTransform&&(r.setTransform(s),s=void 0)}catch(t){}return n&&f.stintSet(n,"transform",s),r}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function tr(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function er(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ir(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function sr(t,e){return(i,s)=>rr(i,s,t,e&&e(s))}function nr(t){return t}function rr(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};tr(t,e,Object.assign(n,s||{})),Mr(t,e,i)}function or(t){return sr(t)}function ar(t,e){return sr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function hr(t,e){return sr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function lr(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),gr(this))}}))}function dr(t,e){return sr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function cr(t,e){return sr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function ur(t,e){return sr(t,t=>({set(i){this.__setAttr(t,i,e)&&gr(this)}}))}function pr(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&(gr(this),this.__.__removeNaturalSize())}}))}function gr(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function _r(t){return sr(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),gr(this)}}))}const fr=ur;function mr(t,e){return sr(t,t=>({set(i){this.__setAttr(t,i)&&(yr(this),e&&(this.__.__useStroke=!0))}}))}function yr(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&gr(t)}const vr=mr;function xr(t){return sr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function wr(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Er(t){return sr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;f.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function br(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Br(this)}}))}function kr(t){return sr(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Sr(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Sr(this,t,e,i),this.mask&&Br(this)}}))}function Br(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Sr(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||gr(t))}function Tr(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Pr(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function Lr(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Rr(t){return sr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===Gt.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function Cr(t){return sr(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Or(t){return(e,i)=>{tr(e,"__DataProcessor",{get:()=>t})}}function Mr(t,e,i){const s=t.__DataProcessor.prototype,n="_"+e,r=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=ir(e,i);if(o(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=_(i);a.get=function(){const e=this[n];return null==e?this[n]=t?{}:f.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=er(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),s[r]&&(a.set=s[r],delete s[r]),tr(s,e,a)}const Dr=new Gt("rewrite"),Ir=[],Ar=["destroy","constructor"];function Wr(t){return(e,i)=>{Ir.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function Fr(){return t=>{zr()}}function zr(t){Ir.length&&(Ir.forEach(e=>{t&&Dr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Ir.length=0)}function Hr(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Ar.includes(s)||e&&e.includes(s)))if(t.prototype){er(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Ur(){return t=>{se.register(t)}}function Nr(){return t=>{oe.register(t)}}setTimeout(()=>zr(!0));const{copy:Yr,toInnerPoint:Xr,toOuterPoint:Vr,scaleOfOuter:jr,rotateOfOuter:Gr,skewOfOuter:Kr,multiplyParent:Zr,divideParent:qr,getLayout:Jr}=G,$r={},{round:Qr}=Math,to={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),so(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)io(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++)no(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&no(t),t.__updateChange()},updateAllChange(t){if(oo(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)ro(e[t])}},worldHittable(t){for(;t;){if(!t.__.hittable)return!1;t=t.parent}return!0},draggable:t=>(t.draggable||t.editable)&&t.hitSelf&&!t.locked,copyCanvasByWorld(t,i,s,n,r,o){n||(n=t.__nowWorld),t.__worldFlipped||e.fullImageShadow?i.copyWorldByReset(s,n,t.__nowWorld,r,o):i.copyWorldToInner(s,n,t.__layout.renderBounds,r)},moveWorld(t,e,i=0,s,n){const r=p(e)?Object.assign({},e):{x:e,y:i};s?Vr(t.localTransform,r,r,!0):t.parent&&Xr(t.parent.scrollWorldTransform,r,r,!0),eo.moveLocal(t,r.x,r.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=Qr(e),i=Qr(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,r){eo.zoomOfLocal(t,ao(t,e),i,s,n,r)},zoomOfLocal(t,e,i,s=i,n,r){const o=t.__localMatrix;if(d(s)||(s&&(r=s),s=i),Yr($r,o),jr($r,e,i,s),eo.hasHighPosition(t))eo.setTransform(t,$r,n,r);else{const e=t.x+$r.e-o.e,a=t.y+$r.f-o.f;r&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},r):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){eo.rotateOfLocal(t,ao(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Yr($r,n),Gr($r,e,i),eo.hasHighPosition(t)?eo.setTransform(t,$r,!1,s):t.set({x:t.x+$r.e-n.e,y:t.y+$r.f-n.f,rotation:O.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,r){eo.skewOfLocal(t,ao(t,e),i,s,n,r)},skewOfLocal(t,e,i,s=0,n,r){Yr($r,t.__localMatrix),Kr($r,e,i,s),eo.setTransform(t,$r,n,r)},transformWorld(t,e,i,s){Yr($r,t.worldTransform),Zr($r,e),t.parent&&qr($r,t.parent.scrollWorldTransform),eo.setTransform(t,$r,i,s)},transform(t,e,i,s){Yr($r,t.localTransform),Zr($r,e),eo.setTransform(t,$r,i,s)},setTransform(t,e,i,s){const n=t.__,r=n.origin&&eo.getInnerOrigin(t,n.origin),o=Jr(e,r,n.around&&eo.getInnerOrigin(t,n.around));if(eo.hasOffset(t)&&(o.x-=n.offsetX,o.y-=n.offsetY),i){const e=o.scaleX/t.scaleX,i=o.scaleY/t.scaleY;if(delete o.scaleX,delete o.scaleY,r){Ft.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=eo.getInnerOrigin(t,n.origin);nt.move(o,r.x-s.x,r.y-s.y)}t.set(o),t.scaleResize(e,i,!1)}else t.set(o,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return jr(i,eo.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>nt.tempToOuterOf(eo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return yt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Yr($r,t.worldTransform),qr($r,e.scrollWorldTransform),i?$r:Object.assign({},$r)),drop(t,e,i,s){t.setTransform(eo.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||eo.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,i,s=.3){if(i.x||i.y)if(Math.abs(i.x)<1&&Math.abs(i.y)<1)t.move(i);else{const n=i.x*s,r=i.y*s;i.x-=n,i.y-=r,t.move(n,r),e.requestRender(()=>eo.animateMove(t,i,s))}}},eo=to,{updateAllMatrix:io,updateMatrix:so,updateAllWorldOpacity:no,updateAllChange:ro,updateChange:oo}=eo;function ao(t,e){return t.updateLayout(),t.parent?nt.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const ho={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)=>co(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>co(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>co(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 lo;function co(t,e){return e||(lo=0),t.__.mask&&(lo=1),lo<0?null:(lo&&(lo=-1),!0)}const{updateBounds:uo}=to,po={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),go(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&o(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++)_o(e[t],e)},updateBounds(t,e){const i=[t];_o(t,i),fo(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++)uo(s[t]);e&&e===i||uo(i)}}},{pushAllChildBranch:go,pushAllBranchStack:_o,updateBoundsByBranchStack:fo}=po,mo={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:yo,updateBounds:vo}=to,{toOuterOf:xo,getPoints:wo,copy:Eo}=Ft,bo="_localContentBounds",ko="_worldContentBounds",Bo="_worldBoxBounds",So="_worldStrokeBounds";class To{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 xo(this.contentBounds,this.leaf.__localMatrix,this[bo]||(this[bo]={})),this[bo]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return xo(this.contentBounds,this.leaf.__world,this[ko]||(this[ko]={})),this[ko]}get worldBoxBounds(){return xo(this.boxBounds,this.leaf.__world,this[Bo]||(this[Bo]={})),this[Bo]}get worldStrokeBounds(){return xo(this.strokeBounds,this.leaf.__world,this[So]||(this[So]={})),this[So]}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:i}=t;if(t.isApp)return vo(t);if(i)i.ready?i.watcher.changed&&i.layouter.layout():i.start();else{let i=t;for(;i.parent&&!i.parent.leafer;)i=i.parent;const s=i;if(s.__fullLayouting)return;s.__fullLayouting=!0,e.layout(s),delete s.__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 G.defaultMatrix;case"page":t=e.zoomLayer;default:return yo(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 Nt(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,r,o,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),r=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;o={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,r=G.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),r=yo(s,e,!0)}if(o||(o=G.getLayout(r)),Eo(o,a),nt.copy(o,n),i){const{scaleX:t,scaleY:e}=o,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(o.scaleX/=i,o.scaleY/=s,o.width*=i,o.height*=s)}return o}getLayoutPoints(t,e="world"){const{leaf:i}=this,s=wo(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:n=e}return o(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 Po{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&e.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&e.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&e.event.stop(this.origin)}}class Lo extends Po{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Lo.ADD="child.add",Lo.REMOVE="child.remove",Lo.CREATED="created",Lo.MOUNTED="mounted",Lo.UNMOUNTED="unmounted",Lo.DESTROY="destroy";const Ro="property.scroll";class Co extends Po{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Co.CHANGE="property.change",Co.LEAFER_CHANGE="property.leafer_change",Co.SCROLL=Ro;const Oo={scrollX:Ro,scrollY:Ro};class Mo extends Po{constructor(t,e){super(t),Object.assign(this,e)}}Mo.LOAD="image.load",Mo.LOADED="image.loaded",Mo.ERROR="image.error";class Do extends Po{static checkHas(t,e,i){"on"===i?e===Fo?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Io)||t.hasEvent(Ao)||t.hasEvent(Wo),t.__hasWorldEvent=t.hasEvent(Fo))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Io,t),"inner"===e&&t.emit(Ao,t)),t.emit(Wo,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Fo,this)}}Do.RESIZE="bounds.resize",Do.INNER="bounds.inner",Do.LOCAL="bounds.local",Do.WORLD="bounds.world";const{RESIZE:Io,INNER:Ao,LOCAL:Wo,WORLD:Fo}=Do,zo={};[Io,Ao,Wo,Fo].forEach(t=>zo[t]=1);class Ho extends Po{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(Ho.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!o(this.resizingKeys[t.innerId])}}Ho.RESIZE="resize";class Uo extends Po{constructor(t,e){super(t),this.data=e}}Uo.REQUEST="watch.request",Uo.DATA="watch.data";class No extends Po{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}No.REQUEST="layout.request",No.START="layout.start",No.BEFORE="layout.before",No.LAYOUT="layout",No.AFTER="layout.after",No.AGAIN="layout.again",No.END="layout.end";class Yo extends Po{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Yo.REQUEST="render.request",Yo.CHILD_START="render.child_start",Yo.CHILD_END="render.child_end",Yo.START="render.start",Yo.BEFORE="render.before",Yo.RENDER="render",Yo.AFTER="render.after",Yo.AGAIN="render.again",Yo.END="render.end",Yo.NEXT="render.next";class Xo extends Po{}Xo.START="leafer.start",Xo.BEFORE_READY="leafer.before_ready",Xo.READY="leafer.ready",Xo.AFTER_READY="leafer.after_ready",Xo.VIEW_READY="leafer.view_ready",Xo.VIEW_COMPLETED="leafer.view_completed",Xo.STOP="leafer.stop",Xo.RESTART="leafer.restart",Xo.END="leafer.end",Xo.UPDATE_MODE="leafer.update_mode",Xo.TRANSFORM="leafer.transform",Xo.MOVE="leafer.move",Xo.SCALE="leafer.scale",Xo.ROTATE="leafer.rotate",Xo.SKEW="leafer.skew";const{MOVE:Vo,SCALE:jo,ROTATE:Go,SKEW:Ko}=Xo,Zo={x:Vo,y:Vo,scaleX:jo,scaleY:jo,rotation:Go,skewX:Ko,skewY:Ko},qo={};class Jo{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(u(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)u(e=t[i])?this.on(i,e[0],e[1]):this.on(i,e);return}let s,n,r;i&&("once"===i?n=!0:"boolean"==typeof i?s=i:(s=i.capture,n=i.once));const o=$o(this,s,!0),a=h(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};a.forEach(t=>{t&&(r=o[t],r?-1===r.findIndex(t=>t.listener===e)&&r.push(l):o[t]=[l],zo[t]&&Do.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=h(t)?t.split(" "):t;if(e){let t,n,r;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const o=$o(this,t);s.forEach(t=>{t&&(n=o[t],n&&(r=n.findIndex(t=>t.listener===e),r>-1&&n.splice(r,1),n.length||delete o[t],zo[t]&&Do.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):u(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=u(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):u(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 u(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&&oe.has(t)&&(e=oe.get(t,{type:t,target:this,current:this}));const s=$o(this,i)[t];if(s){let n;for(let r=0,o=s.length;r<o&&!((n=s[r])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),r--,o--),e&&e.isStopNow));r++);}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],r=s&&s[t];return!!(o(e)?n||r:e?r:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function $o(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:qo)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:qo)}}const{on:Qo,on_:ta,off:ea,off_:ia,once:sa,emit:na,emitEvent:ra,hasEvent:oa,destroy:aa}=Jo.prototype,ha={on:Qo,on_:ta,off:ea,off_:ia,once:sa,emit:na,emitEvent:ra,hasEvent:oa,destroyEventer:aa},la=Gt.get("setAttr"),da={__setAttr(t,e,i){if(this.leaferIsCreated){const s=this.__.__getInput(t);if(!i||l(e)||o(e)||(la.warn(this.innerName,t,e),e=void 0),p(e)||s!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Co(Co.LEAFER_CHANGE,this,t,s,e));const i=Zo[t];i&&(this.emitEvent(new Xo(i,this)),this.emitEvent(new Xo(Xo.TRANSFORM,this)))}this.emitPropertyEvent(Co.CHANGE,t,s,e);const i=Oo[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 Co(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||o(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ca,multiplyParent:ua,translateInner:pa,defaultWorld:ga}=G,{toPoint:_a,tempPoint:fa}=yt,ma={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;ua(this.__local||e,t?t.__scrollWorld||t.__world:ga,i,!!e.affectScaleOrRotation,n),s&&pa(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)&&(ca(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)&&(_a(i.around||i.origin,t.boxBounds,fa),pa(e,-fa.x,-fa.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:ya,updateAllMatrix:va}=to,{updateBounds:xa}=po,{toOuterOf:wa,copyAndSpread:Ea,copy:ba}=Ft,{toBounds:ka}=Tn,Ba={__updateWorldBounds(){const t=this.__layout;wa(t.renderBounds,this.__world,this.__world),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Do.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Do.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(),wa(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){wa(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){wa(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?ka(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(),va(this),xa(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(va(this),xa(this,this))):ya(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Ea(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;d(i)&&i<=0?ba(e.renderBounds,e.strokeBounds):Ea(e.renderBounds,e.boxBounds,i)}},Sa={__render(t,e){if(e.shape)return this.__renderShape(t,e);if(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),to.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);Gt.showBounds&&Gt.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:Ta}=ho,Pa={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__nowWorld=this.__getNowWorld(e),this.__worldOpacity){const i=this.__;if(i.__useDim)if(i.dim)e.dimOpacity=!0===i.dim?.2:i.dim;else{if(i.bright&&!e.topRendering)return e.topList.add(this);i.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(i.__single&&!this.isBranchLeaf){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!1,!0);this.__renderBranch(s,e);const n=this.__nowWorld;t.opacity=e.dimOpacity?i.opacity*e.dimOpacity:i.opacity,t.copyWorldByReset(s,n,n,i.__blendMode,!0),s.recycle(n)}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++)Ta(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++)Ta(i[s],e)||i[s].__clip(t,e)}}},La={},{LEAF:Ra,create:Ca}=i,{stintSet:Oa}=f,{toInnerPoint:Ma,toOuterPoint:Da,multiplyParent:Ia}=G,{toOuterOf:Aa}=Ft,{copy:Wa,move:Fa}=nt,{moveLocal:za,zoomOfLocal:Ha,rotateOfLocal:Ua,skewOfLocal:Na,moveWorld:Ya,zoomOfWorld:Xa,rotateOfWorld:Va,skewOfWorld:ja,transform:Ga,transformWorld:Ka,setTransform:Za,getFlipTransform:qa,getLocalOrigin:Ja,getRelativeWorld:$a,drop:Qa}=to;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 y}get __LayoutProcessor(){return To}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=Ca(Ra),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Lo.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(Lo.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Lo.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(Lo.MOUNTED)):this.__emitLifeEvent(Lo.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){o(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=o(e)?null:void 0,this[t]=e}forceRender(t,e){this.forceUpdate("surface")}__extraUpdate(){this.leaferIsReady&&this.leafer.layouter.addExtra(this)}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(t,e){}__updateContentBounds(){}__updateStrokeBounds(t){}__updateRenderBounds(t){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some(t=>t.__.eraser)}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:i}=this.__layout;t.clearRect(i.x,i.y,i.width,i.height),t.restore()}__updateMask(t){this.__hasMask=this.children.some(t=>t.__.mask&&t.__.visible&&t.__.opacity)}__renderMask(t,e){}__getNowWorld(t){if(t.matrix){this.__cameraWorld||(this.__cameraWorld={});const e=this.__cameraWorld,i=this.__world;return Ia(i,t.matrix,e,void 0,i),Aa(this.__layout.renderBounds,e,e),Oa(e,"half",i.half),Oa(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}=Gn.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),La.scaleX=i,La.scaleY=s,La}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?$a(this,e):this.worldTransform,n=i?t:{};return Aa(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Wa(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Wa(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Ma(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Da(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:r,y:o}=this.boxBounds;return Fa(n,-r,-o),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:r,y:o}=this.boxBounds;return Fa(n,r,o),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){Za(this,t,e,i)}transform(t,e,i){Ga(this,t,e,i)}move(t,e,i){za(this,t,e,i)}moveInner(t,e,i){Ya(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Ha(this,Ja(this,t),e,i,s,n)}rotateOf(t,e,i){Ua(this,Ja(this,t),e,i)}skewOf(t,e,i,s,n){Na(this,Ja(this,t),e,i,s,n)}transformWorld(t,e,i){Ka(this,t,e,i)}moveWorld(t,e,i){Ya(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){Xa(this,t,e,i,s,n)}rotateOfWorld(t,e){Va(this,t,e)}skewOfWorld(t,e,i,s,n){ja(this,t,e,i,s,n)}flip(t,e){Ga(this,qa(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){return!0}__hit(t){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return te.need("path")}getMotionPoint(t){return te.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){Qa(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):Mr(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=ur),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Lo(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Lo.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},t.Leaf=le([Hr(da),Hr(ma),Hr(Ba),Hr(ha),Hr(Sa)],t.Leaf);const{setListWithFn:th}=Ft,{sort:eh}=po,{localBoxBounds:ih,localStrokeBounds:sh,localRenderBounds:nh,maskLocalBoxBounds:rh,maskLocalStrokeBounds:oh,maskLocalRenderBounds:ah}=ho,hh=new Gt("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){th(e||this.__layout.boxBounds,this.children,this.__hasMask?rh:ih)}__updateStrokeBounds(t){th(t||this.__layout.strokeBounds,this.children,this.__hasMask?oh:sh)}__updateRenderBounds(t){th(t||this.__layout.renderBounds,this.children,this.__hasMask?ah:nh)}__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(eh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return hh.warn("add self or destroyed");const i=o(e);if(!t.__){if(u(t))return t.forEach(t=>{this.add(t,e),i||e++});t=se.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(Lo.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Lo.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)):o(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(Lo.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Lo.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Lo(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}},t.Branch=le([Hr(Pa)],t.Branch);class lh{get length(){return this.list.length}constructor(t){this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return t&&!o(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return o(e)?-1:e}add(t){const{list:e,keys:i}=this;o(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(o(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++)o(i)?e[s].innerId===t.innerId&&(i=s,delete this.keys[t.innerId]):this.keys[e[s].innerId]=s-1;o(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 lh;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 dh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(u(t)?this.addList(t):this.add(t))}has(t){return!o(this.keys[t.innerId])}without(t){return o(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 ch extends ke{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.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}}Fn(OffscreenCanvasRenderingContext2D.prototype),Fn(Path2D.prototype);const{mineType:uh}=zn;function ph(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:uh(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:uh(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=ee.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(ee,{canvas:(t,e)=>new ch(t,e),image:t=>new Qn(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},tr(e,"devicePixelRatio",{get:()=>1});const{userAgent:gh}=navigator;gh.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),gh.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):gh.indexOf("Mac")>-1?e.os="Mac":gh.indexOf("Linux")>-1&&(e.os="Linux");class _h{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new lh;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 lh,this.target=t,e&&(this.config=f.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(Yo.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===Lo.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 Uo(Uo.DATA,{updatedList:this.updatedList})),this.__updatedList=new lh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Co.CHANGE,this.__onAttrChange,this],[[Lo.ADD,Lo.REMOVE],this.__onChildEvent,this],[Uo.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:fh,updateBounds:mh,updateChange:yh}=to,{pushAllChildBranch:vh,pushAllParent:xh}=po;const{worldBounds:wh}=ho;class Eh{constructor(t){this.updatedBounds=new Nt,this.beforeBounds=new Nt,this.afterBounds=new Nt,u(t)&&(t=new lh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,wh)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,wh),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:bh,updateAllChange:kh}=to,Bh=Gt.get("Layouter");class Sh{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new dh,this.target=t,e&&(this.config=f.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(No.START),this.layoutOnce(),t.emitEvent(new No(No.END,this.layoutedBlocks,this.times))}catch(t){Bh.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Bh.warn("layouting"):this.times>3?Bh.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Uo.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=Jt.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:o}=No,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new No(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?(fh(t,!0),e.add(t),t.isBranch&&vh(t,e),xh(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),xh(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||mh(s[t])}mh(i)}})}(this.__levelList),function(t){t.list.forEach(yh)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new No(r,a,this.times)),i.emitEvent(new No(o,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,Jt.end(e)}fullLayout(){const t=Jt.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=No,r=this.getBlocks(new lh(e));e.emitEvent(new No(i,r,this.times)),Sh.fullLayout(e),r.forEach(t=>{t.setAfter()}),e.emitEvent(new No(s,r,this.times)),e.emitEvent(new No(n,r,this.times)),this.addBlocks(r),Jt.end(t)}static fullLayout(t){bh(t,!0),t.isBranch?po.updateBounds(t):to.updateBounds(t),kh(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Eh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Eh(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_([[No.REQUEST,this.layout,this],[No.AGAIN,this.layoutAgain,this],[Uo.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Th=Gt.get("Renderer");class Ph{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=f.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(No.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Yo.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Yo.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Yo.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new Nt,Th.log(e.innerName,"---\x3e");try{this.emitRender(Yo.START),this.renderOnce(t),this.emitRender(Yo.END,this.totalBounds),Gn.clearRecycled()}catch(t){this.rendering=!1,Th.error(t)}Th.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Th.warn("rendering");if(this.times>3)return Th.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new Nt,this.renderOptions={},t)this.emitRender(Yo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Yo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Yo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Yo.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=Jt.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new Nt(s);i.save(),s.spread(Ph.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),Jt.end(e)}fullRender(){const t=Jt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),Jt.end(t)}__render(t,i){const{canvas:s}=this,n=t.includes(this.target.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),Gt.showRepaint&&Gt.drawRepaint(s,t),e.render(this.target,s,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new Nt;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 i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new Nt(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 Nt(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||Th.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 Yo(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Yo.REQUEST,this.update,this],[No.END,this.__onLayoutEnd,this],[Yo.AGAIN,this.renderAgain,this],[Ho.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Ph.clipSpread=10;const{hitRadiusPoint:Lh}=Ft;class Rh{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,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new lh(i.findList),i.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,a=this.getBestMatchLeaf(o,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:o.length?this.getThroughPath(o):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 lh;if(t.length){let e;const{x:s,y:r}=this.point,o={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=t.length;s<r;s++)if(e=t[s],(i||to.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&to.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=>to.worldHittable(t))}getPath(t){const e=new lh,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 lh;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 lh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,r;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(r=s.list[t],!n||!n.has(r));t++)e.add(r)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let r=t.length-1;r>-1;r--)i=t[r],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||Lh(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:r}=s;for(let s=0,o=r.length;s<o;s++)if(i=r[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 Ch{constructor(t,e){this.config={},e&&(this.config=f.default(e,this.config)),this.picker=new Rh(this.target=t,this),this.finder=ee.finder&&ee.finder()}getByPoint(t,i,s){const{target:n,picker:r}=this;return e.backgrounder&&n&&n.updateLayout(),r.getByPoint(t,i,s)}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):te.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Oh(t){return sr(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Mh(t){return sr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Dh(){return(t,e)=>{const i="_"+e;tr(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(ee,{watcher:(t,e)=>new _h(t,e),layouter:(t,e)=>new Sh(t,e),renderer:(t,e,i)=>new Ph(t,e,i),selector:(t,e)=>new Ch(t,e)}),e.layout=Sh.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new lh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Ih={},Ah={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},Wh={number:(t,e)=>p(t)?"percent"===t.type?t.value*e:t.value:t},Fh={},zh={},Hh={},Uh={},Nh={},Yh={apply(){te.need("filter")}},Xh={},Vh={setStyleName:()=>te.need("state"),set:()=>te.need("state")},jh={list:{},register(t,e){jh.list[t]=e},get:t=>jh.list[t]},{parse:Gh,objectToCanvasData:Kh}=Gi,{stintSet:Zh}=f,{hasTransparent:qh}=Ah,Jh={},$h=Gt.get("UIData");class Qh extends y{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,$h.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,$h.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),h(t)||!t?(Zh(this,"__isTransparentFill",qh(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):p(t)&&this.__setPaint("fill",t)}setStroke(t){h(t)||!t?(Zh(this,"__isTransparentStroke",qh(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?Gh(t):Kh(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){tl(this,"shadow",t)}setInnerShadow(t){tl(this,"innerShadow",t)}setFilter(t){tl(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&zh.compute("fill",this.__leaf),e&&zh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),o(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(),u(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=Jh)):(this.__isStrokes=!0,this._stroke||(this._stroke=Jh))}__removePaint(t,e){e&&this.__removeInput(t),Hh.recycleImage(t,this),"fill"===t?(Zh(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(Zh(this,"__isAlphaPixelStroke",void 0),Zh(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function tl(t,e,i){t.__setInput(e,i),u(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 el extends Qh{}class il extends el{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 sl extends el{__getInputData(t,e){const i=super.__getInputData(t,e);return be.forEach(t=>delete i[t]),i}}class nl extends il{}class rl extends Qh{get __usePathBox(){return this.points||this.__pathInputed}}class ol extends Qh{get __boxStroke(){return!this.__pathInputed}}class al extends Qh{get __boxStroke(){return!this.__pathInputed}}class hl extends rl{}class ll extends Qh{}class dl extends Qh{get __pathInputed(){return 2}}class cl extends el{}const ul={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class pl extends Qh{get __useNaturalRatio(){return!1}setFontWeight(t){h(t)?(this.__setInput("fontWeight",t),t=ul[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=se.get("Rect",0);const n=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=n.boxBounds),i.set(t),r.strokeChanged&&n.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class gl extends ol{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 _l extends ol{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:fl,add:ml}=k,yl={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,r=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),r&&(t=fl(t,r.__layout.strokeSpread=r.__updateStrokeSpread()),e=Math.max(e,r.__layout.strokeBoxSpread)),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:r,renderSpread:o}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=Nh.getShadowRenderSpread(this,e)),s&&(t=fl(t,s)),r&&(t=ml(t,Yh.getSpread(r))),o&&(t=ml(t,o)),a&&(t=ml(t,a));let l=t;return i&&(l=fl(l,Nh.getInnerShadowSpread(this,i))),n&&(l=fl(l,n)),this.__layout.renderShapeSpread=l,h?fl(h.__updateRenderSpread(),t):t}},{stintSet:vl}=f,xl={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);vl(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),vl(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;vl(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!Nh.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(u(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),vl(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){wl(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:r,__drawAfterFill:o,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=zh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&Nh.shadow(this,t,h),a&&(s.__isStrokes?zh.strokes(r,this,t):zh.stroke(r,this,t)),n&&(s.__isFills?zh.fills(n,this,t):zh.fill(n,this,t)),o&&this.__drawAfterFill(t,e),d&&Nh.innerShadow(this,t,h),r&&!a&&(s.__isStrokes?zh.strokes(r,this,t):zh.stroke(r,this,t)),c&&Yh.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?zh.strokes(r,this,t):zh.stroke(r,this,t)),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,Ah.string(e.color))}n&&(s.__isFills?zh.fills(n,this,t):zh.fill(n,this,t)),h&&t.restore(),o&&this.__drawAfterFill(t,e),r&&!a&&(s.__isStrokes?zh.strokes(r,this,t):zh.stroke(r,this,t))}}else s.__pathInputed?wl(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?zh.fills(s,this,t):zh.fill("#000000",this,t)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?zh.strokes(n,this,t):zh.stroke("#000000",this,t))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function wl(t,e,i){const{fill:s,stroke:n,__drawAfterFill:r,__fillAfterStroke:o}=t.__;t.__drawRenderPath(e),o&&zh.stroke(n,t,e),s&&zh.fill(s,t,e),r&&t.__drawAfterFill(e,i),n&&!o&&zh.stroke(n,t,e)}const El={__drawFast(t,e){let{x:i,y:s,width:n,height:r}=this.__layout.boxBounds;const{fill:o,stroke:a,__drawAfterFill:h}=this.__;if(o&&(t.fillStyle=o,t.fillRect(i,s,n,r)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:o,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(o){case"center":t.strokeRect(0,0,n,r);break;case"inside":n-=h,r-=h,n<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,r),t.restore()):t.strokeRect(i+l,s+l,n,r);break;case"outside":t.strokeRect(i-l,s-l,n+h,r+h)}}}};var bl,kl;t.UI=bl=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){O.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 An.set(this.path=t||[]),t||this.__drawPathByBox(An),An}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 te.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return te.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(An.set(i=[]),this.__drawPathByBox(An)),t?Gi.toCanvasData(i,!0):i}getPathString(t,e,i){return Gi.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Xh.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Dn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Fh.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)}__drawPathByData(t,e){e?Ks.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:n}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,n,d(r)?[r]:r)}else t.rect(e,i,s,n)}drawImagePlaceholder(t,e){zh.fill(this.__.placeholderColor,this,t)}animate(t,e,i,s){return this.set(t),te.need("animate")}killAnimate(t,e){}export(t,e){return te.need("export")}syncExport(t,e){return te.need("export")}clone(t){const e=f.clone(this.toJSON());return t&&Object.assign(e,t),bl.one(e)}static one(t,e,i,s,n){return se.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Ur()(this)}static registerData(t){Or(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},le([Or(Qh)],t.UI.prototype,"__",void 0),le([Dh()],t.UI.prototype,"zoomLayer",void 0),le([or("")],t.UI.prototype,"id",void 0),le([or("")],t.UI.prototype,"name",void 0),le([or("")],t.UI.prototype,"className",void 0),le([wr("pass-through")],t.UI.prototype,"blendMode",void 0),le([br(1)],t.UI.prototype,"opacity",void 0),le([kr(!0)],t.UI.prototype,"visible",void 0),le([wr(!1)],t.UI.prototype,"locked",void 0),le([Er(!1)],t.UI.prototype,"dim",void 0),le([Er(!1)],t.UI.prototype,"dimskip",void 0),le([Tr(0)],t.UI.prototype,"zIndex",void 0),le([Pr(!1)],t.UI.prototype,"mask",void 0),le([Lr(!1)],t.UI.prototype,"eraser",void 0),le([ar(0,!0)],t.UI.prototype,"x",void 0),le([ar(0,!0)],t.UI.prototype,"y",void 0),le([ur(100,!0)],t.UI.prototype,"width",void 0),le([ur(100,!0)],t.UI.prototype,"height",void 0),le([dr(1,!0)],t.UI.prototype,"scaleX",void 0),le([dr(1,!0)],t.UI.prototype,"scaleY",void 0),le([cr(0,!0)],t.UI.prototype,"rotation",void 0),le([cr(0,!0)],t.UI.prototype,"skewX",void 0),le([cr(0,!0)],t.UI.prototype,"skewY",void 0),le([ar(0,!0)],t.UI.prototype,"offsetX",void 0),le([ar(0,!0)],t.UI.prototype,"offsetY",void 0),le([hr(0,!0)],t.UI.prototype,"scrollX",void 0),le([hr(0,!0)],t.UI.prototype,"scrollY",void 0),le([lr()],t.UI.prototype,"origin",void 0),le([lr()],t.UI.prototype,"around",void 0),le([or(!1)],t.UI.prototype,"lazy",void 0),le([pr(1)],t.UI.prototype,"pixelRatio",void 0),le([xr(0)],t.UI.prototype,"renderSpread",void 0),le([_r()],t.UI.prototype,"path",void 0),le([fr()],t.UI.prototype,"windingRule",void 0),le([fr(!0)],t.UI.prototype,"closed",void 0),le([ur(0)],t.UI.prototype,"padding",void 0),le([ur(!1)],t.UI.prototype,"lockRatio",void 0),le([ur()],t.UI.prototype,"widthRange",void 0),le([ur()],t.UI.prototype,"heightRange",void 0),le([or(!1)],t.UI.prototype,"draggable",void 0),le([or()],t.UI.prototype,"dragBounds",void 0),le([or("auto")],t.UI.prototype,"dragBoundsType",void 0),le([or(!1)],t.UI.prototype,"editable",void 0),le([Rr(!0)],t.UI.prototype,"hittable",void 0),le([Rr("path")],t.UI.prototype,"hitFill",void 0),le([vr("path")],t.UI.prototype,"hitStroke",void 0),le([Rr(!1)],t.UI.prototype,"hitBox",void 0),le([Rr(!0)],t.UI.prototype,"hitChildren",void 0),le([Rr(!0)],t.UI.prototype,"hitSelf",void 0),le([Rr()],t.UI.prototype,"hitRadius",void 0),le([Cr("")],t.UI.prototype,"cursor",void 0),le([wr()],t.UI.prototype,"fill",void 0),le([vr(void 0,!0)],t.UI.prototype,"stroke",void 0),le([vr("inside")],t.UI.prototype,"strokeAlign",void 0),le([vr(1,!0)],t.UI.prototype,"strokeWidth",void 0),le([vr(!1)],t.UI.prototype,"strokeWidthFixed",void 0),le([vr("none")],t.UI.prototype,"strokeCap",void 0),le([vr("miter")],t.UI.prototype,"strokeJoin",void 0),le([vr()],t.UI.prototype,"dashPattern",void 0),le([vr(0)],t.UI.prototype,"dashOffset",void 0),le([vr(10)],t.UI.prototype,"miterLimit",void 0),le([fr(0)],t.UI.prototype,"cornerRadius",void 0),le([fr()],t.UI.prototype,"cornerSmoothing",void 0),le([Oh()],t.UI.prototype,"shadow",void 0),le([Oh()],t.UI.prototype,"innerShadow",void 0),le([Oh()],t.UI.prototype,"blur",void 0),le([Oh()],t.UI.prototype,"backgroundBlur",void 0),le([Oh()],t.UI.prototype,"grayscale",void 0),le([Oh()],t.UI.prototype,"filter",void 0),le([wr()],t.UI.prototype,"placeholderColor",void 0),le([or(100)],t.UI.prototype,"placeholderDelay",void 0),le([or({})],t.UI.prototype,"data",void 0),le([Wr(t.Leaf.prototype.reset)],t.UI.prototype,"reset",null),t.UI=bl=le([Hr(yl),Hr(xl),Fr()],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(){}},le([Or(el)],t.Group.prototype,"__",void 0),le([ur(0)],t.Group.prototype,"width",void 0),le([ur(0)],t.Group.prototype,"height",void 0),t.Group=le([Hr(t.Branch),Ur()],t.Group);const Bl=Gt.get("Leafer");t.Leafer=kl=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&&Vn.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),kl.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,f.assign(s,t));const n=this.canvas=ee.canvas(s);this.__controllers.push(this.renderer=ee.renderer(this,n,s),this.watcher=ee.watcher(this,s),this.layouter=ee.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),this.view=n.view,e||(this.selector=ee.selector(this),this.interaction=ee.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ee.hitCanvasManager()),this.canvasManager=new he,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))),mo.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(Xo.RESTART):this.emitLeafer(Xo.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(Xo.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=f.copyAttrs({},t,be);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new Nt(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=f.copyAttrs({},this.canvas,be);e.resize(t),this.updateLazyBounds(),this.__onResize(new Ho(t,i))}__onResize(t){this.emitEvent(t),f.copyAttrs(this.__,t,be),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 Xt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(be.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(Xo.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&be.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=f.copyAttrs({},s,be);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(Xo.BEFORE_READY),this.emitLeafer(Xo.READY),this.emitLeafer(Xo.AFTER_READY),mo.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Xo.VIEW_READY),mo.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:r}=this;const o="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,o.x+o.width)),i||(n=Math.max(1,o.y+o.height)),this.__doResize({width:s,height:n,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){mo.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(Xo.VIEW_COMPLETED),mo.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 te.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 Xo(t,this))}__listenEvents(){const t=Jt.start("FirstCreate "+this.innerName);this.once([[Xo.START,()=>Jt.end(t)],[No.START,this.updateLazyBounds,this],[Yo.START,this.__onCreated,this],[Yo.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Uo.DATA,this.__onWatchData,this],[No.END,this.__onLayoutEnd,this],[Yo.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){kl.list.remove(this);try{this.stop(),this.emitLeafer(Xo.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.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{Gn.clearRecycled()},100)}catch(t){Bl.error(t)}}};t?e():setTimeout(e)}},t.Leafer.list=new lh,le([Or(sl)],t.Leafer.prototype,"__",void 0),le([ur()],t.Leafer.prototype,"pixelRatio",void 0),le([or("normal")],t.Leafer.prototype,"mode",void 0),t.Leafer=kl=le([Ur()],t.Leafer),t.Rect=class extends t.UI{get __tag(){return"Rect"}},le([Or(ol)],t.Rect.prototype,"__",void 0),t.Rect=le([Hr(El),Fr(),Ur()],t.Rect);const{add:Sl,includes:Tl,scroll:Pl}=Ft,Ll=t.Rect.prototype,Rl=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:r}=s,{overflow:o}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=o.includes("scroll"))&&(Sl(a,r),Pl(a,i)),this.__updateRectRenderBounds(),t=!Tl(r,a),t&&"show"===o&&Sl(n,a)}else this.__updateRectRenderBounds();f.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))}},le([Or(il)],t.Box.prototype,"__",void 0),le([ur(100)],t.Box.prototype,"width",void 0),le([ur(100)],t.Box.prototype,"height",void 0),le([or(!1)],t.Box.prototype,"resizeChildren",void 0),le([xr("show")],t.Box.prototype,"overflow",void 0),le([Wr(Ll.__updateStrokeSpread)],t.Box.prototype,"__updateStrokeSpread",null),le([Wr(Ll.__updateRenderSpread)],t.Box.prototype,"__updateRectRenderSpread",null),le([Wr(Ll.__updateBoxBounds)],t.Box.prototype,"__updateRectBoxBounds",null),le([Wr(Ll.__updateStrokeBounds)],t.Box.prototype,"__updateStrokeBounds",null),le([Wr(Ll.__updateRenderBounds)],t.Box.prototype,"__updateRectRenderBounds",null),le([Wr(Ll.__updateChange)],t.Box.prototype,"__updateRectChange",null),le([Wr(Ll.__render)],t.Box.prototype,"__renderRect",null),le([Wr(Rl.__render)],t.Box.prototype,"__renderGroup",null),t.Box=le([Fr(),Ur()],t.Box),t.Frame=class extends t.Box{get __tag(){return"Frame"}get isFrame(){return!0}},le([Or(nl)],t.Frame.prototype,"__",void 0),le([wr("#FFFFFF")],t.Frame.prototype,"fill",void 0),le([xr("hide")],t.Frame.prototype,"overflow",void 0),t.Frame=le([Ur()],t.Frame);const{moveTo:Cl,closePath:Ol,ellipse:Ml}=fs;t.Ellipse=class extends t.UI{get __tag(){return"Ellipse"}__updatePath(){const{width:t,height:i,innerRadius:s,startAngle:n,endAngle:r}=this.__,o=t/2,a=i/2,h=this.__.path=[];s?(n||r?(s<1&&Ml(h,o,a,o*s,a*s,0,n,r,!1),Ml(h,o,a,o,a,0,r,n,!0),s<1&&Ol(h)):(s<1&&(Ml(h,o,a,o*s,a*s),Cl(h,t,a)),Ml(h,o,a,o,a,0,360,0,!0)),e.ellipseToCurve&&(this.__.path=this.getPath(!0))):n||r?(Cl(h,o,a),Ml(h,o,a,o,a,0,n,r,!1),Ol(h)):Ml(h,o,a,o,a)}},le([Or(al)],t.Ellipse.prototype,"__",void 0),le([fr(0)],t.Ellipse.prototype,"innerRadius",void 0),le([fr(0)],t.Ellipse.prototype,"startAngle",void 0),le([fr(0)],t.Ellipse.prototype,"endAngle",void 0),t.Ellipse=le([Ur()],t.Ellipse);const{sin:Dl,cos:Il,PI:Al}=Math,{moveTo:Wl,lineTo:Fl,closePath:zl,drawPoints:Hl}=fs;t.Polygon=class extends t.UI{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)Hl(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,r=i/2,o=s/2;Wl(e,r,0);for(let t=1;t<n;t++)Fl(e,r+r*Dl(2*t*Al/n),o-o*Il(2*t*Al/n));zl(e)}}},le([Or(hl)],t.Polygon.prototype,"__",void 0),le([fr(3)],t.Polygon.prototype,"sides",void 0),le([fr()],t.Polygon.prototype,"points",void 0),le([fr(0)],t.Polygon.prototype,"curve",void 0),t.Polygon=le([Fr(),Ur()],t.Polygon);const{sin:Ul,cos:Nl,PI:Yl}=Math,{moveTo:Xl,lineTo:Vl,closePath:jl}=fs;t.Star=class extends t.UI{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,r=e/2,o=this.__.path=[];Xl(o,n,0);for(let t=1;t<2*i;t++)Vl(o,n+(t%2==0?n:n*s)*Ul(t*Yl/i),r-(t%2==0?r:r*s)*Nl(t*Yl/i));jl(o)}},le([Or(ll)],t.Star.prototype,"__",void 0),le([fr(5)],t.Star.prototype,"corners",void 0),le([fr(.382)],t.Star.prototype,"innerRadius",void 0),t.Star=le([Ur()],t.Star);const{moveTo:Gl,lineTo:Kl,drawPoints:Zl}=fs,{rotate:ql,getAngle:Jl,getDistance:$l,defaultPoint:Ql}=nt;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&&ql(i,e),i}set toPoint(t){this.width=$l(Ql,t),this.rotation=Jl(Ql,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?Zl(e,t.points,t.curve,t.closed):(Gl(e,0,0),Kl(e,this.width,0))}},le([Or(rl)],t.Line.prototype,"__",void 0),le([mr("center")],t.Line.prototype,"strokeAlign",void 0),le([ur(0)],t.Line.prototype,"height",void 0),le([fr()],t.Line.prototype,"points",void 0),le([fr(0)],t.Line.prototype,"curve",void 0),le([fr(!1)],t.Line.prototype,"closed",void 0),t.Line=le([Ur()],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 u(t)&&t[0].image}},le([Or(gl)],t.Image.prototype,"__",void 0),le([ur("")],t.Image.prototype,"url",void 0),t.Image=le([Ur()],t.Image);const td=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=ee.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new Qn({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Mo(Mo.LOADED,{image:t}))})}draw(t,e,i,s){const n=new ct(t.worldTransform).invert(),r=new ct;e&&r.translate(e.x,e.y),i&&(d(i)?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),n.multiplyParent(r),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()}},le([Or(_l)],t.Canvas.prototype,"__",void 0),le([Mh(100)],t.Canvas.prototype,"width",void 0),le([Mh(100)],t.Canvas.prototype,"height",void 0),le([Mh(1)],t.Canvas.prototype,"pixelRatio",void 0),le([Mh(!0)],t.Canvas.prototype,"smooth",void 0),le([or(!1)],t.Canvas.prototype,"safeResize",void 0),le([Mh()],t.Canvas.prototype,"contextSettings",void 0),t.Canvas=le([Ur()],t.Canvas);const{copyAndSpread:ed,includes:id,spread:sd,setList:nd}=Ft;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:r,italic:o,textCase:a,textOverflow:h,padding:l}=t;t.__lineHeight=Wh.number(e,n),t.__letterSpacing=Wh.number(i,n),t.__padding=l?O.fourNumber(l):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${o?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==r?r+" ":""}${n||12}px ${s||"caption"}`,t.__clipText="show"!==h&&!t.__autoSize,t.__textDrawData=Ih.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:r,__autoHeight:o}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&sd(a,i/2),r||o){if(h.x=r?a.x:0,h.y=o?a.y:0,h.width=r?a.width:t.width,h.height=o?a.height:t.height,n){const[e,i,s,n]=t.__padding;r&&(h.x-=n,h.width+=i+n),o&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),f.stintSet(this,"isOverflow",!id(h,a)),this.isOverflow?(nd(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;ed(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()}},le([Or(pl)],t.Text.prototype,"__",void 0),le([ur(0)],t.Text.prototype,"width",void 0),le([ur(0)],t.Text.prototype,"height",void 0),le([wr()],t.Text.prototype,"boxStyle",void 0),le([or(!1)],t.Text.prototype,"resizeFontSize",void 0),le([wr("#000000")],t.Text.prototype,"fill",void 0),le([mr("outside")],t.Text.prototype,"strokeAlign",void 0),le([Rr("all")],t.Text.prototype,"hitFill",void 0),le([ur("")],t.Text.prototype,"text",void 0),le([ur("")],t.Text.prototype,"placeholder",void 0),le([ur("caption")],t.Text.prototype,"fontFamily",void 0),le([ur(12)],t.Text.prototype,"fontSize",void 0),le([ur("normal")],t.Text.prototype,"fontWeight",void 0),le([ur(!1)],t.Text.prototype,"italic",void 0),le([ur("none")],t.Text.prototype,"textCase",void 0),le([ur("none")],t.Text.prototype,"textDecoration",void 0),le([ur(0)],t.Text.prototype,"letterSpacing",void 0),le([ur({type:"percent",value:1.5})],t.Text.prototype,"lineHeight",void 0),le([ur(0)],t.Text.prototype,"paraIndent",void 0),le([ur(0)],t.Text.prototype,"paraSpacing",void 0),le([ur("x")],t.Text.prototype,"writingMode",void 0),le([ur("left")],t.Text.prototype,"textAlign",void 0),le([ur("top")],t.Text.prototype,"verticalAlign",void 0),le([ur(!0)],t.Text.prototype,"autoSizeAlign",void 0),le([ur("normal")],t.Text.prototype,"textWrap",void 0),le([ur("show")],t.Text.prototype,"textOverflow",void 0),le([wr(!1)],t.Text.prototype,"textEditing",void 0),t.Text=le([Ur()],t.Text),t.Path=class extends t.UI{get __tag(){return"Path"}},le([Or(dl)],t.Path.prototype,"__",void 0),le([mr("center")],t.Path.prototype,"strokeAlign",void 0),t.Path=le([Ur()],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,r){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,r,o,a){return this}arc(t,e,i,s,n,r){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,r,o,a){return this}drawArc(t,e,i,s,n,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},le([Or(cl)],t.Pen.prototype,"__",void 0),le([(t,e)=>{tr(t,e,{get(){return this.__path}})}],t.Pen.prototype,"path",void 0),t.Pen=le([Hr(Ms,["set","path","paint"]),Ur()],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&&ee.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),o(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&&f.assign(e,t),this.autoLayout&&f.copyAttrs(e,this,be),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[No.END,this.__onReady,this],[Yo.START,this.__onCreated,this],[Yo.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Yo.END,this.__onChildRenderEnd,this))}},t.App=le([Ur()],t.App);const rd={},od={isHoldSpaceKey:()=>od.isHold("Space"),isHold:t=>rd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){rd[t]||(rd[t]=!0)},setUpCode(t){rd[t]=!1}},ad={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 hd extends Po{get spaceKey(){return od.isHoldSpaceKey()}get left(){return ad.left(this)}get right(){return ad.right(this)}get middle(){return ad.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return od.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){oe.changeName(t,e)}}const{min:ld,max:dd,abs:cd}=Math,{float:ud,sign:pd}=O,{minX:gd,maxX:_d,minY:fd,maxY:md}=Ft,yd=new Nt,vd=new Nt,xd={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&wd.getValidMove(t.__localBoxBounds,wd.getDragBounds(t),s,e,!0),wd.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:r}=t;n&&wd.getValidScaleOf(t.__localBoxBounds,wd.getDragBounds(t),r,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 r=t.x+s.x,o=t.y+s.y,a=r+t.width,h=o+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),wd.isInnerMode(t,e,i,"width")?r>e.x?s.x+=e.x-r:a<l&&(s.x+=l-a):r<e.x?s.x+=e.x-r:a>l&&(s.x+=l-a),wd.isInnerMode(t,e,i,"height")?o>e.y?s.y+=e.y-o:h<d&&(s.y+=d-h):o<e.y?s.y+=e.y-o:h>d&&(s.y+=d-h),s.x=ud(s.x),s.y=ud(s.y),s},getValidScaleOf(t,e,i,s,n,r,o){o||(n=Object.assign({},n)),vd.set(e),yd.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,p,g,_,f=1,m=1;return wd.isInnerMode(t,e,i,"width")?(n.x<0&&yd.scaleOf(s,f=1/n.x,1),g=ud(yd.minX-vd.minX),_=ud(vd.maxX-yd.maxX),u=a&&g>0?1+g/(a*yd.width):1,p=h&&_>0?1+_/(h*yd.width):1,f*=dd(u,p)):(n.x<0&&((ud(gd(t)-gd(e))<=0||ud(_d(e)-_d(t))<=0)&&yd.scaleOf(s,f=1/n.x,1),yd.unsign()),g=ud(vd.minX-yd.minX),_=ud(yd.maxX-vd.maxX),u=a&&g>0?1-g/(a*yd.width):1,p=h&&_>0?1-_/(h*yd.width):1,f*=ld(u,p)),wd.isInnerMode(t,e,i,"height")?(n.y<0&&yd.scaleOf(s,1,m=1/n.y),g=ud(yd.minY-vd.minY),_=ud(vd.maxY-yd.maxY),u=d&&g>0?1+g/(d*yd.height):1,p=c&&_>0?1+_/(c*yd.height):1,m*=dd(u,p),r&&(u=dd(cd(f),cd(m)),f=pd(f)*u,m=pd(m)*u)):(n.y<0&&((ud(fd(t)-fd(e))<=0||ud(md(e)-md(t))<=0)&&yd.scaleOf(s,1,m=1/n.y),yd.unsign()),g=ud(vd.minY-yd.minY),_=ud(yd.maxY-vd.maxY),u=d&&g>0?1-g/(d*yd.height):1,p=c&&_>0?1-_/(c*yd.height):1,m*=ld(u,p)),n.x*=l(f)?f:1,n.y*=l(m)?m:1,n}},wd=xd;t.PointerEvent=class extends hd{},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=le([Nr()],t.PointerEvent);const Ed=t.PointerEvent,bd={};t.DragEvent=class extends t.PointerEvent{static setList(t){this.list=t instanceof lh?t:new lh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return nt.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),xd.axisMove(t,n),n}static limitMove(t,e){xd.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(bd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(bd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(bd,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 Ft.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Ft.unsign(i),i}assignMove(t){bd.x=t?this.totalX:this.moveX,bd.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=le([Nr()],t.DragEvent);const kd=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=le([Nr()],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.END="move.end",t.MoveEvent=le([Nr()],t.MoveEvent),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=le([Nr()],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=le([Nr()],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=le([Nr()],t.ZoomEvent),t.KeyEvent=class extends hd{},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=le([Nr()],t.KeyEvent);const Bd={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:Sd.getSwipeDirection(nt.getAngle(t,i))}),getBase(t){const e=1===t.button?4:t.button;return{altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:o(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 lh,{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=>to.draggable(e)||!e.isLeafer&&e.hasEvent(t.DragEvent.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Sd=Bd,Td=new lh,{getDragEventData:Pd,getDropEventData:Ld,getSwipeEventData:Rd}=Bd;class Cd{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Pd(t,t,t),this.canAnimate=this.canDragOut=!0}getList(e,i){const{proxy:s}=this.interaction.selector,n=s&&s.list.length,r=t.DragEvent.list||this.draggableList||Td;return this.dragging&&(n?e?Td:new lh(i?[...s.list,...s.dragHoverExclude]:s.list):r)}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&&ad.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],to.draggable(e)){this.draggableList=new lh(e);break}}drag(e){const{interaction:i,dragData:s,downData:n}=this,{path:r,throughPath:o}=n;this.dragData=Pd(n,s,e),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.moving?(this.dragData.moveType="drag",i.emit(t.MoveEvent.BEFORE_MOVE,this.dragData),i.emit(t.MoveEvent.MOVE,this.dragData)):this.dragging&&(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:r}=this.dragData,{dragLimitAnimate:o}=i.p,a=!o||!!e;n.forEach(i=>{if(i.draggable){const n=h(i.draggable),l=t.DragEvent.getValidMove(i,this.dragStartPoints[i.innerId],{x:s,y:r},a||n);o&&!n&&e?to.animateMove(i,l,d(o)?o:.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,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(e){const{interaction:i,downData:s,dragData:n}=this;e||(e=n);const{path:r,throughPath:o}=s,a=Pd(s,e,e);if(o&&(a.throughPath=o),a.path=r,this.moving&&(this.moving=!1,a.moveType="drag",i.emit(t.MoveEvent.END,a)),this.dragging){const r=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,r,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(nt.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Rd(e,i,s);this.interaction.emit(t.type,t)}}drop(e,i,s){const n=Ld(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}checkDragEndAnimate(t,e){return!1}animate(t,e){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const Od=Gt.get("emit");const Md=["move","zoom","rotate","key"];function Dd(t,e,i,s,n){if(Md.some(t=>e.startsWith(t))&&t.__.hitChildren&&!Ad(t,n)){let r;for(let o=0,a=t.children.length;o<a;o++)r=t.children[o],!i.path.has(r)&&r.__.hittable&&Id(r,e,i,s,n)}}function Id(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!Ad(t,n)&&(Vh.updateEventStyle&&!s&&Vh.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=oe.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function Ad(t,e){return e&&e.has(t)}const Wd={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:Fd,pathCanDrag:zd,pathHasOutside:Hd}=Bd;class Ud{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&&ad.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&ad.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&od.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=f.clone(Wd),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new lh(t),this.createTransformer(),this.dragger=new Cd(this),s&&(this.config=f.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(e,i){e||(e=this.hoverData),e&&(ad.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),ad.left(e)&&(this.tapWait(),this.longPressWait(e)),this.waitRightTap=ad.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&&ad.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=nt.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;ad.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,od.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,od.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 lh),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,r=[t.PointerEvent.DOUBLE_TAP,t.PointerEvent.DOUBLE_CLICK].some(t=>Fd(e.path,t));n<i.tapTime+50&&r?(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,i){const{hitRadius:s,through:n}=this.p,{bottomList:r,target:o}=this;e.backgrounder||t.origin||o&&o.updateLayout();const a=this.selector.getByPoint(t,s,Object.assign({bottomList:r,name:t.type},i||{through:n}));return a.throughPath&&(t.throughPath=a.throughPath),t.path=a.path,a.path}isRootPath(t){return t&&t.path.list[0].isLeafer}isTreePath(t){const e=this.target.app;return!(!e||!e.isApp)&&(e.editor&&!t.path.has(e.editor)&&t.path.has(e.tree)&&!t.target.syncEventer)}checkPath(t,e){(e||this.moveMode&&!Hd(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!zd(t.path))&&!Hd(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(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&&nt.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),(Fd(e.path,t.PointerEvent.LONG_TAP)||Fd(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 Nt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(d(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Ho.RESIZE,this.__onResize,this)],t.once(Xo.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 r=i.length-1;r>-1;r--){if(n=i.list[r],Id(n,t,e,!0,s))return;n.isApp&&Dd(n,t,e,!0,s)}for(let r=0,o=i.length;r<o;r++)if(n=i.list[r],n.isApp&&Dd(n,t,e,!1,s),Id(n,t,e,!1,s))return}catch(t){Od.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class Nd{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Nd.custom={};class Yd extends he{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new lh,this.pixelList=new lh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),ee.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),ee.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()}}e.getSelector=function(t){return t.leafer?t.leafer.selector:e.selector||(e.selector=ee.selector())};const{toInnerRadiusPointOf:Xd,copy:Vd,setRadius:jd}=nt,{hitRadiusPoint:Gd,hitPoint:Kd}=Ft,Zd={},qd={},Jd=t.Leaf.prototype;Jd.hit=function(t,i=0){this.updateLayout(),Vd(qd,t),jd(qd,i);const s=this.__world;return!!(i?Gd(s,qd):Kd(s,qd))&&(this.isBranch?e.getSelector(this).hitPoint(Object.assign({},qd),i,{target:this}):this.__hitWorld(qd))},Jd.__hitWorld=function(t){const e=this.__;if(!e.hitSelf)return!1;const i=this.__world,s=this.__layout,n=i.width<10&&i.height<10;if(e.hitRadius&&(Vd(Zd,t),jd(t=Zd,e.hitRadius)),Xd(t,i,Zd),e.hitBox||n){if(Ft.hitRadiusPoint(s.boxBounds,Zd))return!0;if(n)return!1}return!s.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),s.boundsChanged||(s.hitCanvasChanged=!1)),this.__hit(Zd)},Jd.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},Jd.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},Jd.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},Jd.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const $d=new ct,Qd=t.UI.prototype;Qd.__updateHitCanvas=function(){this.__box&&this.__box.__updateHitCanvas();const{hitCanvasManager:t}=this.leafer||this.parent&&this.parent.leafer||{};if(!t)return;const i=this.__,s=(i.__isAlphaPixelFill||i.__isCanvas)&&"pixel"===i.hitFill,n=i.__isAlphaPixelStroke&&"pixel"===i.hitStroke,r=s||n;this.__hitCanvas||(this.__hitCanvas=r?t.getPixelType(this,{contextSettings:{willReadFrequently:!0}}):t.getPathType(this));const o=this.__hitCanvas;if(r){const{renderBounds:t}=this.__layout,r=e.image.hitCanvasSize,a=o.hitScale=Yt.set(0,0,r,r).getFitMatrix(t).a,{x:h,y:l,width:d,height:c}=Yt.set(t).scale(a);o.resize({width:d,height:c,pixelRatio:1}),o.clear(),Gn.patternLocked=!0,this.__renderShape(o,{matrix:$d.setWith(this.__world).scaleWith(1/a).invertWith().translate(-h,-l),ignoreFill:!s,ignoreStroke:!n}),Gn.patternLocked=!1,o.resetTransform(),i.__isHitPixel=!0}else i.__isHitPixel&&(i.__isHitPixel=!1);this.__drawHitPath(o),o.setStrokeOptions(i)},Qd.__hit=function(t){if(this.__box&&this.__box.__hit(t))return!0;const e=this.__;if(e.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:i}=e,s=(e.fill||e.__isCanvas)&&("path"===i||"pixel"===i&&!(e.__isAlphaPixelFill||e.__isCanvas))||"all"===i;if(s&&this.__hitFill(t))return!0;const{hitStroke:n,__maxStrokeWidth:r}=e,o=e.stroke&&("path"===n||"pixel"===n&&!e.__isAlphaPixelStroke)||"all"===n;if(!s&&!o)return!1;const a=2*t.radiusX;let h=a;if(o)switch(e.strokeAlign){case"inside":if(h+=2*r,!s&&this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a;break;case"center":h+=r;break;case"outside":if(h+=2*r,!s){if(!this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a}}return!!h&&this.__hitStroke(t,h)};const tc=t.UI.prototype,ec=t.Rect.prototype,ic=t.Box.prototype;ec.__updateHitCanvas=ic.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?tc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},ec.__hitFill=ic.__hitFill=function(t){return this.__hitCanvas?tc.__hitFill.call(this,t):Ft.hitRadiusPoint(this.__layout.boxBounds,t)},t.Text.prototype.__drawHitPath=function(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__letterSpacing:n,__textDrawData:r}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):r.rows.forEach(n=>t.rect(n.x,n.y-s,n.width,e<i?i:e))},t.Group.prototype.pick=function(t,i){return i||(i=r),this.updateLayout(),e.getSelector(this).getByPoint(t,i.hitRadius||0,Object.assign(Object.assign({},i),{target:this}))};const sc=ke.prototype;function nc(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let r;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)r=s[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(n){const{decorationColor:t,decorationHeight:r}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,r)))}}function rc(t,e){t.__.__font?nc(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function oc(t,e,i){switch(e.__.strokeAlign){case"center":ac(t,1,e,i);break;case"inside":hc(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ac(t,2,e,i):hc(t,"outside",e,i)}}function ac(t,e,i,s){const n=i.__;p(t)?dc(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),lc(i,s))}function hc(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ac(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",nc(i,n),n.blendMode="normal",to.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function lc(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:r}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(r){const{decorationHeight:t}=s;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function dc(t,e,i,s,n){let r;const o=s.__,{__hasMultiStrokeStyle:a}=o;a||n.setStroke(void 0,o.__strokeWidth*e,o);for(let h=0,l=t.length;h<l;h++)if(r=t[h],(!r.image||!Hh.checkImage(s,n,r,!1))&&r.style){if(a){const{strokeStyle:t}=r;t?n.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(r.style,o.__strokeWidth*e,o)}else n.strokeStyle=r.style;r.blendMode?(n.saveBlendMode(r.blendMode),i?lc(s,n):n.stroke(),n.restoreBlendMode()):i?lc(s,n):n.stroke()}}function cc(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)oc(t,e,i);else switch(s.strokeAlign){case"center":uc(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),uc(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)uc(t,2,e,i);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),uc(t,2,e,r),r.clipUI(s),r.clearWorld(n),to.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i)}}function uc(t,e,i,s){const n=i.__;p(t)?dc(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&zh.strokeArrow(t,i,s)}sc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},sc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},sc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:r,radiusY:o}=t;e&&(s-=e.x,n-=e.y),Yt.set(s-r,n-o,2*r,2*o).scale(i).ceil();const{data:a}=this.context.getImageData(Yt.x,Yt.y,Yt.width||1,Yt.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:pc,copyAndSpread:gc,toOuterOf:_c,getOuterOf:fc,getByMove:mc,move:yc,getIntersectData:vc}=Ft,xc={};let wc;const{stintSet:Ec}=f,{hasTransparent:bc}=Ah;function kc(t,e,i){if(!p(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=Hh.image(i,t,e,n,!wc||!wc[e.url]);break;case"linear":s=Uh.linearGradient(e,n);break;case"radial":s=Uh.radialGradient(e,n);break;case"angular":s=Uh.conicGradient(e,n);break;case"solid":const{type:r,color:a,opacity:h}=e;s={type:r,style:Ah.string(a,h)};break;default:o(e.r)||(s={type:"solid",style:Ah.string(e)})}if(s){if(h(s.style)&&bc(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Bc={compute:function(t,e){const i=e.__,s=[];let n,r,o,a=i.__input[t];u(a)||(a=[a]),wc=Hh.recycleImage(t,i);for(let i,n=0,r=a.length;n<r;n++)(i=kc(t,a[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),r=!0),"fill"===t?(Ec(i,"__isAlphaPixelFill",n),Ec(i,"__isTransparentFill",r)):(Ec(i,"__isAlphaPixelStroke",n),Ec(i,"__isTransparentStroke",r),Ec(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,rc(e,i)},fills:function(t,e,i){let s;for(let n=0,r=t.length;n<r;n++){if(s=t[n],s.image){if(Hh.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),rc(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),rc(e,i),i.restoreBlendMode()):rc(e,i)}},fillPathOrText:rc,fillText:nc,stroke:cc,strokes:function(t,e,i){cc(t,e,i)},strokeText:oc,drawTextStroke:lc,shape:function(t,i,s){const n=i.getSameCanvas(),r=i.bounds,o=t.__nowWorld,a=t.__layout,h=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let l,d,c,u,p,g;_c(a.strokeSpread?(gc(xc,a.boxBounds,a.strokeSpread),xc):a.boxBounds,o,h);let{scaleX:_,scaleY:f}=t.getRenderScaleData(!0);if(r.includes(h))g=n,l=p=h,d=o;else{let n;if(e.fullImageShadow)n=h;else{const t=a.renderShapeSpread?pc(r,k.swapAndScale(a.renderShapeSpread,_,f)):r;n=vc(t,h)}u=r.getFitMatrix(n);let{a:m,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),_*=m,f*=y),p=fc(h,u),l=mc(p,-u.e,-u.f),d=fc(o,u),yc(d,-u.e,-u.f);const v=s.matrix;v?(c=new ct(u),c.multiply(v),m*=v.scaleX,y*=v.scaleY):c=u,c.withScale(m,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:l,renderBounds:d,worldCanvas:g,shapeBounds:p,scaleX:_,scaleY:f}}};let Sc={},Tc={a:1,b:0,c:0,d:1,e:0,f:0};const{get:Pc,set:Lc,rotateOfOuter:Rc,translate:Cc,scaleOfOuter:Oc,multiplyParent:Mc,scale:Dc,rotate:Ic,skew:Ac}=G;function Wc(t,e,i,s){const n=Pc();Cc(n,e.x,e.y),i&&Dc(n,i,s),t.transform=n}function Fc(t,e,i,s,n,r,o){const a=Pc();Cc(a,e.x+i,e.y+s),Dc(a,n,r),o&&Rc(a,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=a}function zc(t,e,i,s,n,r,o,a,h,l){const d=Pc();Uc(d,e,i,s,n,r,o,a),h&&(o||a?(Lc(Tc),Oc(Tc,e,h,l),Mc(d,Tc)):Oc(d,e,h,l)),t.transform=d}function Hc(t,e,i,s,n,r,o,a,h,l,d,c){const u=Pc();if(c)Uc(u,e,n,r,o,a,h,l);else{if(h)if("center"===d)Rc(u,{x:i/2,y:s/2},h);else switch(Ic(u,h),h){case 90:Cc(u,s,0);break;case 180:Cc(u,i,s);break;case 270:Cc(u,0,i)}Sc.x=e.x+n,Sc.y=e.y+r,Cc(u,Sc.x,Sc.y),o&&Oc(u,Sc,o,a)}t.transform=u}function Uc(t,e,i,s,n,r,o,a){o&&Ic(t,o),a&&Ac(t,a.x,a.y),n&&Dc(t,n,r),Cc(t,e.x+i,e.y+s)}const{get:Nc,translate:Yc}=G,Xc=new Nt,Vc={},jc={};function Gc(t,e,i,s){const{changeful:n,sync:r,scaleFixed:o}=i;n&&(t.changeful=n),r&&(t.sync=r),o&&(t.scaleFixed=o),t.data=Kc(i,s,e)}function Kc(t,e,i){t.padding&&(e=Xc.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:r,mode:o,align:a,offset:l,scale:d,size:c,rotation:u,skew:g,clipSize:_,repeat:f,gap:m,filters:y}=t,v=e.width===s&&e.height===n,x={mode:o},w="center"!==a&&(u||0)%180==90;let E,b;switch(Ft.set(jc,0,0,w?n:s,w?s:n),o&&"cover"!==o&&"fit"!==o?((d||c)&&(O.getScaleData(d,c,i,Vc),E=Vc.scaleX,b=Vc.scaleY),(a||m||f)&&(E&&Ft.scale(jc,E,b,!0),a&&wt.toPoint(a,jc,e,jc,!0,!0))):v&&!u||(E=b=Ft.getFitScale(e,jc,"fit"!==o),Ft.put(e,i,a,E,!1,jc),Ft.scale(jc,E,b,!0)),l&&nt.move(jc,l),o){case"stretch":v||(E=e.width/s,b=e.height/n,Wc(x,e,E,b));break;case"normal":case"clip":if(jc.x||jc.y||E||_||u||g){let t,i;_&&(t=e.width/_.width,i=e.height/_.height),zc(x,e,jc.x,jc.y,E,b,u,g,t,i),t&&(E=E?E*t:t,b=b?b*i:i)}break;case"repeat":(!v||E||u||g)&&Hc(x,e,s,n,jc.x,jc.y,E,b,u,g,a,t.freeTransform),f||(x.repeat="repeat");const i=p(f);(m||i)&&(x.gap=function(t,e,i,s,n){let r,o;p(t)?(r=t.x,o=t.y):r=o=t;return{x:Zc(r,i,n.width,e&&e.x),y:Zc(o,s,n.height,e&&e.y)}}(m,i&&f,jc.width,jc.height,e));break;default:E&&Fc(x,e,jc.x,jc.y,E,b,u)}return x.transform||(e.x||e.y)&&Yc(x.transform=Nc(),e.x,e.y),x.width=s,x.height=n,E&&(x.scaleX=E,x.scaleY=b),r&&(x.opacity=r),y&&(x.filters=y),f&&(x.repeat=h(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),x}function Zc(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 qc,Jc=new Nt;const{isSame:$c}=Ft;function Qc(t,e,i,s,n,r){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||Gc(n,s,i,r),!0}function tu(t,e){su(t,Mo.LOAD,e)}function eu(t,e){su(t,Mo.LOADED,e)}function iu(t,e,i){e.error=i,t.forceUpdate("surface"),su(t,Mo.ERROR,e)}function su(t,e,i){t.hasEvent(e)&&t.emitEvent(new Mo(e,i))}function nu(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ru,scale:ou,copy:au}=G,{floor:hu,ceil:lu,max:du,abs:cu}=Math;function uu(t,i,s){let{scaleX:n,scaleY:r}=t.getRenderScaleData(!0,i.scaleFixed);const o=n+"-"+r+"-"+s;if(i.patternId===o||t.destroyed)return!1;{const{image:a,data:h}=i;let l,d,{width:c,height:u,scaleX:p,scaleY:g,transform:_,repeat:f,gap:m}=h;n*=s,r*=s,p&&(p=cu(p),g=cu(g),d=ru(),au(d,_),ou(d,1/p,1/g),n*=p,r*=g),c*=n,u*=r;const y=c*u;if(!f&&y>e.image.maxCacheSize)return!1;let v=e.image.maxPatternSize;if(a.isSVG){const t=c/a.width;t>1&&(l=t/lu(t))}else{const t=a.width*a.height;v>t&&(v=t)}y>v&&(l=Math.sqrt(y/v)),l&&(n/=l,r/=l,c/=l,u/=l),p&&(n/=p,r/=g);const x=m&&m.x*n,w=m&&m.y*r;if(_||1!==n||1!==r){const t=c+(x||0),e=u+(w||0);n/=t/du(hu(t),1),r/=e/du(hu(e),1),d||(d=ru(),_&&au(d,_)),ou(d,1/n,1/r)}const E=a.getCanvas(c,u,h.opacity,h.filters,x,w,t.leafer&&t.leafer.config.smooth),b=a.getPattern(E,f||e.origin.noRepeat||"no-repeat",d,i);return i.style=b,i.patternId=o,!0}}const pu={image:function(t,e,i,s,n){let r,o;const a=Gn.get(i);return qc&&i===qc.paint&&$c(s,qc.boxBounds)?r=qc.leafPaint:(r={type:i.type,image:a},a.hasAlphaPixel&&(r.isTransparent=!0),qc=a.use>1?{leafPaint:r,paint:i,boxBounds:Jc.set(s)}:null),(n||a.loading)&&(o={image:a,attrName:e,attrValue:i}),a.ready?(Qc(t,e,i,a,r,s),n&&(tu(t,o),eu(t,o))):a.error?n&&iu(t,o,a.error):(n&&(nu(t,!0),tu(t,o)),r.loadId=a.load(()=>{nu(t,!1),t.destroyed||(Qc(t,e,i,a,r,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),eu(t,o)),r.loadId=void 0},e=>{nu(t,!1),iu(t,o,e),r.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),r},checkImage:function(t,i,s,n){const{scaleX:r,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:a}=i,{data:h}=s;if(!h||s.patternId===r+"-"+o+"-"+a&&!Xh.running)return!1;if(n)if(h.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&Ho.isResizing(t)||Xh.running)){let{width:t,height:i}=h;t*=r*a,i*=o*a,h.scaleX&&(t*=h.scaleX,i*=h.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,h),!0):(!s.style||s.sync||Xh.running?uu(t,s,a):s.patternTask||(s.patternTask=Gn.patternTasker.add(()=>de(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&uu(t,s,a),t.forceUpdate("surface")}),300)),!1)},createPattern:uu,recycleImage:function(t,e){const i=e["_"+t];if(u(i)){let s,n,r,o,a;for(let h=0,l=i.length;h<l;h++)s=i[h],n=s.image,a=n&&n.url,a&&(r||(r={}),r[a]=!0,Gn.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],u(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===a))));return r}return null},createData:Gc,getPatternData:Kc,stretchMode:Wc,fillOrFitMode:Fc,clipMode:zc,repeatMode:Hc},{toPoint:gu}=yt,{hasTransparent:_u}=Ah,fu={},mu={};function yu(t,e,i,s){if(i){let n,r,o,a;for(let t=0,l=i.length;t<l;t++)n=i[t],h(n)?(o=t/(l-1),r=Ah.string(n,s)):(o=n.offset,r=Ah.string(n.color,s)),e.addColorStop(o,r),!a&&_u(r)&&(a=!0);a&&(t.isTransparent=!0)}}const{getAngle:vu,getDistance:xu}=nt,{get:wu,rotateOfOuter:Eu,scaleOfOuter:bu}=G,{toPoint:ku}=yt,Bu={},Su={};function Tu(t,e,i,s,n){let r;const{width:o,height:a}=t;if(o!==a||s){const t=vu(e,i);r=wu(),n?(bu(r,e,o/a*(s||1),1),Eu(r,e,t+90)):(bu(r,e,1,o/a*(s||1)),Eu(r,e,t))}return r}const{getDistance:Pu}=nt,{toPoint:Lu}=yt,Ru={},Cu={};const Ou={linearGradient:function(t,i){let{from:s,to:n,type:r,opacity:o}=t;gu(s||"top",i,fu),gu(n||"bottom",i,mu);const a=e.canvas.createLinearGradient(fu.x,fu.y,mu.x,mu.y),h={type:r,style:a};return yu(h,a,t.stops,o),h},radialGradient:function(t,i){let{from:s,to:n,type:r,opacity:o,stretch:a}=t;ku(s||"center",i,Bu),ku(n||"bottom",i,Su);const h=e.canvas.createRadialGradient(Bu.x,Bu.y,0,Bu.x,Bu.y,xu(Bu,Su)),l={type:r,style:h};yu(l,h,t.stops,o);const d=Tu(i,Bu,Su,a,!0);return d&&(l.transform=d),l},conicGradient:function(t,i){let{from:s,to:n,type:r,opacity:o,stretch:a}=t;Lu(s||"center",i,Ru),Lu(n||"bottom",i,Cu);const h=e.conicGradientSupport?e.canvas.createConicGradient(0,Ru.x,Ru.y):e.canvas.createRadialGradient(Ru.x,Ru.y,0,Ru.x,Ru.y,Pu(Ru,Cu)),l={type:r,style:h};yu(l,h,t.stops,o);const d=Tu(i,Ru,Cu,a||1,e.conicGradientRotate90);return d&&(l.transform=d),l},getTransform:Tu},{copy:Mu,move:Du,toOffsetOutBounds:Iu}=Ft,{max:Au,abs:Wu}=Math,Fu={},zu=new ct,Hu={};function Uu(t,e){let i,s,n,r,o=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,r=1.5*(t.blur||0),n=Wu(t.spread||0),o=Au(o,n+r-s),a=Au(a,n+r+i),h=Au(h,n+r+s),l=Au(l,n+r-i)}),o===a&&a===h&&h===l?o:[o,a,h,l]}function Nu(t,i,s){const{shapeBounds:n}=s;let r,o;e.fullImageShadow?(Mu(Fu,t.bounds),Du(Fu,i.x-n.x,i.y-n.y),r=t.bounds,o=Fu):(r=n,o=i),t.copyWorld(s.canvas,r,o)}const{toOffsetOutBounds:Yu}=Ft,Xu={};const Vu=Uu;const ju={shadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{shadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Iu(h,Hu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.setWorldShadow(Hu.offsetX+(o.x||0)*c*f,Hu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f,Ah.string(o.color)),n=Nh.getShadowTransform(t,p,i,o,Hu,f),n&&p.setTransform(n),Nu(p,Hu,i),n&&p.resetTransform(),s=l,o.box&&(p.restore(),p.save(),a&&(p.copyWorld(p,l,r,"copy"),s=r),a?p.copyWorld(a,r,r,"destination-out"):p.copyWorld(i.canvas,d,h,"destination-out")),to.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{innerShadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Yu(h,Xu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.save(),p.setWorldShadow(Xu.offsetX+(o.x||0)*c*f,Xu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f),n=Nh.getShadowTransform(t,p,i,o,Xu,f,!0),n&&p.setTransform(n),Nu(p,Xu,i),p.restore(),a?(p.copyWorld(p,l,r,"copy"),p.copyWorld(a,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,d,h,"source-out"),s=l),p.fillWorld(s,Ah.string(o.color),"source-in"),to.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Uu,getShadowTransform:function(t,e,i,s,n,r,o){if(s.spread){const i=2*s.spread*r*(o?-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:Gu}=ho;let Ku;function Zu(t,e,i,s,n,r,o,a){switch(e){case"grayscale":Ku||(Ku=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,r){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),r&&s.recycle(o);Ju(t,e,i,1,n,r)}(t,i,s,n,o,a);break;case"opacity-path":Ju(t,i,s,r,o,a);break;case"path":a&&i.restore()}}function qu(t){return t.getSameCanvas(!1,!0)}function Ju(t,e,i,s,n,r){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),r?i.recycle(o):i.clearWorld(o)}t.Group.prototype.__renderMask=function(t,e){let i,s,n,r,o,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){o&&(Zu(this,o,t,n,s,r,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||Gu(i,e)||i.__render(t,e),r=i.__.opacity,Ku=!1,"path"===a||"clipping-path"===a?(r<1?(o="opacity-path",n||(n=qu(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===a?"grayscale":"alpha",s||(s=qu(t)),n||(n=qu(t)),i.__render(s,e));continue}const d=1===r&&i.__.__blendMode;d&&Zu(this,o,t,n,s,r,void 0,!1),Gu(i,e)||i.__render(n||t,e),d&&Zu(this,o,t,n,s,r,d,!1)}Zu(this,o,t,n,s,r,void 0,!0)};const $u=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qu=$u+"_#~&*+\\=|≮≯≈≠=…",tp=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 ep(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ip=ep("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),sp=ep("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),np=ep($u),rp=ep(Qu),op=ep("- —/~|┆·");var ap;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ap||(ap={}));const{Letter:hp,Single:lp,Before:dp,After:cp,Symbol:up,Break:pp}=ap;function gp(t){return ip[t]?hp:op[t]?pp:sp[t]?dp:np[t]?cp:rp[t]?up:tp.test(t)?lp:hp}const _p={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let r=n-1;r>-1&&(i=e[r].data[0]," "===i.char);r--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function fp(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:mp}=_p,{Letter:yp,Single:vp,Before:xp,After:wp,Symbol:Ep,Break:bp}=ap;let kp,Bp,Sp,Tp,Pp,Lp,Rp,Cp,Op,Mp,Dp,Ip,Ap,Wp,Fp,zp,Hp,Up=[];function Np(t,e){Op&&!Cp&&(Cp=Op),kp.data.push({char:t,width:e}),Sp+=e}function Yp(){Tp+=Sp,kp.width=Sp,Bp.words.push(kp),kp={data:[]},Sp=0}function Xp(){Wp&&(Fp.paraNumber++,Bp.paraStart=!0,Wp=!1),Op&&(Bp.startCharSize=Cp,Bp.endCharSize=Op,Cp=0),Bp.width=Tp,zp.width?mp(Bp):Hp&&Vp(),Up.push(Bp),Bp={words:[]},Tp=0}function Vp(){Tp>(Fp.maxWidth||0)&&(Fp.maxWidth=Tp)}const{top:jp,right:Gp,bottom:Kp,left:Zp}=t.Direction4;function qp(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 Jp={getDrawData:function(t,i){h(t)||(t=String(t));let s=0,n=0,r=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:a,__font:l,__padding:d}=i;d&&(r?(s=d[Zp],r-=d[Gp]+d[Zp]):i.autoSizeAlign||(s=d[Zp]),o?(n=d[jp],o-=d[jp]+d[Kp]):i.autoSizeAlign||(n=d[jp]));const c={bounds:{x:s,y:n,width:r,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Fp=t,Up=t.rows,zp=t.bounds,Hp=!zp.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:r,textCase:o}=s,{canvas:a}=e,{width:h,height:l}=zp;if(h||l||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Wp=!0,Dp=null,Cp=Rp=Op=Sp=Tp=0,kp={data:[]},Bp={words:[]},n&&(i=[...i]);for(let s=0,l=i.length;s<l;s++)Lp=i[s],"\n"===Lp?(Sp&&Yp(),Bp.paraEnd=!0,Xp(),Wp=!0):(Mp=gp(Lp),Mp===yp&&"none"!==o&&(Lp=fp(Lp,o,!Sp)),Rp=a.measureText(Lp).width,n&&(n<0&&(Op=Rp),Rp+=n),Ip=Mp===vp&&(Dp===vp||Dp===yp)||Dp===vp&&Mp!==wp,Ap=!(Mp!==xp&&Mp!==vp||Dp!==Ep&&Dp!==wp),Pp=Wp&&r?h-r:h,t&&h&&Tp+Sp+Rp>Pp&&(e?(Sp&&Yp(),Tp&&Xp()):(Ap||(Ap=Mp===yp&&Dp==wp),Ip||Ap||Mp===bp||Mp===xp||Mp===vp||Sp+Rp>Pp?(Sp&&Yp(),Tp&&Xp()):Tp&&Xp()))," "===Lp&&!0!==Wp&&Tp+Sp===0||(Mp===bp?(" "===Lp&&Sp&&Yp(),Np(Lp,Rp),Yp()):Ip||Ap?(Sp&&Yp(),Np(Lp,Rp)):Np(Lp,Rp)),Dp=Mp);Sp&&Yp(),Tp&&Xp(),Up.length>0&&(Up[Up.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Fp.paraNumber++,Tp=a.measureText(t).width,Up.push({x:r||0,text:t,width:Tp,paraStart:!0}),Hp&&Vp()})}(c,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":qp(e,"x",t[Zp]);break;case"right":qp(e,"x",-t[Gp])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":qp(e,"y",t[jp]);break;case"bottom":qp(e,"y",-t[Kp])}}(d,c,i,r,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:r,__baseLine:o,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:p,y:g,width:_,height:f}=s,m=r*n+(c?c*(t.paraNumber-1):0),y=o;if(h&&m>f)m=Math.max(f,r),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":g+=(f-m)/2;break;case"bottom":g+=f-m}y+=g;let v,x,w,E=_||u?_:t.maxWidth;for(let o=0,d=n;o<d;o++){if(v=i[o],v.x=p,v.width<_||v.width>_&&!h)switch(l){case"center":v.x+=(E-v.width)/2;break;case"right":v.x+=E-v.width}v.paraStart&&c&&o>0&&(y+=c),v.y=y,y+=r,t.overflow>o&&y>m&&(v.isOverflow=!0,t.overflow=o+1),x=v.x,w=v.width,a<0&&(v.width<0?(w=-v.width+e.fontSize+a,x-=w,w+=e.fontSize):w-=a),x<s.x&&(s.x=x),w>s.width&&(s.width=w),h&&_&&_<w&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:r,letterSpacing:o}=e;let a,h,l,d,c,u;s.forEach(t=>{t.words&&(l=r&&t.paraStart?r:0,u=t.words.length,h=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-l)/(u-1):0,d=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===d?(t.x+=l,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=l,a=t.x,t.data=[],t.words.forEach((e,i)=>{1===d?(c={char:"",x:a},a=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,a,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):a=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,a,t.data,t.isOverflow),!h||t.paraEnd&&"both"!==n||i===u-1||(a+=h,t.width+=h)})),t.words=null)})}(c,i,r),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:r,overflow:o}=t;let{textOverflow:a}=i;if(r.splice(o),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?e.canvas.measureText(a).width:0,d=s+n-l;("none"===i.textWrap?r:[r[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<d));s--){if(h<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,i,s,r),"none"!==a&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:r}=e;switch(t.decorationHeight=n/11,p(r)?(i=r.type,r.color&&(t.decorationColor=Ah.string(r.color)),r.offset&&(s=Math.min(.3*n,Math.max(r.offset,.15*-n)))):i=r,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]}}(c,i),c}};const $p={string:function(t,e){if(!t)return"#000";const i=d(e)&&e<1;if(h(t)){if(!i||!Ah.object)return t;t=Ah.object(t)}let s=o(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 Qp(t){return t?u(t)?t:[t]:[]}Object.assign(Ih,Jp),Object.assign(Ah,$p),Object.assign(zh,Bc),Object.assign(Hh,pu),Object.assign(Uh,Ou),Object.assign(Nh,ju),Object.assign(ee,{interaction:(t,e,i,s)=>new Ud(t,e,i,s),hitCanvas:(t,e)=>new ch(t,e),hitCanvasManager:()=>new Yd}),ph();class tg extends Po{get list(){return Qp(this.value)}get oldList(){return Qp(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function eg(t){return(e,i)=>{const s="_"+i;tr(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const r=this;if(r.config){const t="target"===i;if(t){const{beforeSelect:t}=r.config;if(t){const i=t({target:e});if(p(i))e=i;else if(!1===i)return}r.setDimOthers(!1),r.setBright(!1),u(e)&&e.length>1&&e[0].locked&&e.splice(0,1),r.single&&(delete r.element.syncEventer,delete r.element.__world.ignorePixelSnap)}const s=t?tg.BEFORE_SELECT:tg.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new tg(s,{editor:r,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}tg.BEFORE_SELECT="editor.before_select",tg.SELECT="editor.select",tg.AFTER_SELECT="editor.after_select",tg.BEFORE_HOVER="editor.before_hover",tg.HOVER="editor.hover";const{abs:ig}=Math,{copy:sg,scale:ng}=G,{setListWithFn:rg}=Ft,{worldBounds:og}=ho,ag={a:1,b:0,c:0,d:1,e:0,f:0},hg={x:0,y:0,width:0,height:0};class lg 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?(rg(hg,e,og),t&&this.set(t),this.set(hg),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const n=this.__,{stroke:r,strokeWidth:o,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=ig(c.scaleX),l=ig(c.scaleY);if(sg(ag,c),ag.half=o%2,i!==l){ng(ag,1/i,1/l),t.setWorld(ag,e.matrix),t.beginPath(),n.strokeWidth=o;const{x:r,y:a,width:h,height:d}=s.__layout.boxBounds;t.rect(r*i,a*l,h*i,d*l)}else t.setWorld(ag,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=o/ig(c.scaleX);r&&(h(r)?zh.stroke(r,this,t):zh.strokes(r,this,t)),a&&(h(a)?zh.fill(a,this,t):zh.fills(a,this,t))}}n.strokeWidth=o}}destroy(){this.target=null,super.destroy()}}le([eg(function(t){const e=t.target;t.list=e?u(e)?e:[e]:[]})],lg.prototype,"target",void 0);class dg 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 cg={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return ug([t],i,e),i}};function ug(t,e,i){let s,n;for(let r=0,o=t.length;r<o;r++)if(s=t[r],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&&ug(s.children,e,i)}}const{findOne:pg,findByBounds:gg}=cg;class _g 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 lg,this.targetStroker=new lg,this.bounds=new Nt,this.selectArea=new dg,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:r,hover:o,hoverStyle:a}=s;this.hoverStroker.setTarget(o?e:null,Object.assign({stroke:n,strokeWidth:r},a||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedStyle:i}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2)},i||{}))}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:r}=t.getInnerPoint(this);this.bounds.set(n,r),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:r},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 lh(gg(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)&&!pg(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new lh(this.editor.editBox.rect)};return pg(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):pg(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_([[tg.HOVER,this.onHover,this],[tg.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:fg,top:mg,topRight:yg,right:vg,bottomRight:xg,bottom:wg,bottomLeft:Eg,left:bg}=t.Direction9,{toPoint:kg}=yt,{within:Bg,sign:Sg}=O,{abs:Tg}=Math,Pg={getScaleData(t,e,i,s,n,r,o,a){let h,l,c={},u=1,p=1;const{boxBounds:g,widthRange:_,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:x}=e,w=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=Sg(w),k=Sg(E),B=a?w:b*g.width/v,S=a?E:k*g.height/x;if(d(s))u=p=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=a?w:b,s.y*=a?E:k;const t=(-s.y+x)/x,e=(s.x+v)/v,o=(s.y+x)/x,d=(-s.x+v)/v;switch(i){case mg:p=t,h="bottom";break;case vg:u=e,h="left";break;case wg:p=o,h="top";break;case bg:u=d,h="right";break;case fg:p=t,u=d,h="bottom-right";break;case yg:p=t,u=e,h="bottom-left";break;case xg:p=o,u=e,h="top-left";break;case Eg:p=o,u=d,h="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case mg:case wg:u=p;break;case bg:case vg:p=u;break;default:l=Math.sqrt(Tg(u*p)),u=Sg(u)*l,p=Sg(p)*l}}const T=1!==u,P=1!==p;if(T&&(u/=B),P&&(p/=S),!o){const{worldTransform:e}=t;u<0&&(u=1/g.width/e.scaleX),p<0&&(p=1/g.height/e.scaleY)}if(kg(r||h,g,c,!0),m){const e={x:u,y:p};xd.limitScaleOf(t,c,e,n),u=e.x,p=e.y}if(T&&_){const e=g.width*t.scaleX;u=Bg(e*u,_)/e}if(P&&f){const e=g.height*t.scaleY;p=Bg(e*p,f)/e}return T&&Tg(u*y.width)<1&&(u=Sg(u)/y.width),P&&Tg(p*y.height)<1&&(p=Sg(p)/y.height),n&&u!==p&&(l=Math.min(Tg(u),Tg(p)),u=Sg(u)*l,p=Sg(p)*l),{origin:c,scaleX:u,scaleY:p,direction:i,lockRatio:n,around:r}},getRotateData(t,e,i,s,n){let r,o={};switch(e){case fg:r="bottom-right";break;case yg:r="bottom-left";break;case xg:r="top-left";break;case Eg:r="top-right";break;default:r="center"}return kg(n||r,t.boxBounds,o,!0),{origin:o,rotation:nt.getRotation(s,t.getWorldPointByBox(o),i)}},getSkewData(t,e,i,s){let n,r,o={},a=0,h=0;switch(e){case mg:case fg:r={x:.5,y:0},n="bottom",a=1;break;case wg:case xg:r={x:.5,y:1},n="top",a=1;break;case bg:case Eg:r={x:0,y:.5},n="right",h=1;break;case vg:case yg:r={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;r.x=r.x*l,r.y=r.y*d,kg(s||n,t,o,!0);const c=nt.getRotation(r,o,{x:r.x+(a?i.x:0),y:r.y+(h?i.y:0)});return a?a=-c:h=c,{origin:o,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 bg:t=vg;break;case fg:t=yg;break;case Eg:t=xg;break;case vg:t=bg;break;case yg:t=fg;break;case xg:t=Eg}if(i)switch(t){case mg:t=wg;break;case fg:t=Eg;break;case yg:t=xg;break;case wg:t=mg;break;case Eg:t=fg;break;case xg:t=yg}return t}},Lg={};function Rg(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:r,flippedX:o,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Cg(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:p,moveable:g,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(g||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!_)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),x=s?n?p:r?c:u:v?p:y?c:u;h+=45*(Pg.getFlipDirection(i.direction,o,a)+1),h=2*Math.round(O.formatRotation(h,!0)/2);const{url:w,x:E,y:b}=x,k=w+h;Lg[k]?i.cursor=Lg[k]:Lg[k]=i.cursor={url:Og(w,h),x:E,y:b}}function Cg(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function Og(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Mg extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const Dg=["top","right","bottom","left"],Ig=void 0;class Ag 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 Mg({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Mg({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:r,resizeLines:o,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 Mg({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Mg({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),o.push(e),this.listenPointEvents(e,"resize",s)),i=new Mg({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(...r,a,h,l,...o,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:n,resizePoints:r,resizeLines:o}=this,{stroke:h,strokeWidth:l,resizeLine:d,ignorePixelSnap:c}=e,u=this.getPointsStyle(),p=this.getMiddlePointsStyle();let g;this.visible=!t.locked;for(let t=0;t<8;t++)g=r[t],g.set(this.getPointStyle(t%2?p[(t-1)/2%p.length]:u[t/2%u.length])),g.rotation=(t-(t%2?1:0))/2*90,t%2&&o[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},d||{}));n.set(this.getPointStyle(e.circle||e.rotatePoint||u[0])),s.set(Object.assign({stroke:h,strokeWidth:l,editConfig:Ig},e.rect||{}));const _=a(e.rectThrough)?i:e.rectThrough;s.hittable=!_,_&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&f.stintSet(t.__world,"ignorePixelSnap",c),Cg(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:r,skewX:o,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:r,skewX:o,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:r,buttons:o,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{editMask:c}=e,{middlePoint:u,resizeable:p,rotateable:g,hideOnSmall:_,editBox:f,mask:m,dimOthers:y,bright:v,spread:x,hideRotatePoints:w,hideResizeLines:E}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),x&&Ft.spread(t,x),this.view.worldOpacity){const{width:e,height:c}=t,m=d(_)?_:10,y=f&&!(_&&e<m&&c<m);let v,x,b,k={};for(let i=0;i<8;i++)yt.toPoint(yt.directionData[i],t,k),x=a[i],v=h[i],x.set(k),v.set(k),x.visible=y&&!(!p&&!g),v.visible=y&&g&&p&&!w,i%2&&(b=l[(i-1)/2],b.set(k),b.visible=x.visible&&!E,x.visible=v.visible=y&&!!u,(i+1)/2%2?(b.width=e+b.height,_&&2*x.width>e&&(x.visible=!1)):(b.width=c+b.height,_&&2*x.width>c&&(x.visible=!1)));r.visible=y&&g&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),o.visible=y&&o.children.length>0||0,o.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,r=Dg.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:r,flippedY:o}=this;let a=Dg.indexOf(e);(a%2&&r||(a+1)%2&&o)&&i&&(a=(a+2)%4);const h=i?Pg.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=r?-1:1,t.scaleY=o?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],r=e%2,o=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*o;r?(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:r}=this.mergedConfig,o={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:n,height:n,cornerRadius:r,offsetX:0,offsetY:0,editConfig:Ig};return t?Object.assign(o,t):o}getPointsStyle(){const{point:t}=this.mergedConfig;return u(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return u(t)?t:t?[t]:this.getPointsStyle()}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:n,rotateable:r,skewable:o}=this.mergeConfig;"move"===i?s&&(this.moving=!0):(i.includes("rotate")||this.isHoldRotateKey(t)||!n?(r&&(this.rotating=!0),"resize-rotate"===i?n&&(this.resizing=!0):"resize-line"===e.name&&(o&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&n&&(this.resizing=!0),"skew"===i&&o&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:r}=this;if(i)e.onMove(t);else if(s||n||r){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),r&&e.onSkew(t)}Rg(this,t)}onDragEnd(t){this.onTransformEnd(t),this.dragPoint=null}onTransformStart(t){this.moving&&(this.editor.opacity=this.mergedConfig.hideOnMove?0:1),this.resizing&&(Ho.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&&(Ho.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(e){this.canGesture&&"drag"!==e.moveType&&(e.stop(),h(this.mergedConfig.moveable)&&(this.gesturing=this.moving=!0,e.type===t.MoveEvent.START?this.onTransformStart(e):this.transformTool.onMove(e)))}onScale(e){this.canGesture&&(e.stop(),h(this.mergedConfig.resizeable)&&(this.gesturing=this.resizing=!0,e.type===t.ZoomEvent.START?this.onTransformStart(e):this.transformTool.onScale(e)))}onRotate(e){this.canGesture&&(e.stop(),h(this.mergedConfig.rotateable)&&(this.gesturing=this.rotating=!0,e.type===t.RotateEvent.START?this.onTransformStart(e):this.transformTool.onRotate(e)))}onGestureStart(t){this.canGesture&&"drag"!==t.moveType&&this.onTransformStart(t)}onGestureEnd(t){this.canGesture&&"drag"!==t.moveType&&this.onTransformEnd(t)}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Rg(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,Rg(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.BEFORE_MOVE,this.onMove,this,!0],[t.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0],[t.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0],[[t.MoveEvent.START,t.ZoomEvent.START,t.RotateEvent.START],this.onGestureStart,this],[[t.MoveEvent.END,t.ZoomEvent.END,t.RotateEvent.END],this.onGestureEnd,this]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const Wg={x:0,y:0,width:1e5,height:1e5};class Fg extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Wg),Object.assign(this.__world,Wg)}__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 zg='\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"/>',Hg={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${zg}\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${zg}\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${zg}\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},Ug=new Nt;function Ng(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{Ug.setListWithFn(i,t=>t.getBounds("box","page")),0===Ug.width&&(Ug.width=.1),0===Ug.height&&(Ug.height=.1),e.reset(Ug.get())}),s.add(e)}const Yg=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Xg=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Vg={group(e,i,s){e.sort(Xg);const{app:n,parent:r}=e[0];let o;o=s&&s.add?s:new t.Group(s),r.addAt(o,r.children.indexOf(e[0])),e.sort(Yg);const a=new ct(i.worldTransform);return a.divideParent(r.scrollWorldTransform),o.setTransform(a),o.editable=!0,o.hitChildren=!1,n.lockLayout(),e.forEach(t=>t.dropTo(o)),n.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(Yg),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(Xg),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},jg=Gt.get("EditToolCreator");function Gg(){return t=>{Zg.register(t)}}const Kg=Gg,Zg={list:{},register(t){const{tag:e}=t.prototype;qg[e]&&jg.repeat(e),qg[e]=t},get:(t,e)=>new qg[t](e)},{list:qg}=Zg;class Jg extends tg{constructor(t,e){super(t,e)}}Jg.BEFORE_OPEN="innerEditor.before_open",Jg.OPEN="innerEditor.open",Jg.BEFORE_CLOSE="innerEditor.before_close",Jg.CLOSE="innerEditor.close";class $g extends tg{constructor(t,e){super(t,e)}}$g.BEFORE_GROUP="editor.before_group",$g.GROUP="editor.group",$g.BEFORE_UNGROUP="editor.before_ungroup",$g.UNGROUP="editor.ungroup",$g.BEFORE_OPEN="editor.before_open_group",$g.OPEN="editor.open_group",$g.BEFORE_CLOSE="editor.before_close_group",$g.CLOSE="editor.close_group";const{updateMatrix:Qg}=to,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(Co.CHANGE,e=>{if(this.checkChange&&t_[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,r="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const o=this.__;o[i]=n,Qg(this.parent),Qg(this);const a=new ct(this.__world);switch(o[i]=s,this.__layout.rotationChange(),Qg(this),this.changedTransform=new ct(this.__world).divide(a),i){case"x":t.move(r,0);break;case"y":t.move(0,r);break;case"rotation":t.rotateOf(e_,r);break;case"scaleX":t.scaleOf(e_,r,1);break;case"scaleY":t.scaleOf(e_,1,r);break;case"skewX":t.skewOf(e_,r,0);break;case"skewY":t.skewOf(e_,0,r)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class s_ extends tg{constructor(t,e){super(t,e)}}s_.BEFORE_MOVE="editor.before_move",s_.MOVE="editor.move";class n_ extends tg{constructor(t,e){super(t,e)}}n_.BEFORE_SCALE="editor.before_scale",n_.SCALE="editor.scale";class r_ extends tg{constructor(t,e){super(t,e)}}r_.BEFORE_ROTATE="editor.before_rotate",r_.ROTATE="editor.rotate";class o_ extends tg{constructor(t,e){super(t,e)}}o_.BEFORE_SKEW="editor.before_skew",o_.SKEW="editor.skew";class a_{onMove(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox;let r,{dragLimitAnimate:o}=s;const a=e.type===t.MoveEvent.END||e.type===t.DragEvent.END,l=h(i.draggable),c=!o||a||l,u={x:e.totalX,y:e.totalY};e instanceof t.MoveEvent&&nt.move(u,i.getWorldPointByLocal(n.totalOffset,null,!0)),e.shiftKey&&(Math.abs(u.x)>Math.abs(u.y)?u.y=0:u.x=0),r=t.DragEvent.getValidMove(i,n.point,u,c),(r.x||r.y)&&(o&&!l&&a?to.animateMove(this,r,d(o)?o:.3):this.move(r))}onScale(e){const{target:i,mergeConfig:s,single:n,dragStartData:r}=this.editBox;let o,{around:a,lockRatio:h,flipable:l,editSize:d}=s;e instanceof t.ZoomEvent?(a=i.getBoxPoint(e),o=e.totalScale):o=e.getInnerTotal(i);const{direction:c}=e.current;(e.shiftKey||i.lockRatio)&&(h=!0);const u=Pg.getScaleData(i,r.bounds,c,o,h,Pg.getAround(a,e.altKey),l,!n||"scale"===d),p=i.x,g=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),nt.move(r.totalOffset,i.x-p,i.y-g)}onRotate(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox,{around:r,rotateAround:o,rotateGap:a,diagonalRotateKey:h}=s,{direction:l}=e.current;let d,c;if(e instanceof t.RotateEvent)c=e.rotation,d=o?yt.getPoint(o,i.boxBounds):i.getBoxPoint(e);else{const t=h?e.isHoldKeys(h):e.shiftKey,s=Pg.getRotateData(i,l,e,n,t?null:o||i.around||i.origin||r||"center");c=n.rotation+s.rotation-i.rotation,d=s.origin}if(c=O.float(O.getGapRotation(c,a,i.rotation),2),!c)return;const u=i.x,p=i.y;this.rotateOf(d,c),nt.move(n.totalOffset,i.x-u,i.y-p)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:r,skewY:o}=Pg.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Pg.getAround(s,t.altKey));(r||o)&&this.skewOf(n,r,o)}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:r}=this.editBox,{beforeMove:o}=s;if(o){const s=o({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:r,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:r,drag:o}=t;if(!1===n({target:e,drag:o,origin:i,scaleX:s,scaleY:r}))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 r=new n_(n_.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeScale:h}=r;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=!o&&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 u=new n_(n_.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"),r=i?new ct(to.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),o={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:r};this.emitEvent(new n_(n_.BEFORE_SCALE,o));const a=new n_(n_.SCALE,o);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:r}=this.editBox,{beforeRotate:o}=s;if(o){const s=o({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:r,worldOrigin:a,rotation:e,transform:h};this.emitEvent(new r_(r_.BEFORE_ROTATE,l));const c=new r_(r_.ROTATE,l);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeSkew:h}=r;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=!o&&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(to.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new ct(e.worldTransform);return t(),new ct(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 lh,this.openedGroupList=new lh,this.simulateTarget=new i_(this),this.editBox=new Ag(this),this.editToolList={},this.selector=new _g(this),this.editMask=new Fg(this),this.targetEventIds=[];let i=f.clone(Hg);t&&(i=f.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),te.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?u(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>f.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&&Ng(this),this.update()}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(Zg.list[e]){const t=this.editTool=this.editToolList[e]=this.editToolList[e]||Zg.get(e,this);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($g.BEFORE_GROUP),this.target=Vg.group(this.list,this.element,t),this.emitGroupEvent($g.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent($g.BEFORE_UNGROUP,t)),this.target=Vg.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent($g.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent($g.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent($g.OPEN,t)}closeGroup(t){this.emitGroupEvent($g.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent($g.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!to.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 $g(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}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}Zg.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[s]=this.editToolList[s]||Zg.get(s,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Jg.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Jg.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Jg.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Jg.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Jg(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&&(Vg.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Vg.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_(Yo.START,this.onRenderStart,this),i&&i.on_(Co.SCROLL,this.onChildScroll,this),t.on_(Yo.CHILD_START,this.onAppRenderStart,this),t.on_(Xo.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())}},le([(t,e)=>{tr(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:s,app:n}=this,r=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(r,t)}return s.config&&Object.assign(r,s.config),i&&(i.editConfig&&Object.assign(r,i.editConfig),"font-size"===r.editSize&&(r.lockRatio=!0),"resize-rotate"===i.pointType&&(r.around||(r.around="center"),a(r.lockRatio)&&(r.lockRatio=!0))),o(r.dragLimitAnimate)&&(r.dragLimitAnimate=n&&n.config.pointer.dragLimitAnimate),this.mergedConfig=r}})}],t.Editor.prototype,"mergeConfig",void 0),le([eg(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof lh?i:new lh(i),t.multiple&&Ng(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new tg(tg.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new tg(tg.AFTER_SELECT,s))})],t.Editor.prototype,"target",void 0),le([eg(function(t,e){t.emitEvent(new tg(tg.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],t.Editor.prototype,"hoverTarget",void 0),t.Editor=le([Hr(a_,["editBox","editTool","emitEvent"])],t.Editor);class h_{static registerInnerEditor(){Zg.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(){Zg.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.scaleOfWorld(n,e,i,o)}),o.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:r,list:o}=n;r.lockLayout(),o.forEach(t=>{const r="scale"!==n.getEditSize(t);i?t.transformWorld(i,r):t.rotateOfWorld(s,e)}),r.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.skewOfWorld(n,e,i,o)}),o.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=le([Gg()],t.EditTool);const{left:l_,right:d_}=t.Direction9,{move:c_,copy:u_,toNumberPoints:p_}=nt;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,r=t.target,o=i===l_;if(r.pathInputed){const{path:t}=r.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,r.path=t}else if(r.points){const{points:t}=r,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,r.points=t}else{const t={x:0,y:0},{toPoint:i}=r;r.rotation=0,this.dragPoint(t,i,o,n,this.getInnerMove(r,e,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(i,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(i,null,null,!0),r.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=p_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:r,y:o}=n;i?(c_(t,r,o),s&&c_(e,-r,-o)):(s&&c_(t,-r,-o),c_(e,r,o))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,r=this.editor.element;let o,a;if(r.pathInputed?o=this.getFromToByPath(r.__.path):r.points&&(o=this.getFromToByPoints(r.__.points)),o){const{from:i,to:a}=o;r.innerToWorld(i,i,!1,t),r.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=!o&&a}},t.LineEditTool=le([Gg()],t.LineEditTool);const{M:g_,L:__,C:f_,Q:m_,Z:y_,N:v_,D:x_,X:w_,G:E_,F:b_,O:k_,P:B_,U:S_}=Te,T_={scale(t,e,i){if(!t)return;let s,n=0,r=t.length;for(;n<r;)switch(s=t[n],s){case g_: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 x_:P_(t,e,i,n,2),n+=9;break;case w_:P_(t,e,i,n,2),n+=6;break;case E_:P_(t,e,i,n,2),n+=9;break;case b_:P_(t,e,i,n,2),n+=5;break;case k_:t[n]=E_,t.splice(n+4,0,t[n+3],0),P_(t,e,i,n,2),n+=9,r+=2;break;case B_:t[n]=b_,t.splice(n+4,0,t[n+3]),P_(t,e,i,n,2),n+=5,r+=1;break;case S_:P_(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let r=n?s+1:0,o=n?r+2*n:t.length;r<o;r+=2)t[r]*=e,t[r+1]*=i}},{scalePoints:P_}=T_,L_=G.get(),{topLeft:R_,top:C_,topRight:O_,right:M_,bottom:D_,left:I_}=t.Direction9;function A_(t,e,i){t.pathInputed?W_(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function W_(t,e,i){T_.scale(t.__.path,e,i),t.path=t.__.path}function F_(t,e,i){const{points:s}=t;p(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):T_.scalePoints(s,e,i),t.points=s}function z_(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)L_.a=e,L_.d=i,s[t].transform(L_,!0)}const H_=t.Leaf.prototype;function U_(e,i,s){N_(e.parentApp?e.parentApp:e,i),e.isApp||s||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,t=>{e.zoomLayer.move(e.getValidMove(t.moveX,t.moveY,!1))}),e.on_(t.MoveEvent.END,t=>{to.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 N_(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&f.assign(i,e),f.assign(t.config,i,t.userConfig)}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){A_(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,r=n&&n.dragPoint;if(this.__.resizeFontSize||s&&"font-size"===s.editSize||r&&"font-size"===n.mergedConfig.editSize)!function(t,e,i,s){let n=e;if(!o(s)){const r=t.__layout;let{width:o,height:a}=r.boxBounds;switch(o*=i-e,a*=e-i,s){case C_:case D_:n=i,r.affectScaleOrRotation?t.moveInner(-o/2,0):t.x-=o/2;break;case I_:case M_:r.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case R_:case O_:r.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=n;const r=t.__,{padding:a}=r;a&&(t.padding=u(a)?a.map(t=>t*n):a*n),r.__autoWidth||(t.width*=n),r.__autoHeight||(t.height*=n)}(this,t,e,r&&r.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:r}=this.__,{boxBounds:o}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=o.x),s&&"top"!==r&&1!==e&&(this.y+=o.y),A_(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?F_(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?W_(this,t,e):this.points?F_(this,t,e):A_(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||A_(this,t,e),i&&z_(this,t,e)},te.add("resize"),te.add("editor","resize"),ee.editor=function(e,i){const s=new t.Editor(e);return i&&i.sky.add(i.editor=s),s},t.Box.addAttr("textBox",!1,or),t.UI.addAttr("editConfig",void 0,or),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),or),t.UI.addAttr("editInner","PathEditor",or),t.Group.addAttr("editInner","",or),t.Text.addAttr("editInner","TextEditor",or),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 Y_=Gt.get("LeaferTypeCreator"),X_={list:{},register(t,e){V_[t]&&Y_.repeat(t),V_[t]=e},run(t,e){const i=V_[t];i&&i(e)}},{list:V_,register:j_}=X_;j_("viewport",U_),j_("custom",function(t){U_(t,null,!0)}),j_("design",function(t){U_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),j_("document",function(t){U_(t,{zoom:{min:1},move:{scroll:"limit"}})});const G_={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=nt.getCenter(e.from,i.from),n=nt.getCenter(e.to,i.to),r={x:n.x-s.x,y:n.y-s.y},o=nt.getDistance(e.from,i.from);return{move:r,scale:nt.getDistance(e.to,i.to)/o,rotation:nt.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}=K_,s=K_.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),K_.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)?K_.getType(i.totalData,e):"none"},add(t,e){e&&(nt.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=K_;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},K_=G_,{abs:Z_,max:q_}=Math,{sign:J_,within:$_}=O,Q_={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const r=Z_(s),o=Z_(n);return r>50&&(s=q_(50,r/3)*J_(s)),o>50&&(n=q_(50,o/3)*J_(n)),{x:-s*i*2,y:-n*i*2}},getScale(t,i){let s,n=1,{zoomMode:r,zoomSpeed:o}=i;const a=t.deltaY||t.deltaX;if(r?(s="mouse"===r||!t.deltaX&&(e.intWheelDeltaY?Math.abs(a)>17:Math.ceil(a)!==a),(t.shiftKey||t.metaKey||t.ctrlKey)&&(s=!0)):s=!t.shiftKey&&(t.metaKey||t.ctrlKey),s){o=$_(o,0,1);const e=t.deltaY?i.delta.y:i.delta.x,s=$_(1-Z_(a)/(4*e)*o,.5,2);n=a>0?s:1/s}return n}};let tf,ef,sf,nf;class rf{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),tf=0,ef=0,this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0,totalX:tf,totalY:ef}),i.emit(t.MoveEvent.START,this.moveData)),e.path=this.moveData.path,e.totalX=tf+=e.moveX,e.totalY=ef+=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),sf=1,this.zoomData=Object.assign(Object.assign({},e),{scale:1,totalScale:sf}),i.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,e.totalScale=sf*=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),nf=0,this.rotateData=Object.assign(Object.assign({},e),{rotation:0,totalRotation:nf}),i.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,e.totalRotation=nf+=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:tf,totalY:ef})),s&&e.emit(t.ZoomEvent.END,Object.assign(Object.assign({},s),{totalScale:sf})),n&&e.emit(t.RotateEvent.END,Object.assign(Object.assign({},n),{totalRotation:nf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const of=t.Leafer.prototype,af=new Nt,hf=new lt;function lf(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function df(t,e){return Object.assign(Object.assign({},e),{scale:t})}of.initType=function(t){X_.run(t,this)},of.getValidMove=function(t,e,i=!0){const{scroll:s,disabled:n}=this.app.config.move;if(hf.set(t,e),s){const t=!0===s?"":s;t.includes("x")?hf.y=0:t.includes("y")?hf.x=0:Math.abs(hf.x)>Math.abs(hf.y)?hf.y=0:hf.x=0,i&&t.includes("limit")&&(af.set(this.__world).addPoint(this.zoomLayer),xd.getValidMove(af,this.canvas.bounds,"inner",hf,!0),t.includes("x")?hf.y=0:t.includes("y")&&(hf.x=0))}return{x:n?0:hf.x,y:n?0:hf.y}},of.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,r=Math.abs(e*t);return i&&r<i?t=i/e:s&&r>s&&(t=s/e),n?1:t};const cf=Ud.prototype;cf.createTransformer=function(){this.transformer=new rf(this)},cf.move=function(t){this.transformer.move(t)},cf.zoom=function(t){this.transformer.zoom(t)},cf.rotate=function(t){this.transformer.rotate(t)},cf.transformEnd=function(){this.transformer.transformEnd()},cf.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 r=e.getScale?e.getScale(t,e):Q_.getScale(t,e);if(1!==r)this.zoom(df(r,t));else{const s=e.getMove?e.getMove(t,e):Q_.getMove(t,e);i.snap&&nt.round(s),this.move(lf(s,t))}},cf.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=G_.getData(e),{moving:r,zooming:o,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(G_.detect(n,p(s)?s:{})){case"move":r=!0;break;case"zoom":o=!0;break;case"rotate":a=!0;break;default:return}G_.reset()}r||(n.center=G_.state.center)}else r=o=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}))),o&&this.zoom(df(n.scale,t)),r&&this.move(lf(n.move,t))};const uf=Cd.prototype,{abs:pf}=Math;function gf(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}uf.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=pf(i),r=pf(s),o=e?1:.1,a=this.canAnimate&&this.moving&&(n>o||r>o)&&this.interaction.m.dragAnimate;if(a){const o="touch"===t.pointerType?3:1,h=70;n*(e=e?d(a)?a:.95:o)>h?e=h/n:r*e>h&&(e=h/r),t=Object.assign({},t),nt.move(t,i*e,s*e),this.drag(t),this.animate(()=>{this.dragEnd(t,1)})}return a},uf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},uf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},uf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:r}=e.m;if(!r||!s||!n)return;const o=e.shrinkCanvasBounds,{x:a,y:h}=o,l=Ft.maxX(o),d=Ft.maxY(o),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let p=0,g=0;this.autoMoveTimer=setInterval(()=>{p+=c,g+=u,nt.move(i,c,u),nt.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:p,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},uf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},te.add("viewport"),te.add("view"),t.Leafer.prototype.zoom=function(t,e,i,s){let n;this.killAnimate(),g(e)?(n=e.padding,i=e.scroll,s=e.transition):n=e;const{zoomLayer:r}=this,o=this.canvas.bounds.clone().shrink(a(n)?30:n),l=new Nt,c={x:o.x+o.width/2,y:o.y+o.height/2};let _;const{x:f,y:m,scaleX:y,scaleY:v}=r.__;if(h(t))switch(t){case"in":_=gf(y,"in");break;case"out":_=gf(y,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new Nt(this.boxBounds)).height=0;break;case"fit-height":(t=new Nt(this.boxBounds)).width=0}else d(t)&&(_=t/y);if(_)_=this.getValidScale(_),r.scaleOfWorld(c,_,_,!1,s);else if(p(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=u(t);if(n||t.tag){const e=n?t:[t];l.setListWithFn(e,ho.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:r,height:o}=t;return o||(o=r*(e.height/e.width),i=!0),r||(r=o*(e.width/e.height),i=!0),i?{x:s,y:n,width:r,height:o}:t}(t,o);l.set(r.getWorldBounds(e))}const{width:a,height:h}=l;let d=o.x-l.x,c=o.y-l.y;return i?(d+=Math.max((o.width-a)/2,0),c+=Math.max((o.height-h)/2,0)):(_=this.getValidScale(Math.min(o.width/a,o.height/h)),d+=(o.width-a*_)/2,c+=(o.height-h*_)/2,nt.scaleOf(e,l,_),l.scaleOf(l,_),e.scaleX*=_,e.scaleY*=_),"x"===i?c=0:"y"===i&&(d=0),nt.move(e,d,c),l.move(d,c),r.set(e,s),l}return r.worldBoxBounds};class _f 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&&f.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:r}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(r))return;this.scrollBounds=new Nt(r);const o=n.bounds.clone().shrink(i),a=o.clone().add(r),h=this.ratioX=o.width/a.width,l=this.ratioY=o.height/a.height,d=(o.x-a.x)/a.width,c=(o.y-a.y)/a.height,u=h<1,p=l<1,{scrollXBar:g,scrollYBar:_}=this,{x:f,y:m,width:y,height:v}=o.shrink([2,p?_.width+6:2,u?g.height+6:2,2]);g.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:p})}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_(Yo.BEFORE,()=>this.update(!0)),this.target.leafer.on_(Ho.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}te.add("scroll");class ff extends rl{}function mf(t){return sr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,yr(this)}}}))}t.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Fh.register(t,e)}},le([Or(ff)],t.Arrow.prototype,"__",void 0),le([mf("angle")],t.Arrow.prototype,"endArrow",void 0),t.Arrow=le([Ur()],t.Arrow);const{M:yf,L:vf,C:xf,Q:wf,O:Ef}=Te,{rotate:bf,copyFrom:kf,scale:Bf}=nt,Sf={},Tf={layout(t,e,i,s,n,r,o){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case yf:case vf:Pf(t,l+1,e,i,s,n,r,o),l+=3;break;case xf:for(h=1;h<6;h+=2)Pf(t,l+h,e,i,s,n,r,o);l+=7;break;case wf:for(h=1;h<4;h+=2)Pf(t,l+h,e,i,s,n,r,o);l+=5;break;case Ef:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),r&&(t[l+4]+=r,t[l+5]+=r),l+=7}},rotate(t,e,i){Tf.layout(t,0,0,1,1,e,i)}};function Pf(t,e,i,s,n,r,o,a){kf(Sf,t[e],t[e+1]),o&&bf(Sf,o,a),n&&Bf(Sf,n,r),t[e]=i+Sf.x,t[e+1]=s+Sf.y}const{layout:Lf,rotate:Rf}=Tf,{getAngle:Cf}=nt,Of={x:-.5},Mf={connect:Of,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},Df={connect:Of,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},If={connect:Of,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]},Af={connect:Of,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]},Wf={offset:Of,path:[...If.path],dashPath:[1,-2.5,0,2,-1,0]};Rf(Wf.path,180,{x:-1.5,y:0});const Ff={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:[...Ff.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},Hf={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]},Uf={path:[...Hf.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},Nf=f.clone(Hf),Yf=f.clone(Uf);Rf(Nf.path,45),Rf(Yf.path,45);const Xf={angle:Mf,"angle-side":Df,arrow:Af,triangle:If,"triangle-flip":Wf,circle:zf,"circle-line":Ff,square:Uf,"square-line":Hf,diamond:Yf,"diamond-line":Nf,mark:{offset:Of,path:[1,0,-2,2,0,2]}};function Vf(t,e,i,s,n,r,o){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;p(e)?e.type?(h=e.scale,a=Xf[e.type]):a=e:a=Xf[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 o&&_&&y.push(..._),"none"!==l&&(f-=.5),c&&("round"===d&&c.roundJoin?m+=c.roundJoin:"bevel"===d&&c.bevelJoin&&(m+=c.bevelJoin)),h&&Lf(y,0,0,h,h),m&&Lf(y,m,0),Lf(y,s.x,s.y,n,n,Cf(i,s)),r.x=(f+m)*n,y}const{M:jf,L:Gf,C:Kf,Q:Zf,Z:qf,N:Jf,D:$f,X:Qf,G:tm,F:em,O:im,P:sm,U:nm}=Te,{copy:rm,copyFrom:om,getDistancePoint:am}=nt,hm={},lm={},dm={},cm={},um={},pm={list:Xf,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:r,cornerRadius:o}=t.__,a=!o;let h,l=0,d=r.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=r[l],h){case jf:case Gf:(c<2||l+6>=d)&&(om(um,r[l+1],r[l+2]),!c&&u&&rm(lm,um)),l+=3;break;case Kf:(1===c||l+7>=d-3)&&gm(r,cm,um,l+3),l+=7;break;case Zf:(1===c||l+5>=d-3)&&gm(r,cm,um,l+1),l+=5;break;case qf:return;case Jf:l+=5;break;case $f:l+=9;break;case Qf:l+=6;break;case tm:l+=9;break;case em:l+=5;break;case im:l+=7;break;case sm:l+=4;break;case nm:(1===c||l+6>=d-3)&&(gm(r,cm,um,l+1),l+6!==d&&(um.x-=(um.x-cm.x)/10,um.y-=(um.y-cm.y)/10)),l+=6}if(c++,1===c&&h!==jf)return;if(2===c&&u&&rm(dm,h===Gf?um:cm),l===d){const o=t.__.__pathForRender=a?[...r]:r,d=t.__.__pathForArrow=[];if(u){const i=Vf(t,e,dm,lm,s,hm,!!n);n?d.push(...i):o.push(...i),hm.x&&(am(lm,dm,-hm.x,!0),o[1]=dm.x,o[2]=dm.y)}if(i&&"none"!==i){const e=Vf(t,i,cm,um,s,hm,!!n);if(n?d.push(...e):o.push(...e),hm.x){let t;switch(am(um,cm,-hm.x,!0),h){case Gf:t=l-3+1;break;case Kf:t=l-7+5;break;case Zf:t=l-5+3;break;case nm:t=l-6+3}t&&_m(o,cm,t)}}}else rm(cm,um)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function gm(t,e,i,s){om(e,t[s],t[s+1]),om(i,t[s+2],t[s+3])}function _m(t,e,i){t[i]=e.x,t[i+1]=e.y}te.add("arrow"),t.UI.addAttr("startArrow","none",mf),t.UI.addAttr("endArrow","none",mf),Object.assign(Fh,pm),Object.assign(zh,{strokeArrow(t,e,i){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});const{Yes:fm,NoAndSkip:mm,YesAndSkip:ym}=t.Answer,vm={},xm={},wm={};class Em{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"#":vm.id=t.substring(1),t=vm;break;case".":xm.className=t.substring(1),t=xm;break;default:wm.tag=t,t=wm}case"object":if(o(t.id)){if(t.tag){const{tag:s}=t,n=u(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?f.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&&to.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,r;for(let o=0,a=t.length;o<a;o++){if(n=t[o],r=e(n,s),r===fm||r===ym){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&r<mm&&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_(Lo.REMOVE,this.__onRemoveChild,this),this.target.on_(Co.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 bm=t.UI.prototype;function km(t){return t.leafer?t.leafer.selector:e.selector||(e.selector=ee.selector())}bm.find=function(t,e){return km(this).getBy(t,this,!1,e)},bm.findOne=function(t,e){return km(this).getBy(t,this,!0,e)},te.add("find"),ee.finder=function(t){return new Em(t)};const{setPoint:Bm,addPoint:Sm,toBounds:Tm}=pt;const Pm={syncExport(t,i,s){let n;Xh.running=!0;try{const r=zn.fileType(i),a=i.includes(".");s=zn.getExportOptions(s);const{toURL:h}=e,{download:l}=e.origin;if("json"===r)a&&l(h(JSON.stringify(t.toJSON(s.json)),"text"),i),n={data:!!a||t.toJSON(s.json)};else if("svg"===r)a&&l(h(t.toSVG(),"svg"),i),n={data:!!a||t.toSVG()};else{let r,a,h=1,l=1;const{worldTransform:d,isLeafer:c,leafer:u,isFrame:p}=t,{slice:g,clip:_,trim:f,screenshot:m,padding:y,onCanvas:v}=s,x=o(s.smooth)?!u||u.config.smooth:s.smooth,w=s.contextSettings||(u?u.config.contextSettings:void 0),E=c&&m&&o(s.fill)?t.fill:s.fill,b=zn.isOpaqueImage(i)||E,k=new ct;if(m)r=!0===m?c?u.canvas.bounds:t.worldRenderBounds:m;else{let e=s.relative||(c?"inner":"local");switch(h=d.scaleX,l=d.scaleY,e){case"inner":k.set(d);break;case"local":k.set(d).divide(t.localTransform),h/=t.scaleX,l/=t.scaleY;break;case"world":h=1,l=1;break;case"page":e=u||t;default:k.set(d).divide(t.getTransform(e));const i=e.worldTransform;h/=h/i.scaleX,l/=l/i.scaleY}r=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};O.getScaleData(s.scale,s.size,r,B);let S=s.pixelRatio||1,{x:T,y:P,width:L,height:R}=new Nt(r).scale(B.scaleX,B.scaleY);_&&(T+=_.x,P+=_.y,L=_.width,R=_.height);const C={exporting:!0,matrix:k.scale(1/B.scaleX,1/B.scaleY).invert().translate(-T,-P).withScale(1/h*B.scaleX,1/l*B.scaleY)};let M,D=ee.canvas({width:Math.floor(L),height:Math.floor(R),pixelRatio:S,smooth:x,contextSettings:w});g&&(M=t,M.__worldOpacity=0,t=u||t,C.bounds=D.bounds),D.save();const I=p&&!o(E),A=t.get("fill");if(I&&(t.fill=""),e.render(t,D,C),I&&(t.fill=A),D.restore(),M&&M.__updateWorldOpacity(),f){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,r,o,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,r=(a-n)/e,o?Sm(o,n,r):Bm(o={},n,r)),a++;const h=new Nt;return o&&(Tm(o,h),h.scale(1/t.pixelRatio).ceil()),h}(D);const t=D,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:S};D=ee.canvas(s),D.copyWorld(t,a,s),t.destroy()}if(y){const[t,e,i,s]=O.fourNumber(y),n=D,{width:r,height:o}=n;D=ee.canvas({width:r+s+e,height:o+t+i,pixelRatio:S}),D.copyWorld(n,n.bounds,{x:s,y:t,width:r,height:o}),n.destroy()}b&&D.fillWorld(D.bounds,E||"#FFFFFF","destination-over"),v&&v(D);n={data:"canvas"===i?D:D.export(i,s),width:D.pixelWidth,height:D.pixelHeight,renderBounds:r,trimBounds:a};const W=u&&u.app;W&&W.canvasManager&&W.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return Xh.running=!1,n},export(t,i,s){return Xh.running=!0,function(t){Lm||(Lm=new Yn);return new Promise(e=>{Lm.add(()=>de(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(n=>new Promise(r=>{const o=()=>de(this,void 0,void 0,function*(){if(!Vn.isComplete)return e.requestRender(o);const a=Xh.syncExport(t,i,s);a.data instanceof Promise&&(a.data=yield a.data),n(a),r()});t.updateLayout(),Rm(t);const{leafer:a}=t;a?a.waitViewCompleted(o):o()}))}};let Lm;function Rm(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Rm(t))}const Cm=ke.prototype,Om=Gt.get("@leafer-in/export");Cm.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)},Cm.toBlob=function(t,i){return new Promise(s=>{e.origin.canvasToBolb(this.view,t,i).then(t=>{s(t)}).catch(t=>{Om.error(t),s(null)})})},Cm.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Cm.saveAs=function(t,i){return new Promise(s=>{e.origin.canvasSaveAs(this.view,t,i).then(()=>{s(!0)}).catch(t=>{Om.error(t),s(!1)})})},te.add("export"),Object.assign(Xh,Pm),t.UI.prototype.export=function(t,e){return Xh.export(this,t,e)},t.UI.prototype.syncExport=function(t,e){return Xh.syncExport(this,t,e)};const Mm={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},Dm={top:"flex-start",middle:"center",bottom:"flex-end"},Im={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function Am(t,e,i){const{style:s}=t,{fill:n,padding:r,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";u(e)&&(e=e[0]);if(p(e))switch(e.type){case"solid":i=Ah.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=Ah.string(h(t)?t:t.color);break;default:o(e.r)||(i=Ah.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=Ah.string(d.color))):c=d,s.textDecoration=Im[c],s.textTransform=Mm[e.textCase],s.textAlign="both"===e.textAlign?"justify":e.textAlign,s.display="flex",s.flexDirection="column",s.justifyContent=Dm[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=u(r)?r.map(t=>t*i+"px").join(" "):(r||0)*i+"px",s.textOverflow="show"===l?"":"hide"===l?"clip":l}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"),{style:r}=n;n.contentEditable="true",r.position="fixed",r.transformOrigin="left top",r.boxSizing="border-box",this.isHTMLText?n.innerHTML=String(s.text):n.innerText=String(s.text);const{view:o}=e.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(n):o.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];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 r=i.split("\n"),o=document.createDocumentFragment();r.forEach((t,e)=>{e>0&&o.appendChild(document.createElement("br")),o.appendChild(document.createTextNode(t))}),n.insertNode(o),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,r=0;i*=e,s*=e;const o=t.__;if(o.__autoWidth)switch(i+=20,o.textAlign){case"center":n=o.autoSizeAlign?-i/2:-10;break;case"right":n=o.autoSizeAlign?-i:-20}if(o.__autoHeight)switch(s+=20,o.verticalAlign){case"middle":r=o.autoSizeAlign?-s/2:-10;break;case"bottom":r=o.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:p,f:g}=new ct(t.worldTransform).scale(1/e).translateInner(n,r),{style:_}=this.editDom;_.transform=`matrix(${l},${d},${c},${u},${p},${g})`,_.left=a+"px",_.top=h+"px",_.width=i+"px",_.height=s+"px",this.isHTMLText||Am(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=le([Kg()],t.TextEditor),te.add("text-editor","editor");class Wm extends gl{setText(t){this._text=t,this.__htmlChanged=!0}}const Fm={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:"≥"};return 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(),r=s+10,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${n}">\n <foreignObject width="${r}" 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(o)),t.__naturalWidth=r/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 r=t.indexOf(";",n+1);if(r>n+1&&(e=t.slice(n+1,r),i=Fm[e],void 0!==i)){s+=i,n=r+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){h(t)?Fm[t]=e:Object.assign(Fm,t)}},le([Or(Wm)],t.HTMLText.prototype,"__",void 0),le([ur("")],t.HTMLText.prototype,"text",void 0),le([or("TextEditor")],t.HTMLText.prototype,"editInner",void 0),le([wr(!1)],t.HTMLText.prototype,"textEditing",void 0),t.HTMLText=le([Ur()],t.HTMLText),te.add("html"),t.AlignHelper=wt,t.AroundHelper=yt,t.ArrowData=ff,t.AutoBounds=Xt,t.BezierHelper=ti,t.Bounds=Nt,t.BoundsEvent=Do,t.BoundsHelper=Ft,t.BoxData=il,t.BranchHelper=po,t.BranchRender=Pa,t.CanvasData=_l,t.CanvasManager=he,t.ChildEvent=Lo,t.ColorConvert=Ah,t.Creator=ee,t.Cursor=Nd,t.DataHelper=f,t.Debug=Gt,t.DragBoundsHelper=xd,t.Dragger=Cd,t.EditBox=Ag,t.EditDataHelper=Pg,t.EditPoint=Mg,t.EditSelect=_g,t.EditSelectHelper=cg,t.EditToolCreator=Zg,t.EditorEvent=tg,t.EditorGroupEvent=$g,t.EditorHelper=Vg,t.EditorMoveEvent=s_,t.EditorRotateEvent=r_,t.EditorScaleEvent=n_,t.EditorSkewEvent=o_,t.Effect=Nh,t.EllipseData=al,t.EllipseHelper=li,t.Event=Po,t.EventCreator=oe,t.Eventer=Jo,t.Export=Xh,t.FileHelper=zn,t.Filter=Yh,t.Finder=Em,t.FourNumberHelper=k,t.FrameData=nl,t.GroupData=el,t.HTMLTextData=Wm,t.HitCanvasManager=Yd,t.ImageData=gl,t.ImageEvent=Mo,t.ImageManager=Gn,t.IncrementId=i,t.InnerEditor=h_,t.InnerEditorEvent=Jg,t.InteractionBase=Ud,t.InteractionHelper=Bd,t.Keyboard=od,t.LayoutEvent=No,t.Layouter=Sh,t.LeafBounds=Ba,t.LeafBoundsHelper=ho,t.LeafData=y,t.LeafDataProxy=da,t.LeafEventer=ha,t.LeafHelper=to,t.LeafLayout=To,t.LeafLevelList=dh,t.LeafList=lh,t.LeafMatrix=ma,t.LeafRender=Sa,t.LeaferCanvas=ch,t.LeaferCanvasBase=ke,t.LeaferData=sl,t.LeaferEvent=Xo,t.LeaferImage=Qn,t.LeaferTypeCreator=X_,t.LineData=rl,t.MathHelper=O,t.Matrix=ct,t.MatrixHelper=G,t.MultiTouchHelper=G_,t.MyDragEvent=kd,t.MyImage=td,t.MyPointerEvent=Ed,t.NeedConvertToCanvasCommandMap=Le,t.OneRadian=D,t.PI2=I,t.PI_2=A,t.Paint=zh,t.PaintGradient=Uh,t.PaintImage=Hh,t.PathArrow=Fh,t.PathArrowModule=pm,t.PathBounds=Tn,t.PathCommandDataHelper=fs,t.PathCommandMap=Te,t.PathConvert=Gi,t.PathCorner=Dn,t.PathCreator=Ms,t.PathData=dl,t.PathDrawer=Ks,t.PathHelper=Be,t.PathMatrixHelper=Tf,t.PathNumberCommandLengthMap=Me,t.PathNumberCommandMap=Oe,t.PenData=cl,t.Picker=Rh,t.Platform=e,t.Plugin=te,t.Point=lt,t.PointHelper=nt,t.PointerButton=ad,t.PolygonData=hl,t.PropertyEvent=Co,t.RectData=ol,t.RectHelper=De,t.RectRender=El,t.RenderEvent=Yo,t.Renderer=Ph,t.ResizeEvent=Ho,t.Resource=Vn,t.Run=Jt,t.ScrollBar=_f,t.SelectArea=dg,t.Selector=Ch,t.StarData=ll,t.State=Vh,t.StringNumberMap=Vt,t.Stroker=lg,t.TaskItem=Nn,t.TaskProcessor=Yn,t.TextConvert=Ih,t.TextData=pl,t.TransformTool=a_,t.Transformer=rf,t.Transition=jh,t.TwoPointBoundsHelper=pt,t.UIBounds=yl,t.UICreator=se,t.UIData=Qh,t.UIEvent=hd,t.UIRender=xl,t.UnitConvert=Wh,t.WaitHelper=mo,t.WatchEvent=Uo,t.Watcher=_h,t.WheelEventHelper=Q_,t.addViewport=U_,t.addViewportConfig=N_,t.affectRenderBoundsType=xr,t.affectStrokeBoundsType=mr,t.arrowType=mf,t.attr=nr,t.autoLayoutType=lr,t.boundsType=ur,t.canvasPatch=Fn,t.canvasSizeAttrs=be,t.createAttr=function(t){return(e,i)=>{tr(e,i,ir(i,t))}},t.createDescriptor=ir,t.cursorType=Cr,t.dataProcessor=Or,t.dataType=or,t.decorateLeafAttr=sr,t.defineDataProcessor=Mr,t.defineKey=tr,t.defineLeafAttr=rr,t.dimType=Er,t.doBoundsType=gr,t.doStrokeType=yr,t.effectType=Oh,t.emptyData=r,t.eraserType=Lr,t.extraPropertyEventMap=Oo,t.getBoundsData=F,t.getDescriptor=er,t.getMatrixData=z,t.getPointData=W,t.hitType=Rr,t.isArray=u,t.isData=g,t.isEmptyData=_,t.isFinite=l,t.isNull=a,t.isNumber=d,t.isObject=p,t.isString=h,t.isUndefined=o,t.layoutProcessor=function(t){return(e,i)=>{tr(e,"__LayoutProcessor",{get:()=>t})}},t.leaferTransformAttrMap=Zo,t.maskType=Pr,t.naturalBoundsType=pr,t.opacityType=br,t.path=In,t.pathInputType=_r,t.pathType=fr,t.pen=An,t.positionType=ar,t.registerEditTool=Gg,t.registerInnerEditor=Kg,t.registerUI=Ur,t.registerUIEvent=Nr,t.resizeType=Mh,t.rewrite=Wr,t.rewriteAble=Fr,t.rotationType=cr,t.scaleType=dr,t.scrollType=hr,t.sortType=Tr,t.strokeType=vr,t.surfaceType=wr,t.tempBounds=Yt,t.tempMatrix=ut,t.tempPoint=dt,t.tryToNumber=function(t){return"string"==typeof t&&c.test(t)?+t:t},t.useCanvas=ph,t.useModule=Hr,t.version="1.9.12",t.visibleType=kr,t.zoomLayerType=Dh,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;t.Answer=void 0,(e=t.Answer||(t.Answer={}))[e.No=0]="No",e[e.Yes=1]="Yes",e[e.NoAndSkip=2]="NoAndSkip",e[e.YesAndSkip=3]="YesAndSkip";const i={};function s(t){return void 0===t}function n(t){return null==t}function r(t){return"string"==typeof t}const{isFinite:o}=Number;function a(t){return"number"==typeof t}const h=/^-?\d+(?:\.\d+)?$/;const{isArray:l}=Array;function d(t){return t&&"object"==typeof t}function c(t){return d(t)&&!l(t)}function u(t){return"{}"===JSON.stringify(t)}const p={default:(t,e)=>(g(e,t),g(t,e),t),assign(t,e,i){let s;Object.keys(e).forEach(n=>{var r,o;if(s=e[n],(null==s?void 0:s.constructor)===Object&&(null===(r=t[n])||void 0===r?void 0:r.constructor)===Object)return g(t[n],e[n],i&&i[n]);i&&n in i?(null===(o=i[n])||void 0===o?void 0:o.constructor)===Object&&g(t[n]={},e[n],i[n]):t[n]=e[n]})},copyAttrs:(t,e,i)=>(i.forEach(i=>{s(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:g}=p;class _{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __usePathBox(){return this.__pathInputed}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(!s(e))return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let i;for(let n in this)"_"!==n[0]&&(i=e?e[n]:void 0,t[n]=s(i)?this[n]: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(!s(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!s(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const i={};if(t)if(l(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:n}=this;i.tag=this.__leaf.tag;for(let r in this)if("_"!==r[0]&&(t=this["_"+r],!s(t))){if("path"===r&&!this.__pathInputed)continue;e=n?n[r]:void 0,i[r]=s(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:s,d:n,e:r,f:o}=this.__leaf.__localMatrix;i.matrix={a:t,b:e,c:s,d:n,e:r,f:o}}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{floor:f,max:m}=Math,y={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||v.maxCacheSize),isSuperLarge:(t,e,i)=>v.isLarge(t,e,i,v.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=y.image;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,r,o,a,h){const l=y.origin.createCanvas(m(f(e+(s||0)),1),m(f(i+(n||0)),1)),d=l.getContext("2d");if(a&&(d.globalAlpha=a),d.imageSmoothingEnabled=!1!==o,r){const s=e/r.width,n=i/r.height;d.setTransform(s,0,0,n,-r.x*s,-r.y*n),d.drawImage(t,0,0,t.width,t.height)}else d.drawImage(t,0,0,e,i);return l},setPatternTransform(t,e,i){try{e&&t.setTransform&&(t.setTransform(e),e=void 0)}catch(t){}i&&p.stintSet(i,"transform",e)}}},{image:v}=y,x={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=w;return e[t]?e[t]++:(e[t]=1,0)}},w=x;let E,b,k;const{max:S}=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){k=i?a(t)?e:t:[],a(t)?(E=R(t),b=e):a(e)?(E=t,b=R(e)):(E=t,b=e),4!==E.length&&(E=L(E)),4!==b.length&&(b=L(b))},get(t,e){let i;if(!a(t))switch(t.length){case 4:i=s(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]),!s(e))for(let t=0;t<4;t++)i[t]>e&&(i[t]=e);return i},max:(t,e,i)=>a(t)&&a(e)?S(t,e):(C(t,e,i),P(k,S(E[0],b[0]),S(E[1],b[1]),S(E[2],b[2]),S(E[3],b[3]))),add:(t,e,i)=>a(t)&&a(e)?t+e:(C(t,e,i),P(k,E[0]+b[0],E[1]+b[1],E[2]+b[2],E[3]+b[3])),swapAndScale(t,e,i,s){if(a(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[r,o,h,l]=4===t.length?t:L(t);return P(n,h*i,l*e,r*i,o*e)}},{set:P,get:L,setTemp:R,toTempAB:C}=T,{round:O,pow:M,max:D,floor:I,PI:A}=Math,W={within:(t,e,i)=>(d(e)&&(i=e.max,e=e.min),!s(e)&&t<e&&(t=e),!s(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)),W.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=s(e)?1e12:M(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=(a(e)?e:e.width||0)/i.width,n=(a(e)?e:e.height||0)/i.height;s.scaleX=t||n||1,s.scaleY=n||t||1}else t&&W.assignScale(s,t);return s},assignScale(t,e){a(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>D(I(t),e)/t,randInt:F,randColor:t=>`rgba(${F(255)},${F(255)},${F(255)},${t||1})`};function F(t){return Math.round(Math.random()*t)}const z=A/180,U=2*A,H=A/2;function N(){return{x:0,y:0}}function Y(){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:j,acos:G,sqrt:K}=Math,{float:Z}=W,q={};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,r=0,o=0){t.a=e,t.b=i,t.c=s,t.d=n,t.e=r,t.f=o},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,q),Q.scaleOfInner(t,q,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:r}=t,o=j(e*=z),a=V(e);t.a=i*o-s*a,t.b=i*a+s*o,t.c=n*o-r*a,t.d=n*a+r*o},rotateOfOuter(t,e,i){Q.toInnerPoint(t,e,q),Q.rotateOfInner(t,q,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:r,d:o}=t;i&&(i*=z,t.a=s+r*i,t.b=n+o*i),e&&(e*=z,t.c=r+s*e,t.d=o+n*e)},skewOfOuter(t,e,i,s){Q.toInnerPoint(t,e,q),Q.skewOfInner(t,q,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:r,e:o,f:a}=t;t.a=e.a*i+e.b*n,t.b=e.a*s+e.b*r,t.c=e.c*i+e.d*n,t.d=e.c*s+e.d*r,t.e=e.e*i+e.f*n+o,t.f=e.e*s+e.f*r+a},multiplyParent(t,e,i,n,r){const{e:o,f:a}=t;if(i||(i=t),s(n)&&(n=1!==t.a||t.b||t.c||1!==t.d),n){const{a:s,b:n,c:o,d:a}=t;i.a=s*e.a+n*e.c,i.b=s*e.b+n*e.d,i.c=o*e.a+a*e.c,i.d=o*e.b+a*e.d,r&&(i.scaleX=e.scaleX*r.scaleX,i.scaleY=e.scaleY*r.scaleY)}else i.a=e.a,i.b=e.b,i.c=e.c,i.d=e.d,r&&(i.scaleX=e.scaleX,i.scaleY=e.scaleY);i.e=o*e.a+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:r,f:o}=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=-(r*n-o*s)*a,t.f=-(o*e-r*i)*a}else if(1===e&&1===n)t.e=-r,t.f=-o;else{const i=1/(e*n);t.a=n*i,t.d=e*i,t.e=-r*n*i,t.f=-o*e*i}},toOuterPoint(t,e,i,s){const{x:n,y:r}=e;i||(i=e),i.x=n*t.a+r*t.c,i.y=n*t.b+r*t.d,s||(i.x+=t.e,i.y+=t.f)},toInnerPoint(t,e,i,s){const{a:n,b:r,c:o,d:a}=t,h=1/(n*a-r*o),{x:l,y:d}=e;if(i||(i=e),i.x=(l*a-d*o)*h,i.y=(d*n-l*r)*h,!s){const{e:e,f:s}=t;i.x-=(e*a-s*o)*h,i.y-=(s*n-e*r)*h}},setLayout(t,e,i,n,r){const{x:o,y:a,scaleX:h,scaleY:l}=e;if(s(r)&&(r=e.rotation||e.skewX||e.skewY),r){const{rotation:i,skewX:s,skewY:n}=e,r=i*z,o=j(r),a=V(r);if(s||n){const e=s*z,i=n*z;t.a=(o+i*-a)*h,t.b=(a+i*o)*h,t.c=(e*o-a)*l,t.d=(o+e*a)*l}else t.a=o*h,t.b=a*h,t.c=-a*l,t.d=o*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=o,t.f=a,(i=i||n)&&Q.translateInner(t,-i.x,-i.y,!n)},getLayout(t,e,i,s){const{a:n,b:r,c:o,d:a,e:h,f:l}=t;let d,c,u,p,g,_=h,f=l;if(r||o){const t=n*a-r*o;if(o&&!s){d=K(n*n+r*r),c=t/d;const e=n/d;u=r>0?G(e):-G(e)}else{c=K(o*o+a*a),d=t/c;const e=o/c;u=H-(a>0?G(-e):-G(e))}const e=Z(j(u)),i=V(u);d=Z(d),c=Z(c),p=e?Z((o/c+i)/e/z,9):0,g=e?Z((r/d-i)/e/z,9):0,u=Z(u/z)}else d=n,c=a,u=p=g=0;return(e=i||e)&&(_+=e.x*n+e.y*o,f+=e.x*r+e.y*a,i||(_-=e.x,f-=e.y)),{x:_,y:f,scaleX:d,scaleY:c,rotation:u,skewX:p,skewY:g}},withScale(t,e,i=e){const s=t;if(!e||!i){const{a:s,b:n,c:r,d:o}=t;n||r?i=(s*o-n*r)/(e=K(s*s+n*n)):(e=s,i=o)}return s.scaleX=e,s.scaleY=i,s},reset(t){Q.set(t)}},Q=$,{toInnerPoint:tt,toOuterPoint:et}=$,{sin:it,cos:st,abs:nt,sqrt:rt,atan2:ot,min:at,round:ht}=Math,lt={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=s(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?ht(t.x-.5)+.5:ht(t.x),t.y=e?ht(t.y-.5)+.5:ht(t.y)},move(t,e,i){d(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=dt.defaultPoint);const s=st(e*=z),n=it(e),r=t.x-i.x,o=t.y-i.y;t.x=i.x+r*s-o*n,t.y=i.y+r*n+o*s},tempToInnerOf(t,e){const{tempPoint:i}=dt;return ut(i,t),tt(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=dt;return ut(i,t),et(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=dt;return ut(i,t),dt.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),tt(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){tt(e,t,i)},toOuterOf(t,e,i){et(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)=>ct(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=nt(i-t),r=nt(s-e);return rt(n*n+r*r)},getMinDistanceFrom:(t,e,i,s,n,r)=>at(ct(t,e,i,s),ct(i,s,n,r)),getAngle:(t,e)=>pt(t,e)/z,getRotation:(t,e,i,s)=>(s||(s=e),dt.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/z),getRadianFrom(t,e,i,n,r,o,a,h){s(a)&&(a=i,h=n);const l=t-i,d=e-n,c=r-a,u=o-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){const n=pt(t,e);return(e=s?e:{}).x=t.x+st(n)*i,e.y=t.y+it(n)*i,e},toNumberPoints(t){let e=t;return d(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},reset(t){dt.reset(t)}},dt=lt,{getDistanceFrom:ct,copy:ut,getAtan2:pt}=dt;class gt{constructor(t,e){this.set(t,e)}set(t,e){return d(t)?lt.copy(this,t):lt.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new gt(this)}move(t,e){return lt.move(this,t,e),this}scale(t,e){return lt.scale(this,t,e),this}scaleOf(t,e,i){return lt.scaleOf(this,t,e,i),this}rotate(t,e){return lt.rotate(this,t,e),this}rotateOf(t,e){return lt.rotate(this,e,t),this}getRotation(t,e,i){return lt.getRotation(this,t,e,i)}toInnerOf(t,e){return lt.toInnerOf(this,t,e),this}toOuterOf(t,e){return lt.toOuterOf(this,t,e),this}getCenter(t){return new gt(lt.getCenter(this,t))}getDistance(t){return lt.getDistance(this,t)}getDistancePoint(t,e,i){return new gt(lt.getDistancePoint(this,t,e,i))}getAngle(t){return lt.getAngle(this,t)}getAtan2(t){return lt.getAtan2(this,t)}reset(){return lt.reset(this),this}}const _t=new gt;class ft{constructor(t,e,i,s,n,r){this.set(t,e,i,s,n,r)}set(t,e,i,s,n,r){return d(t)?$.copy(this,t):$.set(this,t,e,i,s,n,r),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:r}=this;return{a:t,b:e,c:i,d:s,e:n,f:r}}clone(){return new ft(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 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 xt,wt;t.Direction4=void 0,(xt=t.Direction4||(t.Direction4={}))[xt.top=0]="top",xt[xt.right=1]="right",xt[xt.bottom=2]="bottom",xt[xt.left=3]="left",t.Direction9=void 0,(wt=t.Direction9||(t.Direction9={}))[wt.topLeft=0]="topLeft",wt[wt.top=1]="top",wt[wt.topRight=2]="topRight",wt[wt.right=3]="right",wt[wt.bottomRight=4]="bottomRight",wt[wt.bottom=5]="bottom",wt[wt.bottomLeft=6]="bottomLeft",wt[wt.left=7]="left",wt[wt.center=8]="center",wt[wt["top-left"]=0]="top-left",wt[wt["top-right"]=2]="top-right",wt[wt["bottom-right"]=4]="bottom-right",wt[wt["bottom-left"]=6]="bottom-left";const Et=[{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}];Et.forEach(t=>t.type="percent");const bt={directionData:Et,tempPoint:{},get:kt,toPoint(t,e,i,s,n,r){const o=kt(t);i.x=o.x,i.y=o.y,"percent"===o.type&&(i.x*=e.width,i.y*=e.height,n&&(r||(i.x-=n.x,i.y-=n.y),o.x&&(i.x-=1===o.x?n.width:.5===o.x?o.x*n.width:0),o.y&&(i.y-=1===o.y?n.height:.5===o.y?o.y*n.height:0))),s||(i.x+=e.x,i.y+=e.y)},getPoint:(t,e,i)=>(i||(i={}),bt.toPoint(t,e,i,!0),i)};function kt(e){return r(e)?Et[t.Direction9[e]]:e}const{toPoint:St}=bt,Bt={toPoint(t,e,i,s,n,r){St(t,i,s,n,e,r)}},{tempPointBounds:Tt,setPoint:Pt,addPoint:Lt,toBounds:Rt}=yt,{toOuterPoint:Ct}=$,{float:Ot,fourNumber:Mt}=W,{floor:Dt,ceil:It}=Math;let At,Wt,Ft,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:r,y:o,width:a,height:h}=e;if(l(i)){const e=Mt(i);s?Xt.set(t,r+e[3],o+e[0],a-e[1]-e[3],h-e[2]-e[0]):Xt.set(t,r-e[3],o-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Xt.set(t,r-i,o-i,a+2*i,h+2*i);n&&("width"===n?(t.y=o,t.height=h):(t.x=r,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?jt(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||lt.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){lt.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:r,f:o}=e;s>0?(i.width=t.width*s,i.x=r+t.x*s):(i.width=t.width*-s,i.x=r+t.x*s-i.width),n>0?(i.height=t.height*n,i.y=o+t.y*n):(i.height=t.height*-n,i.y=o+t.y*n-i.height)}else Ut.x=t.x,Ut.y=t.y,Ct(e,Ut,Ht),Pt(Tt,Ht.x,Ht.y),Ut.x=t.x+t.width,Ct(e,Ut,Ht),Lt(Tt,Ht.x,Ht.y),Ut.y=t.y+t.height,Ct(e,Ut,Ht),Lt(Tt,Ht.x,Ht.y),Ut.x=t.x,Ct(e,Ut,Ht),Lt(Tt,Ht.x,Ht.y),Rt(Tt,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,Bt.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?It(t.width+e-t.x):It(t.width),t.height=i>t.y?It(t.height+i-t.y):It(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){At=t.x+t.width,Wt=t.y+t.height,Ft=e.x,zt=e.y,i||(Ft+=e.width,zt+=e.height),At=At>Ft?At:Ft,Wt=Wt>zt?Wt:zt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=At-t.x,t.height=Wt-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,r=!0;for(let o=0,a=e.length;o<a;o++)n=i?i(e[o],o):e[o],n&&(n.width||n.height)&&(r?(r=!1,s||jt(t,n)):Vt(t,n));r&&Xt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?Pt(Tt,t.x,t.y):Lt(Tt,t.x,t.y)),Rt(Tt,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=lt.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=lt.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:r,height:o}=e;return At=s+r,Wt=n+o,Ft=t.x+t.width,zt=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,At=At<Ft?At:Ft,Wt=Wt<zt?Wt:zt,r=At-s,o=Wt-n,{x:s,y:n,width:r,height:o}},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,reset(t){Xt.set(t)}},Xt=Yt,{add:Vt,copy:jt}=Xt;class Gt{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 d(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 Gt(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 Gt(Yt.getIntersectData(this,t,e))}isSame(t){return Yt.isSame(this,t)}isEmpty(){return Yt.isEmpty(this)}reset(){Yt.reset(this)}}const Kt=new Gt;class Zt{constructor(t,e,i,s,n,r){d(t)?this.copy(t):this.set(t,e,i,s,n,r)}set(t=0,e=0,i=0,s=0,n=0,r=0){this.top=t,this.right=e,this.bottom=i,this.left=s,this.width=n,this.height=r}copy(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=t;this.set(e,i,s,n,r,o)}getBoundsFrom(t){const{top:e,right:i,bottom:s,left:n,width:r,height:o}=this;return new Gt(n,e,r||t.width-n-i,o||t.height-e-s)}}const 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},{randColor:Jt}=W;class $t{constructor(t){this.repeatMap={},this.name=t}static get(t){return new $t(t)}static set filter(t){this.filterList=Qt(t)}static set exclude(t){this.excludeList=Qt(t)}static drawRepaint(t,e){const i=Jt();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===$t.showBounds,n=t.__nowWorld,r=Jt();s&&(e.setWorld(n),t.__drawHitPath(e),e.fillStyle=r.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(r,2),s?e.stroke():e.strokeWorld(n,r)}log(...t){if(te.enable){if(te.filterList.length&&te.filterList.every(t=>t!==this.name))return;if(te.excludeList.length&&te.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){te.enable&&this.warn(...t)}warn(...t){te.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 Qt(t){return t?r(t)&&(t=[t]):t=[],t}$t.filterList=[],$t.excludeList=[],$t.showWarn=!0;const te=$t,ee=$t.get("RunTime"),ie={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=x.create(x.RUNTIME);return se.currentId=se.idMap[i]=e?performance.now():Date.now(),se.currentName=se.nameMap[i]=t,se.nameToIdMap[t]=i,i},end(t,e){const i=se.idMap[t],s=se.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;se.idMap[t]=se.nameMap[t]=se.nameToIdMap[s]=void 0,ee.log(s,n,"ms")},endOfName(t,e){const i=se.nameToIdMap[t];s(i)||se.end(i,e)}},se=ie,ne=[],re={list:{},add(t,...e){this.list[t]=!0,ne.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(()=>ne.forEach(t=>re.has(t,!0)));const oe={editor:t=>re.need("editor")},ae=$t.get("UICreator"),he={list:{},register(t){const{__tag:e}=t.prototype;le[e]&&ae.repeat(e),le[e]=t},get(t,e,i,n,r,o){le[t]||ae.error("not register "+t);const a=new le[t](e);return s(i)||(a.x=i,n&&(a.y=n),r&&(a.width=r),o&&(a.height=o)),a}},{list:le}=he,de=$t.get("EventCreator"),ce={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],r(e)&&(ue[e]&&de.repeat(e),ue[e]=t)})},changeName(t,e){const i=ue[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,ue[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new ue[t](...e)},{nameList:ue}=ce;class pe{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=oe.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 ge(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o}function _e(t,e,i,s){return new(i||(i=Promise))(function(n,r){function o(t){try{h(s.next(t))}catch(t){r(t)}}function a(t){try{h(s.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,a)}h((s=s.apply(t,e||[])).next())})}function fe(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 me=[];function ye(){return(t,e)=>{me.push(e)}}const ve=[];class xe{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||ve)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;me.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,i,s,n,r){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,i,s,n,r){d(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,i,s,n,r)}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,r,o,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/s*a;s+=e,e=0,r+=t,a-=t}if(i<0){const t=-i/n*h;n+=i,i=0,o+=t,h-=t}this.context.drawImage(t,e,i,s,n,r,o,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,r){}quadraticCurveTo(t,e,i,s){}closePath(){}arc(t,e,i,s,n,r){}arcTo(t,e,i,s,n){}ellipse(t,e,i,s,n,r,o,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,r){}fillText(t,e,i,s){}measureText(t){}strokeText(t,e,i,s){}destroy(){this.context=null}}ge([fe("imageSmoothingEnabled")],xe.prototype,"smooth",void 0),ge([fe("imageSmoothingQuality")],xe.prototype,"smoothLevel",void 0),ge([fe("globalAlpha")],xe.prototype,"opacity",void 0),ge([fe()],xe.prototype,"fillStyle",void 0),ge([fe()],xe.prototype,"strokeStyle",void 0),ge([fe("lineWidth")],xe.prototype,"strokeWidth",void 0),ge([fe("lineCap")],xe.prototype,"strokeCap",void 0),ge([fe("lineJoin")],xe.prototype,"strokeJoin",void 0),ge([fe("lineDashOffset")],xe.prototype,"dashOffset",void 0),ge([fe()],xe.prototype,"miterLimit",void 0),ge([fe()],xe.prototype,"shadowBlur",void 0),ge([fe()],xe.prototype,"shadowColor",void 0),ge([fe()],xe.prototype,"shadowOffsetX",void 0),ge([fe()],xe.prototype,"shadowOffsetY",void 0),ge([fe()],xe.prototype,"filter",void 0),ge([fe()],xe.prototype,"font",void 0),ge([fe()],xe.prototype,"fontKerning",void 0),ge([fe()],xe.prototype,"fontStretch",void 0),ge([fe()],xe.prototype,"fontVariantCaps",void 0),ge([fe()],xe.prototype,"textAlign",void 0),ge([fe()],xe.prototype,"textBaseline",void 0),ge([fe()],xe.prototype,"textRendering",void 0),ge([fe()],xe.prototype,"wordSpacing",void 0),ge([fe()],xe.prototype,"letterSpacing",void 0),ge([fe()],xe.prototype,"direction",void 0),ge([ye()],xe.prototype,"setTransform",null),ge([ye()],xe.prototype,"resetTransform",null),ge([ye()],xe.prototype,"getTransform",null),ge([ye()],xe.prototype,"save",null),ge([ye()],xe.prototype,"restore",null),ge([ye()],xe.prototype,"translate",null),ge([ye()],xe.prototype,"scale",null),ge([ye()],xe.prototype,"rotate",null),ge([ye()],xe.prototype,"fill",null),ge([ye()],xe.prototype,"stroke",null),ge([ye()],xe.prototype,"clip",null),ge([ye()],xe.prototype,"fillRect",null),ge([ye()],xe.prototype,"strokeRect",null),ge([ye()],xe.prototype,"clearRect",null),ge([ye()],xe.prototype,"beginPath",null),ge([ye()],xe.prototype,"moveTo",null),ge([ye()],xe.prototype,"lineTo",null),ge([ye()],xe.prototype,"bezierCurveTo",null),ge([ye()],xe.prototype,"quadraticCurveTo",null),ge([ye()],xe.prototype,"closePath",null),ge([ye()],xe.prototype,"arc",null),ge([ye()],xe.prototype,"arcTo",null),ge([ye()],xe.prototype,"ellipse",null),ge([ye()],xe.prototype,"rect",null),ge([ye()],xe.prototype,"roundRect",null),ge([ye()],xe.prototype,"createConicGradient",null),ge([ye()],xe.prototype,"createLinearGradient",null),ge([ye()],xe.prototype,"createPattern",null),ge([ye()],xe.prototype,"createRadialGradient",null),ge([ye()],xe.prototype,"fillText",null),ge([ye()],xe.prototype,"measureText",null),ge([ye()],xe.prototype,"strokeText",null);const{copy:we,multiplyParent:Ee,pixelScale:be}=$,{round:ke}=Math,Se=new Gt,Be=new Gt,Te={width:1,height:1,pixelRatio:1},Pe=["width","height","pixelRatio"];class Le extends xe{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=Te),this.manager=e,this.innerId=x.create(x.CNAVAS);const{width:i,height:s,pixelRatio:n}=t;this.autoLayout=!i||!s,this.size.pixelRatio=n||y.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;p.copyAttrs(s,t,Pe),Pe.forEach(t=>s[t]||(s[t]=1)),this.bounds=new Gt(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&&Ee(t,e,n),be(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=ke(n.e-.5)+.5,n.f=ke(n.f-.5)+.5):(n.e=ke(n.e),n.f=ke(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:n,dashPattern:r,dashOffset:o,miterLimit:a}=t;e&&(e.strokeCap&&(i=e.strokeCap),e.strokeJoin&&(n=e.strokeJoin),s(e.dashPattern)||(r=e.dashPattern),s(e.dashOffset)||(o=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=i,this.strokeJoin=n,this.dashPattern=r,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=!0){s&&(this.blendMode=s),e?(this.setTempPixelBounds(e,n),i?(this.setTempPixelBounds2(i,n),i=Be):i=Se,this.drawImage(t.view,Se.x,Se.y,Se.width,Se.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=!0){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,Se.x,Se.y,Se.width,Se.height,i.x,i.y,i.width,i.height),s&&(this.blendMode="source-over"))}copyWorldByReset(t,e,i,s,n,r=!0){this.resetTransform(),this.copyWorld(t,e,i,s,r),n||this.useWorldTransform()}useGrayscaleAlpha(t){let e,i;this.setTempPixelBounds(t,!0,!0);const{context:s}=this,n=s.getImageData(Se.x,Se.y,Se.width,Se.height),{data:r}=n;for(let t=0,s=r.length;t<s;t+=4)i=.299*r[t]+.587*r[t+1]+.114*r[t+2],(e=r[t+3])&&(r[t+3]=255===e?i:e*(i/255));s.putImageData(n,Se.x,Se.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(Se.x,Se.y,Se.width,Se.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Se.x,Se.y,Se.width,Se.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Se.x,Se.y,Se.width,Se.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Se.x,Se.y,Se.width,Se.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Se,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(Be,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):oe.canvas(Object.assign({},i));return n.save(),t&&(we(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 Re={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Ce={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Oe=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},Ce),Me={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},De={m:10,l:20,H:3,h:30,V:4,v:40,c:50,S:6,s:60,q:70,T:8,t:80,A:9,a:90},Ie=Object.assign(Object.assign({},De),Ce),Ae=Oe,We={};for(let t in Ae)We[Ae[t]]=t;const Fe={};for(let t in Ae)Fe[Ae[t]]=Me[t];const ze={drawRoundRect(t,e,i,s,n,r){const o=W.fourNumber(r,Math.min(s/2,n/2)),a=e+s,h=i+n;o[0]?t.moveTo(e+o[0],i):t.moveTo(e,i),o[1]?t.arcTo(a,i,a,h,o[1]):t.lineTo(a,i),o[2]?t.arcTo(a,h,e,h,o[2]):t.lineTo(a,h),o[3]?t.arcTo(e,h,e,i,o[3]):t.lineTo(e,h),o[0]?t.arcTo(e,i,a,i,o[0]):t.lineTo(e,i)}},{sin:Ue,cos:He,hypot:Ne,atan2:Ye,ceil:Xe,abs:Ve,PI:je,sqrt:Ge,pow:Ke}=Math,{setPoint:Ze,addPoint:qe}=yt,{set:Je,toNumberPoints:$e}=lt,{M:Qe,L:ti,C:ei,Q:ii,Z:si}=Oe,ni={},ri={points(t,e,i,s){let n=$e(e);if(t.push(Qe,n[0],n[1]),i&&n.length>5){let e,r,o,a,h,l,d,c,u,p,g,_,f,m=n.length;const y=!0===i?.5:i;s&&(n=[n[m-2],n[m-1],...n,n[0],n[1],n[2],n[3]],m=n.length);for(let i=2;i<m-2;i+=2)e=n[i-2],r=n[i-1],o=n[i],a=n[i+1],h=n[i+2],l=n[i+3],g=Ge(Ke(o-e,2)+Ke(a-r,2)),_=Ge(Ke(h-o,2)+Ke(l-a,2)),(g||_)&&(f=g+_,g=y*g/f,_=y*_/f,h-=e,l-=r,d=o-g*h,c=a-g*l,2===i?s||t.push(ii,d,c,o,a):t.push(ei,u,p,d,c,o,a),u=o+_*h,p=a+_*l);s||t.push(ii,u,p,n[m-2],n[m-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(ti,n[e],n[e+1]);s&&t.push(si)},rect(t,e,i,s,n){Re.creator.path=t,Re.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,r){Re.creator.path=[],ze.drawRoundRect(Re.creator,e,i,s,n,r),t.push(...Re.convertToCanvasData(Re.creator.path,!0))},arcTo(t,e,i,s,n,r,o,a,h,l,d){const c=s-e,u=n-i,p=r-s,g=o-n;let _=Ye(u,c),f=Ye(g,p);const m=Ne(c,u),y=Ne(p,g);let v=f-_;if(v<0&&(v+=U),m<1e-12||y<1e-12||v<1e-12||Ve(v-je)<1e-12)return t&&t.push(ti,s,n),h&&(Ze(h,e,i),qe(h,s,n)),d&&Je(d,e,i),void(l&&Je(l,s,n));const x=c*g-p*u<0,w=x?-1:1,E=a/He(v/2),b=s+E*He(_+v/2+H*w),k=n+E*Ue(_+v/2+H*w);return _-=H*w,f-=H*w,hi(t,b,k,a,a,0,_/z,f/z,x,h,l,d)},arc:(t,e,i,s,n,r,o,a,h,l)=>hi(t,e,i,s,s,0,n,r,o,a,h,l),ellipse(t,e,i,s,n,r,o,a,h,l,d,c){const u=r*z,p=Ue(u),g=He(u);let _=o*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=Xe(Ve(m/H)),v=m/y,x=Ue(v/4),w=8/3*x*x/Ue(v/2);f=_+v;let E,b,k,S,B,T,P,L,R=He(_),C=Ue(_),O=k=g*s*R-p*n*C,M=S=p*s*R+g*n*C,D=e+k,I=i+S;t&&t.push(t.length?ti:Qe,D,I),l&&Ze(l,D,I),c&&Je(c,D,I);for(let r=0;r<y;r++)E=He(f),b=Ue(f),k=g*s*E-p*n*b,S=p*s*E+g*n*b,B=e+O-w*(g*s*C+p*n*R),T=i+M-w*(p*s*C-g*n*R),P=e+k+w*(g*s*b+p*n*E),L=i+S+w*(p*s*b-g*n*E),t&&t.push(ei,B,T,P,L,e+k,i+S),l&&ai(e+O,i+M,B,T,P,L,e+k,i+S,l,!0),O=k,M=S,R=E,C=b,_=f,f+=v;d&&Je(d,e+k,i+S)},quadraticCurveTo(t,e,i,s,n,r,o){t.push(ei,(e+2*s)/3,(i+2*n)/3,(r+2*s)/3,(o+2*n)/3,r,o)},toTwoPointBoundsByQuadraticCurve(t,e,i,s,n,r,o,a){ai(t,e,(t+2*i)/3,(e+2*s)/3,(n+2*i)/3,(r+2*s)/3,n,r,o,a)},toTwoPointBounds(t,e,i,s,n,r,o,a,h,l){const d=[];let c,u,p,g,_,f,m,y,v=t,x=i,w=n,E=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=s,w=r,E=a),c=-3*v+9*x-9*w+3*E,u=6*v-12*x+6*w,p=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-p/u,0<g&&g<1&&d.push(g)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(_=(-u+y)/(2*c),0<_&&_<1&&d.push(_),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?qe(h,t,e):Ze(h,t,e),qe(h,o,a);for(let l=0,c=d.length;l<c;l++)oi(d[l],t,e,i,s,n,r,o,a,ni),qe(h,ni.x,ni.y)},getPointAndSet(t,e,i,s,n,r,o,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,g=t*t*t;l.x=c*e+u*s+p*r+g*a,l.y=c*i+u*n+p*o+g*h},getPoint(t,e,i,s,n,r,o,a,h){const l={};return oi(t,e,i,s,n,r,o,a,h,l),l},getDerivative(t,e,i,s,n){const r=1-t;return 3*r*r*(i-e)+6*r*t*(s-i)+3*t*t*(n-s)}},{getPointAndSet:oi,toTwoPointBounds:ai,ellipse:hi}=ri,{sin:li,cos:di,sqrt:ci,atan2:ui}=Math,{ellipse:pi}=ri,gi={ellipticalArc(t,e,i,s,n,r,o,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,p=r*z,g=li(p),_=di(p),f=-_*c-g*u,m=-_*u+g*c,v=s*s,x=n*n,w=m*m,E=f*f,b=v*x-v*w-x*E;let k=0;if(b<0){const t=ci(1-b/(v*x));s*=t,n*=t}else k=(o===a?-1:1)*ci(b/(v*w+x*E));const S=k*s*m/n,B=-k*n*f/s,T=ui((m-B)/n,(f-S)/s),P=ui((-m-B)/n,(-f-S)/s);let L=P-T;0===a&&L>0?L-=U:1===a&&L<0&&(L+=U);const R=e+c+_*S-g*B,C=i+u+g*S+_*B,O=L<0?1:0;d||y.ellipseToCurve?pi(t,R,C,s,n,r,T/z,P/z,O):s!==n||r?t.push(Oe.G,R,C,s,n,r,T/z,P/z,O):t.push(Oe.O,R,C,s,T/z,P/z,O)}},{M:_i,m:fi,L:mi,l:yi,H:vi,h:xi,V:wi,v:Ei,C:bi,c:ki,S:Si,s:Bi,Q:Ti,q:Pi,T:Li,t:Ri,A:Ci,a:Oi,Z:Mi,z:Di,N:Ii,D:Ai,X:Wi,G:Fi,F:zi,O:Ui,P:Hi,U:Ni}=Oe,{rect:Yi,roundRect:Xi,arcTo:Vi,arc:ji,ellipse:Gi,quadraticCurveTo:Ki}=ri,{ellipticalArc:Zi}=gi,qi=$t.get("PathConvert"),Ji={},$i={current:{dot:0},stringify(t,e){let i,s,n,r=0,o=t.length,a="";for(;r<o;){s=t[r],i=Fe[s],a+=s===n?" ":We[s];for(let s=1;s<i;s++)a+=W.float(t[r+s],e),s===i-1||(a+=" ");n=s,r+=i}return a},parse(t,e){let i,s,n,r="";const o=[],a=e?Ie:De;for(let e=0,h=t.length;e<h;e++)s=t[e],qt[s]?("."===s&&(Qi.dot&&(ts(o,r),r=""),Qi.dot++),"0"===r&&"."!==s&&(ts(o,r),r=""),r+=s):Oe[s]?(r&&(ts(o,r),r=""),Qi.name=Oe[s],Qi.length=Me[s],Qi.index=0,ts(o,Qi.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?r+=s:(r&&ts(o,r),r=s):r&&(ts(o,r),r=""),n=s;return r&&ts(o,r),i?$i.toCanvasData(o,e):o},toCanvasData(t,e){let i,s,n,r,o,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(n=t[c],n){case fi:t[c+1]+=a,t[c+2]+=h;case _i:a=t[c+1],h=t[c+2],p.push(_i,a,h),c+=3;break;case xi:t[c+1]+=a;case vi:a=t[c+1],p.push(mi,a,h),c+=2;break;case Ei:t[c+1]+=h;case wi:h=t[c+1],p.push(mi,a,h),c+=2;break;case yi:t[c+1]+=a,t[c+2]+=h;case mi:a=t[c+1],h=t[c+2],p.push(mi,a,h),c+=3;break;case Bi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Si;case Si:o=r===bi||r===Si,l=o?2*a-i:t[c+1],d=o?2*h-s:t[c+2],i=t[c+1],s=t[c+2],a=t[c+3],h=t[c+4],p.push(bi,l,d,i,s,a,h),c+=5;break;case ki: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=bi;case bi:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],p.push(bi,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Ri:t[c+1]+=a,t[c+2]+=h,n=Li;case Li:o=r===Ti||r===Li,i=o?2*a-i:t[c+1],s=o?2*h-s:t[c+2],e?Ki(p,a,h,i,s,t[c+1],t[c+2]):p.push(Ti,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Pi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ti;case Ti:i=t[c+1],s=t[c+2],e?Ki(p,a,h,i,s,t[c+3],t[c+4]):p.push(Ti,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Oi:t[c+6]+=a,t[c+7]+=h;case Ci:Zi(p,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case Di:case Mi:p.push(Mi),c++;break;case Ii:a=t[c+1],h=t[c+2],e?Yi(p,a,h,t[c+3],t[c+4]):es(p,t,c,5),c+=5;break;case Ai:a=t[c+1],h=t[c+2],e?Xi(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):es(p,t,c,9),c+=9;break;case Wi:a=t[c+1],h=t[c+2],e?Xi(p,a,h,t[c+3],t[c+4],t[c+5]):es(p,t,c,6),c+=6;break;case Fi:Gi(e?p:es(p,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,Ji),a=Ji.x,h=Ji.y,c+=9;break;case zi:e?Gi(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):es(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Ui:ji(e?p:es(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,Ji),a=Ji.x,h=Ji.y,c+=7;break;case Hi:e?ji(p,t[c+1],t[c+2],t[c+3],0,360,!1):es(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Ni:Vi(e?p:es(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,Ji),a=Ji.x,h=Ji.y,c+=6;break;default:return qi.error(`command: ${n} [index:${c}]`,t),p}r=n}return p},objectToCanvasData(t){const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(_i,t.x,t.y);break;case"L":e.push(mi,t.x,t.y);break;case"C":e.push(bi,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Ti,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Mi)}}),e},copyData(t,e,i,s){for(let n=i,r=i+s;n<r;n++)t.push(e[n])},pushData(t,e){Qi.index===Qi.length&&(Qi.index=1,t.push(Qi.name)),t.push(Number(e)),Qi.index++,Qi.dot=0}},{current:Qi,pushData:ts,copyData:es}=$i,{M:is,L:ss,C:ns,Q:rs,Z:os,N:as,D:hs,X:ls,G:ds,F:cs,O:us,P:ps,U:gs}=Oe,{getMinDistanceFrom:_s,getRadianFrom:fs}=lt,{tan:ms,min:ys,abs:vs}=Math,xs={},ws={beginPath(t){t.length=0},moveTo(t,e,i){t.push(is,e,i)},lineTo(t,e,i){t.push(ss,e,i)},bezierCurveTo(t,e,i,s,n,r,o){t.push(ns,e,i,s,n,r,o)},quadraticCurveTo(t,e,i,s,n){t.push(rs,e,i,s,n)},closePath(t){t.push(os)},rect(t,e,i,s,n){t.push(as,e,i,s,n)},roundRect(t,e,i,s,n,r){if(a(r))t.push(ls,e,i,s,n,r);else{const o=W.fourNumber(r);o?t.push(hs,e,i,s,n,...o):t.push(as,e,i,s,n)}},ellipse(t,e,i,s,r,o,a,h,l){n(o)?t.push(cs,e,i,s,r):(n(a)&&(a=0),n(h)&&(h=360),t.push(ds,e,i,s,r,o,a,h,l?1:0))},arc(t,e,i,s,r,o,a){n(r)?t.push(ps,e,i,s):(n(o)&&(o=360),t.push(us,e,i,s,r,o,a?1:0))},arcTo(t,e,i,n,r,o,a,h){if(!s(a)){const t=_s(a,h,e,i,n,r);o=ys(o,ys(t/2,t/2*vs(ms(fs(a,h,e,i,n,r)/2))))}t.push(gs,e,i,n,r,o)},drawEllipse(t,e,i,s,r,o,a,h,l){ri.ellipse(null,e,i,s,r,n(o)?0:o,n(a)?0:a,n(h)?360:h,l,null,null,xs),t.push(is,xs.x,xs.y),Es(t,e,i,s,r,o,a,h,l)},drawArc(t,e,i,s,r,o,a){ri.arc(null,e,i,s,n(r)?0:r,n(o)?360:o,a,null,null,xs),t.push(is,xs.x,xs.y),bs(t,e,i,s,r,o,a)},drawPoints(t,e,i,s){ri.points(t,e,i,s)}},{ellipse:Es,arc:bs}=ws,{moveTo:ks,lineTo:Ss,quadraticCurveTo:Bs,bezierCurveTo:Ts,closePath:Ps,beginPath:Ls,rect:Rs,roundRect:Cs,ellipse:Os,arc:Ms,arcTo:Ds,drawEllipse:Is,drawArc:As,drawPoints:Ws}=ws;class Fs{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?r(t)?Re.parse(t):t:[],this}beginPath(){return Ls(this.__path),this.paint(),this}moveTo(t,e){return ks(this.__path,t,e),this.paint(),this}lineTo(t,e){return Ss(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,r){return Ts(this.__path,t,e,i,s,n,r),this.paint(),this}quadraticCurveTo(t,e,i,s){return Bs(this.__path,t,e,i,s),this.paint(),this}closePath(){return Ps(this.__path),this.paint(),this}rect(t,e,i,s){return Rs(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Cs(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,r,o,a){return Os(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}arc(t,e,i,s,n,r){return Ms(this.__path,t,e,i,s,n,r),this.paint(),this}arcTo(t,e,i,s,n){return Ds(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,r,o,a){return Is(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}drawArc(t,e,i,s,n,r){return As(this.__path,t,e,i,s,n,r),this.paint(),this}drawPoints(t,e,i){return Ws(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:zs,L:Us,C:Hs,Q:Ns,Z:Ys,N:Xs,D:Vs,X:js,G:Gs,F:Ks,O:Zs,P:qs,U:Js}=Oe,$s=$t.get("PathDrawer"),Qs={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case zs:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Us:t.lineTo(e[s+1],e[s+2]),s+=3;break;case Hs:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Ns:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Ys:t.closePath(),s+=1;break;case Xs:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Vs: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 js:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Gs: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 Ks:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,U,!1),s+=5;break;case Zs: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 qs:t.arc(e[s+1],e[s+2],e[s+3],0,U,!1),s+=4;break;case Js:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void $s.error(`command: ${i} [index:${s}]`,e)}}},{M:tn,L:en,C:sn,Q:nn,Z:rn,N:on,D:an,X:hn,G:ln,F:dn,O:cn,P:un,U:pn}=Oe,{toTwoPointBounds:gn,toTwoPointBoundsByQuadraticCurve:_n,arcTo:fn,arc:mn,ellipse:yn}=ri,{addPointBounds:vn,copy:xn,addPoint:wn,setPoint:En,addBounds:bn,toBounds:kn}=yt,Sn=$t.get("PathBounds");let Bn,Tn,Pn;const Ln={},Rn={},Cn={},On={toBounds(t,e){On.toTwoPointBounds(t,Rn),kn(Rn,e)},toTwoPointBounds(t,e){if(!t||!t.length)return En(e,0,0);let i,s,n,r,o,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(o=t[a],0===a&&(o===rn||o===sn||o===nn?En(e,h,l):En(e,t[a+1],t[a+2])),o){case tn:case en:h=t[a+1],l=t[a+2],wn(e,h,l),a+=3;break;case sn:n=t[a+5],r=t[a+6],gn(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,r,Ln),vn(e,Ln),h=n,l=r,a+=7;break;case nn:i=t[a+1],s=t[a+2],n=t[a+3],r=t[a+4],_n(h,l,i,s,n,r,Ln),vn(e,Ln),h=n,l=r,a+=5;break;case rn:a+=1;break;case on:h=t[a+1],l=t[a+2],bn(e,h,l,t[a+3],t[a+4]),a+=5;break;case an:case hn:h=t[a+1],l=t[a+2],bn(e,h,l,t[a+3],t[a+4]),a+=o===an?9:6;break;case ln:yn(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],Ln,Cn),0===a?xn(e,Ln):vn(e,Ln),h=Cn.x,l=Cn.y,a+=9;break;case dn:h=t[a+1],l=t[a+2],Tn=t[a+3],Pn=t[a+4],bn(e,h-Tn,l-Pn,2*Tn,2*Pn),h+=Tn,a+=5;break;case cn:mn(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Ln,Cn),0===a?xn(e,Ln):vn(e,Ln),h=Cn.x,l=Cn.y,a+=7;break;case un:h=t[a+1],l=t[a+2],Bn=t[a+3],bn(e,h-Bn,l-Bn,2*Bn,2*Bn),h+=Bn,a+=4;break;case pn:fn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Ln,Cn),0===a?xn(e,Ln):vn(e,Ln),h=Cn.x,l=Cn.y,a+=6;break;default:return void Sn.error(`command: ${o} [index:${a}]`,t)}}},{M:Mn,L:Dn,Z:In}=Oe,{getCenterX:An,getCenterY:Wn}=lt,{arcTo:Fn}=ws,zn={smooth(t,e,i){let s,n,r,o=0,a=0,h=0,l=0,d=0,c=0,u=0,p=0,g=0;const _=t.length,f=[];for(;o<_;){switch(s=t[o],s){case Mn:l=p=t[o+1],d=g=t[o+2],o+=3,t[o]===Dn?(c=t[o+1],u=t[o+2],f.push(Mn,An(l,c),Wn(d,u))):f.push(Mn,l,d);break;case Dn:switch(a=t[o+1],h=t[o+2],o+=3,t[o]){case Dn:Fn(f,a,h,t[o+1],t[o+2],e,p,g);break;case In:Fn(f,a,h,l,d,e,p,g);break;default:f.push(Dn,a,h)}p=a,g=h;break;case In:n!==In&&(Fn(f,l,d,c,u,e,p,g),f.push(In)),o+=1;break;default:r=Fe[s];for(let e=0;e<r;e++)f.push(t[o+e]);o+=r}n=s}return s!==In&&(f[1]=l,f[2]=d),f}};function Un(t){return new Fs(t)}const Hn=Un();Re.creator=Un(),Re.parse=$i.parse,Re.convertToCanvasData=$i.toCanvasData;const{drawRoundRect:Nn}=ze;function Yn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Nn(this,t,e,i,s,n)})}(t)}const Xn={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=Vn.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{}}}},Vn=Xn;Vn.alphaPixelTypes.forEach(t=>Vn.upperCaseTypeMap[t]=t.toUpperCase());const jn=$t.get("TaskProcessor");class Gn{constructor(t){this.parallel=!0,this.time=1,this.id=x.create(x.TASK),this.task=t}run(){return _e(this,void 0,void 0,function*(){try{if(this.isComplete)return;if(this.canUse&&!this.canUse())return this.cancel();this.task&&this.parent.running&&(yield this.task())}catch(t){jn.error(t)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}}class Kn{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&&p.assign(this.config,t),this.empty()}add(t,e,i){let n,r,o,h;const l=new Gn(t);return l.parent=this,a(e)?h=e:e&&(r=e.parallel,n=e.start,o=e.time,h=e.delay,i||(i=e.canUse)),o&&(l.time=o),!1===r&&(l.parallel=!1),i&&(l.canUse=i),s(h)?this.push(l,n):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(l,n))},h)),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.cancel()}),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then(()=>{this.onTask(t),this.index++,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 Zn=$t.get("Resource"),qn={tasker:new Kn,map:{},get isComplete(){return Jn.tasker.isComplete},set(t,e){Jn.map[t]&&Zn.repeat(t),Jn.map[t]=e},get:t=>Jn.map[t],remove(t){const e=Jn.map[t];e&&(e.destroy&&e.destroy(),delete Jn.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=oe.image(s)),Jn.set(t,e),e},destroy(){Jn.map={}}},Jn=qn,$n={maxRecycled:10,recycledList:[],patternTasker:new Kn,get(t){let e=qn.get(t.url);return e||qn.set(t.url,e=oe.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||Qn.recycledList.push(t)})},clearRecycled(){const t=Qn.recycledList;t.length>Qn.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&qn.remove(t.url)),t.length=0)},hasAlphaPixel:t=>Xn.alphaPixelTypes.some(e=>Qn.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:"+Xn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Xn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){Qn.recycledList=[]}},Qn=$n,{IMAGE:tr,create:er}=x;class ir{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=er(tr),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}$n.isFormat("svg",t)&&(this.isSVG=!0),$n.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,e){if(!this.loading){this.loading=!0;const{crossOrigin:t}=this.config;qn.tasker.add(()=>_e(this,void 0,void 0,function*(){return yield y.origin.loadImage(this.url,s(t)?y.image.crossOrigin:t,this).then(t=>this.setView(t)).catch(t=>{this.error=t,this.onComplete(!1)})}))}return 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=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onComplete(t){let e;this.waitComplete.forEach((i,s)=>{e=s%2,i&&(t?e||i(this):e&&i(this.error))}),this.waitComplete.length=0,this.loading=!1}getFull(t){return this.view}getCanvas(t,e,i,s,n,r,o){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 a=y.image.resize(this.view,t,e,n,r,void 0,o,i,s);return this.cache=this.use>1?{data:a,params:arguments}:null,a}getPattern(t,e,i,s){const n=y.canvas.createPattern(t,e);return y.image.setPatternTransform(n,i,s),n}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function sr(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function nr(t,e){return Object.getOwnPropertyDescriptor(t,e)}function rr(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function or(t,e){return(i,s)=>hr(i,s,t,e&&e(s))}function ar(t){return t}function hr(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};sr(t,e,Object.assign(n,s||{})),Ar(t,e,i)}function lr(t){return or(t)}function dr(t,e){return or(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function cr(t,e){return or(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function ur(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),mr(this))}}))}function pr(t,e){return or(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function gr(t,e){return or(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function _r(t,e){return or(t,t=>({set(i){this.__setAttr(t,i,e)&&mr(this)}}))}function fr(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&(mr(this),this.__.__removeNaturalSize())}}))}function mr(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function yr(t){return or(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),mr(this)}}))}const vr=_r;function xr(t,e){return or(t,t=>({set(i){this.__setAttr(t,i)&&(wr(this),e&&(this.__.__useStroke=!0))}}))}function wr(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&mr(t)}const Er=xr;function br(t){return or(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function kr(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Sr(t){return or(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;p.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Br(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Pr(this)}}))}function Tr(t){return or(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Lr(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Lr(this,t,e,i),this.mask&&Pr(this)}}))}function Pr(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Lr(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||mr(t))}function Rr(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Cr(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function Or(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Mr(t){return or(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===$t.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function Dr(t){return or(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Ir(t){return(e,i)=>{sr(e,"__DataProcessor",{get:()=>t})}}function Ar(t,e,i){const n=t.__DataProcessor.prototype,r="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=rr(e,i);if(s(i))a.get=function(){return this[r]};else if("function"==typeof i)a.get=function(){const t=this[r];return null==t?i(this.__leaf):t};else if(d(i)){const t=u(i);a.get=function(){const e=this[r];return null==e?this[r]=t?{}:p.clone(i):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[r];if(null==t){const t=this,e=t.__naturalWidth,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&s.children.length?s.boxBounds.width:i}return t}:"height"===e&&(a.get=function(){const t=this[r];if(null==t){const t=this,e=t.__naturalHeight,s=t.__leaf;return!i||s.pathInputed?s.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&s.children.length?s.boxBounds.height:i}return t});let l,c=n;for(;!l&&c;)l=nr(c,e),c=c.__proto__;l&&l.set&&(a.set=l.set),n[o]&&(a.set=n[o],delete n[o]),sr(n,e,a)}const Wr=new $t("rewrite"),Fr=[],zr=["destroy","constructor"];function Ur(t){return(e,i)=>{Fr.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function Hr(){return t=>{Nr()}}function Nr(t){Fr.length&&(Fr.forEach(e=>{t&&Wr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Fr.length=0)}function Yr(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(zr.includes(s)||e&&e.includes(s)))if(t.prototype){nr(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Xr(){return t=>{he.register(t)}}function Vr(){return t=>{ce.register(t)}}setTimeout(()=>Nr(!0));const{copy:jr,toInnerPoint:Gr,toOuterPoint:Kr,scaleOfOuter:Zr,rotateOfOuter:qr,skewOfOuter:Jr,multiplyParent:$r,divideParent:Qr,getLayout:to}=$,eo={},{round:io}=Math,so={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),oo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)ro(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++)ao(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&ao(t),t.__updateChange()},updateAllChange(t){if(lo(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)ho(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,r){s||(s=t.__nowWorld),t.__worldFlipped||y.fullImageShadow?e.copyWorldByReset(i,s,t.__nowWorld,n,r):e.copyWorldToInner(i,s,t.__layout.renderBounds,n)},moveWorld(t,e,i=0,s,n){const r=d(e)?Object.assign({},e):{x:e,y:i};s?Kr(t.localTransform,r,r,!0):t.parent&&Gr(t.parent.scrollWorldTransform,r,r,!0),no.moveLocal(t,r.x,r.y,n)},moveLocal(t,e,i=0,s){d(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=io(e),i=io(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,r){no.zoomOfLocal(t,co(t,e),i,s,n,r)},zoomOfLocal(t,e,i,s=i,n,r){const o=t.__localMatrix;if(a(s)||(s&&(r=s),s=i),jr(eo,o),Zr(eo,e,i,s),no.hasHighPosition(t))no.setTransform(t,eo,n,r);else{const e=t.x+eo.e-o.e,a=t.y+eo.f-o.f;r&&!n?t.animate({x:e,y:a,scaleX:t.scaleX*i,scaleY:t.scaleY*s},r):(t.x=e,t.y=a,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){no.rotateOfLocal(t,co(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;jr(eo,n),qr(eo,e,i),no.hasHighPosition(t)?no.setTransform(t,eo,!1,s):t.set({x:t.x+eo.e-n.e,y:t.y+eo.f-n.f,rotation:W.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,r){no.skewOfLocal(t,co(t,e),i,s,n,r)},skewOfLocal(t,e,i,s=0,n,r){jr(eo,t.__localMatrix),Jr(eo,e,i,s),no.setTransform(t,eo,n,r)},transformWorld(t,e,i,s){jr(eo,t.worldTransform),$r(eo,e),t.parent&&Qr(eo,t.parent.scrollWorldTransform),no.setTransform(t,eo,i,s)},transform(t,e,i,s){jr(eo,t.localTransform),$r(eo,e),no.setTransform(t,eo,i,s)},setTransform(t,e,i,s){const n=t.__,r=n.origin&&no.getInnerOrigin(t,n.origin),o=to(e,r,n.around&&no.getInnerOrigin(t,n.around));if(no.hasOffset(t)&&(o.x-=n.offsetX,o.y-=n.offsetY),i){const e=o.scaleX/t.scaleX,i=o.scaleY/t.scaleY;if(delete o.scaleX,delete o.scaleY,r){Yt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=no.getInnerOrigin(t,n.origin);lt.move(o,r.x-s.x,r.y-s.y)}t.set(o),t.scaleResize(e,i,!1)}else t.set(o,s)},getFlipTransform(t,e){const i={a:1,b:0,c:0,d:1,e:0,f:0},s="x"===e?1:-1;return Zr(i,no.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>lt.tempToOuterOf(no.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return bt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(jr(eo,t.worldTransform),Qr(eo,e.scrollWorldTransform),i?eo:Object.assign({},eo)),drop(t,e,i,s){t.setTransform(no.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||no.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),y.requestRender(()=>no.animateMove(t,e,i))}}},no=so,{updateAllMatrix:ro,updateMatrix:oo,updateAllWorldOpacity:ao,updateAllChange:ho,updateChange:lo}=no;function co(t,e){return t.updateLayout(),t.parent?lt.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const uo={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)=>go(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>go(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>go(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 po;function go(t,e){return e||(po=0),t.__.mask&&(po=1),po<0?null:(po&&(po=-1),!0)}const{updateBounds:_o}=so,fo={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),mo(t,e))}},pushAllParent(t,e){const{keys:i}=e;if(i)for(;t.parent&&s(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++)yo(e[t],e)},updateBounds(t,e){const i=[t];yo(t,i),vo(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++)_o(s[t]);e&&e===i||_o(i)}}},{pushAllChildBranch:mo,pushAllBranchStack:yo,updateBoundsByBranchStack:vo}=fo,xo={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:wo,updateBounds:Eo}=so,{toOuterOf:bo,getPoints:ko,copy:So}=Yt,Bo="_localContentBounds",To="_worldContentBounds",Po="_worldBoxBounds",Lo="_worldStrokeBounds";class Ro{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 bo(this.contentBounds,this.leaf.__localMatrix,this[Bo]||(this[Bo]={})),this[Bo]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return bo(this.contentBounds,this.leaf.__world,this[To]||(this[To]={})),this[To]}get worldBoxBounds(){return bo(this.boxBounds,this.leaf.__world,this[Po]||(this[Po]={})),this[Po]}get worldStrokeBounds(){return bo(this.strokeBounds,this.leaf.__world,this[Lo]||(this[Lo]={})),this[Lo]}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 Eo(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,y.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 wo(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 Gt(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,r,o,a=this.getInnerBounds(t);switch(e){case"world":n=s.getWorldPoint(a),r=s.__world;break;case"local":const{scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d}=s.__;o={scaleX:t,scaleY:i,rotation:h,skewX:l,skewY:d},n=s.getLocalPointByInner(a);break;case"inner":n=a,r=$.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),r=wo(s,e,!0)}if(o||(o=$.getLayout(r)),So(o,a),lt.copy(o,n),i){const{scaleX:t,scaleY:e}=o,i=Math.abs(t),s=Math.abs(e);1===i&&1===s||(o.scaleX/=i,o.scaleY/=s,o.width*=i,o.height*=s)}return o}getLayoutPoints(t,e="world"){const{leaf:i}=this,n=ko(this.getInnerBounds(t));let r;switch(e){case"world":r=null;break;case"local":r=i.parent;break;case"inner":break;case"page":e=i.zoomLayer;default:r=e}return s(r)||n.forEach(t=>i.innerToWorld(t,null,!1,r)),n}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 Co{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&y.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&y.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&y.event.stop(this.origin)}}class Oo extends Co{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Oo.ADD="child.add",Oo.REMOVE="child.remove",Oo.CREATED="created",Oo.MOUNTED="mounted",Oo.UNMOUNTED="unmounted",Oo.DESTROY="destroy";const Mo="property.scroll";class Do extends Co{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Do.CHANGE="property.change",Do.LEAFER_CHANGE="property.leafer_change",Do.SCROLL=Mo;const Io={scrollX:Mo,scrollY:Mo};class Ao extends Co{constructor(t,e){super(t),Object.assign(this,e)}}Ao.LOAD="image.load",Ao.LOADED="image.loaded",Ao.ERROR="image.error";class Wo extends Co{static checkHas(t,e,i){"on"===i?e===Ho?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Fo)||t.hasEvent(zo)||t.hasEvent(Uo),t.__hasWorldEvent=t.hasEvent(Ho))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Fo,t),"inner"===e&&t.emit(zo,t)),t.emit(Uo,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Ho,this)}}Wo.RESIZE="bounds.resize",Wo.INNER="bounds.inner",Wo.LOCAL="bounds.local",Wo.WORLD="bounds.world";const{RESIZE:Fo,INNER:zo,LOCAL:Uo,WORLD:Ho}=Wo,No={};[Fo,zo,Uo,Ho].forEach(t=>No[t]=1);class Yo extends Co{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){d(t)?(super(Yo.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!s(this.resizingKeys[t.innerId])}}Yo.RESIZE="resize";class Xo extends Co{constructor(t,e){super(t),this.data=e}}Xo.REQUEST="watch.request",Xo.DATA="watch.data";class Vo extends Co{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Vo.REQUEST="layout.request",Vo.START="layout.start",Vo.BEFORE="layout.before",Vo.LAYOUT="layout",Vo.AFTER="layout.after",Vo.AGAIN="layout.again",Vo.END="layout.end";class jo extends Co{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}jo.REQUEST="render.request",jo.CHILD_START="render.child_start",jo.CHILD_END="render.child_end",jo.START="render.start",jo.BEFORE="render.before",jo.RENDER="render",jo.AFTER="render.after",jo.AGAIN="render.again",jo.END="render.end",jo.NEXT="render.next";class Go extends Co{}Go.START="leafer.start",Go.BEFORE_READY="leafer.before_ready",Go.READY="leafer.ready",Go.AFTER_READY="leafer.after_ready",Go.VIEW_READY="leafer.view_ready",Go.VIEW_COMPLETED="leafer.view_completed",Go.STOP="leafer.stop",Go.RESTART="leafer.restart",Go.END="leafer.end",Go.UPDATE_MODE="leafer.update_mode",Go.TRANSFORM="leafer.transform",Go.MOVE="leafer.move",Go.SCALE="leafer.scale",Go.ROTATE="leafer.rotate",Go.SKEW="leafer.skew";const{MOVE:Ko,SCALE:Zo,ROTATE:qo,SKEW:Jo}=Go,$o={x:Ko,y:Ko,scaleX:Zo,scaleY:Zo,rotation:qo,skewX:Jo,skewY:Jo},Qo={};class ta{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(l(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)l(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=ea(this,s,!0),h=r(t)?t.split(" "):t,d=n?{listener:e,once:n}:{listener:e};h.forEach(t=>{t&&(o=a[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(d):a[t]=[d],No[t]&&Wo.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=r(t)?t.split(" "):t;if(e){let t,n,r;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const o=ea(this,t);s.forEach(t=>{t&&(n=o[t],n&&(r=n.findIndex(t=>t.listener===e),r>-1&&n.splice(r,1),n.length||delete o[t],No[t]&&Wo.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):l(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=l(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):l(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 l(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));d(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&ce.has(t)&&(e=ce.get(t,{type:t,target:this,current:this}));const s=ea(this,i)[t];if(s){let n;for(let r=0,o=s.length;r<o&&!((n=s[r])&&(n.listener(e),n.once&&(this.off(t,n.listener,i),r--,o--),e&&e.isStopNow));r++);}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:n}=this,r=i&&i[t],o=n&&n[t];return!!(s(e)?r||o:e?o:r)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function ea(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:Qo)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:Qo)}}const{on:ia,on_:sa,off:na,off_:ra,once:oa,emit:aa,emitEvent:ha,hasEvent:la,destroy:da}=ta.prototype,ca={on:ia,on_:sa,off:na,off_:ra,once:oa,emit:aa,emitEvent:ha,hasEvent:la,destroyEventer:da},ua=$t.get("setAttr"),pa={__setAttr(t,e,i){if(this.leaferIsCreated){const n=this.__.__getInput(t);if(!i||o(e)||s(e)||(ua.warn(this.innerName,t,e),e=void 0),d(e)||n!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Do(Do.LEAFER_CHANGE,this,t,n,e));const i=$o[t];i&&(this.emitEvent(new Go(i,this)),this.emitEvent(new Go(Go.TRANSFORM,this)))}this.emitPropertyEvent(Do.CHANGE,t,n,e);const i=Io[t];return i&&this.emitPropertyEvent(i,t,n,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,i,s){const n=new Do(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||s(i.normalStyle[t])||(i.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:ga,multiplyParent:_a,translateInner:fa,defaultWorld:ma}=$,{toPoint:ya,tempPoint:va}=bt,xa={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;_a(this.__local||e,t?t.__scrollWorld||t.__world:ma,i,!!e.affectScaleOrRotation,n),s&&fa(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)&&(ga(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)&&(ya(i.around||i.origin,t.boxBounds,va),fa(e,-va.x,-va.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:wa,updateAllMatrix:Ea}=so,{updateBounds:ba}=fo,{toOuterOf:ka,copyAndSpread:Sa,copy:Ba}=Yt,{toBounds:Ta}=On,Pa={__updateWorldBounds(){const{__layout:t,__world:e}=this;ka(t.renderBounds,e,e),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Wo.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Wo.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(),ka(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){ka(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){ka(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Ta(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(),Ea(this),ba(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(Ea(this),ba(this,this))):wa(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Sa(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;a(i)&&i<=0?Ba(e.renderBounds,e.strokeBounds):Sa(e.renderBounds,e.boxBounds,i)}},La={__render(t,e){if(e.shape)return this.__renderShape(t,e);if(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),so.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);$t.showBounds&&$t.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:Ra}=uo,Ca={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__nowWorld=this.__getNowWorld(e),this.__worldOpacity){const i=this.__;if(i.__useDim)if(i.dim)e.dimOpacity=!0===i.dim?.2:i.dim;else{if(i.bright&&!e.topRendering)return e.topList.add(this);i.dimskip&&e.dimOpacity&&(e.dimOpacity=0)}if(i.__single&&!this.isBranchLeaf){if("path"===i.eraser)return this.__renderEraser(t,e);const s=t.getSameCanvas(!1,!0);this.__renderBranch(s,e);const n=this.__nowWorld;t.opacity=e.dimOpacity?i.opacity*e.dimOpacity:i.opacity,t.copyWorldByReset(s,n,n,i.__blendMode,!0),s.recycle(n)}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++)Ra(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++)Ra(i[s],e)||i[s].__clip(t,e)}}},Oa={},{LEAF:Ma,create:Da}=x,{stintSet:Ia}=p,{toInnerPoint:Aa,toOuterPoint:Wa,multiplyParent:Fa}=$,{toOuterOf:za}=Yt,{copy:Ua,move:Ha}=lt,{moveLocal:Na,zoomOfLocal:Ya,rotateOfLocal:Xa,skewOfLocal:Va,moveWorld:ja,zoomOfWorld:Ga,rotateOfWorld:Ka,skewOfWorld:Za,transform:qa,transformWorld:Ja,setTransform:$a,getFlipTransform:Qa,getLocalOrigin:th,getRelativeWorld:eh,drop:ih}=so;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 _}get __LayoutProcessor(){return Ro}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=Da(Ma),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Oo.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(Oo.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Oo.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(Oo.MOUNTED)):this.__emitLifeEvent(Oo.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){s(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=s(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 Fa(i,t.matrix,e,void 0,i),za(this.__layout.renderBounds,e,e),Ia(e,"half",i.half),Ia(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}=$n.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),Oa.scaleX=i,Oa.scaleY=s,Oa}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?eh(this,e):this.worldTransform,n=i?t:{};return za(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Ua(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Ua(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Aa(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Wa(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:r,y:o}=this.boxBounds;return Ha(n,-r,-o),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:r,y:o}=this.boxBounds;return Ha(n,r,o),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){$a(this,t,e,i)}transform(t,e,i){qa(this,t,e,i)}move(t,e,i){Na(this,t,e,i)}moveInner(t,e,i){ja(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Ya(this,th(this,t),e,i,s,n)}rotateOf(t,e,i){Xa(this,th(this,t),e,i)}skewOf(t,e,i,s,n){Va(this,th(this,t),e,i,s,n)}transformWorld(t,e,i){Ja(this,t,e,i)}moveWorld(t,e,i){ja(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){Ga(this,t,e,i,s,n)}rotateOfWorld(t,e){Ka(this,t,e)}skewOfWorld(t,e,i,s,n){Za(this,t,e,i,s,n)}flip(t,e){qa(this,Qa(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){return!0}__hit(t){return!0}__hitFill(t){return!0}__hitStroke(t,e){return!0}__hitPixel(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e,i){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return re.need("path")}getMotionPoint(t){return re.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){ih(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):Ar(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=_r),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Oo(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Oo.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},t.Leaf=ge([Yr(pa),Yr(xa),Yr(Pa),Yr(ca),Yr(La)],t.Leaf);const{setListWithFn:sh}=Yt,{sort:nh}=fo,{localBoxBounds:rh,localStrokeBounds:oh,localRenderBounds:ah,maskLocalBoxBounds:hh,maskLocalStrokeBounds:lh,maskLocalRenderBounds:dh}=uo,ch=new $t("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){sh(e||this.__layout.boxBounds,this.children,this.__hasMask?hh:rh)}__updateStrokeBounds(t){sh(t||this.__layout.strokeBounds,this.children,this.__hasMask?lh:oh)}__updateRenderBounds(t){sh(t||this.__layout.renderBounds,this.children,this.__hasMask?dh:ah)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let i=0,s=e.length;i<s;i++)e[i].__tempNumber=i,e[i].__.zIndex&&(t=!0);e.sort(nh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return ch.warn("add self or destroyed");const i=s(e);if(!t.__){if(l(t))return t.forEach(t=>{this.add(t,e),i||e++});t=he.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 n=t.__layout;n.boxChanged||n.boxChange(),n.matrixChanged||n.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(Oo.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Oo.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)):s(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(Oo.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Oo.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Oo(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}},t.Branch=ge([Yr(Ca)],t.Branch);class uh{get length(){return this.list.length}constructor(t){this.reset(),t&&(l(t)?this.addList(t):this.add(t))}has(t){return t&&!s(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return s(e)?-1:e}add(t){const{list:e,keys:i}=this;s(i[t.innerId])&&(e.push(t),i[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:i}=this;if(s(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 n=0,r=e.length;n<r;n++)s(i)?e[n].innerId===t.innerId&&(i=n,delete this.keys[t.innerId]):this.keys[e[n].innerId]=n-1;s(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 uh;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 ph{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(l(t)?this.addList(t):this.add(t))}has(t){return!s(this.keys[t.innerId])}without(t){return s(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 gh extends Le{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=y.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}}Yn(OffscreenCanvasRenderingContext2D.prototype),Yn(Path2D.prototype);const{mineType:_h}=Xn;function fh(t,e){y.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:_h(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:_h(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",y.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()})},y.canvas=oe.canvas(),y.conicGradientSupport=!!y.canvas.context.createConicGradient}Object.assign(oe,{canvas:(t,e)=>new gh(t,e),image:t=>new ir(t)}),y.name="web",y.isWorker=!0,y.backgrounder=!0,y.requestRender=function(t){requestAnimationFrame(t)},sr(y,"devicePixelRatio",{get:()=>1});const{userAgent:mh}=navigator;mh.indexOf("Firefox")>-1?(y.conicGradientRotate90=!0,y.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(y.fullImageShadow=!0),mh.indexOf("Windows")>-1?(y.os="Windows",y.intWheelDeltaY=!0):mh.indexOf("Mac")>-1?y.os="Mac":mh.indexOf("Linux")>-1&&(y.os="Linux");class yh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new uh;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 uh,this.target=t,e&&(this.config=p.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(jo.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===Oo.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 Xo(Xo.DATA,{updatedList:this.updatedList})),this.__updatedList=new uh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Do.CHANGE,this.__onAttrChange,this],[[Oo.ADD,Oo.REMOVE],this.__onChildEvent,this],[Xo.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:vh,updateBounds:xh,updateChange:wh}=so,{pushAllChildBranch:Eh,pushAllParent:bh}=fo;const{worldBounds:kh}=uo;class Sh{constructor(t){this.updatedBounds=new Gt,this.beforeBounds=new Gt,this.afterBounds=new Gt,l(t)&&(t=new uh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,kh)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,kh),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:Bh,updateAllChange:Th}=so,Ph=$t.get("Layouter");class Lh{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new ph,this.target=t,e&&(this.config=p.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(Vo.START),this.layoutOnce(),t.emitEvent(new Vo(Vo.END,this.layoutedBlocks,this.times))}catch(t){Ph.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Ph.warn("layouting"):this.times>3?Ph.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Xo.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=ie.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:o}=Vo,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Vo(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?(vh(t,!0),e.add(t),t.isBranch&&Eh(t,e),bh(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),bh(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||xh(s[t])}xh(i)}})}(this.__levelList),function(t){t.list.forEach(wh)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Vo(r,a,this.times)),i.emitEvent(new Vo(o,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,ie.end(e)}fullLayout(){const t=ie.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=Vo,r=this.getBlocks(new uh(e));e.emitEvent(new Vo(i,r,this.times)),Lh.fullLayout(e),r.forEach(t=>{t.setAfter()}),e.emitEvent(new Vo(s,r,this.times)),e.emitEvent(new Vo(n,r,this.times)),this.addBlocks(r),ie.end(t)}static fullLayout(t){Bh(t,!0),t.isBranch?fo.updateBounds(t):so.updateBounds(t),Th(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Sh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Sh(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_([[Vo.REQUEST,this.layout,this],[Vo.AGAIN,this.layoutAgain,this],[Xo.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Rh=$t.get("Renderer");class Ch{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=p.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(Vo.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(jo.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(jo.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(jo.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new Gt,Rh.log(e.innerName,"---\x3e");try{this.emitRender(jo.START),this.renderOnce(t),this.emitRender(jo.END,this.totalBounds),$n.clearRecycled()}catch(t){this.rendering=!1,Rh.error(t)}Rh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Rh.warn("rendering");if(this.times>3)return Rh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new Gt,this.renderOptions={},t)this.emitRender(jo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(jo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(jo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(jo.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=ie.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new Gt(s);i.save(),s.spread(Ch.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),ie.end(e)}fullRender(){const t=ie.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),ie.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),$t.showRepaint&&$t.drawRepaint(i,t),y.render(this.target,i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new Gt;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 y.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()};y.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new Gt(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 Gt(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||Rh.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new jo(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[jo.REQUEST,this.update,this],[Vo.END,this.__onLayoutEnd,this],[jo.AGAIN,this.renderAgain,this],[Yo.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Ch.clipSpread=10;const{hitRadiusPoint:Oh}=Yt;class Mh{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,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new uh(i.findList),i.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,a=this.getBestMatchLeaf(o,i.bottomList,n,!!i.findList),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:o.length?this.getThroughPath(o):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 uh;if(t.length){let e;const{x:s,y:r}=this.point,o={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=t.length;s<r;s++)if(e=t[s],(i||so.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&so.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=>so.worldHittable(t))}getPath(t){const e=new uh,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 uh;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 uh,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,r;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(r=s.list[t],!n||!n.has(r));t++)e.add(r)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let r=t.length-1;r>-1;r--)if(i=t[r],i.__.visible&&(!e||i.__.mask))if(s=!!i.__.hitRadius||Oh(i.__world,n),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&i.__.__clipAfterFill&&!i.__hitWorld(n))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)}}else s&&this.hitChild(i,n)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:r}=s;for(let s=0,o=r.length;s<o;s++)if(i=r[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 Dh{constructor(t,e){this.config={},e&&(this.config=p.default(e,this.config)),this.picker=new Mh(this.target=t,this),this.finder=oe.finder&&oe.finder()}getByPoint(t,e,i){const{target:s,picker:n}=this;return y.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):re.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Ih(t){return or(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Ah(t){return or(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Wh(){return(t,e)=>{const i="_"+e;sr(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(oe,{watcher:(t,e)=>new yh(t,e),layouter:(t,e)=>new Lh(t,e),renderer:(t,e,i)=>new Ch(t,e,i),selector:(t,e)=>new Dh(t,e)}),y.layout=Lh.fullLayout,y.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new uh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Fh={},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}},Uh={number:(t,e)=>d(t)?"percent"===t.type?t.value*e:t.value:t},Hh={},Nh={},Yh={},Xh={},Vh={},jh={apply(){re.need("filter")}},Gh={},Kh={setStyleName:()=>re.need("state"),set:()=>re.need("state")},Zh={list:{},register(t,e){Zh.list[t]=e},get:t=>Zh.list[t]},{parse:qh,objectToCanvasData:Jh}=$i,{stintSet:$h}=p,{hasTransparent:Qh}=zh,tl={},el=$t.get("UIData");class il extends _{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,el.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,el.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),r(t)||!t?($h(this,"__isTransparentFill",Qh(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):d(t)&&this.__setPaint("fill",t)}setStroke(t){r(t)||!t?($h(this,"__isTransparentStroke",Qh(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):d(t)&&this.__setPaint("stroke",t)}setPath(t){const e=r(t);e||t&&d(t[0])?(this.__setInput("path",t),this._path=e?qh(t):Jh(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){sl(this,"shadow",t)}setInnerShadow(t){sl(this,"innerShadow",t)}setFilter(t){sl(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Nh.compute("fill",this.__leaf),e&&Nh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),s(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(),l(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=tl)):(this.__isStrokes=!0,this._stroke||(this._stroke=tl))}__removePaint(t,e){e&&this.__removeInput(t),Yh.recycleImage(t,this),"fill"===t?($h(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):($h(this,"__isAlphaPixelStroke",void 0),$h(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function sl(t,e,i){t.__setInput(e,i),l(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 nl extends il{}class rl extends nl{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 ol extends nl{__getInputData(t,e){const i=super.__getInputData(t,e);return Pe.forEach(t=>delete i[t]),i}}class al extends rl{}class hl extends il{get __usePathBox(){return this.points||this.__pathInputed}}class ll extends il{get __boxStroke(){return!this.__pathInputed}}class dl extends il{get __boxStroke(){return!this.__pathInputed}}class cl extends hl{}class ul extends il{}class pl extends il{get __pathInputed(){return 2}}class gl extends nl{}const _l={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class fl extends il{get __useNaturalRatio(){return!1}setFontWeight(t){r(t)?(this.__setInput("fontWeight",t),t=_l[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=he.get("Rect",0);const n=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=n.boxBounds),i.set(t),r.strokeChanged&&n.strokeChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class ml extends ll{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 yl extends ll{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:vl,add:xl}=T,wl={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:n}=i,r=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),r&&(t=vl(t,r.__layout.strokeSpread=r.__updateStrokeSpread()),e=Math.max(e,r.__layout.strokeBoxSpread)),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:n,filter:r,renderSpread:o}=this.__,{strokeSpread:a}=this.__layout,h=this.__box;e&&(t=Vh.getShadowRenderSpread(this,e)),s&&(t=vl(t,s)),r&&(t=xl(t,jh.getSpread(r))),o&&(t=xl(t,o)),a&&(t=xl(t,a));let l=t;return i&&(l=vl(l,Vh.getInnerShadowSpread(this,i))),n&&(l=vl(l,n)),this.__layout.renderShapeSpread=l,h?vl(h.__updateRenderSpread(),t):t}},{stintSet:El}=p,bl={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);El(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),El(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;El(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!Vh.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(l(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),El(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){kl(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:n,stroke:r,__drawAfterFill:o,__fillAfterStroke:a,__isFastShadow:h}=s;if(this.__drawRenderPath(t),s.__useEffect&&!h){const h=Nh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&Vh.shadow(this,t,h),a&&(s.__isStrokes?Nh.strokes(r,this,t,e):Nh.stroke(r,this,t,e)),n&&(s.__isFills?Nh.fills(n,this,t,e):Nh.fill(n,this,t,e)),o&&this.__drawAfterFill(t,e),d&&Vh.innerShadow(this,t,h),r&&!a&&(s.__isStrokes?Nh.strokes(r,this,t,e):Nh.stroke(r,this,t,e)),c&&jh.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?Nh.strokes(r,this,t,e):Nh.stroke(r,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?Nh.fills(n,this,t,e):Nh.fill(n,this,t,e)),h&&t.restore(),o&&this.__drawAfterFill(t,e),r&&!a&&(s.__isStrokes?Nh.strokes(r,this,t,e):Nh.stroke(r,this,t,e))}}else s.__pathInputed?kl(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?Nh.fills(s,this,t,e):Nh.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?Nh.strokes(n,this,t,e):Nh.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 kl(t,e,i){const{fill:s,stroke:n,__drawAfterFill:r,__fillAfterStroke:o}=t.__;t.__drawRenderPath(e),o&&Nh.stroke(n,t,e,i),s&&Nh.fill(s,t,e,i),r&&t.__drawAfterFill(e,i),n&&!o&&Nh.stroke(n,t,e,i)}const Sl={__drawFast(t,e){let{x:i,y:s,width:n,height:r}=this.__layout.boxBounds;const{fill:o,stroke:a,__drawAfterFill:h}=this.__;if(o&&(t.fillStyle=o,t.fillRect(i,s,n,r)),h&&this.__drawAfterFill(t,e),a){const{strokeAlign:o,__strokeWidth:h}=this.__;if(!h)return;t.setStroke(a,h,this.__);const l=h/2;switch(o){case"center":t.strokeRect(0,0,n,r);break;case"inside":n-=h,r-=h,n<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+l,s+l,n,r),t.restore()):t.strokeRect(i+l,s+l,n,r);break;case"outside":t.strokeRect(i-l,s-l,n+h,r+h)}}}};var Bl,Tl;t.UI=Bl=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){W.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 Hn.set(this.path=t||[]),t||this.__drawPathByBox(Hn),Hn}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 re.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return re.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(Hn.set(i=[]),this.__drawPathByBox(Hn)),t?$i.toCanvasData(i,!0):i}getPathString(t,e,i){return $i.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Gh.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?zn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Hh.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)}__drawPathByData(t,e){e?Qs.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:n}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,n,a(r)?[r]:r)}else t.rect(e,i,s,n)}drawImagePlaceholder(t,e,i){Nh.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),re.need("animate")}killAnimate(t,e){}export(t,e){return re.need("export")}syncExport(t,e){return re.need("export")}clone(t){const e=p.clone(this.toJSON());return t&&Object.assign(e,t),Bl.one(e)}static one(t,e,i,s,n){return he.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Xr()(this)}static registerData(t){Ir(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}},ge([Ir(il)],t.UI.prototype,"__",void 0),ge([Wh()],t.UI.prototype,"zoomLayer",void 0),ge([lr("")],t.UI.prototype,"id",void 0),ge([lr("")],t.UI.prototype,"name",void 0),ge([lr("")],t.UI.prototype,"className",void 0),ge([kr("pass-through")],t.UI.prototype,"blendMode",void 0),ge([Br(1)],t.UI.prototype,"opacity",void 0),ge([Tr(!0)],t.UI.prototype,"visible",void 0),ge([kr(!1)],t.UI.prototype,"locked",void 0),ge([Sr(!1)],t.UI.prototype,"dim",void 0),ge([Sr(!1)],t.UI.prototype,"dimskip",void 0),ge([Rr(0)],t.UI.prototype,"zIndex",void 0),ge([Cr(!1)],t.UI.prototype,"mask",void 0),ge([Or(!1)],t.UI.prototype,"eraser",void 0),ge([dr(0,!0)],t.UI.prototype,"x",void 0),ge([dr(0,!0)],t.UI.prototype,"y",void 0),ge([_r(100,!0)],t.UI.prototype,"width",void 0),ge([_r(100,!0)],t.UI.prototype,"height",void 0),ge([pr(1,!0)],t.UI.prototype,"scaleX",void 0),ge([pr(1,!0)],t.UI.prototype,"scaleY",void 0),ge([gr(0,!0)],t.UI.prototype,"rotation",void 0),ge([gr(0,!0)],t.UI.prototype,"skewX",void 0),ge([gr(0,!0)],t.UI.prototype,"skewY",void 0),ge([dr(0,!0)],t.UI.prototype,"offsetX",void 0),ge([dr(0,!0)],t.UI.prototype,"offsetY",void 0),ge([cr(0,!0)],t.UI.prototype,"scrollX",void 0),ge([cr(0,!0)],t.UI.prototype,"scrollY",void 0),ge([ur()],t.UI.prototype,"origin",void 0),ge([ur()],t.UI.prototype,"around",void 0),ge([lr(!1)],t.UI.prototype,"lazy",void 0),ge([fr(1)],t.UI.prototype,"pixelRatio",void 0),ge([br(0)],t.UI.prototype,"renderSpread",void 0),ge([yr()],t.UI.prototype,"path",void 0),ge([vr()],t.UI.prototype,"windingRule",void 0),ge([vr(!0)],t.UI.prototype,"closed",void 0),ge([_r(0)],t.UI.prototype,"padding",void 0),ge([_r(!1)],t.UI.prototype,"lockRatio",void 0),ge([_r()],t.UI.prototype,"widthRange",void 0),ge([_r()],t.UI.prototype,"heightRange",void 0),ge([lr(!1)],t.UI.prototype,"draggable",void 0),ge([lr()],t.UI.prototype,"dragBounds",void 0),ge([lr("auto")],t.UI.prototype,"dragBoundsType",void 0),ge([lr(!1)],t.UI.prototype,"editable",void 0),ge([Mr(!0)],t.UI.prototype,"hittable",void 0),ge([Mr("path")],t.UI.prototype,"hitFill",void 0),ge([Er("path")],t.UI.prototype,"hitStroke",void 0),ge([Mr(!1)],t.UI.prototype,"hitBox",void 0),ge([Mr(!0)],t.UI.prototype,"hitChildren",void 0),ge([Mr(!0)],t.UI.prototype,"hitSelf",void 0),ge([Mr()],t.UI.prototype,"hitRadius",void 0),ge([Dr("")],t.UI.prototype,"cursor",void 0),ge([kr()],t.UI.prototype,"fill",void 0),ge([Er(void 0,!0)],t.UI.prototype,"stroke",void 0),ge([Er("inside")],t.UI.prototype,"strokeAlign",void 0),ge([Er(1,!0)],t.UI.prototype,"strokeWidth",void 0),ge([Er(!1)],t.UI.prototype,"strokeWidthFixed",void 0),ge([Er("none")],t.UI.prototype,"strokeCap",void 0),ge([Er("miter")],t.UI.prototype,"strokeJoin",void 0),ge([Er()],t.UI.prototype,"dashPattern",void 0),ge([Er(0)],t.UI.prototype,"dashOffset",void 0),ge([Er(10)],t.UI.prototype,"miterLimit",void 0),ge([vr(0)],t.UI.prototype,"cornerRadius",void 0),ge([vr()],t.UI.prototype,"cornerSmoothing",void 0),ge([Ih()],t.UI.prototype,"shadow",void 0),ge([Ih()],t.UI.prototype,"innerShadow",void 0),ge([Ih()],t.UI.prototype,"blur",void 0),ge([Ih()],t.UI.prototype,"backgroundBlur",void 0),ge([Ih()],t.UI.prototype,"grayscale",void 0),ge([Ih()],t.UI.prototype,"filter",void 0),ge([kr()],t.UI.prototype,"placeholderColor",void 0),ge([lr(100)],t.UI.prototype,"placeholderDelay",void 0),ge([lr({})],t.UI.prototype,"data",void 0),ge([Ur(t.Leaf.prototype.reset)],t.UI.prototype,"reset",null),t.UI=Bl=ge([Yr(wl),Yr(bl),Hr()],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(){}},ge([Ir(nl)],t.Group.prototype,"__",void 0),ge([_r(0)],t.Group.prototype,"width",void 0),ge([_r(0)],t.Group.prototype,"height",void 0),t.Group=ge([Yr(t.Branch),Xr()],t.Group);const Pl=$t.get("Leafer");t.Leafer=Tl=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&&qn.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||{x:0,y:0,width:0,height:0}}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Tl.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,p.assign(s,t));const n=this.canvas=oe.canvas(s);this.__controllers.push(this.renderer=oe.renderer(this,n,s),this.watcher=oe.watcher(this,s),this.layouter=oe.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),this.view=n.view,e||(this.selector=oe.selector(this),this.interaction=oe.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=oe.hitCanvasManager()),this.canvasManager=new pe,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))),xo.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(Go.RESTART):this.emitLeafer(Go.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(Go.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=p.copyAttrs({},t,Pe);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new Gt(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=p.copyAttrs({},this.canvas,Pe);e.resize(t),this.updateLazyBounds(),this.__onResize(new Yo(t,i))}__onResize(t){this.emitEvent(t),p.copyAttrs(this.__,t,Pe),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 Zt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Pe.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(Go.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Pe.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=p.copyAttrs({},s,Pe);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(Go.BEFORE_READY),this.emitLeafer(Go.READY),this.emitLeafer(Go.AFTER_READY),xo.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Go.VIEW_READY),xo.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:n,pixelRatio:r}=this;const o="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,o.x+o.width)),i||(n=Math.max(1,o.y+o.height)),this.__doResize({width:s,height:n,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){xo.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(Go.VIEW_COMPLETED),xo.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 re.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 Go(t,this))}__listenEvents(){const t=ie.start("FirstCreate "+this.innerName);this.once([[Go.START,()=>ie.end(t)],[Vo.START,this.updateLazyBounds,this],[jo.START,this.__onCreated,this],[jo.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Xo.DATA,this.__onWatchData,this],[Vo.END,this.__onLayoutEnd,this],[jo.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Tl.list.remove(this);try{this.stop(),this.emitLeafer(Go.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.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout(()=>{$n.clearRecycled()},100)}catch(t){Pl.error(t)}}};t?e():setTimeout(e)}},t.Leafer.list=new uh,ge([Ir(ol)],t.Leafer.prototype,"__",void 0),ge([_r()],t.Leafer.prototype,"pixelRatio",void 0),ge([lr("normal")],t.Leafer.prototype,"mode",void 0),t.Leafer=Tl=ge([Xr()],t.Leafer),t.Rect=class extends t.UI{get __tag(){return"Rect"}},ge([Ir(ll)],t.Rect.prototype,"__",void 0),t.Rect=ge([Yr(Sl),Hr(),Xr()],t.Rect);const{add:Ll,includes:Rl,scroll:Cl}=Yt,Ol=t.Rect.prototype,Ml=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:r}=s,{overflow:o}=i,a=s.childrenRenderBounds||(s.childrenRenderBounds={x:0,y:0,width:0,height:0});super.__updateRenderBounds(a),(e=o.includes("scroll"))&&(Ll(a,r),Cl(a,i)),this.__updateRectRenderBounds(),t=!Rl(r,a),t&&"show"===o&&Ll(n,a)}else this.__updateRectRenderBounds();p.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))}},ge([Ir(rl)],t.Box.prototype,"__",void 0),ge([_r(100)],t.Box.prototype,"width",void 0),ge([_r(100)],t.Box.prototype,"height",void 0),ge([lr(!1)],t.Box.prototype,"resizeChildren",void 0),ge([br("show")],t.Box.prototype,"overflow",void 0),ge([Ur(Ol.__updateStrokeSpread)],t.Box.prototype,"__updateStrokeSpread",null),ge([Ur(Ol.__updateRenderSpread)],t.Box.prototype,"__updateRectRenderSpread",null),ge([Ur(Ol.__updateBoxBounds)],t.Box.prototype,"__updateRectBoxBounds",null),ge([Ur(Ol.__updateStrokeBounds)],t.Box.prototype,"__updateStrokeBounds",null),ge([Ur(Ol.__updateRenderBounds)],t.Box.prototype,"__updateRectRenderBounds",null),ge([Ur(Ol.__updateChange)],t.Box.prototype,"__updateRectChange",null),ge([Ur(Ol.__render)],t.Box.prototype,"__renderRect",null),ge([Ur(Ml.__render)],t.Box.prototype,"__renderGroup",null),t.Box=ge([Hr(),Xr()],t.Box),t.Frame=class extends t.Box{get __tag(){return"Frame"}get isFrame(){return!0}},ge([Ir(al)],t.Frame.prototype,"__",void 0),ge([kr("#FFFFFF")],t.Frame.prototype,"fill",void 0),ge([br("hide")],t.Frame.prototype,"overflow",void 0),t.Frame=ge([Xr()],t.Frame);const{moveTo:Dl,closePath:Il,ellipse:Al}=ws;t.Ellipse=class extends t.UI{get __tag(){return"Ellipse"}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:n}=this.__,r=t/2,o=e/2,a=this.__.path=[];i?(s||n?(i<1&&Al(a,r,o,r*i,o*i,0,s,n,!1),Al(a,r,o,r,o,0,n,s,!0),i<1&&Il(a)):(i<1&&(Al(a,r,o,r*i,o*i),Dl(a,t,o)),Al(a,r,o,r,o,0,360,0,!0)),y.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||n?(Dl(a,r,o),Al(a,r,o,r,o,0,s,n,!1),Il(a)):Al(a,r,o,r,o)}},ge([Ir(dl)],t.Ellipse.prototype,"__",void 0),ge([vr(0)],t.Ellipse.prototype,"innerRadius",void 0),ge([vr(0)],t.Ellipse.prototype,"startAngle",void 0),ge([vr(0)],t.Ellipse.prototype,"endAngle",void 0),t.Ellipse=ge([Xr()],t.Ellipse);const{sin:Wl,cos:Fl,PI:zl}=Math,{moveTo:Ul,lineTo:Hl,closePath:Nl,drawPoints:Yl}=ws;t.Polygon=class extends t.UI{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)Yl(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,r=i/2,o=s/2;Ul(e,r,0);for(let t=1;t<n;t++)Hl(e,r+r*Wl(2*t*zl/n),o-o*Fl(2*t*zl/n));Nl(e)}}},ge([Ir(cl)],t.Polygon.prototype,"__",void 0),ge([vr(3)],t.Polygon.prototype,"sides",void 0),ge([vr()],t.Polygon.prototype,"points",void 0),ge([vr(0)],t.Polygon.prototype,"curve",void 0),t.Polygon=ge([Hr(),Xr()],t.Polygon);const{sin:Xl,cos:Vl,PI:jl}=Math,{moveTo:Gl,lineTo:Kl,closePath:Zl}=ws;t.Star=class extends t.UI{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,r=e/2,o=this.__.path=[];Gl(o,n,0);for(let t=1;t<2*i;t++)Kl(o,n+(t%2==0?n:n*s)*Xl(t*jl/i),r-(t%2==0?r:r*s)*Vl(t*jl/i));Zl(o)}},ge([Ir(ul)],t.Star.prototype,"__",void 0),ge([vr(5)],t.Star.prototype,"corners",void 0),ge([vr(.382)],t.Star.prototype,"innerRadius",void 0),t.Star=ge([Xr()],t.Star);const{moveTo:ql,lineTo:Jl,drawPoints:$l}=ws,{rotate:Ql,getAngle:td,getDistance:ed,defaultPoint:id}=lt;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&&Ql(i,e),i}set toPoint(t){this.width=ed(id,t),this.rotation=td(id,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?$l(e,t.points,t.curve,t.closed):(ql(e,0,0),Jl(e,this.width,0))}},ge([Ir(hl)],t.Line.prototype,"__",void 0),ge([xr("center")],t.Line.prototype,"strokeAlign",void 0),ge([_r(0)],t.Line.prototype,"height",void 0),ge([vr()],t.Line.prototype,"points",void 0),ge([vr(0)],t.Line.prototype,"curve",void 0),ge([vr(!1)],t.Line.prototype,"closed",void 0),t.Line=ge([Xr()],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 l(t)&&t[0].image}},ge([Ir(ml)],t.Image.prototype,"__",void 0),ge([_r("")],t.Image.prototype,"url",void 0),t.Image=ge([Xr()],t.Image);const sd=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=oe.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new ir({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Ao(Ao.LOADED,{image:t}))})}draw(t,e,i,s){const n=new ft(t.worldTransform).invert(),r=new ft;e&&r.translate(e.x,e.y),i&&(a(i)?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),n.multiplyParent(r),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()}},ge([Ir(yl)],t.Canvas.prototype,"__",void 0),ge([Ah(100)],t.Canvas.prototype,"width",void 0),ge([Ah(100)],t.Canvas.prototype,"height",void 0),ge([Ah(1)],t.Canvas.prototype,"pixelRatio",void 0),ge([Ah(!0)],t.Canvas.prototype,"smooth",void 0),ge([lr(!1)],t.Canvas.prototype,"safeResize",void 0),ge([Ah()],t.Canvas.prototype,"contextSettings",void 0),t.Canvas=ge([Xr()],t.Canvas);const{copyAndSpread:nd,includes:rd,spread:od,setList:ad}=Yt,{stintSet:hd}=p;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:r,italic:o,textCase:a,textOverflow:h,padding:l,width:d,height:c}=t;t.__lineHeight=Uh.number(e,n),t.__letterSpacing=Uh.number(i,n),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*n)/2,t.__font=`${o?"italic ":""}${"small-caps"===a?"small-caps ":""}${"normal"!==r?r+" ":""}${n||12}px ${s||"caption"}`,hd(t,"__padding",l&&W.fourNumber(l)),hd(t,"__clipText","show"!==h&&!t.__autoSize),hd(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=Fh.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:r,__autoHeight:o}=t;this.__updateTextDrawData();const{bounds:a}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=a,t.__lineHeight<i&&od(a,i/2),r||o){if(h.x=r?a.x:0,h.y=o?a.y:0,h.width=r?a.width:t.width,h.height=o?a.height:t.height,n){const[e,i,s,n]=t.__padding;r&&(h.x-=n,h.width+=i+n),o&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),p.stintSet(this,"isOverflow",!rd(h,a)),this.isOverflow?(ad(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;nd(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()}},ge([Ir(fl)],t.Text.prototype,"__",void 0),ge([_r(0)],t.Text.prototype,"width",void 0),ge([_r(0)],t.Text.prototype,"height",void 0),ge([kr()],t.Text.prototype,"boxStyle",void 0),ge([lr(!1)],t.Text.prototype,"resizeFontSize",void 0),ge([kr("#000000")],t.Text.prototype,"fill",void 0),ge([xr("outside")],t.Text.prototype,"strokeAlign",void 0),ge([Mr("all")],t.Text.prototype,"hitFill",void 0),ge([_r("")],t.Text.prototype,"text",void 0),ge([_r("")],t.Text.prototype,"placeholder",void 0),ge([_r("caption")],t.Text.prototype,"fontFamily",void 0),ge([_r(12)],t.Text.prototype,"fontSize",void 0),ge([_r("normal")],t.Text.prototype,"fontWeight",void 0),ge([_r(!1)],t.Text.prototype,"italic",void 0),ge([_r("none")],t.Text.prototype,"textCase",void 0),ge([_r("none")],t.Text.prototype,"textDecoration",void 0),ge([_r(0)],t.Text.prototype,"letterSpacing",void 0),ge([_r({type:"percent",value:1.5})],t.Text.prototype,"lineHeight",void 0),ge([_r(0)],t.Text.prototype,"paraIndent",void 0),ge([_r(0)],t.Text.prototype,"paraSpacing",void 0),ge([_r("x")],t.Text.prototype,"writingMode",void 0),ge([_r("left")],t.Text.prototype,"textAlign",void 0),ge([_r("top")],t.Text.prototype,"verticalAlign",void 0),ge([_r(!0)],t.Text.prototype,"autoSizeAlign",void 0),ge([_r("normal")],t.Text.prototype,"textWrap",void 0),ge([_r("show")],t.Text.prototype,"textOverflow",void 0),ge([kr(!1)],t.Text.prototype,"textEditing",void 0),t.Text=ge([Xr()],t.Text),t.Path=class extends t.UI{get __tag(){return"Path"}},ge([Ir(pl)],t.Path.prototype,"__",void 0),ge([xr("center")],t.Path.prototype,"strokeAlign",void 0),t.Path=ge([Xr()],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,r){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,r,o,a){return this}arc(t,e,i,s,n,r){return this}arcTo(t,e,i,s,n){return this}drawEllipse(t,e,i,s,n,r,o,a){return this}drawArc(t,e,i,s,n,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}},ge([Ir(gl)],t.Pen.prototype,"__",void 0),ge([(t,e)=>{sr(t,e,{get(){return this.__path}})}],t.Pen.prototype,"path",void 0),t.Pen=ge([Yr(Fs,["set","path","paint"]),Xr()],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&&oe.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),s(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&&p.assign(e,t),this.autoLayout&&p.copyAttrs(e,this,Pe),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Vo.END,this.__onReady,this],[jo.START,this.__onCreated,this],[jo.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(jo.END,this.__onChildRenderEnd,this))}},t.App=ge([Xr()],t.App);const ld={},dd={isHoldSpaceKey:()=>dd.isHold("Space"),isHold:t=>ld[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){ld[t]||(ld[t]=!0)},setUpCode(t){ld[t]=!1}},cd={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 ud extends Co{get spaceKey(){return dd.isHoldSpaceKey()}get left(){return cd.left(this)}get right(){return cd.right(this)}get middle(){return cd.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return dd.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){ce.changeName(t,e)}}const{min:pd,max:gd,abs:_d}=Math,{float:fd,sign:md}=W,{minX:yd,maxX:vd,minY:xd,maxY:wd}=Yt,Ed=new Gt,bd=new Gt,kd={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Sd.getValidMove(t.__localBoxBounds,Sd.getDragBounds(t),s,e,!0),Sd.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:r}=t;n&&Sd.getValidScaleOf(t.__localBoxBounds,Sd.getDragBounds(t),r,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 r=t.x+s.x,o=t.y+s.y,a=r+t.width,h=o+t.height,l=e.x+e.width,d=e.y+e.height;return n||(s=Object.assign({},s)),Sd.isInnerMode(t,e,i,"width")?r>e.x?s.x+=e.x-r:a<l&&(s.x+=l-a):r<e.x?s.x+=e.x-r:a>l&&(s.x+=l-a),Sd.isInnerMode(t,e,i,"height")?o>e.y?s.y+=e.y-o:h<d&&(s.y+=d-h):o<e.y?s.y+=e.y-o:h>d&&(s.y+=d-h),s.x=fd(s.x),s.y=fd(s.y),s},getValidScaleOf(t,e,i,s,n,r,a){a||(n=Object.assign({},n)),bd.set(e),Ed.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,p,g,_,f=1,m=1;return Sd.isInnerMode(t,e,i,"width")?(n.x<0&&Ed.scaleOf(s,f=1/n.x,1),g=fd(Ed.minX-bd.minX),_=fd(bd.maxX-Ed.maxX),u=h&&g>0?1+g/(h*Ed.width):1,p=l&&_>0?1+_/(l*Ed.width):1,f*=gd(u,p)):(n.x<0&&((fd(yd(t)-yd(e))<=0||fd(vd(e)-vd(t))<=0)&&Ed.scaleOf(s,f=1/n.x,1),Ed.unsign()),g=fd(bd.minX-Ed.minX),_=fd(Ed.maxX-bd.maxX),u=h&&g>0?1-g/(h*Ed.width):1,p=l&&_>0?1-_/(l*Ed.width):1,f*=pd(u,p)),Sd.isInnerMode(t,e,i,"height")?(n.y<0&&Ed.scaleOf(s,1,m=1/n.y),g=fd(Ed.minY-bd.minY),_=fd(bd.maxY-Ed.maxY),u=d&&g>0?1+g/(d*Ed.height):1,p=c&&_>0?1+_/(c*Ed.height):1,m*=gd(u,p),r&&(u=gd(_d(f),_d(m)),f=md(f)*u,m=md(m)*u)):(n.y<0&&((fd(xd(t)-xd(e))<=0||fd(wd(e)-wd(t))<=0)&&Ed.scaleOf(s,1,m=1/n.y),Ed.unsign()),g=fd(bd.minY-Ed.minY),_=fd(Ed.maxY-bd.maxY),u=d&&g>0?1-g/(d*Ed.height):1,p=c&&_>0?1-_/(c*Ed.height):1,m*=pd(u,p)),n.x*=o(f)?f:1,n.y*=o(m)?m:1,n}},Sd=kd;t.PointerEvent=class extends ud{},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=ge([Vr()],t.PointerEvent);const Bd=t.PointerEvent,Td={};t.DragEvent=class extends t.PointerEvent{static setList(t){this.list=t instanceof uh?t:new uh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return lt.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),kd.axisMove(t,n),n}static limitMove(t,e){kd.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Td,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Td,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Td,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){Td.x=t?this.totalX:this.moveX,Td.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=ge([Vr()],t.DragEvent);const Pd=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=ge([Vr()],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.END="move.end",t.MoveEvent=ge([Vr()],t.MoveEvent),t.TouchEvent=class extends ud{},t.TouchEvent=ge([Vr()],t.TouchEvent);const Ld=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=ge([Vr()],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=ge([Vr()],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=ge([Vr()],t.ZoomEvent),t.KeyEvent=class extends ud{},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=ge([Vr()],t.KeyEvent);const Rd={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:Cd.getSwipeDirection(lt.getAngle(t,i))}),getBase(t){const e=1===t.button?4:t.button;return{altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:s(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 uh,{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=>so.draggable(e)||!e.isLeafer&&e.hasEvent(t.DragEvent.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},Cd=Rd,Od=new uh,{getDragEventData:Md,getDropEventData:Dd,getSwipeEventData:Id}=Rd;class Ad{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=Md(t,t,t),this.canAnimate=this.canDragOut=!0}getList(e,i){const{proxy:s}=this.interaction.selector,n=s&&s.list.length,r=t.DragEvent.list||this.draggableList||Od;return this.dragging&&(n?e?Od:new uh(i?[...s.list,...s.dragHoverExclude]:s.list):r)}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&&cd.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],so.draggable(e)){this.draggableList=new uh(e);break}}drag(e){const{interaction:i,dragData:s,downData:n}=this,{path:r,throughPath:o}=n;this.dragData=Md(n,s,e),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.moving?(this.dragData.moveType="drag",i.emit(t.MoveEvent.BEFORE_MOVE,this.dragData),i.emit(t.MoveEvent.MOVE,this.dragData)):this.dragging&&(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:h}=i.p,l=!h||!!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);h&&!n&&e?so.animateMove(i,d,a(h)?h:.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,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(e){const{interaction:i,downData:s,dragData:n}=this;e||(e=n);const{path:r,throughPath:o}=s,a=Md(s,e,e);if(o&&(a.throughPath=o),a.path=r,this.moving&&(this.moving=!1,a.moveType="drag",i.emit(t.MoveEvent.END,a)),this.dragging){const r=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,r,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(lt.getDistance(e,t)>n.config.pointer.swipeDistance){const t=Id(e,i,s);this.interaction.emit(t.type,t)}}drop(e,i,s){const n=Dd(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}checkDragEndAnimate(t,e){return!1}animate(t,e){}checkDragOut(t){}autoMoveOnDragOut(t){}autoMoveCancel(){}destroy(){this.dragReset()}}const Wd=$t.get("emit");const Fd=["move","zoom","rotate","key"];function zd(t,e,i,s,n){if(Fd.some(t=>e.startsWith(t))&&t.__.hitChildren&&!Hd(t,n)){let r;for(let o=0,a=t.children.length;o<a;o++)r=t.children[o],!i.path.has(r)&&r.__.hittable&&Ud(r,e,i,s,n)}}function Ud(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!Hd(t,n)&&(Kh.updateEventStyle&&!s&&Kh.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=ce.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function Hd(t,e){return e&&e.has(t)}const Nd={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:Yd,pathCanDrag:Xd,pathHasOutside:Vd}=Rd;class jd{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&&cd.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&cd.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&dd.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=p.clone(Nd),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new uh(t),this.createTransformer(),this.dragger=new Ad(this),s&&(this.config=p.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(e,i){e||(e=this.hoverData),e&&(cd.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),cd.left(e)&&(this.tapWait(),this.longPressWait(e)),this.waitRightTap=cd.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&&cd.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=lt.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;cd.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,dd.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,dd.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 uh),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,r=[t.PointerEvent.DOUBLE_TAP,t.PointerEvent.DOUBLE_CLICK].some(t=>Yd(e.path,t));n<i.tapTime+50&&r?(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:r}=this;y.backgrounder||t.origin||r&&r.updateLayout();const o=this.selector.getByPoint(t,i,Object.assign({bottomList:n,name:t.type},e||{through:s}));return o.throughPath&&(t.throughPath=o.throughPath),t.path=o.path,o.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&&!Vd(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!Xd(t.path))&&!Vd(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(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&&lt.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),(Yd(e.path,t.PointerEvent.LONG_TAP)||Yd(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 Gt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(a(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Yo.RESIZE,this.__onResize,this)],t.once(Go.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 r=i.length-1;r>-1;r--){if(n=i.list[r],Ud(n,t,e,!0,s))return;n.isApp&&zd(n,t,e,!0,s)}for(let r=0,o=i.length;r<o;r++)if(n=i.list[r],n.isApp&&zd(n,t,e,!1,s),Ud(n,t,e,!1,s))return}catch(t){Wd.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 Gd{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Gd.custom={};class Kd extends pe{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new uh,this.pixelList=new uh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),oe.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),oe.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()}}y.getSelector=function(t){return t.leafer?t.leafer.selector:y.selector||(y.selector=oe.selector())};const{toInnerRadiusPointOf:Zd,copy:qd,setRadius:Jd}=lt,{hitRadiusPoint:$d,hitPoint:Qd}=Yt,tc={},ec={},ic=t.Leaf.prototype;ic.hit=function(t,e=0){this.updateLayout(),qd(ec,t),Jd(ec,e);const i=this.__world;return!!(e?$d(i,ec):Qd(i,ec))&&(this.isBranch?y.getSelector(this).hitPoint(Object.assign({},ec),e,{target:this}):this.__hitWorld(ec))},ic.__hitWorld=function(t){const e=this.__;if(!e.hitSelf)return!1;const i=this.__world,s=this.__layout,n=i.width<10&&i.height<10;if(e.hitRadius&&(qd(tc,t),Jd(t=tc,e.hitRadius)),Zd(t,i,tc),e.hitBox||n){if(Yt.hitRadiusPoint(s.boxBounds,tc))return!0;if(n)return!1}return!s.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),s.boundsChanged||(s.hitCanvasChanged=!1)),this.__hit(tc)},ic.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},ic.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},ic.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},ic.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const sc=new ft,nc=t.UI.prototype;nc.__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 r=this.__hitCanvas;if(n){const{renderBounds:t}=this.__layout,n=y.image.hitCanvasSize,o=r.hitScale=Kt.set(0,0,n,n).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=Kt.set(t).scale(o);r.resize({width:l,height:d,pixelRatio:1}),r.clear(),$n.patternLocked=!0,this.__renderShape(r,{matrix:sc.setWith(this.__world).scaleWith(1/o).invertWith().translate(-a,-h),ignoreFill:!i,ignoreStroke:!s}),$n.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},nc.__hit=function(t){if(this.__box&&this.__box.__hit(t))return!0;const e=this.__;if(e.__isHitPixel&&this.__hitPixel(t))return!0;const{hitFill:i}=e,s=(e.fill||e.__isCanvas)&&("path"===i||"pixel"===i&&!(e.__isAlphaPixelFill||e.__isCanvas))||"all"===i;if(s&&this.__hitFill(t))return!0;const{hitStroke:n,__maxStrokeWidth:r}=e,o=e.stroke&&("path"===n||"pixel"===n&&!e.__isAlphaPixelStroke)||"all"===n;if(!s&&!o)return!1;const a=2*t.radiusX;let h=a;if(o)switch(e.strokeAlign){case"inside":if(h+=2*r,!s&&this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a;break;case"center":h+=r;break;case"outside":if(h+=2*r,!s){if(!this.__hitFill(t)&&this.__hitStroke(t,h))return!0;h=a}}return!!h&&this.__hitStroke(t,h)};const rc=t.UI.prototype,oc=t.Rect.prototype,ac=t.Box.prototype;oc.__updateHitCanvas=ac.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?rc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},oc.__hitFill=ac.__hitFill=function(t){return this.__hitCanvas?rc.__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:r}=this.__;t.beginPath(),n<0?this.__drawPathByBox(t):r.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=i),this.updateLayout(),y.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};const hc=Le.prototype;function lc(t,e,i){t.__.__font?Nh.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function dc(t,e,i,s,n){const r=i.__;d(t)?Nh.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),s.stroke()),r.__useArrow&&Nh.strokeArrow(t,i,s,n)}function cc(t,e,i,s,n){const r=i.__;d(t)?Nh.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),Nh.drawTextStroke(i,s,n))}function uc(t,e,i,s,n){const r=s.getSameCanvas(!0,!0);r.font=i.__.__font,cc(t,2,i,r,n),r.blendMode="outside"===e?"destination-out":"destination-in",Nh.fillText(i,r,n),r.blendMode="normal",so.copyCanvasByWorld(i,s,r),r.recycle(i.__nowWorld)}hc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},hc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},hc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:r,radiusY:o}=t;e&&(s-=e.x,n-=e.y),Kt.set(s-r,n-o,2*r,2*o).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:pc,copyAndSpread:gc,toOuterOf:_c,getOuterOf:fc,getByMove:mc,move:yc,getIntersectData:vc}=Yt,xc={};let wc;const{stintSet:Ec}=p,{hasTransparent:bc}=zh;function kc(t,e,i){if(!d(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:o}=i.__layout;switch(e.type){case"image":n=Yh.image(i,t,e,o,!wc||!wc[e.url]);break;case"linear":n=Xh.linearGradient(e,o);break;case"radial":n=Xh.radialGradient(e,o);break;case"angular":n=Xh.conicGradient(e,o);break;case"solid":const{type:r,color:a,opacity:h}=e;n={type:r,style:zh.string(a,h)};break;default:s(e.r)||(n={type:"solid",style:zh.string(e)})}if(n&&(n.originPaint=e,r(n.style)&&bc(n.style)&&(n.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}return n}const Sc={compute:function(t,e){const i=e.__,s=[];let n,r,o,a=i.__input[t];l(a)||(a=[a]),wc=Yh.recycleImage(t,i);for(let i,n=0,r=a.length;n<r;n++)(i=kc(t,a[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),r=!0),"fill"===t?(Ec(i,"__isAlphaPixelFill",n),Ec(i,"__isTransparentFill",r)):(Ec(i,"__isAlphaPixelStroke",n),Ec(i,"__isTransparentStroke",r),Ec(i,"__hasMultiStrokeStyle",o))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,lc(e,i,s)},fills:function(t,e,i,s){let n,r,o;for(let a=0,h=t.length;a<h;a++){if(n=t[a],r=n.originPaint,n.image){if(o?o++:o=1,Yh.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===o&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||r.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),r.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===r.scaleFixed||"zoom-in"===r.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}r.blendMode&&(i.blendMode=r.blendMode),lc(e,i,s),i.restore()}else r.blendMode?(i.saveBlendMode(r.blendMode),lc(e,i,s),i.restoreBlendMode()):lc(e,i,s)}},fillPathOrText:lc,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:r}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(r){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>r.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)Nh.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":dc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),dc(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)dc(t,2,e,i,s);else{const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),dc(t,2,e,o,s),o.clipUI(n),o.clearWorld(r),so.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Nh.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":cc(t,1,e,i,s);break;case"inside":uc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?cc(t,2,e,i,s):uc(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:r,decorationY:o}=n;for(let t=0,i=r.length;t<i;t++)s=r[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(o){const{decorationHeight:t}=n;r.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,r){let o;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(o=t[l],(!o.image||!Yh.checkImage(o,!1,s,n,r))&&o.style){if(h){const{strokeStyle:t}=o;t?n.setStroke(o.style,a.__getRealStrokeWidth(t)*e,a,t):n.setStroke(o.style,a.__strokeWidth*e,a)}else n.strokeStyle=o.style;o.originPaint.blendMode?(n.saveBlendMode(o.originPaint.blendMode),i?Nh.drawTextStroke(s,n,r):n.stroke(),n.restoreBlendMode()):i?Nh.drawTextStroke(s,n,r):n.stroke()}},shape:function(t,e,i){const s=e.getSameCanvas(),n=e.bounds,r=t.__nowWorld,o=t.__layout,a=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let h,l,d,c,u,p;_c(o.strokeSpread?(gc(xc,o.boxBounds,o.strokeSpread),xc):o.boxBounds,r,a);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(a))p=s,h=u=a,l=r;else{let s;if(y.fullImageShadow)s=a;else{const t=o.renderShapeSpread?pc(n,T.swapAndScale(o.renderShapeSpread,g,_)):n;s=vc(t,a)}c=n.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,i),g*=f,_*=m),u=fc(a,c),h=mc(u,-c.e,-c.f),l=fc(r,c),yc(l,-c.e,-c.f);const v=i.matrix;v?(d=new ft(c),d.multiply(v),f*=v.scaleX,m*=v.scaleY):d=c,d.withScale(f,m),i=Object.assign(Object.assign({},i),{matrix:d})}return t.__renderShape(s,i),{canvas:s,matrix:d,fitMatrix:c,bounds:h,renderBounds:l,worldCanvas:p,shapeBounds:u,scaleX:g,scaleY:_}}};let Bc,Tc=new Gt;const{isSame:Pc}=Yt;function Lc(t,e,i,s,n,r){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||Yh.createData(n,s,i,r),!0}function Rc(t,e){Mc(t,Ao.LOAD,e)}function Cc(t,e){Mc(t,Ao.LOADED,e)}function Oc(t,e,i){e.error=i,t.forceUpdate("surface"),Mc(t,Ao.ERROR,e)}function Mc(t,e,i){t.hasEvent(e)&&t.emitEvent(new Ao(e,i))}function Dc(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ic,translate:Ac}=$,Wc=new Gt,Fc={},zc={};function Uc(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 Hc={},Nc={a:1,b:0,c:0,d:1,e:0,f:0};const{get:Yc,set:Xc,rotateOfOuter:Vc,translate:jc,scaleOfOuter:Gc,multiplyParent:Kc,scale:Zc,rotate:qc,skew:Jc}=$;function $c(t,e,i,s,n,r,o,a){o&&qc(t,o),a&&Jc(t,a.x,a.y),n&&Zc(t,n,r),jc(t,e.x+i,e.y+s)}const{get:Qc,scale:tu,copy:eu}=$,{getFloorScale:iu}=W,{abs:su}=Math;const nu={image:function(t,e,i,s,n){let r,o;const a=$n.get(i);return Bc&&i===Bc.paint&&Pc(s,Bc.boxBounds)?r=Bc.leafPaint:(r={type:i.type,image:a},a.hasAlphaPixel&&(r.isTransparent=!0),Bc=a.use>1?{leafPaint:r,paint:i,boxBounds:Tc.set(s)}:null),(n||a.loading)&&(o={image:a,attrName:e,attrValue:i}),a.ready?(Lc(t,e,i,a,r,s),n&&(Rc(t,o),Cc(t,o))):a.error?n&&Oc(t,o,a.error):(n&&(Dc(t,!0),Rc(t,o)),r.loadId=a.load(()=>{Dc(t,!1),t.destroyed||(Lc(t,e,i,a,r,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Cc(t,o)),r.loadId=void 0},e=>{Dc(t,!1),Oc(t,o,e),r.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{a.ready||(a.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):a.isPlacehold=!0)),r},checkImage:function(t,e,i,s,n){const{scaleX:r,scaleY:o}=Yh.getImageRenderScaleData(t,i,s,n),{image:a,data:h,originPaint:l}=t,{exporting:d}=n;return!(!h||t.patternId===r+"-"+o&&!d)&&(e&&(h.repeat?e=!1:l.changeful||"miniapp"===y.name&&Yo.isResizing(i)||d||(e=y.image.isLarge(a,r,o))),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),Yh.drawImage(t,r,o,i,s,n),!0):(!t.style||l.sync||d?Yh.createPattern(t,i,s,n):Yh.createPatternTask(t,i,s,n),!1))},drawImage:function(t,e,i,s,n,r){const{data:o,image:a}=t,{blendMode:h}=t.originPaint,{opacity:l,transform:d}=o,c=a.getFull(o.filters),u=s.__;let p,{width:g,height:_}=a;(p=d&&!d.onlyScale||u.path||u.cornerRadius)||l||h?(n.save(),p&&n.clipUI(s),h&&(n.blendMode=h),l&&(n.opacity*=l),d&&n.transform(d),n.drawImage(c,0,0,g,_),n.restore()):(o.scaleX&&(g*=o.scaleX,_*=o.scaleY),n.drawImage(c,0,0,g,_))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:r}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return r&&r.scaleX&&(n.scaleX*=Math.abs(r.scaleX),n.scaleY*=Math.abs(r.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(l(i)){let s,n,r,o,a;for(let h=0,d=i.length;h<d;h++)s=i[h],n=s.image,a=n&&n.url,a&&(r||(r={}),r[a]=!0,$n.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],l(o)||(o=[o])),n.unload(i[h].loadId,!o.some(t=>t.url===a))));return r}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=$n.patternTasker.add(()=>_e(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&Yh.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,e,i,s){let{scaleX:n,scaleY:r}=Yh.getImageRenderScaleData(t,e,i,s),o=n+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!y.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:i,data:s}=t,{transform:a,gap:h}=s,l=Yh.getPatternFixScale(t,n,r);let d,c,u,{width:p,height:g}=i;l&&(n*=l,r*=l),p*=n,g*=r,h&&(c=h.x*n/su(s.scaleX||1),u=h.y*r/su(s.scaleY||1)),(a||1!==n||1!==r)&&(n*=iu(p+(c||0)),r*=iu(g+(u||0)),d=Qc(),a&&eu(d,a),tu(d,1/n,1/r));const _=i.getCanvas(p,g,s.opacity,s.filters,c,u,e.leafer&&e.leafer.config.smooth),f=i.getPattern(_,s.repeat||y.origin.noRepeat||"no-repeat",d,t);t.style=f,t.patternId=o}},getPatternFixScale:function(t,e,i){const{image:s}=t;let n,r=y.image.maxPatternSize,o=s.width*s.height;return s.isSVG?e>1&&(n=Math.ceil(e)/e):r>o&&(r=o),(o*=e*i)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=Yh.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=Wc.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:n}=i,{opacity:o,mode:a,align:h,offset:l,scale:c,size:u,rotation:p,skew:g,clipSize:_,repeat:f,gap:m,filters:y}=t,v=e.width===s&&e.height===n,x={mode:a},w="center"!==h&&(p||0)%180==90;let E,b;switch(Yt.set(zc,0,0,w?n:s,w?s:n),a&&"cover"!==a&&"fit"!==a?((c||u)&&(W.getScaleData(c,u,i,Fc),E=Fc.scaleX,b=Fc.scaleY),(h||m||f)&&(E&&Yt.scale(zc,E,b,!0),h&&Bt.toPoint(h,zc,e,zc,!0,!0))):v&&!p||(E=b=Yt.getFitScale(e,zc,"fit"!==a),Yt.put(e,i,h,E,!1,zc),Yt.scale(zc,E,b,!0)),l&&lt.move(zc,l),a){case"stretch":v?E&&(E=b=void 0):(E=e.width/s,b=e.height/n,Yh.stretchMode(x,e,E,b));break;case"normal":case"clip":if(zc.x||zc.y||E||_||p||g){let t,i;_&&(t=e.width/_.width,i=e.height/_.height),Yh.clipMode(x,e,zc.x,zc.y,E,b,p,g,t,i),t&&(E=E?E*t:t,b=b?b*i:i)}break;case"repeat":(!v||E||p||g)&&Yh.repeatMode(x,e,s,n,zc.x,zc.y,E,b,p,g,h,t.freeTransform),f||(x.repeat="repeat");const i=d(f);(m||i)&&(x.gap=function(t,e,i,s,n){let r,o;d(t)?(r=t.x,o=t.y):r=o=t;return{x:Uc(r,i,n.width,e&&e.x),y:Uc(o,s,n.height,e&&e.y)}}(m,i&&f,zc.width,zc.height,e));break;default:E&&Yh.fillOrFitMode(x,e,zc.x,zc.y,E,b,p)}return x.transform||(e.x||e.y)&&Ac(x.transform=Ic(),e.x,e.y),E&&(x.scaleX=E,x.scaleY=b),o&&o<1&&(x.opacity=o),y&&(x.filters=y),f&&(x.repeat=r(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),x},stretchMode:function(t,e,i,s){const n=Yc(),{x:r,y:o}=e;r||o?jc(n,r,o):n.onlyScale=!0,Zc(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,r,o){const a=Yc();jc(a,e.x+i,e.y+s),Zc(a,n,r),o&&Vc(a,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=a},clipMode:function(t,e,i,s,n,r,o,a,h,l){const d=Yc();$c(d,e,i,s,n,r,o,a),h&&(o||a?(Xc(Nc),Gc(Nc,e,h,l),Kc(d,Nc)):Gc(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,n,r,o,a,h,l,d,c){const u=Yc();if(c)$c(u,e,n,r,o,a,h,l);else{if(h)if("center"===d)Vc(u,{x:i/2,y:s/2},h);else switch(qc(u,h),h){case 90:jc(u,s,0);break;case 180:jc(u,i,s);break;case 270:jc(u,0,i)}Hc.x=e.x+n,Hc.y=e.y+r,jc(u,Hc.x,Hc.y),o&&Gc(u,Hc,o,a)}t.transform=u}},{toPoint:ru}=bt,{hasTransparent:ou}=zh,au={},hu={};function lu(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&&ou(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:du,getDistance:cu}=lt,{get:uu,rotateOfOuter:pu,scaleOfOuter:gu}=$,{toPoint:_u}=bt,fu={},mu={};function yu(t,e,i,s,n){let r;const{width:o,height:a}=t;if(o!==a||s){const t=du(e,i);r=uu(),n?(gu(r,e,o/a*(s||1),1),pu(r,e,t+90)):(gu(r,e,1,o/a*(s||1)),pu(r,e,t))}return r}const{getDistance:vu}=lt,{toPoint:xu}=bt,wu={},Eu={};const bu={linearGradient:function(t,e){let{from:i,to:s,type:n,opacity:r}=t;ru(i||"top",e,au),ru(s||"bottom",e,hu);const o=y.canvas.createLinearGradient(au.x,au.y,hu.x,hu.y),a={type:n,style:o};return lu(a,o,t.stops,r),a},radialGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;_u(i||"center",e,fu),_u(s||"bottom",e,mu);const a=y.canvas.createRadialGradient(fu.x,fu.y,0,fu.x,fu.y,cu(fu,mu)),h={type:n,style:a};lu(h,a,t.stops,r);const l=yu(e,fu,mu,o,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;xu(i||"center",e,wu),xu(s||"bottom",e,Eu);const a=y.conicGradientSupport?y.canvas.createConicGradient(0,wu.x,wu.y):y.canvas.createRadialGradient(wu.x,wu.y,0,wu.x,wu.y,vu(wu,Eu)),h={type:n,style:a};lu(h,a,t.stops,r);const l=yu(e,wu,Eu,o||1,y.conicGradientRotate90);return l&&(h.transform=l),h},getTransform:yu},{copy:ku,move:Su,toOffsetOutBounds:Bu}=Yt,{max:Tu,abs:Pu}=Math,Lu={},Ru=new ft,Cu={};function Ou(t,e){let i,s,n,r,o=0,a=0,h=0,l=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,r=1.5*(t.blur||0),n=Pu(t.spread||0),o=Tu(o,n+r-s),a=Tu(a,n+r+i),h=Tu(h,n+r+s),l=Tu(l,n+r-i)}),o===a&&a===h&&h===l?o:[o,a,h,l]}function Mu(t,e,i){const{shapeBounds:s}=i;let n,r;y.fullImageShadow?(ku(Lu,t.bounds),Su(Lu,e.x-s.x,e.y-s.y),n=t.bounds,r=Lu):(n=s,r=e),t.copyWorld(i.canvas,n,r)}const{toOffsetOutBounds:Du}=Yt,Iu={};const Au=Ou;const Wu={shadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{shadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Bu(h,Cu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.setWorldShadow(Cu.offsetX+(o.x||0)*c*f,Cu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f,zh.string(o.color)),n=Vh.getShadowTransform(t,p,i,o,Cu,f),n&&p.setTransform(n),Mu(p,Cu,i),n&&p.resetTransform(),s=l,o.box&&(p.restore(),p.save(),a&&(p.copyWorld(p,l,r,"copy"),s=r),a?p.copyWorld(a,r,r,"destination-out"):p.copyWorld(i.canvas,d,h,"destination-out")),so.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:r}=t,{innerShadow:o}=t.__,{worldCanvas:a,bounds:h,renderBounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;Du(h,Iu,l),o.forEach((o,_)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}p.save(),p.setWorldShadow(Iu.offsetX+(o.x||0)*c*f,Iu.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f),n=Vh.getShadowTransform(t,p,i,o,Iu,f,!0),n&&p.setTransform(n),Mu(p,Iu,i),p.restore(),a?(p.copyWorld(p,l,r,"copy"),p.copyWorld(a,r,r,"source-out"),s=r):(p.copyWorld(i.canvas,d,h,"source-out"),s=l),p.fillWorld(s,zh.string(o.color),"source-in"),so.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Ou,getShadowTransform:function(t,e,i,s,n,r,o){if(s.spread){const i=2*s.spread*r*(o?-1:1),{width:a,height:h}=t.__layout.strokeBounds;return Ru.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),Ru}},isTransformShadow(t){},getInnerShadowSpread:Au},{excludeRenderBounds:Fu}=uo;let zu;function Uu(t,e,i,s,n,r,o,a){switch(e){case"grayscale":zu||(zu=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,r){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),r&&s.recycle(o);Nu(t,e,i,1,n,r)}(t,i,s,n,o,a);break;case"opacity-path":Nu(t,i,s,r,o,a);break;case"path":a&&i.restore()}}function Hu(t){return t.getSameCanvas(!1,!0)}function Nu(t,e,i,s,n,r){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),r?i.recycle(o):i.clearWorld(o)}t.Group.prototype.__renderMask=function(t,e){let i,s,n,r,o,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++){if(i=h[l],a=i.__.mask,a){o&&(Uu(this,o,t,n,s,r,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||Fu(i,e)||i.__render(t,e),r=i.__.opacity,zu=!1,"path"===a||"clipping-path"===a?(r<1?(o="opacity-path",n||(n=Hu(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===a?"grayscale":"alpha",s||(s=Hu(t)),n||(n=Hu(t)),i.__render(s,e));continue}const d=1===r&&i.__.__blendMode;d&&Uu(this,o,t,n,s,r,void 0,!1),Fu(i,e)||i.__render(n||t,e),d&&Uu(this,o,t,n,s,r,d,!1)}Uu(this,o,t,n,s,r,void 0,!0)};const Yu=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Xu=Yu+"_#~&*+\\=|≮≯≈≠=…",Vu=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 ju(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Gu=ju("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ku=ju("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zu=ju(Yu),qu=ju(Xu),Ju=ju("- —/~|┆·");var $u;!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"}($u||($u={}));const{Letter:Qu,Single:tp,Before:ep,After:ip,Symbol:sp,Break:np}=$u;function rp(t){return Gu[t]?Qu:Ju[t]?np:Ku[t]?ep:Zu[t]?ip:qu[t]?sp:Vu.test(t)?tp:Qu}const op={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let r=n-1;r>-1&&(i=e[r].data[0]," "===i.char);r--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ap(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:hp}=op,{Letter:lp,Single:dp,Before:cp,After:up,Symbol:pp,Break:gp}=$u;let _p,fp,mp,yp,vp,xp,wp,Ep,bp,kp,Sp,Bp,Tp,Pp,Lp,Rp,Cp,Op=[];function Mp(t,e){bp&&!Ep&&(Ep=bp),_p.data.push({char:t,width:e}),mp+=e}function Dp(){yp+=mp,_p.width=mp,fp.words.push(_p),_p={data:[]},mp=0}function Ip(){Pp&&(Lp.paraNumber++,fp.paraStart=!0,Pp=!1),bp&&(fp.startCharSize=Ep,fp.endCharSize=bp,Ep=0),fp.width=yp,Rp.width?hp(fp):Cp&&Ap(),Op.push(fp),fp={words:[]},yp=0}function Ap(){yp>(Lp.maxWidth||0)&&(Lp.maxWidth=yp)}const{top:Wp,right:Fp,bottom:zp,left:Up}=t.Direction4;function Hp(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 Np={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[Up],n-=a[Fp]+a[Up],!n&&(n=.01)):e.autoSizeAlign||(i=a[Up]),o?(s=a[Wp],o-=a[Wp]+a[zp],!o&&(o=.01)):e.autoSizeAlign||(s=a[Wp]));const h={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:y.canvas.font=e.__font};return function(t,e,i){Lp=t,Op=t.rows,Rp=t.bounds,Cp=!Rp.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:o}=y,{width:a}=Rp;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;Pp=!0,Sp=null,Ep=wp=bp=mp=yp=0,_p={data:[]},fp={words:[]},s&&(e=[...e]);for(let i=0,l=e.length;i<l;i++)xp=e[i],"\n"===xp?(mp&&Dp(),fp.paraEnd=!0,Ip(),Pp=!0):(kp=rp(xp),kp===lp&&"none"!==r&&(xp=ap(xp,r,!mp)),wp=o.measureText(xp).width,s&&(s<0&&(bp=wp),wp+=s),Bp=kp===dp&&(Sp===dp||Sp===lp)||Sp===dp&&kp!==up,Tp=!(kp!==cp&&kp!==dp||Sp!==pp&&Sp!==up),vp=Pp&&n?a-n:a,t&&a&&yp+mp+wp>vp&&(h?(mp&&Dp(),yp&&Ip()):(Tp||(Tp=kp===lp&&Sp==up),Bp||Tp||kp===gp||kp===cp||kp===dp||mp+wp>vp?(mp&&Dp(),yp&&Ip()):yp&&Ip()))," "===xp&&!0!==Pp&&yp+mp===0||(kp===gp?(" "===xp&&mp&&Dp(),Mp(xp,wp),Dp()):Bp||Tp?(mp&&Dp(),Mp(xp,wp)):Mp(xp,wp)),Sp=kp);mp&&Dp(),yp&&Ip(),Op.length>0&&(Op[Op.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Lp.paraNumber++,yp=o.measureText(t).width,Op.push({x:n||0,text:t,width:yp,paraStart:!0}),Cp&&Ap()})}(h,t,e),a&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Hp(e,"x",t[Up]);break;case"right":Hp(e,"x",-t[Fp])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Hp(e,"y",t[Wp]);break;case"bottom":Hp(e,"y",-t[zp])}}(a,h,e,n,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:r,__baseLine:o,__letterSpacing:a,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:p,y:g,width:_,height:f}=s,m=r*n+(c?c*(t.paraNumber-1):0),y=o;if(h&&m>f)m=Math.max(f,r),n>1&&(t.overflow=n);else if(f||u)switch(d){case"middle":g+=(f-m)/2;break;case"bottom":g+=f-m}y+=g;let v,x,w,E=_||u?_:t.maxWidth;for(let o=0,d=n;o<d;o++){if(v=i[o],v.x=p,v.width<_||v.width>_&&!h)switch(l){case"center":v.x+=(E-v.width)/2;break;case"right":v.x+=E-v.width}v.paraStart&&c&&o>0&&(y+=c),v.y=y,y+=r,t.overflow>o&&y>m&&(v.isOverflow=!0,t.overflow=o+1),x=v.x,w=v.width,a<0&&(v.width<0?(w=-v.width+e.fontSize+a,x-=w,w+=e.fontSize):w-=a),x<s.x&&(s.x=x),w>s.width&&(s.width=w),h&&_&&_<w&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(h,e),e.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:r,letterSpacing:o}=e,a=i&&n.includes("both"),h=a||i&&n.includes("justify"),l=h&&n.includes("letter");let d,c,u,p,g,_,f,m,y,v;s.forEach(t=>{t.words&&(g=r&&t.paraStart?r:0,m=t.words.length,h&&(v=!t.paraEnd||a,c=i-t.width-g,l?p=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),_=o||t.isOverflow||l?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===_?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===_?(f={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,f),(t.isOverflow||" "!==f.char)&&t.data.push(f)):d=function(t,e,i,s,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&&p),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):p&&(t.width+=p*(e.data.length-(y?1:0))))})),t.words=null)})}(h,e,n),h.overflow&&function(t,e,i,s){if(!s)return;const{rows:n,overflow:r}=t;let{textOverflow:o}=e;if(n.splice(r),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?y.canvas.measureText(o).width:0,l=i+s-h;("none"===e.textWrap?n:[n[r-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:o,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:r}=e;switch(t.decorationHeight=n/11,d(r)?(i=r.type,r.color&&(t.decorationColor=zh.string(r.color)),r.offset&&(s=Math.min(.3*n,Math.max(r.offset,.15*-n)))):i=r,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 Yp={string:function(t,e){if(!t)return"#000";const i=a(e)&&e<1;if(r(t)){if(!i||!zh.object)return t;t=zh.object(t)}let n=s(t.a)?1:t.a;i&&(n*=e);const o=t.r+","+t.g+","+t.b;return 1===n?"rgb("+o+")":"rgba("+o+","+n+")"}};function Xp(t){return t?l(t)?t:[t]:[]}Object.assign(Fh,Np),Object.assign(zh,Yp),Object.assign(Nh,Sc),Object.assign(Yh,nu),Object.assign(Xh,bu),Object.assign(Vh,Wu),Object.assign(oe,{interaction:(t,e,i,s)=>new jd(t,e,i,s),hitCanvas:(t,e)=>new gh(t,e),hitCanvasManager:()=>new Kd}),fh();class Vp extends Co{get list(){return Xp(this.value)}get oldList(){return Xp(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function jp(t){return(e,i)=>{const s="_"+i;sr(e,i,{get(){return this[s]},set(e){const n=this[s];if(n!==e){const r=this;if(r.config){const t="target"===i;if(t){const{beforeSelect:t}=r.config;if(t){const i=t({target:e});if(d(i))e=i;else if(!1===i)return}r.setDimOthers(!1),r.setBright(!1),l(e)&&e.length>1&&e[0].locked&&e.splice(0,1),r.single&&(delete r.element.syncEventer,delete r.element.__world.ignorePixelSnap)}const s=t?Vp.BEFORE_SELECT:Vp.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new Vp(s,{editor:r,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}Vp.BEFORE_SELECT="editor.before_select",Vp.SELECT="editor.select",Vp.AFTER_SELECT="editor.after_select",Vp.BEFORE_HOVER="editor.before_hover",Vp.HOVER="editor.hover";const{abs:Gp}=Math,{copy:Kp,scale:Zp}=$,{setListWithFn:qp}=Yt,{worldBounds:Jp}=uo,$p={a:1,b:0,c:0,d:1,e:0,f:0},Qp={x:0,y:0,width:0,height:0};class tg 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?(qp(Qp,e,Jp),t&&this.set(t),this.set(Qp),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=Gp(c.scaleX),l=Gp(c.scaleY);if(Kp($p,c),$p.half=a%2,i!==l){Zp($p,1/i,1/l),t.setWorld($p,e.matrix),t.beginPath(),n.strokeWidth=a;const{x:r,y:o,width:h,height:d}=s.__layout.boxBounds;t.rect(r*i,o*l,h*i,d*l)}else t.setWorld($p,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=a/Gp(c.scaleX);o&&(r(o)?Nh.stroke(o,this,t,e):Nh.strokes(o,this,t,e)),h&&(r(h)?Nh.fill(h,this,t,e):Nh.fills(h,this,t,e))}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}ge([jp(function(t){const e=t.target;t.list=e?l(e)?e:[e]:[]})],tg.prototype,"target",void 0);class eg 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 ig={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return sg([t],i,e),i}};function sg(t,e,i){let s,n;for(let r=0,o=t.length;r<o;r++)if(s=t[r],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&&sg(s.children,e,i)}}const{findOne:ng,findByBounds:rg}=ig;class og 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 tg,this.targetStroker=new tg,this.bounds=new Gt,this.selectArea=new eg,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:r,hover:o,hoverStyle:a}=s;this.hoverStroker.setTarget(o?e:null,Object.assign({stroke:n,strokeWidth:r},a||{}))}}onSelect(){this.running&&(this.targetStroker.setTarget(this.editor.list),this.hoverStroker.target=null)}update(){this.hoverStroker.update();const{stroke:t,strokeWidth:e,selectedStyle:i}=this.editor.mergedConfig;this.targetStroker.update(Object.assign({stroke:t,strokeWidth:e&&Math.max(1,e/2)},i||{}))}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:r}=t.getInnerPoint(this);this.bounds.set(n,r),this.selectArea.setStyle({visible:!0,stroke:i,x:n,y:r},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 uh(rg(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)&&!ng(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new uh(this.editor.editBox.rect)};return ng(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):ng(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_([[Vp.HOVER,this.onHover,this],[Vp.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:ag,top:hg,topRight:lg,right:dg,bottomRight:cg,bottom:ug,bottomLeft:pg,left:gg}=t.Direction9,{toPoint:_g}=bt,{within:fg,sign:mg}=W,{abs:yg}=Math,vg={getScaleData(t,e,i,s,n,r,o,h){let l,d,c={},u=1,p=1;const{boxBounds:g,widthRange:_,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:x}=e,w=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,b=mg(w),k=mg(E),S=h?w:b*g.width/v,B=h?E:k*g.height/x;if(a(s))u=p=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=h?w:b,s.y*=h?E:k;const t=(-s.y+x)/x,e=(s.x+v)/v,o=(s.y+x)/x,a=(-s.x+v)/v;switch(i){case hg:p=t,l="bottom";break;case dg:u=e,l="left";break;case ug:p=o,l="top";break;case gg:u=a,l="right";break;case ag:p=t,u=a,l="bottom-right";break;case lg:p=t,u=e,l="bottom-left";break;case cg:p=o,u=e,l="top-left";break;case pg:p=o,u=a,l="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case hg:case ug:u=p;break;case gg:case dg:p=u;break;default:d=Math.sqrt(yg(u*p)),u=mg(u)*d,p=mg(p)*d}}const T=1!==u,P=1!==p;if(T&&(u/=S),P&&(p/=B),!o){const{worldTransform:e}=t;u<0&&(u=1/g.width/e.scaleX),p<0&&(p=1/g.height/e.scaleY)}if(_g(r||l,g,c,!0),m){const e={x:u,y:p};kd.limitScaleOf(t,c,e,n),u=e.x,p=e.y}if(T&&_){const e=g.width*t.scaleX;u=fg(e*u,_)/e}if(P&&f){const e=g.height*t.scaleY;p=fg(e*p,f)/e}return T&&yg(u*y.width)<1&&(u=mg(u)/y.width),P&&yg(p*y.height)<1&&(p=mg(p)/y.height),n&&u!==p&&(d=Math.min(yg(u),yg(p)),u=mg(u)*d,p=mg(p)*d),isFinite(u)||(u=1),isFinite(p)||(p=1),{origin:c,scaleX:u,scaleY:p,direction:i,lockRatio:n,around:r}},getRotateData(t,e,i,s,n){let r,o={};switch(e){case ag:r="bottom-right";break;case lg:r="bottom-left";break;case cg:r="top-left";break;case pg:r="top-right";break;default:r="center"}return _g(n||r,t.boxBounds,o,!0),{origin:o,rotation:lt.getRotation(s,t.getWorldPointByBox(o),i)}},getSkewData(t,e,i,s){let n,r,o={},a=0,h=0;switch(e){case hg:case ag:r={x:.5,y:0},n="bottom",a=1;break;case ug:case cg:r={x:.5,y:1},n="top",a=1;break;case gg:case pg:r={x:0,y:.5},n="right",h=1;break;case dg:case lg:r={x:1,y:.5},n="left",h=1}const{width:l,height:d}=t;r.x=r.x*l,r.y=r.y*d,_g(s||n,t,o,!0);const c=lt.getRotation(r,o,{x:r.x+(a?i.x:0),y:r.y+(h?i.y:0)});return a?a=-c:h=c,{origin:o,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 gg:t=dg;break;case ag:t=lg;break;case pg:t=cg;break;case dg:t=gg;break;case lg:t=ag;break;case cg:t=pg}if(i)switch(t){case hg:t=ug;break;case ag:t=pg;break;case lg:t=cg;break;case ug:t=hg;break;case pg:t=ag;break;case cg:t=lg}return t}},xg={};function wg(t,e){const{enterPoint:i,dragging:s,skewing:n,resizing:r,flippedX:o,flippedY:a}=t;if(!i||!t.editor.editing||!t.canUse)return;if("rect"===i.name)return Eg(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:p,moveable:g,resizeable:_,rotateable:f,skewable:m}=t.mergeConfig;if("move"===l)return i.cursor=d,void(g||(i.visible=!1));if("button"===l)return void(i.cursor||(i.cursor="pointer"));let y=l.includes("resize");y&&f&&(t.isHoldRotateKey(e)||!_)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),x=s?n?p:r?c:u:v?p:y?c:u;h+=45*(vg.getFlipDirection(i.direction,o,a)+1),h=2*Math.round(W.formatRotation(h,!0)/2);const{url:w,x:E,y:b}=x,k=w+h;xg[k]?i.cursor=xg[k]:xg[k]=i.cursor={url:bg(w,h),x:E,y:b}}function Eg(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function bg(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class kg extends t.Box{constructor(t){super(t),this.useFastShadow=!0}}const Sg=["top","right","bottom","left"],Bg=void 0;class Tg 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 kg({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new kg({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:r,resizeLines:o,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 kg({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new kg({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),o.push(e),this.listenPointEvents(e,"resize",s)),i=new kg({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(...r,a,h,l,...o,...n),this.add(s)}load(){const{target:t,mergeConfig:e,single:i,rect:s,circle:r,resizePoints:o,resizeLines:a}=this,{stroke:h,strokeWidth:l,ignorePixelSnap:d}=e,c=this.getPointsStyle(),u=this.getMiddlePointsStyle(),g=this.getResizeLinesStyle();let _;this.visible=!t.locked;for(let t=0;t<8;t++)_=o[t],_.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:c[t/2%c.length])),_.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]||{}));r.set(this.getPointStyle(e.circle||e.rotatePoint||c[0])),s.set(Object.assign({stroke:h,strokeWidth:l,opacity:1,editConfig:Bg},e.rect||{}));const f=n(e.rectThrough)?i:e.rectThrough;s.hittable=!f,f&&(t.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:t}]),i&&p.stintSet(t.__world,"ignorePixelSnap",d),Eg(this)}update(){const{editor:t}=this,{x:e,y:i,scaleX:s,scaleY:n,rotation:r,skewX:o,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:r,skewX:o,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:r,buttons:o,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{editMask:c}=e,{middlePoint:u,resizeable:p,rotateable:g,hideOnSmall:_,editBox:f,mask:m,dimOthers:y,bright:v,spread:x,hideRotatePoints:w,hideResizeLines:E}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),x&&Yt.spread(t,x),this.view.worldOpacity){const{width:e,height:c}=t,m=a(_)?_:10,y=f&&!(_&&e<m&&c<m);let v,x,b,k={};for(let i=0;i<8;i++)bt.toPoint(bt.directionData[i],t,k),x=h[i],v=l[i],x.set(k),v.set(k),x.visible=y&&!(!p&&!g),v.visible=y&&g&&p&&!w,i%2&&(b=d[(i-1)/2],b.set(k),b.visible=x.visible&&!E,x.visible=v.visible=y&&!!u,(i+1)/2%2?(b.width=e+b.height,_&&2*x.width>e&&(x.visible=!1)):(b.width=c+b.height,_&&2*x.width>c&&(x.visible=!1)));r.visible=y&&g&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!s||f})),o.visible=y&&o.children.length>0||0,o.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,r=Sg.indexOf(t||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,e||i,!!n)}layoutButtons(){const{buttons:t}=this,{buttonsDirection:e,buttonsFixed:i,buttonsMargin:s,middlePoint:n}=this.mergedConfig,{flippedX:r,flippedY:o}=this;let a=Sg.indexOf(e);(a%2&&r||(a+1)%2&&o)&&i&&(a=(a+2)%4);const h=i?vg.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a;this.setButtonPosition(t,h,s,!!n),i&&(t.rotation=90*(h-a)),t.scaleX=r?-1:1,t.scaleY=o?-1:1}setButtonPosition(t,e,i,s){const n=this.resizePoints[2*e+1],r=e%2,o=e&&3!==e?1:-1,a=(i+(e%2?(s?n.width:0)+t.boxBounds.width:(s?n.height:0)+t.boxBounds.height)/2)*o;r?(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:r}=this.mergedConfig,o={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",opacity:1,width:n,height:n,cornerRadius:r,offsetX:0,offsetY:0,editConfig:Bg};return t?Object.assign(o,t):o}getPointsStyle(){const{point:t}=this.mergedConfig;return l(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return l(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return l(t)?t:[t]}onDragStart(t){this.dragging=!0;const e=this.dragPoint=t.current,{pointType:i}=e,{moveable:s,resizeable:n,rotateable:r,skewable:o}=this.mergeConfig;"move"===i?s&&(this.moving=!0):(i.includes("rotate")||this.isHoldRotateKey(t)||!n?(r&&(this.rotating=!0),"resize-rotate"===i?n&&(this.resizing=!0):"resize-line"===e.name&&(o&&(this.skewing=!0),this.rotating=!1)):"resize"===i&&n&&(this.resizing=!0),"skew"===i&&o&&(this.skewing=!0)),this.onTransformStart(t)}onDrag(t){const{transformTool:e,moving:i,resizing:s,rotating:n,skewing:r}=this;if(i)e.onMove(t);else if(s||n||r){const i=t.current;i.pointType&&(this.enterPoint=i),n&&e.onRotate(t),s&&e.onScale(t),r&&e.onSkew(t)}wg(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&&(Yo.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&&(Yo.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){wg(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,wg(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 Pg={x:0,y:0,width:1e5,height:1e5};class Lg extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,Pg),Object.assign(this.__world,Pg)}__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 Rg='\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"/>',Cg={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${Rg}\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${Rg}\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${Rg}\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},Og=new Gt;function Mg(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{Og.setListWithFn(i,t=>t.getBounds("box","page")),0===Og.width&&(Og.width=.1),0===Og.height&&(Og.height=.1),e.reset(Og.get())}),s.add(e)}const Dg=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Ig=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Ag={group(e,i,s){e.sort(Ig);const{app:n,parent:r}=e[0];let o;o=s&&s.add?s:new t.Group(s),r.addAt(o,r.children.indexOf(e[0])),e.sort(Dg);const a=new ft(i.worldTransform);return a.divideParent(r.scrollWorldTransform),o.setTransform(a),o.editable=!0,o.hitChildren=!1,n.lockLayout(),e.forEach(t=>t.dropTo(o)),n.unlockLayout(),o},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(Dg),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(Ig),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},Wg=$t.get("EditToolCreator");function Fg(){return t=>{Ug.register(t)}}const zg=Fg,Ug={list:{},register(t){const{tag:e}=t.prototype;Hg[e]&&Wg.repeat(e),Hg[e]=t},get:(t,e)=>new Hg[t](e)},{list:Hg}=Ug;class Ng extends Vp{constructor(t,e){super(t,e)}}Ng.BEFORE_OPEN="innerEditor.before_open",Ng.OPEN="innerEditor.open",Ng.BEFORE_CLOSE="innerEditor.before_close",Ng.CLOSE="innerEditor.close";class Yg extends Vp{constructor(t,e){super(t,e)}}Yg.BEFORE_GROUP="editor.before_group",Yg.GROUP="editor.group",Yg.BEFORE_UNGROUP="editor.before_ungroup",Yg.UNGROUP="editor.ungroup",Yg.BEFORE_OPEN="editor.before_open_group",Yg.OPEN="editor.open_group",Yg.BEFORE_CLOSE="editor.before_close_group",Yg.CLOSE="editor.close_group";const{updateMatrix:Xg}=so,Vg={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},jg="top-left";class Gg extends t.Rect{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Do.CHANGE,e=>{if(this.checkChange&&Vg[e.attrName]){const{attrName:i,newValue:s,oldValue:n}=e,r="s"===i[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const o=this.__;o[i]=n,Xg(this.parent),Xg(this);const a=new ft(this.__world);switch(o[i]=s,this.__layout.rotationChange(),Xg(this),this.changedTransform=new ft(this.__world).divide(a),i){case"x":t.move(r,0);break;case"y":t.move(0,r);break;case"rotation":t.rotateOf(jg,r);break;case"scaleX":t.scaleOf(jg,r,1);break;case"scaleY":t.scaleOf(jg,1,r);break;case"skewX":t.skewOf(jg,r,0);break;case"skewY":t.skewOf(jg,0,r)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Kg extends Vp{constructor(t,e){super(t,e)}}Kg.BEFORE_MOVE="editor.before_move",Kg.MOVE="editor.move";class Zg extends Vp{constructor(t,e){super(t,e)}}Zg.BEFORE_SCALE="editor.before_scale",Zg.SCALE="editor.scale";class qg extends Vp{constructor(t,e){super(t,e)}}qg.BEFORE_ROTATE="editor.before_rotate",qg.ROTATE="editor.rotate";class Jg extends Vp{constructor(t,e){super(t,e)}}Jg.BEFORE_SKEW="editor.before_skew",Jg.SKEW="editor.skew";class $g{onMove(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox;let o,{dragLimitAnimate:h}=s;const l=e.type===t.MoveEvent.END||e.type===t.DragEvent.END,d=r(i.draggable),c=!h||l||d,u={x:e.totalX,y:e.totalY};e instanceof t.MoveEvent&&lt.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)&&(h&&!d&&l?so.animateMove(this,o,a(h)?h:.3):this.move(o))}onScale(e){const{target:i,mergeConfig:s,single:n,dragStartData:r}=this.editBox;let o,{around:a,lockRatio:h,flipable:l,editSize:d}=s;e instanceof t.ZoomEvent?(a=i.getBoxPoint(e),o=e.totalScale):o=e.getInnerTotal(i);const{direction:c}=e.current;(e.shiftKey||i.lockRatio)&&(h=!0);const u=vg.getScaleData(i,r.bounds,c,o,h,vg.getAround(a,e.altKey),l,!n||"scale"===d),p=i.x,g=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),lt.move(r.totalOffset,i.x-p,i.y-g)}onRotate(e){const{target:i,mergeConfig:s,dragStartData:n}=this.editBox,{around:r,rotateAround:o,rotateGap:a,diagonalRotateKey:h}=s,{direction:l}=e.current;let d,c;if(e instanceof t.RotateEvent)c=e.rotation,d=o?bt.getPoint(o,i.boxBounds):i.getBoxPoint(e);else{const t=h?e.isHoldKeys(h):e.shiftKey,s=vg.getRotateData(i,l,e,n,t?null:o||i.around||i.origin||r||"center");c=n.rotation+s.rotation-i.rotation,d=s.origin}if(c=W.float(W.getGapRotation(c,a,i.rotation),2),!c)return;const u=i.x,p=i.y;this.rotateOf(d,c),lt.move(n.totalOffset,i.x-u,i.y-p)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:r,skewY:o}=vg.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),vg.getAround(s,t.altKey));(r||o)&&this.skewOf(n,r,o)}move(t,e=0){if(!this.checkTransform("moveable"))return;d(t)&&(e=t.y,t=t.x);const{target:i,mergeConfig:s,single:n,editor:r}=this.editBox,{beforeMove:o}=s;if(o){const s=o({target:i,x:t,y:e});if(d(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:r,moveX:a.x,moveY:a.y};this.emitEvent(new Kg(Kg.BEFORE_MOVE,h));const l=new Kg(Kg.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:r,drag:o}=t;if(!1===n({target:e,drag:o,origin:i,scaleX:s,scaleY:r}))return}t=Object.assign(Object.assign({},t),{target:e,editor:s,worldOrigin:e.getWorldPoint(t.origin)}),this.emitEvent(new Zg(Zg.BEFORE_SCALE,t));const r=new Zg(Zg.SCALE,t);this.editTool.onScaleWithDrag(r),this.emitEvent(r)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeScale:h}=r;if(h){const s=h({target:n,origin:t,scaleX:e,scaleY:i});if(d(s))e=s.scaleX,i=s.scaleY;else if(!1===s)return}const l=this.getWorldOrigin(t),c=!o&&this.getChangedTransform(()=>n.safeChange(()=>n.scaleOf(t,e,i))),u={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:c};this.emitEvent(new Zg(Zg.BEFORE_SCALE,u));const p=new Zg(Zg.SCALE,u);this.doScale(p),this.emitEvent(p)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),r=i?new ft(so.getFlipTransform(e,t)):this.getChangedTransform(()=>e.safeChange(()=>e.flip(t))),o={target:e,editor:s,worldOrigin:n,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:r};this.emitEvent(new Zg(Zg.BEFORE_SCALE,o));const a=new Zg(Zg.SCALE,o);this.doScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{target:i,mergeConfig:s,single:n,editor:r}=this.editBox,{beforeRotate:o}=s;if(o){const s=o({target:i,origin:t,rotation:e});if(a(s))e=s;else if(!1===s)return}const h=this.getWorldOrigin(t),l=!n&&this.getChangedTransform(()=>i.safeChange(()=>i.rotateOf(t,e))),d={target:i,editor:r,worldOrigin:h,rotation:e,transform:l};this.emitEvent(new qg(qg.BEFORE_ROTATE,d));const c=new qg(qg.ROTATE,d);this.doRotate(c),this.emitEvent(c)}skewOf(t,e,i=0,s){if(!this.checkTransform("skewable"))return;const{target:n,mergeConfig:r,single:o,editor:a}=this.editBox,{beforeSkew:h}=r;if(h){const s=h({target:n,origin:t,skewX:e,skewY:i});if(d(s))e=s.skewX,i=s.skewY;else if(!1===s)return}const l=this.getWorldOrigin(t),c=!o&&this.getChangedTransform(()=>n.safeChange(()=>n.skewOf(t,e,i))),u={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:c};this.emitEvent(new Jg(Jg.BEFORE_SKEW,u));const p=new Jg(Jg.SKEW,u);this.doSkew(p),this.emitEvent(p)}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(so.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 uh,this.openedGroupList=new uh,this.simulateTarget=new Gg(this),this.editBox=new Tg(this),this.editToolList={},this.selector=new og(this),this.editMask=new Lg(this),this.targetEventIds=[];let i=p.clone(Cg);t&&(i=p.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),re.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?l(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>p.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&&Mg(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||Ug.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(Ug.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(Yg.BEFORE_GROUP),this.target=Ag.group(this.list,this.element,t),this.emitGroupEvent(Yg.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(Yg.BEFORE_UNGROUP,t)),this.target=Ag.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(Yg.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(Yg.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Yg.OPEN,t)}closeGroup(t){this.emitGroupEvent(Yg.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Yg.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!so.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 Yg(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||Ug.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}Ug.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(Ng.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Ng.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Ng.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Ng.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Ng(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&&(Ag.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Ag.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_(jo.START,this.onRenderStart,this),i&&i.on_(Do.SCROLL,this.onChildScroll,this),t.on_(jo.CHILD_START,this.onAppRenderStart,this),t.on_(Go.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())}},ge([(t,e)=>{sr(t,e,{get(){const{config:t,element:e,dragPoint:i,editBox:r,app:o}=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 r.config&&Object.assign(a,r.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"),n(a.lockRatio)&&(a.lockRatio=!0))),s(a.dragLimitAnimate)&&(a.dragLimitAnimate=o&&o.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],t.Editor.prototype,"mergeConfig",void 0),ge([jp(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof uh?i:new uh(i),t.multiple&&Mg(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new Vp(Vp.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new Vp(Vp.AFTER_SELECT,s))})],t.Editor.prototype,"target",void 0),ge([jp(function(t,e){t.emitEvent(new Vp(Vp.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],t.Editor.prototype,"hoverTarget",void 0),t.Editor=ge([Yr($g,["editBox","editTool","emitEvent"])],t.Editor);class Qg{static registerInnerEditor(){Ug.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 Qg{static registerEditTool(){Ug.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach(t=>{t.moveWorld(e,i)}),n.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.scaleOfWorld(n,e,i,o)}),o.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:n}=t,{app:r,list:o}=n;r.lockLayout(),o.forEach(t=>{const r="scale"!==n.getEditSize(t);i?t.transformWorld(i,r):t.rotateOfWorld(s,e)}),r.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:n,editor:r}=t,{app:o,list:a}=r;o.lockLayout(),a.forEach(t=>{const o="scale"!==r.getEditSize(t);s?t.transformWorld(s,o):t.skewOfWorld(n,e,i,o)}),o.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=ge([Fg()],t.EditTool);const{left:t_,right:e_}=t.Direction9,{move:i_,copy:s_,toNumberPoints:n_}=lt;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,r=t.target,o=i===t_;if(r.pathInputed){const{path:t}=r.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,r.path=t}else if(r.points){const{points:t}=r,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,o,n,this.getInnerMove(r,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,r.points=t}else{const t={x:0,y:0},{toPoint:i}=r;r.rotation=0,this.dragPoint(t,i,o,n,this.getInnerMove(r,e,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(i,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(i,null,null,!0),r.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=n_(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,n){const{x:r,y:o}=n;i?(i_(t,r,o),s&&i_(e,-r,-o)):(s&&i_(t,-r,-o),i_(e,r,o))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:n}=t,r=this.editor.element;let o,a;if(r.pathInputed?o=this.getFromToByPath(r.__.path):r.points&&(o=this.getFromToByPoints(r.__.points)),o){const{from:i,to:a}=o;r.innerToWorld(i,i,!1,t),r.innerToWorld(a,a,!1,t),n.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),s_(s[7],i),s_(e[7],i),s_(s[3],a),s_(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===t_||t===e_,s[t].visible=a,e[t].visible=!o&&a}},t.LineEditTool=ge([Fg()],t.LineEditTool);const{M:r_,L:o_,C:a_,Q:h_,Z:l_,N:d_,D:c_,X:u_,G:p_,F:g_,O:__,P:f_,U:m_}=Oe,y_={scale(t,e,i){if(!t)return;let s,n=0,r=t.length;for(;n<r;)switch(s=t[n],s){case r_:case o_:v_(t,e,i,n,1),n+=3;break;case a_:v_(t,e,i,n,3),n+=7;break;case h_:v_(t,e,i,n,2),n+=5;break;case l_:n+=1;break;case d_:v_(t,e,i,n,2),n+=5;break;case c_:v_(t,e,i,n,2),n+=9;break;case u_:v_(t,e,i,n,2),n+=6;break;case p_:v_(t,e,i,n,2),n+=9;break;case g_:v_(t,e,i,n,2),n+=5;break;case __:t[n]=p_,t.splice(n+4,0,t[n+3],0),v_(t,e,i,n,2),n+=9,r+=2;break;case f_:t[n]=g_,t.splice(n+4,0,t[n+3]),v_(t,e,i,n,2),n+=5,r+=1;break;case m_:v_(t,e,i,n,2),n+=6}},scalePoints(t,e,i,s,n){for(let r=n?s+1:0,o=n?r+2*n:t.length;r<o;r+=2)t[r]*=e,t[r+1]*=i}},{scalePoints:v_}=y_,x_=$.get(),{topLeft:w_,top:E_,topRight:b_,right:k_,bottom:S_,left:B_}=t.Direction9;function T_(t,e,i){t.pathInputed?P_(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function P_(t,e,i){y_.scale(t.__.path,e,i),t.path=t.__.path}function L_(t,e,i){const{points:s}=t;d(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):y_.scalePoints(s,e,i),t.points=s}function R_(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)x_.a=e,x_.d=i,s[t].transform(x_,!0)}const C_=t.Leaf.prototype;function O_(e,i,s){M_(e.parentApp?e.parentApp:e,i),e.isApp||s||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,t=>{e.zoomLayer.move(e.getValidMove(t.moveX,t.moveY,!1))}),e.on_(t.MoveEvent.END,t=>{so.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 M_(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&p.assign(i,e),p.assign(t.config,i,t.userConfig)}C_.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))},C_.__scaleResize=function(t,e){T_(this,t,e)},C_.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},C_.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:n}=this,r=i&&i.editor,o=r&&r.dragPoint;if(this.__.resizeFontSize||n&&"font-size"===n.editSize||o&&"font-size"===r.mergedConfig.editSize)!function(t,e,i,n){let r=e;if(!s(n)){const s=t.__layout;let{width:o,height:a}=s.boxBounds;switch(o*=i-e,a*=e-i,n){case E_:case S_:r=i,s.affectScaleOrRotation?t.moveInner(-o/2,0):t.x-=o/2;break;case B_:case k_:s.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case w_:case b_:s.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=r;const o=t.__,{padding:a}=o;a&&(t.padding=l(a)?a.map(t=>t*r):a*r),o.__autoWidth||(t.width*=r),o.__autoHeight||(t.height*=r)}(this,t,e,o&&o.direction);else{const{__autoWidth:i,__autoHeight:s,textAlign:n,verticalAlign:r}=this.__,{boxBounds:o}=this.__layout;i&&"left"!==n&&1!==t&&(this.x+=o.x),s&&"top"!==r&&1!==e&&(this.y+=o.y),T_(this,t,e)}},t.Path.prototype.__scaleResize=function(t,e){P_(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?P_(this,t,e):this.points?L_(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?P_(this,t,e):this.points?L_(this,t,e):T_(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){R_(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||T_(this,t,e),i&&R_(this,t,e)},re.add("resize"),re.add("editor","resize"),oe.editor=function(e,i){const s=new t.Editor(e);return i&&i.sky.add(i.editor=s),s},t.Box.addAttr("textBox",!1,lr),t.UI.addAttr("editConfig",void 0,lr),t.UI.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),lr),t.UI.addAttr("editInner","PathEditor",lr),t.Group.addAttr("editInner","",lr),t.Text.addAttr("editInner","TextEditor",lr),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 D_=$t.get("LeaferTypeCreator"),I_={list:{},register(t,e){A_[t]&&D_.repeat(t),A_[t]=e},run(t,e){const i=A_[t];i&&i(e)}},{list:A_,register:W_}=I_;W_("viewport",O_),W_("custom",function(t){O_(t,null,!0)}),W_("design",function(t){O_(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),W_("document",function(t){O_(t,{zoom:{min:1},move:{scroll:"limit"}})});const F_={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=lt.getCenter(e.from,i.from),n=lt.getCenter(e.to,i.to),r={x:n.x-s.x,y:n.y-s.y},o=lt.getDistance(e.from,i.from);return{move:r,scale:lt.getDistance(e.to,i.to)/o,rotation:lt.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}=z_,s=z_.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),z_.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)?z_.getType(i.totalData,e):"none"},add(t,e){e&&(lt.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=z_;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},z_=F_,{abs:U_,max:H_}=Math,{sign:N_,within:Y_}=W,X_={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const r=U_(s),o=U_(n);return r>50&&(s=H_(50,r/3)*N_(s)),o>50&&(n=H_(50,o/3)*N_(n)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:r}=e;const o=t.deltaY||t.deltaX;if(n?(i="mouse"===n||!t.deltaX&&(y.intWheelDeltaY?Math.abs(o)>17:Math.ceil(o)!==o),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){r=Y_(r,0,1);const i=t.deltaY?e.delta.y:e.delta.x,n=Y_(1-U_(o)/(4*i)*r,.5,2);s=o>0?n:1/n}return s}};let V_,j_,G_,K_;class Z_{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),V_=0,j_=0,this.moveData=Object.assign(Object.assign({},e),{moveX:0,moveY:0,totalX:V_,totalY:j_}),i.emit(t.MoveEvent.START,this.moveData)),e.path=this.moveData.path,e.totalX=V_+=e.moveX,e.totalY=j_+=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),G_=1,this.zoomData=Object.assign(Object.assign({},e),{scale:1,totalScale:G_}),i.emit(t.ZoomEvent.START,this.zoomData)),e.path=this.zoomData.path,e.totalScale=G_*=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),K_=0,this.rotateData=Object.assign(Object.assign({},e),{rotation:0,totalRotation:K_}),i.emit(t.RotateEvent.START,this.rotateData)),e.path=this.rotateData.path,e.totalRotation=K_+=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:V_,totalY:j_})),s&&e.emit(t.ZoomEvent.END,Object.assign(Object.assign({},s),{totalScale:G_})),n&&e.emit(t.RotateEvent.END,Object.assign(Object.assign({},n),{totalRotation:K_})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const q_=t.Leafer.prototype,J_=new Gt,$_=new gt;function Q_(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function tf(t,e){return Object.assign(Object.assign({},e),{scale:t})}q_.initType=function(t){I_.run(t,this)},q_.getValidMove=function(t,e,i=!0){const{scroll:s,disabled:n}=this.app.config.move;if($_.set(t,e),s){const t=!0===s?"":s;t.includes("x")?$_.y=0:t.includes("y")?$_.x=0:Math.abs($_.x)>Math.abs($_.y)?$_.y=0:$_.x=0,i&&t.includes("limit")&&(J_.set(this.__world).addPoint(this.zoomLayer),kd.getValidMove(J_,this.canvas.bounds,"inner",$_,!0),t.includes("x")?$_.y=0:t.includes("y")&&($_.x=0))}return{x:n?0:$_.x,y:n?0:$_.y}},q_.getValidScale=function(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s,disabled:n}=this.app.config.zoom,r=Math.abs(e*t);return i&&r<i?t=i/e:s&&r>s&&(t=s/e),n?1:t};const ef=jd.prototype;ef.createTransformer=function(){this.transformer=new Z_(this)},ef.move=function(t){this.transformer.move(t)},ef.zoom=function(t){this.transformer.zoom(t)},ef.rotate=function(t){this.transformer.rotate(t)},ef.transformEnd=function(){this.transformer.transformEnd()},ef.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 r=e.getScale?e.getScale(t,e):X_.getScale(t,e);if(1!==r)this.zoom(tf(r,t));else{const s=e.getMove?e.getMove(t,e):X_.getMove(t,e);i.snap&&lt.round(s),this.move(Q_(s,t))}},ef.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=F_.getData(e),{moving:r,zooming:o,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(F_.detect(n,d(s)?s:{})){case"move":r=!0;break;case"zoom":o=!0;break;case"rotate":a=!0;break;default:return}F_.reset()}r||(n.center=F_.state.center)}else r=o=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}))),o&&this.zoom(tf(n.scale,t)),r&&this.move(Q_(n.move,t))};const sf=Ad.prototype,{abs:nf}=Math;function rf(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}sf.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=nf(i),r=nf(s),o=e?1:.1,h=this.canAnimate&&this.moving&&(n>o||r>o)&&this.interaction.m.dragAnimate;if(h){const o="touch"===t.pointerType?3:1,l=70;n*(e=e?a(h)?h:.95:o)>l?e=l/n:r*e>l&&(e=l/r),t=Object.assign({},t),lt.move(t,i*e,s*e),this.drag(t),this.animate(()=>{this.dragEnd(t,1)})}return h},sf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},sf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},sf.autoMoveOnDragOut=function(t){const{interaction:e,downData:i,canDragOut:s}=this,{autoDistance:n,dragOut:r}=e.m;if(!r||!s||!n)return;const o=e.shrinkCanvasBounds,{x:a,y:h}=o,l=Yt.maxX(o),d=Yt.maxY(o),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let p=0,g=0;this.autoMoveTimer=setInterval(()=>{p+=c,g+=u,lt.move(i,c,u),lt.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:p,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},sf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},re.add("viewport"),re.add("view"),t.Leafer.prototype.zoom=function(t,e,i,s){let o;this.killAnimate(),c(e)?(o=e.padding,i=e.scroll,s=e.transition):o=e;const{zoomLayer:h}=this,u=this.canvas.bounds.clone().shrink(n(o)?30:o),p=new Gt,g={x:u.x+u.width/2,y:u.y+u.height/2};let _;const{x:f,y:m,scaleX:y,scaleY:v}=h.__;if(r(t))switch(t){case"in":_=rf(y,"in");break;case"out":_=rf(y,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new Gt(this.boxBounds)).height=0;break;case"fit-height":(t=new Gt(this.boxBounds)).width=0}else a(t)&&(_=t/y);if(_)_=this.getValidScale(_),h.scaleOfWorld(g,_,_,!1,s);else if(d(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=l(t);if(n||t.tag){const e=n?t:[t];p.setListWithFn(e,uo.worldBounds)}else{const e=function(t,e){let i,{x:s,y:n,width:r,height:o}=t;return o||(o=r*(e.height/e.width),i=!0),r||(r=o*(e.width/e.height),i=!0),i?{x:s,y:n,width:r,height:o}:t}(t,u);p.set(h.getWorldBounds(e))}const{width:r,height:o}=p;let a=u.x-p.x,d=u.y-p.y;return i?(a+=Math.max((u.width-r)/2,0),d+=Math.max((u.height-o)/2,0)):(_=this.getValidScale(Math.min(u.width/r,u.height/o)),a+=(u.width-r*_)/2,d+=(u.height-o*_)/2,lt.scaleOf(e,p,_),p.scaleOf(p,_),e.scaleX*=_,e.scaleY*=_),"x"===i?d=0:"y"===i&&(a=0),lt.move(e,a,d),p.move(a,d),h.set(e,s),p}return h.worldBoxBounds};class of 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&&p.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:r}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(r))return;this.scrollBounds=new Gt(r);const o=n.bounds.clone().shrink(i),a=o.clone().add(r),h=this.ratioX=o.width/a.width,l=this.ratioY=o.height/a.height,d=(o.x-a.x)/a.width,c=(o.y-a.y)/a.height,u=h<1,p=l<1,{scrollXBar:g,scrollYBar:_}=this,{x:f,y:m,width:y,height:v}=o.shrink([2,p?_.width+6:2,u?g.height+6:2,2]);g.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:p})}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_(jo.BEFORE,()=>this.update(!0)),this.target.leafer.on_(Yo.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}re.add("scroll");class af extends hl{}function hf(t){return or(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,wr(this)}}}))}t.Arrow=class extends t.Line{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Hh.register(t,e)}},ge([Ir(af)],t.Arrow.prototype,"__",void 0),ge([hf("angle")],t.Arrow.prototype,"endArrow",void 0),t.Arrow=ge([Xr()],t.Arrow);const{M:lf,L:df,C:cf,Q:uf,O:pf}=Oe,{rotate:gf,copyFrom:_f,scale:ff}=lt,mf={},yf={layout(t,e,i,s,n,r,o){let a,h,l=0,d=t.length;for(;l<d;)switch(a=t[l],a){case lf:case df:vf(t,l+1,e,i,s,n,r,o),l+=3;break;case cf:for(h=1;h<6;h+=2)vf(t,l+h,e,i,s,n,r,o);l+=7;break;case uf:for(h=1;h<4;h+=2)vf(t,l+h,e,i,s,n,r,o);l+=5;break;case pf:t[l+1]+=e,t[l+2]+=i,s&&(t[l+3]*=s),r&&(t[l+4]+=r,t[l+5]+=r),l+=7}},rotate(t,e,i){yf.layout(t,0,0,1,1,e,i)}};function vf(t,e,i,s,n,r,o,a){_f(mf,t[e],t[e+1]),o&&gf(mf,o,a),n&&ff(mf,n,r),t[e]=i+mf.x,t[e+1]=s+mf.y}const{layout:xf,rotate:wf}=yf,{getAngle:Ef}=lt,bf={x:-.5},kf={connect:bf,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},Sf={connect:bf,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},Bf={connect:bf,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]},Tf={connect:bf,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]},Pf={offset:bf,path:[...Bf.path],dashPath:[1,-2.5,0,2,-1,0]};wf(Pf.path,180,{x:-1.5,y:0});const Lf={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},Rf={connect:{x:.5},path:[...Lf.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},Cf={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]},Of={path:[...Cf.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},Mf=p.clone(Cf),Df=p.clone(Of);wf(Mf.path,45),wf(Df.path,45);const If={angle:kf,"angle-side":Sf,arrow:Tf,triangle:Bf,"triangle-flip":Pf,circle:Rf,"circle-line":Lf,square:Of,"square-line":Cf,diamond:Df,"diamond-line":Mf,mark:{offset:bf,path:[1,0,-2,2,0,2]}};function Af(t,e,i,s,n,r,o){let a,h;const{strokeCap:l,strokeJoin:c}=t.__;d(e)?e.type?(h=e.scale,a=If[e.type]):a=e:a=If[e];const{offset:u,connect:p,path:g,dashPath:_}=a;let f=p?p.x:0,m=u?u.x:0;const y=[...g];return o&&_&&y.push(..._),"none"!==l&&(f-=.5),u&&("round"===c&&u.roundJoin?m+=u.roundJoin:"bevel"===c&&u.bevelJoin&&(m+=u.bevelJoin)),h&&xf(y,0,0,h,h),m&&xf(y,m,0),xf(y,s.x,s.y,n,n,Ef(i,s)),r.x=(f+m)*n,y}const{M:Wf,L:Ff,C:zf,Q:Uf,Z:Hf,N:Nf,D:Yf,X:Xf,G:Vf,F:jf,O:Gf,P:Kf,U:Zf}=Oe,{copy:qf,copyFrom:Jf,getDistancePoint:$f}=lt,Qf={},tm={},em={},im={},sm={},nm={list:If,addArrows(t){const{startArrow:e,endArrow:i,strokeWidth:s,dashPattern:n,__pathForRender:r,cornerRadius:o}=t.__,a=!o;let h,l=0,d=r.length,c=0,u=e&&"none"!==e;for(;l<d;){switch(h=r[l],h){case Wf:case Ff:(c<2||l+6>=d)&&(Jf(sm,r[l+1],r[l+2]),!c&&u&&qf(tm,sm)),l+=3;break;case zf:(1===c||l+7>=d-3)&&rm(r,im,sm,l+3),l+=7;break;case Uf:(1===c||l+5>=d-3)&&rm(r,im,sm,l+1),l+=5;break;case Hf:return;case Nf:l+=5;break;case Yf:l+=9;break;case Xf:l+=6;break;case Vf:l+=9;break;case jf:l+=5;break;case Gf:l+=7;break;case Kf:l+=4;break;case Zf:(1===c||l+6>=d-3)&&(rm(r,im,sm,l+1),l+6!==d&&(sm.x-=(sm.x-im.x)/10,sm.y-=(sm.y-im.y)/10)),l+=6}if(c++,1===c&&h!==Wf)return;if(2===c&&u&&qf(em,h===Ff?sm:im),l===d){const o=t.__.__pathForRender=a?[...r]:r,d=t.__.__pathForArrow=[];if(u){const i=Af(t,e,em,tm,s,Qf,!!n);n?d.push(...i):o.push(...i),Qf.x&&($f(tm,em,-Qf.x,!0),o[1]=em.x,o[2]=em.y)}if(i&&"none"!==i){const e=Af(t,i,im,sm,s,Qf,!!n);if(n?d.push(...e):o.push(...e),Qf.x){let t;switch($f(sm,im,-Qf.x,!0),h){case Ff:t=l-3+1;break;case zf:t=l-7+5;break;case Uf:t=l-5+3;break;case Zf:t=l-6+3}t&&om(o,im,t)}}}else qf(im,sm)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function rm(t,e,i,s){Jf(e,t[s],t[s+1]),Jf(i,t[s+2],t[s+3])}function om(t,e,i){t[i]=e.x,t[i+1]=e.y}re.add("arrow"),t.UI.addAttr("startArrow","none",hf),t.UI.addAttr("endArrow","none",hf),Object.assign(Hh,nm),Object.assign(Nh,{strokeArrow(t,e,i,s){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});const{Yes:am,NoAndSkip:hm,YesAndSkip:lm}=t.Answer,dm={},cm={},um={};class pm{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,n){switch(typeof t){case"number":const r=this.getByInnerId(t,e);return i?r:r?[r]:[];case"string":switch(t[0]){case"#":dm.id=t.substring(1),t=dm;break;case".":cm.className=t.substring(1),t=cm;break;default:um.tag=t,t=um}case"object":if(s(t.id)){if(t.tag){const{tag:s}=t,n=l(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?p.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,n)}}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&&so.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,r;for(let o=0,a=t.length;o<a;o++){if(n=t[o],r=e(n,s),r===am||r===lm){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&r<hm&&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_(Oo.REMOVE,this.__onRemoveChild,this),this.target.on_(Do.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 gm=t.UI.prototype;function _m(t){return t.leafer?t.leafer.selector:y.selector||(y.selector=oe.selector())}gm.find=function(t,e){return _m(this).getBy(t,this,!1,e)},gm.findOne=function(t,e){return _m(this).getBy(t,this,!0,e)},re.add("find"),oe.finder=function(t){return new pm(t)};const{setPoint:fm,addPoint:mm,toBounds:ym}=yt;const vm={syncExport(t,e,i){let n;Gh.running=!0;try{const r=Xn.fileType(e),o=e.includes(".");i=Xn.getExportOptions(i);const{toURL:a}=y,{download:h}=y.origin;if("json"===r)o&&h(a(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!o||t.toJSON(i.json)};else if("svg"===r)o&&h(a(t.toSVG(),"svg"),e),n={data:!!o||t.toSVG()};else{let r,o,a=1,h=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:u}=t,{slice:p,clip:g,trim:_,screenshot:f,padding:m,onCanvas:v}=i,x=s(i.smooth)?!c||c.config.smooth:i.smooth,w=i.contextSettings||(c?c.config.contextSettings:void 0),E=d&&f&&s(i.fill)?t.fill:i.fill,b=Xn.isOpaqueImage(e)||E,k=new ft;if(f)r=!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":k.set(l);break;case"local":k.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:k.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,h/=h/i.scaleY}r=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};W.getScaleData(i.scale,i.size,r,S);let B=i.pixelRatio||1,{x:T,y:P,width:L,height:R}=new Gt(r).scale(S.scaleX,S.scaleY);g&&(T+=g.x,P+=g.y,L=g.width,R=g.height);const C={exporting:!0,matrix:k.scale(1/S.scaleX,1/S.scaleY).invert().translate(-T,-P).withScale(1/a*S.scaleX,1/h*S.scaleY)};let O,M=oe.canvas({width:Math.floor(L),height:Math.floor(R),pixelRatio:B,smooth:x,contextSettings:w});p&&(O=t,O.__worldOpacity=0,t=c||t,C.bounds=M.bounds),M.save();const D=u&&!s(E),I=t.get("fill");if(D&&(t.fill=""),y.render(t,M,C),D&&(t.fill=I),M.restore(),O&&O.__updateWorldOpacity(),_){o=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,r,o,a=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=a%e,r=(a-n)/e,o?mm(o,n,r):fm(o={},n,r)),a++;const h=new Gt;return o&&(ym(o,h),h.scale(1/t.pixelRatio).ceil()),h}(M);const t=M,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:B};M=oe.canvas(s),M.copyWorld(t,o,s),t.destroy()}if(m){const[t,e,i,s]=W.fourNumber(m),n=M,{width:r,height:o}=n;M=oe.canvas({width:r+s+e,height:o+t+i,pixelRatio:B}),M.copyWorld(n,n.bounds,{x:s,y:t,width:r,height:o}),n.destroy()}b&&M.fillWorld(M.bounds,E||"#FFFFFF","destination-over"),v&&v(M);n={data:"canvas"===e?M:M.export(e,i),width:M.pixelWidth,height:M.pixelHeight,renderBounds:r,trimBounds:o};const A=c&&c.app;A&&A.canvasManager&&A.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return Gh.running=!1,n},export(t,e,i){return Gh.running=!0,function(t){xm||(xm=new Kn);return new Promise(e=>{xm.add(()=>_e(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const r=()=>_e(this,void 0,void 0,function*(){if(!qn.isComplete)return y.requestRender(r);const o=Gh.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),wm(t);const{leafer:o}=t;o?o.waitViewCompleted(r):r()}))}};let xm;function wm(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>wm(t))}const Em=Le.prototype,bm=$t.get("@leafer-in/export");Em.export=function(t,e){const{quality:i,blob:s}=Xn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},Em.toBlob=function(t,e){return new Promise(i=>{y.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{bm.error(t),i(null)})})},Em.toDataURL=function(t,e){return y.origin.canvasToDataURL(this.view,t,e)},Em.saveAs=function(t,e){return new Promise(i=>{y.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{bm.error(t),i(!1)})})},re.add("export"),Object.assign(Gh,vm),t.UI.prototype.export=function(t,e){return Gh.export(this,t,e)},t.UI.prototype.syncExport=function(t,e){return Gh.syncExport(this,t,e)};const km={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},Sm={top:"flex-start",middle:"center",bottom:"flex-end"},Bm={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function Tm(t,e,i){const{style:n}=t,{fill:o,padding:a,textWrap:h,textOverflow:c,textDecoration:u}=e;let p;n.fontFamily=e.fontFamily,n.fontSize=e.fontSize*i+"px",function(t,e){let i="black";l(e)&&(e=e[0]);if(d(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:s(e.r)||(i=zh.string(e))}else i=e;t.color=i}(n,o),n.fontStyle=e.italic?"italic":"normal",n.fontWeight=e.fontWeight,d(u)?(p=u.type,u.color&&(n.textDecorationColor=zh.string(u.color))):p=u,n.textDecoration=Bm[p],n.textTransform=km[e.textCase],n.textAlign="both"===e.textAlign?"justify":e.textAlign,n.display="flex",n.flexDirection="column",n.justifyContent=Sm[e.verticalAlign],n.lineHeight=(e.__.__lineHeight||0)*i+"px",n.letterSpacing=(e.__.__letterSpacing||0)*i+"px",n.whiteSpace="none"===h||e.__.__autoWidth?"nowrap":"normal",n.wordBreak="break"===h?"break-all":"normal",n.textIndent=(e.paraIndent||0)*i+"px",n.padding=l(a)?a.map(t=>t*i+"px").join(" "):(a||0)*i+"px",n.textOverflow="show"===c?"":"hide"===c?"clip":c}t.TextEditor=class extends Qg{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"),{style:r}=n;n.contentEditable="true",r.position="fixed",r.transformOrigin="left top",r.boxSizing="border-box",this.isHTMLText?n.innerHTML=String(s.text):n.innerText=String(s.text);const{view:o}=e.app;(this.inBody=o instanceof HTMLCanvasElement)?document.body.appendChild(n):o.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];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 r=i.split("\n"),o=document.createDocumentFragment();r.forEach((t,e)=>{e>0&&o.appendChild(document.createElement("br")),o.appendChild(document.createTextNode(t))}),n.insertNode(o),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,r=0;i*=e,s*=e;const o=t.__;if(o.__autoWidth)switch(i+=20,o.textAlign){case"center":n=o.autoSizeAlign?-i/2:-10;break;case"right":n=o.autoSizeAlign?-i:-20}if(o.__autoHeight)switch(s+=20,o.verticalAlign){case"middle":r=o.autoSizeAlign?-s/2:-10;break;case"bottom":r=o.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:p,f:g}=new ft(t.worldTransform).scale(1/e).translateInner(n,r),{style:_}=this.editDom;_.transform=`matrix(${l},${d},${c},${u},${p},${g})`,_.left=a+"px",_.top=h+"px",_.width=i+"px",_.height=s+"px",this.isHTMLText||Tm(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=ge([zg()],t.TextEditor),re.add("text-editor","editor");class Pm extends ml{setText(t){this._text=t,this.__htmlChanged=!0}}const Lm={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:"≥"};return 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(),r=s+10,o=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${n}">\n <foreignObject width="${r}" 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(o)),t.__naturalWidth=r/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 r=t.indexOf(";",n+1);if(r>n+1&&(e=t.slice(n+1,r),i=Lm[e],void 0!==i)){s+=i,n=r+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){r(t)?Lm[t]=e:Object.assign(Lm,t)}},ge([Ir(Pm)],t.HTMLText.prototype,"__",void 0),ge([_r("")],t.HTMLText.prototype,"text",void 0),ge([lr("TextEditor")],t.HTMLText.prototype,"editInner",void 0),ge([kr(!1)],t.HTMLText.prototype,"textEditing",void 0),t.HTMLText=ge([Xr()],t.HTMLText),re.add("html"),t.AlignHelper=Bt,t.AroundHelper=bt,t.ArrowData=af,t.AutoBounds=Zt,t.BezierHelper=ri,t.Bounds=Gt,t.BoundsEvent=Wo,t.BoundsHelper=Yt,t.BoxData=rl,t.BranchHelper=fo,t.BranchRender=Ca,t.CanvasData=yl,t.CanvasManager=pe,t.ChildEvent=Oo,t.ColorConvert=zh,t.Creator=oe,t.Cursor=Gd,t.DataHelper=p,t.Debug=$t,t.DragBoundsHelper=kd,t.Dragger=Ad,t.EditBox=Tg,t.EditDataHelper=vg,t.EditPoint=kg,t.EditSelect=og,t.EditSelectHelper=ig,t.EditToolCreator=Ug,t.EditorEvent=Vp,t.EditorGroupEvent=Yg,t.EditorHelper=Ag,t.EditorMoveEvent=Kg,t.EditorRotateEvent=qg,t.EditorScaleEvent=Zg,t.EditorSkewEvent=Jg,t.Effect=Vh,t.EllipseData=dl,t.EllipseHelper=gi,t.Event=Co,t.EventCreator=ce,t.Eventer=ta,t.Export=Gh,t.FileHelper=Xn,t.Filter=jh,t.Finder=pm,t.FourNumberHelper=T,t.FrameData=al,t.GroupData=nl,t.HTMLTextData=Pm,t.HitCanvasManager=Kd,t.ImageData=ml,t.ImageEvent=Ao,t.ImageManager=$n,t.IncrementId=x,t.InnerEditor=Qg,t.InnerEditorEvent=Ng,t.InteractionBase=jd,t.InteractionHelper=Rd,t.Keyboard=dd,t.LayoutEvent=Vo,t.Layouter=Lh,t.LeafBounds=Pa,t.LeafBoundsHelper=uo,t.LeafData=_,t.LeafDataProxy=pa,t.LeafEventer=ca,t.LeafHelper=so,t.LeafLayout=Ro,t.LeafLevelList=ph,t.LeafList=uh,t.LeafMatrix=xa,t.LeafRender=La,t.LeaferCanvas=gh,t.LeaferCanvasBase=Le,t.LeaferData=ol,t.LeaferEvent=Go,t.LeaferImage=ir,t.LeaferTypeCreator=I_,t.LineData=hl,t.MathHelper=W,t.Matrix=ft,t.MatrixHelper=$,t.MultiTouchHelper=F_,t.MyDragEvent=Pd,t.MyImage=sd,t.MyPointerEvent=Bd,t.MyTouchEvent=Ld,t.NeedConvertToCanvasCommandMap=De,t.OneRadian=z,t.PI2=U,t.PI_2=H,t.Paint=Nh,t.PaintGradient=Xh,t.PaintImage=Yh,t.PathArrow=Hh,t.PathArrowModule=nm,t.PathBounds=On,t.PathCommandDataHelper=ws,t.PathCommandMap=Oe,t.PathConvert=$i,t.PathCorner=zn,t.PathCreator=Fs,t.PathData=pl,t.PathDrawer=Qs,t.PathHelper=Re,t.PathMatrixHelper=yf,t.PathNumberCommandLengthMap=Fe,t.PathNumberCommandMap=We,t.PenData=gl,t.Picker=Mh,t.Platform=y,t.Plugin=re,t.Point=gt,t.PointHelper=lt,t.PointerButton=cd,t.PolygonData=cl,t.PropertyEvent=Do,t.RectData=ll,t.RectHelper=ze,t.RectRender=Sl,t.RenderEvent=jo,t.Renderer=Ch,t.ResizeEvent=Yo,t.Resource=qn,t.Run=ie,t.ScrollBar=of,t.SelectArea=eg,t.Selector=Dh,t.StarData=ul,t.State=Kh,t.StringNumberMap=qt,t.Stroker=tg,t.TaskItem=Gn,t.TaskProcessor=Kn,t.TextConvert=Fh,t.TextData=fl,t.TransformTool=$g,t.Transformer=Z_,t.Transition=Zh,t.TwoPointBoundsHelper=yt,t.UIBounds=wl,t.UICreator=he,t.UIData=il,t.UIEvent=ud,t.UIRender=bl,t.UnitConvert=Uh,t.WaitHelper=xo,t.WatchEvent=Xo,t.Watcher=yh,t.WheelEventHelper=X_,t.addViewport=O_,t.addViewportConfig=M_,t.affectRenderBoundsType=br,t.affectStrokeBoundsType=xr,t.arrowType=hf,t.attr=ar,t.autoLayoutType=ur,t.boundsType=_r,t.canvasPatch=Yn,t.canvasSizeAttrs=Pe,t.createAttr=function(t){return(e,i)=>{sr(e,i,rr(i,t))}},t.createDescriptor=rr,t.cursorType=Dr,t.dataProcessor=Ir,t.dataType=lr,t.decorateLeafAttr=or,t.defineDataProcessor=Ar,t.defineKey=sr,t.defineLeafAttr=hr,t.dimType=Sr,t.doBoundsType=mr,t.doStrokeType=wr,t.effectType=Ih,t.emptyData=i,t.eraserType=Or,t.extraPropertyEventMap=Io,t.getBoundsData=Y,t.getDescriptor=nr,t.getMatrixData=X,t.getPointData=N,t.hitType=Mr,t.isArray=l,t.isData=c,t.isEmptyData=u,t.isFinite=o,t.isNull=n,t.isNumber=a,t.isObject=d,t.isString=r,t.isUndefined=s,t.layoutProcessor=function(t){return(e,i)=>{sr(e,"__LayoutProcessor",{get:()=>t})}},t.leaferTransformAttrMap=$o,t.maskType=Cr,t.naturalBoundsType=fr,t.opacityType=Br,t.path=Un,t.pathInputType=yr,t.pathType=vr,t.pen=Hn,t.positionType=dr,t.registerEditTool=Fg,t.registerInnerEditor=zg,t.registerUI=Xr,t.registerUIEvent=Vr,t.resizeType=Ah,t.rewrite=Ur,t.rewriteAble=Hr,t.rotationType=gr,t.scaleType=pr,t.scrollType=cr,t.sortType=Rr,t.strokeType=Er,t.surfaceType=kr,t.tempBounds=Kt,t.tempMatrix=mt,t.tempPoint=_t,t.tryToNumber=function(t){return"string"==typeof t&&h.test(t)?+t:t},t.useCanvas=fh,t.useModule=Yr,t.version="1.10.1",t.visibleType=Tr,t.zoomLayerType=Wh,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