@leafer/core 1.0.0-rc.3 → 1.0.0-rc.4

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/core.cjs CHANGED
@@ -649,7 +649,7 @@ const BoundsHelper = {
649
649
  },
650
650
  getFitMatrix(t, put) {
651
651
  const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height));
652
- return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
652
+ return new Matrix(scale, 0, 0, scale, -Math.ceil(put.x * scale), -Math.ceil(put.y * scale));
653
653
  },
654
654
  getSpread(t, spreadX, spreadY) {
655
655
  const n = {};
@@ -4593,7 +4593,8 @@ class InteractionBase {
4593
4593
  dragDistance: 2,
4594
4594
  swipeDistance: 20,
4595
4595
  ignoreMove: false
4596
- }
4596
+ },
4597
+ cursor: {}
4597
4598
  };
4598
4599
  this.tapCount = 0;
4599
4600
  this.downKeyMap = {};
@@ -4819,6 +4820,8 @@ class InteractionBase {
4819
4820
  this.hoverData = data;
4820
4821
  }
4821
4822
  updateCursor(data) {
4823
+ if (this.config.cursor.stop)
4824
+ return;
4822
4825
  if (!data) {
4823
4826
  this.updateHoverData();
4824
4827
  data = this.hoverData;
@@ -4831,17 +4834,16 @@ class InteractionBase {
4831
4834
  }
4832
4835
  else if (!data || this.dragger.dragging)
4833
4836
  return;
4834
- const path = data.path;
4835
4837
  let leaf;
4838
+ let cursor;
4839
+ const { path } = data;
4836
4840
  for (let i = 0, len = path.length; i < len; i++) {
4837
4841
  leaf = path.list[i];
4838
- if (leaf.cursor) {
4839
- const { cursor } = leaf;
4840
- this.setCursor(cursor === 'grab' ? (this.downData ? 'grabbing' : cursor) : cursor);
4841
- return;
4842
- }
4842
+ cursor = leaf.cursor;
4843
+ if (cursor)
4844
+ break;
4843
4845
  }
4844
- this.setCursor('default');
4846
+ this.setCursor(cursor);
4845
4847
  }
4846
4848
  setCursor(cursor) {
4847
4849
  this.cursor = cursor;
@@ -5459,7 +5461,7 @@ const LeafRender = {
5459
5461
  const tempCanvas = canvas.getSameCanvas(true);
5460
5462
  this.__draw(tempCanvas, options);
5461
5463
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5462
- if (options.matrix || this.__hasMirror) {
5464
+ if (this.__hasMirror || options.matrix) {
5463
5465
  canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
5464
5466
  }
5465
5467
  else {
@@ -5528,7 +5530,12 @@ const BranchRender = {
5528
5530
  this.__renderBranch(tempCanvas, options);
5529
5531
  canvas.opacity = this.__worldOpacity;
5530
5532
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5531
- options.matrix ? canvas.copyWorld(tempCanvas, null, null, blendMode) : canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5533
+ if (this.__hasMirror || options.matrix) {
5534
+ canvas.copyWorld(tempCanvas, null, null, blendMode);
5535
+ }
5536
+ else {
5537
+ canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5538
+ }
5532
5539
  tempCanvas.recycle();
5533
5540
  }
5534
5541
  else {
package/dist/core.esm.js CHANGED
@@ -647,7 +647,7 @@ const BoundsHelper = {
647
647
  },
648
648
  getFitMatrix(t, put) {
649
649
  const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height));
650
- return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
650
+ return new Matrix(scale, 0, 0, scale, -Math.ceil(put.x * scale), -Math.ceil(put.y * scale));
651
651
  },
652
652
  getSpread(t, spreadX, spreadY) {
653
653
  const n = {};
@@ -4591,7 +4591,8 @@ class InteractionBase {
4591
4591
  dragDistance: 2,
4592
4592
  swipeDistance: 20,
4593
4593
  ignoreMove: false
4594
- }
4594
+ },
4595
+ cursor: {}
4595
4596
  };
4596
4597
  this.tapCount = 0;
4597
4598
  this.downKeyMap = {};
@@ -4817,6 +4818,8 @@ class InteractionBase {
4817
4818
  this.hoverData = data;
4818
4819
  }
4819
4820
  updateCursor(data) {
4821
+ if (this.config.cursor.stop)
4822
+ return;
4820
4823
  if (!data) {
4821
4824
  this.updateHoverData();
4822
4825
  data = this.hoverData;
@@ -4829,17 +4832,16 @@ class InteractionBase {
4829
4832
  }
4830
4833
  else if (!data || this.dragger.dragging)
4831
4834
  return;
4832
- const path = data.path;
4833
4835
  let leaf;
4836
+ let cursor;
4837
+ const { path } = data;
4834
4838
  for (let i = 0, len = path.length; i < len; i++) {
4835
4839
  leaf = path.list[i];
4836
- if (leaf.cursor) {
4837
- const { cursor } = leaf;
4838
- this.setCursor(cursor === 'grab' ? (this.downData ? 'grabbing' : cursor) : cursor);
4839
- return;
4840
- }
4840
+ cursor = leaf.cursor;
4841
+ if (cursor)
4842
+ break;
4841
4843
  }
4842
- this.setCursor('default');
4844
+ this.setCursor(cursor);
4843
4845
  }
4844
4846
  setCursor(cursor) {
4845
4847
  this.cursor = cursor;
@@ -5457,7 +5459,7 @@ const LeafRender = {
5457
5459
  const tempCanvas = canvas.getSameCanvas(true);
5458
5460
  this.__draw(tempCanvas, options);
5459
5461
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5460
- if (options.matrix || this.__hasMirror) {
5462
+ if (this.__hasMirror || options.matrix) {
5461
5463
  canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
5462
5464
  }
5463
5465
  else {
@@ -5526,7 +5528,12 @@ const BranchRender = {
5526
5528
  this.__renderBranch(tempCanvas, options);
5527
5529
  canvas.opacity = this.__worldOpacity;
5528
5530
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5529
- options.matrix ? canvas.copyWorld(tempCanvas, null, null, blendMode) : canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5531
+ if (this.__hasMirror || options.matrix) {
5532
+ canvas.copyWorld(tempCanvas, null, null, blendMode);
5533
+ }
5534
+ else {
5535
+ canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5536
+ }
5530
5537
  tempCanvas.recycle();
5531
5538
  }
5532
5539
  else {
@@ -1 +1 @@
1
- const t={imageSuffix:"leaf"},e={},s={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=i;return e[t]?e[t]++:(e[t]=1,0)}},i=s,r={within:(t,e,s)=>(t<e&&(t=e),t>s&&(t=s),t),fourNumber(t){let e,s,i,r;if(t instanceof Array)switch(t.length){case 4:return t;case 2:e=i=t[0],s=r=t[1];break;case 3:e=t[0],s=r=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,r]},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),t),getGapRotation(t,e){if(e>1){const s=Math.abs(t%e);(s<1||s>e-1)&&(t=Math.round(t/e)*e)}return t},formatSkew:t=>r.within(t,-90,90)},a=Math.PI/180,o=2*Math.PI,n=Math.PI/2,{sin:h,cos:l,acos:d,atan:c,sqrt:u,PI:p}=Math,_={};function g(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const f={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},tempMatrix:{},set(t,e=1,s=0,i=0,r=1,a=0,o=0){t.a=e,t.b=s,t.c=i,t.d=r,t.e=a,t.f=o},get:g,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.b*=e,t.c*=s,t.d*=s},scaleOfOuter(t,e,s,i=s){m.toInnerPoint(t,e,_),m.scaleOfInner(t,_,s,i)},scaleOfInner(t,e,s,i=s){m.translateInner(t,e.x,e.y),m.scale(t,s,i),m.translateInner(t,-e.x,-e.y)},rotate(t,e){const s=l(e*=a),i=h(e),{a:r,b:o,c:n,d:d}=t;t.a=r*s-o*i,t.b=r*i+o*s,t.c=n*s-d*i,t.d=n*i+d*s},rotateOfOuter(t,e,s){m.toInnerPoint(t,e,_),m.rotateOfInner(t,_,s)},rotateOfInner(t,e,s){m.translateInner(t,e.x,e.y),m.rotate(t,s),m.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:i,b:r,c:o,d:n}=t;s&&(s*=a,t.a=i+o*s,t.b=r+n*s),e&&(e*=a,t.c=o+i*e,t.d=n+r*e)},skewOfOuter(t,e,s,i){m.toInnerPoint(t,e,_),m.skewOfInner(t,_,s,i)},skewOfInner(t,e,s,i){m.translateInner(t,e.x,e.y),m.skew(t,s,i),m.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:i,c:r,d:a,e:o,f:n}=t;t.a=e.a*s+e.b*r,t.b=e.a*i+e.b*a,t.c=e.c*s+e.d*r,t.d=e.c*i+e.d*a,t.e=e.e*s+e.f*r+o,t.f=e.e*i+e.f*a+n},preMultiply(t,e){const{a:s,b:i,c:r,d:a,e:o,f:n}=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=r*e.a+a*e.c,t.d=r*e.b+a*e.d),t.e=o*e.a+n*e.c+e.e,t.f=o*e.b+n*e.d+e.f},divide(t,e){m.preMultiply(t,m.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=m;return m.copy(e,t),m.invert(e),e},invert(t){const{a:e,b:s,c:i,d:r,e:a,f:o}=t,n=1/(e*r-s*i);t.a=r*n,t.b=-s*n,t.c=-i*n,t.d=e*n,t.e=-(a*r-o*i)*n,t.f=-(o*e-a*s)*n},toOuterPoint(t,e,s,i){const{x:r,y:a}=e;s||(s=e),s.x=r*t.a+a*t.c,s.y=r*t.b+a*t.d,i||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,i){const{x:r,y:a}=e,{a:o,b:n,c:h,d:l}=t,d=1/(o*l-n*h);if(s||(s=e),s.x=(r*l-a*h)*d,s.y=(a*o-r*n)*d,!i){const{e:e,f:i}=t;s.x-=(e*l-i*h)*d,s.y-=(i*o-e*n)*d}},decompose(t){const{a:e,b:s,c:i,d:r}=t;let o=e,n=r,h=0,l=0,_=0;if(s||i){const t=e*r-s*i,g=e*i+s*r;if(s){const i=e*e+s*s;o=u(i),n=t/o;const r=e/o;h=s>0?d(r):-d(r),l=c(g/i)/a}else{const e=i*i+r*r;n=u(e),o=t/n;const s=i/n;h=p/2-(r>0?d(-s):-d(s)),_=c(g/e)/a}h/=a}return{x:t.e,y:t.f,scaleX:o,scaleY:n,rotation:h,skewX:l,skewY:_}},reset(t){m.set(t)}},m=f,{toInnerPoint:y,toOuterPoint:v}=f,{sin:x,cos:w,abs:b,sqrt:O,atan2:C}=Math,T={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},setRadius(t,e,s){t.radiusX=e,t.radiusY=void 0===s?e:s},copy(t,e){t.x=e.x,t.y=e.y},move(t,e,s){t.x+=e,t.y+=s},rotate(t,e,s){s||(s=E.defaultPoint);const i=w(e*a),r=x(e*a),o=t.x-s.x,n=t.y-s.y;t.x=s.x+o*i-n*r,t.y=s.y+o*r+n*i},tempToInnerOf(t,e){const{tempPoint:s}=E;return E.copy(s,t),y(e,s,s),s},tempToOuterOf(t,e){const{tempPoint:s}=E;return E.copy(s,t),v(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),y(e,t,s),s.radiusX=Math.abs(t.radiusX/e.scaleX),s.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,s){y(e,t,s)},toOuterOf(t,e,s){v(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=b(e.x-t.x),i=b(e.y-t.y);return O(s*s+i*i)},getAngle:(t,e)=>E.getAtan2(t,e)/a,getChangeAngle(t,e,s,i){i||(i=e);let r=E.getAngle(t,e);const a=E.getAngle(s,i)-r;return a<-180?a+360:a},getAtan2:(t,e)=>C(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s){const i=E.getAtan2(t,e);return{x:t.x+w(i)*s,y:t.y+x(i)*s}},reset(t){E.reset(t)}},E=T;class k{constructor(t,e){"object"==typeof t?T.copy(this,t):T.set(this,t,e)}set(t,e){T.set(this,t,e)}copy(t){return T.copy(this,t),this}clone(){return new k(this)}rotate(t,e){return T.rotate(this,t,e),this}toInnerOf(t,e){return T.toInnerOf(this,t,e),this}toOuterOf(t,e){return T.toOuterOf(this,t,e),this}getCenter(t){return T.getCenter(this,t)}getDistance(t){return T.getDistance(this,t)}getAngle(t){return T.getAngle(this,t)}getAtan2(t){return T.getAtan2(this,t)}reset(){T.reset(this)}}class B{constructor(t,e,s,i,r,a){"object"==typeof t?f.copy(this,t):f.set(this,t,e,s,i,r,a)}set(t,e,s,i,r,a){f.set(this,t,e,s,i,r,a)}copy(t){return f.copy(this,t),this}clone(){return new B(this)}translate(t,e){return f.translate(this,t,e),this}translateInner(t,e){return f.translateInner(this,t,e),this}scale(t,e){return f.scale(this,t,e),this}scaleOfOuter(t,e,s){return f.scaleOfOuter(this,t,e,s),this}scaleOfInner(t,e,s){return f.scaleOfInner(this,t,e,s),this}rotate(t){return f.rotate(this,t),this}rotateOfOuter(t,e){return f.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return f.rotateOfInner(this,t,e),this}skew(t,e){return f.skew(this,t,e),this}skewOfOuter(t,e,s){return f.skewOfOuter(this,t,e,s),this}skewOfInner(t,e,s){return f.skewOfInner(this,t,e,s),this}multiply(t){return f.multiply(this,t),this}preMultiply(t){return f.preMultiply(this,t),this}divide(t){return f.divide(this,t),this}invert(){return f.invert(this),this}toOuterPoint(t,e,s){f.toOuterPoint(this,t,e,s)}toInnerPoint(t,e,s){f.toInnerPoint(this,t,e,s)}decompose(){return f.decompose(this)}reset(){f.reset(this)}}const P={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,r){R(t,e,s),R(t,e+i,s+r)},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:R}=P,{tempPointBounds:D,setPoint:L,addPoint:S,toBounds:M}=P,{toOuterPoint:I}=f;let A,W,N,X;const Y={},j={},z={tempBounds:{},set(t,e=0,s=0,i=0,r=0){t.x=e,t.y=s,t.width=i,t.height=r},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s,i){i||(i=s),U.set(t,e.x-s,e.y-i,e.width+2*s,e.height+2*i)},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),U.move(t,e,s),t),toOffsetOutBounds(t,e,s){e?F(e,t):e=t,s?(e.offsetX=-(U.right(s)-t.x),e.offsetY=-(U.bottom(s)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),U.move(e,-e.offsetX,-e.offsetY)},scale(t,e,s){s||(s=e),t.x&&(t.x*=e),t.y&&(t.y*=s),t.width*=e,t.height*=s},tempToOuterOf:(t,e)=>(U.copy(U.tempBounds,t),U.toOuterOf(U.tempBounds,e),U.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),U.toOuterOf(t,e),t),toOuterOf(t,e,s){if(s||(s=t),0===e.b&&0===e.c){const{a:i,d:r}=e;i>0?(s.width=t.width*i,s.x=e.e+t.x*i):(s.width=t.width*-i,s.x=e.e+t.x*i-s.width),r>0?(s.height=t.height*r,s.y=e.f+t.y*r):(s.height=t.height*-r,s.y=e.f+t.y*r-s.height)}else Y.x=t.x,Y.y=t.y,I(e,Y,j),L(D,j.x,j.y),Y.x=t.x+t.width,I(e,Y,j),S(D,j.x,j.y),Y.y=t.y+t.height,I(e,Y,j),S(D,j.x,j.y),Y.x=t.x,I(e,Y,j),S(D,j.x,j.y),M(D,s)},getFitMatrix(t,e){const s=Math.min(1,Math.min(t.width/e.width,t.height/e.height));return new B(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e,s){const i={};return U.copyAndSpread(i,t,e,s),i},spread(t,e,s){U.copyAndSpread(t,t,e,s)},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)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},add(t,e){A=t.x+t.width,W=t.y+t.height,N=e.x+e.width,X=e.y+e.height,A=A>N?A:N,W=W>X?W:X,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=A-t.x,t.height=W-t.y},addList(t,e){U.setByListWithHandle(t,e,void 0,!0)},setByList(t,e,s=!1){U.setByListWithHandle(t,e,void 0,s)},addListWithHandle(t,e,s){U.setByListWithHandle(t,e,s,!0)},setByListWithHandle(t,e,s,i=!1){let r,a=!0;for(let o=0,n=e.length;o<n;o++)r=s?s(e[o]):e[o],r&&(r.width||r.height)&&(a?(a=!1,i||F(t,r)):H(t,r));a&&U.reset(t)},setByPoints(t,e){e.forEach(((t,e)=>{0===e?L(D,t.x,t.y):S(D,t.x,t.y)})),M(D,t)},hitRadiusPoint:(t,e,s)=>(s&&(e=T.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=T.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=U.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=U.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=U.tempToOuterOf(e,s));let{x:i,y:r,width:a,height:o}=e;return A=i+a,W=r+o,N=t.x+t.width,X=t.y+t.height,i=i>t.x?i:t.x,r=r>t.y?r:t.y,A=A<N?A:N,W=W<X?W:X,a=A-i,o=W-r,{x:i,y:r,width:a,height:o}},intersect(t,e,s){U.copy(t,U.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){U.set(t)}},U=z,{add:H,copy:F}=U;class V{constructor(t,e,s,i){"object"==typeof t?z.copy(this,t):z.set(this,t,e,s,i)}set(t,e,s,i){z.set(this,t,e,s,i)}copy(t){return z.copy(this,t),this}clone(){return new V(this)}scale(t,e){return z.scale(this,t,e),this}toOuterOf(t,e){return z.toOuterOf(this,t,e),this}getFitMatrix(t){return z.getFitMatrix(this,t)}spread(t){return z.spread(this,t),this}ceil(){return z.ceil(this),this}unsign(){return z.unsign(this),this}add(t){return z.add(this,t),this}addList(t){return z.setByList(this,t,!0),this}setByList(t,e){return z.setByList(this,t,e),this}addListWithHandle(t,e){return z.setByListWithHandle(this,t,e,!0),this}setByListWithHandle(t,e,s){return z.setByListWithHandle(this,t,e,s),this}setByPoints(t){return z.setByPoints(this,t),this}hitPoint(t,e){return z.hitPoint(this,t,e)}hitRadiusPoint(t,e){return z.hitRadiusPoint(this,t,e)}hit(t,e){return z.hit(this,t,e)}includes(t,e){return z.includes(this,t,e)}intersect(t,e){return z.intersect(this,t,e),this}getIntersect(t,e){return new V(z.getIntersectData(this,t,e))}isSame(t){return z.isSame(this,t)}isEmpty(){return z.isEmpty(this)}reset(){z.reset(this)}}class G{constructor(t,e,s,i,r,a){"object"==typeof t?this.copy(t):this.set(t,e,s,i,r,a)}set(t=0,e=0,s=0,i=0,r=0,a=0){this.top=t,this.right=e,this.bottom=s,this.left=i,this.width=r,this.height=a}copy(t){const{top:e,right:s,bottom:i,left:r,width:a,height:o}=t;this.set(e,s,i,r,a,o)}getBoundsFrom(t){const{top:e,right:s,bottom:i,left:r,width:a,height:o}=this;return new V(r,e,a||t.width-r-s,o||t.height-e-i)}}class K{constructor(t,e){P.setPoint(this,t,e)}addPoint(t,e){P.addPoint(this,t,e)}addBounds(t,e,s,i){P.addBounds(this,t,e,s,i)}add(t){P.add(this,t)}}const q={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 Z{constructor(t){this.repeatMap={},this.name=t}static get(t){return new Z(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(Q.enable){if(Q.filterList.length&&Q.filterList.every((t=>t!==this.name)))return;if(Q.excludeList.length&&Q.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}warn(...t){Q.enable&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}Z.filterList=[],Z.excludeList=[];const Q=Z,J=Z.get("RunTime");class ${static start(t,e){const i=s.create(s.RUNTIME);return tt.currentId=tt.idMap[i]=e?performance.now():Date.now(),tt.currentName=tt.nameMap[i]=t,tt.nameToIdMap[t]=i,i}static end(t,e){const s=tt.idMap[t],i=tt.nameMap[t];tt.idMap[t]=tt.nameMap[t]=tt.nameToIdMap[i]=void 0,e?J.log(i,performance.now()-s,"µs"):J.log(i,Date.now()-s,"ms")}static endOfName(t,e){const s=tt.nameToIdMap[t];void 0!==s&&tt.end(s,e)}}$.idMap={},$.nameMap={},$.nameToIdMap={};const tt=$,et=Z.get("UICreator"),st={list:{},register(t){const{__tag:e}=t.prototype;it[e]?et.repeat(e):it[e]=t},get(t,e,s,i,r,a){const o=new it[t](e);return void 0!==s&&(o.x=s,i&&(o.y=i),r&&(o.width=r),a&&(o.height=a)),o}},{list:it}=st,rt=Z.get("EventCreator"),at={nameList:{},register(t){let e;Object.keys(t).forEach((s=>{e=t[s],"string"==typeof e&&(ot[e]?rt.repeat(e):ot[e]=t)}))},changeName(t,e){const s=ot[t];if(s){const i=Object.keys(s).find((e=>s[e]===t));i&&(s[i]=e,ot[e]=s)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new ot[t](...e)},{nameList:ot}=at;class nt{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let s;const{list:i}=this;for(let e=0,r=i.length;e<r;e++)if(s=i[e],s.recycled&&s.isSameSize(t))return s.recycled=!1,s.manager||(s.manager=this),s;const r=e.canvas(t);return this.add(r),r}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}destroy(){this.clear()}}class ht{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.pushList(t):this.push(t))}has(t){return t&&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,r=e.length;i<r;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 ht;return this.list.forEach((e=>{t.push(e)})),t}reset(){this.list=[],this.keys={}}destroy(){this.list=null}}class lt{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 dt extends nt{constructor(){super(...arguments),this.pathTypeList=new ht,this.imageTypeList=new ht}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.length&&(t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset())}clear(){this.clearPathType(),this.clearImageType()}}const ct={default:(t,e)=>(ut(e,t),ut(t,e),t),assign(t,e){let s;Object.keys(e).forEach((i=>{var r;s=e[i],(null==s?void 0:s.constructor)===Object&&(null===(r=t[i])||void 0===r?void 0:r.constructor)===Object?ut(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:ut}=ct;class pt{constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(void 0!==e)return 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];if(void 0!==e)return e}return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(){const t={tag:this.__leaf.tag},{__input:e}=this;let s,i;for(let r in this)s=r.substring(1),void 0!==this[s]&&(i=e?e[s]:void 0,t[s]=void 0===i?this[r]:i);return t}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){"pass-through"===this.blendMode?this.__leaf.__hasEraser||this.isEraser?this.__single=!0:this.__single&&(this.__single=!1):this.__single=!0}destroy(){this.__input=this.__middle=null}}const _t={mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]}};function gt(t,e,s,i){var r,a=arguments.length,o=a<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 n=t.length-1;n>=0;n--)(r=t[n])&&(o=(a<3?r(o):a>3?r(e,s,o):r(e,s))||o);return a>3&&o&&Object.defineProperty(e,s,o),o}function ft(t,e,s,i){return new(s||(s=Promise))((function(r,a){function o(t){try{h(i.next(t))}catch(t){a(t)}}function n(t){try{h(i.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,n)}h((i=i.apply(t,e||[])).next())}))}function mt(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)}}"function"==typeof SuppressedError&&SuppressedError;const yt=[];function vt(){return(t,e)=>{yt.push(e)}}const xt=[];class wt{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||xt)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;yt.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))})),this.textBaseline="alphabetic"}setTransform(t,e,s,i,r,a){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,i,r,a){"object"==typeof t?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,s,i,r,a)}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,r,a,o,n,h){switch(arguments.length){case 9:if(e<0){const t=-e/i*n;i+=e,e=0,a+=t,n-=t}if(s<0){const t=-s/r*h;r+=s,s=0,o+=t,h-=t}this.context.drawImage(t,e,s,i,r,a,o,n,h);break;case 5:this.context.drawImage(t,e,s,i,r);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,i,r,a){}quadraticCurveTo(t,e,s,i){}closePath(){}arc(t,e,s,i,r,a){}arcTo(t,e,s,i,r){}ellipse(t,e,s,i,r,a,o,n){}rect(t,e,s,i){}roundRect(t,e,s,i,r){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,i){}createPattern(t,e){}createRadialGradient(t,e,s,i,r,a){}fillText(t,e,s,i){}measureText(t){}strokeText(t,e,s,i){}destroy(){this.context=null}}gt([mt("imageSmoothingEnabled")],wt.prototype,"smooth",void 0),gt([mt("imageSmoothingQuality")],wt.prototype,"smoothLevel",void 0),gt([mt("globalAlpha")],wt.prototype,"opacity",void 0),gt([mt()],wt.prototype,"fillStyle",void 0),gt([mt()],wt.prototype,"strokeStyle",void 0),gt([mt("lineWidth")],wt.prototype,"strokeWidth",void 0),gt([mt("lineCap")],wt.prototype,"strokeCap",void 0),gt([mt("lineJoin")],wt.prototype,"strokeJoin",void 0),gt([mt("lineDashOffset")],wt.prototype,"dashOffset",void 0),gt([mt()],wt.prototype,"miterLimit",void 0),gt([mt()],wt.prototype,"shadowBlur",void 0),gt([mt()],wt.prototype,"shadowColor",void 0),gt([mt()],wt.prototype,"shadowOffsetX",void 0),gt([mt()],wt.prototype,"shadowOffsetY",void 0),gt([mt()],wt.prototype,"filter",void 0),gt([mt()],wt.prototype,"font",void 0),gt([mt()],wt.prototype,"fontKerning",void 0),gt([mt()],wt.prototype,"fontStretch",void 0),gt([mt()],wt.prototype,"fontVariantCaps",void 0),gt([mt()],wt.prototype,"textAlign",void 0),gt([mt()],wt.prototype,"textBaseline",void 0),gt([mt()],wt.prototype,"textRendering",void 0),gt([mt()],wt.prototype,"wordSpacing",void 0),gt([mt()],wt.prototype,"letterSpacing",void 0),gt([mt()],wt.prototype,"direction",void 0),gt([vt()],wt.prototype,"setTransform",null),gt([vt()],wt.prototype,"resetTransform",null),gt([vt()],wt.prototype,"getTransform",null),gt([vt()],wt.prototype,"save",null),gt([vt()],wt.prototype,"restore",null),gt([vt()],wt.prototype,"translate",null),gt([vt()],wt.prototype,"scale",null),gt([vt()],wt.prototype,"rotate",null),gt([vt()],wt.prototype,"fill",null),gt([vt()],wt.prototype,"stroke",null),gt([vt()],wt.prototype,"clip",null),gt([vt()],wt.prototype,"fillRect",null),gt([vt()],wt.prototype,"strokeRect",null),gt([vt()],wt.prototype,"clearRect",null),gt([vt()],wt.prototype,"beginPath",null),gt([vt()],wt.prototype,"moveTo",null),gt([vt()],wt.prototype,"lineTo",null),gt([vt()],wt.prototype,"bezierCurveTo",null),gt([vt()],wt.prototype,"quadraticCurveTo",null),gt([vt()],wt.prototype,"closePath",null),gt([vt()],wt.prototype,"arc",null),gt([vt()],wt.prototype,"arcTo",null),gt([vt()],wt.prototype,"ellipse",null),gt([vt()],wt.prototype,"rect",null),gt([vt()],wt.prototype,"roundRect",null),gt([vt()],wt.prototype,"createConicGradient",null),gt([vt()],wt.prototype,"createLinearGradient",null),gt([vt()],wt.prototype,"createPattern",null),gt([vt()],wt.prototype,"createRadialGradient",null),gt([vt()],wt.prototype,"fillText",null),gt([vt()],wt.prototype,"measureText",null),gt([vt()],wt.prototype,"strokeText",null);const bt=new V,Ot={width:1,height:1,pixelRatio:1},Ct=Z.get("LeaferCanvasBase"),Tt=["width","height","pixelRatio"];class Et extends wt{get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,i){super(),this.worldTransform={},e||(e=Ot),e.pixelRatio||(e.pixelRatio=t.devicePixelRatio),this.manager=i,this.innerId=s.create(s.CNAVAS);const{width:r,height:a,pixelRatio:o}=e;this.autoLayout=!r||!a,this.pixelRatio=o,this.config=e,this.init()}init(){}__createContext(){this.context=this.view.getContext("2d"),this.__bindContext()}toBlob(e,s){return new Promise((i=>{const r=this.getSaveCanvas(e);t.origin.canvasToBolb(r.view,e,s).then((t=>{r.recycle(),i(t)})).catch((t=>{Ct.error(t),i(null)}))}))}toDataURL(e,s){const i=this.getSaveCanvas(e),r=t.origin.canvasToDataURL(i.view,e,s);return i.recycle(),r}saveAs(e,s){return new Promise((i=>{const r=this.getSaveCanvas(_t.fileType(e));t.origin.canvasSaveAs(r.view,e,s).then((()=>{r.recycle(),i(!0)})).catch((t=>{Ct.error(t),i(!1)}))}))}getSaveCanvas(t){const{backgroundColor:e,bounds:s}=this,i=this.getSameCanvas();return["jpg","jpeg"].includes(t)&&i.fillWorld(s,"#FFFFFF"),e&&i.fillWorld(s,e),i.copyWorld(this),i}resize(t){if(this.isSameSize(t))return;let e;this.context&&!this.unreal&&this.width&&(e=this.getSameCanvas(),e.copyWorld(this)),ct.copyAttrs(this,t,Tt),this.bounds=new V(0,0,this.width,this.height),this.pixelRatio||(this.pixelRatio=1),this.unreal||(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&e&&(this.clearWorld(e.bounds),this.copyWorld(e),e.recycle())}updateViewSize(){}updateClientBounds(){}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e,s){const{pixelRatio:i}=this,r=this.worldTransform;if(e)if(s)this.setTransform(r.a=t.a*i,r.b=t.b*i,r.c=t.c*i,r.d=t.d*i,r.e=(t.e+e.e)*i,r.f=(t.f+e.f)*i);else{const{a:s,b:a,c:o,d:n,e:h,f:l}=e;this.setTransform(r.a=(t.a*s+t.b*o)*i,r.b=(t.a*a+t.b*n)*i,r.c=(t.c*s+t.d*o)*i,r.d=(t.c*a+t.d*n)*i,r.e=(t.e*s+t.f*o+h)*i,r.f=(t.e*a+t.f*n+l)*i)}else this.setTransform(r.a=t.a*i,r.b=t.b*i,r.c=t.c*i,r.d=t.d*i,r.e=t.e*i,r.f=t.f*i)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,s){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 e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)}hitStroke(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)}setWorldShadow(t,e,s,i){const{pixelRatio:r}=this;this.shadowOffsetX=t*r,this.shadowOffsetY=e*r,this.shadowBlur=s*r,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="source-over")}copyWorldToInner(t,e,s,i){if(i&&(this.blendMode=i),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,z.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="source-over")}copyWorldByReset(t,e,s,i){this.resetTransform(),this.copyWorld(t,e,s,i),this.useWorldTransform()}useMask(t,e,s){this.copyWorld(t,e,s,"destination-in")}useEraser(t,e,s){this.copyWorld(t,e,s,"destination-out")}fillWorld(t,e,s){s&&(this.blendMode=s),this.fillStyle=e,bt.copy(t).scale(this.pixelRatio),this.fillRect(bt.x,bt.y,bt.width,bt.height),s&&(this.blendMode="source-over")}strokeWorld(t,e,s){s&&(this.blendMode=s),this.strokeStyle=e,bt.copy(t).scale(this.pixelRatio),this.strokeRect(bt.x,bt.y,bt.width,bt.height),s&&(this.blendMode="source-over")}clearWorld(t,e){bt.copy(t).scale(this.pixelRatio),e&&bt.ceil(),this.clearRect(bt.x,bt.y,bt.width,bt.height)}clipWorld(t,e){this.beginPath(),bt.copy(t).scale(this.pixelRatio),e&&bt.ceil(),this.rect(bt.x,bt.y,bt.width,bt.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:s,height:i,pixelRatio:r}=this,a={width:s,height:i,pixelRatio:r},o=this.manager?this.manager.get(a):e.canvas(a);return o.save(),t&&o.useWorldTransform(Object.assign({},this.worldTransform)),o}getBiggerCanvas(t,s){let{width:i,height:r,pixelRatio:a}=this;t&&(i+=t),s&&(r+=s);const o={width:i,height:r,pixelRatio:a},n=this.manager?this.manager.get(o):e.canvas(o);return n.save(),n}recycle(){this.recycled||(this.restore(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const kt={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Bt={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Pt=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},Bt),Rt={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},Dt={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},Lt=Object.assign(Object.assign({},Dt),Bt),St=Pt,Mt={};for(let t in St)Mt[St[t]]=t;const It={};for(let t in St)It[St[t]]=Rt[t];const At={drawRoundRect(t,e,s,i,a,o){let[n,h,l,d]=r.fourNumber(o);const c=Math.min(i/2,a/2);n>c&&(n=c),h>c&&(h=c),l>c&&(l=c),d>c&&(d=c),n?t.moveTo(e+n,s):t.moveTo(e,s),h?t.arcTo(e+i,s,e+i,s+a,h):t.lineTo(e+i,s),l?t.arcTo(e+i,s+a,e,s+a,l):t.lineTo(e+i,s+a),d?t.arcTo(e,s+a,e,s,d):t.lineTo(e,s+a),n?t.arcTo(e,s,e+i,s,n):t.lineTo(e,s)}},{sin:Wt,cos:Nt,atan2:Xt,ceil:Yt,abs:jt,PI:zt,sqrt:Ut,pow:Ht}=Math,{setPoint:Ft,addPoint:Vt}=P,{set:Gt}=T,{M:Kt,L:qt,C:Zt,Q:Qt,Z:Jt}=Pt,$t={},te={points(t,e,s,i){if(t.push(Kt,e[0],e[1]),s&&e.length>5){let r,a,o,n,h,l,d,c,u,p,_,g,f,m=e.length;const y=!0===s?.5:s;i&&(m=(e=[e[m-2],e[m-1],...e,e[0],e[1],e[2],e[3]]).length);for(let s=2;s<m-2;s+=2)r=e[s-2],a=e[s-1],o=e[s],n=e[s+1],h=e[s+2],l=e[s+3],_=Ut(Ht(o-r,2)+Ht(n-a,2)),g=Ut(Ht(h-o,2)+Ht(l-n,2)),f=_+g,_=y*_/f,g=y*g/f,h-=r,l-=a,d=o-_*h,c=n-_*l,2===s?i||t.push(Qt,d,c,o,n):t.push(Zt,u,p,d,c,o,n),u=o+g*h,p=n+g*l;i||t.push(Qt,u,p,e[m-2],e[m-1])}else for(let s=2,i=e.length;s<i;s+=2)t.push(qt,e[s],e[s+1]);i&&t.push(Jt)},rect(t,e,s,i,r){kt.creator.path=t,kt.creator.moveTo(e,s).lineTo(e+i,s).lineTo(e+i,s+r).lineTo(e,s+r).lineTo(e,s)},roundRect(t,e,s,i,r,a){kt.creator.path=[],At.drawRoundRect(kt.creator,e,s,i,r,a),t.push(...kt.convertToCanvasData(kt.creator.path,!0))},arcTo(t,e,s,i,r,h,l,d,c,u,p){const _=i-e,g=r-s,f=h-i,m=l-r;let y=Xt(g,_),v=Xt(m,f),x=v-y;if(x<0&&(x+=o),x===zt||jt(_+g)<1e-12||jt(f+m)<1e-12)return t&&t.push(qt,i,r),c&&(Ft(c,e,s),Vt(c,i,r)),p&&Gt(p,e,s),void(u&&Gt(u,i,r));const w=_*m-f*g<0,b=w?-1:1,O=d/Nt(x/2),C=i+O*Nt(y+x/2+n*b),T=r+O*Wt(y+x/2+n*b);return y-=n*b,v-=n*b,ie(t,C,T,d,d,0,y/a,v/a,w,c,u,p)},arc:(t,e,s,i,r,a,o,n,h,l)=>ie(t,e,s,i,i,0,r,a,o,n,h,l),ellipse(t,e,s,i,r,h,l,d,c,u,p,_){const g=h*a,f=Wt(g),m=Nt(g);let y=l*a,v=d*a;y>zt&&(y-=o),v<0&&(v+=o);let x=v-y;x<0?x+=o:x>o&&(x-=o),c&&(x-=o);const w=Yt(jt(x/n)),b=x/w,O=Wt(b/4),C=8/3*O*O/Wt(b/2);v=y+b;let T,E,k,B,P,R,D,L,S=Nt(y),M=Wt(y),I=k=m*i*S-f*r*M,A=B=f*i*S+m*r*M,W=e+k,N=s+B;t&&t.push(qt,W,N),u&&Ft(u,W,N),_&&Gt(_,W,N);for(let a=0;a<w;a++)T=Nt(v),E=Wt(v),k=m*i*T-f*r*E,B=f*i*T+m*r*E,P=e+I-C*(m*i*M+f*r*S),R=s+A-C*(f*i*M-m*r*S),D=e+k+C*(m*i*E+f*r*T),L=s+B+C*(f*i*E-m*r*T),t&&t.push(Zt,P,R,D,L,e+k,s+B),u&&se(e+I,s+A,P,R,D,L,e+k,s+B,u,!0),I=k,A=B,S=T,M=E,y=v,v+=b;p&&Gt(p,e+k,s+B)},quadraticCurveTo(t,e,s,i,r,a,o){t.push(Zt,(e+2*i)/3,(s+2*r)/3,(a+2*i)/3,(o+2*r)/3,a,o)},toTwoPointBoundsByQuadraticCurve(t,e,s,i,r,a,o,n){se(t,e,(t+2*s)/3,(e+2*i)/3,(r+2*s)/3,(a+2*i)/3,r,a,o,n)},toTwoPointBounds(t,e,s,i,r,a,o,n,h,l){const d=[];let c,u,p,_,g,f,m,y,v=t,x=s,w=r,b=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=i,w=a,b=n),c=-3*v+9*x-9*w+3*b,u=6*v-12*x+6*w,p=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;_=-p/u,0<_&&_<1&&d.push(_)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(g=(-u+y)/(2*c),0<g&&g<1&&d.push(g),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?Vt(h,t,e):Ft(h,t,e),Vt(h,o,n);for(let l=0,c=d.length;l<c;l++)ee(d[l],t,e,s,i,r,a,o,n,$t),Vt(h,$t.x,$t.y)},getPointAndSet(t,e,s,i,r,a,o,n,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,_=t*t*t;l.x=c*e+u*i+p*a+_*n,l.y=c*s+u*r+p*o+_*h},getPoint(t,e,s,i,r,a,o,n,h){const l={};return ee(t,e,s,i,r,a,o,n,h,l),l}},{getPointAndSet:ee,toTwoPointBounds:se,ellipse:ie}=te,{sin:re,cos:ae,sqrt:oe,atan2:ne}=Math,{ellipse:he}=te,le={ellipticalArc(t,e,s,i,r,n,h,l,d,c,u){const p=(d-e)/2,_=(c-s)/2,g=n*a,f=re(g),m=ae(g),y=-m*p-f*_,v=-m*_+f*p,x=i*i,w=r*r,b=v*v,O=y*y,C=x*w-x*b-w*O;let T=0;if(C<0){const t=oe(1-C/(x*w));i*=t,r*=t}else T=(h===l?-1:1)*oe(C/(x*b+w*O));const E=T*i*v/r,k=-T*r*y/i,B=ne((v-k)/r,(y-E)/i),P=ne((-v-k)/r,(-y-E)/i);let R=P-B;0===l&&R>0?R-=o:1===l&&R<0&&(R+=o);const D=e+p+m*E-f*k,L=s+_+f*E+m*k,S=R<0?1:0;u?he(t,D,L,i,r,n,B/a,P/a,S):i!==r||n?t.push(Pt.G,D,L,i,r,n,B/a,P/a,S):t.push(Pt.O,D,L,i,B/a,P/a,S)}},{M:de,m:ce,L:ue,l:pe,H:_e,h:ge,V:fe,v:me,C:ye,c:ve,S:xe,s:we,Q:be,q:Oe,T:Ce,t:Te,A:Ee,a:ke,Z:Be,z:Pe,N:Re,D:De,X:Le,G:Se,F:Me,O:Ie,P:Ae,U:We}=Pt,{rect:Ne,roundRect:Xe,arcTo:Ye,arc:je,ellipse:ze,quadraticCurveTo:Ue}=te,{ellipticalArc:He}=le,Fe=Z.get("PathConvert"),Ve={},Ge={current:{dot:0},stringify(t){let e,s,i,r=0,a=t.length,o="";for(;r<a;){s=t[r],e=It[s],o+=s===i?" ":Mt[s];for(let s=1;s<e;s++)o+=t[r+s],s===e-1||(o+=" ");i=s,r+=e}return o},parse(t,e){let s,i,r,a="";const o=[],n=e?Lt:Dt;for(let e=0,h=t.length;e<h;e++)i=t[e],q[i]?("."===i&&(Ke.dot++,Ke.dot>1&&(qe(o,a),a="")),a+=i):Pt[i]?(a&&(qe(o,a),a=""),Ke.name=Pt[i],Ke.length=Rt[i],Ke.index=0,qe(o,Ke.name),!s&&n[i]&&(s=!0)):"-"===i||"+"===i?"e"===r||"E"===r?a+=i:(a&&qe(o,a),a=i):a&&(qe(o,a),a=""),r=i;return a&&qe(o,a),s?Ge.toCanvasData(o,e):o},toCanvasData(t,e){let s,i,r,a,o,n=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(r=t[c],r){case ce:t[c+1]+=n,t[c+2]+=h;case de:n=t[c+1],h=t[c+2],p.push(de,n,h),c+=3;break;case ge:t[c+1]+=n;case _e:n=t[c+1],p.push(ue,n,h),c+=2;break;case me:t[c+1]+=h;case fe:h=t[c+1],p.push(ue,n,h),c+=2;break;case pe:t[c+1]+=n,t[c+2]+=h;case ue:n=t[c+1],h=t[c+2],p.push(ue,n,h),c+=3;break;case we:t[c+1]+=n,t[c+2]+=h,t[c+3]+=n,t[c+4]+=h,r=xe;case xe:o=a===ye||a===xe,l=o?2*n-s:t[c+1],d=o?2*h-i:t[c+2],s=t[c+1],i=t[c+2],n=t[c+3],h=t[c+4],p.push(ye,l,d,s,i,n,h),c+=5;break;case ve:t[c+1]+=n,t[c+2]+=h,t[c+3]+=n,t[c+4]+=h,t[c+5]+=n,t[c+6]+=h,r=ye;case ye:s=t[c+3],i=t[c+4],n=t[c+5],h=t[c+6],p.push(ye,t[c+1],t[c+2],s,i,n,h),c+=7;break;case Te:t[c+1]+=n,t[c+2]+=h,r=Ce;case Ce:o=a===be||a===Ce,s=o?2*n-s:t[c+1],i=o?2*h-i:t[c+2],e?Ue(p,n,h,s,i,t[c+1],t[c+2]):p.push(be,s,i,t[c+1],t[c+2]),n=t[c+1],h=t[c+2],c+=3;break;case Oe:t[c+1]+=n,t[c+2]+=h,t[c+3]+=n,t[c+4]+=h,r=be;case be:s=t[c+1],i=t[c+2],e?Ue(p,n,h,s,i,t[c+3],t[c+4]):p.push(be,s,i,t[c+3],t[c+4]),n=t[c+3],h=t[c+4],c+=5;break;case ke:t[c+6]+=n,t[c+7]+=h;case Ee:He(p,n,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),n=t[c+6],h=t[c+7],c+=8;break;case Pe:case Be:p.push(Be),c++;break;case Re:n=t[c+1],h=t[c+2],e?Ne(p,n,h,t[c+3],t[c+4]):Ze(p,t,c,5),c+=5;break;case De:n=t[c+1],h=t[c+2],e?Xe(p,n,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):Ze(p,t,c,9),c+=9;break;case Le:n=t[c+1],h=t[c+2],e?Xe(p,n,h,t[c+3],t[c+4],t[c+5]):Ze(p,t,c,6),c+=6;break;case Se:ze(e?p:Ze(p,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,Ve),n=Ve.x,h=Ve.y,c+=9;break;case Me:e?ze(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):Ze(p,t,c,5),n=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Ie:je(e?p:Ze(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,Ve),n=Ve.x,h=Ve.y,c+=7;break;case Ae:e?je(p,t[c+1],t[c+2],t[c+3],0,360,!1):Ze(p,t,c,4),n=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case We:Ye(e?p:Ze(p,t,c,6),n,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,Ve),n=Ve.x,h=Ve.y,c+=6;break;default:return Fe.error(`command: ${r} [index:${c}]`,t),p}a=r}return p},copyData(t,e,s,i){for(let r=s,a=s+i;r<a;r++)t.push(e[r])},pushData(t,e){Ke.index===Ke.length&&(Ke.index=1,t.push(Ke.name)),t.push(Number(e)),Ke.index++,Ke.dot=0}},{current:Ke,pushData:qe,copyData:Ze}=Ge,{M:Qe,L:Je,C:$e,Q:ts,Z:es,N:ss,D:is,X:rs,G:as,F:os,O:ns,P:hs,U:ls}=Pt,ds={},cs={beginPath(t){t.length=0},moveTo(t,e,s){t.push(Qe,e,s)},lineTo(t,e,s){t.push(Je,e,s)},bezierCurveTo(t,e,s,i,r,a,o){t.push($e,e,s,i,r,a,o)},quadraticCurveTo(t,e,s,i,r){t.push(ts,e,s,i,r)},closePath(t){t.push(es)},rect(t,e,s,i,r){t.push(ss,e,s,i,r)},roundRect(t,e,s,i,a,o){if("number"==typeof o)t.push(rs,e,s,i,a,o);else{const n=r.fourNumber(o);n?t.push(is,e,s,i,a,...n):t.push(ss,e,s,i,a)}},ellipse(t,e,s,i,r,a,o,n,h){void 0===a?t.push(os,e,s,i,r):(void 0===o&&(o=0),void 0===n&&(n=360),t.push(as,e,s,i,r,a,o,n,h?1:0))},arc(t,e,s,i,r,a,o){void 0===r?t.push(hs,e,s,i):(void 0===a&&(a=360),t.push(ns,e,s,i,r,a,o?1:0))},arcTo(t,e,s,i,r,a){t.push(ls,e,s,i,r,a)},drawEllipse(t,e,s,i,r,a,o,n,h){void 0===a&&(a=0),void 0===o&&(o=0),void 0===n&&(n=360),te.ellipse(null,e,s,i,r,a,o,n,h,null,null,ds),t.push(Qe,ds.x,ds.y),us(t,e,s,i,r,a,o,n,h)},drawArc(t,e,s,i,r,a,o){void 0===r&&(r=0),void 0===a&&(a=360),te.arc(null,e,s,i,r,a,o,null,null,ds),t.push(Qe,ds.x,ds.y),ps(t,e,s,i,r,a,o)},drawPoints(t,e,s,i){te.points(t,e,s,i)}},{ellipse:us,arc:ps}=cs,{moveTo:_s,lineTo:gs,quadraticCurveTo:fs,bezierCurveTo:ms,closePath:ys,beginPath:vs,rect:xs,roundRect:ws,ellipse:bs,arc:Os,arcTo:Cs,drawEllipse:Ts,drawArc:Es,drawPoints:ks}=cs;class Bs{constructor(t){this.path=t?"string"==typeof t?kt.parse(t):t:[]}beginPath(){return vs(this.path),this}moveTo(t,e){return _s(this.path,t,e),this}lineTo(t,e){return gs(this.path,t,e),this}bezierCurveTo(t,e,s,i,r,a){return ms(this.path,t,e,s,i,r,a),this}quadraticCurveTo(t,e,s,i){return fs(this.path,t,e,s,i),this}closePath(){return ys(this.path),this}rect(t,e,s,i){return xs(this.path,t,e,s,i),this}roundRect(t,e,s,i,r){return ws(this.path,t,e,s,i,r),this}ellipse(t,e,s,i,r,a,o,n){return bs(this.path,t,e,s,i,r,a,o,n),this}arc(t,e,s,i,r,a){return Os(this.path,t,e,s,i,r,a),this}arcTo(t,e,s,i,r){return Cs(this.path,t,e,s,i,r),this}drawEllipse(t,e,s,i,r,a,o,n){return Ts(this.path,t,e,s,i,r,a,o,n),this}drawArc(t,e,s,i,r,a){return Es(this.path,t,e,s,i,r,a),this}drawPoints(t,e,s){return ks(this.path,t,e,s),this}}const{M:Ps,L:Rs,C:Ds,Q:Ls,Z:Ss,N:Ms,D:Is,X:As,G:Ws,F:Ns,O:Xs,P:Ys,U:js}=Pt,zs=Z.get("PathDrawer"),Us={drawPathByData(t,e){if(!e)return;let s,i=0,r=e.length;for(;i<r;)switch(s=e[i],s){case Ps:t.moveTo(e[i+1],e[i+2]),i+=3;break;case Rs:t.lineTo(e[i+1],e[i+2]),i+=3;break;case Ds:t.bezierCurveTo(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5],e[i+6]),i+=7;break;case Ls:t.quadraticCurveTo(e[i+1],e[i+2],e[i+3],e[i+4]),i+=5;break;case Ss:t.closePath(),i+=1;break;case Ms:t.rect(e[i+1],e[i+2],e[i+3],e[i+4]),i+=5;break;case Is: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 As:t.roundRect(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]),i+=6;break;case Ws:t.ellipse(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]*a,e[i+6]*a,e[i+7]*a,e[i+8]),i+=9;break;case Ns:t.ellipse(e[i+1],e[i+2],e[i+3],e[i+4],0,0,o,!1),i+=5;break;case Xs:t.arc(e[i+1],e[i+2],e[i+3],e[i+4]*a,e[i+5]*a,e[i+6]),i+=7;break;case Ys:t.arc(e[i+1],e[i+2],e[i+3],0,o,!1),i+=4;break;case js:t.arcTo(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]),i+=6;break;default:return void zs.error(`command: ${s} [index:${i}]`,e)}}},{M:Hs,L:Fs,C:Vs,Q:Gs,Z:Ks,N:qs,D:Zs,X:Qs,G:Js,F:$s,O:ti,P:ei,U:si}=Pt,{toTwoPointBounds:ii,toTwoPointBoundsByQuadraticCurve:ri,arcTo:ai,arc:oi,ellipse:ni}=te,{add:hi,copy:li,addPoint:di,setPoint:ci,addBounds:ui,toBounds:pi}=P,_i=Z.get("PathBounds");let gi,fi,mi;const yi={},vi={},xi={},wi={toBounds(t,e){wi.toTwoPointBounds(t,vi),pi(vi,e)},toTwoPointBounds(t,e){if(!t||!t.length)return ci(e,0,0);let s,i,r,a,o,n=0,h=0,l=0;const d=t.length;for(;n<d;)switch(s=t[n],0===n&&(s===Ks||s===Vs||s===Gs?ci(e,h,l):ci(e,t[n+1],t[n+2])),s){case Hs:case Fs:h=t[n+1],l=t[n+2],di(e,h,l),n+=3;break;case Vs:a=t[n+5],o=t[n+6],ii(h,l,t[n+1],t[n+2],t[n+3],t[n+4],a,o,yi),hi(e,yi),h=a,l=o,n+=7;break;case Gs:i=t[n+1],r=t[n+2],a=t[n+3],o=t[n+4],ri(h,l,i,r,a,o,yi),hi(e,yi),h=a,l=o,n+=5;break;case Ks:n+=1;break;case qs:h=t[n+1],l=t[n+2],ui(e,h,l,t[n+3],t[n+4]),n+=5;break;case Zs:case Qs:h=t[n+1],l=t[n+2],ui(e,h,l,t[n+3],t[n+4]),n+=s===Zs?9:6;break;case Js:ni(null,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],t[n+6],t[n+7],t[n+8],yi,xi),0===n?li(e,yi):hi(e,yi),h=xi.x,l=xi.y,n+=9;break;case $s:h=t[n+1],l=t[n+2],fi=t[n+3],mi=t[n+4],ui(e,h-fi,l-mi,2*fi,2*mi),h+=fi,n+=5;break;case ti:oi(null,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],t[n+6],yi,xi),0===n?li(e,yi):hi(e,yi),h=xi.x,l=xi.y,n+=7;break;case ei:h=t[n+1],l=t[n+2],gi=t[n+3],ui(e,h-gi,l-gi,2*gi,2*gi),h+=gi,n+=4;break;case si:ai(null,h,l,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],yi,xi),0===n?li(e,yi):hi(e,yi),h=xi.x,l=xi.y,n+=6;break;default:return void _i.error(`command: ${s} [index:${n}]`,t)}}},bi={smooth:(t,e,s)=>t};kt.creator=new Bs,kt.parse=Ge.parse,kt.convertToCanvasData=Ge.toCanvasData;const{drawRoundRect:Oi}=At;function Ci(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,s,i,r){Oi(this,t,e,s,i,r)})}(t)}const Ti=Z.get("TaskProcessor");class Ei{constructor(t){this.parallel=!0,this.time=1,this.id=s.create(s.TASK),this.task=t}run(){return ft(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){Ti.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class ki{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,s=0;for(let i=0;i<t;i++)i<=this.finishedIndex?(s+=this.list[i].time,i===this.finishedIndex&&(e=s)):e+=this.list[i].time;return this.isComplete?1:s/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&ct.assign(this.config,t),this.empty()}add(t,e){let s,i,r,a;const o=new Ei(t);return o.parent=this,"number"==typeof e?a=e:e&&(i=e.parallel,s=e.start,r=e.time,a=e.delay),r&&(o.time=r),!1===i&&(o.parallel=!1),void 0===a?this.push(o,s):(this.delayNumber++,setTimeout((()=>{this.delayNumber--,this.push(o,s)}),a)),this.isComplete=!1,o}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout((()=>this.start())))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[]}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach((t=>{t.isComplete||t.cancel()})),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)})):this.nextTask()}runParallelTasks(){this.parallelList.forEach((t=>this.runParallelTask(t)))}runParallelTask(t){t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout((()=>this.run()))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let s=this.index;s<e&&(t=this.list[s],t.parallel);s++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const s=e.length,i=this.finishedIndex+s;if(e.length){if(!this.running)return;i<this.total&&(t=this.list[i],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const Bi={map:{},recycledList:[],tasker:new ki,patternTasker:new ki,get isComplete(){return Pi.tasker.isComplete&&Pi.patternTasker.isComplete},get(t){let s=Pi.map[t.url];return s||(s=e.image(t),Pi.map[t.url]=s),s.use++,s},recycle(t){t.use--,setTimeout((()=>{t.use||Pi.recycledList.push(t)}))},clearRecycled(){const t=Pi.recycledList;t.length&&(t.forEach((t=>{!t.use&&t.url&&(delete Pi.map[t.url],t.destroy())})),t.length=0)},destroy(){Pi.map={}}},Pi=Bi,{IMAGE:Ri,create:Di}=s;class Li{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){this.use=0,this.waitComplete=[],this.innerId=Di(Ri),this.config=t||{url:""};const{url:e}=t;e.startsWith("data:")?e.startsWith("data:image/svg")&&(this.isSVG=!0):e.includes(".svg")&&(this.isSVG=!0),"svg"===this.config.format&&(this.isSVG=!0)}load(e,s){return this.loading||(this.loading=!0,Bi.tasker.add((()=>ft(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>{this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)})).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),this.waitComplete.push(e,s),this.waitComplete.length-2}unload(t,e){const s=this.waitComplete;if(e){const e=s[t+1];e&&e({type:"stop"})}s[t]=s[t+1]=void 0}onComplete(t){let e;this.waitComplete.forEach(((s,i)=>{e=i%2,s&&(t?e||s(this):e&&s(this.error))})),this.waitComplete.length=0,this.loading=!1}getCanvas(e,s,i,r){e||(e=this.width),s||(s=this.height);const a=t.origin.createCanvas(e,s),o=a.getContext("2d");return i&&(o.globalAlpha=i),o.drawImage(this.view,0,0,e,s),a}destroy(){this.config={url:""},this.waitComplete.length=0}}class Si{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 Mi extends Si{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}Mi.ADD="child.add",Mi.REMOVE="child.remove";class Ii extends Si{constructor(t,e,s,i,r){super(t,e),this.attrName=s,this.oldValue=i,this.newValue=r}}Ii.CHANGE="property.change";class Ai extends Si{constructor(t,e){super(t),Object.assign(this,e)}}Ai.LOAD="image.load",Ai.LOADED="image.loaded",Ai.ERROR="image.error";class Wi extends Si{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){"object"==typeof t?(super(Wi.RESIZE),Object.assign(this,t)):super(t),this.old=e}}Wi.RESIZE="resize";class Ni extends Si{constructor(t,e){super(t),e&&Object.assign(this,e)}}Ni.START="transform.start",Ni.CHANGE="transform.change",Ni.END="transform.end",Ni.BEFORE_START="transform.before_start",Ni.BEFORE_CHANGE="transform.before_change",Ni.BEFORE_END="transform.before_end";class Xi extends Si{constructor(t,e){super(t),this.data=e}}Xi.REQUEST="watch.request",Xi.DATA="watch.data";class Yi extends Si{constructor(t,e,s){super(t),e&&(this.data=e,this.times=s)}}Yi.CHECK_UPDATE="layout.check_update",Yi.REQUEST="layout.request",Yi.START="layout.start",Yi.BEFORE="layout.before",Yi.LAYOUT="layout.layout",Yi.AFTER="layout.after",Yi.AGAIN="layout.again",Yi.END="layout.end";class ji extends Si{}ji.FRAME="animate.frame";class zi extends Si{constructor(t,e,s,i){super(t),e&&(this.times=e),s&&(this.renderBounds=s,this.renderOptions=i)}}zi.REQUEST="render.request",zi.START="render.start",zi.BEFORE="render.before",zi.RENDER="render",zi.AFTER="render.after",zi.AGAIN="render.again",zi.END="render.end";class Ui extends Si{}Ui.START="leafer.start",Ui.BEFORE_READY="leafer.before_ready",Ui.READY="leafer.ready",Ui.AFTER_READY="leafer.after_ready",Ui.VIEW_READY="leafer.view_ready",Ui.VIEW_COMPLETED="leafer.view_completed",Ui.STOP="leafer.stop",Ui.RESTART="leafer.restart",Ui.END="leafer.end";const Hi={},Fi={isHoldSpaceKey:()=>Fi.isHold("Space"),isHold:t=>Hi[t],setDownCode(t){Hi[t]||(Hi[t]=!0)},setUpCode(t){Hi[t]=!1}},Vi={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Gi extends Si{get spaceKey(){return Fi.isHoldSpaceKey()}get left(){return Vi.left(this)}get right(){return Vi.right(this)}get middle(){return Vi.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}getInner(t){return t||(t=this.current),t.getInnerPoint(this)}getLocal(t){return t||(t=this.current),t.getLocalPoint(this)}static changeName(t,e){at.changeName(t,e)}}function Ki(t,e,s){Object.defineProperty(t,e,s)}function qi(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Zi(t){return(e,s)=>{Ki(e,s,{get(){return this.__getAttr(t)},set(e){this.__setAttr(t,e)}})}}function Qi(t,e,s,i){const r={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)},configurable:!0,enumerable:!0};Ki(t,e,Object.assign(r,i||{})),mr(t,e,s)}function Ji(t){return(e,s)=>{Qi(e,s,t)}}function $i(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.positionChanged||this.__layout.positionChange()}})}}function tr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.scaleChanged||this.__layout.scaleChange()}})}}function er(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.rotationChanged||this.__layout.rotationChange()}})}}function sr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__.around&&(this.__layout.positionChanged||this.__layout.positionChange())}})}}const ir=sr;function rr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.strokeChanged||this.__layout.strokeChange()}})}}const ar=rr;function or(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.renderChanged||this.__layout.renderChange()}})}}function nr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange()}})}}function hr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.opacityChanged||this.__layout.opacityChange()}})}}function lr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()}))}})}}function dr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(t)}))}})}}function cr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.waitParent((()=>{this.parent.__updateEraser(t)}))}})}}function ur(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),Z.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor()}})}}function pr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.leafer&&this.leafer.updateCursor()}})}}function _r(t){return(e,s)=>{Ki(e,"__DataProcessor",{get:()=>t})}}function gr(t){return(e,s)=>{Ki(e,"__LayoutProcessor",{get:()=>t})}}function fr(t,e,s){mr(t.prototype,e,s)}function mr(t,e,s){const i=t.__DataProcessor.prototype,r="_"+e,a=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),o={get(){const t=this[r];return void 0===t?s:t},set(t){this[r]=t},configurable:!0,enumerable:!0};void 0===s?o.get=function(){return this[r]}:"width"===e?o.get=function(){const t=this[r];return void 0===t?this.__naturalWidth||s:t}:"height"===e&&(o.get=function(){const t=this[r];return void 0===t?this.__naturalHeight||s:t});const n=qi(i,e);n&&n.set&&(o.set=n.set),i[a]&&(o.set=i[a],delete i[a]),Object.defineProperty(i,e,o)}const yr=new Z("rewrite"),vr=[],xr=["destroy","constructor"];function wr(t){return(e,s)=>{vr.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}}function br(){return t=>{Or()}}function Or(t){vr.length&&(vr.forEach((e=>{t&&yr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),vr.length=0)}function Cr(t,e){return s=>{var i;(t.prototype?(i=t.prototype,Object.getOwnPropertyNames(i)):Object.keys(t)).forEach((i=>{if(!(xr.includes(i)||e&&e.includes(i)))if(t.prototype){qi(t.prototype,i).writable&&(s.prototype[i]=t.prototype[i])}else s.prototype[i]=t[i]}))}}function Tr(){return t=>{st.register(t)}}function Er(){return t=>{at.register(t)}}setTimeout((()=>Or(!0)));let kr=class extends Gi{};kr.POINTER="pointer",kr.BEFORE_DOWN="pointer.before_down",kr.BEFORE_MOVE="pointer.before_move",kr.BEFORE_UP="pointer.before_up",kr.DOWN="pointer.down",kr.MOVE="pointer.move",kr.UP="pointer.up",kr.OVER="pointer.over",kr.OUT="pointer.out",kr.ENTER="pointer.enter",kr.LEAVE="pointer.leave",kr.TAP="tap",kr.DOUBLE_TAP="double_tap",kr.CLICK="click",kr.DOUBLE_CLICK="double_click",kr.LONG_PRESS="long_press",kr.LONG_TAP="long_tap",kr=gt([Er()],kr);const Br={};let Pr=class extends kr{getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Br,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Br,null,!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}assignMove(t){Br.x=t?this.totalX:this.moveX,Br.y=t?this.totalY:this.moveY}};var Rr;Pr.BEFORE_DRAG="drag.before_drag",Pr.START="drag.start",Pr.DRAG="drag",Pr.END="drag.end",Pr.OVER="drag.over",Pr.OUT="drag.out",Pr.ENTER="drag.enter",Pr.LEAVE="drag.leave",Pr=gt([Er()],Pr);let Dr=Rr=class extends kr{static setList(t){Rr.dragList=t instanceof ht?t:new ht(t)}static setData(t){this.dragData=t}};Dr.DROP="drop",Dr=Rr=gt([Er()],Dr);let Lr=class extends Pr{};Lr.BEFORE_MOVE="move.before_move",Lr.START="move.start",Lr.MOVE="move",Lr.END="move.end",Lr=gt([Er()],Lr);let Sr=class extends Gi{};Sr.BEFORE_ROTATE="rotate.before_rotate",Sr.START="rotate.start",Sr.ROTATE="rotate",Sr.END="rotate.end",Sr=gt([Er()],Sr);let Mr=class extends Pr{};Mr.SWIPE="swipe",Mr.LEFT="swipe.left",Mr.RIGHT="swipe.right",Mr.UP="swipe.up",Mr.DOWN="swipe.down",Mr=gt([Er()],Mr);let Ir=class extends Gi{};Ir.BEFORE_ZOOM="zoom.before_zoom",Ir.START="zoom.start",Ir.ZOOM="zoom",Ir.END="zoom.end",Ir=gt([Er()],Ir);let Ar=class extends Gi{};Ar.DOWN="key.down",Ar.HOLD="key.hold",Ar.UP="key.up",Ar=gt([Er()],Ar);class Wr{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(Lr.START,this.moveData)}t.path=this.moveData.path,e.emit(Lr.BEFORE_MOVE,t),e.emit(Lr.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(Ir.START,this.zoomData)}t.path=this.zoomData.path,e.emit(Ir.BEFORE_ZOOM,t),e.emit(Ir.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(Sr.START,this.rotateData)}t.path=this.rotateData.path,e.emit(Sr.BEFORE_ROTATE,t),e.emit(Sr.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(Lr.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(Ir.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(Sr.END,this.rotateData),this.rotateData=null)}destroy(){this.zoomData=this.moveData=this.rotateData=null}}const{copy:Nr,translate:Xr,toInnerPoint:Yr,scaleOfOuter:jr,rotateOfOuter:zr,skewOfOuter:Ur}=f,Hr={},Fr={updateAllWorldMatrix(t){if(t.__updateWorldMatrix(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)Gr(e[t])}},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)Kr(e[t])}},updateAllChange(t){if(Kr(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)qr(e[t])}},worldHittable(t){if(!t.__.hittable)return!1;let{parent:e}=t;for(;e;){if(!e.__.hittable||!e.__.hitChildren)return!1;e=e.parent}return!0},moveWorld(t,e,s){t.__layout.checkUpdate();const i={x:e,y:s};t.parent&&Yr(t.parent.__world,i,i,!0),Vr.moveLocal(t,i.x,i.y)},moveLocal(t,e,s=0){t.x+=e,t.y+=s},zoomOfWorld(t,e,s,i,r){t.__layout.checkUpdate();const a=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.zoomOfLocal(t,a,s,i,r)},zoomOfLocal(t,e,s,i=s,r){Nr(Hr,t.__local),r&&Xr(Hr,r.x,r.y),jr(Hr,e,s,i),r||(r=t),r.x+=Hr.e-t.__local.e,r.y+=Hr.f-t.__local.f,t.scaleX*=s,t.scaleY*=i},rotateOfWorld(t,e,s,i){t.__layout.checkUpdate();const r=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.rotateOfLocal(t,r,s,i)},rotateOfLocal(t,e,s,i){Nr(Hr,t.__local),i&&Xr(Hr,i.x,i.y),zr(Hr,e,s),i||(i=t),i.x+=Hr.e-t.__local.e,i.y+=Hr.f-t.__local.f,t.rotation=r.formatRotation(t.rotation+s)},skewOfWorld(t,e,s,i,r){t.__layout.checkUpdate();const a=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.skewOfLocal(t,a,s,i,r)},skewOfLocal(t,e,s,i,a){Nr(Hr,t.__local),a&&Xr(Hr,a.x,a.y),Ur(Hr,e,s,i),a||(a=t),a.x=Hr.e-t.__local.e,a.y=Hr.f-t.__local.f,t.skewX=r.formatSkew(t.skewX+s),t.skewY=r.formatSkew(t.skewY+i)},drop(t,e){const s={x:t.x,y:t.y};t.localToWorld(s),e.worldToInner(s),t.set(s),e.add(t)}},Vr=Fr,{updateAllWorldMatrix:Gr,updateAllWorldOpacity:Kr,updateAllChange:qr}=Vr,Zr={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.isEraser?null:t.__local,localEventBounds:t=>t.__.isEraser?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.isEraser?null: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},Qr={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,r=s.length;i<r;i++)(t=s[i]).isBranch&&(t.__tempNumber=1,e.push(t),Jr(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++)$r(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:Jr,pushAllBranchStack:$r}=Qr,ta={run(t){for(let e=0,s=t.length;e<s;e++)t[e]();t.length=0}},ea={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?Mr.UP:t>45&&t<135?Mr.DOWN:t<=45&&t>=-45?Mr.RIGHT:Mr.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:sa.getSwipeDirection(T.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 ht,{list:i}=t;for(let t=0,r=i.length;t<r;t++)i[t].hasEvent(e)&&s.push(i[t]);return s}},sa=ea,{getDragEventData:ia,getDropEventData:ra,getSwipeEventData:aa,filterPathByEventType:oa}=ea;class na{constructor(t){this.interaction=t}setDragData(t){this.dragData=ia(t,t,t)}getDragList(){return this.dragging?Dr.dragList||this.dragList:null}checkDrag(t,e){const{interaction:s}=this,{downData:i}=s;if(this.moving&&!Vi.middle(t)&&!Vi.left(t))return void s.pointerCancel();const{dragData:r}=this;if(!this.moving){const a=s.config.move.dragEmpty&&i.target.isLeafer;this.moving=(Vi.middle(t)||s.moveMode||a)&&e,this.moving&&s.emit(Lr.START,r)}this.moving||this.dragStart(t,e);const{path:a,throughPath:o}=i;this.dragData=ia(i,r,t),o&&(this.dragData.throughPath=o),this.dragData.path=a,this.moving?(s.emit(Lr.BEFORE_MOVE,this.dragData),s.emit(Lr.MOVE,this.dragData)):this.dragging&&(this.dragDragableList(),s.emit(Pr.BEFORE_DRAG,this.dragData),s.emit(Pr.DRAG,this.dragData))}dragStart(t,e){this.dragging||(this.dragging=Vi.left(t)&&e,this.dragging&&(this.interaction.emit(Pr.START,this.dragData),this.getDragableList(this.dragData.path),this.dragList=oa(this.dragData.path,Pr.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=>{Fr.moveWorld(s,t,e)}))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:s}=this,{path:i}=t;s?i.indexAt(0)!==s.indexAt(0)&&(e.emit(Pr.OUT,t,s),e.emit(Pr.OVER,t,i)):e.emit(Pr.OVER,t,i),this.dragOverPath=i}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:s}=this,{path:i}=t;e.emit(Pr.LEAVE,t,s,i),e.emit(Pr.ENTER,t,i,s),this.dragEnterPath=i}dragEnd(t){const{interaction:e}=this,{downData:s}=e;if(!s)return;const{path:i,throughPath:r}=s,a=ia(s,t,t);r&&(a.throughPath=r),a.path=i,this.moving&&e.emit(Lr.END,a),this.dragging&&(e.emit(Pr.END,a),this.swipe(t,a),this.drop(t)),this.autoMoveCancel(),this.dragReset()}swipe(t,e){const{interaction:s}=this,{downData:i}=s;if(T.getDistance(i,t)>s.config.pointer.swipeDistance){const t=aa(i,this.dragData,e);this.interaction.emit(t.type,t)}}drop(t){const e=ra(t,this.getDragList(),Dr.dragData);e.path=this.dragEnterPath,this.interaction.emit(Dr.DROP,e),this.interaction.emit(Pr.LEAVE,t,this.dragEnterPath)}dragReset(){Dr.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,{autoDistance:i,dragOut:r}=e.config.move;if(!r||!i)return;const a=e.shrinkCanvasBounds,{x:o,y:n}=a,h=z.right(a),l=z.bottom(a),d=t.x<o?i:h<t.x?-i:0,c=t.y<n?i:l<t.y?-i:0;let u=0,p=0;this.autoMoveTimer=setInterval((()=>{u+=d,p+=c,T.move(s,d,c),T.move(this.dragData,d,c),e.move(Object.assign(Object.assign({},t),{moveX:d,moveY:c,totalX:u,totalY:p})),e.pointerMoveReal(t)}),10)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.dragReset()}}const ha=["move","zoom","rotate","key"];function la(t,e,s,i,r){if(ha.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!ca(t,r)){let a;for(let o=0,n=t.children.length;o<n;o++)a=t.children[o],!s.path.has(a)&&a.__.hittable&&da(a,e,s,i,r)}}function da(t,e,s,i,r){if(t.destroyed)return!0;if(t.__.hitSelf&&t.hasEvent(e,i)&&!ca(t,r)){s.phase=i?1:t===s.target?2:3;const r=at.get(e,s);if(t.emitEvent(r,i),r.isStop)return!0}return!1}function ca(t,e){return e&&e.has(t)}const ua={getData(t){const e=t[0],s=t[1],i=T.getCenter(e.from,s.from),r=T.getCenter(e.to,s.to),a={x:r.x-i.x,y:r.y-i.y},o=T.getDistance(e.from,s.from);return{move:a,scale:T.getDistance(e.to,s.to)/o,angle:T.getChangeAngle(e.from,s.from,e.to,s.to),center:r}}},{pathHasEventType:pa,getMoveEventData:_a,getZoomEventData:ga,getRotateEventData:fa}=ea;class ma{get dragging(){return this.dragger.dragging}get moveMode(){return Fi.isHoldSpaceKey()&&this.config.move.holdSpaceKey||this.downData&&Vi.middle(this.downData)}get hitRadius(){return this.config.pointer.hitRadius}constructor(e,s,i,r){this.config={wheel:{zoomMode:!1,zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:"Windows"===t.os?{x:37.5,y:37.5}:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,through:!1,tapTime:120,longPressTime:800,transformTime:500,dragHover:!0,dragDistance:2,swipeDistance:20,ignoreMove:!1}},this.tapCount=0,this.downKeyMap={},this.target=e,this.canvas=s,this.selector=i,this.defaultPath=new ht(e),this.transformer=new Wr(this),this.dragger=new na(this),r&&(this.config=ct.default(r,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Vi.defaultLeft(t),this.emit(kr.BEFORE_DOWN,t,this.defaultPath),this.updateDownData(t),e&&(t.path=this.defaultPath),this.emit(kr.DOWN,t),this.downTime=Date.now(),this.dragger.setDragData(t),Vi.left(t)&&(this.tapWait(),this.longPressWait(t)),this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;this.downData&&Vi.defaultLeft(t);const e=this.canvas.bounds.hitPoint(t);(e||this.downData)&&(e&&!this.downData&&Vi.left(t)&&this.pointerDown(t,!0),this.pointerMoveReal(t),this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(kr.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=T.getDistance(this.downData,t)>this.config.pointer.dragDistance;this.waitTap&&e&&this.pointerWaitCancel(),this.dragger.checkDrag(t,e)}this.dragger.moving||this.config.pointer.ignoreMove||(this.updateHoverData(t),this.emit(kr.MOVE,t),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t),this.dragger.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t)),this.updateCursor(t))}pointerUp(t){t||(t=this.downData),this.downData&&(Vi.defaultLeft(t),this.emit(kr.BEFORE_UP,t,this.defaultPath),this.findPath(t),this.emit(kr.UP,t),this.emit(kr.UP,this.downData,void 0,t.path),this.touchLeave(t),this.tap(t),this.dragger.dragEnd(t),this.downData=null,this.updateCursor(t))}pointerCancel(){this.pointerUp(this.dragger.dragData)}multiTouch(t,e){const{move:s,angle:i,scale:r,center:a}=ua.getData(e);this.rotate(fa(a,i,t)),this.zoom(ga(a,r,t)),this.move(_a(a,s,t))}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}keyDown(t){const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Fi.setDownCode(e),this.emit(Ar.HOLD,t,this.defaultPath),this.moveMode&&this.updateCursor()),this.emit(Ar.DOWN,t,this.defaultPath)}keyUp(t){const{code:e}=t;this.downKeyMap[e]=!1,Fi.setUpCode(e),this.emit(Ar.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}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(kr.OUT,t,this.overPath),this.emit(kr.OVER,t,e)):this.emit(kr.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(kr.LEAVE,t,this.enterPath,e),this.emit(kr.ENTER,t,e,this.enterPath),this.enterPath=e}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(kr.LEAVE,t),this.dragger.dragging&&this.emit(Dr.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,r=[kr.DOUBLE_TAP,kr.DOUBLE_CLICK].some((e=>pa(t.path,e)));i<e.tapTime+50&&r?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout((()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(t,e){const{hitRadius:s,through:i}=this.config.pointer,r=this.selector.getByPoint(t,s,e||{through:i});return r.throughPath&&(t.throughPath=r.throughPath),t.path=r.path,r.path}updateDownData(t){t||(t=this.downData),t&&(this.findPath(t),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getDragList(),name:kr.MOVE}),this.hoverData=t)}updateCursor(t){if(t||(this.updateHoverData(),t=this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.moveMode)return this.setCursor(this.downData?"grabbing":"grab");if(!t||this.dragger.dragging)return;const e=t.path;let s;for(let t=0,i=e.length;t<i;t++)if(s=e.list[t],s.cursor){const{cursor:t}=s;return void this.setCursor("grab"===t&&this.downData?"grabbing":t)}this.setCursor("default")}setCursor(t){this.cursor=t,this.canvas.setCursor(t)}emitTap(t){this.emit(kr.TAP,t),this.emit(kr.CLICK,t)}emitDoubleTap(t){this.emit(kr.DOUBLE_TAP,t),this.emit(kr.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(kr.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(kr.LONG_TAP,t),pa(t.path,kr.LONG_TAP)&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new V(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Wi.RESIZE,this.__onResize,this)],t.once(Ui.READY,(()=>this.__onResize()))}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,s,i){this.running&&function(t,e,s,i){if(!s&&!e.path)return;let r;e.type=t,s?e=Object.assign(Object.assign({},e),{path:s}):s=e.path,e.target=s.indexAt(0);for(let a=s.length-1;a>-1;a--){if(r=s.list[a],da(r,t,e,!0,i))return;r.isApp&&la(r,t,e,!0,i)}for(let a=0,o=s.length;a<o;a++)if(r=s.list[a],r.isApp&&la(r,t,e,!1,i),da(r,t,e,!1,i))return}(t,e,s,i)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class ya{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}ya.custom={};const{toOuterOf:va}=z;class xa{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.boxChange(),this.positionChange()}checkUpdate(e){const{leafer:s}=this.leaf;if(s)s.ready?(t.realtimeLayout||e)&&s.watcher.changed&&s.layouter.layout():s.start();else{let e=this.leaf;for(;e.parent;)e=e.parent;t.layout(e)}}getTransform(t){return this.checkUpdate(),"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={}),va(this.contentBounds,this.leaf.__world,this._worldContentBounds),this._worldContentBounds}getWorldBoxBounds(){return this._worldBoxBounds||(this._worldBoxBounds={}),va(this.boxBounds,this.leaf.__world,this._worldBoxBounds),this._worldBoxBounds}getWorldStrokeBounds(){return this._worldStrokeBounds||(this._worldStrokeBounds={}),va(this.strokeBounds,this.leaf.__world,this._worldStrokeBounds),this._worldStrokeBounds}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this.strokeBounds=this.boxBounds,this.localStrokeBounds=this.leaf.__local,t&&this.spreadRenderCancel()}spreadRenderCancel(){this.renderBounds=this.strokeBounds,this.localRenderBounds=this.localStrokeBounds}spreadStroke(){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.renderSpread||this.spreadRenderCancel()}spreadRender(){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}}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}positionChange(){this.positionChanged=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}const wa={},ba={on(t,e,s){let i,r,a;s&&("boolean"==typeof s?i=s:(i=s.capture,r=s.once));const o=Oa(this,i,!0),n="string"==typeof t?t.split(" "):t,h=r?{listener:e,once:r}:{listener:e};n.forEach((t=>{t&&(a=o[t],a?-1===a.findIndex((t=>t.listener===e))&&a.push(h):o[t]=[h])}))},off(t,e,s){let i,r,a;s&&(i="boolean"==typeof s?s:s.capture);const o=Oa(this,i);("string"==typeof t?t.split(" "):t).forEach((t=>{t&&(r=o[t],r&&(a=r.findIndex((t=>t.listener===e)),a>-1&&r.splice(a,1),r.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){!e&&at.has(t)&&(e=at.get(t,{type:t,target:this,current:this}));const i=Oa(this,s)[t];if(i){let r;for(let a=0,o=i.length;a<o&&(r=i[a],r.listener(e),r.once&&(this.off(t,r.listener,s),a--,o--),!e||!e.isStopNow);a++);}},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 Oa(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:wa)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:wa)}}const Ca={__setAttr(t,e){if(this.leafer&&this.leafer.created){if("object"==typeof e||this.__.__getInput(t)!==e){this.__[t]=e;const{CHANGE:s}=Ii,i=new Ii(s,this,t,this.__.__get(t),e);this.hasEvent(s)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}}else this.__[t]=e},__getAttr(t){return this.__.__get(t)}},{sin:Ta,cos:Ea}=Math,ka=Object.assign(Object.assign({},f.defaultMatrix),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0}),Ba={x:.5,y:.5},Pa={__updateWorldMatrix(){const t=this.parent?this.parent.__world:ka,e=this.__local,s=this.__world;if(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;const i=this.__;s.scaleX=t.scaleX*i.scaleX,s.scaleY=t.scaleY*i.scaleY,s.rotation=t.rotation+i.rotation,s.skewX=t.skewX+i.skewX,s.skewY=t.skewY+i.skewY}else 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,s.scaleX=t.scaleX,s.scaleY=t.scaleY,s.rotation=t.rotation,s.skewX=t.skewX,s.skewY=t.skewY},__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:r,skewX:o,skewY:n}=this.__;r||o||n?(r*=a,o&&(o*=a),n&&(n*=a),t.a=s*Ea(r+n),t.b=s*Ta(r+n),t.c=i*-Ta(r-o),t.d=i*Ea(r-o)):(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)}if(e.positionChanged){t.e=this.__.x,t.f=this.__.y;const{width:s,height:i,around:r}=this.__;if(r&&s&&i){const e="center"===r?Ba:r,a=s*e.x,o=i*e.y;t.e-=a*t.a+o*t.c,t.f-=a*t.b+o*t.d}e.positionChanged=!1}this.__layout.matrixChanged=!1}},{toOuterOf:Ra,copyAndSpread:Da}=z,La={__updateWorldBounds(){var t;if(this.__layout.boundsChanged){let e;const s=this.__layout;s.boxChanged&&(this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),s.boxChanged=!1,e=!0),s.localBoxChanged&&(this.__updateLocalBoxBounds(),s.localBoxChanged=!1,s.strokeSpread&&(s.strokeChanged=!0),s.renderSpread&&(s.renderChanged=!0),null===(t=this.parent)||void 0===t||t.__layout.boxChange()),s.strokeChanged&&(s.strokeSpread=this.__updateStrokeSpread(),s.strokeSpread?(s.strokeBounds===s.boxBounds&&s.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):s.spreadStrokeCancel(),s.strokeChanged=!1,s.renderSpread&&(s.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),e||(e=!0)),s.renderChanged&&(s.renderSpread=this.__updateRenderSpread(),s.renderSpread?(s.renderBounds!==s.boxBounds&&s.renderBounds!==s.strokeBounds||s.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):s.spreadRenderCancel(),s.renderChanged=!1,this.parent&&this.parent.__layout.renderChange()),s.boundsChanged=!1,Ra(this.__layout.renderBounds,this.__world,this.__world),e&&this.__onUpdateSize()}else Ra(this.__layout.renderBounds,this.__world,this.__world)},__updateLocalBoxBounds(){Ra(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Ra(this.__layout.strokeBounds,this.__local,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Ra(this.__layout.renderBounds,this.__local,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,{width:e,height:s}=this.__;t.x=0,t.y=0,t.width=e,t.height=s},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height,this.around&&(e.positionChanged=e.matrixChanged=!0,this.__updateWorldMatrix())},__updateStrokeBounds(){Da(this.__layout.strokeBounds,this.__layout.boxBounds,this.__layout.strokeSpread)},__updateRenderBounds(){Da(this.__layout.renderBounds,this.__layout.strokeBounds,this.__layout.renderSpread)}},{toInnerRadiusPointOf:Sa,copy:Ma,setRadius:Ia}=T,Aa={},Wa={__hitWorld(t){return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.hitCanvasChanged=!1),this.__.hitRadius&&(Ma(Aa,t),Ia(t=Aa,this.__.hitRadius)),Sa(t,this.__world,Aa),this.__hit(Aa)},__drawHitPath(t){this.__drawRenderPath(t)}},Na={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__world,e.matrix),t.opacity=this.__worldOpacity,this.__.__single){const s=t.getSameCanvas(!0);this.__draw(s,e);const i=this.__.isEraser?"destination-out":this.__.blendMode;e.matrix||this.__hasMirror?t.copyWorldByReset(s,null,null,i):t.copyWorldToInner(s,this.__world,this.__layout.renderBounds,i),s.recycle()}else 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)}},Xa={__updateEraser(t){this.__hasEraser=!!t||this.children.some((t=>t.__.isEraser))},__updateMask(t){this.__hasMask=!!t||this.children.some((t=>t.__.isMask))},__renderMask(t,e,s){e.resetTransform(),e.useMask(s),t.resetTransform(),t.opacity=this.__worldOpacity,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--)}}},Ya={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__worldOpacity)if(this.__.__single){t.resetTransform();const s=t.getSameCanvas();this.__renderBranch(s,e),t.opacity=this.__worldOpacity;const i=this.__.isEraser?"destination-out":this.__.blendMode;e.matrix?t.copyWorld(s,null,null,i):t.copyWorld(s,this.__world,this.__world,i),s.recycle()}else this.__renderBranch(t,e)},__renderBranch(t,e){let s;const{children:i}=this;if(this.__hasMask&&i.length>1){let r,a=t.getSameCanvas(),o=t.getSameCanvas();for(let n=0,h=i.length;n<h;n++)s=i[n],s.isMask?(r?(this.__renderMask(t,o,a),a.clear(),o.clear()):r=!0,s.__render(a,e)):s.__render(o,e);this.__renderMask(t,o,a),a.recycle(),o.recycle()}else{const{bounds:r,hideBounds:a}=e;for(let o=0,n=i.length;o<n;o++)s=i[o],r&&!r.hit(s.__world,e.matrix)||a&&a.includes(s.__world,e.matrix)||s.__render(t,e)}}},{LEAF:ja,create:za}=s,{toInnerPoint:Ua,toOuterPoint:Ha}=f,{tempToOuterOf:Fa,copy:Va}=T,{moveLocal:Ga,zoomOfLocal:Ka,rotateOfLocal:qa,skewOfLocal:Za}=Fr;let Qa=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return pt}get __LayoutProcessor(){return xa}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get boxBounds(){return this.getBounds("box","inner")}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 resizeable(){return!0}get __hasMirror(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}constructor(t){this.innerId=za(ja),this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0},this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0},this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),t&&(t.children?this.set(t):Object.assign(this,t))}waitParent(t){this.parent?t():this.__parentWait?this.__parentWait.push(t):this.__parentWait=[t]}waitLeafer(t){this.leafer?t():this.__leaferWait?this.__leaferWait.push(t):this.__leaferWait=[t]}nextRender(t){this.leafer?this.leafer.nextRender(t):this.waitLeafer((()=>this.leafer.nextRender(t)))}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer=t,t&&(this.__level=this.parent?this.parent.__level+1:1,this.__leaferWait&&ta.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){}toJSON(){return this.__.__getInputData()}toString(){return JSON.stringify(this.toJSON())}__setAttr(t,e){}__getAttr(t){}forceUpdate(t){void 0===t?t="scaleX":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){}__updateMask(t){}__renderMask(t,e,s){}__removeMask(t){}getWorld(t){return this.__layout.checkUpdate(),"x"===t?this.__world.e:"y"===t?this.__world.f:this.__world[t]}getBounds(t,e="world"){return this.__layout.getBounds(t,e)}worldToLocal(t,e,s,i){this.parent?this.parent.worldToInner(t,e,s,i):e&&Va(e,t)}localToWorld(t,e,s,i){this.parent?this.parent.innerToWorld(t,e,s,i):e&&Va(e,t)}worldToInner(t,e,s,i){i&&(i.innerToWorld(t,e,s),t=e||t),Ua(this.worldTransform,t,e,s)}innerToWorld(t,e,s,i){Ha(this.worldTransform,t,e,s),i&&i.worldToInner(e||t,null,s)}getInnerPoint(t,e,s,i){const r=i?t:{};return this.worldToInner(t,r,s,e),r}getInnerPointByLocal(t,e,s,i){return this.getInnerPoint(t,this.parent,s,i)}getLocalPoint(t,e,s,i){const r=i?t:{};return this.worldToLocal(t,r,s,e),r}getLocalPointByInner(t,e,s,i){return this.getWorldPoint(t,this.parent,s,i)}getWorldPoint(t,e,s,i){const r=i?t:{};return this.innerToWorld(t,r,s,e),r}getWorldPointByLocal(t,e,s,i){const r=i?t:{};return this.localToWorld(t,r,s,e),r}move(t,e){Ga(this,t,e)}scaleOf(t,e,s){Ka(this,Fa(t,this.localTransform),e,s)}rotateOf(t,e){qa(this,Fa(t,this.localTransform),e)}skewOf(t,e,s){Za(this,Fa(t,this.localTransform),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(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}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.destroyed||(this.parent&&this.remove(),this.children&&this.removeAll(!0),this.__.destroy(),this.__layout.destroy(),this.__captureMap=this.__bubbleMap=this.__parentWait=this.__leaferWait=null,this.destroyed=!0)}};Qa=gt([Cr(Ca),Cr(Pa),Cr(La),Cr(Wa),Cr(ba),Cr(Na)],Qa);const{setByListWithHandle:Ja}=z,{sort:$a}=Qr,{localBoxBounds:to,localEventBounds:eo,localRenderBounds:so,maskLocalBoxBounds:io,maskLocalEventBounds:ro,maskLocalRenderBounds:ao}=Zr;let oo=class extends Qa{constructor(){super(),this.isBranch=!0,this.children=[]}__updateStrokeSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(){Ja(this.__layout.boxBounds,this.children,this.__hasMask?io:to)}__updateStrokeBounds(){Ja(this.__layout.strokeBounds,this.children,this.__hasMask?ro:eo)}__updateRenderBounds(){Ja(this.__layout.renderBounds,this.children,this.__hasMask?ao:so)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let s=0,i=e.length;s<i;s++)e[s].__tempNumber=s,e[s].__.zIndex&&(t=!0);e.sort($a),this.__layout.affectChildrenSort=t}}add(t,e){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),t.__layout.boundsChanged||t.__layout.positionChange(),t.__parentWait&&ta.run(t.__parentWait),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Mi.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){t.forEach((t=>this.add(t)))}remove(t,e){if(t){const s=this.children.indexOf(t);s>-1&&(this.children.splice(s,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}else void 0===t&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach((e=>{this.__realRemoveChild(e),t&&e.destroy()})))}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Mi.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const s=new Mi(t,e,this);e.hasEvent(t)&&e.emitEvent(s),this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(s),this.leafer.emitEvent(s)}};oo=gt([Cr(Ya),Cr(Xa)],oo);const no=Z.get("plugin"),ho={power:{},list:[],onLeafer(t){ho.list.forEach((e=>{e.onLeafer&&e.onLeafer(t)}))}};function lo(t,e){const s={},{power:i,list:r}=ho;if(i||no.error("need add PluginManager.power = LeaferUI"),r.includes(t))no.warn("repeat run",t.name);else{r.push(t),t.import?t.import.forEach((t=>{i[t]?s[t]=i[t]:no.error(t+" non-existent")})):no.warn("no import");try{t.run(s,e)}catch(t){no.error(t)}}}export{ji as AnimateEvent,G as AutoBounds,te as BezierHelper,V as Bounds,z as BoundsHelper,oo as Branch,Qr as BranchHelper,Ya as BranchRender,nt as CanvasManager,Mi as ChildEvent,e as Creator,ya as Cursor,ct as DataHelper,Z as Debug,Pr as DragEvent,Dr as DropEvent,le as EllipseHelper,Si as Event,at as EventCreator,_t as FileHelper,dt as HitCanvasManager,Ai as ImageEvent,Bi as ImageManager,s as IncrementId,ma as InteractionBase,ea as InteractionHelper,Ar as KeyEvent,Fi as Keyboard,Yi as LayoutEvent,Qa as Leaf,La as LeafBounds,Zr as LeafBoundsHelper,pt as LeafData,Ca as LeafDataProxy,ba as LeafEventer,Fr as LeafHelper,Wa as LeafHit,xa as LeafLayout,lt as LeafLevelList,ht as LeafList,Xa as LeafMask,Pa as LeafMatrix,Na as LeafRender,Et as LeaferCanvasBase,Ui as LeaferEvent,Li as LeaferImage,r as MathHelper,B as Matrix,f as MatrixHelper,Lr as MoveEvent,ua as MultiTouchHelper,Dt as NeedConvertToCanvasCommandMap,a as OneRadian,o as PI2,n as PI_2,wi as PathBounds,cs as PathCommandDataHelper,Pt as PathCommandMap,Ge as PathConvert,bi as PathCorner,Bs as PathCreator,Us as PathDrawer,kt as PathHelper,It as PathNumberCommandLengthMap,Mt as PathNumberCommandMap,t as Platform,ho as PluginManager,k as Point,T as PointHelper,Vi as PointerButton,kr as PointerEvent,Ii as PropertyEvent,At as RectHelper,zi as RenderEvent,Wi as ResizeEvent,Sr as RotateEvent,$ as Run,q as StringNumberMap,Mr as SwipeEvent,Ei as TaskItem,ki as TaskProcessor,Ni as TransformEvent,K as TwoPointBounds,P as TwoPointBoundsHelper,st as UICreator,Gi as UIEvent,ta as WaitHelper,Xi as WatchEvent,Ir as ZoomEvent,or as affectRenderBoundsType,rr as affectStrokeBoundsType,Zi as aliasType,sr as boundsType,Ci as canvasPatch,Tt as canvasSizeAttrs,pr as cursorType,_r as dataProcessor,Ji as dataType,mr as defineDataProcessor,Ki as defineKey,Qi as defineLeafAttr,cr as eraserType,qi as getDescriptor,ur as hitType,gr as layoutProcessor,dr as maskType,hr as opacityType,ir as pathType,$i as positionType,Tr as registerUI,Er as registerUIEvent,wr as rewrite,br as rewriteAble,er as rotationType,tr as scaleType,fr as setDefaultValue,lr as sortType,ar as strokeType,nr as surfaceType,Cr as useModule,lo as usePlugin};
1
+ const t={imageSuffix:"leaf"},e={},s={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=i;return e[t]?e[t]++:(e[t]=1,0)}},i=s,r={within:(t,e,s)=>(t<e&&(t=e),t>s&&(t=s),t),fourNumber(t){let e,s,i,r;if(t instanceof Array)switch(t.length){case 4:return t;case 2:e=i=t[0],s=r=t[1];break;case 3:e=t[0],s=r=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,r]},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),t),getGapRotation(t,e){if(e>1){const s=Math.abs(t%e);(s<1||s>e-1)&&(t=Math.round(t/e)*e)}return t},formatSkew:t=>r.within(t,-90,90)},a=Math.PI/180,o=2*Math.PI,n=Math.PI/2,{sin:h,cos:l,acos:d,atan:c,sqrt:u,PI:p}=Math,_={};function g(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const f={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},tempMatrix:{},set(t,e=1,s=0,i=0,r=1,a=0,o=0){t.a=e,t.b=s,t.c=i,t.d=r,t.e=a,t.f=o},get:g,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.b*=e,t.c*=s,t.d*=s},scaleOfOuter(t,e,s,i=s){m.toInnerPoint(t,e,_),m.scaleOfInner(t,_,s,i)},scaleOfInner(t,e,s,i=s){m.translateInner(t,e.x,e.y),m.scale(t,s,i),m.translateInner(t,-e.x,-e.y)},rotate(t,e){const s=l(e*=a),i=h(e),{a:r,b:o,c:n,d:d}=t;t.a=r*s-o*i,t.b=r*i+o*s,t.c=n*s-d*i,t.d=n*i+d*s},rotateOfOuter(t,e,s){m.toInnerPoint(t,e,_),m.rotateOfInner(t,_,s)},rotateOfInner(t,e,s){m.translateInner(t,e.x,e.y),m.rotate(t,s),m.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:i,b:r,c:o,d:n}=t;s&&(s*=a,t.a=i+o*s,t.b=r+n*s),e&&(e*=a,t.c=o+i*e,t.d=n+r*e)},skewOfOuter(t,e,s,i){m.toInnerPoint(t,e,_),m.skewOfInner(t,_,s,i)},skewOfInner(t,e,s,i){m.translateInner(t,e.x,e.y),m.skew(t,s,i),m.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:i,c:r,d:a,e:o,f:n}=t;t.a=e.a*s+e.b*r,t.b=e.a*i+e.b*a,t.c=e.c*s+e.d*r,t.d=e.c*i+e.d*a,t.e=e.e*s+e.f*r+o,t.f=e.e*i+e.f*a+n},preMultiply(t,e){const{a:s,b:i,c:r,d:a,e:o,f:n}=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=r*e.a+a*e.c,t.d=r*e.b+a*e.d),t.e=o*e.a+n*e.c+e.e,t.f=o*e.b+n*e.d+e.f},divide(t,e){m.preMultiply(t,m.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=m;return m.copy(e,t),m.invert(e),e},invert(t){const{a:e,b:s,c:i,d:r,e:a,f:o}=t,n=1/(e*r-s*i);t.a=r*n,t.b=-s*n,t.c=-i*n,t.d=e*n,t.e=-(a*r-o*i)*n,t.f=-(o*e-a*s)*n},toOuterPoint(t,e,s,i){const{x:r,y:a}=e;s||(s=e),s.x=r*t.a+a*t.c,s.y=r*t.b+a*t.d,i||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,i){const{x:r,y:a}=e,{a:o,b:n,c:h,d:l}=t,d=1/(o*l-n*h);if(s||(s=e),s.x=(r*l-a*h)*d,s.y=(a*o-r*n)*d,!i){const{e:e,f:i}=t;s.x-=(e*l-i*h)*d,s.y-=(i*o-e*n)*d}},decompose(t){const{a:e,b:s,c:i,d:r}=t;let o=e,n=r,h=0,l=0,_=0;if(s||i){const t=e*r-s*i,g=e*i+s*r;if(s){const i=e*e+s*s;o=u(i),n=t/o;const r=e/o;h=s>0?d(r):-d(r),l=c(g/i)/a}else{const e=i*i+r*r;n=u(e),o=t/n;const s=i/n;h=p/2-(r>0?d(-s):-d(s)),_=c(g/e)/a}h/=a}return{x:t.e,y:t.f,scaleX:o,scaleY:n,rotation:h,skewX:l,skewY:_}},reset(t){m.set(t)}},m=f,{toInnerPoint:y,toOuterPoint:v}=f,{sin:x,cos:w,abs:b,sqrt:O,atan2:C}=Math,T={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},setRadius(t,e,s){t.radiusX=e,t.radiusY=void 0===s?e:s},copy(t,e){t.x=e.x,t.y=e.y},move(t,e,s){t.x+=e,t.y+=s},rotate(t,e,s){s||(s=E.defaultPoint);const i=w(e*a),r=x(e*a),o=t.x-s.x,n=t.y-s.y;t.x=s.x+o*i-n*r,t.y=s.y+o*r+n*i},tempToInnerOf(t,e){const{tempPoint:s}=E;return E.copy(s,t),y(e,s,s),s},tempToOuterOf(t,e){const{tempPoint:s}=E;return E.copy(s,t),v(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),y(e,t,s),s.radiusX=Math.abs(t.radiusX/e.scaleX),s.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,s){y(e,t,s)},toOuterOf(t,e,s){v(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=b(e.x-t.x),i=b(e.y-t.y);return O(s*s+i*i)},getAngle:(t,e)=>E.getAtan2(t,e)/a,getChangeAngle(t,e,s,i){i||(i=e);let r=E.getAngle(t,e);const a=E.getAngle(s,i)-r;return a<-180?a+360:a},getAtan2:(t,e)=>C(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s){const i=E.getAtan2(t,e);return{x:t.x+w(i)*s,y:t.y+x(i)*s}},reset(t){E.reset(t)}},E=T;class k{constructor(t,e){"object"==typeof t?T.copy(this,t):T.set(this,t,e)}set(t,e){T.set(this,t,e)}copy(t){return T.copy(this,t),this}clone(){return new k(this)}rotate(t,e){return T.rotate(this,t,e),this}toInnerOf(t,e){return T.toInnerOf(this,t,e),this}toOuterOf(t,e){return T.toOuterOf(this,t,e),this}getCenter(t){return T.getCenter(this,t)}getDistance(t){return T.getDistance(this,t)}getAngle(t){return T.getAngle(this,t)}getAtan2(t){return T.getAtan2(this,t)}reset(){T.reset(this)}}class B{constructor(t,e,s,i,r,a){"object"==typeof t?f.copy(this,t):f.set(this,t,e,s,i,r,a)}set(t,e,s,i,r,a){f.set(this,t,e,s,i,r,a)}copy(t){return f.copy(this,t),this}clone(){return new B(this)}translate(t,e){return f.translate(this,t,e),this}translateInner(t,e){return f.translateInner(this,t,e),this}scale(t,e){return f.scale(this,t,e),this}scaleOfOuter(t,e,s){return f.scaleOfOuter(this,t,e,s),this}scaleOfInner(t,e,s){return f.scaleOfInner(this,t,e,s),this}rotate(t){return f.rotate(this,t),this}rotateOfOuter(t,e){return f.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return f.rotateOfInner(this,t,e),this}skew(t,e){return f.skew(this,t,e),this}skewOfOuter(t,e,s){return f.skewOfOuter(this,t,e,s),this}skewOfInner(t,e,s){return f.skewOfInner(this,t,e,s),this}multiply(t){return f.multiply(this,t),this}preMultiply(t){return f.preMultiply(this,t),this}divide(t){return f.divide(this,t),this}invert(){return f.invert(this),this}toOuterPoint(t,e,s){f.toOuterPoint(this,t,e,s)}toInnerPoint(t,e,s){f.toInnerPoint(this,t,e,s)}decompose(){return f.decompose(this)}reset(){f.reset(this)}}const P={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,r){R(t,e,s),R(t,e+i,s+r)},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:R}=P,{tempPointBounds:D,setPoint:L,addPoint:S,toBounds:M}=P,{toOuterPoint:I}=f;let A,W,N,X;const Y={},j={},z={tempBounds:{},set(t,e=0,s=0,i=0,r=0){t.x=e,t.y=s,t.width=i,t.height=r},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s,i){i||(i=s),U.set(t,e.x-s,e.y-i,e.width+2*s,e.height+2*i)},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),U.move(t,e,s),t),toOffsetOutBounds(t,e,s){e?F(e,t):e=t,s?(e.offsetX=-(U.right(s)-t.x),e.offsetY=-(U.bottom(s)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),U.move(e,-e.offsetX,-e.offsetY)},scale(t,e,s){s||(s=e),t.x&&(t.x*=e),t.y&&(t.y*=s),t.width*=e,t.height*=s},tempToOuterOf:(t,e)=>(U.copy(U.tempBounds,t),U.toOuterOf(U.tempBounds,e),U.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),U.toOuterOf(t,e),t),toOuterOf(t,e,s){if(s||(s=t),0===e.b&&0===e.c){const{a:i,d:r}=e;i>0?(s.width=t.width*i,s.x=e.e+t.x*i):(s.width=t.width*-i,s.x=e.e+t.x*i-s.width),r>0?(s.height=t.height*r,s.y=e.f+t.y*r):(s.height=t.height*-r,s.y=e.f+t.y*r-s.height)}else Y.x=t.x,Y.y=t.y,I(e,Y,j),L(D,j.x,j.y),Y.x=t.x+t.width,I(e,Y,j),S(D,j.x,j.y),Y.y=t.y+t.height,I(e,Y,j),S(D,j.x,j.y),Y.x=t.x,I(e,Y,j),S(D,j.x,j.y),M(D,s)},getFitMatrix(t,e){const s=Math.min(1,Math.min(t.width/e.width,t.height/e.height));return new B(s,0,0,s,-Math.ceil(e.x*s),-Math.ceil(e.y*s))},getSpread(t,e,s){const i={};return U.copyAndSpread(i,t,e,s),i},spread(t,e,s){U.copyAndSpread(t,t,e,s)},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)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},add(t,e){A=t.x+t.width,W=t.y+t.height,N=e.x+e.width,X=e.y+e.height,A=A>N?A:N,W=W>X?W:X,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=A-t.x,t.height=W-t.y},addList(t,e){U.setByListWithHandle(t,e,void 0,!0)},setByList(t,e,s=!1){U.setByListWithHandle(t,e,void 0,s)},addListWithHandle(t,e,s){U.setByListWithHandle(t,e,s,!0)},setByListWithHandle(t,e,s,i=!1){let r,a=!0;for(let o=0,n=e.length;o<n;o++)r=s?s(e[o]):e[o],r&&(r.width||r.height)&&(a?(a=!1,i||F(t,r)):H(t,r));a&&U.reset(t)},setByPoints(t,e){e.forEach(((t,e)=>{0===e?L(D,t.x,t.y):S(D,t.x,t.y)})),M(D,t)},hitRadiusPoint:(t,e,s)=>(s&&(e=T.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=T.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=U.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=U.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=U.tempToOuterOf(e,s));let{x:i,y:r,width:a,height:o}=e;return A=i+a,W=r+o,N=t.x+t.width,X=t.y+t.height,i=i>t.x?i:t.x,r=r>t.y?r:t.y,A=A<N?A:N,W=W<X?W:X,a=A-i,o=W-r,{x:i,y:r,width:a,height:o}},intersect(t,e,s){U.copy(t,U.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){U.set(t)}},U=z,{add:H,copy:F}=U;class V{constructor(t,e,s,i){"object"==typeof t?z.copy(this,t):z.set(this,t,e,s,i)}set(t,e,s,i){z.set(this,t,e,s,i)}copy(t){return z.copy(this,t),this}clone(){return new V(this)}scale(t,e){return z.scale(this,t,e),this}toOuterOf(t,e){return z.toOuterOf(this,t,e),this}getFitMatrix(t){return z.getFitMatrix(this,t)}spread(t){return z.spread(this,t),this}ceil(){return z.ceil(this),this}unsign(){return z.unsign(this),this}add(t){return z.add(this,t),this}addList(t){return z.setByList(this,t,!0),this}setByList(t,e){return z.setByList(this,t,e),this}addListWithHandle(t,e){return z.setByListWithHandle(this,t,e,!0),this}setByListWithHandle(t,e,s){return z.setByListWithHandle(this,t,e,s),this}setByPoints(t){return z.setByPoints(this,t),this}hitPoint(t,e){return z.hitPoint(this,t,e)}hitRadiusPoint(t,e){return z.hitRadiusPoint(this,t,e)}hit(t,e){return z.hit(this,t,e)}includes(t,e){return z.includes(this,t,e)}intersect(t,e){return z.intersect(this,t,e),this}getIntersect(t,e){return new V(z.getIntersectData(this,t,e))}isSame(t){return z.isSame(this,t)}isEmpty(){return z.isEmpty(this)}reset(){z.reset(this)}}class G{constructor(t,e,s,i,r,a){"object"==typeof t?this.copy(t):this.set(t,e,s,i,r,a)}set(t=0,e=0,s=0,i=0,r=0,a=0){this.top=t,this.right=e,this.bottom=s,this.left=i,this.width=r,this.height=a}copy(t){const{top:e,right:s,bottom:i,left:r,width:a,height:o}=t;this.set(e,s,i,r,a,o)}getBoundsFrom(t){const{top:e,right:s,bottom:i,left:r,width:a,height:o}=this;return new V(r,e,a||t.width-r-s,o||t.height-e-i)}}class K{constructor(t,e){P.setPoint(this,t,e)}addPoint(t,e){P.addPoint(this,t,e)}addBounds(t,e,s,i){P.addBounds(this,t,e,s,i)}add(t){P.add(this,t)}}const q={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 Z{constructor(t){this.repeatMap={},this.name=t}static get(t){return new Z(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(Q.enable){if(Q.filterList.length&&Q.filterList.every((t=>t!==this.name)))return;if(Q.excludeList.length&&Q.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}warn(...t){Q.enable&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}Z.filterList=[],Z.excludeList=[];const Q=Z,J=Z.get("RunTime");class ${static start(t,e){const i=s.create(s.RUNTIME);return tt.currentId=tt.idMap[i]=e?performance.now():Date.now(),tt.currentName=tt.nameMap[i]=t,tt.nameToIdMap[t]=i,i}static end(t,e){const s=tt.idMap[t],i=tt.nameMap[t];tt.idMap[t]=tt.nameMap[t]=tt.nameToIdMap[i]=void 0,e?J.log(i,performance.now()-s,"µs"):J.log(i,Date.now()-s,"ms")}static endOfName(t,e){const s=tt.nameToIdMap[t];void 0!==s&&tt.end(s,e)}}$.idMap={},$.nameMap={},$.nameToIdMap={};const tt=$,et=Z.get("UICreator"),st={list:{},register(t){const{__tag:e}=t.prototype;it[e]?et.repeat(e):it[e]=t},get(t,e,s,i,r,a){const o=new it[t](e);return void 0!==s&&(o.x=s,i&&(o.y=i),r&&(o.width=r),a&&(o.height=a)),o}},{list:it}=st,rt=Z.get("EventCreator"),at={nameList:{},register(t){let e;Object.keys(t).forEach((s=>{e=t[s],"string"==typeof e&&(ot[e]?rt.repeat(e):ot[e]=t)}))},changeName(t,e){const s=ot[t];if(s){const i=Object.keys(s).find((e=>s[e]===t));i&&(s[i]=e,ot[e]=s)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new ot[t](...e)},{nameList:ot}=at;class nt{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let s;const{list:i}=this;for(let e=0,r=i.length;e<r;e++)if(s=i[e],s.recycled&&s.isSameSize(t))return s.recycled=!1,s.manager||(s.manager=this),s;const r=e.canvas(t);return this.add(r),r}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}destroy(){this.clear()}}class ht{get length(){return this.list.length}constructor(t){this.reset(),t&&(t instanceof Array?this.pushList(t):this.push(t))}has(t){return t&&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,r=e.length;i<r;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 ht;return this.list.forEach((e=>{t.push(e)})),t}reset(){this.list=[],this.keys={}}destroy(){this.list=null}}class lt{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 dt extends nt{constructor(){super(...arguments),this.pathTypeList=new ht,this.imageTypeList=new ht}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.length&&(t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset())}clear(){this.clearPathType(),this.clearImageType()}}const ct={default:(t,e)=>(ut(e,t),ut(t,e),t),assign(t,e){let s;Object.keys(e).forEach((i=>{var r;s=e[i],(null==s?void 0:s.constructor)===Object&&(null===(r=t[i])||void 0===r?void 0:r.constructor)===Object?ut(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:ut}=ct;class pt{constructor(t){this.__leaf=t}__get(t){if(this.__input){const e=this.__input[t];if(void 0!==e)return 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];if(void 0!==e)return e}return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(){const t={tag:this.__leaf.tag},{__input:e}=this;let s,i;for(let r in this)s=r.substring(1),void 0!==this[s]&&(i=e?e[s]:void 0,t[s]=void 0===i?this[r]:i);return t}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){"pass-through"===this.blendMode?this.__leaf.__hasEraser||this.isEraser?this.__single=!0:this.__single&&(this.__single=!1):this.__single=!0}destroy(){this.__input=this.__middle=null}}const _t={mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]}};function gt(t,e,s,i){var r,a=arguments.length,o=a<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 n=t.length-1;n>=0;n--)(r=t[n])&&(o=(a<3?r(o):a>3?r(e,s,o):r(e,s))||o);return a>3&&o&&Object.defineProperty(e,s,o),o}function ft(t,e,s,i){return new(s||(s=Promise))((function(r,a){function o(t){try{h(i.next(t))}catch(t){a(t)}}function n(t){try{h(i.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,n)}h((i=i.apply(t,e||[])).next())}))}function mt(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)}}"function"==typeof SuppressedError&&SuppressedError;const yt=[];function vt(){return(t,e)=>{yt.push(e)}}const xt=[];class wt{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||xt)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;yt.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))})),this.textBaseline="alphabetic"}setTransform(t,e,s,i,r,a){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,i,r,a){"object"==typeof t?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,s,i,r,a)}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,r,a,o,n,h){switch(arguments.length){case 9:if(e<0){const t=-e/i*n;i+=e,e=0,a+=t,n-=t}if(s<0){const t=-s/r*h;r+=s,s=0,o+=t,h-=t}this.context.drawImage(t,e,s,i,r,a,o,n,h);break;case 5:this.context.drawImage(t,e,s,i,r);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,i,r,a){}quadraticCurveTo(t,e,s,i){}closePath(){}arc(t,e,s,i,r,a){}arcTo(t,e,s,i,r){}ellipse(t,e,s,i,r,a,o,n){}rect(t,e,s,i){}roundRect(t,e,s,i,r){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,i){}createPattern(t,e){}createRadialGradient(t,e,s,i,r,a){}fillText(t,e,s,i){}measureText(t){}strokeText(t,e,s,i){}destroy(){this.context=null}}gt([mt("imageSmoothingEnabled")],wt.prototype,"smooth",void 0),gt([mt("imageSmoothingQuality")],wt.prototype,"smoothLevel",void 0),gt([mt("globalAlpha")],wt.prototype,"opacity",void 0),gt([mt()],wt.prototype,"fillStyle",void 0),gt([mt()],wt.prototype,"strokeStyle",void 0),gt([mt("lineWidth")],wt.prototype,"strokeWidth",void 0),gt([mt("lineCap")],wt.prototype,"strokeCap",void 0),gt([mt("lineJoin")],wt.prototype,"strokeJoin",void 0),gt([mt("lineDashOffset")],wt.prototype,"dashOffset",void 0),gt([mt()],wt.prototype,"miterLimit",void 0),gt([mt()],wt.prototype,"shadowBlur",void 0),gt([mt()],wt.prototype,"shadowColor",void 0),gt([mt()],wt.prototype,"shadowOffsetX",void 0),gt([mt()],wt.prototype,"shadowOffsetY",void 0),gt([mt()],wt.prototype,"filter",void 0),gt([mt()],wt.prototype,"font",void 0),gt([mt()],wt.prototype,"fontKerning",void 0),gt([mt()],wt.prototype,"fontStretch",void 0),gt([mt()],wt.prototype,"fontVariantCaps",void 0),gt([mt()],wt.prototype,"textAlign",void 0),gt([mt()],wt.prototype,"textBaseline",void 0),gt([mt()],wt.prototype,"textRendering",void 0),gt([mt()],wt.prototype,"wordSpacing",void 0),gt([mt()],wt.prototype,"letterSpacing",void 0),gt([mt()],wt.prototype,"direction",void 0),gt([vt()],wt.prototype,"setTransform",null),gt([vt()],wt.prototype,"resetTransform",null),gt([vt()],wt.prototype,"getTransform",null),gt([vt()],wt.prototype,"save",null),gt([vt()],wt.prototype,"restore",null),gt([vt()],wt.prototype,"translate",null),gt([vt()],wt.prototype,"scale",null),gt([vt()],wt.prototype,"rotate",null),gt([vt()],wt.prototype,"fill",null),gt([vt()],wt.prototype,"stroke",null),gt([vt()],wt.prototype,"clip",null),gt([vt()],wt.prototype,"fillRect",null),gt([vt()],wt.prototype,"strokeRect",null),gt([vt()],wt.prototype,"clearRect",null),gt([vt()],wt.prototype,"beginPath",null),gt([vt()],wt.prototype,"moveTo",null),gt([vt()],wt.prototype,"lineTo",null),gt([vt()],wt.prototype,"bezierCurveTo",null),gt([vt()],wt.prototype,"quadraticCurveTo",null),gt([vt()],wt.prototype,"closePath",null),gt([vt()],wt.prototype,"arc",null),gt([vt()],wt.prototype,"arcTo",null),gt([vt()],wt.prototype,"ellipse",null),gt([vt()],wt.prototype,"rect",null),gt([vt()],wt.prototype,"roundRect",null),gt([vt()],wt.prototype,"createConicGradient",null),gt([vt()],wt.prototype,"createLinearGradient",null),gt([vt()],wt.prototype,"createPattern",null),gt([vt()],wt.prototype,"createRadialGradient",null),gt([vt()],wt.prototype,"fillText",null),gt([vt()],wt.prototype,"measureText",null),gt([vt()],wt.prototype,"strokeText",null);const bt=new V,Ot={width:1,height:1,pixelRatio:1},Ct=Z.get("LeaferCanvasBase"),Tt=["width","height","pixelRatio"];class Et extends wt{get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,i){super(),this.worldTransform={},e||(e=Ot),e.pixelRatio||(e.pixelRatio=t.devicePixelRatio),this.manager=i,this.innerId=s.create(s.CNAVAS);const{width:r,height:a,pixelRatio:o}=e;this.autoLayout=!r||!a,this.pixelRatio=o,this.config=e,this.init()}init(){}__createContext(){this.context=this.view.getContext("2d"),this.__bindContext()}toBlob(e,s){return new Promise((i=>{const r=this.getSaveCanvas(e);t.origin.canvasToBolb(r.view,e,s).then((t=>{r.recycle(),i(t)})).catch((t=>{Ct.error(t),i(null)}))}))}toDataURL(e,s){const i=this.getSaveCanvas(e),r=t.origin.canvasToDataURL(i.view,e,s);return i.recycle(),r}saveAs(e,s){return new Promise((i=>{const r=this.getSaveCanvas(_t.fileType(e));t.origin.canvasSaveAs(r.view,e,s).then((()=>{r.recycle(),i(!0)})).catch((t=>{Ct.error(t),i(!1)}))}))}getSaveCanvas(t){const{backgroundColor:e,bounds:s}=this,i=this.getSameCanvas();return["jpg","jpeg"].includes(t)&&i.fillWorld(s,"#FFFFFF"),e&&i.fillWorld(s,e),i.copyWorld(this),i}resize(t){if(this.isSameSize(t))return;let e;this.context&&!this.unreal&&this.width&&(e=this.getSameCanvas(),e.copyWorld(this)),ct.copyAttrs(this,t,Tt),this.bounds=new V(0,0,this.width,this.height),this.pixelRatio||(this.pixelRatio=1),this.unreal||(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&e&&(this.clearWorld(e.bounds),this.copyWorld(e),e.recycle())}updateViewSize(){}updateClientBounds(){}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e,s){const{pixelRatio:i}=this,r=this.worldTransform;if(e)if(s)this.setTransform(r.a=t.a*i,r.b=t.b*i,r.c=t.c*i,r.d=t.d*i,r.e=(t.e+e.e)*i,r.f=(t.f+e.f)*i);else{const{a:s,b:a,c:o,d:n,e:h,f:l}=e;this.setTransform(r.a=(t.a*s+t.b*o)*i,r.b=(t.a*a+t.b*n)*i,r.c=(t.c*s+t.d*o)*i,r.d=(t.c*a+t.d*n)*i,r.e=(t.e*s+t.f*o+h)*i,r.f=(t.e*a+t.f*n+l)*i)}else this.setTransform(r.a=t.a*i,r.b=t.b*i,r.c=t.c*i,r.d=t.d*i,r.e=t.e*i,r.f=t.f*i)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,s){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 e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)}hitStroke(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)}setWorldShadow(t,e,s,i){const{pixelRatio:r}=this;this.shadowOffsetX=t*r,this.shadowOffsetY=e*r,this.shadowBlur=s*r,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="source-over")}copyWorldToInner(t,e,s,i){if(i&&(this.blendMode=i),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,z.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="source-over")}copyWorldByReset(t,e,s,i){this.resetTransform(),this.copyWorld(t,e,s,i),this.useWorldTransform()}useMask(t,e,s){this.copyWorld(t,e,s,"destination-in")}useEraser(t,e,s){this.copyWorld(t,e,s,"destination-out")}fillWorld(t,e,s){s&&(this.blendMode=s),this.fillStyle=e,bt.copy(t).scale(this.pixelRatio),this.fillRect(bt.x,bt.y,bt.width,bt.height),s&&(this.blendMode="source-over")}strokeWorld(t,e,s){s&&(this.blendMode=s),this.strokeStyle=e,bt.copy(t).scale(this.pixelRatio),this.strokeRect(bt.x,bt.y,bt.width,bt.height),s&&(this.blendMode="source-over")}clearWorld(t,e){bt.copy(t).scale(this.pixelRatio),e&&bt.ceil(),this.clearRect(bt.x,bt.y,bt.width,bt.height)}clipWorld(t,e){this.beginPath(),bt.copy(t).scale(this.pixelRatio),e&&bt.ceil(),this.rect(bt.x,bt.y,bt.width,bt.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:s,height:i,pixelRatio:r}=this,a={width:s,height:i,pixelRatio:r},o=this.manager?this.manager.get(a):e.canvas(a);return o.save(),t&&o.useWorldTransform(Object.assign({},this.worldTransform)),o}getBiggerCanvas(t,s){let{width:i,height:r,pixelRatio:a}=this;t&&(i+=t),s&&(r+=s);const o={width:i,height:r,pixelRatio:a},n=this.manager?this.manager.get(o):e.canvas(o);return n.save(),n}recycle(){this.recycled||(this.restore(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}}const kt={creator:{},parse(t,e){},convertToCanvasData(t,e){}},Bt={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Pt=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},Bt),Rt={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},Dt={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},Lt=Object.assign(Object.assign({},Dt),Bt),St=Pt,Mt={};for(let t in St)Mt[St[t]]=t;const It={};for(let t in St)It[St[t]]=Rt[t];const At={drawRoundRect(t,e,s,i,a,o){let[n,h,l,d]=r.fourNumber(o);const c=Math.min(i/2,a/2);n>c&&(n=c),h>c&&(h=c),l>c&&(l=c),d>c&&(d=c),n?t.moveTo(e+n,s):t.moveTo(e,s),h?t.arcTo(e+i,s,e+i,s+a,h):t.lineTo(e+i,s),l?t.arcTo(e+i,s+a,e,s+a,l):t.lineTo(e+i,s+a),d?t.arcTo(e,s+a,e,s,d):t.lineTo(e,s+a),n?t.arcTo(e,s,e+i,s,n):t.lineTo(e,s)}},{sin:Wt,cos:Nt,atan2:Xt,ceil:Yt,abs:jt,PI:zt,sqrt:Ut,pow:Ht}=Math,{setPoint:Ft,addPoint:Vt}=P,{set:Gt}=T,{M:Kt,L:qt,C:Zt,Q:Qt,Z:Jt}=Pt,$t={},te={points(t,e,s,i){if(t.push(Kt,e[0],e[1]),s&&e.length>5){let r,a,o,n,h,l,d,c,u,p,_,g,f,m=e.length;const y=!0===s?.5:s;i&&(m=(e=[e[m-2],e[m-1],...e,e[0],e[1],e[2],e[3]]).length);for(let s=2;s<m-2;s+=2)r=e[s-2],a=e[s-1],o=e[s],n=e[s+1],h=e[s+2],l=e[s+3],_=Ut(Ht(o-r,2)+Ht(n-a,2)),g=Ut(Ht(h-o,2)+Ht(l-n,2)),f=_+g,_=y*_/f,g=y*g/f,h-=r,l-=a,d=o-_*h,c=n-_*l,2===s?i||t.push(Qt,d,c,o,n):t.push(Zt,u,p,d,c,o,n),u=o+g*h,p=n+g*l;i||t.push(Qt,u,p,e[m-2],e[m-1])}else for(let s=2,i=e.length;s<i;s+=2)t.push(qt,e[s],e[s+1]);i&&t.push(Jt)},rect(t,e,s,i,r){kt.creator.path=t,kt.creator.moveTo(e,s).lineTo(e+i,s).lineTo(e+i,s+r).lineTo(e,s+r).lineTo(e,s)},roundRect(t,e,s,i,r,a){kt.creator.path=[],At.drawRoundRect(kt.creator,e,s,i,r,a),t.push(...kt.convertToCanvasData(kt.creator.path,!0))},arcTo(t,e,s,i,r,h,l,d,c,u,p){const _=i-e,g=r-s,f=h-i,m=l-r;let y=Xt(g,_),v=Xt(m,f),x=v-y;if(x<0&&(x+=o),x===zt||jt(_+g)<1e-12||jt(f+m)<1e-12)return t&&t.push(qt,i,r),c&&(Ft(c,e,s),Vt(c,i,r)),p&&Gt(p,e,s),void(u&&Gt(u,i,r));const w=_*m-f*g<0,b=w?-1:1,O=d/Nt(x/2),C=i+O*Nt(y+x/2+n*b),T=r+O*Wt(y+x/2+n*b);return y-=n*b,v-=n*b,ie(t,C,T,d,d,0,y/a,v/a,w,c,u,p)},arc:(t,e,s,i,r,a,o,n,h,l)=>ie(t,e,s,i,i,0,r,a,o,n,h,l),ellipse(t,e,s,i,r,h,l,d,c,u,p,_){const g=h*a,f=Wt(g),m=Nt(g);let y=l*a,v=d*a;y>zt&&(y-=o),v<0&&(v+=o);let x=v-y;x<0?x+=o:x>o&&(x-=o),c&&(x-=o);const w=Yt(jt(x/n)),b=x/w,O=Wt(b/4),C=8/3*O*O/Wt(b/2);v=y+b;let T,E,k,B,P,R,D,L,S=Nt(y),M=Wt(y),I=k=m*i*S-f*r*M,A=B=f*i*S+m*r*M,W=e+k,N=s+B;t&&t.push(qt,W,N),u&&Ft(u,W,N),_&&Gt(_,W,N);for(let a=0;a<w;a++)T=Nt(v),E=Wt(v),k=m*i*T-f*r*E,B=f*i*T+m*r*E,P=e+I-C*(m*i*M+f*r*S),R=s+A-C*(f*i*M-m*r*S),D=e+k+C*(m*i*E+f*r*T),L=s+B+C*(f*i*E-m*r*T),t&&t.push(Zt,P,R,D,L,e+k,s+B),u&&se(e+I,s+A,P,R,D,L,e+k,s+B,u,!0),I=k,A=B,S=T,M=E,y=v,v+=b;p&&Gt(p,e+k,s+B)},quadraticCurveTo(t,e,s,i,r,a,o){t.push(Zt,(e+2*i)/3,(s+2*r)/3,(a+2*i)/3,(o+2*r)/3,a,o)},toTwoPointBoundsByQuadraticCurve(t,e,s,i,r,a,o,n){se(t,e,(t+2*s)/3,(e+2*i)/3,(r+2*s)/3,(a+2*i)/3,r,a,o,n)},toTwoPointBounds(t,e,s,i,r,a,o,n,h,l){const d=[];let c,u,p,_,g,f,m,y,v=t,x=s,w=r,b=o;for(let t=0;t<2;++t)if(1==t&&(v=e,x=i,w=a,b=n),c=-3*v+9*x-9*w+3*b,u=6*v-12*x+6*w,p=3*x-3*v,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;_=-p/u,0<_&&_<1&&d.push(_)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(g=(-u+y)/(2*c),0<g&&g<1&&d.push(g),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?Vt(h,t,e):Ft(h,t,e),Vt(h,o,n);for(let l=0,c=d.length;l<c;l++)ee(d[l],t,e,s,i,r,a,o,n,$t),Vt(h,$t.x,$t.y)},getPointAndSet(t,e,s,i,r,a,o,n,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,_=t*t*t;l.x=c*e+u*i+p*a+_*n,l.y=c*s+u*r+p*o+_*h},getPoint(t,e,s,i,r,a,o,n,h){const l={};return ee(t,e,s,i,r,a,o,n,h,l),l}},{getPointAndSet:ee,toTwoPointBounds:se,ellipse:ie}=te,{sin:re,cos:ae,sqrt:oe,atan2:ne}=Math,{ellipse:he}=te,le={ellipticalArc(t,e,s,i,r,n,h,l,d,c,u){const p=(d-e)/2,_=(c-s)/2,g=n*a,f=re(g),m=ae(g),y=-m*p-f*_,v=-m*_+f*p,x=i*i,w=r*r,b=v*v,O=y*y,C=x*w-x*b-w*O;let T=0;if(C<0){const t=oe(1-C/(x*w));i*=t,r*=t}else T=(h===l?-1:1)*oe(C/(x*b+w*O));const E=T*i*v/r,k=-T*r*y/i,B=ne((v-k)/r,(y-E)/i),P=ne((-v-k)/r,(-y-E)/i);let R=P-B;0===l&&R>0?R-=o:1===l&&R<0&&(R+=o);const D=e+p+m*E-f*k,L=s+_+f*E+m*k,S=R<0?1:0;u?he(t,D,L,i,r,n,B/a,P/a,S):i!==r||n?t.push(Pt.G,D,L,i,r,n,B/a,P/a,S):t.push(Pt.O,D,L,i,B/a,P/a,S)}},{M:de,m:ce,L:ue,l:pe,H:_e,h:ge,V:fe,v:me,C:ye,c:ve,S:xe,s:we,Q:be,q:Oe,T:Ce,t:Te,A:Ee,a:ke,Z:Be,z:Pe,N:Re,D:De,X:Le,G:Se,F:Me,O:Ie,P:Ae,U:We}=Pt,{rect:Ne,roundRect:Xe,arcTo:Ye,arc:je,ellipse:ze,quadraticCurveTo:Ue}=te,{ellipticalArc:He}=le,Fe=Z.get("PathConvert"),Ve={},Ge={current:{dot:0},stringify(t){let e,s,i,r=0,a=t.length,o="";for(;r<a;){s=t[r],e=It[s],o+=s===i?" ":Mt[s];for(let s=1;s<e;s++)o+=t[r+s],s===e-1||(o+=" ");i=s,r+=e}return o},parse(t,e){let s,i,r,a="";const o=[],n=e?Lt:Dt;for(let e=0,h=t.length;e<h;e++)i=t[e],q[i]?("."===i&&(Ke.dot++,Ke.dot>1&&(qe(o,a),a="")),a+=i):Pt[i]?(a&&(qe(o,a),a=""),Ke.name=Pt[i],Ke.length=Rt[i],Ke.index=0,qe(o,Ke.name),!s&&n[i]&&(s=!0)):"-"===i||"+"===i?"e"===r||"E"===r?a+=i:(a&&qe(o,a),a=i):a&&(qe(o,a),a=""),r=i;return a&&qe(o,a),s?Ge.toCanvasData(o,e):o},toCanvasData(t,e){let s,i,r,a,o,n=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(r=t[c],r){case ce:t[c+1]+=n,t[c+2]+=h;case de:n=t[c+1],h=t[c+2],p.push(de,n,h),c+=3;break;case ge:t[c+1]+=n;case _e:n=t[c+1],p.push(ue,n,h),c+=2;break;case me:t[c+1]+=h;case fe:h=t[c+1],p.push(ue,n,h),c+=2;break;case pe:t[c+1]+=n,t[c+2]+=h;case ue:n=t[c+1],h=t[c+2],p.push(ue,n,h),c+=3;break;case we:t[c+1]+=n,t[c+2]+=h,t[c+3]+=n,t[c+4]+=h,r=xe;case xe:o=a===ye||a===xe,l=o?2*n-s:t[c+1],d=o?2*h-i:t[c+2],s=t[c+1],i=t[c+2],n=t[c+3],h=t[c+4],p.push(ye,l,d,s,i,n,h),c+=5;break;case ve:t[c+1]+=n,t[c+2]+=h,t[c+3]+=n,t[c+4]+=h,t[c+5]+=n,t[c+6]+=h,r=ye;case ye:s=t[c+3],i=t[c+4],n=t[c+5],h=t[c+6],p.push(ye,t[c+1],t[c+2],s,i,n,h),c+=7;break;case Te:t[c+1]+=n,t[c+2]+=h,r=Ce;case Ce:o=a===be||a===Ce,s=o?2*n-s:t[c+1],i=o?2*h-i:t[c+2],e?Ue(p,n,h,s,i,t[c+1],t[c+2]):p.push(be,s,i,t[c+1],t[c+2]),n=t[c+1],h=t[c+2],c+=3;break;case Oe:t[c+1]+=n,t[c+2]+=h,t[c+3]+=n,t[c+4]+=h,r=be;case be:s=t[c+1],i=t[c+2],e?Ue(p,n,h,s,i,t[c+3],t[c+4]):p.push(be,s,i,t[c+3],t[c+4]),n=t[c+3],h=t[c+4],c+=5;break;case ke:t[c+6]+=n,t[c+7]+=h;case Ee:He(p,n,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),n=t[c+6],h=t[c+7],c+=8;break;case Pe:case Be:p.push(Be),c++;break;case Re:n=t[c+1],h=t[c+2],e?Ne(p,n,h,t[c+3],t[c+4]):Ze(p,t,c,5),c+=5;break;case De:n=t[c+1],h=t[c+2],e?Xe(p,n,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):Ze(p,t,c,9),c+=9;break;case Le:n=t[c+1],h=t[c+2],e?Xe(p,n,h,t[c+3],t[c+4],t[c+5]):Ze(p,t,c,6),c+=6;break;case Se:ze(e?p:Ze(p,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,Ve),n=Ve.x,h=Ve.y,c+=9;break;case Me:e?ze(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):Ze(p,t,c,5),n=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case Ie:je(e?p:Ze(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,Ve),n=Ve.x,h=Ve.y,c+=7;break;case Ae:e?je(p,t[c+1],t[c+2],t[c+3],0,360,!1):Ze(p,t,c,4),n=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case We:Ye(e?p:Ze(p,t,c,6),n,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,Ve),n=Ve.x,h=Ve.y,c+=6;break;default:return Fe.error(`command: ${r} [index:${c}]`,t),p}a=r}return p},copyData(t,e,s,i){for(let r=s,a=s+i;r<a;r++)t.push(e[r])},pushData(t,e){Ke.index===Ke.length&&(Ke.index=1,t.push(Ke.name)),t.push(Number(e)),Ke.index++,Ke.dot=0}},{current:Ke,pushData:qe,copyData:Ze}=Ge,{M:Qe,L:Je,C:$e,Q:ts,Z:es,N:ss,D:is,X:rs,G:as,F:os,O:ns,P:hs,U:ls}=Pt,ds={},cs={beginPath(t){t.length=0},moveTo(t,e,s){t.push(Qe,e,s)},lineTo(t,e,s){t.push(Je,e,s)},bezierCurveTo(t,e,s,i,r,a,o){t.push($e,e,s,i,r,a,o)},quadraticCurveTo(t,e,s,i,r){t.push(ts,e,s,i,r)},closePath(t){t.push(es)},rect(t,e,s,i,r){t.push(ss,e,s,i,r)},roundRect(t,e,s,i,a,o){if("number"==typeof o)t.push(rs,e,s,i,a,o);else{const n=r.fourNumber(o);n?t.push(is,e,s,i,a,...n):t.push(ss,e,s,i,a)}},ellipse(t,e,s,i,r,a,o,n,h){void 0===a?t.push(os,e,s,i,r):(void 0===o&&(o=0),void 0===n&&(n=360),t.push(as,e,s,i,r,a,o,n,h?1:0))},arc(t,e,s,i,r,a,o){void 0===r?t.push(hs,e,s,i):(void 0===a&&(a=360),t.push(ns,e,s,i,r,a,o?1:0))},arcTo(t,e,s,i,r,a){t.push(ls,e,s,i,r,a)},drawEllipse(t,e,s,i,r,a,o,n,h){void 0===a&&(a=0),void 0===o&&(o=0),void 0===n&&(n=360),te.ellipse(null,e,s,i,r,a,o,n,h,null,null,ds),t.push(Qe,ds.x,ds.y),us(t,e,s,i,r,a,o,n,h)},drawArc(t,e,s,i,r,a,o){void 0===r&&(r=0),void 0===a&&(a=360),te.arc(null,e,s,i,r,a,o,null,null,ds),t.push(Qe,ds.x,ds.y),ps(t,e,s,i,r,a,o)},drawPoints(t,e,s,i){te.points(t,e,s,i)}},{ellipse:us,arc:ps}=cs,{moveTo:_s,lineTo:gs,quadraticCurveTo:fs,bezierCurveTo:ms,closePath:ys,beginPath:vs,rect:xs,roundRect:ws,ellipse:bs,arc:Os,arcTo:Cs,drawEllipse:Ts,drawArc:Es,drawPoints:ks}=cs;class Bs{constructor(t){this.path=t?"string"==typeof t?kt.parse(t):t:[]}beginPath(){return vs(this.path),this}moveTo(t,e){return _s(this.path,t,e),this}lineTo(t,e){return gs(this.path,t,e),this}bezierCurveTo(t,e,s,i,r,a){return ms(this.path,t,e,s,i,r,a),this}quadraticCurveTo(t,e,s,i){return fs(this.path,t,e,s,i),this}closePath(){return ys(this.path),this}rect(t,e,s,i){return xs(this.path,t,e,s,i),this}roundRect(t,e,s,i,r){return ws(this.path,t,e,s,i,r),this}ellipse(t,e,s,i,r,a,o,n){return bs(this.path,t,e,s,i,r,a,o,n),this}arc(t,e,s,i,r,a){return Os(this.path,t,e,s,i,r,a),this}arcTo(t,e,s,i,r){return Cs(this.path,t,e,s,i,r),this}drawEllipse(t,e,s,i,r,a,o,n){return Ts(this.path,t,e,s,i,r,a,o,n),this}drawArc(t,e,s,i,r,a){return Es(this.path,t,e,s,i,r,a),this}drawPoints(t,e,s){return ks(this.path,t,e,s),this}}const{M:Ps,L:Rs,C:Ds,Q:Ls,Z:Ss,N:Ms,D:Is,X:As,G:Ws,F:Ns,O:Xs,P:Ys,U:js}=Pt,zs=Z.get("PathDrawer"),Us={drawPathByData(t,e){if(!e)return;let s,i=0,r=e.length;for(;i<r;)switch(s=e[i],s){case Ps:t.moveTo(e[i+1],e[i+2]),i+=3;break;case Rs:t.lineTo(e[i+1],e[i+2]),i+=3;break;case Ds:t.bezierCurveTo(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5],e[i+6]),i+=7;break;case Ls:t.quadraticCurveTo(e[i+1],e[i+2],e[i+3],e[i+4]),i+=5;break;case Ss:t.closePath(),i+=1;break;case Ms:t.rect(e[i+1],e[i+2],e[i+3],e[i+4]),i+=5;break;case Is: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 As:t.roundRect(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]),i+=6;break;case Ws:t.ellipse(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]*a,e[i+6]*a,e[i+7]*a,e[i+8]),i+=9;break;case Ns:t.ellipse(e[i+1],e[i+2],e[i+3],e[i+4],0,0,o,!1),i+=5;break;case Xs:t.arc(e[i+1],e[i+2],e[i+3],e[i+4]*a,e[i+5]*a,e[i+6]),i+=7;break;case Ys:t.arc(e[i+1],e[i+2],e[i+3],0,o,!1),i+=4;break;case js:t.arcTo(e[i+1],e[i+2],e[i+3],e[i+4],e[i+5]),i+=6;break;default:return void zs.error(`command: ${s} [index:${i}]`,e)}}},{M:Hs,L:Fs,C:Vs,Q:Gs,Z:Ks,N:qs,D:Zs,X:Qs,G:Js,F:$s,O:ti,P:ei,U:si}=Pt,{toTwoPointBounds:ii,toTwoPointBoundsByQuadraticCurve:ri,arcTo:ai,arc:oi,ellipse:ni}=te,{add:hi,copy:li,addPoint:di,setPoint:ci,addBounds:ui,toBounds:pi}=P,_i=Z.get("PathBounds");let gi,fi,mi;const yi={},vi={},xi={},wi={toBounds(t,e){wi.toTwoPointBounds(t,vi),pi(vi,e)},toTwoPointBounds(t,e){if(!t||!t.length)return ci(e,0,0);let s,i,r,a,o,n=0,h=0,l=0;const d=t.length;for(;n<d;)switch(s=t[n],0===n&&(s===Ks||s===Vs||s===Gs?ci(e,h,l):ci(e,t[n+1],t[n+2])),s){case Hs:case Fs:h=t[n+1],l=t[n+2],di(e,h,l),n+=3;break;case Vs:a=t[n+5],o=t[n+6],ii(h,l,t[n+1],t[n+2],t[n+3],t[n+4],a,o,yi),hi(e,yi),h=a,l=o,n+=7;break;case Gs:i=t[n+1],r=t[n+2],a=t[n+3],o=t[n+4],ri(h,l,i,r,a,o,yi),hi(e,yi),h=a,l=o,n+=5;break;case Ks:n+=1;break;case qs:h=t[n+1],l=t[n+2],ui(e,h,l,t[n+3],t[n+4]),n+=5;break;case Zs:case Qs:h=t[n+1],l=t[n+2],ui(e,h,l,t[n+3],t[n+4]),n+=s===Zs?9:6;break;case Js:ni(null,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],t[n+6],t[n+7],t[n+8],yi,xi),0===n?li(e,yi):hi(e,yi),h=xi.x,l=xi.y,n+=9;break;case $s:h=t[n+1],l=t[n+2],fi=t[n+3],mi=t[n+4],ui(e,h-fi,l-mi,2*fi,2*mi),h+=fi,n+=5;break;case ti:oi(null,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],t[n+6],yi,xi),0===n?li(e,yi):hi(e,yi),h=xi.x,l=xi.y,n+=7;break;case ei:h=t[n+1],l=t[n+2],gi=t[n+3],ui(e,h-gi,l-gi,2*gi,2*gi),h+=gi,n+=4;break;case si:ai(null,h,l,t[n+1],t[n+2],t[n+3],t[n+4],t[n+5],yi,xi),0===n?li(e,yi):hi(e,yi),h=xi.x,l=xi.y,n+=6;break;default:return void _i.error(`command: ${s} [index:${n}]`,t)}}},bi={smooth:(t,e,s)=>t};kt.creator=new Bs,kt.parse=Ge.parse,kt.convertToCanvasData=Ge.toCanvasData;const{drawRoundRect:Oi}=At;function Ci(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,s,i,r){Oi(this,t,e,s,i,r)})}(t)}const Ti=Z.get("TaskProcessor");class Ei{constructor(t){this.parallel=!0,this.time=1,this.id=s.create(s.TASK),this.task=t}run(){return ft(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){Ti.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class ki{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,s=0;for(let i=0;i<t;i++)i<=this.finishedIndex?(s+=this.list[i].time,i===this.finishedIndex&&(e=s)):e+=this.list[i].time;return this.isComplete?1:s/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&ct.assign(this.config,t),this.empty()}add(t,e){let s,i,r,a;const o=new Ei(t);return o.parent=this,"number"==typeof e?a=e:e&&(i=e.parallel,s=e.start,r=e.time,a=e.delay),r&&(o.time=r),!1===i&&(o.parallel=!1),void 0===a?this.push(o,s):(this.delayNumber++,setTimeout((()=>{this.delayNumber--,this.push(o,s)}),a)),this.isComplete=!1,o}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout((()=>this.start())))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[]}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach((t=>{t.isComplete||t.cancel()})),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)})):this.nextTask()}runParallelTasks(){this.parallelList.forEach((t=>this.runParallelTask(t)))}runParallelTask(t){t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout((()=>this.run()))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let s=this.index;s<e&&(t=this.list[s],t.parallel);s++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const s=e.length,i=this.finishedIndex+s;if(e.length){if(!this.running)return;i<this.total&&(t=this.list[i],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const Bi={map:{},recycledList:[],tasker:new ki,patternTasker:new ki,get isComplete(){return Pi.tasker.isComplete&&Pi.patternTasker.isComplete},get(t){let s=Pi.map[t.url];return s||(s=e.image(t),Pi.map[t.url]=s),s.use++,s},recycle(t){t.use--,setTimeout((()=>{t.use||Pi.recycledList.push(t)}))},clearRecycled(){const t=Pi.recycledList;t.length&&(t.forEach((t=>{!t.use&&t.url&&(delete Pi.map[t.url],t.destroy())})),t.length=0)},destroy(){Pi.map={}}},Pi=Bi,{IMAGE:Ri,create:Di}=s;class Li{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){this.use=0,this.waitComplete=[],this.innerId=Di(Ri),this.config=t||{url:""};const{url:e}=t;e.startsWith("data:")?e.startsWith("data:image/svg")&&(this.isSVG=!0):e.includes(".svg")&&(this.isSVG=!0),"svg"===this.config.format&&(this.isSVG=!0)}load(e,s){return this.loading||(this.loading=!0,Bi.tasker.add((()=>ft(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>{this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)})).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),this.waitComplete.push(e,s),this.waitComplete.length-2}unload(t,e){const s=this.waitComplete;if(e){const e=s[t+1];e&&e({type:"stop"})}s[t]=s[t+1]=void 0}onComplete(t){let e;this.waitComplete.forEach(((s,i)=>{e=i%2,s&&(t?e||s(this):e&&s(this.error))})),this.waitComplete.length=0,this.loading=!1}getCanvas(e,s,i,r){e||(e=this.width),s||(s=this.height);const a=t.origin.createCanvas(e,s),o=a.getContext("2d");return i&&(o.globalAlpha=i),o.drawImage(this.view,0,0,e,s),a}destroy(){this.config={url:""},this.waitComplete.length=0}}class Si{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 Mi extends Si{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}Mi.ADD="child.add",Mi.REMOVE="child.remove";class Ii extends Si{constructor(t,e,s,i,r){super(t,e),this.attrName=s,this.oldValue=i,this.newValue=r}}Ii.CHANGE="property.change";class Ai extends Si{constructor(t,e){super(t),Object.assign(this,e)}}Ai.LOAD="image.load",Ai.LOADED="image.loaded",Ai.ERROR="image.error";class Wi extends Si{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){"object"==typeof t?(super(Wi.RESIZE),Object.assign(this,t)):super(t),this.old=e}}Wi.RESIZE="resize";class Ni extends Si{constructor(t,e){super(t),e&&Object.assign(this,e)}}Ni.START="transform.start",Ni.CHANGE="transform.change",Ni.END="transform.end",Ni.BEFORE_START="transform.before_start",Ni.BEFORE_CHANGE="transform.before_change",Ni.BEFORE_END="transform.before_end";class Xi extends Si{constructor(t,e){super(t),this.data=e}}Xi.REQUEST="watch.request",Xi.DATA="watch.data";class Yi extends Si{constructor(t,e,s){super(t),e&&(this.data=e,this.times=s)}}Yi.CHECK_UPDATE="layout.check_update",Yi.REQUEST="layout.request",Yi.START="layout.start",Yi.BEFORE="layout.before",Yi.LAYOUT="layout.layout",Yi.AFTER="layout.after",Yi.AGAIN="layout.again",Yi.END="layout.end";class ji extends Si{}ji.FRAME="animate.frame";class zi extends Si{constructor(t,e,s,i){super(t),e&&(this.times=e),s&&(this.renderBounds=s,this.renderOptions=i)}}zi.REQUEST="render.request",zi.START="render.start",zi.BEFORE="render.before",zi.RENDER="render",zi.AFTER="render.after",zi.AGAIN="render.again",zi.END="render.end";class Ui extends Si{}Ui.START="leafer.start",Ui.BEFORE_READY="leafer.before_ready",Ui.READY="leafer.ready",Ui.AFTER_READY="leafer.after_ready",Ui.VIEW_READY="leafer.view_ready",Ui.VIEW_COMPLETED="leafer.view_completed",Ui.STOP="leafer.stop",Ui.RESTART="leafer.restart",Ui.END="leafer.end";const Hi={},Fi={isHoldSpaceKey:()=>Fi.isHold("Space"),isHold:t=>Hi[t],setDownCode(t){Hi[t]||(Hi[t]=!0)},setUpCode(t){Hi[t]=!1}},Vi={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Gi extends Si{get spaceKey(){return Fi.isHoldSpaceKey()}get left(){return Vi.left(this)}get right(){return Vi.right(this)}get middle(){return Vi.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}getInner(t){return t||(t=this.current),t.getInnerPoint(this)}getLocal(t){return t||(t=this.current),t.getLocalPoint(this)}static changeName(t,e){at.changeName(t,e)}}function Ki(t,e,s){Object.defineProperty(t,e,s)}function qi(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Zi(t){return(e,s)=>{Ki(e,s,{get(){return this.__getAttr(t)},set(e){this.__setAttr(t,e)}})}}function Qi(t,e,s,i){const r={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)},configurable:!0,enumerable:!0};Ki(t,e,Object.assign(r,i||{})),mr(t,e,s)}function Ji(t){return(e,s)=>{Qi(e,s,t)}}function $i(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.positionChanged||this.__layout.positionChange()}})}}function tr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.scaleChanged||this.__layout.scaleChange()}})}}function er(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.rotationChanged||this.__layout.rotationChange()}})}}function sr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__.around&&(this.__layout.positionChanged||this.__layout.positionChange())}})}}const ir=sr;function rr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.strokeChanged||this.__layout.strokeChange()}})}}const ar=rr;function or(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.renderChanged||this.__layout.renderChange()}})}}function nr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange()}})}}function hr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.opacityChanged||this.__layout.opacityChange()}})}}function lr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()}))}})}}function dr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(t)}))}})}}function cr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.waitParent((()=>{this.parent.__updateEraser(t)}))}})}}function ur(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),Z.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor()}})}}function pr(t){return(e,s)=>{Qi(e,s,t,{set(t){this.__setAttr(s,t),this.leafer&&this.leafer.updateCursor()}})}}function _r(t){return(e,s)=>{Ki(e,"__DataProcessor",{get:()=>t})}}function gr(t){return(e,s)=>{Ki(e,"__LayoutProcessor",{get:()=>t})}}function fr(t,e,s){mr(t.prototype,e,s)}function mr(t,e,s){const i=t.__DataProcessor.prototype,r="_"+e,a=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),o={get(){const t=this[r];return void 0===t?s:t},set(t){this[r]=t},configurable:!0,enumerable:!0};void 0===s?o.get=function(){return this[r]}:"width"===e?o.get=function(){const t=this[r];return void 0===t?this.__naturalWidth||s:t}:"height"===e&&(o.get=function(){const t=this[r];return void 0===t?this.__naturalHeight||s:t});const n=qi(i,e);n&&n.set&&(o.set=n.set),i[a]&&(o.set=i[a],delete i[a]),Object.defineProperty(i,e,o)}const yr=new Z("rewrite"),vr=[],xr=["destroy","constructor"];function wr(t){return(e,s)=>{vr.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}}function br(){return t=>{Or()}}function Or(t){vr.length&&(vr.forEach((e=>{t&&yr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),vr.length=0)}function Cr(t,e){return s=>{var i;(t.prototype?(i=t.prototype,Object.getOwnPropertyNames(i)):Object.keys(t)).forEach((i=>{if(!(xr.includes(i)||e&&e.includes(i)))if(t.prototype){qi(t.prototype,i).writable&&(s.prototype[i]=t.prototype[i])}else s.prototype[i]=t[i]}))}}function Tr(){return t=>{st.register(t)}}function Er(){return t=>{at.register(t)}}setTimeout((()=>Or(!0)));let kr=class extends Gi{};kr.POINTER="pointer",kr.BEFORE_DOWN="pointer.before_down",kr.BEFORE_MOVE="pointer.before_move",kr.BEFORE_UP="pointer.before_up",kr.DOWN="pointer.down",kr.MOVE="pointer.move",kr.UP="pointer.up",kr.OVER="pointer.over",kr.OUT="pointer.out",kr.ENTER="pointer.enter",kr.LEAVE="pointer.leave",kr.TAP="tap",kr.DOUBLE_TAP="double_tap",kr.CLICK="click",kr.DOUBLE_CLICK="double_click",kr.LONG_PRESS="long_press",kr.LONG_TAP="long_tap",kr=gt([Er()],kr);const Br={};let Pr=class extends kr{getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(Br,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(Br,null,!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}assignMove(t){Br.x=t?this.totalX:this.moveX,Br.y=t?this.totalY:this.moveY}};var Rr;Pr.BEFORE_DRAG="drag.before_drag",Pr.START="drag.start",Pr.DRAG="drag",Pr.END="drag.end",Pr.OVER="drag.over",Pr.OUT="drag.out",Pr.ENTER="drag.enter",Pr.LEAVE="drag.leave",Pr=gt([Er()],Pr);let Dr=Rr=class extends kr{static setList(t){Rr.dragList=t instanceof ht?t:new ht(t)}static setData(t){this.dragData=t}};Dr.DROP="drop",Dr=Rr=gt([Er()],Dr);let Lr=class extends Pr{};Lr.BEFORE_MOVE="move.before_move",Lr.START="move.start",Lr.MOVE="move",Lr.END="move.end",Lr=gt([Er()],Lr);let Sr=class extends Gi{};Sr.BEFORE_ROTATE="rotate.before_rotate",Sr.START="rotate.start",Sr.ROTATE="rotate",Sr.END="rotate.end",Sr=gt([Er()],Sr);let Mr=class extends Pr{};Mr.SWIPE="swipe",Mr.LEFT="swipe.left",Mr.RIGHT="swipe.right",Mr.UP="swipe.up",Mr.DOWN="swipe.down",Mr=gt([Er()],Mr);let Ir=class extends Gi{};Ir.BEFORE_ZOOM="zoom.before_zoom",Ir.START="zoom.start",Ir.ZOOM="zoom",Ir.END="zoom.end",Ir=gt([Er()],Ir);let Ar=class extends Gi{};Ar.DOWN="key.down",Ar.HOLD="key.hold",Ar.UP="key.up",Ar=gt([Er()],Ar);class Wr{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(Lr.START,this.moveData)}t.path=this.moveData.path,e.emit(Lr.BEFORE_MOVE,t),e.emit(Lr.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(Ir.START,this.zoomData)}t.path=this.zoomData.path,e.emit(Ir.BEFORE_ZOOM,t),e.emit(Ir.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(Sr.START,this.rotateData)}t.path=this.rotateData.path,e.emit(Sr.BEFORE_ROTATE,t),e.emit(Sr.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(Lr.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(Ir.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(Sr.END,this.rotateData),this.rotateData=null)}destroy(){this.zoomData=this.moveData=this.rotateData=null}}const{copy:Nr,translate:Xr,toInnerPoint:Yr,scaleOfOuter:jr,rotateOfOuter:zr,skewOfOuter:Ur}=f,Hr={},Fr={updateAllWorldMatrix(t){if(t.__updateWorldMatrix(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)Gr(e[t])}},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)Kr(e[t])}},updateAllChange(t){if(Kr(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)qr(e[t])}},worldHittable(t){if(!t.__.hittable)return!1;let{parent:e}=t;for(;e;){if(!e.__.hittable||!e.__.hitChildren)return!1;e=e.parent}return!0},moveWorld(t,e,s){t.__layout.checkUpdate();const i={x:e,y:s};t.parent&&Yr(t.parent.__world,i,i,!0),Vr.moveLocal(t,i.x,i.y)},moveLocal(t,e,s=0){t.x+=e,t.y+=s},zoomOfWorld(t,e,s,i,r){t.__layout.checkUpdate();const a=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.zoomOfLocal(t,a,s,i,r)},zoomOfLocal(t,e,s,i=s,r){Nr(Hr,t.__local),r&&Xr(Hr,r.x,r.y),jr(Hr,e,s,i),r||(r=t),r.x+=Hr.e-t.__local.e,r.y+=Hr.f-t.__local.f,t.scaleX*=s,t.scaleY*=i},rotateOfWorld(t,e,s,i){t.__layout.checkUpdate();const r=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.rotateOfLocal(t,r,s,i)},rotateOfLocal(t,e,s,i){Nr(Hr,t.__local),i&&Xr(Hr,i.x,i.y),zr(Hr,e,s),i||(i=t),i.x+=Hr.e-t.__local.e,i.y+=Hr.f-t.__local.f,t.rotation=r.formatRotation(t.rotation+s)},skewOfWorld(t,e,s,i,r){t.__layout.checkUpdate();const a=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.skewOfLocal(t,a,s,i,r)},skewOfLocal(t,e,s,i,a){Nr(Hr,t.__local),a&&Xr(Hr,a.x,a.y),Ur(Hr,e,s,i),a||(a=t),a.x=Hr.e-t.__local.e,a.y=Hr.f-t.__local.f,t.skewX=r.formatSkew(t.skewX+s),t.skewY=r.formatSkew(t.skewY+i)},drop(t,e){const s={x:t.x,y:t.y};t.localToWorld(s),e.worldToInner(s),t.set(s),e.add(t)}},Vr=Fr,{updateAllWorldMatrix:Gr,updateAllWorldOpacity:Kr,updateAllChange:qr}=Vr,Zr={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.isEraser?null:t.__local,localEventBounds:t=>t.__.isEraser?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.isEraser?null: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},Qr={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,r=s.length;i<r;i++)(t=s[i]).isBranch&&(t.__tempNumber=1,e.push(t),Jr(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++)$r(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:Jr,pushAllBranchStack:$r}=Qr,ta={run(t){for(let e=0,s=t.length;e<s;e++)t[e]();t.length=0}},ea={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?Mr.UP:t>45&&t<135?Mr.DOWN:t<=45&&t>=-45?Mr.RIGHT:Mr.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:sa.getSwipeDirection(T.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 ht,{list:i}=t;for(let t=0,r=i.length;t<r;t++)i[t].hasEvent(e)&&s.push(i[t]);return s}},sa=ea,{getDragEventData:ia,getDropEventData:ra,getSwipeEventData:aa,filterPathByEventType:oa}=ea;class na{constructor(t){this.interaction=t}setDragData(t){this.dragData=ia(t,t,t)}getDragList(){return this.dragging?Dr.dragList||this.dragList:null}checkDrag(t,e){const{interaction:s}=this,{downData:i}=s;if(this.moving&&!Vi.middle(t)&&!Vi.left(t))return void s.pointerCancel();const{dragData:r}=this;if(!this.moving){const a=s.config.move.dragEmpty&&i.target.isLeafer;this.moving=(Vi.middle(t)||s.moveMode||a)&&e,this.moving&&s.emit(Lr.START,r)}this.moving||this.dragStart(t,e);const{path:a,throughPath:o}=i;this.dragData=ia(i,r,t),o&&(this.dragData.throughPath=o),this.dragData.path=a,this.moving?(s.emit(Lr.BEFORE_MOVE,this.dragData),s.emit(Lr.MOVE,this.dragData)):this.dragging&&(this.dragDragableList(),s.emit(Pr.BEFORE_DRAG,this.dragData),s.emit(Pr.DRAG,this.dragData))}dragStart(t,e){this.dragging||(this.dragging=Vi.left(t)&&e,this.dragging&&(this.interaction.emit(Pr.START,this.dragData),this.getDragableList(this.dragData.path),this.dragList=oa(this.dragData.path,Pr.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=>{Fr.moveWorld(s,t,e)}))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:s}=this,{path:i}=t;s?i.indexAt(0)!==s.indexAt(0)&&(e.emit(Pr.OUT,t,s),e.emit(Pr.OVER,t,i)):e.emit(Pr.OVER,t,i),this.dragOverPath=i}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:s}=this,{path:i}=t;e.emit(Pr.LEAVE,t,s,i),e.emit(Pr.ENTER,t,i,s),this.dragEnterPath=i}dragEnd(t){const{interaction:e}=this,{downData:s}=e;if(!s)return;const{path:i,throughPath:r}=s,a=ia(s,t,t);r&&(a.throughPath=r),a.path=i,this.moving&&e.emit(Lr.END,a),this.dragging&&(e.emit(Pr.END,a),this.swipe(t,a),this.drop(t)),this.autoMoveCancel(),this.dragReset()}swipe(t,e){const{interaction:s}=this,{downData:i}=s;if(T.getDistance(i,t)>s.config.pointer.swipeDistance){const t=aa(i,this.dragData,e);this.interaction.emit(t.type,t)}}drop(t){const e=ra(t,this.getDragList(),Dr.dragData);e.path=this.dragEnterPath,this.interaction.emit(Dr.DROP,e),this.interaction.emit(Pr.LEAVE,t,this.dragEnterPath)}dragReset(){Dr.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,{autoDistance:i,dragOut:r}=e.config.move;if(!r||!i)return;const a=e.shrinkCanvasBounds,{x:o,y:n}=a,h=z.right(a),l=z.bottom(a),d=t.x<o?i:h<t.x?-i:0,c=t.y<n?i:l<t.y?-i:0;let u=0,p=0;this.autoMoveTimer=setInterval((()=>{u+=d,p+=c,T.move(s,d,c),T.move(this.dragData,d,c),e.move(Object.assign(Object.assign({},t),{moveX:d,moveY:c,totalX:u,totalY:p})),e.pointerMoveReal(t)}),10)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.dragReset()}}const ha=["move","zoom","rotate","key"];function la(t,e,s,i,r){if(ha.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!ca(t,r)){let a;for(let o=0,n=t.children.length;o<n;o++)a=t.children[o],!s.path.has(a)&&a.__.hittable&&da(a,e,s,i,r)}}function da(t,e,s,i,r){if(t.destroyed)return!0;if(t.__.hitSelf&&t.hasEvent(e,i)&&!ca(t,r)){s.phase=i?1:t===s.target?2:3;const r=at.get(e,s);if(t.emitEvent(r,i),r.isStop)return!0}return!1}function ca(t,e){return e&&e.has(t)}const ua={getData(t){const e=t[0],s=t[1],i=T.getCenter(e.from,s.from),r=T.getCenter(e.to,s.to),a={x:r.x-i.x,y:r.y-i.y},o=T.getDistance(e.from,s.from);return{move:a,scale:T.getDistance(e.to,s.to)/o,angle:T.getChangeAngle(e.from,s.from,e.to,s.to),center:r}}},{pathHasEventType:pa,getMoveEventData:_a,getZoomEventData:ga,getRotateEventData:fa}=ea;class ma{get dragging(){return this.dragger.dragging}get moveMode(){return Fi.isHoldSpaceKey()&&this.config.move.holdSpaceKey||this.downData&&Vi.middle(this.downData)}get hitRadius(){return this.config.pointer.hitRadius}constructor(e,s,i,r){this.config={wheel:{zoomMode:!1,zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:"Windows"===t.os?{x:37.5,y:37.5}:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,through:!1,tapTime:120,longPressTime:800,transformTime:500,dragHover:!0,dragDistance:2,swipeDistance:20,ignoreMove:!1},cursor:{}},this.tapCount=0,this.downKeyMap={},this.target=e,this.canvas=s,this.selector=i,this.defaultPath=new ht(e),this.transformer=new Wr(this),this.dragger=new na(this),r&&(this.config=ct.default(r,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Vi.defaultLeft(t),this.emit(kr.BEFORE_DOWN,t,this.defaultPath),this.updateDownData(t),e&&(t.path=this.defaultPath),this.emit(kr.DOWN,t),this.downTime=Date.now(),this.dragger.setDragData(t),Vi.left(t)&&(this.tapWait(),this.longPressWait(t)),this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;this.downData&&Vi.defaultLeft(t);const e=this.canvas.bounds.hitPoint(t);(e||this.downData)&&(e&&!this.downData&&Vi.left(t)&&this.pointerDown(t,!0),this.pointerMoveReal(t),this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(kr.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=T.getDistance(this.downData,t)>this.config.pointer.dragDistance;this.waitTap&&e&&this.pointerWaitCancel(),this.dragger.checkDrag(t,e)}this.dragger.moving||this.config.pointer.ignoreMove||(this.updateHoverData(t),this.emit(kr.MOVE,t),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t),this.dragger.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t)),this.updateCursor(t))}pointerUp(t){t||(t=this.downData),this.downData&&(Vi.defaultLeft(t),this.emit(kr.BEFORE_UP,t,this.defaultPath),this.findPath(t),this.emit(kr.UP,t),this.emit(kr.UP,this.downData,void 0,t.path),this.touchLeave(t),this.tap(t),this.dragger.dragEnd(t),this.downData=null,this.updateCursor(t))}pointerCancel(){this.pointerUp(this.dragger.dragData)}multiTouch(t,e){const{move:s,angle:i,scale:r,center:a}=ua.getData(e);this.rotate(fa(a,i,t)),this.zoom(ga(a,r,t)),this.move(_a(a,s,t))}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}keyDown(t){const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Fi.setDownCode(e),this.emit(Ar.HOLD,t,this.defaultPath),this.moveMode&&this.updateCursor()),this.emit(Ar.DOWN,t,this.defaultPath)}keyUp(t){const{code:e}=t;this.downKeyMap[e]=!1,Fi.setUpCode(e),this.emit(Ar.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}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(kr.OUT,t,this.overPath),this.emit(kr.OVER,t,e)):this.emit(kr.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(kr.LEAVE,t,this.enterPath,e),this.emit(kr.ENTER,t,e,this.enterPath),this.enterPath=e}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(kr.LEAVE,t),this.dragger.dragging&&this.emit(Dr.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,r=[kr.DOUBLE_TAP,kr.DOUBLE_CLICK].some((e=>pa(t.path,e)));i<e.tapTime+50&&r?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout((()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(t,e){const{hitRadius:s,through:i}=this.config.pointer,r=this.selector.getByPoint(t,s,e||{through:i});return r.throughPath&&(t.throughPath=r.throughPath),t.path=r.path,r.path}updateDownData(t){t||(t=this.downData),t&&(this.findPath(t),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getDragList(),name:kr.MOVE}),this.hoverData=t)}updateCursor(t){if(this.config.cursor.stop)return;if(t||(this.updateHoverData(),t=this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.moveMode)return this.setCursor(this.downData?"grabbing":"grab");if(!t||this.dragger.dragging)return;let e,s;const{path:i}=t;for(let t=0,r=i.length;t<r&&(e=i.list[t],s=e.cursor,!s);t++);this.setCursor(s)}setCursor(t){this.cursor=t,this.canvas.setCursor(t)}emitTap(t){this.emit(kr.TAP,t),this.emit(kr.CLICK,t)}emitDoubleTap(t){this.emit(kr.DOUBLE_TAP,t),this.emit(kr.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(kr.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(kr.LONG_TAP,t),pa(t.path,kr.LONG_TAP)&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new V(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Wi.RESIZE,this.__onResize,this)],t.once(Ui.READY,(()=>this.__onResize()))}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,s,i){this.running&&function(t,e,s,i){if(!s&&!e.path)return;let r;e.type=t,s?e=Object.assign(Object.assign({},e),{path:s}):s=e.path,e.target=s.indexAt(0);for(let a=s.length-1;a>-1;a--){if(r=s.list[a],da(r,t,e,!0,i))return;r.isApp&&la(r,t,e,!0,i)}for(let a=0,o=s.length;a<o;a++)if(r=s.list[a],r.isApp&&la(r,t,e,!1,i),da(r,t,e,!1,i))return}(t,e,s,i)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}}class ya{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}ya.custom={};const{toOuterOf:va}=z;class xa{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.boxChange(),this.positionChange()}checkUpdate(e){const{leafer:s}=this.leaf;if(s)s.ready?(t.realtimeLayout||e)&&s.watcher.changed&&s.layouter.layout():s.start();else{let e=this.leaf;for(;e.parent;)e=e.parent;t.layout(e)}}getTransform(t){return this.checkUpdate(),"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={}),va(this.contentBounds,this.leaf.__world,this._worldContentBounds),this._worldContentBounds}getWorldBoxBounds(){return this._worldBoxBounds||(this._worldBoxBounds={}),va(this.boxBounds,this.leaf.__world,this._worldBoxBounds),this._worldBoxBounds}getWorldStrokeBounds(){return this._worldStrokeBounds||(this._worldStrokeBounds={}),va(this.strokeBounds,this.leaf.__world,this._worldStrokeBounds),this._worldStrokeBounds}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this.strokeBounds=this.boxBounds,this.localStrokeBounds=this.leaf.__local,t&&this.spreadRenderCancel()}spreadRenderCancel(){this.renderBounds=this.strokeBounds,this.localRenderBounds=this.localStrokeBounds}spreadStroke(){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.renderSpread||this.spreadRenderCancel()}spreadRender(){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}}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}positionChange(){this.positionChanged=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}const wa={},ba={on(t,e,s){let i,r,a;s&&("boolean"==typeof s?i=s:(i=s.capture,r=s.once));const o=Oa(this,i,!0),n="string"==typeof t?t.split(" "):t,h=r?{listener:e,once:r}:{listener:e};n.forEach((t=>{t&&(a=o[t],a?-1===a.findIndex((t=>t.listener===e))&&a.push(h):o[t]=[h])}))},off(t,e,s){let i,r,a;s&&(i="boolean"==typeof s?s:s.capture);const o=Oa(this,i);("string"==typeof t?t.split(" "):t).forEach((t=>{t&&(r=o[t],r&&(a=r.findIndex((t=>t.listener===e)),a>-1&&r.splice(a,1),r.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){!e&&at.has(t)&&(e=at.get(t,{type:t,target:this,current:this}));const i=Oa(this,s)[t];if(i){let r;for(let a=0,o=i.length;a<o&&(r=i[a],r.listener(e),r.once&&(this.off(t,r.listener,s),a--,o--),!e||!e.isStopNow);a++);}},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 Oa(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:wa)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:wa)}}const Ca={__setAttr(t,e){if(this.leafer&&this.leafer.created){if("object"==typeof e||this.__.__getInput(t)!==e){this.__[t]=e;const{CHANGE:s}=Ii,i=new Ii(s,this,t,this.__.__get(t),e);this.hasEvent(s)&&!this.isLeafer&&this.emitEvent(i),this.leafer.emitEvent(i)}}else this.__[t]=e},__getAttr(t){return this.__.__get(t)}},{sin:Ta,cos:Ea}=Math,ka=Object.assign(Object.assign({},f.defaultMatrix),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0}),Ba={x:.5,y:.5},Pa={__updateWorldMatrix(){const t=this.parent?this.parent.__world:ka,e=this.__local,s=this.__world;if(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;const i=this.__;s.scaleX=t.scaleX*i.scaleX,s.scaleY=t.scaleY*i.scaleY,s.rotation=t.rotation+i.rotation,s.skewX=t.skewX+i.skewX,s.skewY=t.skewY+i.skewY}else 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,s.scaleX=t.scaleX,s.scaleY=t.scaleY,s.rotation=t.rotation,s.skewX=t.skewX,s.skewY=t.skewY},__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:r,skewX:o,skewY:n}=this.__;r||o||n?(r*=a,o&&(o*=a),n&&(n*=a),t.a=s*Ea(r+n),t.b=s*Ta(r+n),t.c=i*-Ta(r-o),t.d=i*Ea(r-o)):(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)}if(e.positionChanged){t.e=this.__.x,t.f=this.__.y;const{width:s,height:i,around:r}=this.__;if(r&&s&&i){const e="center"===r?Ba:r,a=s*e.x,o=i*e.y;t.e-=a*t.a+o*t.c,t.f-=a*t.b+o*t.d}e.positionChanged=!1}this.__layout.matrixChanged=!1}},{toOuterOf:Ra,copyAndSpread:Da}=z,La={__updateWorldBounds(){var t;if(this.__layout.boundsChanged){let e;const s=this.__layout;s.boxChanged&&(this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),s.boxChanged=!1,e=!0),s.localBoxChanged&&(this.__updateLocalBoxBounds(),s.localBoxChanged=!1,s.strokeSpread&&(s.strokeChanged=!0),s.renderSpread&&(s.renderChanged=!0),null===(t=this.parent)||void 0===t||t.__layout.boxChange()),s.strokeChanged&&(s.strokeSpread=this.__updateStrokeSpread(),s.strokeSpread?(s.strokeBounds===s.boxBounds&&s.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):s.spreadStrokeCancel(),s.strokeChanged=!1,s.renderSpread&&(s.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),e||(e=!0)),s.renderChanged&&(s.renderSpread=this.__updateRenderSpread(),s.renderSpread?(s.renderBounds!==s.boxBounds&&s.renderBounds!==s.strokeBounds||s.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):s.spreadRenderCancel(),s.renderChanged=!1,this.parent&&this.parent.__layout.renderChange()),s.boundsChanged=!1,Ra(this.__layout.renderBounds,this.__world,this.__world),e&&this.__onUpdateSize()}else Ra(this.__layout.renderBounds,this.__world,this.__world)},__updateLocalBoxBounds(){Ra(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Ra(this.__layout.strokeBounds,this.__local,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Ra(this.__layout.renderBounds,this.__local,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,{width:e,height:s}=this.__;t.x=0,t.y=0,t.width=e,t.height=s},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height,this.around&&(e.positionChanged=e.matrixChanged=!0,this.__updateWorldMatrix())},__updateStrokeBounds(){Da(this.__layout.strokeBounds,this.__layout.boxBounds,this.__layout.strokeSpread)},__updateRenderBounds(){Da(this.__layout.renderBounds,this.__layout.strokeBounds,this.__layout.renderSpread)}},{toInnerRadiusPointOf:Sa,copy:Ma,setRadius:Ia}=T,Aa={},Wa={__hitWorld(t){return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.hitCanvasChanged=!1),this.__.hitRadius&&(Ma(Aa,t),Ia(t=Aa,this.__.hitRadius)),Sa(t,this.__world,Aa),this.__hit(Aa)},__drawHitPath(t){this.__drawRenderPath(t)}},Na={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__world,e.matrix),t.opacity=this.__worldOpacity,this.__.__single){const s=t.getSameCanvas(!0);this.__draw(s,e);const i=this.__.isEraser?"destination-out":this.__.blendMode;this.__hasMirror||e.matrix?t.copyWorldByReset(s,null,null,i):t.copyWorldToInner(s,this.__world,this.__layout.renderBounds,i),s.recycle()}else 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)}},Xa={__updateEraser(t){this.__hasEraser=!!t||this.children.some((t=>t.__.isEraser))},__updateMask(t){this.__hasMask=!!t||this.children.some((t=>t.__.isMask))},__renderMask(t,e,s){e.resetTransform(),e.useMask(s),t.resetTransform(),t.opacity=this.__worldOpacity,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--)}}},Ya={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__worldOpacity)if(this.__.__single){t.resetTransform();const s=t.getSameCanvas();this.__renderBranch(s,e),t.opacity=this.__worldOpacity;const i=this.__.isEraser?"destination-out":this.__.blendMode;this.__hasMirror||e.matrix?t.copyWorld(s,null,null,i):t.copyWorld(s,this.__world,this.__world,i),s.recycle()}else this.__renderBranch(t,e)},__renderBranch(t,e){let s;const{children:i}=this;if(this.__hasMask&&i.length>1){let r,a=t.getSameCanvas(),o=t.getSameCanvas();for(let n=0,h=i.length;n<h;n++)s=i[n],s.isMask?(r?(this.__renderMask(t,o,a),a.clear(),o.clear()):r=!0,s.__render(a,e)):s.__render(o,e);this.__renderMask(t,o,a),a.recycle(),o.recycle()}else{const{bounds:r,hideBounds:a}=e;for(let o=0,n=i.length;o<n;o++)s=i[o],r&&!r.hit(s.__world,e.matrix)||a&&a.includes(s.__world,e.matrix)||s.__render(t,e)}}},{LEAF:ja,create:za}=s,{toInnerPoint:Ua,toOuterPoint:Ha}=f,{tempToOuterOf:Fa,copy:Va}=T,{moveLocal:Ga,zoomOfLocal:Ka,rotateOfLocal:qa,skewOfLocal:Za}=Fr;let Qa=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return pt}get __LayoutProcessor(){return xa}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get boxBounds(){return this.getBounds("box","inner")}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 resizeable(){return!0}get __hasMirror(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}constructor(t){this.innerId=za(ja),this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0},this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0},this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),t&&(t.children?this.set(t):Object.assign(this,t))}waitParent(t){this.parent?t():this.__parentWait?this.__parentWait.push(t):this.__parentWait=[t]}waitLeafer(t){this.leafer?t():this.__leaferWait?this.__leaferWait.push(t):this.__leaferWait=[t]}nextRender(t){this.leafer?this.leafer.nextRender(t):this.waitLeafer((()=>this.leafer.nextRender(t)))}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer=t,t&&(this.__level=this.parent?this.parent.__level+1:1,this.__leaferWait&&ta.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){}toJSON(){return this.__.__getInputData()}toString(){return JSON.stringify(this.toJSON())}__setAttr(t,e){}__getAttr(t){}forceUpdate(t){void 0===t?t="scaleX":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){}__updateMask(t){}__renderMask(t,e,s){}__removeMask(t){}getWorld(t){return this.__layout.checkUpdate(),"x"===t?this.__world.e:"y"===t?this.__world.f:this.__world[t]}getBounds(t,e="world"){return this.__layout.getBounds(t,e)}worldToLocal(t,e,s,i){this.parent?this.parent.worldToInner(t,e,s,i):e&&Va(e,t)}localToWorld(t,e,s,i){this.parent?this.parent.innerToWorld(t,e,s,i):e&&Va(e,t)}worldToInner(t,e,s,i){i&&(i.innerToWorld(t,e,s),t=e||t),Ua(this.worldTransform,t,e,s)}innerToWorld(t,e,s,i){Ha(this.worldTransform,t,e,s),i&&i.worldToInner(e||t,null,s)}getInnerPoint(t,e,s,i){const r=i?t:{};return this.worldToInner(t,r,s,e),r}getInnerPointByLocal(t,e,s,i){return this.getInnerPoint(t,this.parent,s,i)}getLocalPoint(t,e,s,i){const r=i?t:{};return this.worldToLocal(t,r,s,e),r}getLocalPointByInner(t,e,s,i){return this.getWorldPoint(t,this.parent,s,i)}getWorldPoint(t,e,s,i){const r=i?t:{};return this.innerToWorld(t,r,s,e),r}getWorldPointByLocal(t,e,s,i){const r=i?t:{};return this.localToWorld(t,r,s,e),r}move(t,e){Ga(this,t,e)}scaleOf(t,e,s){Ka(this,Fa(t,this.localTransform),e,s)}rotateOf(t,e){qa(this,Fa(t,this.localTransform),e)}skewOf(t,e,s){Za(this,Fa(t,this.localTransform),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(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}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.destroyed||(this.parent&&this.remove(),this.children&&this.removeAll(!0),this.__.destroy(),this.__layout.destroy(),this.__captureMap=this.__bubbleMap=this.__parentWait=this.__leaferWait=null,this.destroyed=!0)}};Qa=gt([Cr(Ca),Cr(Pa),Cr(La),Cr(Wa),Cr(ba),Cr(Na)],Qa);const{setByListWithHandle:Ja}=z,{sort:$a}=Qr,{localBoxBounds:to,localEventBounds:eo,localRenderBounds:so,maskLocalBoxBounds:io,maskLocalEventBounds:ro,maskLocalRenderBounds:ao}=Zr;let oo=class extends Qa{constructor(){super(),this.isBranch=!0,this.children=[]}__updateStrokeSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(){Ja(this.__layout.boxBounds,this.children,this.__hasMask?io:to)}__updateStrokeBounds(){Ja(this.__layout.strokeBounds,this.children,this.__hasMask?ro:eo)}__updateRenderBounds(){Ja(this.__layout.renderBounds,this.children,this.__hasMask?ao:so)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let s=0,i=e.length;s<i;s++)e[s].__tempNumber=s,e[s].__.zIndex&&(t=!0);e.sort($a),this.__layout.affectChildrenSort=t}}add(t,e){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),t.__layout.boundsChanged||t.__layout.positionChange(),t.__parentWait&&ta.run(t.__parentWait),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Mi.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){t.forEach((t=>this.add(t)))}remove(t,e){if(t){const s=this.children.indexOf(t);s>-1&&(this.children.splice(s,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}else void 0===t&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach((e=>{this.__realRemoveChild(e),t&&e.destroy()})))}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Mi.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const s=new Mi(t,e,this);e.hasEvent(t)&&e.emitEvent(s),this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(s),this.leafer.emitEvent(s)}};oo=gt([Cr(Ya),Cr(Xa)],oo);const no=Z.get("plugin"),ho={power:{},list:[],onLeafer(t){ho.list.forEach((e=>{e.onLeafer&&e.onLeafer(t)}))}};function lo(t,e){const s={},{power:i,list:r}=ho;if(i||no.error("need add PluginManager.power = LeaferUI"),r.includes(t))no.warn("repeat run",t.name);else{r.push(t),t.import?t.import.forEach((t=>{i[t]?s[t]=i[t]:no.error(t+" non-existent")})):no.warn("no import");try{t.run(s,e)}catch(t){no.error(t)}}}export{ji as AnimateEvent,G as AutoBounds,te as BezierHelper,V as Bounds,z as BoundsHelper,oo as Branch,Qr as BranchHelper,Ya as BranchRender,nt as CanvasManager,Mi as ChildEvent,e as Creator,ya as Cursor,ct as DataHelper,Z as Debug,Pr as DragEvent,Dr as DropEvent,le as EllipseHelper,Si as Event,at as EventCreator,_t as FileHelper,dt as HitCanvasManager,Ai as ImageEvent,Bi as ImageManager,s as IncrementId,ma as InteractionBase,ea as InteractionHelper,Ar as KeyEvent,Fi as Keyboard,Yi as LayoutEvent,Qa as Leaf,La as LeafBounds,Zr as LeafBoundsHelper,pt as LeafData,Ca as LeafDataProxy,ba as LeafEventer,Fr as LeafHelper,Wa as LeafHit,xa as LeafLayout,lt as LeafLevelList,ht as LeafList,Xa as LeafMask,Pa as LeafMatrix,Na as LeafRender,Et as LeaferCanvasBase,Ui as LeaferEvent,Li as LeaferImage,r as MathHelper,B as Matrix,f as MatrixHelper,Lr as MoveEvent,ua as MultiTouchHelper,Dt as NeedConvertToCanvasCommandMap,a as OneRadian,o as PI2,n as PI_2,wi as PathBounds,cs as PathCommandDataHelper,Pt as PathCommandMap,Ge as PathConvert,bi as PathCorner,Bs as PathCreator,Us as PathDrawer,kt as PathHelper,It as PathNumberCommandLengthMap,Mt as PathNumberCommandMap,t as Platform,ho as PluginManager,k as Point,T as PointHelper,Vi as PointerButton,kr as PointerEvent,Ii as PropertyEvent,At as RectHelper,zi as RenderEvent,Wi as ResizeEvent,Sr as RotateEvent,$ as Run,q as StringNumberMap,Mr as SwipeEvent,Ei as TaskItem,ki as TaskProcessor,Ni as TransformEvent,K as TwoPointBounds,P as TwoPointBoundsHelper,st as UICreator,Gi as UIEvent,ta as WaitHelper,Xi as WatchEvent,Ir as ZoomEvent,or as affectRenderBoundsType,rr as affectStrokeBoundsType,Zi as aliasType,sr as boundsType,Ci as canvasPatch,Tt as canvasSizeAttrs,pr as cursorType,_r as dataProcessor,Ji as dataType,mr as defineDataProcessor,Ki as defineKey,Qi as defineLeafAttr,cr as eraserType,qi as getDescriptor,ur as hitType,gr as layoutProcessor,dr as maskType,hr as opacityType,ir as pathType,$i as positionType,Tr as registerUI,Er as registerUIEvent,wr as rewrite,br as rewriteAble,er as rotationType,tr as scaleType,fr as setDefaultValue,lr as sortType,ar as strokeType,nr as surfaceType,Cr as useModule,lo as usePlugin};
package/dist/core.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const t={imageSuffix:"leaf"},e={},s={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=r;return e[t]?e[t]++:(e[t]=1,0)}},r=s,i={within:(t,e,s)=>(t<e&&(t=e),t>s&&(t=s),t),fourNumber(t){let e,s,r,i;if(t instanceof Array)switch(t.length){case 4:return t;case 2:e=r=t[0],s=i=t[1];break;case 3:e=t[0],s=i=t[1],r=t[2];break;case 1:t=t[0];break;default:t=0}return void 0===e?[t,t,t,t]:[e,s,r,i]},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),t),getGapRotation(t,e){if(e>1){const s=Math.abs(t%e);(s<1||s>e-1)&&(t=Math.round(t/e)*e)}return t},formatSkew:t=>i.within(t,-90,90)},o=Math.PI/180,n=2*Math.PI,a=Math.PI/2,{sin:h,cos:l,acos:d,atan:c,sqrt:u,PI:p}=Math,_={};function g(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const f={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},tempMatrix:{},set(t,e=1,s=0,r=0,i=1,o=0,n=0){t.a=e,t.b=s,t.c=r,t.d=i,t.e=o,t.f=n},get:g,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.b*=e,t.c*=s,t.d*=s},scaleOfOuter(t,e,s,r=s){m.toInnerPoint(t,e,_),m.scaleOfInner(t,_,s,r)},scaleOfInner(t,e,s,r=s){m.translateInner(t,e.x,e.y),m.scale(t,s,r),m.translateInner(t,-e.x,-e.y)},rotate(t,e){const s=l(e*=o),r=h(e),{a:i,b:n,c:a,d:d}=t;t.a=i*s-n*r,t.b=i*r+n*s,t.c=a*s-d*r,t.d=a*r+d*s},rotateOfOuter(t,e,s){m.toInnerPoint(t,e,_),m.rotateOfInner(t,_,s)},rotateOfInner(t,e,s){m.translateInner(t,e.x,e.y),m.rotate(t,s),m.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:r,b:i,c:n,d:a}=t;s&&(s*=o,t.a=r+n*s,t.b=i+a*s),e&&(e*=o,t.c=n+r*e,t.d=a+i*e)},skewOfOuter(t,e,s,r){m.toInnerPoint(t,e,_),m.skewOfInner(t,_,s,r)},skewOfInner(t,e,s,r){m.translateInner(t,e.x,e.y),m.skew(t,s,r),m.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:r,c:i,d:o,e:n,f:a}=t;t.a=e.a*s+e.b*i,t.b=e.a*r+e.b*o,t.c=e.c*s+e.d*i,t.d=e.c*r+e.d*o,t.e=e.e*s+e.f*i+n,t.f=e.e*r+e.f*o+a},preMultiply(t,e){const{a:s,b:r,c:i,d:o,e:n,f:a}=t;1===e.a&&0===e.b&&0===e.c&&1===e.d||(t.a=s*e.a+r*e.c,t.b=s*e.b+r*e.d,t.c=i*e.a+o*e.c,t.d=i*e.b+o*e.d),t.e=n*e.a+a*e.c+e.e,t.f=n*e.b+a*e.d+e.f},divide(t,e){m.preMultiply(t,m.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=m;return m.copy(e,t),m.invert(e),e},invert(t){const{a:e,b:s,c:r,d:i,e:o,f:n}=t,a=1/(e*i-s*r);t.a=i*a,t.b=-s*a,t.c=-r*a,t.d=e*a,t.e=-(o*i-n*r)*a,t.f=-(n*e-o*s)*a},toOuterPoint(t,e,s,r){const{x:i,y:o}=e;s||(s=e),s.x=i*t.a+o*t.c,s.y=i*t.b+o*t.d,r||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,r){const{x:i,y:o}=e,{a:n,b:a,c:h,d:l}=t,d=1/(n*l-a*h);if(s||(s=e),s.x=(i*l-o*h)*d,s.y=(o*n-i*a)*d,!r){const{e:e,f:r}=t;s.x-=(e*l-r*h)*d,s.y-=(r*n-e*a)*d}},decompose(t){const{a:e,b:s,c:r,d:i}=t;let n=e,a=i,h=0,l=0,_=0;if(s||r){const t=e*i-s*r,g=e*r+s*i;if(s){const r=e*e+s*s;n=u(r),a=t/n;const i=e/n;h=s>0?d(i):-d(i),l=c(g/r)/o}else{const e=r*r+i*i;a=u(e),n=t/a;const s=r/a;h=p/2-(i>0?d(-s):-d(s)),_=c(g/e)/o}h/=o}return{x:t.e,y:t.f,scaleX:n,scaleY:a,rotation:h,skewX:l,skewY:_}},reset(t){m.set(t)}},m=f,{toInnerPoint:y,toOuterPoint:x}=f,{sin:v,cos:E,abs:w,sqrt:b,atan2:C}=Math,T={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},setRadius(t,e,s){t.radiusX=e,t.radiusY=void 0===s?e:s},copy(t,e){t.x=e.x,t.y=e.y},move(t,e,s){t.x+=e,t.y+=s},rotate(t,e,s){s||(s=O.defaultPoint);const r=E(e*o),i=v(e*o),n=t.x-s.x,a=t.y-s.y;t.x=s.x+n*r-a*i,t.y=s.y+n*i+a*r},tempToInnerOf(t,e){const{tempPoint:s}=O;return O.copy(s,t),y(e,s,s),s},tempToOuterOf(t,e){const{tempPoint:s}=O;return O.copy(s,t),x(e,s,s),s},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:s}=O;return O.copy(s,t),O.toInnerRadiusPointOf(t,e,s),s},toInnerRadiusPointOf(t,e,s){s||(s=t),y(e,t,s),s.radiusX=Math.abs(t.radiusX/e.scaleX),s.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,s){y(e,t,s)},toOuterOf(t,e,s){x(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),r=w(e.y-t.y);return b(s*s+r*r)},getAngle:(t,e)=>O.getAtan2(t,e)/o,getChangeAngle(t,e,s,r){r||(r=e);let i=O.getAngle(t,e);const o=O.getAngle(s,r)-i;return o<-180?o+360:o},getAtan2:(t,e)=>C(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s){const r=O.getAtan2(t,e);return{x:t.x+E(r)*s,y:t.y+v(r)*s}},reset(t){O.reset(t)}},O=T;class P{constructor(t,e){"object"==typeof t?T.copy(this,t):T.set(this,t,e)}set(t,e){T.set(this,t,e)}copy(t){return T.copy(this,t),this}clone(){return new P(this)}rotate(t,e){return T.rotate(this,t,e),this}toInnerOf(t,e){return T.toInnerOf(this,t,e),this}toOuterOf(t,e){return T.toOuterOf(this,t,e),this}getCenter(t){return T.getCenter(this,t)}getDistance(t){return T.getDistance(this,t)}getAngle(t){return T.getAngle(this,t)}getAtan2(t){return T.getAtan2(this,t)}reset(){T.reset(this)}}class B{constructor(t,e,s,r,i,o){"object"==typeof t?f.copy(this,t):f.set(this,t,e,s,r,i,o)}set(t,e,s,r,i,o){f.set(this,t,e,s,r,i,o)}copy(t){return f.copy(this,t),this}clone(){return new B(this)}translate(t,e){return f.translate(this,t,e),this}translateInner(t,e){return f.translateInner(this,t,e),this}scale(t,e){return f.scale(this,t,e),this}scaleOfOuter(t,e,s){return f.scaleOfOuter(this,t,e,s),this}scaleOfInner(t,e,s){return f.scaleOfInner(this,t,e,s),this}rotate(t){return f.rotate(this,t),this}rotateOfOuter(t,e){return f.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return f.rotateOfInner(this,t,e),this}skew(t,e){return f.skew(this,t,e),this}skewOfOuter(t,e,s){return f.skewOfOuter(this,t,e,s),this}skewOfInner(t,e,s){return f.skewOfInner(this,t,e,s),this}multiply(t){return f.multiply(this,t),this}preMultiply(t){return f.preMultiply(this,t),this}divide(t){return f.divide(this,t),this}invert(){return f.invert(this),this}toOuterPoint(t,e,s){f.toOuterPoint(this,t,e,s)}toInnerPoint(t,e,s){f.toInnerPoint(this,t,e,s)}decompose(){return f.decompose(this)}reset(){f.reset(this)}}const k={tempPointBounds:{},setPoint(t,e,s){t.minX=t.maxX=e,t.minY=t.maxY=s},addPoint(t,e,s){t.minX=e<t.minX?e:t.minX,t.minY=s<t.minY?s:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=s>t.maxY?s:t.maxY},addBounds(t,e,s,r,i){D(t,e,s),D(t,e+r,s+i)},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:D}=k,{tempPointBounds:R,setPoint:L,addPoint:M,toBounds:S}=k,{toOuterPoint:I}=f;let A,W,N,X;const Y={},H={},j={tempBounds:{},set(t,e=0,s=0,r=0,i=0){t.x=e,t.y=s,t.width=r,t.height=i},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s,r){r||(r=s),U.set(t,e.x-s,e.y-r,e.width+2*s,e.height+2*r)},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),U.move(t,e,s),t),toOffsetOutBounds(t,e,s){e?F(e,t):e=t,s?(e.offsetX=-(U.right(s)-t.x),e.offsetY=-(U.bottom(s)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),U.move(e,-e.offsetX,-e.offsetY)},scale(t,e,s){s||(s=e),t.x&&(t.x*=e),t.y&&(t.y*=s),t.width*=e,t.height*=s},tempToOuterOf:(t,e)=>(U.copy(U.tempBounds,t),U.toOuterOf(U.tempBounds,e),U.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),U.toOuterOf(t,e),t),toOuterOf(t,e,s){if(s||(s=t),0===e.b&&0===e.c){const{a:r,d:i}=e;r>0?(s.width=t.width*r,s.x=e.e+t.x*r):(s.width=t.width*-r,s.x=e.e+t.x*r-s.width),i>0?(s.height=t.height*i,s.y=e.f+t.y*i):(s.height=t.height*-i,s.y=e.f+t.y*i-s.height)}else Y.x=t.x,Y.y=t.y,I(e,Y,H),L(R,H.x,H.y),Y.x=t.x+t.width,I(e,Y,H),M(R,H.x,H.y),Y.y=t.y+t.height,I(e,Y,H),M(R,H.x,H.y),Y.x=t.x,I(e,Y,H),M(R,H.x,H.y),S(R,s)},getFitMatrix(t,e){const s=Math.min(1,Math.min(t.width/e.width,t.height/e.height));return new B(s,0,0,s,-e.x*s,-e.y*s)},getSpread(t,e,s){const r={};return U.copyAndSpread(r,t,e,s),r},spread(t,e,s){U.copyAndSpread(t,t,e,s)},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)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},add(t,e){A=t.x+t.width,W=t.y+t.height,N=e.x+e.width,X=e.y+e.height,A=A>N?A:N,W=W>X?W:X,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=A-t.x,t.height=W-t.y},addList(t,e){U.setByListWithHandle(t,e,void 0,!0)},setByList(t,e,s=!1){U.setByListWithHandle(t,e,void 0,s)},addListWithHandle(t,e,s){U.setByListWithHandle(t,e,s,!0)},setByListWithHandle(t,e,s,r=!1){let i,o=!0;for(let n=0,a=e.length;n<a;n++)i=s?s(e[n]):e[n],i&&(i.width||i.height)&&(o?(o=!1,r||F(t,i)):z(t,i));o&&U.reset(t)},setByPoints(t,e){e.forEach(((t,e)=>{0===e?L(R,t.x,t.y):M(R,t.x,t.y)})),S(R,t)},hitRadiusPoint:(t,e,s)=>(s&&(e=T.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=T.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=U.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=U.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=U.tempToOuterOf(e,s));let{x:r,y:i,width:o,height:n}=e;return A=r+o,W=i+n,N=t.x+t.width,X=t.y+t.height,r=r>t.x?r:t.x,i=i>t.y?i:t.y,A=A<N?A:N,W=W<X?W:X,o=A-r,n=W-i,{x:r,y:i,width:o,height:n}},intersect(t,e,s){U.copy(t,U.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){U.set(t)}},U=j,{add:z,copy:F}=U;class V{constructor(t,e,s,r){"object"==typeof t?j.copy(this,t):j.set(this,t,e,s,r)}set(t,e,s,r){j.set(this,t,e,s,r)}copy(t){return j.copy(this,t),this}clone(){return new V(this)}scale(t,e){return j.scale(this,t,e),this}toOuterOf(t,e){return j.toOuterOf(this,t,e),this}getFitMatrix(t){return j.getFitMatrix(this,t)}spread(t){return j.spread(this,t),this}ceil(){return j.ceil(this),this}unsign(){return j.unsign(this),this}add(t){return j.add(this,t),this}addList(t){return j.setByList(this,t,!0),this}setByList(t,e){return j.setByList(this,t,e),this}addListWithHandle(t,e){return j.setByListWithHandle(this,t,e,!0),this}setByListWithHandle(t,e,s){return j.setByListWithHandle(this,t,e,s),this}setByPoints(t){return j.setByPoints(this,t),this}hitPoint(t,e){return j.hitPoint(this,t,e)}hitRadiusPoint(t,e){return j.hitRadiusPoint(this,t,e)}hit(t,e){return j.hit(this,t,e)}includes(t,e){return j.includes(this,t,e)}intersect(t,e){return j.intersect(this,t,e),this}getIntersect(t,e){return new V(j.getIntersectData(this,t,e))}isSame(t){return j.isSame(this,t)}isEmpty(){return j.isEmpty(this)}reset(){j.reset(this)}}const G={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 K{constructor(t){this.repeatMap={},this.name=t}static get(t){return new K(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(Z.enable){if(Z.filterList.length&&Z.filterList.every((t=>t!==this.name)))return;if(Z.excludeList.length&&Z.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}warn(...t){Z.enable&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}K.filterList=[],K.excludeList=[];const Z=K,q=K.get("RunTime");class Q{static start(t,e){const r=s.create(s.RUNTIME);return J.currentId=J.idMap[r]=e?performance.now():Date.now(),J.currentName=J.nameMap[r]=t,J.nameToIdMap[t]=r,r}static end(t,e){const s=J.idMap[t],r=J.nameMap[t];J.idMap[t]=J.nameMap[t]=J.nameToIdMap[r]=void 0,e?q.log(r,performance.now()-s,"µs"):q.log(r,Date.now()-s,"ms")}static endOfName(t,e){const s=J.nameToIdMap[t];void 0!==s&&J.end(s,e)}}Q.idMap={},Q.nameMap={},Q.nameToIdMap={};const J=Q,$=K.get("UICreator"),tt={list:{},register(t){const{__tag:e}=t.prototype;et[e]?$.repeat(e):et[e]=t},get(t,e,s,r,i,o){const n=new et[t](e);return void 0!==s&&(n.x=s,r&&(n.y=r),i&&(n.width=i),o&&(n.height=o)),n}},{list:et}=tt,st=K.get("EventCreator"),rt={nameList:{},register(t){let e;Object.keys(t).forEach((s=>{e=t[s],"string"==typeof e&&(it[e]?st.repeat(e):it[e]=t)}))},changeName(t,e){const s=it[t];if(s){const r=Object.keys(s).find((e=>s[e]===t));r&&(s[r]=e,it[e]=s)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new it[t](...e)},{nameList:it}=rt;class ot{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let s;const{list:r}=this;for(let e=0,i=r.length;e<i;e++)if(s=r[e],s.recycled&&s.isSameSize(t))return s.recycled=!1,s.manager||(s.manager=this),s;const i=e.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,r=this.list.length;s<r;s++)t=this.list[s],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach((t=>{t.destroy()})),this.list.length=0}destroy(){this.clear()}}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 t&&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 r=0,i=e.length;r<i;r++)void 0!==s?this.keys[e[r].innerId]=r-1:e[r].innerId===t.innerId&&(s=r,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}}const at={default:(t,e)=>(ht(e,t),ht(t,e),t),assign(t,e){let s;Object.keys(e).forEach((r=>{var i;s=e[r],(null==s?void 0:s.constructor)===Object&&(null===(i=t[r])||void 0===i?void 0:i.constructor)===Object?ht(t[r],e[r]):t[r]=e[r]}))},copyAttrs:(t,e,s)=>(s.forEach((s=>{void 0!==e[s]&&(t[s]=e[s])})),t),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];if(void 0!==e)return 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];if(void 0!==e)return e}return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(){const t={tag:this.__leaf.tag},{__input:e}=this;let s,r;for(let i in this)s=i.substring(1),void 0!==this[s]&&(r=e?e[s]:void 0,t[s]=void 0===r?this[i]:r);return t}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){"pass-through"===this.blendMode?this.__leaf.__hasEraser||this.isEraser?this.__single=!0:this.__single&&(this.__single=!1):this.__single=!0}destroy(){this.__input=this.__middle=null}}const dt={mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]}};function ct(t,e,s,r){var i,o=arguments.length,n=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,s,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(n=(o<3?i(n):o>3?i(e,s,n):i(e,s))||n);return o>3&&n&&Object.defineProperty(e,s,n),n}function ut(t,e,s,r){return new(s||(s=Promise))((function(i,o){function n(t){try{h(r.next(t))}catch(t){o(t)}}function a(t){try{h(r.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(n,a)}h((r=r.apply(t,e||[])).next())}))}function pt(t){return(e,s)=>{t||(t=s);const r={get(){return this.context[t]},set(e){this.context[t]=e}};Object.defineProperty(e,s,r)}}"function"==typeof SuppressedError&&SuppressedError;const _t=[];function gt(){return(t,e)=>{_t.push(e)}}const ft=[];class mt{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||ft)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;_t.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))})),this.textBaseline="alphabetic"}setTransform(t,e,s,r,i,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,r,i,o){"object"==typeof t?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,s,r,i,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,s,r){}strokeRect(t,e,s,r){}clearRect(t,e,s,r){}drawImage(t,e,s,r,i,o,n,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/r*a;r+=e,e=0,o+=t,a-=t}if(s<0){const t=-s/i*h;i+=s,s=0,n+=t,h-=t}this.context.drawImage(t,e,s,r,i,o,n,a,h);break;case 5:this.context.drawImage(t,e,s,r,i);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,r,i,o){}quadraticCurveTo(t,e,s,r){}closePath(){}arc(t,e,s,r,i,o){}arcTo(t,e,s,r,i){}ellipse(t,e,s,r,i,o,n,a){}rect(t,e,s,r){}roundRect(t,e,s,r,i){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,r){}createPattern(t,e){}createRadialGradient(t,e,s,r,i,o){}fillText(t,e,s,r){}measureText(t){}strokeText(t,e,s,r){}destroy(){this.context=null}}ct([pt("imageSmoothingEnabled")],mt.prototype,"smooth",void 0),ct([pt("imageSmoothingQuality")],mt.prototype,"smoothLevel",void 0),ct([pt("globalAlpha")],mt.prototype,"opacity",void 0),ct([pt()],mt.prototype,"fillStyle",void 0),ct([pt()],mt.prototype,"strokeStyle",void 0),ct([pt("lineWidth")],mt.prototype,"strokeWidth",void 0),ct([pt("lineCap")],mt.prototype,"strokeCap",void 0),ct([pt("lineJoin")],mt.prototype,"strokeJoin",void 0),ct([pt("lineDashOffset")],mt.prototype,"dashOffset",void 0),ct([pt()],mt.prototype,"miterLimit",void 0),ct([pt()],mt.prototype,"shadowBlur",void 0),ct([pt()],mt.prototype,"shadowColor",void 0),ct([pt()],mt.prototype,"shadowOffsetX",void 0),ct([pt()],mt.prototype,"shadowOffsetY",void 0),ct([pt()],mt.prototype,"filter",void 0),ct([pt()],mt.prototype,"font",void 0),ct([pt()],mt.prototype,"fontKerning",void 0),ct([pt()],mt.prototype,"fontStretch",void 0),ct([pt()],mt.prototype,"fontVariantCaps",void 0),ct([pt()],mt.prototype,"textAlign",void 0),ct([pt()],mt.prototype,"textBaseline",void 0),ct([pt()],mt.prototype,"textRendering",void 0),ct([pt()],mt.prototype,"wordSpacing",void 0),ct([pt()],mt.prototype,"letterSpacing",void 0),ct([pt()],mt.prototype,"direction",void 0),ct([gt()],mt.prototype,"setTransform",null),ct([gt()],mt.prototype,"resetTransform",null),ct([gt()],mt.prototype,"getTransform",null),ct([gt()],mt.prototype,"save",null),ct([gt()],mt.prototype,"restore",null),ct([gt()],mt.prototype,"translate",null),ct([gt()],mt.prototype,"scale",null),ct([gt()],mt.prototype,"rotate",null),ct([gt()],mt.prototype,"fill",null),ct([gt()],mt.prototype,"stroke",null),ct([gt()],mt.prototype,"clip",null),ct([gt()],mt.prototype,"fillRect",null),ct([gt()],mt.prototype,"strokeRect",null),ct([gt()],mt.prototype,"clearRect",null),ct([gt()],mt.prototype,"beginPath",null),ct([gt()],mt.prototype,"moveTo",null),ct([gt()],mt.prototype,"lineTo",null),ct([gt()],mt.prototype,"bezierCurveTo",null),ct([gt()],mt.prototype,"quadraticCurveTo",null),ct([gt()],mt.prototype,"closePath",null),ct([gt()],mt.prototype,"arc",null),ct([gt()],mt.prototype,"arcTo",null),ct([gt()],mt.prototype,"ellipse",null),ct([gt()],mt.prototype,"rect",null),ct([gt()],mt.prototype,"roundRect",null),ct([gt()],mt.prototype,"createConicGradient",null),ct([gt()],mt.prototype,"createLinearGradient",null),ct([gt()],mt.prototype,"createPattern",null),ct([gt()],mt.prototype,"createRadialGradient",null),ct([gt()],mt.prototype,"fillText",null),ct([gt()],mt.prototype,"measureText",null),ct([gt()],mt.prototype,"strokeText",null);const yt=new V,xt={width:1,height:1,pixelRatio:1},vt=K.get("LeaferCanvasBase"),Et=["width","height","pixelRatio"];const wt={creator:{},parse(t,e){},convertToCanvasData(t,e){}},bt={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Ct=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},bt),Tt={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},Ot={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},Pt=Object.assign(Object.assign({},Ot),bt),Bt=Ct,kt={};for(let t in Bt)kt[Bt[t]]=t;const Dt={};for(let t in Bt)Dt[Bt[t]]=Tt[t];const Rt={drawRoundRect(t,e,s,r,o,n){let[a,h,l,d]=i.fourNumber(n);const c=Math.min(r/2,o/2);a>c&&(a=c),h>c&&(h=c),l>c&&(l=c),d>c&&(d=c),a?t.moveTo(e+a,s):t.moveTo(e,s),h?t.arcTo(e+r,s,e+r,s+o,h):t.lineTo(e+r,s),l?t.arcTo(e+r,s+o,e,s+o,l):t.lineTo(e+r,s+o),d?t.arcTo(e,s+o,e,s,d):t.lineTo(e,s+o),a?t.arcTo(e,s,e+r,s,a):t.lineTo(e,s)}},{sin:Lt,cos:Mt,atan2:St,ceil:It,abs:At,PI:Wt,sqrt:Nt,pow:Xt}=Math,{setPoint:Yt,addPoint:Ht}=k,{set:jt}=T,{M:Ut,L:zt,C:Ft,Q:Vt,Z:Gt}=Ct,Kt={},Zt={points(t,e,s,r){if(t.push(Ut,e[0],e[1]),s&&e.length>5){let i,o,n,a,h,l,d,c,u,p,_,g,f,m=e.length;const y=!0===s?.5:s;r&&(m=(e=[e[m-2],e[m-1],...e,e[0],e[1],e[2],e[3]]).length);for(let s=2;s<m-2;s+=2)i=e[s-2],o=e[s-1],n=e[s],a=e[s+1],h=e[s+2],l=e[s+3],_=Nt(Xt(n-i,2)+Xt(a-o,2)),g=Nt(Xt(h-n,2)+Xt(l-a,2)),f=_+g,_=y*_/f,g=y*g/f,h-=i,l-=o,d=n-_*h,c=a-_*l,2===s?r||t.push(Vt,d,c,n,a):t.push(Ft,u,p,d,c,n,a),u=n+g*h,p=a+g*l;r||t.push(Vt,u,p,e[m-2],e[m-1])}else for(let s=2,r=e.length;s<r;s+=2)t.push(zt,e[s],e[s+1]);r&&t.push(Gt)},rect(t,e,s,r,i){wt.creator.path=t,wt.creator.moveTo(e,s).lineTo(e+r,s).lineTo(e+r,s+i).lineTo(e,s+i).lineTo(e,s)},roundRect(t,e,s,r,i,o){wt.creator.path=[],Rt.drawRoundRect(wt.creator,e,s,r,i,o),t.push(...wt.convertToCanvasData(wt.creator.path,!0))},arcTo(t,e,s,r,i,h,l,d,c,u,p){const _=r-e,g=i-s,f=h-r,m=l-i;let y=St(g,_),x=St(m,f),v=x-y;if(v<0&&(v+=n),v===Wt||At(_+g)<1e-12||At(f+m)<1e-12)return t&&t.push(zt,r,i),c&&(Yt(c,e,s),Ht(c,r,i)),p&&jt(p,e,s),void(u&&jt(u,r,i));const E=_*m-f*g<0,w=E?-1:1,b=d/Mt(v/2),C=r+b*Mt(y+v/2+a*w),T=i+b*Lt(y+v/2+a*w);return y-=a*w,x-=a*w,Jt(t,C,T,d,d,0,y/o,x/o,E,c,u,p)},arc:(t,e,s,r,i,o,n,a,h,l)=>Jt(t,e,s,r,r,0,i,o,n,a,h,l),ellipse(t,e,s,r,i,h,l,d,c,u,p,_){const g=h*o,f=Lt(g),m=Mt(g);let y=l*o,x=d*o;y>Wt&&(y-=n),x<0&&(x+=n);let v=x-y;v<0?v+=n:v>n&&(v-=n),c&&(v-=n);const E=It(At(v/a)),w=v/E,b=Lt(w/4),C=8/3*b*b/Lt(w/2);x=y+w;let T,O,P,B,k,D,R,L,M=Mt(y),S=Lt(y),I=P=m*r*M-f*i*S,A=B=f*r*M+m*i*S,W=e+P,N=s+B;t&&t.push(zt,W,N),u&&Yt(u,W,N),_&&jt(_,W,N);for(let o=0;o<E;o++)T=Mt(x),O=Lt(x),P=m*r*T-f*i*O,B=f*r*T+m*i*O,k=e+I-C*(m*r*S+f*i*M),D=s+A-C*(f*r*S-m*i*M),R=e+P+C*(m*r*O+f*i*T),L=s+B+C*(f*r*O-m*i*T),t&&t.push(Ft,k,D,R,L,e+P,s+B),u&&Qt(e+I,s+A,k,D,R,L,e+P,s+B,u,!0),I=P,A=B,M=T,S=O,y=x,x+=w;p&&jt(p,e+P,s+B)},quadraticCurveTo(t,e,s,r,i,o,n){t.push(Ft,(e+2*r)/3,(s+2*i)/3,(o+2*r)/3,(n+2*i)/3,o,n)},toTwoPointBoundsByQuadraticCurve(t,e,s,r,i,o,n,a){Qt(t,e,(t+2*s)/3,(e+2*r)/3,(i+2*s)/3,(o+2*r)/3,i,o,n,a)},toTwoPointBounds(t,e,s,r,i,o,n,a,h,l){const d=[];let c,u,p,_,g,f,m,y,x=t,v=s,E=i,w=n;for(let t=0;t<2;++t)if(1==t&&(x=e,v=r,E=o,w=a),c=-3*x+9*v-9*E+3*w,u=6*x-12*v+6*E,p=3*v-3*x,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;_=-p/u,0<_&&_<1&&d.push(_)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(g=(-u+y)/(2*c),0<g&&g<1&&d.push(g),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?Ht(h,t,e):Yt(h,t,e),Ht(h,n,a);for(let l=0,c=d.length;l<c;l++)qt(d[l],t,e,s,r,i,o,n,a,Kt),Ht(h,Kt.x,Kt.y)},getPointAndSet(t,e,s,r,i,o,n,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,_=t*t*t;l.x=c*e+u*r+p*o+_*a,l.y=c*s+u*i+p*n+_*h},getPoint(t,e,s,r,i,o,n,a,h){const l={};return qt(t,e,s,r,i,o,n,a,h,l),l}},{getPointAndSet:qt,toTwoPointBounds:Qt,ellipse:Jt}=Zt,{sin:$t,cos:te,sqrt:ee,atan2:se}=Math,{ellipse:re}=Zt,ie={ellipticalArc(t,e,s,r,i,a,h,l,d,c,u){const p=(d-e)/2,_=(c-s)/2,g=a*o,f=$t(g),m=te(g),y=-m*p-f*_,x=-m*_+f*p,v=r*r,E=i*i,w=x*x,b=y*y,C=v*E-v*w-E*b;let T=0;if(C<0){const t=ee(1-C/(v*E));r*=t,i*=t}else T=(h===l?-1:1)*ee(C/(v*w+E*b));const O=T*r*x/i,P=-T*i*y/r,B=se((x-P)/i,(y-O)/r),k=se((-x-P)/i,(-y-O)/r);let D=k-B;0===l&&D>0?D-=n:1===l&&D<0&&(D+=n);const R=e+p+m*O-f*P,L=s+_+f*O+m*P,M=D<0?1:0;u?re(t,R,L,r,i,a,B/o,k/o,M):r!==i||a?t.push(Ct.G,R,L,r,i,a,B/o,k/o,M):t.push(Ct.O,R,L,r,B/o,k/o,M)}},{M:oe,m:ne,L:ae,l:he,H:le,h:de,V:ce,v:ue,C:pe,c:_e,S:ge,s:fe,Q:me,q:ye,T:xe,t:ve,A:Ee,a:we,Z:be,z:Ce,N:Te,D:Oe,X:Pe,G:Be,F:ke,O:De,P:Re,U:Le}=Ct,{rect:Me,roundRect:Se,arcTo:Ie,arc:Ae,ellipse:We,quadraticCurveTo:Ne}=Zt,{ellipticalArc:Xe}=ie,Ye=K.get("PathConvert"),He={},je={current:{dot:0},stringify(t){let e,s,r,i=0,o=t.length,n="";for(;i<o;){s=t[i],e=Dt[s],n+=s===r?" ":kt[s];for(let s=1;s<e;s++)n+=t[i+s],s===e-1||(n+=" ");r=s,i+=e}return n},parse(t,e){let s,r,i,o="";const n=[],a=e?Pt:Ot;for(let e=0,h=t.length;e<h;e++)r=t[e],G[r]?("."===r&&(Ue.dot++,Ue.dot>1&&(ze(n,o),o="")),o+=r):Ct[r]?(o&&(ze(n,o),o=""),Ue.name=Ct[r],Ue.length=Tt[r],Ue.index=0,ze(n,Ue.name),!s&&a[r]&&(s=!0)):"-"===r||"+"===r?"e"===i||"E"===i?o+=r:(o&&ze(n,o),o=r):o&&(ze(n,o),o=""),i=r;return o&&ze(n,o),s?je.toCanvasData(n,e):n},toCanvasData(t,e){let s,r,i,o,n,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(i=t[c],i){case ne:t[c+1]+=a,t[c+2]+=h;case oe:a=t[c+1],h=t[c+2],p.push(oe,a,h),c+=3;break;case de:t[c+1]+=a;case le:a=t[c+1],p.push(ae,a,h),c+=2;break;case ue:t[c+1]+=h;case ce:h=t[c+1],p.push(ae,a,h),c+=2;break;case he:t[c+1]+=a,t[c+2]+=h;case ae:a=t[c+1],h=t[c+2],p.push(ae,a,h),c+=3;break;case fe:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,i=ge;case ge:n=o===pe||o===ge,l=n?2*a-s:t[c+1],d=n?2*h-r:t[c+2],s=t[c+1],r=t[c+2],a=t[c+3],h=t[c+4],p.push(pe,l,d,s,r,a,h),c+=5;break;case _e:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,i=pe;case pe:s=t[c+3],r=t[c+4],a=t[c+5],h=t[c+6],p.push(pe,t[c+1],t[c+2],s,r,a,h),c+=7;break;case ve:t[c+1]+=a,t[c+2]+=h,i=xe;case xe:n=o===me||o===xe,s=n?2*a-s:t[c+1],r=n?2*h-r:t[c+2],e?Ne(p,a,h,s,r,t[c+1],t[c+2]):p.push(me,s,r,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case ye:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,i=me;case me:s=t[c+1],r=t[c+2],e?Ne(p,a,h,s,r,t[c+3],t[c+4]):p.push(me,s,r,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case we:t[c+6]+=a,t[c+7]+=h;case Ee:Xe(p,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case Ce:case be:p.push(be),c++;break;case Te:a=t[c+1],h=t[c+2],e?Me(p,a,h,t[c+3],t[c+4]):Fe(p,t,c,5),c+=5;break;case Oe:a=t[c+1],h=t[c+2],e?Se(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):Fe(p,t,c,9),c+=9;break;case Pe:a=t[c+1],h=t[c+2],e?Se(p,a,h,t[c+3],t[c+4],t[c+5]):Fe(p,t,c,6),c+=6;break;case Be:We(e?p:Fe(p,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,He),a=He.x,h=He.y,c+=9;break;case ke:e?We(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):Fe(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case De:Ae(e?p:Fe(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,He),a=He.x,h=He.y,c+=7;break;case Re:e?Ae(p,t[c+1],t[c+2],t[c+3],0,360,!1):Fe(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Le:Ie(e?p:Fe(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,He),a=He.x,h=He.y,c+=6;break;default:return Ye.error(`command: ${i} [index:${c}]`,t),p}o=i}return p},copyData(t,e,s,r){for(let i=s,o=s+r;i<o;i++)t.push(e[i])},pushData(t,e){Ue.index===Ue.length&&(Ue.index=1,t.push(Ue.name)),t.push(Number(e)),Ue.index++,Ue.dot=0}},{current:Ue,pushData:ze,copyData:Fe}=je,{M:Ve,L:Ge,C:Ke,Q:Ze,Z:qe,N:Qe,D:Je,X:$e,G:ts,F:es,O:ss,P:rs,U:is}=Ct,os={},ns={beginPath(t){t.length=0},moveTo(t,e,s){t.push(Ve,e,s)},lineTo(t,e,s){t.push(Ge,e,s)},bezierCurveTo(t,e,s,r,i,o,n){t.push(Ke,e,s,r,i,o,n)},quadraticCurveTo(t,e,s,r,i){t.push(Ze,e,s,r,i)},closePath(t){t.push(qe)},rect(t,e,s,r,i){t.push(Qe,e,s,r,i)},roundRect(t,e,s,r,o,n){if("number"==typeof n)t.push($e,e,s,r,o,n);else{const a=i.fourNumber(n);a?t.push(Je,e,s,r,o,...a):t.push(Qe,e,s,r,o)}},ellipse(t,e,s,r,i,o,n,a,h){void 0===o?t.push(es,e,s,r,i):(void 0===n&&(n=0),void 0===a&&(a=360),t.push(ts,e,s,r,i,o,n,a,h?1:0))},arc(t,e,s,r,i,o,n){void 0===i?t.push(rs,e,s,r):(void 0===o&&(o=360),t.push(ss,e,s,r,i,o,n?1:0))},arcTo(t,e,s,r,i,o){t.push(is,e,s,r,i,o)},drawEllipse(t,e,s,r,i,o,n,a,h){void 0===o&&(o=0),void 0===n&&(n=0),void 0===a&&(a=360),Zt.ellipse(null,e,s,r,i,o,n,a,h,null,null,os),t.push(Ve,os.x,os.y),as(t,e,s,r,i,o,n,a,h)},drawArc(t,e,s,r,i,o,n){void 0===i&&(i=0),void 0===o&&(o=360),Zt.arc(null,e,s,r,i,o,n,null,null,os),t.push(Ve,os.x,os.y),hs(t,e,s,r,i,o,n)},drawPoints(t,e,s,r){Zt.points(t,e,s,r)}},{ellipse:as,arc:hs}=ns,{moveTo:ls,lineTo:ds,quadraticCurveTo:cs,bezierCurveTo:us,closePath:ps,beginPath:_s,rect:gs,roundRect:fs,ellipse:ms,arc:ys,arcTo:xs,drawEllipse:vs,drawArc:Es,drawPoints:ws}=ns;class bs{constructor(t){this.path=t?"string"==typeof t?wt.parse(t):t:[]}beginPath(){return _s(this.path),this}moveTo(t,e){return ls(this.path,t,e),this}lineTo(t,e){return ds(this.path,t,e),this}bezierCurveTo(t,e,s,r,i,o){return us(this.path,t,e,s,r,i,o),this}quadraticCurveTo(t,e,s,r){return cs(this.path,t,e,s,r),this}closePath(){return ps(this.path),this}rect(t,e,s,r){return gs(this.path,t,e,s,r),this}roundRect(t,e,s,r,i){return fs(this.path,t,e,s,r,i),this}ellipse(t,e,s,r,i,o,n,a){return ms(this.path,t,e,s,r,i,o,n,a),this}arc(t,e,s,r,i,o){return ys(this.path,t,e,s,r,i,o),this}arcTo(t,e,s,r,i){return xs(this.path,t,e,s,r,i),this}drawEllipse(t,e,s,r,i,o,n,a){return vs(this.path,t,e,s,r,i,o,n,a),this}drawArc(t,e,s,r,i,o){return Es(this.path,t,e,s,r,i,o),this}drawPoints(t,e,s){return ws(this.path,t,e,s),this}}const{M:Cs,L:Ts,C:Os,Q:Ps,Z:Bs,N:ks,D:Ds,X:Rs,G:Ls,F:Ms,O:Ss,P:Is,U:As}=Ct,Ws=K.get("PathDrawer"),Ns={drawPathByData(t,e){if(!e)return;let s,r=0,i=e.length;for(;r<i;)switch(s=e[r],s){case Cs:t.moveTo(e[r+1],e[r+2]),r+=3;break;case Ts:t.lineTo(e[r+1],e[r+2]),r+=3;break;case Os:t.bezierCurveTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5],e[r+6]),r+=7;break;case Ps:t.quadraticCurveTo(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case Bs:t.closePath(),r+=1;break;case ks:t.rect(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case Ds:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],[e[r+5],e[r+6],e[r+7],e[r+8]]),r+=9;break;case Rs:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;case Ls:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]*o,e[r+6]*o,e[r+7]*o,e[r+8]),r+=9;break;case Ms:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],0,0,n,!1),r+=5;break;case Ss:t.arc(e[r+1],e[r+2],e[r+3],e[r+4]*o,e[r+5]*o,e[r+6]),r+=7;break;case Is:t.arc(e[r+1],e[r+2],e[r+3],0,n,!1),r+=4;break;case As:t.arcTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;default:return void Ws.error(`command: ${s} [index:${r}]`,e)}}},{M:Xs,L:Ys,C:Hs,Q:js,Z:Us,N:zs,D:Fs,X:Vs,G:Gs,F:Ks,O:Zs,P:qs,U:Qs}=Ct,{toTwoPointBounds:Js,toTwoPointBoundsByQuadraticCurve:$s,arcTo:tr,arc:er,ellipse:sr}=Zt,{add:rr,copy:ir,addPoint:or,setPoint:nr,addBounds:ar,toBounds:hr}=k,lr=K.get("PathBounds");let dr,cr,ur;const pr={},_r={},gr={},fr={toBounds(t,e){fr.toTwoPointBounds(t,_r),hr(_r,e)},toTwoPointBounds(t,e){if(!t||!t.length)return nr(e,0,0);let s,r,i,o,n,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(s=t[a],0===a&&(s===Us||s===Hs||s===js?nr(e,h,l):nr(e,t[a+1],t[a+2])),s){case Xs:case Ys:h=t[a+1],l=t[a+2],or(e,h,l),a+=3;break;case Hs:o=t[a+5],n=t[a+6],Js(h,l,t[a+1],t[a+2],t[a+3],t[a+4],o,n,pr),rr(e,pr),h=o,l=n,a+=7;break;case js:r=t[a+1],i=t[a+2],o=t[a+3],n=t[a+4],$s(h,l,r,i,o,n,pr),rr(e,pr),h=o,l=n,a+=5;break;case Us:a+=1;break;case zs:h=t[a+1],l=t[a+2],ar(e,h,l,t[a+3],t[a+4]),a+=5;break;case Fs:case Vs:h=t[a+1],l=t[a+2],ar(e,h,l,t[a+3],t[a+4]),a+=s===Fs?9:6;break;case Gs:sr(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],pr,gr),0===a?ir(e,pr):rr(e,pr),h=gr.x,l=gr.y,a+=9;break;case Ks:h=t[a+1],l=t[a+2],cr=t[a+3],ur=t[a+4],ar(e,h-cr,l-ur,2*cr,2*ur),h+=cr,a+=5;break;case Zs:er(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],pr,gr),0===a?ir(e,pr):rr(e,pr),h=gr.x,l=gr.y,a+=7;break;case qs:h=t[a+1],l=t[a+2],dr=t[a+3],ar(e,h-dr,l-dr,2*dr,2*dr),h+=dr,a+=4;break;case Qs:tr(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],pr,gr),0===a?ir(e,pr):rr(e,pr),h=gr.x,l=gr.y,a+=6;break;default:return void lr.error(`command: ${s} [index:${a}]`,t)}}},mr={smooth:(t,e,s)=>t};wt.creator=new bs,wt.parse=je.parse,wt.convertToCanvasData=je.toCanvasData;const{drawRoundRect:yr}=Rt;const xr=K.get("TaskProcessor");class vr{constructor(t){this.parallel=!0,this.time=1,this.id=s.create(s.TASK),this.task=t}run(){return ut(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){xr.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class Er{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,s=0;for(let r=0;r<t;r++)r<=this.finishedIndex?(s+=this.list[r].time,r===this.finishedIndex&&(e=s)):e+=this.list[r].time;return this.isComplete?1:s/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&at.assign(this.config,t),this.empty()}add(t,e){let s,r,i,o;const n=new vr(t);return n.parent=this,"number"==typeof e?o=e:e&&(r=e.parallel,s=e.start,i=e.time,o=e.delay),i&&(n.time=i),!1===r&&(n.parallel=!1),void 0===o?this.push(n,s):(this.delayNumber++,setTimeout((()=>{this.delayNumber--,this.push(n,s)}),o)),this.isComplete=!1,n}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout((()=>this.start())))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[]}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach((t=>{t.isComplete||t.cancel()})),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)})):this.nextTask()}runParallelTasks(){this.parallelList.forEach((t=>this.runParallelTask(t)))}runParallelTask(t){t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout((()=>this.run()))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let s=this.index;s<e&&(t=this.list[s],t.parallel);s++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const s=e.length,r=this.finishedIndex+s;if(e.length){if(!this.running)return;r<this.total&&(t=this.list[r],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const wr={map:{},recycledList:[],tasker:new Er,patternTasker:new Er,get isComplete(){return br.tasker.isComplete&&br.patternTasker.isComplete},get(t){let s=br.map[t.url];return s||(s=e.image(t),br.map[t.url]=s),s.use++,s},recycle(t){t.use--,setTimeout((()=>{t.use||br.recycledList.push(t)}))},clearRecycled(){const t=br.recycledList;t.length&&(t.forEach((t=>{!t.use&&t.url&&(delete br.map[t.url],t.destroy())})),t.length=0)},destroy(){br.map={}}},br=wr,{IMAGE:Cr,create:Tr}=s;class Or{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 Pr extends Or{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}Pr.ADD="child.add",Pr.REMOVE="child.remove";class Br extends Or{constructor(t,e,s,r,i){super(t,e),this.attrName=s,this.oldValue=r,this.newValue=i}}Br.CHANGE="property.change";class kr extends Or{constructor(t,e){super(t),Object.assign(this,e)}}kr.LOAD="image.load",kr.LOADED="image.loaded",kr.ERROR="image.error";class Dr extends Or{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){"object"==typeof t?(super(Dr.RESIZE),Object.assign(this,t)):super(t),this.old=e}}Dr.RESIZE="resize";class Rr extends Or{constructor(t,e){super(t),e&&Object.assign(this,e)}}Rr.START="transform.start",Rr.CHANGE="transform.change",Rr.END="transform.end",Rr.BEFORE_START="transform.before_start",Rr.BEFORE_CHANGE="transform.before_change",Rr.BEFORE_END="transform.before_end";class Lr extends Or{constructor(t,e){super(t),this.data=e}}Lr.REQUEST="watch.request",Lr.DATA="watch.data";class Mr extends Or{constructor(t,e,s){super(t),e&&(this.data=e,this.times=s)}}Mr.CHECK_UPDATE="layout.check_update",Mr.REQUEST="layout.request",Mr.START="layout.start",Mr.BEFORE="layout.before",Mr.LAYOUT="layout.layout",Mr.AFTER="layout.after",Mr.AGAIN="layout.again",Mr.END="layout.end";class Sr extends Or{}Sr.FRAME="animate.frame";class Ir extends Or{constructor(t,e,s,r){super(t),e&&(this.times=e),s&&(this.renderBounds=s,this.renderOptions=r)}}Ir.REQUEST="render.request",Ir.START="render.start",Ir.BEFORE="render.before",Ir.RENDER="render",Ir.AFTER="render.after",Ir.AGAIN="render.again",Ir.END="render.end";class Ar extends Or{}Ar.START="leafer.start",Ar.BEFORE_READY="leafer.before_ready",Ar.READY="leafer.ready",Ar.AFTER_READY="leafer.after_ready",Ar.VIEW_READY="leafer.view_ready",Ar.VIEW_COMPLETED="leafer.view_completed",Ar.STOP="leafer.stop",Ar.RESTART="leafer.restart",Ar.END="leafer.end";const Wr={},Nr={isHoldSpaceKey:()=>Nr.isHold("Space"),isHold:t=>Wr[t],setDownCode(t){Wr[t]||(Wr[t]=!0)},setUpCode(t){Wr[t]=!1}},Xr={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Yr extends Or{get spaceKey(){return Nr.isHoldSpaceKey()}get left(){return Xr.left(this)}get right(){return Xr.right(this)}get middle(){return Xr.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}getInner(t){return t||(t=this.current),t.getInnerPoint(this)}getLocal(t){return t||(t=this.current),t.getLocalPoint(this)}static changeName(t,e){rt.changeName(t,e)}}function Hr(t,e,s){Object.defineProperty(t,e,s)}function jr(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Ur(t,e,s,r){const i={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)},configurable:!0,enumerable:!0};Hr(t,e,Object.assign(i,r||{})),Kr(t,e,s)}function zr(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__.around&&(this.__layout.positionChanged||this.__layout.positionChange())}})}}const Fr=zr;function Vr(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.strokeChanged||this.__layout.strokeChange()}})}}const Gr=Vr;function Kr(t,e,s){const r=t.__DataProcessor.prototype,i="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),n={get(){const t=this[i];return void 0===t?s:t},set(t){this[i]=t},configurable:!0,enumerable:!0};void 0===s?n.get=function(){return this[i]}:"width"===e?n.get=function(){const t=this[i];return void 0===t?this.__naturalWidth||s:t}:"height"===e&&(n.get=function(){const t=this[i];return void 0===t?this.__naturalHeight||s:t});const a=jr(r,e);a&&a.set&&(n.set=a.set),r[o]&&(n.set=r[o],delete r[o]),Object.defineProperty(r,e,n)}const Zr=new K("rewrite"),qr=[],Qr=["destroy","constructor"];function Jr(t){qr.length&&(qr.forEach((e=>{t&&Zr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),qr.length=0)}function $r(t,e){return s=>{var r;(t.prototype?(r=t.prototype,Object.getOwnPropertyNames(r)):Object.keys(t)).forEach((r=>{if(!(Qr.includes(r)||e&&e.includes(r)))if(t.prototype){jr(t.prototype,r).writable&&(s.prototype[r]=t.prototype[r])}else s.prototype[r]=t[r]}))}}function ti(){return t=>{rt.register(t)}}setTimeout((()=>Jr(!0))),exports.PointerEvent=class extends Yr{},exports.PointerEvent.POINTER="pointer",exports.PointerEvent.BEFORE_DOWN="pointer.before_down",exports.PointerEvent.BEFORE_MOVE="pointer.before_move",exports.PointerEvent.BEFORE_UP="pointer.before_up",exports.PointerEvent.DOWN="pointer.down",exports.PointerEvent.MOVE="pointer.move",exports.PointerEvent.UP="pointer.up",exports.PointerEvent.OVER="pointer.over",exports.PointerEvent.OUT="pointer.out",exports.PointerEvent.ENTER="pointer.enter",exports.PointerEvent.LEAVE="pointer.leave",exports.PointerEvent.TAP="tap",exports.PointerEvent.DOUBLE_TAP="double_tap",exports.PointerEvent.CLICK="click",exports.PointerEvent.DOUBLE_CLICK="double_click",exports.PointerEvent.LONG_PRESS="long_press",exports.PointerEvent.LONG_TAP="long_tap",exports.PointerEvent=ct([ti()],exports.PointerEvent);const ei={};var si;exports.DragEvent=class extends exports.PointerEvent{getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(ei,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(ei,null,!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}assignMove(t){ei.x=t?this.totalX:this.moveX,ei.y=t?this.totalY:this.moveY}},exports.DragEvent.BEFORE_DRAG="drag.before_drag",exports.DragEvent.START="drag.start",exports.DragEvent.DRAG="drag",exports.DragEvent.END="drag.end",exports.DragEvent.OVER="drag.over",exports.DragEvent.OUT="drag.out",exports.DragEvent.ENTER="drag.enter",exports.DragEvent.LEAVE="drag.leave",exports.DragEvent=ct([ti()],exports.DragEvent),exports.DropEvent=si=class extends exports.PointerEvent{static setList(t){si.dragList=t instanceof nt?t:new nt(t)}static setData(t){this.dragData=t}},exports.DropEvent.DROP="drop",exports.DropEvent=si=ct([ti()],exports.DropEvent),exports.MoveEvent=class extends exports.DragEvent{},exports.MoveEvent.BEFORE_MOVE="move.before_move",exports.MoveEvent.START="move.start",exports.MoveEvent.MOVE="move",exports.MoveEvent.END="move.end",exports.MoveEvent=ct([ti()],exports.MoveEvent),exports.RotateEvent=class extends Yr{},exports.RotateEvent.BEFORE_ROTATE="rotate.before_rotate",exports.RotateEvent.START="rotate.start",exports.RotateEvent.ROTATE="rotate",exports.RotateEvent.END="rotate.end",exports.RotateEvent=ct([ti()],exports.RotateEvent),exports.SwipeEvent=class extends exports.DragEvent{},exports.SwipeEvent.SWIPE="swipe",exports.SwipeEvent.LEFT="swipe.left",exports.SwipeEvent.RIGHT="swipe.right",exports.SwipeEvent.UP="swipe.up",exports.SwipeEvent.DOWN="swipe.down",exports.SwipeEvent=ct([ti()],exports.SwipeEvent),exports.ZoomEvent=class extends Yr{},exports.ZoomEvent.BEFORE_ZOOM="zoom.before_zoom",exports.ZoomEvent.START="zoom.start",exports.ZoomEvent.ZOOM="zoom",exports.ZoomEvent.END="zoom.end",exports.ZoomEvent=ct([ti()],exports.ZoomEvent),exports.KeyEvent=class extends Yr{},exports.KeyEvent.DOWN="key.down",exports.KeyEvent.HOLD="key.hold",exports.KeyEvent.UP="key.up",exports.KeyEvent=ct([ti()],exports.KeyEvent);class ri{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(exports.MoveEvent.START,this.moveData)}t.path=this.moveData.path,e.emit(exports.MoveEvent.BEFORE_MOVE,t),e.emit(exports.MoveEvent.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(exports.ZoomEvent.START,this.zoomData)}t.path=this.zoomData.path,e.emit(exports.ZoomEvent.BEFORE_ZOOM,t),e.emit(exports.ZoomEvent.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(exports.RotateEvent.START,this.rotateData)}t.path=this.rotateData.path,e.emit(exports.RotateEvent.BEFORE_ROTATE,t),e.emit(exports.RotateEvent.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(exports.MoveEvent.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(exports.ZoomEvent.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(exports.RotateEvent.END,this.rotateData),this.rotateData=null)}destroy(){this.zoomData=this.moveData=this.rotateData=null}}const{copy:ii,translate:oi,toInnerPoint:ni,scaleOfOuter:ai,rotateOfOuter:hi,skewOfOuter:li}=f,di={},ci={updateAllWorldMatrix(t){if(t.__updateWorldMatrix(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)pi(e[t])}},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)_i(e[t])}},updateAllChange(t){if(_i(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)gi(e[t])}},worldHittable(t){if(!t.__.hittable)return!1;let{parent:e}=t;for(;e;){if(!e.__.hittable||!e.__.hitChildren)return!1;e=e.parent}return!0},moveWorld(t,e,s){t.__layout.checkUpdate();const r={x:e,y:s};t.parent&&ni(t.parent.__world,r,r,!0),ui.moveLocal(t,r.x,r.y)},moveLocal(t,e,s=0){t.x+=e,t.y+=s},zoomOfWorld(t,e,s,r,i){t.__layout.checkUpdate();const o=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.zoomOfLocal(t,o,s,r,i)},zoomOfLocal(t,e,s,r=s,i){ii(di,t.__local),i&&oi(di,i.x,i.y),ai(di,e,s,r),i||(i=t),i.x+=di.e-t.__local.e,i.y+=di.f-t.__local.f,t.scaleX*=s,t.scaleY*=r},rotateOfWorld(t,e,s,r){t.__layout.checkUpdate();const i=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.rotateOfLocal(t,i,s,r)},rotateOfLocal(t,e,s,r){ii(di,t.__local),r&&oi(di,r.x,r.y),hi(di,e,s),r||(r=t),r.x+=di.e-t.__local.e,r.y+=di.f-t.__local.f,t.rotation=i.formatRotation(t.rotation+s)},skewOfWorld(t,e,s,r,i){t.__layout.checkUpdate();const o=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.skewOfLocal(t,o,s,r,i)},skewOfLocal(t,e,s,r,o){ii(di,t.__local),o&&oi(di,o.x,o.y),li(di,e,s,r),o||(o=t),o.x=di.e-t.__local.e,o.y=di.f-t.__local.f,t.skewX=i.formatSkew(t.skewX+s),t.skewY=i.formatSkew(t.skewY+r)},drop(t,e){const s={x:t.x,y:t.y};t.localToWorld(s),e.worldToInner(s),t.set(s),e.add(t)}},ui=ci,{updateAllWorldMatrix:pi,updateAllWorldOpacity:_i,updateAllChange:gi}=ui,fi={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.isEraser?null:t.__local,localEventBounds:t=>t.__.isEraser?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.isEraser?null: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},mi={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:s}=t;for(let r=0,i=s.length;r<i;r++)(t=s[r]).isBranch&&(t.__tempNumber=1,e.push(t),yi(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:r}=t;for(let t=0,s=r.length;t<s;t++)r[t].isBranch&&e.push(r[t]);for(let t=s,r=e.length;t<r;t++)xi(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:yi,pushAllBranchStack:xi}=mi,vi={run(t){for(let e=0,s=t.length;e<s;e++)t[e]();t.length=0}},Ei={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?exports.SwipeEvent.UP:t>45&&t<135?exports.SwipeEvent.DOWN:t<=45&&t>=-45?exports.SwipeEvent.RIGHT:exports.SwipeEvent.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:wi.getSwipeDirection(T.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,r=s.length;t<r;t++)if(s[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const s=new nt,{list:r}=t;for(let t=0,i=r.length;t<i;t++)r[t].hasEvent(e)&&s.push(r[t]);return s}},wi=Ei,{getDragEventData:bi,getDropEventData:Ci,getSwipeEventData:Ti,filterPathByEventType:Oi}=Ei;class Pi{constructor(t){this.interaction=t}setDragData(t){this.dragData=bi(t,t,t)}getDragList(){return this.dragging?exports.DropEvent.dragList||this.dragList:null}checkDrag(t,e){const{interaction:s}=this,{downData:r}=s;if(this.moving&&!Xr.middle(t)&&!Xr.left(t))return void s.pointerCancel();const{dragData:i}=this;if(!this.moving){const o=s.config.move.dragEmpty&&r.target.isLeafer;this.moving=(Xr.middle(t)||s.moveMode||o)&&e,this.moving&&s.emit(exports.MoveEvent.START,i)}this.moving||this.dragStart(t,e);const{path:o,throughPath:n}=r;this.dragData=bi(r,i,t),n&&(this.dragData.throughPath=n),this.dragData.path=o,this.moving?(s.emit(exports.MoveEvent.BEFORE_MOVE,this.dragData),s.emit(exports.MoveEvent.MOVE,this.dragData)):this.dragging&&(this.dragDragableList(),s.emit(exports.DragEvent.BEFORE_DRAG,this.dragData),s.emit(exports.DragEvent.DRAG,this.dragData))}dragStart(t,e){this.dragging||(this.dragging=Xr.left(t)&&e,this.dragging&&(this.interaction.emit(exports.DragEvent.START,this.dragData),this.getDragableList(this.dragData.path),this.dragList=Oi(this.dragData.path,exports.DragEvent.DRAG),!this.dragList.length&&this.dragableList&&this.dragList.pushList(this.dragableList)))}getDragableList(t){let e;for(let s=0,r=t.length;s<r;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=>{ci.moveWorld(s,t,e)}))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:s}=this,{path:r}=t;s?r.indexAt(0)!==s.indexAt(0)&&(e.emit(exports.DragEvent.OUT,t,s),e.emit(exports.DragEvent.OVER,t,r)):e.emit(exports.DragEvent.OVER,t,r),this.dragOverPath=r}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:s}=this,{path:r}=t;e.emit(exports.DragEvent.LEAVE,t,s,r),e.emit(exports.DragEvent.ENTER,t,r,s),this.dragEnterPath=r}dragEnd(t){const{interaction:e}=this,{downData:s}=e;if(!s)return;const{path:r,throughPath:i}=s,o=bi(s,t,t);i&&(o.throughPath=i),o.path=r,this.moving&&e.emit(exports.MoveEvent.END,o),this.dragging&&(e.emit(exports.DragEvent.END,o),this.swipe(t,o),this.drop(t)),this.autoMoveCancel(),this.dragReset()}swipe(t,e){const{interaction:s}=this,{downData:r}=s;if(T.getDistance(r,t)>s.config.pointer.swipeDistance){const t=Ti(r,this.dragData,e);this.interaction.emit(t.type,t)}}drop(t){const e=Ci(t,this.getDragList(),exports.DropEvent.dragData);e.path=this.dragEnterPath,this.interaction.emit(exports.DropEvent.DROP,e),this.interaction.emit(exports.DragEvent.LEAVE,t,this.dragEnterPath)}dragReset(){exports.DropEvent.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,{autoDistance:r,dragOut:i}=e.config.move;if(!i||!r)return;const o=e.shrinkCanvasBounds,{x:n,y:a}=o,h=j.right(o),l=j.bottom(o),d=t.x<n?r:h<t.x?-r:0,c=t.y<a?r:l<t.y?-r:0;let u=0,p=0;this.autoMoveTimer=setInterval((()=>{u+=d,p+=c,T.move(s,d,c),T.move(this.dragData,d,c),e.move(Object.assign(Object.assign({},t),{moveX:d,moveY:c,totalX:u,totalY:p})),e.pointerMoveReal(t)}),10)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.dragReset()}}const Bi=["move","zoom","rotate","key"];function ki(t,e,s,r,i){if(Bi.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!Ri(t,i)){let o;for(let n=0,a=t.children.length;n<a;n++)o=t.children[n],!s.path.has(o)&&o.__.hittable&&Di(o,e,s,r,i)}}function Di(t,e,s,r,i){if(t.destroyed)return!0;if(t.__.hitSelf&&t.hasEvent(e,r)&&!Ri(t,i)){s.phase=r?1:t===s.target?2:3;const i=rt.get(e,s);if(t.emitEvent(i,r),i.isStop)return!0}return!1}function Ri(t,e){return e&&e.has(t)}const Li={getData(t){const e=t[0],s=t[1],r=T.getCenter(e.from,s.from),i=T.getCenter(e.to,s.to),o={x:i.x-r.x,y:i.y-r.y},n=T.getDistance(e.from,s.from);return{move:o,scale:T.getDistance(e.to,s.to)/n,angle:T.getChangeAngle(e.from,s.from,e.to,s.to),center:i}}},{pathHasEventType:Mi,getMoveEventData:Si,getZoomEventData:Ii,getRotateEventData:Ai}=Ei;class Wi{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Wi.custom={};const{toOuterOf:Ni}=j;class Xi{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.boxChange(),this.positionChange()}checkUpdate(e){const{leafer:s}=this.leaf;if(s)s.ready?(t.realtimeLayout||e)&&s.watcher.changed&&s.layouter.layout():s.start();else{let e=this.leaf;for(;e.parent;)e=e.parent;t.layout(e)}}getTransform(t){return this.checkUpdate(),"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={}),Ni(this.contentBounds,this.leaf.__world,this._worldContentBounds),this._worldContentBounds}getWorldBoxBounds(){return this._worldBoxBounds||(this._worldBoxBounds={}),Ni(this.boxBounds,this.leaf.__world,this._worldBoxBounds),this._worldBoxBounds}getWorldStrokeBounds(){return this._worldStrokeBounds||(this._worldStrokeBounds={}),Ni(this.strokeBounds,this.leaf.__world,this._worldStrokeBounds),this._worldStrokeBounds}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this.strokeBounds=this.boxBounds,this.localStrokeBounds=this.leaf.__local,t&&this.spreadRenderCancel()}spreadRenderCancel(){this.renderBounds=this.strokeBounds,this.localRenderBounds=this.localStrokeBounds}spreadStroke(){const{x:t,y:e,width:s,height:r}=this.strokeBounds;this.strokeBounds={x:t,y:e,width:s,height:r},this.localStrokeBounds={x:t,y:e,width:s,height:r},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:s,height:r}=this.renderBounds;this.renderBounds={x:t,y:e,width:s,height:r},this.localRenderBounds={x:t,y:e,width:s,height:r}}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}positionChange(){this.positionChanged=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}const Yi={},Hi={on(t,e,s){let r,i,o;s&&("boolean"==typeof s?r=s:(r=s.capture,i=s.once));const n=ji(this,r,!0),a="string"==typeof t?t.split(" "):t,h=i?{listener:e,once:i}:{listener:e};a.forEach((t=>{t&&(o=n[t],o?-1===o.findIndex((t=>t.listener===e))&&o.push(h):n[t]=[h])}))},off(t,e,s){let r,i,o;s&&(r="boolean"==typeof s?s:s.capture);const n=ji(this,r);("string"==typeof t?t.split(" "):t).forEach((t=>{t&&(i=n[t],i&&(o=i.findIndex((t=>t.listener===e)),o>-1&&i.splice(o,1),i.length||delete n[t]))}))},on_(t,e,s,r){return s&&(e=e.bind(s)),this.on(t,e,r),{type:t,listener:e,options:r}},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){!e&&rt.has(t)&&(e=rt.get(t,{type:t,target:this,current:this}));const r=ji(this,s)[t];if(r){let i;for(let o=0,n=r.length;o<n&&(i=r[o],i.listener(e),i.once&&(this.off(t,i.listener,s),o--,n--),!e||!e.isStopNow);o++);}},emitEvent(t,e){t.current=this,this.emit(t.type,t,e)},hasEvent(t,e){const{__bubbleMap:s,__captureMap:r}=this;return void 0===e?!!(r&&r[t]||s&&s[t]):!!(e?r&&r[t]:s&&s[t])}};function ji(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:Yi)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:Yi)}}const Ui={__setAttr(t,e){if(this.leafer&&this.leafer.created){if("object"==typeof e||this.__.__getInput(t)!==e){this.__[t]=e;const{CHANGE:s}=Br,r=new Br(s,this,t,this.__.__get(t),e);this.hasEvent(s)&&!this.isLeafer&&this.emitEvent(r),this.leafer.emitEvent(r)}}else this.__[t]=e},__getAttr(t){return this.__.__get(t)}},{sin:zi,cos:Fi}=Math,Vi=Object.assign(Object.assign({},f.defaultMatrix),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0}),Gi={x:.5,y:.5},Ki={__updateWorldMatrix(){const t=this.parent?this.parent.__world:Vi,e=this.__local,s=this.__world;if(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;const r=this.__;s.scaleX=t.scaleX*r.scaleX,s.scaleY=t.scaleY*r.scaleY,s.rotation=t.rotation+r.rotation,s.skewX=t.skewX+r.skewX,s.skewY=t.skewY+r.skewY}else 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,s.scaleX=t.scaleX,s.scaleY=t.scaleY,s.rotation=t.rotation,s.skewX=t.skewX,s.skewY=t.skewY},__updateLocalMatrix(){const t=this.__local,e=this.__layout;if(e.affectScaleOrRotation){const{scaleX:s,scaleY:r}=this.__;if(e.affectRotation){if(e.scaleChanged||e.rotationChanged){let{rotation:i,skewX:n,skewY:a}=this.__;i||n||a?(i*=o,n&&(n*=o),a&&(a*=o),t.a=s*Fi(i+a),t.b=s*zi(i+a),t.c=r*-zi(i-n),t.d=r*Fi(i-n)):(t.a=s,t.b=0,t.c=0,t.d=r,e.affectRotation=!1),e.scaleChanged=!1,e.rotationChanged=!1}}else e.scaleChanged&&(t.a=s,t.d=r,e.scaleChanged=!1)}if(e.positionChanged){t.e=this.__.x,t.f=this.__.y;const{width:s,height:r,around:i}=this.__;if(i&&s&&r){const e="center"===i?Gi:i,o=s*e.x,n=r*e.y;t.e-=o*t.a+n*t.c,t.f-=o*t.b+n*t.d}e.positionChanged=!1}this.__layout.matrixChanged=!1}},{toOuterOf:Zi,copyAndSpread:qi}=j,Qi={__updateWorldBounds(){var t;if(this.__layout.boundsChanged){let e;const s=this.__layout;s.boxChanged&&(this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),s.boxChanged=!1,e=!0),s.localBoxChanged&&(this.__updateLocalBoxBounds(),s.localBoxChanged=!1,s.strokeSpread&&(s.strokeChanged=!0),s.renderSpread&&(s.renderChanged=!0),null===(t=this.parent)||void 0===t||t.__layout.boxChange()),s.strokeChanged&&(s.strokeSpread=this.__updateStrokeSpread(),s.strokeSpread?(s.strokeBounds===s.boxBounds&&s.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):s.spreadStrokeCancel(),s.strokeChanged=!1,s.renderSpread&&(s.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),e||(e=!0)),s.renderChanged&&(s.renderSpread=this.__updateRenderSpread(),s.renderSpread?(s.renderBounds!==s.boxBounds&&s.renderBounds!==s.strokeBounds||s.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):s.spreadRenderCancel(),s.renderChanged=!1,this.parent&&this.parent.__layout.renderChange()),s.boundsChanged=!1,Zi(this.__layout.renderBounds,this.__world,this.__world),e&&this.__onUpdateSize()}else Zi(this.__layout.renderBounds,this.__world,this.__world)},__updateLocalBoxBounds(){Zi(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Zi(this.__layout.strokeBounds,this.__local,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Zi(this.__layout.renderBounds,this.__local,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,{width:e,height:s}=this.__;t.x=0,t.y=0,t.width=e,t.height=s},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height,this.around&&(e.positionChanged=e.matrixChanged=!0,this.__updateWorldMatrix())},__updateStrokeBounds(){qi(this.__layout.strokeBounds,this.__layout.boxBounds,this.__layout.strokeSpread)},__updateRenderBounds(){qi(this.__layout.renderBounds,this.__layout.strokeBounds,this.__layout.renderSpread)}},{toInnerRadiusPointOf:Ji,copy:$i,setRadius:to}=T,eo={},so={__hitWorld(t){return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.hitCanvasChanged=!1),this.__.hitRadius&&($i(eo,t),to(t=eo,this.__.hitRadius)),Ji(t,this.__world,eo),this.__hit(eo)},__drawHitPath(t){this.__drawRenderPath(t)}},ro={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__world,e.matrix),t.opacity=this.__worldOpacity,this.__.__single){const s=t.getSameCanvas(!0);this.__draw(s,e);const r=this.__.isEraser?"destination-out":this.__.blendMode;e.matrix||this.__hasMirror?t.copyWorldByReset(s,null,null,r):t.copyWorldToInner(s,this.__world,this.__layout.renderBounds,r),s.recycle()}else 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)}},io={__updateEraser(t){this.__hasEraser=!!t||this.children.some((t=>t.__.isEraser))},__updateMask(t){this.__hasMask=!!t||this.children.some((t=>t.__.isMask))},__renderMask(t,e,s){e.resetTransform(),e.useMask(s),t.resetTransform(),t.opacity=this.__worldOpacity,t.copyWorld(e)},__removeMask(t){if(t)t.isMask=!1,this.remove(t);else{const{children:e}=this;for(let s=0,r=e.length;s<r;s++)(t=e[s]).isMask&&(this.__removeMask(t),r--,s--)}}},oo={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__worldOpacity)if(this.__.__single){t.resetTransform();const s=t.getSameCanvas();this.__renderBranch(s,e),t.opacity=this.__worldOpacity;const r=this.__.isEraser?"destination-out":this.__.blendMode;e.matrix?t.copyWorld(s,null,null,r):t.copyWorld(s,this.__world,this.__world,r),s.recycle()}else this.__renderBranch(t,e)},__renderBranch(t,e){let s;const{children:r}=this;if(this.__hasMask&&r.length>1){let i,o=t.getSameCanvas(),n=t.getSameCanvas();for(let a=0,h=r.length;a<h;a++)s=r[a],s.isMask?(i?(this.__renderMask(t,n,o),o.clear(),n.clear()):i=!0,s.__render(o,e)):s.__render(n,e);this.__renderMask(t,n,o),o.recycle(),n.recycle()}else{const{bounds:i,hideBounds:o}=e;for(let n=0,a=r.length;n<a;n++)s=r[n],i&&!i.hit(s.__world,e.matrix)||o&&o.includes(s.__world,e.matrix)||s.__render(t,e)}}},{LEAF:no,create:ao}=s,{toInnerPoint:ho,toOuterPoint:lo}=f,{tempToOuterOf:co,copy:uo}=T,{moveLocal:po,zoomOfLocal:_o,rotateOfLocal:go,skewOfLocal:fo}=ci;exports.Leaf=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return lt}get __LayoutProcessor(){return Xi}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get boxBounds(){return this.getBounds("box","inner")}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 resizeable(){return!0}get __hasMirror(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}constructor(t){this.innerId=ao(no),this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0},this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0},this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),t&&(t.children?this.set(t):Object.assign(this,t))}waitParent(t){this.parent?t():this.__parentWait?this.__parentWait.push(t):this.__parentWait=[t]}waitLeafer(t){this.leafer?t():this.__leaferWait?this.__leaferWait.push(t):this.__leaferWait=[t]}nextRender(t){this.leafer?this.leafer.nextRender(t):this.waitLeafer((()=>this.leafer.nextRender(t)))}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer=t,t&&(this.__level=this.parent?this.parent.__level+1:1,this.__leaferWait&&vi.run(this.__leaferWait)),this.isBranch){const{children:e}=this;for(let s=0,r=e.length;s<r;s++)e[s].__bindLeafer(t)}}set(t){}toJSON(){return this.__.__getInputData()}toString(){return JSON.stringify(this.toJSON())}__setAttr(t,e){}__getAttr(t){}forceUpdate(t){void 0===t?t="scaleX":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){}__updateMask(t){}__renderMask(t,e,s){}__removeMask(t){}getWorld(t){return this.__layout.checkUpdate(),"x"===t?this.__world.e:"y"===t?this.__world.f:this.__world[t]}getBounds(t,e="world"){return this.__layout.getBounds(t,e)}worldToLocal(t,e,s,r){this.parent?this.parent.worldToInner(t,e,s,r):e&&uo(e,t)}localToWorld(t,e,s,r){this.parent?this.parent.innerToWorld(t,e,s,r):e&&uo(e,t)}worldToInner(t,e,s,r){r&&(r.innerToWorld(t,e,s),t=e||t),ho(this.worldTransform,t,e,s)}innerToWorld(t,e,s,r){lo(this.worldTransform,t,e,s),r&&r.worldToInner(e||t,null,s)}getInnerPoint(t,e,s,r){const i=r?t:{};return this.worldToInner(t,i,s,e),i}getInnerPointByLocal(t,e,s,r){return this.getInnerPoint(t,this.parent,s,r)}getLocalPoint(t,e,s,r){const i=r?t:{};return this.worldToLocal(t,i,s,e),i}getLocalPointByInner(t,e,s,r){return this.getWorldPoint(t,this.parent,s,r)}getWorldPoint(t,e,s,r){const i=r?t:{};return this.innerToWorld(t,i,s,e),i}getWorldPointByLocal(t,e,s,r){const i=r?t:{};return this.localToWorld(t,i,s,e),i}move(t,e){po(this,t,e)}scaleOf(t,e,s){_o(this,co(t,this.localTransform),e,s)}rotateOf(t,e){go(this,co(t,this.localTransform),e)}skewOf(t,e,s){fo(this,co(t,this.localTransform),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(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}on(t,e,s){}off(t,e,s){}on_(t,e,s,r){}off_(t){}once(t,e,s){}emit(t,e,s){}emitEvent(t,e){}hasEvent(t,e){return!1}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.removeAll(!0),this.__.destroy(),this.__layout.destroy(),this.__captureMap=this.__bubbleMap=this.__parentWait=this.__leaferWait=null,this.destroyed=!0)}},exports.Leaf=ct([$r(Ui),$r(Ki),$r(Qi),$r(so),$r(Hi),$r(ro)],exports.Leaf);const{setByListWithHandle:mo}=j,{sort:yo}=mi,{localBoxBounds:xo,localEventBounds:vo,localRenderBounds:Eo,maskLocalBoxBounds:wo,maskLocalEventBounds:bo,maskLocalRenderBounds:Co}=fi;exports.Branch=class extends exports.Leaf{constructor(){super(),this.isBranch=!0,this.children=[]}__updateStrokeSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(){mo(this.__layout.boxBounds,this.children,this.__hasMask?wo:xo)}__updateStrokeBounds(){mo(this.__layout.strokeBounds,this.children,this.__hasMask?bo:vo)}__updateRenderBounds(){mo(this.__layout.renderBounds,this.children,this.__hasMask?Co:Eo)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let s=0,r=e.length;s<r;s++)e[s].__tempNumber=s,e[s].__.zIndex&&(t=!0);e.sort(yo),this.__layout.affectChildrenSort=t}}add(t,e){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),t.__layout.boundsChanged||t.__layout.positionChange(),t.__parentWait&&vi.run(t.__parentWait),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Pr.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){t.forEach((t=>this.add(t)))}remove(t,e){if(t){const s=this.children.indexOf(t);s>-1&&(this.children.splice(s,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}else void 0===t&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach((e=>{this.__realRemoveChild(e),t&&e.destroy()})))}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Pr.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const s=new Pr(t,e,this);e.hasEvent(t)&&e.emitEvent(s),this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(s),this.leafer.emitEvent(s)}},exports.Branch=ct([$r(oo),$r(io)],exports.Branch);const To=K.get("plugin"),Oo={power:{},list:[],onLeafer(t){Oo.list.forEach((e=>{e.onLeafer&&e.onLeafer(t)}))}};exports.AnimateEvent=Sr,exports.AutoBounds=class{constructor(t,e,s,r,i,o){"object"==typeof t?this.copy(t):this.set(t,e,s,r,i,o)}set(t=0,e=0,s=0,r=0,i=0,o=0){this.top=t,this.right=e,this.bottom=s,this.left=r,this.width=i,this.height=o}copy(t){const{top:e,right:s,bottom:r,left:i,width:o,height:n}=t;this.set(e,s,r,i,o,n)}getBoundsFrom(t){const{top:e,right:s,bottom:r,left:i,width:o,height:n}=this;return new V(i,e,o||t.width-i-s,n||t.height-e-r)}},exports.BezierHelper=Zt,exports.Bounds=V,exports.BoundsHelper=j,exports.BranchHelper=mi,exports.BranchRender=oo,exports.CanvasManager=ot,exports.ChildEvent=Pr,exports.Creator=e,exports.Cursor=Wi,exports.DataHelper=at,exports.Debug=K,exports.EllipseHelper=ie,exports.Event=Or,exports.EventCreator=rt,exports.FileHelper=dt,exports.HitCanvasManager=class extends ot{constructor(){super(...arguments),this.pathTypeList=new nt,this.imageTypeList=new nt}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.length&&(t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset())}clear(){this.clearPathType(),this.clearImageType()}},exports.ImageEvent=kr,exports.ImageManager=wr,exports.IncrementId=s,exports.InteractionBase=class{get dragging(){return this.dragger.dragging}get moveMode(){return Nr.isHoldSpaceKey()&&this.config.move.holdSpaceKey||this.downData&&Xr.middle(this.downData)}get hitRadius(){return this.config.pointer.hitRadius}constructor(e,s,r,i){this.config={wheel:{zoomMode:!1,zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:"Windows"===t.os?{x:37.5,y:37.5}:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,through:!1,tapTime:120,longPressTime:800,transformTime:500,dragHover:!0,dragDistance:2,swipeDistance:20,ignoreMove:!1}},this.tapCount=0,this.downKeyMap={},this.target=e,this.canvas=s,this.selector=r,this.defaultPath=new nt(e),this.transformer=new ri(this),this.dragger=new Pi(this),i&&(this.config=at.default(i,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Xr.defaultLeft(t),this.emit(exports.PointerEvent.BEFORE_DOWN,t,this.defaultPath),this.updateDownData(t),e&&(t.path=this.defaultPath),this.emit(exports.PointerEvent.DOWN,t),this.downTime=Date.now(),this.dragger.setDragData(t),Xr.left(t)&&(this.tapWait(),this.longPressWait(t)),this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;this.downData&&Xr.defaultLeft(t);const e=this.canvas.bounds.hitPoint(t);(e||this.downData)&&(e&&!this.downData&&Xr.left(t)&&this.pointerDown(t,!0),this.pointerMoveReal(t),this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(exports.PointerEvent.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=T.getDistance(this.downData,t)>this.config.pointer.dragDistance;this.waitTap&&e&&this.pointerWaitCancel(),this.dragger.checkDrag(t,e)}this.dragger.moving||this.config.pointer.ignoreMove||(this.updateHoverData(t),this.emit(exports.PointerEvent.MOVE,t),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t),this.dragger.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t)),this.updateCursor(t))}pointerUp(t){t||(t=this.downData),this.downData&&(Xr.defaultLeft(t),this.emit(exports.PointerEvent.BEFORE_UP,t,this.defaultPath),this.findPath(t),this.emit(exports.PointerEvent.UP,t),this.emit(exports.PointerEvent.UP,this.downData,void 0,t.path),this.touchLeave(t),this.tap(t),this.dragger.dragEnd(t),this.downData=null,this.updateCursor(t))}pointerCancel(){this.pointerUp(this.dragger.dragData)}multiTouch(t,e){const{move:s,angle:r,scale:i,center:o}=Li.getData(e);this.rotate(Ai(o,r,t)),this.zoom(Ii(o,i,t)),this.move(Si(o,s,t))}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}keyDown(t){const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Nr.setDownCode(e),this.emit(exports.KeyEvent.HOLD,t,this.defaultPath),this.moveMode&&this.updateCursor()),this.emit(exports.KeyEvent.DOWN,t,this.defaultPath)}keyUp(t){const{code:e}=t;this.downKeyMap[e]=!1,Nr.setUpCode(e),this.emit(exports.KeyEvent.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}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(exports.PointerEvent.OUT,t,this.overPath),this.emit(exports.PointerEvent.OVER,t,e)):this.emit(exports.PointerEvent.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(exports.PointerEvent.LEAVE,t,this.enterPath,e),this.emit(exports.PointerEvent.ENTER,t,e,this.enterPath),this.enterPath=e}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(exports.PointerEvent.LEAVE,t),this.dragger.dragging&&this.emit(exports.DropEvent.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 r=Date.now()-this.downTime,i=[exports.PointerEvent.DOUBLE_TAP,exports.PointerEvent.DOUBLE_CLICK].some((e=>Mi(t.path,e)));r<e.tapTime+50&&i?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout((()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(t,e){const{hitRadius:s,through:r}=this.config.pointer,i=this.selector.getByPoint(t,s,e||{through:r});return i.throughPath&&(t.throughPath=i.throughPath),t.path=i.path,i.path}updateDownData(t){t||(t=this.downData),t&&(this.findPath(t),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getDragList(),name:exports.PointerEvent.MOVE}),this.hoverData=t)}updateCursor(t){if(t||(this.updateHoverData(),t=this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.moveMode)return this.setCursor(this.downData?"grabbing":"grab");if(!t||this.dragger.dragging)return;const e=t.path;let s;for(let t=0,r=e.length;t<r;t++)if(s=e.list[t],s.cursor){const{cursor:t}=s;return void this.setCursor("grab"===t&&this.downData?"grabbing":t)}this.setCursor("default")}setCursor(t){this.cursor=t,this.canvas.setCursor(t)}emitTap(t){this.emit(exports.PointerEvent.TAP,t),this.emit(exports.PointerEvent.CLICK,t)}emitDoubleTap(t){this.emit(exports.PointerEvent.DOUBLE_TAP,t),this.emit(exports.PointerEvent.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(exports.PointerEvent.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(exports.PointerEvent.LONG_TAP,t),Mi(t.path,exports.PointerEvent.LONG_TAP)&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new V(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Dr.RESIZE,this.__onResize,this)],t.once(Ar.READY,(()=>this.__onResize()))}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,s,r){this.running&&function(t,e,s,r){if(!s&&!e.path)return;let i;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(i=s.list[o],Di(i,t,e,!0,r))return;i.isApp&&ki(i,t,e,!0,r)}for(let o=0,n=s.length;o<n;o++)if(i=s.list[o],i.isApp&&ki(i,t,e,!1,r),Di(i,t,e,!1,r))return}(t,e,s,r)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}},exports.InteractionHelper=Ei,exports.Keyboard=Nr,exports.LayoutEvent=Mr,exports.LeafBounds=Qi,exports.LeafBoundsHelper=fi,exports.LeafData=lt,exports.LeafDataProxy=Ui,exports.LeafEventer=Hi,exports.LeafHelper=ci,exports.LeafHit=so,exports.LeafLayout=Xi,exports.LeafLevelList=class{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,r=e.length;s<r;s++)t(e[s])}))}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}},exports.LeafList=nt,exports.LeafMask=io,exports.LeafMatrix=Ki,exports.LeafRender=ro,exports.LeaferCanvasBase=class extends mt{get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,r){super(),this.worldTransform={},e||(e=xt),e.pixelRatio||(e.pixelRatio=t.devicePixelRatio),this.manager=r,this.innerId=s.create(s.CNAVAS);const{width:i,height:o,pixelRatio:n}=e;this.autoLayout=!i||!o,this.pixelRatio=n,this.config=e,this.init()}init(){}__createContext(){this.context=this.view.getContext("2d"),this.__bindContext()}toBlob(e,s){return new Promise((r=>{const i=this.getSaveCanvas(e);t.origin.canvasToBolb(i.view,e,s).then((t=>{i.recycle(),r(t)})).catch((t=>{vt.error(t),r(null)}))}))}toDataURL(e,s){const r=this.getSaveCanvas(e),i=t.origin.canvasToDataURL(r.view,e,s);return r.recycle(),i}saveAs(e,s){return new Promise((r=>{const i=this.getSaveCanvas(dt.fileType(e));t.origin.canvasSaveAs(i.view,e,s).then((()=>{i.recycle(),r(!0)})).catch((t=>{vt.error(t),r(!1)}))}))}getSaveCanvas(t){const{backgroundColor:e,bounds:s}=this,r=this.getSameCanvas();return["jpg","jpeg"].includes(t)&&r.fillWorld(s,"#FFFFFF"),e&&r.fillWorld(s,e),r.copyWorld(this),r}resize(t){if(this.isSameSize(t))return;let e;this.context&&!this.unreal&&this.width&&(e=this.getSameCanvas(),e.copyWorld(this)),at.copyAttrs(this,t,Et),this.bounds=new V(0,0,this.width,this.height),this.pixelRatio||(this.pixelRatio=1),this.unreal||(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&e&&(this.clearWorld(e.bounds),this.copyWorld(e),e.recycle())}updateViewSize(){}updateClientBounds(){}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e,s){const{pixelRatio:r}=this,i=this.worldTransform;if(e)if(s)this.setTransform(i.a=t.a*r,i.b=t.b*r,i.c=t.c*r,i.d=t.d*r,i.e=(t.e+e.e)*r,i.f=(t.f+e.f)*r);else{const{a:s,b:o,c:n,d:a,e:h,f:l}=e;this.setTransform(i.a=(t.a*s+t.b*n)*r,i.b=(t.a*o+t.b*a)*r,i.c=(t.c*s+t.d*n)*r,i.d=(t.c*o+t.d*a)*r,i.e=(t.e*s+t.f*n+h)*r,i.f=(t.e*o+t.f*a+l)*r)}else this.setTransform(i.a=t.a*r,i.b=t.b*r,i.c=t.c*r,i.d=t.d*r,i.e=t.e*r,i.f=t.f*r)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,s){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 e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)}hitStroke(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)}setWorldShadow(t,e,s,r){const{pixelRatio:i}=this;this.shadowOffsetX=t*i,this.shadowOffsetY=e*i,this.shadowBlur=s*i,this.shadowColor=r||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,s,r){if(r&&(this.blendMode=r),e){const{pixelRatio:r}=this;s||(s=e),this.drawImage(t.view,e.x*r,e.y*r,e.width*r,e.height*r,s.x*r,s.y*r,s.width*r,s.height*r)}else this.drawImage(t.view,0,0);r&&(this.blendMode="source-over")}copyWorldToInner(t,e,s,r){if(r&&(this.blendMode=r),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,j.tempToOuterOf(s,e)),this.restore();else{const{pixelRatio:r}=this;this.drawImage(t.view,e.x*r,e.y*r,e.width*r,e.height*r,s.x,s.y,s.width,s.height)}r&&(this.blendMode="source-over")}copyWorldByReset(t,e,s,r){this.resetTransform(),this.copyWorld(t,e,s,r),this.useWorldTransform()}useMask(t,e,s){this.copyWorld(t,e,s,"destination-in")}useEraser(t,e,s){this.copyWorld(t,e,s,"destination-out")}fillWorld(t,e,s){s&&(this.blendMode=s),this.fillStyle=e,yt.copy(t).scale(this.pixelRatio),this.fillRect(yt.x,yt.y,yt.width,yt.height),s&&(this.blendMode="source-over")}strokeWorld(t,e,s){s&&(this.blendMode=s),this.strokeStyle=e,yt.copy(t).scale(this.pixelRatio),this.strokeRect(yt.x,yt.y,yt.width,yt.height),s&&(this.blendMode="source-over")}clearWorld(t,e){yt.copy(t).scale(this.pixelRatio),e&&yt.ceil(),this.clearRect(yt.x,yt.y,yt.width,yt.height)}clipWorld(t,e){this.beginPath(),yt.copy(t).scale(this.pixelRatio),e&&yt.ceil(),this.rect(yt.x,yt.y,yt.width,yt.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:s,height:r,pixelRatio:i}=this,o={width:s,height:r,pixelRatio:i},n=this.manager?this.manager.get(o):e.canvas(o);return n.save(),t&&n.useWorldTransform(Object.assign({},this.worldTransform)),n}getBiggerCanvas(t,s){let{width:r,height:i,pixelRatio:o}=this;t&&(r+=t),s&&(i+=s);const n={width:r,height:i,pixelRatio:o},a=this.manager?this.manager.get(n):e.canvas(n);return a.save(),a}recycle(){this.recycled||(this.restore(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}},exports.LeaferEvent=Ar,exports.LeaferImage=class{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){this.use=0,this.waitComplete=[],this.innerId=Tr(Cr),this.config=t||{url:""};const{url:e}=t;e.startsWith("data:")?e.startsWith("data:image/svg")&&(this.isSVG=!0):e.includes(".svg")&&(this.isSVG=!0),"svg"===this.config.format&&(this.isSVG=!0)}load(e,s){return this.loading||(this.loading=!0,wr.tasker.add((()=>ut(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>{this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)})).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),this.waitComplete.push(e,s),this.waitComplete.length-2}unload(t,e){const s=this.waitComplete;if(e){const e=s[t+1];e&&e({type:"stop"})}s[t]=s[t+1]=void 0}onComplete(t){let e;this.waitComplete.forEach(((s,r)=>{e=r%2,s&&(t?e||s(this):e&&s(this.error))})),this.waitComplete.length=0,this.loading=!1}getCanvas(e,s,r,i){e||(e=this.width),s||(s=this.height);const o=t.origin.createCanvas(e,s),n=o.getContext("2d");return r&&(n.globalAlpha=r),n.drawImage(this.view,0,0,e,s),o}destroy(){this.config={url:""},this.waitComplete.length=0}},exports.MathHelper=i,exports.Matrix=B,exports.MatrixHelper=f,exports.MultiTouchHelper=Li,exports.NeedConvertToCanvasCommandMap=Ot,exports.OneRadian=o,exports.PI2=n,exports.PI_2=a,exports.PathBounds=fr,exports.PathCommandDataHelper=ns,exports.PathCommandMap=Ct,exports.PathConvert=je,exports.PathCorner=mr,exports.PathCreator=bs,exports.PathDrawer=Ns,exports.PathHelper=wt,exports.PathNumberCommandLengthMap=Dt,exports.PathNumberCommandMap=kt,exports.Platform=t,exports.PluginManager=Oo,exports.Point=P,exports.PointHelper=T,exports.PointerButton=Xr,exports.PropertyEvent=Br,exports.RectHelper=Rt,exports.RenderEvent=Ir,exports.ResizeEvent=Dr,exports.Run=Q,exports.StringNumberMap=G,exports.TaskItem=vr,exports.TaskProcessor=Er,exports.TransformEvent=Rr,exports.TwoPointBounds=class{constructor(t,e){k.setPoint(this,t,e)}addPoint(t,e){k.addPoint(this,t,e)}addBounds(t,e,s,r){k.addBounds(this,t,e,s,r)}add(t){k.add(this,t)}},exports.TwoPointBoundsHelper=k,exports.UICreator=tt,exports.UIEvent=Yr,exports.WaitHelper=vi,exports.WatchEvent=Lr,exports.affectRenderBoundsType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.renderChanged||this.__layout.renderChange()}})}},exports.affectStrokeBoundsType=Vr,exports.aliasType=function(t){return(e,s)=>{Hr(e,s,{get(){return this.__getAttr(t)},set(e){this.__setAttr(t,e)}})}},exports.boundsType=zr,exports.canvasPatch=function(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,s,r,i){yr(this,t,e,s,r,i)})}(t)},exports.canvasSizeAttrs=Et,exports.cursorType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.leafer&&this.leafer.updateCursor()}})}},exports.dataProcessor=function(t){return(e,s)=>{Hr(e,"__DataProcessor",{get:()=>t})}},exports.dataType=function(t){return(e,s)=>{Ur(e,s,t)}},exports.defineDataProcessor=Kr,exports.defineKey=Hr,exports.defineLeafAttr=Ur,exports.eraserType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.waitParent((()=>{this.parent.__updateEraser(t)}))}})}},exports.getDescriptor=jr,exports.hitType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),K.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor()}})}},exports.layoutProcessor=function(t){return(e,s)=>{Hr(e,"__LayoutProcessor",{get:()=>t})}},exports.maskType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(t)}))}})}},exports.opacityType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.opacityChanged||this.__layout.opacityChange()}})}},exports.pathType=Fr,exports.positionType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.positionChanged||this.__layout.positionChange()}})}},exports.registerUI=function(){return t=>{tt.register(t)}},exports.registerUIEvent=ti,exports.rewrite=function(t){return(e,s)=>{qr.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}},exports.rewriteAble=function(){return t=>{Jr()}},exports.rotationType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.rotationChanged||this.__layout.rotationChange()}})}},exports.scaleType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.scaleChanged||this.__layout.scaleChange()}})}},exports.setDefaultValue=function(t,e,s){Kr(t.prototype,e,s)},exports.sortType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()}))}})}},exports.strokeType=Gr,exports.surfaceType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange()}})}},exports.useModule=$r,exports.usePlugin=function(t,e){const s={},{power:r,list:i}=Oo;if(r||To.error("need add PluginManager.power = LeaferUI"),i.includes(t))To.warn("repeat run",t.name);else{i.push(t),t.import?t.import.forEach((t=>{r[t]?s[t]=r[t]:To.error(t+" non-existent")})):To.warn("no import");try{t.run(s,e)}catch(t){To.error(t)}}};
1
+ "use strict";const t={imageSuffix:"leaf"},e={},s={RUNTIME:"runtime",LEAF:"leaf",TASK:"task",CNAVAS:"canvas",IMAGE:"image",types:{},create(t){const{types:e}=r;return e[t]?e[t]++:(e[t]=1,0)}},r=s,i={within:(t,e,s)=>(t<e&&(t=e),t>s&&(t=s),t),fourNumber(t){let e,s,r,i;if(t instanceof Array)switch(t.length){case 4:return t;case 2:e=r=t[0],s=i=t[1];break;case 3:e=t[0],s=i=t[1],r=t[2];break;case 1:t=t[0];break;default:t=0}return void 0===e?[t,t,t,t]:[e,s,r,i]},formatRotation:(t,e)=>(t%=360,e?t<0&&(t+=360):(t>180&&(t-=360),t<-180&&(t+=360)),t),getGapRotation(t,e){if(e>1){const s=Math.abs(t%e);(s<1||s>e-1)&&(t=Math.round(t/e)*e)}return t},formatSkew:t=>i.within(t,-90,90)},o=Math.PI/180,n=2*Math.PI,a=Math.PI/2,{sin:h,cos:l,acos:d,atan:c,sqrt:u,PI:p}=Math,_={};function g(){return{a:1,b:0,c:0,d:1,e:0,f:0}}const f={defaultMatrix:{a:1,b:0,c:0,d:1,e:0,f:0},tempMatrix:{},set(t,e=1,s=0,r=0,i=1,o=0,n=0){t.a=e,t.b=s,t.c=r,t.d=i,t.e=o,t.f=n},get:g,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.b*=e,t.c*=s,t.d*=s},scaleOfOuter(t,e,s,r=s){m.toInnerPoint(t,e,_),m.scaleOfInner(t,_,s,r)},scaleOfInner(t,e,s,r=s){m.translateInner(t,e.x,e.y),m.scale(t,s,r),m.translateInner(t,-e.x,-e.y)},rotate(t,e){const s=l(e*=o),r=h(e),{a:i,b:n,c:a,d:d}=t;t.a=i*s-n*r,t.b=i*r+n*s,t.c=a*s-d*r,t.d=a*r+d*s},rotateOfOuter(t,e,s){m.toInnerPoint(t,e,_),m.rotateOfInner(t,_,s)},rotateOfInner(t,e,s){m.translateInner(t,e.x,e.y),m.rotate(t,s),m.translateInner(t,-e.x,-e.y)},skew(t,e,s){const{a:r,b:i,c:n,d:a}=t;s&&(s*=o,t.a=r+n*s,t.b=i+a*s),e&&(e*=o,t.c=n+r*e,t.d=a+i*e)},skewOfOuter(t,e,s,r){m.toInnerPoint(t,e,_),m.skewOfInner(t,_,s,r)},skewOfInner(t,e,s,r){m.translateInner(t,e.x,e.y),m.skew(t,s,r),m.translateInner(t,-e.x,-e.y)},multiply(t,e){const{a:s,b:r,c:i,d:o,e:n,f:a}=t;t.a=e.a*s+e.b*i,t.b=e.a*r+e.b*o,t.c=e.c*s+e.d*i,t.d=e.c*r+e.d*o,t.e=e.e*s+e.f*i+n,t.f=e.e*r+e.f*o+a},preMultiply(t,e){const{a:s,b:r,c:i,d:o,e:n,f:a}=t;1===e.a&&0===e.b&&0===e.c&&1===e.d||(t.a=s*e.a+r*e.c,t.b=s*e.b+r*e.d,t.c=i*e.a+o*e.c,t.d=i*e.b+o*e.d),t.e=n*e.a+a*e.c+e.e,t.f=n*e.b+a*e.d+e.f},divide(t,e){m.preMultiply(t,m.tempInvert(e))},tempInvert(t){const{tempMatrix:e}=m;return m.copy(e,t),m.invert(e),e},invert(t){const{a:e,b:s,c:r,d:i,e:o,f:n}=t,a=1/(e*i-s*r);t.a=i*a,t.b=-s*a,t.c=-r*a,t.d=e*a,t.e=-(o*i-n*r)*a,t.f=-(n*e-o*s)*a},toOuterPoint(t,e,s,r){const{x:i,y:o}=e;s||(s=e),s.x=i*t.a+o*t.c,s.y=i*t.b+o*t.d,r||(s.x+=t.e,s.y+=t.f)},toInnerPoint(t,e,s,r){const{x:i,y:o}=e,{a:n,b:a,c:h,d:l}=t,d=1/(n*l-a*h);if(s||(s=e),s.x=(i*l-o*h)*d,s.y=(o*n-i*a)*d,!r){const{e:e,f:r}=t;s.x-=(e*l-r*h)*d,s.y-=(r*n-e*a)*d}},decompose(t){const{a:e,b:s,c:r,d:i}=t;let n=e,a=i,h=0,l=0,_=0;if(s||r){const t=e*i-s*r,g=e*r+s*i;if(s){const r=e*e+s*s;n=u(r),a=t/n;const i=e/n;h=s>0?d(i):-d(i),l=c(g/r)/o}else{const e=r*r+i*i;a=u(e),n=t/a;const s=r/a;h=p/2-(i>0?d(-s):-d(s)),_=c(g/e)/o}h/=o}return{x:t.e,y:t.f,scaleX:n,scaleY:a,rotation:h,skewX:l,skewY:_}},reset(t){m.set(t)}},m=f,{toInnerPoint:y,toOuterPoint:x}=f,{sin:v,cos:E,abs:w,sqrt:b,atan2:C}=Math,T={defaultPoint:{x:0,y:0},tempPoint:{},tempRadiusPoint:{},set(t,e=0,s=0){t.x=e,t.y=s},setRadius(t,e,s){t.radiusX=e,t.radiusY=void 0===s?e:s},copy(t,e){t.x=e.x,t.y=e.y},move(t,e,s){t.x+=e,t.y+=s},rotate(t,e,s){s||(s=O.defaultPoint);const r=E(e*o),i=v(e*o),n=t.x-s.x,a=t.y-s.y;t.x=s.x+n*r-a*i,t.y=s.y+n*i+a*r},tempToInnerOf(t,e){const{tempPoint:s}=O;return O.copy(s,t),y(e,s,s),s},tempToOuterOf(t,e){const{tempPoint:s}=O;return O.copy(s,t),x(e,s,s),s},tempToInnerRadiusPointOf(t,e){const{tempRadiusPoint:s}=O;return O.copy(s,t),O.toInnerRadiusPointOf(t,e,s),s},toInnerRadiusPointOf(t,e,s){s||(s=t),y(e,t,s),s.radiusX=Math.abs(t.radiusX/e.scaleX),s.radiusY=Math.abs(t.radiusY/e.scaleY)},toInnerOf(t,e,s){y(e,t,s)},toOuterOf(t,e,s){x(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),r=w(e.y-t.y);return b(s*s+r*r)},getAngle:(t,e)=>O.getAtan2(t,e)/o,getChangeAngle(t,e,s,r){r||(r=e);let i=O.getAngle(t,e);const o=O.getAngle(s,r)-i;return o<-180?o+360:o},getAtan2:(t,e)=>C(e.y-t.y,e.x-t.x),getDistancePoint(t,e,s){const r=O.getAtan2(t,e);return{x:t.x+E(r)*s,y:t.y+v(r)*s}},reset(t){O.reset(t)}},O=T;class P{constructor(t,e){"object"==typeof t?T.copy(this,t):T.set(this,t,e)}set(t,e){T.set(this,t,e)}copy(t){return T.copy(this,t),this}clone(){return new P(this)}rotate(t,e){return T.rotate(this,t,e),this}toInnerOf(t,e){return T.toInnerOf(this,t,e),this}toOuterOf(t,e){return T.toOuterOf(this,t,e),this}getCenter(t){return T.getCenter(this,t)}getDistance(t){return T.getDistance(this,t)}getAngle(t){return T.getAngle(this,t)}getAtan2(t){return T.getAtan2(this,t)}reset(){T.reset(this)}}class B{constructor(t,e,s,r,i,o){"object"==typeof t?f.copy(this,t):f.set(this,t,e,s,r,i,o)}set(t,e,s,r,i,o){f.set(this,t,e,s,r,i,o)}copy(t){return f.copy(this,t),this}clone(){return new B(this)}translate(t,e){return f.translate(this,t,e),this}translateInner(t,e){return f.translateInner(this,t,e),this}scale(t,e){return f.scale(this,t,e),this}scaleOfOuter(t,e,s){return f.scaleOfOuter(this,t,e,s),this}scaleOfInner(t,e,s){return f.scaleOfInner(this,t,e,s),this}rotate(t){return f.rotate(this,t),this}rotateOfOuter(t,e){return f.rotateOfOuter(this,t,e),this}rotateOfInner(t,e){return f.rotateOfInner(this,t,e),this}skew(t,e){return f.skew(this,t,e),this}skewOfOuter(t,e,s){return f.skewOfOuter(this,t,e,s),this}skewOfInner(t,e,s){return f.skewOfInner(this,t,e,s),this}multiply(t){return f.multiply(this,t),this}preMultiply(t){return f.preMultiply(this,t),this}divide(t){return f.divide(this,t),this}invert(){return f.invert(this),this}toOuterPoint(t,e,s){f.toOuterPoint(this,t,e,s)}toInnerPoint(t,e,s){f.toInnerPoint(this,t,e,s)}decompose(){return f.decompose(this)}reset(){f.reset(this)}}const k={tempPointBounds:{},setPoint(t,e,s){t.minX=t.maxX=e,t.minY=t.maxY=s},addPoint(t,e,s){t.minX=e<t.minX?e:t.minX,t.minY=s<t.minY?s:t.minY,t.maxX=e>t.maxX?e:t.maxX,t.maxY=s>t.maxY?s:t.maxY},addBounds(t,e,s,r,i){D(t,e,s),D(t,e+r,s+i)},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:D}=k,{tempPointBounds:R,setPoint:L,addPoint:M,toBounds:S}=k,{toOuterPoint:I}=f;let A,W,N,X;const Y={},H={},j={tempBounds:{},set(t,e=0,s=0,r=0,i=0){t.x=e,t.y=s,t.width=r,t.height=i},copy(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},copyAndSpread(t,e,s,r){r||(r=s),U.set(t,e.x-s,e.y-r,e.width+2*s,e.height+2*r)},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),U.move(t,e,s),t),toOffsetOutBounds(t,e,s){e?F(e,t):e=t,s?(e.offsetX=-(U.right(s)-t.x),e.offsetY=-(U.bottom(s)-t.y)):(e.offsetX=t.x+t.width,e.offsetY=t.y+t.height),U.move(e,-e.offsetX,-e.offsetY)},scale(t,e,s){s||(s=e),t.x&&(t.x*=e),t.y&&(t.y*=s),t.width*=e,t.height*=s},tempToOuterOf:(t,e)=>(U.copy(U.tempBounds,t),U.toOuterOf(U.tempBounds,e),U.tempBounds),getOuterOf:(t,e)=>(t=Object.assign({},t),U.toOuterOf(t,e),t),toOuterOf(t,e,s){if(s||(s=t),0===e.b&&0===e.c){const{a:r,d:i}=e;r>0?(s.width=t.width*r,s.x=e.e+t.x*r):(s.width=t.width*-r,s.x=e.e+t.x*r-s.width),i>0?(s.height=t.height*i,s.y=e.f+t.y*i):(s.height=t.height*-i,s.y=e.f+t.y*i-s.height)}else Y.x=t.x,Y.y=t.y,I(e,Y,H),L(R,H.x,H.y),Y.x=t.x+t.width,I(e,Y,H),M(R,H.x,H.y),Y.y=t.y+t.height,I(e,Y,H),M(R,H.x,H.y),Y.x=t.x,I(e,Y,H),M(R,H.x,H.y),S(R,s)},getFitMatrix(t,e){const s=Math.min(1,Math.min(t.width/e.width,t.height/e.height));return new B(s,0,0,s,-Math.ceil(e.x*s),-Math.ceil(e.y*s))},getSpread(t,e,s){const r={};return U.copyAndSpread(r,t,e,s),r},spread(t,e,s){U.copyAndSpread(t,t,e,s)},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)},unsign(t){t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height)},add(t,e){A=t.x+t.width,W=t.y+t.height,N=e.x+e.width,X=e.y+e.height,A=A>N?A:N,W=W>X?W:X,t.x=t.x<e.x?t.x:e.x,t.y=t.y<e.y?t.y:e.y,t.width=A-t.x,t.height=W-t.y},addList(t,e){U.setByListWithHandle(t,e,void 0,!0)},setByList(t,e,s=!1){U.setByListWithHandle(t,e,void 0,s)},addListWithHandle(t,e,s){U.setByListWithHandle(t,e,s,!0)},setByListWithHandle(t,e,s,r=!1){let i,o=!0;for(let n=0,a=e.length;n<a;n++)i=s?s(e[n]):e[n],i&&(i.width||i.height)&&(o?(o=!1,r||F(t,i)):z(t,i));o&&U.reset(t)},setByPoints(t,e){e.forEach(((t,e)=>{0===e?L(R,t.x,t.y):M(R,t.x,t.y)})),S(R,t)},hitRadiusPoint:(t,e,s)=>(s&&(e=T.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=T.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=U.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=U.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=U.tempToOuterOf(e,s));let{x:r,y:i,width:o,height:n}=e;return A=r+o,W=i+n,N=t.x+t.width,X=t.y+t.height,r=r>t.x?r:t.x,i=i>t.y?i:t.y,A=A<N?A:N,W=W<X?W:X,o=A-r,n=W-i,{x:r,y:i,width:o,height:n}},intersect(t,e,s){U.copy(t,U.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){U.set(t)}},U=j,{add:z,copy:F}=U;class V{constructor(t,e,s,r){"object"==typeof t?j.copy(this,t):j.set(this,t,e,s,r)}set(t,e,s,r){j.set(this,t,e,s,r)}copy(t){return j.copy(this,t),this}clone(){return new V(this)}scale(t,e){return j.scale(this,t,e),this}toOuterOf(t,e){return j.toOuterOf(this,t,e),this}getFitMatrix(t){return j.getFitMatrix(this,t)}spread(t){return j.spread(this,t),this}ceil(){return j.ceil(this),this}unsign(){return j.unsign(this),this}add(t){return j.add(this,t),this}addList(t){return j.setByList(this,t,!0),this}setByList(t,e){return j.setByList(this,t,e),this}addListWithHandle(t,e){return j.setByListWithHandle(this,t,e,!0),this}setByListWithHandle(t,e,s){return j.setByListWithHandle(this,t,e,s),this}setByPoints(t){return j.setByPoints(this,t),this}hitPoint(t,e){return j.hitPoint(this,t,e)}hitRadiusPoint(t,e){return j.hitRadiusPoint(this,t,e)}hit(t,e){return j.hit(this,t,e)}includes(t,e){return j.includes(this,t,e)}intersect(t,e){return j.intersect(this,t,e),this}getIntersect(t,e){return new V(j.getIntersectData(this,t,e))}isSame(t){return j.isSame(this,t)}isEmpty(){return j.isEmpty(this)}reset(){j.reset(this)}}const G={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 K{constructor(t){this.repeatMap={},this.name=t}static get(t){return new K(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(Z.enable){if(Z.filterList.length&&Z.filterList.every((t=>t!==this.name)))return;if(Z.excludeList.length&&Z.excludeList.some((t=>t===this.name)))return;console.log("%c"+this.name,"color:#21ae62",...t)}}warn(...t){Z.enable&&console.warn(this.name,...t)}repeat(t,...e){this.repeatMap[t]||(this.warn("repeat:"+t,...e),this.repeatMap[t]=!0)}error(...t){try{throw new Error}catch(e){console.error(this.name,...t,e)}}}K.filterList=[],K.excludeList=[];const Z=K,q=K.get("RunTime");class Q{static start(t,e){const r=s.create(s.RUNTIME);return J.currentId=J.idMap[r]=e?performance.now():Date.now(),J.currentName=J.nameMap[r]=t,J.nameToIdMap[t]=r,r}static end(t,e){const s=J.idMap[t],r=J.nameMap[t];J.idMap[t]=J.nameMap[t]=J.nameToIdMap[r]=void 0,e?q.log(r,performance.now()-s,"µs"):q.log(r,Date.now()-s,"ms")}static endOfName(t,e){const s=J.nameToIdMap[t];void 0!==s&&J.end(s,e)}}Q.idMap={},Q.nameMap={},Q.nameToIdMap={};const J=Q,$=K.get("UICreator"),tt={list:{},register(t){const{__tag:e}=t.prototype;et[e]?$.repeat(e):et[e]=t},get(t,e,s,r,i,o){const n=new et[t](e);return void 0!==s&&(n.x=s,r&&(n.y=r),i&&(n.width=i),o&&(n.height=o)),n}},{list:et}=tt,st=K.get("EventCreator"),rt={nameList:{},register(t){let e;Object.keys(t).forEach((s=>{e=t[s],"string"==typeof e&&(it[e]?st.repeat(e):it[e]=t)}))},changeName(t,e){const s=it[t];if(s){const r=Object.keys(s).find((e=>s[e]===t));r&&(s[r]=e,it[e]=s)}},has(t){return!!this.nameList[t]},get:(t,...e)=>new it[t](...e)},{nameList:it}=rt;class ot{constructor(){this.list=[]}add(t){t.manager=this,this.list.push(t)}get(t){let s;const{list:r}=this;for(let e=0,i=r.length;e<i;e++)if(s=r[e],s.recycled&&s.isSameSize(t))return s.recycled=!1,s.manager||(s.manager=this),s;const i=e.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,r=this.list.length;s<r;s++)t=this.list[s],t.recycled?t.destroy():e.push(t);this.list=e}clear(){this.list.forEach((t=>{t.destroy()})),this.list.length=0}destroy(){this.clear()}}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 t&&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 r=0,i=e.length;r<i;r++)void 0!==s?this.keys[e[r].innerId]=r-1:e[r].innerId===t.innerId&&(s=r,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}}const at={default:(t,e)=>(ht(e,t),ht(t,e),t),assign(t,e){let s;Object.keys(e).forEach((r=>{var i;s=e[r],(null==s?void 0:s.constructor)===Object&&(null===(i=t[r])||void 0===i?void 0:i.constructor)===Object?ht(t[r],e[r]):t[r]=e[r]}))},copyAttrs:(t,e,s)=>(s.forEach((s=>{void 0!==e[s]&&(t[s]=e[s])})),t),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];if(void 0!==e)return 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];if(void 0!==e)return e}return this["_"+t]}__removeInput(t){this.__input&&void 0!==this.__input[t]&&(this.__input[t]=void 0)}__getInputData(){const t={tag:this.__leaf.tag},{__input:e}=this;let s,r;for(let i in this)s=i.substring(1),void 0!==this[s]&&(r=e?e[s]:void 0,t[s]=void 0===r?this[i]:r);return t}__setMiddle(t,e){this.__middle||(this.__middle={}),this.__middle[t]=e}__getMiddle(t){return this.__middle&&this.__middle[t]}__checkSingle(){"pass-through"===this.blendMode?this.__leaf.__hasEraser||this.isEraser?this.__single=!0:this.__single&&(this.__single=!1):this.__single=!0}destroy(){this.__input=this.__middle=null}}const dt={mineType:t=>!t||t.startsWith("image")?t:("jpg"===t&&(t="jpeg"),"image/"+t),fileType(t){const e=t.split(".");return e[e.length-1]}};function ct(t,e,s,r){var i,o=arguments.length,n=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,s,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(n=(o<3?i(n):o>3?i(e,s,n):i(e,s))||n);return o>3&&n&&Object.defineProperty(e,s,n),n}function ut(t,e,s,r){return new(s||(s=Promise))((function(i,o){function n(t){try{h(r.next(t))}catch(t){o(t)}}function a(t){try{h(r.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(n,a)}h((r=r.apply(t,e||[])).next())}))}function pt(t){return(e,s)=>{t||(t=s);const r={get(){return this.context[t]},set(e){this.context[t]=e}};Object.defineProperty(e,s,r)}}"function"==typeof SuppressedError&&SuppressedError;const _t=[];function gt(){return(t,e)=>{_t.push(e)}}const ft=[];class mt{set blendMode(t){"normal"===t&&(t="source-over"),this.context.globalCompositeOperation=t}get blendMode(){return this.context.globalCompositeOperation}set dashPattern(t){this.context.setLineDash(t||ft)}get dashPattern(){return this.context.getLineDash()}__bindContext(){let t;_t.forEach((e=>{t=this.context[e],t&&(this[e]=t.bind(this.context))})),this.textBaseline="alphabetic"}setTransform(t,e,s,r,i,o){}resetTransform(){}getTransform(){}save(){}restore(){}transform(t,e,s,r,i,o){"object"==typeof t?this.context.transform(t.a,t.b,t.c,t.d,t.e,t.f):this.context.transform(t,e,s,r,i,o)}translate(t,e){}scale(t,e){}rotate(t){}fill(t,e){}stroke(t){}clip(t,e){}fillRect(t,e,s,r){}strokeRect(t,e,s,r){}clearRect(t,e,s,r){}drawImage(t,e,s,r,i,o,n,a,h){switch(arguments.length){case 9:if(e<0){const t=-e/r*a;r+=e,e=0,o+=t,a-=t}if(s<0){const t=-s/i*h;i+=s,s=0,n+=t,h-=t}this.context.drawImage(t,e,s,r,i,o,n,a,h);break;case 5:this.context.drawImage(t,e,s,r,i);break;case 3:this.context.drawImage(t,e,s)}}beginPath(){}moveTo(t,e){}lineTo(t,e){}bezierCurveTo(t,e,s,r,i,o){}quadraticCurveTo(t,e,s,r){}closePath(){}arc(t,e,s,r,i,o){}arcTo(t,e,s,r,i){}ellipse(t,e,s,r,i,o,n,a){}rect(t,e,s,r){}roundRect(t,e,s,r,i){}createConicGradient(t,e,s){}createLinearGradient(t,e,s,r){}createPattern(t,e){}createRadialGradient(t,e,s,r,i,o){}fillText(t,e,s,r){}measureText(t){}strokeText(t,e,s,r){}destroy(){this.context=null}}ct([pt("imageSmoothingEnabled")],mt.prototype,"smooth",void 0),ct([pt("imageSmoothingQuality")],mt.prototype,"smoothLevel",void 0),ct([pt("globalAlpha")],mt.prototype,"opacity",void 0),ct([pt()],mt.prototype,"fillStyle",void 0),ct([pt()],mt.prototype,"strokeStyle",void 0),ct([pt("lineWidth")],mt.prototype,"strokeWidth",void 0),ct([pt("lineCap")],mt.prototype,"strokeCap",void 0),ct([pt("lineJoin")],mt.prototype,"strokeJoin",void 0),ct([pt("lineDashOffset")],mt.prototype,"dashOffset",void 0),ct([pt()],mt.prototype,"miterLimit",void 0),ct([pt()],mt.prototype,"shadowBlur",void 0),ct([pt()],mt.prototype,"shadowColor",void 0),ct([pt()],mt.prototype,"shadowOffsetX",void 0),ct([pt()],mt.prototype,"shadowOffsetY",void 0),ct([pt()],mt.prototype,"filter",void 0),ct([pt()],mt.prototype,"font",void 0),ct([pt()],mt.prototype,"fontKerning",void 0),ct([pt()],mt.prototype,"fontStretch",void 0),ct([pt()],mt.prototype,"fontVariantCaps",void 0),ct([pt()],mt.prototype,"textAlign",void 0),ct([pt()],mt.prototype,"textBaseline",void 0),ct([pt()],mt.prototype,"textRendering",void 0),ct([pt()],mt.prototype,"wordSpacing",void 0),ct([pt()],mt.prototype,"letterSpacing",void 0),ct([pt()],mt.prototype,"direction",void 0),ct([gt()],mt.prototype,"setTransform",null),ct([gt()],mt.prototype,"resetTransform",null),ct([gt()],mt.prototype,"getTransform",null),ct([gt()],mt.prototype,"save",null),ct([gt()],mt.prototype,"restore",null),ct([gt()],mt.prototype,"translate",null),ct([gt()],mt.prototype,"scale",null),ct([gt()],mt.prototype,"rotate",null),ct([gt()],mt.prototype,"fill",null),ct([gt()],mt.prototype,"stroke",null),ct([gt()],mt.prototype,"clip",null),ct([gt()],mt.prototype,"fillRect",null),ct([gt()],mt.prototype,"strokeRect",null),ct([gt()],mt.prototype,"clearRect",null),ct([gt()],mt.prototype,"beginPath",null),ct([gt()],mt.prototype,"moveTo",null),ct([gt()],mt.prototype,"lineTo",null),ct([gt()],mt.prototype,"bezierCurveTo",null),ct([gt()],mt.prototype,"quadraticCurveTo",null),ct([gt()],mt.prototype,"closePath",null),ct([gt()],mt.prototype,"arc",null),ct([gt()],mt.prototype,"arcTo",null),ct([gt()],mt.prototype,"ellipse",null),ct([gt()],mt.prototype,"rect",null),ct([gt()],mt.prototype,"roundRect",null),ct([gt()],mt.prototype,"createConicGradient",null),ct([gt()],mt.prototype,"createLinearGradient",null),ct([gt()],mt.prototype,"createPattern",null),ct([gt()],mt.prototype,"createRadialGradient",null),ct([gt()],mt.prototype,"fillText",null),ct([gt()],mt.prototype,"measureText",null),ct([gt()],mt.prototype,"strokeText",null);const yt=new V,xt={width:1,height:1,pixelRatio:1},vt=K.get("LeaferCanvasBase"),Et=["width","height","pixelRatio"];const wt={creator:{},parse(t,e){},convertToCanvasData(t,e){}},bt={N:21,D:22,X:23,G:24,F:25,O:26,P:27,U:28},Ct=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},bt),Tt={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},Ot={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},Pt=Object.assign(Object.assign({},Ot),bt),Bt=Ct,kt={};for(let t in Bt)kt[Bt[t]]=t;const Dt={};for(let t in Bt)Dt[Bt[t]]=Tt[t];const Rt={drawRoundRect(t,e,s,r,o,n){let[a,h,l,d]=i.fourNumber(n);const c=Math.min(r/2,o/2);a>c&&(a=c),h>c&&(h=c),l>c&&(l=c),d>c&&(d=c),a?t.moveTo(e+a,s):t.moveTo(e,s),h?t.arcTo(e+r,s,e+r,s+o,h):t.lineTo(e+r,s),l?t.arcTo(e+r,s+o,e,s+o,l):t.lineTo(e+r,s+o),d?t.arcTo(e,s+o,e,s,d):t.lineTo(e,s+o),a?t.arcTo(e,s,e+r,s,a):t.lineTo(e,s)}},{sin:Lt,cos:Mt,atan2:St,ceil:It,abs:At,PI:Wt,sqrt:Nt,pow:Xt}=Math,{setPoint:Yt,addPoint:Ht}=k,{set:jt}=T,{M:Ut,L:zt,C:Ft,Q:Vt,Z:Gt}=Ct,Kt={},Zt={points(t,e,s,r){if(t.push(Ut,e[0],e[1]),s&&e.length>5){let i,o,n,a,h,l,d,c,u,p,_,g,f,m=e.length;const y=!0===s?.5:s;r&&(m=(e=[e[m-2],e[m-1],...e,e[0],e[1],e[2],e[3]]).length);for(let s=2;s<m-2;s+=2)i=e[s-2],o=e[s-1],n=e[s],a=e[s+1],h=e[s+2],l=e[s+3],_=Nt(Xt(n-i,2)+Xt(a-o,2)),g=Nt(Xt(h-n,2)+Xt(l-a,2)),f=_+g,_=y*_/f,g=y*g/f,h-=i,l-=o,d=n-_*h,c=a-_*l,2===s?r||t.push(Vt,d,c,n,a):t.push(Ft,u,p,d,c,n,a),u=n+g*h,p=a+g*l;r||t.push(Vt,u,p,e[m-2],e[m-1])}else for(let s=2,r=e.length;s<r;s+=2)t.push(zt,e[s],e[s+1]);r&&t.push(Gt)},rect(t,e,s,r,i){wt.creator.path=t,wt.creator.moveTo(e,s).lineTo(e+r,s).lineTo(e+r,s+i).lineTo(e,s+i).lineTo(e,s)},roundRect(t,e,s,r,i,o){wt.creator.path=[],Rt.drawRoundRect(wt.creator,e,s,r,i,o),t.push(...wt.convertToCanvasData(wt.creator.path,!0))},arcTo(t,e,s,r,i,h,l,d,c,u,p){const _=r-e,g=i-s,f=h-r,m=l-i;let y=St(g,_),x=St(m,f),v=x-y;if(v<0&&(v+=n),v===Wt||At(_+g)<1e-12||At(f+m)<1e-12)return t&&t.push(zt,r,i),c&&(Yt(c,e,s),Ht(c,r,i)),p&&jt(p,e,s),void(u&&jt(u,r,i));const E=_*m-f*g<0,w=E?-1:1,b=d/Mt(v/2),C=r+b*Mt(y+v/2+a*w),T=i+b*Lt(y+v/2+a*w);return y-=a*w,x-=a*w,Jt(t,C,T,d,d,0,y/o,x/o,E,c,u,p)},arc:(t,e,s,r,i,o,n,a,h,l)=>Jt(t,e,s,r,r,0,i,o,n,a,h,l),ellipse(t,e,s,r,i,h,l,d,c,u,p,_){const g=h*o,f=Lt(g),m=Mt(g);let y=l*o,x=d*o;y>Wt&&(y-=n),x<0&&(x+=n);let v=x-y;v<0?v+=n:v>n&&(v-=n),c&&(v-=n);const E=It(At(v/a)),w=v/E,b=Lt(w/4),C=8/3*b*b/Lt(w/2);x=y+w;let T,O,P,B,k,D,R,L,M=Mt(y),S=Lt(y),I=P=m*r*M-f*i*S,A=B=f*r*M+m*i*S,W=e+P,N=s+B;t&&t.push(zt,W,N),u&&Yt(u,W,N),_&&jt(_,W,N);for(let o=0;o<E;o++)T=Mt(x),O=Lt(x),P=m*r*T-f*i*O,B=f*r*T+m*i*O,k=e+I-C*(m*r*S+f*i*M),D=s+A-C*(f*r*S-m*i*M),R=e+P+C*(m*r*O+f*i*T),L=s+B+C*(f*r*O-m*i*T),t&&t.push(Ft,k,D,R,L,e+P,s+B),u&&Qt(e+I,s+A,k,D,R,L,e+P,s+B,u,!0),I=P,A=B,M=T,S=O,y=x,x+=w;p&&jt(p,e+P,s+B)},quadraticCurveTo(t,e,s,r,i,o,n){t.push(Ft,(e+2*r)/3,(s+2*i)/3,(o+2*r)/3,(n+2*i)/3,o,n)},toTwoPointBoundsByQuadraticCurve(t,e,s,r,i,o,n,a){Qt(t,e,(t+2*s)/3,(e+2*r)/3,(i+2*s)/3,(o+2*r)/3,i,o,n,a)},toTwoPointBounds(t,e,s,r,i,o,n,a,h,l){const d=[];let c,u,p,_,g,f,m,y,x=t,v=s,E=i,w=n;for(let t=0;t<2;++t)if(1==t&&(x=e,v=r,E=o,w=a),c=-3*x+9*v-9*E+3*w,u=6*x-12*v+6*E,p=3*v-3*x,Math.abs(c)<1e-12){if(Math.abs(u)<1e-12)continue;_=-p/u,0<_&&_<1&&d.push(_)}else m=u*u-4*p*c,y=Math.sqrt(m),m<0||(g=(-u+y)/(2*c),0<g&&g<1&&d.push(g),f=(-u-y)/(2*c),0<f&&f<1&&d.push(f));l?Ht(h,t,e):Yt(h,t,e),Ht(h,n,a);for(let l=0,c=d.length;l<c;l++)qt(d[l],t,e,s,r,i,o,n,a,Kt),Ht(h,Kt.x,Kt.y)},getPointAndSet(t,e,s,r,i,o,n,a,h,l){const d=1-t,c=d*d*d,u=3*d*d*t,p=3*d*t*t,_=t*t*t;l.x=c*e+u*r+p*o+_*a,l.y=c*s+u*i+p*n+_*h},getPoint(t,e,s,r,i,o,n,a,h){const l={};return qt(t,e,s,r,i,o,n,a,h,l),l}},{getPointAndSet:qt,toTwoPointBounds:Qt,ellipse:Jt}=Zt,{sin:$t,cos:te,sqrt:ee,atan2:se}=Math,{ellipse:re}=Zt,ie={ellipticalArc(t,e,s,r,i,a,h,l,d,c,u){const p=(d-e)/2,_=(c-s)/2,g=a*o,f=$t(g),m=te(g),y=-m*p-f*_,x=-m*_+f*p,v=r*r,E=i*i,w=x*x,b=y*y,C=v*E-v*w-E*b;let T=0;if(C<0){const t=ee(1-C/(v*E));r*=t,i*=t}else T=(h===l?-1:1)*ee(C/(v*w+E*b));const O=T*r*x/i,P=-T*i*y/r,B=se((x-P)/i,(y-O)/r),k=se((-x-P)/i,(-y-O)/r);let D=k-B;0===l&&D>0?D-=n:1===l&&D<0&&(D+=n);const R=e+p+m*O-f*P,L=s+_+f*O+m*P,M=D<0?1:0;u?re(t,R,L,r,i,a,B/o,k/o,M):r!==i||a?t.push(Ct.G,R,L,r,i,a,B/o,k/o,M):t.push(Ct.O,R,L,r,B/o,k/o,M)}},{M:oe,m:ne,L:ae,l:he,H:le,h:de,V:ce,v:ue,C:pe,c:_e,S:ge,s:fe,Q:me,q:ye,T:xe,t:ve,A:Ee,a:we,Z:be,z:Ce,N:Te,D:Oe,X:Pe,G:Be,F:ke,O:De,P:Re,U:Le}=Ct,{rect:Me,roundRect:Se,arcTo:Ie,arc:Ae,ellipse:We,quadraticCurveTo:Ne}=Zt,{ellipticalArc:Xe}=ie,Ye=K.get("PathConvert"),He={},je={current:{dot:0},stringify(t){let e,s,r,i=0,o=t.length,n="";for(;i<o;){s=t[i],e=Dt[s],n+=s===r?" ":kt[s];for(let s=1;s<e;s++)n+=t[i+s],s===e-1||(n+=" ");r=s,i+=e}return n},parse(t,e){let s,r,i,o="";const n=[],a=e?Pt:Ot;for(let e=0,h=t.length;e<h;e++)r=t[e],G[r]?("."===r&&(Ue.dot++,Ue.dot>1&&(ze(n,o),o="")),o+=r):Ct[r]?(o&&(ze(n,o),o=""),Ue.name=Ct[r],Ue.length=Tt[r],Ue.index=0,ze(n,Ue.name),!s&&a[r]&&(s=!0)):"-"===r||"+"===r?"e"===i||"E"===i?o+=r:(o&&ze(n,o),o=r):o&&(ze(n,o),o=""),i=r;return o&&ze(n,o),s?je.toCanvasData(n,e):n},toCanvasData(t,e){let s,r,i,o,n,a=0,h=0,l=0,d=0,c=0,u=t.length;const p=[];for(;c<u;){switch(i=t[c],i){case ne:t[c+1]+=a,t[c+2]+=h;case oe:a=t[c+1],h=t[c+2],p.push(oe,a,h),c+=3;break;case de:t[c+1]+=a;case le:a=t[c+1],p.push(ae,a,h),c+=2;break;case ue:t[c+1]+=h;case ce:h=t[c+1],p.push(ae,a,h),c+=2;break;case he:t[c+1]+=a,t[c+2]+=h;case ae:a=t[c+1],h=t[c+2],p.push(ae,a,h),c+=3;break;case fe:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,i=ge;case ge:n=o===pe||o===ge,l=n?2*a-s:t[c+1],d=n?2*h-r:t[c+2],s=t[c+1],r=t[c+2],a=t[c+3],h=t[c+4],p.push(pe,l,d,s,r,a,h),c+=5;break;case _e:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,t[c+5]+=a,t[c+6]+=h,i=pe;case pe:s=t[c+3],r=t[c+4],a=t[c+5],h=t[c+6],p.push(pe,t[c+1],t[c+2],s,r,a,h),c+=7;break;case ve:t[c+1]+=a,t[c+2]+=h,i=xe;case xe:n=o===me||o===xe,s=n?2*a-s:t[c+1],r=n?2*h-r:t[c+2],e?Ne(p,a,h,s,r,t[c+1],t[c+2]):p.push(me,s,r,t[c+1],t[c+2]),a=t[c+1],h=t[c+2],c+=3;break;case ye:t[c+1]+=a,t[c+2]+=h,t[c+3]+=a,t[c+4]+=h,i=me;case me:s=t[c+1],r=t[c+2],e?Ne(p,a,h,s,r,t[c+3],t[c+4]):p.push(me,s,r,t[c+3],t[c+4]),a=t[c+3],h=t[c+4],c+=5;break;case we:t[c+6]+=a,t[c+7]+=h;case Ee:Xe(p,a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],e),a=t[c+6],h=t[c+7],c+=8;break;case Ce:case be:p.push(be),c++;break;case Te:a=t[c+1],h=t[c+2],e?Me(p,a,h,t[c+3],t[c+4]):Fe(p,t,c,5),c+=5;break;case Oe:a=t[c+1],h=t[c+2],e?Se(p,a,h,t[c+3],t[c+4],[t[c+5],t[c+6],t[c+7],t[c+8]]):Fe(p,t,c,9),c+=9;break;case Pe:a=t[c+1],h=t[c+2],e?Se(p,a,h,t[c+3],t[c+4],t[c+5]):Fe(p,t,c,6),c+=6;break;case Be:We(e?p:Fe(p,t,c,9),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],t[c+7],t[c+8],null,He),a=He.x,h=He.y,c+=9;break;case ke:e?We(p,t[c+1],t[c+2],t[c+3],t[c+4],0,0,360,!1):Fe(p,t,c,5),a=t[c+1]+t[c+3],h=t[c+2],c+=5;break;case De:Ae(e?p:Fe(p,t,c,7),t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],t[c+6],null,He),a=He.x,h=He.y,c+=7;break;case Re:e?Ae(p,t[c+1],t[c+2],t[c+3],0,360,!1):Fe(p,t,c,4),a=t[c+1]+t[c+3],h=t[c+2],c+=4;break;case Le:Ie(e?p:Fe(p,t,c,6),a,h,t[c+1],t[c+2],t[c+3],t[c+4],t[c+5],null,He),a=He.x,h=He.y,c+=6;break;default:return Ye.error(`command: ${i} [index:${c}]`,t),p}o=i}return p},copyData(t,e,s,r){for(let i=s,o=s+r;i<o;i++)t.push(e[i])},pushData(t,e){Ue.index===Ue.length&&(Ue.index=1,t.push(Ue.name)),t.push(Number(e)),Ue.index++,Ue.dot=0}},{current:Ue,pushData:ze,copyData:Fe}=je,{M:Ve,L:Ge,C:Ke,Q:Ze,Z:qe,N:Qe,D:Je,X:$e,G:ts,F:es,O:ss,P:rs,U:is}=Ct,os={},ns={beginPath(t){t.length=0},moveTo(t,e,s){t.push(Ve,e,s)},lineTo(t,e,s){t.push(Ge,e,s)},bezierCurveTo(t,e,s,r,i,o,n){t.push(Ke,e,s,r,i,o,n)},quadraticCurveTo(t,e,s,r,i){t.push(Ze,e,s,r,i)},closePath(t){t.push(qe)},rect(t,e,s,r,i){t.push(Qe,e,s,r,i)},roundRect(t,e,s,r,o,n){if("number"==typeof n)t.push($e,e,s,r,o,n);else{const a=i.fourNumber(n);a?t.push(Je,e,s,r,o,...a):t.push(Qe,e,s,r,o)}},ellipse(t,e,s,r,i,o,n,a,h){void 0===o?t.push(es,e,s,r,i):(void 0===n&&(n=0),void 0===a&&(a=360),t.push(ts,e,s,r,i,o,n,a,h?1:0))},arc(t,e,s,r,i,o,n){void 0===i?t.push(rs,e,s,r):(void 0===o&&(o=360),t.push(ss,e,s,r,i,o,n?1:0))},arcTo(t,e,s,r,i,o){t.push(is,e,s,r,i,o)},drawEllipse(t,e,s,r,i,o,n,a,h){void 0===o&&(o=0),void 0===n&&(n=0),void 0===a&&(a=360),Zt.ellipse(null,e,s,r,i,o,n,a,h,null,null,os),t.push(Ve,os.x,os.y),as(t,e,s,r,i,o,n,a,h)},drawArc(t,e,s,r,i,o,n){void 0===i&&(i=0),void 0===o&&(o=360),Zt.arc(null,e,s,r,i,o,n,null,null,os),t.push(Ve,os.x,os.y),hs(t,e,s,r,i,o,n)},drawPoints(t,e,s,r){Zt.points(t,e,s,r)}},{ellipse:as,arc:hs}=ns,{moveTo:ls,lineTo:ds,quadraticCurveTo:cs,bezierCurveTo:us,closePath:ps,beginPath:_s,rect:gs,roundRect:fs,ellipse:ms,arc:ys,arcTo:xs,drawEllipse:vs,drawArc:Es,drawPoints:ws}=ns;class bs{constructor(t){this.path=t?"string"==typeof t?wt.parse(t):t:[]}beginPath(){return _s(this.path),this}moveTo(t,e){return ls(this.path,t,e),this}lineTo(t,e){return ds(this.path,t,e),this}bezierCurveTo(t,e,s,r,i,o){return us(this.path,t,e,s,r,i,o),this}quadraticCurveTo(t,e,s,r){return cs(this.path,t,e,s,r),this}closePath(){return ps(this.path),this}rect(t,e,s,r){return gs(this.path,t,e,s,r),this}roundRect(t,e,s,r,i){return fs(this.path,t,e,s,r,i),this}ellipse(t,e,s,r,i,o,n,a){return ms(this.path,t,e,s,r,i,o,n,a),this}arc(t,e,s,r,i,o){return ys(this.path,t,e,s,r,i,o),this}arcTo(t,e,s,r,i){return xs(this.path,t,e,s,r,i),this}drawEllipse(t,e,s,r,i,o,n,a){return vs(this.path,t,e,s,r,i,o,n,a),this}drawArc(t,e,s,r,i,o){return Es(this.path,t,e,s,r,i,o),this}drawPoints(t,e,s){return ws(this.path,t,e,s),this}}const{M:Cs,L:Ts,C:Os,Q:Ps,Z:Bs,N:ks,D:Ds,X:Rs,G:Ls,F:Ms,O:Ss,P:Is,U:As}=Ct,Ws=K.get("PathDrawer"),Ns={drawPathByData(t,e){if(!e)return;let s,r=0,i=e.length;for(;r<i;)switch(s=e[r],s){case Cs:t.moveTo(e[r+1],e[r+2]),r+=3;break;case Ts:t.lineTo(e[r+1],e[r+2]),r+=3;break;case Os:t.bezierCurveTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5],e[r+6]),r+=7;break;case Ps:t.quadraticCurveTo(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case Bs:t.closePath(),r+=1;break;case ks:t.rect(e[r+1],e[r+2],e[r+3],e[r+4]),r+=5;break;case Ds:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],[e[r+5],e[r+6],e[r+7],e[r+8]]),r+=9;break;case Rs:t.roundRect(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;case Ls:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]*o,e[r+6]*o,e[r+7]*o,e[r+8]),r+=9;break;case Ms:t.ellipse(e[r+1],e[r+2],e[r+3],e[r+4],0,0,n,!1),r+=5;break;case Ss:t.arc(e[r+1],e[r+2],e[r+3],e[r+4]*o,e[r+5]*o,e[r+6]),r+=7;break;case Is:t.arc(e[r+1],e[r+2],e[r+3],0,n,!1),r+=4;break;case As:t.arcTo(e[r+1],e[r+2],e[r+3],e[r+4],e[r+5]),r+=6;break;default:return void Ws.error(`command: ${s} [index:${r}]`,e)}}},{M:Xs,L:Ys,C:Hs,Q:js,Z:Us,N:zs,D:Fs,X:Vs,G:Gs,F:Ks,O:Zs,P:qs,U:Qs}=Ct,{toTwoPointBounds:Js,toTwoPointBoundsByQuadraticCurve:$s,arcTo:tr,arc:er,ellipse:sr}=Zt,{add:rr,copy:ir,addPoint:or,setPoint:nr,addBounds:ar,toBounds:hr}=k,lr=K.get("PathBounds");let dr,cr,ur;const pr={},_r={},gr={},fr={toBounds(t,e){fr.toTwoPointBounds(t,_r),hr(_r,e)},toTwoPointBounds(t,e){if(!t||!t.length)return nr(e,0,0);let s,r,i,o,n,a=0,h=0,l=0;const d=t.length;for(;a<d;)switch(s=t[a],0===a&&(s===Us||s===Hs||s===js?nr(e,h,l):nr(e,t[a+1],t[a+2])),s){case Xs:case Ys:h=t[a+1],l=t[a+2],or(e,h,l),a+=3;break;case Hs:o=t[a+5],n=t[a+6],Js(h,l,t[a+1],t[a+2],t[a+3],t[a+4],o,n,pr),rr(e,pr),h=o,l=n,a+=7;break;case js:r=t[a+1],i=t[a+2],o=t[a+3],n=t[a+4],$s(h,l,r,i,o,n,pr),rr(e,pr),h=o,l=n,a+=5;break;case Us:a+=1;break;case zs:h=t[a+1],l=t[a+2],ar(e,h,l,t[a+3],t[a+4]),a+=5;break;case Fs:case Vs:h=t[a+1],l=t[a+2],ar(e,h,l,t[a+3],t[a+4]),a+=s===Fs?9:6;break;case Gs:sr(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],pr,gr),0===a?ir(e,pr):rr(e,pr),h=gr.x,l=gr.y,a+=9;break;case Ks:h=t[a+1],l=t[a+2],cr=t[a+3],ur=t[a+4],ar(e,h-cr,l-ur,2*cr,2*ur),h+=cr,a+=5;break;case Zs:er(null,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],t[a+6],pr,gr),0===a?ir(e,pr):rr(e,pr),h=gr.x,l=gr.y,a+=7;break;case qs:h=t[a+1],l=t[a+2],dr=t[a+3],ar(e,h-dr,l-dr,2*dr,2*dr),h+=dr,a+=4;break;case Qs:tr(null,h,l,t[a+1],t[a+2],t[a+3],t[a+4],t[a+5],pr,gr),0===a?ir(e,pr):rr(e,pr),h=gr.x,l=gr.y,a+=6;break;default:return void lr.error(`command: ${s} [index:${a}]`,t)}}},mr={smooth:(t,e,s)=>t};wt.creator=new bs,wt.parse=je.parse,wt.convertToCanvasData=je.toCanvasData;const{drawRoundRect:yr}=Rt;const xr=K.get("TaskProcessor");class vr{constructor(t){this.parallel=!0,this.time=1,this.id=s.create(s.TASK),this.task=t}run(){return ut(this,void 0,void 0,(function*(){try{this.task&&!this.isComplete&&this.parent.running&&(yield this.task())}catch(t){xr.error(t)}}))}complete(){this.isComplete=!0,this.parent=null,this.task=null}cancel(){this.isCancel=!0,this.complete()}}class Er{get total(){return this.list.length+this.delayNumber}get finishedIndex(){return this.isComplete?0:this.index+this.parallelSuccessNumber}get remain(){return this.isComplete?this.total:this.total-this.finishedIndex}get percent(){const{total:t}=this;let e=0,s=0;for(let r=0;r<t;r++)r<=this.finishedIndex?(s+=this.list[r].time,r===this.finishedIndex&&(e=s)):e+=this.list[r].time;return this.isComplete?1:s/e}constructor(t){this.config={parallel:6},this.list=[],this.running=!1,this.isComplete=!0,this.index=0,this.delayNumber=0,t&&at.assign(this.config,t),this.empty()}add(t,e){let s,r,i,o;const n=new vr(t);return n.parent=this,"number"==typeof e?o=e:e&&(r=e.parallel,s=e.start,i=e.time,o=e.delay),i&&(n.time=i),!1===r&&(n.parallel=!1),void 0===o?this.push(n,s):(this.delayNumber++,setTimeout((()=>{this.delayNumber--,this.push(n,s)}),o)),this.isComplete=!1,n}push(t,e){this.list.push(t),!1===e||this.timer||(this.timer=setTimeout((()=>this.start())))}empty(){this.index=0,this.parallelSuccessNumber=0,this.list=[],this.parallelList=[]}start(){this.running||(this.running=!0,this.isComplete=!1,this.run())}pause(){clearTimeout(this.timer),this.timer=null,this.running=!1}resume(){this.start()}skip(){this.index++,this.resume()}stop(){this.isComplete=!0,this.list.forEach((t=>{t.isComplete||t.cancel()})),this.pause(),this.empty()}run(){this.running&&(this.setParallelList(),this.parallelList.length>1?this.runParallelTasks():this.remain?this.runTask():this.onComplete())}runTask(){const t=this.list[this.index];t?t.run().then((()=>{this.onTask(t),this.index++,this.nextTask()})).catch((t=>{this.onError(t)})):this.nextTask()}runParallelTasks(){this.parallelList.forEach((t=>this.runParallelTask(t)))}runParallelTask(t){t.run().then((()=>{this.onTask(t),this.fillParallelTask()})).catch((t=>{this.onParallelError(t)}))}nextTask(){this.total===this.finishedIndex?this.onComplete():this.timer=setTimeout((()=>this.run()))}setParallelList(){let t;this.parallelList=[],this.parallelSuccessNumber=0;let e=this.index+this.config.parallel;e>this.list.length&&(e=this.list.length);for(let s=this.index;s<e&&(t=this.list[s],t.parallel);s++)this.parallelList.push(t)}fillParallelTask(){let t;const e=this.parallelList;this.parallelSuccessNumber++,e.pop();const s=e.length,r=this.finishedIndex+s;if(e.length){if(!this.running)return;r<this.total&&(t=this.list[r],t&&t.parallel&&(e.push(t),this.runParallelTask(t)))}else this.index+=this.parallelSuccessNumber,this.parallelSuccessNumber=0,this.nextTask()}onComplete(){this.stop(),this.config.onComplete&&this.config.onComplete()}onTask(t){t.complete(),this.config.onTask&&this.config.onTask()}onParallelError(t){this.parallelList.forEach((t=>{t.parallel=!1})),this.parallelList.length=0,this.parallelSuccessNumber=0,this.onError(t)}onError(t){this.pause(),this.config.onError&&this.config.onError(t)}destroy(){this.stop()}}const wr={map:{},recycledList:[],tasker:new Er,patternTasker:new Er,get isComplete(){return br.tasker.isComplete&&br.patternTasker.isComplete},get(t){let s=br.map[t.url];return s||(s=e.image(t),br.map[t.url]=s),s.use++,s},recycle(t){t.use--,setTimeout((()=>{t.use||br.recycledList.push(t)}))},clearRecycled(){const t=br.recycledList;t.length&&(t.forEach((t=>{!t.use&&t.url&&(delete br.map[t.url],t.destroy())})),t.length=0)},destroy(){br.map={}}},br=wr,{IMAGE:Cr,create:Tr}=s;class Or{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 Pr extends Or{constructor(t,e,s){super(t,e),this.parent=s,this.child=e}}Pr.ADD="child.add",Pr.REMOVE="child.remove";class Br extends Or{constructor(t,e,s,r,i){super(t,e),this.attrName=s,this.oldValue=r,this.newValue=i}}Br.CHANGE="property.change";class kr extends Or{constructor(t,e){super(t),Object.assign(this,e)}}kr.LOAD="image.load",kr.LOADED="image.loaded",kr.ERROR="image.error";class Dr extends Or{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){"object"==typeof t?(super(Dr.RESIZE),Object.assign(this,t)):super(t),this.old=e}}Dr.RESIZE="resize";class Rr extends Or{constructor(t,e){super(t),e&&Object.assign(this,e)}}Rr.START="transform.start",Rr.CHANGE="transform.change",Rr.END="transform.end",Rr.BEFORE_START="transform.before_start",Rr.BEFORE_CHANGE="transform.before_change",Rr.BEFORE_END="transform.before_end";class Lr extends Or{constructor(t,e){super(t),this.data=e}}Lr.REQUEST="watch.request",Lr.DATA="watch.data";class Mr extends Or{constructor(t,e,s){super(t),e&&(this.data=e,this.times=s)}}Mr.CHECK_UPDATE="layout.check_update",Mr.REQUEST="layout.request",Mr.START="layout.start",Mr.BEFORE="layout.before",Mr.LAYOUT="layout.layout",Mr.AFTER="layout.after",Mr.AGAIN="layout.again",Mr.END="layout.end";class Sr extends Or{}Sr.FRAME="animate.frame";class Ir extends Or{constructor(t,e,s,r){super(t),e&&(this.times=e),s&&(this.renderBounds=s,this.renderOptions=r)}}Ir.REQUEST="render.request",Ir.START="render.start",Ir.BEFORE="render.before",Ir.RENDER="render",Ir.AFTER="render.after",Ir.AGAIN="render.again",Ir.END="render.end";class Ar extends Or{}Ar.START="leafer.start",Ar.BEFORE_READY="leafer.before_ready",Ar.READY="leafer.ready",Ar.AFTER_READY="leafer.after_ready",Ar.VIEW_READY="leafer.view_ready",Ar.VIEW_COMPLETED="leafer.view_completed",Ar.STOP="leafer.stop",Ar.RESTART="leafer.restart",Ar.END="leafer.end";const Wr={},Nr={isHoldSpaceKey:()=>Nr.isHold("Space"),isHold:t=>Wr[t],setDownCode(t){Wr[t]||(Wr[t]=!0)},setUpCode(t){Wr[t]=!1}},Xr={LEFT:1,RIGHT:2,MIDDLE:4,defaultLeft(t){t.buttons||(t.buttons=1)},left:t=>1===t.buttons,right:t=>2===t.buttons,middle:t=>4===t.buttons};class Yr extends Or{get spaceKey(){return Nr.isHoldSpaceKey()}get left(){return Xr.left(this)}get right(){return Xr.right(this)}get middle(){return Xr.middle(this)}constructor(t){super(t.type),this.bubbles=!0,Object.assign(this,t)}getInner(t){return t||(t=this.current),t.getInnerPoint(this)}getLocal(t){return t||(t=this.current),t.getLocalPoint(this)}static changeName(t,e){rt.changeName(t,e)}}function Hr(t,e,s){Object.defineProperty(t,e,s)}function jr(t,e){return Object.getOwnPropertyDescriptor(t,e)}function Ur(t,e,s,r){const i={get(){return this.__getAttr(e)},set(t){this.__setAttr(e,t)},configurable:!0,enumerable:!0};Hr(t,e,Object.assign(i,r||{})),Kr(t,e,s)}function zr(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__.around&&(this.__layout.positionChanged||this.__layout.positionChange())}})}}const Fr=zr;function Vr(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.strokeChanged||this.__layout.strokeChange()}})}}const Gr=Vr;function Kr(t,e,s){const r=t.__DataProcessor.prototype,i="_"+e,o=function(t){return"set"+t.charAt(0).toUpperCase()+t.slice(1)}(e),n={get(){const t=this[i];return void 0===t?s:t},set(t){this[i]=t},configurable:!0,enumerable:!0};void 0===s?n.get=function(){return this[i]}:"width"===e?n.get=function(){const t=this[i];return void 0===t?this.__naturalWidth||s:t}:"height"===e&&(n.get=function(){const t=this[i];return void 0===t?this.__naturalHeight||s:t});const a=jr(r,e);a&&a.set&&(n.set=a.set),r[o]&&(n.set=r[o],delete r[o]),Object.defineProperty(r,e,n)}const Zr=new K("rewrite"),qr=[],Qr=["destroy","constructor"];function Jr(t){qr.length&&(qr.forEach((e=>{t&&Zr.error(e.name,"需在Class上装饰@rewriteAble()"),e.run()})),qr.length=0)}function $r(t,e){return s=>{var r;(t.prototype?(r=t.prototype,Object.getOwnPropertyNames(r)):Object.keys(t)).forEach((r=>{if(!(Qr.includes(r)||e&&e.includes(r)))if(t.prototype){jr(t.prototype,r).writable&&(s.prototype[r]=t.prototype[r])}else s.prototype[r]=t[r]}))}}function ti(){return t=>{rt.register(t)}}setTimeout((()=>Jr(!0))),exports.PointerEvent=class extends Yr{},exports.PointerEvent.POINTER="pointer",exports.PointerEvent.BEFORE_DOWN="pointer.before_down",exports.PointerEvent.BEFORE_MOVE="pointer.before_move",exports.PointerEvent.BEFORE_UP="pointer.before_up",exports.PointerEvent.DOWN="pointer.down",exports.PointerEvent.MOVE="pointer.move",exports.PointerEvent.UP="pointer.up",exports.PointerEvent.OVER="pointer.over",exports.PointerEvent.OUT="pointer.out",exports.PointerEvent.ENTER="pointer.enter",exports.PointerEvent.LEAVE="pointer.leave",exports.PointerEvent.TAP="tap",exports.PointerEvent.DOUBLE_TAP="double_tap",exports.PointerEvent.CLICK="click",exports.PointerEvent.DOUBLE_CLICK="double_click",exports.PointerEvent.LONG_PRESS="long_press",exports.PointerEvent.LONG_TAP="long_tap",exports.PointerEvent=ct([ti()],exports.PointerEvent);const ei={};var si;exports.DragEvent=class extends exports.PointerEvent{getInnerMove(t,e){return t||(t=this.current),this.assignMove(e),t.getInnerPoint(ei,null,!0)}getLocalMove(t,e){return t||(t=this.current),this.assignMove(e),t.getLocalPoint(ei,null,!0)}getInnerTotal(t){return this.getInnerMove(t,!0)}getLocalTotal(t){return this.getLocalMove(t,!0)}assignMove(t){ei.x=t?this.totalX:this.moveX,ei.y=t?this.totalY:this.moveY}},exports.DragEvent.BEFORE_DRAG="drag.before_drag",exports.DragEvent.START="drag.start",exports.DragEvent.DRAG="drag",exports.DragEvent.END="drag.end",exports.DragEvent.OVER="drag.over",exports.DragEvent.OUT="drag.out",exports.DragEvent.ENTER="drag.enter",exports.DragEvent.LEAVE="drag.leave",exports.DragEvent=ct([ti()],exports.DragEvent),exports.DropEvent=si=class extends exports.PointerEvent{static setList(t){si.dragList=t instanceof nt?t:new nt(t)}static setData(t){this.dragData=t}},exports.DropEvent.DROP="drop",exports.DropEvent=si=ct([ti()],exports.DropEvent),exports.MoveEvent=class extends exports.DragEvent{},exports.MoveEvent.BEFORE_MOVE="move.before_move",exports.MoveEvent.START="move.start",exports.MoveEvent.MOVE="move",exports.MoveEvent.END="move.end",exports.MoveEvent=ct([ti()],exports.MoveEvent),exports.RotateEvent=class extends Yr{},exports.RotateEvent.BEFORE_ROTATE="rotate.before_rotate",exports.RotateEvent.START="rotate.start",exports.RotateEvent.ROTATE="rotate",exports.RotateEvent.END="rotate.end",exports.RotateEvent=ct([ti()],exports.RotateEvent),exports.SwipeEvent=class extends exports.DragEvent{},exports.SwipeEvent.SWIPE="swipe",exports.SwipeEvent.LEFT="swipe.left",exports.SwipeEvent.RIGHT="swipe.right",exports.SwipeEvent.UP="swipe.up",exports.SwipeEvent.DOWN="swipe.down",exports.SwipeEvent=ct([ti()],exports.SwipeEvent),exports.ZoomEvent=class extends Yr{},exports.ZoomEvent.BEFORE_ZOOM="zoom.before_zoom",exports.ZoomEvent.START="zoom.start",exports.ZoomEvent.ZOOM="zoom",exports.ZoomEvent.END="zoom.end",exports.ZoomEvent=ct([ti()],exports.ZoomEvent),exports.KeyEvent=class extends Yr{},exports.KeyEvent.DOWN="key.down",exports.KeyEvent.HOLD="key.hold",exports.KeyEvent.UP="key.up",exports.KeyEvent=ct([ti()],exports.KeyEvent);class ri{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(exports.MoveEvent.START,this.moveData)}t.path=this.moveData.path,e.emit(exports.MoveEvent.BEFORE_MOVE,t),e.emit(exports.MoveEvent.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(exports.ZoomEvent.START,this.zoomData)}t.path=this.zoomData.path,e.emit(exports.ZoomEvent.BEFORE_ZOOM,t),e.emit(exports.ZoomEvent.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(exports.RotateEvent.START,this.rotateData)}t.path=this.rotateData.path,e.emit(exports.RotateEvent.BEFORE_ROTATE,t),e.emit(exports.RotateEvent.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(exports.MoveEvent.END,this.moveData),this.moveData=null)}zoomEnd(){this.zoomData&&(this.interaction.emit(exports.ZoomEvent.END,this.zoomData),this.zoomData=null)}rotateEnd(){this.rotateData&&(this.interaction.emit(exports.RotateEvent.END,this.rotateData),this.rotateData=null)}destroy(){this.zoomData=this.moveData=this.rotateData=null}}const{copy:ii,translate:oi,toInnerPoint:ni,scaleOfOuter:ai,rotateOfOuter:hi,skewOfOuter:li}=f,di={},ci={updateAllWorldMatrix(t){if(t.__updateWorldMatrix(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)pi(e[t])}},updateAllWorldOpacity(t){if(t.__updateWorldOpacity(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)_i(e[t])}},updateAllChange(t){if(_i(t),t.__updateChange(),t.isBranch){const{children:e}=t;for(let t=0,s=e.length;t<s;t++)gi(e[t])}},worldHittable(t){if(!t.__.hittable)return!1;let{parent:e}=t;for(;e;){if(!e.__.hittable||!e.__.hitChildren)return!1;e=e.parent}return!0},moveWorld(t,e,s){t.__layout.checkUpdate();const r={x:e,y:s};t.parent&&ni(t.parent.__world,r,r,!0),ui.moveLocal(t,r.x,r.y)},moveLocal(t,e,s=0){t.x+=e,t.y+=s},zoomOfWorld(t,e,s,r,i){t.__layout.checkUpdate();const o=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.zoomOfLocal(t,o,s,r,i)},zoomOfLocal(t,e,s,r=s,i){ii(di,t.__local),i&&oi(di,i.x,i.y),ai(di,e,s,r),i||(i=t),i.x+=di.e-t.__local.e,i.y+=di.f-t.__local.f,t.scaleX*=s,t.scaleY*=r},rotateOfWorld(t,e,s,r){t.__layout.checkUpdate();const i=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.rotateOfLocal(t,i,s,r)},rotateOfLocal(t,e,s,r){ii(di,t.__local),r&&oi(di,r.x,r.y),hi(di,e,s),r||(r=t),r.x+=di.e-t.__local.e,r.y+=di.f-t.__local.f,t.rotation=i.formatRotation(t.rotation+s)},skewOfWorld(t,e,s,r,i){t.__layout.checkUpdate();const o=t.parent?T.tempToInnerOf(e,t.parent.__world):e;this.skewOfLocal(t,o,s,r,i)},skewOfLocal(t,e,s,r,o){ii(di,t.__local),o&&oi(di,o.x,o.y),li(di,e,s,r),o||(o=t),o.x=di.e-t.__local.e,o.y=di.f-t.__local.f,t.skewX=i.formatSkew(t.skewX+s),t.skewY=i.formatSkew(t.skewY+r)},drop(t,e){const s={x:t.x,y:t.y};t.localToWorld(s),e.worldToInner(s),t.set(s),e.add(t)}},ui=ci,{updateAllWorldMatrix:pi,updateAllWorldOpacity:_i,updateAllChange:gi}=ui,fi={worldBounds:t=>t.__world,localBoxBounds:t=>t.__.isEraser?null:t.__local,localEventBounds:t=>t.__.isEraser?null:t.__layout.localStrokeBounds,localRenderBounds:t=>t.__.isEraser?null: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},mi={sort:(t,e)=>t.__.zIndex===e.__.zIndex?t.__tempNumber-e.__tempNumber:t.__.zIndex-e.__.zIndex,pushAllChildBranch(t,e){if(t.__tempNumber=1,t.__.__childBranchNumber){const{children:s}=t;for(let r=0,i=s.length;r<i;r++)(t=s[r]).isBranch&&(t.__tempNumber=1,e.push(t),yi(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:r}=t;for(let t=0,s=r.length;t<s;t++)r[t].isBranch&&e.push(r[t]);for(let t=s,r=e.length;t<r;t++)xi(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:yi,pushAllBranchStack:xi}=mi,vi={run(t){for(let e=0,s=t.length;e<s;e++)t[e]();t.length=0}},Ei={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?exports.SwipeEvent.UP:t>45&&t<135?exports.SwipeEvent.DOWN:t<=45&&t>=-45?exports.SwipeEvent.RIGHT:exports.SwipeEvent.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:wi.getSwipeDirection(T.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,r=s.length;t<r;t++)if(s[t].hasEvent(e))return!0;return!1},filterPathByEventType(t,e){const s=new nt,{list:r}=t;for(let t=0,i=r.length;t<i;t++)r[t].hasEvent(e)&&s.push(r[t]);return s}},wi=Ei,{getDragEventData:bi,getDropEventData:Ci,getSwipeEventData:Ti,filterPathByEventType:Oi}=Ei;class Pi{constructor(t){this.interaction=t}setDragData(t){this.dragData=bi(t,t,t)}getDragList(){return this.dragging?exports.DropEvent.dragList||this.dragList:null}checkDrag(t,e){const{interaction:s}=this,{downData:r}=s;if(this.moving&&!Xr.middle(t)&&!Xr.left(t))return void s.pointerCancel();const{dragData:i}=this;if(!this.moving){const o=s.config.move.dragEmpty&&r.target.isLeafer;this.moving=(Xr.middle(t)||s.moveMode||o)&&e,this.moving&&s.emit(exports.MoveEvent.START,i)}this.moving||this.dragStart(t,e);const{path:o,throughPath:n}=r;this.dragData=bi(r,i,t),n&&(this.dragData.throughPath=n),this.dragData.path=o,this.moving?(s.emit(exports.MoveEvent.BEFORE_MOVE,this.dragData),s.emit(exports.MoveEvent.MOVE,this.dragData)):this.dragging&&(this.dragDragableList(),s.emit(exports.DragEvent.BEFORE_DRAG,this.dragData),s.emit(exports.DragEvent.DRAG,this.dragData))}dragStart(t,e){this.dragging||(this.dragging=Xr.left(t)&&e,this.dragging&&(this.interaction.emit(exports.DragEvent.START,this.dragData),this.getDragableList(this.dragData.path),this.dragList=Oi(this.dragData.path,exports.DragEvent.DRAG),!this.dragList.length&&this.dragableList&&this.dragList.pushList(this.dragableList)))}getDragableList(t){let e;for(let s=0,r=t.length;s<r;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=>{ci.moveWorld(s,t,e)}))}}dragOverOrOut(t){const{interaction:e}=this,{dragOverPath:s}=this,{path:r}=t;s?r.indexAt(0)!==s.indexAt(0)&&(e.emit(exports.DragEvent.OUT,t,s),e.emit(exports.DragEvent.OVER,t,r)):e.emit(exports.DragEvent.OVER,t,r),this.dragOverPath=r}dragEnterOrLeave(t){const{interaction:e}=this,{dragEnterPath:s}=this,{path:r}=t;e.emit(exports.DragEvent.LEAVE,t,s,r),e.emit(exports.DragEvent.ENTER,t,r,s),this.dragEnterPath=r}dragEnd(t){const{interaction:e}=this,{downData:s}=e;if(!s)return;const{path:r,throughPath:i}=s,o=bi(s,t,t);i&&(o.throughPath=i),o.path=r,this.moving&&e.emit(exports.MoveEvent.END,o),this.dragging&&(e.emit(exports.DragEvent.END,o),this.swipe(t,o),this.drop(t)),this.autoMoveCancel(),this.dragReset()}swipe(t,e){const{interaction:s}=this,{downData:r}=s;if(T.getDistance(r,t)>s.config.pointer.swipeDistance){const t=Ti(r,this.dragData,e);this.interaction.emit(t.type,t)}}drop(t){const e=Ci(t,this.getDragList(),exports.DropEvent.dragData);e.path=this.dragEnterPath,this.interaction.emit(exports.DropEvent.DROP,e),this.interaction.emit(exports.DragEvent.LEAVE,t,this.dragEnterPath)}dragReset(){exports.DropEvent.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,{autoDistance:r,dragOut:i}=e.config.move;if(!i||!r)return;const o=e.shrinkCanvasBounds,{x:n,y:a}=o,h=j.right(o),l=j.bottom(o),d=t.x<n?r:h<t.x?-r:0,c=t.y<a?r:l<t.y?-r:0;let u=0,p=0;this.autoMoveTimer=setInterval((()=>{u+=d,p+=c,T.move(s,d,c),T.move(this.dragData,d,c),e.move(Object.assign(Object.assign({},t),{moveX:d,moveY:c,totalX:u,totalY:p})),e.pointerMoveReal(t)}),10)}autoMoveCancel(){this.autoMoveTimer&&(clearInterval(this.autoMoveTimer),this.autoMoveTimer=0)}destroy(){this.dragReset()}}const Bi=["move","zoom","rotate","key"];function ki(t,e,s,r,i){if(Bi.some((t=>e.startsWith(t)))&&t.__.hitChildren&&!Ri(t,i)){let o;for(let n=0,a=t.children.length;n<a;n++)o=t.children[n],!s.path.has(o)&&o.__.hittable&&Di(o,e,s,r,i)}}function Di(t,e,s,r,i){if(t.destroyed)return!0;if(t.__.hitSelf&&t.hasEvent(e,r)&&!Ri(t,i)){s.phase=r?1:t===s.target?2:3;const i=rt.get(e,s);if(t.emitEvent(i,r),i.isStop)return!0}return!1}function Ri(t,e){return e&&e.has(t)}const Li={getData(t){const e=t[0],s=t[1],r=T.getCenter(e.from,s.from),i=T.getCenter(e.to,s.to),o={x:i.x-r.x,y:i.y-r.y},n=T.getDistance(e.from,s.from);return{move:o,scale:T.getDistance(e.to,s.to)/n,angle:T.getChangeAngle(e.from,s.from,e.to,s.to),center:i}}},{pathHasEventType:Mi,getMoveEventData:Si,getZoomEventData:Ii,getRotateEventData:Ai}=Ei;class Wi{static set(t,e){this.custom[t]=e}static get(t){return this.custom[t]}}Wi.custom={};const{toOuterOf:Ni}=j;class Xi{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.boxChange(),this.positionChange()}checkUpdate(e){const{leafer:s}=this.leaf;if(s)s.ready?(t.realtimeLayout||e)&&s.watcher.changed&&s.layouter.layout():s.start();else{let e=this.leaf;for(;e.parent;)e=e.parent;t.layout(e)}}getTransform(t){return this.checkUpdate(),"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={}),Ni(this.contentBounds,this.leaf.__world,this._worldContentBounds),this._worldContentBounds}getWorldBoxBounds(){return this._worldBoxBounds||(this._worldBoxBounds={}),Ni(this.boxBounds,this.leaf.__world,this._worldBoxBounds),this._worldBoxBounds}getWorldStrokeBounds(){return this._worldStrokeBounds||(this._worldStrokeBounds={}),Ni(this.strokeBounds,this.leaf.__world,this._worldStrokeBounds),this._worldStrokeBounds}spreadStrokeCancel(){const t=this.renderBounds===this.strokeBounds;this.strokeBounds=this.boxBounds,this.localStrokeBounds=this.leaf.__local,t&&this.spreadRenderCancel()}spreadRenderCancel(){this.renderBounds=this.strokeBounds,this.localRenderBounds=this.localStrokeBounds}spreadStroke(){const{x:t,y:e,width:s,height:r}=this.strokeBounds;this.strokeBounds={x:t,y:e,width:s,height:r},this.localStrokeBounds={x:t,y:e,width:s,height:r},this.renderSpread||this.spreadRenderCancel()}spreadRender(){const{x:t,y:e,width:s,height:r}=this.renderBounds;this.renderBounds={x:t,y:e,width:s,height:r},this.localRenderBounds={x:t,y:e,width:s,height:r}}boxChange(){this.boxChanged=!0,this.localBoxChanged||this.localBoxChange(),this.hitCanvasChanged=!0}localBoxChange(){this.localBoxChanged=!0,this.boundsChanged=!0}strokeChange(){this.strokeChanged=!0,this.strokeSpread||(this.strokeSpread=1),this.boundsChanged=!0,this.hitCanvasChanged=!0}renderChange(){this.renderChanged=!0,this.renderSpread||(this.renderSpread=1),this.boundsChanged=!0}positionChange(){this.positionChanged=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}scaleChange(){this.scaleChanged=!0,this._scaleOrRotationChange()}rotationChange(){this.rotationChanged=!0,this.affectRotation=!0,this._scaleOrRotationChange()}_scaleOrRotationChange(){this.affectScaleOrRotation=!0,this.matrixChanged=!0,this.localBoxChanged||this.localBoxChange()}surfaceChange(){this.surfaceChanged=!0}opacityChange(){this.opacityChanged=!0,this.surfaceChanged||this.surfaceChange()}childrenSortChange(){this.childrenSortChanged||(this.childrenSortChanged=!0,this.leaf.forceUpdate("surface"))}destroy(){}}const Yi={},Hi={on(t,e,s){let r,i,o;s&&("boolean"==typeof s?r=s:(r=s.capture,i=s.once));const n=ji(this,r,!0),a="string"==typeof t?t.split(" "):t,h=i?{listener:e,once:i}:{listener:e};a.forEach((t=>{t&&(o=n[t],o?-1===o.findIndex((t=>t.listener===e))&&o.push(h):n[t]=[h])}))},off(t,e,s){let r,i,o;s&&(r="boolean"==typeof s?s:s.capture);const n=ji(this,r);("string"==typeof t?t.split(" "):t).forEach((t=>{t&&(i=n[t],i&&(o=i.findIndex((t=>t.listener===e)),o>-1&&i.splice(o,1),i.length||delete n[t]))}))},on_(t,e,s,r){return s&&(e=e.bind(s)),this.on(t,e,r),{type:t,listener:e,options:r}},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){!e&&rt.has(t)&&(e=rt.get(t,{type:t,target:this,current:this}));const r=ji(this,s)[t];if(r){let i;for(let o=0,n=r.length;o<n&&(i=r[o],i.listener(e),i.once&&(this.off(t,i.listener,s),o--,n--),!e||!e.isStopNow);o++);}},emitEvent(t,e){t.current=this,this.emit(t.type,t,e)},hasEvent(t,e){const{__bubbleMap:s,__captureMap:r}=this;return void 0===e?!!(r&&r[t]||s&&s[t]):!!(e?r&&r[t]:s&&s[t])}};function ji(t,e,s){if(e){const{__captureMap:e}=t;return e||(s?t.__captureMap={}:Yi)}{const{__bubbleMap:e}=t;return e||(s?t.__bubbleMap={}:Yi)}}const Ui={__setAttr(t,e){if(this.leafer&&this.leafer.created){if("object"==typeof e||this.__.__getInput(t)!==e){this.__[t]=e;const{CHANGE:s}=Br,r=new Br(s,this,t,this.__.__get(t),e);this.hasEvent(s)&&!this.isLeafer&&this.emitEvent(r),this.leafer.emitEvent(r)}}else this.__[t]=e},__getAttr(t){return this.__.__get(t)}},{sin:zi,cos:Fi}=Math,Vi=Object.assign(Object.assign({},f.defaultMatrix),{scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0}),Gi={x:.5,y:.5},Ki={__updateWorldMatrix(){const t=this.parent?this.parent.__world:Vi,e=this.__local,s=this.__world;if(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;const r=this.__;s.scaleX=t.scaleX*r.scaleX,s.scaleY=t.scaleY*r.scaleY,s.rotation=t.rotation+r.rotation,s.skewX=t.skewX+r.skewX,s.skewY=t.skewY+r.skewY}else 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,s.scaleX=t.scaleX,s.scaleY=t.scaleY,s.rotation=t.rotation,s.skewX=t.skewX,s.skewY=t.skewY},__updateLocalMatrix(){const t=this.__local,e=this.__layout;if(e.affectScaleOrRotation){const{scaleX:s,scaleY:r}=this.__;if(e.affectRotation){if(e.scaleChanged||e.rotationChanged){let{rotation:i,skewX:n,skewY:a}=this.__;i||n||a?(i*=o,n&&(n*=o),a&&(a*=o),t.a=s*Fi(i+a),t.b=s*zi(i+a),t.c=r*-zi(i-n),t.d=r*Fi(i-n)):(t.a=s,t.b=0,t.c=0,t.d=r,e.affectRotation=!1),e.scaleChanged=!1,e.rotationChanged=!1}}else e.scaleChanged&&(t.a=s,t.d=r,e.scaleChanged=!1)}if(e.positionChanged){t.e=this.__.x,t.f=this.__.y;const{width:s,height:r,around:i}=this.__;if(i&&s&&r){const e="center"===i?Gi:i,o=s*e.x,n=r*e.y;t.e-=o*t.a+n*t.c,t.f-=o*t.b+n*t.d}e.positionChanged=!1}this.__layout.matrixChanged=!1}},{toOuterOf:Zi,copyAndSpread:qi}=j,Qi={__updateWorldBounds(){var t;if(this.__layout.boundsChanged){let e;const s=this.__layout;s.boxChanged&&(this.__updatePath(),this.__updateRenderPath(),this.__updateBoxBounds(),s.boxChanged=!1,e=!0),s.localBoxChanged&&(this.__updateLocalBoxBounds(),s.localBoxChanged=!1,s.strokeSpread&&(s.strokeChanged=!0),s.renderSpread&&(s.renderChanged=!0),null===(t=this.parent)||void 0===t||t.__layout.boxChange()),s.strokeChanged&&(s.strokeSpread=this.__updateStrokeSpread(),s.strokeSpread?(s.strokeBounds===s.boxBounds&&s.spreadStroke(),this.__updateStrokeBounds(),this.__updateLocalStrokeBounds()):s.spreadStrokeCancel(),s.strokeChanged=!1,s.renderSpread&&(s.renderChanged=!0),this.parent&&this.parent.__layout.strokeChange(),e||(e=!0)),s.renderChanged&&(s.renderSpread=this.__updateRenderSpread(),s.renderSpread?(s.renderBounds!==s.boxBounds&&s.renderBounds!==s.strokeBounds||s.spreadRender(),this.__updateRenderBounds(),this.__updateLocalRenderBounds()):s.spreadRenderCancel(),s.renderChanged=!1,this.parent&&this.parent.__layout.renderChange()),s.boundsChanged=!1,Zi(this.__layout.renderBounds,this.__world,this.__world),e&&this.__onUpdateSize()}else Zi(this.__layout.renderBounds,this.__world,this.__world)},__updateLocalBoxBounds(){Zi(this.__layout.boxBounds,this.__local,this.__local)},__updateLocalStrokeBounds(){Zi(this.__layout.strokeBounds,this.__local,this.__layout.localStrokeBounds)},__updateLocalRenderBounds(){Zi(this.__layout.renderBounds,this.__local,this.__layout.localRenderBounds)},__updateBoxBounds(){const t=this.__layout.boxBounds,{width:e,height:s}=this.__;t.x=0,t.y=0,t.width=e,t.height=s},__updateNaturalSize(){const{__:t,__layout:e}=this;t.__naturalWidth=e.boxBounds.width,t.__naturalHeight=e.boxBounds.height,this.around&&(e.positionChanged=e.matrixChanged=!0,this.__updateWorldMatrix())},__updateStrokeBounds(){qi(this.__layout.strokeBounds,this.__layout.boxBounds,this.__layout.strokeSpread)},__updateRenderBounds(){qi(this.__layout.renderBounds,this.__layout.strokeBounds,this.__layout.renderSpread)}},{toInnerRadiusPointOf:Ji,copy:$i,setRadius:to}=T,eo={},so={__hitWorld(t){return!this.__layout.hitCanvasChanged&&this.__hitCanvas||(this.__updateHitCanvas(),this.__layout.hitCanvasChanged=!1),this.__.hitRadius&&($i(eo,t),to(t=eo,this.__.hitRadius)),Ji(t,this.__world,eo),this.__hit(eo)},__drawHitPath(t){this.__drawRenderPath(t)}},ro={__render(t,e){if(this.__worldOpacity)if(t.setWorld(this.__world,e.matrix),t.opacity=this.__worldOpacity,this.__.__single){const s=t.getSameCanvas(!0);this.__draw(s,e);const r=this.__.isEraser?"destination-out":this.__.blendMode;this.__hasMirror||e.matrix?t.copyWorldByReset(s,null,null,r):t.copyWorldToInner(s,this.__world,this.__layout.renderBounds,r),s.recycle()}else 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)}},io={__updateEraser(t){this.__hasEraser=!!t||this.children.some((t=>t.__.isEraser))},__updateMask(t){this.__hasMask=!!t||this.children.some((t=>t.__.isMask))},__renderMask(t,e,s){e.resetTransform(),e.useMask(s),t.resetTransform(),t.opacity=this.__worldOpacity,t.copyWorld(e)},__removeMask(t){if(t)t.isMask=!1,this.remove(t);else{const{children:e}=this;for(let s=0,r=e.length;s<r;s++)(t=e[s]).isMask&&(this.__removeMask(t),r--,s--)}}},oo={__updateChange(){const{__layout:t}=this;t.childrenSortChanged&&(this.__updateSortChildren(),t.childrenSortChanged=!1),this.__.__checkSingle()},__render(t,e){if(this.__worldOpacity)if(this.__.__single){t.resetTransform();const s=t.getSameCanvas();this.__renderBranch(s,e),t.opacity=this.__worldOpacity;const r=this.__.isEraser?"destination-out":this.__.blendMode;this.__hasMirror||e.matrix?t.copyWorld(s,null,null,r):t.copyWorld(s,this.__world,this.__world,r),s.recycle()}else this.__renderBranch(t,e)},__renderBranch(t,e){let s;const{children:r}=this;if(this.__hasMask&&r.length>1){let i,o=t.getSameCanvas(),n=t.getSameCanvas();for(let a=0,h=r.length;a<h;a++)s=r[a],s.isMask?(i?(this.__renderMask(t,n,o),o.clear(),n.clear()):i=!0,s.__render(o,e)):s.__render(n,e);this.__renderMask(t,n,o),o.recycle(),n.recycle()}else{const{bounds:i,hideBounds:o}=e;for(let n=0,a=r.length;n<a;n++)s=r[n],i&&!i.hit(s.__world,e.matrix)||o&&o.includes(s.__world,e.matrix)||s.__render(t,e)}}},{LEAF:no,create:ao}=s,{toInnerPoint:ho,toOuterPoint:lo}=f,{tempToOuterOf:co,copy:uo}=T,{moveLocal:po,zoomOfLocal:_o,rotateOfLocal:go,skewOfLocal:fo}=ci;exports.Leaf=class{get tag(){return this.__tag}set tag(t){}get __tag(){return"Leaf"}get innerName(){return this.__.name||this.tag+this.innerId}get __DataProcessor(){return lt}get __LayoutProcessor(){return Xi}get worldTransform(){return this.__layout.getTransform("world")}get localTransform(){return this.__layout.getTransform("local")}get boxBounds(){return this.getBounds("box","inner")}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 resizeable(){return!0}get __hasMirror(){return this.__world.scaleX<0||this.__world.scaleY<0}get __onlyHitMask(){return this.__hasMask&&!this.__.hitChildren}get __ignoreHitWorld(){return(this.__hasMask||this.__hasEraser)&&this.__.hitChildren}constructor(t){this.innerId=ao(no),this.__world={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0},this.__local={a:1,b:0,c:0,d:1,e:0,f:0,x:0,y:0,width:0,height:0},this.__worldOpacity=1,this.__=new this.__DataProcessor(this),this.__layout=new this.__LayoutProcessor(this),t&&(t.children?this.set(t):Object.assign(this,t))}waitParent(t){this.parent?t():this.__parentWait?this.__parentWait.push(t):this.__parentWait=[t]}waitLeafer(t){this.leafer?t():this.__leaferWait?this.__leaferWait.push(t):this.__leaferWait=[t]}nextRender(t){this.leafer?this.leafer.nextRender(t):this.waitLeafer((()=>this.leafer.nextRender(t)))}__bindLeafer(t){if(this.isLeafer&&null!==t&&(t=this),this.leafer=t,t&&(this.__level=this.parent?this.parent.__level+1:1,this.__leaferWait&&vi.run(this.__leaferWait)),this.isBranch){const{children:e}=this;for(let s=0,r=e.length;s<r;s++)e[s].__bindLeafer(t)}}set(t){}toJSON(){return this.__.__getInputData()}toString(){return JSON.stringify(this.toJSON())}__setAttr(t,e){}__getAttr(t){}forceUpdate(t){void 0===t?t="scaleX":"surface"===t&&(t="blendMode");const e=this.__.__getInput(t);this.__[t]=void 0===e?null:void 0,this[t]=e}__updateWorldMatrix(){}__updateLocalMatrix(){}__updateWorldBounds(){}__updateLocalBoxBounds(){}__updateLocalStrokeBounds(){}__updateLocalRenderBounds(){}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){}__updateNaturalSize(){}__updateStrokeSpread(){return 0}__updateRenderSpread(){return 0}__onUpdateSize(){}__updateEraser(t){}__updateMask(t){}__renderMask(t,e,s){}__removeMask(t){}getWorld(t){return this.__layout.checkUpdate(),"x"===t?this.__world.e:"y"===t?this.__world.f:this.__world[t]}getBounds(t,e="world"){return this.__layout.getBounds(t,e)}worldToLocal(t,e,s,r){this.parent?this.parent.worldToInner(t,e,s,r):e&&uo(e,t)}localToWorld(t,e,s,r){this.parent?this.parent.innerToWorld(t,e,s,r):e&&uo(e,t)}worldToInner(t,e,s,r){r&&(r.innerToWorld(t,e,s),t=e||t),ho(this.worldTransform,t,e,s)}innerToWorld(t,e,s,r){lo(this.worldTransform,t,e,s),r&&r.worldToInner(e||t,null,s)}getInnerPoint(t,e,s,r){const i=r?t:{};return this.worldToInner(t,i,s,e),i}getInnerPointByLocal(t,e,s,r){return this.getInnerPoint(t,this.parent,s,r)}getLocalPoint(t,e,s,r){const i=r?t:{};return this.worldToLocal(t,i,s,e),i}getLocalPointByInner(t,e,s,r){return this.getWorldPoint(t,this.parent,s,r)}getWorldPoint(t,e,s,r){const i=r?t:{};return this.innerToWorld(t,i,s,e),i}getWorldPointByLocal(t,e,s,r){const i=r?t:{};return this.localToWorld(t,i,s,e),i}move(t,e){po(this,t,e)}scaleOf(t,e,s){_o(this,co(t,this.localTransform),e,s)}rotateOf(t,e){go(this,co(t,this.localTransform),e)}skewOf(t,e,s){fo(this,co(t,this.localTransform),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(){}__updateChange(){}__drawPath(t){}__drawRenderPath(t){}__updatePath(){}__updateRenderPath(){}__updateSortChildren(){}add(t,e){}remove(t,e){this.parent&&this.parent.remove(this,e)}on(t,e,s){}off(t,e,s){}on_(t,e,s,r){}off_(t){}once(t,e,s){}emit(t,e,s){}emitEvent(t,e){}hasEvent(t,e){return!1}destroy(){this.destroyed||(this.parent&&this.remove(),this.children&&this.removeAll(!0),this.__.destroy(),this.__layout.destroy(),this.__captureMap=this.__bubbleMap=this.__parentWait=this.__leaferWait=null,this.destroyed=!0)}},exports.Leaf=ct([$r(Ui),$r(Ki),$r(Qi),$r(so),$r(Hi),$r(ro)],exports.Leaf);const{setByListWithHandle:mo}=j,{sort:yo}=mi,{localBoxBounds:xo,localEventBounds:vo,localRenderBounds:Eo,maskLocalBoxBounds:wo,maskLocalEventBounds:bo,maskLocalRenderBounds:Co}=fi;exports.Branch=class extends exports.Leaf{constructor(){super(),this.isBranch=!0,this.children=[]}__updateStrokeSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.strokeSpread)return 1;return 0}__updateRenderSpread(){const{children:t}=this;for(let e=0,s=t.length;e<s;e++)if(t[e].__layout.renderSpread)return 1;return 0}__updateBoxBounds(){mo(this.__layout.boxBounds,this.children,this.__hasMask?wo:xo)}__updateStrokeBounds(){mo(this.__layout.strokeBounds,this.children,this.__hasMask?bo:vo)}__updateRenderBounds(){mo(this.__layout.renderBounds,this.children,this.__hasMask?Co:Eo)}__updateSortChildren(){let t;const{children:e}=this;if(e.length>1){for(let s=0,r=e.length;s<r;s++)e[s].__tempNumber=s,e[s].__.zIndex&&(t=!0);e.sort(yo),this.__layout.affectChildrenSort=t}}add(t,e){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),t.__layout.boundsChanged||t.__layout.positionChange(),t.__parentWait&&vi.run(t.__parentWait),this.leafer&&(t.__bindLeafer(this.leafer),this.leafer.created&&this.__emitChildEvent(Pr.ADD,t)),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}addMany(...t){t.forEach((t=>this.add(t)))}remove(t,e){if(t){const s=this.children.indexOf(t);s>-1&&(this.children.splice(s,1),t.isBranch&&(this.__.__childBranchNumber=(this.__.__childBranchNumber||1)-1),this.__preRemove(),this.__realRemoveChild(t),e&&t.destroy())}else void 0===t&&super.remove(null,e)}removeAll(t){const{children:e}=this;e.length&&(this.children=[],this.__preRemove(),this.__.__childBranchNumber=0,e.forEach((e=>{this.__realRemoveChild(e),t&&e.destroy()})))}__preRemove(){this.__hasMask&&this.__updateMask(),this.__hasEraser&&this.__updateEraser(),this.__layout.boxChange(),this.__layout.affectChildrenSort&&this.__layout.childrenSortChange()}__realRemoveChild(t){t.parent=null,this.leafer&&(t.__bindLeafer(null),this.leafer.created&&(this.__emitChildEvent(Pr.REMOVE,t),this.leafer.hitCanvasManager&&this.leafer.hitCanvasManager.clear()))}__emitChildEvent(t,e){const s=new Pr(t,e,this);e.hasEvent(t)&&e.emitEvent(s),this.hasEvent(t)&&!this.isLeafer&&this.emitEvent(s),this.leafer.emitEvent(s)}},exports.Branch=ct([$r(oo),$r(io)],exports.Branch);const To=K.get("plugin"),Oo={power:{},list:[],onLeafer(t){Oo.list.forEach((e=>{e.onLeafer&&e.onLeafer(t)}))}};exports.AnimateEvent=Sr,exports.AutoBounds=class{constructor(t,e,s,r,i,o){"object"==typeof t?this.copy(t):this.set(t,e,s,r,i,o)}set(t=0,e=0,s=0,r=0,i=0,o=0){this.top=t,this.right=e,this.bottom=s,this.left=r,this.width=i,this.height=o}copy(t){const{top:e,right:s,bottom:r,left:i,width:o,height:n}=t;this.set(e,s,r,i,o,n)}getBoundsFrom(t){const{top:e,right:s,bottom:r,left:i,width:o,height:n}=this;return new V(i,e,o||t.width-i-s,n||t.height-e-r)}},exports.BezierHelper=Zt,exports.Bounds=V,exports.BoundsHelper=j,exports.BranchHelper=mi,exports.BranchRender=oo,exports.CanvasManager=ot,exports.ChildEvent=Pr,exports.Creator=e,exports.Cursor=Wi,exports.DataHelper=at,exports.Debug=K,exports.EllipseHelper=ie,exports.Event=Or,exports.EventCreator=rt,exports.FileHelper=dt,exports.HitCanvasManager=class extends ot{constructor(){super(...arguments),this.pathTypeList=new nt,this.imageTypeList=new nt}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.length&&(t.forEach((t=>{t.__hitCanvas&&(t.__hitCanvas.destroy(),t.__hitCanvas=null)})),t.reset())}clear(){this.clearPathType(),this.clearImageType()}},exports.ImageEvent=kr,exports.ImageManager=wr,exports.IncrementId=s,exports.InteractionBase=class{get dragging(){return this.dragger.dragging}get moveMode(){return Nr.isHoldSpaceKey()&&this.config.move.holdSpaceKey||this.downData&&Xr.middle(this.downData)}get hitRadius(){return this.config.pointer.hitRadius}constructor(e,s,r,i){this.config={wheel:{zoomMode:!1,zoomSpeed:.5,moveSpeed:.5,rotateSpeed:.5,delta:"Windows"===t.os?{x:37.5,y:37.5}:{x:20,y:8},preventDefault:!0},pointer:{hitRadius:5,through:!1,tapTime:120,longPressTime:800,transformTime:500,dragHover:!0,dragDistance:2,swipeDistance:20,ignoreMove:!1},cursor:{}},this.tapCount=0,this.downKeyMap={},this.target=e,this.canvas=s,this.selector=r,this.defaultPath=new nt(e),this.transformer=new ri(this),this.dragger=new Pi(this),i&&(this.config=at.default(i,this.config)),this.__listenEvents()}start(){this.running=!0}stop(){this.running=!1}receive(t){}pointerDown(t,e){t||(t=this.hoverData),t&&(Xr.defaultLeft(t),this.emit(exports.PointerEvent.BEFORE_DOWN,t,this.defaultPath),this.updateDownData(t),e&&(t.path=this.defaultPath),this.emit(exports.PointerEvent.DOWN,t),this.downTime=Date.now(),this.dragger.setDragData(t),Xr.left(t)&&(this.tapWait(),this.longPressWait(t)),this.updateCursor(t))}pointerMove(t){if(t||(t=this.hoverData),!t)return;this.downData&&Xr.defaultLeft(t);const e=this.canvas.bounds.hitPoint(t);(e||this.downData)&&(e&&!this.downData&&Xr.left(t)&&this.pointerDown(t,!0),this.pointerMoveReal(t),this.dragger.checkDragOut(t))}pointerMoveReal(t){if(this.emit(exports.PointerEvent.BEFORE_MOVE,t,this.defaultPath),this.downData){const e=T.getDistance(this.downData,t)>this.config.pointer.dragDistance;this.waitTap&&e&&this.pointerWaitCancel(),this.dragger.checkDrag(t,e)}this.dragger.moving||this.config.pointer.ignoreMove||(this.updateHoverData(t),this.emit(exports.PointerEvent.MOVE,t),this.pointerOverOrOut(t),this.pointerEnterOrLeave(t),this.dragger.dragging&&(this.dragger.dragOverOrOut(t),this.dragger.dragEnterOrLeave(t)),this.updateCursor(t))}pointerUp(t){t||(t=this.downData),this.downData&&(Xr.defaultLeft(t),this.emit(exports.PointerEvent.BEFORE_UP,t,this.defaultPath),this.findPath(t),this.emit(exports.PointerEvent.UP,t),this.emit(exports.PointerEvent.UP,this.downData,void 0,t.path),this.touchLeave(t),this.tap(t),this.dragger.dragEnd(t),this.downData=null,this.updateCursor(t))}pointerCancel(){this.pointerUp(this.dragger.dragData)}multiTouch(t,e){const{move:s,angle:r,scale:i,center:o}=Li.getData(e);this.rotate(Ai(o,r,t)),this.zoom(Ii(o,i,t)),this.move(Si(o,s,t))}move(t){this.transformer.move(t)}zoom(t){this.transformer.zoom(t)}rotate(t){this.transformer.rotate(t)}transformEnd(){this.transformer.transformEnd()}keyDown(t){const{code:e}=t;this.downKeyMap[e]||(this.downKeyMap[e]=!0,Nr.setDownCode(e),this.emit(exports.KeyEvent.HOLD,t,this.defaultPath),this.moveMode&&this.updateCursor()),this.emit(exports.KeyEvent.DOWN,t,this.defaultPath)}keyUp(t){const{code:e}=t;this.downKeyMap[e]=!1,Nr.setUpCode(e),this.emit(exports.KeyEvent.UP,t,this.defaultPath),"grab"===this.cursor&&this.updateCursor()}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(exports.PointerEvent.OUT,t,this.overPath),this.emit(exports.PointerEvent.OVER,t,e)):this.emit(exports.PointerEvent.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(exports.PointerEvent.LEAVE,t,this.enterPath,e),this.emit(exports.PointerEvent.ENTER,t,e,this.enterPath),this.enterPath=e}touchLeave(t){"touch"===t.pointerType&&this.enterPath&&(this.emit(exports.PointerEvent.LEAVE,t),this.dragger.dragging&&this.emit(exports.DropEvent.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 r=Date.now()-this.downTime,i=[exports.PointerEvent.DOUBLE_TAP,exports.PointerEvent.DOUBLE_CLICK].some((e=>Mi(t.path,e)));r<e.tapTime+50&&i?(this.tapCount++,2===this.tapCount?(this.tapWaitCancel(),this.emitDoubleTap(t)):(clearTimeout(this.tapTimer),this.tapTimer=setTimeout((()=>{e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}),e.tapTime))):e.tapMore||(this.tapWaitCancel(),this.emitTap(t))}findPath(t,e){const{hitRadius:s,through:r}=this.config.pointer,i=this.selector.getByPoint(t,s,e||{through:r});return i.throughPath&&(t.throughPath=i.throughPath),t.path=i.path,i.path}updateDownData(t){t||(t=this.downData),t&&(this.findPath(t),this.downData=t)}updateHoverData(t){t||(t=this.hoverData),t&&(this.findPath(t,{exclude:this.dragger.getDragList(),name:exports.PointerEvent.MOVE}),this.hoverData=t)}updateCursor(t){if(this.config.cursor.stop)return;if(t||(this.updateHoverData(),t=this.hoverData),this.dragger.moving)return this.setCursor("grabbing");if(this.moveMode)return this.setCursor(this.downData?"grabbing":"grab");if(!t||this.dragger.dragging)return;let e,s;const{path:r}=t;for(let t=0,i=r.length;t<i&&(e=r.list[t],s=e.cursor,!s);t++);this.setCursor(s)}setCursor(t){this.cursor=t,this.canvas.setCursor(t)}emitTap(t){this.emit(exports.PointerEvent.TAP,t),this.emit(exports.PointerEvent.CLICK,t)}emitDoubleTap(t){this.emit(exports.PointerEvent.DOUBLE_TAP,t),this.emit(exports.PointerEvent.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(exports.PointerEvent.LONG_PRESS,t)}),this.config.pointer.longPressTime)}longTap(t){let e;return this.longPressed&&(this.emit(exports.PointerEvent.LONG_TAP,t),Mi(t.path,exports.PointerEvent.LONG_TAP)&&(e=!0)),this.longPressWaitCancel(),e}longPressWaitCancel(){clearTimeout(this.longPressTimer),this.longPressed=!1}__onResize(){this.shrinkCanvasBounds=new V(this.canvas.bounds),this.shrinkCanvasBounds.spread(-2)}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(Dr.RESIZE,this.__onResize,this)],t.once(Ar.READY,(()=>this.__onResize()))}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}emit(t,e,s,r){this.running&&function(t,e,s,r){if(!s&&!e.path)return;let i;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(i=s.list[o],Di(i,t,e,!0,r))return;i.isApp&&ki(i,t,e,!0,r)}for(let o=0,n=s.length;o<n;o++)if(i=s.list[o],i.isApp&&ki(i,t,e,!1,r),Di(i,t,e,!1,r))return}(t,e,s,r)}destroy(){this.__eventIds.length&&(this.stop(),this.__removeListenEvents(),this.dragger.destroy(),this.transformer.destroy(),this.downData=this.overPath=this.enterPath=null)}},exports.InteractionHelper=Ei,exports.Keyboard=Nr,exports.LayoutEvent=Mr,exports.LeafBounds=Qi,exports.LeafBoundsHelper=fi,exports.LeafData=lt,exports.LeafDataProxy=Ui,exports.LeafEventer=Hi,exports.LeafHelper=ci,exports.LeafHit=so,exports.LeafLayout=Xi,exports.LeafLevelList=class{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,r=e.length;s<r;s++)t(e[s])}))}reset(){this.levelMap={},this.keys={},this.levels=[],this._length=0}destroy(){this.levelMap=null}},exports.LeafList=nt,exports.LeafMask=io,exports.LeafMatrix=Ki,exports.LeafRender=ro,exports.LeaferCanvasBase=class extends mt{get pixelWidth(){return this.width*this.pixelRatio}get pixelHeight(){return this.height*this.pixelRatio}get allowBackgroundColor(){return this.view&&this.parentView}constructor(e,r){super(),this.worldTransform={},e||(e=xt),e.pixelRatio||(e.pixelRatio=t.devicePixelRatio),this.manager=r,this.innerId=s.create(s.CNAVAS);const{width:i,height:o,pixelRatio:n}=e;this.autoLayout=!i||!o,this.pixelRatio=n,this.config=e,this.init()}init(){}__createContext(){this.context=this.view.getContext("2d"),this.__bindContext()}toBlob(e,s){return new Promise((r=>{const i=this.getSaveCanvas(e);t.origin.canvasToBolb(i.view,e,s).then((t=>{i.recycle(),r(t)})).catch((t=>{vt.error(t),r(null)}))}))}toDataURL(e,s){const r=this.getSaveCanvas(e),i=t.origin.canvasToDataURL(r.view,e,s);return r.recycle(),i}saveAs(e,s){return new Promise((r=>{const i=this.getSaveCanvas(dt.fileType(e));t.origin.canvasSaveAs(i.view,e,s).then((()=>{i.recycle(),r(!0)})).catch((t=>{vt.error(t),r(!1)}))}))}getSaveCanvas(t){const{backgroundColor:e,bounds:s}=this,r=this.getSameCanvas();return["jpg","jpeg"].includes(t)&&r.fillWorld(s,"#FFFFFF"),e&&r.fillWorld(s,e),r.copyWorld(this),r}resize(t){if(this.isSameSize(t))return;let e;this.context&&!this.unreal&&this.width&&(e=this.getSameCanvas(),e.copyWorld(this)),at.copyAttrs(this,t,Et),this.bounds=new V(0,0,this.width,this.height),this.pixelRatio||(this.pixelRatio=1),this.unreal||(this.updateViewSize(),this.smooth=this.config.smooth),this.updateClientBounds(),this.context&&!this.unreal&&e&&(this.clearWorld(e.bounds),this.copyWorld(e),e.recycle())}updateViewSize(){}updateClientBounds(){}startAutoLayout(t,e){}stopAutoLayout(){}setCursor(t){}setWorld(t,e,s){const{pixelRatio:r}=this,i=this.worldTransform;if(e)if(s)this.setTransform(i.a=t.a*r,i.b=t.b*r,i.c=t.c*r,i.d=t.d*r,i.e=(t.e+e.e)*r,i.f=(t.f+e.f)*r);else{const{a:s,b:o,c:n,d:a,e:h,f:l}=e;this.setTransform(i.a=(t.a*s+t.b*n)*r,i.b=(t.a*o+t.b*a)*r,i.c=(t.c*s+t.d*n)*r,i.d=(t.c*o+t.d*a)*r,i.e=(t.e*s+t.f*n+h)*r,i.f=(t.e*o+t.f*a+l)*r)}else this.setTransform(i.a=t.a*r,i.b=t.b*r,i.c=t.c*r,i.d=t.d*r,i.e=t.e*r,i.f=t.f*r)}useWorldTransform(t){t&&(this.worldTransform=t);const e=this.worldTransform;e&&this.setTransform(e.a,e.b,e.c,e.d,e.e,e.f)}setStroke(t,e,s){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 e?this.context.isPointInPath(t.x,t.y,e):this.context.isPointInPath(t.x,t.y)}hitStroke(t,e){return this.strokeWidth=e,this.context.isPointInStroke(t.x,t.y)}setWorldShadow(t,e,s,r){const{pixelRatio:i}=this;this.shadowOffsetX=t*i,this.shadowOffsetY=e*i,this.shadowBlur=s*i,this.shadowColor=r||"black"}setWorldBlur(t){const{pixelRatio:e}=this;this.filter=`blur(${t*e}px)`}copyWorld(t,e,s,r){if(r&&(this.blendMode=r),e){const{pixelRatio:r}=this;s||(s=e),this.drawImage(t.view,e.x*r,e.y*r,e.width*r,e.height*r,s.x*r,s.y*r,s.width*r,s.height*r)}else this.drawImage(t.view,0,0);r&&(this.blendMode="source-over")}copyWorldToInner(t,e,s,r){if(r&&(this.blendMode=r),e.b||e.c)this.save(),this.resetTransform(),this.copyWorld(t,e,j.tempToOuterOf(s,e)),this.restore();else{const{pixelRatio:r}=this;this.drawImage(t.view,e.x*r,e.y*r,e.width*r,e.height*r,s.x,s.y,s.width,s.height)}r&&(this.blendMode="source-over")}copyWorldByReset(t,e,s,r){this.resetTransform(),this.copyWorld(t,e,s,r),this.useWorldTransform()}useMask(t,e,s){this.copyWorld(t,e,s,"destination-in")}useEraser(t,e,s){this.copyWorld(t,e,s,"destination-out")}fillWorld(t,e,s){s&&(this.blendMode=s),this.fillStyle=e,yt.copy(t).scale(this.pixelRatio),this.fillRect(yt.x,yt.y,yt.width,yt.height),s&&(this.blendMode="source-over")}strokeWorld(t,e,s){s&&(this.blendMode=s),this.strokeStyle=e,yt.copy(t).scale(this.pixelRatio),this.strokeRect(yt.x,yt.y,yt.width,yt.height),s&&(this.blendMode="source-over")}clearWorld(t,e){yt.copy(t).scale(this.pixelRatio),e&&yt.ceil(),this.clearRect(yt.x,yt.y,yt.width,yt.height)}clipWorld(t,e){this.beginPath(),yt.copy(t).scale(this.pixelRatio),e&&yt.ceil(),this.rect(yt.x,yt.y,yt.width,yt.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:s,height:r,pixelRatio:i}=this,o={width:s,height:r,pixelRatio:i},n=this.manager?this.manager.get(o):e.canvas(o);return n.save(),t&&n.useWorldTransform(Object.assign({},this.worldTransform)),n}getBiggerCanvas(t,s){let{width:r,height:i,pixelRatio:o}=this;t&&(r+=t),s&&(i+=s);const n={width:r,height:i,pixelRatio:o},a=this.manager?this.manager.get(n):e.canvas(n);return a.save(),a}recycle(){this.recycled||(this.restore(),this.manager?this.manager.recycle(this):this.destroy())}updateRender(){}unrealCanvas(){}destroy(){this.manager=this.view=this.parentView=null}},exports.LeaferEvent=Ar,exports.LeaferImage=class{get url(){return this.config.url}get completed(){return this.ready||!!this.error}constructor(t){this.use=0,this.waitComplete=[],this.innerId=Tr(Cr),this.config=t||{url:""};const{url:e}=t;e.startsWith("data:")?e.startsWith("data:image/svg")&&(this.isSVG=!0):e.includes(".svg")&&(this.isSVG=!0),"svg"===this.config.format&&(this.isSVG=!0)}load(e,s){return this.loading||(this.loading=!0,wr.tasker.add((()=>ut(this,void 0,void 0,(function*(){return yield t.origin.loadImage(this.url).then((t=>{this.ready=!0,this.width=t.naturalWidth||t.width,this.height=t.naturalHeight||t.height,this.view=t,this.onComplete(!0)})).catch((t=>{this.error=t,this.onComplete(!1)}))}))))),this.waitComplete.push(e,s),this.waitComplete.length-2}unload(t,e){const s=this.waitComplete;if(e){const e=s[t+1];e&&e({type:"stop"})}s[t]=s[t+1]=void 0}onComplete(t){let e;this.waitComplete.forEach(((s,r)=>{e=r%2,s&&(t?e||s(this):e&&s(this.error))})),this.waitComplete.length=0,this.loading=!1}getCanvas(e,s,r,i){e||(e=this.width),s||(s=this.height);const o=t.origin.createCanvas(e,s),n=o.getContext("2d");return r&&(n.globalAlpha=r),n.drawImage(this.view,0,0,e,s),o}destroy(){this.config={url:""},this.waitComplete.length=0}},exports.MathHelper=i,exports.Matrix=B,exports.MatrixHelper=f,exports.MultiTouchHelper=Li,exports.NeedConvertToCanvasCommandMap=Ot,exports.OneRadian=o,exports.PI2=n,exports.PI_2=a,exports.PathBounds=fr,exports.PathCommandDataHelper=ns,exports.PathCommandMap=Ct,exports.PathConvert=je,exports.PathCorner=mr,exports.PathCreator=bs,exports.PathDrawer=Ns,exports.PathHelper=wt,exports.PathNumberCommandLengthMap=Dt,exports.PathNumberCommandMap=kt,exports.Platform=t,exports.PluginManager=Oo,exports.Point=P,exports.PointHelper=T,exports.PointerButton=Xr,exports.PropertyEvent=Br,exports.RectHelper=Rt,exports.RenderEvent=Ir,exports.ResizeEvent=Dr,exports.Run=Q,exports.StringNumberMap=G,exports.TaskItem=vr,exports.TaskProcessor=Er,exports.TransformEvent=Rr,exports.TwoPointBounds=class{constructor(t,e){k.setPoint(this,t,e)}addPoint(t,e){k.addPoint(this,t,e)}addBounds(t,e,s,r){k.addBounds(this,t,e,s,r)}add(t){k.add(this,t)}},exports.TwoPointBoundsHelper=k,exports.UICreator=tt,exports.UIEvent=Yr,exports.WaitHelper=vi,exports.WatchEvent=Lr,exports.affectRenderBoundsType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.renderChanged||this.__layout.renderChange()}})}},exports.affectStrokeBoundsType=Vr,exports.aliasType=function(t){return(e,s)=>{Hr(e,s,{get(){return this.__getAttr(t)},set(e){this.__setAttr(t,e)}})}},exports.boundsType=zr,exports.canvasPatch=function(t){!function(t){t&&!t.roundRect&&(t.roundRect=function(t,e,s,r,i){yr(this,t,e,s,r,i)})}(t)},exports.canvasSizeAttrs=Et,exports.cursorType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.leafer&&this.leafer.updateCursor()}})}},exports.dataProcessor=function(t){return(e,s)=>{Hr(e,"__DataProcessor",{get:()=>t})}},exports.dataType=function(t){return(e,s)=>{Ur(e,s,t)}},exports.defineDataProcessor=Kr,exports.defineKey=Hr,exports.defineLeafAttr=Ur,exports.eraserType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.waitParent((()=>{this.parent.__updateEraser(t)}))}})}},exports.getDescriptor=jr,exports.hitType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),K.showHitView&&(this.__layout.surfaceChanged||this.__layout.surfaceChange()),this.leafer&&this.leafer.updateCursor()}})}},exports.layoutProcessor=function(t){return(e,s)=>{Hr(e,"__LayoutProcessor",{get:()=>t})}},exports.maskType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.waitParent((()=>{this.parent.__updateMask(t)}))}})}},exports.opacityType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.opacityChanged||this.__layout.opacityChange()}})}},exports.pathType=Fr,exports.positionType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.positionChanged||this.__layout.positionChange()}})}},exports.registerUI=function(){return t=>{tt.register(t)}},exports.registerUIEvent=ti,exports.rewrite=function(t){return(e,s)=>{qr.push({name:e.constructor.name+"."+s,run:()=>{e[s]=t}})}},exports.rewriteAble=function(){return t=>{Jr()}},exports.rotationType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.rotationChanged||this.__layout.rotationChange()}})}},exports.scaleType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.scaleChanged||this.__layout.scaleChange()}})}},exports.setDefaultValue=function(t,e,s){Kr(t.prototype,e,s)},exports.sortType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange(),this.waitParent((()=>{this.parent.__layout.childrenSortChange()}))}})}},exports.strokeType=Gr,exports.surfaceType=function(t){return(e,s)=>{Ur(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.surfaceChanged||this.__layout.surfaceChange()}})}},exports.useModule=$r,exports.usePlugin=function(t,e){const s={},{power:r,list:i}=Oo;if(r||To.error("need add PluginManager.power = LeaferUI"),i.includes(t))To.warn("repeat run",t.name);else{i.push(t),t.import?t.import.forEach((t=>{r[t]?s[t]=r[t]:To.error(t+" non-existent")})):To.warn("no import");try{t.run(s,e)}catch(t){To.error(t)}}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/core",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.4",
4
4
  "description": "@leafer/core",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -28,25 +28,25 @@
28
28
  "leaferjs"
29
29
  ],
30
30
  "dependencies": {
31
- "@leafer/interaction": "1.0.0-rc.3",
32
- "@leafer/canvas": "1.0.0-rc.3",
33
- "@leafer/image": "1.0.0-rc.3",
34
- "@leafer/data": "1.0.0-rc.3",
35
- "@leafer/debug": "1.0.0-rc.3",
36
- "@leafer/decorator": "1.0.0-rc.3",
37
- "@leafer/display": "1.0.0-rc.3",
38
- "@leafer/display-module": "1.0.0-rc.3",
39
- "@leafer/event": "1.0.0-rc.3",
40
- "@leafer/event-ui": "1.0.0-rc.3",
41
- "@leafer/file": "1.0.0-rc.3",
42
- "@leafer/helper": "1.0.0-rc.3",
43
- "@leafer/layout": "1.0.0-rc.3",
44
- "@leafer/list": "1.0.0-rc.3",
45
- "@leafer/math": "1.0.0-rc.3",
46
- "@leafer/path": "1.0.0-rc.3",
47
- "@leafer/platform": "1.0.0-rc.3",
48
- "@leafer/plugin": "1.0.0-rc.3",
49
- "@leafer/task": "1.0.0-rc.3",
50
- "@leafer/interface": "1.0.0-rc.3"
31
+ "@leafer/interaction": "1.0.0-rc.4",
32
+ "@leafer/canvas": "1.0.0-rc.4",
33
+ "@leafer/image": "1.0.0-rc.4",
34
+ "@leafer/data": "1.0.0-rc.4",
35
+ "@leafer/debug": "1.0.0-rc.4",
36
+ "@leafer/decorator": "1.0.0-rc.4",
37
+ "@leafer/display": "1.0.0-rc.4",
38
+ "@leafer/display-module": "1.0.0-rc.4",
39
+ "@leafer/event": "1.0.0-rc.4",
40
+ "@leafer/event-ui": "1.0.0-rc.4",
41
+ "@leafer/file": "1.0.0-rc.4",
42
+ "@leafer/helper": "1.0.0-rc.4",
43
+ "@leafer/layout": "1.0.0-rc.4",
44
+ "@leafer/list": "1.0.0-rc.4",
45
+ "@leafer/math": "1.0.0-rc.4",
46
+ "@leafer/path": "1.0.0-rc.4",
47
+ "@leafer/platform": "1.0.0-rc.4",
48
+ "@leafer/plugin": "1.0.0-rc.4",
49
+ "@leafer/task": "1.0.0-rc.4",
50
+ "@leafer/interface": "1.0.0-rc.4"
51
51
  }
52
52
  }