@idraw/renderer 0.2.0-alpha.24 → 0.3.0-alpha.0

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.
@@ -119,18 +119,18 @@ var iDrawRenderer = (function () {
119
119
  function toColorHexStr(color) {
120
120
  return '#' + color.toString(16);
121
121
  }
122
- function isColorStr$1(color) {
122
+ function isColorStr(color) {
123
123
  return typeof color === 'string' && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color);
124
124
  }
125
- function createUUID$1() {
125
+ function createUUID() {
126
126
  function str4() {
127
127
  return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
128
128
  }
129
- return "" + str4() + str4() + "-" + str4() + "-" + str4() + "-" + str4() + "-" + str4() + str4() + str4();
129
+ return "".concat(str4()).concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4()).concat(str4()).concat(str4());
130
130
  }
131
- function deepClone$2(target) {
131
+ function deepClone(target) {
132
132
  function _clone(t) {
133
- var type = is$1$1(t);
133
+ var type = is$1(t);
134
134
  if (['Null', 'Number', 'String', 'Boolean', 'Undefined'].indexOf(type) >= 0) {
135
135
  return t;
136
136
  }
@@ -152,7 +152,7 @@ var iDrawRenderer = (function () {
152
152
  }
153
153
  return _clone(target);
154
154
  }
155
- function is$1$1(data) {
155
+ function is$1(data) {
156
156
  return Object.prototype.toString.call(data).replace(/[\]|\[]{1,1}/ig, '').split(' ')[1];
157
157
  }
158
158
  function parsePrototype(data) {
@@ -160,7 +160,7 @@ var iDrawRenderer = (function () {
160
160
  var result = typeStr.replace(/(\[object|\])/ig, '').trim();
161
161
  return result;
162
162
  }
163
- var istype$1 = {
163
+ var istype = {
164
164
  type: function (data, lowerCase) {
165
165
  var result = parsePrototype(data);
166
166
  return lowerCase === true ? result.toLocaleLowerCase() : result;
@@ -242,7 +242,7 @@ var iDrawRenderer = (function () {
242
242
  function parseHTMLToDataURL(html, opts) {
243
243
  var width = opts.width, height = opts.height;
244
244
  return new Promise(function (resolve, reject) {
245
- var _svg = "\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + (width || '') + "\" height = \"" + (height || '') + "\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n " + html + "\n </div>\n </foreignObject>\n </svg>\n ";
245
+ var _svg = "\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(width || '', "\" height = \"").concat(height || '', "\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n ").concat(html, "\n </div>\n </foreignObject>\n </svg>\n ");
246
246
  var blob = new Blob([_svg], { type: 'image/svg+xml;charset=utf-8' });
247
247
  var reader = new FileReader();
248
248
  reader.readAsDataURL(blob);
@@ -273,7 +273,7 @@ var iDrawRenderer = (function () {
273
273
  });
274
274
  }
275
275
  var Image = window.Image;
276
- function loadImage$1(src) {
276
+ function loadImage(src) {
277
277
  return new Promise(function (resolve, reject) {
278
278
  var img = new Image;
279
279
  img.onload = function () {
@@ -284,7 +284,7 @@ var iDrawRenderer = (function () {
284
284
  img.src = src;
285
285
  });
286
286
  }
287
- function loadSVG$1(svg) {
287
+ function loadSVG(svg) {
288
288
  return __awaiter(this, void 0, void 0, function () {
289
289
  var dataURL, image;
290
290
  return __generator(this, function (_a) {
@@ -292,7 +292,7 @@ var iDrawRenderer = (function () {
292
292
  case 0: return [4, parseSVGToDataURL(svg)];
293
293
  case 1:
294
294
  dataURL = _a.sent();
295
- return [4, loadImage$1(dataURL)];
295
+ return [4, loadImage(dataURL)];
296
296
  case 2:
297
297
  image = _a.sent();
298
298
  return [2, image];
@@ -300,7 +300,7 @@ var iDrawRenderer = (function () {
300
300
  });
301
301
  });
302
302
  }
303
- function loadHTML$1(html, opts) {
303
+ function loadHTML(html, opts) {
304
304
  return __awaiter(this, void 0, void 0, function () {
305
305
  var dataURL, image;
306
306
  return __generator(this, function (_a) {
@@ -308,7 +308,7 @@ var iDrawRenderer = (function () {
308
308
  case 0: return [4, parseHTMLToDataURL(html, opts)];
309
309
  case 1:
310
310
  dataURL = _a.sent();
311
- return [4, loadImage$1(dataURL)];
311
+ return [4, loadImage(dataURL)];
312
312
  case 2:
313
313
  image = _a.sent();
314
314
  return [2, image];
@@ -316,7 +316,7 @@ var iDrawRenderer = (function () {
316
316
  });
317
317
  });
318
318
  }
319
- var Context$1 = (function () {
319
+ var Context = (function () {
320
320
  function Context(ctx, opts) {
321
321
  this._opts = opts;
322
322
  this._ctx = ctx;
@@ -464,11 +464,11 @@ var iDrawRenderer = (function () {
464
464
  Context.prototype.setFont = function (opts) {
465
465
  var strList = [];
466
466
  if (opts.fontWeight === 'bold') {
467
- strList.push("" + opts.fontWeight);
467
+ strList.push("".concat(opts.fontWeight));
468
468
  }
469
- strList.push(this._doSize(opts.fontSize || 12) + "px");
470
- strList.push("" + (opts.fontFamily || 'sans-serif'));
471
- this._ctx.font = "" + strList.join(' ');
469
+ strList.push("".concat(this._doSize(opts.fontSize || 12), "px"));
470
+ strList.push("".concat(opts.fontFamily || 'sans-serif'));
471
+ this._ctx.font = "".concat(strList.join(' '));
472
472
  };
473
473
  Context.prototype.setTextBaseline = function (baseline) {
474
474
  this._ctx.textBaseline = baseline;
@@ -539,20 +539,20 @@ var iDrawRenderer = (function () {
539
539
  function borderRadius(value) {
540
540
  return number(value) && value >= 0;
541
541
  }
542
- function color$2(value) {
543
- return isColorStr$1(value);
542
+ function color(value) {
543
+ return isColorStr(value);
544
544
  }
545
545
  function imageURL(value) {
546
- return (typeof value === 'string' && /^(http:\/\/|https:\/\/|\.\/|\/)/.test("" + value));
546
+ return (typeof value === 'string' && /^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(value)));
547
547
  }
548
548
  function imageBase64(value) {
549
- return (typeof value === 'string' && /^(data:image\/)/.test("" + value));
549
+ return (typeof value === 'string' && /^(data:image\/)/.test("".concat(value)));
550
550
  }
551
551
  function imageSrc(value) {
552
552
  return (imageBase64(value) || imageURL(value));
553
553
  }
554
554
  function svg(value) {
555
- return (typeof value === 'string' && /^(<svg[\s]{1,}|<svg>)/i.test(("" + value).trim()) && /<\/[\s]{0,}svg>$/i.test(("" + value).trim()));
555
+ return (typeof value === 'string' && /^(<svg[\s]{1,}|<svg>)/i.test("".concat(value).trim()) && /<\/[\s]{0,}svg>$/i.test("".concat(value).trim()));
556
556
  }
557
557
  function html(value) {
558
558
  var result = false;
@@ -587,7 +587,7 @@ var iDrawRenderer = (function () {
587
587
  function fontWeight(value) {
588
588
  return ['bold'].includes(value);
589
589
  }
590
- var is$2 = {
590
+ var is = {
591
591
  x: x,
592
592
  y: y,
593
593
  w: w,
@@ -596,7 +596,7 @@ var iDrawRenderer = (function () {
596
596
  number: number,
597
597
  borderWidth: borderWidth,
598
598
  borderRadius: borderRadius,
599
- color: color$2,
599
+ color: color,
600
600
  imageSrc: imageSrc,
601
601
  imageURL: imageURL,
602
602
  imageBase64: imageBase64,
@@ -612,7 +612,7 @@ var iDrawRenderer = (function () {
612
612
  };
613
613
  function attrs(attrs) {
614
614
  var x = attrs.x, y = attrs.y, w = attrs.w, h = attrs.h, angle = attrs.angle;
615
- if (!(is$2.x(x) && is$2.y(y) && is$2.w(w) && is$2.h(h) && is$2.angle(angle))) {
615
+ if (!(is.x(x) && is.y(y) && is.w(w) && is.h(h) && is.angle(angle))) {
616
616
  return false;
617
617
  }
618
618
  if (!(angle >= -360 && angle <= 360)) {
@@ -623,20 +623,20 @@ var iDrawRenderer = (function () {
623
623
  function box(desc) {
624
624
  if (desc === void 0) { desc = {}; }
625
625
  var borderColor = desc.borderColor, borderRadius = desc.borderRadius, borderWidth = desc.borderWidth;
626
- if (desc.hasOwnProperty('borderColor') && !is$2.color(borderColor)) {
626
+ if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
627
627
  return false;
628
628
  }
629
- if (desc.hasOwnProperty('borderRadius') && !is$2.number(borderRadius)) {
629
+ if (desc.hasOwnProperty('borderRadius') && !is.number(borderRadius)) {
630
630
  return false;
631
631
  }
632
- if (desc.hasOwnProperty('borderWidth') && !is$2.number(borderWidth)) {
632
+ if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
633
633
  return false;
634
634
  }
635
635
  return true;
636
636
  }
637
637
  function rectDesc(desc) {
638
638
  var bgColor = desc.bgColor;
639
- if (desc.hasOwnProperty('bgColor') && !is$2.color(bgColor)) {
639
+ if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
640
640
  return false;
641
641
  }
642
642
  if (!box(desc)) {
@@ -646,68 +646,68 @@ var iDrawRenderer = (function () {
646
646
  }
647
647
  function circleDesc(desc) {
648
648
  var bgColor = desc.bgColor, borderColor = desc.borderColor, borderWidth = desc.borderWidth;
649
- if (desc.hasOwnProperty('bgColor') && !is$2.color(bgColor)) {
649
+ if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
650
650
  return false;
651
651
  }
652
- if (desc.hasOwnProperty('borderColor') && !is$2.color(borderColor)) {
652
+ if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
653
653
  return false;
654
654
  }
655
- if (desc.hasOwnProperty('borderWidth') && !is$2.number(borderWidth)) {
655
+ if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
656
656
  return false;
657
657
  }
658
658
  return true;
659
659
  }
660
660
  function imageDesc(desc) {
661
661
  var src = desc.src;
662
- if (!is$2.imageSrc(src)) {
662
+ if (!is.imageSrc(src)) {
663
663
  return false;
664
664
  }
665
665
  return true;
666
666
  }
667
667
  function svgDesc(desc) {
668
668
  var svg = desc.svg;
669
- if (!is$2.svg(svg)) {
669
+ if (!is.svg(svg)) {
670
670
  return false;
671
671
  }
672
672
  return true;
673
673
  }
674
674
  function htmlDesc(desc) {
675
675
  var html = desc.html;
676
- if (!is$2.html(html)) {
676
+ if (!is.html(html)) {
677
677
  return false;
678
678
  }
679
679
  return true;
680
680
  }
681
681
  function textDesc(desc) {
682
682
  var text = desc.text, color = desc.color, fontSize = desc.fontSize, lineHeight = desc.lineHeight, fontFamily = desc.fontFamily, textAlign = desc.textAlign, fontWeight = desc.fontWeight, bgColor = desc.bgColor, strokeWidth = desc.strokeWidth, strokeColor = desc.strokeColor;
683
- if (!is$2.text(text)) {
683
+ if (!is.text(text)) {
684
684
  return false;
685
685
  }
686
- if (!is$2.color(color)) {
686
+ if (!is.color(color)) {
687
687
  return false;
688
688
  }
689
- if (!is$2.fontSize(fontSize)) {
689
+ if (!is.fontSize(fontSize)) {
690
690
  return false;
691
691
  }
692
- if (desc.hasOwnProperty('bgColor') && !is$2.color(bgColor)) {
692
+ if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
693
693
  return false;
694
694
  }
695
- if (desc.hasOwnProperty('fontWeight') && !is$2.fontWeight(fontWeight)) {
695
+ if (desc.hasOwnProperty('fontWeight') && !is.fontWeight(fontWeight)) {
696
696
  return false;
697
697
  }
698
- if (desc.hasOwnProperty('lineHeight') && !is$2.lineHeight(lineHeight)) {
698
+ if (desc.hasOwnProperty('lineHeight') && !is.lineHeight(lineHeight)) {
699
699
  return false;
700
700
  }
701
- if (desc.hasOwnProperty('fontFamily') && !is$2.fontFamily(fontFamily)) {
701
+ if (desc.hasOwnProperty('fontFamily') && !is.fontFamily(fontFamily)) {
702
702
  return false;
703
703
  }
704
- if (desc.hasOwnProperty('textAlign') && !is$2.textAlign(textAlign)) {
704
+ if (desc.hasOwnProperty('textAlign') && !is.textAlign(textAlign)) {
705
705
  return false;
706
706
  }
707
- if (desc.hasOwnProperty('strokeWidth') && !is$2.strokeWidth(strokeWidth)) {
707
+ if (desc.hasOwnProperty('strokeWidth') && !is.strokeWidth(strokeWidth)) {
708
708
  return false;
709
709
  }
710
- if (desc.hasOwnProperty('strokeColor') && !is$2.color(strokeColor)) {
710
+ if (desc.hasOwnProperty('strokeColor') && !is.color(strokeColor)) {
711
711
  return false;
712
712
  }
713
713
  if (!box(desc)) {
@@ -724,36 +724,25 @@ var iDrawRenderer = (function () {
724
724
  svgDesc: svgDesc,
725
725
  htmlDesc: htmlDesc,
726
726
  };
727
- var index = {
728
- is: is$2,
729
- check: check,
730
- time: {
731
- delay: delay,
732
- compose: compose,
733
- throttle: throttle,
734
- },
735
- loader: {
736
- loadImage: loadImage$1,
737
- loadSVG: loadSVG$1,
738
- loadHTML: loadHTML$1,
739
- },
740
- file: {
741
- downloadImageFromCanvas: downloadImageFromCanvas,
742
- },
743
- color: {
744
- toColorHexStr: toColorHexStr,
745
- toColorHexNum: toColorHexNum,
746
- isColorStr: isColorStr$1,
747
- },
748
- uuid: {
749
- createUUID: createUUID$1
750
- },
751
- istype: istype$1,
752
- data: {
753
- deepClone: deepClone$2,
754
- },
755
- Context: Context$1,
756
- };
727
+ Object.freeze({
728
+ __proto__: null,
729
+ is: is,
730
+ check: check,
731
+ delay: delay,
732
+ compose: compose,
733
+ throttle: throttle,
734
+ loadImage: loadImage,
735
+ loadSVG: loadSVG,
736
+ loadHTML: loadHTML,
737
+ downloadImageFromCanvas: downloadImageFromCanvas,
738
+ toColorHexStr: toColorHexStr,
739
+ toColorHexNum: toColorHexNum,
740
+ isColorStr: isColorStr,
741
+ createUUID: createUUID,
742
+ istype: istype,
743
+ deepClone: deepClone,
744
+ Context: Context
745
+ });
757
746
 
758
747
  function parseAngleToRadian(angle) {
759
748
  return angle / 180 * Math.PI;
@@ -785,7 +774,6 @@ var iDrawRenderer = (function () {
785
774
  }
786
775
  }
787
776
 
788
- var is$1 = index.is, istype = index.istype, color$1 = index.color;
789
777
  function clearContext(ctx) {
790
778
  ctx.setFillStyle('#000000');
791
779
  ctx.setStrokeStyle('#000000');
@@ -836,7 +824,7 @@ var iDrawRenderer = (function () {
836
824
  }
837
825
  var bw = elem.desc.borderWidth;
838
826
  var borderColor = '#000000';
839
- if (color$1.isColorStr(elem.desc.borderColor) === true) {
827
+ if (isColorStr(elem.desc.borderColor) === true) {
840
828
  borderColor = elem.desc.borderColor;
841
829
  }
842
830
  var x = elem.x - bw / 2;
@@ -849,16 +837,16 @@ var iDrawRenderer = (function () {
849
837
  r = r + bw / 2;
850
838
  }
851
839
  var desc = elem.desc;
852
- if (desc.shadowColor !== undefined && color$1.isColorStr(desc.shadowColor)) {
840
+ if (desc.shadowColor !== undefined && isColorStr(desc.shadowColor)) {
853
841
  ctx.setShadowColor(desc.shadowColor);
854
842
  }
855
- if (desc.shadowOffsetX !== undefined && is$1.number(desc.shadowOffsetX)) {
843
+ if (desc.shadowOffsetX !== undefined && is.number(desc.shadowOffsetX)) {
856
844
  ctx.setShadowOffsetX(desc.shadowOffsetX);
857
845
  }
858
- if (desc.shadowOffsetY !== undefined && is$1.number(desc.shadowOffsetY)) {
846
+ if (desc.shadowOffsetY !== undefined && is.number(desc.shadowOffsetY)) {
859
847
  ctx.setShadowOffsetY(desc.shadowOffsetY);
860
848
  }
861
- if (desc.shadowBlur !== undefined && is$1.number(desc.shadowBlur)) {
849
+ if (desc.shadowBlur !== undefined && is.number(desc.shadowBlur)) {
862
850
  ctx.setShadowBlur(desc.shadowBlur);
863
851
  }
864
852
  ctx.beginPath();
@@ -905,7 +893,6 @@ var iDrawRenderer = (function () {
905
893
  });
906
894
  }
907
895
 
908
- var is = index.is, color = index.color;
909
896
  function drawText(ctx, elem, loader) {
910
897
  clearContext(ctx);
911
898
  drawBox(ctx, elem, elem.desc.bgColor || 'transparent');
@@ -926,41 +913,52 @@ var iDrawRenderer = (function () {
926
913
  var fontHeight = desc.lineHeight || desc.fontSize;
927
914
  var descTextList = descText.split('\n');
928
915
  var lines = [];
929
- descTextList.forEach(function (tempText) {
916
+ var lineNum = 0;
917
+ descTextList.forEach(function (tempText, idx) {
930
918
  var lineText = '';
931
- var lineNum = 0;
932
- for (var i = 0; i < tempText.length; i++) {
933
- if (ctx.measureText(lineText + (tempText[i] || '')).width < ctx.calcDeviceNum(elem.w)) {
934
- lineText += (tempText[i] || '');
935
- }
936
- else {
937
- lines.push({
938
- text: lineText,
939
- width: ctx.calcScreenNum(ctx.measureText(lineText).width),
940
- });
941
- lineText = (tempText[i] || '');
942
- lineNum++;
943
- }
944
- if ((lineNum + 1) * fontHeight > elem.h) {
945
- break;
946
- }
947
- if (lineText && tempText.length - 1 === i) {
948
- if ((lineNum + 1) * fontHeight < elem.h) {
919
+ if (tempText.length > 0) {
920
+ for (var i = 0; i < tempText.length; i++) {
921
+ if (ctx.measureText(lineText + (tempText[i] || '')).width < ctx.calcDeviceNum(elem.w)) {
922
+ lineText += (tempText[i] || '');
923
+ }
924
+ else {
949
925
  lines.push({
950
926
  text: lineText,
951
927
  width: ctx.calcScreenNum(ctx.measureText(lineText).width),
952
928
  });
929
+ lineText = (tempText[i] || '');
930
+ lineNum++;
931
+ }
932
+ if ((lineNum + 1) * fontHeight > elem.h) {
953
933
  break;
954
934
  }
935
+ if (tempText.length - 1 === i) {
936
+ if ((lineNum + 1) * fontHeight < elem.h) {
937
+ lines.push({
938
+ text: lineText,
939
+ width: ctx.calcScreenNum(ctx.measureText(lineText).width),
940
+ });
941
+ if (idx < descTextList.length - 1) {
942
+ lineNum++;
943
+ }
944
+ break;
945
+ }
946
+ }
955
947
  }
956
948
  }
949
+ else {
950
+ lines.push({
951
+ text: '',
952
+ width: 0,
953
+ });
954
+ }
957
955
  });
958
956
  {
959
957
  var _y_1 = elem.y;
960
958
  if (lines.length * fontHeight < elem.h) {
961
959
  _y_1 += ((elem.h - lines.length * fontHeight) / 2);
962
960
  }
963
- if (desc.textShadowColor !== undefined && color.isColorStr(desc.textShadowColor)) {
961
+ if (desc.textShadowColor !== undefined && isColorStr(desc.textShadowColor)) {
964
962
  ctx.setShadowColor(desc.textShadowColor);
965
963
  }
966
964
  if (desc.textShadowOffsetX !== undefined && is.number(desc.textShadowOffsetX)) {
@@ -984,7 +982,7 @@ var iDrawRenderer = (function () {
984
982
  });
985
983
  clearContext(ctx);
986
984
  }
987
- if (color.isColorStr(desc.strokeColor) && desc.strokeWidth !== undefined && desc.strokeWidth > 0) {
985
+ if (isColorStr(desc.strokeColor) && desc.strokeWidth !== undefined && desc.strokeWidth > 0) {
988
986
  var _y_2 = elem.y;
989
987
  if (lines.length * fontHeight < elem.h) {
990
988
  _y_2 += ((elem.h - lines.length * fontHeight) / 2);
@@ -1036,7 +1034,6 @@ var iDrawRenderer = (function () {
1036
1034
  });
1037
1035
  }
1038
1036
 
1039
- var isColorStr = index.color.isColorStr;
1040
1037
  function drawContext(ctx, data, loader) {
1041
1038
  var _a;
1042
1039
  clearContext(ctx);
@@ -1138,8 +1135,6 @@ var iDrawRenderer = (function () {
1138
1135
  return html.replace(/<script[\s\S]*?<\/script>/ig, '');
1139
1136
  }
1140
1137
 
1141
- var _a$1 = index.loader, loadImage = _a$1.loadImage, loadSVG = _a$1.loadSVG, loadHTML = _a$1.loadHTML;
1142
- var deepClone$1 = index.data.deepClone;
1143
1138
  var LoaderStatus;
1144
1139
  (function (LoaderStatus) {
1145
1140
  LoaderStatus["FREE"] = "free";
@@ -1235,7 +1230,7 @@ var iDrawRenderer = (function () {
1235
1230
  source: source,
1236
1231
  elemW: elemW,
1237
1232
  elemH: elemH,
1238
- element: deepClone$1(elem),
1233
+ element: deepClone(elem),
1239
1234
  };
1240
1235
  };
1241
1236
  Loader.prototype._loadTask = function () {
@@ -1448,9 +1443,6 @@ var iDrawRenderer = (function () {
1448
1443
 
1449
1444
  var _a, _b, _c;
1450
1445
  var requestAnimationFrame = window.requestAnimationFrame;
1451
- var createUUID = index.uuid.createUUID;
1452
- var deepClone = index.data.deepClone;
1453
- var Context = index.Context;
1454
1446
  var DrawStatus;
1455
1447
  (function (DrawStatus) {
1456
1448
  DrawStatus["NULL"] = "null";
@@ -1585,6 +1577,11 @@ var iDrawRenderer = (function () {
1585
1577
  return Renderer;
1586
1578
  }(RendererEvent));
1587
1579
 
1588
- return Renderer;
1580
+ var default_1 = /*#__PURE__*/Object.freeze({
1581
+ __proto__: null,
1582
+ Renderer: Renderer
1583
+ });
1584
+
1585
+ return default_1;
1589
1586
 
1590
1587
  })();
@@ -1 +1 @@
1
- var iDrawRenderer=function(){'use strict';var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};var e=function(){return e=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},e.apply(this,arguments)};function o(t,e,o,r){return new(o||(o=Promise))((function(n,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function r(t,e){var o,r,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,r&&(n=2&i[0]?r.return:i[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,i[1])).done)return n;switch(r=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){s.label=i[1];break}if(6===i[0]&&s.label<n[1]){s.label=n[1],n=i;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(i);break}n[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{o=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function n(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function i(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var s={type:function(t,e){var o=i(t);return!0===e?o.toLocaleLowerCase():o},array:function(t){return'Array'===i(t)},json:function(t){return'Object'===i(t)},function:function(t){return'Function'===i(t)},asyncFunction:function(t){return'AsyncFunction'===i(t)},string:function(t){return'String'===i(t)},number:function(t){return'Number'===i(t)},undefined:function(t){return'Undefined'===i(t)},null:function(t){return'Null'===i(t)},promise:function(t){return'Promise'===i(t)}},a=function(){return a=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},a.apply(this,arguments)};function u(t,e,o,r){return new(o||(o=Promise))((function(n,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function l(t,e){var o,r,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,r&&(n=2&i[0]?r.return:i[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,i[1])).done)return n;switch(r=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){s.label=i[1];break}if(6===i[0]&&s.label<n[1]){s.label=n[1],n=i;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(i);break}n[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{o=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function c(t,e){var o=e.width,r=e.height;return new Promise((function(e,n){var i=new Blob(["\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+(o||'')+"\" height = \""+(r||'')+"\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n "+t+"\n </div>\n </foreignObject>\n </svg>\n "],{type:'image/svg+xml;charset=utf-8'}),s=new FileReader;s.readAsDataURL(i),s.onload=function(t){var o,r=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(r)},s.onerror=function(t){n(t)}}))}function h(t){return new Promise((function(e,o){var r=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),n=new FileReader;n.readAsDataURL(r),n.onload=function(t){var o,r=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(r)},n.onerror=function(t){o(t)}}))}var f=window.Image;function d(t){return new Promise((function(e,o){var r=new f;r.onload=function(){e(r)},r.onabort=o,r.onerror=o,r.src=t}))}var p=function(){function t(t,e){this._opts=e,this._ctx=t,this._transform={scale:1,scrollX:0,scrollY:0}}return t.prototype.getContext=function(){return this._ctx},t.prototype.resetSize=function(t){this._opts=a(a({},this._opts),t)},t.prototype.calcDeviceNum=function(t){return t*this._opts.devicePixelRatio},t.prototype.calcScreenNum=function(t){return t/this._opts.devicePixelRatio},t.prototype.getSize=function(){return{width:this._opts.width,height:this._opts.height,contextWidth:this._opts.contextWidth,contextHeight:this._opts.contextHeight,devicePixelRatio:this._opts.devicePixelRatio}},t.prototype.setTransform=function(t){this._transform=a(a({},this._transform),t)},t.prototype.getTransform=function(){return{scale:this._transform.scale,scrollX:this._transform.scrollX,scrollY:this._transform.scrollY}},t.prototype.setFillStyle=function(t){this._ctx.fillStyle=t},t.prototype.fill=function(t){return this._ctx.fill(t||'nonzero')},t.prototype.arc=function(t,e,o,r,n,i){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(o),r,n,i)},t.prototype.rect=function(t,e,o,r){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(r))},t.prototype.fillRect=function(t,e,o,r){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(r))},t.prototype.clearRect=function(t,e,o,r){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(r))},t.prototype.beginPath=function(){return this._ctx.beginPath()},t.prototype.closePath=function(){return this._ctx.closePath()},t.prototype.lineTo=function(t,e){return this._ctx.lineTo(this._doSize(t),this._doSize(e))},t.prototype.moveTo=function(t,e){return this._ctx.moveTo(this._doSize(t),this._doSize(e))},t.prototype.arcTo=function(t,e,o,r,n){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(r),this._doSize(n))},t.prototype.setLineWidth=function(t){return this._ctx.lineWidth=this._doSize(t)},t.prototype.setLineDash=function(t){var e=this;return this._ctx.setLineDash(t.map((function(t){return e._doSize(t)})))},t.prototype.isPointInPath=function(t,e){return this._ctx.isPointInPath(this._doX(t),this._doY(e))},t.prototype.isPointInPathWithoutScroll=function(t,e){return this._ctx.isPointInPath(this._doSize(t),this._doSize(e))},t.prototype.setStrokeStyle=function(t){this._ctx.strokeStyle=t},t.prototype.stroke=function(){return this._ctx.stroke()},t.prototype.translate=function(t,e){return this._ctx.translate(this._doSize(t),this._doSize(e))},t.prototype.rotate=function(t){return this._ctx.rotate(t)},t.prototype.drawImage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var o=t[0],r=t[1],n=t[2],i=t[3],s=t[4],a=t[t.length-4],u=t[t.length-3],l=t[t.length-2],c=t[t.length-1];return 9===t.length?this._ctx.drawImage(o,this._doSize(r),this._doSize(n),this._doSize(i),this._doSize(s),this._doSize(a),this._doSize(u),this._doSize(l),this._doSize(c)):this._ctx.drawImage(o,this._doSize(a),this._doSize(u),this._doSize(l),this._doSize(c))},t.prototype.createPattern=function(t,e){return this._ctx.createPattern(t,e)},t.prototype.measureText=function(t){return this._ctx.measureText(t)},t.prototype.setTextAlign=function(t){this._ctx.textAlign=t},t.prototype.fillText=function(t,e,o,r){return void 0!==r?this._ctx.fillText(t,this._doSize(e),this._doSize(o),this._doSize(r)):this._ctx.fillText(t,this._doSize(e),this._doSize(o))},t.prototype.strokeText=function(t,e,o,r){return void 0!==r?this._ctx.strokeText(t,this._doSize(e),this._doSize(o),this._doSize(r)):this._ctx.strokeText(t,this._doSize(e),this._doSize(o))},t.prototype.setFont=function(t){var e=[];'bold'===t.fontWeight&&e.push(""+t.fontWeight),e.push(this._doSize(t.fontSize||12)+"px"),e.push(""+(t.fontFamily||'sans-serif')),this._ctx.font=""+e.join(' ')},t.prototype.setTextBaseline=function(t){this._ctx.textBaseline=t},t.prototype.setGlobalAlpha=function(t){this._ctx.globalAlpha=t},t.prototype.save=function(){this._ctx.save()},t.prototype.restore=function(){this._ctx.restore()},t.prototype.scale=function(t,e){this._ctx.scale(t,e)},t.prototype.setShadowColor=function(t){this._ctx.shadowColor=t},t.prototype.setShadowOffsetX=function(t){this._ctx.shadowOffsetX=this._doSize(t)},t.prototype.setShadowOffsetY=function(t){this._ctx.shadowOffsetY=this._doSize(t)},t.prototype.setShadowBlur=function(t){this._ctx.shadowBlur=this._doSize(t)},t.prototype.ellipse=function(t,e,o,r,n,i,s,a){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(r),n,i,s,a)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,o=e.scale,r=(t-e.scrollX)/o;return this._doSize(r)},t.prototype._doY=function(t){var e=this._transform,o=e.scale,r=(t-e.scrollY)/o;return this._doSize(r)},t}();function g(t){return'number'==typeof t&&(t>0||t<=0)}function v(t){return'number'==typeof t&&t>=0}function _(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(""+t)}function y(t){return'string'==typeof t&&/^(data:image\/)/.test(""+t)}var m={x:function(t){return g(t)},y:function(t){return g(t)},w:v,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:g,borderWidth:function(t){return v(t)},borderRadius:function(t){return g(t)&&t>=0},color:function(t){return n(t)},imageSrc:function(t){return y(t)||_(t)},imageURL:_,imageBase64:y,svg:function(t){return'string'==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test((""+t).trim())&&/<\/[\s]{0,}svg>$/i.test((""+t).trim())},html:function(t){var e=!1;if('string'==typeof t){var o=document.createElement('div');o.innerHTML=t,o.children.length>0&&(e=!0),o=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return g(t)&&t>0},lineHeight:function(t){return g(t)&&t>0},textAlign:function(t){return['center','left','right'].includes(t)},fontFamily:function(t){return'string'==typeof t&&t.length>0},fontWeight:function(t){return['bold'].includes(t)},strokeWidth:function(t){return g(t)&&t>0}};function w(t){void 0===t&&(t={});var e=t.borderColor,o=t.borderRadius,r=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!m.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!m.number(o))&&!(t.hasOwnProperty('borderWidth')&&!m.number(r)))}var x={attrs:function(t){var e=t.x,o=t.y,r=t.w,n=t.h,i=t.angle;return!!(m.x(e)&&m.y(o)&&m.w(r)&&m.h(n)&&m.angle(i))&&(i>=-360&&i<=360)},textDesc:function(t){var e=t.text,o=t.color,r=t.fontSize,n=t.lineHeight,i=t.fontFamily,s=t.textAlign,a=t.fontWeight,u=t.bgColor,l=t.strokeWidth,c=t.strokeColor;return!!m.text(e)&&(!!m.color(o)&&(!!m.fontSize(r)&&(!(t.hasOwnProperty('bgColor')&&!m.color(u))&&(!(t.hasOwnProperty('fontWeight')&&!m.fontWeight(a))&&(!(t.hasOwnProperty('lineHeight')&&!m.lineHeight(n))&&(!(t.hasOwnProperty('fontFamily')&&!m.fontFamily(i))&&(!(t.hasOwnProperty('textAlign')&&!m.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!m.strokeWidth(l))&&(!(t.hasOwnProperty('strokeColor')&&!m.color(c))&&!!w(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!m.color(e))&&!!w(t)},circleDesc:function(t){var e=t.bgColor,o=t.borderColor,r=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!m.color(e))&&(!(t.hasOwnProperty('borderColor')&&!m.color(o))&&!(t.hasOwnProperty('borderWidth')&&!m.number(r)))},imageDesc:function(t){var e=t.src;return!!m.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!m.svg(e)},htmlDesc:function(t){var e=t.html;return!!m.html(e)}},S={is:m,check:x,time:{delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,o){return function r(n){var i=t[n];n===t.length&&o&&(i=o);if(!i)return Promise.resolve();try{return Promise.resolve(i(e,r.bind(null,n+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var o=-1;return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];o>0||(o=setTimeout((function(){t.apply(void 0,r),o=-1}),e))}}},loader:{loadImage:d,loadSVG:function(t){return u(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,h(t)];case 1:return[4,d(e.sent())];case 2:return[2,e.sent()]}}))}))},loadHTML:function(t,e){return u(this,void 0,void 0,(function(){return l(this,(function(o){switch(o.label){case 0:return[4,c(t,e)];case 1:return[4,d(o.sent())];case 2:return[2,o.sent()]}}))}))}},file:{downloadImageFromCanvas:function(t,e){var o=e.filename,r=e.type,n=void 0===r?'image/jpeg':r,i=t.toDataURL(n),s=document.createElement('a');s.href=i,s.download=o;var a=document.createEvent('MouseEvents');a.initEvent('click',!0,!1),s.dispatchEvent(a)}},color:{toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:n},uuid:{createUUID:function(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return""+t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}},istype:s,data:{deepClone:function(t){return function t(e){var o,r=(o=e,Object.prototype.toString.call(o).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(r)>=0)return e;if('Array'===r){var n=[];return e.forEach((function(e){n.push(t(e))})),n}if('Object'===r){var i={};return Object.keys(e).forEach((function(o){i[o]=t(e[o])})),i}}(t)}},Context:p};function b(t,e,o){var r=function(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}(e),n=function(t){return t/180*Math.PI}(e.angle||0);return function(t,e,o,r){e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(o),t.translate(-e.x,-e.y));r(t),e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(-o),t.translate(-e.x,-e.y))}(t,r,n||0,o)}var z=S.is,L=S.istype,D=S.color;function E(t){t.setFillStyle('#000000'),t.setStrokeStyle('#000000'),t.setLineDash([]),t.setGlobalAlpha(1),t.setShadowColor('#00000000'),t.setShadowOffsetX(0),t.setShadowOffsetY(0),t.setShadowBlur(0)}function C(t,e,o){E(t),function(t,e){E(t),b(t,e,(function(){if(e.desc.borderWidth&&e.desc.borderWidth>0){var o=e.desc.borderWidth,r='#000000';!0===D.isColorStr(e.desc.borderColor)&&(r=e.desc.borderColor);var n=e.x-o/2,i=e.y-o/2,s=e.w+o,a=e.h+o,u=e.desc.borderRadius||0;(u=Math.min(u,s/2,a/2))<s/2&&u<a/2&&(u+=o/2);var l=e.desc;void 0!==l.shadowColor&&D.isColorStr(l.shadowColor)&&t.setShadowColor(l.shadowColor),void 0!==l.shadowOffsetX&&z.number(l.shadowOffsetX)&&t.setShadowOffsetX(l.shadowOffsetX),void 0!==l.shadowOffsetY&&z.number(l.shadowOffsetY)&&t.setShadowOffsetY(l.shadowOffsetY),void 0!==l.shadowBlur&&z.number(l.shadowBlur)&&t.setShadowBlur(l.shadowBlur),t.beginPath(),t.setLineWidth(o),t.setStrokeStyle(r),t.moveTo(n+u,i),t.arcTo(n+s,i,n+s,i+a,u),t.arcTo(n+s,i+a,n,i+a,u),t.arcTo(n,i+a,n,i,u),t.arcTo(n,i,n+s,i,u),t.closePath(),t.stroke()}}))}(t,e),E(t),b(t,e,(function(){var r=e.x,n=e.y,i=e.w,s=e.h,a=e.desc.borderRadius||0;(i<2*(a=Math.min(a,i/2,s/2))||s<2*a)&&(a=0),t.beginPath(),t.moveTo(r+a,n),t.arcTo(r+i,n,r+i,n+s,a),t.arcTo(r+i,n+s,r,n+s,a),t.arcTo(r,n+s,r,n,a),t.arcTo(r,n,r+i,n,a),t.closePath(),('string'==typeof o||['CanvasPattern'].includes(L.type(o)))&&t.setFillStyle(o),t.fill()}))}function O(t,e){C(t,e,e.desc.bgColor)}function P(t,e,o){var r=o.getContent(e.uuid);b(t,e,(function(){r&&t.drawImage(r,e.x,e.y,e.w,e.h)}))}function k(t,e,o){var r=o.getContent(e.uuid);b(t,e,(function(){r&&t.drawImage(r,e.x,e.y,e.w,e.h)}))}function T(t,e,o){var r=o.getContent(e.uuid);b(t,e,(function(){r&&t.drawImage(r,e.x,e.y,e.w,e.h)}))}var W=S.is,R=S.color;function F(t,o,r){E(t),C(t,o,o.desc.bgColor||'transparent'),b(t,o,(function(){var r=e({fontSize:12,fontFamily:'sans-serif',textAlign:'center'},o.desc);t.setFillStyle(o.desc.color),t.setTextBaseline('top'),t.setFont({fontWeight:r.fontWeight,fontSize:r.fontSize,fontFamily:r.fontFamily});var n=r.text.replace(/\r\n/gi,'\n'),i=r.lineHeight||r.fontSize,s=n.split('\n'),a=[];s.forEach((function(e){for(var r='',n=0,s=0;s<e.length&&(t.measureText(r+(e[s]||'')).width<t.calcDeviceNum(o.w)?r+=e[s]||'':(a.push({text:r,width:t.calcScreenNum(t.measureText(r).width)}),r=e[s]||'',n++),!((n+1)*i>o.h));s++)if(r&&e.length-1===s&&(n+1)*i<o.h){a.push({text:r,width:t.calcScreenNum(t.measureText(r).width)});break}}));var u=o.y;if(a.length*i<o.h&&(u+=(o.h-a.length*i)/2),void 0!==r.textShadowColor&&R.isColorStr(r.textShadowColor)&&t.setShadowColor(r.textShadowColor),void 0!==r.textShadowOffsetX&&W.number(r.textShadowOffsetX)&&t.setShadowOffsetX(r.textShadowOffsetX),void 0!==r.textShadowOffsetY&&W.number(r.textShadowOffsetY)&&t.setShadowOffsetY(r.textShadowOffsetY),void 0!==r.textShadowBlur&&W.number(r.textShadowBlur)&&t.setShadowBlur(r.textShadowBlur),a.forEach((function(e,n){var s=o.x;'center'===r.textAlign?s=o.x+(o.w-e.width)/2:'right'===r.textAlign&&(s=o.x+(o.w-e.width)),t.fillText(e.text,s,u+i*n)})),E(t),R.isColorStr(r.strokeColor)&&void 0!==r.strokeWidth&&r.strokeWidth>0){var l=o.y;a.length*i<o.h&&(l+=(o.h-a.length*i)/2),a.forEach((function(e,n){var s=o.x;'center'===r.textAlign?s=o.x+(o.w-e.width)/2:'right'===r.textAlign&&(s=o.x+(o.w-e.width)),void 0!==r.strokeColor&&t.setStrokeStyle(r.strokeColor),void 0!==r.strokeWidth&&r.strokeWidth>0&&t.setLineWidth(r.strokeWidth),t.strokeText(e.text,s,l+i*n)}))}}))}function A(t,e){E(t),b(t,e,(function(t){var o=e.x,r=e.y,n=e.w,i=e.h,s=e.desc,a=s.bgColor,u=void 0===a?'#000000':a,l=s.borderColor,c=void 0===l?'#000000':l,h=s.borderWidth,f=void 0===h?0:h,d=n/2,p=i/2,g=o+d,v=r+p;if(f&&f>0){var _=f/2+d,y=f/2+p;t.beginPath(),t.setStrokeStyle(c),t.setLineWidth(f),t.ellipse(g,v,_,y,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath(),t.setFillStyle(u),t.ellipse(g,v,d,p,0,0,2*Math.PI),t.closePath(),t.fill()}))}var I=S.color.isColorStr;function H(t,e,o){var r;E(t);var n=t.getSize();if(t.clearRect(0,0,n.contextWidth,n.contextHeight),'string'==typeof e.bgColor&&I(e.bgColor)&&function(t,e){var o=t.getSize();t.setFillStyle(e),t.fillRect(0,0,o.contextWidth,o.contextHeight)}(t,e.bgColor),e.elements.length>0)for(var i=0;i<e.elements.length;i++){var s=e.elements[i];if(!0!==(null===(r=null==s?void 0:s.operation)||void 0===r?void 0:r.invisible))switch(s.type){case'rect':O(t,s);break;case'text':F(t,s);break;case'image':P(t,s,o);break;case'svg':k(t,s,o);break;case'html':T(t,s,o);break;case'circle':A(t,s)}}}var U=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var r=0;r<(null==o?void 0:o.length);r++)if(o[r]===e){o.splice(r,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}();var j,N=S.loader,B=N.loadImage,M=N.loadSVG,X=N.loadHTML,Y=S.data.deepClone;!function(t){t.FREE="free",t.LOADING="loading",t.COMPLETE="complete"}(j||(j={}));var Q,G,Z,q,V=function(){function t(t){this._currentLoadData={},this._currentUUIDQueue=[],this._storageLoadData={},this._status=j.FREE,this._waitingLoadQueue=[],this._opts=t,this._event=new U,this._waitingLoadQueue=[]}return t.prototype.load=function(t,e){var o=this._resetLoadData(t,e),r=o[0],n=o[1];this._status===j.FREE||this._status===j.COMPLETE?(this._currentUUIDQueue=r,this._currentLoadData=n,this._loadTask()):this._status===j.LOADING&&r.length>0&&this._waitingLoadQueue.push({uuidQueue:r,loadData:n})},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype.isComplete=function(){return this._status===j.COMPLETE},t.prototype.getContent=function(t){var e;return'loaded'===(null===(e=this._storageLoadData[t])||void 0===e?void 0:e.status)?this._storageLoadData[t].content:null},t.prototype._resetLoadData=function(t,e){for(var o={},r=[],n=this._storageLoadData,i=t.elements.length-1;i>=0;i--){var s=t.elements[i];['image','svg','html'].includes(s.type)&&(n[s.uuid]?e.includes(s.uuid)&&(o[s.uuid]=this._createEmptyLoadItem(s),r.push(s.uuid)):(o[s.uuid]=this._createEmptyLoadItem(s),r.push(s.uuid)))}return[r,o]},t.prototype._createEmptyLoadItem=function(t){var e='',o=t.type,r=t.w,n=t.h;if('image'===t.type)e=(i=t).desc.src||'';else if('svg'===t.type){e=(i=t).desc.svg||''}else if('html'===t.type){var i;e=function(t){return t.replace(/<script[\s\S]*?<\/script>/gi,'')}((i=t).desc.html||''),r=i.desc.width||t.w,n=i.desc.height||t.h}return{uuid:t.uuid,type:o,status:'null',content:null,source:e,elemW:r,elemH:n,element:Y(t)}},t.prototype._loadTask=function(){var t=this;if(this._status!==j.LOADING){if(this._status=j.LOADING,0===this._currentUUIDQueue.length){if(0===this._waitingLoadQueue.length)return this._status=j.COMPLETE,void this._event.trigger('complete',void 0);var e=this._waitingLoadQueue.shift();if(e){var o=e.uuidQueue,r=e.loadData;this._currentLoadData=r,this._currentUUIDQueue=o}}var n=this._opts.maxParallelNum,i=this._currentUUIDQueue.splice(0,n),s={};i.forEach((function(t,e){s[t]=e}));var a=[],u=function(){if(a.length>=n)return!1;if(0===i.length)return!0;for(var e=function(e){var o=i.shift();if(void 0===o)return"break";a.push(o),t._loadElementSource(t._currentLoadData[o]).then((function(e){var r,n;a.splice(a.indexOf(o),1);var s=u();t._storageLoadData[o]={uuid:o,type:t._currentLoadData[o].type,status:'loaded',content:e,source:t._currentLoadData[o].source,elemW:t._currentLoadData[o].elemW,elemH:t._currentLoadData[o].elemH,element:t._currentLoadData[o].element},0===a.length&&0===i.length&&!0===s&&(t._status=j.FREE,t._loadTask()),t._event.trigger('load',{uuid:null===(r=t._storageLoadData[o])||void 0===r?void 0:r.uuid,type:t._storageLoadData[o].type,status:t._storageLoadData[o].status,content:t._storageLoadData[o].content,source:t._storageLoadData[o].source,elemW:t._storageLoadData[o].elemW,elemH:t._storageLoadData[o].elemH,element:null===(n=t._storageLoadData[o])||void 0===n?void 0:n.element})})).catch((function(e){var r,n,s,l,c,h,f,d,p,g,v,_;console.warn(e),a.splice(a.indexOf(o),1);var y=u();t._currentLoadData[o]&&(t._storageLoadData[o]={uuid:o,type:null===(r=t._currentLoadData[o])||void 0===r?void 0:r.type,status:'fail',content:null,error:e,source:null===(n=t._currentLoadData[o])||void 0===n?void 0:n.source,elemW:null===(s=t._currentLoadData[o])||void 0===s?void 0:s.elemW,elemH:null===(l=t._currentLoadData[o])||void 0===l?void 0:l.elemH,element:null===(c=t._currentLoadData[o])||void 0===c?void 0:c.element}),0===a.length&&0===i.length&&!0===y&&(t._status=j.FREE,t._loadTask()),t._currentLoadData[o]&&t._event.trigger('error',{uuid:o,type:null===(h=t._storageLoadData[o])||void 0===h?void 0:h.type,status:null===(f=t._storageLoadData[o])||void 0===f?void 0:f.status,content:null===(d=t._storageLoadData[o])||void 0===d?void 0:d.content,source:null===(p=t._storageLoadData[o])||void 0===p?void 0:p.source,elemW:null===(g=t._storageLoadData[o])||void 0===g?void 0:g.elemW,elemH:null===(v=t._storageLoadData[o])||void 0===v?void 0:v.elemH,element:null===(_=t._storageLoadData[o])||void 0===_?void 0:_.element})}))},o=a.length;o<n;o++){if("break"===e())break}return!1};u()}},t.prototype._loadElementSource=function(t){return o(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return t&&'image'===t.type?[4,B(t.source)]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return t&&'svg'===t.type?[4,M(t.source)]:[3,4];case 4:return t&&'html'===t.type?[4,X(t.source,{width:t.elemW,height:t.elemH})]:[3,6];case 6:throw Error('Element\'s source is not support!')}}))}))},t}(),$=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var r=0;r<(null==o?void 0:o.length);r++)if(o[r]===e){o.splice(r,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}(),J=Symbol('_queue'),K=Symbol('_ctx'),tt=Symbol('_status'),et=Symbol('_loader'),ot=Symbol('_opts'),rt=Symbol('_freeze'),nt=Symbol('_drawFrame'),it=Symbol('_retainQueueOneItem'),st=window.requestAnimationFrame,at=S.uuid.createUUID,ut=S.data.deepClone,lt=S.Context;return function(t){t.NULL="null",t.FREE="free",t.DRAWING="drawing",t.FREEZE="freeze"}(q||(q={})),function(e){function o(t){var o=e.call(this)||this;return o[Q]=[],o[G]=null,o[Z]=q.NULL,o[ot]=t,o[et]=new V({maxParallelNum:6}),o[et].on('load',(function(t){o[nt](),o.trigger('load',{element:t.element})})),o[et].on('error',(function(t){o.trigger('error',{element:t.element,error:t.error})})),o[et].on('complete',(function(){o.trigger('loadComplete',{t:Date.now()})})),o}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}(o,e),o.prototype.render=function(t,e,o){var r=(o||{}).changeResourceUUIDs,n=void 0===r?[]:r;this[tt]=q.FREE;var i=ut(e);if(Array.isArray(i.elements)&&i.elements.forEach((function(t){'string'==typeof t.uuid&&t.uuid||(t.uuid=at())})),!this[K])if(this[ot]&&'[object HTMLCanvasElement]'===Object.prototype.toString.call(t)){var s=this[ot],a=s.width,u=s.height,l=s.contextWidth,c=s.contextHeight,h=s.devicePixelRatio,f=t;f.width=a*h,f.height=u*h;var d=f.getContext('2d');this[K]=new lt(d,{width:a,height:u,contextWidth:l||a,contextHeight:c||u,devicePixelRatio:h})}else t&&(this[K]=t);if(![q.FREEZE].includes(this[tt])){var p=ut({data:i});this[J].push(p),this[nt](),this[et].load(i,n||[])}},o.prototype.getContext=function(){return this[K]},o.prototype.thaw=function(){this[tt]=q.FREE},o.prototype[(Q=J,G=K,Z=tt,rt)]=function(){this[tt]=q.FREEZE},o.prototype[nt]=function(){var t=this;this[tt]!==q.FREEZE&&st((function(){if(t[tt]!==q.FREEZE){var e=t[K],o=t[J][0],r=!1;t[J].length>1?o=t[J].shift():r=!0,!0!==t[et].isComplete()?(t[nt](),o&&e&&H(e,o.data,t[et])):o&&e?(H(e,o.data,t[et]),t[it](),r?t[tt]=q.FREE:t[nt]()):t[tt]=q.FREE,t.trigger('drawFrame',{t:Date.now()}),!0===t[et].isComplete()&&1===t[J].length&&t[tt]===q.FREE&&(e&&t[J][0]&&t[J][0].data&&H(e,t[J][0].data,t[et]),t.trigger('drawFrameComplete',{t:Date.now()}),t[rt]())}}))},o.prototype[it]=function(){if(!(this[J].length<=1)){var t=ut(this[J][this[J].length-1]);this[J]=[t]}},o}($)}();
1
+ var iDrawRenderer=function(){'use strict';var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};var e=function(){return e=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},e.apply(this,arguments)};function o(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function n(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function r(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function i(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(t()).concat(t(),"-").concat(t(),"-").concat(t(),"-").concat(t(),"-").concat(t()).concat(t()).concat(t())}function s(t){return function t(e){var o,n=(o=e,Object.prototype.toString.call(o).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(n)>=0)return e;if('Array'===n){var r=[];return e.forEach((function(e){r.push(t(e))})),r}if('Object'===n){var i={};return Object.keys(e).forEach((function(o){i[o]=t(e[o])})),i}}(t)}function a(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var u={type:function(t,e){var o=a(t);return!0===e?o.toLocaleLowerCase():o},array:function(t){return'Array'===a(t)},json:function(t){return'Object'===a(t)},function:function(t){return'Function'===a(t)},asyncFunction:function(t){return'AsyncFunction'===a(t)},string:function(t){return'String'===a(t)},number:function(t){return'Number'===a(t)},undefined:function(t){return'Undefined'===a(t)},null:function(t){return'Null'===a(t)},promise:function(t){return'Promise'===a(t)}},c=function(){return c=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},c.apply(this,arguments)};function l(t,e,o,n){return new(o||(o=Promise))((function(r,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function h(t,e){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function f(t,e){var o=e.width,n=e.height;return new Promise((function(e,r){var i="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(o||'',"\" height = \"").concat(n||'',"\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n ").concat(t,"\n </div>\n </foreignObject>\n </svg>\n "),s=new Blob([i],{type:'image/svg+xml;charset=utf-8'}),a=new FileReader;a.readAsDataURL(s),a.onload=function(t){var o,n=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(n)},a.onerror=function(t){r(t)}}))}function d(t){return new Promise((function(e,o){var n=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),r=new FileReader;r.readAsDataURL(n),r.onload=function(t){var o,n=null===(o=null==t?void 0:t.target)||void 0===o?void 0:o.result;e(n)},r.onerror=function(t){o(t)}}))}var p=window.Image;function g(t){return new Promise((function(e,o){var n=new p;n.onload=function(){e(n)},n.onabort=o,n.onerror=o,n.src=t}))}function _(t){return l(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,d(t)];case 1:return[4,g(e.sent())];case 2:return[2,e.sent()]}}))}))}function v(t,e){return l(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:return[4,f(t,e)];case 1:return[4,g(o.sent())];case 2:return[2,o.sent()]}}))}))}var y=function(){function t(t,e){this._opts=e,this._ctx=t,this._transform={scale:1,scrollX:0,scrollY:0}}return t.prototype.getContext=function(){return this._ctx},t.prototype.resetSize=function(t){this._opts=c(c({},this._opts),t)},t.prototype.calcDeviceNum=function(t){return t*this._opts.devicePixelRatio},t.prototype.calcScreenNum=function(t){return t/this._opts.devicePixelRatio},t.prototype.getSize=function(){return{width:this._opts.width,height:this._opts.height,contextWidth:this._opts.contextWidth,contextHeight:this._opts.contextHeight,devicePixelRatio:this._opts.devicePixelRatio}},t.prototype.setTransform=function(t){this._transform=c(c({},this._transform),t)},t.prototype.getTransform=function(){return{scale:this._transform.scale,scrollX:this._transform.scrollX,scrollY:this._transform.scrollY}},t.prototype.setFillStyle=function(t){this._ctx.fillStyle=t},t.prototype.fill=function(t){return this._ctx.fill(t||'nonzero')},t.prototype.arc=function(t,e,o,n,r,i){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(o),n,r,i)},t.prototype.rect=function(t,e,o,n){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.fillRect=function(t,e,o,n){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.clearRect=function(t,e,o,n){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n))},t.prototype.beginPath=function(){return this._ctx.beginPath()},t.prototype.closePath=function(){return this._ctx.closePath()},t.prototype.lineTo=function(t,e){return this._ctx.lineTo(this._doSize(t),this._doSize(e))},t.prototype.moveTo=function(t,e){return this._ctx.moveTo(this._doSize(t),this._doSize(e))},t.prototype.arcTo=function(t,e,o,n,r){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n),this._doSize(r))},t.prototype.setLineWidth=function(t){return this._ctx.lineWidth=this._doSize(t)},t.prototype.setLineDash=function(t){var e=this;return this._ctx.setLineDash(t.map((function(t){return e._doSize(t)})))},t.prototype.isPointInPath=function(t,e){return this._ctx.isPointInPath(this._doX(t),this._doY(e))},t.prototype.isPointInPathWithoutScroll=function(t,e){return this._ctx.isPointInPath(this._doSize(t),this._doSize(e))},t.prototype.setStrokeStyle=function(t){this._ctx.strokeStyle=t},t.prototype.stroke=function(){return this._ctx.stroke()},t.prototype.translate=function(t,e){return this._ctx.translate(this._doSize(t),this._doSize(e))},t.prototype.rotate=function(t){return this._ctx.rotate(t)},t.prototype.drawImage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var o=t[0],n=t[1],r=t[2],i=t[3],s=t[4],a=t[t.length-4],u=t[t.length-3],c=t[t.length-2],l=t[t.length-1];return 9===t.length?this._ctx.drawImage(o,this._doSize(n),this._doSize(r),this._doSize(i),this._doSize(s),this._doSize(a),this._doSize(u),this._doSize(c),this._doSize(l)):this._ctx.drawImage(o,this._doSize(a),this._doSize(u),this._doSize(c),this._doSize(l))},t.prototype.createPattern=function(t,e){return this._ctx.createPattern(t,e)},t.prototype.measureText=function(t){return this._ctx.measureText(t)},t.prototype.setTextAlign=function(t){this._ctx.textAlign=t},t.prototype.fillText=function(t,e,o,n){return void 0!==n?this._ctx.fillText(t,this._doSize(e),this._doSize(o),this._doSize(n)):this._ctx.fillText(t,this._doSize(e),this._doSize(o))},t.prototype.strokeText=function(t,e,o,n){return void 0!==n?this._ctx.strokeText(t,this._doSize(e),this._doSize(o),this._doSize(n)):this._ctx.strokeText(t,this._doSize(e),this._doSize(o))},t.prototype.setFont=function(t){var e=[];'bold'===t.fontWeight&&e.push("".concat(t.fontWeight)),e.push("".concat(this._doSize(t.fontSize||12),"px")),e.push("".concat(t.fontFamily||'sans-serif')),this._ctx.font="".concat(e.join(' '))},t.prototype.setTextBaseline=function(t){this._ctx.textBaseline=t},t.prototype.setGlobalAlpha=function(t){this._ctx.globalAlpha=t},t.prototype.save=function(){this._ctx.save()},t.prototype.restore=function(){this._ctx.restore()},t.prototype.scale=function(t,e){this._ctx.scale(t,e)},t.prototype.setShadowColor=function(t){this._ctx.shadowColor=t},t.prototype.setShadowOffsetX=function(t){this._ctx.shadowOffsetX=this._doSize(t)},t.prototype.setShadowOffsetY=function(t){this._ctx.shadowOffsetY=this._doSize(t)},t.prototype.setShadowBlur=function(t){this._ctx.shadowBlur=this._doSize(t)},t.prototype.ellipse=function(t,e,o,n,r,i,s,a){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(o),this._doSize(n),r,i,s,a)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,o=e.scale,n=(t-e.scrollX)/o;return this._doSize(n)},t.prototype._doY=function(t){var e=this._transform,o=e.scale,n=(t-e.scrollY)/o;return this._doSize(n)},t}();function m(t){return'number'==typeof t&&(t>0||t<=0)}function w(t){return'number'==typeof t&&t>=0}function x(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function S(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var b={x:function(t){return m(t)},y:function(t){return m(t)},w:w,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:m,borderWidth:function(t){return w(t)},borderRadius:function(t){return m(t)&&t>=0},color:function(t){return r(t)},imageSrc:function(t){return S(t)||x(t)},imageURL:x,imageBase64:S,svg:function(t){return'string'==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test("".concat(t).trim())&&/<\/[\s]{0,}svg>$/i.test("".concat(t).trim())},html:function(t){var e=!1;if('string'==typeof t){var o=document.createElement('div');o.innerHTML=t,o.children.length>0&&(e=!0),o=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return m(t)&&t>0},lineHeight:function(t){return m(t)&&t>0},textAlign:function(t){return['center','left','right'].includes(t)},fontFamily:function(t){return'string'==typeof t&&t.length>0},fontWeight:function(t){return['bold'].includes(t)},strokeWidth:function(t){return m(t)&&t>0}};function z(t){void 0===t&&(t={});var e=t.borderColor,o=t.borderRadius,n=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!b.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!b.number(o))&&!(t.hasOwnProperty('borderWidth')&&!b.number(n)))}var L={attrs:function(t){var e=t.x,o=t.y,n=t.w,r=t.h,i=t.angle;return!!(b.x(e)&&b.y(o)&&b.w(n)&&b.h(r)&&b.angle(i))&&(i>=-360&&i<=360)},textDesc:function(t){var e=t.text,o=t.color,n=t.fontSize,r=t.lineHeight,i=t.fontFamily,s=t.textAlign,a=t.fontWeight,u=t.bgColor,c=t.strokeWidth,l=t.strokeColor;return!!b.text(e)&&(!!b.color(o)&&(!!b.fontSize(n)&&(!(t.hasOwnProperty('bgColor')&&!b.color(u))&&(!(t.hasOwnProperty('fontWeight')&&!b.fontWeight(a))&&(!(t.hasOwnProperty('lineHeight')&&!b.lineHeight(r))&&(!(t.hasOwnProperty('fontFamily')&&!b.fontFamily(i))&&(!(t.hasOwnProperty('textAlign')&&!b.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!b.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!b.color(l))&&!!z(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!b.color(e))&&!!z(t)},circleDesc:function(t){var e=t.bgColor,o=t.borderColor,n=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!b.color(e))&&(!(t.hasOwnProperty('borderColor')&&!b.color(o))&&!(t.hasOwnProperty('borderWidth')&&!b.number(n)))},imageDesc:function(t){var e=t.src;return!!b.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!b.svg(e)},htmlDesc:function(t){var e=t.html;return!!b.html(e)}};function D(t,e,o){var n=function(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}(e),r=function(t){return t/180*Math.PI}(e.angle||0);return function(t,e,o,n){e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(o),t.translate(-e.x,-e.y));n(t),e&&(o>0||o<0)&&(t.translate(e.x,e.y),t.rotate(-o),t.translate(-e.x,-e.y))}(t,n,r||0,o)}function E(t){t.setFillStyle('#000000'),t.setStrokeStyle('#000000'),t.setLineDash([]),t.setGlobalAlpha(1),t.setShadowColor('#00000000'),t.setShadowOffsetX(0),t.setShadowOffsetY(0),t.setShadowBlur(0)}function O(t,e,o){E(t),function(t,e){E(t),D(t,e,(function(){if(e.desc.borderWidth&&e.desc.borderWidth>0){var o=e.desc.borderWidth,n='#000000';!0===r(e.desc.borderColor)&&(n=e.desc.borderColor);var i=e.x-o/2,s=e.y-o/2,a=e.w+o,u=e.h+o,c=e.desc.borderRadius||0;(c=Math.min(c,a/2,u/2))<a/2&&c<u/2&&(c+=o/2);var l=e.desc;void 0!==l.shadowColor&&r(l.shadowColor)&&t.setShadowColor(l.shadowColor),void 0!==l.shadowOffsetX&&b.number(l.shadowOffsetX)&&t.setShadowOffsetX(l.shadowOffsetX),void 0!==l.shadowOffsetY&&b.number(l.shadowOffsetY)&&t.setShadowOffsetY(l.shadowOffsetY),void 0!==l.shadowBlur&&b.number(l.shadowBlur)&&t.setShadowBlur(l.shadowBlur),t.beginPath(),t.setLineWidth(o),t.setStrokeStyle(n),t.moveTo(i+c,s),t.arcTo(i+a,s,i+a,s+u,c),t.arcTo(i+a,s+u,i,s+u,c),t.arcTo(i,s+u,i,s,c),t.arcTo(i,s,i+a,s,c),t.closePath(),t.stroke()}}))}(t,e),E(t),D(t,e,(function(){var n=e.x,r=e.y,i=e.w,s=e.h,a=e.desc.borderRadius||0;(i<2*(a=Math.min(a,i/2,s/2))||s<2*a)&&(a=0),t.beginPath(),t.moveTo(n+a,r),t.arcTo(n+i,r,n+i,r+s,a),t.arcTo(n+i,r+s,n,r+s,a),t.arcTo(n,r+s,n,r,a),t.arcTo(n,r,n+i,r,a),t.closePath(),('string'==typeof o||['CanvasPattern'].includes(u.type(o)))&&t.setFillStyle(o),t.fill()}))}function P(t,e){O(t,e,e.desc.bgColor)}function C(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function k(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function T(t,e,o){var n=o.getContent(e.uuid);D(t,e,(function(){n&&t.drawImage(n,e.x,e.y,e.w,e.h)}))}function W(t,o,n){E(t),O(t,o,o.desc.bgColor||'transparent'),D(t,o,(function(){var n=e({fontSize:12,fontFamily:'sans-serif',textAlign:'center'},o.desc);t.setFillStyle(o.desc.color),t.setTextBaseline('top'),t.setFont({fontWeight:n.fontWeight,fontSize:n.fontSize,fontFamily:n.fontFamily});var i=n.text.replace(/\r\n/gi,'\n'),s=n.lineHeight||n.fontSize,a=i.split('\n'),u=[],c=0;a.forEach((function(e,n){var r='';if(e.length>0){for(var i=0;i<e.length&&(t.measureText(r+(e[i]||'')).width<t.calcDeviceNum(o.w)?r+=e[i]||'':(u.push({text:r,width:t.calcScreenNum(t.measureText(r).width)}),r=e[i]||'',c++),!((c+1)*s>o.h));i++)if(e.length-1===i&&(c+1)*s<o.h){u.push({text:r,width:t.calcScreenNum(t.measureText(r).width)}),n<a.length-1&&c++;break}}else u.push({text:'',width:0})}));var l=o.y;if(u.length*s<o.h&&(l+=(o.h-u.length*s)/2),void 0!==n.textShadowColor&&r(n.textShadowColor)&&t.setShadowColor(n.textShadowColor),void 0!==n.textShadowOffsetX&&b.number(n.textShadowOffsetX)&&t.setShadowOffsetX(n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&b.number(n.textShadowOffsetY)&&t.setShadowOffsetY(n.textShadowOffsetY),void 0!==n.textShadowBlur&&b.number(n.textShadowBlur)&&t.setShadowBlur(n.textShadowBlur),u.forEach((function(e,r){var i=o.x;'center'===n.textAlign?i=o.x+(o.w-e.width)/2:'right'===n.textAlign&&(i=o.x+(o.w-e.width)),t.fillText(e.text,i,l+s*r)})),E(t),r(n.strokeColor)&&void 0!==n.strokeWidth&&n.strokeWidth>0){var h=o.y;u.length*s<o.h&&(h+=(o.h-u.length*s)/2),u.forEach((function(e,r){var i=o.x;'center'===n.textAlign?i=o.x+(o.w-e.width)/2:'right'===n.textAlign&&(i=o.x+(o.w-e.width)),void 0!==n.strokeColor&&t.setStrokeStyle(n.strokeColor),void 0!==n.strokeWidth&&n.strokeWidth>0&&t.setLineWidth(n.strokeWidth),t.strokeText(e.text,i,h+s*r)}))}}))}function R(t,e){E(t),D(t,e,(function(t){var o=e.x,n=e.y,r=e.w,i=e.h,s=e.desc,a=s.bgColor,u=void 0===a?'#000000':a,c=s.borderColor,l=void 0===c?'#000000':c,h=s.borderWidth,f=void 0===h?0:h,d=r/2,p=i/2,g=o+d,_=n+p;if(f&&f>0){var v=f/2+d,y=f/2+p;t.beginPath(),t.setStrokeStyle(l),t.setLineWidth(f),t.ellipse(g,_,v,y,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath(),t.setFillStyle(u),t.ellipse(g,_,d,p,0,0,2*Math.PI),t.closePath(),t.fill()}))}function F(t,e,o){var n;E(t);var i=t.getSize();if(t.clearRect(0,0,i.contextWidth,i.contextHeight),'string'==typeof e.bgColor&&r(e.bgColor)&&function(t,e){var o=t.getSize();t.setFillStyle(e),t.fillRect(0,0,o.contextWidth,o.contextHeight)}(t,e.bgColor),e.elements.length>0)for(var s=0;s<e.elements.length;s++){var a=e.elements[s];if(!0!==(null===(n=null==a?void 0:a.operation)||void 0===n?void 0:n.invisible))switch(a.type){case'rect':P(t,a);break;case'text':W(t,a);break;case'image':C(t,a,o);break;case'svg':k(t,a,o);break;case'html':T(t,a,o);break;case'circle':R(t,a)}}}Object.freeze({__proto__:null,is:b,check:L,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,o){return function n(r){var i=t[r];r===t.length&&o&&(i=o);if(!i)return Promise.resolve();try{return Promise.resolve(i(e,n.bind(null,r+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var o=-1;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];o>0||(o=setTimeout((function(){t.apply(void 0,n),o=-1}),e))}},loadImage:g,loadSVG:_,loadHTML:v,downloadImageFromCanvas:function(t,e){var o=e.filename,n=e.type,r=void 0===n?'image/jpeg':n,i=t.toDataURL(r),s=document.createElement('a');s.href=i,s.download=o;var a=document.createEvent('MouseEvents');a.initEvent('click',!0,!1),s.dispatchEvent(a)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:r,createUUID:i,istype:u,deepClone:s,Context:y});var A,I=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var n=0;n<(null==o?void 0:o.length);n++)if(o[n]===e){o.splice(n,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}();!function(t){t.FREE="free",t.LOADING="loading",t.COMPLETE="complete"}(A||(A={}));var H,j,U,N,B=function(){function t(t){this._currentLoadData={},this._currentUUIDQueue=[],this._storageLoadData={},this._status=A.FREE,this._waitingLoadQueue=[],this._opts=t,this._event=new I,this._waitingLoadQueue=[]}return t.prototype.load=function(t,e){var o=this._resetLoadData(t,e),n=o[0],r=o[1];this._status===A.FREE||this._status===A.COMPLETE?(this._currentUUIDQueue=n,this._currentLoadData=r,this._loadTask()):this._status===A.LOADING&&n.length>0&&this._waitingLoadQueue.push({uuidQueue:n,loadData:r})},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype.isComplete=function(){return this._status===A.COMPLETE},t.prototype.getContent=function(t){var e;return'loaded'===(null===(e=this._storageLoadData[t])||void 0===e?void 0:e.status)?this._storageLoadData[t].content:null},t.prototype._resetLoadData=function(t,e){for(var o={},n=[],r=this._storageLoadData,i=t.elements.length-1;i>=0;i--){var s=t.elements[i];['image','svg','html'].includes(s.type)&&(r[s.uuid]?e.includes(s.uuid)&&(o[s.uuid]=this._createEmptyLoadItem(s),n.push(s.uuid)):(o[s.uuid]=this._createEmptyLoadItem(s),n.push(s.uuid)))}return[n,o]},t.prototype._createEmptyLoadItem=function(t){var e='',o=t.type,n=t.w,r=t.h;if('image'===t.type)e=(i=t).desc.src||'';else if('svg'===t.type){e=(i=t).desc.svg||''}else if('html'===t.type){var i;e=function(t){return t.replace(/<script[\s\S]*?<\/script>/gi,'')}((i=t).desc.html||''),n=i.desc.width||t.w,r=i.desc.height||t.h}return{uuid:t.uuid,type:o,status:'null',content:null,source:e,elemW:n,elemH:r,element:s(t)}},t.prototype._loadTask=function(){var t=this;if(this._status!==A.LOADING){if(this._status=A.LOADING,0===this._currentUUIDQueue.length){if(0===this._waitingLoadQueue.length)return this._status=A.COMPLETE,void this._event.trigger('complete',void 0);var e=this._waitingLoadQueue.shift();if(e){var o=e.uuidQueue,n=e.loadData;this._currentLoadData=n,this._currentUUIDQueue=o}}var r=this._opts.maxParallelNum,i=this._currentUUIDQueue.splice(0,r),s={};i.forEach((function(t,e){s[t]=e}));var a=[],u=function(){if(a.length>=r)return!1;if(0===i.length)return!0;for(var e=function(e){var o=i.shift();if(void 0===o)return"break";a.push(o),t._loadElementSource(t._currentLoadData[o]).then((function(e){var n,r;a.splice(a.indexOf(o),1);var s=u();t._storageLoadData[o]={uuid:o,type:t._currentLoadData[o].type,status:'loaded',content:e,source:t._currentLoadData[o].source,elemW:t._currentLoadData[o].elemW,elemH:t._currentLoadData[o].elemH,element:t._currentLoadData[o].element},0===a.length&&0===i.length&&!0===s&&(t._status=A.FREE,t._loadTask()),t._event.trigger('load',{uuid:null===(n=t._storageLoadData[o])||void 0===n?void 0:n.uuid,type:t._storageLoadData[o].type,status:t._storageLoadData[o].status,content:t._storageLoadData[o].content,source:t._storageLoadData[o].source,elemW:t._storageLoadData[o].elemW,elemH:t._storageLoadData[o].elemH,element:null===(r=t._storageLoadData[o])||void 0===r?void 0:r.element})})).catch((function(e){var n,r,s,c,l,h,f,d,p,g,_,v;console.warn(e),a.splice(a.indexOf(o),1);var y=u();t._currentLoadData[o]&&(t._storageLoadData[o]={uuid:o,type:null===(n=t._currentLoadData[o])||void 0===n?void 0:n.type,status:'fail',content:null,error:e,source:null===(r=t._currentLoadData[o])||void 0===r?void 0:r.source,elemW:null===(s=t._currentLoadData[o])||void 0===s?void 0:s.elemW,elemH:null===(c=t._currentLoadData[o])||void 0===c?void 0:c.elemH,element:null===(l=t._currentLoadData[o])||void 0===l?void 0:l.element}),0===a.length&&0===i.length&&!0===y&&(t._status=A.FREE,t._loadTask()),t._currentLoadData[o]&&t._event.trigger('error',{uuid:o,type:null===(h=t._storageLoadData[o])||void 0===h?void 0:h.type,status:null===(f=t._storageLoadData[o])||void 0===f?void 0:f.status,content:null===(d=t._storageLoadData[o])||void 0===d?void 0:d.content,source:null===(p=t._storageLoadData[o])||void 0===p?void 0:p.source,elemW:null===(g=t._storageLoadData[o])||void 0===g?void 0:g.elemW,elemH:null===(_=t._storageLoadData[o])||void 0===_?void 0:_.elemH,element:null===(v=t._storageLoadData[o])||void 0===v?void 0:v.element})}))},o=a.length;o<r;o++){if("break"===e())break}return!1};u()}},t.prototype._loadElementSource=function(t){return o(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return t&&'image'===t.type?[4,g(t.source)]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return t&&'svg'===t.type?[4,_(t.source)]:[3,4];case 4:return t&&'html'===t.type?[4,v(t.source,{width:t.elemW,height:t.elemH})]:[3,6];case 6:throw Error('Element\'s source is not support!')}}))}))},t}(),X=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);null==o||o.push(e),this._listeners.set(t,o||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var o=this._listeners.get(t);if(Array.isArray(o))for(var n=0;n<(null==o?void 0:o.length);n++)if(o[n]===e){o.splice(n,1);break}this._listeners.set(t,o||[])}},t.prototype.trigger=function(t,e){var o=this._listeners.get(t);return!!Array.isArray(o)&&(o.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}(),Y=Symbol('_queue'),M=Symbol('_ctx'),Q=Symbol('_status'),G=Symbol('_loader'),Z=Symbol('_opts'),q=Symbol('_freeze'),$=Symbol('_drawFrame'),V=Symbol('_retainQueueOneItem'),J=window.requestAnimationFrame;!function(t){t.NULL="null",t.FREE="free",t.DRAWING="drawing",t.FREEZE="freeze"}(N||(N={}));var K=function(e){function o(t){var o=e.call(this)||this;return o[H]=[],o[j]=null,o[U]=N.NULL,o[Z]=t,o[G]=new B({maxParallelNum:6}),o[G].on('load',(function(t){o[$](),o.trigger('load',{element:t.element})})),o[G].on('error',(function(t){o.trigger('error',{element:t.element,error:t.error})})),o[G].on('complete',(function(){o.trigger('loadComplete',{t:Date.now()})})),o}return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}(o,e),o.prototype.render=function(t,e,o){var n=(o||{}).changeResourceUUIDs,r=void 0===n?[]:n;this[Q]=N.FREE;var a=s(e);if(Array.isArray(a.elements)&&a.elements.forEach((function(t){'string'==typeof t.uuid&&t.uuid||(t.uuid=i())})),!this[M])if(this[Z]&&'[object HTMLCanvasElement]'===Object.prototype.toString.call(t)){var u=this[Z],c=u.width,l=u.height,h=u.contextWidth,f=u.contextHeight,d=u.devicePixelRatio,p=t;p.width=c*d,p.height=l*d;var g=p.getContext('2d');this[M]=new y(g,{width:c,height:l,contextWidth:h||c,contextHeight:f||l,devicePixelRatio:d})}else t&&(this[M]=t);if(![N.FREEZE].includes(this[Q])){var _=s({data:a});this[Y].push(_),this[$](),this[G].load(a,r||[])}},o.prototype.getContext=function(){return this[M]},o.prototype.thaw=function(){this[Q]=N.FREE},o.prototype[(H=Y,j=M,U=Q,q)]=function(){this[Q]=N.FREEZE},o.prototype[$]=function(){var t=this;this[Q]!==N.FREEZE&&J((function(){if(t[Q]!==N.FREEZE){var e=t[M],o=t[Y][0],n=!1;t[Y].length>1?o=t[Y].shift():n=!0,!0!==t[G].isComplete()?(t[$](),o&&e&&F(e,o.data,t[G])):o&&e?(F(e,o.data,t[G]),t[V](),n?t[Q]=N.FREE:t[$]()):t[Q]=N.FREE,t.trigger('drawFrame',{t:Date.now()}),!0===t[G].isComplete()&&1===t[Y].length&&t[Q]===N.FREE&&(e&&t[Y][0]&&t[Y][0].data&&F(e,t[Y][0].data,t[G]),t.trigger('drawFrameComplete',{t:Date.now()}),t[q]())}}))},o.prototype[V]=function(){if(!(this[Y].length<=1)){var t=s(this[Y][this[Y].length-1]);this[Y]=[t]}},o}(X);return Object.freeze({__proto__:null,Renderer:K})}();