@idraw/renderer 0.4.0-beta.4 → 0.4.0-beta.40

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.
@@ -1,43 +1,29 @@
1
1
  var iDrawRenderer = function(exports) {
2
- "use strict";var __accessCheck = (obj, member, msg) => {
3
- if (!member.has(obj))
4
- throw TypeError("Cannot " + msg);
5
- };
6
- var __privateGet = (obj, member, getter) => {
7
- __accessCheck(obj, member, "read from private field");
8
- return getter ? getter.call(obj) : member.get(obj);
9
- };
10
- var __privateAdd = (obj, member, value) => {
11
- if (member.has(obj))
12
- throw TypeError("Cannot add the same private member more than once");
13
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
14
- };
15
- var __privateSet = (obj, member, value, setter) => {
16
- __accessCheck(obj, member, "write to private field");
17
- setter ? setter.call(obj, value) : member.set(obj, value);
18
- return value;
19
- };
20
- var __privateMethod = (obj, member, method) => {
21
- __accessCheck(obj, member, "access private method");
22
- return method;
2
+ "use strict";var __typeError = (msg) => {
3
+ throw TypeError(msg);
23
4
  };
5
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
8
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
9
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
24
10
 
25
- var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _registerLoadFunc, registerLoadFunc_fn, _getLoadElementSource, getLoadElementSource_fn, _createLoadItem, createLoadItem_fn, _emitLoad, emitLoad_fn, _emitError, emitError_fn, _loadResource, loadResource_fn, _isExistingErrorStorage, isExistingErrorStorage_fn, _opts, _loader, _init, init_fn;
11
+ var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _hasDestroyed, _Loader_instances, registerLoadFunc_fn, getLoadElementSource_fn, createLoadItem_fn, emitLoad_fn, emitError_fn, loadResource_fn, isExistingErrorStorage_fn, _opts, _store, _opts2, _loader, _calculator, _hasDestroyed2, _Renderer_instances, init_fn;
26
12
  function isColorStr(color2) {
27
- return typeof color2 === "string" && (/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
13
+ return typeof color2 === "string" && (/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
28
14
  }
29
15
  function mergeHexColorAlpha(hex, alpha) {
30
16
  if (alpha === 1) {
31
17
  return hex;
32
18
  }
33
19
  let hexAlpha = 1;
34
- const regHex1 = /^\#[0-9a-f]{6,6}$/i;
35
- const regHex2 = /^\#[0-9a-f]{8,8}$/i;
20
+ const regHex1 = /^#[0-9a-f]{6,6}$/i;
21
+ const regHex2 = /^#[0-9a-f]{8,8}$/i;
36
22
  let result = hex;
37
23
  if (regHex1.test(hex)) {
38
- hexAlpha = parseInt(hex.substring(5, 7).replace(/^\#/, "0x"));
24
+ hexAlpha = parseInt(hex.substring(5, 7).replace(/^#/, "0x"));
39
25
  } else if (regHex2.test(hex)) {
40
- hexAlpha = parseInt(hex.substring(7, 9).replace(/^\#/, "0x"));
26
+ hexAlpha = parseInt(hex.substring(7, 9).replace(/^#/, "0x"));
41
27
  result = hex.substring(0, 7);
42
28
  }
43
29
  hexAlpha = hexAlpha * alpha;
@@ -78,6 +64,46 @@ var __privateMethod = (obj, member, method) => {
78
64
  function isAssetId(id) {
79
65
  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(`${id}`);
80
66
  }
67
+ (function(s, e) {
68
+ var t = {};
69
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
70
+ t[p] = s[p];
71
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
72
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
73
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
74
+ t[p[i]] = s[p[i]];
75
+ }
76
+ return t;
77
+ });
78
+ function deepClone(target) {
79
+ function _clone(t) {
80
+ const type = is$1(t);
81
+ if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type) >= 0) {
82
+ return t;
83
+ } else if (type === "Array") {
84
+ const arr = [];
85
+ t.forEach((item) => {
86
+ arr.push(_clone(item));
87
+ });
88
+ return arr;
89
+ } else if (type === "Object") {
90
+ const obj = {};
91
+ const keys = Object.keys(t);
92
+ keys.forEach((key) => {
93
+ obj[key] = _clone(t[key]);
94
+ });
95
+ const symbolKeys = Object.getOwnPropertySymbols(t);
96
+ symbolKeys.forEach((key) => {
97
+ obj[key] = _clone(t[key]);
98
+ });
99
+ return obj;
100
+ }
101
+ }
102
+ return _clone(target);
103
+ }
104
+ function is$1(target) {
105
+ return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
106
+ }
81
107
  function parsePrototype(data) {
82
108
  const typeStr = Object.prototype.toString.call(data) || "";
83
109
  const result = typeStr.replace(/(\[object|\])/gi, "").trim();
@@ -100,6 +126,9 @@ var __privateMethod = (obj, member, method) => {
100
126
  asyncFunction(data) {
101
127
  return parsePrototype(data) === "AsyncFunction";
102
128
  },
129
+ boolean(data) {
130
+ return parsePrototype(data) === "Boolean";
131
+ },
103
132
  string(data) {
104
133
  return parsePrototype(data) === "String";
105
134
  },
@@ -218,6 +247,9 @@ var __privateMethod = (obj, member, method) => {
218
247
  return image;
219
248
  });
220
249
  }
250
+ function positiveNum(value) {
251
+ return typeof value === "number" && value >= 0;
252
+ }
221
253
  function number(value) {
222
254
  return typeof value === "number" && (value > 0 || value <= 0);
223
255
  }
@@ -228,19 +260,19 @@ var __privateMethod = (obj, member, method) => {
228
260
  return number(value);
229
261
  }
230
262
  function w(value) {
231
- return typeof value === "number" && value >= 0;
263
+ return positiveNum(value);
232
264
  }
233
265
  function h(value) {
234
- return typeof value === "number" && value >= 0;
266
+ return positiveNum(value);
235
267
  }
236
268
  function angle(value) {
237
269
  return typeof value === "number" && value >= -360 && value <= 360;
238
270
  }
239
271
  function borderWidth(value) {
240
- return w(value);
272
+ return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
241
273
  }
242
274
  function borderRadius(value) {
243
- return number(value) && value >= 0;
275
+ return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
244
276
  }
245
277
  function color(value) {
246
278
  return isColorStr(value);
@@ -294,6 +326,7 @@ var __privateMethod = (obj, member, method) => {
294
326
  return /^(-?\d+(?:\.\d+)?)$/.test(`${value}`);
295
327
  }
296
328
  const is = {
329
+ positiveNum,
297
330
  x,
298
331
  y,
299
332
  w,
@@ -318,37 +351,45 @@ var __privateMethod = (obj, member, method) => {
318
351
  strokeWidth
319
352
  };
320
353
  (function(receiver, state, value, kind, f) {
321
- if (kind === "m")
322
- throw new TypeError("Private method is not writable");
323
- if (kind === "a" && !f)
324
- throw new TypeError("Private accessor was defined without a setter");
325
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
326
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
354
+ if (kind === "m") throw new TypeError("Private method is not writable");
355
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
356
+ 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");
327
357
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
328
358
  });
329
359
  (function(receiver, state, kind, f) {
330
- if (kind === "a" && !f)
331
- throw new TypeError("Private accessor was defined without a getter");
332
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
333
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
360
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
361
+ 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");
334
362
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
335
363
  });
364
+ var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
365
+ if (kind === "m") throw new TypeError("Private method is not writable");
366
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
367
+ 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");
368
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
369
+ };
370
+ var __classPrivateFieldGet$1 = function(receiver, state, kind, f) {
371
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
372
+ 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");
373
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
374
+ };
375
+ var _EventEmitter_listeners;
336
376
  class EventEmitter {
337
377
  constructor() {
338
- this._listeners = /* @__PURE__ */ new Map();
378
+ _EventEmitter_listeners.set(this, void 0);
379
+ __classPrivateFieldSet$1(this, _EventEmitter_listeners, /* @__PURE__ */ new Map(), "f");
339
380
  }
340
381
  on(eventKey, callback) {
341
- if (this._listeners.has(eventKey)) {
342
- const callbacks = this._listeners.get(eventKey) || [];
382
+ if (__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").has(eventKey)) {
383
+ const callbacks = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(eventKey) || [];
343
384
  callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
344
- this._listeners.set(eventKey, callbacks);
385
+ __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").set(eventKey, callbacks);
345
386
  } else {
346
- this._listeners.set(eventKey, [callback]);
387
+ __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").set(eventKey, [callback]);
347
388
  }
348
389
  }
349
390
  off(eventKey, callback) {
350
- if (this._listeners.has(eventKey)) {
351
- const callbacks = this._listeners.get(eventKey);
391
+ if (__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").has(eventKey)) {
392
+ const callbacks = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(eventKey);
352
393
  if (Array.isArray(callbacks)) {
353
394
  for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
354
395
  if (callbacks[i] === callback) {
@@ -357,11 +398,11 @@ var __privateMethod = (obj, member, method) => {
357
398
  }
358
399
  }
359
400
  }
360
- this._listeners.set(eventKey, callbacks || []);
401
+ __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").set(eventKey, callbacks || []);
361
402
  }
362
403
  }
363
404
  trigger(eventKey, e) {
364
- const callbacks = this._listeners.get(eventKey);
405
+ const callbacks = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(eventKey);
365
406
  if (Array.isArray(callbacks)) {
366
407
  callbacks.forEach((cb) => {
367
408
  cb(e);
@@ -372,15 +413,83 @@ var __privateMethod = (obj, member, method) => {
372
413
  }
373
414
  }
374
415
  has(name) {
375
- if (this._listeners.has(name)) {
376
- const list = this._listeners.get(name);
416
+ if (__classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").has(name)) {
417
+ const list = __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").get(name);
377
418
  if (Array.isArray(list) && list.length > 0) {
378
419
  return true;
379
420
  }
380
421
  }
381
422
  return false;
382
423
  }
424
+ destroy() {
425
+ this.clear();
426
+ }
427
+ clear() {
428
+ __classPrivateFieldGet$1(this, _EventEmitter_listeners, "f").clear();
429
+ }
430
+ }
431
+ _EventEmitter_listeners = /* @__PURE__ */ new WeakMap();
432
+ function calcDistance(start, end) {
433
+ const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
434
+ return distance === 0 ? distance : Math.sqrt(distance);
435
+ }
436
+ function getCenterFromTwoPoints(p1, p2) {
437
+ return {
438
+ x: p1.x + (p2.x - p1.x) / 2,
439
+ y: p1.y + (p2.y - p1.y) / 2
440
+ };
441
+ }
442
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
443
+ if (kind === "m") throw new TypeError("Private method is not writable");
444
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
445
+ 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");
446
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
447
+ };
448
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
449
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
450
+ 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");
451
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
452
+ };
453
+ var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_static, _Store_createTempStorage;
454
+ class Store {
455
+ constructor(opts) {
456
+ _Store_instances.add(this);
457
+ _Store_temp.set(this, void 0);
458
+ _Store_backUpDefaultStorage.set(this, void 0);
459
+ _Store_static.set(this, void 0);
460
+ __classPrivateFieldSet(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
461
+ __classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
462
+ __classPrivateFieldSet(this, _Store_static, opts.defaultStatic || {}, "f");
463
+ }
464
+ set(name, value) {
465
+ __classPrivateFieldGet(this, _Store_temp, "f")[name] = value;
466
+ }
467
+ get(name) {
468
+ return __classPrivateFieldGet(this, _Store_temp, "f")[name];
469
+ }
470
+ setStatic(name, value) {
471
+ __classPrivateFieldGet(this, _Store_static, "f")[name] = value;
472
+ }
473
+ getStatic(name) {
474
+ return __classPrivateFieldGet(this, _Store_static, "f")[name];
475
+ }
476
+ getSnapshot(opts) {
477
+ if ((opts === null || opts === void 0 ? void 0 : opts.deepClone) === true) {
478
+ return deepClone(__classPrivateFieldGet(this, _Store_temp, "f"));
479
+ }
480
+ return Object.assign({}, __classPrivateFieldGet(this, _Store_temp, "f"));
481
+ }
482
+ clear() {
483
+ __classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
484
+ }
485
+ destroy() {
486
+ __classPrivateFieldSet(this, _Store_temp, null, "f");
487
+ __classPrivateFieldSet(this, _Store_static, null, "f");
488
+ }
383
489
  }
490
+ _Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_static = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
491
+ return deepClone(__classPrivateFieldGet(this, _Store_backUpDefaultStorage, "f"));
492
+ };
384
493
  function parseAngleToRadian(angle2) {
385
494
  return angle2 / 180 * Math.PI;
386
495
  }
@@ -411,6 +520,404 @@ var __privateMethod = (obj, member, method) => {
411
520
  };
412
521
  return p;
413
522
  }
523
+ function calcElementCenterFromVertexes(ves) {
524
+ const startX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
525
+ const startY = Math.min(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
526
+ const endX = Math.max(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
527
+ const endY = Math.max(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
528
+ const elemSize = {
529
+ x: startX,
530
+ y: startY,
531
+ w: endX - startX,
532
+ h: endY - startY
533
+ };
534
+ return calcElementCenter(elemSize);
535
+ }
536
+ function calcLineRadian(center, p) {
537
+ const x2 = p.x - center.x;
538
+ const y2 = p.y - center.y;
539
+ if (x2 === 0) {
540
+ if (y2 < 0) {
541
+ return 0;
542
+ } else if (y2 > 0) {
543
+ return Math.PI;
544
+ }
545
+ } else if (y2 === 0) {
546
+ if (x2 < 0) {
547
+ return Math.PI * 3 / 2;
548
+ } else if (x2 > 0) {
549
+ return Math.PI / 2;
550
+ }
551
+ }
552
+ if (x2 > 0 && y2 < 0) {
553
+ return Math.atan(Math.abs(x2) / Math.abs(y2));
554
+ } else if (x2 > 0 && y2 > 0) {
555
+ return Math.PI - Math.atan(Math.abs(x2) / Math.abs(y2));
556
+ } else if (x2 < 0 && y2 > 0) {
557
+ return Math.PI + Math.atan(Math.abs(x2) / Math.abs(y2));
558
+ } else if (x2 < 0 && y2 < 0) {
559
+ return 2 * Math.PI - Math.atan(Math.abs(x2) / Math.abs(y2));
560
+ }
561
+ return 0;
562
+ }
563
+ function rotatePoint(center, start, radian) {
564
+ const startRadian = calcLineRadian(center, start);
565
+ const rotateRadian = radian;
566
+ let endRadian = startRadian + rotateRadian;
567
+ if (endRadian > Math.PI * 2) {
568
+ endRadian = endRadian - Math.PI * 2;
569
+ } else if (endRadian < 0 - Math.PI * 2) {
570
+ endRadian = endRadian + Math.PI * 2;
571
+ }
572
+ if (endRadian < 0) {
573
+ endRadian = endRadian + Math.PI * 2;
574
+ }
575
+ const length = calcDistance(center, start);
576
+ let x2 = 0;
577
+ let y2 = 0;
578
+ if (endRadian === 0) {
579
+ x2 = 0;
580
+ y2 = 0 - length;
581
+ } else if (endRadian > 0 && endRadian < Math.PI / 2) {
582
+ x2 = Math.sin(endRadian) * length;
583
+ y2 = 0 - Math.cos(endRadian) * length;
584
+ } else if (endRadian === Math.PI / 2) {
585
+ x2 = length;
586
+ y2 = 0;
587
+ } else if (endRadian > Math.PI / 2 && endRadian < Math.PI) {
588
+ x2 = Math.sin(Math.PI - endRadian) * length;
589
+ y2 = Math.cos(Math.PI - endRadian) * length;
590
+ } else if (endRadian === Math.PI) {
591
+ x2 = 0;
592
+ y2 = length;
593
+ } else if (endRadian > Math.PI && endRadian < 3 / 2 * Math.PI) {
594
+ x2 = 0 - Math.sin(endRadian - Math.PI) * length;
595
+ y2 = Math.cos(endRadian - Math.PI) * length;
596
+ } else if (endRadian === 3 / 2 * Math.PI) {
597
+ x2 = 0 - length;
598
+ y2 = 0;
599
+ } else if (endRadian > 3 / 2 * Math.PI && endRadian < 2 * Math.PI) {
600
+ x2 = 0 - Math.sin(2 * Math.PI - endRadian) * length;
601
+ y2 = 0 - Math.cos(2 * Math.PI - endRadian) * length;
602
+ } else if (endRadian === 2 * Math.PI) {
603
+ x2 = 0;
604
+ y2 = 0 - length;
605
+ }
606
+ x2 += center.x;
607
+ y2 += center.y;
608
+ return { x: x2, y: y2 };
609
+ }
610
+ function getElementRotateVertexes(elemSize, center, angle2) {
611
+ const { x: x2, y: y2, w: w2, h: h2 } = elemSize;
612
+ let p1 = { x: x2, y: y2 };
613
+ let p2 = { x: x2 + w2, y: y2 };
614
+ let p3 = { x: x2 + w2, y: y2 + h2 };
615
+ let p4 = { x: x2, y: y2 + h2 };
616
+ if (angle2 && (angle2 > 0 || angle2 < 0)) {
617
+ const radian = parseAngleToRadian(limitAngle(angle2));
618
+ p1 = rotatePoint(center, p1, radian);
619
+ p2 = rotatePoint(center, p2, radian);
620
+ p3 = rotatePoint(center, p3, radian);
621
+ p4 = rotatePoint(center, p4, radian);
622
+ }
623
+ return [p1, p2, p3, p4];
624
+ }
625
+ function rotateElementVertexes(elemSize) {
626
+ const { angle: angle2 = 0 } = elemSize;
627
+ const center = calcElementCenter(elemSize);
628
+ return getElementRotateVertexes(elemSize, center, angle2);
629
+ }
630
+ function rotateVertexes(center, ves, radian) {
631
+ return [
632
+ rotatePoint(center, { x: ves[0].x, y: ves[0].y }, radian),
633
+ rotatePoint(center, { x: ves[1].x, y: ves[1].y }, radian),
634
+ rotatePoint(center, { x: ves[2].x, y: ves[2].y }, radian),
635
+ rotatePoint(center, { x: ves[3].x, y: ves[3].y }, radian)
636
+ ];
637
+ }
638
+ function limitAngle(angle2) {
639
+ if (!(angle2 > 0 || angle2 < 0) || angle2 === 0 || angle2 === 360) {
640
+ return 0;
641
+ }
642
+ let num = angle2 % 360;
643
+ if (num < 0) {
644
+ num += 360;
645
+ } else if (angle2 === 360) {
646
+ num = 0;
647
+ }
648
+ return num;
649
+ }
650
+ function getGroupQueueByElementPosition(elements, position) {
651
+ var _a;
652
+ const groupQueue = [];
653
+ let currentElements = elements;
654
+ if (position.length > 1) {
655
+ for (let i = 0; i < position.length - 1; i++) {
656
+ const index = position[i];
657
+ const group = currentElements[index];
658
+ if ((group === null || group === void 0 ? void 0 : group.type) === "group" && Array.isArray((_a = group === null || group === void 0 ? void 0 : group.detail) === null || _a === void 0 ? void 0 : _a.children)) {
659
+ groupQueue.push(group);
660
+ currentElements = group.detail.children;
661
+ } else {
662
+ return null;
663
+ }
664
+ }
665
+ }
666
+ return groupQueue;
667
+ }
668
+ function findElementFromListByPosition(position, list) {
669
+ let result = null;
670
+ let tempList = list;
671
+ for (let i = 0; i < position.length; i++) {
672
+ const pos = position[i];
673
+ const item = tempList[pos];
674
+ if (i < position.length - 1 && item.type === "group") {
675
+ tempList = item.detail.children;
676
+ } else if (i === position.length - 1) {
677
+ result = item;
678
+ } else {
679
+ break;
680
+ }
681
+ }
682
+ return result;
683
+ }
684
+ function getElementVertexes(elemSize) {
685
+ const { x: x2, y: y2, h: h2, w: w2 } = elemSize;
686
+ return [
687
+ { x: x2, y: y2 },
688
+ { x: x2 + w2, y: y2 },
689
+ { x: x2 + w2, y: y2 + h2 },
690
+ { x: x2, y: y2 + h2 }
691
+ ];
692
+ }
693
+ function calcElementVertexes(elemSize) {
694
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemSize;
695
+ if (angle2 === 0) {
696
+ return getElementVertexes(elemSize);
697
+ }
698
+ return getElementRotateVertexes(elemSize, calcElementCenter({ x: x2, y: y2, w: w2, h: h2 }), angle2);
699
+ }
700
+ function calcElementQueueVertexesQueueInGroup(groupQueue) {
701
+ const vesList = [];
702
+ let totalX = 0;
703
+ let totalY = 0;
704
+ const rotateActionList = [];
705
+ const elemQueue = [...groupQueue];
706
+ for (let i = 0; i < elemQueue.length; i++) {
707
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 = 0 } = elemQueue[i];
708
+ totalX += x2;
709
+ totalY += y2;
710
+ let ves;
711
+ if (i === 0) {
712
+ const elemSize = { x: totalX, y: totalY, w: w2, h: h2 };
713
+ ves = calcElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
714
+ rotateActionList.push({
715
+ center: calcElementCenter(elemSize),
716
+ angle: angle2,
717
+ radian: parseAngleToRadian(angle2)
718
+ });
719
+ } else {
720
+ const elemSize = { x: totalX, y: totalY, w: w2, h: h2 };
721
+ ves = getElementVertexes(elemSize);
722
+ for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
723
+ const { center, radian } = rotateActionList[aIdx];
724
+ ves = rotateVertexes(center, ves, radian);
725
+ }
726
+ const vesCenter = calcElementCenterFromVertexes(ves);
727
+ if (angle2 > 0 || angle2 < 0) {
728
+ const radian = parseAngleToRadian(angle2);
729
+ ves = rotateVertexes(vesCenter, ves, radian);
730
+ }
731
+ rotateActionList.push({
732
+ center: vesCenter,
733
+ angle: angle2,
734
+ radian: parseAngleToRadian(angle2)
735
+ });
736
+ }
737
+ vesList.push(ves);
738
+ }
739
+ return vesList;
740
+ }
741
+ function calcElementVertexesQueueInGroup(targetElem, opts) {
742
+ const { groupQueue } = opts;
743
+ if (!(groupQueue.length > 0)) {
744
+ return [calcElementVertexes(targetElem)];
745
+ }
746
+ const elemQueue = [...groupQueue, ...[targetElem]];
747
+ const vesList = calcElementQueueVertexesQueueInGroup(elemQueue);
748
+ return vesList;
749
+ }
750
+ function calcElementVertexesInGroup(targetElem, opts) {
751
+ const vesList = calcElementVertexesQueueInGroup(targetElem, opts);
752
+ const ves = vesList.pop();
753
+ return ves || null;
754
+ }
755
+ function calcViewElementSize(size, opts) {
756
+ const { viewScaleInfo } = opts;
757
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = size;
758
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
759
+ const newSize = {
760
+ x: x2 * scale + offsetLeft,
761
+ y: y2 * scale + offsetTop,
762
+ w: w2 * scale,
763
+ h: h2 * scale,
764
+ angle: angle2
765
+ };
766
+ return newSize;
767
+ }
768
+ function calcViewPointSize(size, opts) {
769
+ const { viewScaleInfo } = opts;
770
+ const { x: x2, y: y2 } = size;
771
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
772
+ const newSize = {
773
+ x: x2 * scale + offsetLeft,
774
+ y: y2 * scale + offsetTop
775
+ };
776
+ return newSize;
777
+ }
778
+ function isViewPointInElement(p, opts) {
779
+ const { context2d: ctx, element: elem, viewScaleInfo } = opts;
780
+ const { angle: angle2 = 0 } = elem;
781
+ const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo });
782
+ const vertexes = rotateElementVertexes({ x: x2, y: y2, w: w2, h: h2, angle: angle2 });
783
+ if (vertexes.length >= 2) {
784
+ ctx.beginPath();
785
+ ctx.moveTo(vertexes[0].x, vertexes[0].y);
786
+ for (let i = 1; i < vertexes.length; i++) {
787
+ ctx.lineTo(vertexes[i].x, vertexes[i].y);
788
+ }
789
+ ctx.closePath();
790
+ }
791
+ if (ctx.isPointInPath(p.x, p.y)) {
792
+ return true;
793
+ }
794
+ return false;
795
+ }
796
+ function getViewPointAtElement(p, opts) {
797
+ var _a, _b, _c;
798
+ const { context2d: ctx, data, viewScaleInfo, groupQueue } = opts;
799
+ const result = {
800
+ index: -1,
801
+ element: null,
802
+ groupQueueIndex: -1
803
+ };
804
+ if (groupQueue && Array.isArray(groupQueue) && (groupQueue === null || groupQueue === void 0 ? void 0 : groupQueue.length) > 0) {
805
+ for (let gIdx = groupQueue.length - 1; gIdx >= 0; gIdx--) {
806
+ let totalX = 0;
807
+ let totalY = 0;
808
+ let totalAngle = 0;
809
+ for (let i = 0; i <= gIdx; i++) {
810
+ totalX += groupQueue[i].x;
811
+ totalY += groupQueue[i].y;
812
+ totalAngle += groupQueue[i].angle || 0;
813
+ }
814
+ const lastGroup = groupQueue[gIdx];
815
+ if (lastGroup && lastGroup.type === "group" && Array.isArray((_a = lastGroup.detail) === null || _a === void 0 ? void 0 : _a.children)) {
816
+ for (let i = 0; i < lastGroup.detail.children.length; i++) {
817
+ const child = lastGroup.detail.children[i];
818
+ if (((_b = child === null || child === void 0 ? void 0 : child.operations) === null || _b === void 0 ? void 0 : _b.invisible) === true) {
819
+ continue;
820
+ }
821
+ if (child) {
822
+ const elemSize = {
823
+ x: totalX + child.x,
824
+ y: totalY + child.y,
825
+ w: child.w,
826
+ h: child.h,
827
+ angle: totalAngle + (child.angle || 0)
828
+ };
829
+ if (isViewPointInElement(p, { context2d: ctx, element: elemSize, viewScaleInfo })) {
830
+ result.element = child;
831
+ if (gIdx < groupQueue.length - 1 || child.type !== "group") {
832
+ result.groupQueueIndex = gIdx;
833
+ }
834
+ break;
835
+ }
836
+ } else {
837
+ break;
838
+ }
839
+ }
840
+ }
841
+ if (result.element) {
842
+ break;
843
+ }
844
+ }
845
+ }
846
+ if (result.element) {
847
+ return result;
848
+ }
849
+ for (let i = data.elements.length - 1; i >= 0; i--) {
850
+ const elem = data.elements[i];
851
+ if (((_c = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _c === void 0 ? void 0 : _c.invisible) === true) {
852
+ continue;
853
+ }
854
+ if (isViewPointInElement(p, { context2d: ctx, element: elem, viewScaleInfo })) {
855
+ result.index = i;
856
+ result.element = elem;
857
+ break;
858
+ }
859
+ }
860
+ return result;
861
+ }
862
+ function calcElementOriginRectInfo(elemSize, opts) {
863
+ const { groupQueue } = opts;
864
+ const vertexes = calcElementVertexesInGroup(elemSize, { groupQueue });
865
+ const top = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
866
+ const right = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
867
+ const bottom = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
868
+ const left = getCenterFromTwoPoints(vertexes[3], vertexes[0]);
869
+ const topLeft = vertexes[0];
870
+ const topRight = vertexes[1];
871
+ const bottomRight = vertexes[2];
872
+ const bottomLeft = vertexes[3];
873
+ const maxX = Math.max(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
874
+ const maxY = Math.max(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
875
+ const minX = Math.min(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x);
876
+ const minY = Math.min(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y);
877
+ const center = {
878
+ x: (maxX + minX) / 2,
879
+ y: (maxY + minY) / 2
880
+ };
881
+ const rectInfo = {
882
+ center,
883
+ topLeft,
884
+ topRight,
885
+ bottomLeft,
886
+ bottomRight,
887
+ top,
888
+ right,
889
+ left,
890
+ bottom
891
+ };
892
+ return rectInfo;
893
+ }
894
+ function originRectInfoToRangeRectInfo(originRectInfo) {
895
+ const rangeMaxX = Math.max(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
896
+ const rangeMaxY = Math.max(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
897
+ const rangeMinX = Math.min(originRectInfo.topLeft.x, originRectInfo.topRight.x, originRectInfo.bottomRight.x, originRectInfo.bottomLeft.x);
898
+ const rangeMinY = Math.min(originRectInfo.topLeft.y, originRectInfo.topRight.y, originRectInfo.bottomRight.y, originRectInfo.bottomLeft.y);
899
+ const rangeCenter = { x: originRectInfo.center.x, y: originRectInfo.center.y };
900
+ const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
901
+ const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
902
+ const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
903
+ const rangeBottomLeft = { x: rangeMinX, y: rangeMaxY };
904
+ const rangeTop = getCenterFromTwoPoints(rangeTopLeft, rangeTopRight);
905
+ const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
906
+ const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
907
+ const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
908
+ const rangeRectInfo = {
909
+ center: rangeCenter,
910
+ topLeft: rangeTopLeft,
911
+ topRight: rangeTopRight,
912
+ bottomLeft: rangeBottomLeft,
913
+ bottomRight: rangeBottomRight,
914
+ top: rangeTop,
915
+ right: rangeRight,
916
+ left: rangeLeft,
917
+ bottom: rangeBottom
918
+ };
919
+ return rangeRectInfo;
920
+ }
414
921
  function generateSVGPath(commands) {
415
922
  let path = "";
416
923
  commands.forEach((item) => {
@@ -434,9 +941,10 @@ var __privateMethod = (obj, member, method) => {
434
941
  textAlign: "left",
435
942
  verticalAlign: "top",
436
943
  fontSize: 16,
437
- lineHeight: 20,
438
944
  fontFamily: "sans-serif",
439
945
  fontWeight: 400,
946
+ minInlineSize: "auto",
947
+ wordBreak: "break-all",
440
948
  overflow: "hidden"
441
949
  };
442
950
  return config;
@@ -446,8 +954,10 @@ var __privateMethod = (obj, member, method) => {
446
954
  const { viewScaleInfo } = opts;
447
955
  const { scale } = viewScaleInfo;
448
956
  let { borderRadius: borderRadius2 } = viewElem.detail;
957
+ const { borderDash } = viewElem.detail;
958
+ const hasBorderDash = Array.isArray(borderDash) && borderDash.length > 0;
449
959
  const { boxSizing = defaultElemConfig$1.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
450
- if (typeof borderWidth2 !== "number") {
960
+ if (Array.isArray(borderWidth2)) {
451
961
  borderRadius2 = 0;
452
962
  }
453
963
  let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
@@ -462,7 +972,7 @@ var __privateMethod = (obj, member, method) => {
462
972
  if (typeof borderWidth2 === "number") {
463
973
  bw = (borderWidth2 || 0) * scale;
464
974
  }
465
- if (boxSizing === "border-box") {
975
+ if (boxSizing === "border-box" && !hasBorderDash) {
466
976
  x2 = viewElem.x + bw / 2;
467
977
  y2 = viewElem.y + bw / 2;
468
978
  w2 = viewElem.w - bw;
@@ -491,6 +1001,21 @@ var __privateMethod = (obj, member, method) => {
491
1001
  radiusList
492
1002
  };
493
1003
  }
1004
+ const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
1005
+ function enhanceFontFamliy(fontFamily2) {
1006
+ return [fontFamily2, ...baseFontFamilyList].join(", ");
1007
+ }
1008
+ (function(s, e) {
1009
+ var t = {};
1010
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1011
+ t[p] = s[p];
1012
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1013
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1014
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1015
+ t[p[i]] = s[p[i]];
1016
+ }
1017
+ return t;
1018
+ });
494
1019
  function createColorStyle(ctx, color2, opts) {
495
1020
  if (typeof color2 === "string") {
496
1021
  return color2;
@@ -535,30 +1060,50 @@ var __privateMethod = (obj, member, method) => {
535
1060
  return "#000000";
536
1061
  }
537
1062
  const defaultElemConfig = getDefaultElementDetailConfig();
1063
+ function getOpacity(elem) {
1064
+ var _a, _b, _c, _d;
1065
+ let opacity = 1;
1066
+ if (((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.opacity) !== void 0 && ((_b = elem == null ? void 0 : elem.detail) == null ? void 0 : _b.opacity) >= 0 && ((_c = elem == null ? void 0 : elem.detail) == null ? void 0 : _c.opacity) <= 1) {
1067
+ opacity = (_d = elem == null ? void 0 : elem.detail) == null ? void 0 : _d.opacity;
1068
+ }
1069
+ return opacity;
1070
+ }
538
1071
  function drawBox(ctx, viewElem, opts) {
539
1072
  const { pattern, renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts || {};
540
- drawClipPath(ctx, viewElem, {
541
- originElem,
542
- calcElemSize,
543
- viewScaleInfo,
544
- viewSizeInfo,
545
- renderContent: () => {
546
- var _a, _b;
547
- if (((_a = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _b.opacity) >= 0) {
548
- ctx.globalAlpha = viewElem.detail.opacity;
549
- } else {
550
- ctx.globalAlpha = 1;
1073
+ const { parentOpacity } = opts;
1074
+ const opacity = getOpacity(originElem) * parentOpacity;
1075
+ const { clipPath, clipPathStrokeColor, clipPathStrokeWidth } = originElem.detail;
1076
+ const mainRender = () => {
1077
+ ctx.globalAlpha = opacity;
1078
+ drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
1079
+ renderContent == null ? void 0 : renderContent();
1080
+ drawBoxBorder(ctx, viewElem, { viewScaleInfo });
1081
+ ctx.globalAlpha = parentOpacity;
1082
+ };
1083
+ if (clipPath) {
1084
+ drawClipPath(ctx, viewElem, {
1085
+ originElem,
1086
+ calcElemSize,
1087
+ viewSizeInfo,
1088
+ renderContent: () => {
1089
+ mainRender();
551
1090
  }
552
- drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
553
- renderContent == null ? void 0 : renderContent();
554
- drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
555
- ctx.globalAlpha = 1;
1091
+ });
1092
+ if (typeof clipPathStrokeWidth === "number" && clipPathStrokeWidth > 0 && clipPathStrokeColor) {
1093
+ drawClipPathStroke(ctx, viewElem, {
1094
+ originElem,
1095
+ calcElemSize,
1096
+ viewSizeInfo,
1097
+ parentOpacity
1098
+ });
556
1099
  }
557
- });
1100
+ } else {
1101
+ mainRender();
1102
+ }
558
1103
  }
559
1104
  function drawClipPath(ctx, viewElem, opts) {
560
- const { renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts;
561
- const totalScale = viewScaleInfo.scale * viewSizeInfo.devicePixelRatio;
1105
+ const { renderContent, originElem, calcElemSize, viewSizeInfo } = opts;
1106
+ const totalScale = viewSizeInfo.devicePixelRatio;
562
1107
  const { clipPath } = (originElem == null ? void 0 : originElem.detail) || {};
563
1108
  if (clipPath && calcElemSize && clipPath.commands) {
564
1109
  const { x: x2, y: y2, w: w2, h: h2 } = calcElemSize;
@@ -585,16 +1130,45 @@ var __privateMethod = (obj, member, method) => {
585
1130
  renderContent == null ? void 0 : renderContent();
586
1131
  }
587
1132
  }
1133
+ function drawClipPathStroke(ctx, viewElem, opts) {
1134
+ const { renderContent, originElem, calcElemSize, viewSizeInfo, parentOpacity } = opts;
1135
+ const totalScale = viewSizeInfo.devicePixelRatio;
1136
+ const { clipPath, clipPathStrokeColor, clipPathStrokeWidth } = (originElem == null ? void 0 : originElem.detail) || {};
1137
+ if (clipPath && calcElemSize && clipPath.commands && typeof clipPathStrokeWidth === "number" && clipPathStrokeWidth > 0 && clipPathStrokeColor) {
1138
+ const { x: x2, y: y2, w: w2, h: h2 } = calcElemSize;
1139
+ const { originW, originH, originX, originY } = clipPath;
1140
+ const scaleW = w2 / originW;
1141
+ const scaleH = h2 / originH;
1142
+ const viewOriginX = originX * scaleW;
1143
+ const viewOriginY = originY * scaleH;
1144
+ const internalX = x2 - viewOriginX;
1145
+ const internalY = y2 - viewOriginY;
1146
+ ctx.save();
1147
+ ctx.globalAlpha = parentOpacity;
1148
+ ctx.translate(internalX, internalY);
1149
+ ctx.scale(totalScale * scaleW, totalScale * scaleH);
1150
+ const pathStr = generateSVGPath(clipPath.commands || []);
1151
+ const path2d = new Path2D(pathStr);
1152
+ ctx.strokeStyle = clipPathStrokeColor;
1153
+ ctx.lineWidth = clipPathStrokeWidth;
1154
+ ctx.stroke(path2d);
1155
+ ctx.translate(0 - internalX, 0 - internalY);
1156
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
1157
+ rotateElement(ctx, { ...viewElem }, () => {
1158
+ renderContent == null ? void 0 : renderContent();
1159
+ });
1160
+ ctx.restore();
1161
+ } else {
1162
+ renderContent == null ? void 0 : renderContent();
1163
+ }
1164
+ }
588
1165
  function drawBoxBackground(ctx, viewElem, opts) {
589
1166
  var _a, _b;
590
1167
  const { pattern, viewScaleInfo, viewSizeInfo } = opts;
591
1168
  const transform = [];
592
- viewElem.detail;
593
- viewElem.detail;
594
1169
  if (viewElem.detail.background || pattern) {
595
1170
  const { x: x2, y: y2, w: w2, h: h2, radiusList } = calcViewBoxSize(viewElem, {
596
- viewScaleInfo,
597
- viewSizeInfo
1171
+ viewScaleInfo
598
1172
  });
599
1173
  ctx.beginPath();
600
1174
  ctx.moveTo(x2 + radiusList[0], y2);
@@ -643,30 +1217,28 @@ var __privateMethod = (obj, member, method) => {
643
1217
  }
644
1218
  }
645
1219
  function drawBoxBorder(ctx, viewElem, opts) {
646
- var _a, _b;
647
1220
  if (viewElem.detail.borderWidth === 0) {
648
1221
  return;
649
1222
  }
650
1223
  if (!isColorStr(viewElem.detail.borderColor)) {
651
1224
  return;
652
1225
  }
653
- if (((_a = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _b.opacity) >= 0) {
654
- ctx.globalAlpha = viewElem.detail.opacity;
655
- } else {
656
- ctx.globalAlpha = 1;
657
- }
658
1226
  const { viewScaleInfo } = opts;
659
1227
  const { scale } = viewScaleInfo;
660
1228
  let borderColor = defaultElemConfig.borderColor;
661
1229
  if (isColorStr(viewElem.detail.borderColor) === true) {
662
1230
  borderColor = viewElem.detail.borderColor;
663
1231
  }
664
- const { borderWidth: borderWidth2, borderRadius: borderRadius2, borderDash, boxSizing = defaultElemConfig.boxSizing } = viewElem.detail;
665
- let bw = 0;
666
- if (typeof borderWidth2 === "number") {
667
- bw = borderWidth2 || 1;
1232
+ const { borderDash, borderWidth: borderWidth2, borderRadius: borderRadius2, boxSizing = defaultElemConfig.boxSizing } = viewElem.detail;
1233
+ let viewBorderDash = [];
1234
+ if (Array.isArray(borderDash) && borderDash.length > 0) {
1235
+ viewBorderDash = borderDash.map((num) => Math.ceil(num * scale));
1236
+ }
1237
+ if (viewBorderDash.length > 0) {
1238
+ ctx.lineCap = "butt";
1239
+ } else {
1240
+ ctx.lineCap = "square";
668
1241
  }
669
- bw = bw * scale;
670
1242
  let radiusList = [0, 0, 0, 0];
671
1243
  if (typeof borderRadius2 === "number") {
672
1244
  const br = borderRadius2 * scale;
@@ -674,11 +1246,12 @@ var __privateMethod = (obj, member, method) => {
674
1246
  } else if (Array.isArray(borderRadius2) && (borderRadius2 == null ? void 0 : borderRadius2.length) === 4) {
675
1247
  radiusList = [borderRadius2[0] * scale, borderRadius2[1] * scale, borderRadius2[2] * scale, borderRadius2[3] * scale];
676
1248
  }
677
- ctx.strokeStyle = borderColor;
678
- let viewBorderDash = [];
679
- if (Array.isArray(borderDash) && borderDash.length > 0) {
680
- viewBorderDash = borderDash.map((num) => Math.ceil(num * scale));
1249
+ let bw = 0;
1250
+ if (typeof borderWidth2 === "number") {
1251
+ bw = borderWidth2 || 1;
681
1252
  }
1253
+ bw = bw * scale;
1254
+ ctx.strokeStyle = borderColor;
682
1255
  let borderTop = 0;
683
1256
  let borderRight = 0;
684
1257
  let borderBottom = 0;
@@ -758,11 +1331,6 @@ var __privateMethod = (obj, member, method) => {
758
1331
  w2 = viewElem.w;
759
1332
  h2 = viewElem.h;
760
1333
  }
761
- if (viewBorderDash.length > 0) {
762
- ctx.lineCap = "butt";
763
- } else {
764
- ctx.lineCap = "square";
765
- }
766
1334
  w2 = Math.max(w2, 1);
767
1335
  h2 = Math.max(h2, 1);
768
1336
  radiusList = radiusList.map((r) => {
@@ -778,7 +1346,6 @@ var __privateMethod = (obj, member, method) => {
778
1346
  ctx.arcTo(x2, y2, x2 + w2, y2, radiusList[0]);
779
1347
  ctx.closePath();
780
1348
  ctx.stroke();
781
- ctx.globalAlpha = 1;
782
1349
  }
783
1350
  ctx.setLineDash([]);
784
1351
  }
@@ -795,69 +1362,96 @@ var __privateMethod = (obj, member, method) => {
795
1362
  renderContent();
796
1363
  ctx.restore();
797
1364
  } else {
1365
+ ctx.save();
1366
+ ctx.shadowColor = "transparent";
1367
+ ctx.shadowOffsetX = 0;
1368
+ ctx.shadowOffsetY = 0;
1369
+ ctx.shadowBlur = 0;
798
1370
  renderContent();
1371
+ ctx.restore();
799
1372
  }
800
1373
  }
801
1374
  function drawCircle(ctx, elem, opts) {
802
1375
  const { detail, angle: angle2 } = elem;
803
- const { background = "#000000", borderColor = "#000000", borderWidth: borderWidth2 = 0 } = detail;
804
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
805
- const { x: x2, y: y2, w: w2, h: h2 } = (calculator == null ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, viewScaleInfo, viewSizeInfo)) || elem;
1376
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1377
+ const { background = "#000000", borderColor = "#000000", boxSizing, borderWidth: borderWidth2 = 0, borderDash } = detail;
1378
+ let bw = 0;
1379
+ if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
1380
+ bw = borderWidth2;
1381
+ } else if (Array.isArray(borderWidth2) && typeof borderWidth2[0] === "number" && borderWidth2[0] > 0) {
1382
+ bw = borderWidth2[0];
1383
+ }
1384
+ bw = bw * viewScaleInfo.scale;
1385
+ const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, { viewScaleInfo }) || elem;
806
1386
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
807
1387
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
808
1388
  drawBoxShadow(ctx, viewElem, {
809
1389
  viewScaleInfo,
810
- viewSizeInfo,
811
1390
  renderContent: () => {
812
- var _a, _b;
813
- const a = w2 / 2;
814
- const b = h2 / 2;
1391
+ let a = w2 / 2;
1392
+ let b = h2 / 2;
815
1393
  const centerX = x2 + a;
816
1394
  const centerY = y2 + b;
817
- if (((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.opacity) !== void 0 && ((_b = elem == null ? void 0 : elem.detail) == null ? void 0 : _b.opacity) >= 0) {
818
- ctx.globalAlpha = elem.detail.opacity;
819
- } else {
820
- ctx.globalAlpha = 1;
1395
+ const radiusA = a;
1396
+ const radiusB = b;
1397
+ if (bw > 0) {
1398
+ if (boxSizing === "content-box") ;
1399
+ else if (boxSizing === "center-line") {
1400
+ a = a - bw / 2;
1401
+ b = b - bw / 2;
1402
+ } else {
1403
+ a = a - bw;
1404
+ b = b - bw;
1405
+ }
821
1406
  }
822
- if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
823
- const ba = borderWidth2 / 2 + a;
824
- const bb = borderWidth2 / 2 + b;
1407
+ if (a >= 0 && b >= 0) {
1408
+ const opacity = getOpacity(viewElem) * parentOpacity;
1409
+ ctx.globalAlpha = opacity;
825
1410
  ctx.beginPath();
826
- ctx.strokeStyle = borderColor;
827
- ctx.lineWidth = borderWidth2;
828
- ctx.circle(centerX, centerY, ba, bb, 0, 0, 2 * Math.PI);
1411
+ const fillStyle = createColorStyle(ctx, background, {
1412
+ viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
1413
+ viewScaleInfo,
1414
+ opacity: ctx.globalAlpha
1415
+ });
1416
+ ctx.fillStyle = fillStyle;
1417
+ ctx.circle(centerX, centerY, radiusA, radiusB, 0, 0, 2 * Math.PI);
829
1418
  ctx.closePath();
830
- ctx.stroke();
1419
+ ctx.fill();
1420
+ ctx.globalAlpha = parentOpacity;
1421
+ if (typeof bw === "number" && bw > 0) {
1422
+ const ba = bw / 2 + a;
1423
+ const bb = bw / 2 + b;
1424
+ ctx.beginPath();
1425
+ if (borderDash) {
1426
+ const lineDash = borderDash.map((n) => n * viewScaleInfo.scale);
1427
+ ctx.setLineDash(lineDash);
1428
+ }
1429
+ ctx.strokeStyle = borderColor;
1430
+ ctx.lineWidth = bw;
1431
+ ctx.circle(centerX, centerY, ba, bb, 0, 0, 2 * Math.PI);
1432
+ ctx.closePath();
1433
+ ctx.stroke();
1434
+ ctx.setLineDash([]);
1435
+ }
831
1436
  }
832
- ctx.beginPath();
833
- const fillStyle = createColorStyle(ctx, background, {
834
- viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
835
- viewScaleInfo,
836
- opacity: ctx.globalAlpha
837
- });
838
- ctx.fillStyle = fillStyle;
839
- ctx.circle(centerX, centerY, a, b, 0, 0, 2 * Math.PI);
840
- ctx.closePath();
841
- ctx.fill();
842
- ctx.globalAlpha = 1;
843
1437
  }
844
1438
  });
845
1439
  });
846
1440
  }
847
1441
  function drawRect(ctx, elem, opts) {
848
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
849
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1442
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1443
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
850
1444
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
851
1445
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
852
1446
  drawBoxShadow(ctx, viewElem, {
853
1447
  viewScaleInfo,
854
- viewSizeInfo,
855
1448
  renderContent: () => {
856
1449
  drawBox(ctx, viewElem, {
857
1450
  originElem: elem,
858
1451
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
859
1452
  viewScaleInfo,
860
1453
  viewSizeInfo,
1454
+ parentOpacity,
861
1455
  renderContent: () => {
862
1456
  }
863
1457
  });
@@ -867,30 +1461,32 @@ var __privateMethod = (obj, member, method) => {
867
1461
  }
868
1462
  function drawImage(ctx, elem, opts) {
869
1463
  const content = opts.loader.getContent(elem);
870
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
871
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1464
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1465
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
872
1466
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
873
1467
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
874
1468
  drawBoxShadow(ctx, viewElem, {
875
1469
  viewScaleInfo,
876
- viewSizeInfo,
877
1470
  renderContent: () => {
878
1471
  drawBox(ctx, viewElem, {
879
1472
  originElem: elem,
880
1473
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
881
1474
  viewScaleInfo,
882
1475
  viewSizeInfo,
1476
+ parentOpacity,
883
1477
  renderContent: () => {
884
- if (!content) {
1478
+ if (!content && !opts.loader.isDestroyed()) {
885
1479
  opts.loader.load(elem, opts.elementAssets || {});
886
1480
  }
887
1481
  if (elem.type === "image" && content) {
888
- const { opacity } = elem.detail;
889
- ctx.globalAlpha = opacity ? opacity : 1;
1482
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
890
1483
  const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
891
- viewScaleInfo,
892
- viewSizeInfo
1484
+ viewScaleInfo
893
1485
  });
1486
+ const { detail } = elem;
1487
+ const { scaleMode, originW = 0, originH = 0 } = detail;
1488
+ const imageW = ctx.$undoPixelRatio(originW);
1489
+ const imageH = ctx.$undoPixelRatio(originH);
894
1490
  ctx.save();
895
1491
  ctx.fillStyle = "transparent";
896
1492
  ctx.beginPath();
@@ -902,8 +1498,42 @@ var __privateMethod = (obj, member, method) => {
902
1498
  ctx.closePath();
903
1499
  ctx.fill();
904
1500
  ctx.clip();
905
- ctx.drawImage(content, x22, y22, w22, h22);
906
- ctx.globalAlpha = 1;
1501
+ if (scaleMode && originH && originW) {
1502
+ let sx = 0;
1503
+ let sy = 0;
1504
+ let sWidth = imageW;
1505
+ let sHeight = imageH;
1506
+ const dx = x22;
1507
+ const dy = y22;
1508
+ const dWidth = w22;
1509
+ const dHeight = h22;
1510
+ if (imageW > elem.w || imageH > elem.h) {
1511
+ if (scaleMode === "fill") {
1512
+ const sourceScale = Math.max(elem.w / imageW, elem.h / imageH);
1513
+ const newImageWidth = imageW * sourceScale;
1514
+ const newImageHeight = imageH * sourceScale;
1515
+ sx = (newImageWidth - elem.w) / 2 / sourceScale;
1516
+ sy = (newImageHeight - elem.h) / 2 / sourceScale;
1517
+ sWidth = elem.w / sourceScale;
1518
+ sHeight = elem.h / sourceScale;
1519
+ } else if (scaleMode === "tile") {
1520
+ sx = 0;
1521
+ sy = 0;
1522
+ sWidth = elem.w;
1523
+ sHeight = elem.h;
1524
+ } else if (scaleMode === "fit") {
1525
+ const sourceScale = Math.min(elem.w / imageW, elem.h / imageH);
1526
+ sx = (imageW - elem.w / sourceScale) / 2;
1527
+ sy = (imageH - elem.h / sourceScale) / 2;
1528
+ sWidth = elem.w / sourceScale;
1529
+ sHeight = elem.h / sourceScale;
1530
+ }
1531
+ }
1532
+ ctx.drawImage(content, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
1533
+ } else {
1534
+ ctx.drawImage(content, x22, y22, w22, h22);
1535
+ }
1536
+ ctx.globalAlpha = parentOpacity;
907
1537
  ctx.restore();
908
1538
  }
909
1539
  }
@@ -914,115 +1544,73 @@ var __privateMethod = (obj, member, method) => {
914
1544
  }
915
1545
  function drawSVG(ctx, elem, opts) {
916
1546
  const content = opts.loader.getContent(elem);
917
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
918
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1547
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1548
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
919
1549
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
920
- if (!content) {
1550
+ if (!content && !opts.loader.isDestroyed()) {
921
1551
  opts.loader.load(elem, opts.elementAssets || {});
922
1552
  }
923
1553
  if (elem.type === "svg" && content) {
924
- const { opacity } = elem.detail;
925
- ctx.globalAlpha = opacity ? opacity : 1;
1554
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
926
1555
  ctx.drawImage(content, x2, y2, w2, h2);
927
- ctx.globalAlpha = 1;
1556
+ ctx.globalAlpha = parentOpacity;
928
1557
  }
929
1558
  });
930
1559
  }
931
1560
  function drawHTML(ctx, elem, opts) {
932
1561
  const content = opts.loader.getContent(elem);
933
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
934
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1562
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1563
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
935
1564
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
936
- if (!content) {
1565
+ if (!content && !opts.loader.isDestroyed()) {
937
1566
  opts.loader.load(elem, opts.elementAssets || {});
938
1567
  }
939
1568
  if (elem.type === "html" && content) {
940
- const { opacity } = elem.detail;
941
- ctx.globalAlpha = opacity ? opacity : 1;
1569
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
942
1570
  ctx.drawImage(content, x2, y2, w2, h2);
943
- ctx.globalAlpha = 1;
1571
+ ctx.globalAlpha = parentOpacity;
944
1572
  }
945
1573
  });
946
1574
  }
947
- const detailConfig = getDefaultElementDetailConfig();
1575
+ const detailConfig$1 = getDefaultElementDetailConfig();
948
1576
  function drawText(ctx, elem, opts) {
949
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
950
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1577
+ const { viewScaleInfo, viewSizeInfo, parentOpacity, calculator } = opts;
1578
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
951
1579
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
952
1580
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
953
- drawBox(ctx, viewElem, {
954
- originElem: elem,
955
- calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
1581
+ var _a, _b;
1582
+ drawBoxShadow(ctx, viewElem, {
956
1583
  viewScaleInfo,
957
- viewSizeInfo,
958
1584
  renderContent: () => {
959
- const detail = {
960
- ...detailConfig,
961
- ...elem.detail
962
- };
963
- const fontSize2 = (detail.fontSize || detailConfig.fontSize) * viewScaleInfo.scale;
964
- const lineHeight2 = detail.lineHeight ? detail.lineHeight * viewScaleInfo.scale : fontSize2;
965
- ctx.fillStyle = elem.detail.color || detailConfig.color;
966
- ctx.textBaseline = "top";
967
- ctx.$setFont({
968
- fontWeight: detail.fontWeight,
969
- fontSize: fontSize2,
970
- fontFamily: detail.fontFamily
971
- });
972
- const detailText = detail.text.replace(/\r\n/gi, "\n");
973
- const fontHeight = lineHeight2;
974
- const detailTextList = detailText.split("\n");
975
- const lines = [];
976
- let lineNum = 0;
977
- detailTextList.forEach((tempText, idx) => {
978
- let lineText = "";
979
- if (tempText.length > 0) {
980
- for (let i = 0; i < tempText.length; i++) {
981
- if (ctx.measureText(lineText + (tempText[i] || "")).width < ctx.$doPixelRatio(w2)) {
982
- lineText += tempText[i] || "";
983
- } else {
984
- lines.push({
985
- text: lineText,
986
- width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
987
- });
988
- lineText = tempText[i] || "";
989
- lineNum++;
990
- }
991
- if ((lineNum + 1) * fontHeight > h2) {
992
- break;
993
- }
994
- if (tempText.length - 1 === i) {
995
- if ((lineNum + 1) * fontHeight < h2) {
996
- lines.push({
997
- text: lineText,
998
- width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
999
- });
1000
- if (idx < detailTextList.length - 1) {
1001
- lineNum++;
1002
- }
1003
- break;
1004
- }
1005
- }
1006
- }
1007
- } else {
1008
- lines.push({
1009
- text: "",
1010
- width: 0
1011
- });
1012
- }
1585
+ drawBox(ctx, viewElem, {
1586
+ originElem: elem,
1587
+ calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
1588
+ viewScaleInfo,
1589
+ viewSizeInfo,
1590
+ parentOpacity
1013
1591
  });
1014
- let startY = 0;
1015
- if (lines.length * fontHeight < h2) {
1016
- if (elem.detail.verticalAlign === "top") {
1017
- startY = 0;
1018
- } else if (elem.detail.verticalAlign === "bottom") {
1019
- startY += h2 - lines.length * fontHeight;
1020
- } else {
1021
- startY += (h2 - lines.length * fontHeight) / 2;
1022
- }
1023
- }
1024
- {
1025
- const _y = y2 + startY;
1592
+ }
1593
+ });
1594
+ {
1595
+ const detail = {
1596
+ ...detailConfig$1,
1597
+ ...elem.detail
1598
+ };
1599
+ const originFontSize = detail.fontSize || detailConfig$1.fontSize;
1600
+ const fontSize2 = originFontSize * viewScaleInfo.scale;
1601
+ if (fontSize2 < 2) {
1602
+ return;
1603
+ }
1604
+ ctx.fillStyle = elem.detail.color || detailConfig$1.color;
1605
+ ctx.textBaseline = "top";
1606
+ ctx.$setFont({
1607
+ fontWeight: detail.fontWeight,
1608
+ fontSize: fontSize2,
1609
+ fontFamily: enhanceFontFamliy(detail.fontFamily)
1610
+ });
1611
+ {
1612
+ const virtualTextDetail = calculator.getVirtualFlatItem(elem.uuid);
1613
+ if (Array.isArray(virtualTextDetail == null ? void 0 : virtualTextDetail.textLines) && ((_a = virtualTextDetail == null ? void 0 : virtualTextDetail.textLines) == null ? void 0 : _a.length) > 0) {
1026
1614
  if (detail.textShadowColor !== void 0 && isColorStr(detail.textShadowColor)) {
1027
1615
  ctx.shadowColor = detail.textShadowColor;
1028
1616
  }
@@ -1035,43 +1623,64 @@ var __privateMethod = (obj, member, method) => {
1035
1623
  if (detail.textShadowBlur !== void 0 && is.number(detail.textShadowBlur)) {
1036
1624
  ctx.shadowBlur = detail.textShadowBlur;
1037
1625
  }
1038
- lines.forEach((line, i) => {
1039
- let _x = x2;
1040
- if (detail.textAlign === "center") {
1041
- _x = x2 + (w2 - line.width) / 2;
1042
- } else if (detail.textAlign === "right") {
1043
- _x = x2 + (w2 - line.width);
1044
- }
1045
- ctx.fillText(line.text, _x, _y + fontHeight * i);
1626
+ (_b = virtualTextDetail == null ? void 0 : virtualTextDetail.textLines) == null ? void 0 : _b.forEach((line) => {
1627
+ ctx.fillText(line.text, x2 + line.x * viewScaleInfo.scale, y2 + line.y * viewScaleInfo.scale);
1046
1628
  });
1047
1629
  }
1048
1630
  }
1049
- });
1631
+ }
1050
1632
  });
1051
1633
  }
1052
1634
  function drawPath(ctx, elem, opts) {
1635
+ var _a, _b;
1053
1636
  const { detail } = elem;
1054
- const { originX, originY, originW, originH } = detail;
1055
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
1056
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1637
+ const { originX, originY, originW, originH, fillRule } = detail;
1638
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1639
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
1057
1640
  const scaleW = w2 / originW;
1058
1641
  const scaleH = h2 / originH;
1059
1642
  const viewOriginX = originX * scaleW;
1060
1643
  const viewOriginY = originY * scaleH;
1061
1644
  const internalX = x2 - viewOriginX;
1062
1645
  const internalY = y2 - viewOriginY;
1646
+ const { clipPath, clipPathStrokeColor, clipPathStrokeWidth, ...restDetail } = elem.detail;
1063
1647
  const scaleNum = viewScaleInfo.scale * viewSizeInfo.devicePixelRatio;
1064
1648
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
1649
+ let boxViewElem = { ...viewElem };
1650
+ boxViewElem.detail = restDetail;
1651
+ let boxOriginElem = { ...elem };
1652
+ boxOriginElem.detail = restDetail;
1653
+ if (detail.fill && detail.fill !== "string" && ((_b = (_a = detail.fill) == null ? void 0 : _a.type) == null ? void 0 : _b.includes("gradient"))) {
1654
+ boxViewElem = {
1655
+ ...viewElem,
1656
+ ...{
1657
+ detail: {
1658
+ ...viewElem.detail,
1659
+ ...{
1660
+ background: detail.fill,
1661
+ clipPath: {
1662
+ commands: detail.commands,
1663
+ originX,
1664
+ originY,
1665
+ originW,
1666
+ originH
1667
+ }
1668
+ }
1669
+ }
1670
+ }
1671
+ };
1672
+ boxOriginElem.detail = { ...boxViewElem.detail };
1673
+ }
1065
1674
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1066
- drawBox(ctx, viewElem, {
1067
- originElem: elem,
1675
+ drawBox(ctx, boxViewElem, {
1676
+ originElem: boxOriginElem,
1068
1677
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
1069
1678
  viewScaleInfo,
1070
1679
  viewSizeInfo,
1680
+ parentOpacity,
1071
1681
  renderContent: () => {
1072
1682
  drawBoxShadow(ctx, viewElem, {
1073
1683
  viewScaleInfo,
1074
- viewSizeInfo,
1075
1684
  renderContent: () => {
1076
1685
  ctx.save();
1077
1686
  ctx.translate(internalX, internalY);
@@ -1079,8 +1688,14 @@ var __privateMethod = (obj, member, method) => {
1079
1688
  const pathStr = generateSVGPath(detail.commands || []);
1080
1689
  const path2d = new Path2D(pathStr);
1081
1690
  if (detail.fill) {
1082
- ctx.fillStyle = detail.fill;
1083
- ctx.fill(path2d);
1691
+ if (typeof detail.fill === "string") {
1692
+ ctx.fillStyle = detail.fill;
1693
+ } else {
1694
+ ctx.fillStyle = "transparent";
1695
+ }
1696
+ }
1697
+ if (detail.fill) {
1698
+ ctx.fill(path2d, fillRule);
1084
1699
  }
1085
1700
  if (detail.stroke && detail.strokeWidth !== 0) {
1086
1701
  ctx.strokeStyle = detail.stroke;
@@ -1096,11 +1711,21 @@ var __privateMethod = (obj, member, method) => {
1096
1711
  });
1097
1712
  });
1098
1713
  }
1714
+ const visiableMinSize = 0.4;
1099
1715
  function drawElement(ctx, elem, opts) {
1100
- var _a;
1716
+ var _a, _b, _c;
1101
1717
  if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.invisible) === true) {
1102
1718
  return;
1103
1719
  }
1720
+ const { w: w2, h: h2 } = elem;
1721
+ const { scale } = opts.viewScaleInfo;
1722
+ if (scale < 1 && (w2 * scale < visiableMinSize || h2 * scale < visiableMinSize) || opts.parentOpacity === 0) {
1723
+ return;
1724
+ }
1725
+ const { overrideElementMap } = opts;
1726
+ if ((_c = (_b = overrideElementMap == null ? void 0 : overrideElementMap[elem.uuid]) == null ? void 0 : _b.operations) == null ? void 0 : _c.invisible) {
1727
+ return;
1728
+ }
1104
1729
  try {
1105
1730
  switch (elem.type) {
1106
1731
  case "rect": {
@@ -1151,23 +1776,23 @@ var __privateMethod = (obj, member, method) => {
1151
1776
  }
1152
1777
  }
1153
1778
  function drawGroup(ctx, elem, opts) {
1154
- const { calculator, viewScaleInfo, viewSizeInfo } = opts;
1155
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo)) || elem;
1779
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1780
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, { viewScaleInfo }) || elem;
1156
1781
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
1157
1782
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1783
+ ctx.globalAlpha = getOpacity(elem) * parentOpacity;
1158
1784
  drawBoxShadow(ctx, viewElem, {
1159
1785
  viewScaleInfo,
1160
- viewSizeInfo,
1161
1786
  renderContent: () => {
1162
1787
  drawBox(ctx, viewElem, {
1163
1788
  originElem: elem,
1164
1789
  calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
1165
1790
  viewScaleInfo,
1166
1791
  viewSizeInfo,
1792
+ parentOpacity,
1167
1793
  renderContent: () => {
1168
1794
  const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
1169
- viewScaleInfo,
1170
- viewSizeInfo
1795
+ viewScaleInfo
1171
1796
  });
1172
1797
  if (elem.detail.overflow === "hidden") {
1173
1798
  ctx.save();
@@ -1191,7 +1816,7 @@ var __privateMethod = (obj, member, method) => {
1191
1816
  h: elem.h || parentSize.h,
1192
1817
  angle: elem.angle
1193
1818
  };
1194
- const { calculator: calculator2 } = opts;
1819
+ const { calculator } = opts;
1195
1820
  for (let i = 0; i < elem.detail.children.length; i++) {
1196
1821
  let child = elem.detail.children[i];
1197
1822
  child = {
@@ -1202,31 +1827,32 @@ var __privateMethod = (obj, member, method) => {
1202
1827
  }
1203
1828
  };
1204
1829
  if (opts.forceDrawAll !== true) {
1205
- if (!(calculator2 == null ? void 0 : calculator2.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo))) {
1830
+ if (!(calculator == null ? void 0 : calculator.needRender(child))) {
1206
1831
  continue;
1207
1832
  }
1208
1833
  }
1209
1834
  try {
1210
- drawElement(ctx, child, { ...opts });
1835
+ drawElement(ctx, child, { ...opts, ...{ parentOpacity: parentOpacity * getOpacity(elem) } });
1211
1836
  } catch (err) {
1212
1837
  console.error(err);
1213
1838
  }
1214
1839
  }
1215
1840
  }
1216
1841
  if (elem.detail.overflow === "hidden") {
1217
- ctx.globalAlpha = 1;
1218
1842
  ctx.restore();
1219
1843
  }
1220
1844
  }
1221
1845
  });
1222
1846
  }
1223
1847
  });
1848
+ ctx.globalAlpha = parentOpacity;
1224
1849
  });
1225
1850
  }
1226
1851
  const defaultDetail = getDefaultElementDetailConfig();
1227
1852
  function drawElementList(ctx, data, opts) {
1228
1853
  var _a;
1229
1854
  const { elements = [] } = data;
1855
+ const { parentOpacity } = opts;
1230
1856
  for (let i = 0; i < elements.length; i++) {
1231
1857
  const element = elements[i];
1232
1858
  const elem = {
@@ -1239,17 +1865,71 @@ var __privateMethod = (obj, member, method) => {
1239
1865
  }
1240
1866
  };
1241
1867
  if (opts.forceDrawAll !== true) {
1242
- if (!((_a = opts.calculator) == null ? void 0 : _a.isElementInView(elem, opts.viewScaleInfo, opts.viewSizeInfo))) {
1868
+ if (!((_a = opts.calculator) == null ? void 0 : _a.needRender(elem))) {
1243
1869
  continue;
1244
1870
  }
1245
1871
  }
1246
1872
  try {
1247
- drawElement(ctx, elem, opts);
1873
+ drawElement(ctx, elem, {
1874
+ ...opts,
1875
+ ...{
1876
+ parentOpacity
1877
+ }
1878
+ });
1248
1879
  } catch (err) {
1249
1880
  console.error(err);
1250
1881
  }
1251
1882
  }
1252
1883
  }
1884
+ function drawLayout(ctx, layout, opts, renderContent) {
1885
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1886
+ const elem = { uuid: "layout", type: "group", ...layout };
1887
+ const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
1888
+ const angle2 = 0;
1889
+ const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
1890
+ ctx.globalAlpha = 1;
1891
+ drawBoxShadow(ctx, viewElem, {
1892
+ viewScaleInfo,
1893
+ renderContent: () => {
1894
+ drawBoxBackground(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
1895
+ }
1896
+ });
1897
+ if (layout.detail.overflow === "hidden") {
1898
+ const { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 } = opts;
1899
+ const elem2 = { uuid: "layout", type: "group", ...layout };
1900
+ const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2 }) || elem2;
1901
+ const viewElem2 = { ...elem2, ...viewElemSize };
1902
+ const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem2, {
1903
+ viewScaleInfo: viewScaleInfo2
1904
+ });
1905
+ ctx.save();
1906
+ ctx.fillStyle = "transparent";
1907
+ ctx.beginPath();
1908
+ ctx.moveTo(x22 + radiusList[0], y22);
1909
+ ctx.arcTo(x22 + w22, y22, x22 + w22, y22 + h22, radiusList[1]);
1910
+ ctx.arcTo(x22 + w22, y22 + h22, x22, y22 + h22, radiusList[2]);
1911
+ ctx.arcTo(x22, y22 + h22, x22, y22, radiusList[3]);
1912
+ ctx.arcTo(x22, y22, x22 + w22, y22, radiusList[0]);
1913
+ ctx.closePath();
1914
+ ctx.fill();
1915
+ ctx.clip();
1916
+ }
1917
+ renderContent(ctx);
1918
+ if (layout.detail.overflow === "hidden") {
1919
+ ctx.restore();
1920
+ }
1921
+ drawBoxBorder(ctx, viewElem, { viewScaleInfo });
1922
+ ctx.globalAlpha = parentOpacity;
1923
+ }
1924
+ function drawGlobalBackground(ctx, global, opts) {
1925
+ if (typeof (global == null ? void 0 : global.background) === "string") {
1926
+ const { viewSizeInfo } = opts;
1927
+ const { width, height } = viewSizeInfo;
1928
+ ctx.globalAlpha = 1;
1929
+ ctx.fillStyle = global.background;
1930
+ ctx.fillRect(0, 0, width, height);
1931
+ }
1932
+ }
1253
1933
  const supportElementTypes = ["image", "svg", "html"];
1254
1934
  const getAssetIdFromElement = (element) => {
1255
1935
  var _a, _b, _c;
@@ -1272,17 +1952,12 @@ var __privateMethod = (obj, member, method) => {
1272
1952
  class Loader extends EventEmitter {
1273
1953
  constructor() {
1274
1954
  super();
1275
- __privateAdd(this, _registerLoadFunc);
1276
- __privateAdd(this, _getLoadElementSource);
1277
- __privateAdd(this, _createLoadItem);
1278
- __privateAdd(this, _emitLoad);
1279
- __privateAdd(this, _emitError);
1280
- __privateAdd(this, _loadResource);
1281
- __privateAdd(this, _isExistingErrorStorage);
1955
+ __privateAdd(this, _Loader_instances);
1282
1956
  __privateAdd(this, _loadFuncMap, {});
1283
1957
  __privateAdd(this, _currentLoadItemMap, {});
1284
1958
  __privateAdd(this, _storageLoadItemMap, {});
1285
- __privateMethod(this, _registerLoadFunc, registerLoadFunc_fn).call(this, "image", async (elem, assets) => {
1959
+ __privateAdd(this, _hasDestroyed, false);
1960
+ __privateMethod(this, _Loader_instances, registerLoadFunc_fn).call(this, "image", async (elem, assets) => {
1286
1961
  var _a;
1287
1962
  const src = ((_a = assets[elem.detail.src]) == null ? void 0 : _a.value) || elem.detail.src;
1288
1963
  const content = await loadImage(src);
@@ -1292,12 +1967,12 @@ var __privateMethod = (obj, member, method) => {
1292
1967
  content
1293
1968
  };
1294
1969
  });
1295
- __privateMethod(this, _registerLoadFunc, registerLoadFunc_fn).call(this, "html", async (elem, assets) => {
1970
+ __privateMethod(this, _Loader_instances, registerLoadFunc_fn).call(this, "html", async (elem, assets) => {
1296
1971
  var _a;
1297
1972
  const html2 = ((_a = assets[elem.detail.html]) == null ? void 0 : _a.value) || elem.detail.html;
1298
1973
  const content = await loadHTML(html2, {
1299
- width: elem.detail.width || elem.w,
1300
- height: elem.detail.height || elem.h
1974
+ width: elem.detail.originW || elem.w,
1975
+ height: elem.detail.originH || elem.h
1301
1976
  });
1302
1977
  return {
1303
1978
  uuid: elem.uuid,
@@ -1305,7 +1980,7 @@ var __privateMethod = (obj, member, method) => {
1305
1980
  content
1306
1981
  };
1307
1982
  });
1308
- __privateMethod(this, _registerLoadFunc, registerLoadFunc_fn).call(this, "svg", async (elem, assets) => {
1983
+ __privateMethod(this, _Loader_instances, registerLoadFunc_fn).call(this, "svg", async (elem, assets) => {
1309
1984
  var _a;
1310
1985
  const svg2 = ((_a = assets[elem.detail.svg]) == null ? void 0 : _a.value) || elem.detail.svg;
1311
1986
  const content = await loadSVG(svg2);
@@ -1316,12 +1991,25 @@ var __privateMethod = (obj, member, method) => {
1316
1991
  };
1317
1992
  });
1318
1993
  }
1994
+ isDestroyed() {
1995
+ return __privateGet(this, _hasDestroyed);
1996
+ }
1997
+ destroy() {
1998
+ __privateSet(this, _hasDestroyed, true);
1999
+ this.clear();
2000
+ __privateSet(this, _loadFuncMap, null);
2001
+ __privateSet(this, _currentLoadItemMap, null);
2002
+ __privateSet(this, _storageLoadItemMap, null);
2003
+ }
1319
2004
  load(element, assets) {
1320
- if (__privateMethod(this, _isExistingErrorStorage, isExistingErrorStorage_fn).call(this, element)) {
2005
+ if (__privateGet(this, _hasDestroyed) === true) {
2006
+ return;
2007
+ }
2008
+ if (__privateMethod(this, _Loader_instances, isExistingErrorStorage_fn).call(this, element)) {
1321
2009
  return;
1322
2010
  }
1323
2011
  if (supportElementTypes.includes(element.type)) {
1324
- __privateMethod(this, _loadResource, loadResource_fn).call(this, element, assets);
2012
+ __privateMethod(this, _Loader_instances, loadResource_fn).call(this, element, assets);
1325
2013
  }
1326
2014
  }
1327
2015
  getContent(element) {
@@ -1339,11 +2027,11 @@ var __privateMethod = (obj, member, method) => {
1339
2027
  _loadFuncMap = new WeakMap();
1340
2028
  _currentLoadItemMap = new WeakMap();
1341
2029
  _storageLoadItemMap = new WeakMap();
1342
- _registerLoadFunc = new WeakSet();
2030
+ _hasDestroyed = new WeakMap();
2031
+ _Loader_instances = new WeakSet();
1343
2032
  registerLoadFunc_fn = function(type, func) {
1344
2033
  __privateGet(this, _loadFuncMap)[type] = func;
1345
2034
  };
1346
- _getLoadElementSource = new WeakSet();
1347
2035
  getLoadElementSource_fn = function(element) {
1348
2036
  var _a, _b, _c;
1349
2037
  let source = null;
@@ -1356,7 +2044,6 @@ var __privateMethod = (obj, member, method) => {
1356
2044
  }
1357
2045
  return source;
1358
2046
  };
1359
- _createLoadItem = new WeakSet();
1360
2047
  createLoadItem_fn = function(element) {
1361
2048
  return {
1362
2049
  element,
@@ -1365,88 +2052,521 @@ var __privateMethod = (obj, member, method) => {
1365
2052
  error: null,
1366
2053
  startTime: -1,
1367
2054
  endTime: -1,
1368
- source: __privateMethod(this, _getLoadElementSource, getLoadElementSource_fn).call(this, element)
2055
+ source: __privateMethod(this, _Loader_instances, getLoadElementSource_fn).call(this, element)
1369
2056
  };
1370
2057
  };
1371
- _emitLoad = new WeakSet();
1372
2058
  emitLoad_fn = function(item) {
1373
2059
  const assetId = getAssetIdFromElement(item.element);
1374
2060
  const storageItem = __privateGet(this, _storageLoadItemMap)[assetId];
1375
- if (storageItem) {
1376
- if (storageItem.startTime < item.startTime) {
2061
+ if (!__privateGet(this, _hasDestroyed)) {
2062
+ if (storageItem) {
2063
+ if (storageItem.startTime < item.startTime) {
2064
+ __privateGet(this, _storageLoadItemMap)[assetId] = item;
2065
+ this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
2066
+ }
2067
+ } else {
1377
2068
  __privateGet(this, _storageLoadItemMap)[assetId] = item;
1378
2069
  this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
1379
2070
  }
1380
- } else {
1381
- __privateGet(this, _storageLoadItemMap)[assetId] = item;
1382
- this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
1383
2071
  }
1384
2072
  };
1385
- _emitError = new WeakSet();
1386
2073
  emitError_fn = function(item) {
2074
+ var _a;
1387
2075
  const assetId = getAssetIdFromElement(item.element);
1388
- const storageItem = __privateGet(this, _storageLoadItemMap)[assetId];
1389
- if (storageItem) {
1390
- if (storageItem.startTime < item.startTime) {
2076
+ const storageItem = (_a = __privateGet(this, _storageLoadItemMap)) == null ? void 0 : _a[assetId];
2077
+ if (!__privateGet(this, _hasDestroyed)) {
2078
+ if (storageItem) {
2079
+ if (storageItem.startTime < item.startTime) {
2080
+ __privateGet(this, _storageLoadItemMap)[assetId] = item;
2081
+ this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
2082
+ }
2083
+ } else {
1391
2084
  __privateGet(this, _storageLoadItemMap)[assetId] = item;
1392
2085
  this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
1393
2086
  }
1394
- } else {
1395
- __privateGet(this, _storageLoadItemMap)[assetId] = item;
1396
- this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
1397
2087
  }
1398
2088
  };
1399
- _loadResource = new WeakSet();
1400
2089
  loadResource_fn = function(element, assets) {
1401
- const item = __privateMethod(this, _createLoadItem, createLoadItem_fn).call(this, element);
2090
+ const item = __privateMethod(this, _Loader_instances, createLoadItem_fn).call(this, element);
1402
2091
  const assetId = getAssetIdFromElement(element);
2092
+ if (__privateGet(this, _currentLoadItemMap)[assetId]) {
2093
+ return;
2094
+ }
1403
2095
  __privateGet(this, _currentLoadItemMap)[assetId] = item;
1404
2096
  const loadFunc = __privateGet(this, _loadFuncMap)[element.type];
1405
- if (typeof loadFunc === "function") {
2097
+ if (typeof loadFunc === "function" && !__privateGet(this, _hasDestroyed)) {
1406
2098
  item.startTime = Date.now();
1407
2099
  loadFunc(element, assets).then((result) => {
1408
- item.content = result.content;
1409
- item.endTime = Date.now();
1410
- item.status = "load";
1411
- __privateMethod(this, _emitLoad, emitLoad_fn).call(this, item);
2100
+ if (!__privateGet(this, _hasDestroyed)) {
2101
+ item.content = result.content;
2102
+ item.endTime = Date.now();
2103
+ item.status = "load";
2104
+ __privateMethod(this, _Loader_instances, emitLoad_fn).call(this, item);
2105
+ }
1412
2106
  }).catch((err) => {
1413
2107
  console.warn(`Load element source "${item.source}" fail`, err, element);
1414
2108
  item.endTime = Date.now();
1415
2109
  item.status = "error";
1416
2110
  item.error = err;
1417
- __privateMethod(this, _emitError, emitError_fn).call(this, item);
2111
+ __privateMethod(this, _Loader_instances, emitError_fn).call(this, item);
1418
2112
  });
1419
2113
  }
1420
2114
  };
1421
- _isExistingErrorStorage = new WeakSet();
1422
2115
  isExistingErrorStorage_fn = function(element) {
1423
2116
  var _a;
1424
2117
  const assetId = getAssetIdFromElement(element);
1425
2118
  const existItem = (_a = __privateGet(this, _currentLoadItemMap)) == null ? void 0 : _a[assetId];
1426
- if (existItem && existItem.status === "error" && existItem.source && existItem.source === __privateMethod(this, _getLoadElementSource, getLoadElementSource_fn).call(this, element)) {
2119
+ if (existItem && existItem.status === "error" && existItem.source && existItem.source === __privateMethod(this, _Loader_instances, getLoadElementSource_fn).call(this, element)) {
1427
2120
  return true;
1428
2121
  }
1429
2122
  return false;
1430
2123
  };
2124
+ const detailConfig = getDefaultElementDetailConfig();
2125
+ function isTextWidthWithinErrorRange(w0, w1, scale) {
2126
+ return w0 >= w1;
2127
+ }
2128
+ function calcVirtualTextDetail(elem, opts) {
2129
+ const { w: w2, h: h2 } = elem;
2130
+ const x2 = 0;
2131
+ const y2 = 0;
2132
+ const ctx = opts.tempContext;
2133
+ const lines = [];
2134
+ const detail = {
2135
+ ...detailConfig,
2136
+ ...elem.detail
2137
+ };
2138
+ const originFontSize = detail.fontSize || detailConfig.fontSize;
2139
+ const fontSize2 = originFontSize;
2140
+ if (fontSize2 < 2) {
2141
+ return {};
2142
+ }
2143
+ const originLineHeight = detail.lineHeight || originFontSize;
2144
+ const lineHeight2 = originLineHeight;
2145
+ ctx.textBaseline = "top";
2146
+ ctx.$setFont({
2147
+ fontWeight: detail.fontWeight,
2148
+ fontSize: fontSize2,
2149
+ fontFamily: enhanceFontFamliy(detail.fontFamily)
2150
+ });
2151
+ let detailText = detail.text.replace(/\r\n/gi, "\n");
2152
+ if (detail.textTransform === "lowercase") {
2153
+ detailText = detailText.toLowerCase();
2154
+ } else if (detail.textTransform === "uppercase") {
2155
+ detailText = detailText.toUpperCase();
2156
+ }
2157
+ const fontHeight = lineHeight2;
2158
+ const detailTextList = detailText.split("\n");
2159
+ let lineNum = 0;
2160
+ detailTextList.forEach((itemText, idx) => {
2161
+ if (detail.minInlineSize === "maxContent") {
2162
+ lines.push({
2163
+ x: x2,
2164
+ y: 0,
2165
+ // TODO
2166
+ text: itemText,
2167
+ width: ctx.$undoPixelRatio(ctx.measureText(itemText).width)
2168
+ });
2169
+ } else {
2170
+ let lineText = "";
2171
+ let splitStr = "";
2172
+ let tempStrList = itemText.split(splitStr);
2173
+ if (detail.wordBreak === "normal") {
2174
+ splitStr = " ";
2175
+ const wordList = itemText.split(splitStr);
2176
+ tempStrList = [];
2177
+ wordList.forEach((word, idx2) => {
2178
+ tempStrList.push(word);
2179
+ if (idx2 < wordList.length - 1) {
2180
+ tempStrList.push(splitStr);
2181
+ }
2182
+ });
2183
+ }
2184
+ if (tempStrList.length === 1 && detail.overflow === "visible") {
2185
+ lines.push({
2186
+ x: x2,
2187
+ y: 0,
2188
+ // TODO
2189
+ text: tempStrList[0],
2190
+ width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
2191
+ });
2192
+ } else if (tempStrList.length > 0) {
2193
+ for (let i = 0; i < tempStrList.length; i++) {
2194
+ if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(w2), ctx.measureText(lineText + tempStrList[i]).width)) {
2195
+ lineText += tempStrList[i] || "";
2196
+ } else {
2197
+ lines.push({
2198
+ x: x2,
2199
+ y: 0,
2200
+ // TODO
2201
+ text: lineText,
2202
+ width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
2203
+ });
2204
+ lineText = tempStrList[i] || "";
2205
+ lineNum++;
2206
+ }
2207
+ if ((lineNum + 1) * fontHeight > h2 && detail.overflow === "hidden") {
2208
+ break;
2209
+ }
2210
+ if (tempStrList.length - 1 === i) {
2211
+ if ((lineNum + 1) * fontHeight <= h2) {
2212
+ lines.push({
2213
+ x: x2,
2214
+ y: 0,
2215
+ // TODO
2216
+ text: lineText,
2217
+ width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
2218
+ });
2219
+ if (idx < detailTextList.length - 1) {
2220
+ lineNum++;
2221
+ }
2222
+ break;
2223
+ }
2224
+ }
2225
+ }
2226
+ } else {
2227
+ lines.push({
2228
+ x: x2,
2229
+ y: 0,
2230
+ // TODO
2231
+ text: "",
2232
+ width: 0
2233
+ });
2234
+ }
2235
+ }
2236
+ });
2237
+ let startY = 0;
2238
+ let eachLineStartY = 0;
2239
+ if (fontHeight > fontSize2) {
2240
+ eachLineStartY = (fontHeight - fontSize2) / 2;
2241
+ }
2242
+ if (lines.length * fontHeight < h2) {
2243
+ if (elem.detail.verticalAlign === "top") {
2244
+ startY = 0;
2245
+ } else if (elem.detail.verticalAlign === "bottom") {
2246
+ startY += h2 - lines.length * fontHeight;
2247
+ } else {
2248
+ startY += (h2 - lines.length * fontHeight) / 2;
2249
+ }
2250
+ }
2251
+ {
2252
+ const _y = y2 + startY;
2253
+ lines.forEach((line, i) => {
2254
+ let _x = x2;
2255
+ if (detail.textAlign === "center") {
2256
+ _x = x2 + (w2 - line.width) / 2;
2257
+ } else if (detail.textAlign === "right") {
2258
+ _x = x2 + (w2 - line.width);
2259
+ }
2260
+ lines[i].x = _x;
2261
+ lines[i].y = _y + fontHeight * i + eachLineStartY;
2262
+ });
2263
+ }
2264
+ const virtualTextDetail = {
2265
+ textLines: lines
2266
+ };
2267
+ return virtualTextDetail;
2268
+ }
2269
+ function calcVirtualFlatDetail(elem, opts) {
2270
+ let virtualDetail = {};
2271
+ if (elem.type === "text") {
2272
+ virtualDetail = calcVirtualTextDetail(elem, opts);
2273
+ }
2274
+ return virtualDetail;
2275
+ }
2276
+ function elementsToVirtualFlatMap(elements, opts) {
2277
+ const virtualFlatMap = {};
2278
+ const currentPosition = [];
2279
+ const _walk = (elem) => {
2280
+ const baseInfo = {
2281
+ type: elem.type,
2282
+ isVisibleInView: true,
2283
+ position: [...currentPosition]
2284
+ };
2285
+ let originRectInfo = null;
2286
+ const groupQueue = getGroupQueueByElementPosition(elements, currentPosition);
2287
+ originRectInfo = calcElementOriginRectInfo(elem, {
2288
+ groupQueue: groupQueue || []
2289
+ });
2290
+ const virtualItem = {
2291
+ ...baseInfo,
2292
+ ...{
2293
+ originRectInfo,
2294
+ rangeRectInfo: is.angle(elem.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo
2295
+ },
2296
+ ...calcVirtualFlatDetail(elem, opts)
2297
+ };
2298
+ virtualFlatMap[elem.uuid] = virtualItem;
2299
+ if (elem.type === "group") {
2300
+ elem.detail.children.forEach((ele, i) => {
2301
+ currentPosition.push(i);
2302
+ _walk(ele);
2303
+ currentPosition.pop();
2304
+ });
2305
+ }
2306
+ };
2307
+ elements.forEach((elem, index) => {
2308
+ currentPosition.push(index);
2309
+ _walk(elem);
2310
+ currentPosition.pop();
2311
+ });
2312
+ return virtualFlatMap;
2313
+ }
2314
+ function sortElementsViewVisiableInfoMap(elements, opts) {
2315
+ const { viewScaleInfo, viewSizeInfo, tempContext } = opts;
2316
+ const visibleInfoMap = elementsToVirtualFlatMap(elements, { tempContext });
2317
+ return updateVirtualFlatItemMapStatus(visibleInfoMap, { viewScaleInfo, viewSizeInfo });
2318
+ }
2319
+ function isRangeRectInfoCollide(info1, info2) {
2320
+ const rect1MinX = Math.min(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
2321
+ const rect1MaxX = Math.max(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
2322
+ const rect1MinY = Math.min(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
2323
+ const rect1MaxY = Math.max(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
2324
+ const rect2MinX = Math.min(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
2325
+ const rect2MaxX = Math.max(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x);
2326
+ const rect2MinY = Math.min(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
2327
+ const rect2MaxY = Math.max(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y);
2328
+ if (rect1MinX <= rect2MaxX && rect1MaxX >= rect2MinX && rect1MinY <= rect2MaxY && rect1MaxY >= rect2MinY || rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY && rect2MaxX <= rect1MaxY && rect2MaxX >= rect1MaxY) {
2329
+ return true;
2330
+ }
2331
+ return false;
2332
+ }
2333
+ function updateVirtualFlatItemMapStatus(virtualFlatItemMap, opts) {
2334
+ const canvasRectInfo = calcVisibleOriginCanvasRectInfo(opts);
2335
+ let visibleCount = 0;
2336
+ let invisibleCount = 0;
2337
+ Object.keys(virtualFlatItemMap).forEach((uuid) => {
2338
+ const info = virtualFlatItemMap[uuid];
2339
+ info.isVisibleInView = isRangeRectInfoCollide(info.rangeRectInfo, canvasRectInfo);
2340
+ info.isVisibleInView ? visibleCount++ : invisibleCount++;
2341
+ });
2342
+ return { virtualFlatItemMap, visibleCount, invisibleCount };
2343
+ }
2344
+ function calcVisibleOriginCanvasRectInfo(opts) {
2345
+ const { viewScaleInfo, viewSizeInfo } = opts;
2346
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
2347
+ const { width, height } = viewSizeInfo;
2348
+ const x2 = 0 - offsetLeft / scale;
2349
+ const y2 = 0 - offsetTop / scale;
2350
+ const w2 = width / scale;
2351
+ const h2 = height / scale;
2352
+ const center = calcElementCenter({ x: x2, y: y2, w: w2, h: h2 });
2353
+ const topLeft = { x: x2, y: y2 };
2354
+ const topRight = { x: x2 + w2, y: y2 };
2355
+ const bottomLeft = { x: x2, y: y2 + h2 };
2356
+ const bottomRight = { x: x2 + w2, y: y2 + h2 };
2357
+ const left = { x: x2, y: center.y };
2358
+ const top = { x: center.x, y: y2 };
2359
+ const right = { x: x2 + w2, y: center.y };
2360
+ const bottom = { x: center.x, y: y2 + h2 };
2361
+ const rectInfo = {
2362
+ center,
2363
+ topLeft,
2364
+ topRight,
2365
+ bottomLeft,
2366
+ bottomRight,
2367
+ left,
2368
+ top,
2369
+ right,
2370
+ bottom
2371
+ };
2372
+ return rectInfo;
2373
+ }
2374
+ class Calculator {
2375
+ constructor(opts) {
2376
+ __privateAdd(this, _opts);
2377
+ __privateAdd(this, _store);
2378
+ __privateSet(this, _opts, opts);
2379
+ __privateSet(this, _store, new Store({
2380
+ defaultStorage: {
2381
+ virtualFlatItemMap: {},
2382
+ visibleCount: 0,
2383
+ invisibleCount: 0
2384
+ }
2385
+ }));
2386
+ }
2387
+ toGridNum(num, opts) {
2388
+ if ((opts == null ? void 0 : opts.ignore) === true) {
2389
+ return num;
2390
+ }
2391
+ return Math.round(num);
2392
+ }
2393
+ destroy() {
2394
+ __privateSet(this, _opts, null);
2395
+ }
2396
+ needRender(elem) {
2397
+ const virtualFlatItemMap = __privateGet(this, _store).get("virtualFlatItemMap");
2398
+ const info = virtualFlatItemMap[elem.uuid];
2399
+ if (!info) {
2400
+ return true;
2401
+ }
2402
+ return info.isVisibleInView;
2403
+ }
2404
+ getPointElement(p, opts) {
2405
+ const context2d = __privateGet(this, _opts).tempContext;
2406
+ return getViewPointAtElement(p, { ...opts, ...{ context2d } });
2407
+ }
2408
+ resetVirtualFlatItemMap(data, opts) {
2409
+ if (data) {
2410
+ const { virtualFlatItemMap, invisibleCount, visibleCount } = sortElementsViewVisiableInfoMap(data.elements, {
2411
+ ...opts,
2412
+ ...{
2413
+ tempContext: __privateGet(this, _opts).tempContext
2414
+ }
2415
+ });
2416
+ __privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
2417
+ __privateGet(this, _store).set("invisibleCount", invisibleCount);
2418
+ __privateGet(this, _store).set("visibleCount", visibleCount);
2419
+ }
2420
+ }
2421
+ updateVisiableStatus(opts) {
2422
+ const { virtualFlatItemMap, invisibleCount, visibleCount } = updateVirtualFlatItemMapStatus(
2423
+ __privateGet(this, _store).get("virtualFlatItemMap"),
2424
+ opts
2425
+ );
2426
+ __privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
2427
+ __privateGet(this, _store).set("invisibleCount", invisibleCount);
2428
+ __privateGet(this, _store).set("visibleCount", visibleCount);
2429
+ }
2430
+ calcViewRectInfoFromOrigin(uuid, opts) {
2431
+ const infoData = __privateGet(this, _store).get("virtualFlatItemMap")[uuid];
2432
+ if (!(infoData == null ? void 0 : infoData.originRectInfo)) {
2433
+ return null;
2434
+ }
2435
+ const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
2436
+ const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.originRectInfo;
2437
+ if (checkVisible === true && infoData.isVisibleInView === false) {
2438
+ return null;
2439
+ }
2440
+ const calcOpts = { viewScaleInfo };
2441
+ const viewRectInfo = {
2442
+ center: calcViewPointSize(center, calcOpts),
2443
+ left: calcViewPointSize(left, calcOpts),
2444
+ right: calcViewPointSize(right, calcOpts),
2445
+ bottom: calcViewPointSize(bottom, calcOpts),
2446
+ top: calcViewPointSize(top, calcOpts),
2447
+ topLeft: calcViewPointSize(topLeft, calcOpts),
2448
+ topRight: calcViewPointSize(topRight, calcOpts),
2449
+ bottomLeft: calcViewPointSize(bottomLeft, calcOpts),
2450
+ bottomRight: calcViewPointSize(bottomRight, calcOpts)
2451
+ };
2452
+ return viewRectInfo;
2453
+ }
2454
+ calcViewRectInfoFromRange(uuid, opts) {
2455
+ const infoData = __privateGet(this, _store).get("virtualFlatItemMap")[uuid];
2456
+ if (!(infoData == null ? void 0 : infoData.originRectInfo)) {
2457
+ return null;
2458
+ }
2459
+ const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
2460
+ const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.rangeRectInfo;
2461
+ if (checkVisible === true && infoData.isVisibleInView === false) {
2462
+ return null;
2463
+ }
2464
+ const calcOpts = { viewScaleInfo };
2465
+ const viewRectInfo = {
2466
+ center: calcViewPointSize(center, calcOpts),
2467
+ left: calcViewPointSize(left, calcOpts),
2468
+ right: calcViewPointSize(right, calcOpts),
2469
+ bottom: calcViewPointSize(bottom, calcOpts),
2470
+ top: calcViewPointSize(top, calcOpts),
2471
+ topLeft: calcViewPointSize(topLeft, calcOpts),
2472
+ topRight: calcViewPointSize(topRight, calcOpts),
2473
+ bottomLeft: calcViewPointSize(bottomLeft, calcOpts),
2474
+ bottomRight: calcViewPointSize(bottomRight, calcOpts)
2475
+ };
2476
+ return viewRectInfo;
2477
+ }
2478
+ modifyVirtualFlatItemMap(data, opts) {
2479
+ const { modifyOptions, viewScaleInfo, viewSizeInfo } = opts;
2480
+ const { type, content } = modifyOptions;
2481
+ const list = data.elements;
2482
+ const virtualFlatItemMap = __privateGet(this, _store).get("virtualFlatItemMap");
2483
+ if (type === "deleteElement") {
2484
+ const { element } = content;
2485
+ const uuids = [];
2486
+ const _walk = (e) => {
2487
+ uuids.push(e.uuid);
2488
+ if (e.type === "group" && Array.isArray(e.detail.children)) {
2489
+ e.detail.children.forEach((child) => {
2490
+ _walk(child);
2491
+ });
2492
+ }
2493
+ };
2494
+ _walk(element);
2495
+ uuids.forEach((uuid) => {
2496
+ delete virtualFlatItemMap[uuid];
2497
+ });
2498
+ __privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
2499
+ } else if (type === "addElement" || type === "updateElement") {
2500
+ const { position } = content;
2501
+ const element = findElementFromListByPosition(position, data.elements);
2502
+ const groupQueue = getGroupQueueByElementPosition(list, position);
2503
+ if (element) {
2504
+ if (type === "updateElement" && element.type === "group") {
2505
+ this.resetVirtualFlatItemMap(data, { viewScaleInfo, viewSizeInfo });
2506
+ } else {
2507
+ const originRectInfo = calcElementOriginRectInfo(element, {
2508
+ groupQueue: groupQueue || []
2509
+ });
2510
+ const newVirtualFlatItem = {
2511
+ type: element.type,
2512
+ originRectInfo,
2513
+ rangeRectInfo: is.angle(element.angle) ? originRectInfoToRangeRectInfo(originRectInfo) : originRectInfo,
2514
+ isVisibleInView: true,
2515
+ position: [...position],
2516
+ ...calcVirtualFlatDetail(element, {
2517
+ tempContext: __privateGet(this, _opts).tempContext
2518
+ })
2519
+ };
2520
+ virtualFlatItemMap[element.uuid] = newVirtualFlatItem;
2521
+ __privateGet(this, _store).set("virtualFlatItemMap", virtualFlatItemMap);
2522
+ if (type === "updateElement") {
2523
+ this.updateVisiableStatus({ viewScaleInfo, viewSizeInfo });
2524
+ }
2525
+ }
2526
+ }
2527
+ } else if (type === "moveElement") {
2528
+ this.resetVirtualFlatItemMap(data, { viewScaleInfo, viewSizeInfo });
2529
+ }
2530
+ }
2531
+ getVirtualFlatItem(uuid) {
2532
+ const itemMap = __privateGet(this, _store).get("virtualFlatItemMap");
2533
+ return itemMap[uuid] || null;
2534
+ }
2535
+ }
2536
+ _opts = new WeakMap();
2537
+ _store = new WeakMap();
1431
2538
  class Renderer extends EventEmitter {
1432
- // private _draftContextTop: CanvasRenderingContext2D;
1433
- // private _draftContextMiddle: CanvasRenderingContext2D;
1434
- // private _draftContextBottom: CanvasRenderingContext2D;
1435
2539
  constructor(opts) {
1436
2540
  super();
1437
- __privateAdd(this, _init);
1438
- __privateAdd(this, _opts, void 0);
2541
+ __privateAdd(this, _Renderer_instances);
2542
+ __privateAdd(this, _opts2);
1439
2543
  __privateAdd(this, _loader, new Loader());
1440
- __privateSet(this, _opts, opts);
1441
- __privateMethod(this, _init, init_fn).call(this);
2544
+ __privateAdd(this, _calculator);
2545
+ __privateAdd(this, _hasDestroyed2, false);
2546
+ __privateSet(this, _opts2, opts);
2547
+ __privateSet(this, _calculator, new Calculator({
2548
+ tempContext: opts.tempContext
2549
+ }));
2550
+ __privateMethod(this, _Renderer_instances, init_fn).call(this);
2551
+ }
2552
+ isDestroyed() {
2553
+ return __privateGet(this, _hasDestroyed2);
2554
+ }
2555
+ destroy() {
2556
+ this.clear();
2557
+ __privateSet(this, _opts2, null);
2558
+ __privateGet(this, _loader).destroy();
2559
+ __privateSet(this, _loader, null);
2560
+ __privateSet(this, _hasDestroyed2, true);
1442
2561
  }
1443
2562
  updateOptions(opts) {
1444
- __privateSet(this, _opts, opts);
2563
+ __privateSet(this, _opts2, opts);
1445
2564
  }
1446
2565
  drawData(data, opts) {
1447
2566
  const loader = __privateGet(this, _loader);
1448
- const { calculator } = __privateGet(this, _opts);
1449
- const viewContext = __privateGet(this, _opts).viewContext;
2567
+ const calculator = __privateGet(this, _calculator);
2568
+ const { sharer } = __privateGet(this, _opts2);
2569
+ const viewContext = __privateGet(this, _opts2).viewContext;
1450
2570
  viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
1451
2571
  const parentElementSize = {
1452
2572
  x: 0,
@@ -1454,20 +2574,41 @@ var __privateMethod = (obj, member, method) => {
1454
2574
  w: opts.viewSizeInfo.width,
1455
2575
  h: opts.viewSizeInfo.height
1456
2576
  };
1457
- drawElementList(viewContext, data, {
2577
+ const drawOpts = {
1458
2578
  loader,
1459
2579
  calculator,
1460
2580
  parentElementSize,
1461
2581
  elementAssets: data.assets,
2582
+ parentOpacity: 1,
2583
+ overrideElementMap: sharer == null ? void 0 : sharer.getActiveOverrideElemenentMap(),
1462
2584
  ...opts
1463
- });
2585
+ };
2586
+ drawGlobalBackground(viewContext, data.global, drawOpts);
2587
+ if (data.layout) {
2588
+ drawLayout(viewContext, data.layout, drawOpts, () => {
2589
+ drawElementList(viewContext, data, drawOpts);
2590
+ });
2591
+ } else {
2592
+ drawElementList(viewContext, data, drawOpts);
2593
+ }
1464
2594
  }
1465
2595
  scale(num) {
1466
- const { sharer } = __privateGet(this, _opts);
2596
+ const { sharer } = __privateGet(this, _opts2);
1467
2597
  if (!sharer) {
1468
2598
  return;
1469
2599
  }
1470
- const { data, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = sharer.getActiveStoreSnapshot();
2600
+ const {
2601
+ data,
2602
+ offsetTop,
2603
+ offsetBottom,
2604
+ offsetLeft,
2605
+ offsetRight,
2606
+ width,
2607
+ height,
2608
+ contextHeight,
2609
+ contextWidth,
2610
+ devicePixelRatio
2611
+ } = sharer.getActiveStoreSnapshot();
1471
2612
  if (data) {
1472
2613
  this.drawData(data, {
1473
2614
  viewScaleInfo: {
@@ -1493,19 +2634,40 @@ var __privateMethod = (obj, member, method) => {
1493
2634
  getLoadItemMap() {
1494
2635
  return __privateGet(this, _loader).getLoadItemMap();
1495
2636
  }
2637
+ getLoader() {
2638
+ return __privateGet(this, _loader);
2639
+ }
2640
+ getCalculator() {
2641
+ return __privateGet(this, _calculator);
2642
+ }
1496
2643
  }
1497
- _opts = new WeakMap();
2644
+ _opts2 = new WeakMap();
1498
2645
  _loader = new WeakMap();
1499
- _init = new WeakSet();
2646
+ _calculator = new WeakMap();
2647
+ _hasDestroyed2 = new WeakMap();
2648
+ _Renderer_instances = new WeakSet();
1500
2649
  init_fn = function() {
1501
2650
  const loader = __privateGet(this, _loader);
1502
2651
  loader.on("load", (e) => {
1503
2652
  this.trigger("load", e);
1504
2653
  });
1505
- loader.on("error", () => {
2654
+ loader.on("error", (e) => {
2655
+ console.error(e);
1506
2656
  });
1507
2657
  };
2658
+ exports.Calculator = Calculator;
1508
2659
  exports.Renderer = Renderer;
2660
+ exports.drawCircle = drawCircle;
2661
+ exports.drawElement = drawElement;
2662
+ exports.drawElementList = drawElementList;
2663
+ exports.drawGlobalBackground = drawGlobalBackground;
2664
+ exports.drawGroup = drawGroup;
2665
+ exports.drawHTML = drawHTML;
2666
+ exports.drawImage = drawImage;
2667
+ exports.drawLayout = drawLayout;
2668
+ exports.drawRect = drawRect;
2669
+ exports.drawSVG = drawSVG;
2670
+ exports.drawText = drawText;
1509
2671
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1510
2672
  return exports;
1511
2673
  }({});