@leafer-draw/worker 1.12.3 → 2.0.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/worker.js CHANGED
@@ -199,54 +199,6 @@ var LeaferUI = function(exports) {
199
199
  this.__input = this.__middle = null;
200
200
  }
201
201
  }
202
- const {floor: floor$2, max: max$4} = Math;
203
- const Platform = {
204
- toURL(text, fileType) {
205
- let url = encodeURIComponent(text);
206
- if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
207
- return url;
208
- },
209
- image: {
210
- hitCanvasSize: 100,
211
- maxCacheSize: 2560 * 1600,
212
- maxPatternSize: 4096 * 2160,
213
- crossOrigin: "anonymous",
214
- isLarge(size, scaleX, scaleY, largeSize) {
215
- return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
216
- },
217
- isSuperLarge(size, scaleX, scaleY) {
218
- return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
219
- },
220
- getRealURL(url) {
221
- const {prefix: prefix, suffix: suffix} = Platform.image;
222
- if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
223
- if (prefix && url[0] === "/") url = prefix + url;
224
- return url;
225
- },
226
- resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
227
- const canvas = Platform.origin.createCanvas(max$4(floor$2(width + (xGap || 0)), 1), max$4(floor$2(height + (yGap || 0)), 1));
228
- const ctx = canvas.getContext("2d");
229
- if (opacity) ctx.globalAlpha = opacity;
230
- ctx.imageSmoothingEnabled = smooth === false ? false : true;
231
- if (clip) {
232
- const scaleX = width / clip.width, scaleY = height / clip.height;
233
- ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
234
- ctx.drawImage(image, 0, 0, image.width, image.height);
235
- } else ctx.drawImage(image, 0, 0, width, height);
236
- return canvas;
237
- },
238
- setPatternTransform(pattern, transform, paint) {
239
- try {
240
- if (transform && pattern.setTransform) {
241
- pattern.setTransform(transform);
242
- transform = undefined;
243
- }
244
- } catch (_a) {}
245
- if (paint) DataHelper.stintSet(paint, "transform", transform);
246
- }
247
- }
248
- };
249
- const {image: image$1} = Platform;
250
202
  const IncrementId = {
251
203
  RUNTIME: "runtime",
252
204
  LEAF: "leaf",
@@ -266,7 +218,7 @@ var LeaferUI = function(exports) {
266
218
  };
267
219
  const I$1 = IncrementId;
268
220
  let tempA, tempB, tempTo;
269
- const {max: max$3} = Math, tempFour = [ 0, 0, 0, 0 ];
221
+ const {max: max$4} = Math, tempFour = [ 0, 0, 0, 0 ];
270
222
  const FourNumberHelper = {
271
223
  zero: [ ...tempFour ],
272
224
  tempFour: tempFour,
@@ -317,9 +269,9 @@ var LeaferUI = function(exports) {
317
269
  return data;
318
270
  },
319
271
  max(t, other, change) {
320
- if (isNumber(t) && isNumber(other)) return max$3(t, other);
272
+ if (isNumber(t) && isNumber(other)) return max$4(t, other);
321
273
  toTempAB(t, other, change);
322
- return set$2(tempTo, max$3(tempA[0], tempB[0]), max$3(tempA[1], tempB[1]), max$3(tempA[2], tempB[2]), max$3(tempA[3], tempB[3]));
274
+ return set$2(tempTo, max$4(tempA[0], tempB[0]), max$4(tempA[1], tempB[1]), max$4(tempA[2], tempB[2]), max$4(tempA[3], tempB[3]));
323
275
  },
324
276
  add(t, other, change) {
325
277
  if (isNumber(t) && isNumber(other)) return t + other;
@@ -334,7 +286,7 @@ var LeaferUI = function(exports) {
334
286
  }
335
287
  };
336
288
  const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
337
- const {round: round$3, pow: pow$1, max: max$2, floor: floor$1, PI: PI$3} = Math;
289
+ const {round: round$3, pow: pow$1, max: max$3, floor: floor$2, PI: PI$3} = Math;
338
290
  const MathHelper = {
339
291
  within(value, min, max) {
340
292
  if (isObject(min)) max = min.max, min = min.min;
@@ -387,7 +339,7 @@ var LeaferUI = function(exports) {
387
339
  }
388
340
  },
389
341
  getFloorScale(num, min = 1) {
390
- return max$2(floor$1(num), min) / num;
342
+ return max$3(floor$2(num), min) / num;
391
343
  },
392
344
  randInt: randInt,
393
345
  randColor(opacity) {
@@ -1193,7 +1145,7 @@ var LeaferUI = function(exports) {
1193
1145
  const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
1194
1146
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1195
1147
  const {float: float, fourNumber: fourNumber} = MathHelper;
1196
- const {floor: floor, ceil: ceil$1} = Math;
1148
+ const {floor: floor$1, ceil: ceil$1} = Math;
1197
1149
  let right$1, bottom$1, boundsRight, boundsBottom;
1198
1150
  const point = {};
1199
1151
  const toPoint$4 = {};
@@ -1345,8 +1297,8 @@ var LeaferUI = function(exports) {
1345
1297
  },
1346
1298
  ceil(t) {
1347
1299
  const {x: x, y: y} = t;
1348
- t.x = floor(t.x);
1349
- t.y = floor(t.y);
1300
+ t.x = floor$1(t.x);
1301
+ t.y = floor$1(t.y);
1350
1302
  t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1351
1303
  t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
1352
1304
  },
@@ -1478,6 +1430,9 @@ var LeaferUI = function(exports) {
1478
1430
  isEmpty(t) {
1479
1431
  return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
1480
1432
  },
1433
+ hasSize(t) {
1434
+ return t.width && t.height;
1435
+ },
1481
1436
  reset(t) {
1482
1437
  B.set(t);
1483
1438
  }
@@ -1648,6 +1603,11 @@ var LeaferUI = function(exports) {
1648
1603
  return new Bounds(left, top, width ? width : parent.width - left - right, height ? height : parent.height - top - bottom);
1649
1604
  }
1650
1605
  }
1606
+ const UnitConvertHelper = {
1607
+ number(value, percentRefer) {
1608
+ return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
1609
+ }
1610
+ };
1651
1611
  const StringNumberMap = {
1652
1612
  0: 1,
1653
1613
  1: 1,
@@ -1663,6 +1623,66 @@ var LeaferUI = function(exports) {
1663
1623
  e: 1,
1664
1624
  E: 1
1665
1625
  };
1626
+ const {floor: floor, max: max$2} = Math;
1627
+ const Platform = {
1628
+ toURL(text, fileType) {
1629
+ let url = encodeURIComponent(text);
1630
+ if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
1631
+ return url;
1632
+ },
1633
+ image: {
1634
+ hitCanvasSize: 100,
1635
+ maxCacheSize: 2560 * 1600,
1636
+ maxPatternSize: 4096 * 2160,
1637
+ crossOrigin: "anonymous",
1638
+ isLarge(size, scaleX, scaleY, largeSize) {
1639
+ return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image$1.maxCacheSize);
1640
+ },
1641
+ isSuperLarge(size, scaleX, scaleY) {
1642
+ return image$1.isLarge(size, scaleX, scaleY, image$1.maxPatternSize);
1643
+ },
1644
+ getRealURL(url) {
1645
+ const {prefix: prefix, suffix: suffix} = image$1;
1646
+ if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
1647
+ if (prefix && url[0] === "/") url = prefix + url;
1648
+ return url;
1649
+ },
1650
+ resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1651
+ const realWidth = max$2(floor(width + (xGap || 0)), 1), realHeight = max$2(floor(height + (yGap || 0)), 1);
1652
+ let interlaceX, interlaceY, interlaceOffset;
1653
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
1654
+ const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1655
+ const ctx = canvas.getContext("2d");
1656
+ if (opacity) ctx.globalAlpha = opacity;
1657
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
1658
+ if (image$1.canUse(view)) {
1659
+ if (clip) {
1660
+ const scaleX = width / clip.width, scaleY = height / clip.height;
1661
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
1662
+ ctx.drawImage(view, 0, 0, view.width, view.height);
1663
+ } else ctx.drawImage(view, 0, 0, width, height);
1664
+ if (interlaceOffset) {
1665
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
1666
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
1667
+ }
1668
+ }
1669
+ return canvas;
1670
+ },
1671
+ canUse(view) {
1672
+ return view && view.width && !view.__closed;
1673
+ },
1674
+ setPatternTransform(pattern, transform, paint) {
1675
+ try {
1676
+ if (transform && pattern.setTransform) {
1677
+ pattern.setTransform(transform);
1678
+ transform = undefined;
1679
+ }
1680
+ } catch (_a) {}
1681
+ if (paint) DataHelper.stintSet(paint, "transform", transform);
1682
+ }
1683
+ }
1684
+ };
1685
+ const {image: image$1} = Platform;
1666
1686
  const {randColor: randColor} = MathHelper;
1667
1687
  class Debug {
1668
1688
  constructor(name) {
@@ -3549,9 +3569,10 @@ var LeaferUI = function(exports) {
3549
3569
  run() {
3550
3570
  return __awaiter(this, void 0, void 0, function*() {
3551
3571
  try {
3552
- if (this.isComplete) return;
3572
+ if (this.isComplete || this.runing) return;
3573
+ this.runing = true;
3553
3574
  if (this.canUse && !this.canUse()) return this.cancel();
3554
- if (this.task && this.parent.running) yield this.task();
3575
+ if (this.task) yield this.task();
3555
3576
  } catch (error) {
3556
3577
  debug$8.error(error);
3557
3578
  }
@@ -3666,7 +3687,7 @@ var LeaferUI = function(exports) {
3666
3687
  stop() {
3667
3688
  this.isComplete = true;
3668
3689
  this.list.forEach(task => {
3669
- if (!task.isComplete) task.cancel();
3690
+ if (!task.isComplete) task.run();
3670
3691
  });
3671
3692
  this.pause();
3672
3693
  this.empty();
@@ -3949,7 +3970,7 @@ var LeaferUI = function(exports) {
3949
3970
  getFull(_filters) {
3950
3971
  return this.view;
3951
3972
  }
3952
- getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
3973
+ getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
3953
3974
  width || (width = this.width);
3954
3975
  height || (height = this.height);
3955
3976
  if (this.cache) {
@@ -3962,7 +3983,7 @@ var LeaferUI = function(exports) {
3962
3983
  }
3963
3984
  if (data) return data;
3964
3985
  }
3965
- const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
3986
+ const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
3966
3987
  this.cache = this.use > 1 ? {
3967
3988
  data: canvas,
3968
3989
  params: arguments
@@ -3978,13 +3999,13 @@ var LeaferUI = function(exports) {
3978
3999
  return this.url;
3979
4000
  }
3980
4001
  setThumbView(_view) {}
3981
- getThumbSize() {
4002
+ getThumbSize(_lod) {
3982
4003
  return undefined;
3983
4004
  }
3984
4005
  getMinLevel() {
3985
4006
  return undefined;
3986
4007
  }
3987
- getLevelData(_level) {
4008
+ getLevelData(_level, _width, _height) {
3988
4009
  return undefined;
3989
4010
  }
3990
4011
  clearLevels(_checkUse) {}
@@ -5704,7 +5725,7 @@ var LeaferUI = function(exports) {
5704
5725
  if (this.__layout.opacityChanged) this.__layout.opacityChanged = false;
5705
5726
  }
5706
5727
  };
5707
- const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper;
5728
+ const {excludeRenderBounds: excludeRenderBounds$1} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
5708
5729
  const BranchRender = {
5709
5730
  __updateChange() {
5710
5731
  const {__layout: layout} = this;
@@ -5715,8 +5736,8 @@ var LeaferUI = function(exports) {
5715
5736
  this.__.__checkSingle();
5716
5737
  },
5717
5738
  __render(canvas, options) {
5718
- this.__nowWorld = this.__getNowWorld(options);
5719
- if (this.__worldOpacity) {
5739
+ const nowWorld = this.__nowWorld = this.__getNowWorld(options);
5740
+ if (this.__worldOpacity && hasSize(nowWorld)) {
5720
5741
  const data = this.__;
5721
5742
  if (data.__useDim) {
5722
5743
  if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
@@ -5725,7 +5746,6 @@ var LeaferUI = function(exports) {
5725
5746
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5726
5747
  const tempCanvas = canvas.getSameCanvas(false, true);
5727
5748
  this.__renderBranch(tempCanvas, options);
5728
- const nowWorld = this.__nowWorld;
5729
5749
  canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
5730
5750
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
5731
5751
  tempCanvas.recycle(nowWorld);
@@ -6547,7 +6567,7 @@ var LeaferUI = function(exports) {
6547
6567
  this.levelMap = null;
6548
6568
  }
6549
6569
  }
6550
- const version = "1.12.3";
6570
+ const version = "2.0.0";
6551
6571
  class LeaferCanvas extends LeaferCanvasBase {
6552
6572
  get allowBackgroundColor() {
6553
6573
  return true;
@@ -6947,6 +6967,7 @@ var LeaferUI = function(exports) {
6947
6967
  this.times = 0;
6948
6968
  this.config = {
6949
6969
  usePartRender: true,
6970
+ ceilPartPixel: true,
6950
6971
  maxFPS: 120
6951
6972
  };
6952
6973
  this.frames = [];
@@ -7055,8 +7076,9 @@ var LeaferUI = function(exports) {
7055
7076
  const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
7056
7077
  canvas.save();
7057
7078
  bounds.spread(Renderer.clipSpread).ceil();
7058
- canvas.clearWorld(bounds);
7059
- canvas.clipWorld(bounds);
7079
+ const {ceilPartPixel: ceilPartPixel} = this.config;
7080
+ canvas.clipWorld(bounds, ceilPartPixel);
7081
+ canvas.clearWorld(bounds, ceilPartPixel);
7060
7082
  this.__render(bounds, realBounds);
7061
7083
  canvas.restore();
7062
7084
  Run.end(t);
@@ -7243,11 +7265,7 @@ var LeaferUI = function(exports) {
7243
7265
  const ColorConvert = {
7244
7266
  hasTransparent: hasTransparent$3
7245
7267
  };
7246
- const UnitConvert = {
7247
- number(value, percentRefer) {
7248
- return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
7249
- }
7250
- };
7268
+ const UnitConvert = UnitConvertHelper;
7251
7269
  const PathArrow = {};
7252
7270
  const Paint = {};
7253
7271
  const PaintImage = {};
@@ -8465,9 +8483,10 @@ var LeaferUI = function(exports) {
8465
8483
  const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8466
8484
  const rx = width / 2, ry = height / 2;
8467
8485
  const path = this.__.path = [];
8486
+ let open;
8468
8487
  if (innerRadius) {
8469
8488
  if (startAngle || endAngle) {
8470
- if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false);
8489
+ if (innerRadius < 1) ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius, 0, startAngle, endAngle, false); else open = true;
8471
8490
  ellipse(path, rx, ry, rx, ry, 0, endAngle, startAngle, true);
8472
8491
  } else {
8473
8492
  if (innerRadius < 1) {
@@ -8484,7 +8503,7 @@ var LeaferUI = function(exports) {
8484
8503
  ellipse(path, rx, ry, rx, ry);
8485
8504
  }
8486
8505
  }
8487
- closePath$2(path);
8506
+ if (!open) closePath$2(path);
8488
8507
  if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
8489
8508
  }
8490
8509
  };
@@ -9238,7 +9257,7 @@ var LeaferUI = function(exports) {
9238
9257
  ignoreRender(ui, false);
9239
9258
  onLoadError(ui, event, error);
9240
9259
  leafPaint.loadId = undefined;
9241
- }, paint.lod && image.getThumbSize());
9260
+ }, paint.lod && image.getThumbSize(paint.lod));
9242
9261
  if (ui.placeholderColor) {
9243
9262
  if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
9244
9263
  if (!image.ready) {
@@ -9296,7 +9315,7 @@ var LeaferUI = function(exports) {
9296
9315
  if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
9297
9316
  if (paint.mode === "strench") paint.mode = "stretch";
9298
9317
  const {width: width, height: height} = image;
9299
- const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
9318
+ const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters, interlace: interlace} = paint;
9300
9319
  const sameBox = box.width === width && box.height === height;
9301
9320
  const data = {
9302
9321
  mode: mode
@@ -9362,6 +9381,10 @@ var LeaferUI = function(exports) {
9362
9381
  if (opacity && opacity < 1) data.opacity = opacity;
9363
9382
  if (filters) data.filters = filters;
9364
9383
  if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
9384
+ if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
9385
+ type: "x",
9386
+ offset: interlace
9387
+ } : interlace;
9365
9388
  return data;
9366
9389
  }
9367
9390
  function getGapData(gap, repeat, width, height, box) {
@@ -9482,7 +9505,7 @@ var LeaferUI = function(exports) {
9482
9505
  if (transform) copy$1(imageMatrix, transform);
9483
9506
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
9484
9507
  }
9485
- const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
9508
+ const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
9486
9509
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
9487
9510
  paint.style = pattern;
9488
9511
  paint.patternId = id;
@@ -9502,8 +9525,8 @@ var LeaferUI = function(exports) {
9502
9525
  }
9503
9526
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
9504
9527
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
9505
- const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
9506
- if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
9528
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
9529
+ if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting || snapshot) {
9507
9530
  return false;
9508
9531
  } else {
9509
9532
  if (drawImage) {
@@ -10096,7 +10119,7 @@ var LeaferUI = function(exports) {
10096
10119
  const TextMode = 2;
10097
10120
  function layoutChar(drawData, style, width, _height) {
10098
10121
  const {rows: rows} = drawData;
10099
- const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
10122
+ const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
10100
10123
  const justifyLast = width && textAlign.includes("both");
10101
10124
  const justify = justifyLast || width && textAlign.includes("justify");
10102
10125
  const justifyLetter = justify && textAlign.includes("letter");
@@ -10109,8 +10132,8 @@ var LeaferUI = function(exports) {
10109
10132
  remainingWidth = width - row.width - indentWidth;
10110
10133
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
10111
10134
  }
10112
- mode = letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
10113
- if (row.isOverflow && !letterSpacing) row.textMode = true;
10135
+ mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
10136
+ if (row.isOverflow && !__letterSpacing) row.textMode = true;
10114
10137
  if (mode === TextMode) {
10115
10138
  row.x += indentWidth;
10116
10139
  toTextChar$1(row);
@@ -10481,6 +10504,7 @@ var LeaferUI = function(exports) {
10481
10504
  exports.UIData = UIData;
10482
10505
  exports.UIRender = UIRender;
10483
10506
  exports.UnitConvert = UnitConvert;
10507
+ exports.UnitConvertHelper = UnitConvertHelper;
10484
10508
  exports.WaitHelper = WaitHelper;
10485
10509
  exports.WatchEvent = WatchEvent;
10486
10510
  exports.Watcher = Watcher;
@@ -1,2 +1,2 @@
1
- "use strict";var t,e=require("@leafer/core"),a=require("@leafer-ui/draw");exports.PathNodeHandleType=void 0,(t=exports.PathNodeHandleType||(exports.PathNodeHandleType={}))[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror";class n extends e.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:a}=this;this.view.width=Math.ceil(t*a),this.view.height=Math.ceil(e*a),this.clientBounds=this.bounds}}e.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),e.canvasPatch(Path2D.prototype);const{mineType:r}=e.FileHelper;function i(t,a){e.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,a)=>new Promise((n,i)=>{t.convertToBlob({type:r(e),quality:a}).then(t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>i(t),e.readAsDataURL(t)}).catch(t=>{i(t)})}),canvasToBolb:(t,e,a)=>t.convertToBlob({type:r(e),quality:a}),canvasSaveAs:(t,e,a)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((a,n)=>{let r=new XMLHttpRequest;r.open("GET",e.Platform.image.getRealURL(t),!0),r.responseType="blob",r.onload=()=>{createImageBitmap(r.response).then(t=>{a(t)}).catch(t=>{n(t)})},r.onerror=t=>n(t),r.send()})},e.Platform.canvas=e.Creator.canvas(),e.Platform.conicGradientSupport=!!e.Platform.canvas.context.createConicGradient}Object.assign(e.Creator,{canvas:(t,e)=>new n(t,e),image:t=>new e.LeaferImage(t)}),e.Platform.name="web",e.Platform.isWorker=!0,e.Platform.backgrounder=!0,e.Platform.requestRender=function(t){requestAnimationFrame(t)},e.defineKey(e.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:s}=navigator;s.indexOf("Firefox")>-1?(e.Platform.conicGradientRotate90=!0,e.Platform.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.Platform.fullImageShadow=!0),s.indexOf("Windows")>-1?(e.Platform.os="Windows",e.Platform.intWheelDeltaY=!0):s.indexOf("Mac")>-1?e.Platform.os="Mac":s.indexOf("Linux")>-1&&(e.Platform.os="Linux");class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new e.LeafList;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,a){this.totalTimes=0,this.config={},this.__updatedList=new e.LeafList,this.target=t,a&&(this.config=e.DataHelper.default(a,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(e.RenderEvent.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===e.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,a=e.length;t<a;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new e.WatchEvent(e.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new e.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[e.PropertyEvent.CHANGE,this.__onAttrChange,this],[[e.ChildEvent.ADD,e.ChildEvent.REMOVE],this.__onChildEvent,this],[e.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:d,updateChange:c}=e.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=e.BranchHelper;const{worldBounds:f}=e.LeafBoundsHelper;class g{constructor(t){this.updatedBounds=new e.Bounds,this.beforeBounds=new e.Bounds,this.afterBounds=new e.Bounds,e.isArray(t)&&(t=new e.LeafList(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,f),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:p,updateAllChange:_}=e.LeafHelper,m=e.Debug.get("Layouter");class y{constructor(t,a){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new e.LeafLevelList,this.target=t,a&&(this.config=e.DataHelper.default(a,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(e.LayoutEvent.START),this.layoutOnce(),t.emitEvent(new e.LayoutEvent(e.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(e.WatchEvent.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const a=e.Run.start("PartLayout"),{target:n,__updatedList:r}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=e.LayoutEvent,f=this.getBlocks(r);f.forEach(t=>t.setBefore()),n.emitEvent(new e.LayoutEvent(i,f,this.times)),this.extraBlock=null,r.sort(),function(t,e){let a;t.list.forEach(t=>{a=t.__layout,e.without(t)&&!a.proxyZoom&&(a.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):a.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))})}(r,this.__levelList),function(t){let e,a,n;t.sort(!0),t.levels.forEach(r=>{e=t.levelMap[r];for(let t=0,r=e.length;t<r;t++){if(a=e[t],a.isBranch&&a.__tempNumber){n=a.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||d(n[t])}d(a)}})}(this.__levelList),function(t){t.list.forEach(c)}(r),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),n.emitEvent(new e.LayoutEvent(s,f,this.times)),n.emitEvent(new e.LayoutEvent(o,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,e.Run.end(a)}fullLayout(){const t=e.Run.start("FullLayout"),{target:a}=this,{BEFORE:n,LAYOUT:r,AFTER:i}=e.LayoutEvent,s=this.getBlocks(new e.LeafList(a));a.emitEvent(new e.LayoutEvent(n,s,this.times)),y.fullLayout(a),s.forEach(t=>{t.setAfter()}),a.emitEvent(new e.LayoutEvent(r,s,this.times)),a.emitEvent(new e.LayoutEvent(i,s,this.times)),this.addBlocks(s),e.Run.end(t)}static fullLayout(t){p(t,!0),t.isBranch?e.BranchHelper.updateBounds(t):e.LeafHelper.updateBounds(t),_(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:a}=this.extraBlock||(this.extraBlock=new g([]));e.length?a.add(t.__world):a.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[e.LayoutEvent.REQUEST,this.layout,this],[e.LayoutEvent.AGAIN,this.layoutAgain,this],[e.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const w=e.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,a,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=a,n&&(this.config=e.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(e.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(e.RenderEvent.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(e.RenderEvent.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(e.RenderEvent.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:a}=this;this.times=0,this.totalBounds=new e.Bounds,w.log(a.innerName,"---\x3e");try{this.emitRender(e.RenderEvent.START),this.renderOnce(t),this.emitRender(e.RenderEvent.END,this.totalBounds),e.ImageManager.clearRecycled()}catch(t){this.rendering=!1,w.error(t)}w.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return w.warn("rendering");if(this.times>3)return w.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new e.Bounds,this.renderOptions={},t)this.emitRender(e.RenderEvent.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(e.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(e.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(e.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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const a=e.Run.start("PartRender"),{canvas:n}=this,r=t.getIntersect(n.bounds),i=new e.Bounds(r);n.save(),r.spread(v.clipSpread).ceil(),n.clearWorld(r),n.clipWorld(r),this.__render(r,i),n.restore(),e.Run.end(a)}fullRender(){const t=e.Run.start("FullRender"),{canvas:a}=this;a.save(),a.clear(),this.__render(a.bounds),a.restore(),e.Run.end(t)}__render(t,a){const{canvas:n,target:r}=this,i=t.includes(r.__world),s=i?{includes:i}:{bounds:t,includes:i};this.needFill&&n.fillWorld(t,this.config.fill),e.Debug.showRepaint&&e.Debug.drawRepaint(n,t),this.config.useCellRender&&(s.cellList=this.getCellList()),e.Platform.render(r,n,s),this.renderBounds=a=a||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=a:this.totalBounds.add(a),n.updateRender(a)}getCellList(){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const a=new e.Bounds;a.setList(t),t.length=0,t.push(a)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const a=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&t>n)return e.Platform.requestRender(a);const{frames:r}=this;r.length>30&&r.shift(),r.push(t),this.FPS=Math.round(r.reduce((t,e)=>t+e,0)/r.length),this.requestTime=0,this.checkRender()};e.Platform.requestRender(a)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:a,height:n}=t.old;if(!new e.Bounds(0,0,a,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new e.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||w.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,a,n){this.target.emitEvent(new e.RenderEvent(t,this.times,a,n))}__listenEvents(){this.__eventIds=[this.target.on_([[e.RenderEvent.REQUEST,this.update,this],[e.LayoutEvent.END,this.__onLayoutEnd,this],[e.RenderEvent.AGAIN,this.renderAgain,this],[e.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function x(t,e,n){t.__.__font?a.Paint.fillText(t,e,n):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function b(t,n,r,i,s){const o=r.__;e.isObject(t)?a.Paint.drawStrokesStyle(t,n,!1,r,i,s):(i.setStroke(t,o.__strokeWidth*n,o),i.stroke()),o.__useArrow&&a.Paint.strokeArrow(t,r,i,s)}function S(t,n,r,i,s){const o=r.__;e.isObject(t)?a.Paint.drawStrokesStyle(t,n,!0,r,i,s):(i.setStroke(t,o.__strokeWidth*n,o),a.Paint.drawTextStroke(r,i,s))}function E(t,n,r,i,s){const o=i.getSameCanvas(!0,!0);o.font=r.__.__font,S(t,2,r,o,s),o.blendMode="outside"===n?"destination-out":"destination-in",a.Paint.fillText(r,o,s),o.blendMode="normal",e.LeafHelper.copyCanvasByWorld(r,i,o),o.recycle(r.__nowWorld)}v.clipSpread=10,Object.assign(e.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,a)=>new v(t,e,a),selector:(t,e)=>{},interaction:(t,e,a,n)=>{}}),e.Platform.layout=y.fullLayout,e.Platform.render=function(t,a,n){const r=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new e.LeafList,t.__render(a,n),n.topList.length&&n.topList.forEach(t=>t.__render(a,r))};const{getSpread:P,copyAndSpread:B,toOuterOf:L,getOuterOf:k,getByMove:R,move:C,getIntersectData:A}=e.BoundsHelper,T={};let O;const{stintSet:I}=e.DataHelper,{hasTransparent:M}=a.ColorConvert;function W(t,n,r){if(!e.isObject(n)||!1===n.visible||0===n.opacity)return;let i;const{boxBounds:s}=r.__layout;switch(n.type){case"image":if(!n.url)return;i=a.PaintImage.image(r,t,n,s,!O||!O[n.url]);break;case"linear":i=a.PaintGradient.linearGradient(n,s);break;case"radial":i=a.PaintGradient.radialGradient(n,s);break;case"angular":i=a.PaintGradient.conicGradient(n,s);break;case"solid":const{type:o,color:l,opacity:d}=n;i={type:o,style:a.ColorConvert.string(l,d)};break;default:e.isUndefined(n.r)||(i={type:"solid",style:a.ColorConvert.string(n)})}if(i&&(i.originPaint=n,e.isString(i.style)&&M(i.style)&&(i.isTransparent=!0),n.style)){if(0===n.style.strokeWidth)return;i.strokeStyle=n.style}return i}const D={compute:function(t,n){const r=n.__,i=[];let s,o,l,d=r.__input[t];e.isArray(d)||(d=[d]),O=a.PaintImage.recycleImage(t,r);for(let e,a=0,r=d.length;a<r;a++)(e=W(t,d[a],n))&&(i.push(e),e.strokeStyle&&(l||(l=1),e.strokeStyle.strokeWidth&&(l=Math.max(l,e.strokeStyle.strokeWidth))));r["_"+t]=i.length?i:void 0,i.length?(i.every(t=>t.isTransparent)&&(i.some(t=>t.image)&&(s=!0),o=!0),"fill"===t?(I(r,"__isAlphaPixelFill",s),I(r,"__isTransparentFill",o)):(I(r,"__isAlphaPixelStroke",s),I(r,"__isTransparentStroke",o),I(r,"__hasMultiStrokeStyle",l))):r.__removePaint(t,!1)},fill:function(t,e,a,n){a.fillStyle=t,x(e,a,n)},fills:function(t,e,n,r){let i,s,o;for(let l=0,d=t.length;l<d;l++){if(i=t[l],s=i.originPaint,i.image){if(o?o++:o=1,a.PaintImage.checkImage(i,!e.__.__font,e,n,r))continue;if(!i.style){1===o&&i.image.isPlacehold&&e.drawImagePlaceholder(i,n,r);continue}}if(n.fillStyle=i.style,i.transform||s.scaleFixed){if(n.save(),i.transform&&n.transform(i.transform),s.scaleFixed){const{scaleX:t,scaleY:a}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&a>1)&&n.scale(1/t,1/a)}s.blendMode&&(n.blendMode=s.blendMode),x(e,n,r),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),x(e,n,r),n.restoreBlendMode()):x(e,n,r)}},fillPathOrText:x,fillText:function(t,e,a){const n=t.__,{rows:r,decorationY:i}=n.__textDrawData;let s;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,a=r.length;t<a;t++)s=r[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.fillText(t.char,t.x,s.y)});if(i){const{decorationColor:t,decorationHeight:a}=n.__textDrawData;t&&(e.fillStyle=t),r.forEach(t=>i.forEach(n=>e.fillRect(t.x,t.y+n,t.width,a)))}},stroke:function(t,n,r,i){const s=n.__;if(s.__strokeWidth)if(s.__font)a.Paint.strokeText(t,n,r,i);else switch(s.strokeAlign){case"center":b(t,1,n,r,i);break;case"inside":!function(t,e,a,n){a.save(),a.clipUI(e),b(t,2,e,a,n),a.restore()}(t,n,r,i);break;case"outside":!function(t,a,n,r){const i=a.__;if(i.__fillAfterStroke)b(t,2,a,n,r);else{const{renderBounds:s}=a.__layout,o=n.getSameCanvas(!0,!0);a.__drawRenderPath(o),b(t,2,a,o,r),o.clipUI(i),o.clearWorld(s),e.LeafHelper.copyCanvasByWorld(a,n,o),o.recycle(a.__nowWorld)}}(t,n,r,i)}},strokes:function(t,e,n,r){a.Paint.stroke(t,e,n,r)},strokeText:function(t,e,a,n){switch(e.__.strokeAlign){case"center":S(t,1,e,a,n);break;case"inside":E(t,"inside",e,a,n);break;case"outside":e.__.__fillAfterStroke?S(t,2,e,a,n):E(t,"outside",e,a,n)}},drawTextStroke:function(t,e,a){let n,r=t.__.__textDrawData;const{rows:i,decorationY:s}=r;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)});if(s){const{decorationHeight:t}=r;i.forEach(a=>s.forEach(n=>e.strokeRect(a.x,a.y+n,a.width,t)))}},drawStrokesStyle:function(t,e,n,r,i,s){let o;const l=r.__,{__hasMultiStrokeStyle:d}=l;d||i.setStroke(void 0,l.__strokeWidth*e,l);for(let c=0,h=t.length;c<h;c++)if(o=t[c],(!o.image||!a.PaintImage.checkImage(o,!1,r,i,s))&&o.style){if(d){const{strokeStyle:t}=o;t?i.setStroke(o.style,l.__getRealStrokeWidth(t)*e,l,t):i.setStroke(o.style,l.__strokeWidth*e,l)}else i.strokeStyle=o.style;o.originPaint.blendMode?(i.saveBlendMode(o.originPaint.blendMode),n?a.Paint.drawTextStroke(r,i,s):i.stroke(),i.restoreBlendMode()):n?a.Paint.drawTextStroke(r,i,s):i.stroke()}},shape:function(t,a,n){const r=a.getSameCanvas(),i=a.bounds,s=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;L(o.strokeSpread?(B(T,o.boxBounds,o.strokeSpread),T):o.boxBounds,s,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(i.includes(l))g=r,d=f=l,c=s;else{let r;if(e.Platform.fullImageShadow)r=l;else{const t=o.renderShapeSpread?P(i,e.FourNumberHelper.swapAndScale(o.renderShapeSpread,p,_)):i;r=A(t,l)}u=i.getFitMatrix(r);let{a:m,d:y}=u;u.a<1&&(g=a.getSameCanvas(),t.__renderShape(g,n),p*=m,_*=y),f=k(l,u),d=R(f,-u.e,-u.f),c=k(s,u),C(c,-u.e,-u.f);const w=n.matrix;w?(h=new e.Matrix(u),h.multiply(w),m*=w.scaleX,y*=w.scaleY):h=u,h.withScale(m,y),n=Object.assign(Object.assign({},n),{matrix:h})}return t.__renderShape(r,n),{canvas:r,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let H,F=new e.Bounds;const{isSame:j}=e.BoundsHelper;function G(t,e,n,r,i,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=r.width/e.pixelRatio,e.__naturalHeight=r.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||a.PaintImage.createData(i,r,n,s),!0}function Y(t,a){N(t,e.ImageEvent.LOAD,a)}function U(t,a){N(t,e.ImageEvent.LOADED,a)}function z(t,a,n){a.error=n,t.forceUpdate("surface"),N(t,e.ImageEvent.ERROR,a)}function N(t,a,n){t.hasEvent(a)&&t.emitEvent(new e.ImageEvent(a,n))}function X(t,e){const{leafer:a}=t;a&&a.viewReady&&(a.renderer.ignore=e)}const{get:q,translate:V}=e.MatrixHelper,Q=new e.Bounds,Z={},K={};function $(t,a,n,r){const i=e.isString(t)||r?(r?n-r*a:n%a)/((r||Math.floor(n/a))-1):t;return"auto"===t&&i<0?0:i}let J={},tt=e.getMatrixData();const{get:et,set:at,rotateOfOuter:nt,translate:rt,scaleOfOuter:it,multiplyParent:st,scale:ot,rotate:lt,skew:dt}=e.MatrixHelper;function ct(t,e,a,n,r,i,s,o){s&&lt(t,s),o&&dt(t,o.x,o.y),r&&ot(t,r,i),rt(t,e.x+a,e.y+n)}function ht(t,e,a,n){return new(a||(a=Promise))(function(r,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function o(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof a?e:new a(function(t){t(e)})).then(s,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ut,scale:ft,copy:gt}=e.MatrixHelper,{getFloorScale:pt}=e.MathHelper,{abs:_t}=Math;const mt={image:function(t,a,n,r,i){let s,o;const l=e.ImageManager.get(n);return H&&n===H.paint&&j(r,H.boxBounds)?s=H.leafPaint:(s={type:n.type,image:l},l.hasAlphaPixel&&(s.isTransparent=!0),H=l.use>1?{leafPaint:s,paint:n,boxBounds:F.set(r)}:null),(i||l.loading)&&(o={image:l,attrName:a,attrValue:n}),l.ready?(G(t,a,n,l,s,r),i&&(Y(t,o),U(t,o))):l.error?i&&z(t,o,l.error):(i&&(X(t,!0),Y(t,o)),s.loadId=l.load(()=>{X(t,!1),t.destroyed||(G(t,a,n,l,s,r)&&(l.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),U(t,o)),s.loadId=void 0},e=>{X(t,!1),z(t,o,e),s.loadId=void 0},n.lod&&l.getThumbSize()),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):l.isPlacehold=!0)),s},checkImage:function(t,n,r,i,s){const{scaleX:o,scaleY:l}=a.PaintImage.getImageRenderScaleData(t,r,i,s),{image:d,data:c,originPaint:h}=t,{exporting:u}=s;return!(!c||t.patternId===o+"-"+l&&!u)&&(n&&(c.repeat?n=!1:h.changeful||"miniapp"===e.Platform.name&&e.ResizeEvent.isResizing(r)||u||(n=e.Platform.image.isLarge(d,o,l)||d.width*o>8096||d.height*l>8096)),n?(r.__.__isFastShadow&&(i.fillStyle=t.style||"#000",i.fill()),a.PaintImage.drawImage(t,o,l,r,i,s),!0):(!t.style||h.sync||u?a.PaintImage.createPattern(t,r,i,s):a.PaintImage.createPatternTask(t,r,i,s),!1))},drawImage:function(t,e,a,n,r,i){const{data:s,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=s,h=o.getFull(s.filters),u=n.__;let f,{width:g,height:p}=o;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(r.save(),f&&r.clipUI(n),l&&(r.blendMode=l),d&&(r.opacity*=d),c&&r.transform(c),r.drawImage(h,0,0,g,p),r.restore()):(s.scaleX&&(g*=s.scaleX,p*=s.scaleY),r.drawImage(h,0,0,g,p))},getImageRenderScaleData:function(t,e,a,n){const r=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:i}=t;if(a){const{pixelRatio:t}=a;r.scaleX*=t,r.scaleY*=t}return i&&i.scaleX&&(r.scaleX*=Math.abs(i.scaleX),r.scaleY*=Math.abs(i.scaleY)),r},recycleImage:function(t,a){const n=a["_"+t];if(e.isArray(n)){let r,i,s,o,l;for(let d=0,c=n.length;d<c;d++)r=n[d],i=r.image,l=i&&i.url,l&&(s||(s={}),s[l]=!0,e.ImageManager.recyclePaint(r),i.loading&&(o||(o=a.__input&&a.__input[t]||[],e.isArray(o)||(o=[o])),i.unload(n[d].loadId,!o.some(t=>t.url===l))));return s}return null},createPatternTask:function(t,n,r,i){t.patternTask||(t.patternTask=e.ImageManager.patternTasker.add(()=>ht(this,void 0,void 0,function*(){a.PaintImage.createPattern(t,n,r,i),n.forceUpdate("surface")}),0,()=>(t.patternTask=null,r.bounds.hit(n.__nowWorld))))},createPattern:function(t,n,r,i){let{scaleX:s,scaleY:o}=a.PaintImage.getImageRenderScaleData(t,n,r,i),l=s+"-"+o;if(t.patternId!==l&&!n.destroyed&&(!e.Platform.image.isLarge(t.image,s,o)||t.data.repeat)){const{image:r,data:i}=t,{transform:d,gap:c}=i,h=a.PaintImage.getPatternFixScale(t,s,o);let u,f,g,{width:p,height:_}=r;h&&(s*=h,o*=h),p*=s,_*=o,c&&(f=c.x*s/_t(i.scaleX||1),g=c.y*o/_t(i.scaleY||1)),(d||1!==s||1!==o)&&(s*=pt(p+(f||0)),o*=pt(_+(g||0)),u=ut(),d&&gt(u,d),ft(u,1/s,1/o));const m=r.getCanvas(p,_,i.opacity,i.filters,f,g,n.leafer&&n.leafer.config.smooth),y=r.getPattern(m,i.repeat||e.Platform.origin.noRepeat||"no-repeat",u,t);t.style=y,t.patternId=l}},getPatternFixScale:function(t,a,n){const{image:r}=t;let i,s=e.Platform.image.maxPatternSize,o=r.width*r.height;return r.isSVG?a>1&&(i=Math.ceil(a)/a):s>o&&(s=o),(o*=a*n)>s&&(i=Math.sqrt(s/o)),i},createData:function(t,e,n,r){t.data=a.PaintImage.getPatternData(n,r,e)},getPatternData:function(t,n,r){t.padding&&(n=Q.set(n).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:i,height:s}=r,{opacity:o,mode:l,align:d,offset:c,scale:h,size:u,rotation:f,skew:g,clipSize:p,repeat:_,gap:m,filters:y}=t,w=n.width===i&&n.height===s,v={mode:l},x="center"!==d&&(f||0)%180==90;let b,S;switch(e.BoundsHelper.set(K,0,0,x?s:i,x?i:s),l&&"cover"!==l&&"fit"!==l?((h||u)&&(e.MathHelper.getScaleData(h,u,r,Z),b=Z.scaleX,S=Z.scaleY),(d||m||_)&&(b&&e.BoundsHelper.scale(K,b,S,!0),d&&e.AlignHelper.toPoint(d,K,n,K,!0,!0))):w&&!f||(b=S=e.BoundsHelper.getFitScale(n,K,"fit"!==l),e.BoundsHelper.put(n,r,d,b,!1,K),e.BoundsHelper.scale(K,b,S,!0)),c&&e.PointHelper.move(K,c),l){case"stretch":w?b&&(b=S=void 0):(b=n.width/i,S=n.height/s,a.PaintImage.stretchMode(v,n,b,S));break;case"normal":case"clip":if(K.x||K.y||b||p||f||g){let t,e;p&&(t=n.width/p.width,e=n.height/p.height),a.PaintImage.clipMode(v,n,K.x,K.y,b,S,f,g,t,e),t&&(b=b?b*t:t,S=S?S*e:e)}break;case"repeat":(!w||b||f||g)&&a.PaintImage.repeatMode(v,n,i,s,K.x,K.y,b,S,f,g,d,t.freeTransform),_||(v.repeat="repeat");const r=e.isObject(_);(m||r)&&(v.gap=function(t,a,n,r,i){let s,o;e.isObject(t)?(s=t.x,o=t.y):s=o=t;return{x:$(s,n,i.width,a&&a.x),y:$(o,r,i.height,a&&a.y)}}(m,r&&_,K.width,K.height,n));break;default:b&&a.PaintImage.fillOrFitMode(v,n,K.x,K.y,b,S,f)}return v.transform||(n.x||n.y)&&V(v.transform=q(),n.x,n.y),b&&(v.scaleX=b,v.scaleY=S),o&&o<1&&(v.opacity=o),y&&(v.filters=y),_&&(v.repeat=e.isString(_)?"x"===_?"repeat-x":"repeat-y":"repeat"),v},stretchMode:function(t,e,a,n){const r=et(),{x:i,y:s}=e;i||s?rt(r,i,s):r.onlyScale=!0,ot(r,a,n),t.transform=r},fillOrFitMode:function(t,e,a,n,r,i,s){const o=et();rt(o,e.x+a,e.y+n),ot(o,r,i),s&&nt(o,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=o},clipMode:function(t,e,a,n,r,i,s,o,l,d){const c=et();ct(c,e,a,n,r,i,s,o),l&&(s||o?(at(tt),it(tt,e,l,d),st(c,tt)):it(c,e,l,d)),t.transform=c},repeatMode:function(t,e,a,n,r,i,s,o,l,d,c,h){const u=et();if(h)ct(u,e,r,i,s,o,l,d);else{if(l)if("center"===c)nt(u,{x:a/2,y:n/2},l);else switch(lt(u,l),l){case 90:rt(u,n,0);break;case 180:rt(u,a,n);break;case 270:rt(u,0,a)}J.x=e.x+r,J.y=e.y+i,rt(u,J.x,J.y),s&&it(u,J,s,o)}t.transform=u}},{toPoint:yt}=e.AroundHelper,{hasTransparent:wt}=a.ColorConvert,vt={},xt={};function bt(t,n,r,i){if(r){let s,o,l,d;for(let t=0,c=r.length;t<c;t++)s=r[t],e.isString(s)?(l=t/(c-1),o=a.ColorConvert.string(s,i)):(l=s.offset,o=a.ColorConvert.string(s.color,i)),n.addColorStop(l,o),!d&&wt(o)&&(d=!0);d&&(t.isTransparent=!0)}}const{getAngle:St,getDistance:Et}=e.PointHelper,{get:Pt,rotateOfOuter:Bt,scaleOfOuter:Lt}=e.MatrixHelper,{toPoint:kt}=e.AroundHelper,Rt={},Ct={};function At(t,e,a,n,r){let i;const{width:s,height:o}=t;if(s!==o||n){const t=St(e,a);i=Pt(),r?(Lt(i,e,s/o*(n||1),1),Bt(i,e,t+90)):(Lt(i,e,1,s/o*(n||1)),Bt(i,e,t))}return i}const{getDistance:Tt}=e.PointHelper,{toPoint:Ot}=e.AroundHelper,It={},Mt={};const Wt={linearGradient:function(t,a){let{from:n,to:r,type:i,opacity:s}=t;yt(n||"top",a,vt),yt(r||"bottom",a,xt);const o=e.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y),l={type:i,style:o};return bt(l,o,t.stops,s),l},radialGradient:function(t,a){let{from:n,to:r,type:i,opacity:s,stretch:o}=t;kt(n||"center",a,Rt),kt(r||"bottom",a,Ct);const l=e.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,Et(Rt,Ct)),d={type:i,style:l};bt(d,l,t.stops,s);const c=At(a,Rt,Ct,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,a){let{from:n,to:r,type:i,opacity:s,stretch:o}=t;Ot(n||"center",a,It),Ot(r||"bottom",a,Mt);const l=e.Platform.conicGradientSupport?e.Platform.canvas.createConicGradient(0,It.x,It.y):e.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,Tt(It,Mt)),d={type:i,style:l};bt(d,l,t.stops,s);const c=At(a,It,Mt,o||1,e.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:At},{copy:Dt,move:Ht,toOffsetOutBounds:Ft}=e.BoundsHelper,{max:jt,abs:Gt}=Math,Yt={},Ut=new e.Matrix,zt={};function Nt(t,e){let a,n,r,i,s=0,o=0,l=0,d=0;return e.forEach(t=>{a=t.x||0,n=t.y||0,i=1.5*(t.blur||0),r=Gt(t.spread||0),s=jt(s,r+i-n),o=jt(o,r+i+a),l=jt(l,r+i+n),d=jt(d,r+i-a)}),s===o&&o===l&&l===d?s:[s,o,l,d]}function Xt(t,a,n){const{shapeBounds:r}=n;let i,s;e.Platform.fullImageShadow?(Dt(Yt,t.bounds),Ht(Yt,a.x-r.x,a.y-r.y),i=t.bounds,s=Yt):(i=r,s=a),t.copyWorld(n.canvas,i,s)}const{toOffsetOutBounds:qt}=e.BoundsHelper,Vt={};const Qt=Nt;const Zt={shadow:function(t,n,r){let i,s;const{__nowWorld:o}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:g}=r,p=n.getSameCanvas(),_=l.length-1;Ft(c,zt,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}p.setWorldShadow(zt.offsetX+(l.x||0)*f*y,zt.offsetY+(l.y||0)*g*y,(l.blur||0)*f*y,a.ColorConvert.string(l.color)),s=a.Effect.getShadowTransform(t,p,r,l,zt,y),s&&p.setTransform(s),Xt(p,zt,r),s&&p.resetTransform(),i=h,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,h,o,"copy"),i=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(r.canvas,u,c,"destination-out")),e.LeafHelper.copyCanvasByWorld(t,n,p,i,l.blendMode),_&&m<_&&p.clearWorld(i)}),p.recycle(i)},innerShadow:function(t,n,r){let i,s;const{__nowWorld:o}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:g}=r,p=n.getSameCanvas(),_=l.length-1;qt(c,Vt,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}p.save(),p.setWorldShadow(Vt.offsetX+(l.x||0)*f*y,Vt.offsetY+(l.y||0)*g*y,(l.blur||0)*f*y),s=a.Effect.getShadowTransform(t,p,r,l,Vt,y,!0),s&&p.setTransform(s),Xt(p,Vt,r),p.restore(),d?(p.copyWorld(p,h,o,"copy"),p.copyWorld(d,o,o,"source-out"),i=o):(p.copyWorld(r.canvas,u,c,"source-out"),i=h),p.fillWorld(i,a.ColorConvert.string(l.color),"source-in"),e.LeafHelper.copyCanvasByWorld(t,n,p,i,l.blendMode),_&&m<_&&p.clearWorld(i)}),p.recycle(i)},blur:function(t,e,a){const{blur:n}=t.__;a.setWorldBlur(n*t.__nowWorld.a),a.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),a.filter="none"},backgroundBlur:function(t,e,a){},getShadowRenderSpread:Nt,getShadowTransform:function(t,e,a,n,r,i,s){if(n.spread){const a=2*n.spread*i*(s?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Ut.set().scaleOfOuter({x:(r.x+r.width/2)*e.pixelRatio,y:(r.y+r.height/2)*e.pixelRatio},1+a/o,1+a/l),Ut}},isTransformShadow(t){},getInnerShadowSpread:Qt},{excludeRenderBounds:Kt}=e.LeafBoundsHelper;let $t;function Jt(t,e,a,n,r,i,s,o){switch(e){case"grayscale":$t||($t=!0,r.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,a,n,r,i){const s=t.__nowWorld;a.resetTransform(),a.opacity=1,a.useMask(n,s),i&&n.recycle(s);ee(t,e,a,1,r,i)}(t,a,n,r,s,o);break;case"opacity-path":ee(t,a,n,i,s,o);break;case"path":o&&a.restore()}}function te(t){return t.getSameCanvas(!1,!0)}function ee(t,e,a,n,r,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(a,s,void 0,r),i?a.recycle(s):a.clearWorld(s)}a.Group.prototype.__renderMask=function(t,e){let a,n,r,i,s,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(a=l[d],o=a.__.mask,o){s&&(Jt(this,s,t,r,n,i,void 0,!0),n=r=null),"clipping"!==o&&"clipping-path"!==o||Kt(a,e)||a.__render(t,e),i=a.__.opacity,$t=!1,"path"===o||"clipping-path"===o?(i<1?(s="opacity-path",r||(r=te(t))):(s="path",t.save()),a.__clip(r||t,e)):(s="grayscale"===o?"grayscale":"alpha",n||(n=te(t)),r||(r=te(t)),a.__render(n,e));continue}const c=1===i&&a.__.__blendMode;c&&Jt(this,s,t,r,n,i,void 0,!1),Kt(a,e)||a.__render(r||t,e),c&&Jt(this,s,t,r,n,i,c,!1)}Jt(this,s,t,r,n,i,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ne=ae+"_#~&*+\\=|≮≯≈≠=…",re=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 ie(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oe=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),le=ie(ae),de=ie(ne),ce=ie("- —/~|┆·");var he;!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"}(he||(he={}));const{Letter:ue,Single:fe,Before:ge,After:pe,Symbol:_e,Break:me}=he;function ye(t){return se[t]?ue:ce[t]?me:oe[t]?ge:le[t]?pe:de[t]?_e:re.test(t)?fe:ue}const we={trimRight(t){const{words:e}=t;let a,n=0,r=e.length;for(let i=r-1;i>-1&&(a=e[i].data[0]," "===a.char);i--)n++,t.width-=a.width;n&&e.splice(r-n,n)}};function ve(t,e,a){switch(e){case"title":return a?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:xe}=we,{Letter:be,Single:Se,Before:Ee,After:Pe,Symbol:Be,Break:Le}=he;let ke,Re,Ce,Ae,Te,Oe,Ie,Me,We,De,He,Fe,je,Ge,Ye,Ue,ze,Ne=[];function Xe(t,e){We&&!Me&&(Me=We),ke.data.push({char:t,width:e}),Ce+=e}function qe(){Ae+=Ce,ke.width=Ce,Re.words.push(ke),ke={data:[]},Ce=0}function Ve(){Ge&&(Ye.paraNumber++,Re.paraStart=!0,Ge=!1),We&&(Re.startCharSize=Me,Re.endCharSize=We,Me=0),Re.width=Ae,Ue.width?xe(Re):ze&&Qe(),Ne.push(Re),Re={words:[]},Ae=0}function Qe(){Ae>(Ye.maxWidth||0)&&(Ye.maxWidth=Ae)}const{top:Ze,right:Ke,bottom:$e,left:Je}=e.Direction4;function ta(t,e,a){const{bounds:n,rows:r}=t;n[e]+=a;for(let t=0;t<r.length;t++)r[t][e]+=a}const ea={getDrawData:function(t,n){e.isString(t)||(t=String(t));let r=0,i=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{__padding:l}=n;l&&(s?(r=l[Je],s-=l[Ke]+l[Je],!s&&(s=.01)):n.autoSizeAlign||(r=l[Je]),o?(i=l[Ze],o-=l[Ze]+l[$e],!o&&(o=.01)):n.autoSizeAlign||(i=l[Ze]));const d={bounds:{x:r,y:i,width:s,height:o},rows:[],paraNumber:0,font:e.Platform.canvas.font=n.__font};return function(t,a,n){Ye=t,Ne=t.rows,Ue=t.bounds,ze=!Ue.width&&!n.autoSizeAlign;const{__letterSpacing:r,paraIndent:i,textCase:s}=n,{canvas:o}=e.Platform,{width:l}=Ue;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap;Ge=!0,He=null,Me=Ie=We=Ce=Ae=0,ke={data:[]},Re={words:[]},r&&(a=[...a]);for(let n=0,d=a.length;n<d;n++)Oe=a[n],"\n"===Oe?(Ce&&qe(),Re.paraEnd=!0,Ve(),Ge=!0):(De=ye(Oe),De===be&&"none"!==s&&(Oe=ve(Oe,s,!Ce)),Ie=o.measureText(Oe).width,r&&(r<0&&(We=Ie),Ie+=r),Fe=De===Se&&(He===Se||He===be)||He===Se&&De!==Pe,je=!(De!==Ee&&De!==Se||He!==Be&&He!==Pe),Te=Ge&&i?l-i:l,t&&l&&Ae+Ce+Ie>Te&&(e?(Ce&&qe(),Ae&&Ve()):(je||(je=De===be&&He==Pe),Fe||je||De===Le||De===Ee||De===Se||Ce+Ie>Te?(Ce&&qe(),Ae&&Ve()):Ae&&Ve()))," "===Oe&&!0!==Ge&&Ae+Ce===0||(De===Le?(" "===Oe&&Ce&&qe(),Xe(Oe,Ie),qe()):Fe||je?(Ce&&qe(),Xe(Oe,Ie)):Xe(Oe,Ie)),He=De);Ce&&qe(),Ae&&Ve(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else a.split("\n").forEach(t=>{Ye.paraNumber++,Ae=o.measureText(t).width,Ne.push({x:i||0,text:t,width:Ae,paraStart:!0}),ze&&Qe()})}(d,t,n),l&&function(t,e,a,n,r){if(!n&&a.autoSizeAlign)switch(a.textAlign){case"left":ta(e,"x",t[Je]);break;case"right":ta(e,"x",-t[Ke])}if(!r&&a.autoSizeAlign)switch(a.verticalAlign){case"top":ta(e,"y",t[Ze]);break;case"bottom":ta(e,"y",-t[$e])}}(l,d,n,s,o),function(t,e){const{rows:a,bounds:n}=t,r=a.length,{__lineHeight:i,__baseLine:s,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,m=i*r+(h?h*(t.paraNumber-1):0),y=s;if(l&&m>_)m=Math.max(_,i),r>1&&(t.overflow=r);else if(_||u)switch(c){case"middle":g+=(_-m)/2;break;case"bottom":g+=_-m}y+=g;let w,v,x,b=p||u?p:t.maxWidth;for(let s=0,c=r;s<c;s++){if(w=a[s],w.x=f,w.width<p||w.width>p&&!l)switch(d){case"center":w.x+=(b-w.width)/2;break;case"right":w.x+=b-w.width}w.paraStart&&h&&s>0&&(y+=h),w.y=y,y+=i,t.overflow>s&&y>m&&(w.isOverflow=!0,t.overflow=s+1),v=w.x,x=w.width,o<0&&(w.width<0?(x=-w.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&p&&p<x&&(w.isOverflow=!0,t.overflow||(t.overflow=a.length))}n.y=g,n.height=m}(d,n),n.__isCharMode&&function(t,e,a){const{rows:n}=t,{textAlign:r,paraIndent:i,letterSpacing:s}=e,o=a&&r.includes("both"),l=o||a&&r.includes("justify"),d=l&&r.includes("letter");let c,h,u,f,g,p,_,m,y,w;n.forEach(t=>{t.words&&(g=i&&t.paraStart?i:0,m=t.words.length,l&&(w=!t.paraEnd||o,h=a-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?h/(m-1):0),p=s||t.isOverflow||d?0:u?1:2,t.isOverflow&&!s&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,a)=>{1===p?(_={char:"",x:c},c=function(t,e,a){return t.forEach(t=>{a.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,a,n,r){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,a.push(t)),e+=t.width,r&&(e+=r)}),e}(e.data,c,t.data,t.isOverflow,w&&f),w&&(y=a===m-1,u?y||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(y?1:0))))})),t.words=null)})}(d,n,s),d.overflow&&function(t,a,n,r){if(!r)return;const{rows:i,overflow:s}=t;let{textOverflow:o}=a;if(i.splice(s),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.Platform.canvas.measureText(o).width:0,c=n+r-d;("none"===a.textWrap?i:[i[s-1]]).forEach(e=>{if(e.isOverflow&&e.data){let a=e.data.length-1;for(let n=a;n>-1&&(t=e.data[n],l=t.x+t.width,!(n===a&&l<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,n,r,s),"none"!==n.textDecoration&&function(t,n){let r,i=0;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,e.isObject(o)?(r=o.type,o.color&&(t.decorationColor=a.ColorConvert.string(o.color)),o.offset&&(i=Math.min(.3*s,Math.max(o.offset,.15*-s)))):r=o,r){case"under":t.decorationY=[.15*s+i];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+i,.35*-s]}}(d,n),d}};const aa={string:function(t,n){if(!t)return"#000";const r=e.isNumber(n)&&n<1;if(e.isString(t)){if(!r||!a.ColorConvert.object)return t;t=a.ColorConvert.object(t)}let i=e.isUndefined(t.a)?1:t.a;r&&(i*=n);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(a.TextConvert,ea),Object.assign(a.ColorConvert,aa),Object.assign(a.Paint,D),Object.assign(a.PaintImage,mt),Object.assign(a.PaintGradient,Wt),Object.assign(a.Effect,Zt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return e.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=o,exports.useCanvas=i,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]}})}),Object.keys(a).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return a[t]}})});
1
+ "use strict";var t,e=require("@leafer/core"),a=require("@leafer-ui/draw");exports.PathNodeHandleType=void 0,(t=exports.PathNodeHandleType||(exports.PathNodeHandleType={}))[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror";class n extends e.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:a}=this;this.view.width=Math.ceil(t*a),this.view.height=Math.ceil(e*a),this.clientBounds=this.bounds}}e.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),e.canvasPatch(Path2D.prototype);const{mineType:r}=e.FileHelper;function i(t,a){e.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,a)=>new Promise((n,i)=>{t.convertToBlob({type:r(e),quality:a}).then(t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>i(t),e.readAsDataURL(t)}).catch(t=>{i(t)})}),canvasToBolb:(t,e,a)=>t.convertToBlob({type:r(e),quality:a}),canvasSaveAs:(t,e,a)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((a,n)=>{let r=new XMLHttpRequest;r.open("GET",e.Platform.image.getRealURL(t),!0),r.responseType="blob",r.onload=()=>{createImageBitmap(r.response).then(t=>{a(t)}).catch(t=>{n(t)})},r.onerror=t=>n(t),r.send()})},e.Platform.canvas=e.Creator.canvas(),e.Platform.conicGradientSupport=!!e.Platform.canvas.context.createConicGradient}Object.assign(e.Creator,{canvas:(t,e)=>new n(t,e),image:t=>new e.LeaferImage(t)}),e.Platform.name="web",e.Platform.isWorker=!0,e.Platform.backgrounder=!0,e.Platform.requestRender=function(t){requestAnimationFrame(t)},e.defineKey(e.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:s}=navigator;s.indexOf("Firefox")>-1?(e.Platform.conicGradientRotate90=!0,e.Platform.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.Platform.fullImageShadow=!0),s.indexOf("Windows")>-1?(e.Platform.os="Windows",e.Platform.intWheelDeltaY=!0):s.indexOf("Mac")>-1?e.Platform.os="Mac":s.indexOf("Linux")>-1&&(e.Platform.os="Linux");class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new e.LeafList;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,a){this.totalTimes=0,this.config={},this.__updatedList=new e.LeafList,this.target=t,a&&(this.config=e.DataHelper.default(a,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(e.RenderEvent.REQUEST)}__onAttrChange(t){this.config.usePartLayout&&this.__updatedList.add(t.target),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===e.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,a=e.length;t<a;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new e.WatchEvent(e.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new e.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[e.PropertyEvent.CHANGE,this.__onAttrChange,this],[[e.ChildEvent.ADD,e.ChildEvent.REMOVE],this.__onChildEvent,this],[e.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:d,updateChange:c}=e.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=e.BranchHelper;const{worldBounds:f}=e.LeafBoundsHelper;class p{constructor(t){this.updatedBounds=new e.Bounds,this.beforeBounds=new e.Bounds,this.afterBounds=new e.Bounds,e.isArray(t)&&(t=new e.LeafList(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,f),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:g,updateAllChange:_}=e.LeafHelper,m=e.Debug.get("Layouter");class y{constructor(t,a){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new e.LeafLevelList,this.target=t,a&&(this.config=e.DataHelper.default(a,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(e.LayoutEvent.START),this.layoutOnce(),t.emitEvent(new e.LayoutEvent(e.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(e.WatchEvent.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const a=e.Run.start("PartLayout"),{target:n,__updatedList:r}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=e.LayoutEvent,f=this.getBlocks(r);f.forEach(t=>t.setBefore()),n.emitEvent(new e.LayoutEvent(i,f,this.times)),this.extraBlock=null,r.sort(),function(t,e){let a;t.list.forEach(t=>{a=t.__layout,e.without(t)&&!a.proxyZoom&&(a.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):a.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))})}(r,this.__levelList),function(t){let e,a,n;t.sort(!0),t.levels.forEach(r=>{e=t.levelMap[r];for(let t=0,r=e.length;t<r;t++){if(a=e[t],a.isBranch&&a.__tempNumber){n=a.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||d(n[t])}d(a)}})}(this.__levelList),function(t){t.list.forEach(c)}(r),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),n.emitEvent(new e.LayoutEvent(s,f,this.times)),n.emitEvent(new e.LayoutEvent(o,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,e.Run.end(a)}fullLayout(){const t=e.Run.start("FullLayout"),{target:a}=this,{BEFORE:n,LAYOUT:r,AFTER:i}=e.LayoutEvent,s=this.getBlocks(new e.LeafList(a));a.emitEvent(new e.LayoutEvent(n,s,this.times)),y.fullLayout(a),s.forEach(t=>{t.setAfter()}),a.emitEvent(new e.LayoutEvent(r,s,this.times)),a.emitEvent(new e.LayoutEvent(i,s,this.times)),this.addBlocks(s),e.Run.end(t)}static fullLayout(t){g(t,!0),t.isBranch?e.BranchHelper.updateBounds(t):e.LeafHelper.updateBounds(t),_(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:a}=this.extraBlock||(this.extraBlock=new p([]));e.length?a.add(t.__world):a.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[e.LayoutEvent.REQUEST,this.layout,this],[e.LayoutEvent.AGAIN,this.layoutAgain,this],[e.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const w=e.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,a,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=a,n&&(this.config=e.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(e.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(e.RenderEvent.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(e.RenderEvent.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(e.RenderEvent.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:a}=this;this.times=0,this.totalBounds=new e.Bounds,w.log(a.innerName,"---\x3e");try{this.emitRender(e.RenderEvent.START),this.renderOnce(t),this.emitRender(e.RenderEvent.END,this.totalBounds),e.ImageManager.clearRecycled()}catch(t){this.rendering=!1,w.error(t)}w.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return w.warn("rendering");if(this.times>3)return w.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new e.Bounds,this.renderOptions={},t)this.emitRender(e.RenderEvent.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(e.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(e.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(e.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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const a=e.Run.start("PartRender"),{canvas:n}=this,r=t.getIntersect(n.bounds),i=new e.Bounds(r);n.save(),r.spread(v.clipSpread).ceil();const{ceilPartPixel:s}=this.config;n.clipWorld(r,s),n.clearWorld(r,s),this.__render(r,i),n.restore(),e.Run.end(a)}fullRender(){const t=e.Run.start("FullRender"),{canvas:a}=this;a.save(),a.clear(),this.__render(a.bounds),a.restore(),e.Run.end(t)}__render(t,a){const{canvas:n,target:r}=this,i=t.includes(r.__world),s=i?{includes:i}:{bounds:t,includes:i};this.needFill&&n.fillWorld(t,this.config.fill),e.Debug.showRepaint&&e.Debug.drawRepaint(n,t),this.config.useCellRender&&(s.cellList=this.getCellList()),e.Platform.render(r,n,s),this.renderBounds=a=a||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=a:this.totalBounds.add(a),n.updateRender(a)}getCellList(){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const a=new e.Bounds;a.setList(t),t.length=0,t.push(a)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const a=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&t>n)return e.Platform.requestRender(a);const{frames:r}=this;r.length>30&&r.shift(),r.push(t),this.FPS=Math.round(r.reduce((t,e)=>t+e,0)/r.length),this.requestTime=0,this.checkRender()};e.Platform.requestRender(a)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:a,height:n}=t.old;if(!new e.Bounds(0,0,a,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new e.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||w.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,a,n){this.target.emitEvent(new e.RenderEvent(t,this.times,a,n))}__listenEvents(){this.__eventIds=[this.target.on_([[e.RenderEvent.REQUEST,this.update,this],[e.LayoutEvent.END,this.__onLayoutEnd,this],[e.RenderEvent.AGAIN,this.renderAgain,this],[e.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function x(t,e,n){t.__.__font?a.Paint.fillText(t,e,n):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function b(t,n,r,i,s){const o=r.__;e.isObject(t)?a.Paint.drawStrokesStyle(t,n,!1,r,i,s):(i.setStroke(t,o.__strokeWidth*n,o),i.stroke()),o.__useArrow&&a.Paint.strokeArrow(t,r,i,s)}function P(t,n,r,i,s){const o=r.__;e.isObject(t)?a.Paint.drawStrokesStyle(t,n,!0,r,i,s):(i.setStroke(t,o.__strokeWidth*n,o),a.Paint.drawTextStroke(r,i,s))}function S(t,n,r,i,s){const o=i.getSameCanvas(!0,!0);o.font=r.__.__font,P(t,2,r,o,s),o.blendMode="outside"===n?"destination-out":"destination-in",a.Paint.fillText(r,o,s),o.blendMode="normal",e.LeafHelper.copyCanvasByWorld(r,i,o),o.recycle(r.__nowWorld)}v.clipSpread=10,Object.assign(e.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,a)=>new v(t,e,a),selector:(t,e)=>{},interaction:(t,e,a,n)=>{}}),e.Platform.layout=y.fullLayout,e.Platform.render=function(t,a,n){const r=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new e.LeafList,t.__render(a,n),n.topList.length&&n.topList.forEach(t=>t.__render(a,r))};const{getSpread:E,copyAndSpread:B,toOuterOf:L,getOuterOf:k,getByMove:R,move:C,getIntersectData:A}=e.BoundsHelper,T={};let O;const{stintSet:I}=e.DataHelper,{hasTransparent:M}=a.ColorConvert;function W(t,n,r){if(!e.isObject(n)||!1===n.visible||0===n.opacity)return;let i;const{boxBounds:s}=r.__layout;switch(n.type){case"image":if(!n.url)return;i=a.PaintImage.image(r,t,n,s,!O||!O[n.url]);break;case"linear":i=a.PaintGradient.linearGradient(n,s);break;case"radial":i=a.PaintGradient.radialGradient(n,s);break;case"angular":i=a.PaintGradient.conicGradient(n,s);break;case"solid":const{type:o,color:l,opacity:d}=n;i={type:o,style:a.ColorConvert.string(l,d)};break;default:e.isUndefined(n.r)||(i={type:"solid",style:a.ColorConvert.string(n)})}if(i&&(i.originPaint=n,e.isString(i.style)&&M(i.style)&&(i.isTransparent=!0),n.style)){if(0===n.style.strokeWidth)return;i.strokeStyle=n.style}return i}const D={compute:function(t,n){const r=n.__,i=[];let s,o,l,d=r.__input[t];e.isArray(d)||(d=[d]),O=a.PaintImage.recycleImage(t,r);for(let e,a=0,r=d.length;a<r;a++)(e=W(t,d[a],n))&&(i.push(e),e.strokeStyle&&(l||(l=1),e.strokeStyle.strokeWidth&&(l=Math.max(l,e.strokeStyle.strokeWidth))));r["_"+t]=i.length?i:void 0,i.length?(i.every(t=>t.isTransparent)&&(i.some(t=>t.image)&&(s=!0),o=!0),"fill"===t?(I(r,"__isAlphaPixelFill",s),I(r,"__isTransparentFill",o)):(I(r,"__isAlphaPixelStroke",s),I(r,"__isTransparentStroke",o),I(r,"__hasMultiStrokeStyle",l))):r.__removePaint(t,!1)},fill:function(t,e,a,n){a.fillStyle=t,x(e,a,n)},fills:function(t,e,n,r){let i,s,o;for(let l=0,d=t.length;l<d;l++){if(i=t[l],s=i.originPaint,i.image){if(o?o++:o=1,a.PaintImage.checkImage(i,!e.__.__font,e,n,r))continue;if(!i.style){1===o&&i.image.isPlacehold&&e.drawImagePlaceholder(i,n,r);continue}}if(n.fillStyle=i.style,i.transform||s.scaleFixed){if(n.save(),i.transform&&n.transform(i.transform),s.scaleFixed){const{scaleX:t,scaleY:a}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&a>1)&&n.scale(1/t,1/a)}s.blendMode&&(n.blendMode=s.blendMode),x(e,n,r),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),x(e,n,r),n.restoreBlendMode()):x(e,n,r)}},fillPathOrText:x,fillText:function(t,e,a){const n=t.__,{rows:r,decorationY:i}=n.__textDrawData;let s;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,a=r.length;t<a;t++)s=r[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.fillText(t.char,t.x,s.y)});if(i){const{decorationColor:t,decorationHeight:a}=n.__textDrawData;t&&(e.fillStyle=t),r.forEach(t=>i.forEach(n=>e.fillRect(t.x,t.y+n,t.width,a)))}},stroke:function(t,n,r,i){const s=n.__;if(s.__strokeWidth)if(s.__font)a.Paint.strokeText(t,n,r,i);else switch(s.strokeAlign){case"center":b(t,1,n,r,i);break;case"inside":!function(t,e,a,n){a.save(),a.clipUI(e),b(t,2,e,a,n),a.restore()}(t,n,r,i);break;case"outside":!function(t,a,n,r){const i=a.__;if(i.__fillAfterStroke)b(t,2,a,n,r);else{const{renderBounds:s}=a.__layout,o=n.getSameCanvas(!0,!0);a.__drawRenderPath(o),b(t,2,a,o,r),o.clipUI(i),o.clearWorld(s),e.LeafHelper.copyCanvasByWorld(a,n,o),o.recycle(a.__nowWorld)}}(t,n,r,i)}},strokes:function(t,e,n,r){a.Paint.stroke(t,e,n,r)},strokeText:function(t,e,a,n){switch(e.__.strokeAlign){case"center":P(t,1,e,a,n);break;case"inside":S(t,"inside",e,a,n);break;case"outside":e.__.__fillAfterStroke?P(t,2,e,a,n):S(t,"outside",e,a,n)}},drawTextStroke:function(t,e,a){let n,r=t.__.__textDrawData;const{rows:i,decorationY:s}=r;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)});if(s){const{decorationHeight:t}=r;i.forEach(a=>s.forEach(n=>e.strokeRect(a.x,a.y+n,a.width,t)))}},drawStrokesStyle:function(t,e,n,r,i,s){let o;const l=r.__,{__hasMultiStrokeStyle:d}=l;d||i.setStroke(void 0,l.__strokeWidth*e,l);for(let c=0,h=t.length;c<h;c++)if(o=t[c],(!o.image||!a.PaintImage.checkImage(o,!1,r,i,s))&&o.style){if(d){const{strokeStyle:t}=o;t?i.setStroke(o.style,l.__getRealStrokeWidth(t)*e,l,t):i.setStroke(o.style,l.__strokeWidth*e,l)}else i.strokeStyle=o.style;o.originPaint.blendMode?(i.saveBlendMode(o.originPaint.blendMode),n?a.Paint.drawTextStroke(r,i,s):i.stroke(),i.restoreBlendMode()):n?a.Paint.drawTextStroke(r,i,s):i.stroke()}},shape:function(t,a,n){const r=a.getSameCanvas(),i=a.bounds,s=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;L(o.strokeSpread?(B(T,o.boxBounds,o.strokeSpread),T):o.boxBounds,s,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(i.includes(l))p=r,d=f=l,c=s;else{let r;if(e.Platform.fullImageShadow)r=l;else{const t=o.renderShapeSpread?E(i,e.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):i;r=A(t,l)}u=i.getFitMatrix(r);let{a:m,d:y}=u;u.a<1&&(p=a.getSameCanvas(),t.__renderShape(p,n),g*=m,_*=y),f=k(l,u),d=R(f,-u.e,-u.f),c=k(s,u),C(c,-u.e,-u.f);const w=n.matrix;w?(h=new e.Matrix(u),h.multiply(w),m*=w.scaleX,y*=w.scaleY):h=u,h.withScale(m,y),n=Object.assign(Object.assign({},n),{matrix:h})}return t.__renderShape(r,n),{canvas:r,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let H,F=new e.Bounds;const{isSame:j}=e.BoundsHelper;function G(t,e,n,r,i,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=r.width/e.pixelRatio,e.__naturalHeight=r.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||a.PaintImage.createData(i,r,n,s),!0}function Y(t,a){z(t,e.ImageEvent.LOAD,a)}function N(t,a){z(t,e.ImageEvent.LOADED,a)}function U(t,a,n){a.error=n,t.forceUpdate("surface"),z(t,e.ImageEvent.ERROR,a)}function z(t,a,n){t.hasEvent(a)&&t.emitEvent(new e.ImageEvent(a,n))}function X(t,e){const{leafer:a}=t;a&&a.viewReady&&(a.renderer.ignore=e)}const{get:q,translate:V}=e.MatrixHelper,Q=new e.Bounds,Z={},K={};function $(t,a,n,r){const i=e.isString(t)||r?(r?n-r*a:n%a)/((r||Math.floor(n/a))-1):t;return"auto"===t&&i<0?0:i}let J={},tt=e.getMatrixData();const{get:et,set:at,rotateOfOuter:nt,translate:rt,scaleOfOuter:it,multiplyParent:st,scale:ot,rotate:lt,skew:dt}=e.MatrixHelper;function ct(t,e,a,n,r,i,s,o){s&&lt(t,s),o&&dt(t,o.x,o.y),r&&ot(t,r,i),rt(t,e.x+a,e.y+n)}function ht(t,e,a,n){return new(a||(a=Promise))(function(r,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function o(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof a?e:new a(function(t){t(e)})).then(s,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ut,scale:ft,copy:pt}=e.MatrixHelper,{getFloorScale:gt}=e.MathHelper,{abs:_t}=Math;const mt={image:function(t,a,n,r,i){let s,o;const l=e.ImageManager.get(n);return H&&n===H.paint&&j(r,H.boxBounds)?s=H.leafPaint:(s={type:n.type,image:l},l.hasAlphaPixel&&(s.isTransparent=!0),H=l.use>1?{leafPaint:s,paint:n,boxBounds:F.set(r)}:null),(i||l.loading)&&(o={image:l,attrName:a,attrValue:n}),l.ready?(G(t,a,n,l,s,r),i&&(Y(t,o),N(t,o))):l.error?i&&U(t,o,l.error):(i&&(X(t,!0),Y(t,o)),s.loadId=l.load(()=>{X(t,!1),t.destroyed||(G(t,a,n,l,s,r)&&(l.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),N(t,o)),s.loadId=void 0},e=>{X(t,!1),U(t,o,e),s.loadId=void 0},n.lod&&l.getThumbSize(n.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):l.isPlacehold=!0)),s},checkImage:function(t,n,r,i,s){const{scaleX:o,scaleY:l}=a.PaintImage.getImageRenderScaleData(t,r,i,s),{image:d,data:c,originPaint:h}=t,{exporting:u,snapshot:f}=s;return!(!c||t.patternId===o+"-"+l&&!u||f)&&(n&&(c.repeat?n=!1:h.changeful||"miniapp"===e.Platform.name&&e.ResizeEvent.isResizing(r)||u||(n=e.Platform.image.isLarge(d,o,l)||d.width*o>8096||d.height*l>8096)),n?(r.__.__isFastShadow&&(i.fillStyle=t.style||"#000",i.fill()),a.PaintImage.drawImage(t,o,l,r,i,s),!0):(!t.style||h.sync||u?a.PaintImage.createPattern(t,r,i,s):a.PaintImage.createPatternTask(t,r,i,s),!1))},drawImage:function(t,e,a,n,r,i){const{data:s,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=s,h=o.getFull(s.filters),u=n.__;let f,{width:p,height:g}=o;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(r.save(),f&&r.clipUI(n),l&&(r.blendMode=l),d&&(r.opacity*=d),c&&r.transform(c),r.drawImage(h,0,0,p,g),r.restore()):(s.scaleX&&(p*=s.scaleX,g*=s.scaleY),r.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,a,n){const r=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:i}=t;if(a){const{pixelRatio:t}=a;r.scaleX*=t,r.scaleY*=t}return i&&i.scaleX&&(r.scaleX*=Math.abs(i.scaleX),r.scaleY*=Math.abs(i.scaleY)),r},recycleImage:function(t,a){const n=a["_"+t];if(e.isArray(n)){let r,i,s,o,l;for(let d=0,c=n.length;d<c;d++)r=n[d],i=r.image,l=i&&i.url,l&&(s||(s={}),s[l]=!0,e.ImageManager.recyclePaint(r),i.loading&&(o||(o=a.__input&&a.__input[t]||[],e.isArray(o)||(o=[o])),i.unload(n[d].loadId,!o.some(t=>t.url===l))));return s}return null},createPatternTask:function(t,n,r,i){t.patternTask||(t.patternTask=e.ImageManager.patternTasker.add(()=>ht(this,void 0,void 0,function*(){a.PaintImage.createPattern(t,n,r,i),n.forceUpdate("surface")}),0,()=>(t.patternTask=null,r.bounds.hit(n.__nowWorld))))},createPattern:function(t,n,r,i){let{scaleX:s,scaleY:o}=a.PaintImage.getImageRenderScaleData(t,n,r,i),l=s+"-"+o;if(t.patternId!==l&&!n.destroyed&&(!e.Platform.image.isLarge(t.image,s,o)||t.data.repeat)){const{image:r,data:i}=t,{transform:d,gap:c}=i,h=a.PaintImage.getPatternFixScale(t,s,o);let u,f,p,{width:g,height:_}=r;h&&(s*=h,o*=h),g*=s,_*=o,c&&(f=c.x*s/_t(i.scaleX||1),p=c.y*o/_t(i.scaleY||1)),(d||1!==s||1!==o)&&(s*=gt(g+(f||0)),o*=gt(_+(p||0)),u=ut(),d&&pt(u,d),ft(u,1/s,1/o));const m=r.getCanvas(g,_,i.opacity,i.filters,f,p,n.leafer&&n.leafer.config.smooth,i.interlace),y=r.getPattern(m,i.repeat||e.Platform.origin.noRepeat||"no-repeat",u,t);t.style=y,t.patternId=l}},getPatternFixScale:function(t,a,n){const{image:r}=t;let i,s=e.Platform.image.maxPatternSize,o=r.width*r.height;return r.isSVG?a>1&&(i=Math.ceil(a)/a):s>o&&(s=o),(o*=a*n)>s&&(i=Math.sqrt(s/o)),i},createData:function(t,e,n,r){t.data=a.PaintImage.getPatternData(n,r,e)},getPatternData:function(t,n,r){t.padding&&(n=Q.set(n).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:i,height:s}=r,{opacity:o,mode:l,align:d,offset:c,scale:h,size:u,rotation:f,skew:p,clipSize:g,repeat:_,gap:m,filters:y,interlace:w}=t,v=n.width===i&&n.height===s,x={mode:l},b="center"!==d&&(f||0)%180==90;let P,S;switch(e.BoundsHelper.set(K,0,0,b?s:i,b?i:s),l&&"cover"!==l&&"fit"!==l?((h||u)&&(e.MathHelper.getScaleData(h,u,r,Z),P=Z.scaleX,S=Z.scaleY),(d||m||_)&&(P&&e.BoundsHelper.scale(K,P,S,!0),d&&e.AlignHelper.toPoint(d,K,n,K,!0,!0))):v&&!f||(P=S=e.BoundsHelper.getFitScale(n,K,"fit"!==l),e.BoundsHelper.put(n,r,d,P,!1,K),e.BoundsHelper.scale(K,P,S,!0)),c&&e.PointHelper.move(K,c),l){case"stretch":v?P&&(P=S=void 0):(P=n.width/i,S=n.height/s,a.PaintImage.stretchMode(x,n,P,S));break;case"normal":case"clip":if(K.x||K.y||P||g||f||p){let t,e;g&&(t=n.width/g.width,e=n.height/g.height),a.PaintImage.clipMode(x,n,K.x,K.y,P,S,f,p,t,e),t&&(P=P?P*t:t,S=S?S*e:e)}break;case"repeat":(!v||P||f||p)&&a.PaintImage.repeatMode(x,n,i,s,K.x,K.y,P,S,f,p,d,t.freeTransform),_||(x.repeat="repeat");const r=e.isObject(_);(m||r)&&(x.gap=function(t,a,n,r,i){let s,o;e.isObject(t)?(s=t.x,o=t.y):s=o=t;return{x:$(s,n,i.width,a&&a.x),y:$(o,r,i.height,a&&a.y)}}(m,r&&_,K.width,K.height,n));break;default:P&&a.PaintImage.fillOrFitMode(x,n,K.x,K.y,P,S,f)}return x.transform||(n.x||n.y)&&V(x.transform=q(),n.x,n.y),P&&(x.scaleX=P,x.scaleY=S),o&&o<1&&(x.opacity=o),y&&(x.filters=y),_&&(x.repeat=e.isString(_)?"x"===_?"repeat-x":"repeat-y":"repeat"),w&&(x.interlace=e.isNumber(w)||"percent"===w.type?{type:"x",offset:w}:w),x},stretchMode:function(t,e,a,n){const r=et(),{x:i,y:s}=e;i||s?rt(r,i,s):r.onlyScale=!0,ot(r,a,n),t.transform=r},fillOrFitMode:function(t,e,a,n,r,i,s){const o=et();rt(o,e.x+a,e.y+n),ot(o,r,i),s&&nt(o,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=o},clipMode:function(t,e,a,n,r,i,s,o,l,d){const c=et();ct(c,e,a,n,r,i,s,o),l&&(s||o?(at(tt),it(tt,e,l,d),st(c,tt)):it(c,e,l,d)),t.transform=c},repeatMode:function(t,e,a,n,r,i,s,o,l,d,c,h){const u=et();if(h)ct(u,e,r,i,s,o,l,d);else{if(l)if("center"===c)nt(u,{x:a/2,y:n/2},l);else switch(lt(u,l),l){case 90:rt(u,n,0);break;case 180:rt(u,a,n);break;case 270:rt(u,0,a)}J.x=e.x+r,J.y=e.y+i,rt(u,J.x,J.y),s&&it(u,J,s,o)}t.transform=u}},{toPoint:yt}=e.AroundHelper,{hasTransparent:wt}=a.ColorConvert,vt={},xt={};function bt(t,n,r,i){if(r){let s,o,l,d;for(let t=0,c=r.length;t<c;t++)s=r[t],e.isString(s)?(l=t/(c-1),o=a.ColorConvert.string(s,i)):(l=s.offset,o=a.ColorConvert.string(s.color,i)),n.addColorStop(l,o),!d&&wt(o)&&(d=!0);d&&(t.isTransparent=!0)}}const{getAngle:Pt,getDistance:St}=e.PointHelper,{get:Et,rotateOfOuter:Bt,scaleOfOuter:Lt}=e.MatrixHelper,{toPoint:kt}=e.AroundHelper,Rt={},Ct={};function At(t,e,a,n,r){let i;const{width:s,height:o}=t;if(s!==o||n){const t=Pt(e,a);i=Et(),r?(Lt(i,e,s/o*(n||1),1),Bt(i,e,t+90)):(Lt(i,e,1,s/o*(n||1)),Bt(i,e,t))}return i}const{getDistance:Tt}=e.PointHelper,{toPoint:Ot}=e.AroundHelper,It={},Mt={};const Wt={linearGradient:function(t,a){let{from:n,to:r,type:i,opacity:s}=t;yt(n||"top",a,vt),yt(r||"bottom",a,xt);const o=e.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y),l={type:i,style:o};return bt(l,o,t.stops,s),l},radialGradient:function(t,a){let{from:n,to:r,type:i,opacity:s,stretch:o}=t;kt(n||"center",a,Rt),kt(r||"bottom",a,Ct);const l=e.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,St(Rt,Ct)),d={type:i,style:l};bt(d,l,t.stops,s);const c=At(a,Rt,Ct,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,a){let{from:n,to:r,type:i,opacity:s,stretch:o}=t;Ot(n||"center",a,It),Ot(r||"bottom",a,Mt);const l=e.Platform.conicGradientSupport?e.Platform.canvas.createConicGradient(0,It.x,It.y):e.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,Tt(It,Mt)),d={type:i,style:l};bt(d,l,t.stops,s);const c=At(a,It,Mt,o||1,e.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:At},{copy:Dt,move:Ht,toOffsetOutBounds:Ft}=e.BoundsHelper,{max:jt,abs:Gt}=Math,Yt={},Nt=new e.Matrix,Ut={};function zt(t,e){let a,n,r,i,s=0,o=0,l=0,d=0;return e.forEach(t=>{a=t.x||0,n=t.y||0,i=1.5*(t.blur||0),r=Gt(t.spread||0),s=jt(s,r+i-n),o=jt(o,r+i+a),l=jt(l,r+i+n),d=jt(d,r+i-a)}),s===o&&o===l&&l===d?s:[s,o,l,d]}function Xt(t,a,n){const{shapeBounds:r}=n;let i,s;e.Platform.fullImageShadow?(Dt(Yt,t.bounds),Ht(Yt,a.x-r.x,a.y-r.y),i=t.bounds,s=Yt):(i=r,s=a),t.copyWorld(n.canvas,i,s)}const{toOffsetOutBounds:qt}=e.BoundsHelper,Vt={};const Qt=zt;const Zt={shadow:function(t,n,r){let i,s;const{__nowWorld:o}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=r,g=n.getSameCanvas(),_=l.length-1;Ft(c,Ut,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.setWorldShadow(Ut.offsetX+(l.x||0)*f*y,Ut.offsetY+(l.y||0)*p*y,(l.blur||0)*f*y,a.ColorConvert.string(l.color)),s=a.Effect.getShadowTransform(t,g,r,l,Ut,y),s&&g.setTransform(s),Xt(g,Ut,r),s&&g.resetTransform(),i=h,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,h,o,"copy"),i=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(r.canvas,u,c,"destination-out")),e.LeafHelper.copyCanvasByWorld(t,n,g,i,l.blendMode),_&&m<_&&g.clearWorld(i)}),g.recycle(i)},innerShadow:function(t,n,r){let i,s;const{__nowWorld:o}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=r,g=n.getSameCanvas(),_=l.length-1;qt(c,Vt,h),l.forEach((l,m)=>{let y=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(Vt.offsetX+(l.x||0)*f*y,Vt.offsetY+(l.y||0)*p*y,(l.blur||0)*f*y),s=a.Effect.getShadowTransform(t,g,r,l,Vt,y,!0),s&&g.setTransform(s),Xt(g,Vt,r),g.restore(),d?(g.copyWorld(g,h,o,"copy"),g.copyWorld(d,o,o,"source-out"),i=o):(g.copyWorld(r.canvas,u,c,"source-out"),i=h),g.fillWorld(i,a.ColorConvert.string(l.color),"source-in"),e.LeafHelper.copyCanvasByWorld(t,n,g,i,l.blendMode),_&&m<_&&g.clearWorld(i)}),g.recycle(i)},blur:function(t,e,a){const{blur:n}=t.__;a.setWorldBlur(n*t.__nowWorld.a),a.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),a.filter="none"},backgroundBlur:function(t,e,a){},getShadowRenderSpread:zt,getShadowTransform:function(t,e,a,n,r,i,s){if(n.spread){const a=2*n.spread*i*(s?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Nt.set().scaleOfOuter({x:(r.x+r.width/2)*e.pixelRatio,y:(r.y+r.height/2)*e.pixelRatio},1+a/o,1+a/l),Nt}},isTransformShadow(t){},getInnerShadowSpread:Qt},{excludeRenderBounds:Kt}=e.LeafBoundsHelper;let $t;function Jt(t,e,a,n,r,i,s,o){switch(e){case"grayscale":$t||($t=!0,r.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,a,n,r,i){const s=t.__nowWorld;a.resetTransform(),a.opacity=1,a.useMask(n,s),i&&n.recycle(s);ee(t,e,a,1,r,i)}(t,a,n,r,s,o);break;case"opacity-path":ee(t,a,n,i,s,o);break;case"path":o&&a.restore()}}function te(t){return t.getSameCanvas(!1,!0)}function ee(t,e,a,n,r,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(a,s,void 0,r),i?a.recycle(s):a.clearWorld(s)}a.Group.prototype.__renderMask=function(t,e){let a,n,r,i,s,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(a=l[d],o=a.__.mask,o){s&&(Jt(this,s,t,r,n,i,void 0,!0),n=r=null),"clipping"!==o&&"clipping-path"!==o||Kt(a,e)||a.__render(t,e),i=a.__.opacity,$t=!1,"path"===o||"clipping-path"===o?(i<1?(s="opacity-path",r||(r=te(t))):(s="path",t.save()),a.__clip(r||t,e)):(s="grayscale"===o?"grayscale":"alpha",n||(n=te(t)),r||(r=te(t)),a.__render(n,e));continue}const c=1===i&&a.__.__blendMode;c&&Jt(this,s,t,r,n,i,void 0,!1),Kt(a,e)||a.__render(r||t,e),c&&Jt(this,s,t,r,n,i,c,!1)}Jt(this,s,t,r,n,i,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ne=ae+"_#~&*+\\=|≮≯≈≠=…",re=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 ie(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oe=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),le=ie(ae),de=ie(ne),ce=ie("- —/~|┆·");var he;!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"}(he||(he={}));const{Letter:ue,Single:fe,Before:pe,After:ge,Symbol:_e,Break:me}=he;function ye(t){return se[t]?ue:ce[t]?me:oe[t]?pe:le[t]?ge:de[t]?_e:re.test(t)?fe:ue}const we={trimRight(t){const{words:e}=t;let a,n=0,r=e.length;for(let i=r-1;i>-1&&(a=e[i].data[0]," "===a.char);i--)n++,t.width-=a.width;n&&e.splice(r-n,n)}};function ve(t,e,a){switch(e){case"title":return a?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:xe}=we,{Letter:be,Single:Pe,Before:Se,After:Ee,Symbol:Be,Break:Le}=he;let ke,Re,Ce,Ae,Te,Oe,Ie,Me,We,De,He,Fe,je,Ge,Ye,Ne,Ue,ze=[];function Xe(t,e){We&&!Me&&(Me=We),ke.data.push({char:t,width:e}),Ce+=e}function qe(){Ae+=Ce,ke.width=Ce,Re.words.push(ke),ke={data:[]},Ce=0}function Ve(){Ge&&(Ye.paraNumber++,Re.paraStart=!0,Ge=!1),We&&(Re.startCharSize=Me,Re.endCharSize=We,Me=0),Re.width=Ae,Ne.width?xe(Re):Ue&&Qe(),ze.push(Re),Re={words:[]},Ae=0}function Qe(){Ae>(Ye.maxWidth||0)&&(Ye.maxWidth=Ae)}const{top:Ze,right:Ke,bottom:$e,left:Je}=e.Direction4;function ta(t,e,a){const{bounds:n,rows:r}=t;n[e]+=a;for(let t=0;t<r.length;t++)r[t][e]+=a}const ea={getDrawData:function(t,n){e.isString(t)||(t=String(t));let r=0,i=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{__padding:l}=n;l&&(s?(r=l[Je],s-=l[Ke]+l[Je],!s&&(s=.01)):n.autoSizeAlign||(r=l[Je]),o?(i=l[Ze],o-=l[Ze]+l[$e],!o&&(o=.01)):n.autoSizeAlign||(i=l[Ze]));const d={bounds:{x:r,y:i,width:s,height:o},rows:[],paraNumber:0,font:e.Platform.canvas.font=n.__font};return function(t,a,n){Ye=t,ze=t.rows,Ne=t.bounds,Ue=!Ne.width&&!n.autoSizeAlign;const{__letterSpacing:r,paraIndent:i,textCase:s}=n,{canvas:o}=e.Platform,{width:l}=Ne;if(n.__isCharMode){const t="none"!==n.textWrap,e="break"===n.textWrap;Ge=!0,He=null,Me=Ie=We=Ce=Ae=0,ke={data:[]},Re={words:[]},r&&(a=[...a]);for(let n=0,d=a.length;n<d;n++)Oe=a[n],"\n"===Oe?(Ce&&qe(),Re.paraEnd=!0,Ve(),Ge=!0):(De=ye(Oe),De===be&&"none"!==s&&(Oe=ve(Oe,s,!Ce)),Ie=o.measureText(Oe).width,r&&(r<0&&(We=Ie),Ie+=r),Fe=De===Pe&&(He===Pe||He===be)||He===Pe&&De!==Ee,je=!(De!==Se&&De!==Pe||He!==Be&&He!==Ee),Te=Ge&&i?l-i:l,t&&l&&Ae+Ce+Ie>Te&&(e?(Ce&&qe(),Ae&&Ve()):(je||(je=De===be&&He==Ee),Fe||je||De===Le||De===Se||De===Pe||Ce+Ie>Te?(Ce&&qe(),Ae&&Ve()):Ae&&Ve()))," "===Oe&&!0!==Ge&&Ae+Ce===0||(De===Le?(" "===Oe&&Ce&&qe(),Xe(Oe,Ie),qe()):Fe||je?(Ce&&qe(),Xe(Oe,Ie)):Xe(Oe,Ie)),He=De);Ce&&qe(),Ae&&Ve(),ze.length>0&&(ze[ze.length-1].paraEnd=!0)}else a.split("\n").forEach(t=>{Ye.paraNumber++,Ae=o.measureText(t).width,ze.push({x:i||0,text:t,width:Ae,paraStart:!0}),Ue&&Qe()})}(d,t,n),l&&function(t,e,a,n,r){if(!n&&a.autoSizeAlign)switch(a.textAlign){case"left":ta(e,"x",t[Je]);break;case"right":ta(e,"x",-t[Ke])}if(!r&&a.autoSizeAlign)switch(a.verticalAlign){case"top":ta(e,"y",t[Ze]);break;case"bottom":ta(e,"y",-t[$e])}}(l,d,n,s,o),function(t,e){const{rows:a,bounds:n}=t,r=a.length,{__lineHeight:i,__baseLine:s,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=i*r+(h?h*(t.paraNumber-1):0),y=s;if(l&&m>_)m=Math.max(_,i),r>1&&(t.overflow=r);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}y+=p;let w,v,x,b=g||u?g:t.maxWidth;for(let s=0,c=r;s<c;s++){if(w=a[s],w.x=f,w.width<g||w.width>g&&!l)switch(d){case"center":w.x+=(b-w.width)/2;break;case"right":w.x+=b-w.width}w.paraStart&&h&&s>0&&(y+=h),w.y=y,y+=i,t.overflow>s&&y>m&&(w.isOverflow=!0,t.overflow=s+1),v=w.x,x=w.width,o<0&&(w.width<0?(x=-w.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(w.isOverflow=!0,t.overflow||(t.overflow=a.length))}n.y=p,n.height=m}(d,n),n.__isCharMode&&function(t,e,a){const{rows:n}=t,{textAlign:r,paraIndent:i,__letterSpacing:s}=e,o=a&&r.includes("both"),l=o||a&&r.includes("justify"),d=l&&r.includes("letter");let c,h,u,f,p,g,_,m,y,w;n.forEach(t=>{t.words&&(p=i&&t.paraStart?i:0,m=t.words.length,l&&(w=!t.paraEnd||o,h=a-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?h/(m-1):0),g=s||t.isOverflow||d?0:u?1:2,t.isOverflow&&!s&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,a)=>{1===g?(_={char:"",x:c},c=function(t,e,a){return t.forEach(t=>{a.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,a,n,r){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,a.push(t)),e+=t.width,r&&(e+=r)}),e}(e.data,c,t.data,t.isOverflow,w&&f),w&&(y=a===m-1,u?y||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(y?1:0))))})),t.words=null)})}(d,n,s),d.overflow&&function(t,a,n,r){if(!r)return;const{rows:i,overflow:s}=t;let{textOverflow:o}=a;if(i.splice(s),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.Platform.canvas.measureText(o).width:0,c=n+r-d;("none"===a.textWrap?i:[i[s-1]]).forEach(e=>{if(e.isOverflow&&e.data){let a=e.data.length-1;for(let n=a;n>-1&&(t=e.data[n],l=t.x+t.width,!(n===a&&l<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,n,r,s),"none"!==n.textDecoration&&function(t,n){let r,i=0;const{fontSize:s,textDecoration:o}=n;switch(t.decorationHeight=s/11,e.isObject(o)?(r=o.type,o.color&&(t.decorationColor=a.ColorConvert.string(o.color)),o.offset&&(i=Math.min(.3*s,Math.max(o.offset,.15*-s)))):r=o,r){case"under":t.decorationY=[.15*s+i];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+i,.35*-s]}}(d,n),d}};const aa={string:function(t,n){if(!t)return"#000";const r=e.isNumber(n)&&n<1;if(e.isString(t)){if(!r||!a.ColorConvert.object)return t;t=a.ColorConvert.object(t)}let i=e.isUndefined(t.a)?1:t.a;r&&(i*=n);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(a.TextConvert,ea),Object.assign(a.ColorConvert,aa),Object.assign(a.Paint,D),Object.assign(a.PaintImage,mt),Object.assign(a.PaintGradient,Wt),Object.assign(a.Effect,Zt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return e.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=o,exports.useCanvas=i,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]}})}),Object.keys(a).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return a[t]}})});
2
2
  //# sourceMappingURL=worker.min.cjs.map