leafer-draw 1.0.9 → 1.1.0

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/web.js CHANGED
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
111
111
  return rotation - oldRotation;
112
112
  },
113
113
  float(num, maxLength) {
114
- const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
114
+ const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
115
115
  num = round(num * a) / a;
116
116
  return num === -0 ? 0 : num;
117
117
  },
@@ -1414,14 +1414,13 @@ var LeaferUI = (function (exports) {
1414
1414
  list: {},
1415
1415
  register(UI) {
1416
1416
  const { __tag: tag } = UI.prototype;
1417
- if (list$1[tag]) {
1417
+ if (list$1[tag])
1418
1418
  debug$d.repeat(tag);
1419
- }
1420
- else {
1421
- list$1[tag] = UI;
1422
- }
1419
+ list$1[tag] = UI;
1423
1420
  },
1424
1421
  get(tag, data, x, y, width, height) {
1422
+ if (!list$1[tag])
1423
+ debug$d.error('not register ' + tag);
1425
1424
  const ui = new list$1[tag](data);
1426
1425
  if (x !== undefined) {
1427
1426
  ui.x = x;
@@ -1445,7 +1444,7 @@ var LeaferUI = (function (exports) {
1445
1444
  Object.keys(Event).forEach(key => {
1446
1445
  name = Event[key];
1447
1446
  if (typeof name === 'string')
1448
- nameList[name] ? debug$c.repeat(name) : nameList[name] = Event;
1447
+ nameList[name] && debug$c.repeat(name), nameList[name] = Event;
1449
1448
  });
1450
1449
  },
1451
1450
  changeName(oldName, newName) {
@@ -1647,7 +1646,7 @@ var LeaferUI = (function (exports) {
1647
1646
  const t = this;
1648
1647
  if (t.blendMode === 'pass-through') {
1649
1648
  const leaf = this.__leaf;
1650
- if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
1649
+ if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
1651
1650
  t.__single = true;
1652
1651
  }
1653
1652
  else if (t.__single) {
@@ -2045,8 +2044,9 @@ var LeaferUI = (function (exports) {
2045
2044
  takeCanvas = this.getSameCanvas();
2046
2045
  takeCanvas.copyWorld(this);
2047
2046
  }
2048
- DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
2049
- this.size.pixelRatio || (this.size.pixelRatio = 1);
2047
+ const s = this.size;
2048
+ DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2049
+ canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2050
2050
  this.bounds = new Bounds(0, 0, this.width, this.height);
2051
2051
  if (this.context && !this.unreal) {
2052
2052
  this.updateViewSize();
@@ -2160,6 +2160,17 @@ var LeaferUI = (function (exports) {
2160
2160
  if (!onlyResetTransform)
2161
2161
  this.useWorldTransform();
2162
2162
  }
2163
+ useGrayscaleAlpha(bounds) {
2164
+ this.setTempBounds(bounds, true, true);
2165
+ let alpha, pixel;
2166
+ const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
2167
+ for (let i = 0, len = data.length; i < len; i += 4) {
2168
+ pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
2169
+ if (alpha = data[i + 3])
2170
+ data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
2171
+ }
2172
+ context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
2173
+ }
2163
2174
  useMask(maskCanvas, fromBounds, toBounds) {
2164
2175
  this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
2165
2176
  }
@@ -2170,7 +2181,7 @@ var LeaferUI = (function (exports) {
2170
2181
  if (blendMode)
2171
2182
  this.blendMode = blendMode;
2172
2183
  this.fillStyle = color;
2173
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2184
+ this.setTempBounds(bounds);
2174
2185
  this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2175
2186
  if (blendMode)
2176
2187
  this.blendMode = 'source-over';
@@ -2179,22 +2190,18 @@ var LeaferUI = (function (exports) {
2179
2190
  if (blendMode)
2180
2191
  this.blendMode = blendMode;
2181
2192
  this.strokeStyle = color;
2182
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2193
+ this.setTempBounds(bounds);
2183
2194
  this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2184
2195
  if (blendMode)
2185
2196
  this.blendMode = 'source-over';
2186
2197
  }
2187
2198
  clearWorld(bounds, ceilPixel) {
2188
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2189
- if (ceilPixel)
2190
- tempBounds$1.ceil();
2199
+ this.setTempBounds(bounds, ceilPixel);
2191
2200
  this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2192
2201
  }
2193
2202
  clipWorld(bounds, ceilPixel) {
2194
2203
  this.beginPath();
2195
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2196
- if (ceilPixel)
2197
- tempBounds$1.ceil();
2204
+ this.setTempBounds(bounds, ceilPixel);
2198
2205
  this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2199
2206
  this.clip();
2200
2207
  }
@@ -2202,6 +2209,14 @@ var LeaferUI = (function (exports) {
2202
2209
  const { pixelRatio } = this;
2203
2210
  this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2204
2211
  }
2212
+ setTempBounds(bounds, ceil, intersect) {
2213
+ tempBounds$1.set(bounds);
2214
+ if (intersect)
2215
+ tempBounds$1.intersect(this.bounds);
2216
+ tempBounds$1.scale(this.pixelRatio);
2217
+ if (ceil)
2218
+ tempBounds$1.ceil();
2219
+ }
2205
2220
  isSameSize(size) {
2206
2221
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
2207
2222
  }
@@ -4153,20 +4168,17 @@ var LeaferUI = (function (exports) {
4153
4168
  }
4154
4169
  return true;
4155
4170
  },
4156
- moveWorld(t, x, y = 0, isInnerPoint) {
4171
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4157
4172
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4158
4173
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4159
- L.moveLocal(t, local.x, local.y);
4174
+ L.moveLocal(t, local.x, local.y, transition);
4160
4175
  },
4161
- moveLocal(t, x, y = 0) {
4162
- if (typeof x === 'object') {
4163
- t.x += x.x;
4164
- t.y += x.y;
4165
- }
4166
- else {
4167
- t.x += x;
4168
- t.y += y;
4169
- }
4176
+ moveLocal(t, x, y = 0, transition) {
4177
+ if (typeof x === 'object')
4178
+ y = x.y, x = x.x;
4179
+ x += t.x;
4180
+ y += t.y;
4181
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4170
4182
  },
4171
4183
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4172
4184
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -5215,13 +5227,14 @@ var LeaferUI = (function (exports) {
5215
5227
  this.__.__checkSingle();
5216
5228
  },
5217
5229
  __render(canvas, options) {
5230
+ this.__nowWorld = this.__getNowWorld(options);
5218
5231
  if (this.__worldOpacity) {
5219
5232
  if (this.__.__single) {
5220
5233
  if (this.__.eraser === 'path')
5221
5234
  return this.__renderEraser(canvas, options);
5222
5235
  const tempCanvas = canvas.getSameCanvas(false, true);
5223
5236
  this.__renderBranch(tempCanvas, options);
5224
- const nowWorld = this.__getNowWorld(options);
5237
+ const nowWorld = this.__nowWorld;
5225
5238
  canvas.opacity = this.__.opacity;
5226
5239
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
5227
5240
  tempCanvas.recycle(nowWorld);
@@ -5545,11 +5558,11 @@ var LeaferUI = (function (exports) {
5545
5558
  transform(matrix, resize) {
5546
5559
  transform(this, matrix, resize);
5547
5560
  }
5548
- move(x, y) {
5549
- moveLocal(this, x, y);
5561
+ move(x, y, transition) {
5562
+ moveLocal(this, x, y, transition);
5550
5563
  }
5551
- moveInner(x, y) {
5552
- moveWorld(this, x, y, true);
5564
+ moveInner(x, y, transition) {
5565
+ moveWorld(this, x, y, true, transition);
5553
5566
  }
5554
5567
  scaleOf(origin, scaleX, scaleY, resize) {
5555
5568
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5563,8 +5576,8 @@ var LeaferUI = (function (exports) {
5563
5576
  transformWorld(worldTransform, resize) {
5564
5577
  transformWorld(this, worldTransform, resize);
5565
5578
  }
5566
- moveWorld(x, y) {
5567
- moveWorld(this, x, y);
5579
+ moveWorld(x, y, transition) {
5580
+ moveWorld(this, x, y, false, transition);
5568
5581
  }
5569
5582
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5570
5583
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5962,7 +5975,7 @@ var LeaferUI = (function (exports) {
5962
5975
  }
5963
5976
  }
5964
5977
 
5965
- const version = "1.0.9";
5978
+ const version = "1.1.0";
5966
5979
 
5967
5980
  const debug$5 = Debug.get('LeaferCanvas');
5968
5981
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6604,7 +6617,8 @@ var LeaferUI = (function (exports) {
6604
6617
  this.totalBounds = new Bounds();
6605
6618
  debug$3.log(target.innerName, '--->');
6606
6619
  try {
6607
- target.app.emit(RenderEvent.CHILD_START, target);
6620
+ if (!target.isApp)
6621
+ target.app.emit(RenderEvent.CHILD_START, target);
6608
6622
  this.emitRender(RenderEvent.START);
6609
6623
  this.renderOnce(callback);
6610
6624
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6885,6 +6899,12 @@ var LeaferUI = (function (exports) {
6885
6899
  return strokeWidth;
6886
6900
  }
6887
6901
  get __hasStroke() { return this.stroke && this.strokeWidth; }
6902
+ get __hasMultiPaint() {
6903
+ const t = this;
6904
+ if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
6905
+ return true;
6906
+ return t.fill && this.__hasStroke;
6907
+ }
6888
6908
  get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
6889
6909
  get __autoWidth() { return !this._width; }
6890
6910
  get __autoHeight() { return !this._height; }
@@ -7254,9 +7274,8 @@ var LeaferUI = (function (exports) {
7254
7274
  canvas.strokeRect(half, half, width, height);
7255
7275
  canvas.restore();
7256
7276
  }
7257
- else {
7277
+ else
7258
7278
  canvas.strokeRect(half, half, width, height);
7259
- }
7260
7279
  break;
7261
7280
  case 'outside':
7262
7281
  canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
@@ -7286,11 +7305,15 @@ var LeaferUI = (function (exports) {
7286
7305
  super(data);
7287
7306
  }
7288
7307
  reset(_data) { }
7289
- set(data, isTemp) {
7290
- if (isTemp) {
7291
- this.lockNormalStyle = true;
7292
- Object.assign(this, data);
7293
- this.lockNormalStyle = false;
7308
+ set(data, transition) {
7309
+ if (transition) {
7310
+ if (transition === 'temp') {
7311
+ this.lockNormalStyle = true;
7312
+ Object.assign(this, data);
7313
+ this.lockNormalStyle = false;
7314
+ }
7315
+ else
7316
+ this.animate(data, transition);
7294
7317
  }
7295
7318
  else
7296
7319
  Object.assign(this, data);
@@ -7481,6 +7504,15 @@ var LeaferUI = (function (exports) {
7481
7504
  __decorate([
7482
7505
  boundsType(0)
7483
7506
  ], exports.UI.prototype, "padding", void 0);
7507
+ __decorate([
7508
+ boundsType(false)
7509
+ ], exports.UI.prototype, "lockRatio", void 0);
7510
+ __decorate([
7511
+ boundsType()
7512
+ ], exports.UI.prototype, "widthRange", void 0);
7513
+ __decorate([
7514
+ boundsType()
7515
+ ], exports.UI.prototype, "heightRange", void 0);
7484
7516
  __decorate([
7485
7517
  dataType(false)
7486
7518
  ], exports.UI.prototype, "draggable", void 0);
@@ -7591,17 +7623,17 @@ var LeaferUI = (function (exports) {
7591
7623
  if (!this.children)
7592
7624
  this.children = [];
7593
7625
  }
7594
- set(data, isTemp) {
7626
+ set(data, transition) {
7595
7627
  if (data.children) {
7596
7628
  const { children } = data;
7597
7629
  delete data.children;
7598
7630
  this.children ? this.clear() : this.__setBranch();
7599
- super.set(data, isTemp);
7631
+ super.set(data, transition);
7600
7632
  children.forEach(child => this.add(child));
7601
7633
  data.children = children;
7602
7634
  }
7603
7635
  else
7604
- super.set(data, isTemp);
7636
+ super.set(data, transition);
7605
7637
  }
7606
7638
  toJSON(options) {
7607
7639
  const data = super.toJSON(options);
@@ -7714,8 +7746,8 @@ var LeaferUI = (function (exports) {
7714
7746
  }
7715
7747
  onInit() { }
7716
7748
  initType(_type) { }
7717
- set(data) {
7718
- this.waitInit(() => { super.set(data); });
7749
+ set(data, transition) {
7750
+ this.waitInit(() => { super.set(data, transition); });
7719
7751
  }
7720
7752
  start() {
7721
7753
  clearTimeout(this.__startTimer);
@@ -7772,8 +7804,6 @@ var LeaferUI = (function (exports) {
7772
7804
  __onResize(event) {
7773
7805
  this.emitEvent(event);
7774
7806
  DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
7775
- if (!event.width || !event.height)
7776
- debug$1.warn('w = 0 or h = 0');
7777
7807
  setTimeout(() => { if (this.canvasManager)
7778
7808
  this.canvasManager.clearRecycled(); }, 0);
7779
7809
  }
@@ -8098,9 +8128,6 @@ var LeaferUI = (function (exports) {
8098
8128
  __decorate([
8099
8129
  dataType(false)
8100
8130
  ], exports.Box.prototype, "resizeChildren", void 0);
8101
- __decorate([
8102
- dataType(false)
8103
- ], exports.Box.prototype, "textBox", void 0);
8104
8131
  __decorate([
8105
8132
  affectRenderBoundsType('show')
8106
8133
  ], exports.Box.prototype, "overflow", void 0);
@@ -8815,6 +8842,8 @@ var LeaferUI = (function (exports) {
8815
8842
  case 'center':
8816
8843
  canvas.setStroke(stroke, __strokeWidth, options);
8817
8844
  canvas.stroke();
8845
+ if (options.__useArrow)
8846
+ strokeArrow(ui, canvas);
8818
8847
  break;
8819
8848
  case 'inside':
8820
8849
  canvas.save();
@@ -8852,6 +8881,8 @@ var LeaferUI = (function (exports) {
8852
8881
  case 'center':
8853
8882
  canvas.setStroke(undefined, __strokeWidth, options);
8854
8883
  drawStrokesStyle(strokes, false, ui, canvas);
8884
+ if (options.__useArrow)
8885
+ strokeArrow(ui, canvas);
8855
8886
  break;
8856
8887
  case 'inside':
8857
8888
  canvas.save();
@@ -8877,6 +8908,14 @@ var LeaferUI = (function (exports) {
8877
8908
  }
8878
8909
  }
8879
8910
  }
8911
+ function strokeArrow(ui, canvas) {
8912
+ if (ui.__.dashPattern) {
8913
+ canvas.beginPath();
8914
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
8915
+ canvas.dashPattern = null;
8916
+ canvas.stroke();
8917
+ }
8918
+ }
8880
8919
 
8881
8920
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
8882
8921
  function shape(ui, current, options) {
@@ -9562,16 +9601,16 @@ var LeaferUI = (function (exports) {
9562
9601
 
9563
9602
  const { excludeRenderBounds } = LeafBoundsHelper;
9564
9603
  exports.Group.prototype.__renderMask = function (canvas, options) {
9565
- let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
9604
+ let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
9566
9605
  const { children } = this;
9567
9606
  for (let i = 0, len = children.length; i < len; i++) {
9568
- child = children[i];
9569
- if (child.__.mask) {
9607
+ child = children[i], mask = child.__.mask;
9608
+ if (mask) {
9570
9609
  if (currentMask) {
9571
9610
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
9572
9611
  maskCanvas = contentCanvas = null;
9573
9612
  }
9574
- if (child.__.mask === 'path') {
9613
+ if (mask === 'path' || mask === 'clipping-path') {
9575
9614
  if (child.opacity < 1) {
9576
9615
  currentMask = 'opacity-path';
9577
9616
  maskOpacity = child.opacity;
@@ -9585,14 +9624,14 @@ var LeaferUI = (function (exports) {
9585
9624
  child.__clip(contentCanvas || canvas, options);
9586
9625
  }
9587
9626
  else {
9588
- currentMask = 'alpha';
9627
+ currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
9589
9628
  if (!maskCanvas)
9590
9629
  maskCanvas = getCanvas(canvas);
9591
9630
  if (!contentCanvas)
9592
9631
  contentCanvas = getCanvas(canvas);
9593
9632
  child.__render(maskCanvas, options);
9594
9633
  }
9595
- if (child.__.mask !== 'clipping')
9634
+ if (!(mask === 'clipping' || mask === 'clipping-path'))
9596
9635
  continue;
9597
9636
  }
9598
9637
  if (excludeRenderBounds(child, options))
@@ -9603,6 +9642,8 @@ var LeaferUI = (function (exports) {
9603
9642
  };
9604
9643
  function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
9605
9644
  switch (maskMode) {
9645
+ case 'grayscale':
9646
+ maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
9606
9647
  case 'alpha':
9607
9648
  usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
9608
9649
  break;
@@ -10307,15 +10348,12 @@ var LeaferUI = (function (exports) {
10307
10348
  const debug = Debug.get('@leafer-ui/export');
10308
10349
  canvas.export = function (filename, options) {
10309
10350
  const { quality, blob } = FileHelper.getExportOptions(options);
10310
- if (filename.includes('.')) {
10351
+ if (filename.includes('.'))
10311
10352
  return this.saveAs(filename, quality);
10312
- }
10313
- else if (blob) {
10353
+ else if (blob)
10314
10354
  return this.toBlob(filename, quality);
10315
- }
10316
- else {
10355
+ else
10317
10356
  return this.toDataURL(filename, quality);
10318
- }
10319
10357
  };
10320
10358
  canvas.toBlob = function (type, quality) {
10321
10359
  return new Promise((resolve) => {
package/dist/web.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:m}=t.LeafHelper,v=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){v.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?v.warn("layouting"):this.times>3?v.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?k(e,!0,i,r):L(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",B(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function L(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function k(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:P,getOuterOf:S,getByMove:C,getIntersectData:A}=t.BoundsHelper;let O;function W(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!O||!O[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const M={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),O=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=W(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?B(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?B(n,i):o?i.fill(o):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),k(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=A(i?P(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=S(s,a),o=C(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let T={};const{get:D,rotateOfOuter:I,translate:H,scaleOfOuter:z,scale:F,rotate:V}=t.MatrixHelper;function Y(t,e,n,i,s,o,a){const r=D();H(r,e.x+n,e.y+i),F(r,s,o),a&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function j(t,e,n,i,s,o,a){const r=D();H(r,e.x+n,e.y+i),s&&F(r,s,o),a&&V(r,a),t.transform=r}function G(t,e,n,i,s,o,a,r,l,d){const c=D();if(l)if("center"===d)I(c,{x:n/2,y:i/2},l);else switch(V(c,l),l){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}T.x=e.x+s,T.y=e.y+o,H(c,T.x,T.y),a&&z(c,T,a,r),t.transform=c}const{get:U,translate:X}=t.MatrixHelper,N=new t.Bounds,q={},Q={};function J(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Z(n,i,e)}function Z(e,n,i){let{width:s,height:o}=i;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,Q),v=Q.scaleX,y=Q.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,q,!0),x+=q.x,b+=q.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&j(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&G(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&Y(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=U(),X(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let $,K=new t.Bounds;const{isSame:tt}=t.BoundsHelper;function et(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||J(s,i,n,o),!0}function nt(e,n){ot(e,t.ImageEvent.LOAD,n)}function it(e,n){ot(e,t.ImageEvent.LOADED,n)}function st(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:rt,scale:lt,copy:dt}=t.MatrixHelper,{ceil:ct,abs:ht}=Math;function ut(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=ht(s),o=ht(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=rt(),dt(d,g),lt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=rt(),g&&dt(d,g)),lt(d,1/s,1/o));const v=e.getCanvas(ct(c)||1,ct(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function ft(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:pt}=Math;const gt={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return $&&i===$.paint&&tt(s,$.boxBounds)?a=$.leafPaint:(a={type:i.type,image:l},$=l.use>1?{leafPaint:a,paint:i,boxBounds:K.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(et(e,n,i,l,a,s),o&&(nt(e,r),it(e,r))):l.error?o&&st(e,r,l.error):(o&&(at(e,!0),nt(e,r)),a.loadId=l.load((()=>{at(e,!1),e.destroyed||(et(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),it(e,r)),a.loadId=null}),(t=>{at(e,!1),st(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=pt(a)*l,i*=pt(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ut(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ft(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ut(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ut,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:J,getPatternData:Z,fillOrFitMode:Y,clipMode:j,repeatMode:G},{toPoint:_t}=t.AroundHelper,wt={},mt={};function vt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:yt,getDistance:xt}=t.PointHelper,{get:bt,rotateOfOuter:Bt,scaleOfOuter:Et}=t.MatrixHelper,{toPoint:Rt}=t.AroundHelper,Lt={},kt={};function Pt(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=yt(e,n);o=bt(),s?(Et(o,e,a/r*(i||1),1),Bt(o,e,t+90)):(Et(o,e,1,a/r*(i||1)),Bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,At={},Ot={};const Wt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;_t(i||"top",n,wt),_t(s||"bottom",n,mt);const l=t.Platform.canvas.createLinearGradient(wt.x,wt.y,mt.x,mt.y);vt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Rt(i||"center",n,Lt),Rt(s||"bottom",n,kt);const d=t.Platform.canvas.createRadialGradient(Lt.x,Lt.y,0,Lt.x,Lt.y,xt(Lt,kt));vt(d,e.stops,a);const c={type:o,style:d},h=Pt(n,Lt,kt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ct(i||"center",n,At),Ct(s||"bottom",n,Ot);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,St(At,Ot));vt(d,e.stops,a);const c={type:o,style:d},h=Pt(n,At,Ot,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Pt},{copy:Mt,toOffsetOutBounds:Tt}=t.BoundsHelper,Dt={},It={};function Ht(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Mt(Dt,e.bounds),Dt.x+=n.x-a.x,Dt.y+=n.y-a.y,i){const{matrix:t}=s;Dt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Dt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Dt.width*=i,Dt.height*=i}e.copyWorld(s.canvas,e.bounds,Dt)}else i&&(Mt(Dt,n),Dt.x-=n.width/2*(i-1),Dt.y-=n.height/2*(i-1),Dt.width*=i,Dt.height*=i),e.copyWorld(s.canvas,a,i?Dt:n)}const{toOffsetOutBounds:zt}=t.BoundsHelper,Ft={};const Vt={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Tt(d,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,It,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;zt(d,Ft),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,Ft,s,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Yt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ut(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ut(t,n,i,o);break;case"path":n.restore()}}function Gt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(a&&(jt(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Gt(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Gt(t)),s||(s=Gt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Yt(n,e)||n.__render(s||t,e);jt(this,a,t,s,i,o)};const Xt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=Xt+"_#~&*+\\=|≮≯≈≠=…",qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Qt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Jt=Qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=Qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$t=Qt(Xt),Kt=Qt(Nt),te=Qt("- —/~|┆·");var ee;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ee||(ee={}));const{Letter:ne,Single:ie,Before:se,After:oe,Symbol:ae,Break:re}=ee;function le(t){return Jt[t]?ne:te[t]?re:Zt[t]?se:$t[t]?oe:Kt[t]?ae:qt.test(t)?ie:ne}const de={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ce(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:he}=de,{Letter:ue,Single:fe,Before:pe,After:ge,Symbol:_e,Break:we}=ee;let me,ve,ye,xe,be,Be,Ee,Re,Le,ke,Pe,Se,Ce,Ae,Oe,We,Me,Te=[];function De(t,e){Le&&!Re&&(Re=Le),me.data.push({char:t,width:e}),ye+=e}function Ie(){xe+=ye,me.width=ye,ve.words.push(me),me={data:[]},ye=0}function He(){Ae&&(Oe.paraNumber++,ve.paraStart=!0,Ae=!1),Le&&(ve.startCharSize=Re,ve.endCharSize=Le,Re=0),ve.width=xe,We.width?he(ve):Me&&ze(),Te.push(ve),ve={words:[]},xe=0}function ze(){xe>(Oe.maxWidth||0)&&(Oe.maxWidth=xe)}const Fe=0,Ve=1,Ye=2;const{top:je,right:Ge,bottom:Ue,left:Xe}=t.Direction4;function Ne(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Xe],o-=d[Ge]+d[Xe]):n.autoSizeAlign||(i=d[Xe]),a?(s=d[je],a-=d[je]+d[Ue]):n.autoSizeAlign||(s=d[je]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Oe=e,Te=e.rows,We=e.bounds,Me=!We.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=We;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,Pe=null,Re=Ee=Le=ye=xe=0,me={data:[]},ve={words:[]};for(let i=0,d=n.length;i<d;i++)Be=n[i],"\n"===Be?(ye&&Ie(),ve.paraEnd=!0,He(),Ae=!0):(ke=le(Be),ke===ue&&"none"!==a&&(Be=ce(Be,a,!ye)),Ee=r.measureText(Be).width,s&&(s<0&&(Le=Ee),Ee+=s),Se=ke===fe&&(Pe===fe||Pe===ue)||Pe===fe&&ke!==ge,Ce=!(ke!==pe&&ke!==fe||Pe!==_e&&Pe!==ge),be=Ae&&o?l-o:l,t&&l&&xe+ye+Ee>be&&(e?(ye&&Ie(),xe&&He()):(Ce||(Ce=ke===ue&&Pe==ge),Se||Ce||ke===we||ke===pe||ke===fe||ye+Ee>be?(ye&&Ie(),xe&&He()):xe&&He()))," "===Be&&!0!==Ae&&xe+ye===0||(ke===we?(" "===Be&&ye&&Ie(),De(Be,Ee),Ie()):Se||Ce?(ye&&Ie(),De(Be,Ee)):De(Be,Ee)),Pe=ke);ye&&Ie(),xe&&He(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Oe.paraNumber++,xe=r.measureText(t).width,Te.push({x:o||0,text:t,width:xe,paraStart:!0}),Me&&ze()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[Xe]);break;case"right":Ne(e,"x",-t[Ge])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[je]);break;case"bottom":Ne(e,"y",-t[Ue])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:d>.01?Ve:Ye,t.isOverflow&&!r&&(t.textMode=!0),h===Ye?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ve?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Qe={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:Je,addPoint:Ze,toBounds:$e}=t.TwoPointBoundsHelper;const Ke={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){tn||(tn=new t.TaskProcessor);return new Promise((t=>{tn.add((()=>ft(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(en(e),h.waitViewCompleted((()=>ft(this,void 0,void 0,(function*(){let s,o,a=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/a*b.scaleX,1/r*b.scaleY)};let S,C=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=h,P.bounds=C.bounds),C.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(C,P),e.fill=t}else e.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?Ze(r,o,a):Je(r={},o,a)),l++;const d=new t.Bounds;return $e(r,d),d.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};C=t.Creator.canvas(s),C.copyWorld(e,o,s)}y&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),g&&g(C);const A="canvas"===n?C:yield C.export(n,i);l({data:A,width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let tn;function en(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>en(t)))}const nn=t.LeaferCanvasBase.prototype,sn=t.Debug.get("@leafer-ui/export");nn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},nn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{sn.error(t),i(null)}))}))},nn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},nn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{sn.error(t),i(!1)}))}))},Object.assign(e.TextConvert,qe),Object.assign(e.ColorConvert,Qe),Object.assign(e.Paint,M),Object.assign(e.PaintImage,gt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,Vt),Object.assign(e.Export,Ke),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=b,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:m}=t.LeafHelper,v=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){v.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?v.warn("layouting"):this.times>3?v.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?k(e,!0,i,r):L(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",B(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function L(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function k(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}function P(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:S,getOuterOf:A,getByMove:C,getIntersectData:O}=t.BoundsHelper;let W;function M(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!W||!W[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const T={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),W=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=M(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?B(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?B(n,i):o?i.fill(o):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n),i.__useArrow&&P(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),k(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=A(s,a),o=C(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let D={};const{get:I,rotateOfOuter:F,translate:H,scaleOfOuter:z,scale:V,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,s,o,a){const r=I();H(r,e.x+n,e.y+i),V(r,s,o),a&&F(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function j(t,e,n,i,s,o,a){const r=I();H(r,e.x+n,e.y+i),s&&V(r,s,o),a&&Y(r,a),t.transform=r}function U(t,e,n,i,s,o,a,r,l,d){const c=I();if(l)if("center"===d)F(c,{x:n/2,y:i/2},l);else switch(Y(c,l),l){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}D.x=e.x+s,D.y=e.y+o,H(c,D.x,D.y),a&&z(c,D,a,r),t.transform=c}const{get:X,translate:N}=t.MatrixHelper,q=new t.Bounds,Q={},J={};function Z(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=$(n,i,e)}function $(e,n,i){let{width:s,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,J),v=J.scaleX,y=J.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,Q,!0),x+=Q.x,b+=Q.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&j(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&U(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&G(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=X(),N(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let K,tt=new t.Bounds;const{isSame:et}=t.BoundsHelper;function nt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Z(s,i,n,o),!0}function it(e,n){at(e,t.ImageEvent.LOAD,n)}function st(e,n){at(e,t.ImageEvent.LOADED,n)}function ot(e,n,i){n.error=i,e.forceUpdate("surface"),at(e,t.ImageEvent.ERROR,n)}function at(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function rt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:lt,scale:dt,copy:ct}=t.MatrixHelper,{ceil:ht,abs:ut}=Math;function ft(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=ut(s),o=ut(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=lt(),ct(d,g),dt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=lt(),g&&ct(d,g)),dt(d,1/s,1/o));const v=e.getCanvas(ht(c)||1,ht(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function pt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:gt}=Math;const _t={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return K&&i===K.paint&&et(s,K.boxBounds)?a=K.leafPaint:(a={type:i.type,image:l},K=l.use>1?{leafPaint:a,paint:i,boxBounds:tt.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(nt(e,n,i,l,a,s),o&&(it(e,r),st(e,r))):l.error?o&&ot(e,r,l.error):(o&&(rt(e,!0),it(e,r)),a.loadId=l.load((()=>{rt(e,!1),e.destroyed||(nt(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,r)),a.loadId=null}),(t=>{rt(e,!1),ot(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=gt(a)*l,i*=gt(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ft(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ft(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ft,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:Z,getPatternData:$,fillOrFitMode:G,clipMode:j,repeatMode:U},{toPoint:wt}=t.AroundHelper,mt={},vt={};function yt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:xt,getDistance:bt}=t.PointHelper,{get:Bt,rotateOfOuter:Et,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:Lt}=t.AroundHelper,kt={},Pt={};function St(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=xt(e,n);o=Bt(),s?(Rt(o,e,a/r*(i||1),1),Et(o,e,t+90)):(Rt(o,e,1,a/r*(i||1)),Et(o,e,t))}return o}const{getDistance:At}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,Ot={},Wt={};const Mt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;wt(i||"top",n,mt),wt(s||"bottom",n,vt);const l=t.Platform.canvas.createLinearGradient(mt.x,mt.y,vt.x,vt.y);yt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Lt(i||"center",n,kt),Lt(s||"bottom",n,Pt);const d=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,bt(kt,Pt));yt(d,e.stops,a);const c={type:o,style:d},h=St(n,kt,Pt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ct(i||"center",n,Ot),Ct(s||"bottom",n,Wt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,At(Ot,Wt));yt(d,e.stops,a);const c={type:o,style:d},h=St(n,Ot,Wt,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:St},{copy:Tt,toOffsetOutBounds:Dt}=t.BoundsHelper,It={},Ft={};function Ht(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Tt(It,e.bounds),It.x+=n.x-a.x,It.y+=n.y-a.y,i){const{matrix:t}=s;It.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),It.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),It.width*=i,It.height*=i}e.copyWorld(s.canvas,e.bounds,It)}else i&&(Tt(It,n),It.x-=n.width/2*(i-1),It.y-=n.height/2*(i-1),It.width*=i,It.height*=i),e.copyWorld(s.canvas,a,i?It:n)}const{toOffsetOutBounds:zt}=t.BoundsHelper,Vt={};const Yt={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,Ft),r.forEach(((r,g)=>{f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,Ft,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;zt(d,Vt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Vt.offsetX+r.x*h,Vt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,Vt,s,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Gt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Xt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Xt(t,n,i,o);break;case"path":n.restore()}}function Ut(t){return t.getSameCanvas(!1,!0)}function Xt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(a&&(jt(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ut(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ut(t)),s||(s=Ut(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Gt(n,e)||n.__render(s||t,e);jt(this,a,t,s,i,o)};const Nt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qt=Nt+"_#~&*+\\=|≮≯≈≠=…",Qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Jt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Zt=Jt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$t=Jt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Kt=Jt(Nt),te=Jt(qt),ee=Jt("- —/~|┆·");var ne;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ne||(ne={}));const{Letter:ie,Single:se,Before:oe,After:ae,Symbol:re,Break:le}=ne;function de(t){return Zt[t]?ie:ee[t]?le:$t[t]?oe:Kt[t]?ae:te[t]?re:Qt.test(t)?se:ie}const ce={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function he(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ue}=ce,{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:we,Break:me}=ne;let ve,ye,xe,be,Be,Ee,Re,Le,ke,Pe,Se,Ae,Ce,Oe,We,Me,Te,De=[];function Ie(t,e){ke&&!Le&&(Le=ke),ve.data.push({char:t,width:e}),xe+=e}function Fe(){be+=xe,ve.width=xe,ye.words.push(ve),ve={data:[]},xe=0}function He(){Oe&&(We.paraNumber++,ye.paraStart=!0,Oe=!1),ke&&(ye.startCharSize=Le,ye.endCharSize=ke,Le=0),ye.width=be,Me.width?ue(ye):Te&&ze(),De.push(ye),ye={words:[]},be=0}function ze(){be>(We.maxWidth||0)&&(We.maxWidth=be)}const Ve=0,Ye=1,Ge=2;const{top:je,right:Ue,bottom:Xe,left:Ne}=t.Direction4;function qe(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Ne],o-=d[Ue]+d[Ne]):n.autoSizeAlign||(i=d[Ne]),a?(s=d[je],a-=d[je]+d[Xe]):n.autoSizeAlign||(s=d[je]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){We=e,De=e.rows,Me=e.bounds,Te=!Me.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Me;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Se=null,Le=Re=ke=xe=be=0,ve={data:[]},ye={words:[]};for(let i=0,d=n.length;i<d;i++)Ee=n[i],"\n"===Ee?(xe&&Fe(),ye.paraEnd=!0,He(),Oe=!0):(Pe=de(Ee),Pe===fe&&"none"!==a&&(Ee=he(Ee,a,!xe)),Re=r.measureText(Ee).width,s&&(s<0&&(ke=Re),Re+=s),Ae=Pe===pe&&(Se===pe||Se===fe)||Se===pe&&Pe!==_e,Ce=!(Pe!==ge&&Pe!==pe||Se!==we&&Se!==_e),Be=Oe&&o?l-o:l,t&&l&&be+xe+Re>Be&&(e?(xe&&Fe(),be&&He()):(Ce||(Ce=Pe===fe&&Se==_e),Ae||Ce||Pe===me||Pe===ge||Pe===pe||xe+Re>Be?(xe&&Fe(),be&&He()):be&&He()))," "===Ee&&!0!==Oe&&be+xe===0||(Pe===me?(" "===Ee&&xe&&Fe(),Ie(Ee,Re),Fe()):Ae||Ce?(xe&&Fe(),Ie(Ee,Re)):Ie(Ee,Re)),Se=Pe);xe&&Fe(),be&&He(),De.length>0&&(De[De.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,be=r.measureText(t).width,De.push({x:o||0,text:t,width:be,paraStart:!0}),Te&&ze()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":qe(e,"x",t[Ne]);break;case"right":qe(e,"x",-t[Ue])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":qe(e,"y",t[je]);break;case"bottom":qe(e,"y",-t[Xe])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Ve:d>.01?Ye:Ge,t.isOverflow&&!r&&(t.textMode=!0),h===Ge?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Je={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:Ze,addPoint:$e,toBounds:Ke}=t.TwoPointBoundsHelper;const tn={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){en||(en=new t.TaskProcessor);return new Promise((t=>{en.add((()=>pt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(nn(e),h.waitViewCompleted((()=>pt(this,void 0,void 0,(function*(){let s,o,a=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/a*b.scaleX,1/r*b.scaleY)};let S,A=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=h,P.bounds=A.bounds),A.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(A,P),e.fill=t}else e.__render(A,P);if(A.restore(),S&&S.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?$e(r,o,a):Ze(r={},o,a)),l++;const d=new t.Bounds;return Ke(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(s),A.copyWorld(e,o,s)}y&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let en;function nn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>nn(t)))}const sn=t.LeaferCanvasBase.prototype,on=t.Debug.get("@leafer-ui/export");sn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},sn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{on.error(t),i(null)}))}))},sn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},sn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{on.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Qe),Object.assign(e.ColorConvert,Je),Object.assign(e.Paint,T),Object.assign(e.PaintImage,_t),Object.assign(e.PaintGradient,Mt),Object.assign(e.Effect,Yt),Object.assign(e.Export,tn),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=b,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));