@leafer-ui/draw 1.6.7 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/draw.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineKey, decorateLeafAttr, attr, Plugin, PathConvert, DataHelper, Debug, LeafData, canvasSizeAttrs, UICreator, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, affectRenderBoundsType, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, LeaferImage, ImageEvent, Matrix, PathCreator } from '@leafer/core';
1
+ import { defineKey, decorateLeafAttr, attr, createDescriptor, Plugin, PathConvert, DataHelper, Debug, LeafData, canvasSizeAttrs, UICreator, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, affectRenderBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, LeaferImage, ImageEvent, Matrix, PathCreator } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
 
4
4
  /******************************************************************************
@@ -63,6 +63,11 @@ function zoomLayerType() {
63
63
  });
64
64
  };
65
65
  }
66
+ function createAttr(defaultValue) {
67
+ return (target, key) => {
68
+ defineKey(target, key, createDescriptor(key, defaultValue));
69
+ };
70
+ }
66
71
 
67
72
  function hasTransparent$1(color) {
68
73
  if (!color || color.length === 7 || color.length === 4)
@@ -120,26 +125,9 @@ const emptyPaint = {};
120
125
  const debug$1 = Debug.get('UIData');
121
126
  class UIData extends LeafData {
122
127
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
123
- get __strokeWidth() {
124
- const { strokeWidth, strokeWidthFixed } = this;
125
- if (strokeWidthFixed) {
126
- const ui = this.__leaf;
127
- let { scaleX } = ui.__nowWorld || ui.__world;
128
- if (scaleX < 0)
129
- scaleX = -scaleX;
130
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
131
- }
132
- else
133
- return strokeWidth;
134
- }
135
- get __hasStroke() { return this.stroke && this.strokeWidth; }
136
- get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
137
- get __hasMultiPaint() {
138
- const t = this;
139
- if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
140
- return true;
141
- return t.fill && this.__hasStroke;
142
- }
128
+ get __strokeWidth() { return this.__getRealStrokeWidth(); }
129
+ get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
130
+ get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
143
131
  get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
144
132
  get __hasSurface() { const t = this; return (t.fill || t.stroke); }
145
133
  get __autoWidth() { return !this._width; }
@@ -221,6 +209,21 @@ class UIData extends LeafData {
221
209
  Paint.compute('stroke', this.__leaf);
222
210
  this.__needComputePaint = undefined;
223
211
  }
212
+ __getRealStrokeWidth(childStyle) {
213
+ let { strokeWidth, strokeWidthFixed } = this;
214
+ if (childStyle) {
215
+ if (childStyle.strokeWidth)
216
+ strokeWidth = childStyle.strokeWidth;
217
+ if (childStyle.strokeWidthFixed !== undefined)
218
+ strokeWidthFixed = childStyle.strokeWidthFixed;
219
+ }
220
+ if (strokeWidthFixed) {
221
+ const scale = this.__leaf.getClampRenderScale();
222
+ return scale > 1 ? strokeWidth / scale : strokeWidth;
223
+ }
224
+ else
225
+ return strokeWidth;
226
+ }
224
227
  __setPaint(attrName, value) {
225
228
  this.__setInput(attrName, value);
226
229
  const layout = this.__leaf.__layout;
@@ -245,6 +248,7 @@ class UIData extends LeafData {
245
248
  }
246
249
  else {
247
250
  stintSet$1(this, '__isAlphaPixelStroke', undefined);
251
+ stintSet$1(this, '__hasMultiStrokeStyle', undefined);
248
252
  this._stroke = this.__isStrokes = undefined;
249
253
  }
250
254
  }
@@ -266,8 +270,8 @@ class GroupData extends UIData {
266
270
 
267
271
  class BoxData extends GroupData {
268
272
  get __boxStroke() { return !this.__pathInputed; }
269
- get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
270
- get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
273
+ get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
274
+ get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
271
275
  }
272
276
 
273
277
  class LeaferData extends GroupData {
@@ -387,7 +391,7 @@ class CanvasData extends RectData {
387
391
  const UIBounds = {
388
392
  __updateStrokeSpread() {
389
393
  let width = 0, boxWidth = 0;
390
- const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
394
+ const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
391
395
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
392
396
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
393
397
  if (!data.__boxStroke) {
@@ -407,13 +411,15 @@ const UIBounds = {
407
411
  },
408
412
  __updateRenderSpread() {
409
413
  let width = 0;
410
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
414
+ const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
411
415
  if (shadow)
412
416
  shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
413
417
  if (blur)
414
418
  width = Math.max(width, blur);
415
419
  if (filter)
416
420
  width += Filter.getSpread(filter);
421
+ if (renderSpread)
422
+ width += renderSpread;
417
423
  let shapeWidth = width = Math.ceil(width);
418
424
  if (innerShadow)
419
425
  innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
@@ -429,15 +435,18 @@ const { stintSet } = DataHelper;
429
435
  const UIRender = {
430
436
  __updateChange() {
431
437
  const data = this.__;
438
+ if (data.__useStroke) {
439
+ const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
440
+ stintSet(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
441
+ stintSet(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
442
+ }
432
443
  if (data.__useEffect) {
433
444
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
434
- stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
445
+ stintSet(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
435
446
  data.__useEffect = !!(shadow || otherEffect);
436
447
  }
437
- stintSet(this.__world, 'half', data.__hasHalf);
438
- stintSet(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
439
448
  data.__checkSingle();
440
- stintSet(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
449
+ stintSet(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
441
450
  },
442
451
  __drawFast(canvas, options) {
443
452
  drawFast(this, canvas, options);
@@ -495,18 +504,15 @@ const UIRender = {
495
504
  this.__drawFast(canvas, options);
496
505
  }
497
506
  },
498
- __renderShape(canvas, options, ignoreFill, ignoreStroke) {
499
- if (this.__worldOpacity) {
500
- canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
501
- const { fill, stroke } = this.__;
502
- this.__drawRenderPath(canvas);
503
- if (fill && !ignoreFill)
504
- this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
505
- if (this.__.__isCanvas)
506
- this.__drawAfterFill(canvas, options);
507
- if (stroke && !ignoreStroke)
508
- this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
509
- }
507
+ __drawShape(canvas, options) {
508
+ this.__drawRenderPath(canvas);
509
+ const data = this.__, { fill, stroke } = data;
510
+ if (fill && !options.ignoreFill)
511
+ data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
512
+ if (data.__isCanvas)
513
+ this.__drawAfterFill(canvas, options);
514
+ if (stroke && !options.ignoreStroke)
515
+ data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
510
516
  },
511
517
  __drawAfterFill(canvas, options) {
512
518
  if (this.__.__clipAfterFill) {
@@ -543,17 +549,17 @@ const RectRender = {
543
549
  if (__drawAfterFill)
544
550
  this.__drawAfterFill(canvas, options);
545
551
  if (stroke) {
546
- const { strokeAlign, __strokeWidth } = this.__;
547
- if (!__strokeWidth)
552
+ const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
553
+ if (!strokeWidth)
548
554
  return;
549
- canvas.setStroke(stroke, __strokeWidth, this.__);
550
- const half = __strokeWidth / 2;
555
+ canvas.setStroke(stroke, strokeWidth, this.__);
556
+ const half = strokeWidth / 2;
551
557
  switch (strokeAlign) {
552
558
  case 'center':
553
559
  canvas.strokeRect(0, 0, width, height);
554
560
  break;
555
561
  case 'inside':
556
- width -= __strokeWidth, height -= __strokeWidth;
562
+ width -= strokeWidth, height -= strokeWidth;
557
563
  if (width < 0 || height < 0) {
558
564
  canvas.save();
559
565
  this.__clip(canvas, options);
@@ -564,7 +570,7 @@ const RectRender = {
564
570
  canvas.strokeRect(x + half, y + half, width, height);
565
571
  break;
566
572
  case 'outside':
567
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
573
+ canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
568
574
  break;
569
575
  }
570
576
  }
@@ -577,6 +583,8 @@ let UI = UI_1 = class UI extends Leaf {
577
583
  get isFrame() { return false; }
578
584
  set scale(value) { MathHelper.assignScale(this, value); }
579
585
  get scale() { return this.__.scale; }
586
+ get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
587
+ get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
580
588
  get pen() {
581
589
  const { path } = this.__;
582
590
  pen.set(this.path = path || []);
@@ -631,12 +639,14 @@ let UI = UI_1 = class UI extends Leaf {
631
639
  }
632
640
  }
633
641
  __updateRenderPath() {
634
- if (this.__.path) {
635
- const data = this.__;
642
+ const data = this.__;
643
+ if (data.path) {
636
644
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
637
645
  if (data.__useArrow)
638
646
  PathArrow.addArrows(this, !data.cornerRadius);
639
647
  }
648
+ else
649
+ data.__pathForRender && (data.__pathForRender = undefined);
640
650
  }
641
651
  __drawRenderPath(canvas) {
642
652
  canvas.beginPath();
@@ -789,6 +799,9 @@ __decorate([
789
799
  __decorate([
790
800
  naturalBoundsType(1)
791
801
  ], UI.prototype, "pixelRatio", void 0);
802
+ __decorate([
803
+ affectRenderBoundsType(0)
804
+ ], UI.prototype, "renderSpread", void 0);
792
805
  __decorate([
793
806
  pathInputType()
794
807
  ], UI.prototype, "path", void 0);
@@ -847,13 +860,13 @@ __decorate([
847
860
  surfaceType()
848
861
  ], UI.prototype, "fill", void 0);
849
862
  __decorate([
850
- strokeType()
863
+ strokeType(undefined, true)
851
864
  ], UI.prototype, "stroke", void 0);
852
865
  __decorate([
853
866
  strokeType('inside')
854
867
  ], UI.prototype, "strokeAlign", void 0);
855
868
  __decorate([
856
- strokeType(1)
869
+ strokeType(1, true)
857
870
  ], UI.prototype, "strokeWidth", void 0);
858
871
  __decorate([
859
872
  strokeType(false)
@@ -945,7 +958,8 @@ let Group = class Group extends UI {
945
958
  }
946
959
  toJSON(options) {
947
960
  const data = super.toJSON(options);
948
- data.children = this.children.map(child => child.toJSON(options));
961
+ if (!this.childlessJSON)
962
+ data.children = this.children.map(child => child.toJSON(options));
949
963
  return data;
950
964
  }
951
965
  pick(_hitPoint, _options) { return undefined; }
@@ -1280,7 +1294,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
1280
1294
  list.push(item);
1281
1295
  this.requestRender();
1282
1296
  }
1283
- zoom(_zoomType, _padding, _fixedScale, _transition) {
1297
+ zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
1284
1298
  return Plugin.need('view');
1285
1299
  }
1286
1300
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
@@ -1325,7 +1339,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
1325
1339
  Leafer_1.list.remove(this);
1326
1340
  try {
1327
1341
  this.stop();
1328
- this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
1342
+ this.emitLeafer(LeaferEvent.END);
1329
1343
  this.__removeListenEvents();
1330
1344
  this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
1331
1345
  this.__controllers.length = 0;
@@ -1392,8 +1406,8 @@ let Box = class Box extends Group {
1392
1406
  __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
1393
1407
  __updateRectBoxBounds() { }
1394
1408
  __updateBoxBounds(_secondLayout) {
1395
- const data = this.__;
1396
1409
  if (this.children.length && !this.pathInputed) {
1410
+ const data = this.__;
1397
1411
  if (data.__autoSide) {
1398
1412
  if (data.__hasSurface)
1399
1413
  this.__extraUpdate();
@@ -1420,20 +1434,26 @@ let Box = class Box extends Group {
1420
1434
  __updateStrokeBounds() { }
1421
1435
  __updateRenderBounds() {
1422
1436
  let isOverflow;
1423
- const { renderBounds } = this.__layout;
1424
1437
  if (this.children.length) {
1438
+ const data = this.__, { renderBounds, boxBounds } = this.__layout;
1425
1439
  super.__updateRenderBounds();
1426
1440
  copy(childrenRenderBounds, renderBounds);
1427
1441
  this.__updateRectRenderBounds();
1428
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
1429
- if (isOverflow && this.__.overflow !== 'hide')
1442
+ if (data.scrollY || data.scrollX) {
1443
+ childrenRenderBounds.x += data.scrollX;
1444
+ childrenRenderBounds.y += data.scrollY;
1445
+ }
1446
+ isOverflow = !includes$1(boxBounds, childrenRenderBounds);
1447
+ if (isOverflow && data.overflow !== 'hide')
1430
1448
  add(renderBounds, childrenRenderBounds);
1431
1449
  }
1432
1450
  else
1433
1451
  this.__updateRectRenderBounds();
1434
1452
  DataHelper.stintSet(this, 'isOverflow', isOverflow);
1453
+ this.__updateScrollBar();
1435
1454
  }
1436
1455
  __updateRectRenderBounds() { }
1456
+ __updateScrollBar() { }
1437
1457
  __updateRectChange() { }
1438
1458
  __updateChange() {
1439
1459
  super.__updateChange();
@@ -1450,10 +1470,12 @@ let Box = class Box extends Group {
1450
1470
  if (this.children.length)
1451
1471
  this.__renderGroup(canvas, options);
1452
1472
  }
1473
+ if (this.scrollBar)
1474
+ this.scrollBar.__render(canvas, options);
1453
1475
  }
1454
1476
  __drawContent(canvas, options) {
1455
1477
  this.__renderGroup(canvas, options);
1456
- if (this.__.__hasStroke) {
1478
+ if (this.__.__useStroke || this.__.__useEffect) {
1457
1479
  canvas.setWorld(this.__nowWorld);
1458
1480
  this.__drawRenderPath(canvas);
1459
1481
  }
@@ -1673,8 +1695,8 @@ let Polygon = class Polygon extends UI {
1673
1695
  for (let i = 1; i < sides; i++) {
1674
1696
  lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
1675
1697
  }
1698
+ closePath$1(path);
1676
1699
  }
1677
- closePath$1(path);
1678
1700
  }
1679
1701
  __updateRenderPath() { }
1680
1702
  __updateBoxBounds() { }
@@ -1912,6 +1934,11 @@ let Text = class Text extends UI {
1912
1934
  return;
1913
1935
  super.__draw(canvas, options, originCanvas);
1914
1936
  }
1937
+ __drawShape(canvas, options) {
1938
+ if (options.shape)
1939
+ this.__box && this.__box.__drawShape(canvas, options);
1940
+ super.__drawShape(canvas, options);
1941
+ }
1915
1942
  destroy() {
1916
1943
  if (this.boxStyle)
1917
1944
  this.boxStyle = null;
@@ -2069,4 +2096,4 @@ function penPathType() {
2069
2096
  };
2070
2097
  }
2071
2098
 
2072
- export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, Transition, UI, UIBounds, UIData, UIRender, UnitConvert, effectType, resizeType, zoomLayerType };
2099
+ export { Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Filter, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, Line, LineData, MyImage, Paint, PaintGradient, PaintImage, Path, PathArrow, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, State, Text, TextConvert, TextData, Transition, UI, UIBounds, UIData, UIRender, UnitConvert, createAttr, effectType, resizeType, zoomLayerType };
@@ -1,2 +1,2 @@
1
- import{defineKey as t,decorateLeafAttr as e,attr as i,Plugin as s,PathConvert as o,DataHelper as r,Debug as a,LeafData as n,canvasSizeAttrs as _,UICreator as h,dataProcessor as d,dataType as p,surfaceType as l,opacityType as u,visibleType as c,sortType as y,maskType as g,eraserType as v,positionType as f,boundsType as w,scaleType as x,rotationType as m,autoLayoutType as S,naturalBoundsType as R,pathInputType as k,pathType as b,hitType as B,strokeType as A,cursorType as C,rewrite as P,Leaf as F,useModule as W,rewriteAble as E,MathHelper as I,pen as T,PathCorner as D,PathDrawer as z,registerUI as L,Branch as M,LeafList as O,Resource as N,getBoundsData as V,Creator as j,CanvasManager as Y,WaitHelper as H,LeaferEvent as U,Bounds as X,ResizeEvent as q,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as Q,ImageManager as Z,BoundsHelper as tt,affectRenderBoundsType as et,PathCommandDataHelper as it,Platform as st,PointHelper as ot,PathBounds as rt,affectStrokeBoundsType as at,getPointData as nt,LeaferImage as _t,ImageEvent as ht,Matrix as dt,PathCreator as pt}from"@leafer/core";export*from"@leafer/core";function lt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function ut(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function ct(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function yt(){return(e,i)=>{const s="_"+i;t(e,i,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const gt={},vt={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},wt={},xt={},mt={},St={},Rt={},kt={apply(){s.need("filter")}},bt={},Bt={setStyleName:()=>s.need("state"),set:()=>s.need("state")},At={list:{},register(t,e){At.list[t]=e},get:t=>At.list[t]},{parse:Ct,objectToCanvasData:Pt}=o,{stintSet:Ft}=r,{hasTransparent:Wt}=vt,Et={},It=a.get("UIData");class Tt extends n{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasHalf(){const t=this;return t.stroke&&"center"===t.strokeAlign&&t.strokeWidth%2||void 0}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,It.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,It.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&this.__setPaint("fill",t):(Ft(this,"__isTransparentFill",Wt(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&this.__setPaint("stroke",t):(Ft(this,"__isTransparentStroke",Wt(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Ct(t):Pt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){Dt(this,"shadow",t)}setInnerShadow(t){Dt(this,"innerShadow",t)}setFilter(t){Dt(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&xt.compute("fill",this.__leaf),e&&xt.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),e instanceof Array&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=Et)):(this.__isStrokes=!0,this._stroke||(this._stroke=Et))}__removePaint(t,e){e&&this.__removeInput(t),mt.recycleImage(t,this),"fill"===t?(Ft(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(Ft(this,"__isAlphaPixelStroke",void 0),this._stroke=this.__isStrokes=void 0)}}function Dt(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}class zt extends Tt{}class Lt extends zt{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class Mt extends zt{__getInputData(t,e){const i=super.__getInputData(t,e);return _.forEach((t=>delete i[t])),i}}class Ot extends Lt{}class Nt extends Tt{}class Vt extends Tt{get __boxStroke(){return!this.__pathInputed}}class jt extends Tt{get __boxStroke(){return!this.__pathInputed}}class Yt extends Tt{}class Ht extends Tt{}class Ut extends Tt{get __pathInputed(){return 2}}class Xt extends zt{}const qt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Gt extends Tt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),t=qt[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=h.get("Rect",0);const o=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=o.boxBounds),i.set(t),r.strokeChanged&&o.strokeChange(),r.renderChanged&&o.renderChange(),i.__updateChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class Jt extends Vt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class $t extends Vt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Kt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i,r=this.__box;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),r&&(t=Math.max(r.__layout.strokeSpread=r.__updateStrokeSpread(),t),e=r.__layout.strokeBoxSpread),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),r&&(t+=kt.getSpread(r));let a=t=Math.ceil(t);return i&&i.forEach((t=>a=Math.max(a,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(a=Math.max(a,o)),this.__layout.renderShapeSpread=a,t+=this.__layout.strokeSpread||0,this.__box?Math.max(this.__box.__updateRenderSpread(),t):t}},{stintSet:Qt}=r,Zt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,o=t.innerShadow||t.blur||t.backgroundBlur||t.filter;Qt(t,"__isFastShadow",e&&!o&&e.length<2&&!e[0].spread&&!(e[0].box&&t.__isTransparentFill)&&i&&!(i instanceof Array&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!o)}Qt(this.__world,"half",t.__hasHalf),Qt(t,"__fillAfterStroke",t.stroke&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill),t.__checkSingle(),Qt(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){te(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:r,__drawAfterFill:a,__fillAfterStroke:n,__isFastShadow:_}=s;if(this.__drawRenderPath(t),s.__useEffect&&!_){const _=xt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:d,filter:p}=s;h&&Rt.shadow(this,t,_),n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),d&&Rt.innerShadow(this,t,_),r&&!n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),p&&kt.apply(p,this,this.__nowWorld,t,i,_),_.worldCanvas&&_.worldCanvas.recycle(),_.canvas.recycle()}else{if(n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),_){const e=s.shadow[0],{scaleX:i,scaleY:o}=this.__nowWorld;t.save(),t.setWorldShadow(e.x*i,e.y*o,e.blur*i,vt.string(e.color))}o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),_&&t.restore(),a&&this.__drawAfterFill(t,e),r&&!n&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t))}}else s.__pathInputed?te(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__isAlphaPixelFill?xt.fills(o,this,t):xt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__isAlphaPixelStroke?xt.strokes(r,this,t):xt.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function te(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r,__fillAfterStroke:a}=t.__;t.__drawRenderPath(e),a&&xt.stroke(o,t,e),s&&xt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&!a&&xt.stroke(o,t,e)}const ee={__drawFast(t,e){let{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;const{fill:a,stroke:n,__drawAfterFill:_}=this.__;if(a&&(t.fillStyle=a,t.fillRect(i,s,o,r)),_&&this.__drawAfterFill(t,e),n){const{strokeAlign:a,__strokeWidth:_}=this.__;if(!_)return;t.setStroke(n,_,this.__);const h=_/2;switch(a){case"center":t.strokeRect(0,0,o,r);break;case"inside":o-=_,r-=_,o<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+h,s+h,o,r),t.restore()):t.strokeRect(i+h,s+h,o,r);break;case"outside":t.strokeRect(i-h,s-h,o+_,r+_)}}}};var ie;let se=ie=class extends F{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){I.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return T.set(this.path=t||[]),t||this.__drawPathByBox(T),T}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return s.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return s.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(T.set(i=[]),this.__drawPathByBox(T)),t?o.toCanvasData(i,!0):i}getPathString(t,e,i){return o.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||bt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?D.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&wt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?z.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}drawImagePlaceholder(t,e){xt.fill(this.__.placeholderColor,this,t)}animate(t,e,i,o){return s.need("animate")}killAnimate(t,e){}export(t,e){return s.need("export")}syncExport(t,e){return s.need("export")}clone(t){const e=r.clone(this.toJSON());return t&&Object.assign(e,t),ie.one(e)}static one(t,e,i,s,o){return h.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){L()(this)}static registerData(t){d(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};lt([d(Tt)],se.prototype,"__",void 0),lt([yt()],se.prototype,"zoomLayer",void 0),lt([p("")],se.prototype,"id",void 0),lt([p("")],se.prototype,"name",void 0),lt([p("")],se.prototype,"className",void 0),lt([l("pass-through")],se.prototype,"blendMode",void 0),lt([u(1)],se.prototype,"opacity",void 0),lt([c(!0)],se.prototype,"visible",void 0),lt([l(!1)],se.prototype,"locked",void 0),lt([l(!1)],se.prototype,"dim",void 0),lt([l(!1)],se.prototype,"dimskip",void 0),lt([y(0)],se.prototype,"zIndex",void 0),lt([g(!1)],se.prototype,"mask",void 0),lt([v(!1)],se.prototype,"eraser",void 0),lt([f(0,!0)],se.prototype,"x",void 0),lt([f(0,!0)],se.prototype,"y",void 0),lt([w(100,!0)],se.prototype,"width",void 0),lt([w(100,!0)],se.prototype,"height",void 0),lt([x(1,!0)],se.prototype,"scaleX",void 0),lt([x(1,!0)],se.prototype,"scaleY",void 0),lt([m(0,!0)],se.prototype,"rotation",void 0),lt([m(0,!0)],se.prototype,"skewX",void 0),lt([m(0,!0)],se.prototype,"skewY",void 0),lt([f(0,!0)],se.prototype,"offsetX",void 0),lt([f(0,!0)],se.prototype,"offsetY",void 0),lt([f(0,!0)],se.prototype,"scrollX",void 0),lt([f(0,!0)],se.prototype,"scrollY",void 0),lt([S()],se.prototype,"origin",void 0),lt([S()],se.prototype,"around",void 0),lt([p(!1)],se.prototype,"lazy",void 0),lt([R(1)],se.prototype,"pixelRatio",void 0),lt([k()],se.prototype,"path",void 0),lt([b()],se.prototype,"windingRule",void 0),lt([b(!0)],se.prototype,"closed",void 0),lt([w(0)],se.prototype,"padding",void 0),lt([w(!1)],se.prototype,"lockRatio",void 0),lt([w()],se.prototype,"widthRange",void 0),lt([w()],se.prototype,"heightRange",void 0),lt([p(!1)],se.prototype,"draggable",void 0),lt([p()],se.prototype,"dragBounds",void 0),lt([p(!1)],se.prototype,"editable",void 0),lt([B(!0)],se.prototype,"hittable",void 0),lt([B("path")],se.prototype,"hitFill",void 0),lt([A("path")],se.prototype,"hitStroke",void 0),lt([B(!1)],se.prototype,"hitBox",void 0),lt([B(!0)],se.prototype,"hitChildren",void 0),lt([B(!0)],se.prototype,"hitSelf",void 0),lt([B()],se.prototype,"hitRadius",void 0),lt([C("")],se.prototype,"cursor",void 0),lt([l()],se.prototype,"fill",void 0),lt([A()],se.prototype,"stroke",void 0),lt([A("inside")],se.prototype,"strokeAlign",void 0),lt([A(1)],se.prototype,"strokeWidth",void 0),lt([A(!1)],se.prototype,"strokeWidthFixed",void 0),lt([A("none")],se.prototype,"strokeCap",void 0),lt([A("miter")],se.prototype,"strokeJoin",void 0),lt([A()],se.prototype,"dashPattern",void 0),lt([A(0)],se.prototype,"dashOffset",void 0),lt([A(10)],se.prototype,"miterLimit",void 0),lt([b(0)],se.prototype,"cornerRadius",void 0),lt([b()],se.prototype,"cornerSmoothing",void 0),lt([ut()],se.prototype,"shadow",void 0),lt([ut()],se.prototype,"innerShadow",void 0),lt([ut()],se.prototype,"blur",void 0),lt([ut()],se.prototype,"backgroundBlur",void 0),lt([ut()],se.prototype,"grayscale",void 0),lt([ut()],se.prototype,"filter",void 0),lt([l()],se.prototype,"placeholderColor",void 0),lt([p(100)],se.prototype,"placeholderDelay",void 0),lt([p({})],se.prototype,"data",void 0),lt([P(F.prototype.reset)],se.prototype,"reset",null),se=ie=lt([W(Kt),W(Zt),E()],se);let oe=class extends se{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var re;lt([d(zt)],oe.prototype,"__",void 0),lt([w(0)],oe.prototype,"width",void 0),lt([w(0)],oe.prototype,"height",void 0),oe=lt([W(M),L()],oe);const ae=a.get("Leafer");let ne=re=class extends oe{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&N.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||V()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),re.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,r.assign(s,t));const o=this.canvas=j.canvas(s);this.__controllers.push(this.renderer=j.renderer(this,o,s),this.watcher=j.watcher(this,s),this.layouter=j.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=j.selector(this),this.interaction=j.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=j.hitCanvasManager()),this.canvasManager=new Y,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(U.RESTART):this.emitLeafer(U.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(U.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=r.copyAttrs({},t,_);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=r.copyAttrs({},this.canvas,_);e.resize(t),this.updateLazyBounds(),this.__onResize(new q(t,i))}__onResize(t){this.emitEvent(t),r.copyAttrs(this.__,t,_),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(_.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&_.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=r.copyAttrs({},this.canvas,_);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(U.BEFORE_READY),this.emitLeafer(U.READY),this.emitLeafer(U.AFTER_READY),H.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(U.VIEW_READY),H.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,a.x+a.width)),i||(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(U.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,o){return s.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new U(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once([[U.START,()=>J.end(t)],[$.START,this.updateLazyBounds,this],[K.START,this.__onCreated,this],[K.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[Q.DATA,this.__onWatchData,this],[$.END,this.__onLayoutEnd,this],[K.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){re.list.remove(this);try{this.stop(),this.emitEvent(new U(U.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Z.clearRecycled()}),100)}catch(t){ae.error(t)}}};t?e():setTimeout(e)}};ne.list=new O,lt([d(Mt)],ne.prototype,"__",void 0),lt([w()],ne.prototype,"pixelRatio",void 0),ne=re=lt([L()],ne);let _e=class extends se{get __tag(){return"Rect"}constructor(t){super(t)}};lt([d(Vt)],_e.prototype,"__",void 0),_e=lt([W(ee),E(),L()],_e);const{copy:he,add:de,includes:pe}=tt,le=_e.prototype,ue=oe.prototype,ce={};let ye=class extends oe{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length&&!this.pathInputed)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),he(ce,e),this.__updateRectRenderBounds(),t=!pe(e,ce),t&&"hide"!==this.__.overflow&&de(e,ce)):this.__updateRectRenderBounds(),r.stintSet(this,"isOverflow",t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};lt([d(Lt)],ye.prototype,"__",void 0),lt([w(100)],ye.prototype,"width",void 0),lt([w(100)],ye.prototype,"height",void 0),lt([p(!1)],ye.prototype,"resizeChildren",void 0),lt([et("show")],ye.prototype,"overflow",void 0),lt([P(le.__updateStrokeSpread)],ye.prototype,"__updateStrokeSpread",null),lt([P(le.__updateRenderSpread)],ye.prototype,"__updateRectRenderSpread",null),lt([P(le.__updateBoxBounds)],ye.prototype,"__updateRectBoxBounds",null),lt([P(le.__updateStrokeBounds)],ye.prototype,"__updateStrokeBounds",null),lt([P(le.__updateRenderBounds)],ye.prototype,"__updateRectRenderBounds",null),lt([P(le.__updateChange)],ye.prototype,"__updateRectChange",null),lt([P(le.__render)],ye.prototype,"__renderRect",null),lt([P(ue.__render)],ye.prototype,"__renderGroup",null),ye=lt([E(),L()],ye);let ge=class extends ye{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};lt([d(Ot)],ge.prototype,"__",void 0),lt([l("#FFFFFF")],ge.prototype,"fill",void 0),lt([et("hide")],ge.prototype,"overflow",void 0),ge=lt([L()],ge);const{moveTo:ve,closePath:fe,ellipse:we}=it;let xe=class extends se{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&we(n,r,a,r*i,a*i,0,s,o,!1),we(n,r,a,r,a,0,o,s,!0),i<1&&fe(n)):(i<1&&(we(n,r,a,r*i,a*i),ve(n,t,a)),we(n,r,a,r,a,0,360,0,!0)),st.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(ve(n,r,a),we(n,r,a,r,a,0,s,o,!1),fe(n)):we(n,r,a,r,a)}};lt([d(jt)],xe.prototype,"__",void 0),lt([b(0)],xe.prototype,"innerRadius",void 0),lt([b(0)],xe.prototype,"startAngle",void 0),lt([b(0)],xe.prototype,"endAngle",void 0),xe=lt([L()],xe);const{moveTo:me,lineTo:Se,drawPoints:Re}=it,{rotate:ke,getAngle:be,getDistance:Be,defaultPoint:Ae}=ot,{toBounds:Ce}=rt;let Pe=class extends se{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=nt();return t&&(i.x=t),e&&ke(i,e),i}set toPoint(t){this.width=Be(Ae,t),this.rotation=be(Ae,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?Re(e,t.points,!1,t.closed):(me(e,0,0),Se(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(Re(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&wt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?Ce(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};lt([d(Nt)],Pe.prototype,"__",void 0),lt([at("center")],Pe.prototype,"strokeAlign",void 0),lt([w(0)],Pe.prototype,"height",void 0),lt([b()],Pe.prototype,"points",void 0),lt([b(0)],Pe.prototype,"curve",void 0),lt([b(!1)],Pe.prototype,"closed",void 0),Pe=lt([L()],Pe);const{sin:Fe,cos:We,PI:Ee}=Math,{moveTo:Ie,lineTo:Te,closePath:De,drawPoints:ze}=it,Le=Pe.prototype;let Me=class extends se{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)ze(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;Ie(t,o,0);for(let e=1;e<s;e++)Te(t,o+o*Fe(2*e*Ee/s),r-r*We(2*e*Ee/s))}De(t)}__updateRenderPath(){}__updateBoxBounds(){}};lt([d(Yt)],Me.prototype,"__",void 0),lt([b(3)],Me.prototype,"sides",void 0),lt([b()],Me.prototype,"points",void 0),lt([b(0)],Me.prototype,"curve",void 0),lt([P(Le.__updateRenderPath)],Me.prototype,"__updateRenderPath",null),lt([P(Le.__updateBoxBounds)],Me.prototype,"__updateBoxBounds",null),Me=lt([E(),L()],Me);const{sin:Oe,cos:Ne,PI:Ve}=Math,{moveTo:je,lineTo:Ye,closePath:He}=it;let Ue=class extends se{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];je(a,o,0);for(let t=1;t<2*i;t++)Ye(a,o+(t%2==0?o:o*s)*Oe(t*Ve/i),r-(t%2==0?r:r*s)*Ne(t*Ve/i));He(a)}};lt([d(Ht)],Ue.prototype,"__",void 0),lt([b(5)],Ue.prototype,"corners",void 0),lt([b(.382)],Ue.prototype,"innerRadius",void 0),Ue=lt([L()],Ue);let Xe=class extends _e{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return t instanceof Array&&t[0].image}constructor(t){super(t)}};lt([d(Jt)],Xe.prototype,"__",void 0),lt([w("")],Xe.prototype,"url",void 0),Xe=lt([L()],Xe);const qe=Xe;let Ge=class extends _e{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=j.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new _t({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new ht(ht.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new dt(t.worldTransform).invert(),r=new dt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}};lt([d($t)],Ge.prototype,"__",void 0),lt([ct(100)],Ge.prototype,"width",void 0),lt([ct(100)],Ge.prototype,"height",void 0),lt([ct(1)],Ge.prototype,"pixelRatio",void 0),lt([ct(!0)],Ge.prototype,"smooth",void 0),lt([p(!1)],Ge.prototype,"safeResize",void 0),lt([ct()],Ge.prototype,"contextSettings",void 0),Ge=lt([L()],Ge);const{copyAndSpread:Je,includes:$e,spread:Ke,setList:Qe}=tt;let Ze=class extends se{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}constructor(t){super(t)}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=ft.number(e,o),t.__letterSpacing=ft.number(i,o),t.__padding=h?I.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=gt.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:a,__autoHeight:n}=t;this.__updateTextDrawData();const{bounds:_}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=_,t.__lineHeight<i&&Ke(_,i/2),a||n){if(h.x=a?_.x:0,h.y=n?_.y:0,h.width=a?_.width:t.width,h.height=n?_.height:t.height,o){const[e,i,s,o]=t.__padding;a&&(h.x-=o,h.width+=i+o),n&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),r.stintSet(this,"isOverflow",!$e(h,_)),this.isOverflow?(Qe(t.__textBoxBounds={},[h,_]),e.renderChanged=!0):t.__textBoxBounds=h}__onUpdateSize(){this.__box&&this.__box.__onUpdateSize(),super.__onUpdateSize()}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;Je(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};lt([d(Gt)],Ze.prototype,"__",void 0),lt([w(0)],Ze.prototype,"width",void 0),lt([w(0)],Ze.prototype,"height",void 0),lt([l()],Ze.prototype,"boxStyle",void 0),lt([p(!1)],Ze.prototype,"resizeFontSize",void 0),lt([l("#000000")],Ze.prototype,"fill",void 0),lt([at("outside")],Ze.prototype,"strokeAlign",void 0),lt([B("all")],Ze.prototype,"hitFill",void 0),lt([w("")],Ze.prototype,"text",void 0),lt([w("")],Ze.prototype,"placeholder",void 0),lt([w("caption")],Ze.prototype,"fontFamily",void 0),lt([w(12)],Ze.prototype,"fontSize",void 0),lt([w("normal")],Ze.prototype,"fontWeight",void 0),lt([w(!1)],Ze.prototype,"italic",void 0),lt([w("none")],Ze.prototype,"textCase",void 0),lt([w("none")],Ze.prototype,"textDecoration",void 0),lt([w(0)],Ze.prototype,"letterSpacing",void 0),lt([w({type:"percent",value:1.5})],Ze.prototype,"lineHeight",void 0),lt([w(0)],Ze.prototype,"paraIndent",void 0),lt([w(0)],Ze.prototype,"paraSpacing",void 0),lt([w("x")],Ze.prototype,"writingMode",void 0),lt([w("left")],Ze.prototype,"textAlign",void 0),lt([w("top")],Ze.prototype,"verticalAlign",void 0),lt([w(!0)],Ze.prototype,"autoSizeAlign",void 0),lt([w("normal")],Ze.prototype,"textWrap",void 0),lt([w("show")],Ze.prototype,"textOverflow",void 0),lt([l(!1)],Ze.prototype,"textEditing",void 0),Ze=lt([L()],Ze);let ti=class extends se{get __tag(){return"Path"}constructor(t){super(t)}};lt([d(Ut)],ti.prototype,"__",void 0),lt([at("center")],ti.prototype,"strokeAlign",void 0),ti=lt([L()],ti);let ei=class extends oe{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new ti(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};lt([d(Xt)],ei.prototype,"__",void 0),lt([(e,i)=>{t(e,i,{get(){return this.__path}})}],ei.prototype,"path",void 0),ei=lt([W(pt,["set","path","paint"]),L()],ei);export{ye as Box,Lt as BoxData,Ge as Canvas,$t as CanvasData,vt as ColorConvert,Rt as Effect,xe as Ellipse,jt as EllipseData,bt as Export,kt as Filter,ge as Frame,Ot as FrameData,oe as Group,zt as GroupData,Xe as Image,Jt as ImageData,ne as Leafer,Mt as LeaferData,Pe as Line,Nt as LineData,qe as MyImage,xt as Paint,St as PaintGradient,mt as PaintImage,ti as Path,wt as PathArrow,Ut as PathData,ei as Pen,Xt as PenData,Me as Polygon,Yt as PolygonData,_e as Rect,Vt as RectData,ee as RectRender,Ue as Star,Ht as StarData,Bt as State,Ze as Text,gt as TextConvert,Gt as TextData,At as Transition,se as UI,Kt as UIBounds,Tt as UIData,Zt as UIRender,ft as UnitConvert,ut as effectType,ct as resizeType,yt as zoomLayerType};
1
+ import{defineKey as t,decorateLeafAttr as e,attr as i,createDescriptor as s,Plugin as o,PathConvert as r,DataHelper as a,Debug as n,LeafData as _,canvasSizeAttrs as h,UICreator as d,dataProcessor as p,dataType as l,surfaceType as u,opacityType as c,visibleType as y,sortType as g,maskType as v,eraserType as f,positionType as w,boundsType as x,scaleType as S,rotationType as m,autoLayoutType as R,naturalBoundsType as k,affectRenderBoundsType as b,pathInputType as B,pathType as A,hitType as C,strokeType as P,cursorType as F,rewrite as W,Leaf as E,useModule as I,rewriteAble as T,MathHelper as D,pen as z,PathCorner as L,PathDrawer as M,registerUI as O,Branch as N,LeafList as Y,Resource as V,getBoundsData as j,Creator as H,CanvasManager as U,WaitHelper as X,LeaferEvent as J,Bounds as q,ResizeEvent as G,AutoBounds as $,Run as K,LayoutEvent as Q,RenderEvent as Z,WatchEvent as tt,ImageManager as et,BoundsHelper as it,PathCommandDataHelper as st,Platform as ot,PointHelper as rt,PathBounds as at,affectStrokeBoundsType as nt,getPointData as _t,LeaferImage as ht,ImageEvent as dt,Matrix as pt,PathCreator as lt}from"@leafer/core";export*from"@leafer/core";function ut(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function ct(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function yt(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function gt(){return(e,i)=>{const s="_"+i;t(e,i,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}function vt(e){return(i,o)=>{t(i,o,s(o,e))}}"function"==typeof SuppressedError&&SuppressedError;const ft={},wt={hasTransparent:function(t){if(!t||7===t.length||4===t.length)return!1;if("transparent"===t)return!0;const e=t[0];if("#"===e)switch(t.length){case 5:return"f"!==t[4]&&"F"!==t[4];case 9:return"f"!==t[7]&&"F"!==t[7]||"f"!==t[8]&&"F"!==t[8]}else if(("r"===e||"h"===e)&&"a"===t[3]){const e=t.lastIndexOf(",");if(e>-1)return parseFloat(t.slice(e+1))<1}return!1}},xt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},St={},mt={},Rt={},kt={},bt={},Bt={apply(){o.need("filter")}},At={},Ct={setStyleName:()=>o.need("state"),set:()=>o.need("state")},Pt={list:{},register(t,e){Pt.list[t]=e},get:t=>Pt.list[t]},{parse:Ft,objectToCanvasData:Wt}=r,{stintSet:Et}=a,{hasTransparent:It}=wt,Tt={},Dt=n.get("UIData");class zt extends _{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){return this.__getRealStrokeWidth()}get __maxStrokeWidth(){const t=this;return t.__hasMultiStrokeStyle?Math.max(t.__hasMultiStrokeStyle,t.strokeWidth):t.strokeWidth}get __hasMultiPaint(){const t=this;return t.fill&&this.__useStroke||t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Dt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Dt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&this.__setPaint("fill",t):(Et(this,"__isTransparentFill",It(t)),this.__isFills&&this.__removePaint("fill",!0),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&this.__setPaint("stroke",t):(Et(this,"__isTransparentStroke",It(t)),this.__isStrokes&&this.__removePaint("stroke",!0),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Ft(t):Wt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){Lt(this,"shadow",t)}setInnerShadow(t){Lt(this,"innerShadow",t)}setFilter(t){Lt(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&mt.compute("fill",this.__leaf),e&&mt.compute("stroke",this.__leaf),this.__needComputePaint=void 0}__getRealStrokeWidth(t){let{strokeWidth:e,strokeWidthFixed:i}=this;if(t&&(t.strokeWidth&&(e=t.strokeWidth),void 0!==t.strokeWidthFixed&&(i=t.strokeWidthFixed)),i){const t=this.__leaf.getClampRenderScale();return t>1?e/t:e}return e}__setPaint(t,e){this.__setInput(t,e);const i=this.__leaf.__layout;i.boxChanged||i.boxChange(),e instanceof Array&&!e.length?this.__removePaint(t):"fill"===t?(this.__isFills=!0,this._fill||(this._fill=Tt)):(this.__isStrokes=!0,this._stroke||(this._stroke=Tt))}__removePaint(t,e){e&&this.__removeInput(t),Rt.recycleImage(t,this),"fill"===t?(Et(this,"__isAlphaPixelFill",void 0),this._fill=this.__isFills=void 0):(Et(this,"__isAlphaPixelStroke",void 0),Et(this,"__hasMultiStrokeStyle",void 0),this._stroke=this.__isStrokes=void 0)}}function Lt(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=void 0)):i=i&&!1!==i.visible?[i]:void 0,t["_"+e]=i}class Mt extends zt{}class Ot extends Mt{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return this.__single||this.__clipAfterFill}get __clipAfterFill(){const t=this;return"hide"===t.overflow&&t.__leaf.children.length&&(t.__leaf.isOverflow||super.__clipAfterFill)}}class Nt extends Mt{__getInputData(t,e){const i=super.__getInputData(t,e);return h.forEach((t=>delete i[t])),i}}class Yt extends Ot{}class Vt extends zt{}class jt extends zt{get __boxStroke(){return!this.__pathInputed}}class Ht extends zt{get __boxStroke(){return!this.__pathInputed}}class Ut extends zt{}class Xt extends zt{}class Jt extends zt{get __pathInputed(){return 2}}class qt extends Mt{}const Gt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class $t extends zt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),t=Gt[t]||400):this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=d.get("Rect",0);const o=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=o.boxBounds),i.set(t),r.strokeChanged&&o.strokeChange(),r.renderChanged&&o.renderChange(),i.__updateChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class Kt extends jt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Qt extends jt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Zt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,__maxStrokeWidth:o}=i,r=this.__box;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),r&&(t=Math.max(r.__layout.strokeSpread=r.__updateStrokeSpread(),t),e=r.__layout.strokeBoxSpread),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r,renderSpread:a}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),r&&(t+=Bt.getSpread(r)),a&&(t+=a);let n=t=Math.ceil(t);return i&&i.forEach((t=>n=Math.max(n,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(n=Math.max(n,o)),this.__layout.renderShapeSpread=n,t+=this.__layout.strokeSpread||0,this.__box?Math.max(this.__box.__updateRenderSpread(),t):t}},{stintSet:te}=a,ee={__updateChange(){const t=this.__;if(t.__useStroke){const e=t.__useStroke=!(!t.stroke||!t.strokeWidth);te(this.__world,"half",e&&"center"===t.strokeAlign&&t.strokeWidth%2),te(t,"__fillAfterStroke",e&&"outside"===t.strokeAlign&&t.fill&&!t.__isTransparentFill)}if(t.__useEffect){const{shadow:e,fill:i,stroke:s}=t,o=t.innerShadow||t.blur||t.backgroundBlur||t.filter;te(t,"__isFastShadow",e&&!o&&e.length<2&&!e[0].spread&&i&&!t.__isTransparentFill&&!(i instanceof Array&&i.length>1)&&(this.useFastShadow||!s||s&&"inside"===t.strokeAlign)),t.__useEffect=!(!e&&!o)}t.__checkSingle(),te(t,"__complex",t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect)},__drawFast(t,e){ie(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:r,__drawAfterFill:a,__fillAfterStroke:n,__isFastShadow:_}=s;if(this.__drawRenderPath(t),s.__useEffect&&!_){const _=mt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:d,filter:p}=s;h&&bt.shadow(this,t,_),n&&(s.__isStrokes?mt.strokes(r,this,t):mt.stroke(r,this,t)),o&&(s.__isFills?mt.fills(o,this,t):mt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),d&&bt.innerShadow(this,t,_),r&&!n&&(s.__isStrokes?mt.strokes(r,this,t):mt.stroke(r,this,t)),p&&Bt.apply(p,this,this.__nowWorld,t,i,_),_.worldCanvas&&_.worldCanvas.recycle(),_.canvas.recycle()}else{if(n&&(s.__isStrokes?mt.strokes(r,this,t):mt.stroke(r,this,t)),_){const e=s.shadow[0],{scaleX:i,scaleY:o}=this.__nowWorld;t.save(),t.setWorldShadow(e.x*i,e.y*o,e.blur*i,wt.string(e.color))}o&&(s.__isFills?mt.fills(o,this,t):mt.fill(o,this,t)),_&&t.restore(),a&&this.__drawAfterFill(t,e),r&&!n&&(s.__isStrokes?mt.strokes(r,this,t):mt.stroke(r,this,t))}}else s.__pathInputed?ie(this,t,e):this.__drawFast(t,e)},__drawShape(t,e){this.__drawRenderPath(t);const i=this.__,{fill:s,stroke:o}=i;s&&!e.ignoreFill&&(i.__isAlphaPixelFill?mt.fills(s,this,t):mt.fill("#000000",this,t)),i.__isCanvas&&this.__drawAfterFill(t,e),o&&!e.ignoreStroke&&(i.__isAlphaPixelStroke?mt.strokes(o,this,t):mt.stroke("#000000",this,t))},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),t.clipUI(this),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function ie(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r,__fillAfterStroke:a}=t.__;t.__drawRenderPath(e),a&&mt.stroke(o,t,e),s&&mt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&!a&&mt.stroke(o,t,e)}const se={__drawFast(t,e){let{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;const{fill:a,stroke:n,__drawAfterFill:_}=this.__;if(a&&(t.fillStyle=a,t.fillRect(i,s,o,r)),_&&this.__drawAfterFill(t,e),n){const{strokeAlign:a,__strokeWidth:_}=this.__;if(!_)return;t.setStroke(n,_,this.__);const h=_/2;switch(a){case"center":t.strokeRect(0,0,o,r);break;case"inside":o-=_,r-=_,o<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+h,s+h,o,r),t.restore()):t.strokeRect(i+h,s+h,o,r);break;case"outside":t.strokeRect(i-h,s-h,o+_,r+_)}}}};var oe;let re=oe=class extends E{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get isAutoWidth(){const t=this.__;return t.__autoWidth||t.autoWidth}get isAutoHeight(){const t=this.__;return t.__autoHeight||t.autoHeight}get pen(){const{path:t}=this.__;return z.set(this.path=t||[]),t||this.__drawPathByBox(z),z}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return o.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return o.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(z.set(i=[]),this.__drawPathByBox(z)),t?r.toCanvasData(i,!0):i}getPathString(t,e,i){return r.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||At.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){const t=this.__;t.path?(t.__pathForRender=t.cornerRadius?L.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&St.addArrows(this,!t.cornerRadius)):t.__pathForRender&&(t.__pathForRender=void 0)}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?M.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}drawImagePlaceholder(t,e){mt.fill(this.__.placeholderColor,this,t)}animate(t,e,i,s){return o.need("animate")}killAnimate(t,e){}export(t,e){return o.need("export")}syncExport(t,e){return o.need("export")}clone(t){const e=a.clone(this.toJSON());return t&&Object.assign(e,t),oe.one(e)}static one(t,e,i,s,o){return d.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){O()(this)}static registerData(t){p(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};ut([p(zt)],re.prototype,"__",void 0),ut([gt()],re.prototype,"zoomLayer",void 0),ut([l("")],re.prototype,"id",void 0),ut([l("")],re.prototype,"name",void 0),ut([l("")],re.prototype,"className",void 0),ut([u("pass-through")],re.prototype,"blendMode",void 0),ut([c(1)],re.prototype,"opacity",void 0),ut([y(!0)],re.prototype,"visible",void 0),ut([u(!1)],re.prototype,"locked",void 0),ut([u(!1)],re.prototype,"dim",void 0),ut([u(!1)],re.prototype,"dimskip",void 0),ut([g(0)],re.prototype,"zIndex",void 0),ut([v(!1)],re.prototype,"mask",void 0),ut([f(!1)],re.prototype,"eraser",void 0),ut([w(0,!0)],re.prototype,"x",void 0),ut([w(0,!0)],re.prototype,"y",void 0),ut([x(100,!0)],re.prototype,"width",void 0),ut([x(100,!0)],re.prototype,"height",void 0),ut([S(1,!0)],re.prototype,"scaleX",void 0),ut([S(1,!0)],re.prototype,"scaleY",void 0),ut([m(0,!0)],re.prototype,"rotation",void 0),ut([m(0,!0)],re.prototype,"skewX",void 0),ut([m(0,!0)],re.prototype,"skewY",void 0),ut([w(0,!0)],re.prototype,"offsetX",void 0),ut([w(0,!0)],re.prototype,"offsetY",void 0),ut([w(0,!0)],re.prototype,"scrollX",void 0),ut([w(0,!0)],re.prototype,"scrollY",void 0),ut([R()],re.prototype,"origin",void 0),ut([R()],re.prototype,"around",void 0),ut([l(!1)],re.prototype,"lazy",void 0),ut([k(1)],re.prototype,"pixelRatio",void 0),ut([b(0)],re.prototype,"renderSpread",void 0),ut([B()],re.prototype,"path",void 0),ut([A()],re.prototype,"windingRule",void 0),ut([A(!0)],re.prototype,"closed",void 0),ut([x(0)],re.prototype,"padding",void 0),ut([x(!1)],re.prototype,"lockRatio",void 0),ut([x()],re.prototype,"widthRange",void 0),ut([x()],re.prototype,"heightRange",void 0),ut([l(!1)],re.prototype,"draggable",void 0),ut([l()],re.prototype,"dragBounds",void 0),ut([l(!1)],re.prototype,"editable",void 0),ut([C(!0)],re.prototype,"hittable",void 0),ut([C("path")],re.prototype,"hitFill",void 0),ut([P("path")],re.prototype,"hitStroke",void 0),ut([C(!1)],re.prototype,"hitBox",void 0),ut([C(!0)],re.prototype,"hitChildren",void 0),ut([C(!0)],re.prototype,"hitSelf",void 0),ut([C()],re.prototype,"hitRadius",void 0),ut([F("")],re.prototype,"cursor",void 0),ut([u()],re.prototype,"fill",void 0),ut([P(void 0,!0)],re.prototype,"stroke",void 0),ut([P("inside")],re.prototype,"strokeAlign",void 0),ut([P(1,!0)],re.prototype,"strokeWidth",void 0),ut([P(!1)],re.prototype,"strokeWidthFixed",void 0),ut([P("none")],re.prototype,"strokeCap",void 0),ut([P("miter")],re.prototype,"strokeJoin",void 0),ut([P()],re.prototype,"dashPattern",void 0),ut([P(0)],re.prototype,"dashOffset",void 0),ut([P(10)],re.prototype,"miterLimit",void 0),ut([A(0)],re.prototype,"cornerRadius",void 0),ut([A()],re.prototype,"cornerSmoothing",void 0),ut([ct()],re.prototype,"shadow",void 0),ut([ct()],re.prototype,"innerShadow",void 0),ut([ct()],re.prototype,"blur",void 0),ut([ct()],re.prototype,"backgroundBlur",void 0),ut([ct()],re.prototype,"grayscale",void 0),ut([ct()],re.prototype,"filter",void 0),ut([u()],re.prototype,"placeholderColor",void 0),ut([l(100)],re.prototype,"placeholderDelay",void 0),ut([l({})],re.prototype,"data",void 0),ut([W(E.prototype.reset)],re.prototype,"reset",null),re=oe=ut([I(Zt),I(ee),T()],re);let ae=class extends re{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return this.childlessJSON||(e.children=this.children.map((e=>e.toJSON(t)))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var ne;ut([p(Mt)],ae.prototype,"__",void 0),ut([x(0)],ae.prototype,"width",void 0),ut([x(0)],ae.prototype,"height",void 0),ae=ut([I(N),O()],ae);const _e=n.get("Leafer");let he=ne=class extends ae{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&V.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||j()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),ne.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,a.assign(s,t));const o=this.canvas=H.canvas(s);this.__controllers.push(this.renderer=H.renderer(this,o,s),this.watcher=H.watcher(this,s),this.layouter=H.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=H.selector(this),this.interaction=H.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=H.hitCanvasManager()),this.canvasManager=new U,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),X.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(J.RESTART):this.emitLeafer(J.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(J.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=a.copyAttrs({},t,h);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new q(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=a.copyAttrs({},this.canvas,h);e.resize(t),this.updateLazyBounds(),this.__onResize(new G(t,i))}__onResize(t){this.emitEvent(t),a.copyAttrs(this.__,t,h),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new $(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(h.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&h.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=a.copyAttrs({},this.canvas,h);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(J.BEFORE_READY),this.emitLeafer(J.READY),this.emitLeafer(J.AFTER_READY),X.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(J.VIEW_READY),X.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,a.x+a.width)),i||(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){X.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(J.VIEW_COMPLETED),X.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,s){return o.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new J(t,this))}__listenEvents(){const t=K.start("FirstCreate "+this.innerName);this.once([[J.START,()=>K.end(t)],[Q.START,this.updateLazyBounds,this],[Z.START,this.__onCreated,this],[Z.END,this.__onViewReady,this]]),this.__eventIds.push(this.on_([[tt.DATA,this.__onWatchData,this],[Q.END,this.__onLayoutEnd,this],[Z.NEXT,this.__onNextRender,this]]))}__removeListenEvents(){this.off_(this.__eventIds)}destroy(t){const e=()=>{if(!this.destroyed){ne.list.remove(this);try{this.stop(),this.emitLeafer(J.END),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{et.clearRecycled()}),100)}catch(t){_e.error(t)}}};t?e():setTimeout(e)}};he.list=new Y,ut([p(Nt)],he.prototype,"__",void 0),ut([x()],he.prototype,"pixelRatio",void 0),he=ne=ut([O()],he);let de=class extends re{get __tag(){return"Rect"}constructor(t){super(t)}};ut([p(jt)],de.prototype,"__",void 0),de=ut([I(se),T(),O()],de);const{copy:pe,add:le,includes:ue}=it,ce=de.prototype,ye=ae.prototype,ge={};let ve=class extends ae{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){if(this.children.length&&!this.pathInputed){const t=this.__;if(t.__autoSide){t.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:e}=this.__layout;t.__autoSize||(t.__autoWidth?(e.width+=e.x,e.x=0,e.height=t.height,e.y=0):(e.height+=e.y,e.y=0,e.width=t.width,e.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;if(this.children.length){const e=this.__,{renderBounds:i,boxBounds:s}=this.__layout;super.__updateRenderBounds(),pe(ge,i),this.__updateRectRenderBounds(),(e.scrollY||e.scrollX)&&(ge.x+=e.scrollX,ge.y+=e.scrollY),t=!ue(s,ge),t&&"hide"!==e.overflow&&le(i,ge)}else this.__updateRectRenderBounds();a.stintSet(this,"isOverflow",t),this.__updateScrollBar()}__updateRectRenderBounds(){}__updateScrollBar(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e)),this.scrollBar&&this.scrollBar.__render(t,e)}__drawContent(t,e){this.__renderGroup(t,e),(this.__.__useStroke||this.__.__useEffect)&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};ut([p(Ot)],ve.prototype,"__",void 0),ut([x(100)],ve.prototype,"width",void 0),ut([x(100)],ve.prototype,"height",void 0),ut([l(!1)],ve.prototype,"resizeChildren",void 0),ut([b("show")],ve.prototype,"overflow",void 0),ut([W(ce.__updateStrokeSpread)],ve.prototype,"__updateStrokeSpread",null),ut([W(ce.__updateRenderSpread)],ve.prototype,"__updateRectRenderSpread",null),ut([W(ce.__updateBoxBounds)],ve.prototype,"__updateRectBoxBounds",null),ut([W(ce.__updateStrokeBounds)],ve.prototype,"__updateStrokeBounds",null),ut([W(ce.__updateRenderBounds)],ve.prototype,"__updateRectRenderBounds",null),ut([W(ce.__updateChange)],ve.prototype,"__updateRectChange",null),ut([W(ce.__render)],ve.prototype,"__renderRect",null),ut([W(ye.__render)],ve.prototype,"__renderGroup",null),ve=ut([T(),O()],ve);let fe=class extends ve{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};ut([p(Yt)],fe.prototype,"__",void 0),ut([u("#FFFFFF")],fe.prototype,"fill",void 0),ut([b("hide")],fe.prototype,"overflow",void 0),fe=ut([O()],fe);const{moveTo:we,closePath:xe,ellipse:Se}=st;let me=class extends re{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&Se(n,r,a,r*i,a*i,0,s,o,!1),Se(n,r,a,r,a,0,o,s,!0),i<1&&xe(n)):(i<1&&(Se(n,r,a,r*i,a*i),we(n,t,a)),Se(n,r,a,r,a,0,360,0,!0)),ot.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(we(n,r,a),Se(n,r,a,r,a,0,s,o,!1),xe(n)):Se(n,r,a,r,a)}};ut([p(Ht)],me.prototype,"__",void 0),ut([A(0)],me.prototype,"innerRadius",void 0),ut([A(0)],me.prototype,"startAngle",void 0),ut([A(0)],me.prototype,"endAngle",void 0),me=ut([O()],me);const{moveTo:Re,lineTo:ke,drawPoints:be}=st,{rotate:Be,getAngle:Ae,getDistance:Ce,defaultPoint:Pe}=rt,{toBounds:Fe}=at;let We=class extends re{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=_t();return t&&(i.x=t),e&&Be(i,e),i}set toPoint(t){this.width=Ce(Pe,t),this.rotation=Ae(Pe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?be(e,t.points,!1,t.closed):(Re(e,0,0),ke(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(be(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&St.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?Fe(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};ut([p(Vt)],We.prototype,"__",void 0),ut([nt("center")],We.prototype,"strokeAlign",void 0),ut([x(0)],We.prototype,"height",void 0),ut([A()],We.prototype,"points",void 0),ut([A(0)],We.prototype,"curve",void 0),ut([A(!1)],We.prototype,"closed",void 0),We=ut([O()],We);const{sin:Ee,cos:Ie,PI:Te}=Math,{moveTo:De,lineTo:ze,closePath:Le,drawPoints:Me}=st,Oe=We.prototype;let Ne=class extends re{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Me(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;De(t,o,0);for(let e=1;e<s;e++)ze(t,o+o*Ee(2*e*Te/s),r-r*Ie(2*e*Te/s));Le(t)}}__updateRenderPath(){}__updateBoxBounds(){}};ut([p(Ut)],Ne.prototype,"__",void 0),ut([A(3)],Ne.prototype,"sides",void 0),ut([A()],Ne.prototype,"points",void 0),ut([A(0)],Ne.prototype,"curve",void 0),ut([W(Oe.__updateRenderPath)],Ne.prototype,"__updateRenderPath",null),ut([W(Oe.__updateBoxBounds)],Ne.prototype,"__updateBoxBounds",null),Ne=ut([T(),O()],Ne);const{sin:Ye,cos:Ve,PI:je}=Math,{moveTo:He,lineTo:Ue,closePath:Xe}=st;let Je=class extends re{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=[];He(a,o,0);for(let t=1;t<2*i;t++)Ue(a,o+(t%2==0?o:o*s)*Ye(t*je/i),r-(t%2==0?r:r*s)*Ve(t*je/i));Xe(a)}};ut([p(Xt)],Je.prototype,"__",void 0),ut([A(5)],Je.prototype,"corners",void 0),ut([A(.382)],Je.prototype,"innerRadius",void 0),Je=ut([O()],Je);let qe=class extends de{get __tag(){return"Image"}get ready(){const{image:t}=this;return t&&t.ready}get image(){const{fill:t}=this.__;return t instanceof Array&&t[0].image}constructor(t){super(t)}};ut([p(Kt)],qe.prototype,"__",void 0),ut([x("")],qe.prototype,"url",void 0),qe=ut([O()],qe);const Ge=qe;let $e=class extends de{get __tag(){return"Canvas"}get context(){return this.canvas.context}get ready(){return!this.url}constructor(t){super(t),this.canvas=H.canvas(this.__),t&&t.url&&this.drawImage(t.url)}drawImage(t){new ht({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new dt(dt.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new pt(t.worldTransform).invert(),r=new pt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null),super.destroy()}};ut([p(Qt)],$e.prototype,"__",void 0),ut([yt(100)],$e.prototype,"width",void 0),ut([yt(100)],$e.prototype,"height",void 0),ut([yt(1)],$e.prototype,"pixelRatio",void 0),ut([yt(!0)],$e.prototype,"smooth",void 0),ut([l(!1)],$e.prototype,"safeResize",void 0),ut([yt()],$e.prototype,"contextSettings",void 0),$e=ut([O()],$e);const{copyAndSpread:Ke,includes:Qe,spread:Ze,setList:ti}=it;let ei=class extends re{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}constructor(t){super(t)}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=xt.number(e,o),t.__letterSpacing=xt.number(i,o),t.__padding=h?D.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=ft.getDrawData((t.__isPlacehold=t.placeholder&&""===t.text)?t.placeholder:t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:n}=t;this.__updateTextDrawData();const{bounds:_}=t.__textDrawData,h=e.boxBounds;if(e.contentBounds=_,t.__lineHeight<i&&Ze(_,i/2),r||n){if(h.x=r?_.x:0,h.y=n?_.y:0,h.width=r?_.width:t.width,h.height=n?_.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(h.x-=o,h.width+=i+o),n&&(h.y-=e,h.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(h.width+=.16*i),a.stintSet(this,"isOverflow",!Qe(h,_)),this.isOverflow?(ti(t.__textBoxBounds={},[h,_]),e.renderChanged=!0):t.__textBoxBounds=h}__onUpdateSize(){this.__box&&this.__box.__onUpdateSize(),super.__onUpdateSize()}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;Ke(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!e.exporting||super.__draw(t,e,i)}__drawShape(t,e){e.shape&&this.__box&&this.__box.__drawShape(t,e),super.__drawShape(t,e)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};ut([p($t)],ei.prototype,"__",void 0),ut([x(0)],ei.prototype,"width",void 0),ut([x(0)],ei.prototype,"height",void 0),ut([u()],ei.prototype,"boxStyle",void 0),ut([l(!1)],ei.prototype,"resizeFontSize",void 0),ut([u("#000000")],ei.prototype,"fill",void 0),ut([nt("outside")],ei.prototype,"strokeAlign",void 0),ut([C("all")],ei.prototype,"hitFill",void 0),ut([x("")],ei.prototype,"text",void 0),ut([x("")],ei.prototype,"placeholder",void 0),ut([x("caption")],ei.prototype,"fontFamily",void 0),ut([x(12)],ei.prototype,"fontSize",void 0),ut([x("normal")],ei.prototype,"fontWeight",void 0),ut([x(!1)],ei.prototype,"italic",void 0),ut([x("none")],ei.prototype,"textCase",void 0),ut([x("none")],ei.prototype,"textDecoration",void 0),ut([x(0)],ei.prototype,"letterSpacing",void 0),ut([x({type:"percent",value:1.5})],ei.prototype,"lineHeight",void 0),ut([x(0)],ei.prototype,"paraIndent",void 0),ut([x(0)],ei.prototype,"paraSpacing",void 0),ut([x("x")],ei.prototype,"writingMode",void 0),ut([x("left")],ei.prototype,"textAlign",void 0),ut([x("top")],ei.prototype,"verticalAlign",void 0),ut([x(!0)],ei.prototype,"autoSizeAlign",void 0),ut([x("normal")],ei.prototype,"textWrap",void 0),ut([x("show")],ei.prototype,"textOverflow",void 0),ut([u(!1)],ei.prototype,"textEditing",void 0),ei=ut([O()],ei);let ii=class extends re{get __tag(){return"Path"}constructor(t){super(t)}};ut([p(Jt)],ii.prototype,"__",void 0),ut([nt("center")],ii.prototype,"strokeAlign",void 0),ii=ut([O()],ii);let si=class extends ae{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new ii(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};ut([p(qt)],si.prototype,"__",void 0),ut([(e,i)=>{t(e,i,{get(){return this.__path}})}],si.prototype,"path",void 0),si=ut([I(lt,["set","path","paint"]),O()],si);export{ve as Box,Ot as BoxData,$e as Canvas,Qt as CanvasData,wt as ColorConvert,bt as Effect,me as Ellipse,Ht as EllipseData,At as Export,Bt as Filter,fe as Frame,Yt as FrameData,ae as Group,Mt as GroupData,qe as Image,Kt as ImageData,he as Leafer,Nt as LeaferData,We as Line,Vt as LineData,Ge as MyImage,mt as Paint,kt as PaintGradient,Rt as PaintImage,ii as Path,St as PathArrow,Jt as PathData,si as Pen,qt as PenData,Ne as Polygon,Ut as PolygonData,de as Rect,jt as RectData,se as RectRender,Je as Star,Xt as StarData,Ct as State,ei as Text,ft as TextConvert,$t as TextData,Pt as Transition,re as UI,Zt as UIBounds,zt as UIData,ee as UIRender,xt as UnitConvert,vt as createAttr,ct as effectType,yt as resizeType,gt as zoomLayerType};
2
2
  //# sourceMappingURL=draw.esm.min.js.map