@idraw/util 0.4.0 → 0.4.1

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.
@@ -26,7 +26,7 @@ export { compressImage } from './tool/image';
26
26
  export { formatNumber } from './tool/number';
27
27
  export { matrixToAngle, matrixToRadian } from './view/matrix';
28
28
  export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './view/config';
29
- export { calcViewBoxSize } from './view/view-box';
29
+ export { calcViewBoxSize, calcVisiableViewSize } from './view/view-box';
30
30
  export { mergeElement, createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList, updateElementInListByPosition } from './view/handle-element';
31
31
  export { resizeEffectGroupElement } from './view/resize-element';
32
32
  export { calcViewCenterContent, calcViewCenter } from './view/view-content';
package/dist/esm/index.js CHANGED
@@ -26,7 +26,7 @@ export { compressImage } from './tool/image';
26
26
  export { formatNumber } from './tool/number';
27
27
  export { matrixToAngle, matrixToRadian } from './view/matrix';
28
28
  export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './view/config';
29
- export { calcViewBoxSize } from './view/view-box';
29
+ export { calcViewBoxSize, calcVisiableViewSize } from './view/view-box';
30
30
  export { mergeElement, createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList, updateElementInListByPosition } from './view/handle-element';
31
31
  export { resizeEffectGroupElement } from './view/resize-element';
32
32
  export { calcViewCenterContent, calcViewCenter } from './view/view-content';
@@ -21,8 +21,16 @@ declare function textAlign(value: any): boolean;
21
21
  declare function fontFamily(value: any): boolean;
22
22
  declare function fontWeight(value: any): boolean;
23
23
  declare function numberStr(value: any): boolean;
24
+ declare function type(value: any): boolean;
25
+ declare function element(elem: any): boolean;
26
+ declare function layout(value: any): boolean;
27
+ declare function data(d: any): boolean;
24
28
  export declare const is: {
25
29
  positiveNum: typeof positiveNum;
30
+ data: typeof data;
31
+ element: typeof element;
32
+ layout: typeof layout;
33
+ type: typeof type;
26
34
  x: typeof x;
27
35
  y: typeof y;
28
36
  w: typeof w;
@@ -89,8 +89,33 @@ function fontWeight(value) {
89
89
  function numberStr(value) {
90
90
  return /^(-?\d+(?:\.\d+)?)$/.test(`${value}`);
91
91
  }
92
+ function type(value) {
93
+ return ['rect', 'circle', 'text', 'image', 'svg', 'html', 'group'].includes(value);
94
+ }
95
+ function element(elem) {
96
+ if (!elem) {
97
+ return false;
98
+ }
99
+ return type(elem === null || elem === void 0 ? void 0 : elem.type) && x(elem === null || elem === void 0 ? void 0 : elem.x) && y(elem === null || elem === void 0 ? void 0 : elem.y) && w(elem === null || elem === void 0 ? void 0 : elem.w) && h(elem === null || elem === void 0 ? void 0 : elem.h);
100
+ }
101
+ function layout(value) {
102
+ if (!value) {
103
+ return false;
104
+ }
105
+ return x(value === null || value === void 0 ? void 0 : value.x) && y(value === null || value === void 0 ? void 0 : value.y) && w(value === null || value === void 0 ? void 0 : value.w) && h(value === null || value === void 0 ? void 0 : value.h);
106
+ }
107
+ function data(d) {
108
+ if (Array(d === null || d === void 0 ? void 0 : d.elements) && (d === null || d === void 0 ? void 0 : d.elements.length) >= 0) {
109
+ return true;
110
+ }
111
+ return false;
112
+ }
92
113
  export const is = {
93
114
  positiveNum,
115
+ data,
116
+ element,
117
+ layout,
118
+ type,
94
119
  x,
95
120
  y,
96
121
  w,
@@ -1,5 +1,6 @@
1
- import type { Element, ViewScaleInfo, ViewSizeInfo, ViewBoxSize } from '@idraw/types';
1
+ import type { Data, Element, ElementSize, ViewScaleInfo, ViewSizeInfo, ViewBoxSize } from '@idraw/types';
2
2
  export declare function calcViewBoxSize(viewElem: Element, opts: {
3
3
  viewScaleInfo: ViewScaleInfo;
4
4
  viewSizeInfo: ViewSizeInfo;
5
5
  }): ViewBoxSize;
6
+ export declare function calcVisiableViewSize(data: Data): Omit<ElementSize, 'angle'>;
@@ -1,4 +1,5 @@
1
1
  import { getDefaultElementDetailConfig } from './config';
2
+ import { calcElementListSize } from './element';
2
3
  const defaultElemConfig = getDefaultElementDetailConfig();
3
4
  export function calcViewBoxSize(viewElem, opts) {
4
5
  const { viewScaleInfo } = opts;
@@ -54,3 +55,22 @@ export function calcViewBoxSize(viewElem, opts) {
54
55
  radiusList
55
56
  };
56
57
  }
58
+ export function calcVisiableViewSize(data) {
59
+ var _a, _b;
60
+ const outputSize = calcElementListSize(data.elements);
61
+ if (data.layout) {
62
+ if (((_b = (_a = data.layout) === null || _a === void 0 ? void 0 : _a.detail) === null || _b === void 0 ? void 0 : _b.overflow) === 'hidden') {
63
+ outputSize.x = data.layout.x;
64
+ outputSize.y = data.layout.y;
65
+ outputSize.w = data.layout.w;
66
+ outputSize.h = data.layout.h;
67
+ }
68
+ else {
69
+ outputSize.x = Math.min(outputSize.x, data.layout.x);
70
+ outputSize.y = Math.min(outputSize.y, data.layout.y);
71
+ outputSize.w = Math.max(outputSize.w, data.layout.w);
72
+ outputSize.h = Math.max(outputSize.h, data.layout.h);
73
+ }
74
+ }
75
+ return outputSize;
76
+ }
@@ -2,7 +2,7 @@ import { rotateElementVertexes } from './rotate';
2
2
  import { formatNumber } from '../tool/number';
3
3
  import { is } from './is';
4
4
  export function calcViewCenterContent(data, opts) {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6
6
  let offsetX = 0;
7
7
  let offsetY = 0;
8
8
  let scale = 1;
@@ -11,9 +11,9 @@ export function calcViewCenterContent(data, opts) {
11
11
  let contentW = ((_f = (_e = data === null || data === void 0 ? void 0 : data.elements) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.w) || 0;
12
12
  let contentH = ((_h = (_g = data === null || data === void 0 ? void 0 : data.elements) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.h) || 0;
13
13
  const { width, height } = opts.viewSizeInfo;
14
- if (data.layout && ((_k = (_j = data.layout) === null || _j === void 0 ? void 0 : _j.detail) === null || _k === void 0 ? void 0 : _k.overflow) === 'hidden') {
15
- contentX = 0;
16
- contentY = 0;
14
+ if (is.layout(data.layout) && ((_k = (_j = data.layout) === null || _j === void 0 ? void 0 : _j.detail) === null || _k === void 0 ? void 0 : _k.overflow) === 'hidden') {
15
+ contentX = data.layout.x;
16
+ contentY = data.layout.y;
17
17
  contentW = data.layout.w || 0;
18
18
  contentH = data.layout.h || 0;
19
19
  }
@@ -47,9 +47,15 @@ export function calcViewCenterContent(data, opts) {
47
47
  contentH = Math.abs(areaEndY - areaStartY);
48
48
  });
49
49
  }
50
- if (data.layout) {
50
+ if ((data === null || data === void 0 ? void 0 : data.layout) && is.layout(data.layout)) {
51
51
  const { x, y, w, h } = data.layout;
52
- if (is.x(x) && is.y(y) && is.w(w) && is.h(h)) {
52
+ if (((_m = (_l = data.layout) === null || _l === void 0 ? void 0 : _l.detail) === null || _m === void 0 ? void 0 : _m.overflow) === 'hidden') {
53
+ contentX = Math.min(contentX, x);
54
+ contentY = Math.min(contentY, y);
55
+ contentW = Math.min(contentW, w);
56
+ contentH = Math.min(contentH, h);
57
+ }
58
+ else {
53
59
  contentX = Math.min(contentX, x);
54
60
  contentY = Math.min(contentY, y);
55
61
  contentW = Math.max(contentW, w);
@@ -58,8 +58,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
58
58
  };
59
59
  }
60
60
  function downloadImageFromCanvas(canvas, opts) {
61
- const { fileName, type = "image/jpeg" } = opts;
62
- const stream = canvas.toDataURL(type);
61
+ const { fileName, type: type2 = "image/jpeg" } = opts;
62
+ const stream = canvas.toDataURL(type2);
63
63
  let downloadLink = document.createElement("a");
64
64
  downloadLink.href = stream;
65
65
  downloadLink.download = fileName;
@@ -412,16 +412,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
412
412
  }
413
413
  function deepClone(target) {
414
414
  function _clone(t) {
415
- const type = is$1(t);
416
- if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type) >= 0) {
415
+ const type2 = is$1(t);
416
+ if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type2) >= 0) {
417
417
  return t;
418
- } else if (type === "Array") {
418
+ } else if (type2 === "Array") {
419
419
  const arr = [];
420
420
  t.forEach((item) => {
421
421
  arr.push(_clone(item));
422
422
  });
423
423
  return arr;
424
- } else if (type === "Object") {
424
+ } else if (type2 === "Object") {
425
425
  const obj = {};
426
426
  const keys = Object.keys(t);
427
427
  keys.forEach((key) => {
@@ -436,8 +436,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
436
436
  }
437
437
  return _clone(target);
438
438
  }
439
- function deepCloneElement(element) {
440
- const elem = deepClone(element);
439
+ function deepCloneElement(element2) {
440
+ const elem = deepClone(element2);
441
441
  const _resetUUID = (e) => {
442
442
  e.uuid = createUUID();
443
443
  if (e.type === "group" && e.detail.children) {
@@ -449,8 +449,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
449
449
  _resetUUID(elem);
450
450
  return elem;
451
451
  }
452
- function deepCloneData(data) {
453
- const { elements, ...restData } = data;
452
+ function deepCloneData(data2) {
453
+ const { elements, ...restData } = data2;
454
454
  return {
455
455
  ...deepClone(restData),
456
456
  ...{
@@ -461,11 +461,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
461
461
  function is$1(target) {
462
462
  return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
463
463
  }
464
- function sortDataAsserts(data, opts) {
465
- const assets = data.assets || {};
466
- let sortedData = data;
464
+ function sortDataAsserts(data2, opts) {
465
+ const assets = data2.assets || {};
466
+ let sortedData = data2;
467
467
  if ((opts == null ? void 0 : opts.clone) === true) {
468
- sortedData = deepClone(data);
468
+ sortedData = deepClone(data2);
469
469
  }
470
470
  const _scanElements = (elems) => {
471
471
  elems.forEach((elem) => {
@@ -515,9 +515,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
515
515
  sortedData.assets = assets;
516
516
  return sortedData;
517
517
  }
518
- function filterCompactData(data, opts) {
519
- const assets = data.assets || {};
520
- const sortedData = deepClone(data);
518
+ function filterCompactData(data2, opts) {
519
+ const assets = data2.assets || {};
520
+ const sortedData = deepClone(data2);
521
521
  const loadItemMap = (opts == null ? void 0 : opts.loadItemMap) || {};
522
522
  const _scanElements = (elems) => {
523
523
  elems.forEach((elem) => {
@@ -589,45 +589,45 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
589
589
  sortedData.assets = assets;
590
590
  return sortedData;
591
591
  }
592
- function parsePrototype(data) {
593
- const typeStr = Object.prototype.toString.call(data) || "";
592
+ function parsePrototype(data2) {
593
+ const typeStr = Object.prototype.toString.call(data2) || "";
594
594
  const result = typeStr.replace(/(\[object|\])/gi, "").trim();
595
595
  return result;
596
596
  }
597
597
  const istype = {
598
- type(data, lowerCase) {
599
- const result = parsePrototype(data);
598
+ type(data2, lowerCase) {
599
+ const result = parsePrototype(data2);
600
600
  return lowerCase === true ? result.toLocaleLowerCase() : result;
601
601
  },
602
- array(data) {
603
- return parsePrototype(data) === "Array";
602
+ array(data2) {
603
+ return parsePrototype(data2) === "Array";
604
604
  },
605
- json(data) {
606
- return parsePrototype(data) === "Object";
605
+ json(data2) {
606
+ return parsePrototype(data2) === "Object";
607
607
  },
608
- function(data) {
609
- return parsePrototype(data) === "Function";
608
+ function(data2) {
609
+ return parsePrototype(data2) === "Function";
610
610
  },
611
- asyncFunction(data) {
612
- return parsePrototype(data) === "AsyncFunction";
611
+ asyncFunction(data2) {
612
+ return parsePrototype(data2) === "AsyncFunction";
613
613
  },
614
- boolean(data) {
615
- return parsePrototype(data) === "Boolean";
614
+ boolean(data2) {
615
+ return parsePrototype(data2) === "Boolean";
616
616
  },
617
- string(data) {
618
- return parsePrototype(data) === "String";
617
+ string(data2) {
618
+ return parsePrototype(data2) === "String";
619
619
  },
620
- number(data) {
621
- return parsePrototype(data) === "Number";
620
+ number(data2) {
621
+ return parsePrototype(data2) === "Number";
622
622
  },
623
- undefined(data) {
624
- return parsePrototype(data) === "Undefined";
623
+ undefined(data2) {
624
+ return parsePrototype(data2) === "Undefined";
625
625
  },
626
- null(data) {
627
- return parsePrototype(data) === "Null";
626
+ null(data2) {
627
+ return parsePrototype(data2) === "Null";
628
628
  },
629
- promise(data) {
630
- return parsePrototype(data) === "Promise";
629
+ promise(data2) {
630
+ return parsePrototype(data2) === "Promise";
631
631
  }
632
632
  // nodeList (data: any): boolean {
633
633
  // return parsePrototype(data) === 'NodeList';
@@ -785,8 +785,33 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
785
785
  function numberStr(value) {
786
786
  return /^(-?\d+(?:\.\d+)?)$/.test(`${value}`);
787
787
  }
788
+ function type(value) {
789
+ return ["rect", "circle", "text", "image", "svg", "html", "group"].includes(value);
790
+ }
791
+ function element(elem) {
792
+ if (!elem) {
793
+ return false;
794
+ }
795
+ return type(elem == null ? void 0 : elem.type) && x(elem == null ? void 0 : elem.x) && y(elem == null ? void 0 : elem.y) && w(elem == null ? void 0 : elem.w) && h(elem == null ? void 0 : elem.h);
796
+ }
797
+ function layout(value) {
798
+ if (!value) {
799
+ return false;
800
+ }
801
+ return x(value == null ? void 0 : value.x) && y(value == null ? void 0 : value.y) && w(value == null ? void 0 : value.w) && h(value == null ? void 0 : value.h);
802
+ }
803
+ function data(d) {
804
+ if (Array(d == null ? void 0 : d.elements) && (d == null ? void 0 : d.elements.length) >= 0) {
805
+ return true;
806
+ }
807
+ return false;
808
+ }
788
809
  const is = {
789
810
  positiveNum,
811
+ data,
812
+ element,
813
+ layout,
814
+ type,
790
815
  x,
791
816
  y,
792
817
  w,
@@ -1681,18 +1706,18 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1681
1706
  }
1682
1707
  return uuids;
1683
1708
  }
1684
- function getSelectedElementUUIDs(data, indexes) {
1709
+ function getSelectedElementUUIDs(data2, indexes) {
1685
1710
  var _a;
1686
1711
  let uuids = [];
1687
- if (Array.isArray(data == null ? void 0 : data.elements) && ((_a = data == null ? void 0 : data.elements) == null ? void 0 : _a.length) > 0 && Array.isArray(indexes) && indexes.length > 0) {
1712
+ if (Array.isArray(data2 == null ? void 0 : data2.elements) && ((_a = data2 == null ? void 0 : data2.elements) == null ? void 0 : _a.length) > 0 && Array.isArray(indexes) && indexes.length > 0) {
1688
1713
  indexes.forEach((idx) => {
1689
1714
  var _a2;
1690
1715
  if (typeof idx === "number") {
1691
- if ((_a2 = data == null ? void 0 : data.elements) == null ? void 0 : _a2[idx]) {
1692
- uuids.push(data.elements[idx].uuid);
1716
+ if ((_a2 = data2 == null ? void 0 : data2.elements) == null ? void 0 : _a2[idx]) {
1717
+ uuids.push(data2.elements[idx].uuid);
1693
1718
  }
1694
1719
  } else if (typeof idx === "string") {
1695
- uuids = uuids.concat(getGroupUUIDs(data.elements, idx));
1720
+ uuids = uuids.concat(getGroupUUIDs(data2.elements, idx));
1696
1721
  }
1697
1722
  });
1698
1723
  }
@@ -1936,8 +1961,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1936
1961
  const size = { x: x2, y: y2, w: w2, h: h2, angle: angle2 };
1937
1962
  return size;
1938
1963
  }
1939
- function mergeElementAsset(element, assets) {
1940
- const elem = element;
1964
+ function mergeElementAsset(element2, assets) {
1965
+ const elem = element2;
1941
1966
  let assetId = null;
1942
1967
  let assetItem = null;
1943
1968
  if (elem.type === "image") {
@@ -1961,33 +1986,33 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1961
1986
  }
1962
1987
  return elem;
1963
1988
  }
1964
- function filterElementAsset(element) {
1989
+ function filterElementAsset(element2) {
1965
1990
  let assetId = null;
1966
1991
  let assetItem = null;
1967
1992
  let resource = null;
1968
- if (element.type === "image") {
1969
- resource = element.detail.src;
1970
- } else if (element.type === "svg") {
1971
- resource = element.detail.svg;
1972
- } else if (element.type === "html") {
1973
- resource = element.detail.html;
1993
+ if (element2.type === "image") {
1994
+ resource = element2.detail.src;
1995
+ } else if (element2.type === "svg") {
1996
+ resource = element2.detail.svg;
1997
+ } else if (element2.type === "html") {
1998
+ resource = element2.detail.html;
1974
1999
  }
1975
2000
  if (typeof resource === "string" && !isAssetId(resource)) {
1976
- assetId = createAssetId(resource, element.uuid);
2001
+ assetId = createAssetId(resource, element2.uuid);
1977
2002
  assetItem = {
1978
- type: element.type,
2003
+ type: element2.type,
1979
2004
  value: resource
1980
2005
  };
1981
- if (element.type === "image") {
1982
- element.detail.src = assetId;
1983
- } else if (element.type === "svg") {
1984
- element.detail.svg = assetId;
1985
- } else if (element.type === "html") {
1986
- element.detail.html = assetId;
2006
+ if (element2.type === "image") {
2007
+ element2.detail.src = assetId;
2008
+ } else if (element2.type === "svg") {
2009
+ element2.detail.svg = assetId;
2010
+ } else if (element2.type === "html") {
2011
+ element2.detail.html = assetId;
1987
2012
  }
1988
2013
  }
1989
2014
  return {
1990
- element,
2015
+ element: element2,
1991
2016
  assetId,
1992
2017
  assetItem
1993
2018
  };
@@ -2305,7 +2330,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2305
2330
  }
2306
2331
  function getViewPointAtElement(p, opts) {
2307
2332
  var _a, _b, _c;
2308
- const { context2d: ctx, data, viewScaleInfo, viewSizeInfo, groupQueue } = opts;
2333
+ const { context2d: ctx, data: data2, viewScaleInfo, viewSizeInfo, groupQueue } = opts;
2309
2334
  const result = {
2310
2335
  index: -1,
2311
2336
  element: null,
@@ -2356,8 +2381,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2356
2381
  if (result.element) {
2357
2382
  return result;
2358
2383
  }
2359
- for (let i = data.elements.length - 1; i >= 0; i--) {
2360
- const elem = data.elements[i];
2384
+ for (let i = data2.elements.length - 1; i >= 0; i--) {
2385
+ const elem = data2.elements[i];
2361
2386
  if (((_c = elem == null ? void 0 : elem.operations) == null ? void 0 : _c.invisible) === true) {
2362
2387
  continue;
2363
2388
  }
@@ -2872,7 +2897,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2872
2897
  const elemRegExp = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;
2873
2898
  const whitespaceReg = /^\s*$/;
2874
2899
  const singleElements = {};
2875
- function parseElement(element) {
2900
+ function parseElement(element2) {
2876
2901
  const node = {
2877
2902
  type: "element",
2878
2903
  name: "",
@@ -2880,28 +2905,28 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2880
2905
  attributes: {},
2881
2906
  children: []
2882
2907
  };
2883
- const elementMatch = element.match(/<\/?([^\s]+?)[/\s>]/);
2908
+ const elementMatch = element2.match(/<\/?([^\s]+?)[/\s>]/);
2884
2909
  if (elementMatch) {
2885
2910
  node.name = elementMatch[1];
2886
- if (singleElements[elementMatch[1]] || element.charAt(element.length - 2) === "/") {
2911
+ if (singleElements[elementMatch[1]] || element2.charAt(element2.length - 2) === "/") {
2887
2912
  node.isVoid = true;
2888
2913
  }
2889
2914
  if (node.name.startsWith("!--")) {
2890
- const endIndex = element.indexOf("-->");
2915
+ const endIndex = element2.indexOf("-->");
2891
2916
  return {
2892
2917
  type: "comment",
2893
2918
  name: null,
2894
2919
  attributes: {},
2895
2920
  children: [],
2896
2921
  isVoid: false,
2897
- comment: endIndex !== -1 ? element.slice(4, endIndex) : ""
2922
+ comment: endIndex !== -1 ? element2.slice(4, endIndex) : ""
2898
2923
  };
2899
2924
  }
2900
2925
  }
2901
2926
  const reg = new RegExp(attrRegExp);
2902
2927
  let result = null;
2903
2928
  while (true) {
2904
- result = reg.exec(element);
2929
+ result = reg.exec(element2);
2905
2930
  if (result === null) {
2906
2931
  break;
2907
2932
  }
@@ -2927,25 +2952,25 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2927
2952
  const arr = [];
2928
2953
  let current;
2929
2954
  let level = -1;
2930
- html2.replace(elemRegExp, (element, index) => {
2931
- const isOpen = element.charAt(1) !== "/";
2932
- const isComment = element.startsWith("<!--");
2933
- const start = index + element.length;
2955
+ html2.replace(elemRegExp, (element2, index) => {
2956
+ const isOpen = element2.charAt(1) !== "/";
2957
+ const isComment = element2.startsWith("<!--");
2958
+ const start = index + element2.length;
2934
2959
  const nextChar = html2.charAt(start);
2935
2960
  let parent;
2936
2961
  if (isComment) {
2937
- const comment = parseElement(element);
2962
+ const comment = parseElement(element2);
2938
2963
  if (level < 0) {
2939
2964
  result.push(comment);
2940
- return element;
2965
+ return element2;
2941
2966
  }
2942
2967
  parent = arr[level];
2943
2968
  parent.children.push(comment);
2944
- return element;
2969
+ return element2;
2945
2970
  }
2946
2971
  if (isOpen) {
2947
2972
  level++;
2948
- current = parseElement(element);
2973
+ current = parseElement(element2);
2949
2974
  if (!current.isVoid && true && nextChar && nextChar !== "<") {
2950
2975
  const content = html2.slice(start, html2.indexOf("<", start));
2951
2976
  if (content.trim()) {
@@ -2969,7 +2994,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2969
2994
  arr[level] = current;
2970
2995
  }
2971
2996
  if (!isOpen || !Array.isArray(current) && current.isVoid) {
2972
- if (level > -1 && !Array.isArray(current) && (current.isVoid || current.name === element.slice(2, -1))) {
2997
+ if (level > -1 && !Array.isArray(current) && (current.isVoid || current.name === element2.slice(2, -1))) {
2973
2998
  level--;
2974
2999
  current = level === -1 ? result : arr[level];
2975
3000
  }
@@ -2994,7 +3019,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
2994
3019
  }
2995
3020
  }
2996
3021
  }
2997
- return element;
3022
+ return element2;
2998
3023
  });
2999
3024
  return result;
3000
3025
  }
@@ -3030,7 +3055,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3030
3055
  }
3031
3056
  function compressImage(src, opts) {
3032
3057
  let radio = 0.5;
3033
- const type = (opts == null ? void 0 : opts.type) || "image/png";
3058
+ const type2 = (opts == null ? void 0 : opts.type) || "image/png";
3034
3059
  if ((opts == null ? void 0 : opts.radio) && (opts == null ? void 0 : opts.radio) > 0 && (opts == null ? void 0 : opts.radio) <= 1) {
3035
3060
  radio = opts == null ? void 0 : opts.radio;
3036
3061
  }
@@ -3045,7 +3070,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3045
3070
  canvas.height = resultH;
3046
3071
  const ctx = canvas.getContext("2d");
3047
3072
  ctx.drawImage(image, 0, 0, resultW, resultH);
3048
- const base64 = canvas.toDataURL(type);
3073
+ const base64 = canvas.toDataURL(type2);
3049
3074
  canvas = null;
3050
3075
  resolve(base64);
3051
3076
  });
@@ -3202,6 +3227,24 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3202
3227
  radiusList
3203
3228
  };
3204
3229
  }
3230
+ function calcVisiableViewSize(data2) {
3231
+ var _a, _b;
3232
+ const outputSize = calcElementListSize(data2.elements);
3233
+ if (data2.layout) {
3234
+ if (((_b = (_a = data2.layout) == null ? void 0 : _a.detail) == null ? void 0 : _b.overflow) === "hidden") {
3235
+ outputSize.x = data2.layout.x;
3236
+ outputSize.y = data2.layout.y;
3237
+ outputSize.w = data2.layout.w;
3238
+ outputSize.h = data2.layout.h;
3239
+ } else {
3240
+ outputSize.x = Math.min(outputSize.x, data2.layout.x);
3241
+ outputSize.y = Math.min(outputSize.y, data2.layout.y);
3242
+ outputSize.w = Math.max(outputSize.w, data2.layout.w);
3243
+ outputSize.h = Math.max(outputSize.h, data2.layout.h);
3244
+ }
3245
+ }
3246
+ return outputSize;
3247
+ }
3205
3248
  function flattenObject(obj, parentKey = "", result = {}, opts) {
3206
3249
  Object.keys(obj).forEach((key) => {
3207
3250
  var _a;
@@ -3232,8 +3275,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3232
3275
  function toFlattenElement(elem) {
3233
3276
  return flatObject(elem, { ignorePaths: ["detail.children"] });
3234
3277
  }
3235
- function toFlattenLayout(layout) {
3236
- return flatObject(layout);
3278
+ function toFlattenLayout(layout2) {
3279
+ return flatObject(layout2);
3237
3280
  }
3238
3281
  function toFlattenGlobal(global) {
3239
3282
  return flatObject(global);
@@ -3425,14 +3468,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3425
3468
  return record;
3426
3469
  }
3427
3470
  function deepResizeElementByRatio(elem, opts, record) {
3428
- const { type, uuid } = elem;
3471
+ const { type: type2, uuid } = elem;
3429
3472
  const rootRecord = resizeElementBaseByRatio(elem, opts);
3430
3473
  const rootRecordBefore = { ...rootRecord.content.before, uuid };
3431
3474
  const rootRecordAfter = { ...rootRecord.content.after, uuid };
3432
3475
  record == null ? void 0 : record.content.before.push(rootRecordBefore);
3433
3476
  record == null ? void 0 : record.content.after.push(rootRecordAfter);
3434
- if (type === "circle") ;
3435
- else if (type === "text") {
3477
+ if (type2 === "circle") ;
3478
+ else if (type2 === "text") {
3436
3479
  const textRecord = resizeTextElementDetailByRatio(elem, opts);
3437
3480
  Object.keys(textRecord.content.before || {}).forEach((key) => {
3438
3481
  var _a;
@@ -3442,11 +3485,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3442
3485
  var _a;
3443
3486
  rootRecordAfter[key] = (_a = textRecord.content.after) == null ? void 0 : _a[key];
3444
3487
  });
3445
- } else if (type === "image") ;
3446
- else if (type === "svg") ;
3447
- else if (type === "html") ;
3448
- else if (type === "path") ;
3449
- else if (type === "group" && Array.isArray(elem.detail.children)) {
3488
+ } else if (type2 === "image") ;
3489
+ else if (type2 === "svg") ;
3490
+ else if (type2 === "html") ;
3491
+ else if (type2 === "path") ;
3492
+ else if (type2 === "group" && Array.isArray(elem.detail.children)) {
3450
3493
  elem.detail.children.forEach((child) => {
3451
3494
  deepResizeElementByRatio(child, opts, record);
3452
3495
  });
@@ -3554,7 +3597,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3554
3597
  }
3555
3598
  const defaultViewWidth = 200;
3556
3599
  const defaultViewHeight = 200;
3557
- function createElementSize(type, opts) {
3600
+ function createElementSize(type2, opts) {
3558
3601
  let x2 = 0;
3559
3602
  let y2 = 0;
3560
3603
  let w2 = defaultViewWidth;
@@ -3575,9 +3618,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3575
3618
  } else {
3576
3619
  h2 = defaultViewHeight / scale;
3577
3620
  }
3578
- if (["circle", "svg", "image"].includes(type)) {
3621
+ if (["circle", "svg", "image"].includes(type2)) {
3579
3622
  w2 = h2 = Math.max(w2, h2);
3580
- } else if (type === "text") {
3623
+ } else if (type2 === "text") {
3581
3624
  const fontSize2 = w2 / defaultText.length;
3582
3625
  h2 = fontSize2 * 2;
3583
3626
  }
@@ -3592,27 +3635,27 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3592
3635
  };
3593
3636
  return elemSize;
3594
3637
  }
3595
- function createElement(type, baseElem, opts) {
3596
- const elementSize = createElementSize(type, opts);
3638
+ function createElement(type2, baseElem, opts) {
3639
+ const elementSize = createElementSize(type2, opts);
3597
3640
  let detail = {};
3598
- if (type === "rect") {
3641
+ if (type2 === "rect") {
3599
3642
  detail = getDefaultElementRectDetail();
3600
- } else if (type === "circle") {
3643
+ } else if (type2 === "circle") {
3601
3644
  detail = getDefaultElementCircleDetail();
3602
- } else if (type === "text") {
3645
+ } else if (type2 === "text") {
3603
3646
  detail = getDefaultElementTextDetail(elementSize);
3604
- } else if (type === "svg") {
3647
+ } else if (type2 === "svg") {
3605
3648
  detail = getDefaultElementSVGDetail();
3606
- } else if (type === "image") {
3649
+ } else if (type2 === "image") {
3607
3650
  detail = getDefaultElementImageDetail();
3608
- } else if (type === "group") {
3651
+ } else if (type2 === "group") {
3609
3652
  detail = getDefaultElementGroupDetail();
3610
3653
  }
3611
3654
  const elem = {
3612
3655
  uuid: createUUID(),
3613
3656
  ...elementSize,
3614
3657
  ...baseElem,
3615
- type,
3658
+ type: type2,
3616
3659
  detail: {
3617
3660
  ...detail,
3618
3661
  ...baseElem.detail || {}
@@ -3620,11 +3663,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3620
3663
  };
3621
3664
  return elem;
3622
3665
  }
3623
- function insertElementToListByPosition(element, position, list) {
3666
+ function insertElementToListByPosition(element2, position, list) {
3624
3667
  let result = false;
3625
3668
  if (position.length === 1) {
3626
3669
  const pos = position[0];
3627
- list.splice(pos, 0, element);
3670
+ list.splice(pos, 0, element2);
3628
3671
  result = true;
3629
3672
  } else if (position.length > 1) {
3630
3673
  let tempList = list;
@@ -3633,7 +3676,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3633
3676
  const item = tempList[pos];
3634
3677
  if (i === position.length - 1) {
3635
3678
  const pos2 = position[i];
3636
- tempList.splice(pos2, 0, element);
3679
+ tempList.splice(pos2, 0, element2);
3637
3680
  result = true;
3638
3681
  } else if (i < position.length - 1 && item.type === "group") {
3639
3682
  tempList = item.detail.children;
@@ -3827,23 +3870,23 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3827
3870
  }
3828
3871
  return elem;
3829
3872
  }
3830
- function calcViewCenterContent(data, opts) {
3831
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3873
+ function calcViewCenterContent(data2, opts) {
3874
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
3832
3875
  let offsetX = 0;
3833
3876
  let offsetY = 0;
3834
3877
  let scale = 1;
3835
- let contentX = ((_b = (_a = data == null ? void 0 : data.elements) == null ? void 0 : _a[0]) == null ? void 0 : _b.x) || 0;
3836
- let contentY = ((_d = (_c = data == null ? void 0 : data.elements) == null ? void 0 : _c[0]) == null ? void 0 : _d.y) || 0;
3837
- let contentW = ((_f = (_e = data == null ? void 0 : data.elements) == null ? void 0 : _e[0]) == null ? void 0 : _f.w) || 0;
3838
- let contentH = ((_h = (_g = data == null ? void 0 : data.elements) == null ? void 0 : _g[0]) == null ? void 0 : _h.h) || 0;
3878
+ let contentX = ((_b = (_a = data2 == null ? void 0 : data2.elements) == null ? void 0 : _a[0]) == null ? void 0 : _b.x) || 0;
3879
+ let contentY = ((_d = (_c = data2 == null ? void 0 : data2.elements) == null ? void 0 : _c[0]) == null ? void 0 : _d.y) || 0;
3880
+ let contentW = ((_f = (_e = data2 == null ? void 0 : data2.elements) == null ? void 0 : _e[0]) == null ? void 0 : _f.w) || 0;
3881
+ let contentH = ((_h = (_g = data2 == null ? void 0 : data2.elements) == null ? void 0 : _g[0]) == null ? void 0 : _h.h) || 0;
3839
3882
  const { width, height } = opts.viewSizeInfo;
3840
- if (data.layout && ((_j = (_i = data.layout) == null ? void 0 : _i.detail) == null ? void 0 : _j.overflow) === "hidden") {
3841
- contentX = 0;
3842
- contentY = 0;
3843
- contentW = data.layout.w || 0;
3844
- contentH = data.layout.h || 0;
3883
+ if (is.layout(data2.layout) && ((_j = (_i = data2.layout) == null ? void 0 : _i.detail) == null ? void 0 : _j.overflow) === "hidden") {
3884
+ contentX = data2.layout.x;
3885
+ contentY = data2.layout.y;
3886
+ contentW = data2.layout.w || 0;
3887
+ contentH = data2.layout.h || 0;
3845
3888
  } else {
3846
- data.elements.forEach((elem) => {
3889
+ data2.elements.forEach((elem) => {
3847
3890
  const elemSize = {
3848
3891
  x: elem.x,
3849
3892
  y: elem.y,
@@ -3872,9 +3915,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
3872
3915
  contentH = Math.abs(areaEndY - areaStartY);
3873
3916
  });
3874
3917
  }
3875
- if (data.layout) {
3876
- const { x: x2, y: y2, w: w2, h: h2 } = data.layout;
3877
- if (is.x(x2) && is.y(y2) && is.w(w2) && is.h(h2)) {
3918
+ if ((data2 == null ? void 0 : data2.layout) && is.layout(data2.layout)) {
3919
+ const { x: x2, y: y2, w: w2, h: h2 } = data2.layout;
3920
+ if (((_l = (_k = data2.layout) == null ? void 0 : _k.detail) == null ? void 0 : _l.overflow) === "hidden") {
3921
+ contentX = Math.min(contentX, x2);
3922
+ contentY = Math.min(contentY, y2);
3923
+ contentW = Math.min(contentW, w2);
3924
+ contentH = Math.min(contentH, h2);
3925
+ } else {
3878
3926
  contentX = Math.min(contentX, x2);
3879
3927
  contentY = Math.min(contentY, y2);
3880
3928
  contentW = Math.max(contentW, w2);
@@ -4575,6 +4623,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
4575
4623
  exports.calcViewPointSize = calcViewPointSize;
4576
4624
  exports.calcViewScaleInfo = calcViewScaleInfo;
4577
4625
  exports.calcViewVertexes = calcViewVertexes;
4626
+ exports.calcVisiableViewSize = calcVisiableViewSize;
4578
4627
  exports.check = check;
4579
4628
  exports.checkRectIntersect = checkRectIntersect;
4580
4629
  exports.colorNameToHex = colorNameToHex;
@@ -1 +1 @@
1
- var iDrawUtil=function(t){"use strict";var e,n,i,o,r,l,a,s,c=t=>{throw TypeError(t)},u=(t,e,n)=>e.has(t)||c("Cannot "+n),f=(t,e,n)=>(u(t,e,"read from private field"),n?n.call(t):e.get(t)),h=(t,e,n)=>e.has(t)?c("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),d=(t,e,n,i)=>(u(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),y=(t,e,n)=>(u(t,e,"access private method"),n);function g(t){return"string"==typeof t&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const x={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function p(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function m(t,e){let n=0;for(let e=0;e<t.length;e++)n+=t.charCodeAt(e);return(n+e).toString(16).substring(0,4)}function b(t,e){const n=t.length,i=function(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n);return e}(e),o=Math.floor(n/2),r=t.substring(0,4).padStart(4,"0"),l=t.substring(0,4).padStart(4,"0");return`@assets/${m(n.toString(16).padStart(4,r),i).padStart(4,"0")}${m(t.substring(o-4,o).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-8,o-4).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-12,o-8).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-16,o-12).padStart(4,l),i).padStart(4,"0")}-${m(t.substring(o,o+4).padStart(4,l),i).padStart(4,"0")}${m(t.substring(o+4,o+8).padStart(4,l),i).padStart(4,"0")}${m(l.padStart(4,r).padStart(4,l),i)}`}function v(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function w(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach((e=>{n.push(t(e))})),n}if("Object"===n){const n={};Object.keys(e).forEach((i=>{n[i]=t(e[i])}));return Object.getOwnPropertySymbols(e).forEach((i=>{n[i]=t(e[i])})),n}}(t)}function M(t){const e=w(t),n=t=>{t.uuid=p(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e}function P(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(t,e){const n=P(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===P(t),json:t=>"Object"===P(t),function:t=>"Function"===P(t),asyncFunction:t=>"AsyncFunction"===P(t),boolean:t=>"Boolean"===P(t),string:t=>"String"===P(t),number:t=>"Number"===P(t),undefined:t=>"Undefined"===P(t),null:t=>"Null"===P(t),promise:t=>"Promise"===P(t)};const{Image:I}=window;function S(t){return new Promise(((e,n)=>{const i=new I;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function $(t){return"number"==typeof t&&t>=0}function E(t){return"number"==typeof t&&(t>0||t<=0)}function A(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function z(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const k={positiveNum:$,x:function(t){return E(t)},y:function(t){return E(t)},w:function(t){return $(t)},h:function(t){return $(t)},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:E,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},borderRadius:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},color:function(t){return g(t)},imageSrc:function(t){return z(t)||A(t)},imageURL:A,imageBase64:z,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return E(t)&&t>0},lineHeight:function(t){return E(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)},strokeWidth:function(t){return E(t)&&t>0}};function O(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!k.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderRadius")&&!k.number(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!k.number(i)))}const L={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(k.x(e)&&k.y(n)&&k.w(i)&&k.h(o)&&k.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:l,fontWeight:a,background:s,strokeWidth:c,strokeColor:u}=t;return!!k.text(e)&&(!!k.color(n)&&(!!k.fontSize(i)&&(!(Object.prototype.hasOwnProperty.call(t,"background")&&!k.color(s))&&(!(Object.prototype.hasOwnProperty.call(t,"fontWeight")&&!k.fontWeight(a))&&(!(Object.prototype.hasOwnProperty.call(t,"lineHeight")&&!k.lineHeight(o))&&(!(Object.prototype.hasOwnProperty.call(t,"fontFamily")&&!k.fontFamily(r))&&(!(Object.prototype.hasOwnProperty.call(t,"textAlign")&&!k.textAlign(l))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!k.strokeWidth(c))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeColor")&&!k.color(u))&&!!O(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!k.color(e))&&!!O(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!k.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!k.color(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!k.number(i)))},imageDesc:function(t){const{src:e}=t;return!!k.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!k.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!k.html(e)}};class C{constructor(t,i){h(this,e),h(this,n),d(this,e,t),d(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/f(this,n).devicePixelRatio}$doPixelRatio(t){return f(this,n).devicePixelRatio*t}$getContext(){return f(this,e)}$setContext(t){d(this,e,t)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),f(this,e).font=`${n.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return f(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:l}=t,{canvas:a}=f(this,e);a.width=i*r,a.height=o*r,d(this,n,{...f(this,n),devicePixelRatio:r}),!0===l&&(a.style.width=`${i}px`,a.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=f(this,n),{width:i,height:o}=f(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return f(this,e).canvas}get fillStyle(){return f(this,e).fillStyle}set fillStyle(t){f(this,e).fillStyle=t}get strokeStyle(){return f(this,e).strokeStyle}set strokeStyle(t){f(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(f(this,e).lineWidth)}set lineWidth(t){f(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return f(this,e).textAlign}set textAlign(t){f(this,e).textAlign=t}get textBaseline(){return f(this,e).textBaseline}set textBaseline(t){f(this,e).textBaseline=t}get globalAlpha(){return f(this,e).globalAlpha}set globalAlpha(t){f(this,e).globalAlpha=t}get shadowColor(){return f(this,e).shadowColor}set shadowColor(t){f(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(f(this,e).shadowOffsetX)}set shadowOffsetX(t){f(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(f(this,e).shadowOffsetY)}set shadowOffsetY(t){f(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(f(this,e).shadowBlur)}set shadowBlur(t){f(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return f(this,e).lineCap}set lineCap(t){f(this,e).lineCap=t}get globalCompositeOperation(){return f(this,e).globalCompositeOperation}set globalCompositeOperation(t){f(this,e).globalCompositeOperation=t}fill(...t){return f(this,e).fill(...t)}arc(t,n,i,o,r,l){return f(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,l)}rect(t,n,i,o){return f(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return f(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return f(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return f(this,e).beginPath()}closePath(){return f(this,e).closePath()}lineTo(t,n){return f(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return f(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return f(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}bezierCurveTo(t,n,i,o,r,l){return f(this,e).bezierCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}quadraticCurveTo(t,n,i,o){return f(this,e).quadraticCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return f(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return f(this,e).setLineDash(n)}stroke(t){return t?f(this,e).stroke(t):f(this,e).stroke()}translate(t,n){return f(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return f(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],l=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],u=t[t.length-1];return 9===t.length?f(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u)):f(this,e).drawImage(n,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u))}createPattern(t,n){return f(this,e).createPattern(t,n)}measureText(t){return f(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?f(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):f(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?f(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):f(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){f(this,e).save()}restore(){f(this,e).restore()}scale(t,n){f(this,e).scale(t,n)}circle(t,n,i,o,r,l,a,s){f(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,l,a,s)}isPointInPath(t,n){return f(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return f(this,e).clip(...t)}setTransform(t,n,i,o,r,l){return f(this,e).setTransform(t,n,i,o,r,l)}getTransform(){return f(this,e).getTransform()}createLinearGradient(t,n,i,o){return f(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,l){return f(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}createConicGradient(t,n,i){return f(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function j(t){const{width:e,height:n,ctx:i,devicePixelRatio:o}=t;let r=i;if(!r){const t=document.createElement("canvas");t.width=e*o,t.height=n*o,r=t.getContext("2d")}return new C(r,t)}function T(t){const{width:e,height:n,devicePixelRatio:i}=t,o=new OffscreenCanvas(e*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new C(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function D(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function W(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function N(t){return t>=0||t<0}function F(t){return N(t.x)&&N(t.y)&&t.t>0}function B(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function V(t){return t/180*Math.PI}function H(t,e,n,i){const o=V(e||0);n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(o),t.translate(-n.x,-n.y)),i(t),n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(-o),t.translate(-n.x,-n.y))}function G(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Q(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return G({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function Y(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}function U(t,e,n){let i=Y(t,e)+n;i>2*Math.PI?i-=2*Math.PI:i<0-2*Math.PI&&(i+=2*Math.PI),i<0&&(i+=2*Math.PI);const o=D(t,e);let r=0,l=0;return 0===i?(r=0,l=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,l=0-Math.cos(i)*o):i===Math.PI/2?(r=o,l=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,l=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,l=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,l=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,l=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,l=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,l=0-o),r+=t.x,l+=t.y,{x:r,y:l}}function X(t,e){if((null==e?void 0:e.length)>0){let n=t.x,i=t.y;return e.forEach((t=>{const{x:e,y:o,w:r,h:l,angle:a=0}=t,s=U(G({x:e,y:o,w:r,h:l}),{x:n,y:i},V(a));n=s.x,i=s.y})),{x:n,y:i}}return t}function q(t,e,n){const{x:i,y:o,w:r,h:l}=t;let a={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+l},u={x:i,y:o+l};if(n&&(n>0||n<0)){const t=V(K(n));a=U(e,a,t),s=U(e,s,t),c=U(e,c,t),u=U(e,u,t)}return[a,s,c,u]}function Z(t){const{angle:e=0}=t;return q(t,G(t),e)}function J(t,e,n){return[U(t,{x:e[0].x,y:e[0].y},n),U(t,{x:e[1].x,y:e[1].y},n),U(t,{x:e[2].x,y:e[2].y},n),U(t,{x:e[3].x,y:e[3].y},n)]}function K(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function _(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const l={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(l.angle&&(l.angle>0||l.angle<0)){const t=Z(l);if(4===t.length){const e=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];l.x=Math.min(...e),l.y=Math.min(...n),l.w=Math.abs(Math.max(...e)-Math.min(...e)),l.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(l.x,n.x),e=Math.min(l.y,n.y),i=Math.max(l.x+l.w,n.x+n.w),o=Math.max(l.y+l.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=l.x,n.y=l.y,n.w=l.w,n.h=l.h;i=l}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}}function tt(t,e){const n={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=Z(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),l=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(l-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function et(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e<t.length-1&&"group"===(null==o?void 0:o.type))i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}function nt(t,e){const n=[];let i=!1;const o=e=>{var r;for(let l=0;l<e.length&&!0!==i;l++){n.push(l);const a=e[l];if(a.uuid===t){i=!0;break}if("group"===a.type&&o((null==(r=null==a?void 0:a.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function it(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,l=e.x,a=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=l&&i<=c&&r>=a}function ot(t){const{x:e,y:n,h:i,w:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e+o,y:n+i},{x:e,y:n+i}]}function rt(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?ot(t):q(t,G({x:e,y:n,w:i,h:o}),r)}function lt(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:l,y:a,w:s,h:c,angle:u=0}=r[t];let f;if(n+=l,i+=a,0===t){const t={x:n,y:i,w:s,h:c};f=rt({x:l,y:a,w:s,h:c,angle:u}),o.push({center:G(t),angle:u,radian:V(u)})}else{f=ot({x:n,y:i,w:s,h:c});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];f=J(e,f,n)}const t=Q(f);if(u>0||u<0){f=J(t,f,V(u))}o.push({center:t,angle:u,radian:V(u)})}e.push(f)}return e}function at(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[rt(t)];return lt([...n,t])}function st(t,e){return at(t,e).pop()||null}function ct(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:l,angle:a}=t,{scale:s,offsetTop:c,offsetLeft:u}=n;return{x:i*s+u,y:o*s+c,w:r*s,h:l*s,angle:a}}function ut(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:l,offsetLeft:a}=n;return{x:i*r+a,y:o*r+l}}function ft(t,e){const{context2d:n,element:i,viewScaleInfo:o}=e,{angle:r=0}=i,{x:l,y:a,w:s,h:c}=ct(i,{viewScaleInfo:o}),u=Z({x:l,y:a,w:s,h:c,angle:r});if(u.length>=2){n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let t=1;t<u.length;t++)n.lineTo(u[t].x,u[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function ht(t,e,n){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y],r=Math.min(...i),l=Math.max(...i),a=Math.min(...o),s=Math.max(...o);return t.x>r&&t.x<l&&t.y>a&&t.y<s||!0===(null==n?void 0:n.includeBorder)&&(t.x===r||t.x===l||t.y===a||t.y===s)}function dt(t,e){const{groupQueue:n}=e,i=st(t,{groupQueue:n}),o=B(i[0],i[1]),r=B(i[1],i[2]),l=B(i[2],i[3]),a=B(i[3],i[0]),s=i[0],c=i[1],u=i[2],f=i[3],h=Math.max(s.x,c.x,u.x,f.x),d=Math.max(s.y,c.y,u.y,f.y);return{center:{x:(h+Math.min(s.x,c.x,u.x,f.x))/2,y:(d+Math.min(s.y,c.y,u.y,f.y))/2},topLeft:s,topRight:c,bottomLeft:f,bottomRight:u,top:o,right:r,left:a,bottom:l}}function yt(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakSet,s=function(){return w(f(this,r))};const gt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,xt=/(-?\d+(?:\.\d+)?)/gi;const pt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,mt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,bt=/^\s*$/,vt={};function wt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(vt[n[1]]||"/"===t.charAt(t.length-2))&&(e.isVoid=!0),e.name.startsWith("!--"))){const e=t.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==e?t.slice(4,e):""}}const i=new RegExp(pt);let o=null;for(;o=i.exec(t),null!==o;)if(o[0].trim())if(o[1]){const t=o[1].trim();let n=[t,""];t.indexOf("=")>-1&&(n=t.split("=")),e.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(e.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return e}function Mt(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(const n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(Mt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function Pt(t,e){let n=2;return void 0!==(null==e?void 0:e.decimalPlaces)&&(null==e?void 0:e.decimalPlaces)>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function Rt(t){return t[1]!=-1*t[3]||t[4]!=t[0]||t[0]*t[4]-t[3]*t[1]!=1?null:Math.acos(t[0])}const It="Text Element";function St(){return{boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"}}function $t(){return{background:"#D9D9D9"}}const Et={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function At(t,e="",n={},i){return Object.keys(t).forEach((o=>{var r;const l=e?`${e}${function(t){return/^\d+$/.test(t)&&!isNaN(Number(t))}(o)?`[${o}]`:`.${o}`}`:o;if(!(null==(r=null==i?void 0:i.ignorePaths)?void 0:r.includes(l))){const e=t[o];!function(t){return"object"==typeof t&&null!==t&&!(t instanceof Date)||Array.isArray(t)}(e)?n[l]=e:At(e,(Array.isArray(e),l),n,i)}})),n}function zt(t,e){return"object"!=typeof t||null===t?{"":t}:At(t,"",{},e)}function kt(t){return zt(t,{ignorePaths:["detail.children"]})}function Ot(t){return zt(t)}function Lt(t){return zt(t)}function Ct(t){return Array.isArray(t)?[...t]:t.split(/\.|\[|\]/).filter((t=>""!==t))}function jt(t,e,n){const i=Ct(e);if(0===i.length)return t;let o=t;if(o)for(let t=0;t<i.length;t++){const e=i[t];if(t===i.length-1){o[e]=n;break}if(o&&(void 0===(null==o?void 0:o[e])||"object"!=typeof(null==o?void 0:o[e])||null===(null==o?void 0:o[e]))){const n=i[t+1],r=/^\d+$/.test(n);o[e]=r?[]:{}}o=null==o?void 0:o[e]}return t}function Tt(t,e){const n=Ct(e);if(0===n.length)return t;let i=t;if(i)for(let t=0;t<n.length;t++){const e=n[t];if(t===n.length-1){delete i[e];break}if(i&&(void 0===(null==i?void 0:i[e])||"object"!=typeof(null==i?void 0:i[e])||null===(null==i?void 0:i[e]))){const o=n[t+1],r=/^\d+$/.test(o);i[e]=r?[]:{}}i=null==i?void 0:i[e]}return t}const Dt=t=>Pt(t,{decimalPlaces:4});function Wt(t,e){const n={detail:{}},i={detail:{}},o={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:null,after:null}},{detail:r}=t,{xRatio:l,yRatio:a,maxRatio:s}=e,c=(l+a)/2,{borderWidth:u,borderRadius:f,borderDash:h,shadowOffsetX:d,shadowOffsetY:y,shadowBlur:g}=r;if("number"==typeof u)r.borderWidth=Dt(u*c),n.detail.borderWidth=u,i.detail.borderWidth=r.borderWidth;else if(Array.isArray(r.borderWidth)){const t=u;r.borderWidth=[Dt(t[0]*a),Dt(t[1]*l),Dt(t[2]*a),Dt(t[3]*l)],n.detail.borderWidth=[...t],i.detail.borderWidth=[...r.borderWidth]}if("number"==typeof f)r.borderRadius=Dt(f*c),n.detail.borderRadius=f,i.detail.borderRadius=r.borderRadius;else if(Array.isArray(r.borderRadius)){const t=f;r.borderRadius=[t[0]*l,t[1]*l,t[2]*a,t[3]*a],n.detail.borderRadius=[...t],i.detail.borderRadius=[...r.borderRadius]}return Array.isArray(h)&&(h.forEach(((t,e)=>{r.borderDash[e]=Dt(t*s)})),n.detail.borderDash=[...h],i.detail.borderDash=[...r.borderDash]),"number"==typeof d&&(r.shadowOffsetX=Dt(d*s),n.detail.shadowOffsetX=d,i.detail.shadowOffsetX=r.shadowOffsetX),"number"==typeof y&&(r.shadowOffsetY=Dt(y*s),n.detail.shadowOffsetY=y,i.detail.shadowOffsetY=r.shadowOffsetY),"number"==typeof g&&(r.shadowBlur=Dt(g*s),n.detail.shadowBlur=g,i.detail.shadowBlur=r.shadowBlur),o.content.before=kt(n),o.content.after=kt(i),o}function Nt(t,e,n){const{type:i,uuid:o}=t,r=function(t,e){const{xRatio:n,yRatio:i}=e,{uuid:o,x:r,y:l,w:a,h:s}=t;t.x=Dt(r*n),t.y=Dt(l*i),t.w=Dt(a*n),t.h=Dt(s*i);const c={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:o,before:{x:r,y:l,w:a,h:s},after:{x:t.x,y:t.y,w:t.w,h:t.h}}},u=Wt(t,e);return c.content.before={...c.content.before,...u.content.before},c.content.after={...c.content.after,...u.content.after},c}(t,e),l={...r.content.before,uuid:o},a={...r.content.after,uuid:o};if(null==n||n.content.before.push(l),null==n||n.content.after.push(a),"circle"===i);else if("text"===i){const n=function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,l=(n+i)/2,a={},s={};return o&&o>0&&(t.detail.fontSize=Dt(o*l),a["detail.fontSize"]=o,s["detail.fontSize"]=t.detail.fontSize),r&&r>0&&(t.detail.lineHeight=Dt(r*l),a["detail.lineHeight"]=r,s["detail.lineHeight"]=t.detail.lineHeight),{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:a,after:s}}}(t,e);Object.keys(n.content.before||{}).forEach((t=>{var e;l[t]=null==(e=n.content.before)?void 0:e[t]})),Object.keys(n.content.after||{}).forEach((t=>{var e;a[t]=null==(e=n.content.after)?void 0:e[t]}))}else"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Nt(t,e,n)}))}function Ft(t,e,n){const i={type:"resizeElements",time:Date.now(),content:{method:"modifyElements",before:[],after:[]}},o=t.uuid,r=t.x,l=t.y,a=t.w,s=t.h,c=R.number(e.x)?e.x:t.x,u=R.number(e.y)?e.y:t.y,f=(e.w&&e.w>0?e.w:t.w)||0,h=(e.h&&e.h>0?e.h:t.h)||0,d={uuid:o,x:r,y:l,w:a,h:s},y={uuid:o,x:c,y:u,w:f,h:h};if("deepResize"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=f/t.w,n=h/t.h;if(e===n&&1===e)return i;const o=Math.min(e,n),r=Math.max(e,n);t.w=f,t.h=h;const l={xRatio:e,yRatio:n,minRatio:o,maxRatio:r};"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Nt(t,l,i)}));const a=Wt(t,l);return Object.keys(a.content.before||{}).forEach((t=>{var e;d[t]=null==(e=a.content.before)?void 0:e[t]})),Object.keys(a.content.after||{}).forEach((t=>{var e;y[t]=null==(e=a.content.after)?void 0:e[t]})),i}if("fixed"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=c-t.x,n=u-t.y,o=f-t.w;return function(t,e,n){if("group"!==t.type||!Array.isArray(t.detail.children))return;const{moveX:i,moveY:o,moveH:r,moveW:l}=e;let a=0,s=0,c=!1;0===i&&0===o||0===r&&0===l||(c=!0,a=-i,s=-o),!0===c&&t.detail.children.forEach((t=>{const{uuid:e,x:i,y:o}=t,r=i+a,l=o+s,c={uuid:e,x:i,y:o},u={uuid:e,x:r,y:l};t.x=r,t.y=l,null==n||n.content.before.push(c),null==n||n.content.after.push(u)}))}(t,{moveX:e,moveY:n,moveH:h-t.h,moveW:o},i),t.w=f,t.h=h,t.x=c,t.y=u,i}return t.w=f,t.h=h,t.x=c,t.y=u,i.content.before.push(d),i.content.after.push(y),i}function Bt(t,e,n){let i=!1;if(1===e.length){const o=e[0];n.splice(o,0,t),i=!0}else if(e.length>1){let o=n;for(let n=0;n<e.length;n++){const r=o[e[n]];if(n===e.length-1){const r=e[n];o.splice(r,0,t),i=!0}else{if(!(n<e.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Vt(t,e){let n=!1;if(1===t.length){const i=t[0];e.splice(i,1),n=!0}else if(t.length>1){let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e===t.length-1){const o=t[e];i.splice(o,1),n=!0}else{if(!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function Ht(t,e,n){const i=kt(e),o=["uuid","type"],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Tt(t,e),void 0!==n&&jt(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=kt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Tt(t,e)}))}return t}const Gt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Qt(t){const e=[...t.from],n=[...t.to];if(0===e.length||0===n.length)return null;if(e.length<=n.length)for(let t=0;t<e.length;t++)if(n[t]!==e[t]);else if(t===e.length-1)return null;let i=null;if(e.length>=1&&n.length>=1){if(e.length<=n.length)if(1===e.length)e[0]<n[0]&&(i="up-down");else for(let t=0;t<e.length&&e[t]===n[t];t++)if(e.length===e.length-1){i="up-down";break}if(e.length>=n.length)if(1===n.length)n[0]<e[0]&&(i="down-up");else for(let t=0;t<n.length&&(t===n.length-1&&n[t]<e[t]&&(i="down-up"),e[t]===n[t]);t++);}const o=e.length-1,r=n.length-1;return"up-down"===i&&o>=0?n[o]-=1:"down-up"===i&&r>=0&&(e[r]+=1),{from:e,to:n}}function Yt(t){const e=/([\w-]+)|\[(\d+)\]/g,n=[];let i;for(;null!==(i=e.exec(t));){const t=i[1]||i[2];t&&n.push(t)}return n}function Ut(t,e,n){let i=t;for(let t=0;t<e.length;t++){const o=e[t],r=Xt(o),l=t===e.length-1;try{r?qt(i,o):Zt(i,o)}catch(n){throw new Error(`Structure conflict at path '${e.slice(0,t+1).join(".")}': ${n.message}`)}l?Kt(i,o,n):i=Jt(i,o,e[t+1])}}function Xt(t){return/^\d+$/.test(t)}function qt(t,e){if(!Array.isArray(t))throw new Error("Expected array but found "+typeof t);const n=Number(e);n>t.length&&(t.length=n+1)}function Zt(t,e){if(Array.isArray(t))throw new Error(`Cannot create object property '${e}' on array`);if("object"!=typeof t||null===t)throw new Error(`Invalid structure for property '${e}'`)}function Jt(t,e,n){const i=!!n&&Xt(n);if(Array.isArray(t)){const n=Number(e);return t[n]||(t[n]=i?[]:{}),t[n]}return t[e]||(t[e]=i?[]:{}),t[e]}function Kt(t,e,n){if(Array.isArray(t)){const i=Number(e);i>=t.length&&(t.length=i+1),t[i]=n}else t[e]=n}return t.Context2D=C,t.EventEmitter=class{constructor(){h(this,i),d(this,i,new Map)}on(t,e){if(f(this,i).has(t)){const n=f(this,i).get(t)||[];null==n||n.push(e),f(this,i).set(t,n)}else f(this,i).set(t,[e])}off(t,e){if(f(this,i).has(t)){const n=f(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}f(this,i).set(t,n||[])}}trigger(t,e){const n=f(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(f(this,i).has(t)){const e=f(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){f(this,i).clear()}},t.Store=class{constructor(t){h(this,a),h(this,o),h(this,r),h(this,l),d(this,r,w(t.defaultStorage)),d(this,o,y(this,a,s).call(this)),d(this,l,t.defaultStatic||{})}set(t,e){f(this,o)[t]=e}get(t){return f(this,o)[t]}setStatic(t,e){f(this,l)[t]=e}getStatic(t){return f(this,l)[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?w(f(this,o)):{...f(this,o)}}clear(){d(this,o,y(this,a,s).call(this))}destroy(){d(this,o,null),d(this,l,null)}},t.calcDistance=D,t.calcElementCenter=G,t.calcElementCenterFromVertexes=Q,t.calcElementListSize=_,t.calcElementOriginRectInfo=dt,t.calcElementQueueVertexesQueueInGroup=lt,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o,rotateControllerSize:r,rotateControllerPosition:l}=e,a=(i&&i>0?i:8)/o.scale,{x:s,y:c,w:u,h:f,angle:h=0}=t,d=r,y=l,g=[{uuid:p(),x:s,y:c,w:u,h:f,angle:h,type:"group",detail:{children:[]}},...n];let x=0;g.forEach((({angle:t=0})=>{x+=t}));const m=st(t,{groupQueue:n}),b=st({x:s,y:c-(y+d/2)/o.scale,h:f+(2*y+d)/o.scale,w:u,angle:h},{groupQueue:[...n]}),v=B(m[0],m[1]),w=B(m[1],m[2]),M=B(m[2],m[3]),P=B(m[3],m[0]),R=m[0],I=m[1],S=m[2],$=m[3],E=yt(v,{size:a,angle:x}),A=yt(w,{size:a,angle:x}),z=yt(M,{size:a,angle:x}),k=yt(P,{size:a,angle:x}),O=yt(R,{size:a,angle:x}),L=yt(I,{size:a,angle:x}),C=yt($,{size:a,angle:x}),j=yt(S,{size:a,angle:x}),T=rt(O),D=rt(L),W=rt(C),N=rt(j),F=[T[1],D[0],D[3],T[2]],V=[D[3],D[2],N[1],N[0]],H=[W[1],N[0],N[3],W[2]],Q=[T[3],T[2],W[1],W[0]],Y=rt(E),U=rt(A),X=rt(z),q=rt(k),Z=B(b[0],b[1]),J=rt(yt(Z,{size:1.1*r/o.scale,angle:x}));return{originalElementCenter:G(t),originalElementSize:{...t},elementWrapper:m,left:{type:"left",vertexes:Q,center:P,size:a},right:{type:"right",vertexes:V,center:w,size:a},top:{type:"top",vertexes:F,center:v,size:a},bottom:{type:"bottom",vertexes:H,center:M,size:a},topLeft:{type:"top-left",vertexes:T,center:R,size:a},topRight:{type:"top-right",vertexes:D,center:I,size:a},bottomLeft:{type:"bottom-left",vertexes:W,center:$,size:a},bottomRight:{type:"bottom-right",vertexes:N,center:S,size:a},leftMiddle:{type:"left-middle",vertexes:q,center:P,size:a},rightMiddle:{type:"right-middle",vertexes:U,center:w,size:a},topMiddle:{type:"top-middle",vertexes:Y,center:v,size:a},bottomMiddle:{type:"bottom-middle",vertexes:X,center:M,size:a},rotate:{type:"rotate",vertexes:J,center:Z,size:r}}},t.calcElementVertexesInGroup=st,t.calcElementVertexesQueueInGroup=at,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=dt(t,{groupQueue:n}),{center:l,top:a,bottom:s,left:c,right:u,topLeft:f,topRight:h,bottomLeft:d,bottomRight:y}=r,g={center:ut(l,{viewScaleInfo:i}),topLeft:ut(f,{viewScaleInfo:i}),topRight:ut(h,{viewScaleInfo:i}),bottomLeft:ut(d,{viewScaleInfo:i}),bottomRight:ut(y,{viewScaleInfo:i}),top:ut(a,{viewScaleInfo:i}),right:ut(u,{viewScaleInfo:i}),left:ut(c,{viewScaleInfo:i}),bottom:ut(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),e=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),n=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),i=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),o={x:g.center.x,y:g.center.y},r={x:n,y:i},l={x:t,y:i},a={x:t,y:e},s={x:n,y:e},c=B(r,l),u=B(s,a),f=B(r,s);return{center:o,topLeft:r,topRight:l,bottomLeft:s,bottomRight:a,top:c,right:B(l,a),left:f,bottom:u}}return g},t.calcElementsContextSize=tt,t.calcElementsViewInfo=function(t,e,n){const i=tt(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,o=n&&n>0?n:8,{x:r,y:l,w:a,h:s}=ct(t,{viewScaleInfo:i}),c=G({x:r,y:l,w:a,h:s}),u={x:c.x,y:l},f={x:r+a,y:c.y},h={x:c.x,y:l+s},d={x:r,y:c.y},y={x:r,y:l},g={x:r+a,y:l},x={x:r+a,y:l+s},p={x:r,y:l+s},m=yt(u,{size:o,angle:0}),b=yt(f,{size:o,angle:0}),v=yt(h,{size:o,angle:0}),w=yt(d,{size:o,angle:0}),M=yt(y,{size:o,angle:0}),P=yt(g,{size:o,angle:0}),R=yt(p,{size:o,angle:0}),I=yt(x,{size:o,angle:0}),S=rt(M),$=rt(P),E=rt(R),A=rt(I),z=[S[1],$[0],$[3],S[2]],k=[$[3],$[2],A[1],A[0]],O=[E[1],A[0],A[3],E[2]],L=[S[3],S[2],E[1],E[0]],C=rt(m),j=rt(b),T=rt(v);return{left:{type:"left",vertexes:L,center:d,size:o},right:{type:"right",vertexes:k,center:f,size:o},top:{type:"top",vertexes:z,center:u,size:o},bottom:{type:"bottom",vertexes:O,center:h,size:o},topLeft:{type:"top-left",vertexes:S,center:y,size:o},topRight:{type:"top-right",vertexes:$,center:g,size:o},bottomLeft:{type:"bottom-left",vertexes:E,center:p,size:o},bottomRight:{type:"bottom-right",vertexes:A,center:x,size:o},leftMiddle:{type:"left-middle",vertexes:rt(w),center:d,size:o},rightMiddle:{type:"right-middle",vertexes:j,center:f,size:o},topMiddle:{type:"top-middle",vertexes:C,center:u,size:o},bottomMiddle:{type:"bottom-middle",vertexes:T,center:h,size:o}}},t.calcPointMoveElementInGroup=function(t,e,n){let i=e.x-t.x,o=e.y-t.y;const r=[];if(n.forEach((t=>{const{x:e,y:n,w:i,h:o,angle:l=0}=t;r.push({x:e,y:n,w:i,h:o,angle:0-l})})),(null==n?void 0:n.length)>0){const n=X(t,r),l=X(e,r);i=l.x-n.x,o=l.y-n.y}return{moveX:i,moveY:o}},t.calcRadian=function(t,e,n){const i=Y(t,e),o=Y(t,n);return null!==o&&null!==i?o-i:0},t.calcResultMovePosition=Qt,t.calcRevertMovePosition=function(t){const e=Qt(t);return e?{from:[...e.to],to:[...e.from]}:e},t.calcSpeed=function(t,e){return D(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o}=t.detail;const{borderDash:r}=t.detail,l=Array.isArray(r)&&r.length>0,{boxSizing:a=Et.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:c,y:u,w:f,h:h}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*i;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let y=0;return"number"==typeof s&&(y=(s||0)*i),"border-box"!==a||l?"content-box"===a?(c=t.x-y/2,u=t.y-y/2,f=t.w+y,h=t.h+y):(c=t.x,u=t.y,f=t.w,h=t.h):(c=t.x+y/2,u=t.y+y/2,f=t.w-y,h=t.h-y),f=Math.max(f,1),h=Math.max(h,1),d=d.map((t=>Math.min(t,f/2,h/2))),{x:c,y:u,w:f,h:h,radiusList:d}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:l,scale:a}=i,{width:s,height:c}=o;e=0-r+s/a/2,n=0-l+c/a/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,l,a,s,c,u,f;let h=0,d=0,y=1,g=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,x=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,p=(null==(a=null==(l=null==t?void 0:t.elements)?void 0:l[0])?void 0:a.w)||0,m=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:b,height:v}=e.viewSizeInfo;if(t.layout&&"hidden"===(null==(f=null==(u=t.layout)?void 0:u.detail)?void 0:f.overflow)?(g=0,x=0,p=t.layout.w||0,m=t.layout.h||0):t.elements.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=Z(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,g),i=Math.min(e.y,x),o=Math.max(e.x+e.w,g+p),r=Math.max(e.y+e.h,x+m);g=n,x=i,p=Math.abs(o-n),m=Math.abs(r-i)})),t.layout){const{x:e,y:n,w:i,h:o}=t.layout;k.x(e)&&k.y(n)&&k.w(i)&&k.h(o)&&(g=Math.min(g,e),x=Math.min(x,n),p=Math.max(p,i),m=Math.max(m,o))}if(p>0&&m>0){const t=Pt(b/p,{decimalPlaces:4}),e=Pt(v/m,{decimalPlaces:4});y=Math.min(t,e,1),h=(p*y-b)/2/y+g,d=(m*y-v)/2/y+x}return{offsetX:Pt(h,{decimalPlaces:0}),offsetY:Pt(d,{decimalPlaces:0}),scale:y}},t.calcViewElementSize=ct,t.calcViewPointSize=ut,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:l,height:a,contextWidth:s,contextHeight:c}=r,u=0-i*n,f=0-o*n;return{scale:n,offsetLeft:u,offsetTop:f,offsetRight:l-(s*n+u/n),offsetBottom:a-(c*n+f/n)}},t.calcViewVertexes=function(t,e){return[ut(t[0],e),ut(t[1],e),ut(t[2],e),ut(t[3],e)]},t.check=L,t.checkRectIntersect=it,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=x[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if(1===(null==t?void 0:t.stops.length))e=t.stops[0].color;else if("linear-gradient"===(null==t?void 0:t.type)){const n=[];"number"==typeof t.angle?n.push(`${t.angle}deg`):n.push("180deg"),Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`radial-gradient(circle, ${n.join(", ")})`}return e},t.colorToLinearGradientCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("radial-gradient"===(null==t?void 0:t.type)||"linear-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.length>0&&(t.stops.forEach(((e,i)=>{n.push(`${e.color} ${100*e.offset}%`),i===t.stops.length-1&&e.offset<1&&n.push(`${e.color} ${100*e.offset}%`)})),e=`linear-gradient(90deg, ${n.join(", ")})`)}return e},t.compose=function(t){return function(e,n){return function i(o){let r=t[o];o===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,i.bind(null,o+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=(null==e?void 0:e.type)||"image/png";return(null==e?void 0:e.radio)&&(null==e?void 0:e.radio)>0&&(null==e?void 0:e.radio)<=1&&(n=null==e?void 0:e.radio),new Promise(((e,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:t,height:o}=r,l=t*n,a=o*n;let s=document.createElement("canvas");s.width=l,s.height=a;s.getContext("2d").drawImage(r,0,0,l,a);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=b,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o}=e,r={width:n,height:i,devicePixelRatio:o},l=t.getContext("2d"),a=T(r),s=T(r),c=T(r),u=j({ctx:l,...r}),f=T(r);return{underlayContext:c,viewContext:a,overlayContext:s,boardContext:u,tempContext:f,drawView:()=>{const{width:t,height:e}=a.$getSize();u.clearRect(0,0,t,e),u.drawImage(c.canvas,0,0,t,e),u.drawImage(a.canvas,0,0,t,e),u.drawImage(s.canvas,0,0,t,e),c.clearRect(0,0,t,e),a.clearRect(0,0,t,e),s.clearRect(0,0,t,e)}}},t.createContext2D=j,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=200,r=200;if(e){const{viewScaleInfo:l,viewSizeInfo:a}=e,{scale:s,offsetLeft:c,offsetTop:u}=l,{width:f,height:h}=a,d=f/4,y=h/4;o=200>=d?d/s:200/s,r=200>=y?y/s:200/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/12*2),n=(0-c+f/2-o*s/2)/s,i=(0-u+h/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};return{text:It,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontSize:t.w/12,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===t?o={svg:'<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'}:"image"===t?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===t&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{uuid:p(),...i,...e,type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=T,t.createUUID=p,t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{t(...i),n=-1}),e)}},t.deepClone=w,t.deepCloneData=function(t){const{elements:e,...n}=t;return{...w(n),elements:e.map((t=>M(t)))}},t.deepCloneElement=M,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Vt(nt(t,e),e)},t.deleteElementInListByPosition=Vt,t.downloadFileFromText=function(t,e){const{fileName:n}=e,i=function(t){const e=(new TextEncoder).encode(t),n=new Blob([e],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(t);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,o=t.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},t.elementToBoxInfo=function(t){const{x:e,y:n,w:i,h:o,detail:r}=t,{borderWidth:l,borderRadius:a,boxSizing:s}=r;let c=0,u=0,f=0,h=0,d=0,y=0,g=0,x=0;"number"==typeof l&&l>0?(c=l,u=l,f=l,h=l):Array.isArray(l)&&(c=k.positiveNum(l[0])?l[0]:0,u=k.positiveNum(l[1])?l[0]:0,f=k.positiveNum(l[2])?l[0]:0,h=k.positiveNum(l[3])?l[0]:0),"number"==typeof a&&a>0?(d=a,y=a,g=a,x=a):Array.isArray(a)&&(d=k.positiveNum(a[0])?a[0]:0,y=k.positiveNum(a[0])?a[0]:0,g=k.positiveNum(a[0])?a[0]:0,x=k.positiveNum(a[0])?a[0]:0);const p={x:e,y:n},m={x:e+i,y:n},b={x:e+i,y:n+o},v={x:e,y:n+o},w={x:e,y:n+d},M={x:e+d,y:n},P={x:e+i-y,y:n},R={x:e+i,y:n+y},I={x:e+i,y:n+o-x},S={x:e+i-x,y:n+o},$={x:e+g,y:n+o},E={x:e,y:n+o-g};let A={...p},z={...m},O={...b},L={...v},C={...w},j={...M},T={...P},D={...R},W={...I},N={...S},F={...$},B={...E},V={...p},H={...m},G={...b},Q={...v},Y={...w},U={...M},X={...P},q={...R},Z={...I},J={...S},K={...$},_={...E};return"border-box"===s?(V={x:V.x+h,y:V.y+c},H={x:H.x-u,y:H.y+c},G={x:G.x-u,y:G.y-f},Q={x:Q.x+h,y:Q.y-f},Y={x:Y.x+h,y:Y.y+c},U={x:U.x+h,y:U.y+c},X={x:X.x-u,y:X.y+c},q={x:q.x-u,y:q.y+c},Z={x:Z.x-u,y:Z.y-f},J={x:J.x-u,y:J.y-f},K={x:K.x+h,y:K.y-f},_={x:_.x+h,y:_.y-f}):"content-box"===s?(A={x:A.x-h,y:A.y-c},z={x:z.x+u,y:z.y-c},O={x:O.x+u,y:O.y+f},L={x:L.x-h,y:L.y+f},C={x:C.x-h,y:C.y-c},j={x:j.x-h,y:j.y-c},T={x:T.x+u,y:T.y-c},D={x:D.x+u,y:D.y-c},W={x:W.x+u,y:W.y+f},N={x:N.x+u,y:N.y+f},F={x:F.x-h,y:F.y+f},B={x:B.x-h,y:B.y+f}):(V={x:V.x+h/2,y:V.y+c/2},H={x:H.x-u/2,y:H.y+c/2},G={x:G.x-u/2,y:G.y-f/2},Q={x:Q.x+h/2,y:Q.y-f/2},Y={x:Y.x+h/2,y:Y.y+c/2},U={x:U.x+h/2,y:U.y+c/2},X={x:X.x-u/2,y:X.y+c/2},q={x:q.x-u/2,y:q.y+c/2},Z={x:Z.x-u/2,y:Z.y-f/2},J={x:J.x-u/2,y:J.y-f/2},K={x:K.x+h/2,y:K.y-f/2},_={x:_.x+h/2,y:_.y-f/2},A={x:A.x-h/2,y:A.y-c/2},z={x:z.x+u/2,y:z.y-c/2},O={x:O.x+u/2,y:O.y+f/2},L={x:L.x-h/2,y:L.y+f/2},C={x:C.x-h/2,y:C.y-c/2},j={x:j.x-h/2,y:j.y-c/2},T={x:T.x+u/2,y:T.y-c/2},D={x:D.x+u/2,y:D.y-c/2},W={x:W.x+u/2,y:W.y+f/2},N={x:N.x+u/2,y:N.y+f/2},F={x:F.x-h/2,y:F.y+f/2},B={x:B.x-h/2,y:B.y+f/2}),{btw:c,brw:u,bbw:f,blw:h,btlr:d,btrr:y,bblr:g,bbrr:x,p0:p,p1:m,p2:b,p3:v,p0s:w,p0e:M,p1s:P,p1e:R,p2s:I,p2e:S,p3s:$,p3e:E,op0:A,op1:z,op2:O,op3:L,op0s:C,op0e:j,op1s:T,op1e:D,op2s:W,op2e:N,op3s:F,op3e:B,ip0:V,ip1:H,ip2:G,ip3:Q,ip0s:Y,ip0e:U,ip1s:X,ip1e:q,ip2s:Z,ip2e:J,ip3s:K,ip3e:_}},t.enhanceFontFamliy=function(t){return[t,...Gt].join(", ")},t.equalPoint=W,t.equalTouchPoint=function(t,e){return!0===W(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=w(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,l;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(v(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const e=b(i,t.uuid);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source))n[e]={type:"svg",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(l=o[e])?void 0:l.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,r(t.detail.children)}}))};return r(i.elements),i.assets=n,i},t.filterElementAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.detail.src:"svg"===t.type?i=t.detail.svg:"html"===t.type&&(i=t.detail.html),"string"!=typeof i||v(i)||(e=b(i,t.uuid),n={type:t.type,value:i},"image"===t.type?t.detail.src=e:"svg"===t.type?t.detail.svg=e:"html"===t.type&&(t.detail.html=e)),{element:t,assetId:e,assetItem:n}},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const l=n[r];if(l.uuid===e){o=l;break}if(!o&&"group"===l.type){const n=t(e,(null==(i=null==l?void 0:l.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=et,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const l=i[r];t.includes(l.uuid)?n.push(l):"group"===l.type&&e((null==(o=null==l?void 0:l.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=et(t,e);i&&n.push(i)})),n},t.flatElementList=function(t){const e=[],n=[],i=t=>{if(!function(t){var e;if(["rect","circle"].includes(t.type)){const e=t.detail;if(!e.background&&!e.borderWidth)return!1;if("transparent"===e.background&&!e.borderWidth)return!1}if(["group"].includes(t.type)){const e=t.detail||{},{children:n}=e;if(!(n.length>0||e.background||e.borderWidth))return!1;if(!(n.length>0||"transparent"!==e.background||e.borderWidth))return!1}if("text"===t.type&&!t.detail.text)return!1;if("image"===t.type&&!t.detail.src)return!1;if("html"===t.type&&!t.detail.html)return!1;if("svg"===t.type&&!t.detail.svg)return!1;if("path"===t.type){const n=t.detail;if(!((null==(e=null==n?void 0:n.commands)?void 0:e.length)>0))return!1}return!0}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:o}=t;const{w:r,h:l,angle:a=0}=t;let s=0;if(n.forEach((t=>{i+=t.x,o+=t.y,s+=t.angle||0})),s=K(s),0===s)return{x:i,y:o,w:r,h:l,angle:a};s+=t.angle||0,s=K(s);const c=st(t,{groupQueue:n}),u=U(Q(c),c[0],V(0-s));return i=u.x,o=u.y,{x:i,y:o,w:r,h:l,angle:s}}(t,{groupQueue:n}),o={...t,...i};e.push(o)},o=t=>{var e;if(!0!==(null==(e=null==t?void 0:t.operations)?void 0:e.invisible))if("group"===t.type){const{detail:e}=t,{children:r,...l}=e;i({...t,detail:{...l,children:[]}}),n.push(t),r.forEach((t=>{o(t)})),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];o(n)}return e},t.flatObject=zt,t.formatNumber=Pt,t.generateHTML=function(t){return t.reduce((function(t,e){return t+Mt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.get=function(t,e,n){if(!e)return;const i=Ct(e);let o=t;for(const t of i){if(null==o)return n;o=o[t]}return void 0!==o?o:n},t.getCenterFromTwoPoints=B,t.getDefaultElementDetailConfig=St,t.getDefaultElementRectDetail=$t,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&v(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&v(t.detail.svg)?e.push(t.detail.svg):"html"===t.type&&t.detail.html?e.push(t.detail.html):"group"===t.type&&Array.isArray(t.detail.children)&&n(t.detail.children)}))};return n(t),e},t.getElementPositionFromList=nt,t.getElementPositionMapFromList=function(t,e){const n=[],i={};let o=!1;const r=e=>{var l;for(let a=0;a<e.length&&!0!==o;a++){n.push(a);const s=e[a];if(t.includes(s.uuid)){if(i[s.uuid]=[...n],Object.keys(i).length===t.length){o=!0;break}}else"group"===s.type&&r((null==(l=null==s?void 0:s.detail)?void 0:l.children)||[]);if(o)break;n.pop()}};return r(e),i},t.getElementRotateVertexes=q,t.getElementSize=function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return{x:e,y:n,w:i,h:o,angle:r}},t.getElementVertexes=ot,t.getGroupQueueByElementPosition=function(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=o[e[t]];if("group"!==(null==r?void 0:r.type)||!Array.isArray(null==(n=null==r?void 0:r.detail)?void 0:n.children))return null;i.push(r),o=r.detail.children}return i},t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let l=0;l<i.length;l++){const a=i[l];if(a.uuid===e){r=a;break}if(!r&&"group"===a.type){n.push(a);const i=t(e,(null==(o=null==a?void 0:a.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:l,viewScaleInfo:a,viewSizeInfo:s,groupQueue:c}=e,u={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let e=c.length-1;e>=0;e--){let o=0,l=0,s=0;for(let t=0;t<=e;t++)o+=c[t].x,l+=c[t].y,s+=c[t].angle||0;const f=c[e];if(f&&"group"===f.type&&Array.isArray(null==(n=f.detail)?void 0:n.children))for(let n=0;n<f.detail.children.length;n++){const h=f.detail.children[n];if(!0!==(null==(i=null==h?void 0:h.operations)?void 0:i.invisible)){if(!h)break;if(ft(t,{context2d:r,element:{x:o+h.x,y:l+h.y,w:h.w,h:h.h,angle:s+(h.angle||0)},viewScaleInfo:a})){u.element=h,(e<c.length-1||"group"!==h.type)&&(u.groupQueueIndex=e);break}}}if(u.element)break}if(u.element)return u;for(let e=l.elements.length-1;e>=0;e--){const n=l.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&ft(t,{context2d:r,element:n,viewScaleInfo:a})){u.index=e,u.element=n;break}}return u},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:null==e?void 0:e.scale,offsetTop:null==e?void 0:e.offsetTop,offsetBottom:null==e?void 0:e.offsetBottom,offsetLeft:null==e?void 0:e.offsetLeft,offsetRight:null==e?void 0:e.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:null==e?void 0:e.width,height:null==e?void 0:e.height,contextWidth:null==e?void 0:e.contextWidth,contextHeight:null==e?void 0:e.contextHeight}},t.groupElementsByPosition=function(t,e){if(e.length>1){let n=!0,i=[];for(let t=1;t<e.length;t++){const o=e[t-1],r=e[t];if(!(o.length>0&&r.length>0)){n=!1;break}if(o.length!==r.length){n=!1;break}const l=[...o],a=[...r],s=l.pop(),c=a.pop();1===t&&"number"==typeof s&&s>=0&&i.push(s),"number"==typeof c&&c>=0&&i.push(c)}if(!0!==n)return console.error("[idraw]: The grouped elements are not siblings!"),t;i.sort(((t,e)=>t-e));const o=[...e[0]].splice(0,e[0].length-1),r=[],l=[...o,i[0]];for(let e=0;e<i.length;e++){const n=et([...o,i[e]],t);n&&r.push(n)}const a=_(r);for(let t=0;t<r.length;t++){const e=r[t];e&&(e.x-=a.x,e.y-=a.y)}for(let e=i.length-1;e>=0;e--){Vt([...o,i[e]],t)}Bt({name:"Group",uuid:p(),type:"group",...a,detail:{children:r}},l,t)}return t},t.insertElementToListByPosition=Bt,t.is=k,t.isAssetId=v,t.isColorStr=g,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:l}=t,{x:a,y:s,w:c,h:u}=ct(t,{viewScaleInfo:i}),f=Z({x:a,y:s,w:c,h:u,angle:l}),h={x:0,y:0,w:o,h:r},d=Math.min(f[0].x,f[1].x,f[2].x,f[3].x),y=Math.min(f[0].y,f[1].y,f[2].y,f[3].y);return it(h,{x:d,y:y,w:Math.max(f[0].x,f[1].x,f[2].x,f[3].x)-d,h:Math.max(f[0].y,f[1].y,f[2].y,f[3].y)-y})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isSameElementSize=function(t,e){return t.x===e.x&&t.y===e.y&&t.h===e.h&&t.w===e.w&&K(t.angle||0)===K(e.angle||0)},t.isViewPointInElement=ft,t.isViewPointInElementSize=function(t,e,n){return ht(t,rt(e),n)},t.isViewPointInVertexes=ht,t.istype=R,t.limitAngle=K,t.loadHTML=async function(t,e){t=t.replace(/\&/gi,"&amp;");const n=await function(t,e){const{width:n,height:i}=e;return new Promise(((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),l=new FileReader;l.readAsDataURL(r),l.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},l.onerror=function(t){o(t)}}))}(t,e);return await S(n)},t.loadImage=S,t.loadSVG=async function(t){const e=await function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return await S(e)},t.matrixToAngle=function(t){const e=Rt(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=Rt,t.merge=function t(e,n){const i=e;for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"==typeof n[e]&&null!==n[e]&&"object"==typeof i[e]&&null!==i[e]?i[e]=t(i[e],n[e]):i[e]=n[e]);return e},t.mergeElement=Ht,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeGlobal=function(t,e,n){const i=Lt(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Tt(t,e),void 0!==n&&jt(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Lt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Tt(t,e)}))}return t},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.mergeLayout=function(t,e,n){const i=Ot(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Tt(t,e),void 0!==n&&jt(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Ot(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Tt(t,e)}))}return t},t.moveElementPosition=function(t,e){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{elements:t,from:n,to:i};if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return{elements:t,from:n,to:i};const o=et(n,t);if(o){if(!Bt(o,i,t))return{elements:t,from:n,to:i};let e=-1,r=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(r=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){r=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(r=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(r=!0),n[t]===i[t]);t++);}if(!0===r)for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),Vt(n,t)}return{elements:t,from:n,to:i}},t.omit=function(t,e){const n={...t};for(const t of e)delete n[t];return n},t.originRectInfoToRangeRectInfo=function(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},l={x:i,y:o},a={x:e,y:o},s={x:e,y:n},c={x:i,y:n},u=B(l,a),f=B(c,s),h=B(l,c);return{center:r,topLeft:l,topRight:a,bottomLeft:c,bottomRight:s,top:u,right:B(a,s),left:h,bottom:f}},t.parseAngleToRadian=V,t.parseFileToBase64=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsDataURL(t)}))},t.parseFileToText=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsText(t)}))},t.parseHTML=function(t){const e=[],n=[];let i,o=-1;return t.replace(mt,((r,l)=>{const a="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=l+r.length,u=t.charAt(c);let f;if(s){const t=wt(r);return o<0?(e.push(t),r):(f=n[o],f.children.push(t),r)}if(a){if(o++,i=wt(r),!i.isVoid&&u&&"<"!==u){const e=t.slice(c,t.indexOf("<",c));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===o&&e.push(i),f=n[o-1],f&&f.children.push(i),n[o]=i}if((!a||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==u&&u)){f=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);bt.test(r)&&(r=" "),(i>-1&&o+f.length>=0||" "!==r)&&r.trim()&&f.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:r.trim()})}return r})),e},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGPath=function(t){const e=[];return t.replace(gt,((t,n,i)=>{const o=i.match(xt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let o=document.createElement("input");o.type="file",e&&(o.accept=e),o.addEventListener("change",(function(){var t;const e=null==(t=o.files)?void 0:t[0];n({file:e}),o=null})),o.addEventListener("error",(function(t){"function"==typeof i&&i(t),o=null})),o.click()},t.resizeEffectGroupElement=Ft,t.rotateByCenter=H,t.rotateElement=function(t,e,n){const i=G(e);H(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=Z,t.rotatePoint=U,t.rotatePointInGroup=X,t.rotateVertexes=J,t.set=jt,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=w(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=b(e,t.uuid);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.toFlattenElement=kt,t.toFlattenGlobal=Lt,t.toFlattenLayout=Ot,t.toPath=Ct,t.unflatObject=function(t){const e={};for(const[n,i]of Object.entries(t)){Ut(e,Yt(n),i)}return e},t.ungroupElementsByPosition=function(t,e){var n;const i=et(e,t);i&&"group"===(null==i?void 0:i.type)&&Array.isArray(null==(n=null==i?void 0:i.detail)?void 0:n.children)||console.error("[idraw]: The ungrouped element is not a group element!");const o=[...e].splice(0,e.length-1),r=e[e.length-1],{x:l,y:a}=i;return Vt(e,t),i.detail.children.forEach(((e,n)=>{e.x+=l,e.y+=a;Bt(e,[...o,r+n],t)})),t},t.updateElementInList=function t(e,n,i){var o,r,l;let a=null;for(let s=0;s<i.length;s++){const c=i[s];if(c.uuid===e){"group"===c.type&&(null==(o=c.operations)?void 0:o.resizeEffect)&&Ft(c,{...n},{resizeEffect:null==(r=c.operations)?void 0:r.resizeEffect}),Ht(c,n),a=c;break}"group"===c.type&&(a=t(e,n,(null==(l=null==c?void 0:c.detail)?void 0:l.children)||[]))}return a},t.updateElementInListByPosition=function(t,e,n,i){var o,r;const l=et(t,n);return l&&("group"===l.type&&(null==(o=l.operations)?void 0:o.resizeEffect)&&Ft(l,{...e},{resizeEffect:null==(r=l.operations)?void 0:r.resizeEffect}),Ht(l,e,i)),l},t.vaildPoint=F,t.vaildTouchPoint=function(t){return!0===F(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,l=e/i.scale,a=n.x,s=n.y;return{moveX:a-a*l+(o*l-o),moveY:s-s*l+(r*l-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:l,height:a,contextWidth:s,contextHeight:c}=o;let u=i.offsetLeft,f=i.offsetRight,h=i.offsetTop,d=i.offsetBottom;return u+=e,h+=n,f=l-(s*r+u),d=a-(c*r+h),{scale:r,offsetTop:h,offsetLeft:u,offsetRight:f,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
1
+ var iDrawUtil=function(t){"use strict";var e,n,i,o,r,l,a,s,c=t=>{throw TypeError(t)},u=(t,e,n)=>e.has(t)||c("Cannot "+n),h=(t,e,n)=>(u(t,e,"read from private field"),n?n.call(t):e.get(t)),f=(t,e,n)=>e.has(t)?c("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),d=(t,e,n,i)=>(u(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),y=(t,e,n)=>(u(t,e,"access private method"),n);function g(t){return"string"==typeof t&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const x={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function p(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function m(t,e){let n=0;for(let e=0;e<t.length;e++)n+=t.charCodeAt(e);return(n+e).toString(16).substring(0,4)}function b(t,e){const n=t.length,i=function(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n);return e}(e),o=Math.floor(n/2),r=t.substring(0,4).padStart(4,"0"),l=t.substring(0,4).padStart(4,"0");return`@assets/${m(n.toString(16).padStart(4,r),i).padStart(4,"0")}${m(t.substring(o-4,o).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-8,o-4).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-12,o-8).padStart(4,r),i).padStart(4,"0")}-${m(t.substring(o-16,o-12).padStart(4,l),i).padStart(4,"0")}-${m(t.substring(o,o+4).padStart(4,l),i).padStart(4,"0")}${m(t.substring(o+4,o+8).padStart(4,l),i).padStart(4,"0")}${m(l.padStart(4,r).padStart(4,l),i)}`}function v(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function w(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach((e=>{n.push(t(e))})),n}if("Object"===n){const n={};Object.keys(e).forEach((i=>{n[i]=t(e[i])}));return Object.getOwnPropertySymbols(e).forEach((i=>{n[i]=t(e[i])})),n}}(t)}function M(t){const e=w(t),n=t=>{t.uuid=p(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e}function P(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(t,e){const n=P(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===P(t),json:t=>"Object"===P(t),function:t=>"Function"===P(t),asyncFunction:t=>"AsyncFunction"===P(t),boolean:t=>"Boolean"===P(t),string:t=>"String"===P(t),number:t=>"Number"===P(t),undefined:t=>"Undefined"===P(t),null:t=>"Null"===P(t),promise:t=>"Promise"===P(t)};const{Image:I}=window;function S(t){return new Promise(((e,n)=>{const i=new I;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function $(t){return"number"==typeof t&&t>=0}function E(t){return"number"==typeof t&&(t>0||t<=0)}function A(t){return E(t)}function z(t){return E(t)}function k(t){return $(t)}function O(t){return $(t)}function L(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function C(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function j(t){return["rect","circle","text","image","svg","html","group"].includes(t)}const T={positiveNum:$,data:function(t){return!!(Array(null==t?void 0:t.elements)&&(null==t?void 0:t.elements.length)>=0)},element:function(t){return!!t&&(j(null==t?void 0:t.type)&&A(null==t?void 0:t.x)&&z(null==t?void 0:t.y)&&k(null==t?void 0:t.w)&&O(null==t?void 0:t.h))},layout:function(t){return!!t&&(A(null==t?void 0:t.x)&&z(null==t?void 0:t.y)&&k(null==t?void 0:t.w)&&O(null==t?void 0:t.h))},type:j,x:A,y:z,w:k,h:O,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:E,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},borderRadius:function(t){return $(t)||Array.isArray(t)&&$(t[0])&&$(t[1])&&$(t[2])&&$(t[3])},color:function(t){return g(t)},imageSrc:function(t){return C(t)||L(t)},imageURL:L,imageBase64:C,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return E(t)&&t>0},lineHeight:function(t){return E(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)},strokeWidth:function(t){return E(t)&&t>0}};function D(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!T.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderRadius")&&!T.number(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!T.number(i)))}const W={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(T.x(e)&&T.y(n)&&T.w(i)&&T.h(o)&&T.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:l,fontWeight:a,background:s,strokeWidth:c,strokeColor:u}=t;return!!T.text(e)&&(!!T.color(n)&&(!!T.fontSize(i)&&(!(Object.prototype.hasOwnProperty.call(t,"background")&&!T.color(s))&&(!(Object.prototype.hasOwnProperty.call(t,"fontWeight")&&!T.fontWeight(a))&&(!(Object.prototype.hasOwnProperty.call(t,"lineHeight")&&!T.lineHeight(o))&&(!(Object.prototype.hasOwnProperty.call(t,"fontFamily")&&!T.fontFamily(r))&&(!(Object.prototype.hasOwnProperty.call(t,"textAlign")&&!T.textAlign(l))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeWidth")&&!T.strokeWidth(c))&&(!(Object.prototype.hasOwnProperty.call(t,"strokeColor")&&!T.color(u))&&!!D(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!T.color(e))&&!!D(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(Object.prototype.hasOwnProperty.call(t,"background")&&!T.color(e))&&(!(Object.prototype.hasOwnProperty.call(t,"borderColor")&&!T.color(n))&&!(Object.prototype.hasOwnProperty.call(t,"borderWidth")&&!T.number(i)))},imageDesc:function(t){const{src:e}=t;return!!T.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!T.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!T.html(e)}};class N{constructor(t,i){f(this,e),f(this,n),d(this,e,t),d(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/h(this,n).devicePixelRatio}$doPixelRatio(t){return h(this,n).devicePixelRatio*t}$getContext(){return h(this,e)}$setContext(t){d(this,e,t)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),h(this,e).font=`${n.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return h(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:l}=t,{canvas:a}=h(this,e);a.width=i*r,a.height=o*r,d(this,n,{...h(this,n),devicePixelRatio:r}),!0===l&&(a.style.width=`${i}px`,a.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=h(this,n),{width:i,height:o}=h(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return h(this,e).canvas}get fillStyle(){return h(this,e).fillStyle}set fillStyle(t){h(this,e).fillStyle=t}get strokeStyle(){return h(this,e).strokeStyle}set strokeStyle(t){h(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(h(this,e).lineWidth)}set lineWidth(t){h(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return h(this,e).textAlign}set textAlign(t){h(this,e).textAlign=t}get textBaseline(){return h(this,e).textBaseline}set textBaseline(t){h(this,e).textBaseline=t}get globalAlpha(){return h(this,e).globalAlpha}set globalAlpha(t){h(this,e).globalAlpha=t}get shadowColor(){return h(this,e).shadowColor}set shadowColor(t){h(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(h(this,e).shadowOffsetX)}set shadowOffsetX(t){h(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(h(this,e).shadowOffsetY)}set shadowOffsetY(t){h(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(h(this,e).shadowBlur)}set shadowBlur(t){h(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return h(this,e).lineCap}set lineCap(t){h(this,e).lineCap=t}get globalCompositeOperation(){return h(this,e).globalCompositeOperation}set globalCompositeOperation(t){h(this,e).globalCompositeOperation=t}fill(...t){return h(this,e).fill(...t)}arc(t,n,i,o,r,l){return h(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,l)}rect(t,n,i,o){return h(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return h(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return h(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return h(this,e).beginPath()}closePath(){return h(this,e).closePath()}lineTo(t,n){return h(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return h(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return h(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}bezierCurveTo(t,n,i,o,r,l){return h(this,e).bezierCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}quadraticCurveTo(t,n,i,o){return h(this,e).quadraticCurveTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return h(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return h(this,e).setLineDash(n)}stroke(t){return t?h(this,e).stroke(t):h(this,e).stroke()}translate(t,n){return h(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return h(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],l=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],u=t[t.length-1];return 9===t.length?h(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u)):h(this,e).drawImage(n,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u))}createPattern(t,n){return h(this,e).createPattern(t,n)}measureText(t){return h(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?h(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):h(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?h(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):h(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){h(this,e).save()}restore(){h(this,e).restore()}scale(t,n){h(this,e).scale(t,n)}circle(t,n,i,o,r,l,a,s){h(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,l,a,s)}isPointInPath(t,n){return h(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return h(this,e).clip(...t)}setTransform(t,n,i,o,r,l){return h(this,e).setTransform(t,n,i,o,r,l)}getTransform(){return h(this,e).getTransform()}createLinearGradient(t,n,i,o){return h(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,l){return h(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}createConicGradient(t,n,i){return h(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function F(t){const{width:e,height:n,ctx:i,devicePixelRatio:o}=t;let r=i;if(!r){const t=document.createElement("canvas");t.width=e*o,t.height=n*o,r=t.getContext("2d")}return new N(r,t)}function B(t){const{width:e,height:n,devicePixelRatio:i}=t,o=new OffscreenCanvas(e*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new N(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function V(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function H(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function G(t){return t>=0||t<0}function Q(t){return G(t.x)&&G(t.y)&&t.t>0}function Y(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function U(t){return t/180*Math.PI}function X(t,e,n,i){const o=U(e||0);n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(o),t.translate(-n.x,-n.y)),i(t),n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(-o),t.translate(-n.x,-n.y))}function q(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Z(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return q({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function J(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}function K(t,e,n){let i=J(t,e)+n;i>2*Math.PI?i-=2*Math.PI:i<0-2*Math.PI&&(i+=2*Math.PI),i<0&&(i+=2*Math.PI);const o=V(t,e);let r=0,l=0;return 0===i?(r=0,l=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,l=0-Math.cos(i)*o):i===Math.PI/2?(r=o,l=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,l=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,l=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,l=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,l=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,l=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,l=0-o),r+=t.x,l+=t.y,{x:r,y:l}}function _(t,e){if((null==e?void 0:e.length)>0){let n=t.x,i=t.y;return e.forEach((t=>{const{x:e,y:o,w:r,h:l,angle:a=0}=t,s=K(q({x:e,y:o,w:r,h:l}),{x:n,y:i},U(a));n=s.x,i=s.y})),{x:n,y:i}}return t}function tt(t,e,n){const{x:i,y:o,w:r,h:l}=t;let a={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+l},u={x:i,y:o+l};if(n&&(n>0||n<0)){const t=U(it(n));a=K(e,a,t),s=K(e,s,t),c=K(e,c,t),u=K(e,u,t)}return[a,s,c,u]}function et(t){const{angle:e=0}=t;return tt(t,q(t),e)}function nt(t,e,n){return[K(t,{x:e[0].x,y:e[0].y},n),K(t,{x:e[1].x,y:e[1].y},n),K(t,{x:e[2].x,y:e[2].y},n),K(t,{x:e[3].x,y:e[3].y},n)]}function it(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function ot(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const l={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(l.angle&&(l.angle>0||l.angle<0)){const t=et(l);if(4===t.length){const e=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];l.x=Math.min(...e),l.y=Math.min(...n),l.w=Math.abs(Math.max(...e)-Math.min(...e)),l.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(l.x,n.x),e=Math.min(l.y,n.y),i=Math.max(l.x+l.w,n.x+n.w),o=Math.max(l.y+l.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=l.x,n.y=l.y,n.w=l.w,n.h=l.h;i=l}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}}function rt(t,e){const n={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=et(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),l=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(l-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function lt(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e<t.length-1&&"group"===(null==o?void 0:o.type))i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}function at(t,e){const n=[];let i=!1;const o=e=>{var r;for(let l=0;l<e.length&&!0!==i;l++){n.push(l);const a=e[l];if(a.uuid===t){i=!0;break}if("group"===a.type&&o((null==(r=null==a?void 0:a.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function st(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,l=e.x,a=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=l&&i<=c&&r>=a}function ct(t){const{x:e,y:n,h:i,w:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e+o,y:n+i},{x:e,y:n+i}]}function ut(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?ct(t):tt(t,q({x:e,y:n,w:i,h:o}),r)}function ht(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:l,y:a,w:s,h:c,angle:u=0}=r[t];let h;if(n+=l,i+=a,0===t){const t={x:n,y:i,w:s,h:c};h=ut({x:l,y:a,w:s,h:c,angle:u}),o.push({center:q(t),angle:u,radian:U(u)})}else{h=ct({x:n,y:i,w:s,h:c});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];h=nt(e,h,n)}const t=Z(h);if(u>0||u<0){h=nt(t,h,U(u))}o.push({center:t,angle:u,radian:U(u)})}e.push(h)}return e}function ft(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[ut(t)];return ht([...n,t])}function dt(t,e){return ft(t,e).pop()||null}function yt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:l,angle:a}=t,{scale:s,offsetTop:c,offsetLeft:u}=n;return{x:i*s+u,y:o*s+c,w:r*s,h:l*s,angle:a}}function gt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:l,offsetLeft:a}=n;return{x:i*r+a,y:o*r+l}}function xt(t,e){const{context2d:n,element:i,viewScaleInfo:o}=e,{angle:r=0}=i,{x:l,y:a,w:s,h:c}=yt(i,{viewScaleInfo:o}),u=et({x:l,y:a,w:s,h:c,angle:r});if(u.length>=2){n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let t=1;t<u.length;t++)n.lineTo(u[t].x,u[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function pt(t,e,n){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y],r=Math.min(...i),l=Math.max(...i),a=Math.min(...o),s=Math.max(...o);return t.x>r&&t.x<l&&t.y>a&&t.y<s||!0===(null==n?void 0:n.includeBorder)&&(t.x===r||t.x===l||t.y===a||t.y===s)}function mt(t,e){const{groupQueue:n}=e,i=dt(t,{groupQueue:n}),o=Y(i[0],i[1]),r=Y(i[1],i[2]),l=Y(i[2],i[3]),a=Y(i[3],i[0]),s=i[0],c=i[1],u=i[2],h=i[3],f=Math.max(s.x,c.x,u.x,h.x),d=Math.max(s.y,c.y,u.y,h.y);return{center:{x:(f+Math.min(s.x,c.x,u.x,h.x))/2,y:(d+Math.min(s.y,c.y,u.y,h.y))/2},topLeft:s,topRight:c,bottomLeft:h,bottomRight:u,top:o,right:r,left:a,bottom:l}}function bt(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakSet,s=function(){return w(h(this,r))};const vt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,wt=/(-?\d+(?:\.\d+)?)/gi;const Mt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Pt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Rt=/^\s*$/,It={};function St(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(It[n[1]]||"/"===t.charAt(t.length-2))&&(e.isVoid=!0),e.name.startsWith("!--"))){const e=t.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==e?t.slice(4,e):""}}const i=new RegExp(Mt);let o=null;for(;o=i.exec(t),null!==o;)if(o[0].trim())if(o[1]){const t=o[1].trim();let n=[t,""];t.indexOf("=")>-1&&(n=t.split("=")),e.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(e.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return e}function $t(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(const n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce($t,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function Et(t,e){let n=2;return void 0!==(null==e?void 0:e.decimalPlaces)&&(null==e?void 0:e.decimalPlaces)>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function At(t){return t[1]!=-1*t[3]||t[4]!=t[0]||t[0]*t[4]-t[3]*t[1]!=1?null:Math.acos(t[0])}const zt="Text Element";function kt(){return{boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"}}function Ot(){return{background:"#D9D9D9"}}const Lt={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Ct(t,e="",n={},i){return Object.keys(t).forEach((o=>{var r;const l=e?`${e}${function(t){return/^\d+$/.test(t)&&!isNaN(Number(t))}(o)?`[${o}]`:`.${o}`}`:o;if(!(null==(r=null==i?void 0:i.ignorePaths)?void 0:r.includes(l))){const e=t[o];!function(t){return"object"==typeof t&&null!==t&&!(t instanceof Date)||Array.isArray(t)}(e)?n[l]=e:Ct(e,(Array.isArray(e),l),n,i)}})),n}function jt(t,e){return"object"!=typeof t||null===t?{"":t}:Ct(t,"",{},e)}function Tt(t){return jt(t,{ignorePaths:["detail.children"]})}function Dt(t){return jt(t)}function Wt(t){return jt(t)}function Nt(t){return Array.isArray(t)?[...t]:t.split(/\.|\[|\]/).filter((t=>""!==t))}function Ft(t,e,n){const i=Nt(e);if(0===i.length)return t;let o=t;if(o)for(let t=0;t<i.length;t++){const e=i[t];if(t===i.length-1){o[e]=n;break}if(o&&(void 0===(null==o?void 0:o[e])||"object"!=typeof(null==o?void 0:o[e])||null===(null==o?void 0:o[e]))){const n=i[t+1],r=/^\d+$/.test(n);o[e]=r?[]:{}}o=null==o?void 0:o[e]}return t}function Bt(t,e){const n=Nt(e);if(0===n.length)return t;let i=t;if(i)for(let t=0;t<n.length;t++){const e=n[t];if(t===n.length-1){delete i[e];break}if(i&&(void 0===(null==i?void 0:i[e])||"object"!=typeof(null==i?void 0:i[e])||null===(null==i?void 0:i[e]))){const o=n[t+1],r=/^\d+$/.test(o);i[e]=r?[]:{}}i=null==i?void 0:i[e]}return t}const Vt=t=>Et(t,{decimalPlaces:4});function Ht(t,e){const n={detail:{}},i={detail:{}},o={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:null,after:null}},{detail:r}=t,{xRatio:l,yRatio:a,maxRatio:s}=e,c=(l+a)/2,{borderWidth:u,borderRadius:h,borderDash:f,shadowOffsetX:d,shadowOffsetY:y,shadowBlur:g}=r;if("number"==typeof u)r.borderWidth=Vt(u*c),n.detail.borderWidth=u,i.detail.borderWidth=r.borderWidth;else if(Array.isArray(r.borderWidth)){const t=u;r.borderWidth=[Vt(t[0]*a),Vt(t[1]*l),Vt(t[2]*a),Vt(t[3]*l)],n.detail.borderWidth=[...t],i.detail.borderWidth=[...r.borderWidth]}if("number"==typeof h)r.borderRadius=Vt(h*c),n.detail.borderRadius=h,i.detail.borderRadius=r.borderRadius;else if(Array.isArray(r.borderRadius)){const t=h;r.borderRadius=[t[0]*l,t[1]*l,t[2]*a,t[3]*a],n.detail.borderRadius=[...t],i.detail.borderRadius=[...r.borderRadius]}return Array.isArray(f)&&(f.forEach(((t,e)=>{r.borderDash[e]=Vt(t*s)})),n.detail.borderDash=[...f],i.detail.borderDash=[...r.borderDash]),"number"==typeof d&&(r.shadowOffsetX=Vt(d*s),n.detail.shadowOffsetX=d,i.detail.shadowOffsetX=r.shadowOffsetX),"number"==typeof y&&(r.shadowOffsetY=Vt(y*s),n.detail.shadowOffsetY=y,i.detail.shadowOffsetY=r.shadowOffsetY),"number"==typeof g&&(r.shadowBlur=Vt(g*s),n.detail.shadowBlur=g,i.detail.shadowBlur=r.shadowBlur),o.content.before=Tt(n),o.content.after=Tt(i),o}function Gt(t,e,n){const{type:i,uuid:o}=t,r=function(t,e){const{xRatio:n,yRatio:i}=e,{uuid:o,x:r,y:l,w:a,h:s}=t;t.x=Vt(r*n),t.y=Vt(l*i),t.w=Vt(a*n),t.h=Vt(s*i);const c={type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:o,before:{x:r,y:l,w:a,h:s},after:{x:t.x,y:t.y,w:t.w,h:t.h}}},u=Ht(t,e);return c.content.before={...c.content.before,...u.content.before},c.content.after={...c.content.after,...u.content.after},c}(t,e),l={...r.content.before,uuid:o},a={...r.content.after,uuid:o};if(null==n||n.content.before.push(l),null==n||n.content.after.push(a),"circle"===i);else if("text"===i){const n=function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,l=(n+i)/2,a={},s={};return o&&o>0&&(t.detail.fontSize=Vt(o*l),a["detail.fontSize"]=o,s["detail.fontSize"]=t.detail.fontSize),r&&r>0&&(t.detail.lineHeight=Vt(r*l),a["detail.lineHeight"]=r,s["detail.lineHeight"]=t.detail.lineHeight),{type:"modifyElement",time:Date.now(),content:{method:"modifyElement",uuid:t.uuid,before:a,after:s}}}(t,e);Object.keys(n.content.before||{}).forEach((t=>{var e;l[t]=null==(e=n.content.before)?void 0:e[t]})),Object.keys(n.content.after||{}).forEach((t=>{var e;a[t]=null==(e=n.content.after)?void 0:e[t]}))}else"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Gt(t,e,n)}))}function Qt(t,e,n){const i={type:"resizeElements",time:Date.now(),content:{method:"modifyElements",before:[],after:[]}},o=t.uuid,r=t.x,l=t.y,a=t.w,s=t.h,c=R.number(e.x)?e.x:t.x,u=R.number(e.y)?e.y:t.y,h=(e.w&&e.w>0?e.w:t.w)||0,f=(e.h&&e.h>0?e.h:t.h)||0,d={uuid:o,x:r,y:l,w:a,h:s},y={uuid:o,x:c,y:u,w:h,h:f};if("deepResize"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=h/t.w,n=f/t.h;if(e===n&&1===e)return i;const o=Math.min(e,n),r=Math.max(e,n);t.w=h,t.h=f;const l={xRatio:e,yRatio:n,minRatio:o,maxRatio:r};"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Gt(t,l,i)}));const a=Ht(t,l);return Object.keys(a.content.before||{}).forEach((t=>{var e;d[t]=null==(e=a.content.before)?void 0:e[t]})),Object.keys(a.content.after||{}).forEach((t=>{var e;y[t]=null==(e=a.content.after)?void 0:e[t]})),i}if("fixed"===(null==n?void 0:n.resizeEffect)){i.content.before.push(d),i.content.after.push(y);const e=c-t.x,n=u-t.y,o=h-t.w;return function(t,e,n){if("group"!==t.type||!Array.isArray(t.detail.children))return;const{moveX:i,moveY:o,moveH:r,moveW:l}=e;let a=0,s=0,c=!1;0===i&&0===o||0===r&&0===l||(c=!0,a=-i,s=-o),!0===c&&t.detail.children.forEach((t=>{const{uuid:e,x:i,y:o}=t,r=i+a,l=o+s,c={uuid:e,x:i,y:o},u={uuid:e,x:r,y:l};t.x=r,t.y=l,null==n||n.content.before.push(c),null==n||n.content.after.push(u)}))}(t,{moveX:e,moveY:n,moveH:f-t.h,moveW:o},i),t.w=h,t.h=f,t.x=c,t.y=u,i}return t.w=h,t.h=f,t.x=c,t.y=u,i.content.before.push(d),i.content.after.push(y),i}function Yt(t,e,n){let i=!1;if(1===e.length){const o=e[0];n.splice(o,0,t),i=!0}else if(e.length>1){let o=n;for(let n=0;n<e.length;n++){const r=o[e[n]];if(n===e.length-1){const r=e[n];o.splice(r,0,t),i=!0}else{if(!(n<e.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Ut(t,e){let n=!1;if(1===t.length){const i=t[0];e.splice(i,1),n=!0}else if(t.length>1){let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e===t.length-1){const o=t[e];i.splice(o,1),n=!0}else{if(!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function Xt(t,e,n){const i=Tt(e),o=["uuid","type"],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Bt(t,e),void 0!==n&&Ft(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Tt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Bt(t,e)}))}return t}const qt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Zt(t){const e=[...t.from],n=[...t.to];if(0===e.length||0===n.length)return null;if(e.length<=n.length)for(let t=0;t<e.length;t++)if(n[t]!==e[t]);else if(t===e.length-1)return null;let i=null;if(e.length>=1&&n.length>=1){if(e.length<=n.length)if(1===e.length)e[0]<n[0]&&(i="up-down");else for(let t=0;t<e.length&&e[t]===n[t];t++)if(e.length===e.length-1){i="up-down";break}if(e.length>=n.length)if(1===n.length)n[0]<e[0]&&(i="down-up");else for(let t=0;t<n.length&&(t===n.length-1&&n[t]<e[t]&&(i="down-up"),e[t]===n[t]);t++);}const o=e.length-1,r=n.length-1;return"up-down"===i&&o>=0?n[o]-=1:"down-up"===i&&r>=0&&(e[r]+=1),{from:e,to:n}}function Jt(t){const e=/([\w-]+)|\[(\d+)\]/g,n=[];let i;for(;null!==(i=e.exec(t));){const t=i[1]||i[2];t&&n.push(t)}return n}function Kt(t,e,n){let i=t;for(let t=0;t<e.length;t++){const o=e[t],r=_t(o),l=t===e.length-1;try{r?te(i,o):ee(i,o)}catch(n){throw new Error(`Structure conflict at path '${e.slice(0,t+1).join(".")}': ${n.message}`)}l?ie(i,o,n):i=ne(i,o,e[t+1])}}function _t(t){return/^\d+$/.test(t)}function te(t,e){if(!Array.isArray(t))throw new Error("Expected array but found "+typeof t);const n=Number(e);n>t.length&&(t.length=n+1)}function ee(t,e){if(Array.isArray(t))throw new Error(`Cannot create object property '${e}' on array`);if("object"!=typeof t||null===t)throw new Error(`Invalid structure for property '${e}'`)}function ne(t,e,n){const i=!!n&&_t(n);if(Array.isArray(t)){const n=Number(e);return t[n]||(t[n]=i?[]:{}),t[n]}return t[e]||(t[e]=i?[]:{}),t[e]}function ie(t,e,n){if(Array.isArray(t)){const i=Number(e);i>=t.length&&(t.length=i+1),t[i]=n}else t[e]=n}return t.Context2D=N,t.EventEmitter=class{constructor(){f(this,i),d(this,i,new Map)}on(t,e){if(h(this,i).has(t)){const n=h(this,i).get(t)||[];null==n||n.push(e),h(this,i).set(t,n)}else h(this,i).set(t,[e])}off(t,e){if(h(this,i).has(t)){const n=h(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}h(this,i).set(t,n||[])}}trigger(t,e){const n=h(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(h(this,i).has(t)){const e=h(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){h(this,i).clear()}},t.Store=class{constructor(t){f(this,a),f(this,o),f(this,r),f(this,l),d(this,r,w(t.defaultStorage)),d(this,o,y(this,a,s).call(this)),d(this,l,t.defaultStatic||{})}set(t,e){h(this,o)[t]=e}get(t){return h(this,o)[t]}setStatic(t,e){h(this,l)[t]=e}getStatic(t){return h(this,l)[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?w(h(this,o)):{...h(this,o)}}clear(){d(this,o,y(this,a,s).call(this))}destroy(){d(this,o,null),d(this,l,null)}},t.calcDistance=V,t.calcElementCenter=q,t.calcElementCenterFromVertexes=Z,t.calcElementListSize=ot,t.calcElementOriginRectInfo=mt,t.calcElementQueueVertexesQueueInGroup=ht,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o,rotateControllerSize:r,rotateControllerPosition:l}=e,a=(i&&i>0?i:8)/o.scale,{x:s,y:c,w:u,h:h,angle:f=0}=t,d=r,y=l,g=[{uuid:p(),x:s,y:c,w:u,h:h,angle:f,type:"group",detail:{children:[]}},...n];let x=0;g.forEach((({angle:t=0})=>{x+=t}));const m=dt(t,{groupQueue:n}),b=dt({x:s,y:c-(y+d/2)/o.scale,h:h+(2*y+d)/o.scale,w:u,angle:f},{groupQueue:[...n]}),v=Y(m[0],m[1]),w=Y(m[1],m[2]),M=Y(m[2],m[3]),P=Y(m[3],m[0]),R=m[0],I=m[1],S=m[2],$=m[3],E=bt(v,{size:a,angle:x}),A=bt(w,{size:a,angle:x}),z=bt(M,{size:a,angle:x}),k=bt(P,{size:a,angle:x}),O=bt(R,{size:a,angle:x}),L=bt(I,{size:a,angle:x}),C=bt($,{size:a,angle:x}),j=bt(S,{size:a,angle:x}),T=ut(O),D=ut(L),W=ut(C),N=ut(j),F=[T[1],D[0],D[3],T[2]],B=[D[3],D[2],N[1],N[0]],V=[W[1],N[0],N[3],W[2]],H=[T[3],T[2],W[1],W[0]],G=ut(E),Q=ut(A),U=ut(z),X=ut(k),Z=Y(b[0],b[1]),J=ut(bt(Z,{size:1.1*r/o.scale,angle:x}));return{originalElementCenter:q(t),originalElementSize:{...t},elementWrapper:m,left:{type:"left",vertexes:H,center:P,size:a},right:{type:"right",vertexes:B,center:w,size:a},top:{type:"top",vertexes:F,center:v,size:a},bottom:{type:"bottom",vertexes:V,center:M,size:a},topLeft:{type:"top-left",vertexes:T,center:R,size:a},topRight:{type:"top-right",vertexes:D,center:I,size:a},bottomLeft:{type:"bottom-left",vertexes:W,center:$,size:a},bottomRight:{type:"bottom-right",vertexes:N,center:S,size:a},leftMiddle:{type:"left-middle",vertexes:X,center:P,size:a},rightMiddle:{type:"right-middle",vertexes:Q,center:w,size:a},topMiddle:{type:"top-middle",vertexes:G,center:v,size:a},bottomMiddle:{type:"bottom-middle",vertexes:U,center:M,size:a},rotate:{type:"rotate",vertexes:J,center:Z,size:r}}},t.calcElementVertexesInGroup=dt,t.calcElementVertexesQueueInGroup=ft,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=mt(t,{groupQueue:n}),{center:l,top:a,bottom:s,left:c,right:u,topLeft:h,topRight:f,bottomLeft:d,bottomRight:y}=r,g={center:gt(l,{viewScaleInfo:i}),topLeft:gt(h,{viewScaleInfo:i}),topRight:gt(f,{viewScaleInfo:i}),bottomLeft:gt(d,{viewScaleInfo:i}),bottomRight:gt(y,{viewScaleInfo:i}),top:gt(a,{viewScaleInfo:i}),right:gt(u,{viewScaleInfo:i}),left:gt(c,{viewScaleInfo:i}),bottom:gt(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),e=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),n=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),i=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),o={x:g.center.x,y:g.center.y},r={x:n,y:i},l={x:t,y:i},a={x:t,y:e},s={x:n,y:e},c=Y(r,l),u=Y(s,a),h=Y(r,s);return{center:o,topLeft:r,topRight:l,bottomLeft:s,bottomRight:a,top:c,right:Y(l,a),left:h,bottom:u}}return g},t.calcElementsContextSize=rt,t.calcElementsViewInfo=function(t,e,n){const i=rt(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,o=n&&n>0?n:8,{x:r,y:l,w:a,h:s}=yt(t,{viewScaleInfo:i}),c=q({x:r,y:l,w:a,h:s}),u={x:c.x,y:l},h={x:r+a,y:c.y},f={x:c.x,y:l+s},d={x:r,y:c.y},y={x:r,y:l},g={x:r+a,y:l},x={x:r+a,y:l+s},p={x:r,y:l+s},m=bt(u,{size:o,angle:0}),b=bt(h,{size:o,angle:0}),v=bt(f,{size:o,angle:0}),w=bt(d,{size:o,angle:0}),M=bt(y,{size:o,angle:0}),P=bt(g,{size:o,angle:0}),R=bt(p,{size:o,angle:0}),I=bt(x,{size:o,angle:0}),S=ut(M),$=ut(P),E=ut(R),A=ut(I),z=[S[1],$[0],$[3],S[2]],k=[$[3],$[2],A[1],A[0]],O=[E[1],A[0],A[3],E[2]],L=[S[3],S[2],E[1],E[0]],C=ut(m),j=ut(b),T=ut(v);return{left:{type:"left",vertexes:L,center:d,size:o},right:{type:"right",vertexes:k,center:h,size:o},top:{type:"top",vertexes:z,center:u,size:o},bottom:{type:"bottom",vertexes:O,center:f,size:o},topLeft:{type:"top-left",vertexes:S,center:y,size:o},topRight:{type:"top-right",vertexes:$,center:g,size:o},bottomLeft:{type:"bottom-left",vertexes:E,center:p,size:o},bottomRight:{type:"bottom-right",vertexes:A,center:x,size:o},leftMiddle:{type:"left-middle",vertexes:ut(w),center:d,size:o},rightMiddle:{type:"right-middle",vertexes:j,center:h,size:o},topMiddle:{type:"top-middle",vertexes:C,center:u,size:o},bottomMiddle:{type:"bottom-middle",vertexes:T,center:f,size:o}}},t.calcPointMoveElementInGroup=function(t,e,n){let i=e.x-t.x,o=e.y-t.y;const r=[];if(n.forEach((t=>{const{x:e,y:n,w:i,h:o,angle:l=0}=t;r.push({x:e,y:n,w:i,h:o,angle:0-l})})),(null==n?void 0:n.length)>0){const n=_(t,r),l=_(e,r);i=l.x-n.x,o=l.y-n.y}return{moveX:i,moveY:o}},t.calcRadian=function(t,e,n){const i=J(t,e),o=J(t,n);return null!==o&&null!==i?o-i:0},t.calcResultMovePosition=Zt,t.calcRevertMovePosition=function(t){const e=Zt(t);return e?{from:[...e.to],to:[...e.from]}:e},t.calcSpeed=function(t,e){return V(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o}=t.detail;const{borderDash:r}=t.detail,l=Array.isArray(r)&&r.length>0,{boxSizing:a=Lt.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:c,y:u,w:h,h:f}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*i;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let y=0;return"number"==typeof s&&(y=(s||0)*i),"border-box"!==a||l?"content-box"===a?(c=t.x-y/2,u=t.y-y/2,h=t.w+y,f=t.h+y):(c=t.x,u=t.y,h=t.w,f=t.h):(c=t.x+y/2,u=t.y+y/2,h=t.w-y,f=t.h-y),h=Math.max(h,1),f=Math.max(f,1),d=d.map((t=>Math.min(t,h/2,f/2))),{x:c,y:u,w:h,h:f,radiusList:d}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:l,scale:a}=i,{width:s,height:c}=o;e=0-r+s/a/2,n=0-l+c/a/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,l,a,s,c,u,h,f,d;let y=0,g=0,x=1,p=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,m=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,b=(null==(a=null==(l=null==t?void 0:t.elements)?void 0:l[0])?void 0:a.w)||0,v=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:w,height:M}=e.viewSizeInfo;if(T.layout(t.layout)&&"hidden"===(null==(h=null==(u=t.layout)?void 0:u.detail)?void 0:h.overflow)?(p=t.layout.x,m=t.layout.y,b=t.layout.w||0,v=t.layout.h||0):t.elements.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=et(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,p),i=Math.min(e.y,m),o=Math.max(e.x+e.w,p+b),r=Math.max(e.y+e.h,m+v);p=n,m=i,b=Math.abs(o-n),v=Math.abs(r-i)})),(null==t?void 0:t.layout)&&T.layout(t.layout)){const{x:e,y:n,w:i,h:o}=t.layout;"hidden"===(null==(d=null==(f=t.layout)?void 0:f.detail)?void 0:d.overflow)?(p=Math.min(p,e),m=Math.min(m,n),b=Math.min(b,i),v=Math.min(v,o)):(p=Math.min(p,e),m=Math.min(m,n),b=Math.max(b,i),v=Math.max(v,o))}if(b>0&&v>0){const t=Et(w/b,{decimalPlaces:4}),e=Et(M/v,{decimalPlaces:4});x=Math.min(t,e,1),y=(b*x-w)/2/x+p,g=(v*x-M)/2/x+m}return{offsetX:Et(y,{decimalPlaces:0}),offsetY:Et(g,{decimalPlaces:0}),scale:x}},t.calcViewElementSize=yt,t.calcViewPointSize=gt,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:l,height:a,contextWidth:s,contextHeight:c}=r,u=0-i*n,h=0-o*n;return{scale:n,offsetLeft:u,offsetTop:h,offsetRight:l-(s*n+u/n),offsetBottom:a-(c*n+h/n)}},t.calcViewVertexes=function(t,e){return[gt(t[0],e),gt(t[1],e),gt(t[2],e),gt(t[3],e)]},t.calcVisiableViewSize=function(t){var e,n;const i=ot(t.elements);return t.layout&&("hidden"===(null==(n=null==(e=t.layout)?void 0:e.detail)?void 0:n.overflow)?(i.x=t.layout.x,i.y=t.layout.y,i.w=t.layout.w,i.h=t.layout.h):(i.x=Math.min(i.x,t.layout.x),i.y=Math.min(i.y,t.layout.y),i.w=Math.max(i.w,t.layout.w),i.h=Math.max(i.h,t.layout.h))),i},t.check=W,t.checkRectIntersect=st,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=x[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if(1===(null==t?void 0:t.stops.length))e=t.stops[0].color;else if("linear-gradient"===(null==t?void 0:t.type)){const n=[];"number"==typeof t.angle?n.push(`${t.angle}deg`):n.push("180deg"),Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`radial-gradient(circle, ${n.join(", ")})`}return e},t.colorToLinearGradientCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("radial-gradient"===(null==t?void 0:t.type)||"linear-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.length>0&&(t.stops.forEach(((e,i)=>{n.push(`${e.color} ${100*e.offset}%`),i===t.stops.length-1&&e.offset<1&&n.push(`${e.color} ${100*e.offset}%`)})),e=`linear-gradient(90deg, ${n.join(", ")})`)}return e},t.compose=function(t){return function(e,n){return function i(o){let r=t[o];o===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,i.bind(null,o+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=(null==e?void 0:e.type)||"image/png";return(null==e?void 0:e.radio)&&(null==e?void 0:e.radio)>0&&(null==e?void 0:e.radio)<=1&&(n=null==e?void 0:e.radio),new Promise(((e,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:t,height:o}=r,l=t*n,a=o*n;let s=document.createElement("canvas");s.width=l,s.height=a;s.getContext("2d").drawImage(r,0,0,l,a);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=b,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o}=e,r={width:n,height:i,devicePixelRatio:o},l=t.getContext("2d"),a=B(r),s=B(r),c=B(r),u=F({ctx:l,...r}),h=B(r);return{underlayContext:c,viewContext:a,overlayContext:s,boardContext:u,tempContext:h,drawView:()=>{const{width:t,height:e}=a.$getSize();u.clearRect(0,0,t,e),u.drawImage(c.canvas,0,0,t,e),u.drawImage(a.canvas,0,0,t,e),u.drawImage(s.canvas,0,0,t,e),c.clearRect(0,0,t,e),a.clearRect(0,0,t,e),s.clearRect(0,0,t,e)}}},t.createContext2D=F,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=200,r=200;if(e){const{viewScaleInfo:l,viewSizeInfo:a}=e,{scale:s,offsetLeft:c,offsetTop:u}=l,{width:h,height:f}=a,d=h/4,y=f/4;o=200>=d?d/s:200/s,r=200>=y?y/s:200/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/12*2),n=(0-c+h/2-o*s/2)/s,i=(0-u+f/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};return{text:zt,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontSize:t.w/12,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===t?o={svg:'<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'}:"image"===t?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===t&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{uuid:p(),...i,...e,type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=B,t.createUUID=p,t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{t(...i),n=-1}),e)}},t.deepClone=w,t.deepCloneData=function(t){const{elements:e,...n}=t;return{...w(n),elements:e.map((t=>M(t)))}},t.deepCloneElement=M,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Ut(at(t,e),e)},t.deleteElementInListByPosition=Ut,t.downloadFileFromText=function(t,e){const{fileName:n}=e,i=function(t){const e=(new TextEncoder).encode(t),n=new Blob([e],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(t);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,o=t.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},t.elementToBoxInfo=function(t){const{x:e,y:n,w:i,h:o,detail:r}=t,{borderWidth:l,borderRadius:a,boxSizing:s}=r;let c=0,u=0,h=0,f=0,d=0,y=0,g=0,x=0;"number"==typeof l&&l>0?(c=l,u=l,h=l,f=l):Array.isArray(l)&&(c=T.positiveNum(l[0])?l[0]:0,u=T.positiveNum(l[1])?l[0]:0,h=T.positiveNum(l[2])?l[0]:0,f=T.positiveNum(l[3])?l[0]:0),"number"==typeof a&&a>0?(d=a,y=a,g=a,x=a):Array.isArray(a)&&(d=T.positiveNum(a[0])?a[0]:0,y=T.positiveNum(a[0])?a[0]:0,g=T.positiveNum(a[0])?a[0]:0,x=T.positiveNum(a[0])?a[0]:0);const p={x:e,y:n},m={x:e+i,y:n},b={x:e+i,y:n+o},v={x:e,y:n+o},w={x:e,y:n+d},M={x:e+d,y:n},P={x:e+i-y,y:n},R={x:e+i,y:n+y},I={x:e+i,y:n+o-x},S={x:e+i-x,y:n+o},$={x:e+g,y:n+o},E={x:e,y:n+o-g};let A={...p},z={...m},k={...b},O={...v},L={...w},C={...M},j={...P},D={...R},W={...I},N={...S},F={...$},B={...E},V={...p},H={...m},G={...b},Q={...v},Y={...w},U={...M},X={...P},q={...R},Z={...I},J={...S},K={...$},_={...E};return"border-box"===s?(V={x:V.x+f,y:V.y+c},H={x:H.x-u,y:H.y+c},G={x:G.x-u,y:G.y-h},Q={x:Q.x+f,y:Q.y-h},Y={x:Y.x+f,y:Y.y+c},U={x:U.x+f,y:U.y+c},X={x:X.x-u,y:X.y+c},q={x:q.x-u,y:q.y+c},Z={x:Z.x-u,y:Z.y-h},J={x:J.x-u,y:J.y-h},K={x:K.x+f,y:K.y-h},_={x:_.x+f,y:_.y-h}):"content-box"===s?(A={x:A.x-f,y:A.y-c},z={x:z.x+u,y:z.y-c},k={x:k.x+u,y:k.y+h},O={x:O.x-f,y:O.y+h},L={x:L.x-f,y:L.y-c},C={x:C.x-f,y:C.y-c},j={x:j.x+u,y:j.y-c},D={x:D.x+u,y:D.y-c},W={x:W.x+u,y:W.y+h},N={x:N.x+u,y:N.y+h},F={x:F.x-f,y:F.y+h},B={x:B.x-f,y:B.y+h}):(V={x:V.x+f/2,y:V.y+c/2},H={x:H.x-u/2,y:H.y+c/2},G={x:G.x-u/2,y:G.y-h/2},Q={x:Q.x+f/2,y:Q.y-h/2},Y={x:Y.x+f/2,y:Y.y+c/2},U={x:U.x+f/2,y:U.y+c/2},X={x:X.x-u/2,y:X.y+c/2},q={x:q.x-u/2,y:q.y+c/2},Z={x:Z.x-u/2,y:Z.y-h/2},J={x:J.x-u/2,y:J.y-h/2},K={x:K.x+f/2,y:K.y-h/2},_={x:_.x+f/2,y:_.y-h/2},A={x:A.x-f/2,y:A.y-c/2},z={x:z.x+u/2,y:z.y-c/2},k={x:k.x+u/2,y:k.y+h/2},O={x:O.x-f/2,y:O.y+h/2},L={x:L.x-f/2,y:L.y-c/2},C={x:C.x-f/2,y:C.y-c/2},j={x:j.x+u/2,y:j.y-c/2},D={x:D.x+u/2,y:D.y-c/2},W={x:W.x+u/2,y:W.y+h/2},N={x:N.x+u/2,y:N.y+h/2},F={x:F.x-f/2,y:F.y+h/2},B={x:B.x-f/2,y:B.y+h/2}),{btw:c,brw:u,bbw:h,blw:f,btlr:d,btrr:y,bblr:g,bbrr:x,p0:p,p1:m,p2:b,p3:v,p0s:w,p0e:M,p1s:P,p1e:R,p2s:I,p2e:S,p3s:$,p3e:E,op0:A,op1:z,op2:k,op3:O,op0s:L,op0e:C,op1s:j,op1e:D,op2s:W,op2e:N,op3s:F,op3e:B,ip0:V,ip1:H,ip2:G,ip3:Q,ip0s:Y,ip0e:U,ip1s:X,ip1e:q,ip2s:Z,ip2e:J,ip3s:K,ip3e:_}},t.enhanceFontFamliy=function(t){return[t,...qt].join(", ")},t.equalPoint=H,t.equalTouchPoint=function(t,e){return!0===H(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=w(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,l;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(v(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const e=b(i,t.uuid);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source))n[e]={type:"svg",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(l=o[e])?void 0:l.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,r(t.detail.children)}}))};return r(i.elements),i.assets=n,i},t.filterElementAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.detail.src:"svg"===t.type?i=t.detail.svg:"html"===t.type&&(i=t.detail.html),"string"!=typeof i||v(i)||(e=b(i,t.uuid),n={type:t.type,value:i},"image"===t.type?t.detail.src=e:"svg"===t.type?t.detail.svg=e:"html"===t.type&&(t.detail.html=e)),{element:t,assetId:e,assetItem:n}},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const l=n[r];if(l.uuid===e){o=l;break}if(!o&&"group"===l.type){const n=t(e,(null==(i=null==l?void 0:l.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=lt,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const l=i[r];t.includes(l.uuid)?n.push(l):"group"===l.type&&e((null==(o=null==l?void 0:l.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=lt(t,e);i&&n.push(i)})),n},t.flatElementList=function(t){const e=[],n=[],i=t=>{if(!function(t){var e;if(["rect","circle"].includes(t.type)){const e=t.detail;if(!e.background&&!e.borderWidth)return!1;if("transparent"===e.background&&!e.borderWidth)return!1}if(["group"].includes(t.type)){const e=t.detail||{},{children:n}=e;if(!(n.length>0||e.background||e.borderWidth))return!1;if(!(n.length>0||"transparent"!==e.background||e.borderWidth))return!1}if("text"===t.type&&!t.detail.text)return!1;if("image"===t.type&&!t.detail.src)return!1;if("html"===t.type&&!t.detail.html)return!1;if("svg"===t.type&&!t.detail.svg)return!1;if("path"===t.type){const n=t.detail;if(!((null==(e=null==n?void 0:n.commands)?void 0:e.length)>0))return!1}return!0}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:o}=t;const{w:r,h:l,angle:a=0}=t;let s=0;if(n.forEach((t=>{i+=t.x,o+=t.y,s+=t.angle||0})),s=it(s),0===s)return{x:i,y:o,w:r,h:l,angle:a};s+=t.angle||0,s=it(s);const c=dt(t,{groupQueue:n}),u=K(Z(c),c[0],U(0-s));return i=u.x,o=u.y,{x:i,y:o,w:r,h:l,angle:s}}(t,{groupQueue:n}),o={...t,...i};e.push(o)},o=t=>{var e;if(!0!==(null==(e=null==t?void 0:t.operations)?void 0:e.invisible))if("group"===t.type){const{detail:e}=t,{children:r,...l}=e;i({...t,detail:{...l,children:[]}}),n.push(t),r.forEach((t=>{o(t)})),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];o(n)}return e},t.flatObject=jt,t.formatNumber=Et,t.generateHTML=function(t){return t.reduce((function(t,e){return t+$t("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.get=function(t,e,n){if(!e)return;const i=Nt(e);let o=t;for(const t of i){if(null==o)return n;o=o[t]}return void 0!==o?o:n},t.getCenterFromTwoPoints=Y,t.getDefaultElementDetailConfig=kt,t.getDefaultElementRectDetail=Ot,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&v(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&v(t.detail.svg)?e.push(t.detail.svg):"html"===t.type&&t.detail.html?e.push(t.detail.html):"group"===t.type&&Array.isArray(t.detail.children)&&n(t.detail.children)}))};return n(t),e},t.getElementPositionFromList=at,t.getElementPositionMapFromList=function(t,e){const n=[],i={};let o=!1;const r=e=>{var l;for(let a=0;a<e.length&&!0!==o;a++){n.push(a);const s=e[a];if(t.includes(s.uuid)){if(i[s.uuid]=[...n],Object.keys(i).length===t.length){o=!0;break}}else"group"===s.type&&r((null==(l=null==s?void 0:s.detail)?void 0:l.children)||[]);if(o)break;n.pop()}};return r(e),i},t.getElementRotateVertexes=tt,t.getElementSize=function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return{x:e,y:n,w:i,h:o,angle:r}},t.getElementVertexes=ct,t.getGroupQueueByElementPosition=function(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=o[e[t]];if("group"!==(null==r?void 0:r.type)||!Array.isArray(null==(n=null==r?void 0:r.detail)?void 0:n.children))return null;i.push(r),o=r.detail.children}return i},t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let l=0;l<i.length;l++){const a=i[l];if(a.uuid===e){r=a;break}if(!r&&"group"===a.type){n.push(a);const i=t(e,(null==(o=null==a?void 0:a.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:l,viewScaleInfo:a,viewSizeInfo:s,groupQueue:c}=e,u={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let e=c.length-1;e>=0;e--){let o=0,l=0,s=0;for(let t=0;t<=e;t++)o+=c[t].x,l+=c[t].y,s+=c[t].angle||0;const h=c[e];if(h&&"group"===h.type&&Array.isArray(null==(n=h.detail)?void 0:n.children))for(let n=0;n<h.detail.children.length;n++){const f=h.detail.children[n];if(!0!==(null==(i=null==f?void 0:f.operations)?void 0:i.invisible)){if(!f)break;if(xt(t,{context2d:r,element:{x:o+f.x,y:l+f.y,w:f.w,h:f.h,angle:s+(f.angle||0)},viewScaleInfo:a})){u.element=f,(e<c.length-1||"group"!==f.type)&&(u.groupQueueIndex=e);break}}}if(u.element)break}if(u.element)return u;for(let e=l.elements.length-1;e>=0;e--){const n=l.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&xt(t,{context2d:r,element:n,viewScaleInfo:a})){u.index=e,u.element=n;break}}return u},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:null==e?void 0:e.scale,offsetTop:null==e?void 0:e.offsetTop,offsetBottom:null==e?void 0:e.offsetBottom,offsetLeft:null==e?void 0:e.offsetLeft,offsetRight:null==e?void 0:e.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:null==e?void 0:e.width,height:null==e?void 0:e.height,contextWidth:null==e?void 0:e.contextWidth,contextHeight:null==e?void 0:e.contextHeight}},t.groupElementsByPosition=function(t,e){if(e.length>1){let n=!0,i=[];for(let t=1;t<e.length;t++){const o=e[t-1],r=e[t];if(!(o.length>0&&r.length>0)){n=!1;break}if(o.length!==r.length){n=!1;break}const l=[...o],a=[...r],s=l.pop(),c=a.pop();1===t&&"number"==typeof s&&s>=0&&i.push(s),"number"==typeof c&&c>=0&&i.push(c)}if(!0!==n)return console.error("[idraw]: The grouped elements are not siblings!"),t;i.sort(((t,e)=>t-e));const o=[...e[0]].splice(0,e[0].length-1),r=[],l=[...o,i[0]];for(let e=0;e<i.length;e++){const n=lt([...o,i[e]],t);n&&r.push(n)}const a=ot(r);for(let t=0;t<r.length;t++){const e=r[t];e&&(e.x-=a.x,e.y-=a.y)}for(let e=i.length-1;e>=0;e--){Ut([...o,i[e]],t)}Yt({name:"Group",uuid:p(),type:"group",...a,detail:{children:r}},l,t)}return t},t.insertElementToListByPosition=Yt,t.is=T,t.isAssetId=v,t.isColorStr=g,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:l}=t,{x:a,y:s,w:c,h:u}=yt(t,{viewScaleInfo:i}),h=et({x:a,y:s,w:c,h:u,angle:l}),f={x:0,y:0,w:o,h:r},d=Math.min(h[0].x,h[1].x,h[2].x,h[3].x),y=Math.min(h[0].y,h[1].y,h[2].y,h[3].y);return st(f,{x:d,y:y,w:Math.max(h[0].x,h[1].x,h[2].x,h[3].x)-d,h:Math.max(h[0].y,h[1].y,h[2].y,h[3].y)-y})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isSameElementSize=function(t,e){return t.x===e.x&&t.y===e.y&&t.h===e.h&&t.w===e.w&&it(t.angle||0)===it(e.angle||0)},t.isViewPointInElement=xt,t.isViewPointInElementSize=function(t,e,n){return pt(t,ut(e),n)},t.isViewPointInVertexes=pt,t.istype=R,t.limitAngle=it,t.loadHTML=async function(t,e){t=t.replace(/\&/gi,"&amp;");const n=await function(t,e){const{width:n,height:i}=e;return new Promise(((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),l=new FileReader;l.readAsDataURL(r),l.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},l.onerror=function(t){o(t)}}))}(t,e);return await S(n)},t.loadImage=S,t.loadSVG=async function(t){const e=await function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return await S(e)},t.matrixToAngle=function(t){const e=At(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=At,t.merge=function t(e,n){const i=e;for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"==typeof n[e]&&null!==n[e]&&"object"==typeof i[e]&&null!==i[e]?i[e]=t(i[e],n[e]):i[e]=n[e]);return e},t.mergeElement=Xt,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeGlobal=function(t,e,n){const i=Wt(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Bt(t,e),void 0!==n&&Ft(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Wt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Bt(t,e)}))}return t},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.mergeLayout=function(t,e,n){const i=Dt(e),o=[],r=Object.keys(i);if(r.forEach((e=>{if(!o.includes(e)){const n=i[e];Bt(t,e),void 0!==n&&Ft(t,e,n)}})),!0===(null==n?void 0:n.strict)){const e=Dt(t);Object.keys(e).forEach((e=>{o.includes(e)||r.includes(e)||Bt(t,e)}))}return t},t.moveElementPosition=function(t,e){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{elements:t,from:n,to:i};if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return{elements:t,from:n,to:i};const o=lt(n,t);if(o){if(!Yt(o,i,t))return{elements:t,from:n,to:i};let e=-1,r=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(r=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){r=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(r=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(r=!0),n[t]===i[t]);t++);}if(!0===r)for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),Ut(n,t)}return{elements:t,from:n,to:i}},t.omit=function(t,e){const n={...t};for(const t of e)delete n[t];return n},t.originRectInfoToRangeRectInfo=function(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},l={x:i,y:o},a={x:e,y:o},s={x:e,y:n},c={x:i,y:n},u=Y(l,a),h=Y(c,s),f=Y(l,c);return{center:r,topLeft:l,topRight:a,bottomLeft:c,bottomRight:s,top:u,right:Y(a,s),left:f,bottom:h}},t.parseAngleToRadian=U,t.parseFileToBase64=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsDataURL(t)}))},t.parseFileToText=function(t){return new Promise((function(e,n){let i=new FileReader;i.addEventListener("load",(function(){e(i.result),i=null})),i.addEventListener("error",(function(t){n(t),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsText(t)}))},t.parseHTML=function(t){const e=[],n=[];let i,o=-1;return t.replace(Pt,((r,l)=>{const a="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=l+r.length,u=t.charAt(c);let h;if(s){const t=St(r);return o<0?(e.push(t),r):(h=n[o],h.children.push(t),r)}if(a){if(o++,i=St(r),!i.isVoid&&u&&"<"!==u){const e=t.slice(c,t.indexOf("<",c));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===o&&e.push(i),h=n[o-1],h&&h.children.push(i),n[o]=i}if((!a||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==u&&u)){h=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);Rt.test(r)&&(r=" "),(i>-1&&o+h.length>=0||" "!==r)&&r.trim()&&h.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:r.trim()})}return r})),e},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGPath=function(t){const e=[];return t.replace(vt,((t,n,i)=>{const o=i.match(wt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let o=document.createElement("input");o.type="file",e&&(o.accept=e),o.addEventListener("change",(function(){var t;const e=null==(t=o.files)?void 0:t[0];n({file:e}),o=null})),o.addEventListener("error",(function(t){"function"==typeof i&&i(t),o=null})),o.click()},t.resizeEffectGroupElement=Qt,t.rotateByCenter=X,t.rotateElement=function(t,e,n){const i=q(e);X(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=et,t.rotatePoint=K,t.rotatePointInGroup=_,t.rotateVertexes=nt,t.set=Ft,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=w(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=b(e,t.uuid);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=b(e,t.uuid);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=b(e,t.uuid);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.toFlattenElement=Tt,t.toFlattenGlobal=Wt,t.toFlattenLayout=Dt,t.toPath=Nt,t.unflatObject=function(t){const e={};for(const[n,i]of Object.entries(t)){Kt(e,Jt(n),i)}return e},t.ungroupElementsByPosition=function(t,e){var n;const i=lt(e,t);i&&"group"===(null==i?void 0:i.type)&&Array.isArray(null==(n=null==i?void 0:i.detail)?void 0:n.children)||console.error("[idraw]: The ungrouped element is not a group element!");const o=[...e].splice(0,e.length-1),r=e[e.length-1],{x:l,y:a}=i;return Ut(e,t),i.detail.children.forEach(((e,n)=>{e.x+=l,e.y+=a;Yt(e,[...o,r+n],t)})),t},t.updateElementInList=function t(e,n,i){var o,r,l;let a=null;for(let s=0;s<i.length;s++){const c=i[s];if(c.uuid===e){"group"===c.type&&(null==(o=c.operations)?void 0:o.resizeEffect)&&Qt(c,{...n},{resizeEffect:null==(r=c.operations)?void 0:r.resizeEffect}),Xt(c,n),a=c;break}"group"===c.type&&(a=t(e,n,(null==(l=null==c?void 0:c.detail)?void 0:l.children)||[]))}return a},t.updateElementInListByPosition=function(t,e,n,i){var o,r;const l=lt(t,n);return l&&("group"===l.type&&(null==(o=l.operations)?void 0:o.resizeEffect)&&Qt(l,{...e},{resizeEffect:null==(r=l.operations)?void 0:r.resizeEffect}),Xt(l,e,i)),l},t.vaildPoint=Q,t.vaildTouchPoint=function(t){return!0===Q(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,l=e/i.scale,a=n.x,s=n.y;return{moveX:a-a*l+(o*l-o),moveY:s-s*l+(r*l-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:l,height:a,contextWidth:s,contextHeight:c}=o;let u=i.offsetLeft,h=i.offsetRight,f=i.offsetTop,d=i.offsetBottom;return u+=e,f+=n,h=l-(s*r+u),d=a-(c*r+f),{scale:r,offsetTop:f,offsetLeft:u,offsetRight:h,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idraw/util",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",