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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { ViewContext2D, Element, ElementType, ElementSize, ViewScaleInfo, ViewSizeInfo } from '@idraw/types';
2
2
  export declare function getOpacity(elem: Element): number;
3
- export declare function drawBox(ctx: ViewContext2D, viewElem: Element<ElementType>, opts: {
4
- originElem: Element<ElementType>;
3
+ export declare function drawBox(ctx: ViewContext2D, viewElem: Element, opts: {
4
+ originElem: Element;
5
5
  calcElemSize: ElementSize;
6
6
  pattern?: string | CanvasPattern | null;
7
7
  renderContent: () => void;
@@ -9,6 +9,15 @@ export declare function drawBox(ctx: ViewContext2D, viewElem: Element<ElementTyp
9
9
  viewSizeInfo: ViewSizeInfo;
10
10
  parentOpacity: number;
11
11
  }): void;
12
+ export declare function drawBoxBackground(ctx: ViewContext2D, viewElem: Element<ElementType>, opts: {
13
+ pattern?: string | CanvasPattern | null;
14
+ viewScaleInfo: ViewScaleInfo;
15
+ viewSizeInfo: ViewSizeInfo;
16
+ }): void;
17
+ export declare function drawBoxBorder(ctx: ViewContext2D, viewElem: Element<ElementType>, opts: {
18
+ viewScaleInfo: ViewScaleInfo;
19
+ viewSizeInfo: ViewSizeInfo;
20
+ }): void;
12
21
  export declare function drawBoxShadow(ctx: ViewContext2D, viewElem: Element<ElementType>, opts: {
13
22
  viewScaleInfo: ViewScaleInfo;
14
23
  viewSizeInfo: ViewSizeInfo;
@@ -57,7 +57,7 @@ function drawClipPath(ctx, viewElem, opts) {
57
57
  renderContent === null || renderContent === void 0 ? void 0 : renderContent();
58
58
  }
59
59
  }
60
- function drawBoxBackground(ctx, viewElem, opts) {
60
+ export function drawBoxBackground(ctx, viewElem, opts) {
61
61
  var _a, _b;
62
62
  const { pattern, viewScaleInfo, viewSizeInfo } = opts;
63
63
  const transform = [];
@@ -118,7 +118,7 @@ function drawBoxBackground(ctx, viewElem, opts) {
118
118
  }
119
119
  }
120
120
  }
121
- function drawBoxBorder(ctx, viewElem, opts) {
121
+ export function drawBoxBorder(ctx, viewElem, opts) {
122
122
  if (viewElem.detail.borderWidth === 0) {
123
123
  return;
124
124
  }
@@ -1,9 +1,9 @@
1
- import { rotateElement } from '@idraw/util';
1
+ import { rotateElement, calcViewElementSize } from '@idraw/util';
2
2
  import { createColorStyle } from './color';
3
3
  import { drawBoxShadow, getOpacity } from './box';
4
4
  export function drawCircle(ctx, elem, opts) {
5
5
  const { detail, angle } = elem;
6
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
6
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
7
7
  const { background = '#000000', borderColor = '#000000', boxSizing, borderWidth = 0 } = detail;
8
8
  let bw = 0;
9
9
  if (typeof borderWidth === 'number' && borderWidth > 0) {
@@ -13,7 +13,7 @@ export function drawCircle(ctx, elem, opts) {
13
13
  bw = borderWidth[0];
14
14
  }
15
15
  bw = bw * viewScaleInfo.scale;
16
- const { x, y, w, h } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, viewScaleInfo, viewSizeInfo)) || elem;
16
+ const { x, y, w, h } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, { viewScaleInfo, viewSizeInfo }) || elem;
17
17
  const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
18
18
  rotateElement(ctx, { x, y, w, h, angle }, () => {
19
19
  drawBoxShadow(ctx, viewElem, {
@@ -11,7 +11,7 @@ export function drawElementList(ctx, data, opts) {
11
11
  detail: Object.assign(Object.assign({}, defaultDetail), element === null || element === void 0 ? void 0 : element.detail)
12
12
  });
13
13
  if (opts.forceDrawAll !== true) {
14
- if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.isElementInView(elem, opts.viewScaleInfo, opts.viewSizeInfo))) {
14
+ if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.needRender(elem))) {
15
15
  continue;
16
16
  }
17
17
  }
@@ -1,4 +1,4 @@
1
- import { rotateElement, calcViewBoxSize } from '@idraw/util';
1
+ import { rotateElement, calcViewBoxSize, calcViewElementSize } from '@idraw/util';
2
2
  import { drawCircle } from './circle';
3
3
  import { drawRect } from './rect';
4
4
  import { drawImage } from './image';
@@ -62,8 +62,8 @@ export function drawElement(ctx, elem, opts) {
62
62
  }
63
63
  }
64
64
  export function drawGroup(ctx, elem, opts) {
65
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
66
- const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo)) || elem;
65
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
66
+ const { x, y, w, h, angle } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, { viewScaleInfo, viewSizeInfo }) || elem;
67
67
  const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
68
68
  rotateElement(ctx, { x, y, w, h, angle }, () => {
69
69
  ctx.globalAlpha = getOpacity(elem) * parentOpacity;
@@ -112,7 +112,7 @@ export function drawGroup(ctx, elem, opts) {
112
112
  y: newParentSize.y + child.y
113
113
  });
114
114
  if (opts.forceDrawAll !== true) {
115
- if (!(calculator === null || calculator === void 0 ? void 0 : calculator.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo))) {
115
+ if (!(calculator === null || calculator === void 0 ? void 0 : calculator.needRender(child))) {
116
116
  continue;
117
117
  }
118
118
  }
@@ -1,9 +1,9 @@
1
- import { rotateElement } from '@idraw/util';
1
+ import { rotateElement, calcViewElementSize } from '@idraw/util';
2
2
  import { getOpacity } from './box';
3
3
  export function drawHTML(ctx, elem, opts) {
4
4
  const content = opts.loader.getContent(elem);
5
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
6
- const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
5
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
6
+ const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
7
7
  rotateElement(ctx, { x, y, w, h, angle }, () => {
8
8
  if (!content && !opts.loader.isDestroyed()) {
9
9
  opts.loader.load(elem, opts.elementAssets || {});
@@ -1,9 +1,9 @@
1
- import { rotateElement, calcViewBoxSize } from '@idraw/util';
1
+ import { rotateElement, calcViewBoxSize, calcViewElementSize } from '@idraw/util';
2
2
  import { drawBox, drawBoxShadow, getOpacity } from './box';
3
3
  export function drawImage(ctx, elem, opts) {
4
4
  const content = opts.loader.getContent(elem);
5
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
6
- const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
5
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
6
+ const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
7
7
  const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
8
8
  rotateElement(ctx, { x, y, w, h, angle }, () => {
9
9
  drawBoxShadow(ctx, viewElem, {
@@ -5,4 +5,4 @@ export { drawSVG } from './svg';
5
5
  export { drawHTML } from './html';
6
6
  export { drawText } from './text';
7
7
  export { drawElementList } from './elements';
8
- export { drawUnderlay } from './underlay';
8
+ export { drawLayout } from './layout';
@@ -5,4 +5,4 @@ export { drawSVG } from './svg';
5
5
  export { drawHTML } from './html';
6
6
  export { drawText } from './text';
7
7
  export { drawElementList } from './elements';
8
- export { drawUnderlay } from './underlay';
8
+ export { drawLayout } from './layout';
@@ -0,0 +1,2 @@
1
+ import type { RendererDrawElementOptions, ViewContext2D, DataLayout } from '@idraw/types';
2
+ export declare function drawLayout(ctx: ViewContext2D, layout: DataLayout, opts: RendererDrawElementOptions, renderContent: (ctx: ViewContext2D) => void): void;
@@ -0,0 +1,44 @@
1
+ import { calcViewElementSize, calcViewBoxSize } from '@idraw/util';
2
+ import { drawBoxShadow, drawBoxBackground, drawBoxBorder } from './box';
3
+ export function drawLayout(ctx, layout, opts, renderContent) {
4
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
5
+ const elem = Object.assign({ uuid: 'layout', type: 'group', x: 0, y: 0 }, layout);
6
+ const { x, y, w, h } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
7
+ const angle = 0;
8
+ const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
9
+ ctx.globalAlpha = 1;
10
+ drawBoxShadow(ctx, viewElem, {
11
+ viewScaleInfo,
12
+ viewSizeInfo,
13
+ renderContent: () => {
14
+ drawBoxBackground(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
15
+ }
16
+ });
17
+ if (layout.detail.overflow === 'hidden') {
18
+ const { viewScaleInfo, viewSizeInfo } = opts;
19
+ const elem = Object.assign({ uuid: 'layout', type: 'group', x: 0, y: 0 }, layout);
20
+ const viewElemSize = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
21
+ const viewElem = Object.assign(Object.assign({}, elem), viewElemSize);
22
+ const { x, y, w, h, radiusList } = calcViewBoxSize(viewElem, {
23
+ viewScaleInfo,
24
+ viewSizeInfo
25
+ });
26
+ ctx.save();
27
+ ctx.fillStyle = 'transparent';
28
+ ctx.beginPath();
29
+ ctx.moveTo(x + radiusList[0], y);
30
+ ctx.arcTo(x + w, y, x + w, y + h, radiusList[1]);
31
+ ctx.arcTo(x + w, y + h, x, y + h, radiusList[2]);
32
+ ctx.arcTo(x, y + h, x, y, radiusList[3]);
33
+ ctx.arcTo(x, y, x + w, y, radiusList[0]);
34
+ ctx.closePath();
35
+ ctx.fill();
36
+ ctx.clip();
37
+ }
38
+ renderContent(ctx);
39
+ if (layout.detail.overflow === 'hidden') {
40
+ ctx.restore();
41
+ }
42
+ drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
43
+ ctx.globalAlpha = parentOpacity;
44
+ }
@@ -1,10 +1,10 @@
1
- import { rotateElement, generateSVGPath } from '@idraw/util';
1
+ import { rotateElement, generateSVGPath, calcViewElementSize } from '@idraw/util';
2
2
  import { drawBox, drawBoxShadow } from './box';
3
3
  export function drawPath(ctx, elem, opts) {
4
4
  const { detail } = elem;
5
5
  const { originX, originY, originW, originH } = detail;
6
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
7
- const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
6
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
7
+ const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
8
8
  const scaleW = w / originW;
9
9
  const scaleH = h / originH;
10
10
  const viewOriginX = originX * scaleW;
@@ -1,8 +1,8 @@
1
- import { rotateElement } from '@idraw/util';
1
+ import { rotateElement, calcViewElementSize } from '@idraw/util';
2
2
  import { drawBox, drawBoxShadow } from './box';
3
3
  export function drawRect(ctx, elem, opts) {
4
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
5
- const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
4
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
5
+ const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
6
6
  const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
7
7
  rotateElement(ctx, { x, y, w, h, angle }, () => {
8
8
  drawBoxShadow(ctx, viewElem, {
@@ -1,9 +1,9 @@
1
- import { rotateElement } from '@idraw/util';
1
+ import { rotateElement, calcViewElementSize } from '@idraw/util';
2
2
  import { getOpacity } from './box';
3
3
  export function drawSVG(ctx, elem, opts) {
4
4
  const content = opts.loader.getContent(elem);
5
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
6
- const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
5
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
6
+ const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
7
7
  rotateElement(ctx, { x, y, w, h, angle }, () => {
8
8
  if (!content && !opts.loader.isDestroyed()) {
9
9
  opts.loader.load(elem, opts.elementAssets || {});
@@ -1,10 +1,10 @@
1
- import { rotateElement } from '@idraw/util';
1
+ import { rotateElement, calcViewElementSize } from '@idraw/util';
2
2
  import { is, isColorStr, getDefaultElementDetailConfig } from '@idraw/util';
3
3
  import { drawBox } from './box';
4
4
  const detailConfig = getDefaultElementDetailConfig();
5
5
  export function drawText(ctx, elem, opts) {
6
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
7
- const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
6
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
7
+ const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
8
8
  const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
9
9
  rotateElement(ctx, { x, y, w, h, angle }, () => {
10
10
  drawBox(ctx, viewElem, {
package/dist/esm/index.js CHANGED
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _Renderer_instances, _Renderer_opts, _Renderer_loader, _Renderer_hasDestroyed, _Renderer_init;
13
13
  import { EventEmitter } from '@idraw/util';
14
- import { drawElementList, drawUnderlay } from './draw/index';
14
+ import { drawElementList, drawLayout } from './draw/index';
15
15
  import { Loader } from './loader';
16
16
  export class Renderer extends EventEmitter {
17
17
  constructor(opts) {
@@ -47,14 +47,17 @@ export class Renderer extends EventEmitter {
47
47
  w: opts.viewSizeInfo.width,
48
48
  h: opts.viewSizeInfo.height
49
49
  };
50
- if (data.underlay) {
51
- drawUnderlay(viewContext, data.underlay, Object.assign({ loader,
52
- calculator,
53
- parentElementSize, parentOpacity: 1 }, opts));
54
- }
55
- drawElementList(viewContext, data, Object.assign({ loader,
50
+ const drawOpts = Object.assign({ loader,
56
51
  calculator,
57
- parentElementSize, elementAssets: data.assets, parentOpacity: 1 }, opts));
52
+ parentElementSize, elementAssets: data.assets, parentOpacity: 1 }, opts);
53
+ if (data.layout) {
54
+ drawLayout(viewContext, data.layout, drawOpts, () => {
55
+ drawElementList(viewContext, data, drawOpts);
56
+ });
57
+ }
58
+ else {
59
+ drawElementList(viewContext, data, drawOpts);
60
+ }
58
61
  }
59
62
  scale(num) {
60
63
  const { sharer } = __classPrivateFieldGet(this, _Renderer_opts, "f");
@@ -455,6 +455,19 @@ var __privateMethod = (obj, member, method) => {
455
455
  };
456
456
  return p;
457
457
  }
458
+ function calcViewElementSize(size, opts) {
459
+ const { viewScaleInfo } = opts;
460
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = size;
461
+ const { scale, offsetTop, offsetLeft } = viewScaleInfo;
462
+ const newSize = {
463
+ x: x2 * scale + offsetLeft,
464
+ y: y2 * scale + offsetTop,
465
+ w: w2 * scale,
466
+ h: h2 * scale,
467
+ angle: angle2
468
+ };
469
+ return newSize;
470
+ }
458
471
  function generateSVGPath(commands) {
459
472
  let path = "";
460
473
  commands.forEach((item) => {
@@ -846,7 +859,7 @@ var __privateMethod = (obj, member, method) => {
846
859
  }
847
860
  function drawCircle(ctx, elem, opts) {
848
861
  const { detail, angle: angle2 } = elem;
849
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
862
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
850
863
  const { background = "#000000", borderColor = "#000000", boxSizing, borderWidth: borderWidth2 = 0 } = detail;
851
864
  let bw = 0;
852
865
  if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
@@ -855,7 +868,7 @@ var __privateMethod = (obj, member, method) => {
855
868
  bw = borderWidth2[0];
856
869
  }
857
870
  bw = bw * viewScaleInfo.scale;
858
- 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;
871
+ const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, { viewScaleInfo, viewSizeInfo }) || elem;
859
872
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
860
873
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
861
874
  drawBoxShadow(ctx, viewElem, {
@@ -908,8 +921,8 @@ var __privateMethod = (obj, member, method) => {
908
921
  });
909
922
  }
910
923
  function drawRect(ctx, elem, opts) {
911
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
912
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
924
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
925
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
913
926
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
914
927
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
915
928
  drawBoxShadow(ctx, viewElem, {
@@ -931,8 +944,8 @@ var __privateMethod = (obj, member, method) => {
931
944
  }
932
945
  function drawImage(ctx, elem, opts) {
933
946
  const content = opts.loader.getContent(elem);
934
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
935
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
947
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
948
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
936
949
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
937
950
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
938
951
  drawBoxShadow(ctx, viewElem, {
@@ -978,8 +991,8 @@ var __privateMethod = (obj, member, method) => {
978
991
  }
979
992
  function drawSVG(ctx, elem, opts) {
980
993
  const content = opts.loader.getContent(elem);
981
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
982
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
994
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
995
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
983
996
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
984
997
  if (!content && !opts.loader.isDestroyed()) {
985
998
  opts.loader.load(elem, opts.elementAssets || {});
@@ -993,8 +1006,8 @@ var __privateMethod = (obj, member, method) => {
993
1006
  }
994
1007
  function drawHTML(ctx, elem, opts) {
995
1008
  const content = opts.loader.getContent(elem);
996
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
997
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1009
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1010
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
998
1011
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
999
1012
  if (!content && !opts.loader.isDestroyed()) {
1000
1013
  opts.loader.load(elem, opts.elementAssets || {});
@@ -1008,8 +1021,8 @@ var __privateMethod = (obj, member, method) => {
1008
1021
  }
1009
1022
  const detailConfig = getDefaultElementDetailConfig();
1010
1023
  function drawText(ctx, elem, opts) {
1011
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1012
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1024
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1025
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
1013
1026
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
1014
1027
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1015
1028
  drawBox(ctx, viewElem, {
@@ -1115,8 +1128,8 @@ var __privateMethod = (obj, member, method) => {
1115
1128
  function drawPath(ctx, elem, opts) {
1116
1129
  const { detail } = elem;
1117
1130
  const { originX, originY, originW, originH } = detail;
1118
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1119
- const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1131
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1132
+ const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
1120
1133
  const scaleW = w2 / originW;
1121
1134
  const scaleH = h2 / originH;
1122
1135
  const viewOriginX = originX * scaleW;
@@ -1220,8 +1233,8 @@ var __privateMethod = (obj, member, method) => {
1220
1233
  }
1221
1234
  }
1222
1235
  function drawGroup(ctx, elem, opts) {
1223
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1224
- 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;
1236
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1237
+ 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, viewSizeInfo }) || elem;
1225
1238
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
1226
1239
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
1227
1240
  ctx.globalAlpha = getOpacity(elem) * parentOpacity;
@@ -1262,7 +1275,7 @@ var __privateMethod = (obj, member, method) => {
1262
1275
  h: elem.h || parentSize.h,
1263
1276
  angle: elem.angle
1264
1277
  };
1265
- const { calculator: calculator2 } = opts;
1278
+ const { calculator } = opts;
1266
1279
  for (let i = 0; i < elem.detail.children.length; i++) {
1267
1280
  let child = elem.detail.children[i];
1268
1281
  child = {
@@ -1273,7 +1286,7 @@ var __privateMethod = (obj, member, method) => {
1273
1286
  }
1274
1287
  };
1275
1288
  if (opts.forceDrawAll !== true) {
1276
- if (!(calculator2 == null ? void 0 : calculator2.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo))) {
1289
+ if (!(calculator == null ? void 0 : calculator.needRender(child))) {
1277
1290
  continue;
1278
1291
  }
1279
1292
  }
@@ -1311,7 +1324,7 @@ var __privateMethod = (obj, member, method) => {
1311
1324
  }
1312
1325
  };
1313
1326
  if (opts.forceDrawAll !== true) {
1314
- if (!((_a = opts.calculator) == null ? void 0 : _a.isElementInView(elem, opts.viewScaleInfo, opts.viewSizeInfo))) {
1327
+ if (!((_a = opts.calculator) == null ? void 0 : _a.needRender(elem))) {
1315
1328
  continue;
1316
1329
  }
1317
1330
  }
@@ -1327,27 +1340,47 @@ var __privateMethod = (obj, member, method) => {
1327
1340
  }
1328
1341
  }
1329
1342
  }
1330
- function drawUnderlay(ctx, underlay, opts) {
1331
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1332
- const elem = { uuid: "underlay", ...underlay };
1333
- const { x: x2, y: y2, w: w2, h: h2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
1343
+ function drawLayout(ctx, layout, opts, renderContent) {
1344
+ const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
1345
+ const elem = { uuid: "layout", type: "group", x: 0, y: 0, ...layout };
1346
+ const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo }) || elem;
1334
1347
  const angle2 = 0;
1335
1348
  const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
1349
+ ctx.globalAlpha = 1;
1336
1350
  drawBoxShadow(ctx, viewElem, {
1337
1351
  viewScaleInfo,
1338
1352
  viewSizeInfo,
1339
1353
  renderContent: () => {
1340
- drawBox(ctx, viewElem, {
1341
- originElem: elem,
1342
- calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
1343
- viewScaleInfo,
1344
- viewSizeInfo,
1345
- parentOpacity,
1346
- renderContent: () => {
1347
- }
1348
- });
1354
+ drawBoxBackground(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
1349
1355
  }
1350
1356
  });
1357
+ if (layout.detail.overflow === "hidden") {
1358
+ const { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 } = opts;
1359
+ const elem2 = { uuid: "layout", type: "group", x: 0, y: 0, ...layout };
1360
+ const viewElemSize = calcViewElementSize(elem2, { viewScaleInfo: viewScaleInfo2, viewSizeInfo: viewSizeInfo2 }) || elem2;
1361
+ const viewElem2 = { ...elem2, ...viewElemSize };
1362
+ const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem2, {
1363
+ viewScaleInfo: viewScaleInfo2,
1364
+ viewSizeInfo: viewSizeInfo2
1365
+ });
1366
+ ctx.save();
1367
+ ctx.fillStyle = "transparent";
1368
+ ctx.beginPath();
1369
+ ctx.moveTo(x22 + radiusList[0], y22);
1370
+ ctx.arcTo(x22 + w22, y22, x22 + w22, y22 + h22, radiusList[1]);
1371
+ ctx.arcTo(x22 + w22, y22 + h22, x22, y22 + h22, radiusList[2]);
1372
+ ctx.arcTo(x22, y22 + h22, x22, y22, radiusList[3]);
1373
+ ctx.arcTo(x22, y22, x22 + w22, y22, radiusList[0]);
1374
+ ctx.closePath();
1375
+ ctx.fill();
1376
+ ctx.clip();
1377
+ }
1378
+ renderContent(ctx);
1379
+ if (layout.detail.overflow === "hidden") {
1380
+ ctx.restore();
1381
+ }
1382
+ drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
1383
+ ctx.globalAlpha = parentOpacity;
1351
1384
  }
1352
1385
  const supportElementTypes = ["image", "svg", "html"];
1353
1386
  const getAssetIdFromElement = (element) => {
@@ -1586,23 +1619,21 @@ var __privateMethod = (obj, member, method) => {
1586
1619
  w: opts.viewSizeInfo.width,
1587
1620
  h: opts.viewSizeInfo.height
1588
1621
  };
1589
- if (data.underlay) {
1590
- drawUnderlay(viewContext, data.underlay, {
1591
- loader,
1592
- calculator,
1593
- parentElementSize,
1594
- parentOpacity: 1,
1595
- ...opts
1596
- });
1597
- }
1598
- drawElementList(viewContext, data, {
1622
+ const drawOpts = {
1599
1623
  loader,
1600
1624
  calculator,
1601
1625
  parentElementSize,
1602
1626
  elementAssets: data.assets,
1603
1627
  parentOpacity: 1,
1604
1628
  ...opts
1605
- });
1629
+ };
1630
+ if (data.layout) {
1631
+ drawLayout(viewContext, data.layout, drawOpts, () => {
1632
+ drawElementList(viewContext, data, drawOpts);
1633
+ });
1634
+ } else {
1635
+ drawElementList(viewContext, data, drawOpts);
1636
+ }
1606
1637
  }
1607
1638
  scale(num) {
1608
1639
  const { sharer } = __privateGet(this, _opts);
@@ -1 +1 @@
1
- var iDrawRenderer=function(e){"use strict";var t,n,i,o,a,r,l,s,c,d,h,f,u,w,g,v,y,p,m,S,x,b,I,z=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},T=(e,t,n)=>(z(e,t,"read from private field"),n?n.call(e):t.get(e)),A=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},C=(e,t,n,i)=>(z(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),E=(e,t,n)=>(z(e,t,"access private method"),n);function k(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function O(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o}function W(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function P(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function $(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${P(t.toString(16).padEnd(4,i))}${P(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${P(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${P(o.padEnd(4,i).padEnd(4,o))}`}function M(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const D={type(e,t){const n=M(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===M(e),json:e=>"Object"===M(e),function:e=>"Function"===M(e),asyncFunction:e=>"AsyncFunction"===M(e),boolean:e=>"Boolean"===M(e),string:e=>"String"===M(e),number:e=>"Number"===M(e),undefined:e=>"Undefined"===M(e),null:e=>"Null"===M(e),promise:e=>"Promise"===M(e)};var R=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function l(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((i=i.apply(e,t||[])).next())}))};const{Image:L}=window;function B(e){return new Promise(((t,n)=>{const i=new L;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function F(e){return R(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return yield B(t)}))}function H(e,t){return R(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const n=yield function(e,t){const{width:n,height:i}=t;return new Promise(((t,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},r.onerror=function(e){o(e)}}))}(e,t);return yield B(n)}))}function X(e){return"number"==typeof e&&(e>0||e<=0)}function Y(e){return"number"==typeof e&&e>=0}function j(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function U(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const q={x:function(e){return X(e)},y:function(e){return X(e)},w:Y,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:X,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return Y(e)},borderRadius:function(e){return X(e)&&e>=0},color:function(e){return k(e)},imageSrc:function(e){return U(e)||j(e)},imageURL:j,imageBase64:U,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return X(e)&&e>0},lineHeight:function(e){return X(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return X(e)&&e>0}};var G,N=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};class V{constructor(){G.set(this,void 0),function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(e,n):o?o.value=n:t.set(e,n)}(this,G,new Map,"f")}on(e,t){if(N(this,G,"f").has(e)){const n=N(this,G,"f").get(e)||[];null==n||n.push(t),N(this,G,"f").set(e,n)}else N(this,G,"f").set(e,[t])}off(e,t){if(N(this,G,"f").has(e)){const n=N(this,G,"f").get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}N(this,G,"f").set(e,n||[])}}trigger(e,t){const n=N(this,G,"f").get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(N(this,G,"f").has(e)){const t=N(this,G,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){N(this,G,"f").clear()}}function J(e,t,n,i){const o=function(e){return e/180*Math.PI}(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function K(e,t,n){const i={x:(o=t).x+o.w/2,y:o.y+o.h/2};var o;J(e,t.angle||0,i,(()=>{n(e)}))}function Q(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}G=new WeakMap;const Z={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function _(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:a=Z.boxSizing,borderWidth:r}=e.detail;Array.isArray(r)&&(o=0);let{x:l,y:s,w:c,h:d}=e,h=[0,0,0,0];if("number"==typeof o){const e=o*i;h=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let f=0;return"number"==typeof r&&(f=(r||0)*i),"border-box"===a?(l=e.x+f/2,s=e.y+f/2,c=e.w-f,d=e.h-f):"content-box"===a?(l=e.x-f/2,s=e.y-f/2,c=e.w+f,d=e.h+f):(l=e.x,s=e.y,c=e.w,d=e.h),c=Math.max(c,1),d=Math.max(d,1),h=h.map((e=>Math.min(e,c/2,d/2))),{x:l,y:s,w:c,h:d,radiusList:h}}function ee(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s},d={x:r+i.x*s,y:l+i.y*s},h=e.createLinearGradient(c.x,c.y,d.x,d.y);return o.forEach((e=>{h.addColorStop(e.offset,O(e.color,a))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},d={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},h=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return o.forEach((e=>{h.addColorStop(e.offset,O(e.color,a))})),h}return"#000000"}const te={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function ne(e){var t,n,i,o;let a=1;return void 0!==(null==(t=null==e?void 0:e.detail)?void 0:t.opacity)&&(null==(n=null==e?void 0:e.detail)?void 0:n.opacity)>=0&&(null==(i=null==e?void 0:e.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==e?void 0:e.detail)?void 0:o.opacity),a}function ie(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=ne(a)*c;!function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r}=n,l=r.devicePixelRatio,{clipPath:s}=(null==o?void 0:o.detail)||{};if(s&&a&&s.commands){const{x:n,y:o,w:r,h:c}=a,{originW:d,originH:h,originX:f,originY:u}=s,w=r/d,g=c/h,v=n-f*w,y=o-u*g;e.save(),e.translate(v,y),e.scale(l*w,l*g);const p=Q(s.commands||[]),m=new Path2D(p);e.clip(m),e.translate(0-v,0-y),e.setTransform(1,0,0,1,0,0),K(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{e.globalAlpha=d,function(e,t,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:f}=_(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(n+f[0],c),e.arcTo(n+d,c,n+d,c+h,f[1]),e.arcTo(n+d,c+h,n,c+h,f[2]),e.arcTo(n,c+h,n,c,f[3]),e.arcTo(n,c,n+d,c,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(D.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const i=ee(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=ee(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=i,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const i=s[t];"translate"===i.method?e.translate(i.args[0]+n,i.args[1]+c):"rotate"===i.method?e.rotate(...i.args):"scale"===i.method&&e.scale(...i.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),function(e,t,n){if(0===t.detail.borderWidth)return;if(!k(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=te.borderColor;!0===k(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=te.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1);d*=o;let h=[0,0,0,0];if("number"==typeof l){const e=l*o;h=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(h=[l[0]*o,l[1]*o,l[2]*o,l[3]*o]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*o))));let u=0,w=0,g=0,v=0;Array.isArray(r)&&(u=(r[0]||0)*o,w=(r[1]||0)*o,g=(r[2]||0)*o,v=(r[3]||0)*o);if(v||w||u||g){e.lineCap="butt";let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n+=v/2,i+=u/2,o=o-v/2-w/2,a=a-u/2-g/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+w/2,a=a+u/2+g/2):(n=t.x,i=t.y,o=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(n-v/2,i),e.lineTo(n+o+w/2,i),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+g/2),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n-v/2,i+a),e.lineTo(n+o+w/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+g/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n=t.x+d/2,i=t.y+d/2,o=t.w-d,a=t.h-d):"content-box"===c?(n=t.x-d/2,i=t.y-d/2,o=t.w+d,a=t.h+d):(n=t.x,i=t.y,o=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),h=h.map((e=>Math.min(e,o/2,a/2))),e.setLineDash(f),e.lineWidth=d,e.beginPath(),e.moveTo(n+h[0],i),e.arcTo(n+o,i,n+o,i+a,h[1]),e.arcTo(n+o,i+a,n,i+a,h[2]),e.arcTo(n,i+a,n,i,h[3]),e.arcTo(n,i,n+o,i,h[0]),e.closePath(),e.stroke()}e.setLineDash([])}(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c}})}function oe(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;q.number(c)?(e.save(),e.shadowColor=r||te.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}function ae(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};K(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{oe(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ie(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}))}const re={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function le(e,t,n){var i;if(!0===(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))return;const{w:o,h:a}=t,{scale:r}=n.viewScaleInfo;if(!(r<1&&(o*r<1||a*r<1)||0===n.parentOpacity))try{switch(t.type){case"rect":ae(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{calculator:a,viewScaleInfo:r,viewSizeInfo:l,parentOpacity:s}=n,{background:c="#000000",borderColor:d="#000000",boxSizing:h,borderWidth:f=0}=i;let u=0;"number"==typeof f&&f>0?u=f:Array.isArray(f)&&"number"==typeof f[0]&&f[0]>0&&(u=f[0]),u*=r.scale;const{x:w,y:g,w:v,h:y}=(null==a?void 0:a.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},r,l))||t,p={...t,x:w,y:g,w:v,h:y,angle:o};K(e,{x:w,y:g,w:v,h:y,angle:o},(()=>{oe(e,p,{viewScaleInfo:r,viewSizeInfo:l,renderContent:()=>{let t=v/2,n=y/2;const i=w+t,o=g+n;if(u>0&&("border-box"===h?(t-=u,n-=u):"center-line"===h?(t-=u/2,n-=u/2):(t-=u,n-=u)),t>=0&&n>=0){const a=ne(p)*s;if(e.globalAlpha=a,"number"==typeof u&&u>0){const a=u/2+t,r=u/2+n;e.beginPath(),e.strokeStyle=d,e.lineWidth=u,e.circle(i,o,a,r,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const l=ee(e,c,{viewElementSize:{x:w,y:g,w:v,h:y},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=l,e.circle(i,o,t,n,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=s}}})}))}(e,t,n);break;case"text":!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};K(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{ie(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const n={...re,...t.detail},i=(n.fontSize||re.fontSize)*o.scale,a=n.lineHeight?n.lineHeight*o.scale:i;e.fillStyle=t.detail.color||re.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:i,fontFamily:n.fontFamily});const r=n.text.replace(/\r\n/gi,"\n"),h=a,f=r.split("\n"),u=[];let w=0;f.forEach(((t,n)=>{let i="";if(t.length>0){for(let o=0;o<t.length&&(e.measureText(i+(t[o]||"")).width<e.$doPixelRatio(c)?i+=t[o]||"":(u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),i=t[o]||"",w++),!((w+1)*h>d));o++)if(t.length-1===o&&(w+1)*h<d){u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),n<f.length-1&&w++;break}}else u.push({text:"",width:0})}));let g=0;u.length*h<d&&("top"===t.detail.verticalAlign?g=0:"bottom"===t.detail.verticalAlign?g+=d-u.length*h:g+=(d-u.length*h)/2);{const t=s+g;void 0!==n.textShadowColor&&k(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&q.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&q.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&q.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),u.forEach(((i,o)=>{let a=l;"center"===n.textAlign?a=l+(c-i.width)/2:"right"===n.textAlign&&(a=l+(c-i.width)),e.fillText(i.text,a,t+h*o)}))}}})}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t,u={...t,x:s,y:c,w:d,h:h,angle:f};K(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{oe(e,u,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{ie(e,u,{originElem:t,calcElemSize:{x:s,y:c,w:d,h:h,angle:f},viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l,renderContent:()=>{if(i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=ne(t)*l;const{x:n,y:o,w:s,h:c,radiusList:d}=_(u,{viewScaleInfo:a,viewSizeInfo:r});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],o),e.arcTo(n+s,o,n+s,o+c,d[1]),e.arcTo(n+s,o+c,n,o+c,d[2]),e.arcTo(n,o+c,n,o,d[3]),e.arcTo(n,o,n+s,o,d[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(i,n,o,s,c),e.globalAlpha=l,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;K(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=ne(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;K(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=ne(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"path":!function(e,t,n){const{detail:i}=t,{originX:o,originY:a,originW:r,originH:l}=i,{calculator:s,viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h}=n,{x:f,y:u,w:w,h:g,angle:v}=(null==s?void 0:s.elementSize(t,c,d))||t,y=w/r,p=g/l,m=f-o*y,S=u-a*p,x=c.scale*d.devicePixelRatio,b={...t,x:f,y:u,w:w,h:g,angle:v};K(e,{x:f,y:u,w:w,h:g,angle:v},(()=>{ie(e,b,{originElem:t,calcElemSize:{x:f,y:u,w:w,h:g,angle:v},viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h,renderContent:()=>{oe(e,b,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{e.save(),e.translate(m,S),e.scale(x*y/c.scale,x*p/c.scale);const t=Q(i.commands||[]),n=new Path2D(t);i.fill&&(e.fillStyle=i.fill,e.fill(n)),i.stroke&&0!==i.strokeWidth&&(e.strokeStyle=i.stroke,e.lineWidth=(i.strokeWidth||1)/d.devicePixelRatio,e.lineCap=i.strokeLineCap||"square",e.stroke(n)),e.translate(-m,-S),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};K(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{e.globalAlpha=ne(t)*r,oe(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ie(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const{x:i,y:l,w:s,h:c,radiusList:d}=_(f,{viewScaleInfo:o,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+d[0],l),e.arcTo(i+s,l,i+s,l+c,d[1]),e.arcTo(i+s,l+c,i,l+c,d[2]),e.arcTo(i,l+c,i,l,d[3]),e.arcTo(i,l,i+s,l,d[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:i}=n,o={x:i.x+t.x,y:i.y+t.y,w:t.w||i.w,h:t.h||i.h,angle:t.angle},{calculator:a}=n;for(let i=0;i<t.detail.children.length;i++){let l=t.detail.children[i];if(l={...l,x:o.x+l.x,y:o.y+l.y},!0===n.forceDrawAll||(null==a?void 0:a.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{le(e,l,{...n,parentOpacity:r*ne(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=r}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}const se={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const ce=["image","svg","html"],de=e=>{var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),"string"==typeof o&&o?/^@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(`${o}`)?o:$(o):$(`${W()}-${e.uuid}-${W()}-${W()}`)};class he extends V{constructor(){super(),A(this,a),A(this,l),A(this,c),A(this,h),A(this,u),A(this,g),A(this,y),A(this,t,{}),A(this,n,{}),A(this,i,{}),A(this,o,!1),E(this,a,r).call(this,"image",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,o=await B(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),E(this,a,r).call(this,"html",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,o=await H(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),E(this,a,r).call(this,"svg",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,o=await F(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}isDestroyed(){return T(this,o)}destroy(){C(this,o,!0),this.clear(),C(this,t,null),C(this,n,null),C(this,i,null)}load(e,t){!0!==T(this,o)&&(E(this,y,p).call(this,e)||ce.includes(e.type)&&E(this,g,v).call(this,e,t))}getContent(e){var t,n;const o=de(e);return(null==(n=null==(t=T(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return T(this,i)}setLoadItemMap(e){C(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakSet,r=function(e,n){T(this,t)[e]=n},l=new WeakSet,s=function(e){var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),o},c=new WeakSet,d=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:E(this,l,s).call(this,e)}},h=new WeakSet,f=function(e){const t=de(e.element),n=T(this,i)[t];T(this,o)||(n?n.startTime<e.startTime&&(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))},u=new WeakSet,w=function(e){var t;const n=de(e.element),a=null==(t=T(this,i))?void 0:t[n];T(this,o)||(a?a.startTime<e.startTime&&(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))},g=new WeakSet,v=function(e,i){const a=E(this,c,d).call(this,e),r=de(e);if(T(this,n)[r])return;T(this,n)[r]=a;const l=T(this,t)[e.type];"function"!=typeof l||T(this,o)||(a.startTime=Date.now(),l(e,i).then((e=>{T(this,o)||(a.content=e.content,a.endTime=Date.now(),a.status="load",E(this,h,f).call(this,a))})).catch((t=>{console.warn(`Load element source "${a.source}" fail`,t,e),a.endTime=Date.now(),a.status="error",a.error=t,E(this,u,w).call(this,a)})))},y=new WeakSet,p=function(e){var t;const i=de(e),o=null==(t=T(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==E(this,l,s).call(this,e))};return m=new WeakMap,S=new WeakMap,x=new WeakMap,b=new WeakSet,I=function(){const e=T(this,S);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))},e.Renderer=class extends V{constructor(e){super(),A(this,b),A(this,m,void 0),A(this,S,new he),A(this,x,!1),C(this,m,e),E(this,b,I).call(this)}isDestroyed(){return T(this,x)}destroy(){this.clear(),C(this,m,null),T(this,S).destroy(),C(this,S,null),C(this,x,!0)}updateOptions(e){C(this,m,e)}drawData(e,t){const n=T(this,S),{calculator:i}=T(this,m),o=T(this,m).viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);const a={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height};e.underlay&&function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"underlay",...t},{x:s,y:c,w:d,h:h}=(null==i?void 0:i.elementSize(l,o,a))||l,f={...l,x:s,y:c,w:d,h:h,angle:0};oe(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ie(e,f,{originElem:l,calcElemSize:{x:s,y:c,w:d,h:h,angle:0},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}(o,e.underlay,{loader:n,calculator:i,parentElementSize:a,parentOpacity:1,...t}),function(e,t,n){var i;const{elements:o=[]}=t,{parentOpacity:a}=n;for(let t=0;t<o.length;t++){const r=o[t],l={...r,detail:{...se,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{le(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}(o,e,{loader:n,calculator:i,parentElementSize:a,elementAssets:e.assets,parentOpacity:1,...t})}scale(e){const{sharer:t}=T(this,m);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){T(this,S).setLoadItemMap(e)}getLoadItemMap(){return T(this,S).getLoadItemMap()}getLoader(){return T(this,S)}},e.drawRect=ae,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var iDrawRenderer=function(e){"use strict";var t,n,i,o,a,r,l,s,c,d,h,f,u,w,g,v,y,p,m,S,x,b,I,z=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},T=(e,t,n)=>(z(e,t,"read from private field"),n?n.call(e):t.get(e)),A=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},C=(e,t,n,i)=>(z(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),E=(e,t,n)=>(z(e,t,"access private method"),n);function k(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function O(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o}function W(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function P(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function $(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${P(t.toString(16).padEnd(4,i))}${P(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${P(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${P(o.padEnd(4,i).padEnd(4,o))}`}function M(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(e,t){const n=M(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===M(e),json:e=>"Object"===M(e),function:e=>"Function"===M(e),asyncFunction:e=>"AsyncFunction"===M(e),boolean:e=>"Boolean"===M(e),string:e=>"String"===M(e),number:e=>"Number"===M(e),undefined:e=>"Undefined"===M(e),null:e=>"Null"===M(e),promise:e=>"Promise"===M(e)};var D=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function l(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((i=i.apply(e,t||[])).next())}))};const{Image:L}=window;function B(e){return new Promise(((t,n)=>{const i=new L;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function F(e){return D(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return yield B(t)}))}function H(e,t){return D(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const n=yield function(e,t){const{width:n,height:i}=t;return new Promise(((t,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},r.onerror=function(e){o(e)}}))}(e,t);return yield B(n)}))}function X(e){return"number"==typeof e&&(e>0||e<=0)}function Y(e){return"number"==typeof e&&e>=0}function j(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function U(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const q={x:function(e){return X(e)},y:function(e){return X(e)},w:Y,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:X,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return Y(e)},borderRadius:function(e){return X(e)&&e>=0},color:function(e){return k(e)},imageSrc:function(e){return U(e)||j(e)},imageURL:j,imageBase64:U,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return X(e)&&e>0},lineHeight:function(e){return X(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return X(e)&&e>0}};var G,N=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};class J{constructor(){G.set(this,void 0),function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(e,n):o?o.value=n:t.set(e,n)}(this,G,new Map,"f")}on(e,t){if(N(this,G,"f").has(e)){const n=N(this,G,"f").get(e)||[];null==n||n.push(t),N(this,G,"f").set(e,n)}else N(this,G,"f").set(e,[t])}off(e,t){if(N(this,G,"f").has(e)){const n=N(this,G,"f").get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}N(this,G,"f").set(e,n||[])}}trigger(e,t){const n=N(this,G,"f").get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(N(this,G,"f").has(e)){const t=N(this,G,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){N(this,G,"f").clear()}}function K(e,t,n,i){const o=function(e){return e/180*Math.PI}(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function Q(e,t,n){const i={x:(o=t).x+o.w/2,y:o.y+o.h/2};var o;K(e,t.angle||0,i,(()=>{n(e)}))}function V(e,t){const{viewScaleInfo:n}=t,{x:i,y:o,w:a,h:r,angle:l}=e,{scale:s,offsetTop:c,offsetLeft:d}=n;return{x:i*s+d,y:o*s+c,w:a*s,h:r*s,angle:l}}function Z(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}G=new WeakMap;const _={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function ee(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:a=_.boxSizing,borderWidth:r}=e.detail;Array.isArray(r)&&(o=0);let{x:l,y:s,w:c,h:d}=e,h=[0,0,0,0];if("number"==typeof o){const e=o*i;h=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let f=0;return"number"==typeof r&&(f=(r||0)*i),"border-box"===a?(l=e.x+f/2,s=e.y+f/2,c=e.w-f,d=e.h-f):"content-box"===a?(l=e.x-f/2,s=e.y-f/2,c=e.w+f,d=e.h+f):(l=e.x,s=e.y,c=e.w,d=e.h),c=Math.max(c,1),d=Math.max(d,1),h=h.map((e=>Math.min(e,c/2,d/2))),{x:l,y:s,w:c,h:d,radiusList:h}}function te(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s},d={x:r+i.x*s,y:l+i.y*s},h=e.createLinearGradient(c.x,c.y,d.x,d.y);return o.forEach((e=>{h.addColorStop(e.offset,O(e.color,a))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},d={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},h=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return o.forEach((e=>{h.addColorStop(e.offset,O(e.color,a))})),h}return"#000000"}const ne={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function ie(e){var t,n,i,o;let a=1;return void 0!==(null==(t=null==e?void 0:e.detail)?void 0:t.opacity)&&(null==(n=null==e?void 0:e.detail)?void 0:n.opacity)>=0&&(null==(i=null==e?void 0:e.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==e?void 0:e.detail)?void 0:o.opacity),a}function oe(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=ie(a)*c;!function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r}=n,l=r.devicePixelRatio,{clipPath:s}=(null==o?void 0:o.detail)||{};if(s&&a&&s.commands){const{x:n,y:o,w:r,h:c}=a,{originW:d,originH:h,originX:f,originY:u}=s,w=r/d,g=c/h,v=n-f*w,y=o-u*g;e.save(),e.translate(v,y),e.scale(l*w,l*g);const p=Z(s.commands||[]),m=new Path2D(p);e.clip(m),e.translate(0-v,0-y),e.setTransform(1,0,0,1,0,0),Q(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{e.globalAlpha=d,ae(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),re(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c}})}function ae(e,t,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:f}=ee(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(n+f[0],c),e.arcTo(n+d,c,n+d,c+h,f[1]),e.arcTo(n+d,c+h,n,c+h,f[2]),e.arcTo(n,c+h,n,c,f[3]),e.arcTo(n,c,n+d,c,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(R.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const i=te(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=te(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=i,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const i=s[t];"translate"===i.method?e.translate(i.args[0]+n,i.args[1]+c):"rotate"===i.method?e.rotate(...i.args):"scale"===i.method&&e.scale(...i.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function re(e,t,n){if(0===t.detail.borderWidth)return;if(!k(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=ne.borderColor;!0===k(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=ne.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1),d*=o;let h=[0,0,0,0];if("number"==typeof l){const e=l*o;h=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(h=[l[0]*o,l[1]*o,l[2]*o,l[3]*o]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*o))));let u=0,w=0,g=0,v=0;if(Array.isArray(r)&&(u=(r[0]||0)*o,w=(r[1]||0)*o,g=(r[2]||0)*o,v=(r[3]||0)*o),v||w||u||g){e.lineCap="butt";let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n+=v/2,i+=u/2,o=o-v/2-w/2,a=a-u/2-g/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+w/2,a=a+u/2+g/2):(n=t.x,i=t.y,o=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(n-v/2,i),e.lineTo(n+o+w/2,i),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+g/2),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n-v/2,i+a),e.lineTo(n+o+w/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+g/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n=t.x+d/2,i=t.y+d/2,o=t.w-d,a=t.h-d):"content-box"===c?(n=t.x-d/2,i=t.y-d/2,o=t.w+d,a=t.h+d):(n=t.x,i=t.y,o=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),h=h.map((e=>Math.min(e,o/2,a/2))),e.setLineDash(f),e.lineWidth=d,e.beginPath(),e.moveTo(n+h[0],i),e.arcTo(n+o,i,n+o,i+a,h[1]),e.arcTo(n+o,i+a,n,i+a,h[2]),e.arcTo(n,i+a,n,i,h[3]),e.arcTo(n,i,n+o,i,h[0]),e.closePath(),e.stroke()}e.setLineDash([])}function le(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;q.number(c)?(e.save(),e.shadowColor=r||ne.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}function se(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V(t,{viewScaleInfo:i,viewSizeInfo:o})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{le(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{oe(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{}})}})}))}const ce={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function de(e,t,n){var i;if(!0===(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))return;const{w:o,h:a}=t,{scale:r}=n.viewScaleInfo;if(!(r<1&&(o*r<1||a*r<1)||0===n.parentOpacity))try{switch(t.type){case"rect":se(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{background:s="#000000",borderColor:c="#000000",boxSizing:d,borderWidth:h=0}=i;let f=0;"number"==typeof h&&h>0?f=h:Array.isArray(h)&&"number"==typeof h[0]&&h[0]>0&&(f=h[0]),f*=a.scale;const{x:u,y:w,w:g,h:v}=V({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a,viewSizeInfo:r})||t,y={...t,x:u,y:w,w:g,h:v,angle:o};Q(e,{x:u,y:w,w:g,h:v,angle:o},(()=>{le(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=g/2,n=v/2;const i=u+t,o=w+n;if(f>0&&("border-box"===d?(t-=f,n-=f):"center-line"===d?(t-=f/2,n-=f/2):(t-=f,n-=f)),t>=0&&n>=0){const r=ie(y)*l;if(e.globalAlpha=r,"number"==typeof f&&f>0){const a=f/2+t,r=f/2+n;e.beginPath(),e.strokeStyle=c,e.lineWidth=f,e.circle(i,o,a,r,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const d=te(e,s,{viewElementSize:{x:u,y:w,w:g,h:v},viewScaleInfo:a,opacity:e.globalAlpha});e.fillStyle=d,e.circle(i,o,t,n,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l}}})}))}(e,t,n);break;case"text":!function(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V(t,{viewScaleInfo:i,viewSizeInfo:o})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{oe(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{const n={...ce,...t.detail},o=(n.fontSize||ce.fontSize)*i.scale,a=n.lineHeight?n.lineHeight*i.scale:o;e.fillStyle=t.detail.color||ce.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:o,fontFamily:n.fontFamily});const d=n.text.replace(/\r\n/gi,"\n"),h=a,f=d.split("\n"),u=[];let w=0;f.forEach(((t,n)=>{let i="";if(t.length>0){for(let o=0;o<t.length&&(e.measureText(i+(t[o]||"")).width<e.$doPixelRatio(s)?i+=t[o]||"":(u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),i=t[o]||"",w++),!((w+1)*h>c));o++)if(t.length-1===o&&(w+1)*h<c){u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),n<f.length-1&&w++;break}}else u.push({text:"",width:0})}));let g=0;u.length*h<c&&("top"===t.detail.verticalAlign?g=0:"bottom"===t.detail.verticalAlign?g+=c-u.length*h:g+=(c-u.length*h)/2);{const t=l+g;void 0!==n.textShadowColor&&k(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&q.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&q.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&q.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),u.forEach(((i,o)=>{let a=r;"center"===n.textAlign?a=r+(s-i.width)/2:"right"===n.textAlign&&(a=r+(s-i.width)),e.fillText(i.text,a,t+h*o)}))}}})}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o,viewSizeInfo:a})||t,f={...t,x:l,y:s,w:c,h:d,angle:h};Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{le(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{oe(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=ie(t)*r;const{x:n,y:l,w:s,h:c,radiusList:d}=ee(f,{viewScaleInfo:o,viewSizeInfo:a});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],l),e.arcTo(n+s,l,n+s,l+c,d[1]),e.arcTo(n+s,l+c,n,l+c,d[2]),e.arcTo(n,l+c,n,l,d[3]),e.arcTo(n,l,n+s,l,d[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(i,n,l,s,c),e.globalAlpha=r,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o,viewSizeInfo:a})||t;Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=ie(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o,viewSizeInfo:a})||t;Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=ie(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}(e,t,n);break;case"path":!function(e,t,n){const{detail:i}=t,{originX:o,originY:a,originW:r,originH:l}=i,{viewScaleInfo:s,viewSizeInfo:c,parentOpacity:d}=n,{x:h,y:f,w:u,h:w,angle:g}=V(t,{viewScaleInfo:s,viewSizeInfo:c})||t,v=u/r,y=w/l,p=h-o*v,m=f-a*y,S=s.scale*c.devicePixelRatio,x={...t,x:h,y:f,w:u,h:w,angle:g};Q(e,{x:h,y:f,w:u,h:w,angle:g},(()=>{oe(e,x,{originElem:t,calcElemSize:{x:h,y:f,w:u,h:w,angle:g},viewScaleInfo:s,viewSizeInfo:c,parentOpacity:d,renderContent:()=>{le(e,x,{viewScaleInfo:s,viewSizeInfo:c,renderContent:()=>{e.save(),e.translate(p,m),e.scale(S*v/s.scale,S*y/s.scale);const t=Z(i.commands||[]),n=new Path2D(t);i.fill&&(e.fillStyle=i.fill,e.fill(n)),i.stroke&&0!==i.strokeWidth&&(e.strokeStyle=i.stroke,e.lineWidth=(i.strokeWidth||1)/c.devicePixelRatio,e.lineCap=i.strokeLineCap||"square",e.stroke(n)),e.translate(-p,-m),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:i,viewSizeInfo:o})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{e.globalAlpha=ie(t)*a,le(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{oe(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:c,radiusList:d}=ee(h,{viewScaleInfo:i,viewSizeInfo:o});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+d[0],l),e.arcTo(r+s,l,r+s,l+c,d[1]),e.arcTo(r+s,l+c,r,l+c,d[2]),e.arcTo(r,l+c,r,l,d[3]),e.arcTo(r,l,r+s,l,d[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:i}=n,o={x:i.x+t.x,y:i.y+t.y,w:t.w||i.w,h:t.h||i.h,angle:t.angle},{calculator:r}=n;for(let i=0;i<t.detail.children.length;i++){let l=t.detail.children[i];if(l={...l,x:o.x+l.x,y:o.y+l.y},!0===n.forceDrawAll||(null==r?void 0:r.needRender(l)))try{de(e,l,{...n,parentOpacity:a*ie(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}const he={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function fe(e,t,n){var i;const{elements:o=[]}=t,{parentOpacity:a}=n;for(let t=0;t<o.length;t++){const r=o[t],l={...r,detail:{...he,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.needRender(l)))try{de(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}const ue=["image","svg","html"],we=e=>{var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),"string"==typeof o&&o?/^@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(`${o}`)?o:$(o):$(`${W()}-${e.uuid}-${W()}-${W()}`)};class ge extends J{constructor(){super(),A(this,a),A(this,l),A(this,c),A(this,h),A(this,u),A(this,g),A(this,y),A(this,t,{}),A(this,n,{}),A(this,i,{}),A(this,o,!1),E(this,a,r).call(this,"image",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,o=await B(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),E(this,a,r).call(this,"html",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,o=await H(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),E(this,a,r).call(this,"svg",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,o=await F(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}isDestroyed(){return T(this,o)}destroy(){C(this,o,!0),this.clear(),C(this,t,null),C(this,n,null),C(this,i,null)}load(e,t){!0!==T(this,o)&&(E(this,y,p).call(this,e)||ue.includes(e.type)&&E(this,g,v).call(this,e,t))}getContent(e){var t,n;const o=we(e);return(null==(n=null==(t=T(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return T(this,i)}setLoadItemMap(e){C(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakSet,r=function(e,n){T(this,t)[e]=n},l=new WeakSet,s=function(e){var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),o},c=new WeakSet,d=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:E(this,l,s).call(this,e)}},h=new WeakSet,f=function(e){const t=we(e.element),n=T(this,i)[t];T(this,o)||(n?n.startTime<e.startTime&&(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))},u=new WeakSet,w=function(e){var t;const n=we(e.element),a=null==(t=T(this,i))?void 0:t[n];T(this,o)||(a?a.startTime<e.startTime&&(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))},g=new WeakSet,v=function(e,i){const a=E(this,c,d).call(this,e),r=we(e);if(T(this,n)[r])return;T(this,n)[r]=a;const l=T(this,t)[e.type];"function"!=typeof l||T(this,o)||(a.startTime=Date.now(),l(e,i).then((e=>{T(this,o)||(a.content=e.content,a.endTime=Date.now(),a.status="load",E(this,h,f).call(this,a))})).catch((t=>{console.warn(`Load element source "${a.source}" fail`,t,e),a.endTime=Date.now(),a.status="error",a.error=t,E(this,u,w).call(this,a)})))},y=new WeakSet,p=function(e){var t;const i=we(e),o=null==(t=T(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==E(this,l,s).call(this,e))};return m=new WeakMap,S=new WeakMap,x=new WeakMap,b=new WeakSet,I=function(){const e=T(this,S);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))},e.Renderer=class extends J{constructor(e){super(),A(this,b),A(this,m,void 0),A(this,S,new ge),A(this,x,!1),C(this,m,e),E(this,b,I).call(this)}isDestroyed(){return T(this,x)}destroy(){this.clear(),C(this,m,null),T(this,S).destroy(),C(this,S,null),C(this,x,!0)}updateOptions(e){C(this,m,e)}drawData(e,t){const n=T(this,S),{calculator:i}=T(this,m),o=T(this,m).viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);const a={loader:n,calculator:i,parentElementSize:{x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},elementAssets:e.assets,parentOpacity:1,...t};e.layout?function(e,t,n,i){const{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"layout",type:"group",x:0,y:0,...t},{x:s,y:c,w:d,h:h}=V(l,{viewScaleInfo:o,viewSizeInfo:a})||l,f={...l,x:s,y:c,w:d,h:h,angle:0};if(e.globalAlpha=1,le(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ae(e,f,{viewScaleInfo:o,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:i,viewSizeInfo:o}=n,a={uuid:"layout",type:"group",x:0,y:0,...t},r=V(a,{viewScaleInfo:i,viewSizeInfo:o})||a,l={...a,...r},{x:s,y:c,w:d,h:h,radiusList:f}=ee(l,{viewScaleInfo:i,viewSizeInfo:o});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],c),e.arcTo(s+d,c,s+d,c+h,f[1]),e.arcTo(s+d,c+h,s,c+h,f[2]),e.arcTo(s,c+h,s,c,f[3]),e.arcTo(s,c,s+d,c,f[0]),e.closePath(),e.fill(),e.clip()}i(e),"hidden"===t.detail.overflow&&e.restore(),re(e,f,{viewScaleInfo:o,viewSizeInfo:a}),e.globalAlpha=r}(o,e.layout,a,(()=>{fe(o,e,a)})):fe(o,e,a)}scale(e){const{sharer:t}=T(this,m);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){T(this,S).setLoadItemMap(e)}getLoadItemMap(){return T(this,S).getLoadItemMap()}getLoader(){return T(this,S)}},e.drawRect=se,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idraw/renderer",
3
- "version": "0.4.0-beta.16",
3
+ "version": "0.4.0-beta.18",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -21,11 +21,11 @@
21
21
  "author": "chenshenhai",
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@idraw/types": "^0.4.0-beta.16"
24
+ "@idraw/types": "^0.4.0-beta.18"
25
25
  },
26
26
  "dependencies": {},
27
27
  "peerDependencies": {
28
- "@idraw/util": "^0.4.0-beta.16"
28
+ "@idraw/util": "^0.4.0-beta.18"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public",
@@ -1,2 +0,0 @@
1
- import type { RendererDrawElementOptions, ViewContext2D, DataUnderlay } from '@idraw/types';
2
- export declare function drawUnderlay(ctx: ViewContext2D, underlay: DataUnderlay, opts: RendererDrawElementOptions): void;
@@ -1,23 +0,0 @@
1
- import { drawBox, drawBoxShadow } from './box';
2
- export function drawUnderlay(ctx, underlay, opts) {
3
- const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
4
- const elem = Object.assign({ uuid: 'underlay' }, underlay);
5
- const { x, y, w, h } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
6
- const angle = 0;
7
- const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
8
- drawBoxShadow(ctx, viewElem, {
9
- viewScaleInfo,
10
- viewSizeInfo,
11
- renderContent: () => {
12
- drawBox(ctx, viewElem, {
13
- originElem: elem,
14
- calcElemSize: { x, y, w, h, angle },
15
- viewScaleInfo,
16
- viewSizeInfo,
17
- parentOpacity,
18
- renderContent: () => {
19
- }
20
- });
21
- }
22
- });
23
- }