@idraw/util 0.4.0-beta.16 → 0.4.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,8 +16,8 @@ export { Context2D } from './lib/context2d';
16
16
  export { rotateElement, parseRadianToAngle, parseAngleToRadian, rotateElementVertexes, getElementRotateVertexes, calcElementCenter, calcElementCenterFromVertexes, rotatePointInGroup, limitAngle, calcRadian } from './lib/rotate';
17
17
  export { getSelectedElementUUIDs, validateElements, calcElementsContextSize, calcElementsViewInfo, getElemenetsAssetIds, findElementFromList, findElementsFromList, findElementFromListByPosition, findElementQueueFromListByPosition, findElementsFromListByPositions, getGroupQueueFromList, getGroupQueueByElementPosition, getElementSize, mergeElementAsset, filterElementAsset, isResourceElement, getElementPositionFromList, calcElementListSize } from './lib/element';
18
18
  export { checkRectIntersect } from './lib/rect';
19
- export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, calcElementViewRectInfoMap } from './lib/view-calc';
20
- export { sortElementsViewVisiableInfoMap } from './lib/view-visible';
19
+ export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, calcElementViewRectInfoMap, originRectInfoToRangeRectInfo } from './lib/view-calc';
20
+ export { sortElementsViewVisiableInfoMap, calcVisibleOriginCanvasRectInfo, updateViewVisibleInfoMapStatus } from './lib/view-visible';
21
21
  export { rotatePoint, rotateVertexes, rotateByCenter } from './lib/rotate';
22
22
  export { getElementVertexes, calcElementVertexesInGroup, calcElementVertexesQueueInGroup, calcElementQueueVertexesQueueInGroup } from './lib/vertex';
23
23
  export { calcElementSizeController } from './lib/controller';
package/dist/esm/index.js CHANGED
@@ -16,8 +16,8 @@ export { Context2D } from './lib/context2d';
16
16
  export { rotateElement, parseRadianToAngle, parseAngleToRadian, rotateElementVertexes, getElementRotateVertexes, calcElementCenter, calcElementCenterFromVertexes, rotatePointInGroup, limitAngle, calcRadian } from './lib/rotate';
17
17
  export { getSelectedElementUUIDs, validateElements, calcElementsContextSize, calcElementsViewInfo, getElemenetsAssetIds, findElementFromList, findElementsFromList, findElementFromListByPosition, findElementQueueFromListByPosition, findElementsFromListByPositions, getGroupQueueFromList, getGroupQueueByElementPosition, getElementSize, mergeElementAsset, filterElementAsset, isResourceElement, getElementPositionFromList, calcElementListSize } from './lib/element';
18
18
  export { checkRectIntersect } from './lib/rect';
19
- export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, calcElementViewRectInfoMap } from './lib/view-calc';
20
- export { sortElementsViewVisiableInfoMap } from './lib/view-visible';
19
+ export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, calcElementViewRectInfoMap, originRectInfoToRangeRectInfo } from './lib/view-calc';
20
+ export { sortElementsViewVisiableInfoMap, calcVisibleOriginCanvasRectInfo, updateViewVisibleInfoMapStatus } from './lib/view-visible';
21
21
  export { rotatePoint, rotateVertexes, rotateByCenter } from './lib/rotate';
22
22
  export { getElementVertexes, calcElementVertexesInGroup, calcElementVertexesQueueInGroup, calcElementQueueVertexesQueueInGroup } from './lib/vertex';
23
23
  export { calcElementSizeController } from './lib/controller';
@@ -266,7 +266,8 @@ export function getGroupQueueByElementPosition(elements, position) {
266
266
  let currentElements = elements;
267
267
  if (position.length > 1) {
268
268
  for (let i = 0; i < position.length - 1; i++) {
269
- const group = currentElements[i];
269
+ const index = position[i];
270
+ const group = currentElements[index];
270
271
  if ((group === null || group === void 0 ? void 0 : group.type) === 'group' && Array.isArray((_a = group === null || group === void 0 ? void 0 : group.detail) === null || _a === void 0 ? void 0 : _a.children)) {
271
272
  groupQueue.push(group);
272
273
  currentElements = group.detail.children;
@@ -1,11 +1,11 @@
1
1
  export function checkRectIntersect(rect1, rect2) {
2
- const react1MinX = rect1.x;
3
- const react1MinY = rect1.y;
4
- const react1MaxX = rect1.x + rect1.w;
5
- const react1MaxY = rect1.y + rect1.h;
6
- const react2MinX = rect2.x;
7
- const react2MinY = rect2.y;
8
- const react2MaxX = rect2.x + rect2.w;
9
- const react2MaxY = rect2.y + rect2.h;
10
- return react1MinX <= react2MaxX && react1MaxX >= react2MinX && react1MinY <= react2MaxY && react1MaxY >= react2MinY;
2
+ const rect1MinX = rect1.x;
3
+ const rect1MinY = rect1.y;
4
+ const rect1MaxX = rect1.x + rect1.w;
5
+ const rect1MaxY = rect1.y + rect1.h;
6
+ const rect2MinX = rect2.x;
7
+ const rect2MinY = rect2.y;
8
+ const rect2MaxX = rect2.x + rect2.w;
9
+ const rect2MaxY = rect2.y + rect2.h;
10
+ return rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY;
11
11
  }
@@ -5,7 +5,9 @@ export declare class Store<T extends Record<string | symbol, any> = Record<strin
5
5
  });
6
6
  set<K extends keyof T>(name: K, value: T[K]): void;
7
7
  get<K extends keyof T>(name: K): T[K];
8
- getSnapshot(): T;
8
+ getSnapshot(opts?: {
9
+ deepClone?: boolean;
10
+ }): T;
9
11
  clear(): void;
10
12
  destroy(): void;
11
13
  }
@@ -25,8 +25,11 @@ export class Store {
25
25
  get(name) {
26
26
  return __classPrivateFieldGet(this, _Store_temp, "f")[name];
27
27
  }
28
- getSnapshot() {
29
- return __classPrivateFieldGet(this, _Store_temp, "f");
28
+ getSnapshot(opts) {
29
+ if ((opts === null || opts === void 0 ? void 0 : opts.deepClone) === true) {
30
+ return deepClone(__classPrivateFieldGet(this, _Store_temp, "f"));
31
+ }
32
+ return Object.assign({}, __classPrivateFieldGet(this, _Store_temp, "f"));
30
33
  }
31
34
  clear() {
32
35
  __classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
@@ -56,6 +56,7 @@ export declare function isElementInView(elem: ElementSize, opts: {
56
56
  export declare function calcElementOriginRectInfo(elemSize: ElementSize, opts: {
57
57
  groupQueue: Element<'group'>[];
58
58
  }): ViewRectInfo;
59
+ export declare function originRectInfoToRangeRectInfo(originRectInfo: ViewRectInfo): ViewRectInfo;
59
60
  export declare function calcElementViewRectInfo(elemSize: ElementSize, opts: {
60
61
  groupQueue: Element<'group'>[];
61
62
  viewScaleInfo: ViewScaleInfo;
@@ -218,6 +218,33 @@ export function calcElementOriginRectInfo(elemSize, opts) {
218
218
  };
219
219
  return rectInfo;
220
220
  }
221
+ export function originRectInfoToRangeRectInfo(originRectInfo) {
222
+ const rangeMaxX = Math.max(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
223
+ const rangeMaxY = Math.max(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
224
+ const rangeMinX = Math.min(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
225
+ const rangeMinY = Math.min(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
226
+ const rangeCenter = { x: originRectInfo.center.x, y: originRectInfo.center.y };
227
+ const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
228
+ const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
229
+ const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
230
+ const rangeBottomLeft = { x: rangeMinX, y: rangeMaxY };
231
+ const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
232
+ const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
233
+ const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
234
+ const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
235
+ const rangeRectInfo = {
236
+ center: rangeCenter,
237
+ topLeft: rangeTopLeft,
238
+ topRight: rangeTopRight,
239
+ bottomLeft: rangeBottomLeft,
240
+ bottomRight: rangeBottomRight,
241
+ top: rangeTop,
242
+ right: rangeRight,
243
+ left: rangeLeft,
244
+ bottom: rangeBottom
245
+ };
246
+ return rangeRectInfo;
247
+ }
221
248
  export function calcElementViewRectInfo(elemSize, opts) {
222
249
  const { groupQueue, viewScaleInfo, range } = opts;
223
250
  const originRectInfo = calcElementOriginRectInfo(elemSize, { groupQueue });
@@ -303,7 +330,6 @@ export function calcElementViewRectInfoMap(elemSize, opts) {
303
330
  };
304
331
  return {
305
332
  originRectInfo,
306
- viewRectInfo,
307
333
  rangeRectInfo
308
334
  };
309
335
  }
@@ -1,7 +1,7 @@
1
1
  import { rotateElementVertexes } from './rotate';
2
2
  import { formatNumber } from './number';
3
3
  export function calcViewCenterContent(data, opts) {
4
- var _a, _b, _c, _d, _e, _f, _g, _h;
4
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5
5
  let offsetX = 0;
6
6
  let offsetY = 0;
7
7
  let scale = 1;
@@ -10,34 +10,42 @@ export function calcViewCenterContent(data, opts) {
10
10
  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;
11
11
  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;
12
12
  const { width, height } = opts.viewSizeInfo;
13
- data.elements.forEach((elem) => {
14
- const elemSize = {
15
- x: elem.x,
16
- y: elem.y,
17
- w: elem.w,
18
- h: elem.h,
19
- angle: elem.angle
20
- };
21
- if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
22
- const ves = rotateElementVertexes(elemSize);
23
- if (ves.length === 4) {
24
- const xList = [ves[0].x, ves[1].x, ves[2].x, ves[3].x];
25
- const yList = [ves[0].y, ves[1].y, ves[2].y, ves[3].y];
26
- elemSize.x = Math.min(...xList);
27
- elemSize.y = Math.min(...yList);
28
- elemSize.w = Math.abs(Math.max(...xList) - Math.min(...xList));
29
- elemSize.h = Math.abs(Math.max(...yList) - Math.min(...yList));
13
+ if (data.layout && ((_k = (_j = data.layout) === null || _j === void 0 ? void 0 : _j.detail) === null || _k === void 0 ? void 0 : _k.overflow) === 'hidden') {
14
+ contentX = 0;
15
+ contentY = 0;
16
+ contentW = data.layout.w || 0;
17
+ contentH = data.layout.h || 0;
18
+ }
19
+ else {
20
+ data.elements.forEach((elem) => {
21
+ const elemSize = {
22
+ x: elem.x,
23
+ y: elem.y,
24
+ w: elem.w,
25
+ h: elem.h,
26
+ angle: elem.angle
27
+ };
28
+ if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
29
+ const ves = rotateElementVertexes(elemSize);
30
+ if (ves.length === 4) {
31
+ const xList = [ves[0].x, ves[1].x, ves[2].x, ves[3].x];
32
+ const yList = [ves[0].y, ves[1].y, ves[2].y, ves[3].y];
33
+ elemSize.x = Math.min(...xList);
34
+ elemSize.y = Math.min(...yList);
35
+ elemSize.w = Math.abs(Math.max(...xList) - Math.min(...xList));
36
+ elemSize.h = Math.abs(Math.max(...yList) - Math.min(...yList));
37
+ }
30
38
  }
31
- }
32
- const areaStartX = Math.min(elemSize.x, contentX);
33
- const areaStartY = Math.min(elemSize.y, contentY);
34
- const areaEndX = Math.max(elemSize.x + elemSize.w, contentX + contentW);
35
- const areaEndY = Math.max(elemSize.y + elemSize.h, contentY + contentH);
36
- contentX = areaStartX;
37
- contentY = areaStartY;
38
- contentW = Math.abs(areaEndX - areaStartX);
39
- contentH = Math.abs(areaEndY - areaStartY);
40
- });
39
+ const areaStartX = Math.min(elemSize.x, contentX);
40
+ const areaStartY = Math.min(elemSize.y, contentY);
41
+ const areaEndX = Math.max(elemSize.x + elemSize.w, contentX + contentW);
42
+ const areaEndY = Math.max(elemSize.y + elemSize.h, contentY + contentH);
43
+ contentX = areaStartX;
44
+ contentY = areaStartY;
45
+ contentW = Math.abs(areaEndX - areaStartX);
46
+ contentH = Math.abs(areaEndY - areaStartY);
47
+ });
48
+ }
41
49
  if (contentW > 0 && contentH > 0) {
42
50
  const scaleW = formatNumber(width / contentW, { decimalPlaces: 4 });
43
51
  const scaleH = formatNumber(height / contentH, { decimalPlaces: 4 });
@@ -1,2 +1,21 @@
1
- import { Elements, ViewVisibleInfoMap } from '@idraw/types';
2
- export declare function sortElementsViewVisiableInfoMap(elements: Elements): ViewVisibleInfoMap;
1
+ import { Elements, ViewScaleInfo, ViewSizeInfo, ViewRectInfo, ViewVisibleInfoMap } from '@idraw/types';
2
+ export declare function sortElementsViewVisiableInfoMap(elements: Elements, opts: {
3
+ viewScaleInfo: ViewScaleInfo;
4
+ viewSizeInfo: ViewSizeInfo;
5
+ }): {
6
+ viewVisibleInfoMap: ViewVisibleInfoMap;
7
+ visibleCount: number;
8
+ invisibleCount: number;
9
+ };
10
+ export declare function updateViewVisibleInfoMapStatus(viewVisibleInfoMap: ViewVisibleInfoMap, opts: {
11
+ viewScaleInfo: ViewScaleInfo;
12
+ viewSizeInfo: ViewSizeInfo;
13
+ }): {
14
+ viewVisibleInfoMap: ViewVisibleInfoMap;
15
+ visibleCount: number;
16
+ invisibleCount: number;
17
+ };
18
+ export declare function calcVisibleOriginCanvasRectInfo(opts: {
19
+ viewScaleInfo: ViewScaleInfo;
20
+ viewSizeInfo: ViewSizeInfo;
21
+ }): ViewRectInfo;
@@ -1,12 +1,12 @@
1
- import { calcElementOriginRectInfo } from './view-calc';
1
+ import { calcElementOriginRectInfo, originRectInfoToRangeRectInfo } from './view-calc';
2
2
  import { getGroupQueueByElementPosition } from './element';
3
- export function sortElementsViewVisiableInfoMap(elements) {
3
+ import { calcElementCenter } from './rotate';
4
+ import { is } from './is';
5
+ export function sortElementsViewVisiableInfoMap(elements, opts) {
4
6
  const visibleInfoMap = {};
5
7
  const currentPosition = [];
6
8
  const _walk = (elem) => {
7
9
  const baseInfo = {
8
- viewRectInfo: null,
9
- rangeRectInfo: null,
10
10
  isVisibleInView: true,
11
11
  isGroup: elem.type === 'group',
12
12
  position: [...currentPosition]
@@ -17,17 +17,14 @@ export function sortElementsViewVisiableInfoMap(elements) {
17
17
  groupQueue: groupQueue || []
18
18
  });
19
19
  visibleInfoMap[elem.uuid] = Object.assign(Object.assign({}, baseInfo), {
20
- originRectInfo: originRectInfo
20
+ originRectInfo: originRectInfo,
21
+ rangeRectInfo: is.angle(elem.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo
21
22
  });
22
23
  if (elem.type === 'group') {
23
24
  elem.detail.children.forEach((ele, i) => {
24
- if (ele.type === 'group') {
25
- currentPosition.push(i);
26
- }
25
+ currentPosition.push(i);
27
26
  _walk(ele);
28
- if (ele.type === 'group') {
29
- currentPosition.pop();
30
- }
27
+ currentPosition.pop();
31
28
  });
32
29
  }
33
30
  };
@@ -36,5 +33,61 @@ export function sortElementsViewVisiableInfoMap(elements) {
36
33
  _walk(elem);
37
34
  currentPosition.pop();
38
35
  });
39
- return visibleInfoMap;
36
+ return updateViewVisibleInfoMapStatus(visibleInfoMap, opts);
37
+ }
38
+ function isRangeRectInfoCollide(info1, info2) {
39
+ const rect1MinX = Math.min(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
40
+ const rect1MaxX = Math.max(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
41
+ const rect1MinY = Math.min(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
42
+ const rect1MaxY = Math.max(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
43
+ const rect2MinX = Math.min(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
44
+ const rect2MaxX = Math.max(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
45
+ const rect2MinY = Math.min(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
46
+ const rect2MaxY = Math.max(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
47
+ if ((rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY) ||
48
+ (rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY && rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY)) {
49
+ return true;
50
+ }
51
+ return false;
52
+ }
53
+ export function updateViewVisibleInfoMapStatus(viewVisibleInfoMap, opts) {
54
+ const canvasRectInfo = calcVisibleOriginCanvasRectInfo(opts);
55
+ let visibleCount = 0;
56
+ let invisibleCount = 0;
57
+ Object.keys(viewVisibleInfoMap).forEach((uuid) => {
58
+ const info = viewVisibleInfoMap[uuid];
59
+ info.isVisibleInView = isRangeRectInfoCollide(info.rangeRectInfo, canvasRectInfo);
60
+ info.isVisibleInView ? visibleCount++ : invisibleCount++;
61
+ });
62
+ return { viewVisibleInfoMap, visibleCount, invisibleCount };
63
+ }
64
+ export function calcVisibleOriginCanvasRectInfo(opts) {
65
+ const { viewScaleInfo, viewSizeInfo } = opts;
66
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
67
+ const { width, height } = viewSizeInfo;
68
+ const x = 0 - offsetLeft / scale;
69
+ const y = 0 - offsetTop / scale;
70
+ const w = width / scale;
71
+ const h = height / scale;
72
+ const center = calcElementCenter({ x, y, w, h });
73
+ const topLeft = { x, y };
74
+ const topRight = { x: x + w, y };
75
+ const bottomLeft = { x, y: y + h };
76
+ const bottomRight = { x: x + w, y: y + h };
77
+ const left = { x, y: center.y };
78
+ const top = { x: center.x, y };
79
+ const right = { x: x + w, y: center.y };
80
+ const bottom = { x: center.x, y: y + h };
81
+ const rectInfo = {
82
+ center,
83
+ topLeft,
84
+ topRight,
85
+ bottomLeft,
86
+ bottomRight,
87
+ left,
88
+ top,
89
+ right,
90
+ bottom
91
+ };
92
+ return rectInfo;
40
93
  }
@@ -1408,8 +1408,11 @@ var __privateMethod = (obj, member, method) => {
1408
1408
  get(name) {
1409
1409
  return __privateGet(this, _temp)[name];
1410
1410
  }
1411
- getSnapshot() {
1412
- return __privateGet(this, _temp);
1411
+ getSnapshot(opts) {
1412
+ if ((opts == null ? void 0 : opts.deepClone) === true) {
1413
+ return deepClone(__privateGet(this, _temp));
1414
+ }
1415
+ return { ...__privateGet(this, _temp) };
1413
1416
  }
1414
1417
  clear() {
1415
1418
  __privateSet(this, _temp, __privateMethod(this, _createTempStorage, createTempStorage_fn).call(this));
@@ -1892,7 +1895,8 @@ var __privateMethod = (obj, member, method) => {
1892
1895
  let currentElements = elements;
1893
1896
  if (position.length > 1) {
1894
1897
  for (let i = 0; i < position.length - 1; i++) {
1895
- const group = currentElements[i];
1898
+ const index = position[i];
1899
+ const group = currentElements[index];
1896
1900
  if ((group == null ? void 0 : group.type) === "group" && Array.isArray((_a = group == null ? void 0 : group.detail) == null ? void 0 : _a.children)) {
1897
1901
  groupQueue.push(group);
1898
1902
  currentElements = group.detail.children;
@@ -2039,15 +2043,15 @@ var __privateMethod = (obj, member, method) => {
2039
2043
  return result;
2040
2044
  }
2041
2045
  function checkRectIntersect(rect1, rect2) {
2042
- const react1MinX = rect1.x;
2043
- const react1MinY = rect1.y;
2044
- const react1MaxX = rect1.x + rect1.w;
2045
- const react1MaxY = rect1.y + rect1.h;
2046
- const react2MinX = rect2.x;
2047
- const react2MinY = rect2.y;
2048
- const react2MaxX = rect2.x + rect2.w;
2049
- const react2MaxY = rect2.y + rect2.h;
2050
- return react1MinX <= react2MaxX && react1MaxX >= react2MinX && react1MinY <= react2MaxY && react1MaxY >= react2MinY;
2046
+ const rect1MinX = rect1.x;
2047
+ const rect1MinY = rect1.y;
2048
+ const rect1MaxX = rect1.x + rect1.w;
2049
+ const rect1MaxY = rect1.y + rect1.h;
2050
+ const rect2MinX = rect2.x;
2051
+ const rect2MinY = rect2.y;
2052
+ const rect2MaxX = rect2.x + rect2.w;
2053
+ const rect2MaxY = rect2.y + rect2.h;
2054
+ return rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY;
2051
2055
  }
2052
2056
  function getElementVertexes(elemSize) {
2053
2057
  const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
@@ -2335,6 +2339,33 @@ var __privateMethod = (obj, member, method) => {
2335
2339
  };
2336
2340
  return rectInfo;
2337
2341
  }
2342
+ function originRectInfoToRangeRectInfo(originRectInfo) {
2343
+ const rangeMaxX = Math.max(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
2344
+ const rangeMaxY = Math.max(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
2345
+ const rangeMinX = Math.min(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
2346
+ const rangeMinY = Math.min(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
2347
+ const rangeCenter = { x: originRectInfo.center.x, y: originRectInfo.center.y };
2348
+ const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
2349
+ const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
2350
+ const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
2351
+ const rangeBottomLeft = { x: rangeMinX, y: rangeMaxY };
2352
+ const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
2353
+ const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
2354
+ const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
2355
+ const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
2356
+ const rangeRectInfo = {
2357
+ center: rangeCenter,
2358
+ topLeft: rangeTopLeft,
2359
+ topRight: rangeTopRight,
2360
+ bottomLeft: rangeBottomLeft,
2361
+ bottomRight: rangeBottomRight,
2362
+ top: rangeTop,
2363
+ right: rangeRight,
2364
+ left: rangeLeft,
2365
+ bottom: rangeBottom
2366
+ };
2367
+ return rangeRectInfo;
2368
+ }
2338
2369
  function calcElementViewRectInfo(elemSize, opts) {
2339
2370
  const { groupQueue, viewScaleInfo, range } = opts;
2340
2371
  const originRectInfo = calcElementOriginRectInfo(elemSize, { groupQueue });
@@ -2420,17 +2451,15 @@ var __privateMethod = (obj, member, method) => {
2420
2451
  };
2421
2452
  return {
2422
2453
  originRectInfo,
2423
- viewRectInfo,
2454
+ // viewRectInfo,
2424
2455
  rangeRectInfo
2425
2456
  };
2426
2457
  }
2427
- function sortElementsViewVisiableInfoMap(elements) {
2458
+ function sortElementsViewVisiableInfoMap(elements, opts) {
2428
2459
  const visibleInfoMap = {};
2429
2460
  const currentPosition = [];
2430
2461
  const _walk = (elem) => {
2431
2462
  const baseInfo = {
2432
- viewRectInfo: null,
2433
- rangeRectInfo: null,
2434
2463
  isVisibleInView: true,
2435
2464
  isGroup: elem.type === "group",
2436
2465
  position: [...currentPosition]
@@ -2443,18 +2472,15 @@ var __privateMethod = (obj, member, method) => {
2443
2472
  visibleInfoMap[elem.uuid] = {
2444
2473
  ...baseInfo,
2445
2474
  ...{
2446
- originRectInfo
2475
+ originRectInfo,
2476
+ rangeRectInfo: is.angle(elem.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo
2447
2477
  }
2448
2478
  };
2449
2479
  if (elem.type === "group") {
2450
2480
  elem.detail.children.forEach((ele, i) => {
2451
- if (ele.type === "group") {
2452
- currentPosition.push(i);
2453
- }
2481
+ currentPosition.push(i);
2454
2482
  _walk(ele);
2455
- if (ele.type === "group") {
2456
- currentPosition.pop();
2457
- }
2483
+ currentPosition.pop();
2458
2484
  });
2459
2485
  }
2460
2486
  };
@@ -2463,7 +2489,62 @@ var __privateMethod = (obj, member, method) => {
2463
2489
  _walk(elem);
2464
2490
  currentPosition.pop();
2465
2491
  });
2466
- return visibleInfoMap;
2492
+ return updateViewVisibleInfoMapStatus(visibleInfoMap, opts);
2493
+ }
2494
+ function isRangeRectInfoCollide(info1, info2) {
2495
+ const rect1MinX = Math.min(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
2496
+ const rect1MaxX = Math.max(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
2497
+ const rect1MinY = Math.min(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
2498
+ const rect1MaxY = Math.max(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
2499
+ const rect2MinX = Math.min(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
2500
+ const rect2MaxX = Math.max(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
2501
+ const rect2MinY = Math.min(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
2502
+ const rect2MaxY = Math.max(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
2503
+ if (rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY || rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY && rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY) {
2504
+ return true;
2505
+ }
2506
+ return false;
2507
+ }
2508
+ function updateViewVisibleInfoMapStatus(viewVisibleInfoMap, opts) {
2509
+ const canvasRectInfo = calcVisibleOriginCanvasRectInfo(opts);
2510
+ let visibleCount = 0;
2511
+ let invisibleCount = 0;
2512
+ Object.keys(viewVisibleInfoMap).forEach((uuid) => {
2513
+ const info = viewVisibleInfoMap[uuid];
2514
+ info.isVisibleInView = isRangeRectInfoCollide(info.rangeRectInfo, canvasRectInfo);
2515
+ info.isVisibleInView ? visibleCount++ : invisibleCount++;
2516
+ });
2517
+ return { viewVisibleInfoMap, visibleCount, invisibleCount };
2518
+ }
2519
+ function calcVisibleOriginCanvasRectInfo(opts) {
2520
+ const { viewScaleInfo, viewSizeInfo } = opts;
2521
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
2522
+ const { width, height } = viewSizeInfo;
2523
+ const x2 = 0 - offsetLeft / scale;
2524
+ const y2 = 0 - offsetTop / scale;
2525
+ const w2 = width / scale;
2526
+ const h2 = height / scale;
2527
+ const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
2528
+ const topLeft = { x: x2, y: y2 };
2529
+ const topRight = { x: x2 + w2, y: y2 };
2530
+ const bottomLeft = { x: x2, y: y2 + h2 };
2531
+ const bottomRight = { x: x2 + w2, y: y2 + h2 };
2532
+ const left = { x: x2, y: center.y };
2533
+ const top = { x: center.x, y: y2 };
2534
+ const right = { x: x2 + w2, y: center.y };
2535
+ const bottom = { x: center.x, y: y2 + h2 };
2536
+ const rectInfo = {
2537
+ center,
2538
+ topLeft,
2539
+ topRight,
2540
+ bottomLeft,
2541
+ bottomRight,
2542
+ left,
2543
+ top,
2544
+ right,
2545
+ bottom
2546
+ };
2547
+ return rectInfo;
2467
2548
  }
2468
2549
  function createControllerElementSizeFromCenter(center, opts) {
2469
2550
  const { x: x2, y: y2 } = center;
@@ -3295,7 +3376,7 @@ var __privateMethod = (obj, member, method) => {
3295
3376
  return elem;
3296
3377
  }
3297
3378
  function calcViewCenterContent(data, opts) {
3298
- var _a, _b, _c, _d, _e, _f, _g, _h;
3379
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3299
3380
  let offsetX = 0;
3300
3381
  let offsetY = 0;
3301
3382
  let scale = 1;
@@ -3304,34 +3385,41 @@ var __privateMethod = (obj, member, method) => {
3304
3385
  let contentW = ((_f = (_e = data == null ? void 0 : data.elements) == null ? void 0 : _e[0]) == null ? void 0 : _f.w) || 0;
3305
3386
  let contentH = ((_h = (_g = data == null ? void 0 : data.elements) == null ? void 0 : _g[0]) == null ? void 0 : _h.h) || 0;
3306
3387
  const { width, height } = opts.viewSizeInfo;
3307
- data.elements.forEach((elem) => {
3308
- const elemSize = {
3309
- x: elem.x,
3310
- y: elem.y,
3311
- w: elem.w,
3312
- h: elem.h,
3313
- angle: elem.angle
3314
- };
3315
- if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
3316
- const ves = rotateElementVertexes(elemSize);
3317
- if (ves.length === 4) {
3318
- const xList = [ves[0].x, ves[1].x, ves[2].x, ves[3].x];
3319
- const yList = [ves[0].y, ves[1].y, ves[2].y, ves[3].y];
3320
- elemSize.x = Math.min(...xList);
3321
- elemSize.y = Math.min(...yList);
3322
- elemSize.w = Math.abs(Math.max(...xList) - Math.min(...xList));
3323
- elemSize.h = Math.abs(Math.max(...yList) - Math.min(...yList));
3388
+ if (data.layout && ((_j = (_i = data.layout) == null ? void 0 : _i.detail) == null ? void 0 : _j.overflow) === "hidden") {
3389
+ contentX = 0;
3390
+ contentY = 0;
3391
+ contentW = data.layout.w || 0;
3392
+ contentH = data.layout.h || 0;
3393
+ } else {
3394
+ data.elements.forEach((elem) => {
3395
+ const elemSize = {
3396
+ x: elem.x,
3397
+ y: elem.y,
3398
+ w: elem.w,
3399
+ h: elem.h,
3400
+ angle: elem.angle
3401
+ };
3402
+ if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {
3403
+ const ves = rotateElementVertexes(elemSize);
3404
+ if (ves.length === 4) {
3405
+ const xList = [ves[0].x, ves[1].x, ves[2].x, ves[3].x];
3406
+ const yList = [ves[0].y, ves[1].y, ves[2].y, ves[3].y];
3407
+ elemSize.x = Math.min(...xList);
3408
+ elemSize.y = Math.min(...yList);
3409
+ elemSize.w = Math.abs(Math.max(...xList) - Math.min(...xList));
3410
+ elemSize.h = Math.abs(Math.max(...yList) - Math.min(...yList));
3411
+ }
3324
3412
  }
3325
- }
3326
- const areaStartX = Math.min(elemSize.x, contentX);
3327
- const areaStartY = Math.min(elemSize.y, contentY);
3328
- const areaEndX = Math.max(elemSize.x + elemSize.w, contentX + contentW);
3329
- const areaEndY = Math.max(elemSize.y + elemSize.h, contentY + contentH);
3330
- contentX = areaStartX;
3331
- contentY = areaStartY;
3332
- contentW = Math.abs(areaEndX - areaStartX);
3333
- contentH = Math.abs(areaEndY - areaStartY);
3334
- });
3413
+ const areaStartX = Math.min(elemSize.x, contentX);
3414
+ const areaStartY = Math.min(elemSize.y, contentY);
3415
+ const areaEndX = Math.max(elemSize.x + elemSize.w, contentX + contentW);
3416
+ const areaEndY = Math.max(elemSize.y + elemSize.h, contentY + contentH);
3417
+ contentX = areaStartX;
3418
+ contentY = areaStartY;
3419
+ contentW = Math.abs(areaEndX - areaStartX);
3420
+ contentH = Math.abs(areaEndY - areaStartY);
3421
+ });
3422
+ }
3335
3423
  if (contentW > 0 && contentH > 0) {
3336
3424
  const scaleW = formatNumber(width / contentW, { decimalPlaces: 4 });
3337
3425
  const scaleH = formatNumber(height / contentH, { decimalPlaces: 4 });
@@ -3475,6 +3563,7 @@ var __privateMethod = (obj, member, method) => {
3475
3563
  exports.calcViewPointSize = calcViewPointSize;
3476
3564
  exports.calcViewScaleInfo = calcViewScaleInfo;
3477
3565
  exports.calcViewVertexes = calcViewVertexes;
3566
+ exports.calcVisibleOriginCanvasRectInfo = calcVisibleOriginCanvasRectInfo;
3478
3567
  exports.check = check;
3479
3568
  exports.checkRectIntersect = checkRectIntersect;
3480
3569
  exports.colorNameToHex = colorNameToHex;
@@ -3542,6 +3631,7 @@ var __privateMethod = (obj, member, method) => {
3542
3631
  exports.mergeHexColorAlpha = mergeHexColorAlpha;
3543
3632
  exports.modifyElement = modifyElement;
3544
3633
  exports.moveElementPosition = moveElementPosition;
3634
+ exports.originRectInfoToRangeRectInfo = originRectInfoToRangeRectInfo;
3545
3635
  exports.parseAngleToRadian = parseAngleToRadian;
3546
3636
  exports.parseFileToBase64 = parseFileToBase64;
3547
3637
  exports.parseFileToText = parseFileToText;
@@ -3562,6 +3652,7 @@ var __privateMethod = (obj, member, method) => {
3562
3652
  exports.toColorHexStr = toColorHexStr;
3563
3653
  exports.updateElementInList = updateElementInList;
3564
3654
  exports.updateElementInListByPosition = updateElementInListByPosition;
3655
+ exports.updateViewVisibleInfoMapStatus = updateViewVisibleInfoMapStatus;
3565
3656
  exports.vaildPoint = vaildPoint;
3566
3657
  exports.vaildTouchPoint = vaildTouchPoint;
3567
3658
  exports.validateElements = validateElements;
@@ -1 +1 @@
1
- var iDrawUtil=function(t){"use strict";var e,n,i,o,r,a,l,s=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},c=(t,e,n)=>(s(t,e,"read from private field"),n?n.call(t):e.get(t)),h=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},u=(t,e,n,i)=>(s(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),f=(t,e,n)=>(s(t,e,"access private method"),n);function d(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 g={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 m(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function p(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n)*t.charCodeAt(n)*n*n;return e.toString(16).substring(0,4)}function y(t){const e=t.length,n=Math.floor(e/2),i=t.substring(0,4).padEnd(4,"0"),o=t.substring(0,4).padEnd(4,"0");return`@assets/${p(e.toString(16).padEnd(4,i))}${p(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${p(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${p(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${p(t.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${p(t.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${p(t.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${p(o.padEnd(4,i).padEnd(4,o))}`}function x(t){return/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.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 v(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const b={type(t,e){const n=v(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===v(t),json:t=>"Object"===v(t),function:t=>"Function"===v(t),asyncFunction:t=>"AsyncFunction"===v(t),boolean:t=>"Boolean"===v(t),string:t=>"String"===v(t),number:t=>"Number"===v(t),undefined:t=>"Undefined"===v(t),null:t=>"Null"===v(t),promise:t=>"Promise"===v(t)};const{Image:M}=window;function P(t){return new Promise(((e,n)=>{const i=new M;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function R(t){return"number"==typeof t&&(t>0||t<=0)}function I(t){return"number"==typeof t&&t>=0}function S(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function $(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const E={x:function(t){return R(t)},y:function(t){return R(t)},w:I,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:R,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return I(t)},borderRadius:function(t){return R(t)&&t>=0},color:function(t){return d(t)},imageSrc:function(t){return $(t)||S(t)},imageURL:S,imageBase64:$,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 R(t)&&t>0},lineHeight:function(t){return R(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 R(t)&&t>0}};function A(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!E.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!E.number(n))&&!(t.hasOwnProperty("borderWidth")&&!E.number(i)))}const C={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(E.x(e)&&E.y(n)&&E.w(i)&&E.h(o)&&E.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:h}=t;return!!E.text(e)&&(!!E.color(n)&&(!!E.fontSize(i)&&(!(t.hasOwnProperty("background")&&!E.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!E.fontWeight(l))&&(!(t.hasOwnProperty("lineHeight")&&!E.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!E.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!E.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!E.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!E.color(h))&&!!A(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!E.color(e))&&!!A(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!E.color(e))&&(!(t.hasOwnProperty("borderColor")&&!E.color(n))&&!(t.hasOwnProperty("borderWidth")&&!E.number(i)))},imageDesc:function(t){const{src:e}=t;return!!E.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!E.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!E.html(e)}};class L{constructor(t,i){h(this,e,void 0),h(this,n,void 0),u(this,e,t),u(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/c(this,n).devicePixelRatio}$doPixelRatio(t){return c(this,n).devicePixelRatio*t}$getContext(){return c(this,e)}$setContext(t){u(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"}`),c(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 c(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:a}=t,{canvas:l}=c(this,e);l.width=i*r,l.height=o*r,u(this,n,{...c(this,n),devicePixelRatio:r}),!0===a&&(l.style.width=`${i}px`,l.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=c(this,n),{width:i,height:o}=c(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return c(this,e).canvas}get fillStyle(){return c(this,e).fillStyle}set fillStyle(t){c(this,e).fillStyle=t}get strokeStyle(){return c(this,e).strokeStyle}set strokeStyle(t){c(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(c(this,e).lineWidth)}set lineWidth(t){c(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return c(this,e).textAlign}set textAlign(t){c(this,e).textAlign=t}get textBaseline(){return c(this,e).textBaseline}set textBaseline(t){c(this,e).textBaseline=t}get globalAlpha(){return c(this,e).globalAlpha}set globalAlpha(t){c(this,e).globalAlpha=t}get shadowColor(){return c(this,e).shadowColor}set shadowColor(t){c(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(c(this,e).shadowOffsetX)}set shadowOffsetX(t){c(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(c(this,e).shadowOffsetY)}set shadowOffsetY(t){c(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(c(this,e).shadowBlur)}set shadowBlur(t){c(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return c(this,e).lineCap}set lineCap(t){c(this,e).lineCap=t}get globalCompositeOperation(){return c(this,e).globalCompositeOperation}set globalCompositeOperation(t){c(this,e).globalCompositeOperation=t}fill(...t){return c(this,e).fill(...t)}arc(t,n,i,o,r,a){return c(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a)}rect(t,n,i,o){return c(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return c(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return c(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return c(this,e).beginPath()}closePath(){return c(this,e).closePath()}lineTo(t,n){return c(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return c(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return c(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return c(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return c(this,e).setLineDash(n)}stroke(t){return t?c(this,e).stroke(t):c(this,e).stroke()}translate(t,n){return c(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return c(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],a=t[4],l=t[t.length-4],s=t[t.length-3],h=t[t.length-2],u=t[t.length-1];return 9===t.length?c(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u)):c(this,e).drawImage(n,this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u))}createPattern(t,n){return c(this,e).createPattern(t,n)}measureText(t){return c(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){c(this,e).save()}restore(){c(this,e).restore()}scale(t,n){c(this,e).scale(t,n)}circle(t,n,i,o,r,a,l,s){c(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,l,s)}isPointInPath(t,n){return c(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return c(this,e).clip(...t)}setTransform(t,n,i,o,r,a){return c(this,e).setTransform(t,n,i,o,r,a)}getTransform(){return c(this,e).getTransform()}createLinearGradient(t,n,i,o){return c(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,a){return c(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(t,n,i){return c(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function k(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 L(r,t)}function z(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 L(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function O(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 T(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function D(t){return t>=0||t<0}function j(t){return D(t.x)&&D(t.y)&&t.t>0}function W(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 F(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 H(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function N(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 H({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 B(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 Q(t,e,n){let i=B(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=O(t,e);let r=0,a=0;return 0===i?(r=0,a=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,a=0-Math.cos(i)*o):i===Math.PI/2?(r=o,a=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,a=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,a=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,a=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,a=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,a=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,a=0-o),r+=t.x,a+=t.y,{x:r,y:a}}function G(t,e,n){const{x:i,y:o,w:r,h:a}=t;let l={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+a},h={x:i,y:o+a};if(n&&(n>0||n<0)){const t=V(X(n));l=Q(e,l,t),s=Q(e,s,t),c=Q(e,c,t),h=Q(e,h,t)}return[l,s,c,h]}function U(t){const{angle:e=0}=t;return G(t,H(t),e)}function Y(t,e,n){return[Q(t,{x:e[0].x,y:e[0].y},n),Q(t,{x:e[1].x,y:e[1].y},n),Q(t,{x:e[2].x,y:e[2].y},n),Q(t,{x:e[3].x,y:e[3].y},n)]}function X(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function q(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=U(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),a=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(a-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 Z(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const e=o[t];if("group"!==(null==e?void 0:e.type)||!Array.isArray(null==(n=null==e?void 0:e.detail)?void 0:n.children))return null;i.push(e),o=e.detail.children}return i}function J(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"===o.type)i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}function K(t,e){const n=[];let i=!1;const o=e=>{var r;for(let a=0;a<e.length&&!0!==i;a++){n.push(a);const l=e[a];if(l.uuid===t){i=!0;break}if("group"===l.type&&o((null==(r=null==l?void 0:l.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function _(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,a=e.x,l=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=a&&i<=c&&r>=l}function tt(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 et(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?tt(t):G(t,H({x:e,y:n,w:i,h:o,angle:r}),r)}function nt(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:l,w:s,h:c,angle:h=0}=r[t];let u;if(n+=a,i+=l,0===t){const t={x:n,y:i,w:s,h:c,angle:h};u=et({x:a,y:l,w:s,h:c,angle:h}),o.push({center:H(t),angle:h,radian:V(h)})}else{u=tt({x:n,y:i,w:s,h:c,angle:h});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];u=Y(e,u,n)}const t=N(u);if(h>0||h<0){u=Y(t,u,V(h))}o.push({center:t,angle:h,radian:V(h)})}e.push(u)}return e}function it(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[et(t)];return nt([...n,t])}function ot(t,e){return it(t,e).pop()||null}function rt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:a,angle:l}=t,{scale:s,offsetTop:c,offsetLeft:h}=n;return{x:i*s+h,y:o*s+c,w:r*s,h:a*s,angle:l}}function at(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function lt(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:l,y:s,w:c,h:h}=rt(i,{viewScaleInfo:o,viewSizeInfo:r}),u=U({x:l,y:s,w:c,h:h,angle:a});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 st(t,e){const{groupQueue:n}=e,i=ot(t,{groupQueue:n}),o=W(i[0],i[1]),r=W(i[1],i[2]),a=W(i[2],i[3]),l=W(i[3],i[0]),s=i[0],c=i[1],h=i[2],u=i[3],f=Math.max(s.x,c.x,h.x,u.x),d=Math.max(s.y,c.y,h.y,u.y);return{center:{x:(f+Math.min(s.x,c.x,h.x,u.x))/2,y:(d+Math.min(s.y,c.y,h.y,u.y))/2},topLeft:s,topRight:c,bottomLeft:u,bottomRight:h,top:o,right:r,left:l,bottom:a}}function ct(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,a=new WeakSet,l=function(){return w(c(this,r))};const ht=/([astvzqmhlc])([^astvzqmhlc]*)/gi,ut=/(-?\d+(?:\.\d+)?)/gi;const ft=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,dt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,gt=/^\s*$/,mt={};function pt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(mt[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(ft);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 yt(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(let n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(yt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function xt(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 wt(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 vt="Text Element";function bt(){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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"}}function Mt(){return{background:"#D9D9D9"}}const Pt={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const Rt=t=>xt(t,{decimalPlaces:4});function It(t,e){const{detail:n}=t,{xRatio:i,yRatio:o,maxRatio:r}=e,a=(i+o)/2,{borderWidth:l,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:u,shadowBlur:f}=n;if("number"==typeof l)n.borderWidth=Rt(l*a);else if(Array.isArray(n.borderWidth)){const t=l;n.borderWidth=[Rt(t[0]*o),Rt(t[1]*i),Rt(t[2]*o),Rt(t[3]*i)]}if("number"==typeof s)n.borderRadius=Rt(s*a);else if(Array.isArray(n.borderRadius)){const t=s;n.borderRadius=[t[0]*i,t[1]*i,t[2]*o,t[3]*o]}Array.isArray(c)&&c.forEach(((t,e)=>{n.borderDash[e]=Rt(t*r)})),"number"==typeof h&&(n.shadowOffsetX=Rt(h*r)),"number"==typeof u&&(n.shadowOffsetX=Rt(u*r)),"number"==typeof f&&(n.shadowOffsetX=Rt(f*r))}function St(t,e){const{type:n}=t;!function(t,e){const{xRatio:n,yRatio:i}=e,{x:o,y:r,w:a,h:l}=t;t.x=Rt(o*n),t.y=Rt(r*i),t.w=Rt(a*n),t.h=Rt(l*i),It(t,e)}(t,e),"circle"===n||("text"===n?function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,a=(n+i)/2;o&&o>0&&(t.detail.fontSize=Rt(o*a)),r&&r>0&&(t.detail.lineHeight=Rt(r*a))}(t,e):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{St(t,e)})))}function $t(t,e){const n=e.w&&e.w>0?e.w:t.w,i=e.h&&e.h>0?e.h:t.h,o=n/t.w,r=i/t.h;if(o===r&&1===o)return t;const a=Math.min(o,r),l=Math.max(o,r);t.w=n,t.h=i;const s={xRatio:o,yRatio:r,minRatio:a,maxRatio:l};return"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{St(t,s)})),It(t,s),t}const Et=200,At=200;function Ct(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 Lt(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 kt(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=J(n,t);if(o){if(!Ct(o,i,t))return{elements:t,from:n,to:i};let e=-1;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),Lt(n,t)}return{elements:t,from:n,to:i}}function zt(t,e){var n;const i=Object.keys(e);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?t[r]=e[r]:["detail","operations"].includes(r)&&(b.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),b.json(t[r])&&(t[r]={...t[r],...e[r]})):b.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),b.array(t[r])&&(null==(n=null==e?void 0:e[r])||n.forEach(((e,n)=>{t[r][n]=e})),t[r]=[...t[r],...e[r]])))}return t}function Ot(t,e,n){var i;const o=J(t,n);return o&&("group"===o.type&&!0===(null==(i=o.operations)?void 0:i.deepResize)&&(e.w&&e.w>0||e.h&&e.h>0)&&$t(o,{w:e.w,h:e.h}),zt(o,e)),o}function Tt(t,e,n=void 0){const i=e.split(".").reduce(((t,e)=>Object(t)[e]),t);return void 0===i?n:i}function Dt(t,e,n){const i=e.split(".");return"object"!=typeof t||i.reduce(((t,e,i,o)=>i===o.length-1?(t[e]=n,null):(e in t||(t[e]=/^[0-9]{1,}$/.test(o[i+1])?[]:{}),t[e])),t),t}return t.Context2D=L,t.EventEmitter=class{constructor(){h(this,i,void 0),u(this,i,new Map)}on(t,e){if(c(this,i).has(t)){const n=c(this,i).get(t)||[];null==n||n.push(e),c(this,i).set(t,n)}else c(this,i).set(t,[e])}off(t,e){if(c(this,i).has(t)){const n=c(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}c(this,i).set(t,n||[])}}trigger(t,e){const n=c(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(c(this,i).has(t)){const e=c(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){c(this,i).clear()}},t.Store=class{constructor(t){h(this,a),h(this,o,void 0),h(this,r,void 0),u(this,r,w(t.defaultStorage)),u(this,o,f(this,a,l).call(this))}set(t,e){c(this,o)[t]=e}get(t){return c(this,o)[t]}getSnapshot(){return c(this,o)}clear(){u(this,o,f(this,a,l).call(this))}destroy(){u(this,o,null)}},t.calcDistance=O,t.calcElementCenter=H,t.calcElementCenterFromVertexes=N,t.calcElementListSize=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 a={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const t=U(a);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];a.x=Math.min(...e),a.y=Math.min(...n),a.w=Math.abs(Math.max(...e)-Math.min(...e)),a.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(a.x,n.x),e=Math.min(a.y,n.y),i=Math.max(a.x+a.w,n.x+n.w),o=Math.max(a.y+a.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=a.x,n.y=a.y,n.w=a.w,n.h=a.h;i=a}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}},t.calcElementOriginRectInfo=st,t.calcElementQueueVertexesQueueInGroup=nt,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=e,r=(i&&i>0?i:8)/o.scale,{x:a,y:l,w:s,h:c,angle:h=0}=t,u=[{uuid:m(),x:a,y:l,w:s,h:c,angle:h,type:"group",detail:{children:[]}},...n];let f=0;u.forEach((({angle:t=0})=>{f+=t}));const d=ot(t,{groupQueue:n}),g=ot({x:a-2*r,y:l-2*r,h:c+4*r,w:s+4*r,angle:h},{groupQueue:[...n]}),p=W(d[0],d[1]),y=W(d[1],d[2]),x=W(d[2],d[3]),w=W(d[3],d[0]),v=d[0],b=d[1],M=d[2],P=d[3],R=ct(p,{size:r,angle:f}),I=ct(y,{size:r,angle:f}),S=ct(x,{size:r,angle:f}),$=ct(w,{size:r,angle:f}),E=ct(v,{size:r,angle:f}),A=ct(b,{size:r,angle:f}),C=ct(P,{size:r,angle:f}),L=ct(M,{size:r,angle:f}),k=et(E),z=et(A),O=et(C),T=et(L),D=[k[1],z[0],z[3],k[2]],j=[z[3],z[2],T[1],T[0]],V=[O[1],T[0],T[3],O[2]],F=[k[3],k[2],O[1],O[0]],H=et(R),N=et(I),B=et(S),Q=et($),G=W(g[0],g[1]);return{elementWrapper:d,left:{type:"left",vertexes:F,center:w},right:{type:"right",vertexes:j,center:y},top:{type:"top",vertexes:D,center:p},bottom:{type:"bottom",vertexes:V,center:x},topLeft:{type:"top-left",vertexes:k,center:v},topRight:{type:"top-right",vertexes:z,center:b},bottomLeft:{type:"bottom-left",vertexes:O,center:P},bottomRight:{type:"bottom-right",vertexes:T,center:M},leftMiddle:{type:"left-middle",vertexes:Q,center:w},rightMiddle:{type:"right-middle",vertexes:N,center:y},topMiddle:{type:"top-middle",vertexes:H,center:p},bottomMiddle:{type:"bottom-middle",vertexes:B,center:x},rotate:{type:"rotate",vertexes:et(ct(G,{size:r,angle:f})),center:G}}},t.calcElementVertexesInGroup=ot,t.calcElementVertexesQueueInGroup=it,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=st(t,{groupQueue:n}),{center:a,top:l,bottom:s,left:c,right:h,topLeft:u,topRight:f,bottomLeft:d,bottomRight:g}=r,m={center:at(a,{viewScaleInfo:i}),topLeft:at(u,{viewScaleInfo:i}),topRight:at(f,{viewScaleInfo:i}),bottomLeft:at(d,{viewScaleInfo:i}),bottomRight:at(g,{viewScaleInfo:i}),top:at(l,{viewScaleInfo:i}),right:at(h,{viewScaleInfo:i}),left:at(c,{viewScaleInfo:i}),bottom:at(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(m.topLeft.x,m.topRight.x,m.bottomRight.x,m.bottomLeft.x),e=Math.max(m.topLeft.y,m.topRight.y,m.bottomRight.y,m.bottomLeft.y),n=Math.min(m.topLeft.x,m.topRight.x,m.bottomRight.x,m.bottomLeft.x),i=Math.min(m.topLeft.y,m.topRight.y,m.bottomRight.y,m.bottomLeft.y),o={x:m.center.x,y:m.center.y},r={x:n,y:i},a={x:t,y:i},l={x:t,y:e},s={x:n,y:e},c=W(r,a),h=W(s,l),u=W(r,s);return{center:o,topLeft:r,topRight:a,bottomLeft:s,bottomRight:l,top:c,right:W(a,l),left:u,bottom:h}}return m},t.calcElementViewRectInfoMap=function(t,e){const{groupQueue:n,viewScaleInfo:i}=e,o=st(t,{groupQueue:n}),{center:r,top:a,bottom:l,left:s,right:c,topLeft:h,topRight:u,bottomLeft:f,bottomRight:d}=o,g={center:at(r,{viewScaleInfo:i}),topLeft:at(h,{viewScaleInfo:i}),topRight:at(u,{viewScaleInfo:i}),bottomLeft:at(f,{viewScaleInfo:i}),bottomRight:at(d,{viewScaleInfo:i}),top:at(a,{viewScaleInfo:i}),right:at(c,{viewScaleInfo:i}),left:at(s,{viewScaleInfo:i}),bottom:at(l,{viewScaleInfo:i})},m=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),p=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),y=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),x=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),w={x:g.center.x,y:g.center.y},v={x:y,y:x},b={x:m,y:x},M={x:m,y:p},P={x:y,y:p},R=W(v,b),I=W(P,M),S=W(v,P);return{originRectInfo:o,viewRectInfo:g,rangeRectInfo:{center:w,topLeft:v,topRight:b,bottomLeft:P,bottomRight:M,top:R,right:W(b,M),left:S,bottom:I}}},t.calcElementsContextSize=q,t.calcElementsViewInfo=function(t,e,n){const i=q(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.calcRadian=function(t,e,n){const i=B(t,e),o=B(t,n);return null!==o&&null!==i?i>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-i):o>3*Math.PI/2&&i<Math.PI/2?i+(2*Math.PI-o):o-i:0},t.calcSpeed=function(t,e){return O(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{boxSizing:r=Pt.boxSizing,borderWidth:a}=t.detail;Array.isArray(a)&&(o=0);let{x:l,y:s,w:c,h:h}=t,u=[0,0,0,0];if("number"==typeof o){const t=o*i;u=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(u=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let f=0;return"number"==typeof a&&(f=(a||0)*i),"border-box"===r?(l=t.x+f/2,s=t.y+f/2,c=t.w-f,h=t.h-f):"content-box"===r?(l=t.x-f/2,s=t.y-f/2,c=t.w+f,h=t.h+f):(l=t.x,s=t.y,c=t.w,h=t.h),c=Math.max(c,1),h=Math.max(h,1),u=u.map((t=>Math.min(t,c/2,h/2))),{x:l,y:s,w:c,h:h,radiusList:u}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:a,scale:l}=i,{width:s,height:c}=o;e=0-r+s/l/2,n=0-a+c/l/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,a,l,s,c;let h=0,u=0,f=1,d=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,g=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,m=(null==(l=null==(a=null==t?void 0:t.elements)?void 0:a[0])?void 0:l.w)||0,p=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:y,height:x}=e.viewSizeInfo;if(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=U(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,d),i=Math.min(e.y,g),o=Math.max(e.x+e.w,d+m),r=Math.max(e.y+e.h,g+p);d=n,g=i,m=Math.abs(o-n),p=Math.abs(r-i)})),m>0&&p>0){const t=xt(y/m,{decimalPlaces:4}),e=xt(x/p,{decimalPlaces:4});f=Math.min(t,e,1),h=(m*f-y)/2/f+d,u=(p*f-x)/2/f+g}return{offsetX:xt(h,{decimalPlaces:0}),offsetY:xt(u,{decimalPlaces:0}),scale:f}},t.calcViewElementSize=rt,t.calcViewPointSize=at,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:a,height:l,contextWidth:s,contextHeight:c}=r,h=0-i*n,u=0-o*n;return{scale:n,offsetLeft:h,offsetTop:u,offsetRight:a-(s*n+h/n),offsetBottom:l-(c*n+u/n)}},t.calcViewVertexes=function(t,e){return[at(t[0],e),at(t[1],e),at(t[2],e),at(t[3],e)]},t.check=C,t.checkRectIntersect=_,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=g[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;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,a=t*n,l=o*n;let s=document.createElement("canvas");s.width=a,s.height=l;s.getContext("2d").drawImage(r,0,0,a,l);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=y,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r,createCustomContext2D:a}=e,l={width:n,height:i,devicePixelRatio:o},s=t.getContext("2d");if(a){const t=a(l),e=a(l),n=a(l),i=k({ctx:s,...l}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underContext:n,viewContext:t,helperContext:e,boardContext:i,drawView:o}}if(!0===r){const t=z(l),e=z(l),n=z(l),i=k({ctx:s,...l}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underContext:n,viewContext:t,helperContext:e,boardContext:i,drawView:o}}{const t=k(l),e=k(l),o=k(l),r=k({ctx:s,...l}),a=()=>{r.clearRect(0,0,n,i),r.drawImage(o.canvas,0,0,n,i),r.drawImage(t.canvas,0,0,n,i),r.drawImage(e.canvas,0,0,n,i),o.clearRect(0,0,n,i),t.clearRect(0,0,n,i),e.clearRect(0,0,n,i)};return{underContext:o,viewContext:t,helperContext:e,boardContext:r,drawView:a}}},t.createContext2D=k,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=Et,r=At;if(e){const{viewScaleInfo:a,viewSizeInfo:l}=e,{scale:s,offsetLeft:c,offsetTop:h}=a,{width:u,height:f}=l,d=u/4,g=f/4;o=Et>=d?d/s:Et/s,r=At>=g?g/s:At/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/vt.length*2),n=(0-c+u/2-o*s/2)/s,i=(0-h+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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};return{text:vt,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,lineHeight:t.w/vt.length,fontSize:t.w/vt.length,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"}),{...i,...e,uuid:m(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=z,t.createUUID=m,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.deepCloneElement=function(t){const e=w(t),n=t=>{t.uuid=m(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e},t.deepResizeGroupElement=$t,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Lt(K(t,e),e)},t.deleteElementInListByPosition=Lt,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.equalPoint=T,t.equalTouchPoint=function(t,e){return!0===T(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,a;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(x(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=y(i);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(x(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=y(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(x(e)&&!n[e]&&o[e]&&"string"==typeof(null==(a=o[e])?void 0:a.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=y(e);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||x(i)||(e=y(i),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 a=n[r];if(a.uuid===e){o=a;break}if(!o&&"group"===a.type){const n=t(e,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=J,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 a=i[r];t.includes(a.uuid)?n.push(a):"group"===a.type&&e((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=J(t,e);i&&n.push(i)})),n},t.formatNumber=xt,t.generateHTML=function(t){return t.reduce((function(t,e){return t+yt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=W,t.getDefaultElementDetailConfig=bt,t.getDefaultElementRectDetail=Mt,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&x(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&x(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=K,t.getElementRotateVertexes=G,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=tt,t.getGroupQueueByElementPosition=Z,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===e){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=t(e,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getModifiedElement=function(t,e){const n={},i=[],o=t=>{if(b.json(t)){Object.keys(t).forEach((r=>{if(i.push(r),b.json(t[r])||b.array(t[r]))o(t[r]);else{const t=i.join(".");if("uuid"!==t){const o=Tt(e,t);Dt(n,i.join("."),o)}}i.pop()}))}else b.array(t)&&t.forEach((r=>{if(i.push(r),b.json(t[r])||b.array(t[r]))o(t[r]);else{const t=Tt(e,i.join("."));Dt(n,i.join("."),t)}i.pop()}))};return o(t),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:a,viewScaleInfo:l,viewSizeInfo:s,groupQueue:c}=e,h={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,a=0,u=0;for(let t=0;t<=e;t++)o+=c[t].x,a+=c[t].y,u+=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 d=f.detail.children[n];if(!0!==(null==(i=null==d?void 0:d.operations)?void 0:i.invisible)){if(!d)break;if(lt(t,{context2d:r,element:{x:o+d.x,y:a+d.y,w:d.w,h:d.h,angle:u+(d.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){h.element=d,(e<c.length-1||"group"!==d.type)&&(h.groupQueueIndex=e);break}}}if(h.element)break}if(h.element)return h;for(let e=a.elements.length-1;e>=0;e--){const n=a.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&lt(t,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){h.index=e,h.element=n;break}}return h},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.insertElementToListByPosition=Ct,t.is=E,t.isAssetId=x,t.isColorStr=d,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:a}=t,{x:l,y:s,w:c,h:h}=rt(t,{viewScaleInfo:i,viewSizeInfo:n}),u=U({x:l,y:s,w:c,h:h,angle:a}),f={x:0,y:0,w:o,h:r},d=Math.min(u[0].x,u[1].x,u[2].x,u[3].x),g=Math.min(u[0].y,u[1].y,u[2].y,u[3].y);return _(f,{x:d,y:g,w:Math.max(u[0].x,u[1].x,u[2].x,u[3].x)-d,h:Math.max(u[0].y,u[1].y,u[2].y,u[3].y)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=lt,t.istype=b,t.limitAngle=X,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"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},a.onerror=function(t){o(t)}}))}(t,e);return await P(n)},t.loadImage=P,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 P(e)},t.matrixToAngle=function(t){const e=wt(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=wt,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.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.modifyElement=function(t,e){const{type:n}=e,i={...e.content};if("addElement"===n){const n=e,{element:i,position:o}=n.content;(null==o?void 0:o.length)>0?Ct(i,[...o],t.elements):t.elements.push(i)}else if("deleteElement"===n){const n=e,{position:i}=n.content;Lt(i,t.elements)}else if("moveElement"===n){const n=e,{from:o,to:r}=n.content,a=kt(t.elements,{from:o,to:r});i.from=a.from,i.to=a.to,t.elements=a.elements}else if("updateElement"===n){const n=e,{position:i,afterModifiedElement:o}=n.content;Ot(i,o,t.elements)}return{data:t,content:i}},t.moveElementPosition=kt,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(dt,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,h=t.charAt(c);let u;if(s){const t=pt(r);return o<0?(e.push(t),r):(u=n[o],u.children.push(t),r)}if(l){if(o++,i=pt(r),!i.isVoid&&h&&"<"!==h){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),u=n[o-1],u&&u.children.push(i),n[o]=i}if((!l||!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]),"<"!==h&&h)){u=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);gt.test(r)&&(r=" "),(i>-1&&o+u.length>=0||" "!==r)&&r.trim()&&u.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(ht,((t,n,i)=>{const o=i.match(ut),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.rotateByCenter=F,t.rotateElement=function(t,e,n){const i=H(e);F(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=U,t.rotatePoint=Q,t.rotatePointInGroup=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:a,angle:l=0}=t,s=Q(H({x:e,y:o,w:r,h:a,angle:l}),{x:n,y:i},V(l));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=Y,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=y(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=y(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=y(e);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.sortElementsViewVisiableInfoMap=function(t){const e={},n=[],i=o=>{const r={viewRectInfo:null,rangeRectInfo:null,isVisibleInView:!0,isGroup:"group"===o.type,position:[...n]};let a=null;a=st(o,{groupQueue:Z(t,n)||[]}),e[o.uuid]={...r,originRectInfo:a},"group"===o.type&&o.detail.children.forEach(((t,e)=>{"group"===t.type&&n.push(e),i(t),"group"===t.type&&n.pop()}))};return t.forEach(((t,e)=>{n.push(e),i(t),n.pop()})),e},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.updateElementInList=function t(e,n,i){var o,r;let a=null;for(let l=0;l<i.length;l++){const s=i[l];if(s.uuid===e){"group"===s.type&&!0===(null==(o=s.operations)?void 0:o.deepResize)&&(n.w&&n.w>0||n.h&&n.h>0)&&$t(s,{w:n.w,h:n.h}),zt(s,n),a=s;break}"group"===s.type&&(a=t(e,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return a},t.updateElementInListByPosition=Ot,t.vaildPoint=j,t.vaildTouchPoint=function(t){return!0===j(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,a=e/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:a,height:l,contextWidth:s,contextHeight:c}=o;let h=i.offsetLeft,u=i.offsetRight,f=i.offsetTop,d=i.offsetBottom;return h+=e,f+=n,u=a-(s*r+h),d=l-(c*r+f),{scale:r,offsetTop:f,offsetLeft:h,offsetRight:u,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
1
+ var iDrawUtil=function(t){"use strict";var e,n,i,o,r,a,l,s=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},c=(t,e,n)=>(s(t,e,"read from private field"),n?n.call(t):e.get(t)),h=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},f=(t,e,n,i)=>(s(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),u=(t,e,n)=>(s(t,e,"access private method"),n);function d(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 g={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 m(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function y(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n)*t.charCodeAt(n)*n*n;return e.toString(16).substring(0,4)}function x(t){const e=t.length,n=Math.floor(e/2),i=t.substring(0,4).padEnd(4,"0"),o=t.substring(0,4).padEnd(4,"0");return`@assets/${y(e.toString(16).padEnd(4,i))}${y(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${y(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${y(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${y(t.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${y(t.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${y(t.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${y(o.padEnd(4,i).padEnd(4,o))}`}function p(t){return/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.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 v(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const b={type(t,e){const n=v(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===v(t),json:t=>"Object"===v(t),function:t=>"Function"===v(t),asyncFunction:t=>"AsyncFunction"===v(t),boolean:t=>"Boolean"===v(t),string:t=>"String"===v(t),number:t=>"Number"===v(t),undefined:t=>"Undefined"===v(t),null:t=>"Null"===v(t),promise:t=>"Promise"===v(t)};const{Image:M}=window;function R(t){return new Promise(((e,n)=>{const i=new M;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function P(t){return"number"==typeof t&&(t>0||t<=0)}function I(t){return"number"==typeof t&&t>=0}function S(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function L(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const E={x:function(t){return P(t)},y:function(t){return P(t)},w:I,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:P,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return I(t)},borderRadius:function(t){return P(t)&&t>=0},color:function(t){return d(t)},imageSrc:function(t){return L(t)||S(t)},imageURL:S,imageBase64:L,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 P(t)&&t>0},lineHeight:function(t){return P(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 P(t)&&t>0}};function $(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!E.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!E.number(n))&&!(t.hasOwnProperty("borderWidth")&&!E.number(i)))}const A={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(E.x(e)&&E.y(n)&&E.w(i)&&E.h(o)&&E.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:h}=t;return!!E.text(e)&&(!!E.color(n)&&(!!E.fontSize(i)&&(!(t.hasOwnProperty("background")&&!E.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!E.fontWeight(l))&&(!(t.hasOwnProperty("lineHeight")&&!E.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!E.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!E.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!E.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!E.color(h))&&!!$(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!E.color(e))&&!!$(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!E.color(e))&&(!(t.hasOwnProperty("borderColor")&&!E.color(n))&&!(t.hasOwnProperty("borderWidth")&&!E.number(i)))},imageDesc:function(t){const{src:e}=t;return!!E.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!E.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!E.html(e)}};class C{constructor(t,i){h(this,e,void 0),h(this,n,void 0),f(this,e,t),f(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/c(this,n).devicePixelRatio}$doPixelRatio(t){return c(this,n).devicePixelRatio*t}$getContext(){return c(this,e)}$setContext(t){f(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"}`),c(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 c(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:a}=t,{canvas:l}=c(this,e);l.width=i*r,l.height=o*r,f(this,n,{...c(this,n),devicePixelRatio:r}),!0===a&&(l.style.width=`${i}px`,l.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=c(this,n),{width:i,height:o}=c(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return c(this,e).canvas}get fillStyle(){return c(this,e).fillStyle}set fillStyle(t){c(this,e).fillStyle=t}get strokeStyle(){return c(this,e).strokeStyle}set strokeStyle(t){c(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(c(this,e).lineWidth)}set lineWidth(t){c(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return c(this,e).textAlign}set textAlign(t){c(this,e).textAlign=t}get textBaseline(){return c(this,e).textBaseline}set textBaseline(t){c(this,e).textBaseline=t}get globalAlpha(){return c(this,e).globalAlpha}set globalAlpha(t){c(this,e).globalAlpha=t}get shadowColor(){return c(this,e).shadowColor}set shadowColor(t){c(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(c(this,e).shadowOffsetX)}set shadowOffsetX(t){c(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(c(this,e).shadowOffsetY)}set shadowOffsetY(t){c(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(c(this,e).shadowBlur)}set shadowBlur(t){c(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return c(this,e).lineCap}set lineCap(t){c(this,e).lineCap=t}get globalCompositeOperation(){return c(this,e).globalCompositeOperation}set globalCompositeOperation(t){c(this,e).globalCompositeOperation=t}fill(...t){return c(this,e).fill(...t)}arc(t,n,i,o,r,a){return c(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a)}rect(t,n,i,o){return c(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return c(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return c(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return c(this,e).beginPath()}closePath(){return c(this,e).closePath()}lineTo(t,n){return c(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return c(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return c(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return c(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return c(this,e).setLineDash(n)}stroke(t){return t?c(this,e).stroke(t):c(this,e).stroke()}translate(t,n){return c(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return c(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],a=t[4],l=t[t.length-4],s=t[t.length-3],h=t[t.length-2],f=t[t.length-1];return 9===t.length?c(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(f)):c(this,e).drawImage(n,this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(f))}createPattern(t,n){return c(this,e).createPattern(t,n)}measureText(t){return c(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){c(this,e).save()}restore(){c(this,e).restore()}scale(t,n){c(this,e).scale(t,n)}circle(t,n,i,o,r,a,l,s){c(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,l,s)}isPointInPath(t,n){return c(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return c(this,e).clip(...t)}setTransform(t,n,i,o,r,a){return c(this,e).setTransform(t,n,i,o,r,a)}getTransform(){return c(this,e).getTransform()}createLinearGradient(t,n,i,o){return c(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,a){return c(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(t,n,i){return c(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function k(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 z(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 O(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 T(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function D(t){return t>=0||t<0}function j(t){return D(t.x)&&D(t.y)&&t.t>0}function W(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 F(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 H(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function N(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 H({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 B(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 Q(t,e,n){let i=B(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=O(t,e);let r=0,a=0;return 0===i?(r=0,a=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,a=0-Math.cos(i)*o):i===Math.PI/2?(r=o,a=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,a=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,a=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,a=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,a=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,a=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,a=0-o),r+=t.x,a+=t.y,{x:r,y:a}}function G(t,e,n){const{x:i,y:o,w:r,h:a}=t;let l={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+a},h={x:i,y:o+a};if(n&&(n>0||n<0)){const t=V(X(n));l=Q(e,l,t),s=Q(e,s,t),c=Q(e,c,t),h=Q(e,h,t)}return[l,s,c,h]}function U(t){const{angle:e=0}=t;return G(t,H(t),e)}function Y(t,e,n){return[Q(t,{x:e[0].x,y:e[0].y},n),Q(t,{x:e[1].x,y:e[1].y},n),Q(t,{x:e[2].x,y:e[2].y},n),Q(t,{x:e[3].x,y:e[3].y},n)]}function X(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function q(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=U(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),a=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(a-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 Z(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}function J(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"===o.type)i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}function K(t,e){const n=[];let i=!1;const o=e=>{var r;for(let a=0;a<e.length&&!0!==i;a++){n.push(a);const l=e[a];if(l.uuid===t){i=!0;break}if("group"===l.type&&o((null==(r=null==l?void 0:l.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function _(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,a=e.x,l=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=a&&i<=c&&r>=l}function tt(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 et(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?tt(t):G(t,H({x:e,y:n,w:i,h:o,angle:r}),r)}function nt(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:l,w:s,h:c,angle:h=0}=r[t];let f;if(n+=a,i+=l,0===t){const t={x:n,y:i,w:s,h:c,angle:h};f=et({x:a,y:l,w:s,h:c,angle:h}),o.push({center:H(t),angle:h,radian:V(h)})}else{f=tt({x:n,y:i,w:s,h:c,angle:h});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];f=Y(e,f,n)}const t=N(f);if(h>0||h<0){f=Y(t,f,V(h))}o.push({center:t,angle:h,radian:V(h)})}e.push(f)}return e}function it(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[et(t)];return nt([...n,t])}function ot(t,e){return it(t,e).pop()||null}function rt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:a,angle:l}=t,{scale:s,offsetTop:c,offsetLeft:h}=n;return{x:i*s+h,y:o*s+c,w:r*s,h:a*s,angle:l}}function at(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function lt(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:l,y:s,w:c,h:h}=rt(i,{viewScaleInfo:o,viewSizeInfo:r}),f=U({x:l,y:s,w:c,h:h,angle:a});if(f.length>=2){n.beginPath(),n.moveTo(f[0].x,f[0].y);for(let t=1;t<f.length;t++)n.lineTo(f[t].x,f[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function st(t,e){const{groupQueue:n}=e,i=ot(t,{groupQueue:n}),o=W(i[0],i[1]),r=W(i[1],i[2]),a=W(i[2],i[3]),l=W(i[3],i[0]),s=i[0],c=i[1],h=i[2],f=i[3],u=Math.max(s.x,c.x,h.x,f.x),d=Math.max(s.y,c.y,h.y,f.y);return{center:{x:(u+Math.min(s.x,c.x,h.x,f.x))/2,y:(d+Math.min(s.y,c.y,h.y,f.y))/2},topLeft:s,topRight:c,bottomLeft:f,bottomRight:h,top:o,right:r,left:l,bottom:a}}function ct(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},a={x:i,y:o},l={x:e,y:o},s={x:e,y:n},c={x:i,y:n},h=W(a,l),f=W(c,s),u=W(a,c);return{center:r,topLeft:a,topRight:l,bottomLeft:c,bottomRight:s,top:h,right:W(l,s),left:u,bottom:f}}function ht(t,e){const n=ft(e);let i=0,o=0;return Object.keys(t).forEach((e=>{const r=t[e];r.isVisibleInView=function(t,e){const n=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),i=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),r=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),a=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),l=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),s=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),c=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y);return n<=l&&i>=a&&o<=c&&r>=s||l<=r&&l>=r&&l<=r&&l>=r}(r.rangeRectInfo,n),r.isVisibleInView?i++:o++})),{viewVisibleInfoMap:t,visibleCount:i,invisibleCount:o}}function ft(t){const{viewScaleInfo:e,viewSizeInfo:n}=t,{scale:i,offsetTop:o,offsetLeft:r}=e,{width:a,height:l}=n,s=0-r/i,c=0-o/i,h=a/i,f=l/i,u=H({x:s,y:c,w:h,h:f});return{center:u,topLeft:{x:s,y:c},topRight:{x:s+h,y:c},bottomLeft:{x:s,y:c+f},bottomRight:{x:s+h,y:c+f},left:{x:s,y:u.y},top:{x:u.x,y:c},right:{x:s+h,y:u.y},bottom:{x:u.x,y:c+f}}}function ut(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,a=new WeakSet,l=function(){return w(c(this,r))};const dt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,gt=/(-?\d+(?:\.\d+)?)/gi;const mt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,yt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,xt=/^\s*$/,pt={};function wt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(pt[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 vt(t,e){switch(e.type){case"text":return t+e.textContent;case"element":return t+="<"+e.name+(e.attributes?function(t){const e=[];for(let n in t)e.push(n+'="'+t[n]+'"');return e.length?" "+e.join(" "):""}(e.attributes):"")+(e.isVoid?"/>":">"),e.isVoid?t:t+e.children.reduce(vt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function bt(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 Mt(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 Rt="Text Element";function Pt(){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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"}}function It(){return{background:"#D9D9D9"}}const St={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const Lt=t=>bt(t,{decimalPlaces:4});function Et(t,e){const{detail:n}=t,{xRatio:i,yRatio:o,maxRatio:r}=e,a=(i+o)/2,{borderWidth:l,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:f,shadowBlur:u}=n;if("number"==typeof l)n.borderWidth=Lt(l*a);else if(Array.isArray(n.borderWidth)){const t=l;n.borderWidth=[Lt(t[0]*o),Lt(t[1]*i),Lt(t[2]*o),Lt(t[3]*i)]}if("number"==typeof s)n.borderRadius=Lt(s*a);else if(Array.isArray(n.borderRadius)){const t=s;n.borderRadius=[t[0]*i,t[1]*i,t[2]*o,t[3]*o]}Array.isArray(c)&&c.forEach(((t,e)=>{n.borderDash[e]=Lt(t*r)})),"number"==typeof h&&(n.shadowOffsetX=Lt(h*r)),"number"==typeof f&&(n.shadowOffsetX=Lt(f*r)),"number"==typeof u&&(n.shadowOffsetX=Lt(u*r))}function $t(t,e){const{type:n}=t;!function(t,e){const{xRatio:n,yRatio:i}=e,{x:o,y:r,w:a,h:l}=t;t.x=Lt(o*n),t.y=Lt(r*i),t.w=Lt(a*n),t.h=Lt(l*i),Et(t,e)}(t,e),"circle"===n||("text"===n?function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,a=(n+i)/2;o&&o>0&&(t.detail.fontSize=Lt(o*a)),r&&r>0&&(t.detail.lineHeight=Lt(r*a))}(t,e):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{$t(t,e)})))}function At(t,e){const n=e.w&&e.w>0?e.w:t.w,i=e.h&&e.h>0?e.h:t.h,o=n/t.w,r=i/t.h;if(o===r&&1===o)return t;const a=Math.min(o,r),l=Math.max(o,r);t.w=n,t.h=i;const s={xRatio:o,yRatio:r,minRatio:a,maxRatio:l};return"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{$t(t,s)})),Et(t,s),t}const Ct=200,kt=200;function zt(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 Ot(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 Tt(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=J(n,t);if(o){if(!zt(o,i,t))return{elements:t,from:n,to:i};let e=-1;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),Ot(n,t)}return{elements:t,from:n,to:i}}function Dt(t,e){var n;const i=Object.keys(e);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?t[r]=e[r]:["detail","operations"].includes(r)&&(b.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),b.json(t[r])&&(t[r]={...t[r],...e[r]})):b.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),b.array(t[r])&&(null==(n=null==e?void 0:e[r])||n.forEach(((e,n)=>{t[r][n]=e})),t[r]=[...t[r],...e[r]])))}return t}function jt(t,e,n){var i;const o=J(t,n);return o&&("group"===o.type&&!0===(null==(i=o.operations)?void 0:i.deepResize)&&(e.w&&e.w>0||e.h&&e.h>0)&&At(o,{w:e.w,h:e.h}),Dt(o,e)),o}function Wt(t,e,n=void 0){const i=e.split(".").reduce(((t,e)=>Object(t)[e]),t);return void 0===i?n:i}function Vt(t,e,n){const i=e.split(".");return"object"!=typeof t||i.reduce(((t,e,i,o)=>i===o.length-1?(t[e]=n,null):(e in t||(t[e]=/^[0-9]{1,}$/.test(o[i+1])?[]:{}),t[e])),t),t}return t.Context2D=C,t.EventEmitter=class{constructor(){h(this,i,void 0),f(this,i,new Map)}on(t,e){if(c(this,i).has(t)){const n=c(this,i).get(t)||[];null==n||n.push(e),c(this,i).set(t,n)}else c(this,i).set(t,[e])}off(t,e){if(c(this,i).has(t)){const n=c(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}c(this,i).set(t,n||[])}}trigger(t,e){const n=c(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(c(this,i).has(t)){const e=c(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){c(this,i).clear()}},t.Store=class{constructor(t){h(this,a),h(this,o,void 0),h(this,r,void 0),f(this,r,w(t.defaultStorage)),f(this,o,u(this,a,l).call(this))}set(t,e){c(this,o)[t]=e}get(t){return c(this,o)[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?w(c(this,o)):{...c(this,o)}}clear(){f(this,o,u(this,a,l).call(this))}destroy(){f(this,o,null)}},t.calcDistance=O,t.calcElementCenter=H,t.calcElementCenterFromVertexes=N,t.calcElementListSize=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 a={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const t=U(a);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];a.x=Math.min(...e),a.y=Math.min(...n),a.w=Math.abs(Math.max(...e)-Math.min(...e)),a.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(a.x,n.x),e=Math.min(a.y,n.y),i=Math.max(a.x+a.w,n.x+n.w),o=Math.max(a.y+a.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=a.x,n.y=a.y,n.w=a.w,n.h=a.h;i=a}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}},t.calcElementOriginRectInfo=st,t.calcElementQueueVertexesQueueInGroup=nt,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=e,r=(i&&i>0?i:8)/o.scale,{x:a,y:l,w:s,h:c,angle:h=0}=t,f=[{uuid:m(),x:a,y:l,w:s,h:c,angle:h,type:"group",detail:{children:[]}},...n];let u=0;f.forEach((({angle:t=0})=>{u+=t}));const d=ot(t,{groupQueue:n}),g=ot({x:a-2*r,y:l-2*r,h:c+4*r,w:s+4*r,angle:h},{groupQueue:[...n]}),y=W(d[0],d[1]),x=W(d[1],d[2]),p=W(d[2],d[3]),w=W(d[3],d[0]),v=d[0],b=d[1],M=d[2],R=d[3],P=ut(y,{size:r,angle:u}),I=ut(x,{size:r,angle:u}),S=ut(p,{size:r,angle:u}),L=ut(w,{size:r,angle:u}),E=ut(v,{size:r,angle:u}),$=ut(b,{size:r,angle:u}),A=ut(R,{size:r,angle:u}),C=ut(M,{size:r,angle:u}),k=et(E),z=et($),O=et(A),T=et(C),D=[k[1],z[0],z[3],k[2]],j=[z[3],z[2],T[1],T[0]],V=[O[1],T[0],T[3],O[2]],F=[k[3],k[2],O[1],O[0]],H=et(P),N=et(I),B=et(S),Q=et(L),G=W(g[0],g[1]);return{elementWrapper:d,left:{type:"left",vertexes:F,center:w},right:{type:"right",vertexes:j,center:x},top:{type:"top",vertexes:D,center:y},bottom:{type:"bottom",vertexes:V,center:p},topLeft:{type:"top-left",vertexes:k,center:v},topRight:{type:"top-right",vertexes:z,center:b},bottomLeft:{type:"bottom-left",vertexes:O,center:R},bottomRight:{type:"bottom-right",vertexes:T,center:M},leftMiddle:{type:"left-middle",vertexes:Q,center:w},rightMiddle:{type:"right-middle",vertexes:N,center:x},topMiddle:{type:"top-middle",vertexes:H,center:y},bottomMiddle:{type:"bottom-middle",vertexes:B,center:p},rotate:{type:"rotate",vertexes:et(ut(G,{size:r,angle:u})),center:G}}},t.calcElementVertexesInGroup=ot,t.calcElementVertexesQueueInGroup=it,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=st(t,{groupQueue:n}),{center:a,top:l,bottom:s,left:c,right:h,topLeft:f,topRight:u,bottomLeft:d,bottomRight:g}=r,m={center:at(a,{viewScaleInfo:i}),topLeft:at(f,{viewScaleInfo:i}),topRight:at(u,{viewScaleInfo:i}),bottomLeft:at(d,{viewScaleInfo:i}),bottomRight:at(g,{viewScaleInfo:i}),top:at(l,{viewScaleInfo:i}),right:at(h,{viewScaleInfo:i}),left:at(c,{viewScaleInfo:i}),bottom:at(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(m.topLeft.x,m.topRight.x,m.bottomRight.x,m.bottomLeft.x),e=Math.max(m.topLeft.y,m.topRight.y,m.bottomRight.y,m.bottomLeft.y),n=Math.min(m.topLeft.x,m.topRight.x,m.bottomRight.x,m.bottomLeft.x),i=Math.min(m.topLeft.y,m.topRight.y,m.bottomRight.y,m.bottomLeft.y),o={x:m.center.x,y:m.center.y},r={x:n,y:i},a={x:t,y:i},l={x:t,y:e},s={x:n,y:e},c=W(r,a),h=W(s,l),f=W(r,s);return{center:o,topLeft:r,topRight:a,bottomLeft:s,bottomRight:l,top:c,right:W(a,l),left:f,bottom:h}}return m},t.calcElementViewRectInfoMap=function(t,e){const{groupQueue:n,viewScaleInfo:i}=e,o=st(t,{groupQueue:n}),{center:r,top:a,bottom:l,left:s,right:c,topLeft:h,topRight:f,bottomLeft:u,bottomRight:d}=o,g={center:at(r,{viewScaleInfo:i}),topLeft:at(h,{viewScaleInfo:i}),topRight:at(f,{viewScaleInfo:i}),bottomLeft:at(u,{viewScaleInfo:i}),bottomRight:at(d,{viewScaleInfo:i}),top:at(a,{viewScaleInfo:i}),right:at(c,{viewScaleInfo:i}),left:at(s,{viewScaleInfo:i}),bottom:at(l,{viewScaleInfo:i})},m=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),y=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),x=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),p=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),w={x:g.center.x,y:g.center.y},v={x:x,y:p},b={x:m,y:p},M={x:m,y:y},R={x:x,y:y},P=W(v,b),I=W(R,M),S=W(v,R);return{originRectInfo:o,rangeRectInfo:{center:w,topLeft:v,topRight:b,bottomLeft:R,bottomRight:M,top:P,right:W(b,M),left:S,bottom:I}}},t.calcElementsContextSize=q,t.calcElementsViewInfo=function(t,e,n){const i=q(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.calcRadian=function(t,e,n){const i=B(t,e),o=B(t,n);return null!==o&&null!==i?i>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-i):o>3*Math.PI/2&&i<Math.PI/2?i+(2*Math.PI-o):o-i:0},t.calcSpeed=function(t,e){return O(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{boxSizing:r=St.boxSizing,borderWidth:a}=t.detail;Array.isArray(a)&&(o=0);let{x:l,y:s,w:c,h:h}=t,f=[0,0,0,0];if("number"==typeof o){const t=o*i;f=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(f=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let u=0;return"number"==typeof a&&(u=(a||0)*i),"border-box"===r?(l=t.x+u/2,s=t.y+u/2,c=t.w-u,h=t.h-u):"content-box"===r?(l=t.x-u/2,s=t.y-u/2,c=t.w+u,h=t.h+u):(l=t.x,s=t.y,c=t.w,h=t.h),c=Math.max(c,1),h=Math.max(h,1),f=f.map((t=>Math.min(t,c/2,h/2))),{x:l,y:s,w:c,h:h,radiusList:f}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:a,scale:l}=i,{width:s,height:c}=o;e=0-r+s/l/2,n=0-a+c/l/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,a,l,s,c,h,f;let u=0,d=0,g=1,m=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,y=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,x=(null==(l=null==(a=null==t?void 0:t.elements)?void 0:a[0])?void 0:l.w)||0,p=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:w,height:v}=e.viewSizeInfo;if(t.layout&&"hidden"===(null==(f=null==(h=t.layout)?void 0:h.detail)?void 0:f.overflow)?(m=0,y=0,x=t.layout.w||0,p=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=U(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,m),i=Math.min(e.y,y),o=Math.max(e.x+e.w,m+x),r=Math.max(e.y+e.h,y+p);m=n,y=i,x=Math.abs(o-n),p=Math.abs(r-i)})),x>0&&p>0){const t=bt(w/x,{decimalPlaces:4}),e=bt(v/p,{decimalPlaces:4});g=Math.min(t,e,1),u=(x*g-w)/2/g+m,d=(p*g-v)/2/g+y}return{offsetX:bt(u,{decimalPlaces:0}),offsetY:bt(d,{decimalPlaces:0}),scale:g}},t.calcViewElementSize=rt,t.calcViewPointSize=at,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:a,height:l,contextWidth:s,contextHeight:c}=r,h=0-i*n,f=0-o*n;return{scale:n,offsetLeft:h,offsetTop:f,offsetRight:a-(s*n+h/n),offsetBottom:l-(c*n+f/n)}},t.calcViewVertexes=function(t,e){return[at(t[0],e),at(t[1],e),at(t[2],e),at(t[3],e)]},t.calcVisibleOriginCanvasRectInfo=ft,t.check=A,t.checkRectIntersect=_,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=g[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;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,a=t*n,l=o*n;let s=document.createElement("canvas");s.width=a,s.height=l;s.getContext("2d").drawImage(r,0,0,a,l);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=x,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r,createCustomContext2D:a}=e,l={width:n,height:i,devicePixelRatio:o},s=t.getContext("2d");if(a){const t=a(l),e=a(l),n=a(l),i=k({ctx:s,...l}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underContext:n,viewContext:t,helperContext:e,boardContext:i,drawView:o}}if(!0===r){const t=z(l),e=z(l),n=z(l),i=k({ctx:s,...l}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underContext:n,viewContext:t,helperContext:e,boardContext:i,drawView:o}}{const t=k(l),e=k(l),o=k(l),r=k({ctx:s,...l}),a=()=>{r.clearRect(0,0,n,i),r.drawImage(o.canvas,0,0,n,i),r.drawImage(t.canvas,0,0,n,i),r.drawImage(e.canvas,0,0,n,i),o.clearRect(0,0,n,i),t.clearRect(0,0,n,i),e.clearRect(0,0,n,i)};return{underContext:o,viewContext:t,helperContext:e,boardContext:r,drawView:a}}},t.createContext2D=k,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=Ct,r=kt;if(e){const{viewScaleInfo:a,viewSizeInfo:l}=e,{scale:s,offsetLeft:c,offsetTop:h}=a,{width:f,height:u}=l,d=f/4,g=u/4;o=Ct>=d?d/s:Ct/s,r=kt>=g?g/s:kt/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/Rt.length*2),n=(0-c+f/2-o*s/2)/s,i=(0-h+u/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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};return{text:Rt,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,lineHeight:t.w/Rt.length,fontSize:t.w/Rt.length,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"}),{...i,...e,uuid:m(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=z,t.createUUID=m,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.deepCloneElement=function(t){const e=w(t),n=t=>{t.uuid=m(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e},t.deepResizeGroupElement=At,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Ot(K(t,e),e)},t.deleteElementInListByPosition=Ot,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.equalPoint=T,t.equalTouchPoint=function(t,e){return!0===T(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,a;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(p(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=x(i);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(p(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=x(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(p(e)&&!n[e]&&o[e]&&"string"==typeof(null==(a=o[e])?void 0:a.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=x(e);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||p(i)||(e=x(i),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 a=n[r];if(a.uuid===e){o=a;break}if(!o&&"group"===a.type){const n=t(e,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=J,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 a=i[r];t.includes(a.uuid)?n.push(a):"group"===a.type&&e((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=J(t,e);i&&n.push(i)})),n},t.formatNumber=bt,t.generateHTML=function(t){return t.reduce((function(t,e){return t+vt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=W,t.getDefaultElementDetailConfig=Pt,t.getDefaultElementRectDetail=It,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&p(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&p(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=K,t.getElementRotateVertexes=G,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=tt,t.getGroupQueueByElementPosition=Z,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===e){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=t(e,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getModifiedElement=function(t,e){const n={},i=[],o=t=>{if(b.json(t)){Object.keys(t).forEach((r=>{if(i.push(r),b.json(t[r])||b.array(t[r]))o(t[r]);else{const t=i.join(".");if("uuid"!==t){const o=Wt(e,t);Vt(n,i.join("."),o)}}i.pop()}))}else b.array(t)&&t.forEach((r=>{if(i.push(r),b.json(t[r])||b.array(t[r]))o(t[r]);else{const t=Wt(e,i.join("."));Vt(n,i.join("."),t)}i.pop()}))};return o(t),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:a,viewScaleInfo:l,viewSizeInfo:s,groupQueue:c}=e,h={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,a=0,f=0;for(let t=0;t<=e;t++)o+=c[t].x,a+=c[t].y,f+=c[t].angle||0;const u=c[e];if(u&&"group"===u.type&&Array.isArray(null==(n=u.detail)?void 0:n.children))for(let n=0;n<u.detail.children.length;n++){const d=u.detail.children[n];if(!0!==(null==(i=null==d?void 0:d.operations)?void 0:i.invisible)){if(!d)break;if(lt(t,{context2d:r,element:{x:o+d.x,y:a+d.y,w:d.w,h:d.h,angle:f+(d.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){h.element=d,(e<c.length-1||"group"!==d.type)&&(h.groupQueueIndex=e);break}}}if(h.element)break}if(h.element)return h;for(let e=a.elements.length-1;e>=0;e--){const n=a.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&lt(t,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){h.index=e,h.element=n;break}}return h},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.insertElementToListByPosition=zt,t.is=E,t.isAssetId=p,t.isColorStr=d,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:a}=t,{x:l,y:s,w:c,h:h}=rt(t,{viewScaleInfo:i,viewSizeInfo:n}),f=U({x:l,y:s,w:c,h:h,angle:a}),u={x:0,y:0,w:o,h:r},d=Math.min(f[0].x,f[1].x,f[2].x,f[3].x),g=Math.min(f[0].y,f[1].y,f[2].y,f[3].y);return _(u,{x:d,y:g,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)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=lt,t.istype=b,t.limitAngle=X,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"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},a.onerror=function(t){o(t)}}))}(t,e);return await R(n)},t.loadImage=R,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 R(e)},t.matrixToAngle=function(t){const e=Mt(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=Mt,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.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.modifyElement=function(t,e){const{type:n}=e,i={...e.content};if("addElement"===n){const n=e,{element:i,position:o}=n.content;(null==o?void 0:o.length)>0?zt(i,[...o],t.elements):t.elements.push(i)}else if("deleteElement"===n){const n=e,{position:i}=n.content;Ot(i,t.elements)}else if("moveElement"===n){const n=e,{from:o,to:r}=n.content,a=Tt(t.elements,{from:o,to:r});i.from=a.from,i.to=a.to,t.elements=a.elements}else if("updateElement"===n){const n=e,{position:i,afterModifiedElement:o}=n.content;jt(i,o,t.elements)}return{data:t,content:i}},t.moveElementPosition=Tt,t.originRectInfoToRangeRectInfo=ct,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(yt,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,h=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(l){if(o++,i=wt(r),!i.isVoid&&h&&"<"!==h){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((!l||!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]),"<"!==h&&h)){f=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);xt.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(dt,((t,n,i)=>{const o=i.match(gt),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.rotateByCenter=F,t.rotateElement=function(t,e,n){const i=H(e);F(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=U,t.rotatePoint=Q,t.rotatePointInGroup=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:a,angle:l=0}=t,s=Q(H({x:e,y:o,w:r,h:a,angle:l}),{x:n,y:i},V(l));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=Y,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=x(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=x(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=x(e);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.sortElementsViewVisiableInfoMap=function(t,e){const n={},i=[],o=e=>{const r={isVisibleInView:!0,isGroup:"group"===e.type,position:[...i]};let a=null;a=st(e,{groupQueue:Z(t,i)||[]}),n[e.uuid]={...r,originRectInfo:a,rangeRectInfo:E.angle(e.angle)?ct(a):a},"group"===e.type&&e.detail.children.forEach(((t,e)=>{i.push(e),o(t),i.pop()}))};return t.forEach(((t,e)=>{i.push(e),o(t),i.pop()})),ht(n,e)},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.updateElementInList=function t(e,n,i){var o,r;let a=null;for(let l=0;l<i.length;l++){const s=i[l];if(s.uuid===e){"group"===s.type&&!0===(null==(o=s.operations)?void 0:o.deepResize)&&(n.w&&n.w>0||n.h&&n.h>0)&&At(s,{w:n.w,h:n.h}),Dt(s,n),a=s;break}"group"===s.type&&(a=t(e,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return a},t.updateElementInListByPosition=jt,t.updateViewVisibleInfoMapStatus=ht,t.vaildPoint=j,t.vaildTouchPoint=function(t){return!0===j(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,a=e/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:a,height:l,contextWidth:s,contextHeight:c}=o;let h=i.offsetLeft,f=i.offsetRight,u=i.offsetTop,d=i.offsetBottom;return h+=e,u+=n,f=a-(s*r+h),d=l-(c*r+u),{scale:r,offsetTop:u,offsetLeft:h,offsetRight:f,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-beta.16",
3
+ "version": "0.4.0-beta.18",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",