@idraw/util 0.4.0-beta.6 → 0.4.0-beta.7
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/event.d.ts +3 -2
- package/dist/esm/lib/event.js +28 -11
- package/dist/esm/lib/store.d.ts +3 -4
- package/dist/esm/lib/store.js +26 -8
- package/dist/index.global.js +38 -20
- package/dist/index.global.min.js +1 -1
- package/package.json +1 -1
package/dist/esm/lib/event.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { UtilEventEmitter } from '@idraw/types';
|
|
2
2
|
export declare class EventEmitter<T extends Record<string, any>> implements UtilEventEmitter<T> {
|
|
3
|
-
private
|
|
3
|
+
#private;
|
|
4
4
|
constructor();
|
|
5
5
|
on<K extends keyof T>(eventKey: K, callback: (e: T[K]) => void): void;
|
|
6
6
|
off<K extends keyof T>(eventKey: K, callback: (e: T[K]) => void): void;
|
|
7
|
-
trigger<K extends keyof T>(eventKey: K, e
|
|
7
|
+
trigger<K extends keyof T>(eventKey: K, e?: T[K]): boolean;
|
|
8
8
|
has<K extends keyof T>(name: K | string): boolean;
|
|
9
|
+
destroy(): void;
|
|
9
10
|
}
|
package/dist/esm/lib/event.js
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _EventEmitter_listeners;
|
|
1
13
|
export class EventEmitter {
|
|
2
14
|
constructor() {
|
|
3
|
-
this
|
|
15
|
+
_EventEmitter_listeners.set(this, void 0);
|
|
16
|
+
__classPrivateFieldSet(this, _EventEmitter_listeners, new Map(), "f");
|
|
4
17
|
}
|
|
5
18
|
on(eventKey, callback) {
|
|
6
|
-
if (this.
|
|
7
|
-
const callbacks = this.
|
|
19
|
+
if (__classPrivateFieldGet(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
20
|
+
const callbacks = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(eventKey) || [];
|
|
8
21
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
9
|
-
this.
|
|
22
|
+
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(eventKey, callbacks);
|
|
10
23
|
}
|
|
11
24
|
else {
|
|
12
|
-
this.
|
|
25
|
+
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(eventKey, [callback]);
|
|
13
26
|
}
|
|
14
27
|
}
|
|
15
28
|
off(eventKey, callback) {
|
|
16
|
-
if (this.
|
|
17
|
-
const callbacks = this.
|
|
29
|
+
if (__classPrivateFieldGet(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
30
|
+
const callbacks = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
18
31
|
if (Array.isArray(callbacks)) {
|
|
19
32
|
for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
20
33
|
if (callbacks[i] === callback) {
|
|
@@ -23,11 +36,11 @@ export class EventEmitter {
|
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
}
|
|
26
|
-
this.
|
|
39
|
+
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(eventKey, callbacks || []);
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
42
|
trigger(eventKey, e) {
|
|
30
|
-
const callbacks = this.
|
|
43
|
+
const callbacks = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
31
44
|
if (Array.isArray(callbacks)) {
|
|
32
45
|
callbacks.forEach((cb) => {
|
|
33
46
|
cb(e);
|
|
@@ -39,12 +52,16 @@ export class EventEmitter {
|
|
|
39
52
|
}
|
|
40
53
|
}
|
|
41
54
|
has(name) {
|
|
42
|
-
if (this.
|
|
43
|
-
const list = this.
|
|
55
|
+
if (__classPrivateFieldGet(this, _EventEmitter_listeners, "f").has(name)) {
|
|
56
|
+
const list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(name);
|
|
44
57
|
if (Array.isArray(list) && list.length > 0) {
|
|
45
58
|
return true;
|
|
46
59
|
}
|
|
47
60
|
}
|
|
48
61
|
return false;
|
|
49
62
|
}
|
|
63
|
+
destroy() {
|
|
64
|
+
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").clear();
|
|
65
|
+
}
|
|
50
66
|
}
|
|
67
|
+
_EventEmitter_listeners = new WeakMap();
|
package/dist/esm/lib/store.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export declare class Store<T extends Record<string | symbol, any>> {
|
|
2
|
-
private
|
|
3
|
-
private _backUpDefaultStorage;
|
|
1
|
+
export declare class Store<T extends Record<string | symbol, any> = Record<string | symbol, any>> {
|
|
2
|
+
#private;
|
|
4
3
|
constructor(opts: {
|
|
5
4
|
defaultStorage: T;
|
|
6
5
|
});
|
|
@@ -8,5 +7,5 @@ export declare class Store<T extends Record<string | symbol, any>> {
|
|
|
8
7
|
get<K extends keyof T>(name: K): T[K];
|
|
9
8
|
getSnapshot(): T;
|
|
10
9
|
clear(): void;
|
|
11
|
-
|
|
10
|
+
destroy(): void;
|
|
12
11
|
}
|
package/dist/esm/lib/store.js
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_createTempStorage;
|
|
1
13
|
import { deepClone } from './data';
|
|
2
14
|
export class Store {
|
|
3
15
|
constructor(opts) {
|
|
4
|
-
|
|
5
|
-
this
|
|
16
|
+
_Store_instances.add(this);
|
|
17
|
+
_Store_temp.set(this, void 0);
|
|
18
|
+
_Store_backUpDefaultStorage.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
|
|
20
|
+
__classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
6
21
|
}
|
|
7
22
|
set(name, value) {
|
|
8
|
-
this
|
|
23
|
+
__classPrivateFieldGet(this, _Store_temp, "f")[name] = value;
|
|
9
24
|
}
|
|
10
25
|
get(name) {
|
|
11
|
-
return this
|
|
26
|
+
return __classPrivateFieldGet(this, _Store_temp, "f")[name];
|
|
12
27
|
}
|
|
13
28
|
getSnapshot() {
|
|
14
|
-
return deepClone(this
|
|
29
|
+
return deepClone(__classPrivateFieldGet(this, _Store_temp, "f"));
|
|
15
30
|
}
|
|
16
31
|
clear() {
|
|
17
|
-
this
|
|
32
|
+
__classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
18
33
|
}
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
destroy() {
|
|
35
|
+
__classPrivateFieldSet(this, _Store_temp, null, "f");
|
|
21
36
|
}
|
|
22
37
|
}
|
|
38
|
+
_Store_temp = new WeakMap(), _Store_backUpDefaultStorage = new WeakMap(), _Store_instances = new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage() {
|
|
39
|
+
return deepClone(__classPrivateFieldGet(this, _Store_backUpDefaultStorage, "f"));
|
|
40
|
+
};
|
package/dist/index.global.js
CHANGED
|
@@ -17,8 +17,12 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
17
17
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
18
18
|
return value;
|
|
19
19
|
};
|
|
20
|
+
var __privateMethod = (obj, member, method) => {
|
|
21
|
+
__accessCheck(obj, member, "access private method");
|
|
22
|
+
return method;
|
|
23
|
+
};
|
|
20
24
|
|
|
21
|
-
var _ctx, _opts;
|
|
25
|
+
var _ctx, _opts, _listeners, _temp, _backUpDefaultStorage, _createTempStorage, createTempStorage_fn;
|
|
22
26
|
function compose(middleware) {
|
|
23
27
|
return function(context, next) {
|
|
24
28
|
return dispatch(0);
|
|
@@ -1250,20 +1254,21 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1250
1254
|
}
|
|
1251
1255
|
class EventEmitter {
|
|
1252
1256
|
constructor() {
|
|
1253
|
-
this
|
|
1257
|
+
__privateAdd(this, _listeners, void 0);
|
|
1258
|
+
__privateSet(this, _listeners, /* @__PURE__ */ new Map());
|
|
1254
1259
|
}
|
|
1255
1260
|
on(eventKey, callback) {
|
|
1256
|
-
if (this
|
|
1257
|
-
const callbacks = this
|
|
1261
|
+
if (__privateGet(this, _listeners).has(eventKey)) {
|
|
1262
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey) || [];
|
|
1258
1263
|
callbacks == null ? void 0 : callbacks.push(callback);
|
|
1259
|
-
this
|
|
1264
|
+
__privateGet(this, _listeners).set(eventKey, callbacks);
|
|
1260
1265
|
} else {
|
|
1261
|
-
this
|
|
1266
|
+
__privateGet(this, _listeners).set(eventKey, [callback]);
|
|
1262
1267
|
}
|
|
1263
1268
|
}
|
|
1264
1269
|
off(eventKey, callback) {
|
|
1265
|
-
if (this
|
|
1266
|
-
const callbacks = this
|
|
1270
|
+
if (__privateGet(this, _listeners).has(eventKey)) {
|
|
1271
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey);
|
|
1267
1272
|
if (Array.isArray(callbacks)) {
|
|
1268
1273
|
for (let i = 0; i < (callbacks == null ? void 0 : callbacks.length); i++) {
|
|
1269
1274
|
if (callbacks[i] === callback) {
|
|
@@ -1272,11 +1277,11 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1272
1277
|
}
|
|
1273
1278
|
}
|
|
1274
1279
|
}
|
|
1275
|
-
this
|
|
1280
|
+
__privateGet(this, _listeners).set(eventKey, callbacks || []);
|
|
1276
1281
|
}
|
|
1277
1282
|
}
|
|
1278
1283
|
trigger(eventKey, e) {
|
|
1279
|
-
const callbacks = this
|
|
1284
|
+
const callbacks = __privateGet(this, _listeners).get(eventKey);
|
|
1280
1285
|
if (Array.isArray(callbacks)) {
|
|
1281
1286
|
callbacks.forEach((cb) => {
|
|
1282
1287
|
cb(e);
|
|
@@ -1287,15 +1292,19 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1287
1292
|
}
|
|
1288
1293
|
}
|
|
1289
1294
|
has(name) {
|
|
1290
|
-
if (this
|
|
1291
|
-
const list = this
|
|
1295
|
+
if (__privateGet(this, _listeners).has(name)) {
|
|
1296
|
+
const list = __privateGet(this, _listeners).get(name);
|
|
1292
1297
|
if (Array.isArray(list) && list.length > 0) {
|
|
1293
1298
|
return true;
|
|
1294
1299
|
}
|
|
1295
1300
|
}
|
|
1296
1301
|
return false;
|
|
1297
1302
|
}
|
|
1303
|
+
destroy() {
|
|
1304
|
+
__privateGet(this, _listeners).clear();
|
|
1305
|
+
}
|
|
1298
1306
|
}
|
|
1307
|
+
_listeners = new WeakMap();
|
|
1299
1308
|
function calcDistance(start, end) {
|
|
1300
1309
|
const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
|
|
1301
1310
|
return distance === 0 ? distance : Math.sqrt(distance);
|
|
@@ -1328,25 +1337,34 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1328
1337
|
}
|
|
1329
1338
|
class Store {
|
|
1330
1339
|
constructor(opts) {
|
|
1331
|
-
this
|
|
1332
|
-
this
|
|
1340
|
+
__privateAdd(this, _createTempStorage);
|
|
1341
|
+
__privateAdd(this, _temp, void 0);
|
|
1342
|
+
__privateAdd(this, _backUpDefaultStorage, void 0);
|
|
1343
|
+
__privateSet(this, _backUpDefaultStorage, deepClone(opts.defaultStorage));
|
|
1344
|
+
__privateSet(this, _temp, __privateMethod(this, _createTempStorage, createTempStorage_fn).call(this));
|
|
1333
1345
|
}
|
|
1334
1346
|
set(name, value) {
|
|
1335
|
-
this
|
|
1347
|
+
__privateGet(this, _temp)[name] = value;
|
|
1336
1348
|
}
|
|
1337
1349
|
get(name) {
|
|
1338
|
-
return this
|
|
1350
|
+
return __privateGet(this, _temp)[name];
|
|
1339
1351
|
}
|
|
1340
1352
|
getSnapshot() {
|
|
1341
|
-
return deepClone(this
|
|
1353
|
+
return deepClone(__privateGet(this, _temp));
|
|
1342
1354
|
}
|
|
1343
1355
|
clear() {
|
|
1344
|
-
this
|
|
1356
|
+
__privateSet(this, _temp, __privateMethod(this, _createTempStorage, createTempStorage_fn).call(this));
|
|
1345
1357
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1358
|
+
destroy() {
|
|
1359
|
+
__privateSet(this, _temp, null);
|
|
1348
1360
|
}
|
|
1349
1361
|
}
|
|
1362
|
+
_temp = new WeakMap();
|
|
1363
|
+
_backUpDefaultStorage = new WeakMap();
|
|
1364
|
+
_createTempStorage = new WeakSet();
|
|
1365
|
+
createTempStorage_fn = function() {
|
|
1366
|
+
return deepClone(__privateGet(this, _backUpDefaultStorage));
|
|
1367
|
+
};
|
|
1350
1368
|
function getViewScaleInfoFromSnapshot(snapshot) {
|
|
1351
1369
|
const { activeStore } = snapshot;
|
|
1352
1370
|
const sacelInfo = {
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawUtil=function(e){"use strict";var t,n,i=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},o=(e,t,n)=>(i(e,t,"read from private field"),n?n.call(e):t.get(e)),r=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},a=(e,t,n,o)=>(i(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n);function l(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}const s={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function c(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function u(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function h(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${u(t.toString(16).padEnd(4,i))}${u(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${u(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${u(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${u(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${u(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${u(o.padEnd(4,i).padEnd(4,o))}`}function d(e){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(`${e}`)}function f(e){return function e(t){const n=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return t;if("Array"===n){const n=[];return t.forEach((t=>{n.push(e(t))})),n}if("Object"===n){const n={};Object.keys(t).forEach((i=>{n[i]=e(t[i])}));return Object.getOwnPropertySymbols(t).forEach((i=>{n[i]=e(t[i])})),n}}(e)}function g(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const x={type(e,t){const n=g(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===g(e),json:e=>"Object"===g(e),function:e=>"Function"===g(e),asyncFunction:e=>"AsyncFunction"===g(e),string:e=>"String"===g(e),number:e=>"Number"===g(e),undefined:e=>"Undefined"===g(e),null:e=>"Null"===g(e),promise:e=>"Promise"===g(e)};const{Image:y}=window;function p(e){return new Promise(((t,n)=>{const i=new y;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function m(e){return"number"==typeof e&&(e>0||e<=0)}function w(e){return"number"==typeof e&&e>=0}function v(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function b(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const P={x:function(e){return m(e)},y:function(e){return m(e)},w:w,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:m,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return w(e)},borderRadius:function(e){return m(e)&&e>=0},color:function(e){return l(e)},imageSrc:function(e){return b(e)||v(e)},imageURL:v,imageBase64:b,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return m(e)&&e>0},lineHeight:function(e){return m(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return m(e)&&e>0}};function M(e={}){const{borderColor:t,borderRadius:n,borderWidth:i}=e;return!(e.hasOwnProperty("borderColor")&&!P.color(t))&&(!(e.hasOwnProperty("borderRadius")&&!P.number(n))&&!(e.hasOwnProperty("borderWidth")&&!P.number(i)))}const R={attrs:function(e){const{x:t,y:n,w:i,h:o,angle:r}=e;return!!(P.x(t)&&P.y(n)&&P.w(i)&&P.h(o)&&P.angle(r))&&(r>=-360&&r<=360)},textDesc:function(e){const{text:t,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:u}=e;return!!P.text(t)&&(!!P.color(n)&&(!!P.fontSize(i)&&(!(e.hasOwnProperty("background")&&!P.color(s))&&(!(e.hasOwnProperty("fontWeight")&&!P.fontWeight(l))&&(!(e.hasOwnProperty("lineHeight")&&!P.lineHeight(o))&&(!(e.hasOwnProperty("fontFamily")&&!P.fontFamily(r))&&(!(e.hasOwnProperty("textAlign")&&!P.textAlign(a))&&(!(e.hasOwnProperty("strokeWidth")&&!P.strokeWidth(c))&&(!(e.hasOwnProperty("strokeColor")&&!P.color(u))&&!!M(e))))))))))},rectDesc:function(e){const{background:t}=e;return!(e.hasOwnProperty("background")&&!P.color(t))&&!!M(e)},circleDesc:function(e){const{background:t,borderColor:n,borderWidth:i}=e;return!(e.hasOwnProperty("background")&&!P.color(t))&&(!(e.hasOwnProperty("borderColor")&&!P.color(n))&&!(e.hasOwnProperty("borderWidth")&&!P.number(i)))},imageDesc:function(e){const{src:t}=e;return!!P.imageSrc(t)},svgDesc:function(e){const{svg:t}=e;return!!P.svg(t)},htmlDesc:function(e){const{html:t}=e;return!!P.html(t)}};class I{constructor(e,i){r(this,t,void 0),r(this,n,void 0),a(this,t,e),a(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i})}$undoPixelRatio(e){return e/o(this,n).devicePixelRatio}$doPixelRatio(e){return o(this,n).devicePixelRatio*e}$getContext(){return o(this,t)}$setFont(e){const n=[];e.fontWeight&&n.push(`${e.fontWeight}`),n.push(`${this.$doPixelRatio(e.fontSize||12)}px`),n.push(`${e.fontFamily||"sans-serif"}`),o(this,t).font=`${n.join(" ")}`}$getOffscreenCanvas(){return o(this,n).offscreenCanvas}$resize(e){const{width:i,height:r,devicePixelRatio:l,resetStyle:s}=e,{canvas:c}=o(this,t);c.width=i*l,c.height=r*l,a(this,n,{...o(this,n),devicePixelRatio:l}),!0===s&&(c.style.width=`${i}px`,c.style.height=`${r}px`)}$getSize(){const{devicePixelRatio:e}=o(this,n),{width:i,height:r}=o(this,t).canvas;return{width:i/e,height:r/e,devicePixelRatio:e}}get canvas(){return o(this,t).canvas}get fillStyle(){return o(this,t).fillStyle}set fillStyle(e){o(this,t).fillStyle=e}get strokeStyle(){return o(this,t).strokeStyle}set strokeStyle(e){o(this,t).strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(o(this,t).lineWidth)}set lineWidth(e){o(this,t).lineWidth=this.$doPixelRatio(e)}get textAlign(){return o(this,t).textAlign}set textAlign(e){o(this,t).textAlign=e}get textBaseline(){return o(this,t).textBaseline}set textBaseline(e){o(this,t).textBaseline=e}get globalAlpha(){return o(this,t).globalAlpha}set globalAlpha(e){o(this,t).globalAlpha=e}get shadowColor(){return o(this,t).shadowColor}set shadowColor(e){o(this,t).shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(o(this,t).shadowOffsetX)}set shadowOffsetX(e){o(this,t).shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(o(this,t).shadowOffsetY)}set shadowOffsetY(e){o(this,t).shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(o(this,t).shadowBlur)}set shadowBlur(e){o(this,t).shadowBlur=this.$doPixelRatio(e)}get lineCap(){return o(this,t).lineCap}set lineCap(e){o(this,t).lineCap=e}get globalCompositeOperation(){return o(this,t).globalCompositeOperation}set globalCompositeOperation(e){o(this,t).globalCompositeOperation=e}fill(...e){return o(this,t).fill(...e)}arc(e,n,i,r,a,l){return o(this,t).arc(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),r,a,l)}rect(e,n,i,r){return o(this,t).rect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}fillRect(e,n,i,r){return o(this,t).fillRect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}clearRect(e,n,i,r){return o(this,t).clearRect(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}beginPath(){return o(this,t).beginPath()}closePath(){return o(this,t).closePath()}lineTo(e,n){return o(this,t).lineTo(this.$doPixelRatio(e),this.$doPixelRatio(n))}moveTo(e,n){return o(this,t).moveTo(this.$doPixelRatio(e),this.$doPixelRatio(n))}arcTo(e,n,i,r,a){return o(this,t).arcTo(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a))}getLineDash(){return o(this,t).getLineDash()}setLineDash(e){const n=e.map((e=>this.$doPixelRatio(e)));return o(this,t).setLineDash(n)}stroke(e){return e?o(this,t).stroke(e):o(this,t).stroke()}translate(e,n){return o(this,t).translate(this.$doPixelRatio(e),this.$doPixelRatio(n))}rotate(e){return o(this,t).rotate(e)}drawImage(...e){const n=e[0],i=e[1],r=e[2],a=e[3],l=e[4],s=e[e.length-4],c=e[e.length-3],u=e[e.length-2],h=e[e.length-1];return 9===e.length?o(this,t).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u),this.$doPixelRatio(h)):o(this,t).drawImage(n,this.$doPixelRatio(s),this.$doPixelRatio(c),this.$doPixelRatio(u),this.$doPixelRatio(h))}createPattern(e,n){return o(this,t).createPattern(e,n)}measureText(e){return o(this,t).measureText(e)}fillText(e,n,i,r){return void 0!==r?o(this,t).fillText(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r)):o(this,t).fillText(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(e,n,i,r){return void 0!==r?o(this,t).strokeText(e,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r)):o(this,t).strokeText(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){o(this,t).save()}restore(){o(this,t).restore()}scale(e,n){o(this,t).scale(e,n)}circle(e,n,i,r,a,l,s,c){o(this,t).ellipse(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),a,l,s,c)}isPointInPath(e,n){return o(this,t).isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(n))}clip(...e){return o(this,t).clip(...e)}setTransform(e,n,i,r,a,l){return o(this,t).setTransform(e,n,i,r,a,l)}getTransform(){return o(this,t).getTransform()}createLinearGradient(e,n,i,r){return o(this,t).createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r))}createRadialGradient(e,n,i,r,a,l){return o(this,t).createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l))}createConicGradient(e,n,i){return o(this,t).createConicGradient(e,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function $(e){const{width:t,height:n,ctx:i,devicePixelRatio:o}=e;let r=i;if(!r){const e=document.createElement("canvas");e.width=t*o,e.height=n*o,r=e.getContext("2d")}return new I(r,e)}function E(e){const{width:t,height:n,devicePixelRatio:i}=e,o=new OffscreenCanvas(t*i,n*i),r=o.getContext("2d").canvas.getContext("2d");return new I(r,{devicePixelRatio:i,offscreenCanvas:o})}t=new WeakMap,n=new WeakMap;function A(e,t){const n=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===n?n:Math.sqrt(n)}function S(e,t){return e.x===t.x&&e.y===t.y&&e.t===t.t}function C(e){return e>=0||e<0}function k(e){return C(e.x)&&C(e.y)&&e.t>0}function z(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}function O(e){return e/180*Math.PI}function T(e,t,n,i){const o=O(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function L(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function D(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),n=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return L({x:t,y:n,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-n})}function j(e,t,n){const i=function(e,t){const n=t.x-e.x,i=t.y-e.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}(e,t);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=A(e,t);let a=0,l=0;return 0===o?(a=0,l=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,l=0-Math.cos(o)*r):o===Math.PI/2?(a=r,l=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,l=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,l=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,l=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,l=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,l=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,l=0-r),a+=e.x,l+=e.y,{x:a,y:l}}function W(e,t,n){const{x:i,y:o,w:r,h:a}=e;let l={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+a},u={x:i,y:o+a};if(n&&(n>0||n<0)){const e=O(V(n));l=j(t,l,e),s=j(t,s,e),c=j(t,c,e),u=j(t,u,e)}return[l,s,c,u]}function F(e){const{angle:t=0}=e;return W(e,L(e),t)}function H(e,t,n){return[j(e,{x:t[0].x,y:t[0].y},n),j(e,{x:t[1].x,y:t[1].y},n),j(e,{x:t[2].x,y:t[2].y},n),j(e,{x:t[3].x,y:t[3].y},n)]}function V(e){if(!(e>0||e<0)||0===e)return 0;let t=e%360;return t<0&&(t+=360),t}function N(e,t){const n={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=F(t);if(4===e.length){const n=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...n),t.y=Math.min(...i),t.w=Math.abs(Math.max(...n)-Math.min(...n)),t.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(t.x,n.x),o=Math.min(t.y,n.y),r=Math.max(t.x+t.w,n.x+n.w),a=Math.max(t.y+t.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(a-o)})),(null==t?void 0:t.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==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>n.x+n.w&&(i.contextWidth=t.viewWidth-n.x),t.viewHeight>n.y+n.h&&(i.contextHeight=t.viewHeight-n.y)),i}function B(e,t){let n=null,i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(t<e.length-1&&"group"===o.type)i=o.detail.children;else{if(t!==e.length-1)break;n=o}}return n}function G(e,t){const n=[];let i=!1;const o=t=>{var r;for(let a=0;a<t.length&&!0!==i;a++){n.push(a);const l=t[a];if(l.uuid===e){i=!0;break}if("group"===l.type&&o((null==(r=null==l?void 0:l.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(t),n}function U(e,t){const n=e.x,i=e.y,o=e.x+e.w,r=e.y+e.h,a=t.x,l=t.y,s=t.x+t.w,c=t.y+t.h;return n<=s&&o>=a&&i<=c&&r>=l}function _(e,t){const{viewScaleInfo:n}=t,{x:i,y:o,w:r,h:a,angle:l}=e,{scale:s,offsetTop:c,offsetLeft:u}=n;return{x:i*s+u,y:o*s+c,w:r*s,h:a*s,angle:l}}function Q(e,t){const{viewScaleInfo:n}=t,{x:i,y:o}=e,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function Y(e,t){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=t,{angle:a=0}=i,{x:l,y:s,w:c,h:u}=_(i,{viewScaleInfo:o,viewSizeInfo:r}),h=F({x:l,y:s,w:c,h:u,angle:a});if(h.length>=2){n.beginPath(),n.moveTo(h[0].x,h[0].y);for(let e=1;e<h.length;e++)n.lineTo(h[e].x,h[e].y);n.closePath()}return!!n.isPointInPath(e.x,e.y)}function X(e){const{x:t,y:n,h:i,w:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+i},{x:t,y:n+i}]}function q(e){const{x:t,y:n,w:i,h:o,angle:r=0}=e;return 0===r?X(e):W(e,L({x:t,y:n,w:i,h:o,angle:r}),r)}function Z(e){const t=[];let n=0,i=0;const o=[],r=[...e];for(let e=0;e<r.length;e++){const{x:a,y:l,w:s,h:c,angle:u=0}=r[e];let h;if(n+=a,i+=l,0===e){const e={x:n,y:i,w:s,h:c,angle:u};h=q({x:a,y:l,w:s,h:c,angle:u}),o.push({center:L(e),angle:u,radian:O(u)})}else{h=X({x:n,y:i,w:s,h:c,angle:u});for(let e=0;e<o.length;e++){const{center:t,radian:n}=o[e];h=H(t,h,n)}const e=D(h);if(u>0||u<0){h=H(e,h,O(u))}o.push({center:e,angle:u,radian:O(u)})}t.push(h)}return t}function J(e,t){const{groupQueue:n}=t;if(!(n.length>0))return[q(e)];return Z([...n,e])}function K(e,t){return J(e,t).pop()||null}function ee(e,t){const{x:n,y:i}=e,{size:o,angle:r}=t;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}const te=/([astvzqmhlc])([^astvzqmhlc]*)/gi,ne=/(-?\d+(?:\.\d+)?)/gi;const ie=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,oe=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,re=/^\s*$/,ae={};function le(e){const t={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(ae[n[1]]||"/"===e.charAt(e.length-2))&&(t.isVoid=!0),t.name.startsWith("!--"))){const t=e.indexOf("--\x3e");return{type:"comment",name:null,attributes:{},children:[],isVoid:!1,comment:-1!==t?e.slice(4,t):""}}const i=new RegExp(ie);let o=null;for(;o=i.exec(e),null!==o;)if(o[0].trim())if(o[1]){const e=o[1].trim();let n=[e,""];e.indexOf("=")>-1&&(n=e.split("=")),t.attributes[n[0]]=n[1],i.lastIndex--}else o[2]&&(t.attributes[o[2]]=o[3].trim().substring(1,o[3].length-1));return t}function se(e,t){switch(t.type){case"text":return e+t.textContent;case"element":return e+="<"+t.name+(t.attributes?function(e){const t=[];for(let n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attributes):"")+(t.isVoid?"/>":">"),t.isVoid?e:e+t.children.reduce(se,"")+"</"+t.name+">";case"comment":return e+="\x3c!--"+t.comment+"--\x3e"}}function ce(e,t){let n=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(n=t.decimalPlaces),parseFloat(e.toFixed(n))}function ue(e){return e[1]!=-1*e[3]||e[4]!=e[0]||e[0]*e[4]-e[3]*e[1]!=1?null:Math.acos(e[0])}const he="Text Element";function de(){return{boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"}}function fe(){return{background:"#D9D9D9"}}const ge={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const xe=e=>ce(e,{decimalPlaces:4});function ye(e,t){const{detail:n}=e,{xRatio:i,yRatio:o,maxRatio:r}=t,a=(i+o)/2,{borderWidth:l,borderRadius:s,borderDash:c,shadowOffsetX:u,shadowOffsetY:h,shadowBlur:d}=n;if("number"==typeof l)n.borderWidth=xe(l*a);else if(Array.isArray(n.borderWidth)){const e=l;n.borderWidth=[xe(e[0]*o),xe(e[1]*i),xe(e[2]*o),xe(e[3]*i)]}if("number"==typeof s)n.borderRadius=xe(s*a);else if(Array.isArray(n.borderRadius)){const e=s;n.borderRadius=[e[0]*i,e[1]*i,e[2]*o,e[3]*o]}Array.isArray(c)&&c.forEach(((e,t)=>{n.borderDash[t]=xe(e*r)})),"number"==typeof u&&(n.shadowOffsetX=xe(u*r)),"number"==typeof h&&(n.shadowOffsetX=xe(h*r)),"number"==typeof d&&(n.shadowOffsetX=xe(d*r))}function pe(e,t){const{type:n}=e;!function(e,t){const{xRatio:n,yRatio:i}=t,{x:o,y:r,w:a,h:l}=e;e.x=xe(o*n),e.y=xe(r*i),e.w=xe(a*n),e.h=xe(l*i),ye(e,t)}(e,t),"circle"===n||("text"===n?function(e,t){const{minRatio:n,maxRatio:i}=t,{fontSize:o,lineHeight:r}=e.detail,a=(n+i)/2;o&&o>0&&(e.detail.fontSize=xe(o*a)),r&&r>0&&(e.detail.lineHeight=xe(r*a))}(e,t):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{pe(e,t)})))}function me(e,t){const n=t.w&&t.w>0?t.w:e.w,i=t.h&&t.h>0?t.h:e.h,o=n/e.w,r=i/e.h;if(o===r&&1===o)return e;const a=Math.min(o,r),l=Math.max(o,r);e.w=n,e.h=i;const s={xRatio:o,yRatio:r,minRatio:a,maxRatio:l};return"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{pe(e,s)})),ye(e,s),e}const we=200,ve=200;function be(e,t,n){let i=!1;if(1===t.length){const o=t[0];n.splice(o,0,e),i=!0}else if(t.length>1){let o=n;for(let n=0;n<t.length;n++){const r=o[t[n]];if(n===t.length-1){const r=t[n];o.splice(r,0,e),i=!0}else{if(!(n<t.length-1&&"group"===r.type))break;o=r.detail.children}}}return i}function Pe(e,t){let n=!1;if(1===e.length){const i=e[0];t.splice(i,1),n=!0}else if(e.length>1){let i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(t===e.length-1){const o=e[t];i.splice(o,1),n=!0}else{if(!(t<e.length-1&&"group"===o.type))break;i=o.detail.children}}}return n}function Me(e,t){var n;const i=Object.keys(t);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?e[r]=t[r]:["detail","operations"].includes(r)&&(x.json(t[r])?((null==e?void 0:e.hasOwnProperty(r))||(e[r]={}),x.json(e[r])&&(e[r]={...e[r],...t[r]})):x.array(t[r])&&((null==e?void 0:e.hasOwnProperty(r))||(e[r]=[]),x.array(e[r])&&(null==(n=null==t?void 0:t[r])||n.forEach(((t,n)=>{e[r][n]=t})),e[r]=[...e[r],...t[r]])))}return e}return e.Context2D=I,e.EventEmitter=class{constructor(){this._listeners=new Map}on(e,t){if(this._listeners.has(e)){const n=this._listeners.get(e)||[];null==n||n.push(t),this._listeners.set(e,n)}else this._listeners.set(e,[t])}off(e,t){if(this._listeners.has(e)){const n=this._listeners.get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}this._listeners.set(e,n||[])}}trigger(e,t){const n=this._listeners.get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(this._listeners.has(e)){const t=this._listeners.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}},e.Store=class{constructor(e){this._backUpDefaultStorage=f(e.defaultStorage),this._temp=this._createTempStorage()}set(e,t){this._temp[e]=t}get(e){return this._temp[e]}getSnapshot(){return f(this._temp)}clear(){this._temp=this._createTempStorage()}_createTempStorage(){return f(this._backUpDefaultStorage)}},e.calcDistance=A,e.calcElementCenter=L,e.calcElementCenterFromVertexes=D,e.calcElementListSize=function(e){var t;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<e.length;o++){const r=e[o];if(null==(t=null==r?void 0:r.operations)?void 0:t.invisible)continue;const a={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const e=F(a);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],n=[e[0].y,e[1].y,e[2].y,e[3].y];a.x=Math.min(...t),a.y=Math.min(...n),a.w=Math.abs(Math.max(...t)-Math.min(...t)),a.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const e=Math.min(a.x,n.x),t=Math.min(a.y,n.y),i=Math.max(a.x+a.w,n.x+n.w),o=Math.max(a.y+a.h,n.y+n.h);n.x=e,n.y=t,n.w=Math.abs(i-e),n.h=Math.abs(o-t)}else n.x=a.x,n.y=a.y,n.w=a.w,n.h=a.h;i=a}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}},e.calcElementQueueVertexesQueueInGroup=Z,e.calcElementSizeController=function(e,t){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=t,r=(i&&i>0?i:8)/o.scale,{x:a,y:l,w:s,h:u,angle:h=0}=e,d=[{uuid:c(),x:a,y:l,w:s,h:u,angle:h,type:"group",detail:{children:[]}},...n];let f=0;d.forEach((({angle:e=0})=>{f+=e}));const g=K(e,{groupQueue:n}),x=z(g[0],g[1]),y=z(g[1],g[2]),p=z(g[2],g[3]),m=z(g[3],g[0]),w=g[0],v=g[1],b=g[2],P=g[3],M=ee(w,{size:r,angle:f}),R=ee(v,{size:r,angle:f}),I=ee(P,{size:r,angle:f}),$=ee(b,{size:r,angle:f}),E=q(M),A=q(R),S=q(I),C=q($),k=[E[1],A[0],A[3],E[2]],O=[A[3],A[2],C[1],C[0]],T=[S[1],C[0],C[3],S[2]];return{elementWrapper:g,left:{type:"left",vertexes:[E[3],E[2],S[1],S[0]],center:m},right:{type:"right",vertexes:O,center:y},top:{type:"top",vertexes:k,center:x},bottom:{type:"bottom",vertexes:T,center:p},topLeft:{type:"top-left",vertexes:E,center:w},topRight:{type:"top-right",vertexes:A,center:v},bottomLeft:{type:"bottom-left",vertexes:S,center:P},bottomRight:{type:"bottom-right",vertexes:C,center:b}}},e.calcElementVertexesInGroup=K,e.calcElementVertexesQueueInGroup=J,e.calcElementsContextSize=N,e.calcElementsViewInfo=function(e,t,n){const i=N(e,{viewWidth:t.width,viewHeight:t.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,t.contextWidth),i.contextHeight=Math.max(i.contextHeight,t.contextHeight)),{contextSize:i}},e.calcSpeed=function(e,t){return A(e,t)/Math.abs(t.t-e.t)},e.calcViewBoxSize=function(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:r=ge.boxSizing,borderWidth:a}=e.detail;Array.isArray(a)&&(o=0);let{x:l,y:s,w:c,h:u}=e,h=[0,0,0,0];if("number"==typeof o){const e=o*i;h=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let d=0;return"number"==typeof a&&(d=(a||0)*i),"border-box"===r?(l=e.x+d/2,s=e.y+d/2,c=e.w-d,u=e.h-d):"content-box"===r?(l=e.x-d/2,s=e.y-d/2,c=e.w+d,u=e.h+d):(l=e.x,s=e.y,c=e.w,u=e.h),c=Math.max(c,1),u=Math.max(u,1),h=h.map((e=>Math.min(e,c/2,u/2))),{x:l,y:s,w:c,h:u,radiusList:h}},e.calcViewElementSize=_,e.calcViewPointSize=Q,e.calcViewScaleInfo=function(e,t){const{scale:n,offsetX:i,offsetY:o}=e,{viewSizeInfo:r}=t,{width:a,height:l,contextWidth:s,contextHeight:c}=r,u=0-i*n,h=0-o*n;return{scale:n,offsetLeft:u,offsetTop:h,offsetRight:a-(s*n+u/n),offsetBottom:l-(c*n+h/n)}},e.calcViewVertexes=function(e,t){return[Q(e[0],t),Q(e[1],t),Q(e[2],t),Q(e[3],t)]},e.check=R,e.checkRectIntersect=U,e.colorNameToHex=function(e){const t=e.toLowerCase(),n=s[t];return"string"==typeof n?n:null},e.colorToCSS=function(e){let t="transparent";if("string"==typeof e)t=e;else if("linear-gradient"===(null==e?void 0:e.type)){const n=[];"number"==typeof e.angle?n.push(`${e.angle}deg`):n.push("180deg"),Array.isArray(e.stops)&&e.stops.forEach((e=>{n.push(`${e.color} ${100*e.offset}%`)})),t=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==e?void 0:e.type)){const n=[];Array.isArray(e.stops)&&e.stops.forEach((e=>{n.push(`${e.color} ${100*e.offset}%`)})),t=`radial-gradient(circle, ${n.join(", ")})`}return t},e.colorToLinearGradientCSS=function(e){let t="transparent";if("string"==typeof e)t=e;else if("radial-gradient"===(null==e?void 0:e.type)||"linear-gradient"===(null==e?void 0:e.type)){const n=[];Array.isArray(e.stops)&&e.stops.length>0&&(e.stops.forEach(((t,i)=>{n.push(`${t.color} ${100*t.offset}%`),i===e.stops.length-1&&t.offset<1&&n.push(`${t.color} ${100*t.offset}%`)})),t=`linear-gradient(90deg, ${n.join(", ")})`)}return t},e.compose=function(e){return function(t,n){return function i(o){let r=e[o];o===e.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(t,i.bind(null,o+1)))}catch(e){return Promise.reject(e)}}(0)}},e.compressImage=function(e,t){let n=.5;const i=(null==t?void 0:t.type)||"image/png";return(null==t?void 0:t.radio)&&(null==t?void 0:t.radio)>0&&(null==t?void 0:t.radio)<=1&&(n=null==t?void 0:t.radio),new Promise(((t,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:e,height:o}=r,a=e*n,l=o*n;let s=document.createElement("canvas");s.width=a,s.height=l;s.getContext("2d").drawImage(r,0,0,a,l);const c=s.toDataURL(i);s=null,t(c)})),r.addEventListener("error",(e=>{o(e)})),r.src=e}))},e.createAssetId=h,e.createBoardContent=function(e,t){const{width:n,height:i,devicePixelRatio:o,offscreen:r}=t,a={width:n,height:i,devicePixelRatio:o};if(!0===r){const t=e.getContext("2d"),n=E(a),i=E(a),o=E(a),r=$({ctx:t,...a}),l=()=>{const{width:e,height:t}=n.$getSize();r.clearRect(0,0,e,t),r.drawImage(o.canvas,0,0,e,t),r.drawImage(n.canvas,0,0,e,t),r.drawImage(i.canvas,0,0,e,t),o.clearRect(0,0,e,t),n.clearRect(0,0,e,t),i.clearRect(0,0,e,t)};return{underContext:o,viewContext:n,helperContext:i,boardContext:r,drawView:l}}{const t=e.getContext("2d"),o=$(a),r=$(a),l=$(a),s=$({ctx:t,...a}),c=()=>{s.clearRect(0,0,n,i),s.drawImage(l.canvas,0,0,n,i),s.drawImage(o.canvas,0,0,n,i),s.drawImage(r.canvas,0,0,n,i),l.clearRect(0,0,n,i),o.clearRect(0,0,n,i),r.clearRect(0,0,n,i)};return{underContext:l,viewContext:o,helperContext:r,boardContext:s,drawView:c}}},e.createContext2D=$,e.createElement=function(e,t,n){const i=function(e,t){let n=0,i=0,o=we,r=ve;if(t){const{viewScaleInfo:a,viewSizeInfo:l}=t,{scale:s,offsetLeft:c,offsetTop:u}=a,{width:h,height:d}=l,f=h/4,g=d/4;o=we>=f?f/s:we/s,r=ve>=g?g/s:ve/s,["circle","svg","image"].includes(e)?o=r=Math.max(o,r):"text"===e&&(r=o/he.length*2),n=(0-c+h/2-o*s/2)/s,i=(0-u+d/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(e,n);let o={};return"rect"===e?o={background:"#D9D9D9"}:"circle"===e?o={background:"#D9D9D9",radius:0}:"text"===e?o=function(e){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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};return{text:he,color:t.color,fontFamily:t.fontFamily,fontWeight:t.fontWeight,lineHeight:e.w/he.length,fontSize:e.w/he.length,textAlign:"center",verticalAlign:"middle"}}(i):"svg"===e?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"===e?o={src:"data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=="}:"group"===e&&(o={children:[],background:"#D9D9D9",overflow:"hidden"}),{...i,...t,uuid:c(),type:e,detail:{...o,...t.detail||{}}}},e.createOffscreenContext2D=E,e.createUUID=c,e.deepClone=f,e.deepCloneElement=function(e){const t=f(e),n=e=>{e.uuid=c(),"group"===e.type&&e.detail.children&&e.detail.children.forEach((e=>{n(e)}))};return n(t),t},e.deepResizeGroupElement=me,e.delay=function(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))},e.deleteElementInList=function(e,t){return Pe(G(e,t),t)},e.deleteElementInListByPosition=Pe,e.downloadFileFromText=function(e,t){const{fileName:n}=t,i=function(e){const t=(new TextEncoder).encode(e),n=new Blob([t],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(e);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},e.downloadImageFromCanvas=function(e,t){const{fileName:n,type:i="image/jpeg"}=t,o=e.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},e.equalPoint=S,e.equalTouchPoint=function(e,t){return!0===S(e,t)&&e.f===t.f},e.filterCompactData=function(e,t){const n=e.assets||{},i=f(e),o=(null==t?void 0:t.loadItemMap)||{},r=e=>{e.forEach((e=>{var t,i,a;if("image"===e.type&&e.detail.src){const i=e.detail.src;if(d(i)&&!n[i]&&o[i]&&"string"==typeof(null==(t=o[i])?void 0:t.source))n[i]={type:"image",value:o[i].source};else{const t=h(i);n[t]||(n[t]={type:"image",value:i}),e.detail.src=t}}else if("svg"===e.type){const t=e.detail.svg,r=h(t);d(t)&&!n[t]&&o[t]&&"string"==typeof(null==(i=o[t])?void 0:i.source)?n[t]={type:"svg",value:o[t].source}:n[r]||(n[r]={type:"svg",value:t}),e.detail.svg=r}else if("html"===e.type){const t=e.detail.html,i=h(t);d(t)&&!n[t]&&o[t]&&"string"==typeof(null==(a=o[t])?void 0:a.source)?n[t]={type:"html",value:o[t].source}:n[i]||(n[i]={type:"html",value:t}),e.detail.html=i}else if("group"===e.type&&Array.isArray(e.detail.children)){const t=e.detail.assets||{};Object.keys(t).forEach((e=>{n[e]||(n[e]=t[e])})),delete e.detail.assets,r(e.detail.children)}}))};return r(i.elements),i.assets=n,i},e.filterElementAsset=function(e){let t=null,n=null,i=null;return"image"===e.type?i=e.detail.src:"svg"===e.type?i=e.detail.svg:"html"===e.type&&(i=e.detail.html),"string"!=typeof i||d(i)||(t=h(i),n={type:e.type,value:i},"image"===e.type?e.detail.src=t:"svg"===e.type?e.detail.svg=t:"html"===e.type&&(e.detail.html=t)),{element:e,assetId:t,assetItem:n}},e.findElementFromList=function e(t,n){var i;let o=null;for(let r=0;r<n.length;r++){const a=n[r];if(a.uuid===t){o=a;break}if(!o&&"group"===a.type){const n=e(t,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===t){o=n;break}}}return o},e.findElementFromListByPosition=B,e.findElementQueueFromListByPosition=function(e,t){const n=[];let i=t;for(let t=0;t<e.length;t++){const o=i[e[t]];if(!o)break;if(n.push(o),!(t<e.length-1&&"group"===o.type))break;i=o.detail.children}return n},e.findElementsFromList=function(e,t){const n=[];return function t(i){var o;for(let r=0;r<i.length;r++){const a=i[r];e.includes(a.uuid)?n.push(a):"group"===a.type&&t((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(t),n},e.findElementsFromListByPositions=function(e,t){const n=[];return e.forEach((e=>{const i=B(e,t);i&&n.push(i)})),n},e.formatNumber=ce,e.generateHTML=function(e){return e.reduce((function(e,t){return e+se("",t)}),"")},e.generateSVGPath=function(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t},e.getCenterFromTwoPoints=z,e.getDefaultElementDetailConfig=de,e.getDefaultElementRectDetail=fe,e.getElemenetsAssetIds=function(e){const t=[],n=e=>{e.forEach((e=>{"image"===e.type&&d(e.detail.src)?t.push(e.detail.src):"svg"===e.type&&d(e.detail.svg)?t.push(e.detail.svg):"html"===e.type&&e.detail.html?t.push(e.detail.html):"group"===e.type&&Array.isArray(e.detail.children)&&n(e.detail.children)}))};return n(e),t},e.getElementPositionFromList=G,e.getElementRotateVertexes=W,e.getElementSize=function(e){const{x:t,y:n,w:i,h:o,angle:r}=e;return{x:t,y:n,w:i,h:o,angle:r}},e.getElementVertexes=X,e.getGroupQueueFromList=function(e,t){const n=[];return function e(t,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===t){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=e(t,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===t){r=i;break}n.pop()}}return r}(e,t),n},e.getSelectedElementUUIDs=function(e,t){var n;let i=[];return Array.isArray(null==e?void 0:e.elements)&&(null==(n=null==e?void 0:e.elements)?void 0:n.length)>0&&Array.isArray(t)&&t.length>0&&t.forEach((t=>{var n;"number"==typeof t?(null==(n=null==e?void 0:e.elements)?void 0:n[t])&&i.push(e.elements[t].uuid):"string"==typeof t&&(i=i.concat(function(e,t){var n;const i=[];if("string"==typeof t&&/^\d+(\.\d+)*$/.test(t)){const o=t.split(".");let r=e;for(;o.length>0;){const e=o.shift();if("string"==typeof e){const t=r[parseInt(e)];t&&0===o.length?i.push(t.uuid):"group"===t.type&&o.length>0&&(r=(null==(n=null==t?void 0:t.detail)?void 0:n.children)||[])}break}}return i}(e.elements,t)))})),i},e.getViewPointAtElement=function(e,t){var n,i,o;const{context2d:r,data:a,viewScaleInfo:l,viewSizeInfo:s,groupQueue:c}=t,u={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let t=c.length-1;t>=0;t--){let o=0,a=0,h=0;for(let e=0;e<=t;e++)o+=c[e].x,a+=c[e].y,h+=c[e].angle||0;const d=c[t];if(d&&"group"===d.type&&Array.isArray(null==(n=d.detail)?void 0:n.children))for(let n=0;n<d.detail.children.length;n++){const f=d.detail.children[n];if(!0!==(null==(i=null==f?void 0:f.operations)?void 0:i.invisible)){if(!f)break;if(Y(e,{context2d:r,element:{x:o+f.x,y:a+f.y,w:f.w,h:f.h,angle:h+(f.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){u.element=f,(t<c.length-1||"group"!==f.type)&&(u.groupQueueIndex=t);break}}}if(u.element)break}if(u.element)return u;for(let t=a.elements.length-1;t>=0;t--){const n=a.elements[t];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&Y(e,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){u.index=t,u.element=n;break}}return u},e.getViewScaleInfoFromSnapshot=function(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}},e.getViewSizeInfoFromSnapshot=function(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}},e.insertElementToListByPosition=be,e.is=P,e.isAssetId=d,e.isColorStr=l,e.isElementInView=function(e,t){const{viewSizeInfo:n,viewScaleInfo:i}=t,{width:o,height:r}=n,{angle:a}=e,{x:l,y:s,w:c,h:u}=_(e,{viewScaleInfo:i,viewSizeInfo:n}),h=F({x:l,y:s,w:c,h:u,angle:a}),d={x:0,y:0,w:o,h:r},f=Math.min(h[0].x,h[1].x,h[2].x,h[3].x),g=Math.min(h[0].y,h[1].y,h[2].y,h[3].y);return U(d,{x:f,y:g,w:Math.max(h[0].x,h[1].x,h[2].x,h[3].x)-f,h:Math.max(h[0].y,h[1].y,h[2].y,h[3].y)-g})},e.isResourceElement=function(e){return["image","svg","html"].includes(null==e?void 0:e.type)},e.isViewPointInElement=Y,e.istype=x,e.limitAngle=V,e.loadHTML=async function(e,t){e=e.replace(/\&/gi,"&");const n=await function(e,t){const{width:n,height:i}=t;return new Promise(((t,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 ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(e){var n;const i=null==(n=null==e?void 0:e.target)?void 0:n.result;t(i)},a.onerror=function(e){o(e)}}))}(e,t);return await p(n)},e.loadImage=p,e.loadSVG=async function(e){const t=await function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null==(n=null==e?void 0:e.target)?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return await p(t)},e.matrixToAngle=function(e){const t=ue(e);if("number"==typeof t){return 180*t/Math.PI}return t},e.matrixToRadian=ue,e.mergeElementAsset=function(e,t){const n=e;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=t[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},e.mergeHexColorAlpha=function(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o},e.moveElementPosition=function(e,t){const{from:n,to:i}=t;if(0===n.length||0===i.length)return e;if(n.length<=i.length)for(let t=0;t<n.length;t++)if(i[t]!==n[t]);else if(t===n.length-1)return e;const o=B(n,e);if(o){if(!be(o,i,e))return e;let t=-1;for(let e=0;e<n.length&&i[e]>=0;e++)i[e]!==n[e]&&i[e]<n[e]&&e==i.length-1&&(t=e);t>=0&&(n[t]=n[t]+1),Pe(n,e)}return e},e.parseAngleToRadian=O,e.parseFileToBase64=function(e){return new Promise((function(t,n){let i=new FileReader;i.addEventListener("load",(function(){t(i.result),i=null})),i.addEventListener("error",(function(e){n(e),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsDataURL(e)}))},e.parseFileToText=function(e){return new Promise((function(t,n){let i=new FileReader;i.addEventListener("load",(function(){t(i.result),i=null})),i.addEventListener("error",(function(e){n(e),i=null})),i.addEventListener("abort",(function(){n(new Error("abort")),i=null})),i.readAsText(e)}))},e.parseHTML=function(e){const t=[],n=[];let i,o=-1;return e.replace(oe,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,u=e.charAt(c);let h;if(s){const e=le(r);return o<0?(t.push(e),r):(h=n[o],h.children.push(e),r)}if(l){if(o++,i=le(r),!i.isVoid&&u&&"<"!==u){const t=e.slice(c,e.indexOf("<",c));t.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:t.trim()})}0===o&&t.push(i),h=n[o-1],h&&h.children.push(i),n[o]=i}if((!l||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?t:n[o]),"<"!==u&&u)){h=-1===o?t:n[o].children;const i=e.indexOf("<",c);let r=e.slice(c,-1===i?void 0:i);re.test(r)&&(r=" "),(i>-1&&o+h.length>=0||" "!==r)&&r.trim()&&h.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:r.trim()})}return r})),t},e.parseRadianToAngle=function(e){return e/Math.PI*180},e.parseSVGPath=function(e){const t=[];return e.replace(te,((e,n,i)=>{const o=i.match(ne),r={type:n,params:o?o.map(Number):[]};return t.push(r),e})),t},e.pickFile=function(e){const{accept:t,success:n,error:i}=e;let o=document.createElement("input");o.type="file",t&&(o.accept=t),o.addEventListener("change",(function(){var e;const t=null==(e=o.files)?void 0:e[0];n({file:t}),o=null})),o.addEventListener("error",(function(e){"function"==typeof i&&i(e),o=null})),o.click()},e.rotateByCenter=T,e.rotateElement=function(e,t,n){const i=L(t);T(e,t.angle||0,i,(()=>{n(e)}))},e.rotateElementVertexes=F,e.rotatePoint=j,e.rotatePointInGroup=function(e,t){if((null==t?void 0:t.length)>0){let n=e.x,i=e.y;return t.forEach((e=>{const{x:t,y:o,w:r,h:a,angle:l=0}=e,s=j(L({x:t,y:o,w:r,h:a,angle:l}),{x:n,y:i},O(l));n=s.x,i=s.y})),{x:n,y:i}}return e},e.rotateVertexes=H,e.sortDataAsserts=function(e,t){const n=e.assets||{};let i=e;!0===(null==t?void 0:t.clone)&&(i=f(e));const o=e=>{e.forEach((e=>{if("image"===e.type&&e.detail.src){const t=e.detail.src,i=h(t);n[i]||(n[i]={type:"image",value:t}),e.detail.src=i}else if("svg"===e.type){const t=e.detail.svg,i=h(t);n[i]||(n[i]={type:"svg",value:t}),e.detail.svg=i}else if("html"===e.type){const t=e.detail.html,i=h(t);n[i]||(n[i]={type:"html",value:t}),e.detail.html=i}else if("group"===e.type&&Array.isArray(e.detail.children)){const t=e.detail.assets||{};Object.keys(t).forEach((e=>{n[e]||(n[e]=t[e])})),delete e.detail.assets,o(e.detail.children)}}))};return o(i.elements),i.assets=n,i},e.throttle=function(e,t){let n=-1;return function(...i){n>0||(n=setTimeout((()=>{e(...i),n=-1}),t))}},e.toColorHexNum=function(e){return parseInt(e.replace(/^\#/,"0x"))},e.toColorHexStr=function(e){return"#"+e.toString(16)},e.updateElementInList=function e(t,n,i){var o,r;let a=null;for(let l=0;l<i.length;l++){const s=i[l];if(s.uuid===t){"group"===s.type&&!0===(null==(o=s.operations)?void 0:o.deepResize)&&(n.w&&n.w>0||n.h&&n.h>0)&&me(s,{w:n.w,h:n.h}),Me(s,n),a=s;break}"group"===s.type&&(a=e(t,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return a},e.vaildPoint=k,e.vaildTouchPoint=function(e){return!0===k(e)&&e.f>=0},e.validateElements=function e(t){let n=!0;if(Array.isArray(t)){const i=[];t.forEach((t=>{var o;"string"==typeof t.uuid&&t.uuid?i.includes(t.uuid)?(n=!1,console.warn(`Duplicate uuids: ${t.uuid}`)):i.push(t.uuid):(n=!1,console.warn("Element missing uuid",t)),"group"===t.type&&(n=e(null==(o=null==t?void 0:t.detail)?void 0:o.children))}))}return n},e.viewScale=function(e){const{scale:t,point:n,viewScaleInfo:i}=e,{offsetLeft:o,offsetTop:r}=i,a=t/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},e.viewScroll=function(e){const{moveX:t=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=e,{scale:r}=i,{width:a,height:l,contextWidth:s,contextHeight:c}=o;let u=i.offsetLeft,h=i.offsetRight,d=i.offsetTop,f=i.offsetBottom;return u+=t,d+=n,h=a-(s*r+u),f=l-(c*r+d),{scale:r,offsetTop:d,offsetLeft:u,offsetRight:h,offsetBottom:f}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
1
|
+
var iDrawUtil=function(t){"use strict";var e,n,i,o,r,a,l,s=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},c=(t,e,n)=>(s(t,e,"read from private field"),n?n.call(t):e.get(t)),h=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},u=(t,e,n,i)=>(s(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),d=(t,e,n)=>(s(t,e,"access private method"),n);function f(t){return"string"==typeof t&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}const g={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function y(){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 p(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 m(t){return/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${t}`)}function w(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach((e=>{n.push(t(e))})),n}if("Object"===n){const n={};Object.keys(e).forEach((i=>{n[i]=t(e[i])}));return Object.getOwnPropertySymbols(e).forEach((i=>{n[i]=t(e[i])})),n}}(t)}function v(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const b={type(t,e){const n=v(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===v(t),json:t=>"Object"===v(t),function:t=>"Function"===v(t),asyncFunction:t=>"AsyncFunction"===v(t),string:t=>"String"===v(t),number:t=>"Number"===v(t),undefined:t=>"Undefined"===v(t),null:t=>"Null"===v(t),promise:t=>"Promise"===v(t)};const{Image:P}=window;function M(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 R(t){return"number"==typeof t&&(t>0||t<=0)}function I(t){return"number"==typeof t&&t>=0}function $(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function E(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const A={x:function(t){return R(t)},y:function(t){return R(t)},w:I,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:R,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return I(t)},borderRadius:function(t){return R(t)&&t>=0},color:function(t){return f(t)},imageSrc:function(t){return E(t)||$(t)},imageURL:$,imageBase64:E,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return R(t)&&t>0},lineHeight:function(t){return R(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)},strokeWidth:function(t){return R(t)&&t>0}};function S(t={}){const{borderColor:e,borderRadius:n,borderWidth:i}=t;return!(t.hasOwnProperty("borderColor")&&!A.color(e))&&(!(t.hasOwnProperty("borderRadius")&&!A.number(n))&&!(t.hasOwnProperty("borderWidth")&&!A.number(i)))}const C={attrs:function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return!!(A.x(e)&&A.y(n)&&A.w(i)&&A.h(o)&&A.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){const{text:e,color:n,fontSize:i,lineHeight:o,fontFamily:r,textAlign:a,fontWeight:l,background:s,strokeWidth:c,strokeColor:h}=t;return!!A.text(e)&&(!!A.color(n)&&(!!A.fontSize(i)&&(!(t.hasOwnProperty("background")&&!A.color(s))&&(!(t.hasOwnProperty("fontWeight")&&!A.fontWeight(l))&&(!(t.hasOwnProperty("lineHeight")&&!A.lineHeight(o))&&(!(t.hasOwnProperty("fontFamily")&&!A.fontFamily(r))&&(!(t.hasOwnProperty("textAlign")&&!A.textAlign(a))&&(!(t.hasOwnProperty("strokeWidth")&&!A.strokeWidth(c))&&(!(t.hasOwnProperty("strokeColor")&&!A.color(h))&&!!S(t))))))))))},rectDesc:function(t){const{background:e}=t;return!(t.hasOwnProperty("background")&&!A.color(e))&&!!S(t)},circleDesc:function(t){const{background:e,borderColor:n,borderWidth:i}=t;return!(t.hasOwnProperty("background")&&!A.color(e))&&(!(t.hasOwnProperty("borderColor")&&!A.color(n))&&!(t.hasOwnProperty("borderWidth")&&!A.number(i)))},imageDesc:function(t){const{src:e}=t;return!!A.imageSrc(e)},svgDesc:function(t){const{svg:e}=t;return!!A.svg(e)},htmlDesc:function(t){const{html:e}=t;return!!A.html(e)}};class k{constructor(t,i){h(this,e,void 0),h(this,n,void 0),u(this,e,t),u(this,n,{devicePixelRatio:1,offscreenCanvas:null,...i})}$undoPixelRatio(t){return t/c(this,n).devicePixelRatio}$doPixelRatio(t){return c(this,n).devicePixelRatio*t}$getContext(){return c(this,e)}$setFont(t){const n=[];t.fontWeight&&n.push(`${t.fontWeight}`),n.push(`${this.$doPixelRatio(t.fontSize||12)}px`),n.push(`${t.fontFamily||"sans-serif"}`),c(this,e).font=`${n.join(" ")}`}$getOffscreenCanvas(){return c(this,n).offscreenCanvas}$resize(t){const{width:i,height:o,devicePixelRatio:r,resetStyle:a}=t,{canvas:l}=c(this,e);l.width=i*r,l.height=o*r,u(this,n,{...c(this,n),devicePixelRatio:r}),!0===a&&(l.style.width=`${i}px`,l.style.height=`${o}px`)}$getSize(){const{devicePixelRatio:t}=c(this,n),{width:i,height:o}=c(this,e).canvas;return{width:i/t,height:o/t,devicePixelRatio:t}}get canvas(){return c(this,e).canvas}get fillStyle(){return c(this,e).fillStyle}set fillStyle(t){c(this,e).fillStyle=t}get strokeStyle(){return c(this,e).strokeStyle}set strokeStyle(t){c(this,e).strokeStyle=t}get lineWidth(){return this.$undoPixelRatio(c(this,e).lineWidth)}set lineWidth(t){c(this,e).lineWidth=this.$doPixelRatio(t)}get textAlign(){return c(this,e).textAlign}set textAlign(t){c(this,e).textAlign=t}get textBaseline(){return c(this,e).textBaseline}set textBaseline(t){c(this,e).textBaseline=t}get globalAlpha(){return c(this,e).globalAlpha}set globalAlpha(t){c(this,e).globalAlpha=t}get shadowColor(){return c(this,e).shadowColor}set shadowColor(t){c(this,e).shadowColor=t}get shadowOffsetX(){return this.$undoPixelRatio(c(this,e).shadowOffsetX)}set shadowOffsetX(t){c(this,e).shadowOffsetX=this.$doPixelRatio(t)}get shadowOffsetY(){return this.$undoPixelRatio(c(this,e).shadowOffsetY)}set shadowOffsetY(t){c(this,e).shadowOffsetY=this.$doPixelRatio(t)}get shadowBlur(){return this.$undoPixelRatio(c(this,e).shadowBlur)}set shadowBlur(t){c(this,e).shadowBlur=this.$doPixelRatio(t)}get lineCap(){return c(this,e).lineCap}set lineCap(t){c(this,e).lineCap=t}get globalCompositeOperation(){return c(this,e).globalCompositeOperation}set globalCompositeOperation(t){c(this,e).globalCompositeOperation=t}fill(...t){return c(this,e).fill(...t)}arc(t,n,i,o,r,a){return c(this,e).arc(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),o,r,a)}rect(t,n,i,o){return c(this,e).rect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(t,n,i,o){return c(this,e).fillRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(t,n,i,o){return c(this,e).clearRect(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return c(this,e).beginPath()}closePath(){return c(this,e).closePath()}lineTo(t,n){return c(this,e).lineTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}moveTo(t,n){return c(this,e).moveTo(this.$doPixelRatio(t),this.$doPixelRatio(n))}arcTo(t,n,i,o,r){return c(this,e).arcTo(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}getLineDash(){return c(this,e).getLineDash()}setLineDash(t){const n=t.map((t=>this.$doPixelRatio(t)));return c(this,e).setLineDash(n)}stroke(t){return t?c(this,e).stroke(t):c(this,e).stroke()}translate(t,n){return c(this,e).translate(this.$doPixelRatio(t),this.$doPixelRatio(n))}rotate(t){return c(this,e).rotate(t)}drawImage(...t){const n=t[0],i=t[1],o=t[2],r=t[3],a=t[4],l=t[t.length-4],s=t[t.length-3],h=t[t.length-2],u=t[t.length-1];return 9===t.length?c(this,e).drawImage(n,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u)):c(this,e).drawImage(n,this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h),this.$doPixelRatio(u))}createPattern(t,n){return c(this,e).createPattern(t,n)}measureText(t){return c(this,e).measureText(t)}fillText(t,n,i,o){return void 0!==o?c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).fillText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}strokeText(t,n,i,o){return void 0!==o?c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o)):c(this,e).strokeText(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}save(){c(this,e).save()}restore(){c(this,e).restore()}scale(t,n){c(this,e).scale(t,n)}circle(t,n,i,o,r,a,l,s){c(this,e).ellipse(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,l,s)}isPointInPath(t,n){return c(this,e).isPointInPath(this.$doPixelRatio(t),this.$doPixelRatio(n))}clip(...t){return c(this,e).clip(...t)}setTransform(t,n,i,o,r,a){return c(this,e).setTransform(t,n,i,o,r,a)}getTransform(){return c(this,e).getTransform()}createLinearGradient(t,n,i,o){return c(this,e).createLinearGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(t,n,i,o,r,a){return c(this,e).createRadialGradient(this.$doPixelRatio(t),this.$doPixelRatio(n),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(t,n,i){return c(this,e).createConicGradient(t,this.$doPixelRatio(n),this.$doPixelRatio(i))}}function 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 L(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}function T(t,e){return t.x===e.x&&t.y===e.y&&t.t===e.t}function D(t){return t>=0||t<0}function j(t){return D(t.x)&&D(t.y)&&t.t>0}function W(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}i=new WeakMap;function F(t){return t/180*Math.PI}function H(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 V(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function N(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return V({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function B(t,e,n){const i=function(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}(t,e);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=L(t,e);let a=0,l=0;return 0===o?(a=0,l=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,l=0-Math.cos(o)*r):o===Math.PI/2?(a=r,l=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,l=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,l=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,l=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,l=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,l=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,l=0-r),a+=t.x,l+=t.y,{x:a,y:l}}function G(t,e,n){const{x:i,y:o,w:r,h:a}=t;let l={x:i,y:o},s={x:i+r,y:o},c={x:i+r,y:o+a},h={x:i,y:o+a};if(n&&(n>0||n<0)){const t=F(Y(n));l=B(e,l,t),s=B(e,s,t),c=B(e,c,t),h=B(e,h,t)}return[l,s,c,h]}function U(t){const{angle:e=0}=t;return G(t,V(t),e)}function Q(t,e,n){return[B(t,{x:e[0].x,y:e[0].y},n),B(t,{x:e[1].x,y:e[1].y},n),B(t,{x:e[2].x,y:e[2].y},n),B(t,{x:e[3].x,y:e[3].y},n)]}function Y(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}function X(t,e){const n={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=U(e);if(4===t.length){const n=[t[0].x,t[1].x,t[2].x,t[3].x],i=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...n),e.y=Math.min(...i),e.w=Math.abs(Math.max(...n)-Math.min(...n)),e.h=Math.abs(Math.max(...i)-Math.min(...i))}}const i=Math.min(e.x,n.x),o=Math.min(e.y,n.y),r=Math.max(e.x+e.w,n.x+n.w),a=Math.max(e.y+e.h,n.y+n.h);n.x=i,n.y=o,n.w=Math.abs(r-i),n.h=Math.abs(a-o)})),(null==e?void 0:e.extend)&&(n.x=Math.min(n.x,0),n.y=Math.min(n.y,0));const i={contextWidth:n.w,contextHeight:n.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>n.x+n.w&&(i.contextWidth=e.viewWidth-n.x),e.viewHeight>n.y+n.h&&(i.contextHeight=e.viewHeight-n.y)),i}function q(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 Z(t,e){const n=[];let i=!1;const o=e=>{var r;for(let a=0;a<e.length&&!0!==i;a++){n.push(a);const l=e[a];if(l.uuid===t){i=!0;break}if("group"===l.type&&o((null==(r=null==l?void 0:l.detail)?void 0:r.children)||[]),i)break;n.pop()}};return o(e),n}function J(t,e){const n=t.x,i=t.y,o=t.x+t.w,r=t.y+t.h,a=e.x,l=e.y,s=e.x+e.w,c=e.y+e.h;return n<=s&&o>=a&&i<=c&&r>=l}function K(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:r,h:a,angle:l}=t,{scale:s,offsetTop:c,offsetLeft:h}=n;return{x:i*s+h,y:o*s+c,w:r*s,h:a*s,angle:l}}function _(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:r,offsetTop:a,offsetLeft:l}=n;return{x:i*r+l,y:o*r+a}}function tt(t,e){const{context2d:n,element:i,viewScaleInfo:o,viewSizeInfo:r}=e,{angle:a=0}=i,{x:l,y:s,w:c,h:h}=K(i,{viewScaleInfo:o,viewSizeInfo:r}),u=U({x:l,y:s,w:c,h:h,angle:a});if(u.length>=2){n.beginPath(),n.moveTo(u[0].x,u[0].y);for(let t=1;t<u.length;t++)n.lineTo(u[t].x,u[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function et(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 nt(t){const{x:e,y:n,w:i,h:o,angle:r=0}=t;return 0===r?et(t):G(t,V({x:e,y:n,w:i,h:o,angle:r}),r)}function it(t){const e=[];let n=0,i=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:l,w:s,h:c,angle:h=0}=r[t];let u;if(n+=a,i+=l,0===t){const t={x:n,y:i,w:s,h:c,angle:h};u=nt({x:a,y:l,w:s,h:c,angle:h}),o.push({center:V(t),angle:h,radian:F(h)})}else{u=et({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=N(u);if(h>0||h<0){u=Q(t,u,F(h))}o.push({center:t,angle:h,radian:F(h)})}e.push(u)}return e}function ot(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[nt(t)];return it([...n,t])}function rt(t,e){return ot(t,e).pop()||null}function at(t,e){const{x:n,y:i}=t,{size:o,angle:r}=e;return{x:n-o/2,y:i-o/2,w:o,h:o,angle:r}}o=new WeakMap,r=new WeakMap,a=new WeakSet,l=function(){return w(c(this,r))};const lt=/([astvzqmhlc])([^astvzqmhlc]*)/gi,st=/(-?\d+(?:\.\d+)?)/gi;const ct=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,ht=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ut=/^\s*$/,dt={};function ft(t){const e={type:"element",name:"",isVoid:!1,attributes:{},children:[]},n=t.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(e.name=n[1],(dt[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(ct);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 gt(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(gt,"")+"</"+e.name+">";case"comment":return t+="\x3c!--"+e.comment+"--\x3e"}}function yt(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 xt(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 pt="Text Element";function mt(){return{boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"}}function wt(){return{background:"#D9D9D9"}}const vt={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const bt=t=>yt(t,{decimalPlaces:4});function Pt(t,e){const{detail:n}=t,{xRatio:i,yRatio:o,maxRatio:r}=e,a=(i+o)/2,{borderWidth:l,borderRadius:s,borderDash:c,shadowOffsetX:h,shadowOffsetY:u,shadowBlur:d}=n;if("number"==typeof l)n.borderWidth=bt(l*a);else if(Array.isArray(n.borderWidth)){const t=l;n.borderWidth=[bt(t[0]*o),bt(t[1]*i),bt(t[2]*o),bt(t[3]*i)]}if("number"==typeof s)n.borderRadius=bt(s*a);else if(Array.isArray(n.borderRadius)){const t=s;n.borderRadius=[t[0]*i,t[1]*i,t[2]*o,t[3]*o]}Array.isArray(c)&&c.forEach(((t,e)=>{n.borderDash[e]=bt(t*r)})),"number"==typeof h&&(n.shadowOffsetX=bt(h*r)),"number"==typeof u&&(n.shadowOffsetX=bt(u*r)),"number"==typeof d&&(n.shadowOffsetX=bt(d*r))}function Mt(t,e){const{type:n}=t;!function(t,e){const{xRatio:n,yRatio:i}=e,{x:o,y:r,w:a,h:l}=t;t.x=bt(o*n),t.y=bt(r*i),t.w=bt(a*n),t.h=bt(l*i),Pt(t,e)}(t,e),"circle"===n||("text"===n?function(t,e){const{minRatio:n,maxRatio:i}=e,{fontSize:o,lineHeight:r}=t.detail,a=(n+i)/2;o&&o>0&&(t.detail.fontSize=bt(o*a)),r&&r>0&&(t.detail.lineHeight=bt(r*a))}(t,e):"image"===n||"svg"===n||"html"===n||"path"===n||"group"===n&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Mt(t,e)})))}function Rt(t,e){const n=e.w&&e.w>0?e.w:t.w,i=e.h&&e.h>0?e.h:t.h,o=n/t.w,r=i/t.h;if(o===r&&1===o)return t;const a=Math.min(o,r),l=Math.max(o,r);t.w=n,t.h=i;const s={xRatio:o,yRatio:r,minRatio:a,maxRatio:l};return"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{Mt(t,s)})),Pt(t,s),t}const It=200,$t=200;function Et(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 At(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 St(t,e){var n;const i=Object.keys(e);for(let o=0;o<i.length;o++){const r=i[o];["x","y","w","h","angle","name"].includes(r)?t[r]=e[r]:["detail","operations"].includes(r)&&(b.json(e[r])?((null==t?void 0:t.hasOwnProperty(r))||(t[r]={}),b.json(t[r])&&(t[r]={...t[r],...e[r]})):b.array(e[r])&&((null==t?void 0:t.hasOwnProperty(r))||(t[r]=[]),b.array(t[r])&&(null==(n=null==e?void 0:e[r])||n.forEach(((e,n)=>{t[r][n]=e})),t[r]=[...t[r],...e[r]])))}return t}return t.Context2D=k,t.EventEmitter=class{constructor(){h(this,i,void 0),u(this,i,new Map)}on(t,e){if(c(this,i).has(t)){const n=c(this,i).get(t)||[];null==n||n.push(e),c(this,i).set(t,n)}else c(this,i).set(t,[e])}off(t,e){if(c(this,i).has(t)){const n=c(this,i).get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}c(this,i).set(t,n||[])}}trigger(t,e){const n=c(this,i).get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(c(this,i).has(t)){const e=c(this,i).get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){c(this,i).clear()}},t.Store=class{constructor(t){h(this,a),h(this,o,void 0),h(this,r,void 0),u(this,r,w(t.defaultStorage)),u(this,o,d(this,a,l).call(this))}set(t,e){c(this,o)[t]=e}get(t){return c(this,o)[t]}getSnapshot(){return w(c(this,o))}clear(){u(this,o,d(this,a,l).call(this))}destroy(){u(this,o,null)}},t.calcDistance=L,t.calcElementCenter=V,t.calcElementCenterFromVertexes=N,t.calcElementListSize=function(t){var e;const n={x:0,y:0,w:0,h:0};let i=null;for(let o=0;o<t.length;o++){const r=t[o];if(null==(e=null==r?void 0:r.operations)?void 0:e.invisible)continue;const a={x:r.x,y:r.y,w:r.w,h:r.h,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const t=U(a);if(4===t.length){const e=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];a.x=Math.min(...e),a.y=Math.min(...n),a.w=Math.abs(Math.max(...e)-Math.min(...e)),a.h=Math.abs(Math.max(...n)-Math.min(...n))}}if(i){const t=Math.min(a.x,n.x),e=Math.min(a.y,n.y),i=Math.max(a.x+a.w,n.x+n.w),o=Math.max(a.y+a.h,n.y+n.h);n.x=t,n.y=e,n.w=Math.abs(i-t),n.h=Math.abs(o-e)}else n.x=a.x,n.y=a.y,n.w=a.w,n.h=a.h;i=a}return{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.ceil(n.w),h:Math.ceil(n.h)}},t.calcElementQueueVertexesQueueInGroup=it,t.calcElementSizeController=function(t,e){const{groupQueue:n,controllerSize:i,viewScaleInfo:o}=e,r=(i&&i>0?i:8)/o.scale,{x:a,y:l,w:s,h:c,angle:h=0}=t,u=[{uuid:y(),x:a,y:l,w:s,h:c,angle:h,type:"group",detail:{children:[]}},...n];let d=0;u.forEach((({angle:t=0})=>{d+=t}));const f=rt(t,{groupQueue:n}),g=W(f[0],f[1]),x=W(f[1],f[2]),p=W(f[2],f[3]),m=W(f[3],f[0]),w=f[0],v=f[1],b=f[2],P=f[3],M=at(w,{size:r,angle:d}),R=at(v,{size:r,angle:d}),I=at(P,{size:r,angle:d}),$=at(b,{size:r,angle:d}),E=nt(M),A=nt(R),S=nt(I),C=nt($),k=[E[1],A[0],A[3],E[2]],z=[A[3],A[2],C[1],C[0]],O=[S[1],C[0],C[3],S[2]];return{elementWrapper:f,left:{type:"left",vertexes:[E[3],E[2],S[1],S[0]],center:m},right:{type:"right",vertexes:z,center:x},top:{type:"top",vertexes:k,center:g},bottom:{type:"bottom",vertexes:O,center:p},topLeft:{type:"top-left",vertexes:E,center:w},topRight:{type:"top-right",vertexes:A,center:v},bottomLeft:{type:"bottom-left",vertexes:S,center:P},bottomRight:{type:"bottom-right",vertexes:C,center:b}}},t.calcElementVertexesInGroup=rt,t.calcElementVertexesQueueInGroup=ot,t.calcElementsContextSize=X,t.calcElementsViewInfo=function(t,e,n){const i=X(t,{viewWidth:e.width,viewHeight:e.height,extend:null==n?void 0:n.extend});return!0===(null==n?void 0:n.extend)&&(i.contextWidth=Math.max(i.contextWidth,e.contextWidth),i.contextHeight=Math.max(i.contextHeight,e.contextHeight)),{contextSize:i}},t.calcSpeed=function(t,e){return L(t,e)/Math.abs(e.t-t.t)},t.calcViewBoxSize=function(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o}=t.detail;const{boxSizing:r=vt.boxSizing,borderWidth:a}=t.detail;Array.isArray(a)&&(o=0);let{x:l,y:s,w:c,h:h}=t,u=[0,0,0,0];if("number"==typeof o){const t=o*i;u=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(u=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let d=0;return"number"==typeof a&&(d=(a||0)*i),"border-box"===r?(l=t.x+d/2,s=t.y+d/2,c=t.w-d,h=t.h-d):"content-box"===r?(l=t.x-d/2,s=t.y-d/2,c=t.w+d,h=t.h+d):(l=t.x,s=t.y,c=t.w,h=t.h),c=Math.max(c,1),h=Math.max(h,1),u=u.map((t=>Math.min(t,c/2,h/2))),{x:l,y:s,w:c,h:h,radiusList:u}},t.calcViewElementSize=K,t.calcViewPointSize=_,t.calcViewScaleInfo=function(t,e){const{scale:n,offsetX:i,offsetY:o}=t,{viewSizeInfo:r}=e,{width:a,height:l,contextWidth:s,contextHeight:c}=r,h=0-i*n,u=0-o*n;return{scale:n,offsetLeft:h,offsetTop:u,offsetRight:a-(s*n+h/n),offsetBottom:l-(c*n+u/n)}},t.calcViewVertexes=function(t,e){return[_(t[0],e),_(t[1],e),_(t[2],e),_(t[3],e)]},t.check=C,t.checkRectIntersect=J,t.colorNameToHex=function(t){const e=t.toLowerCase(),n=g[e];return"string"==typeof n?n:null},t.colorToCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("linear-gradient"===(null==t?void 0:t.type)){const n=[];"number"==typeof t.angle?n.push(`${t.angle}deg`):n.push("180deg"),Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`linear-gradient(${n.join(", ")})`}else if("radial-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.forEach((t=>{n.push(`${t.color} ${100*t.offset}%`)})),e=`radial-gradient(circle, ${n.join(", ")})`}return e},t.colorToLinearGradientCSS=function(t){let e="transparent";if("string"==typeof t)e=t;else if("radial-gradient"===(null==t?void 0:t.type)||"linear-gradient"===(null==t?void 0:t.type)){const n=[];Array.isArray(t.stops)&&t.stops.length>0&&(t.stops.forEach(((e,i)=>{n.push(`${e.color} ${100*e.offset}%`),i===t.stops.length-1&&e.offset<1&&n.push(`${e.color} ${100*e.offset}%`)})),e=`linear-gradient(90deg, ${n.join(", ")})`)}return e},t.compose=function(t){return function(e,n){return function i(o){let r=t[o];o===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,i.bind(null,o+1)))}catch(t){return Promise.reject(t)}}(0)}},t.compressImage=function(t,e){let n=.5;const i=(null==e?void 0:e.type)||"image/png";return(null==e?void 0:e.radio)&&(null==e?void 0:e.radio)>0&&(null==e?void 0:e.radio)<=1&&(n=null==e?void 0:e.radio),new Promise(((e,o)=>{const r=new Image;r.addEventListener("load",(()=>{const{width:t,height:o}=r,a=t*n,l=o*n;let s=document.createElement("canvas");s.width=a,s.height=l;s.getContext("2d").drawImage(r,0,0,a,l);const c=s.toDataURL(i);s=null,e(c)})),r.addEventListener("error",(t=>{o(t)})),r.src=t}))},t.createAssetId=p,t.createBoardContent=function(t,e){const{width:n,height:i,devicePixelRatio:o,offscreen:r}=e,a={width:n,height:i,devicePixelRatio:o};if(!0===r){const e=t.getContext("2d"),n=O(a),i=O(a),o=O(a),r=z({ctx:e,...a}),l=()=>{const{width:t,height:e}=n.$getSize();r.clearRect(0,0,t,e),r.drawImage(o.canvas,0,0,t,e),r.drawImage(n.canvas,0,0,t,e),r.drawImage(i.canvas,0,0,t,e),o.clearRect(0,0,t,e),n.clearRect(0,0,t,e),i.clearRect(0,0,t,e)};return{underContext:o,viewContext:n,helperContext:i,boardContext:r,drawView:l}}{const e=t.getContext("2d"),o=z(a),r=z(a),l=z(a),s=z({ctx:e,...a}),c=()=>{s.clearRect(0,0,n,i),s.drawImage(l.canvas,0,0,n,i),s.drawImage(o.canvas,0,0,n,i),s.drawImage(r.canvas,0,0,n,i),l.clearRect(0,0,n,i),o.clearRect(0,0,n,i),r.clearRect(0,0,n,i)};return{underContext:l,viewContext:o,helperContext:r,boardContext:s,drawView:c}}},t.createContext2D=z,t.createElement=function(t,e,n){const i=function(t,e){let n=0,i=0,o=It,r=$t;if(e){const{viewScaleInfo:a,viewSizeInfo:l}=e,{scale:s,offsetLeft:c,offsetTop:h}=a,{width:u,height:d}=l,f=u/4,g=d/4;o=It>=f?f/s:It/s,r=$t>=g?g/s:$t/s,["circle","svg","image"].includes(t)?o=r=Math.max(o,r):"text"===t&&(r=o/pt.length*2),n=(0-c+u/2-o*s/2)/s,i=(0-h+d/2-r*s/2)/s}return{x:n,y:i,w:o,h:r}}(t,n);let o={};return"rect"===t?o={background:"#D9D9D9"}:"circle"===t?o={background:"#D9D9D9",radius:0}:"text"===t?o=function(t){const e={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};return{text:pt,color:e.color,fontFamily:e.fontFamily,fontWeight:e.fontWeight,lineHeight:t.w/pt.length,fontSize:t.w/pt.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:y(),type:t,detail:{...o,...e.detail||{}}}},t.createOffscreenContext2D=O,t.createUUID=y,t.deepClone=w,t.deepCloneElement=function(t){const e=w(t),n=t=>{t.uuid=y(),"group"===t.type&&t.detail.children&&t.detail.children.forEach((t=>{n(t)}))};return n(e),e},t.deepResizeGroupElement=Rt,t.delay=function(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))},t.deleteElementInList=function(t,e){return At(Z(t,e),e)},t.deleteElementInListByPosition=At,t.downloadFileFromText=function(t,e){const{fileName:n}=e,i=function(t){const e=(new TextEncoder).encode(t),n=new Blob([e],{type:"text/plain;charset=utf-8"});return window.URL.createObjectURL(n)}(t);let o=document.createElement("a");o.href=i,o.download=n,o.click(),o=null},t.downloadImageFromCanvas=function(t,e){const{fileName:n,type:i="image/jpeg"}=e,o=t.toDataURL(i);let r=document.createElement("a");r.href=o,r.download=n,r.click(),r=null},t.equalPoint=T,t.equalTouchPoint=function(t,e){return!0===T(t,e)&&t.f===e.f},t.filterCompactData=function(t,e){const n=t.assets||{},i=w(t),o=(null==e?void 0:e.loadItemMap)||{},r=t=>{t.forEach((t=>{var e,i,a;if("image"===t.type&&t.detail.src){const i=t.detail.src;if(m(i)&&!n[i]&&o[i]&&"string"==typeof(null==(e=o[i])?void 0:e.source))n[i]={type:"image",value:o[i].source};else{const e=p(i);n[e]||(n[e]={type:"image",value:i}),t.detail.src=e}}else if("svg"===t.type){const e=t.detail.svg,r=p(e);m(e)&&!n[e]&&o[e]&&"string"==typeof(null==(i=o[e])?void 0:i.source)?n[e]={type:"svg",value:o[e].source}:n[r]||(n[r]={type:"svg",value:e}),t.detail.svg=r}else if("html"===t.type){const e=t.detail.html,i=p(e);m(e)&&!n[e]&&o[e]&&"string"==typeof(null==(a=o[e])?void 0:a.source)?n[e]={type:"html",value:o[e].source}: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||m(i)||(e=p(i),n={type:t.type,value:i},"image"===t.type?t.detail.src=e:"svg"===t.type?t.detail.svg=e:"html"===t.type&&(t.detail.html=e)),{element:t,assetId:e,assetItem:n}},t.findElementFromList=function t(e,n){var i;let o=null;for(let r=0;r<n.length;r++){const a=n[r];if(a.uuid===e){o=a;break}if(!o&&"group"===a.type){const n=t(e,(null==(i=null==a?void 0:a.detail)?void 0:i.children)||[]);if((null==n?void 0:n.uuid)===e){o=n;break}}}return o},t.findElementFromListByPosition=q,t.findElementQueueFromListByPosition=function(t,e){const n=[];let i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(!o)break;if(n.push(o),!(e<t.length-1&&"group"===o.type))break;i=o.detail.children}return n},t.findElementsFromList=function(t,e){const n=[];return function e(i){var o;for(let r=0;r<i.length;r++){const a=i[r];t.includes(a.uuid)?n.push(a):"group"===a.type&&e((null==(o=null==a?void 0:a.detail)?void 0:o.children)||[])}}(e),n},t.findElementsFromListByPositions=function(t,e){const n=[];return t.forEach((t=>{const i=q(t,e);i&&n.push(i)})),n},t.formatNumber=yt,t.generateHTML=function(t){return t.reduce((function(t,e){return t+gt("",e)}),"")},t.generateSVGPath=function(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e},t.getCenterFromTwoPoints=W,t.getDefaultElementDetailConfig=mt,t.getDefaultElementRectDetail=wt,t.getElemenetsAssetIds=function(t){const e=[],n=t=>{t.forEach((t=>{"image"===t.type&&m(t.detail.src)?e.push(t.detail.src):"svg"===t.type&&m(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=Z,t.getElementRotateVertexes=G,t.getElementSize=function(t){const{x:e,y:n,w:i,h:o,angle:r}=t;return{x:e,y:n,w:i,h:o,angle:r}},t.getElementVertexes=et,t.getGroupQueueFromList=function(t,e){const n=[];return function t(e,i){var o;let r=null;for(let a=0;a<i.length;a++){const l=i[a];if(l.uuid===e){r=l;break}if(!r&&"group"===l.type){n.push(l);const i=t(e,(null==(o=null==l?void 0:l.detail)?void 0:o.children)||[]);if((null==i?void 0:i.uuid)===e){r=i;break}n.pop()}}return r}(t,e),n},t.getSelectedElementUUIDs=function(t,e){var n;let i=[];return Array.isArray(null==t?void 0:t.elements)&&(null==(n=null==t?void 0:t.elements)?void 0:n.length)>0&&Array.isArray(e)&&e.length>0&&e.forEach((e=>{var n;"number"==typeof e?(null==(n=null==t?void 0:t.elements)?void 0:n[e])&&i.push(t.elements[e].uuid):"string"==typeof e&&(i=i.concat(function(t,e){var n;const i=[];if("string"==typeof e&&/^\d+(\.\d+)*$/.test(e)){const o=e.split(".");let r=t;for(;o.length>0;){const t=o.shift();if("string"==typeof t){const e=r[parseInt(t)];e&&0===o.length?i.push(e.uuid):"group"===e.type&&o.length>0&&(r=(null==(n=null==e?void 0:e.detail)?void 0:n.children)||[])}break}}return i}(t.elements,e)))})),i},t.getViewPointAtElement=function(t,e){var n,i,o;const{context2d:r,data:a,viewScaleInfo:l,viewSizeInfo:s,groupQueue:c}=e,h={index:-1,element:null,groupQueueIndex:-1};if(c&&Array.isArray(c)&&(null==c?void 0:c.length)>0)for(let e=c.length-1;e>=0;e--){let o=0,a=0,u=0;for(let t=0;t<=e;t++)o+=c[t].x,a+=c[t].y,u+=c[t].angle||0;const d=c[e];if(d&&"group"===d.type&&Array.isArray(null==(n=d.detail)?void 0:n.children))for(let n=0;n<d.detail.children.length;n++){const f=d.detail.children[n];if(!0!==(null==(i=null==f?void 0:f.operations)?void 0:i.invisible)){if(!f)break;if(tt(t,{context2d:r,element:{x:o+f.x,y:a+f.y,w:f.w,h:f.h,angle:u+(f.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){h.element=f,(e<c.length-1||"group"!==f.type)&&(h.groupQueueIndex=e);break}}}if(h.element)break}if(h.element)return h;for(let e=a.elements.length-1;e>=0;e--){const n=a.elements[e];if(!0!==(null==(o=null==n?void 0:n.operations)?void 0:o.invisible)&&tt(t,{context2d:r,element:n,viewScaleInfo:l,viewSizeInfo:s})){h.index=e,h.element=n;break}}return h},t.getViewScaleInfoFromSnapshot=function(t){const{activeStore:e}=t;return{scale:null==e?void 0:e.scale,offsetTop:null==e?void 0:e.offsetTop,offsetBottom:null==e?void 0:e.offsetBottom,offsetLeft:null==e?void 0:e.offsetLeft,offsetRight:null==e?void 0:e.offsetRight}},t.getViewSizeInfoFromSnapshot=function(t){const{activeStore:e}=t;return{devicePixelRatio:e.devicePixelRatio,width:null==e?void 0:e.width,height:null==e?void 0:e.height,contextWidth:null==e?void 0:e.contextWidth,contextHeight:null==e?void 0:e.contextHeight}},t.insertElementToListByPosition=Et,t.is=A,t.isAssetId=m,t.isColorStr=f,t.isElementInView=function(t,e){const{viewSizeInfo:n,viewScaleInfo:i}=e,{width:o,height:r}=n,{angle:a}=t,{x:l,y:s,w:c,h:h}=K(t,{viewScaleInfo:i,viewSizeInfo:n}),u=U({x:l,y:s,w:c,h:h,angle:a}),d={x:0,y:0,w:o,h:r},f=Math.min(u[0].x,u[1].x,u[2].x,u[3].x),g=Math.min(u[0].y,u[1].y,u[2].y,u[3].y);return J(d,{x:f,y:g,w:Math.max(u[0].x,u[1].x,u[2].x,u[3].x)-f,h:Math.max(u[0].y,u[1].y,u[2].y,u[3].y)-g})},t.isResourceElement=function(t){return["image","svg","html"].includes(null==t?void 0:t.type)},t.isViewPointInElement=tt,t.istype=b,t.limitAngle=Y,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"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},a.onerror=function(t){o(t)}}))}(t,e);return await M(n)},t.loadImage=M,t.loadSVG=async function(t){const e=await function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null==(n=null==t?void 0:t.target)?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return await M(e)},t.matrixToAngle=function(t){const e=xt(t);if("number"==typeof e){return 180*e/Math.PI}return e},t.matrixToRadian=xt,t.mergeElementAsset=function(t,e){const n=t;let i=null,o=null;return"image"===n.type?i=n.detail.src:"svg"===n.type?i=n.detail.svg:"html"===n.type&&(i=n.detail.html),i&&(null==i?void 0:i.startsWith("@assets/"))&&(o=e[i]),(null==o?void 0:o.type)===n.type&&"string"==typeof(null==o?void 0:o.value)&&(null==o?void 0:o.value)&&("image"===n.type?n.detail.src=o.value:"svg"===n.type?n.detail.svg=o.value:"html"===n.type&&(n.detail.html=o.value)),n},t.mergeHexColorAlpha=function(t,e){if(1===e)return t;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^\#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o},t.moveElementPosition=function(t,e){const{from:n,to:i}=e;if(0===n.length||0===i.length)return t;if(n.length<=i.length)for(let e=0;e<n.length;e++)if(i[e]!==n[e]);else if(e===n.length-1)return t;const o=q(n,t);if(o){if(!Et(o,i,t))return t;let e=-1;for(let t=0;t<n.length&&i[t]>=0;t++)i[t]!==n[t]&&i[t]<n[t]&&t==i.length-1&&(e=t);e>=0&&(n[e]=n[e]+1),At(n,t)}return t},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(ht,((r,a)=>{const l="/"!==r.charAt(1),s=r.startsWith("\x3c!--"),c=a+r.length,h=t.charAt(c);let u;if(s){const t=ft(r);return o<0?(e.push(t),r):(u=n[o],u.children.push(t),r)}if(l){if(o++,i=ft(r),!i.isVoid&&h&&"<"!==h){const e=t.slice(c,t.indexOf("<",c));e.trim()&&i.children.push({type:"text",name:null,attributes:{},children:[],isVoid:!1,textContent:e.trim()})}0===o&&e.push(i),u=n[o-1],u&&u.children.push(i),n[o]=i}if((!l||!Array.isArray(i)&&i.isVoid)&&(o>-1&&!Array.isArray(i)&&(i.isVoid||i.name===r.slice(2,-1))&&(o--,i=-1===o?e:n[o]),"<"!==h&&h)){u=-1===o?e:n[o].children;const i=t.indexOf("<",c);let r=t.slice(c,-1===i?void 0:i);ut.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(lt,((t,n,i)=>{const o=i.match(st),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=H,t.rotateElement=function(t,e,n){const i=V(e);H(t,e.angle||0,i,(()=>{n(t)}))},t.rotateElementVertexes=U,t.rotatePoint=B,t.rotatePointInGroup=function(t,e){if((null==e?void 0:e.length)>0){let n=t.x,i=t.y;return e.forEach((t=>{const{x:e,y:o,w:r,h:a,angle:l=0}=t,s=B(V({x:e,y:o,w:r,h:a,angle:l}),{x:n,y:i},F(l));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=p(e);n[i]||(n[i]={type:"image",value:e}),t.detail.src=i}else if("svg"===t.type){const e=t.detail.svg,i=p(e);n[i]||(n[i]={type:"svg",value:e}),t.detail.svg=i}else if("html"===t.type){const e=t.detail.html,i=p(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.throttle=function(t,e){let n=-1;return function(...i){n>0||(n=setTimeout((()=>{t(...i),n=-1}),e))}},t.toColorHexNum=function(t){return parseInt(t.replace(/^\#/,"0x"))},t.toColorHexStr=function(t){return"#"+t.toString(16)},t.updateElementInList=function t(e,n,i){var o,r;let a=null;for(let l=0;l<i.length;l++){const s=i[l];if(s.uuid===e){"group"===s.type&&!0===(null==(o=s.operations)?void 0:o.deepResize)&&(n.w&&n.w>0||n.h&&n.h>0)&&Rt(s,{w:n.w,h:n.h}),St(s,n),a=s;break}"group"===s.type&&(a=t(e,n,(null==(r=null==s?void 0:s.detail)?void 0:r.children)||[]))}return a},t.vaildPoint=j,t.vaildTouchPoint=function(t){return!0===j(t)&&t.f>=0},t.validateElements=function t(e){let n=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(n=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(n=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(n=t(null==(o=null==e?void 0:e.detail)?void 0:o.children))}))}return n},t.viewScale=function(t){const{scale:e,point:n,viewScaleInfo:i}=t,{offsetLeft:o,offsetTop:r}=i,a=e/i.scale,l=n.x,s=n.y;return{moveX:l-l*a+(o*a-o),moveY:s-s*a+(r*a-r)}},t.viewScroll=function(t){const{moveX:e=0,moveY:n=0,viewScaleInfo:i,viewSizeInfo:o}=t,{scale:r}=i,{width:a,height:l,contextWidth:s,contextHeight:c}=o;let h=i.offsetLeft,u=i.offsetRight,d=i.offsetTop,f=i.offsetBottom;return h+=e,d+=n,u=a-(s*r+h),f=l-(c*r+d),{scale:r,offsetTop:d,offsetLeft:h,offsetRight:u,offsetBottom:f}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
|