New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@idraw/renderer

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idraw/renderer - npm Package Compare versions

Comparing version 0.4.0-beta.10 to 0.4.0-beta.11

2

dist/esm/draw/html.js

@@ -8,3 +8,3 @@ import { rotateElement } from '@idraw/util';

rotateElement(ctx, { x, y, w, h, angle }, () => {
if (!content) {
if (!content && !opts.loader.isDestroyed()) {
opts.loader.load(elem, opts.elementAssets || {});

@@ -11,0 +11,0 @@ }

@@ -20,3 +20,3 @@ import { rotateElement, calcViewBoxSize } from '@idraw/util';

renderContent: () => {
if (!content) {
if (!content && !opts.loader.isDestroyed()) {
opts.loader.load(elem, opts.elementAssets || {});

@@ -23,0 +23,0 @@ }

@@ -8,3 +8,3 @@ import { rotateElement } from '@idraw/util';

rotateElement(ctx, { x, y, w, h, angle }, () => {
if (!content) {
if (!content && !opts.loader.isDestroyed()) {
opts.loader.load(elem, opts.elementAssets || {});

@@ -11,0 +11,0 @@ }

@@ -8,2 +8,3 @@ import { EventEmitter } from '@idraw/util';

constructor(opts: RendererOptions);
isDestroyed(): boolean;
destroy(): void;

@@ -10,0 +11,0 @@ updateOptions(opts: RendererOptions): void;

@@ -12,3 +12,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

};
var _Renderer_instances, _Renderer_opts, _Renderer_loader, _Renderer_init;
var _Renderer_instances, _Renderer_opts, _Renderer_loader, _Renderer_hasDestroyed, _Renderer_init;
import { EventEmitter } from '@idraw/util';

@@ -23,9 +23,15 @@ import { drawElementList, drawUnderlay } from './draw/index';

_Renderer_loader.set(this, new Loader());
_Renderer_hasDestroyed.set(this, false);
__classPrivateFieldSet(this, _Renderer_opts, opts, "f");
__classPrivateFieldGet(this, _Renderer_instances, "m", _Renderer_init).call(this);
}
isDestroyed() {
return __classPrivateFieldGet(this, _Renderer_hasDestroyed, "f");
}
destroy() {
this.clear();
__classPrivateFieldSet(this, _Renderer_opts, null, "f");
__classPrivateFieldGet(this, _Renderer_loader, "f").destroy();
__classPrivateFieldSet(this, _Renderer_loader, null, "f");
__classPrivateFieldSet(this, _Renderer_hasDestroyed, true, "f");
}

@@ -90,3 +96,3 @@ updateOptions(opts) {

}
_Renderer_opts = new WeakMap(), _Renderer_loader = new WeakMap(), _Renderer_instances = new WeakSet(), _Renderer_init = function _Renderer_init() {
_Renderer_opts = new WeakMap(), _Renderer_loader = new WeakMap(), _Renderer_hasDestroyed = new WeakMap(), _Renderer_instances = new WeakSet(), _Renderer_init = function _Renderer_init() {
const loader = __classPrivateFieldGet(this, _Renderer_loader, "f");

@@ -93,0 +99,0 @@ loader.on('load', (e) => {

@@ -6,2 +6,3 @@ import type { RendererLoader, LoaderEventMap, LoadContent, LoadItemMap, LoadElementType, Element, ElementAssets } from '@idraw/types';

constructor();
isDestroyed(): boolean;
destroy(): void;

@@ -8,0 +9,0 @@ load(element: Element<LoadElementType>, assets: ElementAssets): void;

@@ -21,3 +21,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
var _Loader_instances, _Loader_loadFuncMap, _Loader_currentLoadItemMap, _Loader_storageLoadItemMap, _Loader_registerLoadFunc, _Loader_getLoadElementSource, _Loader_createLoadItem, _Loader_emitLoad, _Loader_emitError, _Loader_loadResource, _Loader_isExistingErrorStorage;
var _Loader_instances, _Loader_loadFuncMap, _Loader_currentLoadItemMap, _Loader_storageLoadItemMap, _Loader_hasDestroyed, _Loader_registerLoadFunc, _Loader_getLoadElementSource, _Loader_createLoadItem, _Loader_emitLoad, _Loader_emitError, _Loader_loadResource, _Loader_isExistingErrorStorage;
import { loadImage, loadHTML, loadSVG, EventEmitter, createAssetId, isAssetId, createUUID } from '@idraw/util';

@@ -52,2 +52,3 @@ const supportElementTypes = ['image', 'svg', 'html'];

_Loader_storageLoadItemMap.set(this, {});
_Loader_hasDestroyed.set(this, false);
__classPrivateFieldGet(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, 'image', (elem, assets) => __awaiter(this, void 0, void 0, function* () {

@@ -87,3 +88,8 @@ var _a;

}
isDestroyed() {
return __classPrivateFieldGet(this, _Loader_hasDestroyed, "f");
}
destroy() {
__classPrivateFieldSet(this, _Loader_hasDestroyed, true, "f");
this.clear();
__classPrivateFieldSet(this, _Loader_loadFuncMap, null, "f");

@@ -94,2 +100,5 @@ __classPrivateFieldSet(this, _Loader_currentLoadItemMap, null, "f");

load(element, assets) {
if (__classPrivateFieldGet(this, _Loader_hasDestroyed, "f") === true) {
return;
}
if (__classPrivateFieldGet(this, _Loader_instances, "m", _Loader_isExistingErrorStorage).call(this, element)) {

@@ -114,3 +123,3 @@ return;

}
_Loader_loadFuncMap = new WeakMap(), _Loader_currentLoadItemMap = new WeakMap(), _Loader_storageLoadItemMap = new WeakMap(), _Loader_instances = new WeakSet(), _Loader_registerLoadFunc = function _Loader_registerLoadFunc(type, func) {
_Loader_loadFuncMap = new WeakMap(), _Loader_currentLoadItemMap = new WeakMap(), _Loader_storageLoadItemMap = new WeakMap(), _Loader_hasDestroyed = new WeakMap(), _Loader_instances = new WeakSet(), _Loader_registerLoadFunc = function _Loader_registerLoadFunc(type, func) {
__classPrivateFieldGet(this, _Loader_loadFuncMap, "f")[type] = func;

@@ -143,4 +152,10 @@ }, _Loader_getLoadElementSource = function _Loader_getLoadElementSource(element) {

const storageItem = __classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")[assetId];
if (storageItem) {
if (storageItem.startTime < item.startTime) {
if (!__classPrivateFieldGet(this, _Loader_hasDestroyed, "f")) {
if (storageItem) {
if (storageItem.startTime < item.startTime) {
__classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
this.trigger('load', Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
}
}
else {
__classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")[assetId] = item;

@@ -150,6 +165,2 @@ this.trigger('load', Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));

}
else {
__classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
this.trigger('load', Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
}
}, _Loader_emitError = function _Loader_emitError(item) {

@@ -159,4 +170,10 @@ var _a;

const storageItem = (_a = __classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId];
if (storageItem) {
if (storageItem.startTime < item.startTime) {
if (!__classPrivateFieldGet(this, _Loader_hasDestroyed, "f")) {
if (storageItem) {
if (storageItem.startTime < item.startTime) {
__classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
this.trigger('error', Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
}
}
else {
__classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")[assetId] = item;

@@ -166,6 +183,2 @@ this.trigger('error', Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));

}
else {
__classPrivateFieldGet(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
this.trigger('error', Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
}
}, _Loader_loadResource = function _Loader_loadResource(element, assets) {

@@ -176,10 +189,12 @@ const item = __classPrivateFieldGet(this, _Loader_instances, "m", _Loader_createLoadItem).call(this, element);

const loadFunc = __classPrivateFieldGet(this, _Loader_loadFuncMap, "f")[element.type];
if (typeof loadFunc === 'function') {
if (typeof loadFunc === 'function' && !__classPrivateFieldGet(this, _Loader_hasDestroyed, "f")) {
item.startTime = Date.now();
loadFunc(element, assets)
.then((result) => {
item.content = result.content;
item.endTime = Date.now();
item.status = 'load';
__classPrivateFieldGet(this, _Loader_instances, "m", _Loader_emitLoad).call(this, item);
if (!__classPrivateFieldGet(this, _Loader_hasDestroyed, "f")) {
item.content = result.content;
item.endTime = Date.now();
item.status = 'load';
__classPrivateFieldGet(this, _Loader_instances, "m", _Loader_emitLoad).call(this, item);
}
})

@@ -186,0 +201,0 @@ .catch((err) => {

@@ -25,3 +25,3 @@ var iDrawRenderer = function(exports) {

var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _registerLoadFunc, registerLoadFunc_fn, _getLoadElementSource, getLoadElementSource_fn, _createLoadItem, createLoadItem_fn, _emitLoad, emitLoad_fn, _emitError, emitError_fn, _loadResource, loadResource_fn, _isExistingErrorStorage, isExistingErrorStorage_fn, _opts, _loader, _init, init_fn;
var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _hasDestroyed, _registerLoadFunc, registerLoadFunc_fn, _getLoadElementSource, getLoadElementSource_fn, _createLoadItem, createLoadItem_fn, _emitLoad, emitLoad_fn, _emitError, emitError_fn, _loadResource, loadResource_fn, _isExistingErrorStorage, isExistingErrorStorage_fn, _opts, _loader, _hasDestroyed2, _init, init_fn;
function isColorStr(color2) {

@@ -403,2 +403,5 @@ return typeof color2 === "string" && (/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));

destroy() {
this.clear();
}
clear() {
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").clear();

@@ -938,3 +941,3 @@ }

renderContent: () => {
if (!content) {
if (!content && !opts.loader.isDestroyed()) {
opts.loader.load(elem, opts.elementAssets || {});

@@ -974,3 +977,3 @@ }

rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
if (!content) {
if (!content && !opts.loader.isDestroyed()) {
opts.loader.load(elem, opts.elementAssets || {});

@@ -990,3 +993,3 @@ }

rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
if (!content) {
if (!content && !opts.loader.isDestroyed()) {
opts.loader.load(elem, opts.elementAssets || {});

@@ -1376,2 +1379,3 @@ }

__privateAdd(this, _storageLoadItemMap, {});
__privateAdd(this, _hasDestroyed, false);
__privateMethod(this, _registerLoadFunc, registerLoadFunc_fn).call(this, "image", async (elem, assets) => {

@@ -1411,3 +1415,8 @@ var _a;

}
isDestroyed() {
return __privateGet(this, _hasDestroyed);
}
destroy() {
__privateSet(this, _hasDestroyed, true);
this.clear();
__privateSet(this, _loadFuncMap, null);

@@ -1418,2 +1427,5 @@ __privateSet(this, _currentLoadItemMap, null);

load(element, assets) {
if (__privateGet(this, _hasDestroyed) === true) {
return;
}
if (__privateMethod(this, _isExistingErrorStorage, isExistingErrorStorage_fn).call(this, element)) {

@@ -1441,2 +1453,3 @@ return;

_storageLoadItemMap = new WeakMap();
_hasDestroyed = new WeakMap();
_registerLoadFunc = new WeakSet();

@@ -1475,10 +1488,12 @@ registerLoadFunc_fn = function(type, func) {

const storageItem = __privateGet(this, _storageLoadItemMap)[assetId];
if (storageItem) {
if (storageItem.startTime < item.startTime) {
if (!__privateGet(this, _hasDestroyed)) {
if (storageItem) {
if (storageItem.startTime < item.startTime) {
__privateGet(this, _storageLoadItemMap)[assetId] = item;
this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
}
} else {
__privateGet(this, _storageLoadItemMap)[assetId] = item;
this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
}
} else {
__privateGet(this, _storageLoadItemMap)[assetId] = item;
this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
}

@@ -1491,10 +1506,12 @@ };

const storageItem = (_a = __privateGet(this, _storageLoadItemMap)) == null ? void 0 : _a[assetId];
if (storageItem) {
if (storageItem.startTime < item.startTime) {
if (!__privateGet(this, _hasDestroyed)) {
if (storageItem) {
if (storageItem.startTime < item.startTime) {
__privateGet(this, _storageLoadItemMap)[assetId] = item;
this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
}
} else {
__privateGet(this, _storageLoadItemMap)[assetId] = item;
this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
}
} else {
__privateGet(this, _storageLoadItemMap)[assetId] = item;
this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
}

@@ -1508,9 +1525,11 @@ };

const loadFunc = __privateGet(this, _loadFuncMap)[element.type];
if (typeof loadFunc === "function") {
if (typeof loadFunc === "function" && !__privateGet(this, _hasDestroyed)) {
item.startTime = Date.now();
loadFunc(element, assets).then((result) => {
item.content = result.content;
item.endTime = Date.now();
item.status = "load";
__privateMethod(this, _emitLoad, emitLoad_fn).call(this, item);
if (!__privateGet(this, _hasDestroyed)) {
item.content = result.content;
item.endTime = Date.now();
item.status = "load";
__privateMethod(this, _emitLoad, emitLoad_fn).call(this, item);
}
}).catch((err) => {

@@ -1541,9 +1560,15 @@ console.warn(`Load element source "${item.source}" fail`, err, element);

__privateAdd(this, _loader, new Loader());
__privateAdd(this, _hasDestroyed2, false);
__privateSet(this, _opts, opts);
__privateMethod(this, _init, init_fn).call(this);
}
isDestroyed() {
return __privateGet(this, _hasDestroyed2);
}
destroy() {
this.clear();
__privateSet(this, _opts, null);
__privateGet(this, _loader).destroy();
__privateSet(this, _loader, null);
__privateSet(this, _hasDestroyed2, true);
}

@@ -1619,2 +1644,3 @@ updateOptions(opts) {

_loader = new WeakMap();
_hasDestroyed2 = new WeakMap();
_init = new WeakSet();

@@ -1621,0 +1647,0 @@ init_fn = function() {

@@ -1,1 +0,1 @@

var iDrawRenderer=function(e){"use strict";var t,n,i,o,a,r,l,s,c,d,h,f,u,w,g,v,y,p,m,S,x,b=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},I=(e,t,n)=>(b(e,t,"read from private field"),n?n.call(e):t.get(e)),z=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},T=(e,t,n,i)=>(b(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),A=(e,t,n)=>(b(e,t,"access private method"),n);function C(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function E(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o}function k(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function O(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function W(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${O(t.toString(16).padEnd(4,i))}${O(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${O(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${O(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${O(o.padEnd(4,i).padEnd(4,o))}`}function P(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const $={type(e,t){const n=P(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===P(e),json:e=>"Object"===P(e),function:e=>"Function"===P(e),asyncFunction:e=>"AsyncFunction"===P(e),string:e=>"String"===P(e),number:e=>"Number"===P(e),undefined:e=>"Undefined"===P(e),null:e=>"Null"===P(e),promise:e=>"Promise"===P(e)};var M=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function l(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((i=i.apply(e,t||[])).next())}))};const{Image:R}=window;function L(e){return new Promise(((t,n)=>{const i=new R;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function D(e){return M(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return yield L(t)}))}function B(e,t){return M(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const n=yield function(e,t){const{width:n,height:i}=t;return new Promise(((t,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},r.onerror=function(e){o(e)}}))}(e,t);return yield L(n)}))}function F(e){return"number"==typeof e&&(e>0||e<=0)}function H(e){return"number"==typeof e&&e>=0}function X(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function Y(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const j={x:function(e){return F(e)},y:function(e){return F(e)},w:H,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:F,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return H(e)},borderRadius:function(e){return F(e)&&e>=0},color:function(e){return C(e)},imageSrc:function(e){return Y(e)||X(e)},imageURL:X,imageBase64:Y,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return F(e)&&e>0},lineHeight:function(e){return F(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return F(e)&&e>0}};var U,q=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};class G{constructor(){U.set(this,void 0),function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(e,n):o?o.value=n:t.set(e,n)}(this,U,new Map,"f")}on(e,t){if(q(this,U,"f").has(e)){const n=q(this,U,"f").get(e)||[];null==n||n.push(t),q(this,U,"f").set(e,n)}else q(this,U,"f").set(e,[t])}off(e,t){if(q(this,U,"f").has(e)){const n=q(this,U,"f").get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}q(this,U,"f").set(e,n||[])}}trigger(e,t){const n=q(this,U,"f").get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(q(this,U,"f").has(e)){const t=q(this,U,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){q(this,U,"f").clear()}}function N(e,t,n,i){const o=function(e){return e/180*Math.PI}(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function V(e,t,n){const i={x:(o=t).x+o.w/2,y:o.y+o.h/2};var o;N(e,t.angle||0,i,(()=>{n(e)}))}function J(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}U=new WeakMap;const K={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function Q(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:a=K.boxSizing,borderWidth:r}=e.detail;Array.isArray(r)&&(o=0);let{x:l,y:s,w:c,h:d}=e,h=[0,0,0,0];if("number"==typeof o){const e=o*i;h=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let f=0;return"number"==typeof r&&(f=(r||0)*i),"border-box"===a?(l=e.x+f/2,s=e.y+f/2,c=e.w-f,d=e.h-f):"content-box"===a?(l=e.x-f/2,s=e.y-f/2,c=e.w+f,d=e.h+f):(l=e.x,s=e.y,c=e.w,d=e.h),c=Math.max(c,1),d=Math.max(d,1),h=h.map((e=>Math.min(e,c/2,d/2))),{x:l,y:s,w:c,h:d,radiusList:h}}function Z(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s},d={x:r+i.x*s,y:l+i.y*s},h=e.createLinearGradient(c.x,c.y,d.x,d.y);return o.forEach((e=>{h.addColorStop(e.offset,E(e.color,a))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},d={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},h=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return o.forEach((e=>{h.addColorStop(e.offset,E(e.color,a))})),h}return"#000000"}const _={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function ee(e){var t,n,i,o;let a=1;return void 0!==(null==(t=null==e?void 0:e.detail)?void 0:t.opacity)&&(null==(n=null==e?void 0:e.detail)?void 0:n.opacity)>=0&&(null==(i=null==e?void 0:e.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==e?void 0:e.detail)?void 0:o.opacity),a}function te(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=ee(a)*c;!function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r}=n,l=r.devicePixelRatio,{clipPath:s}=(null==o?void 0:o.detail)||{};if(s&&a&&s.commands){const{x:n,y:o,w:r,h:c}=a,{originW:d,originH:h,originX:f,originY:u}=s,w=r/d,g=c/h,v=n-f*w,y=o-u*g;e.save(),e.translate(v,y),e.scale(l*w,l*g);const p=J(s.commands||[]),m=new Path2D(p);e.clip(m),e.translate(0-v,0-y),e.setTransform(1,0,0,1,0,0),V(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{e.globalAlpha=d,function(e,t,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:f}=Q(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(n+f[0],c),e.arcTo(n+d,c,n+d,c+h,f[1]),e.arcTo(n+d,c+h,n,c+h,f[2]),e.arcTo(n,c+h,n,c,f[3]),e.arcTo(n,c,n+d,c,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes($.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const i=Z(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=Z(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=i,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const i=s[t];"translate"===i.method?e.translate(i.args[0]+n,i.args[1]+c):"rotate"===i.method?e.rotate(...i.args):"scale"===i.method&&e.scale(...i.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),function(e,t,n){if(0===t.detail.borderWidth)return;if(!C(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=_.borderColor;!0===C(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=_.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1);d*=o;let h=[0,0,0,0];if("number"==typeof l){const e=l*o;h=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(h=[l[0]*o,l[1]*o,l[2]*o,l[3]*o]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*o))));let u=0,w=0,g=0,v=0;Array.isArray(r)&&(u=(r[0]||0)*o,w=(r[1]||0)*o,g=(r[2]||0)*o,v=(r[3]||0)*o);if(v||w||u||g){e.lineCap="butt";let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n+=v/2,i+=u/2,o=o-v/2-w/2,a=a-u/2-g/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+w/2,a=a+u/2+g/2):(n=t.x,i=t.y,o=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(n-v/2,i),e.lineTo(n+o+w/2,i),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+g/2),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n-v/2,i+a),e.lineTo(n+o+w/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+g/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n=t.x+d/2,i=t.y+d/2,o=t.w-d,a=t.h-d):"content-box"===c?(n=t.x-d/2,i=t.y-d/2,o=t.w+d,a=t.h+d):(n=t.x,i=t.y,o=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),h=h.map((e=>Math.min(e,o/2,a/2))),e.setLineDash(f),e.lineWidth=d,e.beginPath(),e.moveTo(n+h[0],i),e.arcTo(n+o,i,n+o,i+a,h[1]),e.arcTo(n+o,i+a,n,i+a,h[2]),e.arcTo(n,i+a,n,i,h[3]),e.arcTo(n,i,n+o,i,h[0]),e.closePath(),e.stroke()}e.setLineDash([])}(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c}})}function ne(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;j.number(c)?(e.save(),e.shadowColor=r||_.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):a()}function ie(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};V(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{ne(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{te(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}))}const oe={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function ae(e,t,n){var i;if(!0===(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))return;const{w:o,h:a}=t,{scale:r}=n.viewScaleInfo;if(!(r<1&&(o*r<1||a*r<1)||0===n.parentOpacity))try{switch(t.type){case"rect":ie(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{background:a="#000000",borderColor:r="#000000",boxSizing:l,borderWidth:s=0}=i;let c=0;"number"==typeof s&&s>0?c=s:Array.isArray(s)&&"number"==typeof s[0]&&s[0]>0&&(c=s[0]);const{calculator:d,viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u}=n,{x:w,y:g,w:v,h:y}=(null==d?void 0:d.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},h,f))||t,p={...t,x:w,y:g,w:v,h:y,angle:o};V(e,{x:w,y:g,w:v,h:y,angle:o},(()=>{ne(e,p,{viewScaleInfo:h,viewSizeInfo:f,renderContent:()=>{let t=v/2,n=y/2;const i=w+t,o=g+n;if(c>0&&("border-box"===l?(t-=c,n-=c):"center-line"===l?(t-=c/2,n-=c/2):(t-=c,n-=c)),t>=0&&n>=0){const l=ee(p)*u;if(e.globalAlpha=l,"number"==typeof s&&s>0){const a=s/2+t,l=s/2+n;e.beginPath(),e.strokeStyle=r,e.lineWidth=s,e.circle(i,o,a,l,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const c=Z(e,a,{viewElementSize:{x:w,y:g,w:v,h:y},viewScaleInfo:h,opacity:e.globalAlpha});e.fillStyle=c,e.circle(i,o,t,n,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=u}}})}))}(e,t,n);break;case"text":!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};V(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{te(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const n={...oe,...t.detail},i=(n.fontSize||oe.fontSize)*o.scale,a=n.lineHeight?n.lineHeight*o.scale:i;e.fillStyle=t.detail.color||oe.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:i,fontFamily:n.fontFamily});const r=n.text.replace(/\r\n/gi,"\n"),h=a,f=r.split("\n"),u=[];let w=0;f.forEach(((t,n)=>{let i="";if(t.length>0){for(let o=0;o<t.length&&(e.measureText(i+(t[o]||"")).width<e.$doPixelRatio(c)?i+=t[o]||"":(u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),i=t[o]||"",w++),!((w+1)*h>d));o++)if(t.length-1===o&&(w+1)*h<d){u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),n<f.length-1&&w++;break}}else u.push({text:"",width:0})}));let g=0;u.length*h<d&&("top"===t.detail.verticalAlign?g=0:"bottom"===t.detail.verticalAlign?g+=d-u.length*h:g+=(d-u.length*h)/2);{const t=s+g;void 0!==n.textShadowColor&&C(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&j.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&j.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&j.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),u.forEach(((i,o)=>{let a=l;"center"===n.textAlign?a=l+(c-i.width)/2:"right"===n.textAlign&&(a=l+(c-i.width)),e.fillText(i.text,a,t+h*o)}))}}})}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t,u={...t,x:s,y:c,w:d,h:h,angle:f};V(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{ne(e,u,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{te(e,u,{originElem:t,calcElemSize:{x:s,y:c,w:d,h:h,angle:f},viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l,renderContent:()=>{if(i||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=ee(t)*l;const{x:n,y:o,w:s,h:c,radiusList:d}=Q(u,{viewScaleInfo:a,viewSizeInfo:r});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],o),e.arcTo(n+s,o,n+s,o+c,d[1]),e.arcTo(n+s,o+c,n,o+c,d[2]),e.arcTo(n,o+c,n,o,d[3]),e.arcTo(n,o,n+s,o,d[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(i,n,o,s,c),e.globalAlpha=l,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;V(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=ee(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;V(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=ee(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"path":!function(e,t,n){const{detail:i}=t,{originX:o,originY:a,originW:r,originH:l}=i,{calculator:s,viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h}=n,{x:f,y:u,w:w,h:g,angle:v}=(null==s?void 0:s.elementSize(t,c,d))||t,y=w/r,p=g/l,m=f-o*y,S=u-a*p,x=c.scale*d.devicePixelRatio,b={...t,x:f,y:u,w:w,h:g,angle:v};V(e,{x:f,y:u,w:w,h:g,angle:v},(()=>{te(e,b,{originElem:t,calcElemSize:{x:f,y:u,w:w,h:g,angle:v},viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h,renderContent:()=>{ne(e,b,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{e.save(),e.translate(m,S),e.scale(x*y/c.scale,x*p/c.scale);const t=J(i.commands||[]),n=new Path2D(t);i.fill&&(e.fillStyle=i.fill,e.fill(n)),i.stroke&&0!==i.strokeWidth&&(e.strokeStyle=i.stroke,e.lineWidth=(i.strokeWidth||1)/d.devicePixelRatio,e.lineCap=i.strokeLineCap||"square",e.stroke(n)),e.translate(-m,-S),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};V(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{e.globalAlpha=ee(t)*r,ne(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{te(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const{x:i,y:l,w:s,h:c,radiusList:d}=Q(f,{viewScaleInfo:o,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+d[0],l),e.arcTo(i+s,l,i+s,l+c,d[1]),e.arcTo(i+s,l+c,i,l+c,d[2]),e.arcTo(i,l+c,i,l,d[3]),e.arcTo(i,l,i+s,l,d[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:i}=n,o={x:i.x+t.x,y:i.y+t.y,w:t.w||i.w,h:t.h||i.h,angle:t.angle},{calculator:a}=n;for(let i=0;i<t.detail.children.length;i++){let l=t.detail.children[i];if(l={...l,x:o.x+l.x,y:o.y+l.y},!0===n.forceDrawAll||(null==a?void 0:a.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{ae(e,l,{...n,parentOpacity:r*ee(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=r}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}const re={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const le=["image","svg","html"],se=e=>{var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),"string"==typeof o&&o?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${o}`)?o:W(o):W(`${k()}-${e.uuid}-${k()}-${k()}`)};class ce extends G{constructor(){super(),z(this,o),z(this,r),z(this,s),z(this,d),z(this,f),z(this,w),z(this,v),z(this,t,{}),z(this,n,{}),z(this,i,{}),A(this,o,a).call(this,"image",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,o=await L(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),A(this,o,a).call(this,"html",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,o=await B(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),A(this,o,a).call(this,"svg",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,o=await D(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}destroy(){T(this,t,null),T(this,n,null),T(this,i,null)}load(e,t){A(this,v,y).call(this,e)||le.includes(e.type)&&A(this,w,g).call(this,e,t)}getContent(e){var t,n;const o=se(e);return(null==(n=null==(t=I(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return I(this,i)}setLoadItemMap(e){T(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakSet,a=function(e,n){I(this,t)[e]=n},r=new WeakSet,l=function(e){var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),o},s=new WeakSet,c=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:A(this,r,l).call(this,e)}},d=new WeakSet,h=function(e){const t=se(e.element),n=I(this,i)[t];n?n.startTime<e.startTime&&(I(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(I(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime}))},f=new WeakSet,u=function(e){var t;const n=se(e.element),o=null==(t=I(this,i))?void 0:t[n];o?o.startTime<e.startTime&&(I(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(I(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime}))},w=new WeakSet,g=function(e,i){const o=A(this,s,c).call(this,e),a=se(e);I(this,n)[a]=o;const r=I(this,t)[e.type];"function"==typeof r&&(o.startTime=Date.now(),r(e,i).then((e=>{o.content=e.content,o.endTime=Date.now(),o.status="load",A(this,d,h).call(this,o)})).catch((t=>{console.warn(`Load element source "${o.source}" fail`,t,e),o.endTime=Date.now(),o.status="error",o.error=t,A(this,f,u).call(this,o)})))},v=new WeakSet,y=function(e){var t;const i=se(e),o=null==(t=I(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==A(this,r,l).call(this,e))};return p=new WeakMap,m=new WeakMap,S=new WeakSet,x=function(){const e=I(this,m);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))},e.Renderer=class extends G{constructor(e){super(),z(this,S),z(this,p,void 0),z(this,m,new ce),T(this,p,e),A(this,S,x).call(this)}destroy(){T(this,p,null),I(this,m).destroy(),T(this,m,null)}updateOptions(e){T(this,p,e)}drawData(e,t){const n=I(this,m),{calculator:i}=I(this,p),o=I(this,p).viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);const a={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height};e.underlay&&function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"underlay",...t},{x:s,y:c,w:d,h:h}=(null==i?void 0:i.elementSize(l,o,a))||l,f={...l,x:s,y:c,w:d,h:h,angle:0};ne(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{te(e,f,{originElem:l,calcElemSize:{x:s,y:c,w:d,h:h,angle:0},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}(o,e.underlay,{loader:n,calculator:i,parentElementSize:a,parentOpacity:1,...t}),function(e,t,n){var i;const{elements:o=[]}=t,{parentOpacity:a}=n;for(let t=0;t<o.length;t++){const r=o[t],l={...r,detail:{...re,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{ae(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}(o,e,{loader:n,calculator:i,parentElementSize:a,elementAssets:e.assets,parentOpacity:1,...t})}scale(e){const{sharer:t}=I(this,p);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){I(this,m).setLoadItemMap(e)}getLoadItemMap(){return I(this,m).getLoadItemMap()}getLoader(){return I(this,m)}},e.drawRect=ie,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
var iDrawRenderer=function(e){"use strict";var t,n,i,o,a,r,l,s,c,d,h,f,u,w,g,v,y,p,m,S,x,b,I,z=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},T=(e,t,n)=>(z(e,t,"read from private field"),n?n.call(e):t.get(e)),A=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},C=(e,t,n,i)=>(z(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),E=(e,t,n)=>(z(e,t,"access private method"),n);function k(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function O(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o}function W(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function P(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function $(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${P(t.toString(16).padEnd(4,i))}${P(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${P(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${P(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${P(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${P(o.padEnd(4,i).padEnd(4,o))}`}function M(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const D={type(e,t){const n=M(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===M(e),json:e=>"Object"===M(e),function:e=>"Function"===M(e),asyncFunction:e=>"AsyncFunction"===M(e),string:e=>"String"===M(e),number:e=>"Number"===M(e),undefined:e=>"Undefined"===M(e),null:e=>"Null"===M(e),promise:e=>"Promise"===M(e)};var R=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function l(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((i=i.apply(e,t||[])).next())}))};const{Image:L}=window;function B(e){return new Promise(((t,n)=>{const i=new L;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function F(e){return R(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return yield B(t)}))}function H(e,t){return R(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const n=yield function(e,t){const{width:n,height:i}=t;return new Promise(((t,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},r.onerror=function(e){o(e)}}))}(e,t);return yield B(n)}))}function X(e){return"number"==typeof e&&(e>0||e<=0)}function Y(e){return"number"==typeof e&&e>=0}function j(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function U(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const q={x:function(e){return X(e)},y:function(e){return X(e)},w:Y,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:X,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return Y(e)},borderRadius:function(e){return X(e)&&e>=0},color:function(e){return k(e)},imageSrc:function(e){return U(e)||j(e)},imageURL:j,imageBase64:U,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return X(e)&&e>0},lineHeight:function(e){return X(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return X(e)&&e>0}};var G,N=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};class V{constructor(){G.set(this,void 0),function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(e,n):o?o.value=n:t.set(e,n)}(this,G,new Map,"f")}on(e,t){if(N(this,G,"f").has(e)){const n=N(this,G,"f").get(e)||[];null==n||n.push(t),N(this,G,"f").set(e,n)}else N(this,G,"f").set(e,[t])}off(e,t){if(N(this,G,"f").has(e)){const n=N(this,G,"f").get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}N(this,G,"f").set(e,n||[])}}trigger(e,t){const n=N(this,G,"f").get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(N(this,G,"f").has(e)){const t=N(this,G,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){N(this,G,"f").clear()}}function J(e,t,n,i){const o=function(e){return e/180*Math.PI}(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function K(e,t,n){const i={x:(o=t).x+o.w/2,y:o.y+o.h/2};var o;J(e,t.angle||0,i,(()=>{n(e)}))}function Q(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}G=new WeakMap;const Z={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function _(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:a=Z.boxSizing,borderWidth:r}=e.detail;Array.isArray(r)&&(o=0);let{x:l,y:s,w:c,h:d}=e,h=[0,0,0,0];if("number"==typeof o){const e=o*i;h=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let f=0;return"number"==typeof r&&(f=(r||0)*i),"border-box"===a?(l=e.x+f/2,s=e.y+f/2,c=e.w-f,d=e.h-f):"content-box"===a?(l=e.x-f/2,s=e.y-f/2,c=e.w+f,d=e.h+f):(l=e.x,s=e.y,c=e.w,d=e.h),c=Math.max(c,1),d=Math.max(d,1),h=h.map((e=>Math.min(e,c/2,d/2))),{x:l,y:s,w:c,h:d,radiusList:h}}function ee(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s},d={x:r+i.x*s,y:l+i.y*s},h=e.createLinearGradient(c.x,c.y,d.x,d.y);return o.forEach((e=>{h.addColorStop(e.offset,O(e.color,a))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},d={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},h=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return o.forEach((e=>{h.addColorStop(e.offset,O(e.color,a))})),h}return"#000000"}const te={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function ne(e){var t,n,i,o;let a=1;return void 0!==(null==(t=null==e?void 0:e.detail)?void 0:t.opacity)&&(null==(n=null==e?void 0:e.detail)?void 0:n.opacity)>=0&&(null==(i=null==e?void 0:e.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==e?void 0:e.detail)?void 0:o.opacity),a}function ie(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=ne(a)*c;!function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r}=n,l=r.devicePixelRatio,{clipPath:s}=(null==o?void 0:o.detail)||{};if(s&&a&&s.commands){const{x:n,y:o,w:r,h:c}=a,{originW:d,originH:h,originX:f,originY:u}=s,w=r/d,g=c/h,v=n-f*w,y=o-u*g;e.save(),e.translate(v,y),e.scale(l*w,l*g);const p=Q(s.commands||[]),m=new Path2D(p);e.clip(m),e.translate(0-v,0-y),e.setTransform(1,0,0,1,0,0),K(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{e.globalAlpha=d,function(e,t,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:f}=_(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(n+f[0],c),e.arcTo(n+d,c,n+d,c+h,f[1]),e.arcTo(n+d,c+h,n,c+h,f[2]),e.arcTo(n,c+h,n,c,f[3]),e.arcTo(n,c,n+d,c,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(D.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const i=ee(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=ee(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=i,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const i=s[t];"translate"===i.method?e.translate(i.args[0]+n,i.args[1]+c):"rotate"===i.method?e.rotate(...i.args):"scale"===i.method&&e.scale(...i.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),function(e,t,n){if(0===t.detail.borderWidth)return;if(!k(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=te.borderColor;!0===k(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=te.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1);d*=o;let h=[0,0,0,0];if("number"==typeof l){const e=l*o;h=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(h=[l[0]*o,l[1]*o,l[2]*o,l[3]*o]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*o))));let u=0,w=0,g=0,v=0;Array.isArray(r)&&(u=(r[0]||0)*o,w=(r[1]||0)*o,g=(r[2]||0)*o,v=(r[3]||0)*o);if(v||w||u||g){e.lineCap="butt";let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n+=v/2,i+=u/2,o=o-v/2-w/2,a=a-u/2-g/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+w/2,a=a+u/2+g/2):(n=t.x,i=t.y,o=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(n-v/2,i),e.lineTo(n+o+w/2,i),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+g/2),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n-v/2,i+a),e.lineTo(n+o+w/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+g/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n=t.x+d/2,i=t.y+d/2,o=t.w-d,a=t.h-d):"content-box"===c?(n=t.x-d/2,i=t.y-d/2,o=t.w+d,a=t.h+d):(n=t.x,i=t.y,o=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),h=h.map((e=>Math.min(e,o/2,a/2))),e.setLineDash(f),e.lineWidth=d,e.beginPath(),e.moveTo(n+h[0],i),e.arcTo(n+o,i,n+o,i+a,h[1]),e.arcTo(n+o,i+a,n,i+a,h[2]),e.arcTo(n,i+a,n,i,h[3]),e.arcTo(n,i,n+o,i,h[0]),e.closePath(),e.stroke()}e.setLineDash([])}(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c}})}function oe(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;q.number(c)?(e.save(),e.shadowColor=r||te.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):a()}function ae(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};K(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{oe(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ie(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}))}const re={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function le(e,t,n){var i;if(!0===(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))return;const{w:o,h:a}=t,{scale:r}=n.viewScaleInfo;if(!(r<1&&(o*r<1||a*r<1)||0===n.parentOpacity))try{switch(t.type){case"rect":ae(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{background:a="#000000",borderColor:r="#000000",boxSizing:l,borderWidth:s=0}=i;let c=0;"number"==typeof s&&s>0?c=s:Array.isArray(s)&&"number"==typeof s[0]&&s[0]>0&&(c=s[0]);const{calculator:d,viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u}=n,{x:w,y:g,w:v,h:y}=(null==d?void 0:d.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},h,f))||t,p={...t,x:w,y:g,w:v,h:y,angle:o};K(e,{x:w,y:g,w:v,h:y,angle:o},(()=>{oe(e,p,{viewScaleInfo:h,viewSizeInfo:f,renderContent:()=>{let t=v/2,n=y/2;const i=w+t,o=g+n;if(c>0&&("border-box"===l?(t-=c,n-=c):"center-line"===l?(t-=c/2,n-=c/2):(t-=c,n-=c)),t>=0&&n>=0){const l=ne(p)*u;if(e.globalAlpha=l,"number"==typeof s&&s>0){const a=s/2+t,l=s/2+n;e.beginPath(),e.strokeStyle=r,e.lineWidth=s,e.circle(i,o,a,l,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const c=ee(e,a,{viewElementSize:{x:w,y:g,w:v,h:y},viewScaleInfo:h,opacity:e.globalAlpha});e.fillStyle=c,e.circle(i,o,t,n,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=u}}})}))}(e,t,n);break;case"text":!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};K(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{ie(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const n={...re,...t.detail},i=(n.fontSize||re.fontSize)*o.scale,a=n.lineHeight?n.lineHeight*o.scale:i;e.fillStyle=t.detail.color||re.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:i,fontFamily:n.fontFamily});const r=n.text.replace(/\r\n/gi,"\n"),h=a,f=r.split("\n"),u=[];let w=0;f.forEach(((t,n)=>{let i="";if(t.length>0){for(let o=0;o<t.length&&(e.measureText(i+(t[o]||"")).width<e.$doPixelRatio(c)?i+=t[o]||"":(u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),i=t[o]||"",w++),!((w+1)*h>d));o++)if(t.length-1===o&&(w+1)*h<d){u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),n<f.length-1&&w++;break}}else u.push({text:"",width:0})}));let g=0;u.length*h<d&&("top"===t.detail.verticalAlign?g=0:"bottom"===t.detail.verticalAlign?g+=d-u.length*h:g+=(d-u.length*h)/2);{const t=s+g;void 0!==n.textShadowColor&&k(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&q.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&q.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&q.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),u.forEach(((i,o)=>{let a=l;"center"===n.textAlign?a=l+(c-i.width)/2:"right"===n.textAlign&&(a=l+(c-i.width)),e.fillText(i.text,a,t+h*o)}))}}})}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t,u={...t,x:s,y:c,w:d,h:h,angle:f};K(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{oe(e,u,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{ie(e,u,{originElem:t,calcElemSize:{x:s,y:c,w:d,h:h,angle:f},viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l,renderContent:()=>{if(i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=ne(t)*l;const{x:n,y:o,w:s,h:c,radiusList:d}=_(u,{viewScaleInfo:a,viewSizeInfo:r});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],o),e.arcTo(n+s,o,n+s,o+c,d[1]),e.arcTo(n+s,o+c,n,o+c,d[2]),e.arcTo(n,o+c,n,o,d[3]),e.arcTo(n,o,n+s,o,d[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(i,n,o,s,c),e.globalAlpha=l,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;K(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=ne(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;K(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=ne(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"path":!function(e,t,n){const{detail:i}=t,{originX:o,originY:a,originW:r,originH:l}=i,{calculator:s,viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h}=n,{x:f,y:u,w:w,h:g,angle:v}=(null==s?void 0:s.elementSize(t,c,d))||t,y=w/r,p=g/l,m=f-o*y,S=u-a*p,x=c.scale*d.devicePixelRatio,b={...t,x:f,y:u,w:w,h:g,angle:v};K(e,{x:f,y:u,w:w,h:g,angle:v},(()=>{ie(e,b,{originElem:t,calcElemSize:{x:f,y:u,w:w,h:g,angle:v},viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h,renderContent:()=>{oe(e,b,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{e.save(),e.translate(m,S),e.scale(x*y/c.scale,x*p/c.scale);const t=Q(i.commands||[]),n=new Path2D(t);i.fill&&(e.fillStyle=i.fill,e.fill(n)),i.stroke&&0!==i.strokeWidth&&(e.strokeStyle=i.stroke,e.lineWidth=(i.strokeWidth||1)/d.devicePixelRatio,e.lineCap=i.strokeLineCap||"square",e.stroke(n)),e.translate(-m,-S),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},o,a))||t,f={...t,x:l,y:s,w:c,h:d,angle:h};K(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{e.globalAlpha=ne(t)*r,oe(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ie(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const{x:i,y:l,w:s,h:c,radiusList:d}=_(f,{viewScaleInfo:o,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+d[0],l),e.arcTo(i+s,l,i+s,l+c,d[1]),e.arcTo(i+s,l+c,i,l+c,d[2]),e.arcTo(i,l+c,i,l,d[3]),e.arcTo(i,l,i+s,l,d[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:i}=n,o={x:i.x+t.x,y:i.y+t.y,w:t.w||i.w,h:t.h||i.h,angle:t.angle},{calculator:a}=n;for(let i=0;i<t.detail.children.length;i++){let l=t.detail.children[i];if(l={...l,x:o.x+l.x,y:o.y+l.y},!0===n.forceDrawAll||(null==a?void 0:a.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{le(e,l,{...n,parentOpacity:r*ne(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=r}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}const se={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const ce=["image","svg","html"],de=e=>{var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),"string"==typeof o&&o?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${o}`)?o:$(o):$(`${W()}-${e.uuid}-${W()}-${W()}`)};class he extends V{constructor(){super(),A(this,a),A(this,l),A(this,c),A(this,h),A(this,u),A(this,g),A(this,y),A(this,t,{}),A(this,n,{}),A(this,i,{}),A(this,o,!1),E(this,a,r).call(this,"image",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,o=await B(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),E(this,a,r).call(this,"html",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,o=await H(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),E(this,a,r).call(this,"svg",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,o=await F(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}isDestroyed(){return T(this,o)}destroy(){C(this,o,!0),this.clear(),C(this,t,null),C(this,n,null),C(this,i,null)}load(e,t){!0!==T(this,o)&&(E(this,y,p).call(this,e)||ce.includes(e.type)&&E(this,g,v).call(this,e,t))}getContent(e){var t,n;const o=de(e);return(null==(n=null==(t=T(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return T(this,i)}setLoadItemMap(e){C(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakSet,r=function(e,n){T(this,t)[e]=n},l=new WeakSet,s=function(e){var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),o},c=new WeakSet,d=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:E(this,l,s).call(this,e)}},h=new WeakSet,f=function(e){const t=de(e.element),n=T(this,i)[t];T(this,o)||(n?n.startTime<e.startTime&&(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))},u=new WeakSet,w=function(e){var t;const n=de(e.element),a=null==(t=T(this,i))?void 0:t[n];T(this,o)||(a?a.startTime<e.startTime&&(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))},g=new WeakSet,v=function(e,i){const a=E(this,c,d).call(this,e),r=de(e);T(this,n)[r]=a;const l=T(this,t)[e.type];"function"!=typeof l||T(this,o)||(a.startTime=Date.now(),l(e,i).then((e=>{T(this,o)||(a.content=e.content,a.endTime=Date.now(),a.status="load",E(this,h,f).call(this,a))})).catch((t=>{console.warn(`Load element source "${a.source}" fail`,t,e),a.endTime=Date.now(),a.status="error",a.error=t,E(this,u,w).call(this,a)})))},y=new WeakSet,p=function(e){var t;const i=de(e),o=null==(t=T(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==E(this,l,s).call(this,e))};return m=new WeakMap,S=new WeakMap,x=new WeakMap,b=new WeakSet,I=function(){const e=T(this,S);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))},e.Renderer=class extends V{constructor(e){super(),A(this,b),A(this,m,void 0),A(this,S,new he),A(this,x,!1),C(this,m,e),E(this,b,I).call(this)}isDestroyed(){return T(this,x)}destroy(){this.clear(),C(this,m,null),T(this,S).destroy(),C(this,S,null),C(this,x,!0)}updateOptions(e){C(this,m,e)}drawData(e,t){const n=T(this,S),{calculator:i}=T(this,m),o=T(this,m).viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);const a={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height};e.underlay&&function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"underlay",...t},{x:s,y:c,w:d,h:h}=(null==i?void 0:i.elementSize(l,o,a))||l,f={...l,x:s,y:c,w:d,h:h,angle:0};oe(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ie(e,f,{originElem:l,calcElemSize:{x:s,y:c,w:d,h:h,angle:0},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}(o,e.underlay,{loader:n,calculator:i,parentElementSize:a,parentOpacity:1,...t}),function(e,t,n){var i;const{elements:o=[]}=t,{parentOpacity:a}=n;for(let t=0;t<o.length;t++){const r=o[t],l={...r,detail:{...se,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{le(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}(o,e,{loader:n,calculator:i,parentElementSize:a,elementAssets:e.assets,parentOpacity:1,...t})}scale(e){const{sharer:t}=T(this,m);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){T(this,S).setLoadItemMap(e)}getLoadItemMap(){return T(this,S).getLoadItemMap()}getLoader(){return T(this,S)}},e.drawRect=ae,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
{
"name": "@idraw/renderer",
"version": "0.4.0-beta.10",
"version": "0.4.0-beta.11",
"description": "",

@@ -24,7 +24,7 @@ "main": "dist/esm/index.js",

"devDependencies": {
"@idraw/types": "^0.4.0-beta.10"
"@idraw/types": "^0.4.0-beta.11"
},
"dependencies": {},
"peerDependencies": {
"@idraw/util": "^0.4.0-beta.10"
"@idraw/util": "^0.4.0-beta.11"
},

@@ -31,0 +31,0 @@ "publishConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc