@leafer-editor/worker 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var t;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(t||(t={}));const e={};function i(t){return void 0===t}function s(t){return null==t}function n(t){return"string"==typeof t}const{isFinite:r}=Number;function o(t){return"number"==typeof t}const a=/^-?\d+(?:\.\d+)?$/;function h(t){return"string"==typeof t&&a.test(t)?+t:t}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 _={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,s)=>(s.forEach(s=>{i(e[s])||(t[s]=e[s])}),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}=_;class p{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(!i(e))return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let s;for(let n in this)"_"!==n[0]&&(s=e?e[n]:void 0,t[n]=i(s)?this[n]:s);return t}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];if(!i(e))return e}if("path"!==t||this.__pathInputed)return this["_"+t]}__removeInput(t){this.__input&&!i(this.__input[t])&&(this.__input[t]=void 0)}__getInputData(t,e){const s={};if(t)if(l(t))for(let e of t)s[e]=this.__getInput(e);else for(let e in t)s[e]=this.__getInput(e);else{let t,e,{__input:n}=this;s.tag=this.__leaf.tag;for(let r in this)if("_"!==r[0]&&(t=this["_"+r],!i(t))){if("path"===r&&!this.__pathInputed)continue;e=n?n[r]:void 0,s[r]=i(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:i,d:n,e:r,f:o}=this.__leaf.__localMatrix;s.matrix={a:t,b:e,c:i,d:n,e:r,f:o}}return s}__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&&_.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 b,k,E;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)=>R(B,t,e,i,s),toTempAB(t,e,i){E=i?o(t)?e:t:[],o(t)?(b=C(t),k=e):o(e)?(b=t,k=C(e)):(b=t,k=e),4!==b.length&&(b=O(b)),4!==k.length&&(k=O(k))},get(t,e){let s;if(!o(t))switch(t.length){case 4:s=i(e)?t:[...t];break;case 2:s=[t[0],t[1],t[0],t[1]];break;case 3:s=[t[0],t[1],t[2],t[1]];break;case 1:t=t[0];break;default:t=0}if(s||(s=[t,t,t,t]),!i(e))for(let t=0;t<4;t++)s[t]>e&&(s[t]=e);return s},max:(t,e,i)=>o(t)&&o(e)?S(t,e):(L(t,e,i),R(E,S(b[0],k[0]),S(b[1],k[1]),S(b[2],k[2]),S(b[3],k[3]))),add:(t,e,i)=>o(t)&&o(e)?t+e:(L(t,e,i),R(E,b[0]+k[0],b[1]+k[1],b[2]+k[2],b[3]+k[3])),swapAndScale(t,e,i,s){if(o(t))return e===i?t*e:[t*i,t*e];const n=s?t:[],[r,a,h,l]=4===t.length?t:O(t);return R(n,h*i,l*e,r*i,a*e)}},{set:R,get:O,setTemp:C,toTempAB:L}=T,{round:P,pow:M,max:A,floor:D,PI:I}=Math,W={within:(t,e,s)=>(d(e)&&(s=e.max,e=e.min),!i(e)&&t<e&&(t=e),!i(s)&&t>s&&(t=s),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 s=i(e)?1e12:M(10,e);return-0===(t=P(t*s)/s)?0:t},sign:t=>t<0?-1:1,getScaleData(t,e,i,s){if(s||(s={}),e){const t=(o(e)?e:e.width||0)/i.width,n=(o(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){o(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},getFloorScale:(t,e=1)=>A(D(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=I/180,Y=2*I,N=I/2;function X(){return{x:0,y:0}}function H(){return{x:0,y:0,width:0,height:0}}function V(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:U,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:V,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=U(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,s,n,r){const{e:o,f:a}=t;if(s||(s=t),i(n)&&(n=1!==t.a||t.b||t.c||1!==t.d),n){const{a:i,b:n,c:o,d:a}=t;s.a=i*e.a+n*e.c,s.b=i*e.b+n*e.d,s.c=o*e.a+a*e.c,s.d=o*e.b+a*e.d,r&&(s.scaleX=e.scaleX*r.scaleX,s.scaleY=e.scaleY*r.scaleY)}else s.a=e.a,s.b=e.b,s.c=e.c,s.d=e.d,r&&(s.scaleX=e.scaleX,s.scaleY=e.scaleY);s.e=o*e.a+a*e.c+e.e,s.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,s,n,r){const{x:o,y:a,scaleX:h,scaleY:l}=e;if(i(r)&&(r=e.rotation||e.skewX||e.skewY),r){const{rotation:i,skewX:s,skewY:n}=e,r=i*z,o=j(r),a=U(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,(s=s||n)&&Q.translateInner(t,-s.x,-s.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,_,g,p=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=N-(a>0?G(-e):-G(e))}const e=Z(j(u)),i=U(u);d=Z(d),c=Z(c),_=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=_=g=0;return(e=i||e)&&(p+=e.x*n+e.y*o,f+=e.x*r+e.y*a,i||(p-=e.x,f-=e.y)),{x:p,y:f,scaleX:d,scaleY:c,rotation:u,skewX:_,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,s){t.radiusX=e,t.radiusY=i(s)?e:s},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)=>_t(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,s,n,r,o,a,h){i(a)&&(a=s,h=n);const l=t-s,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,n){const r=_t(t,e);return n&&(t=e),s||(e={}),e.x=t.x+st(r)*i,e.y=t.y+it(r)*i,e},toNumberPoints(t){let e=t;return d(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e)=>t.x===e.x&&t.y===e.y,reset(t){dt.reset(t)}},dt=lt,{getDistanceFrom:ct,copy:ut,getAtan2:_t}=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,s){return new gt(lt.getDistancePoint(this,t,e,i,s))}getAngle(t){return lt.getAngle(this,t)}getAtan2(t){return lt.getAtan2(this,t)}isSame(t){return lt.isSame(this,t)}reset(){return lt.reset(this),this}}const pt=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;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(xt||(xt={})),function(t){t[t.topLeft=0]="topLeft",t[t.top=1]="top",t[t.topRight=2]="topRight",t[t.right=3]="right",t[t.bottomRight=4]="bottomRight",t[t.bottom=5]="bottom",t[t.bottomLeft=6]="bottomLeft",t[t.left=7]="left",t[t.center=8]="center",t[t["top-left"]=0]="top-left",t[t["top-right"]=2]="top-right",t[t["bottom-right"]=4]="bottom-right",t[t["bottom-left"]=6]="bottom-left"}(wt||(wt={}));const bt=[{x:0,y:0},{x:.5,y:0},{x:1,y:0},{x:1,y:.5},{x:1,y:1},{x:.5,y:1},{x:0,y:1},{x:0,y:.5},{x:.5,y:.5}];bt.forEach(t=>t.type="percent");const kt={directionData:bt,tempPoint:{},get:Et,toPoint(t,e,i,s,n,r){const o=Et(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={}),kt.toPoint(t,e,i,!0),i)};function Et(t){return n(t)?bt[wt[t]]:t}const{toPoint:St}=kt,Bt={toPoint(t,e,i,s,n,r){St(t,i,s,n,e,r)}},{tempPointBounds:Tt,setPoint:Rt,addPoint:Ot,toBounds:Ct}=yt,{toOuterPoint:Lt}=$,{float:Pt,fourNumber:Mt}=W,{floor:At,ceil:Dt}=Math;let It,Wt,Ft,zt;const Yt={},Nt={},Xt={},Ht={tempBounds:Xt,set(t,e=0,i=0,s=0,n=0){t.x=e,t.y=i,t.width=s,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,i,s,n){const{x:r,y:o,width:a,height:h}=e;if(l(i)){const e=Mt(i);s?Vt.set(t,r+e[3],o+e[0],a-e[1]-e[3],h-e[2]-e[0]):Vt.set(t,r-e[3],o-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Vt.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),Vt.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?jt(e,t):e=t,i||(i=t),e.offsetX=Vt.maxX(i),e.offsetY=Vt.maxY(i),Vt.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)=>(Vt.copy(Xt,t),Vt.toOuterOf(Xt,e),Xt),getOuterOf:(t,e)=>(t=Object.assign({},t),Vt.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 Yt.x=t.x,Yt.y=t.y,Lt(e,Yt,Nt),Rt(Tt,Nt.x,Nt.y),Yt.x=t.x+t.width,Lt(e,Yt,Nt),Ot(Tt,Nt.x,Nt.y),Yt.y=t.y+t.height,Lt(e,Yt,Nt),Ot(Tt,Nt.x,Nt.y),Yt.x=t.x,Lt(e,Yt,Nt),Ot(Tt,Nt.x,Nt.y),Ct(Tt,i)},toInnerOf(t,e,i){i||(i=t),Vt.move(i,-e.e,-e.f),Vt.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Vt.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,r=!0,o){o||(o=e),n(s)&&(s=Vt.getFitScale(t,e,"cover"===s)),Xt.width=r?e.width*=s:e.width*s,Xt.height=r?e.height*=s:e.height*s,Bt.toPoint(i,Xt,t,o,!0,!0)},getSpread(t,e,i){const s={};return Vt.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Vt.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Vt.copyAndSpread(t,t,e,!0,i)},ceil(t){const{x:e,y:i}=t;t.x=At(t.x),t.y=At(t.y),t.width=e>t.x?Dt(t.width+e-t.x):Dt(t.width),t.height=i>t.y?Dt(t.height+i-t.y):Dt(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=Pt(t.x,e),t.y=Pt(t.y,e),t.width=Pt(t.width,e),t.height=Pt(t.height,e)},add(t,e,i){It=t.x+t.width,Wt=t.y+t.height,Ft=e.x,zt=e.y,i||(Ft+=e.width,zt+=e.height),It=It>Ft?It: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=It-t.x,t.height=Wt-t.y},addList(t,e){Vt.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Vt.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Vt.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)):Ut(t,n));r&&Vt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?Rt(Tt,t.x,t.y):Ot(Tt,t.x,t.y)),Ct(Tt,t)},setPoint(t,e){Vt.set(t,e.x,e.y)},addPoint(t,e){Ut(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=Vt.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=Vt.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=Vt.tempToOuterOf(e,i)),!Vt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:r,height:o}=e;return It=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,It=It<Ft?It:Ft,Wt=Wt<zt?Wt:zt,r=It-s,o=Wt-n,{x:s,y:n,width:r,height:o}},intersect(t,e,i){Vt.copy(t,Vt.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){Vt.set(t)}},Vt=Ht,{add:Ut,copy:jt}=Vt;class Gt{get minX(){return Ht.minX(this)}get minY(){return Ht.minY(this)}get maxX(){return Ht.maxX(this)}get maxY(){return Ht.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return d(t)?Ht.copy(this,t):Ht.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 Ht.move(this,t,e),this}scale(t,e,i){return Ht.scale(this,t,e,i),this}scaleOf(t,e,i){return Ht.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Ht.toOuterOf(this,t,e),this}toInnerOf(t,e){return Ht.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Ht.getFitMatrix(this,t,e)}put(t,e,i){Ht.put(this,t,e,i)}spread(t,e){return Ht.spread(this,t,e),this}shrink(t,e){return Ht.shrink(this,t,e),this}ceil(){return Ht.ceil(this),this}unsign(){return Ht.unsign(this),this}float(t){return Ht.float(this,t),this}add(t){return Ht.add(this,t),this}addList(t){return Ht.setList(this,t,!0),this}setList(t){return Ht.setList(this,t),this}addListWithFn(t,e){return Ht.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Ht.setListWithFn(this,t,e),this}setPoint(t){return Ht.setPoint(this,t),this}setPoints(t){return Ht.setPoints(this,t),this}addPoint(t){return Ht.addPoint(this,t),this}getPoints(){return Ht.getPoints(this)}hitPoint(t,e){return Ht.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Ht.hitRadiusPoint(this,t,e)}hit(t,e){return Ht.hit(this,t,e)}includes(t,e){return Ht.includes(this,t,e)}intersect(t,e){return Ht.intersect(this,t,e),this}getIntersect(t,e){return new Gt(Ht.getIntersectData(this,t,e))}isSame(t){return Ht.isSame(this,t)}isEmpty(){return Ht.isEmpty(this)}reset(){Ht.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?n(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 s=se.nameToIdMap[t];i(s)||se.end(s,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,s,n,r,o){le[t]||ae.error("not register "+t);const a=new le[t](e);return i(s)||(a.x=s,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],n(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 _e{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 pe(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=[];let xe=class{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||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:be,pixelScale:ke}=$,{round:Ee}=Math,Se=new Gt,Be=new Gt,Te={width:1,height:1,pixelRatio:1},Re=["width","height","pixelRatio"];class Oe 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;_.copyAttrs(s,t,Re),Re.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&&be(t,e,n),ke(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=Ee(n.e-.5)+.5,n.f=Ee(n.f-.5)+.5):(n.e=Ee(n.e),n.f=Ee(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:s,strokeJoin:n,dashPattern:r,dashOffset:o,miterLimit:a}=t;e&&(e.strokeCap&&(s=e.strokeCap),e.strokeJoin&&(n=e.strokeJoin),i(e.dashPattern)||(r=e.dashPattern),i(e.dashOffset)||(o=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=s,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,Ht.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 Ce={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Le={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Pe=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},Le),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},Ae={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},De=Object.assign(Object.assign({},Ae),Le),Ie=Pe,We={};for(let t in Ie)We[Ie[t]]=t;const Fe={};for(let t in Ie)Fe[Ie[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:Ye,cos:Ne,hypot:Xe,atan2:He,ceil:Ve,abs:Ue,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}=Pe,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,_,g,p,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)),p=Ge(Ke(h-o,2)+Ke(l-a,2)),(g||p)&&(f=g+p,g=y*g/f,p=y*p/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,_,d,c,o,a),u=o+p*h,_=a+p*l);s||t.push(ii,u,_,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){Ce.creator.path=t,Ce.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){Ce.creator.path=[],ze.drawRoundRect(Ce.creator,e,i,s,n,r),t.push(...Ce.convertToCanvasData(Ce.creator.path,!0))},arcTo(t,e,i,s,n,r,o,a,h,l,d){const c=s-e,u=n-i,_=r-s,g=o-n;let p=He(u,c),f=He(g,_);const m=Xe(c,u),y=Xe(_,g);let v=f-p;if(v<0&&(v+=Y),m<1e-12||y<1e-12||v<1e-12||Ue(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-_*u<0,w=x?-1:1,b=a/Ne(v/2),k=s+b*Ne(p+v/2+N*w),E=n+b*Ye(p+v/2+N*w);return p-=N*w,f-=N*w,hi(t,k,E,a,a,0,p/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,_=Ye(u),g=Ne(u);let p=o*z,f=a*z;p>je&&(p-=Y),f<0&&(f+=Y);let m=f-p;m<0?m+=Y:m>Y&&(m-=Y),h&&(m-=Y);const y=Ve(Ue(m/N)),v=m/y,x=Ye(v/4),w=8/3*x*x/Ye(v/2);f=p+v;let b,k,E,S,B,T,R,O,C=Ne(p),L=Ye(p),P=E=g*s*C-_*n*L,M=S=_*s*C+g*n*L,A=e+E,D=i+S;t&&t.push(t.length?ti:Qe,A,D),l&&Ze(l,A,D),c&&Je(c,A,D);for(let r=0;r<y;r++)b=Ne(f),k=Ye(f),E=g*s*b-_*n*k,S=_*s*b+g*n*k,B=e+P-w*(g*s*L+_*n*C),T=i+M-w*(_*s*L-g*n*C),R=e+E+w*(g*s*k+_*n*b),O=i+S+w*(_*s*k-g*n*b),t&&t.push(ei,B,T,R,O,e+E,i+S),l&&ai(e+P,i+M,B,T,R,O,e+E,i+S,l,!0),P=E,M=S,C=b,L=k,p=f,f+=v;d&&Je(d,e+E,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,_,g,p,f,m,y,v=t,x=i,w=n,b=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=s,w=r,b=a),c=-3*v+9*x-9*w+3*b,u=6*v-12*x+6*w,_=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-_/u,0<g&&g<1&&d.push(g)}else m=u*u-4*_*c,y=Math.sqrt(m),m<0||(p=(-u+y)/(2*c),0<p&&p<1&&d.push(p),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,_=3*d*t*t,g=t*t*t;l.x=c*e+u*s+_*r+g*a,l.y=c*i+u*n+_*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:_i}=ri,gi={ellipticalArc(t,e,i,s,n,r,o,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,_=r*z,g=li(_),p=di(_),f=-p*c-g*u,m=-p*u+g*c,v=s*s,x=n*n,w=m*m,b=f*f,k=v*x-v*w-x*b;let E=0;if(k<0){const t=ci(1-k/(v*x));s*=t,n*=t}else E=(o===a?-1:1)*ci(k/(v*w+x*b));const S=E*s*m/n,B=-E*n*f/s,T=ui((m-B)/n,(f-S)/s),R=ui((-m-B)/n,(-f-S)/s);let O=R-T;0===a&&O>0?O-=Y:1===a&&O<0&&(O+=Y);const C=e+c+p*S-g*B,L=i+u+g*S+p*B,P=O<0?1:0;d||y.ellipseToCurve?_i(t,C,L,s,n,r,T/z,R/z,P):s!==n||r?t.push(Pe.G,C,L,s,n,r,T/z,R/z,P):t.push(Pe.O,C,L,s,T/z,R/z,P)}},pi={toCommand:t=>[],toNode:t=>[]},{M:fi,m:mi,L:yi,l:vi,H:xi,h:wi,V:bi,v:ki,C:Ei,c:Si,S:Bi,s:Ti,Q:Ri,q:Oi,T:Ci,t:Li,A:Pi,a:Mi,Z:Ai,z:Di,N:Ii,D:Wi,X:Fi,G:zi,F:Yi,O:Ni,P:Xi,U:Hi}=Pe,{rect:Vi,roundRect:Ui,arcTo:ji,arc:Gi,ellipse:Ki,quadraticCurveTo:Zi}=ri,{ellipticalArc:qi}=gi,Ji=$t.get("PathConvert"),$i={},Qi={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?De:Ae;for(let e=0,h=t.length;e<h;e++)s=t[e],qt[s]?("."===s&&(ts.dot&&(es(o,r),r=""),ts.dot++),"0"===r&&"."!==s&&(es(o,r),r=""),r+=s):Pe[s]?(r&&(es(o,r),r=""),ts.name=Pe[s],ts.length=Me[s],ts.index=0,es(o,ts.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?r+=s:(r&&es(o,r),r=s):r&&(es(o,r),r=""),n=s;return r&&es(o,r),i?Qi.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 _=[];for(;c<u;){switch(n=t[c],n){case mi:t[c+1]+=a,t[c+2]+=h;case fi:a=t[c+1],h=t[c+2],_.push(fi,a,h),c+=3;break;case wi:t[c+1]+=a;case xi:a=t[c+1],_.push(yi,a,h),c+=2;break;case ki:t[c+1]+=h;case bi:h=t[c+1],_.push(yi,a,h),c+=2;break;case vi:t[c+1]+=a,t[c+2]+=h;case yi:a=t[c+1],h=t[c+2],_.push(yi,a,h),c+=3;break;case Ti:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Bi;case Bi:o=r===Ei||r===Bi,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],_.push(Ei,l,d,i,s,a,h),c+=5;break;case Si: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=Ei;case Ei:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],_.push(Ei,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Li:t[c+1]+=a,t[c+2]+=h,n=Ci;case Ci:o=r===Ri||r===Ci,i=o?2*a-i:t[c+1],s=o?2*h-s:t[c+2],e?Zi(_,a,h,i,s,t[c+1],t[c+2]):_.push(Ri,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Oi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ri;case Ri:i=t[c+1],s=t[c+2],e?Zi(_,a,h,i,s,t[c+3],t[c+4]):_.push(Ri,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Mi:t[c+6]+=a,t[c+7]+=h;case Pi:qi(_,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 Ai:_.push(Ai),c++;break;case Ii:a=t[c+1],h=t[c+2],e?Vi(_,a,h,t[c+3],t[c+4]):is(_,t,c,5),c+=5;break;case Wi:a=t[c+1],h=t[c+2],e?Ui(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):is(_,t,c,9),c+=9;break;case Fi:a=t[c+1],h=t[c+2],e?Ui(_,a,h,t[c+3],t[c+4],t[c+5]):is(_,t,c,6),c+=6;break;case zi:Ki(e?_:is(_,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,$i),a=$i.x,h=$i.y,c+=9;break;case Yi:e?Ki(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):is(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Ni:Gi(e?_:is(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,$i),a=$i.x,h=$i.y,c+=7;break;case Xi:e?Gi(_,t[c+1],t[c+2],t[c+3],0,360,!1):is(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Hi:ji(e?_:is(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,$i),a=$i.x,h=$i.y,c+=6;break;default:return Ji.error(`command: ${n} [index:${c}]`,t),_}r=n}return _},objectToCanvasData(t){if(t[0].name.length>1)return pi.toCommand(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(fi,t.x,t.y);break;case"L":e.push(yi,t.x,t.y);break;case"C":e.push(Ei,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Ri,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Ai)}}),e}},copyData(t,e,i,s){for(let n=i,r=i+s;n<r;n++)t.push(e[n])},pushData(t,e){ts.index===ts.length&&(ts.index=1,t.push(ts.name)),t.push(Number(e)),ts.index++,ts.dot=0}},{current:ts,pushData:es,copyData:is}=Qi,{M:ss,L:ns,C:rs,Q:os,Z:as,N:hs,D:ls,X:ds,G:cs,F:us,O:_s,P:gs,U:ps}=Pe,{getMinDistanceFrom:fs,getRadianFrom:ms}=lt,{tan:ys,min:vs,abs:xs}=Math,ws={},bs={beginPath(t){t.length=0},moveTo(t,e,i){t.push(ss,e,i)},lineTo(t,e,i){t.push(ns,e,i)},bezierCurveTo(t,e,i,s,n,r,o){t.push(rs,e,i,s,n,r,o)},quadraticCurveTo(t,e,i,s,n){t.push(os,e,i,s,n)},closePath(t){t.push(as)},rect(t,e,i,s,n){t.push(hs,e,i,s,n)},roundRect(t,e,i,s,n,r){if(o(r))t.push(ds,e,i,s,n,r);else{const o=W.fourNumber(r);o?t.push(ls,e,i,s,n,...o):t.push(hs,e,i,s,n)}},ellipse(t,e,i,n,r,o,a,h,l){s(o)?t.push(us,e,i,n,r):(s(a)&&(a=0),s(h)&&(h=360),t.push(cs,e,i,n,r,o,a,h,l?1:0))},arc(t,e,i,n,r,o,a){s(r)?t.push(gs,e,i,n):(s(o)&&(o=360),t.push(_s,e,i,n,r,o,a?1:0))},arcTo(t,e,s,n,r,o,a,h){if(!i(a)){const t=fs(a,h,e,s,n,r);o=vs(o,vs(t/2,t/2*xs(ys(ms(a,h,e,s,n,r)/2))))}t.push(ps,e,s,n,r,o)},drawEllipse(t,e,i,n,r,o,a,h,l){ri.ellipse(null,e,i,n,r,s(o)?0:o,s(a)?0:a,s(h)?360:h,l,null,null,ws),t.push(ss,ws.x,ws.y),ks(t,e,i,n,r,o,a,h,l)},drawArc(t,e,i,n,r,o,a){ri.arc(null,e,i,n,s(r)?0:r,s(o)?360:o,a,null,null,ws),t.push(ss,ws.x,ws.y),Es(t,e,i,n,r,o,a)},drawPoints(t,e,i,s){ri.points(t,e,i,s)}},{ellipse:ks,arc:Es}=bs,{moveTo:Ss,lineTo:Bs,quadraticCurveTo:Ts,bezierCurveTo:Rs,closePath:Os,beginPath:Cs,rect:Ls,roundRect:Ps,ellipse:Ms,arc:As,arcTo:Ds,drawEllipse:Is,drawArc:Ws,drawPoints:Fs}=bs;class zs{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?n(t)?Ce.parse(t):t:[],this}beginPath(){return Cs(this.__path),this.paint(),this}moveTo(t,e){return Ss(this.__path,t,e),this.paint(),this}lineTo(t,e){return Bs(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,r){return Rs(this.__path,t,e,i,s,n,r),this.paint(),this}quadraticCurveTo(t,e,i,s){return Ts(this.__path,t,e,i,s),this.paint(),this}closePath(){return Os(this.__path),this.paint(),this}rect(t,e,i,s){return Ls(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Ps(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,r,o,a){return Ms(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}arc(t,e,i,s,n,r){return As(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 Ws(this.__path,t,e,i,s,n,r),this.paint(),this}drawPoints(t,e,i){return Fs(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Ys,L:Ns,C:Xs,Q:Hs,Z:Vs,N:Us,D:js,X:Gs,G:Ks,F:Zs,O:qs,P:Js,U:$s}=Pe,Qs=$t.get("PathDrawer"),tn={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Ys:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Ns:t.lineTo(e[s+1],e[s+2]),s+=3;break;case Xs:t.bezierCurveTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5],e[s+6]),s+=7;break;case Hs:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Vs:t.closePath(),s+=1;break;case Us:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case js:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],[e[s+5],e[s+6],e[s+7],e[s+8]]),s+=9;break;case Gs:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Ks: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 Zs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,Y,!1),s+=5;break;case qs: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 Js:t.arc(e[s+1],e[s+2],e[s+3],0,Y,!1),s+=4;break;case $s:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void Qs.error(`command: ${i} [index:${s}]`,e)}}},{M:en,L:sn,C:nn,Q:rn,Z:on,N:an,D:hn,X:ln,G:dn,F:cn,O:un,P:_n,U:gn}=Pe,{toTwoPointBounds:pn,toTwoPointBoundsByQuadraticCurve:fn,arcTo:mn,arc:yn,ellipse:vn}=ri,{addPointBounds:xn,copy:wn,addPoint:bn,setPoint:kn,addBounds:En,toBounds:Sn}=yt,Bn=$t.get("PathBounds");let Tn,Rn,On;const Cn={},Ln={},Pn={},Mn={toBounds(t,e){Mn.toTwoPointBounds(t,Ln),Sn(Ln,e)},toTwoPointBounds(t,e){if(!t||!t.length)return kn(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===on||o===nn||o===rn?kn(e,h,l):kn(e,t[a+1],t[a+2])),o){case en:case sn:h=t[a+1],l=t[a+2],bn(e,h,l),a+=3;break;case nn:n=t[a+5],r=t[a+6],pn(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,r,Cn),xn(e,Cn),h=n,l=r,a+=7;break;case rn:i=t[a+1],s=t[a+2],n=t[a+3],r=t[a+4],fn(h,l,i,s,n,r,Cn),xn(e,Cn),h=n,l=r,a+=5;break;case on:a+=1;break;case an:h=t[a+1],l=t[a+2],En(e,h,l,t[a+3],t[a+4]),a+=5;break;case hn:case ln:h=t[a+1],l=t[a+2],En(e,h,l,t[a+3],t[a+4]),a+=o===hn?9:6;break;case dn:vn(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],Cn,Pn),0===a?wn(e,Cn):xn(e,Cn),h=Pn.x,l=Pn.y,a+=9;break;case cn:h=t[a+1],l=t[a+2],Rn=t[a+3],On=t[a+4],En(e,h-Rn,l-On,2*Rn,2*On),h+=Rn,a+=5;break;case un:yn(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Cn,Pn),0===a?wn(e,Cn):xn(e,Cn),h=Pn.x,l=Pn.y,a+=7;break;case _n:h=t[a+1],l=t[a+2],Tn=t[a+3],En(e,h-Tn,l-Tn,2*Tn,2*Tn),h+=Tn,a+=4;break;case gn:mn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Cn,Pn),0===a?wn(e,Cn):xn(e,Cn),h=Pn.x,l=Pn.y,a+=6;break;default:return void Bn.error(`command: ${o} [index:${a}]`,t)}}},{M:An,L:Dn,Z:In}=Pe,{getCenterX:Wn,getCenterY:Fn}=lt,{arcTo:zn}=bs,Yn={smooth(t,e,i){let s,n,r,o=0,a=0,h=0,l=0,d=0,c=0,u=0,_=0,g=0;const p=t.length,f=[];for(;o<p;){switch(s=t[o],s){case An:l=_=t[o+1],d=g=t[o+2],o+=3,t[o]===Dn?(c=t[o+1],u=t[o+2],f.push(An,Wn(l,c),Fn(d,u))):f.push(An,l,d);break;case Dn:switch(a=t[o+1],h=t[o+2],o+=3,t[o]){case Dn:zn(f,a,h,t[o+1],t[o+2],e,_,g);break;case In:zn(f,a,h,l,d,e,_,g);break;default:f.push(Dn,a,h)}_=a,g=h;break;case In:n!==In&&(zn(f,l,d,c,u,e,_,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 Nn(t){return new zs(t)}const Xn=Nn();Ce.creator=Nn(),Ce.parse=Qi.parse,Ce.convertToCanvasData=Qi.toCanvasData;const{drawRoundRect:Hn}=ze;function Vn(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Hn(this,t,e,i,s,n)})}(t)}const Un={alphaPixelTypes:["png","webp","svg"],upperCaseTypeMap:{},mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]},isOpaqueImage(t){const e=jn.fileType(t);return["jpg","jpeg"].some(t=>t===e)},getExportOptions(t){switch(typeof t){case"object":return t;case"number":return{quality:t};case"boolean":return{blob:t};default:return{}}}},jn=Un;jn.alphaPixelTypes.forEach(t=>jn.upperCaseTypeMap[t]=t.toUpperCase());const Gn=$t.get("TaskProcessor");class Kn{constructor(t){this.parallel=!0,this.time=1,this.id=x.create(x.TASK),this.task=t}run(){return pe(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){Gn.error(t)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}}class Zn{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,i=0;for(let s=0;s<t;s++)s<=this.finishedIndex?(i+=this.list[s].time,s===this.finishedIndex&&(e=i)):e+=this.list[s].time;return this.isComplete?1:i/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&_.assign(this.config,t),this.empty()}add(t,e,s){let n,r,a,h;const l=new Kn(t);return l.parent=this,o(e)?h=e:e&&(r=e.parallel,n=e.start,a=e.time,h=e.delay,s||(s=e.canUse)),a&&(l.time=a),!1===r&&(l.parallel=!1),s&&(l.canUse=s),i(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 qn=$t.get("Resource"),Jn={tasker:new Zn,map:{},get isComplete(){return $n.tasker.isComplete},set(t,e){$n.map[t]&&qn.repeat(t),$n.map[t]=e},get:t=>$n.map[t],remove(t){const e=$n.map[t];e&&(e.destroy&&e.destroy(),delete $n.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 n(e)?s={url:e}:e.url||(s={url:t,view:e}),s&&(i&&(s.format=i),e=oe.image(s)),$n.set(t,e),e},destroy(){$n.map={}}},$n=Jn,Qn={maxRecycled:10,recycledList:[],patternTasker:new Zn,get(t){let e=Jn.get(t.url);return e||Jn.set(t.url,e=oe.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||tr.recycledList.push(t)})},clearRecycled(){const t=tr.recycledList;t.length>tr.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&Jn.remove(t.url)),t.length=0)},hasAlphaPixel:t=>Un.alphaPixelTypes.some(e=>tr.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:"+Un.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+Un.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){tr.recycledList=[]}},tr=Qn,{IMAGE:er,create:ir}=x;class sr{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=ir(er),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}Qn.isFormat("svg",t)&&(this.isSVG=!0),Qn.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,e){if(!this.loading){this.loading=!0;const{crossOrigin:t}=this.config;Jn.tasker.add(()=>pe(this,void 0,void 0,function*(){return yield y.origin.loadImage(this.url,i(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 nr(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function rr(t,e){return Object.getOwnPropertyDescriptor(t,e)}function or(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function ar(t,e){return(i,s)=>lr(i,s,t,e&&e(s))}function hr(t){return t}function lr(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};nr(t,e,Object.assign(n,s||{})),Fr(t,e,i)}function dr(t){return ar(t)}function cr(t,e){return ar(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function ur(t,e){return ar(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function _r(t){return ar(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),yr(this))}}))}function gr(t,e){return ar(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function pr(t,e){return ar(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function fr(t,e){return ar(t,t=>({set(i){this.__setAttr(t,i,e)&&yr(this)}}))}function mr(t){return ar(t,t=>({set(e){this.__setAttr(t,e)&&(yr(this),this.__.__removeNaturalSize())}}))}function yr(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function vr(t){return ar(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),yr(this)}}))}const xr=fr;function wr(t,e){return ar(t,t=>({set(i){this.__setAttr(t,i)&&(br(this),e&&(this.__.__useStroke=!0))}}))}function br(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&yr(t)}const kr=wr;function Er(t){return ar(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Sr(t){return ar(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Br(t){return ar(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;_.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Tr(t){return ar(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Or(this)}}))}function Rr(t){return ar(t,t=>({set(e){const i=this.visible;if(!0===i&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Cr(this,t,e,i))}else 0===i&&!0===e&&this.animation&&this.__runAnimation("in");Cr(this,t,e,i),this.mask&&Or(this)}}))}function Or(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Cr(t,e,i,s){t.__setAttr(e,i)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==s&&0!==i||yr(t))}function Lr(t){return ar(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Pr(t){return ar(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function Mr(t){return ar(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Ar(t){return ar(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 ar(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Ir(t){return(e,i)=>{nr(e,"__DataProcessor",{get:()=>t})}}function Wr(t){return(e,i)=>{nr(e,"__LayoutProcessor",{get:()=>t})}}function Fr(t,e,s){const n=t.__DataProcessor.prototype,r="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=or(e,s);if(i(s))a.get=function(){return this[r]};else if("function"==typeof s)a.get=function(){const t=this[r];return null==t?s(this.__leaf):t};else if(d(s)){const t=u(s);a.get=function(){const e=this[r];return null==e?this[r]=t?{}:_.clone(s):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[r];if(null==t){const t=this,e=t.__naturalWidth,i=t.__leaf;return!s||i.pathInputed?i.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&i.children.length?i.boxBounds.width:s}return t}:"height"===e&&(a.get=function(){const t=this[r];if(null==t){const t=this,e=t.__naturalHeight,i=t.__leaf;return!s||i.pathInputed?i.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&i.children.length?i.boxBounds.height:s}return t});let l,c=n;for(;!l&&c;)l=rr(c,e),c=c.__proto__;l&&l.set&&(a.set=l.set),n[o]&&(a.set=n[o],delete n[o]),nr(n,e,a)}const zr=new $t("rewrite"),Yr=[],Nr=["destroy","constructor"];function Xr(t){return(e,i)=>{Yr.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function Hr(){return t=>{Vr()}}function Vr(t){Yr.length&&(Yr.forEach(e=>{t&&zr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Yr.length=0)}function Ur(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Nr.includes(s)||e&&e.includes(s)))if(t.prototype){rr(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function jr(){return t=>{he.register(t)}}function Gr(){return t=>{ce.register(t)}}setTimeout(()=>Vr(!0));const{copy:Kr,toInnerPoint:Zr,toOuterPoint:qr,scaleOfOuter:Jr,rotateOfOuter:$r,skewOfOuter:Qr,multiplyParent:to,divideParent:eo,getLayout:io}=$,so={},{round:no}=Math,ro={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),ho(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)ao(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++)lo(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&lo(t),t.__updateChange()},updateAllChange(t){if(uo(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)co(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?qr(t.localTransform,r,r,!0):t.parent&&Zr(t.parent.scrollWorldTransform,r,r,!0),oo.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=no(e),i=no(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,r){oo.zoomOfLocal(t,_o(t,e),i,s,n,r)},zoomOfLocal(t,e,i,s=i,n,r){const a=t.__localMatrix;if(o(s)||(s&&(r=s),s=i),Kr(so,a),Jr(so,e,i,s),oo.hasHighPosition(t))oo.setTransform(t,so,n,r);else{const e=t.x+so.e-a.e,o=t.y+so.f-a.f;r&&!n?t.animate({x:e,y:o,scaleX:t.scaleX*i,scaleY:t.scaleY*s},r):(t.x=e,t.y=o,t.scaleResize(i,s,!0!==n))}},rotateOfWorld(t,e,i,s){oo.rotateOfLocal(t,_o(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Kr(so,n),$r(so,e,i),oo.hasHighPosition(t)?oo.setTransform(t,so,!1,s):t.set({x:t.x+so.e-n.e,y:t.y+so.f-n.f,rotation:W.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,r){oo.skewOfLocal(t,_o(t,e),i,s,n,r)},skewOfLocal(t,e,i,s=0,n,r){Kr(so,t.__localMatrix),Qr(so,e,i,s),oo.setTransform(t,so,n,r)},transformWorld(t,e,i,s){Kr(so,t.worldTransform),to(so,e),t.parent&&eo(so,t.parent.scrollWorldTransform),oo.setTransform(t,so,i,s)},transform(t,e,i,s){Kr(so,t.localTransform),to(so,e),oo.setTransform(t,so,i,s)},setTransform(t,e,i,s){const n=t.__,r=n.origin&&oo.getInnerOrigin(t,n.origin),o=io(e,r,n.around&&oo.getInnerOrigin(t,n.around));if(oo.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){Ht.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=oo.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 Jr(i,oo.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>lt.tempToOuterOf(oo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return kt.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Kr(so,t.worldTransform),eo(so,e.scrollWorldTransform),i?so:Object.assign({},so)),drop(t,e,i,s){t.setTransform(oo.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||oo.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(()=>oo.animateMove(t,e,i))}}},oo=ro,{updateAllMatrix:ao,updateMatrix:ho,updateAllWorldOpacity:lo,updateAllChange:co,updateChange:uo}=oo;function _o(t,e){return t.updateLayout(),t.parent?lt.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const go={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)=>fo(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>fo(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>fo(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 fo(t,e){return e||(po=0),t.__.mask&&(po=1),po<0?null:(po&&(po=-1),!0)}const{updateBounds:mo}=ro,yo={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),vo(t,e))}},pushAllParent(t,e){const{keys:s}=e;if(s)for(;t.parent&&i(s[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++)xo(e[t],e)},updateBounds(t,e){const i=[t];xo(t,i),wo(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++)mo(s[t]);e&&e===i||mo(i)}}},{pushAllChildBranch:vo,pushAllBranchStack:xo,updateBoundsByBranchStack:wo}=yo,bo={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:ko,updateBounds:Eo}=ro,{toOuterOf:So,getPoints:Bo,copy:To}=Ht,Ro="_localContentBounds",Oo="_worldContentBounds",Co="_worldBoxBounds",Lo="_worldStrokeBounds";class Po{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 So(this.contentBounds,this.leaf.__localMatrix,this[Ro]||(this[Ro]={})),this[Ro]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return So(this.contentBounds,this.leaf.__world,this[Oo]||(this[Oo]={})),this[Oo]}get worldBoxBounds(){return So(this.boxBounds,this.leaf.__world,this[Co]||(this[Co]={})),this[Co]}get worldStrokeBounds(){return So(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 ko(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=ko(s,e,!0)}if(o||(o=$.getLayout(r)),To(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:s}=this,n=Bo(this.getInnerBounds(t));let r;switch(e){case"world":r=null;break;case"local":r=s.parent;break;case"inner":break;case"page":e=s.zoomLayer;default:r=e}return i(r)||n.forEach(t=>s.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 Mo{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 Ao extends Mo{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Ao.ADD="child.add",Ao.REMOVE="child.remove",Ao.CREATED="created",Ao.MOUNTED="mounted",Ao.UNMOUNTED="unmounted",Ao.DESTROY="destroy";const Do="property.scroll";class Io extends Mo{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Io.CHANGE="property.change",Io.LEAFER_CHANGE="property.leafer_change",Io.SCROLL=Do;const Wo={scrollX:Do,scrollY:Do};class Fo extends Mo{constructor(t,e){super(t),Object.assign(this,e)}}Fo.LOAD="image.load",Fo.LOADED="image.loaded",Fo.ERROR="image.error";class zo extends Mo{static checkHas(t,e,i){"on"===i?e===Ho?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Yo)||t.hasEvent(No)||t.hasEvent(Xo),t.__hasWorldEvent=t.hasEvent(Ho))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Yo,t),"inner"===e&&t.emit(No,t)),t.emit(Xo,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Ho,this)}}zo.RESIZE="bounds.resize",zo.INNER="bounds.inner",zo.LOCAL="bounds.local",zo.WORLD="bounds.world";const{RESIZE:Yo,INNER:No,LOCAL:Xo,WORLD:Ho}=zo,Vo={};[Yo,No,Xo,Ho].forEach(t=>Vo[t]=1);class Uo extends Mo{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(Uo.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!i(this.resizingKeys[t.innerId])}}Uo.RESIZE="resize";class jo extends Mo{constructor(t,e){super(t),this.data=e}}jo.REQUEST="watch.request",jo.DATA="watch.data";class Go extends Mo{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Go.REQUEST="layout.request",Go.START="layout.start",Go.BEFORE="layout.before",Go.LAYOUT="layout",Go.AFTER="layout.after",Go.AGAIN="layout.again",Go.END="layout.end";class Ko extends Mo{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Ko.REQUEST="render.request",Ko.CHILD_START="render.child_start",Ko.CHILD_END="render.child_end",Ko.START="render.start",Ko.BEFORE="render.before",Ko.RENDER="render",Ko.AFTER="render.after",Ko.AGAIN="render.again",Ko.END="render.end",Ko.NEXT="render.next";class Zo extends Mo{}Zo.START="leafer.start",Zo.BEFORE_READY="leafer.before_ready",Zo.READY="leafer.ready",Zo.AFTER_READY="leafer.after_ready",Zo.VIEW_READY="leafer.view_ready",Zo.VIEW_COMPLETED="leafer.view_completed",Zo.STOP="leafer.stop",Zo.RESTART="leafer.restart",Zo.END="leafer.end",Zo.UPDATE_MODE="leafer.update_mode",Zo.TRANSFORM="leafer.transform",Zo.MOVE="leafer.move",Zo.SCALE="leafer.scale",Zo.ROTATE="leafer.rotate",Zo.SKEW="leafer.skew";const{MOVE:qo,SCALE:Jo,ROTATE:$o,SKEW:Qo}=Zo,ta={x:qo,y:qo,scaleX:Jo,scaleY:Jo,rotation:$o,skewX:Qo,skewY:Qo},ea={};class ia{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,r,o;i&&("once"===i?r=!0:"boolean"==typeof i?s=i:(s=i.capture,r=i.once));const a=sa(this,s,!0),h=n(t)?t.split(" "):t,d=r?{listener:e,once:r}:{listener:e};h.forEach(t=>{t&&(o=a[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(d):a[t]=[d],Vo[t]&&zo.checkHas(this,t,"on"))})}off(t,e,i){if(t){const s=n(t)?t.split(" "):t;if(e){let t,n,r;i&&(t="boolean"==typeof i?i:"once"!==i&&i.capture);const o=sa(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],Vo[t]&&zo.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=sa(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:s,__captureMap:n}=this,r=s&&s[t],o=n&&n[t];return!!(i(e)?r||o:e?o:r)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function sa(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:ea)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:ea)}}const{on:na,on_:ra,off:oa,off_:aa,once:ha,emit:la,emitEvent:da,hasEvent:ca,destroy:ua}=ia.prototype,_a={on:na,on_:ra,off:oa,off_:aa,once:ha,emit:la,emitEvent:da,hasEvent:ca,destroyEventer:ua},ga=$t.get("setAttr"),pa={__setAttr(t,e,s){if(this.leaferIsCreated){const n=this.__.__getInput(t);if(!s||r(e)||i(e)||(ga.warn(this.innerName,t,e),e=void 0),d(e)||n!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Io(Io.LEAFER_CHANGE,this,t,n,e));const i=ta[t];i&&(this.emitEvent(new Zo(i,this)),this.emitEvent(new Zo(Zo.TRANSFORM,this)))}this.emitPropertyEvent(Io.CHANGE,t,n,e);const i=Wo[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 Io(t,this,e,i,s);this.isLeafer||this.hasEvent(t)&&this.emitEvent(n),this.leafer.emitEvent(n)},__realSetAttr(t,e){const s=this.__;s[t]=e,this.__proxyData&&this.setProxyAttr(t,e),s.normalStyle&&(this.lockNormalStyle||i(s.normalStyle[t])||(s.normalStyle[t]=e))},__getAttr(t){return this.__proxyData?this.getProxyAttr(t):this.__.__get(t)}},{setLayout:fa,multiplyParent:ma,translateInner:ya,defaultWorld:va}=$,{toPoint:xa,tempPoint:wa}=kt,ba={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;ma(this.__local||e,t?t.__scrollWorld||t.__world:va,i,!!e.affectScaleOrRotation,n),s&&ya(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)&&(fa(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)&&(xa(i.around||i.origin,t.boxBounds,wa),ya(e,-wa.x,-wa.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:ka,updateAllMatrix:Ea}=ro,{updateBounds:Sa}=yo,{toOuterOf:Ba,copyAndSpread:Ta,copy:Ra}=Ht,{toBounds:Oa}=Mn,Ca={__updateWorldBounds(){const{__layout:t,__world:e}=this;Ba(t.renderBounds,e,e),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&zo.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&zo.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(),Ba(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Ba(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Ba(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Oa(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),Sa(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(Ea(this),Sa(this,this))):ka(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Ta(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;o(i)&&i<=0?Ra(e.renderBounds,e.strokeBounds):Ta(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),ro.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:Pa}=go,Ma={__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++)Pa(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++)Pa(i[s],e)||i[s].__clip(t,e)}}},Aa={},{LEAF:Da,create:Ia}=x,{stintSet:Wa}=_,{toInnerPoint:Fa,toOuterPoint:za,multiplyParent:Ya}=$,{toOuterOf:Na}=Ht,{copy:Xa,move:Ha}=lt,{moveLocal:Va,zoomOfLocal:Ua,rotateOfLocal:ja,skewOfLocal:Ga,moveWorld:Ka,zoomOfWorld:Za,rotateOfWorld:qa,skewOfWorld:Ja,transform:$a,transformWorld:Qa,setTransform:th,getFlipTransform:eh,getLocalOrigin:ih,getRelativeWorld:sh,drop:nh}=ro;let rh=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 p}get __LayoutProcessor(){return Po}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=Ia(Da),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Ao.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(Ao.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Ao.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(Ao.MOUNTED)):this.__emitLifeEvent(Ao.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){i(t)?t="width":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=i(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 Ya(i,t.matrix,e,void 0,i),Na(this.__layout.renderBounds,e,e),Wa(e,"half",i.half),Wa(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}=Qn.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),Aa.scaleX=i,Aa.scaleY=s,Aa}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?sh(this,e):this.worldTransform,n=i?t:{};return Na(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Xa(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Xa(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),Fa(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){za(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){th(this,t,e,i)}transform(t,e,i){$a(this,t,e,i)}move(t,e,i){Va(this,t,e,i)}moveInner(t,e,i){Ka(this,t,e,!0,i)}scaleOf(t,e,i,s,n){Ua(this,ih(this,t),e,i,s,n)}rotateOf(t,e,i){ja(this,ih(this,t),e,i)}skewOf(t,e,i,s,n){Ga(this,ih(this,t),e,i,s,n)}transformWorld(t,e,i){Qa(this,t,e,i)}moveWorld(t,e,i){Ka(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){Za(this,t,e,i,s,n)}rotateOfWorld(t,e){qa(this,t,e)}skewOfWorld(t,e,i,s,n){Ja(this,t,e,i,s,n)}flip(t,e){$a(this,eh(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){nh(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):Fr(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=fr),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Ao(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Ao.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};rh=ge([Ur(pa),Ur(ba),Ur(Ca),Ur(_a),Ur(La)],rh);const{setListWithFn:oh}=Ht,{sort:ah}=yo,{localBoxBounds:hh,localStrokeBounds:lh,localRenderBounds:dh,maskLocalBoxBounds:ch,maskLocalStrokeBounds:uh,maskLocalRenderBounds:_h}=go,gh=new $t("Branch");let ph=class extends rh{__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){oh(e||this.__layout.boxBounds,this.children,this.__hasMask?ch:hh)}__updateStrokeBounds(t){oh(t||this.__layout.strokeBounds,this.children,this.__hasMask?uh:lh)}__updateRenderBounds(t){oh(t||this.__layout.renderBounds,this.children,this.__hasMask?_h:dh)}__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(ah),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return gh.warn("add self or destroyed");const s=i(e);if(!t.__){if(l(t))return t.forEach(t=>{this.add(t,e),s||e++});t=he.get(t.tag,t)}t.parent&&t.parent.remove(t),t.parent=this,s?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(Ao.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Ao.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)):i(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(Ao.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Ao.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Ao(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};ph=ge([Ur(Ma)],ph);class fh{get length(){return this.list.length}constructor(t){this.reset(),t&&(l(t)?this.addList(t):this.add(t))}has(t){return t&&!i(this.keys[t.innerId])}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return i(e)?-1:e}add(t){const{list:e,keys:s}=this;i(s[t.innerId])&&(e.push(t),s[t.innerId]=e.length-1)}addAt(t,e=0){const{keys:s}=this;if(i(s[t.innerId])){const{list:i}=this;for(let t=e,n=i.length;t<n;t++)s[i[t].innerId]++;0===e?i.unshift(t):(e>i.length&&(e=i.length),i.splice(e,0,t)),s[t.innerId]=e}}addList(t){for(let e=0;e<t.length;e++)this.add(t[e])}remove(t){const{list:e}=this;let s;for(let n=0,r=e.length;n<r;n++)i(s)?e[n].innerId===t.innerId&&(s=n,delete this.keys[t.innerId]):this.keys[e[n].innerId]=n-1;i(s)||e.splice(s,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 fh;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 mh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(l(t)?this.addList(t):this.add(t))}has(t){return!i(this.keys[t.innerId])}without(t){return i(this.keys[t.innerId])}sort(t){const{levels:e}=this;t?e.sort((t,e)=>e-t):e.sort((t,e)=>t-e)}addList(t){t.forEach(t=>{this.add(t)})}add(t){const{keys:e,levelMap:i}=this;e[t.innerId]||(e[t.innerId]=1,i[t.__level]?i[t.__level].push(t):(i[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(i=>{e=this.levelMap[i];for(let i=0,s=e.length;i<s;i++)t(e[i])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}const yh="1.11.1";class vh extends Oe{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}}Vn(OffscreenCanvasRenderingContext2D.prototype),Vn(Path2D.prototype);const{mineType:xh}=Un;function wh(t,e){y.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:xh(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:xh(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 vh(t,e),image:t=>new sr(t)}),y.name="web",y.isWorker=!0,y.backgrounder=!0,y.requestRender=function(t){requestAnimationFrame(t)},nr(y,"devicePixelRatio",{get:()=>1});const{userAgent:bh}=navigator;bh.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),bh.indexOf("Windows")>-1?(y.os="Windows",y.intWheelDeltaY=!0):bh.indexOf("Mac")>-1?y.os="Mac":bh.indexOf("Linux")>-1&&(y.os="Linux");class kh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new fh;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 fh,this.target=t,e&&(this.config=_.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(Ko.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===Ao.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 jo(jo.DATA,{updatedList:this.updatedList})),this.__updatedList=new fh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Io.CHANGE,this.__onAttrChange,this],[[Ao.ADD,Ao.REMOVE],this.__onChildEvent,this],[jo.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:Eh,updateBounds:Sh,updateChange:Bh}=ro,{pushAllChildBranch:Th,pushAllParent:Rh}=yo;const{worldBounds:Oh}=go;class Ch{constructor(t){this.updatedBounds=new Gt,this.beforeBounds=new Gt,this.afterBounds=new Gt,l(t)&&(t=new fh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Oh)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Oh),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:Lh,updateAllChange:Ph}=ro,Mh=$t.get("Layouter");class Ah{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new mh,this.target=t,e&&(this.config=_.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(Go.START),this.layoutOnce(),t.emitEvent(new Go(Go.END,this.layoutedBlocks,this.times))}catch(t){Mh.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Mh.warn("layouting"):this.times>3?Mh.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(jo.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}=Go,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Go(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?(Eh(t,!0),e.add(t),t.isBranch&&Th(t,e),Rh(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Rh(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||Sh(s[t])}Sh(i)}})}(this.__levelList),function(t){t.list.forEach(Bh)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Go(r,a,this.times)),i.emitEvent(new Go(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}=Go,r=this.getBlocks(new fh(e));e.emitEvent(new Go(i,r,this.times)),Ah.fullLayout(e),r.forEach(t=>{t.setAfter()}),e.emitEvent(new Go(s,r,this.times)),e.emitEvent(new Go(n,r,this.times)),this.addBlocks(r),ie.end(t)}static fullLayout(t){Lh(t,!0),t.isBranch?yo.updateBounds(t):ro.updateBounds(t),Ph(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Ch([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Ch(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_([[Go.REQUEST,this.layout,this],[Go.AGAIN,this.layoutAgain,this],[jo.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Dh=$t.get("Renderer");class Ih{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=_.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(Go.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Ko.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Ko.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Ko.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new Gt,Dh.log(e.innerName,"---\x3e");try{this.emitRender(Ko.START),this.renderOnce(t),this.emitRender(Ko.END,this.totalBounds),Qn.clearRecycled()}catch(t){this.rendering=!1,Dh.error(t)}Dh.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Dh.warn("rendering");if(this.times>3)return Dh.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new Gt,this.renderOptions={},t)this.emitRender(Ko.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Ko.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Ko.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Ko.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(Ih.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||Dh.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 Ko(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Ko.REQUEST,this.update,this],[Go.END,this.__onLayoutEnd,this],[Ko.AGAIN,this.renderAgain,this],[Uo.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Ih.clipSpread=10;const{hitRadiusPoint:Wh}=Ht;class Fh{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 fh(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 fh;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||ro.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&ro.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=>ro.worldHittable(t))}getPath(t){const e=new fh,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 fh;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 fh,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||Wh(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 zh{constructor(t,e){this.config={},e&&(this.config=_.default(e,this.config)),this.picker=new Fh(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 Yh(t){return ar(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Nh(t){return ar(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Xh(){return(t,e)=>{const i="_"+e;nr(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}})}}function Hh(t){return(e,i)=>{nr(e,i,or(i,t))}}Object.assign(oe,{watcher:(t,e)=>new kh(t,e),layouter:(t,e)=>new Ah(t,e),renderer:(t,e,i)=>new Ih(t,e,i),selector:(t,e)=>new zh(t,e)}),y.layout=Ah.fullLayout,y.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new fh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Vh={},Uh={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},jh={number:(t,e)=>d(t)?"percent"===t.type?t.value*e:t.value:t},Gh={},Kh={},Zh={},qh={},Jh={},$h={apply(){re.need("filter")}},Qh={},tl={setStyleName:()=>re.need("state"),set:()=>re.need("state")},el={list:{},register(t,e){el.list[t]=e},get:t=>el.list[t]},{parse:il,objectToCanvasData:sl}=Qi,{stintSet:nl}=_,{hasTransparent:rl}=Uh,ol={originPaint:{}},al=$t.get("UIData");class hl extends p{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,al.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,al.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),n(t)||!t?(nl(this,"__isTransparentFill",rl(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):d(t)&&this.__setPaint("fill",t)}setStroke(t){n(t)||!t?(nl(this,"__isTransparentStroke",rl(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):d(t)&&this.__setPaint("stroke",t)}setPath(t){const e=n(t);e||t&&d(t[0])?(this.__setInput("path",t),this._path=e?il(t):sl(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){ll(this,"shadow",t)}setInnerShadow(t){ll(this,"innerShadow",t)}setFilter(t){ll(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&Kh.compute("fill",this.__leaf),e&&Kh.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:s}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),i(t.strokeWidthFixed)||(s=t.strokeWidthFixed)),s){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=ol)):(this.__isStrokes=!0,this._stroke||(this._stroke=ol))}__removePaint(t,e){e&&this.__removeInput(t),Zh.recycleImage(t,this),"fill"===t?(nl(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(nl(this,"__isAlphaPixelStroke",void 0),nl(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function ll(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 dl extends hl{}class cl extends dl{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 ul extends dl{__getInputData(t,e){const i=super.__getInputData(t,e);return Re.forEach(t=>delete i[t]),i}}class _l extends cl{}class gl extends hl{get __usePathBox(){return this.points||this.__pathInputed}}class pl extends hl{get __boxStroke(){return!this.__pathInputed}}class fl extends hl{get __boxStroke(){return!this.__pathInputed}}class ml extends gl{}class yl extends hl{}class vl extends hl{get __pathInputed(){return 2}}class xl extends dl{}const wl={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class bl extends hl{get __useNaturalRatio(){return!1}setFontWeight(t){n(t)?(this.__setInput("fontWeight",t),t=wl[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 kl extends pl{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 El extends pl{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:Sl,add:Bl}=T,Tl={__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=Sl(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=Jh.getShadowRenderSpread(this,e)),s&&(t=Sl(t,s)),r&&(t=Bl(t,$h.getSpread(r))),o&&(t=Bl(t,o)),a&&(t=Bl(t,a));let l=t;return i&&(l=Sl(l,Jh.getInnerShadowSpread(this,i))),n&&(l=Sl(l,n)),this.__layout.renderShapeSpread=l,h?Sl(h.__updateRenderSpread(),t):t}},{stintSet:Rl}=_,Ol={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Rl(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Rl(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;Rl(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!Jh.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(l(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),Rl(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){Cl(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=Kh.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:l,innerShadow:d,filter:c}=s;l&&Jh.shadow(this,t,h),a&&(s.__isStrokes?Kh.strokes(r,this,t,e):Kh.stroke(r,this,t,e)),n&&(s.__isFills?Kh.fills(n,this,t,e):Kh.fill(n,this,t,e)),o&&this.__drawAfterFill(t,e),d&&Jh.innerShadow(this,t,h),r&&!a&&(s.__isStrokes?Kh.strokes(r,this,t,e):Kh.stroke(r,this,t,e)),c&&$h.apply(c,this,this.__nowWorld,t,i,h),h.worldCanvas&&h.worldCanvas.recycle(),h.canvas.recycle()}else{if(a&&(s.__isStrokes?Kh.strokes(r,this,t,e):Kh.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,Uh.string(e.color))}n&&(s.__isFills?Kh.fills(n,this,t,e):Kh.fill(n,this,t,e)),h&&t.restore(),o&&this.__drawAfterFill(t,e),r&&!a&&(s.__isStrokes?Kh.strokes(r,this,t,e):Kh.stroke(r,this,t,e))}}else s.__pathInputed?Cl(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?Kh.fills(s,this,t,e):Kh.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?Kh.strokes(n,this,t,e):Kh.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 Cl(t,e,i){const{fill:s,stroke:n,__drawAfterFill:r,__fillAfterStroke:o}=t.__;t.__drawRenderPath(e),o&&Kh.stroke(n,t,e,i),s&&Kh.fill(s,t,e,i),r&&t.__drawAfterFill(e,i),n&&!o&&Kh.stroke(n,t,e,i)}const Ll={__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 Pl;let Ml=Pl=class extends rh{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 Xn.set(this.path=t||[]),t||this.__drawPathByBox(Xn),Xn}reset(t){}set(t,e){t&&Object.assign(this,t)}get(t){return n(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||(Xn.set(i=[]),this.__drawPathByBox(Xn)),t?Qi.toCanvasData(i,!0):i}getPathString(t,e,i){return Qi.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Qh.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Yn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Gh.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?tn.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,o(r)?[r]:r)}else t.rect(e,i,s,n)}drawImagePlaceholder(t,e,i){Kh.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=_.clone(this.toJSON());return t&&Object.assign(e,t),Pl.one(e)}static one(t,e,i,s,n){return he.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){jr()(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(hl)],Ml.prototype,"__",void 0),ge([Xh()],Ml.prototype,"zoomLayer",void 0),ge([dr("")],Ml.prototype,"id",void 0),ge([dr("")],Ml.prototype,"name",void 0),ge([dr("")],Ml.prototype,"className",void 0),ge([Sr("pass-through")],Ml.prototype,"blendMode",void 0),ge([Tr(1)],Ml.prototype,"opacity",void 0),ge([Rr(!0)],Ml.prototype,"visible",void 0),ge([Sr(!1)],Ml.prototype,"locked",void 0),ge([Br(!1)],Ml.prototype,"dim",void 0),ge([Br(!1)],Ml.prototype,"dimskip",void 0),ge([Lr(0)],Ml.prototype,"zIndex",void 0),ge([Pr(!1)],Ml.prototype,"mask",void 0),ge([Mr(!1)],Ml.prototype,"eraser",void 0),ge([cr(0,!0)],Ml.prototype,"x",void 0),ge([cr(0,!0)],Ml.prototype,"y",void 0),ge([fr(100,!0)],Ml.prototype,"width",void 0),ge([fr(100,!0)],Ml.prototype,"height",void 0),ge([gr(1,!0)],Ml.prototype,"scaleX",void 0),ge([gr(1,!0)],Ml.prototype,"scaleY",void 0),ge([pr(0,!0)],Ml.prototype,"rotation",void 0),ge([pr(0,!0)],Ml.prototype,"skewX",void 0),ge([pr(0,!0)],Ml.prototype,"skewY",void 0),ge([cr(0,!0)],Ml.prototype,"offsetX",void 0),ge([cr(0,!0)],Ml.prototype,"offsetY",void 0),ge([ur(0,!0)],Ml.prototype,"scrollX",void 0),ge([ur(0,!0)],Ml.prototype,"scrollY",void 0),ge([_r()],Ml.prototype,"origin",void 0),ge([_r()],Ml.prototype,"around",void 0),ge([dr(!1)],Ml.prototype,"lazy",void 0),ge([mr(1)],Ml.prototype,"pixelRatio",void 0),ge([Er(0)],Ml.prototype,"renderSpread",void 0),ge([vr()],Ml.prototype,"path",void 0),ge([xr()],Ml.prototype,"windingRule",void 0),ge([xr(!0)],Ml.prototype,"closed",void 0),ge([fr(0)],Ml.prototype,"padding",void 0),ge([fr(!1)],Ml.prototype,"lockRatio",void 0),ge([fr()],Ml.prototype,"widthRange",void 0),ge([fr()],Ml.prototype,"heightRange",void 0),ge([dr(!1)],Ml.prototype,"draggable",void 0),ge([dr()],Ml.prototype,"dragBounds",void 0),ge([dr("auto")],Ml.prototype,"dragBoundsType",void 0),ge([dr(!1)],Ml.prototype,"editable",void 0),ge([Ar(!0)],Ml.prototype,"hittable",void 0),ge([Ar("path")],Ml.prototype,"hitFill",void 0),ge([kr("path")],Ml.prototype,"hitStroke",void 0),ge([Ar(!1)],Ml.prototype,"hitBox",void 0),ge([Ar(!0)],Ml.prototype,"hitChildren",void 0),ge([Ar(!0)],Ml.prototype,"hitSelf",void 0),ge([Ar()],Ml.prototype,"hitRadius",void 0),ge([Dr("")],Ml.prototype,"cursor",void 0),ge([Sr()],Ml.prototype,"fill",void 0),ge([kr(void 0,!0)],Ml.prototype,"stroke",void 0),ge([kr("inside")],Ml.prototype,"strokeAlign",void 0),ge([kr(1,!0)],Ml.prototype,"strokeWidth",void 0),ge([kr(!1)],Ml.prototype,"strokeWidthFixed",void 0),ge([kr("none")],Ml.prototype,"strokeCap",void 0),ge([kr("miter")],Ml.prototype,"strokeJoin",void 0),ge([kr()],Ml.prototype,"dashPattern",void 0),ge([kr(0)],Ml.prototype,"dashOffset",void 0),ge([kr(10)],Ml.prototype,"miterLimit",void 0),ge([xr(0)],Ml.prototype,"cornerRadius",void 0),ge([xr()],Ml.prototype,"cornerSmoothing",void 0),ge([Yh()],Ml.prototype,"shadow",void 0),ge([Yh()],Ml.prototype,"innerShadow",void 0),ge([Yh()],Ml.prototype,"blur",void 0),ge([Yh()],Ml.prototype,"backgroundBlur",void 0),ge([Yh()],Ml.prototype,"grayscale",void 0),ge([Yh()],Ml.prototype,"filter",void 0),ge([Sr()],Ml.prototype,"placeholderColor",void 0),ge([dr(100)],Ml.prototype,"placeholderDelay",void 0),ge([dr({})],Ml.prototype,"data",void 0),ge([Xr(rh.prototype.reset)],Ml.prototype,"reset",null),Ml=Pl=ge([Ur(Tl),Ur(Ol),Hr()],Ml);let Al=class extends Ml{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(){}};var Dl;ge([Ir(dl)],Al.prototype,"__",void 0),ge([fr(0)],Al.prototype,"width",void 0),ge([fr(0)],Al.prototype,"height",void 0),Al=ge([Ur(ph),jr()],Al);const Il=$t.get("Leafer");let Wl=Dl=class extends Al{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&Jn.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),Dl.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,_.assign(s,t));const n=this.canvas=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 _e,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))),bo.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(Zo.RESTART):this.emitLeafer(Zo.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(Zo.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=_.copyAttrs({},t,Re);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=_.copyAttrs({},this.canvas,Re);e.resize(t),this.updateLazyBounds(),this.__onResize(new Uo(t,i))}__onResize(t){this.emitEvent(t),_.copyAttrs(this.__,t,Re),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&&(Re.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(Zo.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Re.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=_.copyAttrs({},s,Re);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(Zo.BEFORE_READY),this.emitLeafer(Zo.READY),this.emitLeafer(Zo.AFTER_READY),bo.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Zo.VIEW_READY),bo.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){bo.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(Zo.VIEW_COMPLETED),bo.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 Zo(t,this))}__listenEvents(){const t=ie.start("FirstCreate "+this.innerName);this.once([[Zo.START,()=>ie.end(t)],[Go.START,this.updateLazyBounds,this],[Ko.START,this.__onCreated,this],[Ko.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[jo.DATA,this.__onWatchData,this],[Go.END,this.__onLayoutEnd,this],[Ko.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Dl.list.remove(this);try{this.stop(),this.emitLeafer(Zo.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(()=>{Qn.clearRecycled()},100)}catch(t){Il.error(t)}}};t?e():setTimeout(e)}};Wl.list=new fh,ge([Ir(ul)],Wl.prototype,"__",void 0),ge([fr()],Wl.prototype,"pixelRatio",void 0),ge([dr("normal")],Wl.prototype,"mode",void 0),Wl=Dl=ge([jr()],Wl);let Fl=class extends Ml{get __tag(){return"Rect"}};ge([Ir(pl)],Fl.prototype,"__",void 0),Fl=ge([Ur(Ll),Hr(),jr()],Fl);const{add:zl,includes:Yl,scroll:Nl}=Ht,Xl=Fl.prototype,Hl=Al.prototype;let Vl=class extends Al{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&&o.includes("scroll"))&&(zl(a,r),Nl(a,i)),this.__updateRectRenderBounds(),t=!Yl(r,a),t&&"show"===o&&zl(n,a)}else this.__updateRectRenderBounds();_.stintSet(this,"isOverflow",t),this.__checkScroll(e)}__updateRectRenderBounds(){}__checkScroll(t){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e)),this.hasScroller&&this.scroller.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};ge([Ir(cl)],Vl.prototype,"__",void 0),ge([fr(100)],Vl.prototype,"width",void 0),ge([fr(100)],Vl.prototype,"height",void 0),ge([dr(!1)],Vl.prototype,"resizeChildren",void 0),ge([Er("show")],Vl.prototype,"overflow",void 0),ge([Xr(Xl.__updateStrokeSpread)],Vl.prototype,"__updateStrokeSpread",null),ge([Xr(Xl.__updateRenderSpread)],Vl.prototype,"__updateRectRenderSpread",null),ge([Xr(Xl.__updateBoxBounds)],Vl.prototype,"__updateRectBoxBounds",null),ge([Xr(Xl.__updateStrokeBounds)],Vl.prototype,"__updateStrokeBounds",null),ge([Xr(Xl.__updateRenderBounds)],Vl.prototype,"__updateRectRenderBounds",null),ge([Xr(Xl.__updateChange)],Vl.prototype,"__updateRectChange",null),ge([Xr(Xl.__render)],Vl.prototype,"__renderRect",null),ge([Xr(Hl.__render)],Vl.prototype,"__renderGroup",null),Vl=ge([Hr(),jr()],Vl);let Ul=class extends Vl{get __tag(){return"Frame"}get isFrame(){return!0}};ge([Ir(_l)],Ul.prototype,"__",void 0),ge([Sr("#FFFFFF")],Ul.prototype,"fill",void 0),ge([Er("hide")],Ul.prototype,"overflow",void 0),Ul=ge([jr()],Ul);const{moveTo:jl,closePath:Gl,ellipse:Kl}=bs;let Zl=class extends Ml{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&&Kl(a,r,o,r*i,o*i,0,s,n,!1),Kl(a,r,o,r,o,0,n,s,!0),i<1&&Gl(a)):(i<1&&(Kl(a,r,o,r*i,o*i),jl(a,t,o)),Kl(a,r,o,r,o,0,360,0,!0)),y.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||n?(jl(a,r,o),Kl(a,r,o,r,o,0,s,n,!1),Gl(a)):Kl(a,r,o,r,o)}};ge([Ir(fl)],Zl.prototype,"__",void 0),ge([xr(0)],Zl.prototype,"innerRadius",void 0),ge([xr(0)],Zl.prototype,"startAngle",void 0),ge([xr(0)],Zl.prototype,"endAngle",void 0),Zl=ge([jr()],Zl);const{sin:ql,cos:Jl,PI:$l}=Math,{moveTo:Ql,lineTo:td,closePath:ed,drawPoints:id}=bs;let sd=class extends Ml{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)id(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,r=i/2,o=s/2;Ql(e,r,0);for(let t=1;t<n;t++)td(e,r+r*ql(2*t*$l/n),o-o*Jl(2*t*$l/n));ed(e)}}};ge([Ir(ml)],sd.prototype,"__",void 0),ge([xr(3)],sd.prototype,"sides",void 0),ge([xr()],sd.prototype,"points",void 0),ge([xr(0)],sd.prototype,"curve",void 0),sd=ge([Hr(),jr()],sd);const{sin:nd,cos:rd,PI:od}=Math,{moveTo:ad,lineTo:hd,closePath:ld}=bs;let dd=class extends Ml{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,r=e/2,o=this.__.path=[];ad(o,n,0);for(let t=1;t<2*i;t++)hd(o,n+(t%2==0?n:n*s)*nd(t*od/i),r-(t%2==0?r:r*s)*rd(t*od/i));ld(o)}};ge([Ir(yl)],dd.prototype,"__",void 0),ge([xr(5)],dd.prototype,"corners",void 0),ge([xr(.382)],dd.prototype,"innerRadius",void 0),dd=ge([jr()],dd);const{moveTo:cd,lineTo:ud,drawPoints:_d}=bs,{rotate:gd,getAngle:pd,getDistance:fd,defaultPoint:md}=lt;let yd=class extends Ml{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&gd(i,e),i}set toPoint(t){this.width=fd(md,t),this.rotation=pd(md,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?_d(e,t.points,t.curve,t.closed):(cd(e,0,0),ud(e,this.width,0))}};ge([Ir(gl)],yd.prototype,"__",void 0),ge([wr("center")],yd.prototype,"strokeAlign",void 0),ge([fr(0)],yd.prototype,"height",void 0),ge([xr()],yd.prototype,"points",void 0),ge([xr(0)],yd.prototype,"curve",void 0),ge([xr(!1)],yd.prototype,"closed",void 0),yd=ge([jr()],yd);let vd=class extends Fl{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(kl)],vd.prototype,"__",void 0),ge([fr("")],vd.prototype,"url",void 0),vd=ge([jr()],vd);const xd=vd;let wd=class extends Fl{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 sr({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new Fo(Fo.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&&(o(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(El)],wd.prototype,"__",void 0),ge([Nh(100)],wd.prototype,"width",void 0),ge([Nh(100)],wd.prototype,"height",void 0),ge([Nh(1)],wd.prototype,"pixelRatio",void 0),ge([Nh(!0)],wd.prototype,"smooth",void 0),ge([dr(!1)],wd.prototype,"safeResize",void 0),ge([Nh()],wd.prototype,"contextSettings",void 0),wd=ge([jr()],wd);const{copyAndSpread:bd,includes:kd,spread:Ed,setList:Sd}=Ht,{stintSet:Bd}=_;let Td=class extends Ml{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=jh.number(e,n),t.__letterSpacing=jh.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"}`,Bd(t,"__padding",l&&W.fourNumber(l)),Bd(t,"__clipText","show"!==h&&!t.__autoSize),Bd(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=Vh.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&&Ed(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),_.stintSet(this,"isOverflow",!kd(h,a)),this.isOverflow?(Sd(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;bd(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(bl)],Td.prototype,"__",void 0),ge([fr(0)],Td.prototype,"width",void 0),ge([fr(0)],Td.prototype,"height",void 0),ge([Sr()],Td.prototype,"boxStyle",void 0),ge([dr(!1)],Td.prototype,"resizeFontSize",void 0),ge([Sr("#000000")],Td.prototype,"fill",void 0),ge([wr("outside")],Td.prototype,"strokeAlign",void 0),ge([Ar("all")],Td.prototype,"hitFill",void 0),ge([fr("")],Td.prototype,"text",void 0),ge([fr("")],Td.prototype,"placeholder",void 0),ge([fr("caption")],Td.prototype,"fontFamily",void 0),ge([fr(12)],Td.prototype,"fontSize",void 0),ge([fr("normal")],Td.prototype,"fontWeight",void 0),ge([fr(!1)],Td.prototype,"italic",void 0),ge([fr("none")],Td.prototype,"textCase",void 0),ge([fr("none")],Td.prototype,"textDecoration",void 0),ge([fr(0)],Td.prototype,"letterSpacing",void 0),ge([fr({type:"percent",value:1.5})],Td.prototype,"lineHeight",void 0),ge([fr(0)],Td.prototype,"paraIndent",void 0),ge([fr(0)],Td.prototype,"paraSpacing",void 0),ge([fr("x")],Td.prototype,"writingMode",void 0),ge([fr("left")],Td.prototype,"textAlign",void 0),ge([fr("top")],Td.prototype,"verticalAlign",void 0),ge([fr(!0)],Td.prototype,"autoSizeAlign",void 0),ge([fr("normal")],Td.prototype,"textWrap",void 0),ge([fr("show")],Td.prototype,"textOverflow",void 0),ge([Sr(!1)],Td.prototype,"textEditing",void 0),Td=ge([jr()],Td);let Rd=class extends Ml{get __tag(){return"Path"}};ge([Ir(vl)],Rd.prototype,"__",void 0),ge([wr("center")],Rd.prototype,"strokeAlign",void 0),Rd=ge([jr()],Rd);let Od=class extends Al{get __tag(){return"Pen"}setStyle(t){const e=this.pathElement=new Rd(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,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(xl)],Od.prototype,"__",void 0),ge([(t,e)=>{nr(t,e,{get(){return this.__path}})}],Od.prototype,"path",void 0),Od=ge([Ur(zs,["set","path","paint"]),jr()],Od);let Cd=class extends Wl{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(t){const e=new Wl(t);return this.add(e),e}add(t,e){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout(()=>this.add(t,e),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t,e),i(e)||(t.canvas.childIndex=e),this.__listenChildEvents(t)}forEach(t){this.children.forEach(t)}__onCreated(){this.created=this.children.every(t=>t.created)}__onReady(){this.children.every(t=>t.ready)&&super.__onReady()}__onViewReady(){this.children.every(t=>t.viewReady)&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){t.context&&this.forEach(i=>e.matrix?i.__render(t,e):t.copyWorld(i.canvas,e.bounds))}__onResize(t){this.forEach(e=>e.resize(t)),super.__onResize(t)}updateLayout(){this.forEach(t=>t.updateLayout())}__getChildConfig(t){const e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&_.assign(e,t),this.autoLayout&&_.copyAttrs(e,this,Re),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Go.END,this.__onReady,this],[Ko.START,this.__onCreated,this],[Ko.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Ko.END,this.__onChildRenderEnd,this))}};Cd=ge([jr()],Cd);const Ld={},Pd={isHoldSpaceKey:()=>Pd.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}},Md={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 Ad extends Mo{get spaceKey(){return Pd.isHoldSpaceKey()}get left(){return Md.left(this)}get right(){return Md.right(this)}get middle(){return Md.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}isHoldKeys(t){return Pd.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:Dd,max:Id,abs:Wd}=Math,{float:Fd,sign:zd}=W,{minX:Yd,maxX:Nd,minY:Xd,maxY:Hd}=Ht,Vd=new Gt,Ud=new Gt,jd={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Gd.getValidMove(t.__localBoxBounds,Gd.getDragBounds(t),s,e,!0),Gd.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:r}=t;n&&Gd.getValidScaleOf(t.__localBoxBounds,Gd.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)),Gd.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),Gd.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,o,a){a||(n=Object.assign({},n)),Ud.set(e),Vd.set(t).scaleOf(s,n.x,n.y);const h=(s.x-t.x)/t.width,l=1-h,d=(s.y-t.y)/t.height,c=1-d;let u,_,g,p,f=1,m=1;return Gd.isInnerMode(t,e,i,"width")?(n.x<0&&Vd.scaleOf(s,f=1/n.x,1),g=Fd(Vd.minX-Ud.minX),p=Fd(Ud.maxX-Vd.maxX),u=h&&g>0?1+g/(h*Vd.width):1,_=l&&p>0?1+p/(l*Vd.width):1,f*=Id(u,_)):(n.x<0&&((Fd(Yd(t)-Yd(e))<=0||Fd(Nd(e)-Nd(t))<=0)&&Vd.scaleOf(s,f=1/n.x,1),Vd.unsign()),g=Fd(Ud.minX-Vd.minX),p=Fd(Vd.maxX-Ud.maxX),u=h&&g>0?1-g/(h*Vd.width):1,_=l&&p>0?1-p/(l*Vd.width):1,f*=Dd(u,_)),Gd.isInnerMode(t,e,i,"height")?(n.y<0&&Vd.scaleOf(s,1,m=1/n.y),g=Fd(Vd.minY-Ud.minY),p=Fd(Ud.maxY-Vd.maxY),u=d&&g>0?1+g/(d*Vd.height):1,_=c&&p>0?1+p/(c*Vd.height):1,m*=Id(u,_),o&&(u=Id(Wd(f),Wd(m)),f=zd(f)*u,m=zd(m)*u)):(n.y<0&&((Fd(Xd(t)-Xd(e))<=0||Fd(Hd(e)-Hd(t))<=0)&&Vd.scaleOf(s,1,m=1/n.y),Vd.unsign()),g=Fd(Ud.minY-Vd.minY),p=Fd(Vd.maxY-Ud.maxY),u=d&&g>0?1-g/(d*Vd.height):1,_=c&&p>0?1-p/(c*Vd.height):1,m*=Dd(u,_)),n.x*=r(f)?f:1,n.y*=r(m)?m:1,n}},Gd=jd;let Kd=class extends Ad{};Kd.POINTER="pointer",Kd.BEFORE_DOWN="pointer.before_down",Kd.BEFORE_MOVE="pointer.before_move",Kd.BEFORE_UP="pointer.before_up",Kd.DOWN="pointer.down",Kd.MOVE="pointer.move",Kd.UP="pointer.up",Kd.OVER="pointer.over",Kd.OUT="pointer.out",Kd.ENTER="pointer.enter",Kd.LEAVE="pointer.leave",Kd.TAP="tap",Kd.DOUBLE_TAP="double_tap",Kd.CLICK="click",Kd.DOUBLE_CLICK="double_click",Kd.LONG_PRESS="long_press",Kd.LONG_TAP="long_tap",Kd.MENU="pointer.menu",Kd.MENU_TAP="pointer.menu_tap",Kd=ge([Gr()],Kd);const Zd=Kd,qd={};let Jd=class extends Kd{static setList(t){this.list=t instanceof fh?t:new fh(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),jd.axisMove(t,n),n}static limitMove(t,e){jd.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(qd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(qd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(qd,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 Ht.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Ht.unsign(i),i}assignMove(t){qd.x=t?this.totalX:this.moveX,qd.y=t?this.totalY:this.moveY}};Jd.BEFORE_DRAG="drag.before_drag",Jd.START="drag.start",Jd.DRAG="drag",Jd.END="drag.end",Jd.OVER="drag.over",Jd.OUT="drag.out",Jd.ENTER="drag.enter",Jd.LEAVE="drag.leave",Jd=ge([Gr()],Jd);const $d=Jd;let Qd=class extends Kd{static setList(t){Jd.setList(t)}static setData(t){Jd.setData(t)}};Qd.DROP="drop",Qd=ge([Gr()],Qd);let tc=class extends Jd{};tc.BEFORE_MOVE="move.before_move",tc.START="move.start",tc.MOVE="move",tc.END="move.end",tc=ge([Gr()],tc);let ec=class extends Ad{};ec=ge([Gr()],ec);const ic=ec;let sc=class extends Kd{};sc.BEFORE_ROTATE="rotate.before_rotate",sc.START="rotate.start",sc.ROTATE="rotate",sc.END="rotate.end",sc=ge([Gr()],sc);let nc=class extends Jd{};nc.SWIPE="swipe",nc.LEFT="swipe.left",nc.RIGHT="swipe.right",nc.UP="swipe.up",nc.DOWN="swipe.down",nc=ge([Gr()],nc);let rc=class extends Kd{};rc.BEFORE_ZOOM="zoom.before_zoom",rc.START="zoom.start",rc.ZOOM="zoom",rc.END="zoom.end",rc=ge([Gr()],rc);let oc=class extends Ad{};oc.BEFORE_DOWN="key.before_down",oc.BEFORE_UP="key.before_up",oc.DOWN="key.down",oc.HOLD="key.hold",oc.UP="key.up",oc=ge([Gr()],oc);const ac={getDragEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:i.x,y:i.y,moveX:i.x-e.x,moveY:i.y-e.y,totalX:i.x-t.x,totalY:i.y-t.y}),getDropEventData:(t,e,i)=>Object.assign(Object.assign({},t),{list:e,data:i}),getSwipeDirection:t=>t<-45&&t>-135?nc.UP:t>45&&t<135?nc.DOWN:t<=45&&t>=-45?nc.RIGHT:nc.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:hc.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:i(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 fh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:t=>t&&t.list.some(t=>ro.draggable(t)||!t.isLeafer&&t.hasEvent(Jd.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},hc=ac,lc=new fh,{getDragEventData:dc,getDropEventData:cc,getSwipeEventData:uc}=ac;class _c{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=dc(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,n=Jd.list||this.draggableList||lc;return this.dragging&&(s?t?lc:new fh(e?[...i.list,...i.dragHoverExclude]:i.list):n)}checkDrag(t,e){const{interaction:i}=this;if(this.moving&&t.buttons<1)return this.canAnimate=!1,void i.pointerCancel();!this.moving&&e&&(this.moving=i.canMove(this.downData)||i.isHoldRightKey||i.isMobileDragEmpty)&&(this.dragData.moveType="drag",i.emit(tc.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&Md.left(t),this.dragging&&(this.interaction.emit(Jd.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],ro.draggable(e)){this.draggableList=new fh(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:n,throughPath:r}=s;this.dragData=dc(s,i,t),r&&(this.dragData.throughPath=r),this.dragData.path=n,this.moving?(t.moving=!0,this.dragData.moveType="drag",e.emit(tc.BEFORE_MOVE,this.dragData),e.emit(tc.MOVE,this.dragData)):this.dragging&&(t.dragging=!0,this.dragReal(),e.emit(Jd.BEFORE_DRAG,this.dragData),e.emit(Jd.DRAG,this.dragData))}dragReal(t){const{interaction:e}=this,{running:i}=e,s=this.realDraggableList;if(s.length&&i){const{totalX:i,totalY:r}=this.dragData,{dragLimitAnimate:a}=e.p,h=!a||!!t;s.forEach(e=>{if(e.draggable){const s=n(e.draggable),l=Jd.getValidMove(e,this.dragStartPoints[e.innerId],{x:i,y:r},h||s);a&&!s&&t?ro.animateMove(e,l,o(a)?a:.3):e.move(l)}})}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit(Jd.OUT,t,i),e.emit(Jd.OVER,t,s)):e.emit(Jd.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit(Jd.LEAVE,t,i,s),e.emit(Jd.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:n,throughPath:r}=i,o=dc(i,t,t);if(r&&(o.throughPath=r),o.path=n,this.moving&&(this.moving=!1,o.moveType="drag",e.emit(tc.END,o)),this.dragging){const n=this.getList();this.dragging=!1,e.p.dragLimitAnimate&&this.dragReal(!0),e.emit(Jd.END,o),this.swipe(t,i,s,o),this.drop(t,n,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=uc(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=cc(t,e,Jd.data);s.path=i,this.interaction.emit(Qd.DROP,s),this.interaction.emit(Jd.LEAVE,t,i)}dragReset(){Jd.list=Jd.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 gc=$t.get("emit");const pc=["move","zoom","rotate","key"];function fc(t,e,i,s,n){if(pc.some(t=>e.startsWith(t))&&t.__.hitChildren&&!yc(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&&mc(r,e,i,s,n)}}function mc(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!yc(t,n)&&(tl.updateEventStyle&&!s&&tl.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 yc(t,e){return e&&e.has(t)}const vc={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:xc,pathCanDrag:wc,pathHasOutside:bc}=ac;class kc{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&&Md.middle(this.downData)}get isHoldRightKey(){return this.m.holdRightKey&&this.downData&&Md.right(this.downData)}get isHoldSpaceKey(){return this.m.holdSpaceKey&&Pd.isHoldSpaceKey()}get m(){return this.config.move}get p(){return this.config.pointer}get hitRadius(){return this.p.hitRadius}constructor(t,e,i,s){this.config=_.clone(vc),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new fh(t),this.createTransformer(),this.dragger=new _c(this),s&&(this.config=_.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Md.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(Kd.BEFORE_DOWN,t),this.emit(Kd.DOWN,t),Md.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=Md.right(t),this.dragger.setDragData(t),this.isHoldRightKey||this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&Md.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(Kd.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=lt.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(Kd.MOVE,t),this.pointerHover(t),this.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t))),this.updateCursor(this.downData||t)}pointerUp(t){const{downData:e}=this;if(t||(t=e),!e)return;Md.defaultLeft(t),t.multiTouch=e.multiTouch,this.findPath(t);const i=Object.assign(Object.assign({},t),{path:t.path.clone()});t.path.addList(e.path.list),this.checkPath(t),this.downData=null,this.emit(Kd.BEFORE_UP,t),this.emit(Kd.UP,t),this.touchLeave(t),t.isCancel||(this.tap(t),this.menuTap(t)),this.dragger.dragEnd(t),this.updateCursor(i)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(t){this.findPath(t),this.emit(Kd.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(Kd.MENU_TAP,t),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(t){if(!this.config.keyEvent)return;this.emit(oc.BEFORE_DOWN,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Pd.setDownCode(e),this.emit(oc.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(oc.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;this.emit(oc.BEFORE_UP,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]=!1,Pd.setUpCode(e),this.emit(oc.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new fh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(t){const{path:e}=t,{overPath:i}=this;this.overPath=e,i?e.indexAt(0)!==i.indexAt(0)&&(this.emit(Kd.OUT,t,i),this.emit(Kd.OVER,t,e)):this.emit(Kd.OVER,t,e)}pointerEnterOrLeave(t){let{path:e}=t;this.downData&&!this.moveMode&&(e=e.clone(),this.downData.path.forEach(t=>e.add(t)));const{enterPath:i}=this;this.enterPath=e,this.emit(Kd.LEAVE,t,i,e),this.emit(Kd.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(Kd.LEAVE,t),this.dragger.dragging&&this.emit(Qd.LEAVE,t))}tap(t){const{pointer:e}=this.config,i=this.longTap(t);if(!e.tapMore&&i)return;if(!this.waitTap)return;e.tapMore&&this.emitTap(t);const s=Date.now()-this.downTime,n=[Kd.DOUBLE_TAP,Kd.DOUBLE_CLICK].some(e=>xc(t.path,e));s<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))},e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(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&&!bc(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!wc(t.path))&&!bc(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getList(!1,!0),name:Kd.MOVE}),this.hoverData=t)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),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(t){this.emit(Kd.TAP,t),this.emit(Kd.CLICK,t)}emitDoubleTap(t){this.emit(Kd.DOUBLE_TAP,t),this.emit(Kd.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(Kd.LONG_PRESS,t)},this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(Kd.LONG_TAP,t),(xc(t.path,Kd.LONG_TAP)||xc(t.path,Kd.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new Gt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(o(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Uo.RESIZE,this.__onResize,this)],t.once(Zo.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],mc(n,t,e,!0,s))return;n.isApp&&fc(n,t,e,!0,s)}for(let r=0,o=i.length;r<o;r++)if(n=i.list[r],n.isApp&&fc(n,t,e,!1,s),mc(n,t,e,!1,s))return}catch(t){gc.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 Ec{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Ec.custom={};class Sc extends _e{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new fh,this.pixelList=new fh}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:Bc,copy:Tc,setRadius:Rc}=lt,{hitRadiusPoint:Oc,hitPoint:Cc}=Ht,Lc={},Pc={},Mc=rh.prototype;Mc.hit=function(t,e=0){this.updateLayout(),Tc(Pc,t),Rc(Pc,e);const i=this.__world;return!!(e?Oc(i,Pc):Cc(i,Pc))&&(this.isBranch?y.getSelector(this).hitPoint(Object.assign({},Pc),e,{target:this}):this.__hitWorld(Pc))},Mc.__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&&(Tc(Lc,t),Rc(t=Lc,e.hitRadius)),Bc(t,i,Lc),e.hitBox||n){if(Ht.hitRadiusPoint(s.boxBounds,Lc))return!0;if(n)return!1}return!s.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),s.boundsChanged||(s.hitCanvasChanged=!1)),this.__hit(Lc)},Mc.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},Mc.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},Mc.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},Mc.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const Ac=new ft,Dc=Ml.prototype;Dc.__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(),Qn.patternLocked=!0,this.__renderShape(r,{matrix:Ac.setWith(this.__world).scaleWith(1/o).invertWith().translate(-a,-h),ignoreFill:!i,ignoreStroke:!s}),Qn.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},Dc.__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 Ic=Ml.prototype,Wc=Fl.prototype,Fc=Vl.prototype;Wc.__updateHitCanvas=Fc.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?Ic.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},Wc.__hitFill=Fc.__hitFill=function(t){return this.__hitCanvas?Ic.__hitFill.call(this,t):Ht.hitRadiusPoint(this.__layout.boxBounds,t)},Td.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))},Al.prototype.pick=function(t,i){return i||(i=e),this.updateLayout(),y.getSelector(this).getByPoint(t,i.hitRadius||0,Object.assign(Object.assign({},i),{target:this}))};const zc=Oe.prototype;function Yc(t,e,i){t.__.__font?Kh.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Nc(t,e,i,s,n){const r=i.__;d(t)?Kh.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),s.stroke()),r.__useArrow&&Kh.strokeArrow(t,i,s,n)}function Xc(t,e,i,s,n){const r=i.__;d(t)?Kh.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),Kh.drawTextStroke(i,s,n))}function Hc(t,e,i,s,n){const r=s.getSameCanvas(!0,!0);r.font=i.__.__font,Xc(t,2,i,r,n),r.blendMode="outside"===e?"destination-out":"destination-in",Kh.fillText(i,r,n),r.blendMode="normal",ro.copyCanvasByWorld(i,s,r),r.recycle(i.__nowWorld)}zc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},zc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},zc.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:Vc,copyAndSpread:Uc,toOuterOf:jc,getOuterOf:Gc,getByMove:Kc,move:Zc,getIntersectData:qc}=Ht,Jc={};let $c;const{stintSet:Qc}=_,{hasTransparent:tu}=Uh;function eu(t,e,s){if(!d(e)||!1===e.visible||0===e.opacity)return;let r;const{boxBounds:o}=s.__layout;switch(e.type){case"image":r=Zh.image(s,t,e,o,!$c||!$c[e.url]);break;case"linear":r=qh.linearGradient(e,o);break;case"radial":r=qh.radialGradient(e,o);break;case"angular":r=qh.conicGradient(e,o);break;case"solid":const{type:n,color:a,opacity:h}=e;r={type:n,style:Uh.string(a,h)};break;default:i(e.r)||(r={type:"solid",style:Uh.string(e)})}if(r&&(r.originPaint=e,n(r.style)&&tu(r.style)&&(r.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;r.strokeStyle=e.style}return r}const iu={compute:function(t,e){const i=e.__,s=[];let n,r,o,a=i.__input[t];l(a)||(a=[a]),$c=Zh.recycleImage(t,i);for(let i,n=0,r=a.length;n<r;n++)(i=eu(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?(Qc(i,"__isAlphaPixelFill",n),Qc(i,"__isTransparentFill",r)):(Qc(i,"__isAlphaPixelStroke",n),Qc(i,"__isTransparentStroke",r),Qc(i,"__hasMultiStrokeStyle",o))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Yc(e,i,s)},fills:function(t,e,i,s){let n,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,Zh.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),Yc(e,i,s),i.restore()}else r.blendMode?(i.saveBlendMode(r.blendMode),Yc(e,i,s),i.restoreBlendMode()):Yc(e,i,s)}},fillPathOrText:Yc,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)Kh.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":Nc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Nc(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)Nc(t,2,e,i,s);else{const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Nc(t,2,e,o,s),o.clipUI(n),o.clearWorld(r),ro.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Kh.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Xc(t,1,e,i,s);break;case"inside":Hc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Xc(t,2,e,i,s):Hc(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||!Zh.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?Kh.drawTextStroke(s,n,r):n.stroke(),n.restoreBlendMode()):i?Kh.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,_;jc(o.strokeSpread?(Uc(Jc,o.boxBounds,o.strokeSpread),Jc):o.boxBounds,r,a);let{scaleX:g,scaleY:p}=t.getRenderScaleData(!0);if(n.includes(a))_=s,h=u=a,l=r;else{let s;if(y.fullImageShadow)s=a;else{const t=o.renderShapeSpread?Vc(n,T.swapAndScale(o.renderShapeSpread,g,p)):n;s=qc(t,a)}c=n.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(_=e.getSameCanvas(),t.__renderShape(_,i),g*=f,p*=m),u=Gc(a,c),h=Kc(u,-c.e,-c.f),l=Gc(r,c),Zc(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:_,shapeBounds:u,scaleX:g,scaleY:p}}};let su,nu=new Gt;const{isSame:ru}=Ht;function ou(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||Zh.createData(n,s,i,r),!0}function au(t,e){du(t,Fo.LOAD,e)}function hu(t,e){du(t,Fo.LOADED,e)}function lu(t,e,i){e.error=i,t.forceUpdate("surface"),du(t,Fo.ERROR,e)}function du(t,e,i){t.hasEvent(e)&&t.emitEvent(new Fo(e,i))}function cu(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:uu,translate:_u}=$,gu=new Gt,pu={},fu={};function mu(t,e,i,s){const r=n(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&r<0?0:r}let yu={},vu={a:1,b:0,c:0,d:1,e:0,f:0};const{get:xu,set:wu,rotateOfOuter:bu,translate:ku,scaleOfOuter:Eu,multiplyParent:Su,scale:Bu,rotate:Tu,skew:Ru}=$;function Ou(t,e,i,s,n,r,o,a){o&&Tu(t,o),a&&Ru(t,a.x,a.y),n&&Bu(t,n,r),ku(t,e.x+i,e.y+s)}const{get:Cu,scale:Lu,copy:Pu}=$,{getFloorScale:Mu}=W,{abs:Au}=Math;const Du={image:function(t,e,i,s,n){let r,o;const a=Qn.get(i);return su&&i===su.paint&&ru(s,su.boxBounds)?r=su.leafPaint:(r={type:i.type,image:a},a.hasAlphaPixel&&(r.isTransparent=!0),su=a.use>1?{leafPaint:r,paint:i,boxBounds:nu.set(s)}:null),(n||a.loading)&&(o={image:a,attrName:e,attrValue:i}),a.ready?(ou(t,e,i,a,r,s),n&&(au(t,o),hu(t,o))):a.error?n&&lu(t,o,a.error):(n&&(cu(t,!0),au(t,o)),r.loadId=a.load(()=>{cu(t,!1),t.destroyed||(ou(t,e,i,a,r,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),hu(t,o)),r.loadId=void 0},e=>{cu(t,!1),lu(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}=Zh.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&&Uo.isResizing(i)||d||(e=y.image.isLarge(a,r,o))),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),Zh.drawImage(t,r,o,i,s,n),!0):(!t.style||l.sync||d?Zh.createPattern(t,i,s,n):Zh.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 _,{width:g,height:p}=a;(_=d&&!d.onlyScale||u.path||u.cornerRadius)||l||h?(n.save(),_&&n.clipUI(s),h&&(n.blendMode=h),l&&(n.opacity*=l),d&&n.transform(d),n.drawImage(c,0,0,g,p),n.restore()):(o.scaleX&&(g*=o.scaleX,p*=o.scaleY),n.drawImage(c,0,0,g,p))},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,Qn.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=Qn.patternTasker.add(()=>pe(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&Zh.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,e,i,s){let{scaleX:n,scaleY:r}=Zh.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=Zh.getPatternFixScale(t,n,r);let d,c,u,{width:_,height:g}=i;l&&(n*=l,r*=l),_*=n,g*=r,h&&(c=h.x*n/Au(s.scaleX||1),u=h.y*r/Au(s.scaleY||1)),(a||1!==n||1!==r)&&(n*=Mu(_+(c||0)),r*=Mu(g+(u||0)),d=Cu(),a&&Pu(d,a),Lu(d,1/n,1/r));const p=i.getCanvas(_,g,s.opacity,s.filters,c,u,e.leafer&&e.leafer.config.smooth),f=i.getPattern(p,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=Zh.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=gu.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:r}=i,{opacity:o,mode:a,align:h,offset:l,scale:c,size:u,rotation:_,skew:g,clipSize:p,repeat:f,gap:m,filters:y}=t,v=e.width===s&&e.height===r,x={mode:a},w="center"!==h&&(_||0)%180==90;let b,k;switch(Ht.set(fu,0,0,w?r:s,w?s:r),a&&"cover"!==a&&"fit"!==a?((c||u)&&(W.getScaleData(c,u,i,pu),b=pu.scaleX,k=pu.scaleY),(h||m||f)&&(b&&Ht.scale(fu,b,k,!0),h&&Bt.toPoint(h,fu,e,fu,!0,!0))):v&&!_||(b=k=Ht.getFitScale(e,fu,"fit"!==a),Ht.put(e,i,h,b,!1,fu),Ht.scale(fu,b,k,!0)),l&&lt.move(fu,l),a){case"stretch":v?b&&(b=k=void 0):(b=e.width/s,k=e.height/r,Zh.stretchMode(x,e,b,k));break;case"normal":case"clip":if(fu.x||fu.y||b||p||_||g){let t,i;p&&(t=e.width/p.width,i=e.height/p.height),Zh.clipMode(x,e,fu.x,fu.y,b,k,_,g,t,i),t&&(b=b?b*t:t,k=k?k*i:i)}break;case"repeat":(!v||b||_||g)&&Zh.repeatMode(x,e,s,r,fu.x,fu.y,b,k,_,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:mu(r,i,n.width,e&&e.x),y:mu(o,s,n.height,e&&e.y)}}(m,i&&f,fu.width,fu.height,e));break;default:b&&Zh.fillOrFitMode(x,e,fu.x,fu.y,b,k,_)}return x.transform||(e.x||e.y)&&_u(x.transform=uu(),e.x,e.y),b&&(x.scaleX=b,x.scaleY=k),o&&o<1&&(x.opacity=o),y&&(x.filters=y),f&&(x.repeat=n(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),x},stretchMode:function(t,e,i,s){const n=xu(),{x:r,y:o}=e;r||o?ku(n,r,o):n.onlyScale=!0,Bu(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,r,o){const a=xu();ku(a,e.x+i,e.y+s),Bu(a,n,r),o&&bu(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=xu();Ou(d,e,i,s,n,r,o,a),h&&(o||a?(wu(vu),Eu(vu,e,h,l),Su(d,vu)):Eu(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,n,r,o,a,h,l,d,c){const u=xu();if(c)Ou(u,e,n,r,o,a,h,l);else{if(h)if("center"===d)bu(u,{x:i/2,y:s/2},h);else switch(Tu(u,h),h){case 90:ku(u,s,0);break;case 180:ku(u,i,s);break;case 270:ku(u,0,i)}yu.x=e.x+n,yu.y=e.y+r,ku(u,yu.x,yu.y),o&&Eu(u,yu,o,a)}t.transform=u}},{toPoint:Iu}=kt,{hasTransparent:Wu}=Uh,Fu={},zu={};function Yu(t,e,i,s){if(i){let r,o,a,h;for(let t=0,l=i.length;t<l;t++)r=i[t],n(r)?(a=t/(l-1),o=Uh.string(r,s)):(a=r.offset,o=Uh.string(r.color,s)),e.addColorStop(a,o),!h&&Wu(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Nu,getDistance:Xu}=lt,{get:Hu,rotateOfOuter:Vu,scaleOfOuter:Uu}=$,{toPoint:ju}=kt,Gu={},Ku={};function Zu(t,e,i,s,n){let r;const{width:o,height:a}=t;if(o!==a||s){const t=Nu(e,i);r=Hu(),n?(Uu(r,e,o/a*(s||1),1),Vu(r,e,t+90)):(Uu(r,e,1,o/a*(s||1)),Vu(r,e,t))}return r}const{getDistance:qu}=lt,{toPoint:Ju}=kt,$u={},Qu={};const t_={linearGradient:function(t,e){let{from:i,to:s,type:n,opacity:r}=t;Iu(i||"top",e,Fu),Iu(s||"bottom",e,zu);const o=y.canvas.createLinearGradient(Fu.x,Fu.y,zu.x,zu.y),a={type:n,style:o};return Yu(a,o,t.stops,r),a},radialGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;ju(i||"center",e,Gu),ju(s||"bottom",e,Ku);const a=y.canvas.createRadialGradient(Gu.x,Gu.y,0,Gu.x,Gu.y,Xu(Gu,Ku)),h={type:n,style:a};Yu(h,a,t.stops,r);const l=Zu(e,Gu,Ku,o,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;Ju(i||"center",e,$u),Ju(s||"bottom",e,Qu);const a=y.conicGradientSupport?y.canvas.createConicGradient(0,$u.x,$u.y):y.canvas.createRadialGradient($u.x,$u.y,0,$u.x,$u.y,qu($u,Qu)),h={type:n,style:a};Yu(h,a,t.stops,r);const l=Zu(e,$u,Qu,o||1,y.conicGradientRotate90);return l&&(h.transform=l),h},getTransform:Zu},{copy:e_,move:i_,toOffsetOutBounds:s_}=Ht,{max:n_,abs:r_}=Math,o_={},a_=new ft,h_={};function l_(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=r_(t.spread||0),o=n_(o,n+r-s),a=n_(a,n+r+i),h=n_(h,n+r+s),l=n_(l,n+r-i)}),o===a&&a===h&&h===l?o:[o,a,h,l]}function d_(t,e,i){const{shapeBounds:s}=i;let n,r;y.fullImageShadow?(e_(o_,t.bounds),i_(o_,e.x-s.x,e.y-s.y),n=t.bounds,r=o_):(n=s,r=e),t.copyWorld(i.canvas,n,r)}const{toOffsetOutBounds:c_}=Ht,u_={};const __=l_;const g_={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,_=e.getSameCanvas(),g=o.length-1;s_(h,h_,l),o.forEach((o,p)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}_.setWorldShadow(h_.offsetX+(o.x||0)*c*f,h_.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f,Uh.string(o.color)),n=Jh.getShadowTransform(t,_,i,o,h_,f),n&&_.setTransform(n),d_(_,h_,i),n&&_.resetTransform(),s=l,o.box&&(_.restore(),_.save(),a&&(_.copyWorld(_,l,r,"copy"),s=r),a?_.copyWorld(a,r,r,"destination-out"):_.copyWorld(i.canvas,d,h,"destination-out")),ro.copyCanvasByWorld(t,e,_,s,o.blendMode),g&&p<g&&_.clearWorld(s)}),_.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,_=e.getSameCanvas(),g=o.length-1;c_(h,u_,l),o.forEach((o,p)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}_.save(),_.setWorldShadow(u_.offsetX+(o.x||0)*c*f,u_.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f),n=Jh.getShadowTransform(t,_,i,o,u_,f,!0),n&&_.setTransform(n),d_(_,u_,i),_.restore(),a?(_.copyWorld(_,l,r,"copy"),_.copyWorld(a,r,r,"source-out"),s=r):(_.copyWorld(i.canvas,d,h,"source-out"),s=l),_.fillWorld(s,Uh.string(o.color),"source-in"),ro.copyCanvasByWorld(t,e,_,s,o.blendMode),g&&p<g&&_.clearWorld(s)}),_.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:l_,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 a_.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),a_}},isTransformShadow(t){},getInnerShadowSpread:__},{excludeRenderBounds:p_}=go;let f_;function m_(t,e,i,s,n,r,o,a){switch(e){case"grayscale":f_||(f_=!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);v_(t,e,i,1,n,r)}(t,i,s,n,o,a);break;case"opacity-path":v_(t,i,s,r,o,a);break;case"path":a&&i.restore()}}function y_(t){return t.getSameCanvas(!1,!0)}function v_(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)}Al.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&&(m_(this,o,t,n,s,r,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||p_(i,e)||i.__render(t,e),r=i.__.opacity,f_=!1,"path"===a||"clipping-path"===a?(r<1?(o="opacity-path",n||(n=y_(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===a?"grayscale":"alpha",s||(s=y_(t)),n||(n=y_(t)),i.__render(s,e));continue}const d=1===r&&i.__.__blendMode;d&&m_(this,o,t,n,s,r,void 0,!1),p_(i,e)||i.__render(n||t,e),d&&m_(this,o,t,n,s,r,d,!1)}m_(this,o,t,n,s,r,void 0,!0)};const x_=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",w_=x_+"_#~&*+\\=|≮≯≈≠=…",b_=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 k_(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const E_=k_("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),S_=k_("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),B_=k_(x_),T_=k_(w_),R_=k_("- —/~|┆·");var O_;!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"}(O_||(O_={}));const{Letter:C_,Single:L_,Before:P_,After:M_,Symbol:A_,Break:D_}=O_;function I_(t){return E_[t]?C_:R_[t]?D_:S_[t]?P_:B_[t]?M_:T_[t]?A_:b_.test(t)?L_:C_}const W_={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 F_(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:z_}=W_,{Letter:Y_,Single:N_,Before:X_,After:H_,Symbol:V_,Break:U_}=O_;let j_,G_,K_,Z_,q_,J_,$_,Q_,tg,eg,ig,sg,ng,rg,og,ag,hg,lg=[];function dg(t,e){tg&&!Q_&&(Q_=tg),j_.data.push({char:t,width:e}),K_+=e}function cg(){Z_+=K_,j_.width=K_,G_.words.push(j_),j_={data:[]},K_=0}function ug(){rg&&(og.paraNumber++,G_.paraStart=!0,rg=!1),tg&&(G_.startCharSize=Q_,G_.endCharSize=tg,Q_=0),G_.width=Z_,ag.width?z_(G_):hg&&_g(),lg.push(G_),G_={words:[]},Z_=0}function _g(){Z_>(og.maxWidth||0)&&(og.maxWidth=Z_)}const{top:gg,right:pg,bottom:fg,left:mg}=xt;function yg(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 vg={getDrawData:function(t,e){n(t)||(t=String(t));let i=0,s=0,r=e.__getInput("width")||0,o=e.__getInput("height")||0;const{__padding:a}=e;a&&(r?(i=a[mg],r-=a[pg]+a[mg],!r&&(r=.01)):e.autoSizeAlign||(i=a[mg]),o?(s=a[gg],o-=a[gg]+a[fg],!o&&(o=.01)):e.autoSizeAlign||(s=a[gg]));const h={bounds:{x:i,y:s,width:r,height:o},rows:[],paraNumber:0,font:y.canvas.font=e.__font};return function(t,e,i){og=t,lg=t.rows,ag=t.bounds,hg=!ag.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:o}=y,{width:a}=ag;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;rg=!0,ig=null,Q_=$_=tg=K_=Z_=0,j_={data:[]},G_={words:[]},s&&(e=[...e]);for(let i=0,l=e.length;i<l;i++)J_=e[i],"\n"===J_?(K_&&cg(),G_.paraEnd=!0,ug(),rg=!0):(eg=I_(J_),eg===Y_&&"none"!==r&&(J_=F_(J_,r,!K_)),$_=o.measureText(J_).width,s&&(s<0&&(tg=$_),$_+=s),sg=eg===N_&&(ig===N_||ig===Y_)||ig===N_&&eg!==H_,ng=!(eg!==X_&&eg!==N_||ig!==V_&&ig!==H_),q_=rg&&n?a-n:a,t&&a&&Z_+K_+$_>q_&&(h?(K_&&cg(),Z_&&ug()):(ng||(ng=eg===Y_&&ig==H_),sg||ng||eg===U_||eg===X_||eg===N_||K_+$_>q_?(K_&&cg(),Z_&&ug()):Z_&&ug()))," "===J_&&!0!==rg&&Z_+K_===0||(eg===U_?(" "===J_&&K_&&cg(),dg(J_,$_),cg()):sg||ng?(K_&&cg(),dg(J_,$_)):dg(J_,$_)),ig=eg);K_&&cg(),Z_&&ug(),lg.length>0&&(lg[lg.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{og.paraNumber++,Z_=o.measureText(t).width,lg.push({x:n||0,text:t,width:Z_,paraStart:!0}),hg&&_g()})}(h,t,e),a&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":yg(e,"x",t[mg]);break;case"right":yg(e,"x",-t[pg])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":yg(e,"y",t[gg]);break;case"bottom":yg(e,"y",-t[fg])}}(a,h,e,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:_,y:g,width:p,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,b=p||u?p:t.maxWidth;for(let o=0,d=n;o<d;o++){if(v=i[o],v.x=_,v.width<p||v.width>p&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-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&&p&&p<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,_,g,p,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?_=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),p=o||t.isOverflow||l?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===p?(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===p?(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&&_),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):_&&(t.width+=_*(e.data.length-(y?1:0))))})),t.words=null)})}(h,e,r),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,r),"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=Uh.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 xg={string:function(t,e){if(!t)return"#000";const s=o(e)&&e<1;if(n(t)){if(!s||!Uh.object)return t;t=Uh.object(t)}let r=i(t.a)?1:t.a;s&&(r*=e);const a=t.r+","+t.g+","+t.b;return 1===r?"rgb("+a+")":"rgba("+a+","+r+")"}};function wg(t){return t?l(t)?t:[t]:[]}Object.assign(Vh,vg),Object.assign(Uh,xg),Object.assign(Kh,iu),Object.assign(Zh,Du),Object.assign(qh,t_),Object.assign(Jh,g_),Object.assign(oe,{interaction:(t,e,i,s)=>new kc(t,e,i,s),hitCanvas:(t,e)=>new vh(t,e),hitCanvasManager:()=>new Sc}),wh();class bg extends Mo{get list(){return wg(this.value)}get oldList(){return wg(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function kg(t){return(e,i)=>{const s="_"+i;nr(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?bg.BEFORE_SELECT:bg.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new bg(s,{editor:r,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}bg.BEFORE_SELECT="editor.before_select",bg.SELECT="editor.select",bg.AFTER_SELECT="editor.after_select",bg.BEFORE_HOVER="editor.before_hover",bg.HOVER="editor.hover";const{abs:Eg}=Math,{copy:Sg,scale:Bg}=$,{setListWithFn:Tg}=Ht,{worldBounds:Rg}=go,Og={a:1,b:0,c:0,d:1,e:0,f:0},Cg={x:0,y:0,width:0,height:0};class Lg extends Ml{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?(Tg(Cg,e,Rg),t&&this.set(t),this.set(Cg),this.visible=!0):this.visible=0}__draw(t,e){const{list:i}=this;if(i.length){let s;const r=this.__,{stroke:o,strokeWidth:a,fill:h}=r,{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=Eg(c.scaleX),l=Eg(c.scaleY);if(Sg(Og,c),Og.half=a%2,i!==l){Bg(Og,1/i,1/l),t.setWorld(Og,e.matrix),t.beginPath(),r.strokeWidth=a;const{x:n,y:o,width:h,height:d}=s.__layout.boxBounds;t.rect(n*i,o*l,h*i,d*l)}else t.setWorld(Og,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),r.strokeWidth=a/Eg(c.scaleX);o&&(n(o)?Kh.stroke(o,this,t,e):Kh.strokes(o,this,t,e)),h&&(n(h)?Kh.fill(h,this,t,e):Kh.fills(h,this,t,e))}}r.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}ge([kg(function(t){const e=t.target;t.list=e?l(e)?e:[e]:[]})],Lg.prototype,"target",void 0);class Pg extends Al{constructor(t){super(t),this.strokeArea=new Fl({strokeAlign:"center"}),this.fillArea=new Fl,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 Mg={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return Ag([t],i,e),i}};function Ag(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&&Ag(s.children,e,i)}}const{findOne:Dg,findByBounds:Ig}=Mg;class Wg extends Al{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 Gt,this.selectArea=new Pg,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 fh(Ig(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)&&!Dg(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new fh(this.editor.editBox.rect)};return Dg(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):Dg(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[bg.HOVER,this.onHover,this],[bg.SELECT,this.onSelect,this]]),e.on_([[Kd.MOVE,this.onPointerMove,this],[Kd.BEFORE_DOWN,this.onBeforeDown,this],[Kd.TAP,this.onTap,this],[Jd.START,this.onDragStart,this,!0],[Jd.DRAG,this.onDrag,this],[Jd.END,this.onDragEnd,this],[tc.MOVE,this.onAutoMove,this],[[rc.ZOOM,tc.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:zg,topRight:Yg,right:Ng,bottomRight:Xg,bottom:Hg,bottomLeft:Vg,left:Ug}=wt,{toPoint:jg}=kt,{within:Gg,sign:Kg}=W,{abs:Zg}=Math,qg={getScaleData(t,e,i,s,n,r,a,h){let l,d,c={},u=1,_=1;const{boxBounds:g,widthRange:p,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:x}=e,w=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,k=Kg(w),E=Kg(b),S=h?w:k*g.width/v,B=h?b:E*g.height/x;if(o(s))u=_=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=h?w:k,s.y*=h?b:E;const t=(-s.y+x)/x,e=(s.x+v)/v,o=(s.y+x)/x,a=(-s.x+v)/v;switch(i){case zg:_=t,l="bottom";break;case Ng:u=e,l="left";break;case Hg:_=o,l="top";break;case Ug:u=a,l="right";break;case Fg:_=t,u=a,l="bottom-right";break;case Yg:_=t,u=e,l="bottom-left";break;case Xg:_=o,u=e,l="top-left";break;case Vg:_=o,u=a,l="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case zg:case Hg:u=_;break;case Ug:case Ng:_=u;break;default:d=Math.sqrt(Zg(u*_)),u=Kg(u)*d,_=Kg(_)*d}}const T=1!==u,R=1!==_;if(T&&(u/=S),R&&(_/=B),!a){const{worldTransform:e}=t;u<0&&(u=1/g.width/e.scaleX),_<0&&(_=1/g.height/e.scaleY)}if(jg(r||l,g,c,!0),m){const e={x:u,y:_};jd.limitScaleOf(t,c,e,n),u=e.x,_=e.y}if(T&&p){const e=g.width*t.scaleX;u=Gg(e*u,p)/e}if(R&&f){const e=g.height*t.scaleY;_=Gg(e*_,f)/e}return T&&Zg(u*y.width)<1&&(u=Kg(u)/y.width),R&&Zg(_*y.height)<1&&(_=Kg(_)/y.height),n&&u!==_&&(d=Math.min(Zg(u),Zg(_)),u=Kg(u)*d,_=Kg(_)*d),isFinite(u)||(u=1),isFinite(_)||(_=1),{origin:c,scaleX:u,scaleY:_,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 Vg:r="top-right";break;default:r="center"}return jg(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 zg:case Fg:r={x:.5,y:0},n="bottom",a=1;break;case Hg:case Xg:r={x:.5,y:1},n="top",a=1;break;case Ug:case Vg:r={x:0,y:.5},n="right",h=1;break;case Ng: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,jg(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 Ug:t=Ng;break;case Fg:t=Yg;break;case Vg:t=Xg;break;case Ng:t=Ug;break;case Yg:t=Fg;break;case Xg:t=Vg}if(i)switch(t){case zg:t=Hg;break;case Fg:t=Vg;break;case Yg:t=Xg;break;case Hg:t=zg;break;case Vg:t=Fg;break;case Xg:t=Yg}return t}},Jg={};function $g(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 Qg(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:_,moveable:g,resizeable:p,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)||!p)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),x=s?n?_:r?c:u:v?_:y?c:u;h+=45*(qg.getFlipDirection(i.direction,o,a)+1),h=2*Math.round(W.formatRotation(h,!0)/2);const{url:w,x:b,y:k}=x,E=w+h;Jg[E]?i.cursor=Jg[E]:Jg[E]=i.cursor={url:tp(w,h),x:b,y:k}}function Qg(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function tp(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class ep extends Vl{constructor(t){super(t),this.useFastShadow=!0}}const ip=["top","right","bottom","left"],sp=void 0;class np extends Al{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 n(t)||n(e)||n(i)}get canDragLimitAnimate(){return this.moving&&this.mergeConfig.dragLimitAnimate&&this.target.dragBounds}constructor(t){super(),this.view=new Al,this.rect=new ep({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new ep({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new Al({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints: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 ep({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new ep({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),o.push(e),this.listenPointEvents(e,"resize",s)),i=new ep({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:n,circle:r,resizePoints:o,resizeLines:a}=this,{stroke:h,strokeWidth:l,ignorePixelSnap:d}=e,c=this.getPointsStyle(),u=this.getMiddlePointsStyle(),g=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let t=0;t<8;t++)p=o[t],p.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:c[t/2%c.length])),p.rotation=(t-(t%2?1:0))/2*90,t%2&&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])),n.set(Object.assign({stroke:h,strokeWidth:l,opacity:1,editConfig:sp},e.rect||{}));const f=s(e.rectThrough)?i:e.rectThrough;n.hittable=!f,f&&(t.syncEventer=n,this.app.interaction.bottomList=[{target:n,proxy:t}]),i&&_.stintSet(t.__world,"ignorePixelSnap",d),Qg(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:a,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{editMask:c}=e,{middlePoint:u,resizeable:_,rotateable:g,hideOnSmall:p,editBox:f,mask:m,dimOthers:y,bright:v,spread:x,hideRotatePoints:w,hideResizeLines:b}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),x&&Ht.spread(t,x),this.view.worldOpacity){const{width:e,height:c}=t,m=o(p)?p:10,y=f&&!(p&&e<m&&c<m);let v,x,k,E={};for(let i=0;i<8;i++)kt.toPoint(kt.directionData[i],t,E),x=h[i],v=l[i],x.set(E),v.set(E),x.visible=y&&!(!_&&!g),v.visible=y&&g&&_&&!w,i%2&&(k=d[(i-1)/2],k.set(E),k.visible=x.visible&&!b,x.visible=v.visible=y&&!!u,(i+1)/2%2?(k.width=e+k.height,p&&2*x.width>e&&(x.visible=!1)):(k.width=c+k.height,p&&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})),a.visible=y&&a.children.length>0||0,a.visible&&this.layoutButtons()}else n.set(t)}layoutCircle(){const{circleDirection:t,circleMargin:e,buttonsMargin:i,buttonsDirection:s,middlePoint:n}=this.mergedConfig,r=ip.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=ip.indexOf(e);(a%2&&r||(a+1)%2&&o)&&i&&(a=(a+2)%4);const h=i?qg.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:sp};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)}$g(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&&(Uo.resizingKeys=this.editor.leafList.keys);const{dragStartData:e,target:i}=this;e.x=t.x,e.y=t.y,e.totalOffset={x:0,y:0},e.point={x:i.x,y:i.y},e.bounds=Object.assign({},i.getLayoutBounds("box","local")),e.rotation=i.rotation}onTransformEnd(t){this.canDragLimitAnimate&&(t instanceof Jd||t instanceof tc)&&this.transformTool.onMove(t),this.resizing&&(Uo.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(t){if(this.canGesture&&"drag"!==t.moveType&&(t.stop(),n(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,t.type){case tc.START:this.onTransformStart(t);break;case tc.END:this.onTransformEnd(t);break;default:this.transformTool.onMove(t)}}onScale(t){if(this.canGesture&&(t.stop(),n(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,t.type){case rc.START:this.onTransformStart(t);break;case rc.END:this.onTransformEnd(t);break;default:this.transformTool.onScale(t)}}onRotate(t){if(this.canGesture&&(t.stop(),n(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,t.type){case rc.START:this.onTransformStart(t);break;case rc.END:this.onTransformEnd(t);break;default:this.transformTool.onRotate(t)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){$g(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(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof Td)||t.find(t=>t instanceof Td);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[Jd.START,this.onDragStart,this],[Jd.DRAG,this.onDrag,this],[Jd.END,this.onDragEnd,this],[Kd.ENTER,e=>{this.enterPoint=t,$g(this,e)}],[Kd.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[Kd.DOUBLE_TAP,this.onDoubleTap,this],[Kd.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[oc.HOLD,oc.UP],this.onKey,this],[oc.DOWN,this.onArrow,this],[[tc.START,tc.BEFORE_MOVE,tc.END],this.onMove,this,!0],[[rc.START,rc.BEFORE_ZOOM,rc.END],this.onScale,this,!0],[[sc.START,sc.BEFORE_ROTATE,sc.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const rp={x:0,y:0,width:1e5,height:1e5};class op extends Ml{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,rp),Object.assign(this.__world,rp)}__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 ap='\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"/>',hp={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${ap}\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${ap}\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${ap}\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},lp=new Gt;function dp(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{lp.setListWithFn(i,t=>t.getBounds("box","page")),0===lp.width&&(lp.width=.1),0===lp.height&&(lp.height=.1),e.reset(lp.get())}),s.add(e)}const cp=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),up=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),_p={group(t,e,i){t.sort(up);const{app:s,parent:n}=t[0];let r;r=i&&i.add?i:new Al(i),n.addAt(r,n.children.indexOf(t[0])),t.sort(cp);const o=new ft(e.worldTransform);return o.divideParent(n.scrollWorldTransform),r.setTransform(o),r.editable=!0,r.hitChildren=!1,s.lockLayout(),t.forEach(t=>t.dropTo(r)),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(cp),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(up),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},gp=$t.get("EditToolCreator");function pp(){return t=>{mp.register(t)}}const fp=pp,mp={list:{},register(t){const{tag:e}=t.prototype;yp[e]&&gp.repeat(e),yp[e]=t},get:(t,e)=>new yp[t](e)},{list:yp}=mp;class vp extends bg{constructor(t,e){super(t,e)}}vp.BEFORE_OPEN="innerEditor.before_open",vp.OPEN="innerEditor.open",vp.BEFORE_CLOSE="innerEditor.before_close",vp.CLOSE="innerEditor.close";class xp extends bg{constructor(t,e){super(t,e)}}xp.BEFORE_GROUP="editor.before_group",xp.GROUP="editor.group",xp.BEFORE_UNGROUP="editor.before_ungroup",xp.UNGROUP="editor.ungroup",xp.BEFORE_OPEN="editor.before_open_group",xp.OPEN="editor.open_group",xp.BEFORE_CLOSE="editor.before_close_group",xp.CLOSE="editor.close_group";const{updateMatrix:wp}=ro,bp={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},kp="top-left";class Ep extends Fl{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Io.CHANGE,e=>{if(this.checkChange&&bp[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,wp(this.parent),wp(this);const a=new ft(this.__world);switch(o[i]=s,this.__layout.rotationChange(),wp(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(kp,r);break;case"scaleX":t.scaleOf(kp,r,1);break;case"scaleY":t.scaleOf(kp,1,r);break;case"skewX":t.skewOf(kp,r,0);break;case"skewY":t.skewOf(kp,0,r)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Sp extends bg{constructor(t,e){super(t,e)}}Sp.BEFORE_MOVE="editor.before_move",Sp.MOVE="editor.move";class Bp extends bg{constructor(t,e){super(t,e)}}Bp.BEFORE_SCALE="editor.before_scale",Bp.SCALE="editor.scale";class Tp extends bg{constructor(t,e){super(t,e)}}Tp.BEFORE_ROTATE="editor.before_rotate",Tp.ROTATE="editor.rotate";class Rp extends bg{constructor(t,e){super(t,e)}}Rp.BEFORE_SKEW="editor.before_skew",Rp.SKEW="editor.skew";class Op{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let r,{dragLimitAnimate:a}=i;const h=t.type===tc.END||t.type===Jd.END,l=n(e.draggable),d=!a||h||l,c={x:t.totalX,y:t.totalY};t instanceof tc&&lt.move(c,e.getWorldPointByLocal(s.totalOffset,null,!0)),t.shiftKey&&(Math.abs(c.x)>Math.abs(c.y)?c.y=0:c.x=0),r=Jd.getValidMove(e,s.point,c,d),(r.x||r.y)&&(a&&!l&&h?ro.animateMove(this,r,o(a)?a:.3):this.move(r))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:n}=this.editBox;let r,{around:o,lockRatio:a,flipable:h,editSize:l}=i;t instanceof rc?(o=e.getBoxPoint(t),r=t.totalScale):r=t.getInnerTotal(e);const{direction:d}=t.current;(t.shiftKey||e.lockRatio)&&(a=!0);const c=qg.getScaleData(e,n.bounds,d,r,a,qg.getAround(o,t.altKey),h,!s||"scale"===l),u=e.x,_=e.y;t instanceof Jd&&this.editTool&&this.editTool.onScaleWithDrag?(c.drag=t,this.scaleWithDrag(c)):this.scaleOf(c.origin,c.scaleX,c.scaleY),lt.move(n.totalOffset,e.x-u,e.y-_)}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:n,rotateAround:r,rotateGap:o,diagonalRotateKey:a}=i,{direction:h}=t.current;let l,d;if(t instanceof sc)d=t.rotation,l=r?kt.getPoint(r,e.boxBounds):e.getBoxPoint(t);else{const i=a?t.isHoldKeys(a):t.shiftKey,o=qg.getRotateData(e,h,t,s,i?null:r||e.around||e.origin||n||"center");d=s.rotation+o.rotation-e.rotation,l=o.origin}if(d=W.float(W.getGapRotation(d,o,e.rotation),2),!d)return;const c=e.x,u=e.y;this.rotateOf(l,d),lt.move(s.totalOffset,e.x-c,e.y-u)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:r,skewY:o}=qg.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),qg.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 Sp(Sp.BEFORE_MOVE,h));const l=new Sp(Sp.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 Bp(Bp.BEFORE_SCALE,t));const r=new Bp(Bp.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 Bp(Bp.BEFORE_SCALE,u));const _=new Bp(Bp.SCALE,u);this.doScale(_),this.emitEvent(_)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),r=i?new ft(ro.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 Bp(Bp.BEFORE_SCALE,o));const a=new Bp(Bp.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:a}=s;if(a){const s=a({target:i,origin:t,rotation:e});if(o(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 Tp(Tp.BEFORE_ROTATE,d));const c=new Tp(Tp.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 Rp(Rp.BEFORE_SKEW,u));const _=new Rp(Rp.SKEW,u);this.doSkew(_),this.emitEvent(_)}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(ro.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)}}let Cp=class extends Al{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 fh,this.openedGroupList=new fh,this.simulateTarget=new Ep(this),this.editBox=new np(this),this.editToolList={},this.selector=new Wg(this),this.editMask=new op(this),this.targetEventIds=[];let i=_.clone(hp);t&&(i=_.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)}getItem(t){return this.list[t||0]}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?l(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>_.stintSet(i,e,t))}setBright(t){this.setDimOthers(t,"bright",this.list)}update(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&dp(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||mp.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(n(s))e=s;else if(!1===s)return}if(mp.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(xp.BEFORE_GROUP),this.target=_p.group(this.list,this.element,t),this.emitGroupEvent(xp.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(xp.BEFORE_UNGROUP,t)),this.target=_p.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(xp.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(xp.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(xp.OPEN,t)}closeGroup(t){this.emitGroupEvent(xp.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(xp.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!ro.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 xp(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||mp.get(t,this)}openInnerEditor(t,e,i){let s;if(n(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(n(i))s=i;else if(!1===i)return}mp.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(vp.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(vp.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(vp.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(vp.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new vp(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&&(_p.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(_p.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_(Ko.START,this.onRenderStart,this),i&&i.on_(Io.SCROLL,this.onChildScroll,this),t.on_(Ko.CHILD_START,this.onAppRenderStart,this),t.on_(Zo.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)=>{nr(t,e,{get(){const{config:t,element:e,dragPoint:n,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),n&&(n.editConfig&&Object.assign(a,n.editConfig),"font-size"===a.editSize&&(a.lockRatio=!0),"resize-rotate"===n.pointType&&(a.around||(a.around="center"),s(a.lockRatio)&&(a.lockRatio=!0))),i(a.dragLimitAnimate)&&(a.dragLimitAnimate=o&&o.config.pointer.dragLimitAnimate),this.mergedConfig=a}})}],Cp.prototype,"mergeConfig",void 0),ge([kg(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof fh?i:new fh(i),t.multiple&&dp(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new bg(bg.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new bg(bg.AFTER_SELECT,s))})],Cp.prototype,"target",void 0),ge([kg(function(t,e){t.emitEvent(new bg(bg.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],Cp.prototype,"hoverTarget",void 0),Cp=ge([Ur(Op,["editBox","editTool","emitEvent"])],Cp);class Lp{static registerInnerEditor(){mp.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 Al,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)}}let Pp=class extends Lp{static registerEditTool(){mp.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()}};Pp=ge([pp()],Pp);const{left:Mp,right:Ap}=wt,{move:Dp,copy:Ip,toNumberPoints:Wp}=lt;let Fp=class extends Pp{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===Mp;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=Wp(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?(Dp(t,r,o),s&&Dp(e,-r,-o)):(s&&Dp(t,-r,-o),Dp(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),Ip(s[7],i),Ip(e[7],i),Ip(s[3],a),Ip(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Mp||t===Ap,s[t].visible=a,e[t].visible=!o&&a}};Fp=ge([pp()],Fp);const{M:zp,L:Yp,C:Np,Q:Xp,Z:Hp,N:Vp,D:Up,X:jp,G:Gp,F:Kp,O:Zp,P:qp,U:Jp}=Pe,$p={scale(t,e,i){if(!t)return;let s,n=0,r=t.length;for(;n<r;)switch(s=t[n],s){case zp:case Yp:Qp(t,e,i,n,1),n+=3;break;case Np:Qp(t,e,i,n,3),n+=7;break;case Xp:Qp(t,e,i,n,2),n+=5;break;case Hp:n+=1;break;case Vp:Qp(t,e,i,n,2),n+=5;break;case Up:Qp(t,e,i,n,2),n+=9;break;case jp:Qp(t,e,i,n,2),n+=6;break;case Gp:Qp(t,e,i,n,2),n+=9;break;case Kp:Qp(t,e,i,n,2),n+=5;break;case Zp:t[n]=Gp,t.splice(n+4,0,t[n+3],0),Qp(t,e,i,n,2),n+=9,r+=2;break;case qp:t[n]=Kp,t.splice(n+4,0,t[n+3]),Qp(t,e,i,n,2),n+=5,r+=1;break;case Jp:Qp(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:Qp}=$p,tf=$.get(),{topLeft:ef,top:sf,topRight:nf,right:rf,bottom:of,left:af}=wt;function hf(t,e,i){t.pathInputed?lf(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function lf(t,e,i){$p.scale(t.__.path,e,i),t.path=t.__.path}function df(t,e,i){const{points:s}=t;d(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):$p.scalePoints(s,e,i),t.points=s}function cf(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)tf.a=e,tf.d=i,s[t].transform(tf,!0)}const uf=rh.prototype;function _f(t,e,i){gf(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(tc.BEFORE_MOVE,e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY,!1))}),t.on_(tc.END,e=>{ro.animateMove(t.zoomLayer,t.getValidMove(e.moveX,e.moveY))}),t.on_(rc.BEFORE_ZOOM,e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&i.scaleOfWorld(e,s)}))}function gf(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&_.assign(i,e),_.assign(t.config,i,t.userConfig)}uf.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))},uf.__scaleResize=function(t,e){hf(this,t,e)},uf.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},uf.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},Td.prototype.__scaleResize=function(t,e){const{app:s,editConfig:n}=this,r=s&&s.editor,o=r&&r.dragPoint;if(this.__.resizeFontSize||n&&"font-size"===n.editSize||o&&"font-size"===r.mergedConfig.editSize)!function(t,e,s,n){let r=e;if(!i(n)){const i=t.__layout;let{width:o,height:a}=i.boxBounds;switch(o*=s-e,a*=e-s,n){case sf:case of:r=s,i.affectScaleOrRotation?t.moveInner(-o/2,0):t.x-=o/2;break;case af:case rf:i.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case ef:case nf:i.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),hf(this,t,e)}},Rd.prototype.__scaleResize=function(t,e){lf(this,t,e)},yd.prototype.__scaleResize=function(t,e){this.pathInputed?lf(this,t,e):this.points?df(this,t,e):this.width*=t},sd.prototype.__scaleResize=function(t,e){this.pathInputed?lf(this,t,e):this.points?df(this,t,e):hf(this,t,e)},Al.prototype.__scaleResize=function(t,e){cf(this,t,e)},Vl.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||hf(this,t,e),i&&cf(this,t,e)},re.add("resize"),re.add("editor","resize"),oe.editor=function(t,e){const i=new Cp(t);return e&&e.sky.add(e.editor=i),i},Vl.addAttr("textBox",!1,dr),Ml.addAttr("editConfig",void 0,dr),Ml.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),dr),Ml.addAttr("editInner","PathEditor",dr),Al.addAttr("editInner","",dr),Td.addAttr("editInner","TextEditor",dr),Ml.setEditConfig=function(t){this.changeAttr("editConfig",t)},Ml.setEditOuter=function(t){this.changeAttr("editOuter",t)},Ml.setEditInner=function(t){this.changeAttr("editInner",t)};const pf=$t.get("LeaferTypeCreator"),ff={list:{},register(t,e){mf[t]&&pf.repeat(t),mf[t]=e},run(t,e){const i=mf[t];i&&i(e)}},{list:mf,register:yf}=ff;yf("viewport",_f),yf("custom",function(t){_f(t,null,!0)}),yf("design",function(t){_f(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),yf("document",function(t){_f(t,{zoom:{min:1},move:{scroll:"limit"}})});const vf={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}=xf,s=xf.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),xf.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)?xf.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}=xf;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},xf=vf,{abs:wf,max:bf}=Math,{sign:kf,within:Ef}=W,Sf={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const r=wf(s),o=wf(n);return r>50&&(s=bf(50,r/3)*kf(s)),o>50&&(n=bf(50,o/3)*kf(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=Ef(r,0,1);const i=t.deltaY?e.delta.y:e.delta.x,n=Ef(1-wf(o)/(4*i)*r,.5,2);s=o>0?n:1/n}return s}};let Bf,Tf,Rf,Of;class Cf{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),Bf=0,Tf=0,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0,totalX:Bf,totalY:Tf}),e.emit(tc.START,this.moveData)),t.path=this.moveData.path,t.totalX=Bf+=t.moveX,t.totalY=Tf+=t.moveY,e.emit(tc.BEFORE_MOVE,t),e.emit(tc.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),Rf=1,this.zoomData=Object.assign(Object.assign({},t),{scale:1,totalScale:Rf}),e.emit(rc.START,this.zoomData)),t.path=this.zoomData.path,t.totalScale=Rf*=t.scale,e.emit(rc.BEFORE_ZOOM,t),e.emit(rc.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),Of=0,this.rotateData=Object.assign(Object.assign({},t),{rotation:0,totalRotation:Of}),e.emit(sc.START,this.rotateData)),t.path=this.rotateData.path,t.totalRotation=Of+=t.rotation,e.emit(sc.BEFORE_ROTATE,t),e.emit(sc.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:t,moveData:e,zoomData:i,rotateData:s}=this;e&&t.emit(tc.END,Object.assign(Object.assign({},e),{totalX:Bf,totalY:Tf})),i&&t.emit(rc.END,Object.assign(Object.assign({},i),{totalScale:Rf})),s&&t.emit(sc.END,Object.assign(Object.assign({},s),{totalRotation:Of})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const Lf=Wl.prototype,Pf=new Gt,Mf=new gt;function Af(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})}Lf.initType=function(t){ff.run(t,this)},Lf.getValidMove=function(t,e,i=!0){const{scroll:s,disabled:n}=this.app.config.move;if(Mf.set(t,e),s){const t=!0===s?"":s;t.includes("x")?Mf.y=0:t.includes("y")?Mf.x=0:Math.abs(Mf.x)>Math.abs(Mf.y)?Mf.y=0:Mf.x=0,i&&t.includes("limit")&&(Pf.set(this.__world).addPoint(this.zoomLayer),jd.getValidMove(Pf,this.canvas.bounds,"inner",Mf,!0),t.includes("x")?Mf.y=0:t.includes("y")&&(Mf.x=0))}return{x:n?0:Mf.x,y:n?0:Mf.y}},Lf.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 If=kc.prototype;If.createTransformer=function(){this.transformer=new Cf(this)},If.move=function(t){this.transformer.move(t)},If.zoom=function(t){this.transformer.zoom(t)},If.rotate=function(t){this.transformer.rotate(t)},If.transformEnd=function(){this.transformer.transformEnd()},If.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):Sf.getScale(t,e);if(1!==r)this.zoom(Df(r,t));else{const s=e.getMove?e.getMove(t,e):Sf.getMove(t,e);i.snap&&lt.round(s),this.move(Af(s,t))}},If.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=vf.getData(e),{moving:r,zooming:o,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(vf.detect(n,d(s)?s:{})){case"move":r=!0;break;case"zoom":o=!0;break;case"rotate":a=!0;break;default:return}vf.reset()}r||(n.center=vf.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(Af(n.move,t))};const Wf=_c.prototype,{abs:Ff}=Math;function zf(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}Wf.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=Ff(i),r=Ff(s),a=e?1:.1,h=this.canAnimate&&this.moving&&(n>a||r>a)&&this.interaction.m.dragAnimate;if(h){const a="touch"===t.pointerType?3:1,l=70;n*(e=e?o(h)?h:.95:a)>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},Wf.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},Wf.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},Wf.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=Ht.maxX(o),d=Ht.maxY(o),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let _=0,g=0;this.autoMoveTimer=setInterval(()=>{_+=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:_,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},Wf.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},re.add("viewport"),re.add("view"),Wl.prototype.zoom=function(t,e,i,r){let a;this.killAnimate(),c(e)?(a=e.padding,i=e.scroll,r=e.transition):a=e;const{zoomLayer:h}=this,u=this.canvas.bounds.clone().shrink(s(a)?30:a),_=new Gt,g={x:u.x+u.width/2,y:u.y+u.height/2};let p;const{x:f,y:m,scaleX:y,scaleY:v}=h.__;if(n(t))switch(t){case"in":p=zf(y,"in");break;case"out":p=zf(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 o(t)&&(p=t/y);if(p)p=this.getValidScale(p),h.scaleOfWorld(g,p,p,!1,r);else if(d(t)){const e={x:f,y:m,scaleX:y,scaleY:v},s=l(t);if(s||t.tag){const e=s?t:[t];_.setListWithFn(e,go.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);_.set(h.getWorldBounds(e))}const{width:n,height:o}=_;let a=u.x-_.x,d=u.y-_.y;return i?(a+=Math.max((u.width-n)/2,0),d+=Math.max((u.height-o)/2,0)):(p=this.getValidScale(Math.min(u.width/n,u.height/o)),a+=(u.width-n*p)/2,d+=(u.height-o*p)/2,lt.scaleOf(e,_,p),_.scaleOf(_,p),e.scaleX*=p,e.scaleY*=p),"x"===i?d=0:"y"===i&&(a=0),lt.move(e,a,d),_.move(a,d),h.set(e,r),_}return h.worldBoxBounds};class Yf extends Al{get isOutside(){return!0}constructor(t,e){super(),this.config={theme:"light",padding:0,minSize:10},t.isApp&&(t.sky.add(this),t=t.tree),this.target=t,e&&_.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let e;n(t)?(e={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(e.fill="white",e.stroke="rgba(0,0,0,0.2)")):e=t,this.scrollXBar||this.addMany(this.scrollXBar=new Vl,this.scrollYBar=new Vl),e=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},e),e.height||(e.height=e.width),this.scrollXBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds: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,_=l<1,{scrollXBar:g,scrollYBar:p}=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}),p.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:_})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:e}=this;this.__eventIds=[t.on_(Jd.DRAG,this.onDrag,this),e.on_(Jd.DRAG,this.onDrag,this),t.on_(Jd.END,this.onDragEnd,this),e.on_(Jd.END,this.onDragEnd,this),this.target.on_(Ko.BEFORE,()=>this.update(!0)),this.target.leafer.on_(Uo.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}re.add("scroll");class Nf extends gl{}function Xf(t){return ar(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__,e="none"!==t.startArrow||"none"!==t.endArrow;t.__useArrow!==e&&yr(this),t.__useArrow=e,br(this)}}}))}let Hf=class extends yd{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Gh.register(t,e)}};ge([Ir(Nf)],Hf.prototype,"__",void 0),ge([Xf("angle")],Hf.prototype,"endArrow",void 0),Hf=ge([jr()],Hf);const{M:Vf,L:Uf,C:jf,Q:Gf,O:Kf}=Pe,{rotate:Zf,copyFrom:qf,scale:Jf}=lt,$f={},Qf={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 Vf:case Uf:tm(t,l+1,e,i,s,n,r,o),l+=3;break;case jf:for(h=1;h<6;h+=2)tm(t,l+h,e,i,s,n,r,o);l+=7;break;case Gf:for(h=1;h<4;h+=2)tm(t,l+h,e,i,s,n,r,o);l+=5;break;case Kf: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){Qf.layout(t,0,0,1,1,e,i)}};function tm(t,e,i,s,n,r,o,a){qf($f,t[e],t[e+1]),o&&Zf($f,o,a),n&&Jf($f,n,r),t[e]=i+$f.x,t[e+1]=s+$f.y}const{layout:em,rotate:im}=Qf,{getAngle:sm}=lt,nm={x:-.5},rm={connect:nm,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},om={connect:nm,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},am={connect:nm,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]},hm={connect:nm,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]},lm={offset:nm,path:[...am.path],dashPath:[1,-2.5,0,2,-1,0]};im(lm.path,180,{x:-1.5,y:0});const dm={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},cm={connect:{x:.5},path:[...dm.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},um={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]},_m={path:[...um.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},gm=_.clone(um),pm=_.clone(_m);im(gm.path,45),im(pm.path,45);const fm={angle:rm,"angle-side":om,arrow:hm,triangle:am,"triangle-flip":lm,circle:cm,"circle-line":dm,square:_m,"square-line":um,diamond:pm,"diamond-line":gm,mark:{offset:nm,path:[1,0,-2,2,0,2]}};function mm(t,e,i,s,n,r,o){let a,h;const{strokeCap:l,strokeJoin:c}=t.__;d(e)?e.type?(h=e.scale,a=fm[e.type]):a=e:a=fm[e];const{offset:u,connect:_,path:g,dashPath:p}=a;let f=_?_.x:0,m=u?u.x:0;const y=[...g];return o&&p&&y.push(...p),"none"!==l&&(f-=.5),u&&("round"===c&&u.roundJoin?m+=u.roundJoin:"bevel"===c&&u.bevelJoin&&(m+=u.bevelJoin)),h&&em(y,0,0,h,h),m&&em(y,m,0),em(y,s.x,s.y,n,n,sm(i,s)),r.x=(f+m)*n,y}const{M:ym,L:vm,C:xm,Q:wm,Z:bm,N:km,D:Em,X:Sm,G:Bm,F:Tm,O:Rm,P:Om,U:Cm}=Pe,{copy:Lm,copyFrom:Pm,getDistancePoint:Mm}=lt,Am={},Dm={},Im={},Wm={},Fm={},zm={list:fm,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 ym:case vm:(c<2||l+6>=d)&&(Pm(Fm,r[l+1],r[l+2]),!c&&u&&Lm(Dm,Fm)),l+=3;break;case xm:(1===c||l+7>=d-3)&&Ym(r,Wm,Fm,l+3),l+=7;break;case wm:(1===c||l+5>=d-3)&&Ym(r,Wm,Fm,l+1),l+=5;break;case bm:return;case km:l+=5;break;case Em:l+=9;break;case Sm:l+=6;break;case Bm:l+=9;break;case Tm:l+=5;break;case Rm:l+=7;break;case Om:l+=4;break;case Cm:(1===c||l+6>=d-3)&&(Ym(r,Wm,Fm,l+1),l+6!==d&&(Fm.x-=(Fm.x-Wm.x)/10,Fm.y-=(Fm.y-Wm.y)/10)),l+=6}if(c++,1===c&&h!==ym)return;if(2===c&&u&&Lm(Im,h===vm?Fm:Wm),l===d){const o=t.__.__pathForRender=a?[...r]:r,d=t.__.__pathForArrow=[];if(u){const i=mm(t,e,Im,Dm,s,Am,!!n);n?d.push(...i):o.push(...i),Am.x&&(Mm(Dm,Im,-Am.x,!0),o[1]=Im.x,o[2]=Im.y)}if(i&&"none"!==i){const e=mm(t,i,Wm,Fm,s,Am,!!n);if(n?d.push(...e):o.push(...e),Am.x){let t;switch(Mm(Fm,Wm,-Am.x,!0),h){case vm:t=l-3+1;break;case xm:t=l-7+5;break;case wm:t=l-5+3;break;case Cm:t=l-6+3}t&&Nm(o,Wm,t)}}}else Lm(Wm,Fm)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function Ym(t,e,i,s){Pm(e,t[s],t[s+1]),Pm(i,t[s+2],t[s+3])}function Nm(t,e,i){t[i]=e.x,t[i+1]=e.y}re.add("arrow"),Ml.addAttr("startArrow","none",Xf),Ml.addAttr("endArrow","none",Xf),Object.assign(Gh,zm),Object.assign(Kh,{strokeArrow(t,e,i,s){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});const{Yes:Xm,NoAndSkip:Hm,YesAndSkip:Vm}=t,Um={},jm={},Gm={};class Km{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,s,n){switch(typeof t){case"number":const r=this.getByInnerId(t,e);return s?r:r?[r]:[];case"string":switch(t[0]){case"#":Um.id=t.substring(1),t=Um;break;case".":jm.className=t.substring(1),t=jm;break;default:Gm.tag=t,t=Gm}case"object":if(i(t.id)){if(t.tag){const{tag:i}=t,n=l(i);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,s,n?_.toMap(i):i)}return this.getByMethod(this.methods.className,e,s,t.className)}{const i=this.getById(t.id,e);return s?i:i?[i]:[]}case"function":return this.getByMethod(t,e,s,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&&ro.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===Xm||r===Vm){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_(Ao.REMOVE,this.__onRemoveChild,this),this.target.on_(Io.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 Zm=Ml.prototype;function qm(t){return t.leafer?t.leafer.selector:y.selector||(y.selector=oe.selector())}Zm.find=function(t,e){return qm(this).getBy(t,this,!1,e)},Zm.findOne=function(t,e){return qm(this).getBy(t,this,!0,e)},re.add("find"),oe.finder=function(t){return new Km(t)};const{setPoint:Jm,addPoint:$m,toBounds:Qm}=yt;const ty={syncExport(t,e,s){let n;Qh.running=!0;try{const r=Un.fileType(e),o=e.includes(".");s=Un.getExportOptions(s);const{toURL:a}=y,{download:h}=y.origin;if("json"===r)o&&h(a(JSON.stringify(t.toJSON(s.json)),"text"),e),n={data:!!o||t.toJSON(s.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:_,clip:g,trim:p,screenshot:f,padding:m,onCanvas:v}=s,x=i(s.smooth)?!c||c.config.smooth:s.smooth,w=s.contextSettings||(c?c.config.contextSettings:void 0),b=d&&f&&i(s.fill)?t.fill:s.fill,k=Un.isOpaqueImage(e)||b,E=new ft;if(f)r=!0===f?d?c.canvas.bounds:t.worldRenderBounds:f;else{let e=s.relative||(d?"inner":"local");switch(a=l.scaleX,h=l.scaleY,e){case"inner":E.set(l);break;case"local":E.set(l).divide(t.localTransform),a/=t.scaleX,h/=t.scaleY;break;case"world":a=1,h=1;break;case"page":e=c||t;default:E.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,h/=h/i.scaleY}r=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};W.getScaleData(s.scale,s.size,r,S);let B=s.pixelRatio||1,{x:T,y:R,width:O,height:C}=new Gt(r).scale(S.scaleX,S.scaleY);g&&(T+=g.x,R+=g.y,O=g.width,C=g.height);const L={exporting:!0,matrix:E.scale(1/S.scaleX,1/S.scaleY).invert().translate(-T,-R).withScale(1/a*S.scaleX,1/h*S.scaleY)};let P,M=oe.canvas({width:Math.floor(O),height:Math.floor(C),pixelRatio:B,smooth:x,contextSettings:w});_&&(P=t,P.__worldOpacity=0,t=c||t,L.bounds=M.bounds),M.save();const A=u&&!i(b),D=t.get("fill");if(A&&(t.fill=""),y.render(t,M,L),A&&(t.fill=D),M.restore(),P&&P.__updateWorldOpacity(),p){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?$m(o,n,r):Jm(o={},n,r)),a++;const h=new Gt;return o&&(Qm(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()}k&&M.fillWorld(M.bounds,b||"#FFFFFF","destination-over"),v&&v(M);n={data:"canvas"===e?M:M.export(e,s),width:M.pixelWidth,height:M.pixelHeight,renderBounds:r,trimBounds:o};const I=c&&c.app;I&&I.canvasManager&&I.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return Qh.running=!1,n},export(t,e,i){return Qh.running=!0,function(t){ey||(ey=new Zn);return new Promise(e=>{ey.add(()=>pe(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const r=()=>pe(this,void 0,void 0,function*(){if(!Jn.isComplete)return y.requestRender(r);const o=Qh.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),iy(t);const{leafer:o}=t;o?o.waitViewCompleted(r):r()}))}};let ey;function iy(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>iy(t))}const sy=Oe.prototype,ny=$t.get("@leafer-in/export");sy.export=function(t,e){const{quality:i,blob:s}=Un.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},sy.toBlob=function(t,e){return new Promise(i=>{y.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{ny.error(t),i(null)})})},sy.toDataURL=function(t,e){return y.origin.canvasToDataURL(this.view,t,e)},sy.saveAs=function(t,e){return new Promise(i=>{y.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{ny.error(t),i(!1)})})},re.add("export"),Object.assign(Qh,ty),Ml.prototype.export=function(t,e){return Qh.export(this,t,e)},Ml.prototype.syncExport=function(t,e){return Qh.syncExport(this,t,e)};const ry={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},oy={top:"flex-start",middle:"center",bottom:"flex-end"},ay={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function hy(t,e,s){const{style:r}=t,{fill:o,padding:a,textWrap:h,textOverflow:c,textDecoration:u}=e;let _;r.fontFamily=e.fontFamily,r.fontSize=e.fontSize*s+"px",function(t,e){let s="black";l(e)&&(e=e[0]);if(d(e))switch(e.type){case"solid":s=Uh.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];s=Uh.string(n(t)?t:t.color);break;default:i(e.r)||(s=Uh.string(e))}else s=e;t.color=s}(r,o),r.fontStyle=e.italic?"italic":"normal",r.fontWeight=e.fontWeight,d(u)?(_=u.type,u.color&&(r.textDecorationColor=Uh.string(u.color))):_=u,r.textDecoration=ay[_],r.textTransform=ry[e.textCase],r.textAlign="both"===e.textAlign?"justify":e.textAlign,r.display="flex",r.flexDirection="column",r.justifyContent=oy[e.verticalAlign],r.lineHeight=(e.__.__lineHeight||0)*s+"px",r.letterSpacing=(e.__.__letterSpacing||0)*s+"px",r.whiteSpace="none"===h||e.__.__autoWidth?"nowrap":"normal",r.wordBreak="break"===h?"break-all":"normal",r.textIndent=(e.paraIndent||0)*s+"px",r.padding=l(a)?a.map(t=>t*s+"px").join(" "):(a||0)*s+"px",r.textOverflow="show"===c?"":"hide"===c?"clip":c}let ly=class extends Lp{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:t}=this,{config:e}=t.app,i=this.editTarget;i.textEditing=!0,this.isHTMLText=!(i instanceof Td),this._keyEvent=e.keyEvent,e.keyEvent=!1;const s=this.editDom=document.createElement("div");s.classList.add("leafer-text-editor");const{style:n}=s;s.contentEditable="true",n.position="fixed",n.transformOrigin="left top",n.boxSizing="border-box",this.isHTMLText?s.innerHTML=String(i.text):s.innerText=String(i.text);const{view:r}=t.app;(this.inBody=r instanceof HTMLCanvasElement)?document.body.appendChild(s):r.appendChild(s),this.eventIds=[t.app.on_(Kd.DOWN,e=>{let i,{target:n}=e.origin;for(;n;)n===s&&(i=!0),n=n.parentElement;i||t.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),s.addEventListener("focus",this.onFocus),s.addEventListener("input",this.onInput),s.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const o=window.getSelection(),a=document.createRange();if(this.config.selectAll)a.selectNodeContents(s);else{const t=s.childNodes[0];t&&(a.setStartAfter(t),a.setEndAfter(t)),a.collapse(!0)}o.removeAllRanges(),o.addRange(a)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=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:_,f:g}=new ft(t.worldTransform).scale(1/e).translateInner(n,r),{style:p}=this.editDom;p.transform=`matrix(${l},${d},${c},${u},${_},${g})`,p.left=a+"px",p.top=h+"px",p.width=i+"px",p.height=s+"px",this.isHTMLText||hy(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)}};ly=ge([fp()],ly),re.add("text-editor","editor");class dy extends kl{setText(t){this._text=t,this.__htmlChanged=!0}}const cy={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:"≥"};let uy=class extends vd{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=cy[e],void 0!==i)){s+=i,n=r+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){n(t)?cy[t]=e:Object.assign(cy,t)}};ge([Ir(dy)],uy.prototype,"__",void 0),ge([fr("")],uy.prototype,"text",void 0),ge([dr("TextEditor")],uy.prototype,"editInner",void 0),ge([Sr(!1)],uy.prototype,"textEditing",void 0),uy=ge([jr()],uy),re.add("html");export{Bt as AlignHelper,t as Answer,Cd as App,kt as AroundHelper,Hf as Arrow,Nf as ArrowData,Zt as AutoBounds,ri as BezierHelper,Gt as Bounds,zo as BoundsEvent,Ht as BoundsHelper,Vl as Box,cl as BoxData,ph as Branch,yo as BranchHelper,Ma as BranchRender,wd as Canvas,El as CanvasData,_e as CanvasManager,Ao as ChildEvent,Uh as ColorConvert,oe as Creator,Ec as Cursor,_ as DataHelper,$t as Debug,xt as Direction4,wt as Direction9,jd as DragBoundsHelper,Jd as DragEvent,_c as Dragger,Qd as DropEvent,np as EditBox,qg as EditDataHelper,ep as EditPoint,Wg as EditSelect,Mg as EditSelectHelper,Pp as EditTool,mp as EditToolCreator,Cp as Editor,bg as EditorEvent,xp as EditorGroupEvent,_p as EditorHelper,Sp as EditorMoveEvent,Tp as EditorRotateEvent,Bp as EditorScaleEvent,Rp as EditorSkewEvent,Jh as Effect,Zl as Ellipse,fl as EllipseData,gi as EllipseHelper,Mo as Event,ce as EventCreator,ia as Eventer,Qh as Export,Un as FileHelper,$h as Filter,Km as Finder,T as FourNumberHelper,Ul as Frame,_l as FrameData,Al as Group,dl as GroupData,uy as HTMLText,dy as HTMLTextData,Sc as HitCanvasManager,vd as Image,kl as ImageData,Fo as ImageEvent,Qn as ImageManager,x as IncrementId,Lp as InnerEditor,vp as InnerEditorEvent,kc as InteractionBase,ac as InteractionHelper,oc as KeyEvent,Pd as Keyboard,Go as LayoutEvent,Ah as Layouter,rh as Leaf,Ca as LeafBounds,go as LeafBoundsHelper,p as LeafData,pa as LeafDataProxy,_a as LeafEventer,ro as LeafHelper,Po as LeafLayout,mh as LeafLevelList,fh as LeafList,ba as LeafMatrix,La as LeafRender,Wl as Leafer,vh as LeaferCanvas,Oe as LeaferCanvasBase,ul as LeaferData,Zo as LeaferEvent,sr as LeaferImage,ff as LeaferTypeCreator,yd as Line,gl as LineData,Fp as LineEditTool,W as MathHelper,ft as Matrix,$ as MatrixHelper,tc as MoveEvent,vf as MultiTouchHelper,$d as MyDragEvent,xd as MyImage,Zd as MyPointerEvent,ic as MyTouchEvent,Ae as NeedConvertToCanvasCommandMap,z as OneRadian,Y as PI2,N as PI_2,Kh as Paint,qh as PaintGradient,Zh as PaintImage,Rd as Path,Gh as PathArrow,zm as PathArrowModule,Mn as PathBounds,bs as PathCommandDataHelper,Pe as PathCommandMap,pi as PathCommandNodeHelper,Qi as PathConvert,Yn as PathCorner,zs as PathCreator,vl as PathData,tn as PathDrawer,Ce as PathHelper,Qf as PathMatrixHelper,Fe as PathNumberCommandLengthMap,We as PathNumberCommandMap,Od as Pen,xl as PenData,Fh as Picker,y as Platform,re as Plugin,gt as Point,lt as PointHelper,Md as PointerButton,Kd as PointerEvent,sd as Polygon,ml as PolygonData,Io as PropertyEvent,Fl as Rect,pl as RectData,ze as RectHelper,Ll as RectRender,Ko as RenderEvent,Ih as Renderer,Uo as ResizeEvent,Jn as Resource,sc as RotateEvent,ie as Run,Yf as ScrollBar,Pg as SelectArea,zh as Selector,dd as Star,yl as StarData,tl as State,qt as StringNumberMap,Lg as Stroker,nc as SwipeEvent,Kn as TaskItem,Zn as TaskProcessor,Td as Text,Vh as TextConvert,bl as TextData,ly as TextEditor,ec as TouchEvent,Op as TransformTool,Cf as Transformer,el as Transition,yt as TwoPointBoundsHelper,Ml as UI,Tl as UIBounds,he as UICreator,hl as UIData,Ad as UIEvent,Ol as UIRender,jh as UnitConvert,bo as WaitHelper,jo as WatchEvent,kh as Watcher,Sf as WheelEventHelper,rc as ZoomEvent,_f as addViewport,gf as addViewportConfig,Er as affectRenderBoundsType,wr as affectStrokeBoundsType,Xf as arrowType,hr as attr,_r as autoLayoutType,fr as boundsType,Vn as canvasPatch,Re as canvasSizeAttrs,Hh as createAttr,or as createDescriptor,Dr as cursorType,Ir as dataProcessor,dr as dataType,ar as decorateLeafAttr,Fr as defineDataProcessor,nr as defineKey,lr as defineLeafAttr,Br as dimType,yr as doBoundsType,br as doStrokeType,Yh as effectType,e as emptyData,Mr as eraserType,Wo as extraPropertyEventMap,H as getBoundsData,rr as getDescriptor,V as getMatrixData,X as getPointData,Ar as hitType,l as isArray,c as isData,u as isEmptyData,r as isFinite,s as isNull,o as isNumber,d as isObject,n as isString,i as isUndefined,Wr as layoutProcessor,ta as leaferTransformAttrMap,Pr as maskType,mr as naturalBoundsType,Tr as opacityType,Nn as path,vr as pathInputType,xr as pathType,Xn as pen,cr as positionType,pp as registerEditTool,fp as registerInnerEditor,jr as registerUI,Gr as registerUIEvent,Nh as resizeType,Xr as rewrite,Hr as rewriteAble,pr as rotationType,gr as scaleType,ur as scrollType,Lr as sortType,kr as strokeType,Sr as surfaceType,Kt as tempBounds,mt as tempMatrix,pt as tempPoint,h as tryToNumber,wh as useCanvas,Ur as useModule,yh as version,Rr as visibleType,Xh as zoomLayerType};
1
+ var t,e;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(t||(t={})),function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(e||(e={}));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+)?$/;function l(t){return"string"==typeof t&&h.test(t)?+t:t}const{isArray:d}=Array;function c(t){return t&&"object"==typeof t}function u(t){return c(t)&&!d(t)}function _(t){return"{}"===JSON.stringify(t)}const g={default:(t,e)=>(p(e,t),p(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 p(t[n],e[n],i&&i[n]);i&&n in i?(null===(o=i[n])||void 0===o?void 0:o.constructor)===Object&&p(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:p}=g;class f{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(d(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:m,max:y}=Math,v={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||x.maxCacheSize),isSuperLarge:(t,e,i)=>x.isLarge(t,e,i,x.maxPatternSize),getRealURL(t){const{prefix:e,suffix:i}=v.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=v.origin.createCanvas(y(m(e+(s||0)),1),y(m(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&&g.stintSet(i,"transform",e)}}},{image:x}=v,w={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=b;return e[t]?e[t]++:(e[t]=1,0)}},b=w;let k,E,S;const{max:B}=Math,T=[0,0,0,0],R={zero:[...T],tempFour:T,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)=>O(T,t,e,i,s),toTempAB(t,e,i){S=i?a(t)?e:t:[],a(t)?(k=L(t),E=e):a(e)?(k=t,E=L(e)):(k=t,E=e),4!==k.length&&(k=C(k)),4!==E.length&&(E=C(E))},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)?B(t,e):(P(t,e,i),O(S,B(k[0],E[0]),B(k[1],E[1]),B(k[2],E[2]),B(k[3],E[3]))),add:(t,e,i)=>a(t)&&a(e)?t+e:(P(t,e,i),O(S,k[0]+E[0],k[1]+E[1],k[2]+E[2],k[3]+E[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:C(t);return O(n,h*i,l*e,r*i,o*e)}},{set:O,get:C,setTemp:L,toTempAB:P}=R,{round:M,pow:A,max:D,floor:I,PI:W}=Math,F={within:(t,e,i)=>(c(e)&&(i=e.max,e=e.min),!s(e)&&t<e&&(t=e),!s(i)&&t>i&&(t=i),t),fourNumber:R.get,formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),F.float(t)),getGapRotation(t,e,i=0){let s=t+i;if(e>1){const t=Math.abs(s%e);(t<1||t>e-1)&&(s=Math.round(s/e)*e)}return s-i},float(t,e){const i=s(e)?1e12:A(10,e);return-0===(t=M(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&&F.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:z,randColor:t=>`rgba(${z(255)},${z(255)},${z(255)},${t||1})`};function z(t){return Math.round(Math.random()*t)}const Y=W/180,N=2*W,X=W/2;function H(){return{x:0,y:0}}function V(){return{x:0,y:0,width:0,height:0}}function U(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:j,cos:G,acos:K,sqrt:Z}=Math,{float:q}=F,J={};function $(){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 Q={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:$(),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:U,getWorld:$,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){tt.toInnerPoint(t,e,J),tt.scaleOfInner(t,J,i,s)},scaleOfInner(t,e,i,s=i){tt.translateInner(t,e.x,e.y),tt.scale(t,i,s),tt.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:i,b:s,c:n,d:r}=t,o=G(e*=Y),a=j(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){tt.toInnerPoint(t,e,J),tt.rotateOfInner(t,J,i)},rotateOfInner(t,e,i){tt.translateInner(t,e.x,e.y),tt.rotate(t,i),tt.translateInner(t,-e.x,-e.y)},skew(t,e,i){const{a:s,b:n,c:r,d:o}=t;i&&(i*=Y,t.a=s+r*i,t.b=n+o*i),e&&(e*=Y,t.c=r+s*e,t.d=o+n*e)},skewOfOuter(t,e,i,s){tt.toInnerPoint(t,e,J),tt.skewOfInner(t,J,i,s)},skewOfInner(t,e,i,s=0){tt.translateInner(t,e.x,e.y),tt.skew(t,i,s),tt.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){tt.multiply(t,tt.tempInvert(e))},divideParent(t,e){tt.multiplyParent(t,tt.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=tt;return tt.copy(e,t),tt.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*Y,o=G(r),a=j(r);if(s||n){const e=s*Y,i=n*Y;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)&&tt.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,_,g,p=h,f=l;if(r||o){const t=n*a-r*o;if(o&&!s){d=Z(n*n+r*r),c=t/d;const e=n/d;u=r>0?K(e):-K(e)}else{c=Z(o*o+a*a),d=t/c;const e=o/c;u=X-(a>0?K(-e):-K(e))}const e=q(G(u)),i=j(u);d=q(d),c=q(c),_=e?q((o/c+i)/e/Y,9):0,g=e?q((r/d-i)/e/Y,9):0,u=q(u/Y)}else d=n,c=a,u=_=g=0;return(e=i||e)&&(p+=e.x*n+e.y*o,f+=e.x*r+e.y*a,i||(p-=e.x,f-=e.y)),{x:p,y:f,scaleX:d,scaleY:c,rotation:u,skewX:_,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=Z(s*s+n*n)):(e=s,i=o)}return s.scaleX=e,s.scaleY=i,s},reset(t){tt.set(t)}},tt=Q,{toInnerPoint:et,toOuterPoint:it}=Q,{sin:st,cos:nt,abs:rt,sqrt:ot,atan2:at,min:ht,round:lt}=Math,dt={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,i=0){t.x=e,t.y=i},setRadius(t,e,i){t.radiusX=e,t.radiusY=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?lt(t.x-.5)+.5:lt(t.x),t.y=e?lt(t.y-.5)+.5:lt(t.y)},move(t,e,i){c(e)?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=i)},scale(t,e,i=e){t.x&&(t.x*=e),t.y&&(t.y*=i)},scaleOf(t,e,i,s=i){t.x+=(t.x-e.x)*(i-1),t.y+=(t.y-e.y)*(s-1)},rotate(t,e,i){i||(i=ct.defaultPoint);const s=nt(e*=Y),n=st(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}=ct;return _t(i,t),et(e,i,i),i},tempToOuterOf(t,e){const{tempPoint:i}=ct;return _t(i,t),it(e,i,i),i},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:i}=ct;return _t(i,t),ct.toInnerRadiusPointOf(t,e,i),i},toInnerRadiusPointOf(t,e,i){i||(i=t),et(e,t,i),i.radiusX=Math.abs(t.radiusX/e.scaleX),i.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,i){et(e,t,i)},toOuterOf(t,e,i){it(e,t,i)},getCenter:(t,e)=>({x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}),getCenterX:(t,e)=>t+(e-t)/2,getCenterY:(t,e)=>t+(e-t)/2,getDistance:(t,e)=>ut(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,i,s){const n=rt(i-t),r=rt(s-e);return ot(n*n+r*r)},getMinDistanceFrom:(t,e,i,s,n,r)=>ht(ut(t,e,i,s),ut(i,s,n,r)),getAngle:(t,e)=>gt(t,e)/Y,getRotation:(t,e,i,s)=>(s||(s=e),ct.getRadianFrom(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y)/Y),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)=>at(e.y-t.y,e.x-t.x),getDistancePoint(t,e,i,s,n){const r=gt(t,e);return n&&(t=e),s||(e={}),e.x=t.x+nt(r)*i,e.y=t.y+st(r)*i,e},toNumberPoints(t){let e=t;return c(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},isSame:(t,e)=>t.x===e.x&&t.y===e.y,reset(t){ct.reset(t)}},ct=dt,{getDistanceFrom:ut,copy:_t,getAtan2:gt}=ct;class pt{constructor(t,e){this.set(t,e)}set(t,e){return c(t)?dt.copy(this,t):dt.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new pt(this)}move(t,e){return dt.move(this,t,e),this}scale(t,e){return dt.scale(this,t,e),this}scaleOf(t,e,i){return dt.scaleOf(this,t,e,i),this}rotate(t,e){return dt.rotate(this,t,e),this}rotateOf(t,e){return dt.rotate(this,e,t),this}getRotation(t,e,i){return dt.getRotation(this,t,e,i)}toInnerOf(t,e){return dt.toInnerOf(this,t,e),this}toOuterOf(t,e){return dt.toOuterOf(this,t,e),this}getCenter(t){return new pt(dt.getCenter(this,t))}getDistance(t){return dt.getDistance(this,t)}getDistancePoint(t,e,i,s){return new pt(dt.getDistancePoint(this,t,e,i,s))}getAngle(t){return dt.getAngle(this,t)}getAtan2(t){return dt.getAtan2(this,t)}isSame(t){return dt.isSame(this,t)}reset(){return dt.reset(this),this}}const ft=new pt;class mt{constructor(t,e,i,s,n,r){this.set(t,e,i,s,n,r)}set(t,e,i,s,n,r){return c(t)?Q.copy(this,t):Q.set(this,t,e,i,s,n,r),this}setWith(t){return Q.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 mt(this)}translate(t,e){return Q.translate(this,t,e),this}translateInner(t,e){return Q.translateInner(this,t,e),this}scale(t,e){return Q.scale(this,t,e),this}scaleWith(t,e){return Q.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}pixelScale(t){return Q.pixelScale(this,t),this}scaleOfOuter(t,e,i){return Q.scaleOfOuter(this,t,e,i),this}scaleOfInner(t,e,i){return Q.scaleOfInner(this,t,e,i),this}rotate(t){return Q.rotate(this,t),this}rotateOfOuter(t,e){return Q.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return Q.rotateOfInner(this,t,e),this}skew(t,e){return Q.skew(this,t,e),this}skewOfOuter(t,e,i){return Q.skewOfOuter(this,t,e,i),this}skewOfInner(t,e,i){return Q.skewOfInner(this,t,e,i),this}multiply(t){return Q.multiply(this,t),this}multiplyParent(t){return Q.multiplyParent(this,t),this}divide(t){return Q.divide(this,t),this}divideParent(t){return Q.divideParent(this,t),this}invert(){return Q.invert(this),this}invertWith(){return Q.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,i){Q.toOuterPoint(this,t,e,i)}toInnerPoint(t,e,i){Q.toInnerPoint(this,t,e,i)}setLayout(t,e,i){return Q.setLayout(this,t,e,i),this}getLayout(t,e,i){return Q.getLayout(this,t,e,i)}withScale(t,e){return Q.withScale(this,t,e)}reset(){Q.reset(this)}}const yt=new mt,vt={tempPointBounds:{},setPoint(t,e,i){t.minX=t.maxX=e,t.minY=t.maxY=i},addPoint(t,e,i){t.minX=e<t.minX?e:t.minX,t.minY=i<t.minY?i:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=i>t.maxY?i:t.maxY},addBounds(t,e,i,s,n){xt(t,e,i),xt(t,e+s,i+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:xt}=vt;var wt,bt;!function(t){t[t.top=0]="top",t[t.right=1]="right",t[t.bottom=2]="bottom",t[t.left=3]="left"}(wt||(wt={})),function(t){t[t.topLeft=0]="topLeft",t[t.top=1]="top",t[t.topRight=2]="topRight",t[t.right=3]="right",t[t.bottomRight=4]="bottomRight",t[t.bottom=5]="bottom",t[t.bottomLeft=6]="bottomLeft",t[t.left=7]="left",t[t.center=8]="center",t[t["top-left"]=0]="top-left",t[t["top-right"]=2]="top-right",t[t["bottom-right"]=4]="bottom-right",t[t["bottom-left"]=6]="bottom-left"}(bt||(bt={}));const kt=[{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}];kt.forEach(t=>t.type="percent");const Et={directionData:kt,tempPoint:{},get:St,toPoint(t,e,i,s,n,r){const o=St(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={}),Et.toPoint(t,e,i,!0),i)};function St(t){return r(t)?kt[bt[t]]:t}const{toPoint:Bt}=Et,Tt={toPoint(t,e,i,s,n,r){Bt(t,i,s,n,e,r)}},{tempPointBounds:Rt,setPoint:Ot,addPoint:Ct,toBounds:Lt}=vt,{toOuterPoint:Pt}=Q,{float:Mt,fourNumber:At}=F,{floor:Dt,ceil:It}=Math;let Wt,Ft,zt,Yt;const Nt={},Xt={},Ht={},Vt={tempBounds:Ht,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(d(i)){const e=At(i);s?Ut.set(t,r+e[3],o+e[0],a-e[1]-e[3],h-e[2]-e[0]):Ut.set(t,r-e[3],o-e[0],a+e[1]+e[3],h+e[2]+e[0])}else s&&(i=-i),Ut.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),Ut.move(t,e,i),t),toOffsetOutBounds(t,e,i){e?Gt(e,t):e=t,i||(i=t),e.offsetX=Ut.maxX(i),e.offsetY=Ut.maxY(i),Ut.move(e,-e.offsetX,-e.offsetY)},scale(t,e,i=e,s){s||dt.scale(t,e,i),t.width*=e,t.height*=i},scaleOf(t,e,i,s=i){dt.scaleOf(t,e,i,s),t.width*=i,t.height*=s},tempToOuterOf:(t,e)=>(Ut.copy(Ht,t),Ut.toOuterOf(Ht,e),Ht),getOuterOf:(t,e)=>(t=Object.assign({},t),Ut.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 Nt.x=t.x,Nt.y=t.y,Pt(e,Nt,Xt),Ot(Rt,Xt.x,Xt.y),Nt.x=t.x+t.width,Pt(e,Nt,Xt),Ct(Rt,Xt.x,Xt.y),Nt.y=t.y+t.height,Pt(e,Nt,Xt),Ct(Rt,Xt.x,Xt.y),Nt.x=t.x,Pt(e,Nt,Xt),Ct(Rt,Xt.x,Xt.y),Lt(Rt,i)},toInnerOf(t,e,i){i||(i=t),Ut.move(i,-e.e,-e.f),Ut.scale(i,1/e.a,1/e.d)},getFitMatrix(t,e,i=1){const s=Math.min(i,Ut.getFitScale(t,e));return new mt(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=Ut.getFitScale(t,e,"cover"===s)),Ht.width=n?e.width*=s:e.width*s,Ht.height=n?e.height*=s:e.height*s,Tt.toPoint(i,Ht,t,o,!0,!0)},getSpread(t,e,i){const s={};return Ut.copyAndSpread(s,t,e,!1,i),s},spread(t,e,i){Ut.copyAndSpread(t,t,e,!1,i)},shrink(t,e,i){Ut.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=Mt(t.x,e),t.y=Mt(t.y,e),t.width=Mt(t.width,e),t.height=Mt(t.height,e)},add(t,e,i){Wt=t.x+t.width,Ft=t.y+t.height,zt=e.x,Yt=e.y,i||(zt+=e.width,Yt+=e.height),Wt=Wt>zt?Wt:zt,Ft=Ft>Yt?Ft:Yt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=Wt-t.x,t.height=Ft-t.y},addList(t,e){Ut.setListWithFn(t,e,void 0,!0)},setList(t,e,i=!1){Ut.setListWithFn(t,e,void 0,i)},addListWithFn(t,e,i){Ut.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||Gt(t,n)):jt(t,n));r&&Ut.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?Ot(Rt,t.x,t.y):Ct(Rt,t.x,t.y)),Lt(Rt,t)},setPoint(t,e){Ut.set(t,e.x,e.y)},addPoint(t,e){jt(t,e,!0)},getPoints(t){const{x:e,y:i,width:s,height:n}=t;return[{x:e,y:i},{x:e+s,y:i},{x:e+s,y:i+n},{x:e,y:i+n}]},hitRadiusPoint:(t,e,i)=>(i&&(e=dt.tempToInnerRadiusPointOf(e,i)),e.x>=t.x-e.radiusX&&e.x<=t.x+t.width+e.radiusX&&e.y>=t.y-e.radiusY&&e.y<=t.y+t.height+e.radiusY),hitPoint:(t,e,i)=>(i&&(e=dt.tempToInnerOf(e,i)),e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height),hit:(t,e,i)=>(i&&(e=Ut.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=Ut.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=Ut.tempToOuterOf(e,i)),!Ut.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:s,y:n,width:r,height:o}=e;return Wt=s+r,Ft=n+o,zt=t.x+t.width,Yt=t.y+t.height,s=s>t.x?s:t.x,n=n>t.y?n:t.y,Wt=Wt<zt?Wt:zt,Ft=Ft<Yt?Ft:Yt,r=Wt-s,o=Ft-n,{x:s,y:n,width:r,height:o}},intersect(t,e,i){Ut.copy(t,Ut.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){Ut.set(t)}},Ut=Vt,{add:jt,copy:Gt}=Ut;class Kt{get minX(){return Vt.minX(this)}get minY(){return Vt.minY(this)}get maxX(){return Vt.maxX(this)}get maxY(){return Vt.maxY(this)}constructor(t,e,i,s){this.set(t,e,i,s)}set(t,e,i,s){return c(t)?Vt.copy(this,t):Vt.set(this,t,e,i,s),this}get(){const{x:t,y:e,width:i,height:s}=this;return{x:t,y:e,width:i,height:s}}clone(){return new Kt(this)}move(t,e){return Vt.move(this,t,e),this}scale(t,e,i){return Vt.scale(this,t,e,i),this}scaleOf(t,e,i){return Vt.scaleOf(this,t,e,i),this}toOuterOf(t,e){return Vt.toOuterOf(this,t,e),this}toInnerOf(t,e){return Vt.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Vt.getFitMatrix(this,t,e)}put(t,e,i){Vt.put(this,t,e,i)}spread(t,e){return Vt.spread(this,t,e),this}shrink(t,e){return Vt.shrink(this,t,e),this}ceil(){return Vt.ceil(this),this}unsign(){return Vt.unsign(this),this}float(t){return Vt.float(this,t),this}add(t){return Vt.add(this,t),this}addList(t){return Vt.setList(this,t,!0),this}setList(t){return Vt.setList(this,t),this}addListWithFn(t,e){return Vt.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Vt.setListWithFn(this,t,e),this}setPoint(t){return Vt.setPoint(this,t),this}setPoints(t){return Vt.setPoints(this,t),this}addPoint(t){return Vt.addPoint(this,t),this}getPoints(){return Vt.getPoints(this)}hitPoint(t,e){return Vt.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Vt.hitRadiusPoint(this,t,e)}hit(t,e){return Vt.hit(this,t,e)}includes(t,e){return Vt.includes(this,t,e)}intersect(t,e){return Vt.intersect(this,t,e),this}getIntersect(t,e){return new Kt(Vt.getIntersectData(this,t,e))}isSame(t){return Vt.isSame(this,t)}isEmpty(){return Vt.isEmpty(this)}reset(){Vt.reset(this)}}const Zt=new Kt;class qt{constructor(t,e,i,s,n,r){c(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 Kt(n,e,r||t.width-n-i,o||t.height-e-s)}}const Jt={0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,".":1,e:1,E:1},{randColor:$t}=F;class Qt{constructor(t){this.repeatMap={},this.name=t}static get(t){return new Qt(t)}static set filter(t){this.filterList=te(t)}static set exclude(t){this.excludeList=te(t)}static drawRepaint(t,e){const i=$t();t.fillWorld(e,i.replace("1)",".1)")),t.strokeWorld(e,i)}static drawBounds(t,e,i){const s="hit"===Qt.showBounds,n=t.__nowWorld,r=$t();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(ee.enable){if(ee.filterList.length&&ee.filterList.every(t=>t!==this.name))return;if(ee.excludeList.length&&ee.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){ee.enable&&this.warn(...t)}warn(...t){ee.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 te(t){return t?r(t)&&(t=[t]):t=[],t}Qt.filterList=[],Qt.excludeList=[],Qt.showWarn=!0;const ee=Qt,ie=Qt.get("RunTime"),se={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,e){const i=w.create(w.RUNTIME);return ne.currentId=ne.idMap[i]=e?performance.now():Date.now(),ne.currentName=ne.nameMap[i]=t,ne.nameToIdMap[t]=i,i},end(t,e){const i=ne.idMap[t],s=ne.nameMap[t],n=e?(performance.now()-i)/1e3:Date.now()-i;ne.idMap[t]=ne.nameMap[t]=ne.nameToIdMap[s]=void 0,ie.log(s,n,"ms")},endOfName(t,e){const i=ne.nameToIdMap[t];s(i)||ne.end(i,e)}},ne=se,re=[],oe={list:{},add(t,...e){this.list[t]=!0,re.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(()=>re.forEach(t=>oe.has(t,!0)));const ae={editor:t=>oe.need("editor")},he=Qt.get("UICreator"),le={list:{},register(t){const{__tag:e}=t.prototype;de[e]&&he.repeat(e),de[e]=t},get(t,e,i,n,r,o){de[t]||he.error("not register "+t);const a=new de[t](e);return s(i)||(a.x=i,n&&(a.y=n),r&&(a.width=r),o&&(a.height=o)),a}},{list:de}=le,ce=Qt.get("EventCreator"),ue={nameList:{},register(t){let e;Object.keys(t).forEach(i=>{e=t[i],r(e)&&(_e[e]&&ce.repeat(e),_e[e]=t)})},changeName(t,e){const i=_e[t];if(i){const s=Object.keys(i).find(e=>i[e]===t);s&&(i[s]=e,_e[e]=i)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new _e[t](...e)},{nameList:_e}=ue;class ge{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=ae.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 pe(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 fe(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 me(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 ye=[];function ve(){return(t,e)=>{ye.push(e)}}const xe=[];let we=class{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||xe)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;ye.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){c(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}};pe([me("imageSmoothingEnabled")],we.prototype,"smooth",void 0),pe([me("imageSmoothingQuality")],we.prototype,"smoothLevel",void 0),pe([me("globalAlpha")],we.prototype,"opacity",void 0),pe([me()],we.prototype,"fillStyle",void 0),pe([me()],we.prototype,"strokeStyle",void 0),pe([me("lineWidth")],we.prototype,"strokeWidth",void 0),pe([me("lineCap")],we.prototype,"strokeCap",void 0),pe([me("lineJoin")],we.prototype,"strokeJoin",void 0),pe([me("lineDashOffset")],we.prototype,"dashOffset",void 0),pe([me()],we.prototype,"miterLimit",void 0),pe([me()],we.prototype,"shadowBlur",void 0),pe([me()],we.prototype,"shadowColor",void 0),pe([me()],we.prototype,"shadowOffsetX",void 0),pe([me()],we.prototype,"shadowOffsetY",void 0),pe([me()],we.prototype,"filter",void 0),pe([me()],we.prototype,"font",void 0),pe([me()],we.prototype,"fontKerning",void 0),pe([me()],we.prototype,"fontStretch",void 0),pe([me()],we.prototype,"fontVariantCaps",void 0),pe([me()],we.prototype,"textAlign",void 0),pe([me()],we.prototype,"textBaseline",void 0),pe([me()],we.prototype,"textRendering",void 0),pe([me()],we.prototype,"wordSpacing",void 0),pe([me()],we.prototype,"letterSpacing",void 0),pe([me()],we.prototype,"direction",void 0),pe([ve()],we.prototype,"setTransform",null),pe([ve()],we.prototype,"resetTransform",null),pe([ve()],we.prototype,"getTransform",null),pe([ve()],we.prototype,"save",null),pe([ve()],we.prototype,"restore",null),pe([ve()],we.prototype,"translate",null),pe([ve()],we.prototype,"scale",null),pe([ve()],we.prototype,"rotate",null),pe([ve()],we.prototype,"fill",null),pe([ve()],we.prototype,"stroke",null),pe([ve()],we.prototype,"clip",null),pe([ve()],we.prototype,"fillRect",null),pe([ve()],we.prototype,"strokeRect",null),pe([ve()],we.prototype,"clearRect",null),pe([ve()],we.prototype,"beginPath",null),pe([ve()],we.prototype,"moveTo",null),pe([ve()],we.prototype,"lineTo",null),pe([ve()],we.prototype,"bezierCurveTo",null),pe([ve()],we.prototype,"quadraticCurveTo",null),pe([ve()],we.prototype,"closePath",null),pe([ve()],we.prototype,"arc",null),pe([ve()],we.prototype,"arcTo",null),pe([ve()],we.prototype,"ellipse",null),pe([ve()],we.prototype,"rect",null),pe([ve()],we.prototype,"roundRect",null),pe([ve()],we.prototype,"createConicGradient",null),pe([ve()],we.prototype,"createLinearGradient",null),pe([ve()],we.prototype,"createPattern",null),pe([ve()],we.prototype,"createRadialGradient",null),pe([ve()],we.prototype,"fillText",null),pe([ve()],we.prototype,"measureText",null),pe([ve()],we.prototype,"strokeText",null);const{copy:be,multiplyParent:ke,pixelScale:Ee}=Q,{round:Se}=Math,Be=new Kt,Te=new Kt,Re={width:1,height:1,pixelRatio:1},Oe=["width","height","pixelRatio"];class Ce extends we{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=Re),this.manager=e,this.innerId=w.create(w.CNAVAS);const{width:i,height:s,pixelRatio:n}=t;this.autoLayout=!i||!s,this.size.pixelRatio=n||v.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;g.copyAttrs(s,t,Oe),Oe.forEach(t=>s[t]||(s[t]=1)),this.bounds=new Kt(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&&ke(t,e,n),Ee(t,i,n),s&&!t.ignorePixelSnap&&(t.half&&t.half*i%2?(n.e=Se(n.e-.5)+.5,n.f=Se(n.f-.5)+.5):(n.e=Se(n.e),n.f=Se(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=Te):i=Be,this.drawImage(t.view,Be.x,Be.y,Be.width,Be.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,Vt.tempToOuterOf(i,e),s,n),this.restore()):(s&&(this.blendMode=s),this.setTempPixelBounds(e,n),this.drawImage(t.view,Be.x,Be.y,Be.width,Be.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(Be.x,Be.y,Be.width,Be.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,Be.x,Be.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(Be.x,Be.y,Be.width,Be.height),i&&(this.blendMode="source-over")}strokeWorld(t,e,i,s){i&&(this.blendMode=i),this.strokeStyle=e,this.setTempPixelBounds(t,s),this.strokeRect(Be.x,Be.y,Be.width,Be.height),i&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(Be.x,Be.y,Be.width,Be.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(Be.x,Be.y,Be.width,Be.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,i){this.copyToPixelBounds(Be,t,e,i)}setTempPixelBounds2(t,e,i){this.copyToPixelBounds(Te,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):ae.canvas(Object.assign({},i));return n.save(),t&&(be(n.worldTransform,this.worldTransform),n.useWorldTransform()),e&&(n.smooth=this.smooth),n.pixelSnap!==s&&(n.pixelSnap=s),n}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const Le={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Pe={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Me=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},Pe),Ae={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),Pe),We=Me,Fe={};for(let t in We)Fe[We[t]]=t;const ze={};for(let t in We)ze[We[t]]=Ae[t];const Ye={drawRoundRect(t,e,i,s,n,r){const o=F.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:Ne,cos:Xe,hypot:He,atan2:Ve,ceil:Ue,abs:je,PI:Ge,sqrt:Ke,pow:Ze}=Math,{setPoint:qe,addPoint:Je}=vt,{set:$e,toNumberPoints:Qe}=dt,{M:ti,L:ei,C:ii,Q:si,Z:ni}=Me,ri={},oi={points(t,e,i,s){let n=Qe(e);if(t.push(ti,n[0],n[1]),i&&n.length>5){let e,r,o,a,h,l,d,c,u,_,g,p,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=Ke(Ze(o-e,2)+Ze(a-r,2)),p=Ke(Ze(h-o,2)+Ze(l-a,2)),(g||p)&&(f=g+p,g=y*g/f,p=y*p/f,h-=e,l-=r,d=o-g*h,c=a-g*l,2===i?s||t.push(si,d,c,o,a):t.push(ii,u,_,d,c,o,a),u=o+p*h,_=a+p*l);s||t.push(si,u,_,n[m-2],n[m-1])}else for(let e=2,i=n.length;e<i;e+=2)t.push(ei,n[e],n[e+1]);s&&t.push(ni)},rect(t,e,i,s,n){Le.creator.path=t,Le.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){Le.creator.path=[],Ye.drawRoundRect(Le.creator,e,i,s,n,r),t.push(...Le.convertToCanvasData(Le.creator.path,!0))},arcTo(t,e,i,s,n,r,o,a,h,l,d){const c=s-e,u=n-i,_=r-s,g=o-n;let p=Ve(u,c),f=Ve(g,_);const m=He(c,u),y=He(_,g);let v=f-p;if(v<0&&(v+=N),m<1e-12||y<1e-12||v<1e-12||je(v-Ge)<1e-12)return t&&t.push(ei,s,n),h&&(qe(h,e,i),Je(h,s,n)),d&&$e(d,e,i),void(l&&$e(l,s,n));const x=c*g-_*u<0,w=x?-1:1,b=a/Xe(v/2),k=s+b*Xe(p+v/2+X*w),E=n+b*Ne(p+v/2+X*w);return p-=X*w,f-=X*w,li(t,k,E,a,a,0,p/Y,f/Y,x,h,l,d)},arc:(t,e,i,s,n,r,o,a,h,l)=>li(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*Y,_=Ne(u),g=Xe(u);let p=o*Y,f=a*Y;p>Ge&&(p-=N),f<0&&(f+=N);let m=f-p;m<0?m+=N:m>N&&(m-=N),h&&(m-=N);const y=Ue(je(m/X)),v=m/y,x=Ne(v/4),w=8/3*x*x/Ne(v/2);f=p+v;let b,k,E,S,B,T,R,O,C=Xe(p),L=Ne(p),P=E=g*s*C-_*n*L,M=S=_*s*C+g*n*L,A=e+E,D=i+S;t&&t.push(t.length?ei:ti,A,D),l&&qe(l,A,D),c&&$e(c,A,D);for(let r=0;r<y;r++)b=Xe(f),k=Ne(f),E=g*s*b-_*n*k,S=_*s*b+g*n*k,B=e+P-w*(g*s*L+_*n*C),T=i+M-w*(_*s*L-g*n*C),R=e+E+w*(g*s*k+_*n*b),O=i+S+w*(_*s*k-g*n*b),t&&t.push(ii,B,T,R,O,e+E,i+S),l&&hi(e+P,i+M,B,T,R,O,e+E,i+S,l,!0),P=E,M=S,C=b,L=k,p=f,f+=v;d&&$e(d,e+E,i+S)},quadraticCurveTo(t,e,i,s,n,r,o){t.push(ii,(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){hi(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,_,g,p,f,m,y,v=t,x=i,w=n,b=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=s,w=r,b=a),c=-3*v+9*x-9*w+3*b,u=6*v-12*x+6*w,_=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;g=-_/u,0<g&&g<1&&d.push(g)}else m=u*u-4*_*c,y=Math.sqrt(m),m<0||(p=(-u+y)/(2*c),0<p&&p<1&&d.push(p),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?Je(h,t,e):qe(h,t,e),Je(h,o,a);for(let l=0,c=d.length;l<c;l++)ai(d[l],t,e,i,s,n,r,o,a,ri),Je(h,ri.x,ri.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,_=3*d*t*t,g=t*t*t;l.x=c*e+u*s+_*r+g*a,l.y=c*i+u*n+_*o+g*h},getPoint(t,e,i,s,n,r,o,a,h){const l={};return ai(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:ai,toTwoPointBounds:hi,ellipse:li}=oi,{sin:di,cos:ci,sqrt:ui,atan2:_i}=Math,{ellipse:gi}=oi,pi={ellipticalArc(t,e,i,s,n,r,o,a,h,l,d){const c=(h-e)/2,u=(l-i)/2,_=r*Y,g=di(_),p=ci(_),f=-p*c-g*u,m=-p*u+g*c,y=s*s,x=n*n,w=m*m,b=f*f,k=y*x-y*w-x*b;let E=0;if(k<0){const t=ui(1-k/(y*x));s*=t,n*=t}else E=(o===a?-1:1)*ui(k/(y*w+x*b));const S=E*s*m/n,B=-E*n*f/s,T=_i((m-B)/n,(f-S)/s),R=_i((-m-B)/n,(-f-S)/s);let O=R-T;0===a&&O>0?O-=N:1===a&&O<0&&(O+=N);const C=e+c+p*S-g*B,L=i+u+g*S+p*B,P=O<0?1:0;d||v.ellipseToCurve?gi(t,C,L,s,n,r,T/Y,R/Y,P):s!==n||r?t.push(Me.G,C,L,s,n,r,T/Y,R/Y,P):t.push(Me.O,C,L,s,T/Y,R/Y,P)}},fi={toCommand:t=>[],toNode:t=>[]},{M:mi,m:yi,L:vi,l:xi,H:wi,h:bi,V:ki,v:Ei,C:Si,c:Bi,S:Ti,s:Ri,Q:Oi,q:Ci,T:Li,t:Pi,A:Mi,a:Ai,Z:Di,z:Ii,N:Wi,D:Fi,X:zi,G:Yi,F:Ni,O:Xi,P:Hi,U:Vi}=Me,{rect:Ui,roundRect:ji,arcTo:Gi,arc:Ki,ellipse:Zi,quadraticCurveTo:qi}=oi,{ellipticalArc:Ji}=pi,$i=Qt.get("PathConvert"),Qi={},ts={current:{dot:0},stringify(t,e){let i,s,n,r=0,o=t.length,a="";for(;r<o;){s=t[r],i=ze[s],a+=s===n?" ":Fe[s];for(let s=1;s<i;s++)a+=F.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],Jt[s]?("."===s&&(es.dot&&(is(o,r),r=""),es.dot++),"0"===r&&"."!==s&&(is(o,r),r=""),r+=s):Me[s]?(r&&(is(o,r),r=""),es.name=Me[s],es.length=Ae[s],es.index=0,is(o,es.name),!i&&a[s]&&(i=!0)):"-"===s||"+"===s?"e"===n||"E"===n?r+=s:(r&&is(o,r),r=s):r&&(is(o,r),r=""),n=s;return r&&is(o,r),i?ts.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 _=[];for(;c<u;){switch(n=t[c],n){case yi:t[c+1]+=a,t[c+2]+=h;case mi:a=t[c+1],h=t[c+2],_.push(mi,a,h),c+=3;break;case bi:t[c+1]+=a;case wi:a=t[c+1],_.push(vi,a,h),c+=2;break;case Ei:t[c+1]+=h;case ki:h=t[c+1],_.push(vi,a,h),c+=2;break;case xi:t[c+1]+=a,t[c+2]+=h;case vi:a=t[c+1],h=t[c+2],_.push(vi,a,h),c+=3;break;case Ri:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Ti;case Ti:o=r===Si||r===Ti,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],_.push(Si,l,d,i,s,a,h),c+=5;break;case Bi: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=Si;case Si:i=t[c+3],s=t[c+4],a=t[c+5],h=t[c+6],_.push(Si,t[c+1],t[c+2],i,s,a,h),c+=7;break;case Pi:t[c+1]+=a,t[c+2]+=h,n=Li;case Li:o=r===Oi||r===Li,i=o?2*a-i:t[c+1],s=o?2*h-s:t[c+2],e?qi(_,a,h,i,s,t[c+1],t[c+2]):_.push(Oi,i,s,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case Ci:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=Oi;case Oi:i=t[c+1],s=t[c+2],e?qi(_,a,h,i,s,t[c+3],t[c+4]):_.push(Oi,i,s,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case Ai:t[c+6]+=a,t[c+7]+=h;case Mi:Ji(_,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 Ii:case Di:_.push(Di),c++;break;case Wi:a=t[c+1],h=t[c+2],e?Ui(_,a,h,t[c+3],t[c+4]):ss(_,t,c,5),c+=5;break;case Fi:a=t[c+1],h=t[c+2],e?ji(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):ss(_,t,c,9),c+=9;break;case zi:a=t[c+1],h=t[c+2],e?ji(_,a,h,t[c+3],t[c+4],t[c+5]):ss(_,t,c,6),c+=6;break;case Yi:Zi(e?_:ss(_,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,Qi),a=Qi.x,h=Qi.y,c+=9;break;case Ni:e?Zi(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):ss(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Xi:Ki(e?_:ss(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,Qi),a=Qi.x,h=Qi.y,c+=7;break;case Hi:e?Ki(_,t[c+1],t[c+2],t[c+3],0,360,!1):ss(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Vi:Gi(e?_:ss(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,Qi),a=Qi.x,h=Qi.y,c+=6;break;default:return $i.error(`command: ${n} [index:${c}]`,t),_}r=n}return _},objectToCanvasData(t){if(t[0].name.length>1)return fi.toCommand(t);{const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(mi,t.x,t.y);break;case"L":e.push(vi,t.x,t.y);break;case"C":e.push(Si,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(Oi,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(Di)}}),e}},copyData(t,e,i,s){for(let n=i,r=i+s;n<r;n++)t.push(e[n])},pushData(t,e){es.index===es.length&&(es.index=1,t.push(es.name)),t.push(Number(e)),es.index++,es.dot=0}},{current:es,pushData:is,copyData:ss}=ts,{M:ns,L:rs,C:os,Q:as,Z:hs,N:ls,D:ds,X:cs,G:us,F:_s,O:gs,P:ps,U:fs}=Me,{getMinDistanceFrom:ms,getRadianFrom:ys}=dt,{tan:vs,min:xs,abs:ws}=Math,bs={},ks={beginPath(t){t.length=0},moveTo(t,e,i){t.push(ns,e,i)},lineTo(t,e,i){t.push(rs,e,i)},bezierCurveTo(t,e,i,s,n,r,o){t.push(os,e,i,s,n,r,o)},quadraticCurveTo(t,e,i,s,n){t.push(as,e,i,s,n)},closePath(t){t.push(hs)},rect(t,e,i,s,n){t.push(ls,e,i,s,n)},roundRect(t,e,i,s,n,r){if(a(r))t.push(cs,e,i,s,n,r);else{const o=F.fourNumber(r);o?t.push(ds,e,i,s,n,...o):t.push(ls,e,i,s,n)}},ellipse(t,e,i,s,r,o,a,h,l){n(o)?t.push(_s,e,i,s,r):(n(a)&&(a=0),n(h)&&(h=360),t.push(us,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(gs,e,i,s,r,o,a?1:0))},arcTo(t,e,i,n,r,o,a,h){if(!s(a)){const t=ms(a,h,e,i,n,r);o=xs(o,xs(t/2,t/2*ws(vs(ys(a,h,e,i,n,r)/2))))}t.push(fs,e,i,n,r,o)},drawEllipse(t,e,i,s,r,o,a,h,l){oi.ellipse(null,e,i,s,r,n(o)?0:o,n(a)?0:a,n(h)?360:h,l,null,null,bs),t.push(ns,bs.x,bs.y),Es(t,e,i,s,r,o,a,h,l)},drawArc(t,e,i,s,r,o,a){oi.arc(null,e,i,s,n(r)?0:r,n(o)?360:o,a,null,null,bs),t.push(ns,bs.x,bs.y),Ss(t,e,i,s,r,o,a)},drawPoints(t,e,i,s){oi.points(t,e,i,s)}},{ellipse:Es,arc:Ss}=ks,{moveTo:Bs,lineTo:Ts,quadraticCurveTo:Rs,bezierCurveTo:Os,closePath:Cs,beginPath:Ls,rect:Ps,roundRect:Ms,ellipse:As,arc:Ds,arcTo:Is,drawEllipse:Ws,drawArc:Fs,drawPoints:zs}=ks;class Ys{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?r(t)?Le.parse(t):t:[],this}beginPath(){return Ls(this.__path),this.paint(),this}moveTo(t,e){return Bs(this.__path,t,e),this.paint(),this}lineTo(t,e){return Ts(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,i,s,n,r){return Os(this.__path,t,e,i,s,n,r),this.paint(),this}quadraticCurveTo(t,e,i,s){return Rs(this.__path,t,e,i,s),this.paint(),this}closePath(){return Cs(this.__path),this.paint(),this}rect(t,e,i,s){return Ps(this.__path,t,e,i,s),this.paint(),this}roundRect(t,e,i,s,n){return Ms(this.__path,t,e,i,s,n),this.paint(),this}ellipse(t,e,i,s,n,r,o,a){return As(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}arc(t,e,i,s,n,r){return Ds(this.__path,t,e,i,s,n,r),this.paint(),this}arcTo(t,e,i,s,n){return Is(this.__path,t,e,i,s,n),this.paint(),this}drawEllipse(t,e,i,s,n,r,o,a){return Ws(this.__path,t,e,i,s,n,r,o,a),this.paint(),this}drawArc(t,e,i,s,n,r){return Fs(this.__path,t,e,i,s,n,r),this.paint(),this}drawPoints(t,e,i){return zs(this.__path,t,e,i),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:Ns,L:Xs,C:Hs,Q:Vs,Z:Us,N:js,D:Gs,X:Ks,G:Zs,F:qs,O:Js,P:$s,U:Qs}=Me,tn=Qt.get("PathDrawer"),en={drawPathByData(t,e){if(!e)return;let i,s=0,n=e.length;for(;s<n;)switch(i=e[s],i){case Ns:t.moveTo(e[s+1],e[s+2]),s+=3;break;case Xs: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 Vs:t.quadraticCurveTo(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Us:t.closePath(),s+=1;break;case js:t.rect(e[s+1],e[s+2],e[s+3],e[s+4]),s+=5;break;case Gs: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 Ks:t.roundRect(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;case Zs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]*Y,e[s+6]*Y,e[s+7]*Y,e[s+8]),s+=9;break;case qs:t.ellipse(e[s+1],e[s+2],e[s+3],e[s+4],0,0,N,!1),s+=5;break;case Js:t.arc(e[s+1],e[s+2],e[s+3],e[s+4]*Y,e[s+5]*Y,e[s+6]),s+=7;break;case $s:t.arc(e[s+1],e[s+2],e[s+3],0,N,!1),s+=4;break;case Qs:t.arcTo(e[s+1],e[s+2],e[s+3],e[s+4],e[s+5]),s+=6;break;default:return void tn.error(`command: ${i} [index:${s}]`,e)}}},{M:sn,L:nn,C:rn,Q:on,Z:an,N:hn,D:ln,X:dn,G:cn,F:un,O:_n,P:gn,U:pn}=Me,{toTwoPointBounds:fn,toTwoPointBoundsByQuadraticCurve:mn,arcTo:yn,arc:vn,ellipse:xn}=oi,{addPointBounds:wn,copy:bn,addPoint:kn,setPoint:En,addBounds:Sn,toBounds:Bn}=vt,Tn=Qt.get("PathBounds");let Rn,On,Cn;const Ln={},Pn={},Mn={},An={toBounds(t,e){An.toTwoPointBounds(t,Pn),Bn(Pn,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===an||o===rn||o===on?En(e,h,l):En(e,t[a+1],t[a+2])),o){case sn:case nn:h=t[a+1],l=t[a+2],kn(e,h,l),a+=3;break;case rn:n=t[a+5],r=t[a+6],fn(h,l,t[a+1],t[a+2],t[a+3],t[a+4],n,r,Ln),wn(e,Ln),h=n,l=r,a+=7;break;case on:i=t[a+1],s=t[a+2],n=t[a+3],r=t[a+4],mn(h,l,i,s,n,r,Ln),wn(e,Ln),h=n,l=r,a+=5;break;case an:a+=1;break;case hn:h=t[a+1],l=t[a+2],Sn(e,h,l,t[a+3],t[a+4]),a+=5;break;case ln:case dn:h=t[a+1],l=t[a+2],Sn(e,h,l,t[a+3],t[a+4]),a+=o===ln?9:6;break;case cn:xn(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,Mn),0===a?bn(e,Ln):wn(e,Ln),h=Mn.x,l=Mn.y,a+=9;break;case un:h=t[a+1],l=t[a+2],On=t[a+3],Cn=t[a+4],Sn(e,h-On,l-Cn,2*On,2*Cn),h+=On,a+=5;break;case _n:vn(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],Ln,Mn),0===a?bn(e,Ln):wn(e,Ln),h=Mn.x,l=Mn.y,a+=7;break;case gn:h=t[a+1],l=t[a+2],Rn=t[a+3],Sn(e,h-Rn,l-Rn,2*Rn,2*Rn),h+=Rn,a+=4;break;case pn:yn(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],Ln,Mn),0===a?bn(e,Ln):wn(e,Ln),h=Mn.x,l=Mn.y,a+=6;break;default:return void Tn.error(`command: ${o} [index:${a}]`,t)}}},{M:Dn,L:In,Z:Wn}=Me,{getCenterX:Fn,getCenterY:zn}=dt,{arcTo:Yn}=ks,Nn={smooth(t,e,i){let s,n,r,o=0,a=0,h=0,l=0,d=0,c=0,u=0,_=0,g=0;const p=t.length,f=[];for(;o<p;){switch(s=t[o],s){case Dn:l=_=t[o+1],d=g=t[o+2],o+=3,t[o]===In?(c=t[o+1],u=t[o+2],f.push(Dn,Fn(l,c),zn(d,u))):f.push(Dn,l,d);break;case In:switch(a=t[o+1],h=t[o+2],o+=3,t[o]){case In:Yn(f,a,h,t[o+1],t[o+2],e,_,g);break;case Wn:Yn(f,a,h,l,d,e,_,g);break;default:f.push(In,a,h)}_=a,g=h;break;case Wn:n!==Wn&&(Yn(f,l,d,c,u,e,_,g),f.push(Wn)),o+=1;break;default:r=ze[s];for(let e=0;e<r;e++)f.push(t[o+e]);o+=r}n=s}return s!==Wn&&(f[1]=l,f[2]=d),f}};function Xn(t){return new Ys(t)}const Hn=Xn();Le.creator=Xn(),Le.parse=ts.parse,Le.convertToCanvasData=ts.toCanvasData;const{drawRoundRect:Vn}=Ye;function Un(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,i,s,n){Vn(this,t,e,i,s,n)})}(t)}const jn={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=Gn.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{}}}},Gn=jn;Gn.alphaPixelTypes.forEach(t=>Gn.upperCaseTypeMap[t]=t.toUpperCase());const Kn=Qt.get("TaskProcessor");class Zn{constructor(t){this.parallel=!0,this.time=1,this.id=w.create(w.TASK),this.task=t}run(){return fe(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){Kn.error(t)}})}complete(){this.isComplete=!0,this.parent=this.task=this.canUse=null}cancel(){this.isCancel=!0,this.complete()}}class qn{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&&g.assign(this.config,t),this.empty()}add(t,e,i){let n,r,o,h;const l=new Zn(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 Jn=Qt.get("Resource"),$n={tasker:new qn,map:{},get isComplete(){return Qn.tasker.isComplete},set(t,e){Qn.map[t]&&Jn.repeat(t),Qn.map[t]=e},get:t=>Qn.map[t],remove(t){const e=Qn.map[t];e&&(e.destroy&&e.destroy(),delete Qn.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=ae.image(s)),Qn.set(t,e),e},destroy(){Qn.map={}}},Qn=$n,tr={maxRecycled:10,recycledList:[],patternTasker:new qn,get(t){let e=$n.get(t.url);return e||$n.set(t.url,e=ae.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||er.recycledList.push(t)})},clearRecycled(){const t=er.recycledList;t.length>er.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&$n.remove(t.url)),t.length=0)},hasAlphaPixel:t=>jn.alphaPixelTypes.some(e=>er.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:"+jn.mineType(t)))return!0}else{if(i.includes("."+t)||i.includes("."+jn.upperCaseTypeMap[t]))return!0;if("png"===t&&!i.includes("."))return!0}return!1},destroy(){er.recycledList=[]}},er=tr,{IMAGE:ir,create:sr}=w;class nr{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=sr(ir),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}tr.isFormat("svg",t)&&(this.isSVG=!0),tr.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(t,e){if(!this.loading){this.loading=!0;const{crossOrigin:t}=this.config;$n.tasker.add(()=>fe(this,void 0,void 0,function*(){return yield v.origin.loadImage(this.url,s(t)?v.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=v.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=v.canvas.createPattern(t,e);return v.image.setPatternTransform(n,i,s),n}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}}function rr(t,e,i,s){s||(i.configurable=i.enumerable=!0),Object.defineProperty(t,e,i)}function or(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ar(t,e){const i="_"+t;return{get(){const t=this[i];return null==t?e:t},set(t){this[i]=t}}}function hr(t,e){return(i,s)=>dr(i,s,t,e&&e(s))}function lr(t){return t}function dr(t,e,i,s){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};rr(t,e,Object.assign(n,s||{})),zr(t,e,i)}function cr(t){return hr(t)}function ur(t,e){return hr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))}function _r(t,e){return hr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))}function gr(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),vr(this))}}))}function pr(t,e){return hr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))}function fr(t,e){return hr(t,t=>({set(i){this.__setAttr(t,i,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))}function mr(t,e){return hr(t,t=>({set(i){this.__setAttr(t,i,e)&&vr(this)}}))}function yr(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&(vr(this),this.__.__removeNaturalSize())}}))}function vr(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}function xr(t){return hr(t,t=>({set(e){const i=this.__;2!==i.__pathInputed&&(i.__pathInputed=e?1:0),e||(i.__pathForRender=void 0),this.__setAttr(t,e),vr(this)}}))}const wr=mr;function br(t,e){return hr(t,t=>({set(i){this.__setAttr(t,i)&&(kr(this),e&&(this.__.__useStroke=!0))}}))}function kr(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&vr(t)}const Er=br;function Sr(t){return hr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Br(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))}function Tr(t){return hr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__;g.stintSet(t,"__useDim",t.dim||t.bright||t.dimskip),this.__layout.surfaceChange()}}}))}function Rr(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Cr(this)}}))}function Or(t){return hr(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&&Cr(this)}}))}function Cr(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||vr(t))}function Pr(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))}function Mr(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))}function Ar(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))}function Dr(t){return hr(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===Qt.showBounds&&this.__layout.surfaceChange(),this.leafer&&this.leafer.updateCursor())}}))}function Ir(t){return hr(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))}function Wr(t){return(e,i)=>{rr(e,"__DataProcessor",{get:()=>t})}}function Fr(t){return(e,i)=>{rr(e,"__LayoutProcessor",{get:()=>t})}}function zr(t,e,i){const n=t.__DataProcessor.prototype,r="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=ar(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(c(i)){const t=_(i);a.get=function(){const e=this[r];return null==e?this[r]=t?{}:g.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,d=n;for(;!l&&d;)l=or(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),n[o]&&(a.set=n[o],delete n[o]),rr(n,e,a)}const Yr=new Qt("rewrite"),Nr=[],Xr=["destroy","constructor"];function Hr(t){return(e,i)=>{Nr.push({name:e.constructor.name+"."+i,run:()=>{e[i]=t}})}}function Vr(){return t=>{Ur()}}function Ur(t){Nr.length&&(Nr.forEach(e=>{t&&Yr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Nr.length=0)}function jr(t,e){return i=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach(s=>{if(!(Xr.includes(s)||e&&e.includes(s)))if(t.prototype){or(t.prototype,s).writable&&(i.prototype[s]=t.prototype[s])}else i.prototype[s]=t[s]})}}function Gr(){return t=>{le.register(t)}}function Kr(){return t=>{ue.register(t)}}setTimeout(()=>Ur(!0));const{copy:Zr,toInnerPoint:qr,toOuterPoint:Jr,scaleOfOuter:$r,rotateOfOuter:Qr,skewOfOuter:to,multiplyParent:eo,divideParent:io,getLayout:so}=Q,no={},{round:ro}=Math,oo={updateAllMatrix(t,e,i){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(i=!0),lo(t,e,i),t.isBranch){const{children:s}=t;for(let t=0,n=s.length;t<n;t++)ho(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++)co(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&co(t),t.__updateChange()},updateAllChange(t){if(_o(t),t.isBranch){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)uo(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||v.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=c(e)?Object.assign({},e):{x:e,y:i};s?Jr(t.localTransform,r,r,!0):t.parent&&qr(t.parent.scrollWorldTransform,r,r,!0),ao.moveLocal(t,r.x,r.y,n)},moveLocal(t,e,i=0,s){c(e)&&(i=e.y,e=e.x),e+=t.x,i+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=ro(e),i=ro(i)),s?t.animate({x:e,y:i},s):(t.x=e,t.y=i)},zoomOfWorld(t,e,i,s,n,r){ao.zoomOfLocal(t,go(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),Zr(no,o),$r(no,e,i,s),ao.hasHighPosition(t))ao.setTransform(t,no,n,r);else{const e=t.x+no.e-o.e,a=t.y+no.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){ao.rotateOfLocal(t,go(t,e),i,s)},rotateOfLocal(t,e,i,s){const n=t.__localMatrix;Zr(no,n),Qr(no,e,i),ao.hasHighPosition(t)?ao.setTransform(t,no,!1,s):t.set({x:t.x+no.e-n.e,y:t.y+no.f-n.f,rotation:F.formatRotation(t.rotation+i)},s)},skewOfWorld(t,e,i,s,n,r){ao.skewOfLocal(t,go(t,e),i,s,n,r)},skewOfLocal(t,e,i,s=0,n,r){Zr(no,t.__localMatrix),to(no,e,i,s),ao.setTransform(t,no,n,r)},transformWorld(t,e,i,s){Zr(no,t.worldTransform),eo(no,e),t.parent&&io(no,t.parent.scrollWorldTransform),ao.setTransform(t,no,i,s)},transform(t,e,i,s){Zr(no,t.localTransform),eo(no,e),ao.setTransform(t,no,i,s)},setTransform(t,e,i,s){const n=t.__,r=n.origin&&ao.getInnerOrigin(t,n.origin),o=so(e,r,n.around&&ao.getInnerOrigin(t,n.around));if(ao.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){Vt.scale(t.boxBounds,Math.abs(e),Math.abs(i));const s=ao.getInnerOrigin(t,n.origin);dt.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 $r(i,ao.getLocalOrigin(t,"center"),-1*s,1*s),i},getLocalOrigin:(t,e)=>dt.tempToOuterOf(ao.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const i={};return Et.toPoint(e,t.boxBounds,i),i},getRelativeWorld:(t,e,i)=>(Zr(no,t.worldTransform),io(no,e.scrollWorldTransform),i?no:Object.assign({},no)),drop(t,e,i,s){t.setTransform(ao.getRelativeWorld(t,e,!0),s),e.add(t,i)},hasHighPosition:t=>t.origin||t.around||ao.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),v.requestRender(()=>ao.animateMove(t,e,i))}}},ao=oo,{updateAllMatrix:ho,updateMatrix:lo,updateAllWorldOpacity:co,updateAllChange:uo,updateChange:_o}=ao;function go(t,e){return t.updateLayout(),t.parent?dt.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const po={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)=>mo(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>mo(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>mo(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 fo;function mo(t,e){return e||(fo=0),t.__.mask&&(fo=1),fo<0?null:(fo&&(fo=-1),!0)}const{updateBounds:yo}=oo,vo={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),xo(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++)wo(e[t],e)},updateBounds(t,e){const i=[t];wo(t,i),bo(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++)yo(s[t]);e&&e===i||yo(i)}}},{pushAllChildBranch:xo,pushAllBranchStack:wo,updateBoundsByBranchStack:bo}=vo,ko={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:Eo,updateBounds:So}=oo,{toOuterOf:Bo,getPoints:To,copy:Ro}=Vt,Oo="_localContentBounds",Co="_worldContentBounds",Lo="_worldBoxBounds",Po="_worldStrokeBounds";class Mo{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[Oo]||(this[Oo]={})),this[Oo]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return Bo(this.contentBounds,this.leaf.__world,this[Co]||(this[Co]={})),this[Co]}get worldBoxBounds(){return Bo(this.boxBounds,this.leaf.__world,this[Lo]||(this[Lo]={})),this[Lo]}get worldStrokeBounds(){return Bo(this.strokeBounds,this.leaf.__world,this[Po]||(this[Po]={})),this[Po]}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 So(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,v.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 Q.defaultMatrix;case"page":t=e.zoomLayer;default:return Eo(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 Kt(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=Q.defaultMatrix;break;case"page":e=s.zoomLayer;default:n=s.getWorldPoint(a,e),r=Eo(s,e,!0)}if(o||(o=Q.getLayout(r)),Ro(o,a),dt.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=To(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 Ao{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&v.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&v.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&v.event.stop(this.origin)}}class Do extends Ao{constructor(t,e,i){super(t,e),this.parent=i,this.child=e}}Do.ADD="child.add",Do.REMOVE="child.remove",Do.CREATED="created",Do.MOUNTED="mounted",Do.UNMOUNTED="unmounted",Do.DESTROY="destroy";const Io="property.scroll";class Wo extends Ao{constructor(t,e,i,s,n){super(t,e),this.attrName=i,this.oldValue=s,this.newValue=n}}Wo.CHANGE="property.change",Wo.LEAFER_CHANGE="property.leafer_change",Wo.SCROLL=Io;const Fo={scrollX:Io,scrollY:Io};class zo extends Ao{constructor(t,e){super(t),Object.assign(this,e)}}zo.LOAD="image.load",zo.LOADED="image.loaded",zo.ERROR="image.error";class Yo extends Ao{static checkHas(t,e,i){"on"===i?e===Vo?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(No)||t.hasEvent(Xo)||t.hasEvent(Ho),t.__hasWorldEvent=t.hasEvent(Vo))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(No,t),"inner"===e&&t.emit(Xo,t)),t.emit(Ho,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Vo,this)}}Yo.RESIZE="bounds.resize",Yo.INNER="bounds.inner",Yo.LOCAL="bounds.local",Yo.WORLD="bounds.world";const{RESIZE:No,INNER:Xo,LOCAL:Ho,WORLD:Vo}=Yo,Uo={};[No,Xo,Ho,Vo].forEach(t=>Uo[t]=1);class jo extends Ao{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){c(t)?(super(jo.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!s(this.resizingKeys[t.innerId])}}jo.RESIZE="resize";class Go extends Ao{constructor(t,e){super(t),this.data=e}}Go.REQUEST="watch.request",Go.DATA="watch.data";class Ko extends Ao{constructor(t,e,i){super(t),e&&(this.data=e,this.times=i)}}Ko.REQUEST="layout.request",Ko.START="layout.start",Ko.BEFORE="layout.before",Ko.LAYOUT="layout",Ko.AFTER="layout.after",Ko.AGAIN="layout.again",Ko.END="layout.end";class Zo extends Ao{constructor(t,e,i,s){super(t),e&&(this.times=e),i&&(this.renderBounds=i,this.renderOptions=s)}}Zo.REQUEST="render.request",Zo.CHILD_START="render.child_start",Zo.CHILD_END="render.child_end",Zo.START="render.start",Zo.BEFORE="render.before",Zo.RENDER="render",Zo.AFTER="render.after",Zo.AGAIN="render.again",Zo.END="render.end",Zo.NEXT="render.next";class qo extends Ao{}qo.START="leafer.start",qo.BEFORE_READY="leafer.before_ready",qo.READY="leafer.ready",qo.AFTER_READY="leafer.after_ready",qo.VIEW_READY="leafer.view_ready",qo.VIEW_COMPLETED="leafer.view_completed",qo.STOP="leafer.stop",qo.RESTART="leafer.restart",qo.END="leafer.end",qo.UPDATE_MODE="leafer.update_mode",qo.TRANSFORM="leafer.transform",qo.MOVE="leafer.move",qo.SCALE="leafer.scale",qo.ROTATE="leafer.rotate",qo.SKEW="leafer.skew";const{MOVE:Jo,SCALE:$o,ROTATE:Qo,SKEW:ta}=qo,ea={x:Jo,y:Jo,scaleX:$o,scaleY:$o,rotation:Qo,skewX:ta,skewY:ta},ia={};class sa{set event(t){this.on(t)}on(t,e,i){if(!e){let e;if(d(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let i in t)d(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=na(this,s,!0),h=r(t)?t.split(" "):t,l=n?{listener:e,once:n}:{listener:e};h.forEach(t=>{t&&(o=a[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(l):a[t]=[l],Uo[t]&&Yo.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=na(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],Uo[t]&&Yo.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):d(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=d(t)?t:[t];e.forEach(t=>{t&&(t.listener?t.current.off(t.type,t.listener,t.options):d(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 d(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));c(i)?e=e.bind(i):s=i,this.on(t,e,{once:!0,capture:s})}emit(t,e,i){!e&&ue.has(t)&&(e=ue.get(t,{type:t,target:this,current:this}));const s=na(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 na(t,e,i){if(e){const{__captureMap:e}=t;return e||(i?t.__captureMap={}:ia)}{const{__bubbleMap:e}=t;return e||(i?t.__bubbleMap={}:ia)}}const{on:ra,on_:oa,off:aa,off_:ha,once:la,emit:da,emitEvent:ca,hasEvent:ua,destroy:_a}=sa.prototype,ga={on:ra,on_:oa,off:aa,off_:ha,once:la,emit:da,emitEvent:ca,hasEvent:ua,destroyEventer:_a},pa=Qt.get("setAttr"),fa={__setAttr(t,e,i){if(this.leaferIsCreated){const n=this.__.__getInput(t);if(!i||o(e)||s(e)||(pa.warn(this.innerName,t,e),e=void 0),c(e)||n!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Wo(Wo.LEAFER_CHANGE,this,t,n,e));const i=ea[t];i&&(this.emitEvent(new qo(i,this)),this.emitEvent(new qo(qo.TRANSFORM,this)))}this.emitPropertyEvent(Wo.CHANGE,t,n,e);const i=Fo[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 Wo(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:ma,multiplyParent:ya,translateInner:va,defaultWorld:xa}=Q,{toPoint:wa,tempPoint:ba}=Et,ka={__updateWorldMatrix(){const{parent:t,__layout:e,__world:i,__scrollWorld:s,__:n}=this;ya(this.__local||e,t?t.__scrollWorld||t.__world:xa,i,!!e.affectScaleOrRotation,n),s&&va(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)&&(ma(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)&&(wa(i.around||i.origin,t.boxBounds,ba),va(e,-ba.x,-ba.y,!i.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:Ea,updateAllMatrix:Sa}=oo,{updateBounds:Ba}=vo,{toOuterOf:Ta,copyAndSpread:Ra,copy:Oa}=Vt,{toBounds:Ca}=An,La={__updateWorldBounds(){const{__layout:t,__world:e}=this;Ta(t.renderBounds,e,e),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Yo.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Yo.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(),Ta(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Ta(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Ta(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const i=this.__layout.boxBounds,s=this.__;s.__usePathBox?Ca(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(),Sa(this),Ba(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(Sa(this),Ba(this,this))):Ea(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;Ra(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout,{renderSpread:i}=e;a(i)&&i<=0?Oa(e.renderBounds,e.strokeBounds):Ra(e.renderBounds,e.boxBounds,i)}},Pa={__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),oo.copyCanvasByWorld(this,t,s,this.__nowWorld,i.__blendMode,!0),s.recycle(this.__nowWorld)}else this.__draw(t,e);Qt.showBounds&&Qt.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:Ma}=po,Aa={__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++)Ma(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++)Ma(i[s],e)||i[s].__clip(t,e)}}},Da={},{LEAF:Ia,create:Wa}=w,{stintSet:Fa}=g,{toInnerPoint:za,toOuterPoint:Ya,multiplyParent:Na}=Q,{toOuterOf:Xa}=Vt,{copy:Ha,move:Va}=dt,{moveLocal:Ua,zoomOfLocal:ja,rotateOfLocal:Ga,skewOfLocal:Ka,moveWorld:Za,zoomOfWorld:qa,rotateOfWorld:Ja,skewOfWorld:$a,transform:Qa,transformWorld:th,setTransform:eh,getFlipTransform:ih,getLocalOrigin:sh,getRelativeWorld:nh,drop:rh}=oo;let oh=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 f}get __LayoutProcessor(){return Mo}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=Wa(Ia),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Do.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(Do.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Do.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(Do.MOUNTED)):this.__emitLifeEvent(Do.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 Na(i,t.matrix,e,void 0,i),Xa(this.__layout.renderBounds,e,e),Fa(e,"half",i.half),Fa(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}=tr.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),Da.scaleX=i,Da.scaleY=s,Da}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?nh(this,e):this.worldTransform,n=i?t:{};return Xa(t,s,n),n}worldToLocal(t,e,i,s){this.parent?this.parent.worldToInner(t,e,i,s):e&&Ha(e,t)}localToWorld(t,e,i,s){this.parent?this.parent.innerToWorld(t,e,i,s):e&&Ha(e,t)}worldToInner(t,e,i,s){s&&(s.innerToWorld(t,e,i),t=e||t),za(this.scrollWorldTransform,t,e,i)}innerToWorld(t,e,i,s){Ya(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 Va(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 Va(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){eh(this,t,e,i)}transform(t,e,i){Qa(this,t,e,i)}move(t,e,i){Ua(this,t,e,i)}moveInner(t,e,i){Za(this,t,e,!0,i)}scaleOf(t,e,i,s,n){ja(this,sh(this,t),e,i,s,n)}rotateOf(t,e,i){Ga(this,sh(this,t),e,i)}skewOf(t,e,i,s,n){Ka(this,sh(this,t),e,i,s,n)}transformWorld(t,e,i){th(this,t,e,i)}moveWorld(t,e,i){Za(this,t,e,!1,i)}scaleOfWorld(t,e,i,s,n){qa(this,t,e,i,s,n)}rotateOfWorld(t,e){Ja(this,t,e)}skewOfWorld(t,e,i,s,n){$a(this,t,e,i,s,n)}flip(t,e){Qa(this,ih(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 oe.need("path")}getMotionPoint(t){return oe.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){rh(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):zr(this.prototype,t,e)}static addAttr(t,e,i,s){i||(i=mr),i(e,s)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Do(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Do.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}};oh=pe([jr(fa),jr(ka),jr(La),jr(ga),jr(Pa)],oh);const{setListWithFn:ah}=Vt,{sort:hh}=vo,{localBoxBounds:lh,localStrokeBounds:dh,localRenderBounds:ch,maskLocalBoxBounds:uh,maskLocalStrokeBounds:_h,maskLocalRenderBounds:gh}=po,ph=new Qt("Branch");let fh=class extends oh{__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){ah(e||this.__layout.boxBounds,this.children,this.__hasMask?uh:lh)}__updateStrokeBounds(t){ah(t||this.__layout.strokeBounds,this.children,this.__hasMask?_h:dh)}__updateRenderBounds(t){ah(t||this.__layout.renderBounds,this.children,this.__hasMask?gh:ch)}__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(hh),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return ph.warn("add self or destroyed");const i=s(e);if(!t.__){if(d(t))return t.forEach(t=>{this.add(t,e),i||e++});t=le.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(Do.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Do.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(Do.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Do.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const i=new Do(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}};fh=pe([jr(Aa)],fh);class mh{get length(){return this.list.length}constructor(t){this.reset(),t&&(d(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 mh;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 yh{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(d(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}}const vh="1.11.2";class xh extends Ce{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=v.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}}Un(OffscreenCanvasRenderingContext2D.prototype),Un(Path2D.prototype);const{mineType:wh}=jn;function bh(t,e){v.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:wh(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:wh(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",v.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()})},v.canvas=ae.canvas(),v.conicGradientSupport=!!v.canvas.context.createConicGradient}Object.assign(ae,{canvas:(t,e)=>new xh(t,e),image:t=>new nr(t)}),v.name="web",v.isWorker=!0,v.backgrounder=!0,v.requestRender=function(t){requestAnimationFrame(t)},rr(v,"devicePixelRatio",{get:()=>1});const{userAgent:kh}=navigator;kh.indexOf("Firefox")>-1?(v.conicGradientRotate90=!0,v.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(v.fullImageShadow=!0),kh.indexOf("Windows")>-1?(v.os="Windows",v.intWheelDeltaY=!0):kh.indexOf("Mac")>-1?v.os="Mac":kh.indexOf("Linux")>-1&&(v.os="Linux");class Eh{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new mh;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 mh,this.target=t,e&&(this.config=g.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(Zo.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===Do.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 Go(Go.DATA,{updatedList:this.updatedList})),this.__updatedList=new mh,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[Wo.CHANGE,this.__onAttrChange,this],[[Do.ADD,Do.REMOVE],this.__onChildEvent,this],[Go.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:Sh,updateBounds:Bh,updateChange:Th}=oo,{pushAllChildBranch:Rh,pushAllParent:Oh}=vo;const{worldBounds:Ch}=po;class Lh{constructor(t){this.updatedBounds=new Kt,this.beforeBounds=new Kt,this.afterBounds=new Kt,d(t)&&(t=new mh(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Ch)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,Ch),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:Ph,updateAllChange:Mh}=oo,Ah=Qt.get("Layouter");class Dh{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new yh,this.target=t,e&&(this.config=g.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(Ko.START),this.layoutOnce(),t.emitEvent(new Ko(Ko.END,this.layoutedBlocks,this.times))}catch(t){Ah.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Ah.warn("layouting"):this.times>3?Ah.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(Go.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=se.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:o}=Ko,a=this.getBlocks(s);a.forEach(t=>t.setBefore()),i.emitEvent(new Ko(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?(Sh(t,!0),e.add(t),t.isBranch&&Rh(t,e),Oh(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Oh(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Bh(s[t])}Bh(i)}})}(this.__levelList),function(t){t.list.forEach(Th)}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach(t=>t.setAfter()),i.emitEvent(new Ko(r,a,this.times)),i.emitEvent(new Ko(o,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,se.end(e)}fullLayout(){const t=se.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=Ko,r=this.getBlocks(new mh(e));e.emitEvent(new Ko(i,r,this.times)),Dh.fullLayout(e),r.forEach(t=>{t.setAfter()}),e.emitEvent(new Ko(s,r,this.times)),e.emitEvent(new Ko(n,r,this.times)),this.addBlocks(r),se.end(t)}static fullLayout(t){Ph(t,!0),t.isBranch?vo.updateBounds(t):oo.updateBounds(t),Mh(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new Lh([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new Lh(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_([[Ko.REQUEST,this.layout,this],[Ko.AGAIN,this.layoutAgain,this],[Go.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Ih=Qt.get("Renderer");class Wh{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=g.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(Ko.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(Zo.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(Zo.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(Zo.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new Kt,Ih.log(e.innerName,"---\x3e");try{this.emitRender(Zo.START),this.renderOnce(t),this.emitRender(Zo.END,this.totalBounds),tr.clearRecycled()}catch(t){this.rendering=!1,Ih.error(t)}Ih.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Ih.warn("rendering");if(this.times>3)return Ih.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new Kt,this.renderOptions={},t)this.emitRender(Zo.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(Zo.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(Zo.RENDER,this.renderBounds,this.renderOptions),this.emitRender(Zo.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=se.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new Kt(s);i.save(),s.spread(Wh.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),se.end(e)}fullRender(){const t=se.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),se.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),Qt.showRepaint&&Qt.drawRepaint(i,t),v.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 Kt;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 v.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()};v.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new Kt(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 Kt(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||Ih.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 Zo(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[Zo.REQUEST,this.update,this],[Ko.END,this.__onLayoutEnd,this],[Zo.AGAIN,this.renderAgain,this],[jo.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}Wh.clipSpread=10;const{hitRadiusPoint:Fh}=Vt;class zh{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 mh(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 mh;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||oo.worldHittable(e))&&(this.hitChild(e,o),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&oo.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=>oo.worldHittable(t))}getPath(t){const e=new mh,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 mh;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 mh,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||Fh(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 Yh{constructor(t,e){this.config={},e&&(this.config=g.default(e,this.config)),this.picker=new zh(this.target=t,this),this.finder=ae.finder&&ae.finder()}getByPoint(t,e,i){const{target:s,picker:n}=this;return v.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):oe.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Nh(t){return hr(t,t=>({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}}))}function Xh(t){return hr(t,t=>({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}}))}function Hh(){return(t,e)=>{const i="_"+e;rr(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}})}}function Vh(t){return(e,i)=>{rr(e,i,ar(i,t))}}Object.assign(ae,{watcher:(t,e)=>new Eh(t,e),layouter:(t,e)=>new Dh(t,e),renderer:(t,e,i)=>new Wh(t,e,i),selector:(t,e)=>new Yh(t,e)}),v.layout=Dh.fullLayout,v.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new mh,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const Uh={},jh={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}},Gh={number:(t,e)=>c(t)?"percent"===t.type?t.value*e:t.value:t},Kh={},Zh={},qh={},Jh={},$h={},Qh={apply(){oe.need("filter")}},tl={},el={setStyleName:()=>oe.need("state"),set:()=>oe.need("state")},il={list:{},register(t,e){il.list[t]=e},get:t=>il.list[t]},{parse:sl,objectToCanvasData:nl}=ts,{stintSet:rl}=g,{hasTransparent:ol}=jh,al={originPaint:{}},hl=Qt.get("UIData");class ll extends f{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,hl.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,hl.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),r(t)||!t?(rl(this,"__isTransparentFill",ol(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t):c(t)&&this.__setPaint("fill",t)}setStroke(t){r(t)||!t?(rl(this,"__isTransparentStroke",ol(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t):c(t)&&this.__setPaint("stroke",t)}setPath(t){const e=r(t);e||t&&c(t[0])?(this.__setInput("path",t),this._path=e?sl(t):nl(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){dl(this,"shadow",t)}setInnerShadow(t){dl(this,"innerShadow",t)}setFilter(t){dl(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),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(),d(e)&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=al)):(this.__isStrokes=!0,this._stroke||(this._stroke=al))}__removePaint(t,e){e&&this.__removeInput(t),qh.recycleImage(t,this),"fill"===t?(rl(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(rl(this,"__isAlphaPixelStroke",void 0),rl(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function dl(t,e,i){t.__setInput(e,i),d(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 cl extends ll{}class ul extends cl{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 _l extends cl{__getInputData(t,e){const i=super.__getInputData(t,e);return Oe.forEach(t=>delete i[t]),i}}class gl extends ul{}class pl extends ll{get __usePathBox(){return this.points||this.__pathInputed}}class fl extends ll{get __boxStroke(){return!this.__pathInputed}}class ml extends ll{get __boxStroke(){return!this.__pathInputed}}class yl extends pl{}class vl extends ll{}class xl extends ll{get __pathInputed(){return 2}}class wl extends cl{}const bl={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class kl extends ll{get __useNaturalRatio(){return!1}setFontWeight(t){r(t)?(this.__setInput("fontWeight",t),t=bl[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=le.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 El extends fl{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 Sl extends fl{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:Bl,add:Tl}=R,Rl={__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=Bl(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=$h.getShadowRenderSpread(this,e)),s&&(t=Bl(t,s)),r&&(t=Tl(t,Qh.getSpread(r))),o&&(t=Tl(t,o)),a&&(t=Tl(t,a));let l=t;return i&&(l=Bl(l,$h.getInnerShadowSpread(this,i))),n&&(l=Bl(l,n)),this.__layout.renderShapeSpread=l,h?Bl(h.__updateRenderSpread(),t):t}},{stintSet:Ol}=g,Cl={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);Ol(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),Ol(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,n=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Ol(t,"__isFastShadow",e&&!n&&e.length<2&&!e[0].spread&&!$h.isTransformShadow(e[0])&&i&&!t.__isTransparentFill&&!(d(i)&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!n)}t.__checkSingle(),Ol(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){Ll(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&&$h.shadow(this,t,h),a&&(s.__isStrokes?Zh.strokes(r,this,t,e):Zh.stroke(r,this,t,e)),n&&(s.__isFills?Zh.fills(n,this,t,e):Zh.fill(n,this,t,e)),o&&this.__drawAfterFill(t,e),d&&$h.innerShadow(this,t,h),r&&!a&&(s.__isStrokes?Zh.strokes(r,this,t,e):Zh.stroke(r,this,t,e)),c&&Qh.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,e):Zh.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,jh.string(e.color))}n&&(s.__isFills?Zh.fills(n,this,t,e):Zh.fill(n,this,t,e)),h&&t.restore(),o&&this.__drawAfterFill(t,e),r&&!a&&(s.__isStrokes?Zh.strokes(r,this,t,e):Zh.stroke(r,this,t,e))}}else s.__pathInputed?Ll(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,e):Zh.fill("#000000",this,t,e)),i.__isCanvas&&this.__drawAfterFill(t,e),n&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?Zh.strokes(n,this,t,e):Zh.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 Ll(t,e,i){const{fill:s,stroke:n,__drawAfterFill:r,__fillAfterStroke:o}=t.__;t.__drawRenderPath(e),o&&Zh.stroke(n,t,e,i),s&&Zh.fill(s,t,e,i),r&&t.__drawAfterFill(e,i),n&&!o&&Zh.stroke(n,t,e,i)}const Pl={__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 Ml;let Al=Ml=class extends oh{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){F.assignScale(this,t)}get scale(){return this.__.scale}get isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return 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 oe.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return oe.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?ts.toCanvasData(i,!0):i}getPathString(t,e,i){return ts.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||tl.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?Nn.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&Kh.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?en.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){Zh.fill(this.__.placeholderColor,this,e,i)}animate(t,e,i,s){return this.set(t),oe.need("animate")}killAnimate(t,e){}export(t,e){return oe.need("export")}syncExport(t,e){return oe.need("export")}clone(t){const e=g.clone(this.toJSON());return t&&Object.assign(e,t),Ml.one(e)}static one(t,e,i,s,n){return le.get(t.tag||this.prototype.__tag,t,e,i,s,n)}static registerUI(){Gr()(this)}static registerData(t){Wr(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};pe([Wr(ll)],Al.prototype,"__",void 0),pe([Hh()],Al.prototype,"zoomLayer",void 0),pe([cr("")],Al.prototype,"id",void 0),pe([cr("")],Al.prototype,"name",void 0),pe([cr("")],Al.prototype,"className",void 0),pe([Br("pass-through")],Al.prototype,"blendMode",void 0),pe([Rr(1)],Al.prototype,"opacity",void 0),pe([Or(!0)],Al.prototype,"visible",void 0),pe([Br(!1)],Al.prototype,"locked",void 0),pe([Tr(!1)],Al.prototype,"dim",void 0),pe([Tr(!1)],Al.prototype,"dimskip",void 0),pe([Pr(0)],Al.prototype,"zIndex",void 0),pe([Mr(!1)],Al.prototype,"mask",void 0),pe([Ar(!1)],Al.prototype,"eraser",void 0),pe([ur(0,!0)],Al.prototype,"x",void 0),pe([ur(0,!0)],Al.prototype,"y",void 0),pe([mr(100,!0)],Al.prototype,"width",void 0),pe([mr(100,!0)],Al.prototype,"height",void 0),pe([pr(1,!0)],Al.prototype,"scaleX",void 0),pe([pr(1,!0)],Al.prototype,"scaleY",void 0),pe([fr(0,!0)],Al.prototype,"rotation",void 0),pe([fr(0,!0)],Al.prototype,"skewX",void 0),pe([fr(0,!0)],Al.prototype,"skewY",void 0),pe([ur(0,!0)],Al.prototype,"offsetX",void 0),pe([ur(0,!0)],Al.prototype,"offsetY",void 0),pe([_r(0,!0)],Al.prototype,"scrollX",void 0),pe([_r(0,!0)],Al.prototype,"scrollY",void 0),pe([gr()],Al.prototype,"origin",void 0),pe([gr()],Al.prototype,"around",void 0),pe([cr(!1)],Al.prototype,"lazy",void 0),pe([yr(1)],Al.prototype,"pixelRatio",void 0),pe([Sr(0)],Al.prototype,"renderSpread",void 0),pe([xr()],Al.prototype,"path",void 0),pe([wr()],Al.prototype,"windingRule",void 0),pe([wr(!0)],Al.prototype,"closed",void 0),pe([mr(0)],Al.prototype,"padding",void 0),pe([mr(!1)],Al.prototype,"lockRatio",void 0),pe([mr()],Al.prototype,"widthRange",void 0),pe([mr()],Al.prototype,"heightRange",void 0),pe([cr(!1)],Al.prototype,"draggable",void 0),pe([cr()],Al.prototype,"dragBounds",void 0),pe([cr("auto")],Al.prototype,"dragBoundsType",void 0),pe([cr(!1)],Al.prototype,"editable",void 0),pe([Dr(!0)],Al.prototype,"hittable",void 0),pe([Dr("path")],Al.prototype,"hitFill",void 0),pe([Er("path")],Al.prototype,"hitStroke",void 0),pe([Dr(!1)],Al.prototype,"hitBox",void 0),pe([Dr(!0)],Al.prototype,"hitChildren",void 0),pe([Dr(!0)],Al.prototype,"hitSelf",void 0),pe([Dr()],Al.prototype,"hitRadius",void 0),pe([Ir("")],Al.prototype,"cursor",void 0),pe([Br()],Al.prototype,"fill",void 0),pe([Er(void 0,!0)],Al.prototype,"stroke",void 0),pe([Er("inside")],Al.prototype,"strokeAlign",void 0),pe([Er(1,!0)],Al.prototype,"strokeWidth",void 0),pe([Er(!1)],Al.prototype,"strokeWidthFixed",void 0),pe([Er("none")],Al.prototype,"strokeCap",void 0),pe([Er("miter")],Al.prototype,"strokeJoin",void 0),pe([Er()],Al.prototype,"dashPattern",void 0),pe([Er(0)],Al.prototype,"dashOffset",void 0),pe([Er(10)],Al.prototype,"miterLimit",void 0),pe([wr(0)],Al.prototype,"cornerRadius",void 0),pe([wr()],Al.prototype,"cornerSmoothing",void 0),pe([Nh()],Al.prototype,"shadow",void 0),pe([Nh()],Al.prototype,"innerShadow",void 0),pe([Nh()],Al.prototype,"blur",void 0),pe([Nh()],Al.prototype,"backgroundBlur",void 0),pe([Nh()],Al.prototype,"grayscale",void 0),pe([Nh()],Al.prototype,"filter",void 0),pe([Br()],Al.prototype,"placeholderColor",void 0),pe([cr(100)],Al.prototype,"placeholderDelay",void 0),pe([cr({})],Al.prototype,"data",void 0),pe([Hr(oh.prototype.reset)],Al.prototype,"reset",null),Al=Ml=pe([jr(Rl),jr(Cl),Vr()],Al);let Dl=class extends Al{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(){}};var Il;pe([Wr(cl)],Dl.prototype,"__",void 0),pe([mr(0)],Dl.prototype,"width",void 0),pe([mr(0)],Dl.prototype,"height",void 0),Dl=pe([jr(fh),Gr()],Dl);const Wl=Qt.get("Leafer");let Fl=Il=class extends Dl{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&$n.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),Il.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,g.assign(s,t));const n=this.canvas=ae.canvas(s);this.__controllers.push(this.renderer=ae.renderer(this,n,s),this.watcher=ae.watcher(this,s),this.layouter=ae.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(),this.view=n.view,e||(this.selector=ae.selector(this),this.interaction=ae.interaction(this,n,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=ae.hitCanvasManager()),this.canvasManager=new ge,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))),ko.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(qo.RESTART):this.emitLeafer(qo.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(qo.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=g.copyAttrs({},t,Oe);Object.keys(e).forEach(t=>this[t]=e[t])}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new Kt(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=g.copyAttrs({},this.canvas,Oe);e.resize(t),this.updateLazyBounds(),this.__onResize(new jo(t,i))}__onResize(t){this.emitEvent(t),g.copyAttrs(this.__,t,Oe),setTimeout(()=>{this.canvasManager&&this.canvasManager.clearRecycled()},0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(){const{config:t,parentApp:e}=this;e||(t.width&&t.height||(this.autoLayout=new qt(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(Oe.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(qo.UPDATE_MODE,{mode:e})),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Oe.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const{config:i,canvas:s}=this,n=g.copyAttrs({},s,Oe);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(qo.BEFORE_READY),this.emitLeafer(qo.READY),this.emitLeafer(qo.AFTER_READY),ko.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(qo.VIEW_READY),ko.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){ko.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(qo.VIEW_COMPLETED),ko.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 oe.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 qo(t,this))}__listenEvents(){const t=se.start("FirstCreate "+this.innerName);this.once([[qo.START,()=>se.end(t)],[Ko.START,this.updateLazyBounds,this],[Zo.START,this.__onCreated,this],[Zo.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Go.DATA,this.__onWatchData,this],[Ko.END,this.__onLayoutEnd,this],[Zo.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){Il.list.remove(this);try{this.stop(),this.emitLeafer(qo.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(()=>{tr.clearRecycled()},100)}catch(t){Wl.error(t)}}};t?e():setTimeout(e)}};Fl.list=new mh,pe([Wr(_l)],Fl.prototype,"__",void 0),pe([mr()],Fl.prototype,"pixelRatio",void 0),pe([cr("normal")],Fl.prototype,"mode",void 0),Fl=Il=pe([Gr()],Fl);let zl=class extends Al{get __tag(){return"Rect"}};pe([Wr(fl)],zl.prototype,"__",void 0),zl=pe([jr(Pl),Vr(),Gr()],zl);const{add:Yl,includes:Nl,scroll:Xl}=Vt,Hl=zl.prototype,Vl=Dl.prototype;let Ul=class extends Dl{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&&o.includes("scroll"))&&(Yl(a,r),Xl(a,i)),this.__updateRectRenderBounds(),t=!Nl(r,a),t&&"show"===o&&Yl(n,a)}else this.__updateRectRenderBounds();g.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))}};pe([Wr(ul)],Ul.prototype,"__",void 0),pe([mr(100)],Ul.prototype,"width",void 0),pe([mr(100)],Ul.prototype,"height",void 0),pe([cr(!1)],Ul.prototype,"resizeChildren",void 0),pe([Sr("show")],Ul.prototype,"overflow",void 0),pe([Hr(Hl.__updateStrokeSpread)],Ul.prototype,"__updateStrokeSpread",null),pe([Hr(Hl.__updateRenderSpread)],Ul.prototype,"__updateRectRenderSpread",null),pe([Hr(Hl.__updateBoxBounds)],Ul.prototype,"__updateRectBoxBounds",null),pe([Hr(Hl.__updateStrokeBounds)],Ul.prototype,"__updateStrokeBounds",null),pe([Hr(Hl.__updateRenderBounds)],Ul.prototype,"__updateRectRenderBounds",null),pe([Hr(Hl.__updateChange)],Ul.prototype,"__updateRectChange",null),pe([Hr(Hl.__render)],Ul.prototype,"__renderRect",null),pe([Hr(Vl.__render)],Ul.prototype,"__renderGroup",null),Ul=pe([Vr(),Gr()],Ul);let jl=class extends Ul{get __tag(){return"Frame"}get isFrame(){return!0}};pe([Wr(gl)],jl.prototype,"__",void 0),pe([Br("#FFFFFF")],jl.prototype,"fill",void 0),pe([Sr("hide")],jl.prototype,"overflow",void 0),jl=pe([Gr()],jl);const{moveTo:Gl,closePath:Kl,ellipse:Zl}=ks;let ql=class extends Al{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&&Zl(a,r,o,r*i,o*i,0,s,n,!1),Zl(a,r,o,r,o,0,n,s,!0),i<1&&Kl(a)):(i<1&&(Zl(a,r,o,r*i,o*i),Gl(a,t,o)),Zl(a,r,o,r,o,0,360,0,!0)),v.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||n?(Gl(a,r,o),Zl(a,r,o,r,o,0,s,n,!1),Kl(a)):Zl(a,r,o,r,o)}};pe([Wr(ml)],ql.prototype,"__",void 0),pe([wr(0)],ql.prototype,"innerRadius",void 0),pe([wr(0)],ql.prototype,"startAngle",void 0),pe([wr(0)],ql.prototype,"endAngle",void 0),ql=pe([Gr()],ql);const{sin:Jl,cos:$l,PI:Ql}=Math,{moveTo:td,lineTo:ed,closePath:id,drawPoints:sd}=ks;let nd=class extends Al{get __tag(){return"Polygon"}__updatePath(){const t=this.__,e=t.path=[];if(t.points)sd(e,t.points,t.curve,!0);else{const{width:i,height:s,sides:n}=t,r=i/2,o=s/2;td(e,r,0);for(let t=1;t<n;t++)ed(e,r+r*Jl(2*t*Ql/n),o-o*$l(2*t*Ql/n));id(e)}}};pe([Wr(yl)],nd.prototype,"__",void 0),pe([wr(3)],nd.prototype,"sides",void 0),pe([wr()],nd.prototype,"points",void 0),pe([wr(0)],nd.prototype,"curve",void 0),nd=pe([Vr(),Gr()],nd);const{sin:rd,cos:od,PI:ad}=Math,{moveTo:hd,lineTo:ld,closePath:dd}=ks;let cd=class extends Al{get __tag(){return"Star"}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,n=t/2,r=e/2,o=this.__.path=[];hd(o,n,0);for(let t=1;t<2*i;t++)ld(o,n+(t%2==0?n:n*s)*rd(t*ad/i),r-(t%2==0?r:r*s)*od(t*ad/i));dd(o)}};pe([Wr(vl)],cd.prototype,"__",void 0),pe([wr(5)],cd.prototype,"corners",void 0),pe([wr(.382)],cd.prototype,"innerRadius",void 0),cd=pe([Gr()],cd);const{moveTo:ud,lineTo:_d,drawPoints:gd}=ks,{rotate:pd,getAngle:fd,getDistance:md,defaultPoint:yd}=dt;let vd=class extends Al{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i={x:0,y:0};return t&&(i.x=t),e&&pd(i,e),i}set toPoint(t){this.width=md(yd,t),this.rotation=fd(yd,t),this.height&&(this.height=0)}__updatePath(){const t=this.__,e=t.path=[];t.points?gd(e,t.points,t.curve,t.closed):(ud(e,0,0),_d(e,this.width,0))}};pe([Wr(pl)],vd.prototype,"__",void 0),pe([br("center")],vd.prototype,"strokeAlign",void 0),pe([mr(0)],vd.prototype,"height",void 0),pe([wr()],vd.prototype,"points",void 0),pe([wr(0)],vd.prototype,"curve",void 0),pe([wr(!1)],vd.prototype,"closed",void 0),vd=pe([Gr()],vd);let xd=class extends zl{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return d(t)&&t[0].image}};pe([Wr(El)],xd.prototype,"__",void 0),pe([mr("")],xd.prototype,"url",void 0),xd=pe([Gr()],xd);const wd=xd;let bd=class extends zl{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=ae.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new nr({url:t}).load(t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new zo(zo.LOADED,{image:t}))})}draw(t,e,i,s){const n=new mt(t.worldTransform).invert(),r=new mt;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()}};pe([Wr(Sl)],bd.prototype,"__",void 0),pe([Xh(100)],bd.prototype,"width",void 0),pe([Xh(100)],bd.prototype,"height",void 0),pe([Xh(1)],bd.prototype,"pixelRatio",void 0),pe([Xh(!0)],bd.prototype,"smooth",void 0),pe([cr(!1)],bd.prototype,"safeResize",void 0),pe([Xh()],bd.prototype,"contextSettings",void 0),bd=pe([Gr()],bd);const{copyAndSpread:kd,includes:Ed,spread:Sd,setList:Bd}=Vt,{stintSet:Td}=g;let Rd=class extends Al{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=Gh.number(e,n),t.__letterSpacing=Gh.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"}`,Td(t,"__padding",l&&F.fourNumber(l)),Td(t,"__clipText","show"!==h&&!t.__autoSize),Td(t,"__isCharMode",d||c||t.__letterSpacing||"none"!==a),t.__textDrawData=Uh.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),g.stintSet(this,"isOverflow",!Ed(h,a)),this.isOverflow?(Bd(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;kd(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()}};pe([Wr(kl)],Rd.prototype,"__",void 0),pe([mr(0)],Rd.prototype,"width",void 0),pe([mr(0)],Rd.prototype,"height",void 0),pe([Br()],Rd.prototype,"boxStyle",void 0),pe([cr(!1)],Rd.prototype,"resizeFontSize",void 0),pe([Br("#000000")],Rd.prototype,"fill",void 0),pe([br("outside")],Rd.prototype,"strokeAlign",void 0),pe([Dr("all")],Rd.prototype,"hitFill",void 0),pe([mr("")],Rd.prototype,"text",void 0),pe([mr("")],Rd.prototype,"placeholder",void 0),pe([mr("caption")],Rd.prototype,"fontFamily",void 0),pe([mr(12)],Rd.prototype,"fontSize",void 0),pe([mr("normal")],Rd.prototype,"fontWeight",void 0),pe([mr(!1)],Rd.prototype,"italic",void 0),pe([mr("none")],Rd.prototype,"textCase",void 0),pe([mr("none")],Rd.prototype,"textDecoration",void 0),pe([mr(0)],Rd.prototype,"letterSpacing",void 0),pe([mr({type:"percent",value:1.5})],Rd.prototype,"lineHeight",void 0),pe([mr(0)],Rd.prototype,"paraIndent",void 0),pe([mr(0)],Rd.prototype,"paraSpacing",void 0),pe([mr("x")],Rd.prototype,"writingMode",void 0),pe([mr("left")],Rd.prototype,"textAlign",void 0),pe([mr("top")],Rd.prototype,"verticalAlign",void 0),pe([mr(!0)],Rd.prototype,"autoSizeAlign",void 0),pe([mr("normal")],Rd.prototype,"textWrap",void 0),pe([mr("show")],Rd.prototype,"textOverflow",void 0),pe([Br(!1)],Rd.prototype,"textEditing",void 0),Rd=pe([Gr()],Rd);let Od=class extends Al{get __tag(){return"Path"}};pe([Wr(xl)],Od.prototype,"__",void 0),pe([br("center")],Od.prototype,"strokeAlign",void 0),Od=pe([Gr()],Od);let Cd=class extends Dl{get __tag(){return"Pen"}setStyle(t){const e=this.pathElement=new Od(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,n,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")}};pe([Wr(wl)],Cd.prototype,"__",void 0),pe([(t,e)=>{rr(t,e,{get(){return this.__path}})}],Cd.prototype,"path",void 0),Cd=pe([jr(Ys,["set","path","paint"]),Gr()],Cd);let Ld=class extends Fl{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&&ae.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(t){const e=new Fl(t);return this.add(e),e}add(t,e){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout(()=>this.add(t,e),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t,e),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&&g.assign(e,t),this.autoLayout&&g.copyAttrs(e,this,Oe),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once([[Ko.END,this.__onReady,this],[Zo.START,this.__onCreated,this],[Zo.END,this.__onViewReady,this]]),this.realCanvas&&this.__eventIds.push(t.on_(Zo.END,this.__onChildRenderEnd,this))}};Ld=pe([Gr()],Ld);const Pd={},Md={isHoldSpaceKey:()=>Md.isHold("Space"),isHold:t=>Pd[t],isHoldKeys:(t,e)=>e?t(e):void 0,setDownCode(t){Pd[t]||(Pd[t]=!0)},setUpCode(t){Pd[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 Dd extends Ao{get spaceKey(){return Md.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 Md.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){ue.changeName(t,e)}}const{min:Id,max:Wd,abs:Fd}=Math,{float:zd,sign:Yd}=F,{minX:Nd,maxX:Xd,minY:Hd,maxY:Vd}=Vt,Ud=new Kt,jd=new Kt,Gd={limitMove(t,e){const{dragBounds:i,dragBoundsType:s}=t;i&&Kd.getValidMove(t.__localBoxBounds,Kd.getDragBounds(t),s,e,!0),Kd.axisMove(t,e)},limitScaleOf(t,e,i,s){const{dragBounds:n,dragBoundsType:r}=t;n&&Kd.getValidScaleOf(t.__localBoxBounds,Kd.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)),Kd.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),Kd.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=zd(s.x),s.y=zd(s.y),s},getValidScaleOf(t,e,i,s,n,r,a){a||(n=Object.assign({},n)),jd.set(e),Ud.set(t).scaleOf(s,n.x,n.y);const h=(s.x-t.x)/t.width,l=1-h,d=(s.y-t.y)/t.height,c=1-d;let u,_,g,p,f=1,m=1;return Kd.isInnerMode(t,e,i,"width")?(n.x<0&&Ud.scaleOf(s,f=1/n.x,1),g=zd(Ud.minX-jd.minX),p=zd(jd.maxX-Ud.maxX),u=h&&g>0?1+g/(h*Ud.width):1,_=l&&p>0?1+p/(l*Ud.width):1,f*=Wd(u,_)):(n.x<0&&((zd(Nd(t)-Nd(e))<=0||zd(Xd(e)-Xd(t))<=0)&&Ud.scaleOf(s,f=1/n.x,1),Ud.unsign()),g=zd(jd.minX-Ud.minX),p=zd(Ud.maxX-jd.maxX),u=h&&g>0?1-g/(h*Ud.width):1,_=l&&p>0?1-p/(l*Ud.width):1,f*=Id(u,_)),Kd.isInnerMode(t,e,i,"height")?(n.y<0&&Ud.scaleOf(s,1,m=1/n.y),g=zd(Ud.minY-jd.minY),p=zd(jd.maxY-Ud.maxY),u=d&&g>0?1+g/(d*Ud.height):1,_=c&&p>0?1+p/(c*Ud.height):1,m*=Wd(u,_),r&&(u=Wd(Fd(f),Fd(m)),f=Yd(f)*u,m=Yd(m)*u)):(n.y<0&&((zd(Hd(t)-Hd(e))<=0||zd(Vd(e)-Vd(t))<=0)&&Ud.scaleOf(s,1,m=1/n.y),Ud.unsign()),g=zd(jd.minY-Ud.minY),p=zd(Ud.maxY-jd.maxY),u=d&&g>0?1-g/(d*Ud.height):1,_=c&&p>0?1-p/(c*Ud.height):1,m*=Id(u,_)),n.x*=o(f)?f:1,n.y*=o(m)?m:1,n}},Kd=Gd;let Zd=class extends Dd{};Zd.POINTER="pointer",Zd.BEFORE_DOWN="pointer.before_down",Zd.BEFORE_MOVE="pointer.before_move",Zd.BEFORE_UP="pointer.before_up",Zd.DOWN="pointer.down",Zd.MOVE="pointer.move",Zd.UP="pointer.up",Zd.OVER="pointer.over",Zd.OUT="pointer.out",Zd.ENTER="pointer.enter",Zd.LEAVE="pointer.leave",Zd.TAP="tap",Zd.DOUBLE_TAP="double_tap",Zd.CLICK="click",Zd.DOUBLE_CLICK="double_click",Zd.LONG_PRESS="long_press",Zd.LONG_TAP="long_tap",Zd.MENU="pointer.menu",Zd.MENU_TAP="pointer.menu_tap",Zd=pe([Kr()],Zd);const qd=Zd,Jd={};let $d=class extends Zd{static setList(t){this.list=t instanceof mh?t:new mh(t)}static setData(t){this.data=t}static getValidMove(t,e,i,s=!0){const n=t.getLocalPoint(i,null,!0);return dt.move(n,e.x-t.x,e.y-t.y),s&&this.limitMove(t,n),Gd.axisMove(t,n),n}static limitMove(t,e){Gd.limitMove(t,e)}getPageMove(t){return this.assignMove(t),this.current.getPagePoint(Jd,null,!0)}getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Jd,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Jd,null,!0)}getPageTotal(){return this.getPageMove(!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}getPageBounds(){const t=this.getPageTotal(),e=this.getPagePoint(),i={};return Vt.set(i,e.x-t.x,e.y-t.y,t.x,t.y),Vt.unsign(i),i}assignMove(t){Jd.x=t?this.totalX:this.moveX,Jd.y=t?this.totalY:this.moveY}};$d.BEFORE_DRAG="drag.before_drag",$d.START="drag.start",$d.DRAG="drag",$d.END="drag.end",$d.OVER="drag.over",$d.OUT="drag.out",$d.ENTER="drag.enter",$d.LEAVE="drag.leave",$d=pe([Kr()],$d);const Qd=$d;let tc=class extends Zd{static setList(t){$d.setList(t)}static setData(t){$d.setData(t)}};tc.DROP="drop",tc=pe([Kr()],tc);let ec=class extends $d{};ec.BEFORE_MOVE="move.before_move",ec.START="move.start",ec.MOVE="move",ec.END="move.end",ec=pe([Kr()],ec);let ic=class extends Dd{};ic=pe([Kr()],ic);const sc=ic;let nc=class extends Zd{};nc.BEFORE_ROTATE="rotate.before_rotate",nc.START="rotate.start",nc.ROTATE="rotate",nc.END="rotate.end",nc=pe([Kr()],nc);let rc=class extends $d{};rc.SWIPE="swipe",rc.LEFT="swipe.left",rc.RIGHT="swipe.right",rc.UP="swipe.up",rc.DOWN="swipe.down",rc=pe([Kr()],rc);let oc=class extends Zd{};oc.BEFORE_ZOOM="zoom.before_zoom",oc.START="zoom.start",oc.ZOOM="zoom",oc.END="zoom.end",oc=pe([Kr()],oc);let ac=class extends Dd{};ac.BEFORE_DOWN="key.before_down",ac.BEFORE_UP="key.before_up",ac.DOWN="key.down",ac.HOLD="key.hold",ac.UP="key.up",ac=pe([Kr()],ac);const hc={getDragEventData:(t,e,i)=>Object.assign(Object.assign({},i),{x:i.x,y:i.y,moveX:i.x-e.x,moveY:i.y-e.y,totalX:i.x-t.x,totalY:i.y-t.y}),getDropEventData:(t,e,i)=>Object.assign(Object.assign({},t),{list:e,data:i}),getSwipeDirection:t=>t<-45&&t>-135?rc.UP:t>45&&t<135?rc.DOWN:t<=45&&t>=-45?rc.RIGHT:rc.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:lc.getSwipeDirection(dt.getAngle(t,i))}),getBase(t){const e=1===t.button?4:t.button;return{altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,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 mh,{list:s}=t;for(let t=0,n=s.length;t<n;t++)s[t].hasEvent(e)&&i.add(s[t]);return i},pathCanDrag:t=>t&&t.list.some(t=>oo.draggable(t)||!t.isLeafer&&t.hasEvent($d.DRAG)),pathHasOutside:t=>t&&t.list.some(t=>t.isOutside)},lc=hc,dc=new mh,{getDragEventData:cc,getDropEventData:uc,getSwipeEventData:_c}=hc;class gc{constructor(t){this.interaction=t}setDragData(t){this.animateWait&&this.dragEndReal(),this.downData=this.interaction.downData,this.dragData=cc(t,t,t),this.canAnimate=this.canDragOut=!0}getList(t,e){const{proxy:i}=this.interaction.selector,s=i&&i.list.length,n=$d.list||this.draggableList||dc;return this.dragging&&(s?t?dc:new mh(e?[...i.list,...i.dragHoverExclude]:i.list):n)}checkDrag(t,e){const{interaction:i}=this;if(this.moving&&t.buttons<1)return this.canAnimate=!1,void i.pointerCancel();!this.moving&&e&&(this.moving=i.canMove(this.downData)||i.isHoldRightKey||i.isMobileDragEmpty)&&(this.dragData.moveType="drag",i.emit(ec.START,this.dragData)),this.moving||this.dragStart(t,e),this.drag(t)}dragStart(t,e){this.dragging||(this.dragging=e&&Ad.left(t),this.dragging&&(this.interaction.emit($d.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],oo.draggable(e)){this.draggableList=new mh(e);break}}drag(t){const{interaction:e,dragData:i,downData:s}=this,{path:n,throughPath:r}=s;this.dragData=cc(s,i,t),r&&(this.dragData.throughPath=r),this.dragData.path=n,this.moving?(t.moving=!0,this.dragData.moveType="drag",e.emit(ec.BEFORE_MOVE,this.dragData),e.emit(ec.MOVE,this.dragData)):this.dragging&&(t.dragging=!0,this.dragReal(),e.emit($d.BEFORE_DRAG,this.dragData),e.emit($d.DRAG,this.dragData))}dragReal(t){const{interaction:e}=this,{running:i}=e,s=this.realDraggableList;if(s.length&&i){const{totalX:i,totalY:n}=this.dragData,{dragLimitAnimate:o}=e.p,h=!o||!!t;s.forEach(e=>{if(e.draggable){const s=r(e.draggable),l=$d.getValidMove(e,this.dragStartPoints[e.innerId],{x:i,y:n},h||s);o&&!s&&t?oo.animateMove(e,l,a(o)?o:.3):e.move(l)}})}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:i}=this,{path:s}=t;this.dragOverPath=s,i?s.indexAt(0)!==i.indexAt(0)&&(e.emit($d.OUT,t,i),e.emit($d.OVER,t,s)):e.emit($d.OVER,t,s)}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:i}=this,{path:s}=t;e.emit($d.LEAVE,t,i,s),e.emit($d.ENTER,t,s,i),this.dragEnterPath=s}dragEnd(t,e){(this.dragging||this.moving)&&(this.checkDragEndAnimate(t,e)||this.dragEndReal(t))}dragEndReal(t){const{interaction:e,downData:i,dragData:s}=this;t||(t=s);const{path:n,throughPath:r}=i,o=cc(i,t,t);if(r&&(o.throughPath=r),o.path=n,this.moving&&(this.moving=!1,o.moveType="drag",e.emit(ec.END,o)),this.dragging){const n=this.getList();this.dragging=!1,e.p.dragLimitAnimate&&this.dragReal(!0),e.emit($d.END,o),this.swipe(t,i,s,o),this.drop(t,n,this.dragEnterPath)}this.autoMoveCancel(),this.dragReset(),this.animate(null,"off")}swipe(t,e,i,s){const{interaction:n}=this;if(dt.getDistance(e,t)>n.config.pointer.swipeDistance){const t=_c(e,i,s);this.interaction.emit(t.type,t)}}drop(t,e,i){const s=uc(t,e,$d.data);s.path=i,this.interaction.emit(tc.DROP,s),this.interaction.emit($d.LEAVE,t,i)}dragReset(){$d.list=$d.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 pc=Qt.get("emit");const fc=["move","zoom","rotate","key"];function mc(t,e,i,s,n){if(fc.some(t=>e.startsWith(t))&&t.__.hitChildren&&!vc(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&&yc(r,e,i,s,n)}}function yc(t,e,i,s,n){if(t.destroyed)return!1;if(t.__.hitSelf&&!vc(t,n)&&(el.updateEventStyle&&!s&&el.updateEventStyle(t,e),t.hasEvent(e,s))){i.phase=s?1:t===i.target?2:3;const n=ue.get(e,i);if(t.emitEvent(n,s),n.isStop)return!0}return!1}function vc(t,e){return e&&e.has(t)}const xc={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:wc,pathCanDrag:bc,pathHasOutside:kc}=hc;class Ec{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&&Md.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=g.clone(xc),this.tapCount=0,this.downKeyMap={},this.target=t,this.canvas=e,this.selector=i,this.defaultPath=new mh(t),this.createTransformer(),this.dragger=new gc(this),s&&(this.config=g.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Ad.defaultLeft(t),this.updateDownData(t),this.checkPath(t,e),this.downTime=Date.now(),this.emit(Zd.BEFORE_DOWN,t),this.emit(Zd.DOWN,t),Ad.left(t)&&(this.tapWait(),this.longPressWait(t)),this.waitRightTap=Ad.right(t),this.dragger.setDragData(t),this.isHoldRightKey||this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;const{downData:e}=this;e&&Ad.defaultLeft(t);(this.canvas.bounds.hitPoint(t)||e)&&(this.pointerMoveReal(t),e&&this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(Zd.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=dt.getDistance(this.downData,t)>this.p.dragDistance;e&&(this.pointerWaitCancel(),this.waitRightTap=!1),this.dragger.checkDrag(t,e)}this.dragger.moving||(this.updateHoverData(t),this.checkPath(t),this.emit(Zd.MOVE,t),this.pointerHover(t),this.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t))),this.updateCursor(this.downData||t)}pointerUp(t){const{downData:e}=this;if(t||(t=e),!e)return;Ad.defaultLeft(t),t.multiTouch=e.multiTouch,this.findPath(t);const i=Object.assign(Object.assign({},t),{path:t.path.clone()});t.path.addList(e.path.list),this.checkPath(t),this.downData=null,this.emit(Zd.BEFORE_UP,t),this.emit(Zd.UP,t),this.touchLeave(t),t.isCancel||(this.tap(t),this.menuTap(t)),this.dragger.dragEnd(t),this.updateCursor(i)}pointerCancel(){const t=Object.assign({},this.dragger.dragData);t.isCancel=!0,this.pointerUp(t)}menu(t){this.findPath(t),this.emit(Zd.MENU,t),this.waitMenuTap=!0,!this.downData&&this.waitRightTap&&this.menuTap(t)}menuTap(t){this.waitRightTap&&this.waitMenuTap&&(this.emit(Zd.MENU_TAP,t),this.waitRightTap=this.waitMenuTap=!1)}createTransformer(){}move(t){}zoom(t){}rotate(t){}transformEnd(){}wheel(t){}multiTouch(t,e){}keyDown(t){if(!this.config.keyEvent)return;this.emit(ac.BEFORE_DOWN,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Md.setDownCode(e),this.emit(ac.HOLD,t,this.defaultPath),this.moveMode&&(this.cancelHover(),this.updateCursor())),this.emit(ac.DOWN,t,this.defaultPath)}keyUp(t){if(!this.config.keyEvent)return;this.emit(ac.BEFORE_UP,t,this.defaultPath);const{code:e}=t;this.downKeyMap[e]=!1,Md.setUpCode(e),this.emit(ac.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}pointerHover(t){!this.canHover||this.dragging&&!this.p.dragHover||(t.path||(t.path=new mh),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t))}pointerOverOrOut(t){const{path:e}=t,{overPath:i}=this;this.overPath=e,i?e.indexAt(0)!==i.indexAt(0)&&(this.emit(Zd.OUT,t,i),this.emit(Zd.OVER,t,e)):this.emit(Zd.OVER,t,e)}pointerEnterOrLeave(t){let{path:e}=t;this.downData&&!this.moveMode&&(e=e.clone(),this.downData.path.forEach(t=>e.add(t)));const{enterPath:i}=this;this.enterPath=e,this.emit(Zd.LEAVE,t,i,e),this.emit(Zd.ENTER,t,e,i)}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(Zd.LEAVE,t),this.dragger.dragging&&this.emit(tc.LEAVE,t))}tap(t){const{pointer:e}=this.config,i=this.longTap(t);if(!e.tapMore&&i)return;if(!this.waitTap)return;e.tapMore&&this.emitTap(t);const s=Date.now()-this.downTime,n=[Zd.DOUBLE_TAP,Zd.DOUBLE_CLICK].some(e=>wc(t.path,e));s<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))},e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(t,e){const{hitRadius:i,through:s}=this.p,{bottomList:n,target:r}=this;v.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&&!kc(t.path))&&(t.path=this.defaultPath)}canMove(t){return t&&(this.moveMode||"auto"===this.m.drag&&!bc(t.path))&&!kc(t.path)}isDrag(t){return this.dragger.getList().has(t)}isPress(t){return this.downData&&this.downData.path.has(t)}isHover(t){return this.enterPath&&this.enterPath.has(t)}isFocus(t){return this.focusData===t}cancelHover(){const{hoverData:t}=this;t&&(t.path=this.defaultPath,this.pointerHover(t))}updateDownData(t,e,i){const{downData:s}=this;!t&&s&&(t=s),t&&(this.findPath(t,e),i&&s&&t.path.addList(s.path.list),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getList(!1,!0),name:Zd.MOVE}),this.hoverData=t)}updateCursor(t){if(!this.config.cursor||!this.canHover)return;if(t||(this.updateHoverData(),t=this.downData||this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.canMove(t))return this.setCursor(this.downData?"grabbing":"grab");if(!t)return;let e,i;const{path:s}=t;for(let t=0,n=s.length;t<n&&(e=s.list[t],i=e.syncEventer&&e.syncEventer.cursor||e.cursor,!i);t++);this.setCursor(i)}setCursor(t){this.cursor=t}getLocal(t,e){const i=this.canvas.getClientBounds(e),s={x:t.clientX-i.x,y:t.clientY-i.y},{bounds:n}=this.canvas;return s.x*=n.width/i.width,s.y*=n.height/i.height,this.p.snap&&dt.round(s),s}emitTap(t){this.emit(Zd.TAP,t),this.emit(Zd.CLICK,t)}emitDoubleTap(t){this.emit(Zd.DOUBLE_TAP,t),this.emit(Zd.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){this.waitTap&&(clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0)}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout(()=>{this.longPressed=!0,this.emit(Zd.LONG_PRESS,t)},this.p.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(Zd.LONG_TAP,t),(wc(t.path,Zd.LONG_TAP)||wc(t.path,Zd.LONG_PRESS))&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressed=!1)}__onResize(){const{dragOut:t}=this.m;this.shrinkCanvasBounds=new Kt(this.canvas.bounds),this.shrinkCanvasBounds.spread(-(a(t)?t:2))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(jo.RESIZE,this.__onResize,this)],t.once(qo.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],yc(n,t,e,!0,s))return;n.isApp&&mc(n,t,e,!0,s)}for(let r=0,o=i.length;r<o;r++)if(n=i.list[r],n.isApp&&mc(n,t,e,!1,s),yc(n,t,e,!1,s))return}catch(t){pc.error(t)}}(t,e,i,s)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer&&this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class Sc{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Sc.custom={};class Bc extends ge{constructor(){super(...arguments),this.maxTotal=1e3,this.pathList=new mh,this.pixelList=new mh}getPixelType(t,e){return this.__autoClear(),this.pixelList.add(t),ae.hitCanvas(e)}getPathType(t){return this.__autoClear(),this.pathList.add(t),ae.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()}}v.getSelector=function(t){return t.leafer?t.leafer.selector:v.selector||(v.selector=ae.selector())};const{toInnerRadiusPointOf:Tc,copy:Rc,setRadius:Oc}=dt,{hitRadiusPoint:Cc,hitPoint:Lc}=Vt,Pc={},Mc={},Ac=oh.prototype;Ac.hit=function(t,e=0){this.updateLayout(),Rc(Mc,t),Oc(Mc,e);const i=this.__world;return!!(e?Cc(i,Mc):Lc(i,Mc))&&(this.isBranch?v.getSelector(this).hitPoint(Object.assign({},Mc),e,{target:this}):this.__hitWorld(Mc))},Ac.__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&&(Rc(Pc,t),Oc(t=Pc,e.hitRadius)),Tc(t,i,Pc),e.hitBox||n){if(Vt.hitRadiusPoint(s.boxBounds,Pc))return!0;if(n)return!1}return!s.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),s.boundsChanged||(s.hitCanvasChanged=!1)),this.__hit(Pc)},Ac.__hitFill=function(t){const e=this.__hitCanvas;return e&&e.hitFill(t,this.__.windingRule)},Ac.__hitStroke=function(t,e){const i=this.__hitCanvas;return i&&i.hitStroke(t,e)},Ac.__hitPixel=function(t){const e=this.__hitCanvas;return e&&e.hitPixel(t,this.__layout.renderBounds,e.hitScale)},Ac.__drawHitPath=function(t){t&&this.__drawRenderPath(t)};const Dc=new mt,Ic=Al.prototype;Ic.__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=v.image.hitCanvasSize,o=r.hitScale=Zt.set(0,0,n,n).getFitMatrix(t).a,{x:a,y:h,width:l,height:d}=Zt.set(t).scale(o);r.resize({width:l,height:d,pixelRatio:1}),r.clear(),tr.patternLocked=!0,this.__renderShape(r,{matrix:Dc.setWith(this.__world).scaleWith(1/o).invertWith().translate(-a,-h),ignoreFill:!i,ignoreStroke:!s}),tr.patternLocked=!1,r.resetTransform(),e.__isHitPixel=!0}else e.__isHitPixel&&(e.__isHitPixel=!1);this.__drawHitPath(r),r.setStrokeOptions(e)},Ic.__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 Wc=Al.prototype,Fc=zl.prototype,zc=Ul.prototype;Fc.__updateHitCanvas=zc.__updateHitCanvas=function(){this.stroke||this.cornerRadius||(this.fill||this.__.__isCanvas)&&"pixel"===this.hitFill||"all"===this.hitStroke?Wc.__updateHitCanvas.call(this):this.__hitCanvas&&(this.__hitCanvas=null)},Fc.__hitFill=zc.__hitFill=function(t){return this.__hitCanvas?Wc.__hitFill.call(this,t):Vt.hitRadiusPoint(this.__layout.boxBounds,t)},Rd.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))},Dl.prototype.pick=function(t,e){return e||(e=i),this.updateLayout(),v.getSelector(this).getByPoint(t,e.hitRadius||0,Object.assign(Object.assign({},e),{target:this}))};const Yc=Ce.prototype;function Nc(t,e,i){t.__.__font?Zh.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Xc(t,e,i,s,n){const r=i.__;c(t)?Zh.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),s.stroke()),r.__useArrow&&Zh.strokeArrow(t,i,s,n)}function Hc(t,e,i,s,n){const r=i.__;c(t)?Zh.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,r.__strokeWidth*e,r),Zh.drawTextStroke(i,s,n))}function Vc(t,e,i,s,n){const r=s.getSameCanvas(!0,!0);r.font=i.__.__font,Hc(t,2,i,r,n),r.blendMode="outside"===e?"destination-out":"destination-in",Zh.fillText(i,r,n),r.blendMode="normal",oo.copyCanvasByWorld(i,s,r),r.recycle(i.__nowWorld)}Yc.hitFill=function(t,e){return e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)},Yc.hitStroke=function(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)},Yc.hitPixel=function(t,e,i=1){let{x:s,y:n,radiusX:r,radiusY:o}=t;e&&(s-=e.x,n-=e.y),Zt.set(s-r,n-o,2*r,2*o).scale(i).ceil();const{data:a}=this.context.getImageData(Zt.x,Zt.y,Zt.width||1,Zt.height||1);for(let t=0,e=a.length;t<e;t+=4)if(a[t+3]>0)return!0;return a[3]>0};const{getSpread:Uc,copyAndSpread:jc,toOuterOf:Gc,getOuterOf:Kc,getByMove:Zc,move:qc,getIntersectData:Jc}=Vt,$c={};let Qc;const{stintSet:tu}=g,{hasTransparent:eu}=jh;function iu(t,e,i){if(!c(e)||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:o}=i.__layout;switch(e.type){case"image":n=qh.image(i,t,e,o,!Qc||!Qc[e.url]);break;case"linear":n=Jh.linearGradient(e,o);break;case"radial":n=Jh.radialGradient(e,o);break;case"angular":n=Jh.conicGradient(e,o);break;case"solid":const{type:r,color:a,opacity:h}=e;n={type:r,style:jh.string(a,h)};break;default:s(e.r)||(n={type:"solid",style:jh.string(e)})}if(n&&(n.originPaint=e,r(n.style)&&eu(n.style)&&(n.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;n.strokeStyle=e.style}return n}const su={compute:function(t,e){const i=e.__,s=[];let n,r,o,a=i.__input[t];d(a)||(a=[a]),Qc=qh.recycleImage(t,i);for(let i,n=0,r=a.length;n<r;n++)(i=iu(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?(tu(i,"__isAlphaPixelFill",n),tu(i,"__isTransparentFill",r)):(tu(i,"__isAlphaPixelStroke",n),tu(i,"__isTransparentStroke",r),tu(i,"__hasMultiStrokeStyle",o))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,Nc(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,qh.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),Nc(e,i,s),i.restore()}else r.blendMode?(i.saveBlendMode(r.blendMode),Nc(e,i,s),i.restoreBlendMode()):Nc(e,i,s)}},fillPathOrText:Nc,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)Zh.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":Xc(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),Xc(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)Xc(t,2,e,i,s);else{const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),Xc(t,2,e,o,s),o.clipUI(n),o.clearWorld(r),oo.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Zh.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":Hc(t,1,e,i,s);break;case"inside":Vc(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?Hc(t,2,e,i,s):Vc(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||!qh.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?Zh.drawTextStroke(s,n,r):n.stroke(),n.restoreBlendMode()):i?Zh.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,_;Gc(o.strokeSpread?(jc($c,o.boxBounds,o.strokeSpread),$c):o.boxBounds,r,a);let{scaleX:g,scaleY:p}=t.getRenderScaleData(!0);if(n.includes(a))_=s,h=u=a,l=r;else{let s;if(v.fullImageShadow)s=a;else{const t=o.renderShapeSpread?Uc(n,R.swapAndScale(o.renderShapeSpread,g,p)):n;s=Jc(t,a)}c=n.getFitMatrix(s);let{a:f,d:m}=c;c.a<1&&(_=e.getSameCanvas(),t.__renderShape(_,i),g*=f,p*=m),u=Kc(a,c),h=Zc(u,-c.e,-c.f),l=Kc(r,c),qc(l,-c.e,-c.f);const y=i.matrix;y?(d=new mt(c),d.multiply(y),f*=y.scaleX,m*=y.scaleY):d=c,d.withScale(f,m),i=Object.assign(Object.assign({},i),{matrix:d})}return t.__renderShape(s,i),{canvas:s,matrix:d,fitMatrix:c,bounds:h,renderBounds:l,worldCanvas:_,shapeBounds:u,scaleX:g,scaleY:p}}};let nu,ru=new Kt;const{isSame:ou}=Vt;function au(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||qh.createData(n,s,i,r),!0}function hu(t,e){cu(t,zo.LOAD,e)}function lu(t,e){cu(t,zo.LOADED,e)}function du(t,e,i){e.error=i,t.forceUpdate("surface"),cu(t,zo.ERROR,e)}function cu(t,e,i){t.hasEvent(e)&&t.emitEvent(new zo(e,i))}function uu(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_u,translate:gu}=Q,pu=new Kt,fu={},mu={};function yu(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 vu={},xu={a:1,b:0,c:0,d:1,e:0,f:0};const{get:wu,set:bu,rotateOfOuter:ku,translate:Eu,scaleOfOuter:Su,multiplyParent:Bu,scale:Tu,rotate:Ru,skew:Ou}=Q;function Cu(t,e,i,s,n,r,o,a){o&&Ru(t,o),a&&Ou(t,a.x,a.y),n&&Tu(t,n,r),Eu(t,e.x+i,e.y+s)}const{get:Lu,scale:Pu,copy:Mu}=Q,{getFloorScale:Au}=F,{abs:Du}=Math;const Iu={image:function(t,e,i,s,n){let r,o;const a=tr.get(i);return nu&&i===nu.paint&&ou(s,nu.boxBounds)?r=nu.leafPaint:(r={type:i.type,image:a},a.hasAlphaPixel&&(r.isTransparent=!0),nu=a.use>1?{leafPaint:r,paint:i,boxBounds:ru.set(s)}:null),(n||a.loading)&&(o={image:a,attrName:e,attrValue:i}),a.ready?(au(t,e,i,a,r,s),n&&(hu(t,o),lu(t,o))):a.error?n&&du(t,o,a.error):(n&&(uu(t,!0),hu(t,o)),r.loadId=a.load(()=>{uu(t,!1),t.destroyed||(au(t,e,i,a,r,s)&&(a.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),lu(t,o)),r.loadId=void 0},e=>{uu(t,!1),du(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}=qh.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"===v.name&&jo.isResizing(i)||d||(e=v.image.isLarge(a,r,o))),e?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),qh.drawImage(t,r,o,i,s,n),!0):(!t.style||l.sync||d?qh.createPattern(t,i,s,n):qh.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 _,{width:g,height:p}=a;(_=d&&!d.onlyScale||u.path||u.cornerRadius)||l||h?(n.save(),_&&n.clipUI(s),h&&(n.blendMode=h),l&&(n.opacity*=l),d&&n.transform(d),n.drawImage(c,0,0,g,p),n.restore()):(o.scaleX&&(g*=o.scaleX,p*=o.scaleY),n.drawImage(c,0,0,g,p))},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(d(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,tr.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],d(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=tr.patternTasker.add(()=>fe(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&qh.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,e,i,s){let{scaleX:n,scaleY:r}=qh.getImageRenderScaleData(t,e,i,s),o=n+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!v.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:i,data:s}=t,{transform:a,gap:h}=s,l=qh.getPatternFixScale(t,n,r);let d,c,u,{width:_,height:g}=i;l&&(n*=l,r*=l),_*=n,g*=r,h&&(c=h.x*n/Du(s.scaleX||1),u=h.y*r/Du(s.scaleY||1)),(a||1!==n||1!==r)&&(n*=Au(_+(c||0)),r*=Au(g+(u||0)),d=Lu(),a&&Mu(d,a),Pu(d,1/n,1/r));const p=i.getCanvas(_,g,s.opacity,s.filters,c,u,e.leafer&&e.leafer.config.smooth),f=i.getPattern(p,s.repeat||v.origin.noRepeat||"no-repeat",d,t);t.style=f,t.patternId=o}},getPatternFixScale:function(t,e,i){const{image:s}=t;let n,r=v.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=qh.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=pu.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:d,size:u,rotation:_,skew:g,clipSize:p,repeat:f,gap:m,filters:y}=t,v=e.width===s&&e.height===n,x={mode:a},w="center"!==h&&(_||0)%180==90;let b,k;switch(Vt.set(mu,0,0,w?n:s,w?s:n),a&&"cover"!==a&&"fit"!==a?((d||u)&&(F.getScaleData(d,u,i,fu),b=fu.scaleX,k=fu.scaleY),(h||m||f)&&(b&&Vt.scale(mu,b,k,!0),h&&Tt.toPoint(h,mu,e,mu,!0,!0))):v&&!_||(b=k=Vt.getFitScale(e,mu,"fit"!==a),Vt.put(e,i,h,b,!1,mu),Vt.scale(mu,b,k,!0)),l&&dt.move(mu,l),a){case"stretch":v?b&&(b=k=void 0):(b=e.width/s,k=e.height/n,qh.stretchMode(x,e,b,k));break;case"normal":case"clip":if(mu.x||mu.y||b||p||_||g){let t,i;p&&(t=e.width/p.width,i=e.height/p.height),qh.clipMode(x,e,mu.x,mu.y,b,k,_,g,t,i),t&&(b=b?b*t:t,k=k?k*i:i)}break;case"repeat":(!v||b||_||g)&&qh.repeatMode(x,e,s,n,mu.x,mu.y,b,k,_,g,h,t.freeTransform),f||(x.repeat="repeat");const i=c(f);(m||i)&&(x.gap=function(t,e,i,s,n){let r,o;c(t)?(r=t.x,o=t.y):r=o=t;return{x:yu(r,i,n.width,e&&e.x),y:yu(o,s,n.height,e&&e.y)}}(m,i&&f,mu.width,mu.height,e));break;default:b&&qh.fillOrFitMode(x,e,mu.x,mu.y,b,k,_)}return x.transform||(e.x||e.y)&&gu(x.transform=_u(),e.x,e.y),b&&(x.scaleX=b,x.scaleY=k),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=wu(),{x:r,y:o}=e;r||o?Eu(n,r,o):n.onlyScale=!0,Tu(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,r,o){const a=wu();Eu(a,e.x+i,e.y+s),Tu(a,n,r),o&&ku(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=wu();Cu(d,e,i,s,n,r,o,a),h&&(o||a?(bu(xu),Su(xu,e,h,l),Bu(d,xu)):Su(d,e,h,l)),t.transform=d},repeatMode:function(t,e,i,s,n,r,o,a,h,l,d,c){const u=wu();if(c)Cu(u,e,n,r,o,a,h,l);else{if(h)if("center"===d)ku(u,{x:i/2,y:s/2},h);else switch(Ru(u,h),h){case 90:Eu(u,s,0);break;case 180:Eu(u,i,s);break;case 270:Eu(u,0,i)}vu.x=e.x+n,vu.y=e.y+r,Eu(u,vu.x,vu.y),o&&Su(u,vu,o,a)}t.transform=u}},{toPoint:Wu}=Et,{hasTransparent:Fu}=jh,zu={},Yu={};function Nu(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=jh.string(n,s)):(a=n.offset,o=jh.string(n.color,s)),e.addColorStop(a,o),!h&&Fu(o)&&(h=!0);h&&(t.isTransparent=!0)}}const{getAngle:Xu,getDistance:Hu}=dt,{get:Vu,rotateOfOuter:Uu,scaleOfOuter:ju}=Q,{toPoint:Gu}=Et,Ku={},Zu={};function qu(t,e,i,s,n){let r;const{width:o,height:a}=t;if(o!==a||s){const t=Xu(e,i);r=Vu(),n?(ju(r,e,o/a*(s||1),1),Uu(r,e,t+90)):(ju(r,e,1,o/a*(s||1)),Uu(r,e,t))}return r}const{getDistance:Ju}=dt,{toPoint:$u}=Et,Qu={},t_={};const e_={linearGradient:function(t,e){let{from:i,to:s,type:n,opacity:r}=t;Wu(i||"top",e,zu),Wu(s||"bottom",e,Yu);const o=v.canvas.createLinearGradient(zu.x,zu.y,Yu.x,Yu.y),a={type:n,style:o};return Nu(a,o,t.stops,r),a},radialGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;Gu(i||"center",e,Ku),Gu(s||"bottom",e,Zu);const a=v.canvas.createRadialGradient(Ku.x,Ku.y,0,Ku.x,Ku.y,Hu(Ku,Zu)),h={type:n,style:a};Nu(h,a,t.stops,r);const l=qu(e,Ku,Zu,o,!0);return l&&(h.transform=l),h},conicGradient:function(t,e){let{from:i,to:s,type:n,opacity:r,stretch:o}=t;$u(i||"center",e,Qu),$u(s||"bottom",e,t_);const a=v.conicGradientSupport?v.canvas.createConicGradient(0,Qu.x,Qu.y):v.canvas.createRadialGradient(Qu.x,Qu.y,0,Qu.x,Qu.y,Ju(Qu,t_)),h={type:n,style:a};Nu(h,a,t.stops,r);const l=qu(e,Qu,t_,o||1,v.conicGradientRotate90);return l&&(h.transform=l),h},getTransform:qu},{copy:i_,move:s_,toOffsetOutBounds:n_}=Vt,{max:r_,abs:o_}=Math,a_={},h_=new mt,l_={};function d_(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=o_(t.spread||0),o=r_(o,n+r-s),a=r_(a,n+r+i),h=r_(h,n+r+s),l=r_(l,n+r-i)}),o===a&&a===h&&h===l?o:[o,a,h,l]}function c_(t,e,i){const{shapeBounds:s}=i;let n,r;v.fullImageShadow?(i_(a_,t.bounds),s_(a_,e.x-s.x,e.y-s.y),n=t.bounds,r=a_):(n=s,r=e),t.copyWorld(i.canvas,n,r)}const{toOffsetOutBounds:u_}=Vt,__={};const g_=d_;const p_={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,_=e.getSameCanvas(),g=o.length-1;n_(h,l_,l),o.forEach((o,p)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}_.setWorldShadow(l_.offsetX+(o.x||0)*c*f,l_.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f,jh.string(o.color)),n=$h.getShadowTransform(t,_,i,o,l_,f),n&&_.setTransform(n),c_(_,l_,i),n&&_.resetTransform(),s=l,o.box&&(_.restore(),_.save(),a&&(_.copyWorld(_,l,r,"copy"),s=r),a?_.copyWorld(a,r,r,"destination-out"):_.copyWorld(i.canvas,d,h,"destination-out")),oo.copyCanvasByWorld(t,e,_,s,o.blendMode),g&&p<g&&_.clearWorld(s)}),_.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,_=e.getSameCanvas(),g=o.length-1;u_(h,__,l),o.forEach((o,p)=>{let f=1;if(o.scaleFixed){const t=Math.abs(r.scaleX);t>1&&(f=1/t)}_.save(),_.setWorldShadow(__.offsetX+(o.x||0)*c*f,__.offsetY+(o.y||0)*u*f,(o.blur||0)*c*f),n=$h.getShadowTransform(t,_,i,o,__,f,!0),n&&_.setTransform(n),c_(_,__,i),_.restore(),a?(_.copyWorld(_,l,r,"copy"),_.copyWorld(a,r,r,"source-out"),s=r):(_.copyWorld(i.canvas,d,h,"source-out"),s=l),_.fillWorld(s,jh.string(o.color),"source-in"),oo.copyCanvasByWorld(t,e,_,s,o.blendMode),g&&p<g&&_.clearWorld(s)}),_.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:d_,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 h_.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/a,1+i/h),h_}},isTransformShadow(t){},getInnerShadowSpread:g_},{excludeRenderBounds:f_}=po;let m_;function y_(t,e,i,s,n,r,o,a){switch(e){case"grayscale":m_||(m_=!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);x_(t,e,i,1,n,r)}(t,i,s,n,o,a);break;case"opacity-path":x_(t,i,s,r,o,a);break;case"path":a&&i.restore()}}function v_(t){return t.getSameCanvas(!1,!0)}function x_(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)}Dl.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&&(y_(this,o,t,n,s,r,void 0,!0),s=n=null),"clipping"!==a&&"clipping-path"!==a||f_(i,e)||i.__render(t,e),r=i.__.opacity,m_=!1,"path"===a||"clipping-path"===a?(r<1?(o="opacity-path",n||(n=v_(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===a?"grayscale":"alpha",s||(s=v_(t)),n||(n=v_(t)),i.__render(s,e));continue}const d=1===r&&i.__.__blendMode;d&&y_(this,o,t,n,s,r,void 0,!1),f_(i,e)||i.__render(n||t,e),d&&y_(this,o,t,n,s,r,d,!1)}y_(this,o,t,n,s,r,void 0,!0)};const w_=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",b_=w_+"_#~&*+\\=|≮≯≈≠=…",k_=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 E_(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const S_=E_("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),B_=E_("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),T_=E_(w_),R_=E_(b_),O_=E_("- —/~|┆·");var C_;!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"}(C_||(C_={}));const{Letter:L_,Single:P_,Before:M_,After:A_,Symbol:D_,Break:I_}=C_;function W_(t){return S_[t]?L_:O_[t]?I_:B_[t]?M_:T_[t]?A_:R_[t]?D_:k_.test(t)?P_:L_}const F_={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 z_(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:Y_}=F_,{Letter:N_,Single:X_,Before:H_,After:V_,Symbol:U_,Break:j_}=C_;let G_,K_,Z_,q_,J_,$_,Q_,tg,eg,ig,sg,ng,rg,og,ag,hg,lg,dg=[];function cg(t,e){eg&&!tg&&(tg=eg),G_.data.push({char:t,width:e}),Z_+=e}function ug(){q_+=Z_,G_.width=Z_,K_.words.push(G_),G_={data:[]},Z_=0}function _g(){og&&(ag.paraNumber++,K_.paraStart=!0,og=!1),eg&&(K_.startCharSize=tg,K_.endCharSize=eg,tg=0),K_.width=q_,hg.width?Y_(K_):lg&&gg(),dg.push(K_),K_={words:[]},q_=0}function gg(){q_>(ag.maxWidth||0)&&(ag.maxWidth=q_)}const{top:pg,right:fg,bottom:mg,left:yg}=wt;function vg(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 xg={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[yg],n-=a[fg]+a[yg],!n&&(n=.01)):e.autoSizeAlign||(i=a[yg]),o?(s=a[pg],o-=a[pg]+a[mg],!o&&(o=.01)):e.autoSizeAlign||(s=a[pg]));const h={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:v.canvas.font=e.__font};return function(t,e,i){ag=t,dg=t.rows,hg=t.bounds,lg=!hg.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:o}=v,{width:a}=hg;if(i.__isCharMode){const t="none"!==i.textWrap,h="break"===i.textWrap;og=!0,sg=null,tg=Q_=eg=Z_=q_=0,G_={data:[]},K_={words:[]},s&&(e=[...e]);for(let i=0,l=e.length;i<l;i++)$_=e[i],"\n"===$_?(Z_&&ug(),K_.paraEnd=!0,_g(),og=!0):(ig=W_($_),ig===N_&&"none"!==r&&($_=z_($_,r,!Z_)),Q_=o.measureText($_).width,s&&(s<0&&(eg=Q_),Q_+=s),ng=ig===X_&&(sg===X_||sg===N_)||sg===X_&&ig!==V_,rg=!(ig!==H_&&ig!==X_||sg!==U_&&sg!==V_),J_=og&&n?a-n:a,t&&a&&q_+Z_+Q_>J_&&(h?(Z_&&ug(),q_&&_g()):(rg||(rg=ig===N_&&sg==V_),ng||rg||ig===j_||ig===H_||ig===X_||Z_+Q_>J_?(Z_&&ug(),q_&&_g()):q_&&_g()))," "===$_&&!0!==og&&q_+Z_===0||(ig===j_?(" "===$_&&Z_&&ug(),cg($_,Q_),ug()):ng||rg?(Z_&&ug(),cg($_,Q_)):cg($_,Q_)),sg=ig);Z_&&ug(),q_&&_g(),dg.length>0&&(dg[dg.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{ag.paraNumber++,q_=o.measureText(t).width,dg.push({x:n||0,text:t,width:q_,paraStart:!0}),lg&&gg()})}(h,t,e),a&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":vg(e,"x",t[yg]);break;case"right":vg(e,"x",-t[fg])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":vg(e,"y",t[pg]);break;case"bottom":vg(e,"y",-t[mg])}}(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:_,y:g,width:p,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,b=p||u?p:t.maxWidth;for(let o=0,d=n;o<d;o++){if(v=i[o],v.x=_,v.width<p||v.width>p&&!h)switch(l){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-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&&p&&p<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,_,g,p,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?_=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?c/(m-1):0),p=o||t.isOverflow||l?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===p?(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===p?(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&&_),v&&(y=i===m-1,u?y||(d+=u,t.width+=u):_&&(t.width+=_*(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?v.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,c(r)?(i=r.type,r.color&&(t.decorationColor=jh.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 wg={string:function(t,e){if(!t)return"#000";const i=a(e)&&e<1;if(r(t)){if(!i||!jh.object)return t;t=jh.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 bg(t){return t?d(t)?t:[t]:[]}Object.assign(Uh,xg),Object.assign(jh,wg),Object.assign(Zh,su),Object.assign(qh,Iu),Object.assign(Jh,e_),Object.assign($h,p_),Object.assign(ae,{interaction:(t,e,i,s)=>new Ec(t,e,i,s),hitCanvas:(t,e)=>new xh(t,e),hitCanvasManager:()=>new Bc}),bh();class kg extends Ao{get list(){return bg(this.value)}get oldList(){return bg(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}function Eg(t){return(e,i)=>{const s="_"+i;rr(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(c(i))e=i;else if(!1===i)return}r.setDimOthers(!1),r.setBright(!1),d(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?kg.BEFORE_SELECT:kg.BEFORE_HOVER;this.hasEvent(s)&&this.emitEvent(new kg(s,{editor:r,value:e,oldValue:n}))}this[s]=e,t(this,n)}}})}}kg.BEFORE_SELECT="editor.before_select",kg.SELECT="editor.select",kg.AFTER_SELECT="editor.after_select",kg.BEFORE_HOVER="editor.before_hover",kg.HOVER="editor.hover";const{abs:Sg}=Math,{copy:Bg,scale:Tg}=Q,{setListWithFn:Rg}=Vt,{worldBounds:Og}=po,Cg={a:1,b:0,c:0,d:1,e:0,f:0},Lg={x:0,y:0,width:0,height:0};class Pg extends Al{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(Lg,e,Og),t&&this.set(t),this.set(Lg),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=Sg(c.scaleX),l=Sg(c.scaleY);if(Bg(Cg,c),Cg.half=a%2,i!==l){Tg(Cg,1/i,1/l),t.setWorld(Cg,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(Cg,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=a/Sg(c.scaleX);o&&(r(o)?Zh.stroke(o,this,t,e):Zh.strokes(o,this,t,e)),h&&(r(h)?Zh.fill(h,this,t,e):Zh.fills(h,this,t,e))}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}pe([Eg(function(t){const e=t.target;t.list=e?d(e)?e:[e]:[]})],Pg.prototype,"target",void 0);class Mg extends Dl{constructor(t){super(t),this.strokeArea=new zl({strokeAlign:"center"}),this.fillArea=new zl,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 Ag={findOne:t=>t.list.find(t=>t.editable),findByBounds(t,e){const i=[];return Dg([t],i,e),i}};function Dg(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&&Dg(s.children,e,i)}}const{findOne:Ig,findByBounds:Wg}=Ag;class Fg extends Dl{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 Pg,this.targetStroker=new Pg,this.bounds=new Kt,this.selectArea=new Mg,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 mh(Wg(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)&&!Ig(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new mh(this.editor.editBox.rect)};return Ig(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):Ig(t.path)}isMultipleSelect(t){const{multipleSelect:e,continuousSelect:i}=this.editor.mergeConfig;return e&&(this.isHoldMultipleSelectKey(t)||i)}isHoldMultipleSelectKey(t){const{multipleSelectKey:e}=this.editor.mergedConfig;return e?t.isHoldKeys(e):t.shiftKey}__listenEvents(){const{editor:t}=this;t.waitLeafer(()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_([[kg.HOVER,this.onHover,this],[kg.SELECT,this.onSelect,this]]),e.on_([[Zd.MOVE,this.onPointerMove,this],[Zd.BEFORE_DOWN,this.onBeforeDown,this],[Zd.TAP,this.onTap,this],[$d.START,this.onDragStart,this,!0],[$d.DRAG,this.onDrag,this],[$d.END,this.onDragEnd,this],[ec.MOVE,this.onAutoMove,this],[[oc.ZOOM,ec.MOVE],()=>{this.editor.hoverTarget=null}]])]})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:zg,top:Yg,topRight:Ng,right:Xg,bottomRight:Hg,bottom:Vg,bottomLeft:Ug,left:jg}=bt,{toPoint:Gg}=Et,{within:Kg,sign:Zg}=F,{abs:qg}=Math,Jg={getScaleData(t,e,i,s,n,r,o,h){let l,d,c={},u=1,_=1;const{boxBounds:g,widthRange:p,heightRange:f,dragBounds:m,worldBoxBounds:y}=t,{width:v,height:x}=e,w=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,k=Zg(w),E=Zg(b),S=h?w:k*g.width/v,B=h?b:E*g.height/x;if(a(s))u=_=Math.sqrt(s);else{r&&(s.x*=2,s.y*=2),s.x*=h?w:k,s.y*=h?b:E;const t=(-s.y+x)/x,e=(s.x+v)/v,o=(s.y+x)/x,a=(-s.x+v)/v;switch(i){case Yg:_=t,l="bottom";break;case Xg:u=e,l="left";break;case Vg:_=o,l="top";break;case jg:u=a,l="right";break;case zg:_=t,u=a,l="bottom-right";break;case Ng:_=t,u=e,l="bottom-left";break;case Hg:_=o,u=e,l="top-left";break;case Ug:_=o,u=a,l="top-right"}if(n)if("corner"===n&&i%2)n=!1;else switch(i){case Yg:case Vg:u=_;break;case jg:case Xg:_=u;break;default:d=Math.sqrt(qg(u*_)),u=Zg(u)*d,_=Zg(_)*d}}const T=1!==u,R=1!==_;if(T&&(u/=S),R&&(_/=B),!o){const{worldTransform:e}=t;u<0&&(u=1/g.width/e.scaleX),_<0&&(_=1/g.height/e.scaleY)}if(Gg(r||l,g,c,!0),m){const e={x:u,y:_};Gd.limitScaleOf(t,c,e,n),u=e.x,_=e.y}if(T&&p){const e=g.width*t.scaleX;u=Kg(e*u,p)/e}if(R&&f){const e=g.height*t.scaleY;_=Kg(e*_,f)/e}return T&&qg(u*y.width)<1&&(u=Zg(u)/y.width),R&&qg(_*y.height)<1&&(_=Zg(_)/y.height),n&&u!==_&&(d=Math.min(qg(u),qg(_)),u=Zg(u)*d,_=Zg(_)*d),isFinite(u)||(u=1),isFinite(_)||(_=1),{origin:c,scaleX:u,scaleY:_,direction:i,lockRatio:n,around:r}},getRotateData(t,e,i,s,n){let r,o={};switch(e){case zg:r="bottom-right";break;case Ng:r="bottom-left";break;case Hg:r="top-left";break;case Ug:r="top-right";break;default:r="center"}return Gg(n||r,t.boxBounds,o,!0),{origin:o,rotation:dt.getRotation(s,t.getWorldPointByBox(o),i)}},getSkewData(t,e,i,s){let n,r,o={},a=0,h=0;switch(e){case Yg:case zg:r={x:.5,y:0},n="bottom",a=1;break;case Vg:case Hg:r={x:.5,y:1},n="top",a=1;break;case jg:case Ug:r={x:0,y:.5},n="right",h=1;break;case Xg:case Ng: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,Gg(s||n,t,o,!0);const c=dt.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 jg:t=Xg;break;case zg:t=Ng;break;case Ug:t=Hg;break;case Xg:t=jg;break;case Ng:t=zg;break;case Hg:t=Ug}if(i)switch(t){case Yg:t=Vg;break;case zg:t=Ug;break;case Ng:t=Hg;break;case Vg:t=Yg;break;case Ug:t=zg;break;case Hg:t=Ng}return t}},$g={};function Qg(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 tp(t);if("circle"===i.name)return;let{rotation:h}=t;const{pointType:l}=i,{moveCursor:d,resizeCursor:c,rotateCursor:u,skewCursor:_,moveable:g,resizeable:p,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)||!p)&&(y=!1);const v=m&&!y&&("resize-line"===i.name||"skew"===l),x=s?n?_:r?c:u:v?_:y?c:u;h+=45*(Jg.getFlipDirection(i.direction,o,a)+1),h=2*Math.round(F.formatRotation(h,!0)/2);const{url:w,x:b,y:k}=x,E=w+h;$g[E]?i.cursor=$g[E]:$g[E]=i.cursor={url:ep(w,h),x:b,y:k}}function tp(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.canUse&&(t.rect.cursor=i?e:void 0)}function ep(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class ip extends Ul{constructor(t){super(t),this.useFastShadow=!0}}const sp=["top","right","bottom","left"],np=void 0;class rp extends Dl{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(t){super(),this.view=new Dl,this.rect=new ip({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new ip({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new Dl({around:"center",hitSelf:!1,visible:0}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.dragStartData={},this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints: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 ip({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),r.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new ip({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),o.push(e),this.listenPointEvents(e,"resize",s)),i=new ip({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(),_=this.getResizeLinesStyle();let p;this.visible=!t.locked;for(let t=0;t<8;t++)p=o[t],p.set(this.getPointStyle(t%2?u[(t-1)/2%u.length]:c[t/2%c.length])),p.rotation=(t-(t%2?1:0))/2*90,t%2&&a[(t-1)/2].set(Object.assign({pointType:"resize",rotation:(t-1)/2*90},_[(t-1)/2%_.length]||{}));r.set(this.getPointStyle(e.circle||e.rotatePoint||c[0])),s.set(Object.assign({stroke:h,strokeWidth:l,opacity:1,editConfig:np},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&&g.stintSet(t.__world,"ignorePixelSnap",d),tp(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:_,rotateable:g,hideOnSmall:p,editBox:f,mask:m,dimOthers:y,bright:v,spread:x,hideRotatePoints:w,hideResizeLines:b}=i;if(c.visible=!!m||0,e.setDimOthers(y),e.setBright(!!y||v),x&&Vt.spread(t,x),this.view.worldOpacity){const{width:e,height:c}=t,m=a(p)?p:10,y=f&&!(p&&e<m&&c<m);let v,x,k,E={};for(let i=0;i<8;i++)Et.toPoint(Et.directionData[i],t,E),x=h[i],v=l[i],x.set(E),v.set(E),x.visible=y&&!(!_&&!g),v.visible=y&&g&&_&&!w,i%2&&(k=d[(i-1)/2],k.set(E),k.visible=x.visible&&!b,x.visible=v.visible=y&&!!u,(i+1)/2%2?(k.width=e+k.height,p&&2*x.width>e&&(x.visible=!1)):(k.width=c+k.height,p&&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=sp.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=sp.indexOf(e);(a%2&&r||(a+1)%2&&o)&&i&&(a=(a+2)%4);const h=i?Jg.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:np};return t?Object.assign(o,t):o}getPointsStyle(){const{point:t}=this.mergedConfig;return d(t)?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.mergedConfig;return d(t)?t:t?[t]:this.getPointsStyle()}getResizeLinesStyle(){const{resizeLine:t}=this.mergedConfig;return d(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)}Qg(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&&(jo.resizingKeys=this.editor.leafList.keys);const{dragStartData:e,target:i}=this;e.x=t.x,e.y=t.y,e.totalOffset={x:0,y:0},e.point={x:i.x,y:i.y},e.bounds=Object.assign({},i.getLayoutBounds("box","local")),e.rotation=i.rotation}onTransformEnd(t){this.canDragLimitAnimate&&(t instanceof $d||t instanceof ec)&&this.transformTool.onMove(t),this.resizing&&(jo.resizingKeys=null),this.dragging=this.gesturing=this.moving=this.resizing=this.rotating=this.skewing=!1,this.editor.opacity=1,this.editor.update()}onMove(t){if(this.canGesture&&"drag"!==t.moveType&&(t.stop(),r(this.mergedConfig.moveable)))switch(this.gesturing=this.moving=!0,t.type){case ec.START:this.onTransformStart(t);break;case ec.END:this.onTransformEnd(t);break;default:this.transformTool.onMove(t)}}onScale(t){if(this.canGesture&&(t.stop(),r(this.mergedConfig.resizeable)))switch(this.gesturing=this.resizing=!0,t.type){case oc.START:this.onTransformStart(t);break;case oc.END:this.onTransformEnd(t);break;default:this.transformTool.onScale(t)}}onRotate(t){if(this.canGesture&&(t.stop(),r(this.mergedConfig.rotateable)))switch(this.gesturing=this.rotating=!0,t.type){case oc.START:this.onTransformStart(t);break;case oc.END:this.onTransformEnd(t);break;default:this.transformTool.onRotate(t)}}isHoldRotateKey(t){const{rotateKey:e}=this.mergedConfig;return e?t.isHoldKeys(e):t.metaKey||t.ctrlKey}onKey(t){Qg(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(t){const{editor:e,target:i}=this;if(this.single){if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find(t=>t.editable&&t instanceof Rd)||t.find(t=>t instanceof Rd);if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){t.direction=i,t.pointType=e,this.__eventIds.push(t.on_([[$d.START,this.onDragStart,this],[$d.DRAG,this.onDrag,this],[$d.END,this.onDragEnd,this],[Zd.ENTER,e=>{this.enterPoint=t,Qg(this,e)}],[Zd.LEAVE,()=>{this.enterPoint=null}]]))}__listenEvents(){const{rect:t,editor:e,__eventIds:i}=this;i.push(t.on_([[Zd.DOUBLE_TAP,this.onDoubleTap,this],[Zd.LONG_PRESS,this.onLongPress,this]])),this.waitLeafer(()=>{i.push(e.app.on_([[[ac.HOLD,ac.UP],this.onKey,this],[ac.DOWN,this.onArrow,this],[[ec.START,ec.BEFORE_MOVE,ec.END],this.onMove,this,!0],[[oc.START,oc.BEFORE_ZOOM,oc.END],this.onScale,this,!0],[[nc.START,nc.BEFORE_ROTATE,nc.END],this.onRotate,this,!0]]))})}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const op={x:0,y:0,width:1e5,height:1e5};class ap extends Al{constructor(t){super(),this.editor=t,this.hittable=!1,this.visible=0}__updateWorldBounds(){Object.assign(this.__local,op),Object.assign(this.__world,op)}__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 hp='\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"/>',lp={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${hp}\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${hp}\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${hp}\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},dp=new Kt;function cp(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer;e.safeChange(()=>{dp.setListWithFn(i,t=>t.getBounds("box","page")),0===dp.width&&(dp.width=.1),0===dp.height&&(dp.height=.1),e.reset(dp.get())}),s.add(e)}const up=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),_p=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),gp={group(t,e,i){t.sort(_p);const{app:s,parent:n}=t[0];let r;r=i&&i.add?i:new Dl(i),n.addAt(r,n.children.indexOf(t[0])),t.sort(up);const o=new mt(e.worldTransform);return o.divideParent(n.scrollWorldTransform),r.setTransform(o),r.editable=!0,r.hitChildren=!1,s.lockLayout(),t.forEach(t=>t.dropTo(r)),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach(t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.isBranchLeaf?i.push(t):t.remove()}else i.push(t)}),e.unlockLayout(),i},toTop(t){t.sort(up),t.forEach(t=>{t.parent&&t.parent.add(t)})},toBottom(t){t.sort(_p),t.forEach(t=>{t.parent&&t.parent.addAt(t,0)})}},pp=Qt.get("EditToolCreator");function fp(){return t=>{yp.register(t)}}const mp=fp,yp={list:{},register(t){const{tag:e}=t.prototype;vp[e]&&pp.repeat(e),vp[e]=t},get:(t,e)=>new vp[t](e)},{list:vp}=yp;class xp extends kg{constructor(t,e){super(t,e)}}xp.BEFORE_OPEN="innerEditor.before_open",xp.OPEN="innerEditor.open",xp.BEFORE_CLOSE="innerEditor.before_close",xp.CLOSE="innerEditor.close";class wp extends kg{constructor(t,e){super(t,e)}}wp.BEFORE_GROUP="editor.before_group",wp.GROUP="editor.group",wp.BEFORE_UNGROUP="editor.before_ungroup",wp.UNGROUP="editor.ungroup",wp.BEFORE_OPEN="editor.before_open_group",wp.OPEN="editor.open_group",wp.BEFORE_CLOSE="editor.before_close_group",wp.CLOSE="editor.close_group";const{updateMatrix:bp}=oo,kp={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},Ep="top-left";class Sp extends zl{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(Wo.CHANGE,e=>{if(this.checkChange&&kp[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,bp(this.parent),bp(this);const a=new mt(this.__world);switch(o[i]=s,this.__layout.rotationChange(),bp(this),this.changedTransform=new mt(this.__world).divide(a),i){case"x":t.move(r,0);break;case"y":t.move(0,r);break;case"rotation":t.rotateOf(Ep,r);break;case"scaleX":t.scaleOf(Ep,r,1);break;case"scaleY":t.scaleOf(Ep,1,r);break;case"skewX":t.skewOf(Ep,r,0);break;case"skewY":t.skewOf(Ep,0,r)}this.canChange=!0}})}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Bp extends kg{constructor(t,e){super(t,e)}}Bp.BEFORE_MOVE="editor.before_move",Bp.MOVE="editor.move";class Tp extends kg{constructor(t,e){super(t,e)}}Tp.BEFORE_SCALE="editor.before_scale",Tp.SCALE="editor.scale";class Rp extends kg{constructor(t,e){super(t,e)}}Rp.BEFORE_ROTATE="editor.before_rotate",Rp.ROTATE="editor.rotate";class Op extends kg{constructor(t,e){super(t,e)}}Op.BEFORE_SKEW="editor.before_skew",Op.SKEW="editor.skew";class Cp{onMove(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox;let n,{dragLimitAnimate:o}=i;const h=t.type===ec.END||t.type===$d.END,l=r(e.draggable),d=!o||h||l,c={x:t.totalX,y:t.totalY};t instanceof ec&&dt.move(c,e.getWorldPointByLocal(s.totalOffset,null,!0)),t.shiftKey&&(Math.abs(c.x)>Math.abs(c.y)?c.y=0:c.x=0),n=$d.getValidMove(e,s.point,c,d),(n.x||n.y)&&(o&&!l&&h?oo.animateMove(this,n,a(o)?o:.3):this.move(n))}onScale(t){const{target:e,mergeConfig:i,single:s,dragStartData:n}=this.editBox;let r,{around:o,lockRatio:a,flipable:h,editSize:l}=i;t instanceof oc?(o=e.getBoxPoint(t),r=t.totalScale):r=t.getInnerTotal(e);const{direction:d}=t.current;(t.shiftKey||e.lockRatio)&&(a=!0);const c=Jg.getScaleData(e,n.bounds,d,r,a,Jg.getAround(o,t.altKey),h,!s||"scale"===l),u=e.x,_=e.y;t instanceof $d&&this.editTool&&this.editTool.onScaleWithDrag?(c.drag=t,this.scaleWithDrag(c)):this.scaleOf(c.origin,c.scaleX,c.scaleY),dt.move(n.totalOffset,e.x-u,e.y-_)}onRotate(t){const{target:e,mergeConfig:i,dragStartData:s}=this.editBox,{around:n,rotateAround:r,rotateGap:o,diagonalRotateKey:a}=i,{direction:h}=t.current;let l,d;if(t instanceof nc)d=t.rotation,l=r?Et.getPoint(r,e.boxBounds):e.getBoxPoint(t);else{const i=a?t.isHoldKeys(a):t.shiftKey,o=Jg.getRotateData(e,h,t,s,i?null:r||e.around||e.origin||n||"center");d=s.rotation+o.rotation-e.rotation,l=o.origin}if(d=F.float(F.getGapRotation(d,o,e.rotation),2),!d)return;const c=e.x,u=e.y;this.rotateOf(l,d),dt.move(s.totalOffset,e.x-c,e.y-u)}onSkew(t){const{target:e,mergeConfig:i}=this.editBox,{around:s}=i,{origin:n,skewX:r,skewY:o}=Jg.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Jg.getAround(s,t.altKey));(r||o)&&this.skewOf(n,r,o)}move(t,e=0){if(!this.checkTransform("moveable"))return;c(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(c(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 Bp(Bp.BEFORE_MOVE,h));const l=new Bp(Bp.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 Tp(Tp.BEFORE_SCALE,t));const r=new Tp(Tp.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(c(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))),u={target:n,editor:a,worldOrigin:l,scaleX:e,scaleY:i,transform:d};this.emitEvent(new Tp(Tp.BEFORE_SCALE,u));const _=new Tp(Tp.SCALE,u);this.doScale(_),this.emitEvent(_)}flip(t){if(!this.checkTransform("resizeable"))return;const{target:e,single:i,editor:s}=this.editBox,n=this.getWorldOrigin("center"),r=i?new mt(oo.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 Tp(Tp.BEFORE_SCALE,o));const a=new Tp(Tp.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 Rp(Rp.BEFORE_ROTATE,d));const c=new Rp(Rp.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(c(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))),u={target:n,editor:a,worldOrigin:l,skewX:e,skewY:i,transform:d};this.emitEvent(new Op(Op.BEFORE_SKEW,u));const _=new Op(Op.SKEW,u);this.doSkew(_),this.emitEvent(_)}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(oo.getInnerOrigin(e,t))}getChangedTransform(t){const{target:e,single:i}=this.editBox;if(!i&&!e.canChange)return e.changedTransform;const s=new mt(e.worldTransform);return t(),new mt(e.worldTransform).divide(s)}emitEvent(t,e){this.editBox.editor.emitEvent(t,e)}}let Lp=class extends Dl{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 mh,this.openedGroupList=new mh,this.simulateTarget=new Sp(this),this.editBox=new rp(this),this.editToolList={},this.selector=new Fg(this),this.editMask=new ap(this),this.targetEventIds=[];let i=g.clone(lp);t&&(i=g.default(t,i)),this.mergedConfig=this.config=i,this.addMany(this.editMask,this.selector,this.editBox),oe.has("resize")||(this.config.editSize="scale")}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}getItem(t){return this.list[t||0]}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}setDimOthers(t,e="dim",i){if(!i){const{dimTarget:t,targetLeafer:e}=this;i=t?d(t)?t:[t]:[e]}i[0]&&i[0][e]!==(t||!1)&&i.forEach(i=>g.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&&cp(this),this.update()}getEditTool(t){return this.editToolList[t]=this.editToolList[t]||yp.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(yp.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(wp.BEFORE_GROUP),this.target=gp.group(this.list,this.element,t),this.emitGroupEvent(wp.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach(t=>t.isBranch&&this.emitGroupEvent(wp.BEFORE_UNGROUP,t)),this.target=gp.ungroup(t),t.forEach(t=>t.isBranch&&this.emitGroupEvent(wp.UNGROUP,t))),this.list}openGroup(t){this.emitGroupEvent(wp.BEFORE_OPEN,t),this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(wp.OPEN,t)}closeGroup(t){this.emitGroupEvent(wp.BEFORE_CLOSE,t),this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(wp.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach(t=>this.list.every(e=>!oo.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 wp(t,{editTarget:e});this.emitEvent(i),e&&e.emitEvent(i)}getInnerEditor(t){return this.editToolList[t]=this.editToolList[t]||yp.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}yp.list[s]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.getInnerEditor(s),this.innerEditor.editTarget=t,this.emitInnerEvent(xp.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(xp.OPEN))}}closeInnerEditor(t){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(xp.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(xp.CLOSE),t||this.updateEditTool(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new xp(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&&(gp.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(gp.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_(Zo.START,this.onRenderStart,this),i&&i.on_(Wo.SCROLL,this.onChildScroll,this),t.on_(Zo.CHILD_START,this.onAppRenderStart,this),t.on_(qo.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())}};pe([(t,e)=>{rr(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}})}],Lp.prototype,"mergeConfig",void 0),pe([Eg(function(t,e){const{target:i}=t;i?(t.leafList=i instanceof mh?i:new mh(i),t.multiple&&cp(t)):(t.simulateTarget.remove(),t.leafList.reset()),t.closeInnerEditor(!0),t.unloadEditTool();const s={editor:t,value:i,oldValue:e};t.emitEvent(new kg(kg.SELECT,s)),t.checkOpenedGroups(),t.editing?t.waitLeafer(()=>{t.updateEditTool(),t.listenTargetEvents()}):(t.updateEditTool(),t.removeTargetEvents()),t.emitEvent(new kg(kg.AFTER_SELECT,s))})],Lp.prototype,"target",void 0),pe([Eg(function(t,e){t.emitEvent(new kg(kg.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))})],Lp.prototype,"hoverTarget",void 0),Lp=pe([jr(Cp,["editBox","editTool","emitEvent"])],Lp);class Pp{static registerInnerEditor(){yp.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 Dl,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)}}let Mp=class extends Pp{static registerEditTool(){yp.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()}};Mp=pe([fp()],Mp);const{left:Ap,right:Dp}=bt,{move:Ip,copy:Wp,toNumberPoints:Fp}=dt;let zp=class extends Mp{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===Ap;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=Fp(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?(Ip(t,r,o),s&&Ip(e,-r,-o)):(s&&Ip(t,-r,-o),Ip(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),Wp(s[7],i),Wp(e[7],i),Wp(s[3],a),Wp(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Ap||t===Dp,s[t].visible=a,e[t].visible=!o&&a}};zp=pe([fp()],zp);const{M:Yp,L:Np,C:Xp,Q:Hp,Z:Vp,N:Up,D:jp,X:Gp,G:Kp,F:Zp,O:qp,P:Jp,U:$p}=Me,Qp={scale(t,e,i){if(!t)return;let s,n=0,r=t.length;for(;n<r;)switch(s=t[n],s){case Yp:case Np:tf(t,e,i,n,1),n+=3;break;case Xp:tf(t,e,i,n,3),n+=7;break;case Hp:tf(t,e,i,n,2),n+=5;break;case Vp:n+=1;break;case Up:tf(t,e,i,n,2),n+=5;break;case jp:tf(t,e,i,n,2),n+=9;break;case Gp:tf(t,e,i,n,2),n+=6;break;case Kp:tf(t,e,i,n,2),n+=9;break;case Zp:tf(t,e,i,n,2),n+=5;break;case qp:t[n]=Kp,t.splice(n+4,0,t[n+3],0),tf(t,e,i,n,2),n+=9,r+=2;break;case Jp:t[n]=Zp,t.splice(n+4,0,t[n+3]),tf(t,e,i,n,2),n+=5,r+=1;break;case $p:tf(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:tf}=Qp,ef=Q.get(),{topLeft:sf,top:nf,topRight:rf,right:of,bottom:af,left:hf}=bt;function lf(t,e,i){t.pathInputed?df(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function df(t,e,i){Qp.scale(t.__.path,e,i),t.path=t.__.path}function cf(t,e,i){const{points:s}=t;c(s[0])?s.forEach(t=>{t.x*=e,t.y*=i}):Qp.scalePoints(s,e,i),t.points=s}function uf(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)ef.a=e,ef.d=i,s[t].transform(ef,!0)}const _f=oh.prototype;function gf(t,e,i){pf(t.parentApp?t.parentApp:t,e),t.isApp||i||t.__eventIds.push(t.on_(ec.BEFORE_MOVE,e=>{t.zoomLayer.move(t.getValidMove(e.moveX,e.moveY,!1))}),t.on_(ec.END,e=>{oo.animateMove(t.zoomLayer,t.getValidMove(e.moveX,e.moveY))}),t.on_(oc.BEFORE_ZOOM,e=>{const{zoomLayer:i}=t,s=t.getValidScale(e.scale);1!==s&&i.scaleOfWorld(e,s)}))}function pf(t,e){const i={wheel:{preventDefault:!0},touch:{preventDefault:!0},pointer:{preventDefaultMenu:!0}};e&&g.assign(i,e),g.assign(t.config,i,t.userConfig)}_f.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))},_f.__scaleResize=function(t,e){lf(this,t,e)},_f.resizeWidth=function(t){const e=t/this.getBounds("box","local").width||1;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},_f.resizeHeight=function(t){const e=t/this.getBounds("box","local").height||1;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},Rd.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 nf:case af:r=i,s.affectScaleOrRotation?t.moveInner(-o/2,0):t.x-=o/2;break;case hf:case of:s.affectScaleOrRotation?t.moveInner(0,-a/2):t.y-=a/2;break;case sf:case rf:s.affectScaleOrRotation?t.moveInner(0,-a):t.y-=a}}t.fontSize*=r;const o=t.__,{padding:a}=o;a&&(t.padding=d(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),lf(this,t,e)}},Od.prototype.__scaleResize=function(t,e){df(this,t,e)},vd.prototype.__scaleResize=function(t,e){this.pathInputed?df(this,t,e):this.points?cf(this,t,e):this.width*=t},nd.prototype.__scaleResize=function(t,e){this.pathInputed?df(this,t,e):this.points?cf(this,t,e):lf(this,t,e)},Dl.prototype.__scaleResize=function(t,e){uf(this,t,e)},Ul.prototype.__scaleResize=function(t,e){const{resizeChildren:i,__autoSize:s}=this.__;s&&i||lf(this,t,e),i&&uf(this,t,e)},oe.add("resize"),oe.add("editor","resize"),ae.editor=function(t,e){const i=new Lp(t);return e&&e.sky.add(e.editor=i),i},Ul.addAttr("textBox",!1,cr),Al.addAttr("editConfig",void 0,cr),Al.addAttr("editOuter",t=>(t.updateLayout(),t.__.__isLinePath?"LineEditTool":"EditTool"),cr),Al.addAttr("editInner","PathEditor",cr),Dl.addAttr("editInner","",cr),Rd.addAttr("editInner","TextEditor",cr),Al.setEditConfig=function(t){this.changeAttr("editConfig",t)},Al.setEditOuter=function(t){this.changeAttr("editOuter",t)},Al.setEditInner=function(t){this.changeAttr("editInner",t)};const ff=Qt.get("LeaferTypeCreator"),mf={list:{},register(t,e){yf[t]&&ff.repeat(t),yf[t]=e},run(t,e){const i=yf[t];i&&i(e)}},{list:yf,register:vf}=mf;vf("viewport",gf),vf("custom",function(t){gf(t,null,!0)}),vf("design",function(t){gf(t,{zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0}})}),vf("document",function(t){gf(t,{zoom:{min:1},move:{scroll:"limit"}})});const xf={state:{type:"none",typeCount:0,startTime:0,totalData:null,center:{}},getData(t){const e=t[0],i=t[1],s=dt.getCenter(e.from,i.from),n=dt.getCenter(e.to,i.to),r={x:n.x-s.x,y:n.y-s.y},o=dt.getDistance(e.from,i.from);return{move:r,scale:dt.getDistance(e.to,i.to)/o,rotation:dt.getRotation(e.from,i.from,e.to,i.to),center:n}},getType(t,e){const i=Math.hypot(t.move.x,t.move.y)/(e.move||5),s=Math.abs(t.scale-1)/(e.scale||.03),n=Math.abs(t.rotation)/(e.rotation||2);return i<1&&s<1&&n<1?"none":i>=s&&i>=n?"move":s>=n?"zoom":"rotate"},detect(t,e){const{state:i}=wf,s=wf.getType(t,e);if(i.totalData||(i.startTime=Date.now(),i.center=t.center),wf.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)?wf.getType(i.totalData,e):"none"},add(t,e){e&&(dt.move(t.move,e.move),t.scale*=e.scale,t.rotation+=e.rotation,t.center=e.center)},reset(){const{state:t}=wf;t.type="none",t.typeCount=0,t.startTime=0,t.totalData=null}},wf=xf,{abs:bf,max:kf}=Math,{sign:Ef,within:Sf}=F,Bf={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;t.shiftKey&&!s&&(s=n,n=0);const r=bf(s),o=bf(n);return r>50&&(s=kf(50,r/3)*Ef(s)),o>50&&(n=kf(50,o/3)*Ef(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&&(v.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=Sf(r,0,1);const i=t.deltaY?e.delta.y:e.delta.x,n=Sf(1-bf(o)/(4*i)*r,.5,2);s=o>0?n:1/n}return s}};let Tf,Rf,Of,Cf;class Lf{get transforming(){return this.moving||this.zooming||this.rotating}get moving(){return!!this.moveData}get zooming(){return!!this.zoomData}get rotating(){return!!this.rotateData}constructor(t){this.interaction=t}move(t){const{interaction:e}=this;t.moveType||(t.moveType="move"),this.moveData||(this.setPath(t),Tf=0,Rf=0,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0,totalX:Tf,totalY:Rf}),e.emit(ec.START,this.moveData)),t.path=this.moveData.path,t.totalX=Tf+=t.moveX,t.totalY=Rf+=t.moveY,e.emit(ec.BEFORE_MOVE,t),e.emit(ec.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;this.zoomData||(this.setPath(t),Of=1,this.zoomData=Object.assign(Object.assign({},t),{scale:1,totalScale:Of}),e.emit(oc.START,this.zoomData)),t.path=this.zoomData.path,t.totalScale=Of*=t.scale,e.emit(oc.BEFORE_ZOOM,t),e.emit(oc.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;this.rotateData||(this.setPath(t),Cf=0,this.rotateData=Object.assign(Object.assign({},t),{rotation:0,totalRotation:Cf}),e.emit(nc.START,this.rotateData)),t.path=this.rotateData.path,t.totalRotation=Cf+=t.rotation,e.emit(nc.BEFORE_ROTATE,t),e.emit(nc.ROTATE,t),this.transformEndWait()}setPath(t){const{interaction:e}=this,{path:i}=e.selector.getByPoint(t,e.hitRadius);t.path=i,e.cancelHover()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout(()=>{this.transformEnd()},this.interaction.p.transformTime)}transformEnd(){const{interaction:t,moveData:e,zoomData:i,rotateData:s}=this;e&&t.emit(ec.END,Object.assign(Object.assign({},e),{totalX:Tf,totalY:Rf})),i&&t.emit(oc.END,Object.assign(Object.assign({},i),{totalScale:Of})),s&&t.emit(nc.END,Object.assign(Object.assign({},s),{totalRotation:Cf})),this.reset()}reset(){this.zoomData=this.moveData=this.rotateData=null}destroy(){this.reset()}}const Pf=Fl.prototype,Mf=new Kt,Af=new pt;function Df(t,e){return Object.assign(Object.assign({},e),{moveX:t.x,moveY:t.y})}function If(t,e){return Object.assign(Object.assign({},e),{scale:t})}Pf.initType=function(t){mf.run(t,this)},Pf.getValidMove=function(t,e,i=!0){const{scroll:s,disabled:n}=this.app.config.move;if(Af.set(t,e),s){const t=!0===s?"":s;t.includes("x")?Af.y=0:t.includes("y")?Af.x=0:Math.abs(Af.x)>Math.abs(Af.y)?Af.y=0:Af.x=0,i&&t.includes("limit")&&(Mf.set(this.__world).addPoint(this.zoomLayer),Gd.getValidMove(Mf,this.canvas.bounds,"inner",Af,!0),t.includes("x")?Af.y=0:t.includes("y")&&(Af.x=0))}return{x:n?0:Af.x,y:n?0:Af.y}},Pf.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 Wf=Ec.prototype;Wf.createTransformer=function(){this.transformer=new Lf(this)},Wf.move=function(t){this.transformer.move(t)},Wf.zoom=function(t){this.transformer.zoom(t)},Wf.rotate=function(t){this.transformer.rotate(t)},Wf.transformEnd=function(){this.transformer.transformEnd()},Wf.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):Bf.getScale(t,e);if(1!==r)this.zoom(If(r,t));else{const s=e.getMove?e.getMove(t,e):Bf.getMove(t,e);i.snap&&dt.round(s),this.move(Df(s,t))}},Wf.multiTouch=function(t,e){const{disabled:i,singleGesture:s}=this.config.multiTouch;if(i)return;this.pointerWaitCancel();let n=xf.getData(e),{moving:r,zooming:o,rotating:a}=this.transformer;if(s){if(!this.transformer.transforming){switch(xf.detect(n,c(s)?s:{})){case"move":r=!0;break;case"zoom":o=!0;break;case"rotate":a=!0;break;default:return}xf.reset()}r||(n.center=xf.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(If(n.scale,t)),r&&this.move(Df(n.move,t))};const Ff=gc.prototype,{abs:zf}=Math;function Yf(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}Ff.checkDragEndAnimate=function(t,e){const{moveX:i,moveY:s}=this.dragData,n=zf(i),r=zf(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),dt.move(t,i*e,s*e),this.drag(t),this.animate(()=>{this.dragEnd(t,1)})}return h},Ff.animate=function(t,e){const i=t||this.animateWait;i&&this.interaction.target.nextRender(i,null,e),this.animateWait=t},Ff.checkDragOut=function(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)},Ff.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=Vt.maxX(o),d=Vt.maxY(o),c=t.x<a?n:l<t.x?-n:0,u=t.y<h?n:d<t.y?-n:0;let _=0,g=0;this.autoMoveTimer=setInterval(()=>{_+=c,g+=u,dt.move(i,c,u),dt.move(this.dragData,c,u),e.move(Object.assign(Object.assign({},t),{moveX:c,moveY:u,totalX:_,totalY:g,moveType:"drag"})),e.pointerMoveReal(t)},10)},Ff.autoMoveCancel=function(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)},oe.add("viewport"),oe.add("view"),Fl.prototype.zoom=function(t,e,i,s){let o;this.killAnimate(),u(e)?(o=e.padding,i=e.scroll,s=e.transition):o=e;const{zoomLayer:h}=this,l=this.canvas.bounds.clone().shrink(n(o)?30:o),_=new Kt,g={x:l.x+l.width/2,y:l.y+l.height/2};let p;const{x:f,y:m,scaleX:y,scaleY:v}=h.__;if(r(t))switch(t){case"in":p=Yf(y,"in");break;case"out":p=Yf(y,"out");break;case"fit":t=this.boxBounds;break;case"fit-width":(t=new Kt(this.boxBounds)).height=0;break;case"fit-height":(t=new Kt(this.boxBounds)).width=0}else a(t)&&(p=t/y);if(p)p=this.getValidScale(p),h.scaleOfWorld(g,p,p,!1,s);else if(c(t)){const e={x:f,y:m,scaleX:y,scaleY:v},n=d(t);if(n||t.tag){const e=n?t:[t];_.setListWithFn(e,po.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,l);_.set(h.getWorldBounds(e))}const{width:r,height:o}=_;let a=l.x-_.x,c=l.y-_.y;return i?(a+=Math.max((l.width-r)/2,0),c+=Math.max((l.height-o)/2,0)):(p=this.getValidScale(Math.min(l.width/r,l.height/o)),a+=(l.width-r*p)/2,c+=(l.height-o*p)/2,dt.scaleOf(e,_,p),_.scaleOf(_,p),e.scaleX*=p,e.scaleY*=p),"x"===i?c=0:"y"===i&&(a=0),dt.move(e,a,c),_.move(a,c),h.set(e,s),_}return h.worldBoxBounds};class Nf extends Dl{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&&g.assign(this.config,e),this.changeTheme(this.config.theme),this.waitLeafer(this.__listenEvents,this)}changeTheme(t){let e;r(t)?(e={fill:"black",stroke:"rgba(255,255,255,0.8)"},"dark"===t&&(e.fill="white",e.stroke="rgba(0,0,0,0.2)")):e=t,this.scrollXBar||this.addMany(this.scrollXBar=new Ul,this.scrollYBar=new Ul),e=Object.assign({strokeAlign:"center",opacity:.5,width:6,cornerRadius:3,hoverStyle:{opacity:.6},pressStyle:{opacity:.7}},e),e.height||(e.height=e.width),this.scrollXBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.scrollYBar.set(Object.assign(Object.assign({},e),{visible:!1})),this.leafer&&this.update()}update(t){if(this.dragScrolling)return;const{minSize:e,padding:i}=this.config,{zoomLayer:s,canvas:n}=this.target.leafer,{worldRenderBounds:r}=s;if(t&&this.scrollBounds&&this.scrollBounds.isSame(r))return;this.scrollBounds=new Kt(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,_=l<1,{scrollXBar:g,scrollYBar:p}=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}),p.set({x:f+y+2,y:m+v*c,height:Math.max(v*l,e),visible:_})}onDrag(t){this.dragScrolling=!0,this.__dragOut=this.app.config.move.dragOut,this.app.config.move.dragOut=!1;const e=t.current===this.scrollXBar,i=this.target.leafer.getValidMove(e?-t.moveX/this.ratioX:0,e?0:-t.moveY/this.ratioY);this.target.moveWorld(i.x,i.y),t.current.moveWorld(i.x&&-i.x*this.ratioX,i.y&&-i.y*this.ratioY)}onDragEnd(){this.dragScrolling=!1,this.app.config.move.dragOut=this.__dragOut}__listenEvents(){const{scrollXBar:t,scrollYBar:e}=this;this.__eventIds=[t.on_($d.DRAG,this.onDrag,this),e.on_($d.DRAG,this.onDrag,this),t.on_($d.END,this.onDragEnd,this),e.on_($d.END,this.onDragEnd,this),this.target.on_(Zo.BEFORE,()=>this.update(!0)),this.target.leafer.on_(jo.RESIZE,()=>this.update())]}__removeListenEvents(){this.off_(this.__eventIds)}destroy(){this.destroyed||(this.__removeListenEvents(),this.target=this.config=null,super.destroy())}}oe.add("scroll");class Xf extends pl{}function Hf(t){return hr(t,t=>({set(e){if(this.__setAttr(t,e)){const t=this.__,e="none"!==t.startArrow||"none"!==t.endArrow;t.__useArrow!==e&&vr(this),t.__useArrow=e,kr(this)}}}))}let Vf=class extends vd{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){Kh.register(t,e)}};pe([Wr(Xf)],Vf.prototype,"__",void 0),pe([Hf("angle")],Vf.prototype,"endArrow",void 0),Vf=pe([Gr()],Vf);const{M:Uf,L:jf,C:Gf,Q:Kf,O:Zf}=Me,{rotate:qf,copyFrom:Jf,scale:$f}=dt,Qf={},tm={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 Uf:case jf:em(t,l+1,e,i,s,n,r,o),l+=3;break;case Gf:for(h=1;h<6;h+=2)em(t,l+h,e,i,s,n,r,o);l+=7;break;case Kf:for(h=1;h<4;h+=2)em(t,l+h,e,i,s,n,r,o);l+=5;break;case Zf: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){tm.layout(t,0,0,1,1,e,i)}};function em(t,e,i,s,n,r,o,a){Jf(Qf,t[e],t[e+1]),o&&qf(Qf,o,a),n&&$f(Qf,n,r),t[e]=i+Qf.x,t[e+1]=s+Qf.y}const{layout:im,rotate:sm}=tm,{getAngle:nm}=dt,rm={x:-.5},om={connect:rm,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},am={connect:rm,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},hm={connect:rm,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]},lm={connect:rm,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]},dm={offset:rm,path:[...hm.path],dashPath:[1,-2.5,0,2,-1,0]};sm(dm.path,180,{x:-1.5,y:0});const cm={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},um={connect:{x:.5},path:[...cm.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},_m={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]},gm={path:[..._m.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},pm=g.clone(_m),fm=g.clone(gm);sm(pm.path,45),sm(fm.path,45);const mm={angle:om,"angle-side":am,arrow:lm,triangle:hm,"triangle-flip":dm,circle:um,"circle-line":cm,square:gm,"square-line":_m,diamond:fm,"diamond-line":pm,mark:{offset:rm,path:[1,0,-2,2,0,2]}};function ym(t,e,i,s,n,r,o){let a,h;const{strokeCap:l,strokeJoin:d}=t.__;c(e)?e.type?(h=e.scale,a=mm[e.type]):a=e:a=mm[e];const{offset:u,connect:_,path:g,dashPath:p}=a;let f=_?_.x:0,m=u?u.x:0;const y=[...g];return o&&p&&y.push(...p),"none"!==l&&(f-=.5),u&&("round"===d&&u.roundJoin?m+=u.roundJoin:"bevel"===d&&u.bevelJoin&&(m+=u.bevelJoin)),h&&im(y,0,0,h,h),m&&im(y,m,0),im(y,s.x,s.y,n,n,nm(i,s)),r.x=(f+m)*n,y}const{M:vm,L:xm,C:wm,Q:bm,Z:km,N:Em,D:Sm,X:Bm,G:Tm,F:Rm,O:Om,P:Cm,U:Lm}=Me,{copy:Pm,copyFrom:Mm,getDistancePoint:Am}=dt,Dm={},Im={},Wm={},Fm={},zm={},Ym={list:mm,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 vm:case xm:(c<2||l+6>=d)&&(Mm(zm,r[l+1],r[l+2]),!c&&u&&Pm(Im,zm)),l+=3;break;case wm:(1===c||l+7>=d-3)&&Nm(r,Fm,zm,l+3),l+=7;break;case bm:(1===c||l+5>=d-3)&&Nm(r,Fm,zm,l+1),l+=5;break;case km:return;case Em:l+=5;break;case Sm:l+=9;break;case Bm:l+=6;break;case Tm:l+=9;break;case Rm:l+=5;break;case Om:l+=7;break;case Cm:l+=4;break;case Lm:(1===c||l+6>=d-3)&&(Nm(r,Fm,zm,l+1),l+6!==d&&(zm.x-=(zm.x-Fm.x)/10,zm.y-=(zm.y-Fm.y)/10)),l+=6}if(c++,1===c&&h!==vm)return;if(2===c&&u&&Pm(Wm,h===xm?zm:Fm),l===d){const o=t.__.__pathForRender=a?[...r]:r,d=t.__.__pathForArrow=[];if(u){const i=ym(t,e,Wm,Im,s,Dm,!!n);n?d.push(...i):o.push(...i),Dm.x&&(Am(Im,Wm,-Dm.x,!0),o[1]=Wm.x,o[2]=Wm.y)}if(i&&"none"!==i){const e=ym(t,i,Fm,zm,s,Dm,!!n);if(n?d.push(...e):o.push(...e),Dm.x){let t;switch(Am(zm,Fm,-Dm.x,!0),h){case xm:t=l-3+1;break;case wm:t=l-7+5;break;case bm:t=l-5+3;break;case Lm:t=l-6+3}t&&Xm(o,Fm,t)}}}else Pm(Fm,zm)}},register(t,e){this.list[t]=e},get(t){return this.list[t]}};function Nm(t,e,i,s){Mm(e,t[s],t[s+1]),Mm(i,t[s+2],t[s+3])}function Xm(t,e,i){t[i]=e.x,t[i+1]=e.y}oe.add("arrow"),Al.addAttr("startArrow","none",Hf),Al.addAttr("endArrow","none",Hf),Object.assign(Kh,Ym),Object.assign(Zh,{strokeArrow(t,e,i,s){e.__.dashPattern&&(i.beginPath(),e.__drawPathByData(i,e.__.__pathForArrow),i.dashPattern=null,i.stroke())}});const{Yes:Hm,NoAndSkip:Vm,YesAndSkip:Um}=e,jm={},Gm={},Km={};class Zm{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"#":jm.id=t.substring(1),t=jm;break;case".":Gm.className=t.substring(1),t=Gm;break;default:Km.tag=t,t=Km}case"object":if(s(t.id)){if(t.tag){const{tag:s}=t,n=d(s);return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?g.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&&oo.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===Hm||r===Um){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&r<Vm&&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_(Do.REMOVE,this.__onRemoveChild,this),this.target.on_(Wo.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 qm=Al.prototype;function Jm(t){return t.leafer?t.leafer.selector:v.selector||(v.selector=ae.selector())}qm.find=function(t,e){return Jm(this).getBy(t,this,!1,e)},qm.findOne=function(t,e){return Jm(this).getBy(t,this,!0,e)},oe.add("find"),ae.finder=function(t){return new Zm(t)};const{setPoint:$m,addPoint:Qm,toBounds:ty}=vt;const ey={syncExport(t,e,i){let n;tl.running=!0;try{const r=jn.fileType(e),o=e.includes(".");i=jn.getExportOptions(i);const{toURL:a}=v,{download:h}=v.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:_,clip:g,trim:p,screenshot:f,padding:m,onCanvas:y}=i,x=s(i.smooth)?!c||c.config.smooth:i.smooth,w=i.contextSettings||(c?c.config.contextSettings:void 0),b=d&&f&&s(i.fill)?t.fill:i.fill,k=jn.isOpaqueImage(e)||b,E=new mt;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":E.set(l);break;case"local":E.set(l).divide(t.localTransform),a/=t.scaleX,h/=t.scaleY;break;case"world":a=1,h=1;break;case"page":e=c||t;default:E.set(l).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,h/=h/i.scaleY}r=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};F.getScaleData(i.scale,i.size,r,S);let B=i.pixelRatio||1,{x:T,y:R,width:O,height:C}=new Kt(r).scale(S.scaleX,S.scaleY);g&&(T+=g.x,R+=g.y,O=g.width,C=g.height);const L={exporting:!0,matrix:E.scale(1/S.scaleX,1/S.scaleY).invert().translate(-T,-R).withScale(1/a*S.scaleX,1/h*S.scaleY)};let P,M=ae.canvas({width:Math.floor(O),height:Math.floor(C),pixelRatio:B,smooth:x,contextSettings:w});_&&(P=t,P.__worldOpacity=0,t=c||t,L.bounds=M.bounds),M.save();const A=u&&!s(b),D=t.get("fill");if(A&&(t.fill=""),v.render(t,M,L),A&&(t.fill=D),M.restore(),P&&P.__updateWorldOpacity(),p){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?Qm(o,n,r):$m(o={},n,r)),a++;const h=new Kt;return o&&(ty(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=ae.canvas(s),M.copyWorld(t,o,s),t.destroy()}if(m){const[t,e,i,s]=F.fourNumber(m),n=M,{width:r,height:o}=n;M=ae.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()}k&&M.fillWorld(M.bounds,b||"#FFFFFF","destination-over"),y&&y(M);n={data:"canvas"===e?M:M.export(e,i),width:M.pixelWidth,height:M.pixelHeight,renderBounds:r,trimBounds:o};const I=c&&c.app;I&&I.canvasManager&&I.canvasManager.clearRecycled()}}catch(t){n={data:"",error:t}}return tl.running=!1,n},export(t,e,i){return tl.running=!0,function(t){iy||(iy=new qn);return new Promise(e=>{iy.add(()=>fe(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const r=()=>fe(this,void 0,void 0,function*(){if(!$n.isComplete)return v.requestRender(r);const o=tl.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),sy(t);const{leafer:o}=t;o?o.waitViewCompleted(r):r()}))}};let iy;function sy(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>sy(t))}const ny=Ce.prototype,ry=Qt.get("@leafer-in/export");ny.export=function(t,e){const{quality:i,blob:s}=jn.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ny.toBlob=function(t,e){return new Promise(i=>{v.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{ry.error(t),i(null)})})},ny.toDataURL=function(t,e){return v.origin.canvasToDataURL(this.view,t,e)},ny.saveAs=function(t,e){return new Promise(i=>{v.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{ry.error(t),i(!1)})})},oe.add("export"),Object.assign(tl,ey),Al.prototype.export=function(t,e){return tl.export(this,t,e)},Al.prototype.syncExport=function(t,e){return tl.syncExport(this,t,e)};const oy={none:"none",title:"capitalize",upper:"uppercase",lower:"lowercase","small-caps":"small-caps"},ay={top:"flex-start",middle:"center",bottom:"flex-end"},hy={none:"none",under:"underline",delete:"line-through","under-delete":"underline line-through"};function ly(t,e,i){const{style:n}=t,{fill:o,padding:a,textWrap:h,textOverflow:l,textDecoration:u}=e;let _;n.fontFamily=e.fontFamily,n.fontSize=e.fontSize*i+"px",function(t,e){let i="black";d(e)&&(e=e[0]);if(c(e))switch(e.type){case"solid":i=jh.string(e.color);break;case"image":break;case"linear":case"radial":case"angular":const t=e.stops[0];i=jh.string(r(t)?t:t.color);break;default:s(e.r)||(i=jh.string(e))}else i=e;t.color=i}(n,o),n.fontStyle=e.italic?"italic":"normal",n.fontWeight=e.fontWeight,c(u)?(_=u.type,u.color&&(n.textDecorationColor=jh.string(u.color))):_=u,n.textDecoration=hy[_],n.textTransform=oy[e.textCase],n.textAlign="both"===e.textAlign?"justify":e.textAlign,n.display="flex",n.flexDirection="column",n.justifyContent=ay[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=d(a)?a.map(t=>t*i+"px").join(" "):(a||0)*i+"px",n.textOverflow="show"===l?"":"hide"===l?"clip":l}let dy=class extends Pp{constructor(){super(...arguments),this.config={selectAll:!0},this.eventIds=[]}get tag(){return"TextEditor"}onLoad(){const{editor:t}=this,{config:e}=t.app,i=this.editTarget;i.textEditing=!0,this.isHTMLText=!(i instanceof Rd),this._keyEvent=e.keyEvent,e.keyEvent=!1;const s=this.editDom=document.createElement("div");s.classList.add("leafer-text-editor");const{style:n}=s;s.contentEditable="true",n.position="fixed",n.transformOrigin="left top",n.boxSizing="border-box",this.isHTMLText?s.innerHTML=String(i.text):s.innerText=String(i.text);const{view:r}=t.app;(this.inBody=r instanceof HTMLCanvasElement)?document.body.appendChild(s):r.appendChild(s),this.eventIds=[t.app.on_(Zd.DOWN,e=>{let i,{target:n}=e.origin;for(;n;)n===s&&(i=!0),n=n.parentElement;i||t.closeInnerEditor()})],this.onFocus=this.onFocus.bind(this),this.onInput=this.onInput.bind(this),this.onPaste=this.onPaste.bind(this),this.onUpdate=this.onUpdate.bind(this),this.onKeydown=this.onKeydown.bind(this),s.addEventListener("focus",this.onFocus),s.addEventListener("input",this.onInput),s.addEventListener("paste",this.onPaste),window.addEventListener("keydown",this.onKeydown),window.addEventListener("scroll",this.onUpdate);const o=window.getSelection(),a=document.createRange();if(this.config.selectAll)a.selectNodeContents(s);else{const t=s.childNodes[0];t&&(a.setStartAfter(t),a.setEndAfter(t)),a.collapse(!0)}o.removeAllRanges(),o.addRange(a)}onInput(){const{editDom:t}=this;this.editTarget.text=this.isHTMLText?t.innerHTML:t.innerText}onFocus(){this.editDom.style.outline="none"}onKeydown(t){if("Escape"===t.code&&this.editor.closeInnerEditor(),"Enter"===t.key){t.preventDefault();const e=document.createElement("br"),i=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:_,f:g}=new mt(t.worldTransform).scale(1/e).translateInner(n,r),{style:p}=this.editDom;p.transform=`matrix(${l},${d},${c},${u},${_},${g})`,p.left=a+"px",p.top=h+"px",p.width=i+"px",p.height=s+"px",this.isHTMLText||ly(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)}};dy=pe([mp()],dy),oe.add("text-editor","editor");class cy extends El{setText(t){this._text=t,this.__htmlChanged=!0}}const uy={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:"≥"};let _y=class extends xd{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=uy[e],void 0!==i)){s+=i,n=r+1;continue}}s+=t[n++]}return s}static addUnicodeEntity(t,e){r(t)?uy[t]=e:Object.assign(uy,t)}};pe([Wr(cy)],_y.prototype,"__",void 0),pe([mr("")],_y.prototype,"text",void 0),pe([cr("TextEditor")],_y.prototype,"editInner",void 0),pe([Br(!1)],_y.prototype,"textEditing",void 0),_y=pe([Gr()],_y),oe.add("html");export{Tt as AlignHelper,e as Answer,Ld as App,Et as AroundHelper,Vf as Arrow,Xf as ArrowData,qt as AutoBounds,oi as BezierHelper,Kt as Bounds,Yo as BoundsEvent,Vt as BoundsHelper,Ul as Box,ul as BoxData,fh as Branch,vo as BranchHelper,Aa as BranchRender,bd as Canvas,Sl as CanvasData,ge as CanvasManager,Do as ChildEvent,jh as ColorConvert,ae as Creator,Sc as Cursor,g as DataHelper,Qt as Debug,wt as Direction4,bt as Direction9,Gd as DragBoundsHelper,$d as DragEvent,gc as Dragger,tc as DropEvent,rp as EditBox,Jg as EditDataHelper,ip as EditPoint,Fg as EditSelect,Ag as EditSelectHelper,Mp as EditTool,yp as EditToolCreator,Lp as Editor,kg as EditorEvent,wp as EditorGroupEvent,gp as EditorHelper,Bp as EditorMoveEvent,Rp as EditorRotateEvent,Tp as EditorScaleEvent,Op as EditorSkewEvent,$h as Effect,ql as Ellipse,ml as EllipseData,pi as EllipseHelper,Ao as Event,ue as EventCreator,sa as Eventer,tl as Export,jn as FileHelper,Qh as Filter,Zm as Finder,R as FourNumberHelper,jl as Frame,gl as FrameData,Dl as Group,cl as GroupData,_y as HTMLText,cy as HTMLTextData,Bc as HitCanvasManager,xd as Image,El as ImageData,zo as ImageEvent,tr as ImageManager,w as IncrementId,Pp as InnerEditor,xp as InnerEditorEvent,Ec as InteractionBase,hc as InteractionHelper,ac as KeyEvent,Md as Keyboard,Ko as LayoutEvent,Dh as Layouter,oh as Leaf,La as LeafBounds,po as LeafBoundsHelper,f as LeafData,fa as LeafDataProxy,ga as LeafEventer,oo as LeafHelper,Mo as LeafLayout,yh as LeafLevelList,mh as LeafList,ka as LeafMatrix,Pa as LeafRender,Fl as Leafer,xh as LeaferCanvas,Ce as LeaferCanvasBase,_l as LeaferData,qo as LeaferEvent,nr as LeaferImage,mf as LeaferTypeCreator,vd as Line,pl as LineData,zp as LineEditTool,F as MathHelper,mt as Matrix,Q as MatrixHelper,ec as MoveEvent,xf as MultiTouchHelper,Qd as MyDragEvent,wd as MyImage,qd as MyPointerEvent,sc as MyTouchEvent,De as NeedConvertToCanvasCommandMap,Y as OneRadian,N as PI2,X as PI_2,Zh as Paint,Jh as PaintGradient,qh as PaintImage,Od as Path,Kh as PathArrow,Ym as PathArrowModule,An as PathBounds,ks as PathCommandDataHelper,Me as PathCommandMap,fi as PathCommandNodeHelper,ts as PathConvert,Nn as PathCorner,Ys as PathCreator,xl as PathData,en as PathDrawer,Le as PathHelper,tm as PathMatrixHelper,t as PathNodeHandleType,ze as PathNumberCommandLengthMap,Fe as PathNumberCommandMap,Cd as Pen,wl as PenData,zh as Picker,v as Platform,oe as Plugin,pt as Point,dt as PointHelper,Ad as PointerButton,Zd as PointerEvent,nd as Polygon,yl as PolygonData,Wo as PropertyEvent,zl as Rect,fl as RectData,Ye as RectHelper,Pl as RectRender,Zo as RenderEvent,Wh as Renderer,jo as ResizeEvent,$n as Resource,nc as RotateEvent,se as Run,Nf as ScrollBar,Mg as SelectArea,Yh as Selector,cd as Star,vl as StarData,el as State,Jt as StringNumberMap,Pg as Stroker,rc as SwipeEvent,Zn as TaskItem,qn as TaskProcessor,Rd as Text,Uh as TextConvert,kl as TextData,dy as TextEditor,ic as TouchEvent,Cp as TransformTool,Lf as Transformer,il as Transition,vt as TwoPointBoundsHelper,Al as UI,Rl as UIBounds,le as UICreator,ll as UIData,Dd as UIEvent,Cl as UIRender,Gh as UnitConvert,ko as WaitHelper,Go as WatchEvent,Eh as Watcher,Bf as WheelEventHelper,oc as ZoomEvent,gf as addViewport,pf as addViewportConfig,Sr as affectRenderBoundsType,br as affectStrokeBoundsType,Hf as arrowType,lr as attr,gr as autoLayoutType,mr as boundsType,Un as canvasPatch,Oe as canvasSizeAttrs,Vh as createAttr,ar as createDescriptor,Ir as cursorType,Wr as dataProcessor,cr as dataType,hr as decorateLeafAttr,zr as defineDataProcessor,rr as defineKey,dr as defineLeafAttr,Tr as dimType,vr as doBoundsType,kr as doStrokeType,Nh as effectType,i as emptyData,Ar as eraserType,Fo as extraPropertyEventMap,V as getBoundsData,or as getDescriptor,U as getMatrixData,H as getPointData,Dr as hitType,d as isArray,u as isData,_ as isEmptyData,o as isFinite,n as isNull,a as isNumber,c as isObject,r as isString,s as isUndefined,Fr as layoutProcessor,ea as leaferTransformAttrMap,Mr as maskType,yr as naturalBoundsType,Rr as opacityType,Xn as path,xr as pathInputType,wr as pathType,Hn as pen,ur as positionType,fp as registerEditTool,mp as registerInnerEditor,Gr as registerUI,Kr as registerUIEvent,Xh as resizeType,Hr as rewrite,Vr as rewriteAble,fr as rotationType,pr as scaleType,_r as scrollType,Pr as sortType,Er as strokeType,Br as surfaceType,Zt as tempBounds,yt as tempMatrix,ft as tempPoint,l as tryToNumber,bh as useCanvas,jr as useModule,vh as version,Or as visibleType,Hh as zoomLayerType};
2
2
  //# sourceMappingURL=worker.module.min.js.map