@idraw/util 0.4.0-beta.4 → 0.4.0-beta.5

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.
@@ -2,7 +2,7 @@ export { delay, compose, throttle } from './lib/time';
2
2
  export { downloadImageFromCanvas, parseFileToBase64, pickFile, parseFileToText, downloadFileFromText } from './lib/file';
3
3
  export { toColorHexStr, toColorHexNum, isColorStr, colorNameToHex, colorToCSS, colorToLinearGradientCSS, mergeHexColorAlpha } from './lib/color';
4
4
  export { createUUID, isAssetId, createAssetId } from './lib/uuid';
5
- export { deepClone, sortDataAsserts } from './lib/data';
5
+ export { deepClone, sortDataAsserts, deepCloneElement } from './lib/data';
6
6
  export { istype } from './lib/istype';
7
7
  export { loadImage, loadSVG, loadHTML } from './lib/load';
8
8
  export { is } from './lib/is';
@@ -28,3 +28,4 @@ export { matrixToAngle, matrixToRadian } from './lib/matrix';
28
28
  export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './lib/config';
29
29
  export { calcViewBoxSize } from './lib/view-box';
30
30
  export { createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList } from './lib/handle-element';
31
+ export { deepResizeGroupElement } from './lib/resize-element';
package/dist/esm/index.js CHANGED
@@ -2,7 +2,7 @@ export { delay, compose, throttle } from './lib/time';
2
2
  export { downloadImageFromCanvas, parseFileToBase64, pickFile, parseFileToText, downloadFileFromText } from './lib/file';
3
3
  export { toColorHexStr, toColorHexNum, isColorStr, colorNameToHex, colorToCSS, colorToLinearGradientCSS, mergeHexColorAlpha } from './lib/color';
4
4
  export { createUUID, isAssetId, createAssetId } from './lib/uuid';
5
- export { deepClone, sortDataAsserts } from './lib/data';
5
+ export { deepClone, sortDataAsserts, deepCloneElement } from './lib/data';
6
6
  export { istype } from './lib/istype';
7
7
  export { loadImage, loadSVG, loadHTML } from './lib/load';
8
8
  export { is } from './lib/is';
@@ -28,3 +28,4 @@ export { matrixToAngle, matrixToRadian } from './lib/matrix';
28
28
  export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './lib/config';
29
29
  export { calcViewBoxSize } from './lib/view-box';
30
30
  export { createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList } from './lib/handle-element';
31
+ export { deepResizeGroupElement } from './lib/resize-element';
@@ -1,14 +1,9 @@
1
- import type { ViewScaleInfo, DefaultElementDetailConfig, ElementRectDetail, ElementCircleDetail, ElementTextDetail, ElementSVGDetail, ElementImageDetail, ElementGroupDetail } from '@idraw/types';
1
+ import type { DefaultElementDetailConfig, ElementSize, ElementRectDetail, ElementCircleDetail, ElementTextDetail, ElementSVGDetail, ElementImageDetail, ElementGroupDetail } from '@idraw/types';
2
+ export declare const defaultText = "Text Element";
2
3
  export declare function getDefaultElementDetailConfig(): DefaultElementDetailConfig;
3
4
  export declare function getDefaultElementRectDetail(): ElementRectDetail;
4
- export declare function getDefaultElementCircleDetail(opts: {
5
- radius: number;
6
- }): ElementCircleDetail;
7
- export declare function getDefaultElementTextDetail(opts?: {
8
- viewScaleInfo: ViewScaleInfo;
9
- }): ElementTextDetail;
5
+ export declare function getDefaultElementCircleDetail(): ElementCircleDetail;
6
+ export declare function getDefaultElementTextDetail(elementSize: ElementSize): ElementTextDetail;
10
7
  export declare function getDefaultElementSVGDetail(): ElementSVGDetail;
11
8
  export declare function getDefaultElementImageDetail(): ElementImageDetail;
12
- export declare function getDefaultElementGroupDetail(opts?: {
13
- viewScaleInfo: ViewScaleInfo;
14
- }): ElementGroupDetail;
9
+ export declare function getDefaultElementGroupDetail(): ElementGroupDetail;
@@ -1,3 +1,4 @@
1
+ export const defaultText = 'Text Element';
1
2
  export function getDefaultElementDetailConfig() {
2
3
  const config = {
3
4
  boxSizing: 'border-box',
@@ -27,24 +28,22 @@ export function getDefaultElementRectDetail() {
27
28
  };
28
29
  return detail;
29
30
  }
30
- export function getDefaultElementCircleDetail(opts) {
31
+ export function getDefaultElementCircleDetail() {
31
32
  const detail = {
32
33
  background: '#D9D9D9',
33
34
  radius: 0
34
35
  };
35
36
  return detail;
36
37
  }
37
- export function getDefaultElementTextDetail(opts) {
38
- var _a;
38
+ export function getDefaultElementTextDetail(elementSize) {
39
39
  const detailConfig = getDefaultElementDetailConfig();
40
- const scale = ((_a = opts === null || opts === void 0 ? void 0 : opts.viewScaleInfo) === null || _a === void 0 ? void 0 : _a.scale) || 1;
41
40
  const detail = {
42
- text: 'Text Element',
41
+ text: defaultText,
43
42
  color: detailConfig.color,
44
43
  fontFamily: detailConfig.fontFamily,
45
44
  fontWeight: detailConfig.fontWeight,
46
- lineHeight: detailConfig.fontSize * scale,
47
- fontSize: detailConfig.fontSize * scale,
45
+ lineHeight: elementSize.w / defaultText.length,
46
+ fontSize: elementSize.w / defaultText.length,
48
47
  textAlign: 'center',
49
48
  verticalAlign: 'middle'
50
49
  };
@@ -62,7 +61,7 @@ export function getDefaultElementImageDetail() {
62
61
  };
63
62
  return detail;
64
63
  }
65
- export function getDefaultElementGroupDetail(opts) {
64
+ export function getDefaultElementGroupDetail() {
66
65
  const detail = {
67
66
  children: [],
68
67
  background: '#D9D9D9',
@@ -1,5 +1,6 @@
1
- import type { Data } from '@idraw/types';
2
- export declare function deepClone<T extends any = any>(target: T): T;
1
+ import type { Data, Element } from '@idraw/types';
2
+ export declare function deepClone<T = any>(target: T): T;
3
+ export declare function deepCloneElement<T extends Element = Element>(element: T): T;
3
4
  export declare function sortDataAsserts(data: Data, opts?: {
4
5
  clone?: boolean;
5
6
  }): Data;
@@ -1,4 +1,4 @@
1
- import { createAssetId } from './uuid';
1
+ import { createAssetId, createUUID } from './uuid';
2
2
  export function deepClone(target) {
3
3
  function _clone(t) {
4
4
  const type = is(t);
@@ -27,6 +27,19 @@ export function deepClone(target) {
27
27
  }
28
28
  return _clone(target);
29
29
  }
30
+ export function deepCloneElement(element) {
31
+ const elem = deepClone(element);
32
+ const _resetUUID = (e) => {
33
+ e.uuid = createUUID();
34
+ if (e.type === 'group' && e.detail.children) {
35
+ e.detail.children.forEach((child) => {
36
+ _resetUUID(child);
37
+ });
38
+ }
39
+ };
40
+ _resetUUID(elem);
41
+ return elem;
42
+ }
30
43
  function is(target) {
31
44
  return Object.prototype.toString
32
45
  .call(target)
@@ -1,10 +1,10 @@
1
1
  import { createUUID } from './uuid';
2
- import { getDefaultElementDetailConfig, getDefaultElementRectDetail, getDefaultElementCircleDetail, getDefaultElementTextDetail, getDefaultElementSVGDetail, getDefaultElementImageDetail, getDefaultElementGroupDetail } from './config';
2
+ import { defaultText, getDefaultElementRectDetail, getDefaultElementCircleDetail, getDefaultElementTextDetail, getDefaultElementSVGDetail, getDefaultElementImageDetail, getDefaultElementGroupDetail } from './config';
3
3
  import { istype } from './istype';
4
4
  import { findElementFromListByPosition, getElementPositionFromList } from './element';
5
+ import { deepResizeGroupElement } from './resize-element';
5
6
  const defaultViewWidth = 200;
6
7
  const defaultViewHeight = 200;
7
- const defaultDetail = getDefaultElementDetailConfig();
8
8
  function createElementSize(type, opts) {
9
9
  let x = 0;
10
10
  let y = 0;
@@ -14,29 +14,26 @@ function createElementSize(type, opts) {
14
14
  const { viewScaleInfo, viewSizeInfo } = opts;
15
15
  const { scale, offsetLeft, offsetTop } = viewScaleInfo;
16
16
  const { width, height } = viewSizeInfo;
17
- if (type === 'text') {
18
- const textDetail = getDefaultElementTextDetail();
19
- w = defaultDetail.fontSize * scale * textDetail.text.length;
20
- h = defaultDetail.fontSize * scale * 2;
17
+ const limitViewWidth = width / 4;
18
+ const limitViewHeight = height / 4;
19
+ if (defaultViewWidth >= limitViewWidth) {
20
+ w = limitViewWidth / scale;
21
21
  }
22
22
  else {
23
- const limitViewWidth = width / 4;
24
- const limitViewHeight = height / 4;
25
- if (defaultViewWidth >= limitViewWidth) {
26
- w = limitViewWidth / scale;
27
- }
28
- else {
29
- w = defaultViewWidth / scale;
30
- }
31
- if (defaultViewHeight >= limitViewHeight) {
32
- h = limitViewHeight / scale;
33
- }
34
- else {
35
- h = defaultViewHeight / scale;
36
- }
37
- if (['circle', 'svg', 'image'].includes(type)) {
38
- w = h = Math.max(w, h);
39
- }
23
+ w = defaultViewWidth / scale;
24
+ }
25
+ if (defaultViewHeight >= limitViewHeight) {
26
+ h = limitViewHeight / scale;
27
+ }
28
+ else {
29
+ h = defaultViewHeight / scale;
30
+ }
31
+ if (['circle', 'svg', 'image'].includes(type)) {
32
+ w = h = Math.max(w, h);
33
+ }
34
+ else if (type === 'text') {
35
+ const fontSize = w / defaultText.length;
36
+ h = fontSize * 2;
40
37
  }
41
38
  x = (0 - offsetLeft + width / 2 - (w * scale) / 2) / scale;
42
39
  y = (0 - offsetTop + height / 2 - (h * scale) / 2) / scale;
@@ -50,18 +47,16 @@ function createElementSize(type, opts) {
50
47
  return elemSize;
51
48
  }
52
49
  export function createElement(type, baseElem, opts) {
53
- const elemSize = createElementSize(type, opts);
50
+ const elementSize = createElementSize(type, opts);
54
51
  let detail = {};
55
52
  if (type === 'rect') {
56
53
  detail = getDefaultElementRectDetail();
57
54
  }
58
55
  else if (type === 'circle') {
59
- detail = getDefaultElementCircleDetail({
60
- radius: elemSize.w
61
- });
56
+ detail = getDefaultElementCircleDetail();
62
57
  }
63
58
  else if (type === 'text') {
64
- detail = getDefaultElementTextDetail(opts);
59
+ detail = getDefaultElementTextDetail(elementSize);
65
60
  }
66
61
  else if (type === 'svg') {
67
62
  detail = getDefaultElementSVGDetail();
@@ -72,7 +67,7 @@ export function createElement(type, baseElem, opts) {
72
67
  else if (type === 'group') {
73
68
  detail = getDefaultElementGroupDetail();
74
69
  }
75
- const elem = Object.assign(Object.assign(Object.assign({}, elemSize), baseElem), { uuid: createUUID(), type, detail: Object.assign(Object.assign({}, detail), (baseElem.detail || {})) });
70
+ const elem = Object.assign(Object.assign(Object.assign({}, elementSize), baseElem), { uuid: createUUID(), type, detail: Object.assign(Object.assign({}, detail), (baseElem.detail || {})) });
76
71
  return elem;
77
72
  }
78
73
  export function insertElementToListByPosition(element, position, list) {
@@ -209,17 +204,25 @@ function mergeElement(originElem, updateContent) {
209
204
  return originElem;
210
205
  }
211
206
  export function updateElementInList(uuid, updateContent, elements) {
212
- var _a;
207
+ var _a, _b;
213
208
  let targetElement = null;
214
209
  for (let i = 0; i < elements.length; i++) {
215
210
  const elem = elements[i];
216
211
  if (elem.uuid === uuid) {
212
+ if (elem.type === 'group' && ((_a = elem.operations) === null || _a === void 0 ? void 0 : _a.deepResize) === true) {
213
+ if ((updateContent.w && updateContent.w > 0) || (updateContent.h && updateContent.h > 0)) {
214
+ deepResizeGroupElement(elem, {
215
+ w: updateContent.w,
216
+ h: updateContent.h
217
+ });
218
+ }
219
+ }
217
220
  mergeElement(elem, updateContent);
218
221
  targetElement = elem;
219
222
  break;
220
223
  }
221
224
  else if (elem.type === 'group') {
222
- targetElement = updateElementInList(uuid, updateContent, ((_a = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _a === void 0 ? void 0 : _a.children) || []);
225
+ targetElement = updateElementInList(uuid, updateContent, ((_b = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _b === void 0 ? void 0 : _b.children) || []);
223
226
  }
224
227
  }
225
228
  return targetElement;
@@ -0,0 +1,2 @@
1
+ import type { Element, ElementSize } from '@idraw/types';
2
+ export declare function deepResizeGroupElement(elem: Element<'group'>, size: Pick<Partial<ElementSize>, 'w' | 'h'>): Element<'group'>;
@@ -0,0 +1,101 @@
1
+ import { formatNumber } from './number';
2
+ const doNum = (n) => {
3
+ return formatNumber(n, { decimalPlaces: 4 });
4
+ };
5
+ function resizeElementBaseDetail(elem, opts) {
6
+ const { detail } = elem;
7
+ const { xRatio, yRatio, maxRatio } = opts;
8
+ const middleRatio = (xRatio + yRatio) / 2;
9
+ const { borderWidth, borderRadius, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
10
+ if (typeof borderWidth === 'number') {
11
+ detail.borderWidth = doNum(borderWidth * middleRatio);
12
+ }
13
+ else if (Array.isArray(detail.borderWidth)) {
14
+ const bw = borderWidth;
15
+ detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
16
+ }
17
+ if (typeof borderRadius === 'number') {
18
+ detail.borderRadius = doNum(borderRadius * middleRatio);
19
+ }
20
+ else if (Array.isArray(detail.borderRadius)) {
21
+ const br = borderRadius;
22
+ detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
23
+ }
24
+ if (Array.isArray(borderDash)) {
25
+ borderDash.forEach((dash, i) => {
26
+ detail.borderDash[i] = doNum(dash * maxRatio);
27
+ });
28
+ }
29
+ if (typeof shadowOffsetX === 'number') {
30
+ detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
31
+ }
32
+ if (typeof shadowOffsetY === 'number') {
33
+ detail.shadowOffsetX = doNum(shadowOffsetY * maxRatio);
34
+ }
35
+ if (typeof shadowBlur === 'number') {
36
+ detail.shadowOffsetX = doNum(shadowBlur * maxRatio);
37
+ }
38
+ }
39
+ function resizeElementBase(elem, opts) {
40
+ const { xRatio, yRatio } = opts;
41
+ const { x, y, w, h } = elem;
42
+ elem.x = doNum(x * xRatio);
43
+ elem.y = doNum(y * yRatio);
44
+ elem.w = doNum(w * xRatio);
45
+ elem.h = doNum(h * yRatio);
46
+ resizeElementBaseDetail(elem, opts);
47
+ }
48
+ function resizeTextElementDetail(elem, opts) {
49
+ const { minRatio, maxRatio } = opts;
50
+ const { fontSize, lineHeight } = elem.detail;
51
+ const ratio = (minRatio + maxRatio) / 2;
52
+ if (fontSize && fontSize > 0) {
53
+ elem.detail.fontSize = doNum(fontSize * ratio);
54
+ }
55
+ if (lineHeight && lineHeight > 0) {
56
+ elem.detail.lineHeight = doNum(lineHeight * ratio);
57
+ }
58
+ }
59
+ function resizeElement(elem, opts) {
60
+ const { type } = elem;
61
+ resizeElementBase(elem, opts);
62
+ if (type === 'circle') {
63
+ }
64
+ else if (type === 'text') {
65
+ resizeTextElementDetail(elem, opts);
66
+ }
67
+ else if (type === 'image') {
68
+ }
69
+ else if (type === 'svg') {
70
+ }
71
+ else if (type === 'html') {
72
+ }
73
+ else if (type === 'path') {
74
+ }
75
+ else if (type === 'group' && Array.isArray(elem.detail.children)) {
76
+ elem.detail.children.forEach((child) => {
77
+ resizeElement(child, opts);
78
+ });
79
+ }
80
+ }
81
+ export function deepResizeGroupElement(elem, size) {
82
+ const resizeW = size.w && size.w > 0 ? size.w : elem.w;
83
+ const resizeH = size.h && size.h > 0 ? size.h : elem.h;
84
+ const xRatio = resizeW / elem.w;
85
+ const yRatio = resizeH / elem.h;
86
+ if (xRatio === yRatio && xRatio === 1) {
87
+ return elem;
88
+ }
89
+ const minRatio = Math.min(xRatio, yRatio);
90
+ const maxRatio = Math.max(xRatio, yRatio);
91
+ elem.w = resizeW;
92
+ elem.h = resizeH;
93
+ const opts = { xRatio, yRatio, minRatio, maxRatio };
94
+ if (elem.type === 'group' && Array.isArray(elem.detail.children)) {
95
+ elem.detail.children.forEach((child) => {
96
+ resizeElement(child, opts);
97
+ });
98
+ }
99
+ resizeElementBaseDetail(elem, opts);
100
+ return elem;
101
+ }
@@ -5,7 +5,7 @@ export function calcViewBoxSize(viewElem, opts) {
5
5
  const { scale } = viewScaleInfo;
6
6
  let { borderRadius } = viewElem.detail;
7
7
  const { boxSizing = defaultElemConfig.boxSizing, borderWidth } = viewElem.detail;
8
- if (typeof borderWidth !== 'number') {
8
+ if (Array.isArray(borderWidth)) {
9
9
  borderRadius = 0;
10
10
  }
11
11
  let { x, y, w, h } = viewElem;
@@ -422,6 +422,19 @@ var __privateSet = (obj, member, value, setter) => {
422
422
  }
423
423
  return _clone(target);
424
424
  }
425
+ function deepCloneElement(element) {
426
+ const elem = deepClone(element);
427
+ const _resetUUID = (e) => {
428
+ e.uuid = createUUID();
429
+ if (e.type === "group" && e.detail.children) {
430
+ e.detail.children.forEach((child) => {
431
+ _resetUUID(child);
432
+ });
433
+ }
434
+ };
435
+ _resetUUID(elem);
436
+ return elem;
437
+ }
425
438
  function is$1(target) {
426
439
  return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
427
440
  }
@@ -2441,6 +2454,7 @@ var __privateSet = (obj, member, value, setter) => {
2441
2454
  }
2442
2455
  return radian;
2443
2456
  }
2457
+ const defaultText = "Text Element";
2444
2458
  function getDefaultElementDetailConfig() {
2445
2459
  const config = {
2446
2460
  boxSizing: "border-box",
@@ -2470,24 +2484,22 @@ var __privateSet = (obj, member, value, setter) => {
2470
2484
  };
2471
2485
  return detail;
2472
2486
  }
2473
- function getDefaultElementCircleDetail(opts) {
2487
+ function getDefaultElementCircleDetail() {
2474
2488
  const detail = {
2475
2489
  background: "#D9D9D9",
2476
2490
  radius: 0
2477
2491
  };
2478
2492
  return detail;
2479
2493
  }
2480
- function getDefaultElementTextDetail(opts) {
2481
- var _a;
2494
+ function getDefaultElementTextDetail(elementSize) {
2482
2495
  const detailConfig = getDefaultElementDetailConfig();
2483
- const scale = ((_a = opts == null ? void 0 : opts.viewScaleInfo) == null ? void 0 : _a.scale) || 1;
2484
2496
  const detail = {
2485
- text: "Text Element",
2497
+ text: defaultText,
2486
2498
  color: detailConfig.color,
2487
2499
  fontFamily: detailConfig.fontFamily,
2488
2500
  fontWeight: detailConfig.fontWeight,
2489
- lineHeight: detailConfig.fontSize * scale,
2490
- fontSize: detailConfig.fontSize * scale,
2501
+ lineHeight: elementSize.w / defaultText.length,
2502
+ fontSize: elementSize.w / defaultText.length,
2491
2503
  textAlign: "center",
2492
2504
  verticalAlign: "middle"
2493
2505
  };
@@ -2505,7 +2517,7 @@ var __privateSet = (obj, member, value, setter) => {
2505
2517
  };
2506
2518
  return detail;
2507
2519
  }
2508
- function getDefaultElementGroupDetail(opts) {
2520
+ function getDefaultElementGroupDetail() {
2509
2521
  const detail = {
2510
2522
  children: [],
2511
2523
  background: "#D9D9D9",
@@ -2519,7 +2531,7 @@ var __privateSet = (obj, member, value, setter) => {
2519
2531
  const { scale } = viewScaleInfo;
2520
2532
  let { borderRadius: borderRadius2 } = viewElem.detail;
2521
2533
  const { boxSizing = defaultElemConfig.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
2522
- if (typeof borderWidth2 !== "number") {
2534
+ if (Array.isArray(borderWidth2)) {
2523
2535
  borderRadius2 = 0;
2524
2536
  }
2525
2537
  let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
@@ -2563,9 +2575,105 @@ var __privateSet = (obj, member, value, setter) => {
2563
2575
  radiusList
2564
2576
  };
2565
2577
  }
2578
+ const doNum = (n) => {
2579
+ return formatNumber(n, { decimalPlaces: 4 });
2580
+ };
2581
+ function resizeElementBaseDetail(elem, opts) {
2582
+ const { detail } = elem;
2583
+ const { xRatio, yRatio, maxRatio } = opts;
2584
+ const middleRatio = (xRatio + yRatio) / 2;
2585
+ const { borderWidth: borderWidth2, borderRadius: borderRadius2, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
2586
+ if (typeof borderWidth2 === "number") {
2587
+ detail.borderWidth = doNum(borderWidth2 * middleRatio);
2588
+ } else if (Array.isArray(detail.borderWidth)) {
2589
+ const bw = borderWidth2;
2590
+ detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
2591
+ }
2592
+ if (typeof borderRadius2 === "number") {
2593
+ detail.borderRadius = doNum(borderRadius2 * middleRatio);
2594
+ } else if (Array.isArray(detail.borderRadius)) {
2595
+ const br = borderRadius2;
2596
+ detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
2597
+ }
2598
+ if (Array.isArray(borderDash)) {
2599
+ borderDash.forEach((dash, i) => {
2600
+ detail.borderDash[i] = doNum(dash * maxRatio);
2601
+ });
2602
+ }
2603
+ if (typeof shadowOffsetX === "number") {
2604
+ detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
2605
+ }
2606
+ if (typeof shadowOffsetY === "number") {
2607
+ detail.shadowOffsetX = doNum(shadowOffsetY * maxRatio);
2608
+ }
2609
+ if (typeof shadowBlur === "number") {
2610
+ detail.shadowOffsetX = doNum(shadowBlur * maxRatio);
2611
+ }
2612
+ }
2613
+ function resizeElementBase(elem, opts) {
2614
+ const { xRatio, yRatio } = opts;
2615
+ const { x: x2, y: y2, w: w2, h: h2 } = elem;
2616
+ elem.x = doNum(x2 * xRatio);
2617
+ elem.y = doNum(y2 * yRatio);
2618
+ elem.w = doNum(w2 * xRatio);
2619
+ elem.h = doNum(h2 * yRatio);
2620
+ resizeElementBaseDetail(elem, opts);
2621
+ }
2622
+ function resizeTextElementDetail(elem, opts) {
2623
+ const { minRatio, maxRatio } = opts;
2624
+ const { fontSize: fontSize2, lineHeight: lineHeight2 } = elem.detail;
2625
+ const ratio = (minRatio + maxRatio) / 2;
2626
+ if (fontSize2 && fontSize2 > 0) {
2627
+ elem.detail.fontSize = doNum(fontSize2 * ratio);
2628
+ }
2629
+ if (lineHeight2 && lineHeight2 > 0) {
2630
+ elem.detail.lineHeight = doNum(lineHeight2 * ratio);
2631
+ }
2632
+ }
2633
+ function resizeElement(elem, opts) {
2634
+ const { type } = elem;
2635
+ resizeElementBase(elem, opts);
2636
+ if (type === "circle")
2637
+ ;
2638
+ else if (type === "text") {
2639
+ resizeTextElementDetail(elem, opts);
2640
+ } else if (type === "image")
2641
+ ;
2642
+ else if (type === "svg")
2643
+ ;
2644
+ else if (type === "html")
2645
+ ;
2646
+ else if (type === "path")
2647
+ ;
2648
+ else if (type === "group" && Array.isArray(elem.detail.children)) {
2649
+ elem.detail.children.forEach((child) => {
2650
+ resizeElement(child, opts);
2651
+ });
2652
+ }
2653
+ }
2654
+ function deepResizeGroupElement(elem, size) {
2655
+ const resizeW = size.w && size.w > 0 ? size.w : elem.w;
2656
+ const resizeH = size.h && size.h > 0 ? size.h : elem.h;
2657
+ const xRatio = resizeW / elem.w;
2658
+ const yRatio = resizeH / elem.h;
2659
+ if (xRatio === yRatio && xRatio === 1) {
2660
+ return elem;
2661
+ }
2662
+ const minRatio = Math.min(xRatio, yRatio);
2663
+ const maxRatio = Math.max(xRatio, yRatio);
2664
+ elem.w = resizeW;
2665
+ elem.h = resizeH;
2666
+ const opts = { xRatio, yRatio, minRatio, maxRatio };
2667
+ if (elem.type === "group" && Array.isArray(elem.detail.children)) {
2668
+ elem.detail.children.forEach((child) => {
2669
+ resizeElement(child, opts);
2670
+ });
2671
+ }
2672
+ resizeElementBaseDetail(elem, opts);
2673
+ return elem;
2674
+ }
2566
2675
  const defaultViewWidth = 200;
2567
2676
  const defaultViewHeight = 200;
2568
- const defaultDetail = getDefaultElementDetailConfig();
2569
2677
  function createElementSize(type, opts) {
2570
2678
  let x2 = 0;
2571
2679
  let y2 = 0;
@@ -2575,26 +2683,23 @@ var __privateSet = (obj, member, value, setter) => {
2575
2683
  const { viewScaleInfo, viewSizeInfo } = opts;
2576
2684
  const { scale, offsetLeft, offsetTop } = viewScaleInfo;
2577
2685
  const { width, height } = viewSizeInfo;
2578
- if (type === "text") {
2579
- const textDetail = getDefaultElementTextDetail();
2580
- w2 = defaultDetail.fontSize * scale * textDetail.text.length;
2581
- h2 = defaultDetail.fontSize * scale * 2;
2686
+ const limitViewWidth = width / 4;
2687
+ const limitViewHeight = height / 4;
2688
+ if (defaultViewWidth >= limitViewWidth) {
2689
+ w2 = limitViewWidth / scale;
2582
2690
  } else {
2583
- const limitViewWidth = width / 4;
2584
- const limitViewHeight = height / 4;
2585
- if (defaultViewWidth >= limitViewWidth) {
2586
- w2 = limitViewWidth / scale;
2587
- } else {
2588
- w2 = defaultViewWidth / scale;
2589
- }
2590
- if (defaultViewHeight >= limitViewHeight) {
2591
- h2 = limitViewHeight / scale;
2592
- } else {
2593
- h2 = defaultViewHeight / scale;
2594
- }
2595
- if (["circle", "svg", "image"].includes(type)) {
2596
- w2 = h2 = Math.max(w2, h2);
2597
- }
2691
+ w2 = defaultViewWidth / scale;
2692
+ }
2693
+ if (defaultViewHeight >= limitViewHeight) {
2694
+ h2 = limitViewHeight / scale;
2695
+ } else {
2696
+ h2 = defaultViewHeight / scale;
2697
+ }
2698
+ if (["circle", "svg", "image"].includes(type)) {
2699
+ w2 = h2 = Math.max(w2, h2);
2700
+ } else if (type === "text") {
2701
+ const fontSize2 = w2 / defaultText.length;
2702
+ h2 = fontSize2 * 2;
2598
2703
  }
2599
2704
  x2 = (0 - offsetLeft + width / 2 - w2 * scale / 2) / scale;
2600
2705
  y2 = (0 - offsetTop + height / 2 - h2 * scale / 2) / scale;
@@ -2608,16 +2713,14 @@ var __privateSet = (obj, member, value, setter) => {
2608
2713
  return elemSize;
2609
2714
  }
2610
2715
  function createElement(type, baseElem, opts) {
2611
- const elemSize = createElementSize(type, opts);
2716
+ const elementSize = createElementSize(type, opts);
2612
2717
  let detail = {};
2613
2718
  if (type === "rect") {
2614
2719
  detail = getDefaultElementRectDetail();
2615
2720
  } else if (type === "circle") {
2616
- detail = getDefaultElementCircleDetail({
2617
- radius: elemSize.w
2618
- });
2721
+ detail = getDefaultElementCircleDetail();
2619
2722
  } else if (type === "text") {
2620
- detail = getDefaultElementTextDetail(opts);
2723
+ detail = getDefaultElementTextDetail(elementSize);
2621
2724
  } else if (type === "svg") {
2622
2725
  detail = getDefaultElementSVGDetail();
2623
2726
  } else if (type === "image") {
@@ -2626,7 +2729,7 @@ var __privateSet = (obj, member, value, setter) => {
2626
2729
  detail = getDefaultElementGroupDetail();
2627
2730
  }
2628
2731
  const elem = {
2629
- ...elemSize,
2732
+ ...elementSize,
2630
2733
  ...baseElem,
2631
2734
  uuid: createUUID(),
2632
2735
  type,
@@ -2762,16 +2865,24 @@ var __privateSet = (obj, member, value, setter) => {
2762
2865
  return originElem;
2763
2866
  }
2764
2867
  function updateElementInList(uuid, updateContent, elements) {
2765
- var _a;
2868
+ var _a, _b;
2766
2869
  let targetElement = null;
2767
2870
  for (let i = 0; i < elements.length; i++) {
2768
2871
  const elem = elements[i];
2769
2872
  if (elem.uuid === uuid) {
2873
+ if (elem.type === "group" && ((_a = elem.operations) == null ? void 0 : _a.deepResize) === true) {
2874
+ if (updateContent.w && updateContent.w > 0 || updateContent.h && updateContent.h > 0) {
2875
+ deepResizeGroupElement(elem, {
2876
+ w: updateContent.w,
2877
+ h: updateContent.h
2878
+ });
2879
+ }
2880
+ }
2770
2881
  mergeElement(elem, updateContent);
2771
2882
  targetElement = elem;
2772
2883
  break;
2773
2884
  } else if (elem.type === "group") {
2774
- targetElement = updateElementInList(uuid, updateContent, ((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.children) || []);
2885
+ targetElement = updateElementInList(uuid, updateContent, ((_b = elem == null ? void 0 : elem.detail) == null ? void 0 : _b.children) || []);
2775
2886
  }
2776
2887
  }
2777
2888
  return targetElement;
@@ -2809,6 +2920,8 @@ var __privateSet = (obj, member, value, setter) => {
2809
2920
  exports.createOffscreenContext2D = createOffscreenContext2D;
2810
2921
  exports.createUUID = createUUID;
2811
2922
  exports.deepClone = deepClone;
2923
+ exports.deepCloneElement = deepCloneElement;
2924
+ exports.deepResizeGroupElement = deepResizeGroupElement;
2812
2925
  exports.delay = delay;
2813
2926
  exports.deleteElementInList = deleteElementInList;
2814
2927
  exports.deleteElementInListByPosition = deleteElementInListByPosition;
@@ -1 +1 @@
1
- var iDrawUtil=function(t){"use strict";var e,n,i=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},o=(t,e,n)=>(i(t,e,"read from private field"),n?n.call(t):e.get(t)),r=(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)},a=(t,e,n,o)=>(i(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);function l(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 s={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 c(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function u(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 h(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/${u(e.toString(16).padEnd(4,i))}${u(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${u(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${u(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${u(t.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${u(t.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${u(t.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${u(o.padEnd(4,i).padEnd(4,o))}`}function f(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 d(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 g(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const x={type(t,e){const n=g(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===g(t),json:t=>"Object"===g(t),function:t=>"Function"===g(t),asyncFunction:t=>"AsyncFunction"===g(t),string:t=>"String"===g(t),number:t=>"Number"===g(t),undefined:t=>"Undefined"===g(t),null:t=>"Null"===g(t),promise:t=>"Promise"===g(t)};const{Image:y}=window;function m(t){return new Promise(((e,n)=>{const i=new y;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 w(t){return"number"==typeof t&&t>=0}function v(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function b(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const P={x:function(t){return p(t)},y:function(t){return p(t)},w:w,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 w(t)},borderRadius:function(t){return p(t)&&t>=0},color:function(t){return l(t)},imageSrc:function(t){return b(t)||v(t)},imageURL:v,imageBase64:b,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 M(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!P.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!P.number(n))&&!(t.hasOwnProperty("borderWidth")&&!P.number(i)))}const I={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(P.x(e)&&P.y(n)&&P.w(i)&&P.h(o)&&P.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:u}=t;return!!P.text(e)&&(!!P.color(n)&&(!!P.fontSize(i)&&(!(t.hasOwnProperty("background")&&!P.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!P.fontWeight(l))&&(!(t.hasOwnProperty("lineHeight")&&!P.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!P.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!P.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!P.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!P.color(u))&&!!M(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!P.color(e))&&!!M(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!P.color(e))&&(!(t.hasOwnProperty("borderColor")&&!P.color(n))&&!(t.hasOwnProperty("borderWidth")&&!P.number(i)))},imageDesc:function(t){const{src:e}=t;return!!P.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!P.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!P.html(e)}};class R{constructor(t,i){r(this,e,void 0),r(this,n,void 0),a(this,e,t),a(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i})}$undoPixelRatio(t){return t/o(this,n).devicePixelRatio}$doPixelRatio(t){return o(this,n).devicePixelRatio*t}$getContext(){return o(this,e)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),o(this,e).font=`${n.join(" ")}`}$getOffscreenCanvas(){return o(this,n).offscreenCanvas}$resize(t){const{width:i,height:r,devicePixelRatio:l,resetStyle:s}=t,{canvas:c}=o(this,e);c.width=i*l,c.height=r*l,a(this,n,{...o(this,n),devicePixelRatio:l}),!0===s&&(c.style.width=`${i}px`,c.style.height=`${r}px`)}$getSize(){const{devicePixelRatio:t}=o(this,n),{width:i,height:r}=o(this,e).canvas;return{width:i/t,height:r/t,devicePixelRatio:t}}get canvas(){return o(this,e).canvas}get fillStyle(){return o(this,e).fillStyle}set fillStyle(t){o(this,e).fillStyle=t}get strokeStyle(){return o(this,e).strokeStyle}set strokeStyle(t){o(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(o(this,e).lineWidth)}set lineWidth(t){o(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return o(this,e).textAlign}set textAlign(t){o(this,e).textAlign=t}get textBaseline(){return o(this,e).textBaseline}set textBaseline(t){o(this,e).textBaseline=t}get globalAlpha(){return o(this,e).globalAlpha}set globalAlpha(t){o(this,e).globalAlpha=t}get shadowColor(){return o(this,e).shadowColor}set shadowColor(t){o(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(o(this,e).shadowOffsetX)}set shadowOffsetX(t){o(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(o(this,e).shadowOffsetY)}set shadowOffsetY(t){o(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(o(this,e).shadowBlur)}set shadowBlur(t){o(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return o(this,e).lineCap}set lineCap(t){o(this,e).lineCap=t}get globalCompositeOperation(){return o(this,e).globalCompositeOperation}set globalCompositeOperation(t){o(this,e).globalCompositeOperation=t}fill(...t){return o(this,e).fill(...t)}arc(t,n,i,r,a,l){return o(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),r,a,l)}rect(t,n,i,r){return o(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}fillRect(t,n,i,r){return o(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}clearRect(t,n,i,r){return o(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}beginPath(){return o(this,e).beginPath()}closePath(){return o(this,e).closePath()}lineTo(t,n){return o(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return o(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,r,a){return o(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a))}getLineDash(){return o(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return o(this,e).setLineDash(n)}stroke(t){return t?o(this,e).stroke(t):o(this,e).stroke()}translate(t,n){return o(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return o(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],r=t[2],a=t[3],l=t[4],s=t[t.length-4],c=t[t.length-3],u=t[t.length-2],h=t[t.length-1];return 9===t.length?o(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u),this.$doPixelRatio(h)):o(this,e).drawImage(n,this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u),this.$doPixelRatio(h))}createPattern(t,n){return o(this,e).createPattern(t,n)}measureText(t){return o(this,e).measureText(t)}fillText(t,n,i,r){return void 0!==r?o(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r)):o(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,r){return void 0!==r?o(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r)):o(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){o(this,e).save()}restore(){o(this,e).restore()}scale(t,n){o(this,e).scale(t,n)}circle(t,n,i,r,a,l,s,c){o(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),a,l,s,c)}isPointInPath(t,n){return o(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return o(this,e).clip(...t)}setTransform(t,n,i,r,a,l){return o(this,e).setTransform(t,n,i,r,a,l)}getTransform(){return o(this,e).getTransform()}createLinearGradient(t,n,i,r){return o(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}createRadialGradient(t,n,i,r,a,l){return o(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l))}createConicGradient(t,n,i){return o(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function $(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 R(r,t)}function S(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 R(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function E(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 A(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function C(t){return t>=0||t<0}function k(t){return C(t.x)&&C(t.y)&&t.t>0}function z(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}function T(t){return t/180*Math.PI}function L(t,e,n,i){const o=T(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 O(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function D(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 O({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function j(t,e,n){const i=function(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}(t,e);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=E(t,e);let a=0,l=0;return 0===o?(a=0,l=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,l=0-Math.cos(o)*r):o===Math.PI/2?(a=r,l=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,l=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,l=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,l=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,l=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,l=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,l=0-r),a+=t.x,l+=t.y,{x:a,y:l}}function W(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},u={x:i,y:o+a};if(n&&(n>0||n<0)){const t=T(H(n));l=j(e,l,t),s=j(e,s,t),c=j(e,c,t),u=j(e,u,t)}return[l,s,c,u]}function F(t){const{angle:e=0}=t;return W(t,O(t),e)}function V(t,e,n){return[j(t,{x:e[0].x,y:e[0].y},n),j(t,{x:e[1].x,y:e[1].y},n),j(t,{x:e[2].x,y:e[2].y},n),j(t,{x:e[3].x,y:e[3].y},n)]}function H(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function N(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=F(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 B(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 G(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 U(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 _(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:a,angle:l}=t,{scale:s,offsetTop:c,offsetLeft:u}=n;return{x:i*s+u,y:o*s+c,w:r*s,h:a*s,angle:l}}function Q(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 Y(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:l,y:s,w:c,h:u}=_(i,{viewScaleInfo:o,viewSizeInfo:r}),h=F({x:l,y:s,w:c,h:u,angle:a});if(h.length>=2){n.beginPath(),n.moveTo(h[0].x,h[0].y);for(let t=1;t<h.length;t++)n.lineTo(h[t].x,h[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function q(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 X(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?q(t):W(t,O({x:e,y:n,w:i,h:o,angle:r}),r)}function Z(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:u=0}=r[t];let h;if(n+=a,i+=l,0===t){const t={x:n,y:i,w:s,h:c,angle:u};h=X({x:a,y:l,w:s,h:c,angle:u}),o.push({center:O(t),angle:u,radian:T(u)})}else{h=q({x:n,y:i,w:s,h:c,angle:u});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];h=V(e,h,n)}const t=D(h);if(u>0||u<0){h=V(t,h,T(u))}o.push({center:t,angle:u,radian:T(u)})}e.push(h)}return e}function J(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[X(t)];return Z([...n,t])}function K(t,e){return J(t,e).pop()||null}function tt(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}}const et=/([astvzqmhlc])([^astvzqmhlc]*)/gi,nt=/(-?\d+(?:\.\d+)?)/gi;const it=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,ot=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,rt=/^\s*$/,at={};function lt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(at[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(it);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 st(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(st,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function ct(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])}function ut(){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 ht(){return{background:"#D9D9D9"}}function ft(t){var e;const n={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"},i=(null==(e=null==t?void 0:t.viewScaleInfo)?void 0:e.scale)||1;return{text:"Text Element",color:n.color,fontFamily:n.fontFamily,fontWeight:n.fontWeight,lineHeight:n.fontSize*i,fontSize:n.fontSize*i,textAlign:"center",verticalAlign:"middle"}}const dt={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 gt=200,xt=200,yt={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(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 pt(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 wt(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)&&(x.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),x.json(t[r])&&(t[r]={...t[r],...e[r]})):x.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),x.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}return t.Context2D=R,t.EventEmitter=class{constructor(){this._listeners=new Map}on(t,e){if(this._listeners.has(t)){const n=this._listeners.get(t)||[];null==n||n.push(e),this._listeners.set(t,n)}else this._listeners.set(t,[e])}off(t,e){if(this._listeners.has(t)){const n=this._listeners.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}this._listeners.set(t,n||[])}}trigger(t,e){const n=this._listeners.get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(this._listeners.has(t)){const e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}},t.Store=class{constructor(t){this._backUpDefaultStorage=d(t.defaultStorage),this._temp=this._createTempStorage()}set(t,e){this._temp[t]=e}get(t){return this._temp[t]}getSnapshot(){return d(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return d(this._backUpDefaultStorage)}},t.calcDistance=E,t.calcElementCenter=O,t.calcElementCenterFromVertexes=D,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=F(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.calcElementQueueVertexesQueueInGroup=Z,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:u,angle:h=0}=t,f=[{uuid:c(),x:a,y:l,w:s,h:u,angle:h,type:"group",detail:{children:[]}},...n];let d=0;f.forEach((({angle:t=0})=>{d+=t}));const g=K(t,{groupQueue:n}),x=z(g[0],g[1]),y=z(g[1],g[2]),m=z(g[2],g[3]),p=z(g[3],g[0]),w=g[0],v=g[1],b=g[2],P=g[3],M=tt(w,{size:r,angle:d}),I=tt(v,{size:r,angle:d}),R=tt(P,{size:r,angle:d}),$=tt(b,{size:r,angle:d}),S=X(M),E=X(I),A=X(R),C=X($),k=[S[1],E[0],E[3],S[2]],T=[E[3],E[2],C[1],C[0]],L=[A[1],C[0],C[3],A[2]];return{elementWrapper:g,left:{type:"left",vertexes:[S[3],S[2],A[1],A[0]],center:p},right:{type:"right",vertexes:T,center:y},top:{type:"top",vertexes:k,center:x},bottom:{type:"bottom",vertexes:L,center:m},topLeft:{type:"top-left",vertexes:S,center:w},topRight:{type:"top-right",vertexes:E,center:v},bottomLeft:{type:"bottom-left",vertexes:A,center:P},bottomRight:{type:"bottom-right",vertexes:C,center:b}}},t.calcElementVertexesInGroup=K,t.calcElementVertexesQueueInGroup=J,t.calcElementsContextSize=N,t.calcElementsViewInfo=function(t,e,n){const i=N(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.calcSpeed=function(t,e){return E(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=dt.boxSizing,borderWidth:a}=t.detail;"number"!=typeof a&&(o=0);let{x:l,y:s,w:c,h:u}=t,h=[0,0,0,0];if("number"==typeof o){const t=o*i;h=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[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,u=t.h-f):"content-box"===r?(l=t.x-f/2,s=t.y-f/2,c=t.w+f,u=t.h+f):(l=t.x,s=t.y,c=t.w,u=t.h),c=Math.max(c,1),u=Math.max(u,1),h=h.map((t=>Math.min(t,c/2,u/2))),{x:l,y:s,w:c,h:u,radiusList:h}},t.calcViewElementSize=_,t.calcViewPointSize=Q,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,u=0-i*n,h=0-o*n;return{scale:n,offsetLeft:u,offsetTop:h,offsetRight:a-(s*n+u/n),offsetBottom:l-(c*n+h/n)}},t.calcViewVertexes=function(t,e){return[Q(t[0],e),Q(t[1],e),Q(t[2],e),Q(t[3],e)]},t.check=I,t.checkRectIntersect=U,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=s[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=h,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r}=e,a={width:n,height:i,devicePixelRatio:o};if(!0===r){const e=t.getContext("2d"),n=S(a),i=S(a),o=S(a),r=$({ctx:e,...a}),l=()=>{const{width:t,height:e}=n.$getSize();r.clearRect(0,0,t,e),r.drawImage(o.canvas,0,0,t,e),r.drawImage(n.canvas,0,0,t,e),r.drawImage(i.canvas,0,0,t,e),o.clearRect(0,0,t,e),n.clearRect(0,0,t,e),i.clearRect(0,0,t,e)};return{underContext:o,viewContext:n,helperContext:i,boardContext:r,drawView:l}}{const e=t.getContext("2d"),o=$(a),r=$(a),l=$(a),s=$({ctx:e,...a}),c=()=>{s.clearRect(0,0,n,i),s.drawImage(l.canvas,0,0,n,i),s.drawImage(o.canvas,0,0,n,i),s.drawImage(r.canvas,0,0,n,i),l.clearRect(0,0,n,i),o.clearRect(0,0,n,i),r.clearRect(0,0,n,i)};return{underContext:l,viewContext:o,helperContext:r,boardContext:s,drawView:c}}},t.createContext2D=$,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=gt,r=xt;if(e){const{viewScaleInfo:a,viewSizeInfo:l}=e,{scale:s,offsetLeft:c,offsetTop:u}=a,{width:h,height:f}=l;if("text"===t){const t=ft();o=yt.fontSize*s*t.text.length,r=yt.fontSize*s*2}else{const e=h/4,n=f/4;o=gt>=e?e/s:gt/s,r=xt>=n?n/s:xt/s,["circle","svg","image"].includes(t)&&(o=r=Math.max(o,r))}n=(0-c+h/2-o*s/2)/s,i=(0-u+f/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?(i.w,o={background:"#D9D9D9",radius:0}):"text"===t?o=ft(n):"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:c(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=S,t.createUUID=c,t.deepClone=d,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return pt(G(t,e),e)},t.deleteElementInListByPosition=pt,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=A,t.equalTouchPoint=function(t,e){return!0===A(t,e)&&t.f===e.f},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||f(i)||(e=h(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=B,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=B(t,e);i&&n.push(i)})),n},t.formatNumber=function(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))},t.generateHTML=function(t){return t.reduce((function(t,e){return t+st("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=z,t.getDefaultElementDetailConfig=ut,t.getDefaultElementRectDetail=ht,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&f(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&f(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=G,t.getElementRotateVertexes=W,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=q,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.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,u={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let e=c.length-1;e>=0;e--){let o=0,a=0,h=0;for(let t=0;t<=e;t++)o+=c[t].x,a+=c[t].y,h+=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(Y(t,{context2d:r,element:{x:o+d.x,y:a+d.y,w:d.w,h:d.h,angle:h+(d.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){u.element=d,(e<c.length-1||"group"!==d.type)&&(u.groupQueueIndex=e);break}}}if(u.element)break}if(u.element)return u;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)&&Y(t,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){u.index=e,u.element=n;break}}return u},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:null==e?void 0:e.scale,offsetTop:null==e?void 0:e.offsetTop,offsetBottom:null==e?void 0:e.offsetBottom,offsetLeft:null==e?void 0:e.offsetLeft,offsetRight:null==e?void 0:e.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:null==e?void 0:e.width,height:null==e?void 0:e.height,contextWidth:null==e?void 0:e.contextWidth,contextHeight:null==e?void 0:e.contextHeight}},t.insertElementToListByPosition=mt,t.is=P,t.isAssetId=f,t.isColorStr=l,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:u}=_(t,{viewScaleInfo:i,viewSizeInfo:n}),h=F({x:l,y:s,w:c,h:u,angle:a}),f={x:0,y:0,w:o,h:r},d=Math.min(h[0].x,h[1].x,h[2].x,h[3].x),g=Math.min(h[0].y,h[1].y,h[2].y,h[3].y);return U(f,{x:d,y:g,w:Math.max(h[0].x,h[1].x,h[2].x,h[3].x)-d,h:Math.max(h[0].y,h[1].y,h[2].y,h[3].y)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=Y,t.istype=x,t.limitAngle=H,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 m(n)},t.loadImage=m,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 m(e)},t.matrixToAngle=function(t){const e=ct(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=ct,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.moveElementPosition=function(t,e){const{from:n,to:i}=e;if(0===n.length||0===i.length)return t;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 t;const o=B(n,t);if(o){if(!mt(o,i,t))return t;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),pt(n,t)}return t},t.parseAngleToRadian=T,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(ot,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,u=t.charAt(c);let h;if(s){const t=lt(r);return o<0?(e.push(t),r):(h=n[o],h.children.push(t),r)}if(l){if(o++,i=lt(r),!i.isVoid&&u&&"<"!==u){const e=t.slice(c,t.indexOf("<",c));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===o&&e.push(i),h=n[o-1],h&&h.children.push(i),n[o]=i}if((!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]),"<"!==u&&u)){h=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);rt.test(r)&&(r=" "),(i>-1&&o+h.length>=0||" "!==r)&&r.trim()&&h.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:r.trim()})}return r})),e},t.parseRadianToAngle=function(t){return t/Math.PI*180},t.parseSVGPath=function(t){const e=[];return t.replace(et,((t,n,i)=>{const o=i.match(nt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{success:e,error:n}=t;let i=document.createElement("input");i.type="file",i.addEventListener("change",(function(){var t;const n=null==(t=i.files)?void 0:t[0];e({file:n}),i=null})),i.addEventListener("error",(function(t){"function"==typeof n&&n(t),i=null})),i.click()},t.rotateByCenter=L,t.rotateElement=function(t,e,n){const i=O(e);L(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=F,t.rotatePoint=j,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=j(O({x:e,y:o,w:r,h:a,angle:l}),{x:n,y:i},T(l));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=V,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=d(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=h(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=h(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=h(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.throttle=function(t,e){let n=-1;return function(...i){n>0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^\#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.updateElementInList=function t(e,n,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===e){wt(l,n),r=l;break}"group"===l.type&&(r=t(e,n,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]))}return r},t.vaildPoint=k,t.vaildTouchPoint=function(t){return!0===k(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 u=i.offsetLeft,h=i.offsetRight,f=i.offsetTop,d=i.offsetBottom;return u+=e,f+=n,h=a-(s*r+u),d=l-(c*r+f),{scale:r,offsetTop:f,offsetLeft:u,offsetRight:h,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
1
+ var iDrawUtil=function(t){"use strict";var e,n,i=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},o=(t,e,n)=>(i(t,e,"read from private field"),n?n.call(t):e.get(t)),r=(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)},a=(t,e,n,o)=>(i(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);function l(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 s={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 c(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function h(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 u(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/${h(e.toString(16).padEnd(4,i))}${h(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${h(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${h(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${h(t.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${h(t.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${h(t.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${h(o.padEnd(4,i).padEnd(4,o))}`}function d(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 f(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 g(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const x={type(t,e){const n=g(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===g(t),json:t=>"Object"===g(t),function:t=>"Function"===g(t),asyncFunction:t=>"AsyncFunction"===g(t),string:t=>"String"===g(t),number:t=>"Number"===g(t),undefined:t=>"Undefined"===g(t),null:t=>"Null"===g(t),promise:t=>"Promise"===g(t)};const{Image:y}=window;function m(t){return new Promise(((e,n)=>{const i=new y;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 w(t){return"number"==typeof t&&t>=0}function v(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function b(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const P={x:function(t){return p(t)},y:function(t){return p(t)},w:w,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 w(t)},borderRadius:function(t){return p(t)&&t>=0},color:function(t){return l(t)},imageSrc:function(t){return b(t)||v(t)},imageURL:v,imageBase64:b,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 M(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!P.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!P.number(n))&&!(t.hasOwnProperty("borderWidth")&&!P.number(i)))}const R={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(P.x(e)&&P.y(n)&&P.w(i)&&P.h(o)&&P.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!!P.text(e)&&(!!P.color(n)&&(!!P.fontSize(i)&&(!(t.hasOwnProperty("background")&&!P.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!P.fontWeight(l))&&(!(t.hasOwnProperty("lineHeight")&&!P.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!P.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!P.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!P.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!P.color(h))&&!!M(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!P.color(e))&&!!M(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!P.color(e))&&(!(t.hasOwnProperty("borderColor")&&!P.color(n))&&!(t.hasOwnProperty("borderWidth")&&!P.number(i)))},imageDesc:function(t){const{src:e}=t;return!!P.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!P.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!P.html(e)}};class I{constructor(t,i){r(this,e,void 0),r(this,n,void 0),a(this,e,t),a(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i})}$undoPixelRatio(t){return t/o(this,n).devicePixelRatio}$doPixelRatio(t){return o(this,n).devicePixelRatio*t}$getContext(){return o(this,e)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),o(this,e).font=`${n.join(" ")}`}$getOffscreenCanvas(){return o(this,n).offscreenCanvas}$resize(t){const{width:i,height:r,devicePixelRatio:l,resetStyle:s}=t,{canvas:c}=o(this,e);c.width=i*l,c.height=r*l,a(this,n,{...o(this,n),devicePixelRatio:l}),!0===s&&(c.style.width=`${i}px`,c.style.height=`${r}px`)}$getSize(){const{devicePixelRatio:t}=o(this,n),{width:i,height:r}=o(this,e).canvas;return{width:i/t,height:r/t,devicePixelRatio:t}}get canvas(){return o(this,e).canvas}get fillStyle(){return o(this,e).fillStyle}set fillStyle(t){o(this,e).fillStyle=t}get strokeStyle(){return o(this,e).strokeStyle}set strokeStyle(t){o(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(o(this,e).lineWidth)}set lineWidth(t){o(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return o(this,e).textAlign}set textAlign(t){o(this,e).textAlign=t}get textBaseline(){return o(this,e).textBaseline}set textBaseline(t){o(this,e).textBaseline=t}get globalAlpha(){return o(this,e).globalAlpha}set globalAlpha(t){o(this,e).globalAlpha=t}get shadowColor(){return o(this,e).shadowColor}set shadowColor(t){o(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(o(this,e).shadowOffsetX)}set shadowOffsetX(t){o(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(o(this,e).shadowOffsetY)}set shadowOffsetY(t){o(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(o(this,e).shadowBlur)}set shadowBlur(t){o(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return o(this,e).lineCap}set lineCap(t){o(this,e).lineCap=t}get globalCompositeOperation(){return o(this,e).globalCompositeOperation}set globalCompositeOperation(t){o(this,e).globalCompositeOperation=t}fill(...t){return o(this,e).fill(...t)}arc(t,n,i,r,a,l){return o(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),r,a,l)}rect(t,n,i,r){return o(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}fillRect(t,n,i,r){return o(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}clearRect(t,n,i,r){return o(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}beginPath(){return o(this,e).beginPath()}closePath(){return o(this,e).closePath()}lineTo(t,n){return o(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return o(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,r,a){return o(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a))}getLineDash(){return o(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return o(this,e).setLineDash(n)}stroke(t){return t?o(this,e).stroke(t):o(this,e).stroke()}translate(t,n){return o(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return o(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],r=t[2],a=t[3],l=t[4],s=t[t.length-4],c=t[t.length-3],h=t[t.length-2],u=t[t.length-1];return 9===t.length?o(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(h),this.$doPixelRatio(u)):o(this,e).drawImage(n,this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(h),this.$doPixelRatio(u))}createPattern(t,n){return o(this,e).createPattern(t,n)}measureText(t){return o(this,e).measureText(t)}fillText(t,n,i,r){return void 0!==r?o(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r)):o(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,r){return void 0!==r?o(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r)):o(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){o(this,e).save()}restore(){o(this,e).restore()}scale(t,n){o(this,e).scale(t,n)}circle(t,n,i,r,a,l,s,c){o(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),a,l,s,c)}isPointInPath(t,n){return o(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return o(this,e).clip(...t)}setTransform(t,n,i,r,a,l){return o(this,e).setTransform(t,n,i,r,a,l)}getTransform(){return o(this,e).getTransform()}createLinearGradient(t,n,i,r){return o(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}createRadialGradient(t,n,i,r,a,l){return o(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l))}createConicGradient(t,n,i){return o(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function $(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 I(r,t)}function E(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 I(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function S(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 A(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function C(t){return t>=0||t<0}function k(t){return C(t.x)&&C(t.y)&&t.t>0}function z(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}function O(t){return t/180*Math.PI}function T(t,e,n,i){const o=O(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 L(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function D(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 L({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function j(t,e,n){const i=function(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}(t,e);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=S(t,e);let a=0,l=0;return 0===o?(a=0,l=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,l=0-Math.cos(o)*r):o===Math.PI/2?(a=r,l=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,l=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,l=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,l=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,l=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,l=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,l=0-r),a+=t.x,l+=t.y,{x:a,y:l}}function W(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=O(V(n));l=j(e,l,t),s=j(e,s,t),c=j(e,c,t),h=j(e,h,t)}return[l,s,c,h]}function F(t){const{angle:e=0}=t;return W(t,L(t),e)}function H(t,e,n){return[j(t,{x:e[0].x,y:e[0].y},n),j(t,{x:e[1].x,y:e[1].y},n),j(t,{x:e[2].x,y:e[2].y},n),j(t,{x:e[3].x,y:e[3].y},n)]}function V(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function N(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=F(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 B(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 G(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 U(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 _(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 Q(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 Y(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:l,y:s,w:c,h:h}=_(i,{viewScaleInfo:o,viewSizeInfo:r}),u=F({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 X(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 q(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?X(t):W(t,L({x:e,y:n,w:i,h:o,angle:r}),r)}function Z(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=q({x:a,y:l,w:s,h:c,angle:h}),o.push({center:L(t),angle:h,radian:O(h)})}else{u=X({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=H(e,u,n)}const t=D(u);if(h>0||h<0){u=H(t,u,O(h))}o.push({center:t,angle:h,radian:O(h)})}e.push(u)}return e}function J(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[q(t)];return Z([...n,t])}function K(t,e){return J(t,e).pop()||null}function tt(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}}const et=/([astvzqmhlc])([^astvzqmhlc]*)/gi,nt=/(-?\d+(?:\.\d+)?)/gi;const it=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,ot=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,rt=/^\s*$/,at={};function lt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(at[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(it);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 st(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(st,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function ct(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 ht(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 ut="Text Element";function dt(){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 ft(){return{background:"#D9D9D9"}}const gt={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 xt=t=>ct(t,{decimalPlaces:4});function yt(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:d}=n;if("number"==typeof l)n.borderWidth=xt(l*a);else if(Array.isArray(n.borderWidth)){const t=l;n.borderWidth=[xt(t[0]*o),xt(t[1]*i),xt(t[2]*o),xt(t[3]*i)]}if("number"==typeof s)n.borderRadius=xt(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]=xt(t*r)})),"number"==typeof h&&(n.shadowOffsetX=xt(h*r)),"number"==typeof u&&(n.shadowOffsetX=xt(u*r)),"number"==typeof d&&(n.shadowOffsetX=xt(d*r))}function mt(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=xt(o*n),t.y=xt(r*i),t.w=xt(a*n),t.h=xt(l*i),yt(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=xt(o*a)),r&&r>0&&(t.detail.lineHeight=xt(r*a))}(t,e):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{mt(t,e)})))}function pt(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=>{mt(t,s)})),yt(t,s),t}const wt=200,vt=200;function bt(t,e,n){let i=!1;if(1===e.length){const o=e[0];n.splice(o,0,t),i=!0}else if(e.length>1){let o=n;for(let n=0;n<e.length;n++){const r=o[e[n]];if(n===e.length-1){const r=e[n];o.splice(r,0,t),i=!0}else{if(!(n<e.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Pt(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 Mt(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)&&(x.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),x.json(t[r])&&(t[r]={...t[r],...e[r]})):x.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),x.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}return t.Context2D=I,t.EventEmitter=class{constructor(){this._listeners=new Map}on(t,e){if(this._listeners.has(t)){const n=this._listeners.get(t)||[];null==n||n.push(e),this._listeners.set(t,n)}else this._listeners.set(t,[e])}off(t,e){if(this._listeners.has(t)){const n=this._listeners.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}this._listeners.set(t,n||[])}}trigger(t,e){const n=this._listeners.get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(this._listeners.has(t)){const e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}},t.Store=class{constructor(t){this._backUpDefaultStorage=f(t.defaultStorage),this._temp=this._createTempStorage()}set(t,e){this._temp[t]=e}get(t){return this._temp[t]}getSnapshot(){return f(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return f(this._backUpDefaultStorage)}},t.calcDistance=S,t.calcElementCenter=L,t.calcElementCenterFromVertexes=D,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=F(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.calcElementQueueVertexesQueueInGroup=Z,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:h,angle:u=0}=t,d=[{uuid:c(),x:a,y:l,w:s,h:h,angle:u,type:"group",detail:{children:[]}},...n];let f=0;d.forEach((({angle:t=0})=>{f+=t}));const g=K(t,{groupQueue:n}),x=z(g[0],g[1]),y=z(g[1],g[2]),m=z(g[2],g[3]),p=z(g[3],g[0]),w=g[0],v=g[1],b=g[2],P=g[3],M=tt(w,{size:r,angle:f}),R=tt(v,{size:r,angle:f}),I=tt(P,{size:r,angle:f}),$=tt(b,{size:r,angle:f}),E=q(M),S=q(R),A=q(I),C=q($),k=[E[1],S[0],S[3],E[2]],O=[S[3],S[2],C[1],C[0]],T=[A[1],C[0],C[3],A[2]];return{elementWrapper:g,left:{type:"left",vertexes:[E[3],E[2],A[1],A[0]],center:p},right:{type:"right",vertexes:O,center:y},top:{type:"top",vertexes:k,center:x},bottom:{type:"bottom",vertexes:T,center:m},topLeft:{type:"top-left",vertexes:E,center:w},topRight:{type:"top-right",vertexes:S,center:v},bottomLeft:{type:"bottom-left",vertexes:A,center:P},bottomRight:{type:"bottom-right",vertexes:C,center:b}}},t.calcElementVertexesInGroup=K,t.calcElementVertexesQueueInGroup=J,t.calcElementsContextSize=N,t.calcElementsViewInfo=function(t,e,n){const i=N(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.calcSpeed=function(t,e){return S(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=gt.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 d=0;return"number"==typeof a&&(d=(a||0)*i),"border-box"===r?(l=t.x+d/2,s=t.y+d/2,c=t.w-d,h=t.h-d):"content-box"===r?(l=t.x-d/2,s=t.y-d/2,c=t.w+d,h=t.h+d):(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.calcViewElementSize=_,t.calcViewPointSize=Q,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[Q(t[0],e),Q(t[1],e),Q(t[2],e),Q(t[3],e)]},t.check=R,t.checkRectIntersect=U,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=s[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=u,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r}=e,a={width:n,height:i,devicePixelRatio:o};if(!0===r){const e=t.getContext("2d"),n=E(a),i=E(a),o=E(a),r=$({ctx:e,...a}),l=()=>{const{width:t,height:e}=n.$getSize();r.clearRect(0,0,t,e),r.drawImage(o.canvas,0,0,t,e),r.drawImage(n.canvas,0,0,t,e),r.drawImage(i.canvas,0,0,t,e),o.clearRect(0,0,t,e),n.clearRect(0,0,t,e),i.clearRect(0,0,t,e)};return{underContext:o,viewContext:n,helperContext:i,boardContext:r,drawView:l}}{const e=t.getContext("2d"),o=$(a),r=$(a),l=$(a),s=$({ctx:e,...a}),c=()=>{s.clearRect(0,0,n,i),s.drawImage(l.canvas,0,0,n,i),s.drawImage(o.canvas,0,0,n,i),s.drawImage(r.canvas,0,0,n,i),l.clearRect(0,0,n,i),o.clearRect(0,0,n,i),r.clearRect(0,0,n,i)};return{underContext:l,viewContext:o,helperContext:r,boardContext:s,drawView:c}}},t.createContext2D=$,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=wt,r=vt;if(e){const{viewScaleInfo:a,viewSizeInfo:l}=e,{scale:s,offsetLeft:c,offsetTop:h}=a,{width:u,height:d}=l,f=u/4,g=d/4;o=wt>=f?f/s:wt/s,r=vt>=g?g/s:vt/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/ut.length*2),n=(0-c+u/2-o*s/2)/s,i=(0-h+d/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:ut,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,lineHeight:t.w/ut.length,fontSize:t.w/ut.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:c(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=E,t.createUUID=c,t.deepClone=f,t.deepCloneElement=function(t){const e=f(t),n=t=>{t.uuid=c(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e},t.deepResizeGroupElement=pt,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Pt(G(t,e),e)},t.deleteElementInListByPosition=Pt,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=A,t.equalTouchPoint=function(t,e){return!0===A(t,e)&&t.f===e.f},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||d(i)||(e=u(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=B,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=B(t,e);i&&n.push(i)})),n},t.formatNumber=ct,t.generateHTML=function(t){return t.reduce((function(t,e){return t+st("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=z,t.getDefaultElementDetailConfig=dt,t.getDefaultElementRectDetail=ft,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&d(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&d(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=G,t.getElementRotateVertexes=W,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=X,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.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 d=c[e];if(d&&"group"===d.type&&Array.isArray(null==(n=d.detail)?void 0:n.children))for(let n=0;n<d.detail.children.length;n++){const f=d.detail.children[n];if(!0!==(null==(i=null==f?void 0:f.operations)?void 0:i.invisible)){if(!f)break;if(Y(t,{context2d:r,element:{x:o+f.x,y:a+f.y,w:f.w,h:f.h,angle:u+(f.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){h.element=f,(e<c.length-1||"group"!==f.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)&&Y(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=bt,t.is=P,t.isAssetId=d,t.isColorStr=l,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}=_(t,{viewScaleInfo:i,viewSizeInfo:n}),u=F({x:l,y:s,w:c,h:h,angle:a}),d={x:0,y:0,w:o,h:r},f=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 U(d,{x:f,y:g,w:Math.max(u[0].x,u[1].x,u[2].x,u[3].x)-f,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=Y,t.istype=x,t.limitAngle=V,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 m(n)},t.loadImage=m,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 m(e)},t.matrixToAngle=function(t){const e=ht(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=ht,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.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.moveElementPosition=function(t,e){const{from:n,to:i}=e;if(0===n.length||0===i.length)return t;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 t;const o=B(n,t);if(o){if(!bt(o,i,t))return t;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),Pt(n,t)}return t},t.parseAngleToRadian=O,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(ot,((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=lt(r);return o<0?(e.push(t),r):(u=n[o],u.children.push(t),r)}if(l){if(o++,i=lt(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);rt.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(et,((t,n,i)=>{const o=i.match(nt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{success:e,error:n}=t;let i=document.createElement("input");i.type="file",i.addEventListener("change",(function(){var t;const n=null==(t=i.files)?void 0:t[0];e({file:n}),i=null})),i.addEventListener("error",(function(t){"function"==typeof n&&n(t),i=null})),i.click()},t.rotateByCenter=T,t.rotateElement=function(t,e,n){const i=L(e);T(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=F,t.rotatePoint=j,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=j(L({x:e,y:o,w:r,h:a,angle:l}),{x:n,y:i},O(l));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=H,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=f(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=u(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=u(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=u(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.throttle=function(t,e){let n=-1;return function(...i){n>0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^\#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.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)&&pt(s,{w:n.w,h:n.h}),Mt(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.vaildPoint=k,t.vaildTouchPoint=function(t){return!0===k(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,d=i.offsetTop,f=i.offsetBottom;return h+=e,d+=n,u=a-(s*r+h),f=l-(c*r+d),{scale:r,offsetTop:d,offsetLeft:h,offsetRight:u,offsetBottom:f}},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.4",
3
+ "version": "0.4.0-beta.5",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",