@leafer-ui/node 1.0.0-rc.22 → 1.0.0-rc.24

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/node.cjs CHANGED
@@ -556,7 +556,7 @@ class Renderer {
556
556
  canvas.clear();
557
557
  }
558
558
  else {
559
- bounds.spread(1 + 1 / this.canvas.pixelRatio).ceil();
559
+ bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
560
560
  canvas.clearWorld(bounds, true);
561
561
  canvas.clipWorld(bounds, true);
562
562
  }
@@ -628,8 +628,11 @@ class Renderer {
628
628
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
629
629
  this.addBlock(this.canvas.bounds);
630
630
  this.target.forceUpdate('surface');
631
+ return;
631
632
  }
632
633
  }
634
+ this.addBlock(new core.Bounds(0, 0, 1, 1));
635
+ this.changed = true;
633
636
  }
634
637
  __onLayoutEnd(event) {
635
638
  if (event.data)
@@ -802,6 +805,7 @@ class Picker {
802
805
  }
803
806
 
804
807
  const { Yes, NoAndSkip, YesAndSkip } = core.Answer;
808
+ const idCondition = {}, classNameCondition = {}, tagCondition = {};
805
809
  class Selector {
806
810
  constructor(target, userConfig) {
807
811
  this.config = {};
@@ -811,7 +815,8 @@ class Selector {
811
815
  id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
812
816
  innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
813
817
  className: (leaf, name) => leaf.className === name ? 1 : 0,
814
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0
818
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
819
+ tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
815
820
  };
816
821
  this.target = target;
817
822
  if (userConfig)
@@ -827,12 +832,25 @@ class Selector {
827
832
  case 'string':
828
833
  switch (condition[0]) {
829
834
  case '#':
830
- const leaf = this.getById(condition.substring(1), branch);
831
- return one ? leaf : (leaf ? [leaf] : []);
835
+ idCondition.id = condition.substring(1), condition = idCondition;
836
+ break;
832
837
  case '.':
833
- return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
838
+ classNameCondition.className = condition.substring(1), condition = classNameCondition;
839
+ break;
834
840
  default:
835
- return this.getByMethod(this.methods.tag, branch, one, condition);
841
+ tagCondition.tag = condition, condition = tagCondition;
842
+ }
843
+ case 'object':
844
+ if (condition.id !== undefined) {
845
+ const leaf = this.getById(condition.id, branch);
846
+ return one ? leaf : (leaf ? [leaf] : []);
847
+ }
848
+ else if (condition.tag) {
849
+ const { tag } = condition, isArray = tag instanceof Array;
850
+ return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? core.DataHelper.toMap(tag) : tag);
851
+ }
852
+ else {
853
+ return this.getByMethod(this.methods.className, branch, one, condition.className);
836
854
  }
837
855
  case 'function':
838
856
  return this.getByMethod(condition, branch, one, options);
@@ -1152,7 +1170,7 @@ function shape(ui, current, options) {
1152
1170
  }
1153
1171
  else {
1154
1172
  const { renderShapeSpread: spread } = ui.__layout;
1155
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
1173
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
1156
1174
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
1157
1175
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
1158
1176
  if (fitMatrix.a < 1) {
@@ -1252,10 +1270,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
1252
1270
  rotate(transform, rotation);
1253
1271
  data.transform = transform;
1254
1272
  }
1255
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
1273
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
1256
1274
  const transform = get$4();
1257
1275
  if (rotation) {
1258
- if (around === 'center') {
1276
+ if (align === 'center') {
1259
1277
  rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
1260
1278
  }
1261
1279
  else {
@@ -1288,12 +1306,12 @@ function createData(leafPaint, image, paint, box) {
1288
1306
  let { width, height } = image;
1289
1307
  if (paint.padding)
1290
1308
  box = tempBox.set(box).shrink(paint.padding);
1291
- const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
1309
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
1292
1310
  const sameBox = box.width === width && box.height === height;
1293
1311
  if (blendMode)
1294
1312
  leafPaint.blendMode = blendMode;
1295
1313
  const data = leafPaint.data = { mode };
1296
- const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
1314
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
1297
1315
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
1298
1316
  let x = 0, y = 0, scaleX, scaleY;
1299
1317
  if (!mode || mode === 'cover' || mode === 'fit') {
@@ -1311,11 +1329,11 @@ function createData(leafPaint, image, paint, box) {
1311
1329
  scaleX = typeof scale === 'number' ? scale : scale.x;
1312
1330
  scaleY = typeof scale === 'number' ? scale : scale.y;
1313
1331
  }
1314
- if (around) {
1332
+ if (align) {
1315
1333
  const imageBounds = { x, y, width: swapWidth, height: swapHeight };
1316
1334
  if (scaleX)
1317
1335
  imageBounds.width *= scaleX, imageBounds.height *= scaleY;
1318
- core.AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
1336
+ core.AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
1319
1337
  x += tempPoint.x, y += tempPoint.y;
1320
1338
  }
1321
1339
  if (offset)
@@ -1332,7 +1350,7 @@ function createData(leafPaint, image, paint, box) {
1332
1350
  break;
1333
1351
  case 'repeat':
1334
1352
  if (!sameBox || scaleX || rotation)
1335
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
1353
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
1336
1354
  if (!repeat)
1337
1355
  data.repeat = 'repeat';
1338
1356
  break;
@@ -1603,13 +1621,14 @@ const PaintImageModule = {
1603
1621
  recycleImage
1604
1622
  };
1605
1623
 
1606
- const defaultFrom$2 = { x: 0.5, y: 0 };
1607
- const defaultTo$2 = { x: 0.5, y: 1 };
1624
+ const { toPoint: toPoint$2 } = core.AroundHelper;
1625
+ const realFrom$2 = {};
1626
+ const realTo$2 = {};
1608
1627
  function linearGradient(paint, box) {
1609
1628
  let { from, to, type, blendMode, opacity } = paint;
1610
- from || (from = defaultFrom$2);
1611
- to || (to = defaultTo$2);
1612
- const style = core.Platform.canvas.createLinearGradient(box.x + from.x * box.width, box.y + from.y * box.height, box.x + to.x * box.width, box.y + to.y * box.height);
1629
+ toPoint$2(from || 'top', box, realFrom$2);
1630
+ toPoint$2(to || 'bottom', box, realTo$2);
1631
+ const style = core.Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
1613
1632
  applyStops(style, paint.stops, opacity);
1614
1633
  const data = { type, style };
1615
1634
  if (blendMode)
@@ -1620,23 +1639,25 @@ function applyStops(gradient, stops, opacity) {
1620
1639
  let stop;
1621
1640
  for (let i = 0, len = stops.length; i < len; i++) {
1622
1641
  stop = stops[i];
1623
- gradient.addColorStop(stop.offset, draw.ColorConvert.string(stop.color, opacity));
1642
+ if (typeof stop === 'string') {
1643
+ gradient.addColorStop(i / (len - 1), draw.ColorConvert.string(stop, opacity));
1644
+ }
1645
+ else {
1646
+ gradient.addColorStop(stop.offset, draw.ColorConvert.string(stop.color, opacity));
1647
+ }
1624
1648
  }
1625
1649
  }
1626
1650
 
1627
- const { set: set$1, getAngle: getAngle$1, getDistance: getDistance$1 } = core.PointHelper;
1651
+ const { getAngle: getAngle$1, getDistance: getDistance$1 } = core.PointHelper;
1628
1652
  const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = core.MatrixHelper;
1629
- const defaultFrom$1 = { x: 0.5, y: 0.5 };
1630
- const defaultTo$1 = { x: 0.5, y: 1 };
1653
+ const { toPoint: toPoint$1 } = core.AroundHelper;
1631
1654
  const realFrom$1 = {};
1632
1655
  const realTo$1 = {};
1633
1656
  function radialGradient(paint, box) {
1634
1657
  let { from, to, type, opacity, blendMode, stretch } = paint;
1635
- from || (from = defaultFrom$1);
1636
- to || (to = defaultTo$1);
1637
- const { x, y, width, height } = box;
1638
- set$1(realFrom$1, x + from.x * width, y + from.y * height);
1639
- set$1(realTo$1, x + to.x * width, y + to.y * height);
1658
+ toPoint$1(from || 'center', box, realFrom$1);
1659
+ toPoint$1(to || 'bottom', box, realTo$1);
1660
+ const { width, height } = box;
1640
1661
  let transform;
1641
1662
  if (width !== height || stretch) {
1642
1663
  transform = get$1();
@@ -1651,19 +1672,16 @@ function radialGradient(paint, box) {
1651
1672
  return data;
1652
1673
  }
1653
1674
 
1654
- const { set, getAngle, getDistance } = core.PointHelper;
1675
+ const { getAngle, getDistance } = core.PointHelper;
1655
1676
  const { get, rotateOfOuter, scaleOfOuter } = core.MatrixHelper;
1656
- const defaultFrom = { x: 0.5, y: 0.5 };
1657
- const defaultTo = { x: 0.5, y: 1 };
1677
+ const { toPoint } = core.AroundHelper;
1658
1678
  const realFrom = {};
1659
1679
  const realTo = {};
1660
1680
  function conicGradient(paint, box) {
1661
1681
  let { from, to, type, opacity, blendMode, stretch } = paint;
1662
- from || (from = defaultFrom);
1663
- to || (to = defaultTo);
1664
- const { x, y, width, height } = box;
1665
- set(realFrom, x + from.x * width, y + from.y * height);
1666
- set(realTo, x + to.x * width, y + to.y * height);
1682
+ toPoint(from || 'center', box, realFrom);
1683
+ toPoint(to || 'bottom', box, realTo);
1684
+ const { width, height } = box;
1667
1685
  const transform = get();
1668
1686
  const angle = getAngle(realFrom, realTo);
1669
1687
  if (core.Platform.conicGradientRotate90) {
@@ -1817,7 +1835,7 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
1817
1835
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1818
1836
  maskCanvas = contentCanvas = null;
1819
1837
  }
1820
- if (child.__.maskType === 'path') {
1838
+ if (child.__.mask === 'path') {
1821
1839
  if (child.opacity < 1) {
1822
1840
  currentMask = 'opacity-path';
1823
1841
  maskOpacity = child.opacity;
@@ -1838,7 +1856,7 @@ draw.Group.prototype.__renderMask = function (canvas, options) {
1838
1856
  contentCanvas = getCanvas(canvas);
1839
1857
  child.__render(maskCanvas, options);
1840
1858
  }
1841
- if (child.__.maskType !== 'clipping')
1859
+ if (child.__.mask !== 'clipping')
1842
1860
  continue;
1843
1861
  }
1844
1862
  if (excludeRenderBounds(child, options))
@@ -2139,11 +2157,11 @@ function layoutChar(drawData, style, width, _height) {
2139
2157
  if (mode === WordMode) {
2140
2158
  wordChar = { char: '', x: charX };
2141
2159
  charX = toWordChar(word.data, charX, wordChar);
2142
- if (wordChar.char !== ' ')
2160
+ if (row.isOverflow || wordChar.char !== ' ')
2143
2161
  row.data.push(wordChar);
2144
2162
  }
2145
2163
  else {
2146
- charX = toChar(word.data, charX, row.data);
2164
+ charX = toChar(word.data, charX, row.data, row.isOverflow);
2147
2165
  }
2148
2166
  if (!row.paraEnd && addWordWidth) {
2149
2167
  charX += addWordWidth;
@@ -2170,9 +2188,9 @@ function toWordChar(data, charX, wordChar) {
2170
2188
  });
2171
2189
  return charX;
2172
2190
  }
2173
- function toChar(data, charX, rowData) {
2191
+ function toChar(data, charX, rowData, isOverflow) {
2174
2192
  data.forEach(char => {
2175
- if (char.char !== ' ') {
2193
+ if (isOverflow || char.char !== ' ') {
2176
2194
  char.x = charX;
2177
2195
  rowData.push(char);
2178
2196
  }
@@ -2204,12 +2222,14 @@ function layoutText(drawData, style) {
2204
2222
  for (let i = 0, len = rows.length; i < len; i++) {
2205
2223
  row = rows[i];
2206
2224
  row.x = x;
2207
- switch (textAlign) {
2208
- case 'center':
2209
- row.x += (width - row.width) / 2;
2210
- break;
2211
- case 'right':
2212
- row.x += width - row.width;
2225
+ if (row.width < width || (row.width > width && !__clipText)) {
2226
+ switch (textAlign) {
2227
+ case 'center':
2228
+ row.x += (width - row.width) / 2;
2229
+ break;
2230
+ case 'right':
2231
+ row.x += width - row.width;
2232
+ }
2213
2233
  }
2214
2234
  if (row.paraStart && paraSpacing && i > 0)
2215
2235
  starY += paraSpacing;
@@ -2249,11 +2269,13 @@ function clipText(drawData, style) {
2249
2269
  const { rows, overflow } = drawData;
2250
2270
  let { textOverflow } = style;
2251
2271
  rows.splice(overflow);
2252
- if (textOverflow !== 'hide') {
2253
- if (textOverflow === 'ellipsis')
2272
+ if (textOverflow && textOverflow !== 'show') {
2273
+ if (textOverflow === 'hide')
2274
+ textOverflow = '';
2275
+ else if (textOverflow === 'ellipsis')
2254
2276
  textOverflow = '...';
2255
2277
  let char, charRight;
2256
- const ellipsisWidth = core.Platform.canvas.measureText(textOverflow).width;
2278
+ const ellipsisWidth = textOverflow ? core.Platform.canvas.measureText(textOverflow).width : 0;
2257
2279
  const right = style.x + style.width - ellipsisWidth;
2258
2280
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
2259
2281
  list.forEach(row => {
@@ -2421,8 +2443,12 @@ const ExportModule = {
2421
2443
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
2422
2444
  const { worldTransform, isLeafer, isFrame } = leaf;
2423
2445
  const { slice, trim, onCanvas } = options;
2424
- const scale = options.scale || 1;
2425
- const pixelRatio = options.pixelRatio || 1;
2446
+ let scale = options.scale || 1;
2447
+ let pixelRatio = options.pixelRatio || 1;
2448
+ if (leaf.isApp) {
2449
+ scale *= pixelRatio;
2450
+ pixelRatio = leaf.app.pixelRatio;
2451
+ }
2426
2452
  const screenshot = options.screenshot || leaf.isApp;
2427
2453
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
2428
2454
  const needFill = core.FileHelper.isOpaqueImage(filename) || fill, matrix = new core.Matrix();
package/dist/node.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, ResizeEvent, BoundsHelper, Answer, MatrixHelper, AroundHelper, ImageEvent, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, AnimateEvent, ResizeEvent, BoundsHelper, Answer, MatrixHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4, TwoPointBoundsHelper, TaskProcessor, Matrix } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { writeFileSync } from 'fs';
@@ -557,7 +557,7 @@ class Renderer {
557
557
  canvas.clear();
558
558
  }
559
559
  else {
560
- bounds.spread(1 + 1 / this.canvas.pixelRatio).ceil();
560
+ bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
561
561
  canvas.clearWorld(bounds, true);
562
562
  canvas.clipWorld(bounds, true);
563
563
  }
@@ -629,8 +629,11 @@ class Renderer {
629
629
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
630
630
  this.addBlock(this.canvas.bounds);
631
631
  this.target.forceUpdate('surface');
632
+ return;
632
633
  }
633
634
  }
635
+ this.addBlock(new Bounds(0, 0, 1, 1));
636
+ this.changed = true;
634
637
  }
635
638
  __onLayoutEnd(event) {
636
639
  if (event.data)
@@ -803,6 +806,7 @@ class Picker {
803
806
  }
804
807
 
805
808
  const { Yes, NoAndSkip, YesAndSkip } = Answer;
809
+ const idCondition = {}, classNameCondition = {}, tagCondition = {};
806
810
  class Selector {
807
811
  constructor(target, userConfig) {
808
812
  this.config = {};
@@ -812,7 +816,8 @@ class Selector {
812
816
  id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
813
817
  innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
814
818
  className: (leaf, name) => leaf.className === name ? 1 : 0,
815
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0
819
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
820
+ tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
816
821
  };
817
822
  this.target = target;
818
823
  if (userConfig)
@@ -828,12 +833,25 @@ class Selector {
828
833
  case 'string':
829
834
  switch (condition[0]) {
830
835
  case '#':
831
- const leaf = this.getById(condition.substring(1), branch);
832
- return one ? leaf : (leaf ? [leaf] : []);
836
+ idCondition.id = condition.substring(1), condition = idCondition;
837
+ break;
833
838
  case '.':
834
- return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
839
+ classNameCondition.className = condition.substring(1), condition = classNameCondition;
840
+ break;
835
841
  default:
836
- return this.getByMethod(this.methods.tag, branch, one, condition);
842
+ tagCondition.tag = condition, condition = tagCondition;
843
+ }
844
+ case 'object':
845
+ if (condition.id !== undefined) {
846
+ const leaf = this.getById(condition.id, branch);
847
+ return one ? leaf : (leaf ? [leaf] : []);
848
+ }
849
+ else if (condition.tag) {
850
+ const { tag } = condition, isArray = tag instanceof Array;
851
+ return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
852
+ }
853
+ else {
854
+ return this.getByMethod(this.methods.className, branch, one, condition.className);
837
855
  }
838
856
  case 'function':
839
857
  return this.getByMethod(condition, branch, one, options);
@@ -1153,7 +1171,7 @@ function shape(ui, current, options) {
1153
1171
  }
1154
1172
  else {
1155
1173
  const { renderShapeSpread: spread } = ui.__layout;
1156
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
1174
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
1157
1175
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
1158
1176
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
1159
1177
  if (fitMatrix.a < 1) {
@@ -1253,10 +1271,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
1253
1271
  rotate(transform, rotation);
1254
1272
  data.transform = transform;
1255
1273
  }
1256
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
1274
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
1257
1275
  const transform = get$4();
1258
1276
  if (rotation) {
1259
- if (around === 'center') {
1277
+ if (align === 'center') {
1260
1278
  rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
1261
1279
  }
1262
1280
  else {
@@ -1289,12 +1307,12 @@ function createData(leafPaint, image, paint, box) {
1289
1307
  let { width, height } = image;
1290
1308
  if (paint.padding)
1291
1309
  box = tempBox.set(box).shrink(paint.padding);
1292
- const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
1310
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
1293
1311
  const sameBox = box.width === width && box.height === height;
1294
1312
  if (blendMode)
1295
1313
  leafPaint.blendMode = blendMode;
1296
1314
  const data = leafPaint.data = { mode };
1297
- const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
1315
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
1298
1316
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
1299
1317
  let x = 0, y = 0, scaleX, scaleY;
1300
1318
  if (!mode || mode === 'cover' || mode === 'fit') {
@@ -1312,11 +1330,11 @@ function createData(leafPaint, image, paint, box) {
1312
1330
  scaleX = typeof scale === 'number' ? scale : scale.x;
1313
1331
  scaleY = typeof scale === 'number' ? scale : scale.y;
1314
1332
  }
1315
- if (around) {
1333
+ if (align) {
1316
1334
  const imageBounds = { x, y, width: swapWidth, height: swapHeight };
1317
1335
  if (scaleX)
1318
1336
  imageBounds.width *= scaleX, imageBounds.height *= scaleY;
1319
- AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
1337
+ AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
1320
1338
  x += tempPoint.x, y += tempPoint.y;
1321
1339
  }
1322
1340
  if (offset)
@@ -1333,7 +1351,7 @@ function createData(leafPaint, image, paint, box) {
1333
1351
  break;
1334
1352
  case 'repeat':
1335
1353
  if (!sameBox || scaleX || rotation)
1336
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
1354
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
1337
1355
  if (!repeat)
1338
1356
  data.repeat = 'repeat';
1339
1357
  break;
@@ -1604,13 +1622,14 @@ const PaintImageModule = {
1604
1622
  recycleImage
1605
1623
  };
1606
1624
 
1607
- const defaultFrom$2 = { x: 0.5, y: 0 };
1608
- const defaultTo$2 = { x: 0.5, y: 1 };
1625
+ const { toPoint: toPoint$2 } = AroundHelper;
1626
+ const realFrom$2 = {};
1627
+ const realTo$2 = {};
1609
1628
  function linearGradient(paint, box) {
1610
1629
  let { from, to, type, blendMode, opacity } = paint;
1611
- from || (from = defaultFrom$2);
1612
- to || (to = defaultTo$2);
1613
- const style = Platform.canvas.createLinearGradient(box.x + from.x * box.width, box.y + from.y * box.height, box.x + to.x * box.width, box.y + to.y * box.height);
1630
+ toPoint$2(from || 'top', box, realFrom$2);
1631
+ toPoint$2(to || 'bottom', box, realTo$2);
1632
+ const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
1614
1633
  applyStops(style, paint.stops, opacity);
1615
1634
  const data = { type, style };
1616
1635
  if (blendMode)
@@ -1621,23 +1640,25 @@ function applyStops(gradient, stops, opacity) {
1621
1640
  let stop;
1622
1641
  for (let i = 0, len = stops.length; i < len; i++) {
1623
1642
  stop = stops[i];
1624
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
1643
+ if (typeof stop === 'string') {
1644
+ gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
1645
+ }
1646
+ else {
1647
+ gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
1648
+ }
1625
1649
  }
1626
1650
  }
1627
1651
 
1628
- const { set: set$1, getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
1652
+ const { getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
1629
1653
  const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = MatrixHelper;
1630
- const defaultFrom$1 = { x: 0.5, y: 0.5 };
1631
- const defaultTo$1 = { x: 0.5, y: 1 };
1654
+ const { toPoint: toPoint$1 } = AroundHelper;
1632
1655
  const realFrom$1 = {};
1633
1656
  const realTo$1 = {};
1634
1657
  function radialGradient(paint, box) {
1635
1658
  let { from, to, type, opacity, blendMode, stretch } = paint;
1636
- from || (from = defaultFrom$1);
1637
- to || (to = defaultTo$1);
1638
- const { x, y, width, height } = box;
1639
- set$1(realFrom$1, x + from.x * width, y + from.y * height);
1640
- set$1(realTo$1, x + to.x * width, y + to.y * height);
1659
+ toPoint$1(from || 'center', box, realFrom$1);
1660
+ toPoint$1(to || 'bottom', box, realTo$1);
1661
+ const { width, height } = box;
1641
1662
  let transform;
1642
1663
  if (width !== height || stretch) {
1643
1664
  transform = get$1();
@@ -1652,19 +1673,16 @@ function radialGradient(paint, box) {
1652
1673
  return data;
1653
1674
  }
1654
1675
 
1655
- const { set, getAngle, getDistance } = PointHelper;
1676
+ const { getAngle, getDistance } = PointHelper;
1656
1677
  const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
1657
- const defaultFrom = { x: 0.5, y: 0.5 };
1658
- const defaultTo = { x: 0.5, y: 1 };
1678
+ const { toPoint } = AroundHelper;
1659
1679
  const realFrom = {};
1660
1680
  const realTo = {};
1661
1681
  function conicGradient(paint, box) {
1662
1682
  let { from, to, type, opacity, blendMode, stretch } = paint;
1663
- from || (from = defaultFrom);
1664
- to || (to = defaultTo);
1665
- const { x, y, width, height } = box;
1666
- set(realFrom, x + from.x * width, y + from.y * height);
1667
- set(realTo, x + to.x * width, y + to.y * height);
1683
+ toPoint(from || 'center', box, realFrom);
1684
+ toPoint(to || 'bottom', box, realTo);
1685
+ const { width, height } = box;
1668
1686
  const transform = get();
1669
1687
  const angle = getAngle(realFrom, realTo);
1670
1688
  if (Platform.conicGradientRotate90) {
@@ -1818,7 +1836,7 @@ Group.prototype.__renderMask = function (canvas, options) {
1818
1836
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1819
1837
  maskCanvas = contentCanvas = null;
1820
1838
  }
1821
- if (child.__.maskType === 'path') {
1839
+ if (child.__.mask === 'path') {
1822
1840
  if (child.opacity < 1) {
1823
1841
  currentMask = 'opacity-path';
1824
1842
  maskOpacity = child.opacity;
@@ -1839,7 +1857,7 @@ Group.prototype.__renderMask = function (canvas, options) {
1839
1857
  contentCanvas = getCanvas(canvas);
1840
1858
  child.__render(maskCanvas, options);
1841
1859
  }
1842
- if (child.__.maskType !== 'clipping')
1860
+ if (child.__.mask !== 'clipping')
1843
1861
  continue;
1844
1862
  }
1845
1863
  if (excludeRenderBounds(child, options))
@@ -2140,11 +2158,11 @@ function layoutChar(drawData, style, width, _height) {
2140
2158
  if (mode === WordMode) {
2141
2159
  wordChar = { char: '', x: charX };
2142
2160
  charX = toWordChar(word.data, charX, wordChar);
2143
- if (wordChar.char !== ' ')
2161
+ if (row.isOverflow || wordChar.char !== ' ')
2144
2162
  row.data.push(wordChar);
2145
2163
  }
2146
2164
  else {
2147
- charX = toChar(word.data, charX, row.data);
2165
+ charX = toChar(word.data, charX, row.data, row.isOverflow);
2148
2166
  }
2149
2167
  if (!row.paraEnd && addWordWidth) {
2150
2168
  charX += addWordWidth;
@@ -2171,9 +2189,9 @@ function toWordChar(data, charX, wordChar) {
2171
2189
  });
2172
2190
  return charX;
2173
2191
  }
2174
- function toChar(data, charX, rowData) {
2192
+ function toChar(data, charX, rowData, isOverflow) {
2175
2193
  data.forEach(char => {
2176
- if (char.char !== ' ') {
2194
+ if (isOverflow || char.char !== ' ') {
2177
2195
  char.x = charX;
2178
2196
  rowData.push(char);
2179
2197
  }
@@ -2205,12 +2223,14 @@ function layoutText(drawData, style) {
2205
2223
  for (let i = 0, len = rows.length; i < len; i++) {
2206
2224
  row = rows[i];
2207
2225
  row.x = x;
2208
- switch (textAlign) {
2209
- case 'center':
2210
- row.x += (width - row.width) / 2;
2211
- break;
2212
- case 'right':
2213
- row.x += width - row.width;
2226
+ if (row.width < width || (row.width > width && !__clipText)) {
2227
+ switch (textAlign) {
2228
+ case 'center':
2229
+ row.x += (width - row.width) / 2;
2230
+ break;
2231
+ case 'right':
2232
+ row.x += width - row.width;
2233
+ }
2214
2234
  }
2215
2235
  if (row.paraStart && paraSpacing && i > 0)
2216
2236
  starY += paraSpacing;
@@ -2250,11 +2270,13 @@ function clipText(drawData, style) {
2250
2270
  const { rows, overflow } = drawData;
2251
2271
  let { textOverflow } = style;
2252
2272
  rows.splice(overflow);
2253
- if (textOverflow !== 'hide') {
2254
- if (textOverflow === 'ellipsis')
2273
+ if (textOverflow && textOverflow !== 'show') {
2274
+ if (textOverflow === 'hide')
2275
+ textOverflow = '';
2276
+ else if (textOverflow === 'ellipsis')
2255
2277
  textOverflow = '...';
2256
2278
  let char, charRight;
2257
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
2279
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
2258
2280
  const right = style.x + style.width - ellipsisWidth;
2259
2281
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
2260
2282
  list.forEach(row => {
@@ -2422,8 +2444,12 @@ const ExportModule = {
2422
2444
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
2423
2445
  const { worldTransform, isLeafer, isFrame } = leaf;
2424
2446
  const { slice, trim, onCanvas } = options;
2425
- const scale = options.scale || 1;
2426
- const pixelRatio = options.pixelRatio || 1;
2447
+ let scale = options.scale || 1;
2448
+ let pixelRatio = options.pixelRatio || 1;
2449
+ if (leaf.isApp) {
2450
+ scale *= pixelRatio;
2451
+ pixelRatio = leaf.app.pixelRatio;
2452
+ }
2427
2453
  const screenshot = options.screenshot || leaf.isApp;
2428
2454
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
2429
2455
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as g,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as B,BoundsHelper as b,Answer as R,MatrixHelper as k,AroundHelper as E,ImageEvent as L,PointHelper as S,Direction4 as M,TwoPointBoundsHelper as A,TaskProcessor as C,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as W}from"fs";import{InteractionBase as O,HitCanvasManager as I}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as F,Export as N,Group as Y,TextConvert as U,Paint as H,Effect as X}from"@leafer-ui/draw";function G(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class j extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:V,fileType:q}=a;function z(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:n},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(V(e),i),canvasToBolb:(t,e,i)=>G(this,void 0,void 0,(function*(){return t.toBuffer(V(e),i)})),canvasSaveAs:(t,e,i)=>G(this,void 0,void 0,(function*(){return W(e,t.toBuffer(V(q(e)),i))})),download(t,e){},loadImage:n}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new j(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:Z,updateAllWorldOpacity:K}=u,{pushAllChildBranch:$,pushAllParent:tt}=f;const{worldBounds:et}=g,it={x:0,y:0,width:1e5,height:1e5};class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),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:st,updateAllChange:at}=u,ot=p.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&$(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||Z(n[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&K(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),rt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){st(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=p.get("Renderer");class ht{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new _(n);i.save(),s&&!p.showRepaint?i.clear():(n.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(n),p.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(B.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:lt}=b;class ct{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),h=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:h,target:d,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||u.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||lt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(i||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ut,NoAndSkip:ft,YesAndSkip:_t}=R;class gt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new ct(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":const n=this.getById(t.substring(1),e);return i?n:n?[n]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&u.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===ut||a===_t){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<ft&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function pt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function wt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?vt(t,!0,e,i):mt(e,i);break;case"inside":yt("inside",t,s,e,i);break;case"outside":yt("outside",t,s,e,i)}}function yt(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?vt(e,!0,n,r):mt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",pt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function mt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function vt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?mt(i,n):n.stroke(),n.restoreBlendMode()):e?mt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new ht(t,e,i),selector:(t,e)=>new gt(t,e)}),e.layout=rt.fullLayout;const{getSpread:xt,getOuterOf:Bt,getByMove:bt,getIntersectData:Rt}=b;let kt;function Et(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:D.string(o,r)};case"image":return P.image(i,t,e,n,!kt||!kt[e.url]);case"linear":return F.linearGradient(e,n);case"radial":return F.radialGradient(e,n);case"angular":return F.conicGradient(e,n);default:return e.r?{type:"solid",style:D.string(e)}:void 0}}const Lt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),kt=P.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Et(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?pt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&P.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?pt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?pt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?pt(e,i):s?i.fill(s):i.fill())},fillText:pt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)wt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)wt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),vt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),vt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),vt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:wt,drawTextStroke:mt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=s;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Rt(n?xt(e.bounds,n*h,n*l):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=Bt(s,o),a=bt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let St={};const{get:Mt,rotateOfOuter:At,translate:Ct,scaleOfOuter:Tt,scale:Wt,rotate:Ot}=k;function It(t,e,i,n,s,a,o){const r=Mt();Ct(r,e.x+i,e.y+n),Wt(r,s,a),o&&At(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Pt(t,e,i,n,s,a,o){const r=Mt();Ct(r,e.x+i,e.y+n),s&&Wt(r,s,a),o&&Ot(r,o),t.transform=r}function Dt(t,e,i,n,s,a,o,r,d,h){const l=Mt();if(d)if("center"===h)At(l,{x:i/2,y:n/2},d);else switch(Ot(l,d),d){case 90:Ct(l,n,0);break;case 180:Ct(l,i,n);break;case 270:Ct(l,0,i)}St.x=e.x+s,St.y=e.y+a,Ct(l,St.x,St.y),o&&Tt(l,St,o,r),t.transform=l}const{get:Ft,translate:Nt}=k,Yt=new _,Ut={};function Ht(t,e,i,n){let{width:s,height:a}=e;i.padding&&(n=Yt.set(n).shrink(i.padding));const{opacity:o,mode:r,around:d,offset:h,scale:l,size:c,rotation:u,blendMode:f,repeat:_}=i,g=n.width===s&&n.height===a;f&&(t.blendMode=f);const p=t.data={mode:r},w="center"!==d&&(u||0)%180==90,y=w?a:s,m=w?s:a;let v,x,B=0,b=0;if(r&&"cover"!==r&&"fit"!==r)c?(v=("number"==typeof c?c:c.width)/s,x=("number"==typeof c?c:c.height)/a):l&&(v="number"==typeof l?l:l.x,x="number"==typeof l?l:l.y);else if(!g||u){const t=n.width/y,e=n.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),B+=(n.width-s*v)/2,b+=(n.height-a*x)/2}if(d){const t={x:B,y:b,width:y,height:m};v&&(t.width*=v,t.height*=x),E.toPoint(d,n,Ut,!0,t),B+=Ut.x,b+=Ut.y}switch(h&&(B+=h.x,b+=h.y),r){case"strench":g||(s=n.width,a=n.height);break;case"normal":case"clip":(B||b||v||u)&&Pt(p,n,B,b,v,x,u);break;case"repeat":(!g||v||u)&&Dt(p,n,s,a,B,b,v,x,u,d),_||(p.repeat="repeat");break;default:v&&It(p,n,B,b,v,x,u)}p.transform||(n.x||n.y)&&(p.transform=Ft(),Nt(p.transform,n.x,n.y)),v&&"strench"!==r&&(p.scaleX=v,p.scaleY=x),p.width=s,p.height=a,o&&(p.opacity=o),_&&(p.repeat="string"==typeof _?"x"===_?"repeat-x":"repeat-y":"repeat")}let Xt,Gt=new _;const{isSame:jt}=b;function Vt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Ht(s,n,i,a),!0}function qt(t,e){Jt(t,L.LOAD,e)}function zt(t,e){Jt(t,L.LOADED,e)}function Qt(t,e,i){e.error=i,t.forceUpdate("surface"),Jt(t,L.ERROR,e)}function Jt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Zt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Kt,scale:$t,copy:te}=k,{ceil:ee,abs:ie}=Math;function ne(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a;if(i.patternId===o||t.destroyed)return!1;{s=ie(s),a=ie(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(h=Kt(),te(h,g),$t(h,1/u,1/f),s*=u,a*=f),s*=n,a*=n,l*=s,c*=a;const w=l*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,l/=d,c/=d),u&&(s/=u,a/=f),(g||1!==s||1!==a)&&(h||(h=Kt(),g&&te(h,g)),$t(h,1/s,1/a));const m=t.getCanvas(ee(l)||1,ee(c)||1,_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}const{abs:se}=Math;const ae={image:function(t,e,i,n,s){let a,o;const r=v.get(i);return Xt&&i===Xt.paint&&jt(n,Xt.boxBounds)?a=Xt.leafPaint:(a={type:i.type,image:r},Xt=r.use>1?{leafPaint:a,paint:i,boxBounds:Gt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Vt(t,e,i,r,a,n),s&&(qt(t,o),zt(t,o))):r.error?s&&Qt(t,o,r.error):(Zt(t,!0),s&&qt(t,o),a.loadId=r.load((()=>{Zt(t,!1),t.destroyed||(Vt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),zt(t,o)),a.loadId=null}),(e=>{Zt(t,!1),Qt(t,o,e),a.loadId=null}))),a},createData:Ht,fillOrFitMode:It,clipMode:Pt,repeatMode:Dt,createPattern:ne,checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==a+"-"+o){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=se(a)*i.pixelRatio,n*=se(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||N.running?ne(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>G(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ne(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,v.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null}},oe={x:.5,y:0},re={x:.5,y:1};function de(t,e,i){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],t.addColorStop(n.offset,D.string(n.color,i))}const{set:he,getAngle:le,getDistance:ce}=S,{get:ue,rotateOfOuter:fe,scaleOfOuter:_e}=k,ge={x:.5,y:.5},pe={x:.5,y:1},we={},ye={};const{set:me,getAngle:ve,getDistance:xe}=S,{get:Be,rotateOfOuter:be,scaleOfOuter:Re}=k,ke={x:.5,y:.5},Ee={x:.5,y:1},Le={},Se={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;n||(n=oe),s||(s=re);const d=e.canvas.createLinearGradient(i.x+n.x*i.width,i.y+n.y*i.height,i.x+s.x*i.width,i.y+s.y*i.height);de(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;n||(n=ge),s||(s=pe);const{x:h,y:l,width:c,height:u}=i;let f;he(we,h+n.x*c,l+n.y*u),he(ye,h+s.x*c,l+s.y*u),(c!==u||d)&&(f=ue(),_e(f,we,c/u*(d||1),1),fe(f,we,le(we,ye)+90));const _=e.canvas.createRadialGradient(we.x,we.y,0,we.x,we.y,ce(we,ye));de(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;n||(n=ke),s||(s=Ee);const{x:h,y:l,width:c,height:u}=i;me(Le,h+n.x*c,l+n.y*u),me(Se,h+s.x*c,l+s.y*u);const f=Be(),_=ve(Le,Se);e.conicGradientRotate90?(Re(f,Le,c/u*(d||1),1),be(f,Le,_+90)):(Re(f,Le,1,c/u*(d||1)),be(f,Le,_));const g=e.conicGradientSupport?e.canvas.createConicGradient(0,Le.x,Le.y):e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,xe(Le,Se));de(g,t.stops,o);const p={type:a,style:g,transform:f};return r&&(p.blendMode=r),p}},{copy:Ae,toOffsetOutBounds:Ce}=b,Te={},We={};function Oe(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ae(Te,t.bounds),Te.x+=i.x-o.x,Te.y+=i.y-o.y,n){const{matrix:t}=s;Te.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Te.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Te.width*=n,Te.height*=n}t.copyWorld(s.canvas,t.bounds,Te)}else n&&(Ae(Te,i),Te.x-=i.width/2*(n-1),Te.y-=i.height/2*(n-1),Te.width*=n,Te.height*=n),t.copyWorld(s.canvas,o,n?Te:i)}const{toOffsetOutBounds:Ie}=b,Pe={};const De={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Ce(h,We),r.forEach(((r,g)=>{f.setWorldShadow(We.offsetX+r.x*c,We.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Oe(f,We,s,i),n=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Ie(h,Pe),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Pe.offsetX+r.x*c,Pe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Oe(f,Pe,s,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,l,h,"source-out"),n=h),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Fe}=g;function Ne(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ue(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ue(t,i,n,a);break;case"path":i.restore()}}function Ye(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Ne(this,o,t,s,n,a),n=s=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ye(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Ye(t)),s||(s=Ye(t)),i.__render(n,e)),"clipping"!==i.__.maskType)||Fe(i,e)||i.__render(s||t,e);Ne(this,o,t,s,n,a)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Xe=He+"_#~&*+\\=|≮≯≈≠=…",Ge=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 je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ve=je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ze=je(He),Qe=je(Xe),Je=je("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Ke,Single:$e,Before:ti,After:ei,Symbol:ii,Break:ni}=Ze;function si(t){return Ve[t]?Ke:Je[t]?ni:qe[t]?ti:ze[t]?ei:Qe[t]?ii:Ge.test(t)?$e:Ke}const ai={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function oi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ri}=ai,{Letter:di,Single:hi,Before:li,After:ci,Symbol:ui,Break:fi}=Ze;let _i,gi,pi,wi,yi,mi,vi,xi,Bi,bi,Ri,ki,Ei,Li,Si,Mi,Ai=[];function Ci(t,e){Bi&&!xi&&(xi=Bi),_i.data.push({char:t,width:e}),pi+=e}function Ti(){wi+=pi,_i.width=pi,gi.words.push(_i),_i={data:[]},pi=0}function Wi(){Li&&(Si.paraNumber++,gi.paraStart=!0,Li=!1),Bi&&(gi.startCharSize=xi,gi.endCharSize=Bi,xi=0),gi.width=wi,Mi.width&&ri(gi),Ai.push(gi),gi={words:[]},wi=0}const Oi=0,Ii=1,Pi=2;const{top:Di,right:Fi,bottom:Ni,left:Yi}=M;function Ui(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Hi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(n=h[Yi],a-=h[Fi]+h[Yi]),o&&(s=h[Di],o-=h[Di]+h[Ni]));const l={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Si=t,Ai=t.rows,Mi=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:h}=Mi;if(d||h||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Li=!0,Ri=null,xi=vi=Bi=pi=wi=0,_i={data:[]},gi={words:[]};for(let n=0,h=i.length;n<h;n++)mi=i[n],"\n"===mi?(pi&&Ti(),gi.paraEnd=!0,Wi(),Li=!0):(bi=si(mi),bi===di&&"none"!==o&&(mi=oi(mi,o,!pi)),vi=r.measureText(mi).width,s&&(s<0&&(Bi=vi),vi+=s),ki=bi===hi&&(Ri===hi||Ri===di)||Ri===hi&&bi!==ci,Ei=!(bi!==li&&bi!==hi||Ri!==ui&&Ri!==ci),yi=Li&&a?d-a:d,t&&d&&wi+pi+vi>yi&&(e?(pi&&Ti(),Wi()):(Ei||(Ei=bi===di&&Ri==ci),ki||Ei||bi===fi||bi===li||bi===hi||pi+vi>yi?(pi&&Ti(),Wi()):Wi()))," "===mi&&!0!==Li&&wi+pi===0||(bi===fi?(" "===mi&&pi&&Ti(),Ci(mi,vi),Ti()):ki||Ei?(pi&&Ti(),Ci(mi,vi)):Ci(mi,vi)),Ri=bi);pi&&Ti(),wi&&Wi(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Si.paraNumber++,Ai.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Ui(e,"x",t[Yi]);break;case"right":Ui(e,"x",-t[Fi])}if(!s)switch(i.verticalAlign){case"top":Ui(e,"y",t[Di]);break;case"bottom":Ui(e,"y",-t[Ni])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=n,y=s*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=s,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=y}(l,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Oi:h>.01?Ii:Pi,t.isOverflow&&!r&&(t.textMode=!0),c===Pi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ii?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:a}=i;if(n.splice(s),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],o=t.x+t.width,!(n===i&&o<d));n--){if(o<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const Xi={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Gi,addPoint:ji,toBounds:Vi}=A;const qi={export(t,i,s){return this.running=!0,function(t){zi||(zi=new C);return new Promise((e=>{zi.add((()=>G(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((r=>{const d=t=>{o(t),r(),this.running=!1};if("json"===i)return d({data:t.toJSON()});if("json"===a.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),d({data:!0});const{leafer:h}=t;h?h.waitViewCompleted((()=>G(this,void 0,void 0,(function*(){s=a.getExportOptions(s);let e,o,r=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:g,trim:p,onCanvas:w}=s,y=s.scale||1,m=s.pixelRatio||1,v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,B=a.isOpaqueImage(i)||x,b=new T;if(v)e=!0===v?u?h.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(r=c.scaleX,l=c.scaleY,i){case"inner":b.set(c);break;case"local":b.set(c).divide(t.localTransform),r/=t.scaleX,l/=t.scaleY;break;case"world":r=1,l=1;break;case"page":i=t.leafer;default:b.set(c).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:E,height:L}=new _(e).scale(y);let S=n.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const M={matrix:b.scale(1/y).invert().translate(-R,-k).withScale(1/r*y,1/l*y)};if(g&&(t=h,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?ji(o,s,a):Gi(o={},s,a)),r++;const d=new _;return Vi(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=n.canvas(s),S.copyWorld(t,o,s)}B&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===i?S:yield S.export(i,s);d({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:e,trimBounds:o})})))):d({data:!1})}))))}};let zi;const Qi=t.prototype,Ji=p.get("@leafer-ui/export");Qi.export=function(t,e){const{quality:i,blob:n}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Qi.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Ji.error(t),n(null)}))}))},Qi.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Qi.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Ji.error(t),n(!1)}))}))},Object.assign(U,Hi),Object.assign(D,Xi),Object.assign(H,Lt),Object.assign(P,ae),Object.assign(F,Me),Object.assign(X,De),Object.assign(N,qi),Object.assign(n,{interaction:(t,e,i,n)=>new O(t,e,i,n),hitCanvas:(t,e)=>new j(t,e),hitCanvasManager:()=>new I});export{rt as Layouter,j as LeaferCanvas,ht as Renderer,gt as Selector,Q as Watcher,z as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as g,LeafBoundsHelper as _,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,Answer as R,MatrixHelper as k,AlignHelper as E,ImageEvent as L,AroundHelper as S,PointHelper as M,Direction4 as A,TwoPointBoundsHelper as C,TaskProcessor as O,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as T}from"fs";import{InteractionBase as I,HitCanvasManager as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as F,PaintGradient as N,Export as Y,Group as U,TextConvert as H,Paint as X,Effect as j}from"@leafer-ui/draw";function G(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class V extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:q,fileType:z}=a;function Q(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:n},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(q(e),i),canvasToBolb:(t,e,i)=>G(this,void 0,void 0,(function*(){return t.toBuffer(q(e),i)})),canvasSaveAs:(t,e,i)=>G(this,void 0,void 0,(function*(){return T(e,t.toBuffer(q(z(e)),i))})),download(t,e){},loadImage:n}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new V(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:K,updateAllWorldOpacity:$}=u,{pushAllChildBranch:tt,pushAllParent:et}=f;const{worldBounds:it}=_,nt={x:0,y:0,width:1e5,height:1e5};class st{constructor(t){this.updatedBounds=new g,this.beforeBounds=new g,this.afterBounds=new g,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,it),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:at,updateAllChange:ot}=u,rt=p.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=m.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new y(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Z(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||K(n[t])}K(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&$(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),dt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,a,this.times)),e.emitEvent(new y(s,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){at(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=p.get("Renderer");class lt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new g,ht.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new g,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return ht.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new g(n);i.save(),s&&!p.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(n),p.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new g;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new g(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new g(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ht.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ct}=B;class ut{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,s),h=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:h,target:d,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new o;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||u.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||ct(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(i||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ft,NoAndSkip:gt,YesAndSkip:_t}=R,pt={},wt={},yt={};class mt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new ut(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":pt.id=t.substring(1),t=pt;break;case".":wt.className=t.substring(1),t=wt;break;default:yt.tag=t,t=yt}case"object":if(void 0!==t.id){const n=this.getById(t.id,e);return i?n:n?[n]:[]}if(t.tag){const{tag:n}=t,s=n instanceof Array;return this.getByMethod(s?this.methods.tags:this.methods.tag,e,i,s?r.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,n){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&u.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===ft||a===_t){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<gt&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function vt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function xt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?Rt(t,!0,e,i):Bt(e,i);break;case"inside":bt("inside",t,s,e,i);break;case"outside":bt("outside",t,s,e,i)}}function bt(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?Rt(e,!0,n,r):Bt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",vt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function Bt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function Rt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Bt(i,n):n.stroke(),n.restoreBlendMode()):e?Bt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>new mt(t,e)}),e.layout=dt.fullLayout;const{getSpread:kt,getOuterOf:Et,getByMove:Lt,getIntersectData:St}=B;let Mt;function At(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:F.string(o,r)};case"image":return D.image(i,t,e,n,!Mt||!Mt[e.url]);case"linear":return N.linearGradient(e,n);case"radial":return N.radialGradient(e,n);case"angular":return N.conicGradient(e,n);default:return e.r?{type:"solid",style:F.string(e)}:void 0}}const Ct={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Mt=D.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=At(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?vt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&D.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?vt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?vt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?vt(e,i):s?i.fill(s):i.fill())},fillText:vt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)xt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)xt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Rt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Rt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),Rt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:xt,drawTextStroke:Bt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=s;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=St(n?kt(e.bounds,h===l?n*h:[n*l,n*h]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=Et(s,o),a=Lt(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let Ot={};const{get:Wt,rotateOfOuter:Tt,translate:It,scaleOfOuter:Pt,scale:Dt,rotate:Ft}=k;function Nt(t,e,i,n,s,a,o){const r=Wt();It(r,e.x+i,e.y+n),Dt(r,s,a),o&&Tt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Yt(t,e,i,n,s,a,o){const r=Wt();It(r,e.x+i,e.y+n),s&&Dt(r,s,a),o&&Ft(r,o),t.transform=r}function Ut(t,e,i,n,s,a,o,r,d,h){const l=Wt();if(d)if("center"===h)Tt(l,{x:i/2,y:n/2},d);else switch(Ft(l,d),d){case 90:It(l,n,0);break;case 180:It(l,i,n);break;case 270:It(l,0,i)}Ot.x=e.x+s,Ot.y=e.y+a,It(l,Ot.x,Ot.y),o&&Pt(l,Ot,o,r),t.transform=l}const{get:Ht,translate:Xt}=k,jt=new g,Gt={};function Vt(t,e,i,n){let{width:s,height:a}=e;i.padding&&(n=jt.set(n).shrink(i.padding));const{opacity:o,mode:r,align:d,offset:h,scale:l,size:c,rotation:u,blendMode:f,repeat:g}=i,_=n.width===s&&n.height===a;f&&(t.blendMode=f);const p=t.data={mode:r},w="center"!==d&&(u||0)%180==90,y=w?a:s,m=w?s:a;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)c?(v=("number"==typeof c?c:c.width)/s,x=("number"==typeof c?c:c.height)/a):l&&(v="number"==typeof l?l:l.x,x="number"==typeof l?l:l.y);else if(!_||u){const t=n.width/y,e=n.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,B+=(n.height-a*x)/2}if(d){const t={x:b,y:B,width:y,height:m};v&&(t.width*=v,t.height*=x),E.toPoint(d,t,n,Gt,!0),b+=Gt.x,B+=Gt.y}switch(h&&(b+=h.x,B+=h.y),r){case"strench":_||(s=n.width,a=n.height);break;case"normal":case"clip":(b||B||v||u)&&Yt(p,n,b,B,v,x,u);break;case"repeat":(!_||v||u)&&Ut(p,n,s,a,b,B,v,x,u,d),g||(p.repeat="repeat");break;default:v&&Nt(p,n,b,B,v,x,u)}p.transform||(n.x||n.y)&&(p.transform=Ht(),Xt(p.transform,n.x,n.y)),v&&"strench"!==r&&(p.scaleX=v,p.scaleY=x),p.width=s,p.height=a,o&&(p.opacity=o),g&&(p.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat")}let qt,zt=new g;const{isSame:Qt}=B;function Jt(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Vt(s,n,i,a),!0}function Zt(t,e){te(t,L.LOAD,e)}function Kt(t,e){te(t,L.LOADED,e)}function $t(t,e,i){e.error=i,t.forceUpdate("surface"),te(t,L.ERROR,e)}function te(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function ee(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ie,scale:ne,copy:se}=k,{ceil:ae,abs:oe}=Math;function re(t,i,n){let{scaleX:s,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a;if(i.patternId===o||t.destroyed)return!1;{s=oe(s),a=oe(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(h=ie(),se(h,_),ne(h,1/u,1/f),s*=u,a*=f),s*=n,a*=n,l*=s,c*=a;const w=l*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,l/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(h||(h=ie(),_&&se(h,_)),ne(h,1/s,1/a));const m=t.getCanvas(ae(l)||1,ae(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}const{abs:de}=Math;const he={image:function(t,e,i,n,s){let a,o;const r=v.get(i);return qt&&i===qt.paint&&Qt(n,qt.boxBounds)?a=qt.leafPaint:(a={type:i.type,image:r},qt=r.use>1?{leafPaint:a,paint:i,boxBounds:zt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Jt(t,e,i,r,a,n),s&&(Zt(t,o),Kt(t,o))):r.error?s&&$t(t,o,r.error):(ee(t,!0),s&&Zt(t,o),a.loadId=r.load((()=>{ee(t,!1),t.destroyed||(Jt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Kt(t,o)),a.loadId=null}),(e=>{ee(t,!1),$t(t,o,e),a.loadId=null}))),a},createData:Vt,fillOrFitMode:Nt,clipMode:Yt,repeatMode:Ut,createPattern:re,checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==a+"-"+o){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=de(a)*i.pixelRatio,n*=de(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||Y.running?re(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>G(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&re(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,v.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null}},{toPoint:le}=S,ce={},ue={};function fe(t,e,i){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),F.string(n,i)):t.addColorStop(n.offset,F.string(n.color,i))}const{getAngle:ge,getDistance:_e}=M,{get:pe,rotateOfOuter:we,scaleOfOuter:ye}=k,{toPoint:me}=S,ve={},xe={};const{getAngle:be,getDistance:Be}=M,{get:Re,rotateOfOuter:ke,scaleOfOuter:Ee}=k,{toPoint:Le}=S,Se={},Me={};const Ae={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;le(n||"top",i,ce),le(s||"bottom",i,ue);const d=e.canvas.createLinearGradient(ce.x,ce.y,ue.x,ue.y);fe(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;me(n||"center",i,ve),me(s||"bottom",i,xe);const{width:h,height:l}=i;let c;(h!==l||d)&&(c=pe(),ye(c,ve,h/l*(d||1),1),we(c,ve,ge(ve,xe)+90));const u=e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,xe));fe(u,t.stops,o);const f={type:a,style:u,transform:c};return r&&(f.blendMode=r),f},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Le(n||"center",i,Se),Le(s||"bottom",i,Me);const{width:h,height:l}=i,c=Re(),u=be(Se,Me);e.conicGradientRotate90?(Ee(c,Se,h/l*(d||1),1),ke(c,Se,u+90)):(Ee(c,Se,1,h/l*(d||1)),ke(c,Se,u));const f=e.conicGradientSupport?e.canvas.createConicGradient(0,Se.x,Se.y):e.canvas.createRadialGradient(Se.x,Se.y,0,Se.x,Se.y,Be(Se,Me));fe(f,t.stops,o);const g={type:a,style:f,transform:c};return r&&(g.blendMode=r),g}},{copy:Ce,toOffsetOutBounds:Oe}=B,We={},Te={};function Ie(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ce(We,t.bounds),We.x+=i.x-o.x,We.y+=i.y-o.y,n){const{matrix:t}=s;We.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),We.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),We.width*=n,We.height*=n}t.copyWorld(s.canvas,t.bounds,We)}else n&&(Ce(We,i),We.x-=i.width/2*(n-1),We.y-=i.height/2*(n-1),We.width*=n,We.height*=n),t.copyWorld(s.canvas,o,n?We:i)}const{toOffsetOutBounds:Pe}=B,De={};const Fe={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Oe(h,Te),r.forEach(((r,_)=>{f.setWorldShadow(Te.offsetX+r.x*c,Te.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,Te,s,i),n=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Pe(h,De),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(De.offsetX+r.x*c,De.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,De,s,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,l,h,"source-out"),n=h),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ne}=_;function Ye(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),He(t,e,i,1)}(t,i,n,s);break;case"opacity-path":He(t,i,n,a);break;case"path":i.restore()}}function Ue(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}U.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Ye(this,o,t,s,n,a),n=s=null),"path"===i.__.mask?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ue(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Ue(t)),s||(s=Ue(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Ne(i,e)||i.__render(s||t,e);Ye(this,o,t,s,n,a)};const Xe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",je=Xe+"_#~&*+\\=|≮≯≈≠=…",Ge=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 Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qe=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ze=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Qe=Ve(Xe),Je=Ve(je),Ze=Ve("- —/~|┆·");var Ke;!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"}(Ke||(Ke={}));const{Letter:$e,Single:ti,Before:ei,After:ii,Symbol:ni,Break:si}=Ke;function ai(t){return qe[t]?$e:Ze[t]?si:ze[t]?ei:Qe[t]?ii:Je[t]?ni:Ge.test(t)?ti:$e}const oi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ri(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:di}=oi,{Letter:hi,Single:li,Before:ci,After:ui,Symbol:fi,Break:gi}=Ke;let _i,pi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Ei,Li,Si,Mi,Ai,Ci=[];function Oi(t,e){Bi&&!bi&&(bi=Bi),_i.data.push({char:t,width:e}),wi+=e}function Wi(){yi+=wi,_i.width=wi,pi.words.push(_i),_i={data:[]},wi=0}function Ti(){Si&&(Mi.paraNumber++,pi.paraStart=!0,Si=!1),Bi&&(pi.startCharSize=bi,pi.endCharSize=Bi,bi=0),pi.width=yi,Ai.width&&di(pi),Ci.push(pi),pi={words:[]},yi=0}const Ii=0,Pi=1,Di=2;const{top:Fi,right:Ni,bottom:Yi,left:Ui}=A;function Hi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Xi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(n=h[Ui],a-=h[Ni]+h[Ui]),o&&(s=h[Fi],o-=h[Fi]+h[Yi]));const l={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Mi=t,Ci=t.rows,Ai=t.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:h}=Ai;if(d||h||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Si=!0,ki=null,bi=xi=Bi=wi=yi=0,_i={data:[]},pi={words:[]};for(let n=0,h=i.length;n<h;n++)vi=i[n],"\n"===vi?(wi&&Wi(),pi.paraEnd=!0,Ti(),Si=!0):(Ri=ai(vi),Ri===hi&&"none"!==o&&(vi=ri(vi,o,!wi)),xi=r.measureText(vi).width,s&&(s<0&&(Bi=xi),xi+=s),Ei=Ri===li&&(ki===li||ki===hi)||ki===li&&Ri!==ui,Li=!(Ri!==ci&&Ri!==li||ki!==fi&&ki!==ui),mi=Si&&a?d-a:d,t&&d&&yi+wi+xi>mi&&(e?(wi&&Wi(),Ti()):(Li||(Li=Ri===hi&&ki==ui),Ei||Li||Ri===gi||Ri===ci||Ri===li||wi+xi>mi?(wi&&Wi(),Ti()):Ti()))," "===vi&&!0!==Si&&yi+wi===0||(Ri===gi?(" "===vi&&wi&&Wi(),Oi(vi,xi),Wi()):Ei||Li?(wi&&Wi(),Oi(vi,xi)):Oi(vi,xi)),ki=Ri);wi&&Wi(),yi&&Ti(),Ci.length>0&&(Ci[Ci.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Mi.paraNumber++,Ci.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Hi(e,"x",t[Ui]);break;case"right":Hi(e,"x",-t[Ni])}if(!s)switch(i.verticalAlign){case"top":Hi(e,"y",t[Fi]);break;case"bottom":Hi(e,"y",-t[Yi])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:g,y:_,width:p,height:w}=n,y=s*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(h){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,h=i.length;a<h;a++){if(c=i[a],c.x=g,c.width<p||c.width>p&&!r)switch(d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=s,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=_,n.height=y}(l,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;s.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ii:h>.01?Pi:Di,t.isOverflow&&!r&&(t.textMode=!0),c===Di?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Pi?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:a}=i;if(n.splice(s),a&&"show"!==a){let t,o;"hide"===a?a="":"ellipsis"===a&&(a="...");const r=a?e.canvas.measureText(a).width:0,d=i.x+i.width-r;("none"===i.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],o=t.x+t.width,!(n===i&&o<d));n--){if(o<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const ji={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Gi,addPoint:Vi,toBounds:qi}=C;const zi={export(t,i,s){return this.running=!0,function(t){Qi||(Qi=new O);return new Promise((e=>{Qi.add((()=>G(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((r=>{const d=t=>{o(t),r(),this.running=!1};if("json"===i)return d({data:t.toJSON()});if("json"===a.fileType(i))return e.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(t.toJSON())),i),d({data:!0});const{leafer:h}=t;h?h.waitViewCompleted((()=>G(this,void 0,void 0,(function*(){s=a.getExportOptions(s);let e,o,r=1,l=1;const{worldTransform:c,isLeafer:u,isFrame:f}=t,{slice:_,trim:p,onCanvas:w}=s;let y=s.scale||1,m=s.pixelRatio||1;t.isApp&&(y*=m,m=t.app.pixelRatio);const v=s.screenshot||t.isApp,x=u&&v&&void 0===s.fill?t.fill:s.fill,b=a.isOpaqueImage(i)||x,B=new W;if(v)e=!0===v?u?h.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(u?"inner":"local");switch(r=c.scaleX,l=c.scaleY,i){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),r/=t.scaleX,l/=t.scaleY;break;case"world":r=1,l=1;break;case"page":i=t.leafer;default:B.set(c).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:k,width:E,height:L}=new g(e).scale(y);let S=n.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const M={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/r*y,1/l*y)};if(_&&(t=h,M.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,M),t.fill=e}else t.__render(S,M);if(S.restore(),p){o=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Vi(o,s,a):Gi(o={},s,a)),r++;const d=new g;return qi(o,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=o,s={x:0,y:0,width:e,height:i,pixelRatio:m};S=n.canvas(s),S.copyWorld(t,o,s)}b&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),w&&w(S);const A="canvas"===i?S:yield S.export(i,s);d({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:e,trimBounds:o})})))):d({data:!1})}))))}};let Qi;const Ji=t.prototype,Zi=p.get("@leafer-ui/export");Ji.export=function(t,e){const{quality:i,blob:n}=a.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ji.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Zi.error(t),n(null)}))}))},Ji.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ji.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Zi.error(t),n(!1)}))}))},Object.assign(H,Xi),Object.assign(F,ji),Object.assign(X,Ct),Object.assign(D,he),Object.assign(N,Ae),Object.assign(j,Fe),Object.assign(Y,zi),Object.assign(n,{interaction:(t,e,i,n)=>new I(t,e,i,n),hitCanvas:(t,e)=>new V(t,e),hitCanvasManager:()=>new P});export{dt as Layouter,V as LeaferCanvas,lt as Renderer,mt as Selector,J as Watcher,Q as useCanvas};
package/dist/node.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function r(t){try{d(i.next(t))}catch(t){a(t)}}function o(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:r,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class d{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,g),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:y,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){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(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,d,this.times)),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),v.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){y(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),r=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,r),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:n,height:i}=e.old;new t.Bounds(0,0,n,i).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:b}=t.BoundsHelper;class E{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(r);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,a),l=a?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,r={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,r),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)n.add(r)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(n||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:L,NoAndSkip:R,YesAndSkip:k}=t.Answer;class P{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new E(e,this),this.__listenEvents()}getBy(t,e,n,i){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return n?s:s?[s]:[];case"string":switch(t[0]){case"#":const i=this.getById(t.substring(1),e);return n?i:i?[i]:[];case".":return this.getByMethod(this.methods.className,e,n,t.substring(1));default:return this.getByMethod(this.methods.tag,e,n,t)}case"function":return this.getByMethod(t,e,n,i)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let r=0,o=t.length;r<o;r++){if(s=t[r],a=e(s,i),a===L||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function C(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function M(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?A(t,!0,e,n):I(e,n);break;case"inside":S("inside",t,s,e,n);break;case"outside":S("outside",t,s,e,n)}}function S(t,e,n,i,s){const{__strokeWidth:a,__font:r}=i.__,o=s.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*a,i.__),o.font=r,n?A(e,!0,i,o):I(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",C(i,o),o.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function I(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function A(t,e,n,s){let a;for(let r=0,o=t.length;r<o;r++)a=t[r],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?I(n,s):s.stroke(),s.restoreBlendMode()):e?I(n,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new P(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:O,getOuterOf:W,getByMove:T,getIntersectData:D}=t.BoundsHelper;let H;function F(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:r,color:o,opacity:d}=e;return{type:a,blendMode:r,style:i.ColorConvert.string(o,d)};case"image":return i.PaintImage.image(n,t,e,s,!H||!H[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const N={compute:function(t,e){const n=e.__,s=[];let a,r=n.__input[t];r instanceof Array||(r=[r]),H=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=r.length;i<a;i++)n=F(t,r[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?C(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:r}=e.__;for(let o=0,d=t.length;o<d;o++)s=t[o],s.image&&i.PaintImage.checkImage(e,n,s,!r)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),r?C(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),r?C(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):r?C(e,n):a?n.fill(a):n.fill())},fillText:C,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)M(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)M(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),A(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),A(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),A(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:M,drawTextStroke:I,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=o=s;else{const{renderShapeSpread:i}=t.__layout,c=D(i?O(e.bounds,i*l,i*h):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),o=W(s,r),a=T(o,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let Y={};const{get:j,rotateOfOuter:U,translate:G,scaleOfOuter:q,scale:X,rotate:V}=t.MatrixHelper;function z(t,e,n,i,s,a,r){const o=j();G(o,e.x+n,e.y+i),X(o,s,a),r&&U(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Q(t,e,n,i,s,a,r){const o=j();G(o,e.x+n,e.y+i),s&&X(o,s,a),r&&V(o,r),t.transform=o}function J(t,e,n,i,s,a,r,o,d,l){const h=j();if(d)if("center"===l)U(h,{x:n/2,y:i/2},d);else switch(V(h,d),d){case 90:G(h,i,0);break;case 180:G(h,n,i);break;case 270:G(h,0,n)}Y.x=e.x+s,Y.y=e.y+a,G(h,Y.x,Y.y),r&&q(h,Y,r,o),t.transform=h}const{get:Z,translate:K}=t.MatrixHelper,$=new t.Bounds,tt={};function et(e,n,i,s){let{width:a,height:r}=n;i.padding&&(s=$.set(s).shrink(i.padding));const{opacity:o,mode:d,around:l,offset:h,scale:c,size:u,rotation:f,blendMode:g,repeat:p}=i,_=s.width===a&&s.height===r;g&&(e.blendMode=g);const y=e.data={mode:d},w="center"!==l&&(f||0)%180==90,m=w?r:a,v=w?a:r;let x,B,b=0,E=0;if(d&&"cover"!==d&&"fit"!==d)u?(x=("number"==typeof u?u:u.width)/a,B=("number"==typeof u?u:u.height)/r):c&&(x="number"==typeof c?c:c.x,B="number"==typeof c?c:c.y);else if(!_||f){const t=s.width/m,e=s.height/v;x=B="fit"===d?Math.min(t,e):Math.max(t,e),b+=(s.width-a*x)/2,E+=(s.height-r*B)/2}if(l){const e={x:b,y:E,width:m,height:v};x&&(e.width*=x,e.height*=B),t.AroundHelper.toPoint(l,s,tt,!0,e),b+=tt.x,E+=tt.y}switch(h&&(b+=h.x,E+=h.y),d){case"strench":_||(a=s.width,r=s.height);break;case"normal":case"clip":(b||E||x||f)&&Q(y,s,b,E,x,B,f);break;case"repeat":(!_||x||f)&&J(y,s,a,r,b,E,x,B,f,l),p||(y.repeat="repeat");break;default:x&&z(y,s,b,E,x,B,f)}y.transform||(s.x||s.y)&&(y.transform=Z(),K(y.transform,s.x,s.y)),x&&"strench"!==d&&(y.scaleX=x,y.scaleY=B),y.width=a,y.height=r,o&&(y.opacity=o),p&&(y.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat")}let nt,it=new t.Bounds;const{isSame:st}=t.BoundsHelper;function at(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||et(s,i,n,a),!0}function rt(e,n){lt(e,t.ImageEvent.LOAD,n)}function ot(e,n){lt(e,t.ImageEvent.LOADED,n)}function dt(e,n,i){n.error=i,e.forceUpdate("surface"),lt(e,t.ImageEvent.ERROR,n)}function lt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ct,scale:ut,copy:ft}=t.MatrixHelper,{ceil:gt,abs:pt}=Math;function _t(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{s=pt(s),a=pt(a);const{image:e,data:o}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=o;u&&(l=ct(),ft(l,p),ut(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const y=h*c;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=ct(),p&&ft(l,p)),ut(l,1/s,1/a));const m=e.getCanvas(gt(h)||1,gt(c)||1,g),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}const{abs:yt}=Math;const wt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return nt&&i===nt.paint&&st(s,nt.boxBounds)?r=nt.leafPaint:(r={type:i.type,image:d},nt=d.use>1?{leafPaint:r,paint:i,boxBounds:it.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(at(e,n,i,d,r,s),a&&(rt(e,o),ot(e,o))):d.error?a&&dt(e,o,d.error):(ht(e,!0),a&&rt(e,o),r.loadId=d.load((()=>{ht(e,!1),e.destroyed||(at(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ot(e,o)),r.loadId=null}),(t=>{ht(e,!1),dt(e,o,t),r.loadId=null}))),r},createData:et,fillOrFitMode:z,clipMode:Q,repeatMode:J,createPattern:_t,checkImage:function(e,n,a,r){const{scaleX:o,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(a.data&&a.patternId!==o+"-"+d){const{data:l}=a;if(r)if(l.repeat)r=!1;else{let{width:e,height:i}=l;e*=yt(o)*n.pixelRatio,i*=yt(d)*n.pixelRatio,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),r=e*i>t.Platform.image.maxCacheSize}return r?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(a.image.view,0,0,l.width,l.height),n.restore(),!0):(!a.style||i.Export.running?_t(e,a,n.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,a,n.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d].image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null}},mt={x:.5,y:0},vt={x:.5,y:1};function xt(t,e,n){let s;for(let a=0,r=e.length;a<r;a++)s=e[a],t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}const{set:Bt,getAngle:bt,getDistance:Et}=t.PointHelper,{get:Lt,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,Pt={x:.5,y:.5},Ct={x:.5,y:1},Mt={},St={};const{set:It,getAngle:At,getDistance:Ot}=t.PointHelper,{get:Wt,rotateOfOuter:Tt,scaleOfOuter:Dt}=t.MatrixHelper,Ht={x:.5,y:.5},Ft={x:.5,y:1},Nt={},Yt={};const jt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;i||(i=mt),s||(s=vt);const d=t.Platform.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);xt(d,e.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=Pt),s||(s=Ct);const{x:l,y:h,width:c,height:u}=n;let f;Bt(Mt,l+i.x*c,h+i.y*u),Bt(St,l+s.x*c,h+s.y*u),(c!==u||d)&&(f=Lt(),kt(f,Mt,c/u*(d||1),1),Rt(f,Mt,bt(Mt,St)+90));const g=t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,Et(Mt,St));xt(g,e.stops,r);const p={type:a,style:g,transform:f};return o&&(p.blendMode=o),p},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=Ht),s||(s=Ft);const{x:l,y:h,width:c,height:u}=n;It(Nt,l+i.x*c,h+i.y*u),It(Yt,l+s.x*c,h+s.y*u);const f=Wt(),g=At(Nt,Yt);t.Platform.conicGradientRotate90?(Dt(f,Nt,c/u*(d||1),1),Tt(f,Nt,g+90)):(Dt(f,Nt,1,c/u*(d||1)),Tt(f,Nt,g));const p=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Nt.x,Nt.y):t.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Ot(Nt,Yt));xt(p,e.stops,r);const _={type:a,style:p,transform:f};return o&&(_.blendMode=o),_}},{copy:Ut,toOffsetOutBounds:Gt}=t.BoundsHelper,qt={},Xt={};function Vt(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Ut(qt,e.bounds),qt.x+=n.x-r.x,qt.y+=n.y-r.y,i){const{matrix:t}=s;qt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),qt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),qt.width*=i,qt.height*=i}e.copyWorld(s.canvas,e.bounds,qt)}else i&&(Ut(qt,n),qt.x-=n.width/2*(i-1),qt.y-=n.height/2*(i-1),qt.width*=i,qt.height*=i),e.copyWorld(s.canvas,r,i?qt:n)}const{toOffsetOutBounds:zt}=t.BoundsHelper,Qt={};const Jt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Gt(l,Xt),o.forEach(((o,p)=>{f.setWorldShadow(Xt.offsetX+o.x*c,Xt.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Vt(f,Xt,s,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;zt(l,Qt),o.forEach(((o,p)=>{f.save(),f.setWorldShadow(Qt.offsetX+o.x*c,Qt.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Vt(f,Qt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Zt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),te(t,e,n,1)}(t,n,i,s);break;case"opacity-path":te(t,n,i,a);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function te(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,r;const{children:o}=this;for(let d=0,l=o.length;d<l;d++)n=o[d],n.__.mask&&(r&&(Kt(this,r,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=$t(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="alpha",i||(i=$t(t)),s||(s=$t(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||Zt(n,e)||n.__render(s||t,e);Kt(this,r,t,s,i,a)};const ee=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ne=ee+"_#~&*+\\=|≮≯≈≠=…",ie=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 se(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ae=se("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),re=se("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=se(ee),de=se(ne),le=se("- —/~|┆·");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:ce,Single:ue,Before:fe,After:ge,Symbol:pe,Break:_e}=he;function ye(t){return ae[t]?ce:le[t]?_e:re[t]?fe:oe[t]?ge:de[t]?pe:ie.test(t)?ue:ce}const we={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ve}=we,{Letter:xe,Single:Be,Before:be,After:Ee,Symbol:Le,Break:Re}=he;let ke,Pe,Ce,Me,Se,Ie,Ae,Oe,We,Te,De,He,Fe,Ne,Ye,je,Ue=[];function Ge(t,e){We&&!Oe&&(Oe=We),ke.data.push({char:t,width:e}),Ce+=e}function qe(){Me+=Ce,ke.width=Ce,Pe.words.push(ke),ke={data:[]},Ce=0}function Xe(){Ne&&(Ye.paraNumber++,Pe.paraStart=!0,Ne=!1),We&&(Pe.startCharSize=Oe,Pe.endCharSize=We,Oe=0),Pe.width=Me,je.width&&ve(Pe),Ue.push(Pe),Pe={words:[]},Me=0}const Ve=0,ze=1,Qe=2;const{top:Je,right:Ze,bottom:Ke,left:$e}=t.Direction4;function tn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const en={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(a&&(i=l[$e],a-=l[Ze]+l[$e]),r&&(s=l[Je],r-=l[Je]+l[Ke]));const h={bounds:{x:i,y:s,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ye=e,Ue=e.rows,je=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=je;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Ne=!0,De=null,Oe=Ae=We=Ce=Me=0,ke={data:[]},Pe={words:[]};for(let i=0,l=n.length;i<l;i++)Ie=n[i],"\n"===Ie?(Ce&&qe(),Pe.paraEnd=!0,Xe(),Ne=!0):(Te=ye(Ie),Te===xe&&"none"!==r&&(Ie=me(Ie,r,!Ce)),Ae=o.measureText(Ie).width,s&&(s<0&&(We=Ae),Ae+=s),He=Te===Be&&(De===Be||De===xe)||De===Be&&Te!==Ee,Fe=!(Te!==be&&Te!==Be||De!==Le&&De!==Ee),Se=Ne&&a?d-a:d,t&&d&&Me+Ce+Ae>Se&&(e?(Ce&&qe(),Xe()):(Fe||(Fe=Te===xe&&De==Ee),He||Fe||Te===Re||Te===be||Te===Be||Ce+Ae>Se?(Ce&&qe(),Xe()):Xe()))," "===Ie&&!0!==Ne&&Me+Ce===0||(Te===Re?(" "===Ie&&Ce&&qe(),Ge(Ie,Ae),qe()):He||Fe?(Ce&&qe(),Ge(Ie,Ae)):Ge(Ie,Ae)),De=Te);Ce&&qe(),Me&&Xe(),Ue.length>0&&(Ue[Ue.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ye.paraNumber++,Ue.push({x:a||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":tn(e,"x",t[$e]);break;case"right":tn(e,"x",-t[Ze])}if(!s)switch(n.verticalAlign){case"top":tn(e,"y",t[Je]);break;case"bottom":tn(e,"y",-t[Ke])}}(l,h,n,a,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:g,y:p,width:_,height:y}=i,w=s*n.length+(h?h*(t.paraNumber-1):0),m=a;if(o&&w>y)w=Math.max(y,s),t.overflow=n.length;else switch(l){case"middle":p+=(y-w)/2;break;case"bottom":p+=y-w}m+=p;for(let a=0,l=n.length;a<l;a++){switch(c=n[a],c.x=g,d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(m+=h),c.y=m,m+=s,t.overflow>a&&m>w&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<i.x&&(i.x=u),f>i.width&&(i.width=f),o&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?Ve:l>.01?ze:Qe,t.isOverflow&&!o&&(t.textMode=!0),c===Qe?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===ze?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n){const{rows:i,overflow:s}=e;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let e,r;"ellipsis"===a&&(a="...");const o=t.Platform.canvas.measureText(a).width,d=n.x+n.width-o;("none"===n.textWrap?i:[i[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],r=e.x+e.width,!(i===n&&r<d));i--){if(r<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=o,t.data.push({char:a,x:r}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n),"none"!==o&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const nn={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:sn,addPoint:an,toBounds:rn}=t.TwoPointBoundsHelper;const on={export(e,n,i){return this.running=!0,function(e){dn||(dn=new t.TaskProcessor);return new Promise((t=>{dn.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const o=t=>{a(t),r(),this.running=!1};if("json"===n)return o({data:e.toJSON()});if("json"===t.FileHelper.fileType(n))return t.Platform.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(e.toJSON())),n),o({data:!0});const{leafer:d}=e;d?d.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){i=t.FileHelper.getExportOptions(i);let s,a,r=1,l=1;const{worldTransform:h,isLeafer:c,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=i,_=i.scale||1,y=i.pixelRatio||1,w=i.screenshot||e.isApp,m=c&&w&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||m,x=new t.Matrix;if(w)s=!0===w?c?d.canvas.bounds:e.worldRenderBounds:w;else{let t=i.relative||(c?"inner":"local");switch(r=h.scaleX,l=h.scaleY,t){case"inner":x.set(h);break;case"local":x.set(h).divide(e.localTransform),r/=e.scaleX,l/=e.scaleY;break;case"world":r=1,l=1;break;case"page":t=e.leafer;default:x.set(h).divide(e.getTransform(t));const n=t.worldTransform;r/=r/n.scaleX,l/=l/n.scaleY}s=e.getBounds("render",t)}const{x:B,y:b,width:E,height:L}=new t.Bounds(s).scale(_);let R=t.Creator.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:y});const k={matrix:x.scale(1/_).invert().translate(-B,-b).withScale(1/r*_,1/l*_)};if(f&&(e=d,k.bounds=R.bounds),R.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(R,k),e.fill=t}else e.__render(R,k);if(R.restore(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,r,o,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,r=(d-a)/n,o?an(o,a,r):sn(o={},a,r)),d++;const l=new t.Bounds;return rn(o,l),l.scale(1/e.pixelRatio).ceil()}(R);const e=R,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:y};R=t.Creator.canvas(s),R.copyWorld(e,a,s)}v&&R.fillWorld(R.bounds,m||"#FFFFFF","destination-over"),p&&p(R);const P="canvas"===n?R:yield R.export(n,i);o({data:P,width:R.pixelWidth,height:R.pixelHeight,renderBounds:s,trimBounds:a})})))):o({data:!1})}))))}};let dn;const ln=t.LeaferCanvasBase.prototype,hn=t.Debug.get("@leafer-ui/export");ln.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},ln.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{hn.error(t),i(null)}))}))},ln.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},ln.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{hn.error(t),i(!1)}))}))},Object.assign(i.TextConvert,en),Object.assign(i.ColorConvert,nn),Object.assign(i.Paint,N),Object.assign(i.PaintImage,wt),Object.assign(i.PaintGradient,jt),Object.assign(i.Effect,Jt),Object.assign(i.Export,on),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=P,exports.Watcher=d,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:a}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(r(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(r(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(r(o(n)),i))})),download(t,e){},loadImage:a}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function r(t){try{d(i.next(t))}catch(t){a(t)}}function o(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:r,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class d{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,g),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:y}=t.LeafHelper,m=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){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(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,d,this.times)),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),v.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),r=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,r),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:b}=t.BoundsHelper;class E{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(r);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,a),l=a?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,r={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,r),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)n.add(r)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.add(n||t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:L,NoAndSkip:R,YesAndSkip:k}=t.Answer,P={},C={},M={};class S{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new E(e,this),this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":P.id=e.substring(1),e=P;break;case".":C.className=e.substring(1),e=C;break;default:M.tag=e,e=M}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let r=0,o=t.length;r<o;r++){if(s=t[r],a=e(s,i),a===L||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function A(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function I(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?T(t,!0,e,n):W(e,n);break;case"inside":O("inside",t,s,e,n);break;case"outside":O("outside",t,s,e,n)}}function O(t,e,n,i,s){const{__strokeWidth:a,__font:r}=i.__,o=s.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*a,i.__),o.font=r,n?T(e,!0,i,o):W(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",A(i,o),o.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function W(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function T(t,e,n,s){let a;for(let r=0,o=t.length;r<o;r++)a=t[r],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?W(n,s):s.stroke(),s.restoreBlendMode()):e?W(n,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new S(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:H,getOuterOf:D,getByMove:F,getIntersectData:N}=t.BoundsHelper;let j;function Y(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:r,color:o,opacity:d}=e;return{type:a,blendMode:r,style:i.ColorConvert.string(o,d)};case"image":return i.PaintImage.image(n,t,e,s,!j||!j[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const U={compute:function(t,e){const n=e.__,s=[];let a,r=n.__input[t];r instanceof Array||(r=[r]),j=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=r.length;i<a;i++)n=Y(t,r[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?A(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:r}=e.__;for(let o=0,d=t.length;o<d;o++)s=t[o],s.image&&i.PaintImage.checkImage(e,n,s,!r)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),r?A(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),r?A(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):r?A(e,n):a?n.fill(a):n.fill())},fillText:A,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)I(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)I(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),T(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),T(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),T(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:I,drawTextStroke:W,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=o=s;else{const{renderShapeSpread:i}=t.__layout,c=N(i?H(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),o=D(s,r),a=F(o,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let G={};const{get:q,rotateOfOuter:X,translate:V,scaleOfOuter:z,scale:Q,rotate:J}=t.MatrixHelper;function Z(t,e,n,i,s,a,r){const o=q();V(o,e.x+n,e.y+i),Q(o,s,a),r&&X(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function K(t,e,n,i,s,a,r){const o=q();V(o,e.x+n,e.y+i),s&&Q(o,s,a),r&&J(o,r),t.transform=o}function $(t,e,n,i,s,a,r,o,d,l){const h=q();if(d)if("center"===l)X(h,{x:n/2,y:i/2},d);else switch(J(h,d),d){case 90:V(h,i,0);break;case 180:V(h,n,i);break;case 270:V(h,0,n)}G.x=e.x+s,G.y=e.y+a,V(h,G.x,G.y),r&&z(h,G,r,o),t.transform=h}const{get:tt,translate:et}=t.MatrixHelper,nt=new t.Bounds,it={};function st(e,n,i,s){let{width:a,height:r}=n;i.padding&&(s=nt.set(s).shrink(i.padding));const{opacity:o,mode:d,align:l,offset:h,scale:c,size:u,rotation:f,blendMode:g,repeat:p}=i,_=s.width===a&&s.height===r;g&&(e.blendMode=g);const w=e.data={mode:d},y="center"!==l&&(f||0)%180==90,m=y?r:a,v=y?a:r;let x,B,b=0,E=0;if(d&&"cover"!==d&&"fit"!==d)u?(x=("number"==typeof u?u:u.width)/a,B=("number"==typeof u?u:u.height)/r):c&&(x="number"==typeof c?c:c.x,B="number"==typeof c?c:c.y);else if(!_||f){const t=s.width/m,e=s.height/v;x=B="fit"===d?Math.min(t,e):Math.max(t,e),b+=(s.width-a*x)/2,E+=(s.height-r*B)/2}if(l){const e={x:b,y:E,width:m,height:v};x&&(e.width*=x,e.height*=B),t.AlignHelper.toPoint(l,e,s,it,!0),b+=it.x,E+=it.y}switch(h&&(b+=h.x,E+=h.y),d){case"strench":_||(a=s.width,r=s.height);break;case"normal":case"clip":(b||E||x||f)&&K(w,s,b,E,x,B,f);break;case"repeat":(!_||x||f)&&$(w,s,a,r,b,E,x,B,f,l),p||(w.repeat="repeat");break;default:x&&Z(w,s,b,E,x,B,f)}w.transform||(s.x||s.y)&&(w.transform=tt(),et(w.transform,s.x,s.y)),x&&"strench"!==d&&(w.scaleX=x,w.scaleY=B),w.width=a,w.height=r,o&&(w.opacity=o),p&&(w.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat")}let at,rt=new t.Bounds;const{isSame:ot}=t.BoundsHelper;function dt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||st(s,i,n,a),!0}function lt(e,n){ut(e,t.ImageEvent.LOAD,n)}function ht(e,n){ut(e,t.ImageEvent.LOADED,n)}function ct(e,n,i){n.error=i,e.forceUpdate("surface"),ut(e,t.ImageEvent.ERROR,n)}function ut(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ft(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:gt,scale:pt,copy:_t}=t.MatrixHelper,{ceil:wt,abs:yt}=Math;function mt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{s=yt(s),a=yt(a);const{image:e,data:o}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=o;u&&(l=gt(),_t(l,p),pt(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=gt(),p&&_t(l,p)),pt(l,1/s,1/a));const m=e.getCanvas(wt(h)||1,wt(c)||1,g),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}const{abs:vt}=Math;const xt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return at&&i===at.paint&&ot(s,at.boxBounds)?r=at.leafPaint:(r={type:i.type,image:d},at=d.use>1?{leafPaint:r,paint:i,boxBounds:rt.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(dt(e,n,i,d,r,s),a&&(lt(e,o),ht(e,o))):d.error?a&&ct(e,o,d.error):(ft(e,!0),a&&lt(e,o),r.loadId=d.load((()=>{ft(e,!1),e.destroyed||(dt(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(e,o)),r.loadId=null}),(t=>{ft(e,!1),ct(e,o,t),r.loadId=null}))),r},createData:st,fillOrFitMode:Z,clipMode:K,repeatMode:$,createPattern:mt,checkImage:function(e,n,a,r){const{scaleX:o,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(a.data&&a.patternId!==o+"-"+d){const{data:l}=a;if(r)if(l.repeat)r=!1;else{let{width:e,height:i}=l;e*=vt(o)*n.pixelRatio,i*=vt(d)*n.pixelRatio,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),r=e*i>t.Platform.image.maxCacheSize}return r?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(a.image.view,0,0,l.width,l.height),n.restore(),!0):(!a.style||i.Export.running?mt(e,a,n.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__nowWorld)&&mt(e,a,n.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d].image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null}},{toPoint:Bt}=t.AroundHelper,bt={},Et={};function Lt(t,e,n){let s;for(let a=0,r=e.length;a<r;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(r-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}const{getAngle:Rt,getDistance:kt}=t.PointHelper,{get:Pt,rotateOfOuter:Ct,scaleOfOuter:Mt}=t.MatrixHelper,{toPoint:St}=t.AroundHelper,At={},It={};const{getAngle:Ot,getDistance:Wt}=t.PointHelper,{get:Tt,rotateOfOuter:Ht,scaleOfOuter:Dt}=t.MatrixHelper,{toPoint:Ft}=t.AroundHelper,Nt={},jt={};const Yt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;Bt(i||"top",n,bt),Bt(s||"bottom",n,Et);const d=t.Platform.canvas.createLinearGradient(bt.x,bt.y,Et.x,Et.y);Lt(d,e.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;St(i||"center",n,At),St(s||"bottom",n,It);const{width:l,height:h}=n;let c;(l!==h||d)&&(c=Pt(),Mt(c,At,l/h*(d||1),1),Ct(c,At,Rt(At,It)+90));const u=t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,kt(At,It));Lt(u,e.stops,r);const f={type:a,style:u,transform:c};return o&&(f.blendMode=o),f},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;Ft(i||"center",n,Nt),Ft(s||"bottom",n,jt);const{width:l,height:h}=n,c=Tt(),u=Ot(Nt,jt);t.Platform.conicGradientRotate90?(Dt(c,Nt,l/h*(d||1),1),Ht(c,Nt,u+90)):(Dt(c,Nt,1,l/h*(d||1)),Ht(c,Nt,u));const f=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Nt.x,Nt.y):t.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Wt(Nt,jt));Lt(f,e.stops,r);const g={type:a,style:f,transform:c};return o&&(g.blendMode=o),g}},{copy:Ut,toOffsetOutBounds:Gt}=t.BoundsHelper,qt={},Xt={};function Vt(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Ut(qt,e.bounds),qt.x+=n.x-r.x,qt.y+=n.y-r.y,i){const{matrix:t}=s;qt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),qt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),qt.width*=i,qt.height*=i}e.copyWorld(s.canvas,e.bounds,qt)}else i&&(Ut(qt,n),qt.x-=n.width/2*(i-1),qt.y-=n.height/2*(i-1),qt.width*=i,qt.height*=i),e.copyWorld(s.canvas,r,i?qt:n)}const{toOffsetOutBounds:zt}=t.BoundsHelper,Qt={};const Jt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Gt(l,Xt),o.forEach(((o,p)=>{f.setWorldShadow(Xt.offsetX+o.x*c,Xt.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Vt(f,Xt,s,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;zt(l,Qt),o.forEach(((o,p)=>{f.save(),f.setWorldShadow(Qt.offsetX+o.x*c,Qt.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Vt(f,Qt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Zt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),te(t,e,n,1)}(t,n,i,s);break;case"opacity-path":te(t,n,i,a);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function te(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,r;const{children:o}=this;for(let d=0,l=o.length;d<l;d++)n=o[d],n.__.mask&&(r&&(Kt(this,r,t,s,i,a),i=s=null),"path"===n.__.mask?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=$t(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="alpha",i||(i=$t(t)),s||(s=$t(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Zt(n,e)||n.__render(s||t,e);Kt(this,r,t,s,i,a)};const ee=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ne=ee+"_#~&*+\\=|≮≯≈≠=…",ie=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 se(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ae=se("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),re=se("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=se(ee),de=se(ne),le=se("- —/~|┆·");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:ce,Single:ue,Before:fe,After:ge,Symbol:pe,Break:_e}=he;function we(t){return ae[t]?ce:le[t]?_e:re[t]?fe:oe[t]?ge:de[t]?pe:ie.test(t)?ue:ce}const ye={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ve}=ye,{Letter:xe,Single:Be,Before:be,After:Ee,Symbol:Le,Break:Re}=he;let ke,Pe,Ce,Me,Se,Ae,Ie,Oe,We,Te,He,De,Fe,Ne,je,Ye,Ue=[];function Ge(t,e){We&&!Oe&&(Oe=We),ke.data.push({char:t,width:e}),Ce+=e}function qe(){Me+=Ce,ke.width=Ce,Pe.words.push(ke),ke={data:[]},Ce=0}function Xe(){Ne&&(je.paraNumber++,Pe.paraStart=!0,Ne=!1),We&&(Pe.startCharSize=Oe,Pe.endCharSize=We,Oe=0),Pe.width=Me,Ye.width&&ve(Pe),Ue.push(Pe),Pe={words:[]},Me=0}const Ve=0,ze=1,Qe=2;const{top:Je,right:Ze,bottom:Ke,left:$e}=t.Direction4;function tn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const en={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(a&&(i=l[$e],a-=l[Ze]+l[$e]),r&&(s=l[Je],r-=l[Je]+l[Ke]));const h={bounds:{x:i,y:s,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){je=e,Ue=e.rows,Ye=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Ye;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Ne=!0,He=null,Oe=Ie=We=Ce=Me=0,ke={data:[]},Pe={words:[]};for(let i=0,l=n.length;i<l;i++)Ae=n[i],"\n"===Ae?(Ce&&qe(),Pe.paraEnd=!0,Xe(),Ne=!0):(Te=we(Ae),Te===xe&&"none"!==r&&(Ae=me(Ae,r,!Ce)),Ie=o.measureText(Ae).width,s&&(s<0&&(We=Ie),Ie+=s),De=Te===Be&&(He===Be||He===xe)||He===Be&&Te!==Ee,Fe=!(Te!==be&&Te!==Be||He!==Le&&He!==Ee),Se=Ne&&a?d-a:d,t&&d&&Me+Ce+Ie>Se&&(e?(Ce&&qe(),Xe()):(Fe||(Fe=Te===xe&&He==Ee),De||Fe||Te===Re||Te===be||Te===Be||Ce+Ie>Se?(Ce&&qe(),Xe()):Xe()))," "===Ae&&!0!==Ne&&Me+Ce===0||(Te===Re?(" "===Ae&&Ce&&qe(),Ge(Ae,Ie),qe()):De||Fe?(Ce&&qe(),Ge(Ae,Ie)):Ge(Ae,Ie)),He=Te);Ce&&qe(),Me&&Xe(),Ue.length>0&&(Ue[Ue.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{je.paraNumber++,Ue.push({x:a||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":tn(e,"x",t[$e]);break;case"right":tn(e,"x",-t[Ze])}if(!s)switch(n.verticalAlign){case"top":tn(e,"y",t[Je]);break;case"bottom":tn(e,"y",-t[Ke])}}(l,h,n,a,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:g,y:p,width:_,height:w}=i,y=s*n.length+(h?h*(t.paraNumber-1):0),m=a;if(o&&y>w)y=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let a=0,l=n.length;a<l;a++){if(c=n[a],c.x=g,c.width<_||c.width>_&&!o)switch(d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(m+=h),c.y=m,m+=s,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<i.x&&(i.x=u),f>i.width&&(i.width=f),o&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=y}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?Ve:l>.01?ze:Qe,t.isOverflow&&!o&&(t.textMode=!0),c===Qe?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===ze?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n){const{rows:i,overflow:s}=e;let{textOverflow:a}=n;if(i.splice(s),a&&"show"!==a){let e,r;"hide"===a?a="":"ellipsis"===a&&(a="...");const o=a?t.Platform.canvas.measureText(a).width:0,d=n.x+n.width-o;("none"===n.textWrap?i:[i[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],r=e.x+e.width,!(i===n&&r<d));i--){if(r<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=o,t.data.push({char:a,x:r}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n),"none"!==o&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const nn={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:sn,addPoint:an,toBounds:rn}=t.TwoPointBoundsHelper;const on={export(e,n,i){return this.running=!0,function(e){dn||(dn=new t.TaskProcessor);return new Promise((t=>{dn.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const o=t=>{a(t),r(),this.running=!1};if("json"===n)return o({data:e.toJSON()});if("json"===t.FileHelper.fileType(n))return t.Platform.origin.download("data:text/plain;charset=utf-8,"+encodeURIComponent(JSON.stringify(e.toJSON())),n),o({data:!0});const{leafer:d}=e;d?d.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){i=t.FileHelper.getExportOptions(i);let s,a,r=1,l=1;const{worldTransform:h,isLeafer:c,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=i;let _=i.scale||1,w=i.pixelRatio||1;e.isApp&&(_*=w,w=e.app.pixelRatio);const y=i.screenshot||e.isApp,m=c&&y&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||m,x=new t.Matrix;if(y)s=!0===y?c?d.canvas.bounds:e.worldRenderBounds:y;else{let t=i.relative||(c?"inner":"local");switch(r=h.scaleX,l=h.scaleY,t){case"inner":x.set(h);break;case"local":x.set(h).divide(e.localTransform),r/=e.scaleX,l/=e.scaleY;break;case"world":r=1,l=1;break;case"page":t=e.leafer;default:x.set(h).divide(e.getTransform(t));const n=t.worldTransform;r/=r/n.scaleX,l/=l/n.scaleY}s=e.getBounds("render",t)}const{x:B,y:b,width:E,height:L}=new t.Bounds(s).scale(_);let R=t.Creator.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:w});const k={matrix:x.scale(1/_).invert().translate(-B,-b).withScale(1/r*_,1/l*_)};if(f&&(e=d,k.bounds=R.bounds),R.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(R,k),e.fill=t}else e.__render(R,k);if(R.restore(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,r,o,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,r=(d-a)/n,o?an(o,a,r):sn(o={},a,r)),d++;const l=new t.Bounds;return rn(o,l),l.scale(1/e.pixelRatio).ceil()}(R);const e=R,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:w};R=t.Creator.canvas(s),R.copyWorld(e,a,s)}v&&R.fillWorld(R.bounds,m||"#FFFFFF","destination-over"),p&&p(R);const P="canvas"===n?R:yield R.export(n,i);o({data:P,width:R.pixelWidth,height:R.pixelHeight,renderBounds:s,trimBounds:a})})))):o({data:!1})}))))}};let dn;const ln=t.LeaferCanvasBase.prototype,hn=t.Debug.get("@leafer-ui/export");ln.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},ln.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{hn.error(t),i(null)}))}))},ln.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},ln.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{hn.error(t),i(!1)}))}))},Object.assign(i.TextConvert,en),Object.assign(i.ColorConvert,nn),Object.assign(i.Paint,U),Object.assign(i.PaintImage,xt),Object.assign(i.PaintGradient,Yt),Object.assign(i.Effect,Jt),Object.assign(i.Export,on),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=S,exports.Watcher=d,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:a}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(r(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(r(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(r(o(n)),i))})),download(t,e){},loadImage:a}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@leafer-ui/node",
3
- "version": "1.0.0-rc.22",
3
+ "version": "1.0.0-rc.24",
4
4
  "description": "@leafer-ui/node",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
- "main": "dist/core.esm.js",
8
+ "main": "dist/node.esm.js",
9
9
  "exports": {
10
10
  "import": "./dist/node.esm.js",
11
11
  "require": "./dist/node.cjs",
@@ -30,13 +30,13 @@
30
30
  "leaferjs"
31
31
  ],
32
32
  "dependencies": {
33
- "@leafer/core": "1.0.0-rc.22",
34
- "@leafer/node": "1.0.0-rc.22",
35
- "@leafer/partner": "1.0.0-rc.22",
36
- "@leafer/interface": "1.0.0-rc.22",
37
- "@leafer-ui/draw": "1.0.0-rc.22",
38
- "@leafer-ui/core": "1.0.0-rc.22",
39
- "@leafer-ui/partner": "1.0.0-rc.22",
40
- "@leafer-ui/interface": "1.0.0-rc.22"
33
+ "@leafer/core": "1.0.0-rc.24",
34
+ "@leafer/node": "1.0.0-rc.24",
35
+ "@leafer/partner": "1.0.0-rc.24",
36
+ "@leafer/interface": "1.0.0-rc.24",
37
+ "@leafer-ui/draw": "1.0.0-rc.24",
38
+ "@leafer-ui/core": "1.0.0-rc.24",
39
+ "@leafer-ui/partner": "1.0.0-rc.24",
40
+ "@leafer-ui/interface": "1.0.0-rc.24"
41
41
  }
42
42
  }