leafer-ui 1.0.0-alpha.23 → 1.0.0-alpha.30

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/dist/global.js CHANGED
@@ -1,2 +1 @@
1
- const t={},e={},s={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",types:{},create(t){const{types:e}=i;return e[t]?e[t]++:(e[t]=1,0)}},i=s,n={within:(t,e,s)=>(t<e&&(t=e),t>s&&(t=s),t)},o=Math.PI/180,{sin:r,cos:a,acos:h,atan:l,sqrt:d,PI:c}=Math,u={};function _(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const p={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},tempMatrix:{},set(t,e=1,s=0,i=0,n=1,o=0,r=0){t.a=e,t.b=s,t.c=i,t.d=n,t.e=o,t.f=r},get:_,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){t.e+=t.a*e+t.c*s,t.f+=t.b*e+t.d*s},scale(t,e,s=e){t.a*=e,t.d*=s,t.c*=e,t.b*=s},scaleOf(t,e,s,i=s){g.toInnerPoint(t,e,u),g.scaleOfInner(t,u,s,i)},scaleOfInner(t,e,s,i=s){g.translateInner(t,e.x,e.y),g.scale(t,s,i),g.translateInner(t,-e.x,-e.y)},rotate(t,e){const s=a(e*=o),i=r(e),{a:n,b:h,c:l,d:d}=t;t.a=n*s-h*i,t.b=n*i+h*s,t.c=l*s-d*i,t.d=l*i+d*s},rotateOf(t,e,s){g.toInnerPoint(t,e,u),g.rotateOfInner(t,u,s)},rotateOfInner(t,e,s){g.translateInner(t,e.x,e.y),g.rotate(t,s),g.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:i,b:n,c:r,d:a}=t;s&&(s*=o,t.a=i+r*s,t.b=n+a*s),e&&(e*=o,t.c=r+i*e,t.d=a+n*e)},skewOf(t,e,s,i){g.toInnerPoint(t,e,u),g.skewOfInner(t,u,s,i)},skewOfInner(t,e,s,i){g.translateInner(t,e.x,e.y),g.skew(t,s,i),g.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:i,c:n,d:o,e:r,f:a}=t;t.a=e.a*s+e.b*n,t.b=e.a*i+e.b*o,t.c=e.c*s+e.d*n,t.d=e.c*i+e.d*o,t.e=e.e*s+e.f*n+r,t.f=e.e*i+e.f*o+a},divide(t,e){g.multiply(t,g.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=g;return g.copy(e,t),g.invert(e),e},invert(t){const{a:e,b:s,c:i,d:n,e:o,f:r}=t,a=1/(e*n-s*i);t.a=n*a,t.b=-s*a,t.c=-i*a,t.d=e*a,t.e=-(o*n-r*i)*a,t.f=-(r*e-o*s)*a},toOuterPoint(t,e,s,i){const{x:n,y:o}=e;s||(s=e),s.x=n*t.a+o*t.c,s.y=n*t.b+o*t.d,i||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,i){const{x:n,y:o}=e,{a:r,b:a,c:h,d:l}=t,d=1/(r*l-a*h);if(s||(s=e),s.x=(n*l-o*h)*d,s.y=(o*r-n*a)*d,!i){const{e:e,f:i}=t;s.x-=(e*l-i*h)*d,s.y-=(i*r-e*a)*d}},decompose(t){const{a:e,b:s,c:i,d:n}=t;let r=e,a=n,u=0,_=0,p=0;if(s||i){const t=e*n-s*i,g=e*i+s*n;if(s){const i=e*e+s*s;r=d(i),a=t/r;const n=e/r;u=s>0?h(n):-h(n),_=l(g/i)/o}else{const e=i*i+n*n;a=d(e),r=t/a;const s=i/a;u=c/2-(n>0?h(-s):-h(s)),p=l(g/e)/o}u/=o}return{x:t.e,y:t.f,scaleX:r,scaleY:a,rotation:u,skewX:_,skewY:p}},reset(t){g.set(t)}},g=p,{toInnerPoint:f,toOuterPoint:y}=p,{sin:m,cos:v,abs:w,sqrt:x,atan2:B}=Math,b={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},copy(t,e){t.x=e.x,t.y=e.y},rotate(t,e,s){s||(s=E.defaultPoint);const i=v(e*o),n=m(e*o),r=t.x-s.x,a=t.y-s.y;t.x=s.x+r*i-a*n,t.y=s.y+r*n-a*i},tempToInnerOf(t,e){const{tempPoint:s}=E;return E.copy(s,t),f(e,s,s),s},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:s}=E;return E.copy(s,t),E.toInnerRadiusPointOf(t,e,s),s},toInnerRadiusPointOf(t,e,s){s||(s=t),f(e,t,s),s.radiusX=t.radiusX/e.a,s.radiusY=t.radiusY/e.d},toInnerOf(t,e,s){f(e,t,s)},toOuterOf(t,e,s){y(e,t,s)},getCenter:(t,e)=>({x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}),getDistance(t,e){const s=w(e.x-t.x),i=w(e.y-t.y);return x(s*s+i*i)},getAngle:(t,e)=>E.getAtan2(t,e)/o,getAtan2:(t,e)=>B(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s){const i=E.getAtan2(t,e);return{x:t.x+v(i)*s,y:t.y+m(i)*s}},reset(t){E.reset(t)}},E=b;class T{constructor(t,e){"object"==typeof t?b.copy(this,t):b.set(this,t,e)}set(t,e){b.set(this,t,e)}copy(t){return b.copy(this,t),this}clone(){return new T(this)}rotate(t,e){return b.rotate(this,t,e),this}toInnerOf(t,e){return b.toInnerOf(this,t,e),this}toOuterOf(t,e){return b.toOuterOf(this,t,e),this}getCenter(t){return b.getCenter(this,t)}getDistance(t){return b.getDistance(this,t)}getAngle(t){return b.getAngle(this,t)}getAtan2(t){return b.getAtan2(this,t)}reset(){b.reset(this)}}class k{constructor(t,e,s,i,n,o){"object"==typeof t?p.copy(this,t):p.set(this,t,e,s,i,n,o)}set(t,e,s,i,n,o){p.set(this,t,e,s,i,n,o)}copy(t){return p.copy(this,t),this}clone(){return new k(this)}translate(t,e){return p.translate(this,t,e),this}translateInner(t,e){return p.translateInner(this,t,e),this}scale(t,e){return p.scale(this,t,e),this}scaleOf(t,e,s){return p.scaleOf(this,t,e,s),this}scaleOfInner(t,e,s){return p.scaleOfInner(this,t,e,s),this}rotate(t){return p.rotate(this,t),this}rotateOf(t,e){return p.rotateOf(this,t,e),this}rotateOfInner(t,e){return p.rotateOfInner(this,t,e),this}skew(t,e){return p.skew(this,t,e),this}skewOf(t,e,s){return p.skewOf(this,t,e,s),this}skewOfInner(t,e,s){return p.skewOfInner(this,t,e,s),this}multiply(t){return p.multiply(this,t),this}divide(t){return p.divide(this,t),this}invert(){return p.invert(this),this}toOuterPoint(t,e){p.toOuterPoint(this,t,e)}toInnerPoint(t,e){p.toInnerPoint(this,t,e)}decompose(){return p.decompose(this)}reset(){p.reset(this)}}const R={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},add(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}},{tempPointBounds:P,setPoint:C,addPoint:O,toBounds:L}=R,{toOuterPoint:S}=p;let D,M,A,I;const W={},N={},F={tempBounds:{},set(t,e=0,s=0,i=0,n=0){t.x=e,t.y=s,t.width=i,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s){z.set(t,e.x-s,e.y-s,e.width+2*s,e.height+2*s)},right:t=>t.x+t.width,bottom:t=>t.y+t.height,move(t,e,s){t.x+=e,t.y+=s},getByMove:(t,e,s)=>(t=Object.assign({},t),z.move(t,e,s),t),getOutOfBounds(t,e){const s=-(z.right(e)-t.x),i=-(z.bottom(e)-t.y),n=Object.assign(Object.assign({},t),{offsetX:s,offsetY:i});return z.move(n,-s,-i),n},scale(t,e){t.x*=e,t.y*=e,t.width*=e,t.height*=e},tempToOuterOf:(t,e)=>(z.copy(z.tempBounds,t),z.toOuterOf(z.tempBounds,e),z.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),z.toOuterOf(t,e),t),toOuterOf(t,e,s){s||(s=t),0===e.b&&0===e.c?(s.x=e.e+t.x*e.a,s.y=e.f+t.y*e.d,s.width=t.width*e.a,s.height=t.height*e.d):(W.x=t.x,W.y=t.y,S(e,W,N),C(P,N.x,N.y),W.x=t.x+t.width,S(e,W,N),O(P,N.x,N.y),W.y=t.y+t.height,S(e,W,N),O(P,N.x,N.y),W.x=t.x,S(e,W,N),O(P,N.x,N.y),L(P,s))},getFitMatrix(t,e){const s=Math.min(1,Math.min(t.width/e.width,t.height/e.height));return new k(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e){const s={};return z.copyAndSpread(s,t,e),s},spread(t,e){z.copyAndSpread(t,t,e)},ceil(t){t.x=Math.floor(t.x),t.y=Math.floor(t.y),t.width=Math.ceil(t.width),t.height=Math.ceil(t.height)},add(t,e){D=t.x+t.width,M=t.y+t.height,A=e.x+e.width,I=e.y+e.height,D=D>A?D:A,M=M>I?M:I,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=D-t.x,t.height=M-t.y},addList(t,e){z.setByListWithHandle(t,e,void 0,!0)},setByList(t,e,s=!1){z.setByListWithHandle(t,e,void 0,s)},addListWithHandle(t,e,s){z.setByListWithHandle(t,e,s,!0)},setByListWithHandle(t,e,s,i=!1){if(!e.length)return void z.reset(t);let n,o=!0;for(let r=0,a=e.length;r<a;r++)n=s?s(e[r]):e[r],n&&(n.width||n.height)&&(o?(o=!1,i||j(t,n)):Y(t,n))},setByPoints(t,e){e.forEach(((t,e)=>{0===e?C(P,t.x,t.y):O(P,t.x,t.y)})),L(P,t)},hitRadiusPoint:(t,e,s)=>(s&&(e=b.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=b.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=z.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=z.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){s&&(e=z.tempToOuterOf(e,s));let{x:i,y:n,width:o,height:r}=e;return D=i+o,M=n+r,A=t.x+t.width,I=t.y+t.height,i=i>t.x?i:t.x,n=n>t.y?n:t.y,D=D<A?D:A,M=M<I?M:I,o=D-i,r=M-n,{x:i,y:n,width:o,height:r}},intersect(t,e,s){z.copy(t,z.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){z.set(t)}},z=F,{add:Y,copy:j}=z;class H{constructor(t,e,s,i){"object"==typeof t?F.copy(this,t):F.set(this,t,e,s,i)}set(t,e,s,i){F.set(this,t,e,s,i)}copy(t){return F.copy(this,t),this}clone(){return new H(this)}scale(t){return F.scale(this,t),this}toOuterOf(t,e){return F.toOuterOf(this,t,e),this}getFitMatrix(t){return F.getFitMatrix(this,t)}spread(t){return F.spread(this,t),this}ceil(){return F.ceil(this),this}add(t){return F.add(this,t),this}addList(t){return F.setByList(this,t,!0),this}setByList(t,e){return F.setByList(this,t,e),this}addListWithHandle(t,e){return F.setByListWithHandle(this,t,e,!0),this}setByListWithHandle(t,e,s){return F.setByListWithHandle(this,t,e,s),this}setByPoints(t){return F.setByPoints(this,t),this}hitPoint(t,e){return F.hitPoint(this,t,e)}hitRadiusPoint(t,e){return F.hitRadiusPoint(this,t,e)}hit(t,e){return F.hit(this,t,e)}includes(t,e){return F.includes(this,t,e)}intersect(t,e){return F.intersect(this,t,e),this}getIntersect(t,e){return new H(F.getIntersectData(this,t,e))}isSame(t){return F.isSame(this,t)}isEmpty(){return F.isEmpty(this)}reset(){F.reset(this)}}class X{constructor(t,e,s,i,n,o){"object"==typeof t?this.copy(t):this.set(t,e,s,i,n,o)}set(t=0,e=0,s=0,i=0,n=0,o=0){this.top=t,this.right=e,this.bottom=s,this.left=i,this.width=n,this.height=o}copy(t){const{top:e,right:s,bottom:i,left:n,width:o,height:r}=t;this.set(e,s,i,n,o,r)}getBoundsFrom(t){const{top:e,right:s,bottom:i,left:n,width:o,height:r}=this;return new H(n,e,o||t.width-n-s,r||t.height-e-i)}}const U={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};class V{constructor(t){this.name=t}static get(t){return new V(t)}static set filter(t){t?"string"==typeof t&&(t=[t]):t=[],this.filterList=t}static set exclude(t){t?"string"==typeof t&&(t=[t]):t=[],this.excludeList=t}log(...t){if(G.enable){if(G.filterList.length&&G.filterList.every((t=>t!==this.name)))return;if(G.excludeList.length&&G.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}warn(...t){console.warn(this.name,...t)}error(...t){console.error(this.name,...t)}}V.filterList=[],V.excludeList=[],V.__={};const G=V,K=V.get("RunTime");class q{static start(t,e){const i=s.create(s.RUNTIME);return Q.currentId=Q.idMap[i]=e?performance.now():Date.now(),Q.currentName=Q.nameMap[i]=t,Q.nameToIdMap[t]=i,i}static end(t,e){const s=Q.idMap[t],i=Q.nameMap[t];Q.idMap[t]=Q.nameMap[t]=Q.nameToIdMap[i]=void 0,e?K.log(i,performance.now()-s,"µs"):K.log(i,Date.now()-s,"ms")}static endOfName(t,e){const s=Q.nameToIdMap[t];void 0!==s&&Q.end(s,e)}}q.idMap={},q.nameMap={},q.nameToIdMap={};const Q=q,Z=V.get("UICreator"),$={list:{},register(t){const{__tag:e}=t.prototype;J[e]?Z.error("register the repeat UI: ",e):J[e]=t},get(t,e,s,i,n,o){const r=new J[t](e);return void 0!==s&&(r.x=s,i&&(r.y=i),n&&(r.width=n),o&&(r.height=o)),r}},{list:J}=$,tt=V.get("EventCreator"),et={nameList:{},register(t){let e;Object.keys(t).forEach((s=>{e=t[s],"string"==typeof e&&(st[e]?tt.error("register the repeat EventType: ",e):st[e]=t)}))},changeName(t,e){const s=st[t];if(s){const i=Object.keys(s).find((e=>s[e]===t));i&&(s[i]=e,st[e]=s)}},get:(t,...e)=>new st[t](...e)},{nameList:st}=et;class it{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let s;const{list:i}=this;for(let e=0,n=i.length;e<n;e++)if(s=i[e],s.recycled&&s.isSameSize(t))return s.recycled=!1,s;const n=e.canvas(t);return this.add(n),n}recycle(t){t.recycled||(t.clear(),t.recycled=!0)}clearRecycled(){let t;const e=[];for(let s=0,i=this.list.length;s<i;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}destory(){this.clear()}}class nt{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.pushList(t):this.push(t))}has(t){return void 0!==this.keys[t.innerId]}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return void 0===e?-1:e}pushList(t){t.forEach((t=>{this.push(t)}))}unshift(t){const{keys:e}=this;void 0===e[t.innerId]&&(this.list.unshift(t),Object.keys(e).forEach((t=>{void 0!==e[t]&&e[t]++})),e[t.innerId]=0)}push(t){const{list:e,keys:s}=this;void 0===s[t.innerId]&&(e.push(t),s[t.innerId]=e.length-1)}sort(t){const{list:e}=this;t?e.sort(((t,e)=>e.__level-t.__level)):e.sort(((t,e)=>t.__level-e.__level))}remove(t){const{list:e}=this;let s;for(let i=0,n=e.length;i<n;i++)void 0!==s?this.keys[e[i].innerId]=i-1:e[i].innerId===t.innerId&&(s=i,delete this.keys[t.innerId]);void 0!==s&&e.splice(s,1)}forEach(t){this.list.forEach(t)}clone(){const t=new nt;return this.list.forEach((e=>{t.push(e)})),t}reset(){this.list=[],this.keys={}}destroy(){this.list=null}}class ot{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(t instanceof Array?this.pushList(t):this.push(t))}has(t){return void 0!==this.keys[t.innerId]}without(t){return void 0===this.keys[t.innerId]}sort(t){const{levels:e}=this;t?e.sort(((t,e)=>e-t)):e.sort(((t,e)=>t-e))}pushList(t){t.forEach((t=>{this.push(t)}))}push(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,i=e.length;s<i;s++)t(e[s])}))}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}class rt extends it{constructor(){super(...arguments),this.pathTypeList=new nt,this.imageTypeList=new nt}get(t){}getImageType(t,s){return this.imageTypeList.push(t),e.hitCanvas(s)}getPathType(t){return this.pathTypeList.push(t),e.hitCanvas()}clearImageType(){this.__clearLeafList(this.imageTypeList)}clearPathType(){this.__clearLeafList(this.pathTypeList)}__clearLeafList(t){t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset()}clear(){this.clearPathType(),this.clearImageType()}}const at={default:(t,e)=>(ht(e,t),ht(t,e),t),assign(t,e){let s;Object.keys(e).forEach((i=>{var n;s=e[i],(null==s?void 0:s.constructor)===Object&&(null===(n=t[i])||void 0===n?void 0:n.constructor)===Object?ht(t[i],e[i]):t[i]=e[i]}))},clone:t=>JSON.parse(JSON.stringify(t))},{assign:ht}=at;class lt{constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];return void 0===e?this[t]:e}return this[t]}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];return void 0===e?this["_"+t]:e}return this["_"+t]}__getInputData(){const t={},{__input:e}=this;let s,i;for(let n in this)s=n.substring(1),void 0!==this[s]&&(i=e?e[s]:void 0,t[s]=void 0===i?this[n]:i);return t}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}destroy(){this.__leaf=null}}function dt(t,e,s){Object.defineProperty(t,e,s)}function ct(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ut(t,e,s,i){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)}};dt(t,e,Object.assign(n,i||{})),Tt(t,e,s)}function _t(t){return(e,s)=>{ut(e,s,t)}}function pt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.positionChanged||this.__layout.positionChange()}})}}function gt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.scaleChanged||this.__layout.scaleChange()}})}}function ft(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.rotationChanged||this.__layout.rotationChange()}})}}function yt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxBoundsChanged||this.__layout.boxBoundsChange()}})}}const mt=yt;function vt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.strokeBoundsChanged||this.__layout.strokeBoundsChange()}})}}function wt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange()}})}}function xt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.opacityChanged||this.__layout.opacityChange()}})}}function Bt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.parent?this.parent.__layout.childrenSortChanged=!0:this.__addParentWait((()=>{this.parent.__layout.childrenSortChanged=!0}))}})}}function bt(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxBoundsChanged||this.__layout.boxBoundsChange(),this.parent?this.parent.__hasMask=!!t||this.parent.children.some((t=>t.isMask)):this.__addParentWait((()=>{this.parent.__hasMask=!!t||this.parent.children.some((t=>t.isMask))}))}})}}function Et(t){return(e,s)=>{dt(e,"__DataProcessor",{get:()=>t})}}function Tt(t,e,s){const i=t.__DataProcessor.prototype,n="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),r={get(){const t=this[n];return void 0===t?s:t},set(t){this[n]=t}};void 0===s&&(r.get=function(){return this[n]});const a=ct(i,e);a&&(a.set&&(r.set=a.set),a.get&&(r.get=a.get)),i[o]&&(r.set=i[o],delete i[o]),Object.defineProperty(i,e,r)}const kt=new V("rewrite"),Rt=[],Pt=["destroy","constructor"];function Ct(t){return(e,s)=>{Rt.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}}function Ot(){return t=>{Lt()}}function Lt(t){Rt.length&&(Rt.forEach((e=>{t&&kt.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),Rt.length=0)}function St(t){return e=>{var s;(t.prototype?(s=t.prototype,Object.getOwnPropertyNames(s)):Object.keys(t)).forEach((s=>{if(!Pt.includes(s))if(t.prototype){ct(t.prototype,s).writable&&(e.prototype[s]=t.prototype[s])}else e.prototype[s]=t[s]}))}}function Dt(){return t=>{$.register(t)}}function Mt(){return t=>{et.register(t)}}function At(t,e,s,i){var n,o=arguments.length,r=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,s,r):n(e,s))||r);return o>3&&r&&Object.defineProperty(e,s,r),r}function It(t,e,s,i){return new(s||(s=Promise))((function(n,o){function r(t){try{h(i.next(t))}catch(t){o(t)}}function a(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}h((i=i.apply(t,e||[])).next())}))}setTimeout((()=>Lt(!0)));const{toOuterOf:Wt}=F;class Nt{constructor(t){this.leaf=t,this.renderBounds=this.strokeBounds=this.boxBounds={x:0,y:0,width:0,height:0},this.localRenderBounds=this.localStrokeBounds=t.__local,this.boxBoundsChange()}update(){const{leafer:t}=this.leaf;t&&(t.ready?t.watcher.changed&&t.layouter.layout():(t.start(),t.layouter.layout()))}getTransform(t){return this.update(),"world"===t?this.leaf.__world:this.leaf.__local}getMatrixDecompositionData(t){return this.update(),p.decompose("world"===t?this.leaf.__world:this.leaf.__local)}getBounds(t,e){if(this.update(),"world"===e)switch(t){case"render":return this.leaf.__world;case"box":return this.getWorldBoxBounds();case"stroke":return this.getWorldStrokeBounds()}else if("inner"===e)switch(t){case"render":return this.renderBounds;case"box":return this.boxBounds;case"stroke":return this.strokeBounds}else switch(t){case"render":return this.localRenderBounds;case"box":return this.leaf.__local;case"stroke":return this.localStrokeBounds}return this.leaf.__world}getWorldBoxBounds(){return this._worldBoxBounds||(this._worldBoxBounds={}),Wt(this.boxBounds,this.leaf.__world,this._worldBoxBounds),this._worldBoxBounds}getWorldStrokeBounds(){return this._worldStrokeBounds||(this._worldStrokeBounds={}),Wt(this.strokeBounds,this.leaf.__world,this._worldStrokeBounds),this._worldStrokeBounds}strokeBoundsSpreadCancel(){const t=this.renderBounds===this.strokeBounds;this.strokeBounds=this.boxBounds,this.localStrokeBounds=this.leaf.__local,t&&this.renderBoundsSpreadCancel()}renderBoundsSpreadCancel(){this.renderBounds=this.strokeBounds,this.localRenderBounds=this.localStrokeBounds}strokeBoundsSpread(){const{x:t,y:e,width:s,height:i}=this.strokeBounds;this.strokeBounds={x:t,y:e,width:s,height:i},this.localStrokeBounds={x:t,y:e,width:s,height:i},this.renderBoundsSpreadWidth||this.renderBoundsSpreadCancel()}renderBoundsSpread(){const{x:t,y:e,width:s,height:i}=this.renderBounds;this.renderBounds={x:t,y:e,width:s,height:i},this.localRenderBounds={x:t,y:e,width:s,height:i}}boxBoundsChange(){this.boxBoundsChanged=!0,this.localBoxBoundsChanged||this.localBoxBoundsChange(),this.hitCanvasChanged=!0}localBoxBoundsChange(){this.localBoxBoundsChanged=!0,this.boundsChanged=!0}strokeBoundsChange(){this.strokeBoundsChanged=!0,this.strokeBoundsSpreadWidth||(this.strokeBoundsSpreadWidth=1),this.boundsChanged=!0}renderBoundsChange(){this.renderBoundsChanged=!0,this.renderBoundsSpreadWidth||(this.renderBoundsSpreadWidth=1),this.boundsChanged=!0}positionChange(){this.positionChanged=!0,this.matrixChanged=!0,this.localBoxBoundsChanged||this.localBoxBoundsChange()}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChanged=!0,this.localBoxBoundsChanged||this.localBoxBoundsChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}destroy(){this.leaf=null}}const Ft=V.get("Life"),zt={},Yt={on(t,e,s){let i,n,o;if(s){const t="boolean"==typeof s;i=t?s:s.capture,n=!t&&s.once}const r=jt(this,i,!0),a="string"==typeof t?t.split(" "):t,h=n?{listener:e,once:n}:{listener:e};a.forEach((t=>{t&&(o=r[t],o?-1===o.findIndex((t=>t.listener===e))&&o.push(h):r[t]=[h])}))},off(t,e,s){let i,n,o;s&&(i="boolean"==typeof s?s:s.capture);const r=jt(this,i);("string"==typeof t?t.split(" "):t).forEach((t=>{t&&(n=r[t],n&&(o=n.findIndex((t=>t.listener===e)),o>-1&&n.splice(o,1),n.length||delete r[t]))}))},on__(t,e,s,i){return s&&(e=e.bind(s)),this.on(t,e,i),{type:t,listener:e,options:i}},off__(t){if(!t)return;const e=t instanceof Array?t:[t];e.forEach((t=>{this.off(t.type,t.listener,t.options)})),e.length=0},once(t,e,s){this.on(t,e,{once:!0,capture:s})},emit(t,e,s){V.enable&&Ft.log(t);const i=jt(this,s)[t];if(i){let n;for(let o=0,r=i.length;o<r&&(n=i[o],n.listener(e),n.once&&(this.off(t,n.listener,s),o--,r--),!e||!e.isStopNow);o++);}},emitEvent(t,e){t.current=this,this.emit(t.type,t,e)},hasEvent(t,e){const{__bubbleMap:s,__captureMap:i}=this;return void 0===e?!!(i&&i[t]||s&&s[t]):!!(e?i&&i[t]:s&&s[t])}};function jt(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:zt)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:zt)}}class Ht{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0}stopNow(){this.isStopNow=!0,this.isStop=!0}stop(){this.isStop=!0}}class Xt extends Ht{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}Xt.ADD="child.add",Xt.REMOVE="child.remove";class Ut extends Ht{constructor(t,e,s,i,n){super(t,e),this.attrName=s,this.oldValue=i,this.newValue=n}}Ut.CHANGE="property.change";class Vt extends Ht{constructor(t,e,s,i,n,o){super(t,e),this.image=s,this.attrName=i,this.attrValue=n,o&&(this.error=o)}}Vt.LOADED="image.loaded",Vt.ERROR="image.error";class Gt extends Ht{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){const s="object"==typeof t;super(s?Gt.RESIZE:t),s&&Object.assign(this,t),this.old=e}}Gt.RESIZE="resize";class Kt extends Ht{constructor(t,e){super(t),e&&Object.assign(this,e)}}Kt.START="transform.start",Kt.CHANGE="transform.change",Kt.END="transform.end",Kt.BEFORE_START="transform.before_start",Kt.BEFORE_CHANGE="transform.before_change",Kt.BEFORE_END="transform.before_end";class qt extends Ht{constructor(t,e){super(t),this.data=e}}qt.REQUEST="watch.request",qt.DATA="watch.data";class Qt extends Ht{constructor(t,e){super(t),e&&(this.data=e)}}Qt.REQUEST="layout.request",Qt.START="layout.start",Qt.BEFORE="layout.before",Qt.LAYOUT="layout.layout",Qt.AFTER="layout.after",Qt.AGAIN="layout.again",Qt.END="layout.end";class Zt extends Ht{}Zt.REQUEST="render.request",Zt.START="render.start",Zt.BEFORE="render.before",Zt.RENDER="render",Zt.AFTER="render.after",Zt.AGAIN="render.again",Zt.END="render.end";class $t extends Ht{}$t.START="leafer.start",$t.BEFORE_READY="leafer.before_ready",$t.READY="leafer.ready",$t.AFTER_READY="leafer.after_ready",$t.VIEW_READY="leafer.view_ready",$t.STOP="leafer.stop",$t.RESTART="leafer.restart",$t.END="leafer.end";const Jt={__setAttr(t,e){if(this.leafer&&this.leafer.ready){const s=this.__.__get(t);s!==e&&(this.__[t]=e,this.leafer.emitEvent(new Ut(Ut.CHANGE,this,t,s,e)))}else this.__[t]=e},__getAttr(t){return this.__.__get(t)},__updateAttr(t){if(this.leafer&&this.leafer.ready){t||(t="fill");const e=this.__.__get(t);this[t]=e,this.leafer.emitEvent(new Ut(Ut.CHANGE,this,t,e,e))}}},{defaultMatrix:te}=p,{sin:ee,cos:se}=Math,ie={__updateWorldMatrix(){const t=this.parent?this.parent.__world:te,e=this.__local,s=this.__world;this.__layout.matrixChanged&&this.__updateLocalMatrix(),this.__layout.affectScaleOrRotation?(s.a=e.a*t.a+e.b*t.c,s.b=e.a*t.b+e.b*t.d,s.c=e.c*t.a+e.d*t.c,s.d=e.c*t.b+e.d*t.d,s.e=e.e*t.a+e.f*t.c+t.e,s.f=e.e*t.b+e.f*t.d+t.f):(s.a=t.a,s.b=t.b,s.c=t.c,s.d=t.d,s.e=e.e*t.a+e.f*t.c+t.e,s.f=e.e*t.b+e.f*t.d+t.f)},__updateLocalMatrix(){const t=this.__local,e=this.__layout;if(e.affectScaleOrRotation){const{scaleX:s,scaleY:i}=this.__;if(e.affectRotation){if(e.scaleChanged||e.rotationChanged){let{rotation:n,skewX:r,skewY:a}=this.__;n||r||a?(n*=o,r&&(r*=o),a&&(a*=o),t.a=s*se(n+a),t.b=s*ee(n+a),t.c=i*-ee(n-r),t.d=i*se(n-r)):(t.a=s,t.b=0,t.c=0,t.d=i,e.affectRotation=!1),e.scaleChanged=!1,e.rotationChanged=!1}}else e.scaleChanged&&(t.a=s,t.d=i,e.scaleChanged=!1)}e.positionChanged&&(t.e=this.__.x,t.f=this.__.y,e.positionChanged=!1),this.__layout.matrixChanged=!1}},{toOuterOf:ne,copyAndSpread:oe}=F,re={__updateWorldBounds(){var t,e,s;if(this.__layout.boundsChanged){let i;const n=this.__layout;n.boxBoundsChanged&&(this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),n.boxBoundsChanged=!1,i=!0),n.localBoxBoundsChanged&&(this.__updateLocalBoxBounds(),n.localBoxBoundsChanged=!1,n.strokeBoundsSpreadWidth&&(n.strokeBoundsChanged=!0),n.renderBoundsSpreadWidth&&(n.renderBoundsChanged=!0),null===(t=this.parent)||void 0===t||t.__layout.boxBoundsChange()),n.strokeBoundsChanged&&(n.strokeBoundsSpreadWidth=this.__updateStrokeBoundsSpreadWidth(),n.strokeBoundsSpreadWidth?(n.strokeBounds===n.boxBounds&&n.strokeBoundsSpread(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds(),n.strokeBoundsChanged=!1,n.renderBoundsSpreadWidth&&(n.renderBoundsChanged=!0)):n.strokeBoundsSpreadCancel(),null===(e=this.parent)||void 0===e||e.__layout.strokeBoundsChange(),i||(i=!0)),n.renderBoundsChanged&&(n.renderBoundsSpreadWidth=this.__updateRenderBoundsSpreadWidth(),n.renderBoundsSpreadWidth?(n.renderBounds!==n.boxBounds&&n.renderBounds!==n.strokeBounds||n.renderBoundsSpread(),this.__updateRenderBounds(),this.__updateLocalRenderBounds(),n.renderBoundsChanged=!1):n.renderBoundsSpreadCancel(),null===(s=this.parent)||void 0===s||s.__layout.renderBoundsChange()),n.boundsChanged=!1,ne(this.__layout.renderBounds,this.__world,this.__world),i&&this.__onUpdateSize()}else ne(this.__layout.renderBounds,this.__world,this.__world)},__updateLocalBoxBounds(){ne(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){ne(this.__layout.strokeBounds,this.__local,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){ne(this.__layout.renderBounds,this.__local,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds;t.x=0,t.y=0,t.width=this.__.width,t.height=this.__.height},__updateStrokeBounds(){oe(this.__layout.strokeBounds,this.__layout.boxBounds,this.__layout.strokeBoundsSpreadWidth)},__updateRenderBounds(){oe(this.__layout.renderBounds,this.__layout.strokeBounds,this.__layout.renderBoundsSpreadWidth)}},{toInnerRadiusPointOf:ae}=b,he={},le={__hitWorld(t){return this.__layout.hitCanvasChanged&&(this.__updateHitCanvas(),this.__layout.hitCanvasChanged=!1),ae(t,this.__world,he),this.__hit(he)},__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this)),this.__drawHitPath(this.__hitCanvas)},__drawHitPath(t){this.__drawRenderPath(t)}},de={__render(t,e){this.__worldOpacity&&(t.setWorld(this.__world,e.matrix),t.opacity=this.__worldOpacity,this.__draw(t,e))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},{LEAF:ce,create:ue}=s;let _e=class{get tag(){return this.__tag}get __tag(){return"Leaf"}get __DataProcessor(){return lt}get __LayoutProcessor(){return Nt}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}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}constructor(t){this.innerId=ue(ce),this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0},this.__world={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),t&&Object.assign(this,t)}__addParentWait(t){this.__parentWait?this.__parentWait.push(t):this.__parentWait=[t]}__runParentWait(){const t=this.__parentWait.length;for(let e=0;e<t;e++)this.__parentWait[e]();this.__parentWait=null}__bindLeafer(t){if(this.isLeafer&&(t=this),this.leafer=t,this.__level=this.parent?this.parent.__level+1:1,this.__isBranch){const{children:e}=this;for(let s=0,i=e.length;s<i;s++)e[s].__bindLeafer(t)}}set(t){}get(t){}__setAttr(t,e){}__getAttr(t){}__updateAttr(t,e){}forceUpdate(){this.__updateAttr("x")}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateStrokeBoundsSpreadWidth(){return 0}__updateRenderBoundsSpreadWidth(){return 0}__onUpdateSize(){}getWorld(t){return this.__layout.getMatrixDecompositionData("world")[t]}getBounds(t,e="world"){return this.__layout.getBounds(t,e)}worldToLocal(t,e,s){this.parent?p.toInnerPoint(this.parent.worldTransform,t,e,s):e&&b.copy(e,t)}localToWorld(t,e,s){this.parent?p.toOuterPoint(this.parent.worldTransform,t,e,s):e&&b.copy(e,t)}worldToInner(t,e,s){p.toInnerPoint(this.worldTransform,t,e,s)}innerToWorld(t,e,s){p.toOuterPoint(this.worldTransform,t,e,s)}__hitWorld(t){return!0}__hit(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e){}__renderShape(t,e){}__updateWorldOpacity(){}__updateRenderTime(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}__updateSortChildren(){}add(t,e){}remove(t){this.parent&&this.parent.remove(this)}on(t,e,s){}off(t,e,s){}on__(t,e,s,i){}off__(t){}once(t,e,s){}emit(t,e,s){}emitEvent(t,e){}hasEvent(t,e){return!1}destroy(){this.__&&(this.__hitCanvas&&(this.__hitCanvas.destroy(),this.__hitCanvas=null),this.leafer=null,this.parent=null,this.__.destroy(),this.__layout.destroy(),this.__=null,this.__layout=null,this.__captureMap=null,this.__bubbleMap=null,this.__isBranch&&(this.children.forEach((t=>{t.destroy()})),this.children.length=0))}};_e=At([St(Jt),St(ie),St(re),St(le),St(Yt),St(de)],_e);const pe={updateAllWorldMatrix(t){if(t.__updateWorldMatrix(),t.__isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)fe(e[t])}},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.__isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)ye(e[t])}},updateAllChange(t){if(ye(t),t.__updateChange(),t.__isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)me(e[t])}},move(t,e,s){const i={x:e,y:s};t.parent&&p.toInnerPoint(t.parent.__world,i,i,!0),ge.moveLocal(t,i.x,i.y)},moveLocal(t,e,s){t.x=t.__.x+e,t.y=t.__.y+s},zoomOf(t,e,s,i,n){const o=t.parent?b.tempToInnerOf(e,t.parent.__world):e;this.zoomOfLocal(t,o,s,i,n)},zoomOfLocal(t,e,s,i,n){i||(i=s),n||(n=t);const{x:o,y:r}=n.__,a=(new k).translate(o,r).scaleOf(e,s,i);n.x=a.e,n.y=a.f,t.scaleX=t.__.scaleX*s,t.scaleY=t.__.scaleY*i},rotateOf(t,e,s,i){const n=t.parent?b.tempToInnerOf(e,t.parent.__world):e;this.rotateOfLocal(t,n,s,i)},rotateOfLocal(t,e,s,i){i||(i=t);const{x:n,y:o}=i.__,r=(new k).translate(n,o).rotateOf(e,s);i.x=r.e,i.y=r.f,t.rotation=t.__.rotation+s},drop(t,e){const s={x:t.x,y:t.y};t.localToWorld(s),e.worldToInner(s),t.set(s),e.add(t)}},ge=pe,{updateAllWorldMatrix:fe,updateAllWorldOpacity:ye,updateAllChange:me}=ge,ve={worldBounds:t=>t.__world,localBoxBounds:t=>t.__local,localEventBounds:t=>t.__layout.localStrokeBounds,localRenderBounds:t=>t.__layout.localRenderBounds,maskLocalBoxBounds:t=>t.isMask?t.__local:null,maskLocalEventBounds:t=>t.isMask?t.__layout.localStrokeBounds:null,maskLocalRenderBounds:t=>t.isMask?t.__layout.localRenderBounds:null},we={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 i=0,n=s.length;i<n;i++)(t=s[i]).__isBranch&&(t.__tempNumber=1,e.push(t),xe(t,e))}},pushAllParent(t,e){const{keys:s}=e;if(s)for(;t.parent&&void 0===s[t.parent.innerId];)e.push(t.parent),t=t.parent;else for(;t.parent;)e.push(t.parent),t=t.parent},pushAllBranchStack(t,e){let s=e.length;const{children:i}=t;for(let t=0,s=i.length;t<s;t++)i[t].__isBranch&&e.push(i[t]);for(let t=s,i=e.length;t<i;t++)Be(e[t],e)},updateWorldBoundsByBranchStack(t){let e;for(let s=t.length-1;s>-1;s--){e=t[s];for(let t=0,s=e.children.length;t<s;t++)e.children[t].__updateWorldBounds()}e.__updateWorldBounds()}},{pushAllChildBranch:xe,pushAllBranchStack:Be}=we,{setByListWithHandle:be}=F,{sort:Ee}=we,{localBoxBounds:Te,localEventBounds:ke,localRenderBounds:Re,maskLocalBoxBounds:Pe,maskLocalEventBounds:Ce,maskLocalRenderBounds:Oe}=ve;class Le extends _e{constructor(){super(),this.__isBranch=!0,this.children=[]}__updateStrokeBoundsSpreadWidth(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeBoundsSpreadWidth)return 1;return 0}__updateRenderBoundsSpreadWidth(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderBoundsSpreadWidth)return 1;return 0}__updateBoxBounds(){be(this.__layout.boxBounds,this.children,this.__hasMask?Pe:Te)}__updateStrokeBounds(){be(this.__layout.strokeBounds,this.children,this.__hasMask?Ce:ke)}__updateRenderBounds(){be(this.__layout.renderBounds,this.children,this.__hasMask?Oe:Re)}__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1)}__updateSortChildren(){const{children:t}=this;if(t.length>1){for(let e=0,s=t.length;e<s;e++)t[e].__tempNumber=e;t.sort(Ee)}}__render(t,e){if(this.__worldOpacity){let s;const{children:i}=this;if(this.__hasMask){let n,o=t;for(let o=0,r=i.length;o<r;o++)s=i[o],s.isMask?(n=(t=t.getSameCanvas()).getSameCanvas(),s.__render(n,e)):s.__render(t,e);n&&(n.resetTransform(),n.copyWorld(t,this.__world,null,"source-in"),o.resetTransform(),o.copyWorld(n,this.__world),t.recycle(),n.recycle())}else{const{bounds:n,hideBounds:o}=e;for(let r=0,a=i.length;r<a;r++)s=i[r],n&&!n.hit(s.__world,e.matrix)||o&&o.includes(s.__world)||s.__render(t,e)}}}add(t,e){if(t.parent&&t.parent.remove(t),t.parent=this,void 0===e?this.children.push(t):this.children.splice(e,0,t),t.__isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.ready)){const e=new Xt(Xt.ADD,t,this);this.hasEvent(Xt.ADD)&&this.emitEvent(e),this.leafer.emitEvent(e)}t.__parentWait&&t.__runParentWait()}remove(t){if(t){const e=this.children.indexOf(t);if(e>-1){if(this.children.splice(e,1),t.__isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.leafer){if(this.leafer.ready){const e=new Xt(Xt.REMOVE,t,this);this.hasEvent(Xt.REMOVE)&&this.emitEvent(e),this.leafer.emitEvent(e)}t.__bindLeafer(null)}t.parent=null,this.__layout.boxBoundsChange()}}else this.parent&&this.parent.remove(this)}}const Se={};class De{static isHoldSpaceKey(){return De.hasDownCode("Space")}static setDownCode(t){Se[t]||(Se[t]=!0)}static setUpCode(t){Se[t]=!1}static hasDownCode(t){return Se[t]}}class Me{static left(t){return 1===t.buttons}static right(t){return 2===t.buttons}static middle(t){return 4===t.buttons}}class Ae extends Ht{get spaceKey(){return De.isHoldSpaceKey()}get left(){return Me.left(this)}get right(){return Me.right(this)}get middle(){return Me.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}static changeName(t,e){et.changeName(t,e)}}let Ie=class extends Ae{};Ie.POINTER="pointer",Ie.BEFORE_DOWN="pointer.before_down",Ie.BEFORE_MOVE="pointer.before_move",Ie.BEFORE_UP="pointer.before_up",Ie.DOWN="pointer.down",Ie.MOVE="pointer.move",Ie.UP="pointer.up",Ie.OVER="pointer.over",Ie.OUT="pointer.out",Ie.ENTER="pointer.enter",Ie.LEAVE="pointer.leave",Ie.TAP="tap",Ie.DOUBLE_TAP="double_tap",Ie.CLICK="click",Ie.DOUBLE_CLICK="double_click",Ie.LONG_PRESS="long_press",Ie.LONG_TAP="long_tap",Ie=At([Mt()],Ie);let We=class extends Ie{};var Ne;We.DRAG="drag",We.START="drag.start",We.END="drag.end",We=At([Mt()],We);let Fe=Ne=class extends Ie{static setList(t){Ne.dragList=t instanceof nt?t:new nt(t)}static setData(t){this.dragData=t}};Fe.DROP="drop",Fe.ENTER="drop.enter",Fe.LEAVE="drop.leave",Fe=Ne=At([Mt()],Fe);let ze=class extends We{};ze.MOVE="move",ze.START="move.start",ze.END="move.end",ze=At([Mt()],ze);let Ye=class extends Ae{};Ye.ROTATE="rotate",Ye.START="rotate.start",Ye.END="rotate.end",Ye=At([Mt()],Ye);let je=class extends We{};je.SWIPE="swipe",je.LEFT="swipe.left",je.RIGHT="swipe.right",je.UP="swipe.up",je.DOWN="swipe.down",je=At([Mt()],je);let He=class extends Ae{};He.ZOOM="zoom",He.START="zoom.start",He.END="zoom.end",He=At([Mt()],He);let Xe=class extends Ae{};Xe.DOWN="key.down",Xe.PRESS="key.press",Xe.UP="key.up",Xe=At([Mt()],Xe);class Ue{constructor(t,e){this.map={},this.__onLoadMap={},this.__onErrorMap={},this.leafer=t}get(t){let s=this.map[t.url];return s||(s=e.image(t),this.map[t.url]=s),s}onLoad(t,e){const s=this.map[t.url];s&&s.ready&&e(s)}onError(t,e){}destory(){this.leafer=null}}const Ve={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,rect:100,roundRect:101,ellipse:102,arc:103,arcTo:104},Ge={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,rect:5,roundRect:6,ellipse:9,arc:7,arcTo:6},Ke={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,rect:100,roundRect:101,ellipse:102,arc:103,arcTo:104},qe=Ve,Qe={};for(let t in qe)Qe[qe[t]]=t;const Ze={};for(let t in qe)Ze[qe[t]]=Ge[t];const $e={},{sin:Je,cos:ts,sqrt:es,atan2:ss,ceil:is,abs:ns,PI:os}=Math,{setPoint:rs,addPoint:as}=R,hs={getFromACommand(t,e,s,i,n,o,r,a,h){const l=a-t,d=h-e,c=n*os/180,u=Je(c),_=ts(c),p=-_*l*.5-u*d*.5,g=-_*d*.5+u*l*.5,f=s*s,y=i*i,m=g*g,v=p*p,w=f*y-f*m-y*v;let x=0;if(w<0){const t=es(1-w/(f*y));s*=t,i*=t}else{x=(o===r?-1:1)*es(w/(f*m+y*v))}const B=x*s*g/i,b=-x*i*p/s,E=_*B-u*b+.5*l,T=u*B+_*b+.5*d;let k=ss((g-b)/i,(p-B)/s),R=ss((-g-b)/i,(-p-B)/s),P=R-k;0===r&&P>0?P-=2*os:1===r&&P<0&&(P+=2*os);const C=[],O=is(ns(P/os*2)),L=P/O,S=Je(L/2),D=Je(L/4),M=8/3*D*D/S;k=0,R=ss((g-b)/i,(p-B)/s);let A,I,W,N,F,z,Y,j,H=R-k,X=H+L,U=ts(H),V=Je(H),G=0,K=0;for(let n=0;n<O;n++)A=ts(X),I=Je(X),W=_*s*A-u*i*I+E,N=u*s*A+_*i*I+T,F=G+M*(-_*s*V-u*i*U),z=K+M*(-u*s*V+_*i*U),Y=W+M*(_*s*I+u*i*A),j=N+M*(u*s*I-_*i*A),C.push(Ve.C,F+t,z+e,Y+t,j+e,W+t,N+e),G=W,K=N,H=X,U=A,V=I,X+=L;return C},toTwoPointBounds(t,e,s,i,n,o,r,a,h){const l=[];let d,c,u,_,p,g,f,y,m=t,v=s,w=n,x=r;for(let t=0;t<2;++t)if(1==t&&(m=e,v=i,w=o,x=a),d=-3*m+9*v-9*w+3*x,c=6*m-12*v+6*w,u=3*v-3*m,Math.abs(d)<1e-12){if(Math.abs(c)<1e-12)continue;_=-u/c,0<_&&_<1&&l.push(_)}else f=c*c-4*u*d,y=Math.sqrt(f),f<0||(p=(-c+y)/(2*d),0<p&&p<1&&l.push(p),g=(-c-y)/(2*d),0<g&&g<1&&l.push(g));rs(h,t,e),as(h,r,a);for(let d=0,c=l.length;d<c;d++)ls.getPointAndSet(l[d],t,e,s,i,n,o,r,a,$e),as(h,$e.x,$e.y)},getPointAndSet(t,e,s,i,n,o,r,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,_=3*d*t*t,p=t*t*t;l.x=c*e+u*i+_*o+p*a,l.y=c*s+u*n+_*r+p*h},getPoint(t,e,s,i,n,o,r,a,h){const l={};return ls.getPointAndSet(t,e,s,i,n,o,r,a,h,l),l}},ls=hs,{M:ds,m:cs,L:us,l:_s,H:ps,h:gs,V:fs,v:ys,C:ms,c:vs,S:ws,s:xs,Q:Bs,q:bs,T:Es,t:Ts,A:ks,a:Rs,Z:Ps,z:Cs}=Ve,{getFromACommand:Os}=hs,Ls={current:{},stringify(t){let e,s,i,n=0,o=t.length,r="";for(;n<o;){s=t[n],e=Ze[s],r+=s===i?" ":Qe[s];for(let s=1;s<e;s++)r+=t[n+s],s===e-1||(r+=" ");i=s,n+=e}return r},parse(t,e=!0){let s,i,n="";const o=[];for(let e=0,r=t.length;e<r;e++)i=t[e],U[i]?n+=i:Ve[i]?(n&&(Ds(o,Number(n)),n=""),Ss.name=Ve[i],Ss.length=Ge[i],Ss.index=0,Ds(o,Ss.name),!s&&Ke[i]&&(s=!0)):"-"===i?(n&&Ds(o,Number(n)),n=i):n&&(Ds(o,Number(n)),n="");return n&&Ds(o,Number(n)),e&&s?Ls.convertToSimple(o):o},convertToSimple(t){let e,s,i,n,o,r=0,a=0,h=0,l=0,d=0,c=t.length;const u=[];for(;d<c;){switch(i=t[d],i){case cs:t[d+1]+=r,t[d+2]+=a;case ds:r=t[d+1],a=t[d+2],u.push(ds,r,a),d+=3;break;case gs:t[d+1]+=r;case ps:r=t[d+1],u.push(us,r,a),d+=2;break;case ys:t[d+1]+=a;case fs:a=t[d+1],u.push(us,r,a),d+=2;break;case _s:t[d+1]+=r,t[d+2]+=a;case us:r=t[d+1],a=t[d+2],u.push(us,r,a),d+=3;break;case xs:t[d+1]+=r,t[d+2]+=a,t[d+3]+=r,t[d+4]+=a,i=ws;case ws:o=n===ms||n===ws,h=o?2*r-e:t[d+1],l=o?2*a-s:t[d+2],e=t[d+1],s=t[d+2],r=t[d+3],a=t[d+4],u.push(ms,h,l,e,s,r,a),d+=5;break;case vs:t[d+1]+=r,t[d+2]+=a,t[d+3]+=r,t[d+4]+=a,t[d+5]+=r,t[d+6]+=a,i=ms;case ms:e=t[d+3],s=t[d+4],r=t[d+5],a=t[d+6],u.push(ms,t[d+1],t[d+2],e,s,r,a),d+=7;break;case Ts:t[d+1]+=r,t[d+2]+=a,i=Es;case Es:o=n===Bs||n===Es,e=o?2*r-e:t[d+1],s=o?2*a-s:t[d+2],r=t[d+1],a=t[d+2],u.push(Bs,e,s,r,a),d+=3;break;case bs:t[d+1]+=r,t[d+2]+=a,t[d+3]+=r,t[d+4]+=a,i=Bs;case Bs:e=t[d+1],s=t[d+2],r=t[d+3],a=t[d+4],u.push(Bs,e,s,r,a),d+=5;break;case Rs:t[d+6]+=r,t[d+7]+=a;case ks:u.push(...Os(r,a,t[d+1],t[d+2],t[d+3],t[d+4],t[d+5],t[d+6],t[d+7])),r=t[d+6],a=t[d+7],d+=8;break;case Cs:case Ps:u.push(Ps),d++}n=i}return u},pushData(t,e){Ss.index===Ss.length&&(Ss.index=1,t.push(Ss.name)),t.push(e),Ss.index++}},{current:Ss,pushData:Ds}=Ls,{M:Ms,L:As,C:Is,Q:Ws,Z:Ns,ellipse:Fs}=Ve,{toTwoPointBounds:zs}=hs,{add:Ys,addPoint:js,setPoint:Hs,toBounds:Xs}=R,Us={},Vs={},Gs={smoothCorner:(t,e,s)=>t,toBounds(t,e){Ks.toTwoPointBounds(t,Vs),Xs(Vs,e)},toTwoPointBounds(t,e){let s,i,n,o,r,a,h,l=0;const d=t.length;for(;l<d;)switch(s=t[l],0===l&&(s===Ms?Hs(e,t[1],t[2]):Hs(e,0,0)),s){case Ms:case As:i=t[l+1],n=t[l+2],js(e,i,n),l+=3;break;case Is:a=t[l+5],h=t[l+6],zs(i,n,t[l+1],t[l+2],t[l+3],t[l+4],a,h,Us),Ys(e,Us),i=a,n=h,l+=7;break;case Ws:o=t[l+1],r=t[l+2],a=t[l+3],h=t[l+4],zs(i,n,o,r,o,r,a,h,Us),Ys(e,Us),i=a,n=h,l+=5;break;case Ns:l+=1}e.minX--,e.minY--,e.maxX++,e.maxY++},drawData(t,e){if(e){let s,i=0,n=e.length;for(;i<n;)switch(s=e[i],s){case Ms:t.moveTo(e[i+1],e[i+2]),i+=3;break;case As:t.lineTo(e[i+1],e[i+2]),i+=3;break;case Is:t.bezierCurveTo(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5],e[i+6]),i+=7;break;case Ws:t.quadraticCurveTo(e[i+1],e[i+2],e[i+3],e[i+4]),i+=5;break;case Ns:t.closePath(),i+=1;break;case Fs:t.ellipse(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5],e[i+6],e[i+7],e[i+8]),i+=9}}}},Ks=Gs;let qs;const{M:Qs,L:Zs,C:$s,Q:Js,Z:ti,rect:ei,roundRect:si,ellipse:ii,arc:ni,arcTo:oi}=Ve,ri={begin(t){qs=t},end(){qs=null},moveTo(t,e){qs.push(Qs,t,e)},lineTo(t,e){qs.push(Zs,t,e)},bezierCurveTo(t,e,s,i,n,o){qs.push($s,t,e,s,i,n,o)},quadraticCurveTo(t,e,s,i){qs.push(Js,t,e,s,i)},close(t){qs.push(ti),t&&(qs=null)},rect(t,e,s,i){qs.push(ei,t,e,s,i)},roundRect(t,e,s,i,n){qs.push(si,t,e,s,i,n)},ellipse(t,e,s,i,n,o,r,a){qs.push(ii,t,e,s,i,n,o,r,a)},arc(t,e,s,i,n,o){qs.push(ni,t,e,s,i,n,o)},arcTo(t,e,s,i,n){qs.push(oi,t,e,s,i,n)}},ai=V.get("plugin"),hi={list:[]};class li{constructor(t){this.taskTime=1,this.id=s.create(s.TASK),this.task=t}run(){return It(this,void 0,void 0,(function*(){this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}}const di=V.get("TaskProcessor");class ci{constructor(t,e){this.updatedList=new nt,this.totalTimes=0,this.changed=!0,this.config={},this.target=t,e&&(this.config=at.default(e,this.config)),this.__listenEvents()}start(){this.running=!0,this.changed=!1,this.update()}stop(){this.running=!1}update(){this.running&&(this.changed=!0,this.target.emit(Zt.REQUEST))}__onAttrChange(t){this.updatedList.push(t.target),this.update()}__onChildEvent(t){this.updatedList.push(t.type===Xt.REMOVE?t.parent:t.child),this.update()}__onRquestData(){this.target.emitEvent(new qt(qt.DATA,{updatedList:this.updatedList})),this.updatedList=new nt,this.totalTimes++,this.changed=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(Ut.CHANGE,this.__onAttrChange,this),t.on__([Xt.ADD,Xt.REMOVE],this.__onChildEvent,this),t.on__(qt.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.updatedList=null)}}const{updateAllWorldMatrix:ui,updateAllWorldOpacity:_i}=pe,{pushAllChildBranch:pi,pushAllParent:gi}=we;const{worldBounds:fi}=ve,{setByListWithHandle:yi}=F;class mi{constructor(t){this.updatedBounds=new H,this.beforeBounds=new H,this.afterBounds=new H,t instanceof Array&&(t=new nt(t)),this.updatedList=t}setBefore(){yi(this.beforeBounds,this.updatedList.list,fi)}setAfter(){yi(this.afterBounds,this.updatedList.list,fi),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:vi,updateAllChange:wi}=pe,{pushAllBranchStack:xi,updateWorldBoundsByBranchStack:Bi}=we;class bi{constructor(t,e){this.totalTimes=0,this.changed=!0,this.config={partLayout:{maxTimes:3}},this.__levelList=new ot,this.target=t,e&&(this.config=at.default(e,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0,this.changed=!1,t.emit(Qt.START),this.layoutOnce(),t.emitEvent(new Qt(Qt.END,this.layoutedBlocks)),this.layoutedBlocks=null}layoutOnce(){this.totalTimes++,this.times++,this.target.emit(qt.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout()}partLayout(){var t;if(!(null===(t=this.__updateList)||void 0===t?void 0:t.length))return;const e=q.start("PartLayout"),{target:s,__updateList:i}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=Qt,a=this.getBlocks(i);a.forEach((t=>{t.setBefore()})),s.emitEvent(new Qt(n,a)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(ui(t),e.push(t),t.__isBranch&&pi(t,e),gi(t,e)):s.boundsChanged&&(e.push(t),t.__isBranch&&(t.__tempNumber=0),gi(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.__isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].__isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&_i(t),t.__updateChange()}))}(i),a.forEach((t=>t.setAfter())),s.emitEvent(new Qt(o,a)),s.emitEvent(new Qt(r,a)),this.setBlocks(a),this.__levelList.reset(),this.__updateList=null,q.end(e),this.__checkAgain()}fullLayout(){const t=q.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:i,AFTER:n}=Qt,o=this.getBlocks(new nt(e));e.emitEvent(new Qt(s,o)),bi.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new Qt(i,o)),e.emitEvent(new Qt(n,o)),this.setBlocks(o),q.end(t),this.__checkAgain()}static fullLayout(t){if(vi(t),t.__isBranch){const e=[t];xi(t,e),Bi(e)}else t.__updateWorldBounds();wi(t)}createBlock(t){return new mi(t)}getBlocks(t){return[this.createBlock(t)]}setBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__checkAgain(){}__onReceiveWatchData(t){this.__updateList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(Qt.REQUEST,this.layout,this),t.on__(Qt.AGAIN,this.layoutOnce,this),t.on__(qt.DATA,this.__onReceiveWatchData,this),t.on__(Zt.REQUEST,this.update,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null)}}const Ei=[];for(let t=0;t<360;t++)Ei.push(Math.round(360*Math.random())+"");function Ti(t,e,s,i){t.hittable&&(t.__isBranch?ki(t,e,s):Ri(t,e,s,i))}function ki(t,e,s){const{children:i}=t;let n;for(let t=0,o=i.length;t<o;t++)n=i[t],n.hittable&&(n.__isBranch?ki(n,e,s):Ri(n,e,s,n.__hasMask))}function Ri(t,e,s,i){if(t.__worldOpacity){const{isMask:n,__strokeOuterWidth:o}=t.__;if(i&&!n)return;e.setWorld(t.__world,s.matrix),e.opacity=.5,t.__drawHitPath(e),e.fillStyle=e.strokeStyle="hsl("+Ei[t.innerId%360]+",50%, 50%)",e.fill(t.__.windingRule),e.strokeWidth=o?2*o:1,e.stroke()}}const Pi=V.get("Renderer");class Ci{constructor(t,e,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,s&&(this.config=at.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed||this.__requestRender(),this.changed=!0}requestLayout(){this.target.emit(Qt.REQUEST)}render(t){const{target:e}=this;this.times=0,Pi.log(e.innerId,"---\x3e"),e.emit(Zt.START),this.renderOnce(t),e.emit(Zt.END),Pi.log(e.innerId,"---|")}renderOnce(t){const{target:e}=this;this.times++,this.totalTimes++,this.changed=!1,t?(e.emit(Zt.BEFORE),t()):(this.requestLayout(),e.emit(Zt.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),e.emit(Zt.RENDER),e.emit(Zt.AFTER),this.updateBlocks=null,this.__checkAgain()}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Pi.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=q.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world);s.save(),V.showRepaint||!n?(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0),V.showRepaint&&s.strokeWorld(i,"red")):s.clear(),this.__render(i),s.restore(),q.end(e)}fullRender(){const t=q.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),q.end(t)}__render(t){const e=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.target.__render(this.canvas,e),V.showHitView&&Ti(this.target,this.canvas,e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new H;e.setByList(t),t.length=0,t.push(e)}}__checkAgain(){}__requestRender(){const e=Date.now();t.requestRender((()=>{this.changed&&(this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&this.render())}))}__onResize(t){if(t.bigger||!t.samePixelRatio){const{width:e,height:s}=t.old;new H(0,0,e,s).includes(this.target.__world)||(this.target.__updateAttr("fill"),this.update())}}__onLayoutEnd(t){var e;null===(e=t.data)||void 0===e||e.map((t=>this.addBlock(t.updatedBounds)))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(Zt.REQUEST,this.update,this),t.on__(Qt.END,this.__onLayoutEnd,this),t.on__(Zt.AGAIN,this.renderOnce,this),t.on__(Gt.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:Oi}=F;class Li{constructor(t,e){this.target=t,this.selector=e}getHitPointPath(t,e,s){const i=!!s&&s.through;this.exclude=s?s.exclude:null,this.isStop=!1,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.eachFind(this.target.children,this.target.__hasMask);const{leaf:n}=this,{defaultPath:o}=this.selector,r=this.getPath(n);let a;if(r.pushList(o.list),i){const t=this.throughPath=new nt;this.eachThroughFind(this.target.children,this.target.__hasMask),t.pushList(o.list),a={path:r,leaf:n,throughPath:t}}else a={path:r,leaf:n};return this.clear(),a}getPath(t){const e=new nt;for(;t;)e.push(t),t=t.parent;return e}eachThroughFind(t,e){let s;const{point:i}=this;for(let n=t.length-1;n>-1;n--)if(s=t[n],(e?s.isMask&&s.__.hittable:s.__.hittable)&&Oi(s.__world,i)){if(s.__isBranch&&s.__.hitChildren&&this.eachThroughFind(s.children,s.__hasMask),this.exclude&&this.exclude.has(s))continue;s.__hitWorld(i)&&this.throughPath.push(s)}}eachFind(t,e){let s;const{point:i}=this;for(let n=t.length-1;n>-1&&(s=t[n],!(e?s.isMask&&s.__.hittable:s.__.hittable)||(Oi(s.__world,i)&&(s.__isBranch?(s.__.hitChildren&&this.eachFind(s.children,s.__hasMask),s.__isBranchLeaf&&(this.isStop||this.hitChild(s,i))):this.hitChild(s,i)),!this.isStop));n--);}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&(this.leaf=t,this.isStop=!0)}clear(){this.point=null,this.leaf=null,this.throughPath=null,this.exclude=null}destroy(){this.target=null,this.selector=null}}class Si{constructor(t){this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,this.defaultPath=new nt(t),this.pathFinder=new Li(t,this),this.__listenEvents()}getHitPointPath(t,e,s){return this.pathFinder.getHitPointPath(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.__isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on__(Xt.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.__removeListenEvents(),this.pathFinder.destroy(),this.target=null,this.pathFinder=null,this.innerIdList=null,this.idList=null,this.classNameList=null,this.tagNameList=null)}}function Di(t){return(e,s)=>{t||(t=s);const i={get(){return this.context[t]},set(e){this.context[t]=e}};Object.defineProperty(e,s,i)}}const Mi=[];function Ai(){return(t,e)=>{Mi.push(e)}}const Ii=[];class Wi{set dashPattern(t){this.context.setLineDash(t||Ii)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;Mi.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}))}setTransform(t,e,s,i,n,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,i,n,o){}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,s,i){}strokeRect(t,e,s,i){}clearRect(t,e,s,i){}drawImage(t,e,s,i,n,o,r,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/i*a;i+=e,e=0,o+=t,a-=t}if(s<0){const t=-s/n*h;n+=s,s=0,r+=t,h-=t}this.context.drawImage(t,e,s,i,n,o,r,a,h);break;case 5:this.context.drawImage(t,e,s,i,n);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,i,n,o){}quadraticCurveTo(t,e,s,i){}closePath(){}arc(t,e,s,i,n,o){}arcTo(t,e,s,i,n){}ellipse(t,e,s,i,n,o,r,a){}rect(t,e,s,i){}roundRect(t,e,s,i,n){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,i){}createPattern(t,e){}createRadialGradient(t,e,s,i,n,o){}fillText(t,e,s,i){}measureText(t){}strokeText(t,e,s,i){}destroy(){this.context=null}}At([Di("imageSmoothingEnabled")],Wi.prototype,"smooth",void 0),At([Di("imageSmoothingQuality")],Wi.prototype,"smoothLevel",void 0),At([Di("globalAlpha")],Wi.prototype,"opacity",void 0),At([Di("globalCompositeOperation")],Wi.prototype,"blendMode",void 0),At([Di()],Wi.prototype,"fillStyle",void 0),At([Di()],Wi.prototype,"strokeStyle",void 0),At([Di("lineWidth")],Wi.prototype,"strokeWidth",void 0),At([Di("lineCap")],Wi.prototype,"strokeCap",void 0),At([Di("lineJoin")],Wi.prototype,"strokeJoin",void 0),At([Di("lineDashOffset")],Wi.prototype,"dashOffset",void 0),At([Di()],Wi.prototype,"miterLimit",void 0),At([Di()],Wi.prototype,"shadowBlur",void 0),At([Di()],Wi.prototype,"shadowColor",void 0),At([Di()],Wi.prototype,"shadowOffsetX",void 0),At([Di()],Wi.prototype,"shadowOffsetY",void 0),At([Di()],Wi.prototype,"filter",void 0),At([Di()],Wi.prototype,"font",void 0),At([Di()],Wi.prototype,"fontKerning",void 0),At([Di()],Wi.prototype,"fontStretch",void 0),At([Di()],Wi.prototype,"fontVariantCaps",void 0),At([Di()],Wi.prototype,"textAlign",void 0),At([Di()],Wi.prototype,"textBaseline",void 0),At([Di()],Wi.prototype,"textRendering",void 0),At([Di()],Wi.prototype,"wordSpacing",void 0),At([Di()],Wi.prototype,"letterSpacing",void 0),At([Di()],Wi.prototype,"direction",void 0),At([Ai()],Wi.prototype,"setTransform",null),At([Ai()],Wi.prototype,"resetTransform",null),At([Ai()],Wi.prototype,"getTransform",null),At([Ai()],Wi.prototype,"save",null),At([Ai()],Wi.prototype,"restore",null),At([Ai()],Wi.prototype,"transform",null),At([Ai()],Wi.prototype,"translate",null),At([Ai()],Wi.prototype,"scale",null),At([Ai()],Wi.prototype,"rotate",null),At([Ai()],Wi.prototype,"fill",null),At([Ai()],Wi.prototype,"stroke",null),At([Ai()],Wi.prototype,"clip",null),At([Ai()],Wi.prototype,"fillRect",null),At([Ai()],Wi.prototype,"strokeRect",null),At([Ai()],Wi.prototype,"clearRect",null),At([Ai()],Wi.prototype,"beginPath",null),At([Ai()],Wi.prototype,"moveTo",null),At([Ai()],Wi.prototype,"lineTo",null),At([Ai()],Wi.prototype,"bezierCurveTo",null),At([Ai()],Wi.prototype,"quadraticCurveTo",null),At([Ai()],Wi.prototype,"closePath",null),At([Ai()],Wi.prototype,"arc",null),At([Ai()],Wi.prototype,"arcTo",null),At([Ai()],Wi.prototype,"ellipse",null),At([Ai()],Wi.prototype,"rect",null),At([Ai()],Wi.prototype,"roundRect",null),At([Ai()],Wi.prototype,"createConicGradient",null),At([Ai()],Wi.prototype,"createLinearGradient",null),At([Ai()],Wi.prototype,"createPattern",null),At([Ai()],Wi.prototype,"createRadialGradient",null),At([Ai()],Wi.prototype,"fillText",null),At([Ai()],Wi.prototype,"measureText",null),At([Ai()],Wi.prototype,"strokeText",null);const Ni=V.get("LeaferCanvas"),Fi=new H,zi={width:1,height:1,pixelRatio:1};class Yi extends Wi{get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}constructor(e,i){super(),e||(e=zi),e.pixelRatio||(e.pixelRatio=devicePixelRatio),this.manager=i,this.innerId=s.create(s.CNAVAS);const{view:n,width:o,height:r,pixelRatio:a,fill:h,hittable:l}=e,d=!o||!r;if(this.pixelRatio=a,this.offscreen=t.isWorker||e.offscreen,this.offscreen)n?this.view=n:this.__createView();else{n?this.__createViewFrom(n):this.__createView();const{style:t}=this.view;h&&(t.backgroundColor=h),l||(t.pointerEvents="none"),d&&(t.display||(t.display="block")),this.parentView=this.view.parentElement}this.__init(),d||this.resize(e)}__init(){this.context=this.view.getContext("2d"),this.__bindContext()}__createView(){this.view=this.offscreen?new OffscreenCanvas(1,1):document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:s}=e;s.position="absolute",s.top=s.bottom=s.left=s.right="0px",document.body.appendChild(e),t=e}this.__createView();const s=this.view;if(t.hasChildNodes()){const{style:e}=s;e.position="absolute",e.top=e.left="0px",t.style.position||(t.style.position="relative")}t.appendChild(s)}else Ni.error(`can't find view by id: ${t}`),this.__createView()}debug(){const t=document.createElement("div");t.style.position="absolute",t.style.top="10px",t.style.left="10px",t.style.transform="scale(0.5)",t.style.transformOrigin="0px 0px",t.style.pointerEvents="none",t.style.zIndex="100",document.body.appendChild(t),t.appendChild(this.view)}pixel(t){return t*this.pixelRatio}startAutoLayout(t,e){if(!this.offscreen){const s=this.view,i=i=>{const{x:n,y:o,width:r,height:a}=t.getBoundsFrom(i),{style:h}=s;if(h.marginLeft=n+"px",h.marginTop=o+"px",r!==this.width||a!==this.height){const{pixelRatio:t}=this,s={width:r,height:a,pixelRatio:t},i={width:this.width,height:this.height,pixelRatio:this.pixelRatio};this.resize(s),void 0!==this.width&&e(new Gt(s,i))}};this.resizeObserver=new ResizeObserver((t=>{for(const e of t)i(e.contentRect)}));const n=this.parentView;n&&(this.resizeObserver.observe(n),i(n.getBoundingClientRect()))}}stopAutoLayout(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}resize(t){const{width:e,height:s,pixelRatio:i}=t;if(this.isSameSize(t))return;let n;if(this.context&&this.width&&(n=this.getSameCanvas(),n.copyWorld(this)),Object.assign(this,{width:e,height:s,pixelRatio:i}),this.bounds=new H(0,0,e,s),!this.offscreen){const{style:t}=this.view;t.width=e+"px",t.height=s+"px"}this.view.width=e*i,this.view.height=s*i,this.smooth=!1,this.context&&n&&(this.copyWorld(n),n.recycle())}saveBlendMode(t){this.savedblendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedblendMode}setWorld(t,e,s){const{pixelRatio:i}=this;if(e)if(s)this.setTransform(t.a*i,t.b*i,t.c*i,t.d*i,(t.e+e.e)*i,(t.f+e.f)*i);else{const{a:s,b:n,c:o,d:r,e:a,f:h}=e;this.setTransform((t.a*s+t.b*o)*i,(t.a*n+t.b*r)*i,(t.c*s+t.d*o)*i,(t.c*n+t.d*r)*i,(t.e*s+t.f*o+a)*i,(t.e*n+t.f*r+h)*i)}else this.setTransform(t.a*i,t.b*i,t.c*i,t.d*i,t.e*i,t.f*i)}useSameTransform(t){this.setTransform(t.getTransform())}setStroke(t,e,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),s&&(this.strokeCap=s.strokeCap,this.strokeJoin=s.strokeJoin,this.dashPattern=s.dashPattern,this.dashOffset=s.dashOffset,this.miterLimit=s.miterLimit)}hitFill(t,e){return this.context.isPointInPath(t.x,t.y,e)}hitStroke(t){return this.context.isPointInStroke(t.x,t.y)}setWorldShadow(t,e,s,i){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=s*n,this.shadowColor=i||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,s,i){if(i&&(this.blendMode=i),e){const{pixelRatio:i}=this;s||(s=e),this.drawImage(t.view,e.x*i,e.y*i,e.width*i,e.height*i,s.x*i,s.y*i,s.width*i,s.height*i)}else this.drawImage(t.view,0,0);i&&(this.blendMode="normal")}copyWorldToInner(t,e,s,i){if(i&&(this.blendMode=i),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,F.tempToOuterOf(s,e)),this.restore();else{const{pixelRatio:i}=this;this.drawImage(t.view,e.x*i,e.y*i,e.width*i,e.height*i,s.x,s.y,s.width,s.height)}i&&(this.blendMode="normal")}fillWorld(t,e,s){s&&(this.blendMode=s),this.fillStyle=e,Fi.copy(t).scale(this.pixelRatio),this.fillRect(Fi.x,Fi.y,Fi.width,Fi.height),s&&(this.blendMode="normal")}strokeWorld(t,e,s){s&&(this.blendMode=s),this.strokeStyle=e,Fi.copy(t).scale(this.pixelRatio),this.strokeRect(Fi.x,Fi.y,Fi.width,Fi.height),s&&(this.blendMode="normal")}clearWorld(t,e){Fi.copy(t).scale(this.pixelRatio),e&&Fi.ceil(),this.clearRect(Fi.x,Fi.y,Fi.width,Fi.height)}clipWorld(t,e){this.beginPath(),Fi.copy(t).scale(this.pixelRatio),e&&Fi.ceil(),this.rect(Fi.x,Fi.y,Fi.width,Fi.height),this.clip()}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t,this.height*t)}isSameSize(t){return this.width===t.width&&this.height===t.height&&this.pixelRatio===t.pixelRatio}getSameCanvas(t){const{width:e,height:s,pixelRatio:i}=this,n=this.manager.get({width:e,height:s,pixelRatio:i});return n.manager||(n.manager=this.manager),n.save(),t&&n.useSameTransform(this),n}getBiggerCanvas(t,e){let{width:s,height:i,pixelRatio:n}=this;t&&(s+=t),e&&(i+=e);const o=this.manager.get({width:s,height:i,pixelRatio:n});return o.manager||(o.manager=this.manager),o.save(),o}recycle(){this.restore(),this.manager.recycle(this)}unloadView(){if(this.parentView){const t=this.view,e=t.style.backgroundColor;e&&(this.parentView.style.backgroundColor=e),t.remove()}}destroy(){if(this.view){if(super.destroy(),this.stopAutoLayout(),!this.offscreen){const t=this.view;t.parentElement&&t.remove()}this.manager=null,this.view=null,this.parentView=null,this.context=null}}}CanvasRenderingContext2D.prototype.roundRect||(CanvasRenderingContext2D.prototype.roundRect=Path2D.prototype.roundRect=function(t,e,s,i,n){let o,r,a,h;if(n instanceof Array)switch(n.length){case 4:o=n[0],r=n[1],a=n[2],h=n[3];break;case 2:o=a=n[0],r=h=n[1];break;case 3:o=n[0],r=h=n[1],a=n[2];break;case 1:n=n[0];break;default:n=0}if(void 0===o){if(!n)return void this.rect(t,e,s,i);o=r=a=h=n}const l=Math.min(s/2,i/2);o>l&&(o=l),r>l&&(r=l),a>l&&(a=l),h>l&&(h=l);const d=this;o?d.moveTo(t+o,e):d.moveTo(t,e),r?d.arcTo(t+s,e,t+s,e+i,r):d.lineTo(t+s,e),a?d.arcTo(t+s,e+i,t,e+i,a):d.lineTo(t+s,e+i),h?d.arcTo(t,e+i,t,e,h):d.lineTo(t,e+i),o?d.arcTo(t,e,t+s,e,o):d.lineTo(t,e),d.closePath()});class ji{constructor(t){this.options=t}load(t,e){let s=this.options.url;const i=this.view=new Image;i.setAttribute("crossOrigin","anonymous"),i.crossOrigin="anonymous",i.onload=()=>{this.ready=!0,this.width=i.naturalWidth,this.height=i.naturalHeight,t&&t(this)},i.onerror=t=>{e&&e(t)},i.src=s.includes("?")?s+"&xhr":s+"?xhr"}getCanvas(t,e,s,i){const n=document.createElement("canvas");t||(t=this.width),e||(e=this.height),n.width=t,n.height=e;const o=n.getContext("2d");return s&&(o.globalAlpha=s),o.drawImage(this.view,0,0,t,e),n}destory(){}}class Hi{constructor(t){this.interaction=t}move(t){const{interaction:e}=this;if(!this.moveData){const{path:s}=e.selector.getHitPointPath(t,e.hitRadius);t.path=s,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),e.emit(ze.START,this.moveData)}t.path=this.moveData.path,e.emit(ze.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;if(!this.zoomData){const{path:s}=e.selector.getHitPointPath(t,e.hitRadius);t.path=s,this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.emit(He.START,this.zoomData)}t.path=this.zoomData.path,e.emit(He.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;if(!this.rotateData){const{path:s}=e.selector.getHitPointPath(t,e.hitRadius);t.path=s,this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.emit(Ye.START,this.rotateData)}t.path=this.rotateData.path,e.emit(Ye.ROTATE,t),this.transformEndWait()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout((()=>{this.transformEnd()}),this.interaction.config.pointer.transformTime)}transformEnd(){this.moveEnd(),this.zoomEnd(),this.rotateEnd(),this.transformMode=null}moveEnd(){this.moveData&&(this.interaction.emit(ze.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(He.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(Ye.END,this.rotateData),this.rotateData=null)}destroy(){clearTimeout(this.transformTimer),this.transformEnd(),this.interaction=null}}const Xi={getMoveEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:t.x,y:t.y,moveX:e.x,moveY:e.y}),getRotateEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:t.x,y:t.y,rotation:e}),getZoomEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:t.x,y:t.y,scale:e}),getDragEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:s.x,y:s.y,moveX:s.x-e.x,moveY:s.y-e.y,totalX:s.x-t.x,totalY:s.y-t.y}),getDropEventData:(t,e,s)=>Object.assign(Object.assign({},t),{list:e,data:s}),getSwipeDirection:t=>t<-45&&t>-135?je.UP:t>45&&t<135?je.DOWN:t<=45&&t>=-45?je.RIGHT:je.LEFT,getSwipeEventData:(t,e,s)=>Object.assign(Object.assign({},s),{moveX:e.moveX,moveY:e.moveY,totalX:s.x-t.x,totalY:s.y-t.y,type:Ui.getSwipeDirection(b.getAngle(t,s))}),getBase:t=>({altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:void 0===t.buttons?1:t.buttons,origin:t}),pathHasEventType(t,e){const{list:s}=t;for(let t=0,i=s.length;t<i;t++)if(s[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const s=new nt,{list:i}=t;for(let t=0,n=i.length;t<n;t++)i[t].hasEvent(e)&&s.push(i[t]);return s}},Ui=Xi,{getDragEventData:Vi,getDropEventData:Gi,getSwipeEventData:Ki,filterPathByEventType:qi}=Xi;class Qi{constructor(t){this.interaction=t}setDragData(t){this.dragData=Vi(t,t,t)}getDragList(){return this.dragging?Fe.dragList||this.dragList:null}checkDrag(t,e){const{interaction:s}=this,{downData:i}=s;if(this.moving&&!Me.middle(t)&&!Me.left(t))return void s.pointerCancel();const{dragData:n}=this;this.moving||(this.moving=(Me.middle(t)||De.isHoldSpaceKey())&&e,this.moving&&s.emit(ze.START,n)),this.moving||this.dragStart(t,e);const{path:o,throughPath:r}=i;this.dragData=Vi(i,n,t),r&&(this.dragData.throughPath=r),this.dragData.path=o,this.moving?s.emit(ze.MOVE,this.dragData):this.dragging&&(s.emit(We.DRAG,this.dragData),this.dragDragableList())}dragStart(t,e){this.dragging||(this.dragging=Me.left(t)&&e,this.dragging&&(this.interaction.emit(We.START,this.dragData),this.getDragableList(this.dragData.path),this.dragList=qi(this.dragData.path,We.DRAG),!this.dragList.length&&this.dragableList&&this.dragList.pushList(this.dragableList)))}getDragableList(t){let e;for(let s=0,i=t.length;s<i;s++)if(e=t.list[s],e.draggable){this.dragableList=[e];break}}dragDragableList(){if(this.dragableList){const{moveX:t,moveY:e}=this.dragData;this.dragableList.forEach((s=>{pe.move(s,t,e)}))}}dropEnterOrLeave(t){const{interaction:e}=this,{dropEnterPath:s}=this,{path:i}=t;e.emit(Fe.ENTER,t,i,s),e.emit(Fe.LEAVE,t,s,i),this.dropEnterPath=i}dragEnd(t){const{interaction:e}=this,{downData:s}=e;if(!s)return;const{path:i,throughPath:n}=s,o=Vi(s,t,t);n&&(o.throughPath=n),o.path=i,this.moving&&e.emit(ze.END,o),this.dragging&&(e.emit(We.END,o),this.swipe(t,o),this.drop(t)),this.autoMoveCancel(),this.dragReset()}swipe(t,e){const{interaction:s}=this,{downData:i}=s;if(b.getDistance(i,t)>s.config.pointer.swipeDistance){const t=Ki(i,this.dragData,e);this.interaction.emit(t.type,t)}}drop(t){const e=Gi(t,this.getDragList(),Fe.dragData);e.path=this.dropEnterPath,this.interaction.emit(Fe.DROP,e),this.interaction.emit(Fe.LEAVE,t,this.dropEnterPath)}dragReset(){Fe.dragList=null,this.dragList=null,this.dragableList=null,this.dragData=null,this.dropEnterPath=null,this.dragging=null,this.moving=null}checkDragOut(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)}autoMoveOnDragOut(t){const{interaction:e}=this,{downData:s}=e,{autoMoveDistance:i}=e.config.pointer;if(!i)return;const n=e.shrinkCanvasBounds,{x:o,y:r}=n,a=F.right(n),h=F.bottom(n),l=t.x<o?i:a<t.x?-i:0,d=t.y<r?i:h<t.y?-i:0;let c=0,u=0;this.autoMoveTimer=setInterval((()=>{c+=l,u+=d,F.move(s,l,d),F.move(this.dragData,l,d),e.move(Object.assign(Object.assign({},t),{moveX:l,moveY:d,totalX:c,totalY:u})),e.pointerMoveReal(t)}),10)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.interaction=null,this.dragableList=null}}const{pathHasEventType:Zi}=Xi;class $i{get dragging(){return this.dragger.dragging}get hitRadius(){return this.config.pointer.hitRadius}constructor(t,e,s,i){this.config={wheel:{zoomMode:!1,zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,through:!1,tapTime:120,longPressTime:800,transformTime:500,dragHover:!0,dragDistance:2,swipeDistance:20,autoMoveDistance:2,ignoreMove:!1}},this.tapCount=0,this.target=t,this.canvas=e,this.selector=s,this.transformer=new Hi(this),this.dragger=new Qi(this),i&&(this.config=at.default(i,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}pointerDown(t){this.emit(Ie.BEFORE_DOWN,t,this.selector.defaultPath);const{hitRadius:e,through:s}=this.config.pointer,i=this.selector.getHitPointPath(t,e,{through:s});i.throughPath&&(t.throughPath=i.throughPath),t.path=i.path,this.emit(Ie.DOWN,t),this.downData=t,this.downTime=Date.now(),this.dragger.setDragData(t),Me.left(t)&&(this.tapWait(),this.longPressWait(t))}pointerMove(t){(this.downData||this.canvas.bounds.hitPoint(t))&&(this.pointerMoveReal(t),this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(Ie.BEFORE_MOVE,t,this.selector.defaultPath),this.downData){const e=b.getDistance(this.downData,t)>this.config.pointer.dragDistance;this.waitTap&&e&&this.pointerWaitCancel(),this.dragger.checkDrag(t,e)}if(this.dragger.moving||this.config.pointer.ignoreMove)return;const e=this.selector.getHitPointPath(t,this.hitRadius,{exclude:this.dragger.getDragList()});t.path=e.path,this.emit(Ie.MOVE,t),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t),this.dragger.dragging&&this.dragger.dropEnterOrLeave(t)}pointerUp(t){if(!this.downData)return;this.emit(Ie.BEFORE_UP,t,this.selector.defaultPath);const{through:e}=this.config.pointer,s=this.selector.getHitPointPath(t,this.hitRadius,{through:e});s.throughPath&&(t.throughPath=s.throughPath),t.path=s.path,this.emit(Ie.UP,t),this.emit(Ie.UP,this.downData,void 0,t.path),this.touchLeave(t),this.tap(t),this.dragger.dragEnd(t),this.downData=null}pointerCancel(){this.pointerUp(this.dragger.dragData)}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}pointerOverOrOut(t){if(this.dragger.moving)return;if(this.dragging&&!this.config.pointer.dragHover)return;const{path:e}=t;this.overPath?e.indexAt(0)!==this.overPath.indexAt(0)&&(this.emit(Ie.OUT,t,this.overPath),this.emit(Ie.OVER,t,e)):this.emit(Ie.OVER,t,e),this.overPath=e}pointerEnterOrLeave(t){if(this.dragger.moving)return;if(this.dragging&&!this.config.pointer.dragHover)return;const{path:e}=t;this.emit(Ie.ENTER,t,e,this.enterPath),this.emit(Ie.LEAVE,t,this.enterPath,e),this.enterPath=e}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(Ie.LEAVE,t),this.dragger.dragging&&this.emit(Fe.LEAVE,t))}tap(t){const{pointer:e}=this.config,s=this.longTap(t);if(!e.tapMulti&&s)return;if(!this.waitTap)return;e.tapMulti&&this.emitTap(t);const i=Date.now()-this.downTime,n=[Ie.DOUBLE_TAP,Ie.DOUBLE_CLICK].some((e=>Zi(t.path,e)));i<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=window.setTimeout((()=>{e.tapMulti||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMulti||(this.tapWaitCancel(),this.emitTap(t))}emitTap(t){this.emit(Ie.TAP,t),this.emit(Ie.CLICK,t)}emitDoubleTap(t){this.emit(Ie.DOUBLE_TAP,t),this.emit(Ie.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=window.setTimeout((()=>{this.longPressed=!0,this.emit(Ie.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(Ie.LONG_TAP,t),Zi(t.path,Ie.LONG_TAP)&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new H(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(Gt.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}emit(t,e,s,i){this.running&&function(t,e,s,i){if(!s&&!e.path)return;let n;e.type=t,s?e=Object.assign(Object.assign({},e),{path:s}):s=e.path,e.target=s.indexAt(0);for(let o=s.length-1;o>-1;o--)if(n=s.list[o],n.__.hittable&&n.hasEvent(t,!0)&&(!i||!i.has(n))){e.phase=1;const s=et.get(t,e);if(n.emitEvent(s,!0),s.isStop)return}for(let o=0,r=s.length;o<r;o++)if(n=s.list[o],n.__.hittable&&n.hasEvent(t,!1)&&(!i||!i.has(n))){e.phase=n===e.target?2:3;const s=et.get(t,e);if(n.emitEvent(s),s.isStop)return}}(t,e,s,i)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.config=null,this.target=null,this.selector=null,this.canvas=null,this.dragger=null,this.transformer=null)}}const Ji={convert(t,e){const s=Xi.getBase(t),i=Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===i.pointerType&&(i.tangentialPressure=t.tangentialPressure,i.tiltX=t.tiltX,i.tiltY=t.tiltY,i.twist=t.twist),i},convertMouse(t,e){const s=Xi.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const s=Ji.getTouch(t),i=Xi.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:s.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},tn={getData(t,e){const s=b.getCenter(t[0],t[1]),i=b.getCenter(e[0],e[1]),n={x:i.x-s.x,y:i.y-s.y},o=b.getDistance(t[0],t[1]),r=b.getDistance(e[0],e[1])/o,a=b.getAngle(t[0],t[1]),h=b.getAngle(e[0],e[1]);return{move:n,scale:r,angle:this.getChangedAngle(a,h),center:i}},getTouches(t){const e=[];for(let s=0,i=t.length;s<i;s++)e.push(t[s]);return e},getChangedAngle(t,e){const s=(e=e<=-90?360+e:e)-(t=t<=-90?360+t:t);return s<0?s+360:s}};let en=0;const sn={getMove:(t,e)=>({x:-t.deltaX*e.moveSpeed*2,y:-t.deltaY*e.moveSpeed*2}),getScale(t,e){let s,i=1,{zoomMode:o,zoomSpeed:r}=e;const a=t.deltaY||t.deltaX;if(o){const e=t.mozInputSource&&t.deltaY%18==0;e?en++:en=0,s=(Math.floor(t.deltaY)!==t.deltaY||e&&en>2)&&0===t.deltaX,(t.shiftKey||t.metaKey||t.ctrlKey)&&(s=!0)}else s=!t.shiftKey&&(t.metaKey||t.ctrlKey);if(s){r=n.within(r,0,1);i=1-a/(25*(t.deltaY?e.delta.y:e.delta.x)*(1-r)+10),i<.5&&(i=.5),i>=1.5&&(i=1.5)}return i}},{getMoveEventData:nn,getZoomEventData:on,getRotateEventData:rn}=Xi;class an extends $i{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.__onResize(),this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp};const{viewEvents:e,windowEvents:s}=this;for(let s in e)e[s]=e[s].bind(this),t.addEventListener(s,e[s]);for(let t in s)s[t]=s[t].bind(this),window.addEventListener(t,s[t])}__removeListenEvents(){super.__removeListenEvents();for(let t in this.viewEvents)this.view.removeEventListener(t,this.viewEvents[t]),this.viewEvents={};for(let t in this.windowEvents)window.removeEventListener(t,this.windowEvents[t]),this.windowEvents={}}__onResize(){super.__onResize(),this.clientBounds=new H(this.view.getBoundingClientRect())}getLocal(t){return{x:t.clientX-this.clientBounds.x,y:t.clientY-this.clientBounds.y}}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}onKeyDown(t){De.setDownCode(t.code)}onKeyUp(t){De.setUpCode(t.code)}onPointerDown(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMutiTouch||this.pointerDown(Ji.convert(t,this.getLocal(t)))}onPointerMove(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMutiTouch||this.pointerMove(Ji.convert(t,this.getLocal(t)))}onPointerUp(t){this.preventDefaultPointer(t),this.useMutiTouch||this.pointerUp(Ji.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMutiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(Ji.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerMove(Ji.convertMouse(t,this.getLocal(t)))}onMouseUp(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerUp(Ji.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(this.preventDefaultPointer(t),this.mutiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=Ji.getTouch(t);this.pointerDown(Ji.convertTouch(t,this.getLocal(e)))}onTouchMove(t){if(this.preventDefaultPointer(t),this.mutiTouchMove(t),this.usePointer)return;const e=Ji.getTouch(t);this.pointerMove(Ji.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.preventDefaultPointer(t),this.mutiTouchEnd(),this.usePointer)return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=window.setTimeout((()=>{this.useTouch=!1}),500);const e=Ji.getTouch(t);this.pointerUp(Ji.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}mutiTouchStart(t){this.useMutiTouch=t.touches.length>=2,this.touches=this.useMutiTouch?tn.getTouches(t.touches):void 0,this.useMutiTouch&&this.pointerCancel()}mutiTouchMove(t){if(this.useMutiTouch&&t.touches.length>=2){const e=tn.getTouches(t.touches),s=e.find((t=>t.identifier===this.touches[0].identifier)),i=e.find((t=>t.identifier===this.touches[1].identifier));if(s&&i){const n=[this.getLocal(this.touches[0]),this.getLocal(this.touches[1])],o=[this.getLocal(s),this.getLocal(i)],{move:r,angle:a,scale:h,center:l}=tn.getData(n,o),d=Xi.getBase(t);this.rotate(rn(l,a,d)),this.zoom(on(l,h,d)),this.move(nn(l,r,d)),this.touches=e}}}mutiTouchEnd(){this.touches=null,this.useMutiTouch=!1,this.transformEnd()}onWheel(t){this.preventDefaultWheel(t);const{wheel:e}=this.config,s=e.getScale?e.getScale(t,e):sn.getScale(t,e),i=this.getLocal(t),n=Xi.getBase(t);1!==s?this.zoom(on(i,s,n)):this.move(nn(i,e.getMove?e.getMove(t,e):sn.getMove(t,e),n))}onGesturestart(t){this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0}onGesturechange(t){this.preventDefaultWheel(t);const e=this.getLocal(t),s=Xi.getBase(t),i=t.scale/this.lastGestureScale,o=t.rotation-this.lastGestureRotation;let{rotateSpeed:r}=this.config.wheel;r=n.within(r,0,1),this.zoom(on(e,i*i,s)),this.rotate(rn(e,o/Math.PI*180*(r/4+.1),s)),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.preventDefaultWheel(t),this.transformEnd()}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function hn(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__.__useEffect=!0,this.__layout.renderBoundsChanged||this.__layout.renderBoundsChange()}})}}Object.assign(e,{canvas:(t,e)=>new Yi(t,e),image:t=>new ji(t),hitCanvas:(t,e)=>new Yi(t,e),watcher:t=>new ci(t),layouter:t=>new bi(t),renderer:(t,e,s)=>new Ci(t,e,s),selector:t=>new Si(t),interaction:(t,e,s,i)=>new an(t,e,s,i)}),t.requestRender=function(t){window.requestAnimationFrame(t)},t.canvas=e.canvas(),navigator.userAgent.indexOf("Firefox")>-1&&(t.conicGradientRotate90=!0);class ln extends lt{setFill(t){this._fill=t,"string"!=typeof t&&t?t instanceof Array?(this.__setInput("fill",t),this.__isFills=!0):"object"==typeof t&&(this.__setInput("fill",[t]),this.__isFills=!0):this.__isFills&&(this.__isFills=!1)}setStroke(t){this._stroke=t,"string"!=typeof t&&t?t instanceof Array?(this.__setInput("stroke",t),this.__isStrokes=!0):"object"==typeof t&&(this.__setInput("stroke",[t]),this.__isStrokes=!0):this.__isStrokes&&(this.__isStrokes=!1)}setShadow(t){this._shadow=t instanceof Array?t:[t]}setInnerShadow(t){this._innerShadow=t instanceof Array?t:[t]}}class dn extends ln{}const{parse:cn}=Ls;const un={__updateStrokeBoundsSpreadWidth(){let t=0;const{stroke:e,strokeAlign:s}=this.__;if(e&&"inside"!==s){const{strokeWidth:e,miterLimit:i,path:n}=this.__,r=n?1/Math.sin(i*o/2)*Math.sqrt(e):0;t="center"===s?e/2:e,this.__.__strokeOuterWidth=t,r&&(t+=r-t)}return t||(this.__.__strokeOuterWidth=0),t},__updateRenderBoundsSpreadWidth(){let t=0;const{shadow:e,innerShadow:s,blur:i,backgroundBlur:n}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),i&&(t=Math.max(t,i));let o=t=Math.ceil(t);return s&&s.forEach((t=>{o=Math.max(o,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),n&&(o=Math.max(o,n)),this.__layout.renderShapeBoundsSpreadWidth=o,t}},_n=["visible","fill-visible"],pn=["all","fill"],gn=["visible","stroke-visible"],fn=["all","stroke"],yn={__hit(t){const{__hitCanvas:e}=this,{fill:s,hitType:i}=this.__,n=s&&_n.includes(i)||pn.includes(i);if(n&&e.hitFill(t,this.__.windingRule))return!0;const{stroke:o,__strokeOuterWidth:r}=this.__,a=o&&gn.includes(i)||fn.includes(i);if(!n&&!a)return!1;const h=2*((a&&r||0)+t.radiusX);return e.strokeWidth!==h&&(e.strokeWidth=h,e.stroke()),e.hitStroke(t)}},mn={},vn={},wn={width:4,height:4};const xn={width:4,height:4};var Bn=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s){let i;const{__world:n,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:a,bounds:h,shapeBounds:l,scaleX:d,scaleY:c}=s,u=e.getBiggerCanvas(xn.width,xn.height),_=F.getOutOfBounds(h,e.bounds);r.forEach((t=>{u.save(),u.setWorldShadow(_.offsetX+t.x*d,_.offsetY+t.y*c,t.blur*d),u.copyWorld(s.canvas,l,t.spread?F.getSpread(_,-t.spread*d*(o.renderBounds.width/o.strokeBounds.width)):_),u.restore(),a?(u.copyWorld(u,h,n,"copy"),u.copyWorld(a,n,n,"source-out"),i=n):(u.copyWorld(s.canvas,l,h,"source-out"),i=h),u.fillWorld(i,t.color,"source-in"),e.copyWorldToInner(u,i,o.renderBounds,t.blendMode)})),u.recycle()},shadow:function(t,e,s){let i;const{__world:n,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:a,bounds:h,shapeBounds:l,scaleX:d,scaleY:c}=s,u=e.getBiggerCanvas(wn.width,wn.height),_=F.getOutOfBounds(h,e.bounds);r.forEach((t=>{u.setWorldShadow(_.offsetX+t.x*d,_.offsetY+t.y*c,t.blur*d,t.color),u.copyWorld(s.canvas,l,t.spread?F.getSpread(_,t.spread*d*(o.renderBounds.width/o.strokeBounds.width)):_),i=h,t.showBehind||(u.restore(),u.save(),a&&(u.copyWorld(u,h,n,"copy"),i=n),a?u.copyWorld(a,n,n,"destination-out"):u.copyWorld(s.canvas,l,h,"destination-out")),e.copyWorldToInner(u,i,o.renderBounds,t.blendMode)})),u.recycle()}});function bn(t,e){t.forEach((t=>{e.strokeStyle=t.style,t.blendMode?(e.saveBlendMode(t.blendMode),e.stroke(),e.restoreBlendMode()):e.stroke()}))}function En(t,e){return"string"==typeof t?t:(e&&(t.a=e),"rgba("+t.r+","+t.g+","+t.b+","+t.a+")")}const{get:Tn,rotateOf:kn,translate:Rn,scaleOf:Pn,scale:Cn,rotate:On}=p;function Ln(e,s,i,n,o){let{type:r,blendMode:a}=i,h={type:r,blendMode:a,style:"rgba(255,255,255,0)"};const l=e.leafer.imageManager.get(i);if(l.ready){let e,{opacity:s,mode:r,offset:a,scale:d,rotation:c}=i,{width:u,height:_}=l;const p=n===u&&o===_;switch(r){case"strench":p||(u=n,_=o);break;case"clip":(a||d||c)&&(e=function(t,e,s){const i=Tn();t&&Rn(i,t.x,t.y);e&&("number"==typeof e?Cn(i,e):Cn(i,e.x,e.y));s&&On(i,s);return i}(a,d,c));break;case"repeat":(!p||d||c)&&(e=function(t,e,s,i){const n=Tn();if(i)switch(On(n,i),i){case 90:Rn(n,e,0);break;case 180:Rn(n,t,e);break;case 270:Rn(n,0,t)}s&&Pn(n,{x:0,y:0},s);return n}(u,_,d,c));break;default:p&&!c||(e=function(t,e,s,i,n,o){const r=Tn(),a=o&&180!==o,h=i/(a?s:e),l=n/(a?e:s),d="fit"===t?Math.min(h,l):Math.max(h,l),c=(i-e*d)/2,u=(n-s*d)/2;if(Rn(r,c,u),Cn(r,d),o){kn(r,{x:i/2,y:n/2},o)}return r}(r,u,_,n,o,c))}h.style=function(e,s,i){let n=t.canvas.createPattern(e,i?"repeat":"no-repeat");if(s){const{a:t,b:e,c:i,d:o,e:r,f:a}=s;n.setTransform(new DOMMatrix([t,e,i,o,r,a]))}return n}(l.getCanvas(u,_,s),e,"repeat"===r)}else l.load((()=>{e.__.__getInput("width")||(e.width=l.width),e.__.__getInput("height")||(e.height=l.height),e.__updateAttr("width"),e.emitEvent(new Vt(Vt.LOADED,e,l,s,i))}),(t=>{e.emitEvent(new Vt(Vt.ERROR,e,l,s,i,t))}));return h}const Sn={x:.5,y:0},Dn={x:.5,y:1};function Mn(t,e,s){let i;for(let n=0,o=e.length;n<o;n++)i=e[n],t.addColorStop(i.offset,En(i.color,s))}const{set:An,getAngle:In,getDistance:Wn}=b,{get:Nn,rotateOf:Fn,scaleOf:zn}=p,Yn={x:.5,y:.5},jn={x:.5,y:1},Hn={},Xn={};const{set:Un,getAngle:Vn}=b,{get:Gn,rotateOf:Kn,scaleOf:qn}=p,Qn={x:.5,y:.5},Zn={x:.5,y:1},$n={},Jn={};function to(t,e){const s=t.__.__input[e];if("object"==typeof s){let i;const n=[];for(let o=0,r=s.length;o<r;o++)i=eo(t,s[o],e),i&&n.push(i);t.__["_"+e]=n.length?n:void 0}}function eo(e,s,i){if(!1===s.visible||0===s.opacity)return;const{width:n,height:o}=e.__layout.boxBounds;switch(s.type){case"solid":let{type:r,blendMode:a,color:h}=s;return{type:r,blendMode:a,style:En(h)};case"image":return Ln(e,i,s,n,o);case"linear":return function(e,s,i){let{from:n,to:o,type:r,blendMode:a,opacity:h}=e;n||(n=Sn),o||(o=Dn);const l=t.canvas.createLinearGradient(n.x*s,n.y*i,o.x*s,o.y*i);return Mn(l,e.stops,h),{type:r,blendMode:a,style:l}}(s,n,o);case"radial":return function(e,s,i){let n,{from:o,to:r,type:a,opacity:h,blendMode:l,stretch:d}=e;o||(o=Yn),r||(r=jn),An(Hn,o.x*s,o.y*i),An(Xn,r.x*s,r.y*i),(s!==i||d)&&(n=Nn(),zn(n,Hn,s/i*(d||1),1),Fn(n,Hn,In(Hn,Xn)+90));const c=t.canvas.createRadialGradient(Hn.x,Hn.y,0,Hn.x,Hn.y,Wn(Hn,Xn));return Mn(c,e.stops,h),{type:a,blendMode:l,style:c,transform:n}}(s,n,o);case"angular":return function(e,s,i){let{from:n,to:o,type:r,opacity:a,blendMode:h,stretch:l}=e;n||(n=Qn),o||(o=Zn),Un($n,n.x*s,n.y*i),Un(Jn,o.x*s,o.y*i);const d=Gn(),c=Vn($n,Jn);t.conicGradientRotate90?(qn(d,$n,s/i*(l||1),1),Kn(d,$n,c+90)):(qn(d,$n,1,s/i*(l||1)),Kn(d,$n,c));const u=t.canvas.createConicGradient(0,$n.x,$n.y);return Mn(u,e.stops,a),{type:r,blendMode:h,style:u,transform:d}}(s,n,o)}}var so=Object.freeze({__proto__:null,computeFill:function(t){to(t,"fill")},computeStroke:function(t){to(t,"stroke")},fill:function(t,e,s){e.fillStyle=s,e.fill(t.__.windingRule)},fills:function(t,e,s){let i;const{windingRule:n}=t.__;for(let t=0,o=s.length;t<o;t++)if(i=s[t],e.fillStyle=i.style,i.transform){e.save();const{a:t,b:s,c:o,d:r,e:a,f:h}=i.transform;e.transform(t,s,o,r,a,h),i.blendMode&&(e.blendMode=i.blendMode),e.fill(n),e.restore()}else i.blendMode?(e.saveBlendMode(i.blendMode),e.fill(n),e.restoreBlendMode()):e.fill(n)},shape:function(t,e,s){const i=e.getSameCanvas();let n,o,r,a;const{__world:h}=t;let{a:l,d:d}=h;if(e.bounds.includes(h,s.matrix))n=r=h,a=i;else{const{renderBoundsSpreadWidth:i}=t.__layout,c=F.getIntersectData(i?F.getSpread(e.bounds,i*h.a):e.bounds,h,s.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,s),l*=o.a,d*=o.d),r=F.getOuterOf(h,o),n=F.getByMove(r,-o.e,-o.f),s.matrix&&o.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:o})}return t.__renderShape(i,s),{canvas:i,matrix:o,bounds:n,worldCanvas:a,shapeBounds:r,scaleX:l,scaleY:d}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:o}=i;switch(o){case"center":e.setStroke(void 0,n,i),e.strokeStyle=s,e.stroke();break;case"inside":e.save(),e.setStroke(void 0,2*n,i),e.clip(i.windingRule),e.strokeStyle=s,e.stroke(),e.restore();break;case"outside":const o=e.getSameCanvas(!0);t.__drawRenderPath(o),o.setStroke(void 0,2*n,t.__),o.strokeStyle=s,o.stroke(),o.clip(i.windingRule),o.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}},strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:o}=i;switch(o){case"center":e.setStroke(void 0,n,i),bn(s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),e.clip(i.windingRule),bn(s,e),e.restore();break;case"outside":const{renderBounds:o}=t.__layout,r=e.getSameCanvas(!0);t.__drawRenderPath(r),r.setStroke(void 0,2*n,t.__),bn(s,r),r.clip(i.windingRule),r.clearWorld(o),e.copyWorldToInner(r,t.__world,o),r.recycle()}}});Object.assign(mn,Bn),Object.assign(vn,so);const io={__updateChange(){let t=this.__;t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i}=this.__;this.__drawRenderPath(t),s&&vn.fill(this,t,s),i&&vn.stroke(this,t,i)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const n=vn.shape(this,t,e),{shadow:o,innerShadow:r}=this.__;o&&mn.shadow(this,t,n),s&&(this.__.__isFills?vn.fills(this,t,s):vn.fill(this,t,s)),r&&mn.innerShadow(this,t,n),i&&(this.__.__isStrokes?vn.strokes(this,t,i):vn.stroke(this,t,i)),n.worldCanvas&&n.worldCanvas.recycle(),n.canvas.recycle()}else s&&(this.__.__isFills?vn.fills(this,t,s):vn.fill(this,t,s)),i&&(this.__.__isStrokes?vn.strokes(this,t,i):vn.stroke(this,t,i))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,fills:i,stroke:n,strokes:o}=this.__,{context:r}=t;this.__drawRenderPath(t),(s||i)&&(r.fillStyle="#000000",r.fill()),(n||o)&&(r.lineWidth=2,r.stroke())}},no={__render(t,e){const{fill:s,stroke:i}=this.__;i&&(this.__.stroke=void 0),this.__renderRect(t,e);const{clip:n}=this.__;n?(t.save(),t.clip(),this.__renderGroup(t,e),t.restore()):this.__renderGroup(t,e),i&&(this.__.stroke=i,s&&(this.__.fill=void 0),this.__renderRect(t,e),s&&(this.__.fill=s))}},oo={__drawFast(t,e){const{width:s,height:i,fill:n,stroke:o}=this.__;if(t.smooth=!1,n&&(t.fillStyle=n,t.fillRect(0,0,s,i)),o){const{strokeAlign:e,strokeWidth:n}=this.__;t.setStroke(o,n,this.__);const r=n/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(r,r,s-n,i-n);break;case"outside":t.strokeRect(-r,-r,s+n,i+n)}}}},ro={__drawFast(t,e){const{fill:s,stroke:i}=this.__,{list:n,font:o,decorationY:r,decorationHeight:a}=this.__.__textDrawData;let h;if(t.font=o,t.textBaseline="alphabetic",s){t.fillStyle=s;for(let e=0,s=n.length;e<s;e++)h=n[e],t.fillText(h.text,h.x,h.y),r&&t.fillRect(h.x,h.y+r,h.width,a)}if(i){t.strokeStyle=i;for(let e=0,s=n.length;e<s;e++)h=n[e],t.strokeText(h.text,h.x,h.y),r&&t.strokeRect(h.x,h.y+r,h.width,a)}}};ro.__draw=ro.__drawFast;let ao=class extends _e{constructor(t){super(t)}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&vn.computeFill(this),e&&vn.computeStroke(this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?Gs.smoothCorner(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}static one(t,e,s,i,n){return $.get(t.tag||this.prototype.__tag,t,e,s,i,n)}};At([Et(ln)],ao.prototype,"__",void 0),At([_t("")],ao.prototype,"id",void 0),At([_t("")],ao.prototype,"name",void 0),At([_t("")],ao.prototype,"className",void 0),At([wt()],ao.prototype,"blendMode",void 0),At([xt(1)],ao.prototype,"opacity",void 0),At([xt(!0)],ao.prototype,"visible",void 0),At([bt(!1)],ao.prototype,"isMask",void 0),At([Bt(0)],ao.prototype,"zIndex",void 0),At([_t()],ao.prototype,"locked",void 0),At([pt(0)],ao.prototype,"x",void 0),At([pt(0)],ao.prototype,"y",void 0),At([yt(100)],ao.prototype,"width",void 0),At([yt(100)],ao.prototype,"height",void 0),At([gt(1)],ao.prototype,"scaleX",void 0),At([gt(1)],ao.prototype,"scaleY",void 0),At([ft(0)],ao.prototype,"rotation",void 0),At([ft(0)],ao.prototype,"skewX",void 0),At([ft(0)],ao.prototype,"skewY",void 0),At([_t(!1)],ao.prototype,"draggable",void 0),At([_t(!0)],ao.prototype,"hittable",void 0),At([_t("visible")],ao.prototype,"hitType",void 0),At([_t(!0)],ao.prototype,"hitChildren",void 0),At([wt()],ao.prototype,"fill",void 0),At([vt()],ao.prototype,"stroke",void 0),At([vt("inside")],ao.prototype,"strokeAlign",void 0),At([vt(1)],ao.prototype,"strokeWidth",void 0),At([wt("none")],ao.prototype,"strokeCap",void 0),At([wt("miter")],ao.prototype,"strokeJoin",void 0),At([wt()],ao.prototype,"dashPattern",void 0),At([wt()],ao.prototype,"dashOffset",void 0),At([wt(10)],ao.prototype,"miterLimit",void 0),At([mt()],ao.prototype,"cornerRadius",void 0),At([mt()],ao.prototype,"cornerSmoothing",void 0),At([hn()],ao.prototype,"shadow",void 0),At([hn()],ao.prototype,"innerShadow",void 0),At([hn()],ao.prototype,"blur",void 0),At([hn()],ao.prototype,"backgroundBlur",void 0),At([hn()],ao.prototype,"grayscale",void 0),At([Ct(Gs.drawData)],ao.prototype,"__drawPathByData",null),ao=At([St(un),St(yn),St(io),Ot()],ao);let ho=class extends ao{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__isBranch=!0,this.children=[]}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}remove(t){}__removeMask(t){if(t)t.isMask=!1,this.remove(t);else{const{children:e}=this;for(let s=0,i=e.length;s<i;s++)(t=e[s]).isMask&&(t.isMask=!1,this.remove(t),i--,s--)}}};At([Et(dn)],ho.prototype,"__",void 0),ho=At([St(Le),Dt()],ho);let lo=class extends ao{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:i,cornerRadius:n}=this.__;n?t.roundRect(0,0,s,i,n):t.rect(0,0,s,i)}};At([Et(class extends ln{})],lo.prototype,"__",void 0),lo=At([St(oo),Dt()],lo);const co=lo.prototype,uo=ho.prototype,_o={},{copy:po,add:go}=F;let fo=class extends ho{get __tag(){return"Frame"}constructor(t){super(t),this.fill||(this.fill="#FFFFFF"),this.__isBranchLeaf=!0}__drawPathByData(t,e){}__updateBoxBounds(){if(this.__updateRectBoxBounds(),!this.__.clip){const{boxBounds:t}=this.__layout;po(_o,t),super.__updateBoxBounds(),go(t,_o)}}__updateStrokeBounds(){if(this.__updateRectStrokeBounds(),!this.__.clip){const{strokeBounds:t}=this.__layout;po(_o,t),super.__updateStrokeBounds(),go(t,_o)}}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.clip){const{renderBounds:t}=this.__layout;po(_o,t),super.__updateRenderBounds(),go(t,_o)}}__updateRectBoxBounds(){}__updateRectStrokeBounds(){}__updateRectRenderBounds(){}__renderRect(t,e){}__renderGroup(t,e){}};At([Et(class extends dn{})],fo.prototype,"__",void 0),At([yt(!0)],fo.prototype,"clip",void 0),At([Ct(co.__drawPathByData)],fo.prototype,"__drawPathByData",null),At([Ct(co.__updateBoxBounds)],fo.prototype,"__updateRectBoxBounds",null),At([Ct(co.__updateStrokeBounds)],fo.prototype,"__updateRectStrokeBounds",null),At([Ct(co.__updateRenderBounds)],fo.prototype,"__updateRectRenderBounds",null),At([Ct(co.__render)],fo.prototype,"__renderRect",null),At([Ct(uo.__render)],fo.prototype,"__renderGroup",null),fo=At([St(no),Ot(),Dt()],fo);const{PI:yo}=Math,{begin:mo,moveTo:vo,close:wo,ellipse:xo}=ri;let Bo=class extends ao{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:n}=this.__,r=t/2,a=e/2;mo(this.__.path=[]),s?i||n?(s<1&&xo(r,a,r*s,a*s,0,i*o,n*o,!1),xo(r,a,r,a,0,n*o,i*o,!0),s<1&&wo()):(s<1&&(xo(r,a,r*s,a*s,0,0,2*yo,!1),vo(t,a)),xo(r,a,r,a,0,0,2*yo,!0)):i||n?(vo(r,a),xo(r,a,r,a,0,i*o,n*o,!1),wo()):xo(r,a,r,a,0,0,2*yo,!1)}};At([Et(class extends ln{})],Bo.prototype,"__",void 0),At([mt(0)],Bo.prototype,"innerRadius",void 0),At([mt(0)],Bo.prototype,"startAngle",void 0),At([mt(0)],Bo.prototype,"endAngle",void 0),Bo=At([Dt()],Bo);const{sin:bo,cos:Eo,PI:To}=Math,{begin:ko,moveTo:Ro,lineTo:Po,close:Co}=ri;let Oo=class extends ao{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,sides:s}=this.__,i=t/2,n=e/2;ko(this.__.path=[]),Ro(i,0);for(let t=1;t<s;t++)Po(i+i*bo(2*t*To/s),n-n*Eo(2*t*To/s));Co()}};At([Et(class extends ln{})],Oo.prototype,"__",void 0),At([mt(3)],Oo.prototype,"sides",void 0),Oo=At([Dt()],Oo);const{sin:Lo,cos:So,PI:Do}=Math,{begin:Mo,moveTo:Ao,lineTo:Io,close:Wo}=ri;let No=class extends ao{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,points:s,innerRadius:i}=this.__,n=t/2,o=e/2;Mo(this.__.path=[]),Ao(n,0);for(let t=1;t<2*s;t++)Io(n+(t%2==0?n:n*i)*Lo(t*Do/s),o-(t%2==0?o:o*i)*So(t*Do/s));Wo()}};At([Et(class extends ln{})],No.prototype,"__",void 0),At([mt(5)],No.prototype,"points",void 0),At([mt(.382)],No.prototype,"innerRadius",void 0),No=At([Dt()],No);const{begin:Fo,moveTo:zo,lineTo:Yo,end:jo}=ri,{rotate:Ho,getAngle:Xo,getDistance:Uo,defaultPoint:Vo}=b,{setPoint:Go,addPoint:Ko,toBounds:qo}=R,Qo={};let Zo=class extends ao{get __tag(){return"Line"}get toPoint(){if(this.__toPoint&&!this.__layout.boxBoundsChanged)return this.__toPoint;const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&Ho(s,e),this.__toPoint=s,s}set toPoint(t){this.width=Uo(Vo,t),this.rotation=Xo(Vo,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){Fo(this.__.path=[]),zo(0,0);const t=this.toPoint;Yo(t.x,t.y),jo()}__updateBoxBounds(){Go(Qo,0,0),Ko(Qo,this.__toPoint.x,this.__toPoint.y),qo(Qo,this.__layout.boxBounds)}};At([Et(class extends ln{})],Zo.prototype,"__",void 0),At([yt()],Zo.prototype,"rotation",void 0),At([vt("center")],Zo.prototype,"strokeAlign",void 0),Zo=At([Dt()],Zo);const{toBounds:$o}=Gs;let Jo=class extends ao{get __tag(){return"Path"}constructor(t){super(t)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__updateBoxBounds(){$o(this.__.path,this.__layout.boxBounds)}};At([Et(class extends ln{setPath(t){this._path="string"==typeof t?cn(t):t}})],Jo.prototype,"__",void 0),At([mt()],Jo.prototype,"path",void 0),At([mt()],Jo.prototype,"windingRule",void 0),At([vt("center")],Jo.prototype,"strokeAlign",void 0),Jo=At([Dt()],Jo);let tr=class extends ho{get __tag(){return"Vector"}constructor(t){super(t)}__updatePath(){}};At([Et(class extends ln{})],tr.prototype,"__",void 0),At([mt()],tr.prototype,"paths",void 0),tr=At([Dt()],tr);const er={getFont(t){const{fontFamily:e,fontSize:s,fontWeight:i,italic:n,textCase:o}=t;return`${n?"italic":""} ${"small-caps"===o?"small-caps":"normal"} ${i||"normal"} ${s}px/${s}px ${e}`},getDrawData(e,s){const{width:i,height:n,fontSize:o,textDecoration:r,textAlign:a,verticalAlign:h}=s,{canvas:l}=t,d=[],c=o*s.lineHeight,u=l.font=sr.getFont(s);if(i){let t,s,n,o="",r=0,a="",h=0,c="",u=0;for(let _=0,p=e.length;_<p;_++)switch(t=e[_],t){case"\n":d.push({text:c+a}),c=a=o="",u=h=r=0;break;case" ":n||(n=l.measureText(t).width),o+=t,r+=n;break;default:s=l.measureText(t).width,u+h+r+s>i&&(h+r+s>i?(d.push({text:c+a}),c=a=o="",u=h=r=0):(d.push({text:c}),c="",u=0)),o&&(c+=a+o,u+=h+r,a=o="",h=r=0),a+=t,h+=s}d.push({text:c+a+o})}else e.split("\n").map((t=>{d.push({text:t})}));let _=0,p=c*d.length;d.forEach((t=>{t.width=l.measureText(t.text).width,_=Math.max(_,t.width)}));let g,f=c-(c-.7*o)/2;if(n)switch(h){case"middle":f+=(n-p)/2;break;case"bottom":f+=n-p}for(let t=0,e=d.length;t<e;t++){if(g=d[t],g.x=0,i)switch(a){case"center":g.x=(i-g.width)/2;break;case"right":g.x=i-g.width}g.y=f+c*t}let y,m=o/11;switch(r){case"underline":y=.1*o;break;case"strikethrough":y=.35*-o}return{list:d,x:0,y:0,width:_,height:p,font:u,decorationY:y,decorationHeight:m}}},sr=er;let ir=class extends ao{get __tag(){return"Text"}get realWidth(){return this.textDrawData.width}get realHeight(){return this.textDrawData.height}get textDrawData(){return this.__updateTextDrawData(),this.__.__textDrawData}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:i}=this.__;t.rect(0,0,s,i)}__updateTextDrawData(){this.__.__textDrawData||(this.__.__textDrawData=er.getDrawData(this.__.content,this.__))}__updateBoxBounds(){this.__updateTextDrawData();const{width:t,height:e,__textDrawData:s}=this.__,i=this.__layout.boxBounds;i.x=t?0:s.x||0,i.y=e?0:s.y||0,i.width=t?Math.max(t,s.width):s.width,i.height=e?Math.max(e,s.height):s.height}};At([Et(class extends ln{})],ir.prototype,"__",void 0),At([yt(void 0)],ir.prototype,"width",void 0),At([yt(void 0)],ir.prototype,"height",void 0),At([yt("")],ir.prototype,"content",void 0),At([yt("arial")],ir.prototype,"fontFamily",void 0),At([yt(12)],ir.prototype,"fontSize",void 0),At([yt("normal")],ir.prototype,"fontWeight",void 0),At([yt(!1)],ir.prototype,"italic",void 0),At([yt("normal")],ir.prototype,"textCase",void 0),At([yt("none")],ir.prototype,"textDecoration",void 0),At([yt()],ir.prototype,"letterSpacing",void 0),At([yt(1)],ir.prototype,"lineHeight",void 0),At([yt()],ir.prototype,"paragraphIndent",void 0),At([yt()],ir.prototype,"paragraphSpacing",void 0),At([wt("left")],ir.prototype,"textAlign",void 0),At([wt("top")],ir.prototype,"verticalAlign",void 0),ir=At([St(ro),Dt()],ir);let nr=class extends lo{get __tag(){return"Image"}get ready(){var t;return null===(t=this.image)||void 0===t?void 0:t.ready}constructor(t){super(t)}__updateBoxBounds(){let t;const{url:e}=this,s=this.fill;s?s[0].url!==e&&(t=!0):e&&(t=!0),t&&(this.image&&(this.image=null),this.fill={type:"image",mode:"strench",url:e},this.once(Vt.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}};At([Et(class extends ln{})],nr.prototype,"__",void 0),At([yt("")],nr.prototype,"url",void 0),nr=At([Dt()],nr);class or extends ho{get isApp(){return!1}get bounds(){return this.canvas.bounds}constructor(t){super(),this.config={type:"design",start:!0,hittable:!0},this.__eventIds=[],this.userConfig=t,(null==t?void 0:t.view)&&this.init(t)}init(t,s){this.__setLeafer(this),this.__setConfig(t);const{config:i}=this;this.creator=e,this.hittable=i.hittable,this.canvas=e.canvas(i),this.renderer=e.renderer(this,this.canvas,i),this.view=this.canvas.view,this.isApp?this.__setApp():(this.watcher=e.watcher(this),this.layouter=e.layouter(this)),this.__checkAutoLayout(i),s?this.__bindApp(s):(this.selector=e.selector(this),i.hittable&&(this.interaction=e.interaction(this,this,this.selector,i)),this.canvasManager=new it,this.hitCanvasManager=new rt,this.imageManager=new Ue(this,i),i.start&&(this.startTimer=setTimeout(this.start.bind(this)))),this.canvasManager.add(this.canvas),this.__listenEvents()}__listenEvents(){q.start("FirstCreate"),this.once($t.START,(()=>{q.endOfName("FirstCreate"),q.start("FirstLayout")})),this.once(Qt.END,(()=>{q.endOfName("FirstLayout"),q.start("FirstRender"),this.ready=!0,this.emit($t.BEFORE_READY),this.emit($t.READY),this.emit($t.AFTER_READY)})),this.once(Zt.END,(()=>{q.endOfName("FirstRender"),this.emit($t.VIEW_READY)}))}__removeListenEvents(){this.off__(this.__eventIds)}__setApp(){}__bindApp(t){var e;null===(e=t.selector)||void 0===e||e.defaultPath.unshift(this),this.selector=t.selector,this.config.hittable&&(this.interaction=t.interaction),this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager,this.imageManager=t.imageManager,t.running&&(this.startTimer=setTimeout(this.start.bind(this)))}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}__setConfig(t){t&&(this.config=at.default(t,this.config),this.__setAppType(this.config.type))}__setAppType(t){if("user"===t){const{config:t}=this;t.pointer||(t.pointer={}),t.pointer.autoMoveDistance=0}}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new X(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}start(){this.running||(this.ready?this.emit($t.RESTART):this.emit($t.START),this.interaction&&(this.__interactiveWindow(),this.interaction.start()),this.renderer.start(),this.layouter.start(),this.watcher.start(),this.running=!0)}stop(){this.running&&(this.interaction&&this.interaction.stop(),this.watcher.stop(),this.layouter.stop(),this.renderer.stop(),this.running=!1,this.emit($t.STOP))}__interactiveWindow(){if("user"!==this.config.type){const{MOVE:t}=ze,{ZOOM:e}=He;this.hasEvent(t)||this.__eventIds.push(this.on__(t,(t=>{pe.move(this,t.moveX,t.moveY)}))),this.hasEvent(e)||this.__eventIds.push(this.on__(e,(t=>{pe.zoomOf(this,t,t.scale)})))}}resize(t){if(this.canvas.isSameSize(t))return;const{width:e,height:s,pixelRatio:i}=this.canvas,n={width:e,height:s,pixelRatio:i};this.canvas.resize(t),this.__onResize(new Gt(t,n))}__onResize(t){this.emitEvent(t),setTimeout((()=>{this.canvasManager.clearRecycled()}),0)}destory(){var t,e,s;this.canvas&&(clearTimeout(this.startTimer),this.emit($t.END),this.stop(),this.__removeListenEvents(),null===(t=this.interaction)||void 0===t||t.destroy(),this.selector.destroy(),this.renderer.destroy(),null===(e=this.watcher)||void 0===e||e.destroy(),null===(s=this.layouter)||void 0===s||s.destroy(),this.canvasManager.destory(),this.hitCanvasManager.destory(),this.imageManager.destory(),this.canvas.destroy(),this.canvas=null,this.creator=null,this.config=null,this.interaction=null,this.selector=null,this.renderer=null,this.watcher=null,this.layouter=null,this.canvasManager=null,this.hitCanvasManager=null,this.imageManager=null,this.zoomLayer=null,this.moveLayer=void 0,this.parent=void 0,super.destroy())}}function rr(){return(t,e)=>{const s={get(){return this.canvas[e]},set(t){const{width:s,height:i,pixelRatio:n}=this.canvas,o={width:s,height:i,pixelRatio:n};o[e]=t,this.resize(o)}};Object.defineProperty(t,e,s)}}At([rr()],or.prototype,"width",void 0),At([rr()],or.prototype,"height",void 0),At([rr()],or.prototype,"pixelRatio",void 0);class ar extends or{constructor(){super(...arguments),this.children=[]}get isApp(){return!0}__setApp(){this.config.view===this.canvas.view?this.virtualCanvas=!0:(this.canvas.unloadView(),this.view=this.canvas.parentView)}start(){this.running||(this.children.forEach((t=>{t.start()})),this.renderer.start(),this.running=!0)}stop(){this.running&&(this.children.forEach((t=>{t.stop()})),this.renderer.stop(),this.running=!1)}addLeafer(t){const e=new or(t);return this.add(e),e}add(t){if(t.view||t.init(this.__getChildConfig(t.userConfig),this),super.add(t),this.virtualCanvas){const{renderer:e}=this;this.__eventIds.push(t.on__(Qt.END,this.__onChildLayoutEnd,this),t.on__(Zt.END,e.update,e),this.on__(Qt.REQUEST,e.mergeBlocks,e))}}__onChildLayoutEnd(t){const{renderer:e}=this;t.current.config.usePartRender?t.data.map((t=>e.addBlock(t.updatedBounds))):e.addBlock(e.canvas.bounds)}__render(t,e){this.children.forEach((e=>{t.copyWorld(e.canvas)}))}__onResize(t){this.emitEvent(t),this.children.forEach((e=>{e.resize(t)}))}__getChildConfig(t){let e=Object.assign({},this.config);return(t=t?at.default(t,e):e).view=this.virtualCanvas?null:this.canvas.parentView,t.virtualCanvas=null,this.autoLayout&&(t.width=this.width,t.height=this.height,t.pixelRatio=this.pixelRatio),t}}var hr;At([(hr=!0,(t,e)=>{ut(t,e,hr,{set(t){this.__setAttr(e,t),this.children.forEach((e=>{e.hittable=t}))}})})],ar.prototype,"hittable",void 0);var lr=Object.freeze({__proto__:null,Animate:{},App:ar,AutoBounds:X,BezierHelper:hs,Bounds:H,BoundsHelper:F,Branch:Le,BranchHelper:we,CanvasManager:it,ChildEvent:Xt,Creator:e,DataHelper:at,Debug:V,get DragEvent(){return We},get DropEvent(){return Fe},Effect:mn,get Ellipse(){return Bo},Event:Ht,EventCreator:et,Export:{},get Frame(){return fo},FrameRender:no,get Group(){return ho},HitCanvasManager:rt,get Image(){return nr},ImageEvent:Vt,ImageManager:Ue,IncrementId:s,Interaction:an,get KeyEvent(){return Xe},Keyboard:De,LayoutEvent:Qt,Layouter:bi,get Leaf(){return _e},LeafBounds:re,LeafBoundsHelper:ve,LeafData:lt,LeafDataProxy:Jt,LeafEventer:Yt,LeafHelper:pe,LeafHit:le,LeafLevelList:ot,LeafList:nt,LeafMatrix:ie,LeafRender:de,Leafer:or,LeaferCanvas:Yi,LeaferEvent:$t,LeaferImage:ji,get Line(){return Zo},MathHelper:n,Matrix:k,MatrixHelper:p,get MoveEvent(){return ze},NumberPathCommandLengthMap:Ze,NumberPathCommandMap:Qe,OneRadian:o,Paint:vn,get Path(){return Jo},PathCommandMap:Ve,PathCommandNeedConvertMap:Ke,PathConvert:Ls,PathCreator:ri,PathHelper:Gs,Platform:t,Plugin:hi,Point:T,PointHelper:b,PointerButton:Me,get PointerEvent(){return Ie},get Polygon(){return Oo},PropertyEvent:Ut,get Rect(){return lo},RectRender:oo,RenderEvent:Zt,Renderer:Ci,ResizeEvent:Gt,get RotateEvent(){return Ye},Run:q,Selector:Si,get Star(){return No},StringNumberMap:U,get SwipeEvent(){return je},TaskItem:li,TaskProcessor:class{get isComplete(){return this._isComplete}get running(){return this._running}constructor(t){this.parallel=6,this.params={},this.list=[],this.index=0,t&&(this.params=t,t.parallel&&(this.parallel=t.parallel)),this.init()}get percent(){const t=this.list.length;let e=0,s=0;for(let i=0;i<t;i++)i<=this.index?(s+=this.list[i].taskTime,i===this.index&&(e=s)):e+=this.list[i].taskTime;let i=this._isComplete?1:s/e;return Number.isNaN(i)&&(i=0),i}get total(){return this.list.length}get runIndex(){return this.index}init(){this.empty(),this.index=0,this.parallelSuccessNumber=0,this._running=!1,this._isComplete=!1}empty(){this.list=[],this.parallelList=[]}start(){this._running=!0,this._isComplete=!1,this.run()}pause(){this._running=!1}resume(){this._running=!0,this._isComplete=!1,this.run()}skip(){this.index++,this.resume()}stop(){this._running=!1,this.list.forEach((t=>{t.complete()})),this.empty()}add(t,e){this.push(new li(t),e)}addParallel(t,e){const s=new li(t);s.parallel=!0,this.push(s,e)}addEmpty(t){this.push(new li(t))}push(t,e){e&&(t.taskTime=e),t.parent=this,this.list.push(t)}run(){this._running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTask():this.runTask())}runTask(){const t=this.list[this.index];t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)}))}runParallelTask(){this.parallelList.forEach((t=>{t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.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,i=this.index+this.parallelSuccessNumber+s;if(e.length){if(!this._running)return;i<this.list.length&&(t=this.list[i],t.parallel&&(e.push(t),t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))))}else this.index+=this.parallelSuccessNumber,this.nextTask()}nextTask(){setTimeout((()=>{this.run()}),0)}onComplete(){this.stop(),this._isComplete=!0,this.params.onComplete&&this.params.onComplete()}onTask(t){t.complete(),this.params.onTask&&this.params.onTask(),this.index===this.list.length-1&&this.onComplete()}onParallelError(t){di.error("ParallelError"),this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.params.onError&&this.params.onError(t)}},get Text(){return ir},TextRender:ro,TransformEvent:Kt,TwoPointBounds:class{constructor(t,e){R.setPoint(this,t,e)}addPoint(t,e){R.addPoint(this,t,e)}add(t){R.add(this,t)}},TwoPointBoundsHelper:R,get UI(){return ao},UIBounds:un,UICreator:$,UIEvent:Ae,UIHit:yn,UIRender:io,get Vector(){return tr},WatchEvent:qt,Watcher:ci,get ZoomEvent(){return He},affectEventBoundsType:vt,affectRenderBoundsType:function(t){return(e,s)=>{ut(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.renderBoundsChanged||this.__layout.renderBoundsChange()}})}},aliasType:function(t){return(e,s)=>{dt(e,s,{get(){return this.__getAttr(t)},set(e){this.__setAttr(t,e)}})}},boundsType:yt,dataProcessor:Et,dataType:_t,defineDataProcessor:Tt,defineKey:dt,defineLeafAttr:ut,effectType:hn,getDescriptor:ct,layoutProcessor:function(t){return(e,s)=>{dt(e,"__LayoutProcessor",{get:()=>t})}},maskType:bt,opacityType:xt,pathType:mt,positionType:pt,registerUI:Dt,registerUIEvent:Mt,rewrite:Ct,rewriteAble:Ot,rotationType:ft,scaleType:gt,sortType:Bt,surfaceType:wt,useModule:St,usePlugin:function(t,e){if(hi.list.push(t),t.dependencies){const s={};t.dependencies.forEach((t=>{e[t]?s[t]=e[t]:ai.error(t+" non-existent")})),t.run(s)}else ai.error("no dependencies")}});window.LeaferUI=lr;
2
- //# sourceMappingURL=global.js.map
1
+ class t{constructor(t,e){this.bubbles=!1,this.type=t,e&&(this.target=e)}stopDefault(){this.isStopDefault=!0}stopNow(){this.isStopNow=!0,this.isStop=!0}stop(){this.isStop=!0}}class e extends t{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}e.ADD="child.add",e.REMOVE="child.remove";class s extends t{constructor(t,e,s,i,n){super(t,e),this.attrName=s,this.oldValue=i,this.newValue=n}}s.CHANGE="property.change";class i extends t{constructor(t,e,s,i,n,r){super(t,e),this.image=s,this.attrName=i,this.attrValue=n,r&&(this.error=r)}}i.LOADED="image.loaded",i.ERROR="image.error";class n extends t{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){const s="object"==typeof t;super(s?n.RESIZE:t),s&&Object.assign(this,t),this.old=e}}n.RESIZE="resize";class r extends t{constructor(t,e){super(t),e&&Object.assign(this,e)}}r.START="transform.start",r.CHANGE="transform.change",r.END="transform.end",r.BEFORE_START="transform.before_start",r.BEFORE_CHANGE="transform.before_change",r.BEFORE_END="transform.before_end";class o extends t{constructor(t,e){super(t),this.data=e}}o.REQUEST="watch.request",o.DATA="watch.data";class a extends t{constructor(t,e,s){super(t),e&&(this.data=e,this.times=s)}}a.CHECK_UPDATE="layout.check_update",a.REQUEST="layout.request",a.START="layout.start",a.BEFORE="layout.before",a.LAYOUT="layout.layout",a.AFTER="layout.after",a.AGAIN="layout.again",a.END="layout.end";class h extends t{constructor(t,e,s,i){super(t),e&&(this.times=e),s&&(this.renderBounds=s,this.renderOptions=i)}}h.REQUEST="render.request",h.START="render.start",h.BEFORE="render.before",h.RENDER="render",h.AFTER="render.after",h.AGAIN="render.again",h.END="render.end";class d extends t{}d.START="leafer.start",d.BEFORE_READY="leafer.before_ready",d.READY="leafer.ready",d.AFTER_READY="leafer.after_ready",d.VIEW_READY="leafer.view_ready",d.STOP="leafer.stop",d.RESTART="leafer.restart",d.END="leafer.end";class l{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.pushList(t):this.push(t))}has(t){return void 0!==this.keys[t.innerId]}indexAt(t){return this.list[t]}indexOf(t){const e=this.keys[t.innerId];return void 0===e?-1:e}pushList(t){t.forEach((t=>{this.push(t)}))}unshift(t){const{keys:e}=this;void 0===e[t.innerId]&&(this.list.unshift(t),Object.keys(e).forEach((t=>{void 0!==e[t]&&e[t]++})),e[t.innerId]=0)}push(t){const{list:e,keys:s}=this;void 0===s[t.innerId]&&(e.push(t),s[t.innerId]=e.length-1)}sort(t){const{list:e}=this;t?e.sort(((t,e)=>e.__level-t.__level)):e.sort(((t,e)=>t.__level-e.__level))}remove(t){const{list:e}=this;let s;for(let i=0,n=e.length;i<n;i++)void 0!==s?this.keys[e[i].innerId]=i-1:e[i].innerId===t.innerId&&(s=i,delete this.keys[t.innerId]);void 0!==s&&e.splice(s,1)}forEach(t){this.list.forEach(t)}clone(){const t=new l;return this.list.forEach((e=>{t.push(e)})),t}reset(){this.list=[],this.keys={}}destroy(){this.list=null}}class c{get length(){return this._length}constructor(t){this._length=0,this.reset(),t&&(t instanceof Array?this.pushList(t):this.push(t))}has(t){return void 0!==this.keys[t.innerId]}without(t){return void 0===this.keys[t.innerId]}sort(t){const{levels:e}=this;t?e.sort(((t,e)=>e-t)):e.sort(((t,e)=>t-e))}pushList(t){t.forEach((t=>{this.push(t)}))}push(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,i=e.length;s<i;s++)t(e[s])}))}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}}const u={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",types:{},create(t){const{types:e}=_;return e[t]?e[t]++:(e[t]=1,0)}},_=u,p={within:(t,e,s)=>(t<e&&(t=e),t>s&&(t=s),t),fourNumber(t){let e,s,i,n;if(t instanceof Array)switch(t.length){case 4:return t;case 2:e=i=t[0],s=n=t[1];break;case 3:e=t[0],s=n=t[1],i=t[2];break;case 1:t=t[0];break;default:t=0}return void 0===e?[t,t,t,t]:[e,s,i,n]}},g=Math.PI/180,f=2*Math.PI,y=Math.PI/2,{sin:m,cos:v,acos:w,atan:x,sqrt:B,PI:b}=Math,k={};function E(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const T={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},tempMatrix:{},set(t,e=1,s=0,i=0,n=1,r=0,o=0){t.a=e,t.b=s,t.c=i,t.d=n,t.e=r,t.f=o},get:E,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){t.e+=t.a*e+t.c*s,t.f+=t.b*e+t.d*s},scale(t,e,s=e){t.a*=e,t.d*=s,t.c*=e,t.b*=s},scaleOf(t,e,s,i=s){C.toInnerPoint(t,e,k),C.scaleOfInner(t,k,s,i)},scaleOfInner(t,e,s,i=s){C.translateInner(t,e.x,e.y),C.scale(t,s,i),C.translateInner(t,-e.x,-e.y)},rotate(t,e){const s=v(e*=g),i=m(e),{a:n,b:r,c:o,d:a}=t;t.a=n*s-r*i,t.b=n*i+r*s,t.c=o*s-a*i,t.d=o*i+a*s},rotateOf(t,e,s){C.toInnerPoint(t,e,k),C.rotateOfInner(t,k,s)},rotateOfInner(t,e,s){C.translateInner(t,e.x,e.y),C.rotate(t,s),C.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:i,b:n,c:r,d:o}=t;s&&(s*=g,t.a=i+r*s,t.b=n+o*s),e&&(e*=g,t.c=r+i*e,t.d=o+n*e)},skewOf(t,e,s,i){C.toInnerPoint(t,e,k),C.skewOfInner(t,k,s,i)},skewOfInner(t,e,s,i){C.translateInner(t,e.x,e.y),C.skew(t,s,i),C.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:i,c:n,d:r,e:o,f:a}=t;t.a=e.a*s+e.b*n,t.b=e.a*i+e.b*r,t.c=e.c*s+e.d*n,t.d=e.c*i+e.d*r,t.e=e.e*s+e.f*n+o,t.f=e.e*i+e.f*r+a},preMultiply(t,e){const{a:s,b:i,c:n,d:r,e:o,f:a}=t;1===e.a&&0===e.b&&0===e.c&&1===e.d||(t.a=s*e.a+i*e.c,t.b=s*e.b+i*e.d,t.c=n*e.a+r*e.c,t.d=n*e.b+r*e.d),t.e=o*e.a+a*e.c+e.e,t.f=o*e.b+a*e.d+e.f},divide(t,e){C.multiply(t,C.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=C;return C.copy(e,t),C.invert(e),e},invert(t){const{a:e,b:s,c:i,d:n,e:r,f:o}=t,a=1/(e*n-s*i);t.a=n*a,t.b=-s*a,t.c=-i*a,t.d=e*a,t.e=-(r*n-o*i)*a,t.f=-(o*e-r*s)*a},toOuterPoint(t,e,s,i){const{x:n,y:r}=e;s||(s=e),s.x=n*t.a+r*t.c,s.y=n*t.b+r*t.d,i||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,i){const{x:n,y:r}=e,{a:o,b:a,c:h,d:d}=t,l=1/(o*d-a*h);if(s||(s=e),s.x=(n*d-r*h)*l,s.y=(r*o-n*a)*l,!i){const{e:e,f:i}=t;s.x-=(e*d-i*h)*l,s.y-=(i*o-e*a)*l}},decompose(t){const{a:e,b:s,c:i,d:n}=t;let r=e,o=n,a=0,h=0,d=0;if(s||i){const t=e*n-s*i,l=e*i+s*n;if(s){const i=e*e+s*s;r=B(i),o=t/r;const n=e/r;a=s>0?w(n):-w(n),h=x(l/i)/g}else{const e=i*i+n*n;o=B(e),r=t/o;const s=i/o;a=b/2-(n>0?w(-s):-w(s)),d=x(l/e)/g}a/=g}return{x:t.e,y:t.f,scaleX:r,scaleY:o,rotation:a,skewX:h,skewY:d}},reset(t){C.set(t)}},C=T,{toInnerPoint:R,toOuterPoint:P}=T,{sin:L,cos:O,abs:S,sqrt:D,atan2:M}=Math,A={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},copy(t,e){t.x=e.x,t.y=e.y},rotate(t,e,s){s||(s=I.defaultPoint);const i=O(e*g),n=L(e*g),r=t.x-s.x,o=t.y-s.y;t.x=s.x+r*i-o*n,t.y=s.y+r*n-o*i},tempToInnerOf(t,e){const{tempPoint:s}=I;return I.copy(s,t),R(e,s,s),s},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:s}=I;return I.copy(s,t),I.toInnerRadiusPointOf(t,e,s),s},toInnerRadiusPointOf(t,e,s){s||(s=t),R(e,t,s),s.radiusX=t.radiusX/e.a,s.radiusY=t.radiusY/e.d},toInnerOf(t,e,s){R(e,t,s)},toOuterOf(t,e,s){P(e,t,s)},getCenter:(t,e)=>({x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}),getDistance(t,e){const s=S(e.x-t.x),i=S(e.y-t.y);return D(s*s+i*i)},getAngle:(t,e)=>I.getAtan2(t,e)/g,getAtan2:(t,e)=>M(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s){const i=I.getAtan2(t,e);return{x:t.x+O(i)*s,y:t.y+L(i)*s}},reset(t){I.reset(t)}},I=A;class W{constructor(t,e){"object"==typeof t?A.copy(this,t):A.set(this,t,e)}set(t,e){A.set(this,t,e)}copy(t){return A.copy(this,t),this}clone(){return new W(this)}rotate(t,e){return A.rotate(this,t,e),this}toInnerOf(t,e){return A.toInnerOf(this,t,e),this}toOuterOf(t,e){return A.toOuterOf(this,t,e),this}getCenter(t){return A.getCenter(this,t)}getDistance(t){return A.getDistance(this,t)}getAngle(t){return A.getAngle(this,t)}getAtan2(t){return A.getAtan2(this,t)}reset(){A.reset(this)}}class N{constructor(t,e,s,i,n,r){"object"==typeof t?T.copy(this,t):T.set(this,t,e,s,i,n,r)}set(t,e,s,i,n,r){T.set(this,t,e,s,i,n,r)}copy(t){return T.copy(this,t),this}clone(){return new N(this)}translate(t,e){return T.translate(this,t,e),this}translateInner(t,e){return T.translateInner(this,t,e),this}scale(t,e){return T.scale(this,t,e),this}scaleOf(t,e,s){return T.scaleOf(this,t,e,s),this}scaleOfInner(t,e,s){return T.scaleOfInner(this,t,e,s),this}rotate(t){return T.rotate(this,t),this}rotateOf(t,e){return T.rotateOf(this,t,e),this}rotateOfInner(t,e){return T.rotateOfInner(this,t,e),this}skew(t,e){return T.skew(this,t,e),this}skewOf(t,e,s){return T.skewOf(this,t,e,s),this}skewOfInner(t,e,s){return T.skewOfInner(this,t,e,s),this}multiply(t){return T.multiply(this,t),this}preMultiply(t){return T.preMultiply(this,t),this}divide(t){return T.divide(this,t),this}invert(){return T.invert(this),this}toOuterPoint(t,e){T.toOuterPoint(this,t,e)}toInnerPoint(t,e){T.toInnerPoint(this,t,e)}decompose(){return T.decompose(this)}reset(){T.reset(this)}}const F={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,i,n){z(t,e,s),z(t,e+i,s+n)},copy(t,e){t.minX=e.minX,t.minY=e.minY,t.maxX=e.maxX,t.maxY=e.maxY},add(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:z}=F,{tempPointBounds:H,setPoint:U,addPoint:Y,toBounds:j}=F,{toOuterPoint:X}=T;let V,G,K,q;const Q={},Z={},$={tempBounds:{},set(t,e=0,s=0,i=0,n=0){t.x=e,t.y=s,t.width=i,t.height=n},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s){J.set(t,e.x-s,e.y-s,e.width+2*s,e.height+2*s)},right:t=>t.x+t.width,bottom:t=>t.y+t.height,move(t,e,s){t.x+=e,t.y+=s},getByMove:(t,e,s)=>(t=Object.assign({},t),J.move(t,e,s),t),getOutOfBounds(t,e){const s=-(J.right(e)-t.x),i=-(J.bottom(e)-t.y),n=Object.assign(Object.assign({},t),{offsetX:s,offsetY:i});return J.move(n,-s,-i),n},scale(t,e){t.x*=e,t.y*=e,t.width*=e,t.height*=e},tempToOuterOf:(t,e)=>(J.copy(J.tempBounds,t),J.toOuterOf(J.tempBounds,e),J.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),J.toOuterOf(t,e),t),toOuterOf(t,e,s){s||(s=t),0===e.b&&0===e.c?(s.x=e.e+t.x*e.a,s.y=e.f+t.y*e.d,s.width=t.width*e.a,s.height=t.height*e.d):(Q.x=t.x,Q.y=t.y,X(e,Q,Z),U(H,Z.x,Z.y),Q.x=t.x+t.width,X(e,Q,Z),Y(H,Z.x,Z.y),Q.y=t.y+t.height,X(e,Q,Z),Y(H,Z.x,Z.y),Q.x=t.x,X(e,Q,Z),Y(H,Z.x,Z.y),j(H,s))},getFitMatrix(t,e){const s=Math.min(1,Math.min(t.width/e.width,t.height/e.height));return new N(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e){const s={};return J.copyAndSpread(s,t,e),s},spread(t,e){J.copyAndSpread(t,t,e)},ceil(t){t.x=Math.floor(t.x),t.y=Math.floor(t.y),t.width=Math.ceil(t.width),t.height=Math.ceil(t.height)},add(t,e){V=t.x+t.width,G=t.y+t.height,K=e.x+e.width,q=e.y+e.height,V=V>K?V:K,G=G>q?G:q,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=V-t.x,t.height=G-t.y},addList(t,e){J.setByListWithHandle(t,e,void 0,!0)},setByList(t,e,s=!1){J.setByListWithHandle(t,e,void 0,s)},addListWithHandle(t,e,s){J.setByListWithHandle(t,e,s,!0)},setByListWithHandle(t,e,s,i=!1){let n,r=!0;for(let o=0,a=e.length;o<a;o++)n=s?s(e[o]):e[o],n&&(n.width||n.height)&&(r?(r=!1,i||et(t,n)):tt(t,n));r&&J.reset(t)},setByPoints(t,e){e.forEach(((t,e)=>{0===e?U(H,t.x,t.y):Y(H,t.x,t.y)})),j(H,t)},hitRadiusPoint:(t,e,s)=>(s&&(e=A.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=A.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=J.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=J.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){s&&(e=J.tempToOuterOf(e,s));let{x:i,y:n,width:r,height:o}=e;return V=i+r,G=n+o,K=t.x+t.width,q=t.y+t.height,i=i>t.x?i:t.x,n=n>t.y?n:t.y,V=V<K?V:K,G=G<q?G:q,r=V-i,o=G-n,{x:i,y:n,width:r,height:o}},intersect(t,e,s){J.copy(t,J.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){J.set(t)}},J=$,{add:tt,copy:et}=J;class st{constructor(t,e,s,i){"object"==typeof t?$.copy(this,t):$.set(this,t,e,s,i)}set(t,e,s,i){$.set(this,t,e,s,i)}copy(t){return $.copy(this,t),this}clone(){return new st(this)}scale(t){return $.scale(this,t),this}toOuterOf(t,e){return $.toOuterOf(this,t,e),this}getFitMatrix(t){return $.getFitMatrix(this,t)}spread(t){return $.spread(this,t),this}ceil(){return $.ceil(this),this}add(t){return $.add(this,t),this}addList(t){return $.setByList(this,t,!0),this}setByList(t,e){return $.setByList(this,t,e),this}addListWithHandle(t,e){return $.setByListWithHandle(this,t,e,!0),this}setByListWithHandle(t,e,s){return $.setByListWithHandle(this,t,e,s),this}setByPoints(t){return $.setByPoints(this,t),this}hitPoint(t,e){return $.hitPoint(this,t,e)}hitRadiusPoint(t,e){return $.hitRadiusPoint(this,t,e)}hit(t,e){return $.hit(this,t,e)}includes(t,e){return $.includes(this,t,e)}intersect(t,e){return $.intersect(this,t,e),this}getIntersect(t,e){return new st($.getIntersectData(this,t,e))}isSame(t){return $.isSame(this,t)}isEmpty(){return $.isEmpty(this)}reset(){$.reset(this)}}class it{constructor(t,e,s,i,n,r){"object"==typeof t?this.copy(t):this.set(t,e,s,i,n,r)}set(t=0,e=0,s=0,i=0,n=0,r=0){this.top=t,this.right=e,this.bottom=s,this.left=i,this.width=n,this.height=r}copy(t){const{top:e,right:s,bottom:i,left:n,width:r,height:o}=t;this.set(e,s,i,n,r,o)}getBoundsFrom(t){const{top:e,right:s,bottom:i,left:n,width:r,height:o}=this;return new st(n,e,r||t.width-n-s,o||t.height-e-i)}}const nt={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},rt={updateAllWorldMatrix(t){if(t.__updateWorldMatrix(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)at(e[t])}},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)ht(e[t])}},updateAllChange(t){if(ht(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)dt(e[t])}},move(t,e,s){const i={x:e,y:s};t.parent&&T.toInnerPoint(t.parent.__world,i,i,!0),ot.moveLocal(t,i.x,i.y)},moveLocal(t,e,s){t.x=t.__.x+e,t.y=t.__.y+s},zoomOf(t,e,s,i,n){const r=t.parent?A.tempToInnerOf(e,t.parent.__world):e;this.zoomOfLocal(t,r,s,i,n)},zoomOfLocal(t,e,s,i,n){i||(i=s),n||(n=t);const{x:r,y:o}=n.__,a=(new N).translate(r,o).scaleOf(e,s,i);n.x=a.e,n.y=a.f,t.scaleX=t.__.scaleX*s,t.scaleY=t.__.scaleY*i},rotateOf(t,e,s,i){const n=t.parent?A.tempToInnerOf(e,t.parent.__world):e;this.rotateOfLocal(t,n,s,i)},rotateOfLocal(t,e,s,i){i||(i=t);const{x:n,y:r}=i.__,o=(new N).translate(n,r).rotateOf(e,s);i.x=o.e,i.y=o.f,t.rotation=t.__.rotation+s},drop(t,e){const s={x:t.x,y:t.y};t.localToWorld(s),e.worldToInner(s),t.set(s),e.add(t)}},ot=rt,{updateAllWorldMatrix:at,updateAllWorldOpacity:ht,updateAllChange:dt}=ot,lt={worldBounds:t=>t.__world,localBoxBounds:t=>t.__local,localEventBounds:t=>t.__layout.localStrokeBounds,localRenderBounds:t=>t.__layout.localRenderBounds,maskLocalBoxBounds:t=>t.isMask?t.__local:null,maskLocalEventBounds:t=>t.isMask?t.__layout.localStrokeBounds:null,maskLocalRenderBounds:t=>t.isMask?t.__layout.localRenderBounds:null},ct={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 i=0,n=s.length;i<n;i++)(t=s[i]).isBranch&&(t.__tempNumber=1,e.push(t),ut(t,e))}},pushAllParent(t,e){const{keys:s}=e;if(s)for(;t.parent&&void 0===s[t.parent.innerId];)e.push(t.parent),t=t.parent;else for(;t.parent;)e.push(t.parent),t=t.parent},pushAllBranchStack(t,e){let s=e.length;const{children:i}=t;for(let t=0,s=i.length;t<s;t++)i[t].isBranch&&e.push(i[t]);for(let t=s,i=e.length;t<i;t++)_t(e[t],e)},updateWorldBoundsByBranchStack(t){let e;for(let s=t.length-1;s>-1;s--){e=t[s];for(let t=0,s=e.children.length;t<s;t++)e.children[t].__updateWorldBounds()}e.__updateWorldBounds()}},{pushAllChildBranch:ut,pushAllBranchStack:_t}=ct,pt={run(t){for(let e=0,s=t.length;e<s;e++)t[e]();t.length=0}},gt={default:(t,e)=>(ft(e,t),ft(t,e),t),assign(t,e){let s;Object.keys(e).forEach((i=>{var n;s=e[i],(null==s?void 0:s.constructor)===Object&&(null===(n=t[i])||void 0===n?void 0:n.constructor)===Object?ft(t[i],e[i]):t[i]=e[i]}))},copyAttrs:(t,e,s)=>(s.forEach((s=>{void 0!==e[s]&&(t[s]=e[s])})),t),clone:t=>JSON.parse(JSON.stringify(t))},{assign:ft}=gt;class yt{constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];return void 0===e?this[t]:e}return this[t]}__setInput(t,e){this.__input||(this.__input={}),this.__input[t]=e}__getInput(t){if(this.__input){const e=this.__input[t];return void 0===e?this["_"+t]:e}return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(){const t={},{__input:e}=this;let s,i;for(let n in this)s=n.substring(1),void 0!==this[s]&&(i=e?e[s]:void 0,t[s]=void 0===i?this[n]:i);return t}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}destroy(){this.__leaf=null}}class mt{constructor(t){this.name=t}static get(t){return new mt(t)}static set filter(t){t?"string"==typeof t&&(t=[t]):t=[],this.filterList=t}static set exclude(t){t?"string"==typeof t&&(t=[t]):t=[],this.excludeList=t}log(...t){if(vt.enable){if(vt.filterList.length&&vt.filterList.every((t=>t!==this.name)))return;if(vt.excludeList.length&&vt.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}warn(...t){console.warn(this.name,...t)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}mt.filterList=[],mt.excludeList=[];const vt=mt,wt=mt.get("RunTime");class xt{static start(t,e){const s=u.create(u.RUNTIME);return Bt.currentId=Bt.idMap[s]=e?performance.now():Date.now(),Bt.currentName=Bt.nameMap[s]=t,Bt.nameToIdMap[t]=s,s}static end(t,e){const s=Bt.idMap[t],i=Bt.nameMap[t];Bt.idMap[t]=Bt.nameMap[t]=Bt.nameToIdMap[i]=void 0,e?wt.log(i,performance.now()-s,"µs"):wt.log(i,Date.now()-s,"ms")}static endOfName(t,e){const s=Bt.nameToIdMap[t];void 0!==s&&Bt.end(s,e)}}xt.idMap={},xt.nameMap={},xt.nameToIdMap={};const Bt=xt,{updateAllWorldMatrix:bt,updateAllWorldOpacity:kt}=rt,{pushAllChildBranch:Et,pushAllParent:Tt}=ct;const{worldBounds:Ct}=lt,{setByListWithHandle:Rt}=$;class Pt{constructor(t){this.updatedBounds=new st,this.beforeBounds=new st,this.afterBounds=new st,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){Rt(this.beforeBounds,this.updatedList.list,Ct)}setAfter(){Rt(this.afterBounds,this.updatedList.list,Ct),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:Lt,updateAllChange:Ot}=rt,{pushAllBranchStack:St,updateWorldBoundsByBranchStack:Dt}=ct,Mt=mt.get("Layouter");class At{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new c,this.target=t,e&&(this.config=gt.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(a.START),this.layoutOnce(),t.emitEvent(new a(a.END,this.layoutedBlocks,this.times))}catch(t){Mt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Mt.warn("layouting"):this.times>3?Mt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(o.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updateList)||void 0===t?void 0:t.length))return;const e=xt.start("PartLayout"),{target:s,__updateList:i}=this,{BEFORE:n,LAYOUT:r,AFTER:o}=a,h=this.getBlocks(i);h.forEach((t=>{t.setBefore()})),s.emitEvent(new a(n,h,this.times)),i.sort(),function(t,e){let s;t.list.forEach((t=>{s=t.__layout,e.without(t)&&!s.useZoomProxy&&(s.matrixChanged?(bt(t),e.push(t),t.isBranch&&Et(t,e),Tt(t,e)):s.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),Tt(t,e)))}))}(i,this.__levelList),function(t){let e,s;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(s=e[t],s.isBranch&&s.__tempNumber)for(let t=0,e=s.children.length;t<e;t++)s.children[t].isBranch||s.children[t].__updateWorldBounds();s.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&kt(t),t.__updateChange()}))}(i),h.forEach((t=>t.setAfter())),s.emitEvent(new a(r,h,this.times)),s.emitEvent(new a(o,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updateList=null,xt.end(e)}fullLayout(){const t=xt.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:i,AFTER:n}=a,r=this.getBlocks(new l(e));e.emitEvent(new a(s,r,this.times)),At.fullLayout(e),r.forEach((t=>{t.setAfter()})),e.emitEvent(new a(i,r,this.times)),e.emitEvent(new a(n,r,this.times)),this.addBlocks(r),xt.end(t)}static fullLayout(t){if(Lt(t),t.isBranch){const e=[t];St(t,e),Dt(e)}else t.__updateWorldBounds();Ot(t)}createBlock(t){return new Pt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updateList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(a.REQUEST,this.layout,this),t.on__(a.AGAIN,this.layoutAgain,this),t.on__(o.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const It={layout:At.fullLayout},Wt={},Nt=mt.get("UICreator"),Ft={list:{},register(t){const{__tag:e}=t.prototype;zt[e]?Nt.error("repeat:",e):zt[e]=t},get(t,e,s,i,n,r){const o=new zt[t](e);return void 0!==s&&(o.x=s,i&&(o.y=i),n&&(o.width=n),r&&(o.height=r)),o}},{list:zt}=Ft,Ht=mt.get("EventCreator"),Ut={nameList:{},register(t){let e;Object.keys(t).forEach((s=>{e=t[s],"string"==typeof e&&(Yt[e]?Ht.error("repeat: ",e):Yt[e]=t)}))},changeName(t,e){const s=Yt[t];if(s){const i=Object.keys(s).find((e=>s[e]===t));i&&(s[i]=e,Yt[e]=s)}},get:(t,...e)=>new Yt[t](...e)},{nameList:Yt}=Ut;class jt{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let e;const{list:s}=this;for(let i=0,n=s.length;i<n;i++)if(e=s[i],e.recycled&&e.isSameSize(t))return e.recycled=!1,e.manager||(e.manager=this),e;const i=Wt.canvas(t);return this.add(i),i}recycle(t){t.recycled||(t.clear(),t.recycled=!0)}clearRecycled(){let t;const e=[];for(let s=0,i=this.list.length;s<i;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}destory(){this.clear()}}class Xt extends jt{constructor(){super(...arguments),this.pathTypeList=new l,this.imageTypeList=new l}get(t){}getImageType(t,e){return this.imageTypeList.push(t),Wt.hitCanvas(e)}getPathType(t){return this.pathTypeList.push(t),Wt.hitCanvas()}clearImageType(){this.__clearLeafList(this.imageTypeList)}clearPathType(){this.__clearLeafList(this.pathTypeList)}__clearLeafList(t){t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset()}clear(){this.clearPathType(),this.clearImageType()}}function Vt(t,e,s,i){var n,r=arguments.length,o=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,s,o):n(e,s))||o);return r>3&&o&&Object.defineProperty(e,s,o),o}function Gt(t,e,s,i){return new(s||(s=Promise))((function(n,r){function o(t){try{h(i.next(t))}catch(t){r(t)}}function a(t){try{h(i.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}h((i=i.apply(t,e||[])).next())}))}function Kt(t){return(e,s)=>{t||(t=s);const i={get(){return this.context[t]},set(e){this.context[t]=e}};Object.defineProperty(e,s,i)}}const qt=[];function Qt(){return(t,e)=>{qt.push(e)}}const Zt=[];let $t=class{set dashPattern(t){this.context.setLineDash(t||Zt)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;qt.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))}))}setTransform(t,e,s,i,n,r){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,i,n,r){}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,s,i){}strokeRect(t,e,s,i){}clearRect(t,e,s,i){}drawImage(t,e,s,i,n,r,o,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/i*a;i+=e,e=0,r+=t,a-=t}if(s<0){const t=-s/n*h;n+=s,s=0,o+=t,h-=t}this.context.drawImage(t,e,s,i,n,r,o,a,h);break;case 5:this.context.drawImage(t,e,s,i,n);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,i,n,r){}quadraticCurveTo(t,e,s,i){}closePath(){}arc(t,e,s,i,n,r){}arcTo(t,e,s,i,n){}ellipse(t,e,s,i,n,r,o,a){}rect(t,e,s,i){}roundRect(t,e,s,i,n){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,i){}createPattern(t,e){}createRadialGradient(t,e,s,i,n,r){}fillText(t,e,s,i){}measureText(t){}strokeText(t,e,s,i){}destroy(){this.context=null}};Vt([Kt("imageSmoothingEnabled")],$t.prototype,"smooth",void 0),Vt([Kt("imageSmoothingQuality")],$t.prototype,"smoothLevel",void 0),Vt([Kt("globalAlpha")],$t.prototype,"opacity",void 0),Vt([Kt("globalCompositeOperation")],$t.prototype,"blendMode",void 0),Vt([Kt()],$t.prototype,"fillStyle",void 0),Vt([Kt()],$t.prototype,"strokeStyle",void 0),Vt([Kt("lineWidth")],$t.prototype,"strokeWidth",void 0),Vt([Kt("lineCap")],$t.prototype,"strokeCap",void 0),Vt([Kt("lineJoin")],$t.prototype,"strokeJoin",void 0),Vt([Kt("lineDashOffset")],$t.prototype,"dashOffset",void 0),Vt([Kt()],$t.prototype,"miterLimit",void 0),Vt([Kt()],$t.prototype,"shadowBlur",void 0),Vt([Kt()],$t.prototype,"shadowColor",void 0),Vt([Kt()],$t.prototype,"shadowOffsetX",void 0),Vt([Kt()],$t.prototype,"shadowOffsetY",void 0),Vt([Kt()],$t.prototype,"filter",void 0),Vt([Kt()],$t.prototype,"font",void 0),Vt([Kt()],$t.prototype,"fontKerning",void 0),Vt([Kt()],$t.prototype,"fontStretch",void 0),Vt([Kt()],$t.prototype,"fontVariantCaps",void 0),Vt([Kt()],$t.prototype,"textAlign",void 0),Vt([Kt()],$t.prototype,"textBaseline",void 0),Vt([Kt()],$t.prototype,"textRendering",void 0),Vt([Kt()],$t.prototype,"wordSpacing",void 0),Vt([Kt()],$t.prototype,"letterSpacing",void 0),Vt([Kt()],$t.prototype,"direction",void 0),Vt([Qt()],$t.prototype,"setTransform",null),Vt([Qt()],$t.prototype,"resetTransform",null),Vt([Qt()],$t.prototype,"getTransform",null),Vt([Qt()],$t.prototype,"save",null),Vt([Qt()],$t.prototype,"restore",null),Vt([Qt()],$t.prototype,"transform",null),Vt([Qt()],$t.prototype,"translate",null),Vt([Qt()],$t.prototype,"scale",null),Vt([Qt()],$t.prototype,"rotate",null),Vt([Qt()],$t.prototype,"fill",null),Vt([Qt()],$t.prototype,"stroke",null),Vt([Qt()],$t.prototype,"clip",null),Vt([Qt()],$t.prototype,"fillRect",null),Vt([Qt()],$t.prototype,"strokeRect",null),Vt([Qt()],$t.prototype,"clearRect",null),Vt([Qt()],$t.prototype,"beginPath",null),Vt([Qt()],$t.prototype,"moveTo",null),Vt([Qt()],$t.prototype,"lineTo",null),Vt([Qt()],$t.prototype,"bezierCurveTo",null),Vt([Qt()],$t.prototype,"quadraticCurveTo",null),Vt([Qt()],$t.prototype,"closePath",null),Vt([Qt()],$t.prototype,"arc",null),Vt([Qt()],$t.prototype,"arcTo",null),Vt([Qt()],$t.prototype,"ellipse",null),Vt([Qt()],$t.prototype,"rect",null),Vt([Qt()],$t.prototype,"roundRect",null),Vt([Qt()],$t.prototype,"createConicGradient",null),Vt([Qt()],$t.prototype,"createLinearGradient",null),Vt([Qt()],$t.prototype,"createPattern",null),Vt([Qt()],$t.prototype,"createRadialGradient",null),Vt([Qt()],$t.prototype,"fillText",null),Vt([Qt()],$t.prototype,"measureText",null),Vt([Qt()],$t.prototype,"strokeText",null);const Jt=new st,te={width:1,height:1,pixelRatio:1},ee=["width","height","pixelRatio"];class se extends $t{get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView&&!this.offscreen}constructor(t,e){super(),t||(t=te),t.pixelRatio||(t.pixelRatio=devicePixelRatio),this.manager=e,this.innerId=u.create(u.CNAVAS);const{width:s,height:i,pixelRatio:n}=t;this.autoLayout=!s||!i,this.pixelRatio=n,this.offscreen=It.isWorker||t.offscreen,this.config=t,this.init(),this.textBaseline="alphabetic"}init(){}setBackgroundColor(t){}setHittable(t){}resize(t){const{width:e,height:s}=t;if(this.isSameSize(t))return;let i;this.context&&!this.unreal&&this.width&&(i=this.getSameCanvas(),i.copyWorld(this)),gt.copyAttrs(this,t,ee),this.bounds=new st(0,0,e,s),this.unreal||(this.setViewSize(t),this.smooth=this.config.smooth),this.context&&!this.unreal&&i&&(this.clearWorld(i.bounds),this.copyWorld(i),i.recycle())}setViewSize(t){}startAutoLayout(t,e){}stopAutoLayout(){}setWorld(t,e,s){const{pixelRatio:i}=this;if(e)if(s)this.setTransform(t.a*i,t.b*i,t.c*i,t.d*i,(t.e+e.e)*i,(t.f+e.f)*i);else{const{a:s,b:n,c:r,d:o,e:a,f:h}=e;this.setTransform((t.a*s+t.b*r)*i,(t.a*n+t.b*o)*i,(t.c*s+t.d*r)*i,(t.c*n+t.d*o)*i,(t.e*s+t.f*r+a)*i,(t.e*n+t.f*o+h)*i)}else this.setTransform(t.a*i,t.b*i,t.c*i,t.d*i,t.e*i,t.f*i)}useSameTransform(t){this.setTransform(t.getTransform())}setStroke(t,e,s){e&&(this.strokeWidth=e),t&&(this.strokeStyle=t),s&&this.setStrokeOptions(s)}setStrokeOptions(t){this.strokeCap=t.strokeCap,this.strokeJoin=t.strokeJoin,this.dashPattern=t.dashPattern,this.dashOffset=t.dashOffset,this.miterLimit=t.miterLimit}saveBlendMode(t){this.savedblendMode=this.blendMode,this.blendMode=t}restoreBlendMode(){this.blendMode=this.savedblendMode}hitFill(t,e){return this.context.isPointInPath(t.x,t.y,e)}hitStroke(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)}setWorldShadow(t,e,s,i){const{pixelRatio:n}=this;this.shadowOffsetX=t*n,this.shadowOffsetY=e*n,this.shadowBlur=s*n,this.shadowColor=i||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,s,i){if(i&&(this.blendMode=i),e){const{pixelRatio:i}=this;s||(s=e),this.drawImage(t.view,e.x*i,e.y*i,e.width*i,e.height*i,s.x*i,s.y*i,s.width*i,s.height*i)}else this.drawImage(t.view,0,0);i&&(this.blendMode="normal")}copyWorldToInner(t,e,s,i){if(i&&(this.blendMode=i),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,$.tempToOuterOf(s,e)),this.restore();else{const{pixelRatio:i}=this;this.drawImage(t.view,e.x*i,e.y*i,e.width*i,e.height*i,s.x,s.y,s.width,s.height)}i&&(this.blendMode="normal")}useMask(t,e,s){this.copyWorld(t,e,s,"destination-in")}fillWorld(t,e,s){s&&(this.blendMode=s),this.fillStyle=e,Jt.copy(t).scale(this.pixelRatio),this.fillRect(Jt.x,Jt.y,Jt.width,Jt.height),s&&(this.blendMode="normal")}strokeWorld(t,e,s){s&&(this.blendMode=s),this.strokeStyle=e,Jt.copy(t).scale(this.pixelRatio),this.strokeRect(Jt.x,Jt.y,Jt.width,Jt.height),s&&(this.blendMode="normal")}clearWorld(t,e){Jt.copy(t).scale(this.pixelRatio),e&&Jt.ceil(),this.clearRect(Jt.x,Jt.y,Jt.width,Jt.height)}clipWorld(t,e){this.beginPath(),Jt.copy(t).scale(this.pixelRatio),e&&Jt.ceil(),this.rect(Jt.x,Jt.y,Jt.width,Jt.height),this.clip()}clear(){const{pixelRatio:t}=this;this.clearRect(0,0,this.width*t,this.height*t)}isSameSize(t){return this.width===t.width&&this.height===t.height&&this.pixelRatio===t.pixelRatio}getSameCanvas(t){const{width:e,height:s,pixelRatio:i}=this,n={width:e,height:s,pixelRatio:i},r=this.manager?this.manager.get(n):Wt.canvas(n);return r.save(),t&&r.useSameTransform(this),r}getBiggerCanvas(t,e){let{width:s,height:i,pixelRatio:n}=this;t&&(s+=t),e&&(i+=e);const r={width:s,height:i,pixelRatio:n},o=this.manager?this.manager.get(r):Wt.canvas(r);return o.save(),o}recycle(){this.restore(),this.manager?this.manager.recycle(this):this.destroy()}unrealCanvas(){}destroy(){this.manager=null,this.view=null,this.parentView=null,this.context=null,this.config=null}}function ie(t,e,s){Object.defineProperty(t,e,s)}function ne(t,e){return Object.getOwnPropertyDescriptor(t,e)}function re(t,e,s,i){const n={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)},configurable:!0,enumerable:!0};ie(t,e,Object.assign(n,i||{})),xe(t,e,s)}function oe(t){return(e,s)=>{re(e,s,t)}}function ae(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.positionChanged||this.__layout.positionChange()}})}}function he(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.scaleChanged||this.__layout.scaleChange()}})}}function de(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.rotationChanged||this.__layout.rotationChange()}})}}function le(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxBoundsChanged||this.__layout.boxBoundsChange()}})}}const ce=le;function ue(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.strokeBoundsChanged||this.__layout.strokeBoundsChange()}})}}const _e=ue;function pe(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.renderBoundsChanged||this.__layout.renderBoundsChange()}})}}function ge(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange()}})}}function fe(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.opacityChanged||this.__layout.opacityChange()}})}}function ye(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.parent?this.parent.__layout.childrenSortChanged=!0:this.waitParent((()=>{this.parent.__layout.childrenSortChanged=!0}))}})}}function me(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxBoundsChanged||this.__layout.boxBoundsChange(),this.parent?this.parent.__updateMask(t):this.waitParent((()=>{this.parent.__updateMask(t)}))}})}}function ve(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),mt.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange())}})}}function we(t){return(e,s)=>{ie(e,"__DataProcessor",{get:()=>t})}}function xe(t,e,s){const i=t.__DataProcessor.prototype,n="_"+e,r=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),o={get(){const t=this[n];return void 0===t?s:t},set(t){this[n]=t},configurable:!0,enumerable:!0};void 0===s&&(o.get=function(){return this[n]});const a=ne(i,e);a&&a.set&&(o.set=a.set),i[r]&&(o.set=i[r],delete i[r]),Object.defineProperty(i,e,o)}const Be=new mt("rewrite"),be=[],ke=["destroy","constructor"];function Ee(t){return(e,s)=>{be.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}}function Te(){return t=>{Ce()}}function Ce(t){be.length&&(be.forEach((e=>{t&&Be.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),be.length=0)}function Re(t,e){return s=>{var i;(t.prototype?(i=t.prototype,Object.getOwnPropertyNames(i)):Object.keys(t)).forEach((i=>{if(!(ke.includes(i)||e&&e.includes(i)))if(t.prototype){ne(t.prototype,i).writable&&(s.prototype[i]=t.prototype[i])}else s.prototype[i]=t[i]}))}}function Pe(){return t=>{Ft.register(t)}}function Le(){return t=>{Ut.register(t)}}setTimeout((()=>Ce(!0)));const{toOuterOf:Oe}=$;class Se{constructor(t){this.leaf=t,this.renderBounds=this.strokeBounds=this.boxBounds={x:0,y:0,width:0,height:0},this.localRenderBounds=this.localStrokeBounds=t.__local,this.boxBoundsChange()}checkUpdate(){const{leafer:t}=this.leaf;if(t)t.ready?t.watcher.changed&&t.layouter.layout():(t.start(),t.layouter.layout());else{let t=this.leaf;for(;t.parent;)t=t.parent;It.layout(t)}}getTransform(t){return this.checkUpdate(),"world"===t?this.leaf.__world:this.leaf.__local}getMatrixDecompositionData(t){return this.checkUpdate(),T.decompose("world"===t?this.leaf.__world:this.leaf.__local)}getBounds(t,e){if(this.checkUpdate(),"world"===e)switch(t){case"render":return this.leaf.__world;case"content":if(this.contentBounds)return this.getWorldContentBounds();case"margin":case"box":return this.getWorldBoxBounds();case"margin":case"stroke":return this.getWorldStrokeBounds()}else if("inner"===e)switch(t){case"render":return this.renderBounds;case"content":if(this.contentBounds)return this.contentBounds;case"margin":case"box":return this.boxBounds;case"stroke":return this.strokeBounds}else switch(t){case"render":return this.localRenderBounds;case"margin":case"content":case"box":return this.leaf.__local;case"stroke":return this.localStrokeBounds}}getWorldContentBounds(){return this._worldContentBounds||(this._worldContentBounds={}),Oe(this.contentBounds,this.leaf.__world,this._worldContentBounds),this._worldContentBounds}getWorldBoxBounds(){return this._worldBoxBounds||(this._worldBoxBounds={}),Oe(this.boxBounds,this.leaf.__world,this._worldBoxBounds),this._worldBoxBounds}getWorldStrokeBounds(){return this._worldStrokeBounds||(this._worldStrokeBounds={}),Oe(this.strokeBounds,this.leaf.__world,this._worldStrokeBounds),this._worldStrokeBounds}strokeBoundsSpreadCancel(){const t=this.renderBounds===this.strokeBounds;this.strokeBounds=this.boxBounds,this.localStrokeBounds=this.leaf.__local,t&&this.renderBoundsSpreadCancel()}renderBoundsSpreadCancel(){this.renderBounds=this.strokeBounds,this.localRenderBounds=this.localStrokeBounds}strokeBoundsSpread(){const{x:t,y:e,width:s,height:i}=this.strokeBounds;this.strokeBounds={x:t,y:e,width:s,height:i},this.localStrokeBounds={x:t,y:e,width:s,height:i},this.renderBoundsSpreadWidth||this.renderBoundsSpreadCancel()}renderBoundsSpread(){const{x:t,y:e,width:s,height:i}=this.renderBounds;this.renderBounds={x:t,y:e,width:s,height:i},this.localRenderBounds={x:t,y:e,width:s,height:i}}boxBoundsChange(){this.boxBoundsChanged=!0,this.localBoxBoundsChanged||this.localBoxBoundsChange(),this.hitCanvasChanged=!0}localBoxBoundsChange(){this.localBoxBoundsChanged=!0,this.boundsChanged=!0}strokeBoundsChange(){this.strokeBoundsChanged=!0,this.strokeBoundsSpreadWidth||(this.strokeBoundsSpreadWidth=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderBoundsChange(){this.renderBoundsChanged=!0,this.renderBoundsSpreadWidth||(this.renderBoundsSpreadWidth=1),this.boundsChanged=!0}positionChange(){this.positionChanged=!0,this.matrixChanged=!0,this.localBoxBoundsChanged||this.localBoxBoundsChange()}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChanged=!0,this.localBoxBoundsChanged||this.localBoxBoundsChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}destroy(){this.leaf=null}}const De={},Me={on(t,e,s){let i,n,r;if(s){const t="boolean"==typeof s;i=t?s:s.capture,n=!t&&s.once}const o=Ae(this,i,!0),a="string"==typeof t?t.split(" "):t,h=n?{listener:e,once:n}:{listener:e};a.forEach((t=>{t&&(r=o[t],r?-1===r.findIndex((t=>t.listener===e))&&r.push(h):o[t]=[h])}))},off(t,e,s){let i,n,r;s&&(i="boolean"==typeof s?s:s.capture);const o=Ae(this,i);("string"==typeof t?t.split(" "):t).forEach((t=>{t&&(n=o[t],n&&(r=n.findIndex((t=>t.listener===e)),r>-1&&n.splice(r,1),n.length||delete o[t]))}))},on__(t,e,s,i){return s&&(e=e.bind(s)),this.on(t,e,i),{type:t,listener:e,options:i}},off__(t){if(!t)return;const e=t instanceof Array?t:[t];e.forEach((t=>{this.off(t.type,t.listener,t.options)})),e.length=0},once(t,e,s){this.on(t,e,{once:!0,capture:s})},emit(t,e,s){const i=Ae(this,s)[t];if(i){let n;for(let r=0,o=i.length;r<o&&(n=i[r],n.listener(e),n.once&&(this.off(t,n.listener,s),r--,o--),!e||!e.isStopNow);r++);}},emitEvent(t,e){t.current=this,this.emit(t.type,t,e)},hasEvent(t,e){const{__bubbleMap:s,__captureMap:i}=this;return void 0===e?!!(i&&i[t]||s&&s[t]):!!(e?i&&i[t]:s&&s[t])}};function Ae(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:De)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:De)}}const Ie={__setAttr(t,e){if(this.leafer&&this.leafer.ready){this.__[t]=e;const{CHANGE:i}=s,n=new s(i,this,t,this.__.__get(t),e);this.hasEvent(i)&&!this.isLeafer&&this.emitEvent(n),this.leafer.emitEvent(n)}else this.__[t]=e},__getAttr(t){return this.__.__get(t)}},{defaultMatrix:We}=T,{sin:Ne,cos:Fe}=Math,ze={__updateWorldMatrix(){const t=this.parent?this.parent.__world:We,e=this.__local,s=this.__world;this.__layout.matrixChanged&&this.__updateLocalMatrix(),this.__layout.affectScaleOrRotation?(s.a=e.a*t.a+e.b*t.c,s.b=e.a*t.b+e.b*t.d,s.c=e.c*t.a+e.d*t.c,s.d=e.c*t.b+e.d*t.d,s.e=e.e*t.a+e.f*t.c+t.e,s.f=e.e*t.b+e.f*t.d+t.f):(s.a=t.a,s.b=t.b,s.c=t.c,s.d=t.d,s.e=e.e*t.a+e.f*t.c+t.e,s.f=e.e*t.b+e.f*t.d+t.f)},__updateLocalMatrix(){const t=this.__local,e=this.__layout;if(e.affectScaleOrRotation){const{scaleX:s,scaleY:i}=this.__;if(e.affectRotation){if(e.scaleChanged||e.rotationChanged){let{rotation:n,skewX:r,skewY:o}=this.__;n||r||o?(n*=g,r&&(r*=g),o&&(o*=g),t.a=s*Fe(n+o),t.b=s*Ne(n+o),t.c=i*-Ne(n-r),t.d=i*Fe(n-r)):(t.a=s,t.b=0,t.c=0,t.d=i,e.affectRotation=!1),e.scaleChanged=!1,e.rotationChanged=!1}}else e.scaleChanged&&(t.a=s,t.d=i,e.scaleChanged=!1)}e.positionChanged&&(t.e=this.__.x,t.f=this.__.y,e.positionChanged=!1),this.__layout.matrixChanged=!1}},{toOuterOf:He,copyAndSpread:Ue}=$,Ye={__updateWorldBounds(){var t;if(this.__layout.boundsChanged){let e;const s=this.__layout;s.boxBoundsChanged&&(this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),s.boxBoundsChanged=!1,e=!0),s.localBoxBoundsChanged&&(this.__updateLocalBoxBounds(),s.localBoxBoundsChanged=!1,s.strokeBoundsSpreadWidth&&(s.strokeBoundsChanged=!0),s.renderBoundsSpreadWidth&&(s.renderBoundsChanged=!0),null===(t=this.parent)||void 0===t||t.__layout.boxBoundsChange()),s.strokeBoundsChanged&&(s.strokeBoundsSpreadWidth=this.__updateStrokeBoundsSpreadWidth(),s.strokeBoundsSpreadWidth?(s.strokeBounds===s.boxBounds&&s.strokeBoundsSpread(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):s.strokeBoundsSpreadCancel(),s.strokeBoundsChanged=!1,s.renderBoundsSpreadWidth&&(s.renderBoundsChanged=!0),this.parent&&this.parent.__layout.strokeBoundsChange(),e||(e=!0)),s.renderBoundsChanged&&(s.renderBoundsSpreadWidth=this.__updateRenderBoundsSpreadWidth(),s.renderBoundsSpreadWidth?(s.renderBounds!==s.boxBounds&&s.renderBounds!==s.strokeBounds||s.renderBoundsSpread(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):s.renderBoundsSpreadCancel(),s.renderBoundsChanged=!1,this.parent&&this.parent.__layout.renderBoundsChange()),s.boundsChanged=!1,He(this.__layout.renderBounds,this.__world,this.__world),e&&this.__onUpdateSize()}else He(this.__layout.renderBounds,this.__world,this.__world)},__updateLocalBoxBounds(){He(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){He(this.__layout.strokeBounds,this.__local,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){He(this.__layout.renderBounds,this.__local,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds;t.x=0,t.y=0,t.width=this.__.width,t.height=this.__.height},__updateStrokeBounds(){Ue(this.__layout.strokeBounds,this.__layout.boxBounds,this.__layout.strokeBoundsSpreadWidth)},__updateRenderBounds(){Ue(this.__layout.renderBounds,this.__layout.strokeBounds,this.__layout.renderBoundsSpreadWidth)}},{toInnerRadiusPointOf:je}=A,Xe={},Ve={__hitWorld(t){return this.__layout.hitCanvasChanged&&(this.__updateHitCanvas(),this.__layout.hitCanvasChanged=!1),je(t,this.__world,Xe),this.__hit(Xe)},__drawHitPath(t){this.__drawRenderPath(t)}},Ge={__render(t,e){this.__worldOpacity&&(t.setWorld(this.__world,e.matrix),t.opacity=this.__worldOpacity,this.__draw(t,e))},__updateWorldOpacity(){this.__worldOpacity=this.__.visible?this.parent?this.parent.__worldOpacity*this.__.opacity:this.__.opacity:0,this.__layout.opacityChanged&&(this.__layout.opacityChanged=!1)}},Ke={__updateMask(t){this.__hasMask=!!t||this.children.some((t=>t.__.isMask))},__renderMask(t,e,s){e.resetTransform(),e.useMask(s),t.resetTransform(),t.copyWorld(e)},__removeMask(t){if(t)t.isMask=!1,this.remove(t);else{const{children:e}=this;for(let s=0,i=e.length;s<i;s++)(t=e[s]).isMask&&(this.__removeMask(t),i--,s--)}}},{LEAF:qe,create:Qe}=u;let Ze=class{get tag(){return this.__tag}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return yt}get __LayoutProcessor(){return Se}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get worldBoxBounds(){return this.getBounds("box")}get worldStrokeBounds(){return this.getBounds("stroke")}get worldRenderBounds(){return this.getBounds("render")}get worldOpacity(){return this.__layout.checkUpdate(),this.__worldOpacity}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return this.__hasMask&&this.__.hitChildren}constructor(t){this.innerId=Qe(qe),this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0},this.__world={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),t&&Object.assign(this,t)}waitParent(t){this.__parentWait?this.__parentWait.push(t):this.__parentWait=[t]}waitLeafer(t){this.__leaferWait?this.__leaferWait.push(t):this.__leaferWait=[t]}__bindLeafer(t){if(this.isLeafer&&(t=this),this.leafer=t,this.__level=this.parent?this.parent.__level+1:1,this.__leaferWait&&t&&pt.run(this.__leaferWait),this.isBranch){const{children:e}=this;for(let s=0,i=e.length;s<i;s++)e[s].__bindLeafer(t)}}set(t){}get(t){}__setAttr(t,e){}__getAttr(t){}forceUpdate(t){t||(t="x");const e=this.__.__get(t);this.__[t]=null===e?0:null,this[t]=e}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateStrokeBoundsSpreadWidth(){return 0}__updateRenderBoundsSpreadWidth(){return 0}__onUpdateSize(){}__updateMask(){}__renderMask(t,e,s){}__removeMask(t){}getWorld(t){return this.__layout.getMatrixDecompositionData("world")[t]}getBounds(t,e="world"){return this.__layout.getBounds(t,e)}worldToLocal(t,e,s){this.parent?T.toInnerPoint(this.parent.worldTransform,t,e,s):e&&A.copy(e,t)}localToWorld(t,e,s){this.parent?T.toOuterPoint(this.parent.worldTransform,t,e,s):e&&A.copy(e,t)}worldToInner(t,e,s){T.toInnerPoint(this.worldTransform,t,e,s)}innerToWorld(t,e,s){T.toOuterPoint(this.worldTransform,t,e,s)}__hitWorld(t){return!0}__hit(t){return!0}__drawHitPath(t){}__updateHitCanvas(){}__render(t,e){}__drawFast(t,e){}__draw(t,e){}__renderShape(t,e){}__updateWorldOpacity(){}__updateRenderTime(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}__updateSortChildren(){}add(t,e){}remove(t){this.parent&&this.parent.remove(this)}on(t,e,s){}off(t,e,s){}on__(t,e,s,i){}off__(t){}once(t,e,s){}emit(t,e,s){}emitEvent(t,e){}hasEvent(t,e){return!1}destroy(){this.__&&(this.__hitCanvas&&(this.__hitCanvas.destroy(),this.__hitCanvas=null),this.leafer=null,this.parent=null,this.__.destroy(),this.__layout.destroy(),this.__=null,this.__layout=null,this.__captureMap=null,this.__bubbleMap=null,this.children&&(this.children.forEach((t=>{t.destroy()})),this.children.length=0))}};Ze=Vt([Re(Ie),Re(ze),Re(Ye),Re(Ve),Re(Me),Re(Ge)],Ze);const{setByListWithHandle:$e}=$,{sort:Je}=ct,{localBoxBounds:ts,localEventBounds:es,localRenderBounds:ss,maskLocalBoxBounds:is,maskLocalEventBounds:ns,maskLocalRenderBounds:rs}=lt;let os=class extends Ze{constructor(){super(),this.isBranch=!0,this.children=[]}__updateStrokeBoundsSpreadWidth(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeBoundsSpreadWidth)return 1;return 0}__updateRenderBoundsSpreadWidth(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderBoundsSpreadWidth)return 1;return 0}__updateBoxBounds(){$e(this.__layout.boxBounds,this.children,this.__hasMask?is:ts)}__updateStrokeBounds(){$e(this.__layout.strokeBounds,this.children,this.__hasMask?ns:es)}__updateRenderBounds(){$e(this.__layout.renderBounds,this.children,this.__hasMask?rs:ss)}__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1)}__updateSortChildren(){const{children:t}=this;if(t.length>1){for(let e=0,s=t.length;e<s;e++)t[e].__tempNumber=e;t.sort(Je)}}__render(t,e){if(this.__worldOpacity){let s;const{children:i}=this;if(this.__hasMask&&i.length>1){let n,r=t.getSameCanvas(),o=t.getSameCanvas();for(let a=0,h=i.length;a<h;a++)s=i[a],s.isMask?(n?(this.__renderMask(t,o,r),r.clear(),o.clear()):n=!0,s.__render(r,e)):s.__render(o,e);this.__renderMask(t,o,r),r.recycle(),o.recycle()}else{const{bounds:n,hideBounds:r}=e;for(let o=0,a=i.length;o<a;o++)s=i[o],n&&!n.hit(s.__world,e.matrix)||r&&r.includes(s.__world,e.matrix)||s.__render(t,e)}}}add(t,s){if(t.parent&&t.parent.remove(t),t.parent=this,void 0===s?this.children.push(t):this.children.splice(s,0,t),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||0)+1),t.__layout.boundsChanged||t.__layout.positionChange(),t.__parentWait&&pt.run(t.__parentWait),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.ready)){const{ADD:s}=e,i=new e(s,t,this);t.hasEvent(s)&&t.emitEvent(i),this.hasEvent(s)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}}remove(t){if(t){const s=this.children.indexOf(t);if(s>-1&&(this.children.splice(s,1),this.__hasMask&&this.__updateMask(),this.__layout.boxBoundsChange(),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.ready))){const{REMOVE:s}=e,i=new e(s,t,this);t.hasEvent(s)&&t.emitEvent(i),this.hasEvent(s)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}}else super.remove()}};os=Vt([Re(Ke)],os);const as={};class hs{static isHoldSpaceKey(){return hs.hasDownCode("Space")}static setDownCode(t){as[t]||(as[t]=!0)}static setUpCode(t){as[t]=!1}static hasDownCode(t){return as[t]}}class ds{static left(t){return 1===t.buttons}static right(t){return 2===t.buttons}static middle(t){return 4===t.buttons}}class ls extends t{get spaceKey(){return hs.isHoldSpaceKey()}get left(){return ds.left(this)}get right(){return ds.right(this)}get middle(){return ds.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}static changeName(t,e){Ut.changeName(t,e)}}let cs=class extends ls{};cs.POINTER="pointer",cs.BEFORE_DOWN="pointer.before_down",cs.BEFORE_MOVE="pointer.before_move",cs.BEFORE_UP="pointer.before_up",cs.DOWN="pointer.down",cs.MOVE="pointer.move",cs.UP="pointer.up",cs.OVER="pointer.over",cs.OUT="pointer.out",cs.ENTER="pointer.enter",cs.LEAVE="pointer.leave",cs.TAP="tap",cs.DOUBLE_TAP="double_tap",cs.CLICK="click",cs.DOUBLE_CLICK="double_click",cs.LONG_PRESS="long_press",cs.LONG_TAP="long_tap",cs=Vt([Le()],cs);let us=class extends cs{};var _s;us.DRAG="drag",us.START="drag.start",us.END="drag.end",us.OVER="drag.over",us.OUT="drag.out",us.ENTER="drag.enter",us.LEAVE="drag.leave",us=Vt([Le()],us);let ps=_s=class extends cs{static setList(t){_s.dragList=t instanceof l?t:new l(t)}static setData(t){this.dragData=t}};ps.DROP="drop",ps=_s=Vt([Le()],ps);let gs=class extends us{};gs.MOVE="move",gs.START="move.start",gs.END="move.end",gs=Vt([Le()],gs);let fs=class extends ls{};fs.ROTATE="rotate",fs.START="rotate.start",fs.END="rotate.end",fs=Vt([Le()],fs);let ys=class extends us{};ys.SWIPE="swipe",ys.LEFT="swipe.left",ys.RIGHT="swipe.right",ys.UP="swipe.up",ys.DOWN="swipe.down",ys=Vt([Le()],ys);let ms=class extends ls{};ms.ZOOM="zoom",ms.START="zoom.start",ms.END="zoom.end",ms=Vt([Le()],ms);let vs=class extends ls{};vs.DOWN="key.down",vs.PRESS="key.press",vs.UP="key.up",vs=Vt([Le()],vs);class ws{constructor(t,e){this.map={},this.__onLoadMap={},this.__onErrorMap={},this.leafer=t}get(t){let e=this.map[t.url];return e||(e=Wt.image(t),this.map[t.url]=e),e}onLoad(t,e){const s=this.map[t.url];s&&s.ready&&e(s)}onError(t,e){}destory(){this.leafer=null}}const xs={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Bs={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},bs=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},Bs),ks={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},Es={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},Ts=Object.assign(Object.assign({},Es),Bs),Cs=bs,Rs={};for(let t in Cs)Rs[Cs[t]]=t;const Ps={};for(let t in Cs)Ps[Cs[t]]=ks[t];const Ls={drawRoundRect(t,e,s,i,n,r){let[o,a,h,d]=p.fourNumber(r);const l=Math.min(i/2,n/2);o>l&&(o=l),a>l&&(a=l),h>l&&(h=l),d>l&&(d=l),o?t.moveTo(e+o,s):t.moveTo(e,s),a?t.arcTo(e+i,s,e+i,s+n,a):t.lineTo(e+i,s),h?t.arcTo(e+i,s+n,e,s+n,h):t.lineTo(e+i,s+n),d?t.arcTo(e,s+n,e,s,d):t.lineTo(e,s+n),o?t.arcTo(e,s,e+i,s,o):t.lineTo(e,s)}},{sin:Os,cos:Ss,atan2:Ds,ceil:Ms,abs:As,PI:Is}=Math,{setPoint:Ws,addPoint:Ns}=F,{set:Fs}=A,zs={},Hs={rect(t,e,s,i,n){xs.creator.path=t,xs.creator.moveTo(e,s).lineTo(e+i,s).lineTo(e+i,s+n).lineTo(e,s+n).lineTo(e,s)},roundRect(t,e,s,i,n,r){xs.creator.path=[],Ls.drawRoundRect(xs.creator,e,s,i,n,r),t.push(...xs.convertToCanvasData(xs.creator.path,!0))},arcTo(t,e,s,i,n,r,o,a,h,d,l){const c=i-e,u=n-s,_=r-i,p=o-n;let m=Ds(u,c),v=Ds(p,_),w=v-m;if(w<0&&(w+=f),w===Is||As(c+u)<1e-12||As(_+p)<1e-12)return t&&t.push(bs.L,i,n),h&&(Ws(h,e,s),Ns(h,i,n)),l&&Fs(l,e,s),void(d&&Fs(d,i,n));const x=c*p-_*u<0,B=x?-1:1,b=a/Ss(w/2),k=i+b*Ss(m+w/2+y*B),E=n+b*Os(m+w/2+y*B);return m-=y*B,v-=y*B,js(t,k,E,a,a,0,m/g,v/g,x,h,d,l)},arc:(t,e,s,i,n,r,o,a,h,d)=>js(t,e,s,i,i,0,n,r,o,a,h,d),ellipse(t,e,s,i,n,r,o,a,h,d,l,c){const u=r*g,_=Os(u),p=Ss(u);let m=o*g,v=a*g;m>Is&&(m-=f),v<0&&(v+=f);let w=v-m;w<0?w+=f:w>f&&(w-=f),h&&(w-=f);const x=Ms(As(w/y)),B=w/x,b=Os(B/4),k=8/3*b*b/Os(B/2);v=m+B;let E,T,C,R,P,L,O,S,D=Ss(m),M=Os(m),A=C=p*i*D-_*n*M,I=R=_*i*D+p*n*M,W=e+C,N=s+R;t&&t.push(bs.L,W,N),d&&Ws(d,W,N),c&&Fs(c,W,N);for(let r=0;r<x;r++)E=Ss(v),T=Os(v),C=p*i*E-_*n*T,R=_*i*E+p*n*T,P=e+A-k*(p*i*M+_*n*D),L=s+I-k*(_*i*M-p*n*D),O=e+C+k*(p*i*T+_*n*E),S=s+R+k*(_*i*T-p*n*E),t&&t.push(bs.C,P,L,O,S,e+C,s+R),d&&Ys(e+A,s+I,P,L,O,S,e+C,s+R,d,!0),A=C,I=R,D=E,M=T,m=v,v+=B;l&&Fs(l,e+C,s+R)},quadraticCurveTo(t,e,s,i,n,r,o){t.push(bs.C,(e+2*i)/3,(s+2*n)/3,(r+2*i)/3,(o+2*n)/3,r,o)},toTwoPointBoundsByQuadraticCurve(t,e,s,i,n,r,o,a){Ys(t,e,(t+2*s)/3,(e+2*i)/3,(n+2*s)/3,(r+2*i)/3,n,r,o,a)},toTwoPointBounds(t,e,s,i,n,r,o,a,h,d){const l=[];let c,u,_,p,g,f,y,m,v=t,w=s,x=n,B=o;for(let t=0;t<2;++t)if(1==t&&(v=e,w=i,x=r,B=a),c=-3*v+9*w-9*x+3*B,u=6*v-12*w+6*x,_=3*w-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;p=-_/u,0<p&&p<1&&l.push(p)}else y=u*u-4*_*c,m=Math.sqrt(y),y<0||(g=(-u+m)/(2*c),0<g&&g<1&&l.push(g),f=(-u-m)/(2*c),0<f&&f<1&&l.push(f));d?Ns(h,t,e):Ws(h,t,e),Ns(h,o,a);for(let d=0,c=l.length;d<c;d++)Us(l[d],t,e,s,i,n,r,o,a,zs),Ns(h,zs.x,zs.y)},getPointAndSet(t,e,s,i,n,r,o,a,h,d){const l=1-t,c=l*l*l,u=3*l*l*t,_=3*l*t*t,p=t*t*t;d.x=c*e+u*i+_*r+p*a,d.y=c*s+u*n+_*o+p*h},getPoint(t,e,s,i,n,r,o,a,h){const d={};return Us(t,e,s,i,n,r,o,a,h,d),d}},{getPointAndSet:Us,toTwoPointBounds:Ys,ellipse:js}=Hs,{sin:Xs,cos:Vs,sqrt:Gs,atan2:Ks}=Math,{ellipse:qs}=Hs,Qs={ellipticalArc(t,e,s,i,n,r,o,a,h,d,l){const c=(h-e)/2,u=(d-s)/2,_=r*g,p=Xs(_),y=Vs(_),m=-y*c-p*u,v=-y*u+p*c,w=i*i,x=n*n,B=v*v,b=m*m,k=w*x-w*B-x*b;let E=0;if(k<0){const t=Gs(1-k/(w*x));i*=t,n*=t}else E=(o===a?-1:1)*Gs(k/(w*B+x*b));const T=E*i*v/n,C=-E*n*m/i,R=Ks((v-C)/n,(m-T)/i),P=Ks((-v-C)/n,(-m-T)/i);let L=P-R;0===a&&L>0?L-=f:1===a&&L<0&&(L+=f);const O=e+c+y*T-p*C,S=s+u+p*T+y*C,D=L<0?1:0;l?qs(t,O,S,i,n,r,R/g,P/g,D):i!==n||r?t.push(bs.G,O,S,i,n,r,R/g,P/g,D):t.push(bs.O,O,S,i,R/g,P/g,D)}},{M:Zs,m:$s,L:Js,l:ti,H:ei,h:si,V:ii,v:ni,C:ri,c:oi,S:ai,s:hi,Q:di,q:li,T:ci,t:ui,A:_i,a:pi,Z:gi,z:fi,N:yi,D:mi,X:vi,G:wi,F:xi,O:Bi,P:bi,U:ki}=bs,{rect:Ei,roundRect:Ti,arcTo:Ci,arc:Ri,ellipse:Pi,quadraticCurveTo:Li}=Hs,{ellipticalArc:Oi}=Qs,Si=mt.get("PathConvert"),Di={},Mi={current:{},stringify(t){let e,s,i,n=0,r=t.length,o="";for(;n<r;){s=t[n],e=Ps[s],o+=s===i?" ":Rs[s];for(let s=1;s<e;s++)o+=t[n+s],s===e-1||(o+=" ");i=s,n+=e}return o},parse(t,e){let s,i,n,r="";const o=[],a=e?Ts:Es;for(let e=0,h=t.length;e<h;e++)i=t[e],nt[i]?r+=i:bs[i]?(r&&(Ii(o,Number(r)),r=""),Ai.name=bs[i],Ai.length=ks[i],Ai.index=0,Ii(o,Ai.name),!s&&a[i]&&(s=!0)):"-"===i||"+"===i?"e"===n||"E"===n?r+=i:(r&&Ii(o,Number(r)),r=i):r&&(Ii(o,Number(r)),r=""),n=i;return r&&Ii(o,Number(r)),s?Mi.toCanvasData(o,e):o},toCanvasData(t,e){let s,i,n,r,o,a=0,h=0,d=0,l=0,c=0,u=t.length;const _=[];for(;c<u;){switch(n=t[c],n){case $s:t[c+1]+=a,t[c+2]+=h;case Zs:a=t[c+1],h=t[c+2],_.push(Zs,a,h),c+=3;break;case si:t[c+1]+=a;case ei:a=t[c+1],_.push(Js,a,h),c+=2;break;case ni:t[c+1]+=h;case ii:h=t[c+1],_.push(Js,a,h),c+=2;break;case ti:t[c+1]+=a,t[c+2]+=h;case Js:a=t[c+1],h=t[c+2],_.push(Js,a,h),c+=3;break;case hi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=ai;case ai:o=r===ri||r===ai,d=o?2*a-s:t[c+1],l=o?2*h-i:t[c+2],s=t[c+1],i=t[c+2],a=t[c+3],h=t[c+4],_.push(ri,d,l,s,i,a,h),c+=5;break;case oi:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,n=ri;case ri:s=t[c+3],i=t[c+4],a=t[c+5],h=t[c+6],_.push(ri,t[c+1],t[c+2],s,i,a,h),c+=7;break;case ui:t[c+1]+=a,t[c+2]+=h,n=ci;case ci:o=r===di||r===ci,s=o?2*a-s:t[c+1],i=o?2*h-i:t[c+2],e?Li(_,a,h,s,i,t[c+1],t[c+2]):_.push(di,s,i,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case li:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,n=di;case di:s=t[c+1],i=t[c+2],e?Li(_,a,h,s,i,t[c+3],t[c+4]):_.push(di,s,i,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case pi:t[c+6]+=a,t[c+7]+=h;case _i:Oi(_,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case fi:case gi:_.push(gi),c++;break;case yi:a=t[c+1],h=t[c+2],e?Ei(_,a,h,t[c+3],t[c+4]):Wi(_,t,c,5),c+=5;break;case mi:a=t[c+1],h=t[c+2],e?Ti(_,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):Wi(_,t,c,9),c+=9;break;case vi:a=t[c+1],h=t[c+2],e?Ti(_,a,h,t[c+3],t[c+4],t[c+5]):Wi(_,t,c,6),c+=6;break;case wi:Pi(e?_:Wi(_,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,Di),a=Di.x,h=Di.y,c+=9;break;case xi:e?Pi(_,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):Wi(_,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Bi:Ri(e?_:Wi(_,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,Di),a=Di.x,h=Di.y,c+=7;break;case bi:e?Ri(_,t[c+1],t[c+2],t[c+3],0,360,!1):Wi(_,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case ki:Ci(e?_:Wi(_,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,Di),a=Di.x,h=Di.y,c+=6;break;default:return Si.error(`command: ${n} [index:${c}]`,t),_}r=n}return _},copyData(t,e,s,i){for(let n=s,r=s+i;n<r;n++)t.push(e[n])},pushData(t,e){Ai.index===Ai.length&&(Ai.index=1,t.push(Ai.name)),t.push(e),Ai.index++}},{current:Ai,pushData:Ii,copyData:Wi}=Mi,{M:Ni,L:Fi,C:zi,Q:Hi,Z:Ui,N:Yi,D:ji,X:Xi,G:Vi,F:Gi,O:Ki,P:qi,U:Qi}=bs,Zi={},$i={beginPath(t){t.length=0},moveTo(t,e,s){t.push(Ni,e,s)},lineTo(t,e,s){t.push(Fi,e,s)},bezierCurveTo(t,e,s,i,n,r,o){t.push(zi,e,s,i,n,r,o)},quadraticCurveTo(t,e,s,i,n){t.push(Hi,e,s,i,n)},closePath(t){t.push(Ui)},rect(t,e,s,i,n){t.push(Yi,e,s,i,n)},roundRect(t,e,s,i,n,r){if("number"==typeof r)t.push(Xi,e,s,i,n,r);else{const o=p.fourNumber(r);o?t.push(ji,e,s,i,n,...o):t.push(Yi,e,s,i,n)}},ellipse(t,e,s,i,n,r,o,a,h){void 0===r?t.push(Gi,e,s,i,n):(void 0===o&&(o=0),void 0===a&&(a=360),t.push(Vi,e,s,i,n,r,o,a,h?1:0))},arc(t,e,s,i,n,r,o){void 0===n?t.push(qi,e,s,i):(void 0===r&&(r=360),t.push(Ki,e,s,i,n,r,o?1:0))},moveToEllipse(t,e,s,i,n,r,o,a,h){void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=360),Hs.ellipse(null,e,s,i,n,r,o,a,h,null,null,Zi),t.push(Ni,Zi.x,Zi.y),Ji(t,e,s,i,n,r,o,a,h)},moveToArc(t,e,s,i,n,r,o){void 0===n&&(n=0),void 0===r&&(r=360),Hs.arc(null,e,s,i,n,r,o,null,null,Zi),t.push(Ni,Zi.x,Zi.y),tn(t,e,s,i,n,r,o)},arcTo(t,e,s,i,n,r){t.push(Qi,e,s,i,n,r)}},{ellipse:Ji,arc:tn}=$i,{moveTo:en,lineTo:sn,quadraticCurveTo:nn,bezierCurveTo:rn,closePath:on,beginPath:an,rect:hn,roundRect:dn,ellipse:ln,arc:cn,arcTo:un,moveToEllipse:_n,moveToArc:pn}=$i;class gn{constructor(t){this.path=t?"string"==typeof t?xs.parse(t):t:[]}beginPath(){return an(this.path),this}moveTo(t,e){return en(this.path,t,e),this}lineTo(t,e){return sn(this.path,t,e),this}bezierCurveTo(t,e,s,i,n,r){return rn(this.path,t,e,s,i,n,r),this}quadraticCurveTo(t,e,s,i){return nn(this.path,t,e,s,i),this}closePath(){return on(this.path),this}rect(t,e,s,i){return hn(this.path,t,e,s,i),this}roundRect(t,e,s,i,n){return dn(this.path,t,e,s,i,n),this}ellipse(t,e,s,i,n,r,o,a){return ln(this.path,t,e,s,i,n,r,o,a),this}arc(t,e,s,i,n,r){return cn(this.path,t,e,s,i,n,r),this}arcTo(t,e,s,i,n){return un(this.path,t,e,s,i,n),this}moveToEllipse(t,e,s,i,n,r,o,a){return _n(this.path,t,e,s,i,n,r,o,a),this}moveToArc(t,e,s,i,n,r){return pn(this.path,t,e,s,i,n,r),this}}const{M:fn,L:yn,C:mn,Q:vn,Z:wn,N:xn,D:Bn,X:bn,G:kn,F:En,O:Tn,P:Cn,U:Rn}=bs,Pn=mt.get("PathDrawer"),Ln={drawPathByData(t,e){if(!e)return;let s,i=0,n=e.length;for(;i<n;)switch(s=e[i],s){case fn:t.moveTo(e[i+1],e[i+2]),i+=3;break;case yn:t.lineTo(e[i+1],e[i+2]),i+=3;break;case mn:t.bezierCurveTo(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5],e[i+6]),i+=7;break;case vn:t.quadraticCurveTo(e[i+1],e[i+2],e[i+3],e[i+4]),i+=5;break;case wn:t.closePath(),i+=1;break;case xn:t.rect(e[i+1],e[i+2],e[i+3],e[i+4]),i+=5;break;case Bn:t.roundRect(e[i+1],e[i+2],e[i+3],e[i+4],[e[i+5],e[i+6],e[i+7],e[i+8]]),i+=9;break;case bn:t.roundRect(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]),i+=6;break;case kn:t.ellipse(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]*g,e[i+6]*g,e[i+7]*g,e[i+8]),i+=9;break;case En:t.ellipse(e[i+1],e[i+2],e[i+3],e[i+4],0,0,f,!1),i+=5;break;case Tn:t.arc(e[i+1],e[i+2],e[i+3],e[i+4]*g,e[i+5]*g,e[i+6]),i+=7;break;case Cn:t.arc(e[i+1],e[i+2],e[i+3],0,f,!1),i+=4;break;case Rn:t.arcTo(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]),i+=6;break;default:return void Pn.error(`command: ${s} [index:${i}]`,e)}}},{M:On,L:Sn,C:Dn,Q:Mn,Z:An,N:In,D:Wn,X:Nn,G:Fn,F:zn,O:Hn,P:Un,U:Yn}=bs,{toTwoPointBounds:jn,toTwoPointBoundsByQuadraticCurve:Xn,arcTo:Vn,arc:Gn,ellipse:Kn}=Hs,{add:qn,copy:Qn,addPoint:Zn,setPoint:$n,addBounds:Jn,toBounds:tr}=F,er=mt.get("PathBounds");let sr,ir,nr;const rr={},or={},ar={},hr={toBounds(t,e){hr.toTwoPointBounds(t,or),tr(or,e)},toTwoPointBounds(t,e){if(!t||!t.length)return $n(e,0,0);let s,i,n,r,o,a=0,h=0,d=0;const l=t.length;for(;a<l;)switch(s=t[a],0===a&&(s===An||s===Dn||s===Mn?$n(e,h,d):$n(e,t[a+1],t[a+2])),s){case On:case Sn:h=t[a+1],d=t[a+2],Zn(e,h,d),a+=3;break;case Dn:r=t[a+5],o=t[a+6],jn(h,d,t[a+1],t[a+2],t[a+3],t[a+4],r,o,rr),qn(e,rr),h=r,d=o,a+=7;break;case Mn:i=t[a+1],n=t[a+2],r=t[a+3],o=t[a+4],Xn(h,d,i,n,r,o,rr),qn(e,rr),h=r,d=o,a+=5;break;case An:a+=1;break;case In:h=t[a+1],d=t[a+2],Jn(e,h,d,t[a+3],t[a+4]),a+=5;break;case Wn:case Nn:h=t[a+1],d=t[a+2],Jn(e,h,d,t[a+3],t[a+4]),a+=s===Wn?9:6;break;case Fn:Kn(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],rr,ar),0===a?Qn(e,rr):qn(e,rr),h=ar.x,d=ar.y,a+=9;break;case zn:h=t[a+1],d=t[a+2],ir=t[a+3],nr=t[a+4],Jn(e,h-ir,d-nr,2*ir,2*nr),h+=ir,a+=5;break;case Hn:Gn(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],rr,ar),0===a?Qn(e,rr):qn(e,rr),h=ar.x,d=ar.y,a+=7;break;case Un:h=t[a+1],d=t[a+2],sr=t[a+3],Jn(e,h-sr,d-sr,2*sr,2*sr),h+=sr,a+=4;break;case Yn:Vn(null,h,d,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],rr,ar),0===a?Qn(e,rr):qn(e,rr),h=ar.x,d=ar.y,a+=6;break;default:return void er.error(`command: ${s} [index:${a}]`,t)}}},dr={smooth:(t,e,s)=>t};xs.creator=new gn,xs.parse=Mi.parse,xs.convertToCanvasData=Mi.toCanvasData;const lr=mt.get("plugin"),cr={list:[]};class ur{constructor(t){this.taskTime=1,this.id=u.create(u.TASK),this.task=t}run(){return Gt(this,void 0,void 0,(function*(){this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}}const _r=mt.get("TaskProcessor");class pr{constructor(t,e){this.updatedList=new l,this.totalTimes=0,this.config={},this.target=t,e&&(this.config=gt.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(h.REQUEST)}__onAttrChange(t){this.updatedList.push(t.target),this.update()}__onChildEvent(t){this.updatedList.push(t.type===e.REMOVE?t.parent:t.child),this.update()}__onRquestData(){this.target.emitEvent(new o(o.DATA,{updatedList:this.updatedList})),this.updatedList=new l,this.totalTimes++,this.changed=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(s.CHANGE,this.__onAttrChange,this),t.on__([e.ADD,e.REMOVE],this.__onChildEvent,this),t.on__(o.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.updatedList=null)}}const gr=mt.get("Renderer");class fr{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,s&&(this.config=gt.default(s,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed||this.__requestRender(),this.changed=!0}requestLayout(){this.target.emit(a.REQUEST)}render(t){if(!this.running)return;const{target:e}=this;this.times=0,this.totalBounds=new st,gr.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds)}catch(t){gr.error(t)}gr.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?gr.warn("rendering"):this.times>3?gr.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new st,this.renderOptions={},t?(this.emitRender(h.BEFORE),t()):(this.requestLayout(),this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return gr.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=xt.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=t.includes(this.target.__world),r=(new st).copy(i);s.save(),n&&!mt.showRepaint?s.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),s.clearWorld(i,!0),s.clipWorld(i,!0)),this.__render(i,r),s.restore(),xt.end(e)}fullRender(){const t=xt.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),xt.end(t)}__render(t,e){const s=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),mt.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),mt.showHitView&&this.renderHitView(s),mt.showBoundsView&&this.renderBoundsView(s)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new st;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();It.requestRender((()=>{this.changed&&(this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&this.render())}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:s}=t.old;new st(0,0,e,s).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(gr.warn(t.innerName,": none bounds"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new h(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(h.REQUEST,this.update,this),t.on__(a.END,this.__onLayoutEnd,this),t.on__(h.AGAIN,this.renderAgain,this),t.on__(n.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:yr}=$;class mr{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,s){e||(e=0),s||(s={});const i=s.through||!1,n=s.ignoreHittable||!1;this.exclude=s.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,o=this.getBestMatchLeaf(),a=n?this.getPath(o):this.getHitablePath(o);return this.clear(),i?{path:a,leaf:o,throughPath:r.length?this.getThroughPath(r):a}:{path:a,leaf:o}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:s,y:i}=this.point,n={x:s,y:i,radiusX:0,radiusY:0};for(let s=0,i=t.length;s<i;s++)if(e=t[s],this.hitChild(e,n),this.findList.length)return this.findList[0]}return t[0]}getPath(t){const e=new l;for(;t;)e.push(t),t=t.parent;return e.push(this.target),e}getHitablePath(t){const e=this.getPath(t);let s,i=new l;for(let t=e.list.length-1;t>-1&&(s=e.list[t],s.__.hittable)&&(i.unshift(s),s.__.hitChildren);t--);return i}getThroughPath(t){const e=new l,s=[];for(let e=t.length-1;e>-1;e--)s.push(this.getPath(t[e]));let i,n,r;for(let t=0,o=s.length;t<o;t++){i=s[t],n=s[t+1];for(let t=0,s=i.length;t<s&&(r=i.list[t],!n||!n.has(r));t++)e.push(r)}return e}eachFind(t,e){let s,i;const{point:n}=this;for(let r=t.length-1;r>-1;r--)s=t[r],e&&!s.isMask||(i=yr(s.__world,n),s.isBranch?(i||s.__ignoreHitWorld)&&(this.eachFind(s.children,s.__onlyHitMask),s.isBranchLeaf&&!this.findList.length&&this.hitChild(s,n)):i&&this.hitChild(s,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.target=null,this.selector=null}}class vr{constructor(t,e){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,e&&(this.config=gt.default(e,this.config)),this.findPath=new mr(t,this),this.__listenEvents()}getByPoint(t,e,s){return this.target.emit(a.CHECK_UPDATE),this.findPath.getByPoint(t,e,s)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let s,i=this.innerIdList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(s=e,this.innerIdList[t]=s,!0))),s)}getById(t,e){let s,i=this.idList[t];return i||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(s=e,this.idList[t]=s,!0))),s)}getByClassName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.className===t&&s.push(e),!1))),s}getByTagName(t,e){e||(e=this.target);let s=[];return this.loopFind(e,(e=>(e.__tag===t&&s.push(e),!1))),s}loopFind(t,e){if(e(t))return;const{children:s}=t;for(let i=0,n=s.length;i<n;i++){if(e(t=s[i]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on__(e.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off__(this.__eventIds)}destroy(){this.target&&(this.__removeListenEvents(),this.findPath.destroy(),this.target=null,this.findPath=null,this.innerIdList=null,this.idList=null,this.classNameList=null,this.tagNameList=null)}}Object.assign(Wt,{watcher:(t,e)=>new pr(t,e),layouter:(t,e)=>new At(t,e),renderer:(t,e,s)=>new fr(t,e,s),selector:(t,e)=>new vr(t,e)});const wr=mt.get("LeaferCanvas");class xr extends se{init(){const{view:t}=this.config;if(this.offscreen)t?this.view=t:this.__createView();else{t?this.__createViewFrom(t):this.__createView();const{style:e}=this.view;this.autoLayout&&(e.display||(e.display="block")),this.parentView=this.view.parentElement}this.__createContext(),this.autoLayout||this.resize(this.config)}setBackgroundColor(t){this.view.style.backgroundColor=t}setHittable(t){this.view.style.pointerEvents=t?"auto":"none"}__createContext(){this.context=this.view.getContext("2d"),this.__bindContext()}__createView(){this.view=this.offscreen?new OffscreenCanvas(1,1):document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:s}=e;s.position="absolute",s.top=s.bottom=s.left=s.right="0px",document.body.appendChild(e),t=e}this.__createView();const s=this.view;if(t.hasChildNodes()){const{style:e}=s;e.position="absolute",e.top=e.left="0px",t.style.position||(t.style.position="relative")}t.appendChild(s)}else wr.error(`no id: ${t}`),this.__createView()}setViewSize(t){const{width:e,height:s,pixelRatio:i}=t;if(!this.offscreen){const{style:t}=this.view;t.width=e+"px",t.height=s+"px"}this.view.width=e*i,this.view.height=s*i}startAutoLayout(t,e){if(!this.offscreen){const s=this.view,i=i=>{const{x:r,y:o,width:a,height:h}=t.getBoundsFrom(i),{style:d}=s;if(d.marginLeft=r+"px",d.marginTop=o+"px",a!==this.width||h!==this.height){const{pixelRatio:t}=this,s={width:a,height:h,pixelRatio:t},i={width:this.width,height:this.height,pixelRatio:this.pixelRatio};this.resize(s),void 0!==this.width&&e(new n(s,i))}};this.resizeObserver=new ResizeObserver((t=>{for(const e of t)i(e.contentRect)}));const r=this.parentView;r&&(this.resizeObserver.observe(r),i(r.getBoundingClientRect()))}}stopAutoLayout(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null,this.autoLayout=!1)}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal&&!this.offscreen){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}const{drawRoundRect:Br}=Ls;CanvasRenderingContext2D.prototype.roundRect||(CanvasRenderingContext2D.prototype.roundRect=Path2D.prototype.roundRect=function(t,e,s,i,n){Br(this,t,e,s,i,n)});class br{constructor(t){this.options=t}load(t,e){let s=this.options.url;const i=this.view=new Image;i.setAttribute("crossOrigin","anonymous"),i.crossOrigin="anonymous",i.onload=()=>{this.ready=!0,this.width=i.naturalWidth,this.height=i.naturalHeight,t&&t(this)},i.onerror=t=>{e&&e(t)},s.startsWith("data:")||s.includes("?"),i.src=s}getCanvas(t,e,s,i){const n=document.createElement("canvas");t||(t=this.width),e||(e=this.height),n.width=t,n.height=e;const r=n.getContext("2d");return s&&(r.globalAlpha=s),r.drawImage(this.view,0,0,t,e),n}destory(){}}class kr{constructor(t){this.interaction=t}move(t){const{interaction:e}=this;if(!this.moveData){const{path:s}=e.selector.getByPoint(t,e.hitRadius);t.path=s,this.moveData=Object.assign(Object.assign({},t),{moveX:0,moveY:0}),e.emit(gs.START,this.moveData)}t.path=this.moveData.path,e.emit(gs.MOVE,t),this.transformEndWait()}zoom(t){const{interaction:e}=this;if(!this.zoomData){const{path:s}=e.selector.getByPoint(t,e.hitRadius);t.path=s,this.zoomData=Object.assign(Object.assign({},t),{scale:1}),e.emit(ms.START,this.zoomData)}t.path=this.zoomData.path,e.emit(ms.ZOOM,t),this.transformEndWait()}rotate(t){const{interaction:e}=this;if(!this.rotateData){const{path:s}=e.selector.getByPoint(t,e.hitRadius);t.path=s,this.rotateData=Object.assign(Object.assign({},t),{rotation:0}),e.emit(fs.START,this.rotateData)}t.path=this.rotateData.path,e.emit(fs.ROTATE,t),this.transformEndWait()}transformEndWait(){clearTimeout(this.transformTimer),this.transformTimer=setTimeout((()=>{this.transformEnd()}),this.interaction.config.pointer.transformTime)}transformEnd(){this.moveEnd(),this.zoomEnd(),this.rotateEnd(),this.transformMode=null}moveEnd(){this.moveData&&(this.interaction.emit(gs.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(ms.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(fs.END,this.rotateData),this.rotateData=null)}destroy(){clearTimeout(this.transformTimer),this.transformEnd(),this.interaction=null}}const Er={getMoveEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:t.x,y:t.y,moveX:e.x,moveY:e.y}),getRotateEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:t.x,y:t.y,rotation:e}),getZoomEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:t.x,y:t.y,scale:e}),getDragEventData:(t,e,s)=>Object.assign(Object.assign({},s),{x:s.x,y:s.y,moveX:s.x-e.x,moveY:s.y-e.y,totalX:s.x-t.x,totalY:s.y-t.y}),getDropEventData:(t,e,s)=>Object.assign(Object.assign({},t),{list:e,data:s}),getSwipeDirection:t=>t<-45&&t>-135?ys.UP:t>45&&t<135?ys.DOWN:t<=45&&t>=-45?ys.RIGHT:ys.LEFT,getSwipeEventData:(t,e,s)=>Object.assign(Object.assign({},s),{moveX:e.moveX,moveY:e.moveY,totalX:s.x-t.x,totalY:s.y-t.y,type:Tr.getSwipeDirection(A.getAngle(t,s))}),getBase:t=>({altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,metaKey:t.metaKey,buttons:void 0===t.buttons?1:t.buttons,origin:t}),pathHasEventType(t,e){const{list:s}=t;for(let t=0,i=s.length;t<i;t++)if(s[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const s=new l,{list:i}=t;for(let t=0,n=i.length;t<n;t++)i[t].hasEvent(e)&&s.push(i[t]);return s}},Tr=Er,{getDragEventData:Cr,getDropEventData:Rr,getSwipeEventData:Pr,filterPathByEventType:Lr}=Er;class Or{constructor(t){this.interaction=t}setDragData(t){this.dragData=Cr(t,t,t)}getDragList(){return this.dragging?ps.dragList||this.dragList:null}checkDrag(t,e){const{interaction:s}=this,{downData:i}=s;if(this.moving&&!ds.middle(t)&&!ds.left(t))return void s.pointerCancel();const{dragData:n}=this;this.moving||(this.moving=(ds.middle(t)||hs.isHoldSpaceKey())&&e,this.moving&&s.emit(gs.START,n)),this.moving||this.dragStart(t,e);const{path:r,throughPath:o}=i;this.dragData=Cr(i,n,t),o&&(this.dragData.throughPath=o),this.dragData.path=r,this.moving?s.emit(gs.MOVE,this.dragData):this.dragging&&(s.emit(us.DRAG,this.dragData),this.dragDragableList())}dragStart(t,e){this.dragging||(this.dragging=ds.left(t)&&e,this.dragging&&(this.interaction.emit(us.START,this.dragData),this.getDragableList(this.dragData.path),this.dragList=Lr(this.dragData.path,us.DRAG),!this.dragList.length&&this.dragableList&&this.dragList.pushList(this.dragableList)))}getDragableList(t){let e;for(let s=0,i=t.length;s<i;s++)if(e=t.list[s],e.__.draggable&&e.__.hitSelf){this.dragableList=[e];break}}dragDragableList(){const{running:t}=this.interaction;if(this.dragableList&&t){const{moveX:t,moveY:e}=this.dragData;this.dragableList.forEach((s=>{rt.move(s,t,e)}))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:s}=this,{path:i}=t;s?i.indexAt(0)!==s.indexAt(0)&&(e.emit(us.OUT,t,s),e.emit(us.OVER,t,i)):e.emit(us.OVER,t,i),this.dragOverPath=i}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:s}=this,{path:i}=t;e.emit(us.ENTER,t,i,s),e.emit(us.LEAVE,t,s,i),this.dragEnterPath=i}dragEnd(t){const{interaction:e}=this,{downData:s}=e;if(!s)return;const{path:i,throughPath:n}=s,r=Cr(s,t,t);n&&(r.throughPath=n),r.path=i,this.moving&&e.emit(gs.END,r),this.dragging&&(e.emit(us.END,r),this.swipe(t,r),this.drop(t)),this.autoMoveCancel(),this.dragReset()}swipe(t,e){const{interaction:s}=this,{downData:i}=s;if(A.getDistance(i,t)>s.config.pointer.swipeDistance){const t=Pr(i,this.dragData,e);this.interaction.emit(t.type,t)}}drop(t){const e=Rr(t,this.getDragList(),ps.dragData);e.path=this.dragEnterPath,this.interaction.emit(ps.DROP,e),this.interaction.emit(us.LEAVE,t,this.dragEnterPath)}dragReset(){ps.dragList=null,this.dragList=null,this.dragableList=null,this.dragData=null,this.dragOverPath=null,this.dragEnterPath=null,this.dragging=null,this.moving=null}checkDragOut(t){const{interaction:e}=this;this.autoMoveCancel(),this.dragging&&!e.shrinkCanvasBounds.hitPoint(t)&&this.autoMoveOnDragOut(t)}autoMoveOnDragOut(t){const{interaction:e}=this,{downData:s}=e,{autoMoveDistance:i}=e.config.pointer;if(!i)return;const n=e.shrinkCanvasBounds,{x:r,y:o}=n,a=$.right(n),h=$.bottom(n),d=t.x<r?i:a<t.x?-i:0,l=t.y<o?i:h<t.y?-i:0;let c=0,u=0;this.autoMoveTimer=setInterval((()=>{c+=d,u+=l,$.move(s,d,l),$.move(this.dragData,d,l),e.move(Object.assign(Object.assign({},t),{moveX:d,moveY:l,totalX:c,totalY:u})),e.pointerMoveReal(t)}),10)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.interaction=null,this.dragableList=null}}function Sr(t,e,s,i,n){if(t.__.hitChildren&&!Mr(t,n)){let r;for(let o=0,a=t.children.length;o<a;o++)r=t.children[o],!s.path.has(r)&&r.__.hittable&&Dr(r,e,s,i,n)}}function Dr(t,e,s,i,n){if(t.__.hitSelf&&t.hasEvent(e,i)&&!Mr(t,n)){s.phase=i?1:t===s.target?2:3;const n=Ut.get(e,s);if(t.emitEvent(n,i),n.isStop)return!0}return!1}function Mr(t,e){return e&&e.has(t)}const{pathHasEventType:Ar}=Er;class Ir{get dragging(){return this.dragger.dragging}get hitRadius(){return this.config.pointer.hitRadius}constructor(t,e,s,i){this.config={wheel:{zoomMode:!1,zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,through:!1,tapTime:120,longPressTime:800,transformTime:500,dragHover:!0,dragDistance:2,swipeDistance:20,autoMoveDistance:2,ignoreMove:!1}},this.tapCount=0,this.target=t,this.canvas=e,this.selector=s,this.defaultPath=new l(t),this.transformer=new kr(this),this.dragger=new Or(this),i&&(this.config=gt.default(i,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}pointerDown(t){this.emit(cs.BEFORE_DOWN,t,this.defaultPath);const{hitRadius:e,through:s}=this.config.pointer,i=this.selector.getByPoint(t,e,{through:s});i.throughPath&&(t.throughPath=i.throughPath),t.path=i.path,this.emit(cs.DOWN,t),this.downData=t,this.downTime=Date.now(),this.dragger.setDragData(t),ds.left(t)&&(this.tapWait(),this.longPressWait(t))}pointerMove(t){(this.downData||this.canvas.bounds.hitPoint(t))&&(this.pointerMoveReal(t),this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(cs.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=A.getDistance(this.downData,t)>this.config.pointer.dragDistance;this.waitTap&&e&&this.pointerWaitCancel(),this.dragger.checkDrag(t,e)}if(this.dragger.moving||this.config.pointer.ignoreMove)return;const e=this.selector.getByPoint(t,this.hitRadius,{exclude:this.dragger.getDragList(),name:cs.MOVE});t.path=e.path,this.emit(cs.MOVE,t),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t),this.dragger.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t))}pointerUp(t){if(!this.downData)return;this.emit(cs.BEFORE_UP,t,this.defaultPath);const{through:e}=this.config.pointer,s=this.selector.getByPoint(t,this.hitRadius,{through:e});s.throughPath&&(t.throughPath=s.throughPath),t.path=s.path,this.emit(cs.UP,t),this.emit(cs.UP,this.downData,void 0,t.path),this.touchLeave(t),this.tap(t),this.dragger.dragEnd(t),this.downData=null}pointerCancel(){this.pointerUp(this.dragger.dragData)}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}pointerOverOrOut(t){if(this.dragger.moving)return;if(this.dragging&&!this.config.pointer.dragHover)return;const{path:e}=t;this.overPath?e.indexAt(0)!==this.overPath.indexAt(0)&&(this.emit(cs.OUT,t,this.overPath),this.emit(cs.OVER,t,e)):this.emit(cs.OVER,t,e),this.overPath=e}pointerEnterOrLeave(t){if(this.dragger.moving)return;if(this.dragging&&!this.config.pointer.dragHover)return;const{path:e}=t;this.emit(cs.ENTER,t,e,this.enterPath),this.emit(cs.LEAVE,t,this.enterPath,e),this.enterPath=e}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(cs.LEAVE,t),this.dragger.dragging&&this.emit(ps.LEAVE,t))}tap(t){const{pointer:e}=this.config,s=this.longTap(t);if(!e.tapMore&&s)return;if(!this.waitTap)return;e.tapMore&&this.emitTap(t);const i=Date.now()-this.downTime,n=[cs.DOUBLE_TAP,cs.DOUBLE_CLICK].some((e=>Ar(t.path,e)));i<e.tapTime+50&&n?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout((()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}emitTap(t){this.emit(cs.TAP,t),this.emit(cs.CLICK,t)}emitDoubleTap(t){this.emit(cs.DOUBLE_TAP,t),this.emit(cs.DOUBLE_CLICK,t)}pointerWaitCancel(){this.tapWaitCancel(),this.longPressWaitCancel()}tapWait(){clearTimeout(this.tapTimer),this.waitTap=!0}tapWaitCancel(){clearTimeout(this.tapTimer),this.waitTap=!1,this.tapCount=0}longPressWait(t){clearTimeout(this.longPressTimer),this.longPressTimer=setTimeout((()=>{this.longPressed=!0,this.emit(cs.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(cs.LONG_TAP,t),Ar(t.path,cs.LONG_TAP)&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new st(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on__(n.RESIZE,this.__onResize,this)],this.__onResize()}__removeListenEvents(){this.target.off__(this.__eventIds)}emit(t,e,s,i){this.running&&function(t,e,s,i){if(!s&&!e.path)return;let n;e.type=t,s?e=Object.assign(Object.assign({},e),{path:s}):s=e.path,e.target=s.indexAt(0);for(let r=s.length-1;r>-1;r--){if(n=s.list[r],Dr(n,t,e,!0,i))return;n.isApp&&Sr(n,t,e,!0,i)}for(let r=0,o=s.length;r<o;r++)if(n=s.list[r],n.isApp&&Sr(n,t,e,!1,i),Dr(n,t,e,!1,i))return}(t,e,s,i)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.config=null,this.target=null,this.selector=null,this.canvas=null,this.dragger=null,this.transformer=null)}}const Wr={convert(t,e){const s=Er.getBase(t),i=Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===i.pointerType&&(i.tangentialPressure=t.tangentialPressure,i.tiltX=t.tiltX,i.tiltY=t.tiltY,i.twist=t.twist),i},convertMouse(t,e){const s=Er.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const s=Wr.getTouch(t),i=Er.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:s.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},Nr={getData(t,e){const s=A.getCenter(t[0],t[1]),i=A.getCenter(e[0],e[1]),n={x:i.x-s.x,y:i.y-s.y},r=A.getDistance(t[0],t[1]),o=A.getDistance(e[0],e[1])/r,a=A.getAngle(t[0],t[1]),h=A.getAngle(e[0],e[1]);return{move:n,scale:o,angle:this.getChangedAngle(a,h),center:i}},getTouches(t){const e=[];for(let s=0,i=t.length;s<i;s++)e.push(t[s]);return e},getChangedAngle(t,e){const s=(e=e<=-90?360+e:e)-(t=t<=-90?360+t:t);return s<0?s+360:s}};let Fr=0;const zr={getMove:(t,e)=>({x:-t.deltaX*e.moveSpeed*2,y:-t.deltaY*e.moveSpeed*2}),getScale(t,e){let s,i=1,{zoomMode:n,zoomSpeed:r}=e;const o=t.deltaY||t.deltaX;if(n){const e=t.mozInputSource&&t.deltaY%18==0;e?Fr++:Fr=0,s=(Math.floor(t.deltaY)!==t.deltaY||e&&Fr>2)&&0===t.deltaX,(t.shiftKey||t.metaKey||t.ctrlKey)&&(s=!0)}else s=!t.shiftKey&&(t.metaKey||t.ctrlKey);if(s){r=p.within(r,0,1);i=1-o/(25*(t.deltaY?e.delta.y:e.delta.x)*(1-r)+10),i<.5&&(i=.5),i>=1.5&&(i=1.5)}return i}},{getMoveEventData:Hr,getZoomEventData:Ur,getRotateEventData:Yr}=Er;class jr extends Ir{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp};const{viewEvents:e,windowEvents:s}=this;for(let s in e)e[s]=e[s].bind(this),t.addEventListener(s,e[s]);for(let t in s)s[t]=s[t].bind(this),window.addEventListener(t,s[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getLocal(t){const e=this.view.getBoundingClientRect();return{x:t.clientX-e.x,y:t.clientY-e.y}}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}onKeyDown(t){hs.setDownCode(t.code)}onKeyUp(t){hs.setUpCode(t.code)}onPointerDown(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMutiTouch||this.pointerDown(Wr.convert(t,this.getLocal(t)))}onPointerMove(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMutiTouch||this.pointerMove(Wr.convert(t,this.getLocal(t)))}onPointerUp(t){this.preventDefaultPointer(t),this.useMutiTouch||this.pointerUp(Wr.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMutiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(Wr.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerMove(Wr.convertMouse(t,this.getLocal(t)))}onMouseUp(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerUp(Wr.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(t.preventDefault(),this.mutiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=Wr.getTouch(t);this.pointerDown(Wr.convertTouch(t,this.getLocal(e)))}onTouchMove(t){if(t.preventDefault(),this.mutiTouchMove(t),this.usePointer)return;const e=Wr.getTouch(t);this.pointerMove(Wr.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(t.preventDefault(),this.mutiTouchEnd(),this.usePointer)return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=Wr.getTouch(t);this.pointerUp(Wr.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}mutiTouchStart(t){this.useMutiTouch=t.touches.length>=2,this.touches=this.useMutiTouch?Nr.getTouches(t.touches):void 0,this.useMutiTouch&&this.pointerCancel()}mutiTouchMove(t){if(this.useMutiTouch&&t.touches.length>=2){const e=Nr.getTouches(t.touches),s=e.find((t=>t.identifier===this.touches[0].identifier)),i=e.find((t=>t.identifier===this.touches[1].identifier));if(s&&i){const n=[this.getLocal(this.touches[0]),this.getLocal(this.touches[1])],r=[this.getLocal(s),this.getLocal(i)],{move:o,angle:a,scale:h,center:d}=Nr.getData(n,r),l=Er.getBase(t);this.rotate(Yr(d,a,l)),this.zoom(Ur(d,h,l)),this.move(Hr(d,o,l)),this.touches=e}}}mutiTouchEnd(){this.touches=null,this.useMutiTouch=!1,this.transformEnd()}onWheel(t){this.preventDefaultWheel(t);const{wheel:e}=this.config,s=e.getScale?e.getScale(t,e):zr.getScale(t,e),i=this.getLocal(t),n=Er.getBase(t);1!==s?this.zoom(Ur(i,s,n)):this.move(Hr(i,e.getMove?e.getMove(t,e):zr.getMove(t,e),n))}onGesturestart(t){this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0}onGesturechange(t){this.preventDefaultWheel(t);const e=this.getLocal(t),s=Er.getBase(t),i=t.scale/this.lastGestureScale,n=t.rotation-this.lastGestureRotation;let{rotateSpeed:r}=this.config.wheel;r=p.within(r,0,1),this.zoom(Ur(e,i*i,s)),this.rotate(Yr(e,n/Math.PI*180*(r/4+.1),s)),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.preventDefaultWheel(t),this.transformEnd()}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}Object.assign(Wt,{canvas:(t,e)=>new xr(t,e),image:t=>new br(t),hitCanvas:(t,e)=>new xr(t,e),interaction:(t,e,s,i)=>new jr(t,e,s,i)}),It.requestRender=function(t){window.requestAnimationFrame(t)},It.canvas=Wt.canvas(),navigator.userAgent.indexOf("Firefox")>-1&&(It.conicGradientRotate90=!0);const Xr={},Vr={},Gr={width:4,height:4};const Kr={width:4,height:4};var qr=Object.freeze({__proto__:null,blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__world.a),s.copyWorldToInner(e,t.__world,t.__layout.renderBounds),s.filter="none"},innerShadow:function(t,e,s){let i;const{__world:n,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:a,bounds:h,shapeBounds:d,scaleX:l,scaleY:c}=s,u=e.getBiggerCanvas(Kr.width,Kr.height),_=$.getOutOfBounds(h,e.bounds);o.forEach((t=>{u.save(),u.setWorldShadow(_.offsetX+t.x*l,_.offsetY+t.y*c,t.blur*l),u.copyWorld(s.canvas,d,t.spread?$.getSpread(_,-t.spread*l*(r.renderBounds.width/r.strokeBounds.width)):_),u.restore(),a?(u.copyWorld(u,h,n,"copy"),u.copyWorld(a,n,n,"source-out"),i=n):(u.copyWorld(s.canvas,d,h,"source-out"),i=h),u.fillWorld(i,t.color,"source-in"),e.copyWorldToInner(u,i,r.renderBounds,t.blendMode)})),u.recycle()},shadow:function(t,e,s){let i;const{__world:n,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:a,bounds:h,shapeBounds:d,scaleX:l,scaleY:c}=s,u=e.getBiggerCanvas(Gr.width,Gr.height),_=$.getOutOfBounds(h,e.bounds);o.forEach((t=>{u.setWorldShadow(_.offsetX+t.x*l,_.offsetY+t.y*c,t.blur*l,t.color),u.copyWorld(s.canvas,d,t.spread?$.getSpread(_,t.spread*l*(r.renderBounds.width/r.strokeBounds.width)):_),i=h,t.showBehind||(u.restore(),u.save(),a&&(u.copyWorld(u,h,n,"copy"),i=n),a?u.copyWorld(a,n,n,"destination-out"):u.copyWorld(s.canvas,d,h,"destination-out")),e.copyWorldToInner(u,i,r.renderBounds,t.blendMode)})),u.recycle()}});function Qr(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)s=i[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)})),n&&e.fillRect(s.x,s.y+n,s.width,r)}function Zr(t,e,s){const{strokeAlign:i}=t.__;switch(i){case"center":e.setStroke(s,t.__.strokeWidth,t.__),eo(t,e);break;case"inside":$r(t,e,s,"inside");break;case"outside":$r(t,e,s,"outside")}}function $r(t,e,s,i){const{strokeWidth:n,__font:r}=t.__,o=e.getSameCanvas(!0);o.setStroke(s,2*n,t.__),o.font=r,eo(t,o),o.blendMode="outside"===i?"destination-out":"destination-in",Qr(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}function Jr(t,e,s){const{strokeAlign:i}=t.__;switch(i){case"center":e.setStroke(void 0,t.__.strokeWidth,t.__),to(t,s,e);break;case"inside":$r(t,e,s,"inside");break;case"outside":!function(t,e,s,i){const{strokeWidth:n,__font:r}=t.__,o=e.getSameCanvas(!0);o.setStroke(void 0,2*n,t.__),o.font=r,to(t,s,o),o.blendMode="outside"===i?"destination - out":"destination -in ",Qr(t,o),o.blendMode="normal",e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}(t,e,s,"outside")}}function to(t,e,s){e.forEach((e=>{s.strokeStyle=e.style,e.blendMode?(s.saveBlendMode(e.blendMode),eo(t,s),s.restoreBlendMode()):eo(t,s)}))}function eo(t,e){let s;const{rows:i,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)s=i[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.strokeText(t.char,t.x,s.y)})),n&&e.strokeRect(s.x,s.y+n,s.width,r)}function so(t,e){t.forEach((t=>{e.strokeStyle=t.style,t.blendMode?(e.saveBlendMode(t.blendMode),e.stroke(),e.restoreBlendMode()):e.stroke()}))}const io={string(t,e){if("string"==typeof t)return t;let s=void 0===t.a?1:t.a;e&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}},{get:no,rotateOf:ro,translate:oo,scaleOf:ao,scale:ho,rotate:lo}=T;function co(t,e,s,n){let{type:r,blendMode:o}=s,a={type:r,blendMode:o,style:"rgba(255,255,255,0)"};const h=t.leafer.imageManager.get(s);if(h.ready){let t,{opacity:e,mode:i,offset:r,scale:o,rotation:d}=s,{width:l,height:c}=h;const u=n.width===l&&n.height===c;switch(i){case"strench":u||(l=n.width,c=n.height),(n.x||n.y)&&(t=no(),oo(t,n.x,n.y));break;case"clip":(r||o||d)&&(t=function(t,e,s,i){const n=no();oo(n,t.x,t.y),e&&oo(n,e.x,e.y);s&&("number"==typeof s?ho(n,s):ho(n,s.x,s.y));i&&lo(n,i);return n}(n,r,o,d));break;case"repeat":(!u||o||d)&&(t=function(t,e,s,i,n){const r=no();if(n)switch(lo(r,n),n){case 90:oo(r,s,0);break;case 180:oo(r,e,s);break;case 270:oo(r,0,e)}oo(r,t.x,t.y),i&&ao(r,t,i);return r}(n,l,c,o,d));break;default:u&&!d||(t=function(t,e,s,i,n){const r=no(),o=n&&180!==n,a=e.width/(o?i:s),h=e.height/(o?s:i),d="fit"===t?Math.min(a,h):Math.max(a,h),l=e.x+(e.width-s*d)/2,c=e.y+(e.height-i*d)/2;oo(r,l,c),ho(r,d),n&&ro(r,{x:e.x+e.width/2,y:e.y+e.height/2},n);return r}(i,n,l,c,d))}a.style=function(t,e,s){let i=It.canvas.createPattern(t,s?"repeat":"no-repeat");if(e){const{a:t,b:s,c:n,d:r,e:o,f:a}=e;i.setTransform(new DOMMatrix([t,s,n,r,o,a]))}return i}(h.getCanvas(l,c,e),t,"repeat"===i)}else h.load((()=>{t.__.__getInput("width")||(t.width=h.width),t.__.__getInput("height")||(t.height=h.height),t.forceUpdate("width"),t.emitEvent(new i(i.LOADED,t,h,e,s))}),(n=>{t.emitEvent(new i(i.ERROR,t,h,e,s,n))}));return a}const uo={x:.5,y:0},_o={x:.5,y:1};function po(t,e,s){let i;for(let n=0,r=e.length;n<r;n++)i=e[n],t.addColorStop(i.offset,io.string(i.color,s))}const{set:go,getAngle:fo,getDistance:yo}=A,{get:mo,rotateOf:vo,scaleOf:wo}=T,xo={x:.5,y:.5},Bo={x:.5,y:1},bo={},ko={};const{set:Eo,getAngle:To}=A,{get:Co,rotateOf:Ro,scaleOf:Po}=T,Lo={x:.5,y:.5},Oo={x:.5,y:1},So={},Do={};function Mo(t,e){let s,i=t.__.__input[e];const n=[];i instanceof Array||(i=[i]);for(let r=0,o=i.length;r<o;r++)s=Ao(t,i[r],e),s&&n.push(s);t.__["_"+e]=n.length?n:void 0}function Ao(t,e,s){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:o,opacity:a}=e;return{type:n,blendMode:r,style:io.string(o,a)};case"image":return co(t,s,e,i);case"linear":return function(t,e){let{from:s,to:i,type:n,blendMode:r,opacity:o}=t;s||(s=uo),i||(i=_o);const a=It.canvas.createLinearGradient(e.x+s.x*e.width,e.y+s.y*e.height,e.x+i.x*e.width,e.y+i.y*e.height);return po(a,t.stops,o),{type:n,blendMode:r,style:a}}(e,i);case"radial":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:o,stretch:a}=t;s||(s=xo),i||(i=Bo);const{x:h,y:d,width:l,height:c}=e;let u;go(bo,h+s.x*l,d+s.y*c),go(ko,h+i.x*l,d+i.y*c),(l!==c||a)&&(u=mo(),wo(u,bo,l/c*(a||1),1),vo(u,bo,fo(bo,ko)+90));const _=It.canvas.createRadialGradient(bo.x,bo.y,0,bo.x,bo.y,yo(bo,ko));return po(_,t.stops,r),{type:n,blendMode:o,style:_,transform:u}}(e,i);case"angular":return function(t,e){let{from:s,to:i,type:n,opacity:r,blendMode:o,stretch:a}=t;s||(s=Lo),i||(i=Oo);const{x:h,y:d,width:l,height:c}=e;Eo(So,h+s.x*l,d+s.y*c),Eo(Do,h+i.x*l,d+i.y*c);const u=Co(),_=To(So,Do);It.conicGradientRotate90?(Po(u,So,l/c*(a||1),1),Ro(u,So,_+90)):(Po(u,So,1,l/c*(a||1)),Ro(u,So,_));const p=It.canvas.createConicGradient(0,So.x,So.y);return po(p,t.stops,r),{type:n,blendMode:o,style:p,transform:u}}(e,i);default:return e.r?{type:"solid",style:io.string(e)}:void 0}}var Io=Object.freeze({__proto__:null,computeFill:function(t){Mo(t,"fill")},computeStroke:function(t){Mo(t,"stroke")},drawText:Qr,drawTextStroke:eo,fill:function(t,e,s){e.fillStyle=s,t.__.__font?Qr(t,e):e.fill(t.__.windingRule)},fills:function(t,e,s){let i;const{windingRule:n,__font:r}=t.__;for(let o=0,a=s.length;o<a;o++)if(i=s[o],e.fillStyle=i.style,i.transform){e.save();const{a:s,b:o,c:a,d:h,e:d,f:l}=i.transform;e.transform(s,o,a,h,d,l),i.blendMode&&(e.blendMode=i.blendMode),r?Qr(t,e):e.fill(n),e.restore()}else i.blendMode?(e.saveBlendMode(i.blendMode),r?Qr(t,e):e.fill(n),e.restoreBlendMode()):r?Qr(t,e):e.fill(n)},shape:function(t,e,s){const i=e.getSameCanvas();let n,r,o,a;const{__world:h}=t;let{a:d,d:l}=h;if(e.bounds.includes(h,s.matrix))n=o=h,a=i;else{const{renderBoundsSpreadWidth:i}=t.__layout,c=$.getIntersectData(i?$.getSpread(e.bounds,i*h.a):e.bounds,h,s.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,s),d*=r.a,l*=r.d),o=$.getOuterOf(h,r),n=$.getByMove(o,-r.e,-r.f),s.matrix&&r.multiply(s.matrix),s=Object.assign(Object.assign({},s),{matrix:r})}return t.__renderShape(i,s),{canvas:i,matrix:r,bounds:n,worldCanvas:a,shapeBounds:o,scaleX:d,scaleY:l}},stroke:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:o}=i;if(o)Zr(t,e,s);else switch(r){case"center":e.setStroke(s,n,i),e.stroke();break;case"inside":e.save(),e.setStroke(s,2*n,i),e.clip(i.windingRule),e.stroke(),e.restore();break;case"outside":const r=e.getSameCanvas(!0);r.setStroke(s,2*n,t.__),t.__drawRenderPath(r),r.stroke(),r.clip(i.windingRule),r.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(r,t.__world,t.__layout.renderBounds),r.recycle()}},strokeText:Zr,strokes:function(t,e,s){const i=t.__,{strokeWidth:n,strokeAlign:r,__font:o}=i;if(o)Jr(t,e,s);else switch(r){case"center":e.setStroke(void 0,n,i),so(s,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,i),e.clip(i.windingRule),so(s,e),e.restore();break;case"outside":const{renderBounds:r}=t.__layout,o=e.getSameCanvas(!0);t.__drawRenderPath(o),o.setStroke(void 0,2*n,t.__),so(s,o),o.clip(i.windingRule),o.clearWorld(r),e.copyWorldToInner(o,t.__world,r),o.recycle()}},strokesText:Jr});Object.assign(Xr,qr),Object.assign(Vr,Io);class Wo extends yt{setFill(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxBoundsChanged?this._fill=t:Vr.computeFill(this.__leaf),this.__isFills=!0):(this._fill=t,this.__input&&this.__removeInput("fill"),this.__isFills&&(this.__isFills=!1))}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxBoundsChanged?this._stroke=t:Vr.computeStroke(this.__leaf),this.__isStrokes=!0):(this._stroke=t,this.__input&&this.__removeInput("stroke"),this.__isStrokes&&(this.__isStrokes=!1))}setShadow(t){this._shadow=t instanceof Array?t:t?[t]:t}setInnerShadow(t){t instanceof Array?this._innerShadow=t:t?this._innerShadow=[t]:this._shadow=t}}const No={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class Fo extends Wo{}class zo extends Fo{}const{parse:Ho}=Mi;const Uo={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Yo extends Wo{}function jo(t){return(e,s)=>{re(e,s,t,{set(t){this.__setAttr(s,t),this.__.__useEffect=!0,this.__layout.renderBoundsChanged||this.__layout.renderBoundsChange()}})}}const Xo={__updateStrokeBoundsSpreadWidth(){let t=0;const{stroke:e,hitStroke:s,strokeAlign:i,strokeWidth:n}=this.__;if((e||"always"===s)&&n&&"inside"!==i){t="center"===i?n/2:n,this.__.__strokeOuterWidth=t;const{miterLimit:e,strokeCap:s,path:r}=this.__;if(r){const i=1/Math.sin(e*g/2)*Math.sqrt(n)-t,r="none"===s?0:n;t+=Math.max(i,r)}}return t||(this.__.__strokeOuterWidth=0),t},__updateRenderBoundsSpreadWidth(){let t=0;const{shadow:e,innerShadow:s,blur:i,backgroundBlur:n}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),i&&(t=Math.max(t,i));let r=t=Math.ceil(t);return s&&s.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),n&&(r=Math.max(r,n)),this.__layout.renderShapeBoundsSpreadWidth=r,t}},Vo={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this)),this.__drawHitPath(this.__hitCanvas),this.__hitCanvas.setStrokeOptions(this.__)},__hit(t){const{__hitCanvas:e}=this,{fill:s,hitFill:i,windingRule:n}=this.__,r=s&&"visible"===i||"always"===i;if(r&&e.hitFill(t,n))return!0;const{stroke:o,hitStroke:a,strokeWidth:h,strokeAlign:d}=this.__,l=o&&"visible"===a||"always"===a,c=2*t.radiusX;let u=2*(l?"center"===d?h/2:h:0)+c;if(!u)return!1;switch(d){case"inside":if(!r&&e.hitFill(t,n)&&e.hitStroke(t,u))return!0;u=c;break;case"outside":if(!r){if(!e.hitFill(t,n)&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Go={__updateChange(){let t=this.__;t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i,__drawAfterFill:n}=this.__;this.__drawRenderPath(t),s&&Vr.fill(this,t,s),n&&this.__drawAfterFill(t,e),i&&Vr.stroke(this,t,i)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:n,__font:r}=this.__;if(r?t.font=r:this.__drawRenderPath(t),this.__.__useEffect){const r=Vr.shape(this,t,e),{shadow:o,innerShadow:a}=this.__;o&&Xr.shadow(this,t,r),s&&(this.__.__isFills?Vr.fills(this,t,s):Vr.fill(this,t,s)),n&&this.__drawAfterFill(t,e),a&&Xr.innerShadow(this,t,r),i&&(this.__.__isStrokes?Vr.strokes(this,t,i):Vr.stroke(this,t,i)),r.worldCanvas&&r.worldCanvas.recycle(),r.canvas.recycle()}else s&&(this.__.__isFills?Vr.fills(this,t,s):Vr.fill(this,t,s)),n&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?Vr.strokes(this,t,i):Vr.stroke(this,t,i))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:i,__font:n}=this.__;if(n?t.font=n:this.__drawRenderPath(t),s&&(t.fillStyle="#000000",n?Vr.drawText(this,t):t.fill()),i){const{strokeWidth:e,strokeAlign:s}=this.__;"inside"!==s&&(t.setStroke("#000000","outside"===s?2*e:e,this.__),n?Vr.drawTextStroke(this,t):t.stroke())}}},Ko={__drawFast(t,e){const{width:s,height:i,fill:n,stroke:r,__drawAfterFill:o}=this.__;if(n&&(t.fillStyle=n,t.fillRect(0,0,s,i)),o&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,strokeWidth:n}=this.__;t.setStroke(r,n,this.__);const o=n/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(o,o,s-n,i-n);break;case"outside":t.strokeRect(-o,-o,s+n,i+n)}}}},qo={__drawFast(t,e){const{fill:s,stroke:i}=this.__,{__font:n}=this.__;t.font=n,s&&(t.fillStyle=s,Vr.drawText(this,t)),i&&Vr.strokeText(this,t,i)}};let Qo=class extends Ze{constructor(t){super(t)}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&Vr.computeFill(this),e&&Vr.computeStroke(this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?dr.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}static one(t,e,s,i,n){return Ft.get(t.tag||this.prototype.__tag,t,e,s,i,n)}};Vt([we(Wo)],Qo.prototype,"__",void 0),Vt([oe("")],Qo.prototype,"id",void 0),Vt([oe("")],Qo.prototype,"name",void 0),Vt([oe("")],Qo.prototype,"className",void 0),Vt([ge()],Qo.prototype,"blendMode",void 0),Vt([fe(1)],Qo.prototype,"opacity",void 0),Vt([fe(!0)],Qo.prototype,"visible",void 0),Vt([me(!1)],Qo.prototype,"isMask",void 0),Vt([ye(0)],Qo.prototype,"zIndex",void 0),Vt([oe()],Qo.prototype,"locked",void 0),Vt([ae(0)],Qo.prototype,"x",void 0),Vt([ae(0)],Qo.prototype,"y",void 0),Vt([le(100)],Qo.prototype,"width",void 0),Vt([le(100)],Qo.prototype,"height",void 0),Vt([he(1)],Qo.prototype,"scaleX",void 0),Vt([he(1)],Qo.prototype,"scaleY",void 0),Vt([de(0)],Qo.prototype,"rotation",void 0),Vt([de(0)],Qo.prototype,"skewX",void 0),Vt([de(0)],Qo.prototype,"skewY",void 0),Vt([oe(!1)],Qo.prototype,"draggable",void 0),Vt([ve(!0)],Qo.prototype,"hittable",void 0),Vt([ve("visible")],Qo.prototype,"hitFill",void 0),Vt([_e("visible")],Qo.prototype,"hitStroke",void 0),Vt([ve(!0)],Qo.prototype,"hitChildren",void 0),Vt([ve(!0)],Qo.prototype,"hitSelf",void 0),Vt([ge()],Qo.prototype,"fill",void 0),Vt([_e()],Qo.prototype,"stroke",void 0),Vt([_e("inside")],Qo.prototype,"strokeAlign",void 0),Vt([_e(1)],Qo.prototype,"strokeWidth",void 0),Vt([_e("none")],Qo.prototype,"strokeCap",void 0),Vt([_e("miter")],Qo.prototype,"strokeJoin",void 0),Vt([_e()],Qo.prototype,"dashPattern",void 0),Vt([_e()],Qo.prototype,"dashOffset",void 0),Vt([_e(10)],Qo.prototype,"miterLimit",void 0),Vt([ce()],Qo.prototype,"cornerRadius",void 0),Vt([ce()],Qo.prototype,"cornerSmoothing",void 0),Vt([jo()],Qo.prototype,"shadow",void 0),Vt([jo()],Qo.prototype,"innerShadow",void 0),Vt([jo()],Qo.prototype,"blur",void 0),Vt([jo()],Qo.prototype,"backgroundBlur",void 0),Vt([jo()],Qo.prototype,"grayscale",void 0),Vt([Ee(Ln.drawPathByData)],Qo.prototype,"__drawPathByData",null),Qo=Vt([Re(Xo),Re(Vo),Re(Go),Te()],Qo);let Zo=class extends Qo{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.isBranch=!0,this.children=[]}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}remove(t){}};Vt([we(Fo)],Zo.prototype,"__",void 0),Zo=Vt([Re(os),Pe()],Zo);let $o=class extends Qo{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:i,cornerRadius:n}=this.__;n?t.roundRect(0,0,s,i,n):t.rect(0,0,s,i)}};Vt([we(class extends Wo{})],$o.prototype,"__",void 0),$o=Vt([Re(Ko),Pe()],$o);const Jo=$o.prototype,ta=Zo.prototype,ea={},{copy:sa,add:ia}=$;let na=class extends Zo{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderBoundsChanged||this.__layout.renderBoundsChange()}__updateStrokeBoundsSpreadWidth(){return 0}__updateRectRenderBoundsSpreadWidth(){return 0}__updateRenderBoundsSpreadWidth(){let t=this.__updateRectRenderBoundsSpreadWidth()||super.__updateRenderBoundsSpreadWidth();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;sa(ea,t),super.__updateRenderBounds(),ia(t,ea)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};Vt([we(zo)],na.prototype,"__",void 0),Vt([pe("show")],na.prototype,"overflow",void 0),Vt([Ee(Jo.__updateStrokeBoundsSpreadWidth)],na.prototype,"__updateStrokeBoundsSpreadWidth",null),Vt([Ee(Jo.__updateRenderBoundsSpreadWidth)],na.prototype,"__updateRectRenderBoundsSpreadWidth",null),Vt([Ee(Jo.__updateBoxBounds)],na.prototype,"__updateBoxBounds",null),Vt([Ee(Jo.__updateStrokeBounds)],na.prototype,"__updateStrokeBounds",null),Vt([Ee(Jo.__updateRenderBounds)],na.prototype,"__updateRectRenderBounds",null),Vt([Ee(Jo.__updateChange)],na.prototype,"__updateRectChange",null),Vt([Ee(Jo.__drawPathByData)],na.prototype,"__drawPathByData",null),Vt([Ee(Jo.__render)],na.prototype,"__renderRect",null),Vt([Ee(ta.__render)],na.prototype,"__renderGroup",null),na=Vt([Te(),Pe()],na);let ra=class extends na{get __tag(){return"Frame"}constructor(t){super(t),this.__.fill||(this.__.fill="#FFFFFF")}};Vt([we(class extends zo{})],ra.prototype,"__",void 0),Vt([pe("hide")],ra.prototype,"overflow",void 0),ra=Vt([Pe()],ra);const{moveTo:oa,closePath:aa,ellipse:ha}=$i;let da=class extends Qo{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:n}=this.__,r=t/2,o=e/2,a=this.__.path=[];s?i||n?(s<1&&ha(a,r,o,r*s,o*s,0,i,n,!1),ha(a,r,o,r,o,0,n,i,!0),s<1&&aa(a)):(s<1&&(ha(a,r,o,r*s,o*s),oa(a,t,o)),ha(a,r,o,r,o,0,0,360,!0)):i||n?(oa(a,r,o),ha(a,r,o,r,o,0,i,n,!1),aa(a)):ha(a,r,o,r,o)}};Vt([we(class extends Wo{})],da.prototype,"__",void 0),Vt([ce(0)],da.prototype,"innerRadius",void 0),Vt([ce(0)],da.prototype,"startAngle",void 0),Vt([ce(0)],da.prototype,"endAngle",void 0),da=Vt([Pe()],da);const{sin:la,cos:ca,PI:ua}=Math,{moveTo:_a,lineTo:pa,closePath:ga}=$i;let fa=class extends Qo{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,sides:s}=this.__,i=t/2,n=e/2,r=this.__.path=[];_a(r,i,0);for(let t=1;t<s;t++)pa(r,i+i*la(2*t*ua/s),n-n*ca(2*t*ua/s));ga(r)}};Vt([we(class extends Wo{})],fa.prototype,"__",void 0),Vt([ce(3)],fa.prototype,"sides",void 0),fa=Vt([Pe()],fa);const{sin:ya,cos:ma,PI:va}=Math,{moveTo:wa,lineTo:xa,closePath:Ba}=$i;let ba=class extends Qo{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,points:s,innerRadius:i}=this.__,n=t/2,r=e/2,o=this.__.path=[];wa(o,n,0);for(let t=1;t<2*s;t++)xa(o,n+(t%2==0?n:n*i)*ya(t*va/s),r-(t%2==0?r:r*i)*ma(t*va/s));Ba(o)}};Vt([we(class extends Wo{})],ba.prototype,"__",void 0),Vt([ce(5)],ba.prototype,"points",void 0),Vt([ce(.382)],ba.prototype,"innerRadius",void 0),ba=Vt([Pe()],ba);const{moveTo:ka,lineTo:Ea}=$i,{rotate:Ta,getAngle:Ca,getDistance:Ra,defaultPoint:Pa}=A,{setPoint:La,addPoint:Oa,toBounds:Sa}=F,Da={};let Ma=class extends Qo{get __tag(){return"Line"}get toPoint(){if(this.__toPoint&&!this.__layout.boxBoundsChanged)return this.__toPoint;const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&Ta(s,e),this.__toPoint=s,s}set toPoint(t){this.width=Ra(Pa,t),this.rotation=Ca(Pa,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];ka(t,0,0);const e=this.toPoint;Ea(t,e.x,e.y)}__updateBoxBounds(){La(Da,0,0),Oa(Da,this.__toPoint.x,this.__toPoint.y),Sa(Da,this.__layout.boxBounds)}};Vt([we(class extends Wo{})],Ma.prototype,"__",void 0),Vt([le()],Ma.prototype,"rotation",void 0),Vt([ue("center")],Ma.prototype,"strokeAlign",void 0),Ma=Vt([Pe()],Ma);let Aa=class extends $o{get __tag(){return"Image"}get ready(){var t;return null===(t=this.image)||void 0===t?void 0:t.ready}constructor(t){super(t)}__updateBoxBounds(){let t;const{url:e}=this,s=this.fill;s?s.url!==e&&(t=!0):e&&(t=!0),t&&(this.image&&(this.image=null),this.fill={type:"image",mode:"strench",url:e},this.once(i.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}};Vt([we(Yo)],Aa.prototype,"__",void 0),Vt([le("")],Aa.prototype,"url",void 0),Aa=Vt([Pe()],Aa);let Ia=class extends $o{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=Wt.canvas(t),this.context=this.canvas.context,this.__.hitType="all",this.__.pixelRatio=this.canvas.pixelRatio}draw(t,e,s,i){t.__layout.checkUpdate();const n=new N(t.__world);n.invert();const r=new N;e&&r.translate(e.x,e.y),s&&("number"==typeof s?r.scale(s):r.scale(s.x,s.y)),i&&r.rotate(i),n.preMultiply(r),t.__render(this.canvas,{matrix:n}),this.forceUpdate("fill")}__draw(t,e){t.drawImage(this.canvas.view,0,0)}__updateBoxBounds(){super.__updateBoxBounds(),this.canvas.resize(this.__)}};Vt([we(Yo)],Ia.prototype,"__",void 0),Vt([le("")],Ia.prototype,"pixelRatio",void 0),Vt([ge("true")],Ia.prototype,"smooth",void 0),Ia=Vt([Pe()],Ia);const Wa=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’“!?,、。:;‰",Na=Wa+"_#~&*+\\=|≮≯≈≠=…";function Fa(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const za=Fa("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ha=Fa("{[(<'\"《(「〈『〖【〔{┌<’“=¥¥$€££¢¢"),Ua=Fa(Wa),Ya=Fa(Na),ja=Fa("- —/~|┆·");var Xa;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Xa||(Xa={}));const{Letter:Va,Single:Ga,Before:Ka,After:qa,Symbol:Qa,Break:Za}=Xa;function $a(t){return za[t]?Va:ja[t]?Za:/[\u3400-\u9FBF]/.test(t)?Ga:Ha[t]?Ka:Ua[t]?qa:Ya[t]?Qa:Va}const Ja={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let r=n-1;r>-1&&(s=e[r].data[0]," "===s.char);r--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function th(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:eh}=Ja,{Letter:sh,Single:ih,Before:nh,After:rh,Symbol:oh,Break:ah}=Xa;let hh,dh,lh,ch,uh,_h,ph,gh,fh,yh,mh,vh,wh,xh,Bh=[];function bh(t,e){hh.data.push({char:t,width:e}),lh+=e}function kh(){ch+=lh,hh.width=lh,dh.words.push(hh),hh={data:[]},lh=0}function Eh(){vh&&(wh.paraNumber++,dh.paraStart=!0,vh=!1),dh.width=ch,eh(dh),Bh.push(dh),dh.width>xh.width&&(xh.width=dh.width),dh={words:[]},ch=0}const Th=0,Ch=1,Rh=2;const Ph={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let s=0,i=0,{width:n,height:r,padding:o}=e;const{textDecoration:a,textOverflow:h,fontSize:d,__font:l}=e;if(n||(n=0),r=Math.max(r,d),o){const[t,e,a,h]=p.fourNumber(o);n&&(s=h,n-=e+h),r&&(i=t,r-=t+a)}const c={bounds:{x:s,y:i,width:n,height:r},rows:[],paraNumber:0,font:It.canvas.font=l};return function(t,e,s){wh=t,Bh=t.rows,xh=t.bounds;const{__letterSpacing:i,paraIndent:n,textCase:r}=s,{canvas:o}=It,{width:a,height:h}=xh;if(a||h||i||r){vh=!0,fh=null,lh=ch=0,hh={data:[]},dh={words:[]};for(let t=0,s=e.length;t<s;t++)_h=e[t],"\n"===_h?(lh&&kh(),dh.paraEnd=!0,Eh(),vh=!0):(gh=$a(_h),gh===sh&&"none"!==r&&(_h=th(_h,r,!lh)),ph=o.measureText(_h).width,i&&(ph+=i),yh=gh===ih&&(fh===ih||fh===sh)||fh===ih&&gh!==rh,mh=!(gh!==nh&&gh!==ih||fh!==oh&&fh!==rh),uh=vh&&n?a-n:a,ch+lh+ph>uh&&(mh||(mh=gh===sh&&fh==rh),yh||mh||gh===ah||gh===nh||gh===ih||lh+ph>uh?(lh&&kh(),Eh()):Eh())," "===_h&&ch+lh===0||(gh===ah?(" "===_h&&lh&&kh(),bh(_h,ph),kh()):yh||mh?(lh&&kh(),bh(_h,ph)):bh(_h,ph)),fh=gh);lh&&kh(),ch&&Eh(),Bh[Bh.length-1].paraEnd=!0}else e.split("\n").forEach((t=>{wh.paraNumber++,Bh.push({x:n||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(c,t,e),function(t,e){const{rows:s,bounds:i}=t,{__lineHeight:n,__baseLine:r,textAlign:o,verticalAlign:a,paraSpacing:h,textOverflow:d}=e;let l,{x:c,y:u,width:_,height:p}=i,g=n*s.length+(h?h*(t.paraNumber-1):0),f=r;if(p){if("show"!==d&&g>p)g=Math.max(p,n),t.overflow=s.length;else switch(a){case"middle":u+=(p-g)/2;break;case"bottom":u+=p-g}f+=u}for(let e=0,i=s.length;e<i;e++){switch(l=s[e],l.x=c,o){case"center":l.x+=(_-l.width)/2;break;case"right":l.x+=_-l.width}l.paraStart&&h&&e>0&&(f+=h),l.y=f,f+=n,t.overflow>e&&f>g&&(l.isOverflow=!0,t.overflow=e+1)}i.y=u,i.height=g}(c,e),function(t,e,s,i){const{rows:n}=t,{textAlign:r,paraIndent:o,letterSpacing:a}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,d=s&&"justify"===r&&t.words.length>1?(s-t.width-l)/(t.words.length-1):0,c=a||t.isOverflow?Th:d>.01?Ch:Rh,c===Rh?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{c===Ch?(u={char:"",x:h},h=function(t,e,s){return t.forEach((t=>{s.char+=t.char,e+=t.width})),e}(e.data,h,u)," "!==u.char&&t.data.push(u)):h=function(t,e,s){return t.forEach((t=>{" "!==t.char&&(t.x=e,s.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(c,e,n),c.overflow&&function(t,e){const{rows:s,overflow:i}=t;if(s.splice(i),"hide"!==e){"ellipsis"===e&&(e="...");const n=It.canvas.measureText(e).width,r=s[i-1];let o,a,h=r.data.length-1;const{x:d,width:l}=t.bounds,c=d+l-n;for(let t=h;t>-1&&(o=r.data[t],a=o.x+o.width,!(t===h&&a<c));t--){if(a<c&&" "!==o.char){r.data.splice(t+1),r.width-=o.width;break}r.width-=o.width}r.width+=n,r.data.push({char:e,x:a})}}(c,h),"none"!==a&&function(t,e){const{fontSize:s}=e;switch(t.decorationHeight=s/11,e.textDecoration){case"underline":t.decorationY=.15*s;break;case"delete":t.decorationY=.35*-s}}(c,e),c}},{copyAndSpread:Lh,includes:Oh,spread:Sh}=$;let Dh=class extends Qo{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:i}=this.__;t.beginPath(),i.rows.forEach((i=>t.rect(i.x,i.y-s,i.width,e)))}__drawPathByData(t,e){const{x:s,y:i,width:n,height:r}=this.__layout.boxBounds;t.rect(s,i,n,r)}__updateTextDrawData(){const t=this.__;t.__textDrawData=Ph.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{width:s,height:i,lineHeight:n,letterSpacing:r,fontFamily:o,fontSize:a,fontWeight:h,italic:d}=t;t.__lineHeight=No.number(n,a),t.__letterSpacing=No.number(r,a),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*a)/2,t.__font=`${d?"italic ":""}${"normal"!==h?h+" ":""}${a}px ${o}`,this.__updateTextDrawData();const{bounds:l}=t.__textDrawData,c=e.boxBounds;t.__lineHeight<a&&Sh(l,a/2),s&&i?super.__updateBoxBounds():(c.x=s?0:l.x,c.y=i?0:l.y,c.width=s||l.width,c.height=i||l.height);const u=Oh(c,l)?c:l;u!==e.contentBounds&&(e.contentBounds=u,e.renderBoundsChanged=!0)}__updateRenderBoundsSpreadWidth(){let t=super.__updateRenderBoundsSpreadWidth();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Lh(this.__layout.renderBounds,this.__layout.contentBounds,this.__layout.renderBoundsSpreadWidth)}};Vt([we(class extends Wo{setFontWeight(t){this._fontWeight="string"==typeof t?Uo[t]||400:t}})],Dh.prototype,"__",void 0),Vt([le(0)],Dh.prototype,"width",void 0),Vt([le(0)],Dh.prototype,"height",void 0),Vt([le(0)],Dh.prototype,"padding",void 0),Vt([ue("outside")],Dh.prototype,"strokeAlign",void 0),Vt([le("")],Dh.prototype,"text",void 0),Vt([le("L")],Dh.prototype,"fontFamily",void 0),Vt([le(12)],Dh.prototype,"fontSize",void 0),Vt([le("normal")],Dh.prototype,"fontWeight",void 0),Vt([le(!1)],Dh.prototype,"italic",void 0),Vt([le("none")],Dh.prototype,"textCase",void 0),Vt([le("none")],Dh.prototype,"textDecoration",void 0),Vt([le(0)],Dh.prototype,"letterSpacing",void 0),Vt([le({type:"percent",value:150})],Dh.prototype,"lineHeight",void 0),Vt([le(0)],Dh.prototype,"paraIndent",void 0),Vt([le(0)],Dh.prototype,"paraSpacing",void 0),Vt([le("left")],Dh.prototype,"textAlign",void 0),Vt([le("top")],Dh.prototype,"verticalAlign",void 0),Vt([le("show")],Dh.prototype,"textOverflow",void 0),Dh=Vt([Re(qo),Pe()],Dh);const{toBounds:Mh}=hr;let Ah=class extends Qo{get __tag(){return"Path"}constructor(t){super(t)}getCurvePath(){return Mi.toCanvasData(this.__.path,!0)}getStringPath(t){let e=this.__.path;return t&&(e=Mi.toCanvasData([...e],!0)),Mi.stringify(e)}__updateBoxBounds(){Mh(this.__.path,this.__layout.boxBounds)}};Vt([we(class extends Wo{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Ho(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],Ah.prototype,"__",void 0),Vt([ce()],Ah.prototype,"path",void 0),Vt([ce()],Ah.prototype,"windingRule",void 0),Vt([ue("center")],Ah.prototype,"strokeAlign",void 0),Ah=Vt([Pe()],Ah);let Ih=class extends Zo{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ah(t);return this.pathStyle=t,this.path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,i,n,r){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,n){return this}ellipse(t,e,s,i,n,r,o,a){return this}arc(t,e,s,i,n,r){return this}arcTo(t,e,s,i,n){return this}moveToEllipse(t,e,s,i,n,r,o,a){return this}moveToArc(t,e,s,i,n,r){return this}paint(){this.pathElement.forceUpdate("path")}};Vt([we(class extends Fo{})],Ih.prototype,"__",void 0),Ih=Vt([Re(gn,["beginPath"]),Pe()],Ih);let Wh=class extends Zo{get __tag(){return"Vector"}constructor(t){super(t)}__updatePath(){}};Vt([we(class extends Wo{})],Wh.prototype,"__",void 0),Vt([ce()],Wh.prototype,"paths",void 0),Wh=Vt([Pe()],Wh);const Nh=mt.get("LeaferType"),Fh={list:{},register(t,e){zh[t]?Nh.error("repeat:",t):zh[t]=e},run(t,e){const s=Fh.list[t];s?s(e):Nh.error("no",t)}},{list:zh}=Fh;Fh.register("user",(function(t){const{config:e}=t;e.pointer||(e.pointer={}),e.pointer.autoMoveDistance=0})),Fh.register("design",(function(t){const{MOVE:e}=gs,{ZOOM:s}=ms;t.__eventIds.push(t.on__(e,(e=>{rt.move(t.moveLayer,e.moveX,e.moveY)})),t.on__(s,(e=>{rt.zoomOf(t.zoomLayer,e,e.scale)})))}));const Hh=mt.get("Leafer");let Uh=class extends Zo{get __tag(){return"Leafer"}get isApp(){return!1}constructor(t,e){super(e),this.zoomLayer=this,this.moveLayer=this,this.config={type:"design",start:!0,hittable:!0},this.__eventIds=[],this.__controllers=[],this.userConfig=t,(null==t?void 0:t.view)&&this.init(t)}init(t,e){if(this.canvas)return;let s;this.__setLeafer(this),t&&gt.assign(this.config,t);const{config:i}=this;Fh.run(i.type,this),this.canvas=Wt.canvas(i),this.__controllers.push(this.renderer=Wt.renderer(this,this.canvas,i),this.watcher=Wt.watcher(this,i),this.layouter=Wt.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=Wt.selector(this),this.__controllers.unshift(this.interaction=Wt.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new jt,this.hitCanvasManager=new Xt,this.imageManager=new ws(this,i),s=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this)))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(d.RESTART):this.emitLeafer(d.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(d.STOP))}resize(t){const e=gt.copyAttrs({},t,ee);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=gt.copyAttrs({},this.canvas,ee);this.canvas.resize(t),this.__onResize(new n(t,e))}__onResize(t){this.emitEvent(t),gt.copyAttrs(this.__,t,ee),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager,this.imageManager=t.imageManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new it(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(ee.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&this.canvas.setHittable(e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&ee.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=gt.copyAttrs({},this.canvas,ee);s[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.setBackgroundColor(t):this.forceFullRender()}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(d.BEFORE_READY),this.emitLeafer(d.READY),this.emitLeafer(d.AFTER_READY))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(d.VIEW_READY))}__checkUpdateLayout(){this.__layout.checkUpdate()}emitLeafer(t){this.emitEvent(new d(t,this))}__listenEvents(){const t=xt.start("FirstCreate "+this.innerName);this.once(d.START,(()=>xt.end(t))),this.once(a.END,(()=>this.__onReady())),this.once(h.END,(()=>this.__onViewReady())),this.on(a.CHECK_UPDATE,(()=>this.__checkUpdateLayout()))}__removeListenEvents(){this.off__(this.__eventIds)}destory(){if(this.canvas)try{this.stop(),this.emitEvent(new d(d.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>t.destroy())),this.__controllers.length=0,this.selector.destroy(),this.canvasManager.destory(),this.hitCanvasManager.destory(),this.imageManager.destory(),this.canvas.destroy(),this.canvas=null,this.config=this.userConfig=this.view=null,super.destroy()}catch(t){Hh.error(t)}}};Vt([we(class extends Fo{})],Uh.prototype,"__",void 0),Vt([le()],Uh.prototype,"pixelRatio",void 0),Uh=Vt([Pe()],Uh);let Yh=class extends Uh{constructor(){super(...arguments),this.children=[]}get __tag(){return"App"}get isApp(){return!0}__setApp(){const{canvas:t}=this,{realCanvas:e,view:i}=this.config;e||i===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on__(s.CHANGE,(()=>{mt.showHitView&&this.children.forEach((t=>{t.forceUpdate("blendMode")}))})))}start(){super.start(),this.children.forEach((t=>{t.start()}))}stop(){this.children.forEach((t=>{t.stop()})),super.stop()}addLeafer(t){const e=new Uh(t);return this.add(e),e}add(t){t.view||t.init(this.__getChildConfig(t.userConfig),this),super.add(t),t.once(a.END,(()=>{!this.ready&&this.children.every((t=>t.ready))&&this.__onReady()})),t.once(h.END,(()=>{!this.viewReady&&this.children.every((t=>t.viewReady))&&this.__onViewReady()})),this.realCanvas&&this.__eventIds.push(t.on__(h.END,this.__onChildRenderEnd,this))}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>{t.copyWorld(e.canvas)}))}__onResize(t){this.children.forEach((e=>{e.resize(t)})),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>{t.__layout.checkUpdate()}))}__getChildConfig(t){let e=Object.assign({},this.config);return t&&gt.assign(e,t),e.view=this.realCanvas?void 0:this.view,e.fill=e.hittable=e.realCanvas=void 0,this.autoLayout&&gt.copyAttrs(e,this,ee),e}destory(){this.children.forEach((t=>{t.destory()})),this.children.length=0,super.destory()}};Yh=Vt([Pe()],Yh);var jh=Object.freeze({__proto__:null,Animate:{},get App(){return Yh},AutoBounds:it,BezierHelper:Hs,Bounds:st,BoundsHelper:$,get Box(){return na},get Branch(){return os},BranchHelper:ct,get Canvas(){return Ia},CanvasManager:jt,ChildEvent:e,Creator:Wt,DataHelper:gt,Debug:mt,get DragEvent(){return us},get DropEvent(){return ps},Effect:Xr,get Ellipse(){return da},EllipseHelper:Qs,Event:t,EventCreator:Ut,Export:{},get Frame(){return ra},get Group(){return Zo},HitCanvasManager:Xt,get Image(){return Aa},ImageEvent:i,ImageManager:ws,IncrementId:u,Interaction:jr,get KeyEvent(){return vs},Keyboard:hs,LayoutEvent:a,Layouter:At,get Leaf(){return Ze},LeafBounds:Ye,LeafBoundsHelper:lt,LeafData:yt,LeafDataProxy:Ie,LeafEventer:Me,LeafHelper:rt,LeafHit:Ve,LeafLevelList:c,LeafList:l,LeafMask:Ke,LeafMatrix:ze,LeafRender:Ge,get Leafer(){return Uh},LeaferCanvas:xr,LeaferCanvasBase:se,LeaferEvent:d,LeaferImage:br,get Line(){return Ma},MathHelper:p,Matrix:N,MatrixHelper:T,get MoveEvent(){return gs},NeedConvertToCanvasCommandMap:Es,OneRadian:g,PI2:f,PI_2:y,Paint:Vr,get Path(){return Ah},PathBounds:hr,PathCommandDataHelper:$i,PathCommandMap:bs,PathConvert:Mi,PathCorner:dr,PathCreator:gn,PathDrawer:Ln,PathHelper:xs,PathNumberCommandLengthMap:Ps,PathNumberCommandMap:Rs,get Pen(){return Ih},Platform:It,Plugin:cr,Point:W,PointHelper:A,PointerButton:ds,get PointerEvent(){return cs},get Polygon(){return fa},PropertyEvent:s,get Rect(){return $o},RectHelper:Ls,RectRender:Ko,RenderEvent:h,Renderer:fr,ResizeEvent:n,get RotateEvent(){return fs},Run:xt,Selector:vr,get Star(){return ba},StringNumberMap:nt,get SwipeEvent(){return ys},TaskItem:ur,TaskProcessor:class{get isComplete(){return this._isComplete}get running(){return this._running}constructor(t){this.parallel=6,this.params={},this.list=[],this.index=0,t&&(this.params=t,t.parallel&&(this.parallel=t.parallel)),this.init()}get percent(){const t=this.list.length;let e=0,s=0;for(let i=0;i<t;i++)i<=this.index?(s+=this.list[i].taskTime,i===this.index&&(e=s)):e+=this.list[i].taskTime;let i=this._isComplete?1:s/e;return Number.isNaN(i)&&(i=0),i}get total(){return this.list.length}get runIndex(){return this.index}init(){this.empty(),this.index=0,this.parallelSuccessNumber=0,this._running=!1,this._isComplete=!1}empty(){this.list=[],this.parallelList=[]}start(){this._running=!0,this._isComplete=!1,this.run()}pause(){this._running=!1}resume(){this._running=!0,this._isComplete=!1,this.run()}skip(){this.index++,this.resume()}stop(){this._running=!1,this.list.forEach((t=>{t.complete()})),this.empty()}add(t,e){this.push(new ur(t),e)}addParallel(t,e){const s=new ur(t);s.parallel=!0,this.push(s,e)}addEmpty(t){this.push(new ur(t))}push(t,e){e&&(t.taskTime=e),t.parent=this,this.list.push(t)}run(){this._running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTask():this.runTask())}runTask(){const t=this.list[this.index];t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)}))}runParallelTask(){this.parallelList.forEach((t=>{t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.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,i=this.index+this.parallelSuccessNumber+s;if(e.length){if(!this._running)return;i<this.list.length&&(t=this.list[i],t.parallel&&(e.push(t),t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))))}else this.index+=this.parallelSuccessNumber,this.nextTask()}nextTask(){setTimeout((()=>{this.run()}),0)}onComplete(){this.stop(),this._isComplete=!0,this.params.onComplete&&this.params.onComplete()}onTask(t){t.complete(),this.params.onTask&&this.params.onTask(),this.index===this.list.length-1&&this.onComplete()}onParallelError(t){_r.error("ParallelError"),this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.params.onError&&this.params.onError(t)}},get Text(){return Dh},TextRender:qo,TransformEvent:r,TwoPointBounds:class{constructor(t,e){F.setPoint(this,t,e)}addPoint(t,e){F.addPoint(this,t,e)}addBounds(t,e,s,i){F.addBounds(this,t,e,s,i)}add(t){F.add(this,t)}},TwoPointBoundsHelper:F,get UI(){return Qo},UIBounds:Xo,UICreator:Ft,UIEvent:ls,UIHit:Vo,UIRender:Go,get Vector(){return Wh},WaitHelper:pt,WatchEvent:o,Watcher:pr,get ZoomEvent(){return ms},affectRenderBoundsType:pe,affectStrokeBoundsType:ue,aliasType:function(t){return(e,s)=>{ie(e,s,{get(){return this.__getAttr(t)},set(e){this.__setAttr(t,e)}})}},boundsType:le,canvasSizeAttrs:ee,dataProcessor:we,dataType:oe,defineDataProcessor:xe,defineKey:ie,defineLeafAttr:re,effectType:jo,getDescriptor:ne,hitType:ve,layoutProcessor:function(t){return(e,s)=>{ie(e,"__LayoutProcessor",{get:()=>t})}},maskType:me,opacityType:fe,pathType:ce,positionType:ae,registerUI:Pe,registerUIEvent:Le,rewrite:Ee,rewriteAble:Te,rotationType:de,scaleType:he,setDefaultValue:function(t,e,s){xe(t.prototype,e,s)},sortType:ye,strokeType:_e,surfaceType:ge,useModule:Re,usePlugin:function(t,e){if(cr.list.push(t),t.dependencies){const s={};t.dependencies.forEach((t=>{e[t]?s[t]=e[t]:lr.error(t+" non-existent")})),t.run(s)}else lr.error("no dependencies")}});window.LeaferUI=jh;