@idraw/core 0.3.0-alpha.3 → 0.3.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +4 -10
- package/dist/index.esm.js +4 -10
- package/dist/index.global.js +4 -10
- package/dist/index.global.min.js +1 -1
- package/package.json +6 -6
package/dist/index.cjs.js
CHANGED
|
@@ -236,7 +236,7 @@ var Image$2 = window.Image;
|
|
|
236
236
|
function loadImage$2(src) {
|
|
237
237
|
return new Promise(function (resolve, reject) {
|
|
238
238
|
var img = new Image$2;
|
|
239
|
-
img.
|
|
239
|
+
img.crossOrigin = 'anonymous';
|
|
240
240
|
img.onload = function () {
|
|
241
241
|
resolve(img);
|
|
242
242
|
};
|
|
@@ -762,7 +762,6 @@ var BoardEvent = (function () {
|
|
|
762
762
|
}());
|
|
763
763
|
function createTempData() {
|
|
764
764
|
return {
|
|
765
|
-
moveStartPoint: null,
|
|
766
765
|
prevClickPoint: null,
|
|
767
766
|
isHoverCanvas: false,
|
|
768
767
|
isDragCanvas: false,
|
|
@@ -781,10 +780,7 @@ var TempData$2 = (function () {
|
|
|
781
780
|
TempData.prototype.set = function (name, value) {
|
|
782
781
|
this._temp[name] = value;
|
|
783
782
|
};
|
|
784
|
-
TempData.prototype.get = function (name
|
|
785
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.clone) === true) {
|
|
786
|
-
return deepClone$2(this._temp[name]);
|
|
787
|
-
}
|
|
783
|
+
TempData.prototype.get = function (name) {
|
|
788
784
|
return this._temp[name];
|
|
789
785
|
};
|
|
790
786
|
TempData.prototype.clear = function () {
|
|
@@ -1782,7 +1778,7 @@ var Image$1 = window.Image;
|
|
|
1782
1778
|
function loadImage$1(src) {
|
|
1783
1779
|
return new Promise(function (resolve, reject) {
|
|
1784
1780
|
var img = new Image$1;
|
|
1785
|
-
img.
|
|
1781
|
+
img.crossOrigin = 'anonymous';
|
|
1786
1782
|
img.onload = function () {
|
|
1787
1783
|
resolve(img);
|
|
1788
1784
|
};
|
|
@@ -2530,7 +2526,7 @@ var Image = window.Image;
|
|
|
2530
2526
|
function loadImage(src) {
|
|
2531
2527
|
return new Promise(function (resolve, reject) {
|
|
2532
2528
|
var img = new Image;
|
|
2533
|
-
img.
|
|
2529
|
+
img.crossOrigin = 'anonymous';
|
|
2534
2530
|
img.onload = function () {
|
|
2535
2531
|
resolve(img);
|
|
2536
2532
|
};
|
|
@@ -3503,9 +3499,7 @@ var Loader = (function () {
|
|
|
3503
3499
|
}
|
|
3504
3500
|
var maxParallelNum = this._opts.maxParallelNum;
|
|
3505
3501
|
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
3506
|
-
var uuidMap = {};
|
|
3507
3502
|
uuids.forEach(function (url, i) {
|
|
3508
|
-
uuidMap[url] = i;
|
|
3509
3503
|
});
|
|
3510
3504
|
var loadUUIDList = [];
|
|
3511
3505
|
var _loadAction = function () {
|
package/dist/index.esm.js
CHANGED
|
@@ -234,7 +234,7 @@ var Image$2 = window.Image;
|
|
|
234
234
|
function loadImage$2(src) {
|
|
235
235
|
return new Promise(function (resolve, reject) {
|
|
236
236
|
var img = new Image$2;
|
|
237
|
-
img.
|
|
237
|
+
img.crossOrigin = 'anonymous';
|
|
238
238
|
img.onload = function () {
|
|
239
239
|
resolve(img);
|
|
240
240
|
};
|
|
@@ -760,7 +760,6 @@ var BoardEvent = (function () {
|
|
|
760
760
|
}());
|
|
761
761
|
function createTempData() {
|
|
762
762
|
return {
|
|
763
|
-
moveStartPoint: null,
|
|
764
763
|
prevClickPoint: null,
|
|
765
764
|
isHoverCanvas: false,
|
|
766
765
|
isDragCanvas: false,
|
|
@@ -779,10 +778,7 @@ var TempData$2 = (function () {
|
|
|
779
778
|
TempData.prototype.set = function (name, value) {
|
|
780
779
|
this._temp[name] = value;
|
|
781
780
|
};
|
|
782
|
-
TempData.prototype.get = function (name
|
|
783
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.clone) === true) {
|
|
784
|
-
return deepClone$2(this._temp[name]);
|
|
785
|
-
}
|
|
781
|
+
TempData.prototype.get = function (name) {
|
|
786
782
|
return this._temp[name];
|
|
787
783
|
};
|
|
788
784
|
TempData.prototype.clear = function () {
|
|
@@ -1780,7 +1776,7 @@ var Image$1 = window.Image;
|
|
|
1780
1776
|
function loadImage$1(src) {
|
|
1781
1777
|
return new Promise(function (resolve, reject) {
|
|
1782
1778
|
var img = new Image$1;
|
|
1783
|
-
img.
|
|
1779
|
+
img.crossOrigin = 'anonymous';
|
|
1784
1780
|
img.onload = function () {
|
|
1785
1781
|
resolve(img);
|
|
1786
1782
|
};
|
|
@@ -2528,7 +2524,7 @@ var Image = window.Image;
|
|
|
2528
2524
|
function loadImage(src) {
|
|
2529
2525
|
return new Promise(function (resolve, reject) {
|
|
2530
2526
|
var img = new Image;
|
|
2531
|
-
img.
|
|
2527
|
+
img.crossOrigin = 'anonymous';
|
|
2532
2528
|
img.onload = function () {
|
|
2533
2529
|
resolve(img);
|
|
2534
2530
|
};
|
|
@@ -3501,9 +3497,7 @@ var Loader = (function () {
|
|
|
3501
3497
|
}
|
|
3502
3498
|
var maxParallelNum = this._opts.maxParallelNum;
|
|
3503
3499
|
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
3504
|
-
var uuidMap = {};
|
|
3505
3500
|
uuids.forEach(function (url, i) {
|
|
3506
|
-
uuidMap[url] = i;
|
|
3507
3501
|
});
|
|
3508
3502
|
var loadUUIDList = [];
|
|
3509
3503
|
var _loadAction = function () {
|
package/dist/index.global.js
CHANGED
|
@@ -237,7 +237,7 @@ var iDrawCore = (function () {
|
|
|
237
237
|
function loadImage$2(src) {
|
|
238
238
|
return new Promise(function (resolve, reject) {
|
|
239
239
|
var img = new Image$2;
|
|
240
|
-
img.
|
|
240
|
+
img.crossOrigin = 'anonymous';
|
|
241
241
|
img.onload = function () {
|
|
242
242
|
resolve(img);
|
|
243
243
|
};
|
|
@@ -763,7 +763,6 @@ var iDrawCore = (function () {
|
|
|
763
763
|
}());
|
|
764
764
|
function createTempData() {
|
|
765
765
|
return {
|
|
766
|
-
moveStartPoint: null,
|
|
767
766
|
prevClickPoint: null,
|
|
768
767
|
isHoverCanvas: false,
|
|
769
768
|
isDragCanvas: false,
|
|
@@ -782,10 +781,7 @@ var iDrawCore = (function () {
|
|
|
782
781
|
TempData.prototype.set = function (name, value) {
|
|
783
782
|
this._temp[name] = value;
|
|
784
783
|
};
|
|
785
|
-
TempData.prototype.get = function (name
|
|
786
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.clone) === true) {
|
|
787
|
-
return deepClone$2(this._temp[name]);
|
|
788
|
-
}
|
|
784
|
+
TempData.prototype.get = function (name) {
|
|
789
785
|
return this._temp[name];
|
|
790
786
|
};
|
|
791
787
|
TempData.prototype.clear = function () {
|
|
@@ -1783,7 +1779,7 @@ var iDrawCore = (function () {
|
|
|
1783
1779
|
function loadImage$1(src) {
|
|
1784
1780
|
return new Promise(function (resolve, reject) {
|
|
1785
1781
|
var img = new Image$1;
|
|
1786
|
-
img.
|
|
1782
|
+
img.crossOrigin = 'anonymous';
|
|
1787
1783
|
img.onload = function () {
|
|
1788
1784
|
resolve(img);
|
|
1789
1785
|
};
|
|
@@ -2531,7 +2527,7 @@ var iDrawCore = (function () {
|
|
|
2531
2527
|
function loadImage(src) {
|
|
2532
2528
|
return new Promise(function (resolve, reject) {
|
|
2533
2529
|
var img = new Image;
|
|
2534
|
-
img.
|
|
2530
|
+
img.crossOrigin = 'anonymous';
|
|
2535
2531
|
img.onload = function () {
|
|
2536
2532
|
resolve(img);
|
|
2537
2533
|
};
|
|
@@ -3504,9 +3500,7 @@ var iDrawCore = (function () {
|
|
|
3504
3500
|
}
|
|
3505
3501
|
var maxParallelNum = this._opts.maxParallelNum;
|
|
3506
3502
|
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
3507
|
-
var uuidMap = {};
|
|
3508
3503
|
uuids.forEach(function (url, i) {
|
|
3509
|
-
uuidMap[url] = i;
|
|
3510
3504
|
});
|
|
3511
3505
|
var loadUUIDList = [];
|
|
3512
3506
|
var _loadAction = function () {
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawCore=function(){'use strict';var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)},e=function(){return e=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function o(t){return function t(e){var n,o=(n=e,Object.prototype.toString.call(n).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var i=[];return e.forEach((function(e){i.push(t(e))})),i}if('Object'===o){var r={};return Object.keys(e).forEach((function(n){r[n]=t(e[n])})),r}}(t)}function i(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var r={type:function(t,e){var n=i(t);return!0===e?n.toLocaleLowerCase():n},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)}},s=function(){return s=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},s.apply(this,arguments)};function l(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function a(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function c(t,e){var n=e.width,o=e.height;return new Promise((function(e,i){var r="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(n||'',"\" height = \"").concat(o||'',"\">\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([r],{type:'image/svg+xml;charset=utf-8'}),l=new FileReader;l.readAsDataURL(s),l.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},l.onerror=function(t){i(t)}}))}function h(t){return new Promise((function(e,n){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),i=new FileReader;i.readAsDataURL(o),i.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},i.onerror=function(t){n(t)}}))}var u=window.Image;function f(t){return new Promise((function(e,n){var o=new u;o.setAttribute('crossOrigin','anonymous'),o.onload=function(){e(o)},o.onabort=n,o.onerror=n,o.src=t}))}var d=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=s(s({},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=s(s({},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,n,o,i,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(n),o,i,r)},t.prototype.rect=function(t,e,n,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.fillRect=function(t,e,n,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.clearRect=function(t,e,n,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},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,n,o,i){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),this._doSize(i))},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 n=t[0],o=t[1],i=t[2],r=t[3],s=t[4],l=t[t.length-4],a=t[t.length-3],c=t[t.length-2],h=t[t.length-1];return 9===t.length?this._ctx.drawImage(n,this._doSize(o),this._doSize(i),this._doSize(r),this._doSize(s),this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h)):this._ctx.drawImage(n,this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h))},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,n,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(n))},t.prototype.strokeText=function(t,e,n,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(n))},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,n,o,i,r,s,l){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),i,r,s,l)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollX)/n;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollY)/n;return this._doSize(o)},t}();function p(t){return'number'==typeof t&&(t>0||t<=0)}function v(t){return'number'==typeof t&&t>=0}function g(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function m(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var y={x:function(t){return p(t)},y:function(t){return p(t)},w:v,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:p,borderWidth:function(t){return v(t)},borderRadius:function(t){return p(t)&&t>=0},color:function(t){return n(t)},imageSrc:function(t){return m(t)||g(t)},imageURL:g,imageBase64:m,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return p(t)&&t>0},lineHeight:function(t){return p(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 p(t)&&t>0}};function _(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!y.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!y.number(n))&&!(t.hasOwnProperty('borderWidth')&&!y.number(o)))}var S={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(y.x(e)&&y.y(n)&&y.w(o)&&y.h(i)&&y.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!y.text(e)&&(!!y.color(n)&&(!!y.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!y.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!y.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!y.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!y.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!y.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!y.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!y.color(h))&&!!_(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!y.color(e))&&!!_(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!y.color(e))&&(!(t.hasOwnProperty('borderColor')&&!y.color(n))&&!(t.hasOwnProperty('borderWidth')&&!y.number(o)))},imageDesc:function(t){var e=t.src;return!!y.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!y.svg(e)},htmlDesc:function(t){var e=t.html;return!!y.html(e)}},x=Object.freeze({__proto__:null,is:y,check:S,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,n){return function o(i){var r=t[i];i===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var n=-1;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n>0||(n=setTimeout((function(){t.apply(void 0,o),n=-1}),e))}},loadImage:f,loadSVG:function(t){return l(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,h(t)];case 1:return[4,f(e.sent())];case 2:return[2,e.sent()]}}))}))},loadHTML:function(t,e){return l(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,c(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,f(n.sent())];case 2:return[2,n.sent()]}}))}))},downloadImageFromCanvas:function(t,e){var n=e.filename,o=e.type,i=void 0===o?'image/jpeg':o,r=t.toDataURL(i),s=document.createElement('a');s.href=r,s.download=n;var l=document.createEvent('MouseEvents');l.initEvent('click',!0,!1),s.dispatchEvent(l)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:n,createUUID:function(){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())},istype:r,deepClone:o,Context:d}),b=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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 w=function(){function t(){this._temp={moveStartPoint:null,prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t,e){return!0===(null==e?void 0:e.clone)?o(this._temp[t]):this._temp[t]},t.prototype.clear=function(){this._temp={moveStartPoint:null,prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}},t}(),E=function(){function t(t,e){this._isMoving=!1,this._temp=new w,this._container=window,this._canvas=t,this._isMoving=!1,this._initEvent(),this._event=new b}return t.prototype.setStatusMap=function(t){this._temp.set('statusMap',t)},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype._initEvent=function(){var t=this._canvas,e=this._container;e.addEventListener('mousemove',this._listenWindowMove.bind(this),!1),e.addEventListener('mouseup',this._listenWindowMoveEnd.bind(this),!1),t.addEventListener('mousemove',this._listenHover.bind(this),!1),t.addEventListener('mousedown',this._listenMoveStart.bind(this),!1),t.addEventListener('mousemove',this._listenMove.bind(this),!1),t.addEventListener('mouseup',this._listenMoveEnd.bind(this),!1),t.addEventListener('click',this._listenCanvasClick.bind(this),!1),t.addEventListener('wheel',this._listenCanvasWheel.bind(this),!1),t.addEventListener('mousedown',this._listenCanvasMoveStart.bind(this),!0),t.addEventListener('mouseup',this._listenCanvasMoveEnd.bind(this),!0),t.addEventListener('mouseover',this._listenCanvasMoveOver.bind(this),!0),t.addEventListener('mouseleave',this._listenCanvasMoveLeave.bind(this),!0),this._initParentEvent()},t.prototype._initParentEvent=function(){try{for(var t=window,e=t.origin;t.self!==t.top&&(t.self!==t.parent&&t.origin===e&&t.parent.window.addEventListener('mousemove',this._listSameOriginParentWindow.bind(this),!1),t=t.parent););}catch(t){console.warn(t)}},t.prototype._listenHover=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.has('hover')&&this._event.trigger('hover',e),this._isMoving=!0},t.prototype._listenMoveStart=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&(this._event.has('point')&&this._event.trigger('point',e),this._event.has('moveStart')&&this._event.trigger('moveStart',e)),this._isMoving=!0},t.prototype._listenMove=function(t){if(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenMoveEnd=function(t){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._isMoving=!1},t.prototype._listSameOriginParentWindow=function(){this._temp.get('isHoverCanvas')&&this._event.has('leave')&&this._event.trigger('leave',void 0),this._temp.get('isDragCanvas')&&this._event.has('moveEnd')&&this._event.trigger('moveEnd',{x:NaN,y:NaN}),this._isMoving=!1,this._temp.set('isDragCanvas',!1),this._temp.set('isHoverCanvas',!1)},t.prototype._listenCanvasMoveStart=function(){this._temp.get('isHoverCanvas')&&this._temp.set('isDragCanvas',!0)},t.prototype._listenCanvasMoveEnd=function(){this._temp.set('isDragCanvas',!1)},t.prototype._listenCanvasMoveOver=function(){this._temp.set('isHoverCanvas',!0)},t.prototype._listenCanvasMoveLeave=function(){this._temp.set('isHoverCanvas',!1),this._event.has('leave')&&this._event.trigger('leave',void 0)},t.prototype._listenWindowMove=function(t){if(!0===this._temp.get('isDragCanvas')&&(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving)){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenWindowMoveEnd=function(t){if(!0!=!this._temp.get('isDragCanvas')){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._temp.set('isDragCanvas',!1),this._isMoving=!1}},t.prototype._listenCanvasWheel=function(t){this._event.has('wheelX')&&(t.deltaX>0||t.deltaX<0)&&this._event.trigger('wheelX',t.deltaX),this._event.has('wheelY')&&(t.deltaY>0||t.deltaY<0)&&this._event.trigger('wheelY',t.deltaY);var e=this._temp.get('statusMap'),n=e.canScrollYNext,o=e.canScrollYPrev;(t.deltaX>0&&t.deltaX<0||t.deltaY>0&&!0===n||t.deltaY<0&&!0===o)&&t.preventDefault()},t.prototype._listenCanvasClick=function(t){t.preventDefault();var e=this._getPosition(t),n=Date.now();if(this._isVaildPoint(e)){var o=this._temp.get('prevClickPoint');o&&n-o.t<=500&&Math.abs(o.x-e.x)<=5&&Math.abs(o.y-e.y)<=5?this._event.has('doubleClick')&&this._event.trigger('doubleClick',{x:e.x,y:e.y}):this._temp.set('prevClickPoint',{x:e.x,y:e.y,t:n})}},t.prototype._getPosition=function(t){var e=this._canvas,n=0,o=0;if(t&&t.touches&&t.touches.length>0){var i=t.touches[0];i&&(n=i.clientX,o=i.clientY)}else n=t.clientX,o=t.clientY;return{x:n-e.getBoundingClientRect().left,y:o-e.getBoundingClientRect().top,t:Date.now()}},t.prototype._isVaildPoint=function(t){return P(t.x)&&P(t.y)},t}();function P(t){return t>0||t<0||0===t}var z={lineWidth:12,color:'#a0a0a0'},C=function(){function t(t,e){this._displayCtx=t,this._opts=this._getOpts(e)}return t.prototype.draw=function(t){var e=this._opts,n=e.width,o=e.height,i=this.calc(t),r=this._displayCtx;i.xSize>0&&(r.globalAlpha=.2,r.fillStyle=i.color,r.fillRect(0,this._doSize(o-i.lineSize),this._doSize(n),this._doSize(i.lineSize)),r.globalAlpha=1,L(r,{x:this._doSize(i.translateX),y:this._doSize(o-i.lineSize),w:this._doSize(i.xSize),h:this._doSize(i.lineSize),r:this._doSize(i.lineSize/2),color:i.color})),i.ySize>0&&(r.globalAlpha=.2,r.fillStyle=i.color,r.fillRect(this._doSize(n-i.lineSize),0,this._doSize(i.lineSize),this._doSize(o)),r.globalAlpha=1,L(r,{x:this._doSize(n-i.lineSize),y:this._doSize(i.translateY),w:this._doSize(i.lineSize),h:this._doSize(i.ySize),r:this._doSize(i.lineSize/2),color:i.color})),r.globalAlpha=1},t.prototype.resetSize=function(t){this._opts=e(e({},this._opts),t)},t.prototype.isPointAtScrollY=function(t){var e=this._opts,n=e.width,o=e.height,i=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(this._doSize(n-i.lineWidth),0,this._doSize(i.lineWidth),this._doSize(o)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},t.prototype.isPointAtScrollX=function(t){var e=this._opts,n=e.width,o=e.height,i=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(0,this._doSize(o-i.lineWidth),this._doSize(n-i.lineWidth),this._doSize(i.lineWidth)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},t.prototype.getLineWidth=function(){return this._opts.scrollConfig.lineWidth},t.prototype.calc=function(t){var e=this._opts,n=e.width,o=e.height,i=e.scrollConfig,r=2.5*i.lineWidth,s=i.lineWidth,l=0,a=0;t.left<=0&&t.right<=0&&(l=Math.max(r,n-(Math.abs(t.left)+Math.abs(t.right))))>=n&&(l=0),(t.top<=0||t.bottom<=0)&&(a=Math.max(r,o-(Math.abs(t.top)+Math.abs(t.bottom))))>=o&&(a=0);var c=0;l>0&&(c=l/2+(n-l)*Math.abs(t.left)/(Math.abs(t.left)+Math.abs(t.right)),c=Math.min(Math.max(0,c-l/2),n-l));var h=0;return a>0&&(h=a/2+(o-a)*Math.abs(t.top)/(Math.abs(t.top)+Math.abs(t.bottom)),h=Math.min(Math.max(0,h-a/2),o-a)),{lineSize:s,xSize:l,ySize:a,translateY:h,translateX:c,color:this._opts.scrollConfig.color}},t.prototype._doSize=function(t){return t*this._opts.devicePixelRatio},t.prototype._getOpts=function(t){var o=e({scrollConfig:z},t);return o.scrollConfig||(o.scrollConfig=z),o.scrollConfig.lineWidth>0||(o.scrollConfig.lineWidth=z.lineWidth),o.scrollConfig.lineWidth=Math.max(o.scrollConfig.lineWidth,z.lineWidth),!0!==n(o.scrollConfig.color)&&(o.scrollConfig.color=o.scrollConfig.color),o},t}();function L(t,e){var n=e.x,o=e.y,i=e.w,r=e.h,s=e.color,l=e.r;(i<2*(l=Math.min(l,i/2,r/2))||r<2*l)&&(l=0),t.beginPath(),t.moveTo(n+l,o),t.arcTo(n+i,o,n+i,o+r,l),t.arcTo(n+i,o+r,n,o+r,l),t.arcTo(n,o+r,n,o,l),t.arcTo(n,o,n+i,o,l),t.closePath(),t.fillStyle=s,t.fill()}var D,T=Symbol('_opts'),k=Symbol('_ctx'),M=function(){function t(t,e){this[T]=e,this[k]=t}return t.prototype.resetSize=function(t){this[T]=e(e({},this[T]),t)},t.prototype.calcScreen=function(){var t=this[k].getTransform().scale,e=this[T],n=e.width,o=e.height,i=e.contextWidth,r=e.contextHeight,s=e.devicePixelRatio,l=!0,a=!0,c=!0,h=!0;i*t<=n&&(this[k].setTransform({scrollX:(n-i*t)/2}),l=!1,a=!1),r*t<=o&&(this[k].setTransform({scrollY:(o-r*t)/2}),c=!1,h=!1),i*t>=n&&this[k].getTransform().scrollX>0&&(this[k].setTransform({scrollX:0}),l=!1),r*t>=o&&this[k].getTransform().scrollY>0&&(this[k].setTransform({scrollY:0}),c=!1);var u=this[k].getTransform(),f=u.scrollX,d=u.scrollY;f<0&&Math.abs(f)>Math.abs(i*t-n)&&(this[k].setTransform({scrollX:0-Math.abs(i*t-n)}),a=!1),d<0&&Math.abs(d)>Math.abs(r*t-o)&&(this[k].setTransform({scrollY:0-Math.abs(r*t-o)}),h=!1);var p=this[k].getTransform(),v=p.scrollX,g=p.scrollY;return{size:{x:v*t,y:g*t,w:i*t,h:r*t},position:{top:g,bottom:o-(r*t+g),left:v,right:n-(i*t+v)},deviceSize:{x:v*s,y:g*s,w:i*s*t,h:r*s*t},width:this[T].width,height:this[T].height,devicePixelRatio:this[T].devicePixelRatio,canScrollYPrev:c,canScrollYNext:h,canScrollXPrev:l,canScrollXNext:a}},t.prototype.calcScreenScroll=function(t,e,n,o,i){var r=o-n;t<=0&&e<=0&&(r=Math.abs(t)+Math.abs(e));var s=1;return r>0&&(s=r/(o-n)),0-s*i},t}(),I=Symbol('_canvas'),W=Symbol('_displayCanvas'),O=Symbol('_helperCanvas'),U=Symbol('_mount'),R=Symbol('_opts'),A=Symbol('_hasRendered'),F=Symbol('_ctx'),Y=Symbol('_helperCtx'),X=Symbol('_watcher'),N=Symbol('_render'),H=Symbol('_parsePrivateOptions'),j=Symbol('_scroller'),B=Symbol('_initEvent'),G=Symbol('_doScrollX'),Q=Symbol('_doScrollY'),V=Symbol('_doMoveScroll'),$=Symbol('_resetContext'),Z=Symbol('_screen'),q=x.throttle,J=x.Context,K=function(){function t(t,e){this[D]=!1,this[U]=t,this[I]=document.createElement('canvas'),this[O]=document.createElement('canvas'),this[W]=document.createElement('canvas'),this[U].appendChild(this[W]),this[R]=this[H](e);var n=this[I].getContext('2d'),o=this[W].getContext('2d'),i=this[O].getContext('2d');this[F]=new J(n,this[R]),this[Y]=new J(i,this[R]),this[Z]=new M(this[F],this[R]),this[X]=new E(this[W],this[F]),this[j]=new C(o,{width:e.width,height:e.height,devicePixelRatio:e.devicePixelRatio||1,scrollConfig:e.scrollConfig}),this[N]()}return t.prototype.getDisplayContext2D=function(){return this[W].getContext('2d')},t.prototype.getOriginContext2D=function(){return this[F].getContext()},t.prototype.getHelperContext2D=function(){return this[Y].getContext()},t.prototype.getContext=function(){return this[F]},t.prototype.getHelperContext=function(){return this[Y]},t.prototype.scale=function(t){t>0&&(this[F].setTransform({scale:t}),this[Y].setTransform({scale:t}));var e=this[Z].calcScreen();return{position:e.position,size:e.size}},t.prototype.scrollX=function(t){this[X].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[F].setTransform({scrollX:t}),this[Y].setTransform({scrollX:t}));var e=this[Z].calcScreen(),n=e.position,o=e.size,i=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,l=e.canScrollYPrev;return this[X].setStatusMap({canScrollYPrev:l,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:i}),{position:n,size:o}},t.prototype.scrollY=function(t){this[X].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[F].setTransform({scrollY:t}),this[Y].setTransform({scrollY:t}));var e=this[Z].calcScreen(),n=e.position,o=e.size,i=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,l=e.canScrollYPrev;return this[X].setStatusMap({canScrollYPrev:l,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:i}),{position:n,size:o}},t.prototype.getTransform=function(){return this[F].getTransform()},t.prototype.draw=function(){this.clear();var t=this[Z].calcScreen(),e=t.position,n=t.deviceSize,o=t.size,i=this[W].getContext('2d');return null==i||i.drawImage(this[I],n.x,n.y,n.w,n.h),null==i||i.drawImage(this[O],n.x,n.y,n.w,n.h),!0===this[R].canScroll&&this[j].draw(e),{position:e,size:o}},t.prototype.clear=function(){var t=this[W].getContext('2d');null==t||t.clearRect(0,0,this[W].width,this[W].height)},t.prototype.on=function(t,e){this[X].on(t,e)},t.prototype.off=function(t,e){this[X].off(t,e)},t.prototype.getScreenInfo=function(){return this[Z].calcScreen()},t.prototype.setCursor=function(t){this[W].style.cursor=t},t.prototype.resetCursor=function(){this[W].style.cursor='auto'},t.prototype.resetSize=function(t){this[R]=e(e({},this[R]),t),this[$](),this[F].resetSize(t),this[Y].resetSize(t),this[Z].resetSize(t),this[j].resetSize({width:this[R].width,height:this[R].height,devicePixelRatio:this[R].devicePixelRatio}),this.draw()},t.prototype.getScrollLineWidth=function(){var t=0;return!0===this[R].canScroll&&(t=this[j].getLineWidth()),t},t.prototype.pointScreenToContext=function(t){var e=this.getTransform(),n=e.scrollX,o=e.scrollY,i=e.scale;return{x:(t.x-n)/i,y:(t.y-o)/i}},t.prototype.pointContextToScreen=function(t){var e=this.getTransform(),n=e.scrollX,o=e.scrollY,i=e.scale;return{x:t.x*i+n,y:t.y*i+o}},t.prototype[(D=A,N)]=function(){!0!==this[A]&&(this[$](),this[B](),this[A]=!0)},t.prototype[$]=function(){var t,n,o,i,r,s,l=this[R],a=l.width,c=l.height,h=l.contextWidth,u=l.contextHeight,f=l.devicePixelRatio;this[I].width=h*f,this[I].height=u*f,this[O].width=h*f,this[O].height=u*f,this[W].width=a*f,this[W].height=c*f,t=this[W],n={width:"".concat(a,"px"),height:"".concat(c,"px")},o=function(t){var e={};return(t.getAttribute('style')||'').split(';').forEach((function(t){var n=t.split(':');n[0]&&'string'==typeof n[0]&&(e[n[0]]=n[1]||'')})),e}(t),i=e(e({},o),n),r=Object.keys(i),s='',r.forEach((function(t){s+="".concat(t,":").concat(i[t]||'',";")})),t.setAttribute('style',s)},t.prototype[H]=function(t){return e(e({},{devicePixelRatio:1}),t)},t.prototype[B]=function(){var t=this;if(!0!==this[A]&&!0===this[R].canScroll){this.on('wheelX',q((function(e){t[G](e)}),16)),this.on('wheelY',q((function(e){t[Q](e)}),16));var e=null;this.on('moveStart',q((function(n){t[j].isPointAtScrollX(n)?e='x':t[j].isPointAtScrollY(n)&&(e='y')}),16)),this.on('move',q((function(n){e&&t[V](e,n)}),16)),this.on('moveEnd',q((function(n){e&&t[V](e,n),e=null}),16))}},t.prototype[G]=function(t,e){var n=this[R].width,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[F].getTransform().scrollX);var i=this[Z].calcScreen().position,r=this[j].calc(i).xSize,s=this[Z].calcScreenScroll(i.left,i.right,r,n,t);this.scrollX(o+s),this.draw()},t.prototype[Q]=function(t,e){var n=this[R].height,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[F].getTransform().scrollY);var i=this[Z].calcScreen().position,r=this[j].calc(i).ySize,s=this[Z].calcScreenScroll(i.top,i.bottom,r,n,t);this.scrollY(o+s),this.draw()},t.prototype[V]=function(t,e){if(t){var n=this[Z].calcScreen().position,o=this[j].calc(n),i=o.xSize,r=o.ySize;'x'===t?this[G](e.x-i/2,0):'y'===t&&this[Q](e.y-r/2,0)}},t}();function tt(t,e){var n=-1;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n>0||(n=setTimeout((function(){t.apply(void 0,o),n=-1}),e))}}function et(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function nt(){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 ot(t){return function t(e){var n,o=(n=e,Object.prototype.toString.call(n).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var i=[];return e.forEach((function(e){i.push(t(e))})),i}if('Object'===o){var r={};return Object.keys(e).forEach((function(n){r[n]=t(e[n])})),r}}(t)}function it(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}Object.freeze({__proto__:null,Board:K});var rt={type:function(t,e){var n=it(t);return!0===e?n.toLocaleLowerCase():n},array:function(t){return'Array'===it(t)},json:function(t){return'Object'===it(t)},function:function(t){return'Function'===it(t)},asyncFunction:function(t){return'AsyncFunction'===it(t)},string:function(t){return'String'===it(t)},number:function(t){return'Number'===it(t)},undefined:function(t){return'Undefined'===it(t)},null:function(t){return'Null'===it(t)},promise:function(t){return'Promise'===it(t)}},st=function(){return st=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},st.apply(this,arguments)};function lt(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function at(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function ct(t,e){var n=e.width,o=e.height;return new Promise((function(e,i){var r="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(n||'',"\" height = \"").concat(o||'',"\">\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([r],{type:'image/svg+xml;charset=utf-8'}),l=new FileReader;l.readAsDataURL(s),l.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},l.onerror=function(t){i(t)}}))}function ht(t){return new Promise((function(e,n){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),i=new FileReader;i.readAsDataURL(o),i.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},i.onerror=function(t){n(t)}}))}var ut=window.Image;function ft(t){return new Promise((function(e,n){var o=new ut;o.setAttribute('crossOrigin','anonymous'),o.onload=function(){e(o)},o.onabort=n,o.onerror=n,o.src=t}))}var dt=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=st(st({},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=st(st({},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,n,o,i,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(n),o,i,r)},t.prototype.rect=function(t,e,n,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.fillRect=function(t,e,n,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.clearRect=function(t,e,n,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},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,n,o,i){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),this._doSize(i))},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 n=t[0],o=t[1],i=t[2],r=t[3],s=t[4],l=t[t.length-4],a=t[t.length-3],c=t[t.length-2],h=t[t.length-1];return 9===t.length?this._ctx.drawImage(n,this._doSize(o),this._doSize(i),this._doSize(r),this._doSize(s),this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h)):this._ctx.drawImage(n,this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h))},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,n,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(n))},t.prototype.strokeText=function(t,e,n,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(n))},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,n,o,i,r,s,l){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),i,r,s,l)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollX)/n;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollY)/n;return this._doSize(o)},t}();function pt(t){return'number'==typeof t&&(t>0||t<=0)}function vt(t){return'number'==typeof t&&t>=0}function gt(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function mt(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var yt={x:function(t){return pt(t)},y:function(t){return pt(t)},w:vt,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:pt,borderWidth:function(t){return vt(t)},borderRadius:function(t){return pt(t)&&t>=0},color:function(t){return et(t)},imageSrc:function(t){return mt(t)||gt(t)},imageURL:gt,imageBase64:mt,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return pt(t)&&t>0},lineHeight:function(t){return pt(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 pt(t)&&t>0}};function _t(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!yt.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!yt.number(n))&&!(t.hasOwnProperty('borderWidth')&&!yt.number(o)))}var St={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(yt.x(e)&&yt.y(n)&&yt.w(o)&&yt.h(i)&&yt.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!yt.text(e)&&(!!yt.color(n)&&(!!yt.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!yt.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!yt.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!yt.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!yt.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!yt.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!yt.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!yt.color(h))&&!!_t(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!yt.color(e))&&!!_t(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!yt.color(e))&&(!(t.hasOwnProperty('borderColor')&&!yt.color(n))&&!(t.hasOwnProperty('borderWidth')&&!yt.number(o)))},imageDesc:function(t){var e=t.src;return!!yt.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!yt.svg(e)},htmlDesc:function(t){var e=t.html;return!!yt.html(e)}};Object.freeze({__proto__:null,is:yt,check:St,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,n){return function o(i){var r=t[i];i===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:tt,loadImage:ft,loadSVG:function(t){return lt(this,void 0,void 0,(function(){return at(this,(function(e){switch(e.label){case 0:return[4,ht(t)];case 1:return[4,ft(e.sent())];case 2:return[2,e.sent()]}}))}))},loadHTML:function(t,e){return lt(this,void 0,void 0,(function(){return at(this,(function(n){switch(n.label){case 0:return[4,ct(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,ft(n.sent())];case 2:return[2,n.sent()]}}))}))},downloadImageFromCanvas:function(t,e){var n=e.filename,o=e.type,i=void 0===o?'image/jpeg':o,r=t.toDataURL(i),s=document.createElement('a');s.href=r,s.download=n;var l=document.createEvent('MouseEvents');l.initEvent('click',!0,!1),s.dispatchEvent(l)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:et,createUUID:nt,istype:rt,deepClone:ot,Context:dt});var xt=function(t,e){return xt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},xt(t,e)};var bt=function(){return bt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},bt.apply(this,arguments)};function wt(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function Et(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function Pt(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function zt(){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 Ct(t){return function t(e){var n,o=(n=e,Object.prototype.toString.call(n).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var i=[];return e.forEach((function(e){i.push(t(e))})),i}if('Object'===o){var r={};return Object.keys(e).forEach((function(n){r[n]=t(e[n])})),r}}(t)}function Lt(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var Dt={type:function(t,e){var n=Lt(t);return!0===e?n.toLocaleLowerCase():n},array:function(t){return'Array'===Lt(t)},json:function(t){return'Object'===Lt(t)},function:function(t){return'Function'===Lt(t)},asyncFunction:function(t){return'AsyncFunction'===Lt(t)},string:function(t){return'String'===Lt(t)},number:function(t){return'Number'===Lt(t)},undefined:function(t){return'Undefined'===Lt(t)},null:function(t){return'Null'===Lt(t)},promise:function(t){return'Promise'===Lt(t)}},Tt=function(){return Tt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Tt.apply(this,arguments)};function kt(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function Mt(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function It(t,e){var n=e.width,o=e.height;return new Promise((function(e,i){var r="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(n||'',"\" height = \"").concat(o||'',"\">\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([r],{type:'image/svg+xml;charset=utf-8'}),l=new FileReader;l.readAsDataURL(s),l.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},l.onerror=function(t){i(t)}}))}function Wt(t){return new Promise((function(e,n){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),i=new FileReader;i.readAsDataURL(o),i.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},i.onerror=function(t){n(t)}}))}var Ot=window.Image;function Ut(t){return new Promise((function(e,n){var o=new Ot;o.setAttribute('crossOrigin','anonymous'),o.onload=function(){e(o)},o.onabort=n,o.onerror=n,o.src=t}))}function Rt(t){return kt(this,void 0,void 0,(function(){return Mt(this,(function(e){switch(e.label){case 0:return[4,Wt(t)];case 1:return[4,Ut(e.sent())];case 2:return[2,e.sent()]}}))}))}function At(t,e){return kt(this,void 0,void 0,(function(){return Mt(this,(function(n){switch(n.label){case 0:return[4,It(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,Ut(n.sent())];case 2:return[2,n.sent()]}}))}))}var Ft=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=Tt(Tt({},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=Tt(Tt({},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,n,o,i,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(n),o,i,r)},t.prototype.rect=function(t,e,n,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.fillRect=function(t,e,n,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.clearRect=function(t,e,n,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},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,n,o,i){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),this._doSize(i))},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 n=t[0],o=t[1],i=t[2],r=t[3],s=t[4],l=t[t.length-4],a=t[t.length-3],c=t[t.length-2],h=t[t.length-1];return 9===t.length?this._ctx.drawImage(n,this._doSize(o),this._doSize(i),this._doSize(r),this._doSize(s),this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h)):this._ctx.drawImage(n,this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h))},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,n,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(n))},t.prototype.strokeText=function(t,e,n,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(n))},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,n,o,i,r,s,l){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),i,r,s,l)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollX)/n;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollY)/n;return this._doSize(o)},t}();function Yt(t){return'number'==typeof t&&(t>0||t<=0)}function Xt(t){return'number'==typeof t&&t>=0}function Nt(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function Ht(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var jt={x:function(t){return Yt(t)},y:function(t){return Yt(t)},w:Xt,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:Yt,borderWidth:function(t){return Xt(t)},borderRadius:function(t){return Yt(t)&&t>=0},color:function(t){return Pt(t)},imageSrc:function(t){return Ht(t)||Nt(t)},imageURL:Nt,imageBase64:Ht,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return Yt(t)&&t>0},lineHeight:function(t){return Yt(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 Yt(t)&&t>0}};function Bt(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!jt.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!jt.number(n))&&!(t.hasOwnProperty('borderWidth')&&!jt.number(o)))}var Gt={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(jt.x(e)&&jt.y(n)&&jt.w(o)&&jt.h(i)&&jt.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!jt.text(e)&&(!!jt.color(n)&&(!!jt.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!jt.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!jt.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!jt.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!jt.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!jt.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!jt.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!jt.color(h))&&!!Bt(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!jt.color(e))&&!!Bt(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!jt.color(e))&&(!(t.hasOwnProperty('borderColor')&&!jt.color(n))&&!(t.hasOwnProperty('borderWidth')&&!jt.number(o)))},imageDesc:function(t){var e=t.src;return!!jt.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!jt.svg(e)},htmlDesc:function(t){var e=t.html;return!!jt.html(e)}};function Qt(t,e,n){var o=function(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}(e),i=function(t){return t/180*Math.PI}(e.angle||0);return function(t,e,n,o){e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(n),t.translate(-e.x,-e.y));o(t),e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(-n),t.translate(-e.x,-e.y))}(t,o,i||0,n)}function Vt(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 $t(t,e,n){Vt(t),function(t,e){Vt(t),Qt(t,e,(function(){if(e.desc.borderWidth&&e.desc.borderWidth>0){var n=e.desc.borderWidth,o='#000000';!0===Pt(e.desc.borderColor)&&(o=e.desc.borderColor);var i=e.x-n/2,r=e.y-n/2,s=e.w+n,l=e.h+n,a=e.desc.borderRadius||0;(a=Math.min(a,s/2,l/2))<s/2&&a<l/2&&(a+=n/2);var c=e.desc;void 0!==c.shadowColor&&Pt(c.shadowColor)&&t.setShadowColor(c.shadowColor),void 0!==c.shadowOffsetX&&jt.number(c.shadowOffsetX)&&t.setShadowOffsetX(c.shadowOffsetX),void 0!==c.shadowOffsetY&&jt.number(c.shadowOffsetY)&&t.setShadowOffsetY(c.shadowOffsetY),void 0!==c.shadowBlur&&jt.number(c.shadowBlur)&&t.setShadowBlur(c.shadowBlur),t.beginPath(),t.setLineWidth(n),t.setStrokeStyle(o),t.moveTo(i+a,r),t.arcTo(i+s,r,i+s,r+l,a),t.arcTo(i+s,r+l,i,r+l,a),t.arcTo(i,r+l,i,r,a),t.arcTo(i,r,i+s,r,a),t.closePath(),t.stroke()}}))}(t,e),Vt(t),Qt(t,e,(function(){var o=e.x,i=e.y,r=e.w,s=e.h,l=e.desc.borderRadius||0;(r<2*(l=Math.min(l,r/2,s/2))||s<2*l)&&(l=0),t.beginPath(),t.moveTo(o+l,i),t.arcTo(o+r,i,o+r,i+s,l),t.arcTo(o+r,i+s,o,i+s,l),t.arcTo(o,i+s,o,i,l),t.arcTo(o,i,o+r,i,l),t.closePath(),('string'==typeof n||['CanvasPattern'].includes(Dt.type(n)))&&t.setFillStyle(n),t.fill()}))}function Zt(t,e){$t(t,e,e.desc.bgColor)}function qt(t,e,n){var o=n.getContent(e.uuid);Qt(t,e,(function(){o&&t.drawImage(o,e.x,e.y,e.w,e.h)}))}function Jt(t,e,n){var o=n.getContent(e.uuid);Qt(t,e,(function(){o&&t.drawImage(o,e.x,e.y,e.w,e.h)}))}function Kt(t,e,n){var o=n.getContent(e.uuid);Qt(t,e,(function(){o&&t.drawImage(o,e.x,e.y,e.w,e.h)}))}function te(t,e,n){Vt(t),$t(t,e,e.desc.bgColor||'transparent'),Qt(t,e,(function(){var n=bt({fontSize:12,fontFamily:'sans-serif',textAlign:'center'},e.desc);t.setFillStyle(e.desc.color),t.setTextBaseline('top'),t.setFont({fontWeight:n.fontWeight,fontSize:n.fontSize,fontFamily:n.fontFamily});var o=n.text.replace(/\r\n/gi,'\n'),i=n.lineHeight||n.fontSize,r=o.split('\n'),s=[],l=0;r.forEach((function(n,o){var a='';if(n.length>0){for(var c=0;c<n.length&&(t.measureText(a+(n[c]||'')).width<t.calcDeviceNum(e.w)?a+=n[c]||'':(s.push({text:a,width:t.calcScreenNum(t.measureText(a).width)}),a=n[c]||'',l++),!((l+1)*i>e.h));c++)if(n.length-1===c&&(l+1)*i<e.h){s.push({text:a,width:t.calcScreenNum(t.measureText(a).width)}),o<r.length-1&&l++;break}}else s.push({text:'',width:0})}));var a=e.y;if(s.length*i<e.h&&(a+=(e.h-s.length*i)/2),void 0!==n.textShadowColor&&Pt(n.textShadowColor)&&t.setShadowColor(n.textShadowColor),void 0!==n.textShadowOffsetX&&jt.number(n.textShadowOffsetX)&&t.setShadowOffsetX(n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&jt.number(n.textShadowOffsetY)&&t.setShadowOffsetY(n.textShadowOffsetY),void 0!==n.textShadowBlur&&jt.number(n.textShadowBlur)&&t.setShadowBlur(n.textShadowBlur),s.forEach((function(o,r){var s=e.x;'center'===n.textAlign?s=e.x+(e.w-o.width)/2:'right'===n.textAlign&&(s=e.x+(e.w-o.width)),t.fillText(o.text,s,a+i*r)})),Vt(t),Pt(n.strokeColor)&&void 0!==n.strokeWidth&&n.strokeWidth>0){var c=e.y;s.length*i<e.h&&(c+=(e.h-s.length*i)/2),s.forEach((function(o,r){var s=e.x;'center'===n.textAlign?s=e.x+(e.w-o.width)/2:'right'===n.textAlign&&(s=e.x+(e.w-o.width)),void 0!==n.strokeColor&&t.setStrokeStyle(n.strokeColor),void 0!==n.strokeWidth&&n.strokeWidth>0&&t.setLineWidth(n.strokeWidth),t.strokeText(o.text,s,c+i*r)}))}}))}function ee(t,e){Vt(t),Qt(t,e,(function(t){var n=e.x,o=e.y,i=e.w,r=e.h,s=e.desc,l=s.bgColor,a=void 0===l?'#000000':l,c=s.borderColor,h=void 0===c?'#000000':c,u=s.borderWidth,f=void 0===u?0:u,d=i/2,p=r/2,v=n+d,g=o+p;if(f&&f>0){var m=f/2+d,y=f/2+p;t.beginPath(),t.setStrokeStyle(h),t.setLineWidth(f),t.ellipse(v,g,m,y,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath(),t.setFillStyle(a),t.ellipse(v,g,d,p,0,0,2*Math.PI),t.closePath(),t.fill()}))}function ne(t,e,n){var o;Vt(t);var i=t.getSize();if(t.clearRect(0,0,i.contextWidth,i.contextHeight),'string'==typeof e.bgColor&&Pt(e.bgColor)&&function(t,e){var n=t.getSize();t.setFillStyle(e),t.fillRect(0,0,n.contextWidth,n.contextHeight)}(t,e.bgColor),e.elements.length>0)for(var r=0;r<e.elements.length;r++){var s=e.elements[r];if(!0!==(null===(o=null==s?void 0:s.operation)||void 0===o?void 0:o.invisible))switch(s.type){case'rect':Zt(t,s);break;case'text':te(t,s);break;case'image':qt(t,s,n);break;case'svg':Jt(t,s,n);break;case'html':Kt(t,s,n);break;case'circle':ee(t,s)}}}Object.freeze({__proto__:null,is:jt,check:Gt,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,n){return function o(i){var r=t[i];i===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var n=-1;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n>0||(n=setTimeout((function(){t.apply(void 0,o),n=-1}),e))}},loadImage:Ut,loadSVG:Rt,loadHTML:At,downloadImageFromCanvas:function(t,e){var n=e.filename,o=e.type,i=void 0===o?'image/jpeg':o,r=t.toDataURL(i),s=document.createElement('a');s.href=r,s.download=n;var l=document.createEvent('MouseEvents');l.initEvent('click',!0,!1),s.dispatchEvent(l)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:Pt,createUUID:zt,istype:Dt,deepClone:Ct,Context:Ft});var oe,ie=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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"}(oe||(oe={}));var re,se,le,ae,ce=function(){function t(t){this._currentLoadData={},this._currentUUIDQueue=[],this._storageLoadData={},this._status=oe.FREE,this._waitingLoadQueue=[],this._opts=t,this._event=new ie,this._waitingLoadQueue=[]}return t.prototype.load=function(t,e){var n=this._resetLoadData(t,e),o=n[0],i=n[1];this._status===oe.FREE||this._status===oe.COMPLETE?(this._currentUUIDQueue=o,this._currentLoadData=i,this._loadTask()):this._status===oe.LOADING&&o.length>0&&this._waitingLoadQueue.push({uuidQueue:o,loadData:i})},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===oe.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 n={},o=[],i=this._storageLoadData,r=t.elements.length-1;r>=0;r--){var s=t.elements[r];['image','svg','html'].includes(s.type)&&(i[s.uuid]?e.includes(s.uuid)&&(n[s.uuid]=this._createEmptyLoadItem(s),o.push(s.uuid)):(n[s.uuid]=this._createEmptyLoadItem(s),o.push(s.uuid)))}return[o,n]},t.prototype._createEmptyLoadItem=function(t){var e='',n=t.type,o=t.w,i=t.h;if('image'===t.type)e=(r=t).desc.src||'';else if('svg'===t.type){e=(r=t).desc.svg||''}else if('html'===t.type){var r;e=function(t){return t.replace(/<script[\s\S]*?<\/script>/gi,'')}((r=t).desc.html||''),o=r.desc.width||t.w,i=r.desc.height||t.h}return{uuid:t.uuid,type:n,status:'null',content:null,source:e,elemW:o,elemH:i,element:Ct(t)}},t.prototype._loadTask=function(){var t=this;if(this._status!==oe.LOADING){if(this._status=oe.LOADING,0===this._currentUUIDQueue.length){if(0===this._waitingLoadQueue.length)return this._status=oe.COMPLETE,void this._event.trigger('complete',void 0);var e=this._waitingLoadQueue.shift();if(e){var n=e.uuidQueue,o=e.loadData;this._currentLoadData=o,this._currentUUIDQueue=n}}var i=this._opts.maxParallelNum,r=this._currentUUIDQueue.splice(0,i),s={};r.forEach((function(t,e){s[t]=e}));var l=[],a=function(){if(l.length>=i)return!1;if(0===r.length)return!0;for(var e=function(e){var n=r.shift();if(void 0===n)return"break";l.push(n),t._loadElementSource(t._currentLoadData[n]).then((function(e){var o,i;l.splice(l.indexOf(n),1);var s=a();t._storageLoadData[n]={uuid:n,type:t._currentLoadData[n].type,status:'loaded',content:e,source:t._currentLoadData[n].source,elemW:t._currentLoadData[n].elemW,elemH:t._currentLoadData[n].elemH,element:t._currentLoadData[n].element},0===l.length&&0===r.length&&!0===s&&(t._status=oe.FREE,t._loadTask()),t._event.trigger('load',{uuid:null===(o=t._storageLoadData[n])||void 0===o?void 0:o.uuid,type:t._storageLoadData[n].type,status:t._storageLoadData[n].status,content:t._storageLoadData[n].content,source:t._storageLoadData[n].source,elemW:t._storageLoadData[n].elemW,elemH:t._storageLoadData[n].elemH,element:null===(i=t._storageLoadData[n])||void 0===i?void 0:i.element})})).catch((function(e){var o,i,s,c,h,u,f,d,p,v,g,m;console.warn(e),l.splice(l.indexOf(n),1);var y=a();t._currentLoadData[n]&&(t._storageLoadData[n]={uuid:n,type:null===(o=t._currentLoadData[n])||void 0===o?void 0:o.type,status:'fail',content:null,error:e,source:null===(i=t._currentLoadData[n])||void 0===i?void 0:i.source,elemW:null===(s=t._currentLoadData[n])||void 0===s?void 0:s.elemW,elemH:null===(c=t._currentLoadData[n])||void 0===c?void 0:c.elemH,element:null===(h=t._currentLoadData[n])||void 0===h?void 0:h.element}),0===l.length&&0===r.length&&!0===y&&(t._status=oe.FREE,t._loadTask()),t._currentLoadData[n]&&t._event.trigger('error',{uuid:n,type:null===(u=t._storageLoadData[n])||void 0===u?void 0:u.type,status:null===(f=t._storageLoadData[n])||void 0===f?void 0:f.status,content:null===(d=t._storageLoadData[n])||void 0===d?void 0:d.content,source:null===(p=t._storageLoadData[n])||void 0===p?void 0:p.source,elemW:null===(v=t._storageLoadData[n])||void 0===v?void 0:v.elemW,elemH:null===(g=t._storageLoadData[n])||void 0===g?void 0:g.elemH,element:null===(m=t._storageLoadData[n])||void 0===m?void 0:m.element})}))},n=l.length;n<i;n++){if("break"===e())break}return!1};a()}},t.prototype._loadElementSource=function(t){return wt(this,void 0,void 0,(function(){return Et(this,(function(e){switch(e.label){case 0:return t&&'image'===t.type?[4,Ut(t.source)]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return t&&'svg'===t.type?[4,Rt(t.source)]:[3,4];case 4:return t&&'html'===t.type?[4,At(t.source,{width:t.elemW,height:t.elemH})]:[3,6];case 6:throw Error('Element\'s source is not support!')}}))}))},t}(),he=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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}(),ue=Symbol('_queue'),fe=Symbol('_ctx'),de=Symbol('_status'),pe=Symbol('_loader'),ve=Symbol('_opts'),ge=Symbol('_freeze'),me=Symbol('_drawFrame'),ye=Symbol('_retainQueueOneItem'),_e=window.requestAnimationFrame;!function(t){t.NULL="null",t.FREE="free",t.DRAWING="drawing",t.FREEZE="freeze"}(ae||(ae={}));var Se=function(t){function e(e){var n=t.call(this)||this;return n[re]=[],n[se]=null,n[le]=ae.NULL,n[ve]=e,n[pe]=new ce({maxParallelNum:6}),n[pe].on('load',(function(t){n[me](),n.trigger('load',{element:t.element})})),n[pe].on('error',(function(t){n.trigger('error',{element:t.element,error:t.error})})),n[pe].on('complete',(function(){n.trigger('loadComplete',{t:Date.now()})})),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}xt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.render=function(t,e,n){var o=(n||{}).changeResourceUUIDs,i=void 0===o?[]:o;this[de]=ae.FREE;var r=Ct(e);if(Array.isArray(r.elements)&&r.elements.forEach((function(t){'string'==typeof t.uuid&&t.uuid||(t.uuid=zt())})),!this[fe])if(this[ve]&&'[object HTMLCanvasElement]'===Object.prototype.toString.call(t)){var s=this[ve],l=s.width,a=s.height,c=s.contextWidth,h=s.contextHeight,u=s.devicePixelRatio,f=t;f.width=l*u,f.height=a*u;var d=f.getContext('2d');this[fe]=new Ft(d,{width:l,height:a,contextWidth:c||l,contextHeight:h||a,devicePixelRatio:u})}else t&&(this[fe]=t);if(![ae.FREEZE].includes(this[de])){var p=Ct({data:r});this[ue].push(p),this[me](),this[pe].load(r,i||[])}},e.prototype.getContext=function(){return this[fe]},e.prototype.thaw=function(){this[de]=ae.FREE},e.prototype[(re=ue,se=fe,le=de,ge)]=function(){this[de]=ae.FREEZE},e.prototype[me]=function(){var t=this;this[de]!==ae.FREEZE&&_e((function(){if(t[de]!==ae.FREEZE){var e=t[fe],n=t[ue][0],o=!1;t[ue].length>1?n=t[ue].shift():o=!0,!0!==t[pe].isComplete()?(t[me](),n&&e&&ne(e,n.data,t[pe])):n&&e?(ne(e,n.data,t[pe]),t[ye](),o?t[de]=ae.FREE:t[me]()):t[de]=ae.FREE,t.trigger('drawFrame',{t:Date.now()}),!0===t[pe].isComplete()&&1===t[ue].length&&t[de]===ae.FREE&&(e&&t[ue][0]&&t[ue][0].data&&ne(e,t[ue][0].data,t[pe]),t.trigger('drawFrameComplete',{t:Date.now()}),t[ge]())}}))},e.prototype[ye]=function(){if(!(this[ue].length<=1)){var t=Ct(this[ue][this[ue].length-1]);this[ue]=[t]}},e}(he);function xe(t){return'number'==typeof t&&(t>0||t<=0)}function be(t){return'number'==typeof t&&t>=0}function we(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function Ee(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}Object.freeze({__proto__:null,Renderer:Se});var Pe={x:function(t){return xe(t)},y:function(t){return xe(t)},w:be,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:xe,borderWidth:function(t){return be(t)},borderRadius:function(t){return xe(t)&&t>=0},color:function(t){return et(t)},imageSrc:function(t){return Ee(t)||we(t)},imageURL:we,imageBase64:Ee,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return xe(t)&&t>0},lineHeight:function(t){return xe(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 xe(t)&&t>0}};function ze(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!Pe.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!Pe.number(n))&&!(t.hasOwnProperty('borderWidth')&&!Pe.number(o)))}var Ce={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(Pe.x(e)&&Pe.y(n)&&Pe.w(o)&&Pe.h(i)&&Pe.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!Pe.text(e)&&(!!Pe.color(n)&&(!!Pe.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!Pe.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!Pe.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!Pe.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!Pe.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!Pe.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!Pe.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!Pe.color(h))&&!!ze(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!Pe.color(e))&&!!ze(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!Pe.color(e))&&(!(t.hasOwnProperty('borderColor')&&!Pe.color(n))&&!(t.hasOwnProperty('borderWidth')&&!Pe.number(o)))},imageDesc:function(t){var e=t.src;return!!Pe.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!Pe.svg(e)},htmlDesc:function(t){var e=t.html;return!!Pe.html(e)}};function Le(t){return t/180*Math.PI}function De(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Te(t,e){var n=e.x-t.x,o=t.y-e.y;if(0===n){if(o<0)return Math.PI/2;if(o>0)return 1.5*Math.PI}else if(0===o){if(n<0)return Math.PI;if(n>0)return 0}return n>0&&o<0?Math.atan(Math.abs(o)/Math.abs(n)):n<0&&o<0?Math.PI-Math.atan(Math.abs(o)/Math.abs(n)):n<0&&o>0?Math.PI+Math.atan(Math.abs(o)/Math.abs(n)):n>0&&o>0?2*Math.PI-Math.atan(Math.abs(o)/Math.abs(n)):null}var ke={elementWrapper:{color:'#2ab6f1',lockColor:'#aaaaaa',controllerSize:6,lineWidth:1,lineDash:[4,3]}};var Me=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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 Ie(t,e){var n,o;return(null===(n=null==t?void 0:t.desc)||void 0===n?void 0:n.src)!==(null===(o=null==e?void 0:e.desc)||void 0===o?void 0:o.src)}function We(t,e){var n,o;return(null===(n=null==t?void 0:t.desc)||void 0===n?void 0:n.svg)!==(null===(o=null==e?void 0:e.desc)||void 0===o?void 0:o.svg)}function Oe(t,e){var n,o,i,r,s,l;return(null===(n=null==t?void 0:t.desc)||void 0===n?void 0:n.html)!==(null===(o=null==e?void 0:e.desc)||void 0===o?void 0:o.html)||(null===(i=null==t?void 0:t.desc)||void 0===i?void 0:i.width)!==(null===(r=null==e?void 0:e.desc)||void 0===r?void 0:r.width)||(null===(s=null==t?void 0:t.desc)||void 0===s?void 0:s.height)!==(null===(l=null==e?void 0:e.desc)||void 0===l?void 0:l.height)}function Ue(t,e){var n=null,o=!1;switch(e.type){case'image':o=Ie(t,e);break;case'svg':o=We(t,e);break;case'html':o=Oe(t,e)}return!0===o&&(n=e.uuid),n}function Re(t){var e={};return t.elements.forEach((function(t){e[t.uuid]=t})),e}function Ae(t,e,n){return Fe(t,De(e),Le(e.angle||0)||0,n)}function Fe(t,e,n,o){e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(n),t.translate(-e.x,-e.y)),o(t),e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(-n),t.translate(-e.x,-e.y))}function Ye(t){var e=t.toFixed(2);return parseFloat(e)}function Xe(t){return Ye(t%360)}var Ne=Object.keys({text:{},rect:{},image:{},svg:{},circle:{},html:{}}),He=15,je=function(){function t(t){this._ctx=t}return t.prototype.initData=function(t){return t.elements.forEach((function(t){t.uuid&&'string'==typeof t.uuid||(t.uuid=nt())})),t},t.prototype.isPointInElement=function(t,e){for(var n,o,i=this._ctx,r=-1,s=null,l=function(l){var a=e.elements[l];if(!0===(null===(n=a.operation)||void 0===n?void 0:n.invisible))return"continue";var c=0;return(null===(o=a.desc)||void 0===o?void 0:o.borderWidth)>0&&(c=a.desc.borderWidth),Ae(i,a,(function(){i.beginPath(),i.moveTo(a.x-c,a.y-c),i.lineTo(a.x+a.w+c,a.y-c),i.lineTo(a.x+a.w+c,a.y+a.h+c),i.lineTo(a.x-c,a.y+a.h+c),i.lineTo(a.x-c,a.y-c),i.closePath(),i.isPointInPath(t.x,t.y)&&(r=l,s=a.uuid)})),r>=0?"break":void 0},a=e.elements.length-1;a>=0;a--){if("break"===l(a))break}return[r,s]},t.prototype.dragElement=function(t,e,n,o,i){var r=this.getElementIndex(t,e);if(t.elements[r]){var s=n.x-o.x,l=n.y-o.y;t.elements[r].x+=s/i,t.elements[r].y+=l/i,this.limitElementAttrs(t.elements[r])}},t.prototype.transformElement=function(t,e,n,o,i,r){var s,l,a=this.getElementIndex(t,e);if(!t.elements[a])return null;if(!0===(null===(l=null===(s=t.elements[a])||void 0===s?void 0:s.operation)||void 0===l?void 0:l.lock))return null;var c=(n.x-o.x)/i,h=(n.y-o.y)/i,u=t.elements[a];if(['top-left','top','top-right','right','bottom-right','bottom','bottom-left','left'].includes(r)){var f=function(t,e,n,o,i){var r={x:t.x,y:t.y,w:t.w,h:t.h};switch(t.angle,o){case'top-left':t.w-e>0&&t.h-n>0&&(r.x+=e,r.y+=n,r.w-=e,r.h-=n);break;case'top':if(0===t.angle||Math.abs(t.angle)<He)r.h-n>0&&(r.y+=n,r.h-=n);else if(t.angle>0||t.angle<0){var s=t.angle>0?t.angle:Math.max(0,t.angle+360),l=Ge(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(s<90){l=0-Qe(l,n);var h=Be(s);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}else if(s<180){l=Qe(l,e);h=Be(s-90);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}else if(s<270){l=Qe(l,n);h=Be(s-180);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}else if(s<360){l=0-Qe(l,e);h=Be(s-270);a-=(p=l/2)*Math.cos(h),c-=p*Math.sin(h)}r.h+l>0&&(r.h=r.h+l,r.x=a-r.w/2,r.y=c-r.h/2)}else r.h-n>0&&(r.y+=n,r.h-=n);break;case'top-right':r.h-n>0&&r.w+e>0&&(r.y+=n,r.w+=e,r.h-=n);break;case'right':if(0===t.angle||Math.abs(t.angle)<He)t.w+e>0&&(r.w+=e);else if(t.angle>0||t.angle<0){var u=t.angle>0?t.angle:Math.max(0,t.angle+360);l=Ge(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(u<90){l=Qe(l,n);h=Be(u);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}else if(u<180){l=Qe(l,n);h=Be(u-90);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}else if(u<270){l=Qe(l,n);h=Be(u-180);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h),l=0-l}else if(u<360){l=Qe(l,e);h=Be(u-270);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}r.w+l>0&&(r.w=r.w+l,r.x=a-r.w/2,r.y=c-r.h/2)}else t.w+e>0&&(r.w+=e);break;case'bottom-right':t.w+e>0&&t.h+n>0&&(r.w+=e,r.h+=n);break;case'bottom':if(0===t.angle||Math.abs(t.angle)<He)t.h+n>0&&(r.h+=n);else if(t.angle>0||t.angle<0){var f=t.angle>0?t.angle:Math.max(0,t.angle+360);l=Ge(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(f<90){l=Qe(l,n);h=Be(f);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}else if(f<180){l=0-Qe(l,e);h=Be(f-90);a-=(p=l/2)*Math.cos(h),c-=p*Math.sin(h)}else if(f<270){l=Qe(l,e);h=Be(f-180);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}else if(f<360){l=Qe(l,e);h=Be(f-270);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}r.h+l>0&&(r.h=r.h+l,r.x=a-r.w/2,r.y=c-r.h/2)}else t.h+n>0&&(r.h+=n);break;case'bottom-left':t.w-e>0&&t.h+n>0&&(r.x+=e,r.w-=e,r.h+=n);break;case'left':if(0===t.angle||Math.abs(t.angle)<He)t.w-e>0&&(r.x+=e,r.w-=e);else if(t.angle>0||t.angle<0){var d=t.angle>0?t.angle:Math.max(0,t.angle+360);l=Ge(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(d<90){l=0-Qe(l,e);h=Be(d);a-=(p=l/2)*Math.cos(h),c-=p*Math.sin(h)}else if(d<180){l=Qe(l,e);h=Be(d-90);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}else if(d<270){l=Qe(l,n);h=Be(d-180);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}else if(d<360){l=Qe(l,n);var p;h=Be(d-270);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}r.w+l>0&&(r.w=r.w+l,r.x=a-r.w/2,r.y=c-r.h/2)}else t.w-e>0&&(r.x+=e,r.w-=e)}return r}(u,c,h,r);u.x=f.x,u.y=f.y,u.w=f.w,u.h=f.h}else if('rotate'===r){var d=function(t,e,n){var o=Te(t,e),i=Te(t,n);return null!==i&&null!==o?o>3*Math.PI/2&&i<Math.PI/2?i+(2*Math.PI-o):i>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-i):i-o:0}(De(u),o,n);u.angle=(u.angle||0)+function(t){return t/Math.PI*180}(d)}return this.limitElementAttrs(u),{width:Ye(u.w),height:Ye(u.h),angle:Xe(u.angle||0)}},t.prototype.getElementIndex=function(t,e){for(var n=-1,o=0;o<t.elements.length;o++)if(t.elements[o].uuid===e){n=o;break}return n},t.prototype.limitElementAttrs=function(t){t.x=Ye(t.x),t.y=Ye(t.y),t.w=Ye(t.w),t.h=Ye(t.h),t.angle=Xe(t.angle||0)},t}();function Be(t){return t*Math.PI/180}function Ge(t,e){return Math.sqrt(t*t+e*e)}function Qe(t,e){return e>0?Math.abs(t):0-Math.abs(t)}var Ve=function(){function t(t,e){this._areaStart={x:0,y:0},this._areaEnd={x:0,y:0},this._board=t,this._ctx=this._board.getContext(),this._coreConfig=e,this._helperConfig={elementIndexMap:{}}}return t.prototype.updateConfig=function(t,e){this._updateElementIndex(t),this._updateSelectedElementWrapper(t,e),this._updateSelectedElementListWrapper(t,e)},t.prototype.getConfig=function(){return ot(this._helperConfig)},t.prototype.getElementIndexByUUID=function(t){var e=this._helperConfig.elementIndexMap[t];return e>=0?e:null},t.prototype.isPointInElementWrapperController=function(t,e){var n,o,i=this._ctx,r=(null===(o=null===(n=this._helperConfig)||void 0===n?void 0:n.selectedElementWrapper)||void 0===o?void 0:o.uuid)||null,s=null,l=null,a=null;if(!this._helperConfig.selectedElementWrapper)return{uuid:r,selectedControllerDirection:l,directIndex:s,hoverControllerDirection:a};var c=this._helperConfig.selectedElementWrapper,h=[c.controllers.right,c.controllers.topRight,c.controllers.top,c.controllers.topLeft,c.controllers.left,c.controllers.bottomLeft,c.controllers.bottom,c.controllers.bottomRight],u=['right','top-right','top','top-left','left','bottom-left','bottom','bottom-right'],f=ot(u),d=0;if(e&&r){var p=this.getElementIndexByUUID(r);if(null!==p&&p>=0){var v=e.elements[p].angle;v<0&&(v+=360),v<45?d=0:v<90?d=1:v<135?d=2:v<180?d=3:v<225?d=4:v<270?d=5:v<315&&(d=6)}}if(d>0&&(f=f.slice(-d).concat(f.slice(0,-d))),Fe(i,c.translate,c.radian||0,(function(){for(var e=0;e<h.length;e++){var n=h[e];if(!0!==n.invisible&&(i.beginPath(),i.arc(n.x,n.y,c.controllerSize,0,2*Math.PI),i.closePath(),i.isPointInPath(t.x,t.y)&&(l=u[e],a=f[e]),l)){s=e;break}}})),null===l){var g=c.controllers.rotate;!0!==g.invisible&&Fe(i,c.translate,c.radian||0,(function(){i.beginPath(),i.arc(g.x,g.y,c.controllerSize,0,2*Math.PI),i.closePath(),i.isPointInPath(t.x,t.y)&&(l='rotate',a='rotate')}))}return{uuid:r,selectedControllerDirection:l,hoverControllerDirection:a,directIndex:s}},t.prototype.isPointInElementList=function(t,e){for(var n,o,i,r=this._ctx,s=-1,l=null,a=(null===(n=this._helperConfig)||void 0===n?void 0:n.selectedElementListWrappers)||[],c=function(n){var c=a[n],u=h._helperConfig.elementIndexMap[c.uuid],f=e.elements[u];if(!f)return"continue";if(!0===(null===(o=f.operation)||void 0===o?void 0:o.invisible))return"continue";var d=0;return(null===(i=f.desc)||void 0===i?void 0:i.borderWidth)>0&&(d=f.desc.borderWidth),Ae(r,f,(function(){r.beginPath(),r.moveTo(f.x-d,f.y-d),r.lineTo(f.x+f.w+d,f.y-d),r.lineTo(f.x+f.w+d,f.y+f.h+d),r.lineTo(f.x-d,f.y+f.h+d),r.lineTo(f.x-d,f.y-d),r.closePath(),r.isPointInPath(t.x,t.y)&&(s=n,l=f.uuid)})),s>=0?"break":void 0},h=this,u=0;u<a.length;u++){if("break"===c(u))break}return!!(l&&s>=0)},t.prototype.startSelectArea=function(t){this._areaStart=t,this._areaEnd=t},t.prototype.changeSelectArea=function(t){this._areaEnd=t,this._calcSelectedArea()},t.prototype.clearSelectedArea=function(){this._areaStart={x:0,y:0},this._areaEnd={x:0,y:0},this._calcSelectedArea()},t.prototype.calcSelectedElements=function(t){var e=this._ctx.getTransform(),n=e.scale,o=void 0===n?1:n,i=e.scrollX,r=void 0===i?0:i,s=e.scrollY,l=void 0===s?0:s,a=this._areaStart,c=this._areaEnd,h=(Math.min(a.x,c.x)-r)/o,u=(Math.min(a.y,c.y)-l)/o,f=Math.abs(c.x-a.x)/o,d=Math.abs(c.y-a.y)/o,p=[],v=this._ctx;return v.beginPath(),v.moveTo(h,u),v.lineTo(h+f,u),v.lineTo(h+f,u+d),v.lineTo(h,u+d),v.lineTo(h,u),v.closePath(),t.elements.forEach((function(t){var e;if(!0!==(null===(e=null==t?void 0:t.operation)||void 0===e?void 0:e.invisible)){var n=t.x+t.w/2,o=t.y+t.h/2;v.isPointInPathWithoutScroll(n,o)&&p.push(t.uuid)}})),p},t.prototype._calcSelectedArea=function(){var t=this._areaStart,e=this._areaEnd,n=this._ctx.getTransform(),o=n.scale,i=void 0===o?1:o,r=n.scrollX,s=void 0===r?0:r,l=n.scrollY,a=void 0===l?0:l,c=this._coreConfig.elementWrapper,h=c.lineWidth/i,u=c.lineDash.map((function(t){return t/i}));this._helperConfig.selectedAreaWrapper={x:(Math.min(t.x,e.x)-s)/i,y:(Math.min(t.y,e.y)-a)/i,w:Math.abs(e.x-t.x)/i,h:Math.abs(e.y-t.y)/i,startPoint:{x:t.x,y:t.y},endPoint:{x:e.x,y:e.y},lineWidth:h,lineDash:u,color:c.color}},t.prototype._updateElementIndex=function(t){var e=this;this._helperConfig.elementIndexMap={},t.elements.forEach((function(t,n){e._helperConfig.elementIndexMap[t.uuid]=n}))},t.prototype._updateSelectedElementWrapper=function(t,e){var n,o=e.selectedUUID;if('string'==typeof o&&this._helperConfig.elementIndexMap[o]>=0){var i=this._helperConfig.elementIndexMap[o],r=t.elements[i];if(!0!==(null===(n=null==r?void 0:r.operation)||void 0===n?void 0:n.invisible)){var s=this._createSelectedElementWrapper(r,e);this._helperConfig.selectedElementWrapper=s}}else delete this._helperConfig.selectedElementWrapper},t.prototype._updateSelectedElementListWrapper=function(t,e){var n=this,o=e.selectedUUIDList,i=[];t.elements.forEach((function(t,r){if(null==o?void 0:o.includes(t.uuid)){var s=n._createSelectedElementWrapper(t,e);i.push(s)}})),this._helperConfig.selectedElementListWrappers=i},t.prototype._createSelectedElementWrapper=function(t,e){var n,o,i,r,s,l,a,c,h,u,f,d,p=e.scale,v=this._coreConfig.elementWrapper,g=v.controllerSize/p,m=v.lineWidth/p,y=v.lineDash.map((function(t){return t/p})),_=(null===(n=t.desc)||void 0===n?void 0:n.borderWidth)||0,S=!1;'number'==typeof t.angle&&Math.abs(t.angle)>15&&(S=!0);var x=m,b={uuid:t.uuid,controllerSize:g,controllerOffset:x,lock:!0===(null===(o=null==t?void 0:t.operation)||void 0===o?void 0:o.lock),controllers:{topLeft:{x:t.x-x-_,y:t.y-x-_,invisible:S||!0===(null===(i=null==t?void 0:t.operation)||void 0===i?void 0:i.disbaleScale)},top:{x:t.x+t.w/2,y:t.y-x-_,invisible:!0===(null===(r=null==t?void 0:t.operation)||void 0===r?void 0:r.disbaleScale)},topRight:{x:t.x+t.w+x+_,y:t.y-x-_,invisible:S||!0===(null===(s=null==t?void 0:t.operation)||void 0===s?void 0:s.disbaleScale)},right:{x:t.x+t.w+x+_,y:t.y+t.h/2,invisible:!0===(null===(l=null==t?void 0:t.operation)||void 0===l?void 0:l.disbaleScale)},bottomRight:{x:t.x+t.w+x+_,y:t.y+t.h+x+_,invisible:S||!0===(null===(a=null==t?void 0:t.operation)||void 0===a?void 0:a.disbaleScale)},bottom:{x:t.x+t.w/2,y:t.y+t.h+x+_,invisible:!0===(null===(c=null==t?void 0:t.operation)||void 0===c?void 0:c.disbaleScale)},bottomLeft:{x:t.x-x-_,y:t.y+t.h+x+_,invisible:S||!0===(null===(h=null==t?void 0:t.operation)||void 0===h?void 0:h.disbaleScale)},left:{x:t.x-x-_,y:t.y+t.h/2,invisible:!0===(null===(u=null==t?void 0:t.operation)||void 0===u?void 0:u.disbaleScale)},rotate:{x:t.x+t.w/2,y:t.y-g-(2*g+12)-_,invisible:!0===(null===(f=null==t?void 0:t.operation)||void 0===f?void 0:f.disbaleRotate)}},lineWidth:m,lineDash:y,color:!0===(null===(d=null==t?void 0:t.operation)||void 0===d?void 0:d.lock)?v.lockColor:v.color};return'number'==typeof t.angle&&(t.angle>0||t.angle<0)&&(b.radian=Le(t.angle),b.translate=De(t)),b},t}(),$e=Symbol('_displayCtx'),Ze=Symbol('_helper'),qe=Symbol('_element'),Je=Symbol('_opts'),Ke=function(){function t(t){this[Je]=t,this[$e]=this[Je].board,this[qe]=this[Je].element,this[Ze]=this[Je].helper}return t.prototype.isEffectivePoint=function(t){var e=this[$e].getScrollLineWidth(),n=this[$e].getScreenInfo();return t.x<=n.width-e&&t.y<=n.height-e},t.prototype.judgePointCursor=function(t,e){var n='auto',o=null;if(!this.isEffectivePoint(t))return{cursor:n,elementUUID:o};var i=this[Ze].isPointInElementWrapperController(t,e),r=i.uuid,s=i.hoverControllerDirection;if(r&&s){switch(s){case'top-right':n='ne-resize';break;case'top-left':n='nw-resize';break;case'top':n='n-resize';break;case'right':n='e-resize';break;case'bottom-right':n='se-resize';break;case'bottom':n='s-resize';break;case'bottom-left':n='sw-resize';break;case'left':n='w-resize';break;case'rotate':n='grab'}r&&(o=r)}else{var l=this[qe].isPointInElement(t,e),a=l[0],c=l[1];a>=0&&(n='move'),c&&(o=c)}return{cursor:n,elementUUID:o}},t}();function tn(t){var e={elements:[]};return Array.isArray(null==t?void 0:t.elements)&&(null==t||t.elements.forEach((function(t){void 0===t&&(t={}),function(t){if(!(en(t.x)&&en(t.y)&&en(t.w)&&en(t.h)))return!1;if('string'!=typeof t.type||!Ne.includes(t.type))return!1;return!0}(t)&&e.elements.push(t)}))),'string'==typeof t.bgColor&&(e.bgColor=t.bgColor),e}function en(t){return t>=0||t<0}var nn,on,rn=function(){function t(){this._temp={hasInited:!1}}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(){this._temp={hasInited:!1}},t}(),sn=Symbol('_board'),ln=Symbol('_data'),an=Symbol('_opts'),cn=Symbol('_config'),hn=Symbol('_renderer'),un=Symbol('_element'),fn=Symbol('_tempData'),dn=Symbol('_draw'),pn=Symbol('_coreEvent'),vn=Symbol('_emitChangeScreen'),gn=Symbol('_emitChangeData'),mn=Symbol('_engine');function yn(){return{hasInited:!1,mode:nn.NULL,cursorStatus:on.NULL,selectedUUID:null,selectedUUIDList:[],hoverUUID:null,selectedControllerDirection:null,hoverControllerDirection:null,prevPoint:null}}!function(t){t.NULL="null",t.SELECT_ELEMENT="select-element",t.SELECT_ELEMENT_LIST="select-element-list",t.SELECT_ELEMENT_WRAPPER_CONTROLLER="select-element-wrapper-controller",t.SELECT_AREA="select-area"}(nn||(nn={})),function(t){t.DRAGGING="dragging",t.NULL="null"}(on||(on={}));var _n=function(){function t(){this._temp=yn()}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(){this._temp=yn()},t}(),Sn=function(){function t(t){this._plugins=[];var e=t.board,n=t.config,o=t.element,i=new Ve(e,n);this._opts=t,this.temp=new _n,this.helper=i,this._mapper=new Ke({board:e,helper:i,element:o})}return t.prototype.addPlugin=function(t){this._plugins.push(t)},t.prototype.getHelperConfig=function(){return this.helper.getConfig()},t.prototype.updateHelperConfig=function(t){var e,n=this._opts,o=n.board,i=n.getDataFeekback,r=n.config,s=i(),l=o.getTransform();this.helper.updateConfig(s,{width:t.width,height:t.height,devicePixelRatio:t.devicePixelRatio,canScroll:!0===(null===(e=null==r?void 0:r.scrollWrapper)||void 0===e?void 0:e.use),selectedUUID:this.temp.get('selectedUUID'),selectedUUIDList:this.temp.get('selectedUUIDList'),scale:l.scale,scrollX:l.scrollX,scrollY:l.scrollY})},t.prototype.init=function(){this._initEvent()},t.prototype._initEvent=function(){if(!0!==this.temp.get('hasInited')){var t=this._opts.board;t.on('hover',tt(this._handleHover.bind(this),32)),t.on('leave',tt(this._handleLeave.bind(this),32)),t.on('point',tt(this._handleClick.bind(this),16)),t.on('doubleClick',this._handleDoubleClick.bind(this)),t.on('point',this._handlePoint.bind(this)),t.on('moveStart',this._handleMoveStart.bind(this)),t.on('move',tt(this._handleMove.bind(this),16)),t.on('moveEnd',this._handleMoveEnd.bind(this))}},t.prototype._handleDoubleClick=function(t){var e,n,o,i=this._opts,r=i.element,s=i.getDataFeekback,l=i.drawFeekback,a=i.coreEvent,c=s(),h=r.isPointInElement(t,c),u=h[0],f=h[1];if(u>=0&&f){var d=ot(null===(e=c.elements)||void 0===e?void 0:e[u]);!0!==(null===(n=null==d?void 0:d.operation)||void 0===n?void 0:n.invisible)&&a.trigger('screenDoubleClickElement',{index:u,uuid:f,element:ot(null===(o=c.elements)||void 0===o?void 0:o[u])})}l()},t.prototype._handlePoint=function(t){var e,n,o;if(this._mapper.isEffectivePoint(t)){var i=this._opts,r=i.element,s=i.getDataFeekback,l=i.selectElementByIndex,a=i.coreEvent,c=i.emitChangeScreen,h=i.drawFeekback,u=this.helper,f=s();if(u.isPointInElementList(t,f))this.temp.set('mode',nn.SELECT_ELEMENT_LIST);else{var d=u.isPointInElementWrapperController(t,f),p=d.uuid,v=d.selectedControllerDirection;if(p&&v)this.temp.set('mode',nn.SELECT_ELEMENT_WRAPPER_CONTROLLER),this.temp.set('selectedControllerDirection',v),this.temp.set('selectedUUID',p);else{var g=r.isPointInElement(t,f),m=g[0],y=g[1];m>=0&&!0!==(null===(n=null===(e=f.elements[m])||void 0===e?void 0:e.operation)||void 0===n?void 0:n.invisible)?(l(m,{useMode:!0}),'string'==typeof y&&a.has('screenSelectElement')&&(a.trigger('screenSelectElement',{index:m,uuid:y,element:ot(null===(o=f.elements)||void 0===o?void 0:o[m])}),c()),this.temp.set('mode',nn.SELECT_ELEMENT)):(this.temp.set('selectedUUIDList',[]),this.temp.set('selectedUUID',null),this.temp.set('mode',nn.SELECT_AREA))}}h()}},t.prototype._handleClick=function(t){var e,n=this._opts,o=n.element,i=n.getDataFeekback,r=n.coreEvent,s=n.drawFeekback,l=i(),a=o.isPointInElement(t,l),c=a[0],h=a[1];c>=0&&h&&r.trigger('screenClickElement',{index:c,uuid:h,element:ot(null===(e=l.elements)||void 0===e?void 0:e[c])}),s()},t.prototype._handleMoveStart=function(t){var e=this._opts,n=e.element,o=e.getDataFeekback,i=e.coreEvent,r=o(),s=this.helper;this.temp.set('prevPoint',t);var l=this.temp.get('selectedUUID');this.temp.get('mode')===nn.SELECT_ELEMENT_LIST||(this.temp.get('mode')===nn.SELECT_ELEMENT?'string'==typeof l&&i.has('screenMoveElementStart')&&i.trigger('screenMoveElementStart',{index:n.getElementIndex(r,l),uuid:l,x:t.x,y:t.y}):this.temp.get('mode')===nn.SELECT_AREA&&s.startSelectArea(t))},t.prototype._handleMove=function(t){var e=this._opts.drawFeekback,n=this.helper;this.temp.get('mode')===nn.SELECT_ELEMENT_LIST?(this._dragElements(this.temp.get('selectedUUIDList'),t,this.temp.get('prevPoint')),e(),this.temp.set('cursorStatus',on.DRAGGING)):'string'==typeof this.temp.get('selectedUUID')?this.temp.get('mode')===nn.SELECT_ELEMENT?(this._dragElements([this.temp.get('selectedUUID')],t,this.temp.get('prevPoint')),e(),this.temp.set('cursorStatus',on.DRAGGING)):this.temp.get('mode')===nn.SELECT_ELEMENT_WRAPPER_CONTROLLER&&this.temp.get('selectedControllerDirection')&&(this._transfromElement(this.temp.get('selectedUUID'),t,this.temp.get('prevPoint'),this.temp.get('selectedControllerDirection')),this.temp.set('cursorStatus',on.DRAGGING)):this.temp.get('mode')===nn.SELECT_AREA&&(n.changeSelectArea(t),e()),this.temp.set('prevPoint',t)},t.prototype._dragElements=function(t,e,n){if(n){var o=this._opts,i=o.board,r=o.element,s=o.getDataFeekback,l=o.drawFeekback,a=s(),c=this.helper;t.forEach((function(t){var o,s,l=c.getElementIndexByUUID(t);if(null!==l){var h=a.elements[l];!0!==(null===(o=null==h?void 0:h.operation)||void 0===o?void 0:o.lock)&&!0!==(null===(s=null==h?void 0:h.operation)||void 0===s?void 0:s.invisible)&&r.dragElement(a,t,e,n,i.getContext().getTransform().scale)}})),l()}},t.prototype._transfromElement=function(t,e,n,o){if(!n)return null;var i=this._opts,r=i.board,s=i.element,l=i.getDataFeekback,a=i.drawFeekback,c=l(),h=s.transformElement(c,t,e,n,r.getContext().getTransform().scale,o);return a(),h},t.prototype._handleMoveEnd=function(t){var e=this._opts,n=e.element,o=e.getDataFeekback,i=e.coreEvent,r=e.drawFeekback,s=e.emitChangeData,l=o(),a=this.helper,c=this.temp.get('selectedUUID');if('string'==typeof c){var h=n.getElementIndex(l,c),u=l.elements[h];u&&(i.has('screenMoveElementEnd')&&i.trigger('screenMoveElementEnd',{index:h,uuid:c,x:t.x,y:t.y}),i.has('screenChangeElement')&&i.trigger('screenChangeElement',{index:h,uuid:c,width:u.w,height:u.h,angle:u.angle||0}),s())}else if(this.temp.get('mode')===nn.SELECT_AREA){var f=a.calcSelectedElements(l);f.length>0?(this.temp.set('selectedUUIDList',f),this.temp.set('selectedUUID',null)):this.temp.set('mode',nn.NULL),a.clearSelectedArea(),r()}this.temp.get('mode')!==nn.SELECT_ELEMENT&&this.temp.set('selectedUUID',null),this.temp.set('cursorStatus',on.NULL),this.temp.set('mode',nn.NULL)},t.prototype._handleHover=function(t){var e,n,o=!1,i=this._opts,r=i.board,s=i.getDataFeekback,l=i.coreEvent,a=s(),c=this.helper,h=this._mapper;if(this.temp.get('mode')===nn.SELECT_AREA)r.resetCursor();else if(this.temp.get('cursorStatus')===on.NULL){var u=h.judgePointCursor(t,a),f=u.cursor,d=u.elementUUID;if(r.setCursor(f),d)if(null!==(g=c.getElementIndexByUUID(d))&&g>=0){var p=a.elements[g];if(!0===(null===(e=null==p?void 0:p.operation)||void 0===e?void 0:e.lock)||!0===(null===(n=null==p?void 0:p.operation)||void 0===n?void 0:n.invisible))return void r.resetCursor();if(this.temp.get('hoverUUID')!==p.uuid){var v=c.getElementIndexByUUID(this.temp.get('hoverUUID')||'');null!==v&&a.elements[v]&&l.trigger('mouseLeaveElement',{uuid:this.temp.get('hoverUUID'),index:v,element:a.elements[v]})}p&&(l.trigger('mouseOverElement',{uuid:p.uuid,index:g,element:p}),this.temp.set('hoverUUID',p.uuid),o=!0)}}if(!0!==o&&null!==this.temp.get('hoverUUID')){var g,m=this.temp.get('hoverUUID');null!==(g=c.getElementIndexByUUID(m||''))&&l.trigger('mouseLeaveElement',{uuid:m,index:g,element:a.elements[g]}),this.temp.set('hoverUUID',null)}l.has('mouseOverScreen')&&l.trigger('mouseOverScreen',t)},t.prototype._handleLeave=function(){var t=this._opts.coreEvent;t.has('mouseLeaveScreen')&&t.trigger('mouseLeaveScreen',void 0)},t}();function xn(t){t.setFillStyle('#000000'),t.setStrokeStyle('#000000'),t.setLineDash([]),t.setGlobalAlpha(1),t.setShadowColor('#00000000'),t.setShadowOffsetX(0),t.setShadowOffsetY(0),t.setShadowBlur(0)}var bn=function(){function e(e,i,r){var s,l,a,c=this;this[n]=new Me,this[o]=new rn,this[ln]={elements:[]},this[an]=i,this[cn]=function(e){var n=ot(ke);return e&&e.elementWrapper&&(n.elementWrapper=t(t({},n.elementWrapper),e.elementWrapper)),n}(r||{}),this[sn]=new K(e,t(t({},this[an]),{canScroll:null===(s=null==r?void 0:r.scrollWrapper)||void 0===s?void 0:s.use,scrollConfig:{color:(null===(l=null==r?void 0:r.scrollWrapper)||void 0===l?void 0:l.color)||'#a0a0a0',lineWidth:(null===(a=null==r?void 0:r.scrollWrapper)||void 0===a?void 0:a.lineWidth)||12}})),this[hn]=new Se;var h=function(){var t=c[sn].getHelperContext(),e=c[mn].getHelperConfig();c[sn].clear();var n=c[an],o=n.contextWidth,i=n.contextHeight,r=n.devicePixelRatio;t.clearRect(0,0,o*r,i*r),function(t,e){if(null==e?void 0:e.selectedElementWrapper){var n=e.selectedElementWrapper;xn(t),Fe(t,n.translate,n.radian||0,(function(){t.beginPath(),t.setLineDash(n.lineDash),t.setLineWidth(n.lineWidth),t.setStrokeStyle(n.color),t.moveTo(n.controllers.topLeft.x,n.controllers.topLeft.y),t.lineTo(n.controllers.topRight.x,n.controllers.topRight.y),t.lineTo(n.controllers.bottomRight.x,n.controllers.bottomRight.y),t.lineTo(n.controllers.bottomLeft.x,n.controllers.bottomLeft.y),t.lineTo(n.controllers.topLeft.x,n.controllers.topLeft.y-n.lineWidth/2),t.stroke(),t.closePath(),!0!==n.lock?(!0!==n.controllers.rotate.invisible&&(t.beginPath(),t.moveTo(n.controllers.top.x,n.controllers.top.y),t.lineTo(n.controllers.rotate.x,n.controllers.rotate.y+n.controllerSize),t.stroke(),t.closePath(),t.beginPath(),t.setLineDash([]),t.setLineWidth(n.controllerSize/2),t.arc(n.controllers.rotate.x,n.controllers.rotate.y,.8*n.controllerSize,Math.PI/6,2*Math.PI),t.stroke(),t.closePath()),t.setFillStyle(n.color),[n.controllers.topLeft,n.controllers.top,n.controllers.topRight,n.controllers.right,n.controllers.bottomRight,n.controllers.bottom,n.controllers.bottomLeft,n.controllers.left].forEach((function(e){!0!==e.invisible&&(t.beginPath(),t.arc(e.x,e.y,n.controllerSize,0,2*Math.PI),t.fill(),t.closePath())}))):(xn(t),t.setStrokeStyle(n.color),[n.controllers.topLeft,n.controllers.top,n.controllers.topRight,n.controllers.right,n.controllers.bottomRight,n.controllers.bottom,n.controllers.bottomLeft,n.controllers.left].forEach((function(e){t.beginPath(),t.moveTo(e.x-n.controllerSize/2,e.y-n.controllerSize/2),t.lineTo(e.x+n.controllerSize/2,e.y+n.controllerSize/2),t.stroke(),t.closePath(),t.beginPath(),t.moveTo(e.x+n.controllerSize/2,e.y-n.controllerSize/2),t.lineTo(e.x-n.controllerSize/2,e.y+n.controllerSize/2),t.stroke(),t.closePath()})))}))}}(t,e),function(t,e){if(null==e?void 0:e.selectedAreaWrapper){var n=e.selectedAreaWrapper;n&&n.w>0&&n.h>0&&(xn(t),t.setGlobalAlpha(.3),t.setFillStyle(n.color),t.fillRect(n.x,n.y,n.w,n.h),xn(t),t.beginPath(),t.setLineDash(n.lineDash),t.setLineWidth(n.lineWidth),t.setStrokeStyle(n.color),t.moveTo(n.x,n.y),t.lineTo(n.x+n.w,n.y),t.lineTo(n.x+n.w,n.y+n.h),t.lineTo(n.x,n.y+n.h),t.lineTo(n.x,n.y),t.stroke(),t.closePath())}}(t,e),function(t,e){if(Array.isArray(null==e?void 0:e.selectedElementListWrappers)){var n=e.selectedElementListWrappers;null==n||n.forEach((function(e){xn(t),Fe(t,e.translate,e.radian||0,(function(){xn(t),t.setGlobalAlpha(.05),t.setFillStyle(e.color),t.fillRect(e.controllers.topLeft.x,e.controllers.topLeft.y,e.controllers.bottomRight.x-e.controllers.topLeft.x,e.controllers.bottomRight.y-e.controllers.topLeft.y),xn(t),t.beginPath(),t.setLineDash(e.lineDash),t.setLineWidth(e.lineWidth),t.setStrokeStyle(e.color),t.moveTo(e.controllers.topLeft.x,e.controllers.topLeft.y),t.lineTo(e.controllers.topRight.x,e.controllers.topRight.y),t.lineTo(e.controllers.bottomRight.x,e.controllers.bottomRight.y),t.lineTo(e.controllers.bottomLeft.x,e.controllers.bottomLeft.y),t.lineTo(e.controllers.topLeft.x,e.controllers.topLeft.y-e.lineWidth/2),t.stroke(),t.closePath(),!0===e.lock&&(xn(t),t.setStrokeStyle(e.color),[e.controllers.topLeft,e.controllers.top,e.controllers.topRight,e.controllers.right,e.controllers.bottomRight,e.controllers.bottom,e.controllers.bottomLeft,e.controllers.left].forEach((function(n){t.beginPath(),t.moveTo(n.x-e.controllerSize/2,n.y-e.controllerSize/2),t.lineTo(n.x+e.controllerSize/2,n.y+e.controllerSize/2),t.stroke(),t.closePath(),t.beginPath(),t.moveTo(n.x+e.controllerSize/2,n.y-e.controllerSize/2),t.lineTo(n.x-e.controllerSize/2,n.y+e.controllerSize/2),t.stroke(),t.closePath()})))}))}))}}(t,e),c[sn].draw()};this[hn].on('drawFrame',(function(t){h()})),this[hn].on('drawFrameComplete',(function(t){h()})),this[un]=new je(this[sn].getContext()),this[mn]=new Sn({coreEvent:this[pn],board:this[sn],element:this[un],config:this[cn],drawFeekback:this[dn].bind(this),getDataFeekback:function(){return c[ln]},selectElementByIndex:this.selectElementByIndex.bind(this),emitChangeScreen:this[vn].bind(this),emitChangeData:this[gn].bind(this)}),this[mn].init(),this[hn].on('drawFrame',(function(){c[pn].trigger('drawFrame',void 0)})),this[hn].on('drawFrameComplete',(function(){c[pn].trigger('drawFrameComplete',void 0)})),this[fn].set('hasInited',!0)}var n,o;return e.prototype[(n=pn,o=fn,dn)]=function(t){this[mn].updateHelperConfig({width:this[an].width,height:this[an].height,devicePixelRatio:this[an].devicePixelRatio}),this[hn].thaw(),this[hn].render(this[sn].getContext(),this[ln],{changeResourceUUIDs:(null==t?void 0:t.resourceChangeUUIDs)||[]})},e.prototype.getElement=function(t){return function(t,e){var n=null,o=t[mn].helper.getElementIndexByUUID(e);return null!==o&&t[ln].elements[o]&&(n=ot(t[ln].elements[o])),n}(this,t)},e.prototype.getElementByIndex=function(t){return function(t,e){var n=null;return e>=0&&t[ln].elements[e]&&(n=ot(t[ln].elements[e])),n}(this,t)},e.prototype.selectElementByIndex=function(t,e){return function(t,e,n){if(t[ln].elements[e]){var o=t[ln].elements[e].uuid;!0===(null==n?void 0:n.useMode)?t[mn].temp.set('mode',nn.SELECT_ELEMENT):t[mn].temp.set('mode',nn.NULL),'string'==typeof o&&(t[mn].temp.set('selectedUUID',o),t[mn].temp.set('selectedUUIDList',[])),t[dn]()}}(this,t,e)},e.prototype.selectElement=function(t,e){return function(t,e,n){var o=t[mn].helper.getElementIndexByUUID(e);'number'==typeof o&&o>=0&&t.selectElementByIndex(o,n)}(this,t,e)},e.prototype.moveUpElement=function(t){return function(t,e){var n=t[mn].helper.getElementIndexByUUID(e);if('number'==typeof n&&n>=0&&n<t[ln].elements.length-1){var o=t[ln].elements[n];t[ln].elements[n]=t[ln].elements[n+1],t[ln].elements[n+1]=o}t[gn](),t[dn]()}(this,t)},e.prototype.moveDownElement=function(t){return function(t,e){var n=t[mn].helper.getElementIndexByUUID(e);if('number'==typeof n&&n>0&&n<t[ln].elements.length){var o=t[ln].elements[n];t[ln].elements[n]=t[ln].elements[n-1],t[ln].elements[n-1]=o}t[gn](),t[dn]()}(this,t)},e.prototype.updateElement=function(t){return function(t,e){for(var n,o=ot(e),i=t[ln],r=[],s=0;s<i.elements.length;s++)if(o.uuid===(null===(n=i.elements[s])||void 0===n?void 0:n.uuid)){var l=Ue(i.elements[s],o);'string'==typeof l&&r.push(l),i.elements[s]=o;break}t[gn](),t[dn]({resourceChangeUUIDs:r})}(this,t)},e.prototype.addElement=function(t){return function(t,e){var n=ot(e);return n.uuid=nt(),t[ln].elements.push(n),t[gn](),t[dn](),n.uuid}(this,t)},e.prototype.deleteElement=function(t){return function(t,e){var n=t[un].getElementIndex(t[ln],e);n>=0&&(t[ln].elements.splice(n,1),t[gn](),t[dn]())}(this,t)},e.prototype.insertElementBefore=function(t,e){return function(t,e,n){var o=t[mn].helper.getElementIndexByUUID(n);return null!==o?t.insertElementBeforeIndex(e,o):null}(this,t,e)},e.prototype.insertElementBeforeIndex=function(t,e){return function(t,e,n){var o=ot(e);return o.uuid=nt(),n>=0?(t[ln].elements.splice(n,0,o),t[gn](),t[dn](),o.uuid):null}(this,t,e)},e.prototype.getSelectedElements=function(){return e=[],n=[],'string'==typeof(o=(t=this)[mn].temp.get('selectedUUID'))&&o?n.push(o):n=t[mn].temp.get('selectedUUIDList'),n.forEach((function(n){var o,i=t[mn].helper.getElementIndexByUUID(n);if(null!==i&&i>=0){var r=null===(o=t[ln])||void 0===o?void 0:o.elements[i];r&&e.push(r)}})),ot(e);var t,e,n,o},e.prototype.insertElementAfter=function(t,e){return function(t,e,n){var o=t[mn].helper.getElementIndexByUUID(n);return null!==o?t.insertElementAfterIndex(e,o):null}(this,t,e)},e.prototype.insertElementAfterIndex=function(t,e){return function(t,e,n){var o=ot(e);return o.uuid=nt(),n>=0?(t[ln].elements.splice(n+1,0,o),t[gn](),t[dn](),o.uuid):null}(this,t,e)},e.prototype.resetSize=function(e){this[an]=t(t({},this[an]),e),this[sn].resetSize(e),this[dn]()},e.prototype.scale=function(t){var e=this[sn].scale(t);return this[dn](),this[vn](),e},e.prototype.scrollLeft=function(t){var e=this[sn].scrollX(0-t);return this[dn](),this[vn](),e},e.prototype.scrollTop=function(t){var e=this[sn].scrollY(0-t);return this[dn](),this[vn](),e},e.prototype.getScreenTransform=function(){var t=this[sn].getTransform();return{scale:t.scale,scrollTop:Math.max(0,0-t.scrollY),scrollLeft:Math.max(0,0-t.scrollX)}},e.prototype.getData=function(){return ot(this[ln])},e.prototype.setData=function(t,e){var n=function(t,e){var n,o=[],i=Re(t),r=Re(e);for(var s in r)if(!0===['image','svg','html'].includes(null===(n=r[s])||void 0===n?void 0:n.type))if(i[s]){var l=!1;switch(i[s].type){case'image':l=Ie(i[s],r[s]);break;case'svg':l=We(i[s],r[s]);break;case'html':l=Oe(i[s],r[s])}!0===l&&o.push(s)}else o.push(s);return o}(this[ln],t);this[ln]=this[un].initData(ot(tn(t))),e&&!0===e.triggerChangeEvent&&this[gn](),this[dn]({resourceChangeUUIDs:n})},e.prototype.clearOperation=function(){this[fn].clear(),this[dn]()},e.prototype.on=function(t,e){this[pn].on(t,e)},e.prototype.off=function(t,e){this[pn].off(t,e)},e.prototype.pointScreenToContext=function(t){return this[sn].pointScreenToContext(t)},e.prototype.pointContextToScreen=function(t){return this[sn].pointContextToScreen(t)},e.prototype.__getBoardContext=function(){return this[sn].getContext()},e.prototype.__getDisplayContext2D=function(){return this[sn].getDisplayContext2D()},e.prototype.__getOriginContext2D=function(){return this[sn].getOriginContext2D()},e.prototype[vn]=function(){this[pn].has('changeScreen')&&this[pn].trigger('changeScreen',t({},this.getScreenTransform()))},e.prototype[gn]=function(){this[pn].has('changeData')&&this[pn].trigger('changeData',ot(this[ln]))},e.is=Pe,e.check=Ce,e}();return Object.freeze({__proto__:null,Core:bn})}();
|
|
1
|
+
var iDrawCore=function(){'use strict';var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)},e=function(){return e=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function o(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var i={type:function(t,e){var n=o(t);return!0===e?n.toLocaleLowerCase():n},array:function(t){return'Array'===o(t)},json:function(t){return'Object'===o(t)},function:function(t){return'Function'===o(t)},asyncFunction:function(t){return'AsyncFunction'===o(t)},string:function(t){return'String'===o(t)},number:function(t){return'Number'===o(t)},undefined:function(t){return'Undefined'===o(t)},null:function(t){return'Null'===o(t)},promise:function(t){return'Promise'===o(t)}},r=function(){return r=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};function s(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function l(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function a(t,e){var n=e.width,o=e.height;return new Promise((function(e,i){var r="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(n||'',"\" height = \"").concat(o||'',"\">\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([r],{type:'image/svg+xml;charset=utf-8'}),l=new FileReader;l.readAsDataURL(s),l.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},l.onerror=function(t){i(t)}}))}function c(t){return new Promise((function(e,n){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),i=new FileReader;i.readAsDataURL(o),i.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},i.onerror=function(t){n(t)}}))}var h=window.Image;function u(t){return new Promise((function(e,n){var o=new h;o.crossOrigin='anonymous',o.onload=function(){e(o)},o.onabort=n,o.onerror=n,o.src=t}))}var f=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=r(r({},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=r(r({},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,n,o,i,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(n),o,i,r)},t.prototype.rect=function(t,e,n,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.fillRect=function(t,e,n,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.clearRect=function(t,e,n,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},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,n,o,i){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),this._doSize(i))},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 n=t[0],o=t[1],i=t[2],r=t[3],s=t[4],l=t[t.length-4],a=t[t.length-3],c=t[t.length-2],h=t[t.length-1];return 9===t.length?this._ctx.drawImage(n,this._doSize(o),this._doSize(i),this._doSize(r),this._doSize(s),this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h)):this._ctx.drawImage(n,this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h))},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,n,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(n))},t.prototype.strokeText=function(t,e,n,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(n))},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,n,o,i,r,s,l){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),i,r,s,l)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollX)/n;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollY)/n;return this._doSize(o)},t}();function d(t){return'number'==typeof t&&(t>0||t<=0)}function p(t){return'number'==typeof t&&t>=0}function v(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function g(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var m={x:function(t){return d(t)},y:function(t){return d(t)},w:p,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:d,borderWidth:function(t){return p(t)},borderRadius:function(t){return d(t)&&t>=0},color:function(t){return n(t)},imageSrc:function(t){return g(t)||v(t)},imageURL:v,imageBase64:g,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return d(t)&&t>0},lineHeight:function(t){return d(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 d(t)&&t>0}};function y(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!m.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!m.number(n))&&!(t.hasOwnProperty('borderWidth')&&!m.number(o)))}var _={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(m.x(e)&&m.y(n)&&m.w(o)&&m.h(i)&&m.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!m.text(e)&&(!!m.color(n)&&(!!m.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!m.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!m.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!m.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!m.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!m.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!m.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!m.color(h))&&!!y(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!m.color(e))&&!!y(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!m.color(e))&&(!(t.hasOwnProperty('borderColor')&&!m.color(n))&&!(t.hasOwnProperty('borderWidth')&&!m.number(o)))},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=Object.freeze({__proto__:null,is:m,check:_,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,n){return function o(i){var r=t[i];i===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var n=-1;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n>0||(n=setTimeout((function(){t.apply(void 0,o),n=-1}),e))}},loadImage:u,loadSVG:function(t){return s(this,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return[4,c(t)];case 1:return[4,u(e.sent())];case 2:return[2,e.sent()]}}))}))},loadHTML:function(t,e){return s(this,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return[4,a(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,u(n.sent())];case 2:return[2,n.sent()]}}))}))},downloadImageFromCanvas:function(t,e){var n=e.filename,o=e.type,i=void 0===o?'image/jpeg':o,r=t.toDataURL(i),s=document.createElement('a');s.href=r,s.download=n;var l=document.createEvent('MouseEvents');l.initEvent('click',!0,!1),s.dispatchEvent(l)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:n,createUUID:function(){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())},istype:i,deepClone:function(t){return function t(e){var n,o=(n=e,Object.prototype.toString.call(n).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var i=[];return e.forEach((function(e){i.push(t(e))})),i}if('Object'===o){var r={};return Object.keys(e).forEach((function(n){r[n]=t(e[n])})),r}}(t)},Context:f}),x=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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 b=function(){function t(){this._temp={prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(){this._temp={prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}},t}(),w=function(){function t(t,e){this._isMoving=!1,this._temp=new b,this._container=window,this._canvas=t,this._isMoving=!1,this._initEvent(),this._event=new x}return t.prototype.setStatusMap=function(t){this._temp.set('statusMap',t)},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype._initEvent=function(){var t=this._canvas,e=this._container;e.addEventListener('mousemove',this._listenWindowMove.bind(this),!1),e.addEventListener('mouseup',this._listenWindowMoveEnd.bind(this),!1),t.addEventListener('mousemove',this._listenHover.bind(this),!1),t.addEventListener('mousedown',this._listenMoveStart.bind(this),!1),t.addEventListener('mousemove',this._listenMove.bind(this),!1),t.addEventListener('mouseup',this._listenMoveEnd.bind(this),!1),t.addEventListener('click',this._listenCanvasClick.bind(this),!1),t.addEventListener('wheel',this._listenCanvasWheel.bind(this),!1),t.addEventListener('mousedown',this._listenCanvasMoveStart.bind(this),!0),t.addEventListener('mouseup',this._listenCanvasMoveEnd.bind(this),!0),t.addEventListener('mouseover',this._listenCanvasMoveOver.bind(this),!0),t.addEventListener('mouseleave',this._listenCanvasMoveLeave.bind(this),!0),this._initParentEvent()},t.prototype._initParentEvent=function(){try{for(var t=window,e=t.origin;t.self!==t.top&&(t.self!==t.parent&&t.origin===e&&t.parent.window.addEventListener('mousemove',this._listSameOriginParentWindow.bind(this),!1),t=t.parent););}catch(t){console.warn(t)}},t.prototype._listenHover=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.has('hover')&&this._event.trigger('hover',e),this._isMoving=!0},t.prototype._listenMoveStart=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&(this._event.has('point')&&this._event.trigger('point',e),this._event.has('moveStart')&&this._event.trigger('moveStart',e)),this._isMoving=!0},t.prototype._listenMove=function(t){if(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenMoveEnd=function(t){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._isMoving=!1},t.prototype._listSameOriginParentWindow=function(){this._temp.get('isHoverCanvas')&&this._event.has('leave')&&this._event.trigger('leave',void 0),this._temp.get('isDragCanvas')&&this._event.has('moveEnd')&&this._event.trigger('moveEnd',{x:NaN,y:NaN}),this._isMoving=!1,this._temp.set('isDragCanvas',!1),this._temp.set('isHoverCanvas',!1)},t.prototype._listenCanvasMoveStart=function(){this._temp.get('isHoverCanvas')&&this._temp.set('isDragCanvas',!0)},t.prototype._listenCanvasMoveEnd=function(){this._temp.set('isDragCanvas',!1)},t.prototype._listenCanvasMoveOver=function(){this._temp.set('isHoverCanvas',!0)},t.prototype._listenCanvasMoveLeave=function(){this._temp.set('isHoverCanvas',!1),this._event.has('leave')&&this._event.trigger('leave',void 0)},t.prototype._listenWindowMove=function(t){if(!0===this._temp.get('isDragCanvas')&&(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving)){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenWindowMoveEnd=function(t){if(!0!=!this._temp.get('isDragCanvas')){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._temp.set('isDragCanvas',!1),this._isMoving=!1}},t.prototype._listenCanvasWheel=function(t){this._event.has('wheelX')&&(t.deltaX>0||t.deltaX<0)&&this._event.trigger('wheelX',t.deltaX),this._event.has('wheelY')&&(t.deltaY>0||t.deltaY<0)&&this._event.trigger('wheelY',t.deltaY);var e=this._temp.get('statusMap'),n=e.canScrollYNext,o=e.canScrollYPrev;(t.deltaX>0&&t.deltaX<0||t.deltaY>0&&!0===n||t.deltaY<0&&!0===o)&&t.preventDefault()},t.prototype._listenCanvasClick=function(t){t.preventDefault();var e=this._getPosition(t),n=Date.now();if(this._isVaildPoint(e)){var o=this._temp.get('prevClickPoint');o&&n-o.t<=500&&Math.abs(o.x-e.x)<=5&&Math.abs(o.y-e.y)<=5?this._event.has('doubleClick')&&this._event.trigger('doubleClick',{x:e.x,y:e.y}):this._temp.set('prevClickPoint',{x:e.x,y:e.y,t:n})}},t.prototype._getPosition=function(t){var e=this._canvas,n=0,o=0;if(t&&t.touches&&t.touches.length>0){var i=t.touches[0];i&&(n=i.clientX,o=i.clientY)}else n=t.clientX,o=t.clientY;return{x:n-e.getBoundingClientRect().left,y:o-e.getBoundingClientRect().top,t:Date.now()}},t.prototype._isVaildPoint=function(t){return E(t.x)&&E(t.y)},t}();function E(t){return t>0||t<0||0===t}var P={lineWidth:12,color:'#a0a0a0'},z=function(){function t(t,e){this._displayCtx=t,this._opts=this._getOpts(e)}return t.prototype.draw=function(t){var e=this._opts,n=e.width,o=e.height,i=this.calc(t),r=this._displayCtx;i.xSize>0&&(r.globalAlpha=.2,r.fillStyle=i.color,r.fillRect(0,this._doSize(o-i.lineSize),this._doSize(n),this._doSize(i.lineSize)),r.globalAlpha=1,C(r,{x:this._doSize(i.translateX),y:this._doSize(o-i.lineSize),w:this._doSize(i.xSize),h:this._doSize(i.lineSize),r:this._doSize(i.lineSize/2),color:i.color})),i.ySize>0&&(r.globalAlpha=.2,r.fillStyle=i.color,r.fillRect(this._doSize(n-i.lineSize),0,this._doSize(i.lineSize),this._doSize(o)),r.globalAlpha=1,C(r,{x:this._doSize(n-i.lineSize),y:this._doSize(i.translateY),w:this._doSize(i.lineSize),h:this._doSize(i.ySize),r:this._doSize(i.lineSize/2),color:i.color})),r.globalAlpha=1},t.prototype.resetSize=function(t){this._opts=e(e({},this._opts),t)},t.prototype.isPointAtScrollY=function(t){var e=this._opts,n=e.width,o=e.height,i=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(this._doSize(n-i.lineWidth),0,this._doSize(i.lineWidth),this._doSize(o)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},t.prototype.isPointAtScrollX=function(t){var e=this._opts,n=e.width,o=e.height,i=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(0,this._doSize(o-i.lineWidth),this._doSize(n-i.lineWidth),this._doSize(i.lineWidth)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},t.prototype.getLineWidth=function(){return this._opts.scrollConfig.lineWidth},t.prototype.calc=function(t){var e=this._opts,n=e.width,o=e.height,i=e.scrollConfig,r=2.5*i.lineWidth,s=i.lineWidth,l=0,a=0;t.left<=0&&t.right<=0&&(l=Math.max(r,n-(Math.abs(t.left)+Math.abs(t.right))))>=n&&(l=0),(t.top<=0||t.bottom<=0)&&(a=Math.max(r,o-(Math.abs(t.top)+Math.abs(t.bottom))))>=o&&(a=0);var c=0;l>0&&(c=l/2+(n-l)*Math.abs(t.left)/(Math.abs(t.left)+Math.abs(t.right)),c=Math.min(Math.max(0,c-l/2),n-l));var h=0;return a>0&&(h=a/2+(o-a)*Math.abs(t.top)/(Math.abs(t.top)+Math.abs(t.bottom)),h=Math.min(Math.max(0,h-a/2),o-a)),{lineSize:s,xSize:l,ySize:a,translateY:h,translateX:c,color:this._opts.scrollConfig.color}},t.prototype._doSize=function(t){return t*this._opts.devicePixelRatio},t.prototype._getOpts=function(t){var o=e({scrollConfig:P},t);return o.scrollConfig||(o.scrollConfig=P),o.scrollConfig.lineWidth>0||(o.scrollConfig.lineWidth=P.lineWidth),o.scrollConfig.lineWidth=Math.max(o.scrollConfig.lineWidth,P.lineWidth),!0!==n(o.scrollConfig.color)&&(o.scrollConfig.color=o.scrollConfig.color),o},t}();function C(t,e){var n=e.x,o=e.y,i=e.w,r=e.h,s=e.color,l=e.r;(i<2*(l=Math.min(l,i/2,r/2))||r<2*l)&&(l=0),t.beginPath(),t.moveTo(n+l,o),t.arcTo(n+i,o,n+i,o+r,l),t.arcTo(n+i,o+r,n,o+r,l),t.arcTo(n,o+r,n,o,l),t.arcTo(n,o,n+i,o,l),t.closePath(),t.fillStyle=s,t.fill()}var L,D=Symbol('_opts'),T=Symbol('_ctx'),k=function(){function t(t,e){this[D]=e,this[T]=t}return t.prototype.resetSize=function(t){this[D]=e(e({},this[D]),t)},t.prototype.calcScreen=function(){var t=this[T].getTransform().scale,e=this[D],n=e.width,o=e.height,i=e.contextWidth,r=e.contextHeight,s=e.devicePixelRatio,l=!0,a=!0,c=!0,h=!0;i*t<=n&&(this[T].setTransform({scrollX:(n-i*t)/2}),l=!1,a=!1),r*t<=o&&(this[T].setTransform({scrollY:(o-r*t)/2}),c=!1,h=!1),i*t>=n&&this[T].getTransform().scrollX>0&&(this[T].setTransform({scrollX:0}),l=!1),r*t>=o&&this[T].getTransform().scrollY>0&&(this[T].setTransform({scrollY:0}),c=!1);var u=this[T].getTransform(),f=u.scrollX,d=u.scrollY;f<0&&Math.abs(f)>Math.abs(i*t-n)&&(this[T].setTransform({scrollX:0-Math.abs(i*t-n)}),a=!1),d<0&&Math.abs(d)>Math.abs(r*t-o)&&(this[T].setTransform({scrollY:0-Math.abs(r*t-o)}),h=!1);var p=this[T].getTransform(),v=p.scrollX,g=p.scrollY;return{size:{x:v*t,y:g*t,w:i*t,h:r*t},position:{top:g,bottom:o-(r*t+g),left:v,right:n-(i*t+v)},deviceSize:{x:v*s,y:g*s,w:i*s*t,h:r*s*t},width:this[D].width,height:this[D].height,devicePixelRatio:this[D].devicePixelRatio,canScrollYPrev:c,canScrollYNext:h,canScrollXPrev:l,canScrollXNext:a}},t.prototype.calcScreenScroll=function(t,e,n,o,i){var r=o-n;t<=0&&e<=0&&(r=Math.abs(t)+Math.abs(e));var s=1;return r>0&&(s=r/(o-n)),0-s*i},t}(),M=Symbol('_canvas'),I=Symbol('_displayCanvas'),W=Symbol('_helperCanvas'),O=Symbol('_mount'),U=Symbol('_opts'),R=Symbol('_hasRendered'),A=Symbol('_ctx'),F=Symbol('_helperCtx'),Y=Symbol('_watcher'),X=Symbol('_render'),N=Symbol('_parsePrivateOptions'),H=Symbol('_scroller'),j=Symbol('_initEvent'),B=Symbol('_doScrollX'),G=Symbol('_doScrollY'),Q=Symbol('_doMoveScroll'),V=Symbol('_resetContext'),$=Symbol('_screen'),Z=S.throttle,q=S.Context,J=function(){function t(t,e){this[L]=!1,this[O]=t,this[M]=document.createElement('canvas'),this[W]=document.createElement('canvas'),this[I]=document.createElement('canvas'),this[O].appendChild(this[I]),this[U]=this[N](e);var n=this[M].getContext('2d'),o=this[I].getContext('2d'),i=this[W].getContext('2d');this[A]=new q(n,this[U]),this[F]=new q(i,this[U]),this[$]=new k(this[A],this[U]),this[Y]=new w(this[I],this[A]),this[H]=new z(o,{width:e.width,height:e.height,devicePixelRatio:e.devicePixelRatio||1,scrollConfig:e.scrollConfig}),this[X]()}return t.prototype.getDisplayContext2D=function(){return this[I].getContext('2d')},t.prototype.getOriginContext2D=function(){return this[A].getContext()},t.prototype.getHelperContext2D=function(){return this[F].getContext()},t.prototype.getContext=function(){return this[A]},t.prototype.getHelperContext=function(){return this[F]},t.prototype.scale=function(t){t>0&&(this[A].setTransform({scale:t}),this[F].setTransform({scale:t}));var e=this[$].calcScreen();return{position:e.position,size:e.size}},t.prototype.scrollX=function(t){this[Y].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[A].setTransform({scrollX:t}),this[F].setTransform({scrollX:t}));var e=this[$].calcScreen(),n=e.position,o=e.size,i=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,l=e.canScrollYPrev;return this[Y].setStatusMap({canScrollYPrev:l,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:i}),{position:n,size:o}},t.prototype.scrollY=function(t){this[Y].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[A].setTransform({scrollY:t}),this[F].setTransform({scrollY:t}));var e=this[$].calcScreen(),n=e.position,o=e.size,i=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,l=e.canScrollYPrev;return this[Y].setStatusMap({canScrollYPrev:l,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:i}),{position:n,size:o}},t.prototype.getTransform=function(){return this[A].getTransform()},t.prototype.draw=function(){this.clear();var t=this[$].calcScreen(),e=t.position,n=t.deviceSize,o=t.size,i=this[I].getContext('2d');return null==i||i.drawImage(this[M],n.x,n.y,n.w,n.h),null==i||i.drawImage(this[W],n.x,n.y,n.w,n.h),!0===this[U].canScroll&&this[H].draw(e),{position:e,size:o}},t.prototype.clear=function(){var t=this[I].getContext('2d');null==t||t.clearRect(0,0,this[I].width,this[I].height)},t.prototype.on=function(t,e){this[Y].on(t,e)},t.prototype.off=function(t,e){this[Y].off(t,e)},t.prototype.getScreenInfo=function(){return this[$].calcScreen()},t.prototype.setCursor=function(t){this[I].style.cursor=t},t.prototype.resetCursor=function(){this[I].style.cursor='auto'},t.prototype.resetSize=function(t){this[U]=e(e({},this[U]),t),this[V](),this[A].resetSize(t),this[F].resetSize(t),this[$].resetSize(t),this[H].resetSize({width:this[U].width,height:this[U].height,devicePixelRatio:this[U].devicePixelRatio}),this.draw()},t.prototype.getScrollLineWidth=function(){var t=0;return!0===this[U].canScroll&&(t=this[H].getLineWidth()),t},t.prototype.pointScreenToContext=function(t){var e=this.getTransform(),n=e.scrollX,o=e.scrollY,i=e.scale;return{x:(t.x-n)/i,y:(t.y-o)/i}},t.prototype.pointContextToScreen=function(t){var e=this.getTransform(),n=e.scrollX,o=e.scrollY,i=e.scale;return{x:t.x*i+n,y:t.y*i+o}},t.prototype[(L=R,X)]=function(){!0!==this[R]&&(this[V](),this[j](),this[R]=!0)},t.prototype[V]=function(){var t,n,o,i,r,s,l=this[U],a=l.width,c=l.height,h=l.contextWidth,u=l.contextHeight,f=l.devicePixelRatio;this[M].width=h*f,this[M].height=u*f,this[W].width=h*f,this[W].height=u*f,this[I].width=a*f,this[I].height=c*f,t=this[I],n={width:"".concat(a,"px"),height:"".concat(c,"px")},o=function(t){var e={};return(t.getAttribute('style')||'').split(';').forEach((function(t){var n=t.split(':');n[0]&&'string'==typeof n[0]&&(e[n[0]]=n[1]||'')})),e}(t),i=e(e({},o),n),r=Object.keys(i),s='',r.forEach((function(t){s+="".concat(t,":").concat(i[t]||'',";")})),t.setAttribute('style',s)},t.prototype[N]=function(t){return e(e({},{devicePixelRatio:1}),t)},t.prototype[j]=function(){var t=this;if(!0!==this[R]&&!0===this[U].canScroll){this.on('wheelX',Z((function(e){t[B](e)}),16)),this.on('wheelY',Z((function(e){t[G](e)}),16));var e=null;this.on('moveStart',Z((function(n){t[H].isPointAtScrollX(n)?e='x':t[H].isPointAtScrollY(n)&&(e='y')}),16)),this.on('move',Z((function(n){e&&t[Q](e,n)}),16)),this.on('moveEnd',Z((function(n){e&&t[Q](e,n),e=null}),16))}},t.prototype[B]=function(t,e){var n=this[U].width,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[A].getTransform().scrollX);var i=this[$].calcScreen().position,r=this[H].calc(i).xSize,s=this[$].calcScreenScroll(i.left,i.right,r,n,t);this.scrollX(o+s),this.draw()},t.prototype[G]=function(t,e){var n=this[U].height,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[A].getTransform().scrollY);var i=this[$].calcScreen().position,r=this[H].calc(i).ySize,s=this[$].calcScreenScroll(i.top,i.bottom,r,n,t);this.scrollY(o+s),this.draw()},t.prototype[Q]=function(t,e){if(t){var n=this[$].calcScreen().position,o=this[H].calc(n),i=o.xSize,r=o.ySize;'x'===t?this[B](e.x-i/2,0):'y'===t&&this[G](e.y-r/2,0)}},t}();function K(t,e){var n=-1;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n>0||(n=setTimeout((function(){t.apply(void 0,o),n=-1}),e))}}function tt(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function et(){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 nt(t){return function t(e){var n,o=(n=e,Object.prototype.toString.call(n).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var i=[];return e.forEach((function(e){i.push(t(e))})),i}if('Object'===o){var r={};return Object.keys(e).forEach((function(n){r[n]=t(e[n])})),r}}(t)}function ot(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}Object.freeze({__proto__:null,Board:J});var it={type:function(t,e){var n=ot(t);return!0===e?n.toLocaleLowerCase():n},array:function(t){return'Array'===ot(t)},json:function(t){return'Object'===ot(t)},function:function(t){return'Function'===ot(t)},asyncFunction:function(t){return'AsyncFunction'===ot(t)},string:function(t){return'String'===ot(t)},number:function(t){return'Number'===ot(t)},undefined:function(t){return'Undefined'===ot(t)},null:function(t){return'Null'===ot(t)},promise:function(t){return'Promise'===ot(t)}},rt=function(){return rt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},rt.apply(this,arguments)};function st(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function lt(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function at(t,e){var n=e.width,o=e.height;return new Promise((function(e,i){var r="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(n||'',"\" height = \"").concat(o||'',"\">\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([r],{type:'image/svg+xml;charset=utf-8'}),l=new FileReader;l.readAsDataURL(s),l.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},l.onerror=function(t){i(t)}}))}function ct(t){return new Promise((function(e,n){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),i=new FileReader;i.readAsDataURL(o),i.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},i.onerror=function(t){n(t)}}))}var ht=window.Image;function ut(t){return new Promise((function(e,n){var o=new ht;o.crossOrigin='anonymous',o.onload=function(){e(o)},o.onabort=n,o.onerror=n,o.src=t}))}var ft=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=rt(rt({},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=rt(rt({},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,n,o,i,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(n),o,i,r)},t.prototype.rect=function(t,e,n,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.fillRect=function(t,e,n,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.clearRect=function(t,e,n,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},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,n,o,i){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),this._doSize(i))},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 n=t[0],o=t[1],i=t[2],r=t[3],s=t[4],l=t[t.length-4],a=t[t.length-3],c=t[t.length-2],h=t[t.length-1];return 9===t.length?this._ctx.drawImage(n,this._doSize(o),this._doSize(i),this._doSize(r),this._doSize(s),this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h)):this._ctx.drawImage(n,this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h))},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,n,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(n))},t.prototype.strokeText=function(t,e,n,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(n))},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,n,o,i,r,s,l){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),i,r,s,l)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollX)/n;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollY)/n;return this._doSize(o)},t}();function dt(t){return'number'==typeof t&&(t>0||t<=0)}function pt(t){return'number'==typeof t&&t>=0}function vt(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function gt(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var mt={x:function(t){return dt(t)},y:function(t){return dt(t)},w:pt,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:dt,borderWidth:function(t){return pt(t)},borderRadius:function(t){return dt(t)&&t>=0},color:function(t){return tt(t)},imageSrc:function(t){return gt(t)||vt(t)},imageURL:vt,imageBase64:gt,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return dt(t)&&t>0},lineHeight:function(t){return dt(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 dt(t)&&t>0}};function yt(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!mt.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!mt.number(n))&&!(t.hasOwnProperty('borderWidth')&&!mt.number(o)))}var _t={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(mt.x(e)&&mt.y(n)&&mt.w(o)&&mt.h(i)&&mt.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!mt.text(e)&&(!!mt.color(n)&&(!!mt.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!mt.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!mt.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!mt.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!mt.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!mt.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!mt.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!mt.color(h))&&!!yt(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!mt.color(e))&&!!yt(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!mt.color(e))&&(!(t.hasOwnProperty('borderColor')&&!mt.color(n))&&!(t.hasOwnProperty('borderWidth')&&!mt.number(o)))},imageDesc:function(t){var e=t.src;return!!mt.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!mt.svg(e)},htmlDesc:function(t){var e=t.html;return!!mt.html(e)}};Object.freeze({__proto__:null,is:mt,check:_t,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,n){return function o(i){var r=t[i];i===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:K,loadImage:ut,loadSVG:function(t){return st(this,void 0,void 0,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,ct(t)];case 1:return[4,ut(e.sent())];case 2:return[2,e.sent()]}}))}))},loadHTML:function(t,e){return st(this,void 0,void 0,(function(){return lt(this,(function(n){switch(n.label){case 0:return[4,at(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,ut(n.sent())];case 2:return[2,n.sent()]}}))}))},downloadImageFromCanvas:function(t,e){var n=e.filename,o=e.type,i=void 0===o?'image/jpeg':o,r=t.toDataURL(i),s=document.createElement('a');s.href=r,s.download=n;var l=document.createEvent('MouseEvents');l.initEvent('click',!0,!1),s.dispatchEvent(l)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:tt,createUUID:et,istype:it,deepClone:nt,Context:ft});var St=function(t,e){return St=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},St(t,e)};var xt=function(){return xt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},xt.apply(this,arguments)};function bt(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function wt(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function Et(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function Pt(){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 zt(t){return function t(e){var n,o=(n=e,Object.prototype.toString.call(n).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var i=[];return e.forEach((function(e){i.push(t(e))})),i}if('Object'===o){var r={};return Object.keys(e).forEach((function(n){r[n]=t(e[n])})),r}}(t)}function Ct(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var Lt={type:function(t,e){var n=Ct(t);return!0===e?n.toLocaleLowerCase():n},array:function(t){return'Array'===Ct(t)},json:function(t){return'Object'===Ct(t)},function:function(t){return'Function'===Ct(t)},asyncFunction:function(t){return'AsyncFunction'===Ct(t)},string:function(t){return'String'===Ct(t)},number:function(t){return'Number'===Ct(t)},undefined:function(t){return'Undefined'===Ct(t)},null:function(t){return'Null'===Ct(t)},promise:function(t){return'Promise'===Ct(t)}},Dt=function(){return Dt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Dt.apply(this,arguments)};function Tt(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))}function kt(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(r){return function(l){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,l])}}}function Mt(t,e){var n=e.width,o=e.height;return new Promise((function(e,i){var r="\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(n||'',"\" height = \"").concat(o||'',"\">\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([r],{type:'image/svg+xml;charset=utf-8'}),l=new FileReader;l.readAsDataURL(s),l.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},l.onerror=function(t){i(t)}}))}function It(t){return new Promise((function(e,n){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),i=new FileReader;i.readAsDataURL(o),i.onload=function(t){var n,o=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(o)},i.onerror=function(t){n(t)}}))}var Wt=window.Image;function Ot(t){return new Promise((function(e,n){var o=new Wt;o.crossOrigin='anonymous',o.onload=function(){e(o)},o.onabort=n,o.onerror=n,o.src=t}))}function Ut(t){return Tt(this,void 0,void 0,(function(){return kt(this,(function(e){switch(e.label){case 0:return[4,It(t)];case 1:return[4,Ot(e.sent())];case 2:return[2,e.sent()]}}))}))}function Rt(t,e){return Tt(this,void 0,void 0,(function(){return kt(this,(function(n){switch(n.label){case 0:return[4,Mt(t=t.replace(/\&/gi,'&'),e)];case 1:return[4,Ot(n.sent())];case 2:return[2,n.sent()]}}))}))}var At=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=Dt(Dt({},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=Dt(Dt({},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,n,o,i,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(n),o,i,r)},t.prototype.rect=function(t,e,n,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.fillRect=function(t,e,n,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},t.prototype.clearRect=function(t,e,n,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o))},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,n,o,i){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),this._doSize(i))},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 n=t[0],o=t[1],i=t[2],r=t[3],s=t[4],l=t[t.length-4],a=t[t.length-3],c=t[t.length-2],h=t[t.length-1];return 9===t.length?this._ctx.drawImage(n,this._doSize(o),this._doSize(i),this._doSize(r),this._doSize(s),this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h)):this._ctx.drawImage(n,this._doSize(l),this._doSize(a),this._doSize(c),this._doSize(h))},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,n,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(n))},t.prototype.strokeText=function(t,e,n,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(n),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(n))},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,n,o,i,r,s,l){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(n),this._doSize(o),i,r,s,l)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollX)/n;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,n=e.scale,o=(t-e.scrollY)/n;return this._doSize(o)},t}();function Ft(t){return'number'==typeof t&&(t>0||t<=0)}function Yt(t){return'number'==typeof t&&t>=0}function Xt(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function Nt(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}var Ht={x:function(t){return Ft(t)},y:function(t){return Ft(t)},w:Yt,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:Ft,borderWidth:function(t){return Yt(t)},borderRadius:function(t){return Ft(t)&&t>=0},color:function(t){return Et(t)},imageSrc:function(t){return Nt(t)||Xt(t)},imageURL:Xt,imageBase64:Nt,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return Ft(t)&&t>0},lineHeight:function(t){return Ft(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 Ft(t)&&t>0}};function jt(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!Ht.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!Ht.number(n))&&!(t.hasOwnProperty('borderWidth')&&!Ht.number(o)))}var Bt={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(Ht.x(e)&&Ht.y(n)&&Ht.w(o)&&Ht.h(i)&&Ht.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!Ht.text(e)&&(!!Ht.color(n)&&(!!Ht.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!Ht.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!Ht.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!Ht.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!Ht.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!Ht.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!Ht.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!Ht.color(h))&&!!jt(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!Ht.color(e))&&!!jt(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!Ht.color(e))&&(!(t.hasOwnProperty('borderColor')&&!Ht.color(n))&&!(t.hasOwnProperty('borderWidth')&&!Ht.number(o)))},imageDesc:function(t){var e=t.src;return!!Ht.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!Ht.svg(e)},htmlDesc:function(t){var e=t.html;return!!Ht.html(e)}};function Gt(t,e,n){var o=function(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}(e),i=function(t){return t/180*Math.PI}(e.angle||0);return function(t,e,n,o){e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(n),t.translate(-e.x,-e.y));o(t),e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(-n),t.translate(-e.x,-e.y))}(t,o,i||0,n)}function Qt(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 Vt(t,e,n){Qt(t),function(t,e){Qt(t),Gt(t,e,(function(){if(e.desc.borderWidth&&e.desc.borderWidth>0){var n=e.desc.borderWidth,o='#000000';!0===Et(e.desc.borderColor)&&(o=e.desc.borderColor);var i=e.x-n/2,r=e.y-n/2,s=e.w+n,l=e.h+n,a=e.desc.borderRadius||0;(a=Math.min(a,s/2,l/2))<s/2&&a<l/2&&(a+=n/2);var c=e.desc;void 0!==c.shadowColor&&Et(c.shadowColor)&&t.setShadowColor(c.shadowColor),void 0!==c.shadowOffsetX&&Ht.number(c.shadowOffsetX)&&t.setShadowOffsetX(c.shadowOffsetX),void 0!==c.shadowOffsetY&&Ht.number(c.shadowOffsetY)&&t.setShadowOffsetY(c.shadowOffsetY),void 0!==c.shadowBlur&&Ht.number(c.shadowBlur)&&t.setShadowBlur(c.shadowBlur),t.beginPath(),t.setLineWidth(n),t.setStrokeStyle(o),t.moveTo(i+a,r),t.arcTo(i+s,r,i+s,r+l,a),t.arcTo(i+s,r+l,i,r+l,a),t.arcTo(i,r+l,i,r,a),t.arcTo(i,r,i+s,r,a),t.closePath(),t.stroke()}}))}(t,e),Qt(t),Gt(t,e,(function(){var o=e.x,i=e.y,r=e.w,s=e.h,l=e.desc.borderRadius||0;(r<2*(l=Math.min(l,r/2,s/2))||s<2*l)&&(l=0),t.beginPath(),t.moveTo(o+l,i),t.arcTo(o+r,i,o+r,i+s,l),t.arcTo(o+r,i+s,o,i+s,l),t.arcTo(o,i+s,o,i,l),t.arcTo(o,i,o+r,i,l),t.closePath(),('string'==typeof n||['CanvasPattern'].includes(Lt.type(n)))&&t.setFillStyle(n),t.fill()}))}function $t(t,e){Vt(t,e,e.desc.bgColor)}function Zt(t,e,n){var o=n.getContent(e.uuid);Gt(t,e,(function(){o&&t.drawImage(o,e.x,e.y,e.w,e.h)}))}function qt(t,e,n){var o=n.getContent(e.uuid);Gt(t,e,(function(){o&&t.drawImage(o,e.x,e.y,e.w,e.h)}))}function Jt(t,e,n){var o=n.getContent(e.uuid);Gt(t,e,(function(){o&&t.drawImage(o,e.x,e.y,e.w,e.h)}))}function Kt(t,e,n){Qt(t),Vt(t,e,e.desc.bgColor||'transparent'),Gt(t,e,(function(){var n=xt({fontSize:12,fontFamily:'sans-serif',textAlign:'center'},e.desc);t.setFillStyle(e.desc.color),t.setTextBaseline('top'),t.setFont({fontWeight:n.fontWeight,fontSize:n.fontSize,fontFamily:n.fontFamily});var o=n.text.replace(/\r\n/gi,'\n'),i=n.lineHeight||n.fontSize,r=o.split('\n'),s=[],l=0;r.forEach((function(n,o){var a='';if(n.length>0){for(var c=0;c<n.length&&(t.measureText(a+(n[c]||'')).width<t.calcDeviceNum(e.w)?a+=n[c]||'':(s.push({text:a,width:t.calcScreenNum(t.measureText(a).width)}),a=n[c]||'',l++),!((l+1)*i>e.h));c++)if(n.length-1===c&&(l+1)*i<e.h){s.push({text:a,width:t.calcScreenNum(t.measureText(a).width)}),o<r.length-1&&l++;break}}else s.push({text:'',width:0})}));var a=e.y;if(s.length*i<e.h&&(a+=(e.h-s.length*i)/2),void 0!==n.textShadowColor&&Et(n.textShadowColor)&&t.setShadowColor(n.textShadowColor),void 0!==n.textShadowOffsetX&&Ht.number(n.textShadowOffsetX)&&t.setShadowOffsetX(n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&Ht.number(n.textShadowOffsetY)&&t.setShadowOffsetY(n.textShadowOffsetY),void 0!==n.textShadowBlur&&Ht.number(n.textShadowBlur)&&t.setShadowBlur(n.textShadowBlur),s.forEach((function(o,r){var s=e.x;'center'===n.textAlign?s=e.x+(e.w-o.width)/2:'right'===n.textAlign&&(s=e.x+(e.w-o.width)),t.fillText(o.text,s,a+i*r)})),Qt(t),Et(n.strokeColor)&&void 0!==n.strokeWidth&&n.strokeWidth>0){var c=e.y;s.length*i<e.h&&(c+=(e.h-s.length*i)/2),s.forEach((function(o,r){var s=e.x;'center'===n.textAlign?s=e.x+(e.w-o.width)/2:'right'===n.textAlign&&(s=e.x+(e.w-o.width)),void 0!==n.strokeColor&&t.setStrokeStyle(n.strokeColor),void 0!==n.strokeWidth&&n.strokeWidth>0&&t.setLineWidth(n.strokeWidth),t.strokeText(o.text,s,c+i*r)}))}}))}function te(t,e){Qt(t),Gt(t,e,(function(t){var n=e.x,o=e.y,i=e.w,r=e.h,s=e.desc,l=s.bgColor,a=void 0===l?'#000000':l,c=s.borderColor,h=void 0===c?'#000000':c,u=s.borderWidth,f=void 0===u?0:u,d=i/2,p=r/2,v=n+d,g=o+p;if(f&&f>0){var m=f/2+d,y=f/2+p;t.beginPath(),t.setStrokeStyle(h),t.setLineWidth(f),t.ellipse(v,g,m,y,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath(),t.setFillStyle(a),t.ellipse(v,g,d,p,0,0,2*Math.PI),t.closePath(),t.fill()}))}function ee(t,e,n){var o;Qt(t);var i=t.getSize();if(t.clearRect(0,0,i.contextWidth,i.contextHeight),'string'==typeof e.bgColor&&Et(e.bgColor)&&function(t,e){var n=t.getSize();t.setFillStyle(e),t.fillRect(0,0,n.contextWidth,n.contextHeight)}(t,e.bgColor),e.elements.length>0)for(var r=0;r<e.elements.length;r++){var s=e.elements[r];if(!0!==(null===(o=null==s?void 0:s.operation)||void 0===o?void 0:o.invisible))switch(s.type){case'rect':$t(t,s);break;case'text':Kt(t,s);break;case'image':Zt(t,s,n);break;case'svg':qt(t,s,n);break;case'html':Jt(t,s,n);break;case'circle':te(t,s)}}}Object.freeze({__proto__:null,is:Ht,check:Bt,delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,n){return function o(i){var r=t[i];i===t.length&&n&&(r=n);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var n=-1;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];n>0||(n=setTimeout((function(){t.apply(void 0,o),n=-1}),e))}},loadImage:Ot,loadSVG:Ut,loadHTML:Rt,downloadImageFromCanvas:function(t,e){var n=e.filename,o=e.type,i=void 0===o?'image/jpeg':o,r=t.toDataURL(i),s=document.createElement('a');s.href=r,s.download=n;var l=document.createEvent('MouseEvents');l.initEvent('click',!0,!1),s.dispatchEvent(l)},toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:Et,createUUID:Pt,istype:Lt,deepClone:zt,Context:At});var ne,oe=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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"}(ne||(ne={}));var ie,re,se,le,ae=function(){function t(t){this._currentLoadData={},this._currentUUIDQueue=[],this._storageLoadData={},this._status=ne.FREE,this._waitingLoadQueue=[],this._opts=t,this._event=new oe,this._waitingLoadQueue=[]}return t.prototype.load=function(t,e){var n=this._resetLoadData(t,e),o=n[0],i=n[1];this._status===ne.FREE||this._status===ne.COMPLETE?(this._currentUUIDQueue=o,this._currentLoadData=i,this._loadTask()):this._status===ne.LOADING&&o.length>0&&this._waitingLoadQueue.push({uuidQueue:o,loadData:i})},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===ne.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 n={},o=[],i=this._storageLoadData,r=t.elements.length-1;r>=0;r--){var s=t.elements[r];['image','svg','html'].includes(s.type)&&(i[s.uuid]?e.includes(s.uuid)&&(n[s.uuid]=this._createEmptyLoadItem(s),o.push(s.uuid)):(n[s.uuid]=this._createEmptyLoadItem(s),o.push(s.uuid)))}return[o,n]},t.prototype._createEmptyLoadItem=function(t){var e='',n=t.type,o=t.w,i=t.h;if('image'===t.type)e=(r=t).desc.src||'';else if('svg'===t.type){e=(r=t).desc.svg||''}else if('html'===t.type){var r;e=function(t){return t.replace(/<script[\s\S]*?<\/script>/gi,'')}((r=t).desc.html||''),o=r.desc.width||t.w,i=r.desc.height||t.h}return{uuid:t.uuid,type:n,status:'null',content:null,source:e,elemW:o,elemH:i,element:zt(t)}},t.prototype._loadTask=function(){var t=this;if(this._status!==ne.LOADING){if(this._status=ne.LOADING,0===this._currentUUIDQueue.length){if(0===this._waitingLoadQueue.length)return this._status=ne.COMPLETE,void this._event.trigger('complete',void 0);var e=this._waitingLoadQueue.shift();if(e){var n=e.uuidQueue,o=e.loadData;this._currentLoadData=o,this._currentUUIDQueue=n}}var i=this._opts.maxParallelNum,r=this._currentUUIDQueue.splice(0,i);r.forEach((function(t,e){}));var s=[],l=function(){if(s.length>=i)return!1;if(0===r.length)return!0;for(var e=function(e){var n=r.shift();if(void 0===n)return"break";s.push(n),t._loadElementSource(t._currentLoadData[n]).then((function(e){var o,i;s.splice(s.indexOf(n),1);var a=l();t._storageLoadData[n]={uuid:n,type:t._currentLoadData[n].type,status:'loaded',content:e,source:t._currentLoadData[n].source,elemW:t._currentLoadData[n].elemW,elemH:t._currentLoadData[n].elemH,element:t._currentLoadData[n].element},0===s.length&&0===r.length&&!0===a&&(t._status=ne.FREE,t._loadTask()),t._event.trigger('load',{uuid:null===(o=t._storageLoadData[n])||void 0===o?void 0:o.uuid,type:t._storageLoadData[n].type,status:t._storageLoadData[n].status,content:t._storageLoadData[n].content,source:t._storageLoadData[n].source,elemW:t._storageLoadData[n].elemW,elemH:t._storageLoadData[n].elemH,element:null===(i=t._storageLoadData[n])||void 0===i?void 0:i.element})})).catch((function(e){var o,i,a,c,h,u,f,d,p,v,g,m;console.warn(e),s.splice(s.indexOf(n),1);var y=l();t._currentLoadData[n]&&(t._storageLoadData[n]={uuid:n,type:null===(o=t._currentLoadData[n])||void 0===o?void 0:o.type,status:'fail',content:null,error:e,source:null===(i=t._currentLoadData[n])||void 0===i?void 0:i.source,elemW:null===(a=t._currentLoadData[n])||void 0===a?void 0:a.elemW,elemH:null===(c=t._currentLoadData[n])||void 0===c?void 0:c.elemH,element:null===(h=t._currentLoadData[n])||void 0===h?void 0:h.element}),0===s.length&&0===r.length&&!0===y&&(t._status=ne.FREE,t._loadTask()),t._currentLoadData[n]&&t._event.trigger('error',{uuid:n,type:null===(u=t._storageLoadData[n])||void 0===u?void 0:u.type,status:null===(f=t._storageLoadData[n])||void 0===f?void 0:f.status,content:null===(d=t._storageLoadData[n])||void 0===d?void 0:d.content,source:null===(p=t._storageLoadData[n])||void 0===p?void 0:p.source,elemW:null===(v=t._storageLoadData[n])||void 0===v?void 0:v.elemW,elemH:null===(g=t._storageLoadData[n])||void 0===g?void 0:g.elemH,element:null===(m=t._storageLoadData[n])||void 0===m?void 0:m.element})}))},n=s.length;n<i;n++){if("break"===e())break}return!1};l()}},t.prototype._loadElementSource=function(t){return bt(this,void 0,void 0,(function(){return wt(this,(function(e){switch(e.label){case 0:return t&&'image'===t.type?[4,Ot(t.source)]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return t&&'svg'===t.type?[4,Ut(t.source)]:[3,4];case 4:return t&&'html'===t.type?[4,Rt(t.source,{width:t.elemW,height:t.elemH})]:[3,6];case 6:throw Error('Element\'s source is not support!')}}))}))},t}(),ce=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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}(),he=Symbol('_queue'),ue=Symbol('_ctx'),fe=Symbol('_status'),de=Symbol('_loader'),pe=Symbol('_opts'),ve=Symbol('_freeze'),ge=Symbol('_drawFrame'),me=Symbol('_retainQueueOneItem'),ye=window.requestAnimationFrame;!function(t){t.NULL="null",t.FREE="free",t.DRAWING="drawing",t.FREEZE="freeze"}(le||(le={}));var _e=function(t){function e(e){var n=t.call(this)||this;return n[ie]=[],n[re]=null,n[se]=le.NULL,n[pe]=e,n[de]=new ae({maxParallelNum:6}),n[de].on('load',(function(t){n[ge](),n.trigger('load',{element:t.element})})),n[de].on('error',(function(t){n.trigger('error',{element:t.element,error:t.error})})),n[de].on('complete',(function(){n.trigger('loadComplete',{t:Date.now()})})),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}St(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.render=function(t,e,n){var o=(n||{}).changeResourceUUIDs,i=void 0===o?[]:o;this[fe]=le.FREE;var r=zt(e);if(Array.isArray(r.elements)&&r.elements.forEach((function(t){'string'==typeof t.uuid&&t.uuid||(t.uuid=Pt())})),!this[ue])if(this[pe]&&'[object HTMLCanvasElement]'===Object.prototype.toString.call(t)){var s=this[pe],l=s.width,a=s.height,c=s.contextWidth,h=s.contextHeight,u=s.devicePixelRatio,f=t;f.width=l*u,f.height=a*u;var d=f.getContext('2d');this[ue]=new At(d,{width:l,height:a,contextWidth:c||l,contextHeight:h||a,devicePixelRatio:u})}else t&&(this[ue]=t);if(![le.FREEZE].includes(this[fe])){var p=zt({data:r});this[he].push(p),this[ge](),this[de].load(r,i||[])}},e.prototype.getContext=function(){return this[ue]},e.prototype.thaw=function(){this[fe]=le.FREE},e.prototype[(ie=he,re=ue,se=fe,ve)]=function(){this[fe]=le.FREEZE},e.prototype[ge]=function(){var t=this;this[fe]!==le.FREEZE&&ye((function(){if(t[fe]!==le.FREEZE){var e=t[ue],n=t[he][0],o=!1;t[he].length>1?n=t[he].shift():o=!0,!0!==t[de].isComplete()?(t[ge](),n&&e&&ee(e,n.data,t[de])):n&&e?(ee(e,n.data,t[de]),t[me](),o?t[fe]=le.FREE:t[ge]()):t[fe]=le.FREE,t.trigger('drawFrame',{t:Date.now()}),!0===t[de].isComplete()&&1===t[he].length&&t[fe]===le.FREE&&(e&&t[he][0]&&t[he][0].data&&ee(e,t[he][0].data,t[de]),t.trigger('drawFrameComplete',{t:Date.now()}),t[ve]())}}))},e.prototype[me]=function(){if(!(this[he].length<=1)){var t=zt(this[he][this[he].length-1]);this[he]=[t]}},e}(ce);function Se(t){return'number'==typeof t&&(t>0||t<=0)}function xe(t){return'number'==typeof t&&t>=0}function be(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(t))}function we(t){return'string'==typeof t&&/^(data:image\/)/.test("".concat(t))}Object.freeze({__proto__:null,Renderer:_e});var Ee={x:function(t){return Se(t)},y:function(t){return Se(t)},w:xe,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:Se,borderWidth:function(t){return xe(t)},borderRadius:function(t){return Se(t)&&t>=0},color:function(t){return tt(t)},imageSrc:function(t){return we(t)||be(t)},imageURL:be,imageBase64:we,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 n=document.createElement('div');n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return Se(t)&&t>0},lineHeight:function(t){return Se(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 Se(t)&&t>0}};function Pe(t){void 0===t&&(t={});var e=t.borderColor,n=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!Ee.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!Ee.number(n))&&!(t.hasOwnProperty('borderWidth')&&!Ee.number(o)))}var ze={attrs:function(t){var e=t.x,n=t.y,o=t.w,i=t.h,r=t.angle;return!!(Ee.x(e)&&Ee.y(n)&&Ee.w(o)&&Ee.h(i)&&Ee.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,n=t.color,o=t.fontSize,i=t.lineHeight,r=t.fontFamily,s=t.textAlign,l=t.fontWeight,a=t.bgColor,c=t.strokeWidth,h=t.strokeColor;return!!Ee.text(e)&&(!!Ee.color(n)&&(!!Ee.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!Ee.color(a))&&(!(t.hasOwnProperty('fontWeight')&&!Ee.fontWeight(l))&&(!(t.hasOwnProperty('lineHeight')&&!Ee.lineHeight(i))&&(!(t.hasOwnProperty('fontFamily')&&!Ee.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!Ee.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!Ee.strokeWidth(c))&&(!(t.hasOwnProperty('strokeColor')&&!Ee.color(h))&&!!Pe(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!Ee.color(e))&&!!Pe(t)},circleDesc:function(t){var e=t.bgColor,n=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!Ee.color(e))&&(!(t.hasOwnProperty('borderColor')&&!Ee.color(n))&&!(t.hasOwnProperty('borderWidth')&&!Ee.number(o)))},imageDesc:function(t){var e=t.src;return!!Ee.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!Ee.svg(e)},htmlDesc:function(t){var e=t.html;return!!Ee.html(e)}};function Ce(t){return t/180*Math.PI}function Le(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function De(t,e){var n=e.x-t.x,o=t.y-e.y;if(0===n){if(o<0)return Math.PI/2;if(o>0)return 1.5*Math.PI}else if(0===o){if(n<0)return Math.PI;if(n>0)return 0}return n>0&&o<0?Math.atan(Math.abs(o)/Math.abs(n)):n<0&&o<0?Math.PI-Math.atan(Math.abs(o)/Math.abs(n)):n<0&&o>0?Math.PI+Math.atan(Math.abs(o)/Math.abs(n)):n>0&&o>0?2*Math.PI-Math.atan(Math.abs(o)/Math.abs(n)):null}var Te={elementWrapper:{color:'#2ab6f1',lockColor:'#aaaaaa',controllerSize:6,lineWidth:1,lineDash:[4,3]}};var ke=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);null==n||n.push(e),this._listeners.set(t,n||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var n=this._listeners.get(t);if(Array.isArray(n))for(var o=0;o<(null==n?void 0:n.length);o++)if(n[o]===e){n.splice(o,1);break}this._listeners.set(t,n||[])}},t.prototype.trigger=function(t,e){var n=this._listeners.get(t);return!!Array.isArray(n)&&(n.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 Me(t,e){var n,o;return(null===(n=null==t?void 0:t.desc)||void 0===n?void 0:n.src)!==(null===(o=null==e?void 0:e.desc)||void 0===o?void 0:o.src)}function Ie(t,e){var n,o;return(null===(n=null==t?void 0:t.desc)||void 0===n?void 0:n.svg)!==(null===(o=null==e?void 0:e.desc)||void 0===o?void 0:o.svg)}function We(t,e){var n,o,i,r,s,l;return(null===(n=null==t?void 0:t.desc)||void 0===n?void 0:n.html)!==(null===(o=null==e?void 0:e.desc)||void 0===o?void 0:o.html)||(null===(i=null==t?void 0:t.desc)||void 0===i?void 0:i.width)!==(null===(r=null==e?void 0:e.desc)||void 0===r?void 0:r.width)||(null===(s=null==t?void 0:t.desc)||void 0===s?void 0:s.height)!==(null===(l=null==e?void 0:e.desc)||void 0===l?void 0:l.height)}function Oe(t,e){var n=null,o=!1;switch(e.type){case'image':o=Me(t,e);break;case'svg':o=Ie(t,e);break;case'html':o=We(t,e)}return!0===o&&(n=e.uuid),n}function Ue(t){var e={};return t.elements.forEach((function(t){e[t.uuid]=t})),e}function Re(t,e,n){return Ae(t,Le(e),Ce(e.angle||0)||0,n)}function Ae(t,e,n,o){e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(n),t.translate(-e.x,-e.y)),o(t),e&&(n>0||n<0)&&(t.translate(e.x,e.y),t.rotate(-n),t.translate(-e.x,-e.y))}function Fe(t){var e=t.toFixed(2);return parseFloat(e)}function Ye(t){return Fe(t%360)}var Xe=Object.keys({text:{},rect:{},image:{},svg:{},circle:{},html:{}}),Ne=15,He=function(){function t(t){this._ctx=t}return t.prototype.initData=function(t){return t.elements.forEach((function(t){t.uuid&&'string'==typeof t.uuid||(t.uuid=et())})),t},t.prototype.isPointInElement=function(t,e){for(var n,o,i=this._ctx,r=-1,s=null,l=function(l){var a=e.elements[l];if(!0===(null===(n=a.operation)||void 0===n?void 0:n.invisible))return"continue";var c=0;return(null===(o=a.desc)||void 0===o?void 0:o.borderWidth)>0&&(c=a.desc.borderWidth),Re(i,a,(function(){i.beginPath(),i.moveTo(a.x-c,a.y-c),i.lineTo(a.x+a.w+c,a.y-c),i.lineTo(a.x+a.w+c,a.y+a.h+c),i.lineTo(a.x-c,a.y+a.h+c),i.lineTo(a.x-c,a.y-c),i.closePath(),i.isPointInPath(t.x,t.y)&&(r=l,s=a.uuid)})),r>=0?"break":void 0},a=e.elements.length-1;a>=0;a--){if("break"===l(a))break}return[r,s]},t.prototype.dragElement=function(t,e,n,o,i){var r=this.getElementIndex(t,e);if(t.elements[r]){var s=n.x-o.x,l=n.y-o.y;t.elements[r].x+=s/i,t.elements[r].y+=l/i,this.limitElementAttrs(t.elements[r])}},t.prototype.transformElement=function(t,e,n,o,i,r){var s,l,a=this.getElementIndex(t,e);if(!t.elements[a])return null;if(!0===(null===(l=null===(s=t.elements[a])||void 0===s?void 0:s.operation)||void 0===l?void 0:l.lock))return null;var c=(n.x-o.x)/i,h=(n.y-o.y)/i,u=t.elements[a];if(['top-left','top','top-right','right','bottom-right','bottom','bottom-left','left'].includes(r)){var f=function(t,e,n,o,i){var r={x:t.x,y:t.y,w:t.w,h:t.h};switch(t.angle,o){case'top-left':t.w-e>0&&t.h-n>0&&(r.x+=e,r.y+=n,r.w-=e,r.h-=n);break;case'top':if(0===t.angle||Math.abs(t.angle)<Ne)r.h-n>0&&(r.y+=n,r.h-=n);else if(t.angle>0||t.angle<0){var s=t.angle>0?t.angle:Math.max(0,t.angle+360),l=Be(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(s<90){l=0-Ge(l,n);var h=je(s);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}else if(s<180){l=Ge(l,e);h=je(s-90);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}else if(s<270){l=Ge(l,n);h=je(s-180);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}else if(s<360){l=0-Ge(l,e);h=je(s-270);a-=(p=l/2)*Math.cos(h),c-=p*Math.sin(h)}r.h+l>0&&(r.h=r.h+l,r.x=a-r.w/2,r.y=c-r.h/2)}else r.h-n>0&&(r.y+=n,r.h-=n);break;case'top-right':r.h-n>0&&r.w+e>0&&(r.y+=n,r.w+=e,r.h-=n);break;case'right':if(0===t.angle||Math.abs(t.angle)<Ne)t.w+e>0&&(r.w+=e);else if(t.angle>0||t.angle<0){var u=t.angle>0?t.angle:Math.max(0,t.angle+360);l=Be(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(u<90){l=Ge(l,n);h=je(u);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}else if(u<180){l=Ge(l,n);h=je(u-90);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}else if(u<270){l=Ge(l,n);h=je(u-180);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h),l=0-l}else if(u<360){l=Ge(l,e);h=je(u-270);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}r.w+l>0&&(r.w=r.w+l,r.x=a-r.w/2,r.y=c-r.h/2)}else t.w+e>0&&(r.w+=e);break;case'bottom-right':t.w+e>0&&t.h+n>0&&(r.w+=e,r.h+=n);break;case'bottom':if(0===t.angle||Math.abs(t.angle)<Ne)t.h+n>0&&(r.h+=n);else if(t.angle>0||t.angle<0){var f=t.angle>0?t.angle:Math.max(0,t.angle+360);l=Be(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(f<90){l=Ge(l,n);h=je(f);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}else if(f<180){l=0-Ge(l,e);h=je(f-90);a-=(p=l/2)*Math.cos(h),c-=p*Math.sin(h)}else if(f<270){l=Ge(l,e);h=je(f-180);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}else if(f<360){l=Ge(l,e);h=je(f-270);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}r.h+l>0&&(r.h=r.h+l,r.x=a-r.w/2,r.y=c-r.h/2)}else t.h+n>0&&(r.h+=n);break;case'bottom-left':t.w-e>0&&t.h+n>0&&(r.x+=e,r.w-=e,r.h+=n);break;case'left':if(0===t.angle||Math.abs(t.angle)<Ne)t.w-e>0&&(r.x+=e,r.w-=e);else if(t.angle>0||t.angle<0){var d=t.angle>0?t.angle:Math.max(0,t.angle+360);l=Be(e,n),a=r.x+t.w/2,c=r.y+t.h/2;if(d<90){l=0-Ge(l,e);h=je(d);a-=(p=l/2)*Math.cos(h),c-=p*Math.sin(h)}else if(d<180){l=Ge(l,e);h=je(d-90);a+=(p=l/2)*Math.sin(h),c-=p*Math.cos(h)}else if(d<270){l=Ge(l,n);h=je(d-180);a+=(p=l/2)*Math.cos(h),c+=p*Math.sin(h)}else if(d<360){l=Ge(l,n);var p;h=je(d-270);a-=(p=l/2)*Math.sin(h),c+=p*Math.cos(h)}r.w+l>0&&(r.w=r.w+l,r.x=a-r.w/2,r.y=c-r.h/2)}else t.w-e>0&&(r.x+=e,r.w-=e)}return r}(u,c,h,r);u.x=f.x,u.y=f.y,u.w=f.w,u.h=f.h}else if('rotate'===r){var d=function(t,e,n){var o=De(t,e),i=De(t,n);return null!==i&&null!==o?o>3*Math.PI/2&&i<Math.PI/2?i+(2*Math.PI-o):i>3*Math.PI/2&&o<Math.PI/2?o+(2*Math.PI-i):i-o:0}(Le(u),o,n);u.angle=(u.angle||0)+function(t){return t/Math.PI*180}(d)}return this.limitElementAttrs(u),{width:Fe(u.w),height:Fe(u.h),angle:Ye(u.angle||0)}},t.prototype.getElementIndex=function(t,e){for(var n=-1,o=0;o<t.elements.length;o++)if(t.elements[o].uuid===e){n=o;break}return n},t.prototype.limitElementAttrs=function(t){t.x=Fe(t.x),t.y=Fe(t.y),t.w=Fe(t.w),t.h=Fe(t.h),t.angle=Ye(t.angle||0)},t}();function je(t){return t*Math.PI/180}function Be(t,e){return Math.sqrt(t*t+e*e)}function Ge(t,e){return e>0?Math.abs(t):0-Math.abs(t)}var Qe=function(){function t(t,e){this._areaStart={x:0,y:0},this._areaEnd={x:0,y:0},this._board=t,this._ctx=this._board.getContext(),this._coreConfig=e,this._helperConfig={elementIndexMap:{}}}return t.prototype.updateConfig=function(t,e){this._updateElementIndex(t),this._updateSelectedElementWrapper(t,e),this._updateSelectedElementListWrapper(t,e)},t.prototype.getConfig=function(){return nt(this._helperConfig)},t.prototype.getElementIndexByUUID=function(t){var e=this._helperConfig.elementIndexMap[t];return e>=0?e:null},t.prototype.isPointInElementWrapperController=function(t,e){var n,o,i=this._ctx,r=(null===(o=null===(n=this._helperConfig)||void 0===n?void 0:n.selectedElementWrapper)||void 0===o?void 0:o.uuid)||null,s=null,l=null,a=null;if(!this._helperConfig.selectedElementWrapper)return{uuid:r,selectedControllerDirection:l,directIndex:s,hoverControllerDirection:a};var c=this._helperConfig.selectedElementWrapper,h=[c.controllers.right,c.controllers.topRight,c.controllers.top,c.controllers.topLeft,c.controllers.left,c.controllers.bottomLeft,c.controllers.bottom,c.controllers.bottomRight],u=['right','top-right','top','top-left','left','bottom-left','bottom','bottom-right'],f=nt(u),d=0;if(e&&r){var p=this.getElementIndexByUUID(r);if(null!==p&&p>=0){var v=e.elements[p].angle;v<0&&(v+=360),v<45?d=0:v<90?d=1:v<135?d=2:v<180?d=3:v<225?d=4:v<270?d=5:v<315&&(d=6)}}if(d>0&&(f=f.slice(-d).concat(f.slice(0,-d))),Ae(i,c.translate,c.radian||0,(function(){for(var e=0;e<h.length;e++){var n=h[e];if(!0!==n.invisible&&(i.beginPath(),i.arc(n.x,n.y,c.controllerSize,0,2*Math.PI),i.closePath(),i.isPointInPath(t.x,t.y)&&(l=u[e],a=f[e]),l)){s=e;break}}})),null===l){var g=c.controllers.rotate;!0!==g.invisible&&Ae(i,c.translate,c.radian||0,(function(){i.beginPath(),i.arc(g.x,g.y,c.controllerSize,0,2*Math.PI),i.closePath(),i.isPointInPath(t.x,t.y)&&(l='rotate',a='rotate')}))}return{uuid:r,selectedControllerDirection:l,hoverControllerDirection:a,directIndex:s}},t.prototype.isPointInElementList=function(t,e){for(var n,o,i,r=this._ctx,s=-1,l=null,a=(null===(n=this._helperConfig)||void 0===n?void 0:n.selectedElementListWrappers)||[],c=function(n){var c=a[n],u=h._helperConfig.elementIndexMap[c.uuid],f=e.elements[u];if(!f)return"continue";if(!0===(null===(o=f.operation)||void 0===o?void 0:o.invisible))return"continue";var d=0;return(null===(i=f.desc)||void 0===i?void 0:i.borderWidth)>0&&(d=f.desc.borderWidth),Re(r,f,(function(){r.beginPath(),r.moveTo(f.x-d,f.y-d),r.lineTo(f.x+f.w+d,f.y-d),r.lineTo(f.x+f.w+d,f.y+f.h+d),r.lineTo(f.x-d,f.y+f.h+d),r.lineTo(f.x-d,f.y-d),r.closePath(),r.isPointInPath(t.x,t.y)&&(s=n,l=f.uuid)})),s>=0?"break":void 0},h=this,u=0;u<a.length;u++){if("break"===c(u))break}return!!(l&&s>=0)},t.prototype.startSelectArea=function(t){this._areaStart=t,this._areaEnd=t},t.prototype.changeSelectArea=function(t){this._areaEnd=t,this._calcSelectedArea()},t.prototype.clearSelectedArea=function(){this._areaStart={x:0,y:0},this._areaEnd={x:0,y:0},this._calcSelectedArea()},t.prototype.calcSelectedElements=function(t){var e=this._ctx.getTransform(),n=e.scale,o=void 0===n?1:n,i=e.scrollX,r=void 0===i?0:i,s=e.scrollY,l=void 0===s?0:s,a=this._areaStart,c=this._areaEnd,h=(Math.min(a.x,c.x)-r)/o,u=(Math.min(a.y,c.y)-l)/o,f=Math.abs(c.x-a.x)/o,d=Math.abs(c.y-a.y)/o,p=[],v=this._ctx;return v.beginPath(),v.moveTo(h,u),v.lineTo(h+f,u),v.lineTo(h+f,u+d),v.lineTo(h,u+d),v.lineTo(h,u),v.closePath(),t.elements.forEach((function(t){var e;if(!0!==(null===(e=null==t?void 0:t.operation)||void 0===e?void 0:e.invisible)){var n=t.x+t.w/2,o=t.y+t.h/2;v.isPointInPathWithoutScroll(n,o)&&p.push(t.uuid)}})),p},t.prototype._calcSelectedArea=function(){var t=this._areaStart,e=this._areaEnd,n=this._ctx.getTransform(),o=n.scale,i=void 0===o?1:o,r=n.scrollX,s=void 0===r?0:r,l=n.scrollY,a=void 0===l?0:l,c=this._coreConfig.elementWrapper,h=c.lineWidth/i,u=c.lineDash.map((function(t){return t/i}));this._helperConfig.selectedAreaWrapper={x:(Math.min(t.x,e.x)-s)/i,y:(Math.min(t.y,e.y)-a)/i,w:Math.abs(e.x-t.x)/i,h:Math.abs(e.y-t.y)/i,startPoint:{x:t.x,y:t.y},endPoint:{x:e.x,y:e.y},lineWidth:h,lineDash:u,color:c.color}},t.prototype._updateElementIndex=function(t){var e=this;this._helperConfig.elementIndexMap={},t.elements.forEach((function(t,n){e._helperConfig.elementIndexMap[t.uuid]=n}))},t.prototype._updateSelectedElementWrapper=function(t,e){var n,o=e.selectedUUID;if('string'==typeof o&&this._helperConfig.elementIndexMap[o]>=0){var i=this._helperConfig.elementIndexMap[o],r=t.elements[i];if(!0!==(null===(n=null==r?void 0:r.operation)||void 0===n?void 0:n.invisible)){var s=this._createSelectedElementWrapper(r,e);this._helperConfig.selectedElementWrapper=s}}else delete this._helperConfig.selectedElementWrapper},t.prototype._updateSelectedElementListWrapper=function(t,e){var n=this,o=e.selectedUUIDList,i=[];t.elements.forEach((function(t,r){if(null==o?void 0:o.includes(t.uuid)){var s=n._createSelectedElementWrapper(t,e);i.push(s)}})),this._helperConfig.selectedElementListWrappers=i},t.prototype._createSelectedElementWrapper=function(t,e){var n,o,i,r,s,l,a,c,h,u,f,d,p=e.scale,v=this._coreConfig.elementWrapper,g=v.controllerSize/p,m=v.lineWidth/p,y=v.lineDash.map((function(t){return t/p})),_=(null===(n=t.desc)||void 0===n?void 0:n.borderWidth)||0,S=!1;'number'==typeof t.angle&&Math.abs(t.angle)>15&&(S=!0);var x=m,b={uuid:t.uuid,controllerSize:g,controllerOffset:x,lock:!0===(null===(o=null==t?void 0:t.operation)||void 0===o?void 0:o.lock),controllers:{topLeft:{x:t.x-x-_,y:t.y-x-_,invisible:S||!0===(null===(i=null==t?void 0:t.operation)||void 0===i?void 0:i.disbaleScale)},top:{x:t.x+t.w/2,y:t.y-x-_,invisible:!0===(null===(r=null==t?void 0:t.operation)||void 0===r?void 0:r.disbaleScale)},topRight:{x:t.x+t.w+x+_,y:t.y-x-_,invisible:S||!0===(null===(s=null==t?void 0:t.operation)||void 0===s?void 0:s.disbaleScale)},right:{x:t.x+t.w+x+_,y:t.y+t.h/2,invisible:!0===(null===(l=null==t?void 0:t.operation)||void 0===l?void 0:l.disbaleScale)},bottomRight:{x:t.x+t.w+x+_,y:t.y+t.h+x+_,invisible:S||!0===(null===(a=null==t?void 0:t.operation)||void 0===a?void 0:a.disbaleScale)},bottom:{x:t.x+t.w/2,y:t.y+t.h+x+_,invisible:!0===(null===(c=null==t?void 0:t.operation)||void 0===c?void 0:c.disbaleScale)},bottomLeft:{x:t.x-x-_,y:t.y+t.h+x+_,invisible:S||!0===(null===(h=null==t?void 0:t.operation)||void 0===h?void 0:h.disbaleScale)},left:{x:t.x-x-_,y:t.y+t.h/2,invisible:!0===(null===(u=null==t?void 0:t.operation)||void 0===u?void 0:u.disbaleScale)},rotate:{x:t.x+t.w/2,y:t.y-g-(2*g+12)-_,invisible:!0===(null===(f=null==t?void 0:t.operation)||void 0===f?void 0:f.disbaleRotate)}},lineWidth:m,lineDash:y,color:!0===(null===(d=null==t?void 0:t.operation)||void 0===d?void 0:d.lock)?v.lockColor:v.color};return'number'==typeof t.angle&&(t.angle>0||t.angle<0)&&(b.radian=Ce(t.angle),b.translate=Le(t)),b},t}(),Ve=Symbol('_displayCtx'),$e=Symbol('_helper'),Ze=Symbol('_element'),qe=Symbol('_opts'),Je=function(){function t(t){this[qe]=t,this[Ve]=this[qe].board,this[Ze]=this[qe].element,this[$e]=this[qe].helper}return t.prototype.isEffectivePoint=function(t){var e=this[Ve].getScrollLineWidth(),n=this[Ve].getScreenInfo();return t.x<=n.width-e&&t.y<=n.height-e},t.prototype.judgePointCursor=function(t,e){var n='auto',o=null;if(!this.isEffectivePoint(t))return{cursor:n,elementUUID:o};var i=this[$e].isPointInElementWrapperController(t,e),r=i.uuid,s=i.hoverControllerDirection;if(r&&s){switch(s){case'top-right':n='ne-resize';break;case'top-left':n='nw-resize';break;case'top':n='n-resize';break;case'right':n='e-resize';break;case'bottom-right':n='se-resize';break;case'bottom':n='s-resize';break;case'bottom-left':n='sw-resize';break;case'left':n='w-resize';break;case'rotate':n='grab'}r&&(o=r)}else{var l=this[Ze].isPointInElement(t,e),a=l[0],c=l[1];a>=0&&(n='move'),c&&(o=c)}return{cursor:n,elementUUID:o}},t}();function Ke(t){var e={elements:[]};return Array.isArray(null==t?void 0:t.elements)&&(null==t||t.elements.forEach((function(t){void 0===t&&(t={}),function(t){if(!(tn(t.x)&&tn(t.y)&&tn(t.w)&&tn(t.h)))return!1;if('string'!=typeof t.type||!Xe.includes(t.type))return!1;return!0}(t)&&e.elements.push(t)}))),'string'==typeof t.bgColor&&(e.bgColor=t.bgColor),e}function tn(t){return t>=0||t<0}var en,nn,on=function(){function t(){this._temp={hasInited:!1}}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(){this._temp={hasInited:!1}},t}(),rn=Symbol('_board'),sn=Symbol('_data'),ln=Symbol('_opts'),an=Symbol('_config'),cn=Symbol('_renderer'),hn=Symbol('_element'),un=Symbol('_tempData'),fn=Symbol('_draw'),dn=Symbol('_coreEvent'),pn=Symbol('_emitChangeScreen'),vn=Symbol('_emitChangeData'),gn=Symbol('_engine');function mn(){return{hasInited:!1,mode:en.NULL,cursorStatus:nn.NULL,selectedUUID:null,selectedUUIDList:[],hoverUUID:null,selectedControllerDirection:null,hoverControllerDirection:null,prevPoint:null}}!function(t){t.NULL="null",t.SELECT_ELEMENT="select-element",t.SELECT_ELEMENT_LIST="select-element-list",t.SELECT_ELEMENT_WRAPPER_CONTROLLER="select-element-wrapper-controller",t.SELECT_AREA="select-area"}(en||(en={})),function(t){t.DRAGGING="dragging",t.NULL="null"}(nn||(nn={}));var yn=function(){function t(){this._temp=mn()}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(){this._temp=mn()},t}(),_n=function(){function t(t){this._plugins=[];var e=t.board,n=t.config,o=t.element,i=new Qe(e,n);this._opts=t,this.temp=new yn,this.helper=i,this._mapper=new Je({board:e,helper:i,element:o})}return t.prototype.addPlugin=function(t){this._plugins.push(t)},t.prototype.getHelperConfig=function(){return this.helper.getConfig()},t.prototype.updateHelperConfig=function(t){var e,n=this._opts,o=n.board,i=n.getDataFeekback,r=n.config,s=i(),l=o.getTransform();this.helper.updateConfig(s,{width:t.width,height:t.height,devicePixelRatio:t.devicePixelRatio,canScroll:!0===(null===(e=null==r?void 0:r.scrollWrapper)||void 0===e?void 0:e.use),selectedUUID:this.temp.get('selectedUUID'),selectedUUIDList:this.temp.get('selectedUUIDList'),scale:l.scale,scrollX:l.scrollX,scrollY:l.scrollY})},t.prototype.init=function(){this._initEvent()},t.prototype._initEvent=function(){if(!0!==this.temp.get('hasInited')){var t=this._opts.board;t.on('hover',K(this._handleHover.bind(this),32)),t.on('leave',K(this._handleLeave.bind(this),32)),t.on('point',K(this._handleClick.bind(this),16)),t.on('doubleClick',this._handleDoubleClick.bind(this)),t.on('point',this._handlePoint.bind(this)),t.on('moveStart',this._handleMoveStart.bind(this)),t.on('move',K(this._handleMove.bind(this),16)),t.on('moveEnd',this._handleMoveEnd.bind(this))}},t.prototype._handleDoubleClick=function(t){var e,n,o,i=this._opts,r=i.element,s=i.getDataFeekback,l=i.drawFeekback,a=i.coreEvent,c=s(),h=r.isPointInElement(t,c),u=h[0],f=h[1];if(u>=0&&f){var d=nt(null===(e=c.elements)||void 0===e?void 0:e[u]);!0!==(null===(n=null==d?void 0:d.operation)||void 0===n?void 0:n.invisible)&&a.trigger('screenDoubleClickElement',{index:u,uuid:f,element:nt(null===(o=c.elements)||void 0===o?void 0:o[u])})}l()},t.prototype._handlePoint=function(t){var e,n,o;if(this._mapper.isEffectivePoint(t)){var i=this._opts,r=i.element,s=i.getDataFeekback,l=i.selectElementByIndex,a=i.coreEvent,c=i.emitChangeScreen,h=i.drawFeekback,u=this.helper,f=s();if(u.isPointInElementList(t,f))this.temp.set('mode',en.SELECT_ELEMENT_LIST);else{var d=u.isPointInElementWrapperController(t,f),p=d.uuid,v=d.selectedControllerDirection;if(p&&v)this.temp.set('mode',en.SELECT_ELEMENT_WRAPPER_CONTROLLER),this.temp.set('selectedControllerDirection',v),this.temp.set('selectedUUID',p);else{var g=r.isPointInElement(t,f),m=g[0],y=g[1];m>=0&&!0!==(null===(n=null===(e=f.elements[m])||void 0===e?void 0:e.operation)||void 0===n?void 0:n.invisible)?(l(m,{useMode:!0}),'string'==typeof y&&a.has('screenSelectElement')&&(a.trigger('screenSelectElement',{index:m,uuid:y,element:nt(null===(o=f.elements)||void 0===o?void 0:o[m])}),c()),this.temp.set('mode',en.SELECT_ELEMENT)):(this.temp.set('selectedUUIDList',[]),this.temp.set('selectedUUID',null),this.temp.set('mode',en.SELECT_AREA))}}h()}},t.prototype._handleClick=function(t){var e,n=this._opts,o=n.element,i=n.getDataFeekback,r=n.coreEvent,s=n.drawFeekback,l=i(),a=o.isPointInElement(t,l),c=a[0],h=a[1];c>=0&&h&&r.trigger('screenClickElement',{index:c,uuid:h,element:nt(null===(e=l.elements)||void 0===e?void 0:e[c])}),s()},t.prototype._handleMoveStart=function(t){var e=this._opts,n=e.element,o=e.getDataFeekback,i=e.coreEvent,r=o(),s=this.helper;this.temp.set('prevPoint',t);var l=this.temp.get('selectedUUID');this.temp.get('mode')===en.SELECT_ELEMENT_LIST||(this.temp.get('mode')===en.SELECT_ELEMENT?'string'==typeof l&&i.has('screenMoveElementStart')&&i.trigger('screenMoveElementStart',{index:n.getElementIndex(r,l),uuid:l,x:t.x,y:t.y}):this.temp.get('mode')===en.SELECT_AREA&&s.startSelectArea(t))},t.prototype._handleMove=function(t){var e=this._opts.drawFeekback,n=this.helper;this.temp.get('mode')===en.SELECT_ELEMENT_LIST?(this._dragElements(this.temp.get('selectedUUIDList'),t,this.temp.get('prevPoint')),e(),this.temp.set('cursorStatus',nn.DRAGGING)):'string'==typeof this.temp.get('selectedUUID')?this.temp.get('mode')===en.SELECT_ELEMENT?(this._dragElements([this.temp.get('selectedUUID')],t,this.temp.get('prevPoint')),e(),this.temp.set('cursorStatus',nn.DRAGGING)):this.temp.get('mode')===en.SELECT_ELEMENT_WRAPPER_CONTROLLER&&this.temp.get('selectedControllerDirection')&&(this._transfromElement(this.temp.get('selectedUUID'),t,this.temp.get('prevPoint'),this.temp.get('selectedControllerDirection')),this.temp.set('cursorStatus',nn.DRAGGING)):this.temp.get('mode')===en.SELECT_AREA&&(n.changeSelectArea(t),e()),this.temp.set('prevPoint',t)},t.prototype._dragElements=function(t,e,n){if(n){var o=this._opts,i=o.board,r=o.element,s=o.getDataFeekback,l=o.drawFeekback,a=s(),c=this.helper;t.forEach((function(t){var o,s,l=c.getElementIndexByUUID(t);if(null!==l){var h=a.elements[l];!0!==(null===(o=null==h?void 0:h.operation)||void 0===o?void 0:o.lock)&&!0!==(null===(s=null==h?void 0:h.operation)||void 0===s?void 0:s.invisible)&&r.dragElement(a,t,e,n,i.getContext().getTransform().scale)}})),l()}},t.prototype._transfromElement=function(t,e,n,o){if(!n)return null;var i=this._opts,r=i.board,s=i.element,l=i.getDataFeekback,a=i.drawFeekback,c=l(),h=s.transformElement(c,t,e,n,r.getContext().getTransform().scale,o);return a(),h},t.prototype._handleMoveEnd=function(t){var e=this._opts,n=e.element,o=e.getDataFeekback,i=e.coreEvent,r=e.drawFeekback,s=e.emitChangeData,l=o(),a=this.helper,c=this.temp.get('selectedUUID');if('string'==typeof c){var h=n.getElementIndex(l,c),u=l.elements[h];u&&(i.has('screenMoveElementEnd')&&i.trigger('screenMoveElementEnd',{index:h,uuid:c,x:t.x,y:t.y}),i.has('screenChangeElement')&&i.trigger('screenChangeElement',{index:h,uuid:c,width:u.w,height:u.h,angle:u.angle||0}),s())}else if(this.temp.get('mode')===en.SELECT_AREA){var f=a.calcSelectedElements(l);f.length>0?(this.temp.set('selectedUUIDList',f),this.temp.set('selectedUUID',null)):this.temp.set('mode',en.NULL),a.clearSelectedArea(),r()}this.temp.get('mode')!==en.SELECT_ELEMENT&&this.temp.set('selectedUUID',null),this.temp.set('cursorStatus',nn.NULL),this.temp.set('mode',en.NULL)},t.prototype._handleHover=function(t){var e,n,o=!1,i=this._opts,r=i.board,s=i.getDataFeekback,l=i.coreEvent,a=s(),c=this.helper,h=this._mapper;if(this.temp.get('mode')===en.SELECT_AREA)r.resetCursor();else if(this.temp.get('cursorStatus')===nn.NULL){var u=h.judgePointCursor(t,a),f=u.cursor,d=u.elementUUID;if(r.setCursor(f),d)if(null!==(g=c.getElementIndexByUUID(d))&&g>=0){var p=a.elements[g];if(!0===(null===(e=null==p?void 0:p.operation)||void 0===e?void 0:e.lock)||!0===(null===(n=null==p?void 0:p.operation)||void 0===n?void 0:n.invisible))return void r.resetCursor();if(this.temp.get('hoverUUID')!==p.uuid){var v=c.getElementIndexByUUID(this.temp.get('hoverUUID')||'');null!==v&&a.elements[v]&&l.trigger('mouseLeaveElement',{uuid:this.temp.get('hoverUUID'),index:v,element:a.elements[v]})}p&&(l.trigger('mouseOverElement',{uuid:p.uuid,index:g,element:p}),this.temp.set('hoverUUID',p.uuid),o=!0)}}if(!0!==o&&null!==this.temp.get('hoverUUID')){var g,m=this.temp.get('hoverUUID');null!==(g=c.getElementIndexByUUID(m||''))&&l.trigger('mouseLeaveElement',{uuid:m,index:g,element:a.elements[g]}),this.temp.set('hoverUUID',null)}l.has('mouseOverScreen')&&l.trigger('mouseOverScreen',t)},t.prototype._handleLeave=function(){var t=this._opts.coreEvent;t.has('mouseLeaveScreen')&&t.trigger('mouseLeaveScreen',void 0)},t}();function Sn(t){t.setFillStyle('#000000'),t.setStrokeStyle('#000000'),t.setLineDash([]),t.setGlobalAlpha(1),t.setShadowColor('#00000000'),t.setShadowOffsetX(0),t.setShadowOffsetY(0),t.setShadowBlur(0)}var xn=function(){function e(e,i,r){var s,l,a,c=this;this[n]=new ke,this[o]=new on,this[sn]={elements:[]},this[ln]=i,this[an]=function(e){var n=nt(Te);return e&&e.elementWrapper&&(n.elementWrapper=t(t({},n.elementWrapper),e.elementWrapper)),n}(r||{}),this[rn]=new J(e,t(t({},this[ln]),{canScroll:null===(s=null==r?void 0:r.scrollWrapper)||void 0===s?void 0:s.use,scrollConfig:{color:(null===(l=null==r?void 0:r.scrollWrapper)||void 0===l?void 0:l.color)||'#a0a0a0',lineWidth:(null===(a=null==r?void 0:r.scrollWrapper)||void 0===a?void 0:a.lineWidth)||12}})),this[cn]=new _e;var h=function(){var t=c[rn].getHelperContext(),e=c[gn].getHelperConfig();c[rn].clear();var n=c[ln],o=n.contextWidth,i=n.contextHeight,r=n.devicePixelRatio;t.clearRect(0,0,o*r,i*r),function(t,e){if(null==e?void 0:e.selectedElementWrapper){var n=e.selectedElementWrapper;Sn(t),Ae(t,n.translate,n.radian||0,(function(){t.beginPath(),t.setLineDash(n.lineDash),t.setLineWidth(n.lineWidth),t.setStrokeStyle(n.color),t.moveTo(n.controllers.topLeft.x,n.controllers.topLeft.y),t.lineTo(n.controllers.topRight.x,n.controllers.topRight.y),t.lineTo(n.controllers.bottomRight.x,n.controllers.bottomRight.y),t.lineTo(n.controllers.bottomLeft.x,n.controllers.bottomLeft.y),t.lineTo(n.controllers.topLeft.x,n.controllers.topLeft.y-n.lineWidth/2),t.stroke(),t.closePath(),!0!==n.lock?(!0!==n.controllers.rotate.invisible&&(t.beginPath(),t.moveTo(n.controllers.top.x,n.controllers.top.y),t.lineTo(n.controllers.rotate.x,n.controllers.rotate.y+n.controllerSize),t.stroke(),t.closePath(),t.beginPath(),t.setLineDash([]),t.setLineWidth(n.controllerSize/2),t.arc(n.controllers.rotate.x,n.controllers.rotate.y,.8*n.controllerSize,Math.PI/6,2*Math.PI),t.stroke(),t.closePath()),t.setFillStyle(n.color),[n.controllers.topLeft,n.controllers.top,n.controllers.topRight,n.controllers.right,n.controllers.bottomRight,n.controllers.bottom,n.controllers.bottomLeft,n.controllers.left].forEach((function(e){!0!==e.invisible&&(t.beginPath(),t.arc(e.x,e.y,n.controllerSize,0,2*Math.PI),t.fill(),t.closePath())}))):(Sn(t),t.setStrokeStyle(n.color),[n.controllers.topLeft,n.controllers.top,n.controllers.topRight,n.controllers.right,n.controllers.bottomRight,n.controllers.bottom,n.controllers.bottomLeft,n.controllers.left].forEach((function(e){t.beginPath(),t.moveTo(e.x-n.controllerSize/2,e.y-n.controllerSize/2),t.lineTo(e.x+n.controllerSize/2,e.y+n.controllerSize/2),t.stroke(),t.closePath(),t.beginPath(),t.moveTo(e.x+n.controllerSize/2,e.y-n.controllerSize/2),t.lineTo(e.x-n.controllerSize/2,e.y+n.controllerSize/2),t.stroke(),t.closePath()})))}))}}(t,e),function(t,e){if(null==e?void 0:e.selectedAreaWrapper){var n=e.selectedAreaWrapper;n&&n.w>0&&n.h>0&&(Sn(t),t.setGlobalAlpha(.3),t.setFillStyle(n.color),t.fillRect(n.x,n.y,n.w,n.h),Sn(t),t.beginPath(),t.setLineDash(n.lineDash),t.setLineWidth(n.lineWidth),t.setStrokeStyle(n.color),t.moveTo(n.x,n.y),t.lineTo(n.x+n.w,n.y),t.lineTo(n.x+n.w,n.y+n.h),t.lineTo(n.x,n.y+n.h),t.lineTo(n.x,n.y),t.stroke(),t.closePath())}}(t,e),function(t,e){if(Array.isArray(null==e?void 0:e.selectedElementListWrappers)){var n=e.selectedElementListWrappers;null==n||n.forEach((function(e){Sn(t),Ae(t,e.translate,e.radian||0,(function(){Sn(t),t.setGlobalAlpha(.05),t.setFillStyle(e.color),t.fillRect(e.controllers.topLeft.x,e.controllers.topLeft.y,e.controllers.bottomRight.x-e.controllers.topLeft.x,e.controllers.bottomRight.y-e.controllers.topLeft.y),Sn(t),t.beginPath(),t.setLineDash(e.lineDash),t.setLineWidth(e.lineWidth),t.setStrokeStyle(e.color),t.moveTo(e.controllers.topLeft.x,e.controllers.topLeft.y),t.lineTo(e.controllers.topRight.x,e.controllers.topRight.y),t.lineTo(e.controllers.bottomRight.x,e.controllers.bottomRight.y),t.lineTo(e.controllers.bottomLeft.x,e.controllers.bottomLeft.y),t.lineTo(e.controllers.topLeft.x,e.controllers.topLeft.y-e.lineWidth/2),t.stroke(),t.closePath(),!0===e.lock&&(Sn(t),t.setStrokeStyle(e.color),[e.controllers.topLeft,e.controllers.top,e.controllers.topRight,e.controllers.right,e.controllers.bottomRight,e.controllers.bottom,e.controllers.bottomLeft,e.controllers.left].forEach((function(n){t.beginPath(),t.moveTo(n.x-e.controllerSize/2,n.y-e.controllerSize/2),t.lineTo(n.x+e.controllerSize/2,n.y+e.controllerSize/2),t.stroke(),t.closePath(),t.beginPath(),t.moveTo(n.x+e.controllerSize/2,n.y-e.controllerSize/2),t.lineTo(n.x-e.controllerSize/2,n.y+e.controllerSize/2),t.stroke(),t.closePath()})))}))}))}}(t,e),c[rn].draw()};this[cn].on('drawFrame',(function(t){h()})),this[cn].on('drawFrameComplete',(function(t){h()})),this[hn]=new He(this[rn].getContext()),this[gn]=new _n({coreEvent:this[dn],board:this[rn],element:this[hn],config:this[an],drawFeekback:this[fn].bind(this),getDataFeekback:function(){return c[sn]},selectElementByIndex:this.selectElementByIndex.bind(this),emitChangeScreen:this[pn].bind(this),emitChangeData:this[vn].bind(this)}),this[gn].init(),this[cn].on('drawFrame',(function(){c[dn].trigger('drawFrame',void 0)})),this[cn].on('drawFrameComplete',(function(){c[dn].trigger('drawFrameComplete',void 0)})),this[un].set('hasInited',!0)}var n,o;return e.prototype[(n=dn,o=un,fn)]=function(t){this[gn].updateHelperConfig({width:this[ln].width,height:this[ln].height,devicePixelRatio:this[ln].devicePixelRatio}),this[cn].thaw(),this[cn].render(this[rn].getContext(),this[sn],{changeResourceUUIDs:(null==t?void 0:t.resourceChangeUUIDs)||[]})},e.prototype.getElement=function(t){return function(t,e){var n=null,o=t[gn].helper.getElementIndexByUUID(e);return null!==o&&t[sn].elements[o]&&(n=nt(t[sn].elements[o])),n}(this,t)},e.prototype.getElementByIndex=function(t){return function(t,e){var n=null;return e>=0&&t[sn].elements[e]&&(n=nt(t[sn].elements[e])),n}(this,t)},e.prototype.selectElementByIndex=function(t,e){return function(t,e,n){if(t[sn].elements[e]){var o=t[sn].elements[e].uuid;!0===(null==n?void 0:n.useMode)?t[gn].temp.set('mode',en.SELECT_ELEMENT):t[gn].temp.set('mode',en.NULL),'string'==typeof o&&(t[gn].temp.set('selectedUUID',o),t[gn].temp.set('selectedUUIDList',[])),t[fn]()}}(this,t,e)},e.prototype.selectElement=function(t,e){return function(t,e,n){var o=t[gn].helper.getElementIndexByUUID(e);'number'==typeof o&&o>=0&&t.selectElementByIndex(o,n)}(this,t,e)},e.prototype.moveUpElement=function(t){return function(t,e){var n=t[gn].helper.getElementIndexByUUID(e);if('number'==typeof n&&n>=0&&n<t[sn].elements.length-1){var o=t[sn].elements[n];t[sn].elements[n]=t[sn].elements[n+1],t[sn].elements[n+1]=o}t[vn](),t[fn]()}(this,t)},e.prototype.moveDownElement=function(t){return function(t,e){var n=t[gn].helper.getElementIndexByUUID(e);if('number'==typeof n&&n>0&&n<t[sn].elements.length){var o=t[sn].elements[n];t[sn].elements[n]=t[sn].elements[n-1],t[sn].elements[n-1]=o}t[vn](),t[fn]()}(this,t)},e.prototype.updateElement=function(t){return function(t,e){for(var n,o=nt(e),i=t[sn],r=[],s=0;s<i.elements.length;s++)if(o.uuid===(null===(n=i.elements[s])||void 0===n?void 0:n.uuid)){var l=Oe(i.elements[s],o);'string'==typeof l&&r.push(l),i.elements[s]=o;break}t[vn](),t[fn]({resourceChangeUUIDs:r})}(this,t)},e.prototype.addElement=function(t){return function(t,e){var n=nt(e);return n.uuid=et(),t[sn].elements.push(n),t[vn](),t[fn](),n.uuid}(this,t)},e.prototype.deleteElement=function(t){return function(t,e){var n=t[hn].getElementIndex(t[sn],e);n>=0&&(t[sn].elements.splice(n,1),t[vn](),t[fn]())}(this,t)},e.prototype.insertElementBefore=function(t,e){return function(t,e,n){var o=t[gn].helper.getElementIndexByUUID(n);return null!==o?t.insertElementBeforeIndex(e,o):null}(this,t,e)},e.prototype.insertElementBeforeIndex=function(t,e){return function(t,e,n){var o=nt(e);return o.uuid=et(),n>=0?(t[sn].elements.splice(n,0,o),t[vn](),t[fn](),o.uuid):null}(this,t,e)},e.prototype.getSelectedElements=function(){return e=[],n=[],'string'==typeof(o=(t=this)[gn].temp.get('selectedUUID'))&&o?n.push(o):n=t[gn].temp.get('selectedUUIDList'),n.forEach((function(n){var o,i=t[gn].helper.getElementIndexByUUID(n);if(null!==i&&i>=0){var r=null===(o=t[sn])||void 0===o?void 0:o.elements[i];r&&e.push(r)}})),nt(e);var t,e,n,o},e.prototype.insertElementAfter=function(t,e){return function(t,e,n){var o=t[gn].helper.getElementIndexByUUID(n);return null!==o?t.insertElementAfterIndex(e,o):null}(this,t,e)},e.prototype.insertElementAfterIndex=function(t,e){return function(t,e,n){var o=nt(e);return o.uuid=et(),n>=0?(t[sn].elements.splice(n+1,0,o),t[vn](),t[fn](),o.uuid):null}(this,t,e)},e.prototype.resetSize=function(e){this[ln]=t(t({},this[ln]),e),this[rn].resetSize(e),this[fn]()},e.prototype.scale=function(t){var e=this[rn].scale(t);return this[fn](),this[pn](),e},e.prototype.scrollLeft=function(t){var e=this[rn].scrollX(0-t);return this[fn](),this[pn](),e},e.prototype.scrollTop=function(t){var e=this[rn].scrollY(0-t);return this[fn](),this[pn](),e},e.prototype.getScreenTransform=function(){var t=this[rn].getTransform();return{scale:t.scale,scrollTop:Math.max(0,0-t.scrollY),scrollLeft:Math.max(0,0-t.scrollX)}},e.prototype.getData=function(){return nt(this[sn])},e.prototype.setData=function(t,e){var n=function(t,e){var n,o=[],i=Ue(t),r=Ue(e);for(var s in r)if(!0===['image','svg','html'].includes(null===(n=r[s])||void 0===n?void 0:n.type))if(i[s]){var l=!1;switch(i[s].type){case'image':l=Me(i[s],r[s]);break;case'svg':l=Ie(i[s],r[s]);break;case'html':l=We(i[s],r[s])}!0===l&&o.push(s)}else o.push(s);return o}(this[sn],t);this[sn]=this[hn].initData(nt(Ke(t))),e&&!0===e.triggerChangeEvent&&this[vn](),this[fn]({resourceChangeUUIDs:n})},e.prototype.clearOperation=function(){this[un].clear(),this[fn]()},e.prototype.on=function(t,e){this[dn].on(t,e)},e.prototype.off=function(t,e){this[dn].off(t,e)},e.prototype.pointScreenToContext=function(t){return this[rn].pointScreenToContext(t)},e.prototype.pointContextToScreen=function(t){return this[rn].pointContextToScreen(t)},e.prototype.__getBoardContext=function(){return this[rn].getContext()},e.prototype.__getDisplayContext2D=function(){return this[rn].getDisplayContext2D()},e.prototype.__getOriginContext2D=function(){return this[rn].getOriginContext2D()},e.prototype[pn]=function(){this[dn].has('changeScreen')&&this[dn].trigger('changeScreen',t({},this.getScreenTransform()))},e.prototype[vn]=function(){this[dn].has('changeData')&&this[dn].trigger('changeData',nt(this[sn]))},e.is=Ee,e.check=ze,e}();return Object.freeze({__proto__:null,Core:xn})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idraw/core",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"author": "chenshenhai",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@idraw/types": "^0.3.0-alpha.
|
|
29
|
+
"@idraw/types": "^0.3.0-alpha.4"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@idraw/board": "^0.3.0-alpha.
|
|
33
|
-
"@idraw/renderer": "^0.3.0-alpha.
|
|
34
|
-
"@idraw/util": "^0.3.0-alpha.
|
|
32
|
+
"@idraw/board": "^0.3.0-alpha.4",
|
|
33
|
+
"@idraw/renderer": "^0.3.0-alpha.4",
|
|
34
|
+
"@idraw/util": "^0.3.0-alpha.4"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "eda72814239696a852bb4099e9297631824eaf48"
|
|
40
40
|
}
|