@leafer-ui/draw 1.6.1 → 1.6.3

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/lib/draw.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineKey, decorateLeafAttr, attr, Plugin, PathConvert, Debug, LeafData, canvasSizeAttrs, UICreator, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, DataHelper, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, affectRenderBoundsType, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, ImageEvent, LeaferImage, Matrix, PathCreator } from '@leafer/core';
1
+ import { defineKey, decorateLeafAttr, attr, Plugin, PathConvert, DataHelper, Debug, LeafData, canvasSizeAttrs, UICreator, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, affectRenderBoundsType, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, LeaferImage, ImageEvent, Matrix, PathCreator } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
 
4
4
  /******************************************************************************
@@ -64,8 +64,32 @@ function zoomLayerType() {
64
64
  };
65
65
  }
66
66
 
67
+ function hasTransparent$1(color) {
68
+ if (!color || color.length === 7 || color.length === 4)
69
+ return false;
70
+ if (color === 'transparent')
71
+ return true;
72
+ const first = color[0];
73
+ if (first === '#') {
74
+ switch (color.length) {
75
+ case 5: return color[4] !== 'f' && color[4] !== 'F';
76
+ case 9: return (color[7] !== 'f' && color[7] !== 'F') || (color[8] !== 'f' && color[8] !== 'F');
77
+ }
78
+ }
79
+ else if (first === 'r' || first === 'h') {
80
+ if (color[3] === 'a') {
81
+ const i = color.lastIndexOf(',');
82
+ if (i > -1)
83
+ return parseFloat(color.slice(i + 1)) < 1;
84
+ }
85
+ }
86
+ return false;
87
+ }
88
+
67
89
  const TextConvert = {};
68
- const ColorConvert = {};
90
+ const ColorConvert = {
91
+ hasTransparent: hasTransparent$1
92
+ };
69
93
  const UnitConvert = {
70
94
  number(value, percentRefer) {
71
95
  return typeof value === 'object' ? (value.type === 'percent' ? value.value * percentRefer : value.value) : value;
@@ -91,6 +115,7 @@ const Transition = {
91
115
  };
92
116
 
93
117
  const { parse, objectToCanvasData } = PathConvert;
118
+ const { stintSet: stintSet$1 } = DataHelper, { hasTransparent } = ColorConvert;
94
119
  const emptyPaint = {};
95
120
  const debug$1 = Debug.get('UIData');
96
121
  class UIData extends LeafData {
@@ -149,38 +174,22 @@ class UIData extends LeafData {
149
174
  if (this.__naturalWidth)
150
175
  this.__removeNaturalSize();
151
176
  if (typeof value === 'string' || !value) {
152
- if (this.__isFills) {
153
- this.__removeInput('fill');
154
- PaintImage.recycleImage('fill', this);
155
- this.__isFills = false;
156
- this.__pixelFill && (this.__pixelFill = false);
157
- }
177
+ stintSet$1(this, '__isTransparentFill', hasTransparent(value));
178
+ this.__isFills && this.__removePaint('fill', true);
158
179
  this._fill = value;
159
180
  }
160
181
  else if (typeof value === 'object') {
161
- this.__setInput('fill', value);
162
- const layout = this.__leaf.__layout;
163
- layout.boxChanged || layout.boxChange();
164
- this.__isFills = true;
165
- this._fill || (this._fill = emptyPaint);
182
+ this.__setPaint('fill', value);
166
183
  }
167
184
  }
168
185
  setStroke(value) {
169
186
  if (typeof value === 'string' || !value) {
170
- if (this.__isStrokes) {
171
- this.__removeInput('stroke');
172
- PaintImage.recycleImage('stroke', this);
173
- this.__isStrokes = false;
174
- this.__pixelStroke && (this.__pixelStroke = false);
175
- }
187
+ stintSet$1(this, '__isTransparentStroke', hasTransparent(value));
188
+ this.__isStrokes && this.__removePaint('stroke', true);
176
189
  this._stroke = value;
177
190
  }
178
191
  else if (typeof value === 'object') {
179
- this.__setInput('stroke', value);
180
- const layout = this.__leaf.__layout;
181
- layout.boxChanged || layout.boxChange();
182
- this.__isStrokes = true;
183
- this._stroke || (this._stroke = emptyPaint);
192
+ this.__setPaint('stroke', value);
184
193
  }
185
194
  }
186
195
  setPath(value) {
@@ -210,7 +219,34 @@ class UIData extends LeafData {
210
219
  Paint.compute('fill', this.__leaf);
211
220
  if (stroke)
212
221
  Paint.compute('stroke', this.__leaf);
213
- this.__needComputePaint = false;
222
+ this.__needComputePaint = undefined;
223
+ }
224
+ __setPaint(attrName, value) {
225
+ this.__setInput(attrName, value);
226
+ const layout = this.__leaf.__layout;
227
+ layout.boxChanged || layout.boxChange();
228
+ if (value instanceof Array && !value.length) {
229
+ this.__removePaint(attrName);
230
+ }
231
+ else {
232
+ if (attrName === 'fill')
233
+ this.__isFills = true, this._fill || (this._fill = emptyPaint);
234
+ else
235
+ this.__isStrokes = true, this._stroke || (this._stroke = emptyPaint);
236
+ }
237
+ }
238
+ __removePaint(attrName, removeInput) {
239
+ if (removeInput)
240
+ this.__removeInput(attrName);
241
+ PaintImage.recycleImage(attrName, this);
242
+ if (attrName === 'fill') {
243
+ stintSet$1(this, '__isAlphaPixelFill', undefined);
244
+ this._fill = this.__isFills = undefined;
245
+ }
246
+ else {
247
+ stintSet$1(this, '__isAlphaPixelStroke', undefined);
248
+ this._stroke = this.__isStrokes = undefined;
249
+ }
214
250
  }
215
251
  }
216
252
  function setArray(data, key, value) {
@@ -218,10 +254,10 @@ function setArray(data, key, value) {
218
254
  if (value instanceof Array) {
219
255
  if (value.some((item) => item.visible === false))
220
256
  value = value.filter((item) => item.visible !== false);
221
- value.length || (value = null);
257
+ value.length || (value = undefined);
222
258
  }
223
259
  else
224
- value = value && value.visible !== false ? [value] : null;
260
+ value = value && value.visible !== false ? [value] : undefined;
225
261
  data['_' + key] = value;
226
262
  }
227
263
 
@@ -285,13 +321,11 @@ class TextData extends UIData {
285
321
  setFontWeight(value) {
286
322
  if (typeof value === 'string') {
287
323
  this.__setInput('fontWeight', value);
288
- this._fontWeight = fontWeightMap[value] || 400;
289
- }
290
- else {
291
- if (this.__input)
292
- this.__removeInput('fontWeight');
293
- this._fontWeight = value;
324
+ value = fontWeightMap[value] || 400;
294
325
  }
326
+ else if (this.__input)
327
+ this.__removeInput('fontWeight');
328
+ this._fontWeight = value;
295
329
  }
296
330
  setBoxStyle(value) {
297
331
  let t = this.__leaf, box = t.__box;
@@ -326,8 +360,6 @@ class ImageData extends RectData {
326
360
  this._url = value;
327
361
  }
328
362
  __setImageFill(value) {
329
- if (this.__leaf.image)
330
- this.__leaf.image = null;
331
363
  this.fill = value ? { type: 'image', mode: 'stretch', url: value } : undefined;
332
364
  }
333
365
  __getData() {
@@ -393,21 +425,19 @@ const UIBounds = {
393
425
  }
394
426
  };
395
427
 
428
+ const { stintSet } = DataHelper;
396
429
  const UIRender = {
397
430
  __updateChange() {
398
- const data = this.__, w = this.__world;
431
+ const data = this.__;
399
432
  if (data.__useEffect) {
400
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
401
- data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
433
+ const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
434
+ stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
435
+ data.__useEffect = !!(shadow || otherEffect);
402
436
  }
403
- const half = data.__hasHalf;
404
- w.half !== half && (w.half = half);
437
+ stintSet(this.__world, 'half', data.__hasHalf);
438
+ stintSet(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
405
439
  data.__checkSingle();
406
- const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
407
- if (complex)
408
- data.__complex = true;
409
- else
410
- data.__complex && (data.__complex = false);
440
+ stintSet(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
411
441
  },
412
442
  __drawFast(canvas, options) {
413
443
  drawFast(this, canvas, options);
@@ -417,21 +447,23 @@ const UIRender = {
417
447
  if (data.__complex) {
418
448
  if (data.__needComputePaint)
419
449
  data.__computePaint();
420
- const { fill, stroke, __drawAfterFill } = data;
450
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke, __isFastShadow } = data;
421
451
  this.__drawRenderPath(canvas);
422
- if (data.__useEffect) {
452
+ if (data.__useEffect && !__isFastShadow) {
423
453
  const shape = Paint.shape(this, canvas, options);
424
454
  this.__nowWorld = this.__getNowWorld(options);
425
455
  const { shadow, innerShadow, filter } = data;
426
456
  if (shadow)
427
457
  Effect.shadow(this, canvas, shape);
458
+ if (__fillAfterStroke)
459
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
428
460
  if (fill)
429
461
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
430
462
  if (__drawAfterFill)
431
463
  this.__drawAfterFill(canvas, options);
432
464
  if (innerShadow)
433
465
  Effect.innerShadow(this, canvas, shape);
434
- if (stroke)
466
+ if (stroke && !__fillAfterStroke)
435
467
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
436
468
  if (filter)
437
469
  Filter.apply(filter, this, this.__nowWorld, canvas, originCanvas, shape);
@@ -440,21 +472,27 @@ const UIRender = {
440
472
  shape.canvas.recycle();
441
473
  }
442
474
  else {
475
+ if (__fillAfterStroke)
476
+ data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
477
+ if (__isFastShadow) {
478
+ const shadow = data.shadow[0], { scaleX, scaleY } = this.__nowWorld;
479
+ canvas.save(), canvas.setWorldShadow(shadow.x * scaleX, shadow.y * scaleY, shadow.blur * scaleX, ColorConvert.string(shadow.color));
480
+ }
443
481
  if (fill)
444
482
  data.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
483
+ if (__isFastShadow)
484
+ canvas.restore();
445
485
  if (__drawAfterFill)
446
486
  this.__drawAfterFill(canvas, options);
447
- if (stroke)
487
+ if (stroke && !__fillAfterStroke)
448
488
  data.__isStrokes ? Paint.strokes(stroke, this, canvas) : Paint.stroke(stroke, this, canvas);
449
489
  }
450
490
  }
451
491
  else {
452
- if (data.__pathInputed) {
492
+ if (data.__pathInputed)
453
493
  drawFast(this, canvas, options);
454
- }
455
- else {
494
+ else
456
495
  this.__drawFast(canvas, options);
457
- }
458
496
  }
459
497
  },
460
498
  __renderShape(canvas, options, ignoreFill, ignoreStroke) {
@@ -463,11 +501,11 @@ const UIRender = {
463
501
  const { fill, stroke } = this.__;
464
502
  this.__drawRenderPath(canvas);
465
503
  if (fill && !ignoreFill)
466
- this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
504
+ this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
467
505
  if (this.__.__isCanvas)
468
506
  this.__drawAfterFill(canvas, options);
469
507
  if (stroke && !ignoreStroke)
470
- this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
508
+ this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
471
509
  }
472
510
  },
473
511
  __drawAfterFill(canvas, options) {
@@ -482,13 +520,15 @@ const UIRender = {
482
520
  }
483
521
  };
484
522
  function drawFast(ui, canvas, options) {
485
- const { fill, stroke, __drawAfterFill } = ui.__;
523
+ const { fill, stroke, __drawAfterFill, __fillAfterStroke } = ui.__;
486
524
  ui.__drawRenderPath(canvas);
525
+ if (__fillAfterStroke)
526
+ Paint.stroke(stroke, ui, canvas);
487
527
  if (fill)
488
528
  Paint.fill(fill, ui, canvas);
489
529
  if (__drawAfterFill)
490
530
  ui.__drawAfterFill(canvas, options);
491
- if (stroke)
531
+ if (stroke && !__fillAfterStroke)
492
532
  Paint.stroke(stroke, ui, canvas);
493
533
  }
494
534
 
@@ -618,6 +658,9 @@ let UI = UI_1 = class UI extends Leaf {
618
658
  else
619
659
  drawer.rect(x, y, width, height);
620
660
  }
661
+ drawImagePlaceholder(canvas, _image) {
662
+ Paint.fill(this.__.placeholderColor, this, canvas);
663
+ }
621
664
  animate(_keyframe, _options, _type, _isTemp) {
622
665
  return Plugin.need('animate');
623
666
  }
@@ -854,6 +897,12 @@ __decorate([
854
897
  __decorate([
855
898
  effectType()
856
899
  ], UI.prototype, "filter", void 0);
900
+ __decorate([
901
+ surfaceType()
902
+ ], UI.prototype, "placeholderColor", void 0);
903
+ __decorate([
904
+ dataType(100)
905
+ ], UI.prototype, "placeholderDelay", void 0);
857
906
  __decorate([
858
907
  dataType({})
859
908
  ], UI.prototype, "data", void 0);
@@ -1255,15 +1304,20 @@ let Leafer = Leafer_1 = class Leafer extends Group {
1255
1304
  }
1256
1305
  __listenEvents() {
1257
1306
  const runId = Run.start('FirstCreate ' + this.innerName);
1258
- this.once(LeaferEvent.START, () => Run.end(runId));
1259
- this.once(LayoutEvent.START, () => this.updateLazyBounds());
1260
- this.once(RenderEvent.START, () => this.__onCreated());
1261
- this.once(RenderEvent.END, () => this.__onViewReady());
1262
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
1307
+ this.once([
1308
+ [LeaferEvent.START, () => Run.end(runId)],
1309
+ [LayoutEvent.START, this.updateLazyBounds, this],
1310
+ [RenderEvent.START, this.__onCreated, this],
1311
+ [RenderEvent.END, this.__onViewReady, this]
1312
+ ]);
1313
+ this.__eventIds.push(this.on_([
1314
+ [WatchEvent.DATA, this.__onWatchData, this],
1315
+ [LayoutEvent.END, this.__onLayoutEnd, this],
1316
+ [RenderEvent.NEXT, this.__onNextRender, this]
1317
+ ]));
1263
1318
  }
1264
1319
  __removeListenEvents() {
1265
1320
  this.off_(this.__eventIds);
1266
- this.__eventIds.length = 0;
1267
1321
  }
1268
1322
  destroy(sync) {
1269
1323
  const doDestory = () => {
@@ -1371,13 +1425,13 @@ let Box = class Box extends Group {
1371
1425
  super.__updateRenderBounds();
1372
1426
  copy(childrenRenderBounds, renderBounds);
1373
1427
  this.__updateRectRenderBounds();
1374
- isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
1428
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds);
1375
1429
  if (isOverflow && this.__.overflow !== 'hide')
1376
1430
  add(renderBounds, childrenRenderBounds);
1377
1431
  }
1378
1432
  else
1379
1433
  this.__updateRectRenderBounds();
1380
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
1434
+ DataHelper.stintSet(this, 'isOverflow', isOverflow);
1381
1435
  }
1382
1436
  __updateRectRenderBounds() { }
1383
1437
  __updateRectChange() { }
@@ -1681,17 +1735,10 @@ Star = __decorate([
1681
1735
 
1682
1736
  let Image = class Image extends Rect {
1683
1737
  get __tag() { return 'Image'; }
1684
- get ready() { return this.image ? this.image.ready : false; }
1738
+ get ready() { const { image } = this; return image && image.ready; }
1739
+ get image() { const { fill } = this.__; return fill instanceof Array && fill[0].image; }
1685
1740
  constructor(data) {
1686
1741
  super(data);
1687
- this.on(ImageEvent.LOADED, (e) => {
1688
- if (e.attrName === 'fill' && e.attrValue.url === this.url)
1689
- this.image = e.image;
1690
- });
1691
- }
1692
- destroy() {
1693
- this.image = null;
1694
- super.destroy();
1695
1742
  }
1696
1743
  };
1697
1744
  __decorate([
@@ -1707,11 +1754,11 @@ const MyImage = Image;
1707
1754
 
1708
1755
  let Canvas = class Canvas extends Rect {
1709
1756
  get __tag() { return 'Canvas'; }
1757
+ get context() { return this.canvas.context; }
1710
1758
  get ready() { return !this.url; }
1711
1759
  constructor(data) {
1712
1760
  super(data);
1713
1761
  this.canvas = Creator.canvas(this.__);
1714
- this.context = this.canvas.context;
1715
1762
  if (data && data.url)
1716
1763
  this.drawImage(data.url);
1717
1764
  }
@@ -1755,7 +1802,7 @@ let Canvas = class Canvas extends Rect {
1755
1802
  destroy() {
1756
1803
  if (this.canvas) {
1757
1804
  this.canvas.destroy();
1758
- this.canvas = this.context = null;
1805
+ this.canvas = null;
1759
1806
  }
1760
1807
  super.destroy();
1761
1808
  }
@@ -1801,7 +1848,7 @@ let Text = class Text extends UI {
1801
1848
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
1802
1849
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
1803
1850
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
1804
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
1851
+ data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__);
1805
1852
  }
1806
1853
  __updateBoxBounds() {
1807
1854
  const data = this.__;
@@ -1831,12 +1878,11 @@ let Text = class Text extends UI {
1831
1878
  super.__updateBoxBounds();
1832
1879
  if (italic)
1833
1880
  b.width += fontSize * 0.16;
1834
- const isOverflow = !includes(b, contentBounds) || undefined;
1835
- if (isOverflow)
1881
+ DataHelper.stintSet(this, 'isOverflow', !includes(b, contentBounds));
1882
+ if (this.isOverflow)
1836
1883
  setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
1837
1884
  else
1838
1885
  data.__textBoxBounds = b;
1839
- this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
1840
1886
  }
1841
1887
  __onUpdateSize() {
1842
1888
  if (this.__box)
@@ -1899,6 +1945,9 @@ __decorate([
1899
1945
  __decorate([
1900
1946
  boundsType('')
1901
1947
  ], Text.prototype, "text", void 0);
1948
+ __decorate([
1949
+ boundsType('')
1950
+ ], Text.prototype, "placeholder", void 0);
1902
1951
  __decorate([
1903
1952
  boundsType('caption')
1904
1953
  ], Text.prototype, "fontFamily", void 0);
@@ -2018,4 +2067,3 @@ function penPathType() {
2018
2067
  }
2019
2068
 
2020
2069
  export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, Transition, UI, UIBounds, UIData, UIRender, UnitConvert, effectType, resizeType, zoomLayerType };
2021
- //# sourceMappingURL=draw.esm.js.map
@@ -1,2 +1,2 @@
1
- import{defineKey as t,decorateLeafAttr as e,attr as i,Plugin as s,PathConvert as o,Debug as r,LeafData as a,canvasSizeAttrs as n,UICreator as _,dataProcessor as h,dataType as d,surfaceType as p,opacityType as l,visibleType as u,sortType as c,maskType as y,eraserType as g,positionType as v,boundsType as f,scaleType as w,rotationType as x,autoLayoutType as m,naturalBoundsType as R,pathInputType as S,pathType as k,hitType as b,strokeType as B,cursorType as C,rewrite as A,Leaf as P,useModule as F,rewriteAble as W,MathHelper as E,pen as I,PathCorner as D,PathDrawer as z,DataHelper as L,registerUI as T,Branch as M,LeafList as O,Resource as N,getBoundsData as V,Creator as j,CanvasManager as H,WaitHelper as Y,LeaferEvent as U,Bounds as X,ResizeEvent as q,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as Q,ImageManager as Z,BoundsHelper as tt,affectRenderBoundsType as et,PathCommandDataHelper as it,Platform as st,PointHelper as ot,PathBounds as rt,affectStrokeBoundsType as at,getPointData as nt,ImageEvent as _t,LeaferImage as ht,Matrix as dt,PathCreator as pt}from"@leafer/core";export*from"@leafer/core";function lt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function ut(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function ct(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function yt(){return(e,i)=>{const s="_"+i;t(e,i,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const gt={},vt={},ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},wt={},xt={},mt={},Rt={},St={},kt={apply(){s.need("filter")}},bt={},Bt={setStyleName:()=>s.need("state"),set:()=>s.need("state")},Ct={list:{},register(t,e){Ct.list[t]=e},get:t=>Ct.list[t]},{parse:At,objectToCanvasData:Pt}=o,Ft={},Wt=r.get("UIData");class Et extends a{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasHalf(){const t=this;return t.stroke&&"center"===t.strokeAlign&&t.strokeWidth%2||void 0}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Wt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Wt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){if(this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t){if("object"==typeof t){this.__setInput("fill",t);const e=this.__leaf.__layout;e.boxChanged||e.boxChange(),this.__isFills=!0,this._fill||(this._fill=Ft)}}else this.__isFills&&(this.__removeInput("fill"),mt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t}setStroke(t){if("string"!=typeof t&&t){if("object"==typeof t){this.__setInput("stroke",t);const e=this.__leaf.__layout;e.boxChanged||e.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Ft)}}else this.__isStrokes&&(this.__removeInput("stroke"),mt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?At(t):Pt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){It(this,"shadow",t)}setInnerShadow(t){It(this,"innerShadow",t)}setFilter(t){It(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&xt.compute("fill",this.__leaf),e&&xt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}function It(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=null)):i=i&&!1!==i.visible?[i]:null,t["_"+e]=i}class Dt extends Et{}class zt extends Dt{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class Lt extends Dt{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class Tt extends zt{}class Mt extends Et{}class Ot extends Et{get __boxStroke(){return!this.__pathInputed}}class Nt extends Et{get __boxStroke(){return!this.__pathInputed}}class Vt extends Et{}class jt extends Et{}class Ht extends Et{get __pathInputed(){return 2}}class Yt extends Dt{}const Ut={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Xt extends Et{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Ut[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=_.get("Rect",0);const o=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=o.boxBounds),i.set(t),r.strokeChanged&&o.strokeChange(),r.renderChanged&&o.renderChange(),i.__updateChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class qt extends Ot{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Gt extends Ot{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Jt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i,r=this.__box;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),r&&(t=Math.max(r.__layout.strokeSpread=r.__updateStrokeSpread(),t),e=r.__layout.strokeBoxSpread),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),r&&(t+=kt.getSpread(r));let a=t=Math.ceil(t);return i&&i.forEach((t=>a=Math.max(a,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(a=Math.max(a,o)),this.__layout.renderShapeSpread=a,t+=this.__layout.strokeSpread||0,this.__box?Math.max(this.__box.__updateRenderSpread(),t):t}},$t={__updateChange(){const t=this.__,e=this.__world;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;t.__useEffect=!!(e||i||s||o||r)}const i=t.__hasHalf;e.half!==i&&(e.half=i),t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Kt(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:r,__drawAfterFill:a}=s;if(this.__drawRenderPath(t),s.__useEffect){const n=xt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:h,filter:d}=s;_&&St.shadow(this,t,n),o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),h&&St.innerShadow(this,t,n),r&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),d&&kt.apply(d,this,this.__nowWorld,t,i,n),n.worldCanvas&&n.worldCanvas.recycle(),n.canvas.recycle()}else o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),r&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t))}else s.__pathInputed?Kt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?xt.fills(o,this,t):xt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?xt.strokes(r,this,t):xt.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Kt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&xt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&xt.stroke(o,t,e)}const Qt={__drawFast(t,e){let{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;const{fill:a,stroke:n,__drawAfterFill:_}=this.__;if(a&&(t.fillStyle=a,t.fillRect(i,s,o,r)),_&&this.__drawAfterFill(t,e),n){const{strokeAlign:a,__strokeWidth:_}=this.__;if(!_)return;t.setStroke(n,_,this.__);const h=_/2;switch(a){case"center":t.strokeRect(0,0,o,r);break;case"inside":o-=_,r-=_,o<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+h,s+h,o,r),t.restore()):t.strokeRect(i+h,s+h,o,r);break;case"outside":t.strokeRect(i-h,s-h,o+_,r+_)}}}};var Zt;let te=Zt=class extends P{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){E.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return I.set(this.path=t||[]),t||this.__drawPathByBox(I),I}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return s.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return s.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(I.set(i=[]),this.__drawPathByBox(I)),t?o.toCanvasData(i,!0):i}getPathString(t,e,i){return o.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||bt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?D.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&wt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?z.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s.need("animate")}killAnimate(t,e){}export(t,e){return s.need("export")}syncExport(t,e){return s.need("export")}clone(t){const e=L.clone(this.toJSON());return t&&Object.assign(e,t),Zt.one(e)}static one(t,e,i,s,o){return _.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){h(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};lt([h(Et)],te.prototype,"__",void 0),lt([yt()],te.prototype,"zoomLayer",void 0),lt([d("")],te.prototype,"id",void 0),lt([d("")],te.prototype,"name",void 0),lt([d("")],te.prototype,"className",void 0),lt([p("pass-through")],te.prototype,"blendMode",void 0),lt([l(1)],te.prototype,"opacity",void 0),lt([u(!0)],te.prototype,"visible",void 0),lt([p(!1)],te.prototype,"locked",void 0),lt([p(!1)],te.prototype,"dim",void 0),lt([p(!1)],te.prototype,"dimskip",void 0),lt([c(0)],te.prototype,"zIndex",void 0),lt([y(!1)],te.prototype,"mask",void 0),lt([g(!1)],te.prototype,"eraser",void 0),lt([v(0,!0)],te.prototype,"x",void 0),lt([v(0,!0)],te.prototype,"y",void 0),lt([f(100,!0)],te.prototype,"width",void 0),lt([f(100,!0)],te.prototype,"height",void 0),lt([w(1,!0)],te.prototype,"scaleX",void 0),lt([w(1,!0)],te.prototype,"scaleY",void 0),lt([x(0,!0)],te.prototype,"rotation",void 0),lt([x(0,!0)],te.prototype,"skewX",void 0),lt([x(0,!0)],te.prototype,"skewY",void 0),lt([v(0,!0)],te.prototype,"offsetX",void 0),lt([v(0,!0)],te.prototype,"offsetY",void 0),lt([v(0,!0)],te.prototype,"scrollX",void 0),lt([v(0,!0)],te.prototype,"scrollY",void 0),lt([m()],te.prototype,"origin",void 0),lt([m()],te.prototype,"around",void 0),lt([d(!1)],te.prototype,"lazy",void 0),lt([R(1)],te.prototype,"pixelRatio",void 0),lt([S()],te.prototype,"path",void 0),lt([k()],te.prototype,"windingRule",void 0),lt([k(!0)],te.prototype,"closed",void 0),lt([f(0)],te.prototype,"padding",void 0),lt([f(!1)],te.prototype,"lockRatio",void 0),lt([f()],te.prototype,"widthRange",void 0),lt([f()],te.prototype,"heightRange",void 0),lt([d(!1)],te.prototype,"draggable",void 0),lt([d()],te.prototype,"dragBounds",void 0),lt([d(!1)],te.prototype,"editable",void 0),lt([b(!0)],te.prototype,"hittable",void 0),lt([b("path")],te.prototype,"hitFill",void 0),lt([B("path")],te.prototype,"hitStroke",void 0),lt([b(!1)],te.prototype,"hitBox",void 0),lt([b(!0)],te.prototype,"hitChildren",void 0),lt([b(!0)],te.prototype,"hitSelf",void 0),lt([b()],te.prototype,"hitRadius",void 0),lt([C("")],te.prototype,"cursor",void 0),lt([p()],te.prototype,"fill",void 0),lt([B()],te.prototype,"stroke",void 0),lt([B("inside")],te.prototype,"strokeAlign",void 0),lt([B(1)],te.prototype,"strokeWidth",void 0),lt([B(!1)],te.prototype,"strokeWidthFixed",void 0),lt([B("none")],te.prototype,"strokeCap",void 0),lt([B("miter")],te.prototype,"strokeJoin",void 0),lt([B()],te.prototype,"dashPattern",void 0),lt([B(0)],te.prototype,"dashOffset",void 0),lt([B(10)],te.prototype,"miterLimit",void 0),lt([k(0)],te.prototype,"cornerRadius",void 0),lt([k()],te.prototype,"cornerSmoothing",void 0),lt([ut()],te.prototype,"shadow",void 0),lt([ut()],te.prototype,"innerShadow",void 0),lt([ut()],te.prototype,"blur",void 0),lt([ut()],te.prototype,"backgroundBlur",void 0),lt([ut()],te.prototype,"grayscale",void 0),lt([ut()],te.prototype,"filter",void 0),lt([d({})],te.prototype,"data",void 0),lt([A(P.prototype.reset)],te.prototype,"reset",null),te=Zt=lt([F(Jt),F($t),W()],te);let ee=class extends te{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var ie;lt([h(Dt)],ee.prototype,"__",void 0),lt([f(0)],ee.prototype,"width",void 0),lt([f(0)],ee.prototype,"height",void 0),ee=lt([F(M),T()],ee);const se=r.get("Leafer");let oe=ie=class extends ee{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&N.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||V()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),ie.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,L.assign(s,t));const o=this.canvas=j.canvas(s);this.__controllers.push(this.renderer=j.renderer(this,o,s),this.watcher=j.watcher(this,s),this.layouter=j.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=j.selector(this),this.interaction=j.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=j.hitCanvasManager()),this.canvasManager=new H,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Y.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(U.RESTART):this.emitLeafer(U.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(U.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=L.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=L.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new q(t,i))}__onResize(t){this.emitEvent(t),L.copyAttrs(this.__,t,n),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=L.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(U.BEFORE_READY),this.emitLeafer(U.READY),this.emitLeafer(U.AFTER_READY),Y.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(U.VIEW_READY),Y.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,a.x+a.width)),i||(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Y.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(U.VIEW_COMPLETED),Y.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,o){return s.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new U(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(U.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(Q.DATA,this.__onWatchData,this),this.on_($.END,this.__onLayoutEnd,this),this.on_(K.NEXT,this.__onNextRender,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){ie.list.remove(this);try{this.stop(),this.emitEvent(new U(U.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Z.clearRecycled()}),100)}catch(t){se.error(t)}}};t?e():setTimeout(e)}};oe.list=new O,lt([h(Lt)],oe.prototype,"__",void 0),lt([f()],oe.prototype,"pixelRatio",void 0),oe=ie=lt([T()],oe);let re=class extends te{get __tag(){return"Rect"}constructor(t){super(t)}};lt([h(Ot)],re.prototype,"__",void 0),re=lt([F(Qt),W(),T()],re);const{copy:ae,add:ne,includes:_e}=tt,he=re.prototype,de=ee.prototype,pe={};let le=class extends ee{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length&&!this.pathInputed)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),ae(pe,e),this.__updateRectRenderBounds(),t=!_e(e,pe)||void 0,t&&"hide"!==this.__.overflow&&ne(e,pe)):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};lt([h(zt)],le.prototype,"__",void 0),lt([f(100)],le.prototype,"width",void 0),lt([f(100)],le.prototype,"height",void 0),lt([d(!1)],le.prototype,"resizeChildren",void 0),lt([et("show")],le.prototype,"overflow",void 0),lt([A(he.__updateStrokeSpread)],le.prototype,"__updateStrokeSpread",null),lt([A(he.__updateRenderSpread)],le.prototype,"__updateRectRenderSpread",null),lt([A(he.__updateBoxBounds)],le.prototype,"__updateRectBoxBounds",null),lt([A(he.__updateStrokeBounds)],le.prototype,"__updateStrokeBounds",null),lt([A(he.__updateRenderBounds)],le.prototype,"__updateRectRenderBounds",null),lt([A(he.__updateChange)],le.prototype,"__updateRectChange",null),lt([A(he.__render)],le.prototype,"__renderRect",null),lt([A(de.__render)],le.prototype,"__renderGroup",null),le=lt([W(),T()],le);let ue=class extends le{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};lt([h(Tt)],ue.prototype,"__",void 0),lt([p("#FFFFFF")],ue.prototype,"fill",void 0),lt([et("hide")],ue.prototype,"overflow",void 0),ue=lt([T()],ue);const{moveTo:ce,closePath:ye,ellipse:ge}=it;let ve=class extends te{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&ge(n,r,a,r*i,a*i,0,s,o,!1),ge(n,r,a,r,a,0,o,s,!0),i<1&&ye(n)):(i<1&&(ge(n,r,a,r*i,a*i),ce(n,t,a)),ge(n,r,a,r,a,0,360,0,!0)),st.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(ce(n,r,a),ge(n,r,a,r,a,0,s,o,!1),ye(n)):ge(n,r,a,r,a)}};lt([h(Nt)],ve.prototype,"__",void 0),lt([k(0)],ve.prototype,"innerRadius",void 0),lt([k(0)],ve.prototype,"startAngle",void 0),lt([k(0)],ve.prototype,"endAngle",void 0),ve=lt([T()],ve);const{moveTo:fe,lineTo:we,drawPoints:xe}=it,{rotate:me,getAngle:Re,getDistance:Se,defaultPoint:ke}=ot,{toBounds:be}=rt;let Be=class extends te{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=nt();return t&&(i.x=t),e&&me(i,e),i}set toPoint(t){this.width=Se(ke,t),this.rotation=Re(ke,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?xe(e,t.points,!1,t.closed):(fe(e,0,0),we(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(xe(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&wt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?be(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};lt([h(Mt)],Be.prototype,"__",void 0),lt([at("center")],Be.prototype,"strokeAlign",void 0),lt([f(0)],Be.prototype,"height",void 0),lt([k()],Be.prototype,"points",void 0),lt([k(0)],Be.prototype,"curve",void 0),lt([k(!1)],Be.prototype,"closed",void 0),Be=lt([T()],Be);const{sin:Ce,cos:Ae,PI:Pe}=Math,{moveTo:Fe,lineTo:We,closePath:Ee,drawPoints:Ie}=it,De=Be.prototype;let ze=class extends te{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ie(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;Fe(t,o,0);for(let e=1;e<s;e++)We(t,o+o*Ce(2*e*Pe/s),r-r*Ae(2*e*Pe/s))}Ee(t)}__updateRenderPath(){}__updateBoxBounds(){}};lt([h(Vt)],ze.prototype,"__",void 0),lt([k(3)],ze.prototype,"sides",void 0),lt([k()],ze.prototype,"points",void 0),lt([k(0)],ze.prototype,"curve",void 0),lt([A(De.__updateRenderPath)],ze.prototype,"__updateRenderPath",null),lt([A(De.__updateBoxBounds)],ze.prototype,"__updateBoxBounds",null),ze=lt([W(),T()],ze);const{sin:Le,cos:Te,PI:Me}=Math,{moveTo:Oe,lineTo:Ne,closePath:Ve}=it;let je=class extends te{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Oe(a,o,0);for(let t=1;t<2*i;t++)Ne(a,o+(t%2==0?o:o*s)*Le(t*Me/i),r-(t%2==0?r:r*s)*Te(t*Me/i));Ve(a)}};lt([h(jt)],je.prototype,"__",void 0),lt([k(5)],je.prototype,"corners",void 0),lt([k(.382)],je.prototype,"innerRadius",void 0),je=lt([T()],je);let He=class extends re{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(_t.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};lt([h(qt)],He.prototype,"__",void 0),lt([f("")],He.prototype,"url",void 0),He=lt([T()],He);const Ye=He;let Ue=class extends re{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=j.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new ht({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new _t(_t.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new dt(t.worldTransform).invert(),r=new dt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};lt([h(Gt)],Ue.prototype,"__",void 0),lt([ct(100)],Ue.prototype,"width",void 0),lt([ct(100)],Ue.prototype,"height",void 0),lt([ct(1)],Ue.prototype,"pixelRatio",void 0),lt([ct(!0)],Ue.prototype,"smooth",void 0),lt([d(!1)],Ue.prototype,"safeResize",void 0),lt([ct()],Ue.prototype,"contextSettings",void 0),Ue=lt([T()],Ue);const{copyAndSpread:Xe,includes:qe,spread:Ge,setList:Je}=tt;let $e=class extends te{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}constructor(t){super(t)}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=ft.number(e,o),t.__letterSpacing=ft.number(i,o),t.__padding=h?E.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=gt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,_=e.boxBounds;if(e.contentBounds=n,t.__lineHeight<i&&Ge(n,i/2),r||a){if(_.x=r?n.x:0,_.y=a?n.y:0,_.width=r?n.width:t.width,_.height=a?n.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(_.x-=o,_.width+=i+o),a&&(_.y-=e,_.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(_.width+=.16*i);const h=!qe(_,n)||void 0;h?(Je(t.__textBoxBounds={},[_,n]),e.renderChanged=!0):t.__textBoxBounds=_,this.isOverflow!==h&&(this.isOverflow=h)}__onUpdateSize(){this.__box&&this.__box.__onUpdateSize(),super.__onUpdateSize()}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;Xe(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!bt.running||super.__draw(t,e,i)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};lt([h(Xt)],$e.prototype,"__",void 0),lt([f(0)],$e.prototype,"width",void 0),lt([f(0)],$e.prototype,"height",void 0),lt([p()],$e.prototype,"boxStyle",void 0),lt([d(!1)],$e.prototype,"resizeFontSize",void 0),lt([p("#000000")],$e.prototype,"fill",void 0),lt([at("outside")],$e.prototype,"strokeAlign",void 0),lt([b("all")],$e.prototype,"hitFill",void 0),lt([f("")],$e.prototype,"text",void 0),lt([f("caption")],$e.prototype,"fontFamily",void 0),lt([f(12)],$e.prototype,"fontSize",void 0),lt([f("normal")],$e.prototype,"fontWeight",void 0),lt([f(!1)],$e.prototype,"italic",void 0),lt([f("none")],$e.prototype,"textCase",void 0),lt([f("none")],$e.prototype,"textDecoration",void 0),lt([f(0)],$e.prototype,"letterSpacing",void 0),lt([f({type:"percent",value:1.5})],$e.prototype,"lineHeight",void 0),lt([f(0)],$e.prototype,"paraIndent",void 0),lt([f(0)],$e.prototype,"paraSpacing",void 0),lt([f("x")],$e.prototype,"writingMode",void 0),lt([f("left")],$e.prototype,"textAlign",void 0),lt([f("top")],$e.prototype,"verticalAlign",void 0),lt([f(!0)],$e.prototype,"autoSizeAlign",void 0),lt([f("normal")],$e.prototype,"textWrap",void 0),lt([f("show")],$e.prototype,"textOverflow",void 0),$e=lt([T()],$e);let Ke=class extends te{get __tag(){return"Path"}constructor(t){super(t)}};lt([h(Ht)],Ke.prototype,"__",void 0),lt([at("center")],Ke.prototype,"strokeAlign",void 0),Ke=lt([T()],Ke);let Qe=class extends ee{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ke(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};lt([h(Yt)],Qe.prototype,"__",void 0),lt([(e,i)=>{t(e,i,{get(){return this.__path}})}],Qe.prototype,"path",void 0),Qe=lt([F(pt,["set","path","paint"]),T()],Qe);export{le as Box,zt as BoxData,Ue as Canvas,Gt as CanvasData,vt as ColorConvert,St as Effect,ve as Ellipse,Nt as EllipseData,bt as Export,kt as Filter,ue as Frame,Tt as FrameData,ee as Group,Dt as GroupData,He as Image,qt as ImageData,oe as Leafer,Lt as LeaferData,Be as Line,Mt as LineData,Ye as MyImage,xt as Paint,Rt as PaintGradient,mt as PaintImage,Ke as Path,wt as PathArrow,Ht as PathData,Qe as Pen,Yt as PenData,ze as Polygon,Vt as PolygonData,re as Rect,Ot as RectData,Qt as RectRender,je as Star,jt as StarData,Bt as State,$e as Text,gt as TextConvert,Xt as TextData,Ct as Transition,te as UI,Jt as UIBounds,Et as UIData,$t as UIRender,ft as UnitConvert,ut as effectType,ct as resizeType,yt as zoomLayerType};
1
+ import{defineKey as t,decorateLeafAttr as e,attr as i,Plugin as s,PathConvert as o,DataHelper as r,Debug as a,LeafData as n,canvasSizeAttrs as _,UICreator as h,dataProcessor as d,dataType as p,surfaceType as l,opacityType as u,visibleType as c,sortType as y,maskType as g,eraserType as v,positionType as f,boundsType as w,scaleType as x,rotationType as m,autoLayoutType as R,naturalBoundsType as S,pathInputType as k,pathType as b,hitType as B,strokeType as A,cursorType as C,rewrite as P,Leaf as F,useModule as W,rewriteAble as E,MathHelper as I,pen as T,PathCorner as D,PathDrawer as z,registerUI as L,Branch as M,LeafList as O,Resource as N,getBoundsData as V,Creator as j,CanvasManager as Y,WaitHelper as H,LeaferEvent as U,Bounds as X,ResizeEvent as q,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as Q,ImageManager as Z,BoundsHelper as tt,affectRenderBoundsType as et,PathCommandDataHelper as it,Platform as st,PointHelper as ot,PathBounds as rt,affectStrokeBoundsType as at,getPointData as nt,LeaferImage as _t,ImageEvent as ht,Matrix as dt,PathCreator as pt}from"@leafer/core";export*from"@leafer/core";function lt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function ut(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function ct(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function yt(){return(e,i)=>{const s="_"+i;t(e,i,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const gt={},vt={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},wt={},xt={},mt={},Rt={},St={},kt={apply(){s.need("filter")}},bt={},Bt={setStyleName:()=>s.need("state"),set:()=>s.need("state")},At={list:{},register(t,e){At.list[t]=e},get:t=>At.list[t]},{parse:Ct,objectToCanvasData:Pt}=o,{stintSet:Ft}=r,{hasTransparent:Wt}=vt,Et={},It=a.get("UIData");class Tt extends n{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasHalf(){const t=this;return t.stroke&&"center"===t.strokeAlign&&t.strokeWidth%2||void 0}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,It.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,It.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&this.__setPaint("fill",t):(Ft(this,"__isTransparentFill",Wt(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&this.__setPaint("stroke",t):(Ft(this,"__isTransparentStroke",Wt(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Ct(t):Pt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){Dt(this,"shadow",t)}setInnerShadow(t){Dt(this,"innerShadow",t)}setFilter(t){Dt(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&xt.compute("fill",this.__leaf),e&&xt.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),e instanceof Array&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=Et)):(this.__isStrokes=!0,this._stroke||(this._stroke=Et))}__removePaint(t,e){e&&this.__removeInput(t),mt.recycleImage(t,this),"fill"===t?(Ft(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(Ft(this,"__isAlphaPixelStroke",void 0),this._stroke=this.__isStrokes=void 0)}}function Dt(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}class zt extends Tt{}class Lt extends zt{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class Mt extends zt{__getInputData(t,e){const i=super.__getInputData(t,e);return _.forEach((t=>delete i[t])),i}}class Ot extends Lt{}class Nt extends Tt{}class Vt extends Tt{get __boxStroke(){return!this.__pathInputed}}class jt extends Tt{get __boxStroke(){return!this.__pathInputed}}class Yt extends Tt{}class Ht extends Tt{}class Ut extends Tt{get __pathInputed(){return 2}}class Xt extends zt{}const qt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Gt extends Tt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),t=qt[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=h.get("Rect",0);const o=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=o.boxBounds),i.set(t),r.strokeChanged&&o.strokeChange(),r.renderChanged&&o.renderChange(),i.__updateChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class Jt extends Vt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class $t extends Vt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Kt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i,r=this.__box;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),r&&(t=Math.max(r.__layout.strokeSpread=r.__updateStrokeSpread(),t),e=r.__layout.strokeBoxSpread),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),r&&(t+=kt.getSpread(r));let a=t=Math.ceil(t);return i&&i.forEach((t=>a=Math.max(a,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(a=Math.max(a,o)),this.__layout.renderShapeSpread=a,t+=this.__layout.strokeSpread||0,this.__box?Math.max(this.__box.__updateRenderSpread(),t):t}},{stintSet:Qt}=r,Zt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,o=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Qt(t,"__isFastShadow",e&&!o&&e.length<2&&!e[0].spread&&!(e[0].box&&t.__isTransparentFill)&&i&&!(i instanceof Array&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!o)}Qt(this.__world,"half",t.__hasHalf),Qt(t,"__fillAfterStroke",t.stroke&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill),t.__checkSingle(),Qt(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){te(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:r,__drawAfterFill:a,__fillAfterStroke:n,__isFastShadow:_}=s;if(this.__drawRenderPath(t),s.__useEffect&&!_){const _=xt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:d,filter:p}=s;h&&St.shadow(this,t,_),n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),d&&St.innerShadow(this,t,_),r&&!n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),p&&kt.apply(p,this,this.__nowWorld,t,i,_),_.worldCanvas&&_.worldCanvas.recycle(),_.canvas.recycle()}else{if(n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),_){const e=s.shadow[0],{scaleX:i,scaleY:o}=this.__nowWorld;t.save(),t.setWorldShadow(e.x*i,e.y*o,e.blur*i,vt.string(e.color))}o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),_&&t.restore(),a&&this.__drawAfterFill(t,e),r&&!n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t))}}else s.__pathInputed?te(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__isAlphaPixelFill?xt.fills(o,this,t):xt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__isAlphaPixelStroke?xt.strokes(r,this,t):xt.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function te(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r,__fillAfterStroke:a}=t.__;t.__drawRenderPath(e),a&&xt.stroke(o,t,e),s&&xt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&!a&&xt.stroke(o,t,e)}const ee={__drawFast(t,e){let{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;const{fill:a,stroke:n,__drawAfterFill:_}=this.__;if(a&&(t.fillStyle=a,t.fillRect(i,s,o,r)),_&&this.__drawAfterFill(t,e),n){const{strokeAlign:a,__strokeWidth:_}=this.__;if(!_)return;t.setStroke(n,_,this.__);const h=_/2;switch(a){case"center":t.strokeRect(0,0,o,r);break;case"inside":o-=_,r-=_,o<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+h,s+h,o,r),t.restore()):t.strokeRect(i+h,s+h,o,r);break;case"outside":t.strokeRect(i-h,s-h,o+_,r+_)}}}};var ie;let se=ie=class extends F{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){I.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return T.set(this.path=t||[]),t||this.__drawPathByBox(T),T}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return s.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return s.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(T.set(i=[]),this.__drawPathByBox(T)),t?o.toCanvasData(i,!0):i}getPathString(t,e,i){return o.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||bt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?D.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&wt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?z.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}drawImagePlaceholder(t,e){xt.fill(this.__.placeholderColor,this,t)}animate(t,e,i,o){return s.need("animate")}killAnimate(t,e){}export(t,e){return s.need("export")}syncExport(t,e){return s.need("export")}clone(t){const e=r.clone(this.toJSON());return t&&Object.assign(e,t),ie.one(e)}static one(t,e,i,s,o){return h.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){L()(this)}static registerData(t){d(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};lt([d(Tt)],se.prototype,"__",void 0),lt([yt()],se.prototype,"zoomLayer",void 0),lt([p("")],se.prototype,"id",void 0),lt([p("")],se.prototype,"name",void 0),lt([p("")],se.prototype,"className",void 0),lt([l("pass-through")],se.prototype,"blendMode",void 0),lt([u(1)],se.prototype,"opacity",void 0),lt([c(!0)],se.prototype,"visible",void 0),lt([l(!1)],se.prototype,"locked",void 0),lt([l(!1)],se.prototype,"dim",void 0),lt([l(!1)],se.prototype,"dimskip",void 0),lt([y(0)],se.prototype,"zIndex",void 0),lt([g(!1)],se.prototype,"mask",void 0),lt([v(!1)],se.prototype,"eraser",void 0),lt([f(0,!0)],se.prototype,"x",void 0),lt([f(0,!0)],se.prototype,"y",void 0),lt([w(100,!0)],se.prototype,"width",void 0),lt([w(100,!0)],se.prototype,"height",void 0),lt([x(1,!0)],se.prototype,"scaleX",void 0),lt([x(1,!0)],se.prototype,"scaleY",void 0),lt([m(0,!0)],se.prototype,"rotation",void 0),lt([m(0,!0)],se.prototype,"skewX",void 0),lt([m(0,!0)],se.prototype,"skewY",void 0),lt([f(0,!0)],se.prototype,"offsetX",void 0),lt([f(0,!0)],se.prototype,"offsetY",void 0),lt([f(0,!0)],se.prototype,"scrollX",void 0),lt([f(0,!0)],se.prototype,"scrollY",void 0),lt([R()],se.prototype,"origin",void 0),lt([R()],se.prototype,"around",void 0),lt([p(!1)],se.prototype,"lazy",void 0),lt([S(1)],se.prototype,"pixelRatio",void 0),lt([k()],se.prototype,"path",void 0),lt([b()],se.prototype,"windingRule",void 0),lt([b(!0)],se.prototype,"closed",void 0),lt([w(0)],se.prototype,"padding",void 0),lt([w(!1)],se.prototype,"lockRatio",void 0),lt([w()],se.prototype,"widthRange",void 0),lt([w()],se.prototype,"heightRange",void 0),lt([p(!1)],se.prototype,"draggable",void 0),lt([p()],se.prototype,"dragBounds",void 0),lt([p(!1)],se.prototype,"editable",void 0),lt([B(!0)],se.prototype,"hittable",void 0),lt([B("path")],se.prototype,"hitFill",void 0),lt([A("path")],se.prototype,"hitStroke",void 0),lt([B(!1)],se.prototype,"hitBox",void 0),lt([B(!0)],se.prototype,"hitChildren",void 0),lt([B(!0)],se.prototype,"hitSelf",void 0),lt([B()],se.prototype,"hitRadius",void 0),lt([C("")],se.prototype,"cursor",void 0),lt([l()],se.prototype,"fill",void 0),lt([A()],se.prototype,"stroke",void 0),lt([A("inside")],se.prototype,"strokeAlign",void 0),lt([A(1)],se.prototype,"strokeWidth",void 0),lt([A(!1)],se.prototype,"strokeWidthFixed",void 0),lt([A("none")],se.prototype,"strokeCap",void 0),lt([A("miter")],se.prototype,"strokeJoin",void 0),lt([A()],se.prototype,"dashPattern",void 0),lt([A(0)],se.prototype,"dashOffset",void 0),lt([A(10)],se.prototype,"miterLimit",void 0),lt([b(0)],se.prototype,"cornerRadius",void 0),lt([b()],se.prototype,"cornerSmoothing",void 0),lt([ut()],se.prototype,"shadow",void 0),lt([ut()],se.prototype,"innerShadow",void 0),lt([ut()],se.prototype,"blur",void 0),lt([ut()],se.prototype,"backgroundBlur",void 0),lt([ut()],se.prototype,"grayscale",void 0),lt([ut()],se.prototype,"filter",void 0),lt([l()],se.prototype,"placeholderColor",void 0),lt([p(100)],se.prototype,"placeholderDelay",void 0),lt([p({})],se.prototype,"data",void 0),lt([P(F.prototype.reset)],se.prototype,"reset",null),se=ie=lt([W(Kt),W(Zt),E()],se);let oe=class extends se{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var re;lt([d(zt)],oe.prototype,"__",void 0),lt([w(0)],oe.prototype,"width",void 0),lt([w(0)],oe.prototype,"height",void 0),oe=lt([W(M),L()],oe);const ae=a.get("Leafer");let ne=re=class extends oe{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&N.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||V()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),re.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,r.assign(s,t));const o=this.canvas=j.canvas(s);this.__controllers.push(this.renderer=j.renderer(this,o,s),this.watcher=j.watcher(this,s),this.layouter=j.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=j.selector(this),this.interaction=j.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=j.hitCanvasManager()),this.canvasManager=new Y,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(U.RESTART):this.emitLeafer(U.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(U.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=r.copyAttrs({},t,_);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=r.copyAttrs({},this.canvas,_);e.resize(t),this.updateLazyBounds(),this.__onResize(new q(t,i))}__onResize(t){this.emitEvent(t),r.copyAttrs(this.__,t,_),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(_.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&_.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=r.copyAttrs({},this.canvas,_);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(U.BEFORE_READY),this.emitLeafer(U.READY),this.emitLeafer(U.AFTER_READY),H.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(U.VIEW_READY),H.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,a.x+a.width)),i||(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(U.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,o){return s.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new U(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once([[U.START,()=>J.end(t)],[$.START,this.updateLazyBounds,this],[K.START,this.__onCreated,this],[K.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Q.DATA,this.__onWatchData,this],[$.END,this.__onLayoutEnd,this],[K.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){re.list.remove(this);try{this.stop(),this.emitEvent(new U(U.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Z.clearRecycled()}),100)}catch(t){ae.error(t)}}};t?e():setTimeout(e)}};ne.list=new O,lt([d(Mt)],ne.prototype,"__",void 0),lt([w()],ne.prototype,"pixelRatio",void 0),ne=re=lt([L()],ne);let _e=class extends se{get __tag(){return"Rect"}constructor(t){super(t)}};lt([d(Vt)],_e.prototype,"__",void 0),_e=lt([W(ee),E(),L()],_e);const{copy:he,add:de,includes:pe}=tt,le=_e.prototype,ue=oe.prototype,ce={};let ye=class extends oe{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length&&!this.pathInputed)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),he(ce,e),this.__updateRectRenderBounds(),t=!pe(e,ce),t&&"hide"!==this.__.overflow&&de(e,ce)):this.__updateRectRenderBounds(),r.stintSet(this,"isOverflow",t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};lt([d(Lt)],ye.prototype,"__",void 0),lt([w(100)],ye.prototype,"width",void 0),lt([w(100)],ye.prototype,"height",void 0),lt([p(!1)],ye.prototype,"resizeChildren",void 0),lt([et("show")],ye.prototype,"overflow",void 0),lt([P(le.__updateStrokeSpread)],ye.prototype,"__updateStrokeSpread",null),lt([P(le.__updateRenderSpread)],ye.prototype,"__updateRectRenderSpread",null),lt([P(le.__updateBoxBounds)],ye.prototype,"__updateRectBoxBounds",null),lt([P(le.__updateStrokeBounds)],ye.prototype,"__updateStrokeBounds",null),lt([P(le.__updateRenderBounds)],ye.prototype,"__updateRectRenderBounds",null),lt([P(le.__updateChange)],ye.prototype,"__updateRectChange",null),lt([P(le.__render)],ye.prototype,"__renderRect",null),lt([P(ue.__render)],ye.prototype,"__renderGroup",null),ye=lt([E(),L()],ye);let ge=class extends ye{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};lt([d(Ot)],ge.prototype,"__",void 0),lt([l("#FFFFFF")],ge.prototype,"fill",void 0),lt([et("hide")],ge.prototype,"overflow",void 0),ge=lt([L()],ge);const{moveTo:ve,closePath:fe,ellipse:we}=it;let xe=class extends se{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&we(n,r,a,r*i,a*i,0,s,o,!1),we(n,r,a,r,a,0,o,s,!0),i<1&&fe(n)):(i<1&&(we(n,r,a,r*i,a*i),ve(n,t,a)),we(n,r,a,r,a,0,360,0,!0)),st.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(ve(n,r,a),we(n,r,a,r,a,0,s,o,!1),fe(n)):we(n,r,a,r,a)}};lt([d(jt)],xe.prototype,"__",void 0),lt([b(0)],xe.prototype,"innerRadius",void 0),lt([b(0)],xe.prototype,"startAngle",void 0),lt([b(0)],xe.prototype,"endAngle",void 0),xe=lt([L()],xe);const{moveTo:me,lineTo:Re,drawPoints:Se}=it,{rotate:ke,getAngle:be,getDistance:Be,defaultPoint:Ae}=ot,{toBounds:Ce}=rt;let Pe=class extends se{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=nt();return t&&(i.x=t),e&&ke(i,e),i}set toPoint(t){this.width=Be(Ae,t),this.rotation=be(Ae,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Se(e,t.points,!1,t.closed):(me(e,0,0),Re(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Se(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&wt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?Ce(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};lt([d(Nt)],Pe.prototype,"__",void 0),lt([at("center")],Pe.prototype,"strokeAlign",void 0),lt([w(0)],Pe.prototype,"height",void 0),lt([b()],Pe.prototype,"points",void 0),lt([b(0)],Pe.prototype,"curve",void 0),lt([b(!1)],Pe.prototype,"closed",void 0),Pe=lt([L()],Pe);const{sin:Fe,cos:We,PI:Ee}=Math,{moveTo:Ie,lineTo:Te,closePath:De,drawPoints:ze}=it,Le=Pe.prototype;let Me=class extends se{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)ze(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;Ie(t,o,0);for(let e=1;e<s;e++)Te(t,o+o*Fe(2*e*Ee/s),r-r*We(2*e*Ee/s))}De(t)}__updateRenderPath(){}__updateBoxBounds(){}};lt([d(Yt)],Me.prototype,"__",void 0),lt([b(3)],Me.prototype,"sides",void 0),lt([b()],Me.prototype,"points",void 0),lt([b(0)],Me.prototype,"curve",void 0),lt([P(Le.__updateRenderPath)],Me.prototype,"__updateRenderPath",null),lt([P(Le.__updateBoxBounds)],Me.prototype,"__updateBoxBounds",null),Me=lt([E(),L()],Me);const{sin:Oe,cos:Ne,PI:Ve}=Math,{moveTo:je,lineTo:Ye,closePath:He}=it;let Ue=class extends se{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];je(a,o,0);for(let t=1;t<2*i;t++)Ye(a,o+(t%2==0?o:o*s)*Oe(t*Ve/i),r-(t%2==0?r:r*s)*Ne(t*Ve/i));He(a)}};lt([d(Ht)],Ue.prototype,"__",void 0),lt([b(5)],Ue.prototype,"corners",void 0),lt([b(.382)],Ue.prototype,"innerRadius",void 0),Ue=lt([L()],Ue);let Xe=class extends _e{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return t instanceof Array&&t[0].image}constructor(t){super(t)}};lt([d(Jt)],Xe.prototype,"__",void 0),lt([w("")],Xe.prototype,"url",void 0),Xe=lt([L()],Xe);const qe=Xe;let Ge=class extends _e{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=j.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new _t({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new ht(ht.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new dt(t.worldTransform).invert(),r=new dt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}};lt([d($t)],Ge.prototype,"__",void 0),lt([ct(100)],Ge.prototype,"width",void 0),lt([ct(100)],Ge.prototype,"height",void 0),lt([ct(1)],Ge.prototype,"pixelRatio",void 0),lt([ct(!0)],Ge.prototype,"smooth",void 0),lt([p(!1)],Ge.prototype,"safeResize",void 0),lt([ct()],Ge.prototype,"contextSettings",void 0),Ge=lt([L()],Ge);const{copyAndSpread:Je,includes:$e,spread:Ke,setList:Qe}=tt;let Ze=class extends se{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}constructor(t){super(t)}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=ft.number(e,o),t.__letterSpacing=ft.number(i,o),t.__padding=h?I.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=gt.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:a,__autoHeight:n}=t;this.__updateTextDrawData();const{bounds:_}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=_,t.__lineHeight<i&&Ke(_,i/2),a||n){if(h.x=a?_.x:0,h.y=n?_.y:0,h.width=a?_.width:t.width,h.height=n?_.height:t.height,o){const[e,i,s,o]=t.__padding;a&&(h.x-=o,h.width+=i+o),n&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),r.stintSet(this,"isOverflow",!$e(h,_)),this.isOverflow?(Qe(t.__textBoxBounds={},[h,_]),e.renderChanged=!0):t.__textBoxBounds=h}__onUpdateSize(){this.__box&&this.__box.__onUpdateSize(),super.__onUpdateSize()}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;Je(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!bt.running||super.__draw(t,e,i)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};lt([d(Gt)],Ze.prototype,"__",void 0),lt([w(0)],Ze.prototype,"width",void 0),lt([w(0)],Ze.prototype,"height",void 0),lt([l()],Ze.prototype,"boxStyle",void 0),lt([p(!1)],Ze.prototype,"resizeFontSize",void 0),lt([l("#000000")],Ze.prototype,"fill",void 0),lt([at("outside")],Ze.prototype,"strokeAlign",void 0),lt([B("all")],Ze.prototype,"hitFill",void 0),lt([w("")],Ze.prototype,"text",void 0),lt([w("")],Ze.prototype,"placeholder",void 0),lt([w("caption")],Ze.prototype,"fontFamily",void 0),lt([w(12)],Ze.prototype,"fontSize",void 0),lt([w("normal")],Ze.prototype,"fontWeight",void 0),lt([w(!1)],Ze.prototype,"italic",void 0),lt([w("none")],Ze.prototype,"textCase",void 0),lt([w("none")],Ze.prototype,"textDecoration",void 0),lt([w(0)],Ze.prototype,"letterSpacing",void 0),lt([w({type:"percent",value:1.5})],Ze.prototype,"lineHeight",void 0),lt([w(0)],Ze.prototype,"paraIndent",void 0),lt([w(0)],Ze.prototype,"paraSpacing",void 0),lt([w("x")],Ze.prototype,"writingMode",void 0),lt([w("left")],Ze.prototype,"textAlign",void 0),lt([w("top")],Ze.prototype,"verticalAlign",void 0),lt([w(!0)],Ze.prototype,"autoSizeAlign",void 0),lt([w("normal")],Ze.prototype,"textWrap",void 0),lt([w("show")],Ze.prototype,"textOverflow",void 0),Ze=lt([L()],Ze);let ti=class extends se{get __tag(){return"Path"}constructor(t){super(t)}};lt([d(Ut)],ti.prototype,"__",void 0),lt([at("center")],ti.prototype,"strokeAlign",void 0),ti=lt([L()],ti);let ei=class extends oe{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new ti(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};lt([d(Xt)],ei.prototype,"__",void 0),lt([(e,i)=>{t(e,i,{get(){return this.__path}})}],ei.prototype,"path",void 0),ei=lt([W(pt,["set","path","paint"]),L()],ei);export{ye as Box,Lt as BoxData,Ge as Canvas,$t as CanvasData,vt as ColorConvert,St as Effect,xe as Ellipse,jt as EllipseData,bt as Export,kt as Filter,ge as Frame,Ot as FrameData,oe as Group,zt as GroupData,Xe as Image,Jt as ImageData,ne as Leafer,Mt as LeaferData,Pe as Line,Nt as LineData,qe as MyImage,xt as Paint,Rt as PaintGradient,mt as PaintImage,ti as Path,wt as PathArrow,Ut as PathData,ei as Pen,Xt as PenData,Me as Polygon,Yt as PolygonData,_e as Rect,Vt as RectData,ee as RectRender,Ue as Star,Ht as StarData,Bt as State,Ze as Text,gt as TextConvert,Gt as TextData,At as Transition,se as UI,Kt as UIBounds,Tt as UIData,Zt as UIRender,ft as UnitConvert,ut as effectType,ct as resizeType,yt as zoomLayerType};
2
2
  //# sourceMappingURL=draw.esm.min.js.map