@leafer/core 1.9.1 → 1.9.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.
package/lib/core.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";const t={toURL(t,e){let s=encodeURIComponent(t);return"text"===e?s="data:text/plain;charset=utf-8,"+s:"svg"===e&&(s="data:image/svg+xml,"+s),s},image:{hitCanvasSize:100,maxCacheSize:4096e3,maxPatternSize:8847360,crossOrigin:"anonymous",getRealURL(e){const{prefix:s,suffix:r}=t.image;return!r||e.startsWith("data:")||e.startsWith("blob:")||(e+=(e.includes("?")?"&":"?")+r),s&&"/"===e[0]&&(e=s+e),e}}},e={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=s;return e[t]?e[t]++:(e[t]=1,0)}},s=e;var r;exports.Answer=void 0,(r=exports.Answer||(exports.Answer={}))[r.No=0]="No",r[r.Yes=1]="Yes",r[r.NoAndSkip=2]="NoAndSkip",r[r.YesAndSkip=3]="YesAndSkip";function i(t){return void 0===t}function n(t){return null==t}function o(t){return"string"==typeof t}const{isFinite:a}=Number;function h(t){return"number"==typeof t}const l=/^-?\d+(?:\.\d+)?$/;const{isArray:d}=Array;function u(t){return t&&"object"==typeof t}function c(t){return"{}"===JSON.stringify(t)}const p={default:(t,e)=>(_(e,t),_(t,e),t),assign(t,e,s){let r;Object.keys(e).forEach(i=>{var n,o;if(r=e[i],(null==r?void 0:r.constructor)===Object&&(null===(n=t[i])||void 0===n?void 0:n.constructor)===Object)return _(t[i],e[i],s&&s[i]);s&&i in s?(null===(o=s[i])||void 0===o?void 0:o.constructor)===Object&&_(t[i]={},e[i],s[i]):t[i]=e[i]})},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 s=0,r=t.length;s<r;s++)e[t[s]]=!0;return e},stintSet(t,e,s){s||(s=void 0),t[e]!==s&&(t[e]=s)}},{assign:_}=p;class f{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(!i(e))return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let s;for(let r in this)"_"!==r[0]&&(s=e?e[r]:void 0,t[r]=i(s)?this[r]: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(d(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:r}=this;s.tag=this.__leaf.tag;for(let n in this)if("_"!==n[0]&&(t=this["_"+n],!i(t))){if("path"===n&&!this.__pathInputed)continue;e=r?r[n]:void 0,s[n]=i(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:r,d:i,e:n,f:o}=this.__leaf.__localMatrix;s.matrix={a:t,b:e,c:r,d:i,e:n,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{round:g,pow:y,PI:x}=Math,m={within:(t,e,s)=>(u(e)&&(s=e.max,e=e.min),!i(e)&&t<e&&(t=e),!i(s)&&t>s&&(t=s),t),fourNumber(t,e){let s;if(d(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]),e)for(let t=0;t<4;t++)s[t]>e&&(s[t]=e);return s},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),m.float(t)),getGapRotation(t,e,s=0){let r=t+s;if(e>1){const t=Math.abs(r%e);(t<1||t>e-1)&&(r=Math.round(r/e)*e)}return r-s},float(t,e){const s=i(e)?1e12:y(10,e);return-0===(t=g(t*s)/s)?0:t},getScaleData(t,e,s,r){if(r||(r={}),e){const t=(h(e)?e:e.width||0)/s.width,i=(h(e)?e:e.height||0)/s.height;r.scaleX=t||i||1,r.scaleY=i||t||1}else t&&m.assignScale(r,t);return r},assignScale(t,e){h(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},randInt:w,randColor:t=>`rgba(${w(255)},${w(255)},${w(255)},${t||1})`};function w(t){return Math.round(Math.random()*t)}const b=x/180,B=2*x,v=x/2;function k(){return{x:0,y:0}}function C(){return{x:0,y:0,width:0,height:0}}function T(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:O,cos:P,acos:L,sqrt:S}=Math,{float:R}=m,E={};function I(){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 M={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:I(),tempMatrix:{},set(t,e=1,s=0,r=0,i=1,n=0,o=0){t.a=e,t.b=s,t.c=r,t.d=i,t.e=n,t.f=o},get:T,getWorld:I,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,s){t.e+=e,t.f+=s},translateInner(t,e,s,r){t.e+=t.a*e+t.c*s,t.f+=t.b*e+t.d*s,r&&(t.e-=e,t.f-=s)},scale(t,e,s=e){t.a*=e,t.b*=e,t.c*=s,t.d*=s},scaleOfOuter(t,e,s,r){A.toInnerPoint(t,e,E),A.scaleOfInner(t,E,s,r)},scaleOfInner(t,e,s,r=s){A.translateInner(t,e.x,e.y),A.scale(t,s,r),A.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:s,b:r,c:i,d:n}=t,o=P(e*=b),a=O(e);t.a=s*o-r*a,t.b=s*a+r*o,t.c=i*o-n*a,t.d=i*a+n*o},rotateOfOuter(t,e,s){A.toInnerPoint(t,e,E),A.rotateOfInner(t,E,s)},rotateOfInner(t,e,s){A.translateInner(t,e.x,e.y),A.rotate(t,s),A.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:r,b:i,c:n,d:o}=t;s&&(s*=b,t.a=r+n*s,t.b=i+o*s),e&&(e*=b,t.c=n+r*e,t.d=o+i*e)},skewOfOuter(t,e,s,r){A.toInnerPoint(t,e,E),A.skewOfInner(t,E,s,r)},skewOfInner(t,e,s,r=0){A.translateInner(t,e.x,e.y),A.skew(t,s,r),A.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:r,c:i,d:n,e:o,f:a}=t;t.a=e.a*s+e.b*i,t.b=e.a*r+e.b*n,t.c=e.c*s+e.d*i,t.d=e.c*r+e.d*n,t.e=e.e*s+e.f*i+o,t.f=e.e*r+e.f*n+a},multiplyParent(t,e,s,r,n,o){let{e:a,f:h}=t;if(o&&(a+=o.scrollX,h+=o.scrollY),s||(s=t),i(r)&&(r=1!==t.a||t.b||t.c||1!==t.d),r){const{a:r,b:i,c:o,d:a}=t;s.a=r*e.a+i*e.c,s.b=r*e.b+i*e.d,s.c=o*e.a+a*e.c,s.d=o*e.b+a*e.d,n&&(s.scaleX=e.scaleX*n.scaleX,s.scaleY=e.scaleY*n.scaleY)}else s.a=e.a,s.b=e.b,s.c=e.c,s.d=e.d,n&&(s.scaleX=e.scaleX,s.scaleY=e.scaleY);s.e=a*e.a+h*e.c+e.e,s.f=a*e.b+h*e.d+e.f},divide(t,e){A.multiply(t,A.tempInvert(e))},divideParent(t,e){A.multiplyParent(t,A.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=A;return A.copy(e,t),A.invert(e),e},invert(t){const{a:e,b:s,c:r,d:i,e:n,f:o}=t;if(s||r){const a=1/(e*i-s*r);t.a=i*a,t.b=-s*a,t.c=-r*a,t.d=e*a,t.e=-(n*i-o*r)*a,t.f=-(o*e-n*s)*a}else if(1===e&&1===i)t.e=-n,t.f=-o;else{const s=1/(e*i);t.a=i*s,t.d=e*s,t.e=-n*i*s,t.f=-o*e*s}},toOuterPoint(t,e,s,r){const{x:i,y:n}=e;s||(s=e),s.x=i*t.a+n*t.c,s.y=i*t.b+n*t.d,r||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,r){const{a:i,b:n,c:o,d:a}=t,h=1/(i*a-n*o),{x:l,y:d}=e;if(s||(s=e),s.x=(l*a-d*o)*h,s.y=(d*i-l*n)*h,!r){const{e:e,f:r}=t;s.x-=(e*a-r*o)*h,s.y-=(r*i-e*n)*h}},setLayout(t,e,s,r,n){const{x:o,y:a,scaleX:h,scaleY:l}=e;if(i(n)&&(n=e.rotation||e.skewX||e.skewY),n){const{rotation:s,skewX:r,skewY:i}=e,n=s*b,o=P(n),a=O(n);if(r||i){const e=r*b,s=i*b;t.a=(o+s*-a)*h,t.b=(a+s*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||r)&&A.translateInner(t,-s.x,-s.y,!r)},getLayout(t,e,s,r){const{a:i,b:n,c:o,d:a,e:h,f:l}=t;let d,u,c,p,_,f=h,g=l;if(n||o){const t=i*a-n*o;if(o&&!r){d=S(i*i+n*n),u=t/d;const e=i/d;c=n>0?L(e):-L(e)}else{u=S(o*o+a*a),d=t/u;const e=o/u;c=v-(a>0?L(-e):-L(e))}const e=R(P(c)),s=O(c);d=R(d),u=R(u),p=e?R((o/u+s)/e/b,9):0,_=e?R((n/d-s)/e/b,9):0,c=R(c/b)}else d=i,u=a,c=p=_=0;return(e=s||e)&&(f+=e.x*i+e.y*o,g+=e.x*n+e.y*a,s||(f-=e.x,g-=e.y)),{x:f,y:g,scaleX:d,scaleY:u,rotation:c,skewX:p,skewY:_}},withScale(t,e,s=e){const r=t;if(!e||!s){const{a:r,b:i,c:n,d:o}=t;i||n?s=(r*o-i*n)/(e=S(r*r+i*i)):(e=r,s=o)}return r.scaleX=e,r.scaleY=s,r},reset(t){A.set(t)}},A=M,{toInnerPoint:W,toOuterPoint:D}=M,{sin:N,cos:Y,abs:X,sqrt:z,atan2:F,min:H,round:U}=Math,j={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},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,s){t.x=e,t.y=s},round(t,e){t.x=e?U(t.x-.5)+.5:U(t.x),t.y=e?U(t.y-.5)+.5:U(t.y)},move(t,e,s){u(e)?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=s)},scale(t,e,s=e){t.x&&(t.x*=e),t.y&&(t.y*=s)},scaleOf(t,e,s,r=s){t.x+=(t.x-e.x)*(s-1),t.y+=(t.y-e.y)*(r-1)},rotate(t,e,s){s||(s=G.defaultPoint);const r=Y(e*=b),i=N(e),n=t.x-s.x,o=t.y-s.y;t.x=s.x+n*r-o*i,t.y=s.y+n*i+o*r},tempToInnerOf(t,e){const{tempPoint:s}=G;return q(s,t),W(e,s,s),s},tempToOuterOf(t,e){const{tempPoint:s}=G;return q(s,t),D(e,s,s),s},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:s}=G;return q(s,t),G.toInnerRadiusPointOf(t,e,s),s},toInnerRadiusPointOf(t,e,s){s||(s=t),W(e,t,s),s.radiusX=Math.abs(t.radiusX/e.scaleX),s.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,s){W(e,t,s)},toOuterOf(t,e,s){D(e,t,s)},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)=>V(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,s,r){const i=X(s-t),n=X(r-e);return z(i*i+n*n)},getMinDistanceFrom:(t,e,s,r,i,n)=>H(V(t,e,s,r),V(s,r,i,n)),getAngle:(t,e)=>Q(t,e)/b,getRotation:(t,e,s,r)=>(r||(r=e),G.getRadianFrom(t.x,t.y,e.x,e.y,s.x,s.y,r.x,r.y)/b),getRadianFrom(t,e,s,r,n,o,a,h){i(a)&&(a=s,h=r);const l=t-s,d=e-r,u=n-a,c=o-h;return Math.atan2(l*c-d*u,l*u+d*c)},getAtan2:(t,e)=>F(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s,r){const i=Q(t,e);return(e=r?e:{}).x=t.x+Y(i)*s,e.y=t.y+N(i)*s,e},toNumberPoints(t){let e=t;return u(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},reset(t){G.reset(t)}},G=j,{getDistanceFrom:V,copy:q,getAtan2:Q}=G;class J{constructor(t,e){this.set(t,e)}set(t,e){return u(t)?j.copy(this,t):j.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new J(this)}move(t,e){return j.move(this,t,e),this}scale(t,e){return j.scale(this,t,e),this}scaleOf(t,e,s){return j.scaleOf(this,t,e,s),this}rotate(t,e){return j.rotate(this,t,e),this}rotateOf(t,e){return j.rotate(this,e,t),this}getRotation(t,e,s){return j.getRotation(this,t,e,s)}toInnerOf(t,e){return j.toInnerOf(this,t,e),this}toOuterOf(t,e){return j.toOuterOf(this,t,e),this}getCenter(t){return new J(j.getCenter(this,t))}getDistance(t){return j.getDistance(this,t)}getDistancePoint(t,e,s){return new J(j.getDistancePoint(this,t,e,s))}getAngle(t){return j.getAngle(this,t)}getAtan2(t){return j.getAtan2(this,t)}reset(){return j.reset(this),this}}const Z=new J;class ${constructor(t,e,s,r,i,n){this.set(t,e,s,r,i,n)}set(t,e,s,r,i,n){return u(t)?M.copy(this,t):M.set(this,t,e,s,r,i,n),this}setWith(t){return M.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:s,d:r,e:i,f:n}=this;return{a:t,b:e,c:s,d:r,e:i,f:n}}clone(){return new $(this)}translate(t,e){return M.translate(this,t,e),this}translateInner(t,e){return M.translateInner(this,t,e),this}scale(t,e){return M.scale(this,t,e),this}scaleWith(t,e){return M.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}scaleOfOuter(t,e,s){return M.scaleOfOuter(this,t,e,s),this}scaleOfInner(t,e,s){return M.scaleOfInner(this,t,e,s),this}rotate(t){return M.rotate(this,t),this}rotateOfOuter(t,e){return M.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return M.rotateOfInner(this,t,e),this}skew(t,e){return M.skew(this,t,e),this}skewOfOuter(t,e,s){return M.skewOfOuter(this,t,e,s),this}skewOfInner(t,e,s){return M.skewOfInner(this,t,e,s),this}multiply(t){return M.multiply(this,t),this}multiplyParent(t){return M.multiplyParent(this,t),this}divide(t){return M.divide(this,t),this}divideParent(t){return M.divideParent(this,t),this}invert(){return M.invert(this),this}invertWith(){return M.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,s){M.toOuterPoint(this,t,e,s)}toInnerPoint(t,e,s){M.toInnerPoint(this,t,e,s)}setLayout(t,e,s){return M.setLayout(this,t,e,s),this}getLayout(t,e,s){return M.getLayout(this,t,e,s)}withScale(t,e){return M.withScale(this,t,e)}reset(){M.reset(this)}}const K=new $,tt={tempPointBounds:{},setPoint(t,e,s){t.minX=t.maxX=e,t.minY=t.maxY=s},addPoint(t,e,s){t.minX=e<t.minX?e:t.minX,t.minY=s<t.minY?s:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=s>t.maxY?s:t.maxY},addBounds(t,e,s,r,i){et(t,e,s),et(t,e+r,s+i)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:et}=tt;var st,rt;exports.Direction4=void 0,(st=exports.Direction4||(exports.Direction4={}))[st.top=0]="top",st[st.right=1]="right",st[st.bottom=2]="bottom",st[st.left=3]="left",exports.Direction9=void 0,(rt=exports.Direction9||(exports.Direction9={}))[rt.topLeft=0]="topLeft",rt[rt.top=1]="top",rt[rt.topRight=2]="topRight",rt[rt.right=3]="right",rt[rt.bottomRight=4]="bottomRight",rt[rt.bottom=5]="bottom",rt[rt.bottomLeft=6]="bottomLeft",rt[rt.left=7]="left",rt[rt.center=8]="center",rt[rt["top-left"]=0]="top-left",rt[rt["top-right"]=2]="top-right",rt[rt["bottom-right"]=4]="bottom-right",rt[rt["bottom-left"]=6]="bottom-left";const it=[{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}];it.forEach(t=>t.type="percent");const nt={directionData:it,tempPoint:{},get:ot,toPoint(t,e,s,r,i,n){const o=ot(t);s.x=o.x,s.y=o.y,"percent"===o.type&&(s.x*=e.width,s.y*=e.height,i&&(n||(s.x-=i.x,s.y-=i.y),o.x&&(s.x-=1===o.x?i.width:.5===o.x?o.x*i.width:0),o.y&&(s.y-=1===o.y?i.height:.5===o.y?o.y*i.height:0))),r||(s.x+=e.x,s.y+=e.y)},getPoint:(t,e,s)=>(s||(s={}),nt.toPoint(t,e,s,!0),s)};function ot(t){return o(t)?it[exports.Direction9[t]]:t}const{toPoint:at}=nt,ht={toPoint(t,e,s,r,i,n){at(t,s,r,i,e,n)}},{tempPointBounds:lt,setPoint:dt,addPoint:ut,toBounds:ct}=tt,{toOuterPoint:pt}=M,{float:_t,fourNumber:ft}=m,{floor:gt,ceil:yt}=Math;let xt,mt,wt,bt;const Bt={},vt={},kt={},Ct={tempBounds:kt,set(t,e=0,s=0,r=0,i=0){t.x=e,t.y=s,t.width=r,t.height=i},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s,r,i){const{x:n,y:o,width:a,height:h}=e;if(d(s)){const e=ft(s);r?Tt.set(t,n+e[3],o+e[0],a-e[1]-e[3],h-e[2]-e[0]):Tt.set(t,n-e[3],o-e[0],a+e[1]+e[3],h+e[2]+e[0])}else r&&(s=-s),Tt.set(t,n-s,o-s,a+2*s,h+2*s);i&&("width"===i?(t.y=o,t.height=h):(t.x=n,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,s){t.x+=e,t.y+=s},getByMove:(t,e,s)=>(t=Object.assign({},t),Tt.move(t,e,s),t),toOffsetOutBounds(t,e,s){e?Pt(e,t):e=t,s?(e.offsetX=-(Tt.maxX(s)-t.x),e.offsetY=-(Tt.maxY(s)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),Tt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,s=e,r){r||j.scale(t,e,s),t.width*=e,t.height*=s},scaleOf(t,e,s,r=s){j.scaleOf(t,e,s,r),t.width*=s,t.height*=r},tempToOuterOf:(t,e)=>(Tt.copy(kt,t),Tt.toOuterOf(kt,e),kt),getOuterOf:(t,e)=>(t=Object.assign({},t),Tt.toOuterOf(t,e),t),toOuterOf(t,e,s){if(s||(s=t),0===e.b&&0===e.c){const{a:r,d:i}=e;r>0?(s.width=t.width*r,s.x=e.e+t.x*r):(s.width=t.width*-r,s.x=e.e+t.x*r-s.width),i>0?(s.height=t.height*i,s.y=e.f+t.y*i):(s.height=t.height*-i,s.y=e.f+t.y*i-s.height)}else Bt.x=t.x,Bt.y=t.y,pt(e,Bt,vt),dt(lt,vt.x,vt.y),Bt.x=t.x+t.width,pt(e,Bt,vt),ut(lt,vt.x,vt.y),Bt.y=t.y+t.height,pt(e,Bt,vt),ut(lt,vt.x,vt.y),Bt.x=t.x,pt(e,Bt,vt),ut(lt,vt.x,vt.y),ct(lt,s)},toInnerOf(t,e,s){s||(s=t),Tt.move(s,-e.e,-e.f),Tt.scale(s,1/e.a,1/e.d)},getFitMatrix(t,e,s=1){const r=Math.min(s,Tt.getFitScale(t,e));return new $(r,0,0,r,-e.x*r,-e.y*r)},getFitScale(t,e,s){const r=t.width/e.width,i=t.height/e.height;return s?Math.max(r,i):Math.min(r,i)},put(t,e,s="center",r=1,i=!0,n){n||(n=e),o(r)&&(r=Tt.getFitScale(t,e,"cover"===r)),kt.width=i?e.width*=r:e.width*r,kt.height=i?e.height*=r:e.height*r,ht.toPoint(s,kt,t,n,!0,!0)},getSpread(t,e,s){const r={};return Tt.copyAndSpread(r,t,e,!1,s),r},spread(t,e,s){Tt.copyAndSpread(t,t,e,!1,s)},shrink(t,e,s){Tt.copyAndSpread(t,t,e,!0,s)},ceil(t){const{x:e,y:s}=t;t.x=gt(t.x),t.y=gt(t.y),t.width=e>t.x?yt(t.width+e-t.x):yt(t.width),t.height=s>t.y?yt(t.height+s-t.y):yt(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=_t(t.x,e),t.y=_t(t.y,e),t.width=_t(t.width,e),t.height=_t(t.height,e)},add(t,e,s){xt=t.x+t.width,mt=t.y+t.height,wt=e.x,bt=e.y,s||(wt+=e.width,bt+=e.height),xt=xt>wt?xt:wt,mt=mt>bt?mt:bt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=xt-t.x,t.height=mt-t.y},addList(t,e){Tt.setListWithFn(t,e,void 0,!0)},setList(t,e,s=!1){Tt.setListWithFn(t,e,void 0,s)},addListWithFn(t,e,s){Tt.setListWithFn(t,e,s,!0)},setListWithFn(t,e,s,r=!1){let i,n=!0;for(let o=0,a=e.length;o<a;o++)i=s?s(e[o],o):e[o],i&&(i.width||i.height)&&(n?(n=!1,r||Pt(t,i)):Ot(t,i));n&&Tt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?dt(lt,t.x,t.y):ut(lt,t.x,t.y)),ct(lt,t)},setPoint(t,e){Tt.set(t,e.x,e.y)},addPoint(t,e){Ot(t,e,!0)},getPoints(t){const{x:e,y:s,width:r,height:i}=t;return[{x:e,y:s},{x:e+r,y:s},{x:e+r,y:s+i},{x:e,y:s+i}]},hitRadiusPoint:(t,e,s)=>(s&&(e=j.tempToInnerRadiusPointOf(e,s)),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,s)=>(s&&(e=j.tempToInnerOf(e,s)),e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height),hit:(t,e,s)=>(s&&(e=Tt.tempToOuterOf(e,s)),!(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,s)=>(s&&(e=Tt.tempToOuterOf(e,s)),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,s){if(s&&(e=Tt.tempToOuterOf(e,s)),!Tt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:r,y:i,width:n,height:o}=e;return xt=r+n,mt=i+o,wt=t.x+t.width,bt=t.y+t.height,r=r>t.x?r:t.x,i=i>t.y?i:t.y,xt=xt<wt?xt:wt,mt=mt<bt?mt:bt,n=xt-r,o=mt-i,{x:r,y:i,width:n,height:o}},intersect(t,e,s){Tt.copy(t,Tt.getIntersectData(t,e,s))},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){Tt.set(t)}},Tt=Ct,{add:Ot,copy:Pt}=Tt;class Lt{get minX(){return Ct.minX(this)}get minY(){return Ct.minY(this)}get maxX(){return Ct.maxX(this)}get maxY(){return Ct.maxY(this)}constructor(t,e,s,r){this.set(t,e,s,r)}set(t,e,s,r){return u(t)?Ct.copy(this,t):Ct.set(this,t,e,s,r),this}get(){const{x:t,y:e,width:s,height:r}=this;return{x:t,y:e,width:s,height:r}}clone(){return new Lt(this)}move(t,e){return Ct.move(this,t,e),this}scale(t,e,s){return Ct.scale(this,t,e,s),this}scaleOf(t,e,s){return Ct.scaleOf(this,t,e,s),this}toOuterOf(t,e){return Ct.toOuterOf(this,t,e),this}toInnerOf(t,e){return Ct.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Ct.getFitMatrix(this,t,e)}put(t,e,s){Ct.put(this,t,e,s)}spread(t,e){return Ct.spread(this,t,e),this}shrink(t,e){return Ct.shrink(this,t,e),this}ceil(){return Ct.ceil(this),this}unsign(){return Ct.unsign(this),this}float(t){return Ct.float(this,t),this}add(t){return Ct.add(this,t),this}addList(t){return Ct.setList(this,t,!0),this}setList(t){return Ct.setList(this,t),this}addListWithFn(t,e){return Ct.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Ct.setListWithFn(this,t,e),this}setPoint(t){return Ct.setPoint(this,t),this}setPoints(t){return Ct.setPoints(this,t),this}addPoint(t){return Ct.addPoint(this,t),this}getPoints(){return Ct.getPoints(this)}hitPoint(t,e){return Ct.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Ct.hitRadiusPoint(this,t,e)}hit(t,e){return Ct.hit(this,t,e)}includes(t,e){return Ct.includes(this,t,e)}intersect(t,e){return Ct.intersect(this,t,e),this}getIntersect(t,e){return new Lt(Ct.getIntersectData(this,t,e))}isSame(t){return Ct.isSame(this,t)}isEmpty(){return Ct.isEmpty(this)}reset(){Ct.reset(this)}}const St=new Lt;const Rt={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:Et}=m;class It{constructor(t){this.repeatMap={},this.name=t}static get(t){return new It(t)}static set filter(t){this.filterList=Mt(t)}static set exclude(t){this.excludeList=Mt(t)}static drawRepaint(t,e){const s=Et();t.fillWorld(e,s.replace("1)",".1)")),t.strokeWorld(e,s)}static drawBounds(t,e,s){const r="hit"===It.showBounds,i=t.__nowWorld,n=Et();r&&(e.setWorld(i),t.__drawHitPath(e),e.fillStyle=n.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(n,2),r?e.stroke():e.strokeWorld(i,n)}log(...t){if(At.enable){if(At.filterList.length&&At.filterList.every(t=>t!==this.name))return;if(At.excludeList.length&&At.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){At.enable&&this.warn(...t)}warn(...t){At.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 Mt(t){return t?o(t)&&(t=[t]):t=[],t}It.filterList=[],It.excludeList=[],It.showWarn=!0;const At=It,Wt=It.get("RunTime"),Dt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,s){const r=e.create(e.RUNTIME);return Nt.currentId=Nt.idMap[r]=s?performance.now():Date.now(),Nt.currentName=Nt.nameMap[r]=t,Nt.nameToIdMap[t]=r,r},end(t,e){const s=Nt.idMap[t],r=Nt.nameMap[t],i=e?(performance.now()-s)/1e3:Date.now()-s;Nt.idMap[t]=Nt.nameMap[t]=Nt.nameToIdMap[r]=void 0,Wt.log(r,i,"ms")},endOfName(t,e){const s=Nt.nameToIdMap[t];i(s)||Nt.end(s,e)}},Nt=Dt,Yt=[],Xt={list:{},add(t,...e){this.list[t]=!0,Yt.push(...e)},has(t,e){const s=this.list[t];return!s&&e&&this.need(t),s},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>Yt.forEach(t=>Xt.has(t,!0)));const zt={editor:t=>Xt.need("editor")},Ft=It.get("UICreator"),Ht={list:{},register(t){const{__tag:e}=t.prototype;Ut[e]&&Ft.repeat(e),Ut[e]=t},get(t,e,s,r,n,o){Ut[t]||Ft.error("not register "+t);const a=new Ut[t](e);return i(s)||(a.x=s,r&&(a.y=r),n&&(a.width=n),o&&(a.height=o)),a}},{list:Ut}=Ht,jt=It.get("EventCreator"),Gt={nameList:{},register(t){let e;Object.keys(t).forEach(s=>{e=t[s],o(e)&&(Vt[e]&&jt.repeat(e),Vt[e]=t)})},changeName(t,e){const s=Vt[t];if(s){const r=Object.keys(s).find(e=>s[e]===t);r&&(s[r]=e,Vt[e]=s)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new Vt[t](...e)},{nameList:Vt}=Gt;function qt(t,e,s,r){var i,n=arguments.length,o=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(o=(n<3?i(o):n>3?i(e,s,o):i(e,s))||o);return n>3&&o&&Object.defineProperty(e,s,o),o}function Qt(t,e,s,r){return new(s||(s=Promise))(function(i,n){function o(t){try{h(r.next(t))}catch(t){n(t)}}function a(t){try{h(r.throw(t))}catch(t){n(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(o,a)}h((r=r.apply(t,e||[])).next())})}function Jt(t){return(e,s)=>{t||(t=s);const r={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===s&&(r.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,s,r)}}"function"==typeof SuppressedError&&SuppressedError;const Zt=[];function $t(){return(t,e)=>{Zt.push(e)}}const Kt=[];class te{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||Kt)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Zt.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,s,r,i,n){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,r,i,n){u(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,s,r,i,n)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,s,r){}strokeRect(t,e,s,r){}clearRect(t,e,s,r){}drawImage(t,e,s,r,i,n,o,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/r*a;r+=e,e=0,n+=t,a-=t}if(s<0){const t=-s/i*h;i+=s,s=0,o+=t,h-=t}this.context.drawImage(t,e,s,r,i,n,o,a,h);break;case 5:this.context.drawImage(t,e,s,r,i);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,r,i,n){}quadraticCurveTo(t,e,s,r){}closePath(){}arc(t,e,s,r,i,n){}arcTo(t,e,s,r,i){}ellipse(t,e,s,r,i,n,o,a){}rect(t,e,s,r){}roundRect(t,e,s,r,i){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,r){}createPattern(t,e){}createRadialGradient(t,e,s,r,i,n){}fillText(t,e,s,r){}measureText(t){}strokeText(t,e,s,r){}destroy(){this.context=null}}qt([Jt("imageSmoothingEnabled")],te.prototype,"smooth",void 0),qt([Jt("imageSmoothingQuality")],te.prototype,"smoothLevel",void 0),qt([Jt("globalAlpha")],te.prototype,"opacity",void 0),qt([Jt()],te.prototype,"fillStyle",void 0),qt([Jt()],te.prototype,"strokeStyle",void 0),qt([Jt("lineWidth")],te.prototype,"strokeWidth",void 0),qt([Jt("lineCap")],te.prototype,"strokeCap",void 0),qt([Jt("lineJoin")],te.prototype,"strokeJoin",void 0),qt([Jt("lineDashOffset")],te.prototype,"dashOffset",void 0),qt([Jt()],te.prototype,"miterLimit",void 0),qt([Jt()],te.prototype,"shadowBlur",void 0),qt([Jt()],te.prototype,"shadowColor",void 0),qt([Jt()],te.prototype,"shadowOffsetX",void 0),qt([Jt()],te.prototype,"shadowOffsetY",void 0),qt([Jt()],te.prototype,"filter",void 0),qt([Jt()],te.prototype,"font",void 0),qt([Jt()],te.prototype,"fontKerning",void 0),qt([Jt()],te.prototype,"fontStretch",void 0),qt([Jt()],te.prototype,"fontVariantCaps",void 0),qt([Jt()],te.prototype,"textAlign",void 0),qt([Jt()],te.prototype,"textBaseline",void 0),qt([Jt()],te.prototype,"textRendering",void 0),qt([Jt()],te.prototype,"wordSpacing",void 0),qt([Jt()],te.prototype,"letterSpacing",void 0),qt([Jt()],te.prototype,"direction",void 0),qt([$t()],te.prototype,"setTransform",null),qt([$t()],te.prototype,"resetTransform",null),qt([$t()],te.prototype,"getTransform",null),qt([$t()],te.prototype,"save",null),qt([$t()],te.prototype,"restore",null),qt([$t()],te.prototype,"translate",null),qt([$t()],te.prototype,"scale",null),qt([$t()],te.prototype,"rotate",null),qt([$t()],te.prototype,"fill",null),qt([$t()],te.prototype,"stroke",null),qt([$t()],te.prototype,"clip",null),qt([$t()],te.prototype,"fillRect",null),qt([$t()],te.prototype,"strokeRect",null),qt([$t()],te.prototype,"clearRect",null),qt([$t()],te.prototype,"beginPath",null),qt([$t()],te.prototype,"moveTo",null),qt([$t()],te.prototype,"lineTo",null),qt([$t()],te.prototype,"bezierCurveTo",null),qt([$t()],te.prototype,"quadraticCurveTo",null),qt([$t()],te.prototype,"closePath",null),qt([$t()],te.prototype,"arc",null),qt([$t()],te.prototype,"arcTo",null),qt([$t()],te.prototype,"ellipse",null),qt([$t()],te.prototype,"rect",null),qt([$t()],te.prototype,"roundRect",null),qt([$t()],te.prototype,"createConicGradient",null),qt([$t()],te.prototype,"createLinearGradient",null),qt([$t()],te.prototype,"createPattern",null),qt([$t()],te.prototype,"createRadialGradient",null),qt([$t()],te.prototype,"fillText",null),qt([$t()],te.prototype,"measureText",null),qt([$t()],te.prototype,"strokeText",null);const{copy:ee,multiplyParent:se}=M,{round:re}=Math,ie={width:1,height:1,pixelRatio:1},ne=["width","height","pixelRatio"];const oe={creator:{},parse(t,e){},convertToCanvasData(t,e){}},ae={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},he=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},ae),le={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},ue=Object.assign(Object.assign({},de),ae),ce=he,pe={};for(let t in ce)pe[ce[t]]=t;const _e={};for(let t in ce)_e[ce[t]]=le[t];const fe={drawRoundRect(t,e,s,r,i,n){const o=m.fourNumber(n,Math.min(r/2,i/2)),a=e+r,h=s+i;o[0]?t.moveTo(e+o[0],s):t.moveTo(e,s),o[1]?t.arcTo(a,s,a,h,o[1]):t.lineTo(a,s),o[2]?t.arcTo(a,h,e,h,o[2]):t.lineTo(a,h),o[3]?t.arcTo(e,h,e,s,o[3]):t.lineTo(e,h),o[0]?t.arcTo(e,s,a,s,o[0]):t.lineTo(e,s)}},{sin:ge,cos:ye,atan2:xe,ceil:me,abs:we,PI:be,sqrt:Be,pow:ve}=Math,{setPoint:ke,addPoint:Ce}=tt,{set:Te,toNumberPoints:Oe}=j,{M:Pe,L:Le,C:Se,Q:Re,Z:Ee}=he,Ie={},Me={points(t,e,s,r){let i=Oe(e);if(t.push(Pe,i[0],i[1]),s&&i.length>5){let e,n,o,a,h,l,d,u,c,p,_,f,g,y=i.length;const x=!0===s?.5:s;r&&(i=[i[y-2],i[y-1],...i,i[0],i[1],i[2],i[3]],y=i.length);for(let s=2;s<y-2;s+=2)e=i[s-2],n=i[s-1],o=i[s],a=i[s+1],h=i[s+2],l=i[s+3],_=Be(ve(o-e,2)+ve(a-n,2)),f=Be(ve(h-o,2)+ve(l-a,2)),(_||f)&&(g=_+f,_=x*_/g,f=x*f/g,h-=e,l-=n,d=o-_*h,u=a-_*l,2===s?r||t.push(Re,d,u,o,a):t.push(Se,c,p,d,u,o,a),c=o+f*h,p=a+f*l);r||t.push(Re,c,p,i[y-2],i[y-1])}else for(let e=2,s=i.length;e<s;e+=2)t.push(Le,i[e],i[e+1]);r&&t.push(Ee)},rect(t,e,s,r,i){oe.creator.path=t,oe.creator.moveTo(e,s).lineTo(e+r,s).lineTo(e+r,s+i).lineTo(e,s+i).lineTo(e,s)},roundRect(t,e,s,r,i,n){oe.creator.path=[],fe.drawRoundRect(oe.creator,e,s,r,i,n),t.push(...oe.convertToCanvasData(oe.creator.path,!0))},arcTo(t,e,s,r,i,n,o,a,h,l,d){const u=r-e,c=i-s,p=n-r,_=o-i;let f=xe(c,u),g=xe(_,p),y=g-f;if(y<0&&(y+=B),y===be||we(u+c)<1e-12||we(p+_)<1e-12)return t&&t.push(Le,r,i),h&&(ke(h,e,s),Ce(h,r,i)),d&&Te(d,e,s),void(l&&Te(l,r,i));const x=u*_-p*c<0,m=x?-1:1,w=a/ye(y/2),k=r+w*ye(f+y/2+v*m),C=i+w*ge(f+y/2+v*m);return f-=v*m,g-=v*m,De(t,k,C,a,a,0,f/b,g/b,x,h,l,d)},arc:(t,e,s,r,i,n,o,a,h,l)=>De(t,e,s,r,r,0,i,n,o,a,h,l),ellipse(t,e,s,r,i,n,o,a,h,l,d,u){const c=n*b,p=ge(c),_=ye(c);let f=o*b,g=a*b;f>be&&(f-=B),g<0&&(g+=B);let y=g-f;y<0?y+=B:y>B&&(y-=B),h&&(y-=B);const x=me(we(y/v)),m=y/x,w=ge(m/4),k=8/3*w*w/ge(m/2);g=f+m;let C,T,O,P,L,S,R,E,I=ye(f),M=ge(f),A=O=_*r*I-p*i*M,W=P=p*r*I+_*i*M,D=e+O,N=s+P;t&&t.push(t.length?Le:Pe,D,N),l&&ke(l,D,N),u&&Te(u,D,N);for(let n=0;n<x;n++)C=ye(g),T=ge(g),O=_*r*C-p*i*T,P=p*r*C+_*i*T,L=e+A-k*(_*r*M+p*i*I),S=s+W-k*(p*r*M-_*i*I),R=e+O+k*(_*r*T+p*i*C),E=s+P+k*(p*r*T-_*i*C),t&&t.push(Se,L,S,R,E,e+O,s+P),l&&We(e+A,s+W,L,S,R,E,e+O,s+P,l,!0),A=O,W=P,I=C,M=T,f=g,g+=m;d&&Te(d,e+O,s+P)},quadraticCurveTo(t,e,s,r,i,n,o){t.push(Se,(e+2*r)/3,(s+2*i)/3,(n+2*r)/3,(o+2*i)/3,n,o)},toTwoPointBoundsByQuadraticCurve(t,e,s,r,i,n,o,a){We(t,e,(t+2*s)/3,(e+2*r)/3,(i+2*s)/3,(n+2*r)/3,i,n,o,a)},toTwoPointBounds(t,e,s,r,i,n,o,a,h,l){const d=[];let u,c,p,_,f,g,y,x,m=t,w=s,b=i,B=o;for(let t=0;t<2;++t)if(1==t&&(m=e,w=r,b=n,B=a),u=-3*m+9*w-9*b+3*B,c=6*m-12*w+6*b,p=3*w-3*m,Math.abs(u)<1e-12){if(Math.abs(c)<1e-12)continue;_=-p/c,0<_&&_<1&&d.push(_)}else y=c*c-4*p*u,x=Math.sqrt(y),y<0||(f=(-c+x)/(2*u),0<f&&f<1&&d.push(f),g=(-c-x)/(2*u),0<g&&g<1&&d.push(g));l?Ce(h,t,e):ke(h,t,e),Ce(h,o,a);for(let l=0,u=d.length;l<u;l++)Ae(d[l],t,e,s,r,i,n,o,a,Ie),Ce(h,Ie.x,Ie.y)},getPointAndSet(t,e,s,r,i,n,o,a,h,l){const d=1-t,u=d*d*d,c=3*d*d*t,p=3*d*t*t,_=t*t*t;l.x=u*e+c*r+p*n+_*a,l.y=u*s+c*i+p*o+_*h},getPoint(t,e,s,r,i,n,o,a,h){const l={};return Ae(t,e,s,r,i,n,o,a,h,l),l},getDerivative(t,e,s,r,i){const n=1-t;return 3*n*n*(s-e)+6*n*t*(r-s)+3*t*t*(i-r)}},{getPointAndSet:Ae,toTwoPointBounds:We,ellipse:De}=Me,{sin:Ne,cos:Ye,sqrt:Xe,atan2:ze}=Math,{ellipse:Fe}=Me,He={ellipticalArc(e,s,r,i,n,o,a,h,l,d,u){const c=(l-s)/2,p=(d-r)/2,_=o*b,f=Ne(_),g=Ye(_),y=-g*c-f*p,x=-g*p+f*c,m=i*i,w=n*n,v=x*x,k=y*y,C=m*w-m*v-w*k;let T=0;if(C<0){const t=Xe(1-C/(m*w));i*=t,n*=t}else T=(a===h?-1:1)*Xe(C/(m*v+w*k));const O=T*i*x/n,P=-T*n*y/i,L=ze((x-P)/n,(y-O)/i),S=ze((-x-P)/n,(-y-O)/i);let R=S-L;0===h&&R>0?R-=B:1===h&&R<0&&(R+=B);const E=s+c+g*O-f*P,I=r+p+f*O+g*P,M=R<0?1:0;u||t.ellipseToCurve?Fe(e,E,I,i,n,o,L/b,S/b,M):i!==n||o?e.push(he.G,E,I,i,n,o,L/b,S/b,M):e.push(he.O,E,I,i,L/b,S/b,M)}},{M:Ue,m:je,L:Ge,l:Ve,H:qe,h:Qe,V:Je,v:Ze,C:$e,c:Ke,S:ts,s:es,Q:ss,q:rs,T:is,t:ns,A:os,a:as,Z:hs,z:ls,N:ds,D:us,X:cs,G:ps,F:_s,O:fs,P:gs,U:ys}=he,{rect:xs,roundRect:ms,arcTo:ws,arc:bs,ellipse:Bs,quadraticCurveTo:vs}=Me,{ellipticalArc:ks}=He,Cs=It.get("PathConvert"),Ts={},Os={current:{dot:0},stringify(t,e){let s,r,i,n=0,o=t.length,a="";for(;n<o;){r=t[n],s=_e[r],a+=r===i?" ":pe[r];for(let r=1;r<s;r++)a+=m.float(t[n+r],e),r===s-1||(a+=" ");i=r,n+=s}return a},parse(t,e){let s,r,i,n="";const o=[],a=e?ue:de;for(let e=0,h=t.length;e<h;e++)r=t[e],Rt[r]?("."===r&&(Ps.dot&&(Ls(o,n),n=""),Ps.dot++),"0"===n&&"."!==r&&(Ls(o,n),n=""),n+=r):he[r]?(n&&(Ls(o,n),n=""),Ps.name=he[r],Ps.length=le[r],Ps.index=0,Ls(o,Ps.name),!s&&a[r]&&(s=!0)):"-"===r||"+"===r?"e"===i||"E"===i?n+=r:(n&&Ls(o,n),n=r):n&&(Ls(o,n),n=""),i=r;return n&&Ls(o,n),s?Os.toCanvasData(o,e):o},toCanvasData(t,e){let s,r,i,n,o,a=0,h=0,l=0,d=0,u=0,c=t.length;const p=[];for(;u<c;){switch(i=t[u],i){case je:t[u+1]+=a,t[u+2]+=h;case Ue:a=t[u+1],h=t[u+2],p.push(Ue,a,h),u+=3;break;case Qe:t[u+1]+=a;case qe:a=t[u+1],p.push(Ge,a,h),u+=2;break;case Ze:t[u+1]+=h;case Je:h=t[u+1],p.push(Ge,a,h),u+=2;break;case Ve:t[u+1]+=a,t[u+2]+=h;case Ge:a=t[u+1],h=t[u+2],p.push(Ge,a,h),u+=3;break;case es:t[u+1]+=a,t[u+2]+=h,t[u+3]+=a,t[u+4]+=h,i=ts;case ts:o=n===$e||n===ts,l=o?2*a-s:t[u+1],d=o?2*h-r:t[u+2],s=t[u+1],r=t[u+2],a=t[u+3],h=t[u+4],p.push($e,l,d,s,r,a,h),u+=5;break;case Ke:t[u+1]+=a,t[u+2]+=h,t[u+3]+=a,t[u+4]+=h,t[u+5]+=a,t[u+6]+=h,i=$e;case $e:s=t[u+3],r=t[u+4],a=t[u+5],h=t[u+6],p.push($e,t[u+1],t[u+2],s,r,a,h),u+=7;break;case ns:t[u+1]+=a,t[u+2]+=h,i=is;case is:o=n===ss||n===is,s=o?2*a-s:t[u+1],r=o?2*h-r:t[u+2],e?vs(p,a,h,s,r,t[u+1],t[u+2]):p.push(ss,s,r,t[u+1],t[u+2]),a=t[u+1],h=t[u+2],u+=3;break;case rs:t[u+1]+=a,t[u+2]+=h,t[u+3]+=a,t[u+4]+=h,i=ss;case ss:s=t[u+1],r=t[u+2],e?vs(p,a,h,s,r,t[u+3],t[u+4]):p.push(ss,s,r,t[u+3],t[u+4]),a=t[u+3],h=t[u+4],u+=5;break;case as:t[u+6]+=a,t[u+7]+=h;case os:ks(p,a,h,t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],t[u+6],t[u+7],e),a=t[u+6],h=t[u+7],u+=8;break;case ls:case hs:p.push(hs),u++;break;case ds:a=t[u+1],h=t[u+2],e?xs(p,a,h,t[u+3],t[u+4]):Ss(p,t,u,5),u+=5;break;case us:a=t[u+1],h=t[u+2],e?ms(p,a,h,t[u+3],t[u+4],[t[u+5],t[u+6],t[u+7],t[u+8]]):Ss(p,t,u,9),u+=9;break;case cs:a=t[u+1],h=t[u+2],e?ms(p,a,h,t[u+3],t[u+4],t[u+5]):Ss(p,t,u,6),u+=6;break;case ps:Bs(e?p:Ss(p,t,u,9),t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],t[u+6],t[u+7],t[u+8],null,Ts),a=Ts.x,h=Ts.y,u+=9;break;case _s:e?Bs(p,t[u+1],t[u+2],t[u+3],t[u+4],0,0,360,!1):Ss(p,t,u,5),a=t[u+1]+t[u+3],h=t[u+2],u+=5;break;case fs:bs(e?p:Ss(p,t,u,7),t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],t[u+6],null,Ts),a=Ts.x,h=Ts.y,u+=7;break;case gs:e?bs(p,t[u+1],t[u+2],t[u+3],0,360,!1):Ss(p,t,u,4),a=t[u+1]+t[u+3],h=t[u+2],u+=4;break;case ys:ws(e?p:Ss(p,t,u,6),a,h,t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],null,Ts),a=Ts.x,h=Ts.y,u+=6;break;default:return Cs.error(`command: ${i} [index:${u}]`,t),p}n=i}return p},objectToCanvasData(t){const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(Ue,t.x,t.y);break;case"L":e.push(Ge,t.x,t.y);break;case"C":e.push($e,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(ss,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(hs)}}),e},copyData(t,e,s,r){for(let i=s,n=s+r;i<n;i++)t.push(e[i])},pushData(t,e){Ps.index===Ps.length&&(Ps.index=1,t.push(Ps.name)),t.push(Number(e)),Ps.index++,Ps.dot=0}},{current:Ps,pushData:Ls,copyData:Ss}=Os,{M:Rs,L:Es,C:Is,Q:Ms,Z:As,N:Ws,D:Ds,X:Ns,G:Ys,F:Xs,O:zs,P:Fs,U:Hs}=he,{getMinDistanceFrom:Us,getRadianFrom:js}=j,{tan:Gs,min:Vs,abs:qs}=Math,Qs={},Js={beginPath(t){t.length=0},moveTo(t,e,s){t.push(Rs,e,s)},lineTo(t,e,s){t.push(Es,e,s)},bezierCurveTo(t,e,s,r,i,n,o){t.push(Is,e,s,r,i,n,o)},quadraticCurveTo(t,e,s,r,i){t.push(Ms,e,s,r,i)},closePath(t){t.push(As)},rect(t,e,s,r,i){t.push(Ws,e,s,r,i)},roundRect(t,e,s,r,i,n){if(h(n))t.push(Ns,e,s,r,i,n);else{const o=m.fourNumber(n);o?t.push(Ds,e,s,r,i,...o):t.push(Ws,e,s,r,i)}},ellipse(t,e,s,r,i,o,a,h,l){n(o)?t.push(Xs,e,s,r,i):(n(a)&&(a=0),n(h)&&(h=360),t.push(Ys,e,s,r,i,o,a,h,l?1:0))},arc(t,e,s,r,i,o,a){n(i)?t.push(Fs,e,s,r):(n(o)&&(o=360),t.push(zs,e,s,r,i,o,a?1:0))},arcTo(t,e,s,r,n,o,a,h){if(!i(a)){const t=Us(a,h,e,s,r,n);o=Vs(o,Vs(t/2,t/2*qs(Gs(js(a,h,e,s,r,n)/2))))}t.push(Hs,e,s,r,n,o)},drawEllipse(t,e,s,r,i,o,a,h,l){Me.ellipse(null,e,s,r,i,n(o)?0:o,n(a)?0:a,n(h)?360:h,l,null,null,Qs),t.push(Rs,Qs.x,Qs.y),Zs(t,e,s,r,i,o,a,h,l)},drawArc(t,e,s,r,i,o,a){Me.arc(null,e,s,r,n(i)?0:i,n(o)?360:o,a,null,null,Qs),t.push(Rs,Qs.x,Qs.y),$s(t,e,s,r,i,o,a)},drawPoints(t,e,s,r){Me.points(t,e,s,r)}},{ellipse:Zs,arc:$s}=Js,{moveTo:Ks,lineTo:tr,quadraticCurveTo:er,bezierCurveTo:sr,closePath:rr,beginPath:ir,rect:nr,roundRect:or,ellipse:ar,arc:hr,arcTo:lr,drawEllipse:dr,drawArc:ur,drawPoints:cr}=Js;class pr{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?o(t)?oe.parse(t):t:[],this}beginPath(){return ir(this.__path),this.paint(),this}moveTo(t,e){return Ks(this.__path,t,e),this.paint(),this}lineTo(t,e){return tr(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,s,r,i,n){return sr(this.__path,t,e,s,r,i,n),this.paint(),this}quadraticCurveTo(t,e,s,r){return er(this.__path,t,e,s,r),this.paint(),this}closePath(){return rr(this.__path),this.paint(),this}rect(t,e,s,r){return nr(this.__path,t,e,s,r),this.paint(),this}roundRect(t,e,s,r,i){return or(this.__path,t,e,s,r,i),this.paint(),this}ellipse(t,e,s,r,i,n,o,a){return ar(this.__path,t,e,s,r,i,n,o,a),this.paint(),this}arc(t,e,s,r,i,n){return hr(this.__path,t,e,s,r,i,n),this.paint(),this}arcTo(t,e,s,r,i){return lr(this.__path,t,e,s,r,i),this.paint(),this}drawEllipse(t,e,s,r,i,n,o,a){return dr(this.__path,t,e,s,r,i,n,o,a),this.paint(),this}drawArc(t,e,s,r,i,n){return ur(this.__path,t,e,s,r,i,n),this.paint(),this}drawPoints(t,e,s){return cr(this.__path,t,e,s),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:_r,L:fr,C:gr,Q:yr,Z:xr,N:mr,D:wr,X:br,G:Br,F:vr,O:kr,P:Cr,U:Tr}=he,Or=It.get("PathDrawer"),Pr={drawPathByData(t,e){if(!e)return;let s,r=0,i=e.length;for(;r<i;)switch(s=e[r],s){case _r:t.moveTo(e[r+1],e[r+2]),r+=3;break;case fr:t.lineTo(e[r+1],e[r+2]),r+=3;break;case gr:t.bezierCurveTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5],e[r+6]),r+=7;break;case yr:t.quadraticCurveTo(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case xr:t.closePath(),r+=1;break;case mr:t.rect(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case wr:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],[e[r+5],e[r+6],e[r+7],e[r+8]]),r+=9;break;case br:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;case Br:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]*b,e[r+6]*b,e[r+7]*b,e[r+8]),r+=9;break;case vr:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],0,0,B,!1),r+=5;break;case kr:t.arc(e[r+1],e[r+2],e[r+3],e[r+4]*b,e[r+5]*b,e[r+6]),r+=7;break;case Cr:t.arc(e[r+1],e[r+2],e[r+3],0,B,!1),r+=4;break;case Tr:t.arcTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;default:return void Or.error(`command: ${s} [index:${r}]`,e)}}},{M:Lr,L:Sr,C:Rr,Q:Er,Z:Ir,N:Mr,D:Ar,X:Wr,G:Dr,F:Nr,O:Yr,P:Xr,U:zr}=he,{toTwoPointBounds:Fr,toTwoPointBoundsByQuadraticCurve:Hr,arcTo:Ur,arc:jr,ellipse:Gr}=Me,{addPointBounds:Vr,copy:qr,addPoint:Qr,setPoint:Jr,addBounds:Zr,toBounds:$r}=tt,Kr=It.get("PathBounds");let ti,ei,si;const ri={},ii={},ni={},oi={toBounds(t,e){oi.toTwoPointBounds(t,ii),$r(ii,e)},toTwoPointBounds(t,e){if(!t||!t.length)return Jr(e,0,0);let s,r,i,n,o,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(o=t[a],0===a&&(o===Ir||o===Rr||o===Er?Jr(e,h,l):Jr(e,t[a+1],t[a+2])),o){case Lr:case Sr:h=t[a+1],l=t[a+2],Qr(e,h,l),a+=3;break;case Rr:i=t[a+5],n=t[a+6],Fr(h,l,t[a+1],t[a+2],t[a+3],t[a+4],i,n,ri),Vr(e,ri),h=i,l=n,a+=7;break;case Er:s=t[a+1],r=t[a+2],i=t[a+3],n=t[a+4],Hr(h,l,s,r,i,n,ri),Vr(e,ri),h=i,l=n,a+=5;break;case Ir:a+=1;break;case Mr:h=t[a+1],l=t[a+2],Zr(e,h,l,t[a+3],t[a+4]),a+=5;break;case Ar:case Wr:h=t[a+1],l=t[a+2],Zr(e,h,l,t[a+3],t[a+4]),a+=o===Ar?9:6;break;case Dr:Gr(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],ri,ni),0===a?qr(e,ri):Vr(e,ri),h=ni.x,l=ni.y,a+=9;break;case Nr:h=t[a+1],l=t[a+2],ei=t[a+3],si=t[a+4],Zr(e,h-ei,l-si,2*ei,2*si),h+=ei,a+=5;break;case Yr:jr(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],ri,ni),0===a?qr(e,ri):Vr(e,ri),h=ni.x,l=ni.y,a+=7;break;case Xr:h=t[a+1],l=t[a+2],ti=t[a+3],Zr(e,h-ti,l-ti,2*ti,2*ti),h+=ti,a+=4;break;case zr:Ur(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],ri,ni),0===a?qr(e,ri):Vr(e,ri),h=ni.x,l=ni.y,a+=6;break;default:return void Kr.error(`command: ${o} [index:${a}]`,t)}}},{M:ai,L:hi,Z:li}=he,{getCenterX:di,getCenterY:ui}=j,{arcTo:ci}=Js,pi={smooth(t,e,s){let r,i,n,o=0,a=0,h=0,l=0,d=0,u=0,c=0,p=0,_=0;const f=t.length,g=[];for(;o<f;){switch(r=t[o],r){case ai:l=p=t[o+1],d=_=t[o+2],o+=3,t[o]===hi?(u=t[o+1],c=t[o+2],g.push(ai,di(l,u),ui(d,c))):g.push(ai,l,d);break;case hi:switch(a=t[o+1],h=t[o+2],o+=3,t[o]){case hi:ci(g,a,h,t[o+1],t[o+2],e,p,_);break;case li:ci(g,a,h,l,d,e,p,_);break;default:g.push(hi,a,h)}p=a,_=h;break;case li:i!==li&&(ci(g,l,d,u,c,e,p,_),g.push(li)),o+=1;break;default:n=_e[r];for(let e=0;e<n;e++)g.push(t[o+e]);o+=n}i=r}return r!==li&&(g[1]=l,g[2]=d),g}};oe.creator=new pr,oe.parse=Os.parse,oe.convertToCanvasData=Os.toCanvasData;const _i=new pr,{drawRoundRect:fi}=fe;const gi={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=yi.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{}}}},yi=gi;yi.alphaPixelTypes.forEach(t=>yi.upperCaseTypeMap[t]=t.toUpperCase());const xi=It.get("TaskProcessor");class mi{constructor(t){this.parallel=!0,this.time=1,this.id=e.create(e.TASK),this.task=t}run(){return Qt(this,void 0,void 0,function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){xi.error(t)}})}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class wi{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,s=0;for(let r=0;r<t;r++)r<=this.finishedIndex?(s+=this.list[r].time,r===this.finishedIndex&&(e=s)):e+=this.list[r].time;return this.isComplete?1:s/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&p.assign(this.config,t),this.empty()}add(t,e){let s,r,n,o;const a=new mi(t);return a.parent=this,h(e)?o=e:e&&(r=e.parallel,s=e.start,n=e.time,o=e.delay),n&&(a.time=n),!1===r&&(a.parallel=!1),i(o)?this.push(a,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(a,s))},o)),this.isComplete=!1,a}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout(()=>this.start()))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[],this.delayNumber=0}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach(t=>{t.isComplete||t.cancel()}),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then(()=>{this.onTask(t),this.index++,this.nextTask()}).catch(t=>{this.onError(t)}):this.nextTask()}runParallelTasks(){this.parallelList.forEach(t=>this.runParallelTask(t))}runParallelTask(t){t.run().then(()=>{this.onTask(t),this.fillParallelTask()}).catch(t=>{this.onParallelError(t)})}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout(()=>this.run())}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let s=this.index;s<e&&(t=this.list[s],t.parallel);s++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const s=e.length,r=this.finishedIndex+s;if(e.length){if(!this.running)return;r<this.total&&(t=this.list[r],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 bi=It.get("Resource"),Bi={tasker:new wi,map:{},get isComplete(){return vi.tasker.isComplete},set(t,e){vi.map[t]&&bi.repeat(t),vi.map[t]=e},get:t=>vi.map[t],remove(t){const e=vi.map[t];e&&(e.destroy&&e.destroy(),delete vi.map[t])},loadImage(t,e){return new Promise((s,r)=>{const i=this.setImage(t,t,e);i.load(()=>s(i),t=>r(t))})},setImage(t,e,s){let r;return o(e)?r={url:e}:e.url||(r={url:t,view:e}),r&&(s&&(r.format=s),e=zt.image(r)),vi.set(t,e),e},destroy(){vi.map={}}},vi=Bi,ki={maxRecycled:10,recycledList:[],patternTasker:new wi,get(t){let e=Bi.get(t.url);return e||Bi.set(t.url,e=zt.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||Ci.recycledList.push(t)})},clearRecycled(){const t=Ci.recycledList;t.length>Ci.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&Bi.remove(t.url)),t.length=0)},hasAlphaPixel:t=>gi.alphaPixelTypes.some(e=>Ci.isFormat(e,t)),isFormat(t,e){if(e.format===t)return!0;const{url:s}=e;if(s.startsWith("data:")){if(s.startsWith("data:"+gi.mineType(t)))return!0}else{if(s.includes("."+t)||s.includes("."+gi.upperCaseTypeMap[t]))return!0;if("png"===t&&!s.includes("."))return!0}return!1},destroy(){Ci.recycledList=[]}},Ci=ki,{IMAGE:Ti,create:Oi}=e,{floor:Pi,max:Li}=Math;function Si(t,e,s,r){r||(s.configurable=s.enumerable=!0),Object.defineProperty(t,e,s)}function Ri(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Ei(t,e){const s="_"+t;return{get(){const t=this[s];return i(t)?e:t},set(t){this[s]=t}}}function Ii(t,e){return(s,r)=>Ai(s,r,t,e&&e(r))}function Mi(t){return t}function Ai(t,e,s,r){const i={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};Si(t,e,Object.assign(i,r||{})),Ui(t,e,s)}function Wi(t,e){return Ii(t,t=>({set(s){this.__setAttr(t,s,e)&&Di(this)}}))}function Di(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}const Ni=Wi;function Yi(t,e){return Ii(t,t=>({set(s){this.__setAttr(t,s)&&(Xi(this),e&&(this.__.__useStroke=!0))}}))}function Xi(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&Di(t)}const zi=Yi;function Fi(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Hi(t,e,s,r){t.__setAttr(e,s)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==r&&0!==s||Di(t))}function Ui(t,e,s){const r=t.__DataProcessor.prototype,n="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=Ei(e,s);if(i(s))a.get=function(){return this[n]};else if("function"==typeof s)a.get=function(){let t=this[n];return void 0===t?s(this.__leaf):t};else if(u(s)){const t=c(s);a.get=function(){let e=this[n];return void 0===e?this[n]=t?{}:p.clone(s):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[n];if(void 0===t){const t=this,e=t.__naturalWidth,r=t.__leaf;return!s||r.pathInputed?r.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&r.children.length?r.boxBounds.width:s}return t}:"height"===e&&(a.get=function(){const t=this[n];if(void 0===t){const t=this,e=t.__naturalHeight,r=t.__leaf;return!s||r.pathInputed?r.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&r.children.length?r.boxBounds.height:s}return t});let l,d=r;for(;!l&&d;)l=Ri(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),r[o]&&(a.set=r[o],delete r[o]),Si(r,e,a)}const ji=new It("rewrite"),Gi=[],Vi=["destroy","constructor"];function qi(t){Gi.length&&(Gi.forEach(e=>{t&&ji.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),Gi.length=0)}function Qi(t,e){return s=>{var r;(t.prototype?(r=t.prototype,Object.getOwnPropertyNames(r)):Object.keys(t)).forEach(r=>{if(!(Vi.includes(r)||e&&e.includes(r)))if(t.prototype){Ri(t.prototype,r).writable&&(s.prototype[r]=t.prototype[r])}else s.prototype[r]=t[r]})}}setTimeout(()=>qi(!0));const{copy:Ji,toInnerPoint:Zi,toOuterPoint:$i,scaleOfOuter:Ki,rotateOfOuter:tn,skewOfOuter:en,multiplyParent:sn,divideParent:rn,getLayout:nn}=M,on={},{round:an}=Math,hn={updateAllMatrix(t,e,s){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(s=!0),un(t,e,s),t.isBranch){const{children:r}=t;for(let t=0,i=r.length;t<i;t++)dn(r[t],e,s)}},updateMatrix(t,e,s){const r=t.__layout;e?s&&(r.waitAutoLayout=!0,t.__hasAutoLayout&&(r.matrixChanged=!1)):r.waitAutoLayout&&(r.waitAutoLayout=!1),r.matrixChanged&&t.__updateLocalMatrix(),r.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,s=e.length;t<s;t++)cn(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&cn(t),t.__updateChange()},updateAllChange(t){if(_n(t),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)pn(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(e,s,r,i,n,o){i||(i=e.__nowWorld),e.__worldFlipped||t.fullImageShadow?s.copyWorldByReset(r,i,e.__nowWorld,n,o):s.copyWorldToInner(r,i,e.__layout.renderBounds,n)},moveWorld(t,e,s=0,r,i){const n=u(e)?Object.assign({},e):{x:e,y:s};r?$i(t.localTransform,n,n,!0):t.parent&&Zi(t.parent.worldTransform,n,n,!0),ln.moveLocal(t,n.x,n.y,i)},moveLocal(t,e,s=0,r){u(e)&&(s=e.y,e=e.x),e+=t.x,s+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=an(e),s=an(s)),r?t.animate({x:e,y:s},r):(t.x=e,t.y=s)},zoomOfWorld(t,e,s,r,i,n){ln.zoomOfLocal(t,fn(t,e),s,r,i,n)},zoomOfLocal(t,e,s,r=s,i,n){const o=t.__localMatrix;if(h(r)||(r&&(n=r),r=s),Ji(on,o),Ki(on,e,s,r),t.origin||t.around)ln.setTransform(t,on,i,n);else{const e=t.x+on.e-o.e,a=t.y+on.f-o.f;n&&!i?t.animate({x:e,y:a,scaleX:t.scaleX*s,scaleY:t.scaleY*r},n):(t.x=e,t.y=a,t.scaleResize(s,r,!0!==i))}},rotateOfWorld(t,e,s,r){ln.rotateOfLocal(t,fn(t,e),s,r)},rotateOfLocal(t,e,s,r){const i=t.__localMatrix;Ji(on,i),tn(on,e,s),t.origin||t.around?ln.setTransform(t,on,!1,r):t.set({x:t.x+on.e-i.e,y:t.y+on.f-i.f,rotation:m.formatRotation(t.rotation+s)},r)},skewOfWorld(t,e,s,r,i,n){ln.skewOfLocal(t,fn(t,e),s,r,i,n)},skewOfLocal(t,e,s,r=0,i,n){Ji(on,t.__localMatrix),en(on,e,s,r),ln.setTransform(t,on,i,n)},transformWorld(t,e,s,r){Ji(on,t.worldTransform),sn(on,e),t.parent&&rn(on,t.parent.worldTransform),ln.setTransform(t,on,s,r)},transform(t,e,s,r){Ji(on,t.localTransform),sn(on,e),ln.setTransform(t,on,s,r)},setTransform(t,e,s,r){const i=t.__,n=i.origin&&ln.getInnerOrigin(t,i.origin),o=nn(e,n,i.around&&ln.getInnerOrigin(t,i.around));if(s){const e=o.scaleX/t.scaleX,s=o.scaleY/t.scaleY;if(delete o.scaleX,delete o.scaleY,n){Ct.scale(t.boxBounds,Math.abs(e),Math.abs(s));const r=ln.getInnerOrigin(t,i.origin);j.move(o,n.x-r.x,n.y-r.y)}t.set(o),t.scaleResize(e,s,!1)}else t.set(o,r)},getFlipTransform(t,e){const s={a:1,b:0,c:0,d:1,e:0,f:0},r="x"===e?1:-1;return Ki(s,ln.getLocalOrigin(t,"center"),-1*r,1*r),s},getLocalOrigin:(t,e)=>j.tempToOuterOf(ln.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const s={};return nt.toPoint(e,t.boxBounds,s),s},getRelativeWorld:(t,e,s)=>(Ji(on,t.worldTransform),rn(on,e.worldTransform),s?on:Object.assign({},on)),drop(t,e,s,r){t.setTransform(ln.getRelativeWorld(t,e,!0),r),e.add(t,s)},hasParent(t,e){if(!e)return!1;for(;t;){if(e===t)return!0;t=t.parent}},animateMove(e,s,r=.3){if(s.x||s.y)if(Math.abs(s.x)<1&&Math.abs(s.y)<1)e.move(s);else{const i=s.x*r,n=s.y*r;s.x-=i,s.y-=n,e.move(i,n),t.requestRender(()=>ln.animateMove(e,s,r))}}},ln=hn,{updateAllMatrix:dn,updateMatrix:un,updateAllWorldOpacity:cn,updateAllChange:pn,updateChange:_n}=ln;function fn(t,e){return t.__layout.update(),t.parent?j.tempToInnerOf(e,t.parent.__world):e}const gn={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)=>xn(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>xn(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>xn(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 yn;function xn(t,e){return e||(yn=0),t.__.mask&&(yn=1),yn<0?null:(yn&&(yn=-1),!0)}const{updateBounds:mn}=hn,wn={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:s}=t;for(let r=0,i=s.length;r<i;r++)(t=s[r]).isBranch&&(t.__tempNumber=1,e.add(t),bn(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 s=e.length;const{children:r}=t;for(let t=0,s=r.length;t<s;t++)r[t].isBranch&&e.push(r[t]);for(let t=s,r=e.length;t<r;t++)Bn(e[t],e)},updateBounds(t,e){const s=[t];Bn(t,s),vn(s,e)},updateBoundsByBranchStack(t,e){let s,r;for(let i=t.length-1;i>-1;i--){s=t[i],r=s.children;for(let t=0,e=r.length;t<e;t++)mn(r[t]);e&&e===s||mn(s)}}},{pushAllChildBranch:bn,pushAllBranchStack:Bn,updateBoundsByBranchStack:vn}=wn,kn={run(t){if(t&&t.length){const e=t.length;for(let s=0;s<e;s++)t[s]();t.length===e?t.length=0:t.splice(0,e)}}},{getRelativeWorld:Cn,updateBounds:Tn}=hn,{toOuterOf:On,getPoints:Pn,copy:Ln}=Ct,Sn="_localContentBounds",Rn="_worldContentBounds",En="_worldBoxBounds",In="_worldStrokeBounds";class Mn{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 On(this.contentBounds,this.leaf.__localMatrix,this[Sn]||(this[Sn]={})),this[Sn]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return On(this.contentBounds,this.leaf.__world,this[Rn]||(this[Rn]={})),this[Rn]}get worldBoxBounds(){return On(this.boxBounds,this.leaf.__world,this[En]||(this[En]={})),this[En]}get worldStrokeBounds(){return On(this.strokeBounds,this.leaf.__world,this[In]||(this[In]={})),this[In]}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:e}=this,{leafer:s}=e;if(e.isApp)return Tn(e);if(s)s.ready?s.watcher.changed&&s.layouter.layout():s.start();else{let s=e;for(;s.parent&&!s.parent.leafer;)s=s.parent;const r=s;if(r.__fullLayouting)return;r.__fullLayouting=!0,t.layout(r),delete r.__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 M.defaultMatrix;case"page":t=e.zoomLayer;default:return Cn(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 Lt(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",s){const{leaf:r}=this;let i,n,o,a=this.getInnerBounds(t);switch(e){case"world":i=r.getWorldPoint(a),n=r.__world;break;case"local":const{scaleX:t,scaleY:s,rotation:h,skewX:l,skewY:d}=r.__;o={scaleX:t,scaleY:s,rotation:h,skewX:l,skewY:d},i=r.getLocalPointByInner(a);break;case"inner":i=a,n=M.defaultMatrix;break;case"page":e=r.zoomLayer;default:i=r.getWorldPoint(a,e),n=Cn(r,e,!0)}if(o||(o=M.getLayout(n)),Ln(o,a),j.copy(o,i),s){const{scaleX:t,scaleY:e}=o,s=Math.abs(t),r=Math.abs(e);1===s&&1===r||(o.scaleX/=s,o.scaleY/=r,o.width*=s,o.height*=r)}return o}getLayoutPoints(t,e="world"){const{leaf:s}=this,r=Pn(this.getInnerBounds(t));let n;switch(e){case"world":n=null;break;case"local":n=s.parent;break;case"inner":break;case"page":e=s.zoomLayer;default:n=e}return i(n)||r.forEach(t=>s.innerToWorld(t,null,!1,n)),r}shrinkContent(){const{x:t,y:e,width:s,height:r}=this.boxBounds;this._contentBounds={x:t,y:e,width:s,height:r}}spreadStroke(){const{x:t,y:e,width:s,height:r}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:s,height:r},this._localStrokeBounds={x:t,y:e,width:s,height:r},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:s,height:r}=this.renderBounds;this._renderBounds={x:t,y:e,width:s,height:r},this._localRenderBounds={x:t,y:e,width:s,height:r}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class An{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&t.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&t.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&t.event.stop(this.origin)}}class Wn extends An{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}Wn.ADD="child.add",Wn.REMOVE="child.remove",Wn.CREATED="created",Wn.MOUNTED="mounted",Wn.UNMOUNTED="unmounted",Wn.DESTROY="destroy";class Dn extends An{constructor(t,e,s,r,i){super(t,e),this.attrName=s,this.oldValue=r,this.newValue=i}}Dn.CHANGE="property.change",Dn.LEAFER_CHANGE="property.leafer_change";class Nn extends An{constructor(t,e){super(t),Object.assign(this,e)}}Nn.LOAD="image.load",Nn.LOADED="image.loaded",Nn.ERROR="image.error";class Yn extends An{static checkHas(t,e,s){"on"===s?e===Hn?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(Xn)||t.hasEvent(zn)||t.hasEvent(Fn),t.__hasWorldEvent=t.hasEvent(Hn))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(Xn,t),"inner"===e&&t.emit(zn,t)),t.emit(Fn,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Hn,this)}}Yn.RESIZE="bounds.resize",Yn.INNER="bounds.inner",Yn.LOCAL="bounds.local",Yn.WORLD="bounds.world";const{RESIZE:Xn,INNER:zn,LOCAL:Fn,WORLD:Hn}=Yn,Un={};[Xn,zn,Fn,Hn].forEach(t=>Un[t]=1);class jn extends An{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){u(t)?(super(jn.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!i(this.resizingKeys[t.innerId])}}jn.RESIZE="resize";class Gn extends An{constructor(t,e){super(t),this.data=e}}Gn.REQUEST="watch.request",Gn.DATA="watch.data";class Vn extends An{constructor(t,e,s){super(t),e&&(this.data=e,this.times=s)}}Vn.REQUEST="layout.request",Vn.START="layout.start",Vn.BEFORE="layout.before",Vn.LAYOUT="layout",Vn.AFTER="layout.after",Vn.AGAIN="layout.again",Vn.END="layout.end";class qn extends An{constructor(t,e,s,r){super(t),e&&(this.times=e),s&&(this.renderBounds=s,this.renderOptions=r)}}qn.REQUEST="render.request",qn.CHILD_START="render.child_start",qn.CHILD_END="render.child_end",qn.START="render.start",qn.BEFORE="render.before",qn.RENDER="render",qn.AFTER="render.after",qn.AGAIN="render.again",qn.END="render.end",qn.NEXT="render.next";class Qn extends An{}Qn.START="leafer.start",Qn.BEFORE_READY="leafer.before_ready",Qn.READY="leafer.ready",Qn.AFTER_READY="leafer.after_ready",Qn.VIEW_READY="leafer.view_ready",Qn.VIEW_COMPLETED="leafer.view_completed",Qn.STOP="leafer.stop",Qn.RESTART="leafer.restart",Qn.END="leafer.end",Qn.TRANSFORM="leafer.transform",Qn.MOVE="leafer.move",Qn.SCALE="leafer.scale",Qn.ROTATE="leafer.rotate",Qn.SKEW="leafer.skew";const{MOVE:Jn,SCALE:Zn,ROTATE:$n,SKEW:Kn}=Qn,to={x:Jn,y:Jn,scaleX:Zn,scaleY:Zn,rotation:$n,skewX:Kn,skewY:Kn},eo={};class so{set event(t){this.on(t)}on(t,e,s){if(!e){let e;if(d(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let s in t)d(e=t[s])?this.on(s,e[0],e[1]):this.on(s,e);return}let r,i,n;s&&("once"===s?i=!0:"boolean"==typeof s?r=s:(r=s.capture,i=s.once));const a=ro(this,r,!0),h=o(t)?t.split(" "):t,l=i?{listener:e,once:i}:{listener:e};h.forEach(t=>{t&&(n=a[t],n?-1===n.findIndex(t=>t.listener===e)&&n.push(l):a[t]=[l],Un[t]&&Yn.checkHas(this,t,"on"))})}off(t,e,s){if(t){const r=o(t)?t.split(" "):t;if(e){let t,i,n;s&&(t="boolean"==typeof s?s:"once"!==s&&s.capture);const o=ro(this,t);r.forEach(t=>{t&&(i=o[t],i&&(n=i.findIndex(t=>t.listener===e),n>-1&&i.splice(n,1),i.length||delete o[t],Un[t]&&Yn.checkHas(this,t,"off")))})}else{const{__bubbleMap:t,__captureMap:e}=this;r.forEach(s=>{t&&delete t[s],e&&delete e[s]})}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,s,r){return e?this.on(t,s?e=e.bind(s):e,r):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:r}}off_(t){if(!t)return;const e=d(t)?t:[t];e.forEach(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,s,r){if(!e)return d(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));u(s)?e=e.bind(s):r=s,this.on(t,e,{once:!0,capture:r})}emit(t,e,s){!e&&Gt.has(t)&&(e=Gt.get(t,{type:t,target:this,current:this}));const r=ro(this,s)[t];if(r){let i;for(let n=0,o=r.length;n<o&&!((i=r[n])&&(i.listener(e),i.once&&(this.off(t,i.listener,s),n--,o--),e&&e.isStopNow));n++);}this.syncEventer&&this.syncEventer.emitEvent(e,s)}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:r}=this,n=s&&s[t],o=r&&r[t];return!!(i(e)?n||o:e?o:n)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function ro(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:eo)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:eo)}}const{on:io,on_:no,off:oo,off_:ao,once:ho,emit:lo,emitEvent:uo,hasEvent:co,destroy:po}=so.prototype,_o={on:io,on_:no,off:oo,off_:ao,once:ho,emit:lo,emitEvent:uo,hasEvent:co,destroyEventer:po},fo=It.get("setAttr"),go={__setAttr(t,e,s){if(this.leaferIsCreated){const r=this.__.__getInput(t);if(!s||a(e)||i(e)||(fo.warn(this.innerName,t,e),e=void 0),u(e)||r!==e){this.__realSetAttr(t,e);const{CHANGE:s}=Dn,i=new Dn(s,this,t,r,e);if(this.isLeafer){this.emitEvent(new Dn(Dn.LEAFER_CHANGE,this,t,r,e));const s=to[t];s&&(this.emitEvent(new Qn(s,this)),this.emitEvent(new Qn(Qn.TRANSFORM,this)))}else this.hasEvent(s)&&this.emitEvent(i);return this.leafer.emitEvent(i),!0}return!1}return this.__realSetAttr(t,e),!0},__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:yo,multiplyParent:xo,translateInner:mo,defaultWorld:wo}=M,{toPoint:bo,tempPoint:Bo}=nt,vo={__updateWorldMatrix(){const{parent:t,__layout:e}=this;xo(this.__local||e,t?t.__world:wo,this.__world,!!e.affectScaleOrRotation,this.__,t&&(t.scrollY||t.scrollX)&&t.__)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,s=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(yo(e,s,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=s.x+s.offsetX,e.f=s.y+s.offsetY,(s.around||s.origin)&&(bo(s.around||s.origin,t.boxBounds,Bo),mo(e,-Bo.x,-Bo.y,!s.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:ko,updateAllMatrix:Co}=hn,{updateBounds:To}=wn,{toOuterOf:Oo,copyAndSpread:Po,copy:Lo}=Ct,{toBounds:So}=oi,Ro={__updateWorldBounds(){const t=this.__layout;Oo(t.renderBounds,this.__world,this.__world),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Yn.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Yn.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(),Oo(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Oo(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Oo(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,e=this.__;e.__pathInputed?So(e.path,t):(t.x=0,t.y=0,t.width=e.width,t.height=e.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),Co(this),To(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(Co(this),To(this,this))):ko(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(){const t=this.__layout;Po(t.strokeBounds,t.boxBounds,t.strokeBoxSpread)},__updateRenderBounds(){const t=this.__layout;t.renderSpread>0?Po(t.renderBounds,t.boxBounds,t.renderSpread):Lo(t.renderBounds,t.strokeBounds)}},Eo={__render(t,e){if(e.shape)return this.__renderShape(t,e);if(this.__worldOpacity){const s=this.__;if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.dimOpacity&&!s.dimskip?s.opacity*e.dimOpacity:s.opacity,this.__.__single){if("path"===s.eraser)return this.__renderEraser(t,e);const r=t.getSameCanvas(!0,!0);this.__draw(r,e,t),hn.copyCanvasByWorld(this,t,r,this.__nowWorld,s.__blendMode,!0),r.recycle(this.__nowWorld)}else this.__draw(t,e);It.showBounds&&It.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:Io}=gn,Mo={__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 s=this.__;if(s.dim?e.dimOpacity=!0===s.dim?.2:s.dim:s.dimskip&&e.dimOpacity&&(e.dimOpacity=0),s.__single&&!this.isBranchLeaf){if("path"===s.eraser)return this.__renderEraser(t,e);const r=t.getSameCanvas(!1,!0);this.__renderBranch(r,e);const i=this.__nowWorld;t.opacity=e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(r,i,i,s.__blendMode,!0),r.recycle(i)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:s}=this;for(let r=0,i=s.length;r<i;r++)Io(s[r],e)||s[r].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:s}=this;for(let r=0,i=s.length;r<i;r++)Io(s[r],e)||s[r].__clip(t,e)}}},Ao={},{LEAF:Wo,create:Do}=e,{toInnerPoint:No,toOuterPoint:Yo,multiplyParent:Xo}=M,{toOuterOf:zo}=Ct,{copy:Fo,move:Ho}=j,{moveLocal:Uo,zoomOfLocal:jo,rotateOfLocal:Go,skewOfLocal:Vo,moveWorld:qo,zoomOfWorld:Qo,rotateOfWorld:Jo,skewOfWorld:Zo,transform:$o,transformWorld:Ko,setTransform:ta,getFlipTransform:ea,getLocalOrigin:sa,getRelativeWorld:ra,drop:ia}=hn;exports.Leaf=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return f}get __LayoutProcessor(){return Mn}get leaferIsCreated(){return this.leafer&&this.leafer.created}get leaferIsReady(){return this.leafer&&this.leafer.ready}get isLeafer(){return!1}get isBranch(){return!1}get isBranchLeaf(){return!1}get __localMatrix(){return this.__local||this.__layout}get __localBoxBounds(){return this.__local||this.__layout}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get boxBounds(){return this.getBounds("box","inner")}get renderBounds(){return this.getBounds("render","inner")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.__layout.update(),this.__worldOpacity}get __worldFlipped(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}get __inLazyBounds(){return this.leaferIsCreated&&this.leafer.lazyBounds.hit(this.__world)}get pathInputed(){return this.__.__pathInputed}set event(t){this.on(t)}constructor(t){this.innerId=Do(Wo),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(Wn.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(Wn.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(Wn.MOUNTED,t,"once")}nextRender(t,e,s){this.leafer?this.leafer.nextRender(t,e,s):this.waitLeafer(()=>this.leafer.nextRender(t,e,s))}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(Wn.MOUNTED)):this.__emitLifeEvent(Wn.UNMOUNTED),this.isBranch){const{children:e}=this;for(let s=0,r=e.length;s<r;s++)e[s].__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(){}__updateContentBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateAutoLayout(){}__updateFlowLayout(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){this.__hasEraser=!!t||this.children.some(t=>t.__.eraser)}__renderEraser(t,e){t.save(),this.__clip(t,e);const{renderBounds:s}=this.__layout;t.clearRect(s.x,s.y,s.width,s.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,s=this.__world;return Xo(s,t.matrix,e,void 0,s),zo(this.__layout.renderBounds,e,e),e.half!==s.half&&(e.half=s.half),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:s,scaleY:r}=ki.patternLocked?this.__world:this.__nowWorld;return t&&(s<0&&(s=-s),r<0&&(r=-r)),(!0===e||"zoom-in"===e&&s>1&&r>1)&&(s=r=1),Ao.scaleX=s,Ao.scaleY=r,Ao}getTransform(t){return this.__layout.getTransform(t||"local")}getBounds(t,e){return this.__layout.getBounds(t,e)}getLayoutBounds(t,e,s){return this.__layout.getLayoutBounds(t,e,s)}getLayoutPoints(t,e){return this.__layout.getLayoutPoints(t,e)}getWorldBounds(t,e,s){const r=e?ra(this,e):this.worldTransform,i=s?t:{};return zo(t,r,i),i}worldToLocal(t,e,s,r){this.parent?this.parent.worldToInner(t,e,s,r):e&&Fo(e,t)}localToWorld(t,e,s,r){this.parent?this.parent.innerToWorld(t,e,s,r):e&&Fo(e,t)}worldToInner(t,e,s,r){r&&(r.innerToWorld(t,e,s),t=e||t),No(this.worldTransform,t,e,s)}innerToWorld(t,e,s,r){Yo(this.worldTransform,t,e,s),r&&r.worldToInner(e||t,null,s)}getBoxPoint(t,e,s,r){return this.getBoxPointByInner(this.getInnerPoint(t,e,s,r),null,null,!0)}getBoxPointByInner(t,e,s,r){const i=r?t:Object.assign({},t),{x:n,y:o}=this.boxBounds;return Ho(i,-n,-o),i}getInnerPoint(t,e,s,r){const i=r?t:{};return this.worldToInner(t,i,s,e),i}getInnerPointByBox(t,e,s,r){const i=r?t:Object.assign({},t),{x:n,y:o}=this.boxBounds;return Ho(i,n,o),i}getInnerPointByLocal(t,e,s,r){return this.getInnerPoint(t,this.parent,s,r)}getLocalPoint(t,e,s,r){const i=r?t:{};return this.worldToLocal(t,i,s,e),i}getLocalPointByInner(t,e,s,r){return this.getWorldPoint(t,this.parent,s,r)}getPagePoint(t,e,s,r){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,s,r)}getWorldPoint(t,e,s,r){const i=r?t:{};return this.innerToWorld(t,i,s,e),i}getWorldPointByBox(t,e,s,r){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,r),e,s,!0)}getWorldPointByLocal(t,e,s,r){const i=r?t:{};return this.localToWorld(t,i,s,e),i}getWorldPointByPage(t,e,s,r){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,s,r)}setTransform(t,e,s){ta(this,t,e,s)}transform(t,e,s){$o(this,t,e,s)}move(t,e,s){Uo(this,t,e,s)}moveInner(t,e,s){qo(this,t,e,!0,s)}scaleOf(t,e,s,r,i){jo(this,sa(this,t),e,s,r,i)}rotateOf(t,e,s){Go(this,sa(this,t),e,s)}skewOf(t,e,s,r,i){Vo(this,sa(this,t),e,s,r,i)}transformWorld(t,e,s){Ko(this,t,e,s)}moveWorld(t,e,s){qo(this,t,e,!1,s)}scaleOfWorld(t,e,s,r,i){Qo(this,t,e,s,r,i)}rotateOfWorld(t,e){Jo(this,t,e)}skewOfWorld(t,e,s,r,i){Zo(this,t,e,s,r,i)}flip(t,e){$o(this,ea(this,t),!1,e)}scaleResize(t,e=t,s){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,s){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return Xt.need("path")}getMotionPoint(t){return Xt.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,s){ia(this,t,e,s)}on(t,e,s){}off(t,e,s){}on_(t,e,s,r){}off_(t){}once(t,e,s,r){}emit(t,e,s){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,s){s?this.addAttr(t,e,s):Ui(this.prototype,t,e)}static addAttr(t,e,s,r){s||(s=Wi),s(e,r)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new Wn(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(Wn.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},exports.Leaf=qt([Qi(go),Qi(vo),Qi(Ro),Qi(_o),Qi(Eo)],exports.Leaf);const{setListWithFn:na}=Ct,{sort:oa}=wn,{localBoxBounds:aa,localStrokeBounds:ha,localRenderBounds:la,maskLocalBoxBounds:da,maskLocalStrokeBounds:ua,maskLocalRenderBounds:ca}=gn,pa=new It("Branch");exports.Branch=class extends exports.Leaf{__updateStrokeSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(){na(this.__layout.boxBounds,this.children,this.__hasMask?da:aa)}__updateStrokeBounds(){na(this.__layout.strokeBounds,this.children,this.__hasMask?ua:ha)}__updateRenderBounds(){na(this.__layout.renderBounds,this.children,this.__hasMask?ca:la)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let s=0,r=e.length;s<r;s++)e[s].__tempNumber=s,e[s].__.zIndex&&(t=!0);e.sort(oa),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return pa.warn("add self or destroyed");const s=i(e);if(!t.__){if(d(t))return t.forEach(t=>{this.add(t,e),s||e++});t=Ht.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 r=t.__layout;r.boxChanged||r.boxChange(),r.matrixChanged||r.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(Wn.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Wn.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 s=this.children.indexOf(t);s>-1&&(this.children.splice(s,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(Wn.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Wn.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const s=new Wn(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(s),this.leafer.emitEvent(s)}},exports.Branch=qt([Qi(Mo)],exports.Branch);class _a{get length(){return this.list.length}constructor(t){this.reset(),t&&(d(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:r}=this;for(let t=e,i=r.length;t<i;t++)s[r[t].innerId]++;0===e?r.unshift(t):(e>r.length&&(e=r.length),r.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 r=0,n=e.length;r<n;r++)i(s)?e[r].innerId===t.innerId&&(s=r,delete this.keys[t.innerId]):this.keys[e[r].innerId]=r-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 _a;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let s=0,r=t.length;s<r;s++)e[t[s].innerId]=s}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}exports.AlignHelper=ht,exports.AroundHelper=nt,exports.AutoBounds=class{constructor(t,e,s,r,i,n){u(t)?this.copy(t):this.set(t,e,s,r,i,n)}set(t=0,e=0,s=0,r=0,i=0,n=0){this.top=t,this.right=e,this.bottom=s,this.left=r,this.width=i,this.height=n}copy(t){const{top:e,right:s,bottom:r,left:i,width:n,height:o}=t;this.set(e,s,r,i,n,o)}getBoundsFrom(t){const{top:e,right:s,bottom:r,left:i,width:n,height:o}=this;return new Lt(i,e,n||t.width-i-s,o||t.height-e-r)}},exports.BezierHelper=Me,exports.Bounds=Lt,exports.BoundsEvent=Yn,exports.BoundsHelper=Ct,exports.BranchHelper=wn,exports.BranchRender=Mo,exports.CanvasManager=class{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:s}=this;for(let r=0,i=s.length;r<i;r++)if(e=s[r],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const r=zt.canvas(t);return this.add(r),r}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let s=0,r=this.list.length;s<r;s++)t=this.list[s],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach(t=>{t.destroy()}),this.list.length=0}destroy(){this.clear()}},exports.ChildEvent=Wn,exports.Creator=zt,exports.DataHelper=p,exports.Debug=It,exports.EllipseHelper=He,exports.Event=An,exports.EventCreator=Gt,exports.Eventer=so,exports.FileHelper=gi,exports.ImageEvent=Nn,exports.ImageManager=ki,exports.IncrementId=e,exports.LayoutEvent=Vn,exports.LeafBounds=Ro,exports.LeafBoundsHelper=gn,exports.LeafData=f,exports.LeafDataProxy=go,exports.LeafEventer=_o,exports.LeafHelper=hn,exports.LeafLayout=Mn,exports.LeafLevelList=class{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(d(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:s}=this;e[t.innerId]||(e[t.innerId]=1,s[t.__level]?s[t.__level].push(t):(s[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(s=>{e=this.levelMap[s];for(let s=0,r=e.length;s<r;s++)t(e[s])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}},exports.LeafList=_a,exports.LeafMatrix=vo,exports.LeafRender=Eo,exports.LeaferCanvasBase=class extends te{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(s,r){super(),this.size={},this.worldTransform={},s||(s=ie),this.manager=r,this.innerId=e.create(e.CNAVAS);const{width:i,height:n,pixelRatio:o}=s;this.autoLayout=!i||!n,this.size.pixelRatio=o||t.devicePixelRatio,this.config=s,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 s;this.context&&!this.unreal&&e&&this.width&&(s=this.getSameCanvas(),s.copyWorld(this));const r=this.size;p.copyAttrs(r,t,ne),ne.forEach(t=>r[t]||(r[t]=1)),this.bounds=new Lt(0,0,this.width,this.height),this.context&&!this.unreal&&(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&s&&(this.clearWorld(s.bounds),this.copyWorld(s),s.recycle())}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:s,pixelSnap:r}=this,i=this.worldTransform;e&&se(t,e,i),i.a=t.a*s,i.b=t.b*s,i.c=t.c*s,i.d=t.d*s,i.e=t.e*s,i.f=t.f*s,r&&(t.half&&t.half*s%2?(i.e=re(i.e-.5)+.5,i.f=re(i.f-.5)+.5):(i.e=re(i.e),i.f=re(i.f))),this.setTransform(i.a,i.b,i.c,i.d,i.e,i.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,s,r){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),s&&this.setStrokeOptions(s,r)}setStrokeOptions(t,e){let{strokeCap:s,strokeJoin:r,dashPattern:n,dashOffset:o,miterLimit:a}=t;e&&(e.strokeCap&&(s=e.strokeCap),e.strokeJoin&&(r=e.strokeJoin),i(e.dashPattern)||(n=e.dashPattern),i(e.dashOffset)||(o=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=s,this.strokeJoin=r,this.dashPattern=n,this.dashOffset=o,this.miterLimit=a}saveBlendMode(t){this.savedBlendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedBlendMode}hitFill(t,e){return!0}hitStroke(t,e){return!0}hitPixel(t,e,s=1){return!0}setWorldShadow(t,e,s,r){const{pixelRatio:i}=this;this.shadowOffsetX=t*i,this.shadowOffsetY=e*i,this.shadowBlur=s*i,this.shadowColor=r||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,s,r){if(r&&(this.blendMode=r),e){const{pixelRatio:r}=this;s||(s=e),this.drawImage(t.view,e.x*r,e.y*r,e.width*r,e.height*r,s.x*r,s.y*r,s.width*r,s.height*r)}else this.drawImage(t.view,0,0);r&&(this.blendMode="source-over")}copyWorldToInner(t,e,s,r){if(r&&(this.blendMode=r),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,Ct.tempToOuterOf(s,e)),this.restore();else{const{pixelRatio:r}=this;this.drawImage(t.view,e.x*r,e.y*r,e.width*r,e.height*r,s.x,s.y,s.width,s.height)}r&&(this.blendMode="source-over")}copyWorldByReset(t,e,s,r,i){this.resetTransform(),this.copyWorld(t,e,s,r),i||this.useWorldTransform()}useGrayscaleAlpha(t){let e,s;this.setTempBounds(t,!0,!0);const{context:r}=this,i=r.getImageData(St.x,St.y,St.width,St.height),{data:n}=i;for(let t=0,r=n.length;t<r;t+=4)s=.299*n[t]+.587*n[t+1]+.114*n[t+2],(e=n[t+3])&&(n[t+3]=255===e?s:e*(s/255));r.putImageData(i,St.x,St.y)}useMask(t,e,s){this.copyWorld(t,e,s,"destination-in")}useEraser(t,e,s){this.copyWorld(t,e,s,"destination-out")}fillWorld(t,e,s){s&&(this.blendMode=s),this.fillStyle=e,this.setTempBounds(t),this.fillRect(St.x,St.y,St.width,St.height),s&&(this.blendMode="source-over")}strokeWorld(t,e,s){s&&(this.blendMode=s),this.strokeStyle=e,this.setTempBounds(t),this.strokeRect(St.x,St.y,St.width,St.height),s&&(this.blendMode="source-over")}clipWorld(t,e){this.beginPath(),this.setTempBounds(t,e),this.rect(St.x,St.y,St.width,St.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e){this.setTempBounds(t,e),this.clearRect(St.x,St.y,St.width,St.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempBounds(t,e,s){St.set(t),s&&St.intersect(this.bounds),St.scale(this.pixelRatio),e&&St.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:s,pixelSnap:r}=this,i=this.manager?this.manager.get(s):zt.canvas(Object.assign({},s));return i.save(),t&&(ee(i.worldTransform,this.worldTransform),i.useWorldTransform()),e&&(i.smooth=this.smooth),i.pixelSnap!==r&&(i.pixelSnap=r),i}recycle(t){this.recycled||(this.restore(),t?this.clearWorld(t,!0):this.clear(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(t){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}},exports.LeaferEvent=Qn,exports.LeaferImage=class{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=Oi(Ti),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}ki.isFormat("svg",t)&&(this.isSVG=!0),ki.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(e,s){if(!this.loading){this.loading=!0;let{loadImage:e,loadImageWithProgress:s}=t.origin,r=this.config.showProgress&&s&&this.onProgress.bind(this);r&&(e=s),Bi.tasker.add(()=>Qt(this,void 0,void 0,function*(){return yield e(this.url,r).then(t=>this.setView(t)).catch(t=>{this.error=t,this.onComplete(!1)})}))}return this.waitComplete.push(e,s),this.waitComplete.length-2}unload(t,e){const s=this.waitComplete;if(e){const e=s[t+1];e&&e({type:"stop"})}s[t]=s[t+1]=void 0}setView(t){this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onProgress(t){this.progress=t}onComplete(t){let e;this.waitComplete.forEach((s,r)=>{e=r%2,s&&(t?e||s(this):e&&s(this.error))}),this.waitComplete.length=0,this.loading=!1}getFull(t){return this.view}getCanvas(e,s,r,i,n,o){if(e||(e=this.width),s||(s=this.height),this.cache){let{params:t,data:e}=this.cache;for(let s in t)if(t[s]!==arguments[s]){e=null;break}if(e)return e}const a=t.origin.createCanvas(Li(Pi(e+(n||0)),1),Li(Pi(s+(o||0)),1)),h=a.getContext("2d");return r&&(h.globalAlpha=r),h.drawImage(this.view,0,0,e,s),this.cache=this.use>1?{data:a,params:arguments}:null,a}getPattern(e,s,r,i){const n=t.canvas.createPattern(e,s);try{r&&n.setTransform&&(n.setTransform(r),r=void 0)}catch(t){}return i&&p.stintSet(i,"transform",r),n}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}},exports.MathHelper=m,exports.Matrix=$,exports.MatrixHelper=M,exports.NeedConvertToCanvasCommandMap=de,exports.OneRadian=b,exports.PI2=B,exports.PI_2=v,exports.PathBounds=oi,exports.PathCommandDataHelper=Js,exports.PathCommandMap=he,exports.PathConvert=Os,exports.PathCorner=pi,exports.PathCreator=pr,exports.PathDrawer=Pr,exports.PathHelper=oe,exports.PathNumberCommandLengthMap=_e,exports.PathNumberCommandMap=pe,exports.Platform=t,exports.Plugin=Xt,exports.Point=J,exports.PointHelper=j,exports.PropertyEvent=Dn,exports.RectHelper=fe,exports.RenderEvent=qn,exports.ResizeEvent=jn,exports.Resource=Bi,exports.Run=Dt,exports.StringNumberMap=Rt,exports.TaskItem=mi,exports.TaskProcessor=wi,exports.TwoPointBoundsHelper=tt,exports.UICreator=Ht,exports.WaitHelper=kn,exports.WatchEvent=Gn,exports.affectRenderBoundsType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))},exports.affectStrokeBoundsType=Yi,exports.attr=Mi,exports.autoLayoutType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),Di(this))}}))},exports.boundsType=Wi,exports.canvasPatch=function(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,s,r,i){fi(this,t,e,s,r,i)})}(t)},exports.canvasSizeAttrs=ne,exports.createDescriptor=Ei,exports.cursorType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))},exports.dataProcessor=function(t){return(e,s)=>{Si(e,"__DataProcessor",{get:()=>t})}},exports.dataType=function(t){return Ii(t)},exports.decorateLeafAttr=Ii,exports.defineDataProcessor=Ui,exports.defineKey=Si,exports.defineLeafAttr=Ai,exports.doBoundsType=Di,exports.doStrokeType=Xi,exports.emptyData={},exports.eraserType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))},exports.getBoundsData=C,exports.getDescriptor=Ri,exports.getMatrixData=T,exports.getPointData=k,exports.hitType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===It.showBounds&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor())}}))},exports.isArray=d,exports.isData=function(t){return u(t)&&!d(t)},exports.isEmptyData=c,exports.isFinite=a,exports.isNull=n,exports.isNumber=h,exports.isObject=u,exports.isString=o,exports.isUndefined=i,exports.layoutProcessor=function(t){return(e,s)=>{Si(e,"__LayoutProcessor",{get:()=>t})}},exports.leaferTransformAttrMap=to,exports.maskType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))},exports.naturalBoundsType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&(Di(this),this.__.__removeNaturalSize())}}))},exports.opacityType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&Fi(this)}}))},exports.pathInputType=function(t){return Ii(t,t=>({set(e){const s=this.__;2!==s.__pathInputed&&(s.__pathInputed=e?1:0),e||(s.__pathForRender=void 0),this.__setAttr(t,e),Di(this)}}))},exports.pathType=Ni,exports.pen=_i,exports.positionType=function(t,e){return Ii(t,t=>({set(s){this.__setAttr(t,s,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))},exports.registerUI=function(){return t=>{Ht.register(t)}},exports.registerUIEvent=function(){return t=>{Gt.register(t)}},exports.rewrite=function(t){return(e,s)=>{Gi.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}},exports.rewriteAble=function(){return t=>{qi()}},exports.rotationType=function(t,e){return Ii(t,t=>({set(s){this.__setAttr(t,s,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))},exports.scaleType=function(t,e){return Ii(t,t=>({set(s){this.__setAttr(t,s,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))},exports.sortType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))},exports.strokeType=zi,exports.surfaceType=function(t){return Ii(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))},exports.tempBounds=St,exports.tempMatrix=K,exports.tempPoint=Z,exports.tryToNumber=function(t){return"string"==typeof t&&l.test(t)?+t:t},exports.useModule=Qi,exports.version="1.9.1",exports.visibleType=function(t){return Ii(t,t=>({set(e){const s=this.visible;if(!0===s&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Hi(this,t,e,s))}else 0===s&&!0===e&&this.animation&&this.__runAnimation("in");Hi(this,t,e,s),this.mask&&Fi(this)}}))};
1
+ "use strict";const t={toURL(t,e){let s=encodeURIComponent(t);return"text"===e?s="data:text/plain;charset=utf-8,"+s:"svg"===e&&(s="data:image/svg+xml,"+s),s},image:{hitCanvasSize:100,maxCacheSize:4096e3,maxPatternSize:8847360,crossOrigin:"anonymous",getRealURL(e){const{prefix:s,suffix:r}=t.image;return!r||e.startsWith("data:")||e.startsWith("blob:")||(e+=(e.includes("?")?"&":"?")+r),s&&"/"===e[0]&&(e=s+e),e}}},e={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=s;return e[t]?e[t]++:(e[t]=1,0)}},s=e;var r;exports.Answer=void 0,(r=exports.Answer||(exports.Answer={}))[r.No=0]="No",r[r.Yes=1]="Yes",r[r.NoAndSkip=2]="NoAndSkip",r[r.YesAndSkip=3]="YesAndSkip";function i(t){return void 0===t}function o(t){return null==t}function n(t){return"string"==typeof t}const{isFinite:a}=Number;function h(t){return"number"==typeof t}const l=/^-?\d+(?:\.\d+)?$/;const{isArray:d}=Array;function u(t){return t&&"object"==typeof t}function c(t){return"{}"===JSON.stringify(t)}const p={default:(t,e)=>(_(e,t),_(t,e),t),assign(t,e,s){let r;Object.keys(e).forEach(i=>{var o,n;if(r=e[i],(null==r?void 0:r.constructor)===Object&&(null===(o=t[i])||void 0===o?void 0:o.constructor)===Object)return _(t[i],e[i],s&&s[i]);s&&i in s?(null===(n=s[i])||void 0===n?void 0:n.constructor)===Object&&_(t[i]={},e[i],s[i]):t[i]=e[i]})},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 s=0,r=t.length;s<r;s++)e[t[s]]=!0;return e},stintSet(t,e,s){s||(s=void 0),t[e]!==s&&(t[e]=s)}},{assign:_}=p;class f{get __useNaturalRatio(){return!0}get __isLinePath(){const{path:t}=this;return t&&6===t.length&&1===t[0]}get __blendMode(){if(this.eraser&&"path"!==this.eraser)return"destination-out";const{blendMode:t}=this;return"pass-through"===t?null:t}constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(!i(e))return e}return this[t]}__getData(){const t={tag:this.__leaf.tag},{__input:e}=this;let s;for(let r in this)"_"!==r[0]&&(s=e?e[r]:void 0,t[r]=i(s)?this[r]: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(d(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:r}=this;s.tag=this.__leaf.tag;for(let o in this)if("_"!==o[0]&&(t=this["_"+o],!i(t))){if("path"===o&&!this.__pathInputed)continue;e=r?r[o]:void 0,s[o]=i(e)?t:e}}if(e&&e.matrix){const{a:t,b:e,c:r,d:i,e:o,f:n}=this.__leaf.__localMatrix;s.matrix={a:t,b:e,c:r,d:i,e:o,f:n}}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{round:g,pow:y,PI:x}=Math,m={within:(t,e,s)=>(u(e)&&(s=e.max,e=e.min),!i(e)&&t<e&&(t=e),!i(s)&&t>s&&(t=s),t),fourNumber(t,e){let s;if(d(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]),e)for(let t=0;t<4;t++)s[t]>e&&(s[t]=e);return s},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),m.float(t)),getGapRotation(t,e,s=0){let r=t+s;if(e>1){const t=Math.abs(r%e);(t<1||t>e-1)&&(r=Math.round(r/e)*e)}return r-s},float(t,e){const s=i(e)?1e12:y(10,e);return-0===(t=g(t*s)/s)?0:t},getScaleData(t,e,s,r){if(r||(r={}),e){const t=(h(e)?e:e.width||0)/s.width,i=(h(e)?e:e.height||0)/s.height;r.scaleX=t||i||1,r.scaleY=i||t||1}else t&&m.assignScale(r,t);return r},assignScale(t,e){h(e)?t.scaleX=t.scaleY=e:(t.scaleX=e.x,t.scaleY=e.y)},randInt:w,randColor:t=>`rgba(${w(255)},${w(255)},${w(255)},${t||1})`};function w(t){return Math.round(Math.random()*t)}const b=x/180,B=2*x,v=x/2;function k(){return{x:0,y:0}}function C(){return{x:0,y:0,width:0,height:0}}function T(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const{sin:P,cos:O,acos:L,sqrt:S}=Math,{float:R}=m,E={};function I(){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 M={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},defaultWorld:I(),tempMatrix:{},set(t,e=1,s=0,r=0,i=1,o=0,n=0){t.a=e,t.b=s,t.c=r,t.d=i,t.e=o,t.f=n},get:T,getWorld:I,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,s){t.e+=e,t.f+=s},translateInner(t,e,s,r){t.e+=t.a*e+t.c*s,t.f+=t.b*e+t.d*s,r&&(t.e-=e,t.f-=s)},scale(t,e,s=e){t.a*=e,t.b*=e,t.c*=s,t.d*=s},scaleOfOuter(t,e,s,r){A.toInnerPoint(t,e,E),A.scaleOfInner(t,E,s,r)},scaleOfInner(t,e,s,r=s){A.translateInner(t,e.x,e.y),A.scale(t,s,r),A.translateInner(t,-e.x,-e.y)},rotate(t,e){const{a:s,b:r,c:i,d:o}=t,n=O(e*=b),a=P(e);t.a=s*n-r*a,t.b=s*a+r*n,t.c=i*n-o*a,t.d=i*a+o*n},rotateOfOuter(t,e,s){A.toInnerPoint(t,e,E),A.rotateOfInner(t,E,s)},rotateOfInner(t,e,s){A.translateInner(t,e.x,e.y),A.rotate(t,s),A.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:r,b:i,c:o,d:n}=t;s&&(s*=b,t.a=r+o*s,t.b=i+n*s),e&&(e*=b,t.c=o+r*e,t.d=n+i*e)},skewOfOuter(t,e,s,r){A.toInnerPoint(t,e,E),A.skewOfInner(t,E,s,r)},skewOfInner(t,e,s,r=0){A.translateInner(t,e.x,e.y),A.skew(t,s,r),A.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:r,c:i,d:o,e:n,f:a}=t;t.a=e.a*s+e.b*i,t.b=e.a*r+e.b*o,t.c=e.c*s+e.d*i,t.d=e.c*r+e.d*o,t.e=e.e*s+e.f*i+n,t.f=e.e*r+e.f*o+a},multiplyParent(t,e,s,r,o){const{e:n,f:a}=t;if(s||(s=t),i(r)&&(r=1!==t.a||t.b||t.c||1!==t.d),r){const{a:r,b:i,c:n,d:a}=t;s.a=r*e.a+i*e.c,s.b=r*e.b+i*e.d,s.c=n*e.a+a*e.c,s.d=n*e.b+a*e.d,o&&(s.scaleX=e.scaleX*o.scaleX,s.scaleY=e.scaleY*o.scaleY)}else s.a=e.a,s.b=e.b,s.c=e.c,s.d=e.d,o&&(s.scaleX=e.scaleX,s.scaleY=e.scaleY);s.e=n*e.a+a*e.c+e.e,s.f=n*e.b+a*e.d+e.f},divide(t,e){A.multiply(t,A.tempInvert(e))},divideParent(t,e){A.multiplyParent(t,A.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=A;return A.copy(e,t),A.invert(e),e},invert(t){const{a:e,b:s,c:r,d:i,e:o,f:n}=t;if(s||r){const a=1/(e*i-s*r);t.a=i*a,t.b=-s*a,t.c=-r*a,t.d=e*a,t.e=-(o*i-n*r)*a,t.f=-(n*e-o*s)*a}else if(1===e&&1===i)t.e=-o,t.f=-n;else{const s=1/(e*i);t.a=i*s,t.d=e*s,t.e=-o*i*s,t.f=-n*e*s}},toOuterPoint(t,e,s,r){const{x:i,y:o}=e;s||(s=e),s.x=i*t.a+o*t.c,s.y=i*t.b+o*t.d,r||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,r){const{a:i,b:o,c:n,d:a}=t,h=1/(i*a-o*n),{x:l,y:d}=e;if(s||(s=e),s.x=(l*a-d*n)*h,s.y=(d*i-l*o)*h,!r){const{e:e,f:r}=t;s.x-=(e*a-r*n)*h,s.y-=(r*i-e*o)*h}},setLayout(t,e,s,r,o){const{x:n,y:a,scaleX:h,scaleY:l}=e;if(i(o)&&(o=e.rotation||e.skewX||e.skewY),o){const{rotation:s,skewX:r,skewY:i}=e,o=s*b,n=O(o),a=P(o);if(r||i){const e=r*b,s=i*b;t.a=(n+s*-a)*h,t.b=(a+s*n)*h,t.c=(e*n-a)*l,t.d=(n+e*a)*l}else t.a=n*h,t.b=a*h,t.c=-a*l,t.d=n*l}else t.a=h,t.b=0,t.c=0,t.d=l;t.e=n,t.f=a,(s=s||r)&&A.translateInner(t,-s.x,-s.y,!r)},getLayout(t,e,s,r){const{a:i,b:o,c:n,d:a,e:h,f:l}=t;let d,u,c,p,_,f=h,g=l;if(o||n){const t=i*a-o*n;if(n&&!r){d=S(i*i+o*o),u=t/d;const e=i/d;c=o>0?L(e):-L(e)}else{u=S(n*n+a*a),d=t/u;const e=n/u;c=v-(a>0?L(-e):-L(e))}const e=R(O(c)),s=P(c);d=R(d),u=R(u),p=e?R((n/u+s)/e/b,9):0,_=e?R((o/d-s)/e/b,9):0,c=R(c/b)}else d=i,u=a,c=p=_=0;return(e=s||e)&&(f+=e.x*i+e.y*n,g+=e.x*o+e.y*a,s||(f-=e.x,g-=e.y)),{x:f,y:g,scaleX:d,scaleY:u,rotation:c,skewX:p,skewY:_}},withScale(t,e,s=e){const r=t;if(!e||!s){const{a:r,b:i,c:o,d:n}=t;i||o?s=(r*n-i*o)/(e=S(r*r+i*i)):(e=r,s=n)}return r.scaleX=e,r.scaleY=s,r},reset(t){A.set(t)}},A=M,{toInnerPoint:W,toOuterPoint:D}=M,{sin:N,cos:Y,abs:X,sqrt:z,atan2:F,min:H,round:j}=Math,U={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},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,s){t.x=e,t.y=s},round(t,e){t.x=e?j(t.x-.5)+.5:j(t.x),t.y=e?j(t.y-.5)+.5:j(t.y)},move(t,e,s){u(e)?(t.x+=e.x,t.y+=e.y):(t.x+=e,t.y+=s)},scale(t,e,s=e){t.x&&(t.x*=e),t.y&&(t.y*=s)},scaleOf(t,e,s,r=s){t.x+=(t.x-e.x)*(s-1),t.y+=(t.y-e.y)*(r-1)},rotate(t,e,s){s||(s=G.defaultPoint);const r=Y(e*=b),i=N(e),o=t.x-s.x,n=t.y-s.y;t.x=s.x+o*r-n*i,t.y=s.y+o*i+n*r},tempToInnerOf(t,e){const{tempPoint:s}=G;return q(s,t),W(e,s,s),s},tempToOuterOf(t,e){const{tempPoint:s}=G;return q(s,t),D(e,s,s),s},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:s}=G;return q(s,t),G.toInnerRadiusPointOf(t,e,s),s},toInnerRadiusPointOf(t,e,s){s||(s=t),W(e,t,s),s.radiusX=Math.abs(t.radiusX/e.scaleX),s.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,s){W(e,t,s)},toOuterOf(t,e,s){D(e,t,s)},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)=>V(t.x,t.y,e.x,e.y),getDistanceFrom(t,e,s,r){const i=X(s-t),o=X(r-e);return z(i*i+o*o)},getMinDistanceFrom:(t,e,s,r,i,o)=>H(V(t,e,s,r),V(s,r,i,o)),getAngle:(t,e)=>Q(t,e)/b,getRotation:(t,e,s,r)=>(r||(r=e),G.getRadianFrom(t.x,t.y,e.x,e.y,s.x,s.y,r.x,r.y)/b),getRadianFrom(t,e,s,r,o,n,a,h){i(a)&&(a=s,h=r);const l=t-s,d=e-r,u=o-a,c=n-h;return Math.atan2(l*c-d*u,l*u+d*c)},getAtan2:(t,e)=>F(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s,r){const i=Q(t,e);return(e=r?e:{}).x=t.x+Y(i)*s,e.y=t.y+N(i)*s,e},toNumberPoints(t){let e=t;return u(t[0])&&(e=[],t.forEach(t=>e.push(t.x,t.y))),e},reset(t){G.reset(t)}},G=U,{getDistanceFrom:V,copy:q,getAtan2:Q}=G;class J{constructor(t,e){this.set(t,e)}set(t,e){return u(t)?U.copy(this,t):U.set(this,t,e),this}get(){const{x:t,y:e}=this;return{x:t,y:e}}clone(){return new J(this)}move(t,e){return U.move(this,t,e),this}scale(t,e){return U.scale(this,t,e),this}scaleOf(t,e,s){return U.scaleOf(this,t,e,s),this}rotate(t,e){return U.rotate(this,t,e),this}rotateOf(t,e){return U.rotate(this,e,t),this}getRotation(t,e,s){return U.getRotation(this,t,e,s)}toInnerOf(t,e){return U.toInnerOf(this,t,e),this}toOuterOf(t,e){return U.toOuterOf(this,t,e),this}getCenter(t){return new J(U.getCenter(this,t))}getDistance(t){return U.getDistance(this,t)}getDistancePoint(t,e,s){return new J(U.getDistancePoint(this,t,e,s))}getAngle(t){return U.getAngle(this,t)}getAtan2(t){return U.getAtan2(this,t)}reset(){return U.reset(this),this}}const Z=new J;class ${constructor(t,e,s,r,i,o){this.set(t,e,s,r,i,o)}set(t,e,s,r,i,o){return u(t)?M.copy(this,t):M.set(this,t,e,s,r,i,o),this}setWith(t){return M.copy(this,t),this.scaleX=t.scaleX,this.scaleY=t.scaleY,this}get(){const{a:t,b:e,c:s,d:r,e:i,f:o}=this;return{a:t,b:e,c:s,d:r,e:i,f:o}}clone(){return new $(this)}translate(t,e){return M.translate(this,t,e),this}translateInner(t,e){return M.translateInner(this,t,e),this}scale(t,e){return M.scale(this,t,e),this}scaleWith(t,e){return M.scale(this,t,e),this.scaleX*=t,this.scaleY*=e||t,this}scaleOfOuter(t,e,s){return M.scaleOfOuter(this,t,e,s),this}scaleOfInner(t,e,s){return M.scaleOfInner(this,t,e,s),this}rotate(t){return M.rotate(this,t),this}rotateOfOuter(t,e){return M.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return M.rotateOfInner(this,t,e),this}skew(t,e){return M.skew(this,t,e),this}skewOfOuter(t,e,s){return M.skewOfOuter(this,t,e,s),this}skewOfInner(t,e,s){return M.skewOfInner(this,t,e,s),this}multiply(t){return M.multiply(this,t),this}multiplyParent(t){return M.multiplyParent(this,t),this}divide(t){return M.divide(this,t),this}divideParent(t){return M.divideParent(this,t),this}invert(){return M.invert(this),this}invertWith(){return M.invert(this),this.scaleX=1/this.scaleX,this.scaleY=1/this.scaleY,this}toOuterPoint(t,e,s){M.toOuterPoint(this,t,e,s)}toInnerPoint(t,e,s){M.toInnerPoint(this,t,e,s)}setLayout(t,e,s){return M.setLayout(this,t,e,s),this}getLayout(t,e,s){return M.getLayout(this,t,e,s)}withScale(t,e){return M.withScale(this,t,e)}reset(){M.reset(this)}}const K=new $,tt={tempPointBounds:{},setPoint(t,e,s){t.minX=t.maxX=e,t.minY=t.maxY=s},addPoint(t,e,s){t.minX=e<t.minX?e:t.minX,t.minY=s<t.minY?s:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=s>t.maxY?s:t.maxY},addBounds(t,e,s,r,i){et(t,e,s),et(t,e+r,s+i)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},addPointBounds(t,e){t.minX=e.minX<t.minX?e.minX:t.minX,t.minY=e.minY<t.minY?e.minY:t.minY,t.maxX=e.maxX>t.maxX?e.maxX:t.maxX,t.maxY=e.maxY>t.maxY?e.maxY:t.maxY},toBounds(t,e){e.x=t.minX,e.y=t.minY,e.width=t.maxX-t.minX,e.height=t.maxY-t.minY}},{addPoint:et}=tt;var st,rt;exports.Direction4=void 0,(st=exports.Direction4||(exports.Direction4={}))[st.top=0]="top",st[st.right=1]="right",st[st.bottom=2]="bottom",st[st.left=3]="left",exports.Direction9=void 0,(rt=exports.Direction9||(exports.Direction9={}))[rt.topLeft=0]="topLeft",rt[rt.top=1]="top",rt[rt.topRight=2]="topRight",rt[rt.right=3]="right",rt[rt.bottomRight=4]="bottomRight",rt[rt.bottom=5]="bottom",rt[rt.bottomLeft=6]="bottomLeft",rt[rt.left=7]="left",rt[rt.center=8]="center",rt[rt["top-left"]=0]="top-left",rt[rt["top-right"]=2]="top-right",rt[rt["bottom-right"]=4]="bottom-right",rt[rt["bottom-left"]=6]="bottom-left";const it=[{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}];it.forEach(t=>t.type="percent");const ot={directionData:it,tempPoint:{},get:nt,toPoint(t,e,s,r,i,o){const n=nt(t);s.x=n.x,s.y=n.y,"percent"===n.type&&(s.x*=e.width,s.y*=e.height,i&&(o||(s.x-=i.x,s.y-=i.y),n.x&&(s.x-=1===n.x?i.width:.5===n.x?n.x*i.width:0),n.y&&(s.y-=1===n.y?i.height:.5===n.y?n.y*i.height:0))),r||(s.x+=e.x,s.y+=e.y)},getPoint:(t,e,s)=>(s||(s={}),ot.toPoint(t,e,s,!0),s)};function nt(t){return n(t)?it[exports.Direction9[t]]:t}const{toPoint:at}=ot,ht={toPoint(t,e,s,r,i,o){at(t,s,r,i,e,o)}},{tempPointBounds:lt,setPoint:dt,addPoint:ut,toBounds:ct}=tt,{toOuterPoint:pt}=M,{float:_t,fourNumber:ft}=m,{floor:gt,ceil:yt}=Math;let xt,mt,wt,bt;const Bt={},vt={},kt={},Ct={tempBounds:kt,set(t,e=0,s=0,r=0,i=0){t.x=e,t.y=s,t.width=r,t.height=i},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s,r,i){const{x:o,y:n,width:a,height:h}=e;if(d(s)){const e=ft(s);r?Tt.set(t,o+e[3],n+e[0],a-e[1]-e[3],h-e[2]-e[0]):Tt.set(t,o-e[3],n-e[0],a+e[1]+e[3],h+e[2]+e[0])}else r&&(s=-s),Tt.set(t,o-s,n-s,a+2*s,h+2*s);i&&("width"===i?(t.y=n,t.height=h):(t.x=o,t.width=a))},minX:t=>t.width>0?t.x:t.x+t.width,minY:t=>t.height>0?t.y:t.y+t.height,maxX:t=>t.width>0?t.x+t.width:t.x,maxY:t=>t.height>0?t.y+t.height:t.y,move(t,e,s){t.x+=e,t.y+=s},scroll(t,e){(e.scrollY||e.scrollX)&&(t.x+=e.scrollX,t.y+=e.scrollY)},getByMove:(t,e,s)=>(t=Object.assign({},t),Tt.move(t,e,s),t),toOffsetOutBounds(t,e,s){e?Ot(e,t):e=t,s?(e.offsetX=-(Tt.maxX(s)-t.x),e.offsetY=-(Tt.maxY(s)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),Tt.move(e,-e.offsetX,-e.offsetY)},scale(t,e,s=e,r){r||U.scale(t,e,s),t.width*=e,t.height*=s},scaleOf(t,e,s,r=s){U.scaleOf(t,e,s,r),t.width*=s,t.height*=r},tempToOuterOf:(t,e)=>(Tt.copy(kt,t),Tt.toOuterOf(kt,e),kt),getOuterOf:(t,e)=>(t=Object.assign({},t),Tt.toOuterOf(t,e),t),toOuterOf(t,e,s){if(s||(s=t),0===e.b&&0===e.c){const{a:r,d:i}=e;r>0?(s.width=t.width*r,s.x=e.e+t.x*r):(s.width=t.width*-r,s.x=e.e+t.x*r-s.width),i>0?(s.height=t.height*i,s.y=e.f+t.y*i):(s.height=t.height*-i,s.y=e.f+t.y*i-s.height)}else Bt.x=t.x,Bt.y=t.y,pt(e,Bt,vt),dt(lt,vt.x,vt.y),Bt.x=t.x+t.width,pt(e,Bt,vt),ut(lt,vt.x,vt.y),Bt.y=t.y+t.height,pt(e,Bt,vt),ut(lt,vt.x,vt.y),Bt.x=t.x,pt(e,Bt,vt),ut(lt,vt.x,vt.y),ct(lt,s)},toInnerOf(t,e,s){s||(s=t),Tt.move(s,-e.e,-e.f),Tt.scale(s,1/e.a,1/e.d)},getFitMatrix(t,e,s=1){const r=Math.min(s,Tt.getFitScale(t,e));return new $(r,0,0,r,-e.x*r,-e.y*r)},getFitScale(t,e,s){const r=t.width/e.width,i=t.height/e.height;return s?Math.max(r,i):Math.min(r,i)},put(t,e,s="center",r=1,i=!0,o){o||(o=e),n(r)&&(r=Tt.getFitScale(t,e,"cover"===r)),kt.width=i?e.width*=r:e.width*r,kt.height=i?e.height*=r:e.height*r,ht.toPoint(s,kt,t,o,!0,!0)},getSpread(t,e,s){const r={};return Tt.copyAndSpread(r,t,e,!1,s),r},spread(t,e,s){Tt.copyAndSpread(t,t,e,!1,s)},shrink(t,e,s){Tt.copyAndSpread(t,t,e,!0,s)},ceil(t){const{x:e,y:s}=t;t.x=gt(t.x),t.y=gt(t.y),t.width=e>t.x?yt(t.width+e-t.x):yt(t.width),t.height=s>t.y?yt(t.height+s-t.y):yt(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=_t(t.x,e),t.y=_t(t.y,e),t.width=_t(t.width,e),t.height=_t(t.height,e)},add(t,e,s){xt=t.x+t.width,mt=t.y+t.height,wt=e.x,bt=e.y,s||(wt+=e.width,bt+=e.height),xt=xt>wt?xt:wt,mt=mt>bt?mt:bt,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=xt-t.x,t.height=mt-t.y},addList(t,e){Tt.setListWithFn(t,e,void 0,!0)},setList(t,e,s=!1){Tt.setListWithFn(t,e,void 0,s)},addListWithFn(t,e,s){Tt.setListWithFn(t,e,s,!0)},setListWithFn(t,e,s,r=!1){let i,o=!0;for(let n=0,a=e.length;n<a;n++)i=s?s(e[n],n):e[n],i&&(i.width||i.height)&&(o?(o=!1,r||Ot(t,i)):Pt(t,i));o&&Tt.reset(t)},setPoints(t,e){e.forEach((t,e)=>0===e?dt(lt,t.x,t.y):ut(lt,t.x,t.y)),ct(lt,t)},setPoint(t,e){Tt.set(t,e.x,e.y)},addPoint(t,e){Pt(t,e,!0)},getPoints(t){const{x:e,y:s,width:r,height:i}=t;return[{x:e,y:s},{x:e+r,y:s},{x:e+r,y:s+i},{x:e,y:s+i}]},hitRadiusPoint:(t,e,s)=>(s&&(e=U.tempToInnerRadiusPointOf(e,s)),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,s)=>(s&&(e=U.tempToInnerOf(e,s)),e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height),hit:(t,e,s)=>(s&&(e=Tt.tempToOuterOf(e,s)),!(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,s)=>(s&&(e=Tt.tempToOuterOf(e,s)),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,s){if(s&&(e=Tt.tempToOuterOf(e,s)),!Tt.hit(t,e))return{x:0,y:0,width:0,height:0};let{x:r,y:i,width:o,height:n}=e;return xt=r+o,mt=i+n,wt=t.x+t.width,bt=t.y+t.height,r=r>t.x?r:t.x,i=i>t.y?i:t.y,xt=xt<wt?xt:wt,mt=mt<bt?mt:bt,o=xt-r,n=mt-i,{x:r,y:i,width:o,height:n}},intersect(t,e,s){Tt.copy(t,Tt.getIntersectData(t,e,s))},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){Tt.set(t)}},Tt=Ct,{add:Pt,copy:Ot}=Tt;class Lt{get minX(){return Ct.minX(this)}get minY(){return Ct.minY(this)}get maxX(){return Ct.maxX(this)}get maxY(){return Ct.maxY(this)}constructor(t,e,s,r){this.set(t,e,s,r)}set(t,e,s,r){return u(t)?Ct.copy(this,t):Ct.set(this,t,e,s,r),this}get(){const{x:t,y:e,width:s,height:r}=this;return{x:t,y:e,width:s,height:r}}clone(){return new Lt(this)}move(t,e){return Ct.move(this,t,e),this}scale(t,e,s){return Ct.scale(this,t,e,s),this}scaleOf(t,e,s){return Ct.scaleOf(this,t,e,s),this}toOuterOf(t,e){return Ct.toOuterOf(this,t,e),this}toInnerOf(t,e){return Ct.toInnerOf(this,t,e),this}getFitMatrix(t,e){return Ct.getFitMatrix(this,t,e)}put(t,e,s){Ct.put(this,t,e,s)}spread(t,e){return Ct.spread(this,t,e),this}shrink(t,e){return Ct.shrink(this,t,e),this}ceil(){return Ct.ceil(this),this}unsign(){return Ct.unsign(this),this}float(t){return Ct.float(this,t),this}add(t){return Ct.add(this,t),this}addList(t){return Ct.setList(this,t,!0),this}setList(t){return Ct.setList(this,t),this}addListWithFn(t,e){return Ct.setListWithFn(this,t,e,!0),this}setListWithFn(t,e){return Ct.setListWithFn(this,t,e),this}setPoint(t){return Ct.setPoint(this,t),this}setPoints(t){return Ct.setPoints(this,t),this}addPoint(t){return Ct.addPoint(this,t),this}getPoints(){return Ct.getPoints(this)}hitPoint(t,e){return Ct.hitPoint(this,t,e)}hitRadiusPoint(t,e){return Ct.hitRadiusPoint(this,t,e)}hit(t,e){return Ct.hit(this,t,e)}includes(t,e){return Ct.includes(this,t,e)}intersect(t,e){return Ct.intersect(this,t,e),this}getIntersect(t,e){return new Lt(Ct.getIntersectData(this,t,e))}isSame(t){return Ct.isSame(this,t)}isEmpty(){return Ct.isEmpty(this)}reset(){Ct.reset(this)}}const St=new Lt;const Rt={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:Et}=m;class It{constructor(t){this.repeatMap={},this.name=t}static get(t){return new It(t)}static set filter(t){this.filterList=Mt(t)}static set exclude(t){this.excludeList=Mt(t)}static drawRepaint(t,e){const s=Et();t.fillWorld(e,s.replace("1)",".1)")),t.strokeWorld(e,s)}static drawBounds(t,e,s){const r="hit"===It.showBounds,i=t.__nowWorld,o=Et();r&&(e.setWorld(i),t.__drawHitPath(e),e.fillStyle=o.replace("1)",".2)"),e.fill()),e.resetTransform(),e.setStroke(o,2),r?e.stroke():e.strokeWorld(i,o)}log(...t){if(At.enable){if(At.filterList.length&&At.filterList.every(t=>t!==this.name))return;if(At.excludeList.length&&At.excludeList.some(t=>t===this.name))return;console.log("%c"+this.name,"color:#21ae62",...t)}}tip(...t){At.enable&&this.warn(...t)}warn(...t){At.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 Mt(t){return t?n(t)&&(t=[t]):t=[],t}It.filterList=[],It.excludeList=[],It.showWarn=!0;const At=It,Wt=It.get("RunTime"),Dt={currentId:0,currentName:"",idMap:{},nameMap:{},nameToIdMap:{},start(t,s){const r=e.create(e.RUNTIME);return Nt.currentId=Nt.idMap[r]=s?performance.now():Date.now(),Nt.currentName=Nt.nameMap[r]=t,Nt.nameToIdMap[t]=r,r},end(t,e){const s=Nt.idMap[t],r=Nt.nameMap[t],i=e?(performance.now()-s)/1e3:Date.now()-s;Nt.idMap[t]=Nt.nameMap[t]=Nt.nameToIdMap[r]=void 0,Wt.log(r,i,"ms")},endOfName(t,e){const s=Nt.nameToIdMap[t];i(s)||Nt.end(s,e)}},Nt=Dt,Yt=[],Xt={list:{},add(t,...e){this.list[t]=!0,Yt.push(...e)},has(t,e){const s=this.list[t];return!s&&e&&this.need(t),s},need(t){console.error("please install and import plugin: "+(t.includes("-x")?"":"@leafer-in/")+t)}};setTimeout(()=>Yt.forEach(t=>Xt.has(t,!0)));const zt={editor:t=>Xt.need("editor")},Ft=It.get("UICreator"),Ht={list:{},register(t){const{__tag:e}=t.prototype;jt[e]&&Ft.repeat(e),jt[e]=t},get(t,e,s,r,o,n){jt[t]||Ft.error("not register "+t);const a=new jt[t](e);return i(s)||(a.x=s,r&&(a.y=r),o&&(a.width=o),n&&(a.height=n)),a}},{list:jt}=Ht,Ut=It.get("EventCreator"),Gt={nameList:{},register(t){let e;Object.keys(t).forEach(s=>{e=t[s],n(e)&&(Vt[e]&&Ut.repeat(e),Vt[e]=t)})},changeName(t,e){const s=Vt[t];if(s){const r=Object.keys(s).find(e=>s[e]===t);r&&(s[r]=e,Vt[e]=s)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new Vt[t](...e)},{nameList:Vt}=Gt;function qt(t,e,s,r){var i,o=arguments.length,n=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,s,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(n=(o<3?i(n):o>3?i(e,s,n):i(e,s))||n);return o>3&&n&&Object.defineProperty(e,s,n),n}function Qt(t,e,s,r){return new(s||(s=Promise))(function(i,o){function n(t){try{h(r.next(t))}catch(t){o(t)}}function a(t){try{h(r.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(n,a)}h((r=r.apply(t,e||[])).next())})}function Jt(t){return(e,s)=>{t||(t=s);const r={get(){return this.context[t]},set(e){this.context[t]=e}};"strokeCap"===s&&(r.set=function(e){this.context[t]="none"===e?"butt":e}),Object.defineProperty(e,s,r)}}"function"==typeof SuppressedError&&SuppressedError;const Zt=[];function $t(){return(t,e)=>{Zt.push(e)}}const Kt=[];class te{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||Kt)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Zt.forEach(e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}),this.textBaseline="alphabetic"}setTransform(t,e,s,r,i,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,r,i,o){u(t)?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,s,r,i,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,s,r){}strokeRect(t,e,s,r){}clearRect(t,e,s,r){}drawImage(t,e,s,r,i,o,n,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/r*a;r+=e,e=0,o+=t,a-=t}if(s<0){const t=-s/i*h;i+=s,s=0,n+=t,h-=t}this.context.drawImage(t,e,s,r,i,o,n,a,h);break;case 5:this.context.drawImage(t,e,s,r,i);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,r,i,o){}quadraticCurveTo(t,e,s,r){}closePath(){}arc(t,e,s,r,i,o){}arcTo(t,e,s,r,i){}ellipse(t,e,s,r,i,o,n,a){}rect(t,e,s,r){}roundRect(t,e,s,r,i){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,r){}createPattern(t,e){}createRadialGradient(t,e,s,r,i,o){}fillText(t,e,s,r){}measureText(t){}strokeText(t,e,s,r){}destroy(){this.context=null}}qt([Jt("imageSmoothingEnabled")],te.prototype,"smooth",void 0),qt([Jt("imageSmoothingQuality")],te.prototype,"smoothLevel",void 0),qt([Jt("globalAlpha")],te.prototype,"opacity",void 0),qt([Jt()],te.prototype,"fillStyle",void 0),qt([Jt()],te.prototype,"strokeStyle",void 0),qt([Jt("lineWidth")],te.prototype,"strokeWidth",void 0),qt([Jt("lineCap")],te.prototype,"strokeCap",void 0),qt([Jt("lineJoin")],te.prototype,"strokeJoin",void 0),qt([Jt("lineDashOffset")],te.prototype,"dashOffset",void 0),qt([Jt()],te.prototype,"miterLimit",void 0),qt([Jt()],te.prototype,"shadowBlur",void 0),qt([Jt()],te.prototype,"shadowColor",void 0),qt([Jt()],te.prototype,"shadowOffsetX",void 0),qt([Jt()],te.prototype,"shadowOffsetY",void 0),qt([Jt()],te.prototype,"filter",void 0),qt([Jt()],te.prototype,"font",void 0),qt([Jt()],te.prototype,"fontKerning",void 0),qt([Jt()],te.prototype,"fontStretch",void 0),qt([Jt()],te.prototype,"fontVariantCaps",void 0),qt([Jt()],te.prototype,"textAlign",void 0),qt([Jt()],te.prototype,"textBaseline",void 0),qt([Jt()],te.prototype,"textRendering",void 0),qt([Jt()],te.prototype,"wordSpacing",void 0),qt([Jt()],te.prototype,"letterSpacing",void 0),qt([Jt()],te.prototype,"direction",void 0),qt([$t()],te.prototype,"setTransform",null),qt([$t()],te.prototype,"resetTransform",null),qt([$t()],te.prototype,"getTransform",null),qt([$t()],te.prototype,"save",null),qt([$t()],te.prototype,"restore",null),qt([$t()],te.prototype,"translate",null),qt([$t()],te.prototype,"scale",null),qt([$t()],te.prototype,"rotate",null),qt([$t()],te.prototype,"fill",null),qt([$t()],te.prototype,"stroke",null),qt([$t()],te.prototype,"clip",null),qt([$t()],te.prototype,"fillRect",null),qt([$t()],te.prototype,"strokeRect",null),qt([$t()],te.prototype,"clearRect",null),qt([$t()],te.prototype,"beginPath",null),qt([$t()],te.prototype,"moveTo",null),qt([$t()],te.prototype,"lineTo",null),qt([$t()],te.prototype,"bezierCurveTo",null),qt([$t()],te.prototype,"quadraticCurveTo",null),qt([$t()],te.prototype,"closePath",null),qt([$t()],te.prototype,"arc",null),qt([$t()],te.prototype,"arcTo",null),qt([$t()],te.prototype,"ellipse",null),qt([$t()],te.prototype,"rect",null),qt([$t()],te.prototype,"roundRect",null),qt([$t()],te.prototype,"createConicGradient",null),qt([$t()],te.prototype,"createLinearGradient",null),qt([$t()],te.prototype,"createPattern",null),qt([$t()],te.prototype,"createRadialGradient",null),qt([$t()],te.prototype,"fillText",null),qt([$t()],te.prototype,"measureText",null),qt([$t()],te.prototype,"strokeText",null);const{copy:ee,multiplyParent:se}=M,{round:re}=Math,ie=new Lt,oe=new Lt,ne={width:1,height:1,pixelRatio:1},ae=["width","height","pixelRatio"];const he={creator:{},parse(t,e){},convertToCanvasData(t,e){}},le={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},de=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),ue={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},ce={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},pe=Object.assign(Object.assign({},ce),le),_e=de,fe={};for(let t in _e)fe[_e[t]]=t;const ge={};for(let t in _e)ge[_e[t]]=ue[t];const ye={drawRoundRect(t,e,s,r,i,o){const n=m.fourNumber(o,Math.min(r/2,i/2)),a=e+r,h=s+i;n[0]?t.moveTo(e+n[0],s):t.moveTo(e,s),n[1]?t.arcTo(a,s,a,h,n[1]):t.lineTo(a,s),n[2]?t.arcTo(a,h,e,h,n[2]):t.lineTo(a,h),n[3]?t.arcTo(e,h,e,s,n[3]):t.lineTo(e,h),n[0]?t.arcTo(e,s,a,s,n[0]):t.lineTo(e,s)}},{sin:xe,cos:me,atan2:we,ceil:be,abs:Be,PI:ve,sqrt:ke,pow:Ce}=Math,{setPoint:Te,addPoint:Pe}=tt,{set:Oe,toNumberPoints:Le}=U,{M:Se,L:Re,C:Ee,Q:Ie,Z:Me}=de,Ae={},We={points(t,e,s,r){let i=Le(e);if(t.push(Se,i[0],i[1]),s&&i.length>5){let e,o,n,a,h,l,d,u,c,p,_,f,g,y=i.length;const x=!0===s?.5:s;r&&(i=[i[y-2],i[y-1],...i,i[0],i[1],i[2],i[3]],y=i.length);for(let s=2;s<y-2;s+=2)e=i[s-2],o=i[s-1],n=i[s],a=i[s+1],h=i[s+2],l=i[s+3],_=ke(Ce(n-e,2)+Ce(a-o,2)),f=ke(Ce(h-n,2)+Ce(l-a,2)),(_||f)&&(g=_+f,_=x*_/g,f=x*f/g,h-=e,l-=o,d=n-_*h,u=a-_*l,2===s?r||t.push(Ie,d,u,n,a):t.push(Ee,c,p,d,u,n,a),c=n+f*h,p=a+f*l);r||t.push(Ie,c,p,i[y-2],i[y-1])}else for(let e=2,s=i.length;e<s;e+=2)t.push(Re,i[e],i[e+1]);r&&t.push(Me)},rect(t,e,s,r,i){he.creator.path=t,he.creator.moveTo(e,s).lineTo(e+r,s).lineTo(e+r,s+i).lineTo(e,s+i).lineTo(e,s)},roundRect(t,e,s,r,i,o){he.creator.path=[],ye.drawRoundRect(he.creator,e,s,r,i,o),t.push(...he.convertToCanvasData(he.creator.path,!0))},arcTo(t,e,s,r,i,o,n,a,h,l,d){const u=r-e,c=i-s,p=o-r,_=n-i;let f=we(c,u),g=we(_,p),y=g-f;if(y<0&&(y+=B),y===ve||Be(u+c)<1e-12||Be(p+_)<1e-12)return t&&t.push(Re,r,i),h&&(Te(h,e,s),Pe(h,r,i)),d&&Oe(d,e,s),void(l&&Oe(l,r,i));const x=u*_-p*c<0,m=x?-1:1,w=a/me(y/2),k=r+w*me(f+y/2+v*m),C=i+w*xe(f+y/2+v*m);return f-=v*m,g-=v*m,Ye(t,k,C,a,a,0,f/b,g/b,x,h,l,d)},arc:(t,e,s,r,i,o,n,a,h,l)=>Ye(t,e,s,r,r,0,i,o,n,a,h,l),ellipse(t,e,s,r,i,o,n,a,h,l,d,u){const c=o*b,p=xe(c),_=me(c);let f=n*b,g=a*b;f>ve&&(f-=B),g<0&&(g+=B);let y=g-f;y<0?y+=B:y>B&&(y-=B),h&&(y-=B);const x=be(Be(y/v)),m=y/x,w=xe(m/4),k=8/3*w*w/xe(m/2);g=f+m;let C,T,P,O,L,S,R,E,I=me(f),M=xe(f),A=P=_*r*I-p*i*M,W=O=p*r*I+_*i*M,D=e+P,N=s+O;t&&t.push(t.length?Re:Se,D,N),l&&Te(l,D,N),u&&Oe(u,D,N);for(let o=0;o<x;o++)C=me(g),T=xe(g),P=_*r*C-p*i*T,O=p*r*C+_*i*T,L=e+A-k*(_*r*M+p*i*I),S=s+W-k*(p*r*M-_*i*I),R=e+P+k*(_*r*T+p*i*C),E=s+O+k*(p*r*T-_*i*C),t&&t.push(Ee,L,S,R,E,e+P,s+O),l&&Ne(e+A,s+W,L,S,R,E,e+P,s+O,l,!0),A=P,W=O,I=C,M=T,f=g,g+=m;d&&Oe(d,e+P,s+O)},quadraticCurveTo(t,e,s,r,i,o,n){t.push(Ee,(e+2*r)/3,(s+2*i)/3,(o+2*r)/3,(n+2*i)/3,o,n)},toTwoPointBoundsByQuadraticCurve(t,e,s,r,i,o,n,a){Ne(t,e,(t+2*s)/3,(e+2*r)/3,(i+2*s)/3,(o+2*r)/3,i,o,n,a)},toTwoPointBounds(t,e,s,r,i,o,n,a,h,l){const d=[];let u,c,p,_,f,g,y,x,m=t,w=s,b=i,B=n;for(let t=0;t<2;++t)if(1==t&&(m=e,w=r,b=o,B=a),u=-3*m+9*w-9*b+3*B,c=6*m-12*w+6*b,p=3*w-3*m,Math.abs(u)<1e-12){if(Math.abs(c)<1e-12)continue;_=-p/c,0<_&&_<1&&d.push(_)}else y=c*c-4*p*u,x=Math.sqrt(y),y<0||(f=(-c+x)/(2*u),0<f&&f<1&&d.push(f),g=(-c-x)/(2*u),0<g&&g<1&&d.push(g));l?Pe(h,t,e):Te(h,t,e),Pe(h,n,a);for(let l=0,u=d.length;l<u;l++)De(d[l],t,e,s,r,i,o,n,a,Ae),Pe(h,Ae.x,Ae.y)},getPointAndSet(t,e,s,r,i,o,n,a,h,l){const d=1-t,u=d*d*d,c=3*d*d*t,p=3*d*t*t,_=t*t*t;l.x=u*e+c*r+p*o+_*a,l.y=u*s+c*i+p*n+_*h},getPoint(t,e,s,r,i,o,n,a,h){const l={};return De(t,e,s,r,i,o,n,a,h,l),l},getDerivative(t,e,s,r,i){const o=1-t;return 3*o*o*(s-e)+6*o*t*(r-s)+3*t*t*(i-r)}},{getPointAndSet:De,toTwoPointBounds:Ne,ellipse:Ye}=We,{sin:Xe,cos:ze,sqrt:Fe,atan2:He}=Math,{ellipse:je}=We,Ue={ellipticalArc(e,s,r,i,o,n,a,h,l,d,u){const c=(l-s)/2,p=(d-r)/2,_=n*b,f=Xe(_),g=ze(_),y=-g*c-f*p,x=-g*p+f*c,m=i*i,w=o*o,v=x*x,k=y*y,C=m*w-m*v-w*k;let T=0;if(C<0){const t=Fe(1-C/(m*w));i*=t,o*=t}else T=(a===h?-1:1)*Fe(C/(m*v+w*k));const P=T*i*x/o,O=-T*o*y/i,L=He((x-O)/o,(y-P)/i),S=He((-x-O)/o,(-y-P)/i);let R=S-L;0===h&&R>0?R-=B:1===h&&R<0&&(R+=B);const E=s+c+g*P-f*O,I=r+p+f*P+g*O,M=R<0?1:0;u||t.ellipseToCurve?je(e,E,I,i,o,n,L/b,S/b,M):i!==o||n?e.push(de.G,E,I,i,o,n,L/b,S/b,M):e.push(de.O,E,I,i,L/b,S/b,M)}},{M:Ge,m:Ve,L:qe,l:Qe,H:Je,h:Ze,V:$e,v:Ke,C:ts,c:es,S:ss,s:rs,Q:is,q:os,T:ns,t:as,A:hs,a:ls,Z:ds,z:us,N:cs,D:ps,X:_s,G:fs,F:gs,O:ys,P:xs,U:ms}=de,{rect:ws,roundRect:bs,arcTo:Bs,arc:vs,ellipse:ks,quadraticCurveTo:Cs}=We,{ellipticalArc:Ts}=Ue,Ps=It.get("PathConvert"),Os={},Ls={current:{dot:0},stringify(t,e){let s,r,i,o=0,n=t.length,a="";for(;o<n;){r=t[o],s=ge[r],a+=r===i?" ":fe[r];for(let r=1;r<s;r++)a+=m.float(t[o+r],e),r===s-1||(a+=" ");i=r,o+=s}return a},parse(t,e){let s,r,i,o="";const n=[],a=e?pe:ce;for(let e=0,h=t.length;e<h;e++)r=t[e],Rt[r]?("."===r&&(Ss.dot&&(Rs(n,o),o=""),Ss.dot++),"0"===o&&"."!==r&&(Rs(n,o),o=""),o+=r):de[r]?(o&&(Rs(n,o),o=""),Ss.name=de[r],Ss.length=ue[r],Ss.index=0,Rs(n,Ss.name),!s&&a[r]&&(s=!0)):"-"===r||"+"===r?"e"===i||"E"===i?o+=r:(o&&Rs(n,o),o=r):o&&(Rs(n,o),o=""),i=r;return o&&Rs(n,o),s?Ls.toCanvasData(n,e):n},toCanvasData(t,e){let s,r,i,o,n,a=0,h=0,l=0,d=0,u=0,c=t.length;const p=[];for(;u<c;){switch(i=t[u],i){case Ve:t[u+1]+=a,t[u+2]+=h;case Ge:a=t[u+1],h=t[u+2],p.push(Ge,a,h),u+=3;break;case Ze:t[u+1]+=a;case Je:a=t[u+1],p.push(qe,a,h),u+=2;break;case Ke:t[u+1]+=h;case $e:h=t[u+1],p.push(qe,a,h),u+=2;break;case Qe:t[u+1]+=a,t[u+2]+=h;case qe:a=t[u+1],h=t[u+2],p.push(qe,a,h),u+=3;break;case rs:t[u+1]+=a,t[u+2]+=h,t[u+3]+=a,t[u+4]+=h,i=ss;case ss:n=o===ts||o===ss,l=n?2*a-s:t[u+1],d=n?2*h-r:t[u+2],s=t[u+1],r=t[u+2],a=t[u+3],h=t[u+4],p.push(ts,l,d,s,r,a,h),u+=5;break;case es:t[u+1]+=a,t[u+2]+=h,t[u+3]+=a,t[u+4]+=h,t[u+5]+=a,t[u+6]+=h,i=ts;case ts:s=t[u+3],r=t[u+4],a=t[u+5],h=t[u+6],p.push(ts,t[u+1],t[u+2],s,r,a,h),u+=7;break;case as:t[u+1]+=a,t[u+2]+=h,i=ns;case ns:n=o===is||o===ns,s=n?2*a-s:t[u+1],r=n?2*h-r:t[u+2],e?Cs(p,a,h,s,r,t[u+1],t[u+2]):p.push(is,s,r,t[u+1],t[u+2]),a=t[u+1],h=t[u+2],u+=3;break;case os:t[u+1]+=a,t[u+2]+=h,t[u+3]+=a,t[u+4]+=h,i=is;case is:s=t[u+1],r=t[u+2],e?Cs(p,a,h,s,r,t[u+3],t[u+4]):p.push(is,s,r,t[u+3],t[u+4]),a=t[u+3],h=t[u+4],u+=5;break;case ls:t[u+6]+=a,t[u+7]+=h;case hs:Ts(p,a,h,t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],t[u+6],t[u+7],e),a=t[u+6],h=t[u+7],u+=8;break;case us:case ds:p.push(ds),u++;break;case cs:a=t[u+1],h=t[u+2],e?ws(p,a,h,t[u+3],t[u+4]):Es(p,t,u,5),u+=5;break;case ps:a=t[u+1],h=t[u+2],e?bs(p,a,h,t[u+3],t[u+4],[t[u+5],t[u+6],t[u+7],t[u+8]]):Es(p,t,u,9),u+=9;break;case _s:a=t[u+1],h=t[u+2],e?bs(p,a,h,t[u+3],t[u+4],t[u+5]):Es(p,t,u,6),u+=6;break;case fs:ks(e?p:Es(p,t,u,9),t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],t[u+6],t[u+7],t[u+8],null,Os),a=Os.x,h=Os.y,u+=9;break;case gs:e?ks(p,t[u+1],t[u+2],t[u+3],t[u+4],0,0,360,!1):Es(p,t,u,5),a=t[u+1]+t[u+3],h=t[u+2],u+=5;break;case ys:vs(e?p:Es(p,t,u,7),t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],t[u+6],null,Os),a=Os.x,h=Os.y,u+=7;break;case xs:e?vs(p,t[u+1],t[u+2],t[u+3],0,360,!1):Es(p,t,u,4),a=t[u+1]+t[u+3],h=t[u+2],u+=4;break;case ms:Bs(e?p:Es(p,t,u,6),a,h,t[u+1],t[u+2],t[u+3],t[u+4],t[u+5],null,Os),a=Os.x,h=Os.y,u+=6;break;default:return Ps.error(`command: ${i} [index:${u}]`,t),p}o=i}return p},objectToCanvasData(t){const e=[];return t.forEach(t=>{switch(t.name){case"M":e.push(Ge,t.x,t.y);break;case"L":e.push(qe,t.x,t.y);break;case"C":e.push(ts,t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":e.push(is,t.x1,t.y1,t.x,t.y);break;case"Z":e.push(ds)}}),e},copyData(t,e,s,r){for(let i=s,o=s+r;i<o;i++)t.push(e[i])},pushData(t,e){Ss.index===Ss.length&&(Ss.index=1,t.push(Ss.name)),t.push(Number(e)),Ss.index++,Ss.dot=0}},{current:Ss,pushData:Rs,copyData:Es}=Ls,{M:Is,L:Ms,C:As,Q:Ws,Z:Ds,N:Ns,D:Ys,X:Xs,G:zs,F:Fs,O:Hs,P:js,U:Us}=de,{getMinDistanceFrom:Gs,getRadianFrom:Vs}=U,{tan:qs,min:Qs,abs:Js}=Math,Zs={},$s={beginPath(t){t.length=0},moveTo(t,e,s){t.push(Is,e,s)},lineTo(t,e,s){t.push(Ms,e,s)},bezierCurveTo(t,e,s,r,i,o,n){t.push(As,e,s,r,i,o,n)},quadraticCurveTo(t,e,s,r,i){t.push(Ws,e,s,r,i)},closePath(t){t.push(Ds)},rect(t,e,s,r,i){t.push(Ns,e,s,r,i)},roundRect(t,e,s,r,i,o){if(h(o))t.push(Xs,e,s,r,i,o);else{const n=m.fourNumber(o);n?t.push(Ys,e,s,r,i,...n):t.push(Ns,e,s,r,i)}},ellipse(t,e,s,r,i,n,a,h,l){o(n)?t.push(Fs,e,s,r,i):(o(a)&&(a=0),o(h)&&(h=360),t.push(zs,e,s,r,i,n,a,h,l?1:0))},arc(t,e,s,r,i,n,a){o(i)?t.push(js,e,s,r):(o(n)&&(n=360),t.push(Hs,e,s,r,i,n,a?1:0))},arcTo(t,e,s,r,o,n,a,h){if(!i(a)){const t=Gs(a,h,e,s,r,o);n=Qs(n,Qs(t/2,t/2*Js(qs(Vs(a,h,e,s,r,o)/2))))}t.push(Us,e,s,r,o,n)},drawEllipse(t,e,s,r,i,n,a,h,l){We.ellipse(null,e,s,r,i,o(n)?0:n,o(a)?0:a,o(h)?360:h,l,null,null,Zs),t.push(Is,Zs.x,Zs.y),Ks(t,e,s,r,i,n,a,h,l)},drawArc(t,e,s,r,i,n,a){We.arc(null,e,s,r,o(i)?0:i,o(n)?360:n,a,null,null,Zs),t.push(Is,Zs.x,Zs.y),tr(t,e,s,r,i,n,a)},drawPoints(t,e,s,r){We.points(t,e,s,r)}},{ellipse:Ks,arc:tr}=$s,{moveTo:er,lineTo:sr,quadraticCurveTo:rr,bezierCurveTo:ir,closePath:or,beginPath:nr,rect:ar,roundRect:hr,ellipse:lr,arc:dr,arcTo:ur,drawEllipse:cr,drawArc:pr,drawPoints:_r}=$s;class fr{set path(t){this.__path=t}get path(){return this.__path}constructor(t){this.set(t)}set(t){return this.__path=t?n(t)?he.parse(t):t:[],this}beginPath(){return nr(this.__path),this.paint(),this}moveTo(t,e){return er(this.__path,t,e),this.paint(),this}lineTo(t,e){return sr(this.__path,t,e),this.paint(),this}bezierCurveTo(t,e,s,r,i,o){return ir(this.__path,t,e,s,r,i,o),this.paint(),this}quadraticCurveTo(t,e,s,r){return rr(this.__path,t,e,s,r),this.paint(),this}closePath(){return or(this.__path),this.paint(),this}rect(t,e,s,r){return ar(this.__path,t,e,s,r),this.paint(),this}roundRect(t,e,s,r,i){return hr(this.__path,t,e,s,r,i),this.paint(),this}ellipse(t,e,s,r,i,o,n,a){return lr(this.__path,t,e,s,r,i,o,n,a),this.paint(),this}arc(t,e,s,r,i,o){return dr(this.__path,t,e,s,r,i,o),this.paint(),this}arcTo(t,e,s,r,i){return ur(this.__path,t,e,s,r,i),this.paint(),this}drawEllipse(t,e,s,r,i,o,n,a){return cr(this.__path,t,e,s,r,i,o,n,a),this.paint(),this}drawArc(t,e,s,r,i,o){return pr(this.__path,t,e,s,r,i,o),this.paint(),this}drawPoints(t,e,s){return _r(this.__path,t,e,s),this.paint(),this}clearPath(){return this.beginPath()}paint(){}}const{M:gr,L:yr,C:xr,Q:mr,Z:wr,N:br,D:Br,X:vr,G:kr,F:Cr,O:Tr,P:Pr,U:Or}=de,Lr=It.get("PathDrawer"),Sr={drawPathByData(t,e){if(!e)return;let s,r=0,i=e.length;for(;r<i;)switch(s=e[r],s){case gr:t.moveTo(e[r+1],e[r+2]),r+=3;break;case yr:t.lineTo(e[r+1],e[r+2]),r+=3;break;case xr:t.bezierCurveTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5],e[r+6]),r+=7;break;case mr:t.quadraticCurveTo(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case wr:t.closePath(),r+=1;break;case br:t.rect(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case Br:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],[e[r+5],e[r+6],e[r+7],e[r+8]]),r+=9;break;case vr:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;case kr:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]*b,e[r+6]*b,e[r+7]*b,e[r+8]),r+=9;break;case Cr:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],0,0,B,!1),r+=5;break;case Tr:t.arc(e[r+1],e[r+2],e[r+3],e[r+4]*b,e[r+5]*b,e[r+6]),r+=7;break;case Pr:t.arc(e[r+1],e[r+2],e[r+3],0,B,!1),r+=4;break;case Or:t.arcTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;default:return void Lr.error(`command: ${s} [index:${r}]`,e)}}},{M:Rr,L:Er,C:Ir,Q:Mr,Z:Ar,N:Wr,D:Dr,X:Nr,G:Yr,F:Xr,O:zr,P:Fr,U:Hr}=de,{toTwoPointBounds:jr,toTwoPointBoundsByQuadraticCurve:Ur,arcTo:Gr,arc:Vr,ellipse:qr}=We,{addPointBounds:Qr,copy:Jr,addPoint:Zr,setPoint:$r,addBounds:Kr,toBounds:ti}=tt,ei=It.get("PathBounds");let si,ri,ii;const oi={},ni={},ai={},hi={toBounds(t,e){hi.toTwoPointBounds(t,ni),ti(ni,e)},toTwoPointBounds(t,e){if(!t||!t.length)return $r(e,0,0);let s,r,i,o,n,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(n=t[a],0===a&&(n===Ar||n===Ir||n===Mr?$r(e,h,l):$r(e,t[a+1],t[a+2])),n){case Rr:case Er:h=t[a+1],l=t[a+2],Zr(e,h,l),a+=3;break;case Ir:i=t[a+5],o=t[a+6],jr(h,l,t[a+1],t[a+2],t[a+3],t[a+4],i,o,oi),Qr(e,oi),h=i,l=o,a+=7;break;case Mr:s=t[a+1],r=t[a+2],i=t[a+3],o=t[a+4],Ur(h,l,s,r,i,o,oi),Qr(e,oi),h=i,l=o,a+=5;break;case Ar:a+=1;break;case Wr:h=t[a+1],l=t[a+2],Kr(e,h,l,t[a+3],t[a+4]),a+=5;break;case Dr:case Nr:h=t[a+1],l=t[a+2],Kr(e,h,l,t[a+3],t[a+4]),a+=n===Dr?9:6;break;case Yr:qr(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],oi,ai),0===a?Jr(e,oi):Qr(e,oi),h=ai.x,l=ai.y,a+=9;break;case Xr:h=t[a+1],l=t[a+2],ri=t[a+3],ii=t[a+4],Kr(e,h-ri,l-ii,2*ri,2*ii),h+=ri,a+=5;break;case zr:Vr(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],oi,ai),0===a?Jr(e,oi):Qr(e,oi),h=ai.x,l=ai.y,a+=7;break;case Fr:h=t[a+1],l=t[a+2],si=t[a+3],Kr(e,h-si,l-si,2*si,2*si),h+=si,a+=4;break;case Hr:Gr(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],oi,ai),0===a?Jr(e,oi):Qr(e,oi),h=ai.x,l=ai.y,a+=6;break;default:return void ei.error(`command: ${n} [index:${a}]`,t)}}},{M:li,L:di,Z:ui}=de,{getCenterX:ci,getCenterY:pi}=U,{arcTo:_i}=$s,fi={smooth(t,e,s){let r,i,o,n=0,a=0,h=0,l=0,d=0,u=0,c=0,p=0,_=0;const f=t.length,g=[];for(;n<f;){switch(r=t[n],r){case li:l=p=t[n+1],d=_=t[n+2],n+=3,t[n]===di?(u=t[n+1],c=t[n+2],g.push(li,ci(l,u),pi(d,c))):g.push(li,l,d);break;case di:switch(a=t[n+1],h=t[n+2],n+=3,t[n]){case di:_i(g,a,h,t[n+1],t[n+2],e,p,_);break;case ui:_i(g,a,h,l,d,e,p,_);break;default:g.push(di,a,h)}p=a,_=h;break;case ui:i!==ui&&(_i(g,l,d,u,c,e,p,_),g.push(ui)),n+=1;break;default:o=ge[r];for(let e=0;e<o;e++)g.push(t[n+e]);n+=o}i=r}return r!==ui&&(g[1]=l,g[2]=d),g}};he.creator=new fr,he.parse=Ls.parse,he.convertToCanvasData=Ls.toCanvasData;const gi=new fr,{drawRoundRect:yi}=ye;const xi={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=mi.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{}}}},mi=xi;mi.alphaPixelTypes.forEach(t=>mi.upperCaseTypeMap[t]=t.toUpperCase());const wi=It.get("TaskProcessor");class bi{constructor(t){this.parallel=!0,this.time=1,this.id=e.create(e.TASK),this.task=t}run(){return Qt(this,void 0,void 0,function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){wi.error(t)}})}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class Bi{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,s=0;for(let r=0;r<t;r++)r<=this.finishedIndex?(s+=this.list[r].time,r===this.finishedIndex&&(e=s)):e+=this.list[r].time;return this.isComplete?1:s/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&p.assign(this.config,t),this.empty()}add(t,e){let s,r,o,n;const a=new bi(t);return a.parent=this,h(e)?n=e:e&&(r=e.parallel,s=e.start,o=e.time,n=e.delay),o&&(a.time=o),!1===r&&(a.parallel=!1),i(n)?this.push(a,s):(this.delayNumber++,setTimeout(()=>{this.delayNumber&&(this.delayNumber--,this.push(a,s))},n)),this.isComplete=!1,a}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout(()=>this.start()))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[],this.delayNumber=0}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach(t=>{t.isComplete||t.cancel()}),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then(()=>{this.onTask(t),this.index++,this.nextTask()}).catch(t=>{this.onError(t)}):this.nextTask()}runParallelTasks(){this.parallelList.forEach(t=>this.runParallelTask(t))}runParallelTask(t){t.run().then(()=>{this.onTask(t),this.fillParallelTask()}).catch(t=>{this.onParallelError(t)})}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout(()=>this.run())}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let s=this.index;s<e&&(t=this.list[s],t.parallel);s++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const s=e.length,r=this.finishedIndex+s;if(e.length){if(!this.running)return;r<this.total&&(t=this.list[r],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 vi=It.get("Resource"),ki={tasker:new Bi,map:{},get isComplete(){return Ci.tasker.isComplete},set(t,e){Ci.map[t]&&vi.repeat(t),Ci.map[t]=e},get:t=>Ci.map[t],remove(t){const e=Ci.map[t];e&&(e.destroy&&e.destroy(),delete Ci.map[t])},loadImage(t,e){return new Promise((s,r)=>{const i=this.setImage(t,t,e);i.load(()=>s(i),t=>r(t))})},setImage(t,e,s){let r;return n(e)?r={url:e}:e.url||(r={url:t,view:e}),r&&(s&&(r.format=s),e=zt.image(r)),Ci.set(t,e),e},destroy(){Ci.map={}}},Ci=ki,Ti={maxRecycled:10,recycledList:[],patternTasker:new Bi,get(t){let e=ki.get(t.url);return e||ki.set(t.url,e=zt.image(t)),e.use++,e},recycle(t){t.use--,setTimeout(()=>{t.use||Pi.recycledList.push(t)})},clearRecycled(){const t=Pi.recycledList;t.length>Pi.maxRecycled&&(t.forEach(t=>!t.use&&t.url&&ki.remove(t.url)),t.length=0)},hasAlphaPixel:t=>xi.alphaPixelTypes.some(e=>Pi.isFormat(e,t)),isFormat(t,e){if(e.format===t)return!0;const{url:s}=e;if(s.startsWith("data:")){if(s.startsWith("data:"+xi.mineType(t)))return!0}else{if(s.includes("."+t)||s.includes("."+xi.upperCaseTypeMap[t]))return!0;if("png"===t&&!s.includes("."))return!0}return!1},destroy(){Pi.recycledList=[]}},Pi=Ti,{IMAGE:Oi,create:Li}=e,{floor:Si,max:Ri}=Math;function Ei(t,e,s,r){r||(s.configurable=s.enumerable=!0),Object.defineProperty(t,e,s)}function Ii(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Mi(t,e){const s="_"+t;return{get(){const t=this[s];return i(t)?e:t},set(t){this[s]=t}}}function Ai(t,e){return(s,r)=>Di(s,r,t,e&&e(r))}function Wi(t){return t}function Di(t,e,s,r){const i={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};Ei(t,e,Object.assign(i,r||{})),Gi(t,e,s)}function Ni(t,e){return Ai(t,t=>({set(s){this.__setAttr(t,s,e)&&Yi(this)}}))}function Yi(t){t.__layout.boxChanged||t.__layout.boxChange(),t.__hasAutoLayout&&(t.__layout.matrixChanged||t.__layout.matrixChange())}const Xi=Ni;function zi(t,e){return Ai(t,t=>({set(s){this.__setAttr(t,s)&&(Fi(this),e&&(this.__.__useStroke=!0))}}))}function Fi(t){t.__layout.strokeChanged||t.__layout.strokeChange(),t.__.__useArrow&&Yi(t)}const Hi=zi;function ji(t){const{parent:e}=t;if(e){const{__hasMask:t}=e;e.__updateMask(),t!==e.__hasMask&&e.forceUpdate()}}function Ui(t,e,s,r){t.__setAttr(e,s)&&(t.__layout.opacityChanged||t.__layout.opacityChange(),0!==r&&0!==s||Yi(t))}function Gi(t,e,s){const r=t.__DataProcessor.prototype,o="_"+e,n=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),a=Mi(e,s);if(i(s))a.get=function(){return this[o]};else if("function"==typeof s)a.get=function(){let t=this[o];return void 0===t?s(this.__leaf):t};else if(u(s)){const t=c(s);a.get=function(){let e=this[o];return void 0===e?this[o]=t?{}:p.clone(s):e}}const h=t.isBranchLeaf;"width"===e?a.get=function(){const t=this[o];if(void 0===t){const t=this,e=t.__naturalWidth,r=t.__leaf;return!s||r.pathInputed?r.boxBounds.width:e?t._height&&t.__useNaturalRatio?t._height*e/t.__naturalHeight:e:h&&r.children.length?r.boxBounds.width:s}return t}:"height"===e&&(a.get=function(){const t=this[o];if(void 0===t){const t=this,e=t.__naturalHeight,r=t.__leaf;return!s||r.pathInputed?r.boxBounds.height:e?t._width&&t.__useNaturalRatio?t._width*e/t.__naturalWidth:e:h&&r.children.length?r.boxBounds.height:s}return t});let l,d=r;for(;!l&&d;)l=Ii(d,e),d=d.__proto__;l&&l.set&&(a.set=l.set),r[n]&&(a.set=r[n],delete r[n]),Ei(r,e,a)}const Vi=new It("rewrite"),qi=[],Qi=["destroy","constructor"];function Ji(t){qi.length&&(qi.forEach(e=>{t&&Vi.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()}),qi.length=0)}function Zi(t,e){return s=>{var r;(t.prototype?(r=t.prototype,Object.getOwnPropertyNames(r)):Object.keys(t)).forEach(r=>{if(!(Qi.includes(r)||e&&e.includes(r)))if(t.prototype){Ii(t.prototype,r).writable&&(s.prototype[r]=t.prototype[r])}else s.prototype[r]=t[r]})}}setTimeout(()=>Ji(!0));const{copy:$i,toInnerPoint:Ki,toOuterPoint:to,scaleOfOuter:eo,rotateOfOuter:so,skewOfOuter:ro,multiplyParent:io,divideParent:oo,getLayout:no}=M,ao={},{round:ho}=Math,lo={updateAllMatrix(t,e,s){if(e&&t.__hasAutoLayout&&t.__layout.matrixChanged&&(s=!0),po(t,e,s),t.isBranch){const{children:r}=t;for(let t=0,i=r.length;t<i;t++)co(r[t],e,s)}},updateMatrix(t,e,s){const r=t.__layout;e?s&&(r.waitAutoLayout=!0,t.__hasAutoLayout&&(r.matrixChanged=!1)):r.waitAutoLayout&&(r.waitAutoLayout=!1),r.matrixChanged&&t.__updateLocalMatrix(),r.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,s=e.length;t<s;t++)_o(e[t])}},updateChange(t){const e=t.__layout;e.stateStyleChanged&&t.updateState(),e.opacityChanged&&_o(t),t.__updateChange()},updateAllChange(t){if(go(t),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)fo(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(e,s,r,i,o,n){i||(i=e.__nowWorld),e.__worldFlipped||t.fullImageShadow?s.copyWorldByReset(r,i,e.__nowWorld,o,n):s.copyWorldToInner(r,i,e.__layout.renderBounds,o)},moveWorld(t,e,s=0,r,i){const o=u(e)?Object.assign({},e):{x:e,y:s};r?to(t.localTransform,o,o,!0):t.parent&&Ki(t.parent.scrollWorldTransform,o,o,!0),uo.moveLocal(t,o.x,o.y,i)},moveLocal(t,e,s=0,r){u(e)&&(s=e.y,e=e.x),e+=t.x,s+=t.y,t.leafer&&t.leafer.config.pointSnap&&(e=ho(e),s=ho(s)),r?t.animate({x:e,y:s},r):(t.x=e,t.y=s)},zoomOfWorld(t,e,s,r,i,o){uo.zoomOfLocal(t,yo(t,e),s,r,i,o)},zoomOfLocal(t,e,s,r=s,i,o){const n=t.__localMatrix;if(h(r)||(r&&(o=r),r=s),$i(ao,n),eo(ao,e,s,r),uo.hasHighPosition(t))uo.setTransform(t,ao,i,o);else{const e=t.x+ao.e-n.e,a=t.y+ao.f-n.f;o&&!i?t.animate({x:e,y:a,scaleX:t.scaleX*s,scaleY:t.scaleY*r},o):(t.x=e,t.y=a,t.scaleResize(s,r,!0!==i))}},rotateOfWorld(t,e,s,r){uo.rotateOfLocal(t,yo(t,e),s,r)},rotateOfLocal(t,e,s,r){const i=t.__localMatrix;$i(ao,i),so(ao,e,s),uo.hasHighPosition(t)?uo.setTransform(t,ao,!1,r):t.set({x:t.x+ao.e-i.e,y:t.y+ao.f-i.f,rotation:m.formatRotation(t.rotation+s)},r)},skewOfWorld(t,e,s,r,i,o){uo.skewOfLocal(t,yo(t,e),s,r,i,o)},skewOfLocal(t,e,s,r=0,i,o){$i(ao,t.__localMatrix),ro(ao,e,s,r),uo.setTransform(t,ao,i,o)},transformWorld(t,e,s,r){$i(ao,t.worldTransform),io(ao,e),t.parent&&oo(ao,t.parent.scrollWorldTransform),uo.setTransform(t,ao,s,r)},transform(t,e,s,r){$i(ao,t.localTransform),io(ao,e),uo.setTransform(t,ao,s,r)},setTransform(t,e,s,r){const i=t.__,o=i.origin&&uo.getInnerOrigin(t,i.origin),n=no(e,o,i.around&&uo.getInnerOrigin(t,i.around));if(uo.hasOffset(t)&&(n.x-=i.offsetX,n.y-=i.offsetY),s){const e=n.scaleX/t.scaleX,s=n.scaleY/t.scaleY;if(delete n.scaleX,delete n.scaleY,o){Ct.scale(t.boxBounds,Math.abs(e),Math.abs(s));const r=uo.getInnerOrigin(t,i.origin);U.move(n,o.x-r.x,o.y-r.y)}t.set(n),t.scaleResize(e,s,!1)}else t.set(n,r)},getFlipTransform(t,e){const s={a:1,b:0,c:0,d:1,e:0,f:0},r="x"===e?1:-1;return eo(s,uo.getLocalOrigin(t,"center"),-1*r,1*r),s},getLocalOrigin:(t,e)=>U.tempToOuterOf(uo.getInnerOrigin(t,e),t.localTransform),getInnerOrigin(t,e){const s={};return ot.toPoint(e,t.boxBounds,s),s},getRelativeWorld:(t,e,s)=>($i(ao,t.worldTransform),oo(ao,e.scrollWorldTransform),s?ao:Object.assign({},ao)),drop(t,e,s,r){t.setTransform(uo.getRelativeWorld(t,e,!0),r),e.add(t,s)},hasHighPosition:t=>t.origin||t.around||uo.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(e,s,r=.3){if(s.x||s.y)if(Math.abs(s.x)<1&&Math.abs(s.y)<1)e.move(s);else{const i=s.x*r,o=s.y*r;s.x-=i,s.y-=o,e.move(i,o),t.requestRender(()=>uo.animateMove(e,s,r))}}},uo=lo,{updateAllMatrix:co,updateMatrix:po,updateAllWorldOpacity:_o,updateAllChange:fo,updateChange:go}=uo;function yo(t,e){return t.parent?U.tempToInnerOf(e,t.parent.scrollWorldTransform):e}const xo={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)=>wo(t,e)&&t.__localBoxBounds,maskLocalStrokeBounds:(t,e)=>wo(t,e)&&t.__layout.localStrokeBounds,maskLocalRenderBounds:(t,e)=>wo(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 mo;function wo(t,e){return e||(mo=0),t.__.mask&&(mo=1),mo<0?null:(mo&&(mo=-1),!0)}const{updateBounds:bo}=lo,Bo={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:s}=t;for(let r=0,i=s.length;r<i;r++)(t=s[r]).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 s=e.length;const{children:r}=t;for(let t=0,s=r.length;t<s;t++)r[t].isBranch&&e.push(r[t]);for(let t=s,r=e.length;t<r;t++)ko(e[t],e)},updateBounds(t,e){const s=[t];ko(t,s),Co(s,e)},updateBoundsByBranchStack(t,e){let s,r;for(let i=t.length-1;i>-1;i--){s=t[i],r=s.children;for(let t=0,e=r.length;t<e;t++)bo(r[t]);e&&e===s||bo(s)}}},{pushAllChildBranch:vo,pushAllBranchStack:ko,updateBoundsByBranchStack:Co}=Bo,To={run(t){if(t&&t.length){const e=t.length;for(let s=0;s<e;s++)t[s]();t.length===e?t.length=0:t.splice(0,e)}}},{getRelativeWorld:Po,updateBounds:Oo}=lo,{toOuterOf:Lo,getPoints:So,copy:Ro}=Ct,Eo="_localContentBounds",Io="_worldContentBounds",Mo="_worldBoxBounds",Ao="_worldStrokeBounds";class Wo{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 Lo(this.contentBounds,this.leaf.__localMatrix,this[Eo]||(this[Eo]={})),this[Eo]}get localStrokeBounds(){return this._localStrokeBounds||this}get localRenderBounds(){return this._localRenderBounds||this}get worldContentBounds(){return Lo(this.contentBounds,this.leaf.__world,this[Io]||(this[Io]={})),this[Io]}get worldBoxBounds(){return Lo(this.boxBounds,this.leaf.__world,this[Mo]||(this[Mo]={})),this[Mo]}get worldStrokeBounds(){return Lo(this.strokeBounds,this.leaf.__world,this[Ao]||(this[Ao]={})),this[Ao]}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:e}=this,{leafer:s}=e;if(e.isApp)return Oo(e);if(s)s.ready?s.watcher.changed&&s.layouter.layout():s.start();else{let s=e;for(;s.parent&&!s.parent.leafer;)s=s.parent;const r=s;if(r.__fullLayouting)return;r.__fullLayouting=!0,t.layout(r),delete r.__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 M.defaultMatrix;case"page":t=e.zoomLayer;default:return Po(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 Lt(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",s){const{leaf:r}=this;let i,o,n,a=this.getInnerBounds(t);switch(e){case"world":i=r.getWorldPoint(a),o=r.__world;break;case"local":const{scaleX:t,scaleY:s,rotation:h,skewX:l,skewY:d}=r.__;n={scaleX:t,scaleY:s,rotation:h,skewX:l,skewY:d},i=r.getLocalPointByInner(a);break;case"inner":i=a,o=M.defaultMatrix;break;case"page":e=r.zoomLayer;default:i=r.getWorldPoint(a,e),o=Po(r,e,!0)}if(n||(n=M.getLayout(o)),Ro(n,a),U.copy(n,i),s){const{scaleX:t,scaleY:e}=n,s=Math.abs(t),r=Math.abs(e);1===s&&1===r||(n.scaleX/=s,n.scaleY/=r,n.width*=s,n.height*=r)}return n}getLayoutPoints(t,e="world"){const{leaf:s}=this,r=So(this.getInnerBounds(t));let o;switch(e){case"world":o=null;break;case"local":o=s.parent;break;case"inner":break;case"page":e=s.zoomLayer;default:o=e}return i(o)||r.forEach(t=>s.innerToWorld(t,null,!1,o)),r}shrinkContent(){const{x:t,y:e,width:s,height:r}=this.boxBounds;this._contentBounds={x:t,y:e,width:s,height:r}}spreadStroke(){const{x:t,y:e,width:s,height:r}=this.strokeBounds;this._strokeBounds={x:t,y:e,width:s,height:r},this._localStrokeBounds={x:t,y:e,width:s,height:r},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:s,height:r}=this.renderBounds;this._renderBounds={x:t,y:e,width:s,height:r},this._localRenderBounds={x:t,y:e,width:s,height:r}}shrinkContentCancel(){this._contentBounds=void 0}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this._strokeBounds=this.boxBounds,this._localStrokeBounds=this.leaf.__localBoxBounds,t&&this.spreadRenderCancel()}spreadRenderCancel(){this._renderBounds=this._strokeBounds,this._localRenderBounds=this._localStrokeBounds}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChange(),this.leaf.__local||this.createLocal()}matrixChange(){this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=this.affectChildrenSort=!0,this.leaf.forceUpdate("surface"))}destroy(){}}class Do{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0,this.origin&&t.event.stopDefault(this.origin)}stopNow(){this.isStopNow=!0,this.isStop=!0,this.origin&&t.event.stopNow(this.origin)}stop(){this.isStop=!0,this.origin&&t.event.stop(this.origin)}}class No extends Do{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}No.ADD="child.add",No.REMOVE="child.remove",No.CREATED="created",No.MOUNTED="mounted",No.UNMOUNTED="unmounted",No.DESTROY="destroy";const Yo="property.scroll";class Xo extends Do{constructor(t,e,s,r,i){super(t,e),this.attrName=s,this.oldValue=r,this.newValue=i}}Xo.CHANGE="property.change",Xo.LEAFER_CHANGE="property.leafer_change",Xo.SCROLL=Yo;const zo={scrollX:Yo,scrollY:Yo};class Fo extends Do{constructor(t,e){super(t),Object.assign(this,e)}}Fo.LOAD="image.load",Fo.LOADED="image.loaded",Fo.ERROR="image.error";class Ho extends Do{static checkHas(t,e,s){"on"===s?e===Vo?t.__hasWorldEvent=!0:t.__hasLocalEvent=!0:(t.__hasLocalEvent=t.hasEvent(jo)||t.hasEvent(Uo)||t.hasEvent(Go),t.__hasWorldEvent=t.hasEvent(Vo))}static emitLocal(t){if(t.leaferIsReady){const{resized:e}=t.__layout;"local"!==e&&(t.emit(jo,t),"inner"===e&&t.emit(Uo,t)),t.emit(Go,t)}}static emitWorld(t){t.leaferIsReady&&t.emit(Vo,this)}}Ho.RESIZE="bounds.resize",Ho.INNER="bounds.inner",Ho.LOCAL="bounds.local",Ho.WORLD="bounds.world";const{RESIZE:jo,INNER:Uo,LOCAL:Go,WORLD:Vo}=Ho,qo={};[jo,Uo,Go,Vo].forEach(t=>qo[t]=1);class Qo extends Do{get bigger(){if(!this.old)return!0;const{width:t,height:e}=this.old;return this.width>=t&&this.height>=e}get smaller(){return!this.bigger}get samePixelRatio(){return!this.old||this.pixelRatio===this.old.pixelRatio}constructor(t,e){u(t)?(super(Qo.RESIZE),Object.assign(this,t)):super(t),this.old=e}static isResizing(t){return this.resizingKeys&&!i(this.resizingKeys[t.innerId])}}Qo.RESIZE="resize";class Jo extends Do{constructor(t,e){super(t),this.data=e}}Jo.REQUEST="watch.request",Jo.DATA="watch.data";class Zo extends Do{constructor(t,e,s){super(t),e&&(this.data=e,this.times=s)}}Zo.REQUEST="layout.request",Zo.START="layout.start",Zo.BEFORE="layout.before",Zo.LAYOUT="layout",Zo.AFTER="layout.after",Zo.AGAIN="layout.again",Zo.END="layout.end";class $o extends Do{constructor(t,e,s,r){super(t),e&&(this.times=e),s&&(this.renderBounds=s,this.renderOptions=r)}}$o.REQUEST="render.request",$o.CHILD_START="render.child_start",$o.CHILD_END="render.child_end",$o.START="render.start",$o.BEFORE="render.before",$o.RENDER="render",$o.AFTER="render.after",$o.AGAIN="render.again",$o.END="render.end",$o.NEXT="render.next";class Ko extends Do{}Ko.START="leafer.start",Ko.BEFORE_READY="leafer.before_ready",Ko.READY="leafer.ready",Ko.AFTER_READY="leafer.after_ready",Ko.VIEW_READY="leafer.view_ready",Ko.VIEW_COMPLETED="leafer.view_completed",Ko.STOP="leafer.stop",Ko.RESTART="leafer.restart",Ko.END="leafer.end",Ko.TRANSFORM="leafer.transform",Ko.MOVE="leafer.move",Ko.SCALE="leafer.scale",Ko.ROTATE="leafer.rotate",Ko.SKEW="leafer.skew";const{MOVE:tn,SCALE:en,ROTATE:sn,SKEW:rn}=Ko,on={x:tn,y:tn,scaleX:en,scaleY:en,rotation:sn,skewX:rn,skewY:rn},nn={};class an{set event(t){this.on(t)}on(t,e,s){if(!e){let e;if(d(t))t.forEach(t=>this.on(t[0],t[1],t[2]));else for(let s in t)d(e=t[s])?this.on(s,e[0],e[1]):this.on(s,e);return}let r,i,o;s&&("once"===s?i=!0:"boolean"==typeof s?r=s:(r=s.capture,i=s.once));const a=hn(this,r,!0),h=n(t)?t.split(" "):t,l=i?{listener:e,once:i}:{listener:e};h.forEach(t=>{t&&(o=a[t],o?-1===o.findIndex(t=>t.listener===e)&&o.push(l):a[t]=[l],qo[t]&&Ho.checkHas(this,t,"on"))})}off(t,e,s){if(t){const r=n(t)?t.split(" "):t;if(e){let t,i,o;s&&(t="boolean"==typeof s?s:"once"!==s&&s.capture);const n=hn(this,t);r.forEach(t=>{t&&(i=n[t],i&&(o=i.findIndex(t=>t.listener===e),o>-1&&i.splice(o,1),i.length||delete n[t],qo[t]&&Ho.checkHas(this,t,"off")))})}else{const{__bubbleMap:t,__captureMap:e}=this;r.forEach(s=>{t&&delete t[s],e&&delete e[s]})}}else this.__bubbleMap=this.__captureMap=void 0}on_(t,e,s,r){return e?this.on(t,s?e=e.bind(s):e,r):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:r}}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,s,r){if(!e)return d(t)&&t.forEach(t=>this.once(t[0],t[1],t[2],t[3]));u(s)?e=e.bind(s):r=s,this.on(t,e,{once:!0,capture:r})}emit(t,e,s){!e&&Gt.has(t)&&(e=Gt.get(t,{type:t,target:this,current:this}));const r=hn(this,s)[t];if(r){let i;for(let o=0,n=r.length;o<n&&!((i=r[o])&&(i.listener(e),i.once&&(this.off(t,i.listener,s),o--,n--),e&&e.isStopNow));o++);}this.syncEventer&&this.syncEventer.emitEvent(e,s)}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:r}=this,o=s&&s[t],n=r&&r[t];return!!(i(e)?o||n:e?n:o)}destroy(){this.__captureMap=this.__bubbleMap=this.syncEventer=null}}function hn(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:nn)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:nn)}}const{on:ln,on_:dn,off:un,off_:cn,once:pn,emit:_n,emitEvent:fn,hasEvent:gn,destroy:yn}=an.prototype,xn={on:ln,on_:dn,off:un,off_:cn,once:pn,emit:_n,emitEvent:fn,hasEvent:gn,destroyEventer:yn},mn=It.get("setAttr"),wn={__setAttr(t,e,s){if(this.leaferIsCreated){const r=this.__.__getInput(t);if(!s||a(e)||i(e)||(mn.warn(this.innerName,t,e),e=void 0),u(e)||r!==e){if(this.__realSetAttr(t,e),this.isLeafer){this.emitEvent(new Xo(Xo.LEAFER_CHANGE,this,t,r,e));const s=on[t];s&&(this.emitEvent(new Ko(s,this)),this.emitEvent(new Ko(Ko.TRANSFORM,this)))}this.emitPropertyEvent(Xo.CHANGE,t,r,e);const s=zo[t];return s&&this.emitPropertyEvent(s,t,r,e),!0}return!1}return this.__realSetAttr(t,e),!0},emitPropertyEvent(t,e,s,r){const i=new Xo(t,this,e,s,r);this.isLeafer||this.hasEvent(t)&&this.emitEvent(i),this.leafer.emitEvent(i)},__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:bn,multiplyParent:Bn,translateInner:vn,defaultWorld:kn}=M,{toPoint:Cn,tempPoint:Tn}=ot,Pn={__updateWorldMatrix(){const{parent:t,__layout:e,__world:s,__scrollWorld:r,__:i}=this;Bn(this.__local||e,t?t.__scrollWorld||t.__world:kn,s,!!e.affectScaleOrRotation,i),r&&vn(Object.assign(r,s),i.scrollX,i.scrollY)},__updateLocalMatrix(){if(this.__local){const t=this.__layout,e=this.__local,s=this.__;t.affectScaleOrRotation&&(t.scaleChanged&&(t.resized||(t.resized="scale"))||t.rotationChanged)&&(bn(e,s,null,null,t.affectRotation),t.scaleChanged=t.rotationChanged=void 0),e.e=s.x+s.offsetX,e.f=s.y+s.offsetY,(s.around||s.origin)&&(Cn(s.around||s.origin,t.boxBounds,Tn),vn(e,-Tn.x,-Tn.y,!s.around))}this.__layout.matrixChanged=void 0}},{updateMatrix:On,updateAllMatrix:Ln}=lo,{updateBounds:Sn}=Bo,{toOuterOf:Rn,copyAndSpread:En,copy:In}=Ct,{toBounds:Mn}=hi,An={__updateWorldBounds(){const t=this.__layout;Rn(t.renderBounds,this.__world,this.__world),t.resized&&("inner"===t.resized&&this.__onUpdateSize(),this.__hasLocalEvent&&Ho.emitLocal(this),t.resized=void 0),this.__hasWorldEvent&&Ho.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(),Rn(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Rn(this.__layout.strokeBounds,this.__localMatrix,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Rn(this.__layout.renderBounds,this.__localMatrix,this.__layout.localRenderBounds)},__updateBoxBounds(t,e){const s=this.__layout.boxBounds,r=this.__;r.__pathInputed?Mn(r.path,s):(s.x=0,s.y=0,s.width=r.width,s.height=r.height)},__updateAutoLayout(){this.__layout.matrixChanged=!0,this.isBranch?(this.__extraUpdate(),this.__.flow?(this.__layout.boxChanged&&this.__updateFlowLayout(),Ln(this),Sn(this,this),this.__.__autoSide&&this.__updateBoxBounds(!0)):(Ln(this),Sn(this,this))):On(this)},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height},__updateStrokeBounds(t){const e=this.__layout;En(e.strokeBounds,e.boxBounds,e.strokeBoxSpread)},__updateRenderBounds(t){const e=this.__layout;e.renderSpread>0?En(e.renderBounds,e.boxBounds,e.renderSpread):In(e.renderBounds,e.strokeBounds)}},Wn={__render(t,e){if(e.shape)return this.__renderShape(t,e);if(this.__worldOpacity){const s=this.__;if(t.setWorld(this.__nowWorld=this.__getNowWorld(e)),t.opacity=e.dimOpacity&&!s.dimskip?s.opacity*e.dimOpacity:s.opacity,this.__.__single){if("path"===s.eraser)return this.__renderEraser(t,e);const r=t.getSameCanvas(!0,!0);this.__draw(r,e,t),lo.copyCanvasByWorld(this,t,r,this.__nowWorld,s.__blendMode,!0),r.recycle(this.__nowWorld)}else this.__draw(t,e);It.showBounds&&It.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:Dn}=xo,Nn={__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 s=this.__;if(s.dim?e.dimOpacity=!0===s.dim?.2:s.dim:s.dimskip&&e.dimOpacity&&(e.dimOpacity=0),s.__single&&!this.isBranchLeaf){if("path"===s.eraser)return this.__renderEraser(t,e);const r=t.getSameCanvas(!1,!0);this.__renderBranch(r,e);const i=this.__nowWorld;t.opacity=e.dimOpacity?s.opacity*e.dimOpacity:s.opacity,t.copyWorldByReset(r,i,i,s.__blendMode,!0),r.recycle(i)}else this.__renderBranch(t,e)}},__renderBranch(t,e){if(this.__hasMask)this.__renderMask(t,e);else{const{children:s}=this;for(let r=0,i=s.length;r<i;r++)Dn(s[r],e)||s[r].__render(t,e)}},__clip(t,e){if(this.__worldOpacity){const{children:s}=this;for(let r=0,i=s.length;r<i;r++)Dn(s[r],e)||s[r].__clip(t,e)}}},Yn={},{LEAF:Xn,create:zn}=e,{toInnerPoint:Fn,toOuterPoint:Hn,multiplyParent:jn}=M,{toOuterOf:Un}=Ct,{copy:Gn,move:Vn}=U,{moveLocal:qn,zoomOfLocal:Qn,rotateOfLocal:Jn,skewOfLocal:Zn,moveWorld:$n,zoomOfWorld:Kn,rotateOfWorld:ta,skewOfWorld:ea,transform:sa,transformWorld:ra,setTransform:ia,getFlipTransform:oa,getLocalOrigin:na,getRelativeWorld:aa,drop:ha}=lo;exports.Leaf=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return f}get __LayoutProcessor(){return Wo}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=zn(Xn),this.reset(t),this.__bubbleMap&&this.__emitLifeEvent(No.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(No.ADD,t,"once")}waitLeafer(t,e){e&&(t=t.bind(e)),this.leafer?t():this.on(No.MOUNTED,t,"once")}nextRender(t,e,s){this.leafer?this.leafer.nextRender(t,e,s):this.waitLeafer(()=>this.leafer.nextRender(t,e,s))}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(No.MOUNTED)):this.__emitLifeEvent(No.UNMOUNTED),this.isBranch){const{children:e}=this;for(let s=0,r=e.length;s<r;s++)e[s].__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:s}=this.__layout;t.clearRect(s.x,s.y,s.width,s.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,s=this.__world;return jn(s,t.matrix,e,void 0,s),Un(this.__layout.renderBounds,e,e),e.half!==s.half&&(e.half=s.half),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:s,scaleY:r}=Ti.patternLocked?this.__world:this.__nowWorld;return t&&(s<0&&(s=-s),r<0&&(r=-r)),(!0===e||"zoom-in"===e&&s>1&&r>1)&&(s=r=1),Yn.scaleX=s,Yn.scaleY=r,Yn}getTransform(t){return this.__layout.getTransform(t||"local")}getBounds(t,e){return this.__layout.getBounds(t,e)}getLayoutBounds(t,e,s){return this.__layout.getLayoutBounds(t,e,s)}getLayoutPoints(t,e){return this.__layout.getLayoutPoints(t,e)}getWorldBounds(t,e,s){const r=e?aa(this,e):this.worldTransform,i=s?t:{};return Un(t,r,i),i}worldToLocal(t,e,s,r){this.parent?this.parent.worldToInner(t,e,s,r):e&&Gn(e,t)}localToWorld(t,e,s,r){this.parent?this.parent.innerToWorld(t,e,s,r):e&&Gn(e,t)}worldToInner(t,e,s,r){r&&(r.innerToWorld(t,e,s),t=e||t),Fn(this.worldTransform,t,e,s)}innerToWorld(t,e,s,r){Hn(this.worldTransform,t,e,s),r&&r.worldToInner(e||t,null,s)}getBoxPoint(t,e,s,r){return this.getBoxPointByInner(this.getInnerPoint(t,e,s,r),null,null,!0)}getBoxPointByInner(t,e,s,r){const i=r?t:Object.assign({},t),{x:o,y:n}=this.boxBounds;return Vn(i,-o,-n),i}getInnerPoint(t,e,s,r){const i=r?t:{};return this.worldToInner(t,i,s,e),i}getInnerPointByBox(t,e,s,r){const i=r?t:Object.assign({},t),{x:o,y:n}=this.boxBounds;return Vn(i,o,n),i}getInnerPointByLocal(t,e,s,r){return this.getInnerPoint(t,this.parent,s,r)}getLocalPoint(t,e,s,r){const i=r?t:{};return this.worldToLocal(t,i,s,e),i}getLocalPointByInner(t,e,s,r){return this.getWorldPoint(t,this.parent,s,r)}getPagePoint(t,e,s,r){return(this.leafer?this.leafer.zoomLayer:this).getInnerPoint(t,e,s,r)}getWorldPoint(t,e,s,r){const i=r?t:{};return this.innerToWorld(t,i,s,e),i}getWorldPointByBox(t,e,s,r){return this.getWorldPoint(this.getInnerPointByBox(t,null,null,r),e,s,!0)}getWorldPointByLocal(t,e,s,r){const i=r?t:{};return this.localToWorld(t,i,s,e),i}getWorldPointByPage(t,e,s,r){return(this.leafer?this.leafer.zoomLayer:this).getWorldPoint(t,e,s,r)}setTransform(t,e,s){ia(this,t,e,s)}transform(t,e,s){sa(this,t,e,s)}move(t,e,s){qn(this,t,e,s)}moveInner(t,e,s){$n(this,t,e,!0,s)}scaleOf(t,e,s,r,i){Qn(this,na(this,t),e,s,r,i)}rotateOf(t,e,s){Jn(this,na(this,t),e,s)}skewOf(t,e,s,r,i){Zn(this,na(this,t),e,s,r,i)}transformWorld(t,e,s){ra(this,t,e,s)}moveWorld(t,e,s){$n(this,t,e,!1,s)}scaleOfWorld(t,e,s,r,i){Kn(this,t,e,s,r,i)}rotateOfWorld(t,e){ta(this,t,e)}skewOfWorld(t,e,s,r,i){ea(this,t,e,s,r,i)}flip(t,e){sa(this,oa(this,t),!1,e)}scaleResize(t,e=t,s){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,s){}__clip(t,e){}__renderShape(t,e){}__drawShape(t,e){}__updateWorldOpacity(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}getMotionPathData(){return Xt.need("path")}getMotionPoint(t){return Xt.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,s){ha(this,t,e,s)}on(t,e,s){}off(t,e,s){}on_(t,e,s,r){}off_(t){}once(t,e,s,r){}emit(t,e,s){}emitEvent(t,e){}hasEvent(t,e){return!1}static changeAttr(t,e,s){s?this.addAttr(t,e,s):Gi(this.prototype,t,e)}static addAttr(t,e,s,r){s||(s=Ni),s(e,r)(this.prototype,t)}__emitLifeEvent(t){this.hasEvent(t)&&this.emitEvent(new No(t,this,this.parent))}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.clear(),this.__emitLifeEvent(No.DESTROY),this.__.destroy(),this.__layout.destroy(),this.destroyEventer(),this.destroyed=!0)}},exports.Leaf=qt([Zi(wn),Zi(Pn),Zi(An),Zi(xn),Zi(Wn)],exports.Leaf);const{setListWithFn:la}=Ct,{sort:da}=Bo,{localBoxBounds:ua,localStrokeBounds:ca,localRenderBounds:pa,maskLocalBoxBounds:_a,maskLocalStrokeBounds:fa,maskLocalRenderBounds:ga}=xo,ya=new It("Branch");exports.Branch=class extends exports.Leaf{__updateStrokeSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(t,e){la(e||this.__layout.boxBounds,this.children,this.__hasMask?_a:ua)}__updateStrokeBounds(t){la(t||this.__layout.strokeBounds,this.children,this.__hasMask?fa:ca)}__updateRenderBounds(t){la(t||this.__layout.renderBounds,this.children,this.__hasMask?ga:pa)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let s=0,r=e.length;s<r;s++)e[s].__tempNumber=s,e[s].__.zIndex&&(t=!0);e.sort(da),this.__layout.affectChildrenSort=t}}add(t,e){if(t===this||t.destroyed)return ya.warn("add self or destroyed");const s=i(e);if(!t.__){if(d(t))return t.forEach(t=>{this.add(t,e),s||e++});t=Ht.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 r=t.__layout;r.boxChanged||r.boxChange(),r.matrixChanged||r.matrixChange(),t.__bubbleMap&&t.__emitLifeEvent(No.ADD),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(No.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 s=this.children.indexOf(t);s>-1&&(this.children.splice(s,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(No.REMOVE),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(No.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const s=new No(t,e,this);this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(s),this.leafer.emitEvent(s)}},exports.Branch=qt([Zi(Nn)],exports.Branch);class xa{get length(){return this.list.length}constructor(t){this.reset(),t&&(d(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:r}=this;for(let t=e,i=r.length;t<i;t++)s[r[t].innerId]++;0===e?r.unshift(t):(e>r.length&&(e=r.length),r.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 r=0,o=e.length;r<o;r++)i(s)?e[r].innerId===t.innerId&&(s=r,delete this.keys[t.innerId]):this.keys[e[r].innerId]=r-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 xa;return t.list=[...this.list],t.keys=Object.assign({},this.keys),t}update(){this.keys={};const{list:t,keys:e}=this;for(let s=0,r=t.length;s<r;s++)e[t[s].innerId]=s}reset(){this.list=[],this.keys={}}destroy(){this.reset()}}exports.AlignHelper=ht,exports.AroundHelper=ot,exports.AutoBounds=class{constructor(t,e,s,r,i,o){u(t)?this.copy(t):this.set(t,e,s,r,i,o)}set(t=0,e=0,s=0,r=0,i=0,o=0){this.top=t,this.right=e,this.bottom=s,this.left=r,this.width=i,this.height=o}copy(t){const{top:e,right:s,bottom:r,left:i,width:o,height:n}=t;this.set(e,s,r,i,o,n)}getBoundsFrom(t){const{top:e,right:s,bottom:r,left:i,width:o,height:n}=this;return new Lt(i,e,o||t.width-i-s,n||t.height-e-r)}},exports.BezierHelper=We,exports.Bounds=Lt,exports.BoundsEvent=Ho,exports.BoundsHelper=Ct,exports.BranchHelper=Bo,exports.BranchRender=Nn,exports.CanvasManager=class{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:s}=this;for(let r=0,i=s.length;r<i;r++)if(e=s[r],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const r=zt.canvas(t);return this.add(r),r}recycle(t){t.recycled=!0}clearRecycled(){let t;const e=[];for(let s=0,r=this.list.length;s<r;s++)t=this.list[s],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach(t=>{t.destroy()}),this.list.length=0}destroy(){this.clear()}},exports.ChildEvent=No,exports.Creator=zt,exports.DataHelper=p,exports.Debug=It,exports.EllipseHelper=Ue,exports.Event=Do,exports.EventCreator=Gt,exports.Eventer=an,exports.FileHelper=xi,exports.ImageEvent=Fo,exports.ImageManager=Ti,exports.IncrementId=e,exports.LayoutEvent=Zo,exports.LeafBounds=An,exports.LeafBoundsHelper=xo,exports.LeafData=f,exports.LeafDataProxy=wn,exports.LeafEventer=xn,exports.LeafHelper=lo,exports.LeafLayout=Wo,exports.LeafLevelList=class{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(d(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:s}=this;e[t.innerId]||(e[t.innerId]=1,s[t.__level]?s[t.__level].push(t):(s[t.__level]=[t],this.levels.push(t.__level)),this._length++)}forEach(t){let e;this.levels.forEach(s=>{e=this.levelMap[s];for(let s=0,r=e.length;s<r;s++)t(e[s])})}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}},exports.LeafList=xa,exports.LeafMatrix=Pn,exports.LeafRender=Wn,exports.LeaferCanvasBase=class extends te{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(s,r){super(),this.size={},this.worldTransform={},s||(s=ne),this.manager=r,this.innerId=e.create(e.CNAVAS);const{width:i,height:o,pixelRatio:n}=s;this.autoLayout=!i||!o,this.size.pixelRatio=n||t.devicePixelRatio,this.config=s,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 s;this.context&&!this.unreal&&e&&this.width&&(s=this.getSameCanvas(),s.copyWorld(this));const r=this.size;p.copyAttrs(r,t,ae),ae.forEach(t=>r[t]||(r[t]=1)),this.bounds=new Lt(0,0,this.width,this.height),this.context&&!this.unreal&&(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&s&&(this.clearWorld(s.bounds),this.copyWorld(s),s.recycle())}updateViewSize(){}updateClientBounds(){}getClientBounds(t){return t&&this.updateClientBounds(),this.clientBounds||this.bounds}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e){const{pixelRatio:s,pixelSnap:r}=this,i=this.worldTransform;e&&se(t,e,i),i.a=t.a*s,i.b=t.b*s,i.c=t.c*s,i.d=t.d*s,i.e=t.e*s,i.f=t.f*s,r&&(t.half&&t.half*s%2?(i.e=re(i.e-.5)+.5,i.f=re(i.f-.5)+.5):(i.e=re(i.e),i.f=re(i.f))),this.setTransform(i.a,i.b,i.c,i.d,i.e,i.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,s,r){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),s&&this.setStrokeOptions(s,r)}setStrokeOptions(t,e){let{strokeCap:s,strokeJoin:r,dashPattern:o,dashOffset:n,miterLimit:a}=t;e&&(e.strokeCap&&(s=e.strokeCap),e.strokeJoin&&(r=e.strokeJoin),i(e.dashPattern)||(o=e.dashPattern),i(e.dashOffset)||(n=e.dashOffset),e.miterLimit&&(a=e.miterLimit)),this.strokeCap=s,this.strokeJoin=r,this.dashPattern=o,this.dashOffset=n,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,s=1){return!0}setWorldShadow(t,e,s,r){const{pixelRatio:i}=this;this.shadowOffsetX=t*i,this.shadowOffsetY=e*i,this.shadowBlur=s*i,this.shadowColor=r||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,s,r,i=!0){r&&(this.blendMode=r),e?(this.setTempPixelBounds(e,i),s?(this.setTempPixelBounds2(s,i),s=oe):s=ie,this.drawImage(t.view,ie.x,ie.y,ie.width,ie.height,s.x,s.y,s.width,s.height)):this.drawImage(t.view,0,0),r&&(this.blendMode="source-over")}copyWorldToInner(t,e,s,r,i=!0){e.b||e.c?(this.save(),this.resetTransform(),this.copyWorld(t,e,Ct.tempToOuterOf(s,e),r,i),this.restore()):(r&&(this.blendMode=r),this.setTempPixelBounds(e,i),this.drawImage(t.view,ie.x,ie.y,ie.width,ie.height,s.x,s.y,s.width,s.height),r&&(this.blendMode="source-over"))}copyWorldByReset(t,e,s,r,i,o=!0){this.resetTransform(),this.copyWorld(t,e,s,r,o),i||this.useWorldTransform()}useGrayscaleAlpha(t){let e,s;this.setTempPixelBounds(t,!0,!0);const{context:r}=this,i=r.getImageData(ie.x,ie.y,ie.width,ie.height),{data:o}=i;for(let t=0,r=o.length;t<r;t+=4)s=.299*o[t]+.587*o[t+1]+.114*o[t+2],(e=o[t+3])&&(o[t+3]=255===e?s:e*(s/255));r.putImageData(i,ie.x,ie.y)}useMask(t,e,s){this.copyWorld(t,e,s,"destination-in")}useEraser(t,e,s){this.copyWorld(t,e,s,"destination-out")}fillWorld(t,e,s,r){s&&(this.blendMode=s),this.fillStyle=e,this.setTempPixelBounds(t,r),this.fillRect(ie.x,ie.y,ie.width,ie.height),s&&(this.blendMode="source-over")}strokeWorld(t,e,s,r){s&&(this.blendMode=s),this.strokeStyle=e,this.setTempPixelBounds(t,r),this.strokeRect(ie.x,ie.y,ie.width,ie.height),s&&(this.blendMode="source-over")}clipWorld(t,e=!0){this.beginPath(),this.setTempPixelBounds(t,e),this.rect(ie.x,ie.y,ie.width,ie.height),this.clip()}clipUI(t){t.windingRule?this.clip(t.windingRule):this.clip()}clearWorld(t,e=!0){this.setTempPixelBounds(t,e),this.clearRect(ie.x,ie.y,ie.width,ie.height)}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t+2,this.height*t+2)}setTempPixelBounds(t,e,s){this.copyToPixelBounds(ie,t,e,s)}setTempPixelBounds2(t,e,s){this.copyToPixelBounds(oe,t,e,s)}copyToPixelBounds(t,e,s,r){t.set(e),r&&t.intersect(this.bounds),t.scale(this.pixelRatio),s&&t.ceil()}isSameSize(t){return this.width===t.width&&this.height===t.height&&(!t.pixelRatio||this.pixelRatio===t.pixelRatio)}getSameCanvas(t,e){const{size:s,pixelSnap:r}=this,i=this.manager?this.manager.get(s):zt.canvas(Object.assign({},s));return i.save(),t&&(ee(i.worldTransform,this.worldTransform),i.useWorldTransform()),e&&(i.smooth=this.smooth),i.pixelSnap!==r&&(i.pixelSnap=r),i}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}},exports.LeaferEvent=Ko,exports.LeaferImage=class{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){if(this.use=0,this.waitComplete=[],this.innerId=Li(Oi),this.config=t||(t={url:""}),t.view){const{view:e}=t;this.setView(e.config?e.view:e)}Ti.isFormat("svg",t)&&(this.isSVG=!0),Ti.hasAlphaPixel(t)&&(this.hasAlphaPixel=!0)}load(e,s){if(!this.loading){this.loading=!0;let{loadImage:e,loadImageWithProgress:s}=t.origin,r=this.config.showProgress&&s&&this.onProgress.bind(this);r&&(e=s),ki.tasker.add(()=>Qt(this,void 0,void 0,function*(){return yield e(this.url,r).then(t=>this.setView(t)).catch(t=>{this.error=t,this.onComplete(!1)})}))}return this.waitComplete.push(e,s),this.waitComplete.length-2}unload(t,e){const s=this.waitComplete;if(e){const e=s[t+1];e&&e({type:"stop"})}s[t]=s[t+1]=void 0}setView(t){this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)}onProgress(t){this.progress=t}onComplete(t){let e;this.waitComplete.forEach((s,r)=>{e=r%2,s&&(t?e||s(this):e&&s(this.error))}),this.waitComplete.length=0,this.loading=!1}getFull(t){return this.view}getCanvas(e,s,r,i,o,n){if(e||(e=this.width),s||(s=this.height),this.cache){let{params:t,data:e}=this.cache;for(let s in t)if(t[s]!==arguments[s]){e=null;break}if(e)return e}const a=t.origin.createCanvas(Ri(Si(e+(o||0)),1),Ri(Si(s+(n||0)),1)),h=a.getContext("2d");return r&&(h.globalAlpha=r),h.drawImage(this.view,0,0,e,s),this.cache=this.use>1?{data:a,params:arguments}:null,a}getPattern(e,s,r,i){const o=t.canvas.createPattern(e,s);try{r&&o.setTransform&&(o.setTransform(r),r=void 0)}catch(t){}return i&&p.stintSet(i,"transform",r),o}destroy(){this.config={url:""},this.cache=null,this.waitComplete.length=0}},exports.MathHelper=m,exports.Matrix=$,exports.MatrixHelper=M,exports.NeedConvertToCanvasCommandMap=ce,exports.OneRadian=b,exports.PI2=B,exports.PI_2=v,exports.PathBounds=hi,exports.PathCommandDataHelper=$s,exports.PathCommandMap=de,exports.PathConvert=Ls,exports.PathCorner=fi,exports.PathCreator=fr,exports.PathDrawer=Sr,exports.PathHelper=he,exports.PathNumberCommandLengthMap=ge,exports.PathNumberCommandMap=fe,exports.Platform=t,exports.Plugin=Xt,exports.Point=J,exports.PointHelper=U,exports.PropertyEvent=Xo,exports.RectHelper=ye,exports.RenderEvent=$o,exports.ResizeEvent=Qo,exports.Resource=ki,exports.Run=Dt,exports.StringNumberMap=Rt,exports.TaskItem=bi,exports.TaskProcessor=Bi,exports.TwoPointBoundsHelper=tt,exports.UICreator=Ht,exports.WaitHelper=To,exports.WatchEvent=Jo,exports.affectRenderBoundsType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e),this.__layout.renderChanged||this.__layout.renderChange()}}))},exports.affectStrokeBoundsType=zi,exports.attr=Wi,exports.autoLayoutType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&(this.__hasAutoLayout=!!(this.origin||this.around||this.flow),this.__local||this.__layout.createLocal(),Yi(this))}}))},exports.boundsType=Ni,exports.canvasPatch=function(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,s,r,i){yi(this,t,e,s,r,i)})}(t)},exports.canvasSizeAttrs=ae,exports.createDescriptor=Mi,exports.cursorType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e),this.leafer&&this.leafer.updateCursor()}}))},exports.dataProcessor=function(t){return(e,s)=>{Ei(e,"__DataProcessor",{get:()=>t})}},exports.dataType=function(t){return Ai(t)},exports.decorateLeafAttr=Ai,exports.defineDataProcessor=Gi,exports.defineKey=Ei,exports.defineLeafAttr=Di,exports.doBoundsType=Yi,exports.doStrokeType=Fi,exports.emptyData={},exports.eraserType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&this.waitParent(()=>{this.parent.__updateEraser(e)})}}))},exports.extraPropertyEventMap=zo,exports.getBoundsData=C,exports.getDescriptor=Ii,exports.getMatrixData=T,exports.getPointData=k,exports.hitType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.hitCanvasChanged=!0,"hit"===It.showBounds&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor())}}))},exports.isArray=d,exports.isData=function(t){return u(t)&&!d(t)},exports.isEmptyData=c,exports.isFinite=a,exports.isNull=o,exports.isNumber=h,exports.isObject=u,exports.isString=n,exports.isUndefined=i,exports.layoutProcessor=function(t){return(e,s)=>{Ei(e,"__LayoutProcessor",{get:()=>t})}},exports.leaferTransformAttrMap=on,exports.maskType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent(()=>{this.parent.__updateMask(e)}))}}))},exports.naturalBoundsType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&(Yi(this),this.__.__removeNaturalSize())}}))},exports.opacityType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.opacityChanged||this.__layout.opacityChange()),this.mask&&ji(this)}}))},exports.pathInputType=function(t){return Ai(t,t=>({set(e){const s=this.__;2!==s.__pathInputed&&(s.__pathInputed=e?1:0),e||(s.__pathForRender=void 0),this.__setAttr(t,e),Yi(this)}}))},exports.pathType=Xi,exports.pen=gi,exports.positionType=function(t,e){return Ai(t,t=>({set(s){this.__setAttr(t,s,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange())}}))},exports.registerUI=function(){return t=>{Ht.register(t)}},exports.registerUIEvent=function(){return t=>{Gt.register(t)}},exports.rewrite=function(t){return(e,s)=>{qi.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}},exports.rewriteAble=function(){return t=>{Ji()}},exports.rotationType=function(t,e){return Ai(t,t=>({set(s){this.__setAttr(t,s,e)&&(this.__layout.rotationChanged||this.__layout.rotationChange())}}))},exports.scaleType=function(t,e){return Ai(t,t=>({set(s){this.__setAttr(t,s,e)&&(this.__layout.scaleChanged||this.__layout.scaleChange())}}))},exports.scrollType=function(t,e){return Ai(t,t=>({set(s){this.__setAttr(t,s,e)&&(this.__layout.matrixChanged||this.__layout.matrixChange(),this.__scrollWorld||(this.__scrollWorld={}))}}))},exports.sortType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent(()=>{this.parent.__layout.childrenSortChange()}))}}))},exports.strokeType=Hi,exports.surfaceType=function(t){return Ai(t,t=>({set(e){this.__setAttr(t,e)&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}}))},exports.tempBounds=St,exports.tempMatrix=K,exports.tempPoint=Z,exports.tryToNumber=function(t){return"string"==typeof t&&l.test(t)?+t:t},exports.useModule=Zi,exports.version="1.9.2",exports.visibleType=function(t){return Ai(t,t=>({set(e){const s=this.visible;if(!0===s&&0===e){if(this.animationOut)return this.__runAnimation("out",()=>Ui(this,t,e,s))}else 0===s&&!0===e&&this.animation&&this.__runAnimation("in");Ui(this,t,e,s),this.mask&&ji(this)}}))};
2
2
  //# sourceMappingURL=core.min.cjs.map