@idraw/util 0.4.0-beta.35 → 0.4.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/lib/controller.d.ts +3 -1
- package/dist/esm/lib/controller.js +62 -31
- package/dist/esm/lib/is.d.ts +1 -1
- package/dist/esm/lib/rotate.js +8 -13
- package/dist/index.global.js +94 -88
- package/dist/index.global.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Element, ElementSize, ElementSizeController, ViewScaleInfo, LayoutSizeController } from '@idraw/types';
|
|
2
2
|
export declare function calcElementSizeController(elemSize: ElementSize, opts: {
|
|
3
3
|
groupQueue: Element<'group'>[];
|
|
4
|
-
controllerSize
|
|
4
|
+
controllerSize: number;
|
|
5
|
+
rotateControllerSize: number;
|
|
6
|
+
rotateControllerPosition: number;
|
|
5
7
|
viewScaleInfo: ViewScaleInfo;
|
|
6
8
|
}): ElementSizeController;
|
|
7
9
|
export declare function calcLayoutSizeController(layoutSize: Pick<ElementSize, 'x' | 'y' | 'w' | 'h'>, opts: {
|
|
@@ -15,9 +15,11 @@ function createControllerElementSizeFromCenter(center, opts) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
export function calcElementSizeController(elemSize, opts) {
|
|
18
|
-
const { groupQueue, controllerSize, viewScaleInfo } = opts;
|
|
18
|
+
const { groupQueue, controllerSize, viewScaleInfo, rotateControllerSize, rotateControllerPosition } = opts;
|
|
19
19
|
const ctrlSize = (controllerSize && controllerSize > 0 ? controllerSize : 8) / viewScaleInfo.scale;
|
|
20
20
|
const { x, y, w, h, angle = 0 } = elemSize;
|
|
21
|
+
const rotateCtrlSize = rotateControllerSize;
|
|
22
|
+
const rotateCtrlPos = rotateControllerPosition;
|
|
21
23
|
const ctrlGroupQueue = [
|
|
22
24
|
...[
|
|
23
25
|
{
|
|
@@ -39,10 +41,10 @@ export function calcElementSizeController(elemSize, opts) {
|
|
|
39
41
|
});
|
|
40
42
|
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
41
43
|
const rotateElemVertexes = calcElementVertexesInGroup({
|
|
42
|
-
x: x
|
|
43
|
-
y: y -
|
|
44
|
-
h: h +
|
|
45
|
-
w: w
|
|
44
|
+
x: x,
|
|
45
|
+
y: y - (rotateCtrlPos + rotateCtrlSize / 2) / viewScaleInfo.scale,
|
|
46
|
+
h: h + (rotateCtrlPos * 2 + rotateCtrlSize) / viewScaleInfo.scale,
|
|
47
|
+
w: w,
|
|
46
48
|
angle
|
|
47
49
|
}, { groupQueue: [...groupQueue] });
|
|
48
50
|
const topCenter = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
@@ -74,74 +76,91 @@ export function calcElementSizeController(elemSize, opts) {
|
|
|
74
76
|
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
75
77
|
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
76
78
|
const rotateCenter = getCenterFromTwoPoints(rotateElemVertexes[0], rotateElemVertexes[1]);
|
|
77
|
-
const
|
|
79
|
+
const tempRotateSizeRepairRatio = 1.1;
|
|
80
|
+
const rotateSize = createControllerElementSizeFromCenter(rotateCenter, {
|
|
81
|
+
size: (rotateControllerSize * tempRotateSizeRepairRatio) / viewScaleInfo.scale,
|
|
82
|
+
angle: totalAngle
|
|
83
|
+
});
|
|
78
84
|
const rotateVertexes = calcElementVertexes(rotateSize);
|
|
79
85
|
const sizeController = {
|
|
80
86
|
elementWrapper: vertexes,
|
|
81
87
|
left: {
|
|
82
88
|
type: 'left',
|
|
83
89
|
vertexes: leftVertexes,
|
|
84
|
-
center: leftCenter
|
|
90
|
+
center: leftCenter,
|
|
91
|
+
size: ctrlSize
|
|
85
92
|
},
|
|
86
93
|
right: {
|
|
87
94
|
type: 'right',
|
|
88
95
|
vertexes: rightVertexes,
|
|
89
|
-
center: rightCenter
|
|
96
|
+
center: rightCenter,
|
|
97
|
+
size: ctrlSize
|
|
90
98
|
},
|
|
91
99
|
top: {
|
|
92
100
|
type: 'top',
|
|
93
101
|
vertexes: topVertexes,
|
|
94
|
-
center: topCenter
|
|
102
|
+
center: topCenter,
|
|
103
|
+
size: ctrlSize
|
|
95
104
|
},
|
|
96
105
|
bottom: {
|
|
97
106
|
type: 'bottom',
|
|
98
107
|
vertexes: bottomVertexes,
|
|
99
|
-
center: bottomCenter
|
|
108
|
+
center: bottomCenter,
|
|
109
|
+
size: ctrlSize
|
|
100
110
|
},
|
|
101
111
|
topLeft: {
|
|
102
112
|
type: 'top-left',
|
|
103
113
|
vertexes: topLeftVertexes,
|
|
104
|
-
center: topLeftCenter
|
|
114
|
+
center: topLeftCenter,
|
|
115
|
+
size: ctrlSize
|
|
105
116
|
},
|
|
106
117
|
topRight: {
|
|
107
118
|
type: 'top-right',
|
|
108
119
|
vertexes: topRightVertexes,
|
|
109
|
-
center: topRightCenter
|
|
120
|
+
center: topRightCenter,
|
|
121
|
+
size: ctrlSize
|
|
110
122
|
},
|
|
111
123
|
bottomLeft: {
|
|
112
124
|
type: 'bottom-left',
|
|
113
125
|
vertexes: bottomLeftVertexes,
|
|
114
|
-
center: bottomLeftCenter
|
|
126
|
+
center: bottomLeftCenter,
|
|
127
|
+
size: ctrlSize
|
|
115
128
|
},
|
|
116
129
|
bottomRight: {
|
|
117
130
|
type: 'bottom-right',
|
|
118
131
|
vertexes: bottomRightVertexes,
|
|
119
|
-
center: bottomRightCenter
|
|
132
|
+
center: bottomRightCenter,
|
|
133
|
+
size: ctrlSize
|
|
120
134
|
},
|
|
121
135
|
leftMiddle: {
|
|
122
136
|
type: 'left-middle',
|
|
123
137
|
vertexes: leftMiddleVertexes,
|
|
124
|
-
center: leftCenter
|
|
138
|
+
center: leftCenter,
|
|
139
|
+
size: ctrlSize
|
|
125
140
|
},
|
|
126
141
|
rightMiddle: {
|
|
127
142
|
type: 'right-middle',
|
|
128
143
|
vertexes: rightMiddleVertexes,
|
|
129
|
-
center: rightCenter
|
|
144
|
+
center: rightCenter,
|
|
145
|
+
size: ctrlSize
|
|
130
146
|
},
|
|
131
147
|
topMiddle: {
|
|
132
148
|
type: 'top-middle',
|
|
133
149
|
vertexes: topMiddleVertexes,
|
|
134
|
-
center: topCenter
|
|
150
|
+
center: topCenter,
|
|
151
|
+
size: ctrlSize
|
|
135
152
|
},
|
|
136
153
|
bottomMiddle: {
|
|
137
154
|
type: 'bottom-middle',
|
|
138
155
|
vertexes: bottomMiddleVertexes,
|
|
139
|
-
center: bottomCenter
|
|
156
|
+
center: bottomCenter,
|
|
157
|
+
size: ctrlSize
|
|
140
158
|
},
|
|
141
159
|
rotate: {
|
|
142
160
|
type: 'rotate',
|
|
143
161
|
vertexes: rotateVertexes,
|
|
144
|
-
center: rotateCenter
|
|
162
|
+
center: rotateCenter,
|
|
163
|
+
size: rotateControllerSize
|
|
145
164
|
}
|
|
146
165
|
};
|
|
147
166
|
return sizeController;
|
|
@@ -183,62 +202,74 @@ export function calcLayoutSizeController(layoutSize, opts) {
|
|
|
183
202
|
left: {
|
|
184
203
|
type: 'left',
|
|
185
204
|
vertexes: leftVertexes,
|
|
186
|
-
center: leftCenter
|
|
205
|
+
center: leftCenter,
|
|
206
|
+
size: ctrlSize
|
|
187
207
|
},
|
|
188
208
|
right: {
|
|
189
209
|
type: 'right',
|
|
190
210
|
vertexes: rightVertexes,
|
|
191
|
-
center: rightCenter
|
|
211
|
+
center: rightCenter,
|
|
212
|
+
size: ctrlSize
|
|
192
213
|
},
|
|
193
214
|
top: {
|
|
194
215
|
type: 'top',
|
|
195
216
|
vertexes: topVertexes,
|
|
196
|
-
center: topCenter
|
|
217
|
+
center: topCenter,
|
|
218
|
+
size: ctrlSize
|
|
197
219
|
},
|
|
198
220
|
bottom: {
|
|
199
221
|
type: 'bottom',
|
|
200
222
|
vertexes: bottomVertexes,
|
|
201
|
-
center: bottomCenter
|
|
223
|
+
center: bottomCenter,
|
|
224
|
+
size: ctrlSize
|
|
202
225
|
},
|
|
203
226
|
topLeft: {
|
|
204
227
|
type: 'top-left',
|
|
205
228
|
vertexes: topLeftVertexes,
|
|
206
|
-
center: topLeftCenter
|
|
229
|
+
center: topLeftCenter,
|
|
230
|
+
size: ctrlSize
|
|
207
231
|
},
|
|
208
232
|
topRight: {
|
|
209
233
|
type: 'top-right',
|
|
210
234
|
vertexes: topRightVertexes,
|
|
211
|
-
center: topRightCenter
|
|
235
|
+
center: topRightCenter,
|
|
236
|
+
size: ctrlSize
|
|
212
237
|
},
|
|
213
238
|
bottomLeft: {
|
|
214
239
|
type: 'bottom-left',
|
|
215
240
|
vertexes: bottomLeftVertexes,
|
|
216
|
-
center: bottomLeftCenter
|
|
241
|
+
center: bottomLeftCenter,
|
|
242
|
+
size: ctrlSize
|
|
217
243
|
},
|
|
218
244
|
bottomRight: {
|
|
219
245
|
type: 'bottom-right',
|
|
220
246
|
vertexes: bottomRightVertexes,
|
|
221
|
-
center: bottomRightCenter
|
|
247
|
+
center: bottomRightCenter,
|
|
248
|
+
size: ctrlSize
|
|
222
249
|
},
|
|
223
250
|
leftMiddle: {
|
|
224
251
|
type: 'left-middle',
|
|
225
252
|
vertexes: leftMiddleVertexes,
|
|
226
|
-
center: leftCenter
|
|
253
|
+
center: leftCenter,
|
|
254
|
+
size: ctrlSize
|
|
227
255
|
},
|
|
228
256
|
rightMiddle: {
|
|
229
257
|
type: 'right-middle',
|
|
230
258
|
vertexes: rightMiddleVertexes,
|
|
231
|
-
center: rightCenter
|
|
259
|
+
center: rightCenter,
|
|
260
|
+
size: ctrlSize
|
|
232
261
|
},
|
|
233
262
|
topMiddle: {
|
|
234
263
|
type: 'top-middle',
|
|
235
264
|
vertexes: topMiddleVertexes,
|
|
236
|
-
center: topCenter
|
|
265
|
+
center: topCenter,
|
|
266
|
+
size: ctrlSize
|
|
237
267
|
},
|
|
238
268
|
bottomMiddle: {
|
|
239
269
|
type: 'bottom-middle',
|
|
240
270
|
vertexes: bottomMiddleVertexes,
|
|
241
|
-
center: bottomCenter
|
|
271
|
+
center: bottomCenter,
|
|
272
|
+
size: ctrlSize
|
|
242
273
|
}
|
|
243
274
|
};
|
|
244
275
|
return sizeController;
|
package/dist/esm/lib/is.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare function imageBase64(value: any): boolean;
|
|
|
12
12
|
declare function imageSrc(value: any): boolean;
|
|
13
13
|
declare function svg(value: any): boolean;
|
|
14
14
|
declare function html(value: any): boolean;
|
|
15
|
-
declare function text(value: any):
|
|
15
|
+
declare function text(value: any): value is string;
|
|
16
16
|
declare function fontSize(value: any): boolean;
|
|
17
17
|
declare function lineHeight(value: any): boolean;
|
|
18
18
|
declare function strokeWidth(value: any): boolean;
|
package/dist/esm/lib/rotate.js
CHANGED
|
@@ -46,18 +46,10 @@ export function calcElementCenterFromVertexes(ves) {
|
|
|
46
46
|
return calcElementCenter(elemSize);
|
|
47
47
|
}
|
|
48
48
|
export function calcRadian(center, start, end) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
return endAngle + (Math.PI * 2 - startAngle);
|
|
54
|
-
}
|
|
55
|
-
else if (endAngle > (Math.PI * 3) / 2 && startAngle < Math.PI / 2) {
|
|
56
|
-
return startAngle + (Math.PI * 2 - endAngle);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return endAngle - startAngle;
|
|
60
|
-
}
|
|
49
|
+
const startRadian = calcLineRadian(center, start);
|
|
50
|
+
const endRadian = calcLineRadian(center, end);
|
|
51
|
+
if (endRadian !== null && startRadian !== null) {
|
|
52
|
+
return endRadian - startRadian;
|
|
61
53
|
}
|
|
62
54
|
else {
|
|
63
55
|
return 0;
|
|
@@ -199,12 +191,15 @@ export function rotateVertexes(center, ves, radian) {
|
|
|
199
191
|
];
|
|
200
192
|
}
|
|
201
193
|
export function limitAngle(angle) {
|
|
202
|
-
if (!(angle > 0 || angle < 0) || angle === 0) {
|
|
194
|
+
if (!(angle > 0 || angle < 0) || angle === 0 || angle === 360) {
|
|
203
195
|
return 0;
|
|
204
196
|
}
|
|
205
197
|
let num = angle % 360;
|
|
206
198
|
if (num < 0) {
|
|
207
199
|
num += 360;
|
|
208
200
|
}
|
|
201
|
+
else if (angle === 360) {
|
|
202
|
+
num = 0;
|
|
203
|
+
}
|
|
209
204
|
return num;
|
|
210
205
|
}
|
package/dist/index.global.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
var iDrawUtil = function(exports) {
|
|
2
|
-
"use strict";var
|
|
3
|
-
|
|
4
|
-
throw TypeError("Cannot " + msg);
|
|
5
|
-
};
|
|
6
|
-
var __privateGet = (obj, member, getter) => {
|
|
7
|
-
__accessCheck(obj, member, "read from private field");
|
|
8
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
9
|
-
};
|
|
10
|
-
var __privateAdd = (obj, member, value) => {
|
|
11
|
-
if (member.has(obj))
|
|
12
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
13
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
14
|
-
};
|
|
15
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
16
|
-
__accessCheck(obj, member, "write to private field");
|
|
17
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
18
|
-
return value;
|
|
19
|
-
};
|
|
20
|
-
var __privateMethod = (obj, member, method) => {
|
|
21
|
-
__accessCheck(obj, member, "access private method");
|
|
22
|
-
return method;
|
|
2
|
+
"use strict";var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
23
4
|
};
|
|
5
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
6
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
7
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
8
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
24
10
|
|
|
25
|
-
var _ctx, _opts, _listeners, _temp, _backUpDefaultStorage, _static,
|
|
11
|
+
var _ctx, _opts, _listeners, _temp, _backUpDefaultStorage, _static, _Store_instances, createTempStorage_fn;
|
|
26
12
|
function compose(middleware) {
|
|
27
13
|
return function(context, next) {
|
|
28
14
|
return dispatch(0);
|
|
@@ -31,8 +17,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
31
17
|
if (i === middleware.length && next) {
|
|
32
18
|
fn = next;
|
|
33
19
|
}
|
|
34
|
-
if (!fn)
|
|
35
|
-
return Promise.resolve();
|
|
20
|
+
if (!fn) return Promise.resolve();
|
|
36
21
|
try {
|
|
37
22
|
return Promise.resolve(fn(context, dispatch.bind(null, i + 1)));
|
|
38
23
|
} catch (err) {
|
|
@@ -922,8 +907,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
922
907
|
// private _width: number = 0;
|
|
923
908
|
// private _height: number = 0;
|
|
924
909
|
constructor(ctx, opts) {
|
|
925
|
-
__privateAdd(this, _ctx
|
|
926
|
-
__privateAdd(this, _opts
|
|
910
|
+
__privateAdd(this, _ctx);
|
|
911
|
+
__privateAdd(this, _opts);
|
|
927
912
|
__privateSet(this, _ctx, ctx);
|
|
928
913
|
__privateSet(this, _opts, { ...{ devicePixelRatio: 1, offscreenCanvas: null }, ...opts });
|
|
929
914
|
this.$resetFont();
|
|
@@ -1310,7 +1295,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1310
1295
|
}
|
|
1311
1296
|
class EventEmitter {
|
|
1312
1297
|
constructor() {
|
|
1313
|
-
__privateAdd(this, _listeners
|
|
1298
|
+
__privateAdd(this, _listeners);
|
|
1314
1299
|
__privateSet(this, _listeners, /* @__PURE__ */ new Map());
|
|
1315
1300
|
}
|
|
1316
1301
|
on(eventKey, callback) {
|
|
@@ -1396,12 +1381,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1396
1381
|
}
|
|
1397
1382
|
class Store {
|
|
1398
1383
|
constructor(opts) {
|
|
1399
|
-
__privateAdd(this,
|
|
1400
|
-
__privateAdd(this, _temp
|
|
1401
|
-
__privateAdd(this, _backUpDefaultStorage
|
|
1402
|
-
__privateAdd(this, _static
|
|
1384
|
+
__privateAdd(this, _Store_instances);
|
|
1385
|
+
__privateAdd(this, _temp);
|
|
1386
|
+
__privateAdd(this, _backUpDefaultStorage);
|
|
1387
|
+
__privateAdd(this, _static);
|
|
1403
1388
|
__privateSet(this, _backUpDefaultStorage, deepClone(opts.defaultStorage));
|
|
1404
|
-
__privateSet(this, _temp, __privateMethod(this,
|
|
1389
|
+
__privateSet(this, _temp, __privateMethod(this, _Store_instances, createTempStorage_fn).call(this));
|
|
1405
1390
|
__privateSet(this, _static, opts.defaultStatic || {});
|
|
1406
1391
|
}
|
|
1407
1392
|
set(name, value) {
|
|
@@ -1423,7 +1408,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1423
1408
|
return { ...__privateGet(this, _temp) };
|
|
1424
1409
|
}
|
|
1425
1410
|
clear() {
|
|
1426
|
-
__privateSet(this, _temp, __privateMethod(this,
|
|
1411
|
+
__privateSet(this, _temp, __privateMethod(this, _Store_instances, createTempStorage_fn).call(this));
|
|
1427
1412
|
}
|
|
1428
1413
|
destroy() {
|
|
1429
1414
|
__privateSet(this, _temp, null);
|
|
@@ -1433,7 +1418,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1433
1418
|
_temp = new WeakMap();
|
|
1434
1419
|
_backUpDefaultStorage = new WeakMap();
|
|
1435
1420
|
_static = new WeakMap();
|
|
1436
|
-
|
|
1421
|
+
_Store_instances = new WeakSet();
|
|
1437
1422
|
createTempStorage_fn = function() {
|
|
1438
1423
|
return deepClone(__privateGet(this, _backUpDefaultStorage));
|
|
1439
1424
|
};
|
|
@@ -1506,16 +1491,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1506
1491
|
return calcElementCenter(elemSize);
|
|
1507
1492
|
}
|
|
1508
1493
|
function calcRadian(center, start, end) {
|
|
1509
|
-
const
|
|
1510
|
-
const
|
|
1511
|
-
if (
|
|
1512
|
-
|
|
1513
|
-
return endAngle + (Math.PI * 2 - startAngle);
|
|
1514
|
-
} else if (endAngle > Math.PI * 3 / 2 && startAngle < Math.PI / 2) {
|
|
1515
|
-
return startAngle + (Math.PI * 2 - endAngle);
|
|
1516
|
-
} else {
|
|
1517
|
-
return endAngle - startAngle;
|
|
1518
|
-
}
|
|
1494
|
+
const startRadian = calcLineRadian(center, start);
|
|
1495
|
+
const endRadian = calcLineRadian(center, end);
|
|
1496
|
+
if (endRadian !== null && startRadian !== null) {
|
|
1497
|
+
return endRadian - startRadian;
|
|
1519
1498
|
} else {
|
|
1520
1499
|
return 0;
|
|
1521
1500
|
}
|
|
@@ -1641,12 +1620,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1641
1620
|
];
|
|
1642
1621
|
}
|
|
1643
1622
|
function limitAngle(angle2) {
|
|
1644
|
-
if (!(angle2 > 0 || angle2 < 0) || angle2 === 0) {
|
|
1623
|
+
if (!(angle2 > 0 || angle2 < 0) || angle2 === 0 || angle2 === 360) {
|
|
1645
1624
|
return 0;
|
|
1646
1625
|
}
|
|
1647
1626
|
let num = angle2 % 360;
|
|
1648
1627
|
if (num < 0) {
|
|
1649
1628
|
num += 360;
|
|
1629
|
+
} else if (angle2 === 360) {
|
|
1630
|
+
num = 0;
|
|
1650
1631
|
}
|
|
1651
1632
|
return num;
|
|
1652
1633
|
}
|
|
@@ -2617,9 +2598,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2617
2598
|
};
|
|
2618
2599
|
}
|
|
2619
2600
|
function calcElementSizeController(elemSize, opts) {
|
|
2620
|
-
const { groupQueue, controllerSize, viewScaleInfo } = opts;
|
|
2601
|
+
const { groupQueue, controllerSize, viewScaleInfo, rotateControllerSize, rotateControllerPosition } = opts;
|
|
2621
2602
|
const ctrlSize = (controllerSize && controllerSize > 0 ? controllerSize : 8) / viewScaleInfo.scale;
|
|
2622
2603
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
2604
|
+
const rotateCtrlSize = rotateControllerSize;
|
|
2605
|
+
const rotateCtrlPos = rotateControllerPosition;
|
|
2623
2606
|
const ctrlGroupQueue = [
|
|
2624
2607
|
...[
|
|
2625
2608
|
{
|
|
@@ -2642,10 +2625,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2642
2625
|
const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
|
|
2643
2626
|
const rotateElemVertexes = calcElementVertexesInGroup(
|
|
2644
2627
|
{
|
|
2645
|
-
x: x2
|
|
2646
|
-
y: y2 -
|
|
2647
|
-
h: h2 +
|
|
2648
|
-
w: w2
|
|
2628
|
+
x: x2,
|
|
2629
|
+
y: y2 - (rotateCtrlPos + rotateCtrlSize / 2) / viewScaleInfo.scale,
|
|
2630
|
+
h: h2 + (rotateCtrlPos * 2 + rotateCtrlSize) / viewScaleInfo.scale,
|
|
2631
|
+
w: w2,
|
|
2649
2632
|
angle: angle2
|
|
2650
2633
|
},
|
|
2651
2634
|
{ groupQueue: [...groupQueue] }
|
|
@@ -2679,74 +2662,91 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2679
2662
|
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
2680
2663
|
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
2681
2664
|
const rotateCenter = getCenterFromTwoPoints(rotateElemVertexes[0], rotateElemVertexes[1]);
|
|
2682
|
-
const
|
|
2665
|
+
const tempRotateSizeRepairRatio = 1.1;
|
|
2666
|
+
const rotateSize = createControllerElementSizeFromCenter(rotateCenter, {
|
|
2667
|
+
size: rotateControllerSize * tempRotateSizeRepairRatio / viewScaleInfo.scale,
|
|
2668
|
+
angle: totalAngle
|
|
2669
|
+
});
|
|
2683
2670
|
const rotateVertexes2 = calcElementVertexes(rotateSize);
|
|
2684
2671
|
const sizeController = {
|
|
2685
2672
|
elementWrapper: vertexes,
|
|
2686
2673
|
left: {
|
|
2687
2674
|
type: "left",
|
|
2688
2675
|
vertexes: leftVertexes,
|
|
2689
|
-
center: leftCenter
|
|
2676
|
+
center: leftCenter,
|
|
2677
|
+
size: ctrlSize
|
|
2690
2678
|
},
|
|
2691
2679
|
right: {
|
|
2692
2680
|
type: "right",
|
|
2693
2681
|
vertexes: rightVertexes,
|
|
2694
|
-
center: rightCenter
|
|
2682
|
+
center: rightCenter,
|
|
2683
|
+
size: ctrlSize
|
|
2695
2684
|
},
|
|
2696
2685
|
top: {
|
|
2697
2686
|
type: "top",
|
|
2698
2687
|
vertexes: topVertexes,
|
|
2699
|
-
center: topCenter
|
|
2688
|
+
center: topCenter,
|
|
2689
|
+
size: ctrlSize
|
|
2700
2690
|
},
|
|
2701
2691
|
bottom: {
|
|
2702
2692
|
type: "bottom",
|
|
2703
2693
|
vertexes: bottomVertexes,
|
|
2704
|
-
center: bottomCenter
|
|
2694
|
+
center: bottomCenter,
|
|
2695
|
+
size: ctrlSize
|
|
2705
2696
|
},
|
|
2706
2697
|
topLeft: {
|
|
2707
2698
|
type: "top-left",
|
|
2708
2699
|
vertexes: topLeftVertexes,
|
|
2709
|
-
center: topLeftCenter
|
|
2700
|
+
center: topLeftCenter,
|
|
2701
|
+
size: ctrlSize
|
|
2710
2702
|
},
|
|
2711
2703
|
topRight: {
|
|
2712
2704
|
type: "top-right",
|
|
2713
2705
|
vertexes: topRightVertexes,
|
|
2714
|
-
center: topRightCenter
|
|
2706
|
+
center: topRightCenter,
|
|
2707
|
+
size: ctrlSize
|
|
2715
2708
|
},
|
|
2716
2709
|
bottomLeft: {
|
|
2717
2710
|
type: "bottom-left",
|
|
2718
2711
|
vertexes: bottomLeftVertexes,
|
|
2719
|
-
center: bottomLeftCenter
|
|
2712
|
+
center: bottomLeftCenter,
|
|
2713
|
+
size: ctrlSize
|
|
2720
2714
|
},
|
|
2721
2715
|
bottomRight: {
|
|
2722
2716
|
type: "bottom-right",
|
|
2723
2717
|
vertexes: bottomRightVertexes,
|
|
2724
|
-
center: bottomRightCenter
|
|
2718
|
+
center: bottomRightCenter,
|
|
2719
|
+
size: ctrlSize
|
|
2725
2720
|
},
|
|
2726
2721
|
leftMiddle: {
|
|
2727
2722
|
type: "left-middle",
|
|
2728
2723
|
vertexes: leftMiddleVertexes,
|
|
2729
|
-
center: leftCenter
|
|
2724
|
+
center: leftCenter,
|
|
2725
|
+
size: ctrlSize
|
|
2730
2726
|
},
|
|
2731
2727
|
rightMiddle: {
|
|
2732
2728
|
type: "right-middle",
|
|
2733
2729
|
vertexes: rightMiddleVertexes,
|
|
2734
|
-
center: rightCenter
|
|
2730
|
+
center: rightCenter,
|
|
2731
|
+
size: ctrlSize
|
|
2735
2732
|
},
|
|
2736
2733
|
topMiddle: {
|
|
2737
2734
|
type: "top-middle",
|
|
2738
2735
|
vertexes: topMiddleVertexes,
|
|
2739
|
-
center: topCenter
|
|
2736
|
+
center: topCenter,
|
|
2737
|
+
size: ctrlSize
|
|
2740
2738
|
},
|
|
2741
2739
|
bottomMiddle: {
|
|
2742
2740
|
type: "bottom-middle",
|
|
2743
2741
|
vertexes: bottomMiddleVertexes,
|
|
2744
|
-
center: bottomCenter
|
|
2742
|
+
center: bottomCenter,
|
|
2743
|
+
size: ctrlSize
|
|
2745
2744
|
},
|
|
2746
2745
|
rotate: {
|
|
2747
2746
|
type: "rotate",
|
|
2748
2747
|
vertexes: rotateVertexes2,
|
|
2749
|
-
center: rotateCenter
|
|
2748
|
+
center: rotateCenter,
|
|
2749
|
+
size: rotateControllerSize
|
|
2750
2750
|
}
|
|
2751
2751
|
};
|
|
2752
2752
|
return sizeController;
|
|
@@ -2788,62 +2788,74 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2788
2788
|
left: {
|
|
2789
2789
|
type: "left",
|
|
2790
2790
|
vertexes: leftVertexes,
|
|
2791
|
-
center: leftCenter
|
|
2791
|
+
center: leftCenter,
|
|
2792
|
+
size: ctrlSize
|
|
2792
2793
|
},
|
|
2793
2794
|
right: {
|
|
2794
2795
|
type: "right",
|
|
2795
2796
|
vertexes: rightVertexes,
|
|
2796
|
-
center: rightCenter
|
|
2797
|
+
center: rightCenter,
|
|
2798
|
+
size: ctrlSize
|
|
2797
2799
|
},
|
|
2798
2800
|
top: {
|
|
2799
2801
|
type: "top",
|
|
2800
2802
|
vertexes: topVertexes,
|
|
2801
|
-
center: topCenter
|
|
2803
|
+
center: topCenter,
|
|
2804
|
+
size: ctrlSize
|
|
2802
2805
|
},
|
|
2803
2806
|
bottom: {
|
|
2804
2807
|
type: "bottom",
|
|
2805
2808
|
vertexes: bottomVertexes,
|
|
2806
|
-
center: bottomCenter
|
|
2809
|
+
center: bottomCenter,
|
|
2810
|
+
size: ctrlSize
|
|
2807
2811
|
},
|
|
2808
2812
|
topLeft: {
|
|
2809
2813
|
type: "top-left",
|
|
2810
2814
|
vertexes: topLeftVertexes,
|
|
2811
|
-
center: topLeftCenter
|
|
2815
|
+
center: topLeftCenter,
|
|
2816
|
+
size: ctrlSize
|
|
2812
2817
|
},
|
|
2813
2818
|
topRight: {
|
|
2814
2819
|
type: "top-right",
|
|
2815
2820
|
vertexes: topRightVertexes,
|
|
2816
|
-
center: topRightCenter
|
|
2821
|
+
center: topRightCenter,
|
|
2822
|
+
size: ctrlSize
|
|
2817
2823
|
},
|
|
2818
2824
|
bottomLeft: {
|
|
2819
2825
|
type: "bottom-left",
|
|
2820
2826
|
vertexes: bottomLeftVertexes,
|
|
2821
|
-
center: bottomLeftCenter
|
|
2827
|
+
center: bottomLeftCenter,
|
|
2828
|
+
size: ctrlSize
|
|
2822
2829
|
},
|
|
2823
2830
|
bottomRight: {
|
|
2824
2831
|
type: "bottom-right",
|
|
2825
2832
|
vertexes: bottomRightVertexes,
|
|
2826
|
-
center: bottomRightCenter
|
|
2833
|
+
center: bottomRightCenter,
|
|
2834
|
+
size: ctrlSize
|
|
2827
2835
|
},
|
|
2828
2836
|
leftMiddle: {
|
|
2829
2837
|
type: "left-middle",
|
|
2830
2838
|
vertexes: leftMiddleVertexes,
|
|
2831
|
-
center: leftCenter
|
|
2839
|
+
center: leftCenter,
|
|
2840
|
+
size: ctrlSize
|
|
2832
2841
|
},
|
|
2833
2842
|
rightMiddle: {
|
|
2834
2843
|
type: "right-middle",
|
|
2835
2844
|
vertexes: rightMiddleVertexes,
|
|
2836
|
-
center: rightCenter
|
|
2845
|
+
center: rightCenter,
|
|
2846
|
+
size: ctrlSize
|
|
2837
2847
|
},
|
|
2838
2848
|
topMiddle: {
|
|
2839
2849
|
type: "top-middle",
|
|
2840
2850
|
vertexes: topMiddleVertexes,
|
|
2841
|
-
center: topCenter
|
|
2851
|
+
center: topCenter,
|
|
2852
|
+
size: ctrlSize
|
|
2842
2853
|
},
|
|
2843
2854
|
bottomMiddle: {
|
|
2844
2855
|
type: "bottom-middle",
|
|
2845
2856
|
vertexes: bottomMiddleVertexes,
|
|
2846
|
-
center: bottomCenter
|
|
2857
|
+
center: bottomCenter,
|
|
2858
|
+
size: ctrlSize
|
|
2847
2859
|
}
|
|
2848
2860
|
};
|
|
2849
2861
|
return sizeController;
|
|
@@ -3263,18 +3275,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3263
3275
|
function resizeElement(elem, opts) {
|
|
3264
3276
|
const { type } = elem;
|
|
3265
3277
|
resizeElementBase(elem, opts);
|
|
3266
|
-
if (type === "circle")
|
|
3267
|
-
;
|
|
3278
|
+
if (type === "circle") ;
|
|
3268
3279
|
else if (type === "text") {
|
|
3269
3280
|
resizeTextElementDetail(elem, opts);
|
|
3270
|
-
} else if (type === "image")
|
|
3271
|
-
|
|
3272
|
-
else if (type === "
|
|
3273
|
-
|
|
3274
|
-
else if (type === "html")
|
|
3275
|
-
;
|
|
3276
|
-
else if (type === "path")
|
|
3277
|
-
;
|
|
3281
|
+
} else if (type === "image") ;
|
|
3282
|
+
else if (type === "svg") ;
|
|
3283
|
+
else if (type === "html") ;
|
|
3284
|
+
else if (type === "path") ;
|
|
3278
3285
|
else if (type === "group" && Array.isArray(elem.detail.children)) {
|
|
3279
3286
|
elem.detail.children.forEach((child) => {
|
|
3280
3287
|
resizeElement(child, opts);
|
|
@@ -3697,8 +3704,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3697
3704
|
}
|
|
3698
3705
|
function _set(obj, path, value) {
|
|
3699
3706
|
const keys = path.split(".");
|
|
3700
|
-
if (typeof obj !== "object")
|
|
3701
|
-
return obj;
|
|
3707
|
+
if (typeof obj !== "object") return obj;
|
|
3702
3708
|
keys.reduce((o, k, i, _) => {
|
|
3703
3709
|
if (i === _.length - 1) {
|
|
3704
3710
|
o[k] = value;
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawUtil=function(t){"use strict";var e,n,i,o,r,l,a,s,c=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},h=(t,e,n)=>(c(t,e,"read from private field"),n?n.call(t):e.get(t)),u=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},f=(t,e,n,i)=>(c(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),d=(t,e,n)=>(c(t,e,"access private method"),n);function g(t){return"string"==typeof t&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const y={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function m(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function p(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n)*t.charCodeAt(n)*n*n;return e.toString(16).substring(0,4)}function x(t){const e=t.length,n=Math.floor(e/2),i=t.substring(0,4).padEnd(4,"0"),o=t.substring(0,4).padEnd(4,"0");return`@assets/${p(e.toString(16).padEnd(4,i))}${p(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${p(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${p(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${p(t.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${p(t.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${p(t.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${p(o.padEnd(4,i).padEnd(4,o))}`}function v(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 b(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 w(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const M={type(t,e){const n=w(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===w(t),json:t=>"Object"===w(t),function:t=>"Function"===w(t),asyncFunction:t=>"AsyncFunction"===w(t),boolean:t=>"Boolean"===w(t),string:t=>"String"===w(t),number:t=>"Number"===w(t),undefined:t=>"Undefined"===w(t),null:t=>"Null"===w(t),promise:t=>"Promise"===w(t)};const{Image:R}=window;function P(t){return new Promise(((e,n)=>{const i=new R;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function I(t){return"number"==typeof t&&(t>0||t<=0)}function S(t){return"number"==typeof t&&t>=0}function E(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function L(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const $={x:function(t){return I(t)},y:function(t){return I(t)},w:S,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:I,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return S(t)},borderRadius:function(t){return I(t)&&t>=0},color:function(t){return g(t)},imageSrc:function(t){return L(t)||E(t)},imageURL:E,imageBase64:L,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return I(t)&&t>0},lineHeight:function(t){return I(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 I(t)&&t>0}};function A(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!$.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!$.number(n))&&!(t.hasOwnProperty("borderWidth")&&!$.number(i)))}const C={attrs: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))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:l,fontWeight:a,background:s,strokeWidth:c,strokeColor:h}=t;return!!$.text(e)&&(!!$.color(n)&&(!!$.fontSize(i)&&(!(t.hasOwnProperty("background")&&!$.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!$.fontWeight(a))&&(!(t.hasOwnProperty("lineHeight")&&!$.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!$.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!$.textAlign(l))&&(!(t.hasOwnProperty("strokeWidth")&&!$.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!$.color(h))&&!!A(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!$.color(e))&&!!A(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!$.color(e))&&(!(t.hasOwnProperty("borderColor")&&!$.color(n))&&!(t.hasOwnProperty("borderWidth")&&!$.number(i)))},imageDesc:function(t){const{src:e}=t;return!!$.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!$.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!$.html(e)}};class k{constructor(t,i){u(this,e,void 0),u(this,n,void 0),f(this,e,t),f(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/h(this,n).devicePixelRatio}$doPixelRatio(t){return h(this,n).devicePixelRatio*t}$getContext(){return h(this,e)}$setContext(t){f(this,e,t)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),h(this,e).font=`${n.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return h(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:l}=t,{canvas:a}=h(this,e);a.width=i*r,a.height=o*r,f(this,n,{...h(this,n),devicePixelRatio:r}),!0===l&&(a.style.width=`${i}px`,a.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=h(this,n),{width:i,height:o}=h(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return h(this,e).canvas}get fillStyle(){return h(this,e).fillStyle}set fillStyle(t){h(this,e).fillStyle=t}get strokeStyle(){return h(this,e).strokeStyle}set strokeStyle(t){h(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(h(this,e).lineWidth)}set lineWidth(t){h(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return h(this,e).textAlign}set textAlign(t){h(this,e).textAlign=t}get textBaseline(){return h(this,e).textBaseline}set textBaseline(t){h(this,e).textBaseline=t}get globalAlpha(){return h(this,e).globalAlpha}set globalAlpha(t){h(this,e).globalAlpha=t}get shadowColor(){return h(this,e).shadowColor}set shadowColor(t){h(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(h(this,e).shadowOffsetX)}set shadowOffsetX(t){h(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(h(this,e).shadowOffsetY)}set shadowOffsetY(t){h(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(h(this,e).shadowBlur)}set shadowBlur(t){h(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return h(this,e).lineCap}set lineCap(t){h(this,e).lineCap=t}get globalCompositeOperation(){return h(this,e).globalCompositeOperation}set globalCompositeOperation(t){h(this,e).globalCompositeOperation=t}fill(...t){return h(this,e).fill(...t)}arc(t,n,i,o,r,l){return h(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,l)}rect(t,n,i,o){return h(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return h(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return h(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return h(this,e).beginPath()}closePath(){return h(this,e).closePath()}lineTo(t,n){return h(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return h(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return h(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return h(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return h(this,e).setLineDash(n)}stroke(t){return t?h(this,e).stroke(t):h(this,e).stroke()}translate(t,n){return h(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return h(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],l=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],u=t[t.length-1];return 9===t.length?h(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u)):h(this,e).drawImage(n,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u))}createPattern(t,n){return h(this,e).createPattern(t,n)}measureText(t){return h(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?h(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):h(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?h(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):h(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){h(this,e).save()}restore(){h(this,e).restore()}scale(t,n){h(this,e).scale(t,n)}circle(t,n,i,o,r,l,a,s){h(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,l,a,s)}isPointInPath(t,n){return h(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return h(this,e).clip(...t)}setTransform(t,n,i,o,r,l){return h(this,e).setTransform(t,n,i,o,r,l)}getTransform(){return h(this,e).getTransform()}createLinearGradient(t,n,i,o){return h(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,l){return h(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}createConicGradient(t,n,i){return h(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function z(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 k(r,t)}function O(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 k(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function T(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 D(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function j(t){return t>=0||t<0}function W(t){return j(t.x)&&j(t.y)&&t.t>0}function V(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function F(t){return t/180*Math.PI}function B(t,e,n,i){const o=F(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 N(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function H(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 N({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 Q(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}function G(t,e,n){let i=Q(t,e)+n;i>2*Math.PI?i-=2*Math.PI:i<0-2*Math.PI&&(i+=2*Math.PI),i<0&&(i+=2*Math.PI);const o=T(t,e);let r=0,l=0;return 0===i?(r=0,l=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,l=0-Math.cos(i)*o):i===Math.PI/2?(r=o,l=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,l=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,l=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,l=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,l=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,l=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,l=0-o),r+=t.x,l+=t.y,{x:r,y:l}}function U(t,e,n){const{x:i,y:o,w:r,h:l}=t;let a={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+l},h={x:i,y:o+l};if(n&&(n>0||n<0)){const t=F(q(n));a=G(e,a,t),s=G(e,s,t),c=G(e,c,t),h=G(e,h,t)}return[a,s,c,h]}function Y(t){const{angle:e=0}=t;return U(t,N(t),e)}function X(t,e,n){return[G(t,{x:e[0].x,y:e[0].y},n),G(t,{x:e[1].x,y:e[1].y},n),G(t,{x:e[2].x,y:e[2].y},n),G(t,{x:e[3].x,y:e[3].y},n)]}function q(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function Z(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const l={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(l.angle&&(l.angle>0||l.angle<0)){const t=Y(l);if(4===t.length){const e=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];l.x=Math.min(...e),l.y=Math.min(...n),l.w=Math.abs(Math.max(...e)-Math.min(...e)),l.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(l.x,n.x),e=Math.min(l.y,n.y),i=Math.max(l.x+l.w,n.x+n.w),o=Math.max(l.y+l.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=l.x,n.y=l.y,n.w=l.w,n.h=l.h;i=l}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}}function J(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=Y(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),l=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(l-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function K(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=o[e[t]];if("group"!==(null==r?void 0:r.type)||!Array.isArray(null==(n=null==r?void 0:r.detail)?void 0:n.children))return null;i.push(r),o=r.detail.children}return i}function _(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 tt(t,e){const n=[];let i=!1;const o=e=>{var r;for(let l=0;l<e.length&&!0!==i;l++){n.push(l);const a=e[l];if(a.uuid===t){i=!0;break}if("group"===a.type&&o((null==(r=null==a?void 0:a.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function et(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,l=e.x,a=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=l&&i<=c&&r>=a}function nt(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 it(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?nt(t):U(t,N({x:e,y:n,w:i,h:o,angle:r}),r)}function ot(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:l,y:a,w:s,h:c,angle:h=0}=r[t];let u;if(n+=l,i+=a,0===t){const t={x:n,y:i,w:s,h:c,angle:h};u=it({x:l,y:a,w:s,h:c,angle:h}),o.push({center:N(t),angle:h,radian:F(h)})}else{u=nt({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=X(e,u,n)}const t=H(u);if(h>0||h<0){u=X(t,u,F(h))}o.push({center:t,angle:h,radian:F(h)})}e.push(u)}return e}function rt(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[it(t)];return ot([...n,t])}function lt(t,e){return rt(t,e).pop()||null}function at(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:l,angle:a}=t,{scale:s,offsetTop:c,offsetLeft:h}=n;return{x:i*s+h,y:o*s+c,w:r*s,h:l*s,angle:a}}function st(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:l,offsetLeft:a}=n;return{x:i*r+a,y:o*r+l}}function ct(t,e){const{context2d:n,element:i,viewScaleInfo:o}=e,{angle:r=0}=i,{x:l,y:a,w:s,h:c}=at(i,{viewScaleInfo:o}),h=Y({x:l,y:a,w:s,h:c,angle:r});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 ht(t,e,n){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y],r=Math.min(...i),l=Math.max(...i),a=Math.min(...o),s=Math.max(...o);return t.x>r&&t.x<l&&t.y>a&&t.y<s||!0===(null==n?void 0:n.includeBorder)&&(t.x===r||t.x===l||t.y===a||t.y===s)}function ut(t,e){const{groupQueue:n}=e,i=lt(t,{groupQueue:n}),o=V(i[0],i[1]),r=V(i[1],i[2]),l=V(i[2],i[3]),a=V(i[3],i[0]),s=i[0],c=i[1],h=i[2],u=i[3],f=Math.max(s.x,c.x,h.x,u.x),d=Math.max(s.y,c.y,h.y,u.y);return{center:{x:(f+Math.min(s.x,c.x,h.x,u.x))/2,y:(d+Math.min(s.y,c.y,h.y,u.y))/2},topLeft:s,topRight:c,bottomLeft:u,bottomRight:h,top:o,right:r,left:a,bottom:l}}function ft(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},l={x:i,y:o},a={x:e,y:o},s={x:e,y:n},c={x:i,y:n},h=V(l,a),u=V(c,s),f=V(l,c);return{center:r,topLeft:l,topRight:a,bottomLeft:c,bottomRight:s,top:h,right:V(a,s),left:f,bottom:u}}function dt(t,e){const n=gt(e);let i=0,o=0;return Object.keys(t).forEach((e=>{const r=t[e];r.isVisibleInView=function(t,e){const n=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),i=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),r=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),l=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),a=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),s=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),c=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y);return n<=a&&i>=l&&o<=c&&r>=s||a<=r&&a>=r&&a<=r&&a>=r}(r.rangeRectInfo,n),r.isVisibleInView?i++:o++})),{viewVisibleInfoMap:t,visibleCount:i,invisibleCount:o}}function gt(t){const{viewScaleInfo:e,viewSizeInfo:n}=t,{scale:i,offsetTop:o,offsetLeft:r}=e,{width:l,height:a}=n,s=0-r/i,c=0-o/i,h=l/i,u=a/i,f=N({x:s,y:c,w:h,h:u});return{center:f,topLeft:{x:s,y:c},topRight:{x:s+h,y:c},bottomLeft:{x:s,y:c+u},bottomRight:{x:s+h,y:c+u},left:{x:s,y:f.y},top:{x:f.x,y:c},right:{x:s+h,y:f.y},bottom:{x:f.x,y:c+u}}}function yt(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakSet,s=function(){return b(h(this,r))};const mt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,pt=/(-?\d+(?:\.\d+)?)/gi;const xt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,vt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,bt=/^\s*$/,wt={};function Mt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(wt[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(xt);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 Rt(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(Rt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function Pt(t,e){let n=2;return void 0!==(null==e?void 0:e.decimalPlaces)&&(null==e?void 0:e.decimalPlaces)>=0&&(n=e.decimalPlaces),parseFloat(t.toFixed(n))}function It(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 St="Text Element";function Et(){return{boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"}}function Lt(){return{background:"#D9D9D9"}}const $t={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};const At=t=>Pt(t,{decimalPlaces:4});function Ct(t,e){const{detail:n}=t,{xRatio:i,yRatio:o,maxRatio:r}=e,l=(i+o)/2,{borderWidth:a,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:u,shadowBlur:f}=n;if("number"==typeof a)n.borderWidth=At(a*l);else if(Array.isArray(n.borderWidth)){const t=a;n.borderWidth=[At(t[0]*o),At(t[1]*i),At(t[2]*o),At(t[3]*i)]}if("number"==typeof s)n.borderRadius=At(s*l);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]=At(t*r)})),"number"==typeof h&&(n.shadowOffsetX=At(h*r)),"number"==typeof u&&(n.shadowOffsetX=At(u*r)),"number"==typeof f&&(n.shadowOffsetX=At(f*r))}function kt(t,e){const{type:n}=t;!function(t,e){const{xRatio:n,yRatio:i}=e,{x:o,y:r,w:l,h:a}=t;t.x=At(o*n),t.y=At(r*i),t.w=At(l*n),t.h=At(a*i),Ct(t,e)}(t,e),"circle"===n||("text"===n?function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,l=(n+i)/2;o&&o>0&&(t.detail.fontSize=At(o*l)),r&&r>0&&(t.detail.lineHeight=At(r*l))}(t,e):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{kt(t,e)})))}function zt(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 l=Math.min(o,r),a=Math.max(o,r);t.w=n,t.h=i;const s={xRatio:o,yRatio:r,minRatio:l,maxRatio:a};return"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{kt(t,s)})),Ct(t,s),t}const Ot=200,Tt=200;function Dt(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 jt(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){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{elements:t,from:n,to:i};if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return{elements:t,from:n,to:i};const o=_(n,t);if(o){if(!Dt(o,i,t))return{elements:t,from:n,to:i};let e=-1,r=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(r=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){r=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(r=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(r=!0),n[t]===i[t]);t++);}if(!0===r)for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),jt(n,t)}return{elements:t,from:n,to:i}}function Vt(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)&&(M.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),M.json(t[r])&&(t[r]={...t[r],...e[r]})):M.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),M.array(t[r])&&(null==(n=null==e?void 0:e[r])||n.forEach(((e,n)=>{t[r][n]=e})),t[r]=[...t[r],...e[r]])))}return t}function Ft(t,e,n){var i;const o=_(t,n);return o&&("group"===o.type&&!0===(null==(i=o.operations)?void 0:i.deepResize)&&(e.w&&e.w>0||e.h&&e.h>0)&&zt(o,{w:e.w,h:e.h}),Vt(o,e)),o}function Bt(t,e,n=void 0){const i=e.split(".").reduce(((t,e)=>Object(t)[e]),t);return void 0===i?n:i}function Nt(t,e,n){const i=e.split(".");return"object"!=typeof t||i.reduce(((t,e,i,o)=>i===o.length-1?(t[e]=n,null):(e in t||(t[e]=/^[0-9]{1,}$/.test(o[i+1])?[]:{}),t[e])),t),t}const Ht=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];return t.Context2D=k,t.EventEmitter=class{constructor(){u(this,i,void 0),f(this,i,new Map)}on(t,e){if(h(this,i).has(t)){const n=h(this,i).get(t)||[];null==n||n.push(e),h(this,i).set(t,n)}else h(this,i).set(t,[e])}off(t,e){if(h(this,i).has(t)){const n=h(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}h(this,i).set(t,n||[])}}trigger(t,e){const n=h(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(h(this,i).has(t)){const e=h(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){h(this,i).clear()}},t.Store=class{constructor(t){u(this,a),u(this,o,void 0),u(this,r,void 0),u(this,l,void 0),f(this,r,b(t.defaultStorage)),f(this,o,d(this,a,s).call(this)),f(this,l,t.defaultStatic||{})}set(t,e){h(this,o)[t]=e}get(t){return h(this,o)[t]}setStatic(t,e){h(this,l)[t]=e}getStatic(t){return h(this,l)[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?b(h(this,o)):{...h(this,o)}}clear(){f(this,o,d(this,a,s).call(this))}destroy(){f(this,o,null),f(this,l,null)}},t.calcDistance=T,t.calcElementCenter=N,t.calcElementCenterFromVertexes=H,t.calcElementListSize=Z,t.calcElementOriginRectInfo=ut,t.calcElementQueueVertexesQueueInGroup=ot,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=e,r=(i&&i>0?i:8)/o.scale,{x:l,y:a,w:s,h:c,angle:h=0}=t,u=[{uuid:m(),x:l,y:a,w:s,h:c,angle:h,type:"group",detail:{children:[]}},...n];let f=0;u.forEach((({angle:t=0})=>{f+=t}));const d=lt(t,{groupQueue:n}),g=lt({x:l-2*r,y:a-2*r,h:c+4*r,w:s+4*r,angle:h},{groupQueue:[...n]}),y=V(d[0],d[1]),p=V(d[1],d[2]),x=V(d[2],d[3]),v=V(d[3],d[0]),b=d[0],w=d[1],M=d[2],R=d[3],P=yt(y,{size:r,angle:f}),I=yt(p,{size:r,angle:f}),S=yt(x,{size:r,angle:f}),E=yt(v,{size:r,angle:f}),L=yt(b,{size:r,angle:f}),$=yt(w,{size:r,angle:f}),A=yt(R,{size:r,angle:f}),C=yt(M,{size:r,angle:f}),k=it(L),z=it($),O=it(A),T=it(C),D=[k[1],z[0],z[3],k[2]],j=[z[3],z[2],T[1],T[0]],W=[O[1],T[0],T[3],O[2]],F=[k[3],k[2],O[1],O[0]],B=it(P),N=it(I),H=it(S),Q=it(E),G=V(g[0],g[1]);return{elementWrapper:d,left:{type:"left",vertexes:F,center:v},right:{type:"right",vertexes:j,center:p},top:{type:"top",vertexes:D,center:y},bottom:{type:"bottom",vertexes:W,center:x},topLeft:{type:"top-left",vertexes:k,center:b},topRight:{type:"top-right",vertexes:z,center:w},bottomLeft:{type:"bottom-left",vertexes:O,center:R},bottomRight:{type:"bottom-right",vertexes:T,center:M},leftMiddle:{type:"left-middle",vertexes:Q,center:v},rightMiddle:{type:"right-middle",vertexes:N,center:p},topMiddle:{type:"top-middle",vertexes:B,center:y},bottomMiddle:{type:"bottom-middle",vertexes:H,center:x},rotate:{type:"rotate",vertexes:it(yt(G,{size:r,angle:f})),center:G}}},t.calcElementVertexesInGroup=lt,t.calcElementVertexesQueueInGroup=rt,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=ut(t,{groupQueue:n}),{center:l,top:a,bottom:s,left:c,right:h,topLeft:u,topRight:f,bottomLeft:d,bottomRight:g}=r,y={center:st(l,{viewScaleInfo:i}),topLeft:st(u,{viewScaleInfo:i}),topRight:st(f,{viewScaleInfo:i}),bottomLeft:st(d,{viewScaleInfo:i}),bottomRight:st(g,{viewScaleInfo:i}),top:st(a,{viewScaleInfo:i}),right:st(h,{viewScaleInfo:i}),left:st(c,{viewScaleInfo:i}),bottom:st(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(y.topLeft.x,y.topRight.x,y.bottomRight.x,y.bottomLeft.x),e=Math.max(y.topLeft.y,y.topRight.y,y.bottomRight.y,y.bottomLeft.y),n=Math.min(y.topLeft.x,y.topRight.x,y.bottomRight.x,y.bottomLeft.x),i=Math.min(y.topLeft.y,y.topRight.y,y.bottomRight.y,y.bottomLeft.y),o={x:y.center.x,y:y.center.y},r={x:n,y:i},l={x:t,y:i},a={x:t,y:e},s={x:n,y:e},c=V(r,l),h=V(s,a),u=V(r,s);return{center:o,topLeft:r,topRight:l,bottomLeft:s,bottomRight:a,top:c,right:V(l,a),left:u,bottom:h}}return y},t.calcElementViewRectInfoMap=function(t,e){const{groupQueue:n,viewScaleInfo:i}=e,o=ut(t,{groupQueue:n}),{center:r,top:l,bottom:a,left:s,right:c,topLeft:h,topRight:u,bottomLeft:f,bottomRight:d}=o,g={center:st(r,{viewScaleInfo:i}),topLeft:st(h,{viewScaleInfo:i}),topRight:st(u,{viewScaleInfo:i}),bottomLeft:st(f,{viewScaleInfo:i}),bottomRight:st(d,{viewScaleInfo:i}),top:st(l,{viewScaleInfo:i}),right:st(c,{viewScaleInfo:i}),left:st(s,{viewScaleInfo:i}),bottom:st(a,{viewScaleInfo:i})},y=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),m=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),p=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),x=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),v={x:g.center.x,y:g.center.y},b={x:p,y:x},w={x:y,y:x},M={x:y,y:m},R={x:p,y:m},P=V(b,w),I=V(R,M),S=V(b,R);return{originRectInfo:o,rangeRectInfo:{center:v,topLeft:b,topRight:w,bottomLeft:R,bottomRight:M,top:P,right:V(w,M),left:S,bottom:I}}},t.calcElementsContextSize=J,t.calcElementsViewInfo=function(t,e,n){const i=J(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,o=n&&n>0?n:8,{x:r,y:l,w:a,h:s}=at(t,{viewScaleInfo:i}),c=N({x:r,y:l,w:a,h:s}),h={x:c.x,y:l},u={x:r+a,y:c.y},f={x:c.x,y:l+s},d={x:r,y:c.y},g={x:r,y:l},y={x:r+a,y:l},m={x:r+a,y:l+s},p={x:r,y:l+s},x=yt(h,{size:o,angle:0}),v=yt(u,{size:o,angle:0}),b=yt(f,{size:o,angle:0}),w=yt(d,{size:o,angle:0}),M=yt(g,{size:o,angle:0}),R=yt(y,{size:o,angle:0}),P=yt(p,{size:o,angle:0}),I=yt(m,{size:o,angle:0}),S=it(M),E=it(R),L=it(P),$=it(I),A=[S[1],E[0],E[3],S[2]],C=[E[3],E[2],$[1],$[0]],k=[L[1],$[0],$[3],L[2]],z=[S[3],S[2],L[1],L[0]],O=it(x),T=it(v),D=it(b);return{left:{type:"left",vertexes:z,center:d},right:{type:"right",vertexes:C,center:u},top:{type:"top",vertexes:A,center:h},bottom:{type:"bottom",vertexes:k,center:f},topLeft:{type:"top-left",vertexes:S,center:g},topRight:{type:"top-right",vertexes:E,center:y},bottomLeft:{type:"bottom-left",vertexes:L,center:p},bottomRight:{type:"bottom-right",vertexes:$,center:m},leftMiddle:{type:"left-middle",vertexes:it(w),center:d},rightMiddle:{type:"right-middle",vertexes:T,center:u},topMiddle:{type:"top-middle",vertexes:O,center:h},bottomMiddle:{type:"bottom-middle",vertexes:D,center:f}}},t.calcRadian=function(t,e,n){const i=Q(t,e),o=Q(t,n);return null!==o&&null!==i?i>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-i):o>3*Math.PI/2&&i<Math.PI/2?i+(2*Math.PI-o):o-i:0},t.calcSpeed=function(t,e){return T(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o,borderDash:r}=t.detail;const l=Array.isArray(r)&&r.length>0,{boxSizing:a=$t.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:c,y:h,w:u,h:f}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*i;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let g=0;return"number"==typeof s&&(g=(s||0)*i),"border-box"!==a||l?"content-box"===a?(c=t.x-g/2,h=t.y-g/2,u=t.w+g,f=t.h+g):(c=t.x,h=t.y,u=t.w,f=t.h):(c=t.x+g/2,h=t.y+g/2,u=t.w-g,f=t.h-g),u=Math.max(u,1),f=Math.max(f,1),d=d.map((t=>Math.min(t,u/2,f/2))),{x:c,y:h,w:u,h:f,radiusList:d}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:l,scale:a}=i,{width:s,height:c}=o;e=0-r+s/a/2,n=0-l+c/a/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,l,a,s,c,h,u;let f=0,d=0,g=1,y=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,m=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,p=(null==(a=null==(l=null==t?void 0:t.elements)?void 0:l[0])?void 0:a.w)||0,x=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:v,height:b}=e.viewSizeInfo;if(t.layout&&"hidden"===(null==(u=null==(h=t.layout)?void 0:h.detail)?void 0:u.overflow)?(y=0,m=0,p=t.layout.w||0,x=t.layout.h||0):t.elements.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=Y(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,y),i=Math.min(e.y,m),o=Math.max(e.x+e.w,y+p),r=Math.max(e.y+e.h,m+x);y=n,m=i,p=Math.abs(o-n),x=Math.abs(r-i)})),t.layout){const{x:e,y:n,w:i,h:o}=t.layout;$.x(e)&&$.y(n)&&$.w(i)&&$.h(o)&&(y=Math.min(y,e),m=Math.min(m,n),p=Math.max(p,i),x=Math.max(x,o))}if(p>0&&x>0){const t=Pt(v/p,{decimalPlaces:4}),e=Pt(b/x,{decimalPlaces:4});g=Math.min(t,e,1),f=(p*g-v)/2/g+y,d=(x*g-b)/2/g+m}return{offsetX:Pt(f,{decimalPlaces:0}),offsetY:Pt(d,{decimalPlaces:0}),scale:g}},t.calcViewElementSize=at,t.calcViewPointSize=st,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:l,height:a,contextWidth:s,contextHeight:c}=r,h=0-i*n,u=0-o*n;return{scale:n,offsetLeft:h,offsetTop:u,offsetRight:l-(s*n+h/n),offsetBottom:a-(c*n+u/n)}},t.calcViewVertexes=function(t,e){return[st(t[0],e),st(t[1],e),st(t[2],e),st(t[3],e)]},t.calcVisibleOriginCanvasRectInfo=gt,t.check=C,t.checkRectIntersect=et,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=y[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,l=t*n,a=o*n;let s=document.createElement("canvas");s.width=l,s.height=a;s.getContext("2d").drawImage(r,0,0,l,a);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=x,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r,createCustomContext2D:l}=e,a={width:n,height:i,devicePixelRatio:o},s=t.getContext("2d");if(l){const t=l(a),e=l(a),n=l(a),i=z({ctx:s,...a}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underlayContext:n,viewContext:t,overlayContext:e,boardContext:i,drawView:o}}if(!0===r){const t=O(a),e=O(a),n=O(a),i=z({ctx:s,...a}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underlayContext:n,viewContext:t,overlayContext:e,boardContext:i,drawView:o}}{const t=z(a),e=z(a),o=z(a),r=z({ctx:s,...a}),l=()=>{r.clearRect(0,0,n,i),r.drawImage(o.canvas,0,0,n,i),r.drawImage(t.canvas,0,0,n,i),r.drawImage(e.canvas,0,0,n,i),o.clearRect(0,0,n,i),t.clearRect(0,0,n,i),e.clearRect(0,0,n,i)};return{underlayContext:o,viewContext:t,overlayContext:e,boardContext:r,drawView:l}}},t.createContext2D=z,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=Ot,r=Tt;if(e){const{viewScaleInfo:l,viewSizeInfo:a}=e,{scale:s,offsetLeft:c,offsetTop:h}=l,{width:u,height:f}=a,d=u/4,g=f/4;o=Ot>=d?d/s:Ot/s,r=Tt>=g?g/s:Tt/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/St.length*2),n=(0-c+u/2-o*s/2)/s,i=(0-h+f/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};return{text:St,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,lineHeight:t.w/St.length,fontSize:t.w/St.length,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===t?o={svg:'<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'}:"image"===t?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===t&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{...i,...e,uuid:m(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=O,t.createUUID=m,t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{t(...i),n=-1}),e)}},t.deepClone=b,t.deepCloneElement=function(t){const e=b(t),n=t=>{t.uuid=m(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e},t.deepResizeGroupElement=zt,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return jt(tt(t,e),e)},t.deleteElementInListByPosition=jt,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.enhanceFontFamliy=function(t){return[t,...Ht].join(", ")},t.equalPoint=D,t.equalTouchPoint=function(t,e){return!0===D(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=b(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,l;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(v(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const e=x(i);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source))n[e]={type:"svg",value:o[e].source};else if(!n[e]){const i=x(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(v(e)&&!n[e]&&o[e]&&"string"==typeof(null==(l=o[e])?void 0:l.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=x(e);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,r(t.detail.children)}}))};return r(i.elements),i.assets=n,i},t.filterElementAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.detail.src:"svg"===t.type?i=t.detail.svg:"html"===t.type&&(i=t.detail.html),"string"!=typeof i||v(i)||(e=x(i),n={type:t.type,value:i},"image"===t.type?t.detail.src=e:"svg"===t.type?t.detail.svg=e:"html"===t.type&&(t.detail.html=e)),{element:t,assetId:e,assetItem:n}},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const l=n[r];if(l.uuid===e){o=l;break}if(!o&&"group"===l.type){const n=t(e,(null==(i=null==l?void 0:l.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=_,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const l=i[r];t.includes(l.uuid)?n.push(l):"group"===l.type&&e((null==(o=null==l?void 0:l.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=_(t,e);i&&n.push(i)})),n},t.flatElementList=function(t){const e=[],n=[],i=t=>{if(!function(t){var e;if(["rect","circle"].includes(t.type)){const e=t.detail;if(!e.background&&!e.borderWidth)return!1;if("transparent"===e.background&&!e.borderWidth)return!1}if(["group"].includes(t.type)){const e=t.detail||{},{children:n}=e;if(!(n.length>0||e.background||e.borderWidth))return!1;if(!(n.length>0||"transparent"!==e.background||e.borderWidth))return!1}if("text"===t.type&&!t.detail.text)return!1;if("image"===t.type&&!t.detail.src)return!1;if("html"===t.type&&!t.detail.html)return!1;if("svg"===t.type&&!t.detail.svg)return!1;if("path"===t.type){const n=t.detail;if(!((null==(e=null==n?void 0:n.commands)?void 0:e.length)>0))return!1}return!0}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:o,w:r,h:l,angle:a=0}=t,s=0;if(n.forEach((t=>{i+=t.x,o+=t.y,s+=t.angle||0})),s=q(s),0===s)return{x:i,y:o,w:r,h:l,angle:a};s+=t.angle||0,s=q(s);const c=lt(t,{groupQueue:n}),h=G(H(c),c[0],F(0-s));return i=h.x,o=h.y,{x:i,y:o,w:r,h:l,angle:s}}(t,{groupQueue:n}),o={...t,...i};e.push(o)},o=t=>{var e;if(!0!==(null==(e=null==t?void 0:t.operations)?void 0:e.invisible))if("group"===t.type){const{detail:e}=t,{children:r,...l}=e;i({...t,detail:{...l,children:[]}}),n.push(t),r.forEach((t=>{o(t)})),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];o(n)}return e},t.formatNumber=Pt,t.generateHTML=function(t){return t.reduce((function(t,e){return t+Rt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=V,t.getDefaultElementDetailConfig=Et,t.getDefaultElementRectDetail=Lt,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&v(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&v(t.detail.svg)?e.push(t.detail.svg):"html"===t.type&&t.detail.html?e.push(t.detail.html):"group"===t.type&&Array.isArray(t.detail.children)&&n(t.detail.children)}))};return n(t),e},t.getElementPositionFromList=tt,t.getElementPositionMapFromList=function(t,e){const n=[],i={};let o=!1;const r=e=>{var l;for(let a=0;a<e.length&&!0!==o;a++){n.push(a);const s=e[a];if(t.includes(s.uuid)){if(i[s.uuid]=[...n],Object.keys(i).length===t.length){o=!0;break}}else"group"===s.type&&r((null==(l=null==s?void 0:s.detail)?void 0:l.children)||[]);if(o)break;n.pop()}};return r(e),i},t.getElementRotateVertexes=U,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=nt,t.getGroupQueueByElementPosition=K,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let l=0;l<i.length;l++){const a=i[l];if(a.uuid===e){r=a;break}if(!r&&"group"===a.type){n.push(a);const i=t(e,(null==(o=null==a?void 0:a.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getModifiedElement=function(t,e){const n={},i=[],o=t=>{if(M.json(t)){Object.keys(t).forEach((r=>{if(i.push(r),M.json(t[r])||M.array(t[r]))o(t[r]);else{const t=i.join(".");if("uuid"!==t){const o=Bt(e,t);Nt(n,i.join("."),o)}}i.pop()}))}else M.array(t)&&t.forEach((r=>{if(i.push(r),M.json(t[r])||M.array(t[r]))o(t[r]);else{const t=Bt(e,i.join("."));Nt(n,i.join("."),t)}i.pop()}))};return o(t),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:l,viewScaleInfo:a,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,l=0,u=0;for(let t=0;t<=e;t++)o+=c[t].x,l+=c[t].y,u+=c[t].angle||0;const f=c[e];if(f&&"group"===f.type&&Array.isArray(null==(n=f.detail)?void 0:n.children))for(let n=0;n<f.detail.children.length;n++){const d=f.detail.children[n];if(!0!==(null==(i=null==d?void 0:d.operations)?void 0:i.invisible)){if(!d)break;if(ct(t,{context2d:r,element:{x:o+d.x,y:l+d.y,w:d.w,h:d.h,angle:u+(d.angle||0)},viewScaleInfo:a,viewSizeInfo:s})){h.element=d,(e<c.length-1||"group"!==d.type)&&(h.groupQueueIndex=e);break}}}if(h.element)break}if(h.element)return h;for(let e=l.elements.length-1;e>=0;e--){const n=l.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&ct(t,{context2d:r,element:n,viewScaleInfo:a,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.groupElementsByPosition=function(t,e){if(e.length>1){let n=!0,i=[];for(let t=1;t<e.length;t++){const o=e[t-1],r=e[t];if(!(o.length>0&&r.length>0)){n=!1;break}if(o.length!==r.length){n=!1;break}const l=[...o],a=[...r],s=l.pop(),c=a.pop();1===t&&"number"==typeof s&&s>=0&&i.push(s),"number"==typeof c&&c>=0&&i.push(c)}if(!0!==n)return console.error("[idraw]: The grouped elements are not siblings!"),t;i.sort(((t,e)=>t-e));const o=[...e[0]].splice(0,e[0].length-1),r=[],l=[...o,i[0]];for(let e=0;e<i.length;e++){const n=_([...o,i[e]],t);n&&r.push(n)}const a=Z(r);for(let t=0;t<r.length;t++){const e=r[t];e&&(e.x-=a.x,e.y-=a.y)}for(let e=i.length-1;e>=0;e--){jt([...o,i[e]],t)}Dt({name:"Group",uuid:m(),type:"group",...a,detail:{children:r}},l,t)}return t},t.insertElementToListByPosition=Dt,t.is=$,t.isAssetId=v,t.isColorStr=g,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:l}=t,{x:a,y:s,w:c,h:h}=at(t,{viewScaleInfo:i}),u=Y({x:a,y:s,w:c,h:h,angle:l}),f={x:0,y:0,w:o,h:r},d=Math.min(u[0].x,u[1].x,u[2].x,u[3].x),g=Math.min(u[0].y,u[1].y,u[2].y,u[3].y);return et(f,{x:d,y:g,w:Math.max(u[0].x,u[1].x,u[2].x,u[3].x)-d,h:Math.max(u[0].y,u[1].y,u[2].y,u[3].y)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=ct,t.isViewPointInElementSize=function(t,e,n){return ht(t,it(e),n)},t.isViewPointInVertexes=ht,t.istype=M,t.limitAngle=q,t.loadHTML=async function(t,e){t=t.replace(/\&/gi,"&");const n=await function(t,e){const{width:n,height:i}=e;return new Promise(((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),l=new FileReader;l.readAsDataURL(r),l.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},l.onerror=function(t){o(t)}}))}(t,e);return await P(n)},t.loadImage=P,t.loadSVG=async function(t){const e=await function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return await P(e)},t.matrixToAngle=function(t){const e=It(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=It,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^\#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.modifyElement=function(t,e){const{type:n}=e,i={...e.content};if("addElement"===n){const n=e,{element:i,position:o}=n.content;(null==o?void 0:o.length)>0?Dt(i,[...o],t.elements):t.elements.push(i)}else if("deleteElement"===n){const n=e,{position:i}=n.content;jt(i,t.elements)}else if("moveElement"===n){const n=e,{from:o,to:r}=n.content,l=Wt(t.elements,{from:o,to:r});i.from=l.from,i.to=l.to,t.elements=l.elements}else if("updateElement"===n){const n=e,{position:i,afterModifiedElement:o}=n.content;Ft(i,o,t.elements)}return{data:t,content:i}},t.moveElementPosition=Wt,t.originRectInfoToRangeRectInfo=ft,t.parseAngleToRadian=F,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(vt,((r,l)=>{const a="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=l+r.length,h=t.charAt(c);let u;if(s){const t=Mt(r);return o<0?(e.push(t),r):(u=n[o],u.children.push(t),r)}if(a){if(o++,i=Mt(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((!a||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==h&&h)){u=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);bt.test(r)&&(r=" "),(i>-1&&o+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(mt,((t,n,i)=>{const o=i.match(pt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let o=document.createElement("input");o.type="file",e&&(o.accept=e),o.addEventListener("change",(function(){var t;const e=null==(t=o.files)?void 0:t[0];n({file:e}),o=null})),o.addEventListener("error",(function(t){"function"==typeof i&&i(t),o=null})),o.click()},t.rotateByCenter=B,t.rotateElement=function(t,e,n){const i=N(e);B(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=Y,t.rotatePoint=G,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:l,angle:a=0}=t,s=G(N({x:e,y:o,w:r,h:l,angle:a}),{x:n,y:i},F(a));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=X,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=b(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=x(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=x(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=x(e);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.sortElementsViewVisiableInfoMap=function(t,e){const n={},i=[],o=e=>{const r={isVisibleInView:!0,isGroup:"group"===e.type,position:[...i]};let l=null;l=ut(e,{groupQueue:K(t,i)||[]}),n[e.uuid]={...r,originRectInfo:l,rangeRectInfo:$.angle(e.angle)?ft(l):l},"group"===e.type&&e.detail.children.forEach(((t,e)=>{i.push(e),o(t),i.pop()}))};return t.forEach(((t,e)=>{i.push(e),o(t),i.pop()})),dt(n,e)},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^\#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.ungroupElementsByPosition=function(t,e){var n;const i=_(e,t);i&&"group"===(null==i?void 0:i.type)&&Array.isArray(null==(n=null==i?void 0:i.detail)?void 0:n.children)||console.error("[idraw]: The ungrouped element is not a group element!");const o=[...e].splice(0,e.length-1),r=e[e.length-1],{x:l,y:a}=i;return jt(e,t),i.detail.children.forEach(((e,n)=>{e.x+=l,e.y+=a;Dt(e,[...o,r+n],t)})),t},t.updateElementInList=function t(e,n,i){var o,r;let l=null;for(let a=0;a<i.length;a++){const s=i[a];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)&&zt(s,{w:n.w,h:n.h}),Vt(s,n),l=s;break}"group"===s.type&&(l=t(e,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return l},t.updateElementInListByPosition=Ft,t.updateViewVisibleInfoMapStatus=dt,t.vaildPoint=W,t.vaildTouchPoint=function(t){return!0===W(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,l=e/i.scale,a=n.x,s=n.y;return{moveX:a-a*l+(o*l-o),moveY:s-s*l+(r*l-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:l,height:a,contextWidth:s,contextHeight:c}=o;let h=i.offsetLeft,u=i.offsetRight,f=i.offsetTop,d=i.offsetBottom;return h+=e,f+=n,u=l-(s*r+h),d=a-(c*r+f),{scale:r,offsetTop:f,offsetLeft:h,offsetRight:u,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
|
|
1
|
+
var iDrawUtil=function(t){"use strict";var e,n,i,o,r,l,a,s,c=t=>{throw TypeError(t)},h=(t,e,n)=>e.has(t)||c("Cannot "+n),u=(t,e,n)=>(h(t,e,"read from private field"),n?n.call(t):e.get(t)),f=(t,e,n)=>e.has(t)?c("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),d=(t,e,n,i)=>(h(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),g=(t,e,n)=>(h(t,e,"access private method"),n);function y(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 m={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function p(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function x(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 v(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/${x(e.toString(16).padEnd(4,i))}${x(t.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${x(t.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${x(t.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${x(t.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${x(t.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${x(t.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${x(o.padEnd(4,i).padEnd(4,o))}`}function b(t){return/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${t}`)}function w(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach((e=>{n.push(t(e))})),n}if("Object"===n){const n={};Object.keys(e).forEach((i=>{n[i]=t(e[i])}));return Object.getOwnPropertySymbols(e).forEach((i=>{n[i]=t(e[i])})),n}}(t)}function M(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(t,e){const n=M(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===M(t),json:t=>"Object"===M(t),function:t=>"Function"===M(t),asyncFunction:t=>"AsyncFunction"===M(t),boolean:t=>"Boolean"===M(t),string:t=>"String"===M(t),number:t=>"Number"===M(t),undefined:t=>"Undefined"===M(t),null:t=>"Null"===M(t),promise:t=>"Promise"===M(t)};const{Image:P}=window;function I(t){return new Promise(((e,n)=>{const i=new P;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function S(t){return"number"==typeof t&&(t>0||t<=0)}function E(t){return"number"==typeof t&&t>=0}function L(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function $(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const z={x:function(t){return S(t)},y:function(t){return S(t)},w:E,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:S,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return E(t)},borderRadius:function(t){return S(t)&&t>=0},color:function(t){return y(t)},imageSrc:function(t){return $(t)||L(t)},imageURL:L,imageBase64:$,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return S(t)&&t>0},lineHeight:function(t){return S(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 S(t)&&t>0}};function A(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!z.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!z.number(n))&&!(t.hasOwnProperty("borderWidth")&&!z.number(i)))}const C={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(z.x(e)&&z.y(n)&&z.w(i)&&z.h(o)&&z.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:l,fontWeight:a,background:s,strokeWidth:c,strokeColor:h}=t;return!!z.text(e)&&(!!z.color(n)&&(!!z.fontSize(i)&&(!(t.hasOwnProperty("background")&&!z.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!z.fontWeight(a))&&(!(t.hasOwnProperty("lineHeight")&&!z.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!z.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!z.textAlign(l))&&(!(t.hasOwnProperty("strokeWidth")&&!z.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!z.color(h))&&!!A(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!z.color(e))&&!!A(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!z.color(e))&&(!(t.hasOwnProperty("borderColor")&&!z.color(n))&&!(t.hasOwnProperty("borderWidth")&&!z.number(i)))},imageDesc:function(t){const{src:e}=t;return!!z.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!z.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!z.html(e)}};class k{constructor(t,i){f(this,e),f(this,n),d(this,e,t),d(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i}),this.$resetFont()}$undoPixelRatio(t){return t/u(this,n).devicePixelRatio}$doPixelRatio(t){return u(this,n).devicePixelRatio*t}$getContext(){return u(this,e)}$setContext(t){d(this,e,t)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),u(this,e).font=`${n.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return u(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:l}=t,{canvas:a}=u(this,e);a.width=i*r,a.height=o*r,d(this,n,{...u(this,n),devicePixelRatio:r}),!0===l&&(a.style.width=`${i}px`,a.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=u(this,n),{width:i,height:o}=u(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return u(this,e).canvas}get fillStyle(){return u(this,e).fillStyle}set fillStyle(t){u(this,e).fillStyle=t}get strokeStyle(){return u(this,e).strokeStyle}set strokeStyle(t){u(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(u(this,e).lineWidth)}set lineWidth(t){u(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return u(this,e).textAlign}set textAlign(t){u(this,e).textAlign=t}get textBaseline(){return u(this,e).textBaseline}set textBaseline(t){u(this,e).textBaseline=t}get globalAlpha(){return u(this,e).globalAlpha}set globalAlpha(t){u(this,e).globalAlpha=t}get shadowColor(){return u(this,e).shadowColor}set shadowColor(t){u(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(u(this,e).shadowOffsetX)}set shadowOffsetX(t){u(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(u(this,e).shadowOffsetY)}set shadowOffsetY(t){u(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(u(this,e).shadowBlur)}set shadowBlur(t){u(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return u(this,e).lineCap}set lineCap(t){u(this,e).lineCap=t}get globalCompositeOperation(){return u(this,e).globalCompositeOperation}set globalCompositeOperation(t){u(this,e).globalCompositeOperation=t}fill(...t){return u(this,e).fill(...t)}arc(t,n,i,o,r,l){return u(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,l)}rect(t,n,i,o){return u(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return u(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return u(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return u(this,e).beginPath()}closePath(){return u(this,e).closePath()}lineTo(t,n){return u(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return u(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return u(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return u(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return u(this,e).setLineDash(n)}stroke(t){return t?u(this,e).stroke(t):u(this,e).stroke()}translate(t,n){return u(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return u(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],l=t[4],a=t[t.length-4],s=t[t.length-3],c=t[t.length-2],h=t[t.length-1];return 9===t.length?u(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(h)):u(this,e).drawImage(n,this.$doPixelRatio(a),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(h))}createPattern(t,n){return u(this,e).createPattern(t,n)}measureText(t){return u(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?u(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):u(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?u(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):u(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){u(this,e).save()}restore(){u(this,e).restore()}scale(t,n){u(this,e).scale(t,n)}circle(t,n,i,o,r,l,a,s){u(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,l,a,s)}isPointInPath(t,n){return u(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return u(this,e).clip(...t)}setTransform(t,n,i,o,r,l){return u(this,e).setTransform(t,n,i,o,r,l)}getTransform(){return u(this,e).getTransform()}createLinearGradient(t,n,i,o){return u(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,l){return u(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(l))}createConicGradient(t,n,i){return u(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function O(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 k(r,t)}function T(t){const{width:e,height:n,devicePixelRatio:i}=t,o=new OffscreenCanvas(e*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new k(r,{devicePixelRatio:i,offscreenCanvas:o})}e=new WeakMap,n=new WeakMap;function D(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function j(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function W(t){return t>=0||t<0}function V(t){return W(t.x)&&W(t.y)&&t.t>0}function F(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function B(t){return t/180*Math.PI}function N(t,e,n,i){const o=B(e||0);n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(o),t.translate(-n.x,-n.y)),i(t),n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(-o),t.translate(-n.x,-n.y))}function H(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Q(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return H({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function G(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}function U(t,e,n){let i=G(t,e)+n;i>2*Math.PI?i-=2*Math.PI:i<0-2*Math.PI&&(i+=2*Math.PI),i<0&&(i+=2*Math.PI);const o=D(t,e);let r=0,l=0;return 0===i?(r=0,l=0-o):i>0&&i<Math.PI/2?(r=Math.sin(i)*o,l=0-Math.cos(i)*o):i===Math.PI/2?(r=o,l=0):i>Math.PI/2&&i<Math.PI?(r=Math.sin(Math.PI-i)*o,l=Math.cos(Math.PI-i)*o):i===Math.PI?(r=0,l=o):i>Math.PI&&i<1.5*Math.PI?(r=0-Math.sin(i-Math.PI)*o,l=Math.cos(i-Math.PI)*o):i===1.5*Math.PI?(r=0-o,l=0):i>1.5*Math.PI&&i<2*Math.PI?(r=0-Math.sin(2*Math.PI-i)*o,l=0-Math.cos(2*Math.PI-i)*o):i===2*Math.PI&&(r=0,l=0-o),r+=t.x,l+=t.y,{x:r,y:l}}function Y(t,e,n){const{x:i,y:o,w:r,h:l}=t;let a={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+l},h={x:i,y:o+l};if(n&&(n>0||n<0)){const t=B(Z(n));a=U(e,a,t),s=U(e,s,t),c=U(e,c,t),h=U(e,h,t)}return[a,s,c,h]}function X(t){const{angle:e=0}=t;return Y(t,H(t),e)}function q(t,e,n){return[U(t,{x:e[0].x,y:e[0].y},n),U(t,{x:e[1].x,y:e[1].y},n),U(t,{x:e[2].x,y:e[2].y},n),U(t,{x:e[3].x,y:e[3].y},n)]}function Z(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function J(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const l={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(l.angle&&(l.angle>0||l.angle<0)){const t=X(l);if(4===t.length){const e=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];l.x=Math.min(...e),l.y=Math.min(...n),l.w=Math.abs(Math.max(...e)-Math.min(...e)),l.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(l.x,n.x),e=Math.min(l.y,n.y),i=Math.max(l.x+l.w,n.x+n.w),o=Math.max(l.y+l.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=l.x,n.y=l.y,n.w=l.w,n.h=l.h;i=l}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}}function K(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=X(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),l=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(l-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function _(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const r=o[e[t]];if("group"!==(null==r?void 0:r.type)||!Array.isArray(null==(n=null==r?void 0:r.detail)?void 0:n.children))return null;i.push(r),o=r.detail.children}return i}function tt(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 et(t,e){const n=[];let i=!1;const o=e=>{var r;for(let l=0;l<e.length&&!0!==i;l++){n.push(l);const a=e[l];if(a.uuid===t){i=!0;break}if("group"===a.type&&o((null==(r=null==a?void 0:a.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function nt(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,l=e.x,a=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=l&&i<=c&&r>=a}function it(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 ot(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?it(t):Y(t,H({x:e,y:n,w:i,h:o,angle:r}),r)}function rt(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:l,y:a,w:s,h:c,angle:h=0}=r[t];let u;if(n+=l,i+=a,0===t){const t={x:n,y:i,w:s,h:c,angle:h};u=ot({x:l,y:a,w:s,h:c,angle:h}),o.push({center:H(t),angle:h,radian:B(h)})}else{u=it({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=q(e,u,n)}const t=Q(u);if(h>0||h<0){u=q(t,u,B(h))}o.push({center:t,angle:h,radian:B(h)})}e.push(u)}return e}function lt(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[ot(t)];return rt([...n,t])}function at(t,e){return lt(t,e).pop()||null}function st(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:l,angle:a}=t,{scale:s,offsetTop:c,offsetLeft:h}=n;return{x:i*s+h,y:o*s+c,w:r*s,h:l*s,angle:a}}function ct(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:l,offsetLeft:a}=n;return{x:i*r+a,y:o*r+l}}function ht(t,e){const{context2d:n,element:i,viewScaleInfo:o}=e,{angle:r=0}=i,{x:l,y:a,w:s,h:c}=st(i,{viewScaleInfo:o}),h=X({x:l,y:a,w:s,h:c,angle:r});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 ut(t,e,n){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y],r=Math.min(...i),l=Math.max(...i),a=Math.min(...o),s=Math.max(...o);return t.x>r&&t.x<l&&t.y>a&&t.y<s||!0===(null==n?void 0:n.includeBorder)&&(t.x===r||t.x===l||t.y===a||t.y===s)}function ft(t,e){const{groupQueue:n}=e,i=at(t,{groupQueue:n}),o=F(i[0],i[1]),r=F(i[1],i[2]),l=F(i[2],i[3]),a=F(i[3],i[0]),s=i[0],c=i[1],h=i[2],u=i[3],f=Math.max(s.x,c.x,h.x,u.x),d=Math.max(s.y,c.y,h.y,u.y);return{center:{x:(f+Math.min(s.x,c.x,h.x,u.x))/2,y:(d+Math.min(s.y,c.y,h.y,u.y))/2},topLeft:s,topRight:c,bottomLeft:u,bottomRight:h,top:o,right:r,left:a,bottom:l}}function dt(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},l={x:i,y:o},a={x:e,y:o},s={x:e,y:n},c={x:i,y:n},h=F(l,a),u=F(c,s),f=F(l,c);return{center:r,topLeft:l,topRight:a,bottomLeft:c,bottomRight:s,top:h,right:F(a,s),left:f,bottom:u}}function gt(t,e){const n=yt(e);let i=0,o=0;return Object.keys(t).forEach((e=>{const r=t[e];r.isVisibleInView=function(t,e){const n=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),i=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),r=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),l=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),a=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),s=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),c=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y);return n<=a&&i>=l&&o<=c&&r>=s||a<=r&&a>=r&&a<=r&&a>=r}(r.rangeRectInfo,n),r.isVisibleInView?i++:o++})),{viewVisibleInfoMap:t,visibleCount:i,invisibleCount:o}}function yt(t){const{viewScaleInfo:e,viewSizeInfo:n}=t,{scale:i,offsetTop:o,offsetLeft:r}=e,{width:l,height:a}=n,s=0-r/i,c=0-o/i,h=l/i,u=a/i,f=H({x:s,y:c,w:h,h:u});return{center:f,topLeft:{x:s,y:c},topRight:{x:s+h,y:c},bottomLeft:{x:s,y:c+u},bottomRight:{x:s+h,y:c+u},left:{x:s,y:f.y},top:{x:f.x,y:c},right:{x:s+h,y:f.y},bottom:{x:f.x,y:c+u}}}function mt(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,l=new WeakMap,a=new WeakSet,s=function(){return w(u(this,r))};const pt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,xt=/(-?\d+(?:\.\d+)?)/gi;const vt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,bt=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,wt=/^\s*$/,Mt={};function Rt(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(Mt[n[1]]||"/"===t.charAt(t.length-2))&&(e.isVoid=!0),e.name.startsWith("!--"))){const e=t.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==e?t.slice(4,e):""}}const i=new RegExp(vt);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 Pt(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(Pt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function It(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 St(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 Et="Text Element";function Lt(){return{boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"}}function $t(){return{background:"#D9D9D9"}}const zt={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};const At=t=>It(t,{decimalPlaces:4});function Ct(t,e){const{detail:n}=t,{xRatio:i,yRatio:o,maxRatio:r}=e,l=(i+o)/2,{borderWidth:a,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:u,shadowBlur:f}=n;if("number"==typeof a)n.borderWidth=At(a*l);else if(Array.isArray(n.borderWidth)){const t=a;n.borderWidth=[At(t[0]*o),At(t[1]*i),At(t[2]*o),At(t[3]*i)]}if("number"==typeof s)n.borderRadius=At(s*l);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]=At(t*r)})),"number"==typeof h&&(n.shadowOffsetX=At(h*r)),"number"==typeof u&&(n.shadowOffsetX=At(u*r)),"number"==typeof f&&(n.shadowOffsetX=At(f*r))}function kt(t,e){const{type:n}=t;!function(t,e){const{xRatio:n,yRatio:i}=e,{x:o,y:r,w:l,h:a}=t;t.x=At(o*n),t.y=At(r*i),t.w=At(l*n),t.h=At(a*i),Ct(t,e)}(t,e),"circle"===n||("text"===n?function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,l=(n+i)/2;o&&o>0&&(t.detail.fontSize=At(o*l)),r&&r>0&&(t.detail.lineHeight=At(r*l))}(t,e):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{kt(t,e)})))}function Ot(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 l=Math.min(o,r),a=Math.max(o,r);t.w=n,t.h=i;const s={xRatio:o,yRatio:r,minRatio:l,maxRatio:a};return"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{kt(t,s)})),Ct(t,s),t}const Tt=200,Dt=200;function jt(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 Wt(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 Vt(t,e){const n=[...e.from],i=[...e.to];if(0===n.length||0===i.length)return{elements:t,from:n,to:i};if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return{elements:t,from:n,to:i};const o=tt(n,t);if(o){if(!jt(o,i,t))return{elements:t,from:n,to:i};let e=-1,r=!1;if(n.length>=1&&i.length>=1){if(n.length<=i.length)if(1===n.length)n[0]<i[0]&&(r=!0);else for(let t=0;t<n.length&&n[t]===i[t];t++)if(n.length===n.length-1){r=!0;break}if(n.length>=i.length)if(1===i.length)i[0]<n[0]&&(r=!0);else for(let t=0;t<i.length&&(t===i.length-1&&i[t]<n[t]&&(r=!0),n[t]===i[t]);t++);}if(!0===r)for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),Wt(n,t)}return{elements:t,from:n,to:i}}function Ft(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)&&(R.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),R.json(t[r])&&(t[r]={...t[r],...e[r]})):R.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),R.array(t[r])&&(null==(n=null==e?void 0:e[r])||n.forEach(((e,n)=>{t[r][n]=e})),t[r]=[...t[r],...e[r]])))}return t}function Bt(t,e,n){var i;const o=tt(t,n);return o&&("group"===o.type&&!0===(null==(i=o.operations)?void 0:i.deepResize)&&(e.w&&e.w>0||e.h&&e.h>0)&&Ot(o,{w:e.w,h:e.h}),Ft(o,e)),o}function Nt(t,e,n=void 0){const i=e.split(".").reduce(((t,e)=>Object(t)[e]),t);return void 0===i?n:i}function Ht(t,e,n){const i=e.split(".");return"object"!=typeof t||i.reduce(((t,e,i,o)=>i===o.length-1?(t[e]=n,null):(e in t||(t[e]=/^[0-9]{1,}$/.test(o[i+1])?[]:{}),t[e])),t),t}const Qt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];return t.Context2D=k,t.EventEmitter=class{constructor(){f(this,i),d(this,i,new Map)}on(t,e){if(u(this,i).has(t)){const n=u(this,i).get(t)||[];null==n||n.push(e),u(this,i).set(t,n)}else u(this,i).set(t,[e])}off(t,e){if(u(this,i).has(t)){const n=u(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}u(this,i).set(t,n||[])}}trigger(t,e){const n=u(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(u(this,i).has(t)){const e=u(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){u(this,i).clear()}},t.Store=class{constructor(t){f(this,a),f(this,o),f(this,r),f(this,l),d(this,r,w(t.defaultStorage)),d(this,o,g(this,a,s).call(this)),d(this,l,t.defaultStatic||{})}set(t,e){u(this,o)[t]=e}get(t){return u(this,o)[t]}setStatic(t,e){u(this,l)[t]=e}getStatic(t){return u(this,l)[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?w(u(this,o)):{...u(this,o)}}clear(){d(this,o,g(this,a,s).call(this))}destroy(){d(this,o,null),d(this,l,null)}},t.calcDistance=D,t.calcElementCenter=H,t.calcElementCenterFromVertexes=Q,t.calcElementListSize=J,t.calcElementOriginRectInfo=ft,t.calcElementQueueVertexesQueueInGroup=rt,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o,rotateControllerSize:r,rotateControllerPosition:l}=e,a=(i&&i>0?i:8)/o.scale,{x:s,y:c,w:h,h:u,angle:f=0}=t,d=r,g=l,y=[{uuid:p(),x:s,y:c,w:h,h:u,angle:f,type:"group",detail:{children:[]}},...n];let m=0;y.forEach((({angle:t=0})=>{m+=t}));const x=at(t,{groupQueue:n}),v=at({x:s,y:c-(g+d/2)/o.scale,h:u+(2*g+d)/o.scale,w:h,angle:f},{groupQueue:[...n]}),b=F(x[0],x[1]),w=F(x[1],x[2]),M=F(x[2],x[3]),R=F(x[3],x[0]),P=x[0],I=x[1],S=x[2],E=x[3],L=mt(b,{size:a,angle:m}),$=mt(w,{size:a,angle:m}),z=mt(M,{size:a,angle:m}),A=mt(R,{size:a,angle:m}),C=mt(P,{size:a,angle:m}),k=mt(I,{size:a,angle:m}),O=mt(E,{size:a,angle:m}),T=mt(S,{size:a,angle:m}),D=ot(C),j=ot(k),W=ot(O),V=ot(T),B=[D[1],j[0],j[3],D[2]],N=[j[3],j[2],V[1],V[0]],H=[W[1],V[0],V[3],W[2]],Q=[D[3],D[2],W[1],W[0]],G=ot(L),U=ot($),Y=ot(z),X=ot(A),q=F(v[0],v[1]);return{elementWrapper:x,left:{type:"left",vertexes:Q,center:R,size:a},right:{type:"right",vertexes:N,center:w,size:a},top:{type:"top",vertexes:B,center:b,size:a},bottom:{type:"bottom",vertexes:H,center:M,size:a},topLeft:{type:"top-left",vertexes:D,center:P,size:a},topRight:{type:"top-right",vertexes:j,center:I,size:a},bottomLeft:{type:"bottom-left",vertexes:W,center:E,size:a},bottomRight:{type:"bottom-right",vertexes:V,center:S,size:a},leftMiddle:{type:"left-middle",vertexes:X,center:R,size:a},rightMiddle:{type:"right-middle",vertexes:U,center:w,size:a},topMiddle:{type:"top-middle",vertexes:G,center:b,size:a},bottomMiddle:{type:"bottom-middle",vertexes:Y,center:M,size:a},rotate:{type:"rotate",vertexes:ot(mt(q,{size:1.1*r/o.scale,angle:m})),center:q,size:r}}},t.calcElementVertexesInGroup=at,t.calcElementVertexesQueueInGroup=lt,t.calcElementViewRectInfo=function(t,e){const{groupQueue:n,viewScaleInfo:i,range:o}=e,r=ft(t,{groupQueue:n}),{center:l,top:a,bottom:s,left:c,right:h,topLeft:u,topRight:f,bottomLeft:d,bottomRight:g}=r,y={center:ct(l,{viewScaleInfo:i}),topLeft:ct(u,{viewScaleInfo:i}),topRight:ct(f,{viewScaleInfo:i}),bottomLeft:ct(d,{viewScaleInfo:i}),bottomRight:ct(g,{viewScaleInfo:i}),top:ct(a,{viewScaleInfo:i}),right:ct(h,{viewScaleInfo:i}),left:ct(c,{viewScaleInfo:i}),bottom:ct(s,{viewScaleInfo:i})};if(!0===o){const t=Math.max(y.topLeft.x,y.topRight.x,y.bottomRight.x,y.bottomLeft.x),e=Math.max(y.topLeft.y,y.topRight.y,y.bottomRight.y,y.bottomLeft.y),n=Math.min(y.topLeft.x,y.topRight.x,y.bottomRight.x,y.bottomLeft.x),i=Math.min(y.topLeft.y,y.topRight.y,y.bottomRight.y,y.bottomLeft.y),o={x:y.center.x,y:y.center.y},r={x:n,y:i},l={x:t,y:i},a={x:t,y:e},s={x:n,y:e},c=F(r,l),h=F(s,a),u=F(r,s);return{center:o,topLeft:r,topRight:l,bottomLeft:s,bottomRight:a,top:c,right:F(l,a),left:u,bottom:h}}return y},t.calcElementViewRectInfoMap=function(t,e){const{groupQueue:n,viewScaleInfo:i}=e,o=ft(t,{groupQueue:n}),{center:r,top:l,bottom:a,left:s,right:c,topLeft:h,topRight:u,bottomLeft:f,bottomRight:d}=o,g={center:ct(r,{viewScaleInfo:i}),topLeft:ct(h,{viewScaleInfo:i}),topRight:ct(u,{viewScaleInfo:i}),bottomLeft:ct(f,{viewScaleInfo:i}),bottomRight:ct(d,{viewScaleInfo:i}),top:ct(l,{viewScaleInfo:i}),right:ct(c,{viewScaleInfo:i}),left:ct(s,{viewScaleInfo:i}),bottom:ct(a,{viewScaleInfo:i})},y=Math.max(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),m=Math.max(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),p=Math.min(g.topLeft.x,g.topRight.x,g.bottomRight.x,g.bottomLeft.x),x=Math.min(g.topLeft.y,g.topRight.y,g.bottomRight.y,g.bottomLeft.y),v={x:g.center.x,y:g.center.y},b={x:p,y:x},w={x:y,y:x},M={x:y,y:m},R={x:p,y:m},P=F(b,w),I=F(R,M),S=F(b,R);return{originRectInfo:o,rangeRectInfo:{center:v,topLeft:b,topRight:w,bottomLeft:R,bottomRight:M,top:P,right:F(w,M),left:S,bottom:I}}},t.calcElementsContextSize=K,t.calcElementsViewInfo=function(t,e,n){const i=K(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcLayoutSizeController=function(t,e){const{controllerSize:n,viewScaleInfo:i}=e,o=n&&n>0?n:8,{x:r,y:l,w:a,h:s}=st(t,{viewScaleInfo:i}),c=H({x:r,y:l,w:a,h:s}),h={x:c.x,y:l},u={x:r+a,y:c.y},f={x:c.x,y:l+s},d={x:r,y:c.y},g={x:r,y:l},y={x:r+a,y:l},m={x:r+a,y:l+s},p={x:r,y:l+s},x=mt(h,{size:o,angle:0}),v=mt(u,{size:o,angle:0}),b=mt(f,{size:o,angle:0}),w=mt(d,{size:o,angle:0}),M=mt(g,{size:o,angle:0}),R=mt(y,{size:o,angle:0}),P=mt(p,{size:o,angle:0}),I=mt(m,{size:o,angle:0}),S=ot(M),E=ot(R),L=ot(P),$=ot(I),z=[S[1],E[0],E[3],S[2]],A=[E[3],E[2],$[1],$[0]],C=[L[1],$[0],$[3],L[2]],k=[S[3],S[2],L[1],L[0]],O=ot(x),T=ot(v),D=ot(b);return{left:{type:"left",vertexes:k,center:d,size:o},right:{type:"right",vertexes:A,center:u,size:o},top:{type:"top",vertexes:z,center:h,size:o},bottom:{type:"bottom",vertexes:C,center:f,size:o},topLeft:{type:"top-left",vertexes:S,center:g,size:o},topRight:{type:"top-right",vertexes:E,center:y,size:o},bottomLeft:{type:"bottom-left",vertexes:L,center:p,size:o},bottomRight:{type:"bottom-right",vertexes:$,center:m,size:o},leftMiddle:{type:"left-middle",vertexes:ot(w),center:d,size:o},rightMiddle:{type:"right-middle",vertexes:T,center:u,size:o},topMiddle:{type:"top-middle",vertexes:O,center:h,size:o},bottomMiddle:{type:"bottom-middle",vertexes:D,center:f,size:o}}},t.calcRadian=function(t,e,n){const i=G(t,e),o=G(t,n);return null!==o&&null!==i?o-i:0},t.calcSpeed=function(t,e){return D(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o,borderDash:r}=t.detail;const l=Array.isArray(r)&&r.length>0,{boxSizing:a=zt.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:c,y:h,w:u,h:f}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*i;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let g=0;return"number"==typeof s&&(g=(s||0)*i),"border-box"!==a||l?"content-box"===a?(c=t.x-g/2,h=t.y-g/2,u=t.w+g,f=t.h+g):(c=t.x,h=t.y,u=t.w,f=t.h):(c=t.x+g/2,h=t.y+g/2,u=t.w-g,f=t.h-g),u=Math.max(u,1),f=Math.max(f,1),d=d.map((t=>Math.min(t,u/2,f/2))),{x:c,y:h,w:u,h:f,radiusList:d}},t.calcViewCenter=function(t){let e=0,n=0;if(t){const{viewScaleInfo:i,viewSizeInfo:o}=t,{offsetLeft:r,offsetTop:l,scale:a}=i,{width:s,height:c}=o;e=0-r+s/a/2,n=0-l+c/a/2}return{x:e,y:n}},t.calcViewCenterContent=function(t,e){var n,i,o,r,l,a,s,c,h,u;let f=0,d=0,g=1,y=(null==(i=null==(n=null==t?void 0:t.elements)?void 0:n[0])?void 0:i.x)||0,m=(null==(r=null==(o=null==t?void 0:t.elements)?void 0:o[0])?void 0:r.y)||0,p=(null==(a=null==(l=null==t?void 0:t.elements)?void 0:l[0])?void 0:a.w)||0,x=(null==(c=null==(s=null==t?void 0:t.elements)?void 0:s[0])?void 0:c.h)||0;const{width:v,height:b}=e.viewSizeInfo;if(t.layout&&"hidden"===(null==(u=null==(h=t.layout)?void 0:h.detail)?void 0:u.overflow)?(y=0,m=0,p=t.layout.w||0,x=t.layout.h||0):t.elements.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=X(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const n=Math.min(e.x,y),i=Math.min(e.y,m),o=Math.max(e.x+e.w,y+p),r=Math.max(e.y+e.h,m+x);y=n,m=i,p=Math.abs(o-n),x=Math.abs(r-i)})),t.layout){const{x:e,y:n,w:i,h:o}=t.layout;z.x(e)&&z.y(n)&&z.w(i)&&z.h(o)&&(y=Math.min(y,e),m=Math.min(m,n),p=Math.max(p,i),x=Math.max(x,o))}if(p>0&&x>0){const t=It(v/p,{decimalPlaces:4}),e=It(b/x,{decimalPlaces:4});g=Math.min(t,e,1),f=(p*g-v)/2/g+y,d=(x*g-b)/2/g+m}return{offsetX:It(f,{decimalPlaces:0}),offsetY:It(d,{decimalPlaces:0}),scale:g}},t.calcViewElementSize=st,t.calcViewPointSize=ct,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:l,height:a,contextWidth:s,contextHeight:c}=r,h=0-i*n,u=0-o*n;return{scale:n,offsetLeft:h,offsetTop:u,offsetRight:l-(s*n+h/n),offsetBottom:a-(c*n+u/n)}},t.calcViewVertexes=function(t,e){return[ct(t[0],e),ct(t[1],e),ct(t[2],e),ct(t[3],e)]},t.calcVisibleOriginCanvasRectInfo=yt,t.check=C,t.checkRectIntersect=nt,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=m[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,l=t*n,a=o*n;let s=document.createElement("canvas");s.width=l,s.height=a;s.getContext("2d").drawImage(r,0,0,l,a);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=v,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r,createCustomContext2D:l}=e,a={width:n,height:i,devicePixelRatio:o},s=t.getContext("2d");if(l){const t=l(a),e=l(a),n=l(a),i=O({ctx:s,...a}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underlayContext:n,viewContext:t,overlayContext:e,boardContext:i,drawView:o}}if(!0===r){const t=T(a),e=T(a),n=T(a),i=O({ctx:s,...a}),o=()=>{const{width:o,height:r}=t.$getSize();i.clearRect(0,0,o,r),i.drawImage(n.canvas,0,0,o,r),i.drawImage(t.canvas,0,0,o,r),i.drawImage(e.canvas,0,0,o,r),n.clearRect(0,0,o,r),t.clearRect(0,0,o,r),e.clearRect(0,0,o,r)};return{underlayContext:n,viewContext:t,overlayContext:e,boardContext:i,drawView:o}}{const t=O(a),e=O(a),o=O(a),r=O({ctx:s,...a}),l=()=>{r.clearRect(0,0,n,i),r.drawImage(o.canvas,0,0,n,i),r.drawImage(t.canvas,0,0,n,i),r.drawImage(e.canvas,0,0,n,i),o.clearRect(0,0,n,i),t.clearRect(0,0,n,i),e.clearRect(0,0,n,i)};return{underlayContext:o,viewContext:t,overlayContext:e,boardContext:r,drawView:l}}},t.createContext2D=O,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=Tt,r=Dt;if(e){const{viewScaleInfo:l,viewSizeInfo:a}=e,{scale:s,offsetLeft:c,offsetTop:h}=l,{width:u,height:f}=a,d=u/4,g=f/4;o=Tt>=d?d/s:Tt/s,r=Dt>=g?g/s:Dt/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/Et.length*2),n=(0-c+u/2-o*s/2)/s,i=(0-h+f/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};return{text:Et,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,lineHeight:t.w/Et.length,fontSize:t.w/Et.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:p(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=T,t.createUUID=p,t.debounce=function(t,e){let n=-1;return function(...i){n>=0&&window.clearTimeout(n),n=setTimeout((()=>{t(...i),n=-1}),e)}},t.deepClone=w,t.deepCloneElement=function(t){const e=w(t),n=t=>{t.uuid=p(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e},t.deepResizeGroupElement=Ot,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return Wt(et(t,e),e)},t.deleteElementInListByPosition=Wt,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.enhanceFontFamliy=function(t){return[t,...Qt].join(", ")},t.equalPoint=j,t.equalTouchPoint=function(t,e){return!0===j(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=w(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,l;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(b(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else if(!n[i]){const e=v(i);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg;if(b(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source))n[e]={type:"svg",value:o[e].source};else if(!n[e]){const i=v(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}}else if("html"===t.type){const e=t.detail.html;if(b(e)&&!n[e]&&o[e]&&"string"==typeof(null==(l=o[e])?void 0:l.source))n[e]={type:"html",value:o[e].source};else if(!n[e]){const i=v(e);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,r(t.detail.children)}}))};return r(i.elements),i.assets=n,i},t.filterElementAsset=function(t){let e=null,n=null,i=null;return"image"===t.type?i=t.detail.src:"svg"===t.type?i=t.detail.svg:"html"===t.type&&(i=t.detail.html),"string"!=typeof i||b(i)||(e=v(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 l=n[r];if(l.uuid===e){o=l;break}if(!o&&"group"===l.type){const n=t(e,(null==(i=null==l?void 0:l.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=tt,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const l=i[r];t.includes(l.uuid)?n.push(l):"group"===l.type&&e((null==(o=null==l?void 0:l.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=tt(t,e);i&&n.push(i)})),n},t.flatElementList=function(t){const e=[],n=[],i=t=>{if(!function(t){var e;if(["rect","circle"].includes(t.type)){const e=t.detail;if(!e.background&&!e.borderWidth)return!1;if("transparent"===e.background&&!e.borderWidth)return!1}if(["group"].includes(t.type)){const e=t.detail||{},{children:n}=e;if(!(n.length>0||e.background||e.borderWidth))return!1;if(!(n.length>0||"transparent"!==e.background||e.borderWidth))return!1}if("text"===t.type&&!t.detail.text)return!1;if("image"===t.type&&!t.detail.src)return!1;if("html"===t.type&&!t.detail.html)return!1;if("svg"===t.type&&!t.detail.svg)return!1;if("path"===t.type){const n=t.detail;if(!((null==(e=null==n?void 0:n.commands)?void 0:e.length)>0))return!1}return!0}(t))return;const i=function(t,e){const{groupQueue:n}=e;let{x:i,y:o,w:r,h:l,angle:a=0}=t,s=0;if(n.forEach((t=>{i+=t.x,o+=t.y,s+=t.angle||0})),s=Z(s),0===s)return{x:i,y:o,w:r,h:l,angle:a};s+=t.angle||0,s=Z(s);const c=at(t,{groupQueue:n}),h=U(Q(c),c[0],B(0-s));return i=h.x,o=h.y,{x:i,y:o,w:r,h:l,angle:s}}(t,{groupQueue:n}),o={...t,...i};e.push(o)},o=t=>{var e;if(!0!==(null==(e=null==t?void 0:t.operations)?void 0:e.invisible))if("group"===t.type){const{detail:e}=t,{children:r,...l}=e;i({...t,detail:{...l,children:[]}}),n.push(t),r.forEach((t=>{o(t)})),n.pop()}else i(t)};for(let e=0;e<t.length;e++){const n=t[e];o(n)}return e},t.formatNumber=It,t.generateHTML=function(t){return t.reduce((function(t,e){return t+Pt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=F,t.getDefaultElementDetailConfig=Lt,t.getDefaultElementRectDetail=$t,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&b(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&b(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=et,t.getElementPositionMapFromList=function(t,e){const n=[],i={};let o=!1;const r=e=>{var l;for(let a=0;a<e.length&&!0!==o;a++){n.push(a);const s=e[a];if(t.includes(s.uuid)){if(i[s.uuid]=[...n],Object.keys(i).length===t.length){o=!0;break}}else"group"===s.type&&r((null==(l=null==s?void 0:s.detail)?void 0:l.children)||[]);if(o)break;n.pop()}};return r(e),i},t.getElementRotateVertexes=Y,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=it,t.getGroupQueueByElementPosition=_,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let l=0;l<i.length;l++){const a=i[l];if(a.uuid===e){r=a;break}if(!r&&"group"===a.type){n.push(a);const i=t(e,(null==(o=null==a?void 0:a.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getModifiedElement=function(t,e){const n={},i=[],o=t=>{if(R.json(t)){Object.keys(t).forEach((r=>{if(i.push(r),R.json(t[r])||R.array(t[r]))o(t[r]);else{const t=i.join(".");if("uuid"!==t){const o=Nt(e,t);Ht(n,i.join("."),o)}}i.pop()}))}else R.array(t)&&t.forEach((r=>{if(i.push(r),R.json(t[r])||R.array(t[r]))o(t[r]);else{const t=Nt(e,i.join("."));Ht(n,i.join("."),t)}i.pop()}))};return o(t),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:l,viewScaleInfo:a,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,l=0,u=0;for(let t=0;t<=e;t++)o+=c[t].x,l+=c[t].y,u+=c[t].angle||0;const f=c[e];if(f&&"group"===f.type&&Array.isArray(null==(n=f.detail)?void 0:n.children))for(let n=0;n<f.detail.children.length;n++){const d=f.detail.children[n];if(!0!==(null==(i=null==d?void 0:d.operations)?void 0:i.invisible)){if(!d)break;if(ht(t,{context2d:r,element:{x:o+d.x,y:l+d.y,w:d.w,h:d.h,angle:u+(d.angle||0)},viewScaleInfo:a,viewSizeInfo:s})){h.element=d,(e<c.length-1||"group"!==d.type)&&(h.groupQueueIndex=e);break}}}if(h.element)break}if(h.element)return h;for(let e=l.elements.length-1;e>=0;e--){const n=l.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&ht(t,{context2d:r,element:n,viewScaleInfo:a,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.groupElementsByPosition=function(t,e){if(e.length>1){let n=!0,i=[];for(let t=1;t<e.length;t++){const o=e[t-1],r=e[t];if(!(o.length>0&&r.length>0)){n=!1;break}if(o.length!==r.length){n=!1;break}const l=[...o],a=[...r],s=l.pop(),c=a.pop();1===t&&"number"==typeof s&&s>=0&&i.push(s),"number"==typeof c&&c>=0&&i.push(c)}if(!0!==n)return console.error("[idraw]: The grouped elements are not siblings!"),t;i.sort(((t,e)=>t-e));const o=[...e[0]].splice(0,e[0].length-1),r=[],l=[...o,i[0]];for(let e=0;e<i.length;e++){const n=tt([...o,i[e]],t);n&&r.push(n)}const a=J(r);for(let t=0;t<r.length;t++){const e=r[t];e&&(e.x-=a.x,e.y-=a.y)}for(let e=i.length-1;e>=0;e--){Wt([...o,i[e]],t)}jt({name:"Group",uuid:p(),type:"group",...a,detail:{children:r}},l,t)}return t},t.insertElementToListByPosition=jt,t.is=z,t.isAssetId=b,t.isColorStr=y,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:l}=t,{x:a,y:s,w:c,h:h}=st(t,{viewScaleInfo:i}),u=X({x:a,y:s,w:c,h:h,angle:l}),f={x:0,y:0,w:o,h:r},d=Math.min(u[0].x,u[1].x,u[2].x,u[3].x),g=Math.min(u[0].y,u[1].y,u[2].y,u[3].y);return nt(f,{x:d,y:g,w:Math.max(u[0].x,u[1].x,u[2].x,u[3].x)-d,h:Math.max(u[0].y,u[1].y,u[2].y,u[3].y)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=ht,t.isViewPointInElementSize=function(t,e,n){return ut(t,ot(e),n)},t.isViewPointInVertexes=ut,t.istype=R,t.limitAngle=Z,t.loadHTML=async function(t,e){t=t.replace(/\&/gi,"&");const n=await function(t,e){const{width:n,height:i}=e;return new Promise(((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),l=new FileReader;l.readAsDataURL(r),l.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},l.onerror=function(t){o(t)}}))}(t,e);return await I(n)},t.loadImage=I,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 I(e)},t.matrixToAngle=function(t){const e=St(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=St,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^\#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.modifyElement=function(t,e){const{type:n}=e,i={...e.content};if("addElement"===n){const n=e,{element:i,position:o}=n.content;(null==o?void 0:o.length)>0?jt(i,[...o],t.elements):t.elements.push(i)}else if("deleteElement"===n){const n=e,{position:i}=n.content;Wt(i,t.elements)}else if("moveElement"===n){const n=e,{from:o,to:r}=n.content,l=Vt(t.elements,{from:o,to:r});i.from=l.from,i.to=l.to,t.elements=l.elements}else if("updateElement"===n){const n=e,{position:i,afterModifiedElement:o}=n.content;Bt(i,o,t.elements)}return{data:t,content:i}},t.moveElementPosition=Vt,t.originRectInfoToRangeRectInfo=dt,t.parseAngleToRadian=B,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(bt,((r,l)=>{const a="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=l+r.length,h=t.charAt(c);let u;if(s){const t=Rt(r);return o<0?(e.push(t),r):(u=n[o],u.children.push(t),r)}if(a){if(o++,i=Rt(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((!a||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==h&&h)){u=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);wt.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(pt,((t,n,i)=>{const o=i.match(xt),r={type:n,params:o?o.map(Number):[]};return e.push(r),t})),e},t.pickFile=function(t){const{accept:e,success:n,error:i}=t;let o=document.createElement("input");o.type="file",e&&(o.accept=e),o.addEventListener("change",(function(){var t;const e=null==(t=o.files)?void 0:t[0];n({file:e}),o=null})),o.addEventListener("error",(function(t){"function"==typeof i&&i(t),o=null})),o.click()},t.rotateByCenter=N,t.rotateElement=function(t,e,n){const i=H(e);N(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=X,t.rotatePoint=U,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:l,angle:a=0}=t,s=U(H({x:e,y:o,w:r,h:l,angle:a}),{x:n,y:i},B(a));n=s.x,i=s.y})),{x:n,y:i}}return t},t.rotateVertexes=q,t.sortDataAsserts=function(t,e){const n=t.assets||{};let i=t;!0===(null==e?void 0:e.clone)&&(i=w(t));const o=t=>{t.forEach((t=>{if("image"===t.type&&t.detail.src){const e=t.detail.src,i=v(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=v(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=v(e);n[i]||(n[i]={type:"html",value:e}),t.detail.html=i}else if("group"===t.type&&Array.isArray(t.detail.children)){const e=t.detail.assets||{};Object.keys(e).forEach((t=>{n[t]||(n[t]=e[t])})),delete t.detail.assets,o(t.detail.children)}}))};return o(i.elements),i.assets=n,i},t.sortElementsViewVisiableInfoMap=function(t,e){const n={},i=[],o=e=>{const r={isVisibleInView:!0,isGroup:"group"===e.type,position:[...i]};let l=null;l=ft(e,{groupQueue:_(t,i)||[]}),n[e.uuid]={...r,originRectInfo:l,rangeRectInfo:z.angle(e.angle)?dt(l):l},"group"===e.type&&e.detail.children.forEach(((t,e)=>{i.push(e),o(t),i.pop()}))};return t.forEach(((t,e)=>{i.push(e),o(t),i.pop()})),gt(n,e)},t.throttle=function(t,e){let n=-1;return function(...i){n>=0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^\#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.ungroupElementsByPosition=function(t,e){var n;const i=tt(e,t);i&&"group"===(null==i?void 0:i.type)&&Array.isArray(null==(n=null==i?void 0:i.detail)?void 0:n.children)||console.error("[idraw]: The ungrouped element is not a group element!");const o=[...e].splice(0,e.length-1),r=e[e.length-1],{x:l,y:a}=i;return Wt(e,t),i.detail.children.forEach(((e,n)=>{e.x+=l,e.y+=a;jt(e,[...o,r+n],t)})),t},t.updateElementInList=function t(e,n,i){var o,r;let l=null;for(let a=0;a<i.length;a++){const s=i[a];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)&&Ot(s,{w:n.w,h:n.h}),Ft(s,n),l=s;break}"group"===s.type&&(l=t(e,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return l},t.updateElementInListByPosition=Bt,t.updateViewVisibleInfoMapStatus=gt,t.vaildPoint=V,t.vaildTouchPoint=function(t){return!0===V(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,l=e/i.scale,a=n.x,s=n.y;return{moveX:a-a*l+(o*l-o),moveY:s-s*l+(r*l-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:l,height:a,contextWidth:s,contextHeight:c}=o;let h=i.offsetLeft,u=i.offsetRight,f=i.offsetTop,d=i.offsetBottom;return h+=e,f+=n,u=l-(s*r+h),d=a-(c*r+f),{scale:r,offsetTop:f,offsetLeft:h,offsetRight:u,offsetBottom:d}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
|