@idraw/board
Advanced tools
Comparing version 0.4.0-beta.14 to 0.4.0-beta.15
import { Renderer } from '@idraw/renderer'; | ||
import { EventEmitter } from '@idraw/util'; | ||
import type { Data, BoardOptions, BoardMiddleware, ViewSizeInfo, PointSize, BoardExtendEvent } from '@idraw/types'; | ||
import type { Data, BoardOptions, BoardMiddleware, ViewSizeInfo, PointSize, BoardExtendEventMap } from '@idraw/types'; | ||
import { Calculator } from './lib/calculator'; | ||
import { Sharer } from './lib/sharer'; | ||
import { Viewer } from './lib/viewer'; | ||
export declare class Board<T extends BoardExtendEvent = BoardExtendEvent> { | ||
export declare class Board<T extends BoardExtendEventMap = BoardExtendEventMap> { | ||
#private; | ||
@@ -9,0 +9,0 @@ constructor(opts: BoardOptions); |
@@ -201,2 +201,5 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
__classPrivateFieldGet(this, _Board_watcher, "f").on('doubleClick', __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleDoubleClick).bind(this)); | ||
__classPrivateFieldGet(this, _Board_renderer, "f").on('load', () => { | ||
__classPrivateFieldGet(this, _Board_eventHub, "f").trigger('loadResource'); | ||
}); | ||
}, _Board_handlePointStart = function _Board_handlePointStart(e) { | ||
@@ -203,0 +206,0 @@ var _a; |
@@ -1,1 +0,1 @@ | ||
var iDrawBoard=function(t){"use strict";var e,i,n,o,a,s,r,l,h,c,f,d,u,w,v,g,p,y,m,x,b,S,I,M,z,W,P,E,k,C,O,T,A,j,D,R,L,$,B,H,X,Y,F,V,N,U,G,q,Q,K,J,Z,_,tt,et,it,nt,ot,at,st,rt,lt,ht,ct,ft,dt,ut,wt,vt,gt,pt=(t,e,i)=>{if(!e.has(t))throw TypeError("Cannot "+i)},yt=(t,e,i)=>(pt(t,e,"read from private field"),i?i.call(t):e.get(t)),mt=(t,e,i)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,i)},xt=(t,e,i,n)=>(pt(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),bt=(t,e,i)=>(pt(t,e,"access private method"),i);function St(t,e){let i=-1;return function(...n){i>=0||(i=setTimeout((()=>{t(...n),i=-1}),e))}}function It(t){return"string"==typeof t&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}function Mt(t,e){if(1===e)return t;let i=1;const n=/^\#[0-9a-f]{6,6}$/i;let o=t;if(n.test(t)?i=parseInt(t.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(t)&&(i=parseInt(t.substring(7,9).replace(/^\#/,"0x")),o=t.substring(0,7)),i*=e,n.test(o)&&i>0&&i<1){const t=Math.max(0,Math.min(255,Math.ceil(256*i)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o}function zt(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function Wt(t){let e=0;for(let i=0;i<t.length;i++)e+=t.charCodeAt(i)*t.charCodeAt(i)*i*i;return e.toString(16).substring(0,4)}function Pt(t){const e=t.length,i=Math.floor(e/2),n=t.substring(0,4).padEnd(4,"0"),o=t.substring(0,4).padEnd(4,"0");return`@assets/${Wt(e.toString(16).padEnd(4,n))}${Wt(t.substring(i-4,i).padEnd(4,n)).padEnd(4,"f")}-${Wt(t.substring(i-8,i-4).padEnd(4,n)).padEnd(4,"f")}-${Wt(t.substring(i-12,i-8).padEnd(4,n)).padEnd(4,"f")}-${Wt(t.substring(i-16,i-12).padEnd(4,o)).padEnd(4,"f")}-${Wt(t.substring(i,i+4).padEnd(4,o)).padEnd(4,"f")}${Wt(t.substring(i+4,i+8).padEnd(4,o)).padEnd(4,"f")}${Wt(o.padEnd(4,n).padEnd(4,o))}`}function Et(t){return function t(e){const i=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return e;if("Array"===i){const i=[];return e.forEach((e=>{i.push(t(e))})),i}if("Object"===i){const i={};Object.keys(e).forEach((n=>{i[n]=t(e[n])}));return Object.getOwnPropertySymbols(e).forEach((n=>{i[n]=t(e[n])})),i}}(t)}function kt(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const Ct={type(t,e){const i=kt(t);return!0===e?i.toLocaleLowerCase():i},array:t=>"Array"===kt(t),json:t=>"Object"===kt(t),function:t=>"Function"===kt(t),asyncFunction:t=>"AsyncFunction"===kt(t),boolean:t=>"Boolean"===kt(t),string:t=>"String"===kt(t),number:t=>"Number"===kt(t),undefined:t=>"Undefined"===kt(t),null:t=>"Null"===kt(t),promise:t=>"Promise"===kt(t)};var Ot=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const{Image:Tt}=window;function At(t){return new Promise(((e,i)=>{const n=new Tt;n.crossOrigin="anonymous",n.onload=function(){e(n)},n.onabort=i,n.onerror=i,n.src=t}))}function jt(t){return Ot(this,void 0,void 0,(function*(){const e=yield function(t){return new Promise(((e,i)=>{const n=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(n),o.onload=function(t){var i;const n=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(n)},o.onerror=function(t){i(t)}}))}(t);return yield At(e)}))}function Dt(t,e){return Ot(this,void 0,void 0,(function*(){t=t.replace(/\&/gi,"&");const i=yield function(t,e){const{width:i,height:n}=e;return new Promise(((e,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${n||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),s=new FileReader;s.readAsDataURL(a),s.onload=function(t){var i;const n=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(n)},s.onerror=function(t){o(t)}}))}(t,e);return yield At(i)}))}function Rt(t){return"number"==typeof t&&(t>0||t<=0)}function Lt(t){return"number"==typeof t&&t>=0}function $t(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function Bt(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const Ht={x:function(t){return Rt(t)},y:function(t){return Rt(t)},w:Lt,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:Rt,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return Lt(t)},borderRadius:function(t){return Rt(t)&&t>=0},color:function(t){return It(t)},imageSrc:function(t){return Bt(t)||$t(t)},imageURL:$t,imageBase64:Bt,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let i=document.createElement("div");i.innerHTML=t,i.children.length>0&&(e=!0),i=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return Rt(t)&&t>0},lineHeight:function(t){return Rt(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 Rt(t)&&t>0}};var Xt,Yt=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)};class Ft{constructor(){Xt.set(this,void 0),function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(t,i):o?o.value=i:e.set(t,i)}(this,Xt,new Map,"f")}on(t,e){if(Yt(this,Xt,"f").has(t)){const i=Yt(this,Xt,"f").get(t)||[];null==i||i.push(e),Yt(this,Xt,"f").set(t,i)}else Yt(this,Xt,"f").set(t,[e])}off(t,e){if(Yt(this,Xt,"f").has(t)){const i=Yt(this,Xt,"f").get(t);if(Array.isArray(i))for(let t=0;t<(null==i?void 0:i.length);t++)if(i[t]===e){i.splice(t,1);break}Yt(this,Xt,"f").set(t,i||[])}}trigger(t,e){const i=Yt(this,Xt,"f").get(t);return!!Array.isArray(i)&&(i.forEach((t=>{t(e)})),!0)}has(t){if(Yt(this,Xt,"f").has(t)){const e=Yt(this,Xt,"f").get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){Yt(this,Xt,"f").clear()}}Xt=new WeakMap;var Vt,Nt,Ut,Gt,qt=function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,i):o?o.value=i:e.set(t,i),i},Qt=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)};class Kt{constructor(t){Vt.add(this),Nt.set(this,void 0),Ut.set(this,void 0),qt(this,Ut,Et(t.defaultStorage),"f"),qt(this,Nt,Qt(this,Vt,"m",Gt).call(this),"f")}set(t,e){Qt(this,Nt,"f")[t]=e}get(t){return Qt(this,Nt,"f")[t]}getSnapshot(){return Et(Qt(this,Nt,"f"))}clear(){qt(this,Nt,Qt(this,Vt,"m",Gt).call(this),"f")}destroy(){qt(this,Nt,null,"f")}}function Jt(t){return t/180*Math.PI}function Zt(t,e,i){const n=_t(e);!function(t,e,i,n){const o=Jt(e||0);i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(o),t.translate(-i.x,-i.y)),n(t),i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(-o),t.translate(-i.x,-i.y))}(t,e.angle||0,n,(()=>{i(t)}))}function _t(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function te(t,e,i){const n=function(t,e){const i=e.x-t.x,n=e.y-t.y;if(0===i){if(n<0)return 0;if(n>0)return Math.PI}else if(0===n){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&n<0?Math.atan(Math.abs(i)/Math.abs(n)):i>0&&n>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):0}(t,e);let o=n+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const a=function(t,e){const i=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===i?i:Math.sqrt(i)}(t,e);let s=0,r=0;return 0===o?(s=0,r=0-a):o>0&&o<Math.PI/2?(s=Math.sin(o)*a,r=0-Math.cos(o)*a):o===Math.PI/2?(s=a,r=0):o>Math.PI/2&&o<Math.PI?(s=Math.sin(Math.PI-o)*a,r=Math.cos(Math.PI-o)*a):o===Math.PI?(s=0,r=a):o>Math.PI&&o<1.5*Math.PI?(s=0-Math.sin(o-Math.PI)*a,r=Math.cos(o-Math.PI)*a):o===1.5*Math.PI?(s=0-a,r=0):o>1.5*Math.PI&&o<2*Math.PI?(s=0-Math.sin(2*Math.PI-o)*a,r=0-Math.cos(2*Math.PI-o)*a):o===2*Math.PI&&(s=0,r=0-a),s+=t.x,r+=t.y,{x:s,y:r}}function ee(t){const{angle:e=0}=t;return function(t,e,i){const{x:n,y:o,w:a,h:s}=t;let r={x:n,y:o},l={x:n+a,y:o},h={x:n+a,y:o+s},c={x:n,y:o+s};if(i&&(i>0||i<0)){const t=Jt(function(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}(i));r=te(e,r,t),l=te(e,l,t),h=te(e,h,t),c=te(e,c,t)}return[r,l,h,c]}(t,_t(t),e)}function ie(t,e){const{viewScaleInfo:i}=e,{x:n,y:o,w:a,h:s,angle:r}=t,{scale:l,offsetTop:h,offsetLeft:c}=i;return{x:n*l+c,y:o*l+h,w:a*l,h:s*l,angle:r}}function ne(t,e){const{context2d:i,element:n,viewScaleInfo:o,viewSizeInfo:a}=e,{angle:s=0}=n,{x:r,y:l,w:h,h:c}=ie(n,{viewScaleInfo:o,viewSizeInfo:a}),f=ee({x:r,y:l,w:h,h:c,angle:s});if(f.length>=2){i.beginPath(),i.moveTo(f[0].x,f[0].y);for(let t=1;t<f.length;t++)i.lineTo(f[t].x,f[t].y);i.closePath()}return!!i.isPointInPath(t.x,t.y)}function oe(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e}Nt=new WeakMap,Ut=new WeakMap,Vt=new WeakSet,Gt=function(){return Et(Qt(this,Ut,"f"))};const ae={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 se(t,e){const{viewScaleInfo:i}=e,{scale:n}=i;let{borderRadius:o}=t.detail;const{boxSizing:a=ae.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:r,y:l,w:h,h:c}=t,f=[0,0,0,0];if("number"==typeof o){const t=o*n;f=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(f=[o[0]*n,o[1]*n,o[2]*n,o[3]*n]);let d=0;return"number"==typeof s&&(d=(s||0)*n),"border-box"===a?(r=t.x+d/2,l=t.y+d/2,h=t.w-d,c=t.h-d):"content-box"===a?(r=t.x-d/2,l=t.y-d/2,h=t.w+d,c=t.h+d):(r=t.x,l=t.y,h=t.w,c=t.h),h=Math.max(h,1),c=Math.max(c,1),f=f.map((t=>Math.min(t,h/2,c/2))),{x:r,y:l,w:h,h:c,radiusList:f}}function re(t,e,i){if("string"==typeof e)return e;const{viewElementSize:n,viewScaleInfo:o,opacity:a=1}=i,{x:s,y:r}=n,{scale:l}=o;if("linear-gradient"===(null==e?void 0:e.type)){const{start:i,end:n,stops:o}=e,h={x:s+i.x*l,y:r+i.y*l},c={x:s+n.x*l,y:r+n.y*l},f=t.createLinearGradient(h.x,h.y,c.x,c.y);return o.forEach((t=>{f.addColorStop(t.offset,Mt(t.color,a))})),f}if("radial-gradient"===(null==e?void 0:e.type)){const{inner:i,outer:n,stops:o}=e,h={x:s+i.x*l,y:r+i.y*l,radius:i.radius*l},c={x:s+n.x*l,y:r+n.y*l,radius:n.radius*l},f=t.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return o.forEach((t=>{f.addColorStop(t.offset,Mt(t.color,a))})),f}return"#000000"}const le={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 he(t){var e,i,n,o;let a=1;return void 0!==(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.opacity)&&(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.opacity)>=0&&(null===(n=null==t?void 0:t.detail)||void 0===n?void 0:n.opacity)<=1&&(a=null===(o=null==t?void 0:t.detail)||void 0===o?void 0:o.opacity),a}function ce(t,e,i){const{pattern:n,renderContent:o,originElem:a,calcElemSize:s,viewScaleInfo:r,viewSizeInfo:l}=i||{},{parentOpacity:h}=i,c=he(a)*h;!function(t,e,i){const{renderContent:n,originElem:o,calcElemSize:a,viewSizeInfo:s}=i,r=s.devicePixelRatio,{clipPath:l}=(null==o?void 0:o.detail)||{};if(l&&a&&l.commands){const{x:i,y:o,w:s,h:h}=a,{originW:c,originH:f,originX:d,originY:u}=l,w=s/c,v=h/f,g=i-d*w,p=o-u*v;t.save(),t.translate(g,p),t.scale(r*w,r*v);const y=oe(l.commands||[]),m=new Path2D(y);t.clip(m),t.translate(0-g,0-p),t.setTransform(1,0,0,1,0,0),Zt(t,Object.assign({},e),(()=>{null==n||n()})),t.restore()}else null==n||n()}(t,e,{originElem:a,calcElemSize:s,viewScaleInfo:r,viewSizeInfo:l,renderContent:()=>{t.globalAlpha=c,function(t,e,i){var n,o;const{pattern:a,viewScaleInfo:s,viewSizeInfo:r}=i,l=[];if(e.detail.background||a){const{x:i,y:h,w:c,h:f,radiusList:d}=se(e,{viewScaleInfo:s,viewSizeInfo:r});if(t.beginPath(),t.moveTo(i+d[0],h),t.arcTo(i+c,h,i+c,h+f,d[1]),t.arcTo(i+c,h+f,i,h+f,d[2]),t.arcTo(i,h+f,i,h,d[3]),t.arcTo(i,h,i+c,h,d[0]),t.closePath(),"string"==typeof a)t.fillStyle=a;else if(["CanvasPattern"].includes(Ct.type(a)))t.fillStyle=a;else if("string"==typeof e.detail.background)t.fillStyle=e.detail.background;else if("linear-gradient"===(null===(n=e.detail.background)||void 0===n?void 0:n.type)){const n=re(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:f},viewScaleInfo:s,opacity:t.globalAlpha});t.fillStyle=n}else if("radial-gradient"===(null===(o=e.detail.background)||void 0===o?void 0:o.type)){const n=re(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:f},viewScaleInfo:s,opacity:t.globalAlpha});if(t.fillStyle=n,l&&l.length>0)for(let e=0;e<(null==l?void 0:l.length);e++){const n=l[e];"translate"===n.method?t.translate(n.args[0]+i,n.args[1]+h):"rotate"===n.method?t.rotate(...n.args):"scale"===n.method&&t.scale(...n.args)}}t.fill(),l&&l.length>0&&t.setTransform(1,0,0,1,0,0)}}(t,e,{pattern:n,viewScaleInfo:r,viewSizeInfo:l}),null==o||o(),function(t,e,i){if(0===e.detail.borderWidth)return;if(!It(e.detail.borderColor))return;const{viewScaleInfo:n}=i,{scale:o}=n;let a=le.borderColor;!0===It(e.detail.borderColor)&&(a=e.detail.borderColor);const{borderWidth:s,borderRadius:r,borderDash:l,boxSizing:h=le.boxSizing}=e.detail;let c=0;"number"==typeof s&&(c=s||1);c*=o;let f=[0,0,0,0];if("number"==typeof r){const t=r*o;f=[t,t,t,t]}else Array.isArray(r)&&4===(null==r?void 0:r.length)&&(f=[r[0]*o,r[1]*o,r[2]*o,r[3]*o]);t.strokeStyle=a;let d=[];Array.isArray(l)&&l.length>0&&(d=l.map((t=>Math.ceil(t*o))));let u=0,w=0,v=0,g=0;Array.isArray(s)&&(u=(s[0]||0)*o,w=(s[1]||0)*o,v=(s[2]||0)*o,g=(s[3]||0)*o);if(g||w||u||v){t.lineCap="butt";let{x:i,y:n,w:o,h:a}=e;"border-box"===h?(i+=g/2,n+=u/2,o=o-g/2-w/2,a=a-u/2-v/2):"content-box"===h?(i-=g/2,n-=u/2,o=o+g/2+w/2,a=a+u/2+v/2):(i=e.x,n=e.y,o=e.w,a=e.h),u&&(t.beginPath(),t.lineWidth=u,t.moveTo(i-g/2,n),t.lineTo(i+o+w/2,n),t.closePath(),t.stroke()),w&&(t.beginPath(),t.lineWidth=w,t.moveTo(i+o,n-u/2),t.lineTo(i+o,n+a+v/2),t.closePath(),t.stroke()),v&&(t.beginPath(),t.lineWidth=v,t.moveTo(i-g/2,n+a),t.lineTo(i+o+w/2,n+a),t.closePath(),t.stroke()),g&&(t.beginPath(),t.lineWidth=g,t.moveTo(i,n-u/2),t.lineTo(i,n+a+v/2),t.closePath(),t.stroke())}else{let{x:i,y:n,w:o,h:a}=e;"border-box"===h?(i=e.x+c/2,n=e.y+c/2,o=e.w-c,a=e.h-c):"content-box"===h?(i=e.x-c/2,n=e.y-c/2,o=e.w+c,a=e.h+c):(i=e.x,n=e.y,o=e.w,a=e.h),d.length>0?t.lineCap="butt":t.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),f=f.map((t=>Math.min(t,o/2,a/2))),t.setLineDash(d),t.lineWidth=c,t.beginPath(),t.moveTo(i+f[0],n),t.arcTo(i+o,n,i+o,n+a,f[1]),t.arcTo(i+o,n+a,i,n+a,f[2]),t.arcTo(i,n+a,i,n,f[3]),t.arcTo(i,n,i+o,n,f[0]),t.closePath(),t.stroke()}t.setLineDash([])}(t,e,{viewScaleInfo:r,viewSizeInfo:l}),t.globalAlpha=h}})}function fe(t,e,i){const{detail:n}=e,{viewScaleInfo:o,renderContent:a}=i,{shadowColor:s,shadowOffsetX:r,shadowOffsetY:l,shadowBlur:h}=n;Ht.number(h)?(t.save(),t.shadowColor=s||le.shadowColor,t.shadowOffsetX=(r||0)*o.scale,t.shadowOffsetY=(l||0)*o.scale,t.shadowBlur=(h||0)*o.scale,a(),t.restore()):a()}const de={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 ue(t,e,i){var n;if(!0===(null===(n=null==e?void 0:e.operations)||void 0===n?void 0:n.invisible))return;const{w:o,h:a}=e,{scale:s}=i.viewScaleInfo;if(!(s<1&&(o*s<1||a*s<1)||0===i.parentOpacity))try{switch(e.type){case"rect":!function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,{x:r,y:l,w:h,h:c,angle:f}=(null==n?void 0:n.elementSize(e,o,a))||e,d=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:f});Zt(t,{x:r,y:l,w:h,h:c,angle:f},(()=>{fe(t,d,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ce(t,d,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:f},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{}})}})}))}(t,e,i);break;case"circle":!function(t,e,i){const{detail:n,angle:o}=e,{background:a="#000000",borderColor:s="#000000",boxSizing:r,borderWidth:l=0}=n;let h=0;"number"==typeof l&&l>0?h=l:Array.isArray(l)&&"number"==typeof l[0]&&l[0]>0&&(h=l[0]);const{calculator:c,viewScaleInfo:f,viewSizeInfo:d,parentOpacity:u}=i,{x:w,y:v,w:g,h:p}=(null==c?void 0:c.elementSize({x:e.x,y:e.y,w:e.w,h:e.h},f,d))||e,y=Object.assign(Object.assign({},e),{x:w,y:v,w:g,h:p,angle:o});Zt(t,{x:w,y:v,w:g,h:p,angle:o},(()=>{fe(t,y,{viewScaleInfo:f,viewSizeInfo:d,renderContent:()=>{let e=g/2,i=p/2;const n=w+e,o=v+i;if(h>0&&("border-box"===r?(e-=h,i-=h):"center-line"===r?(e-=h/2,i-=h/2):(e-=h,i-=h)),e>=0&&i>=0){const r=he(y)*u;if(t.globalAlpha=r,"number"==typeof l&&l>0){const a=l/2+e,r=l/2+i;t.beginPath(),t.strokeStyle=s,t.lineWidth=l,t.circle(n,o,a,r,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath();const h=re(t,a,{viewElementSize:{x:w,y:v,w:g,h:p},viewScaleInfo:f,opacity:t.globalAlpha});t.fillStyle=h,t.circle(n,o,e,i,0,0,2*Math.PI),t.closePath(),t.fill(),t.globalAlpha=u}}})}))}(t,e,i);break;case"text":!function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,{x:r,y:l,w:h,h:c,angle:f}=(null==n?void 0:n.elementSize(e,o,a))||e,d=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:f});Zt(t,{x:r,y:l,w:h,h:c,angle:f},(()=>{ce(t,d,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:f},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const i=Object.assign(Object.assign({},de),e.detail),n=(i.fontSize||de.fontSize)*o.scale,a=i.lineHeight?i.lineHeight*o.scale:n;t.fillStyle=e.detail.color||de.color,t.textBaseline="top",t.$setFont({fontWeight:i.fontWeight,fontSize:n,fontFamily:i.fontFamily});const s=i.text.replace(/\r\n/gi,"\n"),f=a,d=s.split("\n"),u=[];let w=0;d.forEach(((e,i)=>{let n="";if(e.length>0){for(let o=0;o<e.length&&(t.measureText(n+(e[o]||"")).width<t.$doPixelRatio(h)?n+=e[o]||"":(u.push({text:n,width:t.$undoPixelRatio(t.measureText(n).width)}),n=e[o]||"",w++),!((w+1)*f>c));o++)if(e.length-1===o&&(w+1)*f<c){u.push({text:n,width:t.$undoPixelRatio(t.measureText(n).width)}),i<d.length-1&&w++;break}}else u.push({text:"",width:0})}));let v=0;u.length*f<c&&("top"===e.detail.verticalAlign?v=0:"bottom"===e.detail.verticalAlign?v+=c-u.length*f:v+=(c-u.length*f)/2);{const e=l+v;void 0!==i.textShadowColor&&It(i.textShadowColor)&&(t.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&Ht.number(i.textShadowOffsetX)&&(t.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&Ht.number(i.textShadowOffsetY)&&(t.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&Ht.number(i.textShadowBlur)&&(t.shadowBlur=i.textShadowBlur),u.forEach(((n,o)=>{let a=r;"center"===i.textAlign?a=r+(h-n.width)/2:"right"===i.textAlign&&(a=r+(h-n.width)),t.fillText(n.text,a,e+f*o)}))}}})}))}(t,e,i);break;case"image":!function(t,e,i){const n=i.loader.getContent(e),{calculator:o,viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r}=i,{x:l,y:h,w:c,h:f,angle:d}=(null==o?void 0:o.elementSize(e,a,s))||e,u=Object.assign(Object.assign({},e),{x:l,y:h,w:c,h:f,angle:d});Zt(t,{x:l,y:h,w:c,h:f,angle:d},(()=>{fe(t,u,{viewScaleInfo:a,viewSizeInfo:s,renderContent:()=>{ce(t,u,{originElem:e,calcElemSize:{x:l,y:h,w:c,h:f,angle:d},viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r,renderContent:()=>{if(n||i.loader.isDestroyed()||i.loader.load(e,i.elementAssets||{}),"image"===e.type&&n){t.globalAlpha=he(e)*r;const{x:i,y:o,w:l,h:h,radiusList:c}=se(u,{viewScaleInfo:a,viewSizeInfo:s});t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(i+c[0],o),t.arcTo(i+l,o,i+l,o+h,c[1]),t.arcTo(i+l,o+h,i,o+h,c[2]),t.arcTo(i,o+h,i,o,c[3]),t.arcTo(i,o,i+l,o,c[0]),t.closePath(),t.fill(),t.clip(),t.drawImage(n,i,o,l,h),t.globalAlpha=r,t.restore()}}})}})}))}(t,e,i);break;case"svg":!function(t,e,i){const n=i.loader.getContent(e),{calculator:o,viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r}=i,{x:l,y:h,w:c,h:f,angle:d}=(null==o?void 0:o.elementSize(e,a,s))||e;Zt(t,{x:l,y:h,w:c,h:f,angle:d},(()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.elementAssets||{}),"svg"===e.type&&n&&(t.globalAlpha=he(e)*r,t.drawImage(n,l,h,c,f),t.globalAlpha=r)}))}(t,e,i);break;case"html":!function(t,e,i){const n=i.loader.getContent(e),{calculator:o,viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r}=i,{x:l,y:h,w:c,h:f,angle:d}=(null==o?void 0:o.elementSize(e,a,s))||e;Zt(t,{x:l,y:h,w:c,h:f,angle:d},(()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.elementAssets||{}),"html"===e.type&&n&&(t.globalAlpha=he(e)*r,t.drawImage(n,l,h,c,f),t.globalAlpha=r)}))}(t,e,i);break;case"path":!function(t,e,i){const{detail:n}=e,{originX:o,originY:a,originW:s,originH:r}=n,{calculator:l,viewScaleInfo:h,viewSizeInfo:c,parentOpacity:f}=i,{x:d,y:u,w:w,h:v,angle:g}=(null==l?void 0:l.elementSize(e,h,c))||e,p=w/s,y=v/r,m=d-o*p,x=u-a*y,b=h.scale*c.devicePixelRatio,S=Object.assign(Object.assign({},e),{x:d,y:u,w:w,h:v,angle:g});Zt(t,{x:d,y:u,w:w,h:v,angle:g},(()=>{ce(t,S,{originElem:e,calcElemSize:{x:d,y:u,w:w,h:v,angle:g},viewScaleInfo:h,viewSizeInfo:c,parentOpacity:f,renderContent:()=>{fe(t,S,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{t.save(),t.translate(m,x),t.scale(b*p/h.scale,b*y/h.scale);const e=oe(n.commands||[]),i=new Path2D(e);n.fill&&(t.fillStyle=n.fill,t.fill(i)),n.stroke&&0!==n.strokeWidth&&(t.strokeStyle=n.stroke,t.lineWidth=(n.strokeWidth||1)/c.devicePixelRatio,t.lineCap=n.strokeLineCap||"square",t.stroke(i)),t.translate(-m,-x),t.restore()}})}})}))}(t,e,i);break;case"group":{const n=Object.assign(Object.assign({},i.elementAssets||{}),e.detail.assets||{});!function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,{x:r,y:l,w:h,h:c,angle:f}=(null==n?void 0:n.elementSize({x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle},o,a))||e,d=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:f});Zt(t,{x:r,y:l,w:h,h:c,angle:f},(()=>{t.globalAlpha=he(e)*s,fe(t,d,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ce(t,d,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:f},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const{x:n,y:r,w:l,h:h,radiusList:c}=se(d,{viewScaleInfo:o,viewSizeInfo:a});if("hidden"===e.detail.overflow&&(t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(n+c[0],r),t.arcTo(n+l,r,n+l,r+h,c[1]),t.arcTo(n+l,r+h,n,r+h,c[2]),t.arcTo(n,r+h,n,r,c[3]),t.arcTo(n,r,n+l,r,c[0]),t.closePath(),t.fill(),t.clip()),Array.isArray(e.detail.children)){const{parentElementSize:n}=i,o={x:n.x+e.x,y:n.y+e.y,w:e.w||n.w,h:e.h||n.h,angle:e.angle},{calculator:a}=i;for(let n=0;n<e.detail.children.length;n++){let r=e.detail.children[n];if(r=Object.assign(Object.assign({},r),{x:o.x+r.x,y:o.y+r.y}),!0===i.forceDrawAll||(null==a?void 0:a.isElementInView(r,i.viewScaleInfo,i.viewSizeInfo)))try{ue(t,r,Object.assign(Object.assign({},i),{parentOpacity:s*he(e)}))}catch(t){console.error(t)}}}"hidden"===e.detail.overflow&&t.restore()}})}}),t.globalAlpha=s}))}(t,e,Object.assign(Object.assign({},i),{elementAssets:n}));break}}}catch(t){console.error(t)}}const we={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"};var ve,ge,pe,ye,me,xe,be,Se,Ie,Me,ze,We,Pe=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},Ee=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)},ke=function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,i):o?o.value=i:e.set(t,i),i};const Ce=["image","svg","html"],Oe=t=>{var e,i,n;let o=null;return"image"===t.type?o=(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.src)||null:"svg"===t.type?o=(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.svg)||null:"html"===t.type&&(o=(null===(n=null==t?void 0:t.detail)||void 0===n?void 0:n.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:Pt(o):Pt(`${zt()}-${t.uuid}-${zt()}-${zt()}`)};class Te extends Ft{constructor(){super(),ve.add(this),ge.set(this,{}),pe.set(this,{}),ye.set(this,{}),me.set(this,!1),Ee(this,ve,"m",xe).call(this,"image",((t,e)=>Pe(this,void 0,void 0,(function*(){var i;const n=(null===(i=e[t.detail.src])||void 0===i?void 0:i.value)||t.detail.src,o=yield At(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),Ee(this,ve,"m",xe).call(this,"html",((t,e)=>Pe(this,void 0,void 0,(function*(){var i;const n=(null===(i=e[t.detail.html])||void 0===i?void 0:i.value)||t.detail.html,o=yield Dt(n,{width:t.detail.originW||t.w,height:t.detail.originH||t.h});return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),Ee(this,ve,"m",xe).call(this,"svg",((t,e)=>Pe(this,void 0,void 0,(function*(){var i;const n=(null===(i=e[t.detail.svg])||void 0===i?void 0:i.value)||t.detail.svg,o=yield jt(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}}))))}isDestroyed(){return Ee(this,me,"f")}destroy(){ke(this,me,!0,"f"),this.clear(),ke(this,ge,null,"f"),ke(this,pe,null,"f"),ke(this,ye,null,"f")}load(t,e){!0!==Ee(this,me,"f")&&(Ee(this,ve,"m",We).call(this,t)||Ce.includes(t.type)&&Ee(this,ve,"m",ze).call(this,t,e))}getContent(t){var e,i;const n=Oe(t);return(null===(i=null===(e=Ee(this,ye,"f"))||void 0===e?void 0:e[n])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return Ee(this,ye,"f")}setLoadItemMap(t){ke(this,ye,t,"f")}}ge=new WeakMap,pe=new WeakMap,ye=new WeakMap,me=new WeakMap,ve=new WeakSet,xe=function(t,e){Ee(this,ge,"f")[t]=e},be=function(t){var e,i,n;let o=null;return"image"===t.type?o=(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.src)||null:"svg"===t.type?o=(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.svg)||null:"html"===t.type&&(o=(null===(n=null==t?void 0:t.detail)||void 0===n?void 0:n.html)||null),o},Se=function(t){return{element:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:Ee(this,ve,"m",be).call(this,t)}},Ie=function(t){const e=Oe(t.element),i=Ee(this,ye,"f")[e];Ee(this,me,"f")||(i?i.startTime<t.startTime&&(Ee(this,ye,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(Ee(this,ye,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))))},Me=function(t){var e;const i=Oe(t.element),n=null===(e=Ee(this,ye,"f"))||void 0===e?void 0:e[i];Ee(this,me,"f")||(n?n.startTime<t.startTime&&(Ee(this,ye,"f")[i]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(Ee(this,ye,"f")[i]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))))},ze=function(t,e){const i=Ee(this,ve,"m",Se).call(this,t),n=Oe(t);Ee(this,pe,"f")[n]=i;const o=Ee(this,ge,"f")[t.type];"function"!=typeof o||Ee(this,me,"f")||(i.startTime=Date.now(),o(t,e).then((t=>{Ee(this,me,"f")||(i.content=t.content,i.endTime=Date.now(),i.status="load",Ee(this,ve,"m",Ie).call(this,i))})).catch((e=>{console.warn(`Load element source "${i.source}" fail`,e,t),i.endTime=Date.now(),i.status="error",i.error=e,Ee(this,ve,"m",Me).call(this,i)})))},We=function(t){var e;const i=Oe(t),n=null===(e=Ee(this,pe,"f"))||void 0===e?void 0:e[i];return!(!n||"error"!==n.status||!n.source||n.source!==Ee(this,ve,"m",be).call(this,t))};var Ae,je,De,Re,Le,$e=function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,i):o?o.value=i:e.set(t,i),i},Be=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)};class He extends Ft{constructor(t){super(),Ae.add(this),je.set(this,void 0),De.set(this,new Te),Re.set(this,!1),$e(this,je,t,"f"),Be(this,Ae,"m",Le).call(this)}isDestroyed(){return Be(this,Re,"f")}destroy(){this.clear(),$e(this,je,null,"f"),Be(this,De,"f").destroy(),$e(this,De,null,"f"),$e(this,Re,!0,"f")}updateOptions(t){$e(this,je,t,"f")}drawData(t,e){const i=Be(this,De,"f"),{calculator:n}=Be(this,je,"f"),o=Be(this,je,"f").viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);const a={x:0,y:0,w:e.viewSizeInfo.width,h:e.viewSizeInfo.height};t.underlay&&function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,r=Object.assign({uuid:"underlay"},e),{x:l,y:h,w:c,h:f}=(null==n?void 0:n.elementSize(r,o,a))||r,d=Object.assign(Object.assign({},r),{x:l,y:h,w:c,h:f,angle:0});fe(t,d,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ce(t,d,{originElem:r,calcElemSize:{x:l,y:h,w:c,h:f,angle:0},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{}})}})}(o,t.underlay,Object.assign({loader:i,calculator:n,parentElementSize:a,parentOpacity:1},e)),function(t,e,i){var n;const{elements:o=[]}=e,{parentOpacity:a}=i;for(let e=0;e<o.length;e++){const s=o[e],r=Object.assign(Object.assign({},s),{detail:Object.assign(Object.assign({},we),null==s?void 0:s.detail)});if(!0===i.forceDrawAll||(null===(n=i.calculator)||void 0===n?void 0:n.isElementInView(r,i.viewScaleInfo,i.viewSizeInfo)))try{ue(t,r,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(t){console.error(t)}}}(o,t,Object.assign({loader:i,calculator:n,parentElementSize:a,elementAssets:t.assets,parentOpacity:1},e))}scale(t){const{sharer:e}=Be(this,je,"f");if(!e)return;const{data:i,offsetTop:n,offsetBottom:o,offsetLeft:a,offsetRight:s,width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:f}=e.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:t,offsetTop:n,offsetBottom:o,offsetLeft:a,offsetRight:s},viewSizeInfo:{width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:f}})}setLoadItemMap(t){Be(this,De,"f").setLoadItemMap(t)}getLoadItemMap(){return Be(this,De,"f").getLoadItemMap()}getLoader(){return Be(this,De,"f")}}je=new WeakMap,De=new WeakMap,Re=new WeakMap,Ae=new WeakSet,Le=function(){const t=Be(this,De,"f");t.on("load",(t=>{this.trigger("load",t)})),t.on("error",(()=>{}))};class Xe{constructor(t){mt(this,e,void 0),xt(this,e,t)}destroy(){xt(this,e,null)}elementSize(t,e,i){return ie(t,{viewScaleInfo:e,viewSizeInfo:i})}isElementInView(t,e,i){return function(t,e){const{viewSizeInfo:i,viewScaleInfo:n}=e,{width:o,height:a}=i,{angle:s}=t,{x:r,y:l,w:h,h:c}=ie(t,{viewScaleInfo:n,viewSizeInfo:i}),f=ee({x:r,y:l,w:h,h:c,angle:s}),d={x:0,y:0,w:o,h:a},u=Math.min(f[0].x,f[1].x,f[2].x,f[3].x),w=Math.min(f[0].y,f[1].y,f[2].y,f[3].y);return function(t,e){const i=t.x,n=t.y,o=t.x+t.w,a=t.y+t.h,s=e.x,r=e.y,l=e.x+e.w,h=e.y+e.h;return i<=l&&o>=s&&n<=h&&a>=r}(d,{x:u,y:w,w:Math.max(f[0].x,f[1].x,f[2].x,f[3].x)-u,h:Math.max(f[0].y,f[1].y,f[2].y,f[3].y)-w})}(t,{viewScaleInfo:e,viewSizeInfo:i})}isPointInElement(t,i,n,o){return ne(t,{context2d:yt(this,e).viewContext,element:i,viewScaleInfo:n,viewSizeInfo:o})}getPointElement(t,i){return function(t,e){var i,n,o;const{context2d:a,data:s,viewScaleInfo:r,viewSizeInfo:l,groupQueue:h}=e,c={index:-1,element:null,groupQueueIndex:-1};if(h&&Array.isArray(h)&&(null==h?void 0:h.length)>0)for(let e=h.length-1;e>=0;e--){let o=0,s=0,f=0;for(let t=0;t<=e;t++)o+=h[t].x,s+=h[t].y,f+=h[t].angle||0;const d=h[e];if(d&&"group"===d.type&&Array.isArray(null===(i=d.detail)||void 0===i?void 0:i.children))for(let i=0;i<d.detail.children.length;i++){const u=d.detail.children[i];if(!0!==(null===(n=null==u?void 0:u.operations)||void 0===n?void 0:n.invisible)){if(!u)break;if(ne(t,{context2d:a,element:{x:o+u.x,y:s+u.y,w:u.w,h:u.h,angle:f+(u.angle||0)},viewScaleInfo:r,viewSizeInfo:l})){c.element=u,(e<h.length-1||"group"!==u.type)&&(c.groupQueueIndex=e);break}}}if(c.element)break}if(c.element)return c;for(let e=s.elements.length-1;e>=0;e--){const i=s.elements[e];if(!0!==(null===(o=null==i?void 0:i.operations)||void 0===o?void 0:o.invisible)&&ne(t,{context2d:a,element:i,viewScaleInfo:r,viewSizeInfo:l})){c.index=e,c.element=i;break}}return c}(t,{...i,context2d:yt(this,e).viewContext})}}function Ye(t){return t>0||t<0||0===t}e=new WeakMap;class Fe extends Ft{constructor(t){super(),mt(this,a),mt(this,v),mt(this,p),mt(this,m),mt(this,i,void 0),mt(this,n,void 0),mt(this,o,!1),mt(this,r,(t=>{if(!bt(this,v,g).call(this,t))return;const e=bt(this,p,y).call(this,t);if(!bt(this,m,x).call(this,e))return;t.preventDefault(),t.stopPropagation();const i=t.deltaX>0||t.deltaX<0?t.deltaX:0,n=t.deltaY>0||t.deltaY<0?t.deltaY:0;!0===t.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:i,deltaY:n,point:e}):this.has("wheel")&&this.trigger("wheel",{deltaX:i,deltaY:n,point:e})})),mt(this,l,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)})),mt(this,h,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);if(!bt(this,m,x).call(this,e))return;const i=Date.now(),o=yt(this,n).get("prevClickPoint");o&&i-o.t<=500&&Math.abs(o.x-e.x)<=5&&Math.abs(o.y-e.y)<=5?this.trigger("doubleClick",{point:e}):yt(this,n).set("prevClickPoint",e)})),mt(this,c,(t=>{if(yt(this,n).set("hasPointDown",!1),!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);this.trigger("pointLeave",{point:e})})),mt(this,f,(t=>{if(yt(this,n).set("hasPointDown",!1),!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);this.trigger("pointEnd",{point:e})})),mt(this,d,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault(),t.stopPropagation();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)?!0===yt(this,n).get("hasPointDown")&&this.trigger("pointMove",{point:e}):yt(this,n).get("hasPointDown")&&(this.trigger("pointLeave",{point:e}),yt(this,n).set("hasPointDown",!1))})),mt(this,u,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)&&(yt(this,n).set("hasPointDown",!0),this.trigger("pointStart",{point:e}))})),mt(this,w,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)&&this.trigger("hover",{point:e})}));const e=new Kt({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});xt(this,n,e),xt(this,i,t),bt(this,a,s).call(this)}onEvents(){if(yt(this,o))return;const t=window;t.addEventListener("mousemove",yt(this,w)),t.addEventListener("mousedown",yt(this,u)),t.addEventListener("mousemove",yt(this,d)),t.addEventListener("mouseup",yt(this,f)),t.addEventListener("mouseleave",yt(this,c)),t.addEventListener("wheel",yt(this,r),{passive:!1}),t.addEventListener("click",yt(this,h)),t.addEventListener("contextmenu",yt(this,l))}offEvents(){const t=window;t.removeEventListener("mousemove",yt(this,w)),t.removeEventListener("mousedown",yt(this,u)),t.removeEventListener("mousemove",yt(this,d)),t.removeEventListener("mouseup",yt(this,f)),t.removeEventListener("mouseleave",yt(this,c)),t.removeEventListener("wheel",yt(this,r)),t.removeEventListener("click",yt(this,h)),t.removeEventListener("contextmenu",yt(this,l))}destroy(){this.offEvents(),yt(this,n).destroy(),xt(this,o,!0)}}i=new WeakMap,n=new WeakMap,o=new WeakMap,a=new WeakSet,s=function(){this.onEvents()},r=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,f=new WeakMap,d=new WeakMap,u=new WeakMap,w=new WeakMap,v=new WeakSet,g=function(t){return t.target===yt(this,i).boardContent.boardContext.canvas},p=new WeakSet,y=function(t){const e=yt(this,i).boardContent.boardContext.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top,t:Date.now()}},m=new WeakSet,x=function(t){const e=yt(this,i).sharer.getActiveViewSizeInfo(),{width:n,height:o}=e;return!!(Ye(t.x)&&Ye(t.y)&&t.x<=n&&t.y<=o)};const Ve={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class Ne{constructor(){mt(this,b,void 0),mt(this,S,void 0);const t=new Kt({defaultStorage:Ve}),e=new Kt({defaultStorage:{}});xt(this,b,t),xt(this,S,e)}getActiveStorage(t){return yt(this,b).get(t)}setActiveStorage(t,e){return yt(this,b).set(t,e)}getActiveStoreSnapshot(){return yt(this,b).getSnapshot()}getSharedStorage(t){return yt(this,S).get(t)}setSharedStorage(t,e){return yt(this,S).set(t,e)}getSharedStoreSnapshot(){return yt(this,S).getSnapshot()}getActiveViewScaleInfo(){return{scale:yt(this,b).get("scale"),offsetTop:yt(this,b).get("offsetTop"),offsetBottom:yt(this,b).get("offsetBottom"),offsetLeft:yt(this,b).get("offsetLeft"),offsetRight:yt(this,b).get("offsetRight")}}setActiveViewScaleInfo(t){const{scale:e,offsetTop:i,offsetBottom:n,offsetLeft:o,offsetRight:a}=t;yt(this,b).set("scale",e),yt(this,b).set("offsetTop",i),yt(this,b).set("offsetBottom",n),yt(this,b).set("offsetLeft",o),yt(this,b).set("offsetRight",a)}setActiveViewSizeInfo(t){yt(this,b).set("width",t.width),yt(this,b).set("height",t.height),yt(this,b).set("devicePixelRatio",t.devicePixelRatio),yt(this,b).set("contextWidth",t.contextWidth),yt(this,b).set("contextHeight",t.contextHeight)}getActiveViewSizeInfo(){return{width:yt(this,b).get("width"),height:yt(this,b).get("height"),devicePixelRatio:yt(this,b).get("devicePixelRatio"),contextWidth:yt(this,b).get("contextWidth"),contextHeight:yt(this,b).get("contextHeight")}}}b=new WeakMap,S=new WeakMap;const{requestAnimationFrame:Ue}=window;class Ge extends Ft{constructor(t){super(),mt(this,W),mt(this,E),mt(this,I,void 0),mt(this,M,[]),mt(this,z,"FREE"),xt(this,I,t),bt(this,W,P).call(this)}drawFrame(){const{sharer:t}=yt(this,I),e=t.getActiveStoreSnapshot(),i=t.getSharedStoreSnapshot();yt(this,M).push({activeStore:e,sharedStore:i}),bt(this,E,k).call(this)}scale(t){const{scale:e,point:i}=t,{sharer:n}=yt(this,I),{moveX:o,moveY:a}=function(t){const{scale:e,point:i,viewScaleInfo:n}=t,{offsetLeft:o,offsetTop:a}=n,s=e/n.scale,r=i.x,l=i.y;return{moveX:r-r*s+(o*s-o),moveY:l-l*s+(a*s-a)}}({scale:e,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",e),{moveX:o,moveY:a}}scroll(t){const{sharer:e}=yt(this,I),i=e.getActiveViewScaleInfo(),{moveX:n,moveY:o}=t,a=function(t){const{moveX:e=0,moveY:i=0,viewScaleInfo:n,viewSizeInfo:o}=t,{scale:a}=n,{width:s,height:r,contextWidth:l,contextHeight:h}=o;let c=n.offsetLeft,f=n.offsetRight,d=n.offsetTop,u=n.offsetBottom;return c+=e,d+=i,f=s-(l*a+c),u=r-(h*a+d),{scale:a,offsetTop:d,offsetLeft:c,offsetRight:f,offsetBottom:u}}({moveX:n,moveY:o,viewScaleInfo:i,viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(a),a}updateViewScaleInfo(t){const{sharer:e}=yt(this,I),i=function(t,e){const{scale:i,offsetX:n,offsetY:o}=t,{viewSizeInfo:a}=e,{width:s,height:r,contextWidth:l,contextHeight:h}=a,c=0-n*i,f=0-o*i;return{scale:i,offsetLeft:c,offsetTop:f,offsetRight:s-(l*i+c/i),offsetBottom:r-(h*i+f/i)}}(t,{viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(i),i}resize(t={}){const{sharer:e}=yt(this,I),i={...e.getActiveViewSizeInfo(),...t},{width:n,height:o,devicePixelRatio:a}=i,{underContext:s,boardContext:r,helperContext:l,viewContext:h}=yt(this,I).boardContent;return r.canvas.width=n*a,r.canvas.height=o*a,r.canvas.style.width=`${n}px`,r.canvas.style.height=`${o}px`,s.canvas.width=n*a,s.canvas.height=o*a,l.canvas.width=n*a,l.canvas.height=o*a,h.canvas.width=n*a,h.canvas.height=o*a,e.setActiveViewSizeInfo(i),i}}I=new WeakMap,M=new WeakMap,z=new WeakMap,W=new WeakSet,P=function(){const{renderer:t}=yt(this,I);t.on("load",(()=>{this.drawFrame()}))},E=new WeakSet,k=function(){if("DRAWING"===yt(this,z)||0===yt(this,M).length)return;xt(this,z,"DRAWING");const t=yt(this,M).shift(),{renderer:e,boardContent:i,beforeDrawFrame:n,afterDrawFrame:o}=yt(this,I);if(t){const{scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h,width:c,height:f,contextHeight:d,contextWidth:u,devicePixelRatio:w}=t.activeStore,v={scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h},g={width:c,height:f,contextHeight:d,contextWidth:u,devicePixelRatio:w};(null==t?void 0:t.activeStore.data)&&e.drawData(t.activeStore.data,{viewScaleInfo:v,viewSizeInfo:g}),n({snapshot:t}),i.drawView(),o({snapshot:t})}0!==yt(this,M).length?xt(this,z,"DRAWING")&&Ue((()=>{bt(this,E,k).call(this)})):xt(this,z,"COMPLETE")};return C=new WeakMap,O=new WeakMap,T=new WeakMap,A=new WeakMap,j=new WeakMap,D=new WeakMap,R=new WeakMap,L=new WeakMap,$=new WeakMap,B=new WeakMap,H=new WeakMap,X=new WeakSet,Y=function(){yt(this,j).on("pointStart",bt(this,F,V).bind(this)),yt(this,j).on("pointEnd",bt(this,N,U).bind(this)),yt(this,j).on("pointMove",St((t=>{bt(this,G,q).call(this,t)}),10)),yt(this,j).on("hover",St((t=>{bt(this,Q,K).call(this,t)}),10)),yt(this,j).on("wheel",St((t=>{bt(this,_,tt).call(this,t)}),10)),yt(this,j).on("wheelScale",St((t=>{bt(this,et,it).call(this,t)}),10)),yt(this,j).on("scrollX",bt(this,nt,ot).bind(this)),yt(this,j).on("scrollY",bt(this,at,st).bind(this)),yt(this,j).on("resize",bt(this,rt,lt).bind(this)),yt(this,j).on("doubleClick",bt(this,J,Z).bind(this))},F=new WeakSet,V=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.pointStart)?void 0:e.call(n,t)))return}},N=new WeakSet,U=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.pointEnd)?void 0:e.call(n,t)))return}},G=new WeakSet,q=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.pointMove)?void 0:e.call(n,t)))return}},Q=new WeakSet,K=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.hover)?void 0:e.call(n,t)))return}},J=new WeakSet,Z=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.doubleClick)?void 0:e.call(n,t)))return}},_=new WeakSet,tt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.wheel)?void 0:e.call(n,t)))return}},et=new WeakSet,it=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.wheelScale)?void 0:e.call(n,t)))return}},nt=new WeakSet,ot=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.scrollX)?void 0:e.call(n,t)))return}},at=new WeakSet,st=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.scrollY)?void 0:e.call(n,t)))return}},rt=new WeakSet,lt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.resize)?void 0:e.call(n,t)))return}},ht=new WeakSet,ct=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.clear)?void 0:e.call(n,t)))return}},ft=new WeakSet,dt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.beforeDrawFrame)?void 0:e.call(n,t)))return}},ut=new WeakSet,wt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.afterDrawFrame)?void 0:e.call(n,t)))return}},vt=new WeakSet,gt=function(){const t=[],e=yt(this,O);yt(this,T).forEach((i=>{const n=e.get(i);"enable"===(null==n?void 0:n.status)&&(null==n?void 0:n.middlewareObject)&&t.push(n.middlewareObject)})),xt(this,A,t)},t.Board=class{constructor(t){mt(this,X),mt(this,F),mt(this,N),mt(this,G),mt(this,Q),mt(this,J),mt(this,_),mt(this,et),mt(this,nt),mt(this,at),mt(this,rt),mt(this,ht),mt(this,ft),mt(this,ut),mt(this,vt),mt(this,C,void 0),mt(this,O,new WeakMap),mt(this,T,[]),mt(this,A,[]),mt(this,j,void 0),mt(this,D,void 0),mt(this,R,void 0),mt(this,L,void 0),mt(this,$,void 0),mt(this,B,new Ft),mt(this,H,!1);const{boardContent:e}=t,i=new Ne,n=new Xe({viewContext:e.viewContext}),o=new Fe({boardContent:e,sharer:i}),a=new He({viewContext:e.viewContext,sharer:i,calculator:n});xt(this,C,t),xt(this,R,i),xt(this,j,o),xt(this,D,a),xt(this,$,n),xt(this,L,new Ge({boardContent:t.boardContent,sharer:i,renderer:a,calculator:yt(this,$),beforeDrawFrame:t=>{bt(this,ft,dt).call(this,t)},afterDrawFrame:t=>{bt(this,ut,wt).call(this,t)}})),bt(this,X,Y).call(this),bt(this,vt,gt).call(this)}isDestroyed(){return yt(this,H)}destroy(){yt(this,j).destroy(),yt(this,D).destroy(),yt(this,$).destroy(),yt(this,B).destroy(),xt(this,H,!0)}getSharer(){return yt(this,R)}getViewer(){return yt(this,L)}getRenderer(){return yt(this,D)}setData(t){const e=yt(this,R);yt(this,R).setActiveStorage("data",t);const i=e.getActiveViewSizeInfo(),n=function(t,e){const i={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=ee(e);if(4===t.length){const i=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...i),e.y=Math.min(...n),e.w=Math.abs(Math.max(...i)-Math.min(...i)),e.h=Math.abs(Math.max(...n)-Math.min(...n))}}const n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),a=Math.max(e.x+e.w,i.x+i.w),s=Math.max(e.y+e.h,i.y+i.h);i.x=n,i.y=o,i.w=Math.abs(a-n),i.h=Math.abs(s-o)})),(null==e?void 0:e.extend)&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const n={contextWidth:i.w,contextHeight:i.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>i.x+i.w&&(n.contextWidth=e.viewWidth-i.x),e.viewHeight>i.y+i.h&&(n.contextHeight=e.viewHeight-i.y)),n}(t.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});yt(this,L).drawFrame();const o={...i,...n};return yt(this,R).setActiveViewSizeInfo(o),{viewSizeInfo:o}}getData(){const{data:t}=yt(this,R).getActiveStoreSnapshot();return t}use(t){var e,i,n;if(yt(this,O).has(t)){const n=yt(this,O).get(t);if(n)return null==(i=(e=n.middlewareObject).use)||i.call(e),n.status="enable",yt(this,O).set(t,n),void bt(this,vt,gt).call(this)}const{boardContent:o,container:a}=yt(this,C),s=t({boardContent:o,sharer:yt(this,R),viewer:yt(this,L),calculator:yt(this,$),eventHub:yt(this,B),container:a});null==(n=s.use)||n.call(s),yt(this,T).push(t),yt(this,A).push(s),yt(this,O).set(t,{status:"enable",middlewareObject:s}),bt(this,vt,gt).call(this)}disuse(t){var e,i;const n=yt(this,O).get(t);n&&(null==(i=(e=n.middlewareObject).disuse)||i.call(e),n.status="disable",yt(this,O).set(t,n),bt(this,vt,gt).call(this))}scale(t){const e=yt(this,L),{moveX:i,moveY:n}=e.scale(t);e.scroll({moveX:i,moveY:n})}scroll(t){return yt(this,L).scroll(t)}updateViewScaleInfo(t){return yt(this,L).updateViewScaleInfo(t)}resize(t){const e=yt(this,L).resize(t),{width:i,height:n,devicePixelRatio:o}=t,{boardContent:a}=yt(this,C);a.viewContext.$resize({width:i,height:n,devicePixelRatio:o}),a.helperContext.$resize({width:i,height:n,devicePixelRatio:o}),a.boardContext.$resize({width:i,height:n,devicePixelRatio:o}),a.underContext.$resize({width:i,height:n,devicePixelRatio:o}),yt(this,L).drawFrame(),yt(this,j).trigger("resize",e),yt(this,R).setActiveViewSizeInfo(t)}clear(){const{boardContent:t}=yt(this,C),{underContext:e,helperContext:i,viewContext:n,boardContext:o}=t;e.clearRect(0,0,e.canvas.width,e.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),n.clearRect(0,0,n.canvas.width,n.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),bt(this,ht,ct).call(this)}getEventHub(){return yt(this,B)}onWatcherEvents(){yt(this,j).onEvents()}offWatcherEvents(){yt(this,j).offEvents()}},t.Calculator=Xe,t.Sharer=Ne,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({}); | ||
var iDrawBoard=function(t){"use strict";var e,i,n,o,a,s,r,l,h,c,f,d,u,w,v,g,p,y,m,x,b,S,I,M,z,W,P,E,k,C,O,T,A,j,R,D,L,$,B,H,X,Y,F,V,N,U,G,q,Q,K,J,Z,_,tt,et,it,nt,ot,at,st,rt,lt,ht,ct,ft,dt,ut,wt,vt,gt,pt=(t,e,i)=>{if(!e.has(t))throw TypeError("Cannot "+i)},yt=(t,e,i)=>(pt(t,e,"read from private field"),i?i.call(t):e.get(t)),mt=(t,e,i)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,i)},xt=(t,e,i,n)=>(pt(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),bt=(t,e,i)=>(pt(t,e,"access private method"),i);function St(t,e){let i=-1;return function(...n){i>=0||(i=setTimeout((()=>{t(...n),i=-1}),e))}}function It(t){return"string"==typeof t&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}function Mt(t,e){if(1===e)return t;let i=1;const n=/^\#[0-9a-f]{6,6}$/i;let o=t;if(n.test(t)?i=parseInt(t.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(t)&&(i=parseInt(t.substring(7,9).replace(/^\#/,"0x")),o=t.substring(0,7)),i*=e,n.test(o)&&i>0&&i<1){const t=Math.max(0,Math.min(255,Math.ceil(256*i)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o}function zt(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function Wt(t){let e=0;for(let i=0;i<t.length;i++)e+=t.charCodeAt(i)*t.charCodeAt(i)*i*i;return e.toString(16).substring(0,4)}function Pt(t){const e=t.length,i=Math.floor(e/2),n=t.substring(0,4).padEnd(4,"0"),o=t.substring(0,4).padEnd(4,"0");return`@assets/${Wt(e.toString(16).padEnd(4,n))}${Wt(t.substring(i-4,i).padEnd(4,n)).padEnd(4,"f")}-${Wt(t.substring(i-8,i-4).padEnd(4,n)).padEnd(4,"f")}-${Wt(t.substring(i-12,i-8).padEnd(4,n)).padEnd(4,"f")}-${Wt(t.substring(i-16,i-12).padEnd(4,o)).padEnd(4,"f")}-${Wt(t.substring(i,i+4).padEnd(4,o)).padEnd(4,"f")}${Wt(t.substring(i+4,i+8).padEnd(4,o)).padEnd(4,"f")}${Wt(o.padEnd(4,n).padEnd(4,o))}`}function Et(t){return function t(e){const i=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return e;if("Array"===i){const i=[];return e.forEach((e=>{i.push(t(e))})),i}if("Object"===i){const i={};Object.keys(e).forEach((n=>{i[n]=t(e[n])}));return Object.getOwnPropertySymbols(e).forEach((n=>{i[n]=t(e[n])})),i}}(t)}function kt(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const Ct={type(t,e){const i=kt(t);return!0===e?i.toLocaleLowerCase():i},array:t=>"Array"===kt(t),json:t=>"Object"===kt(t),function:t=>"Function"===kt(t),asyncFunction:t=>"AsyncFunction"===kt(t),boolean:t=>"Boolean"===kt(t),string:t=>"String"===kt(t),number:t=>"Number"===kt(t),undefined:t=>"Undefined"===kt(t),null:t=>"Null"===kt(t),promise:t=>"Promise"===kt(t)};var Ot=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const{Image:Tt}=window;function At(t){return new Promise(((e,i)=>{const n=new Tt;n.crossOrigin="anonymous",n.onload=function(){e(n)},n.onabort=i,n.onerror=i,n.src=t}))}function jt(t){return Ot(this,void 0,void 0,(function*(){const e=yield function(t){return new Promise(((e,i)=>{const n=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(n),o.onload=function(t){var i;const n=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(n)},o.onerror=function(t){i(t)}}))}(t);return yield At(e)}))}function Rt(t,e){return Ot(this,void 0,void 0,(function*(){t=t.replace(/\&/gi,"&");const i=yield function(t,e){const{width:i,height:n}=e;return new Promise(((e,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${n||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),s=new FileReader;s.readAsDataURL(a),s.onload=function(t){var i;const n=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(n)},s.onerror=function(t){o(t)}}))}(t,e);return yield At(i)}))}function Dt(t){return"number"==typeof t&&(t>0||t<=0)}function Lt(t){return"number"==typeof t&&t>=0}function $t(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function Bt(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const Ht={x:function(t){return Dt(t)},y:function(t){return Dt(t)},w:Lt,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:Dt,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return Lt(t)},borderRadius:function(t){return Dt(t)&&t>=0},color:function(t){return It(t)},imageSrc:function(t){return Bt(t)||$t(t)},imageURL:$t,imageBase64:Bt,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let i=document.createElement("div");i.innerHTML=t,i.children.length>0&&(e=!0),i=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}};var Xt,Yt=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)};class Ft{constructor(){Xt.set(this,void 0),function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(t,i):o?o.value=i:e.set(t,i)}(this,Xt,new Map,"f")}on(t,e){if(Yt(this,Xt,"f").has(t)){const i=Yt(this,Xt,"f").get(t)||[];null==i||i.push(e),Yt(this,Xt,"f").set(t,i)}else Yt(this,Xt,"f").set(t,[e])}off(t,e){if(Yt(this,Xt,"f").has(t)){const i=Yt(this,Xt,"f").get(t);if(Array.isArray(i))for(let t=0;t<(null==i?void 0:i.length);t++)if(i[t]===e){i.splice(t,1);break}Yt(this,Xt,"f").set(t,i||[])}}trigger(t,e){const i=Yt(this,Xt,"f").get(t);return!!Array.isArray(i)&&(i.forEach((t=>{t(e)})),!0)}has(t){if(Yt(this,Xt,"f").has(t)){const e=Yt(this,Xt,"f").get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){Yt(this,Xt,"f").clear()}}Xt=new WeakMap;var Vt,Nt,Ut,Gt,qt=function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,i):o?o.value=i:e.set(t,i),i},Qt=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)};class Kt{constructor(t){Vt.add(this),Nt.set(this,void 0),Ut.set(this,void 0),qt(this,Ut,Et(t.defaultStorage),"f"),qt(this,Nt,Qt(this,Vt,"m",Gt).call(this),"f")}set(t,e){Qt(this,Nt,"f")[t]=e}get(t){return Qt(this,Nt,"f")[t]}getSnapshot(){return Et(Qt(this,Nt,"f"))}clear(){qt(this,Nt,Qt(this,Vt,"m",Gt).call(this),"f")}destroy(){qt(this,Nt,null,"f")}}function Jt(t){return t/180*Math.PI}function Zt(t,e,i){const n=_t(e);!function(t,e,i,n){const o=Jt(e||0);i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(o),t.translate(-i.x,-i.y)),n(t),i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(-o),t.translate(-i.x,-i.y))}(t,e.angle||0,n,(()=>{i(t)}))}function _t(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function te(t,e,i){const n=function(t,e){const i=e.x-t.x,n=e.y-t.y;if(0===i){if(n<0)return 0;if(n>0)return Math.PI}else if(0===n){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&n<0?Math.atan(Math.abs(i)/Math.abs(n)):i>0&&n>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):0}(t,e);let o=n+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const a=function(t,e){const i=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===i?i:Math.sqrt(i)}(t,e);let s=0,r=0;return 0===o?(s=0,r=0-a):o>0&&o<Math.PI/2?(s=Math.sin(o)*a,r=0-Math.cos(o)*a):o===Math.PI/2?(s=a,r=0):o>Math.PI/2&&o<Math.PI?(s=Math.sin(Math.PI-o)*a,r=Math.cos(Math.PI-o)*a):o===Math.PI?(s=0,r=a):o>Math.PI&&o<1.5*Math.PI?(s=0-Math.sin(o-Math.PI)*a,r=Math.cos(o-Math.PI)*a):o===1.5*Math.PI?(s=0-a,r=0):o>1.5*Math.PI&&o<2*Math.PI?(s=0-Math.sin(2*Math.PI-o)*a,r=0-Math.cos(2*Math.PI-o)*a):o===2*Math.PI&&(s=0,r=0-a),s+=t.x,r+=t.y,{x:s,y:r}}function ee(t){const{angle:e=0}=t;return function(t,e,i){const{x:n,y:o,w:a,h:s}=t;let r={x:n,y:o},l={x:n+a,y:o},h={x:n+a,y:o+s},c={x:n,y:o+s};if(i&&(i>0||i<0)){const t=Jt(function(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}(i));r=te(e,r,t),l=te(e,l,t),h=te(e,h,t),c=te(e,c,t)}return[r,l,h,c]}(t,_t(t),e)}function ie(t,e){const{viewScaleInfo:i}=e,{x:n,y:o,w:a,h:s,angle:r}=t,{scale:l,offsetTop:h,offsetLeft:c}=i;return{x:n*l+c,y:o*l+h,w:a*l,h:s*l,angle:r}}function ne(t,e){const{context2d:i,element:n,viewScaleInfo:o,viewSizeInfo:a}=e,{angle:s=0}=n,{x:r,y:l,w:h,h:c}=ie(n,{viewScaleInfo:o,viewSizeInfo:a}),f=ee({x:r,y:l,w:h,h:c,angle:s});if(f.length>=2){i.beginPath(),i.moveTo(f[0].x,f[0].y);for(let t=1;t<f.length;t++)i.lineTo(f[t].x,f[t].y);i.closePath()}return!!i.isPointInPath(t.x,t.y)}function oe(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e}Nt=new WeakMap,Ut=new WeakMap,Vt=new WeakSet,Gt=function(){return Et(Qt(this,Ut,"f"))};const ae={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 se(t,e){const{viewScaleInfo:i}=e,{scale:n}=i;let{borderRadius:o}=t.detail;const{boxSizing:a=ae.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:r,y:l,w:h,h:c}=t,f=[0,0,0,0];if("number"==typeof o){const t=o*n;f=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(f=[o[0]*n,o[1]*n,o[2]*n,o[3]*n]);let d=0;return"number"==typeof s&&(d=(s||0)*n),"border-box"===a?(r=t.x+d/2,l=t.y+d/2,h=t.w-d,c=t.h-d):"content-box"===a?(r=t.x-d/2,l=t.y-d/2,h=t.w+d,c=t.h+d):(r=t.x,l=t.y,h=t.w,c=t.h),h=Math.max(h,1),c=Math.max(c,1),f=f.map((t=>Math.min(t,h/2,c/2))),{x:r,y:l,w:h,h:c,radiusList:f}}function re(t,e,i){if("string"==typeof e)return e;const{viewElementSize:n,viewScaleInfo:o,opacity:a=1}=i,{x:s,y:r}=n,{scale:l}=o;if("linear-gradient"===(null==e?void 0:e.type)){const{start:i,end:n,stops:o}=e,h={x:s+i.x*l,y:r+i.y*l},c={x:s+n.x*l,y:r+n.y*l},f=t.createLinearGradient(h.x,h.y,c.x,c.y);return o.forEach((t=>{f.addColorStop(t.offset,Mt(t.color,a))})),f}if("radial-gradient"===(null==e?void 0:e.type)){const{inner:i,outer:n,stops:o}=e,h={x:s+i.x*l,y:r+i.y*l,radius:i.radius*l},c={x:s+n.x*l,y:r+n.y*l,radius:n.radius*l},f=t.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return o.forEach((t=>{f.addColorStop(t.offset,Mt(t.color,a))})),f}return"#000000"}const le={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 he(t){var e,i,n,o;let a=1;return void 0!==(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.opacity)&&(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.opacity)>=0&&(null===(n=null==t?void 0:t.detail)||void 0===n?void 0:n.opacity)<=1&&(a=null===(o=null==t?void 0:t.detail)||void 0===o?void 0:o.opacity),a}function ce(t,e,i){const{pattern:n,renderContent:o,originElem:a,calcElemSize:s,viewScaleInfo:r,viewSizeInfo:l}=i||{},{parentOpacity:h}=i,c=he(a)*h;!function(t,e,i){const{renderContent:n,originElem:o,calcElemSize:a,viewSizeInfo:s}=i,r=s.devicePixelRatio,{clipPath:l}=(null==o?void 0:o.detail)||{};if(l&&a&&l.commands){const{x:i,y:o,w:s,h:h}=a,{originW:c,originH:f,originX:d,originY:u}=l,w=s/c,v=h/f,g=i-d*w,p=o-u*v;t.save(),t.translate(g,p),t.scale(r*w,r*v);const y=oe(l.commands||[]),m=new Path2D(y);t.clip(m),t.translate(0-g,0-p),t.setTransform(1,0,0,1,0,0),Zt(t,Object.assign({},e),(()=>{null==n||n()})),t.restore()}else null==n||n()}(t,e,{originElem:a,calcElemSize:s,viewScaleInfo:r,viewSizeInfo:l,renderContent:()=>{t.globalAlpha=c,function(t,e,i){var n,o;const{pattern:a,viewScaleInfo:s,viewSizeInfo:r}=i,l=[];if(e.detail.background||a){const{x:i,y:h,w:c,h:f,radiusList:d}=se(e,{viewScaleInfo:s,viewSizeInfo:r});if(t.beginPath(),t.moveTo(i+d[0],h),t.arcTo(i+c,h,i+c,h+f,d[1]),t.arcTo(i+c,h+f,i,h+f,d[2]),t.arcTo(i,h+f,i,h,d[3]),t.arcTo(i,h,i+c,h,d[0]),t.closePath(),"string"==typeof a)t.fillStyle=a;else if(["CanvasPattern"].includes(Ct.type(a)))t.fillStyle=a;else if("string"==typeof e.detail.background)t.fillStyle=e.detail.background;else if("linear-gradient"===(null===(n=e.detail.background)||void 0===n?void 0:n.type)){const n=re(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:f},viewScaleInfo:s,opacity:t.globalAlpha});t.fillStyle=n}else if("radial-gradient"===(null===(o=e.detail.background)||void 0===o?void 0:o.type)){const n=re(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:f},viewScaleInfo:s,opacity:t.globalAlpha});if(t.fillStyle=n,l&&l.length>0)for(let e=0;e<(null==l?void 0:l.length);e++){const n=l[e];"translate"===n.method?t.translate(n.args[0]+i,n.args[1]+h):"rotate"===n.method?t.rotate(...n.args):"scale"===n.method&&t.scale(...n.args)}}t.fill(),l&&l.length>0&&t.setTransform(1,0,0,1,0,0)}}(t,e,{pattern:n,viewScaleInfo:r,viewSizeInfo:l}),null==o||o(),function(t,e,i){if(0===e.detail.borderWidth)return;if(!It(e.detail.borderColor))return;const{viewScaleInfo:n}=i,{scale:o}=n;let a=le.borderColor;!0===It(e.detail.borderColor)&&(a=e.detail.borderColor);const{borderWidth:s,borderRadius:r,borderDash:l,boxSizing:h=le.boxSizing}=e.detail;let c=0;"number"==typeof s&&(c=s||1);c*=o;let f=[0,0,0,0];if("number"==typeof r){const t=r*o;f=[t,t,t,t]}else Array.isArray(r)&&4===(null==r?void 0:r.length)&&(f=[r[0]*o,r[1]*o,r[2]*o,r[3]*o]);t.strokeStyle=a;let d=[];Array.isArray(l)&&l.length>0&&(d=l.map((t=>Math.ceil(t*o))));let u=0,w=0,v=0,g=0;Array.isArray(s)&&(u=(s[0]||0)*o,w=(s[1]||0)*o,v=(s[2]||0)*o,g=(s[3]||0)*o);if(g||w||u||v){t.lineCap="butt";let{x:i,y:n,w:o,h:a}=e;"border-box"===h?(i+=g/2,n+=u/2,o=o-g/2-w/2,a=a-u/2-v/2):"content-box"===h?(i-=g/2,n-=u/2,o=o+g/2+w/2,a=a+u/2+v/2):(i=e.x,n=e.y,o=e.w,a=e.h),u&&(t.beginPath(),t.lineWidth=u,t.moveTo(i-g/2,n),t.lineTo(i+o+w/2,n),t.closePath(),t.stroke()),w&&(t.beginPath(),t.lineWidth=w,t.moveTo(i+o,n-u/2),t.lineTo(i+o,n+a+v/2),t.closePath(),t.stroke()),v&&(t.beginPath(),t.lineWidth=v,t.moveTo(i-g/2,n+a),t.lineTo(i+o+w/2,n+a),t.closePath(),t.stroke()),g&&(t.beginPath(),t.lineWidth=g,t.moveTo(i,n-u/2),t.lineTo(i,n+a+v/2),t.closePath(),t.stroke())}else{let{x:i,y:n,w:o,h:a}=e;"border-box"===h?(i=e.x+c/2,n=e.y+c/2,o=e.w-c,a=e.h-c):"content-box"===h?(i=e.x-c/2,n=e.y-c/2,o=e.w+c,a=e.h+c):(i=e.x,n=e.y,o=e.w,a=e.h),d.length>0?t.lineCap="butt":t.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),f=f.map((t=>Math.min(t,o/2,a/2))),t.setLineDash(d),t.lineWidth=c,t.beginPath(),t.moveTo(i+f[0],n),t.arcTo(i+o,n,i+o,n+a,f[1]),t.arcTo(i+o,n+a,i,n+a,f[2]),t.arcTo(i,n+a,i,n,f[3]),t.arcTo(i,n,i+o,n,f[0]),t.closePath(),t.stroke()}t.setLineDash([])}(t,e,{viewScaleInfo:r,viewSizeInfo:l}),t.globalAlpha=h}})}function fe(t,e,i){const{detail:n}=e,{viewScaleInfo:o,renderContent:a}=i,{shadowColor:s,shadowOffsetX:r,shadowOffsetY:l,shadowBlur:h}=n;Ht.number(h)?(t.save(),t.shadowColor=s||le.shadowColor,t.shadowOffsetX=(r||0)*o.scale,t.shadowOffsetY=(l||0)*o.scale,t.shadowBlur=(h||0)*o.scale,a(),t.restore()):(t.save(),t.shadowColor="transparent",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,a(),t.restore())}const de={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 ue(t,e,i){var n;if(!0===(null===(n=null==e?void 0:e.operations)||void 0===n?void 0:n.invisible))return;const{w:o,h:a}=e,{scale:s}=i.viewScaleInfo;if(!(s<1&&(o*s<1||a*s<1)||0===i.parentOpacity))try{switch(e.type){case"rect":!function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,{x:r,y:l,w:h,h:c,angle:f}=(null==n?void 0:n.elementSize(e,o,a))||e,d=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:f});Zt(t,{x:r,y:l,w:h,h:c,angle:f},(()=>{fe(t,d,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ce(t,d,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:f},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{}})}})}))}(t,e,i);break;case"circle":!function(t,e,i){const{detail:n,angle:o}=e,{calculator:a,viewScaleInfo:s,viewSizeInfo:r,parentOpacity:l}=i,{background:h="#000000",borderColor:c="#000000",boxSizing:f,borderWidth:d=0}=n;let u=0;"number"==typeof d&&d>0?u=d:Array.isArray(d)&&"number"==typeof d[0]&&d[0]>0&&(u=d[0]),u*=s.scale;const{x:w,y:v,w:g,h:p}=(null==a?void 0:a.elementSize({x:e.x,y:e.y,w:e.w,h:e.h},s,r))||e,y=Object.assign(Object.assign({},e),{x:w,y:v,w:g,h:p,angle:o});Zt(t,{x:w,y:v,w:g,h:p,angle:o},(()=>{fe(t,y,{viewScaleInfo:s,viewSizeInfo:r,renderContent:()=>{let e=g/2,i=p/2;const n=w+e,o=v+i;if(u>0&&("border-box"===f?(e-=u,i-=u):"center-line"===f?(e-=u/2,i-=u/2):(e-=u,i-=u)),e>=0&&i>=0){const a=he(y)*l;if(t.globalAlpha=a,"number"==typeof u&&u>0){const a=u/2+e,s=u/2+i;t.beginPath(),t.strokeStyle=c,t.lineWidth=u,t.circle(n,o,a,s,0,0,2*Math.PI),t.closePath(),t.stroke()}t.beginPath();const r=re(t,h,{viewElementSize:{x:w,y:v,w:g,h:p},viewScaleInfo:s,opacity:t.globalAlpha});t.fillStyle=r,t.circle(n,o,e,i,0,0,2*Math.PI),t.closePath(),t.fill(),t.globalAlpha=l}}})}))}(t,e,i);break;case"text":!function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,{x:r,y:l,w:h,h:c,angle:f}=(null==n?void 0:n.elementSize(e,o,a))||e,d=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:f});Zt(t,{x:r,y:l,w:h,h:c,angle:f},(()=>{ce(t,d,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:f},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const i=Object.assign(Object.assign({},de),e.detail),n=(i.fontSize||de.fontSize)*o.scale,a=i.lineHeight?i.lineHeight*o.scale:n;t.fillStyle=e.detail.color||de.color,t.textBaseline="top",t.$setFont({fontWeight:i.fontWeight,fontSize:n,fontFamily:i.fontFamily});const s=i.text.replace(/\r\n/gi,"\n"),f=a,d=s.split("\n"),u=[];let w=0;d.forEach(((e,i)=>{let n="";if(e.length>0){for(let o=0;o<e.length&&(t.measureText(n+(e[o]||"")).width<t.$doPixelRatio(h)?n+=e[o]||"":(u.push({text:n,width:t.$undoPixelRatio(t.measureText(n).width)}),n=e[o]||"",w++),!((w+1)*f>c));o++)if(e.length-1===o&&(w+1)*f<c){u.push({text:n,width:t.$undoPixelRatio(t.measureText(n).width)}),i<d.length-1&&w++;break}}else u.push({text:"",width:0})}));let v=0;u.length*f<c&&("top"===e.detail.verticalAlign?v=0:"bottom"===e.detail.verticalAlign?v+=c-u.length*f:v+=(c-u.length*f)/2);{const e=l+v;void 0!==i.textShadowColor&&It(i.textShadowColor)&&(t.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&Ht.number(i.textShadowOffsetX)&&(t.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&Ht.number(i.textShadowOffsetY)&&(t.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&Ht.number(i.textShadowBlur)&&(t.shadowBlur=i.textShadowBlur),u.forEach(((n,o)=>{let a=r;"center"===i.textAlign?a=r+(h-n.width)/2:"right"===i.textAlign&&(a=r+(h-n.width)),t.fillText(n.text,a,e+f*o)}))}}})}))}(t,e,i);break;case"image":!function(t,e,i){const n=i.loader.getContent(e),{calculator:o,viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r}=i,{x:l,y:h,w:c,h:f,angle:d}=(null==o?void 0:o.elementSize(e,a,s))||e,u=Object.assign(Object.assign({},e),{x:l,y:h,w:c,h:f,angle:d});Zt(t,{x:l,y:h,w:c,h:f,angle:d},(()=>{fe(t,u,{viewScaleInfo:a,viewSizeInfo:s,renderContent:()=>{ce(t,u,{originElem:e,calcElemSize:{x:l,y:h,w:c,h:f,angle:d},viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r,renderContent:()=>{if(n||i.loader.isDestroyed()||i.loader.load(e,i.elementAssets||{}),"image"===e.type&&n){t.globalAlpha=he(e)*r;const{x:i,y:o,w:l,h:h,radiusList:c}=se(u,{viewScaleInfo:a,viewSizeInfo:s});t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(i+c[0],o),t.arcTo(i+l,o,i+l,o+h,c[1]),t.arcTo(i+l,o+h,i,o+h,c[2]),t.arcTo(i,o+h,i,o,c[3]),t.arcTo(i,o,i+l,o,c[0]),t.closePath(),t.fill(),t.clip(),t.drawImage(n,i,o,l,h),t.globalAlpha=r,t.restore()}}})}})}))}(t,e,i);break;case"svg":!function(t,e,i){const n=i.loader.getContent(e),{calculator:o,viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r}=i,{x:l,y:h,w:c,h:f,angle:d}=(null==o?void 0:o.elementSize(e,a,s))||e;Zt(t,{x:l,y:h,w:c,h:f,angle:d},(()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.elementAssets||{}),"svg"===e.type&&n&&(t.globalAlpha=he(e)*r,t.drawImage(n,l,h,c,f),t.globalAlpha=r)}))}(t,e,i);break;case"html":!function(t,e,i){const n=i.loader.getContent(e),{calculator:o,viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r}=i,{x:l,y:h,w:c,h:f,angle:d}=(null==o?void 0:o.elementSize(e,a,s))||e;Zt(t,{x:l,y:h,w:c,h:f,angle:d},(()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.elementAssets||{}),"html"===e.type&&n&&(t.globalAlpha=he(e)*r,t.drawImage(n,l,h,c,f),t.globalAlpha=r)}))}(t,e,i);break;case"path":!function(t,e,i){const{detail:n}=e,{originX:o,originY:a,originW:s,originH:r}=n,{calculator:l,viewScaleInfo:h,viewSizeInfo:c,parentOpacity:f}=i,{x:d,y:u,w:w,h:v,angle:g}=(null==l?void 0:l.elementSize(e,h,c))||e,p=w/s,y=v/r,m=d-o*p,x=u-a*y,b=h.scale*c.devicePixelRatio,S=Object.assign(Object.assign({},e),{x:d,y:u,w:w,h:v,angle:g});Zt(t,{x:d,y:u,w:w,h:v,angle:g},(()=>{ce(t,S,{originElem:e,calcElemSize:{x:d,y:u,w:w,h:v,angle:g},viewScaleInfo:h,viewSizeInfo:c,parentOpacity:f,renderContent:()=>{fe(t,S,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{t.save(),t.translate(m,x),t.scale(b*p/h.scale,b*y/h.scale);const e=oe(n.commands||[]),i=new Path2D(e);n.fill&&(t.fillStyle=n.fill,t.fill(i)),n.stroke&&0!==n.strokeWidth&&(t.strokeStyle=n.stroke,t.lineWidth=(n.strokeWidth||1)/c.devicePixelRatio,t.lineCap=n.strokeLineCap||"square",t.stroke(i)),t.translate(-m,-x),t.restore()}})}})}))}(t,e,i);break;case"group":{const n=Object.assign(Object.assign({},i.elementAssets||{}),e.detail.assets||{});!function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,{x:r,y:l,w:h,h:c,angle:f}=(null==n?void 0:n.elementSize({x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle},o,a))||e,d=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:f});Zt(t,{x:r,y:l,w:h,h:c,angle:f},(()=>{t.globalAlpha=he(e)*s,fe(t,d,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ce(t,d,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:f},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const{x:n,y:r,w:l,h:h,radiusList:c}=se(d,{viewScaleInfo:o,viewSizeInfo:a});if("hidden"===e.detail.overflow&&(t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(n+c[0],r),t.arcTo(n+l,r,n+l,r+h,c[1]),t.arcTo(n+l,r+h,n,r+h,c[2]),t.arcTo(n,r+h,n,r,c[3]),t.arcTo(n,r,n+l,r,c[0]),t.closePath(),t.fill(),t.clip()),Array.isArray(e.detail.children)){const{parentElementSize:n}=i,o={x:n.x+e.x,y:n.y+e.y,w:e.w||n.w,h:e.h||n.h,angle:e.angle},{calculator:a}=i;for(let n=0;n<e.detail.children.length;n++){let r=e.detail.children[n];if(r=Object.assign(Object.assign({},r),{x:o.x+r.x,y:o.y+r.y}),!0===i.forceDrawAll||(null==a?void 0:a.isElementInView(r,i.viewScaleInfo,i.viewSizeInfo)))try{ue(t,r,Object.assign(Object.assign({},i),{parentOpacity:s*he(e)}))}catch(t){console.error(t)}}}"hidden"===e.detail.overflow&&t.restore()}})}}),t.globalAlpha=s}))}(t,e,Object.assign(Object.assign({},i),{elementAssets:n}));break}}}catch(t){console.error(t)}}const we={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"};var ve,ge,pe,ye,me,xe,be,Se,Ie,Me,ze,We,Pe=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},Ee=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)},ke=function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,i):o?o.value=i:e.set(t,i),i};const Ce=["image","svg","html"],Oe=t=>{var e,i,n;let o=null;return"image"===t.type?o=(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.src)||null:"svg"===t.type?o=(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.svg)||null:"html"===t.type&&(o=(null===(n=null==t?void 0:t.detail)||void 0===n?void 0:n.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:Pt(o):Pt(`${zt()}-${t.uuid}-${zt()}-${zt()}`)};class Te extends Ft{constructor(){super(),ve.add(this),ge.set(this,{}),pe.set(this,{}),ye.set(this,{}),me.set(this,!1),Ee(this,ve,"m",xe).call(this,"image",((t,e)=>Pe(this,void 0,void 0,(function*(){var i;const n=(null===(i=e[t.detail.src])||void 0===i?void 0:i.value)||t.detail.src,o=yield At(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),Ee(this,ve,"m",xe).call(this,"html",((t,e)=>Pe(this,void 0,void 0,(function*(){var i;const n=(null===(i=e[t.detail.html])||void 0===i?void 0:i.value)||t.detail.html,o=yield Rt(n,{width:t.detail.originW||t.w,height:t.detail.originH||t.h});return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),Ee(this,ve,"m",xe).call(this,"svg",((t,e)=>Pe(this,void 0,void 0,(function*(){var i;const n=(null===(i=e[t.detail.svg])||void 0===i?void 0:i.value)||t.detail.svg,o=yield jt(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}}))))}isDestroyed(){return Ee(this,me,"f")}destroy(){ke(this,me,!0,"f"),this.clear(),ke(this,ge,null,"f"),ke(this,pe,null,"f"),ke(this,ye,null,"f")}load(t,e){!0!==Ee(this,me,"f")&&(Ee(this,ve,"m",We).call(this,t)||Ce.includes(t.type)&&Ee(this,ve,"m",ze).call(this,t,e))}getContent(t){var e,i;const n=Oe(t);return(null===(i=null===(e=Ee(this,ye,"f"))||void 0===e?void 0:e[n])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return Ee(this,ye,"f")}setLoadItemMap(t){ke(this,ye,t,"f")}}ge=new WeakMap,pe=new WeakMap,ye=new WeakMap,me=new WeakMap,ve=new WeakSet,xe=function(t,e){Ee(this,ge,"f")[t]=e},be=function(t){var e,i,n;let o=null;return"image"===t.type?o=(null===(e=null==t?void 0:t.detail)||void 0===e?void 0:e.src)||null:"svg"===t.type?o=(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.svg)||null:"html"===t.type&&(o=(null===(n=null==t?void 0:t.detail)||void 0===n?void 0:n.html)||null),o},Se=function(t){return{element:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:Ee(this,ve,"m",be).call(this,t)}},Ie=function(t){const e=Oe(t.element),i=Ee(this,ye,"f")[e];Ee(this,me,"f")||(i?i.startTime<t.startTime&&(Ee(this,ye,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(Ee(this,ye,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))))},Me=function(t){var e;const i=Oe(t.element),n=null===(e=Ee(this,ye,"f"))||void 0===e?void 0:e[i];Ee(this,me,"f")||(n?n.startTime<t.startTime&&(Ee(this,ye,"f")[i]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(Ee(this,ye,"f")[i]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))))},ze=function(t,e){const i=Ee(this,ve,"m",Se).call(this,t),n=Oe(t);if(Ee(this,pe,"f")[n])return;Ee(this,pe,"f")[n]=i;const o=Ee(this,ge,"f")[t.type];"function"!=typeof o||Ee(this,me,"f")||(i.startTime=Date.now(),o(t,e).then((t=>{Ee(this,me,"f")||(i.content=t.content,i.endTime=Date.now(),i.status="load",Ee(this,ve,"m",Ie).call(this,i))})).catch((e=>{console.warn(`Load element source "${i.source}" fail`,e,t),i.endTime=Date.now(),i.status="error",i.error=e,Ee(this,ve,"m",Me).call(this,i)})))},We=function(t){var e;const i=Oe(t),n=null===(e=Ee(this,pe,"f"))||void 0===e?void 0:e[i];return!(!n||"error"!==n.status||!n.source||n.source!==Ee(this,ve,"m",be).call(this,t))};var Ae,je,Re,De,Le,$e=function(t,e,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(t,i):o?o.value=i:e.set(t,i),i},Be=function(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)};class He extends Ft{constructor(t){super(),Ae.add(this),je.set(this,void 0),Re.set(this,new Te),De.set(this,!1),$e(this,je,t,"f"),Be(this,Ae,"m",Le).call(this)}isDestroyed(){return Be(this,De,"f")}destroy(){this.clear(),$e(this,je,null,"f"),Be(this,Re,"f").destroy(),$e(this,Re,null,"f"),$e(this,De,!0,"f")}updateOptions(t){$e(this,je,t,"f")}drawData(t,e){const i=Be(this,Re,"f"),{calculator:n}=Be(this,je,"f"),o=Be(this,je,"f").viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);const a={x:0,y:0,w:e.viewSizeInfo.width,h:e.viewSizeInfo.height};t.underlay&&function(t,e,i){const{calculator:n,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s}=i,r=Object.assign({uuid:"underlay"},e),{x:l,y:h,w:c,h:f}=(null==n?void 0:n.elementSize(r,o,a))||r,d=Object.assign(Object.assign({},r),{x:l,y:h,w:c,h:f,angle:0});fe(t,d,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ce(t,d,{originElem:r,calcElemSize:{x:l,y:h,w:c,h:f,angle:0},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{}})}})}(o,t.underlay,Object.assign({loader:i,calculator:n,parentElementSize:a,parentOpacity:1},e)),function(t,e,i){var n;const{elements:o=[]}=e,{parentOpacity:a}=i;for(let e=0;e<o.length;e++){const s=o[e],r=Object.assign(Object.assign({},s),{detail:Object.assign(Object.assign({},we),null==s?void 0:s.detail)});if(!0===i.forceDrawAll||(null===(n=i.calculator)||void 0===n?void 0:n.isElementInView(r,i.viewScaleInfo,i.viewSizeInfo)))try{ue(t,r,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(t){console.error(t)}}}(o,t,Object.assign({loader:i,calculator:n,parentElementSize:a,elementAssets:t.assets,parentOpacity:1},e))}scale(t){const{sharer:e}=Be(this,je,"f");if(!e)return;const{data:i,offsetTop:n,offsetBottom:o,offsetLeft:a,offsetRight:s,width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:f}=e.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:t,offsetTop:n,offsetBottom:o,offsetLeft:a,offsetRight:s},viewSizeInfo:{width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:f}})}setLoadItemMap(t){Be(this,Re,"f").setLoadItemMap(t)}getLoadItemMap(){return Be(this,Re,"f").getLoadItemMap()}getLoader(){return Be(this,Re,"f")}}je=new WeakMap,Re=new WeakMap,De=new WeakMap,Ae=new WeakSet,Le=function(){const t=Be(this,Re,"f");t.on("load",(t=>{this.trigger("load",t)})),t.on("error",(t=>{console.error(t)}))};class Xe{constructor(t){mt(this,e,void 0),xt(this,e,t)}destroy(){xt(this,e,null)}elementSize(t,e,i){return ie(t,{viewScaleInfo:e,viewSizeInfo:i})}isElementInView(t,e,i){return function(t,e){const{viewSizeInfo:i,viewScaleInfo:n}=e,{width:o,height:a}=i,{angle:s}=t,{x:r,y:l,w:h,h:c}=ie(t,{viewScaleInfo:n,viewSizeInfo:i}),f=ee({x:r,y:l,w:h,h:c,angle:s}),d={x:0,y:0,w:o,h:a},u=Math.min(f[0].x,f[1].x,f[2].x,f[3].x),w=Math.min(f[0].y,f[1].y,f[2].y,f[3].y);return function(t,e){const i=t.x,n=t.y,o=t.x+t.w,a=t.y+t.h,s=e.x,r=e.y,l=e.x+e.w,h=e.y+e.h;return i<=l&&o>=s&&n<=h&&a>=r}(d,{x:u,y:w,w:Math.max(f[0].x,f[1].x,f[2].x,f[3].x)-u,h:Math.max(f[0].y,f[1].y,f[2].y,f[3].y)-w})}(t,{viewScaleInfo:e,viewSizeInfo:i})}isPointInElement(t,i,n,o){return ne(t,{context2d:yt(this,e).viewContext,element:i,viewScaleInfo:n,viewSizeInfo:o})}getPointElement(t,i){return function(t,e){var i,n,o;const{context2d:a,data:s,viewScaleInfo:r,viewSizeInfo:l,groupQueue:h}=e,c={index:-1,element:null,groupQueueIndex:-1};if(h&&Array.isArray(h)&&(null==h?void 0:h.length)>0)for(let e=h.length-1;e>=0;e--){let o=0,s=0,f=0;for(let t=0;t<=e;t++)o+=h[t].x,s+=h[t].y,f+=h[t].angle||0;const d=h[e];if(d&&"group"===d.type&&Array.isArray(null===(i=d.detail)||void 0===i?void 0:i.children))for(let i=0;i<d.detail.children.length;i++){const u=d.detail.children[i];if(!0!==(null===(n=null==u?void 0:u.operations)||void 0===n?void 0:n.invisible)){if(!u)break;if(ne(t,{context2d:a,element:{x:o+u.x,y:s+u.y,w:u.w,h:u.h,angle:f+(u.angle||0)},viewScaleInfo:r,viewSizeInfo:l})){c.element=u,(e<h.length-1||"group"!==u.type)&&(c.groupQueueIndex=e);break}}}if(c.element)break}if(c.element)return c;for(let e=s.elements.length-1;e>=0;e--){const i=s.elements[e];if(!0!==(null===(o=null==i?void 0:i.operations)||void 0===o?void 0:o.invisible)&&ne(t,{context2d:a,element:i,viewScaleInfo:r,viewSizeInfo:l})){c.index=e,c.element=i;break}}return c}(t,{...i,context2d:yt(this,e).viewContext})}}function Ye(t){return t>0||t<0||0===t}e=new WeakMap;class Fe extends Ft{constructor(t){super(),mt(this,a),mt(this,v),mt(this,p),mt(this,m),mt(this,i,void 0),mt(this,n,void 0),mt(this,o,!1),mt(this,r,(t=>{if(!bt(this,v,g).call(this,t))return;const e=bt(this,p,y).call(this,t);if(!bt(this,m,x).call(this,e))return;t.preventDefault(),t.stopPropagation();const i=t.deltaX>0||t.deltaX<0?t.deltaX:0,n=t.deltaY>0||t.deltaY<0?t.deltaY:0;!0===t.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:i,deltaY:n,point:e}):this.has("wheel")&&this.trigger("wheel",{deltaX:i,deltaY:n,point:e})})),mt(this,l,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)})),mt(this,h,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);if(!bt(this,m,x).call(this,e))return;const i=Date.now(),o=yt(this,n).get("prevClickPoint");o&&i-o.t<=500&&Math.abs(o.x-e.x)<=5&&Math.abs(o.y-e.y)<=5?this.trigger("doubleClick",{point:e}):yt(this,n).set("prevClickPoint",e)})),mt(this,c,(t=>{if(yt(this,n).set("hasPointDown",!1),!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);this.trigger("pointLeave",{point:e})})),mt(this,f,(t=>{if(yt(this,n).set("hasPointDown",!1),!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);this.trigger("pointEnd",{point:e})})),mt(this,d,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault(),t.stopPropagation();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)?!0===yt(this,n).get("hasPointDown")&&this.trigger("pointMove",{point:e}):yt(this,n).get("hasPointDown")&&(this.trigger("pointLeave",{point:e}),yt(this,n).set("hasPointDown",!1))})),mt(this,u,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)&&(yt(this,n).set("hasPointDown",!0),this.trigger("pointStart",{point:e}))})),mt(this,w,(t=>{if(!bt(this,v,g).call(this,t))return;t.preventDefault();const e=bt(this,p,y).call(this,t);bt(this,m,x).call(this,e)&&this.trigger("hover",{point:e})}));const e=new Kt({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});xt(this,n,e),xt(this,i,t),bt(this,a,s).call(this)}onEvents(){if(yt(this,o))return;const t=window;t.addEventListener("mousemove",yt(this,w)),t.addEventListener("mousedown",yt(this,u)),t.addEventListener("mousemove",yt(this,d)),t.addEventListener("mouseup",yt(this,f)),t.addEventListener("mouseleave",yt(this,c)),t.addEventListener("wheel",yt(this,r),{passive:!1}),t.addEventListener("click",yt(this,h)),t.addEventListener("contextmenu",yt(this,l))}offEvents(){const t=window;t.removeEventListener("mousemove",yt(this,w)),t.removeEventListener("mousedown",yt(this,u)),t.removeEventListener("mousemove",yt(this,d)),t.removeEventListener("mouseup",yt(this,f)),t.removeEventListener("mouseleave",yt(this,c)),t.removeEventListener("wheel",yt(this,r)),t.removeEventListener("click",yt(this,h)),t.removeEventListener("contextmenu",yt(this,l))}destroy(){this.offEvents(),yt(this,n).destroy(),xt(this,o,!0)}}i=new WeakMap,n=new WeakMap,o=new WeakMap,a=new WeakSet,s=function(){this.onEvents()},r=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,f=new WeakMap,d=new WeakMap,u=new WeakMap,w=new WeakMap,v=new WeakSet,g=function(t){return t.target===yt(this,i).boardContent.boardContext.canvas},p=new WeakSet,y=function(t){const e=yt(this,i).boardContent.boardContext.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top,t:Date.now()}},m=new WeakSet,x=function(t){const e=yt(this,i).sharer.getActiveViewSizeInfo(),{width:n,height:o}=e;return!!(Ye(t.x)&&Ye(t.y)&&t.x<=n&&t.y<=o)};const Ve={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class Ne{constructor(){mt(this,b,void 0),mt(this,S,void 0);const t=new Kt({defaultStorage:Ve}),e=new Kt({defaultStorage:{}});xt(this,b,t),xt(this,S,e)}getActiveStorage(t){return yt(this,b).get(t)}setActiveStorage(t,e){return yt(this,b).set(t,e)}getActiveStoreSnapshot(){return yt(this,b).getSnapshot()}getSharedStorage(t){return yt(this,S).get(t)}setSharedStorage(t,e){return yt(this,S).set(t,e)}getSharedStoreSnapshot(){return yt(this,S).getSnapshot()}getActiveViewScaleInfo(){return{scale:yt(this,b).get("scale"),offsetTop:yt(this,b).get("offsetTop"),offsetBottom:yt(this,b).get("offsetBottom"),offsetLeft:yt(this,b).get("offsetLeft"),offsetRight:yt(this,b).get("offsetRight")}}setActiveViewScaleInfo(t){const{scale:e,offsetTop:i,offsetBottom:n,offsetLeft:o,offsetRight:a}=t;yt(this,b).set("scale",e),yt(this,b).set("offsetTop",i),yt(this,b).set("offsetBottom",n),yt(this,b).set("offsetLeft",o),yt(this,b).set("offsetRight",a)}setActiveViewSizeInfo(t){yt(this,b).set("width",t.width),yt(this,b).set("height",t.height),yt(this,b).set("devicePixelRatio",t.devicePixelRatio),yt(this,b).set("contextWidth",t.contextWidth),yt(this,b).set("contextHeight",t.contextHeight)}getActiveViewSizeInfo(){return{width:yt(this,b).get("width"),height:yt(this,b).get("height"),devicePixelRatio:yt(this,b).get("devicePixelRatio"),contextWidth:yt(this,b).get("contextWidth"),contextHeight:yt(this,b).get("contextHeight")}}}b=new WeakMap,S=new WeakMap;const{requestAnimationFrame:Ue}=window;class Ge extends Ft{constructor(t){super(),mt(this,W),mt(this,E),mt(this,I,void 0),mt(this,M,[]),mt(this,z,"FREE"),xt(this,I,t),bt(this,W,P).call(this)}drawFrame(){const{sharer:t}=yt(this,I),e=t.getActiveStoreSnapshot(),i=t.getSharedStoreSnapshot();yt(this,M).push({activeStore:e,sharedStore:i}),bt(this,E,k).call(this)}scale(t){const{scale:e,point:i}=t,{sharer:n}=yt(this,I),{moveX:o,moveY:a}=function(t){const{scale:e,point:i,viewScaleInfo:n}=t,{offsetLeft:o,offsetTop:a}=n,s=e/n.scale,r=i.x,l=i.y;return{moveX:r-r*s+(o*s-o),moveY:l-l*s+(a*s-a)}}({scale:e,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",e),{moveX:o,moveY:a}}scroll(t){const{sharer:e}=yt(this,I),i=e.getActiveViewScaleInfo(),{moveX:n,moveY:o}=t,a=function(t){const{moveX:e=0,moveY:i=0,viewScaleInfo:n,viewSizeInfo:o}=t,{scale:a}=n,{width:s,height:r,contextWidth:l,contextHeight:h}=o;let c=n.offsetLeft,f=n.offsetRight,d=n.offsetTop,u=n.offsetBottom;return c+=e,d+=i,f=s-(l*a+c),u=r-(h*a+d),{scale:a,offsetTop:d,offsetLeft:c,offsetRight:f,offsetBottom:u}}({moveX:n,moveY:o,viewScaleInfo:i,viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(a),a}updateViewScaleInfo(t){const{sharer:e}=yt(this,I),i=function(t,e){const{scale:i,offsetX:n,offsetY:o}=t,{viewSizeInfo:a}=e,{width:s,height:r,contextWidth:l,contextHeight:h}=a,c=0-n*i,f=0-o*i;return{scale:i,offsetLeft:c,offsetTop:f,offsetRight:s-(l*i+c/i),offsetBottom:r-(h*i+f/i)}}(t,{viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(i),i}resize(t={}){const{sharer:e}=yt(this,I),i={...e.getActiveViewSizeInfo(),...t},{width:n,height:o,devicePixelRatio:a}=i,{underContext:s,boardContext:r,helperContext:l,viewContext:h}=yt(this,I).boardContent;return r.canvas.width=n*a,r.canvas.height=o*a,r.canvas.style.width=`${n}px`,r.canvas.style.height=`${o}px`,s.canvas.width=n*a,s.canvas.height=o*a,l.canvas.width=n*a,l.canvas.height=o*a,h.canvas.width=n*a,h.canvas.height=o*a,e.setActiveViewSizeInfo(i),i}}I=new WeakMap,M=new WeakMap,z=new WeakMap,W=new WeakSet,P=function(){const{renderer:t}=yt(this,I);t.on("load",(()=>{this.drawFrame()}))},E=new WeakSet,k=function(){if("DRAWING"===yt(this,z)||0===yt(this,M).length)return;xt(this,z,"DRAWING");const t=yt(this,M).shift(),{renderer:e,boardContent:i,beforeDrawFrame:n,afterDrawFrame:o}=yt(this,I);if(t){const{scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h,width:c,height:f,contextHeight:d,contextWidth:u,devicePixelRatio:w}=t.activeStore,v={scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h},g={width:c,height:f,contextHeight:d,contextWidth:u,devicePixelRatio:w};(null==t?void 0:t.activeStore.data)&&e.drawData(t.activeStore.data,{viewScaleInfo:v,viewSizeInfo:g}),n({snapshot:t}),i.drawView(),o({snapshot:t})}0!==yt(this,M).length?xt(this,z,"DRAWING")&&Ue((()=>{bt(this,E,k).call(this)})):xt(this,z,"COMPLETE")};return C=new WeakMap,O=new WeakMap,T=new WeakMap,A=new WeakMap,j=new WeakMap,R=new WeakMap,D=new WeakMap,L=new WeakMap,$=new WeakMap,B=new WeakMap,H=new WeakMap,X=new WeakSet,Y=function(){yt(this,j).on("pointStart",bt(this,F,V).bind(this)),yt(this,j).on("pointEnd",bt(this,N,U).bind(this)),yt(this,j).on("pointMove",St((t=>{bt(this,G,q).call(this,t)}),10)),yt(this,j).on("hover",St((t=>{bt(this,Q,K).call(this,t)}),10)),yt(this,j).on("wheel",St((t=>{bt(this,_,tt).call(this,t)}),10)),yt(this,j).on("wheelScale",St((t=>{bt(this,et,it).call(this,t)}),10)),yt(this,j).on("scrollX",bt(this,nt,ot).bind(this)),yt(this,j).on("scrollY",bt(this,at,st).bind(this)),yt(this,j).on("resize",bt(this,rt,lt).bind(this)),yt(this,j).on("doubleClick",bt(this,J,Z).bind(this)),yt(this,R).on("load",(()=>{yt(this,B).trigger("loadResource")}))},F=new WeakSet,V=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.pointStart)?void 0:e.call(n,t)))return}},N=new WeakSet,U=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.pointEnd)?void 0:e.call(n,t)))return}},G=new WeakSet,q=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.pointMove)?void 0:e.call(n,t)))return}},Q=new WeakSet,K=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.hover)?void 0:e.call(n,t)))return}},J=new WeakSet,Z=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.doubleClick)?void 0:e.call(n,t)))return}},_=new WeakSet,tt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.wheel)?void 0:e.call(n,t)))return}},et=new WeakSet,it=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.wheelScale)?void 0:e.call(n,t)))return}},nt=new WeakSet,ot=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.scrollX)?void 0:e.call(n,t)))return}},at=new WeakSet,st=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.scrollY)?void 0:e.call(n,t)))return}},rt=new WeakSet,lt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.resize)?void 0:e.call(n,t)))return}},ht=new WeakSet,ct=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.clear)?void 0:e.call(n,t)))return}},ft=new WeakSet,dt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.beforeDrawFrame)?void 0:e.call(n,t)))return}},ut=new WeakSet,wt=function(t){var e;for(let i=0;i<yt(this,A).length;i++){const n=yt(this,A)[i];if(!1===(null==(e=null==n?void 0:n.afterDrawFrame)?void 0:e.call(n,t)))return}},vt=new WeakSet,gt=function(){const t=[],e=yt(this,O);yt(this,T).forEach((i=>{const n=e.get(i);"enable"===(null==n?void 0:n.status)&&(null==n?void 0:n.middlewareObject)&&t.push(n.middlewareObject)})),xt(this,A,t)},t.Board=class{constructor(t){mt(this,X),mt(this,F),mt(this,N),mt(this,G),mt(this,Q),mt(this,J),mt(this,_),mt(this,et),mt(this,nt),mt(this,at),mt(this,rt),mt(this,ht),mt(this,ft),mt(this,ut),mt(this,vt),mt(this,C,void 0),mt(this,O,new WeakMap),mt(this,T,[]),mt(this,A,[]),mt(this,j,void 0),mt(this,R,void 0),mt(this,D,void 0),mt(this,L,void 0),mt(this,$,void 0),mt(this,B,new Ft),mt(this,H,!1);const{boardContent:e}=t,i=new Ne,n=new Xe({viewContext:e.viewContext}),o=new Fe({boardContent:e,sharer:i}),a=new He({viewContext:e.viewContext,sharer:i,calculator:n});xt(this,C,t),xt(this,D,i),xt(this,j,o),xt(this,R,a),xt(this,$,n),xt(this,L,new Ge({boardContent:t.boardContent,sharer:i,renderer:a,calculator:yt(this,$),beforeDrawFrame:t=>{bt(this,ft,dt).call(this,t)},afterDrawFrame:t=>{bt(this,ut,wt).call(this,t)}})),bt(this,X,Y).call(this),bt(this,vt,gt).call(this)}isDestroyed(){return yt(this,H)}destroy(){yt(this,j).destroy(),yt(this,R).destroy(),yt(this,$).destroy(),yt(this,B).destroy(),xt(this,H,!0)}getSharer(){return yt(this,D)}getViewer(){return yt(this,L)}getRenderer(){return yt(this,R)}setData(t){const e=yt(this,D);yt(this,D).setActiveStorage("data",t);const i=e.getActiveViewSizeInfo(),n=function(t,e){const i={x:0,y:0,w:0,h:0};t.forEach((t=>{const e={x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle};if(e.angle&&(e.angle>0||e.angle<0)){const t=ee(e);if(4===t.length){const i=[t[0].x,t[1].x,t[2].x,t[3].x],n=[t[0].y,t[1].y,t[2].y,t[3].y];e.x=Math.min(...i),e.y=Math.min(...n),e.w=Math.abs(Math.max(...i)-Math.min(...i)),e.h=Math.abs(Math.max(...n)-Math.min(...n))}}const n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),a=Math.max(e.x+e.w,i.x+i.w),s=Math.max(e.y+e.h,i.y+i.h);i.x=n,i.y=o,i.w=Math.abs(a-n),i.h=Math.abs(s-o)})),(null==e?void 0:e.extend)&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const n={contextWidth:i.w,contextHeight:i.h};return(null==e?void 0:e.viewWidth)&&(null==e?void 0:e.viewHeight)&&(null==e?void 0:e.viewWidth)>0&&(null==e?void 0:e.viewHeight)>0&&(e.viewWidth>i.x+i.w&&(n.contextWidth=e.viewWidth-i.x),e.viewHeight>i.y+i.h&&(n.contextHeight=e.viewHeight-i.y)),n}(t.elements,{viewWidth:i.width,viewHeight:i.height,extend:!0});yt(this,L).drawFrame();const o={...i,...n};return yt(this,D).setActiveViewSizeInfo(o),{viewSizeInfo:o}}getData(){const{data:t}=yt(this,D).getActiveStoreSnapshot();return t}use(t){var e,i,n;if(yt(this,O).has(t)){const n=yt(this,O).get(t);if(n)return null==(i=(e=n.middlewareObject).use)||i.call(e),n.status="enable",yt(this,O).set(t,n),void bt(this,vt,gt).call(this)}const{boardContent:o,container:a}=yt(this,C),s=t({boardContent:o,sharer:yt(this,D),viewer:yt(this,L),calculator:yt(this,$),eventHub:yt(this,B),container:a});null==(n=s.use)||n.call(s),yt(this,T).push(t),yt(this,A).push(s),yt(this,O).set(t,{status:"enable",middlewareObject:s}),bt(this,vt,gt).call(this)}disuse(t){var e,i;const n=yt(this,O).get(t);n&&(null==(i=(e=n.middlewareObject).disuse)||i.call(e),n.status="disable",yt(this,O).set(t,n),bt(this,vt,gt).call(this))}scale(t){const e=yt(this,L),{moveX:i,moveY:n}=e.scale(t);e.scroll({moveX:i,moveY:n})}scroll(t){return yt(this,L).scroll(t)}updateViewScaleInfo(t){return yt(this,L).updateViewScaleInfo(t)}resize(t){const e=yt(this,L).resize(t),{width:i,height:n,devicePixelRatio:o}=t,{boardContent:a}=yt(this,C);a.viewContext.$resize({width:i,height:n,devicePixelRatio:o}),a.helperContext.$resize({width:i,height:n,devicePixelRatio:o}),a.boardContext.$resize({width:i,height:n,devicePixelRatio:o}),a.underContext.$resize({width:i,height:n,devicePixelRatio:o}),yt(this,L).drawFrame(),yt(this,j).trigger("resize",e),yt(this,D).setActiveViewSizeInfo(t)}clear(){const{boardContent:t}=yt(this,C),{underContext:e,helperContext:i,viewContext:n,boardContext:o}=t;e.clearRect(0,0,e.canvas.width,e.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),n.clearRect(0,0,n.canvas.width,n.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),bt(this,ht,ct).call(this)}getEventHub(){return yt(this,B)}onWatcherEvents(){yt(this,j).onEvents()}offWatcherEvents(){yt(this,j).offEvents()}},t.Calculator=Xe,t.Sharer=Ne,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({}); |
{ | ||
"name": "@idraw/board", | ||
"version": "0.4.0-beta.14", | ||
"version": "0.4.0-beta.15", | ||
"description": "", | ||
@@ -24,8 +24,8 @@ "main": "dist/esm/index.js", | ||
"devDependencies": { | ||
"@idraw/types": "^0.4.0-beta.14" | ||
"@idraw/types": "^0.4.0-beta.15" | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"@idraw/util": "^0.4.0-beta.14", | ||
"@idraw/renderer": "^0.4.0-beta.14" | ||
"@idraw/util": "^0.4.0-beta.15", | ||
"@idraw/renderer": "^0.4.0-beta.15" | ||
}, | ||
@@ -32,0 +32,0 @@ "publishConfig": { |
Sorry, the diff of this file is too big to display
216344
3823