@idraw/board
Advanced tools
Comparing version 0.4.0-beta.8 to 0.4.0-beta.9
@@ -1,1 +0,1 @@ | ||
var iDrawBoard=function(t){"use strict";var e,i,n,o,a,s,r,l,h,c,d,f,u,w,v,g,p,y,m,x,S,b,I,M,z,P,W,k,C,E,O,T,A,j,R,L,D,$,H,B,X,Y,F,V,N,U,G,q,Q,K,J,Z,_,tt,et,it,nt,ot,at,st,rt,lt,ht,ct,dt,ft,ut,wt,vt=(t,e,i)=>{if(!e.has(t))throw TypeError("Cannot "+i)},gt=(t,e,i)=>(vt(t,e,"read from private field"),i?i.call(t):e.get(t)),pt=(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)},yt=(t,e,i,n)=>(vt(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),mt=(t,e,i)=>(vt(t,e,"access private method"),i);function xt(t,e){let i=-1;return function(...n){i>0||(i=setTimeout((()=>{t(...n),i=-1}),e))}}function St(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 bt(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 It(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function Mt(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 zt(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/${Mt(e.toString(16).padEnd(4,n))}${Mt(t.substring(i-4,i).padEnd(4,n)).padEnd(4,"f")}-${Mt(t.substring(i-8,i-4).padEnd(4,n)).padEnd(4,"f")}-${Mt(t.substring(i-12,i-8).padEnd(4,n)).padEnd(4,"f")}-${Mt(t.substring(i-16,i-12).padEnd(4,o)).padEnd(4,"f")}-${Mt(t.substring(i,i+4).padEnd(4,o)).padEnd(4,"f")}${Mt(t.substring(i+4,i+8).padEnd(4,o)).padEnd(4,"f")}${Mt(o.padEnd(4,n).padEnd(4,o))}`}function Pt(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 Wt(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const kt={type(t,e){const i=Wt(t);return!0===e?i.toLocaleLowerCase():i},array:t=>"Array"===Wt(t),json:t=>"Object"===Wt(t),function:t=>"Function"===Wt(t),asyncFunction:t=>"AsyncFunction"===Wt(t),string:t=>"String"===Wt(t),number:t=>"Number"===Wt(t),undefined:t=>"Undefined"===Wt(t),null:t=>"Null"===Wt(t),promise:t=>"Promise"===Wt(t)};var Ct=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:Et}=window;function Ot(t){return new Promise(((e,i)=>{const n=new Et;n.crossOrigin="anonymous",n.onload=function(){e(n)},n.onabort=i,n.onerror=i,n.src=t}))}function Tt(t){return Ct(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 Ot(e)}))}function At(t,e){return Ct(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 Ot(i)}))}function jt(t){return"number"==typeof t&&(t>0||t<=0)}function Rt(t){return"number"==typeof t&&t>=0}function Lt(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function Dt(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const $t={x:function(t){return jt(t)},y:function(t){return jt(t)},w:Rt,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:jt,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return Rt(t)},borderRadius:function(t){return jt(t)&&t>=0},color:function(t){return St(t)},imageSrc:function(t){return Dt(t)||Lt(t)},imageURL:Lt,imageBase64:Dt,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 jt(t)&&t>0},lineHeight:function(t){return jt(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 jt(t)&&t>0}};var Ht,Bt=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 Xt{constructor(){Ht.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,Ht,new Map,"f")}on(t,e){if(Bt(this,Ht,"f").has(t)){const i=Bt(this,Ht,"f").get(t)||[];null==i||i.push(e),Bt(this,Ht,"f").set(t,i)}else Bt(this,Ht,"f").set(t,[e])}off(t,e){if(Bt(this,Ht,"f").has(t)){const i=Bt(this,Ht,"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}Bt(this,Ht,"f").set(t,i||[])}}trigger(t,e){const i=Bt(this,Ht,"f").get(t);return!!Array.isArray(i)&&(i.forEach((t=>{t(e)})),!0)}has(t){if(Bt(this,Ht,"f").has(t)){const e=Bt(this,Ht,"f").get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){Bt(this,Ht,"f").clear()}}Ht=new WeakMap;var Yt,Ft,Vt,Nt,Ut=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},Gt=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 qt{constructor(t){Yt.add(this),Ft.set(this,void 0),Vt.set(this,void 0),Ut(this,Vt,Pt(t.defaultStorage),"f"),Ut(this,Ft,Gt(this,Yt,"m",Nt).call(this),"f")}set(t,e){Gt(this,Ft,"f")[t]=e}get(t){return Gt(this,Ft,"f")[t]}getSnapshot(){return Pt(Gt(this,Ft,"f"))}clear(){Ut(this,Ft,Gt(this,Yt,"m",Nt).call(this),"f")}destroy(){Ut(this,Ft,null,"f")}}function Qt(t){return t/180*Math.PI}function Kt(t,e,i){const n=Jt(e);!function(t,e,i,n){const o=Qt(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 Jt(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Zt(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 _t(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=Qt(function(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}(i));r=Zt(e,r,t),l=Zt(e,l,t),h=Zt(e,h,t),c=Zt(e,c,t)}return[r,l,h,c]}(t,Jt(t),e)}function te(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 ee(t,e){const{context2d:i,element:n,viewScaleInfo:o,viewSizeInfo:a}=e,{angle:s=0}=n,{x:r,y:l,w:h,h:c}=te(n,{viewScaleInfo:o,viewSizeInfo:a}),d=_t({x:r,y:l,w:h,h:c,angle:s});if(d.length>=2){i.beginPath(),i.moveTo(d[0].x,d[0].y);for(let t=1;t<d.length;t++)i.lineTo(d[t].x,d[t].y);i.closePath()}return!!i.isPointInPath(t.x,t.y)}function ie(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e}Ft=new WeakMap,Vt=new WeakMap,Yt=new WeakSet,Nt=function(){return Pt(Gt(this,Vt,"f"))};const ne={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function oe(t,e){const{viewScaleInfo:i}=e,{scale:n}=i;let{borderRadius:o}=t.detail;const{boxSizing:a=ne.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:r,y:l,w:h,h:c}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*n;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*n,o[1]*n,o[2]*n,o[3]*n]);let f=0;return"number"==typeof s&&(f=(s||0)*n),"border-box"===a?(r=t.x+f/2,l=t.y+f/2,h=t.w-f,c=t.h-f):"content-box"===a?(r=t.x-f/2,l=t.y-f/2,h=t.w+f,c=t.h+f):(r=t.x,l=t.y,h=t.w,c=t.h),h=Math.max(h,1),c=Math.max(c,1),d=d.map((t=>Math.min(t,h/2,c/2))),{x:r,y:l,w:h,h:c,radiusList:d}}function ae(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},d=t.createLinearGradient(h.x,h.y,c.x,c.y);return o.forEach((t=>{d.addColorStop(t.offset,bt(t.color,a))})),d}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},d=t.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return o.forEach((t=>{d.addColorStop(t.offset,bt(t.color,a))})),d}return"#000000"}const se={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function re(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 le(t,e,i){const{pattern:n,renderContent:o,originElem:a,calcElemSize:s,viewScaleInfo:r,viewSizeInfo:l}=i||{},{parentOpacity:h}=i,c=re(a)*h;!function(t,e,i){const{renderContent:n,originElem:o,calcElemSize:a,viewScaleInfo:s,viewSizeInfo:r}=i,l=s.scale*r.devicePixelRatio,{clipPath:h}=(null==o?void 0:o.detail)||{};if(h&&a&&h.commands){const{x:i,y:o,w:s,h:r}=a,{originW:c,originH:d,originX:f,originY:u}=h,w=s/c,v=r/d,g=i-f*w,p=o-u*v;t.save(),t.translate(g,p),t.scale(l*w,l*v);const y=ie(h.commands||[]),m=new Path2D(y);t.clip(m),t.translate(0-g,0-p),t.setTransform(1,0,0,1,0,0),Kt(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:d,radiusList:f}=oe(e,{viewScaleInfo:s,viewSizeInfo:r});if(t.beginPath(),t.moveTo(i+f[0],h),t.arcTo(i+c,h,i+c,h+d,f[1]),t.arcTo(i+c,h+d,i,h+d,f[2]),t.arcTo(i,h+d,i,h,f[3]),t.arcTo(i,h,i+c,h,f[0]),t.closePath(),"string"==typeof a)t.fillStyle=a;else if(["CanvasPattern"].includes(kt.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=ae(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},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=ae(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},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(!St(e.detail.borderColor))return;const{viewScaleInfo:n}=i,{scale:o}=n;let a=se.borderColor;!0===St(e.detail.borderColor)&&(a=e.detail.borderColor);const{borderWidth:s,borderRadius:r,borderDash:l,boxSizing:h=se.boxSizing}=e.detail;let c=0;"number"==typeof s&&(c=s||1);c*=o;let d=[0,0,0,0];if("number"==typeof r){const t=r*o;d=[t,t,t,t]}else Array.isArray(r)&&4===(null==r?void 0:r.length)&&(d=[r[0]*o,r[1]*o,r[2]*o,r[3]*o]);t.strokeStyle=a;let f=[];Array.isArray(l)&&l.length>0&&(f=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),f.length>0?t.lineCap="butt":t.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),d=d.map((t=>Math.min(t,o/2,a/2))),t.setLineDash(f),t.lineWidth=c,t.beginPath(),t.moveTo(i+d[0],n),t.arcTo(i+o,n,i+o,n+a,d[1]),t.arcTo(i+o,n+a,i,n+a,d[2]),t.arcTo(i,n+a,i,n,d[3]),t.arcTo(i,n,i+o,n,d[0]),t.closePath(),t.stroke()}t.setLineDash([])}(t,e,{viewScaleInfo:r,viewSizeInfo:l}),t.globalAlpha=h}})}function he(t,e,i){const{detail:n}=e,{viewScaleInfo:o,renderContent:a}=i,{shadowColor:s,shadowOffsetX:r,shadowOffsetY:l,shadowBlur:h}=n;$t.number(h)?(t.save(),t.shadowColor=s||se.shadowColor,t.shadowOffsetX=(r||0)*o.scale,t.shadowOffsetY=(l||0)*o.scale,t.shadowBlur=(h||0)*o.scale,a(),t.restore()):a()}const ce={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function de(t,e,i){var n;if(!0!==(null===(n=null==e?void 0:e.operations)||void 0===n?void 0:n.invisible))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:d}=(null==n?void 0:n.elementSize(e,o,a))||e,f=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:d});Kt(t,{x:r,y:l,w:h,h:c,angle:d},(()=>{he(t,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{le(t,f,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:d},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:d,viewSizeInfo:f,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},d,f))||e,y=Object.assign(Object.assign({},e),{x:w,y:v,w:g,h:p,angle:o});Kt(t,{x:w,y:v,w:g,h:p,angle:o},(()=>{he(t,y,{viewScaleInfo:d,viewSizeInfo:f,renderContent:()=>{let e=g/2,i=p/2;const n=w+e,o=v+i;h>0&&("border-box"===r?(e-=h,i-=h):"center-line"===r?(e-=h/2,i-=h/2):(e-=h,i-=h));const c=re(y)*u;if(t.globalAlpha=c,"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 f=ae(t,a,{viewElementSize:{x:w,y:v,w:g,h:p},viewScaleInfo:d,opacity:t.globalAlpha});t.fillStyle=f,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:d}=(null==n?void 0:n.elementSize(e,o,a))||e,f=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:d});Kt(t,{x:r,y:l,w:h,h:c,angle:d},(()=>{le(t,f,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const i=Object.assign(Object.assign({},ce),e.detail),n=(i.fontSize||ce.fontSize)*o.scale,a=i.lineHeight?i.lineHeight*o.scale:n;t.fillStyle=e.detail.color||ce.color,t.textBaseline="top",t.$setFont({fontWeight:i.fontWeight,fontSize:n,fontFamily:i.fontFamily});const s=i.text.replace(/\r\n/gi,"\n"),d=a,f=s.split("\n"),u=[];let w=0;f.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)*d>c));o++)if(e.length-1===o&&(w+1)*d<c){u.push({text:n,width:t.$undoPixelRatio(t.measureText(n).width)}),i<f.length-1&&w++;break}}else u.push({text:"",width:0})}));let v=0;u.length*d<c&&("top"===e.detail.verticalAlign?v=0:"bottom"===e.detail.verticalAlign?v+=c-u.length*d:v+=(c-u.length*d)/2);{const e=l+v;void 0!==i.textShadowColor&&St(i.textShadowColor)&&(t.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&$t.number(i.textShadowOffsetX)&&(t.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&$t.number(i.textShadowOffsetY)&&(t.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&$t.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+d*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:d,angle:f}=(null==o?void 0:o.elementSize(e,a,s))||e,u=Object.assign(Object.assign({},e),{x:l,y:h,w:c,h:d,angle:f});Kt(t,{x:l,y:h,w:c,h:d,angle:f},(()=>{he(t,u,{viewScaleInfo:a,viewSizeInfo:s,renderContent:()=>{le(t,u,{originElem:e,calcElemSize:{x:l,y:h,w:c,h:d,angle:f},viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r,renderContent:()=>{if(n||i.loader.load(e,i.elementAssets||{}),"image"===e.type&&n){t.globalAlpha=re(e)*r;const{x:i,y:o,w:l,h:h,radiusList:c}=oe(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:d,angle:f}=(null==o?void 0:o.elementSize(e,a,s))||e;Kt(t,{x:l,y:h,w:c,h:d,angle:f},(()=>{n||i.loader.load(e,i.elementAssets||{}),"svg"===e.type&&n&&(t.globalAlpha=re(e)*r,t.drawImage(n,l,h,c,d),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:d,angle:f}=(null==o?void 0:o.elementSize(e,a,s))||e;Kt(t,{x:l,y:h,w:c,h:d,angle:f},(()=>{n||i.loader.load(e,i.elementAssets||{}),"html"===e.type&&n&&(t.globalAlpha=re(e)*r,t.drawImage(n,l,h,c,d),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:d}=i,{x:f,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=f-o*p,x=u-a*y,S=h.scale*c.devicePixelRatio,b=Object.assign(Object.assign({},e),{x:f,y:u,w:w,h:v,angle:g});Kt(t,{x:f,y:u,w:w,h:v,angle:g},(()=>{le(t,b,{originElem:e,calcElemSize:{x:f,y:u,w:w,h:v,angle:g},viewScaleInfo:h,viewSizeInfo:c,parentOpacity:d,renderContent:()=>{he(t,b,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{t.save(),t.translate(m,x),t.scale(S*p/h.scale,S*y/h.scale);const e=ie(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:d}=(null==n?void 0:n.elementSize({x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle},o,a))||e,f=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:d});Kt(t,{x:r,y:l,w:h,h:c,angle:d},(()=>{t.globalAlpha=re(e)*s,he(t,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{le(t,f,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const{x:n,y:r,w:l,h:h,radiusList:c}=oe(f,{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{de(t,r,Object.assign(Object.assign({},i),{parentOpacity:s*re(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 fe={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 ue,we,ve,ge,pe,ye,me,xe,Se,be,Ie,Me=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())}))},ze=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)},Pe=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 We=["image","svg","html"],ke=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:zt(o):zt(`${It()}-${t.uuid}-${It()}-${It()}`)};class Ce extends Xt{constructor(){super(),ue.add(this),we.set(this,{}),ve.set(this,{}),ge.set(this,{}),ze(this,ue,"m",pe).call(this,"image",((t,e)=>Me(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 Ot(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),ze(this,ue,"m",pe).call(this,"html",((t,e)=>Me(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 At(n,{width:t.detail.originW||t.w,height:t.detail.originH||t.h});return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),ze(this,ue,"m",pe).call(this,"svg",((t,e)=>Me(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 Tt(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}}))))}destroy(){Pe(this,we,null,"f"),Pe(this,ve,null,"f"),Pe(this,ge,null,"f")}load(t,e){ze(this,ue,"m",Ie).call(this,t)||We.includes(t.type)&&ze(this,ue,"m",be).call(this,t,e)}getContent(t){var e,i;const n=ke(t);return(null===(i=null===(e=ze(this,ge,"f"))||void 0===e?void 0:e[n])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return ze(this,ge,"f")}setLoadItemMap(t){Pe(this,ge,t,"f")}}we=new WeakMap,ve=new WeakMap,ge=new WeakMap,ue=new WeakSet,pe=function(t,e){ze(this,we,"f")[t]=e},ye=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},me=function(t){return{element:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:ze(this,ue,"m",ye).call(this,t)}},xe=function(t){const e=ke(t.element),i=ze(this,ge,"f")[e];i?i.startTime<t.startTime&&(ze(this,ge,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(ze(this,ge,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime})))},Se=function(t){const e=ke(t.element),i=ze(this,ge,"f")[e];i?i.startTime<t.startTime&&(ze(this,ge,"f")[e]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(ze(this,ge,"f")[e]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime})))},be=function(t,e){const i=ze(this,ue,"m",me).call(this,t),n=ke(t);ze(this,ve,"f")[n]=i;const o=ze(this,we,"f")[t.type];"function"==typeof o&&(i.startTime=Date.now(),o(t,e).then((t=>{i.content=t.content,i.endTime=Date.now(),i.status="load",ze(this,ue,"m",xe).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,ze(this,ue,"m",Se).call(this,i)})))},Ie=function(t){var e;const i=ke(t),n=null===(e=ze(this,ve,"f"))||void 0===e?void 0:e[i];return!(!n||"error"!==n.status||!n.source||n.source!==ze(this,ue,"m",ye).call(this,t))};var Ee,Oe,Te,Ae,je=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},Re=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 Le extends Xt{constructor(t){super(),Ee.add(this),Oe.set(this,void 0),Te.set(this,new Ce),je(this,Oe,t,"f"),Re(this,Ee,"m",Ae).call(this)}destroy(){je(this,Oe,null,"f"),Re(this,Te,"f").destroy(),je(this,Te,null,"f")}updateOptions(t){je(this,Oe,t,"f")}drawData(t,e){const i=Re(this,Te,"f"),{calculator:n}=Re(this,Oe,"f"),o=Re(this,Oe,"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:d}=(null==n?void 0:n.elementSize(r,o,a))||r,f=Object.assign(Object.assign({},r),{x:l,y:h,w:c,h:d,angle:0});he(t,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{le(t,f,{originElem:r,calcElemSize:{x:l,y:h,w:c,h:d,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({},fe),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{de(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}=Re(this,Oe,"f");if(!e)return;const{data:i,offsetTop:n,offsetBottom:o,offsetLeft:a,offsetRight:s,width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}=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:d}})}setLoadItemMap(t){Re(this,Te,"f").setLoadItemMap(t)}getLoadItemMap(){return Re(this,Te,"f").getLoadItemMap()}getLoader(){return Re(this,Te,"f")}}Oe=new WeakMap,Te=new WeakMap,Ee=new WeakSet,Ae=function(){const t=Re(this,Te,"f");t.on("load",(t=>{this.trigger("load",t)})),t.on("error",(()=>{}))};class De{constructor(t){pt(this,e,void 0),yt(this,e,t)}destroy(){yt(this,e,null)}elementSize(t,e,i){return te(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}=te(t,{viewScaleInfo:n,viewSizeInfo:i}),d=_t({x:r,y:l,w:h,h:c,angle:s}),f={x:0,y:0,w:o,h:a},u=Math.min(d[0].x,d[1].x,d[2].x,d[3].x),w=Math.min(d[0].y,d[1].y,d[2].y,d[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}(f,{x:u,y:w,w:Math.max(d[0].x,d[1].x,d[2].x,d[3].x)-u,h:Math.max(d[0].y,d[1].y,d[2].y,d[3].y)-w})}(t,{viewScaleInfo:e,viewSizeInfo:i})}isPointInElement(t,i,n,o){return ee(t,{context2d:gt(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,d=0;for(let t=0;t<=e;t++)o+=h[t].x,s+=h[t].y,d+=h[t].angle||0;const f=h[e];if(f&&"group"===f.type&&Array.isArray(null===(i=f.detail)||void 0===i?void 0:i.children))for(let i=0;i<f.detail.children.length;i++){const u=f.detail.children[i];if(!0!==(null===(n=null==u?void 0:u.operations)||void 0===n?void 0:n.invisible)){if(!u)break;if(ee(t,{context2d:a,element:{x:o+u.x,y:s+u.y,w:u.w,h:u.h,angle:d+(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)&&ee(t,{context2d:a,element:i,viewScaleInfo:r,viewSizeInfo:l})){c.index=e,c.element=i;break}}return c}(t,{...i,context2d:gt(this,e).viewContext})}}function $e(t){return t>0||t<0||0===t}e=new WeakMap;class He extends Xt{constructor(t){super(),pt(this,o),pt(this,w),pt(this,g),pt(this,y),pt(this,i,void 0),pt(this,n,void 0),pt(this,s,(t=>{if(!mt(this,w,v).call(this,t))return;const e=mt(this,g,p).call(this,t);if(!mt(this,y,m).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})})),pt(this,r,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)})),pt(this,l,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);if(!mt(this,y,m).call(this,e))return;const i=Date.now(),o=gt(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}):gt(this,n).set("prevClickPoint",e)})),pt(this,h,(t=>{if(gt(this,n).set("hasPointDown",!1),!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);this.trigger("pointLeave",{point:e})})),pt(this,c,(t=>{if(gt(this,n).set("hasPointDown",!1),!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);this.trigger("pointEnd",{point:e})})),pt(this,d,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault(),t.stopPropagation();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)?!0===gt(this,n).get("hasPointDown")&&this.trigger("pointMove",{point:e}):gt(this,n).get("hasPointDown")&&(this.trigger("pointLeave",{point:e}),gt(this,n).set("hasPointDown",!1))})),pt(this,f,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)&&(gt(this,n).set("hasPointDown",!0),this.trigger("pointStart",{point:e}))})),pt(this,u,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)&&this.trigger("hover",{point:e})}));const e=new qt({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});yt(this,n,e),yt(this,i,t),mt(this,o,a).call(this)}destroy(){const t=window;t.removeEventListener("mousemove",gt(this,u)),t.removeEventListener("mousedown",gt(this,f)),t.removeEventListener("mousemove",gt(this,d)),t.removeEventListener("mouseup",gt(this,c)),t.removeEventListener("mouseleave",gt(this,h)),t.removeEventListener("wheel",gt(this,s)),t.removeEventListener("click",gt(this,l)),t.removeEventListener("contextmenu",gt(this,r)),this.destroy()}}i=new WeakMap,n=new WeakMap,o=new WeakSet,a=function(){const t=window;t.addEventListener("mousemove",gt(this,u)),t.addEventListener("mousedown",gt(this,f)),t.addEventListener("mousemove",gt(this,d)),t.addEventListener("mouseup",gt(this,c)),t.addEventListener("mouseleave",gt(this,h)),t.addEventListener("wheel",gt(this,s),{passive:!1}),t.addEventListener("click",gt(this,l)),t.addEventListener("contextmenu",gt(this,r))},s=new WeakMap,r=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,d=new WeakMap,f=new WeakMap,u=new WeakMap,w=new WeakSet,v=function(t){return t.target===gt(this,i).boardContent.boardContext.canvas},g=new WeakSet,p=function(t){const e=gt(this,i).boardContent.boardContext.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top,t:Date.now()}},y=new WeakSet,m=function(t){const e=gt(this,i).sharer.getActiveViewSizeInfo(),{width:n,height:o}=e;return!!($e(t.x)&&$e(t.y)&&t.x<=n&&t.y<=o)};const Be={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class Xe{constructor(){pt(this,x,void 0),pt(this,S,void 0);const t=new qt({defaultStorage:Be}),e=new qt({defaultStorage:{}});yt(this,x,t),yt(this,S,e)}getActiveStorage(t){return gt(this,x).get(t)}setActiveStorage(t,e){return gt(this,x).set(t,e)}getActiveStoreSnapshot(){return gt(this,x).getSnapshot()}getSharedStorage(t){return gt(this,S).get(t)}setSharedStorage(t,e){return gt(this,S).set(t,e)}getSharedStoreSnapshot(){return gt(this,S).getSnapshot()}getActiveViewScaleInfo(){return{scale:gt(this,x).get("scale"),offsetTop:gt(this,x).get("offsetTop"),offsetBottom:gt(this,x).get("offsetBottom"),offsetLeft:gt(this,x).get("offsetLeft"),offsetRight:gt(this,x).get("offsetRight")}}setActiveViewScaleInfo(t){const{scale:e,offsetTop:i,offsetBottom:n,offsetLeft:o,offsetRight:a}=t;gt(this,x).set("scale",e),gt(this,x).set("offsetTop",i),gt(this,x).set("offsetBottom",n),gt(this,x).set("offsetLeft",o),gt(this,x).set("offsetRight",a)}setActiveViewSizeInfo(t){gt(this,x).set("width",t.width),gt(this,x).set("height",t.height),gt(this,x).set("devicePixelRatio",t.devicePixelRatio),gt(this,x).set("contextWidth",t.contextWidth),gt(this,x).set("contextHeight",t.contextHeight)}getActiveViewSizeInfo(){return{width:gt(this,x).get("width"),height:gt(this,x).get("height"),devicePixelRatio:gt(this,x).get("devicePixelRatio"),contextWidth:gt(this,x).get("contextWidth"),contextHeight:gt(this,x).get("contextHeight")}}}x=new WeakMap,S=new WeakMap;const{requestAnimationFrame:Ye}=window;class Fe extends Xt{constructor(t){super(),pt(this,z),pt(this,W),pt(this,b,void 0),pt(this,I,[]),pt(this,M,"FREE"),yt(this,b,t),mt(this,z,P).call(this)}drawFrame(){const{sharer:t}=gt(this,b),e=t.getActiveStoreSnapshot(),i=t.getSharedStoreSnapshot();gt(this,I).push({activeStore:e,sharedStore:i}),mt(this,W,k).call(this)}scale(t){const{scale:e,point:i}=t,{sharer:n}=gt(this,b),{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}=gt(this,b),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,d=n.offsetRight,f=n.offsetTop,u=n.offsetBottom;return c+=e,f+=i,d=s-(l*a+c),u=r-(h*a+f),{scale:a,offsetTop:f,offsetLeft:c,offsetRight:d,offsetBottom:u}}({moveX:n,moveY:o,viewScaleInfo:i,viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(a),a}updateViewScaleInfo(t){const{sharer:e}=gt(this,b),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,d=0-o*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:s-(l*i+c/i),offsetBottom:r-(h*i+d/i)}}(t,{viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(i),i}resize(t={}){const{sharer:e}=gt(this,b),i={...e.getActiveViewSizeInfo(),...t},{width:n,height:o,devicePixelRatio:a}=i,{underContext:s,boardContext:r,helperContext:l,viewContext:h}=gt(this,b).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}}b=new WeakMap,I=new WeakMap,M=new WeakMap,z=new WeakSet,P=function(){const{renderer:t}=gt(this,b);t.on("load",(()=>{this.drawFrame()}))},W=new WeakSet,k=function(){if("DRAWING"===gt(this,M)||0===gt(this,I).length)return;yt(this,M,"DRAWING");const t=gt(this,I).shift(),{renderer:e,boardContent:i,beforeDrawFrame:n,afterDrawFrame:o}=gt(this,b);if(t){const{scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:w}=t.activeStore,v={scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h},g={width:c,height:d,contextHeight:f,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!==gt(this,I).length?yt(this,M,"DRAWING")&&Ye((()=>{mt(this,W,k).call(this)})):yt(this,M,"COMPLETE")};return C=new WeakMap,E=new WeakMap,O=new WeakMap,T=new WeakMap,A=new WeakMap,j=new WeakMap,R=new WeakMap,L=new WeakMap,D=new WeakMap,$=new WeakMap,H=new WeakSet,B=function(){gt(this,A).on("pointStart",mt(this,X,Y).bind(this)),gt(this,A).on("pointEnd",mt(this,F,V).bind(this)),gt(this,A).on("pointMove",xt((t=>{mt(this,N,U).call(this,t)}),10)),gt(this,A).on("hover",xt((t=>{mt(this,G,q).call(this,t)}),10)),gt(this,A).on("wheel",xt((t=>{mt(this,J,Z).call(this,t)}),10)),gt(this,A).on("wheelScale",xt((t=>{mt(this,_,tt).call(this,t)}),10)),gt(this,A).on("scrollX",mt(this,et,it).bind(this)),gt(this,A).on("scrollY",mt(this,nt,ot).bind(this)),gt(this,A).on("resize",mt(this,at,st).bind(this)),gt(this,A).on("doubleClick",mt(this,Q,K).bind(this))},X=new WeakSet,Y=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.pointStart)?void 0:e.call(n,t)))return}},F=new WeakSet,V=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.pointEnd)?void 0:e.call(n,t)))return}},N=new WeakSet,U=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.pointMove)?void 0:e.call(n,t)))return}},G=new WeakSet,q=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.hover)?void 0:e.call(n,t)))return}},Q=new WeakSet,K=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.doubleClick)?void 0:e.call(n,t)))return}},J=new WeakSet,Z=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.wheel)?void 0:e.call(n,t)))return}},_=new WeakSet,tt=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.wheelScale)?void 0:e.call(n,t)))return}},et=new WeakSet,it=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.scrollX)?void 0:e.call(n,t)))return}},nt=new WeakSet,ot=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.scrollY)?void 0:e.call(n,t)))return}},at=new WeakSet,st=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.resize)?void 0:e.call(n,t)))return}},rt=new WeakSet,lt=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.clear)?void 0:e.call(n,t)))return}},ht=new WeakSet,ct=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.beforeDrawFrame)?void 0:e.call(n,t)))return}},dt=new WeakSet,ft=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.afterDrawFrame)?void 0:e.call(n,t)))return}},ut=new WeakSet,wt=function(){const t=[],e=gt(this,E);gt(this,O).forEach((i=>{const n=e.get(i);"enable"===(null==n?void 0:n.status)&&(null==n?void 0:n.middlewareObject)&&t.push(n.middlewareObject)})),yt(this,T,t)},t.Board=class{constructor(t){pt(this,H),pt(this,X),pt(this,F),pt(this,N),pt(this,G),pt(this,Q),pt(this,J),pt(this,_),pt(this,et),pt(this,nt),pt(this,at),pt(this,rt),pt(this,ht),pt(this,dt),pt(this,ut),pt(this,C,void 0),pt(this,E,new WeakMap),pt(this,O,[]),pt(this,T,[]),pt(this,A,void 0),pt(this,j,void 0),pt(this,R,void 0),pt(this,L,void 0),pt(this,D,void 0),pt(this,$,new Xt);const{boardContent:e}=t,i=new Xe,n=new De({viewContext:e.viewContext}),o=new He({boardContent:e,sharer:i}),a=new Le({viewContext:e.viewContext,sharer:i,calculator:n});yt(this,C,t),yt(this,R,i),yt(this,A,o),yt(this,j,a),yt(this,D,n),yt(this,L,new Fe({boardContent:t.boardContent,sharer:i,renderer:a,calculator:gt(this,D),beforeDrawFrame:t=>{mt(this,ht,ct).call(this,t)},afterDrawFrame:t=>{mt(this,dt,ft).call(this,t)}})),mt(this,H,B).call(this),mt(this,ut,wt).call(this)}destroy(){gt(this,A).destroy(),gt(this,j).destroy(),gt(this,D).destroy(),gt(this,$).destroy()}getSharer(){return gt(this,R)}getViewer(){return gt(this,L)}getRenderer(){return gt(this,j)}setData(t){const e=gt(this,R);gt(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=_t(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});gt(this,L).drawFrame();const o={...i,...n};return gt(this,R).setActiveViewSizeInfo(o),{viewSizeInfo:o}}getData(){const{data:t}=gt(this,R).getActiveStoreSnapshot();return t}use(t){var e,i,n;if(gt(this,E).has(t)){const n=gt(this,E).get(t);if(n)return null==(i=(e=n.middlewareObject).use)||i.call(e),n.status="enable",gt(this,E).set(t,n),void mt(this,ut,wt).call(this)}const{boardContent:o,container:a}=gt(this,C),s=t({boardContent:o,sharer:gt(this,R),viewer:gt(this,L),calculator:gt(this,D),eventHub:gt(this,$),container:a});null==(n=s.use)||n.call(s),gt(this,O).push(t),gt(this,T).push(s),gt(this,E).set(t,{status:"enable",middlewareObject:s}),mt(this,ut,wt).call(this)}disuse(t){var e,i;const n=gt(this,E).get(t);n&&(null==(i=(e=n.middlewareObject).disuse)||i.call(e),n.status="disable",gt(this,E).set(t,n),mt(this,ut,wt).call(this))}scale(t){const e=gt(this,L),{moveX:i,moveY:n}=e.scale(t);e.scroll({moveX:i,moveY:n})}scroll(t){return gt(this,L).scroll(t)}updateViewScaleInfo(t){return gt(this,L).updateViewScaleInfo(t)}resize(t){const e=gt(this,L).resize(t),{width:i,height:n,devicePixelRatio:o}=t,{boardContent:a}=gt(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}),gt(this,L).drawFrame(),gt(this,A).trigger("resize",e),gt(this,R).setActiveViewSizeInfo(t)}clear(){const{boardContent:t}=gt(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),mt(this,rt,lt).call(this)}getEventHub(){return gt(this,$)}},t.Calculator=De,t.Sharer=Xe,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,d,f,u,w,v,g,p,y,m,x,S,b,I,M,z,P,W,k,C,E,O,T,A,j,R,L,D,$,H,B,X,Y,F,V,N,U,G,q,Q,K,J,Z,_,tt,et,it,nt,ot,at,st,rt,lt,ht,ct,dt,ft,ut,wt,vt=(t,e,i)=>{if(!e.has(t))throw TypeError("Cannot "+i)},gt=(t,e,i)=>(vt(t,e,"read from private field"),i?i.call(t):e.get(t)),pt=(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)},yt=(t,e,i,n)=>(vt(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),mt=(t,e,i)=>(vt(t,e,"access private method"),i);function xt(t,e){let i=-1;return function(...n){i>=0||(i=setTimeout((()=>{t(...n),i=-1}),e))}}function St(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 bt(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 It(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function Mt(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 zt(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/${Mt(e.toString(16).padEnd(4,n))}${Mt(t.substring(i-4,i).padEnd(4,n)).padEnd(4,"f")}-${Mt(t.substring(i-8,i-4).padEnd(4,n)).padEnd(4,"f")}-${Mt(t.substring(i-12,i-8).padEnd(4,n)).padEnd(4,"f")}-${Mt(t.substring(i-16,i-12).padEnd(4,o)).padEnd(4,"f")}-${Mt(t.substring(i,i+4).padEnd(4,o)).padEnd(4,"f")}${Mt(t.substring(i+4,i+8).padEnd(4,o)).padEnd(4,"f")}${Mt(o.padEnd(4,n).padEnd(4,o))}`}function Pt(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 Wt(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const kt={type(t,e){const i=Wt(t);return!0===e?i.toLocaleLowerCase():i},array:t=>"Array"===Wt(t),json:t=>"Object"===Wt(t),function:t=>"Function"===Wt(t),asyncFunction:t=>"AsyncFunction"===Wt(t),string:t=>"String"===Wt(t),number:t=>"Number"===Wt(t),undefined:t=>"Undefined"===Wt(t),null:t=>"Null"===Wt(t),promise:t=>"Promise"===Wt(t)};var Ct=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:Et}=window;function Ot(t){return new Promise(((e,i)=>{const n=new Et;n.crossOrigin="anonymous",n.onload=function(){e(n)},n.onabort=i,n.onerror=i,n.src=t}))}function Tt(t){return Ct(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 Ot(e)}))}function At(t,e){return Ct(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 Ot(i)}))}function jt(t){return"number"==typeof t&&(t>0||t<=0)}function Rt(t){return"number"==typeof t&&t>=0}function Lt(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function Dt(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}const $t={x:function(t){return jt(t)},y:function(t){return jt(t)},w:Rt,h:function(t){return"number"==typeof t&&t>=0},angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:jt,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return Rt(t)},borderRadius:function(t){return jt(t)&&t>=0},color:function(t){return St(t)},imageSrc:function(t){return Dt(t)||Lt(t)},imageURL:Lt,imageBase64:Dt,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 jt(t)&&t>0},lineHeight:function(t){return jt(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 jt(t)&&t>0}};var Ht,Bt=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 Xt{constructor(){Ht.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,Ht,new Map,"f")}on(t,e){if(Bt(this,Ht,"f").has(t)){const i=Bt(this,Ht,"f").get(t)||[];null==i||i.push(e),Bt(this,Ht,"f").set(t,i)}else Bt(this,Ht,"f").set(t,[e])}off(t,e){if(Bt(this,Ht,"f").has(t)){const i=Bt(this,Ht,"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}Bt(this,Ht,"f").set(t,i||[])}}trigger(t,e){const i=Bt(this,Ht,"f").get(t);return!!Array.isArray(i)&&(i.forEach((t=>{t(e)})),!0)}has(t){if(Bt(this,Ht,"f").has(t)){const e=Bt(this,Ht,"f").get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){Bt(this,Ht,"f").clear()}}Ht=new WeakMap;var Yt,Ft,Vt,Nt,Ut=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},Gt=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 qt{constructor(t){Yt.add(this),Ft.set(this,void 0),Vt.set(this,void 0),Ut(this,Vt,Pt(t.defaultStorage),"f"),Ut(this,Ft,Gt(this,Yt,"m",Nt).call(this),"f")}set(t,e){Gt(this,Ft,"f")[t]=e}get(t){return Gt(this,Ft,"f")[t]}getSnapshot(){return Pt(Gt(this,Ft,"f"))}clear(){Ut(this,Ft,Gt(this,Yt,"m",Nt).call(this),"f")}destroy(){Ut(this,Ft,null,"f")}}function Qt(t){return t/180*Math.PI}function Kt(t,e,i){const n=Jt(e);!function(t,e,i,n){const o=Qt(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 Jt(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function Zt(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 _t(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=Qt(function(t){if(!(t>0||t<0)||0===t)return 0;let e=t%360;return e<0&&(e+=360),e}(i));r=Zt(e,r,t),l=Zt(e,l,t),h=Zt(e,h,t),c=Zt(e,c,t)}return[r,l,h,c]}(t,Jt(t),e)}function te(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 ee(t,e){const{context2d:i,element:n,viewScaleInfo:o,viewSizeInfo:a}=e,{angle:s=0}=n,{x:r,y:l,w:h,h:c}=te(n,{viewScaleInfo:o,viewSizeInfo:a}),d=_t({x:r,y:l,w:h,h:c,angle:s});if(d.length>=2){i.beginPath(),i.moveTo(d[0].x,d[0].y);for(let t=1;t<d.length;t++)i.lineTo(d[t].x,d[t].y);i.closePath()}return!!i.isPointInPath(t.x,t.y)}function ie(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e}Ft=new WeakMap,Vt=new WeakMap,Yt=new WeakSet,Nt=function(){return Pt(Gt(this,Vt,"f"))};const ne={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function oe(t,e){const{viewScaleInfo:i}=e,{scale:n}=i;let{borderRadius:o}=t.detail;const{boxSizing:a=ne.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:r,y:l,w:h,h:c}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*n;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*n,o[1]*n,o[2]*n,o[3]*n]);let f=0;return"number"==typeof s&&(f=(s||0)*n),"border-box"===a?(r=t.x+f/2,l=t.y+f/2,h=t.w-f,c=t.h-f):"content-box"===a?(r=t.x-f/2,l=t.y-f/2,h=t.w+f,c=t.h+f):(r=t.x,l=t.y,h=t.w,c=t.h),h=Math.max(h,1),c=Math.max(c,1),d=d.map((t=>Math.min(t,h/2,c/2))),{x:r,y:l,w:h,h:c,radiusList:d}}function ae(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},d=t.createLinearGradient(h.x,h.y,c.x,c.y);return o.forEach((t=>{d.addColorStop(t.offset,bt(t.color,a))})),d}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},d=t.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return o.forEach((t=>{d.addColorStop(t.offset,bt(t.color,a))})),d}return"#000000"}const se={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function re(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 le(t,e,i){const{pattern:n,renderContent:o,originElem:a,calcElemSize:s,viewScaleInfo:r,viewSizeInfo:l}=i||{},{parentOpacity:h}=i,c=re(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:d,originX:f,originY:u}=l,w=s/c,v=h/d,g=i-f*w,p=o-u*v;t.save(),t.translate(g,p),t.scale(r*w,r*v);const y=ie(l.commands||[]),m=new Path2D(y);t.clip(m),t.translate(0-g,0-p),t.setTransform(1,0,0,1,0,0),Kt(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:d,radiusList:f}=oe(e,{viewScaleInfo:s,viewSizeInfo:r});if(t.beginPath(),t.moveTo(i+f[0],h),t.arcTo(i+c,h,i+c,h+d,f[1]),t.arcTo(i+c,h+d,i,h+d,f[2]),t.arcTo(i,h+d,i,h,f[3]),t.arcTo(i,h,i+c,h,f[0]),t.closePath(),"string"==typeof a)t.fillStyle=a;else if(["CanvasPattern"].includes(kt.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=ae(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},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=ae(t,e.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},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(!St(e.detail.borderColor))return;const{viewScaleInfo:n}=i,{scale:o}=n;let a=se.borderColor;!0===St(e.detail.borderColor)&&(a=e.detail.borderColor);const{borderWidth:s,borderRadius:r,borderDash:l,boxSizing:h=se.boxSizing}=e.detail;let c=0;"number"==typeof s&&(c=s||1);c*=o;let d=[0,0,0,0];if("number"==typeof r){const t=r*o;d=[t,t,t,t]}else Array.isArray(r)&&4===(null==r?void 0:r.length)&&(d=[r[0]*o,r[1]*o,r[2]*o,r[3]*o]);t.strokeStyle=a;let f=[];Array.isArray(l)&&l.length>0&&(f=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),f.length>0?t.lineCap="butt":t.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),d=d.map((t=>Math.min(t,o/2,a/2))),t.setLineDash(f),t.lineWidth=c,t.beginPath(),t.moveTo(i+d[0],n),t.arcTo(i+o,n,i+o,n+a,d[1]),t.arcTo(i+o,n+a,i,n+a,d[2]),t.arcTo(i,n+a,i,n,d[3]),t.arcTo(i,n,i+o,n,d[0]),t.closePath(),t.stroke()}t.setLineDash([])}(t,e,{viewScaleInfo:r,viewSizeInfo:l}),t.globalAlpha=h}})}function he(t,e,i){const{detail:n}=e,{viewScaleInfo:o,renderContent:a}=i,{shadowColor:s,shadowOffsetX:r,shadowOffsetY:l,shadowBlur:h}=n;$t.number(h)?(t.save(),t.shadowColor=s||se.shadowColor,t.shadowOffsetX=(r||0)*o.scale,t.shadowOffsetY=(l||0)*o.scale,t.shadowBlur=(h||0)*o.scale,a(),t.restore()):a()}const ce={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function de(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:d}=(null==n?void 0:n.elementSize(e,o,a))||e,f=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:d});Kt(t,{x:r,y:l,w:h,h:c,angle:d},(()=>{he(t,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{le(t,f,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:d},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:d,viewSizeInfo:f,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},d,f))||e,y=Object.assign(Object.assign({},e),{x:w,y:v,w:g,h:p,angle:o});Kt(t,{x:w,y:v,w:g,h:p,angle:o},(()=>{he(t,y,{viewScaleInfo:d,viewSizeInfo:f,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=re(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=ae(t,a,{viewElementSize:{x:w,y:v,w:g,h:p},viewScaleInfo:d,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:d}=(null==n?void 0:n.elementSize(e,o,a))||e,f=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:d});Kt(t,{x:r,y:l,w:h,h:c,angle:d},(()=>{le(t,f,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const i=Object.assign(Object.assign({},ce),e.detail),n=(i.fontSize||ce.fontSize)*o.scale,a=i.lineHeight?i.lineHeight*o.scale:n;t.fillStyle=e.detail.color||ce.color,t.textBaseline="top",t.$setFont({fontWeight:i.fontWeight,fontSize:n,fontFamily:i.fontFamily});const s=i.text.replace(/\r\n/gi,"\n"),d=a,f=s.split("\n"),u=[];let w=0;f.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)*d>c));o++)if(e.length-1===o&&(w+1)*d<c){u.push({text:n,width:t.$undoPixelRatio(t.measureText(n).width)}),i<f.length-1&&w++;break}}else u.push({text:"",width:0})}));let v=0;u.length*d<c&&("top"===e.detail.verticalAlign?v=0:"bottom"===e.detail.verticalAlign?v+=c-u.length*d:v+=(c-u.length*d)/2);{const e=l+v;void 0!==i.textShadowColor&&St(i.textShadowColor)&&(t.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&$t.number(i.textShadowOffsetX)&&(t.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&$t.number(i.textShadowOffsetY)&&(t.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&$t.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+d*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:d,angle:f}=(null==o?void 0:o.elementSize(e,a,s))||e,u=Object.assign(Object.assign({},e),{x:l,y:h,w:c,h:d,angle:f});Kt(t,{x:l,y:h,w:c,h:d,angle:f},(()=>{he(t,u,{viewScaleInfo:a,viewSizeInfo:s,renderContent:()=>{le(t,u,{originElem:e,calcElemSize:{x:l,y:h,w:c,h:d,angle:f},viewScaleInfo:a,viewSizeInfo:s,parentOpacity:r,renderContent:()=>{if(n||i.loader.load(e,i.elementAssets||{}),"image"===e.type&&n){t.globalAlpha=re(e)*r;const{x:i,y:o,w:l,h:h,radiusList:c}=oe(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:d,angle:f}=(null==o?void 0:o.elementSize(e,a,s))||e;Kt(t,{x:l,y:h,w:c,h:d,angle:f},(()=>{n||i.loader.load(e,i.elementAssets||{}),"svg"===e.type&&n&&(t.globalAlpha=re(e)*r,t.drawImage(n,l,h,c,d),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:d,angle:f}=(null==o?void 0:o.elementSize(e,a,s))||e;Kt(t,{x:l,y:h,w:c,h:d,angle:f},(()=>{n||i.loader.load(e,i.elementAssets||{}),"html"===e.type&&n&&(t.globalAlpha=re(e)*r,t.drawImage(n,l,h,c,d),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:d}=i,{x:f,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=f-o*p,x=u-a*y,S=h.scale*c.devicePixelRatio,b=Object.assign(Object.assign({},e),{x:f,y:u,w:w,h:v,angle:g});Kt(t,{x:f,y:u,w:w,h:v,angle:g},(()=>{le(t,b,{originElem:e,calcElemSize:{x:f,y:u,w:w,h:v,angle:g},viewScaleInfo:h,viewSizeInfo:c,parentOpacity:d,renderContent:()=>{he(t,b,{viewScaleInfo:h,viewSizeInfo:c,renderContent:()=>{t.save(),t.translate(m,x),t.scale(S*p/h.scale,S*y/h.scale);const e=ie(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:d}=(null==n?void 0:n.elementSize({x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle},o,a))||e,f=Object.assign(Object.assign({},e),{x:r,y:l,w:h,h:c,angle:d});Kt(t,{x:r,y:l,w:h,h:c,angle:d},(()=>{t.globalAlpha=re(e)*s,he(t,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{le(t,f,{originElem:e,calcElemSize:{x:r,y:l,w:h,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:s,renderContent:()=>{const{x:n,y:r,w:l,h:h,radiusList:c}=oe(f,{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{de(t,r,Object.assign(Object.assign({},i),{parentOpacity:s*re(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 fe={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 ue,we,ve,ge,pe,ye,me,xe,Se,be,Ie,Me=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())}))},ze=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)},Pe=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 We=["image","svg","html"],ke=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:zt(o):zt(`${It()}-${t.uuid}-${It()}-${It()}`)};class Ce extends Xt{constructor(){super(),ue.add(this),we.set(this,{}),ve.set(this,{}),ge.set(this,{}),ze(this,ue,"m",pe).call(this,"image",((t,e)=>Me(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 Ot(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),ze(this,ue,"m",pe).call(this,"html",((t,e)=>Me(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 At(n,{width:t.detail.originW||t.w,height:t.detail.originH||t.h});return{uuid:t.uuid,lastModified:Date.now(),content:o}})))),ze(this,ue,"m",pe).call(this,"svg",((t,e)=>Me(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 Tt(n);return{uuid:t.uuid,lastModified:Date.now(),content:o}}))))}destroy(){Pe(this,we,null,"f"),Pe(this,ve,null,"f"),Pe(this,ge,null,"f")}load(t,e){ze(this,ue,"m",Ie).call(this,t)||We.includes(t.type)&&ze(this,ue,"m",be).call(this,t,e)}getContent(t){var e,i;const n=ke(t);return(null===(i=null===(e=ze(this,ge,"f"))||void 0===e?void 0:e[n])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return ze(this,ge,"f")}setLoadItemMap(t){Pe(this,ge,t,"f")}}we=new WeakMap,ve=new WeakMap,ge=new WeakMap,ue=new WeakSet,pe=function(t,e){ze(this,we,"f")[t]=e},ye=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},me=function(t){return{element:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:ze(this,ue,"m",ye).call(this,t)}},xe=function(t){const e=ke(t.element),i=ze(this,ge,"f")[e];i?i.startTime<t.startTime&&(ze(this,ge,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(ze(this,ge,"f")[e]=t,this.trigger("load",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime})))},Se=function(t){const e=ke(t.element),i=ze(this,ge,"f")[e];i?i.startTime<t.startTime&&(ze(this,ge,"f")[e]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime}))):(ze(this,ge,"f")[e]=t,this.trigger("error",Object.assign(Object.assign({},t),{countTime:t.endTime-t.startTime})))},be=function(t,e){const i=ze(this,ue,"m",me).call(this,t),n=ke(t);ze(this,ve,"f")[n]=i;const o=ze(this,we,"f")[t.type];"function"==typeof o&&(i.startTime=Date.now(),o(t,e).then((t=>{i.content=t.content,i.endTime=Date.now(),i.status="load",ze(this,ue,"m",xe).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,ze(this,ue,"m",Se).call(this,i)})))},Ie=function(t){var e;const i=ke(t),n=null===(e=ze(this,ve,"f"))||void 0===e?void 0:e[i];return!(!n||"error"!==n.status||!n.source||n.source!==ze(this,ue,"m",ye).call(this,t))};var Ee,Oe,Te,Ae,je=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},Re=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 Le extends Xt{constructor(t){super(),Ee.add(this),Oe.set(this,void 0),Te.set(this,new Ce),je(this,Oe,t,"f"),Re(this,Ee,"m",Ae).call(this)}destroy(){je(this,Oe,null,"f"),Re(this,Te,"f").destroy(),je(this,Te,null,"f")}updateOptions(t){je(this,Oe,t,"f")}drawData(t,e){const i=Re(this,Te,"f"),{calculator:n}=Re(this,Oe,"f"),o=Re(this,Oe,"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:d}=(null==n?void 0:n.elementSize(r,o,a))||r,f=Object.assign(Object.assign({},r),{x:l,y:h,w:c,h:d,angle:0});he(t,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{le(t,f,{originElem:r,calcElemSize:{x:l,y:h,w:c,h:d,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({},fe),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{de(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}=Re(this,Oe,"f");if(!e)return;const{data:i,offsetTop:n,offsetBottom:o,offsetLeft:a,offsetRight:s,width:r,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}=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:d}})}setLoadItemMap(t){Re(this,Te,"f").setLoadItemMap(t)}getLoadItemMap(){return Re(this,Te,"f").getLoadItemMap()}getLoader(){return Re(this,Te,"f")}}Oe=new WeakMap,Te=new WeakMap,Ee=new WeakSet,Ae=function(){const t=Re(this,Te,"f");t.on("load",(t=>{this.trigger("load",t)})),t.on("error",(()=>{}))};class De{constructor(t){pt(this,e,void 0),yt(this,e,t)}destroy(){yt(this,e,null)}elementSize(t,e,i){return te(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}=te(t,{viewScaleInfo:n,viewSizeInfo:i}),d=_t({x:r,y:l,w:h,h:c,angle:s}),f={x:0,y:0,w:o,h:a},u=Math.min(d[0].x,d[1].x,d[2].x,d[3].x),w=Math.min(d[0].y,d[1].y,d[2].y,d[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}(f,{x:u,y:w,w:Math.max(d[0].x,d[1].x,d[2].x,d[3].x)-u,h:Math.max(d[0].y,d[1].y,d[2].y,d[3].y)-w})}(t,{viewScaleInfo:e,viewSizeInfo:i})}isPointInElement(t,i,n,o){return ee(t,{context2d:gt(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,d=0;for(let t=0;t<=e;t++)o+=h[t].x,s+=h[t].y,d+=h[t].angle||0;const f=h[e];if(f&&"group"===f.type&&Array.isArray(null===(i=f.detail)||void 0===i?void 0:i.children))for(let i=0;i<f.detail.children.length;i++){const u=f.detail.children[i];if(!0!==(null===(n=null==u?void 0:u.operations)||void 0===n?void 0:n.invisible)){if(!u)break;if(ee(t,{context2d:a,element:{x:o+u.x,y:s+u.y,w:u.w,h:u.h,angle:d+(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)&&ee(t,{context2d:a,element:i,viewScaleInfo:r,viewSizeInfo:l})){c.index=e,c.element=i;break}}return c}(t,{...i,context2d:gt(this,e).viewContext})}}function $e(t){return t>0||t<0||0===t}e=new WeakMap;class He extends Xt{constructor(t){super(),pt(this,o),pt(this,w),pt(this,g),pt(this,y),pt(this,i,void 0),pt(this,n,void 0),pt(this,s,(t=>{if(!mt(this,w,v).call(this,t))return;const e=mt(this,g,p).call(this,t);if(!mt(this,y,m).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})})),pt(this,r,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)})),pt(this,l,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);if(!mt(this,y,m).call(this,e))return;const i=Date.now(),o=gt(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}):gt(this,n).set("prevClickPoint",e)})),pt(this,h,(t=>{if(gt(this,n).set("hasPointDown",!1),!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);this.trigger("pointLeave",{point:e})})),pt(this,c,(t=>{if(gt(this,n).set("hasPointDown",!1),!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);this.trigger("pointEnd",{point:e})})),pt(this,d,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault(),t.stopPropagation();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)?!0===gt(this,n).get("hasPointDown")&&this.trigger("pointMove",{point:e}):gt(this,n).get("hasPointDown")&&(this.trigger("pointLeave",{point:e}),gt(this,n).set("hasPointDown",!1))})),pt(this,f,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)&&(gt(this,n).set("hasPointDown",!0),this.trigger("pointStart",{point:e}))})),pt(this,u,(t=>{if(!mt(this,w,v).call(this,t))return;t.preventDefault();const e=mt(this,g,p).call(this,t);mt(this,y,m).call(this,e)&&this.trigger("hover",{point:e})}));const e=new qt({defaultStorage:{hasPointDown:!1,prevClickPoint:null}});yt(this,n,e),yt(this,i,t),mt(this,o,a).call(this)}destroy(){const t=window;t.removeEventListener("mousemove",gt(this,u)),t.removeEventListener("mousedown",gt(this,f)),t.removeEventListener("mousemove",gt(this,d)),t.removeEventListener("mouseup",gt(this,c)),t.removeEventListener("mouseleave",gt(this,h)),t.removeEventListener("wheel",gt(this,s)),t.removeEventListener("click",gt(this,l)),t.removeEventListener("contextmenu",gt(this,r)),this.destroy()}}i=new WeakMap,n=new WeakMap,o=new WeakSet,a=function(){const t=window;t.addEventListener("mousemove",gt(this,u)),t.addEventListener("mousedown",gt(this,f)),t.addEventListener("mousemove",gt(this,d)),t.addEventListener("mouseup",gt(this,c)),t.addEventListener("mouseleave",gt(this,h)),t.addEventListener("wheel",gt(this,s),{passive:!1}),t.addEventListener("click",gt(this,l)),t.addEventListener("contextmenu",gt(this,r))},s=new WeakMap,r=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,d=new WeakMap,f=new WeakMap,u=new WeakMap,w=new WeakSet,v=function(t){return t.target===gt(this,i).boardContent.boardContext.canvas},g=new WeakSet,p=function(t){const e=gt(this,i).boardContent.boardContext.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top,t:Date.now()}},y=new WeakSet,m=function(t){const e=gt(this,i).sharer.getActiveViewSizeInfo(),{width:n,height:o}=e;return!!($e(t.x)&&$e(t.y)&&t.x<=n&&t.y<=o)};const Be={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0};class Xe{constructor(){pt(this,x,void 0),pt(this,S,void 0);const t=new qt({defaultStorage:Be}),e=new qt({defaultStorage:{}});yt(this,x,t),yt(this,S,e)}getActiveStorage(t){return gt(this,x).get(t)}setActiveStorage(t,e){return gt(this,x).set(t,e)}getActiveStoreSnapshot(){return gt(this,x).getSnapshot()}getSharedStorage(t){return gt(this,S).get(t)}setSharedStorage(t,e){return gt(this,S).set(t,e)}getSharedStoreSnapshot(){return gt(this,S).getSnapshot()}getActiveViewScaleInfo(){return{scale:gt(this,x).get("scale"),offsetTop:gt(this,x).get("offsetTop"),offsetBottom:gt(this,x).get("offsetBottom"),offsetLeft:gt(this,x).get("offsetLeft"),offsetRight:gt(this,x).get("offsetRight")}}setActiveViewScaleInfo(t){const{scale:e,offsetTop:i,offsetBottom:n,offsetLeft:o,offsetRight:a}=t;gt(this,x).set("scale",e),gt(this,x).set("offsetTop",i),gt(this,x).set("offsetBottom",n),gt(this,x).set("offsetLeft",o),gt(this,x).set("offsetRight",a)}setActiveViewSizeInfo(t){gt(this,x).set("width",t.width),gt(this,x).set("height",t.height),gt(this,x).set("devicePixelRatio",t.devicePixelRatio),gt(this,x).set("contextWidth",t.contextWidth),gt(this,x).set("contextHeight",t.contextHeight)}getActiveViewSizeInfo(){return{width:gt(this,x).get("width"),height:gt(this,x).get("height"),devicePixelRatio:gt(this,x).get("devicePixelRatio"),contextWidth:gt(this,x).get("contextWidth"),contextHeight:gt(this,x).get("contextHeight")}}}x=new WeakMap,S=new WeakMap;const{requestAnimationFrame:Ye}=window;class Fe extends Xt{constructor(t){super(),pt(this,z),pt(this,W),pt(this,b,void 0),pt(this,I,[]),pt(this,M,"FREE"),yt(this,b,t),mt(this,z,P).call(this)}drawFrame(){const{sharer:t}=gt(this,b),e=t.getActiveStoreSnapshot(),i=t.getSharedStoreSnapshot();gt(this,I).push({activeStore:e,sharedStore:i}),mt(this,W,k).call(this)}scale(t){const{scale:e,point:i}=t,{sharer:n}=gt(this,b),{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}=gt(this,b),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,d=n.offsetRight,f=n.offsetTop,u=n.offsetBottom;return c+=e,f+=i,d=s-(l*a+c),u=r-(h*a+f),{scale:a,offsetTop:f,offsetLeft:c,offsetRight:d,offsetBottom:u}}({moveX:n,moveY:o,viewScaleInfo:i,viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(a),a}updateViewScaleInfo(t){const{sharer:e}=gt(this,b),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,d=0-o*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:s-(l*i+c/i),offsetBottom:r-(h*i+d/i)}}(t,{viewSizeInfo:e.getActiveViewSizeInfo()});return e.setActiveViewScaleInfo(i),i}resize(t={}){const{sharer:e}=gt(this,b),i={...e.getActiveViewSizeInfo(),...t},{width:n,height:o,devicePixelRatio:a}=i,{underContext:s,boardContext:r,helperContext:l,viewContext:h}=gt(this,b).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}}b=new WeakMap,I=new WeakMap,M=new WeakMap,z=new WeakSet,P=function(){const{renderer:t}=gt(this,b);t.on("load",(()=>{this.drawFrame()}))},W=new WeakSet,k=function(){if("DRAWING"===gt(this,M)||0===gt(this,I).length)return;yt(this,M,"DRAWING");const t=gt(this,I).shift(),{renderer:e,boardContent:i,beforeDrawFrame:n,afterDrawFrame:o}=gt(this,b);if(t){const{scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:w}=t.activeStore,v={scale:a,offsetTop:s,offsetBottom:r,offsetLeft:l,offsetRight:h},g={width:c,height:d,contextHeight:f,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!==gt(this,I).length?yt(this,M,"DRAWING")&&Ye((()=>{mt(this,W,k).call(this)})):yt(this,M,"COMPLETE")};return C=new WeakMap,E=new WeakMap,O=new WeakMap,T=new WeakMap,A=new WeakMap,j=new WeakMap,R=new WeakMap,L=new WeakMap,D=new WeakMap,$=new WeakMap,H=new WeakSet,B=function(){gt(this,A).on("pointStart",mt(this,X,Y).bind(this)),gt(this,A).on("pointEnd",mt(this,F,V).bind(this)),gt(this,A).on("pointMove",xt((t=>{mt(this,N,U).call(this,t)}),10)),gt(this,A).on("hover",xt((t=>{mt(this,G,q).call(this,t)}),10)),gt(this,A).on("wheel",xt((t=>{mt(this,J,Z).call(this,t)}),10)),gt(this,A).on("wheelScale",xt((t=>{mt(this,_,tt).call(this,t)}),10)),gt(this,A).on("scrollX",mt(this,et,it).bind(this)),gt(this,A).on("scrollY",mt(this,nt,ot).bind(this)),gt(this,A).on("resize",mt(this,at,st).bind(this)),gt(this,A).on("doubleClick",mt(this,Q,K).bind(this))},X=new WeakSet,Y=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.pointStart)?void 0:e.call(n,t)))return}},F=new WeakSet,V=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.pointEnd)?void 0:e.call(n,t)))return}},N=new WeakSet,U=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.pointMove)?void 0:e.call(n,t)))return}},G=new WeakSet,q=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.hover)?void 0:e.call(n,t)))return}},Q=new WeakSet,K=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.doubleClick)?void 0:e.call(n,t)))return}},J=new WeakSet,Z=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.wheel)?void 0:e.call(n,t)))return}},_=new WeakSet,tt=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.wheelScale)?void 0:e.call(n,t)))return}},et=new WeakSet,it=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.scrollX)?void 0:e.call(n,t)))return}},nt=new WeakSet,ot=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.scrollY)?void 0:e.call(n,t)))return}},at=new WeakSet,st=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.resize)?void 0:e.call(n,t)))return}},rt=new WeakSet,lt=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.clear)?void 0:e.call(n,t)))return}},ht=new WeakSet,ct=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.beforeDrawFrame)?void 0:e.call(n,t)))return}},dt=new WeakSet,ft=function(t){var e;for(let i=0;i<gt(this,T).length;i++){const n=gt(this,T)[i];if(!1===(null==(e=null==n?void 0:n.afterDrawFrame)?void 0:e.call(n,t)))return}},ut=new WeakSet,wt=function(){const t=[],e=gt(this,E);gt(this,O).forEach((i=>{const n=e.get(i);"enable"===(null==n?void 0:n.status)&&(null==n?void 0:n.middlewareObject)&&t.push(n.middlewareObject)})),yt(this,T,t)},t.Board=class{constructor(t){pt(this,H),pt(this,X),pt(this,F),pt(this,N),pt(this,G),pt(this,Q),pt(this,J),pt(this,_),pt(this,et),pt(this,nt),pt(this,at),pt(this,rt),pt(this,ht),pt(this,dt),pt(this,ut),pt(this,C,void 0),pt(this,E,new WeakMap),pt(this,O,[]),pt(this,T,[]),pt(this,A,void 0),pt(this,j,void 0),pt(this,R,void 0),pt(this,L,void 0),pt(this,D,void 0),pt(this,$,new Xt);const{boardContent:e}=t,i=new Xe,n=new De({viewContext:e.viewContext}),o=new He({boardContent:e,sharer:i}),a=new Le({viewContext:e.viewContext,sharer:i,calculator:n});yt(this,C,t),yt(this,R,i),yt(this,A,o),yt(this,j,a),yt(this,D,n),yt(this,L,new Fe({boardContent:t.boardContent,sharer:i,renderer:a,calculator:gt(this,D),beforeDrawFrame:t=>{mt(this,ht,ct).call(this,t)},afterDrawFrame:t=>{mt(this,dt,ft).call(this,t)}})),mt(this,H,B).call(this),mt(this,ut,wt).call(this)}destroy(){gt(this,A).destroy(),gt(this,j).destroy(),gt(this,D).destroy(),gt(this,$).destroy()}getSharer(){return gt(this,R)}getViewer(){return gt(this,L)}getRenderer(){return gt(this,j)}setData(t){const e=gt(this,R);gt(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=_t(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});gt(this,L).drawFrame();const o={...i,...n};return gt(this,R).setActiveViewSizeInfo(o),{viewSizeInfo:o}}getData(){const{data:t}=gt(this,R).getActiveStoreSnapshot();return t}use(t){var e,i,n;if(gt(this,E).has(t)){const n=gt(this,E).get(t);if(n)return null==(i=(e=n.middlewareObject).use)||i.call(e),n.status="enable",gt(this,E).set(t,n),void mt(this,ut,wt).call(this)}const{boardContent:o,container:a}=gt(this,C),s=t({boardContent:o,sharer:gt(this,R),viewer:gt(this,L),calculator:gt(this,D),eventHub:gt(this,$),container:a});null==(n=s.use)||n.call(s),gt(this,O).push(t),gt(this,T).push(s),gt(this,E).set(t,{status:"enable",middlewareObject:s}),mt(this,ut,wt).call(this)}disuse(t){var e,i;const n=gt(this,E).get(t);n&&(null==(i=(e=n.middlewareObject).disuse)||i.call(e),n.status="disable",gt(this,E).set(t,n),mt(this,ut,wt).call(this))}scale(t){const e=gt(this,L),{moveX:i,moveY:n}=e.scale(t);e.scroll({moveX:i,moveY:n})}scroll(t){return gt(this,L).scroll(t)}updateViewScaleInfo(t){return gt(this,L).updateViewScaleInfo(t)}resize(t){const e=gt(this,L).resize(t),{width:i,height:n,devicePixelRatio:o}=t,{boardContent:a}=gt(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}),gt(this,L).drawFrame(),gt(this,A).trigger("resize",e),gt(this,R).setActiveViewSizeInfo(t)}clear(){const{boardContent:t}=gt(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),mt(this,rt,lt).call(this)}getEventHub(){return gt(this,$)}},t.Calculator=De,t.Sharer=Xe,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({}); |
{ | ||
"name": "@idraw/board", | ||
"version": "0.4.0-beta.8", | ||
"version": "0.4.0-beta.9", | ||
"description": "", | ||
@@ -24,8 +24,8 @@ "main": "dist/esm/index.js", | ||
"devDependencies": { | ||
"@idraw/types": "^0.4.0-beta.8" | ||
"@idraw/types": "^0.4.0-beta.9" | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"@idraw/util": "^0.4.0-beta.8", | ||
"@idraw/renderer": "^0.4.0-beta.8" | ||
"@idraw/util": "^0.4.0-beta.9", | ||
"@idraw/renderer": "^0.4.0-beta.9" | ||
}, | ||
@@ -32,0 +32,0 @@ "publishConfig": { |
Sorry, the diff of this file is too big to display
211634
3727