@leafer-draw/node 1.0.0-rc.19 → 1.0.0-rc.21

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
@@ -73,6 +73,7 @@ function useCanvas(canvasType, power) {
73
73
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURLSync(type, { quality }),
74
74
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
75
75
  canvasSaveAs: (canvas, filename, quality) => canvas.saveAs(filename, { quality }),
76
+ download(_url, _filename) { return undefined; },
76
77
  loadImage
77
78
  };
78
79
  core.Platform.roundRectPatch = true;
@@ -84,6 +85,7 @@ function useCanvas(canvasType, power) {
84
85
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
85
86
  canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function* () { return canvas.toBuffer(mineType(type), quality); }),
86
87
  canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function* () { return fs.writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
88
+ download(_url, _filename) { return undefined; },
87
89
  loadImage
88
90
  };
89
91
  }
@@ -282,7 +284,7 @@ class LayoutBlockData {
282
284
  }
283
285
 
284
286
  const { updateAllMatrix, updateAllChange } = core.LeafHelper;
285
- const debug$1 = core.Debug.get('Layouter');
287
+ const debug$2 = core.Debug.get('Layouter');
286
288
  class Layouter {
287
289
  constructor(target, userConfig) {
288
290
  this.totalTimes = 0;
@@ -317,7 +319,7 @@ class Layouter {
317
319
  target.emitEvent(new core.LayoutEvent(core.LayoutEvent.END, this.layoutedBlocks, this.times));
318
320
  }
319
321
  catch (e) {
320
- debug$1.error(e);
322
+ debug$2.error(e);
321
323
  }
322
324
  this.layoutedBlocks = null;
323
325
  }
@@ -331,9 +333,9 @@ class Layouter {
331
333
  }
332
334
  layoutOnce() {
333
335
  if (this.layouting)
334
- return debug$1.warn('layouting');
336
+ return debug$2.warn('layouting');
335
337
  if (this.times > 3)
336
- return debug$1.warn('layout max times');
338
+ return debug$2.warn('layout max times');
337
339
  this.times++;
338
340
  this.totalTimes++;
339
341
  this.layouting = true;
@@ -437,7 +439,7 @@ class Layouter {
437
439
  }
438
440
  }
439
441
 
440
- const debug = core.Debug.get('Renderer');
442
+ const debug$1 = core.Debug.get('Renderer');
441
443
  class Renderer {
442
444
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
443
445
  constructor(target, canvas, userConfig) {
@@ -475,7 +477,7 @@ class Renderer {
475
477
  const { target } = this;
476
478
  this.times = 0;
477
479
  this.totalBounds = new core.Bounds();
478
- debug.log(target.innerName, '--->');
480
+ debug$1.log(target.innerName, '--->');
479
481
  try {
480
482
  this.emitRender(core.RenderEvent.START);
481
483
  this.renderOnce(callback);
@@ -484,9 +486,9 @@ class Renderer {
484
486
  }
485
487
  catch (e) {
486
488
  this.rendering = false;
487
- debug.error(e);
489
+ debug$1.error(e);
488
490
  }
489
- debug.log('-------------|');
491
+ debug$1.log('-------------|');
490
492
  }
491
493
  renderAgain() {
492
494
  if (this.rendering) {
@@ -498,9 +500,9 @@ class Renderer {
498
500
  }
499
501
  renderOnce(callback) {
500
502
  if (this.rendering)
501
- return debug.warn('rendering');
503
+ return debug$1.warn('rendering');
502
504
  if (this.times > 3)
503
- return debug.warn('render max times');
505
+ return debug$1.warn('render max times');
504
506
  this.times++;
505
507
  this.totalTimes++;
506
508
  this.rendering = true;
@@ -537,7 +539,7 @@ class Renderer {
537
539
  partRender() {
538
540
  const { canvas, updateBlocks: list } = this;
539
541
  if (!list)
540
- return debug.warn('PartRender: need update attr');
542
+ return debug$1.warn('PartRender: need update attr');
541
543
  this.mergeBlocks();
542
544
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
543
545
  this.clipRender(block); });
@@ -637,7 +639,7 @@ class Renderer {
637
639
  empty = (!leaf.__world.width || !leaf.__world.height);
638
640
  if (empty) {
639
641
  if (!leaf.isLeafer)
640
- debug.tip(leaf.innerName, ': empty');
642
+ debug$1.tip(leaf.innerName, ': empty');
641
643
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
642
644
  }
643
645
  return empty;
@@ -1039,8 +1041,11 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
1039
1041
  }
1040
1042
 
1041
1043
  const { get: get$3, translate } = core.MatrixHelper;
1044
+ const tempBox = new core.Bounds();
1042
1045
  function createData(leafPaint, image, paint, box) {
1043
1046
  let { width, height } = image;
1047
+ if (paint.padding)
1048
+ box = tempBox.set(box).shrink(paint.padding);
1044
1049
  const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
1045
1050
  const sameBox = box.width === width && box.height === height;
1046
1051
  if (blendMode)
@@ -1124,8 +1129,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1124
1129
  leafPaint.loadId = image.load(() => {
1125
1130
  ignoreRender(ui, false);
1126
1131
  if (!ui.destroyed) {
1127
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds))
1132
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
1133
+ if (image.hasOpacityPixel)
1134
+ ui.__layout.hitCanvasChanged = true;
1128
1135
  ui.forceUpdate('surface');
1136
+ }
1129
1137
  onLoadSuccess(ui, event);
1130
1138
  }
1131
1139
  leafPaint.loadId = null;
@@ -1179,7 +1187,7 @@ function ignoreRender(ui, value) {
1179
1187
  const { get: get$2, scale, copy: copy$1 } = core.MatrixHelper;
1180
1188
  const { ceil, abs: abs$1 } = Math;
1181
1189
  function createPattern(ui, paint, pixelRatio) {
1182
- let { scaleX, scaleY } = ui.__nowWorld;
1190
+ let { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1183
1191
  const id = scaleX + '-' + scaleY;
1184
1192
  if (paint.patternId !== id && !ui.destroyed) {
1185
1193
  scaleX = abs$1(scaleX);
@@ -1241,7 +1249,7 @@ function createPattern(ui, paint, pixelRatio) {
1241
1249
 
1242
1250
  const { abs } = Math;
1243
1251
  function checkImage(ui, canvas, paint, allowPaint) {
1244
- const { scaleX, scaleY } = ui.__nowWorld;
1252
+ const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1245
1253
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
1246
1254
  return false;
1247
1255
  }
@@ -2146,7 +2154,7 @@ const ExportModule = {
2146
2154
  const scale = options.scale || 1;
2147
2155
  const pixelRatio = options.pixelRatio || 1;
2148
2156
  const screenshot = options.screenshot || leaf.isApp;
2149
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
2157
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
2150
2158
  const needFill = core.FileHelper.isOpaqueImage(filename) || fill, matrix = new core.Matrix();
2151
2159
  if (screenshot) {
2152
2160
  renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
@@ -2157,10 +2165,10 @@ const ExportModule = {
2157
2165
  scaleY = worldTransform.scaleY;
2158
2166
  switch (relative) {
2159
2167
  case 'inner':
2160
- matrix.set(worldTransform).invert();
2168
+ matrix.set(worldTransform);
2161
2169
  break;
2162
2170
  case 'local':
2163
- matrix.set(worldTransform).divide(leaf.localTransform).invert();
2171
+ matrix.set(worldTransform).divide(leaf.localTransform);
2164
2172
  scaleX /= leaf.scaleX;
2165
2173
  scaleY /= leaf.scaleY;
2166
2174
  break;
@@ -2171,7 +2179,7 @@ const ExportModule = {
2171
2179
  case 'page':
2172
2180
  relative = leaf.leafer;
2173
2181
  default:
2174
- matrix.set(worldTransform).divide(leaf.getTransform(relative)).invert();
2182
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
2175
2183
  const l = relative.worldTransform;
2176
2184
  scaleX /= scaleX / l.scaleX;
2177
2185
  scaleY /= scaleY / l.scaleY;
@@ -2180,7 +2188,7 @@ const ExportModule = {
2180
2188
  }
2181
2189
  const { x, y, width, height } = new core.Bounds(renderBounds).scale(scale);
2182
2190
  let canvas = core.Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
2183
- const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
2191
+ const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
2184
2192
  if (slice) {
2185
2193
  leaf = leafer;
2186
2194
  renderOptions.bounds = canvas.bounds;
@@ -2226,6 +2234,44 @@ function addTask(task) {
2226
2234
  });
2227
2235
  }
2228
2236
 
2237
+ const canvas = core.LeaferCanvasBase.prototype;
2238
+ const debug = core.Debug.get('@leafer-ui/export');
2239
+ canvas.export = function (filename, options) {
2240
+ const { quality, blob } = core.FileHelper.getExportOptions(options);
2241
+ if (filename.includes('.')) {
2242
+ return this.saveAs(filename, quality);
2243
+ }
2244
+ else if (blob) {
2245
+ return this.toBlob(filename, quality);
2246
+ }
2247
+ else {
2248
+ return this.toDataURL(filename, quality);
2249
+ }
2250
+ };
2251
+ canvas.toBlob = function (type, quality) {
2252
+ return new Promise((resolve) => {
2253
+ core.Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
2254
+ resolve(blob);
2255
+ }).catch((e) => {
2256
+ debug.error(e);
2257
+ resolve(null);
2258
+ });
2259
+ });
2260
+ };
2261
+ canvas.toDataURL = function (type, quality) {
2262
+ return core.Platform.origin.canvasToDataURL(this.view, type, quality);
2263
+ };
2264
+ canvas.saveAs = function (filename, quality) {
2265
+ return new Promise((resolve) => {
2266
+ core.Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
2267
+ resolve(true);
2268
+ }).catch((e) => {
2269
+ debug.error(e);
2270
+ resolve(false);
2271
+ });
2272
+ });
2273
+ };
2274
+
2229
2275
  Object.assign(draw.TextConvert, TextConvertModule);
2230
2276
  Object.assign(draw.ColorConvert, ColorConvertModule);
2231
2277
  Object.assign(draw.Paint, PaintModule);
package/dist/node.esm.js CHANGED
@@ -74,6 +74,7 @@ function useCanvas(canvasType, power) {
74
74
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURLSync(type, { quality }),
75
75
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
76
76
  canvasSaveAs: (canvas, filename, quality) => canvas.saveAs(filename, { quality }),
77
+ download(_url, _filename) { return undefined; },
77
78
  loadImage
78
79
  };
79
80
  Platform.roundRectPatch = true;
@@ -85,6 +86,7 @@ function useCanvas(canvasType, power) {
85
86
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
86
87
  canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function* () { return canvas.toBuffer(mineType(type), quality); }),
87
88
  canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function* () { return writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
89
+ download(_url, _filename) { return undefined; },
88
90
  loadImage
89
91
  };
90
92
  }
@@ -283,7 +285,7 @@ class LayoutBlockData {
283
285
  }
284
286
 
285
287
  const { updateAllMatrix, updateAllChange } = LeafHelper;
286
- const debug$1 = Debug.get('Layouter');
288
+ const debug$2 = Debug.get('Layouter');
287
289
  class Layouter {
288
290
  constructor(target, userConfig) {
289
291
  this.totalTimes = 0;
@@ -318,7 +320,7 @@ class Layouter {
318
320
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
319
321
  }
320
322
  catch (e) {
321
- debug$1.error(e);
323
+ debug$2.error(e);
322
324
  }
323
325
  this.layoutedBlocks = null;
324
326
  }
@@ -332,9 +334,9 @@ class Layouter {
332
334
  }
333
335
  layoutOnce() {
334
336
  if (this.layouting)
335
- return debug$1.warn('layouting');
337
+ return debug$2.warn('layouting');
336
338
  if (this.times > 3)
337
- return debug$1.warn('layout max times');
339
+ return debug$2.warn('layout max times');
338
340
  this.times++;
339
341
  this.totalTimes++;
340
342
  this.layouting = true;
@@ -438,7 +440,7 @@ class Layouter {
438
440
  }
439
441
  }
440
442
 
441
- const debug = Debug.get('Renderer');
443
+ const debug$1 = Debug.get('Renderer');
442
444
  class Renderer {
443
445
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
444
446
  constructor(target, canvas, userConfig) {
@@ -476,7 +478,7 @@ class Renderer {
476
478
  const { target } = this;
477
479
  this.times = 0;
478
480
  this.totalBounds = new Bounds();
479
- debug.log(target.innerName, '--->');
481
+ debug$1.log(target.innerName, '--->');
480
482
  try {
481
483
  this.emitRender(RenderEvent.START);
482
484
  this.renderOnce(callback);
@@ -485,9 +487,9 @@ class Renderer {
485
487
  }
486
488
  catch (e) {
487
489
  this.rendering = false;
488
- debug.error(e);
490
+ debug$1.error(e);
489
491
  }
490
- debug.log('-------------|');
492
+ debug$1.log('-------------|');
491
493
  }
492
494
  renderAgain() {
493
495
  if (this.rendering) {
@@ -499,9 +501,9 @@ class Renderer {
499
501
  }
500
502
  renderOnce(callback) {
501
503
  if (this.rendering)
502
- return debug.warn('rendering');
504
+ return debug$1.warn('rendering');
503
505
  if (this.times > 3)
504
- return debug.warn('render max times');
506
+ return debug$1.warn('render max times');
505
507
  this.times++;
506
508
  this.totalTimes++;
507
509
  this.rendering = true;
@@ -538,7 +540,7 @@ class Renderer {
538
540
  partRender() {
539
541
  const { canvas, updateBlocks: list } = this;
540
542
  if (!list)
541
- return debug.warn('PartRender: need update attr');
543
+ return debug$1.warn('PartRender: need update attr');
542
544
  this.mergeBlocks();
543
545
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
544
546
  this.clipRender(block); });
@@ -638,7 +640,7 @@ class Renderer {
638
640
  empty = (!leaf.__world.width || !leaf.__world.height);
639
641
  if (empty) {
640
642
  if (!leaf.isLeafer)
641
- debug.tip(leaf.innerName, ': empty');
643
+ debug$1.tip(leaf.innerName, ': empty');
642
644
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
643
645
  }
644
646
  return empty;
@@ -1040,8 +1042,11 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
1040
1042
  }
1041
1043
 
1042
1044
  const { get: get$3, translate } = MatrixHelper;
1045
+ const tempBox = new Bounds();
1043
1046
  function createData(leafPaint, image, paint, box) {
1044
1047
  let { width, height } = image;
1048
+ if (paint.padding)
1049
+ box = tempBox.set(box).shrink(paint.padding);
1045
1050
  const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
1046
1051
  const sameBox = box.width === width && box.height === height;
1047
1052
  if (blendMode)
@@ -1125,8 +1130,11 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1125
1130
  leafPaint.loadId = image.load(() => {
1126
1131
  ignoreRender(ui, false);
1127
1132
  if (!ui.destroyed) {
1128
- if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds))
1133
+ if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
1134
+ if (image.hasOpacityPixel)
1135
+ ui.__layout.hitCanvasChanged = true;
1129
1136
  ui.forceUpdate('surface');
1137
+ }
1130
1138
  onLoadSuccess(ui, event);
1131
1139
  }
1132
1140
  leafPaint.loadId = null;
@@ -1180,7 +1188,7 @@ function ignoreRender(ui, value) {
1180
1188
  const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
1181
1189
  const { ceil, abs: abs$1 } = Math;
1182
1190
  function createPattern(ui, paint, pixelRatio) {
1183
- let { scaleX, scaleY } = ui.__nowWorld;
1191
+ let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1184
1192
  const id = scaleX + '-' + scaleY;
1185
1193
  if (paint.patternId !== id && !ui.destroyed) {
1186
1194
  scaleX = abs$1(scaleX);
@@ -1242,7 +1250,7 @@ function createPattern(ui, paint, pixelRatio) {
1242
1250
 
1243
1251
  const { abs } = Math;
1244
1252
  function checkImage(ui, canvas, paint, allowPaint) {
1245
- const { scaleX, scaleY } = ui.__nowWorld;
1253
+ const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1246
1254
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
1247
1255
  return false;
1248
1256
  }
@@ -2147,7 +2155,7 @@ const ExportModule = {
2147
2155
  const scale = options.scale || 1;
2148
2156
  const pixelRatio = options.pixelRatio || 1;
2149
2157
  const screenshot = options.screenshot || leaf.isApp;
2150
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : undefined) : options.fill;
2158
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
2151
2159
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
2152
2160
  if (screenshot) {
2153
2161
  renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
@@ -2158,10 +2166,10 @@ const ExportModule = {
2158
2166
  scaleY = worldTransform.scaleY;
2159
2167
  switch (relative) {
2160
2168
  case 'inner':
2161
- matrix.set(worldTransform).invert();
2169
+ matrix.set(worldTransform);
2162
2170
  break;
2163
2171
  case 'local':
2164
- matrix.set(worldTransform).divide(leaf.localTransform).invert();
2172
+ matrix.set(worldTransform).divide(leaf.localTransform);
2165
2173
  scaleX /= leaf.scaleX;
2166
2174
  scaleY /= leaf.scaleY;
2167
2175
  break;
@@ -2172,7 +2180,7 @@ const ExportModule = {
2172
2180
  case 'page':
2173
2181
  relative = leaf.leafer;
2174
2182
  default:
2175
- matrix.set(worldTransform).divide(leaf.getTransform(relative)).invert();
2183
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
2176
2184
  const l = relative.worldTransform;
2177
2185
  scaleX /= scaleX / l.scaleX;
2178
2186
  scaleY /= scaleY / l.scaleY;
@@ -2181,7 +2189,7 @@ const ExportModule = {
2181
2189
  }
2182
2190
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
2183
2191
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
2184
- const renderOptions = { matrix: matrix.scale(scale).translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
2192
+ const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
2185
2193
  if (slice) {
2186
2194
  leaf = leafer;
2187
2195
  renderOptions.bounds = canvas.bounds;
@@ -2227,6 +2235,44 @@ function addTask(task) {
2227
2235
  });
2228
2236
  }
2229
2237
 
2238
+ const canvas = LeaferCanvasBase.prototype;
2239
+ const debug = Debug.get('@leafer-ui/export');
2240
+ canvas.export = function (filename, options) {
2241
+ const { quality, blob } = FileHelper.getExportOptions(options);
2242
+ if (filename.includes('.')) {
2243
+ return this.saveAs(filename, quality);
2244
+ }
2245
+ else if (blob) {
2246
+ return this.toBlob(filename, quality);
2247
+ }
2248
+ else {
2249
+ return this.toDataURL(filename, quality);
2250
+ }
2251
+ };
2252
+ canvas.toBlob = function (type, quality) {
2253
+ return new Promise((resolve) => {
2254
+ Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
2255
+ resolve(blob);
2256
+ }).catch((e) => {
2257
+ debug.error(e);
2258
+ resolve(null);
2259
+ });
2260
+ });
2261
+ };
2262
+ canvas.toDataURL = function (type, quality) {
2263
+ return Platform.origin.canvasToDataURL(this.view, type, quality);
2264
+ };
2265
+ canvas.saveAs = function (filename, quality) {
2266
+ return new Promise((resolve) => {
2267
+ Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
2268
+ resolve(true);
2269
+ }).catch((e) => {
2270
+ debug.error(e);
2271
+ resolve(false);
2272
+ });
2273
+ });
2274
+ };
2275
+
2230
2276
  Object.assign(TextConvert, TextConvertModule);
2231
2277
  Object.assign(ColorConvert, ColorConvertModule);
2232
2278
  Object.assign(Paint, PaintModule);
@@ -1 +1 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,FileHelper as o,LeafList as a,DataHelper as r,RenderEvent as d,ChildEvent as l,WatchEvent as c,PropertyEvent as h,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as p,Debug as g,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,ImageEvent as k,PointHelper as E,Direction4 as S,TwoPointBoundsHelper as L,TaskProcessor as A,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as T}from"fs";import{PaintImage as O,ColorConvert as M,PaintGradient as C,Export as I,Group as D,TextConvert as F,Paint as P,Effect as Y}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function U(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(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(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class X 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:N,fileType:G}=o;function V(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}),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(N(e),i),canvasToBolb:(t,e,i)=>U(this,void 0,void 0,(function*(){return t.toBuffer(N(e),i)})),canvasSaveAs:(t,e,i)=>U(this,void 0,void 0,(function*(){return T(e,t.toBuffer(N(G(e)),i))})),loadImage:n}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new X(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 a;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 a,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===l.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.CHANGE,this.__onAttrChange,this),t.on_([l.ADD,l.REMOVE],this.__onChildEvent,this),t.on_(c.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:q,updateBounds:z,updateAllWorldOpacity:H}=u,{pushAllChildBranch:Q,pushAllParent:Z}=f;const{worldBounds:$}=p,J={x:0,y:0,width:1e5,height:1e5};class K{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(J):this.afterBounds.setListWithFn(t,$),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:tt,updateAllChange:et}=u,it=g.get("Layouter");class nt{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){it.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?it.warn("layouting"):this.times>3?it.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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:o,AFTER:a}=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?(q(t,!0),e.add(t),t.isBranch&&Q(t,e),Z(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Z(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&&H(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(o,r,this.times)),i.emitEvent(new y(a,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,o=this.getBlocks(new a(e));e.emitEvent(new y(i,o,this.times)),nt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(n,o,this.times)),e.emitEvent(new y(s,o,this.times)),this.addBlocks(o),m.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new K([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new K(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_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=g.get("Renderer");class ot{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 _,st.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,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.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 st.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),o=new _(n);i.save(),s&&!g.showRepaint?i.clear():(n.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),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),g.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),g.showHitView&&this.renderHitView(n),g.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||st.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)}}function at(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function rt(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?ct(t,!0,e,i):lt(e,i);break;case"inside":dt("inside",t,s,e,i);break;case"outside":dt("outside",t,s,e,i)}}function dt(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ct(e,!0,n,r):lt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",at(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 lt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;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,o)}function ct(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?lt(i,n):n.stroke(),n.restoreBlendMode()):e?lt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new nt(t,e),renderer:(t,e,i)=>new ot(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=nt.fullLayout;const{getSpread:ht,getOuterOf:ut,getByMove:ft,getIntersectData:_t}=B;let pt;function gt(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:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:M.string(a,r)};case"image":return O.image(i,t,e,n,!pt||!pt[e.url]);case"linear":return C.linearGradient(e,n);case"radial":return C.radialGradient(e,n);case"angular":return C.conicGradient(e,n);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}const wt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),pt=O.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=gt(t,o[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?at(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&O.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?at(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?at(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?at(e,i):s?i.fill(s):i.fill())},fillText:at,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)rt(t,e,i);else switch(o){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 o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)rt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ct(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ct(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ct(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:rt,drawTextStroke:lt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=_t(n?ht(e.bounds,n*l,n*c):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=ut(s,a),o=ft(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let yt={};const{get:mt,rotateOfOuter:vt,translate:xt,scaleOfOuter:bt,scale:Bt,rotate:Rt}=R;function kt(t,e,i,n,s,o){const a=mt(),r=o&&180!==o,d=i.width/(r?s:n),l=i.height/(r?n:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=i.x+(i.width-n*c)/2,u=i.y+(i.height-s*c)/2;xt(a,h,u),Bt(a,c),o&&vt(a,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=c,t.transform=a}function Et(t,e,i,n,s,o,a){const r=mt();xt(r,e.x,e.y),(i||n)&&xt(r,i,n),s&&(Bt(r,s,o),t.scaleX=r.a,t.scaleY=r.d),a&&Rt(r,a),t.transform=r}function St(t,e,i,n,s,o,a,r,d){const l=mt();if(d)switch(Rt(l,d),d){case 90:xt(l,n,0);break;case 180:xt(l,i,n);break;case 270:xt(l,0,i)}yt.x=e.x,yt.y=e.y,(s||o)&&(yt.x+=s,yt.y+=o),xt(l,yt.x,yt.y),a&&(bt(l,yt,a,r),t.scaleX=a,t.scaleY=r),t.transform=l}const{get:Lt,translate:At}=R;function Wt(t,e,i,n){let{width:s,height:o}=e;const{opacity:a,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=i,_=n.width===s&&n.height===o;u&&(t.blendMode=u);const p=t.data={mode:r};let g,w,y,m;switch(d&&(g=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/o):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":_||(s=n.width,o=n.height);break;case"clip":(d||y||h)&&Et(p,n,g,w,y,m,h);break;case"repeat":(!_||y||h)&&St(p,n,s,o,g,w,y,m,h),f||(p.repeat="repeat");break;default:_&&!h||kt(p,r,n,s,o,h)}p.transform||(n.x||n.y)&&(p.transform=Lt(),At(p.transform,n.x,n.y)),p.width=s,p.height=o,a&&(p.opacity=a),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Tt,Ot=new _;const{isSame:Mt}=B;function Ct(t,e,i,n,s,o){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||Wt(s,n,i,o),!0}function It(t,e){Pt(t,k.LOAD,e)}function Dt(t,e){Pt(t,k.LOADED,e)}function Ft(t,e,i){e.error=i,t.forceUpdate("surface"),Pt(t,k.ERROR,e)}function Pt(t,e,i){t.hasEvent(e)&&t.emitEvent(new k(e,i))}function Yt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ut,scale:Xt,copy:Nt}=R,{ceil:Gt,abs:Vt}=Math;function jt(t,i,n){let{scaleX:s,scaleY:o}=t.__nowWorld;const a=s+"-"+o;if(i.patternId===a||t.destroyed)return!1;{s=Vt(s),o=Vt(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Ut(),Nt(l,p),Xt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!g&&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,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Ut(),p&&Nt(l,p)),Xt(l,1/s,1/o));const m=t.getCanvas(Gt(c)||1,Gt(h)||1,_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}const{abs:qt}=Math;const zt={image:function(t,e,i,n,s){let o,a;const r=v.get(i);return Tt&&i===Tt.paint&&Mt(n,Tt.boxBounds)?o=Tt.leafPaint:(o={type:i.type,image:r},Tt=r.use>1?{leafPaint:o,paint:i,boxBounds:Ot.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ct(t,e,i,r,o,n),s&&(It(t,a),Dt(t,a))):r.error?s&&Ft(t,a,r.error):(Yt(t,!0),s&&It(t,a),o.loadId=r.load((()=>{Yt(t,!1),t.destroyed||(Ct(t,e,i,r,o,n)&&t.forceUpdate("surface"),Dt(t,a)),o.loadId=null}),(e=>{Yt(t,!1),Ft(t,a,e),o.loadId=null}))),o},createData:Wt,fillOrFitMode:kt,clipMode:Et,repeatMode:St,createPattern:jt,checkImage:function(t,i,n,s){const{scaleX:o,scaleY:a}=t.__nowWorld;if(n.data&&n.patternId!==o+"-"+a){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=qt(o)*i.pixelRatio,n*=qt(a)*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||I.running?jt(t,n,i.pixelRatio):n.patternTask||(n.patternTask=v.patternTasker.add((()=>U(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&jt(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,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,v.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null}},Ht={x:.5,y:0},Qt={x:.5,y:1};function Zt(t,e,i){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],t.addColorStop(n.offset,M.string(n.color,i))}const{set:$t,getAngle:Jt,getDistance:Kt}=E,{get:te,rotateOfOuter:ee,scaleOfOuter:ie}=R,ne={x:.5,y:.5},se={x:.5,y:1},oe={},ae={};const{set:re,getAngle:de,getDistance:le}=E,{get:ce,rotateOfOuter:he,scaleOfOuter:ue}=R,fe={x:.5,y:.5},_e={x:.5,y:1},pe={},ge={};const we={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;n||(n=Ht),s||(s=Qt);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);Zt(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;n||(n=ne),s||(s=se);const{x:l,y:c,width:h,height:u}=i;let f;$t(oe,l+n.x*h,c+n.y*u),$t(ae,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=te(),ie(f,oe,h/u*(d||1),1),ee(f,oe,Jt(oe,ae)+90));const _=e.canvas.createRadialGradient(oe.x,oe.y,0,oe.x,oe.y,Kt(oe,ae));Zt(_,t.stops,a);const p={type:o,style:_,transform:f};return r&&(p.blendMode=r),p},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;n||(n=fe),s||(s=_e);const{x:l,y:c,width:h,height:u}=i;re(pe,l+n.x*h,c+n.y*u),re(ge,l+s.x*h,c+s.y*u);const f=ce(),_=de(pe,ge);e.conicGradientRotate90?(ue(f,pe,h/u*(d||1),1),he(f,pe,_+90)):(ue(f,pe,1,h/u*(d||1)),he(f,pe,_));const p=e.conicGradientSupport?e.canvas.createConicGradient(0,pe.x,pe.y):e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,le(pe,ge));Zt(p,t.stops,a);const g={type:o,style:p,transform:f};return r&&(g.blendMode=r),g}},{copy:ye,toOffsetOutBounds:me}=B,ve={},xe={};function be(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ye(ve,t.bounds),ve.x+=i.x-a.x,ve.y+=i.y-a.y,n){const{matrix:t}=s;ve.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),ve.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),ve.width*=n,ve.height*=n}t.copyWorld(s.canvas,t.bounds,ve)}else n&&(ye(ve,i),ve.x-=i.width/2*(n-1),ve.y-=i.height/2*(n-1),ve.width*=n,ve.height*=n),t.copyWorld(s.canvas,a,n?ve:i)}const{toOffsetOutBounds:Be}=B,Re={};const ke={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;me(l,xe),r.forEach(((r,p)=>{f.setWorldShadow(xe.offsetX+r.x*h,xe.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,be(f,xe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Be(l,Re),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Re.offsetX+r.x*h,Re.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,be(f,Re,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),_&&p<_&&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:Ee}=p;function Se(t,e,i,n,s,o){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),Ae(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ae(t,i,n,o);break;case"path":i.restore()}}function Le(t){return t.getSameCanvas(!1,!0)}function Ae(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}D.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Se(this,a,t,s,n,o),n=s=null),"path"===i.__.maskType?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Le(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Le(t)),s||(s=Le(t)),i.__render(n,e)),"clipping"!==i.__.maskType)||Ee(i,e)||i.__render(s||t,e);Se(this,a,t,s,n,o)};const We=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Te=We+"_#~&*+\\=|≮≯≈≠=…",Oe=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 Me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ce=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ie=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),De=Me(We),Fe=Me(Te),Pe=Me("- —/~|┆·");var Ye;!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"}(Ye||(Ye={}));const{Letter:Ue,Single:Xe,Before:Ne,After:Ge,Symbol:Ve,Break:je}=Ye;function qe(t){return Ce[t]?Ue:Pe[t]?je:Ie[t]?Ne:De[t]?Ge:Fe[t]?Ve:Oe.test(t)?Xe:Ue}const ze={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function He(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:Qe}=ze,{Letter:Ze,Single:$e,Before:Je,After:Ke,Symbol:ti,Break:ei}=Ye;let ii,ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,_i,pi,gi,wi,yi=[];function mi(t,e){ci&&!li&&(li=ci),ii.data.push({char:t,width:e}),si+=e}function vi(){oi+=si,ii.width=si,ni.words.push(ii),ii={data:[]},si=0}function xi(){pi&&(gi.paraNumber++,ni.paraStart=!0,pi=!1),ci&&(ni.startCharSize=li,ni.endCharSize=ci,li=0),ni.width=oi,wi.width&&Qe(ni),yi.push(ni),ni={words:[]},oi=0}const bi=0,Bi=1,Ri=2;const{top:ki,right:Ei,bottom:Si,left:Li}=S;function Ai(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 Wi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o&&(n=l[Li],o-=l[Ei]+l[Li]),a&&(s=l[ki],a-=l[ki]+l[Si]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){gi=t,yi=t.rows,wi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=wi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;pi=!0,ui=null,li=di=ci=si=oi=0,ii={data:[]},ni={words:[]};for(let n=0,l=i.length;n<l;n++)ri=i[n],"\n"===ri?(si&&vi(),ni.paraEnd=!0,xi(),pi=!0):(hi=qe(ri),hi===Ze&&"none"!==a&&(ri=He(ri,a,!si)),di=r.measureText(ri).width,s&&(s<0&&(ci=di),di+=s),fi=hi===$e&&(ui===$e||ui===Ze)||ui===$e&&hi!==Ke,_i=!(hi!==Je&&hi!==$e||ui!==ti&&ui!==Ke),ai=pi&&o?d-o:d,t&&d&&oi+si+di>ai&&(e?(si&&vi(),xi()):(_i||(_i=hi===Ze&&ui==Ke),fi||_i||hi===ei||hi===Je||hi===$e||si+di>ai?(si&&vi(),xi()):xi()))," "===ri&&!0!==pi&&oi+si===0||(hi===ei?(" "===ri&&si&&vi(),mi(ri,di),vi()):fi||_i?(si&&vi(),mi(ri,di)):mi(ri,di)),ui=hi);si&&vi(),oi&&xi(),yi.length>0&&(yi[yi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{gi.paraNumber++,yi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Ai(e,"x",t[Li]);break;case"right":Ai(e,"x",-t[Ei])}if(!s)switch(i.verticalAlign){case"top":Ai(e,"y",t[ki]);break;case"bottom":Ai(e,"y",-t[Si])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:_,y:p,width:g,height:w}=n,y=s*i.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":p+=(w-y)/2;break;case"bottom":p+=w-y}m+=p;for(let o=0,l=i.length;o<l;o++){switch(h=i[o],h.x=_,d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&o>0&&(m+=c),h.y=m,m+=s,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=y}(c,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?bi:l>.01?Bi:Ri,t.isOverflow&&!r&&(t.textMode=!0),h===Ri?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Bi?(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&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,i,o),c.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:o}=i;if(n.splice(s),"hide"!==o){let t,a;"ellipsis"===o&&(o="...");const r=e.canvas.measureText(o).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],a=t.x+t.width,!(n===i&&a<d));n--){if(a<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,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}}(c,i),c}};const Ti={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:Oi,addPoint:Mi,toBounds:Ci}=L;const Ii={export(t,e,i){return this.running=!0,function(t){Di||(Di=new A);return new Promise((e=>{Di.add((()=>U(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((a=>{const r=t=>{s(t),a(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>U(this,void 0,void 0,(function*(){i=o.getExportOptions(i);let s,a,l=1,c=1;const{worldTransform:h,isLeafer:u,isFrame:f}=t,{slice:p,trim:g,onCanvas:w}=i,y=i.scale||1,m=i.pixelRatio||1,v=i.screenshot||t.isApp,x=u&&v?void 0===i.fill?t.fill:void 0:i.fill,b=o.isOpaqueImage(e)||x,B=new W;if(v)s=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{let e=i.relative||(u?"inner":"local");switch(l=h.scaleX,c=h.scaleY,e){case"inner":B.set(h).invert();break;case"local":B.set(h).divide(t.localTransform).invert(),l/=t.scaleX,c/=t.scaleY;break;case"world":l=1,c=1;break;case"page":e=t.leafer;default:B.set(h).divide(t.getTransform(e)).invert();const i=e.worldTransform;l/=l/i.scaleX,c/=c/i.scaleY}s=t.getBounds("render",e)}const{x:R,y:k,width:E,height:S}=new _(s).scale(y);let L=n.canvas({width:Math.round(E),height:Math.round(S),pixelRatio:m});const A={matrix:B.scale(y).translate(-R,-k).withScale(1/l*y,1/c*y)};if(p&&(t=d,A.bounds=L.bounds),L.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(L,A),t.fill=e}else t.__render(L,A);if(L.restore(),g){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Mi(a,s,o):Oi(a={},s,o)),r++;const d=new _;return Ci(a,d),d.scale(1/t.pixelRatio).ceil()}(L);const t=L,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:m};L=n.canvas(s),L.copyWorld(t,a,s)}b&&L.fillWorld(L.bounds,x||"#FFFFFF","destination-over"),w&&w(L);const T="canvas"===e?L:yield L.export(e,i);r({data:T,width:L.pixelWidth,height:L.pixelHeight,renderBounds:s,trimBounds:a})})))):r({data:!1})}))))}};let Di;Object.assign(F,Wi),Object.assign(M,Ti),Object.assign(P,wt),Object.assign(O,zt),Object.assign(C,we),Object.assign(Y,ke),Object.assign(I,Ii);export{nt as Layouter,X as LeaferCanvas,ot as Renderer,j as Watcher,V as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,FileHelper as o,LeafList as a,DataHelper as r,RenderEvent as d,ChildEvent as l,WatchEvent as c,PropertyEvent as h,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as p,Debug as g,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,ImageEvent as k,PointHelper as E,Direction4 as S,TwoPointBoundsHelper as L,TaskProcessor as A,Matrix as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as T}from"fs";import{PaintImage as O,ColorConvert as M,PaintGradient as C,Export as I,Group as D,TextConvert as F,Paint as P,Effect as Y}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function U(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(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(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class X extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,n(this.context.__proto__))}__createView(){this.view=e.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:N,fileType:G}=o;function q(t,n){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:i}=n;e.origin={createCanvas:(e,n,i)=>new t(e,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:i},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:i}=n;e.origin={createCanvas:(e,n,i)=>new t(e,n,i),canvasToDataURL:(t,e,n)=>t.toDataURL(N(e),n),canvasToBolb:(t,e,n)=>U(this,void 0,void 0,(function*(){return t.toBuffer(N(e),n)})),canvasSaveAs:(t,e,n)=>U(this,void 0,void 0,(function*(){return T(e,t.toBuffer(N(G(e)),n))})),download(t,e){},loadImage:i}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=i.canvas()}}Object.assign(i,{canvas:(t,e)=>new X(t,e),image:t=>new s(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class V{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new a;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 a,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===l.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new a,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(h.CHANGE,this.__onAttrChange,this),t.on_([l.ADD,l.REMOVE],this.__onChildEvent,this),t.on_(c.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:H}=u,{pushAllChildBranch:Q,pushAllParent:Z}=f;const{worldBounds:$}=p,J={x:0,y:0,width:1e5,height:1e5};class K{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new a(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(J):this.afterBounds.setListWithFn(t,$),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:tt,updateAllChange:et}=u,nt=g.get("Layouter");class it{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){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=y,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new y(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(j(t,!0),e.add(t),t.isBranch&&Q(t,e),Z(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Z(t,e)))}))}(i,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||z(i[t])}z(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&H(t),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new y(o,r,this.times)),n.emitEvent(new y(a,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:n,LAYOUT:i,AFTER:s}=y,o=this.getBlocks(new a(e));e.emitEvent(new y(n,o,this.times)),it.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new y(i,o,this.times)),e.emitEvent(new y(s,o,this.times)),this.addBlocks(o),m.end(t)}static fullLayout(t){tt(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),et(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new K([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new K(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_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const st=g.get("Renderer");class ot{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=r.default(n,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 _,st.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,st.error(t)}st.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return st.warn("rendering");if(this.times>3)return st.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 st.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:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new _(i);n.save(),s&&!g.showRepaint?n.clear():(i.spread(1+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.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,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),g.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),g.showHitView&&this.renderHitView(i),g.showBoundsView&&this.renderBoundsView(i),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:n}=t.old;new _(0,0,e,n).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||st.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new d(t,this.times,e,n))}__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)}}function at(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function rt(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?ct(t,!0,e,n):lt(e,n);break;case"inside":dt("inside",t,s,e,n);break;case"outside":dt("outside",t,s,e,n)}}function dt(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?ct(e,!0,i,r):lt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",at(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function lt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function ct(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?lt(n,i):i.stroke(),i.restoreBlendMode()):e?lt(n,i):i.stroke())}Object.assign(i,{watcher:(t,e)=>new V(t,e),layouter:(t,e)=>new it(t,e),renderer:(t,e,n)=>new ot(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=it.fullLayout;const{getSpread:ht,getOuterOf:ut,getByMove:ft,getIntersectData:_t}=B;let pt;function gt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:M.string(a,r)};case"image":return O.image(n,t,e,i,!pt||!pt[e.url]);case"linear":return C.linearGradient(e,i);case"radial":return C.radialGradient(e,i);case"angular":return C.conicGradient(e,i);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}const wt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),pt=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=gt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?at(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&O.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?at(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?at(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?at(e,n):s?n.fill(s):n.fill())},fillText:at,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)rt(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)rt(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),ct(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),ct(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),ct(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:rt,drawTextStroke:lt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=_t(i?ht(e.bounds,i*l,i*c):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ut(s,a),o=ft(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let yt={};const{get:mt,rotateOfOuter:vt,translate:xt,scaleOfOuter:bt,scale:Bt,rotate:Rt}=R;function kt(t,e,n,i,s,o){const a=mt(),r=o&&180!==o,d=n.width/(r?s:i),l=n.height/(r?i:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-i*c)/2,u=n.y+(n.height-s*c)/2;xt(a,h,u),Bt(a,c),o&&vt(a,{x:n.x+n.width/2,y:n.y+n.height/2},o),t.scaleX=t.scaleY=c,t.transform=a}function Et(t,e,n,i,s,o,a){const r=mt();xt(r,e.x,e.y),(n||i)&&xt(r,n,i),s&&(Bt(r,s,o),t.scaleX=r.a,t.scaleY=r.d),a&&Rt(r,a),t.transform=r}function St(t,e,n,i,s,o,a,r,d){const l=mt();if(d)switch(Rt(l,d),d){case 90:xt(l,i,0);break;case 180:xt(l,n,i);break;case 270:xt(l,0,n)}yt.x=e.x,yt.y=e.y,(s||o)&&(yt.x+=s,yt.y+=o),xt(l,yt.x,yt.y),a&&(bt(l,yt,a,r),t.scaleX=a,t.scaleY=r),t.transform=l}const{get:Lt,translate:At}=R,Wt=new _;function Tt(t,e,n,i){let{width:s,height:o}=e;n.padding&&(i=Wt.set(i).shrink(n.padding));const{opacity:a,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,_=i.width===s&&i.height===o;u&&(t.blendMode=u);const p=t.data={mode:r};let g,w,y,m;switch(d&&(g=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/o):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":_||(s=i.width,o=i.height);break;case"clip":(d||y||h)&&Et(p,i,g,w,y,m,h);break;case"repeat":(!_||y||h)&&St(p,i,s,o,g,w,y,m,h),f||(p.repeat="repeat");break;default:_&&!h||kt(p,r,i,s,o,h)}p.transform||(i.x||i.y)&&(p.transform=Lt(),At(p.transform,i.x,i.y)),p.width=s,p.height=o,a&&(p.opacity=a),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Ot,Mt=new _;const{isSame:Ct}=B;function It(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Tt(s,i,n,o),!0}function Dt(t,e){Yt(t,k.LOAD,e)}function Ft(t,e){Yt(t,k.LOADED,e)}function Pt(t,e,n){e.error=n,t.forceUpdate("surface"),Yt(t,k.ERROR,e)}function Yt(t,e,n){t.hasEvent(e)&&t.emitEvent(new k(e,n))}function Ut(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Xt,scale:Nt,copy:Gt}=R,{ceil:qt,abs:Vt}=Math;function jt(t,n,i){let{scaleX:s,scaleY:o}=v.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(n.patternId===a||t.destroyed)return!1;{s=Vt(s),o=Vt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Xt(),Gt(l,p),Nt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&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,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Xt(),p&&Gt(l,p)),Nt(l,1/s,1/o));const m=t.getCanvas(qt(c)||1,qt(h)||1,_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}const{abs:zt}=Math;const Ht={image:function(t,e,n,i,s){let o,a;const r=v.get(n);return Ot&&n===Ot.paint&&Ct(i,Ot.boxBounds)?o=Ot.leafPaint:(o={type:n.type,image:r},Ot=r.use>1?{leafPaint:o,paint:n,boxBounds:Mt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(It(t,e,n,r,o,i),s&&(Dt(t,a),Ft(t,a))):r.error?s&&Pt(t,a,r.error):(Ut(t,!0),s&&Dt(t,a),o.loadId=r.load((()=>{Ut(t,!1),t.destroyed||(It(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ft(t,a)),o.loadId=null}),(e=>{Ut(t,!1),Pt(t,a,e),o.loadId=null}))),o},createData:Tt,fillOrFitMode:kt,clipMode:Et,repeatMode:St,createPattern:jt,checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=v.patternLocked?t.__world:t.__nowWorld;if(i.data&&i.patternId!==o+"-"+a){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=zt(o)*n.pixelRatio,i*=zt(a)*n.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>e.image.maxCacheSize}return s?(n.save(),n.clip(),i.blendMode&&(n.blendMode=i.blendMode),r.opacity&&(n.opacity*=r.opacity),r.transform&&n.transform(r.transform),n.drawImage(i.image.view,0,0,r.width,r.height),n.restore(),!0):(!i.style||I.running?jt(t,i,n.pixelRatio):i.patternTask||(i.patternTask=v.patternTasker.add((()=>U(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&jt(t,i,n.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,v.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null}},Qt={x:.5,y:0},Zt={x:.5,y:1};function $t(t,e,n){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],t.addColorStop(i.offset,M.string(i.color,n))}const{set:Jt,getAngle:Kt,getDistance:te}=E,{get:ee,rotateOfOuter:ne,scaleOfOuter:ie}=R,se={x:.5,y:.5},oe={x:.5,y:1},ae={},re={};const{set:de,getAngle:le,getDistance:ce}=E,{get:he,rotateOfOuter:ue,scaleOfOuter:fe}=R,_e={x:.5,y:.5},pe={x:.5,y:1},ge={},we={};const ye={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;i||(i=Qt),s||(s=Zt);const d=e.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);$t(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;i||(i=se),s||(s=oe);const{x:l,y:c,width:h,height:u}=n;let f;Jt(ae,l+i.x*h,c+i.y*u),Jt(re,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=ee(),ie(f,ae,h/u*(d||1),1),ne(f,ae,Kt(ae,re)+90));const _=e.canvas.createRadialGradient(ae.x,ae.y,0,ae.x,ae.y,te(ae,re));$t(_,t.stops,a);const p={type:o,style:_,transform:f};return r&&(p.blendMode=r),p},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;i||(i=_e),s||(s=pe);const{x:l,y:c,width:h,height:u}=n;de(ge,l+i.x*h,c+i.y*u),de(we,l+s.x*h,c+s.y*u);const f=he(),_=le(ge,we);e.conicGradientRotate90?(fe(f,ge,h/u*(d||1),1),ue(f,ge,_+90)):(fe(f,ge,1,h/u*(d||1)),ue(f,ge,_));const p=e.conicGradientSupport?e.canvas.createConicGradient(0,ge.x,ge.y):e.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,ce(ge,we));$t(p,t.stops,a);const g={type:o,style:p,transform:f};return r&&(g.blendMode=r),g}},{copy:me,toOffsetOutBounds:ve}=B,xe={},be={};function Be(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(me(xe,t.bounds),xe.x+=n.x-a.x,xe.y+=n.y-a.y,i){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),xe.width*=i,xe.height*=i}t.copyWorld(s.canvas,t.bounds,xe)}else i&&(me(xe,n),xe.x-=n.width/2*(i-1),xe.y-=n.height/2*(i-1),xe.width*=i,xe.height*=i),t.copyWorld(s.canvas,a,i?xe:n)}const{toOffsetOutBounds:Re}=B,ke={};const Ee={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;ve(l,be),r.forEach(((r,p)=>{f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;Re(l,ke),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(ke.offsetX+r.x*h,ke.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,ke,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&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:Se}=p;function Le(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),We(t,e,n,1)}(t,n,i,s);break;case"opacity-path":We(t,n,i,o);break;case"path":n.restore()}}function Ae(t){return t.getSameCanvas(!1,!0)}function We(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}D.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(a&&(Le(this,a,t,s,i,o),i=s=null),"path"===n.__.maskType?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ae(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Ae(t)),s||(s=Ae(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||Se(n,e)||n.__render(s||t,e);Le(this,a,t,s,i,o)};const Te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Oe=Te+"_#~&*+\\=|≮≯≈≠=…",Me=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 Ce(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ie=Ce("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),De=Ce("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Fe=Ce(Te),Pe=Ce(Oe),Ye=Ce("- —/~|┆·");var Ue;!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"}(Ue||(Ue={}));const{Letter:Xe,Single:Ne,Before:Ge,After:qe,Symbol:Ve,Break:je}=Ue;function ze(t){return Ie[t]?Xe:Ye[t]?je:De[t]?Ge:Fe[t]?qe:Pe[t]?Ve:Me.test(t)?Ne:Xe}const He={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function Qe(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:Ze}=He,{Letter:$e,Single:Je,Before:Ke,After:tn,Symbol:en,Break:nn}=Ue;let sn,on,an,rn,dn,ln,cn,hn,un,fn,_n,pn,gn,wn,yn,mn,vn=[];function xn(t,e){un&&!hn&&(hn=un),sn.data.push({char:t,width:e}),an+=e}function bn(){rn+=an,sn.width=an,on.words.push(sn),sn={data:[]},an=0}function Bn(){wn&&(yn.paraNumber++,on.paraStart=!0,wn=!1),un&&(on.startCharSize=hn,on.endCharSize=un,hn=0),on.width=rn,mn.width&&Ze(on),vn.push(on),on={words:[]},rn=0}const Rn=0,kn=1,En=2;const{top:Sn,right:Ln,bottom:An,left:Wn}=S;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 On={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o&&(i=l[Wn],o-=l[Ln]+l[Wn]),a&&(s=l[Sn],a-=l[Sn]+l[An]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){yn=t,vn=t.rows,mn=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=mn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;wn=!0,_n=null,hn=cn=un=an=rn=0,sn={data:[]},on={words:[]};for(let i=0,l=n.length;i<l;i++)ln=n[i],"\n"===ln?(an&&bn(),on.paraEnd=!0,Bn(),wn=!0):(fn=ze(ln),fn===$e&&"none"!==a&&(ln=Qe(ln,a,!an)),cn=r.measureText(ln).width,s&&(s<0&&(un=cn),cn+=s),pn=fn===Je&&(_n===Je||_n===$e)||_n===Je&&fn!==tn,gn=!(fn!==Ke&&fn!==Je||_n!==en&&_n!==tn),dn=wn&&o?d-o:d,t&&d&&rn+an+cn>dn&&(e?(an&&bn(),Bn()):(gn||(gn=fn===$e&&_n==tn),pn||gn||fn===nn||fn===Ke||fn===Je||an+cn>dn?(an&&bn(),Bn()):Bn()))," "===ln&&!0!==wn&&rn+an===0||(fn===nn?(" "===ln&&an&&bn(),xn(ln,cn),bn()):pn||gn?(an&&bn(),xn(ln,cn)):xn(ln,cn)),_n=fn);an&&bn(),rn&&Bn(),vn.length>0&&(vn[vn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{yn.paraNumber++,vn.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Tn(e,"x",t[Wn]);break;case"right":Tn(e,"x",-t[Ln])}if(!s)switch(n.verticalAlign){case"top":Tn(e,"y",t[Sn]);break;case"bottom":Tn(e,"y",-t[An])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:_,y:p,width:g,height:w}=i,y=s*n.length+(c?c*(t.paraNumber-1):0),m=o;if(r&&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 o=0,l=n.length;o<l;o++){switch(h=n[o],h.x=_,d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&o>0&&(m+=c),h.y=m,m+=s,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=y}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Rn:l>.01?kn:En,t.isOverflow&&!r&&(t.textMode=!0),h===En?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===kn?(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)}))}(c,n,o),c.overflow&&function(t,n){const{rows:i,overflow:s}=t;let{textOverflow:o}=n;if(i.splice(s),"hide"!==o){let t,a;"ellipsis"===o&&(o="...");const r=e.canvas.measureText(o).width,d=n.x+n.width-r;("none"===n.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],a=t.x+t.width,!(i===n&&a<d));i--){if(a<d&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Mn={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:Cn,addPoint:In,toBounds:Dn}=L;const Fn={export(t,e,n){return this.running=!0,function(t){Pn||(Pn=new A);return new Promise((e=>{Pn.add((()=>U(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((a=>{const r=t=>{s(t),a(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>U(this,void 0,void 0,(function*(){n=o.getExportOptions(n);let s,a,l=1,c=1;const{worldTransform:h,isLeafer:u,isFrame:f}=t,{slice:p,trim:g,onCanvas:w}=n,y=n.scale||1,m=n.pixelRatio||1,v=n.screenshot||t.isApp,x=u&&v&&void 0===n.fill?t.fill:n.fill,b=o.isOpaqueImage(e)||x,B=new W;if(v)s=!0===v?u?d.canvas.bounds:t.worldRenderBounds:v;else{let e=n.relative||(u?"inner":"local");switch(l=h.scaleX,c=h.scaleY,e){case"inner":B.set(h);break;case"local":B.set(h).divide(t.localTransform),l/=t.scaleX,c/=t.scaleY;break;case"world":l=1,c=1;break;case"page":e=t.leafer;default:B.set(h).divide(t.getTransform(e));const n=e.worldTransform;l/=l/n.scaleX,c/=c/n.scaleY}s=t.getBounds("render",e)}const{x:R,y:k,width:E,height:S}=new _(s).scale(y);let L=i.canvas({width:Math.round(E),height:Math.round(S),pixelRatio:m});const A={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/l*y,1/c*y)};if(p&&(t=d,A.bounds=L.bounds),L.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(L,A),t.fill=e}else t.__render(L,A);if(L.restore(),g){a=function(t){const{width:e,height:n}=t.view,{data:i}=t.context.getImageData(0,0,e,n);let s,o,a,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(s=r%e,o=(r-s)/e,a?In(a,s,o):Cn(a={},s,o)),r++;const d=new _;return Dn(a,d),d.scale(1/t.pixelRatio).ceil()}(L);const t=L,{width:e,height:n}=a,s={x:0,y:0,width:e,height:n,pixelRatio:m};L=i.canvas(s),L.copyWorld(t,a,s)}b&&L.fillWorld(L.bounds,x||"#FFFFFF","destination-over"),w&&w(L);const T="canvas"===e?L:yield L.export(e,n);r({data:T,width:L.pixelWidth,height:L.pixelHeight,renderBounds:s,trimBounds:a})})))):r({data:!1})}))))}};let Pn;const Yn=t.prototype,Un=g.get("@leafer-ui/export");Yn.export=function(t,e){const{quality:n,blob:i}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):i?this.toBlob(t,n):this.toDataURL(t,n)},Yn.toBlob=function(t,n){return new Promise((i=>{e.origin.canvasToBolb(this.view,t,n).then((t=>{i(t)})).catch((t=>{Un.error(t),i(null)}))}))},Yn.toDataURL=function(t,n){return e.origin.canvasToDataURL(this.view,t,n)},Yn.saveAs=function(t,n){return new Promise((i=>{e.origin.canvasSaveAs(this.view,t,n).then((()=>{i(!0)})).catch((t=>{Un.error(t),i(!1)}))}))},Object.assign(F,On),Object.assign(M,Mn),Object.assign(P,wt),Object.assign(O,Ht),Object.assign(C,ye),Object.assign(Y,Ee),Object.assign(I,Fn);export{it as Layouter,X as LeaferCanvas,ot as Renderer,V 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/draw");function i(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{d(i.next(t))}catch(t){a(t)}}function r(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(o,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s 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:a,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(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 r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:l,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=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,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:w}=t.LeafHelper,y=t.Debug.get("Layouter");class m{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){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.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:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(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||l(i[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),i.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),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,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),m.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){g(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 v=t.Debug.get("Renderer");class x{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,v.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,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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 v.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),o=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,o),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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function b(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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 B(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?L(t,!0,e,n):R(e,n);break;case"inside":E("inside",t,s,e,n);break;case"outside":E("outside",t,s,e,n)}}function E(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?L(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",b(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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 L(t,e,i,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&n.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?R(i,s):s.stroke(),s.restoreBlendMode()):e?R(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:W}=t.BoundsHelper;let O;function A(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:a,blendMode:o,color:r,opacity:d}=e;return{type:a,blendMode:o,style:n.ColorConvert.string(r,d)};case"image":return n.PaintImage.image(i,t,e,s,!O||!O[e.url]);case"linear":return n.PaintGradient.linearGradient(e,s);case"radial":return n.PaintGradient.radialGradient(e,s);case"angular":return n.PaintGradient.conicGradient(e,s);default:return e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const C={compute:function(t,e){const i=e.__,s=[];let a,o=i.__input[t];o instanceof Array||(o=[o]),O=n.PaintImage.recycleImage(t,i);for(let n,i=0,a=o.length;i<a;i++)n=A(t,o[i],e),n&&s.push(n);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=a:i.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?b(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,d=t.length;r<d;r++)s=t[r],s.image&&n.PaintImage.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?b(e,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?b(e,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):o?b(e,i):a?i.fill(a):i.fill())},fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)B(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:o}=i;if(s)if(o)B(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),L(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),L(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),L(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:B,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,h=W(i?k(e.bounds,i*l,i*c):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(s,o),a=P(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let T={};const{get:M,rotateOfOuter:I,translate:D,scaleOfOuter:F,scale:H,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,s,a){const o=M(),r=a&&180!==a,d=n.width/(r?s:i),l=n.height/(r?i:s),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-i*c)/2,u=n.y+(n.height-s*c)/2;D(o,h,u),H(o,c),a&&I(o,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=c,t.transform=o}function j(t,e,n,i,s,a,o){const r=M();D(r,e.x,e.y),(n||i)&&D(r,n,i),s&&(H(r,s,a),t.scaleX=r.a,t.scaleY=r.d),o&&Y(r,o),t.transform=r}function U(t,e,n,i,s,a,o,r,d){const l=M();if(d)switch(Y(l,d),d){case 90:D(l,i,0);break;case 180:D(l,n,i);break;case 270:D(l,0,n)}T.x=e.x,T.y=e.y,(s||a)&&(T.x+=s,T.y+=a),D(l,T.x,T.y),o&&(F(l,T,o,r),t.scaleX=o,t.scaleY=r),t.transform=l}const{get:X,translate:N}=t.MatrixHelper;function q(t,e,n,i){let{width:s,height:a}=e;const{opacity:o,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,p=i.width===s&&i.height===a;u&&(t.blendMode=u);const _=t.data={mode:r};let g,w,y,m;switch(d&&(g=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/s,m=("number"==typeof c?c:c.height)/a):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":p||(s=i.width,a=i.height);break;case"clip":(d||y||h)&&j(_,i,g,w,y,m,h);break;case"repeat":(!p||y||h)&&U(_,i,s,a,g,w,y,m,h),f||(_.repeat="repeat");break;default:p&&!h||G(_,r,i,s,a,h)}_.transform||(i.x||i.y)&&(_.transform=X(),N(_.transform,i.x,i.y)),_.width=s,_.height=a,o&&(_.opacity=o),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let V,z=new t.Bounds;const{isSame:Q}=t.BoundsHelper;function Z(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||q(s,i,n,a),!0}function $(e,n){tt(e,t.ImageEvent.LOAD,n)}function J(e,n){tt(e,t.ImageEvent.LOADED,n)}function K(e,n,i){n.error=i,e.forceUpdate("surface"),tt(e,t.ImageEvent.ERROR,n)}function tt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function et(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:nt,scale:it,copy:st}=t.MatrixHelper,{ceil:at,abs:ot}=Math;function rt(e,n,i){let{scaleX:s,scaleY:a}=e.__nowWorld;const o=s+"-"+a;if(n.patternId===o||e.destroyed)return!1;{s=ot(s),a=ot(a);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:_,repeat:g}=r;u&&(l=nt(),st(l,_),it(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const w=c*h;if(!g&&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,c/=d,h/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=nt(),_&&st(l,_)),it(l,1/s,1/a));const m=e.getCanvas(at(c)||1,at(h)||1,p),v=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}const{abs:dt}=Math;const lt={image:function(e,n,i,s,a){let o,r;const d=t.ImageManager.get(i);return V&&i===V.paint&&Q(s,V.boxBounds)?o=V.leafPaint:(o={type:i.type,image:d},V=d.use>1?{leafPaint:o,paint:i,boxBounds:z.set(s)}:null),(a||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?(Z(e,n,i,d,o,s),a&&($(e,r),J(e,r))):d.error?a&&K(e,r,d.error):(et(e,!0),a&&$(e,r),o.loadId=d.load((()=>{et(e,!1),e.destroyed||(Z(e,n,i,d,o,s)&&e.forceUpdate("surface"),J(e,r)),o.loadId=null}),(t=>{et(e,!1),K(e,r,t),o.loadId=null}))),o},createData:q,fillOrFitMode:G,clipMode:j,repeatMode:U,createPattern:rt,checkImage:function(e,s,a,o){const{scaleX:r,scaleY:d}=e.__nowWorld;if(a.data&&a.patternId!==r+"-"+d){const{data:l}=a;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=dt(r)*s.pixelRatio,n*=dt(d)*s.pixelRatio,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(s.save(),s.clip(),a.blendMode&&(s.blendMode=a.blendMode),l.opacity&&(s.opacity*=l.opacity),l.transform&&s.transform(l.transform),s.drawImage(a.image.view,0,0,l.width,l.height),s.restore(),!0):(!a.style||n.Export.running?rt(e,a,s.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>i(this,void 0,void 0,(function*(){a.patternTask=null,s.bounds.hit(e.__nowWorld)&&rt(e,a,s.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let d=0,l=i.length;d<l;d++)s=i[d].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[d].loadId,!o.some((t=>t.url===r)))));return a}return null}},ct={x:.5,y:0},ht={x:.5,y:1};function ut(t,e,i){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],t.addColorStop(s.offset,n.ColorConvert.string(s.color,i))}const{set:ft,getAngle:pt,getDistance:_t}=t.PointHelper,{get:gt,rotateOfOuter:wt,scaleOfOuter:yt}=t.MatrixHelper,mt={x:.5,y:.5},vt={x:.5,y:1},xt={},bt={};const{set:Bt,getAngle:Et,getDistance:Rt}=t.PointHelper,{get:Lt,rotateOfOuter:kt,scaleOfOuter:St}=t.MatrixHelper,Pt={x:.5,y:.5},Wt={x:.5,y:1},Ot={},At={};const Ct={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;i||(i=ct),s||(s=ht);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);ut(d,e.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;i||(i=mt),s||(s=vt);const{x:l,y:c,width:h,height:u}=n;let f;ft(xt,l+i.x*h,c+i.y*u),ft(bt,l+s.x*h,c+s.y*u),(h!==u||d)&&(f=gt(),yt(f,xt,h/u*(d||1),1),wt(f,xt,pt(xt,bt)+90));const p=t.Platform.canvas.createRadialGradient(xt.x,xt.y,0,xt.x,xt.y,_t(xt,bt));ut(p,e.stops,o);const _={type:a,style:p,transform:f};return r&&(_.blendMode=r),_},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;i||(i=Pt),s||(s=Wt);const{x:l,y:c,width:h,height:u}=n;Bt(Ot,l+i.x*h,c+i.y*u),Bt(At,l+s.x*h,c+s.y*u);const f=Lt(),p=Et(Ot,At);t.Platform.conicGradientRotate90?(St(f,Ot,h/u*(d||1),1),kt(f,Ot,p+90)):(St(f,Ot,1,h/u*(d||1)),kt(f,Ot,p));const _=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,Rt(Ot,At));ut(_,e.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g}},{copy:Tt,toOffsetOutBounds:Mt}=t.BoundsHelper,It={},Dt={};function Ft(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Tt(It,e.bounds),It.x+=n.x-o.x,It.y+=n.y-o.y,i){const{matrix:t}=s;It.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),It.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),It.width*=i,It.height*=i}e.copyWorld(s.canvas,e.bounds,It)}else i&&(Tt(It,n),It.x-=n.width/2*(i-1),It.y-=n.height/2*(i-1),It.width*=i,It.height*=i),e.copyWorld(s.canvas,o,i?It:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Yt={};const Gt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Mt(l,Dt),r.forEach(((r,_)=>{f.setWorldShadow(Dt.offsetX+r.x*h,Dt.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ft(f,Dt,s,n),i=l,r.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,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(l,Yt),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Yt.offsetX+r.x*h,Yt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ft(f,Yt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&_<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:jt}=t.LeafBoundsHelper;function Ut(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),Nt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Nt(t,n,i,a);break;case"path":n.restore()}}function Xt(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}n.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(Ut(this,o,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Xt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Xt(t)),s||(s=Xt(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||jt(n,e)||n.__render(s||t,e);Ut(this,o,t,s,i,a)};const qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Vt=qt+"_#~&*+\\=|≮≯≈≠=…",zt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Qt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Zt=Qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$t=Qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Qt(qt),Kt=Qt(Vt),te=Qt("- —/~|┆·");var ee;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ee||(ee={}));const{Letter:ne,Single:ie,Before:se,After:ae,Symbol:oe,Break:re}=ee;function de(t){return Zt[t]?ne:te[t]?re:$t[t]?se:Jt[t]?ae:Kt[t]?oe:zt.test(t)?ie:ne}const le={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 ce(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:he}=le,{Letter:ue,Single:fe,Before:pe,After:_e,Symbol:ge,Break:we}=ee;let ye,me,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,We,Oe,Ae,Ce,Te=[];function Me(t,e){Le&&!Re&&(Re=Le),ye.data.push({char:t,width:e}),ve+=e}function Ie(){xe+=ve,ye.width=ve,me.words.push(ye),ye={data:[]},ve=0}function De(){Oe&&(Ae.paraNumber++,me.paraStart=!0,Oe=!1),Le&&(me.startCharSize=Re,me.endCharSize=Le,Re=0),me.width=xe,Ce.width&&he(me),Te.push(me),me={words:[]},xe=0}const Fe=0,He=1,Ye=2;const{top:Ge,right:je,bottom:Ue,left:Xe}=t.Direction4;function Ne(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a&&(i=l[Xe],a-=l[je]+l[Xe]),o&&(s=l[Ge],o-=l[Ge]+l[Ue]));const c={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ae=e,Te=e.rows,Ce=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:d,height:l}=Ce;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Se=null,Re=Ee=Le=ve=xe=0,ye={data:[]},me={words:[]};for(let i=0,l=n.length;i<l;i++)Be=n[i],"\n"===Be?(ve&&Ie(),me.paraEnd=!0,De(),Oe=!0):(ke=de(Be),ke===ue&&"none"!==o&&(Be=ce(Be,o,!ve)),Ee=r.measureText(Be).width,s&&(s<0&&(Le=Ee),Ee+=s),Pe=ke===fe&&(Se===fe||Se===ue)||Se===fe&&ke!==_e,We=!(ke!==pe&&ke!==fe||Se!==ge&&Se!==_e),be=Oe&&a?d-a:d,t&&d&&xe+ve+Ee>be&&(e?(ve&&Ie(),De()):(We||(We=ke===ue&&Se==_e),Pe||We||ke===we||ke===pe||ke===fe||ve+Ee>be?(ve&&Ie(),De()):De()))," "===Be&&!0!==Oe&&xe+ve===0||(ke===we?(" "===Be&&ve&&Ie(),Me(Be,Ee),Ie()):Pe||We?(ve&&Ie(),Me(Be,Ee)):Me(Be,Ee)),Se=ke);ve&&Ie(),xe&&De(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ae.paraNumber++,Te.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Ne(e,"x",t[Xe]);break;case"right":Ne(e,"x",-t[je])}if(!s)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ge]);break;case"bottom":Ne(e,"y",-t[Ue])}}(l,c,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:_,width:g,height:w}=i,y=s*n.length+(c?c*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,s),t.overflow=n.length;else switch(l){case"middle":_+=(w-y)/2;break;case"bottom":_+=w-y}m+=_;for(let a=0,l=n.length;a<l;a++){switch(h=n[a],h.x=p,d){case"center":h.x+=(g-h.width)/2;break;case"right":h.x+=g-h.width}h.paraStart&&c&&a>0&&(m+=c),h.y=m,m+=s,t.overflow>a&&m>y&&(h.isOverflow=!0,t.overflow=a+1),u=h.x,f=h.width,o<0&&(h.width<0?(f=-h.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&g&&g<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=_,i.height=y}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:l>.01?He:Ye,t.isOverflow&&!r&&(t.textMode=!0),h===Ye?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===He?(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)}))}(c,n,a),c.overflow&&function(e,n){const{rows:i,overflow:s}=e;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let e,o;"ellipsis"===a&&(a="...");const r=t.Platform.canvas.measureText(a).width,d=n.x+n.width-r;("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],o=e.x+e.width,!(i===n&&o<d));i--){if(o<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=r,t.data.push({char:a,x:o}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ve={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:ze,addPoint:Qe,toBounds:Ze}=t.TwoPointBoundsHelper;const $e={export(e,n,s){return this.running=!0,function(e){Je||(Je=new t.TaskProcessor);return new Promise((t=>{Je.add((()=>i(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{leafer:d}=e;d?d.waitViewCompleted((()=>i(this,void 0,void 0,(function*(){s=t.FileHelper.getExportOptions(s);let i,a,o=1,l=1;const{worldTransform:c,isLeafer:h,isFrame:u}=e,{slice:f,trim:p,onCanvas:_}=s,g=s.scale||1,w=s.pixelRatio||1,y=s.screenshot||e.isApp,m=h&&y?void 0===s.fill?e.fill:void 0:s.fill,v=t.FileHelper.isOpaqueImage(n)||m,x=new t.Matrix;if(y)i=!0===y?h?d.canvas.bounds:e.worldRenderBounds:y;else{let t=s.relative||(h?"inner":"local");switch(o=c.scaleX,l=c.scaleY,t){case"inner":x.set(c).invert();break;case"local":x.set(c).divide(e.localTransform).invert(),o/=e.scaleX,l/=e.scaleY;break;case"world":o=1,l=1;break;case"page":t=e.leafer;default:x.set(c).divide(e.getTransform(t)).invert();const n=t.worldTransform;o/=o/n.scaleX,l/=l/n.scaleY}i=e.getBounds("render",t)}const{x:b,y:B,width:E,height:R}=new t.Bounds(i).scale(g);let L=t.Creator.canvas({width:Math.round(E),height:Math.round(R),pixelRatio:w});const k={matrix:x.scale(g).translate(-b,-B).withScale(1/o*g,1/l*g)};if(f&&(e=d,k.bounds=L.bounds),L.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(L,k),e.fill=t}else e.__render(L,k);if(L.restore(),p){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,o=(d-a)/n,r?Qe(r,a,o):ze(r={},a,o)),d++;const l=new t.Bounds;return Ze(r,l),l.scale(1/e.pixelRatio).ceil()}(L);const e=L,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:w};L=t.Creator.canvas(s),L.copyWorld(e,a,s)}v&&L.fillWorld(L.bounds,m||"#FFFFFF","destination-over"),_&&_(L);const S="canvas"===n?L:yield L.export(n,s);r({data:S,width:L.pixelWidth,height:L.pixelHeight,renderBounds:i,trimBounds:a})})))):r({data:!1})}))))}};let Je;Object.assign(n.TextConvert,qe),Object.assign(n.ColorConvert,Ve),Object.assign(n.Paint,C),Object.assign(n.PaintImage,lt),Object.assign(n.PaintGradient,Ct),Object.assign(n.Effect,Gt),Object.assign(n.Export,$e),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=s,exports.Renderer=x,exports.Watcher=r,exports.useCanvas=function(n,s){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=s;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}),loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:r}=s;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(a(e),n),canvasToBolb:(t,e,n)=>i(this,void 0,void 0,(function*(){return t.toBuffer(a(e),n)})),canvasSaveAs:(t,n,s)=>i(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(a(o(n)),s))})),loadImage:r}}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/draw");function i(t,e,n,i){return new(n||(n=Promise))((function(a,s){function o(t){try{d(i.next(t))}catch(t){s(t)}}function r(t){try{d(i.throw(t))}catch(t){s(t)}}function d(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}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:s,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 r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:l,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:h,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class g{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,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:w}=t.LeafHelper,y=t.Debug.get("Layouter");class m{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){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.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:a}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;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||l(i[t])}l(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),i.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),m.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){_(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 g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){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 v=t.Debug.get("Renderer");class x{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,v.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,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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 v.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,a=e.getIntersect(i.bounds),s=e.includes(this.target.__world),o=new t.Bounds(a);i.save(),s&&!t.Debug.showRepaint?i.clear():(a.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,s,o),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 a=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,a),this.renderBounds=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function b(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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)})),a&&e.fillRect(n.x,n.y+a,n.width,s)}function B(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?L(t,!0,e,n):R(e,n);break;case"inside":E("inside",t,a,e,n);break;case"outside":E("outside",t,a,e,n)}}function E(t,e,n,i,a){const{__strokeWidth:s,__font:o}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,i.__),r.font=o,n?L(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",b(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;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)})),a&&e.strokeRect(n.x,n.y+a,n.width,s)}function L(t,e,i,a){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&n.PaintImage.checkImage(i,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?R(i,a):a.stroke(),a.restoreBlendMode()):e?R(i,a):a.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:W}=t.BoundsHelper;let A;function C(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:d}=e;return{type:s,blendMode:o,style:n.ColorConvert.string(r,d)};case"image":return n.PaintImage.image(i,t,e,a,!A||!A[e.url]);case"linear":return n.PaintGradient.linearGradient(e,a);case"radial":return n.PaintGradient.radialGradient(e,a);case"angular":return n.PaintGradient.conicGradient(e,a);default:return e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const O={compute:function(t,e){const i=e.__,a=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),A=n.PaintImage.recycleImage(t,i);for(let n,i=0,s=o.length;i<s;i++)n=C(t,o[i],e),n&&a.push(n);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?b(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let a;const{windingRule:s,__font:o}=e.__;for(let r=0,d=t.length;r<d;r++)a=t[r],a.image&&n.PaintImage.checkImage(e,i,a,!o)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),o?b(e,i):s?i.fill(s):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),o?b(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?b(e,i):s?i.fill(s):i.fill())},fillText:b,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)B(t,e,n);else switch(s){case"center":n.setStroke(t,a,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)B(t,e,n);else switch(s){case"center":n.setStroke(void 0,a,i),L(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),L(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,i),L(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:B,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,o,r,d,{scaleX:l,scaleY:c}=a;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(a))d=i,s=r=a;else{const{renderShapeSpread:i}=t.__layout,h=W(i?k(e.bounds,i*l,i*c):e.bounds,a);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(a,o),s=P(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:s,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let T={};const{get:M,rotateOfOuter:I,translate:D,scaleOfOuter:F,scale:H,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,a,s){const o=M(),r=s&&180!==s,d=n.width/(r?a:i),l=n.height/(r?i:a),c="fit"===e?Math.min(d,l):Math.max(d,l),h=n.x+(n.width-i*c)/2,u=n.y+(n.height-a*c)/2;D(o,h,u),H(o,c),s&&I(o,{x:n.x+n.width/2,y:n.y+n.height/2},s),t.scaleX=t.scaleY=c,t.transform=o}function U(t,e,n,i,a,s,o){const r=M();D(r,e.x,e.y),(n||i)&&D(r,n,i),a&&(H(r,a,s),t.scaleX=r.a,t.scaleY=r.d),o&&Y(r,o),t.transform=r}function j(t,e,n,i,a,s,o,r,d){const l=M();if(d)switch(Y(l,d),d){case 90:D(l,i,0);break;case 180:D(l,n,i);break;case 270:D(l,0,n)}T.x=e.x,T.y=e.y,(a||s)&&(T.x+=a,T.y+=s),D(l,T.x,T.y),o&&(F(l,T,o,r),t.scaleX=o,t.scaleY=r),t.transform=l}const{get:X,translate:q}=t.MatrixHelper,N=new t.Bounds;function V(t,e,n,i){let{width:a,height:s}=e;n.padding&&(i=N.set(i).shrink(n.padding));const{opacity:o,mode:r,offset:d,scale:l,size:c,rotation:h,blendMode:u,repeat:f}=n,p=i.width===a&&i.height===s;u&&(t.blendMode=u);const g=t.data={mode:r};let _,w,y,m;switch(d&&(_=d.x,w=d.y),c?(y=("number"==typeof c?c:c.width)/a,m=("number"==typeof c?c:c.height)/s):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),r){case"strench":p||(a=i.width,s=i.height);break;case"clip":(d||y||h)&&U(g,i,_,w,y,m,h);break;case"repeat":(!p||y||h)&&j(g,i,a,s,_,w,y,m,h),f||(g.repeat="repeat");break;default:p&&!h||G(g,r,i,a,s,h)}g.transform||(i.x||i.y)&&(g.transform=X(),q(g.transform,i.x,i.y)),g.width=a,g.height=s,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let z,Q=new t.Bounds;const{isSame:Z}=t.BoundsHelper;function $(t,e,n,i,a,s){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 a.data||V(a,i,n,s),!0}function J(e,n){et(e,t.ImageEvent.LOAD,n)}function K(e,n){et(e,t.ImageEvent.LOADED,n)}function tt(e,n,i){n.error=i,e.forceUpdate("surface"),et(e,t.ImageEvent.ERROR,n)}function et(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function nt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:it,scale:at,copy:st}=t.MatrixHelper,{ceil:ot,abs:rt}=Math;function dt(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=a+"-"+s;if(n.patternId===o||e.destroyed)return!1;{a=rt(a),s=rt(s);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=it(),st(l,g),at(l,1/u,1/f),a*=u,s*=f),a*=i,s*=i,c*=a,h*=s;const w=c*h;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&&(a/=d,s/=d,c/=d,h/=d),u&&(a/=u,s/=f),(g||1!==a||1!==s)&&(l||(l=it(),g&&st(l,g)),at(l,1/a,1/s));const m=e.getCanvas(ot(c)||1,ot(h)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}const{abs:lt}=Math;const ct={image:function(e,n,i,a,s){let o,r;const d=t.ImageManager.get(i);return z&&i===z.paint&&Z(a,z.boxBounds)?o=z.leafPaint:(o={type:i.type,image:d},z=d.use>1?{leafPaint:o,paint:i,boxBounds:Q.set(a)}:null),(s||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?($(e,n,i,d,o,a),s&&(J(e,r),K(e,r))):d.error?s&&tt(e,r,d.error):(nt(e,!0),s&&J(e,r),o.loadId=d.load((()=>{nt(e,!1),e.destroyed||($(e,n,i,d,o,a)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),K(e,r)),o.loadId=null}),(t=>{nt(e,!1),tt(e,r,t),o.loadId=null}))),o},createData:V,fillOrFitMode:G,clipMode:U,repeatMode:j,createPattern:dt,checkImage:function(e,a,s,o){const{scaleX:r,scaleY:d}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;if(s.data&&s.patternId!==r+"-"+d){const{data:l}=s;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=lt(r)*a.pixelRatio,n*=lt(d)*a.pixelRatio,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize}return o?(a.save(),a.clip(),s.blendMode&&(a.blendMode=s.blendMode),l.opacity&&(a.opacity*=l.opacity),l.transform&&a.transform(l.transform),a.drawImage(s.image.view,0,0,l.width,l.height),a.restore(),!0):(!s.style||n.Export.running?dt(e,s,a.pixelRatio):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>i(this,void 0,void 0,(function*(){s.patternTask=null,a.bounds.hit(e.__nowWorld)&&dt(e,s,a.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,o,r;for(let d=0,l=i.length;d<l;d++)a=i[d].image,r=a&&a.url,r&&(s||(s={}),s[r]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),a.unload(i[d].loadId,!o.some((t=>t.url===r)))));return s}return null}},ht={x:.5,y:0},ut={x:.5,y:1};function ft(t,e,i){let a;for(let s=0,o=e.length;s<o;s++)a=e[s],t.addColorStop(a.offset,n.ColorConvert.string(a.color,i))}const{set:pt,getAngle:gt,getDistance:_t}=t.PointHelper,{get:wt,rotateOfOuter:yt,scaleOfOuter:mt}=t.MatrixHelper,vt={x:.5,y:.5},xt={x:.5,y:1},bt={},Bt={};const{set:Et,getAngle:Rt,getDistance:Lt}=t.PointHelper,{get:kt,rotateOfOuter:St,scaleOfOuter:Pt}=t.MatrixHelper,Wt={x:.5,y:.5},At={x:.5,y:1},Ct={},Ot={};const Tt={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:o,opacity:r}=e;i||(i=ht),a||(a=ut);const d=t.Platform.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+a.x*n.width,n.y+a.y*n.height);ft(d,e.stops,r);const l={type:s,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:d}=e;i||(i=vt),a||(a=xt);const{x:l,y:c,width:h,height:u}=n;let f;pt(bt,l+i.x*h,c+i.y*u),pt(Bt,l+a.x*h,c+a.y*u),(h!==u||d)&&(f=wt(),mt(f,bt,h/u*(d||1),1),yt(f,bt,gt(bt,Bt)+90));const p=t.Platform.canvas.createRadialGradient(bt.x,bt.y,0,bt.x,bt.y,_t(bt,Bt));ft(p,e.stops,o);const g={type:s,style:p,transform:f};return r&&(g.blendMode=r),g},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:d}=e;i||(i=Wt),a||(a=At);const{x:l,y:c,width:h,height:u}=n;Et(Ct,l+i.x*h,c+i.y*u),Et(Ot,l+a.x*h,c+a.y*u);const f=kt(),p=Rt(Ct,Ot);t.Platform.conicGradientRotate90?(Pt(f,Ct,h/u*(d||1),1),St(f,Ct,p+90)):(Pt(f,Ct,1,h/u*(d||1)),St(f,Ct,p));const g=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ct.x,Ct.y):t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Lt(Ct,Ot));ft(g,e.stops,o);const _={type:s,style:g,transform:f};return r&&(_.blendMode=r),_}},{copy:Mt,toOffsetOutBounds:It}=t.BoundsHelper,Dt={},Ft={};function Ht(e,n,i,a){const{bounds:s,shapeBounds:o}=a;if(t.Platform.fullImageShadow){if(Mt(Dt,e.bounds),Dt.x+=n.x-o.x,Dt.y+=n.y-o.y,i){const{matrix:t}=a;Dt.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Dt.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),Dt.width*=i,Dt.height*=i}e.copyWorld(a.canvas,e.bounds,Dt)}else i&&(Mt(Dt,n),Dt.x-=n.width/2*(i-1),Dt.y-=n.height/2*(i-1),Dt.width*=i,Dt.height*=i),e.copyWorld(a.canvas,o,i?Dt:n)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,Gt={};const Ut={shadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;It(l,Ft),r.forEach(((r,g)=>{f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ht(f,Ft,a,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,s,"copy"),i=s),d?f.copyWorld(d,s,s,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Yt(l,Gt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Gt.offsetX+r.x*h,Gt.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ht(f,Gt,a,n),f.restore(),d?(f.copyWorld(f,l,s,"copy"),f.copyWorld(d,s,s,"source-out"),i=s):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:jt}=t.LeafBoundsHelper;function Xt(t,e,n,i,a,s){switch(e){case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Nt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Nt(t,n,i,s);break;case"path":n.restore()}}function qt(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}n.Group.prototype.__renderMask=function(t,e){let n,i,a,s,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(Xt(this,o,t,a,i,s),i=a=null),"path"===n.__.maskType?(n.opacity<1?(o="opacity-path",s=n.opacity,a||(a=qt(t))):(o="path",t.save()),n.__clip(a||t,e)):(o="alpha",i||(i=qt(t)),a||(a=qt(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||jt(n,e)||n.__render(a||t,e);Xt(this,o,t,a,i,s)};const Vt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",zt=Vt+"_#~&*+\\=|≮≯≈≠=…",Qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Zt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Zt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=Zt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Kt=Zt(Vt),te=Zt(zt),ee=Zt("- —/~|┆·");var ne;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ne||(ne={}));const{Letter:ie,Single:ae,Before:se,After:oe,Symbol:re,Break:de}=ne;function le(t){return $t[t]?ie:ee[t]?de:Jt[t]?se:Kt[t]?oe:te[t]?re:Qt.test(t)?ae:ie}const ce={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function he(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ue}=ce,{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:we,Break:ye}=ne;let me,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,We,Ae,Ce,Oe,Te,Me=[];function Ie(t,e){ke&&!Le&&(Le=ke),me.data.push({char:t,width:e}),xe+=e}function De(){be+=xe,me.width=xe,ve.words.push(me),me={data:[]},xe=0}function Fe(){Ce&&(Oe.paraNumber++,ve.paraStart=!0,Ce=!1),ke&&(ve.startCharSize=Le,ve.endCharSize=ke,Le=0),ve.width=be,Te.width&&ue(ve),Me.push(ve),ve={words:[]},be=0}const He=0,Ye=1,Ge=2;const{top:Ue,right:je,bottom:Xe,left:qe}=t.Direction4;function Ne(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ve={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(s&&(i=l[qe],s-=l[je]+l[qe]),o&&(a=l[Ue],o-=l[Ue]+l[Xe]));const c={bounds:{x:i,y:a,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Oe=e,Me=e.rows,Te=e.bounds;const{__letterSpacing:a,paraIndent:s,textCase:o}=i,{canvas:r}=t.Platform,{width:d,height:l}=Te;if(d||l||a||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Ce=!0,Pe=null,Le=Re=ke=xe=be=0,me={data:[]},ve={words:[]};for(let i=0,l=n.length;i<l;i++)Ee=n[i],"\n"===Ee?(xe&&De(),ve.paraEnd=!0,Fe(),Ce=!0):(Se=le(Ee),Se===fe&&"none"!==o&&(Ee=he(Ee,o,!xe)),Re=r.measureText(Ee).width,a&&(a<0&&(ke=Re),Re+=a),We=Se===pe&&(Pe===pe||Pe===fe)||Pe===pe&&Se!==_e,Ae=!(Se!==ge&&Se!==pe||Pe!==we&&Pe!==_e),Be=Ce&&s?d-s:d,t&&d&&be+xe+Re>Be&&(e?(xe&&De(),Fe()):(Ae||(Ae=Se===fe&&Pe==_e),We||Ae||Se===ye||Se===ge||Se===pe||xe+Re>Be?(xe&&De(),Fe()):Fe()))," "===Ee&&!0!==Ce&&be+xe===0||(Se===ye?(" "===Ee&&xe&&De(),Ie(Ee,Re),De()):We||Ae?(xe&&De(),Ie(Ee,Re)):Ie(Ee,Re)),Pe=Se);xe&&De(),be&&Fe(),Me.length>0&&(Me[Me.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Oe.paraNumber++,Me.push({x:s||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),l&&function(t,e,n,i,a){if(!i)switch(n.textAlign){case"left":Ne(e,"x",t[qe]);break;case"right":Ne(e,"x",-t[je])}if(!a)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ue]);break;case"bottom":Ne(e,"y",-t[Xe])}}(l,c,n,s,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:s,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=i,y=a*n.length+(c?c*(t.paraNumber-1):0),m=s;if(r&&y>w)y=Math.max(w,a),t.overflow=n.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let s=0,l=n.length;s<l;s++){switch(h=n[s],h.x=p,d){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&s>0&&(m+=c),h.y=m,m+=a,t.overflow>s&&m>y&&(h.isOverflow=!0,t.overflow=s+1),u=h.x,f=h.width,o<0&&(h.width<0?(f=-h.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=g,i.height=y}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let d,l,c,h,u;a.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,l=n&&"justify"===s&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?He:l>.01?Ye:Ge,t.isOverflow&&!r&&(t.textMode=!0),h===Ge?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(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)}))}(c,n,s),c.overflow&&function(e,n){const{rows:i,overflow:a}=e;let{textOverflow:s}=n;if(i.splice(a),"hide"!==s){let e,o;"ellipsis"===s&&(s="...");const r=t.Platform.canvas.measureText(s).width,d=n.x+n.width-r;("none"===n.textWrap?i:[i[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],o=e.x+e.width,!(i===n&&o<d));i--){if(o<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=r,t.data.push({char:s,x:o}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const ze={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:Qe,addPoint:Ze,toBounds:$e}=t.TwoPointBoundsHelper;const Je={export(e,n,a){return this.running=!0,function(e){Ke||(Ke=new t.TaskProcessor);return new Promise((t=>{Ke.add((()=>i(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((s=>new Promise((o=>{const r=t=>{s(t),o(),this.running=!1},{leafer:d}=e;d?d.waitViewCompleted((()=>i(this,void 0,void 0,(function*(){a=t.FileHelper.getExportOptions(a);let i,s,o=1,l=1;const{worldTransform:c,isLeafer:h,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=a,_=a.scale||1,w=a.pixelRatio||1,y=a.screenshot||e.isApp,m=h&&y&&void 0===a.fill?e.fill:a.fill,v=t.FileHelper.isOpaqueImage(n)||m,x=new t.Matrix;if(y)i=!0===y?h?d.canvas.bounds:e.worldRenderBounds:y;else{let t=a.relative||(h?"inner":"local");switch(o=c.scaleX,l=c.scaleY,t){case"inner":x.set(c);break;case"local":x.set(c).divide(e.localTransform),o/=e.scaleX,l/=e.scaleY;break;case"world":o=1,l=1;break;case"page":t=e.leafer;default:x.set(c).divide(e.getTransform(t));const n=t.worldTransform;o/=o/n.scaleX,l/=l/n.scaleY}i=e.getBounds("render",t)}const{x:b,y:B,width:E,height:R}=new t.Bounds(i).scale(_);let L=t.Creator.canvas({width:Math.round(E),height:Math.round(R),pixelRatio:w});const k={matrix:x.scale(1/_).invert().translate(-b,-B).withScale(1/o*_,1/l*_)};if(f&&(e=d,k.bounds=L.bounds),L.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(L,k),e.fill=t}else e.__render(L,k);if(L.restore(),p){s=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let s,o,r,d=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=d%n,o=(d-s)/n,r?Ze(r,s,o):Qe(r={},s,o)),d++;const l=new t.Bounds;return $e(r,l),l.scale(1/e.pixelRatio).ceil()}(L);const e=L,{width:n,height:i}=s,a={x:0,y:0,width:n,height:i,pixelRatio:w};L=t.Creator.canvas(a),L.copyWorld(e,s,a)}v&&L.fillWorld(L.bounds,m||"#FFFFFF","destination-over"),g&&g(L);const S="canvas"===n?L:yield L.export(n,a);r({data:S,width:L.pixelWidth,height:L.pixelHeight,renderBounds:i,trimBounds:s})})))):r({data:!1})}))))}};let Ke;const tn=t.LeaferCanvasBase.prototype,en=t.Debug.get("@leafer-ui/export");tn.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},tn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},tn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},Object.assign(n.TextConvert,Ve),Object.assign(n.ColorConvert,ze),Object.assign(n.Paint,O),Object.assign(n.PaintImage,ct),Object.assign(n.PaintGradient,Tt),Object.assign(n.Effect,Ut),Object.assign(n.Export,Je),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=a,exports.Renderer=x,exports.Watcher=r,exports.useCanvas=function(n,a){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=a;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:r}=a;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>i(this,void 0,void 0,(function*(){return t.toBuffer(s(e),n)})),canvasSaveAs:(t,n,a)=>i(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(s(o(n)),a))})),download(t,e){},loadImage:r}}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,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-draw/node",
3
- "version": "1.0.0-rc.19",
3
+ "version": "1.0.0-rc.21",
4
4
  "description": "@leafer-draw/node",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -31,10 +31,10 @@
31
31
  "leaferjs"
32
32
  ],
33
33
  "dependencies": {
34
- "@leafer/node": "1.0.0-rc.19",
35
- "@leafer-draw/partner": "1.0.0-rc.19",
36
- "@leafer-ui/draw": "1.0.0-rc.19",
37
- "@leafer-ui/partner": "1.0.0-rc.19",
38
- "@leafer-ui/interface": "1.0.0-rc.19"
34
+ "@leafer/node": "1.0.0-rc.21",
35
+ "@leafer-draw/partner": "1.0.0-rc.21",
36
+ "@leafer-ui/draw": "1.0.0-rc.21",
37
+ "@leafer-ui/partner": "1.0.0-rc.21",
38
+ "@leafer-ui/interface": "1.0.0-rc.21"
39
39
  }
40
40
  }