@leafer-ui/draw 1.0.0-rc.16 → 1.0.0-rc.18

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.cjs CHANGED
@@ -31,14 +31,36 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
31
31
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
32
  };
33
33
 
34
+ const TextConvert = {};
35
+ const ColorConvert = {};
36
+ const PathArrow = {};
37
+ const Paint = {};
38
+ const PaintImage = {};
39
+ const PaintGradient = {};
40
+ const Effect = {};
41
+ const Export = {};
42
+ const State = {};
43
+
44
+ function stateType(defaultValue) {
45
+ return (target, key) => {
46
+ const stateType = key + 'Style';
47
+ core.defineLeafAttr(target, key, defaultValue, {
48
+ set(value) {
49
+ this.__setAttr(key, value);
50
+ this.waitLeafer(() => { if (State.setStyle)
51
+ State.setStyle(this, stateType, value); });
52
+ }
53
+ });
54
+ };
55
+ }
34
56
  function arrowType(defaultValue) {
35
57
  return (target, key) => {
36
58
  core.defineLeafAttr(target, key, defaultValue, {
37
59
  set(value) {
38
60
  this.__setAttr(key, value);
39
- core.doStrokeType(this);
40
61
  const data = this.__;
41
62
  data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
63
+ core.doStrokeType(this);
42
64
  }
43
65
  });
44
66
  };
@@ -66,15 +88,16 @@ function resizeType(defaultValue) {
66
88
  });
67
89
  };
68
90
  }
69
-
70
- const TextConvert = {};
71
- const ColorConvert = {};
72
- const PathArrow = {};
73
- const Paint = {};
74
- const PaintImage = {};
75
- const PaintGradient = {};
76
- const Effect = {};
77
- const Export = {};
91
+ function zoomLayerType() {
92
+ return (target, key) => {
93
+ const privateKey = '_' + key;
94
+ core.defineKey(target, key, {
95
+ set(value) { if (this.isLeafer)
96
+ this[privateKey] = value; },
97
+ get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
98
+ });
99
+ };
100
+ }
78
101
 
79
102
  const { parse } = core.PathConvert;
80
103
  const emptyPaint = {};
@@ -83,7 +106,7 @@ class UIData extends core.LeafData {
83
106
  get __strokeWidth() {
84
107
  const { strokeWidth, strokeWidthFixed } = this;
85
108
  if (strokeWidthFixed) {
86
- let { scaleX } = this.__leaf.__world;
109
+ let { scaleX } = this.__leaf.__nowWorld;
87
110
  if (scaleX < 0)
88
111
  scaleX = -scaleX;
89
112
  return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
@@ -357,18 +380,11 @@ const UIRender = {
357
380
  }
358
381
  },
359
382
  __drawFast(canvas, options) {
360
- const { fill, stroke, __drawAfterFill } = this.__;
361
- this.__drawRenderPath(canvas);
362
- if (fill)
363
- Paint.fill(fill, this, canvas);
364
- if (__drawAfterFill)
365
- this.__drawAfterFill(canvas, options);
366
- if (stroke)
367
- Paint.stroke(stroke, this, canvas);
383
+ drawFast(this, canvas, options);
368
384
  },
369
385
  __draw(canvas, options) {
370
- if (this.__.__complex) {
371
- const data = this.__;
386
+ const data = this.__;
387
+ if (data.__complex) {
372
388
  if (data.__needComputePaint)
373
389
  data.__computePaint();
374
390
  const { fill, stroke, __drawAfterFill } = data;
@@ -401,7 +417,12 @@ const UIRender = {
401
417
  }
402
418
  }
403
419
  else {
404
- this.__drawFast(canvas, options);
420
+ if (data.__pathInputed) {
421
+ drawFast(this, canvas, options);
422
+ }
423
+ else {
424
+ this.__drawFast(canvas, options);
425
+ }
405
426
  }
406
427
  },
407
428
  __renderShape(canvas, options) {
@@ -416,6 +437,16 @@ const UIRender = {
416
437
  }
417
438
  }
418
439
  };
440
+ function drawFast(ui, canvas, options) {
441
+ const { fill, stroke, __drawAfterFill } = ui.__;
442
+ ui.__drawRenderPath(canvas);
443
+ if (fill)
444
+ Paint.fill(fill, ui, canvas);
445
+ if (__drawAfterFill)
446
+ ui.__drawAfterFill(canvas, options);
447
+ if (stroke)
448
+ Paint.stroke(stroke, ui, canvas);
449
+ }
419
450
 
420
451
  const RectRender = {
421
452
  __drawFast(canvas, options) {
@@ -464,6 +495,10 @@ exports.UI = UI_1 = class UI extends core.Leaf {
464
495
  const { scaleX, scaleY } = this;
465
496
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
466
497
  }
498
+ get pen() {
499
+ core.pen.set(this.path = this.__.path || []);
500
+ return core.pen;
501
+ }
467
502
  constructor(data) {
468
503
  super(data);
469
504
  }
@@ -472,7 +507,7 @@ exports.UI = UI_1 = class UI extends core.Leaf {
472
507
  Object.assign(this, data);
473
508
  }
474
509
  get(name) {
475
- return name ? this.__.__getInput(name) : this.__.__getInputData();
510
+ return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
476
511
  }
477
512
  createProxyData() { return undefined; }
478
513
  find(_condition, _options) { return undefined; }
@@ -481,10 +516,11 @@ exports.UI = UI_1 = class UI extends core.Leaf {
481
516
  this.__layout.update();
482
517
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
483
518
  if (!path) {
484
- path = [];
485
519
  const { width, height } = this.boxBounds;
486
- if (width || height)
487
- this.__drawPathByBox(new core.PathCreator(path));
520
+ if (width || height) {
521
+ core.pen.set(path = []);
522
+ this.__drawPathByBox(core.pen);
523
+ }
488
524
  }
489
525
  return curve ? core.PathConvert.toCanvasData(path, true) : path;
490
526
  }
@@ -556,6 +592,9 @@ exports.UI = UI_1 = class UI extends core.Leaf {
556
592
  __decorate([
557
593
  core.dataProcessor(UIData)
558
594
  ], exports.UI.prototype, "__", void 0);
595
+ __decorate([
596
+ zoomLayerType()
597
+ ], exports.UI.prototype, "zoomLayer", void 0);
559
598
  __decorate([
560
599
  core.dataType('')
561
600
  ], exports.UI.prototype, "id", void 0);
@@ -574,6 +613,12 @@ __decorate([
574
613
  __decorate([
575
614
  core.opacityType(true)
576
615
  ], exports.UI.prototype, "visible", void 0);
616
+ __decorate([
617
+ stateType(false)
618
+ ], exports.UI.prototype, "selected", void 0);
619
+ __decorate([
620
+ stateType(false)
621
+ ], exports.UI.prototype, "disabled", void 0);
577
622
  __decorate([
578
623
  core.dataType(false)
579
624
  ], exports.UI.prototype, "locked", void 0);
@@ -721,6 +766,24 @@ __decorate([
721
766
  __decorate([
722
767
  effectType()
723
768
  ], exports.UI.prototype, "grayscale", void 0);
769
+ __decorate([
770
+ core.dataType()
771
+ ], exports.UI.prototype, "normalStyle", void 0);
772
+ __decorate([
773
+ core.dataType()
774
+ ], exports.UI.prototype, "hoverStyle", void 0);
775
+ __decorate([
776
+ core.dataType()
777
+ ], exports.UI.prototype, "pressStyle", void 0);
778
+ __decorate([
779
+ core.dataType()
780
+ ], exports.UI.prototype, "focusStyle", void 0);
781
+ __decorate([
782
+ core.dataType()
783
+ ], exports.UI.prototype, "selectedStyle", void 0);
784
+ __decorate([
785
+ core.dataType()
786
+ ], exports.UI.prototype, "disabledStyle", void 0);
724
787
  __decorate([
725
788
  core.rewrite(core.Leaf.prototype.reset)
726
789
  ], exports.UI.prototype, "reset", null);
@@ -757,7 +820,7 @@ exports.Group = class Group extends exports.UI {
757
820
  super.set(data);
758
821
  let child;
759
822
  children.forEach(childData => {
760
- child = core.UICreator.get(childData.tag, childData);
823
+ child = childData.__ ? childData : core.UICreator.get(childData.tag, childData);
761
824
  this.add(child);
762
825
  });
763
826
  data.children = children;
@@ -806,7 +869,6 @@ exports.Leafer = class Leafer extends exports.Group {
806
869
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
807
870
  constructor(userConfig, data) {
808
871
  super(data);
809
- this.zoomLayer = this;
810
872
  this.config = {
811
873
  type: 'design',
812
874
  start: true,
@@ -819,7 +881,6 @@ exports.Leafer = class Leafer extends exports.Group {
819
881
  move: {
820
882
  holdSpaceKey: true,
821
883
  holdMiddleKey: true,
822
- dragOut: true,
823
884
  autoDistance: 2
824
885
  }
825
886
  };
@@ -950,9 +1011,6 @@ exports.Leafer = class Leafer extends exports.Group {
950
1011
  this.leafer = leafer;
951
1012
  this.__level = 1;
952
1013
  }
953
- setZoomLayer(zoomLayer) {
954
- this.zoomLayer = zoomLayer;
955
- }
956
1014
  __checkAutoLayout(config) {
957
1015
  if (!config.width || !config.height) {
958
1016
  this.autoLayout = new core.AutoBounds(config);
@@ -1038,13 +1096,19 @@ exports.Leafer = class Leafer extends exports.Group {
1038
1096
  this.nextRender(() => this.interaction.updateCursor());
1039
1097
  }
1040
1098
  }
1041
- waitReady(item) {
1099
+ waitReady(item, bind) {
1100
+ if (bind)
1101
+ item = item.bind(bind);
1042
1102
  this.ready ? item() : this.__readyWait.push(item);
1043
1103
  }
1044
- waitViewReady(item) {
1104
+ waitViewReady(item, bind) {
1105
+ if (bind)
1106
+ item = item.bind(bind);
1045
1107
  this.viewReady ? item() : this.__viewReadyWait.push(item);
1046
1108
  }
1047
- waitViewCompleted(item) {
1109
+ waitViewCompleted(item, bind) {
1110
+ if (bind)
1111
+ item = item.bind(bind);
1048
1112
  this.__viewCompletedWait.push(item);
1049
1113
  if (this.viewCompleted) {
1050
1114
  this.__checkViewCompleted(false);
@@ -1054,7 +1118,9 @@ exports.Leafer = class Leafer extends exports.Group {
1054
1118
  this.start();
1055
1119
  }
1056
1120
  }
1057
- nextRender(item, off) {
1121
+ nextRender(item, bind, off) {
1122
+ if (bind)
1123
+ item = item.bind(bind);
1058
1124
  const list = this.__nextRenderWait;
1059
1125
  if (off) {
1060
1126
  for (let i = 0; i < list.length; i++) {
@@ -1068,6 +1134,15 @@ exports.Leafer = class Leafer extends exports.Group {
1068
1134
  list.push(item);
1069
1135
  }
1070
1136
  }
1137
+ zoom(_zoomType, _padding, _fixedScale) { return undefined; }
1138
+ validScale(changeScale) {
1139
+ const { scaleX } = this.zoomLayer.__, { min, max } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
1140
+ if (absScale < min)
1141
+ changeScale = min / scaleX;
1142
+ else if (absScale > max)
1143
+ changeScale = max / scaleX;
1144
+ return changeScale;
1145
+ }
1071
1146
  __checkUpdateLayout() {
1072
1147
  this.__layout.update();
1073
1148
  }
@@ -1835,6 +1910,7 @@ exports.PolygonData = PolygonData;
1835
1910
  exports.RectData = RectData;
1836
1911
  exports.RectRender = RectRender;
1837
1912
  exports.StarData = StarData;
1913
+ exports.State = State;
1838
1914
  exports.TextConvert = TextConvert;
1839
1915
  exports.TextData = TextData;
1840
1916
  exports.UIBounds = UIBounds;
@@ -1844,6 +1920,8 @@ exports.UnitConvert = UnitConvert;
1844
1920
  exports.arrowType = arrowType;
1845
1921
  exports.effectType = effectType;
1846
1922
  exports.resizeType = resizeType;
1923
+ exports.stateType = stateType;
1924
+ exports.zoomLayerType = zoomLayerType;
1847
1925
  Object.keys(core).forEach(function (k) {
1848
1926
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1849
1927
  enumerable: true,
package/lib/draw.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineLeafAttr, doStrokeType, Debug, LeafData, PathConvert, OneRadian, dataProcessor, dataType, surfaceType, opacityType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, naturalBoundsType, pathInputType, pathType, rewrite, Leaf, useModule, rewriteAble, PathCreator, PathCorner, PathDrawer, UICreator, registerUI, Branch, ImageManager, DataHelper, Creator, CanvasManager, LeaferEvent, canvasSizeAttrs, Bounds, ResizeEvent, AutoBounds, WaitHelper, Run, LayoutEvent, RenderEvent, WatchEvent, affectRenderBoundsType, BoundsHelper, Platform, PathCommandDataHelper, affectStrokeBoundsType, getPointData, PointHelper, PathBounds, ImageEvent, Matrix, MathHelper, defineKey } from '@leafer/core';
1
+ import { defineLeafAttr, doStrokeType, defineKey, Debug, LeafData, PathConvert, OneRadian, dataProcessor, dataType, surfaceType, opacityType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, naturalBoundsType, pathInputType, pathType, rewrite, Leaf, useModule, rewriteAble, pen, PathCorner, PathDrawer, UICreator, registerUI, Branch, ImageManager, DataHelper, Creator, CanvasManager, LeaferEvent, canvasSizeAttrs, Bounds, ResizeEvent, AutoBounds, WaitHelper, Run, LayoutEvent, RenderEvent, WatchEvent, affectRenderBoundsType, BoundsHelper, Platform, PathCommandDataHelper, affectStrokeBoundsType, getPointData, PointHelper, PathBounds, ImageEvent, Matrix, MathHelper, PathCreator } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
 
4
4
  /******************************************************************************
@@ -30,14 +30,36 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
30
30
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
31
  };
32
32
 
33
+ const TextConvert = {};
34
+ const ColorConvert = {};
35
+ const PathArrow = {};
36
+ const Paint = {};
37
+ const PaintImage = {};
38
+ const PaintGradient = {};
39
+ const Effect = {};
40
+ const Export = {};
41
+ const State = {};
42
+
43
+ function stateType(defaultValue) {
44
+ return (target, key) => {
45
+ const stateType = key + 'Style';
46
+ defineLeafAttr(target, key, defaultValue, {
47
+ set(value) {
48
+ this.__setAttr(key, value);
49
+ this.waitLeafer(() => { if (State.setStyle)
50
+ State.setStyle(this, stateType, value); });
51
+ }
52
+ });
53
+ };
54
+ }
33
55
  function arrowType(defaultValue) {
34
56
  return (target, key) => {
35
57
  defineLeafAttr(target, key, defaultValue, {
36
58
  set(value) {
37
59
  this.__setAttr(key, value);
38
- doStrokeType(this);
39
60
  const data = this.__;
40
61
  data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
62
+ doStrokeType(this);
41
63
  }
42
64
  });
43
65
  };
@@ -65,15 +87,16 @@ function resizeType(defaultValue) {
65
87
  });
66
88
  };
67
89
  }
68
-
69
- const TextConvert = {};
70
- const ColorConvert = {};
71
- const PathArrow = {};
72
- const Paint = {};
73
- const PaintImage = {};
74
- const PaintGradient = {};
75
- const Effect = {};
76
- const Export = {};
90
+ function zoomLayerType() {
91
+ return (target, key) => {
92
+ const privateKey = '_' + key;
93
+ defineKey(target, key, {
94
+ set(value) { if (this.isLeafer)
95
+ this[privateKey] = value; },
96
+ get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
97
+ });
98
+ };
99
+ }
77
100
 
78
101
  const { parse } = PathConvert;
79
102
  const emptyPaint = {};
@@ -82,7 +105,7 @@ class UIData extends LeafData {
82
105
  get __strokeWidth() {
83
106
  const { strokeWidth, strokeWidthFixed } = this;
84
107
  if (strokeWidthFixed) {
85
- let { scaleX } = this.__leaf.__world;
108
+ let { scaleX } = this.__leaf.__nowWorld;
86
109
  if (scaleX < 0)
87
110
  scaleX = -scaleX;
88
111
  return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
@@ -356,18 +379,11 @@ const UIRender = {
356
379
  }
357
380
  },
358
381
  __drawFast(canvas, options) {
359
- const { fill, stroke, __drawAfterFill } = this.__;
360
- this.__drawRenderPath(canvas);
361
- if (fill)
362
- Paint.fill(fill, this, canvas);
363
- if (__drawAfterFill)
364
- this.__drawAfterFill(canvas, options);
365
- if (stroke)
366
- Paint.stroke(stroke, this, canvas);
382
+ drawFast(this, canvas, options);
367
383
  },
368
384
  __draw(canvas, options) {
369
- if (this.__.__complex) {
370
- const data = this.__;
385
+ const data = this.__;
386
+ if (data.__complex) {
371
387
  if (data.__needComputePaint)
372
388
  data.__computePaint();
373
389
  const { fill, stroke, __drawAfterFill } = data;
@@ -400,7 +416,12 @@ const UIRender = {
400
416
  }
401
417
  }
402
418
  else {
403
- this.__drawFast(canvas, options);
419
+ if (data.__pathInputed) {
420
+ drawFast(this, canvas, options);
421
+ }
422
+ else {
423
+ this.__drawFast(canvas, options);
424
+ }
404
425
  }
405
426
  },
406
427
  __renderShape(canvas, options) {
@@ -415,6 +436,16 @@ const UIRender = {
415
436
  }
416
437
  }
417
438
  };
439
+ function drawFast(ui, canvas, options) {
440
+ const { fill, stroke, __drawAfterFill } = ui.__;
441
+ ui.__drawRenderPath(canvas);
442
+ if (fill)
443
+ Paint.fill(fill, ui, canvas);
444
+ if (__drawAfterFill)
445
+ ui.__drawAfterFill(canvas, options);
446
+ if (stroke)
447
+ Paint.stroke(stroke, ui, canvas);
448
+ }
418
449
 
419
450
  const RectRender = {
420
451
  __drawFast(canvas, options) {
@@ -463,6 +494,10 @@ let UI = UI_1 = class UI extends Leaf {
463
494
  const { scaleX, scaleY } = this;
464
495
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
465
496
  }
497
+ get pen() {
498
+ pen.set(this.path = this.__.path || []);
499
+ return pen;
500
+ }
466
501
  constructor(data) {
467
502
  super(data);
468
503
  }
@@ -471,7 +506,7 @@ let UI = UI_1 = class UI extends Leaf {
471
506
  Object.assign(this, data);
472
507
  }
473
508
  get(name) {
474
- return name ? this.__.__getInput(name) : this.__.__getInputData();
509
+ return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
475
510
  }
476
511
  createProxyData() { return undefined; }
477
512
  find(_condition, _options) { return undefined; }
@@ -480,10 +515,11 @@ let UI = UI_1 = class UI extends Leaf {
480
515
  this.__layout.update();
481
516
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
482
517
  if (!path) {
483
- path = [];
484
518
  const { width, height } = this.boxBounds;
485
- if (width || height)
486
- this.__drawPathByBox(new PathCreator(path));
519
+ if (width || height) {
520
+ pen.set(path = []);
521
+ this.__drawPathByBox(pen);
522
+ }
487
523
  }
488
524
  return curve ? PathConvert.toCanvasData(path, true) : path;
489
525
  }
@@ -555,6 +591,9 @@ let UI = UI_1 = class UI extends Leaf {
555
591
  __decorate([
556
592
  dataProcessor(UIData)
557
593
  ], UI.prototype, "__", void 0);
594
+ __decorate([
595
+ zoomLayerType()
596
+ ], UI.prototype, "zoomLayer", void 0);
558
597
  __decorate([
559
598
  dataType('')
560
599
  ], UI.prototype, "id", void 0);
@@ -573,6 +612,12 @@ __decorate([
573
612
  __decorate([
574
613
  opacityType(true)
575
614
  ], UI.prototype, "visible", void 0);
615
+ __decorate([
616
+ stateType(false)
617
+ ], UI.prototype, "selected", void 0);
618
+ __decorate([
619
+ stateType(false)
620
+ ], UI.prototype, "disabled", void 0);
576
621
  __decorate([
577
622
  dataType(false)
578
623
  ], UI.prototype, "locked", void 0);
@@ -720,6 +765,24 @@ __decorate([
720
765
  __decorate([
721
766
  effectType()
722
767
  ], UI.prototype, "grayscale", void 0);
768
+ __decorate([
769
+ dataType()
770
+ ], UI.prototype, "normalStyle", void 0);
771
+ __decorate([
772
+ dataType()
773
+ ], UI.prototype, "hoverStyle", void 0);
774
+ __decorate([
775
+ dataType()
776
+ ], UI.prototype, "pressStyle", void 0);
777
+ __decorate([
778
+ dataType()
779
+ ], UI.prototype, "focusStyle", void 0);
780
+ __decorate([
781
+ dataType()
782
+ ], UI.prototype, "selectedStyle", void 0);
783
+ __decorate([
784
+ dataType()
785
+ ], UI.prototype, "disabledStyle", void 0);
723
786
  __decorate([
724
787
  rewrite(Leaf.prototype.reset)
725
788
  ], UI.prototype, "reset", null);
@@ -756,7 +819,7 @@ let Group = class Group extends UI {
756
819
  super.set(data);
757
820
  let child;
758
821
  children.forEach(childData => {
759
- child = UICreator.get(childData.tag, childData);
822
+ child = childData.__ ? childData : UICreator.get(childData.tag, childData);
760
823
  this.add(child);
761
824
  });
762
825
  data.children = children;
@@ -805,7 +868,6 @@ let Leafer = class Leafer extends Group {
805
868
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
806
869
  constructor(userConfig, data) {
807
870
  super(data);
808
- this.zoomLayer = this;
809
871
  this.config = {
810
872
  type: 'design',
811
873
  start: true,
@@ -818,7 +880,6 @@ let Leafer = class Leafer extends Group {
818
880
  move: {
819
881
  holdSpaceKey: true,
820
882
  holdMiddleKey: true,
821
- dragOut: true,
822
883
  autoDistance: 2
823
884
  }
824
885
  };
@@ -949,9 +1010,6 @@ let Leafer = class Leafer extends Group {
949
1010
  this.leafer = leafer;
950
1011
  this.__level = 1;
951
1012
  }
952
- setZoomLayer(zoomLayer) {
953
- this.zoomLayer = zoomLayer;
954
- }
955
1013
  __checkAutoLayout(config) {
956
1014
  if (!config.width || !config.height) {
957
1015
  this.autoLayout = new AutoBounds(config);
@@ -1037,13 +1095,19 @@ let Leafer = class Leafer extends Group {
1037
1095
  this.nextRender(() => this.interaction.updateCursor());
1038
1096
  }
1039
1097
  }
1040
- waitReady(item) {
1098
+ waitReady(item, bind) {
1099
+ if (bind)
1100
+ item = item.bind(bind);
1041
1101
  this.ready ? item() : this.__readyWait.push(item);
1042
1102
  }
1043
- waitViewReady(item) {
1103
+ waitViewReady(item, bind) {
1104
+ if (bind)
1105
+ item = item.bind(bind);
1044
1106
  this.viewReady ? item() : this.__viewReadyWait.push(item);
1045
1107
  }
1046
- waitViewCompleted(item) {
1108
+ waitViewCompleted(item, bind) {
1109
+ if (bind)
1110
+ item = item.bind(bind);
1047
1111
  this.__viewCompletedWait.push(item);
1048
1112
  if (this.viewCompleted) {
1049
1113
  this.__checkViewCompleted(false);
@@ -1053,7 +1117,9 @@ let Leafer = class Leafer extends Group {
1053
1117
  this.start();
1054
1118
  }
1055
1119
  }
1056
- nextRender(item, off) {
1120
+ nextRender(item, bind, off) {
1121
+ if (bind)
1122
+ item = item.bind(bind);
1057
1123
  const list = this.__nextRenderWait;
1058
1124
  if (off) {
1059
1125
  for (let i = 0; i < list.length; i++) {
@@ -1067,6 +1133,15 @@ let Leafer = class Leafer extends Group {
1067
1133
  list.push(item);
1068
1134
  }
1069
1135
  }
1136
+ zoom(_zoomType, _padding, _fixedScale) { return undefined; }
1137
+ validScale(changeScale) {
1138
+ const { scaleX } = this.zoomLayer.__, { min, max } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
1139
+ if (absScale < min)
1140
+ changeScale = min / scaleX;
1141
+ else if (absScale > max)
1142
+ changeScale = max / scaleX;
1143
+ return changeScale;
1144
+ }
1070
1145
  __checkUpdateLayout() {
1071
1146
  this.__layout.update();
1072
1147
  }
@@ -1813,4 +1888,4 @@ function penPathType() {
1813
1888
  };
1814
1889
  }
1815
1890
 
1816
- export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, Text, TextConvert, TextData, UI, UIBounds, UIData, UIRender, UnitConvert, arrowType, effectType, resizeType };
1891
+ export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, UI, UIBounds, UIData, UIRender, UnitConvert, arrowType, effectType, resizeType, stateType, zoomLayerType };
@@ -1 +1 @@
1
- import{defineLeafAttr as t,doStrokeType as e,Debug as i,LeafData as s,PathConvert as o,OneRadian as r,dataProcessor as a,dataType as _,surfaceType as h,opacityType as n,sortType as d,maskType as p,eraserType as l,positionType as u,boundsType as c,scaleType as y,rotationType as g,autoLayoutType as v,hitType as f,strokeType as w,cursorType as x,naturalBoundsType as m,pathInputType as R,pathType as S,rewrite as k,Leaf as b,useModule as B,rewriteAble as A,PathCreator as C,PathCorner as P,PathDrawer as F,UICreator as D,registerUI as E,Branch as T,ImageManager as L,DataHelper as W,Creator as I,CanvasManager as M,LeaferEvent as z,canvasSizeAttrs as O,Bounds as N,ResizeEvent as H,AutoBounds as V,WaitHelper as Y,Run as U,LayoutEvent as X,RenderEvent as j,WatchEvent as G,affectRenderBoundsType as J,BoundsHelper as $,Platform as K,PathCommandDataHelper as q,affectStrokeBoundsType as Z,getPointData as Q,PointHelper as tt,PathBounds as et,ImageEvent as it,Matrix as st,MathHelper as ot,defineKey as rt}from"@leafer/core";export*from"@leafer/core";function at(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 _=t.length-1;_>=0;_--)(o=t[_])&&(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 _t(i){return(s,o)=>{t(s,o,i,{set(t){this.__setAttr(o,t),e(this);const i=this.__;i.__useArrow="none"!==i.startArrow||"none"!==i.endArrow}})}}function ht(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function nt(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}"function"==typeof SuppressedError&&SuppressedError;const dt={},pt={},lt={},ut={},ct={},yt={},gt={},vt={},{parse:ft}=o,wt={},xt=i.get("UIData");class mt extends s{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){let{scaleX:e}=this.__leaf.__world;return e<0&&(e=-e),e>1?t/e:t}return t}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.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,xt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,xt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=wt)):(this.__isFills&&(this.__removeInput("fill"),ct.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=wt)):(this.__isStrokes&&(this.__removeInput("stroke"),ct.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=ft(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ut.compute("fill",this.__leaf),e&&ut.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Rt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class St extends mt{}class kt extends St{get __boxStroke(){return!0}}class bt extends St{}class Bt extends kt{}class At extends mt{}class Ct extends mt{get __boxStroke(){return!0}}class Pt extends mt{get __boxStroke(){return!0}}class Ft extends mt{}class Dt extends mt{}class Et extends mt{}class Tt extends St{}const Lt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Wt extends mt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Lt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class It extends Ct{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Mt extends Ct{}const zt={__updateStrokeSpread(){let t=0,e=0;const{stroke:i,hitStroke:s,strokeAlign:o,strokeWidth:a}=this.__;if((i||"all"===s)&&a&&"inside"!==o&&(e=t="center"===o?a/2:a,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:i}=this.__,s="Line"!==this.__tag?1/Math.sin(e*r/2)*Math.sqrt(a)-t:0,o="none"===i?0:a;t+=Math.max(s,o)}return this.__layout.strokeBoxSpread=e,this.__.__useArrow&&(t+=5*a),t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=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));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t}},Ot={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:i,stroke:s,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),i&&ut.fill(i,this,t),o&&this.__drawAfterFill(t,e),s&&ut.stroke(s,this,t)},__draw(t,e){if(this.__.__complex){const i=this.__;i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ut.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:h}=i;_&&gt.shadow(this,t,a),s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),h&&gt.innerShadow(this,t,a),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ut.strokes(o,this,t):ut.stroke(o,this,t))}else this.__drawFast(t,e)},__renderShape(t,e){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:s}=this.__;this.__drawRenderPath(t),i&&(this.__.__pixelFill?ut.fills(i,this,t):ut.fill("#000000",this,t)),s&&(this.__.__pixelStroke?ut.strokes(s,this,t):ut.stroke("#000000",this,t))}}},Nt={__drawFast(t,e){const{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,i,s);break;case"inside":t.strokeRect(a,a,i-o,s-o);break;case"outside":t.strokeRect(-a,-a,i+o,s+o)}}}};var Ht;let Vt=Ht=class extends b{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return t?this.__.__getInput(t):this.__.__getInputData()}createProxyData(){}find(t,e){}findOne(t,e){}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;if(!i){i=[];const{width:t,height:e}=this.boxBounds;(t||e)&&this.__drawPathByBox(new C(i))}return t?o.toCanvasData(i,!0):i}getPathString(t,e){return o.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const t=this.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;t.__computePaint()}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?P.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&lt.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?F.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,i,s,o,this.__.cornerRadius):t.rect(e,i,s,o)}export(t,e){return vt.export(this,t,e)}clone(){return Ht.one(this.toJSON())}static one(t,e,i,s,o){return D.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){E()(this)}static registerData(t){a(t)(this.prototype)}destroy(){this.fill=this.stroke=null,super.destroy()}};at([a(mt)],Vt.prototype,"__",void 0),at([_("")],Vt.prototype,"id",void 0),at([_("")],Vt.prototype,"name",void 0),at([_("")],Vt.prototype,"className",void 0),at([h("pass-through")],Vt.prototype,"blendMode",void 0),at([n(1)],Vt.prototype,"opacity",void 0),at([n(!0)],Vt.prototype,"visible",void 0),at([_(!1)],Vt.prototype,"locked",void 0),at([d(0)],Vt.prototype,"zIndex",void 0),at([p(!1)],Vt.prototype,"mask",void 0),at([h("pixel")],Vt.prototype,"maskType",void 0),at([l(!1)],Vt.prototype,"eraser",void 0),at([u(0)],Vt.prototype,"x",void 0),at([u(0)],Vt.prototype,"y",void 0),at([c(100)],Vt.prototype,"width",void 0),at([c(100)],Vt.prototype,"height",void 0),at([y(1)],Vt.prototype,"scaleX",void 0),at([y(1)],Vt.prototype,"scaleY",void 0),at([g(0)],Vt.prototype,"rotation",void 0),at([g(0)],Vt.prototype,"skewX",void 0),at([g(0)],Vt.prototype,"skewY",void 0),at([v()],Vt.prototype,"around",void 0),at([_(!1)],Vt.prototype,"draggable",void 0),at([_(!1)],Vt.prototype,"editable",void 0),at([_("size")],Vt.prototype,"editSize",void 0),at([f(!0)],Vt.prototype,"hittable",void 0),at([f("path")],Vt.prototype,"hitFill",void 0),at([w("path")],Vt.prototype,"hitStroke",void 0),at([f(!1)],Vt.prototype,"hitBox",void 0),at([f(!0)],Vt.prototype,"hitChildren",void 0),at([f(!0)],Vt.prototype,"hitSelf",void 0),at([f()],Vt.prototype,"hitRadius",void 0),at([x("")],Vt.prototype,"cursor",void 0),at([h()],Vt.prototype,"fill",void 0),at([w()],Vt.prototype,"stroke",void 0),at([w("inside")],Vt.prototype,"strokeAlign",void 0),at([w(1)],Vt.prototype,"strokeWidth",void 0),at([w(!1)],Vt.prototype,"strokeWidthFixed",void 0),at([w("none")],Vt.prototype,"strokeCap",void 0),at([w("miter")],Vt.prototype,"strokeJoin",void 0),at([w()],Vt.prototype,"dashPattern",void 0),at([w()],Vt.prototype,"dashOffset",void 0),at([w(10)],Vt.prototype,"miterLimit",void 0),at([_(!1)],Vt.prototype,"lazy",void 0),at([m(1)],Vt.prototype,"pixelRatio",void 0),at([R()],Vt.prototype,"path",void 0),at([S()],Vt.prototype,"windingRule",void 0),at([_t("none")],Vt.prototype,"startArrow",void 0),at([_t("none")],Vt.prototype,"endArrow",void 0),at([S(0)],Vt.prototype,"cornerRadius",void 0),at([S()],Vt.prototype,"cornerSmoothing",void 0),at([ht()],Vt.prototype,"shadow",void 0),at([ht()],Vt.prototype,"innerShadow",void 0),at([ht()],Vt.prototype,"blur",void 0),at([ht()],Vt.prototype,"backgroundBlur",void 0),at([ht()],Vt.prototype,"grayscale",void 0),at([k(b.prototype.reset)],Vt.prototype,"reset",null),Vt=Ht=at([B(zt),B(Ot),A()],Vt);let Yt=class extends Vt{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){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=D.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}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(){}};at([a(St)],Yt.prototype,"__",void 0),Yt=at([B(T),E()],Yt);const Ut=i.get("Leafer");let Xt=class extends Yt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&L.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,dragOut:!0,autoDistance:2}},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)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&W.assign(this.config,t);const{config:s}=this;this.initType(s.type),this.canvas=I.canvas(s),this.__controllers.push(this.renderer=I.renderer(this,this.canvas,s),this.watcher=I.watcher(this,s),this.layouter=I.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s),this.view=this.canvas.view,e?(this.__bindApp(e),i=e.running):(this.selector=I.selector(this),this.interaction=I.interaction(this,this.canvas,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=I.hitCanvasManager()),this.canvasManager=new M,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(z.RESTART):this.emitLeafer(z.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(z.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=W.copyAttrs({},t,O);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.forceRender()}forceRender(t){this.renderer.addBlock(t?new N(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=W.copyAttrs({},this.canvas,O);this.canvas.resize(t),this.__onResize(new H(t,e))}__onResize(t){this.emitEvent(t),W.copyAttrs(this.__,t,O),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}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new V(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(O.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&O.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=W.copyAttrs({},this.canvas,O);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.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(z.BEFORE_READY),this.emitLeafer(z.READY),this.emitLeafer(z.AFTER_READY),Y.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(z.VIEW_READY),Y.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){Y.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(z.VIEW_COMPLETED),Y.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e){const i=this.__nextRenderWait;if(e){for(let e=0;e<i.length;e++)if(i[e]===t){i.splice(e,1);break}}else i.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new z(t,this))}__listenEvents(){const t=U.start("FirstCreate "+this.innerName);this.once(z.START,(()=>U.end(t))),this.once(X.END,(()=>this.__onReady())),this.once(j.START,(()=>this.__onCreated())),this.once(j.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(G.DATA,this.__onWatchData,this),this.on_(j.NEXT,this.__onNextRender,this),this.on_(X.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new z(z.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=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{L.clearRecycled()}),100)}catch(t){Ut.error(t)}}))}};at([a(bt)],Xt.prototype,"__",void 0),at([c()],Xt.prototype,"pixelRatio",void 0),Xt=at([E()],Xt);let jt=class extends Vt{get __tag(){return"Rect"}constructor(t){super(t)}};at([a(Ct)],jt.prototype,"__",void 0),jt=at([B(Nt),A(),E()],jt);const Gt=jt.prototype,Jt=Yt.prototype,$t={},{copy:Kt,add:qt}=$;let Zt=class extends Yt{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(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;Kt($t,t),super.__updateRenderBounds(),qt(t,$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.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};at([a(kt)],Zt.prototype,"__",void 0),at([J("show")],Zt.prototype,"overflow",void 0),at([k(Gt.__updateStrokeSpread)],Zt.prototype,"__updateStrokeSpread",null),at([k(Gt.__updateRenderSpread)],Zt.prototype,"__updateRectRenderSpread",null),at([k(Gt.__updateBoxBounds)],Zt.prototype,"__updateRectBoxBounds",null),at([k(Gt.__updateStrokeBounds)],Zt.prototype,"__updateStrokeBounds",null),at([k(Gt.__updateRenderBounds)],Zt.prototype,"__updateRectRenderBounds",null),at([k(Gt.__updateChange)],Zt.prototype,"__updateRectChange",null),at([k(Gt.__render)],Zt.prototype,"__renderRect",null),at([k(Jt.__render)],Zt.prototype,"__renderGroup",null),Zt=at([A(),E()],Zt);let Qt=class extends Zt{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};at([a(Bt)],Qt.prototype,"__",void 0),at([h("#FFFFFF")],Qt.prototype,"fill",void 0),at([J("hide")],Qt.prototype,"overflow",void 0),Qt=at([E()],Qt);const{moveTo:te,closePath:ee,ellipse:ie}=q;let se=class extends Vt{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,_=this.__.path=[];i?(s||o?(i<1&&ie(_,r,a,r*i,a*i,0,s,o,!1),ie(_,r,a,r,a,0,o,s,!0),i<1&&ee(_)):(i<1&&(ie(_,r,a,r*i,a*i),te(_,t,a)),ie(_,r,a,r,a,0,360,0,!0)),K.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(te(_,r,a),ie(_,r,a,r,a,0,s,o,!1),ee(_)):ie(_,r,a,r,a)}};at([a(Pt)],se.prototype,"__",void 0),at([S(0)],se.prototype,"innerRadius",void 0),at([S(0)],se.prototype,"startAngle",void 0),at([S(0)],se.prototype,"endAngle",void 0),se=at([E()],se);const{moveTo:oe,lineTo:re,drawPoints:ae}=q,{rotate:_e,getAngle:he,getDistance:ne,defaultPoint:de}=tt,{toBounds:pe}=et;let le=class extends Vt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=Q();return t&&(i.x=t),e&&_e(i,e),i}set toPoint(t){this.width=ne(de,t),this.rotation=he(de,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?ae(t,this.__.points,!1):(oe(t,0,0),re(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ae(t.__pathForRender=[],t.points,t.curve,this.pathClosed),t.__useArrow&&lt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?pe(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};at([a(At)],le.prototype,"__",void 0),at([Z("center")],le.prototype,"strokeAlign",void 0),at([c(0)],le.prototype,"height",void 0),at([S()],le.prototype,"points",void 0),at([S(0)],le.prototype,"curve",void 0),le=at([E()],le);const{sin:ue,cos:ce,PI:ye}=Math,{moveTo:ge,lineTo:ve,closePath:fe,drawPoints:we}=q,xe=le.prototype;let me=class extends Vt{get __tag(){return"Polygon"}constructor(t){super(t),this.pathClosed=!0}__updatePath(){const t=this.__.path=[];if(this.__.points)we(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;ge(t,o,0);for(let e=1;e<s;e++)ve(t,o+o*ue(2*e*ye/s),r-r*ce(2*e*ye/s))}fe(t)}__updateRenderPath(){}__updateBoxBounds(){}};at([a(Ft)],me.prototype,"__",void 0),at([S(3)],me.prototype,"sides",void 0),at([S()],me.prototype,"points",void 0),at([S(0)],me.prototype,"curve",void 0),at([k(xe.__updateRenderPath)],me.prototype,"__updateRenderPath",null),at([k(xe.__updateBoxBounds)],me.prototype,"__updateBoxBounds",null),me=at([A(),E()],me);const{sin:Re,cos:Se,PI:ke}=Math,{moveTo:be,lineTo:Be,closePath:Ae}=q;let Ce=class extends Vt{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=[];be(a,o,0);for(let t=1;t<2*i;t++)Be(a,o+(t%2==0?o:o*s)*Re(t*ke/i),r-(t%2==0?r:r*s)*Se(t*ke/i));Ae(a)}};at([a(Dt)],Ce.prototype,"__",void 0),at([S(5)],Ce.prototype,"corners",void 0),at([S(.382)],Ce.prototype,"innerRadius",void 0),Ce=at([E()],Ce);let Pe=class extends jt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(it.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};at([a(It)],Pe.prototype,"__",void 0),at([c("")],Pe.prototype,"url",void 0),Pe=at([E()],Pe);let Fe=class extends jt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=I.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new st(t.__world).invert(),r=new st;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.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}};at([a(Mt)],Fe.prototype,"__",void 0),at([nt(100)],Fe.prototype,"width",void 0),at([nt(100)],Fe.prototype,"height",void 0),at([nt(K.devicePixelRatio)],Fe.prototype,"pixelRatio",void 0),at([nt(!0)],Fe.prototype,"smooth",void 0),at([f("all")],Fe.prototype,"hitFill",void 0),Fe=at([E()],Fe);const{copyAndSpread:De,includes:Ee,spread:Te,setList:Le}=$;let We=class extends Vt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=dt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:_,textCase:h,textOverflow:n,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Rt.number(i,r),t.__letterSpacing=Rt.number(s,r),t.__padding=d?ot.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${_?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==n&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Te(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();const y=Ee(c,u)?c:u;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,Le(t.__textBoxBounds={},[c,u])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){De(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};at([a(Wt)],We.prototype,"__",void 0),at([c(0)],We.prototype,"width",void 0),at([c(0)],We.prototype,"height",void 0),at([c(0)],We.prototype,"padding",void 0),at([h("#000000")],We.prototype,"fill",void 0),at([Z("outside")],We.prototype,"strokeAlign",void 0),at([f("all")],We.prototype,"hitFill",void 0),at([c("")],We.prototype,"text",void 0),at([c("L")],We.prototype,"fontFamily",void 0),at([c(12)],We.prototype,"fontSize",void 0),at([c("normal")],We.prototype,"fontWeight",void 0),at([c(!1)],We.prototype,"italic",void 0),at([c("none")],We.prototype,"textCase",void 0),at([c("none")],We.prototype,"textDecoration",void 0),at([c(0)],We.prototype,"letterSpacing",void 0),at([c({type:"percent",value:150})],We.prototype,"lineHeight",void 0),at([c(0)],We.prototype,"paraIndent",void 0),at([c(0)],We.prototype,"paraSpacing",void 0),at([c("left")],We.prototype,"textAlign",void 0),at([c("top")],We.prototype,"verticalAlign",void 0),at([c("normal")],We.prototype,"textWrap",void 0),at([c("show")],We.prototype,"textOverflow",void 0),We=at([E()],We);let Ie=class extends Vt{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};at([a(Et)],Ie.prototype,"__",void 0),at([Z("center")],Ie.prototype,"strokeAlign",void 0),Ie=at([E()],Ie);let Me=class extends Yt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ie(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),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,_){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,_){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}paint(){this.pathElement.forceUpdate("path")}};at([a(Tt)],Me.prototype,"__",void 0),at([(t,e)=>{rt(t,e,{get(){return this.__path}})}],Me.prototype,"path",void 0),Me=at([B(C,["beginPath","path"]),E()],Me);export{Zt as Box,kt as BoxData,Fe as Canvas,Mt as CanvasData,pt as ColorConvert,gt as Effect,se as Ellipse,Pt as EllipseData,vt as Export,Qt as Frame,Bt as FrameData,Yt as Group,St as GroupData,Pe as Image,It as ImageData,Xt as Leafer,bt as LeaferData,le as Line,At as LineData,ut as Paint,yt as PaintGradient,ct as PaintImage,Ie as Path,lt as PathArrow,Et as PathData,Me as Pen,Tt as PenData,me as Polygon,Ft as PolygonData,jt as Rect,Ct as RectData,Nt as RectRender,Ce as Star,Dt as StarData,We as Text,dt as TextConvert,Wt as TextData,Vt as UI,zt as UIBounds,mt as UIData,Ot as UIRender,Rt as UnitConvert,_t as arrowType,ht as effectType,nt as resizeType};
1
+ import{defineLeafAttr as t,doStrokeType as e,defineKey as i,Debug as s,LeafData as o,PathConvert as r,OneRadian as a,dataProcessor as _,dataType as n,surfaceType as h,opacityType as d,sortType as p,maskType as l,eraserType as u,positionType as c,boundsType as y,scaleType as v,rotationType as g,autoLayoutType as f,hitType as w,strokeType as x,cursorType as m,naturalBoundsType as R,pathInputType as S,pathType as k,rewrite as b,Leaf as B,useModule as A,rewriteAble as C,pen as P,PathCorner as F,PathDrawer as D,UICreator as E,registerUI as L,Branch as T,ImageManager as W,DataHelper as I,Creator as M,CanvasManager as z,LeaferEvent as O,canvasSizeAttrs as N,Bounds as H,ResizeEvent as V,AutoBounds as Y,WaitHelper as X,Run as U,LayoutEvent as j,RenderEvent as G,WatchEvent as J,affectRenderBoundsType as $,BoundsHelper as K,Platform as q,PathCommandDataHelper as Q,affectStrokeBoundsType as Z,getPointData as tt,PointHelper as et,PathBounds as it,ImageEvent as st,Matrix as ot,MathHelper as rt,PathCreator as at}from"@leafer/core";export*from"@leafer/core";function _t(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 _=t.length-1;_>=0;_--)(o=t[_])&&(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"==typeof SuppressedError&&SuppressedError;const nt={},ht={},dt={},pt={},lt={},ut={},ct={},yt={},vt={};function gt(e){return(i,s)=>{const o=s+"Style";t(i,s,e,{set(t){this.__setAttr(s,t),this.waitLeafer((()=>{vt.setStyle&&vt.setStyle(this,o,t)}))}})}}function ft(i){return(s,o)=>{t(s,o,i,{set(t){this.__setAttr(o,t);const i=this.__;i.__useArrow="none"!==i.startArrow||"none"!==i.endArrow,e(this)}})}}function wt(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function xt(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}function mt(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:Rt}=r,St={},kt=s.get("UIData");class bt extends o{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){let{scaleX:e}=this.__leaf.__nowWorld;return e<0&&(e=-e),e>1?t/e:t}return t}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.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,kt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,kt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=St)):(this.__isFills&&(this.__removeInput("fill"),lt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=St)):(this.__isStrokes&&(this.__removeInput("stroke"),lt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Rt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&pt.compute("fill",this.__leaf),e&&pt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Bt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class At extends bt{}class Ct extends At{get __boxStroke(){return!0}}class Pt extends At{}class Ft extends Ct{}class Dt extends bt{}class Et extends bt{get __boxStroke(){return!0}}class Lt extends bt{get __boxStroke(){return!0}}class Tt extends bt{}class Wt extends bt{}class It extends bt{}class Mt extends At{}const zt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ot extends bt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=zt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Nt extends Et{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Ht extends Et{}const Vt={__updateStrokeSpread(){let t=0,e=0;const{stroke:i,hitStroke:s,strokeAlign:o,strokeWidth:r}=this.__;if((i||"all"===s)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:i}=this.__,s="Line"!==this.__tag?1/Math.sin(e*a/2)*Math.sqrt(r)-t:0,o="none"===i?0:r;t+=Math.max(s,o)}return this.__layout.strokeBoxSpread=e,this.__.__useArrow&&(t+=5*r),t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=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));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t}},Yt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Xt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=pt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:n}=i;_&&ct.shadow(this,t,a),s&&(i.__isFills?pt.fills(s,this,t):pt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),n&&ct.innerShadow(this,t,a),o&&(i.__isStrokes?pt.strokes(o,this,t):pt.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?pt.fills(s,this,t):pt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?pt.strokes(o,this,t):pt.stroke(o,this,t))}else i.__pathInputed?Xt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:s}=this.__;this.__drawRenderPath(t),i&&(this.__.__pixelFill?pt.fills(i,this,t):pt.fill("#000000",this,t)),s&&(this.__.__pixelStroke?pt.strokes(s,this,t):pt.stroke("#000000",this,t))}}};function Xt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&pt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&pt.stroke(o,t,e)}const Ut={__drawFast(t,e){const{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,i,s);break;case"inside":t.strokeRect(a,a,i-o,s-o);break;case"outside":t.strokeRect(-a,-a,i+o,s+o)}}}};var jt;let Gt=jt=class extends B{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){return P.set(this.path=this.__.path||[]),P}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findOne(t,e){}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;if(!i){const{width:t,height:e}=this.boxBounds;(t||e)&&(P.set(i=[]),this.__drawPathByBox(P))}return t?r.toCanvasData(i,!0):i}getPathString(t,e){return r.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const t=this.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;t.__computePaint()}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?F.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&dt.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?D.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,i,s,o,this.__.cornerRadius):t.rect(e,i,s,o)}export(t,e){return yt.export(this,t,e)}clone(){return jt.one(this.toJSON())}static one(t,e,i,s,o){return E.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){L()(this)}static registerData(t){_(t)(this.prototype)}destroy(){this.fill=this.stroke=null,super.destroy()}};_t([_(bt)],Gt.prototype,"__",void 0),_t([mt()],Gt.prototype,"zoomLayer",void 0),_t([n("")],Gt.prototype,"id",void 0),_t([n("")],Gt.prototype,"name",void 0),_t([n("")],Gt.prototype,"className",void 0),_t([h("pass-through")],Gt.prototype,"blendMode",void 0),_t([d(1)],Gt.prototype,"opacity",void 0),_t([d(!0)],Gt.prototype,"visible",void 0),_t([gt(!1)],Gt.prototype,"selected",void 0),_t([gt(!1)],Gt.prototype,"disabled",void 0),_t([n(!1)],Gt.prototype,"locked",void 0),_t([p(0)],Gt.prototype,"zIndex",void 0),_t([l(!1)],Gt.prototype,"mask",void 0),_t([h("pixel")],Gt.prototype,"maskType",void 0),_t([u(!1)],Gt.prototype,"eraser",void 0),_t([c(0)],Gt.prototype,"x",void 0),_t([c(0)],Gt.prototype,"y",void 0),_t([y(100)],Gt.prototype,"width",void 0),_t([y(100)],Gt.prototype,"height",void 0),_t([v(1)],Gt.prototype,"scaleX",void 0),_t([v(1)],Gt.prototype,"scaleY",void 0),_t([g(0)],Gt.prototype,"rotation",void 0),_t([g(0)],Gt.prototype,"skewX",void 0),_t([g(0)],Gt.prototype,"skewY",void 0),_t([f()],Gt.prototype,"around",void 0),_t([n(!1)],Gt.prototype,"draggable",void 0),_t([n(!1)],Gt.prototype,"editable",void 0),_t([n("size")],Gt.prototype,"editSize",void 0),_t([w(!0)],Gt.prototype,"hittable",void 0),_t([w("path")],Gt.prototype,"hitFill",void 0),_t([x("path")],Gt.prototype,"hitStroke",void 0),_t([w(!1)],Gt.prototype,"hitBox",void 0),_t([w(!0)],Gt.prototype,"hitChildren",void 0),_t([w(!0)],Gt.prototype,"hitSelf",void 0),_t([w()],Gt.prototype,"hitRadius",void 0),_t([m("")],Gt.prototype,"cursor",void 0),_t([h()],Gt.prototype,"fill",void 0),_t([x()],Gt.prototype,"stroke",void 0),_t([x("inside")],Gt.prototype,"strokeAlign",void 0),_t([x(1)],Gt.prototype,"strokeWidth",void 0),_t([x(!1)],Gt.prototype,"strokeWidthFixed",void 0),_t([x("none")],Gt.prototype,"strokeCap",void 0),_t([x("miter")],Gt.prototype,"strokeJoin",void 0),_t([x()],Gt.prototype,"dashPattern",void 0),_t([x()],Gt.prototype,"dashOffset",void 0),_t([x(10)],Gt.prototype,"miterLimit",void 0),_t([n(!1)],Gt.prototype,"lazy",void 0),_t([R(1)],Gt.prototype,"pixelRatio",void 0),_t([S()],Gt.prototype,"path",void 0),_t([k()],Gt.prototype,"windingRule",void 0),_t([ft("none")],Gt.prototype,"startArrow",void 0),_t([ft("none")],Gt.prototype,"endArrow",void 0),_t([k(0)],Gt.prototype,"cornerRadius",void 0),_t([k()],Gt.prototype,"cornerSmoothing",void 0),_t([wt()],Gt.prototype,"shadow",void 0),_t([wt()],Gt.prototype,"innerShadow",void 0),_t([wt()],Gt.prototype,"blur",void 0),_t([wt()],Gt.prototype,"backgroundBlur",void 0),_t([wt()],Gt.prototype,"grayscale",void 0),_t([n()],Gt.prototype,"normalStyle",void 0),_t([n()],Gt.prototype,"hoverStyle",void 0),_t([n()],Gt.prototype,"pressStyle",void 0),_t([n()],Gt.prototype,"focusStyle",void 0),_t([n()],Gt.prototype,"selectedStyle",void 0),_t([n()],Gt.prototype,"disabledStyle",void 0),_t([b(B.prototype.reset)],Gt.prototype,"reset",null),Gt=jt=_t([A(Vt),A(Yt),C()],Gt);let Jt=class extends Gt{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){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t),e.forEach((t=>{i=t.__?t:E.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}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(){}};_t([_(At)],Jt.prototype,"__",void 0),Jt=_t([A(T),L()],Jt);const $t=s.get("Leafer");let Kt=class extends Jt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&W.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},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)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&I.assign(this.config,t);const{config:s}=this;this.initType(s.type),this.canvas=M.canvas(s),this.__controllers.push(this.renderer=M.renderer(this,this.canvas,s),this.watcher=M.watcher(this,s),this.layouter=M.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s),this.view=this.canvas.view,e?(this.__bindApp(e),i=e.running):(this.selector=M.selector(this),this.interaction=M.interaction(this,this.canvas,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=M.hitCanvasManager()),this.canvasManager=new z,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(O.RESTART):this.emitLeafer(O.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(O.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=I.copyAttrs({},t,N);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.forceRender()}forceRender(t){this.renderer.addBlock(t?new H(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=I.copyAttrs({},this.canvas,N);this.canvas.resize(t),this.__onResize(new V(t,e))}__onResize(t){this.emitEvent(t),I.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){t.width&&t.height||(this.autoLayout=new Y(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(N.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&N.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=I.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.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(O.BEFORE_READY),this.emitLeafer(O.READY),this.emitLeafer(O.AFTER_READY),X.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(O.VIEW_READY),X.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){X.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(O.VIEW_COMPLETED),X.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}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)}zoom(t,e,i){}validScale(t){const{scaleX:e}=this.zoomLayer.__,{min:i,max:s}=this.app.config.zoom,o=Math.abs(e*t);return o<i?t=i/e:o>s&&(t=s/e),t}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new O(t,this))}__listenEvents(){const t=U.start("FirstCreate "+this.innerName);this.once(O.START,(()=>U.end(t))),this.once(j.END,(()=>this.__onReady())),this.once(G.START,(()=>this.__onCreated())),this.once(G.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(J.DATA,this.__onWatchData,this),this.on_(G.NEXT,this.__onNextRender,this),this.on_(j.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new O(O.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=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{W.clearRecycled()}),100)}catch(t){$t.error(t)}}))}};_t([_(Pt)],Kt.prototype,"__",void 0),_t([y()],Kt.prototype,"pixelRatio",void 0),Kt=_t([L()],Kt);let qt=class extends Gt{get __tag(){return"Rect"}constructor(t){super(t)}};_t([_(Et)],qt.prototype,"__",void 0),qt=_t([A(Ut),C(),L()],qt);const Qt=qt.prototype,Zt=Jt.prototype,te={},{copy:ee,add:ie}=K;let se=class extends Jt{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(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;ee(te,t),super.__updateRenderBounds(),ie(t,te)}}__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.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};_t([_(Ct)],se.prototype,"__",void 0),_t([$("show")],se.prototype,"overflow",void 0),_t([b(Qt.__updateStrokeSpread)],se.prototype,"__updateStrokeSpread",null),_t([b(Qt.__updateRenderSpread)],se.prototype,"__updateRectRenderSpread",null),_t([b(Qt.__updateBoxBounds)],se.prototype,"__updateRectBoxBounds",null),_t([b(Qt.__updateStrokeBounds)],se.prototype,"__updateStrokeBounds",null),_t([b(Qt.__updateRenderBounds)],se.prototype,"__updateRectRenderBounds",null),_t([b(Qt.__updateChange)],se.prototype,"__updateRectChange",null),_t([b(Qt.__render)],se.prototype,"__renderRect",null),_t([b(Zt.__render)],se.prototype,"__renderGroup",null),se=_t([C(),L()],se);let oe=class extends se{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};_t([_(Ft)],oe.prototype,"__",void 0),_t([h("#FFFFFF")],oe.prototype,"fill",void 0),_t([$("hide")],oe.prototype,"overflow",void 0),oe=_t([L()],oe);const{moveTo:re,closePath:ae,ellipse:_e}=Q;let ne=class extends Gt{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,_=this.__.path=[];i?(s||o?(i<1&&_e(_,r,a,r*i,a*i,0,s,o,!1),_e(_,r,a,r,a,0,o,s,!0),i<1&&ae(_)):(i<1&&(_e(_,r,a,r*i,a*i),re(_,t,a)),_e(_,r,a,r,a,0,360,0,!0)),q.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(re(_,r,a),_e(_,r,a,r,a,0,s,o,!1),ae(_)):_e(_,r,a,r,a)}};_t([_(Lt)],ne.prototype,"__",void 0),_t([k(0)],ne.prototype,"innerRadius",void 0),_t([k(0)],ne.prototype,"startAngle",void 0),_t([k(0)],ne.prototype,"endAngle",void 0),ne=_t([L()],ne);const{moveTo:he,lineTo:de,drawPoints:pe}=Q,{rotate:le,getAngle:ue,getDistance:ce,defaultPoint:ye}=et,{toBounds:ve}=it;let ge=class extends Gt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=tt();return t&&(i.x=t),e&&le(i,e),i}set toPoint(t){this.width=ce(ye,t),this.rotation=ue(ye,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?pe(t,this.__.points,!1):(he(t,0,0),de(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(pe(t.__pathForRender=[],t.points,t.curve,this.pathClosed),t.__useArrow&&dt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?ve(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};_t([_(Dt)],ge.prototype,"__",void 0),_t([Z("center")],ge.prototype,"strokeAlign",void 0),_t([y(0)],ge.prototype,"height",void 0),_t([k()],ge.prototype,"points",void 0),_t([k(0)],ge.prototype,"curve",void 0),ge=_t([L()],ge);const{sin:fe,cos:we,PI:xe}=Math,{moveTo:me,lineTo:Re,closePath:Se,drawPoints:ke}=Q,be=ge.prototype;let Be=class extends Gt{get __tag(){return"Polygon"}constructor(t){super(t),this.pathClosed=!0}__updatePath(){const t=this.__.path=[];if(this.__.points)ke(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;me(t,o,0);for(let e=1;e<s;e++)Re(t,o+o*fe(2*e*xe/s),r-r*we(2*e*xe/s))}Se(t)}__updateRenderPath(){}__updateBoxBounds(){}};_t([_(Tt)],Be.prototype,"__",void 0),_t([k(3)],Be.prototype,"sides",void 0),_t([k()],Be.prototype,"points",void 0),_t([k(0)],Be.prototype,"curve",void 0),_t([b(be.__updateRenderPath)],Be.prototype,"__updateRenderPath",null),_t([b(be.__updateBoxBounds)],Be.prototype,"__updateBoxBounds",null),Be=_t([C(),L()],Be);const{sin:Ae,cos:Ce,PI:Pe}=Math,{moveTo:Fe,lineTo:De,closePath:Ee}=Q;let Le=class extends Gt{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=[];Fe(a,o,0);for(let t=1;t<2*i;t++)De(a,o+(t%2==0?o:o*s)*Ae(t*Pe/i),r-(t%2==0?r:r*s)*Ce(t*Pe/i));Ee(a)}};_t([_(Wt)],Le.prototype,"__",void 0),_t([k(5)],Le.prototype,"corners",void 0),_t([k(.382)],Le.prototype,"innerRadius",void 0),Le=_t([L()],Le);let Te=class extends qt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(st.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};_t([_(Nt)],Te.prototype,"__",void 0),_t([y("")],Te.prototype,"url",void 0),Te=_t([L()],Te);let We=class extends qt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=M.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new ot(t.__world).invert(),r=new ot;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.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}};_t([_(Ht)],We.prototype,"__",void 0),_t([xt(100)],We.prototype,"width",void 0),_t([xt(100)],We.prototype,"height",void 0),_t([xt(q.devicePixelRatio)],We.prototype,"pixelRatio",void 0),_t([xt(!0)],We.prototype,"smooth",void 0),_t([w("all")],We.prototype,"hitFill",void 0),We=_t([L()],We);const{copyAndSpread:Ie,includes:Me,spread:ze,setList:Oe}=K;let Ne=class extends Gt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=nt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:_,textCase:n,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Bt.number(i,r),t.__letterSpacing=Bt.number(s,r),t.__padding=d?rt.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${_?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&ze(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();const y=Me(c,u)?c:u;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,Oe(t.__textBoxBounds={},[c,u])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Ie(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};_t([_(Ot)],Ne.prototype,"__",void 0),_t([y(0)],Ne.prototype,"width",void 0),_t([y(0)],Ne.prototype,"height",void 0),_t([y(0)],Ne.prototype,"padding",void 0),_t([h("#000000")],Ne.prototype,"fill",void 0),_t([Z("outside")],Ne.prototype,"strokeAlign",void 0),_t([w("all")],Ne.prototype,"hitFill",void 0),_t([y("")],Ne.prototype,"text",void 0),_t([y("L")],Ne.prototype,"fontFamily",void 0),_t([y(12)],Ne.prototype,"fontSize",void 0),_t([y("normal")],Ne.prototype,"fontWeight",void 0),_t([y(!1)],Ne.prototype,"italic",void 0),_t([y("none")],Ne.prototype,"textCase",void 0),_t([y("none")],Ne.prototype,"textDecoration",void 0),_t([y(0)],Ne.prototype,"letterSpacing",void 0),_t([y({type:"percent",value:150})],Ne.prototype,"lineHeight",void 0),_t([y(0)],Ne.prototype,"paraIndent",void 0),_t([y(0)],Ne.prototype,"paraSpacing",void 0),_t([y("left")],Ne.prototype,"textAlign",void 0),_t([y("top")],Ne.prototype,"verticalAlign",void 0),_t([y("normal")],Ne.prototype,"textWrap",void 0),_t([y("show")],Ne.prototype,"textOverflow",void 0),Ne=_t([L()],Ne);let He=class extends Gt{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};_t([_(It)],He.prototype,"__",void 0),_t([Z("center")],He.prototype,"strokeAlign",void 0),He=_t([L()],He);let Ve=class extends Jt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new He(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),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,_){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,_){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}paint(){this.pathElement.forceUpdate("path")}};_t([_(Mt)],Ve.prototype,"__",void 0),_t([(t,e)=>{i(t,e,{get(){return this.__path}})}],Ve.prototype,"path",void 0),Ve=_t([A(at,["beginPath","path"]),L()],Ve);export{se as Box,Ct as BoxData,We as Canvas,Ht as CanvasData,ht as ColorConvert,ct as Effect,ne as Ellipse,Lt as EllipseData,yt as Export,oe as Frame,Ft as FrameData,Jt as Group,At as GroupData,Te as Image,Nt as ImageData,Kt as Leafer,Pt as LeaferData,ge as Line,Dt as LineData,pt as Paint,ut as PaintGradient,lt as PaintImage,He as Path,dt as PathArrow,It as PathData,Ve as Pen,Mt as PenData,Be as Polygon,Tt as PolygonData,qt as Rect,Et as RectData,Ut as RectRender,Le as Star,Wt as StarData,vt as State,Ne as Text,nt as TextConvert,Ot as TextData,Gt as UI,Vt as UIBounds,bt as UIData,Yt as UIRender,Bt as UnitConvert,ft as arrowType,wt as effectType,xt as resizeType,gt as stateType,mt as zoomLayerType};
package/lib/draw.min.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(e){this.__setAttr(r,e),t.doStrokeType(this);const s=this.__;s.__useArrow="none"!==s.startArrow||"none"!==s.endArrow}})}}function r(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function o(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}"function"==typeof SuppressedError&&SuppressedError;const i={},a={},n={},p={},h={},_={},{parse:d}=t.PathConvert,l={},u=t.Debug.get("UIData");class c extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){let{scaleX:e}=this.__leaf.__world;return e<0&&(e=-e),e>1?t/e:t}return t}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.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,u.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,u.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=l)):(this.__isFills&&(this.__removeInput("fill"),p.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=l)):(this.__isStrokes&&(this.__removeInput("stroke"),p.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=d(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&n.compute("fill",this.__leaf),e&&n.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const x={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class y extends c{}class g extends y{get __boxStroke(){return!0}}class v extends y{}class f extends g{}class w extends c{}class m extends c{get __boxStroke(){return!0}}class T extends c{get __boxStroke(){return!0}}class R extends c{}class I extends c{}class P extends c{}class b extends y{}const S={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class k extends c{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=S[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class B extends m{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class C extends m{}const U={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,this.__.__useArrow&&(e+=5*a),e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=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)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},A={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&n.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&n.stroke(r,this,t)},__draw(t,e){if(this.__.__complex){const s=this.__;s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:o,__drawAfterFill:i}=s;if(this.__drawRenderPath(t),s.__useEffect){const a=n.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:p,innerShadow:_}=s;p&&h.shadow(this,t,a),r&&(s.__isFills?n.fills(r,this,t):n.fill(r,this,t)),i&&this.__drawAfterFill(t,e),_&&h.innerShadow(this,t,a),o&&(s.__isStrokes?n.strokes(o,this,t):n.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else r&&(s.__isFills?n.fills(r,this,t):n.fill(r,this,t)),i&&this.__drawAfterFill(t,e),o&&(s.__isStrokes?n.strokes(o,this,t):n.stroke(o,this,t))}else this.__drawFast(t,e)},__renderShape(t,e){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?n.fills(s,this,t):n.fill("#000000",this,t)),r&&(this.__.__pixelStroke?n.strokes(r,this,t):n.stroke("#000000",this,t))}}},L={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var D;exports.UI=D=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return t?this.__.__getInput(t):this.__.__getInputData()}createProxyData(){}find(t,e){}findOne(t,e){}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;if(!r){r=[];const{width:e,height:s}=this.boxBounds;(e||s)&&this.__drawPathByBox(new t.PathCreator(r))}return e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}__onUpdateSize(){if(this.__.__input){const t=this.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;t.__computePaint()}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&a.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,s){s?t.PathDrawer.drawPathByData(e,s):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return _.export(this,t,e)}clone(){return D.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(c)],exports.UI.prototype,"__",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.surfaceType("pixel")],exports.UI.prototype,"maskType",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([s("none")],exports.UI.prototype,"startArrow",void 0),e([s("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([r()],exports.UI.prototype,"shadow",void 0),e([r()],exports.UI.prototype,"innerShadow",void 0),e([r()],exports.UI.prototype,"blur",void 0),e([r()],exports.UI.prototype,"backgroundBlur",void 0),e([r()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=D=e([t.useModule(U),t.useModule(A),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{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(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}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(){}},e([t.dataProcessor(y)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const E=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,dragOut:!0,autoDistance:2}},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)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:o}=this;this.initType(o.type),this.canvas=t.Creator.canvas(o),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,this.canvas,this.selector,o),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,r=o.start),this.hittable=o.hittable,this.fill=o.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.forceRender()}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),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}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e){const s=this.__nextRenderWait;if(e){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.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=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){E.error(t)}}))}},e([t.dataProcessor(v)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(m)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(L),t.rewriteAble(),t.registerUI()],exports.Rect);const F=exports.Rect.prototype,W=exports.Group.prototype,M={},{copy:z,add:H}=t.BoundsHelper;exports.Box=class extends exports.Group{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(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;z(M,t),super.__updateRenderBounds(),H(t,M)}}__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.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(g)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(F.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(F.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(F.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(F.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(F.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(F.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(F.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(W.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(f)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:O,closePath:N,ellipse:G}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];r?(o||i?(r<1&&G(p,a,n,a*r,n*r,0,o,i,!1),G(p,a,n,a,n,0,i,o,!0),r<1&&N(p)):(r<1&&(G(p,a,n,a*r,n*r),O(p,e,n)),G(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(O(p,a,n),G(p,a,n,a,n,0,o,i,!1),N(p)):G(p,a,n,a,n)}},e([t.dataProcessor(T)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:V,lineTo:j,drawPoints:Y}=t.PathCommandDataHelper,{rotate:X,getAngle:J,getDistance:$,defaultPoint:K}=t.PointHelper,{toBounds:q}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,r=t.getPointData();return e&&(r.x=e),s&&X(r,s),r}set toPoint(t){this.width=$(K,t),this.rotation=J(K,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?Y(t,this.__.points,!1):(V(t,0,0),j(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Y(t.__pathForRender=[],t.points,t.curve,this.pathClosed),t.__useArrow&&a.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?q(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(w)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:Z,cos:Q,PI:tt}=Math,{moveTo:et,lineTo:st,closePath:rt,drawPoints:ot}=t.PathCommandDataHelper,it=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t),this.pathClosed=!0}__updatePath(){const t=this.__.path=[];if(this.__.points)ot(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;et(t,o,0);for(let e=1;e<r;e++)st(t,o+o*Z(2*e*tt/r),i-i*Q(2*e*tt/r))}rt(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(R)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(it.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(it.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:at,cos:nt,PI:pt}=Math,{moveTo:ht,lineTo:_t,closePath:dt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];ht(a,o,0);for(let t=1;t<2*s;t++)_t(a,o+(t%2==0?o:o*r)*at(t*pt/s),i-(t%2==0?i:i*r)*nt(t*pt/s));dt(a)}},e([t.dataProcessor(I)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(B)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}},e([t.dataProcessor(C)],exports.Canvas.prototype,"__",void 0),e([o(100)],exports.Canvas.prototype,"width",void 0),e([o(100)],exports.Canvas.prototype,"height",void 0),e([o(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([o(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:lt,includes:ut,spread:ct,setList:xt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=i.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=x.number(r,a),e.__letterSpacing=x.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=s.boxBounds;if(e.__lineHeight<a&&ct(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,s,r,o]=e.__padding;l&&(y.x-=o,y.width+=s+o),u&&(y.y-=t,y.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();const g=ut(y,c)?y:c;g!==s.contentBounds?(s.contentBounds=g,s.renderChanged=!0,xt(e.__textBoxBounds={},[y,c])):e.__textBoxBounds=g}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){lt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(k)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(P)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}},e([t.dataProcessor(b)],exports.Pen.prototype,"__",void 0),e([(e,s)=>{t.defineKey(e,s,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath","path"]),t.registerUI()],exports.Pen),exports.BoxData=g,exports.CanvasData=C,exports.ColorConvert={},exports.Effect=h,exports.EllipseData=T,exports.Export=_,exports.FrameData=f,exports.GroupData=y,exports.ImageData=B,exports.LeaferData=v,exports.LineData=w,exports.Paint=n,exports.PaintGradient={},exports.PaintImage=p,exports.PathArrow=a,exports.PathData=P,exports.PenData=b,exports.PolygonData=R,exports.RectData=m,exports.RectRender=L,exports.StarData=I,exports.TextConvert=i,exports.TextData=k,exports.UIBounds=U,exports.UIData=c,exports.UIRender=A,exports.UnitConvert=x,exports.arrowType=s,exports.effectType=r,exports.resizeType=o,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
1
+ "use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}"function"==typeof SuppressedError&&SuppressedError;const s={},r={},o={},i={},a={},n={},p={};function h(e){return(s,r)=>{const o=r+"Style";t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.waitLeafer((()=>{p.setStyle&&p.setStyle(this,o,t)}))}})}}function _(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(e){this.__setAttr(r,e);const s=this.__;s.__useArrow="none"!==s.startArrow||"none"!==s.endArrow,t.doStrokeType(this)}})}}function d(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function l(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}function u(){return(e,s)=>{const r="_"+s;t.defineKey(e,s,{set(t){this.isLeafer&&(this[r]=t)},get(){return this.isLeafer?this[r]||this:this.leafer&&this.leafer.zoomLayer}})}}const{parse:c}=t.PathConvert,y={},x=t.Debug.get("UIData");class v extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){let{scaleX:e}=this.__leaf.__nowWorld;return e<0&&(e=-e),e>1?t/e:t}return t}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.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,x.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,x.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=y)):(this.__isFills&&(this.__removeInput("fill"),i.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=y)):(this.__isStrokes&&(this.__removeInput("stroke"),i.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=c(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&o.compute("fill",this.__leaf),e&&o.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const g={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class f extends v{}class w extends f{get __boxStroke(){return!0}}class m extends f{}class T extends w{}class I extends v{}class R extends v{get __boxStroke(){return!0}}class P extends v{get __boxStroke(){return!0}}class b extends v{}class S extends v{}class k extends v{}class B extends f{}const U={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class C extends v{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=U[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class A extends R{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class L extends R{}const D={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,this.__.__useArrow&&(e+=5*a),e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=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)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},E={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){F(this,t,e)},__draw(t,e){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:i,__drawAfterFill:n}=s;if(this.__drawRenderPath(t),s.__useEffect){const p=o.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:_}=s;h&&a.shadow(this,t,p),r&&(s.__isFills?o.fills(r,this,t):o.fill(r,this,t)),n&&this.__drawAfterFill(t,e),_&&a.innerShadow(this,t,p),i&&(s.__isStrokes?o.strokes(i,this,t):o.stroke(i,this,t)),p.worldCanvas&&p.worldCanvas.recycle(),p.canvas.recycle()}else r&&(s.__isFills?o.fills(r,this,t):o.fill(r,this,t)),n&&this.__drawAfterFill(t,e),i&&(s.__isStrokes?o.strokes(i,this,t):o.stroke(i,this,t))}else s.__pathInputed?F(this,t,e):this.__drawFast(t,e)},__renderShape(t,e){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?o.fills(s,this,t):o.fill("#000000",this,t)),r&&(this.__.__pixelStroke?o.strokes(r,this,t):o.stroke("#000000",this,t))}}};function F(t,e,s){const{fill:r,stroke:i,__drawAfterFill:a}=t.__;t.__drawRenderPath(e),r&&o.fill(r,t,e),a&&t.__drawAfterFill(e,s),i&&o.stroke(i,t,e)}const W={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var M;exports.UI=M=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get pen(){return t.pen.set(this.path=this.__.path||[]),t.pen}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findOne(t,e){}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;if(!r){const{width:e,height:s}=this.boxBounds;(e||s)&&(t.pen.set(r=[]),this.__drawPathByBox(t.pen))}return e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}__onUpdateSize(){if(this.__.__input){const t=this.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;t.__computePaint()}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path,e.__useArrow&&r.addArrows(this,!e.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(e,s){s?t.PathDrawer.drawPathByData(e,s):this.__drawPathByBox(e)}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return n.export(this,t,e)}clone(){return M.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}static registerUI(){t.registerUI()(this)}static registerData(e){t.dataProcessor(e)(this.prototype)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(v)],exports.UI.prototype,"__",void 0),e([u()],exports.UI.prototype,"zoomLayer",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([h(!1)],exports.UI.prototype,"selected",void 0),e([h(!1)],exports.UI.prototype,"disabled",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.surfaceType("pixel")],exports.UI.prototype,"maskType",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.naturalBoundsType(1)],exports.UI.prototype,"pixelRatio",void 0),e([t.pathInputType()],exports.UI.prototype,"path",void 0),e([t.pathType()],exports.UI.prototype,"windingRule",void 0),e([_("none")],exports.UI.prototype,"startArrow",void 0),e([_("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([d()],exports.UI.prototype,"shadow",void 0),e([d()],exports.UI.prototype,"innerShadow",void 0),e([d()],exports.UI.prototype,"blur",void 0),e([d()],exports.UI.prototype,"backgroundBlur",void 0),e([d()],exports.UI.prototype,"grayscale",void 0),e([t.dataType()],exports.UI.prototype,"normalStyle",void 0),e([t.dataType()],exports.UI.prototype,"hoverStyle",void 0),e([t.dataType()],exports.UI.prototype,"pressStyle",void 0),e([t.dataType()],exports.UI.prototype,"focusStyle",void 0),e([t.dataType()],exports.UI.prototype,"selectedStyle",void 0),e([t.dataType()],exports.UI.prototype,"disabledStyle",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),exports.UI=M=e([t.useModule(D),t.useModule(E),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{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(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.clear():this.__setBranch(),super.set(e),s.forEach((e=>{r=e.__?e:t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}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(){}},e([t.dataProcessor(f)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const z=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},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)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:o}=this;this.initType(o.type),this.canvas=t.Creator.canvas(o),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,this.canvas,this.selector,o),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,r=o.start),this.hittable=o.hittable,this.fill=o.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.forceRender()}forceRender(e){this.renderer.addBlock(e?new t.Bounds(e):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),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(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}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,s){e&&(t=t.bind(e));const r=this.__nextRenderWait;if(s){for(let e=0;e<r.length;e++)if(r[e]===t){r.splice(e,1);break}}else r.push(t)}zoom(t,e,s){}validScale(t){const{scaleX:e}=this.zoomLayer.__,{min:s,max:r}=this.app.config.zoom,o=Math.abs(e*t);return o<s?t=s/e:o>r&&(t=r/e),t}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.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=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){z.error(t)}}))}},e([t.dataProcessor(m)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}},e([t.dataProcessor(R)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(W),t.rewriteAble(),t.registerUI()],exports.Rect);const H=exports.Rect.prototype,O=exports.Group.prototype,N={},{copy:G,add:V}=t.BoundsHelper;exports.Box=class extends exports.Group{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(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){const t=this.__;if(t.__autoSide&&this.children.length){if(this.leafer&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds(),!t.__autoSize){const e=this.__layout.boxBounds;t.__autoWidth||(e.x=0,e.width=t.width),t.__autoHeight||(e.y=0,e.height=t.height)}}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;G(N,t),super.__updateRenderBounds(),V(t,N)}}__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.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(w)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(H.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(H.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(H.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(H.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(H.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(H.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(H.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(O.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}},e([t.dataProcessor(T)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:j,closePath:Y,ellipse:X}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];r?(o||i?(r<1&&X(p,a,n,a*r,n*r,0,o,i,!1),X(p,a,n,a,n,0,i,o,!0),r<1&&Y(p)):(r<1&&(X(p,a,n,a*r,n*r),j(p,e,n)),X(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(j(p,a,n),X(p,a,n,a,n,0,o,i,!1),Y(p)):X(p,a,n,a,n)}},e([t.dataProcessor(P)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:J,lineTo:K,drawPoints:$}=t.PathCommandDataHelper,{rotate:q,getAngle:Q,getDistance:Z,defaultPoint:tt}=t.PointHelper,{toBounds:et}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,r=t.getPointData();return e&&(r.x=e),s&&q(r,s),r}set toPoint(t){this.width=Z(tt,t),this.rotation=Q(tt,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?$(t,this.__.points,!1):(J(t,0,0),K(t,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?($(t.__pathForRender=[],t.points,t.curve,this.pathClosed),t.__useArrow&&r.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?et(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(I)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:st,cos:rt,PI:ot}=Math,{moveTo:it,lineTo:at,closePath:nt,drawPoints:pt}=t.PathCommandDataHelper,ht=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t),this.pathClosed=!0}__updatePath(){const t=this.__.path=[];if(this.__.points)pt(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;it(t,o,0);for(let e=1;e<r;e++)at(t,o+o*st(2*e*ot/r),i-i*rt(2*e*ot/r))}nt(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(b)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(ht.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(ht.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:_t,cos:dt,PI:lt}=Math,{moveTo:ut,lineTo:ct,closePath:yt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];ut(a,o,0);for(let t=1;t<2*s;t++)ct(a,o+(t%2==0?o:o*r)*_t(t*lt/s),i-(t%2==0?i:i*r)*dt(t*lt/s));yt(a)}},e([t.dataProcessor(S)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(A)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}},e([t.dataProcessor(L)],exports.Canvas.prototype,"__",void 0),e([l(100)],exports.Canvas.prototype,"width",void 0),e([l(100)],exports.Canvas.prototype,"height",void 0),e([l(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([l(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:xt,includes:vt,spread:gt,setList:ft}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=s.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,l=e.__autoWidth,u=e.__autoHeight;e.__lineHeight=g.number(r,a),e.__letterSpacing=g.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoSize,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=s.boxBounds;if(e.__lineHeight<a&&gt(c,a/2),l||u){if(y.x=l?c.x:0,y.y=u?c.y:0,y.width=l?c.width:e.width,y.height=u?c.height:e.height,d){const[t,s,r,o]=e.__padding;l&&(y.x-=o,y.width+=s+o),u&&(y.y-=t,y.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();const x=vt(y,c)?y:c;x!==s.contentBounds?(s.contentBounds=x,s.renderChanged=!0,ft(e.__textBoxBounds={},[y,c])):e.__textBoxBounds=x}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){xt(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(C)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text),exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}},e([t.dataProcessor(k)],exports.Path.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}},e([t.dataProcessor(B)],exports.Pen.prototype,"__",void 0),e([(e,s)=>{t.defineKey(e,s,{get(){return this.__path}})}],exports.Pen.prototype,"path",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath","path"]),t.registerUI()],exports.Pen),exports.BoxData=w,exports.CanvasData=L,exports.ColorConvert={},exports.Effect=a,exports.EllipseData=P,exports.Export=n,exports.FrameData=T,exports.GroupData=f,exports.ImageData=A,exports.LeaferData=m,exports.LineData=I,exports.Paint=o,exports.PaintGradient={},exports.PaintImage=i,exports.PathArrow=r,exports.PathData=k,exports.PenData=B,exports.PolygonData=b,exports.RectData=R,exports.RectRender=W,exports.StarData=S,exports.State=p,exports.TextConvert=s,exports.TextData=C,exports.UIBounds=D,exports.UIData=v,exports.UIRender=E,exports.UnitConvert=g,exports.arrowType=_,exports.effectType=d,exports.resizeType=l,exports.stateType=h,exports.zoomLayerType=u,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/draw",
3
- "version": "1.0.0-rc.16",
3
+ "version": "1.0.0-rc.18",
4
4
  "description": "@leafer-ui/draw",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -29,10 +29,10 @@
29
29
  "leaferjs"
30
30
  ],
31
31
  "dependencies": {
32
- "@leafer/core": "1.0.0-rc.16",
33
- "@leafer-ui/display": "1.0.0-rc.16",
34
- "@leafer-ui/display-module": "1.0.0-rc.16",
35
- "@leafer-ui/decorator": "1.0.0-rc.16",
36
- "@leafer-ui/external": "1.0.0-rc.16"
32
+ "@leafer/core": "1.0.0-rc.18",
33
+ "@leafer-ui/display": "1.0.0-rc.18",
34
+ "@leafer-ui/display-module": "1.0.0-rc.18",
35
+ "@leafer-ui/decorator": "1.0.0-rc.18",
36
+ "@leafer-ui/external": "1.0.0-rc.18"
37
37
  }
38
38
  }