@idraw/core 0.4.0-beta.39 → 0.4.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var iDrawCore=function(e){"use strict";var t,i,o,n,a,r,l,s,h,c,d,f,u,g,v,m,w=e=>{throw TypeError(e)},y=(e,t,i)=>t.has(e)||w("Cannot "+i),p=(e,t,i)=>(y(e,t,"read from private field"),i?i.call(e):t.get(e)),x=(e,t,i)=>t.has(e)?w("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),S=(e,t,i,o)=>(y(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i),b=(e,t,i)=>(y(e,t,"access private method"),i);function I(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function A(e,t){if(1===t)return e;let i=1;const o=/^\#[0-9a-f]{6,6}$/i;let n=e;if(o.test(e)?i=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(i=parseInt(e.substring(7,9).replace(/^\#/,"0x")),n=e.substring(0,7)),i*=t,o.test(n)&&i>0&&i<1){const e=Math.max(0,Math.min(255,Math.ceil(256*i)));n=`${n.toUpperCase()}${e.toString(16).toUpperCase()}`}return n}function M(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function z(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i)*e.charCodeAt(i)*i*i;return t.toString(16).substring(0,4)}function R(e){const t=e.length,i=Math.floor(t/2),o=e.substring(0,4).padEnd(4,"0"),n=e.substring(0,4).padEnd(4,"0");return`@assets/${z(t.toString(16).padEnd(4,o))}${z(e.substring(i-4,i).padEnd(4,o)).padEnd(4,"f")}-${z(e.substring(i-8,i-4).padEnd(4,o)).padEnd(4,"f")}-${z(e.substring(i-12,i-8).padEnd(4,o)).padEnd(4,"f")}-${z(e.substring(i-16,i-12).padEnd(4,n)).padEnd(4,"f")}-${z(e.substring(i,i+4).padEnd(4,n)).padEnd(4,"f")}${z(e.substring(i+4,i+8).padEnd(4,n)).padEnd(4,"f")}${z(n.padEnd(4,o).padEnd(4,n))}`}function C(e){return function e(t){const i=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return t;if("Array"===i){const i=[];return t.forEach((t=>{i.push(e(t))})),i}if("Object"===i){const i={};Object.keys(t).forEach((o=>{i[o]=e(t[o])}));return Object.getOwnPropertySymbols(t).forEach((o=>{i[o]=e(t[o])})),i}}(e)}function T(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const P={type(e,t){const i=T(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===T(e),json:e=>"Object"===T(e),function:e=>"Function"===T(e),asyncFunction:e=>"AsyncFunction"===T(e),boolean:e=>"Boolean"===T(e),string:e=>"String"===T(e),number:e=>"Number"===T(e),undefined:e=>"Undefined"===T(e),null:e=>"Null"===T(e),promise:e=>"Promise"===T(e)};var E=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))};const{Image:k}=window;function W(e){return new Promise(((t,i)=>{const o=new k;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function L(e){return E(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,i)=>{const o=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=new FileReader;n.readAsDataURL(o),n.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},n.onerror=function(e){i(e)}}))}(e);return yield W(t)}))}function O(e,t){return E(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const i=yield function(e,t){const{width:i,height:o}=t;return new Promise(((t,n)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${o||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},r.onerror=function(e){n(e)}}))}(e,t);return yield W(i)}))}function j(e){return"number"==typeof e&&(e>0||e<=0)}function D(e){return"number"==typeof e&&e>=0}function Y(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function V(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const B={x:function(e){return j(e)},y:function(e){return j(e)},w:D,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:j,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return D(e)},borderRadius:function(e){return j(e)&&e>=0},color:function(e){return I(e)},imageSrc:function(e){return V(e)||Y(e)},imageURL:Y,imageBase64:V,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let i=document.createElement("div");i.innerHTML=e,i.children.length>0&&(t=!0),i=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return j(e)&&e>0},lineHeight:function(e){return j(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return j(e)&&e>0}};var G,X,N=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},F=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class H{constructor(e,t){G.set(this,void 0),X.set(this,void 0),N(this,G,e,"f"),N(this,X,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f"),this.$resetFont()}$undoPixelRatio(e){return e/F(this,X,"f").devicePixelRatio}$doPixelRatio(e){return F(this,X,"f").devicePixelRatio*e}$getContext(){return F(this,G,"f")}$setContext(e){N(this,G,e,"f")}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),F(this,G,"f").font=`${t.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return F(this,X,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=F(this,G,"f");a.width=t*o,a.height=i*o,N(this,X,Object.assign(Object.assign({},F(this,X,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=F(this,X,"f"),{width:t,height:i}=F(this,G,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return F(this,G,"f").canvas}get fillStyle(){return F(this,G,"f").fillStyle}set fillStyle(e){F(this,G,"f").fillStyle=e}get strokeStyle(){return F(this,G,"f").strokeStyle}set strokeStyle(e){F(this,G,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(F(this,G,"f").lineWidth)}set lineWidth(e){F(this,G,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return F(this,G,"f").textAlign}set textAlign(e){F(this,G,"f").textAlign=e}get textBaseline(){return F(this,G,"f").textBaseline}set textBaseline(e){F(this,G,"f").textBaseline=e}get globalAlpha(){return F(this,G,"f").globalAlpha}set globalAlpha(e){F(this,G,"f").globalAlpha=e}get shadowColor(){return F(this,G,"f").shadowColor}set shadowColor(e){F(this,G,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(F(this,G,"f").shadowOffsetX)}set shadowOffsetX(e){F(this,G,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(F(this,G,"f").shadowOffsetY)}set shadowOffsetY(e){F(this,G,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(F(this,G,"f").shadowBlur)}set shadowBlur(e){F(this,G,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return F(this,G,"f").lineCap}set lineCap(e){F(this,G,"f").lineCap=e}get globalCompositeOperation(){return F(this,G,"f").globalCompositeOperation}set globalCompositeOperation(e){F(this,G,"f").globalCompositeOperation=e}fill(...e){return F(this,G,"f").fill(...e)}arc(e,t,i,o,n,a){return F(this,G,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return F(this,G,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return F(this,G,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return F(this,G,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return F(this,G,"f").beginPath()}closePath(){return F(this,G,"f").closePath()}lineTo(e,t){return F(this,G,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return F(this,G,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return F(this,G,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}getLineDash(){return F(this,G,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return F(this,G,"f").setLineDash(t)}stroke(e){return e?F(this,G,"f").stroke(e):F(this,G,"f").stroke()}translate(e,t){return F(this,G,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return F(this,G,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],a=e[4],r=e[e.length-4],l=e[e.length-3],s=e[e.length-2],h=e[e.length-1];return 9===e.length?F(this,G,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h)):F(this,G,"f").drawImage(t,this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h))}createPattern(e,t){return F(this,G,"f").createPattern(e,t)}measureText(e){return F(this,G,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?F(this,G,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):F(this,G,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?F(this,G,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):F(this,G,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){F(this,G,"f").save()}restore(){F(this,G,"f").restore()}scale(e,t){F(this,G,"f").scale(e,t)}circle(e,t,i,o,n,a,r,l){F(this,G,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,r,l)}isPointInPath(e,t){return F(this,G,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return F(this,G,"f").clip(...e)}setTransform(e,t,i,o,n,a){return F(this,G,"f").setTransform(e,t,i,o,n,a)}getTransform(){return F(this,G,"f").getTransform()}createLinearGradient(e,t,i,o){return F(this,G,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return F(this,G,"f").createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a))}createConicGradient(e,t,i){return F(this,G,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function Z(e){const{width:t,height:i,ctx:o,devicePixelRatio:n}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*n,e.height=i*n,a=e.getContext("2d")}return new H(a,e)}function Q(e){const{width:t,height:i,devicePixelRatio:o}=e,n=new OffscreenCanvas(t*o,i*o),a=n.getContext("2d").canvas.getContext("2d");return new H(a,{devicePixelRatio:o,offscreenCanvas:n})}G=new WeakMap,X=new WeakMap;var U,$=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class J{constructor(){U.set(this,void 0),function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,i):n?n.value=i:t.set(e,i)}(this,U,new Map,"f")}on(e,t){if($(this,U,"f").has(e)){const i=$(this,U,"f").get(e)||[];null==i||i.push(t),$(this,U,"f").set(e,i)}else $(this,U,"f").set(e,[t])}off(e,t){if($(this,U,"f").has(e)){const i=$(this,U,"f").get(e);if(Array.isArray(i))for(let e=0;e<(null==i?void 0:i.length);e++)if(i[e]===t){i.splice(e,1);break}$(this,U,"f").set(e,i||[])}}trigger(e,t){const i=$(this,U,"f").get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if($(this,U,"f").has(e)){const t=$(this,U,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){$(this,U,"f").clear()}}function K(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}U=new WeakMap;var q,_,ee,te,ie,oe=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},ne=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class ae{constructor(e){q.add(this),_.set(this,void 0),ee.set(this,void 0),te.set(this,void 0),oe(this,ee,C(e.defaultStorage),"f"),oe(this,_,ne(this,q,"m",ie).call(this),"f"),oe(this,te,e.defaultStatic||{},"f")}set(e,t){ne(this,_,"f")[e]=t}get(e){return ne(this,_,"f")[e]}setStatic(e,t){ne(this,te,"f")[e]=t}getStatic(e){return ne(this,te,"f")[e]}getSnapshot(e){return!0===(null==e?void 0:e.deepClone)?C(ne(this,_,"f")):Object.assign({},ne(this,_,"f"))}clear(){oe(this,_,ne(this,q,"m",ie).call(this),"f")}destroy(){oe(this,_,null,"f"),oe(this,te,null,"f")}}function re(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}}function le(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}}function se(e){return e/180*Math.PI}function he(e,t,i,o){const n=se(t||0);i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(n),e.translate(-i.x,-i.y)),o(e),i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(-n),e.translate(-i.x,-i.y))}function ce(e,t,i){const o=de(t);he(e,t.angle||0,o,(()=>{i(e)}))}function de(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function fe(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return de({x:t,y:i,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function ue(e,t){const i=t.x-e.x,o=t.y-e.y;if(0===i){if(o<0)return 0;if(o>0)return Math.PI}else if(0===o){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&o<0?Math.atan(Math.abs(i)/Math.abs(o)):i>0&&o>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):0}function ge(e,t,i){let o=ue(e,t)+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 n=function(e,t){const i=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===i?i:Math.sqrt(i)}(e,t);let a=0,r=0;return 0===o?(a=0,r=0-n):o>0&&o<Math.PI/2?(a=Math.sin(o)*n,r=0-Math.cos(o)*n):o===Math.PI/2?(a=n,r=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*n,r=Math.cos(Math.PI-o)*n):o===Math.PI?(a=0,r=n):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*n,r=Math.cos(o-Math.PI)*n):o===1.5*Math.PI?(a=0-n,r=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*n,r=0-Math.cos(2*Math.PI-o)*n):o===2*Math.PI&&(a=0,r=0-n),a+=e.x,r+=e.y,{x:a,y:r}}function ve(e,t){if((null==t?void 0:t.length)>0){let i=e.x,o=e.y;return t.forEach((e=>{const{x:t,y:n,w:a,h:r,angle:l=0}=e,s=ge(de({x:t,y:n,w:a,h:r,angle:l}),{x:i,y:o},se(l));i=s.x,o=s.y})),{x:i,y:o}}return e}function me(e,t,i){const{x:o,y:n,w:a,h:r}=e;let l={x:o,y:n},s={x:o+a,y:n},h={x:o+a,y:n+r},c={x:o,y:n+r};if(i&&(i>0||i<0)){const e=se(pe(i));l=ge(t,l,e),s=ge(t,s,e),h=ge(t,h,e),c=ge(t,c,e)}return[l,s,h,c]}function we(e){const{angle:t=0}=e;return me(e,de(e),t)}function ye(e,t,i){return[ge(e,{x:t[0].x,y:t[0].y},i),ge(e,{x:t[1].x,y:t[1].y},i),ge(e,{x:t[2].x,y:t[2].y},i),ge(e,{x:t[3].x,y:t[3].y},i)]}function pe(e){if(!(e>0||e<0)||0===e||360===e)return 0;let t=e%360;return t<0?t+=360:360===e&&(t=0),t}function xe(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(t=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(t=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(t=xe(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function Se(e,t){const i={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=we(t);if(4===e.length){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...i),t.y=Math.min(...o),t.w=Math.abs(Math.max(...i)-Math.min(...i)),t.h=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.x+t.w,i.x+i.w),r=Math.max(t.y+t.h,i.y+i.h);i.x=o,i.y=n,i.w=Math.abs(a-o),i.h=Math.abs(r-n)})),(null==t?void 0:t.extend)&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.w,contextHeight:i.h};return(null==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>i.x+i.w&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.h&&(o.contextHeight=t.viewHeight-i.y)),o}function be(e,t){var i;const o=[];let n=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const a=n[t[e]];if("group"!==(null==a?void 0:a.type)||!Array.isArray(null===(i=null==a?void 0:a.detail)||void 0===i?void 0:i.children))return null;o.push(a),n=a.detail.children}return o}function Ie(e){const{x:t,y:i,w:o,h:n,angle:a}=e;return{x:t,y:i,w:o,h:n,angle:a}}function Ae(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const n=o[e[t]];if(t<e.length-1&&"group"===n.type)o=n.detail.children;else{if(t!==e.length-1)break;i=n}}return i}function Me(e,t){const i=[];let o=!1;const n=t=>{var a;for(let r=0;r<t.length&&!0!==o;r++){i.push(r);const l=t[r];if(l.uuid===e){o=!0;break}if("group"===l.type&&n((null===(a=null==l?void 0:l.detail)||void 0===a?void 0:a.children)||[]),o)break;i.pop()}};return n(t),i}function ze(e){const{x:t,y:i,h:o,w:n}=e;return[{x:t,y:i},{x:t+n,y:i},{x:t+n,y:i+o},{x:t,y:i+o}]}function Re(e){const{x:t,y:i,w:o,h:n,angle:a=0}=e;return 0===a?ze(e):me(e,de({x:t,y:i,w:o,h:n,angle:a}),a)}function Ce(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x:r,y:l,w:s,h:h,angle:c=0}=a[e];let d;if(i+=r,o+=l,0===e){const e={x:i,y:o,w:s,h:h,angle:c};d=Re({x:r,y:l,w:s,h:h,angle:c}),n.push({center:de(e),angle:c,radian:se(c)})}else{d=ze({x:i,y:o,w:s,h:h,angle:c});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=ye(t,d,i)}const e=fe(d);if(c>0||c<0){d=ye(e,d,se(c))}n.push({center:e,angle:c,radian:se(c)})}t.push(d)}return t}function Te(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?Ce([...i,e]):[Re(e)]}(e,t);return i.pop()||null}function Pe(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:a,h:r,angle:l}=e,{scale:s,offsetTop:h,offsetLeft:c}=i;return{x:o*s+c,y:n*s+h,w:a*s,h:r*s,angle:l}}function Ee(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:r,offsetLeft:l}=i;return{x:o*a+l,y:n*a+r}}function ke(e,t){return[Ee(e[0],t),Ee(e[1],t),Ee(e[2],t),Ee(e[3],t)]}function We(e,t){const{context2d:i,element:o,viewScaleInfo:n}=t,{angle:a=0}=o,{x:r,y:l,w:s,h:h}=Pe(o,{viewScaleInfo:n}),c=we({x:r,y:l,w:s,h:h,angle:a});if(c.length>=2){i.beginPath(),i.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e++)i.lineTo(c[e].x,c[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function Le(e,t,i){const o=[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],a=Math.min(...o),r=Math.max(...o),l=Math.min(...n),s=Math.max(...n);return e.x>a&&e.x<r&&e.y>l&&e.y<s}function Oe(e,t){const{groupQueue:i}=t,o=Te(e,{groupQueue:i}),n=K(o[0],o[1]),a=K(o[1],o[2]),r=K(o[2],o[3]),l=K(o[3],o[0]),s=o[0],h=o[1],c=o[2],d=o[3],f=Math.max(s.x,h.x,c.x,d.x),u=Math.max(s.y,h.y,c.y,d.y);return{center:{x:(f+Math.min(s.x,h.x,c.x,d.x))/2,y:(u+Math.min(s.y,h.y,c.y,d.y))/2},topLeft:s,topRight:h,bottomLeft:d,bottomRight:c,top:n,right:a,left:l,bottom:r}}function je(e){const t=Math.max(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),i=Math.max(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),o=Math.min(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},r={x:o,y:n},l={x:t,y:n},s={x:t,y:i},h={x:o,y:i},c=K(r,l),d=K(h,s),f=K(r,h);return{center:a,topLeft:r,topRight:l,bottomLeft:h,bottomRight:s,top:c,right:K(l,s),left:f,bottom:d}}function De(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n,offsetLeft:a}=t,{width:r,height:l}=i,s=0-a/o,h=0-n/o,c=r/o,d=l/o,f=de({x:s,y:h,w:c,h:d}),u={x:s,y:h},g={x:s+c,y:h},v={x:s,y:h+d},m={x:s+c,y:h+d},w={x:s,y:f.y},y={x:f.x,y:h},p={x:s+c,y:f.y},x={x:f.x,y:h+d};return{center:f,topLeft:u,topRight:g,bottomLeft:v,bottomRight:m,left:w,top:y,right:p,bottom:x}}(t);let o=0,n=0;return Object.keys(e).forEach((t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),o=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),a=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),r=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),l=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),s=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),h=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y);return i<=l&&o>=r&&n<=h&&a>=s||l<=a&&l>=a&&l<=a&&l>=a}(a.rangeRectInfo,i),a.isVisibleInView?o++:n++})),{viewVisibleInfoMap:e,visibleCount:o,invisibleCount:n}}function Ye(e,t){const{x:i,y:o}=e,{size:n,angle:a}=t;return{x:i-n/2,y:o-n/2,w:n,h:n,angle:a}}function Ve(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n,rotateControllerSize:a,rotateControllerPosition:r}=t,l=(o&&o>0?o:8)/n.scale,{x:s,y:h,w:c,h:d,angle:f=0}=e,u=a,g=r,v=[{uuid:M(),x:s,y:h,w:c,h:d,angle:f,type:"group",detail:{children:[]}},...i];let m=0;v.forEach((({angle:e=0})=>{m+=e}));const w=Te(e,{groupQueue:i}),y=Te({x:s,y:h-(g+u/2)/n.scale,h:d+(2*g+u)/n.scale,w:c,angle:f},{groupQueue:[...i]}),p=K(w[0],w[1]),x=K(w[1],w[2]),S=K(w[2],w[3]),b=K(w[3],w[0]),I=w[0],A=w[1],z=w[2],R=w[3],C=Ye(p,{size:l,angle:m}),T=Ye(x,{size:l,angle:m}),P=Ye(S,{size:l,angle:m}),E=Ye(b,{size:l,angle:m}),k=Ye(I,{size:l,angle:m}),W=Ye(A,{size:l,angle:m}),L=Ye(R,{size:l,angle:m}),O=Ye(z,{size:l,angle:m}),j=Re(k),D=Re(W),Y=Re(L),V=Re(O),B=[j[1],D[0],D[3],j[2]],G=[D[3],D[2],V[1],V[0]],X=[Y[1],V[0],V[3],Y[2]],N=[j[3],j[2],Y[1],Y[0]],F=Re(C),H=Re(T),Z=Re(P),Q=Re(E),U=K(y[0],y[1]),$=Re(Ye(U,{size:1.1*a/n.scale,angle:m}));return{originalElementCenter:de(e),originalElementSize:Object.assign({},e),elementWrapper:w,left:{type:"left",vertexes:N,center:b,size:l},right:{type:"right",vertexes:G,center:x,size:l},top:{type:"top",vertexes:B,center:p,size:l},bottom:{type:"bottom",vertexes:X,center:S,size:l},topLeft:{type:"top-left",vertexes:j,center:I,size:l},topRight:{type:"top-right",vertexes:D,center:A,size:l},bottomLeft:{type:"bottom-left",vertexes:Y,center:R,size:l},bottomRight:{type:"bottom-right",vertexes:V,center:z,size:l},leftMiddle:{type:"left-middle",vertexes:Q,center:b,size:l},rightMiddle:{type:"right-middle",vertexes:H,center:x,size:l},topMiddle:{type:"top-middle",vertexes:F,center:p,size:l},bottomMiddle:{type:"bottom-middle",vertexes:Z,center:S,size:l},rotate:{type:"rotate",vertexes:$,center:U,size:a}}}function Be(e,t){const{controllerSize:i,viewScaleInfo:o}=t,n=i&&i>0?i:8,{x:a,y:r,w:l,h:s}=Pe(e,{viewScaleInfo:o}),h=de({x:a,y:r,w:l,h:s}),c={x:h.x,y:r},d={x:a+l,y:h.y},f={x:h.x,y:r+s},u={x:a,y:h.y},g={x:a,y:r},v={x:a+l,y:r},m={x:a+l,y:r+s},w={x:a,y:r+s},y=Ye(c,{size:n,angle:0}),p=Ye(d,{size:n,angle:0}),x=Ye(f,{size:n,angle:0}),S=Ye(u,{size:n,angle:0}),b=Ye(g,{size:n,angle:0}),I=Ye(v,{size:n,angle:0}),A=Ye(w,{size:n,angle:0}),M=Ye(m,{size:n,angle:0}),z=Re(b),R=Re(I),C=Re(A),T=Re(M),P=[z[1],R[0],R[3],z[2]],E=[R[3],R[2],T[1],T[0]],k=[C[1],T[0],T[3],C[2]],W=[z[3],z[2],C[1],C[0]],L=Re(y),O=Re(p),j=Re(x);return{left:{type:"left",vertexes:W,center:u,size:n},right:{type:"right",vertexes:E,center:d,size:n},top:{type:"top",vertexes:P,center:c,size:n},bottom:{type:"bottom",vertexes:k,center:f,size:n},topLeft:{type:"top-left",vertexes:z,center:g,size:n},topRight:{type:"top-right",vertexes:R,center:v,size:n},bottomLeft:{type:"bottom-left",vertexes:C,center:w,size:n},bottomRight:{type:"bottom-right",vertexes:T,center:m,size:n},leftMiddle:{type:"left-middle",vertexes:Re(S),center:u,size:n},rightMiddle:{type:"right-middle",vertexes:O,center:d,size:n},topMiddle:{type:"top-middle",vertexes:L,center:c,size:n},bottomMiddle:{type:"bottom-middle",vertexes:j,center:f,size:n}}}function Ge(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function Xe(e,t){let i=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}_=new WeakMap,ee=new WeakMap,te=new WeakMap,q=new WeakSet,ie=function(){return C(ne(this,ee,"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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Fe(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n,borderDash:a}=e.detail;const r=Array.isArray(a)&&a.length>0,{boxSizing:l=Ne.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(n=0);let{x:h,y:c,w:d,h:f}=e,u=[0,0,0,0];if("number"==typeof n){const e=n*o;u=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(u=[n[0]*o,n[1]*o,n[2]*o,n[3]*o]);let g=0;return"number"==typeof s&&(g=(s||0)*o),"border-box"!==l||r?"content-box"===l?(h=e.x-g/2,c=e.y-g/2,d=e.w+g,f=e.h+g):(h=e.x,c=e.y,d=e.w,f=e.h):(h=e.x+g/2,c=e.y+g/2,d=e.w-g,f=e.h-g),d=Math.max(d,1),f=Math.max(f,1),u=u.map((e=>Math.min(e,d/2,f/2))),{x:h,y:c,w:d,h:f,radiusList:u}}const He=e=>Xe(e,{decimalPlaces:4});function Ze(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:a}=t,r=(o+n)/2,{borderWidth:l,borderRadius:s,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:f}=i;if("number"==typeof l)i.borderWidth=He(l*r);else if(Array.isArray(i.borderWidth)){const e=l;i.borderWidth=[He(e[0]*n),He(e[1]*o),He(e[2]*n),He(e[3]*o)]}if("number"==typeof s)i.borderRadius=He(s*r);else if(Array.isArray(i.borderRadius)){const e=s;i.borderRadius=[e[0]*o,e[1]*o,e[2]*n,e[3]*n]}Array.isArray(h)&&h.forEach(((e,t)=>{i.borderDash[t]=He(e*a)})),"number"==typeof c&&(i.shadowOffsetX=He(c*a)),"number"==typeof d&&(i.shadowOffsetX=He(d*a)),"number"==typeof f&&(i.shadowOffsetX=He(f*a))}function Qe(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:a,w:r,h:l}=e;e.x=He(n*i),e.y=He(a*o),e.w=He(r*i),e.h=He(l*o),Ze(e,t)}(e,t),"circle"===i||("text"===i?function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:n,lineHeight:a}=e.detail,r=(i+o)/2;n&&n>0&&(e.detail.fontSize=He(n*r)),a&&a>0&&(e.detail.lineHeight=He(a*r))}(e,t):"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Qe(e,t)})))}const Ue=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function $e(e){return[e,...Ue].join(", ")}function Je(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:r,y:l}=o,{scale:s}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s},c={x:r+o.x*s,y:l+o.y*s},d=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{d.addColorStop(e.offset,A(e.color,a))})),d}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},c={x:r+o.x*s,y:l+o.y*s,radius:o.radius*s},d=e.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return n.forEach((e=>{d.addColorStop(e.offset,A(e.color,a))})),d}return"#000000"}const Ke={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function qe(e){var t,i,o,n;let a=1;return void 0!==(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.opacity)&&(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.opacity)>=0&&(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.opacity)<=1&&(a=null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.opacity),a}function _e(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=i||{},{parentOpacity:h}=i,c=qe(a)*h,{clipPath:d,clipPathStrokeColor:f,clipPathStrokeWidth:u}=a.detail,g=()=>{e.globalAlpha=c,et(e,t,{pattern:o,viewScaleInfo:l,viewSizeInfo:s}),null==n||n(),tt(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=h};d?(function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r}=i,l=r.devicePixelRatio,{clipPath:s}=(null==n?void 0:n.detail)||{};if(s&&a&&s.commands){const{x:i,y:n,w:r,h:h}=a,{originW:c,originH:d,originX:f,originY:u}=s,g=r/c,v=h/d,m=i-f*g,w=n-u*v;e.save(),e.translate(m,w),e.scale(l*g,l*v);const y=Ge(s.commands||[]),p=new Path2D(y);e.clip(p),e.translate(0-m,0-w),e.setTransform(1,0,0,1,0,0),ce(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof u&&u>0&&f&&function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=i,s=r.devicePixelRatio,{clipPath:h,clipPathStrokeColor:c,clipPathStrokeWidth:d}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands&&"number"==typeof d&&d>0&&c){const{x:i,y:n,w:r,h:f}=a,{originW:u,originH:g,originX:v,originY:m}=h,w=r/u,y=f/g,p=i-v*w,x=n-m*y;e.save(),e.globalAlpha=l,e.translate(p,x),e.scale(s*w,s*y);const S=Ge(h.commands||[]),b=new Path2D(S);e.strokeStyle=c,e.lineWidth=d,e.stroke(b),e.translate(0-p,0-x),e.setTransform(1,0,0,1,0,0),ce(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,parentOpacity:h})):g()}function et(e,t,i){var o,n;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=i,s=[];if(t.detail.background||a){const{x:i,y:h,w:c,h:d,radiusList:f}=Fe(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(i+f[0],h),e.arcTo(i+c,h,i+c,h+d,f[1]),e.arcTo(i+c,h+d,i,h+d,f[2]),e.arcTo(i,h+d,i,h,f[3]),e.arcTo(i,h,i+c,h,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(P.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null===(o=t.detail.background)||void 0===o?void 0:o.type)){const o=Je(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null===(n=t.detail.background)||void 0===n?void 0:n.type)){const o=Je(e,t.detail.background,{viewElementSize:{x:i,y:h,w:c,h:d},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=o,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const o=s[t];"translate"===o.method?e.translate(o.args[0]+i,o.args[1]+h):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function tt(e,t,i){if(0===t.detail.borderWidth)return;if(!I(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let a=Ke.borderColor;!0===I(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:h=Ke.boxSizing}=t.detail;let c=0;"number"==typeof r&&(c=r||1),c*=n;let d=[0,0,0,0];if("number"==typeof l){const e=l*n;d=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(d=[l[0]*n,l[1]*n,l[2]*n,l[3]*n]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*n))));let u=0,g=0,v=0,m=0;if(Array.isArray(r)&&(u=(r[0]||0)*n,g=(r[1]||0)*n,v=(r[2]||0)*n,m=(r[3]||0)*n),m||g||u||v){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i+=m/2,o+=u/2,n=n-m/2-g/2,a=a-u/2-v/2):"content-box"===h?(i-=m/2,o-=u/2,n=n+m/2+g/2,a=a+u/2+v/2):(i=t.x,o=t.y,n=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(i-m/2,o),e.lineTo(i+n+g/2,o),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i+n,o-u/2),e.lineTo(i+n,o+a+v/2),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i-m/2,o+a),e.lineTo(i+n+g/2,o+a),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(i,o-u/2),e.lineTo(i,o+a+v/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i=t.x+c/2,o=t.y+c/2,n=t.w-c,a=t.h-c):"content-box"===h?(i=t.x-c/2,o=t.y-c/2,n=t.w+c,a=t.h+c):(i=t.x,o=t.y,n=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",n=Math.max(n,1),a=Math.max(a,1),d=d.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(f),e.lineWidth=c,e.beginPath(),e.moveTo(i+d[0],o),e.arcTo(i+n,o,i+n,o+a,d[1]),e.arcTo(i+n,o+a,i,o+a,d[2]),e.arcTo(i,o+a,i,o,d[3]),e.arcTo(i,o,i+n,o,d[0]),e.closePath(),e.stroke()}e.setLineDash([])}function it(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:h}=o;B.number(h)?(e.save(),e.shadowColor=r||Ke.shadowColor,e.shadowOffsetX=(l||0)*n.scale,e.shadowOffsetY=(s||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}const ot={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};var nt=function(e,t){var i={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(i[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(i[o[n]]=e[o[n]])}return i};const at=.4;function rt(e,t,i){var o,n,a;if(!0===(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))return;const{w:r,h:l}=t,{scale:s}=i.viewScaleInfo;if(s<1&&(r*s<at||l*s<at)||0===i.parentOpacity)return;const{overrideElementMap:h}=i;if(!(null===(a=null===(n=null==h?void 0:h[t.uuid])||void 0===n?void 0:n.operations)||void 0===a?void 0:a.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=Pe(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ce(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{it(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{_e(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=i,{background:s="#000000",borderColor:h="#000000",boxSizing:c,borderWidth:d=0,borderDash:f}=o;let u=0;"number"==typeof d&&d>0?u=d:Array.isArray(d)&&"number"==typeof d[0]&&d[0]>0&&(u=d[0]),u*=a.scale;const{x:g,y:v,w:m,h:w}=Pe({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,y=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:w,angle:n});ce(e,{x:g,y:v,w:m,h:w,angle:n},(()=>{it(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=m/2,i=w/2;const o=g+t,n=v+i,r=t,d=i;if(u>0&&("content-box"===c||("center-line"===c?(t-=u/2,i-=u/2):(t-=u,i-=u))),t>=0&&i>=0){const c=qe(y)*l;e.globalAlpha=c,e.beginPath();const p=Je(e,s,{viewElementSize:{x:g,y:v,w:m,h:w},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=p,e.circle(o,n,r,d,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof u&&u>0){const r=u/2+t,l=u/2+i;if(e.beginPath(),f){const t=f.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=h,e.lineWidth=u,e.circle(o,n,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=Pe(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ce(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{it(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{_e(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a})}});{const i=Object.assign(Object.assign({},ot),t.detail),n=i.fontSize||ot.fontSize,a=n*o.scale;if(a<2)return;const c=(i.lineHeight||n)*o.scale;e.fillStyle=t.detail.color||ot.color,e.textBaseline="top",e.$setFont({fontWeight:i.fontWeight,fontSize:a,fontFamily:$e(i.fontFamily)});let d=i.text.replace(/\r\n/gi,"\n");"lowercase"===i.textTransform?d=d.toLowerCase():"uppercase"===i.textTransform&&(d=d.toUpperCase());const f=c,u=d.split("\n"),g=[];let v=0;u.forEach(((t,n)=>{if("maxContent"===i.minInlineSize)g.push({text:t,width:e.$undoPixelRatio(e.measureText(t).width)});else{let l="",c="",d=t.split(c);if("normal"===i.wordBreak){const e=" ",i=t.split(e);d=[],i.forEach(((t,o)=>{d.push(t),o<i.length-1&&d.push(e)}))}if(1===d.length&&"visible"===i.overflow)g.push({text:d[0],width:e.$undoPixelRatio(e.measureText(d[0]).width)});else if(d.length>0){for(let t=0;t<d.length&&(a=e.$doPixelRatio(s),r=e.measureText(l+d[t]).width,o.scale<.5&&a<r&&(a-r)/a>-.15||a>=r?l+=d[t]||"":(g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),l=d[t]||"",v++),!((v+1)*f>h&&"hidden"===i.overflow));t++)if(d.length-1===t&&(v+1)*f<=h){g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),n<u.length-1&&v++;break}}else g.push({text:"",width:0})}var a,r}));let m=0,w=0;f>a&&(w=(f-a)/2),g.length*f<h&&("top"===t.detail.verticalAlign?m=0:"bottom"===t.detail.verticalAlign?m+=h-g.length*f:m+=(h-g.length*f)/2);{const t=l+m;void 0!==i.textShadowColor&&I(i.textShadowColor)&&(e.shadowColor=i.textShadowColor),void 0!==i.textShadowOffsetX&&B.number(i.textShadowOffsetX)&&(e.shadowOffsetX=i.textShadowOffsetX),void 0!==i.textShadowOffsetY&&B.number(i.textShadowOffsetY)&&(e.shadowOffsetY=i.textShadowOffsetY),void 0!==i.textShadowBlur&&B.number(i.textShadowBlur)&&(e.shadowBlur=i.textShadowBlur),g.forEach(((o,n)=>{let a=r;"center"===i.textAlign?a=r+(s-o.width)/2:"right"===i.textAlign&&(a=r+(s-o.width)),e.fillText(o.text,a,t+f*n+w)}))}}}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=Pe(t,{viewScaleInfo:n})||t,f=Object.assign(Object.assign({},t),{x:l,y:s,w:h,h:c,angle:d});ce(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{it(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{_e(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=qe(t)*r;const{x:i,y:l,w:s,h:h,radiusList:c}=Fe(f,{viewScaleInfo:n,viewSizeInfo:a}),{detail:d}=t,{scaleMode:u,originW:g=0,originH:v=0}=d,m=e.$undoPixelRatio(g),w=e.$undoPixelRatio(v);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+c[0],l),e.arcTo(i+s,l,i+s,l+h,c[1]),e.arcTo(i+s,l+h,i,l+h,c[2]),e.arcTo(i,l+h,i,l,c[3]),e.arcTo(i,l,i+s,l,c[0]),e.closePath(),e.fill(),e.clip(),u&&v&&g){let n=0,a=0,r=m,c=w;const d=i,f=l,g=s,v=h;if(m>t.w||w>t.h)if("fill"===u){const e=Math.max(t.w/m,t.h/w),i=w*e;n=(m*e-t.w)/2/e,a=(i-t.h)/2/e,r=t.w/e,c=t.h/e}else if("tile"===u)n=0,a=0,r=t.w,c=t.h;else if("fit"===u){const e=Math.min(t.w/m,t.h/w);n=(m-t.w/e)/2,a=(w-t.h/e)/2,r=t.w/e,c=t.h/e}e.drawImage(o,n,a,r,c,d,f,g,v)}else e.drawImage(o,i,l,s,h);e.globalAlpha=r,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=Pe(t,{viewScaleInfo:n,viewSizeInfo:a})||t;ce(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=qe(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=Pe(t,{viewScaleInfo:n,viewSizeInfo:a})||t;ce(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=qe(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"path":!function(e,t,i){var o,n;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:h,fillRule:c}=a,{viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u}=i,{x:g,y:v,w:m,h:w,angle:y}=Pe(t,{viewScaleInfo:d})||t,p=m/s,x=w/h,S=g-r*p,b=v-l*x,I=t.detail,A=nt(I,["clipPath","clipPathStrokeColor","clipPathStrokeWidth"]),M=d.scale*f.devicePixelRatio,z=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:w,angle:y});let R=Object.assign({},z);R.detail=A;let C=Object.assign({},t);C.detail=A,a.fill&&"string"!==a.fill&&(null===(n=null===(o=a.fill)||void 0===o?void 0:o.type)||void 0===n?void 0:n.includes("gradient"))&&(R=Object.assign(Object.assign({},z),{detail:Object.assign(Object.assign({},z.detail),{background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:h}})}),C.detail=Object.assign({},R.detail)),ce(e,{x:g,y:v,w:m,h:w,angle:y},(()=>{_e(e,R,{originElem:C,calcElemSize:{x:g,y:v,w:m,h:w,angle:y},viewScaleInfo:d,viewSizeInfo:f,parentOpacity:u,renderContent:()=>{it(e,z,{viewScaleInfo:d,viewSizeInfo:f,renderContent:()=>{e.save(),e.translate(S,b),e.scale(M*p/d.scale,M*x/d.scale);const t=Ge(a.commands||[]),i=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(i,c),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(i)),e.translate(-S,-b),e.restore()}})}})}))}(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=Pe({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ce(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{e.globalAlpha=qe(t)*a,it(e,d,{viewScaleInfo:o,viewSizeInfo:n,renderContent:()=>{_e(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:h,radiusList:c}=Fe(d,{viewScaleInfo:o,viewSizeInfo:n});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+c[0],l),e.arcTo(r+s,l,r+s,l+h,c[1]),e.arcTo(r+s,l+h,r,l+h,c[2]),e.arcTo(r,l+h,r,l,c[3]),e.arcTo(r,l,r+s,l,c[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:o}=i,n={x:o.x+t.x,y:o.y+t.y,w:t.w||o.w,h:t.h||o.h,angle:t.angle},{calculator:r}=i;for(let o=0;o<t.detail.children.length;o++){let l=t.detail.children[o];if(l=Object.assign(Object.assign({},l),{x:n.x+l.x,y:n.y+l.y}),!0===i.forceDrawAll||(null==r?void 0:r.needRender(l)))try{rt(e,l,Object.assign(Object.assign({},i),{parentOpacity:a*qe(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const lt={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function st(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:a}=i;for(let t=0;t<n.length;t++){const r=n[t],l=Object.assign(Object.assign({},r),{detail:Object.assign(Object.assign({},lt),null==r?void 0:r.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.needRender(l)))try{rt(e,l,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(e){console.error(e)}}}var ht,ct,dt,ft,ut,gt,vt,mt,wt,yt,pt,xt,St=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))},bt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)},It=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i};const At=["image","svg","html"],Mt=e=>{var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),"string"==typeof n&&n?/^@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(`${n}`)?n:R(n):R(`${M()}-${e.uuid}-${M()}-${M()}`)};class zt extends J{constructor(){super(),ht.add(this),ct.set(this,{}),dt.set(this,{}),ft.set(this,{}),ut.set(this,!1),bt(this,ht,"m",gt).call(this,"image",((e,t)=>St(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.src])||void 0===i?void 0:i.value)||e.detail.src,n=yield W(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),bt(this,ht,"m",gt).call(this,"html",((e,t)=>St(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.html])||void 0===i?void 0:i.value)||e.detail.html,n=yield O(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),bt(this,ht,"m",gt).call(this,"svg",((e,t)=>St(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.svg])||void 0===i?void 0:i.value)||e.detail.svg,n=yield L(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}isDestroyed(){return bt(this,ut,"f")}destroy(){It(this,ut,!0,"f"),this.clear(),It(this,ct,null,"f"),It(this,dt,null,"f"),It(this,ft,null,"f")}load(e,t){!0!==bt(this,ut,"f")&&(bt(this,ht,"m",xt).call(this,e)||At.includes(e.type)&&bt(this,ht,"m",pt).call(this,e,t))}getContent(e){var t,i;const o=Mt(e);return(null===(i=null===(t=bt(this,ft,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return bt(this,ft,"f")}setLoadItemMap(e){It(this,ft,e,"f")}}ct=new WeakMap,dt=new WeakMap,ft=new WeakMap,ut=new WeakMap,ht=new WeakSet,gt=function(e,t){bt(this,ct,"f")[e]=t},vt=function(e){var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),n},mt=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:bt(this,ht,"m",vt).call(this,e)}},wt=function(e){const t=Mt(e.element),i=bt(this,ft,"f")[t];bt(this,ut,"f")||(i?i.startTime<e.startTime&&(bt(this,ft,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(bt(this,ft,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},yt=function(e){var t;const i=Mt(e.element),o=null===(t=bt(this,ft,"f"))||void 0===t?void 0:t[i];bt(this,ut,"f")||(o?o.startTime<e.startTime&&(bt(this,ft,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(bt(this,ft,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},pt=function(e,t){const i=bt(this,ht,"m",mt).call(this,e),o=Mt(e);if(bt(this,dt,"f")[o])return;bt(this,dt,"f")[o]=i;const n=bt(this,ct,"f")[e.type];"function"!=typeof n||bt(this,ut,"f")||(i.startTime=Date.now(),n(e,t).then((e=>{bt(this,ut,"f")||(i.content=e.content,i.endTime=Date.now(),i.status="load",bt(this,ht,"m",wt).call(this,i))})).catch((t=>{console.warn(`Load element source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,bt(this,ht,"m",yt).call(this,i)})))},xt=function(e){var t;const i=Mt(e),o=null===(t=bt(this,dt,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==bt(this,ht,"m",vt).call(this,e))};var Rt,Ct,Tt,Pt,Et,kt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Wt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Lt extends J{constructor(e){super(),Rt.add(this),Ct.set(this,void 0),Tt.set(this,new zt),Pt.set(this,!1),kt(this,Ct,e,"f"),Wt(this,Rt,"m",Et).call(this)}isDestroyed(){return Wt(this,Pt,"f")}destroy(){this.clear(),kt(this,Ct,null,"f"),Wt(this,Tt,"f").destroy(),kt(this,Tt,null,"f"),kt(this,Pt,!0,"f")}updateOptions(e){kt(this,Ct,e,"f")}drawData(e,t){const i=Wt(this,Tt,"f"),{calculator:o,sharer:n}=Wt(this,Ct,"f"),a=Wt(this,Ct,"f").viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},l=Object.assign({loader:i,calculator:o,parentElementSize:r,elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==n?void 0:n.getActiveOverrideElemenentMap()},t);!function(e,t,i){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:o}=i,{width:n,height:a}=o;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,n,a)}}(a,e.global,l),e.layout?function(e,t,i,o){const{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,l=Object.assign({uuid:"layout",type:"group"},t),{x:s,y:h,w:c,h:d}=Pe(l,{viewScaleInfo:n})||l,f=Object.assign(Object.assign({},l),{x:s,y:h,w:c,h:d,angle:0});if(e.globalAlpha=1,it(e,f,{viewScaleInfo:n,viewSizeInfo:a,renderContent:()=>{et(e,f,{viewScaleInfo:n,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:o,viewSizeInfo:n}=i,a=Object.assign({uuid:"layout",type:"group"},t),r=Pe(a,{viewScaleInfo:o})||a,l=Object.assign(Object.assign({},a),r),{x:s,y:h,w:c,h:d,radiusList:f}=Fe(l,{viewScaleInfo:o,viewSizeInfo:n});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],h),e.arcTo(s+c,h,s+c,h+d,f[1]),e.arcTo(s+c,h+d,s,h+d,f[2]),e.arcTo(s,h+d,s,h,f[3]),e.arcTo(s,h,s+c,h,f[0]),e.closePath(),e.fill(),e.clip()}o(e),"hidden"===t.detail.overflow&&e.restore(),tt(e,f,{viewScaleInfo:n,viewSizeInfo:a}),e.globalAlpha=r}(a,e.layout,l,(()=>{st(a,e,l)})):st(a,e,l)}scale(e){const{sharer:t}=Wt(this,Ct,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){Wt(this,Tt,"f").setLoadItemMap(e)}getLoadItemMap(){return Wt(this,Tt,"f").getLoadItemMap()}getLoader(){return Wt(this,Tt,"f")}}Ct=new WeakMap,Tt=new WeakMap,Pt=new WeakMap,Rt=new WeakSet,Et=function(){const e=Wt(this,Tt,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))};var Ot,jt,Dt=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Yt=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Vt{constructor(e){Ot.set(this,void 0),jt.set(this,void 0),Dt(this,Ot,e,"f"),Dt(this,jt,new ae({defaultStorage:{viewVisibleInfoMap:{},visibleCount:0,invisibleCount:0}}),"f")}toGridNum(e,t){return!0===(null==t?void 0:t.ignore)?e:Math.round(e)}destroy(){Dt(this,Ot,null,"f")}needRender(e){const t=Yt(this,jt,"f").get("viewVisibleInfoMap")[e.uuid];return!t||t.isVisibleInView}isPointInElement(e,t,i,o){return We(e,{context2d:Yt(this,Ot,"f").viewContext,element:t,viewScaleInfo:i,viewSizeInfo:o})}getPointElement(e,t){const i=Yt(this,Ot,"f").viewContext;return function(e,t){var i,o,n;const{context2d:a,data:r,viewScaleInfo:l,viewSizeInfo:s,groupQueue:h}=t,c={index:-1,element:null,groupQueueIndex:-1};if(h&&Array.isArray(h)&&(null==h?void 0:h.length)>0)for(let t=h.length-1;t>=0;t--){let n=0,r=0,d=0;for(let e=0;e<=t;e++)n+=h[e].x,r+=h[e].y,d+=h[e].angle||0;const f=h[t];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===(o=null==u?void 0:u.operations)||void 0===o?void 0:o.invisible)){if(!u)break;if(We(e,{context2d:a,element:{x:n+u.x,y:r+u.y,w:u.w,h:u.h,angle:d+(u.angle||0)},viewScaleInfo:l,viewSizeInfo:s})){c.element=u,(t<h.length-1||"group"!==u.type)&&(c.groupQueueIndex=t);break}}}if(c.element)break}if(c.element)return c;for(let t=r.elements.length-1;t>=0;t--){const i=r.elements[t];if(!0!==(null===(n=null==i?void 0:i.operations)||void 0===n?void 0:n.invisible)&&We(e,{context2d:a,element:i,viewScaleInfo:l,viewSizeInfo:s})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}resetViewVisibleInfoMap(e,t){if(e){const{viewVisibleInfoMap:i,invisibleCount:o,visibleCount:n}=function(e,t){const i={},o=[],n=t=>{const a={isVisibleInView:!0,isGroup:"group"===t.type,position:[...o]};let r=null;r=Oe(t,{groupQueue:be(e,o)||[]}),i[t.uuid]=Object.assign(Object.assign({},a),{originRectInfo:r,rangeRectInfo:B.angle(t.angle)?je(r):r}),"group"===t.type&&t.detail.children.forEach(((e,t)=>{o.push(t),n(e),o.pop()}))};return e.forEach(((e,t)=>{o.push(t),n(e),o.pop()})),De(i,t)}(e.elements,t);Yt(this,jt,"f").set("viewVisibleInfoMap",i),Yt(this,jt,"f").set("invisibleCount",o),Yt(this,jt,"f").set("visibleCount",n)}}updateVisiableStatus(e){const{viewVisibleInfoMap:t,invisibleCount:i,visibleCount:o}=De(Yt(this,jt,"f").get("viewVisibleInfoMap"),e);Yt(this,jt,"f").set("viewVisibleInfoMap",t),Yt(this,jt,"f").set("invisibleCount",i),Yt(this,jt,"f").set("visibleCount",o)}calcViewRectInfoFromOrigin(e,t){const i=Yt(this,jt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.originRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:Ee(r,v),left:Ee(l,v),right:Ee(s,v),bottom:Ee(h,v),top:Ee(c,v),topLeft:Ee(d,v),topRight:Ee(f,v),bottomLeft:Ee(u,v),bottomRight:Ee(g,v)}}calcViewRectInfoFromRange(e,t){const i=Yt(this,jt,"f").get("viewVisibleInfoMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:f,bottomLeft:u,bottomRight:g}=i.rangeRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n,viewSizeInfo:a};return{center:Ee(r,v),left:Ee(l,v),right:Ee(s,v),bottom:Ee(h,v),top:Ee(c,v),topLeft:Ee(d,v),topRight:Ee(f,v),bottomLeft:Ee(u,v),bottomRight:Ee(g,v)}}modifyViewVisibleInfoMap(e,t){const{modifyOptions:i,viewScaleInfo:o,viewSizeInfo:n}=t,{type:a,content:r}=i,l=e.elements,s=Yt(this,jt,"f").get("viewVisibleInfoMap");if("deleteElement"===a){const{element:e}=r,t=[],i=e=>{t.push(e.uuid),"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{i(e)}))};i(e),t.forEach((e=>{delete s[e]})),Yt(this,jt,"f").set("viewVisibleInfoMap",s)}else if("addElement"===a||"updateElement"===a){const{position:t}=r,i=Ae(t,e.elements),h=be(l,t);if(i)if("updateElement"===a&&"group"===i.type)this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n});else{const e=Oe(i,{groupQueue:h||[]}),r={originRectInfo:e,rangeRectInfo:B.angle(i.angle)?je(e):e,isVisibleInView:!0,isGroup:"group"===(null==i?void 0:i.type),position:[...t]};s[i.uuid]=r,Yt(this,jt,"f").set("viewVisibleInfoMap",s),"updateElement"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:n})}}else"moveElement"===a&&this.resetViewVisibleInfoMap(e,{viewScaleInfo:o,viewSizeInfo:n})}}Ot=new WeakMap,jt=new WeakMap;var Bt,Gt,Xt,Nt,Ft,Ht,Zt,Qt,Ut,$t,Jt,Kt,qt,_t,ei,ti,ii=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},oi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};function ni(e){return e>0||e<0||0===e}class ai extends J{constructor(e){super(),Bt.add(this),Gt.set(this,void 0),Xt.set(this,void 0),Nt.set(this,!1),Ht.set(this,(e=>{if(!oi(this,Bt,"m",_t).call(this,e))return;const t=oi(this,Bt,"m",ei).call(this,e);if(!oi(this,Bt,"m",ti).call(this,t))return;e.preventDefault(),e.stopPropagation();const i=e.deltaX>0||e.deltaX<0?e.deltaX:0,o=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:i,deltaY:o,point:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:i,deltaY:o,point:t})})),Zt.set(this,(e=>{if(2!==e.button)return;if(!oi(this,Bt,"m",_t).call(this,e))return;e.preventDefault();const t=oi(this,Bt,"m",ei).call(this,e);oi(this,Bt,"m",ti).call(this,t)&&this.trigger("contextMenu",{point:t})})),Qt.set(this,(e=>{if(!oi(this,Bt,"m",_t).call(this,e))return;e.preventDefault();const t=oi(this,Bt,"m",ei).call(this,e);if(!oi(this,Bt,"m",ti).call(this,t))return;const i=Date.now(),o=oi(this,Xt,"f").get("prevClickPoint");o&&i-o.t<=500&&Math.abs(o.x-t.x)<=5&&Math.abs(o.y-t.y)<=5?this.trigger("doubleClick",{point:t}):oi(this,Xt,"f").set("prevClickPoint",t)})),Ut.set(this,(e=>{oi(this,Xt,"f").set("hasPointDown",!1),e.preventDefault();const t=oi(this,Bt,"m",ei).call(this,e);this.trigger("pointLeave",{point:t})})),$t.set(this,(e=>{if(oi(this,Xt,"f").set("hasPointDown",!1),!oi(this,Bt,"m",_t).call(this,e))return;e.preventDefault();const t=oi(this,Bt,"m",ei).call(this,e);this.trigger("pointEnd",{point:t})})),Jt.set(this,(e=>{if(!oi(this,Bt,"m",_t).call(this,e))return;e.preventDefault(),e.stopPropagation();const t=oi(this,Bt,"m",ei).call(this,e);oi(this,Bt,"m",ti).call(this,t)?!0===oi(this,Xt,"f").get("hasPointDown")&&this.trigger("pointMove",{point:t}):oi(this,Xt,"f").get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),oi(this,Xt,"f").set("hasPointDown",!1))})),Kt.set(this,(e=>{if(0!==e.button)return;if(!oi(this,Bt,"m",_t).call(this,e))return;e.preventDefault();const t=oi(this,Bt,"m",ei).call(this,e);oi(this,Bt,"m",ti).call(this,t)&&(oi(this,Xt,"f").set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),qt.set(this,(e=>{if(!oi(this,Bt,"m",_t).call(this,e))return void(!0===oi(this,Xt,"f").get("inCanvas")&&(oi(this,Xt,"f").set("inCanvas",!1),oi(this,Ut,"f").call(this,e)));oi(this,Xt,"f").set("inCanvas",!0),e.preventDefault();const t=oi(this,Bt,"m",ei).call(this,e);oi(this,Bt,"m",ti).call(this,t)&&this.trigger("hover",{point:t})}));const t=new ae({defaultStorage:{hasPointDown:!1,prevClickPoint:null,inCanvas:!0}});ii(this,Xt,t,"f"),ii(this,Gt,e,"f"),oi(this,Bt,"m",Ft).call(this)}onEvents(){if(oi(this,Nt,"f"))return;const e=window;e.addEventListener("mousemove",oi(this,qt,"f")),e.addEventListener("mousedown",oi(this,Kt,"f")),e.addEventListener("mousemove",oi(this,Jt,"f")),e.addEventListener("mouseup",oi(this,$t,"f")),e.addEventListener("wheel",oi(this,Ht,"f"),{passive:!1}),e.addEventListener("click",oi(this,Qt,"f")),e.addEventListener("contextmenu",oi(this,Zt,"f"))}offEvents(){const e=window;e.removeEventListener("mousemove",oi(this,qt,"f")),e.removeEventListener("mousedown",oi(this,Kt,"f")),e.removeEventListener("mousemove",oi(this,Jt,"f")),e.removeEventListener("mouseup",oi(this,$t,"f")),e.removeEventListener("mouseleave",oi(this,Ut,"f")),e.removeEventListener("wheel",oi(this,Ht,"f")),e.removeEventListener("click",oi(this,Qt,"f")),e.removeEventListener("contextmenu",oi(this,Zt,"f"))}destroy(){this.offEvents(),oi(this,Xt,"f").destroy(),ii(this,Nt,!0,"f")}}Gt=new WeakMap,Xt=new WeakMap,Nt=new WeakMap,Ht=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,Ut=new WeakMap,$t=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,qt=new WeakMap,Bt=new WeakSet,Ft=function(){this.onEvents()},_t=function(e){return e.target===oi(this,Gt,"f").boardContent.boardContext.canvas},ei=function(e){const t=oi(this,Gt,"f").boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}},ti=function(e){const t=oi(this,Gt,"f").sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!(ni(e.x)&&ni(e.y)&&e.x<=i&&e.y<=o)};var ri,li,si=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},hi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};const ci={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideElementMap:null};class di{constructor(){ri.set(this,void 0),li.set(this,void 0);const e=new ae({defaultStorage:ci}),t=new ae({defaultStorage:{}});si(this,ri,e,"f"),si(this,li,t,"f")}getActiveStorage(e){return hi(this,ri,"f").get(e)}setActiveStorage(e,t){return hi(this,ri,"f").set(e,t)}getActiveStoreSnapshot(e){return hi(this,ri,"f").getSnapshot(e)}getSharedStorage(e){return hi(this,li,"f").get(e)}setSharedStorage(e,t){return hi(this,li,"f").set(e,t)}getSharedStoreSnapshot(e){return hi(this,li,"f").getSnapshot(e)}getActiveViewScaleInfo(){return{scale:hi(this,ri,"f").get("scale"),offsetTop:hi(this,ri,"f").get("offsetTop"),offsetBottom:hi(this,ri,"f").get("offsetBottom"),offsetLeft:hi(this,ri,"f").get("offsetLeft"),offsetRight:hi(this,ri,"f").get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;hi(this,ri,"f").set("scale",t),hi(this,ri,"f").set("offsetTop",i),hi(this,ri,"f").set("offsetBottom",o),hi(this,ri,"f").set("offsetLeft",n),hi(this,ri,"f").set("offsetRight",a)}setActiveViewSizeInfo(e){hi(this,ri,"f").set("width",e.width),hi(this,ri,"f").set("height",e.height),hi(this,ri,"f").set("devicePixelRatio",e.devicePixelRatio),hi(this,ri,"f").set("contextWidth",e.contextWidth),hi(this,ri,"f").set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:hi(this,ri,"f").get("width"),height:hi(this,ri,"f").get("height"),devicePixelRatio:hi(this,ri,"f").get("devicePixelRatio"),contextWidth:hi(this,ri,"f").get("contextWidth"),contextHeight:hi(this,ri,"f").get("contextHeight")}}getActiveOverrideElemenentMap(){return hi(this,ri,"f").get("overrideElementMap")}setActiveOverrideElemenentMap(e){hi(this,ri,"f").set("overrideElementMap",e)}}ri=new WeakMap,li=new WeakMap;var fi,ui,gi,vi,mi,wi,yi=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},pi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};const{requestAnimationFrame:xi}=window;class Si extends J{constructor(e){super(),fi.add(this),ui.set(this,void 0),gi.set(this,[]),vi.set(this,"FREE"),yi(this,ui,e,"f"),pi(this,fi,"m",mi).call(this)}resetViewVisibleInfoMap(e,t){e&&pi(this,ui,"f").calculator.resetViewVisibleInfoMap(e,t)}drawFrame(){const{sharer:e}=pi(this,ui,"f"),t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();pi(this,gi,"f").push({activeStore:t,sharedStore:i}),pi(this,fi,"m",wi).call(this)}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:n}=pi(this,ui,"f"),{moveX:a,moveY:r}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:a}=o,r=t/o.scale,l=i.x,s=i.y;return{moveX:l-l*r+(n*r-n),moveY:s-s*r+(a*r-a)}}({scale:t,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",t),o||pi(this,ui,"f").calculator.updateVisiableStatus({viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),{moveX:a,moveY:r}}scroll(e){const{sharer:t}=pi(this,ui,"f"),i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n,ignoreUpdateVisibleStatus:a}=e,r=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:a}=o,{width:r,height:l,contextWidth:s,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,f=o.offsetTop,u=o.offsetBottom;return c+=t,f+=i,d=r-(s*a+c),u=l-(h*a+f),{scale:a,offsetTop:f,offsetLeft:c,offsetRight:d,offsetBottom:u}}({moveX:o,moveY:n,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(r),a||pi(this,ui,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),r}updateViewScaleInfo(e){const{sharer:t}=pi(this,ui,"f"),i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:a}=t,{width:r,height:l,contextWidth:s,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:r-(s*i+c/i),offsetBottom:l-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),pi(this,ui,"f").calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=pi(this,ui,"f"),o=i.getActiveViewSizeInfo(),n=Object.assign(Object.assign({},o),e),{width:a,height:r,devicePixelRatio:l}=n,{underlayContext:s,boardContext:h,overlayContext:c,viewContext:d}=pi(this,ui,"f").boardContent;return h.canvas.width=a*l,h.canvas.height=r*l,h.canvas.style.width=`${a}px`,h.canvas.style.height=`${r}px`,s.canvas.width=a*l,s.canvas.height=r*l,c.canvas.width=a*l,c.canvas.height=r*l,d.canvas.width=a*l,d.canvas.height=r*l,i.setActiveViewSizeInfo(n),(null==t?void 0:t.ignoreUpdateVisibleStatus)||pi(this,ui,"f").calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),n}}ui=new WeakMap,gi=new WeakMap,vi=new WeakMap,fi=new WeakSet,mi=function(){const{renderer:e}=pi(this,ui,"f");e.on("load",(()=>{this.drawFrame()}))},wi=function e(){if("DRAWING"===pi(this,vi,"f")||0===pi(this,gi,"f").length)return;yi(this,vi,"DRAWING","f");const t=pi(this,gi,"f").shift(),{renderer:i,boardContent:o,beforeDrawFrame:n,afterDrawFrame:a}=pi(this,ui,"f");if(t){const{scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h,width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g}=t.activeStore,v={scale:e,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h},m={width:c,height:d,contextHeight:f,contextWidth:u,devicePixelRatio:g};(null==t?void 0:t.activeStore.data)&&i.drawData(t.activeStore.data,{viewScaleInfo:v,viewSizeInfo:m}),n({snapshot:t}),o.drawView(),a({snapshot:t})}0!==pi(this,gi,"f").length?yi(this,vi,"DRAWING","f")&&xi((()=>{pi(this,fi,"m",e).call(this)})):yi(this,vi,"COMPLETE","f")};var bi,Ii,Ai,Mi,zi,Ri,Ci,Ti,Pi,Ei,ki,Wi,Li,Oi,ji,Di,Yi,Vi,Bi,Gi,Xi,Ni,Fi,Hi,Zi,Qi,Ui,$i,Ji,Ki=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},qi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class _i{constructor(e){bi.add(this),Ii.set(this,void 0),Ai.set(this,new WeakMap),Mi.set(this,[]),zi.set(this,[]),Ri.set(this,void 0),Ci.set(this,void 0),Ti.set(this,void 0),Pi.set(this,void 0),Ei.set(this,void 0),ki.set(this,new J),Wi.set(this,!1);const{boardContent:t}=e,i=new di,o=new Vt({viewContext:t.viewContext}),n=new ai({boardContent:t,sharer:i}),a=new Lt({viewContext:t.viewContext,sharer:i,calculator:o});Ki(this,Ii,e,"f"),Ki(this,Ti,i,"f"),Ki(this,Ri,n,"f"),Ki(this,Ci,a,"f"),Ki(this,Ei,o,"f"),Ki(this,Pi,new Si({boardContent:e.boardContent,sharer:i,renderer:a,calculator:qi(this,Ei,"f"),beforeDrawFrame:e=>{qi(this,bi,"m",Ui).call(this,e)},afterDrawFrame:e=>{qi(this,bi,"m",$i).call(this,e)}}),"f"),qi(this,bi,"m",Li).call(this),qi(this,bi,"m",Ji).call(this)}isDestroyed(){return qi(this,Wi,"f")}destroy(){qi(this,Ri,"f").destroy(),qi(this,Ci,"f").destroy(),qi(this,Ei,"f").destroy(),qi(this,ki,"f").destroy(),Ki(this,Wi,!0,"f")}getSharer(){return qi(this,Ti,"f")}getViewer(){return qi(this,Pi,"f")}getRenderer(){return qi(this,Ci,"f")}setData(e,t){const{modifiedOptions:i}=t||{},o=qi(this,Ti,"f");qi(this,Ti,"f").setActiveStorage("data",e);const n=o.getActiveViewSizeInfo(),a=o.getActiveViewScaleInfo(),r=Se(e.elements,{viewWidth:n.width,viewHeight:n.height,extend:!0});qi(this,Pi,"f").resetViewVisibleInfoMap(e,{viewSizeInfo:n,viewScaleInfo:a}),qi(this,Pi,"f").drawFrame();const l=Object.assign(Object.assign({},n),r);return qi(this,Ti,"f").setActiveViewSizeInfo(l),{viewSizeInfo:l}}getData(){const{data:e}=qi(this,Ti,"f").getActiveStoreSnapshot();return e}use(e,t){var i,o,n;if(qi(this,Ai,"f").has(e)){const t=qi(this,Ai,"f").get(e);if(t)return null===(o=(i=t.middlewareObject).use)||void 0===o||o.call(i),t.status="enable",qi(this,Ai,"f").set(e,t),void qi(this,bi,"m",Ji).call(this)}const{boardContent:a,container:r}=qi(this,Ii,"f"),l=e({boardContent:a,sharer:qi(this,Ti,"f"),viewer:qi(this,Pi,"f"),calculator:qi(this,Ei,"f"),eventHub:qi(this,ki,"f"),container:r},t);null===(n=l.use)||void 0===n||n.call(l),qi(this,Mi,"f").push(e),qi(this,zi,"f").push(l),qi(this,Ai,"f").set(e,{status:"enable",middlewareObject:l,config:t}),qi(this,bi,"m",Ji).call(this)}disuse(e){var t,i;const o=qi(this,Ai,"f").get(e);o&&(null===(i=(t=o.middlewareObject).disuse)||void 0===i||i.call(t),o.status="disable",qi(this,Ai,"f").set(e,o),qi(this,bi,"m",Ji).call(this))}resetMiddlewareConfig(e,t){var i,o;if(qi(this,Ai,"f").has(e)){const n=qi(this,Ai,"f").get(e);n&&(null===(o=(i=n.middlewareObject).resetConfig)||void 0===o||o.call(i,t))}}scale(e){const t=qi(this,Pi,"f"),{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:n}=t.scale(Object.assign(Object.assign({},e),{ignoreUpdateVisibleStatus:!0}));t.scroll({moveX:o,moveY:n,ignoreUpdateVisibleStatus:i})}scroll(e){return qi(this,Pi,"f").scroll(e)}updateViewScaleInfo(e){return qi(this,Pi,"f").updateViewScaleInfo(e)}resize(e,t){const i=qi(this,Pi,"f").resize(e,t),{width:o,height:n,devicePixelRatio:a}=e,{boardContent:r}=qi(this,Ii,"f");r.viewContext.$resize({width:o,height:n,devicePixelRatio:a}),r.overlayContext.$resize({width:o,height:n,devicePixelRatio:a}),r.boardContext.$resize({width:o,height:n,devicePixelRatio:a}),r.underlayContext.$resize({width:o,height:n,devicePixelRatio:a}),qi(this,Pi,"f").drawFrame(),qi(this,Ri,"f").trigger("resize",i),qi(this,Ti,"f").setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=qi(this,Ii,"f"),{underlayContext:t,overlayContext:i,viewContext:o,boardContext:n}=e;t.clearRect(0,0,t.canvas.width,t.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),n.clearRect(0,0,n.canvas.width,n.canvas.height),qi(this,bi,"m",Qi).call(this)}getEventHub(){return qi(this,ki,"f")}onWatcherEvents(){qi(this,Ri,"f").onEvents()}offWatcherEvents(){qi(this,Ri,"f").offEvents()}}Ii=new WeakMap,Ai=new WeakMap,Mi=new WeakMap,zi=new WeakMap,Ri=new WeakMap,Ci=new WeakMap,Ti=new WeakMap,Pi=new WeakMap,Ei=new WeakMap,ki=new WeakMap,Wi=new WeakMap,bi=new WeakSet,Li=function(){qi(this,Ri,"f").on("pointStart",qi(this,bi,"m",Oi).bind(this)),qi(this,Ri,"f").on("pointEnd",qi(this,bi,"m",ji).bind(this)),qi(this,Ri,"f").on("pointMove",qi(this,bi,"m",Di).bind(this)),qi(this,Ri,"f").on("pointLeave",qi(this,bi,"m",Yi).bind(this)),qi(this,Ri,"f").on("hover",qi(this,bi,"m",Vi).bind(this)),qi(this,Ri,"f").on("wheel",qi(this,bi,"m",Xi).bind(this)),qi(this,Ri,"f").on("wheelScale",qi(this,bi,"m",Ni).bind(this)),qi(this,Ri,"f").on("scrollX",qi(this,bi,"m",Fi).bind(this)),qi(this,Ri,"f").on("scrollY",qi(this,bi,"m",Hi).bind(this)),qi(this,Ri,"f").on("resize",qi(this,bi,"m",Zi).bind(this)),qi(this,Ri,"f").on("doubleClick",qi(this,bi,"m",Bi).bind(this)),qi(this,Ri,"f").on("contextMenu",qi(this,bi,"m",Gi).bind(this)),qi(this,Ci,"f").on("load",(()=>{qi(this,ki,"f").trigger("loadResource")}))},Oi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointStart)||void 0===t?void 0:t.call(o,e)))return}},ji=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointEnd)||void 0===t?void 0:t.call(o,e)))return}},Di=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointMove)||void 0===t?void 0:t.call(o,e)))return}},Yi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.pointLeave)||void 0===t?void 0:t.call(o,e)))return}},Vi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.hover)||void 0===t?void 0:t.call(o,e)))return}},Bi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.doubleClick)||void 0===t?void 0:t.call(o,e)))return}},Gi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.contextMenu)||void 0===t?void 0:t.call(o,e)))return}},Xi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheel)||void 0===t?void 0:t.call(o,e)))return}},Ni=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.wheelScale)||void 0===t?void 0:t.call(o,e)))return}},Fi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollX)||void 0===t?void 0:t.call(o,e)))return}},Hi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.scrollY)||void 0===t?void 0:t.call(o,e)))return}},Zi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.resize)||void 0===t?void 0:t.call(o,e)))return}},Qi=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.clear)||void 0===t?void 0:t.call(o,e)))return}},Ui=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.beforeDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},$i=function(e){var t;for(let i=0;i<qi(this,zi,"f").length;i++){const o=qi(this,zi,"f")[i];if(!1===(null===(t=null==o?void 0:o.afterDrawFrame)||void 0===t?void 0:t.call(o,e)))return}},Ji=function(){const e=[],t=qi(this,Ai,"f");qi(this,Mi,"f").forEach((i=>{const o=t.get(i);"enable"===(null==o?void 0:o.status)&&(null==o?void 0:o.middlewareObject)&&e.push(o.middlewareObject)})),Ki(this,zi,e,"f")};const eo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA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r05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==",to="selectInGroup",io={CURSOR:"cursor",CHANGE:"change",RULER:"ruler",SCALE:"scale",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:to,SNAP_TO_GRID:to},oo={};Object.keys(io).forEach((e=>{Object.defineProperty(oo,e,{value:io[e],writable:!1})}));class no{constructor(e,h){x(this,r),x(this,t),x(this,i),x(this,o,null),x(this,n,null),x(this,a,{auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3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Y6H0zhFmoF7vtxk+l9q3ieQfrDo8msF7cy3cN56g7ZWnKcep7IxnrQmz+wHKu2K3EKJWbPpWSUTQ4ZtRJc23sC6ZGB9ZM52JwcboIQjzUvZvNxYfeHlyVkZFcBbux6wKA6ShjoM5yM8uH0Xpuy8ekAQuZc2W8P8nEei9p9mMmPgAfJHO0O27e0lHppw9MEDJo//A4eoE91iB48SJ80lFMB/t/+V/sPGZfTmtMFR4EAAAAASUVORK5CYII="}),S(this,i,e),S(this,t,h.eventHub),b(this,r,l).call(this),b(this,r,s).call(this)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,l=function(){const e=p(this,t);b(this,r,h).call(this,"default"),e.on(oo.CURSOR,(e=>{var t;"over-element"!==e.type&&e.type?"resize-rotate"===e.type?b(this,r,h).call(this,"rotate"):"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?b(this,r,c).call(this,e):"drag-default"===e.type?b(this,r,h).call(this,"drag-default"):"drag-active"===e.type?b(this,r,h).call(this,"drag-active"):b(this,r,h).call(this,"auto"):b(this,r,h).call(this,"auto")}))},s=function(){W(eo).then((e=>{S(this,n,e)})).catch((e=>{console.error(e)}))},h=function(e){if(p(this,o)===e)return;S(this,o,e);const t=p(this,a)[p(this,o)]||p(this,a).auto;let n=0,r=0;(e.startsWith("rotate-")&&p(this,a)[p(this,o)]||"rotate"===e)&&(n=10,r=10),p(this,i).style.cursor="default"===e?"default":`image-set(url(${t})2x) ${n} ${r}, auto`},c=function(e){var t;let i=0;"resize-top"===e.type?i+=0:"resize-top-right"===e.type?i+=45:"resize-right"===e.type?i+=90:"resize-bottom-right"===e.type?i+=135:"resize-bottom"===e.type?i+=180:"resize-bottom-left"===e.type?i+=225:"resize-left"===e.type?i+=270:"resize-top-left"===e.type&&(i+=315),i+=pe((null==(t=null==e?void 0:e.element)?void 0:t.angle)||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach((e=>{i+=pe(e.angle||0)})),i=pe(i);const o=b(this,r,d).call(this,i);b(this,r,h).call(this,o)},d=function(e){const t=`rotate-${e}`;if(!p(this,a)[t]){const i=p(this,n);if(i){const o=document.createElement("canvas"),n=i.width,r=i.height,l={x:n/2,y:r/2};o.width=n,o.height=r;const s=o.getContext("2d"),h=se(e);s.translate(l.x,l.y),s.rotate(h),s.translate(-l.x,-l.y),s.drawImage(i,0,0,n,r),s.translate(l.x,l.y),s.rotate(-h),s.translate(-l.x,-l.y);const c=o.toDataURL("image/png");p(this,a)[t]=c}}return t};const ao="SELECT",ro=Symbol(`${ao}_actionType`),lo=Symbol(`${ao}_resizeType`),so=Symbol(`${ao}_areaStart`),ho=Symbol(`${ao}_areaEnd`),co=Symbol(`${ao}_hoverElement`),fo=Symbol(`${ao}_hoverElementVertexes`),uo=Symbol(`${ao}_selectedElementList`),go=Symbol(`${ao}_selectedElementListVertexes`),vo=Symbol(`${ao}_selectedElementController`),mo=Symbol(`${ao}_selectedElementPosition`),wo=Symbol(`${ao}_groupQueue`),yo=Symbol(`${ao}_groupQueueVertexesList`),po=Symbol(`${ao}_isMoving`),xo=Symbol(`${ao}_enableSelectInGroup`),So=Symbol(`${ao}_enableSnapToGrid`),bo={activeColor:"#1973ba",activeAreaColor:"#1976d21c",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Io(e,t,i){const{borderColor:o,borderWidth:n,background:a,lineDash:r}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=a,e.setLineDash(r),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.lineTo(t[0].x,t[0].y),e.closePath(),e.stroke(),e.fill()}function Ao(e,t,i,o){const{borderColor:n,borderWidth:a,lineDash:r}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=n,e.setLineDash(r),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function Mo(e,t,i){const{borderColor:o,borderWidth:n,lineDash:a}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.setLineDash(a),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[2].x,t[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(t[1].x,t[1].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function zo(e,t,i){const{size:o,borderColor:n,borderWidth:a,lineDash:r}=i,l=t.x-o/2,s=t.x+o/2,h=t.y-o/2,c=t.y+o/2;Mo(e,[{x:l,y:h},{x:s,y:h},{x:s,y:c},{x:l,y:c}],{borderColor:n,borderWidth:a,lineDash:r})}function Ro(e,t,i){if(!t)return;const{style:o}=i,{activeColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Io(e,ke(t,i),a)}function Co(e,t,i){if(!t)return;const{style:o}=i,{lockedColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};Io(e,ke(t,i),a);const{controller:r}=i;if(r){const{topLeft:t,topRight:o,bottomLeft:l,bottomRight:s,topMiddle:h,bottomMiddle:c,leftMiddle:d,rightMiddle:f}=r,u={...a,borderWidth:1,background:n};Mo(e,ke(h.vertexes,i),u),Mo(e,ke(c.vertexes,i),u),Mo(e,ke(d.vertexes,i),u),Mo(e,ke(f.vertexes,i),u),Mo(e,ke(t.vertexes,i),u),Mo(e,ke(o.vertexes,i),u),Mo(e,ke(l.vertexes,i),u),Mo(e,ke(s.vertexes,i),u)}}function To(e,t,i){var o;if(!t)return;const{hideControllers:n,style:a,rotateControllerPattern:r,viewSizeInfo:l,element:s}=i,{devicePixelRatio:h=1}=l,{activeColor:c}=a,{elementWrapper:d,topLeft:f,topRight:u,bottomLeft:g,bottomRight:v,rotate:m}=t,w={borderColor:c,borderWidth:2,background:"transparent",lineDash:[]},y={...w,borderWidth:4,background:"#FFFFFF"};if(Io(e,ke(d,i),w),!n&&(Io(e,ke(f.vertexes,i),y),Io(e,ke(u.vertexes,i),y),Io(e,ke(g.vertexes,i),y),Io(e,ke(v.vertexes,i),y),!1!==(null==(o=null==s?void 0:s.operations)?void 0:o.rotatable))){!function(e,t,i){const{size:o,borderColor:n,borderWidth:a,background:r}=i,l=t,s=o/2,h=s,c=s;if(h>=0&&c>=0){if("number"==typeof a&&a>0){const t=a/2+h,i=a/2+c;e.beginPath(),e.strokeStyle=n,e.lineWidth=a,e.circle(l.x,l.y,t,i,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath(),e.fillStyle=r,e.circle(l.x,l.y,h,c,0,0,2*Math.PI),e.closePath(),e.fill()}}(e,Ee(m.center,i),{...y,size:m.size,borderWidth:0});const t=Ee(m.center,i);e.drawImage(r.canvas,0,0,r.canvas.width/h,r.canvas.height/h,t.x-m.size/2,t.y-m.size/2,m.size,m.size)}}function Po(e,t){const{xLines:i,yLines:o,style:n}=t,{referenceColor:a}=n,r={borderColor:a,borderWidth:1,lineDash:[]},l={...r,size:6};i&&i.forEach((t=>{t.forEach(((i,o)=>{zo(e,i,l),t[o+1]&&Ao(e,t[o],t[o+1],r)}))})),o&&o.forEach((t=>{t.forEach(((i,o)=>{zo(e,i,l),t[o+1]&&Ao(e,t[o],t[o+1],r)}))}))}function Eo(e){return e*Math.PI/180}function ko(e,t){return Math.sqrt(e*e+t*t)}function Wo(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Lo(e,t){const{ctx:i,viewScaleInfo:o,vertexes:n}=t,a=Ee(n[0],{viewScaleInfo:o}),r=Ee(n[1],{viewScaleInfo:o}),l=Ee(n[2],{viewScaleInfo:o}),s=Ee(n[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(r.x,r.y),i.lineTo(l.x,l.y),i.lineTo(s.x,s.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Oo(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,groupQueue:a}=t;if(!(a&&(null==a?void 0:a.length)>0))return!1;const r=Ce(a),l=r[r.length-1];return!!l&&Lo(e,{ctx:i,vertexes:l,viewScaleInfo:o,viewSizeInfo:n})}function jo(e,t){var i,o,n,a,r;const l={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:s,data:h,calculator:c,selectedElements:d,viewScaleInfo:f,viewSizeInfo:u,areaSize:g,groupQueue:v,selectedElementController:m}=t;if(m){const{left:t,right:n,top:a,bottom:r,topLeft:h,topRight:c,bottomLeft:g,bottomRight:w,rotate:y}=m,p=[t,n,a,r,h,c,g,w];1===(null==d?void 0:d.length)&&!1!==(null==(o=null==(i=null==d?void 0:d[0])?void 0:i.operations)?void 0:o.rotatable)&&p.push(y);for(let t=0;t<p.length;t++){const i=p[t];if(Lo(e,{ctx:s,vertexes:i.vertexes,viewSizeInfo:u,viewScaleInfo:f})){l.type=`resize-${i.type}`,d&&(null==d?void 0:d.length)>0&&(l.groupQueue=v||[],l.elements=[d[0]]);break}}}if(v&&Array.isArray(v)&&v.length>0){const t=v[v.length-1];if((null==(n=null==t?void 0:t.detail)?void 0:n.children)&&Array.isArray(null==(a=null==t?void 0:t.detail)?void 0:a.children))for(let i=t.detail.children.length-1;i>=0;i--){const o=t.detail.children[i],n=Te(o,{groupQueue:v});if(n&&Lo(e,{ctx:s,vertexes:n,viewScaleInfo:f,viewSizeInfo:u}))return l.type||(l.type="over-element"),l.groupQueue=v,l.elements=[o],l}return l}if(null!==l.type)return l;if(g&&Array.isArray(d)&&(null==d?void 0:d.length)>1){const{x:t,y:i,w:o,h:n}=g;if(e.x>=t&&e.x<=t+o&&e.y>=i&&e.y<=i+n)return l.type="list-area",l.elements=d,l}if(h){const{index:t,element:i}=c.getPointElement(e,{data:h,viewScaleInfo:f,viewSizeInfo:u});if(t>=0&&i&&!0!==(null==(r=null==i?void 0:i.operations)?void 0:r.invisible))return l.elements=[i],l.type="over-element",l}return l}function Do(e,t){const{x:i,y:o,w:n,h:a,angle:r=0}=e,{center:l,start:s,end:h,viewScaleInfo:c}=t,d=Ee(l,{viewScaleInfo:c}),f=pe(r),u=function(e,t,i){const o=ue(e,t),n=ue(e,i);return null!==n&&null!==o?n-o:0}(d,s,h);return{x:i,y:o,w:n,h:a,angle:pe(f+u/Math.PI*180)}}function Yo(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{viewScaleInfo:n}=t;let a=null;for(let t=0;t<e.length;t++){const r=e[t];if(null==(i=null==r?void 0:r.operations)?void 0:i.invisible)continue;const l=Pe(r,{viewScaleInfo:n});if(l.angle&&(l.angle>0||l.angle<0)){const e=we(l);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];l.x=Math.min(...t),l.y=Math.min(...i),l.w=Math.abs(Math.max(...t)-Math.min(...t)),l.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(a){const e=Math.min(l.x,o.x),t=Math.min(l.y,o.y),i=Math.max(l.x+l.w,o.x+o.w),n=Math.max(l.y+l.h,o.y+o.h);o.x=e,o.y=t,o.w=Math.abs(i-e),o.h=Math.abs(n-t)}else o.x=l.x,o.y=l.y,o.w=l.w,o.h=l.h;a=l}return o}function Vo(e){return{minX:e.topLeft.x,minY:e.topLeft.y,maxX:e.bottomRight.x,maxY:e.bottomRight.y,midX:e.center.x,midY:e.center.y}}const Bo=(e,t)=>{if(0===e.length)throw null;if(1===e.length)return e[0];let i=0,o=e.length-1;for(;i<=o;){const n=Math.floor((i+o)/2);if(e[n]===t)return e[n];e[n]<t?i=n+1:o=n-1}return i>=e.length?e[o]:o<0?e[i]:Math.abs(e[o]-t)<=Math.abs(e[i]-t)?e[o]:e[i]},Go=(e,t)=>Math.abs(e-t)<1e-5;function Xo(e,t){var i,o;const{data:n,groupQueue:a,calculator:r,viewScaleInfo:l,viewSizeInfo:s}=t;let h=n.elements||[];(null==a?void 0:a.length)>0&&(h=(null==(o=null==(i=a[a.length-1])?void 0:i.detail)?void 0:o.children)||[]);const c=[];h.forEach((t=>{if(t.uuid!==e){const e=r.calcViewRectInfoFromRange(t.uuid,{checkVisible:!0,viewScaleInfo:l,viewSizeInfo:s});e&&c.push(e)}}));const d=r.calcViewRectInfoFromRange(e,{viewScaleInfo:l,viewSizeInfo:s});if(!d)return null;const f={},u={},g={},v={},m=[],w=[];let y=[],p=[];const x=Vo(d);f[x.minX]=[x.minY,x.midY,x.maxY],f[x.midX]=[x.minY,x.midY,x.maxY],f[x.maxX]=[x.minY,x.midY,x.maxY],u[x.minY]=[x.minX,x.midX,x.maxX],u[x.midY]=[x.minX,x.midX,x.maxX],u[x.maxY]=[x.minX,x.midX,x.maxX],c.forEach((e=>{const t=Vo(e);g[t.minX]||(g[t.minX]=[]),g[t.midX]||(g[t.midX]=[]),g[t.maxX]||(g[t.maxX]=[]),v[t.minY]||(v[t.minY]=[]),v[t.midY]||(v[t.midY]=[]),v[t.maxY]||(v[t.maxY]=[]),g[t.minX]=[t.minY,t.midY,t.maxY],g[t.midX]=[t.minY,t.midY,t.maxY],g[t.maxX]=[t.minY,t.midY,t.maxY],y.push(t.minX),y.push(t.midX),y.push(t.maxX),v[t.minY]=[t.minX,t.midX,t.maxX],v[t.midY]=[t.minX,t.midX,t.maxX],v[t.maxY]=[t.minX,t.midX,t.maxX],p.push(t.minY),p.push(t.midY),p.push(t.maxY)})),y=y.sort(((e,t)=>e-t)),p=p.sort(((e,t)=>e-t));let S=null,b=null,I=null,A=null,M=null,z=null,R=null,C=null;if(y.length>0){I=Bo(y,x.minX),A=Bo(y,x.midX),M=Bo(y,x.maxX);const e=Math.abs(I-x.minX),t=Math.abs(A-x.midX),i=Math.abs(M-x.maxX),o=Math.min(e,t,i);o<=2/l.scale&&(Go(o,e)?S=I-x.minX:Go(o,t)?S=A-x.midX:Go(o,i)&&(S=M-x.maxX))}if(p.length>0){z=Bo(p,x.minY),R=Bo(p,x.midY),C=Bo(p,x.maxY);const e=Math.abs(z-x.minY),t=Math.abs(R-x.midY),i=Math.abs(C-x.maxY),o=Math.min(e,t,i);o<=2/l.scale&&(Go(o,e)?b=z-x.minY:Go(o,t)?b=R-x.midY:Go(o,i)&&(b=C-x.maxY))}const T={...x};if(null!==S&&(T.minX+=S,T.midX+=S,T.maxX+=S),null!==b&&(T.minY+=b,T.midY+=b,T.maxY+=b),B.x(S)&&null!==S&&null!==I&&null!==A&&null!==M){if(Go(S,I-x.minX)){const e={x:I,yList:[]};e.yList.push(T.minY),e.yList.push(T.maxY),e.yList.push(...(null==v?void 0:v[I])||[]),m.push(e)}if(Go(S,A-x.minX)){const e={x:A,yList:[]};e.yList.push(T.minY),e.yList.push(T.maxY),e.yList.push(...(null==v?void 0:v[A])||[]),m.push(e)}if(Go(S,M-x.minX)){const e={x:M,yList:[]};e.yList.push(T.minY),e.yList.push(T.maxY),e.yList.push(...(null==v?void 0:v[M])||[]),m.push(e)}}if(B.y(b)&&null!==b&&null!==z&&null!==R&&null!==C){if(Go(b,z-x.minY)){const e={y:z,xList:[]};e.xList.push(T.minX),e.xList.push(T.maxX),e.xList.push(...(null==g?void 0:g[z])||[]),w.push(e)}if(Go(b,R-x.midY)){const e={y:R,xList:[]};e.xList.push(T.minX),e.xList.push(T.maxX),e.xList.push(...(null==g?void 0:g[z])||[]),w.push(e)}if(Go(b,C-x.maxY)){const e={y:C,xList:[]};e.xList.push(T.minX),e.xList.push(T.maxX),e.xList.push(...(null==g?void 0:g[C])||[]),w.push(e)}}const P=[];(null==m?void 0:m.length)>0&&m.forEach(((e,t)=>{P.push([]),e.yList.forEach((i=>{P[t].push({x:e.x,y:i})}))}));const E=[];return(null==w?void 0:w.length)>0&&w.forEach(((e,t)=>{E.push([]),e.xList.forEach((i=>{E[t].push({x:i,y:e.y})}))})),{offsetX:S,offsetY:b,yLines:P,xLines:E}}const No="LAYOUT_SELECT",Fo=Symbol(`${No}_layoutActionType`),Ho=Symbol(`${No}_layoutControlType`),Zo=Symbol(`${No}_layoutController`),Qo=Symbol(`${No}_layoutIsHoverContent`),Uo=Symbol(`${No}_layoutIsHoverController`),$o=Symbol(`${No}_layoutIsSelected`),Jo=Symbol(`${No}_layoutIsSelected`),Ko={activeColor:"#b331c9"};function qo(e,t,i){const{activeColor:o}=i;e.setLineDash([]),e.fillStyle="#FFFFFF",e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.fill(),e.strokeStyle=o,e.lineWidth=2,e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function _o(e,t){const{start:i,end:o,style:n}=t,{activeColor:a}=n,r=a;e.setLineDash([]),e.strokeStyle=r,e.lineWidth=2,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.closePath(),e.stroke()}function en(e){const{fill:t,devicePixelRatio:i}=e,o=(e=>({uuid:M(),type:"path",x:0,y:0,w:200,h:200,detail:{commands:[{type:"M",params:[512,0]},{type:"c",params:[282.8,0,512,229.2,512,512]},{type:"s",params:[-229.2,512,-512,512]},{type:"S",params:[0,794.8,0,512,229.2,0,512,0]},{type:"z",params:[]},{type:"m",params:[309.8,253.8]},{type:"c",params:[0,-10.5,-6.5,-19.8,-15.7,-23.8,-9.7,-4,-21,-2,-28.2,5.6]},{type:"l",params:[-52.5,52]},{type:"c",params:[-56.9,-53.7,-133.9,-85.5,-213.4,-85.5,-170.7,0,-309.8,139.2,-309.8,309.8,0,170.6,139.2,309.8,309.8,309.8,92.4,0,179.5,-40.8,238.4,-111.8,4,-5.2,4,-12.9,-.8,-17.3]},{type:"L",params:[694.3,637]},{type:"c",params:[-2.8,-2.4,-6.5,-3.6,-10.1,-3.6,-3.6,.4,-7.3,2,-9.3,4.8,-39.5,51.2,-98.8,80.3,-163,80.3,-113.8,0,-206.5,-92.8,-206.5,-206.5,0,-113.8,92.8,-206.5,206.5,-206.5,52.8,0,102.9,20.2,140.8,55.3]},{type:"L",params:[597,416.5]},{type:"c",params:[-7.7,7.3,-9.7,18.6,-5.6,27.9,4,9.7,13.3,16.1,23.8,16.1]},{type:"H",params:[796]},{type:"c",params:[14.1,0,25.8,-11.7,25.8,-25.8]},{type:"V",params:[253.8]},{type:"z",params:[]}],fill:"#2c2c2c",stroke:"transparent",strokeWidth:0,originX:0,originY:0,originW:1024,originH:1024,opacity:1,...e}}))({fill:t}),{w:n,h:a}=o,r=Q({width:n,height:a,devicePixelRatio:i});return rt(r,o,{loader:void 0,viewScaleInfo:{scale:1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},viewSizeInfo:{width:n,height:a,devicePixelRatio:i,contextWidth:n,contextHeight:a},parentElementSize:{x:0,y:0,w:n,h:a},parentOpacity:1}),{context2d:r,fill:t}}const tn="monospace";const on="@middleware/internal-event/show-info-angle",nn={textBackground:"#1973bac6",textColor:"#ffffff"},an=10,rn="SCROLL",ln=Symbol(`${rn}_xThumbRect`),sn=Symbol(`${rn}_yThumbRect`),hn=Symbol(`${rn}_hoverXThumbRect`),cn=Symbol(`${rn}_hoverYThumbRect`),dn=Symbol(`${rn}_prevPoint`),fn=Symbol(`${rn}_activePoint`),un=Symbol(`${rn}_activeThumbType`),gn={thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"},vn=16,mn=2.5*vn;function wn(e,t,i){const o=e,{x:n,y:a,w:r,h:l}=i;return o.beginPath(),o.rect(n,a,r,l),o.closePath(),!!o.isPointInPath(t.x,t.y)}function yn(e,t){let{x:i,y:o,h:n,w:a,background:r,borderColor:l}=t;e.save(),e.shadowColor="#FFFFFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=1;{const{axis:s}=t;"X"===s?(o=o+n/4+0,n/=2):"Y"===s&&(i=i+a/4+0,a/=2);let h=t.r;h=Math.min(h,a/2,n/2),(a<2*h||n<2*h)&&(h=0),e.globalAlpha=1,e.beginPath(),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.fillStyle=r,e.fill(),e.beginPath(),e.lineWidth=1,e.strokeStyle=l,e.setLineDash([]),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.stroke()}e.restore()}function pn(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a,style:r}=t,{activeThumbType:l,prevPoint:s,activePoint:h,hoverXThumb:c,hoverYThumb:d}=a,f=function(e){const{viewScaleInfo:t,viewSizeInfo:i,hoverXThumb:o,hoverYThumb:n,style:a}=e,{width:r,height:l}=i,{offsetTop:s,offsetBottom:h,offsetLeft:c,offsetRight:d}=t,f=mn,u=vn,{thumbBackground:g,thumbBorderColor:v,hoverThumbBackground:m,hoverThumbBorderColor:w}=a;let y=0,p=0;y=Math.max(f,r-2*u-(Math.abs(c)+Math.abs(d))),y>=r&&(y=r),p=Math.max(f,l-2*u-(Math.abs(s)+Math.abs(h))),p>=l&&(p=l);const x=u;let S=x;c>0?S=x:d>0?S=r-y-u:c<=0&&y>0&&(0!==c||0!==d)&&(S=x+(r-y)*Math.abs(c)/(Math.abs(c)+Math.abs(d)),S=Math.min(Math.max(0,S-x),r-y));const b=u;let I=b;return s>0?I=b:h>0?I=l-p-u:s<=0&&p>0&&(0!==s||0!==h)&&(I=b+(l-p)*Math.abs(s)/(Math.abs(s)+Math.abs(h)),I=Math.min(Math.max(0,I-b),l-p)),{lineSize:u,xSize:y,ySize:p,translateY:I,translateX:S,xThumbBackground:o?m:g,yThumbBackground:n?m:g,xThumbBorderColor:o?w:v,yThumbBorderColor:n?w:v,xThumbRect:{x:S,y:l-u,w:y,h:u},yThumbRect:{x:r-u,y:I,w:u,h:p}}}({viewScaleInfo:o,viewSizeInfo:n,hoverXThumb:c,hoverYThumb:d,style:r});let u={...f.xThumbRect},g={...f.yThumbRect};return l&&s&&h&&("X"===l&&a.xThumbRect?(u={...a.xThumbRect},u.x=u.x+(h.x-s.x)):"Y"===l&&a.yThumbRect&&(g={...a.yThumbRect},g.y=g.y+(h.y-s.y))),yn(i,{axis:"X",...u,r:f.lineSize/2,background:f.xThumbBackground,borderColor:f.xThumbBorderColor}),yn(i,{axis:"Y",...g,r:f.lineSize/2,background:f.yThumbBackground,borderColor:f.yThumbBorderColor}),{xThumbRect:u,yThumbRect:g}}function xn(e,t){const{snapshot:i,style:o}=t,n=le(i),a=re(i),r=function(e){const{sharedStore:t}=e;return{activePoint:t[fn]||null,prevPoint:t[dn]||null,activeThumbType:t[un]||null,xThumbRect:t[ln]||null,yThumbRect:t[sn]||null,hoverXThumb:t[hn],hoverYThumb:t[cn]}}(i),{xThumbRect:l,yThumbRect:s}=pn(e,{viewSizeInfo:n,viewScaleInfo:a,scrollInfo:r,style:o});return{xThumbRect:l,yThumbRect:s}}const Sn=16,bn="monospace",In={background:"#FFFFFFA8",borderColor:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#196097"},An=[1,2,5,10,20,50,100,200,500];function Mn(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let a=10;a=Xe(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(An[0],Math.min(e,An[An.length-1]));for(let t=0;t<An.length-1;t++){const i=An[t],o=An[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const r=10*a,l=5*a;let s=0;const h=a*t,c=0-o,d=c%h,f=(c-d+h)/t,u=h-d+0;for(;u+s*h<i;){const e=Xe(f+s*a,{decimalPlaces:0}),t={num:e,position:Xe(u+s*h,{decimalPlaces:0}),showNum:e%r==0,isKeyNum:e%r==0,isSubKeyNum:e%l==0};n.push(t),s++}return{list:n,rulerUnit:a}}const zn={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"},Rn=Symbol("DRAG_prevPoint");return f=new WeakMap,u=new WeakMap,g=new WeakMap,v=new WeakSet,m=function(){p(this,g).style.position="relative"},e.Core=class{constructor(e,t){x(this,v),x(this,f),x(this,u),x(this,g);const{devicePixelRatio:i=1,width:o,height:n,createCustomContext2D:a}=t;S(this,g,e);const r=document.createElement("canvas");r.setAttribute("tabindex","0"),S(this,u,r),b(this,v,m).call(this),e.appendChild(r);const l=function(e,t){const{width:i,height:o,devicePixelRatio:n,offscreen:a,createCustomContext2D:r}=t,l={width:i,height:o,devicePixelRatio:n},s=e.getContext("2d");if(r){const e=r(l),t=r(l),i=r(l),o=Z(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}if(!0===a){const e=Q(l),t=Q(l),i=Q(l),o=Z(Object.assign({ctx:s},l)),n=()=>{const{width:n,height:a}=e.$getSize();o.clearRect(0,0,n,a),o.drawImage(i.canvas,0,0,n,a),o.drawImage(e.canvas,0,0,n,a),o.drawImage(t.canvas,0,0,n,a),i.clearRect(0,0,n,a),e.clearRect(0,0,n,a),t.clearRect(0,0,n,a)};return{underlayContext:i,viewContext:e,overlayContext:t,boardContext:o,drawView:n}}{const e=Z(l),t=Z(l),n=Z(l),a=Z(Object.assign({ctx:s},l)),r=()=>{a.clearRect(0,0,i,o),a.drawImage(n.canvas,0,0,i,o),a.drawImage(e.canvas,0,0,i,o),a.drawImage(t.canvas,0,0,i,o),n.clearRect(0,0,i,o),e.clearRect(0,0,i,o),t.clearRect(0,0,i,o)};return{underlayContext:n,viewContext:e,overlayContext:t,boardContext:a,drawView:r}}}(r,{width:o,height:n,devicePixelRatio:i,offscreen:!0,createCustomContext2D:a}),s=new _i({boardContent:l,container:e}),h=s.getSharer();h.setActiveViewSizeInfo({width:o,height:n,devicePixelRatio:i,contextWidth:o,contextHeight:n}),S(this,f,s),this.resize(h.getActiveViewSizeInfo());const c=s.getEventHub();new no(e,{eventHub:c})}isDestroyed(){return p(this,f).isDestroyed()}destroy(){p(this,f).destroy(),p(this,u).remove()}use(e,t){p(this,f).use(e,t)}disuse(e){p(this,f).disuse(e)}resetMiddlewareConfig(e,t){p(this,f).resetMiddlewareConfig(e,t)}setData(e,t){xe((null==e?void 0:e.elements)||[]),p(this,f).setData(e,t)}getData(){return p(this,f).getData()}scale(e){p(this,f).scale(e);p(this,f).getViewer().drawFrame()}resize(e){const t=p(this,f),i=t.getSharer().getActiveViewSizeInfo();t.resize({...i,...e})}clear(){p(this,f).clear()}on(e,t){p(this,f).getEventHub().on(e,t)}off(e,t){p(this,f).getEventHub().off(e,t)}trigger(e,t){p(this,f).getEventHub().trigger(e,t)}getViewInfo(){const e=p(this,f).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){p(this,f).getViewer().drawFrame()}setViewScale(e){p(this,f).updateViewScaleInfo(e)}getLoadItemMap(){return p(this,f).getRenderer().getLoadItemMap()}onBoardWatcherEvents(){p(this,f).onWatcherEvents()}offBoardWatcherEvents(){p(this,f).offWatcherEvents()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{name:"@middleware/dragger",hover(){!0!==n&&t.trigger(oo.CURSOR,{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(Rn,o),n=!0,t.trigger(oo.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(Rn);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(Rn,t)},pointEnd(){n=!1,i.setSharedStorage(Rn,null),t.trigger(oo.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o,eventHub:n}=e,{overlayContext:a}=i;let r={...nn,...t},l=!0;const s=({show:e})=>{l=e};return{name:"@middleware/info",use(){n.on(on,s)},disuse(){n.off(on,s)},resetConfig(e){r={...r,...e}},beforeDrawFrame({snapshot:e}){var t;const{textBackground:i,textColor:n}=r,s={textBackground:i,textColor:n},{sharedStore:h}=e,c=h[uo],d=h[ro],f=h[wo]||[];if(1===c.length){const i=c[0];if(i&&["select","drag","resize"].includes(d)){const n=re(e),r=le(e),{x:h,y:c,w:d,h:u,angle:g}=i,v=[...f,{uuid:M(),x:h,y:c,w:d,h:u,angle:g,type:"group",detail:{children:[]}}],m={viewScaleInfo:n,viewSizeInfo:r},w=o.calcViewRectInfoFromOrigin(i.uuid,m);let y=0;v.forEach((e=>{y+=e.angle||0}));const p=se(pe(0-y));if(w){const e=null==w?void 0:w.center,o={topLeft:ge(e,w.topLeft,p),topRight:ge(e,w.topRight,p),bottomRight:ge(e,w.bottomRight,p),bottomLeft:ge(e,w.bottomLeft,p),center:ge(e,w.center,p),top:ge(e,w.top,p),right:ge(e,w.right,p),bottom:ge(e,w.bottom,p),left:ge(e,w.left,p)},n=Xe(i.x,{decimalPlaces:2}),r=Xe(i.y,{decimalPlaces:2}),h=Xe(i.w,{decimalPlaces:2}),c=Xe(i.h,{decimalPlaces:2}),d=`${Xe(n,{decimalPlaces:0})},${Xe(r,{decimalPlaces:0})}`,f=`${Xe(h,{decimalPlaces:0})}x${Xe(c,{decimalPlaces:0})}`,u=`${Xe(i.angle||0,{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textColor:h,textBackground:c}=r;he(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:tn});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x-o/2-t,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=h,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(a,{point:{x:o.bottom.x,y:o.bottom.y+an},rotateCenter:o.center,angle:y,text:f,fontSize:an,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;he(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:tn});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(a,{point:{x:o.topLeft.x,y:o.topLeft.y-20},rotateCenter:o.center,angle:y,text:d,fontSize:an,lineHeight:16,style:s}),l&&!1!==(null==(t=i.operations)?void 0:t.rotatable)&&function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;he(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:tn});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(a,{point:{x:o.top.x+an+4,y:o.top.y-20-18},rotateCenter:o.center,angle:y,text:u,fontSize:an,lineHeight:16,style:s})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,boardContent:o,calculator:n,viewer:a,eventHub:r}=e,{overlayContext:l}=o;let s={...Ko,...t},h=null,c=null,d=null;const f=()=>{h=null,i.setSharedStorage(Fo,null),i.setSharedStorage(Ho,null),i.setSharedStorage(Zo,null),i.setSharedStorage(Qo,null),i.setSharedStorage(Uo,null),i.setSharedStorage($o,null),i.setSharedStorage(Jo,null),c=null,d=null},u=()=>{const e=i.getSharedStorage(ro);return!(!e||"area"===e)&&(f(),!0)},g=()=>{const e=i.getActiveStorage("data");if(null==e?void 0:e.layout){const{x:t,y:i,w:o,h:n}=e.layout;return{x:t,y:i,w:o,h:n}}return null},v=e=>{const t=g();if(t){const{x:o,y:n,w:a,h:r}=t;return function(e,t){return Le(e,Re(t))}(e,Pe({x:o-5,y:n-5,w:a+10,h:r+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},m=()=>{const e=i.getActiveViewScaleInfo(),t=g();if(t){const o=Be(t,{viewScaleInfo:e,controllerSize:10});i.setSharedStorage(Zo,o)}else i.setSharedStorage(Zo,null)},w=e=>{const t=i.getActiveStorage("data"),o=i.getSharedStorage(Zo);let n=null;if(o&&(null==t?void 0:t.layout)&&(null==e?void 0:e.point)){let t=null;if(o){const{topLeft:a,top:l,topRight:s,right:h,bottomRight:c,bottom:d,bottomLeft:f,left:u}=o,g=[a,l,s,h,c,d,f,u];for(let i=0;i<g.length;i++){const o=g[i];if(Le(e.point,o.vertexes)){t=`${o.type}`;break}}t&&(i.setSharedStorage(Ho,t),r.trigger(oo.CLEAR_SELECT),n=t)}}return n?i.setSharedStorage(Uo,!0):i.setSharedStorage(Uo,!1),n},y=e=>{!0!==i.getSharedStorage(Jo)&&r.trigger(oo.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],element:g()})};return{name:"@middleware/layout-selector",use:()=>{f(),m()},resetConfig(e){s={...s,...e}},hover:e=>{if(!0!==i.getSharedStorage(Jo)&&!u()){if(v(e.point)?i.setSharedStorage(Qo,!0):(i.setSharedStorage(Qo,!1),!0===c&&(a.drawFrame(),c=!1)),!0===i.getSharedStorage($o)){const t=i.getSharedStorage(Fo),o=i.getActiveStorage("data");if(null==o?void 0:o.layout)if("resize"!==t){m();const t=w(e);t?y(t):(y(),i.setSharedStorage(Fo,null))}else{const t=w(e);y(t)}return!0!==i.getSharedStorage(Uo)&&void 0}return i.getSharedStorage(Qo)&&!c&&a.drawFrame(),c=i.getSharedStorage(Qo),!0!==i.getSharedStorage(Uo)&&void 0}},pointStart:e=>{if(u())return;v(e.point)?i.setSharedStorage($o,!0):(!0===d&&(f(),a.drawFrame()),i.setSharedStorage($o,!1)),m();const t=w(e);return h=e.point,t&&i.setSharedStorage(Fo,"resize"),!0!==i.getSharedStorage($o)||d||a.drawFrame(),d=i.getSharedStorage($o),!0!==i.getSharedStorage(Uo)&&void 0},pointMove:e=>{if(!i.getSharedStorage($o)&&u())return;const t=i.getSharedStorage(Fo),o=i.getSharedStorage(Ho),r=i.getActiveStorage("data");if("resize"===t&&o&&(null==r?void 0:r.layout)){if(h){i.setSharedStorage(Jo,!0);const t=i.getActiveStorage("scale"),l=e.point.x-h.x,s=e.point.y-h.y,c=l/t,d=s/t,{x:f,y:u,w:g,h:v,operations:m={}}=r.layout,{position:w="absolute"}=m;"top"===o?"relative"===w?(r.layout.h=n.toGridNum(v-d),a.scroll({moveY:s})):(r.layout.y=n.toGridNum(u+d),r.layout.h=n.toGridNum(v-d)):"right"===o?r.layout.w=n.toGridNum(g+c):"bottom"===o?r.layout.h=n.toGridNum(v+d):"left"===o?"relative"===w?(r.layout.w=n.toGridNum(g-c),a.scroll({moveX:l})):(r.layout.x=n.toGridNum(f+c),r.layout.w=n.toGridNum(g-c)):"top-left"===o?"relative"===w?(r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v-d),a.scroll({moveX:l,moveY:s})):(r.layout.x=n.toGridNum(f+c),r.layout.y=n.toGridNum(u+d),r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v-d)):"top-right"===o?"relative"===w?(a.scroll({moveY:s}),r.layout.w=n.toGridNum(g+c),r.layout.h=n.toGridNum(v-d)):(r.layout.y=n.toGridNum(u+d),r.layout.w=n.toGridNum(g+c),r.layout.h=n.toGridNum(v-d)):"bottom-right"===o?(r.layout.w=n.toGridNum(g+c),r.layout.h=n.toGridNum(v+d)):"bottom-left"===o&&("relative"===w?(a.scroll({moveX:l}),r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v+d)):(r.layout.x=n.toGridNum(f+c),r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v+d)))}return h=e.point,m(),a.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{i.setSharedStorage(Jo,!1);const e=i.getSharedStorage(Fo),t=i.getSharedStorage(Ho),o=i.getActiveStorage("data");if(o&&"resize"===e&&t&&r.trigger(oo.CHANGE,{type:"changeLayout",data:o}),!0===i.getSharedStorage(Uo))return!1},beforeDrawFrame:({snapshot:e})=>{var t;if(u())return;const{activeColor:i}=s,o={activeColor:i},{sharedStore:n,activeStore:a}=e,r=n[Fo],h=n[Qo],c=n[$o];if(null==(t=a.data)?void 0:t.layout){const{x:t,y:i,w:n,h:s}=a.data.layout,d=re(e),f={x:t,y:i,w:n,h:s},u=Be(f,{viewScaleInfo:d,controllerSize:10});if(!0===h){const e=Pe(f,{viewScaleInfo:d});!function(e,t){const{layoutSize:i,style:o}=t,{activeColor:n}=o,{x:a,y:r,w:l,h:s}=i;e.setLineDash([]),e.strokeStyle=n,e.lineWidth=1,e.beginPath(),e.moveTo(a,r),e.lineTo(a+l,r),e.lineTo(a+l,r+s),e.lineTo(a,r+s),e.lineTo(a,r),e.closePath(),e.stroke()}(l,{layoutSize:e,style:o})}(r&&["resize"].includes(r)||!0===c)&&function(e,t){const{controller:i,style:o}=t,{topLeft:n,topRight:a,bottomLeft:r,bottomRight:l,topMiddle:s,rightMiddle:h,bottomMiddle:c,leftMiddle:d}=i;_o(e,{start:n.center,end:a.center,centerVertexes:s.vertexes,style:o}),_o(e,{start:a.center,end:l.center,centerVertexes:h.vertexes,style:o}),_o(e,{start:l.center,end:r.center,centerVertexes:c.vertexes,style:o}),_o(e,{start:r.center,end:n.center,centerVertexes:d.vertexes,style:o}),qo(e,n.vertexes,o),qo(e,a.vertexes,o),qo(e,l.vertexes,o),qo(e,r.vertexes,o)}(l,{controller:u,style:o})}},scrollX:()=>{f()},scrollY:()=>{f()},wheelScale:()=>{f()}}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:o}=e,n=t.boardContext.canvas,a=e.container||document.body,r=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`,l=document.createElement("div");return l.setAttribute("id",r),l.style.position="fixed",l.style.top="0",l.style.bottom="unset",l.style.left="0",l.style.right="unset",a.appendChild(l),{name:"@middleware/pointer",use(){},disuse(){},pointStart(e){},pointEnd(){},contextMenu(e){const{point:t}=e,{left:a,top:r}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:a}=e;return{left:t,top:i,width:o,height:a}})();l.style.left=`${a+t.x}px`,l.style.top=`${r+t.y}px`;const s=o.getSharedStorage(uo);i.trigger(oo.CONTEXT_MENU,{pointerContainer:l,selectedElements:s||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:o,eventHub:n,calculator:a}=e,{overlayContext:r,underlayContext:l}=i;let s={...In,...t},h=!0,c=!0;const d=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(h=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(c=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||o.drawFrame()};return{name:"@middleware/ruler",use(){n.on(oo.RULER,d)},disuse(){n.off(oo.RULER,d)},resetConfig(e){s={...s,...e}},beforeDrawFrame:({snapshot:e})=>{const{background:t,borderColor:i,scaleColor:o,textColor:n,gridColor:d,gridPrimaryColor:f,selectedAreaColor:u}=s,g={background:t,borderColor:i,scaleColor:o,textColor:n,gridColor:d,gridPrimaryColor:f,selectedAreaColor:u};if(!0===h){const t=re(e),i=le(e);!function(e,t){const{snapshot:i,calculator:o,style:n}=t,{sharedStore:a}=i,{selectedAreaColor:r}=n,l=a[uo],s=a[ro];if(["select","drag","drag-list","drag-list-end"].includes(s)&&l.length>0){const t=re(i),n=le(i),a=[],s=[],h=[],c=[],d=[];if(l.forEach((e=>{const i=o.calcViewRectInfoFromRange(e.uuid,{viewScaleInfo:t,viewSizeInfo:n});i&&(a.push(i),s.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))})),!(a.length>0))return;const f=Math.min(...s),u=Math.max(...h),g=Math.min(...c),v=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(f,0),e.lineTo(u,0),e.lineTo(u,Sn),e.lineTo(f,Sn),e.fillStyle=r,e.closePath(),e.fill(),e.beginPath(),e.moveTo(0,g),e.lineTo(Sn,g),e.lineTo(Sn,v),e.lineTo(0,v),e.fillStyle=r,e.closePath(),e.fill()}}(r,{snapshot:e,calculator:a,style:g}),function(e,t){const{viewSizeInfo:i,style:o}=t,{width:n,height:a}=i,{background:r,borderColor:l}=o;e.beginPath();const s=-1;e.moveTo(s,s),e.lineTo(n+1,s),e.lineTo(n+1,Sn),e.lineTo(Sn,Sn),e.lineTo(Sn,a+1),e.lineTo(s,a+1),e.lineTo(s,s),e.closePath(),e.fillStyle=r,e.fill(),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=l,e.stroke()}(r,{viewScaleInfo:t,viewSizeInfo:i,style:g});const{list:o,rulerUnit:n}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:a}=i;return Mn({axis:"X",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<Sn||(e.beginPath(),e.moveTo(o.position,16),e.lineTo(o.position,o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8),e.closePath(),e.lineWidth=1,e.setLineDash([]),e.fillStyle=n,e.stroke(),o.isKeyNum&&(e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:bn}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(r,{scaleList:o,style:g});const{list:s}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return Mn({axis:"Y",scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o,r=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<Sn)&&(e.beginPath(),e.moveTo(16,o.position),e.lineTo(o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8,o.position),e.closePath(),e.fillStyle=n,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=r,i=o.position+r,n=`${o.num}`;he(e,-90,{x:t,y:i},(()=>{e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:bn}),e.fillText(n,13.2,o.position+r)}))}}}(r,{scaleList:s,style:g}),!0===c){!function(e,t){const{xList:i,yList:o,viewSizeInfo:n,style:a}=t,{width:r,height:l}=n,{gridColor:s,gridPrimaryColor:h}=a;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,l),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.closePath(),e.lineWidth=1,e.setLineDash([]),e.stroke()}for(let t=0;t<o.length;t++){const i=o[t];e.beginPath(),e.moveTo(0,i.position),e.lineTo(r,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.lineWidth=1,e.closePath(),e.stroke()}}(1===n?r:l,{xList:o,yList:s,viewScaleInfo:t,viewSizeInfo:i,style:g})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:n,point:a}=e,{scale:r}=i.getActiveViewScaleInfo();let l=r;if(n<0?l=1.1*r:n>0&&(l=.9*r),l<.05||l>50)return;const{moveX:s,moveY:h}=t.scale({scale:l,point:a});t.scroll({moveX:s,moveY:h}),t.drawFrame();const c=Xe(r);o.trigger(oo.SCALE,{scale:c})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,boardContent:o,sharer:n,eventHub:a}=e,{overlayContext:r}=o;n.setSharedStorage(ln,null),n.setSharedStorage(sn,null);let l=!1,s={...gn,...t};const h=()=>{n.setSharedStorage(dn,null),n.setSharedStorage(fn,null),n.setSharedStorage(un,null),n.setSharedStorage(hn,null),n.setSharedStorage(cn,null),l=!1};h();const c=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&wn(e,t,n)?o="X":a&&wn(e,t,a)&&(o="Y"),o}(r,e,{xThumbRect:n.getSharedStorage(ln),yThumbRect:n.getSharedStorage(sn)});return{name:"@middleware/scroller",resetConfig(e){s={...s,...e}},wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),i.drawFrame()},hover:e=>{if(!0===l)return!1;const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return"X"===i?(n.setSharedStorage(hn,!0),n.setSharedStorage(cn,!1)):(n.setSharedStorage(hn,!1),n.setSharedStorage(cn,!0)),a.trigger(oo.CURSOR,{type:"default"}),!1;n.setSharedStorage(hn,!1),n.setSharedStorage(cn,!1)},pointStart:e=>{const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return l=!0,n.setSharedStorage(un,i),n.setSharedStorage(dn,t),!1},pointMove:e=>{const{point:t}=e,o=n.getSharedStorage(un);if("X"===o||"Y"===o)return n.setSharedStorage(fn,t),"X"===o?(e=>{const t=n.getSharedStorage(dn);if(t){const{offsetLeft:o,offsetRight:a}=n.getActiveViewScaleInfo(),{width:r}=n.getActiveViewSizeInfo(),l=-(e.x-t.x)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveX:l}),i.drawFrame()}})(t):"Y"===o&&(e=>{const t=n.getSharedStorage(dn);if(t){const{offsetTop:o,offsetBottom:a}=n.getActiveViewScaleInfo(),{height:r}=n.getActiveViewSizeInfo(),l=-(e.y-t.y)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveY:l}),i.drawFrame()}})(t),n.setSharedStorage(dn,t),!1},pointEnd:()=>{l=!1;const e=n.getSharedStorage(un);if(h(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),i.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{thumbBackground:t,thumbBorderColor:i,hoverThumbBackground:o,hoverThumbBorderColor:a,activeThumbBackground:l,activeThumbBorderColor:h}=s,c={thumbBackground:t,thumbBorderColor:i,hoverThumbBackground:o,hoverThumbBorderColor:a,activeThumbBackground:l,activeThumbBorderColor:h},{xThumbRect:d,yThumbRect:f}=xn(r,{snapshot:e,style:c});n.setSharedStorage(ln,d),n.setSharedStorage(sn,f)}}},e.MiddlewareSelector=(e,t)=>{let i={...bo,...t};const{viewer:o,sharer:n,boardContent:a,calculator:r,eventHub:l}=e,{overlayContext:s}=a;let h=null,c=null,d=null,f=null,u=null,g=en({fill:i.activeColor,devicePixelRatio:n.getActiveViewSizeInfo().devicePixelRatio});n.setSharedStorage(ro,null),n.setSharedStorage(So,!0);const v=()=>n.getSharedStorage(uo),m=e=>{let t=n.getSharedStorage(wo);Array.isArray(t)||(t=[]),t.length>0?!function(e,t){var i;if("group"===(null==t?void 0:t.type)&&Array.isArray(null==(i=null==t?void 0:t.detail)?void 0:i.children))for(let i=0;i<t.detail.children.length;i++){const o=t.detail.children[i];if(e.uuid===o.uuid)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e);const i=Ce(t);return n.setSharedStorage(wo,t),n.setSharedStorage(yo,i),t.length>0},w=e=>{n.setSharedStorage(co,e);let t=null;e&&(t=Te(e,{groupQueue:n.getSharedStorage(wo)})),n.setSharedStorage(fo,t)},y=()=>{const e=n.getSharedStorage(uo);if(1===e.length){const t=Ve(e[0],{groupQueue:n.getSharedStorage(wo),controllerSize:10,viewScaleInfo:n.getActiveViewScaleInfo(),rotateControllerPosition:22,rotateControllerSize:20});n.setSharedStorage(vo,t)}},p=(e,t)=>{var i;if(n.setSharedStorage(uo,e),1===e.length?(y(),n.setSharedStorage(mo,Me(e[0].uuid,(null==(i=n.getActiveStorage("data"))?void 0:i.elements)||[]))):(n.setSharedStorage(vo,null),n.setSharedStorage(mo,[])),!0===(null==t?void 0:t.triggerEvent)){const t=e.map((e=>e.uuid)),i=n.getActiveStorage("data"),o=function(e,t){const i=[],o={};let n=!1;const a=t=>{var r;for(let l=0;l<t.length&&!0!==n;l++){i.push(l);const s=t[l];if(e.includes(s.uuid)){if(o[s.uuid]=[...i],Object.keys(o).length===e.length){n=!0;break}}else"group"===s.type&&a((null===(r=null==s?void 0:s.detail)||void 0===r?void 0:r.children)||[]);if(n)break;i.pop()}};return a(t),o}(t,(null==i?void 0:i.elements)||[]);l.trigger(oo.SELECT,{uuids:t,positions:e.map((e=>[...o[e.uuid]]))})}},x=()=>({ctx:s,calculator:r,data:n.getActiveStorage("data"),selectedElements:v(),viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(wo),areaSize:null,selectedElementController:n.getSharedStorage(vo),selectedElementPosition:n.getSharedStorage(mo)}),S=()=>{n.setSharedStorage(ro,null),n.setSharedStorage(lo,null),n.setSharedStorage(so,null),n.setSharedStorage(ho,null),n.setSharedStorage(wo,[]),n.setSharedStorage(yo,[]),n.setSharedStorage(co,null),n.setSharedStorage(fo,null),n.setSharedStorage(uo,[]),n.setSharedStorage(go,null),n.setSharedStorage(vo,null),n.setSharedStorage(mo,[]),n.setSharedStorage(po,null)};S();const b=({uuids:e=[],positions:t})=>{let i=[];const a=n.getSharedStorage(ro),r=n.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach((e=>{const o=Ae(e,t);o&&i.push(o)})),i}(t,(null==r?void 0:r.elements)||[]):function(e,t){const i=[];return function t(o){var n;for(let a=0;a<o.length;a++){const r=o[a];e.includes(r.uuid)?i.push(r):"group"===r.type&&t((null===(n=null==r?void 0:r.detail)||void 0===n?void 0:n.children)||[])}}(t),i}(e,(null==r?void 0:r.elements)||[]);let l=!1;if(a||1!==i.length?"select"===a&&1===i.length&&(l=!0):(n.setSharedStorage(ro,"select"),l=!0),l){const e=function(e,t){const i=[];return function e(t,o){var n;let a=null;for(let r=0;r<o.length;r++){const l=o[r];if(l.uuid===t){a=l;break}if(!a&&"group"===l.type){i.push(l);const o=e(t,(null===(n=null==l?void 0:l.detail)||void 0===n?void 0:n.children)||[]);if((null==o?void 0:o.uuid)===t){a=o;break}i.pop()}}return a}(e,t),i}(i[0].uuid,(null==r?void 0:r.elements)||[]);n.setSharedStorage(wo,e),p(i),o.drawFrame()}},I=()=>{S(),o.drawFrame()},A=e=>{n.setSharedStorage(So,!!e.enable)},M=e=>{n.setSharedStorage(xo,!!e.enable)};return{name:"@middleware/selector",use(){l.on(oo.SELECT,b),l.on(oo.CLEAR_SELECT,I),l.on(oo.SELECT_IN_GROUP,M),l.on(oo.SNAP_TO_GRID,A)},disuse(){l.off(oo.SELECT,b),l.off(oo.CLEAR_SELECT,I),l.off(oo.SELECT_IN_GROUP,M),l.off(oo.SNAP_TO_GRID,A)},resetConfig(e){i={...i,...e}},hover:e=>{var t,i,a,h,c;const d=n.getSharedStorage($o);if(!0===n.getSharedStorage(Jo))return;const u=n.getSharedStorage(lo),g=n.getSharedStorage(ro),m=n.getSharedStorage(wo),y=e=>{if(!0===d)return;const t=e.type;null===f&&l.trigger(oo.CURSOR,{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==m?void 0:m.length)>0){if(!Oo(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(wo)}))return w(null),void o.drawFrame();const i=jo(e.point,x());return y(i),u||["area","drag","drag-list"].includes(g)?(w(null),void o.drawFrame()):1===(null==(t=null==i?void 0:i.elements)?void 0:t.length)?(w(i.elements[0]),void o.drawFrame()):(w(null),void o.drawFrame())}if(u||["area","drag","drag-list"].includes(g))return void w(null);if("drag"===g)return void w(null);const p=v(),S=n.getActiveViewScaleInfo(),b=n.getActiveViewSizeInfo(),I=jo(e.point,{...x(),areaSize:Yo(p,{viewScaleInfo:S,viewSizeInfo:b,calculator:r})});if(y(I),null!==I.type){if(!("over-element"===I.type&&"select"===n.getSharedStorage(ro)&&1===I.elements.length&&I.elements[0].uuid===(null==(a=null==(i=v())?void 0:i[0])?void 0:a.uuid)||"over-element"===I.type&&null===n.getSharedStorage(ro)&&1===I.elements.length&&I.elements[0].uuid===(null==(h=n.getSharedStorage(co))?void 0:h.uuid)))return"over-element"===I.type&&1===(null==(c=null==I?void 0:I.elements)?void 0:c.length)?(w(I.elements[0]),void o.drawFrame()):n.getSharedStorage(co)?(w(null),void o.drawFrame()):void 0}else(n.getSharedStorage(co)||n.getSharedStorage(fo))&&(n.setSharedStorage(co,null),n.setSharedStorage(fo,null),o.drawFrame())},pointStart:e=>{var t,i,a,l,f,u,g,m,y,b,I,A;h=e.point,c=e.point;const M=n.getSharedStorage(wo);if((null==M?void 0:M.length)>0){if(Oo(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:M})){const o=jo(e.point,x()),r=1===(null==(t=null==o?void 0:o.elements)?void 0:t.length)&&!0===(null==(a=null==(i=o.elements[0])?void 0:i.operations)?void 0:a.locked);w(null),1===(null==(l=null==o?void 0:o.elements)?void 0:l.length)&&(d=Ie(null==o?void 0:o.elements[0])),!0===r?S():"over-element"===o.type&&1===(null==(f=null==o?void 0:o.elements)?void 0:f.length)?(p([o.elements[0]],{triggerEvent:!0}),n.setSharedStorage(ro,"drag")):(null==(u=o.type)?void 0:u.startsWith("resize-"))?(n.setSharedStorage(lo,o.type),n.setSharedStorage(ro,"resize")):p([],{triggerEvent:!0})}else S();return void o.drawFrame()}const z=Yo(v(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),calculator:r}),R=jo(e.point,{...x(),areaSize:z,groupQueue:[]}),C=1===(null==(g=null==R?void 0:R.elements)?void 0:g.length)&&!0===(null==(y=null==(m=R.elements[0])?void 0:m.operations)?void 0:y.locked);w(null),1===(null==(b=null==R?void 0:R.elements)?void 0:b.length)&&(d=Ie(null==R?void 0:R.elements[0])),!0===C?(S(),n.setSharedStorage(ro,"area"),n.setSharedStorage(so,e.point),p([],{triggerEvent:!0})):"list-area"===R.type?n.setSharedStorage(ro,"drag-list"):"over-element"===R.type&&1===(null==(I=null==R?void 0:R.elements)?void 0:I.length)?(p([R.elements[0]],{triggerEvent:!0}),n.setSharedStorage(ro,"drag")):(null==(A=R.type)?void 0:A.startsWith("resize-"))?(n.setSharedStorage(lo,R.type),n.setSharedStorage(ro,"resize")):(S(),n.setSharedStorage(ro,"area"),n.setSharedStorage(so,e.point),p([],{triggerEvent:!0})),o.drawFrame()},pointMove:e=>{var t,i,a;n.setSharedStorage(po,!0);const s=n.getActiveStorage("data"),g=v(),m=n.getActiveStorage("scale")||1,w=n.getActiveViewScaleInfo(),y=n.getActiveViewSizeInfo(),x=h,S=c,b=e.point,I=n.getSharedStorage(lo),A=n.getSharedStorage(ro),M=n.getSharedStorage(wo),z=n.getSharedStorage(So);if("drag"===A){if(u=!0,f="drag",l.trigger(on,{show:!1}),s&&1===(null==g?void 0:g.length)&&d&&S&&b&&!0!==(null==(i=null==(t=g[0])?void 0:t.operations)?void 0:i.locked)){const{moveX:e,moveY:t}=function(e,t,i){let o=t.x-e.x,n=t.y-e.y;const a=[];if(i.forEach((e=>{const{x:t,y:i,w:o,h:n,angle:r=0}=e;a.push({x:t,y:i,w:o,h:n,angle:0-r})})),(null==i?void 0:i.length)>0){const i=ve(e,a),r=ve(t,a);o=r.x-i.x,n=r.y-i.y}return{moveX:o,moveY:n}}(S,b,M);let i=r.toGridNum(e/m),o=r.toGridNum(t/m);if(!0===z){const e=Xo(g[0].uuid,{calculator:r,data:s,groupQueue:M,viewScaleInfo:w,viewSizeInfo:y});try{e&&(B.x(e.offsetX)&&null!==e.offsetX&&(i=r.toGridNum(i+e.offsetX)),B.y(e.offsetY)&&null!==e.offsetY&&(o=r.toGridNum(o+e.offsetY)))}catch(e){console.error(e)}}g[0].x=r.toGridNum(d.x+i),g[0].y=r.toGridNum(d.y+o),p([g[0]]),r.modifyViewVisibleInfoMap(s,{modifyOptions:{type:"updateElement",content:{element:g[0],position:n.getSharedStorage(mo)||[]}},viewSizeInfo:y,viewScaleInfo:w})}o.drawFrame()}else if("drag-list"===A){if(u=!0,f="drag-list",s&&S&&x&&b&&(null==g?void 0:g.length)>1){const e=(b.x-x.x)/m,t=(b.y-x.y)/m;g.forEach((i=>{var o;i&&!0!==(null==(o=null==i?void 0:i.operations)?void 0:o.locked)&&(i.x=r.toGridNum(i.x+e),i.y=r.toGridNum(i.y+t),r.modifyViewVisibleInfoMap(s,{modifyOptions:{type:"updateElement",content:{element:i,position:Me(i.uuid,s.elements)||[]}},viewSizeInfo:y,viewScaleInfo:w}))})),n.setActiveStorage("data",s)}o.drawFrame()}else if("resize"===A){if(s&&1===(null==g?void 0:g.length)&&S&&d&&(null==I?void 0:I.startsWith("resize-"))){u=!0,f="resize";const e=[];M.forEach((t=>{const{x:i,y:o,w:n,h:a,angle:r=0}=t;e.push({x:i,y:o,w:n,h:a,angle:0-r})}));let t=S,i=b;if(M.length>0&&(t=ve(S,e),i=ve(b,e)),"resize-rotate"===I){const e=n.getSharedStorage(vo),t=fe([e.topLeft.center,e.topRight.center,e.bottomLeft.center,e.bottomRight.center]),i=Do(d,{center:t,viewScaleInfo:w,viewSizeInfo:y,start:S,end:b,resizeType:I,sharer:n});g[0].angle=r.toGridNum(i.angle||0)}else{const e=function(e,t){var i,o,n,a,r,l,s,h,c;let{x:d,y:f,w:u,h:g,angle:v=0}=e;const m=de({x:d,y:f,w:u,h:g,angle:v});v=pe(v);const w=se(v),y=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:p,end:x,resizeType:S,scale:b}=t;let I={...p},A={...x},M={x:I.x,y:m.y},z={x:A.x,y:m.y},R={...M},C={...z},T={x:m.x,y:I.y},P={x:m.x,y:A.y},E={...T},k={...P},W=(C.x-R.x)/b,L=(C.y-R.y)/b,O=ko(W,L),j=(k.x-E.x)/b,D=(k.y-E.y)/b,Y=ko(j,D);(v>0||v<0)&&(I=ge(m,p,0-w),A=ge(m,x,0-w),M={x:I.x,y:m.y},z={x:A.x,y:m.y},R=ge(m,M,w),C=ge(m,z,w),T={x:m.x,y:I.y},P={x:m.x,y:A.y},E=ge(m,T,w),k=ge(m,P,w),W=(C.x-R.x)/b,L=(C.y-R.y)/b,O=ko(W,L),O=Wo(O,L),j=(k.x-E.x)/b,D=(k.y-E.y)/b,Y=ko(j,D),Y=Wo(Y,D));let V=(x.x-p.x)/b,B=(x.y-p.y)/b;if(!0===y)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(V),Math.abs(B));V=(V>=0?1:-1)*t,B=(B>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(j),Math.abs(D));j=(j>=0?1:-1)*i,D=(D>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(W),Math.abs(L));W=(W>=0?1:-1)*o,L=(L>=0?1:-1)*o/e.w*e.h}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(S)){{const t=Math.abs(V);V=(V>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?B=V>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(B=V>0?-i:i)}O=Math.abs(O),Y=O/e.w*e.h}switch(S){case"resize-top":if(0===v)g-B>0&&(f+=B,g-=B,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=B/e.h*e.w/2,u-=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=0-Wo(Y,D);const e=Eo(v),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){Y=Wo(Y,j);const e=Eo(v-90),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){Y=Wo(Y,D);const e=Eo(v-180),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){Y=0-Wo(Y,j);const e=Eo(v-270),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+Y>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(u+=Y/e.h*e.w),g+=Y,d=t-u/2,f=i-g/2)}break;case"resize-bottom":if(0===v)e.h+B>0&&(g+=B,!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(d-=B/e.h*e.w/2,u+=B/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=Wo(Y,D);const e=Eo(v),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){Y=0-Wo(Y,j);const e=Eo(v-90),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){Y=Wo(Y,j);const e=Eo(v-180),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){Y=Wo(Y,j);const e=Eo(v-270),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+Y>0&&(!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(u+=Y/e.h*e.w),g+=Y,d=t-u/2,f=i-g/2)}break;case"resize-left":if(0===v)e.w-V>0&&(d+=V,u-=V,!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g-=V/e.w*e.h,f+=V/e.w*e.h/2));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=0-Wo(O,W);const e=Eo(v),o=O/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){O=Wo(O,W);const e=Eo(v-90),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){O=Wo(O,L);const e=Eo(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){O=Wo(O,L);const e=Eo(v-270),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}u+O>0&&(!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-right":if(0===v)e.w+V>0&&(u+=V,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(f-=V*e.h/e.w/2,g+=V*e.h/e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=Wo(O,L);const e=Eo(v),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){O=Wo(O,B);const e=Eo(v-90),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){O=Wo(O,B);const e=Eo(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e),O=0-O}else if(v<360){O=Wo(O,V);const e=Eo(v-270),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}u+O>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=O/e.w*e.h),u+=O,d=t-u/2,f=i-g/2)}break;case"resize-top-left":if(0===v)u-V>0&&(d+=V,u-=V),g-B>0&&(f+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Wo(Y,D),O=0-Wo(O,y?0-Y:W);const i=Y/2;e+=i*Math.sin(w),t-=i*Math.cos(w);const o=O/2;e-=o*Math.cos(w),t-=o*Math.sin(w)}else if(v<180){Y=Wo(Y,j),O=Wo(O,y?Y:W);const i=Eo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Wo(Y,D),O=Wo(O,y?Y:L);const i=Eo(v-180),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=0-Wo(Y,j),O=Wo(O,y?Y:L);const i=Eo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-top-right":if(0===v)u+V>0&&(u+=V),g-B>0&&(f+=B,g-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Wo(Y,D),O=Wo(O,y?Y:L);const i=Eo(v),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=Wo(Y,j),O=Wo(O,y?Y:L);const i=Eo(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Eo(v-180);Y=Wo(Y,D),O=Wo(O,y?Y:0-W);const o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=0-Wo(Y,j),O=Wo(O,y?Y:W);const i=Eo(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+B>0&&(g+=B),e.w-V>0&&(d+=V,u-=V);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Wo(Y,D),O=0-Wo(O,y?0-Y:W);const i=Eo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){Y=0-Wo(Y,j),O=Wo(O,y?Y:W);const i=Eo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Wo(Y,j),O=Wo(O,y?Y:L);const i=Eo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=Wo(Y,j),O=Wo(O,y?Y:L);const i=Eo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+B>0&&(g+=B),e.w+V>0&&(u+=V);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Wo(Y,D),O=Wo(O,y?Y:L);const i=Eo(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=0-Wo(Y,j),O=Wo(O,y?Y:B);const i=Eo(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){Y=Wo(Y,j),O=Wo(O,y?Y:0-L);const i=Eo(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=Wo(Y,j),O=Wo(O,y?Y:W);const i=Eo(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),u+O>0&&(u+=O),d=e-u/2,f=t-g/2}}return{x:d,y:f,w:u,h:g,angle:e.angle}}(d,{scale:m,start:t,end:i,resizeType:I,sharer:n}),o={ignore:!!d.angle};g[0].x=r.toGridNum(e.x,o),g[0].y=r.toGridNum(e.y,o),"group"===g[0].type&&!0===(null==(a=g[0].operations)?void 0:a.deepResize)?function(e,t){const i=t.w&&t.w>0?t.w:e.w,o=t.h&&t.h>0?t.h:e.h,n=i/e.w,a=o/e.h;if(n===a&&1===n)return e;const r=Math.min(n,a),l=Math.max(n,a);e.w=i,e.h=o;const s={xRatio:n,yRatio:a,minRatio:r,maxRatio:l};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Qe(e,s)})),Ze(e,s)}(g[0],{w:r.toGridNum(e.w,o),h:r.toGridNum(e.h,o)}):(g[0].w=r.toGridNum(e.w,o),g[0].h=r.toGridNum(e.h,o))}p([g[0]]),r.modifyViewVisibleInfoMap(s,{modifyOptions:{type:"updateElement",content:{element:g[0],position:n.getSharedStorage(mo)||[]}},viewSizeInfo:y,viewScaleInfo:w}),o.drawFrame()}}else"area"===A&&(f="area",n.setSharedStorage(ho,e.point),o.drawFrame());h=e.point},pointEnd(e){f=null,n.setSharedStorage(po,!1);const t=n.getActiveStorage("data"),i=n.getSharedStorage(uo),a=n.getSharedStorage(co),s=n.getSharedStorage(lo),g=n.getSharedStorage(ro),v=n.getActiveViewSizeInfo();let m=!1;if(h=null,c=null,d=null,"drag"===g&&l.trigger(on,{show:!0}),"resize"===g&&s)n.setSharedStorage(lo,null),m=!0;else if("area"===g){if(n.setSharedStorage(ro,null),t){const e=n.getSharedStorage(so),i=n.getSharedStorage(ho);if(e&&i){const{elements:o}=function(e,t){var i;const o=[],n=[],a=[],{viewScaleInfo:r,viewSizeInfo:l,start:s,end:h}=t;if(!(Array.isArray(e.elements)&&s&&h))return{indexes:o,uuids:n,elements:a};const c=Math.min(s.x,h.x),d=Math.max(s.x,h.x),f=Math.min(s.y,h.y),u=Math.max(s.y,h.y);for(let t=0;t<e.elements.length;t++){const l=e.elements[t];if(!0===(null==(i=null==l?void 0:l.operations)?void 0:i.locked))continue;const s=Pe(l,{viewScaleInfo:r}),h=de(s);if(h.x>=c&&h.x<=d&&h.y>=f&&h.y<=u&&(o.push(t),n.push(l.uuid),a.push(l),s.angle&&(s.angle>0||s.angle<0))){const e=we(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.w=Math.abs(Math.max(...t)-Math.min(...t)),s.h=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:o,uuids:n,elements:a}}(t,{start:e,end:i,calculator:r,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});o.length>0&&(n.setSharedStorage(ro,"drag-list"),p(o,{triggerEvent:!0}),m=!0)}}}else if("drag-list"===g)n.setSharedStorage(ro,"drag-list-end"),m=!0;else if(t){r.getPointElement(e.point,{data:t,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}).element?(n.setSharedStorage(ro,"select"),m=!0):n.setSharedStorage(ro,null)}null===n.getSharedStorage(ro)&&(S(),m=!0);(()=>{if(m){if(t&&Array.isArray(null==t?void 0:t.elements)&&["drag","drag-list"].includes(g)){const e=function(e,t,i){const o=Se(e,{viewWidth:t.width,viewHeight:t.height,extend:null==i?void 0:i.extend});return!0===(null==i?void 0:i.extend)&&(o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight)),{contextSize:o}}(t.elements,v,{extend:!0});n.setActiveStorage("contextHeight",e.contextSize.contextHeight),n.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(g)){let e="dragElement";u&&(l.trigger(oo.CHANGE,{data:t,type:e,selectedElements:i,hoverElement:a}),u=!1)}o.drawFrame()}})()},pointLeave(){f=null,n.setSharedStorage(lo,null),l.trigger(oo.CURSOR,{type:"default"})},doubleClick(e){var t,i,a,r,s,h,c,d;if(!1===n.getSharedStorage(xo))return;const f=jo(e.point,x());if(n.setSharedStorage(vo,null),n.setSharedStorage(uo,[]),1!==f.elements.length||!0!==(null==(i=null==(t=f.elements[0])?void 0:t.operations)?void 0:i.locked)){if(1===f.elements.length&&"group"===(null==(a=f.elements[0])?void 0:a.type)){if(!0===m(f.elements[0]))return n.setSharedStorage(ro,null),void o.drawFrame()}else 1!==f.elements.length||"text"!==(null==(r=f.elements[0])?void 0:r.type)||(null==(h=null==(s=f.elements[0])?void 0:s.operations)?void 0:h.invisible)||l.trigger(oo.TEXT_EDIT,{element:f.elements[0],groupQueue:n.getSharedStorage(wo)||[],position:Me(null==(c=f.elements[0])?void 0:c.uuid,(null==(d=n.getActiveStorage("data"))?void 0:d.elements)||[]),viewScaleInfo:n.getActiveViewScaleInfo()});n.setSharedStorage(ro,null)}},wheel(){y()},wheelScale(){y()},contextMenu:e=>{var t,i,a,l,h,c,d,f;const u=n.getSharedStorage(wo);if((null==u?void 0:u.length)>0){if(Oo(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:u})){const n=jo(e.point,x());1===(null==(t=null==n?void 0:n.elements)?void 0:t.length)&&!0!==(null==(a=null==(i=n.elements[0])?void 0:i.operations)?void 0:a.locked)?(S(),p([n.elements[0]],{triggerEvent:!0}),o.drawFrame()):(null==(l=null==n?void 0:n.elements)?void 0:l.length)||S()}return}const g=Yo(v(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),calculator:r}),m=jo(e.point,{...x(),areaSize:g,groupQueue:[]});if(1===(null==(h=null==m?void 0:m.elements)?void 0:h.length)&&!0!==(null==(d=null==(c=m.elements[0])?void 0:c.operations)?void 0:d.locked))return S(),p([m.elements[0]],{triggerEvent:!0}),void o.drawFrame();(null==(f=null==m?void 0:m.elements)?void 0:f.length)||S()},beforeDrawFrame({snapshot:t}){var o;const{activeColor:n,activeAreaColor:a,lockedColor:l,referenceColor:h}=i,c={activeColor:n,activeAreaColor:a,lockedColor:l,referenceColor:h},{activeStore:d,sharedStore:f}=t,{scale:u,offsetLeft:m,offsetTop:w,offsetRight:y,offsetBottom:p,width:x,height:S,contextHeight:b,contextWidth:I,devicePixelRatio:A}=d;g.fill!==n&&(g=en({fill:i.activeColor,devicePixelRatio:A}));const M=e.sharer,z={scale:u,offsetLeft:m,offsetTop:w,offsetRight:y,offsetBottom:p},R={width:x,height:S,contextHeight:b,contextWidth:I,devicePixelRatio:A},C=f[uo],T=C[0],P=f[co],E=f[fo],k=f[ro],W=f[so],L=f[ho],O=f[wo],j=f[yo],D=f[po],Y=f[So],V={calculator:r,viewScaleInfo:z,viewSizeInfo:R,style:c};let B=f[vo];var G,X;B&&1===C.length&&T&&(G=T,X=B.originalElementSize,(G.x!==X.x||G.y!==X.y||G.h!==X.h||G.w!==X.w||pe(G.angle||0)!==pe(X.angle||0))&&(B=Ve(T,{groupQueue:O||[],controllerSize:10,viewScaleInfo:z,rotateControllerPosition:22,rotateControllerSize:20}),M.setSharedStorage(vo,B)));const N=!!(null==(o=null==P?void 0:P.operations)?void 0:o.locked);if((null==O?void 0:O.length)>0){if(function(e,t,i){const{style:o}=i,{activeColor:n}=o;for(let o=0;o<t.length;o++){const a={borderColor:n,borderWidth:2,background:"transparent",lineDash:[4,4]};Io(e,ke(t[o],i),a)}}(s,j,V),P&&"drag"!==k&&(N?Co(s,E,{...V,controller:B,style:c}):Ro(s,E,V)),T&&["select","drag","resize"].includes(k)&&(To(s,B,{...V,element:T,calculator:r,hideControllers:!!D&&"drag"===k,rotateControllerPattern:g.context2d,style:c}),"drag"===k&&!0===Y)){const e=Xo(T.uuid,{calculator:r,data:d.data,groupQueue:O,viewScaleInfo:z,viewSizeInfo:R});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Po(s,{xLines:o,yLines:n,style:c})}}}else if(P&&"drag"!==k&&(N?Co(s,E,{...V,controller:B,style:c}):Ro(s,E,V)),T&&["select","drag","resize"].includes(k)){if(To(s,B,{...V,element:T,calculator:r,hideControllers:!!D&&"drag"===k,rotateControllerPattern:g.context2d,style:c}),"drag"===k&&!0===Y){const e=Xo(T.uuid,{calculator:r,data:d.data,groupQueue:O,viewScaleInfo:z,viewSizeInfo:R});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Po(s,{xLines:o,yLines:n,style:c})}}}else if("area"===k&&W&&L)!function(e,t){const{start:i,end:o,style:n}=t,{activeColor:a,activeAreaColor:r}=n;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=a,e.fillStyle=r,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,i.y),e.lineTo(o.x,o.y),e.lineTo(i.x,o.y),e.closePath(),e.stroke(),e.fill()}(s,{start:W,end:L,style:c});else if(["drag-list","drag-list-end"].includes(k)){const e=Yo(v(),{viewScaleInfo:M.getActiveViewScaleInfo(),viewSizeInfo:M.getActiveViewSizeInfo(),calculator:r});e&&function(e,t){const{areaSize:i,style:o}=t,{activeColor:n,activeAreaColor:a}=o,{x:r,y:l,w:s,h:h}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=n,e.fillStyle=a,e.beginPath(),e.moveTo(r,l),e.lineTo(r+s,l),e.lineTo(r+s,l+h),e.lineTo(r,l+h),e.closePath(),e.stroke(),e.fill()}(s,{areaSize:e,style:c})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o,sharer:n}=e,a=i.boardContext.canvas,r=document.createElement("div");r.setAttribute("contenteditable","true");const l=document.createElement("div"),s=e.container||document.body,h=document.createElement("div");let c=null,d=[];const f=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`;h.setAttribute("id",f),l.appendChild(r),l.style.position="absolute",h.appendChild(l),h.style.position="fixed",h.style.top="0",h.style.bottom="0",h.style.left="0",h.style.right="0",h.style.display="none",s.appendChild(h);const u=()=>{if(null==c?void 0:c.uuid){const e=n.getActiveOverrideElemenentMap();e&&delete e[c.uuid],n.setActiveOverrideElemenentMap(e),o.drawFrame()}h.style.display="none",c=null,d=[]},g=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:a,w:r,h:l}=t,s=pe(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${a}px`,o.style.width=`${r}px`,o.style.height=`${l}px`,o.style.transform=`rotate(${s}deg)`,i.appendChild(o),o},v=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:a,offsetLeft:s}=t;l.children&&Array.from(l.children).forEach((e=>{e.remove()}));let h=l;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:r,w:l,h:c}=t,d={x:i*n,y:r*n,w:l*n,h:c*n,angle:pe(t.angle||0)};0===e&&(d.x+=s,d.y+=a),h=g({size:d,parent:h})}const c={...zn,...i.detail};let d=i.x*n+s,f=i.y*n+a,u=i.w*n,v=i.h*n;o.length>0&&(d=i.x*n,f=i.y*n,u=i.w*n,v=i.h*n);let m="center",w="center";"left"===c.textAlign?m="start":"right"===c.textAlign&&(m="end"),"top"===c.verticalAlign?w="start":"bottom"===c.verticalAlign&&(w="end"),r.style.display="inline-flex",r.style.justifyContent=m,r.style.alignItems=w,r.style.position="absolute",r.style.left=d-1+"px",r.style.top=f-1+"px",r.style.width=`${u+2}px`,r.style.height=`${v+2}px`,r.style.transform=`rotate(${pe(i.angle||0)}deg)`,r.style.boxSizing="border-box",r.style.border="1px solid #1973ba",r.style.resize="none",r.style.overflow="hidden",r.style.wordBreak="break-all",r.style.borderRadius=("number"==typeof c.borderRadius?c.borderRadius:0)*n+"px",r.style.background=`${c.background||"transparent"}`,r.style.color=`${c.color||"#333333"}`,r.style.fontSize=c.fontSize*n+"px",r.style.lineHeight=(c.lineHeight||c.fontSize)*n+"px",r.style.fontFamily=$e(c.fontFamily),r.style.fontWeight=`${c.fontWeight}`,r.style.padding="0",r.style.margin="0",r.style.outline="none",r.innerText=c.text||"",h.appendChild(r)},m=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=a.getBoundingClientRect(),{left:t,top:i,width:o,height:n}=e;return{left:t,top:i,width:o,height:n}})();l.style.position="absolute",l.style.overflow="hidden",l.style.top=`${t}px`,l.style.left=`${e}px`,l.style.width=`${i}px`,l.style.height=`${o}px`};h.addEventListener("click",(()=>{u()})),r.addEventListener("click",(e=>{e.stopPropagation()})),r.addEventListener("input",(()=>{c&&d&&(c.detail.text=r.innerText||"",t.trigger(oo.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d||[]]}),o.drawFrame())})),r.addEventListener("blur",(()=>{c&&d&&t.trigger(oo.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d]}),u()})),r.addEventListener("keydown",(e=>{e.stopPropagation()})),r.addEventListener("keypress",(e=>{e.stopPropagation()})),r.addEventListener("keyup",(e=>{e.stopPropagation()})),r.addEventListener("wheel",(e=>{e.stopPropagation(),e.preventDefault()}));const w=e=>{var t;(null==e?void 0:e.position)&&(null==e?void 0:e.element)&&"text"===(null==(t=null==e?void 0:e.element)?void 0:t.type)&&(c=e.element,d=e.position),(e=>{m(),v(e),h.style.display="block",(null==c?void 0:c.uuid)&&(n.setActiveOverrideElemenentMap({[c.uuid]:{operations:{invisible:!0}}}),o.drawFrame())})(e)};return{name:"@middleware/text-editor",use(){t.on(oo.TEXT_EDIT,w)},disuse(){t.off(oo.TEXT_EDIT,w)}}},e.coreEventKeys=oo,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var iDrawCore=function(e){"use strict";var t,i,o,n,a,r,l,s,h,c,d,u,f,g,v,m,y,p,w,x,S,b,A,I,M,R,z,C,P,T,E,k,L,W,O,D,j,Y,B,F,G,N,V,X,H,Z,Q,U,$,J,K,q,_,ee,te,ie,oe,ne,ae,re,le,se,he,ce,de,ue,fe,ge,ve,me=e=>{throw TypeError(e)},ye=(e,t,i)=>t.has(e)||me("Cannot "+i),pe=(e,t,i)=>(ye(e,t,"read from private field"),i?i.call(e):t.get(e)),we=(e,t,i)=>t.has(e)?me("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),xe=(e,t,i,o)=>(ye(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i),Se=(e,t,i)=>(ye(e,t,"access private method"),i);function be(e){return"string"==typeof e&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function Ae(e,t){if(1===t)return e;let i=1;const o=/^#[0-9a-f]{6,6}$/i;let n=e;if(o.test(e)?i=parseInt(e.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(e)&&(i=parseInt(e.substring(7,9).replace(/^#/,"0x")),n=e.substring(0,7)),i*=t,o.test(n)&&i>0&&i<1){const e=Math.max(0,Math.min(255,Math.ceil(256*i)));n=`${n.toUpperCase()}${e.toString(16).toUpperCase()}`}return n}function Ie(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function Me(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i)*e.charCodeAt(i)*i*i;return t.toString(16).substring(0,4)}function Re(e){const t=e.length,i=Math.floor(t/2),o=e.substring(0,4).padEnd(4,"0"),n=e.substring(0,4).padEnd(4,"0");return`@assets/${Me(t.toString(16).padEnd(4,o))}${Me(e.substring(i-4,i).padEnd(4,o)).padEnd(4,"f")}-${Me(e.substring(i-8,i-4).padEnd(4,o)).padEnd(4,"f")}-${Me(e.substring(i-12,i-8).padEnd(4,o)).padEnd(4,"f")}-${Me(e.substring(i-16,i-12).padEnd(4,n)).padEnd(4,"f")}-${Me(e.substring(i,i+4).padEnd(4,n)).padEnd(4,"f")}${Me(e.substring(i+4,i+8).padEnd(4,n)).padEnd(4,"f")}${Me(n.padEnd(4,o).padEnd(4,n))}`}function ze(e){return function e(t){const i=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return t;if("Array"===i){const i=[];return t.forEach((t=>{i.push(e(t))})),i}if("Object"===i){const i={};Object.keys(t).forEach((o=>{i[o]=e(t[o])}));return Object.getOwnPropertySymbols(t).forEach((o=>{i[o]=e(t[o])})),i}}(e)}function Ce(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const Pe={type(e,t){const i=Ce(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===Ce(e),json:e=>"Object"===Ce(e),function:e=>"Function"===Ce(e),asyncFunction:e=>"AsyncFunction"===Ce(e),boolean:e=>"Boolean"===Ce(e),string:e=>"String"===Ce(e),number:e=>"Number"===Ce(e),undefined:e=>"Undefined"===Ce(e),null:e=>"Null"===Ce(e),promise:e=>"Promise"===Ce(e)};var Te=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))};const{Image:Ee}=window;function ke(e){return new Promise(((t,i)=>{const o=new Ee;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e}))}function Le(e){return Te(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,i)=>{const o=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=new FileReader;n.readAsDataURL(o),n.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},n.onerror=function(e){i(e)}}))}(e);return yield ke(t)}))}function We(e,t){return Te(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const i=yield function(e,t){const{width:i,height:o}=t;return new Promise(((t,n)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${o||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var i;const o=null===(i=null==e?void 0:e.target)||void 0===i?void 0:i.result;t(o)},r.onerror=function(e){n(e)}}))}(e,t);return yield ke(i)}))}function Oe(e){return"number"==typeof e&&e>=0}function De(e){return"number"==typeof e&&(e>0||e<=0)}function je(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function Ye(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const Be={positiveNum:Oe,x:function(e){return De(e)},y:function(e){return De(e)},w:function(e){return Oe(e)},h:function(e){return Oe(e)},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:De,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return Oe(e)||Array.isArray(e)&&Oe(e[0])&&Oe(e[1])&&Oe(e[2])&&Oe(e[3])},borderRadius:function(e){return Oe(e)||Array.isArray(e)&&Oe(e[0])&&Oe(e[1])&&Oe(e[2])&&Oe(e[3])},color:function(e){return be(e)},imageSrc:function(e){return Ye(e)||je(e)},imageURL:je,imageBase64:Ye,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let i=document.createElement("div");i.innerHTML=e,i.children.length>0&&(t=!0),i=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return De(e)&&e>0},lineHeight:function(e){return De(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return De(e)&&e>0}};var Fe,Ge,Ne=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Ve=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Xe{constructor(e,t){Fe.set(this,void 0),Ge.set(this,void 0),Ne(this,Fe,e,"f"),Ne(this,Ge,Object.assign({devicePixelRatio:1,offscreenCanvas:null},t),"f"),this.$resetFont()}$undoPixelRatio(e){return e/Ve(this,Ge,"f").devicePixelRatio}$doPixelRatio(e){return Ve(this,Ge,"f").devicePixelRatio*e}$getContext(){return Ve(this,Fe,"f")}$setContext(e){Ne(this,Fe,e,"f")}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),Ve(this,Fe,"f").font=`${t.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return Ve(this,Ge,"f").offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:n}=e,{canvas:a}=Ve(this,Fe,"f");a.width=t*o,a.height=i*o,Ne(this,Ge,Object.assign(Object.assign({},Ve(this,Ge,"f")),{devicePixelRatio:o}),"f"),!0===n&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=Ve(this,Ge,"f"),{width:t,height:i}=Ve(this,Fe,"f").canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return Ve(this,Fe,"f").canvas}get fillStyle(){return Ve(this,Fe,"f").fillStyle}set fillStyle(e){Ve(this,Fe,"f").fillStyle=e}get strokeStyle(){return Ve(this,Fe,"f").strokeStyle}set strokeStyle(e){Ve(this,Fe,"f").strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(Ve(this,Fe,"f").lineWidth)}set lineWidth(e){Ve(this,Fe,"f").lineWidth=this.$doPixelRatio(e)}get textAlign(){return Ve(this,Fe,"f").textAlign}set textAlign(e){Ve(this,Fe,"f").textAlign=e}get textBaseline(){return Ve(this,Fe,"f").textBaseline}set textBaseline(e){Ve(this,Fe,"f").textBaseline=e}get globalAlpha(){return Ve(this,Fe,"f").globalAlpha}set globalAlpha(e){Ve(this,Fe,"f").globalAlpha=e}get shadowColor(){return Ve(this,Fe,"f").shadowColor}set shadowColor(e){Ve(this,Fe,"f").shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(Ve(this,Fe,"f").shadowOffsetX)}set shadowOffsetX(e){Ve(this,Fe,"f").shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(Ve(this,Fe,"f").shadowOffsetY)}set shadowOffsetY(e){Ve(this,Fe,"f").shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(Ve(this,Fe,"f").shadowBlur)}set shadowBlur(e){Ve(this,Fe,"f").shadowBlur=this.$doPixelRatio(e)}get lineCap(){return Ve(this,Fe,"f").lineCap}set lineCap(e){Ve(this,Fe,"f").lineCap=e}get globalCompositeOperation(){return Ve(this,Fe,"f").globalCompositeOperation}set globalCompositeOperation(e){Ve(this,Fe,"f").globalCompositeOperation=e}fill(...e){return Ve(this,Fe,"f").fill(...e)}arc(e,t,i,o,n,a){return Ve(this,Fe,"f").arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,n,a)}rect(e,t,i,o){return Ve(this,Fe,"f").rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return Ve(this,Fe,"f").fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return Ve(this,Fe,"f").clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return Ve(this,Fe,"f").beginPath()}closePath(){return Ve(this,Fe,"f").closePath()}lineTo(e,t){return Ve(this,Fe,"f").lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return Ve(this,Fe,"f").moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,n){return Ve(this,Fe,"f").arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n))}bezierCurveTo(e,t,i,o,n,a){return Ve(this,Fe,"f").bezierCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a))}quadraticCurveTo(e,t,i,o){return Ve(this,Fe,"f").quadraticCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return Ve(this,Fe,"f").getLineDash()}setLineDash(e){const t=e.map((e=>this.$doPixelRatio(e)));return Ve(this,Fe,"f").setLineDash(t)}stroke(e){return e?Ve(this,Fe,"f").stroke(e):Ve(this,Fe,"f").stroke()}translate(e,t){return Ve(this,Fe,"f").translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return Ve(this,Fe,"f").rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],n=e[3],a=e[4],r=e[e.length-4],l=e[e.length-3],s=e[e.length-2],h=e[e.length-1];return 9===e.length?Ve(this,Fe,"f").drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a),this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h)):Ve(this,Fe,"f").drawImage(t,this.$doPixelRatio(r),this.$doPixelRatio(l),this.$doPixelRatio(s),this.$doPixelRatio(h))}createPattern(e,t){return Ve(this,Fe,"f").createPattern(e,t)}measureText(e){return Ve(this,Fe,"f").measureText(e)}fillText(e,t,i,o){return void 0!==o?Ve(this,Fe,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Ve(this,Fe,"f").fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?Ve(this,Fe,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):Ve(this,Fe,"f").strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){Ve(this,Fe,"f").save()}restore(){Ve(this,Fe,"f").restore()}scale(e,t){Ve(this,Fe,"f").scale(e,t)}circle(e,t,i,o,n,a,r,l){Ve(this,Fe,"f").ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),n,a,r,l)}isPointInPath(e,t){return Ve(this,Fe,"f").isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return Ve(this,Fe,"f").clip(...e)}setTransform(e,t,i,o,n,a){return Ve(this,Fe,"f").setTransform(e,t,i,o,n,a)}getTransform(){return Ve(this,Fe,"f").getTransform()}createLinearGradient(e,t,i,o){return Ve(this,Fe,"f").createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,n,a){return Ve(this,Fe,"f").createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(n),this.$doPixelRatio(a))}createConicGradient(e,t,i){return Ve(this,Fe,"f").createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function He(e){const{width:t,height:i,devicePixelRatio:o}=e,n=new OffscreenCanvas(t*o,i*o),a=n.getContext("2d").canvas.getContext("2d");return new Xe(a,{devicePixelRatio:o,offscreenCanvas:n})}function Ze(e,t){const{width:i,height:o,devicePixelRatio:n}=t,a={width:i,height:o,devicePixelRatio:n},r=e.getContext("2d"),l=He(a),s=He(a),h=He(a),c=function(e){const{width:t,height:i,ctx:o,devicePixelRatio:n}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*n,e.height=i*n,a=e.getContext("2d")}return new Xe(a,e)}(Object.assign({ctx:r},a)),d=He(a);return{underlayContext:h,viewContext:l,overlayContext:s,boardContext:c,tempContext:d,drawView:()=>{const{width:e,height:t}=l.$getSize();c.clearRect(0,0,e,t),c.drawImage(h.canvas,0,0,e,t),c.drawImage(l.canvas,0,0,e,t),c.drawImage(s.canvas,0,0,e,t),h.clearRect(0,0,e,t),l.clearRect(0,0,e,t),s.clearRect(0,0,e,t)}}}Fe=new WeakMap,Ge=new WeakMap;var Qe,Ue=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class $e{constructor(){Qe.set(this,void 0),function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,i):n?n.value=i:t.set(e,i)}(this,Qe,new Map,"f")}on(e,t){if(Ue(this,Qe,"f").has(e)){const i=Ue(this,Qe,"f").get(e)||[];null==i||i.push(t),Ue(this,Qe,"f").set(e,i)}else Ue(this,Qe,"f").set(e,[t])}off(e,t){if(Ue(this,Qe,"f").has(e)){const i=Ue(this,Qe,"f").get(e);if(Array.isArray(i))for(let e=0;e<(null==i?void 0:i.length);e++)if(i[e]===t){i.splice(e,1);break}Ue(this,Qe,"f").set(e,i||[])}}trigger(e,t){const i=Ue(this,Qe,"f").get(e);return!!Array.isArray(i)&&(i.forEach((e=>{e(t)})),!0)}has(e){if(Ue(this,Qe,"f").has(e)){const t=Ue(this,Qe,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){Ue(this,Qe,"f").clear()}}function Je(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}Qe=new WeakMap;var Ke,qe,_e,et,tt,it=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},ot=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class nt{constructor(e){Ke.add(this),qe.set(this,void 0),_e.set(this,void 0),et.set(this,void 0),it(this,_e,ze(e.defaultStorage),"f"),it(this,qe,ot(this,Ke,"m",tt).call(this),"f"),it(this,et,e.defaultStatic||{},"f")}set(e,t){ot(this,qe,"f")[e]=t}get(e){return ot(this,qe,"f")[e]}setStatic(e,t){ot(this,et,"f")[e]=t}getStatic(e){return ot(this,et,"f")[e]}getSnapshot(e){return!0===(null==e?void 0:e.deepClone)?ze(ot(this,qe,"f")):Object.assign({},ot(this,qe,"f"))}clear(){it(this,qe,ot(this,Ke,"m",tt).call(this),"f")}destroy(){it(this,qe,null,"f"),it(this,et,null,"f")}}function at(e){const{activeStore:t}=e;return{scale:null==t?void 0:t.scale,offsetTop:null==t?void 0:t.offsetTop,offsetBottom:null==t?void 0:t.offsetBottom,offsetLeft:null==t?void 0:t.offsetLeft,offsetRight:null==t?void 0:t.offsetRight}}function rt(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:null==t?void 0:t.width,height:null==t?void 0:t.height,contextWidth:null==t?void 0:t.contextWidth,contextHeight:null==t?void 0:t.contextHeight}}function lt(e){return e/180*Math.PI}function st(e,t,i,o){const n=lt(t||0);i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(n),e.translate(-i.x,-i.y)),o(e),i&&(n>0||n<0)&&(e.translate(i.x,i.y),e.rotate(-n),e.translate(-i.x,-i.y))}function ht(e,t,i){const o=ct(t);st(e,t.angle||0,o,(()=>{i(e)}))}function ct(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function dt(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return ct({x:t,y:i,w:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,h:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function ut(e,t){const i=t.x-e.x,o=t.y-e.y;if(0===i){if(o<0)return 0;if(o>0)return Math.PI}else if(0===o){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&o<0?Math.atan(Math.abs(i)/Math.abs(o)):i>0&&o>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):0}function ft(e,t,i){let o=ut(e,t)+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 n=function(e,t){const i=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===i?i:Math.sqrt(i)}(e,t);let a=0,r=0;return 0===o?(a=0,r=0-n):o>0&&o<Math.PI/2?(a=Math.sin(o)*n,r=0-Math.cos(o)*n):o===Math.PI/2?(a=n,r=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*n,r=Math.cos(Math.PI-o)*n):o===Math.PI?(a=0,r=n):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*n,r=Math.cos(o-Math.PI)*n):o===1.5*Math.PI?(a=0-n,r=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*n,r=0-Math.cos(2*Math.PI-o)*n):o===2*Math.PI&&(a=0,r=0-n),a+=e.x,r+=e.y,{x:a,y:r}}function gt(e,t){if((null==t?void 0:t.length)>0){let i=e.x,o=e.y;return t.forEach((e=>{const{x:t,y:n,w:a,h:r,angle:l=0}=e,s=ft(ct({x:t,y:n,w:a,h:r}),{x:i,y:o},lt(l));i=s.x,o=s.y})),{x:i,y:o}}return e}function vt(e,t,i){const{x:o,y:n,w:a,h:r}=e;let l={x:o,y:n},s={x:o+a,y:n},h={x:o+a,y:n+r},c={x:o,y:n+r};if(i&&(i>0||i<0)){const e=lt(pt(i));l=ft(t,l,e),s=ft(t,s,e),h=ft(t,h,e),c=ft(t,c,e)}return[l,s,h,c]}function mt(e){const{angle:t=0}=e;return vt(e,ct(e),t)}function yt(e,t,i){return[ft(e,{x:t[0].x,y:t[0].y},i),ft(e,{x:t[1].x,y:t[1].y},i),ft(e,{x:t[2].x,y:t[2].y},i),ft(e,{x:t[3].x,y:t[3].y},i)]}function pt(e){if(!(e>0||e<0)||0===e||360===e)return 0;let t=e%360;return t<0?t+=360:360===e&&(t=0),t}function wt(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach((e=>{var o;"string"==typeof e.uuid&&e.uuid?i.includes(e.uuid)?(t=!1,console.warn(`Duplicate uuids: ${e.uuid}`)):i.push(e.uuid):(t=!1,console.warn("Element missing uuid",e)),"group"===e.type&&(t=wt(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.children))}))}return t}function xt(e,t){const i={x:0,y:0,w:0,h:0};e.forEach((e=>{const t={x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=mt(t);if(4===e.length){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...i),t.y=Math.min(...o),t.w=Math.abs(Math.max(...i)-Math.min(...i)),t.h=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),n=Math.min(t.y,i.y),a=Math.max(t.x+t.w,i.x+i.w),r=Math.max(t.y+t.h,i.y+i.h);i.x=o,i.y=n,i.w=Math.abs(a-o),i.h=Math.abs(r-n)})),(null==t?void 0:t.extend)&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.w,contextHeight:i.h};return(null==t?void 0:t.viewWidth)&&(null==t?void 0:t.viewHeight)&&(null==t?void 0:t.viewWidth)>0&&(null==t?void 0:t.viewHeight)>0&&(t.viewWidth>i.x+i.w&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.h&&(o.contextHeight=t.viewHeight-i.y)),o}function St(e,t){var i;const o=[];let n=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const a=n[t[e]];if("group"!==(null==a?void 0:a.type)||!Array.isArray(null===(i=null==a?void 0:a.detail)||void 0===i?void 0:i.children))return null;o.push(a),n=a.detail.children}return o}function bt(e){const{x:t,y:i,w:o,h:n,angle:a}=e;return{x:t,y:i,w:o,h:n,angle:a}}function At(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const n=o[e[t]];if(t<e.length-1&&"group"===n.type)o=n.detail.children;else{if(t!==e.length-1)break;i=n}}return i}function It(e,t){const i=[];let o=!1;const n=t=>{var a;for(let r=0;r<t.length&&!0!==o;r++){i.push(r);const l=t[r];if(l.uuid===e){o=!0;break}if("group"===l.type&&n((null===(a=null==l?void 0:l.detail)||void 0===a?void 0:a.children)||[]),o)break;i.pop()}};return n(t),i}function Mt(e){const{x:t,y:i,h:o,w:n}=e;return[{x:t,y:i},{x:t+n,y:i},{x:t+n,y:i+o},{x:t,y:i+o}]}function Rt(e){const{x:t,y:i,w:o,h:n,angle:a=0}=e;return 0===a?Mt(e):vt(e,ct({x:t,y:i,w:o,h:n}),a)}function zt(e){const t=[];let i=0,o=0;const n=[],a=[...e];for(let e=0;e<a.length;e++){const{x:r,y:l,w:s,h:h,angle:c=0}=a[e];let d;if(i+=r,o+=l,0===e){const e={x:i,y:o,w:s,h:h};d=Rt({x:r,y:l,w:s,h:h,angle:c}),n.push({center:ct(e),angle:c,radian:lt(c)})}else{d=Mt({x:i,y:o,w:s,h:h});for(let e=0;e<n.length;e++){const{center:t,radian:i}=n[e];d=yt(t,d,i)}const e=dt(d);if(c>0||c<0){d=yt(e,d,lt(c))}n.push({center:e,angle:c,radian:lt(c)})}t.push(d)}return t}function Ct(e,t){const i=function(e,t){const{groupQueue:i}=t;return i.length>0?zt([...i,e]):[Rt(e)]}(e,t);return i.pop()||null}function Pt(e,t){const{viewScaleInfo:i}=t,{x:o,y:n,w:a,h:r,angle:l}=e,{scale:s,offsetTop:h,offsetLeft:c}=i;return{x:o*s+c,y:n*s+h,w:a*s,h:r*s,angle:l}}function Tt(e,t){const{viewScaleInfo:i}=t,{x:o,y:n}=e,{scale:a,offsetTop:r,offsetLeft:l}=i;return{x:o*a+l,y:n*a+r}}function Et(e,t){return[Tt(e[0],t),Tt(e[1],t),Tt(e[2],t),Tt(e[3],t)]}function kt(e,t){const{context2d:i,element:o,viewScaleInfo:n}=t,{angle:a=0}=o,{x:r,y:l,w:s,h:h}=Pt(o,{viewScaleInfo:n}),c=mt({x:r,y:l,w:s,h:h,angle:a});if(c.length>=2){i.beginPath(),i.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e++)i.lineTo(c[e].x,c[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function Lt(e,t,i){const o=[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],a=Math.min(...o),r=Math.max(...o),l=Math.min(...n),s=Math.max(...n);return e.x>a&&e.x<r&&e.y>l&&e.y<s}function Wt(e,t){const{groupQueue:i}=t,o=Ct(e,{groupQueue:i}),n=Je(o[0],o[1]),a=Je(o[1],o[2]),r=Je(o[2],o[3]),l=Je(o[3],o[0]),s=o[0],h=o[1],c=o[2],d=o[3],u=Math.max(s.x,h.x,c.x,d.x),f=Math.max(s.y,h.y,c.y,d.y);return{center:{x:(u+Math.min(s.x,h.x,c.x,d.x))/2,y:(f+Math.min(s.y,h.y,c.y,d.y))/2},topLeft:s,topRight:h,bottomLeft:d,bottomRight:c,top:n,right:a,left:l,bottom:r}}function Ot(e){const t=Math.max(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),i=Math.max(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),o=Math.min(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},r={x:o,y:n},l={x:t,y:n},s={x:t,y:i},h={x:o,y:i},c=Je(r,l),d=Je(h,s),u=Je(r,h);return{center:a,topLeft:r,topRight:l,bottomLeft:h,bottomRight:s,top:c,right:Je(l,s),left:u,bottom:d}}function Dt(e,t){const{x:i,y:o}=e,{size:n,angle:a}=t;return{x:i-n/2,y:o-n/2,w:n,h:n,angle:a}}function jt(e,t){const{groupQueue:i,controllerSize:o,viewScaleInfo:n,rotateControllerSize:a,rotateControllerPosition:r}=t,l=(o&&o>0?o:8)/n.scale,{x:s,y:h,w:c,h:d,angle:u=0}=e,f=a,g=r,v=[{uuid:Ie(),x:s,y:h,w:c,h:d,angle:u,type:"group",detail:{children:[]}},...i];let m=0;v.forEach((({angle:e=0})=>{m+=e}));const y=Ct(e,{groupQueue:i}),p=Ct({x:s,y:h-(g+f/2)/n.scale,h:d+(2*g+f)/n.scale,w:c,angle:u},{groupQueue:[...i]}),w=Je(y[0],y[1]),x=Je(y[1],y[2]),S=Je(y[2],y[3]),b=Je(y[3],y[0]),A=y[0],I=y[1],M=y[2],R=y[3],z=Dt(w,{size:l,angle:m}),C=Dt(x,{size:l,angle:m}),P=Dt(S,{size:l,angle:m}),T=Dt(b,{size:l,angle:m}),E=Dt(A,{size:l,angle:m}),k=Dt(I,{size:l,angle:m}),L=Dt(R,{size:l,angle:m}),W=Dt(M,{size:l,angle:m}),O=Rt(E),D=Rt(k),j=Rt(L),Y=Rt(W),B=[O[1],D[0],D[3],O[2]],F=[D[3],D[2],Y[1],Y[0]],G=[j[1],Y[0],Y[3],j[2]],N=[O[3],O[2],j[1],j[0]],V=Rt(z),X=Rt(C),H=Rt(P),Z=Rt(T),Q=Je(p[0],p[1]),U=Rt(Dt(Q,{size:1.1*a/n.scale,angle:m}));return{originalElementCenter:ct(e),originalElementSize:Object.assign({},e),elementWrapper:y,left:{type:"left",vertexes:N,center:b,size:l},right:{type:"right",vertexes:F,center:x,size:l},top:{type:"top",vertexes:B,center:w,size:l},bottom:{type:"bottom",vertexes:G,center:S,size:l},topLeft:{type:"top-left",vertexes:O,center:A,size:l},topRight:{type:"top-right",vertexes:D,center:I,size:l},bottomLeft:{type:"bottom-left",vertexes:j,center:R,size:l},bottomRight:{type:"bottom-right",vertexes:Y,center:M,size:l},leftMiddle:{type:"left-middle",vertexes:Z,center:b,size:l},rightMiddle:{type:"right-middle",vertexes:X,center:x,size:l},topMiddle:{type:"top-middle",vertexes:V,center:w,size:l},bottomMiddle:{type:"bottom-middle",vertexes:H,center:S,size:l},rotate:{type:"rotate",vertexes:U,center:Q,size:a}}}function Yt(e,t){const{controllerSize:i,viewScaleInfo:o}=t,n=i&&i>0?i:8,{x:a,y:r,w:l,h:s}=Pt(e,{viewScaleInfo:o}),h=ct({x:a,y:r,w:l,h:s}),c={x:h.x,y:r},d={x:a+l,y:h.y},u={x:h.x,y:r+s},f={x:a,y:h.y},g={x:a,y:r},v={x:a+l,y:r},m={x:a+l,y:r+s},y={x:a,y:r+s},p=Dt(c,{size:n,angle:0}),w=Dt(d,{size:n,angle:0}),x=Dt(u,{size:n,angle:0}),S=Dt(f,{size:n,angle:0}),b=Dt(g,{size:n,angle:0}),A=Dt(v,{size:n,angle:0}),I=Dt(y,{size:n,angle:0}),M=Dt(m,{size:n,angle:0}),R=Rt(b),z=Rt(A),C=Rt(I),P=Rt(M),T=[R[1],z[0],z[3],R[2]],E=[z[3],z[2],P[1],P[0]],k=[C[1],P[0],P[3],C[2]],L=[R[3],R[2],C[1],C[0]],W=Rt(p),O=Rt(w),D=Rt(x);return{left:{type:"left",vertexes:L,center:f,size:n},right:{type:"right",vertexes:E,center:d,size:n},top:{type:"top",vertexes:T,center:c,size:n},bottom:{type:"bottom",vertexes:k,center:u,size:n},topLeft:{type:"top-left",vertexes:R,center:g,size:n},topRight:{type:"top-right",vertexes:z,center:v,size:n},bottomLeft:{type:"bottom-left",vertexes:C,center:y,size:n},bottomRight:{type:"bottom-right",vertexes:P,center:m,size:n},leftMiddle:{type:"left-middle",vertexes:Rt(S),center:f,size:n},rightMiddle:{type:"right-middle",vertexes:O,center:d,size:n},topMiddle:{type:"top-middle",vertexes:W,center:c,size:n},bottomMiddle:{type:"bottom-middle",vertexes:D,center:u,size:n}}}function Bt(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}function Ft(e,t){let i=2;return void 0!==(null==t?void 0:t.decimalPlaces)&&(null==t?void 0:t.decimalPlaces)>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}qe=new WeakMap,_e=new WeakMap,et=new WeakMap,Ke=new WeakSet,tt=function(){return ze(ot(this,_e,"f"))};const Gt={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Nt(e,t){const{viewScaleInfo:i}=t,{scale:o}=i;let{borderRadius:n}=e.detail;const{borderDash:a}=e.detail,r=Array.isArray(a)&&a.length>0,{boxSizing:l=Gt.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(n=0);let{x:h,y:c,w:d,h:u}=e,f=[0,0,0,0];if("number"==typeof n){const e=n*o;f=[e,e,e,e]}else Array.isArray(n)&&4===(null==n?void 0:n.length)&&(f=[n[0]*o,n[1]*o,n[2]*o,n[3]*o]);let g=0;return"number"==typeof s&&(g=(s||0)*o),"border-box"!==l||r?"content-box"===l?(h=e.x-g/2,c=e.y-g/2,d=e.w+g,u=e.h+g):(h=e.x,c=e.y,d=e.w,u=e.h):(h=e.x+g/2,c=e.y+g/2,d=e.w-g,u=e.h-g),d=Math.max(d,1),u=Math.max(u,1),f=f.map((e=>Math.min(e,d/2,u/2))),{x:h,y:c,w:d,h:u,radiusList:f}}const Vt=e=>Ft(e,{decimalPlaces:4});function Xt(e,t){const{detail:i}=e,{xRatio:o,yRatio:n,maxRatio:a}=t,r=(o+n)/2,{borderWidth:l,borderRadius:s,borderDash:h,shadowOffsetX:c,shadowOffsetY:d,shadowBlur:u}=i;if("number"==typeof l)i.borderWidth=Vt(l*r);else if(Array.isArray(i.borderWidth)){const e=l;i.borderWidth=[Vt(e[0]*n),Vt(e[1]*o),Vt(e[2]*n),Vt(e[3]*o)]}if("number"==typeof s)i.borderRadius=Vt(s*r);else if(Array.isArray(i.borderRadius)){const e=s;i.borderRadius=[e[0]*o,e[1]*o,e[2]*n,e[3]*n]}Array.isArray(h)&&h.forEach(((e,t)=>{i.borderDash[t]=Vt(e*a)})),"number"==typeof c&&(i.shadowOffsetX=Vt(c*a)),"number"==typeof d&&(i.shadowOffsetX=Vt(d*a)),"number"==typeof u&&(i.shadowOffsetX=Vt(u*a))}function Ht(e,t){const{type:i}=e;!function(e,t){const{xRatio:i,yRatio:o}=t,{x:n,y:a,w:r,h:l}=e;e.x=Vt(n*i),e.y=Vt(a*o),e.w=Vt(r*i),e.h=Vt(l*o),Xt(e,t)}(e,t),"circle"===i||("text"===i?function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:n,lineHeight:a}=e.detail,r=(i+o)/2;n&&n>0&&(e.detail.fontSize=Vt(n*r)),a&&a>0&&(e.detail.lineHeight=Vt(a*r))}(e,t):"image"===i||"svg"===i||"html"===i||"path"===i||"group"===i&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Ht(e,t)})))}const Zt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Qt(e){return[e,...Zt].join(", ")}function Ut(e,t,i){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:n,opacity:a=1}=i,{x:r,y:l}=o,{scale:s}=n;if("linear-gradient"===(null==t?void 0:t.type)){const{start:i,end:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s},c={x:r+o.x*s,y:l+o.y*s},d=e.createLinearGradient(h.x,h.y,c.x,c.y);return n.forEach((e=>{d.addColorStop(e.offset,Ae(e.color,a))})),d}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:i,outer:o,stops:n}=t,h={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},c={x:r+o.x*s,y:l+o.y*s,radius:o.radius*s},d=e.createRadialGradient(h.x,h.y,h.radius,c.x,c.y,c.radius);return n.forEach((e=>{d.addColorStop(e.offset,Ae(e.color,a))})),d}return"#000000"}const $t={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Jt(e){var t,i,o,n;let a=1;return void 0!==(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.opacity)&&(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.opacity)>=0&&(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.opacity)<=1&&(a=null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.opacity),a}function Kt(e,t,i){const{pattern:o,renderContent:n,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=i||{},{parentOpacity:h}=i,c=Jt(a)*h,{clipPath:d,clipPathStrokeColor:u,clipPathStrokeWidth:f}=a.detail,g=()=>{e.globalAlpha=c,qt(e,t,{pattern:o,viewScaleInfo:l,viewSizeInfo:s}),null==n||n(),_t(e,t,{viewScaleInfo:l}),e.globalAlpha=h};d?(function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r}=i,l=r.devicePixelRatio,{clipPath:s}=(null==n?void 0:n.detail)||{};if(s&&a&&s.commands){const{x:i,y:n,w:r,h:h}=a,{originW:c,originH:d,originX:u,originY:f}=s,g=r/c,v=h/d,m=i-u*g,y=n-f*v;e.save(),e.translate(m,y),e.scale(l*g,l*v);const p=Bt(s.commands||[]),w=new Path2D(p);e.clip(w),e.translate(0-m,0-y),e.setTransform(1,0,0,1,0,0),ht(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof f&&f>0&&u&&function(e,t,i){const{renderContent:o,originElem:n,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=i,s=r.devicePixelRatio,{clipPath:h,clipPathStrokeColor:c,clipPathStrokeWidth:d}=(null==n?void 0:n.detail)||{};if(h&&a&&h.commands&&"number"==typeof d&&d>0&&c){const{x:i,y:n,w:r,h:u}=a,{originW:f,originH:g,originX:v,originY:m}=h,y=r/f,p=u/g,w=i-v*y,x=n-m*p;e.save(),e.globalAlpha=l,e.translate(w,x),e.scale(s*y,s*p);const S=Bt(h.commands||[]),b=new Path2D(S);e.strokeStyle=c,e.lineWidth=d,e.stroke(b),e.translate(0-w,0-x),e.setTransform(1,0,0,1,0,0),ht(e,Object.assign({},t),(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:r,viewSizeInfo:s,parentOpacity:h})):g()}function qt(e,t,i){var o,n;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=i,s=[];if(t.detail.background||a){const{x:i,y:l,w:h,h:c,radiusList:d}=Nt(t,{viewScaleInfo:r});if(e.beginPath(),e.moveTo(i+d[0],l),e.arcTo(i+h,l,i+h,l+c,d[1]),e.arcTo(i+h,l+c,i,l+c,d[2]),e.arcTo(i,l+c,i,l,d[3]),e.arcTo(i,l,i+h,l,d[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(Pe.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null===(o=t.detail.background)||void 0===o?void 0:o.type)){const o=Ut(e,t.detail.background,{viewElementSize:{x:i,y:l,w:h,h:c},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null===(n=t.detail.background)||void 0===n?void 0:n.type)){const o=Ut(e,t.detail.background,{viewElementSize:{x:i,y:l,w:h,h:c},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=o,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const o=s[t];"translate"===o.method?e.translate(o.args[0]+i,o.args[1]+l):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function _t(e,t,i){if(0===t.detail.borderWidth)return;if(!be(t.detail.borderColor))return;const{viewScaleInfo:o}=i,{scale:n}=o;let a=$t.borderColor;!0===be(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderDash:r,borderWidth:l,borderRadius:s,boxSizing:h=$t.boxSizing}=t.detail;let c=[];Array.isArray(r)&&r.length>0&&(c=r.map((e=>Math.ceil(e*n)))),c.length>0?e.lineCap="butt":e.lineCap="square";let d=[0,0,0,0];if("number"==typeof s){const e=s*n;d=[e,e,e,e]}else Array.isArray(s)&&4===(null==s?void 0:s.length)&&(d=[s[0]*n,s[1]*n,s[2]*n,s[3]*n]);let u=0;"number"==typeof l&&(u=l||1),u*=n,e.strokeStyle=a;let f=0,g=0,v=0,m=0;if(Array.isArray(l)&&(f=(l[0]||0)*n,g=(l[1]||0)*n,v=(l[2]||0)*n,m=(l[3]||0)*n),m||g||f||v){e.lineCap="butt";let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i+=m/2,o+=f/2,n=n-m/2-g/2,a=a-f/2-v/2):"content-box"===h?(i-=m/2,o-=f/2,n=n+m/2+g/2,a=a+f/2+v/2):(i=t.x,o=t.y,n=t.w,a=t.h),f&&(e.beginPath(),e.lineWidth=f,e.moveTo(i-m/2,o),e.lineTo(i+n+g/2,o),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(i+n,o-f/2),e.lineTo(i+n,o+a+v/2),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(i-m/2,o+a),e.lineTo(i+n+g/2,o+a),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(i,o-f/2),e.lineTo(i,o+a+v/2),e.closePath(),e.stroke())}else{let{x:i,y:o,w:n,h:a}=t;"border-box"===h?(i=t.x+u/2,o=t.y+u/2,n=t.w-u,a=t.h-u):"content-box"===h?(i=t.x-u/2,o=t.y-u/2,n=t.w+u,a=t.h+u):(i=t.x,o=t.y,n=t.w,a=t.h),n=Math.max(n,1),a=Math.max(a,1),d=d.map((e=>Math.min(e,n/2,a/2))),e.setLineDash(c),e.lineWidth=u,e.beginPath(),e.moveTo(i+d[0],o),e.arcTo(i+n,o,i+n,o+a,d[1]),e.arcTo(i+n,o+a,i,o+a,d[2]),e.arcTo(i,o+a,i,o,d[3]),e.arcTo(i,o,i+n,o,d[0]),e.closePath(),e.stroke()}e.setLineDash([])}function ei(e,t,i){const{detail:o}=t,{viewScaleInfo:n,renderContent:a}=i,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:h}=o;Be.number(h)?(e.save(),e.shadowColor=r||$t.shadowColor,e.shadowOffsetX=(l||0)*n.scale,e.shadowOffsetY=(s||0)*n.scale,e.shadowBlur=(h||0)*n.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}const ti={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function ii(e,t,i){var o,n;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:h,fillRule:c}=a,{viewScaleInfo:d,viewSizeInfo:u,parentOpacity:f}=i,{x:g,y:v,w:m,h:y,angle:p}=Pt(t,{viewScaleInfo:d})||t,w=m/s,x=y/h,S=g-r*w,b=v-l*x,A=t.detail,{clipPath:I,clipPathStrokeColor:M,clipPathStrokeWidth:R}=A,z=function(e,t){var i={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(i[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(i[o[n]]=e[o[n]])}return i}(A,["clipPath","clipPathStrokeColor","clipPathStrokeWidth"]),C=d.scale*u.devicePixelRatio,P=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:y,angle:p});let T=Object.assign({},P);T.detail=z;let E=Object.assign({},t);E.detail=z,a.fill&&"string"!==a.fill&&(null===(n=null===(o=a.fill)||void 0===o?void 0:o.type)||void 0===n?void 0:n.includes("gradient"))&&(T=Object.assign(Object.assign({},P),{detail:Object.assign(Object.assign({},P.detail),{background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:h}})}),E.detail=Object.assign({},T.detail)),ht(e,{x:g,y:v,w:m,h:y,angle:p},(()=>{Kt(e,T,{originElem:E,calcElemSize:{x:g,y:v,w:m,h:y,angle:p},viewScaleInfo:d,viewSizeInfo:u,parentOpacity:f,renderContent:()=>{ei(e,P,{viewScaleInfo:d,renderContent:()=>{e.save(),e.translate(S,b),e.scale(C*w/d.scale,C*x/d.scale);const t=Bt(a.commands||[]),i=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(i,c),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/u.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(i)),e.translate(-S,-b),e.restore()}})}})}))}function oi(e,t,i){var o,n,a;if(!0===(null===(o=null==t?void 0:t.operations)||void 0===o?void 0:o.invisible))return;const{w:r,h:l}=t,{scale:s}=i.viewScaleInfo;if(s<1&&(r*s<.4||l*s<.4)||0===i.parentOpacity)return;const{overrideElementMap:h}=i;if(!(null===(a=null===(n=null==h?void 0:h[t.uuid])||void 0===n?void 0:n.operations)||void 0===a?void 0:a.invisible))try{switch(t.type){case"rect":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=Pt(t,{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ht(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{ei(e,d,{viewScaleInfo:o,renderContent:()=>{Kt(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{}})}})}))}(e,t,i);break;case"circle":!function(e,t,i){const{detail:o,angle:n}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=i,{background:s="#000000",borderColor:h="#000000",boxSizing:c,borderWidth:d=0,borderDash:u}=o;let f=0;"number"==typeof d&&d>0?f=d:Array.isArray(d)&&"number"==typeof d[0]&&d[0]>0&&(f=d[0]),f*=a.scale;const{x:g,y:v,w:m,h:y}=Pt({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,p=Object.assign(Object.assign({},t),{x:g,y:v,w:m,h:y,angle:n});ht(e,{x:g,y:v,w:m,h:y,angle:n},(()=>{ei(e,p,{viewScaleInfo:a,renderContent:()=>{let t=m/2,i=y/2;const o=g+t,n=v+i,r=t,d=i;if(f>0&&("content-box"===c||("center-line"===c?(t-=f/2,i-=f/2):(t-=f,i-=f))),t>=0&&i>=0){const c=Jt(p)*l;e.globalAlpha=c,e.beginPath();const w=Ut(e,s,{viewElementSize:{x:g,y:v,w:m,h:y},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=w,e.circle(o,n,r,d,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof f&&f>0){const r=f/2+t,l=f/2+i;if(e.beginPath(),u){const t=u.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=h,e.lineWidth=f,e.circle(o,n,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,calculator:r}=i,{x:l,y:s,w:h,h:c,angle:d}=Pt(t,{viewScaleInfo:o})||t,u=Object.assign(Object.assign({},t),{x:l,y:s,w:h,h:c,angle:d});ht(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{var i,f;ei(e,u,{viewScaleInfo:o,renderContent:()=>{Kt(e,u,{originElem:t,calcElemSize:{x:l,y:s,w:h,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a})}});{const n=Object.assign(Object.assign({},ti),t.detail),a=(n.fontSize||ti.fontSize)*o.scale;if(a<2)return;e.fillStyle=t.detail.color||ti.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:a,fontFamily:Qt(n.fontFamily)});{const a=r.getVirtualFlatItem(t.uuid);Array.isArray(null==a?void 0:a.textLines)&&(null===(i=null==a?void 0:a.textLines)||void 0===i?void 0:i.length)>0&&(void 0!==n.textShadowColor&&be(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&Be.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&Be.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&Be.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),null===(f=null==a?void 0:a.textLines)||void 0===f||f.forEach((t=>{e.fillText(t.text,l+t.x*o.scale,s+t.y*o.scale)})))}}}))}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=Pt(t,{viewScaleInfo:n})||t,u=Object.assign(Object.assign({},t),{x:l,y:s,w:h,h:c,angle:d});ht(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{ei(e,u,{viewScaleInfo:n,renderContent:()=>{Kt(e,u,{originElem:t,calcElemSize:{x:l,y:s,w:h,h:c,angle:d},viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"image"===t.type&&o){e.globalAlpha=Jt(t)*r;const{x:i,y:a,w:l,h:s,radiusList:h}=Nt(u,{viewScaleInfo:n}),{detail:c}=t,{scaleMode:d,originW:f=0,originH:g=0}=c,v=e.$undoPixelRatio(f),m=e.$undoPixelRatio(g);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+h[0],a),e.arcTo(i+l,a,i+l,a+s,h[1]),e.arcTo(i+l,a+s,i,a+s,h[2]),e.arcTo(i,a+s,i,a,h[3]),e.arcTo(i,a,i+l,a,h[0]),e.closePath(),e.fill(),e.clip(),d&&g&&f){let n=0,r=0,h=v,c=m;const u=i,f=a,g=l,y=s;if(v>t.w||m>t.h)if("fill"===d){const e=Math.max(t.w/v,t.h/m),i=m*e;n=(v*e-t.w)/2/e,r=(i-t.h)/2/e,h=t.w/e,c=t.h/e}else if("tile"===d)n=0,r=0,h=t.w,c=t.h;else if("fit"===d){const e=Math.min(t.w/v,t.h/m);n=(v-t.w/e)/2,r=(m-t.h/e)/2,h=t.w/e,c=t.h/e}e.drawImage(o,n,r,h,c,u,f,g,y)}else e.drawImage(o,i,a,l,s);e.globalAlpha=r,e.restore()}}})}})}))}(e,t,i);break;case"svg":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=Pt(t,{viewScaleInfo:n})||t;ht(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"svg"===t.type&&o&&(e.globalAlpha=Jt(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"html":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,{x:l,y:s,w:h,h:c,angle:d}=Pt(t,{viewScaleInfo:n})||t;ht(e,{x:l,y:s,w:h,h:c,angle:d},(()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.elementAssets||{}),"html"===t.type&&o&&(e.globalAlpha=Jt(t)*r,e.drawImage(o,l,s,h,c),e.globalAlpha=r)}))}(e,t,i);break;case"path":ii(e,t,i);break;case"group":{const o=Object.assign(Object.assign({},i.elementAssets||{}),t.detail.assets||{});!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a}=i,{x:r,y:l,w:s,h:h,angle:c}=Pt({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:o})||t,d=Object.assign(Object.assign({},t),{x:r,y:l,w:s,h:h,angle:c});ht(e,{x:r,y:l,w:s,h:h,angle:c},(()=>{e.globalAlpha=Jt(t)*a,ei(e,d,{viewScaleInfo:o,renderContent:()=>{Kt(e,d,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:h,angle:c},viewScaleInfo:o,viewSizeInfo:n,parentOpacity:a,renderContent:()=>{const{x:n,y:r,w:l,h:s,radiusList:h}=Nt(d,{viewScaleInfo:o});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+h[0],r),e.arcTo(n+l,r,n+l,r+s,h[1]),e.arcTo(n+l,r+s,n,r+s,h[2]),e.arcTo(n,r+s,n,r,h[3]),e.arcTo(n,r,n+l,r,h[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:o}=i,n={x:o.x+t.x,y:o.y+t.y,w:t.w||o.w,h:t.h||o.h,angle:t.angle},{calculator:r}=i;for(let o=0;o<t.detail.children.length;o++){let l=t.detail.children[o];if(l=Object.assign(Object.assign({},l),{x:n.x+l.x,y:n.y+l.y}),!0===i.forceDrawAll||(null==r?void 0:r.needRender(l)))try{oi(e,l,Object.assign(Object.assign({},i),{parentOpacity:a*Jt(t)}))}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,Object.assign(Object.assign({},i),{elementAssets:o}));break}}}catch(e){console.error(e)}}const ni={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function ai(e,t,i){var o;const{elements:n=[]}=t,{parentOpacity:a}=i;for(let t=0;t<n.length;t++){const r=n[t],l=Object.assign(Object.assign({},r),{detail:Object.assign(Object.assign({},ni),null==r?void 0:r.detail)});if(!0===i.forceDrawAll||(null===(o=i.calculator)||void 0===o?void 0:o.needRender(l)))try{oi(e,l,Object.assign(Object.assign({},i),{parentOpacity:a}))}catch(e){console.error(e)}}}var ri,li,si,hi,ci,di,ui,fi,gi,vi,mi,yi,pi=function(e,t,i,o){return new(i||(i=Promise))((function(n,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))},wi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)},xi=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i};const Si=["image","svg","html"],bi=e=>{var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),"string"==typeof n&&n?/^@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(`${n}`)?n:Re(n):Re(`${Ie()}-${e.uuid}-${Ie()}-${Ie()}`)};class Ai extends $e{constructor(){super(),ri.add(this),li.set(this,{}),si.set(this,{}),hi.set(this,{}),ci.set(this,!1),wi(this,ri,"m",di).call(this,"image",((e,t)=>pi(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.src])||void 0===i?void 0:i.value)||e.detail.src,n=yield ke(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),wi(this,ri,"m",di).call(this,"html",((e,t)=>pi(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.html])||void 0===i?void 0:i.value)||e.detail.html,n=yield We(o,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:n}})))),wi(this,ri,"m",di).call(this,"svg",((e,t)=>pi(this,void 0,void 0,(function*(){var i;const o=(null===(i=t[e.detail.svg])||void 0===i?void 0:i.value)||e.detail.svg,n=yield Le(o);return{uuid:e.uuid,lastModified:Date.now(),content:n}}))))}isDestroyed(){return wi(this,ci,"f")}destroy(){xi(this,ci,!0,"f"),this.clear(),xi(this,li,null,"f"),xi(this,si,null,"f"),xi(this,hi,null,"f")}load(e,t){!0!==wi(this,ci,"f")&&(wi(this,ri,"m",yi).call(this,e)||Si.includes(e.type)&&wi(this,ri,"m",mi).call(this,e,t))}getContent(e){var t,i;const o=bi(e);return(null===(i=null===(t=wi(this,hi,"f"))||void 0===t?void 0:t[o])||void 0===i?void 0:i.content)||null}getLoadItemMap(){return wi(this,hi,"f")}setLoadItemMap(e){xi(this,hi,e,"f")}}li=new WeakMap,si=new WeakMap,hi=new WeakMap,ci=new WeakMap,ri=new WeakSet,di=function(e,t){wi(this,li,"f")[e]=t},ui=function(e){var t,i,o;let n=null;return"image"===e.type?n=(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.src)||null:"svg"===e.type?n=(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.svg)||null:"html"===e.type&&(n=(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.html)||null),n},fi=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:wi(this,ri,"m",ui).call(this,e)}},gi=function(e){const t=bi(e.element),i=wi(this,hi,"f")[t];wi(this,ci,"f")||(i?i.startTime<e.startTime&&(wi(this,hi,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(wi(this,hi,"f")[t]=e,this.trigger("load",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},vi=function(e){var t;const i=bi(e.element),o=null===(t=wi(this,hi,"f"))||void 0===t?void 0:t[i];wi(this,ci,"f")||(o?o.startTime<e.startTime&&(wi(this,hi,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))):(wi(this,hi,"f")[i]=e,this.trigger("error",Object.assign(Object.assign({},e),{countTime:e.endTime-e.startTime}))))},mi=function(e,t){const i=wi(this,ri,"m",fi).call(this,e),o=bi(e);if(wi(this,si,"f")[o])return;wi(this,si,"f")[o]=i;const n=wi(this,li,"f")[e.type];"function"!=typeof n||wi(this,ci,"f")||(i.startTime=Date.now(),n(e,t).then((e=>{wi(this,ci,"f")||(i.content=e.content,i.endTime=Date.now(),i.status="load",wi(this,ri,"m",gi).call(this,i))})).catch((t=>{console.warn(`Load element source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,wi(this,ri,"m",vi).call(this,i)})))},yi=function(e){var t;const i=bi(e),o=null===(t=wi(this,si,"f"))||void 0===t?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==wi(this,ri,"m",ui).call(this,e))};const Ii={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function Mi(e,t){let i={};return"text"===e.type&&(i=function(e,t){const{w:i,h:o}=e,n=t.tempContext,a=[],r=Object.assign(Object.assign({},Ii),e.detail),l=r.fontSize||Ii.fontSize,s=l;if(s<2)return{};const h=r.lineHeight||l;n.textBaseline="top",n.$setFont({fontWeight:r.fontWeight,fontSize:s,fontFamily:Qt(r.fontFamily)});let c=r.text.replace(/\r\n/gi,"\n");"lowercase"===r.textTransform?c=c.toLowerCase():"uppercase"===r.textTransform&&(c=c.toUpperCase());const d=h,u=c.split("\n");let f=0;u.forEach(((e,t)=>{if("maxContent"===r.minInlineSize)a.push({x:0,y:0,text:e,width:n.$undoPixelRatio(n.measureText(e).width)});else{let l="",s="",h=e.split(s);if("normal"===r.wordBreak){s=" ";const t=e.split(s);h=[],t.forEach(((e,i)=>{h.push(e),i<t.length-1&&h.push(s)}))}if(1===h.length&&"visible"===r.overflow)a.push({x:0,y:0,text:h[0],width:n.$undoPixelRatio(n.measureText(h[0]).width)});else if(h.length>0){for(let e=0;e<h.length&&(n.$doPixelRatio(i)>=n.measureText(l+h[e]).width?l+=h[e]||"":(a.push({x:0,y:0,text:l,width:n.$undoPixelRatio(n.measureText(l).width)}),l=h[e]||"",f++),!((f+1)*d>o&&"hidden"===r.overflow));e++)if(h.length-1===e&&(f+1)*d<=o){a.push({x:0,y:0,text:l,width:n.$undoPixelRatio(n.measureText(l).width)}),t<u.length-1&&f++;break}}else a.push({x:0,y:0,text:"",width:0})}}));let g=0,v=0;d>s&&(v=(d-s)/2),a.length*d<o&&("top"===e.detail.verticalAlign?g=0:"bottom"===e.detail.verticalAlign?g+=o-a.length*d:g+=(o-a.length*d)/2);{const e=0+g;a.forEach(((t,o)=>{let n=0;"center"===r.textAlign?n=0+(i-t.width)/2:"right"===r.textAlign&&(n=i-t.width+0),a[o].x=n,a[o].y=e+d*o+v}))}return{textLines:a}}(e,t)),i}function Ri(e,t){const{viewScaleInfo:i,viewSizeInfo:o,tempContext:n}=t,a=function(e,t){const i={},o=[],n=a=>{const r={type:a.type,isVisibleInView:!0,position:[...o]};let l=null;l=Wt(a,{groupQueue:St(e,o)||[]});const s=Object.assign(Object.assign(Object.assign({},r),{originRectInfo:l,rangeRectInfo:Be.angle(a.angle)?Ot(l):l}),Mi(a,t));i[a.uuid]=s,"group"===a.type&&a.detail.children.forEach(((e,t)=>{o.push(t),n(e),o.pop()}))};return e.forEach(((e,t)=>{o.push(t),n(e),o.pop()})),i}(e,{tempContext:n});return zi(a,{viewScaleInfo:i,viewSizeInfo:o})}function zi(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n,offsetLeft:a}=t,{width:r,height:l}=i,s=0-a/o,h=0-n/o,c=r/o,d=l/o,u=ct({x:s,y:h,w:c,h:d}),f={x:s,y:h},g={x:s+c,y:h},v={x:s,y:h+d},m={x:s+c,y:h+d},y={x:s,y:u.y},p={x:u.x,y:h},w={x:s+c,y:u.y},x={x:u.x,y:h+d};return{center:u,topLeft:f,topRight:g,bottomLeft:v,bottomRight:m,left:y,top:p,right:w,bottom:x}}(t);let o=0,n=0;return Object.keys(e).forEach((t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),o=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),a=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),r=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),l=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),s=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),h=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y);return i<=l&&o>=r&&n<=h&&a>=s||l<=a&&l>=a&&l<=a&&l>=a}(a.rangeRectInfo,i),a.isVisibleInView?o++:n++})),{virtualFlatItemMap:e,visibleCount:o,invisibleCount:n}}var Ci,Pi,Ti=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Ei=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class ki{constructor(e){Ci.set(this,void 0),Pi.set(this,void 0),Ti(this,Ci,e,"f"),Ti(this,Pi,new nt({defaultStorage:{virtualFlatItemMap:{},visibleCount:0,invisibleCount:0}}),"f")}toGridNum(e,t){return!0===(null==t?void 0:t.ignore)?e:Math.round(e)}destroy(){Ti(this,Ci,null,"f")}needRender(e){const t=Ei(this,Pi,"f").get("virtualFlatItemMap")[e.uuid];return!t||t.isVisibleInView}getPointElement(e,t){const i=Ei(this,Ci,"f").tempContext;return function(e,t){var i,o,n;const{context2d:a,data:r,viewScaleInfo:l,viewSizeInfo:s,groupQueue:h}=t,c={index:-1,element:null,groupQueueIndex:-1};if(h&&Array.isArray(h)&&(null==h?void 0:h.length)>0)for(let t=h.length-1;t>=0;t--){let n=0,r=0,s=0;for(let e=0;e<=t;e++)n+=h[e].x,r+=h[e].y,s+=h[e].angle||0;const d=h[t];if(d&&"group"===d.type&&Array.isArray(null===(i=d.detail)||void 0===i?void 0:i.children))for(let i=0;i<d.detail.children.length;i++){const u=d.detail.children[i];if(!0!==(null===(o=null==u?void 0:u.operations)||void 0===o?void 0:o.invisible)){if(!u)break;if(kt(e,{context2d:a,element:{x:n+u.x,y:r+u.y,w:u.w,h:u.h,angle:s+(u.angle||0)},viewScaleInfo:l})){c.element=u,(t<h.length-1||"group"!==u.type)&&(c.groupQueueIndex=t);break}}}if(c.element)break}if(c.element)return c;for(let t=r.elements.length-1;t>=0;t--){const i=r.elements[t];if(!0!==(null===(n=null==i?void 0:i.operations)||void 0===n?void 0:n.invisible)&&kt(e,{context2d:a,element:i,viewScaleInfo:l})){c.index=t,c.element=i;break}}return c}(e,Object.assign(Object.assign({},t),{context2d:i}))}resetVirtualFlatItemMap(e,t){if(e){const{virtualFlatItemMap:i,invisibleCount:o,visibleCount:n}=Ri(e.elements,Object.assign(Object.assign({},t),{tempContext:Ei(this,Ci,"f").tempContext}));Ei(this,Pi,"f").set("virtualFlatItemMap",i),Ei(this,Pi,"f").set("invisibleCount",o),Ei(this,Pi,"f").set("visibleCount",n)}}updateVisiableStatus(e){const{virtualFlatItemMap:t,invisibleCount:i,visibleCount:o}=zi(Ei(this,Pi,"f").get("virtualFlatItemMap"),e);Ei(this,Pi,"f").set("virtualFlatItemMap",t),Ei(this,Pi,"f").set("invisibleCount",i),Ei(this,Pi,"f").set("visibleCount",o)}calcViewRectInfoFromOrigin(e,t){const i=Ei(this,Pi,"f").get("virtualFlatItemMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.originRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n};return{center:Tt(r,v),left:Tt(l,v),right:Tt(s,v),bottom:Tt(h,v),top:Tt(c,v),topLeft:Tt(d,v),topRight:Tt(u,v),bottomLeft:Tt(f,v),bottomRight:Tt(g,v)}}calcViewRectInfoFromRange(e,t){const i=Ei(this,Pi,"f").get("virtualFlatItemMap")[e];if(!(null==i?void 0:i.originRectInfo))return null;const{checkVisible:o,viewScaleInfo:n,viewSizeInfo:a}=t,{center:r,left:l,right:s,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.rangeRectInfo;if(!0===o&&!1===i.isVisibleInView)return null;const v={viewScaleInfo:n};return{center:Tt(r,v),left:Tt(l,v),right:Tt(s,v),bottom:Tt(h,v),top:Tt(c,v),topLeft:Tt(d,v),topRight:Tt(u,v),bottomLeft:Tt(f,v),bottomRight:Tt(g,v)}}modifyVirtualFlatItemMap(e,t){const{modifyOptions:i,viewScaleInfo:o,viewSizeInfo:n}=t,{type:a,content:r}=i,l=e.elements,s=Ei(this,Pi,"f").get("virtualFlatItemMap");if("deleteElement"===a){const{element:e}=r,t=[],i=e=>{t.push(e.uuid),"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{i(e)}))};i(e),t.forEach((e=>{delete s[e]})),Ei(this,Pi,"f").set("virtualFlatItemMap",s)}else if("addElement"===a||"updateElement"===a){const{position:t}=r,i=At(t,e.elements),h=St(l,t);if(i)if("updateElement"===a&&"group"===i.type)this.resetVirtualFlatItemMap(e,{viewScaleInfo:o,viewSizeInfo:n});else{const e=Wt(i,{groupQueue:h||[]}),r=Object.assign({type:i.type,originRectInfo:e,rangeRectInfo:Be.angle(i.angle)?Ot(e):e,isVisibleInView:!0,position:[...t]},Mi(i,{tempContext:Ei(this,Ci,"f").tempContext}));s[i.uuid]=r,Ei(this,Pi,"f").set("virtualFlatItemMap",s),"updateElement"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:n})}}else"moveElement"===a&&this.resetVirtualFlatItemMap(e,{viewScaleInfo:o,viewSizeInfo:n})}getVirtualFlatItem(e){return Ei(this,Pi,"f").get("virtualFlatItemMap")[e]||null}}Ci=new WeakMap,Pi=new WeakMap;var Li,Wi,Oi,Di,ji,Yi,Bi=function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},Fi=function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};class Gi extends $e{constructor(e){super(),Li.add(this),Wi.set(this,void 0),Oi.set(this,new Ai),Di.set(this,void 0),ji.set(this,!1),Bi(this,Wi,e,"f"),Bi(this,Di,new ki({tempContext:e.tempContext}),"f"),Fi(this,Li,"m",Yi).call(this)}isDestroyed(){return Fi(this,ji,"f")}destroy(){this.clear(),Bi(this,Wi,null,"f"),Fi(this,Oi,"f").destroy(),Bi(this,Oi,null,"f"),Bi(this,ji,!0,"f")}updateOptions(e){Bi(this,Wi,e,"f")}drawData(e,t){const i=Fi(this,Oi,"f"),o=Fi(this,Di,"f"),{sharer:n}=Fi(this,Wi,"f"),a=Fi(this,Wi,"f").viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},l=Object.assign({loader:i,calculator:o,parentElementSize:r,elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==n?void 0:n.getActiveOverrideElemenentMap()},t);!function(e,t,i){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:o}=i,{width:n,height:a}=o;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,n,a)}}(a,e.global,l),e.layout?function(e,t,i,o){const{viewScaleInfo:n,viewSizeInfo:a,parentOpacity:r}=i,l=Object.assign({uuid:"layout",type:"group"},t),{x:s,y:h,w:c,h:d}=Pt(l,{viewScaleInfo:n})||l,u=Object.assign(Object.assign({},l),{x:s,y:h,w:c,h:d,angle:0});if(e.globalAlpha=1,ei(e,u,{viewScaleInfo:n,renderContent:()=>{qt(e,u,{viewScaleInfo:n,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:o,viewSizeInfo:n}=i,a=Object.assign({uuid:"layout",type:"group"},t),r=Pt(a,{viewScaleInfo:o})||a,l=Object.assign(Object.assign({},a),r),{x:s,y:h,w:c,h:d,radiusList:u}=Nt(l,{viewScaleInfo:o});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+u[0],h),e.arcTo(s+c,h,s+c,h+d,u[1]),e.arcTo(s+c,h+d,s,h+d,u[2]),e.arcTo(s,h+d,s,h,u[3]),e.arcTo(s,h,s+c,h,u[0]),e.closePath(),e.fill(),e.clip()}o(e),"hidden"===t.detail.overflow&&e.restore(),_t(e,u,{viewScaleInfo:n}),e.globalAlpha=r}(a,e.layout,l,(()=>{ai(a,e,l)})):ai(a,e,l)}scale(e){const{sharer:t}=Fi(this,Wi,"f");if(!t)return;const{data:i,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:n,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){Fi(this,Oi,"f").setLoadItemMap(e)}getLoadItemMap(){return Fi(this,Oi,"f").getLoadItemMap()}getLoader(){return Fi(this,Oi,"f")}getCalculator(){return Fi(this,Di,"f")}}function Ni(e){return e>0||e<0||0===e}Wi=new WeakMap,Oi=new WeakMap,Di=new WeakMap,ji=new WeakMap,Li=new WeakSet,Yi=function(){const e=Fi(this,Oi,"f");e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))};class Vi extends $e{constructor(e){super(),we(this,n),we(this,t),we(this,i),we(this,o,!1),we(this,r,(e=>{if(!Se(this,n,g).call(this,e))return;const t=Se(this,n,v).call(this,e);if(!Se(this,n,m).call(this,t))return;e.preventDefault(),e.stopPropagation();const i=e.deltaX>0||e.deltaX<0?e.deltaX:0,o=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:i,deltaY:o,point:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:i,deltaY:o,point:t})})),we(this,l,(e=>{if(2!==e.button)return;if(!Se(this,n,g).call(this,e))return;e.preventDefault();const t=Se(this,n,v).call(this,e);Se(this,n,m).call(this,t)&&this.trigger("contextMenu",{point:t})})),we(this,s,(e=>{if(!Se(this,n,g).call(this,e))return;e.preventDefault();const t=Se(this,n,v).call(this,e);if(!Se(this,n,m).call(this,t))return;const o=Date.now(),a=pe(this,i).get("prevClickPoint");a&&o-a.t<=500&&Math.abs(a.x-t.x)<=5&&Math.abs(a.y-t.y)<=5?this.trigger("doubleClick",{point:t}):pe(this,i).set("prevClickPoint",t)})),we(this,h,(e=>{pe(this,i).set("hasPointDown",!1),e.preventDefault();const t=Se(this,n,v).call(this,e);this.trigger("pointLeave",{point:t})})),we(this,c,(e=>{if(pe(this,i).set("hasPointDown",!1),!Se(this,n,g).call(this,e))return;e.preventDefault();const t=Se(this,n,v).call(this,e);this.trigger("pointEnd",{point:t})})),we(this,d,(e=>{if(!Se(this,n,g).call(this,e))return;e.preventDefault(),e.stopPropagation();const t=Se(this,n,v).call(this,e);Se(this,n,m).call(this,t)?!0===pe(this,i).get("hasPointDown")&&this.trigger("pointMove",{point:t}):pe(this,i).get("hasPointDown")&&(this.trigger("pointLeave",{point:t}),pe(this,i).set("hasPointDown",!1))})),we(this,u,(e=>{if(0!==e.button)return;if(!Se(this,n,g).call(this,e))return;e.preventDefault();const t=Se(this,n,v).call(this,e);Se(this,n,m).call(this,t)&&(pe(this,i).set("hasPointDown",!0),this.trigger("pointStart",{point:t}))})),we(this,f,(e=>{if(!Se(this,n,g).call(this,e))return void(!0===pe(this,i).get("inCanvas")&&(pe(this,i).set("inCanvas",!1),pe(this,h).call(this,e)));pe(this,i).set("inCanvas",!0),e.preventDefault();const t=Se(this,n,v).call(this,e);Se(this,n,m).call(this,t)&&this.trigger("hover",{point:t})}));const y=new nt({defaultStorage:{hasPointDown:!1,prevClickPoint:null,inCanvas:!0}});xe(this,i,y),xe(this,t,e),Se(this,n,a).call(this)}onEvents(){if(pe(this,o))return;const e=pe(this,t).boardContent.boardContext.canvas,i=window;i.addEventListener("mousemove",pe(this,f)),i.addEventListener("mousedown",pe(this,u)),i.addEventListener("mousemove",pe(this,d)),i.addEventListener("mouseup",pe(this,c)),e.addEventListener("wheel",pe(this,r),{passive:!1}),i.addEventListener("click",pe(this,s)),i.addEventListener("contextmenu",pe(this,l))}offEvents(){const e=window,i=pe(this,t).boardContent.boardContext.canvas;e.removeEventListener("mousemove",pe(this,f)),e.removeEventListener("mousedown",pe(this,u)),e.removeEventListener("mousemove",pe(this,d)),e.removeEventListener("mouseup",pe(this,c)),e.removeEventListener("mouseleave",pe(this,h)),i.removeEventListener("wheel",pe(this,r)),e.removeEventListener("click",pe(this,s)),e.removeEventListener("contextmenu",pe(this,l))}destroy(){this.offEvents(),pe(this,i).destroy(),xe(this,o,!0)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,n=new WeakSet,a=function(){this.onEvents()},r=new WeakMap,l=new WeakMap,s=new WeakMap,h=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,f=new WeakMap,g=function(e){return e.target===pe(this,t).boardContent.boardContext.canvas},v=function(e){const i=pe(this,t).boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-i.left,y:e.clientY-i.top,t:Date.now()}},m=function(e){const i=pe(this,t).sharer.getActiveViewSizeInfo(),{width:o,height:n}=i;return!!(Ni(e.x)&&Ni(e.y)&&e.x<=o&&e.y<=n)};const Xi={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:null,scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideElementMap:null};class Hi{constructor(){we(this,y),we(this,p);const e=new nt({defaultStorage:Xi}),t=new nt({defaultStorage:{}});xe(this,y,e),xe(this,p,t)}getActiveStorage(e){return pe(this,y).get(e)}setActiveStorage(e,t){return pe(this,y).set(e,t)}getActiveStoreSnapshot(e){return pe(this,y).getSnapshot(e)}getSharedStorage(e){return pe(this,p).get(e)}setSharedStorage(e,t){return pe(this,p).set(e,t)}getSharedStoreSnapshot(e){return pe(this,p).getSnapshot(e)}getActiveViewScaleInfo(){return{scale:pe(this,y).get("scale"),offsetTop:pe(this,y).get("offsetTop"),offsetBottom:pe(this,y).get("offsetBottom"),offsetLeft:pe(this,y).get("offsetLeft"),offsetRight:pe(this,y).get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:n,offsetRight:a}=e;pe(this,y).set("scale",t),pe(this,y).set("offsetTop",i),pe(this,y).set("offsetBottom",o),pe(this,y).set("offsetLeft",n),pe(this,y).set("offsetRight",a)}setActiveViewSizeInfo(e){pe(this,y).set("width",e.width),pe(this,y).set("height",e.height),pe(this,y).set("devicePixelRatio",e.devicePixelRatio),pe(this,y).set("contextWidth",e.contextWidth),pe(this,y).set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:pe(this,y).get("width"),height:pe(this,y).get("height"),devicePixelRatio:pe(this,y).get("devicePixelRatio"),contextWidth:pe(this,y).get("contextWidth"),contextHeight:pe(this,y).get("contextHeight")}}getActiveOverrideElemenentMap(){return pe(this,y).get("overrideElementMap")}setActiveOverrideElemenentMap(e){pe(this,y).set("overrideElementMap",e)}}y=new WeakMap,p=new WeakMap;const{requestAnimationFrame:Zi}=window;class Qi extends $e{constructor(e){super(),we(this,b),we(this,w),we(this,x,[]),we(this,S,"FREE"),xe(this,w,e),Se(this,b,A).call(this)}resetVirtualFlatItemMap(e,t){e&&pe(this,w).calculator.resetVirtualFlatItemMap(e,t)}drawFrame(){const{sharer:e}=pe(this,w),t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();pe(this,x).push({activeStore:t,sharedStore:i}),Se(this,b,I).call(this)}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:n}=pe(this,w),{moveX:a,moveY:r}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:n,offsetTop:a}=o,r=t/o.scale,l=i.x,s=i.y;return{moveX:l-l*r+(n*r-n),moveY:s-s*r+(a*r-a)}}({scale:t,point:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});return n.setActiveStorage("scale",t),o||pe(this,w).calculator.updateVisiableStatus({viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),{moveX:a,moveY:r}}scroll(e){const{sharer:t}=pe(this,w),i=t.getActiveViewScaleInfo(),{moveX:o,moveY:n,ignoreUpdateVisibleStatus:a}=e,r=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:n}=e,{scale:a}=o,{width:r,height:l,contextWidth:s,contextHeight:h}=n;let c=o.offsetLeft,d=o.offsetRight,u=o.offsetTop,f=o.offsetBottom;return c+=t,u+=i,d=r-(s*a+c),f=l-(h*a+u),{scale:a,offsetTop:u,offsetLeft:c,offsetRight:d,offsetBottom:f}}({moveX:o,moveY:n,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(r),a||pe(this,w).calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),r}updateViewScaleInfo(e){const{sharer:t}=pe(this,w),i=function(e,t){const{scale:i,offsetX:o,offsetY:n}=e,{viewSizeInfo:a}=t,{width:r,height:l,contextWidth:s,contextHeight:h}=a,c=0-o*i,d=0-n*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:r-(s*i+c/i),offsetBottom:l-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),pe(this,w).calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=pe(this,w),o={...i.getActiveViewSizeInfo(),...e},{width:n,height:a,devicePixelRatio:r}=o,{underlayContext:l,boardContext:s,overlayContext:h,viewContext:c}=pe(this,w).boardContent;return s.canvas.width=n*r,s.canvas.height=a*r,s.canvas.style.width=`${n}px`,s.canvas.style.height=`${a}px`,l.canvas.width=n*r,l.canvas.height=a*r,h.canvas.width=n*r,h.canvas.height=a*r,c.canvas.width=n*r,c.canvas.height=a*r,i.setActiveViewSizeInfo(o),(null==t?void 0:t.ignoreUpdateVisibleStatus)||pe(this,w).calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),o}}w=new WeakMap,x=new WeakMap,S=new WeakMap,b=new WeakSet,A=function(){const{renderer:e}=pe(this,w);e.on("load",(()=>{this.drawFrame()}))},I=function(){if("DRAWING"===pe(this,S)||0===pe(this,x).length)return;xe(this,S,"DRAWING");const e=pe(this,x).shift(),{renderer:t,boardContent:i,beforeDrawFrame:o,afterDrawFrame:n}=pe(this,w);if(e){const{scale:a,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h,width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g}=e.activeStore,v={scale:a,offsetTop:r,offsetBottom:l,offsetLeft:s,offsetRight:h},m={width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g};(null==e?void 0:e.activeStore.data)&&t.drawData(e.activeStore.data,{viewScaleInfo:v,viewSizeInfo:m}),o({snapshot:e}),i.drawView(),n({snapshot:e})}0!==pe(this,x).length?xe(this,S,"DRAWING")&&Zi((()=>{Se(this,b,I).call(this)})):xe(this,S,"COMPLETE")};class Ui{constructor(e){we(this,D),we(this,M),we(this,R,new WeakMap),we(this,z,[]),we(this,C,[]),we(this,P),we(this,T),we(this,E),we(this,k),we(this,L),we(this,W,new $e),we(this,O,!1);const{boardContent:t}=e,i=new Hi,o=new Vi({boardContent:t,sharer:i}),n=new Gi({viewContext:t.viewContext,tempContext:t.tempContext,sharer:i}),a=n.getCalculator();xe(this,M,e),xe(this,E,i),xe(this,P,o),xe(this,T,n),xe(this,L,a),xe(this,k,new Qi({boardContent:e.boardContent,sharer:i,renderer:n,calculator:pe(this,L),beforeDrawFrame:e=>{Se(this,D,K).call(this,e)},afterDrawFrame:e=>{Se(this,D,q).call(this,e)}})),Se(this,D,j).call(this),Se(this,D,_).call(this)}isDestroyed(){return pe(this,O)}destroy(){pe(this,P).destroy(),pe(this,T).destroy(),pe(this,L).destroy(),pe(this,W).destroy(),xe(this,O,!0)}getSharer(){return pe(this,E)}getViewer(){return pe(this,k)}getRenderer(){return pe(this,T)}setData(e,t){const{modifiedOptions:i}=t||{},o=pe(this,E);pe(this,E).setActiveStorage("data",e);const n=o.getActiveViewSizeInfo(),a=o.getActiveViewScaleInfo(),r=xt(e.elements,{viewWidth:n.width,viewHeight:n.height,extend:!0});pe(this,k).resetVirtualFlatItemMap(e,{viewSizeInfo:n,viewScaleInfo:a}),pe(this,k).drawFrame();const l={...n,...r};return pe(this,E).setActiveViewSizeInfo(l),{viewSizeInfo:l}}getData(){const{data:e}=pe(this,E).getActiveStoreSnapshot();return e}use(e,t){var i,o,n;if(pe(this,R).has(e)){const t=pe(this,R).get(e);if(t)return null==(o=(i=t.middlewareObject).use)||o.call(i),t.status="enable",pe(this,R).set(e,t),void Se(this,D,_).call(this)}const{boardContent:a,container:r}=pe(this,M),l=e({boardContent:a,sharer:pe(this,E),viewer:pe(this,k),calculator:pe(this,L),eventHub:pe(this,W),container:r},t);null==(n=l.use)||n.call(l),pe(this,z).push(e),pe(this,C).push(l),pe(this,R).set(e,{status:"enable",middlewareObject:l,config:t}),Se(this,D,_).call(this)}disuse(e){var t,i;const o=pe(this,R).get(e);o&&(null==(i=(t=o.middlewareObject).disuse)||i.call(t),o.status="disable",pe(this,R).set(e,o),Se(this,D,_).call(this))}resetMiddlewareConfig(e,t){var i,o;if(pe(this,R).has(e)){const n=pe(this,R).get(e);n&&(null==(o=(i=n.middlewareObject).resetConfig)||o.call(i,t))}}scale(e){const t=pe(this,k),{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:n}=t.scale({...e,ignoreUpdateVisibleStatus:!0});t.scroll({moveX:o,moveY:n,ignoreUpdateVisibleStatus:i})}scroll(e){return pe(this,k).scroll(e)}updateViewScaleInfo(e){return pe(this,k).updateViewScaleInfo(e)}resize(e,t){const i=pe(this,k).resize(e,t),{width:o,height:n,devicePixelRatio:a}=e,{boardContent:r}=pe(this,M);r.viewContext.$resize({width:o,height:n,devicePixelRatio:a}),r.overlayContext.$resize({width:o,height:n,devicePixelRatio:a}),r.boardContext.$resize({width:o,height:n,devicePixelRatio:a}),r.underlayContext.$resize({width:o,height:n,devicePixelRatio:a}),pe(this,k).drawFrame(),pe(this,P).trigger("resize",i),pe(this,E).setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=pe(this,M),{underlayContext:t,overlayContext:i,viewContext:o,boardContext:n}=e;t.clearRect(0,0,t.canvas.width,t.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),n.clearRect(0,0,n.canvas.width,n.canvas.height),Se(this,D,J).call(this)}getEventHub(){return pe(this,W)}onWatcherEvents(){pe(this,P).onEvents()}offWatcherEvents(){pe(this,P).offEvents()}}M=new WeakMap,R=new WeakMap,z=new WeakMap,C=new WeakMap,P=new WeakMap,T=new WeakMap,E=new WeakMap,k=new WeakMap,L=new WeakMap,W=new WeakMap,O=new WeakMap,D=new WeakSet,j=function(){pe(this,P).on("pointStart",Se(this,D,Y).bind(this)),pe(this,P).on("pointEnd",Se(this,D,B).bind(this)),pe(this,P).on("pointMove",Se(this,D,F).bind(this)),pe(this,P).on("pointLeave",Se(this,D,G).bind(this)),pe(this,P).on("hover",Se(this,D,N).bind(this)),pe(this,P).on("wheel",Se(this,D,H).bind(this)),pe(this,P).on("wheelScale",Se(this,D,Z).bind(this)),pe(this,P).on("scrollX",Se(this,D,Q).bind(this)),pe(this,P).on("scrollY",Se(this,D,U).bind(this)),pe(this,P).on("resize",Se(this,D,$).bind(this)),pe(this,P).on("doubleClick",Se(this,D,V).bind(this)),pe(this,P).on("contextMenu",Se(this,D,X).bind(this)),pe(this,T).on("load",(()=>{pe(this,W).trigger("loadResource")}))},Y=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.pointStart)?void 0:t.call(o,e)))return}},B=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.pointEnd)?void 0:t.call(o,e)))return}},F=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.pointMove)?void 0:t.call(o,e)))return}},G=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.pointLeave)?void 0:t.call(o,e)))return}},N=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.hover)?void 0:t.call(o,e)))return}},V=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.doubleClick)?void 0:t.call(o,e)))return}},X=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.contextMenu)?void 0:t.call(o,e)))return}},H=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.wheel)?void 0:t.call(o,e)))return}},Z=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.wheelScale)?void 0:t.call(o,e)))return}},Q=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.scrollX)?void 0:t.call(o,e)))return}},U=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.scrollY)?void 0:t.call(o,e)))return}},$=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.resize)?void 0:t.call(o,e)))return}},J=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.clear)?void 0:t.call(o,e)))return}},K=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.beforeDrawFrame)?void 0:t.call(o,e)))return}},q=function(e){var t;for(let i=0;i<pe(this,C).length;i++){const o=pe(this,C)[i];if(!1===(null==(t=null==o?void 0:o.afterDrawFrame)?void 0:t.call(o,e)))return}},_=function(){const e=[],t=pe(this,R);pe(this,z).forEach((i=>{const o=t.get(i);"enable"===(null==o?void 0:o.status)&&(null==o?void 0:o.middlewareObject)&&e.push(o.middlewareObject)})),xe(this,C,e)};const $i="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAs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0cxs6qC1O4T0xMfKYnb21tnXEDNjc3z+nXbW1t3wFvYz9dCAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==",Ji="selectInGroup",Ki={CURSOR:"cursor",CHANGE:"change",RULER:"ruler",SCALE:"scale",SELECT_LAYOUT:"selectLayout",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:Ji,SNAP_TO_GRID:Ji},qi={};Object.keys(Ki).forEach((e=>{Object.defineProperty(qi,e,{value:Ki[e],writable:!1})}));class _i{constructor(e,t){we(this,ae),we(this,ee),we(this,te),we(this,ie,null),we(this,oe,null),we(this,ne,{auto:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzk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PmXb9+vXp6ejzgx5J+ZiGeLSk8GaD34ky5Hd23JP1I0h8kPQmGu7y8/L/aNEUiEe3fv1/Dw8Pp6Es6KqlZ0puSXpHbVU4KiPVglqQFkr4j6aeSfi/pvq/13r172rVrlyorK6cFFo1GtXnzZl25ciU4Ch5J+qOkH0v6tqTXzDk5EwGGlNFjOWQOd8px4vUN4E3cpn2pz/jgwQPef/99Ll68yJ07d+jt7WVwcJBIJEJJSQlz586loaGBTZs2UVdXF5w0OoDLwFWcbPsct6r04+bRLHEYCoWyAD1kBDfHleHmsxrccccS3NFHNV/eenBy6iZwCycMOnHz5wBuDh2nyyY6H0zhFmoF7vtxk+l9q3ieQfrDo8msF7cy3cN56g7ZWnKcep7IxnrQmz+wHKu2K3EKJWbPpWSUTQ4ZtRJc23sC6ZGB9ZM52JwcboIQjzUvZvNxYfeHlyVkZFcBbux6wKA6ShjoM5yM8uH0Xpuy8ekAQuZc2W8P8nEei9p9mMmPgAfJHO0O27e0lHppw9MEDJo//A4eoE91iB48SJ80lFMB/t/+V/sPGZfTmtMFR4EAAAAASUVORK5CYII="}),xe(this,te,e),xe(this,ee,t.eventHub),Se(this,ae,re).call(this),Se(this,ae,le).call(this)}}ee=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap,ne=new WeakMap,ae=new WeakSet,re=function(){const e=pe(this,ee);Se(this,ae,se).call(this,"default"),e.on(qi.CURSOR,(e=>{var t;"over-element"!==e.type&&e.type?"resize-rotate"===e.type?Se(this,ae,se).call(this,"rotate"):"string"==typeof e.type&&(null==(t=e.type)?void 0:t.startsWith("resize-"))?Se(this,ae,he).call(this,e):"drag-default"===e.type?Se(this,ae,se).call(this,"drag-default"):"drag-active"===e.type?Se(this,ae,se).call(this,"drag-active"):Se(this,ae,se).call(this,"auto"):Se(this,ae,se).call(this,"auto")}))},le=function(){ke($i).then((e=>{xe(this,oe,e)})).catch((e=>{console.error(e)}))},se=function(e){if(pe(this,ie)===e)return;xe(this,ie,e);const t=pe(this,ne)[pe(this,ie)]||pe(this,ne).auto;let i=0,o=0;(e.startsWith("rotate-")&&pe(this,ne)[pe(this,ie)]||"rotate"===e)&&(i=10,o=10),pe(this,te).style.cursor="default"===e?"default":`image-set(url(${t})2x) ${i} ${o}, auto`},he=function(e){var t;let i=0;"resize-top"===e.type?i+=0:"resize-top-right"===e.type?i+=45:"resize-right"===e.type?i+=90:"resize-bottom-right"===e.type?i+=135:"resize-bottom"===e.type?i+=180:"resize-bottom-left"===e.type?i+=225:"resize-left"===e.type?i+=270:"resize-top-left"===e.type&&(i+=315),i+=pt((null==(t=null==e?void 0:e.element)?void 0:t.angle)||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach((e=>{i+=pt(e.angle||0)})),i=pt(i);const o=Se(this,ae,ce).call(this,i);Se(this,ae,se).call(this,o)},ce=function(e){const t=`rotate-${e}`;if(!pe(this,ne)[t]){const i=pe(this,oe);if(i){const o=document.createElement("canvas"),n=i.width,a=i.height,r={x:n/2,y:a/2};o.width=n,o.height=a;const l=o.getContext("2d"),s=lt(e);l.translate(r.x,r.y),l.rotate(s),l.translate(-r.x,-r.y),l.drawImage(i,0,0,n,a),l.translate(r.x,r.y),l.rotate(-s),l.translate(-r.x,-r.y);const h=o.toDataURL("image/png");pe(this,ne)[t]=h}}return t};const eo="SELECT",to=Symbol(`${eo}_actionType`),io=Symbol(`${eo}_resizeType`),oo=Symbol(`${eo}_areaStart`),no=Symbol(`${eo}_areaEnd`),ao=Symbol(`${eo}_hoverElement`),ro=Symbol(`${eo}_hoverElementVertexes`),lo=Symbol(`${eo}_selectedElementList`),so=Symbol(`${eo}_selectedElementListVertexes`),ho=Symbol(`${eo}_selectedElementController`),co=Symbol(`${eo}_selectedElementPosition`),uo=Symbol(`${eo}_groupQueue`),fo=Symbol(`${eo}_groupQueueVertexesList`),go=Symbol(`${eo}_isMoving`),vo=Symbol(`${eo}_enableSelectInGroup`),mo=Symbol(`${eo}_enableSnapToGrid`),yo={activeColor:"#1973ba",activeAreaColor:"#1976d21c",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function po(e,t,i){const{borderColor:o,borderWidth:n,background:a,lineDash:r}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.fillStyle=a,e.setLineDash(r),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.lineTo(t[0].x,t[0].y),e.closePath(),e.stroke(),e.fill()}function wo(e,t,i,o){const{borderColor:n,borderWidth:a,lineDash:r}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=n,e.setLineDash(r),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function xo(e,t,i){const{borderColor:o,borderWidth:n,lineDash:a}=i;e.setLineDash([]),e.lineWidth=n,e.strokeStyle=o,e.setLineDash(a),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[2].x,t[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(t[1].x,t[1].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function So(e,t,i){const{size:o,borderColor:n,borderWidth:a,lineDash:r}=i,l=t.x-o/2,s=t.x+o/2,h=t.y-o/2,c=t.y+o/2;xo(e,[{x:l,y:h},{x:s,y:h},{x:s,y:c},{x:l,y:c}],{borderColor:n,borderWidth:a,lineDash:r})}function bo(e,t,i){if(!t)return;const{style:o}=i,{activeColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};po(e,Et(t,i),a)}function Ao(e,t,i){if(!t)return;const{style:o}=i,{lockedColor:n}=o,a={borderColor:n,borderWidth:1,background:"transparent",lineDash:[]};po(e,Et(t,i),a);const{controller:r}=i;if(r){const{topLeft:t,topRight:o,bottomLeft:n,bottomRight:l,topMiddle:s,bottomMiddle:h,leftMiddle:c,rightMiddle:d}=r,u={...a,borderWidth:1};xo(e,Et(s.vertexes,i),u),xo(e,Et(h.vertexes,i),u),xo(e,Et(c.vertexes,i),u),xo(e,Et(d.vertexes,i),u),xo(e,Et(t.vertexes,i),u),xo(e,Et(o.vertexes,i),u),xo(e,Et(n.vertexes,i),u),xo(e,Et(l.vertexes,i),u)}}function Io(e,t,i){var o;if(!t)return;const{hideControllers:n,style:a,rotateControllerPattern:r,viewSizeInfo:l,element:s}=i,{devicePixelRatio:h=1}=l,{activeColor:c}=a,{elementWrapper:d,topLeft:u,topRight:f,bottomLeft:g,bottomRight:v,rotate:m}=t,y={borderColor:c,borderWidth:2,background:"transparent",lineDash:[]},p={...y,borderWidth:4,background:"#FFFFFF"};if(po(e,Et(d,i),y),!n&&(po(e,Et(u.vertexes,i),p),po(e,Et(f.vertexes,i),p),po(e,Et(g.vertexes,i),p),po(e,Et(v.vertexes,i),p),!1!==(null==(o=null==s?void 0:s.operations)?void 0:o.rotatable))){!function(e,t,i){const{size:o,background:n}=i,a=t,r=o/2,l=r,s=r;l>=0&&s>=0&&(e.beginPath(),e.fillStyle=n,e.circle(a.x,a.y,l,s,0,0,2*Math.PI),e.closePath(),e.fill())}(e,Tt(m.center,i),{...p,size:m.size});const t=Tt(m.center,i);e.drawImage(r.canvas,0,0,r.canvas.width/h,r.canvas.height/h,t.x-m.size/2,t.y-m.size/2,m.size,m.size)}}function Mo(e,t){const{xLines:i,yLines:o,style:n}=t,{referenceColor:a}=n,r={borderColor:a,borderWidth:1,lineDash:[]},l={...r,size:6};i&&i.forEach((t=>{t.forEach(((i,o)=>{So(e,i,l),t[o+1]&&wo(e,t[o],t[o+1],r)}))})),o&&o.forEach((t=>{t.forEach(((i,o)=>{So(e,i,l),t[o+1]&&wo(e,t[o],t[o+1],r)}))}))}function Ro(e){return e*Math.PI/180}function zo(e,t){return Math.sqrt(e*e+t*t)}function Co(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Po(e,t){const{ctx:i,viewScaleInfo:o,vertexes:n}=t,a=Tt(n[0],{viewScaleInfo:o}),r=Tt(n[1],{viewScaleInfo:o}),l=Tt(n[2],{viewScaleInfo:o}),s=Tt(n[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(r.x,r.y),i.lineTo(l.x,l.y),i.lineTo(s.x,s.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function To(e,t){const{ctx:i,viewScaleInfo:o,viewSizeInfo:n,groupQueue:a}=t;if(!(a&&(null==a?void 0:a.length)>0))return!1;const r=zt(a),l=r[r.length-1];return!!l&&Po(e,{ctx:i,vertexes:l,viewScaleInfo:o})}function Eo(e,t){var i,o,n,a,r;const l={type:null,elements:[],elementVertexesList:[],groupQueue:[],groupQueueVertexesList:[]},{ctx:s,data:h,calculator:c,selectedElements:d,viewScaleInfo:u,viewSizeInfo:f,areaSize:g,groupQueue:v,selectedElementController:m}=t;if(m){const{left:t,right:n,top:a,bottom:r,topLeft:h,topRight:c,bottomLeft:f,bottomRight:g,rotate:y}=m,p=[t,n,a,r,h,c,f,g];1===(null==d?void 0:d.length)&&!1!==(null==(o=null==(i=null==d?void 0:d[0])?void 0:i.operations)?void 0:o.rotatable)&&p.push(y);for(let t=0;t<p.length;t++){const i=p[t];if(Po(e,{ctx:s,vertexes:i.vertexes,viewScaleInfo:u})){l.type=`resize-${i.type}`,d&&(null==d?void 0:d.length)>0&&(l.groupQueue=v||[],l.elements=[d[0]]);break}}}if(v&&Array.isArray(v)&&v.length>0){const t=v[v.length-1];if((null==(n=null==t?void 0:t.detail)?void 0:n.children)&&Array.isArray(null==(a=null==t?void 0:t.detail)?void 0:a.children))for(let i=t.detail.children.length-1;i>=0;i--){const o=t.detail.children[i],n=Ct(o,{groupQueue:v});if(n&&Po(e,{ctx:s,vertexes:n,viewScaleInfo:u}))return l.type||(l.type="over-element"),l.groupQueue=v,l.elements=[o],l}return l}if(null!==l.type)return l;if(g&&Array.isArray(d)&&(null==d?void 0:d.length)>1){const{x:t,y:i,w:o,h:n}=g;if(e.x>=t&&e.x<=t+o&&e.y>=i&&e.y<=i+n)return l.type="list-area",l.elements=d,l}if(h){const{index:t,element:i}=c.getPointElement(e,{data:h,viewScaleInfo:u,viewSizeInfo:f});if(t>=0&&i&&!0!==(null==(r=null==i?void 0:i.operations)?void 0:r.invisible))return l.elements=[i],l.type="over-element",l}return l}function ko(e,t){const{x:i,y:o,w:n,h:a,angle:r=0}=e,{center:l,start:s,end:h,viewScaleInfo:c}=t,d=Tt(l,{viewScaleInfo:c}),u=pt(r),f=function(e,t,i){const o=ut(e,t),n=ut(e,i);return null!==n&&null!==o?n-o:0}(d,s,h);return{x:i,y:o,w:n,h:a,angle:pt(u+f/Math.PI*180)}}function Lo(e,t){var i;if(!Array.isArray(e))return null;const o={x:0,y:0,w:0,h:0},{viewScaleInfo:n}=t;let a=null;for(let t=0;t<e.length;t++){const r=e[t];if(null==(i=null==r?void 0:r.operations)?void 0:i.invisible)continue;const l=Pt(r,{viewScaleInfo:n});if(l.angle&&(l.angle>0||l.angle<0)){const e=mt(l);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];l.x=Math.min(...t),l.y=Math.min(...i),l.w=Math.abs(Math.max(...t)-Math.min(...t)),l.h=Math.abs(Math.max(...i)-Math.min(...i))}}if(a){const e=Math.min(l.x,o.x),t=Math.min(l.y,o.y),i=Math.max(l.x+l.w,o.x+o.w),n=Math.max(l.y+l.h,o.y+o.h);o.x=e,o.y=t,o.w=Math.abs(i-e),o.h=Math.abs(n-t)}else o.x=l.x,o.y=l.y,o.w=l.w,o.h=l.h;a=l}return o}function Wo(e){return{minX:e.topLeft.x,minY:e.topLeft.y,maxX:e.bottomRight.x,maxY:e.bottomRight.y,midX:e.center.x,midY:e.center.y}}const Oo=(e,t)=>{if(0===e.length)throw null;if(1===e.length)return e[0];let i=0,o=e.length-1;for(;i<=o;){const n=Math.floor((i+o)/2);if(e[n]===t)return e[n];e[n]<t?i=n+1:o=n-1}return i>=e.length?e[o]:o<0?e[i]:Math.abs(e[o]-t)<=Math.abs(e[i]-t)?e[o]:e[i]},Do=(e,t)=>Math.abs(e-t)<1e-5;function jo(e,t){var i,o;const{data:n,groupQueue:a,calculator:r,viewScaleInfo:l,viewSizeInfo:s}=t;let h=n.elements||[];(null==a?void 0:a.length)>0&&(h=(null==(o=null==(i=a[a.length-1])?void 0:i.detail)?void 0:o.children)||[]);const c=[];h.forEach((t=>{if(t.uuid!==e){const e=r.calcViewRectInfoFromRange(t.uuid,{checkVisible:!0,viewScaleInfo:l,viewSizeInfo:s});e&&c.push(e)}}));const d=r.calcViewRectInfoFromRange(e,{viewScaleInfo:l,viewSizeInfo:s});if(!d)return null;const u={},f={},g=[],v=[];let m=[],y=[];const p=Wo(d);c.forEach((e=>{const t=Wo(e);u[t.minX]||(u[t.minX]=[]),u[t.midX]||(u[t.midX]=[]),u[t.maxX]||(u[t.maxX]=[]),f[t.minY]||(f[t.minY]=[]),f[t.midY]||(f[t.midY]=[]),f[t.maxY]||(f[t.maxY]=[]),u[t.minX]=[t.minY,t.midY,t.maxY],u[t.midX]=[t.minY,t.midY,t.maxY],u[t.maxX]=[t.minY,t.midY,t.maxY],m.push(t.minX),m.push(t.midX),m.push(t.maxX),f[t.minY]=[t.minX,t.midX,t.maxX],f[t.midY]=[t.minX,t.midX,t.maxX],f[t.maxY]=[t.minX,t.midX,t.maxX],y.push(t.minY),y.push(t.midY),y.push(t.maxY)})),m=m.sort(((e,t)=>e-t)),y=y.sort(((e,t)=>e-t));let w=null,x=null,S=null,b=null,A=null,I=null,M=null,R=null;if(m.length>0){S=Oo(m,p.minX),b=Oo(m,p.midX),A=Oo(m,p.maxX);const e=Math.abs(S-p.minX),t=Math.abs(b-p.midX),i=Math.abs(A-p.maxX),o=Math.min(e,t,i);o<=2/l.scale&&(Do(o,e)?w=S-p.minX:Do(o,t)?w=b-p.midX:Do(o,i)&&(w=A-p.maxX))}if(y.length>0){I=Oo(y,p.minY),M=Oo(y,p.midY),R=Oo(y,p.maxY);const e=Math.abs(I-p.minY),t=Math.abs(M-p.midY),i=Math.abs(R-p.maxY),o=Math.min(e,t,i);o<=2/l.scale&&(Do(o,e)?x=I-p.minY:Do(o,t)?x=M-p.midY:Do(o,i)&&(x=R-p.maxY))}const z={...p};if(null!==w&&(z.minX+=w,z.midX+=w,z.maxX+=w),null!==x&&(z.minY+=x,z.midY+=x,z.maxY+=x),Be.x(w)&&null!==w&&null!==S&&null!==b&&null!==A){if(Do(w,S-p.minX)){const e={x:S,yList:[]};e.yList.push(z.minY),e.yList.push(z.maxY),e.yList.push(...(null==f?void 0:f[S])||[]),g.push(e)}if(Do(w,b-p.minX)){const e={x:b,yList:[]};e.yList.push(z.minY),e.yList.push(z.maxY),e.yList.push(...(null==f?void 0:f[b])||[]),g.push(e)}if(Do(w,A-p.minX)){const e={x:A,yList:[]};e.yList.push(z.minY),e.yList.push(z.maxY),e.yList.push(...(null==f?void 0:f[A])||[]),g.push(e)}}if(Be.y(x)&&null!==x&&null!==I&&null!==M&&null!==R){if(Do(x,I-p.minY)){const e={y:I,xList:[]};e.xList.push(z.minX),e.xList.push(z.maxX),e.xList.push(...(null==u?void 0:u[I])||[]),v.push(e)}if(Do(x,M-p.midY)){const e={y:M,xList:[]};e.xList.push(z.minX),e.xList.push(z.maxX),e.xList.push(...(null==u?void 0:u[I])||[]),v.push(e)}if(Do(x,R-p.maxY)){const e={y:R,xList:[]};e.xList.push(z.minX),e.xList.push(z.maxX),e.xList.push(...(null==u?void 0:u[R])||[]),v.push(e)}}const C=[];(null==g?void 0:g.length)>0&&g.forEach(((e,t)=>{C.push([]),e.yList.forEach((i=>{C[t].push({x:e.x,y:i})}))}));const P=[];return(null==v?void 0:v.length)>0&&v.forEach(((e,t)=>{P.push([]),e.xList.forEach((i=>{P[t].push({x:i,y:e.y})}))})),{offsetX:w,offsetY:x,yLines:C,xLines:P}}const Yo="LAYOUT_SELECT",Bo=Symbol(`${Yo}_layoutActionType`),Fo=Symbol(`${Yo}_layoutControlType`),Go=Symbol(`${Yo}_layoutController`),No=Symbol(`${Yo}_layoutIsHoverContent`),Vo=Symbol(`${Yo}_layoutIsHoverController`),Xo=Symbol(`${Yo}_layoutIsSelected`),Ho=Symbol(`${Yo}_layoutIsSelected`),Zo={activeColor:"#b331c9"};function Qo(e,t,i){const{activeColor:o}=i;e.setLineDash([]),e.fillStyle="#FFFFFF",e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.fill(),e.strokeStyle=o,e.lineWidth=2,e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[1].x,t[1].y),e.lineTo(t[2].x,t[2].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}function Uo(e,t){const{start:i,end:o,style:n}=t,{activeColor:a}=n,r=a;e.setLineDash([]),e.strokeStyle=r,e.lineWidth=2,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.closePath(),e.stroke()}function $o(e){const{fill:t,devicePixelRatio:i}=e,o=(e=>({uuid:Ie(),type:"path",x:0,y:0,w:200,h:200,detail:{commands:[{type:"M",params:[512,0]},{type:"c",params:[282.8,0,512,229.2,512,512]},{type:"s",params:[-229.2,512,-512,512]},{type:"S",params:[0,794.8,0,512,229.2,0,512,0]},{type:"z",params:[]},{type:"m",params:[309.8,253.8]},{type:"c",params:[0,-10.5,-6.5,-19.8,-15.7,-23.8,-9.7,-4,-21,-2,-28.2,5.6]},{type:"l",params:[-52.5,52]},{type:"c",params:[-56.9,-53.7,-133.9,-85.5,-213.4,-85.5,-170.7,0,-309.8,139.2,-309.8,309.8,0,170.6,139.2,309.8,309.8,309.8,92.4,0,179.5,-40.8,238.4,-111.8,4,-5.2,4,-12.9,-.8,-17.3]},{type:"L",params:[694.3,637]},{type:"c",params:[-2.8,-2.4,-6.5,-3.6,-10.1,-3.6,-3.6,.4,-7.3,2,-9.3,4.8,-39.5,51.2,-98.8,80.3,-163,80.3,-113.8,0,-206.5,-92.8,-206.5,-206.5,0,-113.8,92.8,-206.5,206.5,-206.5,52.8,0,102.9,20.2,140.8,55.3]},{type:"L",params:[597,416.5]},{type:"c",params:[-7.7,7.3,-9.7,18.6,-5.6,27.9,4,9.7,13.3,16.1,23.8,16.1]},{type:"H",params:[796]},{type:"c",params:[14.1,0,25.8,-11.7,25.8,-25.8]},{type:"V",params:[253.8]},{type:"z",params:[]}],fill:"#2c2c2c",stroke:"transparent",strokeWidth:0,originX:0,originY:0,originW:1024,originH:1024,opacity:1,...e}}))({fill:t}),{w:n,h:a}=o,r=He({width:n,height:a,devicePixelRatio:i});return oi(r,o,{loader:void 0,viewScaleInfo:{scale:1,offsetTop:0,offsetBottom:0,offsetLeft:0,offsetRight:0},viewSizeInfo:{width:n,height:a,devicePixelRatio:i,contextWidth:n,contextHeight:a},parentElementSize:{x:0,y:0,w:n,h:a},parentOpacity:1}),{context2d:r,fill:t}}const Jo="monospace";const Ko="@middleware/internal-event/show-info-angle",qo={textBackground:"#1973bac6",textColor:"#ffffff"},_o=10,en="SCROLL",tn=Symbol(`${en}_xThumbRect`),on=Symbol(`${en}_yThumbRect`),nn=Symbol(`${en}_hoverXThumbRect`),an=Symbol(`${en}_hoverYThumbRect`),rn=Symbol(`${en}_prevPoint`),ln=Symbol(`${en}_activePoint`),sn=Symbol(`${en}_activeThumbType`),hn={thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"};function cn(e,t,i){const o=e,{x:n,y:a,w:r,h:l}=i;return o.beginPath(),o.rect(n,a,r,l),o.closePath(),!!o.isPointInPath(t.x,t.y)}function dn(e,t){let{x:i,y:o,h:n,w:a}=t;const{background:r,borderColor:l}=t;e.save(),e.shadowColor="#FFFFFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=1;{const{axis:s}=t;"X"===s?(o=o+n/4+0,n/=2):"Y"===s&&(i=i+a/4+0,a/=2);let h=t.r;h=Math.min(h,a/2,n/2),(a<2*h||n<2*h)&&(h=0),e.globalAlpha=1,e.beginPath(),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.fillStyle=r,e.fill(),e.beginPath(),e.lineWidth=1,e.strokeStyle=l,e.setLineDash([]),e.moveTo(i+h,o),e.arcTo(i+a,o,i+a,o+n,h),e.arcTo(i+a,o+n,i,o+n,h),e.arcTo(i,o+n,i,o,h),e.arcTo(i,o,i+a,o,h),e.closePath(),e.stroke()}e.restore()}function un(e,t){const i=e,{viewScaleInfo:o,viewSizeInfo:n,scrollInfo:a,style:r}=t,{activeThumbType:l,prevPoint:s,activePoint:h,hoverXThumb:c,hoverYThumb:d}=a,u=function(e){const{viewScaleInfo:t,viewSizeInfo:i,hoverXThumb:o,hoverYThumb:n,style:a}=e,{width:r,height:l}=i,{offsetTop:s,offsetBottom:h,offsetLeft:c,offsetRight:d}=t,u=16,{thumbBackground:f,thumbBorderColor:g,hoverThumbBackground:v,hoverThumbBorderColor:m}=a;let y=0,p=0;y=Math.max(40,r-32-(Math.abs(c)+Math.abs(d))),y>=r&&(y=r),p=Math.max(40,l-32-(Math.abs(s)+Math.abs(h))),p>=l&&(p=l);let w=16;c>0?w=16:d>0?w=r-y-u:c<=0&&y>0&&(0!==c||0!==d)&&(w=16+(r-y)*Math.abs(c)/(Math.abs(c)+Math.abs(d)),w=Math.min(Math.max(0,w-16),r-y));let x=16;return s>0?x=16:h>0?x=l-p-u:s<=0&&p>0&&(0!==s||0!==h)&&(x=16+(l-p)*Math.abs(s)/(Math.abs(s)+Math.abs(h)),x=Math.min(Math.max(0,x-16),l-p)),{lineSize:u,xSize:y,ySize:p,translateY:x,translateX:w,xThumbBackground:o?v:f,yThumbBackground:n?v:f,xThumbBorderColor:o?m:g,yThumbBorderColor:n?m:g,xThumbRect:{x:w,y:l-u,w:y,h:u},yThumbRect:{x:r-u,y:x,w:u,h:p}}}({viewScaleInfo:o,viewSizeInfo:n,hoverXThumb:c,hoverYThumb:d,style:r});let f={...u.xThumbRect},g={...u.yThumbRect};return l&&s&&h&&("X"===l&&a.xThumbRect?(f={...a.xThumbRect},f.x=f.x+(h.x-s.x)):"Y"===l&&a.yThumbRect&&(g={...a.yThumbRect},g.y=g.y+(h.y-s.y))),dn(i,{axis:"X",...f,r:u.lineSize/2,background:u.xThumbBackground,borderColor:u.xThumbBorderColor}),dn(i,{axis:"Y",...g,r:u.lineSize/2,background:u.yThumbBackground,borderColor:u.yThumbBorderColor}),{xThumbRect:f,yThumbRect:g}}function fn(e,t){const{snapshot:i,style:o}=t,n=rt(i),a=at(i),r=function(e){const{sharedStore:t}=e;return{activePoint:t[ln]||null,prevPoint:t[rn]||null,activeThumbType:t[sn]||null,xThumbRect:t[tn]||null,yThumbRect:t[on]||null,hoverXThumb:t[nn],hoverYThumb:t[an]}}(i),{xThumbRect:l,yThumbRect:s}=un(e,{viewSizeInfo:n,viewScaleInfo:a,scrollInfo:r,style:o});return{xThumbRect:l,yThumbRect:s}}const gn=16,vn="monospace",mn={background:"#FFFFFFA8",borderColor:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#196097"},yn=[1,2,5,10,20,50,100,200,500];function pn(e){const{scale:t,viewLength:i,viewOffset:o}=e,n=[];let a=10;a=Ft(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(yn[0],Math.min(e,yn[yn.length-1]));for(let t=0;t<yn.length-1;t++){const i=yn[t],o=yn[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const r=10*a,l=5*a;let s=0;const h=a*t,c=0-o,d=c%h,u=(c-d+h)/t,f=h-d+0;for(;f+s*h<i;){const e=Ft(u+s*a,{decimalPlaces:0}),t={num:e,position:Ft(f+s*h,{decimalPlaces:0}),showNum:e%r==0,isKeyNum:e%r==0,isSubKeyNum:e%l==0};n.push(t),s++}return{list:n,rulerUnit:a}}const wn={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,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"},xn=Symbol("DRAG_prevPoint");return de=new WeakMap,ue=new WeakMap,fe=new WeakMap,ge=new WeakSet,ve=function(){pe(this,fe).style.position="relative"},e.Board=Ui,e.Calculator=ki,e.Core=class{constructor(e,t){we(this,ge),we(this,de),we(this,ue),we(this,fe);const{devicePixelRatio:i=1,width:o,height:n}=t;xe(this,fe,e);const a=document.createElement("canvas");a.setAttribute("tabindex","0"),xe(this,ue,a),Se(this,ge,ve).call(this),e.appendChild(a);const r=Ze(a,{width:o,height:n,devicePixelRatio:i}),l=new Ui({boardContent:r,container:e}),s=l.getSharer();s.setActiveViewSizeInfo({width:o,height:n,devicePixelRatio:i,contextWidth:o,contextHeight:n}),xe(this,de,l),this.resize(s.getActiveViewSizeInfo());const h=l.getEventHub();new _i(e,{eventHub:h})}isDestroyed(){return pe(this,de).isDestroyed()}destroy(){pe(this,de).destroy(),pe(this,ue).remove()}use(e,t){pe(this,de).use(e,t)}disuse(e){pe(this,de).disuse(e)}resetMiddlewareConfig(e,t){pe(this,de).resetMiddlewareConfig(e,t)}setData(e,t){wt((null==e?void 0:e.elements)||[]),pe(this,de).setData(e,t)}getData(){return pe(this,de).getData()}scale(e){pe(this,de).scale(e);pe(this,de).getViewer().drawFrame()}resize(e){const t=pe(this,de),i=t.getSharer().getActiveViewSizeInfo();t.resize({...i,...e})}clear(){pe(this,de).clear()}on(e,t){pe(this,de).getEventHub().on(e,t)}off(e,t){pe(this,de).getEventHub().off(e,t)}trigger(e,t){pe(this,de).getEventHub().trigger(e,t)}getViewInfo(){const e=pe(this,de).getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){pe(this,de).getViewer().drawFrame()}setViewScale(e){pe(this,de).updateViewScaleInfo(e)}getLoadItemMap(){return pe(this,de).getRenderer().getLoadItemMap()}onBoardWatcherEvents(){pe(this,de).onWatcherEvents()}offBoardWatcherEvents(){pe(this,de).offWatcherEvents()}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:o}=e;let n=!1;return{name:"@middleware/dragger",hover(){!0!==n&&t.trigger(qi.CURSOR,{type:"drag-default"})},pointStart(e){const{point:o}=e;i.setSharedStorage(xn,o),n=!0,t.trigger(qi.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,n=i.getSharedStorage(xn);if(t&&n){const e=t.x-n.x,i=t.y-n.y;o.scroll({moveX:e,moveY:i}),o.drawFrame()}i.setSharedStorage(xn,t)},pointEnd(){n=!1,i.setSharedStorage(xn,null),t.trigger(qi.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o,eventHub:n}=e,{overlayContext:a}=i;let r={...qo,...t},l=!0;const s=({show:e})=>{l=e};return{name:"@middleware/info",use(){n.on(Ko,s)},disuse(){n.off(Ko,s)},resetConfig(e){r={...r,...e}},beforeDrawFrame({snapshot:e}){var t;const{textBackground:i,textColor:n}=r,s={textBackground:i,textColor:n},{sharedStore:h}=e,c=h[lo],d=h[to],u=h[uo]||[];if(1===c.length){const i=c[0];if(i&&["select","drag","resize"].includes(d)){const n=at(e),r=rt(e),{x:h,y:c,w:d,h:f,angle:g}=i,v=[...u,{uuid:Ie(),x:h,y:c,w:d,h:f,angle:g,type:"group",detail:{children:[]}}],m={viewScaleInfo:n,viewSizeInfo:r},y=o.calcViewRectInfoFromOrigin(i.uuid,m);let p=0;v.forEach((e=>{p+=e.angle||0}));const w=lt(pt(0-p));if(y){const e=null==y?void 0:y.center,o={topLeft:ft(e,y.topLeft,w),topRight:ft(e,y.topRight,w),bottomRight:ft(e,y.bottomRight,w),bottomLeft:ft(e,y.bottomLeft,w),center:ft(e,y.center,w),top:ft(e,y.top,w),right:ft(e,y.right,w),bottom:ft(e,y.bottom,w),left:ft(e,y.left,w)},n=Ft(i.x,{decimalPlaces:2}),r=Ft(i.y,{decimalPlaces:2}),h=Ft(i.w,{decimalPlaces:2}),c=Ft(i.h,{decimalPlaces:2}),d=`${Ft(n,{decimalPlaces:0})},${Ft(r,{decimalPlaces:0})}`,u=`${Ft(h,{decimalPlaces:0})}x${Ft(c,{decimalPlaces:0})}`,f=`${Ft(i.angle||0,{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textColor:h,textBackground:c}=r;st(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:Jo});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x-o/2-t,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=h,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(a,{point:{x:o.bottom.x,y:o.bottom.y+_o},rotateCenter:o.center,angle:p,text:u,fontSize:_o,lineHeight:16,style:s}),function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;st(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:Jo});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(a,{point:{x:o.topLeft.x,y:o.topLeft.y-20},rotateCenter:o.center,angle:p,text:d,fontSize:_o,lineHeight:16,style:s}),l&&!1!==(null==(t=i.operations)?void 0:t.rotatable)&&function(e,t){const{point:i,rotateCenter:o,angle:n,text:a,style:r,fontSize:l,lineHeight:s}=t,{textBackground:h,textColor:c}=r;st(e,n,o,(()=>{e.$setFont({fontWeight:"300",fontSize:l,fontFamily:Jo});const t=(s-l)/2,o=e.$undoPixelRatio(e.measureText(a).width),n={x:i.x,y:i.y},r={x:n.x+o+2*t,y:n.y+l+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,n.y),e.lineTo(r.x,r.y),e.lineTo(n.x,r.y),e.closePath(),e.fill(),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)}))}(a,{point:{x:o.top.x+_o+4,y:o.top.y-20-18},rotateCenter:o.center,angle:p,text:f,fontSize:_o,lineHeight:16,style:s})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,boardContent:o,calculator:n,viewer:a,eventHub:r}=e,{overlayContext:l}=o;let s={...Zo,...t},h=null,c=null,d=null;const u=()=>{h=null,i.setSharedStorage(Bo,null),i.setSharedStorage(Fo,null),i.setSharedStorage(Go,null),i.setSharedStorage(No,null),i.setSharedStorage(Vo,null),i.setSharedStorage(Xo,null),i.setSharedStorage(Ho,null),c=null,d=null},f=()=>{const e=i.getSharedStorage(to);return!(!e||"area"===e)&&(u(),!0)},g=()=>{const e=i.getActiveStorage("data");if(null==e?void 0:e.layout){const{x:t,y:i,w:o,h:n}=e.layout;return{x:t,y:i,w:o,h:n}}return null},v=e=>{const t=g();if(t){const{x:o,y:n,w:a,h:r}=t;return function(e,t){return Lt(e,Rt(t))}(e,Pt({x:o-5,y:n-5,w:a+10,h:r+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},m=()=>{const e=i.getActiveViewScaleInfo(),t=g();if(t){const o=Yt(t,{viewScaleInfo:e,controllerSize:10});i.setSharedStorage(Go,o)}else i.setSharedStorage(Go,null)},y=e=>{const t=i.getActiveStorage("data"),o=i.getSharedStorage(Go);let n=null;if(o&&(null==t?void 0:t.layout)&&(null==e?void 0:e.point)){let t=null;if(o){const{topLeft:a,top:l,topRight:s,right:h,bottomRight:c,bottom:d,bottomLeft:u,left:f}=o,g=[a,l,s,h,c,d,u,f];for(let i=0;i<g.length;i++){const o=g[i];if(Lt(e.point,o.vertexes)){t=`${o.type}`;break}}t&&(i.setSharedStorage(Fo,t),r.trigger(qi.CLEAR_SELECT),n=t)}}return n?i.setSharedStorage(Vo,!0):i.setSharedStorage(Vo,!1),n},p=e=>{!0!==i.getSharedStorage(Ho)&&r.trigger(qi.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],element:g()})};return{name:"@middleware/layout-selector",use:()=>{u(),m()},resetConfig(e){s={...s,...e}},hover:e=>{if(!0!==i.getSharedStorage(Ho)&&!f()){if(v(e.point)?i.setSharedStorage(No,!0):(i.setSharedStorage(No,!1),!0===c&&(a.drawFrame(),c=!1)),!0===i.getSharedStorage(Xo)){const t=i.getSharedStorage(Bo),o=i.getActiveStorage("data");if(null==o?void 0:o.layout)if("resize"!==t){m();const t=y(e);t?p(t):(p(),i.setSharedStorage(Bo,null))}else{const t=y(e);p(t)}return!0!==i.getSharedStorage(Vo)&&void 0}return i.getSharedStorage(No)&&!c&&a.drawFrame(),c=i.getSharedStorage(No),!0!==i.getSharedStorage(Vo)&&void 0}},pointStart:e=>{if(f())return;v(e.point)?i.setSharedStorage(Xo,!0):(!0===d&&(u(),a.drawFrame()),i.setSharedStorage(Xo,!1)),m();const t=y(e);return h=e.point,t&&i.setSharedStorage(Bo,"resize"),!0!==i.getSharedStorage(Xo)||d||(a.drawFrame(),r.trigger(qi.SELECT_LAYOUT)),d=i.getSharedStorage(Xo),!0!==i.getSharedStorage(Vo)&&void 0},pointMove:e=>{if(!i.getSharedStorage(Xo)&&f())return;const t=i.getSharedStorage(Bo),o=i.getSharedStorage(Fo),r=i.getActiveStorage("data");if("resize"===t&&o&&(null==r?void 0:r.layout)){if(h){i.setSharedStorage(Ho,!0);const t=i.getActiveStorage("scale"),l=e.point.x-h.x,s=e.point.y-h.y,c=l/t,d=s/t,{x:u,y:f,w:g,h:v,operations:m={}}=r.layout,{position:y="absolute"}=m;"top"===o?"relative"===y?(r.layout.h=n.toGridNum(v-d),a.scroll({moveY:s})):(r.layout.y=n.toGridNum(f+d),r.layout.h=n.toGridNum(v-d)):"right"===o?r.layout.w=n.toGridNum(g+c):"bottom"===o?r.layout.h=n.toGridNum(v+d):"left"===o?"relative"===y?(r.layout.w=n.toGridNum(g-c),a.scroll({moveX:l})):(r.layout.x=n.toGridNum(u+c),r.layout.w=n.toGridNum(g-c)):"top-left"===o?"relative"===y?(r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v-d),a.scroll({moveX:l,moveY:s})):(r.layout.x=n.toGridNum(u+c),r.layout.y=n.toGridNum(f+d),r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v-d)):"top-right"===o?"relative"===y?(a.scroll({moveY:s}),r.layout.w=n.toGridNum(g+c),r.layout.h=n.toGridNum(v-d)):(r.layout.y=n.toGridNum(f+d),r.layout.w=n.toGridNum(g+c),r.layout.h=n.toGridNum(v-d)):"bottom-right"===o?(r.layout.w=n.toGridNum(g+c),r.layout.h=n.toGridNum(v+d)):"bottom-left"===o&&("relative"===y?(a.scroll({moveX:l}),r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v+d)):(r.layout.x=n.toGridNum(u+c),r.layout.w=n.toGridNum(g-c),r.layout.h=n.toGridNum(v+d)))}return h=e.point,m(),a.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{i.setSharedStorage(Ho,!1);const e=i.getSharedStorage(Bo),t=i.getSharedStorage(Fo),o=i.getActiveStorage("data");if(o&&"resize"===e&&t&&r.trigger(qi.CHANGE,{type:"dragLayout",data:o}),i.setSharedStorage(Bo,null),i.setSharedStorage(Fo,null),!0===i.getSharedStorage(Vo))return!1},beforeDrawFrame:({snapshot:e})=>{var t;if(f())return;const{activeColor:i}=s,o={activeColor:i},{sharedStore:n,activeStore:a}=e,r=n[Bo],h=n[No],c=n[Xo];if(null==(t=a.data)?void 0:t.layout){const{x:t,y:i,w:n,h:s}=a.data.layout,d=at(e),u={x:t,y:i,w:n,h:s},f=Yt(u,{viewScaleInfo:d,controllerSize:10});if(!0===h){const e=Pt(u,{viewScaleInfo:d});!function(e,t){const{layoutSize:i,style:o}=t,{activeColor:n}=o,{x:a,y:r,w:l,h:s}=i;e.setLineDash([]),e.strokeStyle=n,e.lineWidth=1,e.beginPath(),e.moveTo(a,r),e.lineTo(a+l,r),e.lineTo(a+l,r+s),e.lineTo(a,r+s),e.lineTo(a,r),e.closePath(),e.stroke()}(l,{layoutSize:e,style:o})}(r&&["resize"].includes(r)||!0===c)&&function(e,t){const{controller:i,style:o}=t,{topLeft:n,topRight:a,bottomLeft:r,bottomRight:l,topMiddle:s,rightMiddle:h,bottomMiddle:c,leftMiddle:d}=i;Uo(e,{start:n.center,end:a.center,centerVertexes:s.vertexes,style:o}),Uo(e,{start:a.center,end:l.center,centerVertexes:h.vertexes,style:o}),Uo(e,{start:l.center,end:r.center,centerVertexes:c.vertexes,style:o}),Uo(e,{start:r.center,end:n.center,centerVertexes:d.vertexes,style:o}),Qo(e,n.vertexes,o),Qo(e,a.vertexes,o),Qo(e,l.vertexes,o),Qo(e,r.vertexes,o)}(l,{controller:f,style:o})}},scrollX:()=>{u()},scrollY:()=>{u()},wheelScale:()=>{u()}}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:o}=e,n=t.boardContext.canvas,a=e.container||document.body,r=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`,l=document.createElement("div");return l.setAttribute("id",r),l.style.position="fixed",l.style.top="0",l.style.bottom="unset",l.style.left="0",l.style.right="unset",a.appendChild(l),{name:"@middleware/pointer",use(){},disuse(){},pointStart(e){},pointEnd(){},contextMenu(e){const{point:t}=e,{left:a,top:r}=(()=>{const e=n.getBoundingClientRect(),{left:t,top:i,width:o,height:a}=e;return{left:t,top:i,width:o,height:a}})();l.style.left=`${a+t.x}px`,l.style.top=`${r+t.y}px`;const s=o.getSharedStorage(lo);i.trigger(qi.CONTEXT_MENU,{pointerContainer:l,selectedElements:s||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:o,eventHub:n,calculator:a}=e,{overlayContext:r,underlayContext:l}=i;let s={...mn,...t},h=!0,c=!0;const d=e=>{"boolean"==typeof(null==e?void 0:e.show)&&(h=e.show),"boolean"==typeof(null==e?void 0:e.showGrid)&&(c=e.showGrid),"boolean"!=typeof(null==e?void 0:e.show)&&"boolean"!=typeof(null==e?void 0:e.showGrid)||o.drawFrame()};return{name:"@middleware/ruler",use(){n.on(qi.RULER,d)},disuse(){n.off(qi.RULER,d)},resetConfig(e){s={...s,...e}},beforeDrawFrame:({snapshot:e})=>{const{background:t,borderColor:i,scaleColor:o,textColor:n,gridColor:d,gridPrimaryColor:u,selectedAreaColor:f}=s,g={background:t,borderColor:i,scaleColor:o,textColor:n,gridColor:d,gridPrimaryColor:u,selectedAreaColor:f};if(!0===h){const t=at(e),i=rt(e);!function(e,t){const{snapshot:i,calculator:o,style:n}=t,{sharedStore:a}=i,{selectedAreaColor:r}=n,l=a[lo],s=a[to];if(["select","drag","drag-list","drag-list-end"].includes(s)&&l.length>0){const t=at(i),n=rt(i),a=[],s=[],h=[],c=[],d=[];if(l.forEach((e=>{const i=o.calcViewRectInfoFromRange(e.uuid,{viewScaleInfo:t,viewSizeInfo:n});i&&(a.push(i),s.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))})),!(a.length>0))return;const u=Math.min(...s),f=Math.max(...h),g=Math.min(...c),v=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(u,0),e.lineTo(f,0),e.lineTo(f,gn),e.lineTo(u,gn),e.fillStyle=r,e.closePath(),e.fill(),e.beginPath(),e.moveTo(0,g),e.lineTo(gn,g),e.lineTo(gn,v),e.lineTo(0,v),e.fillStyle=r,e.closePath(),e.fill()}}(r,{snapshot:e,calculator:a,style:g}),function(e,t){const{viewSizeInfo:i,style:o}=t,{width:n,height:a}=i,{background:r,borderColor:l}=o;e.beginPath();const s=-1;e.moveTo(s,s),e.lineTo(n+1,s),e.lineTo(n+1,gn),e.lineTo(gn,gn),e.lineTo(gn,a+1),e.lineTo(s,a+1),e.lineTo(s,s),e.closePath(),e.fillStyle=r,e.fill(),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=l,e.stroke()}(r,{viewSizeInfo:i,style:g});const{list:o,rulerUnit:n}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:n}=t,{width:a}=i;return pn({scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<gn||(e.beginPath(),e.moveTo(o.position,16),e.lineTo(o.position,o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8),e.closePath(),e.lineWidth=1,e.setLineDash([]),e.fillStyle=n,e.stroke(),o.isKeyNum&&(e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:vn}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(r,{scaleList:o,style:g});const{list:s}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:n}=t,{height:a}=i;return pn({scale:o,viewLength:a,viewOffset:n})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,style:o}=t,{scaleColor:n,textColor:a}=o,r=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<gn)&&(e.beginPath(),e.moveTo(16,o.position),e.lineTo(o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8,o.position),e.closePath(),e.fillStyle=n,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=r,i=o.position+r,n=`${o.num}`;st(e,-90,{x:t,y:i},(()=>{e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:vn}),e.fillText(n,13.2,o.position+r)}))}}}(r,{scaleList:s,style:g}),!0===c){!function(e,t){const{xList:i,yList:o,viewSizeInfo:n,style:a}=t,{width:r,height:l}=n,{gridColor:s,gridPrimaryColor:h}=a;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,l),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.closePath(),e.lineWidth=1,e.setLineDash([]),e.stroke()}for(let t=0;t<o.length;t++){const i=o[t];e.beginPath(),e.moveTo(0,i.position),e.lineTo(r,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=s,e.lineWidth=1,e.closePath(),e.stroke()}}(1===n?r:l,{xList:o,yList:s,viewSizeInfo:i,style:g})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:o}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:n,point:a}=e,{scale:r}=i.getActiveViewScaleInfo();let l=r;if(n<0?l=1.1*r:n>0&&(l=.9*r),l<.05||l>50)return;const{moveX:s,moveY:h}=t.scale({scale:l,point:a});t.scroll({moveX:s,moveY:h}),t.drawFrame();const c=Ft(r);o.trigger(qi.SCALE,{scale:c})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,boardContent:o,sharer:n,eventHub:a}=e,{overlayContext:r}=o;n.setSharedStorage(tn,null),n.setSharedStorage(on,null);let l=!1,s={...hn,...t};const h=()=>{n.setSharedStorage(rn,null),n.setSharedStorage(ln,null),n.setSharedStorage(sn,null),n.setSharedStorage(nn,null),n.setSharedStorage(an,null),l=!1};h();const c=e=>function(e,t,i){let o=null;const{xThumbRect:n,yThumbRect:a}=i;return n&&cn(e,t,n)?o="X":a&&cn(e,t,a)&&(o="Y"),o}(r,e,{xThumbRect:n.getSharedStorage(tn),yThumbRect:n.getSharedStorage(on)});return{name:"@middleware/scroller",resetConfig(e){s={...s,...e}},wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),i.drawFrame()},hover:e=>{if(!0===l)return!1;const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return"X"===i?(n.setSharedStorage(nn,!0),n.setSharedStorage(an,!1)):(n.setSharedStorage(nn,!1),n.setSharedStorage(an,!0)),a.trigger(qi.CURSOR,{type:"default"}),!1;n.setSharedStorage(nn,!1),n.setSharedStorage(an,!1)},pointStart:e=>{const{point:t}=e,i=c(t);if("X"===i||"Y"===i)return l=!0,n.setSharedStorage(sn,i),n.setSharedStorage(rn,t),!1},pointMove:e=>{const{point:t}=e,o=n.getSharedStorage(sn);if("X"===o||"Y"===o)return n.setSharedStorage(ln,t),"X"===o?(e=>{const t=n.getSharedStorage(rn);if(t){const{offsetLeft:o,offsetRight:a}=n.getActiveViewScaleInfo(),{width:r}=n.getActiveViewSizeInfo(),l=-(e.x-t.x)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveX:l}),i.drawFrame()}})(t):"Y"===o&&(e=>{const t=n.getSharedStorage(rn);if(t){const{offsetTop:o,offsetBottom:a}=n.getActiveViewScaleInfo(),{height:r}=n.getActiveViewSizeInfo(),l=-(e.y-t.y)*(r+Math.abs(o)+Math.abs(a))/r;i.scroll({moveY:l}),i.drawFrame()}})(t),n.setSharedStorage(rn,t),!1},pointEnd:()=>{l=!1;const e=n.getSharedStorage(sn);if(h(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),i.drawFrame(),!1},beforeDrawFrame({snapshot:e}){const{thumbBackground:t,thumbBorderColor:i,hoverThumbBackground:o,hoverThumbBorderColor:a,activeThumbBackground:l,activeThumbBorderColor:h}=s,c={thumbBackground:t,thumbBorderColor:i,hoverThumbBackground:o,hoverThumbBorderColor:a,activeThumbBackground:l,activeThumbBorderColor:h},{xThumbRect:d,yThumbRect:u}=fn(r,{snapshot:e,style:c});n.setSharedStorage(tn,d),n.setSharedStorage(on,u)}}},e.MiddlewareSelector=(e,t)=>{let i={...yo,...t};const{viewer:o,sharer:n,boardContent:a,calculator:r,eventHub:l}=e,{overlayContext:s}=a;let h=null,c=null,d=null,u=null,f=null,g=$o({fill:i.activeColor,devicePixelRatio:n.getActiveViewSizeInfo().devicePixelRatio});n.setSharedStorage(to,null),n.setSharedStorage(mo,!0);const v=()=>n.getSharedStorage(lo),m=e=>{let t=n.getSharedStorage(uo);Array.isArray(t)||(t=[]),t.length>0?!function(e,t){var i;if("group"===(null==t?void 0:t.type)&&Array.isArray(null==(i=null==t?void 0:t.detail)?void 0:i.children))for(let i=0;i<t.detail.children.length;i++){const o=t.detail.children[i];if(e.uuid===o.uuid)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e);const i=zt(t);return n.setSharedStorage(uo,t),n.setSharedStorage(fo,i),t.length>0},y=e=>{n.setSharedStorage(ao,e);let t=null;e&&(t=Ct(e,{groupQueue:n.getSharedStorage(uo)})),n.setSharedStorage(ro,t)},p=()=>{const e=n.getSharedStorage(lo);if(1===e.length){const t=jt(e[0],{groupQueue:n.getSharedStorage(uo),controllerSize:10,viewScaleInfo:n.getActiveViewScaleInfo(),rotateControllerPosition:22,rotateControllerSize:20});n.setSharedStorage(ho,t)}},w=(e,t)=>{var i;if(n.setSharedStorage(lo,e),1===e.length?(p(),n.setSharedStorage(co,It(e[0].uuid,(null==(i=n.getActiveStorage("data"))?void 0:i.elements)||[]))):(n.setSharedStorage(ho,null),n.setSharedStorage(co,[])),!0===(null==t?void 0:t.triggerEvent)){const t=e.map((e=>e.uuid)),i=n.getActiveStorage("data"),o=function(e,t){const i=[],o={};let n=!1;const a=t=>{var r;for(let l=0;l<t.length&&!0!==n;l++){i.push(l);const s=t[l];if(e.includes(s.uuid)){if(o[s.uuid]=[...i],Object.keys(o).length===e.length){n=!0;break}}else"group"===s.type&&a((null===(r=null==s?void 0:s.detail)||void 0===r?void 0:r.children)||[]);if(n)break;i.pop()}};return a(t),o}(t,(null==i?void 0:i.elements)||[]);l.trigger(qi.SELECT,{type:"clickCanvas",uuids:t,positions:e.map((e=>[...o[e.uuid]]))})}},x=()=>({ctx:s,calculator:r,data:n.getActiveStorage("data"),selectedElements:v(),viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(uo),areaSize:null,selectedElementController:n.getSharedStorage(ho),selectedElementPosition:n.getSharedStorage(co)}),S=()=>{n.setSharedStorage(to,null),n.setSharedStorage(io,null),n.setSharedStorage(oo,null),n.setSharedStorage(no,null),n.setSharedStorage(uo,[]),n.setSharedStorage(fo,[]),n.setSharedStorage(ao,null),n.setSharedStorage(ro,null),n.setSharedStorage(lo,[]),n.setSharedStorage(so,null),n.setSharedStorage(ho,null),n.setSharedStorage(co,[]),n.setSharedStorage(go,null)};S();const b=({uuids:e=[],positions:t})=>{let i=[];const a=n.getSharedStorage(to),r=n.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach((e=>{const o=At(e,t);o&&i.push(o)})),i}(t,(null==r?void 0:r.elements)||[]):function(e,t){const i=[];return function t(o){var n;for(let a=0;a<o.length;a++){const r=o[a];e.includes(r.uuid)?i.push(r):"group"===r.type&&t((null===(n=null==r?void 0:r.detail)||void 0===n?void 0:n.children)||[])}}(t),i}(e,(null==r?void 0:r.elements)||[]);let l=!1;if(a||1!==i.length?"select"===a&&1===i.length&&(l=!0):(n.setSharedStorage(to,"select"),l=!0),l){const e=function(e,t){const i=[];return function e(t,o){var n;let a=null;for(let r=0;r<o.length;r++){const l=o[r];if(l.uuid===t){a=l;break}if(!a&&"group"===l.type){i.push(l);const o=e(t,(null===(n=null==l?void 0:l.detail)||void 0===n?void 0:n.children)||[]);if((null==o?void 0:o.uuid)===t){a=o;break}i.pop()}}return a}(e,t),i}(i[0].uuid,(null==r?void 0:r.elements)||[]);n.setSharedStorage(uo,e),w(i),o.drawFrame()}},A=()=>{S(),o.drawFrame()},I=e=>{n.setSharedStorage(mo,!!e.enable)},M=e=>{n.setSharedStorage(vo,!!e.enable)};return{name:"@middleware/selector",use(){l.on(qi.SELECT,b),l.on(qi.CLEAR_SELECT,A),l.on(qi.SELECT_IN_GROUP,M),l.on(qi.SNAP_TO_GRID,I)},disuse(){l.off(qi.SELECT,b),l.off(qi.CLEAR_SELECT,A),l.off(qi.SELECT_IN_GROUP,M),l.off(qi.SNAP_TO_GRID,I)},resetConfig(e){i={...i,...e}},hover:e=>{var t,i,a,r,h;const c=n.getSharedStorage(Xo);if(!0===n.getSharedStorage(Ho))return;const d=n.getSharedStorage(io),f=n.getSharedStorage(to),g=n.getSharedStorage(uo),m=e=>{if(!0===c)return;const t=e.type;null===u&&l.trigger(qi.CURSOR,{type:t,groupQueue:e.groupQueue,element:e.elements[0]})};if((null==g?void 0:g.length)>0){if(!To(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:n.getSharedStorage(uo)}))return y(null),void o.drawFrame();const i=Eo(e.point,x());return m(i),d||["area","drag","drag-list"].includes(f)?(y(null),void o.drawFrame()):1===(null==(t=null==i?void 0:i.elements)?void 0:t.length)?(y(i.elements[0]),void o.drawFrame()):(y(null),void o.drawFrame())}if(d||["area","drag","drag-list"].includes(f))return void y(null);if("drag"===f)return void y(null);const p=v(),w=n.getActiveViewScaleInfo();n.getActiveViewSizeInfo();const S=Eo(e.point,{...x(),areaSize:Lo(p,{viewScaleInfo:w})});if(m(S),null!==S.type){if(!("over-element"===S.type&&"select"===n.getSharedStorage(to)&&1===S.elements.length&&S.elements[0].uuid===(null==(a=null==(i=v())?void 0:i[0])?void 0:a.uuid)||"over-element"===S.type&&null===n.getSharedStorage(to)&&1===S.elements.length&&S.elements[0].uuid===(null==(r=n.getSharedStorage(ao))?void 0:r.uuid)))return"over-element"===S.type&&1===(null==(h=null==S?void 0:S.elements)?void 0:h.length)?(y(S.elements[0]),void o.drawFrame()):n.getSharedStorage(ao)?(y(null),void o.drawFrame()):void 0}else(n.getSharedStorage(ao)||n.getSharedStorage(ro))&&(n.setSharedStorage(ao,null),n.setSharedStorage(ro,null),o.drawFrame())},pointStart:e=>{var t,i,a,r,l,u,f,g,m,p,b,A;h=e.point,c=e.point;const I=n.getSharedStorage(uo);if((null==I?void 0:I.length)>0){if(To(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:I})){const o=Eo(e.point,x()),s=1===(null==(t=null==o?void 0:o.elements)?void 0:t.length)&&!0===(null==(a=null==(i=o.elements[0])?void 0:i.operations)?void 0:a.locked);y(null),1===(null==(r=null==o?void 0:o.elements)?void 0:r.length)&&(d=bt(null==o?void 0:o.elements[0])),!0===s?S():"over-element"===o.type&&1===(null==(l=null==o?void 0:o.elements)?void 0:l.length)?(w([o.elements[0]],{triggerEvent:!0}),n.setSharedStorage(to,"drag")):(null==(u=o.type)?void 0:u.startsWith("resize-"))?(n.setSharedStorage(io,o.type),n.setSharedStorage(to,"resize")):w([],{triggerEvent:!0})}else S();return void o.drawFrame()}const M=Lo(v(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),R=Eo(e.point,{...x(),areaSize:M,groupQueue:[]}),z=1===(null==(f=null==R?void 0:R.elements)?void 0:f.length)&&!0===(null==(m=null==(g=R.elements[0])?void 0:g.operations)?void 0:m.locked);y(null),1===(null==(p=null==R?void 0:R.elements)?void 0:p.length)&&(d=bt(null==R?void 0:R.elements[0])),!0===z?(S(),n.setSharedStorage(to,"area"),n.setSharedStorage(oo,e.point),w([],{triggerEvent:!0})):"list-area"===R.type?n.setSharedStorage(to,"drag-list"):"over-element"===R.type&&1===(null==(b=null==R?void 0:R.elements)?void 0:b.length)?(w([R.elements[0]],{triggerEvent:!0}),n.setSharedStorage(to,"drag")):(null==(A=R.type)?void 0:A.startsWith("resize-"))?(n.setSharedStorage(io,R.type),n.setSharedStorage(to,"resize")):(S(),n.setSharedStorage(to,"area"),n.setSharedStorage(oo,e.point),w([],{triggerEvent:!0})),o.drawFrame()},pointMove:e=>{var t,i,a;n.setSharedStorage(go,!0);const s=n.getActiveStorage("data"),g=v(),m=n.getActiveStorage("scale")||1,y=n.getActiveViewScaleInfo(),p=n.getActiveViewSizeInfo(),x=h,S=c,b=e.point,A=n.getSharedStorage(io),I=n.getSharedStorage(to),M=n.getSharedStorage(uo),R=n.getSharedStorage(mo);if("drag"===I){if(f=!0,u="drag",l.trigger(Ko,{show:!1}),s&&1===(null==g?void 0:g.length)&&d&&S&&b&&!0!==(null==(i=null==(t=g[0])?void 0:t.operations)?void 0:i.locked)){const{moveX:e,moveY:t}=function(e,t,i){let o=t.x-e.x,n=t.y-e.y;const a=[];if(i.forEach((e=>{const{x:t,y:i,w:o,h:n,angle:r=0}=e;a.push({x:t,y:i,w:o,h:n,angle:0-r})})),(null==i?void 0:i.length)>0){const i=gt(e,a),r=gt(t,a);o=r.x-i.x,n=r.y-i.y}return{moveX:o,moveY:n}}(S,b,M);let i=r.toGridNum(e/m),o=r.toGridNum(t/m);if(!0===R){const e=jo(g[0].uuid,{calculator:r,data:s,groupQueue:M,viewScaleInfo:y,viewSizeInfo:p});try{e&&(Be.x(e.offsetX)&&null!==e.offsetX&&(i=r.toGridNum(i+e.offsetX)),Be.y(e.offsetY)&&null!==e.offsetY&&(o=r.toGridNum(o+e.offsetY)))}catch(e){console.error(e)}}g[0].x=r.toGridNum(d.x+i),g[0].y=r.toGridNum(d.y+o),w([g[0]]),r.modifyVirtualFlatItemMap(s,{modifyOptions:{type:"updateElement",content:{element:g[0],position:n.getSharedStorage(co)||[]}},viewSizeInfo:p,viewScaleInfo:y})}o.drawFrame()}else if("drag-list"===I){if(f=!0,u="drag-list",s&&S&&x&&b&&(null==g?void 0:g.length)>1){const e=(b.x-x.x)/m,t=(b.y-x.y)/m;g.forEach((i=>{var o;i&&!0!==(null==(o=null==i?void 0:i.operations)?void 0:o.locked)&&(i.x=r.toGridNum(i.x+e),i.y=r.toGridNum(i.y+t),r.modifyVirtualFlatItemMap(s,{modifyOptions:{type:"updateElement",content:{element:i,position:It(i.uuid,s.elements)||[]}},viewSizeInfo:p,viewScaleInfo:y}))})),n.setActiveStorage("data",s)}o.drawFrame()}else if("resize"===I){if(s&&1===(null==g?void 0:g.length)&&S&&d&&(null==A?void 0:A.startsWith("resize-"))){f=!0,u="resize";const e=[];M.forEach((t=>{const{x:i,y:o,w:n,h:a,angle:r=0}=t;e.push({x:i,y:o,w:n,h:a,angle:0-r})}));let t=S,i=b;if(M.length>0&&(t=gt(S,e),i=gt(b,e)),"resize-rotate"===A){const e=n.getSharedStorage(ho),t=dt([e.topLeft.center,e.topRight.center,e.bottomLeft.center,e.bottomRight.center]),i=ko(d,{center:t,viewScaleInfo:y,start:S,end:b});g[0].angle=r.toGridNum(i.angle||0)}else{const e=function(e,t){var i,o,n,a,r,l,s,h,c;let{x:d,y:u,w:f,h:g,angle:v=0}=e;const m=ct({x:d,y:u,w:f,h:g});v=pt(v);const y=lt(v),p=!!(null==(i=null==e?void 0:e.operations)?void 0:i.limitRatio),{start:w,end:x,resizeType:S,scale:b}=t;let A={...w},I={...x},M={x:A.x,y:m.y},R={x:I.x,y:m.y},z={...M},C={...R},P={x:m.x,y:A.y},T={x:m.x,y:I.y},E={...P},k={...T},L=(C.x-z.x)/b,W=(C.y-z.y)/b,O=zo(L,W),D=(k.x-E.x)/b,j=(k.y-E.y)/b,Y=zo(D,j);(v>0||v<0)&&(A=ft(m,w,0-y),I=ft(m,x,0-y),M={x:A.x,y:m.y},R={x:I.x,y:m.y},z=ft(m,M,y),C=ft(m,R,y),P={x:m.x,y:A.y},T={x:m.x,y:I.y},E=ft(m,P,y),k=ft(m,T,y),L=(C.x-z.x)/b,W=(C.y-z.y)/b,O=zo(L,W),O=Co(O,W),D=(k.x-E.x)/b,j=(k.y-E.y)/b,Y=zo(D,j),Y=Co(Y,j));let B=(x.x-w.x)/b,F=(x.y-w.y)/b;if(!0===p)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(S)){const t=Math.max(Math.abs(B),Math.abs(F));B=(B>=0?1:-1)*t,F=(F>=0?1:-1)*t/e.w*e.h;const i=Math.max(Math.abs(D),Math.abs(j));D=(D>=0?1:-1)*i,j=(j>=0?1:-1)*i/e.w*e.h;const o=Math.max(Math.abs(L),Math.abs(W));L=(L>=0?1:-1)*o,W=(W>=0?1:-1)*o/e.w*e.h}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(S)){{const t=Math.abs(B);B=(B>=0?1:-1)*t;const i=t/e.w*e.h;"resize-top-left"===S||"resize-bottom-right"===S?F=B>0?i:-i:"resize-top-right"!==S&&"resize-bottom-left"!==S||(F=B>0?-i:i)}O=Math.abs(O),Y=O/e.w*e.h}switch(S){case"resize-top":if(0===v)g-F>0&&(u+=F,g-=F,!0===(null==(o=e.operations)?void 0:o.limitRatio)&&(d+=F/e.h*e.w/2,f-=F/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=0-Co(Y,j);const e=Ro(v),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<180){Y=Co(Y,D);const e=Ro(v-90),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<270){Y=Co(Y,j);const e=Ro(v-180),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<360){Y=0-Co(Y,D);const e=Ro(v-270),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}g+Y>0&&(!0===(null==(n=e.operations)?void 0:n.limitRatio)&&(f+=Y/e.h*e.w),g+=Y,d=t-f/2,u=i-g/2)}break;case"resize-bottom":if(0===v)e.h+F>0&&(g+=F,!0===(null==(a=e.operations)?void 0:a.limitRatio)&&(d-=F/e.h*e.w/2,f+=F/e.h*e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){Y=Co(Y,j);const e=Ro(v),o=Y/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<180){Y=0-Co(Y,D);const e=Ro(v-90),o=Y/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<270){Y=Co(Y,D);const e=Ro(v-180),o=Y/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<360){Y=Co(Y,D);const e=Ro(v-270),o=Y/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}g+Y>0&&(!0===(null==(r=e.operations)?void 0:r.limitRatio)&&(f+=Y/e.h*e.w),g+=Y,d=t-f/2,u=i-g/2)}break;case"resize-left":if(0===v)e.w-B>0&&(d+=B,f-=B,!0===(null==(l=e.operations)?void 0:l.limitRatio)&&(g-=B/e.w*e.h,u+=B/e.w*e.h/2));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=0-Co(O,L);const e=Ro(v),o=O/2;t-=o*Math.cos(e),i-=o*Math.sin(e)}else if(v<180){O=Co(O,L);const e=Ro(v-90),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}else if(v<270){O=Co(O,W);const e=Ro(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<360){O=Co(O,W);const e=Ro(v-270),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}f+O>0&&(!0===(null==(s=e.operations)?void 0:s.limitRatio)&&(g+=O/e.w*e.h),f+=O,d=t-f/2,u=i-g/2)}break;case"resize-right":if(0===v)e.w+B>0&&(f+=B,!0===(null==(h=e.operations)?void 0:h.limitRatio)&&(u-=B*e.h/e.w/2,g+=B*e.h/e.w));else if(v>0||v<0){let t=m.x,i=m.y;if(v<90){O=Co(O,W);const e=Ro(v),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e)}else if(v<180){O=Co(O,F);const e=Ro(v-90),o=O/2;t-=o*Math.sin(e),i+=o*Math.cos(e)}else if(v<270){O=Co(O,F);const e=Ro(v-180),o=O/2;t+=o*Math.cos(e),i+=o*Math.sin(e),O=0-O}else if(v<360){O=Co(O,B);const e=Ro(v-270),o=O/2;t+=o*Math.sin(e),i-=o*Math.cos(e)}f+O>0&&(!0===(null==(c=e.operations)?void 0:c.limitRatio)&&(g+=O/e.w*e.h),f+=O,d=t-f/2,u=i-g/2)}break;case"resize-top-left":if(0===v)f-B>0&&(d+=B,f-=B),g-F>0&&(u+=F,g-=F);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Co(Y,j),O=0-Co(O,p?0-Y:L);const i=Y/2;e+=i*Math.sin(y),t-=i*Math.cos(y);const o=O/2;e-=o*Math.cos(y),t-=o*Math.sin(y)}else if(v<180){Y=Co(Y,D),O=Co(O,p?Y:L);const i=Ro(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Co(Y,j),O=Co(O,p?Y:W);const i=Ro(v-180),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=0-Co(Y,D),O=Co(O,p?Y:W);const i=Ro(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),f+O>0&&(f+=O),d=e-f/2,u=t-g/2}break;case"resize-top-right":if(0===v)f+B>0&&(f+=B),g-F>0&&(u+=F,g-=F);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=0-Co(Y,j),O=Co(O,p?Y:W);const i=Ro(v),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=Co(Y,D),O=Co(O,p?Y:W);const i=Ro(v-90),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){const i=Ro(v-180);Y=Co(Y,j),O=Co(O,p?Y:0-L);const o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=0-Co(Y,D),O=Co(O,p?Y:L);const i=Ro(v-270),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),f+O>0&&(f+=O),d=e-f/2,u=t-g/2}break;case"resize-bottom-left":if(0===v)e.h+F>0&&(g+=F),e.w-B>0&&(d+=B,f-=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Co(Y,j),O=0-Co(O,p?0-Y:L);const i=Ro(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<180){Y=0-Co(Y,D),O=Co(O,p?Y:L);const i=Ro(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}else if(v<270){Y=Co(Y,D),O=Co(O,p?Y:W);const i=Ro(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<360){Y=Co(Y,D),O=Co(O,p?Y:W);const i=Ro(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}g+Y>0&&(g+=Y),f+O>0&&(f+=O),d=e-f/2,u=t-g/2}break;case"resize-bottom-right":if(0===v)e.h+F>0&&(g+=F),e.w+B>0&&(f+=B);else if(v>0||v<0){let e=m.x,t=m.y;if(v<90){Y=Co(Y,j),O=Co(O,p?Y:W);const i=Ro(v),o=Y/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const n=O/2;e+=n*Math.cos(i),t+=n*Math.sin(i)}else if(v<180){Y=0-Co(Y,D),O=Co(O,p?Y:F);const i=Ro(v-90),o=Y/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const n=O/2;e-=n*Math.sin(i),t+=n*Math.cos(i)}else if(v<270){Y=Co(Y,D),O=Co(O,p?Y:0-W);const i=Ro(v-180),o=Y/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const n=O/2;e-=n*Math.cos(i),t-=n*Math.sin(i)}else if(v<360){Y=Co(Y,D),O=Co(O,p?Y:L);const i=Ro(v-270),o=Y/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const n=O/2;e+=n*Math.sin(i),t-=n*Math.cos(i)}g+Y>0&&(g+=Y),f+O>0&&(f+=O),d=e-f/2,u=t-g/2}}return{x:d,y:u,w:f,h:g,angle:e.angle}}({...d,operations:g[0].operations},{scale:m,start:t,end:i,resizeType:A}),o={ignore:!!d.angle};g[0].x=r.toGridNum(e.x,o),g[0].y=r.toGridNum(e.y,o),"group"===g[0].type&&!0===(null==(a=g[0].operations)?void 0:a.deepResize)?function(e,t){const i=t.w&&t.w>0?t.w:e.w,o=t.h&&t.h>0?t.h:e.h,n=i/e.w,a=o/e.h;if(n===a&&1===n)return e;const r=Math.min(n,a),l=Math.max(n,a);e.w=i,e.h=o;const s={xRatio:n,yRatio:a,minRatio:r,maxRatio:l};"group"===e.type&&Array.isArray(e.detail.children)&&e.detail.children.forEach((e=>{Ht(e,s)})),Xt(e,s)}(g[0],{w:r.toGridNum(e.w,o),h:r.toGridNum(e.h,o)}):(g[0].w=r.toGridNum(e.w,o),g[0].h=r.toGridNum(e.h,o))}w([g[0]]),r.modifyVirtualFlatItemMap(s,{modifyOptions:{type:"updateElement",content:{element:g[0],position:n.getSharedStorage(co)||[]}},viewSizeInfo:p,viewScaleInfo:y}),o.drawFrame()}}else"area"===I&&(u="area",n.setSharedStorage(no,e.point),o.drawFrame());h=e.point},pointEnd(e){u=null,n.setSharedStorage(go,!1);const t=n.getActiveStorage("data"),i=n.getSharedStorage(lo),a=n.getSharedStorage(ao),s=n.getSharedStorage(io),g=n.getSharedStorage(to),v=n.getActiveViewSizeInfo();let m=!1;if(h=null,c=null,d=null,"drag"===g&&l.trigger(Ko,{show:!0}),"resize"===g&&s)n.setSharedStorage(io,null),m=!0;else if("area"===g){if(n.setSharedStorage(to,null),t){const e=n.getSharedStorage(oo),i=n.getSharedStorage(no);if(e&&i){const{elements:o}=function(e,t){var i;const o=[],n=[],a=[],{viewScaleInfo:r,start:l,end:s}=t;if(!(Array.isArray(e.elements)&&l&&s))return{indexes:o,uuids:n,elements:a};const h=Math.min(l.x,s.x),c=Math.max(l.x,s.x),d=Math.min(l.y,s.y),u=Math.max(l.y,s.y);for(let t=0;t<e.elements.length;t++){const l=e.elements[t];if(!0===(null==(i=null==l?void 0:l.operations)?void 0:i.locked))continue;const s=Pt(l,{viewScaleInfo:r}),f=ct(s);if(f.x>=h&&f.x<=c&&f.y>=d&&f.y<=u&&(o.push(t),n.push(l.uuid),a.push(l),s.angle&&(s.angle>0||s.angle<0))){const e=mt(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.w=Math.abs(Math.max(...t)-Math.min(...t)),s.h=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:o,uuids:n,elements:a}}(t,{start:e,end:i,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()});o.length>0&&(n.setSharedStorage(to,"drag-list"),w(o,{triggerEvent:!0}),m=!0)}}}else if("drag-list"===g)n.setSharedStorage(to,"drag-list-end"),m=!0;else if(t){r.getPointElement(e.point,{data:t,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}).element?(n.setSharedStorage(to,"select"),m=!0):n.setSharedStorage(to,null)}null===n.getSharedStorage(to)&&(S(),m=!0);(()=>{if(m){if(t&&Array.isArray(null==t?void 0:t.elements)&&["drag","drag-list"].includes(g)){const e=function(e,t,i){const o=xt(e,{viewWidth:t.width,viewHeight:t.height,extend:null==i?void 0:i.extend});return!0===(null==i?void 0:i.extend)&&(o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight)),{contextSize:o}}(t.elements,v,{extend:!0});n.setActiveStorage("contextHeight",e.contextSize.contextHeight),n.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(g)){let e="dragElement";f&&(l.trigger(qi.CHANGE,{data:t,type:e,selectedElements:i,hoverElement:a}),f=!1)}o.drawFrame()}})()},pointLeave(){u=null,n.setSharedStorage(io,null),l.trigger(qi.CURSOR,{type:"default"})},doubleClick(e){var t,i,a,r,s,h,c,d;if(!1===n.getSharedStorage(vo))return;const u=Eo(e.point,x());if(n.setSharedStorage(ho,null),n.setSharedStorage(lo,[]),1!==u.elements.length||!0!==(null==(i=null==(t=u.elements[0])?void 0:t.operations)?void 0:i.locked)){if(1===u.elements.length&&"group"===(null==(a=u.elements[0])?void 0:a.type)){if(!0===m(u.elements[0]))return n.setSharedStorage(to,null),void o.drawFrame()}else 1!==u.elements.length||"text"!==(null==(r=u.elements[0])?void 0:r.type)||(null==(h=null==(s=u.elements[0])?void 0:s.operations)?void 0:h.invisible)||l.trigger(qi.TEXT_EDIT,{element:u.elements[0],groupQueue:n.getSharedStorage(uo)||[],position:It(null==(c=u.elements[0])?void 0:c.uuid,(null==(d=n.getActiveStorage("data"))?void 0:d.elements)||[]),viewScaleInfo:n.getActiveViewScaleInfo()});n.setSharedStorage(to,null)}},wheel(){p()},wheelScale(){p()},contextMenu:e=>{var t,i,a,r,l,h,c,d;const u=n.getSharedStorage(uo);if((null==u?void 0:u.length)>0){if(To(e.point,{ctx:s,viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:u})){const n=Eo(e.point,x());1===(null==(t=null==n?void 0:n.elements)?void 0:t.length)&&!0!==(null==(a=null==(i=n.elements[0])?void 0:i.operations)?void 0:a.locked)?(S(),w([n.elements[0]],{triggerEvent:!0}),o.drawFrame()):(null==(r=null==n?void 0:n.elements)?void 0:r.length)||S()}return}const f=Lo(v(),{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo()}),g=Eo(e.point,{...x(),areaSize:f,groupQueue:[]});if(1===(null==(l=null==g?void 0:g.elements)?void 0:l.length)&&!0!==(null==(c=null==(h=g.elements[0])?void 0:h.operations)?void 0:c.locked))return S(),w([g.elements[0]],{triggerEvent:!0}),void o.drawFrame();(null==(d=null==g?void 0:g.elements)?void 0:d.length)||S()},beforeDrawFrame({snapshot:t}){var o;const{activeColor:n,activeAreaColor:a,lockedColor:l,referenceColor:h}=i,c={activeColor:n,activeAreaColor:a,lockedColor:l,referenceColor:h},{activeStore:d,sharedStore:u}=t,{scale:f,offsetLeft:m,offsetTop:y,offsetRight:p,offsetBottom:w,width:x,height:S,contextHeight:b,contextWidth:A,devicePixelRatio:I}=d;g.fill!==n&&(g=$o({fill:i.activeColor,devicePixelRatio:I}));const M=e.sharer,R={scale:f,offsetLeft:m,offsetTop:y,offsetRight:p,offsetBottom:w},z={width:x,height:S,contextHeight:b,contextWidth:A,devicePixelRatio:I},C=u[lo],P=C[0],T=u[ao],E=u[ro],k=u[to],L=u[oo],W=u[no],O=u[uo],D=u[fo],j=u[go],Y=u[mo],B={calculator:r,viewScaleInfo:R,viewSizeInfo:z,style:c};let F=u[ho];var G,N;F&&1===C.length&&P&&(G=P,N=F.originalElementSize,(G.x!==N.x||G.y!==N.y||G.h!==N.h||G.w!==N.w||pt(G.angle||0)!==pt(N.angle||0))&&(F=jt(P,{groupQueue:O||[],controllerSize:10,viewScaleInfo:R,rotateControllerPosition:22,rotateControllerSize:20}),M.setSharedStorage(ho,F)));const V=!!(null==(o=null==T?void 0:T.operations)?void 0:o.locked);if((null==O?void 0:O.length)>0){if(function(e,t,i){const{style:o}=i,{activeColor:n}=o;for(let o=0;o<t.length;o++){const a={borderColor:n,borderWidth:2,background:"transparent",lineDash:[4,4]};po(e,Et(t[o],i),a)}}(s,D,B),T&&"drag"!==k&&(V?Ao(s,E,{...B,controller:F,style:c}):bo(s,E,B)),P&&["select","drag","resize"].includes(k)&&(Io(s,F,{...B,element:P,hideControllers:!!j&&"drag"===k,rotateControllerPattern:g.context2d,style:c}),"drag"===k&&!0===Y)){const e=jo(P.uuid,{calculator:r,data:d.data,groupQueue:O,viewScaleInfo:R,viewSizeInfo:z});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Mo(s,{xLines:o,yLines:n,style:c})}}}else if(T&&"drag"!==k&&(V?Ao(s,E,{...B,controller:F,style:c}):bo(s,E,B)),P&&["select","drag","resize"].includes(k)){if(Io(s,F,{...B,element:P,hideControllers:!!j&&"drag"===k,rotateControllerPattern:g.context2d,style:c}),"drag"===k&&!0===Y){const e=jo(P.uuid,{calculator:r,data:d.data,groupQueue:O,viewScaleInfo:R,viewSizeInfo:z});if(e){const{offsetX:t,offsetY:i,xLines:o,yLines:n}=e;0!==t&&0!==i||Mo(s,{xLines:o,yLines:n,style:c})}}}else if("area"===k&&L&&W)!function(e,t){const{start:i,end:o,style:n}=t,{activeColor:a,activeAreaColor:r}=n;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=a,e.fillStyle=r,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(o.x,i.y),e.lineTo(o.x,o.y),e.lineTo(i.x,o.y),e.closePath(),e.stroke(),e.fill()}(s,{start:L,end:W,style:c});else if(["drag-list","drag-list-end"].includes(k)){const e=Lo(v(),{viewScaleInfo:M.getActiveViewScaleInfo(),viewSizeInfo:M.getActiveViewSizeInfo()});e&&function(e,t){const{areaSize:i,style:o}=t,{activeColor:n,activeAreaColor:a}=o,{x:r,y:l,w:s,h:h}=i;e.setLineDash([]),e.lineWidth=1,e.strokeStyle=n,e.fillStyle=a,e.beginPath(),e.moveTo(r,l),e.lineTo(r+s,l),e.lineTo(r+s,l+h),e.lineTo(r,l+h),e.closePath(),e.stroke(),e.fill()}(s,{areaSize:e,style:c})}}}},e.MiddlewareTextEditor=e=>{const{eventHub:t,boardContent:i,viewer:o,sharer:n}=e,a=i.boardContext.canvas,r=document.createElement("div");r.setAttribute("contenteditable","true");const l=document.createElement("div"),s=e.container||document.body,h=document.createElement("div");let c=null,d=[];const u=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`;h.setAttribute("id",u),l.appendChild(r),l.style.position="absolute",h.appendChild(l),h.style.position="fixed",h.style.top="0",h.style.bottom="0",h.style.left="0",h.style.right="0",h.style.display="none",s.appendChild(h);const f=()=>{if(null==c?void 0:c.uuid){const e=n.getActiveOverrideElemenentMap();e&&delete e[c.uuid],n.setActiveOverrideElemenentMap(e),o.drawFrame()}h.style.display="none",c=null,d=[]},g=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:n,y:a,w:r,h:l}=t,s=pt(t.angle||0);return o.style.position="absolute",o.style.left=`${n}px`,o.style.top=`${a}px`,o.style.width=`${r}px`,o.style.height=`${l}px`,o.style.transform=`rotate(${s}deg)`,i.appendChild(o),o},v=e=>{const{viewScaleInfo:t,element:i,groupQueue:o}=e,{scale:n,offsetTop:a,offsetLeft:s}=t;l.children&&Array.from(l.children).forEach((e=>{e.remove()}));let h=l;for(let e=0;e<o.length;e++){const t=o[e],{x:i,y:r,w:l,h:c}=t,d={x:i*n,y:r*n,w:l*n,h:c*n,angle:pt(t.angle||0)};0===e&&(d.x+=s,d.y+=a),h=g({size:d,parent:h})}const c={...wn,...i.detail};let d=i.x*n+s,u=i.y*n+a,f=i.w*n,v=i.h*n;o.length>0&&(d=i.x*n,u=i.y*n,f=i.w*n,v=i.h*n);let m="center",y="center";"left"===c.textAlign?m="start":"right"===c.textAlign&&(m="end"),"top"===c.verticalAlign?y="start":"bottom"===c.verticalAlign&&(y="end"),r.style.display="inline-flex",r.style.justifyContent=m,r.style.alignItems=y,r.style.position="absolute",r.style.left=d-1+"px",r.style.top=u-1+"px",r.style.width=`${f+2}px`,r.style.height=`${v+2}px`,r.style.transform=`rotate(${pt(i.angle||0)}deg)`,r.style.boxSizing="border-box",r.style.border="1px solid #1973ba",r.style.resize="none",r.style.overflow="hidden",r.style.wordBreak="break-all",r.style.borderRadius=("number"==typeof c.borderRadius?c.borderRadius:0)*n+"px",r.style.background=`${c.background||"transparent"}`,r.style.color=`${c.color||"#333333"}`,r.style.fontSize=c.fontSize*n+"px",r.style.lineHeight=(c.lineHeight||c.fontSize)*n+"px",r.style.fontFamily=Qt(c.fontFamily),r.style.fontWeight=`${c.fontWeight}`,r.style.padding="0",r.style.margin="0",r.style.outline="none",r.innerText=c.text||"",h.appendChild(r)},m=()=>{const{left:e,top:t,width:i,height:o}=(()=>{const e=a.getBoundingClientRect(),{left:t,top:i,width:o,height:n}=e;return{left:t,top:i,width:o,height:n}})();l.style.position="absolute",l.style.overflow="hidden",l.style.top=`${t}px`,l.style.left=`${e}px`,l.style.width=`${i}px`,l.style.height=`${o}px`};h.addEventListener("click",(()=>{f()})),r.addEventListener("click",(e=>{e.stopPropagation()})),r.addEventListener("input",(()=>{c&&d&&(c.detail.text=r.innerText||"",t.trigger(qi.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d||[]]}),o.drawFrame())})),r.addEventListener("blur",(()=>{c&&d&&t.trigger(qi.TEXT_CHANGE,{element:{uuid:c.uuid,detail:{text:c.detail.text}},position:[...d]}),f()})),r.addEventListener("keydown",(e=>{e.stopPropagation()})),r.addEventListener("keypress",(e=>{e.stopPropagation()})),r.addEventListener("keyup",(e=>{e.stopPropagation()})),r.addEventListener("wheel",(e=>{e.stopPropagation(),e.preventDefault()}));const y=e=>{var t;(null==e?void 0:e.position)&&(null==e?void 0:e.element)&&"text"===(null==(t=null==e?void 0:e.element)?void 0:t.type)&&(c=e.element,d=e.position),(e=>{m(),v(e),h.style.display="block",(null==c?void 0:c.uuid)&&(n.setActiveOverrideElemenentMap({[c.uuid]:{operations:{invisible:!0}}}),o.drawFrame())})(e)};return{name:"@middleware/text-editor",use(){t.on(qi.TEXT_EDIT,y)},disuse(){t.off(qi.TEXT_EDIT,y)}}},e.Sharer=Hi,e.coreEventKeys=qi,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});